@hyperframes/producer 0.9.88 → 0.9.90
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 +87 -18
- package/dist/distributed.js +181 -75
- package/dist/hyperframe.manifest.json +1 -1
- package/dist/hyperframe.runtime.iife.js +69 -69
- package/dist/index.js +284 -115
- package/dist/public-server.js +240 -71
- 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);
|
|
@@ -4979,7 +5027,16 @@ function localizeFontFaceUrls(html, downloadDir, assets) {
|
|
|
4979
5027
|
"Remote font download failed",
|
|
4980
5028
|
"Localized remote font face(s)",
|
|
4981
5029
|
assets,
|
|
4982
|
-
(h, url, relPath) =>
|
|
5030
|
+
(h, url, relPath) => replaceMatches(
|
|
5031
|
+
h,
|
|
5032
|
+
styleBlockMatches(h),
|
|
5033
|
+
(style, css) => replaceInner(
|
|
5034
|
+
style,
|
|
5035
|
+
css,
|
|
5036
|
+
"</style>".length,
|
|
5037
|
+
css.replaceAll(`url(${url})`, `url("${relPath}")`)
|
|
5038
|
+
)
|
|
5039
|
+
)
|
|
4983
5040
|
);
|
|
4984
5041
|
}
|
|
4985
5042
|
var MAX_LOCAL_FONT_DATA_URI_BYTES = 5 * 1024 * 1024;
|
|
@@ -5159,7 +5216,7 @@ function rebaseDirectEntryAssetPaths(html, projectDir, htmlPath, budget) {
|
|
|
5159
5216
|
return document2.toString();
|
|
5160
5217
|
}
|
|
5161
5218
|
var MAX_VARIABLE_MEDIA_SRC_BYTES = 8 * 1024;
|
|
5162
|
-
var
|
|
5219
|
+
var MEDIA_SRC_NON_URL_CHARS = /[\u0000-\u001f\u007f<>]/;
|
|
5163
5220
|
function bindVariableMediaSources(html, variables, budget, log) {
|
|
5164
5221
|
if (!html.includes("data-var-src")) return html;
|
|
5165
5222
|
const { document: document2 } = parseHTML5(html);
|
|
@@ -5174,7 +5231,7 @@ function bindVariableMediaSources(html, variables, budget, log) {
|
|
|
5174
5231
|
const bound = boundMediaSrc(el, values);
|
|
5175
5232
|
if (bound === null) continue;
|
|
5176
5233
|
const src = bound.trim();
|
|
5177
|
-
if (src.length > MAX_VARIABLE_MEDIA_SRC_BYTES ||
|
|
5234
|
+
if (src.length > MAX_VARIABLE_MEDIA_SRC_BYTES || MEDIA_SRC_NON_URL_CHARS.test(src)) {
|
|
5178
5235
|
log?.warn("[Compiler] Refused a variable media source that cannot be a URL", {
|
|
5179
5236
|
length: src.length
|
|
5180
5237
|
});
|
|
@@ -5309,6 +5366,7 @@ async function compileWithAssets(projectDir, htmlPath, downloadDir, options, ass
|
|
|
5309
5366
|
cacheDir: options.animatedGifCacheDir,
|
|
5310
5367
|
sourceAssets: remoteImageAssets,
|
|
5311
5368
|
timeoutMs: options.ffmpegProcessTimeout,
|
|
5369
|
+
signal: options.abortSignal,
|
|
5312
5370
|
allowOutsideFiles: assetRoot === void 0
|
|
5313
5371
|
});
|
|
5314
5372
|
if (preparedHeifImages.length > 0) {
|
|
@@ -5325,6 +5383,7 @@ async function compileWithAssets(projectDir, htmlPath, downloadDir, options, ass
|
|
|
5325
5383
|
cacheDir: options.animatedGifCacheDir,
|
|
5326
5384
|
sourceAssets: gifSourceAssets,
|
|
5327
5385
|
timeoutMs: options.ffmpegProcessTimeout,
|
|
5386
|
+
signal: options.abortSignal,
|
|
5328
5387
|
allowOutsideFiles: assetRoot === void 0
|
|
5329
5388
|
});
|
|
5330
5389
|
if (preparedGifs.length > 0) {
|
|
@@ -5803,6 +5862,24 @@ function compileTimeoutMs() {
|
|
|
5803
5862
|
return Number.isInteger(fromEnv) && fromEnv > 0 ? Math.min(fromEnv, MAX_TIMER_MS) : DEFAULT_COMPILE_TIMEOUT_MS;
|
|
5804
5863
|
}
|
|
5805
5864
|
var warnedMissingEntry = false;
|
|
5865
|
+
var endOnProcessExit = /* @__PURE__ */ new Set();
|
|
5866
|
+
var processExitHooked = false;
|
|
5867
|
+
function onProcessExit(end) {
|
|
5868
|
+
if (!processExitHooked) {
|
|
5869
|
+
processExitHooked = true;
|
|
5870
|
+
process.on("exit", () => {
|
|
5871
|
+
for (const each of endOnProcessExit) each();
|
|
5872
|
+
});
|
|
5873
|
+
}
|
|
5874
|
+
endOnProcessExit.add(end);
|
|
5875
|
+
return () => endOnProcessExit.delete(end);
|
|
5876
|
+
}
|
|
5877
|
+
function tryQuietly(action) {
|
|
5878
|
+
try {
|
|
5879
|
+
action();
|
|
5880
|
+
} catch {
|
|
5881
|
+
}
|
|
5882
|
+
}
|
|
5806
5883
|
function resolveCompileWorkerEntry(explicit, log) {
|
|
5807
5884
|
if (explicit) return explicit;
|
|
5808
5885
|
const fromEnv = process.env.HF_COMPILE_WORKER_ENTRY;
|
|
@@ -5836,6 +5913,26 @@ async function compileForRenderInWorker(projectDir, htmlPath, downloadDir, optio
|
|
|
5836
5913
|
const thread = new Worker(entry, {
|
|
5837
5914
|
workerData: { projectDir, htmlPath, downloadDir, options: cloneable }
|
|
5838
5915
|
});
|
|
5916
|
+
const children = /* @__PURE__ */ new Map();
|
|
5917
|
+
const scratchRoots = [downloadDir, options.animatedGifCacheDir].flatMap(
|
|
5918
|
+
(dir) => dir ? [resolvePath(dir)] : []
|
|
5919
|
+
);
|
|
5920
|
+
const isScratch = (path) => scratchRoots.some((root) => {
|
|
5921
|
+
const rel = relative3(root, resolvePath(path));
|
|
5922
|
+
return rel !== "" && !rel.startsWith("..") && !isAbsolute3(rel);
|
|
5923
|
+
});
|
|
5924
|
+
const endChildren = (signal) => {
|
|
5925
|
+
for (const [pid, output] of children) {
|
|
5926
|
+
if (signal) tryQuietly(() => process.kill(pid, "SIGKILL"));
|
|
5927
|
+
if (output) tryQuietly(() => rmSync4(output, { force: true }));
|
|
5928
|
+
}
|
|
5929
|
+
children.clear();
|
|
5930
|
+
};
|
|
5931
|
+
const offProcessExit = onProcessExit(() => endChildren(true));
|
|
5932
|
+
const endThread = () => {
|
|
5933
|
+
endChildren(true);
|
|
5934
|
+
void thread.terminate();
|
|
5935
|
+
};
|
|
5839
5936
|
let settled = false;
|
|
5840
5937
|
const settle = (finish) => {
|
|
5841
5938
|
if (settled) return;
|
|
@@ -5846,7 +5943,7 @@ async function compileForRenderInWorker(projectDir, htmlPath, downloadDir, optio
|
|
|
5846
5943
|
};
|
|
5847
5944
|
const stop = () => {
|
|
5848
5945
|
thread.postMessage({ type: "abort" });
|
|
5849
|
-
setTimeout(
|
|
5946
|
+
setTimeout(endThread, TERMINATE_GRACE_MS).unref();
|
|
5850
5947
|
};
|
|
5851
5948
|
const timer = setTimeout(() => {
|
|
5852
5949
|
stop();
|
|
@@ -5859,7 +5956,7 @@ async function compileForRenderInWorker(projectDir, htmlPath, downloadDir, optio
|
|
|
5859
5956
|
abortSignal?.addEventListener("abort", onAbort, { once: true });
|
|
5860
5957
|
const retire = (graceMs) => {
|
|
5861
5958
|
thread.unref();
|
|
5862
|
-
setTimeout(
|
|
5959
|
+
setTimeout(endThread, graceMs).unref();
|
|
5863
5960
|
};
|
|
5864
5961
|
thread.on(
|
|
5865
5962
|
"message",
|
|
@@ -5878,13 +5975,22 @@ async function compileForRenderInWorker(projectDir, htmlPath, downloadDir, optio
|
|
|
5878
5975
|
}
|
|
5879
5976
|
}
|
|
5880
5977
|
);
|
|
5881
|
-
thread.on("error", (error) => settle(() => reject(error)));
|
|
5882
5978
|
thread.on(
|
|
5883
|
-
"
|
|
5884
|
-
(
|
|
5885
|
-
|
|
5886
|
-
|
|
5979
|
+
"message",
|
|
5980
|
+
({ type, pid, output }) => {
|
|
5981
|
+
if (pid === void 0) return;
|
|
5982
|
+
if (type === "child") children.set(pid, output && isScratch(output) ? output : void 0);
|
|
5983
|
+
else if (type === "childExit") children.delete(pid);
|
|
5984
|
+
}
|
|
5887
5985
|
);
|
|
5986
|
+
thread.on("error", (error) => settle(() => reject(error)));
|
|
5987
|
+
thread.on("exit", (code) => {
|
|
5988
|
+
offProcessExit();
|
|
5989
|
+
endChildren(false);
|
|
5990
|
+
settle(
|
|
5991
|
+
() => reject(new Error(`The compile worker exited with code ${code} before answering`))
|
|
5992
|
+
);
|
|
5993
|
+
});
|
|
5888
5994
|
});
|
|
5889
5995
|
}
|
|
5890
5996
|
|
|
@@ -5914,10 +6020,10 @@ function resolveEntryHtmlPath(input) {
|
|
|
5914
6020
|
const readEntry = (path) => {
|
|
5915
6021
|
if (escapesAssetRoot(path, input.assetRoot)) {
|
|
5916
6022
|
throw new Error(
|
|
5917
|
-
`Entry file "${
|
|
6023
|
+
`Entry file "${relative4(projectDir, path)}" leads outside the project folder`
|
|
5918
6024
|
);
|
|
5919
6025
|
}
|
|
5920
|
-
assertCompositionFileSize2(path,
|
|
6026
|
+
assertCompositionFileSize2(path, relative4(projectDir, path));
|
|
5921
6027
|
return readTextFile2(path);
|
|
5922
6028
|
};
|
|
5923
6029
|
const htmlPath = join11(projectDir, entryFile);
|
|
@@ -8674,7 +8780,7 @@ import {
|
|
|
8674
8780
|
mkdirSync as mkdirSync5,
|
|
8675
8781
|
readdirSync as readdirSync2,
|
|
8676
8782
|
readFileSync as readFileSync6,
|
|
8677
|
-
rmSync as
|
|
8783
|
+
rmSync as rmSync5,
|
|
8678
8784
|
statSync as statSync6,
|
|
8679
8785
|
writeFileSync as writeFileSync4
|
|
8680
8786
|
} from "node:fs";
|
|
@@ -8813,7 +8919,7 @@ async function encodeGifFromDir(framesDir, framePattern, outputPath, input) {
|
|
|
8813
8919
|
fileSize
|
|
8814
8920
|
};
|
|
8815
8921
|
} finally {
|
|
8816
|
-
|
|
8922
|
+
rmSync5(input.palettePath, { force: true });
|
|
8817
8923
|
}
|
|
8818
8924
|
}
|
|
8819
8925
|
function startEncodeProgress(job, stage, onProgress) {
|
|
@@ -9429,7 +9535,7 @@ async function executeDiskCaptureWithAdaptiveRetry(options) {
|
|
|
9429
9535
|
function createRenderJob(config) {
|
|
9430
9536
|
return {
|
|
9431
9537
|
...referenceBackgroundResult(void 0),
|
|
9432
|
-
id:
|
|
9538
|
+
id: randomUUID3(),
|
|
9433
9539
|
config: {
|
|
9434
9540
|
...config,
|
|
9435
9541
|
fps: toFps2(config.fps),
|
|
@@ -10120,7 +10226,7 @@ async function readPlanReferenceBackground(input) {
|
|
|
10120
10226
|
|
|
10121
10227
|
// src/services/render/stages/freezePlan.ts
|
|
10122
10228
|
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
|
|
10229
|
+
import { join as join24, relative as relative5, resolve as resolve8 } from "node:path";
|
|
10124
10230
|
import {
|
|
10125
10231
|
REFERENCE_BACKGROUND_FIELD,
|
|
10126
10232
|
referenceBackgroundResult as referenceBackgroundResult3
|
|
@@ -10343,7 +10449,7 @@ function listPlanFiles(planDir) {
|
|
|
10343
10449
|
walk(full);
|
|
10344
10450
|
} else if (entry.isFile()) {
|
|
10345
10451
|
results.push({
|
|
10346
|
-
planRelativePath:
|
|
10452
|
+
planRelativePath: relative5(rootResolved, full).split(/[\\/]+/).join("/"),
|
|
10347
10453
|
absolutePath: full
|
|
10348
10454
|
});
|
|
10349
10455
|
}
|
|
@@ -10508,7 +10614,7 @@ import { join as join26 } from "node:path";
|
|
|
10508
10614
|
import { appendRenderProvenanceArgs, describeFfmpegFailure as describeFfmpegFailure4, runFfmpeg as runFfmpeg7 } from "@hyperframes/engine";
|
|
10509
10615
|
|
|
10510
10616
|
// src/services/distributed/mp4Stitch.ts
|
|
10511
|
-
import { createReadStream as createReadStream4, createWriteStream, mkdirSync as mkdirSync8, rmSync as
|
|
10617
|
+
import { createReadStream as createReadStream4, createWriteStream, mkdirSync as mkdirSync8, rmSync as rmSync7 } from "node:fs";
|
|
10512
10618
|
import { open } from "node:fs/promises";
|
|
10513
10619
|
import { renameWithRetry as renameWithRetry6 } from "@hyperframes/engine";
|
|
10514
10620
|
import { basename as basename5, dirname as dirname14, join as join25 } from "node:path";
|
|
@@ -10887,7 +10993,7 @@ async function writeStitchedMp4(chunkPaths, outputPath, audioPath) {
|
|
|
10887
10993
|
renameWithRetry6(join25(workDir, "out.mp4"), outputPath);
|
|
10888
10994
|
} finally {
|
|
10889
10995
|
out.destroy();
|
|
10890
|
-
|
|
10996
|
+
rmSync7(workDir, { recursive: true, force: true });
|
|
10891
10997
|
}
|
|
10892
10998
|
}
|
|
10893
10999
|
|
|
@@ -11065,7 +11171,7 @@ async function muxChunkWithAudio(input) {
|
|
|
11065
11171
|
// src/services/distributed/planSize.ts
|
|
11066
11172
|
import { createHash as createHash8 } from "node:crypto";
|
|
11067
11173
|
import { lstatSync, readdirSync as readdirSync6 } from "node:fs";
|
|
11068
|
-
import { extname as extname3, join as join27, relative as
|
|
11174
|
+
import { extname as extname3, join as join27, relative as relative6 } from "node:path";
|
|
11069
11175
|
var MAX_TOP_COMPONENTS = 10;
|
|
11070
11176
|
var SOURCE_MEDIA_EXTENSIONS = /* @__PURE__ */ new Set([
|
|
11071
11177
|
".aac",
|
|
@@ -11154,7 +11260,7 @@ function recordFile(result, components, rootDir, rootKind, filePath) {
|
|
|
11154
11260
|
} catch {
|
|
11155
11261
|
return;
|
|
11156
11262
|
}
|
|
11157
|
-
const rel =
|
|
11263
|
+
const rel = relative6(rootDir, filePath);
|
|
11158
11264
|
const segments = rel.split(/[\\/]+/).filter(Boolean);
|
|
11159
11265
|
const classified = classifyFile(segments, rootKind);
|
|
11160
11266
|
result.totalBytes += sizeBytes;
|
|
@@ -11403,7 +11509,7 @@ var FREEZE_OWNED_PLAN_FILES = [
|
|
|
11403
11509
|
];
|
|
11404
11510
|
function removeFreezeOwnedPlanFiles(planDir) {
|
|
11405
11511
|
for (const relativePath of FREEZE_OWNED_PLAN_FILES) {
|
|
11406
|
-
|
|
11512
|
+
rmSync8(join28(planDir, relativePath), { force: true });
|
|
11407
11513
|
}
|
|
11408
11514
|
}
|
|
11409
11515
|
function buildChunkSlices(totalFrames, chunkCount, effectiveChunkSize) {
|
|
@@ -11542,10 +11648,10 @@ function resolveDistributedEngineConfig(config) {
|
|
|
11542
11648
|
};
|
|
11543
11649
|
}
|
|
11544
11650
|
function leavesRoot(rel) {
|
|
11545
|
-
return rel === ".." || rel.startsWith(`..${sep4}`) ||
|
|
11651
|
+
return rel === ".." || rel.startsWith(`..${sep4}`) || isAbsolute4(rel);
|
|
11546
11652
|
}
|
|
11547
11653
|
function pathInside(root, path) {
|
|
11548
|
-
const rel =
|
|
11654
|
+
const rel = relative7(root, path);
|
|
11549
11655
|
return rel === "" || leavesRoot(rel) ? null : rel;
|
|
11550
11656
|
}
|
|
11551
11657
|
function stableSourcePath(roots, srcPath) {
|
|
@@ -11632,7 +11738,7 @@ async function compilePlanComposition(projectDir, config, planDir, options) {
|
|
|
11632
11738
|
throw new Error(`[plan] entry file not found: ${htmlPath}`);
|
|
11633
11739
|
}
|
|
11634
11740
|
const workDir = join28(planDir, ".plan-work");
|
|
11635
|
-
|
|
11741
|
+
rmSync8(workDir, { recursive: true, force: true });
|
|
11636
11742
|
mkdirSync10(workDir, { recursive: true });
|
|
11637
11743
|
const compiledDir = join28(workDir, "compiled");
|
|
11638
11744
|
mkdirSync10(compiledDir, { recursive: true });
|
|
@@ -11641,7 +11747,7 @@ async function compilePlanComposition(projectDir, config, planDir, options) {
|
|
|
11641
11747
|
recursive: true,
|
|
11642
11748
|
dereference: true,
|
|
11643
11749
|
filter: (src) => {
|
|
11644
|
-
const rel =
|
|
11750
|
+
const rel = relative7(projectDir, src);
|
|
11645
11751
|
if (rel === "") return true;
|
|
11646
11752
|
if (leavesRoot(rel)) return false;
|
|
11647
11753
|
if (job.config.allowOutsideProjectAssets) {
|
|
@@ -11864,15 +11970,15 @@ async function buildLocalExecutionPlan(projectDir, config, executionPlanDir, opt
|
|
|
11864
11970
|
logPlanStage(log, "extract", stageStarted);
|
|
11865
11971
|
const stagedVideoFrames = join28(compiledDir, "__hyperframes_video_frames");
|
|
11866
11972
|
const videoFramesDst = join28(planDir, "video-frames");
|
|
11867
|
-
if (existsSync20(videoFramesDst))
|
|
11973
|
+
if (existsSync20(videoFramesDst)) rmSync8(videoFramesDst, { recursive: true, force: true });
|
|
11868
11974
|
const videoSourcesDir = join28(planDir, "video-sources");
|
|
11869
|
-
|
|
11975
|
+
rmSync8(videoSourcesDir, { recursive: true, force: true });
|
|
11870
11976
|
if (existsSync20(stagedVideoFrames)) {
|
|
11871
11977
|
renameWithRetry7(stagedVideoFrames, videoFramesDst);
|
|
11872
11978
|
} else {
|
|
11873
11979
|
mkdirSync10(videoFramesDst, { recursive: true });
|
|
11874
11980
|
}
|
|
11875
|
-
if (existsSync20(finalCompiledDir))
|
|
11981
|
+
if (existsSync20(finalCompiledDir)) rmSync8(finalCompiledDir, { recursive: true, force: true });
|
|
11876
11982
|
renameWithRetry7(compiledDir, finalCompiledDir);
|
|
11877
11983
|
const shipVideoSource = createVideoSourceShipper({
|
|
11878
11984
|
planDir,
|
|
@@ -12042,7 +12148,7 @@ async function buildLocalExecutionPlan(projectDir, config, executionPlanDir, opt
|
|
|
12042
12148
|
format: config.format
|
|
12043
12149
|
};
|
|
12044
12150
|
try {
|
|
12045
|
-
|
|
12151
|
+
rmSync8(workDir, { recursive: true, force: true });
|
|
12046
12152
|
} catch (err) {
|
|
12047
12153
|
log.warn("[plan] failed to remove temp work dir", {
|
|
12048
12154
|
workDir,
|
|
@@ -12120,7 +12226,7 @@ async function buildPlanAudio(projectDir, config, workRoot, outputPath, options
|
|
|
12120
12226
|
renameWithRetry7(mixed.audioOutputPath, outputPath);
|
|
12121
12227
|
return { hasAudio: true };
|
|
12122
12228
|
} finally {
|
|
12123
|
-
|
|
12229
|
+
rmSync8(c.workDir, { recursive: true, force: true });
|
|
12124
12230
|
}
|
|
12125
12231
|
}
|
|
12126
12232
|
|
|
@@ -12136,12 +12242,12 @@ import {
|
|
|
12136
12242
|
mkdirSync as mkdirSync12,
|
|
12137
12243
|
readFileSync as readFileSync10,
|
|
12138
12244
|
readdirSync as readdirSync7,
|
|
12139
|
-
rmSync as
|
|
12245
|
+
rmSync as rmSync10,
|
|
12140
12246
|
statSync as statSync9,
|
|
12141
12247
|
writeFileSync as writeFileSync10
|
|
12142
12248
|
} from "node:fs";
|
|
12143
12249
|
import { tmpdir } from "node:os";
|
|
12144
|
-
import { dirname as dirname16, isAbsolute as
|
|
12250
|
+
import { dirname as dirname16, isAbsolute as isAbsolute5, join as join31, relative as relative8, resolve as resolve9, sep as sep5 } from "node:path";
|
|
12145
12251
|
import { DISTRIBUTED_FPS, isDistributedFps } from "@hyperframes/core";
|
|
12146
12252
|
import {
|
|
12147
12253
|
createFrameLookupTable as createFrameLookupTable5,
|
|
@@ -12155,7 +12261,7 @@ import {
|
|
|
12155
12261
|
existsSync as existsSync21,
|
|
12156
12262
|
linkSync as linkSync2,
|
|
12157
12263
|
mkdirSync as mkdirSync11,
|
|
12158
|
-
rmSync as
|
|
12264
|
+
rmSync as rmSync9,
|
|
12159
12265
|
statSync as statSync8,
|
|
12160
12266
|
writeFileSync as writeFileSync9
|
|
12161
12267
|
} from "node:fs";
|
|
@@ -12246,7 +12352,7 @@ var LocalPlanV2ArtifactPublisher = class {
|
|
|
12246
12352
|
}
|
|
12247
12353
|
renameWithRetry8(temporaryPath, destinationPath);
|
|
12248
12354
|
} finally {
|
|
12249
|
-
|
|
12355
|
+
rmSync9(stagingDir, { recursive: true, force: true });
|
|
12250
12356
|
}
|
|
12251
12357
|
}
|
|
12252
12358
|
async commitManifest(manifestBytes) {
|
|
@@ -12263,7 +12369,7 @@ var LocalPlanV2ArtifactPublisher = class {
|
|
|
12263
12369
|
}
|
|
12264
12370
|
async abort() {
|
|
12265
12371
|
if (!this.#committed) {
|
|
12266
|
-
|
|
12372
|
+
rmSync9(this.temporaryDir, { recursive: true, force: true });
|
|
12267
12373
|
}
|
|
12268
12374
|
}
|
|
12269
12375
|
};
|
|
@@ -12294,7 +12400,7 @@ function readJsonFile(path, label) {
|
|
|
12294
12400
|
}
|
|
12295
12401
|
function assertSafeRelativePath(path) {
|
|
12296
12402
|
const normalized = path.split(/[\\/]+/);
|
|
12297
|
-
if (path.length === 0 ||
|
|
12403
|
+
if (path.length === 0 || isAbsolute5(path) || normalized.some((part) => part === "" || part === "." || part === "..")) {
|
|
12298
12404
|
throw new PlanV2IntegrityError(`unsafe artifact path: ${JSON.stringify(path)}`);
|
|
12299
12405
|
}
|
|
12300
12406
|
}
|
|
@@ -12308,7 +12414,7 @@ function listFiles(root) {
|
|
|
12308
12414
|
walk(absolutePath);
|
|
12309
12415
|
} else if (entry.isFile()) {
|
|
12310
12416
|
files.push({
|
|
12311
|
-
path:
|
|
12417
|
+
path: relative8(rootResolved, absolutePath).split(sep5).join("/"),
|
|
12312
12418
|
absolutePath
|
|
12313
12419
|
});
|
|
12314
12420
|
} else {
|
|
@@ -12508,7 +12614,7 @@ function collectChunkVideoDependencies(input) {
|
|
|
12508
12614
|
for (let frame = chunk.startFrame; frame < chunk.endFrame; frame++) {
|
|
12509
12615
|
const globalTime = frame * input.fpsDen / input.fpsNum;
|
|
12510
12616
|
for (const [videoId, payload] of input.table.getActiveFramePayloads(globalTime)) {
|
|
12511
|
-
const path = input.deferredSources.get(videoId) ??
|
|
12617
|
+
const path = input.deferredSources.get(videoId) ?? relative8(resolve9(input.executionPlanDir), payload.framePath).split(sep5).join("/");
|
|
12512
12618
|
assertSafeRelativePath(path);
|
|
12513
12619
|
const indexes = mutable.get(path) ?? /* @__PURE__ */ new Set();
|
|
12514
12620
|
indexes.add(chunk.index);
|
|
@@ -12533,7 +12639,7 @@ function writeBlob(sourcePath, destinationPath) {
|
|
|
12533
12639
|
copyFileSync8(sourcePath, temporaryPath);
|
|
12534
12640
|
renameWithRetry9(temporaryPath, destinationPath);
|
|
12535
12641
|
} finally {
|
|
12536
|
-
|
|
12642
|
+
rmSync10(temporaryDir, { recursive: true, force: true });
|
|
12537
12643
|
}
|
|
12538
12644
|
}
|
|
12539
12645
|
function publishBlobFor(absolutePath, digests) {
|
|
@@ -12666,7 +12772,7 @@ function createPlanV2FromExecutionPlan(executionPlanDir, planV2Dir) {
|
|
|
12666
12772
|
renameWithRetry9(tempDir, planV2Dir);
|
|
12667
12773
|
return resultFromManifest(planV2Dir, publication.manifest);
|
|
12668
12774
|
} catch (error) {
|
|
12669
|
-
|
|
12775
|
+
rmSync10(tempDir, { recursive: true, force: true });
|
|
12670
12776
|
throw error;
|
|
12671
12777
|
}
|
|
12672
12778
|
}
|
|
@@ -12731,7 +12837,7 @@ async function planV2WithPublisher(projectDir, config, publisher, options = {})
|
|
|
12731
12837
|
}
|
|
12732
12838
|
throw error;
|
|
12733
12839
|
} finally {
|
|
12734
|
-
|
|
12840
|
+
rmSync10(stagingRoot, { recursive: true, force: true });
|
|
12735
12841
|
}
|
|
12736
12842
|
}
|
|
12737
12843
|
async function planV2(projectDir, config, planV2Dir) {
|
|
@@ -12953,7 +13059,7 @@ function materializePlanV2Target(planV2Dir, target, destinationDir, options = {}
|
|
|
12953
13059
|
);
|
|
12954
13060
|
renameWithRetry9(tempDir, destinationDir);
|
|
12955
13061
|
} catch (error) {
|
|
12956
|
-
|
|
13062
|
+
rmSync10(tempDir, { recursive: true, force: true });
|
|
12957
13063
|
throw error;
|
|
12958
13064
|
}
|
|
12959
13065
|
return {
|
|
@@ -13017,7 +13123,7 @@ function readValidatedPlanV2Materialization(planDir, expectedTarget) {
|
|
|
13017
13123
|
}
|
|
13018
13124
|
|
|
13019
13125
|
// src/services/distributed/planV2Execution.ts
|
|
13020
|
-
import { mkdtempSync, rmSync as
|
|
13126
|
+
import { mkdtempSync, rmSync as rmSync13 } from "node:fs";
|
|
13021
13127
|
import { tmpdir as tmpdir2 } from "node:os";
|
|
13022
13128
|
import { join as join34 } from "node:path";
|
|
13023
13129
|
|
|
@@ -13032,7 +13138,7 @@ import {
|
|
|
13032
13138
|
mkdirSync as mkdirSync13,
|
|
13033
13139
|
readFileSync as readFileSync11,
|
|
13034
13140
|
readdirSync as readdirSync8,
|
|
13035
|
-
rmSync as
|
|
13141
|
+
rmSync as rmSync11,
|
|
13036
13142
|
statSync as statSync10
|
|
13037
13143
|
} from "node:fs";
|
|
13038
13144
|
import { localContainerInputArgs as localContainerInputArgs2 } from "@hyperframes/parsers/ff-binaries";
|
|
@@ -13119,7 +13225,7 @@ async function assemble(planDir, chunkOutputs, audioPath, outputPath, options) {
|
|
|
13119
13225
|
});
|
|
13120
13226
|
} finally {
|
|
13121
13227
|
try {
|
|
13122
|
-
|
|
13228
|
+
rmSync11(workDir, { recursive: true, force: true });
|
|
13123
13229
|
} catch (err) {
|
|
13124
13230
|
log.warn("[assemble] failed to remove work dir", {
|
|
13125
13231
|
workDir,
|
|
@@ -13322,7 +13428,7 @@ function readCfrEncoder(planDir, format) {
|
|
|
13322
13428
|
return encoderJson;
|
|
13323
13429
|
}
|
|
13324
13430
|
function mergePngFrameDirs(chunkPaths, outputPath, totalFrames, audioPath, startTimeMs) {
|
|
13325
|
-
if (existsSync23(outputPath))
|
|
13431
|
+
if (existsSync23(outputPath)) rmSync11(outputPath, { recursive: true, force: true });
|
|
13326
13432
|
mkdirSync13(outputPath, { recursive: true });
|
|
13327
13433
|
let globalIdx = 0;
|
|
13328
13434
|
for (const chunkDir of chunkPaths) {
|
|
@@ -13367,7 +13473,7 @@ function mergePngFrameDirs(chunkPaths, outputPath, totalFrames, audioPath, start
|
|
|
13367
13473
|
|
|
13368
13474
|
// src/services/distributed/renderChunk.ts
|
|
13369
13475
|
import { randomBytes } from "node:crypto";
|
|
13370
|
-
import { existsSync as existsSync24, mkdirSync as mkdirSync14, readFileSync as readFileSync12, readdirSync as readdirSync9, rmSync as
|
|
13476
|
+
import { existsSync as existsSync24, mkdirSync as mkdirSync14, readFileSync as readFileSync12, readdirSync as readdirSync9, rmSync as rmSync12, writeFileSync as writeFileSync11 } from "node:fs";
|
|
13371
13477
|
import { join as join33 } from "node:path";
|
|
13372
13478
|
import {
|
|
13373
13479
|
assertSwiftShader,
|
|
@@ -13957,7 +14063,7 @@ async function renderChunk(planDir, chunkIndex, outputChunkPath, options) {
|
|
|
13957
14063
|
return observedChunkCaptureMode(capturePerfs);
|
|
13958
14064
|
},
|
|
13959
14065
|
resetForScreenshotRetry: () => {
|
|
13960
|
-
|
|
14066
|
+
rmSync12(workDir, { recursive: true, force: true, maxRetries: 3, retryDelay: 100 });
|
|
13961
14067
|
boxesMeasured();
|
|
13962
14068
|
mkdirSync14(framesDir, { recursive: true });
|
|
13963
14069
|
capturePerfs.length = 0;
|
|
@@ -14003,8 +14109,8 @@ async function renderChunk(planDir, chunkIndex, outputChunkPath, options) {
|
|
|
14003
14109
|
fps: { num: plan.dimensions.fpsNum, den: plan.dimensions.fpsDen },
|
|
14004
14110
|
timeoutMs: cfg.ffmpegProcessTimeout
|
|
14005
14111
|
});
|
|
14006
|
-
|
|
14007
|
-
|
|
14112
|
+
rmSync12(videoOnlyPath, { force: true });
|
|
14113
|
+
rmSync12(audioScratchPath, { force: true });
|
|
14008
14114
|
}
|
|
14009
14115
|
encodeStageMs = Date.now() - encodeStarted;
|
|
14010
14116
|
} finally {
|
|
@@ -14054,8 +14160,8 @@ async function renderChunk(planDir, chunkIndex, outputChunkPath, options) {
|
|
|
14054
14160
|
writeFileSync11(perfPath, `${JSON.stringify(perfPayload, null, 2)}
|
|
14055
14161
|
`, "utf-8");
|
|
14056
14162
|
try {
|
|
14057
|
-
|
|
14058
|
-
|
|
14163
|
+
rmSync12(workDir, { recursive: true, force: true, maxRetries: 3, retryDelay: 100 });
|
|
14164
|
+
rmSync12(videoFramesDir, { recursive: true, force: true, maxRetries: 3, retryDelay: 100 });
|
|
14059
14165
|
} catch (err) {
|
|
14060
14166
|
log.warn("[renderChunk] failed to remove work dir", {
|
|
14061
14167
|
workDir,
|
|
@@ -14090,7 +14196,7 @@ async function renderChunkV2(planV2Dir, chunkIndex, outputChunkPath, options) {
|
|
|
14090
14196
|
materializePlanV2Target(planV2Dir, { role: "chunk", chunkIndex }, materializedPlanDir);
|
|
14091
14197
|
return await renderChunk(materializedPlanDir, chunkIndex, outputChunkPath, options);
|
|
14092
14198
|
} finally {
|
|
14093
|
-
|
|
14199
|
+
rmSync13(workRoot, { recursive: true, force: true });
|
|
14094
14200
|
}
|
|
14095
14201
|
}
|
|
14096
14202
|
async function assembleV2(planV2Dir, chunkPaths, outputPath, options) {
|
|
@@ -14110,7 +14216,7 @@ async function assembleV2(planV2Dir, chunkPaths, outputPath, options) {
|
|
|
14110
14216
|
options
|
|
14111
14217
|
);
|
|
14112
14218
|
} finally {
|
|
14113
|
-
|
|
14219
|
+
rmSync13(workRoot, { recursive: true, force: true });
|
|
14114
14220
|
}
|
|
14115
14221
|
}
|
|
14116
14222
|
|