@hyperframes/producer 0.9.29 → 0.9.31
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/dist/distributed.js +320 -301
- package/dist/hyperframe.manifest.json +1 -1
- package/dist/hyperframe.runtime.iife.js +67 -67
- package/dist/index.js +377 -358
- package/dist/public-server.js +181 -162
- package/dist/services/bundledScripts.d.ts +4 -0
- package/package.json +7 -7
package/dist/index.js
CHANGED
|
@@ -9,7 +9,7 @@ import {
|
|
|
9
9
|
// src/services/renderOrchestrator.ts
|
|
10
10
|
import { audioFailureDiagnostics as audioFailureDiagnostics2 } from "@hyperframes/engine";
|
|
11
11
|
import {
|
|
12
|
-
existsSync as
|
|
12
|
+
existsSync as existsSync22,
|
|
13
13
|
mkdirSync as mkdirSync12,
|
|
14
14
|
readdirSync as readdirSync6,
|
|
15
15
|
rmSync as rmSync12,
|
|
@@ -67,7 +67,7 @@ import {
|
|
|
67
67
|
referenceBackgroundResult,
|
|
68
68
|
createReferenceBackgroundRecorder
|
|
69
69
|
} from "@hyperframes/engine";
|
|
70
|
-
import { join as
|
|
70
|
+
import { join as join31, dirname as dirname13, resolve as resolve8 } from "path";
|
|
71
71
|
import { totalmem as totalmem2 } from "node:os";
|
|
72
72
|
import { randomUUID } from "crypto";
|
|
73
73
|
import { fileURLToPath as fileURLToPath4 } from "url";
|
|
@@ -6340,8 +6340,8 @@ function countAuthoredTimedClips(html) {
|
|
|
6340
6340
|
}
|
|
6341
6341
|
|
|
6342
6342
|
// src/services/render/stages/compileStage.ts
|
|
6343
|
-
import { existsSync as
|
|
6344
|
-
import { join as
|
|
6343
|
+
import { existsSync as existsSync13, writeFileSync as writeFileSync5 } from "node:fs";
|
|
6344
|
+
import { join as join19 } from "node:path";
|
|
6345
6345
|
import { suggestMatchingPreset } from "@hyperframes/core";
|
|
6346
6346
|
import { extractStandaloneEntryFromIndex, isTemplateEntry } from "@hyperframes/core/compiler";
|
|
6347
6347
|
import { readTextFile as readTextFile2 } from "@hyperframes/parsers/asset-resolution";
|
|
@@ -6349,9 +6349,23 @@ import { readTextFile as readTextFile2 } from "@hyperframes/parsers/asset-resolu
|
|
|
6349
6349
|
// src/services/htmlCompiler.ts
|
|
6350
6350
|
import { decodedUrlPath as decodedUrlPath2 } from "@hyperframes/parsers/asset-paths";
|
|
6351
6351
|
import { createHash as createHash6 } from "node:crypto";
|
|
6352
|
-
import { createReadStream as createReadStream2, existsSync as
|
|
6353
|
-
import { join as
|
|
6352
|
+
import { createReadStream as createReadStream2, existsSync as existsSync12, mkdirSync as mkdirSync9, readFileSync as readFileSync8 } from "fs";
|
|
6353
|
+
import { join as join18, dirname as dirname8, resolve as resolve7, basename as basename5, relative as relative2, sep as sep2 } from "path";
|
|
6354
6354
|
import { parseHTML as parseHTML5 } from "linkedom";
|
|
6355
|
+
|
|
6356
|
+
// src/services/bundledScripts.ts
|
|
6357
|
+
import { existsSync as existsSync9, readFileSync as readFileSync5 } from "node:fs";
|
|
6358
|
+
import { join as join15 } from "node:path";
|
|
6359
|
+
import { gsapCdnDist } from "@hyperframes/core/gsap-cdn";
|
|
6360
|
+
var GSAP_VENDOR_DIR_ENV = "HYPERFRAMES_GSAP_VENDOR_DIR";
|
|
6361
|
+
function bundledScript(url) {
|
|
6362
|
+
const dir = process.env[GSAP_VENDOR_DIR_ENV];
|
|
6363
|
+
if (!dir || url !== `${gsapCdnDist()}gsap.min.js`) return null;
|
|
6364
|
+
const file = join15(dir, "gsap.min.js");
|
|
6365
|
+
return existsSync9(file) ? readFileSync5(file) : null;
|
|
6366
|
+
}
|
|
6367
|
+
|
|
6368
|
+
// src/services/htmlCompiler.ts
|
|
6355
6369
|
import {
|
|
6356
6370
|
COMPOSITION_SOURCE_URL,
|
|
6357
6371
|
compileTimingAttrs,
|
|
@@ -6373,7 +6387,7 @@ import {
|
|
|
6373
6387
|
import { MAX_AUDIO_GAIN } from "@hyperframes/core/audio-gain";
|
|
6374
6388
|
import { readPlaybackRate } from "@hyperframes/parsers/media-duration";
|
|
6375
6389
|
import { resolveRateSpec } from "@hyperframes/core/speed-ramp";
|
|
6376
|
-
import { gsapCdnDist, normalizeGsapBaseUrl } from "@hyperframes/core/gsap-cdn";
|
|
6390
|
+
import { gsapCdnDist as gsapCdnDist2, normalizeGsapBaseUrl } from "@hyperframes/core/gsap-cdn";
|
|
6377
6391
|
import {
|
|
6378
6392
|
assignBundledRuntimeCompositionIds,
|
|
6379
6393
|
assignMediaRenderIds,
|
|
@@ -6596,8 +6610,8 @@ import {
|
|
|
6596
6610
|
|
|
6597
6611
|
// src/services/animatedGifPrep.ts
|
|
6598
6612
|
import { createHash as createHash4 } from "node:crypto";
|
|
6599
|
-
import { copyFileSync as copyFileSync2, existsSync as
|
|
6600
|
-
import { dirname as dirname6, isAbsolute as isAbsolute2, join as
|
|
6613
|
+
import { copyFileSync as copyFileSync2, existsSync as existsSync10, mkdirSync as mkdirSync7, readFileSync as readFileSync6, rmSync as rmSync9, statSync as statSync6 } from "node:fs";
|
|
6614
|
+
import { dirname as dirname6, isAbsolute as isAbsolute2, join as join16, resolve as resolve5 } from "node:path";
|
|
6601
6615
|
import { parseHTML as parseHTML3 } from "linkedom";
|
|
6602
6616
|
import { parseAnimatedGifMetadata } from "@hyperframes/core";
|
|
6603
6617
|
import { DEFAULT_VP9_CPU_USED, runFfmpeg as runFfmpeg2, renameWithRetry as renameWithRetry3 } from "@hyperframes/engine";
|
|
@@ -6635,14 +6649,14 @@ function resolveLocalImageSourcePath(src, options) {
|
|
|
6635
6649
|
const { basePath } = splitUrlSuffix(trimmed);
|
|
6636
6650
|
const normalizedBase = normalizeRelPath(basePath);
|
|
6637
6651
|
const mapped = options.sourceAssets?.get(trimmed) ?? options.sourceAssets?.get(basePath) ?? options.sourceAssets?.get(normalizedBase);
|
|
6638
|
-
if (mapped &&
|
|
6652
|
+
if (mapped && existsSync10(mapped)) return mapped;
|
|
6639
6653
|
if (isHttpUrl(trimmed)) return null;
|
|
6640
6654
|
const projectRelative = basePath.startsWith("/") ? basePath.slice(1) : basePath;
|
|
6641
6655
|
const candidates = [
|
|
6642
6656
|
isAbsolute2(basePath) ? basePath : resolve5(options.projectDir, projectRelative),
|
|
6643
6657
|
resolve5(options.downloadDir, normalizedBase)
|
|
6644
6658
|
];
|
|
6645
|
-
return candidates.find((candidate) =>
|
|
6659
|
+
return candidates.find((candidate) => existsSync10(candidate)) ?? null;
|
|
6646
6660
|
}
|
|
6647
6661
|
function isUsableFile(path) {
|
|
6648
6662
|
try {
|
|
@@ -6753,10 +6767,10 @@ async function runAnimatedGifTranscode(request) {
|
|
|
6753
6767
|
throw result.error ?? new Error(`Animated GIF transcode failed (${result.exitCode}): ${result.stderr.slice(-500)}`);
|
|
6754
6768
|
}
|
|
6755
6769
|
async function ensurePreparedWebm(input) {
|
|
6756
|
-
if (!
|
|
6770
|
+
if (!existsSync10(dirname6(input.cachePath))) {
|
|
6757
6771
|
mkdirSync7(dirname6(input.cachePath), { recursive: true });
|
|
6758
6772
|
}
|
|
6759
|
-
if (!
|
|
6773
|
+
if (!existsSync10(dirname6(input.outputPath))) {
|
|
6760
6774
|
mkdirSync7(dirname6(input.outputPath), { recursive: true });
|
|
6761
6775
|
}
|
|
6762
6776
|
if (!isUsableFile(input.cachePath)) {
|
|
@@ -6840,7 +6854,7 @@ function replaceImageWithVideo(input) {
|
|
|
6840
6854
|
return video;
|
|
6841
6855
|
}
|
|
6842
6856
|
async function prepareAnimatedGifInputs(html, options) {
|
|
6843
|
-
const outputDir = options.outputDir ??
|
|
6857
|
+
const outputDir = options.outputDir ?? join16(options.downloadDir, PREPARED_GIF_SUBDIR);
|
|
6844
6858
|
const outputSrcPrefix = normalizeRelPath(options.outputSrcPrefix ?? PREPARED_GIF_SUBDIR);
|
|
6845
6859
|
const cacheDir = options.cacheDir ?? outputDir;
|
|
6846
6860
|
const { document: document2 } = parseHTML3(html);
|
|
@@ -6854,7 +6868,7 @@ async function prepareAnimatedGifInputs(html, options) {
|
|
|
6854
6868
|
if (!hasGifExtension(src)) continue;
|
|
6855
6869
|
const sourcePath = resolveLocalImageSourcePath(src, options);
|
|
6856
6870
|
if (!sourcePath) continue;
|
|
6857
|
-
const bytes =
|
|
6871
|
+
const bytes = readFileSync6(sourcePath);
|
|
6858
6872
|
const metadata = parseAnimatedGifMetadata(bytes);
|
|
6859
6873
|
if (!metadata?.animated) continue;
|
|
6860
6874
|
const loopOverride = readLoopOverride(img);
|
|
@@ -6867,8 +6881,8 @@ async function prepareAnimatedGifInputs(html, options) {
|
|
|
6867
6881
|
);
|
|
6868
6882
|
const hash = computePreparedGifHash(bytes, loopIterations, padSeconds);
|
|
6869
6883
|
const filename = `${CACHE_SCHEMA}-${hash.slice(0, 24)}.webm`;
|
|
6870
|
-
const cachePath =
|
|
6871
|
-
const outputPath =
|
|
6884
|
+
const cachePath = join16(cacheDir, filename);
|
|
6885
|
+
const outputPath = join16(outputDir, filename);
|
|
6872
6886
|
const outputSrc = `${outputSrcPrefix}/${filename}`;
|
|
6873
6887
|
await ensurePreparedWebm({
|
|
6874
6888
|
sourcePath,
|
|
@@ -6907,13 +6921,13 @@ import {
|
|
|
6907
6921
|
copyFileSync as copyFileSync3,
|
|
6908
6922
|
mkdirSync as mkdirSync8,
|
|
6909
6923
|
openSync as openSync4,
|
|
6910
|
-
readFileSync as
|
|
6924
|
+
readFileSync as readFileSync7,
|
|
6911
6925
|
readSync as readSync3,
|
|
6912
6926
|
rmSync as rmSync10,
|
|
6913
6927
|
statSync as statSync7,
|
|
6914
6928
|
writeFileSync as writeFileSync4
|
|
6915
6929
|
} from "node:fs";
|
|
6916
|
-
import { dirname as dirname7, join as
|
|
6930
|
+
import { dirname as dirname7, join as join17, resolve as resolve6 } from "node:path";
|
|
6917
6931
|
import { parseHTML as parseHTML4 } from "linkedom";
|
|
6918
6932
|
import { renameWithRetry as renameWithRetry4, runFfmpeg as runFfmpeg3, runFfprobe } from "@hyperframes/engine";
|
|
6919
6933
|
|
|
@@ -7091,7 +7105,7 @@ function primaryGrid(probed) {
|
|
|
7091
7105
|
async function convertHeifToJpeg(request) {
|
|
7092
7106
|
const probed = await probeJson(request.inputPath, true);
|
|
7093
7107
|
const grid = primaryGrid(probed);
|
|
7094
|
-
const rotation = readHeifPrimaryRotation(
|
|
7108
|
+
const rotation = readHeifPrimaryRotation(readFileSync7(request.inputPath));
|
|
7095
7109
|
const filters = [];
|
|
7096
7110
|
let inputs = [];
|
|
7097
7111
|
let size = probed.streams?.[0];
|
|
@@ -7149,7 +7163,7 @@ function resolveImageSource(src, options) {
|
|
|
7149
7163
|
const path = resolveLocalImageSourcePath(src, options);
|
|
7150
7164
|
const head = path ? readHead(path) : null;
|
|
7151
7165
|
if (!path || !head || !isHeifBytes(head)) return null;
|
|
7152
|
-
return { path, bytes:
|
|
7166
|
+
return { path, bytes: readFileSync7(path), label: `"${splitUrlSuffix(src).basePath}"` };
|
|
7153
7167
|
}
|
|
7154
7168
|
function isUsableFile2(path) {
|
|
7155
7169
|
try {
|
|
@@ -7187,7 +7201,7 @@ async function ensurePreparedJpeg(source, cachePath, outputPath, options) {
|
|
|
7187
7201
|
}
|
|
7188
7202
|
}
|
|
7189
7203
|
async function prepareHeifImageInputs(html, options) {
|
|
7190
|
-
const outputDir = options.outputDir ??
|
|
7204
|
+
const outputDir = options.outputDir ?? join17(options.downloadDir, PREPARED_HEIF_SUBDIR);
|
|
7191
7205
|
const outputSrcPrefix = normalizeRelPath(options.outputSrcPrefix ?? PREPARED_HEIF_SUBDIR);
|
|
7192
7206
|
const cacheDir = options.cacheDir ?? outputDir;
|
|
7193
7207
|
const preparedAssets = /* @__PURE__ */ new Map();
|
|
@@ -7208,7 +7222,7 @@ async function prepareHeifImageInputs(html, options) {
|
|
|
7208
7222
|
await Promise.all(
|
|
7209
7223
|
[...unique].map(
|
|
7210
7224
|
([filename, source]) => withMediaProbeSlot(
|
|
7211
|
-
() => ensurePreparedJpeg(source,
|
|
7225
|
+
() => ensurePreparedJpeg(source, join17(cacheDir, filename), join17(outputDir, filename), options)
|
|
7212
7226
|
).catch((error) => {
|
|
7213
7227
|
if (!options.onFailure) throw error;
|
|
7214
7228
|
failed.add(filename);
|
|
@@ -7220,8 +7234,8 @@ async function prepareHeifImageInputs(html, options) {
|
|
|
7220
7234
|
if (failed.has(filename)) continue;
|
|
7221
7235
|
const outputSrc = `${outputSrcPrefix}/${filename}`;
|
|
7222
7236
|
img.setAttribute("src", outputSrc);
|
|
7223
|
-
preparedAssets.set(outputSrc,
|
|
7224
|
-
preparedImages.push({ sourceSrc: src, outputSrc, outputPath:
|
|
7237
|
+
preparedAssets.set(outputSrc, join17(outputDir, filename));
|
|
7238
|
+
preparedImages.push({ sourceSrc: src, outputSrc, outputPath: join17(outputDir, filename) });
|
|
7225
7239
|
}
|
|
7226
7240
|
return { html: document2.toString(), preparedAssets, preparedImages };
|
|
7227
7241
|
}
|
|
@@ -7231,7 +7245,7 @@ import { createStudioPositionSeekReapplyScript } from "@hyperframes/studio-serve
|
|
|
7231
7245
|
import { getPositionEditsRenderScript } from "@hyperframes/core/runtime/position-edits-render";
|
|
7232
7246
|
|
|
7233
7247
|
// src/services/assetMediaType.ts
|
|
7234
|
-
import { existsSync as
|
|
7248
|
+
import { existsSync as existsSync11 } from "node:fs";
|
|
7235
7249
|
import {
|
|
7236
7250
|
fingerprintElementId,
|
|
7237
7251
|
isNotMediaPayload,
|
|
@@ -7304,7 +7318,7 @@ async function preflightCompositionAssetMediaTypes(input) {
|
|
|
7304
7318
|
input.projectDir,
|
|
7305
7319
|
input.compiledDir
|
|
7306
7320
|
);
|
|
7307
|
-
if (!
|
|
7321
|
+
if (!existsSync11(resolvedPath)) continue;
|
|
7308
7322
|
byPath.set(resolvedPath, [...byPath.get(resolvedPath) ?? [], reference]);
|
|
7309
7323
|
}
|
|
7310
7324
|
const mismatches = [];
|
|
@@ -7557,8 +7571,8 @@ function detectShaderTransitionUsage(html) {
|
|
|
7557
7571
|
async function resolveMediaDuration(src, mediaStart, playbackRate, baseDir, downloadDir, tagName, elementIdentity, log, urlByAbsentLocalPath, probes) {
|
|
7558
7572
|
let filePath = src;
|
|
7559
7573
|
if (isHttpUrl(src)) {
|
|
7560
|
-
const remoteDir =
|
|
7561
|
-
if (!
|
|
7574
|
+
const remoteDir = join18(downloadDir, REMOTE_MEDIA_SUBDIR);
|
|
7575
|
+
if (!existsSync12(remoteDir)) mkdirSync9(remoteDir, { recursive: true });
|
|
7562
7576
|
try {
|
|
7563
7577
|
filePath = await downloadToTemp(src, remoteDir, void 0, void 0, void 0, {
|
|
7564
7578
|
onTelemetry: logRemoteDownloadTelemetry
|
|
@@ -7568,10 +7582,10 @@ async function resolveMediaDuration(src, mediaStart, playbackRate, baseDir, down
|
|
|
7568
7582
|
}
|
|
7569
7583
|
} else {
|
|
7570
7584
|
filePath = decodedUrlPath2(src);
|
|
7571
|
-
if (!filePath.startsWith("/")) filePath =
|
|
7585
|
+
if (!filePath.startsWith("/")) filePath = join18(baseDir, filePath);
|
|
7572
7586
|
filePath = urlByAbsentLocalPath?.get(filePath) ?? filePath;
|
|
7573
7587
|
}
|
|
7574
|
-
if (!isHttpUrl(filePath) && !
|
|
7588
|
+
if (!isHttpUrl(filePath) && !existsSync12(filePath)) {
|
|
7575
7589
|
return { duration: null, resolvedPath: filePath };
|
|
7576
7590
|
}
|
|
7577
7591
|
const withSrcContext = (error) => {
|
|
@@ -7920,7 +7934,7 @@ function inlineSubCompositions(html, subCompositions, projectDir, variableOverri
|
|
|
7920
7934
|
parseHtml: (htmlStr) => parseHTML5(htmlStr).document,
|
|
7921
7935
|
// Mirrors the preview bundler: a sub-composition's SIBLING assets resolve
|
|
7922
7936
|
// against its own directory, project-root refs stay as authored.
|
|
7923
|
-
assetExists: (path) =>
|
|
7937
|
+
assetExists: (path) => existsSync12(resolve7(projectDir, path)),
|
|
7924
7938
|
// Preserve the authored root wrapper as a child of the host, matching
|
|
7925
7939
|
// the preview bundler's shape (htmlBundler.ts's prepareFlattenedInnerRoot,
|
|
7926
7940
|
// which the runtime compositionLoader mirrors with its own copy for the
|
|
@@ -8065,12 +8079,17 @@ async function inlineExternalScripts(html) {
|
|
|
8065
8079
|
if (externalScripts.length === 0) return html;
|
|
8066
8080
|
const downloads = await Promise.allSettled(
|
|
8067
8081
|
externalScripts.map(async ({ el, src }) => {
|
|
8082
|
+
const integrity = el.getAttribute("integrity") || "";
|
|
8083
|
+
const bundled = bundledScript(src);
|
|
8084
|
+
if (bundled && matchesScriptIntegrity(bundled, integrity)) {
|
|
8085
|
+
return { src, text: new TextDecoder().decode(bundled) };
|
|
8086
|
+
}
|
|
8068
8087
|
const response = await fetch(src, {
|
|
8069
8088
|
signal: AbortSignal.timeout(15e3)
|
|
8070
8089
|
});
|
|
8071
8090
|
if (!response.ok) throw new Error(`HTTP ${response.status} for ${src}`);
|
|
8072
8091
|
const bytes = new Uint8Array(await response.arrayBuffer());
|
|
8073
|
-
if (!matchesScriptIntegrity(bytes,
|
|
8092
|
+
if (!matchesScriptIntegrity(bytes, integrity)) {
|
|
8074
8093
|
throw new ScriptIntegrityError(`Subresource integrity mismatch for ${src}`);
|
|
8075
8094
|
}
|
|
8076
8095
|
return { src, text: new TextDecoder().decode(bytes) };
|
|
@@ -8111,7 +8130,7 @@ function collectExternalAssets(html, projectDir) {
|
|
|
8111
8130
|
if (isPathInside2(absPath, absProjectDir)) {
|
|
8112
8131
|
return null;
|
|
8113
8132
|
}
|
|
8114
|
-
if (!
|
|
8133
|
+
if (!existsSync12(absPath)) return null;
|
|
8115
8134
|
const safeKey = toExternalAssetKey(absPath);
|
|
8116
8135
|
externalAssets.set(safeKey, absPath);
|
|
8117
8136
|
return safeKey;
|
|
@@ -8161,7 +8180,7 @@ var REMOTE_SOURCE_TAG_RE = /<source\b[^>]*?\bsrc\s*=\s*["'](https?:\/\/[^"']+)["
|
|
|
8161
8180
|
var REMOTE_IMG_TAG_RE = /<img\b[^>]*?(?<![\w-])src\s*=\s*["'](https?:\/\/[^"']+)["'][^>]*>/gi;
|
|
8162
8181
|
async function downloadAndRewriteUrls(urlSet, html, remoteDir, warnLabel, logLabel, extraRewrite) {
|
|
8163
8182
|
if (urlSet.size === 0) return { html, remoteMediaAssets: /* @__PURE__ */ new Map() };
|
|
8164
|
-
if (!
|
|
8183
|
+
if (!existsSync12(remoteDir)) mkdirSync9(remoteDir, { recursive: true });
|
|
8165
8184
|
const urlToLocal = /* @__PURE__ */ new Map();
|
|
8166
8185
|
await Promise.all(
|
|
8167
8186
|
[...urlSet].map(async (url) => {
|
|
@@ -8208,7 +8227,7 @@ async function localizeRemoteMediaSources(html, downloadDir) {
|
|
|
8208
8227
|
return downloadAndRewriteUrls(
|
|
8209
8228
|
urlSet,
|
|
8210
8229
|
html,
|
|
8211
|
-
|
|
8230
|
+
join18(downloadDir, REMOTE_MEDIA_SUBDIR),
|
|
8212
8231
|
"Remote media download failed",
|
|
8213
8232
|
"Localized remote media source(s)"
|
|
8214
8233
|
);
|
|
@@ -8223,7 +8242,7 @@ async function localizeRemoteImageSources(html, downloadDir) {
|
|
|
8223
8242
|
return downloadAndRewriteUrls(
|
|
8224
8243
|
urlSet,
|
|
8225
8244
|
html,
|
|
8226
|
-
|
|
8245
|
+
join18(downloadDir, REMOTE_MEDIA_SUBDIR),
|
|
8227
8246
|
"Remote image download failed",
|
|
8228
8247
|
"Localized remote image source(s)"
|
|
8229
8248
|
);
|
|
@@ -8239,7 +8258,7 @@ async function localizeRemoteBackgroundImages(html, downloadDir) {
|
|
|
8239
8258
|
return downloadAndRewriteUrls(
|
|
8240
8259
|
urlSet,
|
|
8241
8260
|
html,
|
|
8242
|
-
|
|
8261
|
+
join18(downloadDir, REMOTE_MEDIA_SUBDIR),
|
|
8243
8262
|
"Remote background-image download failed",
|
|
8244
8263
|
"Localized remote background-image(s)",
|
|
8245
8264
|
// Quoted url('..')/url("..") are rewritten by downloadAndRewriteUrls' default
|
|
@@ -8344,13 +8363,13 @@ function projectStylesheetFontFamilies(html, projectDir) {
|
|
|
8344
8363
|
const href = /\bhref=["']([^"']+)["']/i.exec(tag)?.[1];
|
|
8345
8364
|
if (!href || /^(?:[a-z][a-z\d+.-]*:|\/\/)/i.test(href)) continue;
|
|
8346
8365
|
const sheet = resolve7(projectDir, decodedUrlPath2(href).replace(/^(?:\.?\/)+/, ""));
|
|
8347
|
-
if (!isPathInside2(sheet, projectDir) || !
|
|
8348
|
-
for (const face of extractFontFaceBlocks(
|
|
8366
|
+
if (!isPathInside2(sheet, projectDir) || !existsSync12(sheet)) continue;
|
|
8367
|
+
for (const face of extractFontFaceBlocks(readFileSync8(sheet, "utf8"))) {
|
|
8349
8368
|
const family = /font-family\s*:\s*([^;}]+)/i.exec(face)?.[1]?.trim().replace(/^['"]|['"]$/g, "");
|
|
8350
8369
|
const shipsFile = [...face.matchAll(LOCAL_FONTFACE_URL_RE)].some(([, url = ""]) => {
|
|
8351
8370
|
const path = decodedUrlPath2(url);
|
|
8352
8371
|
const file = path.startsWith("/") ? resolve7(projectDir, `.${path}`) : resolve7(dirname8(sheet), path);
|
|
8353
|
-
return isPathInside2(file, projectDir) &&
|
|
8372
|
+
return isPathInside2(file, projectDir) && existsSync12(file);
|
|
8354
8373
|
});
|
|
8355
8374
|
if (family && shipsFile) families.push(family);
|
|
8356
8375
|
}
|
|
@@ -8394,7 +8413,7 @@ function localizeFontFaceUrls(html, downloadDir) {
|
|
|
8394
8413
|
return downloadAndRewriteUrls(
|
|
8395
8414
|
collectFontFaceUrls(html),
|
|
8396
8415
|
html,
|
|
8397
|
-
|
|
8416
|
+
join18(downloadDir, REMOTE_MEDIA_SUBDIR),
|
|
8398
8417
|
"Remote font download failed",
|
|
8399
8418
|
"Localized remote font face(s)",
|
|
8400
8419
|
(h, url, relPath) => h.replaceAll(`url(${url})`, `url("${relPath}")`)
|
|
@@ -8478,7 +8497,7 @@ async function embedLocalFontFaces(html, projectDir) {
|
|
|
8478
8497
|
}
|
|
8479
8498
|
function renderGsapDist() {
|
|
8480
8499
|
try {
|
|
8481
|
-
return
|
|
8500
|
+
return gsapCdnDist2(void 0, normalizeGsapBaseUrl(process.env.HYPERFRAMES_GSAP_BASE_URL));
|
|
8482
8501
|
} catch (cause) {
|
|
8483
8502
|
throw new Error(
|
|
8484
8503
|
"Invalid HYPERFRAMES_GSAP_BASE_URL: use an absolute HTTPS npm mirror root (plain HTTP only for localhost) without credentials, query, or fragment",
|
|
@@ -8488,7 +8507,7 @@ function renderGsapDist() {
|
|
|
8488
8507
|
}
|
|
8489
8508
|
function rewriteUnresolvableGsapToCdn(html, projectDir, compSrcPath) {
|
|
8490
8509
|
let gsapDist;
|
|
8491
|
-
const exists = (path) =>
|
|
8510
|
+
const exists = (path) => existsSync12(resolve7(projectDir, path));
|
|
8492
8511
|
return html.replace(
|
|
8493
8512
|
/(<script\b[^>]*\bsrc=["'])([^"']*gsap[^"']*\/dist\/([^"']+))(["'][^>]*>)/gi,
|
|
8494
8513
|
(full, prefix, src, file, suffix) => {
|
|
@@ -8505,7 +8524,7 @@ function rebaseDirectEntryAssetPaths(html, projectDir, htmlPath) {
|
|
|
8505
8524
|
const entryPath = relative2(projectDir, htmlPath).replace(/\\/g, "/");
|
|
8506
8525
|
if (!entryPath.includes("/")) return html;
|
|
8507
8526
|
const { document: document2 } = parseHTML5(html);
|
|
8508
|
-
const assetExists = (path) =>
|
|
8527
|
+
const assetExists = (path) => existsSync12(resolve7(projectDir, path));
|
|
8509
8528
|
rewriteAssetPaths(
|
|
8510
8529
|
document2.querySelectorAll("[src], [href], [srcset]"),
|
|
8511
8530
|
entryPath,
|
|
@@ -9071,11 +9090,11 @@ function adaptAspectAgnosticResolution(requested, aspectAgnostic, width, height,
|
|
|
9071
9090
|
}
|
|
9072
9091
|
function resolveEntryHtmlPath(input) {
|
|
9073
9092
|
const { projectDir, workDir, entryFile, log } = input;
|
|
9074
|
-
const htmlPath =
|
|
9093
|
+
const htmlPath = join19(projectDir, entryFile);
|
|
9075
9094
|
const rawEntry = readTextFile2(htmlPath);
|
|
9076
9095
|
if (entryFile === "index.html" || !isTemplateEntry(rawEntry)) return htmlPath;
|
|
9077
|
-
const projectIndexPath =
|
|
9078
|
-
if (!
|
|
9096
|
+
const projectIndexPath = join19(projectDir, "index.html");
|
|
9097
|
+
if (!existsSync13(projectIndexPath)) {
|
|
9079
9098
|
throw new Error(
|
|
9080
9099
|
`Template entry file "${entryFile}" requires a project index.html to extract its render shell.`
|
|
9081
9100
|
);
|
|
@@ -9090,7 +9109,7 @@ function resolveEntryHtmlPath(input) {
|
|
|
9090
9109
|
`Entry file "${entryFile}" is not mounted from index.html via data-composition-src, so it cannot be rendered independently.`
|
|
9091
9110
|
);
|
|
9092
9111
|
}
|
|
9093
|
-
const wrapperPath =
|
|
9112
|
+
const wrapperPath = join19(workDir, "standalone-entry.html");
|
|
9094
9113
|
writeFileSync5(wrapperPath, standaloneHtml, "utf-8");
|
|
9095
9114
|
log.info("Extracted standalone entry from index.html host context", { entryFile });
|
|
9096
9115
|
return wrapperPath;
|
|
@@ -9111,7 +9130,7 @@ async function runCompileStage(input) {
|
|
|
9111
9130
|
} = input;
|
|
9112
9131
|
const htmlPath = resolveEntryHtmlPath({ projectDir, workDir, entryFile, log });
|
|
9113
9132
|
const compileStart = Date.now();
|
|
9114
|
-
const compiled = await compileForRender(projectDir, htmlPath,
|
|
9133
|
+
const compiled = await compileForRender(projectDir, htmlPath, join19(workDir, "downloads"), {
|
|
9115
9134
|
log,
|
|
9116
9135
|
failClosedFontFetch: failClosedFontFetch === true,
|
|
9117
9136
|
allowSystemFontCapture,
|
|
@@ -9119,7 +9138,7 @@ async function runCompileStage(input) {
|
|
|
9119
9138
|
variables: input.variables,
|
|
9120
9139
|
urlByAbsentLocalPath: input.urlByAbsentLocalPath,
|
|
9121
9140
|
pageMotionBlur: input.pageMotionBlur,
|
|
9122
|
-
animatedGifCacheDir: cfg.extractCacheDir ?
|
|
9141
|
+
animatedGifCacheDir: cfg.extractCacheDir ? join19(cfg.extractCacheDir, "animated-gif") : void 0,
|
|
9123
9142
|
ffmpegProcessTimeout: cfg.ffmpegProcessTimeout
|
|
9124
9143
|
});
|
|
9125
9144
|
assertNotAborted();
|
|
@@ -9176,7 +9195,7 @@ async function runCompileStage(input) {
|
|
|
9176
9195
|
};
|
|
9177
9196
|
await preflightCompositionAssetMediaTypes({
|
|
9178
9197
|
projectDir,
|
|
9179
|
-
compiledDir:
|
|
9198
|
+
compiledDir: join19(workDir, "compiled"),
|
|
9180
9199
|
composition,
|
|
9181
9200
|
signal: abortSignal
|
|
9182
9201
|
});
|
|
@@ -9222,7 +9241,7 @@ async function runCompileStage(input) {
|
|
|
9222
9241
|
|
|
9223
9242
|
// src/services/render/stages/probeStage.ts
|
|
9224
9243
|
import { createHash as createHash7 } from "node:crypto";
|
|
9225
|
-
import { basename as basename6, join as
|
|
9244
|
+
import { basename as basename6, join as join20 } from "node:path";
|
|
9226
9245
|
import { parseHTML as parseHTML6 } from "linkedom";
|
|
9227
9246
|
import {
|
|
9228
9247
|
closeCaptureSession as closeCaptureSession4,
|
|
@@ -9431,7 +9450,7 @@ async function runProbeStage(input) {
|
|
|
9431
9450
|
});
|
|
9432
9451
|
fileServer = await createFileServer({
|
|
9433
9452
|
projectDir,
|
|
9434
|
-
compiledDir:
|
|
9453
|
+
compiledDir: join20(workDir, "compiled"),
|
|
9435
9454
|
port: 0,
|
|
9436
9455
|
preHeadScripts: [VIRTUAL_TIME_SHIM],
|
|
9437
9456
|
fps: job.config.fps
|
|
@@ -9461,7 +9480,7 @@ async function runProbeStage(input) {
|
|
|
9461
9480
|
log.info("Creating capture session...", { attempt, maxAttempts: PROBE_MAX_ATTEMPTS });
|
|
9462
9481
|
probeSession = await createCaptureSession4(
|
|
9463
9482
|
fileServer.url,
|
|
9464
|
-
|
|
9483
|
+
join20(workDir, "probe"),
|
|
9465
9484
|
captureOpts,
|
|
9466
9485
|
null,
|
|
9467
9486
|
probeCfg
|
|
@@ -9546,7 +9565,7 @@ async function runProbeStage(input) {
|
|
|
9546
9565
|
});
|
|
9547
9566
|
probeSession = await createCaptureSession4(
|
|
9548
9567
|
fileServer.url,
|
|
9549
|
-
|
|
9568
|
+
join20(workDir, "probe-screenshot"),
|
|
9550
9569
|
captureOpts,
|
|
9551
9570
|
null,
|
|
9552
9571
|
{ ...probeCfg, forceScreenshot: true }
|
|
@@ -9584,7 +9603,7 @@ async function runProbeStage(input) {
|
|
|
9584
9603
|
compiled,
|
|
9585
9604
|
resolutions,
|
|
9586
9605
|
projectDir,
|
|
9587
|
-
|
|
9606
|
+
join20(workDir, "downloads")
|
|
9588
9607
|
);
|
|
9589
9608
|
assertNotAborted();
|
|
9590
9609
|
composition.videos = compiled.videos;
|
|
@@ -9775,7 +9794,7 @@ async function runProbeStage(input) {
|
|
|
9775
9794
|
}
|
|
9776
9795
|
await preflightCompositionAssetMediaTypes({
|
|
9777
9796
|
projectDir,
|
|
9778
|
-
compiledDir:
|
|
9797
|
+
compiledDir: join20(workDir, "compiled"),
|
|
9779
9798
|
composition,
|
|
9780
9799
|
signal: abortSignal
|
|
9781
9800
|
});
|
|
@@ -9941,8 +9960,8 @@ function validateDistributedDuration(input) {
|
|
|
9941
9960
|
}
|
|
9942
9961
|
|
|
9943
9962
|
// src/services/render/stages/extractVideosStage.ts
|
|
9944
|
-
import { existsSync as
|
|
9945
|
-
import { join as
|
|
9963
|
+
import { existsSync as existsSync14 } from "node:fs";
|
|
9964
|
+
import { join as join21 } from "node:path";
|
|
9946
9965
|
import {
|
|
9947
9966
|
classifyVideoExtractionError,
|
|
9948
9967
|
createFrameLookupTable as createFrameLookupTable3,
|
|
@@ -10216,7 +10235,7 @@ async function runExtractVideosStage(input) {
|
|
|
10216
10235
|
const probeFailures = await Promise.all(
|
|
10217
10236
|
composition.videos.map(async (v) => {
|
|
10218
10237
|
const videoPath = resolveProjectRelativeSrc3(v.src, projectDir, compiledDir);
|
|
10219
|
-
if (!
|
|
10238
|
+
if (!existsSync14(videoPath)) return null;
|
|
10220
10239
|
try {
|
|
10221
10240
|
const attempted = extractionPolicy.maxTransientRetries === 0 ? { result: await extractMediaMetadata3(videoPath), retries: 0 } : await runVideoExtractionWithRetry2(() => extractMediaMetadata3(videoPath), {
|
|
10222
10241
|
signal: abortSignal,
|
|
@@ -10254,7 +10273,7 @@ async function runExtractVideosStage(input) {
|
|
|
10254
10273
|
const probed = await Promise.all(
|
|
10255
10274
|
composition.images.map(async (img) => {
|
|
10256
10275
|
const imgPath = resolveProjectRelativeSrc3(img.src, projectDir, compiledDir);
|
|
10257
|
-
if (!
|
|
10276
|
+
if (!existsSync14(imgPath)) return null;
|
|
10258
10277
|
const colorSpace = await probeColorSpaceSafely(imgPath, log);
|
|
10259
10278
|
if (isHdrColorSpace2(colorSpace)) {
|
|
10260
10279
|
nativeHdrImageIds.add(img.id);
|
|
@@ -10288,14 +10307,14 @@ async function runExtractVideosStage(input) {
|
|
|
10288
10307
|
// because short boundary counts can differ by one frame.
|
|
10289
10308
|
{
|
|
10290
10309
|
fps: job.config.fps,
|
|
10291
|
-
outputDir:
|
|
10310
|
+
outputDir: join21(compiledDir, "__hyperframes_video_frames"),
|
|
10292
10311
|
format: job.config.videoFrameFormat ?? "auto",
|
|
10293
10312
|
toneMapHdrToSdr: rendersSdrOnly(job.config, composition),
|
|
10294
10313
|
timelineEnd: composition.duration,
|
|
10295
10314
|
maxTransientRetries: extractionPolicy.maxTransientRetries,
|
|
10296
10315
|
collectProbeFailures: extractionPolicy.failureMode === "enforce",
|
|
10297
10316
|
deferRangeExtraction,
|
|
10298
|
-
contentKeyedDirs: [
|
|
10317
|
+
contentKeyedDirs: [join21(compiledDir, REMOTE_MEDIA_SUBDIR)],
|
|
10299
10318
|
urlByAbsentLocalPath,
|
|
10300
10319
|
onProgress: ({ planned = 0, done = 0 }) => {
|
|
10301
10320
|
framesPlanned += planned;
|
|
@@ -10374,7 +10393,7 @@ async function appendVideoAudioFromProbe(input) {
|
|
|
10374
10393
|
videos.map(async (video) => {
|
|
10375
10394
|
const path = isHttpUrl2(video.src) ? video.src : resolveProjectRelativeSrc3(video.src, projectDir, compiledDir);
|
|
10376
10395
|
const readFrom = urlByAbsentLocalPath?.get(path) ?? path;
|
|
10377
|
-
if (!isHttpUrl2(readFrom) && !
|
|
10396
|
+
if (!isHttpUrl2(readFrom) && !existsSync14(readFrom)) return null;
|
|
10378
10397
|
const metadata = await extractMediaMetadata3(readFrom);
|
|
10379
10398
|
const window2 = await resolveFinalFrameExtractionWindow2(
|
|
10380
10399
|
readFrom,
|
|
@@ -10394,7 +10413,7 @@ async function appendVideoAudioFromProbe(input) {
|
|
|
10394
10413
|
}
|
|
10395
10414
|
|
|
10396
10415
|
// src/services/render/videoLayerPassthroughPlan.ts
|
|
10397
|
-
import { existsSync as
|
|
10416
|
+
import { existsSync as existsSync15 } from "node:fs";
|
|
10398
10417
|
import {
|
|
10399
10418
|
buildVideoLayerInput,
|
|
10400
10419
|
isHttpUrl as isHttpUrl3,
|
|
@@ -10462,7 +10481,7 @@ async function planVideoLayerPassthrough(input) {
|
|
|
10462
10481
|
const { video } = q;
|
|
10463
10482
|
if (isHttpUrl3(video.src)) return { reason: "remote_source" };
|
|
10464
10483
|
const path = resolveProjectRelativeSrc4(video.src, input.projectDir, input.compiledDir);
|
|
10465
|
-
if (!
|
|
10484
|
+
if (!existsSync15(path)) return { reason: "source_missing" };
|
|
10466
10485
|
const layout = await probeVideoLayout(input.page, video.id, input.canvas, input.duration);
|
|
10467
10486
|
if ("reason" in layout) return layout;
|
|
10468
10487
|
const layer = await buildVideoLayerInput(
|
|
@@ -10477,8 +10496,8 @@ async function planVideoLayerPassthrough(input) {
|
|
|
10477
10496
|
}
|
|
10478
10497
|
|
|
10479
10498
|
// src/services/render/stages/audioStage.ts
|
|
10480
|
-
import { existsSync as
|
|
10481
|
-
import { join as
|
|
10499
|
+
import { existsSync as existsSync17 } from "node:fs";
|
|
10500
|
+
import { join as join24 } from "node:path";
|
|
10482
10501
|
import {
|
|
10483
10502
|
MIXED_AUDIO_FILENAME,
|
|
10484
10503
|
audioFailureDiagnostics,
|
|
@@ -10488,8 +10507,8 @@ import {
|
|
|
10488
10507
|
} from "@hyperframes/engine";
|
|
10489
10508
|
|
|
10490
10509
|
// src/services/render/audioDeliveryLimit.ts
|
|
10491
|
-
import { existsSync as
|
|
10492
|
-
import { dirname as dirname10, join as
|
|
10510
|
+
import { existsSync as existsSync16 } from "node:fs";
|
|
10511
|
+
import { dirname as dirname10, join as join23 } from "node:path";
|
|
10493
10512
|
import {
|
|
10494
10513
|
applyAudioFxChain,
|
|
10495
10514
|
describeFfmpegFailure as describeFfmpegFailure3,
|
|
@@ -10499,7 +10518,7 @@ import {
|
|
|
10499
10518
|
|
|
10500
10519
|
// src/services/render/audioPadTrim.ts
|
|
10501
10520
|
import { spawn } from "node:child_process";
|
|
10502
|
-
import { dirname as dirname9, join as
|
|
10521
|
+
import { dirname as dirname9, join as join22 } from "node:path";
|
|
10503
10522
|
import {
|
|
10504
10523
|
DEFAULT_CONFIG,
|
|
10505
10524
|
describeFfmpegFailure as describeFfmpegFailure2,
|
|
@@ -10779,7 +10798,7 @@ async function constrainAacTruePeak(input) {
|
|
|
10779
10798
|
}
|
|
10780
10799
|
async function cutSource(input, scratchDir, attenuationDb) {
|
|
10781
10800
|
if (!input.sourcePath || !input.rewriteSource) return true;
|
|
10782
|
-
const cutPath =
|
|
10801
|
+
const cutPath = join22(scratchDir, "source.wav");
|
|
10783
10802
|
try {
|
|
10784
10803
|
const result = await input.rewriteSource(input.sourcePath, cutPath, gainFilter(attenuationDb));
|
|
10785
10804
|
if (!result.success) throw new Error(result.error);
|
|
@@ -10794,7 +10813,7 @@ async function enforceAacTruePeak(input) {
|
|
|
10794
10813
|
let scratchDir;
|
|
10795
10814
|
try {
|
|
10796
10815
|
scratchDir = createStagingDir3(dirname9(input.audioPath), ".true-peak-");
|
|
10797
|
-
const correctedPath =
|
|
10816
|
+
const correctedPath = join22(scratchDir, "audio.m4a");
|
|
10798
10817
|
const measurements = [];
|
|
10799
10818
|
let attenuationDb = 0;
|
|
10800
10819
|
let sourcePeakDbfs;
|
|
@@ -10997,14 +11016,14 @@ async function limitDeliveryPeaks(input, deps = {
|
|
|
10997
11016
|
applyChain: applyAudioFxChain,
|
|
10998
11017
|
encode: encodeAac2,
|
|
10999
11018
|
rename: renameWithRetry6,
|
|
11000
|
-
sourceExists:
|
|
11019
|
+
sourceExists: existsSync16
|
|
11001
11020
|
}) {
|
|
11002
11021
|
const { audioPath, sourcePath, signal, timeoutMs } = input;
|
|
11003
11022
|
if (!deps.sourceExists(sourcePath)) return { success: true };
|
|
11004
11023
|
const peak = await deps.measure(audioPath, { timeoutMs, signal });
|
|
11005
11024
|
if (peak <= AAC_DELIVERY_TRUE_PEAK_DBFS) return { success: true };
|
|
11006
11025
|
const alternating = ["a", "b"].map(
|
|
11007
|
-
(k) =>
|
|
11026
|
+
(k) => join23(dirname10(sourcePath), `audio-source-limited-${k}.wav`)
|
|
11008
11027
|
);
|
|
11009
11028
|
let encodedFrom;
|
|
11010
11029
|
let ceiling = AAC_DELIVERY_TRUE_PEAK_DBFS;
|
|
@@ -11076,7 +11095,7 @@ function runAudioStage(input) {
|
|
|
11076
11095
|
}
|
|
11077
11096
|
async function runAudioStageScoped(input) {
|
|
11078
11097
|
const stageStart = Date.now();
|
|
11079
|
-
const pcmSourcePath =
|
|
11098
|
+
const pcmSourcePath = join24(input.workDir, "audio-source.wav");
|
|
11080
11099
|
const duration = input.totalFrames * input.fps.den / input.fps.num;
|
|
11081
11100
|
let deliverySourcePath;
|
|
11082
11101
|
try {
|
|
@@ -11092,7 +11111,7 @@ async function runAudioStageScoped(input) {
|
|
|
11092
11111
|
);
|
|
11093
11112
|
audioLoweredDb = guard.loweredDb;
|
|
11094
11113
|
input.log?.info("[audio] phases", { ...result.audioPhaseMs, guard: Date.now() - guardStart });
|
|
11095
|
-
if (input.keepDeliverySource && !guard.sourceStale &&
|
|
11114
|
+
if (input.keepDeliverySource && !guard.sourceStale && existsSync17(pcmSourcePath)) {
|
|
11096
11115
|
deliverySourcePath = pcmSourcePath;
|
|
11097
11116
|
}
|
|
11098
11117
|
}
|
|
@@ -11141,7 +11160,7 @@ async function mixAudioForDelivery(input, duration, pcmSourcePath) {
|
|
|
11141
11160
|
assertNotAborted,
|
|
11142
11161
|
log
|
|
11143
11162
|
} = input;
|
|
11144
|
-
const audioOutputPath =
|
|
11163
|
+
const audioOutputPath = join24(workDir, MIXED_AUDIO_FILENAME);
|
|
11145
11164
|
let hasAudio = false;
|
|
11146
11165
|
let audioError;
|
|
11147
11166
|
let audioFailures;
|
|
@@ -11152,7 +11171,7 @@ async function mixAudioForDelivery(input, duration, pcmSourcePath) {
|
|
|
11152
11171
|
audioResult = await processCompositionAudio(
|
|
11153
11172
|
audios,
|
|
11154
11173
|
projectDir,
|
|
11155
|
-
|
|
11174
|
+
join24(workDir, "audio-work"),
|
|
11156
11175
|
audioOutputPath,
|
|
11157
11176
|
duration,
|
|
11158
11177
|
abortSignal,
|
|
@@ -11220,8 +11239,8 @@ async function mixAudioForDelivery(input, duration, pcmSourcePath) {
|
|
|
11220
11239
|
}
|
|
11221
11240
|
|
|
11222
11241
|
// src/services/render/stages/captureStage.ts
|
|
11223
|
-
import { existsSync as
|
|
11224
|
-
import { join as
|
|
11242
|
+
import { existsSync as existsSync18, readdirSync as readdirSync4, statfsSync as statfsSync2 } from "node:fs";
|
|
11243
|
+
import { join as join25 } from "node:path";
|
|
11225
11244
|
import {
|
|
11226
11245
|
classifyCaptureFailure as classifyCaptureFailure2,
|
|
11227
11246
|
frameFileExtension,
|
|
@@ -11291,16 +11310,16 @@ function diskCaptureShortfallError(needBytes, freeBytes, framesDir, basis, remed
|
|
|
11291
11310
|
}
|
|
11292
11311
|
function measureCaptureFrameBytes(workDir, framesDir) {
|
|
11293
11312
|
let total = sampleDirectoryBytes(framesDir);
|
|
11294
|
-
if (!
|
|
11313
|
+
if (!existsSync18(workDir)) return total;
|
|
11295
11314
|
for (const attempt of readdirSync4(workDir)) {
|
|
11296
11315
|
if (/^retry-\d+-batch-\d+-worker-\d+$/.test(attempt)) {
|
|
11297
|
-
total += sampleDirectoryBytes(
|
|
11316
|
+
total += sampleDirectoryBytes(join25(workDir, attempt));
|
|
11298
11317
|
continue;
|
|
11299
11318
|
}
|
|
11300
11319
|
if (!/^capture-attempt-\d+$/.test(attempt)) continue;
|
|
11301
|
-
const attemptDir =
|
|
11320
|
+
const attemptDir = join25(workDir, attempt);
|
|
11302
11321
|
for (const name of readdirSync4(attemptDir)) {
|
|
11303
|
-
if (/^worker-\d+$/.test(name)) total += sampleDirectoryBytes(
|
|
11322
|
+
if (/^worker-\d+$/.test(name)) total += sampleDirectoryBytes(join25(attemptDir, name));
|
|
11304
11323
|
}
|
|
11305
11324
|
}
|
|
11306
11325
|
return total;
|
|
@@ -11598,8 +11617,8 @@ async function captureSessionFrames(session, { input, rangeStart, rangeEnd, resu
|
|
|
11598
11617
|
}
|
|
11599
11618
|
|
|
11600
11619
|
// src/services/render/stages/captureHdrStage.ts
|
|
11601
|
-
import { existsSync as
|
|
11602
|
-
import { join as
|
|
11620
|
+
import { existsSync as existsSync20, mkdirSync as mkdirSync10 } from "node:fs";
|
|
11621
|
+
import { join as join29 } from "node:path";
|
|
11603
11622
|
import {
|
|
11604
11623
|
closeCaptureSession as closeCaptureSession7,
|
|
11605
11624
|
cloneCaptureWarnings as cloneCaptureWarnings2,
|
|
@@ -11671,7 +11690,7 @@ function createHdrImageTransferCache(options = {}) {
|
|
|
11671
11690
|
}
|
|
11672
11691
|
|
|
11673
11692
|
// src/services/render/stages/captureHdrSequentialLoop.ts
|
|
11674
|
-
import { join as
|
|
11693
|
+
import { join as join26 } from "node:path";
|
|
11675
11694
|
import {
|
|
11676
11695
|
TRANSITIONS,
|
|
11677
11696
|
crossfade
|
|
@@ -11796,7 +11815,7 @@ async function runSequentialLayeredFrameLoop(input) {
|
|
|
11796
11815
|
);
|
|
11797
11816
|
if (debugDumpEnabled && debugDumpDir && i % 30 === 0) {
|
|
11798
11817
|
writeFileExclusiveSync(
|
|
11799
|
-
|
|
11818
|
+
join26(debugDumpDir, `frame_${String(i).padStart(4, "0")}_final_rgb48le.bin`),
|
|
11800
11819
|
normalCanvas
|
|
11801
11820
|
);
|
|
11802
11821
|
}
|
|
@@ -11828,7 +11847,7 @@ async function runSequentialLayeredFrameLoop(input) {
|
|
|
11828
11847
|
}
|
|
11829
11848
|
|
|
11830
11849
|
// src/services/render/stages/captureHdrHybridLoop.ts
|
|
11831
|
-
import { join as
|
|
11850
|
+
import { join as join28 } from "node:path";
|
|
11832
11851
|
import {
|
|
11833
11852
|
TRANSITIONS as TRANSITIONS2,
|
|
11834
11853
|
closeCaptureSession as closeCaptureSession6,
|
|
@@ -11842,9 +11861,9 @@ import {
|
|
|
11842
11861
|
// src/services/shaderTransitionWorkerPool.ts
|
|
11843
11862
|
import { Worker } from "node:worker_threads";
|
|
11844
11863
|
import { fileURLToPath as fileURLToPath3, pathToFileURL } from "node:url";
|
|
11845
|
-
import { dirname as dirname11, join as
|
|
11864
|
+
import { dirname as dirname11, join as join27 } from "node:path";
|
|
11846
11865
|
import { createRequire } from "node:module";
|
|
11847
|
-
import { existsSync as
|
|
11866
|
+
import { existsSync as existsSync19 } from "node:fs";
|
|
11848
11867
|
import { cpus as cpus2 } from "node:os";
|
|
11849
11868
|
function resolveWorkerEntry(explicit) {
|
|
11850
11869
|
if (explicit && explicit.length > 0) {
|
|
@@ -11856,9 +11875,9 @@ function resolveWorkerEntry(explicit) {
|
|
|
11856
11875
|
return { path: override, isTs };
|
|
11857
11876
|
}
|
|
11858
11877
|
const moduleDir = dirname11(fileURLToPath3(import.meta.url));
|
|
11859
|
-
const jsPath =
|
|
11860
|
-
if (
|
|
11861
|
-
const tsPath =
|
|
11878
|
+
const jsPath = join27(moduleDir, "shaderTransitionWorker.js");
|
|
11879
|
+
if (existsSync19(jsPath)) return { path: jsPath, isTs: false };
|
|
11880
|
+
const tsPath = join27(moduleDir, "shaderTransitionWorker.ts");
|
|
11862
11881
|
return { path: tsPath, isTs: true };
|
|
11863
11882
|
}
|
|
11864
11883
|
function buildExecArgv(entryIsTs) {
|
|
@@ -12226,7 +12245,7 @@ async function runHybridLayeredFrameLoop(input) {
|
|
|
12226
12245
|
);
|
|
12227
12246
|
if (debugDumpEnabled && debugDumpDir && i % 30 === 0) {
|
|
12228
12247
|
writeFileExclusiveSync(
|
|
12229
|
-
|
|
12248
|
+
join28(debugDumpDir, `frame_${String(i).padStart(4, "0")}_final_rgb48le.bin`),
|
|
12230
12249
|
canvas
|
|
12231
12250
|
);
|
|
12232
12251
|
}
|
|
@@ -12417,8 +12436,8 @@ async function runCaptureHdrStage(input) {
|
|
|
12417
12436
|
if (hdrVideoFrameSources.has(v.id)) hdrVideoEndTimes.set(v.id, v.end);
|
|
12418
12437
|
}
|
|
12419
12438
|
const debugDumpEnabled = process.env.KEEP_TEMP === "1";
|
|
12420
|
-
const debugDumpDir = debugDumpEnabled ?
|
|
12421
|
-
if (debugDumpDir && !
|
|
12439
|
+
const debugDumpDir = debugDumpEnabled ? join29(framesDir, "debug-composite") : null;
|
|
12440
|
+
if (debugDumpDir && !existsSync20(debugDumpDir)) {
|
|
12422
12441
|
mkdirSync10(debugDumpDir, { recursive: true });
|
|
12423
12442
|
}
|
|
12424
12443
|
const compositeTransfer = resolveCompositeTransfer(hasHdrContent, effectiveHdr);
|
|
@@ -12575,16 +12594,16 @@ async function runCaptureHdrStage(input) {
|
|
|
12575
12594
|
// src/services/render/stages/encodeStage.ts
|
|
12576
12595
|
import {
|
|
12577
12596
|
copyFileSync as copyFileSync4,
|
|
12578
|
-
existsSync as
|
|
12597
|
+
existsSync as existsSync21,
|
|
12579
12598
|
mkdirSync as mkdirSync11,
|
|
12580
12599
|
readdirSync as readdirSync5,
|
|
12581
|
-
readFileSync as
|
|
12600
|
+
readFileSync as readFileSync9,
|
|
12582
12601
|
rmSync as rmSync11,
|
|
12583
12602
|
statSync as statSync8,
|
|
12584
12603
|
writeFileSync as writeFileSync6
|
|
12585
12604
|
} from "node:fs";
|
|
12586
12605
|
import { readFile as readFile2 } from "node:fs/promises";
|
|
12587
|
-
import { dirname as dirname12, join as
|
|
12606
|
+
import { dirname as dirname12, join as join30 } from "node:path";
|
|
12588
12607
|
import {
|
|
12589
12608
|
encodeFramesChunkedConcat,
|
|
12590
12609
|
encodeFramesFromDir,
|
|
@@ -12672,7 +12691,7 @@ async function reencodeWithClearedWholeFrames(argsInput, run, startTime) {
|
|
|
12672
12691
|
const error = formatFfmpegError(result.exitCode, result.stderr);
|
|
12673
12692
|
return gifEncodeFailure(startTime, outputPath, error, result.failureReason);
|
|
12674
12693
|
}
|
|
12675
|
-
const gif =
|
|
12694
|
+
const gif = readFileSync9(outputPath);
|
|
12676
12695
|
if (!clearGifFramesBeforeNext(gif)) {
|
|
12677
12696
|
const error = "[FFmpeg] GIF output could not be parsed to clear its frames";
|
|
12678
12697
|
return gifEncodeFailure(startTime, outputPath, error);
|
|
@@ -12705,11 +12724,11 @@ async function encodeGifFromDir(framesDir, framePattern, outputPath, input) {
|
|
|
12705
12724
|
return gifEncodeFailure(startTime, outputPath, error, result.failureReason);
|
|
12706
12725
|
}
|
|
12707
12726
|
}
|
|
12708
|
-
if (input.preserveAlpha && gifClearsAfterLeavingFrameInPlace(
|
|
12727
|
+
if (input.preserveAlpha && gifClearsAfterLeavingFrameInPlace(readFileSync9(outputPath)) !== false) {
|
|
12709
12728
|
const failure = await reencodeWithClearedWholeFrames(argsInput, run, startTime);
|
|
12710
12729
|
if (failure) return failure;
|
|
12711
12730
|
}
|
|
12712
|
-
const fileSize =
|
|
12731
|
+
const fileSize = existsSync21(outputPath) ? statSync8(outputPath).size : 0;
|
|
12713
12732
|
return {
|
|
12714
12733
|
success: true,
|
|
12715
12734
|
outputPath,
|
|
@@ -12795,7 +12814,7 @@ function encodeWhileCapturing(input, totalFrames) {
|
|
|
12795
12814
|
await new Promise((resolve13) => wake = resolve13);
|
|
12796
12815
|
}
|
|
12797
12816
|
if (signal.aborted) return;
|
|
12798
|
-
const mergedPath =
|
|
12817
|
+
const mergedPath = join30(input.framesDir, formatCaptureFrameName(next, "jpg"));
|
|
12799
12818
|
const frame = await readLandedFrame(landed.get(next), mergedPath);
|
|
12800
12819
|
landed.delete(next);
|
|
12801
12820
|
if (!await stream.writeFrame(frame)) {
|
|
@@ -12870,7 +12889,7 @@ async function runEncodeStage(input) {
|
|
|
12870
12889
|
const stage5Start = Date.now();
|
|
12871
12890
|
if (isPngSequence) {
|
|
12872
12891
|
const encoded = startEncodeProgress(job, "Writing PNG sequence", onProgress);
|
|
12873
|
-
if (!
|
|
12892
|
+
if (!existsSync21(outputPath)) mkdirSync11(outputPath, { recursive: true });
|
|
12874
12893
|
const captured = readdirSync5(framesDir).filter((name) => name.endsWith(".png")).sort();
|
|
12875
12894
|
if (captured.length === 0) {
|
|
12876
12895
|
throw new Error(
|
|
@@ -12878,11 +12897,11 @@ async function runEncodeStage(input) {
|
|
|
12878
12897
|
);
|
|
12879
12898
|
}
|
|
12880
12899
|
captured.forEach((name, i) => {
|
|
12881
|
-
const dst =
|
|
12882
|
-
copyFileSync4(
|
|
12900
|
+
const dst = join30(outputPath, formatExportFrameName(i, "png"));
|
|
12901
|
+
copyFileSync4(join30(framesDir, name), dst);
|
|
12883
12902
|
});
|
|
12884
|
-
if (hasAudio && audioOutputPath &&
|
|
12885
|
-
copyFileSync4(audioOutputPath,
|
|
12903
|
+
if (hasAudio && audioOutputPath && existsSync21(audioOutputPath)) {
|
|
12904
|
+
copyFileSync4(audioOutputPath, join30(outputPath, MIXED_AUDIO_FILENAME2));
|
|
12886
12905
|
log.info(
|
|
12887
12906
|
`[Render] png-sequence: ${MIXED_AUDIO_FILENAME2} sidecar written to ${outputPath}/${MIXED_AUDIO_FILENAME2}`
|
|
12888
12907
|
);
|
|
@@ -12902,7 +12921,7 @@ async function runEncodeStage(input) {
|
|
|
12902
12921
|
const encodeResult2 = await encodeGifFromDir(framesDir, framePattern2, outputPath, {
|
|
12903
12922
|
fps: job.config.fps,
|
|
12904
12923
|
loop,
|
|
12905
|
-
palettePath:
|
|
12924
|
+
palettePath: join30(dirname12(videoOnlyPath), "gif-palette.png"),
|
|
12906
12925
|
preserveAlpha: needsAlpha,
|
|
12907
12926
|
signal: abortSignal,
|
|
12908
12927
|
timeout: engineCfg.ffmpegEncodeTimeout
|
|
@@ -13113,7 +13132,7 @@ function sampleDirectoryBytes(dir) {
|
|
|
13113
13132
|
continue;
|
|
13114
13133
|
}
|
|
13115
13134
|
for (const name of entries) {
|
|
13116
|
-
const full =
|
|
13135
|
+
const full = join31(current, name);
|
|
13117
13136
|
try {
|
|
13118
13137
|
const st = statSync9(full);
|
|
13119
13138
|
if (st.isDirectory()) {
|
|
@@ -13269,8 +13288,8 @@ function findMissingFrameRanges(totalFrames, framesDir, frameExt) {
|
|
|
13269
13288
|
const ranges = [];
|
|
13270
13289
|
let rangeStart = null;
|
|
13271
13290
|
for (let frameIndex = 0; frameIndex < totalFrames; frameIndex++) {
|
|
13272
|
-
const framePath =
|
|
13273
|
-
const missing = !
|
|
13291
|
+
const framePath = join31(framesDir, formatCaptureFrameName(frameIndex, frameExt));
|
|
13292
|
+
const missing = !existsSync22(framePath) || statSync9(framePath).size <= 8;
|
|
13274
13293
|
if (missing && rangeStart === null) {
|
|
13275
13294
|
rangeStart = frameIndex;
|
|
13276
13295
|
} else if (!missing && rangeStart !== null) {
|
|
@@ -13286,7 +13305,7 @@ function findMissingFrameRanges(totalFrames, framesDir, frameExt) {
|
|
|
13286
13305
|
function buildMissingFrameRetryBatches(ranges, maxWorkers, workDir, attempt, rangeStart = 0, stride = 1) {
|
|
13287
13306
|
const workersPerBatch = Math.max(1, Math.floor(maxWorkers));
|
|
13288
13307
|
const batches = [];
|
|
13289
|
-
const outputDirFor = (batchIndex, workerId) =>
|
|
13308
|
+
const outputDirFor = (batchIndex, workerId) => join31(workDir, `retry-${attempt}-batch-${batchIndex}-worker-${workerId}`);
|
|
13290
13309
|
if (stride > 1) {
|
|
13291
13310
|
const spans = /* @__PURE__ */ new Map();
|
|
13292
13311
|
for (const range of ranges) {
|
|
@@ -13346,8 +13365,8 @@ function getNextRetryWorkerCount(currentWorkers) {
|
|
|
13346
13365
|
return Math.max(1, Math.floor(currentWorkers / 2));
|
|
13347
13366
|
}
|
|
13348
13367
|
function resolveRenderWorkDirPrefix(outputPath, jobId, platform2 = process.platform, systemTempDir = tmpdir2()) {
|
|
13349
|
-
if (platform2 === "win32" || platform2 === "darwin") return
|
|
13350
|
-
return
|
|
13368
|
+
if (platform2 === "win32" || platform2 === "darwin") return join31(systemTempDir, "hf-render-");
|
|
13369
|
+
return join31(dirname13(outputPath), `work-${jobId}-`);
|
|
13351
13370
|
}
|
|
13352
13371
|
var MAX_TRANSIENT_CAPTURE_RETRIES = 1;
|
|
13353
13372
|
function isTransientCaptureRetryEligible(failureKind, missing, retriesUsed) {
|
|
@@ -13394,8 +13413,8 @@ The composition is too large for the available memory. To reduce memory pressure
|
|
|
13394
13413
|
function countCapturedFrames(totalFrames, framesDir, frameExt) {
|
|
13395
13414
|
let captured = 0;
|
|
13396
13415
|
for (let frameIndex = 0; frameIndex < totalFrames; frameIndex++) {
|
|
13397
|
-
const framePath =
|
|
13398
|
-
if (
|
|
13416
|
+
const framePath = join31(framesDir, formatCaptureFrameName(frameIndex, frameExt));
|
|
13417
|
+
if (existsSync22(framePath)) captured++;
|
|
13399
13418
|
}
|
|
13400
13419
|
return captured;
|
|
13401
13420
|
}
|
|
@@ -13420,7 +13439,7 @@ async function executeDiskCaptureWithAdaptiveRetry(options) {
|
|
|
13420
13439
|
reason: attempt === 0 ? "initial" : pendingTransientRetry ? "transient-retry" : "retry"
|
|
13421
13440
|
});
|
|
13422
13441
|
pendingTransientRetry = false;
|
|
13423
|
-
const attemptWorkDir =
|
|
13442
|
+
const attemptWorkDir = join31(options.workDir, `capture-attempt-${attempt}`);
|
|
13424
13443
|
const batches = missingRanges ? buildMissingFrameRetryBatches(
|
|
13425
13444
|
missingRanges,
|
|
13426
13445
|
currentWorkers,
|
|
@@ -14053,18 +14072,18 @@ function deVerifyFallbackTelemetry(err) {
|
|
|
14053
14072
|
}
|
|
14054
14073
|
function resolveRenderDebugDir() {
|
|
14055
14074
|
const producerRoot = process.env.PRODUCER_RENDERS_DIR ? resolve8(process.env.PRODUCER_RENDERS_DIR, "..") : resolve8(dirname13(fileURLToPath4(import.meta.url)), "../..");
|
|
14056
|
-
return
|
|
14075
|
+
return join31(producerRoot, ".debug");
|
|
14057
14076
|
}
|
|
14058
14077
|
async function executeRenderJob(job, projectDir, outputPath, progressSink, abortSignal, assertRenderActive) {
|
|
14059
14078
|
validateHlsRenderConfig(job.config);
|
|
14060
14079
|
validateDeliveryEncoderConfig(job.config);
|
|
14061
14080
|
const debugDir = resolveRenderDebugDir();
|
|
14062
14081
|
const outputDir = dirname13(outputPath);
|
|
14063
|
-
if (!
|
|
14064
|
-
const workDir = job.config.debug ?
|
|
14082
|
+
if (!existsSync22(outputDir)) mkdirSync12(outputDir, { recursive: true });
|
|
14083
|
+
const workDir = job.config.debug ? join31(debugDir, job.id) : createRenderWorkDir(resolveRenderWorkDirPrefix(outputPath, job.id), outputDir);
|
|
14065
14084
|
const pipelineStart = Date.now();
|
|
14066
14085
|
const baseLog = job.config.logger ?? defaultLogger;
|
|
14067
|
-
const logPath = job.config.debug ?
|
|
14086
|
+
const logPath = job.config.debug ? join31(workDir, "render.log") : null;
|
|
14068
14087
|
const execution = new RenderExecutionContext({
|
|
14069
14088
|
request: { renderJobId: job.id, projectDir, outputPath },
|
|
14070
14089
|
logger: logPath ? createRenderFileLogger(logPath, baseLog) : baseLog,
|
|
@@ -14126,7 +14145,7 @@ async function executeRenderPipeline(input) {
|
|
|
14126
14145
|
imageDecodeFailures: 0
|
|
14127
14146
|
};
|
|
14128
14147
|
let hdrPerf;
|
|
14129
|
-
const perfOutputPath =
|
|
14148
|
+
const perfOutputPath = join31(workDir, "perf-summary.json");
|
|
14130
14149
|
const cfg = { ...job.config.producerConfig ?? resolveConfig2() };
|
|
14131
14150
|
const observability = new RenderObservabilityRecorder({
|
|
14132
14151
|
pipelineStartMs: pipelineStart,
|
|
@@ -14202,7 +14221,7 @@ async function executeRenderPipeline(input) {
|
|
|
14202
14221
|
job.startedAt = /* @__PURE__ */ new Date();
|
|
14203
14222
|
assertNotAborted();
|
|
14204
14223
|
assertConfiguredFfmpegBinariesExist();
|
|
14205
|
-
if (!
|
|
14224
|
+
if (!existsSync22(workDir)) mkdirSync12(workDir, { recursive: true });
|
|
14206
14225
|
if (job.config.debug) {
|
|
14207
14226
|
log.info("[Render] Debug artifacts enabled", { workDir, logPath });
|
|
14208
14227
|
}
|
|
@@ -14231,8 +14250,8 @@ async function executeRenderPipeline(input) {
|
|
|
14231
14250
|
requestedWorkers: job.config.workers ?? "auto"
|
|
14232
14251
|
});
|
|
14233
14252
|
const entryFile = job.config.entryFile || "index.html";
|
|
14234
|
-
const htmlPath =
|
|
14235
|
-
if (!
|
|
14253
|
+
const htmlPath = join31(projectDir, entryFile);
|
|
14254
|
+
if (!existsSync22(htmlPath)) {
|
|
14236
14255
|
throw new Error(`Entry file not found: ${htmlPath}`);
|
|
14237
14256
|
}
|
|
14238
14257
|
assertNotAborted();
|
|
@@ -14408,7 +14427,7 @@ async function executeRenderPipeline(input) {
|
|
|
14408
14427
|
canvas: { width, height },
|
|
14409
14428
|
page: probeSession.page,
|
|
14410
14429
|
projectDir,
|
|
14411
|
-
compiledDir:
|
|
14430
|
+
compiledDir: join31(workDir, "compiled")
|
|
14412
14431
|
});
|
|
14413
14432
|
if (videoLayerPlan.videoId === void 0) {
|
|
14414
14433
|
log.info(`[Render] Video layer passthrough off: ${videoLayerPlan.reason}`);
|
|
@@ -14426,7 +14445,7 @@ async function executeRenderPipeline(input) {
|
|
|
14426
14445
|
updateJobStatus(job, "preprocessing", "Extracting video frames", 10, onProgress, {
|
|
14427
14446
|
code: "extract_video"
|
|
14428
14447
|
});
|
|
14429
|
-
const compiledDir =
|
|
14448
|
+
const compiledDir = join31(workDir, "compiled");
|
|
14430
14449
|
const segmentsCapture = (layeredOrEffectRoute) => shouldSegmentCapture({
|
|
14431
14450
|
env: process.env,
|
|
14432
14451
|
durationSeconds: probeResult.duration,
|
|
@@ -14557,7 +14576,7 @@ async function executeRenderPipeline(input) {
|
|
|
14557
14576
|
try {
|
|
14558
14577
|
fileServer = await createFileServer({
|
|
14559
14578
|
projectDir,
|
|
14560
|
-
compiledDir:
|
|
14579
|
+
compiledDir: join31(workDir, "compiled"),
|
|
14561
14580
|
port: 0,
|
|
14562
14581
|
preHeadScripts: [VIRTUAL_TIME_SHIM],
|
|
14563
14582
|
fps: job.config.fps
|
|
@@ -14575,8 +14594,8 @@ async function executeRenderPipeline(input) {
|
|
|
14575
14594
|
if (!activeFileServer) {
|
|
14576
14595
|
throw new Error("File server failed to initialize before frame capture");
|
|
14577
14596
|
}
|
|
14578
|
-
const framesDir =
|
|
14579
|
-
if (!
|
|
14597
|
+
const framesDir = join31(workDir, "captured-frames");
|
|
14598
|
+
if (!existsSync22(framesDir)) mkdirSync12(framesDir, { recursive: true });
|
|
14580
14599
|
updateJobStatus(job, "rendering", "Checking browser GPU", 25, onProgress, {
|
|
14581
14600
|
code: "start_browsers"
|
|
14582
14601
|
});
|
|
@@ -15140,7 +15159,7 @@ async function executeRenderPipeline(input) {
|
|
|
15140
15159
|
hls: ".mp4"
|
|
15141
15160
|
};
|
|
15142
15161
|
const videoExt = FORMAT_EXT[outputFormat] ?? ".mp4";
|
|
15143
|
-
const videoOnlyPath =
|
|
15162
|
+
const videoOnlyPath = join31(workDir, `video-only${videoExt}`);
|
|
15144
15163
|
const usePageSideCompositingForTransitions = (cfg.enablePageSideCompositing || isGif) && compiled.hasShaderTransitions && !hasHdrContent && outputSupportsPageSideShaderCompositing(outputFormat);
|
|
15145
15164
|
if (usePageSideCompositingForTransitions) {
|
|
15146
15165
|
activeFileServer.addPreHeadScript(HF_PAGE_SIDE_COMPOSITING_STUB);
|
|
@@ -15426,7 +15445,7 @@ async function executeRenderPipeline(input) {
|
|
|
15426
15445
|
pageMotionBlur: job.config.pageMotionBlur,
|
|
15427
15446
|
captureQuality: captureOptions.quality
|
|
15428
15447
|
});
|
|
15429
|
-
const segmentDir = segmentDirFor(
|
|
15448
|
+
const segmentDir = segmentDirFor(join31(projectDir, "renders"), segmentPlanHash);
|
|
15430
15449
|
let completedSegments = /* @__PURE__ */ new Set();
|
|
15431
15450
|
if (job.config.resumeSegments === true) {
|
|
15432
15451
|
const existing = readSegmentManifest(segmentDir);
|
|
@@ -15967,7 +15986,7 @@ async function executeRenderPipeline(input) {
|
|
|
15967
15986
|
})
|
|
15968
15987
|
);
|
|
15969
15988
|
const totalElapsed = Date.now() - pipelineStart;
|
|
15970
|
-
const tmpPeakBytes =
|
|
15989
|
+
const tmpPeakBytes = existsSync22(workDir) ? sampleDirectoryBytes(workDir) : 0;
|
|
15971
15990
|
recordTransientRetryObservability();
|
|
15972
15991
|
observability.checkpoint("pipeline", "artifact validated", { totalElapsedMs: totalElapsed });
|
|
15973
15992
|
const observabilitySummary = observability.summary({
|
|
@@ -16048,8 +16067,8 @@ async function executeRenderPipeline(input) {
|
|
|
16048
16067
|
}
|
|
16049
16068
|
}
|
|
16050
16069
|
if (job.config.debug) {
|
|
16051
|
-
if (!isPngSequence && !isHls &&
|
|
16052
|
-
const debugOutput =
|
|
16070
|
+
if (!isPngSequence && !isHls && existsSync22(stagedOutputPath)) {
|
|
16071
|
+
const debugOutput = join31(workDir, `output${videoExt}`);
|
|
16053
16072
|
copyFileSync5(stagedOutputPath, debugOutput);
|
|
16054
16073
|
}
|
|
16055
16074
|
}
|
|
@@ -16163,15 +16182,15 @@ import {
|
|
|
16163
16182
|
REFERENCE_BACKGROUND_FIELD as REFERENCE_BACKGROUND_FIELD4,
|
|
16164
16183
|
referenceBackgroundResult as referenceBackgroundResult6
|
|
16165
16184
|
} from "@hyperframes/engine";
|
|
16166
|
-
import { mkdirSync as mkdirSync20, mkdtempSync, readFileSync as
|
|
16167
|
-
import { join as
|
|
16185
|
+
import { mkdirSync as mkdirSync20, mkdtempSync, readFileSync as readFileSync15, rmSync as rmSync18 } from "node:fs";
|
|
16186
|
+
import { join as join45 } from "node:path";
|
|
16168
16187
|
import { tmpdir as tmpdir4 } from "node:os";
|
|
16169
16188
|
|
|
16170
16189
|
// src/services/distributed/mp4Stitch.ts
|
|
16171
16190
|
import { createReadStream as createReadStream3, createWriteStream, mkdirSync as mkdirSync13, rmSync as rmSync13 } from "node:fs";
|
|
16172
16191
|
import { open } from "node:fs/promises";
|
|
16173
16192
|
import { renameWithRetry as renameWithRetry7 } from "@hyperframes/engine";
|
|
16174
|
-
import { basename as basename7, dirname as dirname14, join as
|
|
16193
|
+
import { basename as basename7, dirname as dirname14, join as join32 } from "node:path";
|
|
16175
16194
|
import { finished, pipeline } from "node:stream/promises";
|
|
16176
16195
|
import { createStagingDir as createStagingDir4 } from "@hyperframes/core/atomic-file";
|
|
16177
16196
|
function boxAt(src, off, at, limit) {
|
|
@@ -16538,13 +16557,13 @@ async function writeStitchedMp4(chunkPaths, outputPath, audioPath) {
|
|
|
16538
16557
|
const header = audioPath ? buildStitchedHeader(layouts.slice(1), layouts[0]) : buildStitchedHeader(layouts);
|
|
16539
16558
|
mkdirSync13(dirname14(outputPath), { recursive: true });
|
|
16540
16559
|
const workDir = createStagingDir4(dirname14(outputPath), `${basename7(outputPath)}.stitch-`);
|
|
16541
|
-
const out = createWriteStream(
|
|
16560
|
+
const out = createWriteStream(join32(workDir, "out.mp4"));
|
|
16542
16561
|
try {
|
|
16543
16562
|
out.write(header);
|
|
16544
16563
|
for (const [i, path] of sourcePaths.entries()) await copyPayload(path, layouts[i], i, out);
|
|
16545
16564
|
out.end();
|
|
16546
16565
|
await finished(out);
|
|
16547
|
-
renameWithRetry7(
|
|
16566
|
+
renameWithRetry7(join32(workDir, "out.mp4"), outputPath);
|
|
16548
16567
|
} finally {
|
|
16549
16568
|
out.destroy();
|
|
16550
16569
|
rmSync13(workDir, { recursive: true, force: true });
|
|
@@ -16561,13 +16580,13 @@ import { audioFailureDiagnostics as audioFailureDiagnostics3 } from "@hyperframe
|
|
|
16561
16580
|
import {
|
|
16562
16581
|
copyFileSync as copyFileSync6,
|
|
16563
16582
|
cpSync as cpSync2,
|
|
16564
|
-
existsSync as
|
|
16583
|
+
existsSync as existsSync27,
|
|
16565
16584
|
linkSync,
|
|
16566
16585
|
mkdirSync as mkdirSync16,
|
|
16567
16586
|
rmSync as rmSync14,
|
|
16568
16587
|
writeFileSync as writeFileSync10
|
|
16569
16588
|
} from "node:fs";
|
|
16570
|
-
import { extname as extname6, isAbsolute as isAbsolute3, join as
|
|
16589
|
+
import { extname as extname6, isAbsolute as isAbsolute3, join as join40, relative as relative5, sep as sep3 } from "node:path";
|
|
16571
16590
|
import {
|
|
16572
16591
|
fpsToNumber as fpsToNumber9,
|
|
16573
16592
|
HF_COLOR_GRADING_ATTR as HF_COLOR_GRADING_ATTR2
|
|
@@ -16583,7 +16602,7 @@ import {
|
|
|
16583
16602
|
} from "@hyperframes/engine";
|
|
16584
16603
|
|
|
16585
16604
|
// src/services/distributed/planFrameCost.ts
|
|
16586
|
-
import { join as
|
|
16605
|
+
import { join as join35 } from "node:path";
|
|
16587
16606
|
import {
|
|
16588
16607
|
closeCaptureSession as closeCaptureSession9,
|
|
16589
16608
|
createCaptureSession as createCaptureSession9,
|
|
@@ -16592,8 +16611,8 @@ import {
|
|
|
16592
16611
|
} from "@hyperframes/engine";
|
|
16593
16612
|
|
|
16594
16613
|
// src/services/distributed/chunkFrames.ts
|
|
16595
|
-
import { existsSync as
|
|
16596
|
-
import { extname as extname4, join as
|
|
16614
|
+
import { existsSync as existsSync24, readdirSync as readdirSync7 } from "node:fs";
|
|
16615
|
+
import { extname as extname4, join as join34 } from "node:path";
|
|
16597
16616
|
import {
|
|
16598
16617
|
compositionRequiresWebGpu as compositionRequiresWebGpu3,
|
|
16599
16618
|
createVideoFrameInjector as createVideoFrameInjector3
|
|
@@ -16601,8 +16620,8 @@ import {
|
|
|
16601
16620
|
|
|
16602
16621
|
// src/services/distributed/shared.ts
|
|
16603
16622
|
import { execFile as execFileCallback } from "node:child_process";
|
|
16604
|
-
import { dirname as dirname15, join as
|
|
16605
|
-
import { existsSync as
|
|
16623
|
+
import { dirname as dirname15, join as join33 } from "node:path";
|
|
16624
|
+
import { existsSync as existsSync23, readFileSync as readFileSync10 } from "node:fs";
|
|
16606
16625
|
import { fileURLToPath as fileURLToPath5 } from "node:url";
|
|
16607
16626
|
import { promisify as promisify2 } from "node:util";
|
|
16608
16627
|
import {
|
|
@@ -16617,8 +16636,8 @@ function isPlanAudioArtifactPath(path) {
|
|
|
16617
16636
|
}
|
|
16618
16637
|
function resolvePlanAudioPath(planDir) {
|
|
16619
16638
|
for (const name of [PLAN_AUDIO_RELATIVE_PATH, PLAN_AUDIO_LEGACY_RELATIVE_PATH]) {
|
|
16620
|
-
const candidate =
|
|
16621
|
-
if (
|
|
16639
|
+
const candidate = join33(planDir, name);
|
|
16640
|
+
if (existsSync23(candidate)) return candidate;
|
|
16622
16641
|
}
|
|
16623
16642
|
return null;
|
|
16624
16643
|
}
|
|
@@ -16878,10 +16897,10 @@ function readProducerVersion() {
|
|
|
16878
16897
|
const startDir = dirname15(fileURLToPath5(import.meta.url));
|
|
16879
16898
|
let current = startDir;
|
|
16880
16899
|
for (let i = 0; i < 10; i++) {
|
|
16881
|
-
const candidate =
|
|
16882
|
-
if (
|
|
16900
|
+
const candidate = join33(current, "package.json");
|
|
16901
|
+
if (existsSync23(candidate)) {
|
|
16883
16902
|
try {
|
|
16884
|
-
const pkg = JSON.parse(
|
|
16903
|
+
const pkg = JSON.parse(readFileSync10(candidate, "utf-8"));
|
|
16885
16904
|
if (pkg.name === "@hyperframes/producer" && typeof pkg.version === "string") {
|
|
16886
16905
|
cachedProducerVersion = pkg.version;
|
|
16887
16906
|
return pkg.version;
|
|
@@ -16933,8 +16952,8 @@ function frameNumberFromFileName(name) {
|
|
|
16933
16952
|
function rebuildExtractedFramesFromPlanDir(planDir, videos, indexMode = "dense-v1") {
|
|
16934
16953
|
const result = [];
|
|
16935
16954
|
for (const v of videos) {
|
|
16936
|
-
const outputDir =
|
|
16937
|
-
if (!
|
|
16955
|
+
const outputDir = join34(planDir, "video-frames", v.videoId);
|
|
16956
|
+
if (!existsSync24(outputDir)) {
|
|
16938
16957
|
throw new Error(
|
|
16939
16958
|
`[renderChunk] planDir missing extracted video frames for ${JSON.stringify(v.videoId)}: ${outputDir} not present. plan() should have written frames here; the planDir is malformed.`
|
|
16940
16959
|
);
|
|
@@ -16952,7 +16971,7 @@ function rebuildExtractedFramesFromPlanDir(planDir, videos, indexMode = "dense-v
|
|
|
16952
16971
|
if (!frameName) continue;
|
|
16953
16972
|
const frameNumber = indexMode === "sparse-v2" ? frameNumberFromFileName(frameName) : null;
|
|
16954
16973
|
const frameIndex = frameNumber === null ? i : frameNumber - 1;
|
|
16955
|
-
framePaths.set(frameIndex,
|
|
16974
|
+
framePaths.set(frameIndex, join34(outputDir, frameName));
|
|
16956
16975
|
}
|
|
16957
16976
|
result.push({
|
|
16958
16977
|
videoId: v.videoId,
|
|
@@ -17032,8 +17051,8 @@ async function extractDeferredVideoFramesForChunk(input) {
|
|
|
17032
17051
|
sourceOf: (video) => {
|
|
17033
17052
|
const range = planned.get(video.videoId).deferredRange;
|
|
17034
17053
|
const remoteUrl = remoteSources[range.sourcePath];
|
|
17035
|
-
const sourcePath = remoteUrl ??
|
|
17036
|
-
if (remoteUrl === void 0 && !
|
|
17054
|
+
const sourcePath = remoteUrl ?? join34(input.planDir, ...range.sourcePath.split("/"));
|
|
17055
|
+
if (remoteUrl === void 0 && !existsSync24(sourcePath)) {
|
|
17037
17056
|
throw new RenderChunkValidationError(
|
|
17038
17057
|
MISSING_PLAN_ARTIFACT,
|
|
17039
17058
|
`[renderChunk] planDir is missing the source for video ${JSON.stringify(video.videoId)}: ${range.sourcePath}`
|
|
@@ -17063,12 +17082,12 @@ async function measurePlanSecondsPerFrame(input) {
|
|
|
17063
17082
|
planVideos,
|
|
17064
17083
|
frames: sampled,
|
|
17065
17084
|
fps: fpsRatio,
|
|
17066
|
-
outputRoot:
|
|
17085
|
+
outputRoot: join35(workDir, "frame-cost-video-frames"),
|
|
17067
17086
|
cfg: input.cfg
|
|
17068
17087
|
})
|
|
17069
17088
|
];
|
|
17070
17089
|
const lookup = extracted.length > 0 ? createFrameLookupTable4(planVideos.videos, extracted, resolveRenderFpsConfig(fpsRatio).value) : null;
|
|
17071
|
-
const compiledDir =
|
|
17090
|
+
const compiledDir = join35(planDir, "compiled");
|
|
17072
17091
|
const fileServer = await createFileServer({
|
|
17073
17092
|
projectDir: compiledDir,
|
|
17074
17093
|
compiledDir,
|
|
@@ -17080,7 +17099,7 @@ async function measurePlanSecondsPerFrame(input) {
|
|
|
17080
17099
|
try {
|
|
17081
17100
|
session = await createCaptureSession9(
|
|
17082
17101
|
fileServer.url,
|
|
17083
|
-
|
|
17102
|
+
join35(workDir, "frame-cost"),
|
|
17084
17103
|
buildChunkCaptureOptions({
|
|
17085
17104
|
dimensions: { ...input, fpsNum: fps, fpsDen: 1 },
|
|
17086
17105
|
encoder: input,
|
|
@@ -17177,7 +17196,7 @@ function buildWeightedChunkSlices(weights, chunkCount, minFrames, maxFrames) {
|
|
|
17177
17196
|
}
|
|
17178
17197
|
|
|
17179
17198
|
// src/services/render/planReferenceBackground.ts
|
|
17180
|
-
import { join as
|
|
17199
|
+
import { join as join36 } from "node:path";
|
|
17181
17200
|
import {
|
|
17182
17201
|
closeCaptureSession as closeCaptureSession10,
|
|
17183
17202
|
createCaptureSession as createCaptureSession10,
|
|
@@ -17190,14 +17209,14 @@ async function readPlanReferenceBackground(input) {
|
|
|
17190
17209
|
try {
|
|
17191
17210
|
server = await createFileServer({
|
|
17192
17211
|
projectDir: input.projectDir,
|
|
17193
|
-
compiledDir:
|
|
17212
|
+
compiledDir: join36(input.workDir, "compiled"),
|
|
17194
17213
|
port: 0,
|
|
17195
17214
|
preHeadScripts: [VIRTUAL_TIME_SHIM],
|
|
17196
17215
|
fps: input.options.fps
|
|
17197
17216
|
});
|
|
17198
17217
|
session = await createCaptureSession10(
|
|
17199
17218
|
server.url,
|
|
17200
|
-
|
|
17219
|
+
join36(input.workDir, "reference"),
|
|
17201
17220
|
{
|
|
17202
17221
|
...input.options,
|
|
17203
17222
|
requiresWebGpu: false
|
|
@@ -17233,8 +17252,8 @@ async function readPlanReferenceBackground(input) {
|
|
|
17233
17252
|
}
|
|
17234
17253
|
|
|
17235
17254
|
// src/services/render/stages/freezePlan.ts
|
|
17236
|
-
import { existsSync as
|
|
17237
|
-
import { join as
|
|
17255
|
+
import { existsSync as existsSync25, mkdirSync as mkdirSync14, readFileSync as readFileSync11, readdirSync as readdirSync8, writeFileSync as writeFileSync8 } from "node:fs";
|
|
17256
|
+
import { join as join37, relative as relative3, resolve as resolve9 } from "node:path";
|
|
17238
17257
|
import {
|
|
17239
17258
|
REFERENCE_BACKGROUND_FIELD,
|
|
17240
17259
|
referenceBackgroundResult as referenceBackgroundResult3
|
|
@@ -17427,7 +17446,7 @@ function planFileSha256(absolutePath, digests) {
|
|
|
17427
17446
|
return sha256;
|
|
17428
17447
|
}
|
|
17429
17448
|
async function prehashPlanFiles(dir, digests) {
|
|
17430
|
-
if (!
|
|
17449
|
+
if (!existsSync25(dir)) return;
|
|
17431
17450
|
for (const { absolutePath } of listPlanFiles(dir)) {
|
|
17432
17451
|
if (!digests.has(absolutePath)) digests.set(absolutePath, await sha256FileAsync(absolutePath));
|
|
17433
17452
|
}
|
|
@@ -17452,7 +17471,7 @@ function listPlanFiles(planDir) {
|
|
|
17452
17471
|
function walk(dir) {
|
|
17453
17472
|
const entries = readdirSync8(dir, { withFileTypes: true });
|
|
17454
17473
|
for (const entry of entries) {
|
|
17455
|
-
const full =
|
|
17474
|
+
const full = join37(dir, entry.name);
|
|
17456
17475
|
if (entry.isDirectory()) {
|
|
17457
17476
|
walk(full);
|
|
17458
17477
|
} else if (entry.isFile()) {
|
|
@@ -17473,7 +17492,7 @@ function collectPlanAssetShas(planDir, digests) {
|
|
|
17473
17492
|
const assets = [];
|
|
17474
17493
|
for (const file of files) {
|
|
17475
17494
|
if (file.planRelativePath === COMPILED_INDEX_RELATIVE_PATH) {
|
|
17476
|
-
compositionHtml =
|
|
17495
|
+
compositionHtml = readFileSync11(file.absolutePath);
|
|
17477
17496
|
continue;
|
|
17478
17497
|
}
|
|
17479
17498
|
if (HASH_EXCLUDED_PLAN_FILES.has(file.planRelativePath)) continue;
|
|
@@ -17493,23 +17512,23 @@ var PLAN_REMOTE_FILES_RELATIVE_PATH = "meta/remote-files.json";
|
|
|
17493
17512
|
function writePlanRemoteFiles(planDir, files) {
|
|
17494
17513
|
if (files.length === 0) return;
|
|
17495
17514
|
const sorted = [...files].sort((a, b) => a.path < b.path ? -1 : 1);
|
|
17496
|
-
writeFileSync8(
|
|
17515
|
+
writeFileSync8(join37(planDir, PLAN_REMOTE_FILES_RELATIVE_PATH), JSON.stringify(sorted), "utf-8");
|
|
17497
17516
|
}
|
|
17498
17517
|
function readPlanRemoteFiles(planDir) {
|
|
17499
|
-
const path =
|
|
17500
|
-
return
|
|
17518
|
+
const path = join37(planDir, PLAN_REMOTE_FILES_RELATIVE_PATH);
|
|
17519
|
+
return existsSync25(path) ? JSON.parse(readFileSync11(path, "utf-8")) : [];
|
|
17501
17520
|
}
|
|
17502
17521
|
function recomputePlanHashFromPlanDir(planDir, digests) {
|
|
17503
|
-
const planJsonPath =
|
|
17504
|
-
const encoderJsonPath =
|
|
17505
|
-
if (!
|
|
17522
|
+
const planJsonPath = join37(planDir, "plan.json");
|
|
17523
|
+
const encoderJsonPath = join37(planDir, "meta", "encoder.json");
|
|
17524
|
+
if (!existsSync25(planJsonPath)) {
|
|
17506
17525
|
throw new Error(`[freezePlan] plan.json missing: ${planJsonPath}`);
|
|
17507
17526
|
}
|
|
17508
|
-
if (!
|
|
17527
|
+
if (!existsSync25(encoderJsonPath)) {
|
|
17509
17528
|
throw new Error(`[freezePlan] meta/encoder.json missing: ${encoderJsonPath}`);
|
|
17510
17529
|
}
|
|
17511
|
-
const planJson = JSON.parse(
|
|
17512
|
-
const encoderConfigCanonicalJson =
|
|
17530
|
+
const planJson = JSON.parse(readFileSync11(planJsonPath, "utf-8"));
|
|
17531
|
+
const encoderConfigCanonicalJson = readFileSync11(encoderJsonPath, "utf-8");
|
|
17513
17532
|
const { compositionHtml, assets } = collectPlanAssetShas(planDir, digests);
|
|
17514
17533
|
return computePlanHash({
|
|
17515
17534
|
compositionHtml,
|
|
@@ -17535,21 +17554,21 @@ async function freezePlan(input) {
|
|
|
17535
17554
|
hasAudio,
|
|
17536
17555
|
digests
|
|
17537
17556
|
} = input;
|
|
17538
|
-
if (!
|
|
17557
|
+
if (!existsSync25(planDir)) {
|
|
17539
17558
|
throw new Error(`[freezePlan] planDir does not exist: ${planDir}`);
|
|
17540
17559
|
}
|
|
17541
|
-
const metaDir =
|
|
17542
|
-
if (!
|
|
17560
|
+
const metaDir = join37(planDir, "meta");
|
|
17561
|
+
if (!existsSync25(metaDir)) mkdirSync14(metaDir, { recursive: true });
|
|
17543
17562
|
writeFileSync8(
|
|
17544
|
-
|
|
17563
|
+
join37(metaDir, "composition.json"),
|
|
17545
17564
|
`${JSON.stringify(composition, null, 2)}
|
|
17546
17565
|
`,
|
|
17547
17566
|
"utf-8"
|
|
17548
17567
|
);
|
|
17549
17568
|
const encoderForCanonical = stripUndefined(encoder);
|
|
17550
17569
|
const encoderConfigCanonicalJson = canonicalJsonStringify(encoderForCanonical);
|
|
17551
|
-
writeFileSync8(
|
|
17552
|
-
writeFileSync8(
|
|
17570
|
+
writeFileSync8(join37(metaDir, "encoder.json"), encoderConfigCanonicalJson, "utf-8");
|
|
17571
|
+
writeFileSync8(join37(metaDir, "chunks.json"), `${JSON.stringify(chunks, null, 2)}
|
|
17553
17572
|
`, "utf-8");
|
|
17554
17573
|
const { compositionHtml, assets } = collectPlanAssetShas(planDir, digests);
|
|
17555
17574
|
const planHash = computePlanHash({
|
|
@@ -17574,7 +17593,7 @@ async function freezePlan(input) {
|
|
|
17574
17593
|
duration: durationSeconds,
|
|
17575
17594
|
hasAudio
|
|
17576
17595
|
};
|
|
17577
|
-
const planJsonPath =
|
|
17596
|
+
const planJsonPath = join37(planDir, "plan.json");
|
|
17578
17597
|
writeFileSync8(planJsonPath, `${JSON.stringify(planJson, null, 2)}
|
|
17579
17598
|
`, "utf-8");
|
|
17580
17599
|
return { planJsonPath, planHash };
|
|
@@ -17616,9 +17635,9 @@ function applyRuntimeEnvSnapshot(snapshot, env = process.env) {
|
|
|
17616
17635
|
}
|
|
17617
17636
|
|
|
17618
17637
|
// src/services/distributed/chunkAudio.ts
|
|
17619
|
-
import { closeSync as closeSync6, existsSync as
|
|
17638
|
+
import { closeSync as closeSync6, existsSync as existsSync26, ftruncateSync, mkdirSync as mkdirSync15, openSync as openSync6, readFileSync as readFileSync12 } from "node:fs";
|
|
17620
17639
|
import { writeFileSync as writeFileSync9, writeSync } from "node:fs";
|
|
17621
|
-
import { join as
|
|
17640
|
+
import { join as join38 } from "node:path";
|
|
17622
17641
|
import { appendRenderProvenanceArgs, describeFfmpegFailure as describeFfmpegFailure4, runFfmpeg as runFfmpeg7 } from "@hyperframes/engine";
|
|
17623
17642
|
function audioCutForChunk(grid, chunks, index, fps) {
|
|
17624
17643
|
const firstPacketAt = (frame) => Math.min(
|
|
@@ -17704,9 +17723,9 @@ async function writeChunkAudioSlices(input) {
|
|
|
17704
17723
|
offset += track.sizes[offsets.length - 1];
|
|
17705
17724
|
}
|
|
17706
17725
|
});
|
|
17707
|
-
const bytes =
|
|
17726
|
+
const bytes = readFileSync12(input.audioPath);
|
|
17708
17727
|
const layout = { sizeBytes: bytes.length, payloadStart, payloadEnd, partStarts: {} };
|
|
17709
|
-
mkdirSync15(
|
|
17728
|
+
mkdirSync15(join38(input.planDir, SLICE_DIR), { recursive: true });
|
|
17710
17729
|
input.chunks.forEach((_, index) => {
|
|
17711
17730
|
const cut = audioCutForChunk(grid, input.chunks, index, input.fps);
|
|
17712
17731
|
if (!cut) return;
|
|
@@ -17714,17 +17733,17 @@ async function writeChunkAudioSlices(input) {
|
|
|
17714
17733
|
const start = offsets[cut.firstPacket];
|
|
17715
17734
|
layout.partStarts[index] = start;
|
|
17716
17735
|
const end = offsets[last] + track.sizes[last];
|
|
17717
|
-
writeFileSync9(
|
|
17736
|
+
writeFileSync9(join38(input.planDir, chunkAudioSlicePath(index)), bytes.subarray(start, end));
|
|
17718
17737
|
});
|
|
17719
17738
|
const frame = [bytes.subarray(0, payloadStart), bytes.subarray(payloadEnd)];
|
|
17720
|
-
writeFileSync9(
|
|
17721
|
-
writeFileSync9(
|
|
17739
|
+
writeFileSync9(join38(input.planDir, SLICE_FRAME), Buffer.concat(frame));
|
|
17740
|
+
writeFileSync9(join38(input.planDir, SLICE_LAYOUT), JSON.stringify(layout));
|
|
17722
17741
|
}
|
|
17723
17742
|
function chunkAudioSource(planDir, chunkIndex, scratchPath) {
|
|
17724
|
-
const layoutPath =
|
|
17725
|
-
if (!
|
|
17726
|
-
const layout = JSON.parse(
|
|
17727
|
-
const frame =
|
|
17743
|
+
const layoutPath = join38(planDir, SLICE_LAYOUT);
|
|
17744
|
+
if (!existsSync26(layoutPath)) return resolvePlanAudioPath(planDir);
|
|
17745
|
+
const layout = JSON.parse(readFileSync12(layoutPath, "utf-8"));
|
|
17746
|
+
const frame = readFileSync12(join38(planDir, SLICE_FRAME));
|
|
17728
17747
|
const fd = openSync6(scratchPath, "w");
|
|
17729
17748
|
try {
|
|
17730
17749
|
writeSync(fd, frame, 0, layout.payloadStart, 0);
|
|
@@ -17737,7 +17756,7 @@ function chunkAudioSource(planDir, chunkIndex, scratchPath) {
|
|
|
17737
17756
|
);
|
|
17738
17757
|
const start = layout.partStarts[chunkIndex];
|
|
17739
17758
|
if (start !== void 0) {
|
|
17740
|
-
const part =
|
|
17759
|
+
const part = readFileSync12(join38(planDir, chunkAudioSlicePath(chunkIndex)));
|
|
17741
17760
|
writeSync(fd, part, 0, part.length, start);
|
|
17742
17761
|
}
|
|
17743
17762
|
ftruncateSync(fd, layout.sizeBytes);
|
|
@@ -17793,7 +17812,7 @@ async function muxChunkWithAudio(input) {
|
|
|
17793
17812
|
// src/services/distributed/planSize.ts
|
|
17794
17813
|
import { createHash as createHash9 } from "node:crypto";
|
|
17795
17814
|
import { lstatSync as lstatSync2, readdirSync as readdirSync9 } from "node:fs";
|
|
17796
|
-
import { extname as extname5, join as
|
|
17815
|
+
import { extname as extname5, join as join39, relative as relative4 } from "node:path";
|
|
17797
17816
|
var MAX_TOP_COMPONENTS = 10;
|
|
17798
17817
|
var SOURCE_MEDIA_EXTENSIONS = /* @__PURE__ */ new Set([
|
|
17799
17818
|
".aac",
|
|
@@ -17905,7 +17924,7 @@ function walkRegularFiles(dir, visit) {
|
|
|
17905
17924
|
return;
|
|
17906
17925
|
}
|
|
17907
17926
|
for (const entry of entries) {
|
|
17908
|
-
const full =
|
|
17927
|
+
const full = join39(dir, entry.name);
|
|
17909
17928
|
if (entry.isDirectory()) {
|
|
17910
17929
|
walkRegularFiles(full, visit);
|
|
17911
17930
|
} else if (entry.isFile()) {
|
|
@@ -18121,13 +18140,13 @@ function assertPositiveInteger2(name, value) {
|
|
|
18121
18140
|
}
|
|
18122
18141
|
var FREEZE_OWNED_PLAN_FILES = [
|
|
18123
18142
|
"plan.json",
|
|
18124
|
-
|
|
18125
|
-
|
|
18126
|
-
|
|
18143
|
+
join40("meta", "composition.json"),
|
|
18144
|
+
join40("meta", "encoder.json"),
|
|
18145
|
+
join40("meta", "chunks.json")
|
|
18127
18146
|
];
|
|
18128
18147
|
function removeFreezeOwnedPlanFiles(planDir) {
|
|
18129
18148
|
for (const relativePath of FREEZE_OWNED_PLAN_FILES) {
|
|
18130
|
-
rmSync14(
|
|
18149
|
+
rmSync14(join40(planDir, relativePath), { force: true });
|
|
18131
18150
|
}
|
|
18132
18151
|
}
|
|
18133
18152
|
function buildChunkSlices(totalFrames, chunkCount, effectiveChunkSize) {
|
|
@@ -18282,19 +18301,19 @@ function createVideoSourceShipper(input) {
|
|
|
18282
18301
|
const known = shipped.get(srcPath);
|
|
18283
18302
|
if (known) return known;
|
|
18284
18303
|
const stagedRel = pathInside(input.workVideoFramesDir, srcPath);
|
|
18285
|
-
const current = stagedRel === null ? srcPath :
|
|
18304
|
+
const current = stagedRel === null ? srcPath : join40(input.planDir, "video-frames", stagedRel);
|
|
18286
18305
|
let result = null;
|
|
18287
18306
|
for (const root of stagedRel === null ? [input.workCompiledDir, input.projectDir] : []) {
|
|
18288
18307
|
const rel = pathInside(root, srcPath);
|
|
18289
|
-
if (rel !== null && (
|
|
18308
|
+
if (rel !== null && (existsSync27(join40(input.planDir, "compiled", rel)) || input.isRemote(srcPath))) {
|
|
18290
18309
|
result = ["compiled", ...rel.split(sep3)].join("/");
|
|
18291
18310
|
break;
|
|
18292
18311
|
}
|
|
18293
18312
|
}
|
|
18294
18313
|
if (result === null) {
|
|
18295
18314
|
result = `video-sources/${shipped.size}${extname6(current)}`;
|
|
18296
|
-
const destination =
|
|
18297
|
-
mkdirSync16(
|
|
18315
|
+
const destination = join40(input.planDir, ...result.split("/"));
|
|
18316
|
+
mkdirSync16(join40(input.planDir, "video-sources"), { recursive: true });
|
|
18298
18317
|
try {
|
|
18299
18318
|
linkSync(current, destination);
|
|
18300
18319
|
} catch {
|
|
@@ -18314,7 +18333,7 @@ async function compilePlanComposition(projectDir, config, planDir, options) {
|
|
|
18314
18333
|
useGpu: false,
|
|
18315
18334
|
browserGpuMode: "software"
|
|
18316
18335
|
});
|
|
18317
|
-
if (!
|
|
18336
|
+
if (!existsSync27(planDir)) mkdirSync16(planDir, { recursive: true });
|
|
18318
18337
|
const log = config.logger ?? defaultLogger;
|
|
18319
18338
|
const sizeLimitBytes = options.executionPlanSizeLimitBytes ?? config.planDirSizeLimitBytes ?? PLAN_DIR_SIZE_LIMIT_BYTES;
|
|
18320
18339
|
const abortSignal = config.abortSignal;
|
|
@@ -18344,14 +18363,14 @@ async function compilePlanComposition(projectDir, config, planDir, options) {
|
|
|
18344
18363
|
pageMotionBlur: config.pageMotionBlur
|
|
18345
18364
|
});
|
|
18346
18365
|
const entryFile = config.entryFile ?? "index.html";
|
|
18347
|
-
const htmlPath =
|
|
18348
|
-
if (!
|
|
18366
|
+
const htmlPath = join40(projectDir, entryFile);
|
|
18367
|
+
if (!existsSync27(htmlPath)) {
|
|
18349
18368
|
throw new Error(`[plan] entry file not found: ${htmlPath}`);
|
|
18350
18369
|
}
|
|
18351
|
-
const workDir =
|
|
18370
|
+
const workDir = join40(planDir, ".plan-work");
|
|
18352
18371
|
rmSync14(workDir, { recursive: true, force: true });
|
|
18353
18372
|
mkdirSync16(workDir, { recursive: true });
|
|
18354
|
-
const compiledDir =
|
|
18373
|
+
const compiledDir = join40(workDir, "compiled");
|
|
18355
18374
|
mkdirSync16(compiledDir, { recursive: true });
|
|
18356
18375
|
let stageStarted = Date.now();
|
|
18357
18376
|
cpSync2(projectDir, compiledDir, {
|
|
@@ -18365,10 +18384,10 @@ async function compilePlanComposition(projectDir, config, planDir, options) {
|
|
|
18365
18384
|
}
|
|
18366
18385
|
});
|
|
18367
18386
|
logPlanStage(log, "copy", stageStarted);
|
|
18368
|
-
const finalCompiledDir =
|
|
18387
|
+
const finalCompiledDir = join40(planDir, "compiled");
|
|
18369
18388
|
const needsAlpha = outputNeedsAlpha(config.format);
|
|
18370
18389
|
const remoteFiles = Object.entries(options.remoteFiles ?? {});
|
|
18371
|
-
const remoteLocalPath = (rel) =>
|
|
18390
|
+
const remoteLocalPath = (rel) => join40(projectDir, ...rel.split("/"));
|
|
18372
18391
|
for (const [, file] of remoteFiles) {
|
|
18373
18392
|
declareContentAddressedUrl(file.url, file.sha256);
|
|
18374
18393
|
if (file.probeFactsUrl) declareProbeFactsUrl(file.url, file.probeFactsUrl);
|
|
@@ -18571,17 +18590,17 @@ async function buildLocalExecutionPlan(projectDir, config, executionPlanDir, opt
|
|
|
18571
18590
|
let stageStarted = Date.now();
|
|
18572
18591
|
const extractResult = await extractPlanVideos(c, options.deferVideoExtraction);
|
|
18573
18592
|
logPlanStage(log, "extract", stageStarted);
|
|
18574
|
-
const stagedVideoFrames =
|
|
18575
|
-
const videoFramesDst =
|
|
18576
|
-
if (
|
|
18577
|
-
const videoSourcesDir =
|
|
18593
|
+
const stagedVideoFrames = join40(compiledDir, "__hyperframes_video_frames");
|
|
18594
|
+
const videoFramesDst = join40(planDir, "video-frames");
|
|
18595
|
+
if (existsSync27(videoFramesDst)) rmSync14(videoFramesDst, { recursive: true, force: true });
|
|
18596
|
+
const videoSourcesDir = join40(planDir, "video-sources");
|
|
18578
18597
|
rmSync14(videoSourcesDir, { recursive: true, force: true });
|
|
18579
|
-
if (
|
|
18598
|
+
if (existsSync27(stagedVideoFrames)) {
|
|
18580
18599
|
renameWithRetry8(stagedVideoFrames, videoFramesDst);
|
|
18581
18600
|
} else {
|
|
18582
18601
|
mkdirSync16(videoFramesDst, { recursive: true });
|
|
18583
18602
|
}
|
|
18584
|
-
if (
|
|
18603
|
+
if (existsSync27(finalCompiledDir)) rmSync14(finalCompiledDir, { recursive: true, force: true });
|
|
18585
18604
|
renameWithRetry8(compiledDir, finalCompiledDir);
|
|
18586
18605
|
const shipVideoSource = createVideoSourceShipper({
|
|
18587
18606
|
planDir,
|
|
@@ -18611,7 +18630,7 @@ async function buildLocalExecutionPlan(projectDir, config, executionPlanDir, opt
|
|
|
18611
18630
|
};
|
|
18612
18631
|
})
|
|
18613
18632
|
});
|
|
18614
|
-
mkdirSync16(
|
|
18633
|
+
mkdirSync16(join40(planDir, "meta"), { recursive: true });
|
|
18615
18634
|
writePlanRemoteFiles(
|
|
18616
18635
|
planDir,
|
|
18617
18636
|
remoteFiles.map(([rel, { sha256, sizeBytes }]) => ({
|
|
@@ -18621,7 +18640,7 @@ async function buildLocalExecutionPlan(projectDir, config, executionPlanDir, opt
|
|
|
18621
18640
|
}))
|
|
18622
18641
|
);
|
|
18623
18642
|
writeFileSync10(
|
|
18624
|
-
|
|
18643
|
+
join40(planDir, PLAN_VIDEOS_META_RELATIVE_PATH),
|
|
18625
18644
|
JSON.stringify(planVideosJson, null, 2),
|
|
18626
18645
|
"utf-8"
|
|
18627
18646
|
);
|
|
@@ -18701,11 +18720,11 @@ async function buildLocalExecutionPlan(projectDir, config, executionPlanDir, opt
|
|
|
18701
18720
|
if (audioResult?.audioError) {
|
|
18702
18721
|
applyDistributedAudioWarningPolicy(job, audioResult.audioError, audioResult.audioFailures, log);
|
|
18703
18722
|
}
|
|
18704
|
-
const planAudioPath =
|
|
18705
|
-
if (audioResult?.hasAudio &&
|
|
18723
|
+
const planAudioPath = join40(planDir, PLAN_AUDIO_RELATIVE_PATH);
|
|
18724
|
+
if (audioResult?.hasAudio && existsSync27(audioResult.audioOutputPath)) {
|
|
18706
18725
|
renameWithRetry8(audioResult.audioOutputPath, planAudioPath);
|
|
18707
18726
|
}
|
|
18708
|
-
if (chunksCarryAudio &&
|
|
18727
|
+
if (chunksCarryAudio && existsSync27(planAudioPath)) {
|
|
18709
18728
|
if (options.sliceChunkAudio) {
|
|
18710
18729
|
stageStarted = Date.now();
|
|
18711
18730
|
await writeChunkAudioSlices({
|
|
@@ -18823,9 +18842,9 @@ async function plan(projectDir, config, planDir, options = {}) {
|
|
|
18823
18842
|
|
|
18824
18843
|
// src/services/distributed/renderChunk.ts
|
|
18825
18844
|
import { randomBytes } from "node:crypto";
|
|
18826
|
-
import { existsSync as
|
|
18845
|
+
import { existsSync as existsSync30, mkdirSync as mkdirSync19, readFileSync as readFileSync14, readdirSync as readdirSync11, rmSync as rmSync17, writeFileSync as writeFileSync13 } from "node:fs";
|
|
18827
18846
|
import { cpus as cpus3 } from "node:os";
|
|
18828
|
-
import { join as
|
|
18847
|
+
import { join as join44 } from "node:path";
|
|
18829
18848
|
import {
|
|
18830
18849
|
assertSwiftShader,
|
|
18831
18850
|
BROWSER_GPU_NOT_SOFTWARE as BROWSER_GPU_NOT_SOFTWARE4,
|
|
@@ -18850,24 +18869,24 @@ import {
|
|
|
18850
18869
|
} from "@hyperframes/engine";
|
|
18851
18870
|
import {
|
|
18852
18871
|
copyFileSync as copyFileSync8,
|
|
18853
|
-
existsSync as
|
|
18872
|
+
existsSync as existsSync29,
|
|
18854
18873
|
lstatSync as lstatSync3,
|
|
18855
18874
|
mkdirSync as mkdirSync18,
|
|
18856
|
-
readFileSync as
|
|
18875
|
+
readFileSync as readFileSync13,
|
|
18857
18876
|
readdirSync as readdirSync10,
|
|
18858
18877
|
rmSync as rmSync16,
|
|
18859
18878
|
statSync as statSync11,
|
|
18860
18879
|
writeFileSync as writeFileSync12
|
|
18861
18880
|
} from "node:fs";
|
|
18862
18881
|
import { tmpdir as tmpdir3 } from "node:os";
|
|
18863
|
-
import { dirname as dirname17, isAbsolute as isAbsolute4, join as
|
|
18882
|
+
import { dirname as dirname17, isAbsolute as isAbsolute4, join as join43, relative as relative6, resolve as resolve10, sep as sep4 } from "node:path";
|
|
18864
18883
|
import { DISTRIBUTED_FPS, isDistributedFps } from "@hyperframes/core";
|
|
18865
18884
|
import { createFrameLookupTable as createFrameLookupTable5, renameWithRetry as renameWithRetry10 } from "@hyperframes/engine";
|
|
18866
18885
|
|
|
18867
18886
|
// src/services/distributed/planV2Publisher.ts
|
|
18868
18887
|
import {
|
|
18869
18888
|
copyFileSync as copyFileSync7,
|
|
18870
|
-
existsSync as
|
|
18889
|
+
existsSync as existsSync28,
|
|
18871
18890
|
linkSync as linkSync2,
|
|
18872
18891
|
mkdirSync as mkdirSync17,
|
|
18873
18892
|
rmSync as rmSync15,
|
|
@@ -18875,7 +18894,7 @@ import {
|
|
|
18875
18894
|
writeFileSync as writeFileSync11
|
|
18876
18895
|
} from "node:fs";
|
|
18877
18896
|
import { renameWithRetry as renameWithRetry9 } from "@hyperframes/engine";
|
|
18878
|
-
import { dirname as dirname16, join as
|
|
18897
|
+
import { dirname as dirname16, join as join42 } from "node:path";
|
|
18879
18898
|
|
|
18880
18899
|
// src/services/distributed/planV2Errors.ts
|
|
18881
18900
|
var PLAN_V2_INTEGRITY_UNRECOVERABLE = "PLAN_V2_INTEGRITY_UNRECOVERABLE";
|
|
@@ -18890,7 +18909,7 @@ var PlanV2IntegrityError = class extends Error {
|
|
|
18890
18909
|
};
|
|
18891
18910
|
|
|
18892
18911
|
// src/services/distributed/planV2Layout.ts
|
|
18893
|
-
import { join as
|
|
18912
|
+
import { join as join41 } from "node:path";
|
|
18894
18913
|
var SHA256_PATTERN = /^[0-9a-f]{64}$/;
|
|
18895
18914
|
function assertPlanV2Sha256(value, field) {
|
|
18896
18915
|
if (typeof value !== "string" || !SHA256_PATTERN.test(value)) {
|
|
@@ -18900,7 +18919,7 @@ function assertPlanV2Sha256(value, field) {
|
|
|
18900
18919
|
}
|
|
18901
18920
|
function planV2BlobPath(root, sha256) {
|
|
18902
18921
|
const digest = assertPlanV2Sha256(sha256, "artifact sha256");
|
|
18903
|
-
return
|
|
18922
|
+
return join41(root, "artifacts", "sha256", digest.slice(0, 2), digest);
|
|
18904
18923
|
}
|
|
18905
18924
|
|
|
18906
18925
|
// src/services/distributed/planV2Publisher.ts
|
|
@@ -18936,7 +18955,7 @@ var LocalPlanV2ArtifactPublisher = class {
|
|
|
18936
18955
|
#linkFile;
|
|
18937
18956
|
#committed = false;
|
|
18938
18957
|
constructor(destinationDir, options = {}) {
|
|
18939
|
-
if (
|
|
18958
|
+
if (existsSync28(destinationDir)) {
|
|
18940
18959
|
throw new PlanV2IntegrityError(`output directory already exists: ${destinationDir}`);
|
|
18941
18960
|
}
|
|
18942
18961
|
this.destinationDir = destinationDir;
|
|
@@ -18953,10 +18972,10 @@ var LocalPlanV2ArtifactPublisher = class {
|
|
|
18953
18972
|
);
|
|
18954
18973
|
}
|
|
18955
18974
|
const destinationPath = planV2BlobPath(this.temporaryDir, digest);
|
|
18956
|
-
if (
|
|
18975
|
+
if (existsSync28(destinationPath)) return;
|
|
18957
18976
|
mkdirSync17(dirname16(destinationPath), { recursive: true });
|
|
18958
18977
|
const stagingDir = createStagingDir5(dirname16(destinationPath), ".plan-v2-blob-");
|
|
18959
|
-
const temporaryPath =
|
|
18978
|
+
const temporaryPath = join42(stagingDir, "blob");
|
|
18960
18979
|
try {
|
|
18961
18980
|
try {
|
|
18962
18981
|
this.#linkFile(blob.sourcePath, temporaryPath);
|
|
@@ -18971,13 +18990,13 @@ var LocalPlanV2ArtifactPublisher = class {
|
|
|
18971
18990
|
}
|
|
18972
18991
|
async commitManifest(manifestBytes) {
|
|
18973
18992
|
for (const digest of new Set(manifestDigests(manifestBytes))) {
|
|
18974
|
-
if (!
|
|
18993
|
+
if (!existsSync28(planV2BlobPath(this.temporaryDir, digest))) {
|
|
18975
18994
|
throw new PlanV2IntegrityError(
|
|
18976
18995
|
`cannot commit manifest before referenced blob is durable: ${digest}`
|
|
18977
18996
|
);
|
|
18978
18997
|
}
|
|
18979
18998
|
}
|
|
18980
|
-
writeFileSync11(
|
|
18999
|
+
writeFileSync11(join42(this.temporaryDir, "plan.json"), manifestBytes, "utf-8");
|
|
18981
19000
|
renameWithRetry9(this.temporaryDir, this.destinationDir);
|
|
18982
19001
|
this.#committed = true;
|
|
18983
19002
|
}
|
|
@@ -19003,7 +19022,7 @@ function isNonNegativeIntegerArray(value) {
|
|
|
19003
19022
|
return Array.isArray(value) && value.every((item) => typeof item === "number" && Number.isInteger(item) && item >= 0);
|
|
19004
19023
|
}
|
|
19005
19024
|
function readJsonFile(path, label) {
|
|
19006
|
-
const contents =
|
|
19025
|
+
const contents = readFileSync13(path, "utf-8");
|
|
19007
19026
|
try {
|
|
19008
19027
|
const parsed = JSON.parse(contents);
|
|
19009
19028
|
return parsed;
|
|
@@ -19023,7 +19042,7 @@ function listFiles(root) {
|
|
|
19023
19042
|
const rootResolved = resolve10(root);
|
|
19024
19043
|
function walk(dir) {
|
|
19025
19044
|
for (const entry of readdirSync10(dir, { withFileTypes: true })) {
|
|
19026
|
-
const absolutePath =
|
|
19045
|
+
const absolutePath = join43(dir, entry.name);
|
|
19027
19046
|
if (entry.isDirectory()) {
|
|
19028
19047
|
walk(absolutePath);
|
|
19029
19048
|
} else if (entry.isFile()) {
|
|
@@ -19050,13 +19069,13 @@ function assertValidExtractionCacheCompleteSentinel(path) {
|
|
|
19050
19069
|
}
|
|
19051
19070
|
}
|
|
19052
19071
|
function validateExtractionCacheCompleteSentinels(executionPlanDir) {
|
|
19053
|
-
const videoRoot =
|
|
19054
|
-
if (!
|
|
19072
|
+
const videoRoot = join43(executionPlanDir, "video-frames");
|
|
19073
|
+
if (!existsSync29(videoRoot)) return;
|
|
19055
19074
|
for (const videoEntry of readdirSync10(videoRoot, { withFileTypes: true })) {
|
|
19056
19075
|
if (!videoEntry.isDirectory()) continue;
|
|
19057
|
-
const videoDir =
|
|
19076
|
+
const videoDir = join43(videoRoot, videoEntry.name);
|
|
19058
19077
|
if (readdirSync10(videoDir).includes(EXTRACTION_CACHE_COMPLETE_SENTINEL)) {
|
|
19059
|
-
const sentinelPath =
|
|
19078
|
+
const sentinelPath = join43(videoDir, EXTRACTION_CACHE_COMPLETE_SENTINEL);
|
|
19060
19079
|
assertValidExtractionCacheCompleteSentinel(sentinelPath);
|
|
19061
19080
|
}
|
|
19062
19081
|
}
|
|
@@ -19103,7 +19122,7 @@ function listVideoFramePaths(executionPlanDir, videos) {
|
|
|
19103
19122
|
if (video.deferredRange) {
|
|
19104
19123
|
const framePaths2 = /* @__PURE__ */ new Map();
|
|
19105
19124
|
for (let index = 0; index < video.totalFrames; index++) {
|
|
19106
|
-
framePaths2.set(index,
|
|
19125
|
+
framePaths2.set(index, join43(outputDir, String(index)));
|
|
19107
19126
|
}
|
|
19108
19127
|
return { ...video, outputDir, framePaths: framePaths2, ownedByLookup: false };
|
|
19109
19128
|
}
|
|
@@ -19111,7 +19130,7 @@ function listVideoFramePaths(executionPlanDir, videos) {
|
|
|
19111
19130
|
const framePaths = /* @__PURE__ */ new Map();
|
|
19112
19131
|
for (const frameName of frameNames) {
|
|
19113
19132
|
if (frameName === EXTRACTION_CACHE_COMPLETE_SENTINEL) {
|
|
19114
|
-
assertValidExtractionCacheCompleteSentinel(
|
|
19133
|
+
assertValidExtractionCacheCompleteSentinel(join43(outputDir, frameName));
|
|
19115
19134
|
continue;
|
|
19116
19135
|
}
|
|
19117
19136
|
const match = /(\d+)(?=\.[^.]+$)/.exec(frameName);
|
|
@@ -19130,7 +19149,7 @@ function listVideoFramePaths(executionPlanDir, videos) {
|
|
|
19130
19149
|
`duplicate extracted frame index ${frameIndex} in ${outputDir}`
|
|
19131
19150
|
);
|
|
19132
19151
|
}
|
|
19133
|
-
framePaths.set(frameIndex,
|
|
19152
|
+
framePaths.set(frameIndex, join43(outputDir, frameName));
|
|
19134
19153
|
}
|
|
19135
19154
|
return {
|
|
19136
19155
|
...video,
|
|
@@ -19151,8 +19170,8 @@ function parsePlanVideosJson2(value) {
|
|
|
19151
19170
|
}
|
|
19152
19171
|
}
|
|
19153
19172
|
function materializeExtractedVideoDirectories(planDir) {
|
|
19154
|
-
const videosPath =
|
|
19155
|
-
if (!
|
|
19173
|
+
const videosPath = join43(planDir, PLAN_VIDEOS_META_RELATIVE_PATH);
|
|
19174
|
+
if (!existsSync29(videosPath)) return;
|
|
19156
19175
|
const videos = parsePlanVideosJson2(readJsonFile(videosPath, PLAN_VIDEOS_META_RELATIVE_PATH));
|
|
19157
19176
|
for (const video of videos.extracted) {
|
|
19158
19177
|
mkdirSync18(resolveExtractedVideoOutputDir(planDir, video.videoId), { recursive: true });
|
|
@@ -19185,13 +19204,13 @@ function parseChunkSlices(value) {
|
|
|
19185
19204
|
});
|
|
19186
19205
|
}
|
|
19187
19206
|
function buildVideoChunkDependencies(executionPlanDir, dimensions) {
|
|
19188
|
-
const videoRoot =
|
|
19189
|
-
const hasExtractedFrames =
|
|
19190
|
-
const videosPath =
|
|
19191
|
-
if (!
|
|
19207
|
+
const videoRoot = join43(executionPlanDir, "video-frames");
|
|
19208
|
+
const hasExtractedFrames = existsSync29(videoRoot) && listFiles(videoRoot).length > 0;
|
|
19209
|
+
const videosPath = join43(executionPlanDir, PLAN_VIDEOS_META_RELATIVE_PATH);
|
|
19210
|
+
if (!existsSync29(videosPath)) {
|
|
19192
19211
|
return hasExtractedFrames ? { mode: "full-source-pack", dependencies: null } : { mode: "exact-rendered-frames", dependencies: /* @__PURE__ */ new Map() };
|
|
19193
19212
|
}
|
|
19194
|
-
const chunksPath =
|
|
19213
|
+
const chunksPath = join43(executionPlanDir, "meta", "chunks.json");
|
|
19195
19214
|
const videos = readJsonFile(videosPath, PLAN_VIDEOS_META_RELATIVE_PATH);
|
|
19196
19215
|
const chunks = readJsonFile(chunksPath, "meta/chunks.json");
|
|
19197
19216
|
const parsedVideos = parsePlanVideosJson2(videos);
|
|
@@ -19245,10 +19264,10 @@ function computeManifestHash(manifest) {
|
|
|
19245
19264
|
return sha256Hex(`${PLAN_V2_HASH_PREFIX}${canonicalJsonStringify(manifestPayload(manifest))}`);
|
|
19246
19265
|
}
|
|
19247
19266
|
function writeBlob(sourcePath, destinationPath) {
|
|
19248
|
-
if (
|
|
19267
|
+
if (existsSync29(destinationPath)) return;
|
|
19249
19268
|
mkdirSync18(dirname17(destinationPath), { recursive: true });
|
|
19250
19269
|
const temporaryDir = createStagingDir6(dirname17(destinationPath), ".plan-v2-blob-");
|
|
19251
|
-
const temporaryPath =
|
|
19270
|
+
const temporaryPath = join43(temporaryDir, "blob");
|
|
19252
19271
|
try {
|
|
19253
19272
|
copyFileSync8(sourcePath, temporaryPath);
|
|
19254
19273
|
renameWithRetry10(temporaryPath, destinationPath);
|
|
@@ -19284,8 +19303,8 @@ async function putTasks(tasks) {
|
|
|
19284
19303
|
if (failure) throw failure.reason;
|
|
19285
19304
|
}
|
|
19286
19305
|
function buildPlanV2Publication(executionPlanDir, digests) {
|
|
19287
|
-
const executionPlanPath =
|
|
19288
|
-
if (!
|
|
19306
|
+
const executionPlanPath = join43(executionPlanDir, "plan.json");
|
|
19307
|
+
if (!existsSync29(executionPlanPath)) {
|
|
19289
19308
|
throw new PlanV2IntegrityError(`execution plan is missing plan.json: ${executionPlanPath}`);
|
|
19290
19309
|
}
|
|
19291
19310
|
const executionPlanValue = readJsonFile(executionPlanPath, "execution plan.json");
|
|
@@ -19312,7 +19331,7 @@ function buildPlanV2Publication(executionPlanDir, digests) {
|
|
|
19312
19331
|
}
|
|
19313
19332
|
validateExtractionCacheCompleteSentinels(executionPlanDir);
|
|
19314
19333
|
const videoDependencyPlan = buildVideoChunkDependencies(executionPlanDir, dimensions);
|
|
19315
|
-
const encoder = readJsonFile(
|
|
19334
|
+
const encoder = readJsonFile(join43(executionPlanDir, "meta", "encoder.json"), "meta/encoder.json");
|
|
19316
19335
|
const files = listFiles(executionPlanDir);
|
|
19317
19336
|
const chunkAudio = !isRecord3(encoder) || encoder.chunksCarryAudio !== true ? "none" : files.some((file) => chunkAudioSliceTarget(file.path) !== null) ? "sliced" : "whole";
|
|
19318
19337
|
for (const file of files) {
|
|
@@ -19365,7 +19384,7 @@ function buildPlanV2Publication(executionPlanDir, digests) {
|
|
|
19365
19384
|
};
|
|
19366
19385
|
}
|
|
19367
19386
|
function createPlanV2FromExecutionPlan(executionPlanDir, planV2Dir) {
|
|
19368
|
-
if (
|
|
19387
|
+
if (existsSync29(planV2Dir)) {
|
|
19369
19388
|
throw new PlanV2IntegrityError(`output directory already exists: ${planV2Dir}`);
|
|
19370
19389
|
}
|
|
19371
19390
|
const publication = buildPlanV2Publication(executionPlanDir);
|
|
@@ -19379,7 +19398,7 @@ function createPlanV2FromExecutionPlan(executionPlanDir, planV2Dir) {
|
|
|
19379
19398
|
writeBlob(blob.sourcePath, planV2BlobPath(tempDir, blob.sha256));
|
|
19380
19399
|
}
|
|
19381
19400
|
writeFileSync12(
|
|
19382
|
-
|
|
19401
|
+
join43(tempDir, "plan.json"),
|
|
19383
19402
|
canonicalJsonStringify(publication.manifest),
|
|
19384
19403
|
"utf-8"
|
|
19385
19404
|
);
|
|
@@ -19431,7 +19450,7 @@ async function planV2WithPublisher(projectDir, config, publisher, options = {})
|
|
|
19431
19450
|
// artifactTargets ships every compiled/ file to all chunks, so each is in the manifest.
|
|
19432
19451
|
whileAudioMixes: () => putBlobs(
|
|
19433
19452
|
publisher,
|
|
19434
|
-
listFiles(
|
|
19453
|
+
listFiles(join43(stagingRoot, "compiled")).map(
|
|
19435
19454
|
(file) => publishBlobFor(file.absolutePath, digests)
|
|
19436
19455
|
)
|
|
19437
19456
|
),
|
|
@@ -19451,7 +19470,7 @@ async function planV2WithPublisher(projectDir, config, publisher, options = {})
|
|
|
19451
19470
|
}
|
|
19452
19471
|
}
|
|
19453
19472
|
async function planV2(projectDir, config, planV2Dir) {
|
|
19454
|
-
if (
|
|
19473
|
+
if (existsSync29(planV2Dir)) {
|
|
19455
19474
|
throw new PlanV2IntegrityError(`output directory already exists: ${planV2Dir}`);
|
|
19456
19475
|
}
|
|
19457
19476
|
const publisher = new LocalPlanV2ArtifactPublisher(planV2Dir);
|
|
@@ -19468,7 +19487,7 @@ function resultFromManifest(planV2Dir, manifest) {
|
|
|
19468
19487
|
isRecord3(executionPlan) ? executionPlan[REFERENCE_BACKGROUND_FIELD3] : void 0
|
|
19469
19488
|
),
|
|
19470
19489
|
planDir: planV2Dir,
|
|
19471
|
-
manifestPath:
|
|
19490
|
+
manifestPath: join43(planV2Dir, "plan.json"),
|
|
19472
19491
|
planProtocol: PLAN_PROTOCOL_V2,
|
|
19473
19492
|
planHash: manifest.planHash,
|
|
19474
19493
|
sourcePlanV1Hash: getPlanV2ExecutionPlanHash(manifest),
|
|
@@ -19604,8 +19623,8 @@ function parsePlanV2Manifest(value) {
|
|
|
19604
19623
|
return parsed;
|
|
19605
19624
|
}
|
|
19606
19625
|
function readPlanV2Manifest(planV2Dir) {
|
|
19607
|
-
const manifestPath =
|
|
19608
|
-
if (!
|
|
19626
|
+
const manifestPath = join43(planV2Dir, "plan.json");
|
|
19627
|
+
if (!existsSync29(manifestPath)) {
|
|
19609
19628
|
throw new PlanV2IntegrityError(`missing v2 manifest: ${manifestPath}`);
|
|
19610
19629
|
}
|
|
19611
19630
|
const value = readJsonFile(manifestPath, "v2 manifest");
|
|
@@ -19624,7 +19643,7 @@ function listPlanV2ArtifactsForTarget(manifest, target) {
|
|
|
19624
19643
|
}
|
|
19625
19644
|
function verifyBlob(planV2Dir, artifact) {
|
|
19626
19645
|
const sourcePath = planV2BlobPath(planV2Dir, artifact.sha256);
|
|
19627
|
-
if (!
|
|
19646
|
+
if (!existsSync29(sourcePath)) {
|
|
19628
19647
|
throw new PlanV2IntegrityError(`missing content-addressed artifact ${artifact.sha256}`);
|
|
19629
19648
|
}
|
|
19630
19649
|
const stats = statSync11(sourcePath);
|
|
@@ -19637,7 +19656,7 @@ function verifyBlob(planV2Dir, artifact) {
|
|
|
19637
19656
|
return sourcePath;
|
|
19638
19657
|
}
|
|
19639
19658
|
function materializePlanV2Target(planV2Dir, target, destinationDir, options = {}) {
|
|
19640
|
-
if (
|
|
19659
|
+
if (existsSync29(destinationDir)) {
|
|
19641
19660
|
throw new PlanV2IntegrityError(`materialization destination already exists: ${destinationDir}`);
|
|
19642
19661
|
}
|
|
19643
19662
|
const manifest = readPlanV2Manifest(planV2Dir);
|
|
@@ -19653,13 +19672,13 @@ function materializePlanV2Target(planV2Dir, target, destinationDir, options = {}
|
|
|
19653
19672
|
const tempDir = createStagingDir6(dirname17(destinationDir), ".plan-v2-materialize-");
|
|
19654
19673
|
try {
|
|
19655
19674
|
for (const { artifact, sourcePath } of verified) {
|
|
19656
|
-
const destinationPath =
|
|
19675
|
+
const destinationPath = join43(tempDir, ...artifact.path.split("/"));
|
|
19657
19676
|
mkdirSync18(dirname17(destinationPath), { recursive: true });
|
|
19658
19677
|
copyFileSync8(sourcePath, destinationPath);
|
|
19659
19678
|
}
|
|
19660
19679
|
if (target.role === "chunk") materializeExtractedVideoDirectories(tempDir);
|
|
19661
19680
|
writeFileSync12(
|
|
19662
|
-
|
|
19681
|
+
join43(tempDir, PLAN_V2_MATERIALIZATION_MARKER),
|
|
19663
19682
|
canonicalJsonStringify({
|
|
19664
19683
|
manifest,
|
|
19665
19684
|
target,
|
|
@@ -19682,7 +19701,7 @@ function materializePlanV2Target(planV2Dir, target, destinationDir, options = {}
|
|
|
19682
19701
|
// Join the artifact's OWN name, not the current constant: a plan written
|
|
19683
19702
|
// before the container change carries the legacy name, and materializing it
|
|
19684
19703
|
// under the new one would point at a file that was never written.
|
|
19685
|
-
audioPath: target.role === "assembler" ? audioArtifact ?
|
|
19704
|
+
audioPath: target.role === "assembler" ? audioArtifact ? join43(destinationDir, audioArtifact.path) : null : null
|
|
19686
19705
|
};
|
|
19687
19706
|
}
|
|
19688
19707
|
function assertRemoteSources(remoteSources, artifacts) {
|
|
@@ -19701,8 +19720,8 @@ function validatePlanV2MaterializedTarget(planDir, expectedTarget) {
|
|
|
19701
19720
|
return readValidatedPlanV2Materialization(planDir, expectedTarget)?.manifest ?? null;
|
|
19702
19721
|
}
|
|
19703
19722
|
function readValidatedPlanV2Materialization(planDir, expectedTarget) {
|
|
19704
|
-
const markerPath =
|
|
19705
|
-
if (!
|
|
19723
|
+
const markerPath = join43(planDir, PLAN_V2_MATERIALIZATION_MARKER);
|
|
19724
|
+
if (!existsSync29(markerPath)) return null;
|
|
19706
19725
|
const marker = readJsonFile(markerPath, "materialization marker");
|
|
19707
19726
|
if (!isRecord3(marker) || !isRecord3(marker.manifest) || !isRecord3(marker.target)) {
|
|
19708
19727
|
throw new PlanV2IntegrityError("malformed materialization marker");
|
|
@@ -19719,8 +19738,8 @@ function readValidatedPlanV2Materialization(planDir, expectedTarget) {
|
|
|
19719
19738
|
assertRemoteSources(remoteSources, required);
|
|
19720
19739
|
for (const artifact of required) {
|
|
19721
19740
|
if (Object.hasOwn(remoteSources, artifact.path)) continue;
|
|
19722
|
-
const path =
|
|
19723
|
-
if (!
|
|
19741
|
+
const path = join43(planDir, ...artifact.path.split("/"));
|
|
19742
|
+
if (!existsSync29(path) || statSync11(path).size !== artifact.sizeBytes) {
|
|
19724
19743
|
throw new PlanV2IntegrityError(
|
|
19725
19744
|
`materialized artifact missing or truncated: ${artifact.path}`
|
|
19726
19745
|
);
|
|
@@ -19848,10 +19867,10 @@ async function beginFrameSessionNeedsScreenshotFallback(session, probe = probeBe
|
|
|
19848
19867
|
return !await probe(session.page, timeoutMs, probeTick, session.beginFrameIntervalMs);
|
|
19849
19868
|
}
|
|
19850
19869
|
function hashChunkOutput(outputPath, kind) {
|
|
19851
|
-
if (kind === "file") return sha256Hex(
|
|
19870
|
+
if (kind === "file") return sha256Hex(readFileSync14(outputPath));
|
|
19852
19871
|
const entries = readdirSync11(outputPath).filter((name) => /\.(png|jpg|jpeg)$/i.test(name)).sort();
|
|
19853
19872
|
const lines = entries.map(
|
|
19854
|
-
(name) => `${name}\0${sha256Hex(
|
|
19873
|
+
(name) => `${name}\0${sha256Hex(readFileSync14(join44(outputPath, name)))}`
|
|
19855
19874
|
);
|
|
19856
19875
|
return sha256Hex(lines.join("\0"));
|
|
19857
19876
|
}
|
|
@@ -19868,16 +19887,16 @@ function resolveLockedVp9CpuUsed(lockedEncoder) {
|
|
|
19868
19887
|
async function renderChunk(planDir, chunkIndex, outputChunkPath, options) {
|
|
19869
19888
|
const start = Date.now();
|
|
19870
19889
|
const log = defaultLogger;
|
|
19871
|
-
const planJsonPath =
|
|
19872
|
-
const encoderJsonPath =
|
|
19873
|
-
const chunksJsonPath =
|
|
19874
|
-
if (!
|
|
19890
|
+
const planJsonPath = join44(planDir, "plan.json");
|
|
19891
|
+
const encoderJsonPath = join44(planDir, "meta", "encoder.json");
|
|
19892
|
+
const chunksJsonPath = join44(planDir, "meta", "chunks.json");
|
|
19893
|
+
if (!existsSync30(planJsonPath)) {
|
|
19875
19894
|
throw new RenderChunkValidationError(
|
|
19876
19895
|
MISSING_PLAN_ARTIFACT,
|
|
19877
19896
|
`[renderChunk] planDir is missing required artifact: ${planJsonPath}`
|
|
19878
19897
|
);
|
|
19879
19898
|
}
|
|
19880
|
-
const plan2 = JSON.parse(
|
|
19899
|
+
const plan2 = JSON.parse(readFileSync14(planJsonPath, "utf-8"));
|
|
19881
19900
|
readPlanProtocolV1(plan2, DISTRIBUTED_RENDER_CAPABILITIES.roles.chunk);
|
|
19882
19901
|
const planHashStarted = Date.now();
|
|
19883
19902
|
const v2Materialization = readValidatedPlanV2Materialization(planDir, {
|
|
@@ -19887,20 +19906,20 @@ async function renderChunk(planDir, chunkIndex, outputChunkPath, options) {
|
|
|
19887
19906
|
const v2Manifest = v2Materialization?.manifest ?? null;
|
|
19888
19907
|
const remoteSources = v2Materialization?.remoteSources ?? {};
|
|
19889
19908
|
for (const required of [encoderJsonPath, chunksJsonPath]) {
|
|
19890
|
-
if (!
|
|
19909
|
+
if (!existsSync30(required)) {
|
|
19891
19910
|
throw new RenderChunkValidationError(
|
|
19892
19911
|
MISSING_PLAN_ARTIFACT,
|
|
19893
19912
|
`[renderChunk] planDir is missing required artifact: ${required}`
|
|
19894
19913
|
);
|
|
19895
19914
|
}
|
|
19896
19915
|
}
|
|
19897
|
-
const encoder = JSON.parse(
|
|
19898
|
-
const chunks = JSON.parse(
|
|
19899
|
-
const videosJsonPath =
|
|
19916
|
+
const encoder = JSON.parse(readFileSync14(encoderJsonPath, "utf-8"));
|
|
19917
|
+
const chunks = JSON.parse(readFileSync14(chunksJsonPath, "utf-8"));
|
|
19918
|
+
const videosJsonPath = join44(planDir, PLAN_VIDEOS_META_RELATIVE_PATH);
|
|
19900
19919
|
let planVideos = null;
|
|
19901
|
-
if (
|
|
19920
|
+
if (existsSync30(videosJsonPath)) {
|
|
19902
19921
|
try {
|
|
19903
|
-
planVideos = validatePlanVideosForChunk(JSON.parse(
|
|
19922
|
+
planVideos = validatePlanVideosForChunk(JSON.parse(readFileSync14(videosJsonPath, "utf-8")));
|
|
19904
19923
|
} catch (err) {
|
|
19905
19924
|
if (err instanceof RenderChunkValidationError) throw err;
|
|
19906
19925
|
throw new RenderChunkValidationError(
|
|
@@ -19928,8 +19947,8 @@ async function renderChunk(planDir, chunkIndex, outputChunkPath, options) {
|
|
|
19928
19947
|
}
|
|
19929
19948
|
const range = resolveChunkFrameRange(slice, chunkIndex, options?.frameRange);
|
|
19930
19949
|
const framesInChunk = range.endFrame - range.startFrame;
|
|
19931
|
-
const compiledDir =
|
|
19932
|
-
if (!
|
|
19950
|
+
const compiledDir = join44(planDir, "compiled");
|
|
19951
|
+
if (!existsSync30(compiledDir)) {
|
|
19933
19952
|
throw new RenderChunkValidationError(
|
|
19934
19953
|
MISSING_PLAN_ARTIFACT,
|
|
19935
19954
|
`[renderChunk] planDir missing compiled/ directory: ${compiledDir}`
|
|
@@ -19987,7 +20006,7 @@ async function renderChunk(planDir, chunkIndex, outputChunkPath, options) {
|
|
|
19987
20006
|
};
|
|
19988
20007
|
const workDir = `${outputChunkPath}.work.${process.pid}.${randomBytes(4).toString("hex")}`;
|
|
19989
20008
|
mkdirSync19(workDir, { recursive: true });
|
|
19990
|
-
const framesDir =
|
|
20009
|
+
const framesDir = join44(workDir, "captured-frames");
|
|
19991
20010
|
mkdirSync19(framesDir, { recursive: true });
|
|
19992
20011
|
const videoFramesDir = `${workDir}.video-frames`;
|
|
19993
20012
|
const chunkFrameNumbers = Array.from({ length: framesInChunk }, (_, i) => range.startFrame + i);
|
|
@@ -20012,7 +20031,7 @@ async function renderChunk(planDir, chunkIndex, outputChunkPath, options) {
|
|
|
20012
20031
|
dimensions: plan2.dimensions,
|
|
20013
20032
|
encoder,
|
|
20014
20033
|
videoCount: planVideos?.videos.length ?? 0,
|
|
20015
|
-
html:
|
|
20034
|
+
html: readFileSync14(join44(compiledDir, "index.html"), "utf-8"),
|
|
20016
20035
|
// The plan ships a deferred source only to chunks that show it; don't wait on the rest.
|
|
20017
20036
|
skipReadinessVideoIds: deferredVideos.filter(
|
|
20018
20037
|
(video) => !shownFrames.get(video.videoId)?.size || remoteVideoIds.has(video.videoId)
|
|
@@ -20180,10 +20199,10 @@ async function renderChunk(planDir, chunkIndex, outputChunkPath, options) {
|
|
|
20180
20199
|
const effectiveBitrate = encoder.crf != null ? void 0 : encoder.bitrate;
|
|
20181
20200
|
const videoOnlyPath = encoder.chunksCarryAudio ? `${outputChunkPath}.video.mp4` : outputChunkPath;
|
|
20182
20201
|
if (isPngSequence) {
|
|
20183
|
-
if (!
|
|
20202
|
+
if (!existsSync30(outputChunkPath)) mkdirSync19(outputChunkPath, { recursive: true });
|
|
20184
20203
|
} else {
|
|
20185
|
-
const outDir =
|
|
20186
|
-
if (!
|
|
20204
|
+
const outDir = join44(outputChunkPath, "..");
|
|
20205
|
+
if (!existsSync30(outDir)) mkdirSync19(outDir, { recursive: true });
|
|
20187
20206
|
}
|
|
20188
20207
|
const encodeInput = {
|
|
20189
20208
|
job,
|
|
@@ -20456,10 +20475,10 @@ async function renderSpan(projectDir, config, span, outputPath) {
|
|
|
20456
20475
|
if (config.cfr === true) {
|
|
20457
20476
|
throw new RenderSpanUnsupportedError("--start/--end cannot be combined with a cfr re-encode.");
|
|
20458
20477
|
}
|
|
20459
|
-
const workDir = mkdtempSync(
|
|
20478
|
+
const workDir = mkdtempSync(join45(tmpdir4(), "hf-render-span-"));
|
|
20460
20479
|
try {
|
|
20461
|
-
const planDir =
|
|
20462
|
-
const partsDir =
|
|
20480
|
+
const planDir = join45(workDir, "plan");
|
|
20481
|
+
const partsDir = join45(workDir, "parts");
|
|
20463
20482
|
mkdirSync20(partsDir, { recursive: true });
|
|
20464
20483
|
const planned = await plan(
|
|
20465
20484
|
projectDir,
|
|
@@ -20474,7 +20493,7 @@ async function renderSpan(projectDir, config, span, outputPath) {
|
|
|
20474
20493
|
planned.totalFrames
|
|
20475
20494
|
);
|
|
20476
20495
|
const slices = JSON.parse(
|
|
20477
|
-
|
|
20496
|
+
readFileSync15(join45(planDir, "meta", "chunks.json"), "utf-8")
|
|
20478
20497
|
);
|
|
20479
20498
|
const parts = [];
|
|
20480
20499
|
for (const slice of slices) {
|
|
@@ -20484,7 +20503,7 @@ async function renderSpan(projectDir, config, span, outputPath) {
|
|
|
20484
20503
|
};
|
|
20485
20504
|
if (range.endFrame <= range.startFrame) continue;
|
|
20486
20505
|
throwIfAborted(config.abortSignal);
|
|
20487
|
-
const part =
|
|
20506
|
+
const part = join45(partsDir, `part-${String(parts.length).padStart(4, "0")}.mp4`);
|
|
20488
20507
|
await renderChunk(planDir, slice.index, part, { frameRange: range });
|
|
20489
20508
|
parts.push(part);
|
|
20490
20509
|
}
|
|
@@ -21100,7 +21119,7 @@ import {
|
|
|
21100
21119
|
|
|
21101
21120
|
// src/server.ts
|
|
21102
21121
|
import {
|
|
21103
|
-
existsSync as
|
|
21122
|
+
existsSync as existsSync33,
|
|
21104
21123
|
mkdirSync as mkdirSync21,
|
|
21105
21124
|
statSync as statSync13,
|
|
21106
21125
|
mkdtempSync as mkdtempSync2,
|
|
@@ -21108,7 +21127,7 @@ import {
|
|
|
21108
21127
|
rmSync as rmSync19,
|
|
21109
21128
|
createReadStream as createReadStream5
|
|
21110
21129
|
} from "node:fs";
|
|
21111
|
-
import { resolve as resolve12, dirname as dirname19, join as
|
|
21130
|
+
import { resolve as resolve12, dirname as dirname19, join as join48 } from "node:path";
|
|
21112
21131
|
import { tmpdir as tmpdir5 } from "node:os";
|
|
21113
21132
|
import { parseArgs } from "node:util";
|
|
21114
21133
|
import crypto from "node:crypto";
|
|
@@ -21123,15 +21142,15 @@ import {
|
|
|
21123
21142
|
|
|
21124
21143
|
// src/services/hyperframeLint.ts
|
|
21125
21144
|
import {
|
|
21126
|
-
existsSync as
|
|
21127
|
-
readFileSync as
|
|
21145
|
+
existsSync as existsSync31,
|
|
21146
|
+
readFileSync as readFileSync16,
|
|
21128
21147
|
statSync as statSync12,
|
|
21129
21148
|
openSync as openSync7,
|
|
21130
21149
|
fstatSync as fstatSync3,
|
|
21131
21150
|
closeSync as closeSync7,
|
|
21132
21151
|
constants as constants3
|
|
21133
21152
|
} from "node:fs";
|
|
21134
|
-
import { resolve as resolve11, join as
|
|
21153
|
+
import { resolve as resolve11, join as join46, relative as relative7, isAbsolute as isAbsolute5, sep as sep5 } from "node:path";
|
|
21135
21154
|
import { lintHyperframeHtml } from "@hyperframes/lint";
|
|
21136
21155
|
function isStringRecord(value) {
|
|
21137
21156
|
if (!value || typeof value !== "object" || Array.isArray(value)) {
|
|
@@ -21170,14 +21189,14 @@ function readEntryHtml(filePath) {
|
|
|
21170
21189
|
}
|
|
21171
21190
|
try {
|
|
21172
21191
|
if (!fstatSync3(fd).isFile()) return null;
|
|
21173
|
-
return
|
|
21192
|
+
return readFileSync16(fd, "utf-8");
|
|
21174
21193
|
} finally {
|
|
21175
21194
|
closeSync7(fd);
|
|
21176
21195
|
}
|
|
21177
21196
|
}
|
|
21178
21197
|
function readProjectEntryFile(projectDir, preferredEntryFile) {
|
|
21179
21198
|
const absProjectDir = resolve11(projectDir);
|
|
21180
|
-
if (!
|
|
21199
|
+
if (!existsSync31(absProjectDir) || !statSync12(absProjectDir).isDirectory()) {
|
|
21181
21200
|
return { error: `Project directory not found: ${absProjectDir}` };
|
|
21182
21201
|
}
|
|
21183
21202
|
const entryCandidates = [preferredEntryFile, "index.html", "src/index.html"].filter(
|
|
@@ -21199,7 +21218,7 @@ function readProjectEntryFile(projectDir, preferredEntryFile) {
|
|
|
21199
21218
|
}
|
|
21200
21219
|
}
|
|
21201
21220
|
return {
|
|
21202
|
-
error: `No HTML entry file found in project directory: ${
|
|
21221
|
+
error: `No HTML entry file found in project directory: ${join46(absProjectDir, preferredEntryFile || "index.html")}`
|
|
21203
21222
|
};
|
|
21204
21223
|
}
|
|
21205
21224
|
function prepareHyperframeLintBody(body) {
|
|
@@ -21245,8 +21264,8 @@ async function runHyperframeLint(prepared) {
|
|
|
21245
21264
|
// src/services/healthWorker.ts
|
|
21246
21265
|
import { Worker as Worker2 } from "node:worker_threads";
|
|
21247
21266
|
import { fileURLToPath as fileURLToPath6 } from "node:url";
|
|
21248
|
-
import { dirname as dirname18, join as
|
|
21249
|
-
import { existsSync as
|
|
21267
|
+
import { dirname as dirname18, join as join47 } from "node:path";
|
|
21268
|
+
import { existsSync as existsSync32 } from "node:fs";
|
|
21250
21269
|
var DEFAULT_HEALTH_PORT = 9848;
|
|
21251
21270
|
async function startHealthWorker(options = {}) {
|
|
21252
21271
|
const log = options.logger ?? defaultLogger2();
|
|
@@ -21321,9 +21340,9 @@ function defaultLogger2() {
|
|
|
21321
21340
|
}
|
|
21322
21341
|
function resolveWorkerEntry2() {
|
|
21323
21342
|
const here = dirname18(fileURLToPath6(import.meta.url));
|
|
21324
|
-
const candidates = [
|
|
21343
|
+
const candidates = [join47(here, "healthWorkerThread.js"), join47(here, "healthWorkerThread.ts")];
|
|
21325
21344
|
for (const candidate of candidates) {
|
|
21326
|
-
if (
|
|
21345
|
+
if (existsSync32(candidate)) return candidate;
|
|
21327
21346
|
}
|
|
21328
21347
|
return void 0;
|
|
21329
21348
|
}
|
|
@@ -21469,7 +21488,7 @@ function resolvePreparedRenderOutput(prepared, rendersDir, log) {
|
|
|
21469
21488
|
const { input, cleanupProjectDir } = prepared;
|
|
21470
21489
|
const absoluteOutputPath = resolveOutputPath(input.projectDir, input.outputPath, rendersDir, log);
|
|
21471
21490
|
const outputDir = dirname19(absoluteOutputPath);
|
|
21472
|
-
if (!
|
|
21491
|
+
if (!existsSync33(outputDir)) mkdirSync21(outputDir, { recursive: true });
|
|
21473
21492
|
return { input, cleanupProjectDir, absoluteOutputPath };
|
|
21474
21493
|
}
|
|
21475
21494
|
function validateRenderOverrides(body) {
|
|
@@ -21510,11 +21529,11 @@ function prepareProjectDirectory(projectDir, options) {
|
|
|
21510
21529
|
const candidate = nonEmptyString(projectDir);
|
|
21511
21530
|
if (!candidate) return null;
|
|
21512
21531
|
const absProjectDir = resolve12(candidate);
|
|
21513
|
-
if (!
|
|
21532
|
+
if (!existsSync33(absProjectDir) || !statSync13(absProjectDir).isDirectory()) {
|
|
21514
21533
|
return { error: `Project directory not found: ${absProjectDir}` };
|
|
21515
21534
|
}
|
|
21516
21535
|
const entry = options.entryFile || "index.html";
|
|
21517
|
-
if (!
|
|
21536
|
+
if (!existsSync33(resolve12(absProjectDir, entry))) {
|
|
21518
21537
|
return { error: `Entry file "${entry}" not found in project directory: ${absProjectDir}` };
|
|
21519
21538
|
}
|
|
21520
21539
|
return { prepared: { input: { projectDir: absProjectDir, ...options } } };
|
|
@@ -21535,8 +21554,8 @@ async function resolveInlineRenderHtml(body) {
|
|
|
21535
21554
|
}
|
|
21536
21555
|
function materializeInlineProject(html, options) {
|
|
21537
21556
|
const tempRoot = process.env.PRODUCER_TMP_PROJECT_DIR || tmpdir5();
|
|
21538
|
-
const tempProjectDir = mkdtempSync2(
|
|
21539
|
-
writeFileSync14(
|
|
21557
|
+
const tempProjectDir = mkdtempSync2(join48(tempRoot, "producer-project-"));
|
|
21558
|
+
writeFileSync14(join48(tempProjectDir, "index.html"), html, "utf-8");
|
|
21540
21559
|
return {
|
|
21541
21560
|
prepared: {
|
|
21542
21561
|
input: { projectDir: tempProjectDir, ...options },
|
|
@@ -21606,7 +21625,7 @@ function cleanupTempDir(dir, log) {
|
|
|
21606
21625
|
}
|
|
21607
21626
|
}
|
|
21608
21627
|
function outputFileSize(path) {
|
|
21609
|
-
return
|
|
21628
|
+
return existsSync33(path) ? statSync13(path).size : 0;
|
|
21610
21629
|
}
|
|
21611
21630
|
function createBlockingProgressReporter(log, requestId) {
|
|
21612
21631
|
let lastLoggedPct = -10;
|
|
@@ -21910,7 +21929,7 @@ function createRenderHandlers(options = {}) {
|
|
|
21910
21929
|
if (!artifact) {
|
|
21911
21930
|
return c.json({ success: false, error: "Output artifact not found or expired" }, 404);
|
|
21912
21931
|
}
|
|
21913
|
-
if (!
|
|
21932
|
+
if (!existsSync33(artifact.path)) {
|
|
21914
21933
|
store.delete(token);
|
|
21915
21934
|
return c.json({ success: false, error: "Output artifact file missing" }, 404);
|
|
21916
21935
|
}
|
|
@@ -22007,7 +22026,7 @@ import { quantizeTimeToFrame, MEDIA_VISUAL_STYLE_PROPERTIES } from "@hyperframes
|
|
|
22007
22026
|
// src/services/distributed/planV2Execution.ts
|
|
22008
22027
|
import { mkdtempSync as mkdtempSync3, rmSync as rmSync21 } from "node:fs";
|
|
22009
22028
|
import { tmpdir as tmpdir6 } from "node:os";
|
|
22010
|
-
import { join as
|
|
22029
|
+
import { join as join50 } from "node:path";
|
|
22011
22030
|
|
|
22012
22031
|
// src/services/distributed/assemble.ts
|
|
22013
22032
|
import {
|
|
@@ -22016,15 +22035,15 @@ import {
|
|
|
22016
22035
|
} from "@hyperframes/engine";
|
|
22017
22036
|
import {
|
|
22018
22037
|
cpSync as cpSync3,
|
|
22019
|
-
existsSync as
|
|
22038
|
+
existsSync as existsSync34,
|
|
22020
22039
|
mkdirSync as mkdirSync22,
|
|
22021
|
-
readFileSync as
|
|
22040
|
+
readFileSync as readFileSync17,
|
|
22022
22041
|
readdirSync as readdirSync12,
|
|
22023
22042
|
rmSync as rmSync20,
|
|
22024
22043
|
statSync as statSync14,
|
|
22025
22044
|
writeFileSync as writeFileSync15
|
|
22026
22045
|
} from "node:fs";
|
|
22027
|
-
import { basename as basename8, dirname as dirname20, join as
|
|
22046
|
+
import { basename as basename8, dirname as dirname20, join as join49 } from "node:path";
|
|
22028
22047
|
import {
|
|
22029
22048
|
appendRateCapArgs as appendRateCapArgs2,
|
|
22030
22049
|
appendRenderProvenanceArgs as appendRenderProvenanceArgs2,
|
|
@@ -22071,7 +22090,7 @@ async function assemble(planDir, chunkOutputs, audioPath, outputPath, options) {
|
|
|
22071
22090
|
}
|
|
22072
22091
|
const format = plan2.dimensions.format;
|
|
22073
22092
|
const cfrEncoder = cfr ? readCfrEncoder(planDir, format) : null;
|
|
22074
|
-
if (!
|
|
22093
|
+
if (!existsSync34(dirname20(outputPath))) {
|
|
22075
22094
|
mkdirSync22(dirname20(outputPath), { recursive: true });
|
|
22076
22095
|
}
|
|
22077
22096
|
const workDir = createStagingDir7(dirname20(outputPath), `${basename8(outputPath)}.assemble-work-`);
|
|
@@ -22094,8 +22113,8 @@ async function assemble(planDir, chunkOutputs, audioPath, outputPath, options) {
|
|
|
22094
22113
|
};
|
|
22095
22114
|
try {
|
|
22096
22115
|
const videoSources = cfrEncoder ? [await reencodeCfr(ctx, chunkPaths, cfrEncoder)] : chunkPaths;
|
|
22097
|
-
const finalPath =
|
|
22098
|
-
const audio = audioPath !== null &&
|
|
22116
|
+
const finalPath = join49(workDir, `output.${format}`);
|
|
22117
|
+
const audio = audioPath !== null && existsSync34(audioPath) ? audioPath : null;
|
|
22099
22118
|
await writeJoined(ctx, videoSources, audio, finalPath);
|
|
22100
22119
|
renameWithRetry11(finalPath, outputPath);
|
|
22101
22120
|
log.info("[assemble] stage timings", {
|
|
@@ -22113,7 +22132,7 @@ async function assemble(planDir, chunkOutputs, audioPath, outputPath, options) {
|
|
|
22113
22132
|
});
|
|
22114
22133
|
}
|
|
22115
22134
|
}
|
|
22116
|
-
const fileSize =
|
|
22135
|
+
const fileSize = existsSync34(outputPath) ? statSync14(outputPath).size : 0;
|
|
22117
22136
|
return {
|
|
22118
22137
|
...referenceBackgroundResult8(plan2[REFERENCE_BACKGROUND_FIELD6]),
|
|
22119
22138
|
outputPath,
|
|
@@ -22123,18 +22142,18 @@ async function assemble(planDir, chunkOutputs, audioPath, outputPath, options) {
|
|
|
22123
22142
|
};
|
|
22124
22143
|
}
|
|
22125
22144
|
function readAssemblePlan(planDir, chunkPaths) {
|
|
22126
|
-
const planJsonPath =
|
|
22127
|
-
const chunksJsonPath =
|
|
22128
|
-
if (!
|
|
22145
|
+
const planJsonPath = join49(planDir, "plan.json");
|
|
22146
|
+
const chunksJsonPath = join49(planDir, "meta", "chunks.json");
|
|
22147
|
+
if (!existsSync34(planJsonPath)) {
|
|
22129
22148
|
throw new Error(`[assemble] planDir missing plan.json: ${planJsonPath}`);
|
|
22130
22149
|
}
|
|
22131
|
-
const plan2 = JSON.parse(
|
|
22150
|
+
const plan2 = JSON.parse(readFileSync17(planJsonPath, "utf-8"));
|
|
22132
22151
|
readPlanProtocolV1(plan2, DISTRIBUTED_RENDER_CAPABILITIES.roles.assembler);
|
|
22133
22152
|
validatePlanV2MaterializedTarget(planDir, { role: "assembler" });
|
|
22134
|
-
if (!
|
|
22153
|
+
if (!existsSync34(chunksJsonPath)) {
|
|
22135
22154
|
throw new Error(`[assemble] planDir missing meta/chunks.json: ${chunksJsonPath}`);
|
|
22136
22155
|
}
|
|
22137
|
-
const chunks = JSON.parse(
|
|
22156
|
+
const chunks = JSON.parse(readFileSync17(chunksJsonPath, "utf-8"));
|
|
22138
22157
|
if (chunkPaths.length !== chunks.length) {
|
|
22139
22158
|
throw new Error(
|
|
22140
22159
|
`[assemble] chunkPaths length (${chunkPaths.length}) does not match chunks.json length (${chunks.length}). Adapters must pass one path per chunk, ordered by index.`
|
|
@@ -22146,7 +22165,7 @@ function readAssemblePlan(planDir, chunkPaths) {
|
|
|
22146
22165
|
}
|
|
22147
22166
|
}
|
|
22148
22167
|
for (const path of chunkPaths.flat()) {
|
|
22149
|
-
if (!
|
|
22168
|
+
if (!existsSync34(path)) {
|
|
22150
22169
|
throw new Error(`[assemble] chunk path does not exist: ${path}`);
|
|
22151
22170
|
}
|
|
22152
22171
|
}
|
|
@@ -22175,7 +22194,7 @@ function cfrEncodeArgs(inputArgs, encoder, fpsArg) {
|
|
|
22175
22194
|
return args;
|
|
22176
22195
|
}
|
|
22177
22196
|
async function reencodeCfr(ctx, chunkPaths, encoder) {
|
|
22178
|
-
const cfrOutputPath =
|
|
22197
|
+
const cfrOutputPath = join49(ctx.workDir, `cfr.${ctx.format}`);
|
|
22179
22198
|
const cfrArgs = cfrEncodeArgs(videoInputArgs(ctx, chunkPaths), encoder, ctx.fpsArg);
|
|
22180
22199
|
appendRenderProvenanceArgs2(cfrArgs, cfrOutputPath);
|
|
22181
22200
|
cfrArgs.push("-y", cfrOutputPath);
|
|
@@ -22202,7 +22221,7 @@ async function writeJoined(ctx, videoSources, audioPath, finalPath) {
|
|
|
22202
22221
|
);
|
|
22203
22222
|
return;
|
|
22204
22223
|
}
|
|
22205
|
-
const paddedAudioPath =
|
|
22224
|
+
const paddedAudioPath = join49(ctx.workDir, "audio-padded.m4a");
|
|
22206
22225
|
const padTrimResult = await ctx.timed(
|
|
22207
22226
|
"audioMs",
|
|
22208
22227
|
() => padOrTrimAudioToVideoFrameCount({
|
|
@@ -22242,7 +22261,7 @@ async function writeJoined(ctx, videoSources, audioPath, finalPath) {
|
|
|
22242
22261
|
}
|
|
22243
22262
|
}
|
|
22244
22263
|
function concatDemuxerInput(chunkPaths, workDir, fpsArg) {
|
|
22245
|
-
const listPath =
|
|
22264
|
+
const listPath = join49(workDir, "concat-list.txt");
|
|
22246
22265
|
const body = chunkPaths.map((path) => `file '${path.replace(/'/g, "'\\''")}'`).join("\n");
|
|
22247
22266
|
writeFileSync15(listPath, `${body}
|
|
22248
22267
|
`, "utf-8");
|
|
@@ -22280,13 +22299,13 @@ function stitchesSeparateAudio(planDir) {
|
|
|
22280
22299
|
return lockedAudio(planDir).separateAudio === true;
|
|
22281
22300
|
}
|
|
22282
22301
|
function planFormat(planDir) {
|
|
22283
|
-
const plan2 = JSON.parse(
|
|
22302
|
+
const plan2 = JSON.parse(readFileSync17(join49(planDir, "plan.json"), "utf-8"));
|
|
22284
22303
|
return plan2.dimensions.format;
|
|
22285
22304
|
}
|
|
22286
22305
|
function lockedAudio(planDir) {
|
|
22287
|
-
const encoderJsonPath =
|
|
22288
|
-
if (!
|
|
22289
|
-
return JSON.parse(
|
|
22306
|
+
const encoderJsonPath = join49(planDir, "meta", "encoder.json");
|
|
22307
|
+
if (!existsSync34(encoderJsonPath)) return {};
|
|
22308
|
+
return JSON.parse(readFileSync17(encoderJsonPath, "utf-8"));
|
|
22290
22309
|
}
|
|
22291
22310
|
function readCfrEncoder(planDir, format) {
|
|
22292
22311
|
if (format !== "mp4") {
|
|
@@ -22294,11 +22313,11 @@ function readCfrEncoder(planDir, format) {
|
|
|
22294
22313
|
`[assemble] cfr=true is only supported for format="mp4" (got "${format}"). Stream-copy paths for webm and mov already produce exact avg_frame_rate; cfr re-encode is not needed.`
|
|
22295
22314
|
);
|
|
22296
22315
|
}
|
|
22297
|
-
const encoderJsonPath =
|
|
22298
|
-
if (!
|
|
22316
|
+
const encoderJsonPath = join49(planDir, "meta", "encoder.json");
|
|
22317
|
+
if (!existsSync34(encoderJsonPath)) {
|
|
22299
22318
|
throw new Error(`[assemble] planDir missing meta/encoder.json: ${encoderJsonPath}`);
|
|
22300
22319
|
}
|
|
22301
|
-
const encoderJson = JSON.parse(
|
|
22320
|
+
const encoderJson = JSON.parse(readFileSync17(encoderJsonPath, "utf-8"));
|
|
22302
22321
|
if (encoderJson.encoder === "libx265-software") {
|
|
22303
22322
|
throw new Error(
|
|
22304
22323
|
`[assemble] cfr=true is not yet supported with codec: "h265". The cfr re-encode pass uses libx264 and would silently transcode the h265 chunks. Either disable cfr or render with codec: "h264".`
|
|
@@ -22307,7 +22326,7 @@ function readCfrEncoder(planDir, format) {
|
|
|
22307
22326
|
return encoderJson;
|
|
22308
22327
|
}
|
|
22309
22328
|
function mergePngFrameDirs(chunkPaths, outputPath, totalFrames, audioPath, startTimeMs) {
|
|
22310
|
-
if (
|
|
22329
|
+
if (existsSync34(outputPath)) rmSync20(outputPath, { recursive: true, force: true });
|
|
22311
22330
|
mkdirSync22(outputPath, { recursive: true });
|
|
22312
22331
|
let globalIdx = 0;
|
|
22313
22332
|
for (const chunkDir of chunkPaths) {
|
|
@@ -22321,8 +22340,8 @@ function mergePngFrameDirs(chunkPaths, outputPath, totalFrames, audioPath, start
|
|
|
22321
22340
|
throw new Error(`[assemble] png-sequence chunk has no frames: ${chunkDir}`);
|
|
22322
22341
|
}
|
|
22323
22342
|
for (const frame of frames) {
|
|
22324
|
-
const dst =
|
|
22325
|
-
cpSync3(
|
|
22343
|
+
const dst = join49(outputPath, formatExportFrameName(globalIdx, "png"));
|
|
22344
|
+
cpSync3(join49(chunkDir, frame), dst);
|
|
22326
22345
|
globalIdx += 1;
|
|
22327
22346
|
}
|
|
22328
22347
|
}
|
|
@@ -22331,14 +22350,14 @@ function mergePngFrameDirs(chunkPaths, outputPath, totalFrames, audioPath, start
|
|
|
22331
22350
|
`[assemble] png-sequence frame count mismatch: merged ${globalIdx} frames vs plan.totalFrames=${totalFrames}. Using on-disk count.`
|
|
22332
22351
|
);
|
|
22333
22352
|
}
|
|
22334
|
-
if (audioPath !== null &&
|
|
22335
|
-
const sidecar =
|
|
22353
|
+
if (audioPath !== null && existsSync34(audioPath)) {
|
|
22354
|
+
const sidecar = join49(outputPath, MIXED_AUDIO_FILENAME4);
|
|
22336
22355
|
cpSync3(audioPath, sidecar);
|
|
22337
22356
|
}
|
|
22338
22357
|
let fileSize = 0;
|
|
22339
22358
|
for (const name of readdirSync12(outputPath)) {
|
|
22340
22359
|
try {
|
|
22341
|
-
fileSize += statSync14(
|
|
22360
|
+
fileSize += statSync14(join49(outputPath, name)).size;
|
|
22342
22361
|
} catch {
|
|
22343
22362
|
}
|
|
22344
22363
|
}
|
|
@@ -22352,8 +22371,8 @@ function mergePngFrameDirs(chunkPaths, outputPath, totalFrames, audioPath, start
|
|
|
22352
22371
|
|
|
22353
22372
|
// src/services/distributed/planV2Execution.ts
|
|
22354
22373
|
async function renderChunkV2(planV2Dir, chunkIndex, outputChunkPath, options) {
|
|
22355
|
-
const workRoot = mkdtempSync3(
|
|
22356
|
-
const materializedPlanDir =
|
|
22374
|
+
const workRoot = mkdtempSync3(join50(tmpdir6(), "hf-plan-v2-chunk-"));
|
|
22375
|
+
const materializedPlanDir = join50(workRoot, "plan");
|
|
22357
22376
|
try {
|
|
22358
22377
|
materializePlanV2Target(planV2Dir, { role: "chunk", chunkIndex }, materializedPlanDir);
|
|
22359
22378
|
return await renderChunk(materializedPlanDir, chunkIndex, outputChunkPath, options);
|
|
@@ -22362,8 +22381,8 @@ async function renderChunkV2(planV2Dir, chunkIndex, outputChunkPath, options) {
|
|
|
22362
22381
|
}
|
|
22363
22382
|
}
|
|
22364
22383
|
async function assembleV2(planV2Dir, chunkPaths, outputPath, options) {
|
|
22365
|
-
const workRoot = mkdtempSync3(
|
|
22366
|
-
const materializedPlanDir =
|
|
22384
|
+
const workRoot = mkdtempSync3(join50(tmpdir6(), "hf-plan-v2-assembler-"));
|
|
22385
|
+
const materializedPlanDir = join50(workRoot, "plan");
|
|
22367
22386
|
try {
|
|
22368
22387
|
const materialized = materializePlanV2Target(
|
|
22369
22388
|
planV2Dir,
|