import type { Rollup } from 'vite'; import type { RouteData, SSRResult } from '../../@types/astro'; import type { PageOptions } from '../../vite-plugin-astro/types'; import type { PageBuildData, StylesheetAsset, ViteID } from './types'; export interface BuildInternals { /** * Each CSS module is named with a chunk id derived from the Astro pages they * are used in by default. It's easy to crawl this relation in the SSR build as * the Astro pages are the entrypoint, but not for the client build as hydratable * components are the entrypoint instead. This map is used as a cache from the SSR * build so the client can pick up the same information and use the same chunk ids. */ cssModuleToChunkIdMap: Map; hoistedScriptIdToHoistedMap: Map>; hoistedScriptIdToPagesMap: Map>; entrySpecifierToBundleMap: Map; /** * A map to get a specific page's bundled output file. */ pageToBundleMap: Map; /** * A map for page-specific information. */ pagesByComponent: Map; /** * A map for page-specific output. */ pageOptionsByPage: Map; /** * A map for page-specific information by Vite ID (a path-like string) */ pagesByViteID: Map; /** * A map for page-specific information by a client:only component */ pagesByClientOnly: Map>; /** * A map of hydrated components to export names that are discovered during the SSR build. * These will be used as the top-level entrypoints for the client build. * * @example * '/project/Component1.jsx' => ['default'] * '/project/Component2.jsx' => ['Counter', 'Timer'] * '/project/Component3.jsx' => ['*'] */ discoveredHydratedComponents: Map; /** * A list of client:only components to export names that are discovered during the SSR build. * These will be used as the top-level entrypoints for the client build. * * @example * '/project/Component1.jsx' => ['default'] * '/project/Component2.jsx' => ['Counter', 'Timer'] * '/project/Component3.jsx' => ['*'] */ discoveredClientOnlyComponents: Map; /** * A list of hoisted scripts that are discovered during the SSR build * These will be used as the top-level entrypoints for the client build. */ discoveredScripts: Set; staticFiles: Set; ssrEntryChunk?: Rollup.OutputChunk; entryPoints: Map; ssrSplitEntryChunks: Map; componentMetadata: SSRResult['componentMetadata']; middlewareEntryPoint?: URL; } /** * Creates internal maps used to coordinate the CSS and HTML plugins. * @returns {BuildInternals} */ export declare function createBuildInternals(): BuildInternals; export declare function trackPageData(internals: BuildInternals, component: string, pageData: PageBuildData, componentModuleId: string, componentURL: URL): void; /** * Tracks client-only components to the pages they are associated with. */ export declare function trackClientOnlyPageDatas(internals: BuildInternals, pageData: PageBuildData, clientOnlys: string[]): void; export declare function getPageDatasByChunk(internals: BuildInternals, chunk: Rollup.RenderedChunk): Generator; export declare function getPageDatasByClientOnlyID(internals: BuildInternals, viteid: ViteID): Generator; export declare function getPageDataByComponent(internals: BuildInternals, component: string): PageBuildData | undefined; export declare function getPageDataByViteID(internals: BuildInternals, viteid: ViteID): PageBuildData | undefined; export declare function hasPageDataByViteID(internals: BuildInternals, viteid: ViteID): boolean; export declare function eachPageData(internals: BuildInternals): Generator; export declare function eachRedirectPageData(internals: BuildInternals): Generator; export declare function eachPageDataFromEntryPoint(internals: BuildInternals): Generator<[PageBuildData, string]>; export declare function hasPrerenderedPages(internals: BuildInternals): boolean; interface OrderInfo { depth: number; order: number; } /** * Sort a page's CSS by depth. A higher depth means that the CSS comes from shared subcomponents. * A lower depth means it comes directly from the top-level page. * Can be used to sort stylesheets so that shared rules come first * and page-specific rules come after. */ export declare function cssOrder(a: OrderInfo, b: OrderInfo): 1 | -1; export declare function mergeInlineCss(acc: Array, current: StylesheetAsset): Array; export declare function isHoistedScript(internals: BuildInternals, id: string): boolean; export declare function getPageDatasByHoistedScriptId(internals: BuildInternals, id: string): Generator; export declare function getEntryFilePathFromComponentPath(internals: BuildInternals, path: string): string | undefined; export {};