/** * Virtual-host fetch shim. * * The libxslt-wasm build is compiled with FILESYSTEM=0, so libxml2 cannot * touch the real filesystem: any `file://` URL aborts inside the WASM sandbox. * Instead, every external resource load (stylesheet imports, DTD entities, * xi:includes, the publication file, `document()` calls) is routed through the * *global* `fetch` via a JSPI-suspended import. That makes resource loading * fully controllable from JavaScript: we register fake hosts under the * reserved `.invalid` TLD and serve them from local directories or in-memory * strings. No HTTP server, no real network traffic. */ /** * Reads `relPath` (posix, leading "/") beneath mount root `root`, or resolves * `undefined` when it is missing or escapes the mount. `root` is opaque: a * directory under Node, a base URL in a browser, whatever an embedder's own * reader wants. */ export type MountReader = (root: string, relPath: string) => Promise; /** * Replace how mounted files are read. Lets an embedder serve the stylesheets * from somewhere the platform seam does not cover — an in-memory map, a zip, * a VS Code webview resource URI — without patching `globalThis.fetch`. * Also how scripts/build-xsl-bundle.mjs records which files a render touches. */ export declare function setMountReader(reader: MountReader): void; /** Install the shim (idempotent). Must run before libxslt-wasm loads anything. */ export declare function installFetchShim(): void; /** * Serve `dir` under a unique fake origin. Returns the base URL * (e.g. `http://mnt1.ptx.invalid`); resource paths append to it. * * `dir` is stored verbatim and handed back to the {@link MountReader}, which * owns its interpretation — under Node a directory path, in a browser a base * URL. */ export declare function mountDirectory(dir: string): string; export declare function unmountDirectory(baseUrl: string): void; /** Serve `content` for exactly `url`. Takes priority over directory mounts. */ export declare function setVirtualFile(url: string, content: string): void; export declare function removeVirtualFile(url: string): void;