/**
* Shared primitives for scanning and rewriting asset paths in HTML/CSS.
*
* Used by: rewriteSubCompPaths (core), collectExternalAssets (producer),
* localizeExternalAssets (CLI publish).
*/
/**
* Regex matching CSS `url(...)` references — captures the quote style and the
* raw URL. The URL group is anchored to non-whitespace at both ends so the
* surrounding `\s*` can never overlap it (avoids polynomial-ReDoS backtracking);
* the captured value is whitespace-bounded already, matching the old behavior
* after callers `.trim()` it.
*/
declare const CSS_URL_RE: RegExp;
/** Attributes that may contain relative asset paths. */
declare const PATH_ATTRS: readonly ["src", "href"];
/** Returns true for URLs/prefixes that should never be rewritten. */
declare function isNonRelativeUrl(val: string): boolean;
/**
* Cross-platform containment check: is `childPath` inside `parentPath`?
* Equality counts as "inside".
*/
declare function isPathInside(childPath: string, parentPath: string): boolean;
/**
* Rewrite relative asset paths in sub-composition content so they resolve
* correctly after the content is inlined into the root document.
*
* A sub-composition at "compositions/scene.html" referencing "../icon.svg"
* means the project root — but after inlining into root index.html, the
* "../" escapes the project directory and causes 404s. This function
* resolves each relative path against the sub-composition's directory,
* then normalizes it to be relative to the project root.
*
* Used by both the core bundler (preview) and the producer compiler (render)
* to ensure consistent behavior.
*/
/**
* Probe for "does this project-root-relative path exist?", supplied by callers
* that can see the filesystem (the studio preview builder, the bundler, the
* producer). Keeps this module free of `node:fs` so it stays browser-safe.
*
* It disambiguates the two conventions for a plain relative path authored in a
* sub-composition that lives in a subdirectory:
*
* 1. A SIBLING file — `` next to the composition.
* This is what a browser resolves when the file is opened directly, and
* what an author means. Once the content moves into the project-root
* document it must become `design/styleframes/_shared.css` or it 404s.
* 2. A PROJECT-ROOT asset — registry blocks are installed into a
* subdirectory but reference `assets/logo.png` at the root. Already
* correct in the root document; rewriting would break it.
*
* A sibling that exists on disk means (1); anything else is left as authored.
* Without a probe the behavior is unchanged — plain relative paths pass through.
*/
type AssetExists = (projectRelativePath: string) => boolean;
/**
* Rewrite a single relative path from a sub-composition's context to the
* project root context.
*
* @param compSrcPath - The `data-composition-src` value (e.g. "compositions/scene.html")
* @param relativePath - The asset path to rewrite (e.g. "../icon.svg")
* @param assetExists - Optional filesystem probe; see `AssetExists`.
* @returns The rewritten path relative to project root (e.g. "icon.svg"), or
* the original path if no rewriting is needed.
*/
declare function rewriteAssetPath(compSrcPath: string, relativePath: string, assetExists?: AssetExists): string;
/**
* Rewrite all relative `src` and `href` attributes on elements within a
* DOM tree, adjusting paths from the sub-composition's directory context
* to the project root.
*
* @param elements - Iterable of DOM elements to scan (e.g. from querySelectorAll)
* @param compSrcPath - The `data-composition-src` value
* @param getAttr - Function to read an attribute from an element
* @param setAttr - Function to set an attribute on an element
*/
declare function rewriteAssetPaths(elements: Iterable, compSrcPath: string, getAttr: (el: T, attr: string) => string | null | undefined, setAttr: (el: T, attr: string, value: string) => void, assetExists?: AssetExists): void;
/**
* Rewrite CSS url(...) references inside inline style attributes.
*/
declare function rewriteInlineStyleAssetUrls(elements: Iterable, compSrcPath: string, getStyle: (el: T) => string | null | undefined, setStyle: (el: T, value: string) => void, assetExists?: AssetExists): void;
/**
* Rewrite CSS url(...) references in a sub-composition's inline styles so
* ../foo.woff2 remains valid after the CSS is hoisted into the root document.
*/
declare function rewriteCssAssetUrls(cssText: string, compSrcPath: string, assetExists?: AssetExists): string;
export { type AssetExists, CSS_URL_RE, PATH_ATTRS, isNonRelativeUrl, isPathInside, rewriteAssetPath, rewriteAssetPaths, rewriteCssAssetUrls, rewriteInlineStyleAssetUrls };