import { BasePartial, BaseResolved, GlobPartial, GlobResolved, InjectPartial, InjectResolved, ManifestEntry, RequiredGlobDirectoryPartial, RequiredGlobDirectoryResolved, RequiredSwDestPartial, RequiredSwDestResolved } from "@serwist/build"; import { BuildOptions, Plugin, ResolvedConfig } from "vite"; import { Require } from "@serwist/utils"; import { RollupOptions } from "rollup"; //#region src/lib/types.d.ts interface InjectPartial$1 { /** * The mode in which your service worker should be built. * * @default * process.env.NODE_ENV // or "production" if undefined */ mode?: "development" | "production"; /** * The module type with which the service worker should be registered. Usually used alongside * `rollupFormat`. * * @default "classic" * @see https://developer.mozilla.org/en-US/docs/Web/API/ServiceWorkerContainer/register#type */ type?: WorkerType; /** * The service worker's URL scope. Set to `"/foo/"` so that paths under "/foo/" * are under the service worker's control while others are not. * * @default viteOptions.base * @see https://vitejs.dev/config/shared-options.html#base * @see https://developer.mozilla.org/en-US/docs/Web/API/ServiceWorkerContainer/register#scope */ scope?: string; /** * The base from which Serwist resolves URLs. * * @default viteOptions.base * @see https://vitejs.dev/config/shared-options.html#base */ base?: string; /** * Whether Serwist should be disabled. * * @default false */ disable?: boolean; /** * Hooks of the build lifecycle. */ integration?: Hooks; /** * The URL to the service worker. * * @default "/sw.js" */ swUrl?: string; /** * Rollup/Vite plugins used to build the service worker. */ plugins?: Plugin[]; /** * The format used to build the service worker. * * @default "es" */ rollupFormat?: "es" | "iife"; /** * Custom Rollup options used to build the service worker. */ rollupOptions?: Omit; /** * Development-specific options. */ devOptions?: DevOptions; } interface InjectResolved$1 extends Require { devOptions: Required; } interface InjectManifestOptions extends Omit, GlobPartial, InjectPartial, RequiredSwDestPartial, RequiredGlobDirectoryPartial, InjectPartial$1 {} interface InjectManifestOptionsComplete extends BaseResolved, GlobResolved, InjectResolved, RequiredSwDestResolved, RequiredGlobDirectoryResolved, InjectResolved$1 {} interface Hooks { /** * Allows you to run some logic before the service worker is built. * @param options * @returns */ beforeBuildServiceWorker?: (options: PluginOptionsComplete) => void | Promise; /** * Adjusts the application order of `@serwist/vite`'s `closeBundle` hook. */ closeBundleOrder?: "pre" | "post" | null; /** * Allows you to configure the options of Serwist and Vite. Useful when there is a dependency between the two. * @param viteOptions * @param options * @returns */ configureOptions?: (viteOptions: ResolvedConfig, options: PluginOptions) => void | Promise; } interface DevOptions { /** * Whether the service worker should be bundled in development mode. * * @default true */ bundle?: boolean; /** * Whether the service worker should be minified in development mode. * * @default false */ minify?: BuildOptions["minify"]; } interface PluginOptions extends InjectManifestOptions {} interface PluginOptionsComplete extends InjectResolved$1 { injectManifest: Omit; } interface SerwistViteApi { /** * Whether the plugin is disabled. */ disabled: boolean; /** * Extends the precache manifest. * @param fn */ extendManifestEntries(fn: ExtendManifestEntriesHook): void; generateSW(): Promise; } type ExtendManifestEntriesHook = (manifestEntries: (string | ManifestEntry)[]) => (string | ManifestEntry)[] | undefined; //#endregion //#region src/lib/context.d.ts type SerwistViteFrameworks = "nuxt"; interface SerwistViteContext { /** * Resolved Vite config. * * Note: This value is set by our main plugin, located at plugins/main.ts. */ viteConfig: ResolvedConfig; /** * Provided options. */ userOptions: PluginOptions; /** * Resolved options. * * Note: this is different from `userOptions` in that it has been parsed, whereas * `userOptions` is the raw configuration that the user provides us. */ options: PluginOptionsComplete; useImportRegister: boolean; /** * Is the plugin running on dev? * * Note: This value is set by our dev plugin, located at plugins/dev.ts. */ devEnvironment: boolean; /** To tailor our APIs to these frameworks. */ framework: SerwistViteFrameworks | undefined; } declare const createContext: (userOptions: PluginOptions, framework: SerwistViteFrameworks | undefined) => SerwistViteContext; //#endregion //#region src/lib/api.d.ts declare const createApi: (ctx: SerwistViteContext) => SerwistViteApi; //#endregion //#region src/lib/utils.d.ts /** * Internal function used by `@serwist/vite`. * Resolves a file path without extension. Also handles `/index` if the path * actually points to a directory. * @internal * @param ctx * @param api * @returns */ declare const resolveEntry: (entry: string) => string | null; /** * Internal function used by `@serwist/vite`. * Converts a filesystem path to a Vite `@fs` URL. * @internal * @param ctx * @param api * @returns */ declare const toFs: (str: string) => string; //#endregion //#region src/lib/validator.d.ts declare const validateInjectManifestOptions: (input: unknown) => Promise; //#endregion //#region src/plugins/build.d.ts /** * Internal build plugin used by `@serwist/vite`. * @internal * @param ctx * @param api * @returns */ declare const buildPlugin: (ctx: SerwistViteContext, api: SerwistViteApi) => Plugin; //#endregion //#region src/plugins/dev.d.ts /** * Internal dev plugin used by `@serwist/vite`. * @internal * @param ctx * @param api * @returns */ declare const devPlugin: (ctx: SerwistViteContext, api: SerwistViteApi) => Plugin; //#endregion //#region src/plugins/main.d.ts /** * Internal plugin used by `@serwist/vite`. * @internal * @param ctx * @param api * @returns */ declare const mainPlugin: (ctx: SerwistViteContext, api: SerwistViteApi) => Plugin; //#endregion //#region src/index.d.ts /** * Integrates Serwist into your Vite app. * @param userOptions * @returns */ declare const serwist: (userOptions: PluginOptions) => Plugin[]; //#endregion export { type DevOptions, type ExtendManifestEntriesHook, type Hooks, type PluginOptions, type PluginOptionsComplete, type SerwistViteApi, type SerwistViteContext, buildPlugin as build, createApi, createContext, devPlugin as dev, mainPlugin as main, resolveEntry, serwist, toFs, validateInjectManifestOptions }; //# sourceMappingURL=index.d.mts.map