/** * Retargeting the asset URLs PreTeXt emits. * * A portable build inlines `latex-image` and `prefigure` SVGs directly into * the page (pretext-html.xsl, mode="svg-embedded"), so those need nothing from * us — they are read at transform time through the fetch shim. Everything else * — author-supplied images and media, sageplot, asymptote — is emitted as a * *runtime* URL under one of two fixed prefixes: * * * * * Those prefixes (`$external-directory` / `$generated-directory` in * publisher-variables.xsl) name directories a real build populates by copying * files next to the output HTML. The preview has no output directory, so the * URLs dangle and the assets silently fail to load. * * The prefixes are hardcoded rather than derived from the publication file, * which is what makes retargeting reliable: find them, and hand each path to a * host that knows how to serve it — `Webview.asWebviewUri` under VS Code, a * blob or hosted URL in a browser. Mapping the prefix back to a real directory * needs the publication file's `@external`/`@generated`, which the renderer * reports as {@link RenderResult.assetDirs}. */ /** Which of PreTeXt's two asset directories a URL points into. */ export type AssetKind = "external" | "generated"; export { describeAsset, missingAssetPlaceholder, missingAssetSvg, } from './missing-asset.js'; export type { MissingAsset } from './missing-asset.js'; /** * Maps one asset path to a URL the host can actually load. * * `relPath` is percent-decoded and relative to the directory `kind` names * (e.g. `"kitten.png"`, `"sageplot/plot.svg"`). Return `undefined` to leave * the URL untouched — appropriate when the file does not exist, so the page * keeps PreTeXt's own broken-image markup rather than pointing at a URL that * will 404 anyway. */ export type AssetUrlResolver = (kind: AssetKind, relPath: string) => string | undefined; /** * Rewrite every `external/`- or `generated/`-prefixed asset URL in `html` * through `resolve`. Paths the resolver declines are left untouched. */ export declare function rewriteAssetUrls(html: string, resolve: AssetUrlResolver): string;