/** * Where a component is defined, on a page the plugin never built: the stack * of its `customElements.define` call (`runtime/define-sites.ts`) mapped * through the page's own sourcemaps. * * Runs wherever the host is: the extension's panel page, which may fetch from * the sites the user enabled, or the `lit-devtools dev` server, which has the * page fetch for it (`page-fetch.ts`). The host supplies `fetch`. Per * generated script it fetches the script once, finds its map * (the `SourceMap` header, else the last `sourceMappingURL` comment; inline * `data:` maps too) and keeps the parsed map until {@link reset}. * * Which frame names the component: the define call's stack starts in * library code (`@customElement`, a registration helper) before reaching the * module that declares the class. So the first mapped frame outside * `node_modules` and Vite's virtual modules wins; failing that, the first outside Lit's own packages (a * component library's element); failing that, the first mapped frame. * * Outside `node_modules`, a frame that lands exactly on a mapping segment * goes first. Bundlers emit helpers such as `__decorate` with no mappings of * their own, and a lookup inside one falls back to the last segment before * it: the end of whatever module was bundled ahead of it. Real call sites * sit on a segment of their own, so in a token-level map the helper's frame * is passed over for the class's module; in a coarser map, where nothing is * exact, the order above stands. * * Anything going wrong (no map, a network error, a map that does not parse) * leaves the location unknown; nothing here throws. */ import type { ElementSource, GeneratedFrame, TemplateSite } from '../../types/inspector.js'; export interface SourceMapResolver { /** The original location of the first fitting frame, if any maps. */ resolve(frames: readonly GeneratedFrame[]): Promise; /** * Where the element a {@link TemplateSite} names is written: its `; /** Forget fetched scripts and maps (the page navigated). */ reset(): void; } /** What a fetched response must offer; the page's `fetch` and ours both do. */ export interface FetchedResponse { ok: boolean; headers: { get(name: string): string | null; }; text(): Promise; } export interface SourceMapResolverOptions { fetch: (url: string) => Promise; /** * Whether a script or map URL may be fetched; the panel allows only the * inspected site, so a CDN's script or a map hosted elsewhere stays * unresolved. Everything when omitted. */ allows?: (url: string) => boolean; } /** The last `sourceMappingURL` comment's value in `code`. */ export declare const sourceMappingUrlOf: (code: string) => string | undefined; /** The JSON text of a `data:` URL, base64 or percent-encoded. */ export declare const decodeDataUrl: (url: string) => string; /** * A readable path for a resolved source URL: `webpack://app/./src/a.ts` and * `http://host/src/a.ts` both read `src/a.ts`; a `file:` URL keeps its * absolute path. */ export declare const displayPath: (source: string) => string; export declare const createSourceMapResolver: (options: SourceMapResolverOptions) => SourceMapResolver; //# sourceMappingURL=source-maps.d.ts.map