mirror of
https://github.com/heygen-com/hyperframes.git
synced 2026-09-05 10:14:30 +00:00
fix(core): resolve sub-composition sibling asset paths everywhere (#2994)
Extends the studio-preview fix to the render path and the asset-discovery utilities, which share the same resolver and had the same defect. `rewriteAssetPath` takes an optional `assetExists` probe. A plain relative ref authored in a sub-composition (`_shared.css`, `clip.mp4`) is re-pointed at the composition's own directory when that sibling exists on disk; project-root refs with no sibling (the registry's `assets/logo.png` convention) stay as authored. Callers that can see the filesystem supply the probe, so the module stays free of node:fs. Also fixes a second defect in the inliner: `<head>` <link> hrefs and external script srcs are hoisted into the root document but never went through the rewrite at all, so even the documented `../` form escaped the project and 404'd at render time. Wired into the preview bundler, the producer compiler, the studio preview builder, the HEVC preview lint, the project lint's asset scans, publish proxy baking, and media-treatment source resolution.
This commit is contained in:
@@ -25,6 +25,7 @@
|
||||
* structured manifest rather than silently shipping an unplayable asset.
|
||||
*/
|
||||
|
||||
import { existsSync } from "node:fs";
|
||||
import { readFile } from "node:fs/promises";
|
||||
import { basename, dirname, resolve } from "node:path";
|
||||
import { parseHTML } from "linkedom";
|
||||
@@ -147,7 +148,9 @@ export async function bakeMediaProxies(
|
||||
// (rewriteAssetPath to root-relative, then decodeUrlPathVariants via
|
||||
// resolveLocalAssetCandidates) so percent-encoded and root-absolute
|
||||
// srcs match the map keys the scan produced.
|
||||
const rootRelativeSrc = rewriteAssetPath(entryPath, cleaned);
|
||||
const rootRelativeSrc = rewriteAssetPath(entryPath, cleaned, (path) =>
|
||||
existsSync(resolve(absProjectDir, path)),
|
||||
);
|
||||
for (const candidate of resolveLocalAssetCandidates(absProjectDir, rootRelativeSrc)) {
|
||||
const archivePath = proxyByAbsolutePath.get(candidate);
|
||||
if (archivePath) return archivePath;
|
||||
|
||||
Reference in New Issue
Block a user