/** * Finds the Custom Elements Manifests a project can see and answers "what is * `` documented as?" from them. * * Two places are searched: the project's own package (the nearest * `package.json` at or above the Vite root) and the packages it lists as * dependencies, resolved the way Node would, by walking `node_modules` up * from the project so hoisted monorepos work. Dependencies of dependencies are * not followed. A package points at its manifest with the `customElements` * field, or leaves a `custom-elements.json` beside its `package.json`. * * Everything touching the disk goes through an injected `DocsFs`, so this * module has no `node:` imports and tests run on an in-memory tree. Paths are * handled as `/`-separated strings, with backslashes normalised, so Windows * roots behave the same. * * It reads three kinds of file: `package.json`s, and manifests named by a * `customElements` field that stay inside that package's directory. A field * pointing elsewhere (`../x.json`, an absolute path) is ignored. Nothing here * throws or logs per file; a missing or broken file is just skipped. * * Parsed manifests are cached by modification time, discovery by the project * `package.json`'s, and each lookup re-stats them so edits show up without a * restart. Each manifest read is watched from then on, so a regenerated one * can be announced to the panel. */ import type { ComponentDocs } from '../../types/component-docs.js'; /** The file access the index needs. `undefined` means missing or unreadable. */ export interface DocsFs { readFile(path: string): string | undefined; /** Modification time in ms, for regular files only. */ mtime(path: string): number | undefined; /** Call `onChange` whenever the file at `path` changes from now on. */ watch?(path: string, onChange: () => void): void; } /** A synchronous `DocsFs` over `node:fs`, imported on first use. */ export declare const nodeDocsFs: () => Promise; export interface ComponentDocsIndex { /** The tag's docs from the first manifest that has it, project first. */ get(tagName: string): Promise; } export interface ManifestSource { /** Absolute path to the manifest file. */ path: string; /** Relative to the package, for `origin.manifest`. */ relative: string; /** Absent for the project's own. */ package?: string; } /** * The manifests visible from `root` that exist right now, the project's * first. Uncached: for the dev server's page links, read once per page. */ export declare const findManifests: (fs: DocsFs, root: string) => ManifestSource[]; /** * A lazy, self-refreshing index over the manifests visible from the project. * * @param options.root The Vite root; read on every lookup, since it can be * unknown early on. Without one, every lookup misses. * @param options.fs The file access, awaited per lookup so `nodeDocsFs` can * load on first use. * @param options.onChange Called when a manifest a lookup has read changes, * so whoever shows its docs can ask again. */ export declare const createComponentDocsIndex: (options: { root: () => string | undefined; fs: () => Promise | DocsFs; onChange?: () => void; }) => ComponentDocsIndex; //# sourceMappingURL=load.d.ts.map