import { License } from "./license";
import { NeedlePWAOptions } from "./webmanifest.js";

export type needleModules = {
    webpack: object | undefined
}

/**
 * Settings for the Needle plugin
 */
export type userSettings = {

    /** disable needle asap plugin */
    noAsap?: boolean;

    /** disable vite.alias modification */
    noAlias?: boolean;
    /**
     * When set to `true` a plugin will log all alias resolutions to a file in the project node_modules directory
     * @default false
     */
    debugAlias?: boolean;

    /** disable automatic copying of files to include and output directory (dist) */
    noCopy?: boolean;
    /** When enabled the needle-engine include directory will be copied */
    copyIncludesFromEngine?: boolean;
    /** set to false to tree-shake rapier physics engine to the reduce bundle size */
    useRapier?: boolean;
    /** experimental */
    usePostprocessing?: boolean;
    noDependencyWatcher?: boolean;
    /** set to false to suppress editor-sync package installation and connection */
    dontInstallEditor?: boolean;
    /** set to false to prevent meta.html modifications (vite only) */
    allowMetaPlugin?: boolean;
    /** set to true to prevent injecting peerjs `parcelRequire` global variable declaration */
    noPeer?: boolean;
    /** set to true to disable reload plugin */
    noReload?: boolean;
    /** Set to false to disable hot reload for the needle plugin. */
    allowHotReload?: boolean;

    /** When enabled the Vite drop plugin will be enabled. @default false */
    useDrop?: boolean;

    noCodegenTransform?: boolean;
    noFacebookInstantGames?: boolean;
    /** Set to true to create an imports.log file that shows all module imports. The file is generated when stopping the server. */
    logModuleImportChains?: boolean;

    /** Set to true to disable generating the buildinfo.json file in your output directory */
    noBuildInfo?: boolean;

    /** Set to true to disable the needle build pipeline (running compression and optimization as a postprocessing step on the exported glTF files) */
    noBuildPipeline?: boolean;

    /**
     * Use to configure optimized builds
     */
    buildPipeline?: {
        /** Set to false to prevent the build pipeline from running */
        enabled?: boolean,
        /** Set a project name (cloud only) */
        projectName?: string,
        /** Enable for verbose log output */
        verbose?: boolean,

        /** Set to a specific version of the Needle Build Pipeline.
         * @default "latest"
         * @example "2.2.0-alpha"
        */
        version?: string;

        /** If defined the access token will be used to run compression on Needle Cloud */
        accessToken?: string | undefined;
    }

    /** required for @serializable https://github.com/vitejs/vite/issues/13736 */
    vite44Hack?: boolean;

    /** set to true to disable poster generation */
    noPoster?: boolean;
    // posterFormat?: "image/webp";// | "image/png";
    /** 
     * Use "default" to always generate the poster after 'src' has changed
     * Use "once" to generate the poster only once, when no poster already exists
    */
    posterGenerationMode?: "default" | "once";

    /** Pass in a mix of VitePWA and NeedlePWA options, true to enable with defaults or "false" to disable */
    /** @type {import("vite-plugin-pwa").VitePWAOptions & Partial<NeedlePWAOptions> | boolean} */
    pwa?: undefined;

    /** used by nextjs config to forward the webpack module */
    modules?: needleModules;

    /**
     * Use to activate a needle engine license
     */
    license?: License;

    /**
     * When set to `true` a plugin will automatically attempt to open the browser using a network ip address when the local server has started
     * @default undefined
     */
    openBrowser?: boolean;
}
