//#region src/graph.d.ts /** * A callback that returns the direct imported module IDs for a given module. * Abstracts over both Vite's dev-mode module graph and rollup's build-mode graph, * allowing the graph walker to work in both contexts without coupling to either. * * @param moduleId - The absolute file path of the module to query. * @returns An array of absolute file paths that the given module imports directly. */ type GetImportedModuleIds = (moduleId: string) => string[]; /** * A callback that returns the direct importer module IDs for a given module * (the inverse of {@link GetImportedModuleIds}). * * @param moduleId - The absolute file path of the module to query. * @returns An array of absolute file paths of modules that directly import the given module. */ type GetImporterModuleIds = (moduleId: string) => string[]; /** * Walks upward from a target module through its importers using a breadth-first * search, returning the shortest import chain from a root module (one with no * importers) down to the target. Used in dev mode where the client entry is the * HTML file, which Vite's dev module graph does not expose traversable * `importedModules` on. The traversal direction is inverted to compensate. * * @param targetModuleId - The module ID to trace upward to a root. * @param getImporterModuleIds - Returns the direct importer IDs for a given module. * @returns An ordered array of module IDs from the nearest root to the target. * Falls back to a single-element array containing only the target if no * root is reachable (e.g. the target is the only node or sits inside a cycle). */ declare function buildImportChainViaImporters(targetModuleId: string, getImporterModuleIds: GetImporterModuleIds): string[]; /** * Walks the module import graph starting from the given client entry points * using a depth-first traversal, collecting all transitively reachable module IDs. * Handles circular imports safely by tracking visited modules. * * @param clientEntryModuleIds - The absolute file paths of all client entry point modules. * @param getImportedModuleIds - Returns the direct imported module IDs for a given module ID. * @returns A Set containing every module ID reachable from the provided entry points. */ declare function collectClientReachableModuleIds(clientEntryModuleIds: string[], getImportedModuleIds: GetImportedModuleIds): Set; /** * Finds the shortest import chain from any client entry point to the target module * using a breadth-first search. Returns the reconstructed path as an ordered array * of module IDs from the entry point to the target. * * @param targetModuleId - The module ID to trace back to a client entry point. * @param clientEntryModuleIds - The absolute file paths of all client entry point modules. * @param getImportedModuleIds - Returns the direct imported module IDs for a given module ID. * @returns An ordered array of module IDs forming the shortest path from an entry to the target, * or a single-element array containing only the target if no chain can be found. */ declare function buildImportChainToModule(targetModuleId: string, clientEntryModuleIds: string[], getImportedModuleIds: GetImportedModuleIds): string[]; //#endregion export { GetImportedModuleIds, GetImporterModuleIds, buildImportChainToModule, buildImportChainViaImporters, collectClientReachableModuleIds }; //# sourceMappingURL=graph.d.ts.map