import { App } from 'vue'; import { Router, RouteRecordRaw, RouterOptions as RouterOptions$1 } from 'vue-router'; import { HeadClient } from '@vueuse/head'; import { Options } from 'critters'; interface ViteSSGOptions { /** * Rewrite scripts loading mode, only works for `type="module"` * * @default 'sync' */ script?: 'sync' | 'async' | 'defer' | 'async defer'; /** * The path of main entry, relative to the project root * * @default 'src/main.ts' */ entry?: string; /** * Mock browser global variables (window, document, etc.) for SSG * * @default false */ mock?: boolean; /** * Applying formatter to the generated index file. * * @default 'none' */ formatting?: 'minify' | 'prettify' | 'none'; /** * Vite environment mode */ mode?: string; /** * Directory style of the output directory. * * flat: `/foo` -> `/foo.html` * nested: `/foo` -> `/foo/index.html` * * @default flat */ dirStyle?: 'flat' | 'nested'; /** * Generate for all routes, including dynamic routes. * If enabled, you will need to configure your server * manually to handle dynamic routes properly. * * @default false */ includeAllRoutes?: boolean; /** * Options for critters * * @see https://github.com/GoogleChromeLabs/critters */ crittersOptions?: Options | false; /** * Custom functions to modified the routes to do the SSG. * * Works only when `includeAllRoutes` is set to false. * * Default to a handler that filter out all the dynamic routes, * when passing your custom handler, you should also take care the dynamic routes yourself. */ includedRoutes?: (routes: string[]) => Promise | string[]; onAfterClientBuild?: () => void; /** * Callback to be called before every page render. * * Also give the change to transform the index html passed to the renderer. */ onBeforePageRender?: (route: string, indexHTML: string, appCtx: ViteSSGContext) => Promise | string | null | undefined; /** * Callback to be called on every page rendered. * * Also give the change to transform the rendered html by returning a string. */ onPageRendered?: (route: string, renderedHTML: string, appCtx: ViteSSGContext) => Promise | string | null | undefined; onFinished?: () => Promise | void; } type PartialKeys = Omit & Partial>; interface ViteSSGContext { app: App; router: HasRouter extends true ? Router : undefined; routes: HasRouter extends true ? RouteRecordRaw[] : undefined; initialState: Record; head: HeadClient | undefined; isClient: boolean; /** * Current router path on SSG, `undefined` on client side. */ routePath?: string; } interface ViteSSGClientOptions { transformState?: (state: any) => any; registerComponents?: boolean; useHead?: boolean; rootContainer?: string | Element; } type RouterOptions = PartialKeys & { base?: string; }; export { RouterOptions as R, ViteSSGContext as V, ViteSSGClientOptions as a, ViteSSGOptions as b };