@hyperframes/producer 0.9.86 → 0.9.88
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/dist/compileWorker.js +3210 -0
- package/dist/distributed.js +401 -279
- package/dist/hyperframe.manifest.json +1 -1
- package/dist/hyperframe.runtime.iife.js +67 -67
- package/dist/index.js +476 -353
- package/dist/public-server.js +284 -163
- package/dist/services/compileInWorker.d.ts +10 -0
- package/dist/services/compileWorker.d.ts +1 -0
- package/dist/services/distributed/chunkFrames.d.ts +1 -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/public-server.js
CHANGED
|
@@ -18,7 +18,7 @@ function requireOutputDimensions(expected, width, height) {
|
|
|
18
18
|
|
|
19
19
|
// src/server.ts
|
|
20
20
|
import {
|
|
21
|
-
existsSync as
|
|
21
|
+
existsSync as existsSync26,
|
|
22
22
|
mkdirSync as mkdirSync13,
|
|
23
23
|
statSync as statSync12,
|
|
24
24
|
mkdtempSync,
|
|
@@ -26,7 +26,7 @@ import {
|
|
|
26
26
|
rmSync as rmSync13,
|
|
27
27
|
createReadStream as createReadStream4
|
|
28
28
|
} from "node:fs";
|
|
29
|
-
import { resolve as resolve11, dirname as
|
|
29
|
+
import { resolve as resolve11, dirname as dirname19, join as join40 } from "node:path";
|
|
30
30
|
import { tmpdir as tmpdir4 } from "node:os";
|
|
31
31
|
import { parseArgs } from "node:util";
|
|
32
32
|
import { isIP } from "node:net";
|
|
@@ -44,7 +44,7 @@ import { isSafePath as isSafePath4 } from "@hyperframes/core/safe-path";
|
|
|
44
44
|
// src/services/renderOrchestrator.ts
|
|
45
45
|
import { audioFailureDiagnostics as audioFailureDiagnostics2, cpuBudget } from "@hyperframes/engine";
|
|
46
46
|
import {
|
|
47
|
-
existsSync as
|
|
47
|
+
existsSync as existsSync22,
|
|
48
48
|
mkdirSync as mkdirSync12,
|
|
49
49
|
readdirSync as readdirSync6,
|
|
50
50
|
rmSync as rmSync12,
|
|
@@ -395,10 +395,10 @@ import {
|
|
|
395
395
|
referenceBackgroundResult,
|
|
396
396
|
createReferenceBackgroundRecorder
|
|
397
397
|
} from "@hyperframes/engine";
|
|
398
|
-
import { join as
|
|
398
|
+
import { join as join35, dirname as dirname15, resolve as resolve9 } from "path";
|
|
399
399
|
import { totalmem as totalmem2 } from "node:os";
|
|
400
400
|
import { randomUUID } from "crypto";
|
|
401
|
-
import { fileURLToPath as
|
|
401
|
+
import { fileURLToPath as fileURLToPath5 } from "url";
|
|
402
402
|
|
|
403
403
|
// src/services/fileServer.ts
|
|
404
404
|
import { Hono } from "hono";
|
|
@@ -1673,12 +1673,12 @@ var workerPhasesByJob = /* @__PURE__ */ new WeakMap();
|
|
|
1673
1673
|
function forgetWorkerPhases(job) {
|
|
1674
1674
|
workerPhasesByJob.delete(job);
|
|
1675
1675
|
}
|
|
1676
|
-
var
|
|
1677
|
-
function
|
|
1678
|
-
|
|
1676
|
+
var captureActivityByJob = /* @__PURE__ */ new WeakMap();
|
|
1677
|
+
function noteCaptureActivity(job) {
|
|
1678
|
+
captureActivityByJob.set(job, (captureActivityByJob.get(job) ?? 0) + 1);
|
|
1679
1679
|
}
|
|
1680
|
-
function
|
|
1681
|
-
return
|
|
1680
|
+
function captureActivity(job) {
|
|
1681
|
+
return captureActivityByJob.get(job) ?? 0;
|
|
1682
1682
|
}
|
|
1683
1683
|
function describeWorkerPhases(job) {
|
|
1684
1684
|
const phases = workerPhasesByJob.get(job);
|
|
@@ -6287,7 +6287,8 @@ async function extractDeferredFrames(input) {
|
|
|
6287
6287
|
outputDir: input.outputRoot,
|
|
6288
6288
|
format: range.format,
|
|
6289
6289
|
frameRanges: contiguousRuns(indexes),
|
|
6290
|
-
shownBox: input.shownBoxes?.get(video.videoId)
|
|
6290
|
+
shownBox: input.shownBoxes?.get(video.videoId),
|
|
6291
|
+
...input.onProgress && { onProgress: input.onProgress }
|
|
6291
6292
|
},
|
|
6292
6293
|
input.signal,
|
|
6293
6294
|
input.cfg
|
|
@@ -7147,14 +7148,20 @@ function countAuthoredTimedClips(html) {
|
|
|
7147
7148
|
}
|
|
7148
7149
|
|
|
7149
7150
|
// src/services/render/stages/compileStage.ts
|
|
7150
|
-
import { existsSync as
|
|
7151
|
-
import { join as
|
|
7151
|
+
import { existsSync as existsSync13, writeFileSync as writeFileSync4 } from "node:fs";
|
|
7152
|
+
import { join as join23, relative as relative4 } from "node:path";
|
|
7152
7153
|
import { privateCacheRoot } from "@hyperframes/engine";
|
|
7153
7154
|
import { suggestMatchingPreset } from "@hyperframes/core";
|
|
7154
7155
|
import { extractStandaloneEntryFromIndex, isTemplateEntry } from "@hyperframes/core/compiler";
|
|
7155
7156
|
import { readTextFile as readTextFile2 } from "@hyperframes/parsers/asset-resolution";
|
|
7156
7157
|
import { assertCompositionFileSize as assertCompositionFileSize2 } from "@hyperframes/core/compiler";
|
|
7157
7158
|
|
|
7159
|
+
// src/services/compileInWorker.ts
|
|
7160
|
+
import { existsSync as existsSync12 } from "node:fs";
|
|
7161
|
+
import { dirname as dirname10, join as join22 } from "node:path";
|
|
7162
|
+
import { fileURLToPath as fileURLToPath3 } from "node:url";
|
|
7163
|
+
import { Worker } from "node:worker_threads";
|
|
7164
|
+
|
|
7158
7165
|
// src/services/htmlCompiler.ts
|
|
7159
7166
|
import { decodedUrlPath } from "@hyperframes/parsers/asset-paths";
|
|
7160
7167
|
import {
|
|
@@ -10467,11 +10474,119 @@ async function recompileWithResolutions(compiled, resolutions, projectDir, downl
|
|
|
10467
10474
|
};
|
|
10468
10475
|
}
|
|
10469
10476
|
|
|
10477
|
+
// src/services/compileInWorker.ts
|
|
10478
|
+
var DEFAULT_COMPILE_TIMEOUT_MS = 10 * 60 * 1e3;
|
|
10479
|
+
var TERMINATE_GRACE_MS = 2e3;
|
|
10480
|
+
var ADVISORY_GRACE_MS = 3e4;
|
|
10481
|
+
var MAX_TIMER_MS = 2 ** 31 - 1;
|
|
10482
|
+
var CompileTimeoutError = class extends Error {
|
|
10483
|
+
code = "COMPILE_TIMEOUT";
|
|
10484
|
+
owner = "user";
|
|
10485
|
+
retryable = false;
|
|
10486
|
+
publicMetadata;
|
|
10487
|
+
constructor(timeoutMs) {
|
|
10488
|
+
super(
|
|
10489
|
+
`Compiling the composition took longer than ${Math.round(timeoutMs / 1e3)} s, so it was stopped. Very large pages, or pages with very many style rules or media tags, are the usual cause.`
|
|
10490
|
+
);
|
|
10491
|
+
this.name = "CompileTimeoutError";
|
|
10492
|
+
this.publicMetadata = { timeoutMs };
|
|
10493
|
+
}
|
|
10494
|
+
};
|
|
10495
|
+
function compileTimeoutMs() {
|
|
10496
|
+
const fromEnv = Number(process.env.HYPERFRAMES_COMPILE_TIMEOUT_MS);
|
|
10497
|
+
return Number.isInteger(fromEnv) && fromEnv > 0 ? Math.min(fromEnv, MAX_TIMER_MS) : DEFAULT_COMPILE_TIMEOUT_MS;
|
|
10498
|
+
}
|
|
10499
|
+
var warnedMissingEntry = false;
|
|
10500
|
+
function resolveCompileWorkerEntry(explicit, log) {
|
|
10501
|
+
if (explicit) return explicit;
|
|
10502
|
+
const fromEnv = process.env.HF_COMPILE_WORKER_ENTRY;
|
|
10503
|
+
if (fromEnv) {
|
|
10504
|
+
if (existsSync12(fromEnv)) return fromEnv;
|
|
10505
|
+
if (!warnedMissingEntry) {
|
|
10506
|
+
warnedMissingEntry = true;
|
|
10507
|
+
log?.warn(
|
|
10508
|
+
"[Compiler] HF_COMPILE_WORKER_ENTRY names a missing file, so compiles run on the main thread with no deadline",
|
|
10509
|
+
{ entry: fromEnv }
|
|
10510
|
+
);
|
|
10511
|
+
}
|
|
10512
|
+
return void 0;
|
|
10513
|
+
}
|
|
10514
|
+
const sibling = join22(dirname10(fileURLToPath3(import.meta.url)), "compileWorker.js");
|
|
10515
|
+
return existsSync12(sibling) ? sibling : void 0;
|
|
10516
|
+
}
|
|
10517
|
+
function rebuildError({ name, message, stack, props }) {
|
|
10518
|
+
const error = Object.assign(new Error(message), props);
|
|
10519
|
+
error.name = name;
|
|
10520
|
+
if (stack) error.stack = stack;
|
|
10521
|
+
return error;
|
|
10522
|
+
}
|
|
10523
|
+
async function compileForRenderInWorker(projectDir, htmlPath, downloadDir, options = {}, worker = {}) {
|
|
10524
|
+
const { log, abortSignal, ...cloneable } = options;
|
|
10525
|
+
const entry = resolveCompileWorkerEntry(worker.entry, log);
|
|
10526
|
+
if (!entry) return compileForRender(projectDir, htmlPath, downloadDir, options);
|
|
10527
|
+
abortSignal?.throwIfAborted();
|
|
10528
|
+
const timeoutMs = worker.timeoutMs ?? compileTimeoutMs();
|
|
10529
|
+
return new Promise((resolve12, reject) => {
|
|
10530
|
+
const thread = new Worker(entry, {
|
|
10531
|
+
workerData: { projectDir, htmlPath, downloadDir, options: cloneable }
|
|
10532
|
+
});
|
|
10533
|
+
let settled = false;
|
|
10534
|
+
const settle = (finish) => {
|
|
10535
|
+
if (settled) return;
|
|
10536
|
+
settled = true;
|
|
10537
|
+
clearTimeout(timer);
|
|
10538
|
+
abortSignal?.removeEventListener("abort", onAbort);
|
|
10539
|
+
finish();
|
|
10540
|
+
};
|
|
10541
|
+
const stop = () => {
|
|
10542
|
+
thread.postMessage({ type: "abort" });
|
|
10543
|
+
setTimeout(() => void thread.terminate(), TERMINATE_GRACE_MS).unref();
|
|
10544
|
+
};
|
|
10545
|
+
const timer = setTimeout(() => {
|
|
10546
|
+
stop();
|
|
10547
|
+
settle(() => reject(new CompileTimeoutError(timeoutMs)));
|
|
10548
|
+
}, timeoutMs);
|
|
10549
|
+
const onAbort = () => {
|
|
10550
|
+
stop();
|
|
10551
|
+
settle(() => reject(abortSignal?.reason ?? new Error("Compile aborted")));
|
|
10552
|
+
};
|
|
10553
|
+
abortSignal?.addEventListener("abort", onAbort, { once: true });
|
|
10554
|
+
const retire = (graceMs) => {
|
|
10555
|
+
thread.unref();
|
|
10556
|
+
setTimeout(() => void thread.terminate(), graceMs).unref();
|
|
10557
|
+
};
|
|
10558
|
+
thread.on(
|
|
10559
|
+
"message",
|
|
10560
|
+
(message) => {
|
|
10561
|
+
if (message.type === "log" && message.level) {
|
|
10562
|
+
log?.[message.level](message.message ?? "", message.meta);
|
|
10563
|
+
} else if (message.type === "result" && message.compiled) {
|
|
10564
|
+
const { compiled } = message;
|
|
10565
|
+
settle(() => resolve12(compiled));
|
|
10566
|
+
retire(ADVISORY_GRACE_MS);
|
|
10567
|
+
} else if (message.type === "error" && message.error) {
|
|
10568
|
+
const { error } = message;
|
|
10569
|
+
settle(() => reject(rebuildError(error)));
|
|
10570
|
+
thread.postMessage({ type: "abort" });
|
|
10571
|
+
retire(TERMINATE_GRACE_MS);
|
|
10572
|
+
}
|
|
10573
|
+
}
|
|
10574
|
+
);
|
|
10575
|
+
thread.on("error", (error) => settle(() => reject(error)));
|
|
10576
|
+
thread.on(
|
|
10577
|
+
"exit",
|
|
10578
|
+
(code) => settle(
|
|
10579
|
+
() => reject(new Error(`The compile worker exited with code ${code} before answering`))
|
|
10580
|
+
)
|
|
10581
|
+
);
|
|
10582
|
+
});
|
|
10583
|
+
}
|
|
10584
|
+
|
|
10470
10585
|
// src/services/render/stages/compileStage.ts
|
|
10471
10586
|
function animatedGifCacheDir(extractCacheDir) {
|
|
10472
10587
|
try {
|
|
10473
10588
|
const root = extractCacheDir && privateCacheRoot(extractCacheDir);
|
|
10474
|
-
return root ?
|
|
10589
|
+
return root ? join23(root, "animated-gif") : void 0;
|
|
10475
10590
|
} catch {
|
|
10476
10591
|
return void 0;
|
|
10477
10592
|
}
|
|
@@ -10499,11 +10614,11 @@ function resolveEntryHtmlPath(input) {
|
|
|
10499
10614
|
assertCompositionFileSize2(path, relative4(projectDir, path));
|
|
10500
10615
|
return readTextFile2(path);
|
|
10501
10616
|
};
|
|
10502
|
-
const htmlPath =
|
|
10617
|
+
const htmlPath = join23(projectDir, entryFile);
|
|
10503
10618
|
const rawEntry = readEntry(htmlPath);
|
|
10504
10619
|
if (entryFile === "index.html" || !isTemplateEntry(rawEntry)) return htmlPath;
|
|
10505
|
-
const projectIndexPath =
|
|
10506
|
-
if (!
|
|
10620
|
+
const projectIndexPath = join23(projectDir, "index.html");
|
|
10621
|
+
if (!existsSync13(projectIndexPath)) {
|
|
10507
10622
|
throw new Error(
|
|
10508
10623
|
`Template entry file "${entryFile}" requires a project index.html to extract its render shell.`
|
|
10509
10624
|
);
|
|
@@ -10518,7 +10633,7 @@ function resolveEntryHtmlPath(input) {
|
|
|
10518
10633
|
`Entry file "${entryFile}" is not mounted from index.html via data-composition-src, so it cannot be rendered independently.`
|
|
10519
10634
|
);
|
|
10520
10635
|
}
|
|
10521
|
-
const wrapperPath =
|
|
10636
|
+
const wrapperPath = join23(workDir, "standalone-entry.html");
|
|
10522
10637
|
writeFileSync4(wrapperPath, standaloneHtml, "utf-8");
|
|
10523
10638
|
log.info("Extracted standalone entry from index.html host context", { entryFile });
|
|
10524
10639
|
return wrapperPath;
|
|
@@ -10548,19 +10663,24 @@ async function runCompileStage(input) {
|
|
|
10548
10663
|
const assetRoot = job.config.allowOutsideProjectAssets ? void 0 : projectDir;
|
|
10549
10664
|
const htmlPath = resolveEntryHtmlPath({ projectDir, workDir, entryFile, log, assetRoot });
|
|
10550
10665
|
const compileStart = Date.now();
|
|
10551
|
-
const compiled = await
|
|
10552
|
-
|
|
10553
|
-
|
|
10554
|
-
|
|
10555
|
-
|
|
10556
|
-
|
|
10557
|
-
|
|
10558
|
-
|
|
10559
|
-
|
|
10560
|
-
|
|
10561
|
-
|
|
10562
|
-
|
|
10563
|
-
|
|
10666
|
+
const compiled = await compileForRenderInWorker(
|
|
10667
|
+
projectDir,
|
|
10668
|
+
htmlPath,
|
|
10669
|
+
join23(workDir, "downloads"),
|
|
10670
|
+
{
|
|
10671
|
+
log,
|
|
10672
|
+
failClosedFontFetch: failClosedFontFetch === true,
|
|
10673
|
+
allowSystemFontCapture,
|
|
10674
|
+
abortSignal,
|
|
10675
|
+
variables: input.variables,
|
|
10676
|
+
urlByAbsentLocalPath: input.urlByAbsentLocalPath,
|
|
10677
|
+
pageMotionBlur: input.pageMotionBlur,
|
|
10678
|
+
animatedGifCacheDir: animatedGifCacheDir(cfg.extractCacheDir),
|
|
10679
|
+
ffmpegProcessTimeout: cfg.ffmpegProcessTimeout,
|
|
10680
|
+
allowOutsideProjectAssets: job.config.allowOutsideProjectAssets,
|
|
10681
|
+
includeOutsideScripts: job.config.includeOutsideScripts
|
|
10682
|
+
}
|
|
10683
|
+
);
|
|
10564
10684
|
assertNotAborted();
|
|
10565
10685
|
const compileOnlyMs = Date.now() - compileStart;
|
|
10566
10686
|
let deCompileGate;
|
|
@@ -10623,7 +10743,7 @@ async function runCompileStage(input) {
|
|
|
10623
10743
|
});
|
|
10624
10744
|
await preflightCompositionAssetMediaTypes({
|
|
10625
10745
|
projectDir,
|
|
10626
|
-
compiledDir:
|
|
10746
|
+
compiledDir: join23(workDir, "compiled"),
|
|
10627
10747
|
composition,
|
|
10628
10748
|
signal: abortSignal
|
|
10629
10749
|
});
|
|
@@ -10671,7 +10791,7 @@ async function runCompileStage(input) {
|
|
|
10671
10791
|
|
|
10672
10792
|
// src/services/render/stages/probeStage.ts
|
|
10673
10793
|
import { createHash as createHash7 } from "node:crypto";
|
|
10674
|
-
import { basename as basename7, join as
|
|
10794
|
+
import { basename as basename7, join as join24 } from "node:path";
|
|
10675
10795
|
import { parseHTML as parseHTML6 } from "linkedom";
|
|
10676
10796
|
import {
|
|
10677
10797
|
closeCaptureSession as closeCaptureSession4,
|
|
@@ -11025,7 +11145,7 @@ async function runProbeStage(input) {
|
|
|
11025
11145
|
});
|
|
11026
11146
|
fileServer = await createFileServer({
|
|
11027
11147
|
projectDir,
|
|
11028
|
-
compiledDir:
|
|
11148
|
+
compiledDir: join24(workDir, "compiled"),
|
|
11029
11149
|
port: 0,
|
|
11030
11150
|
preHeadScripts: [VIRTUAL_TIME_SHIM],
|
|
11031
11151
|
fps: job.config.fps,
|
|
@@ -11039,7 +11159,7 @@ async function runProbeStage(input) {
|
|
|
11039
11159
|
composition.videos,
|
|
11040
11160
|
compiled.html,
|
|
11041
11161
|
projectDir,
|
|
11042
|
-
|
|
11162
|
+
join24(workDir, "compiled")
|
|
11043
11163
|
),
|
|
11044
11164
|
recordReferenceBackground: input.recordReferenceBackground,
|
|
11045
11165
|
width,
|
|
@@ -11059,7 +11179,7 @@ async function runProbeStage(input) {
|
|
|
11059
11179
|
staticDedupMemo,
|
|
11060
11180
|
compositionHash: computeCompositionObservabilityHash(compiled.html),
|
|
11061
11181
|
deferStaticDedup: true,
|
|
11062
|
-
onStaticDedupActivity: () =>
|
|
11182
|
+
onStaticDedupActivity: () => noteCaptureActivity(job)
|
|
11063
11183
|
};
|
|
11064
11184
|
const PROBE_MAX_ATTEMPTS = 2;
|
|
11065
11185
|
for (let attempt = 1; attempt <= PROBE_MAX_ATTEMPTS; attempt++) {
|
|
@@ -11068,7 +11188,7 @@ async function runProbeStage(input) {
|
|
|
11068
11188
|
log.info("Creating capture session...", { attempt, maxAttempts: PROBE_MAX_ATTEMPTS });
|
|
11069
11189
|
probeSession = await createCaptureSession4(
|
|
11070
11190
|
fileServer.url,
|
|
11071
|
-
|
|
11191
|
+
join24(workDir, "probe"),
|
|
11072
11192
|
captureOpts,
|
|
11073
11193
|
null,
|
|
11074
11194
|
probeCfg
|
|
@@ -11154,7 +11274,7 @@ async function runProbeStage(input) {
|
|
|
11154
11274
|
});
|
|
11155
11275
|
probeSession = await createCaptureSession4(
|
|
11156
11276
|
fileServer.url,
|
|
11157
|
-
|
|
11277
|
+
join24(workDir, "probe-screenshot"),
|
|
11158
11278
|
captureOpts,
|
|
11159
11279
|
null,
|
|
11160
11280
|
{ ...probeCfg, forceScreenshot: true }
|
|
@@ -11198,7 +11318,7 @@ async function runProbeStage(input) {
|
|
|
11198
11318
|
compiled,
|
|
11199
11319
|
resolutions,
|
|
11200
11320
|
projectDir,
|
|
11201
|
-
|
|
11321
|
+
join24(workDir, "downloads"),
|
|
11202
11322
|
job.config.allowOutsideProjectAssets ? void 0 : projectDir,
|
|
11203
11323
|
{ includeScripts: job.config.includeOutsideScripts }
|
|
11204
11324
|
);
|
|
@@ -11404,7 +11524,7 @@ async function runProbeStage(input) {
|
|
|
11404
11524
|
});
|
|
11405
11525
|
await preflightCompositionAssetMediaTypes({
|
|
11406
11526
|
projectDir,
|
|
11407
|
-
compiledDir:
|
|
11527
|
+
compiledDir: join24(workDir, "compiled"),
|
|
11408
11528
|
composition,
|
|
11409
11529
|
signal: abortSignal
|
|
11410
11530
|
});
|
|
@@ -11539,8 +11659,8 @@ function validateRenderDuration(input) {
|
|
|
11539
11659
|
}
|
|
11540
11660
|
|
|
11541
11661
|
// src/services/render/stages/extractVideosStage.ts
|
|
11542
|
-
import { existsSync as
|
|
11543
|
-
import { join as
|
|
11662
|
+
import { existsSync as existsSync14 } from "node:fs";
|
|
11663
|
+
import { join as join25 } from "node:path";
|
|
11544
11664
|
import {
|
|
11545
11665
|
classifyVideoExtractionError,
|
|
11546
11666
|
createFrameLookupTable as createFrameLookupTable3,
|
|
@@ -11905,7 +12025,7 @@ async function runExtractVideosStage(input) {
|
|
|
11905
12025
|
// because short boundary counts can differ by one frame.
|
|
11906
12026
|
{
|
|
11907
12027
|
fps: job.config.fps,
|
|
11908
|
-
outputDir:
|
|
12028
|
+
outputDir: join25(compiledDir, "__hyperframes_video_frames"),
|
|
11909
12029
|
format: job.config.videoFrameFormat ?? "auto",
|
|
11910
12030
|
toneMapHdrToSdr: rendersSdrOnly(job.config, composition),
|
|
11911
12031
|
timelineEnd: composition.duration,
|
|
@@ -11913,7 +12033,7 @@ async function runExtractVideosStage(input) {
|
|
|
11913
12033
|
collectProbeFailures: extractionPolicy.failureMode === "enforce",
|
|
11914
12034
|
deferRangeExtraction,
|
|
11915
12035
|
shownBoxes,
|
|
11916
|
-
contentKeyedDirs: [
|
|
12036
|
+
contentKeyedDirs: [join25(compiledDir, REMOTE_MEDIA_SUBDIR)],
|
|
11917
12037
|
urlByAbsentLocalPath,
|
|
11918
12038
|
assetRoots,
|
|
11919
12039
|
onProgress: ({ planned = 0, done = 0 }) => {
|
|
@@ -11993,7 +12113,7 @@ function isPublicHttpsUrl(url) {
|
|
|
11993
12113
|
}
|
|
11994
12114
|
}
|
|
11995
12115
|
function opensLocally(path, assetRoots) {
|
|
11996
|
-
return
|
|
12116
|
+
return existsSync14(path) && (!assetRoots || assetRootsRefusal(path, assetRoots) === null);
|
|
11997
12117
|
}
|
|
11998
12118
|
function localProbeSource(src, input) {
|
|
11999
12119
|
const path = resolveProjectRelativeSrc5(src, input.projectDir, input.compiledDir);
|
|
@@ -12005,7 +12125,7 @@ async function remoteProbeSource(video, input) {
|
|
|
12005
12125
|
if (!isPublicHttpsUrl(video.src)) return null;
|
|
12006
12126
|
if (!resolveRestrictPageNetwork()) return video.src;
|
|
12007
12127
|
if (!video.hasAudio || video.hidden) return null;
|
|
12008
|
-
const downloadDir = input.downloadDir ??
|
|
12128
|
+
const downloadDir = input.downloadDir ?? join25(input.compiledDir, REMOTE_MEDIA_SUBDIR);
|
|
12009
12129
|
try {
|
|
12010
12130
|
return await downloadToTemp2(video.src, downloadDir, void 0, input.signal, void 0, {
|
|
12011
12131
|
onTelemetry: writeUrlDownloadTelemetry2
|
|
@@ -12046,7 +12166,7 @@ async function appendVideoAudioFromProbe(input) {
|
|
|
12046
12166
|
}
|
|
12047
12167
|
|
|
12048
12168
|
// src/services/render/videoLayerPassthroughPlan.ts
|
|
12049
|
-
import { existsSync as
|
|
12169
|
+
import { existsSync as existsSync15 } from "node:fs";
|
|
12050
12170
|
import {
|
|
12051
12171
|
buildVideoLayerInput,
|
|
12052
12172
|
isHttpUrl as isHttpUrl4,
|
|
@@ -12114,7 +12234,7 @@ async function planVideoLayerPassthrough(input) {
|
|
|
12114
12234
|
const { video } = q;
|
|
12115
12235
|
if (isHttpUrl4(video.src)) return { reason: "remote_source" };
|
|
12116
12236
|
const path = resolveProjectRelativeSrc6(video.src, input.projectDir, input.compiledDir);
|
|
12117
|
-
if (!
|
|
12237
|
+
if (!existsSync15(path)) return { reason: "source_missing" };
|
|
12118
12238
|
const layout = await probeVideoLayout(input.page, video.id, input.canvas, input.duration);
|
|
12119
12239
|
if ("reason" in layout) return layout;
|
|
12120
12240
|
const layer = await buildVideoLayerInput(
|
|
@@ -12129,8 +12249,8 @@ async function planVideoLayerPassthrough(input) {
|
|
|
12129
12249
|
}
|
|
12130
12250
|
|
|
12131
12251
|
// src/services/render/stages/audioStage.ts
|
|
12132
|
-
import { existsSync as
|
|
12133
|
-
import { join as
|
|
12252
|
+
import { existsSync as existsSync17 } from "node:fs";
|
|
12253
|
+
import { join as join28 } from "node:path";
|
|
12134
12254
|
import {
|
|
12135
12255
|
MIXED_AUDIO_FILENAME,
|
|
12136
12256
|
audioFailureDiagnostics,
|
|
@@ -12141,8 +12261,8 @@ import {
|
|
|
12141
12261
|
} from "@hyperframes/engine";
|
|
12142
12262
|
|
|
12143
12263
|
// src/services/render/audioDeliveryLimit.ts
|
|
12144
|
-
import { existsSync as
|
|
12145
|
-
import { dirname as
|
|
12264
|
+
import { existsSync as existsSync16 } from "node:fs";
|
|
12265
|
+
import { dirname as dirname12, join as join27 } from "node:path";
|
|
12146
12266
|
import {
|
|
12147
12267
|
applyAudioFxChain,
|
|
12148
12268
|
describeFfmpegFailure as describeFfmpegFailure3,
|
|
@@ -12153,7 +12273,7 @@ import {
|
|
|
12153
12273
|
// src/services/render/audioPadTrim.ts
|
|
12154
12274
|
import { localContainerInputArgs } from "@hyperframes/parsers/ff-binaries";
|
|
12155
12275
|
import { spawn } from "node:child_process";
|
|
12156
|
-
import { dirname as
|
|
12276
|
+
import { dirname as dirname11, join as join26 } from "node:path";
|
|
12157
12277
|
import {
|
|
12158
12278
|
DEFAULT_CONFIG,
|
|
12159
12279
|
describeFfmpegFailure as describeFfmpegFailure2,
|
|
@@ -12434,7 +12554,7 @@ async function constrainAacTruePeak(input) {
|
|
|
12434
12554
|
}
|
|
12435
12555
|
async function cutSource(input, scratchDir, attenuationDb) {
|
|
12436
12556
|
if (!input.sourcePath || !input.rewriteSource) return true;
|
|
12437
|
-
const cutPath =
|
|
12557
|
+
const cutPath = join26(scratchDir, "source.wav");
|
|
12438
12558
|
try {
|
|
12439
12559
|
const result = await input.rewriteSource(input.sourcePath, cutPath, gainFilter(attenuationDb));
|
|
12440
12560
|
if (!result.success) throw new Error(result.error);
|
|
@@ -12448,8 +12568,8 @@ async function cutSource(input, scratchDir, attenuationDb) {
|
|
|
12448
12568
|
async function enforceAacTruePeak(input) {
|
|
12449
12569
|
let scratchDir;
|
|
12450
12570
|
try {
|
|
12451
|
-
scratchDir = createStagingDir3(
|
|
12452
|
-
const correctedPath =
|
|
12571
|
+
scratchDir = createStagingDir3(dirname11(input.audioPath), ".true-peak-");
|
|
12572
|
+
const correctedPath = join26(scratchDir, "audio.m4a");
|
|
12453
12573
|
const measurements = [];
|
|
12454
12574
|
let attenuationDb = 0;
|
|
12455
12575
|
let sourcePeakDbfs;
|
|
@@ -12665,14 +12785,14 @@ async function limitDeliveryPeaks(input, deps = {
|
|
|
12665
12785
|
applyChain: applyAudioFxChain,
|
|
12666
12786
|
encode: encodeAac2,
|
|
12667
12787
|
rename: renameWithRetry5,
|
|
12668
|
-
sourceExists:
|
|
12788
|
+
sourceExists: existsSync16
|
|
12669
12789
|
}) {
|
|
12670
12790
|
const { audioPath, sourcePath, signal, timeoutMs } = input;
|
|
12671
12791
|
if (!deps.sourceExists(sourcePath)) return { success: true };
|
|
12672
12792
|
const peak = await deps.measure(audioPath, { timeoutMs, signal });
|
|
12673
12793
|
if (peak <= AAC_DELIVERY_TRUE_PEAK_DBFS) return { success: true };
|
|
12674
12794
|
const alternating = ["a", "b"].map(
|
|
12675
|
-
(k) =>
|
|
12795
|
+
(k) => join27(dirname12(sourcePath), `audio-source-limited-${k}.wav`)
|
|
12676
12796
|
);
|
|
12677
12797
|
let encodedFrom;
|
|
12678
12798
|
let ceiling = AAC_DELIVERY_TRUE_PEAK_DBFS;
|
|
@@ -12745,7 +12865,7 @@ function runAudioStage(input) {
|
|
|
12745
12865
|
}
|
|
12746
12866
|
async function runAudioStageScoped(input) {
|
|
12747
12867
|
const stageStart = Date.now();
|
|
12748
|
-
const pcmSourcePath =
|
|
12868
|
+
const pcmSourcePath = join28(input.workDir, "audio-source.wav");
|
|
12749
12869
|
const duration = input.totalFrames * input.fps.den / input.fps.num;
|
|
12750
12870
|
let deliverySourcePath;
|
|
12751
12871
|
try {
|
|
@@ -12761,7 +12881,7 @@ async function runAudioStageScoped(input) {
|
|
|
12761
12881
|
);
|
|
12762
12882
|
audioLoweredDb = guard.loweredDb;
|
|
12763
12883
|
input.log?.info("[audio] phases", { ...result.audioPhaseMs, guard: Date.now() - guardStart });
|
|
12764
|
-
if (input.keepDeliverySource && !guard.sourceStale &&
|
|
12884
|
+
if (input.keepDeliverySource && !guard.sourceStale && existsSync17(pcmSourcePath)) {
|
|
12765
12885
|
deliverySourcePath = pcmSourcePath;
|
|
12766
12886
|
}
|
|
12767
12887
|
}
|
|
@@ -12810,7 +12930,7 @@ async function mixAudioForDelivery(input, duration, pcmSourcePath) {
|
|
|
12810
12930
|
assertNotAborted,
|
|
12811
12931
|
log
|
|
12812
12932
|
} = input;
|
|
12813
|
-
const audioOutputPath =
|
|
12933
|
+
const audioOutputPath = join28(workDir, MIXED_AUDIO_FILENAME);
|
|
12814
12934
|
let hasAudio = false;
|
|
12815
12935
|
let audioError;
|
|
12816
12936
|
let audioFailures;
|
|
@@ -12890,8 +13010,8 @@ async function mixAudioForDelivery(input, duration, pcmSourcePath) {
|
|
|
12890
13010
|
}
|
|
12891
13011
|
|
|
12892
13012
|
// src/services/render/stages/captureStage.ts
|
|
12893
|
-
import { existsSync as
|
|
12894
|
-
import { join as
|
|
13013
|
+
import { existsSync as existsSync18, readdirSync as readdirSync4, statfsSync as statfsSync2 } from "node:fs";
|
|
13014
|
+
import { join as join29 } from "node:path";
|
|
12895
13015
|
import {
|
|
12896
13016
|
classifyCaptureFailure as classifyCaptureFailure2,
|
|
12897
13017
|
frameFileExtension,
|
|
@@ -12961,16 +13081,16 @@ function diskCaptureShortfallError(needBytes, freeBytes, framesDir, basis, remed
|
|
|
12961
13081
|
}
|
|
12962
13082
|
function measureCaptureFrameBytes(workDir, framesDir) {
|
|
12963
13083
|
let total = sampleDirectoryBytes(framesDir);
|
|
12964
|
-
if (!
|
|
13084
|
+
if (!existsSync18(workDir)) return total;
|
|
12965
13085
|
for (const attempt of readdirSync4(workDir)) {
|
|
12966
13086
|
if (/^retry-\d+-batch-\d+-worker-\d+$/.test(attempt)) {
|
|
12967
|
-
total += sampleDirectoryBytes(
|
|
13087
|
+
total += sampleDirectoryBytes(join29(workDir, attempt));
|
|
12968
13088
|
continue;
|
|
12969
13089
|
}
|
|
12970
13090
|
if (!/^capture-attempt-\d+$/.test(attempt)) continue;
|
|
12971
|
-
const attemptDir =
|
|
13091
|
+
const attemptDir = join29(workDir, attempt);
|
|
12972
13092
|
for (const name of readdirSync4(attemptDir)) {
|
|
12973
|
-
if (/^worker-\d+$/.test(name)) total += sampleDirectoryBytes(
|
|
13093
|
+
if (/^worker-\d+$/.test(name)) total += sampleDirectoryBytes(join29(attemptDir, name));
|
|
12974
13094
|
}
|
|
12975
13095
|
}
|
|
12976
13096
|
return total;
|
|
@@ -13268,8 +13388,8 @@ async function captureSessionFrames(session, { input, rangeStart, rangeEnd, resu
|
|
|
13268
13388
|
}
|
|
13269
13389
|
|
|
13270
13390
|
// src/services/render/stages/captureHdrStage.ts
|
|
13271
|
-
import { existsSync as
|
|
13272
|
-
import { join as
|
|
13391
|
+
import { existsSync as existsSync20, mkdirSync as mkdirSync10 } from "node:fs";
|
|
13392
|
+
import { join as join33 } from "node:path";
|
|
13273
13393
|
import {
|
|
13274
13394
|
closeCaptureSession as closeCaptureSession7,
|
|
13275
13395
|
cloneCaptureWarnings as cloneCaptureWarnings2,
|
|
@@ -13341,7 +13461,7 @@ function createHdrImageTransferCache(options = {}) {
|
|
|
13341
13461
|
}
|
|
13342
13462
|
|
|
13343
13463
|
// src/services/render/stages/captureHdrSequentialLoop.ts
|
|
13344
|
-
import { join as
|
|
13464
|
+
import { join as join30 } from "node:path";
|
|
13345
13465
|
import {
|
|
13346
13466
|
TRANSITIONS,
|
|
13347
13467
|
crossfade
|
|
@@ -13466,7 +13586,7 @@ async function runSequentialLayeredFrameLoop(input) {
|
|
|
13466
13586
|
);
|
|
13467
13587
|
if (debugDumpEnabled && debugDumpDir && i % 30 === 0) {
|
|
13468
13588
|
writeFileExclusiveSync(
|
|
13469
|
-
|
|
13589
|
+
join30(debugDumpDir, `frame_${String(i).padStart(4, "0")}_final_rgb48le.bin`),
|
|
13470
13590
|
normalCanvas
|
|
13471
13591
|
);
|
|
13472
13592
|
}
|
|
@@ -13498,7 +13618,7 @@ async function runSequentialLayeredFrameLoop(input) {
|
|
|
13498
13618
|
}
|
|
13499
13619
|
|
|
13500
13620
|
// src/services/render/stages/captureHdrHybridLoop.ts
|
|
13501
|
-
import { join as
|
|
13621
|
+
import { join as join32 } from "node:path";
|
|
13502
13622
|
import {
|
|
13503
13623
|
TRANSITIONS as TRANSITIONS2,
|
|
13504
13624
|
closeCaptureSession as closeCaptureSession6,
|
|
@@ -13510,12 +13630,12 @@ import {
|
|
|
13510
13630
|
} from "@hyperframes/engine";
|
|
13511
13631
|
|
|
13512
13632
|
// src/services/shaderTransitionWorkerPool.ts
|
|
13513
|
-
import { Worker } from "node:worker_threads";
|
|
13514
|
-
import { fileURLToPath as
|
|
13515
|
-
import { dirname as
|
|
13633
|
+
import { Worker as Worker2 } from "node:worker_threads";
|
|
13634
|
+
import { fileURLToPath as fileURLToPath4, pathToFileURL } from "node:url";
|
|
13635
|
+
import { dirname as dirname13, join as join31 } from "node:path";
|
|
13516
13636
|
import { createRequire } from "node:module";
|
|
13517
13637
|
import { usableCpuCount } from "@hyperframes/engine";
|
|
13518
|
-
import { existsSync as
|
|
13638
|
+
import { existsSync as existsSync19 } from "node:fs";
|
|
13519
13639
|
function resolveWorkerEntry(explicit) {
|
|
13520
13640
|
if (explicit && explicit.length > 0) {
|
|
13521
13641
|
return { path: explicit, isTs: explicit.endsWith(".ts") };
|
|
@@ -13525,10 +13645,10 @@ function resolveWorkerEntry(explicit) {
|
|
|
13525
13645
|
const isTs = override.endsWith(".ts");
|
|
13526
13646
|
return { path: override, isTs };
|
|
13527
13647
|
}
|
|
13528
|
-
const moduleDir =
|
|
13529
|
-
const jsPath =
|
|
13530
|
-
if (
|
|
13531
|
-
const tsPath =
|
|
13648
|
+
const moduleDir = dirname13(fileURLToPath4(import.meta.url));
|
|
13649
|
+
const jsPath = join31(moduleDir, "shaderTransitionWorker.js");
|
|
13650
|
+
if (existsSync19(jsPath)) return { path: jsPath, isTs: false };
|
|
13651
|
+
const tsPath = join31(moduleDir, "shaderTransitionWorker.ts");
|
|
13532
13652
|
return { path: tsPath, isTs: true };
|
|
13533
13653
|
}
|
|
13534
13654
|
function buildExecArgv(entryIsTs) {
|
|
@@ -13649,7 +13769,7 @@ async function createShaderTransitionWorkerPool(opts) {
|
|
|
13649
13769
|
};
|
|
13650
13770
|
try {
|
|
13651
13771
|
for (let i = 0; i < size; i++) {
|
|
13652
|
-
const worker = new
|
|
13772
|
+
const worker = new Worker2(entry, { execArgv });
|
|
13653
13773
|
const slot = { worker, busy: false, current: null, dead: false };
|
|
13654
13774
|
worker.on("message", (msg) => onWorkerMessage(slot, msg));
|
|
13655
13775
|
worker.on(
|
|
@@ -13896,7 +14016,7 @@ async function runHybridLayeredFrameLoop(input) {
|
|
|
13896
14016
|
);
|
|
13897
14017
|
if (debugDumpEnabled && debugDumpDir && i % 30 === 0) {
|
|
13898
14018
|
writeFileExclusiveSync(
|
|
13899
|
-
|
|
14019
|
+
join32(debugDumpDir, `frame_${String(i).padStart(4, "0")}_final_rgb48le.bin`),
|
|
13900
14020
|
canvas
|
|
13901
14021
|
);
|
|
13902
14022
|
}
|
|
@@ -14092,8 +14212,8 @@ async function runCaptureHdrStage(input) {
|
|
|
14092
14212
|
if (hdrVideoFrameSources.has(v.id)) hdrVideoEndTimes.set(v.id, v.end);
|
|
14093
14213
|
}
|
|
14094
14214
|
const debugDumpEnabled = process.env.KEEP_TEMP === "1";
|
|
14095
|
-
const debugDumpDir = debugDumpEnabled ?
|
|
14096
|
-
if (debugDumpDir && !
|
|
14215
|
+
const debugDumpDir = debugDumpEnabled ? join33(framesDir, "debug-composite") : null;
|
|
14216
|
+
if (debugDumpDir && !existsSync20(debugDumpDir)) {
|
|
14097
14217
|
mkdirSync10(debugDumpDir, { recursive: true });
|
|
14098
14218
|
}
|
|
14099
14219
|
const compositeTransfer = resolveCompositeTransfer(hasHdrContent, effectiveHdr);
|
|
@@ -14252,7 +14372,7 @@ async function runCaptureHdrStage(input) {
|
|
|
14252
14372
|
// src/services/render/stages/encodeStage.ts
|
|
14253
14373
|
import {
|
|
14254
14374
|
copyFileSync as copyFileSync4,
|
|
14255
|
-
existsSync as
|
|
14375
|
+
existsSync as existsSync21,
|
|
14256
14376
|
mkdirSync as mkdirSync11,
|
|
14257
14377
|
readdirSync as readdirSync5,
|
|
14258
14378
|
readFileSync as readFileSync9,
|
|
@@ -14261,7 +14381,7 @@ import {
|
|
|
14261
14381
|
writeFileSync as writeFileSync5
|
|
14262
14382
|
} from "node:fs";
|
|
14263
14383
|
import { readFile as readFile2 } from "node:fs/promises";
|
|
14264
|
-
import { dirname as
|
|
14384
|
+
import { dirname as dirname14, join as join34 } from "node:path";
|
|
14265
14385
|
import {
|
|
14266
14386
|
encodeFramesChunkedConcat,
|
|
14267
14387
|
encodeFramesFromDir,
|
|
@@ -14386,7 +14506,7 @@ async function encodeGifFromDir(framesDir, framePattern, outputPath, input) {
|
|
|
14386
14506
|
const failure = await reencodeWithClearedWholeFrames(argsInput, run, startTime);
|
|
14387
14507
|
if (failure) return failure;
|
|
14388
14508
|
}
|
|
14389
|
-
const fileSize =
|
|
14509
|
+
const fileSize = existsSync21(outputPath) ? statSync9(outputPath).size : 0;
|
|
14390
14510
|
return {
|
|
14391
14511
|
success: true,
|
|
14392
14512
|
outputPath,
|
|
@@ -14480,7 +14600,7 @@ function encodeWhileCapturing(input, totalFrames, captureBudget) {
|
|
|
14480
14600
|
await new Promise((resolve12) => wake = resolve12);
|
|
14481
14601
|
}
|
|
14482
14602
|
if (signal.aborted) return;
|
|
14483
|
-
const mergedPath =
|
|
14603
|
+
const mergedPath = join34(input.framesDir, formatCaptureFrameName(next, "jpg"));
|
|
14484
14604
|
const frame = await readLandedFrame(landed.get(next), mergedPath);
|
|
14485
14605
|
landed.delete(next);
|
|
14486
14606
|
if (!await stream.writeFrame(frame)) {
|
|
@@ -14555,7 +14675,7 @@ async function runEncodeStage(input) {
|
|
|
14555
14675
|
const stage5Start = Date.now();
|
|
14556
14676
|
if (isPngSequence) {
|
|
14557
14677
|
const encoded = startEncodeProgress(job, "Writing PNG sequence", onProgress);
|
|
14558
|
-
if (!
|
|
14678
|
+
if (!existsSync21(outputPath)) mkdirSync11(outputPath, { recursive: true });
|
|
14559
14679
|
const captured = readdirSync5(framesDir).filter((name) => name.endsWith(".png")).sort();
|
|
14560
14680
|
if (captured.length === 0) {
|
|
14561
14681
|
throw new Error(
|
|
@@ -14563,11 +14683,11 @@ async function runEncodeStage(input) {
|
|
|
14563
14683
|
);
|
|
14564
14684
|
}
|
|
14565
14685
|
captured.forEach((name, i) => {
|
|
14566
|
-
const dst =
|
|
14567
|
-
copyFileSync4(
|
|
14686
|
+
const dst = join34(outputPath, formatExportFrameName(i, "png"));
|
|
14687
|
+
copyFileSync4(join34(framesDir, name), dst);
|
|
14568
14688
|
});
|
|
14569
|
-
if (hasAudio && audioOutputPath &&
|
|
14570
|
-
copyFileSync4(audioOutputPath,
|
|
14689
|
+
if (hasAudio && audioOutputPath && existsSync21(audioOutputPath)) {
|
|
14690
|
+
copyFileSync4(audioOutputPath, join34(outputPath, MIXED_AUDIO_FILENAME2));
|
|
14571
14691
|
log.info(
|
|
14572
14692
|
`[Render] png-sequence: ${MIXED_AUDIO_FILENAME2} sidecar written to ${outputPath}/${MIXED_AUDIO_FILENAME2}`
|
|
14573
14693
|
);
|
|
@@ -14587,7 +14707,7 @@ async function runEncodeStage(input) {
|
|
|
14587
14707
|
const encodeResult2 = await encodeGifFromDir(framesDir, framePattern2, outputPath, {
|
|
14588
14708
|
fps: job.config.fps,
|
|
14589
14709
|
loop,
|
|
14590
|
-
palettePath:
|
|
14710
|
+
palettePath: join34(dirname14(videoOnlyPath), "gif-palette.png"),
|
|
14591
14711
|
preserveAlpha: needsAlpha,
|
|
14592
14712
|
signal: abortSignal,
|
|
14593
14713
|
timeout: engineCfg.ffmpegEncodeTimeout
|
|
@@ -14798,7 +14918,7 @@ function sampleDirectoryBytes(dir) {
|
|
|
14798
14918
|
continue;
|
|
14799
14919
|
}
|
|
14800
14920
|
for (const name of entries) {
|
|
14801
|
-
const full =
|
|
14921
|
+
const full = join35(current, name);
|
|
14802
14922
|
try {
|
|
14803
14923
|
const st = statSync10(full);
|
|
14804
14924
|
if (st.isDirectory()) {
|
|
@@ -14956,8 +15076,8 @@ function findMissingFrameRanges(totalFrames, framesDir, frameExt) {
|
|
|
14956
15076
|
const ranges = [];
|
|
14957
15077
|
let rangeStart = null;
|
|
14958
15078
|
for (let frameIndex = 0; frameIndex < totalFrames; frameIndex++) {
|
|
14959
|
-
const framePath =
|
|
14960
|
-
const missing = !
|
|
15079
|
+
const framePath = join35(framesDir, formatCaptureFrameName(frameIndex, frameExt));
|
|
15080
|
+
const missing = !existsSync22(framePath) || statSync10(framePath).size <= 8;
|
|
14961
15081
|
if (missing && rangeStart === null) {
|
|
14962
15082
|
rangeStart = frameIndex;
|
|
14963
15083
|
} else if (!missing && rangeStart !== null) {
|
|
@@ -14973,7 +15093,7 @@ function findMissingFrameRanges(totalFrames, framesDir, frameExt) {
|
|
|
14973
15093
|
function buildMissingFrameRetryBatches(ranges, maxWorkers, workDir, attempt, rangeStart = 0, stride = 1) {
|
|
14974
15094
|
const workersPerBatch = Math.max(1, Math.floor(maxWorkers));
|
|
14975
15095
|
const batches = [];
|
|
14976
|
-
const outputDirFor = (batchIndex, workerId) =>
|
|
15096
|
+
const outputDirFor = (batchIndex, workerId) => join35(workDir, `retry-${attempt}-batch-${batchIndex}-worker-${workerId}`);
|
|
14977
15097
|
if (stride > 1) {
|
|
14978
15098
|
const spans = /* @__PURE__ */ new Map();
|
|
14979
15099
|
for (const range of ranges) {
|
|
@@ -15033,8 +15153,8 @@ function getNextRetryWorkerCount(currentWorkers) {
|
|
|
15033
15153
|
return Math.max(1, Math.floor(currentWorkers / 2));
|
|
15034
15154
|
}
|
|
15035
15155
|
function resolveRenderWorkDirPrefix(outputPath, jobId, platform2 = process.platform, systemTempDir = tmpdir3()) {
|
|
15036
|
-
if (platform2 === "win32" || platform2 === "darwin") return
|
|
15037
|
-
return
|
|
15156
|
+
if (platform2 === "win32" || platform2 === "darwin") return join35(systemTempDir, "hf-render-");
|
|
15157
|
+
return join35(dirname15(outputPath), `work-${jobId}-`);
|
|
15038
15158
|
}
|
|
15039
15159
|
var MAX_TRANSIENT_CAPTURE_RETRIES = 1;
|
|
15040
15160
|
function isTransientCaptureRetryEligible(failureKind, missing, retriesUsed) {
|
|
@@ -15065,7 +15185,7 @@ function frameStallRule(job, totalFrames, probeStartupMs) {
|
|
|
15065
15185
|
tailMs: Math.max(TAIL_STALL_MS, noProgressMs),
|
|
15066
15186
|
detail: () => describeWorkerPhases(job),
|
|
15067
15187
|
attemptOpened: () => forgetWorkerPhases(job),
|
|
15068
|
-
activity: () =>
|
|
15188
|
+
activity: () => captureActivity(job)
|
|
15069
15189
|
};
|
|
15070
15190
|
}
|
|
15071
15191
|
function isRecoverableParallelCaptureError(error) {
|
|
@@ -15089,8 +15209,8 @@ The composition is too large for the available memory. To reduce memory pressure
|
|
|
15089
15209
|
function countCapturedFrames(totalFrames, framesDir, frameExt) {
|
|
15090
15210
|
let captured = 0;
|
|
15091
15211
|
for (let frameIndex = 0; frameIndex < totalFrames; frameIndex++) {
|
|
15092
|
-
const framePath =
|
|
15093
|
-
if (
|
|
15212
|
+
const framePath = join35(framesDir, formatCaptureFrameName(frameIndex, frameExt));
|
|
15213
|
+
if (existsSync22(framePath)) captured++;
|
|
15094
15214
|
}
|
|
15095
15215
|
return captured;
|
|
15096
15216
|
}
|
|
@@ -15115,7 +15235,7 @@ async function executeDiskCaptureWithAdaptiveRetry(options) {
|
|
|
15115
15235
|
reason: attempt === 0 ? "initial" : pendingTransientRetry ? "transient-retry" : "retry"
|
|
15116
15236
|
});
|
|
15117
15237
|
pendingTransientRetry = false;
|
|
15118
|
-
const attemptWorkDir =
|
|
15238
|
+
const attemptWorkDir = join35(options.workDir, `capture-attempt-${attempt}`);
|
|
15119
15239
|
const batches = missingRanges ? buildMissingFrameRetryBatches(
|
|
15120
15240
|
missingRanges,
|
|
15121
15241
|
currentWorkers,
|
|
@@ -15762,20 +15882,20 @@ function deVerifyFallbackTelemetry(err) {
|
|
|
15762
15882
|
};
|
|
15763
15883
|
}
|
|
15764
15884
|
function resolveRenderDebugDir() {
|
|
15765
|
-
const producerRoot = process.env.PRODUCER_RENDERS_DIR ? resolve9(process.env.PRODUCER_RENDERS_DIR, "..") : resolve9(
|
|
15766
|
-
return
|
|
15885
|
+
const producerRoot = process.env.PRODUCER_RENDERS_DIR ? resolve9(process.env.PRODUCER_RENDERS_DIR, "..") : resolve9(dirname15(fileURLToPath5(import.meta.url)), "../..");
|
|
15886
|
+
return join35(producerRoot, ".debug");
|
|
15767
15887
|
}
|
|
15768
15888
|
async function executeRenderJob(job, projectDir, outputPath, progressSink, abortSignal, assertRenderActive) {
|
|
15769
15889
|
validateHlsRenderConfig(job.config);
|
|
15770
15890
|
validateDeliveryEncoderConfig(job.config);
|
|
15771
15891
|
validateChromaSubsamplingConfig(job.config);
|
|
15772
15892
|
const debugDir = resolveRenderDebugDir();
|
|
15773
|
-
const outputDir =
|
|
15774
|
-
if (!
|
|
15775
|
-
const workDir = job.config.debug ?
|
|
15893
|
+
const outputDir = dirname15(outputPath);
|
|
15894
|
+
if (!existsSync22(outputDir)) mkdirSync12(outputDir, { recursive: true });
|
|
15895
|
+
const workDir = job.config.debug ? join35(debugDir, job.id) : createRenderWorkDir(resolveRenderWorkDirPrefix(outputPath, job.id), outputDir);
|
|
15776
15896
|
const pipelineStart = Date.now();
|
|
15777
15897
|
const baseLog = job.config.logger ?? defaultLogger;
|
|
15778
|
-
const logPath = job.config.debug ?
|
|
15898
|
+
const logPath = job.config.debug ? join35(workDir, "render.log") : null;
|
|
15779
15899
|
const execution = new RenderExecutionContext({
|
|
15780
15900
|
request: { renderJobId: job.id, projectDir, outputPath },
|
|
15781
15901
|
logger: logPath ? createRenderFileLogger(logPath, baseLog) : baseLog,
|
|
@@ -15852,7 +15972,7 @@ async function executeRenderPipeline(input) {
|
|
|
15852
15972
|
imageDecodeFailures: 0
|
|
15853
15973
|
};
|
|
15854
15974
|
let hdrPerf;
|
|
15855
|
-
const perfOutputPath =
|
|
15975
|
+
const perfOutputPath = join35(workDir, "perf-summary.json");
|
|
15856
15976
|
const cfg = { ...job.config.producerConfig ?? resolveConfig2() };
|
|
15857
15977
|
const observability = new RenderObservabilityRecorder({
|
|
15858
15978
|
pipelineStartMs: pipelineStart,
|
|
@@ -15928,7 +16048,7 @@ async function executeRenderPipeline(input) {
|
|
|
15928
16048
|
job.startedAt = /* @__PURE__ */ new Date();
|
|
15929
16049
|
assertNotAborted();
|
|
15930
16050
|
assertConfiguredFfmpegBinariesExist();
|
|
15931
|
-
if (!
|
|
16051
|
+
if (!existsSync22(workDir)) mkdirSync12(workDir, { recursive: true });
|
|
15932
16052
|
if (job.config.debug) {
|
|
15933
16053
|
log.info("[Render] Debug artifacts enabled", { workDir, logPath });
|
|
15934
16054
|
}
|
|
@@ -15957,8 +16077,8 @@ async function executeRenderPipeline(input) {
|
|
|
15957
16077
|
requestedWorkers: job.config.workers ?? "auto"
|
|
15958
16078
|
});
|
|
15959
16079
|
const entryFile = job.config.entryFile || "index.html";
|
|
15960
|
-
const htmlPath =
|
|
15961
|
-
if (!
|
|
16080
|
+
const htmlPath = join35(projectDir, entryFile);
|
|
16081
|
+
if (!existsSync22(htmlPath)) {
|
|
15962
16082
|
throw new Error(`Entry file not found: ${htmlPath}`);
|
|
15963
16083
|
}
|
|
15964
16084
|
assertNotAborted();
|
|
@@ -16055,7 +16175,7 @@ async function executeRenderPipeline(input) {
|
|
|
16055
16175
|
const largerThanCanvas = await oversizedVideos(
|
|
16056
16176
|
composition.videos,
|
|
16057
16177
|
projectDir,
|
|
16058
|
-
|
|
16178
|
+
join35(workDir, "compiled"),
|
|
16059
16179
|
{ width: outputWidth, height: outputHeight }
|
|
16060
16180
|
);
|
|
16061
16181
|
const probeResult = await observeRenderStage(
|
|
@@ -16152,7 +16272,7 @@ async function executeRenderPipeline(input) {
|
|
|
16152
16272
|
canvas: { width, height },
|
|
16153
16273
|
page: probeSession.page,
|
|
16154
16274
|
projectDir,
|
|
16155
|
-
compiledDir:
|
|
16275
|
+
compiledDir: join35(workDir, "compiled")
|
|
16156
16276
|
});
|
|
16157
16277
|
if (videoLayerPlan.videoId === void 0) {
|
|
16158
16278
|
log.info(`[Render] Video layer passthrough off: ${videoLayerPlan.reason}`);
|
|
@@ -16170,7 +16290,7 @@ async function executeRenderPipeline(input) {
|
|
|
16170
16290
|
updateJobStatus(job, "preprocessing", "Extracting video frames", 10, onProgress, {
|
|
16171
16291
|
code: "extract_video"
|
|
16172
16292
|
});
|
|
16173
|
-
const compiledDir =
|
|
16293
|
+
const compiledDir = join35(workDir, "compiled");
|
|
16174
16294
|
const segmentsCapture = (layeredOrEffectRoute) => shouldSegmentCapture({
|
|
16175
16295
|
env: process.env,
|
|
16176
16296
|
durationSeconds: probeResult.duration,
|
|
@@ -16311,7 +16431,7 @@ async function executeRenderPipeline(input) {
|
|
|
16311
16431
|
try {
|
|
16312
16432
|
fileServer = await createFileServer({
|
|
16313
16433
|
projectDir,
|
|
16314
|
-
compiledDir:
|
|
16434
|
+
compiledDir: join35(workDir, "compiled"),
|
|
16315
16435
|
port: 0,
|
|
16316
16436
|
preHeadScripts: [VIRTUAL_TIME_SHIM],
|
|
16317
16437
|
fps: job.config.fps,
|
|
@@ -16331,8 +16451,8 @@ async function executeRenderPipeline(input) {
|
|
|
16331
16451
|
if (!activeFileServer) {
|
|
16332
16452
|
throw new Error("File server failed to initialize before frame capture");
|
|
16333
16453
|
}
|
|
16334
|
-
const framesDir =
|
|
16335
|
-
if (!
|
|
16454
|
+
const framesDir = join35(workDir, "captured-frames");
|
|
16455
|
+
if (!existsSync22(framesDir)) mkdirSync12(framesDir, { recursive: true });
|
|
16336
16456
|
updateJobStatus(job, "rendering", "Checking browser GPU", 25, onProgress, {
|
|
16337
16457
|
code: "start_browsers"
|
|
16338
16458
|
});
|
|
@@ -16393,7 +16513,7 @@ async function executeRenderPipeline(input) {
|
|
|
16393
16513
|
subTimelineWaitMemo,
|
|
16394
16514
|
staticDedupMemo,
|
|
16395
16515
|
compositionHash,
|
|
16396
|
-
onStaticDedupActivity: () =>
|
|
16516
|
+
onStaticDedupActivity: () => noteCaptureActivity(job),
|
|
16397
16517
|
// Probe-resolved duration: drawElement self-verification derives its
|
|
16398
16518
|
// sample frame indices from this so they land inside the drained range.
|
|
16399
16519
|
compositionDurationSeconds: job.duration,
|
|
@@ -16912,7 +17032,7 @@ async function executeRenderPipeline(input) {
|
|
|
16912
17032
|
hls: ".mp4"
|
|
16913
17033
|
};
|
|
16914
17034
|
const videoExt = FORMAT_EXT[outputFormat] ?? ".mp4";
|
|
16915
|
-
const videoOnlyPath =
|
|
17035
|
+
const videoOnlyPath = join35(workDir, `video-only${videoExt}`);
|
|
16916
17036
|
let usePageSideCompositingForTransitions = (cfg.enablePageSideCompositing || isGif) && compiled.hasShaderTransitions && !hasHdrContent && outputSupportsPageSideShaderCompositing(outputFormat);
|
|
16917
17037
|
if (usePageSideCompositingForTransitions) {
|
|
16918
17038
|
activeFileServer.addPreHeadScript(HF_PAGE_SIDE_COMPOSITING_STUB);
|
|
@@ -17774,7 +17894,7 @@ async function executeRenderPipeline(input) {
|
|
|
17774
17894
|
})
|
|
17775
17895
|
);
|
|
17776
17896
|
const totalElapsed = Date.now() - pipelineStart;
|
|
17777
|
-
const tmpPeakBytes =
|
|
17897
|
+
const tmpPeakBytes = existsSync22(workDir) ? sampleDirectoryBytes(workDir) : 0;
|
|
17778
17898
|
recordTransientRetryObservability();
|
|
17779
17899
|
observability.checkpoint("pipeline", "artifact validated", { totalElapsedMs: totalElapsed });
|
|
17780
17900
|
const observabilitySummary = observability.summary({
|
|
@@ -17855,8 +17975,8 @@ async function executeRenderPipeline(input) {
|
|
|
17855
17975
|
}
|
|
17856
17976
|
}
|
|
17857
17977
|
if (job.config.debug) {
|
|
17858
|
-
if (!isPngSequence && !isHls &&
|
|
17859
|
-
const debugOutput =
|
|
17978
|
+
if (!isPngSequence && !isHls && existsSync22(stagedOutputPath)) {
|
|
17979
|
+
const debugOutput = join35(workDir, `output${videoExt}`);
|
|
17860
17980
|
copyFileSync5(stagedOutputPath, debugOutput);
|
|
17861
17981
|
}
|
|
17862
17982
|
}
|
|
@@ -17971,7 +18091,7 @@ async function executeRenderPipeline(input) {
|
|
|
17971
18091
|
|
|
17972
18092
|
// src/services/hyperframeLint.ts
|
|
17973
18093
|
import {
|
|
17974
|
-
existsSync as
|
|
18094
|
+
existsSync as existsSync23,
|
|
17975
18095
|
readFileSync as readFileSync10,
|
|
17976
18096
|
statSync as statSync11,
|
|
17977
18097
|
openSync as openSync6,
|
|
@@ -17979,9 +18099,9 @@ import {
|
|
|
17979
18099
|
closeSync as closeSync6,
|
|
17980
18100
|
constants as constants4
|
|
17981
18101
|
} from "node:fs";
|
|
17982
|
-
import { resolve as resolve10, join as
|
|
17983
|
-
import { fileURLToPath as
|
|
17984
|
-
import { Worker as
|
|
18102
|
+
import { resolve as resolve10, join as join36, relative as relative5, isAbsolute as isAbsolute4, sep as sep5, dirname as dirname16 } from "node:path";
|
|
18103
|
+
import { fileURLToPath as fileURLToPath6 } from "node:url";
|
|
18104
|
+
import { Worker as Worker3 } from "node:worker_threads";
|
|
17985
18105
|
function isStringRecord(value) {
|
|
17986
18106
|
if (!value || typeof value !== "object" || Array.isArray(value)) {
|
|
17987
18107
|
return false;
|
|
@@ -18030,7 +18150,7 @@ function leavesProject(absProjectDir, absoluteEntryPath, isAllowedEntry) {
|
|
|
18030
18150
|
}
|
|
18031
18151
|
function readProjectEntryFile(projectDir, preferredEntryFile, isAllowedEntry) {
|
|
18032
18152
|
const absProjectDir = resolve10(projectDir);
|
|
18033
|
-
if (!
|
|
18153
|
+
if (!existsSync23(absProjectDir) || !statSync11(absProjectDir).isDirectory()) {
|
|
18034
18154
|
return { error: `Project directory not found: ${absProjectDir}` };
|
|
18035
18155
|
}
|
|
18036
18156
|
const entryCandidates = [preferredEntryFile, "index.html", "src/index.html"].filter(
|
|
@@ -18051,7 +18171,7 @@ function readProjectEntryFile(projectDir, preferredEntryFile, isAllowedEntry) {
|
|
|
18051
18171
|
}
|
|
18052
18172
|
}
|
|
18053
18173
|
return {
|
|
18054
|
-
error: `No HTML entry file found in project directory: ${
|
|
18174
|
+
error: `No HTML entry file found in project directory: ${join36(absProjectDir, preferredEntryFile || "index.html")}`
|
|
18055
18175
|
};
|
|
18056
18176
|
}
|
|
18057
18177
|
function prepareHyperframeLintBody(body, isAllowedEntry) {
|
|
@@ -18118,10 +18238,10 @@ function freeLintSlot() {
|
|
|
18118
18238
|
waiting.shift()?.();
|
|
18119
18239
|
}
|
|
18120
18240
|
function resolveLintWorkerEntry() {
|
|
18121
|
-
const here =
|
|
18241
|
+
const here = dirname16(fileURLToPath6(import.meta.url));
|
|
18122
18242
|
for (const name of ["hyperframeLintWorker.js", "hyperframeLintWorker.ts"]) {
|
|
18123
|
-
const candidate =
|
|
18124
|
-
if (
|
|
18243
|
+
const candidate = join36(here, name);
|
|
18244
|
+
if (existsSync23(candidate)) return candidate;
|
|
18125
18245
|
}
|
|
18126
18246
|
return void 0;
|
|
18127
18247
|
}
|
|
@@ -18154,7 +18274,7 @@ async function runHyperframeLint(prepared, options = {}) {
|
|
|
18154
18274
|
return new Promise((resolvePromise, reject) => {
|
|
18155
18275
|
let worker;
|
|
18156
18276
|
try {
|
|
18157
|
-
worker = new
|
|
18277
|
+
worker = new Worker3(entry, {
|
|
18158
18278
|
workerData: {
|
|
18159
18279
|
html: prepared.html,
|
|
18160
18280
|
opts: { filePath: prepared.entryFile, compSrcPath: prepared.entryFile }
|
|
@@ -18189,10 +18309,10 @@ async function runHyperframeLint(prepared, options = {}) {
|
|
|
18189
18309
|
}
|
|
18190
18310
|
|
|
18191
18311
|
// src/services/healthWorker.ts
|
|
18192
|
-
import { Worker as
|
|
18193
|
-
import { fileURLToPath as
|
|
18194
|
-
import { dirname as
|
|
18195
|
-
import { existsSync as
|
|
18312
|
+
import { Worker as Worker4 } from "node:worker_threads";
|
|
18313
|
+
import { fileURLToPath as fileURLToPath7 } from "node:url";
|
|
18314
|
+
import { dirname as dirname17, join as join37 } from "node:path";
|
|
18315
|
+
import { existsSync as existsSync24 } from "node:fs";
|
|
18196
18316
|
var DEFAULT_HEALTH_PORT = 9848;
|
|
18197
18317
|
async function startHealthWorker(options = {}) {
|
|
18198
18318
|
const log = options.logger ?? defaultLogger2();
|
|
@@ -18203,7 +18323,7 @@ async function startHealthWorker(options = {}) {
|
|
|
18203
18323
|
"[healthWorker] could not resolve worker entry. Pass options.workerEntry or ensure healthWorkerThread.{js,ts} is co-located."
|
|
18204
18324
|
);
|
|
18205
18325
|
}
|
|
18206
|
-
const worker = new
|
|
18326
|
+
const worker = new Worker4(entry, {
|
|
18207
18327
|
workerData: { port },
|
|
18208
18328
|
// Keep stdio inherited so the worker's console logs land in the pod logs
|
|
18209
18329
|
// alongside the main thread's.
|
|
@@ -18266,10 +18386,10 @@ function defaultLogger2() {
|
|
|
18266
18386
|
};
|
|
18267
18387
|
}
|
|
18268
18388
|
function resolveWorkerEntry2() {
|
|
18269
|
-
const here =
|
|
18270
|
-
const candidates = [
|
|
18389
|
+
const here = dirname17(fileURLToPath7(import.meta.url));
|
|
18390
|
+
const candidates = [join37(here, "healthWorkerThread.js"), join37(here, "healthWorkerThread.ts")];
|
|
18271
18391
|
for (const candidate of candidates) {
|
|
18272
|
-
if (
|
|
18392
|
+
if (existsSync24(candidate)) return candidate;
|
|
18273
18393
|
}
|
|
18274
18394
|
return void 0;
|
|
18275
18395
|
}
|
|
@@ -18309,7 +18429,7 @@ import {
|
|
|
18309
18429
|
createReferenceBackgroundRecorder as createReferenceBackgroundRecorder2
|
|
18310
18430
|
} from "@hyperframes/engine";
|
|
18311
18431
|
import { audioFailureDiagnostics as audioFailureDiagnostics3 } from "@hyperframes/engine";
|
|
18312
|
-
import { extname as extname4, isAbsolute as isAbsolute5, join as
|
|
18432
|
+
import { extname as extname4, isAbsolute as isAbsolute5, join as join39, relative as relative6, sep as sep6 } from "node:path";
|
|
18313
18433
|
import {
|
|
18314
18434
|
fpsToNumber as fpsToNumber9,
|
|
18315
18435
|
HF_COLOR_GRADING_ATTR as HF_COLOR_GRADING_ATTR2
|
|
@@ -18342,9 +18462,9 @@ import {
|
|
|
18342
18462
|
|
|
18343
18463
|
// src/services/distributed/shared.ts
|
|
18344
18464
|
import { execFile as execFileCallback } from "node:child_process";
|
|
18345
|
-
import { dirname as
|
|
18346
|
-
import { existsSync as
|
|
18347
|
-
import { fileURLToPath as
|
|
18465
|
+
import { dirname as dirname18, join as join38 } from "node:path";
|
|
18466
|
+
import { existsSync as existsSync25, readFileSync as readFileSync11 } from "node:fs";
|
|
18467
|
+
import { fileURLToPath as fileURLToPath8 } from "node:url";
|
|
18348
18468
|
import { promisify as promisify2 } from "node:util";
|
|
18349
18469
|
import {
|
|
18350
18470
|
getFfmpegBinary,
|
|
@@ -18355,11 +18475,11 @@ var execFile = promisify2(execFileCallback);
|
|
|
18355
18475
|
var cachedProducerVersion = null;
|
|
18356
18476
|
function readProducerVersion() {
|
|
18357
18477
|
if (cachedProducerVersion !== null) return cachedProducerVersion;
|
|
18358
|
-
const startDir =
|
|
18478
|
+
const startDir = dirname18(fileURLToPath8(import.meta.url));
|
|
18359
18479
|
let current = startDir;
|
|
18360
18480
|
for (let i = 0; i < 10; i++) {
|
|
18361
|
-
const candidate =
|
|
18362
|
-
if (
|
|
18481
|
+
const candidate = join38(current, "package.json");
|
|
18482
|
+
if (existsSync25(candidate)) {
|
|
18363
18483
|
try {
|
|
18364
18484
|
const pkg = JSON.parse(readFileSync11(candidate, "utf-8"));
|
|
18365
18485
|
if (pkg.name === "@hyperframes/producer" && typeof pkg.version === "string") {
|
|
@@ -18369,7 +18489,7 @@ function readProducerVersion() {
|
|
|
18369
18489
|
} catch {
|
|
18370
18490
|
}
|
|
18371
18491
|
}
|
|
18372
|
-
const parent =
|
|
18492
|
+
const parent = dirname18(current);
|
|
18373
18493
|
if (parent === current) break;
|
|
18374
18494
|
current = parent;
|
|
18375
18495
|
}
|
|
@@ -18456,9 +18576,9 @@ var PLAN_ROOT_CATEGORY = {
|
|
|
18456
18576
|
var PLAN_DIR_SIZE_LIMIT_BYTES = 2 * 1024 * 1024 * 1024;
|
|
18457
18577
|
var FREEZE_OWNED_PLAN_FILES = [
|
|
18458
18578
|
"plan.json",
|
|
18459
|
-
|
|
18460
|
-
|
|
18461
|
-
|
|
18579
|
+
join39("meta", "composition.json"),
|
|
18580
|
+
join39("meta", "encoder.json"),
|
|
18581
|
+
join39("meta", "chunks.json")
|
|
18462
18582
|
];
|
|
18463
18583
|
|
|
18464
18584
|
// src/services/distributed/renderConfigValidation.ts
|
|
@@ -18719,7 +18839,8 @@ var SAFE_RENDER_ERROR_CODES = /* @__PURE__ */ new Set([
|
|
|
18719
18839
|
"PAGE_NEVER_READY",
|
|
18720
18840
|
"VARIABLES_INVALID",
|
|
18721
18841
|
"OUTPUT_DIMENSIONS_MISMATCH",
|
|
18722
|
-
"COMPOSITION_TOO_LARGE"
|
|
18842
|
+
"COMPOSITION_TOO_LARGE",
|
|
18843
|
+
"COMPILE_TIMEOUT"
|
|
18723
18844
|
]);
|
|
18724
18845
|
function extractSafeRenderErrorCode(error) {
|
|
18725
18846
|
if (typeof error !== "object" || error === null || !("code" in error)) return void 0;
|
|
@@ -18885,8 +19006,8 @@ function resolvePreparedRenderOutput(prepared, rendersDir, log, confineOutput) {
|
|
|
18885
19006
|
throw new Error("outputPath must be inside the renders directory");
|
|
18886
19007
|
}
|
|
18887
19008
|
}
|
|
18888
|
-
const outputDir =
|
|
18889
|
-
if (!
|
|
19009
|
+
const outputDir = dirname19(absoluteOutputPath);
|
|
19010
|
+
if (!existsSync26(outputDir)) mkdirSync13(outputDir, { recursive: true });
|
|
18890
19011
|
return { input, cleanupProjectDir, absoluteOutputPath };
|
|
18891
19012
|
}
|
|
18892
19013
|
function prepareRenderJob(prepared, rendersDir, log, confineOutput) {
|
|
@@ -18964,12 +19085,12 @@ function prepareProjectDirectory(projectDir, options, policy) {
|
|
|
18964
19085
|
if (!candidate) return null;
|
|
18965
19086
|
const absProjectDir = policy ? resolve11(policy.projectsDir, candidate) : resolve11(candidate);
|
|
18966
19087
|
const shown = policy ? candidate : absProjectDir;
|
|
18967
|
-
if (policy && !isAllowedProjectPath(policy.projectsDir, absProjectDir) || !
|
|
19088
|
+
if (policy && !isAllowedProjectPath(policy.projectsDir, absProjectDir) || !existsSync26(absProjectDir) || !statSync12(absProjectDir).isDirectory()) {
|
|
18968
19089
|
return { error: `Project directory not found: ${shown}` };
|
|
18969
19090
|
}
|
|
18970
19091
|
const entry = options.entryFile || "index.html";
|
|
18971
19092
|
const entryPath = resolve11(absProjectDir, entry);
|
|
18972
|
-
if (policy && !isAllowedEntryPath(policy, absProjectDir, entryPath) || !
|
|
19093
|
+
if (policy && !isAllowedEntryPath(policy, absProjectDir, entryPath) || !existsSync26(entryPath)) {
|
|
18973
19094
|
return { error: `Entry file "${entry}" not found in project directory: ${shown}` };
|
|
18974
19095
|
}
|
|
18975
19096
|
return { prepared: { input: { projectDir: absProjectDir, ...options } } };
|
|
@@ -18990,8 +19111,8 @@ async function resolveInlineRenderHtml(body) {
|
|
|
18990
19111
|
}
|
|
18991
19112
|
function materializeInlineProject(html, options) {
|
|
18992
19113
|
const tempRoot = process.env.PRODUCER_TMP_PROJECT_DIR || tmpdir4();
|
|
18993
|
-
const tempProjectDir = mkdtempSync(
|
|
18994
|
-
writeFileSync7(
|
|
19114
|
+
const tempProjectDir = mkdtempSync(join40(tempRoot, "producer-project-"));
|
|
19115
|
+
writeFileSync7(join40(tempProjectDir, "index.html"), html, "utf-8");
|
|
18995
19116
|
return {
|
|
18996
19117
|
prepared: {
|
|
18997
19118
|
input: { projectDir: tempProjectDir, ...options },
|
|
@@ -19067,7 +19188,7 @@ function publicPerfSummary(job) {
|
|
|
19067
19188
|
return job.perfSummary ? { ...job.perfSummary, renderId: void 0 } : null;
|
|
19068
19189
|
}
|
|
19069
19190
|
function outputFileSize(path) {
|
|
19070
|
-
return
|
|
19191
|
+
return existsSync26(path) ? statSync12(path).size : 0;
|
|
19071
19192
|
}
|
|
19072
19193
|
function createBlockingProgressReporter(log, requestId) {
|
|
19073
19194
|
let lastLoggedPct = -10;
|
|
@@ -19394,7 +19515,7 @@ function createRenderHandlers(options = {}) {
|
|
|
19394
19515
|
if (!artifact) {
|
|
19395
19516
|
return c.json({ success: false, error: "Output artifact not found or expired" }, 404);
|
|
19396
19517
|
}
|
|
19397
|
-
if (!
|
|
19518
|
+
if (!existsSync26(artifact.path)) {
|
|
19398
19519
|
store.delete(token);
|
|
19399
19520
|
return c.json({ success: false, error: "Output artifact file missing" }, 404);
|
|
19400
19521
|
}
|