@hyperframes/producer 0.9.88 → 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 +169 -72
- package/dist/hyperframe.manifest.json +1 -1
- package/dist/hyperframe.runtime.iife.js +69 -69
- package/dist/index.js +272 -112
- package/dist/public-server.js +228 -68
- 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/heifImagePrep.d.ts +2 -0
- 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";
|
|
@@ -2455,7 +2455,7 @@ function requireOutputDimensions(expected, width, height) {
|
|
|
2455
2455
|
|
|
2456
2456
|
// src/services/render/stages/compileStage.ts
|
|
2457
2457
|
import { existsSync as existsSync9, writeFileSync as writeFileSync3 } from "node:fs";
|
|
2458
|
-
import { join as join11, relative as
|
|
2458
|
+
import { join as join11, relative as relative4 } from "node:path";
|
|
2459
2459
|
import { privateCacheRoot } from "@hyperframes/engine";
|
|
2460
2460
|
import { suggestMatchingPreset } from "@hyperframes/core";
|
|
2461
2461
|
import { extractStandaloneEntryFromIndex, isTemplateEntry } from "@hyperframes/core/compiler";
|
|
@@ -2463,8 +2463,8 @@ import { readTextFile as readTextFile2 } from "@hyperframes/parsers/asset-resolu
|
|
|
2463
2463
|
import { assertCompositionFileSize as assertCompositionFileSize2 } from "@hyperframes/core/compiler";
|
|
2464
2464
|
|
|
2465
2465
|
// src/services/compileInWorker.ts
|
|
2466
|
-
import { existsSync as existsSync8 } from "node:fs";
|
|
2467
|
-
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";
|
|
2468
2468
|
import { fileURLToPath as fileURLToPath3 } from "node:url";
|
|
2469
2469
|
import { Worker } from "node:worker_threads";
|
|
2470
2470
|
|
|
@@ -2770,7 +2770,7 @@ import {
|
|
|
2770
2770
|
} from "@hyperframes/core/fonts/embed";
|
|
2771
2771
|
|
|
2772
2772
|
// src/services/animatedGifPrep.ts
|
|
2773
|
-
import { createHash as createHash3 } from "node:crypto";
|
|
2773
|
+
import { createHash as createHash3, randomUUID } from "node:crypto";
|
|
2774
2774
|
import { copyFileSync as copyFileSync2, existsSync as existsSync5, mkdirSync as mkdirSync2, readFileSync as readFileSync3, rmSync as rmSync2, statSync as statSync3 } from "node:fs";
|
|
2775
2775
|
import { dirname as dirname4, isAbsolute as isAbsolute2, join as join6, resolve as resolve4 } from "node:path";
|
|
2776
2776
|
import { parseHTML as parseHTML3 } from "linkedom";
|
|
@@ -2845,6 +2845,8 @@ function resolveLoop(metadata, override) {
|
|
|
2845
2845
|
}
|
|
2846
2846
|
var MAX_LOOP_ITERATIONS = 1e3;
|
|
2847
2847
|
var MAX_PAD_SECONDS = 3600;
|
|
2848
|
+
var FFMPEG_SELF_CPU_SECONDS_CAP = 3600;
|
|
2849
|
+
var FFMPEG_SELF_OUTPUT_BYTES_CAP = 1024 * 1024 * 1024;
|
|
2848
2850
|
function resolveCompositionDurationSeconds(document2) {
|
|
2849
2851
|
let max = null;
|
|
2850
2852
|
for (const el of Array.from(document2.querySelectorAll("[data-composition-id][data-duration]"))) {
|
|
@@ -2887,7 +2889,13 @@ function resolvePreparedPlayback(metadata, loopOverride, windowSeconds) {
|
|
|
2887
2889
|
return { loopIterations, padSeconds: Math.round(padSeconds * 1e3) / 1e3 };
|
|
2888
2890
|
}
|
|
2889
2891
|
function buildAnimatedGifTranscodeArgs(input) {
|
|
2890
|
-
const args = [
|
|
2892
|
+
const args = [
|
|
2893
|
+
"-hide_banner",
|
|
2894
|
+
"-loglevel",
|
|
2895
|
+
"error",
|
|
2896
|
+
"-timelimit",
|
|
2897
|
+
String(FFMPEG_SELF_CPU_SECONDS_CAP)
|
|
2898
|
+
];
|
|
2891
2899
|
if (input.loopIterations > 1) {
|
|
2892
2900
|
args.push("-stream_loop", String(input.loopIterations - 1));
|
|
2893
2901
|
}
|
|
@@ -2915,6 +2923,8 @@ function buildAnimatedGifTranscodeArgs(input) {
|
|
|
2915
2923
|
...input.padSeconds && input.padSeconds > 0 ? ["-vf", `tpad=stop_mode=clone:stop_duration=${input.padSeconds}`] : [],
|
|
2916
2924
|
// Explicit muxer: the transcode writes to a `.tmp-<pid>-<ts>` path whose
|
|
2917
2925
|
// extension ffmpeg cannot infer the container from.
|
|
2926
|
+
"-fs",
|
|
2927
|
+
String(FFMPEG_SELF_OUTPUT_BYTES_CAP),
|
|
2918
2928
|
"-f",
|
|
2919
2929
|
"webm",
|
|
2920
2930
|
"-y",
|
|
@@ -2922,10 +2932,16 @@ function buildAnimatedGifTranscodeArgs(input) {
|
|
|
2922
2932
|
);
|
|
2923
2933
|
return args;
|
|
2924
2934
|
}
|
|
2935
|
+
function abortError() {
|
|
2936
|
+
const error = new Error("Aborted");
|
|
2937
|
+
error.name = "AbortError";
|
|
2938
|
+
return error;
|
|
2939
|
+
}
|
|
2925
2940
|
async function runAnimatedGifTranscode(request) {
|
|
2926
2941
|
const timeout = request.timeoutMs ?? 3e5;
|
|
2927
|
-
const result = await runFfmpeg2(request.args, { timeout });
|
|
2942
|
+
const result = await runFfmpeg2(request.args, { timeout, signal: request.signal });
|
|
2928
2943
|
if (result.success) return;
|
|
2944
|
+
if (request.signal?.aborted) throw abortError();
|
|
2929
2945
|
if (result.failureReason === "external_interruption") {
|
|
2930
2946
|
throw encoderFailureError("Animated GIF transcode failed", {
|
|
2931
2947
|
error: `exit ${result.exitCode}: ${result.stderr.slice(-500)}`,
|
|
@@ -2945,7 +2961,7 @@ async function ensurePreparedWebm(input) {
|
|
|
2945
2961
|
mkdirSync2(dirname4(input.outputPath), { recursive: true });
|
|
2946
2962
|
}
|
|
2947
2963
|
if (!isUsableFile(input.cachePath)) {
|
|
2948
|
-
const tmpPath = `${input.cachePath}.tmp-${process.pid}-${
|
|
2964
|
+
const tmpPath = `${input.cachePath}.tmp-${process.pid}-${randomUUID()}`;
|
|
2949
2965
|
const args = buildAnimatedGifTranscodeArgs({
|
|
2950
2966
|
inputPath: input.sourcePath,
|
|
2951
2967
|
outputPath: tmpPath,
|
|
@@ -2958,11 +2974,15 @@ async function ensurePreparedWebm(input) {
|
|
|
2958
2974
|
inputPath: input.sourcePath,
|
|
2959
2975
|
outputPath: tmpPath,
|
|
2960
2976
|
args,
|
|
2961
|
-
timeoutMs: input.timeoutMs
|
|
2977
|
+
timeoutMs: input.timeoutMs,
|
|
2978
|
+
signal: input.signal
|
|
2962
2979
|
});
|
|
2963
2980
|
if (!isUsableFile(tmpPath)) {
|
|
2964
2981
|
throw new Error("Animated GIF transcode produced an empty output");
|
|
2965
2982
|
}
|
|
2983
|
+
if (statSync3(tmpPath).size >= FFMPEG_SELF_OUTPUT_BYTES_CAP) {
|
|
2984
|
+
throw new Error("Animated GIF transcode reached its output size limit");
|
|
2985
|
+
}
|
|
2966
2986
|
if (!isUsableFile(input.cachePath)) {
|
|
2967
2987
|
renameWithRetry2(tmpPath, input.cachePath);
|
|
2968
2988
|
} else {
|
|
@@ -3062,6 +3082,7 @@ async function prepareAnimatedGifInputs(html, options) {
|
|
|
3062
3082
|
loopIterations,
|
|
3063
3083
|
padSeconds,
|
|
3064
3084
|
timeoutMs: options.timeoutMs,
|
|
3085
|
+
signal: options.signal,
|
|
3065
3086
|
transcode: options.transcode
|
|
3066
3087
|
});
|
|
3067
3088
|
const id = ensureElementId(img, document2, i);
|
|
@@ -3086,7 +3107,7 @@ async function prepareAnimatedGifInputs(html, options) {
|
|
|
3086
3107
|
}
|
|
3087
3108
|
|
|
3088
3109
|
// src/services/heifImagePrep.ts
|
|
3089
|
-
import { createHash as createHash4 } from "node:crypto";
|
|
3110
|
+
import { createHash as createHash4, randomUUID as randomUUID2 } from "node:crypto";
|
|
3090
3111
|
import {
|
|
3091
3112
|
closeSync as closeSync2,
|
|
3092
3113
|
copyFileSync as copyFileSync3,
|
|
@@ -3232,6 +3253,13 @@ var HeifToolUnavailableError = class extends Error {
|
|
|
3232
3253
|
this.name = "HeifToolUnavailableError";
|
|
3233
3254
|
}
|
|
3234
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;
|
|
3235
3263
|
var TOOL_FAILURE_RE = /(?:ffmpeg|ffprobe) not found|ENOENT|Option not found|Unrecognized option|Unknown decoder|Decoder \S+ not found/i;
|
|
3236
3264
|
function isHeifBytes(head) {
|
|
3237
3265
|
const bytes = Buffer.from(head.buffer, head.byteOffset, head.byteLength);
|
|
@@ -3299,6 +3327,8 @@ async function convertHeifToJpeg(request) {
|
|
|
3299
3327
|
"-hide_banner",
|
|
3300
3328
|
"-loglevel",
|
|
3301
3329
|
"error",
|
|
3330
|
+
"-timelimit",
|
|
3331
|
+
String(FFMPEG_SELF_CPU_SECONDS_CAP2),
|
|
3302
3332
|
...urlInputArgs3(request.inputPath),
|
|
3303
3333
|
"-i",
|
|
3304
3334
|
request.inputPath,
|
|
@@ -3307,14 +3337,17 @@ async function convertHeifToJpeg(request) {
|
|
|
3307
3337
|
"1",
|
|
3308
3338
|
"-q:v",
|
|
3309
3339
|
"2",
|
|
3340
|
+
"-fs",
|
|
3341
|
+
String(FFMPEG_SELF_OUTPUT_BYTES_CAP2),
|
|
3310
3342
|
"-f",
|
|
3311
3343
|
"mjpeg",
|
|
3312
3344
|
"-y",
|
|
3313
3345
|
request.outputPath
|
|
3314
3346
|
],
|
|
3315
|
-
{ timeout: request.timeoutMs ?? DEFAULT_TIMEOUT_MS }
|
|
3347
|
+
{ timeout: request.timeoutMs ?? DEFAULT_TIMEOUT_MS, signal: request.signal }
|
|
3316
3348
|
);
|
|
3317
3349
|
if (!result.success) {
|
|
3350
|
+
if (request.signal?.aborted) throw abortError2();
|
|
3318
3351
|
throw result.error ?? new Error(`ffmpeg exited ${result.exitCode}: ${result.stderr.slice(-300)}`);
|
|
3319
3352
|
}
|
|
3320
3353
|
const out = (await probeJson(request.outputPath, false)).streams?.[0];
|
|
@@ -3348,7 +3381,7 @@ async function ensurePreparedJpeg(source, cachePath, outputPath, options) {
|
|
|
3348
3381
|
mkdirSync3(dirname5(cachePath), { recursive: true });
|
|
3349
3382
|
mkdirSync3(dirname5(outputPath), { recursive: true });
|
|
3350
3383
|
if (!isUsableFile2(cachePath)) {
|
|
3351
|
-
const tmpPath = `${cachePath}.tmp-${process.pid}-${
|
|
3384
|
+
const tmpPath = `${cachePath}.tmp-${process.pid}-${randomUUID2()}`;
|
|
3352
3385
|
const inlinePath = `${tmpPath}.heic`;
|
|
3353
3386
|
const inputPath = source.path ?? inlinePath;
|
|
3354
3387
|
try {
|
|
@@ -3356,9 +3389,13 @@ async function ensurePreparedJpeg(source, cachePath, outputPath, options) {
|
|
|
3356
3389
|
await (options.transcode ?? convertHeifToJpeg)({
|
|
3357
3390
|
inputPath,
|
|
3358
3391
|
outputPath: tmpPath,
|
|
3359
|
-
timeoutMs: options.timeoutMs
|
|
3392
|
+
timeoutMs: options.timeoutMs,
|
|
3393
|
+
signal: options.signal
|
|
3360
3394
|
});
|
|
3361
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
|
+
}
|
|
3362
3399
|
renameWithRetry3(tmpPath, cachePath);
|
|
3363
3400
|
} catch (error) {
|
|
3364
3401
|
const reason = error instanceof Error ? error.message : String(error);
|
|
@@ -3429,6 +3466,7 @@ import {
|
|
|
3429
3466
|
isNotImagePayload,
|
|
3430
3467
|
isNotMediaPayload,
|
|
3431
3468
|
isPrivateUnderAssetRoots as isPrivateUnderAssetRoots2,
|
|
3469
|
+
isStructurallyIncompletePngError,
|
|
3432
3470
|
playlistLeavesItsFolder,
|
|
3433
3471
|
NotMediaPayloadError,
|
|
3434
3472
|
probeMediaProfile,
|
|
@@ -3507,6 +3545,13 @@ async function notMediaReferences(path, references) {
|
|
|
3507
3545
|
if (images.length > 0 && await isNotImagePayload(path)) return images;
|
|
3508
3546
|
return await playlistLeavesItsFolder(path) ? references : [];
|
|
3509
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
|
+
}
|
|
3510
3555
|
async function preflightCompositionAssetMediaTypes(input) {
|
|
3511
3556
|
const references = [
|
|
3512
3557
|
...input.composition.videos.map((asset) => ({
|
|
@@ -3552,6 +3597,8 @@ async function preflightCompositionAssetMediaTypes(input) {
|
|
|
3552
3597
|
profile = await probeMediaProfile(resolvedPath, { signal: input.signal });
|
|
3553
3598
|
} catch (error) {
|
|
3554
3599
|
if (input.signal?.aborted) throw input.signal.reason ?? error;
|
|
3600
|
+
if (isStructurallyIncompletePngError(error))
|
|
3601
|
+
mismatches.push(...pngCutShort(pathReferences));
|
|
3555
3602
|
return;
|
|
3556
3603
|
}
|
|
3557
3604
|
for (const reference of pathReferences) {
|
|
@@ -4895,8 +4942,9 @@ async function inlineExternalFontStylesheets(html, budget = new CompositionExpan
|
|
|
4895
4942
|
const css = await fetchExternalStylesheetCss(href, fetchSignal);
|
|
4896
4943
|
const fontFaceBlocks = css ? extractFontFaceBlocks(css) : [];
|
|
4897
4944
|
if (fontFaceBlocks.length === 0) return;
|
|
4945
|
+
const fontCssWithLtAsCssEscape = fontFaceBlocks.join("\n").replace(/</g, "\\3c ");
|
|
4898
4946
|
const inlineStyle = `<style>/* Inlined external font stylesheet */
|
|
4899
|
-
${
|
|
4947
|
+
${fontCssWithLtAsCssEscape}
|
|
4900
4948
|
</style>`;
|
|
4901
4949
|
try {
|
|
4902
4950
|
budget.chargeGenerated(REMOTE_STYLESHEETS, inlineStyle.length);
|
|
@@ -5309,6 +5357,7 @@ async function compileWithAssets(projectDir, htmlPath, downloadDir, options, ass
|
|
|
5309
5357
|
cacheDir: options.animatedGifCacheDir,
|
|
5310
5358
|
sourceAssets: remoteImageAssets,
|
|
5311
5359
|
timeoutMs: options.ffmpegProcessTimeout,
|
|
5360
|
+
signal: options.abortSignal,
|
|
5312
5361
|
allowOutsideFiles: assetRoot === void 0
|
|
5313
5362
|
});
|
|
5314
5363
|
if (preparedHeifImages.length > 0) {
|
|
@@ -5325,6 +5374,7 @@ async function compileWithAssets(projectDir, htmlPath, downloadDir, options, ass
|
|
|
5325
5374
|
cacheDir: options.animatedGifCacheDir,
|
|
5326
5375
|
sourceAssets: gifSourceAssets,
|
|
5327
5376
|
timeoutMs: options.ffmpegProcessTimeout,
|
|
5377
|
+
signal: options.abortSignal,
|
|
5328
5378
|
allowOutsideFiles: assetRoot === void 0
|
|
5329
5379
|
});
|
|
5330
5380
|
if (preparedGifs.length > 0) {
|
|
@@ -5803,6 +5853,24 @@ function compileTimeoutMs() {
|
|
|
5803
5853
|
return Number.isInteger(fromEnv) && fromEnv > 0 ? Math.min(fromEnv, MAX_TIMER_MS) : DEFAULT_COMPILE_TIMEOUT_MS;
|
|
5804
5854
|
}
|
|
5805
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
|
+
}
|
|
5806
5874
|
function resolveCompileWorkerEntry(explicit, log) {
|
|
5807
5875
|
if (explicit) return explicit;
|
|
5808
5876
|
const fromEnv = process.env.HF_COMPILE_WORKER_ENTRY;
|
|
@@ -5836,6 +5904,26 @@ async function compileForRenderInWorker(projectDir, htmlPath, downloadDir, optio
|
|
|
5836
5904
|
const thread = new Worker(entry, {
|
|
5837
5905
|
workerData: { projectDir, htmlPath, downloadDir, options: cloneable }
|
|
5838
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
|
+
};
|
|
5839
5927
|
let settled = false;
|
|
5840
5928
|
const settle = (finish) => {
|
|
5841
5929
|
if (settled) return;
|
|
@@ -5846,7 +5934,7 @@ async function compileForRenderInWorker(projectDir, htmlPath, downloadDir, optio
|
|
|
5846
5934
|
};
|
|
5847
5935
|
const stop = () => {
|
|
5848
5936
|
thread.postMessage({ type: "abort" });
|
|
5849
|
-
setTimeout(
|
|
5937
|
+
setTimeout(endThread, TERMINATE_GRACE_MS).unref();
|
|
5850
5938
|
};
|
|
5851
5939
|
const timer = setTimeout(() => {
|
|
5852
5940
|
stop();
|
|
@@ -5859,7 +5947,7 @@ async function compileForRenderInWorker(projectDir, htmlPath, downloadDir, optio
|
|
|
5859
5947
|
abortSignal?.addEventListener("abort", onAbort, { once: true });
|
|
5860
5948
|
const retire = (graceMs) => {
|
|
5861
5949
|
thread.unref();
|
|
5862
|
-
setTimeout(
|
|
5950
|
+
setTimeout(endThread, graceMs).unref();
|
|
5863
5951
|
};
|
|
5864
5952
|
thread.on(
|
|
5865
5953
|
"message",
|
|
@@ -5878,13 +5966,22 @@ async function compileForRenderInWorker(projectDir, htmlPath, downloadDir, optio
|
|
|
5878
5966
|
}
|
|
5879
5967
|
}
|
|
5880
5968
|
);
|
|
5881
|
-
thread.on("error", (error) => settle(() => reject(error)));
|
|
5882
5969
|
thread.on(
|
|
5883
|
-
"
|
|
5884
|
-
(
|
|
5885
|
-
|
|
5886
|
-
|
|
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
|
+
}
|
|
5887
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
|
+
});
|
|
5888
5985
|
});
|
|
5889
5986
|
}
|
|
5890
5987
|
|
|
@@ -5914,10 +6011,10 @@ function resolveEntryHtmlPath(input) {
|
|
|
5914
6011
|
const readEntry = (path) => {
|
|
5915
6012
|
if (escapesAssetRoot(path, input.assetRoot)) {
|
|
5916
6013
|
throw new Error(
|
|
5917
|
-
`Entry file "${
|
|
6014
|
+
`Entry file "${relative4(projectDir, path)}" leads outside the project folder`
|
|
5918
6015
|
);
|
|
5919
6016
|
}
|
|
5920
|
-
assertCompositionFileSize2(path,
|
|
6017
|
+
assertCompositionFileSize2(path, relative4(projectDir, path));
|
|
5921
6018
|
return readTextFile2(path);
|
|
5922
6019
|
};
|
|
5923
6020
|
const htmlPath = join11(projectDir, entryFile);
|
|
@@ -8674,7 +8771,7 @@ import {
|
|
|
8674
8771
|
mkdirSync as mkdirSync5,
|
|
8675
8772
|
readdirSync as readdirSync2,
|
|
8676
8773
|
readFileSync as readFileSync6,
|
|
8677
|
-
rmSync as
|
|
8774
|
+
rmSync as rmSync5,
|
|
8678
8775
|
statSync as statSync6,
|
|
8679
8776
|
writeFileSync as writeFileSync4
|
|
8680
8777
|
} from "node:fs";
|
|
@@ -8813,7 +8910,7 @@ async function encodeGifFromDir(framesDir, framePattern, outputPath, input) {
|
|
|
8813
8910
|
fileSize
|
|
8814
8911
|
};
|
|
8815
8912
|
} finally {
|
|
8816
|
-
|
|
8913
|
+
rmSync5(input.palettePath, { force: true });
|
|
8817
8914
|
}
|
|
8818
8915
|
}
|
|
8819
8916
|
function startEncodeProgress(job, stage, onProgress) {
|
|
@@ -9429,7 +9526,7 @@ async function executeDiskCaptureWithAdaptiveRetry(options) {
|
|
|
9429
9526
|
function createRenderJob(config) {
|
|
9430
9527
|
return {
|
|
9431
9528
|
...referenceBackgroundResult(void 0),
|
|
9432
|
-
id:
|
|
9529
|
+
id: randomUUID3(),
|
|
9433
9530
|
config: {
|
|
9434
9531
|
...config,
|
|
9435
9532
|
fps: toFps2(config.fps),
|
|
@@ -10120,7 +10217,7 @@ async function readPlanReferenceBackground(input) {
|
|
|
10120
10217
|
|
|
10121
10218
|
// src/services/render/stages/freezePlan.ts
|
|
10122
10219
|
import { existsSync as existsSync18, mkdirSync as mkdirSync7, readFileSync as readFileSync8, readdirSync as readdirSync5, writeFileSync as writeFileSync6 } from "node:fs";
|
|
10123
|
-
import { join as join24, relative as
|
|
10220
|
+
import { join as join24, relative as relative5, resolve as resolve8 } from "node:path";
|
|
10124
10221
|
import {
|
|
10125
10222
|
REFERENCE_BACKGROUND_FIELD,
|
|
10126
10223
|
referenceBackgroundResult as referenceBackgroundResult3
|
|
@@ -10343,7 +10440,7 @@ function listPlanFiles(planDir) {
|
|
|
10343
10440
|
walk(full);
|
|
10344
10441
|
} else if (entry.isFile()) {
|
|
10345
10442
|
results.push({
|
|
10346
|
-
planRelativePath:
|
|
10443
|
+
planRelativePath: relative5(rootResolved, full).split(/[\\/]+/).join("/"),
|
|
10347
10444
|
absolutePath: full
|
|
10348
10445
|
});
|
|
10349
10446
|
}
|
|
@@ -10508,7 +10605,7 @@ import { join as join26 } from "node:path";
|
|
|
10508
10605
|
import { appendRenderProvenanceArgs, describeFfmpegFailure as describeFfmpegFailure4, runFfmpeg as runFfmpeg7 } from "@hyperframes/engine";
|
|
10509
10606
|
|
|
10510
10607
|
// src/services/distributed/mp4Stitch.ts
|
|
10511
|
-
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";
|
|
10512
10609
|
import { open } from "node:fs/promises";
|
|
10513
10610
|
import { renameWithRetry as renameWithRetry6 } from "@hyperframes/engine";
|
|
10514
10611
|
import { basename as basename5, dirname as dirname14, join as join25 } from "node:path";
|
|
@@ -10887,7 +10984,7 @@ async function writeStitchedMp4(chunkPaths, outputPath, audioPath) {
|
|
|
10887
10984
|
renameWithRetry6(join25(workDir, "out.mp4"), outputPath);
|
|
10888
10985
|
} finally {
|
|
10889
10986
|
out.destroy();
|
|
10890
|
-
|
|
10987
|
+
rmSync7(workDir, { recursive: true, force: true });
|
|
10891
10988
|
}
|
|
10892
10989
|
}
|
|
10893
10990
|
|
|
@@ -11065,7 +11162,7 @@ async function muxChunkWithAudio(input) {
|
|
|
11065
11162
|
// src/services/distributed/planSize.ts
|
|
11066
11163
|
import { createHash as createHash8 } from "node:crypto";
|
|
11067
11164
|
import { lstatSync, readdirSync as readdirSync6 } from "node:fs";
|
|
11068
|
-
import { extname as extname3, join as join27, relative as
|
|
11165
|
+
import { extname as extname3, join as join27, relative as relative6 } from "node:path";
|
|
11069
11166
|
var MAX_TOP_COMPONENTS = 10;
|
|
11070
11167
|
var SOURCE_MEDIA_EXTENSIONS = /* @__PURE__ */ new Set([
|
|
11071
11168
|
".aac",
|
|
@@ -11154,7 +11251,7 @@ function recordFile(result, components, rootDir, rootKind, filePath) {
|
|
|
11154
11251
|
} catch {
|
|
11155
11252
|
return;
|
|
11156
11253
|
}
|
|
11157
|
-
const rel =
|
|
11254
|
+
const rel = relative6(rootDir, filePath);
|
|
11158
11255
|
const segments = rel.split(/[\\/]+/).filter(Boolean);
|
|
11159
11256
|
const classified = classifyFile(segments, rootKind);
|
|
11160
11257
|
result.totalBytes += sizeBytes;
|
|
@@ -11403,7 +11500,7 @@ var FREEZE_OWNED_PLAN_FILES = [
|
|
|
11403
11500
|
];
|
|
11404
11501
|
function removeFreezeOwnedPlanFiles(planDir) {
|
|
11405
11502
|
for (const relativePath of FREEZE_OWNED_PLAN_FILES) {
|
|
11406
|
-
|
|
11503
|
+
rmSync8(join28(planDir, relativePath), { force: true });
|
|
11407
11504
|
}
|
|
11408
11505
|
}
|
|
11409
11506
|
function buildChunkSlices(totalFrames, chunkCount, effectiveChunkSize) {
|
|
@@ -11542,10 +11639,10 @@ function resolveDistributedEngineConfig(config) {
|
|
|
11542
11639
|
};
|
|
11543
11640
|
}
|
|
11544
11641
|
function leavesRoot(rel) {
|
|
11545
|
-
return rel === ".." || rel.startsWith(`..${sep4}`) ||
|
|
11642
|
+
return rel === ".." || rel.startsWith(`..${sep4}`) || isAbsolute4(rel);
|
|
11546
11643
|
}
|
|
11547
11644
|
function pathInside(root, path) {
|
|
11548
|
-
const rel =
|
|
11645
|
+
const rel = relative7(root, path);
|
|
11549
11646
|
return rel === "" || leavesRoot(rel) ? null : rel;
|
|
11550
11647
|
}
|
|
11551
11648
|
function stableSourcePath(roots, srcPath) {
|
|
@@ -11632,7 +11729,7 @@ async function compilePlanComposition(projectDir, config, planDir, options) {
|
|
|
11632
11729
|
throw new Error(`[plan] entry file not found: ${htmlPath}`);
|
|
11633
11730
|
}
|
|
11634
11731
|
const workDir = join28(planDir, ".plan-work");
|
|
11635
|
-
|
|
11732
|
+
rmSync8(workDir, { recursive: true, force: true });
|
|
11636
11733
|
mkdirSync10(workDir, { recursive: true });
|
|
11637
11734
|
const compiledDir = join28(workDir, "compiled");
|
|
11638
11735
|
mkdirSync10(compiledDir, { recursive: true });
|
|
@@ -11641,7 +11738,7 @@ async function compilePlanComposition(projectDir, config, planDir, options) {
|
|
|
11641
11738
|
recursive: true,
|
|
11642
11739
|
dereference: true,
|
|
11643
11740
|
filter: (src) => {
|
|
11644
|
-
const rel =
|
|
11741
|
+
const rel = relative7(projectDir, src);
|
|
11645
11742
|
if (rel === "") return true;
|
|
11646
11743
|
if (leavesRoot(rel)) return false;
|
|
11647
11744
|
if (job.config.allowOutsideProjectAssets) {
|
|
@@ -11864,15 +11961,15 @@ async function buildLocalExecutionPlan(projectDir, config, executionPlanDir, opt
|
|
|
11864
11961
|
logPlanStage(log, "extract", stageStarted);
|
|
11865
11962
|
const stagedVideoFrames = join28(compiledDir, "__hyperframes_video_frames");
|
|
11866
11963
|
const videoFramesDst = join28(planDir, "video-frames");
|
|
11867
|
-
if (existsSync20(videoFramesDst))
|
|
11964
|
+
if (existsSync20(videoFramesDst)) rmSync8(videoFramesDst, { recursive: true, force: true });
|
|
11868
11965
|
const videoSourcesDir = join28(planDir, "video-sources");
|
|
11869
|
-
|
|
11966
|
+
rmSync8(videoSourcesDir, { recursive: true, force: true });
|
|
11870
11967
|
if (existsSync20(stagedVideoFrames)) {
|
|
11871
11968
|
renameWithRetry7(stagedVideoFrames, videoFramesDst);
|
|
11872
11969
|
} else {
|
|
11873
11970
|
mkdirSync10(videoFramesDst, { recursive: true });
|
|
11874
11971
|
}
|
|
11875
|
-
if (existsSync20(finalCompiledDir))
|
|
11972
|
+
if (existsSync20(finalCompiledDir)) rmSync8(finalCompiledDir, { recursive: true, force: true });
|
|
11876
11973
|
renameWithRetry7(compiledDir, finalCompiledDir);
|
|
11877
11974
|
const shipVideoSource = createVideoSourceShipper({
|
|
11878
11975
|
planDir,
|
|
@@ -12042,7 +12139,7 @@ async function buildLocalExecutionPlan(projectDir, config, executionPlanDir, opt
|
|
|
12042
12139
|
format: config.format
|
|
12043
12140
|
};
|
|
12044
12141
|
try {
|
|
12045
|
-
|
|
12142
|
+
rmSync8(workDir, { recursive: true, force: true });
|
|
12046
12143
|
} catch (err) {
|
|
12047
12144
|
log.warn("[plan] failed to remove temp work dir", {
|
|
12048
12145
|
workDir,
|
|
@@ -12120,7 +12217,7 @@ async function buildPlanAudio(projectDir, config, workRoot, outputPath, options
|
|
|
12120
12217
|
renameWithRetry7(mixed.audioOutputPath, outputPath);
|
|
12121
12218
|
return { hasAudio: true };
|
|
12122
12219
|
} finally {
|
|
12123
|
-
|
|
12220
|
+
rmSync8(c.workDir, { recursive: true, force: true });
|
|
12124
12221
|
}
|
|
12125
12222
|
}
|
|
12126
12223
|
|
|
@@ -12136,12 +12233,12 @@ import {
|
|
|
12136
12233
|
mkdirSync as mkdirSync12,
|
|
12137
12234
|
readFileSync as readFileSync10,
|
|
12138
12235
|
readdirSync as readdirSync7,
|
|
12139
|
-
rmSync as
|
|
12236
|
+
rmSync as rmSync10,
|
|
12140
12237
|
statSync as statSync9,
|
|
12141
12238
|
writeFileSync as writeFileSync10
|
|
12142
12239
|
} from "node:fs";
|
|
12143
12240
|
import { tmpdir } from "node:os";
|
|
12144
|
-
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";
|
|
12145
12242
|
import { DISTRIBUTED_FPS, isDistributedFps } from "@hyperframes/core";
|
|
12146
12243
|
import {
|
|
12147
12244
|
createFrameLookupTable as createFrameLookupTable5,
|
|
@@ -12155,7 +12252,7 @@ import {
|
|
|
12155
12252
|
existsSync as existsSync21,
|
|
12156
12253
|
linkSync as linkSync2,
|
|
12157
12254
|
mkdirSync as mkdirSync11,
|
|
12158
|
-
rmSync as
|
|
12255
|
+
rmSync as rmSync9,
|
|
12159
12256
|
statSync as statSync8,
|
|
12160
12257
|
writeFileSync as writeFileSync9
|
|
12161
12258
|
} from "node:fs";
|
|
@@ -12246,7 +12343,7 @@ var LocalPlanV2ArtifactPublisher = class {
|
|
|
12246
12343
|
}
|
|
12247
12344
|
renameWithRetry8(temporaryPath, destinationPath);
|
|
12248
12345
|
} finally {
|
|
12249
|
-
|
|
12346
|
+
rmSync9(stagingDir, { recursive: true, force: true });
|
|
12250
12347
|
}
|
|
12251
12348
|
}
|
|
12252
12349
|
async commitManifest(manifestBytes) {
|
|
@@ -12263,7 +12360,7 @@ var LocalPlanV2ArtifactPublisher = class {
|
|
|
12263
12360
|
}
|
|
12264
12361
|
async abort() {
|
|
12265
12362
|
if (!this.#committed) {
|
|
12266
|
-
|
|
12363
|
+
rmSync9(this.temporaryDir, { recursive: true, force: true });
|
|
12267
12364
|
}
|
|
12268
12365
|
}
|
|
12269
12366
|
};
|
|
@@ -12294,7 +12391,7 @@ function readJsonFile(path, label) {
|
|
|
12294
12391
|
}
|
|
12295
12392
|
function assertSafeRelativePath(path) {
|
|
12296
12393
|
const normalized = path.split(/[\\/]+/);
|
|
12297
|
-
if (path.length === 0 ||
|
|
12394
|
+
if (path.length === 0 || isAbsolute5(path) || normalized.some((part) => part === "" || part === "." || part === "..")) {
|
|
12298
12395
|
throw new PlanV2IntegrityError(`unsafe artifact path: ${JSON.stringify(path)}`);
|
|
12299
12396
|
}
|
|
12300
12397
|
}
|
|
@@ -12308,7 +12405,7 @@ function listFiles(root) {
|
|
|
12308
12405
|
walk(absolutePath);
|
|
12309
12406
|
} else if (entry.isFile()) {
|
|
12310
12407
|
files.push({
|
|
12311
|
-
path:
|
|
12408
|
+
path: relative8(rootResolved, absolutePath).split(sep5).join("/"),
|
|
12312
12409
|
absolutePath
|
|
12313
12410
|
});
|
|
12314
12411
|
} else {
|
|
@@ -12508,7 +12605,7 @@ function collectChunkVideoDependencies(input) {
|
|
|
12508
12605
|
for (let frame = chunk.startFrame; frame < chunk.endFrame; frame++) {
|
|
12509
12606
|
const globalTime = frame * input.fpsDen / input.fpsNum;
|
|
12510
12607
|
for (const [videoId, payload] of input.table.getActiveFramePayloads(globalTime)) {
|
|
12511
|
-
const path = input.deferredSources.get(videoId) ??
|
|
12608
|
+
const path = input.deferredSources.get(videoId) ?? relative8(resolve9(input.executionPlanDir), payload.framePath).split(sep5).join("/");
|
|
12512
12609
|
assertSafeRelativePath(path);
|
|
12513
12610
|
const indexes = mutable.get(path) ?? /* @__PURE__ */ new Set();
|
|
12514
12611
|
indexes.add(chunk.index);
|
|
@@ -12533,7 +12630,7 @@ function writeBlob(sourcePath, destinationPath) {
|
|
|
12533
12630
|
copyFileSync8(sourcePath, temporaryPath);
|
|
12534
12631
|
renameWithRetry9(temporaryPath, destinationPath);
|
|
12535
12632
|
} finally {
|
|
12536
|
-
|
|
12633
|
+
rmSync10(temporaryDir, { recursive: true, force: true });
|
|
12537
12634
|
}
|
|
12538
12635
|
}
|
|
12539
12636
|
function publishBlobFor(absolutePath, digests) {
|
|
@@ -12666,7 +12763,7 @@ function createPlanV2FromExecutionPlan(executionPlanDir, planV2Dir) {
|
|
|
12666
12763
|
renameWithRetry9(tempDir, planV2Dir);
|
|
12667
12764
|
return resultFromManifest(planV2Dir, publication.manifest);
|
|
12668
12765
|
} catch (error) {
|
|
12669
|
-
|
|
12766
|
+
rmSync10(tempDir, { recursive: true, force: true });
|
|
12670
12767
|
throw error;
|
|
12671
12768
|
}
|
|
12672
12769
|
}
|
|
@@ -12731,7 +12828,7 @@ async function planV2WithPublisher(projectDir, config, publisher, options = {})
|
|
|
12731
12828
|
}
|
|
12732
12829
|
throw error;
|
|
12733
12830
|
} finally {
|
|
12734
|
-
|
|
12831
|
+
rmSync10(stagingRoot, { recursive: true, force: true });
|
|
12735
12832
|
}
|
|
12736
12833
|
}
|
|
12737
12834
|
async function planV2(projectDir, config, planV2Dir) {
|
|
@@ -12953,7 +13050,7 @@ function materializePlanV2Target(planV2Dir, target, destinationDir, options = {}
|
|
|
12953
13050
|
);
|
|
12954
13051
|
renameWithRetry9(tempDir, destinationDir);
|
|
12955
13052
|
} catch (error) {
|
|
12956
|
-
|
|
13053
|
+
rmSync10(tempDir, { recursive: true, force: true });
|
|
12957
13054
|
throw error;
|
|
12958
13055
|
}
|
|
12959
13056
|
return {
|
|
@@ -13017,7 +13114,7 @@ function readValidatedPlanV2Materialization(planDir, expectedTarget) {
|
|
|
13017
13114
|
}
|
|
13018
13115
|
|
|
13019
13116
|
// src/services/distributed/planV2Execution.ts
|
|
13020
|
-
import { mkdtempSync, rmSync as
|
|
13117
|
+
import { mkdtempSync, rmSync as rmSync13 } from "node:fs";
|
|
13021
13118
|
import { tmpdir as tmpdir2 } from "node:os";
|
|
13022
13119
|
import { join as join34 } from "node:path";
|
|
13023
13120
|
|
|
@@ -13032,7 +13129,7 @@ import {
|
|
|
13032
13129
|
mkdirSync as mkdirSync13,
|
|
13033
13130
|
readFileSync as readFileSync11,
|
|
13034
13131
|
readdirSync as readdirSync8,
|
|
13035
|
-
rmSync as
|
|
13132
|
+
rmSync as rmSync11,
|
|
13036
13133
|
statSync as statSync10
|
|
13037
13134
|
} from "node:fs";
|
|
13038
13135
|
import { localContainerInputArgs as localContainerInputArgs2 } from "@hyperframes/parsers/ff-binaries";
|
|
@@ -13119,7 +13216,7 @@ async function assemble(planDir, chunkOutputs, audioPath, outputPath, options) {
|
|
|
13119
13216
|
});
|
|
13120
13217
|
} finally {
|
|
13121
13218
|
try {
|
|
13122
|
-
|
|
13219
|
+
rmSync11(workDir, { recursive: true, force: true });
|
|
13123
13220
|
} catch (err) {
|
|
13124
13221
|
log.warn("[assemble] failed to remove work dir", {
|
|
13125
13222
|
workDir,
|
|
@@ -13322,7 +13419,7 @@ function readCfrEncoder(planDir, format) {
|
|
|
13322
13419
|
return encoderJson;
|
|
13323
13420
|
}
|
|
13324
13421
|
function mergePngFrameDirs(chunkPaths, outputPath, totalFrames, audioPath, startTimeMs) {
|
|
13325
|
-
if (existsSync23(outputPath))
|
|
13422
|
+
if (existsSync23(outputPath)) rmSync11(outputPath, { recursive: true, force: true });
|
|
13326
13423
|
mkdirSync13(outputPath, { recursive: true });
|
|
13327
13424
|
let globalIdx = 0;
|
|
13328
13425
|
for (const chunkDir of chunkPaths) {
|
|
@@ -13367,7 +13464,7 @@ function mergePngFrameDirs(chunkPaths, outputPath, totalFrames, audioPath, start
|
|
|
13367
13464
|
|
|
13368
13465
|
// src/services/distributed/renderChunk.ts
|
|
13369
13466
|
import { randomBytes } from "node:crypto";
|
|
13370
|
-
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";
|
|
13371
13468
|
import { join as join33 } from "node:path";
|
|
13372
13469
|
import {
|
|
13373
13470
|
assertSwiftShader,
|
|
@@ -13957,7 +14054,7 @@ async function renderChunk(planDir, chunkIndex, outputChunkPath, options) {
|
|
|
13957
14054
|
return observedChunkCaptureMode(capturePerfs);
|
|
13958
14055
|
},
|
|
13959
14056
|
resetForScreenshotRetry: () => {
|
|
13960
|
-
|
|
14057
|
+
rmSync12(workDir, { recursive: true, force: true, maxRetries: 3, retryDelay: 100 });
|
|
13961
14058
|
boxesMeasured();
|
|
13962
14059
|
mkdirSync14(framesDir, { recursive: true });
|
|
13963
14060
|
capturePerfs.length = 0;
|
|
@@ -14003,8 +14100,8 @@ async function renderChunk(planDir, chunkIndex, outputChunkPath, options) {
|
|
|
14003
14100
|
fps: { num: plan.dimensions.fpsNum, den: plan.dimensions.fpsDen },
|
|
14004
14101
|
timeoutMs: cfg.ffmpegProcessTimeout
|
|
14005
14102
|
});
|
|
14006
|
-
|
|
14007
|
-
|
|
14103
|
+
rmSync12(videoOnlyPath, { force: true });
|
|
14104
|
+
rmSync12(audioScratchPath, { force: true });
|
|
14008
14105
|
}
|
|
14009
14106
|
encodeStageMs = Date.now() - encodeStarted;
|
|
14010
14107
|
} finally {
|
|
@@ -14054,8 +14151,8 @@ async function renderChunk(planDir, chunkIndex, outputChunkPath, options) {
|
|
|
14054
14151
|
writeFileSync11(perfPath, `${JSON.stringify(perfPayload, null, 2)}
|
|
14055
14152
|
`, "utf-8");
|
|
14056
14153
|
try {
|
|
14057
|
-
|
|
14058
|
-
|
|
14154
|
+
rmSync12(workDir, { recursive: true, force: true, maxRetries: 3, retryDelay: 100 });
|
|
14155
|
+
rmSync12(videoFramesDir, { recursive: true, force: true, maxRetries: 3, retryDelay: 100 });
|
|
14059
14156
|
} catch (err) {
|
|
14060
14157
|
log.warn("[renderChunk] failed to remove work dir", {
|
|
14061
14158
|
workDir,
|
|
@@ -14090,7 +14187,7 @@ async function renderChunkV2(planV2Dir, chunkIndex, outputChunkPath, options) {
|
|
|
14090
14187
|
materializePlanV2Target(planV2Dir, { role: "chunk", chunkIndex }, materializedPlanDir);
|
|
14091
14188
|
return await renderChunk(materializedPlanDir, chunkIndex, outputChunkPath, options);
|
|
14092
14189
|
} finally {
|
|
14093
|
-
|
|
14190
|
+
rmSync13(workRoot, { recursive: true, force: true });
|
|
14094
14191
|
}
|
|
14095
14192
|
}
|
|
14096
14193
|
async function assembleV2(planV2Dir, chunkPaths, outputPath, options) {
|
|
@@ -14110,7 +14207,7 @@ async function assembleV2(planV2Dir, chunkPaths, outputPath, options) {
|
|
|
14110
14207
|
options
|
|
14111
14208
|
);
|
|
14112
14209
|
} finally {
|
|
14113
|
-
|
|
14210
|
+
rmSync13(workRoot, { recursive: true, force: true });
|
|
14114
14211
|
}
|
|
14115
14212
|
}
|
|
14116
14213
|
|