@hyperframes/producer 0.9.87 → 0.9.89
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/README.md +1 -1
- package/dist/compileWorker.js +75 -15
- package/dist/distributed.js +182 -82
- package/dist/hyperframe.manifest.json +1 -1
- package/dist/hyperframe.runtime.iife.js +69 -69
- package/dist/index.js +286 -123
- package/dist/public-server.js +238 -77
- package/dist/server.d.ts +1 -1
- package/dist/services/animatedGifPrep.d.ts +2 -0
- package/dist/services/assetMediaType.d.ts +4 -4
- package/dist/services/compileScratch.d.ts +2 -0
- package/dist/services/distributed/chunkFrames.d.ts +1 -0
- package/dist/services/heifImagePrep.d.ts +2 -0
- package/dist/services/render/deferredVideoFrames.d.ts +1 -0
- package/dist/services/render/shared.d.ts +3 -3
- package/package.json +7 -7
package/dist/distributed.js
CHANGED
|
@@ -11,10 +11,10 @@ import {
|
|
|
11
11
|
existsSync as existsSync20,
|
|
12
12
|
linkSync,
|
|
13
13
|
mkdirSync as mkdirSync10,
|
|
14
|
-
rmSync as
|
|
14
|
+
rmSync as rmSync8,
|
|
15
15
|
writeFileSync as writeFileSync8
|
|
16
16
|
} from "node:fs";
|
|
17
|
-
import { extname as extname4, isAbsolute as
|
|
17
|
+
import { extname as extname4, isAbsolute as isAbsolute4, join as join28, relative as relative7, sep as sep4 } from "node:path";
|
|
18
18
|
import {
|
|
19
19
|
fpsToNumber as fpsToNumber9,
|
|
20
20
|
HF_COLOR_GRADING_ATTR as HF_COLOR_GRADING_ATTR2
|
|
@@ -97,11 +97,11 @@ var DEFAULT_RENDERS_DIR = process.env.PRODUCER_RENDERS_DIR ?? // fileURLToPath (
|
|
|
97
97
|
nodeResolve(fileURLToPath(import.meta.url), "../../..", "renders");
|
|
98
98
|
var LEADING_PARENT_SEGMENT_RE = /^\.\.(?:[\\/]|$)/;
|
|
99
99
|
function isPathInside(childPath, parentPath, options = {}) {
|
|
100
|
-
const
|
|
100
|
+
const resolvePath2 = options.pathModule?.resolve ?? nodeResolve;
|
|
101
101
|
const relativePath = options.pathModule?.relative ?? nodeRelative;
|
|
102
102
|
const isPathAbsolute = options.pathModule?.isAbsolute ?? nodeIsAbsolute;
|
|
103
|
-
const absChild =
|
|
104
|
-
const absParent =
|
|
103
|
+
const absChild = resolvePath2(childPath);
|
|
104
|
+
const absParent = resolvePath2(parentPath);
|
|
105
105
|
if (absChild === absParent) return true;
|
|
106
106
|
const rel = relativePath(absParent, absChild);
|
|
107
107
|
return rel !== "" && !LEADING_PARENT_SEGMENT_RE.test(rel) && !isPathAbsolute(rel);
|
|
@@ -148,7 +148,7 @@ import {
|
|
|
148
148
|
existsSync as existsSync15,
|
|
149
149
|
mkdirSync as mkdirSync6,
|
|
150
150
|
readdirSync as readdirSync3,
|
|
151
|
-
rmSync as
|
|
151
|
+
rmSync as rmSync6,
|
|
152
152
|
statSync as statSync7,
|
|
153
153
|
writeFileSync as writeFileSync5,
|
|
154
154
|
copyFileSync as copyFileSync5,
|
|
@@ -377,7 +377,7 @@ import {
|
|
|
377
377
|
createReferenceBackgroundRecorder
|
|
378
378
|
} from "@hyperframes/engine";
|
|
379
379
|
import { join as join19, dirname as dirname12, resolve as resolve7 } from "path";
|
|
380
|
-
import { randomUUID } from "crypto";
|
|
380
|
+
import { randomUUID as randomUUID3 } from "crypto";
|
|
381
381
|
|
|
382
382
|
// src/services/fileServer.ts
|
|
383
383
|
import { Hono } from "hono";
|
|
@@ -1409,12 +1409,12 @@ var workerPhasesByJob = /* @__PURE__ */ new WeakMap();
|
|
|
1409
1409
|
function forgetWorkerPhases(job) {
|
|
1410
1410
|
workerPhasesByJob.delete(job);
|
|
1411
1411
|
}
|
|
1412
|
-
var
|
|
1413
|
-
function
|
|
1414
|
-
|
|
1412
|
+
var captureActivityByJob = /* @__PURE__ */ new WeakMap();
|
|
1413
|
+
function noteCaptureActivity(job) {
|
|
1414
|
+
captureActivityByJob.set(job, (captureActivityByJob.get(job) ?? 0) + 1);
|
|
1415
1415
|
}
|
|
1416
|
-
function
|
|
1417
|
-
return
|
|
1416
|
+
function captureActivity(job) {
|
|
1417
|
+
return captureActivityByJob.get(job) ?? 0;
|
|
1418
1418
|
}
|
|
1419
1419
|
function describeWorkerPhases(job) {
|
|
1420
1420
|
const phases = workerPhasesByJob.get(job);
|
|
@@ -2034,7 +2034,8 @@ async function extractDeferredFrames(input) {
|
|
|
2034
2034
|
outputDir: input.outputRoot,
|
|
2035
2035
|
format: range.format,
|
|
2036
2036
|
frameRanges: contiguousRuns(indexes),
|
|
2037
|
-
shownBox: input.shownBoxes?.get(video.videoId)
|
|
2037
|
+
shownBox: input.shownBoxes?.get(video.videoId),
|
|
2038
|
+
...input.onProgress && { onProgress: input.onProgress }
|
|
2038
2039
|
},
|
|
2039
2040
|
input.signal,
|
|
2040
2041
|
input.cfg
|
|
@@ -2454,7 +2455,7 @@ function requireOutputDimensions(expected, width, height) {
|
|
|
2454
2455
|
|
|
2455
2456
|
// src/services/render/stages/compileStage.ts
|
|
2456
2457
|
import { existsSync as existsSync9, writeFileSync as writeFileSync3 } from "node:fs";
|
|
2457
|
-
import { join as join11, relative as
|
|
2458
|
+
import { join as join11, relative as relative4 } from "node:path";
|
|
2458
2459
|
import { privateCacheRoot } from "@hyperframes/engine";
|
|
2459
2460
|
import { suggestMatchingPreset } from "@hyperframes/core";
|
|
2460
2461
|
import { extractStandaloneEntryFromIndex, isTemplateEntry } from "@hyperframes/core/compiler";
|
|
@@ -2462,8 +2463,8 @@ import { readTextFile as readTextFile2 } from "@hyperframes/parsers/asset-resolu
|
|
|
2462
2463
|
import { assertCompositionFileSize as assertCompositionFileSize2 } from "@hyperframes/core/compiler";
|
|
2463
2464
|
|
|
2464
2465
|
// src/services/compileInWorker.ts
|
|
2465
|
-
import { existsSync as existsSync8 } from "node:fs";
|
|
2466
|
-
import { dirname as dirname8, join as join10 } from "node:path";
|
|
2466
|
+
import { existsSync as existsSync8, rmSync as rmSync4 } from "node:fs";
|
|
2467
|
+
import { dirname as dirname8, isAbsolute as isAbsolute3, join as join10, relative as relative3, resolve as resolvePath } from "node:path";
|
|
2467
2468
|
import { fileURLToPath as fileURLToPath3 } from "node:url";
|
|
2468
2469
|
import { Worker } from "node:worker_threads";
|
|
2469
2470
|
|
|
@@ -2769,7 +2770,7 @@ import {
|
|
|
2769
2770
|
} from "@hyperframes/core/fonts/embed";
|
|
2770
2771
|
|
|
2771
2772
|
// src/services/animatedGifPrep.ts
|
|
2772
|
-
import { createHash as createHash3 } from "node:crypto";
|
|
2773
|
+
import { createHash as createHash3, randomUUID } from "node:crypto";
|
|
2773
2774
|
import { copyFileSync as copyFileSync2, existsSync as existsSync5, mkdirSync as mkdirSync2, readFileSync as readFileSync3, rmSync as rmSync2, statSync as statSync3 } from "node:fs";
|
|
2774
2775
|
import { dirname as dirname4, isAbsolute as isAbsolute2, join as join6, resolve as resolve4 } from "node:path";
|
|
2775
2776
|
import { parseHTML as parseHTML3 } from "linkedom";
|
|
@@ -2844,6 +2845,8 @@ function resolveLoop(metadata, override) {
|
|
|
2844
2845
|
}
|
|
2845
2846
|
var MAX_LOOP_ITERATIONS = 1e3;
|
|
2846
2847
|
var MAX_PAD_SECONDS = 3600;
|
|
2848
|
+
var FFMPEG_SELF_CPU_SECONDS_CAP = 3600;
|
|
2849
|
+
var FFMPEG_SELF_OUTPUT_BYTES_CAP = 1024 * 1024 * 1024;
|
|
2847
2850
|
function resolveCompositionDurationSeconds(document2) {
|
|
2848
2851
|
let max = null;
|
|
2849
2852
|
for (const el of Array.from(document2.querySelectorAll("[data-composition-id][data-duration]"))) {
|
|
@@ -2886,7 +2889,13 @@ function resolvePreparedPlayback(metadata, loopOverride, windowSeconds) {
|
|
|
2886
2889
|
return { loopIterations, padSeconds: Math.round(padSeconds * 1e3) / 1e3 };
|
|
2887
2890
|
}
|
|
2888
2891
|
function buildAnimatedGifTranscodeArgs(input) {
|
|
2889
|
-
const args = [
|
|
2892
|
+
const args = [
|
|
2893
|
+
"-hide_banner",
|
|
2894
|
+
"-loglevel",
|
|
2895
|
+
"error",
|
|
2896
|
+
"-timelimit",
|
|
2897
|
+
String(FFMPEG_SELF_CPU_SECONDS_CAP)
|
|
2898
|
+
];
|
|
2890
2899
|
if (input.loopIterations > 1) {
|
|
2891
2900
|
args.push("-stream_loop", String(input.loopIterations - 1));
|
|
2892
2901
|
}
|
|
@@ -2914,6 +2923,8 @@ function buildAnimatedGifTranscodeArgs(input) {
|
|
|
2914
2923
|
...input.padSeconds && input.padSeconds > 0 ? ["-vf", `tpad=stop_mode=clone:stop_duration=${input.padSeconds}`] : [],
|
|
2915
2924
|
// Explicit muxer: the transcode writes to a `.tmp-<pid>-<ts>` path whose
|
|
2916
2925
|
// extension ffmpeg cannot infer the container from.
|
|
2926
|
+
"-fs",
|
|
2927
|
+
String(FFMPEG_SELF_OUTPUT_BYTES_CAP),
|
|
2917
2928
|
"-f",
|
|
2918
2929
|
"webm",
|
|
2919
2930
|
"-y",
|
|
@@ -2921,10 +2932,16 @@ function buildAnimatedGifTranscodeArgs(input) {
|
|
|
2921
2932
|
);
|
|
2922
2933
|
return args;
|
|
2923
2934
|
}
|
|
2935
|
+
function abortError() {
|
|
2936
|
+
const error = new Error("Aborted");
|
|
2937
|
+
error.name = "AbortError";
|
|
2938
|
+
return error;
|
|
2939
|
+
}
|
|
2924
2940
|
async function runAnimatedGifTranscode(request) {
|
|
2925
2941
|
const timeout = request.timeoutMs ?? 3e5;
|
|
2926
|
-
const result = await runFfmpeg2(request.args, { timeout });
|
|
2942
|
+
const result = await runFfmpeg2(request.args, { timeout, signal: request.signal });
|
|
2927
2943
|
if (result.success) return;
|
|
2944
|
+
if (request.signal?.aborted) throw abortError();
|
|
2928
2945
|
if (result.failureReason === "external_interruption") {
|
|
2929
2946
|
throw encoderFailureError("Animated GIF transcode failed", {
|
|
2930
2947
|
error: `exit ${result.exitCode}: ${result.stderr.slice(-500)}`,
|
|
@@ -2944,7 +2961,7 @@ async function ensurePreparedWebm(input) {
|
|
|
2944
2961
|
mkdirSync2(dirname4(input.outputPath), { recursive: true });
|
|
2945
2962
|
}
|
|
2946
2963
|
if (!isUsableFile(input.cachePath)) {
|
|
2947
|
-
const tmpPath = `${input.cachePath}.tmp-${process.pid}-${
|
|
2964
|
+
const tmpPath = `${input.cachePath}.tmp-${process.pid}-${randomUUID()}`;
|
|
2948
2965
|
const args = buildAnimatedGifTranscodeArgs({
|
|
2949
2966
|
inputPath: input.sourcePath,
|
|
2950
2967
|
outputPath: tmpPath,
|
|
@@ -2957,11 +2974,15 @@ async function ensurePreparedWebm(input) {
|
|
|
2957
2974
|
inputPath: input.sourcePath,
|
|
2958
2975
|
outputPath: tmpPath,
|
|
2959
2976
|
args,
|
|
2960
|
-
timeoutMs: input.timeoutMs
|
|
2977
|
+
timeoutMs: input.timeoutMs,
|
|
2978
|
+
signal: input.signal
|
|
2961
2979
|
});
|
|
2962
2980
|
if (!isUsableFile(tmpPath)) {
|
|
2963
2981
|
throw new Error("Animated GIF transcode produced an empty output");
|
|
2964
2982
|
}
|
|
2983
|
+
if (statSync3(tmpPath).size >= FFMPEG_SELF_OUTPUT_BYTES_CAP) {
|
|
2984
|
+
throw new Error("Animated GIF transcode reached its output size limit");
|
|
2985
|
+
}
|
|
2965
2986
|
if (!isUsableFile(input.cachePath)) {
|
|
2966
2987
|
renameWithRetry2(tmpPath, input.cachePath);
|
|
2967
2988
|
} else {
|
|
@@ -3061,6 +3082,7 @@ async function prepareAnimatedGifInputs(html, options) {
|
|
|
3061
3082
|
loopIterations,
|
|
3062
3083
|
padSeconds,
|
|
3063
3084
|
timeoutMs: options.timeoutMs,
|
|
3085
|
+
signal: options.signal,
|
|
3064
3086
|
transcode: options.transcode
|
|
3065
3087
|
});
|
|
3066
3088
|
const id = ensureElementId(img, document2, i);
|
|
@@ -3085,7 +3107,7 @@ async function prepareAnimatedGifInputs(html, options) {
|
|
|
3085
3107
|
}
|
|
3086
3108
|
|
|
3087
3109
|
// src/services/heifImagePrep.ts
|
|
3088
|
-
import { createHash as createHash4 } from "node:crypto";
|
|
3110
|
+
import { createHash as createHash4, randomUUID as randomUUID2 } from "node:crypto";
|
|
3089
3111
|
import {
|
|
3090
3112
|
closeSync as closeSync2,
|
|
3091
3113
|
copyFileSync as copyFileSync3,
|
|
@@ -3231,6 +3253,13 @@ var HeifToolUnavailableError = class extends Error {
|
|
|
3231
3253
|
this.name = "HeifToolUnavailableError";
|
|
3232
3254
|
}
|
|
3233
3255
|
};
|
|
3256
|
+
function abortError2() {
|
|
3257
|
+
const error = new Error("Aborted");
|
|
3258
|
+
error.name = "AbortError";
|
|
3259
|
+
return error;
|
|
3260
|
+
}
|
|
3261
|
+
var FFMPEG_SELF_CPU_SECONDS_CAP2 = 300;
|
|
3262
|
+
var FFMPEG_SELF_OUTPUT_BYTES_CAP2 = 256 * 1024 * 1024;
|
|
3234
3263
|
var TOOL_FAILURE_RE = /(?:ffmpeg|ffprobe) not found|ENOENT|Option not found|Unrecognized option|Unknown decoder|Decoder \S+ not found/i;
|
|
3235
3264
|
function isHeifBytes(head) {
|
|
3236
3265
|
const bytes = Buffer.from(head.buffer, head.byteOffset, head.byteLength);
|
|
@@ -3298,6 +3327,8 @@ async function convertHeifToJpeg(request) {
|
|
|
3298
3327
|
"-hide_banner",
|
|
3299
3328
|
"-loglevel",
|
|
3300
3329
|
"error",
|
|
3330
|
+
"-timelimit",
|
|
3331
|
+
String(FFMPEG_SELF_CPU_SECONDS_CAP2),
|
|
3301
3332
|
...urlInputArgs3(request.inputPath),
|
|
3302
3333
|
"-i",
|
|
3303
3334
|
request.inputPath,
|
|
@@ -3306,14 +3337,17 @@ async function convertHeifToJpeg(request) {
|
|
|
3306
3337
|
"1",
|
|
3307
3338
|
"-q:v",
|
|
3308
3339
|
"2",
|
|
3340
|
+
"-fs",
|
|
3341
|
+
String(FFMPEG_SELF_OUTPUT_BYTES_CAP2),
|
|
3309
3342
|
"-f",
|
|
3310
3343
|
"mjpeg",
|
|
3311
3344
|
"-y",
|
|
3312
3345
|
request.outputPath
|
|
3313
3346
|
],
|
|
3314
|
-
{ timeout: request.timeoutMs ?? DEFAULT_TIMEOUT_MS }
|
|
3347
|
+
{ timeout: request.timeoutMs ?? DEFAULT_TIMEOUT_MS, signal: request.signal }
|
|
3315
3348
|
);
|
|
3316
3349
|
if (!result.success) {
|
|
3350
|
+
if (request.signal?.aborted) throw abortError2();
|
|
3317
3351
|
throw result.error ?? new Error(`ffmpeg exited ${result.exitCode}: ${result.stderr.slice(-300)}`);
|
|
3318
3352
|
}
|
|
3319
3353
|
const out = (await probeJson(request.outputPath, false)).streams?.[0];
|
|
@@ -3347,7 +3381,7 @@ async function ensurePreparedJpeg(source, cachePath, outputPath, options) {
|
|
|
3347
3381
|
mkdirSync3(dirname5(cachePath), { recursive: true });
|
|
3348
3382
|
mkdirSync3(dirname5(outputPath), { recursive: true });
|
|
3349
3383
|
if (!isUsableFile2(cachePath)) {
|
|
3350
|
-
const tmpPath = `${cachePath}.tmp-${process.pid}-${
|
|
3384
|
+
const tmpPath = `${cachePath}.tmp-${process.pid}-${randomUUID2()}`;
|
|
3351
3385
|
const inlinePath = `${tmpPath}.heic`;
|
|
3352
3386
|
const inputPath = source.path ?? inlinePath;
|
|
3353
3387
|
try {
|
|
@@ -3355,9 +3389,13 @@ async function ensurePreparedJpeg(source, cachePath, outputPath, options) {
|
|
|
3355
3389
|
await (options.transcode ?? convertHeifToJpeg)({
|
|
3356
3390
|
inputPath,
|
|
3357
3391
|
outputPath: tmpPath,
|
|
3358
|
-
timeoutMs: options.timeoutMs
|
|
3392
|
+
timeoutMs: options.timeoutMs,
|
|
3393
|
+
signal: options.signal
|
|
3359
3394
|
});
|
|
3360
3395
|
if (!isUsableFile2(tmpPath)) throw new Error("conversion produced an empty file");
|
|
3396
|
+
if (statSync4(tmpPath).size >= FFMPEG_SELF_OUTPUT_BYTES_CAP2) {
|
|
3397
|
+
throw new Error("conversion reached its output size limit");
|
|
3398
|
+
}
|
|
3361
3399
|
renameWithRetry3(tmpPath, cachePath);
|
|
3362
3400
|
} catch (error) {
|
|
3363
3401
|
const reason = error instanceof Error ? error.message : String(error);
|
|
@@ -3428,6 +3466,7 @@ import {
|
|
|
3428
3466
|
isNotImagePayload,
|
|
3429
3467
|
isNotMediaPayload,
|
|
3430
3468
|
isPrivateUnderAssetRoots as isPrivateUnderAssetRoots2,
|
|
3469
|
+
isStructurallyIncompletePngError,
|
|
3431
3470
|
playlistLeavesItsFolder,
|
|
3432
3471
|
NotMediaPayloadError,
|
|
3433
3472
|
probeMediaProfile,
|
|
@@ -3506,6 +3545,13 @@ async function notMediaReferences(path, references) {
|
|
|
3506
3545
|
if (images.length > 0 && await isNotImagePayload(path)) return images;
|
|
3507
3546
|
return await playlistLeavesItsFolder(path) ? references : [];
|
|
3508
3547
|
}
|
|
3548
|
+
function pngCutShort(references) {
|
|
3549
|
+
return references.filter((reference) => reference.expected === "video").map((reference) => ({
|
|
3550
|
+
expected: "video",
|
|
3551
|
+
detected: "image",
|
|
3552
|
+
elementFingerprint: fingerprintElementId(reference.id)
|
|
3553
|
+
}));
|
|
3554
|
+
}
|
|
3509
3555
|
async function preflightCompositionAssetMediaTypes(input) {
|
|
3510
3556
|
const references = [
|
|
3511
3557
|
...input.composition.videos.map((asset) => ({
|
|
@@ -3551,6 +3597,8 @@ async function preflightCompositionAssetMediaTypes(input) {
|
|
|
3551
3597
|
profile = await probeMediaProfile(resolvedPath, { signal: input.signal });
|
|
3552
3598
|
} catch (error) {
|
|
3553
3599
|
if (input.signal?.aborted) throw input.signal.reason ?? error;
|
|
3600
|
+
if (isStructurallyIncompletePngError(error))
|
|
3601
|
+
mismatches.push(...pngCutShort(pathReferences));
|
|
3554
3602
|
return;
|
|
3555
3603
|
}
|
|
3556
3604
|
for (const reference of pathReferences) {
|
|
@@ -4894,8 +4942,9 @@ async function inlineExternalFontStylesheets(html, budget = new CompositionExpan
|
|
|
4894
4942
|
const css = await fetchExternalStylesheetCss(href, fetchSignal);
|
|
4895
4943
|
const fontFaceBlocks = css ? extractFontFaceBlocks(css) : [];
|
|
4896
4944
|
if (fontFaceBlocks.length === 0) return;
|
|
4945
|
+
const fontCssWithLtAsCssEscape = fontFaceBlocks.join("\n").replace(/</g, "\\3c ");
|
|
4897
4946
|
const inlineStyle = `<style>/* Inlined external font stylesheet */
|
|
4898
|
-
${
|
|
4947
|
+
${fontCssWithLtAsCssEscape}
|
|
4899
4948
|
</style>`;
|
|
4900
4949
|
try {
|
|
4901
4950
|
budget.chargeGenerated(REMOTE_STYLESHEETS, inlineStyle.length);
|
|
@@ -5308,6 +5357,7 @@ async function compileWithAssets(projectDir, htmlPath, downloadDir, options, ass
|
|
|
5308
5357
|
cacheDir: options.animatedGifCacheDir,
|
|
5309
5358
|
sourceAssets: remoteImageAssets,
|
|
5310
5359
|
timeoutMs: options.ffmpegProcessTimeout,
|
|
5360
|
+
signal: options.abortSignal,
|
|
5311
5361
|
allowOutsideFiles: assetRoot === void 0
|
|
5312
5362
|
});
|
|
5313
5363
|
if (preparedHeifImages.length > 0) {
|
|
@@ -5324,6 +5374,7 @@ async function compileWithAssets(projectDir, htmlPath, downloadDir, options, ass
|
|
|
5324
5374
|
cacheDir: options.animatedGifCacheDir,
|
|
5325
5375
|
sourceAssets: gifSourceAssets,
|
|
5326
5376
|
timeoutMs: options.ffmpegProcessTimeout,
|
|
5377
|
+
signal: options.abortSignal,
|
|
5327
5378
|
allowOutsideFiles: assetRoot === void 0
|
|
5328
5379
|
});
|
|
5329
5380
|
if (preparedGifs.length > 0) {
|
|
@@ -5802,6 +5853,24 @@ function compileTimeoutMs() {
|
|
|
5802
5853
|
return Number.isInteger(fromEnv) && fromEnv > 0 ? Math.min(fromEnv, MAX_TIMER_MS) : DEFAULT_COMPILE_TIMEOUT_MS;
|
|
5803
5854
|
}
|
|
5804
5855
|
var warnedMissingEntry = false;
|
|
5856
|
+
var endOnProcessExit = /* @__PURE__ */ new Set();
|
|
5857
|
+
var processExitHooked = false;
|
|
5858
|
+
function onProcessExit(end) {
|
|
5859
|
+
if (!processExitHooked) {
|
|
5860
|
+
processExitHooked = true;
|
|
5861
|
+
process.on("exit", () => {
|
|
5862
|
+
for (const each of endOnProcessExit) each();
|
|
5863
|
+
});
|
|
5864
|
+
}
|
|
5865
|
+
endOnProcessExit.add(end);
|
|
5866
|
+
return () => endOnProcessExit.delete(end);
|
|
5867
|
+
}
|
|
5868
|
+
function tryQuietly(action) {
|
|
5869
|
+
try {
|
|
5870
|
+
action();
|
|
5871
|
+
} catch {
|
|
5872
|
+
}
|
|
5873
|
+
}
|
|
5805
5874
|
function resolveCompileWorkerEntry(explicit, log) {
|
|
5806
5875
|
if (explicit) return explicit;
|
|
5807
5876
|
const fromEnv = process.env.HF_COMPILE_WORKER_ENTRY;
|
|
@@ -5835,6 +5904,26 @@ async function compileForRenderInWorker(projectDir, htmlPath, downloadDir, optio
|
|
|
5835
5904
|
const thread = new Worker(entry, {
|
|
5836
5905
|
workerData: { projectDir, htmlPath, downloadDir, options: cloneable }
|
|
5837
5906
|
});
|
|
5907
|
+
const children = /* @__PURE__ */ new Map();
|
|
5908
|
+
const scratchRoots = [downloadDir, options.animatedGifCacheDir].flatMap(
|
|
5909
|
+
(dir) => dir ? [resolvePath(dir)] : []
|
|
5910
|
+
);
|
|
5911
|
+
const isScratch = (path) => scratchRoots.some((root) => {
|
|
5912
|
+
const rel = relative3(root, resolvePath(path));
|
|
5913
|
+
return rel !== "" && !rel.startsWith("..") && !isAbsolute3(rel);
|
|
5914
|
+
});
|
|
5915
|
+
const endChildren = (signal) => {
|
|
5916
|
+
for (const [pid, output] of children) {
|
|
5917
|
+
if (signal) tryQuietly(() => process.kill(pid, "SIGKILL"));
|
|
5918
|
+
if (output) tryQuietly(() => rmSync4(output, { force: true }));
|
|
5919
|
+
}
|
|
5920
|
+
children.clear();
|
|
5921
|
+
};
|
|
5922
|
+
const offProcessExit = onProcessExit(() => endChildren(true));
|
|
5923
|
+
const endThread = () => {
|
|
5924
|
+
endChildren(true);
|
|
5925
|
+
void thread.terminate();
|
|
5926
|
+
};
|
|
5838
5927
|
let settled = false;
|
|
5839
5928
|
const settle = (finish) => {
|
|
5840
5929
|
if (settled) return;
|
|
@@ -5845,7 +5934,7 @@ async function compileForRenderInWorker(projectDir, htmlPath, downloadDir, optio
|
|
|
5845
5934
|
};
|
|
5846
5935
|
const stop = () => {
|
|
5847
5936
|
thread.postMessage({ type: "abort" });
|
|
5848
|
-
setTimeout(
|
|
5937
|
+
setTimeout(endThread, TERMINATE_GRACE_MS).unref();
|
|
5849
5938
|
};
|
|
5850
5939
|
const timer = setTimeout(() => {
|
|
5851
5940
|
stop();
|
|
@@ -5858,7 +5947,7 @@ async function compileForRenderInWorker(projectDir, htmlPath, downloadDir, optio
|
|
|
5858
5947
|
abortSignal?.addEventListener("abort", onAbort, { once: true });
|
|
5859
5948
|
const retire = (graceMs) => {
|
|
5860
5949
|
thread.unref();
|
|
5861
|
-
setTimeout(
|
|
5950
|
+
setTimeout(endThread, graceMs).unref();
|
|
5862
5951
|
};
|
|
5863
5952
|
thread.on(
|
|
5864
5953
|
"message",
|
|
@@ -5877,13 +5966,22 @@ async function compileForRenderInWorker(projectDir, htmlPath, downloadDir, optio
|
|
|
5877
5966
|
}
|
|
5878
5967
|
}
|
|
5879
5968
|
);
|
|
5880
|
-
thread.on("error", (error) => settle(() => reject(error)));
|
|
5881
5969
|
thread.on(
|
|
5882
|
-
"
|
|
5883
|
-
(
|
|
5884
|
-
|
|
5885
|
-
|
|
5970
|
+
"message",
|
|
5971
|
+
({ type, pid, output }) => {
|
|
5972
|
+
if (pid === void 0) return;
|
|
5973
|
+
if (type === "child") children.set(pid, output && isScratch(output) ? output : void 0);
|
|
5974
|
+
else if (type === "childExit") children.delete(pid);
|
|
5975
|
+
}
|
|
5886
5976
|
);
|
|
5977
|
+
thread.on("error", (error) => settle(() => reject(error)));
|
|
5978
|
+
thread.on("exit", (code) => {
|
|
5979
|
+
offProcessExit();
|
|
5980
|
+
endChildren(false);
|
|
5981
|
+
settle(
|
|
5982
|
+
() => reject(new Error(`The compile worker exited with code ${code} before answering`))
|
|
5983
|
+
);
|
|
5984
|
+
});
|
|
5887
5985
|
});
|
|
5888
5986
|
}
|
|
5889
5987
|
|
|
@@ -5913,10 +6011,10 @@ function resolveEntryHtmlPath(input) {
|
|
|
5913
6011
|
const readEntry = (path) => {
|
|
5914
6012
|
if (escapesAssetRoot(path, input.assetRoot)) {
|
|
5915
6013
|
throw new Error(
|
|
5916
|
-
`Entry file "${
|
|
6014
|
+
`Entry file "${relative4(projectDir, path)}" leads outside the project folder`
|
|
5917
6015
|
);
|
|
5918
6016
|
}
|
|
5919
|
-
assertCompositionFileSize2(path,
|
|
6017
|
+
assertCompositionFileSize2(path, relative4(projectDir, path));
|
|
5920
6018
|
return readTextFile2(path);
|
|
5921
6019
|
};
|
|
5922
6020
|
const htmlPath = join11(projectDir, entryFile);
|
|
@@ -6480,7 +6578,7 @@ async function runProbeStage(input) {
|
|
|
6480
6578
|
staticDedupMemo,
|
|
6481
6579
|
compositionHash: computeCompositionObservabilityHash(compiled.html),
|
|
6482
6580
|
deferStaticDedup: true,
|
|
6483
|
-
onStaticDedupActivity: () =>
|
|
6581
|
+
onStaticDedupActivity: () => noteCaptureActivity(job)
|
|
6484
6582
|
};
|
|
6485
6583
|
const PROBE_MAX_ATTEMPTS = 2;
|
|
6486
6584
|
for (let attempt = 1; attempt <= PROBE_MAX_ATTEMPTS; attempt++) {
|
|
@@ -8673,7 +8771,7 @@ import {
|
|
|
8673
8771
|
mkdirSync as mkdirSync5,
|
|
8674
8772
|
readdirSync as readdirSync2,
|
|
8675
8773
|
readFileSync as readFileSync6,
|
|
8676
|
-
rmSync as
|
|
8774
|
+
rmSync as rmSync5,
|
|
8677
8775
|
statSync as statSync6,
|
|
8678
8776
|
writeFileSync as writeFileSync4
|
|
8679
8777
|
} from "node:fs";
|
|
@@ -8812,7 +8910,7 @@ async function encodeGifFromDir(framesDir, framePattern, outputPath, input) {
|
|
|
8812
8910
|
fileSize
|
|
8813
8911
|
};
|
|
8814
8912
|
} finally {
|
|
8815
|
-
|
|
8913
|
+
rmSync5(input.palettePath, { force: true });
|
|
8816
8914
|
}
|
|
8817
8915
|
}
|
|
8818
8916
|
function startEncodeProgress(job, stage, onProgress) {
|
|
@@ -9230,7 +9328,7 @@ function frameStallRule(job, totalFrames, probeStartupMs) {
|
|
|
9230
9328
|
tailMs: Math.max(TAIL_STALL_MS, noProgressMs),
|
|
9231
9329
|
detail: () => describeWorkerPhases(job),
|
|
9232
9330
|
attemptOpened: () => forgetWorkerPhases(job),
|
|
9233
|
-
activity: () =>
|
|
9331
|
+
activity: () => captureActivity(job)
|
|
9234
9332
|
};
|
|
9235
9333
|
}
|
|
9236
9334
|
function isRecoverableParallelCaptureError(error) {
|
|
@@ -9428,7 +9526,7 @@ async function executeDiskCaptureWithAdaptiveRetry(options) {
|
|
|
9428
9526
|
function createRenderJob(config) {
|
|
9429
9527
|
return {
|
|
9430
9528
|
...referenceBackgroundResult(void 0),
|
|
9431
|
-
id:
|
|
9529
|
+
id: randomUUID3(),
|
|
9432
9530
|
config: {
|
|
9433
9531
|
...config,
|
|
9434
9532
|
fps: toFps2(config.fps),
|
|
@@ -9913,6 +10011,7 @@ async function extractDeferredVideoFramesForChunk(input) {
|
|
|
9913
10011
|
outputRoot: input.outputRoot,
|
|
9914
10012
|
cfg: input.cfg,
|
|
9915
10013
|
shownBoxes: input.shownBoxes,
|
|
10014
|
+
...input.onProgress && { onProgress: input.onProgress },
|
|
9916
10015
|
sourceOf: (video) => {
|
|
9917
10016
|
const range = planned.get(video.videoId).deferredRange;
|
|
9918
10017
|
const remoteUrl = remoteSources[range.sourcePath];
|
|
@@ -10118,7 +10217,7 @@ async function readPlanReferenceBackground(input) {
|
|
|
10118
10217
|
|
|
10119
10218
|
// src/services/render/stages/freezePlan.ts
|
|
10120
10219
|
import { existsSync as existsSync18, mkdirSync as mkdirSync7, readFileSync as readFileSync8, readdirSync as readdirSync5, writeFileSync as writeFileSync6 } from "node:fs";
|
|
10121
|
-
import { join as join24, relative as
|
|
10220
|
+
import { join as join24, relative as relative5, resolve as resolve8 } from "node:path";
|
|
10122
10221
|
import {
|
|
10123
10222
|
REFERENCE_BACKGROUND_FIELD,
|
|
10124
10223
|
referenceBackgroundResult as referenceBackgroundResult3
|
|
@@ -10341,7 +10440,7 @@ function listPlanFiles(planDir) {
|
|
|
10341
10440
|
walk(full);
|
|
10342
10441
|
} else if (entry.isFile()) {
|
|
10343
10442
|
results.push({
|
|
10344
|
-
planRelativePath:
|
|
10443
|
+
planRelativePath: relative5(rootResolved, full).split(/[\\/]+/).join("/"),
|
|
10345
10444
|
absolutePath: full
|
|
10346
10445
|
});
|
|
10347
10446
|
}
|
|
@@ -10506,7 +10605,7 @@ import { join as join26 } from "node:path";
|
|
|
10506
10605
|
import { appendRenderProvenanceArgs, describeFfmpegFailure as describeFfmpegFailure4, runFfmpeg as runFfmpeg7 } from "@hyperframes/engine";
|
|
10507
10606
|
|
|
10508
10607
|
// src/services/distributed/mp4Stitch.ts
|
|
10509
|
-
import { createReadStream as createReadStream4, createWriteStream, mkdirSync as mkdirSync8, rmSync as
|
|
10608
|
+
import { createReadStream as createReadStream4, createWriteStream, mkdirSync as mkdirSync8, rmSync as rmSync7 } from "node:fs";
|
|
10510
10609
|
import { open } from "node:fs/promises";
|
|
10511
10610
|
import { renameWithRetry as renameWithRetry6 } from "@hyperframes/engine";
|
|
10512
10611
|
import { basename as basename5, dirname as dirname14, join as join25 } from "node:path";
|
|
@@ -10885,7 +10984,7 @@ async function writeStitchedMp4(chunkPaths, outputPath, audioPath) {
|
|
|
10885
10984
|
renameWithRetry6(join25(workDir, "out.mp4"), outputPath);
|
|
10886
10985
|
} finally {
|
|
10887
10986
|
out.destroy();
|
|
10888
|
-
|
|
10987
|
+
rmSync7(workDir, { recursive: true, force: true });
|
|
10889
10988
|
}
|
|
10890
10989
|
}
|
|
10891
10990
|
|
|
@@ -11063,7 +11162,7 @@ async function muxChunkWithAudio(input) {
|
|
|
11063
11162
|
// src/services/distributed/planSize.ts
|
|
11064
11163
|
import { createHash as createHash8 } from "node:crypto";
|
|
11065
11164
|
import { lstatSync, readdirSync as readdirSync6 } from "node:fs";
|
|
11066
|
-
import { extname as extname3, join as join27, relative as
|
|
11165
|
+
import { extname as extname3, join as join27, relative as relative6 } from "node:path";
|
|
11067
11166
|
var MAX_TOP_COMPONENTS = 10;
|
|
11068
11167
|
var SOURCE_MEDIA_EXTENSIONS = /* @__PURE__ */ new Set([
|
|
11069
11168
|
".aac",
|
|
@@ -11152,7 +11251,7 @@ function recordFile(result, components, rootDir, rootKind, filePath) {
|
|
|
11152
11251
|
} catch {
|
|
11153
11252
|
return;
|
|
11154
11253
|
}
|
|
11155
|
-
const rel =
|
|
11254
|
+
const rel = relative6(rootDir, filePath);
|
|
11156
11255
|
const segments = rel.split(/[\\/]+/).filter(Boolean);
|
|
11157
11256
|
const classified = classifyFile(segments, rootKind);
|
|
11158
11257
|
result.totalBytes += sizeBytes;
|
|
@@ -11401,7 +11500,7 @@ var FREEZE_OWNED_PLAN_FILES = [
|
|
|
11401
11500
|
];
|
|
11402
11501
|
function removeFreezeOwnedPlanFiles(planDir) {
|
|
11403
11502
|
for (const relativePath of FREEZE_OWNED_PLAN_FILES) {
|
|
11404
|
-
|
|
11503
|
+
rmSync8(join28(planDir, relativePath), { force: true });
|
|
11405
11504
|
}
|
|
11406
11505
|
}
|
|
11407
11506
|
function buildChunkSlices(totalFrames, chunkCount, effectiveChunkSize) {
|
|
@@ -11540,10 +11639,10 @@ function resolveDistributedEngineConfig(config) {
|
|
|
11540
11639
|
};
|
|
11541
11640
|
}
|
|
11542
11641
|
function leavesRoot(rel) {
|
|
11543
|
-
return rel === ".." || rel.startsWith(`..${sep4}`) ||
|
|
11642
|
+
return rel === ".." || rel.startsWith(`..${sep4}`) || isAbsolute4(rel);
|
|
11544
11643
|
}
|
|
11545
11644
|
function pathInside(root, path) {
|
|
11546
|
-
const rel =
|
|
11645
|
+
const rel = relative7(root, path);
|
|
11547
11646
|
return rel === "" || leavesRoot(rel) ? null : rel;
|
|
11548
11647
|
}
|
|
11549
11648
|
function stableSourcePath(roots, srcPath) {
|
|
@@ -11630,7 +11729,7 @@ async function compilePlanComposition(projectDir, config, planDir, options) {
|
|
|
11630
11729
|
throw new Error(`[plan] entry file not found: ${htmlPath}`);
|
|
11631
11730
|
}
|
|
11632
11731
|
const workDir = join28(planDir, ".plan-work");
|
|
11633
|
-
|
|
11732
|
+
rmSync8(workDir, { recursive: true, force: true });
|
|
11634
11733
|
mkdirSync10(workDir, { recursive: true });
|
|
11635
11734
|
const compiledDir = join28(workDir, "compiled");
|
|
11636
11735
|
mkdirSync10(compiledDir, { recursive: true });
|
|
@@ -11639,7 +11738,7 @@ async function compilePlanComposition(projectDir, config, planDir, options) {
|
|
|
11639
11738
|
recursive: true,
|
|
11640
11739
|
dereference: true,
|
|
11641
11740
|
filter: (src) => {
|
|
11642
|
-
const rel =
|
|
11741
|
+
const rel = relative7(projectDir, src);
|
|
11643
11742
|
if (rel === "") return true;
|
|
11644
11743
|
if (leavesRoot(rel)) return false;
|
|
11645
11744
|
if (job.config.allowOutsideProjectAssets) {
|
|
@@ -11862,15 +11961,15 @@ async function buildLocalExecutionPlan(projectDir, config, executionPlanDir, opt
|
|
|
11862
11961
|
logPlanStage(log, "extract", stageStarted);
|
|
11863
11962
|
const stagedVideoFrames = join28(compiledDir, "__hyperframes_video_frames");
|
|
11864
11963
|
const videoFramesDst = join28(planDir, "video-frames");
|
|
11865
|
-
if (existsSync20(videoFramesDst))
|
|
11964
|
+
if (existsSync20(videoFramesDst)) rmSync8(videoFramesDst, { recursive: true, force: true });
|
|
11866
11965
|
const videoSourcesDir = join28(planDir, "video-sources");
|
|
11867
|
-
|
|
11966
|
+
rmSync8(videoSourcesDir, { recursive: true, force: true });
|
|
11868
11967
|
if (existsSync20(stagedVideoFrames)) {
|
|
11869
11968
|
renameWithRetry7(stagedVideoFrames, videoFramesDst);
|
|
11870
11969
|
} else {
|
|
11871
11970
|
mkdirSync10(videoFramesDst, { recursive: true });
|
|
11872
11971
|
}
|
|
11873
|
-
if (existsSync20(finalCompiledDir))
|
|
11972
|
+
if (existsSync20(finalCompiledDir)) rmSync8(finalCompiledDir, { recursive: true, force: true });
|
|
11874
11973
|
renameWithRetry7(compiledDir, finalCompiledDir);
|
|
11875
11974
|
const shipVideoSource = createVideoSourceShipper({
|
|
11876
11975
|
planDir,
|
|
@@ -12040,7 +12139,7 @@ async function buildLocalExecutionPlan(projectDir, config, executionPlanDir, opt
|
|
|
12040
12139
|
format: config.format
|
|
12041
12140
|
};
|
|
12042
12141
|
try {
|
|
12043
|
-
|
|
12142
|
+
rmSync8(workDir, { recursive: true, force: true });
|
|
12044
12143
|
} catch (err) {
|
|
12045
12144
|
log.warn("[plan] failed to remove temp work dir", {
|
|
12046
12145
|
workDir,
|
|
@@ -12118,7 +12217,7 @@ async function buildPlanAudio(projectDir, config, workRoot, outputPath, options
|
|
|
12118
12217
|
renameWithRetry7(mixed.audioOutputPath, outputPath);
|
|
12119
12218
|
return { hasAudio: true };
|
|
12120
12219
|
} finally {
|
|
12121
|
-
|
|
12220
|
+
rmSync8(c.workDir, { recursive: true, force: true });
|
|
12122
12221
|
}
|
|
12123
12222
|
}
|
|
12124
12223
|
|
|
@@ -12134,12 +12233,12 @@ import {
|
|
|
12134
12233
|
mkdirSync as mkdirSync12,
|
|
12135
12234
|
readFileSync as readFileSync10,
|
|
12136
12235
|
readdirSync as readdirSync7,
|
|
12137
|
-
rmSync as
|
|
12236
|
+
rmSync as rmSync10,
|
|
12138
12237
|
statSync as statSync9,
|
|
12139
12238
|
writeFileSync as writeFileSync10
|
|
12140
12239
|
} from "node:fs";
|
|
12141
12240
|
import { tmpdir } from "node:os";
|
|
12142
|
-
import { dirname as dirname16, isAbsolute as
|
|
12241
|
+
import { dirname as dirname16, isAbsolute as isAbsolute5, join as join31, relative as relative8, resolve as resolve9, sep as sep5 } from "node:path";
|
|
12143
12242
|
import { DISTRIBUTED_FPS, isDistributedFps } from "@hyperframes/core";
|
|
12144
12243
|
import {
|
|
12145
12244
|
createFrameLookupTable as createFrameLookupTable5,
|
|
@@ -12153,7 +12252,7 @@ import {
|
|
|
12153
12252
|
existsSync as existsSync21,
|
|
12154
12253
|
linkSync as linkSync2,
|
|
12155
12254
|
mkdirSync as mkdirSync11,
|
|
12156
|
-
rmSync as
|
|
12255
|
+
rmSync as rmSync9,
|
|
12157
12256
|
statSync as statSync8,
|
|
12158
12257
|
writeFileSync as writeFileSync9
|
|
12159
12258
|
} from "node:fs";
|
|
@@ -12244,7 +12343,7 @@ var LocalPlanV2ArtifactPublisher = class {
|
|
|
12244
12343
|
}
|
|
12245
12344
|
renameWithRetry8(temporaryPath, destinationPath);
|
|
12246
12345
|
} finally {
|
|
12247
|
-
|
|
12346
|
+
rmSync9(stagingDir, { recursive: true, force: true });
|
|
12248
12347
|
}
|
|
12249
12348
|
}
|
|
12250
12349
|
async commitManifest(manifestBytes) {
|
|
@@ -12261,7 +12360,7 @@ var LocalPlanV2ArtifactPublisher = class {
|
|
|
12261
12360
|
}
|
|
12262
12361
|
async abort() {
|
|
12263
12362
|
if (!this.#committed) {
|
|
12264
|
-
|
|
12363
|
+
rmSync9(this.temporaryDir, { recursive: true, force: true });
|
|
12265
12364
|
}
|
|
12266
12365
|
}
|
|
12267
12366
|
};
|
|
@@ -12292,7 +12391,7 @@ function readJsonFile(path, label) {
|
|
|
12292
12391
|
}
|
|
12293
12392
|
function assertSafeRelativePath(path) {
|
|
12294
12393
|
const normalized = path.split(/[\\/]+/);
|
|
12295
|
-
if (path.length === 0 ||
|
|
12394
|
+
if (path.length === 0 || isAbsolute5(path) || normalized.some((part) => part === "" || part === "." || part === "..")) {
|
|
12296
12395
|
throw new PlanV2IntegrityError(`unsafe artifact path: ${JSON.stringify(path)}`);
|
|
12297
12396
|
}
|
|
12298
12397
|
}
|
|
@@ -12306,7 +12405,7 @@ function listFiles(root) {
|
|
|
12306
12405
|
walk(absolutePath);
|
|
12307
12406
|
} else if (entry.isFile()) {
|
|
12308
12407
|
files.push({
|
|
12309
|
-
path:
|
|
12408
|
+
path: relative8(rootResolved, absolutePath).split(sep5).join("/"),
|
|
12310
12409
|
absolutePath
|
|
12311
12410
|
});
|
|
12312
12411
|
} else {
|
|
@@ -12506,7 +12605,7 @@ function collectChunkVideoDependencies(input) {
|
|
|
12506
12605
|
for (let frame = chunk.startFrame; frame < chunk.endFrame; frame++) {
|
|
12507
12606
|
const globalTime = frame * input.fpsDen / input.fpsNum;
|
|
12508
12607
|
for (const [videoId, payload] of input.table.getActiveFramePayloads(globalTime)) {
|
|
12509
|
-
const path = input.deferredSources.get(videoId) ??
|
|
12608
|
+
const path = input.deferredSources.get(videoId) ?? relative8(resolve9(input.executionPlanDir), payload.framePath).split(sep5).join("/");
|
|
12510
12609
|
assertSafeRelativePath(path);
|
|
12511
12610
|
const indexes = mutable.get(path) ?? /* @__PURE__ */ new Set();
|
|
12512
12611
|
indexes.add(chunk.index);
|
|
@@ -12531,7 +12630,7 @@ function writeBlob(sourcePath, destinationPath) {
|
|
|
12531
12630
|
copyFileSync8(sourcePath, temporaryPath);
|
|
12532
12631
|
renameWithRetry9(temporaryPath, destinationPath);
|
|
12533
12632
|
} finally {
|
|
12534
|
-
|
|
12633
|
+
rmSync10(temporaryDir, { recursive: true, force: true });
|
|
12535
12634
|
}
|
|
12536
12635
|
}
|
|
12537
12636
|
function publishBlobFor(absolutePath, digests) {
|
|
@@ -12664,7 +12763,7 @@ function createPlanV2FromExecutionPlan(executionPlanDir, planV2Dir) {
|
|
|
12664
12763
|
renameWithRetry9(tempDir, planV2Dir);
|
|
12665
12764
|
return resultFromManifest(planV2Dir, publication.manifest);
|
|
12666
12765
|
} catch (error) {
|
|
12667
|
-
|
|
12766
|
+
rmSync10(tempDir, { recursive: true, force: true });
|
|
12668
12767
|
throw error;
|
|
12669
12768
|
}
|
|
12670
12769
|
}
|
|
@@ -12729,7 +12828,7 @@ async function planV2WithPublisher(projectDir, config, publisher, options = {})
|
|
|
12729
12828
|
}
|
|
12730
12829
|
throw error;
|
|
12731
12830
|
} finally {
|
|
12732
|
-
|
|
12831
|
+
rmSync10(stagingRoot, { recursive: true, force: true });
|
|
12733
12832
|
}
|
|
12734
12833
|
}
|
|
12735
12834
|
async function planV2(projectDir, config, planV2Dir) {
|
|
@@ -12951,7 +13050,7 @@ function materializePlanV2Target(planV2Dir, target, destinationDir, options = {}
|
|
|
12951
13050
|
);
|
|
12952
13051
|
renameWithRetry9(tempDir, destinationDir);
|
|
12953
13052
|
} catch (error) {
|
|
12954
|
-
|
|
13053
|
+
rmSync10(tempDir, { recursive: true, force: true });
|
|
12955
13054
|
throw error;
|
|
12956
13055
|
}
|
|
12957
13056
|
return {
|
|
@@ -13015,7 +13114,7 @@ function readValidatedPlanV2Materialization(planDir, expectedTarget) {
|
|
|
13015
13114
|
}
|
|
13016
13115
|
|
|
13017
13116
|
// src/services/distributed/planV2Execution.ts
|
|
13018
|
-
import { mkdtempSync, rmSync as
|
|
13117
|
+
import { mkdtempSync, rmSync as rmSync13 } from "node:fs";
|
|
13019
13118
|
import { tmpdir as tmpdir2 } from "node:os";
|
|
13020
13119
|
import { join as join34 } from "node:path";
|
|
13021
13120
|
|
|
@@ -13030,7 +13129,7 @@ import {
|
|
|
13030
13129
|
mkdirSync as mkdirSync13,
|
|
13031
13130
|
readFileSync as readFileSync11,
|
|
13032
13131
|
readdirSync as readdirSync8,
|
|
13033
|
-
rmSync as
|
|
13132
|
+
rmSync as rmSync11,
|
|
13034
13133
|
statSync as statSync10
|
|
13035
13134
|
} from "node:fs";
|
|
13036
13135
|
import { localContainerInputArgs as localContainerInputArgs2 } from "@hyperframes/parsers/ff-binaries";
|
|
@@ -13117,7 +13216,7 @@ async function assemble(planDir, chunkOutputs, audioPath, outputPath, options) {
|
|
|
13117
13216
|
});
|
|
13118
13217
|
} finally {
|
|
13119
13218
|
try {
|
|
13120
|
-
|
|
13219
|
+
rmSync11(workDir, { recursive: true, force: true });
|
|
13121
13220
|
} catch (err) {
|
|
13122
13221
|
log.warn("[assemble] failed to remove work dir", {
|
|
13123
13222
|
workDir,
|
|
@@ -13320,7 +13419,7 @@ function readCfrEncoder(planDir, format) {
|
|
|
13320
13419
|
return encoderJson;
|
|
13321
13420
|
}
|
|
13322
13421
|
function mergePngFrameDirs(chunkPaths, outputPath, totalFrames, audioPath, startTimeMs) {
|
|
13323
|
-
if (existsSync23(outputPath))
|
|
13422
|
+
if (existsSync23(outputPath)) rmSync11(outputPath, { recursive: true, force: true });
|
|
13324
13423
|
mkdirSync13(outputPath, { recursive: true });
|
|
13325
13424
|
let globalIdx = 0;
|
|
13326
13425
|
for (const chunkDir of chunkPaths) {
|
|
@@ -13365,7 +13464,7 @@ function mergePngFrameDirs(chunkPaths, outputPath, totalFrames, audioPath, start
|
|
|
13365
13464
|
|
|
13366
13465
|
// src/services/distributed/renderChunk.ts
|
|
13367
13466
|
import { randomBytes } from "node:crypto";
|
|
13368
|
-
import { existsSync as existsSync24, mkdirSync as mkdirSync14, readFileSync as readFileSync12, readdirSync as readdirSync9, rmSync as
|
|
13467
|
+
import { existsSync as existsSync24, mkdirSync as mkdirSync14, readFileSync as readFileSync12, readdirSync as readdirSync9, rmSync as rmSync12, writeFileSync as writeFileSync11 } from "node:fs";
|
|
13369
13468
|
import { join as join33 } from "node:path";
|
|
13370
13469
|
import {
|
|
13371
13470
|
assertSwiftShader,
|
|
@@ -13672,7 +13771,7 @@ async function renderChunk(planDir, chunkIndex, outputChunkPath, options) {
|
|
|
13672
13771
|
deferredVideos.filter((video) => remoteVideoIds.has(video.videoId))
|
|
13673
13772
|
)
|
|
13674
13773
|
});
|
|
13675
|
-
captureOptions.onStaticDedupActivity = () =>
|
|
13774
|
+
captureOptions.onStaticDedupActivity = () => noteCaptureActivity(job);
|
|
13676
13775
|
const captureFrames = effectiveChunkFrames(framesInChunk, slice.captureCost);
|
|
13677
13776
|
const chunkWorkerCount = resolveChunkCaptureWorkers(
|
|
13678
13777
|
captureFrames,
|
|
@@ -13789,7 +13888,8 @@ async function renderChunk(planDir, chunkIndex, outputChunkPath, options) {
|
|
|
13789
13888
|
outputRoot: videoFramesDir,
|
|
13790
13889
|
cfg,
|
|
13791
13890
|
remoteSources,
|
|
13792
|
-
shownBoxes
|
|
13891
|
+
shownBoxes,
|
|
13892
|
+
onProgress: () => noteCaptureActivity(job)
|
|
13793
13893
|
}).then((frames) => {
|
|
13794
13894
|
videoExtractMs = Date.now() - extractStarted;
|
|
13795
13895
|
return frames;
|
|
@@ -13954,7 +14054,7 @@ async function renderChunk(planDir, chunkIndex, outputChunkPath, options) {
|
|
|
13954
14054
|
return observedChunkCaptureMode(capturePerfs);
|
|
13955
14055
|
},
|
|
13956
14056
|
resetForScreenshotRetry: () => {
|
|
13957
|
-
|
|
14057
|
+
rmSync12(workDir, { recursive: true, force: true, maxRetries: 3, retryDelay: 100 });
|
|
13958
14058
|
boxesMeasured();
|
|
13959
14059
|
mkdirSync14(framesDir, { recursive: true });
|
|
13960
14060
|
capturePerfs.length = 0;
|
|
@@ -14000,8 +14100,8 @@ async function renderChunk(planDir, chunkIndex, outputChunkPath, options) {
|
|
|
14000
14100
|
fps: { num: plan.dimensions.fpsNum, den: plan.dimensions.fpsDen },
|
|
14001
14101
|
timeoutMs: cfg.ffmpegProcessTimeout
|
|
14002
14102
|
});
|
|
14003
|
-
|
|
14004
|
-
|
|
14103
|
+
rmSync12(videoOnlyPath, { force: true });
|
|
14104
|
+
rmSync12(audioScratchPath, { force: true });
|
|
14005
14105
|
}
|
|
14006
14106
|
encodeStageMs = Date.now() - encodeStarted;
|
|
14007
14107
|
} finally {
|
|
@@ -14051,8 +14151,8 @@ async function renderChunk(planDir, chunkIndex, outputChunkPath, options) {
|
|
|
14051
14151
|
writeFileSync11(perfPath, `${JSON.stringify(perfPayload, null, 2)}
|
|
14052
14152
|
`, "utf-8");
|
|
14053
14153
|
try {
|
|
14054
|
-
|
|
14055
|
-
|
|
14154
|
+
rmSync12(workDir, { recursive: true, force: true, maxRetries: 3, retryDelay: 100 });
|
|
14155
|
+
rmSync12(videoFramesDir, { recursive: true, force: true, maxRetries: 3, retryDelay: 100 });
|
|
14056
14156
|
} catch (err) {
|
|
14057
14157
|
log.warn("[renderChunk] failed to remove work dir", {
|
|
14058
14158
|
workDir,
|
|
@@ -14087,7 +14187,7 @@ async function renderChunkV2(planV2Dir, chunkIndex, outputChunkPath, options) {
|
|
|
14087
14187
|
materializePlanV2Target(planV2Dir, { role: "chunk", chunkIndex }, materializedPlanDir);
|
|
14088
14188
|
return await renderChunk(materializedPlanDir, chunkIndex, outputChunkPath, options);
|
|
14089
14189
|
} finally {
|
|
14090
|
-
|
|
14190
|
+
rmSync13(workRoot, { recursive: true, force: true });
|
|
14091
14191
|
}
|
|
14092
14192
|
}
|
|
14093
14193
|
async function assembleV2(planV2Dir, chunkPaths, outputPath, options) {
|
|
@@ -14107,7 +14207,7 @@ async function assembleV2(planV2Dir, chunkPaths, outputPath, options) {
|
|
|
14107
14207
|
options
|
|
14108
14208
|
);
|
|
14109
14209
|
} finally {
|
|
14110
|
-
|
|
14210
|
+
rmSync13(workRoot, { recursive: true, force: true });
|
|
14111
14211
|
}
|
|
14112
14212
|
}
|
|
14113
14213
|
|