@hyperframes/producer 0.9.93 → 0.9.95
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 +24 -13
- package/dist/distributed.js +82 -54
- package/dist/hyperframe.manifest.json +1 -1
- package/dist/hyperframe.runtime.iife.js +67 -67
- package/dist/index.js +445 -275
- package/dist/public-server.js +349 -179
- package/dist/services/render/captureCost.d.ts +4 -1
- package/dist/services/render/frameWindow.d.ts +17 -0
- package/dist/services/render/gpuChoice.d.ts +15 -0
- package/dist/services/render/stages/audioStage.d.ts +6 -1
- package/dist/services/render/stages/captureHdrFrameShared.d.ts +4 -1
- package/dist/services/renderOrchestrator.d.ts +5 -0
- package/package.json +7 -7
package/dist/public-server.js
CHANGED
|
@@ -23,16 +23,16 @@ import {
|
|
|
23
23
|
existsSync as existsSync26,
|
|
24
24
|
fstatSync as fstatSync5,
|
|
25
25
|
lstatSync as lstatSync4,
|
|
26
|
-
mkdirSync as
|
|
26
|
+
mkdirSync as mkdirSync14,
|
|
27
27
|
openSync as openSync7,
|
|
28
28
|
statSync as statSync12,
|
|
29
29
|
mkdtempSync,
|
|
30
|
-
writeFileSync as
|
|
30
|
+
writeFileSync as writeFileSync8,
|
|
31
31
|
rmSync as rmSync14,
|
|
32
32
|
createReadStream as createReadStream4
|
|
33
33
|
} from "node:fs";
|
|
34
34
|
import { AsyncLocalStorage } from "node:async_hooks";
|
|
35
|
-
import { basename as basename8, resolve as
|
|
35
|
+
import { basename as basename8, resolve as resolve12, dirname as dirname20, join as join40 } from "node:path";
|
|
36
36
|
import { homedir, tmpdir as tmpdir4 } from "node:os";
|
|
37
37
|
import { parseArgs } from "node:util";
|
|
38
38
|
import { isIP } from "node:net";
|
|
@@ -52,11 +52,11 @@ import { foreignWritablePath } from "@hyperframes/core/cache-dir";
|
|
|
52
52
|
import { audioFailureDiagnostics as audioFailureDiagnostics2, cpuBudget } from "@hyperframes/engine";
|
|
53
53
|
import {
|
|
54
54
|
existsSync as existsSync22,
|
|
55
|
-
mkdirSync as
|
|
55
|
+
mkdirSync as mkdirSync13,
|
|
56
56
|
readdirSync as readdirSync6,
|
|
57
57
|
rmSync as rmSync13,
|
|
58
58
|
statSync as statSync10,
|
|
59
|
-
writeFileSync as
|
|
59
|
+
writeFileSync as writeFileSync7,
|
|
60
60
|
copyFileSync as copyFileSync5,
|
|
61
61
|
appendFileSync
|
|
62
62
|
} from "fs";
|
|
@@ -381,6 +381,7 @@ import {
|
|
|
381
381
|
LOW_MEMORY_TOTAL_MB_THRESHOLD,
|
|
382
382
|
assertConfiguredFfmpegBinariesExist,
|
|
383
383
|
resolveBrowserGpuMode,
|
|
384
|
+
probedHardwareGpu,
|
|
384
385
|
resolveHeadlessShellPath,
|
|
385
386
|
compositionRequiresWebGpu as compositionRequiresWebGpu2,
|
|
386
387
|
applyConcreteGpuScreenshotClamp,
|
|
@@ -402,7 +403,8 @@ import {
|
|
|
402
403
|
referenceBackgroundResult,
|
|
403
404
|
createReferenceBackgroundRecorder
|
|
404
405
|
} from "@hyperframes/engine";
|
|
405
|
-
import { join as join35, dirname as
|
|
406
|
+
import { join as join35, dirname as dirname16, resolve as resolve10 } from "path";
|
|
407
|
+
import { fromEmptyFolder } from "@hyperframes/parsers/ff-binaries";
|
|
406
408
|
import { totalmem as totalmem2 } from "node:os";
|
|
407
409
|
import { randomUUID as randomUUID3 } from "crypto";
|
|
408
410
|
import { fileURLToPath as fileURLToPath5 } from "url";
|
|
@@ -432,7 +434,7 @@ import {
|
|
|
432
434
|
serviceWorkerScriptFetch
|
|
433
435
|
} from "@hyperframes/core/studio-preview-mark";
|
|
434
436
|
import { fpsToNumber, terminalText as terminalText2 } from "@hyperframes/core";
|
|
435
|
-
import { isPrivateFileUnder, isStudioPrivatePath } from "@hyperframes/core/safe-path";
|
|
437
|
+
import { isPrivateFileUnder as isPrivateFileUnder2, isStudioPrivatePath as isStudioPrivatePath2 } from "@hyperframes/core/safe-path";
|
|
436
438
|
import { stripSdrPngColourTags } from "@hyperframes/core/compiler/png-colour-tags";
|
|
437
439
|
import { openRangeEnd } from "@hyperframes/studio-server/media-range";
|
|
438
440
|
|
|
@@ -574,7 +576,7 @@ import {
|
|
|
574
576
|
} from "node:path";
|
|
575
577
|
import { statSync } from "node:fs";
|
|
576
578
|
import { fileURLToPath as fileURLToPath2 } from "node:url";
|
|
577
|
-
import { isSafePath } from "@hyperframes/core/safe-path";
|
|
579
|
+
import { isPrivateFileUnder, isSafePath, isStudioPrivatePath } from "@hyperframes/core/safe-path";
|
|
578
580
|
import {
|
|
579
581
|
isCopiedOutsideFileType,
|
|
580
582
|
isPrivateOutsideFile,
|
|
@@ -601,7 +603,10 @@ function escapesAssetRoot(path, assetRoot) {
|
|
|
601
603
|
return assetRoot !== void 0 && !isSafePath(assetRoot, path);
|
|
602
604
|
}
|
|
603
605
|
function outsideAssetRefusal(projectDir, path, policy = {}) {
|
|
604
|
-
if (!linksOutside(projectDir, path))
|
|
606
|
+
if (!linksOutside(projectDir, path)) {
|
|
607
|
+
const privateByAnotherSpelling = !isPathInside(path, projectDir) && isPrivateFileUnder(projectDir, path, isStudioPrivatePath);
|
|
608
|
+
return privateByAnotherSpelling ? "blocklisted" : null;
|
|
609
|
+
}
|
|
605
610
|
if (isPrivateOutsideFile(projectDir, path)) return "blocklisted";
|
|
606
611
|
const folder = statSync(path, { throwIfNoEntry: false })?.isDirectory();
|
|
607
612
|
if (folder || isUploadedOutsideFileType(path)) return null;
|
|
@@ -1227,7 +1232,7 @@ function createFileServer(options) {
|
|
|
1227
1232
|
const candidate = join2(root, relativePath);
|
|
1228
1233
|
const resolveSymlinks = !allowOutsideProjectAssets && root !== compiledDir;
|
|
1229
1234
|
if (!isPathInside2(candidate, root, { resolveSymlinks })) continue;
|
|
1230
|
-
if (
|
|
1235
|
+
if (isPrivateFileUnder2(root, candidate, isStudioPrivatePath2)) continue;
|
|
1231
1236
|
const checksLinks = allowOutsideProjectAssets && root !== compiledDir;
|
|
1232
1237
|
if (checksLinks && refusesOutsideLink(root, candidate, warnLeftOut, outsidePolicy)) continue;
|
|
1233
1238
|
file = openRegularFile(candidate);
|
|
@@ -1309,13 +1314,13 @@ function createFileServer(options) {
|
|
|
1309
1314
|
if (!streamOwnsFd) closeSync(fd);
|
|
1310
1315
|
}
|
|
1311
1316
|
});
|
|
1312
|
-
return new Promise((
|
|
1317
|
+
return new Promise((resolve13, reject) => {
|
|
1313
1318
|
const connections = /* @__PURE__ */ new Set();
|
|
1314
1319
|
const server = serve({ fetch: app.fetch, port, hostname: "127.0.0.1" }, (info) => {
|
|
1315
1320
|
const bound = port === 0 ? settleOnBrowserSafePort(server, "127.0.0.1") : Promise.resolve(info.port);
|
|
1316
1321
|
bound.then((boundPort) => {
|
|
1317
1322
|
listeningPort = boundPort;
|
|
1318
|
-
|
|
1323
|
+
resolve13({
|
|
1319
1324
|
url: `http://localhost:${boundPort}`,
|
|
1320
1325
|
port: boundPort,
|
|
1321
1326
|
addPreHeadScript: (script) => {
|
|
@@ -2003,8 +2008,8 @@ var OrderedRenderEventPublisher = class {
|
|
|
2003
2008
|
let timer;
|
|
2004
2009
|
const drained = await Promise.race([
|
|
2005
2010
|
this.tail.then(() => true),
|
|
2006
|
-
new Promise((
|
|
2007
|
-
timer = setTimeout(() =>
|
|
2011
|
+
new Promise((resolve13) => {
|
|
2012
|
+
timer = setTimeout(() => resolve13(false), FLUSH_TIMEOUT_MS);
|
|
2008
2013
|
})
|
|
2009
2014
|
]);
|
|
2010
2015
|
clearTimeout(timer);
|
|
@@ -2679,6 +2684,7 @@ import {
|
|
|
2679
2684
|
concatVideoFiles,
|
|
2680
2685
|
createCaptureSession as createCaptureSession2,
|
|
2681
2686
|
getCapturePerfSummary as getCapturePerfSummary2,
|
|
2687
|
+
retainCapturePerf as retainCapturePerf3,
|
|
2682
2688
|
initializeSession as initializeSession2,
|
|
2683
2689
|
prepareCaptureSessionForReuse as prepareCaptureSessionForReuse2,
|
|
2684
2690
|
resolveDeVerifyMinDb as resolveDeVerifyMinDb2,
|
|
@@ -2692,7 +2698,7 @@ import { CaptureFailure, classifyCaptureFailure } from "@hyperframes/engine";
|
|
|
2692
2698
|
// src/services/render/perfSummary.ts
|
|
2693
2699
|
import { arch, platform, totalmem } from "node:os";
|
|
2694
2700
|
import { fpsToNumber as fpsToNumber2 } from "@hyperframes/core";
|
|
2695
|
-
import { hostCpuCount } from "@hyperframes/engine";
|
|
2701
|
+
import { hostCpuCount, retainCapturePerf } from "@hyperframes/engine";
|
|
2696
2702
|
|
|
2697
2703
|
// src/services/render/hdrPerf.ts
|
|
2698
2704
|
function createHdrPerfCollector() {
|
|
@@ -2808,7 +2814,7 @@ function worstSubTimelineWaitOutcome(perfs) {
|
|
|
2808
2814
|
}
|
|
2809
2815
|
function pushWorkerDedupPerfs(results, sink) {
|
|
2810
2816
|
for (const r of results) {
|
|
2811
|
-
if (r.perf) sink
|
|
2817
|
+
if (r.perf) retainCapturePerf(sink, r.perf);
|
|
2812
2818
|
}
|
|
2813
2819
|
}
|
|
2814
2820
|
function capturedBeyondViewport(perfs, fallback) {
|
|
@@ -4167,12 +4173,12 @@ function distributeLayeredHybridFrameRanges(totalFrames, workerCount) {
|
|
|
4167
4173
|
}
|
|
4168
4174
|
return ranges;
|
|
4169
4175
|
}
|
|
4170
|
-
function partitionTransitionFrames(transitionRanges, totalFrames) {
|
|
4176
|
+
function partitionTransitionFrames(transitionRanges, totalFrames, firstFrame = 0) {
|
|
4171
4177
|
const frames = /* @__PURE__ */ new Set();
|
|
4172
4178
|
if (totalFrames <= 0) return frames;
|
|
4173
4179
|
for (const range of transitionRanges) {
|
|
4174
|
-
const start = Math.max(
|
|
4175
|
-
const end = Math.min(totalFrames - 1, range.endFrame);
|
|
4180
|
+
const start = Math.max(firstFrame, range.startFrame);
|
|
4181
|
+
const end = Math.min(firstFrame + totalFrames - 1, range.endFrame);
|
|
4176
4182
|
for (let i = start; i <= end; i++) frames.add(i);
|
|
4177
4183
|
}
|
|
4178
4184
|
return frames;
|
|
@@ -4382,6 +4388,18 @@ function cleanupEndedHdrVideos(args) {
|
|
|
4382
4388
|
}
|
|
4383
4389
|
}
|
|
4384
4390
|
}
|
|
4391
|
+
function transitionAtFrame(transitionRanges, frame) {
|
|
4392
|
+
return transitionRanges.find((t) => frame >= t.startFrame && frame <= t.endFrame);
|
|
4393
|
+
}
|
|
4394
|
+
function cleanupHdrVideosEndedBefore(firstFrame, fps, transitionRanges, state) {
|
|
4395
|
+
for (let frame = 0; frame < firstFrame; frame++) {
|
|
4396
|
+
cleanupEndedHdrVideos({
|
|
4397
|
+
...state,
|
|
4398
|
+
time: frame * fps.den / fps.num,
|
|
4399
|
+
activeTransition: transitionAtFrame(transitionRanges, frame)
|
|
4400
|
+
});
|
|
4401
|
+
}
|
|
4402
|
+
}
|
|
4385
4403
|
|
|
4386
4404
|
// src/services/render/segmentPlan.ts
|
|
4387
4405
|
import { join as join9 } from "node:path";
|
|
@@ -4634,6 +4652,7 @@ import {
|
|
|
4634
4652
|
distributeFramesInterleaved,
|
|
4635
4653
|
executeParallelCapture,
|
|
4636
4654
|
getCapturePerfSummary,
|
|
4655
|
+
retainCapturePerf as retainCapturePerf2,
|
|
4637
4656
|
psnrDb,
|
|
4638
4657
|
resolveDeVerifyMinDb,
|
|
4639
4658
|
recaptureDrawElementFrameForVerify,
|
|
@@ -4715,7 +4734,7 @@ var SequentialCaptureStallError = class extends Error {
|
|
|
4715
4734
|
}
|
|
4716
4735
|
};
|
|
4717
4736
|
function raceAgainstStall(promise, deadlineMs, input, signal) {
|
|
4718
|
-
return new Promise((
|
|
4737
|
+
return new Promise((resolve13, reject) => {
|
|
4719
4738
|
const clock = createStallClock();
|
|
4720
4739
|
const trip = () => reject(
|
|
4721
4740
|
signal?.aborted ? new Error(
|
|
@@ -4740,7 +4759,7 @@ function raceAgainstStall(promise, deadlineMs, input, signal) {
|
|
|
4740
4759
|
promise.then(
|
|
4741
4760
|
(value) => {
|
|
4742
4761
|
clearTimeout(timer);
|
|
4743
|
-
|
|
4762
|
+
resolve13(value);
|
|
4744
4763
|
},
|
|
4745
4764
|
(error) => {
|
|
4746
4765
|
clearTimeout(timer);
|
|
@@ -5362,7 +5381,7 @@ async function runCaptureStreamingStage(input) {
|
|
|
5362
5381
|
);
|
|
5363
5382
|
}
|
|
5364
5383
|
}
|
|
5365
|
-
dedupPerfs
|
|
5384
|
+
retainCapturePerf2(dedupPerfs, getCapturePerfSummary(session));
|
|
5366
5385
|
} catch (error) {
|
|
5367
5386
|
lastBrowserConsole = session.browserConsoleBuffer;
|
|
5368
5387
|
if (!resumesAfterStall(error, abortSignal, resume, resumes)) {
|
|
@@ -5662,7 +5681,7 @@ async function openSegmentWorkersTogether(run, workersToCloseLater) {
|
|
|
5662
5681
|
if (failure && failure.status === "rejected") throw failure.reason;
|
|
5663
5682
|
}
|
|
5664
5683
|
async function recycleWorkerSession(run, worker, why) {
|
|
5665
|
-
run.input.dedupPerfs
|
|
5684
|
+
retainCapturePerf3(run.input.dedupPerfs, getCapturePerfSummary2(worker.ctx.session));
|
|
5666
5685
|
const memory = worker.ctx.session.chromeMemory?.stats();
|
|
5667
5686
|
await run.deps.closeSession(worker.ctx.session);
|
|
5668
5687
|
const { frames } = worker.ctx;
|
|
@@ -5791,7 +5810,8 @@ async function runCaptureSegmentedStage(input) {
|
|
|
5791
5810
|
assertNotAborted();
|
|
5792
5811
|
await openSegmentWorkersTogether(run, workers);
|
|
5793
5812
|
const outcomes = await Promise.allSettled(workers.map((w) => runWorkerLoop(w)));
|
|
5794
|
-
for (const worker of workers)
|
|
5813
|
+
for (const worker of workers)
|
|
5814
|
+
retainCapturePerf3(dedupPerfs, getCapturePerfSummary2(worker.ctx.session));
|
|
5795
5815
|
const failure = outcomes.find((o) => o.status === "rejected");
|
|
5796
5816
|
if (failure && failure.status === "rejected") throw failure.reason;
|
|
5797
5817
|
} catch (error) {
|
|
@@ -6039,10 +6059,15 @@ function estimateMeasuredCaptureCostMultiplier(samples) {
|
|
|
6039
6059
|
function shouldCalibrateSoftwareGpu(requestedMode, resolvedMode, hardware) {
|
|
6040
6060
|
return requestedMode === "auto" && resolvedMode === "hardware" && hardware !== void 0 && hardware.multiplier > 1 && hardware.p95Ms !== void 0;
|
|
6041
6061
|
}
|
|
6042
|
-
function
|
|
6043
|
-
if (hardware
|
|
6062
|
+
function settleAutoGpuChoice(hardware, software) {
|
|
6063
|
+
if (hardware?.p95Ms === void 0) return void 0;
|
|
6064
|
+
if (hardware.multiplier <= 1) return "hardware";
|
|
6065
|
+
if (software?.p95Ms === void 0) return void 0;
|
|
6044
6066
|
return software.p95Ms < hardware.p95Ms ? "software" : "hardware";
|
|
6045
6067
|
}
|
|
6068
|
+
function pickAutoGpuModeFromCalibration(hardware, software) {
|
|
6069
|
+
return settleAutoGpuChoice(hardware, software) ?? "hardware";
|
|
6070
|
+
}
|
|
6046
6071
|
function selectCaptureCalibrationFrames(totalFrames) {
|
|
6047
6072
|
if (totalFrames <= 0) return [];
|
|
6048
6073
|
const lastFrame = totalFrames - 1;
|
|
@@ -6057,8 +6082,8 @@ function selectCaptureCalibrationFrames(totalFrames) {
|
|
|
6057
6082
|
new Set(candidates.map((frame) => Math.max(0, Math.min(lastFrame, frame))))
|
|
6058
6083
|
).sort((a, b) => a - b);
|
|
6059
6084
|
}
|
|
6060
|
-
async function measureCaptureCostFromSession(session, totalFrames, fps, log) {
|
|
6061
|
-
const sampledFrames = selectCaptureCalibrationFrames(totalFrames);
|
|
6085
|
+
async function measureCaptureCostFromSession(session, totalFrames, fps, log, firstFrame = 0) {
|
|
6086
|
+
const sampledFrames = selectCaptureCalibrationFrames(totalFrames).map((i) => firstFrame + i);
|
|
6062
6087
|
const samples = [];
|
|
6063
6088
|
const totalSamples = sampledFrames.length;
|
|
6064
6089
|
const savedStaticFrames = session.staticFrames;
|
|
@@ -6154,7 +6179,13 @@ async function runCaptureCalibration(input) {
|
|
|
6154
6179
|
}
|
|
6155
6180
|
assertNotAborted();
|
|
6156
6181
|
log.info("Calibration session ready, capturing test frames...");
|
|
6157
|
-
const result = await measureCaptureCostFromSession(
|
|
6182
|
+
const result = await measureCaptureCostFromSession(
|
|
6183
|
+
session,
|
|
6184
|
+
totalFrames,
|
|
6185
|
+
fps,
|
|
6186
|
+
log,
|
|
6187
|
+
job.frameWindow?.startFrame
|
|
6188
|
+
);
|
|
6158
6189
|
logCaptureCalibrationResult(result, log);
|
|
6159
6190
|
return result;
|
|
6160
6191
|
};
|
|
@@ -6715,6 +6746,57 @@ function resolveVideoCaptureBeyondViewport(videoCount) {
|
|
|
6715
6746
|
return true;
|
|
6716
6747
|
}
|
|
6717
6748
|
|
|
6749
|
+
// src/services/render/gpuChoice.ts
|
|
6750
|
+
import { mkdirSync as mkdirSync7, readFileSync as readFileSync5, renameSync, writeFileSync as writeFileSync3 } from "node:fs";
|
|
6751
|
+
import { dirname as dirname6 } from "node:path";
|
|
6752
|
+
function gpuChoiceStore(cfg, gpu) {
|
|
6753
|
+
if (!cfg.gpuChoiceFile || !cfg.hyperframesVersion || !gpu) return void 0;
|
|
6754
|
+
return { file: cfg.gpuChoiceFile, key: `${cfg.hyperframesVersion} | ${gpu}` };
|
|
6755
|
+
}
|
|
6756
|
+
function readGpuChoice(store) {
|
|
6757
|
+
let record;
|
|
6758
|
+
try {
|
|
6759
|
+
record = JSON.parse(readFileSync5(store.file, "utf8"));
|
|
6760
|
+
} catch {
|
|
6761
|
+
return void 0;
|
|
6762
|
+
}
|
|
6763
|
+
if (record?.key !== store.key) return void 0;
|
|
6764
|
+
return record.mode === "software" || record.mode === "hardware" ? record.mode : void 0;
|
|
6765
|
+
}
|
|
6766
|
+
function writeGpuChoice(store, mode, measured) {
|
|
6767
|
+
mkdirSync7(dirname6(store.file), { recursive: true });
|
|
6768
|
+
const temp = `${store.file}.${process.pid}.tmp`;
|
|
6769
|
+
const record = { key: store.key, mode, ...measured, measuredAt: (/* @__PURE__ */ new Date()).toISOString() };
|
|
6770
|
+
writeFileSync3(temp, `${JSON.stringify(record, null, 2)}
|
|
6771
|
+
`);
|
|
6772
|
+
renameSync(temp, store.file);
|
|
6773
|
+
}
|
|
6774
|
+
|
|
6775
|
+
// src/services/render/frameWindow.ts
|
|
6776
|
+
function resolveFrameWindow(range, fps, filmFrames) {
|
|
6777
|
+
const frameAt = (seconds) => Math.round(seconds * fps.num / fps.den);
|
|
6778
|
+
const startFrame = frameAt(range.startSeconds);
|
|
6779
|
+
const endFrame = Math.min(
|
|
6780
|
+
range.endSeconds === void 0 ? filmFrames : frameAt(range.endSeconds),
|
|
6781
|
+
filmFrames
|
|
6782
|
+
);
|
|
6783
|
+
if (!(endFrame > startFrame)) {
|
|
6784
|
+
throw new Error(
|
|
6785
|
+
`The range ${range.startSeconds}s to ${range.endSeconds ?? "the end"}s holds no frame: the film has ${filmFrames} frames at ${fps.num}/${fps.den} fps.`
|
|
6786
|
+
);
|
|
6787
|
+
}
|
|
6788
|
+
return { startFrame, endFrame };
|
|
6789
|
+
}
|
|
6790
|
+
function windowStartFrame(frameWindow) {
|
|
6791
|
+
return frameWindow?.startFrame ?? 0;
|
|
6792
|
+
}
|
|
6793
|
+
function assertRangeSupported(frameWindow, route) {
|
|
6794
|
+
if (!frameWindow || route === "sdr_disk" || route === "hdr_layered") return;
|
|
6795
|
+
throw new Error(
|
|
6796
|
+
`This composition renders on the "${route}" capture route, which renders the whole film only; render it without a start or end.`
|
|
6797
|
+
);
|
|
6798
|
+
}
|
|
6799
|
+
|
|
6718
6800
|
// src/services/render/observability.ts
|
|
6719
6801
|
import { createHash as createHash3 } from "node:crypto";
|
|
6720
6802
|
import { redactTelemetryString } from "@hyperframes/core";
|
|
@@ -7086,7 +7168,7 @@ function emitFallbackCaptureProfile(recorder, perfSummaries, env = process.env)
|
|
|
7086
7168
|
}
|
|
7087
7169
|
|
|
7088
7170
|
// src/services/render/videoFrameCoverage.ts
|
|
7089
|
-
import { parseHTML } from "linkedom";
|
|
7171
|
+
import { parseHTML } from "@hyperframes/parsers/linkedom";
|
|
7090
7172
|
import {
|
|
7091
7173
|
fpsToNumber as fpsToNumber5,
|
|
7092
7174
|
normalizeRateSpec,
|
|
@@ -7101,7 +7183,6 @@ var SHORT_CLIP_ONE_FRAME_TOLERANCE_MIN_EXPECTED_FRAMES = 14;
|
|
|
7101
7183
|
var SHORT_CLIP_ONE_FRAME_TOLERANCE_MAX_EXPECTED_FRAMES = 20;
|
|
7102
7184
|
var VideoFrameCoverageError = class extends Error {
|
|
7103
7185
|
// Read structurally by isVideoFrameCoverageError and cross-module callers.
|
|
7104
|
-
// fallow-ignore-next-line unused-class-member
|
|
7105
7186
|
hyperframesVideoFrameCoverageError = true;
|
|
7106
7187
|
threshold;
|
|
7107
7188
|
worst;
|
|
@@ -7188,8 +7269,8 @@ function countAuthoredTimedClips(html) {
|
|
|
7188
7269
|
}
|
|
7189
7270
|
|
|
7190
7271
|
// src/services/render/stages/compileStage.ts
|
|
7191
|
-
import { existsSync as existsSync13, writeFileSync as
|
|
7192
|
-
import { join as join23, relative as relative5 } from "node:path";
|
|
7272
|
+
import { existsSync as existsSync13, writeFileSync as writeFileSync5 } from "node:fs";
|
|
7273
|
+
import { join as join23, relative as relative5, resolve as resolve9 } from "node:path";
|
|
7193
7274
|
import { privateCacheRoot } from "@hyperframes/engine";
|
|
7194
7275
|
import { suggestMatchingPreset } from "@hyperframes/core";
|
|
7195
7276
|
import { extractStandaloneEntryFromIndex, isTemplateEntry } from "@hyperframes/core/compiler";
|
|
@@ -7198,7 +7279,8 @@ import { assertCompositionFileSize as assertCompositionFileSize2 } from "@hyperf
|
|
|
7198
7279
|
|
|
7199
7280
|
// src/services/compileInWorker.ts
|
|
7200
7281
|
import { existsSync as existsSync12, rmSync as rmSync11 } from "node:fs";
|
|
7201
|
-
import {
|
|
7282
|
+
import { ffmpegCwd } from "@hyperframes/parsers/ff-binaries";
|
|
7283
|
+
import { dirname as dirname11, isAbsolute as isAbsolute4, join as join22, relative as relative4, resolve as resolvePath } from "node:path";
|
|
7202
7284
|
import { fileURLToPath as fileURLToPath3 } from "node:url";
|
|
7203
7285
|
import { Worker } from "node:worker_threads";
|
|
7204
7286
|
|
|
@@ -7218,17 +7300,17 @@ import {
|
|
|
7218
7300
|
stylesheetLinkMatches
|
|
7219
7301
|
} from "@hyperframes/parsers/css-url-scans";
|
|
7220
7302
|
import { createHash as createHash6 } from "node:crypto";
|
|
7221
|
-
import { createReadStream as createReadStream3, existsSync as existsSync11, mkdirSync as
|
|
7222
|
-
import { join as join21, dirname as
|
|
7223
|
-
import { parseHTML as parseHTML5 } from "linkedom";
|
|
7303
|
+
import { createReadStream as createReadStream3, existsSync as existsSync11, mkdirSync as mkdirSync10, readFileSync as readFileSync9, statSync as statSync8 } from "fs";
|
|
7304
|
+
import { join as join21, dirname as dirname10, resolve as resolve8, basename as basename6, relative as relative3, sep as sep4 } from "path";
|
|
7305
|
+
import { parseHTML as parseHTML5 } from "@hyperframes/parsers/linkedom";
|
|
7224
7306
|
|
|
7225
7307
|
// src/services/bundledScripts.ts
|
|
7226
|
-
import { existsSync as existsSync8, readFileSync as
|
|
7308
|
+
import { existsSync as existsSync8, readFileSync as readFileSync6 } from "node:fs";
|
|
7227
7309
|
import { join as join17 } from "node:path";
|
|
7228
7310
|
import { GSAP_CDN_VERSION } from "@hyperframes/core/gsap-cdn";
|
|
7229
7311
|
var GSAP_VENDOR_DIR_ENV = "HYPERFRAMES_GSAP_VENDOR_DIR";
|
|
7230
7312
|
var DEFAULT_CDN_GSAP_3 = /^https:\/\/cdn\.jsdelivr\.net\/npm\/gsap@(3\.\d+\.\d+)\/dist\/([A-Za-z]+\.min\.js)$/;
|
|
7231
|
-
var read = (file) => existsSync8(file) ?
|
|
7313
|
+
var read = (file) => existsSync8(file) ? readFileSync6(file) : null;
|
|
7232
7314
|
function bundledScript(url) {
|
|
7233
7315
|
const dir = process.env[GSAP_VENDOR_DIR_ENV];
|
|
7234
7316
|
const [, version, file] = DEFAULT_CDN_GSAP_3.exec(url) ?? [];
|
|
@@ -7269,6 +7351,7 @@ import { gsapCdnDist, normalizeGsapBaseUrl } from "@hyperframes/core/gsap-cdn";
|
|
|
7269
7351
|
import {
|
|
7270
7352
|
assignBundledRuntimeCompositionIds,
|
|
7271
7353
|
assignMediaRenderIds,
|
|
7354
|
+
dropAuthoredCompositionFiles,
|
|
7272
7355
|
emitVariablesByCompScript,
|
|
7273
7356
|
inlineSubCompositions as inlineSubCompositionsShared,
|
|
7274
7357
|
ensureExternalLinkTag,
|
|
@@ -7302,7 +7385,7 @@ import {
|
|
|
7302
7385
|
readTextFile,
|
|
7303
7386
|
resolveCompositionSrc
|
|
7304
7387
|
} from "@hyperframes/parsers/asset-resolution";
|
|
7305
|
-
import { isPrivateFileUnder as
|
|
7388
|
+
import { isPrivateFileUnder as isPrivateFileUnder3, isStudioPrivatePath as isStudioPrivatePath3 } from "@hyperframes/core/safe-path";
|
|
7306
7389
|
import { linksOutside as linksOutside2 } from "@hyperframes/studio-server/outside-file";
|
|
7307
7390
|
import {
|
|
7308
7391
|
assertCompositionFileSize,
|
|
@@ -7313,7 +7396,7 @@ import {
|
|
|
7313
7396
|
} from "@hyperframes/core/compiler";
|
|
7314
7397
|
|
|
7315
7398
|
// src/services/renderMediaCollector.ts
|
|
7316
|
-
import { parseHTML as parseHTML2 } from "linkedom";
|
|
7399
|
+
import { parseHTML as parseHTML2 } from "@hyperframes/parsers/linkedom";
|
|
7317
7400
|
import {
|
|
7318
7401
|
MEDIA_RENDER_ID_ATTR,
|
|
7319
7402
|
normalizeRateSpec as normalizeRateSpec2,
|
|
@@ -7505,9 +7588,9 @@ import {
|
|
|
7505
7588
|
|
|
7506
7589
|
// src/services/animatedGifPrep.ts
|
|
7507
7590
|
import { createHash as createHash4, randomUUID } from "node:crypto";
|
|
7508
|
-
import { copyFileSync as copyFileSync2, existsSync as existsSync9, mkdirSync as
|
|
7509
|
-
import { dirname as
|
|
7510
|
-
import { parseHTML as parseHTML3 } from "linkedom";
|
|
7591
|
+
import { copyFileSync as copyFileSync2, existsSync as existsSync9, mkdirSync as mkdirSync8, readFileSync as readFileSync7, rmSync as rmSync9, statSync as statSync6 } from "node:fs";
|
|
7592
|
+
import { dirname as dirname7, isAbsolute as isAbsolute3, join as join18, resolve as resolve6 } from "node:path";
|
|
7593
|
+
import { parseHTML as parseHTML3 } from "@hyperframes/parsers/linkedom";
|
|
7511
7594
|
import { parseAnimatedGifMetadata } from "@hyperframes/core";
|
|
7512
7595
|
import {
|
|
7513
7596
|
DEFAULT_VP9_CPU_USED,
|
|
@@ -7559,7 +7642,11 @@ function resolveLocalImageSourcePath(src, options) {
|
|
|
7559
7642
|
resolve6(options.downloadDir, normalizedBase)
|
|
7560
7643
|
];
|
|
7561
7644
|
const assetRoot = options.allowOutsideFiles ? void 0 : options.projectDir;
|
|
7562
|
-
const allowed = (candidate) => !namesAnotherNetworkRoot(options.projectDir, candidate) && !isPrivateUnderAssetRoots(
|
|
7645
|
+
const allowed = (candidate) => !namesAnotherNetworkRoot(options.projectDir, candidate) && !isPrivateUnderAssetRoots(
|
|
7646
|
+
candidate,
|
|
7647
|
+
[options.projectDir, options.downloadDir],
|
|
7648
|
+
options.allowOutsideFiles
|
|
7649
|
+
) && (!escapesAssetRoot(candidate, assetRoot) && outsideAssetRefusal(options.projectDir, candidate) !== "blocklisted" || !escapesAssetRoot(candidate, options.downloadDir));
|
|
7563
7650
|
return candidates.find((candidate) => allowed(candidate) && existsSync9(candidate)) ?? null;
|
|
7564
7651
|
}
|
|
7565
7652
|
function isUsableFile(path) {
|
|
@@ -7688,11 +7775,11 @@ async function runAnimatedGifTranscode(request) {
|
|
|
7688
7775
|
throw result.error ?? new Error(`Animated GIF transcode failed (${result.exitCode}): ${result.stderr.slice(-500)}`);
|
|
7689
7776
|
}
|
|
7690
7777
|
async function ensurePreparedWebm(input) {
|
|
7691
|
-
if (!existsSync9(
|
|
7692
|
-
|
|
7778
|
+
if (!existsSync9(dirname7(input.cachePath))) {
|
|
7779
|
+
mkdirSync8(dirname7(input.cachePath), { recursive: true });
|
|
7693
7780
|
}
|
|
7694
|
-
if (!existsSync9(
|
|
7695
|
-
|
|
7781
|
+
if (!existsSync9(dirname7(input.outputPath))) {
|
|
7782
|
+
mkdirSync8(dirname7(input.outputPath), { recursive: true });
|
|
7696
7783
|
}
|
|
7697
7784
|
if (!isUsableFile(input.cachePath)) {
|
|
7698
7785
|
const tmpPath = `${input.cachePath}.tmp-${process.pid}-${randomUUID()}`;
|
|
@@ -7793,7 +7880,7 @@ async function prepareAnimatedGifInputs(html, options) {
|
|
|
7793
7880
|
if (!hasGifExtension(src)) continue;
|
|
7794
7881
|
const sourcePath = resolveLocalImageSourcePath(src, options);
|
|
7795
7882
|
if (!sourcePath) continue;
|
|
7796
|
-
const bytes =
|
|
7883
|
+
const bytes = readFileSync7(sourcePath);
|
|
7797
7884
|
const metadata = parseAnimatedGifMetadata(bytes);
|
|
7798
7885
|
if (!metadata?.animated) continue;
|
|
7799
7886
|
const loopOverride = readLoopOverride(img);
|
|
@@ -7845,16 +7932,16 @@ import { createHash as createHash5, randomUUID as randomUUID2 } from "node:crypt
|
|
|
7845
7932
|
import {
|
|
7846
7933
|
closeSync as closeSync5,
|
|
7847
7934
|
copyFileSync as copyFileSync3,
|
|
7848
|
-
mkdirSync as
|
|
7935
|
+
mkdirSync as mkdirSync9,
|
|
7849
7936
|
openSync as openSync5,
|
|
7850
|
-
readFileSync as
|
|
7937
|
+
readFileSync as readFileSync8,
|
|
7851
7938
|
readSync as readSync3,
|
|
7852
7939
|
rmSync as rmSync10,
|
|
7853
7940
|
statSync as statSync7,
|
|
7854
|
-
writeFileSync as
|
|
7941
|
+
writeFileSync as writeFileSync4
|
|
7855
7942
|
} from "node:fs";
|
|
7856
|
-
import { dirname as
|
|
7857
|
-
import { parseHTML as parseHTML4 } from "linkedom";
|
|
7943
|
+
import { dirname as dirname8, join as join19, resolve as resolve7 } from "node:path";
|
|
7944
|
+
import { parseHTML as parseHTML4 } from "@hyperframes/parsers/linkedom";
|
|
7858
7945
|
import { renameWithRetry as renameWithRetry3, runFfmpeg as runFfmpeg3, runFfprobe, urlInputArgs as urlInputArgs3 } from "@hyperframes/engine";
|
|
7859
7946
|
|
|
7860
7947
|
// src/services/heifRotation.ts
|
|
@@ -7922,10 +8009,10 @@ var Semaphore = class {
|
|
|
7922
8009
|
this.active++;
|
|
7923
8010
|
return () => this.release();
|
|
7924
8011
|
}
|
|
7925
|
-
return new Promise((
|
|
8012
|
+
return new Promise((resolve13) => {
|
|
7926
8013
|
this.queue.push(() => {
|
|
7927
8014
|
this.active++;
|
|
7928
|
-
|
|
8015
|
+
resolve13(() => this.release());
|
|
7929
8016
|
});
|
|
7930
8017
|
});
|
|
7931
8018
|
}
|
|
@@ -8038,7 +8125,7 @@ function primaryGrid(probed) {
|
|
|
8038
8125
|
async function convertHeifToJpeg(request) {
|
|
8039
8126
|
const probed = await probeJson(request.inputPath, true);
|
|
8040
8127
|
const grid = primaryGrid(probed);
|
|
8041
|
-
const rotation = readHeifPrimaryRotation(
|
|
8128
|
+
const rotation = readHeifPrimaryRotation(readFileSync8(request.inputPath));
|
|
8042
8129
|
const filters = [];
|
|
8043
8130
|
let inputs = [];
|
|
8044
8131
|
let size = probed.streams?.[0];
|
|
@@ -8102,7 +8189,7 @@ function resolveImageSource(src, options) {
|
|
|
8102
8189
|
const path = resolveLocalImageSourcePath(src, options);
|
|
8103
8190
|
const head = path ? readHead(path) : null;
|
|
8104
8191
|
if (!path || !head || !isHeifBytes(head)) return null;
|
|
8105
|
-
return { path, bytes:
|
|
8192
|
+
return { path, bytes: readFileSync8(path), label: `"${splitUrlSuffix(src).basePath}"` };
|
|
8106
8193
|
}
|
|
8107
8194
|
function isUsableFile2(path) {
|
|
8108
8195
|
try {
|
|
@@ -8112,14 +8199,14 @@ function isUsableFile2(path) {
|
|
|
8112
8199
|
}
|
|
8113
8200
|
}
|
|
8114
8201
|
async function ensurePreparedJpeg(source, cachePath, outputPath, options) {
|
|
8115
|
-
|
|
8116
|
-
|
|
8202
|
+
mkdirSync9(dirname8(cachePath), { recursive: true });
|
|
8203
|
+
mkdirSync9(dirname8(outputPath), { recursive: true });
|
|
8117
8204
|
if (!isUsableFile2(cachePath)) {
|
|
8118
8205
|
const tmpPath = `${cachePath}.tmp-${process.pid}-${randomUUID2()}`;
|
|
8119
8206
|
const inlinePath = `${tmpPath}.heic`;
|
|
8120
8207
|
const inputPath = source.path ?? inlinePath;
|
|
8121
8208
|
try {
|
|
8122
|
-
if (!source.path)
|
|
8209
|
+
if (!source.path) writeFileSync4(inlinePath, source.bytes);
|
|
8123
8210
|
await (options.transcode ?? convertHeifToJpeg)({
|
|
8124
8211
|
inputPath,
|
|
8125
8212
|
outputPath: tmpPath,
|
|
@@ -8192,7 +8279,7 @@ import { getPositionEditsRenderScript } from "@hyperframes/core/runtime/position
|
|
|
8192
8279
|
|
|
8193
8280
|
// src/services/assetMediaType.ts
|
|
8194
8281
|
import { existsSync as existsSync10 } from "node:fs";
|
|
8195
|
-
import { dirname as
|
|
8282
|
+
import { dirname as dirname9, join as join20 } from "node:path";
|
|
8196
8283
|
import {
|
|
8197
8284
|
fingerprintElementId,
|
|
8198
8285
|
isHttpUrl as isHttpUrl2,
|
|
@@ -8246,7 +8333,7 @@ function assertAssetMediaTypeProfile(expected, profile, elementIdentity) {
|
|
|
8246
8333
|
]);
|
|
8247
8334
|
}
|
|
8248
8335
|
function mediaAssetRoots(projectDir, compiledDir) {
|
|
8249
|
-
return [projectDir, compiledDir, join20(
|
|
8336
|
+
return [projectDir, compiledDir, join20(dirname9(compiledDir), "downloads")];
|
|
8250
8337
|
}
|
|
8251
8338
|
function dropMediaOutsideProject(input) {
|
|
8252
8339
|
const { projectDir, workDir, composition, log } = input;
|
|
@@ -8255,7 +8342,7 @@ function dropMediaOutsideProject(input) {
|
|
|
8255
8342
|
const staysInside = ({ id, src }) => {
|
|
8256
8343
|
if (!src || isHttpUrl2(src)) return true;
|
|
8257
8344
|
const path = resolveProjectRelativeSrc3(src, projectDir, compiledDir);
|
|
8258
|
-
if (isPrivateUnderAssetRoots2(path, roots)) {
|
|
8345
|
+
if (isPrivateUnderAssetRoots2(path, roots, input.allowOutsideProjectAssets)) {
|
|
8259
8346
|
log.warn(`[Render] Media "${id}" source is missing: it is a private project file`, { src });
|
|
8260
8347
|
return false;
|
|
8261
8348
|
}
|
|
@@ -8425,7 +8512,7 @@ function assertOutsideMarkupAsked(projectDir, filePath, srcPath, assetRoot, outs
|
|
|
8425
8512
|
throw new EmptyCompositionError([{ srcPath, detail: OUTSIDE_COMPOSITION_NEEDS_FLAG }]);
|
|
8426
8513
|
}
|
|
8427
8514
|
}
|
|
8428
|
-
var isPrivateCompositionFile = (projectDir, filePath) =>
|
|
8515
|
+
var isPrivateCompositionFile = (projectDir, filePath) => isPrivateFileUnder3(projectDir, filePath, isStudioPrivatePath3);
|
|
8429
8516
|
function compositionSrcsIn(html) {
|
|
8430
8517
|
const { document: document2 } = parseHTML5(html);
|
|
8431
8518
|
const mounts = [];
|
|
@@ -8727,7 +8814,7 @@ var AssetDownloads = class {
|
|
|
8727
8814
|
}
|
|
8728
8815
|
async download(url, destDir) {
|
|
8729
8816
|
while (this.running >= ASSET_DOWNLOADS_AT_ONCE) {
|
|
8730
|
-
await new Promise((
|
|
8817
|
+
await new Promise((resolve13) => this.queued.push(resolve13));
|
|
8731
8818
|
}
|
|
8732
8819
|
if (this.signal?.aborted) {
|
|
8733
8820
|
this.queued.shift()?.();
|
|
@@ -8751,7 +8838,7 @@ async function resolveMediaDuration(src, mediaStart, playbackRate, projectDir, b
|
|
|
8751
8838
|
let filePath = src;
|
|
8752
8839
|
if (isHttpUrl(src)) {
|
|
8753
8840
|
const remoteDir = join21(downloadDir, REMOTE_MEDIA_SUBDIR);
|
|
8754
|
-
if (!existsSync11(remoteDir))
|
|
8841
|
+
if (!existsSync11(remoteDir)) mkdirSync10(remoteDir, { recursive: true });
|
|
8755
8842
|
run?.assets.reserve([src]);
|
|
8756
8843
|
try {
|
|
8757
8844
|
filePath = await downloadAsset(src, remoteDir, run?.assets);
|
|
@@ -8762,7 +8849,7 @@ async function resolveMediaDuration(src, mediaStart, playbackRate, projectDir, b
|
|
|
8762
8849
|
} else {
|
|
8763
8850
|
filePath = decodedUrlPath(src);
|
|
8764
8851
|
if (!filePath.startsWith("/")) filePath = join21(baseDir, filePath);
|
|
8765
|
-
if (escapesAssetRoot(filePath, assetRoot) || isPrivateUnderAssetRoots3(filePath, [projectDir, downloadDir])) {
|
|
8852
|
+
if (escapesAssetRoot(filePath, assetRoot) || isPrivateUnderAssetRoots3(filePath, [projectDir, downloadDir], assetRoot === void 0)) {
|
|
8766
8853
|
return { duration: null, resolvedPath: filePath };
|
|
8767
8854
|
}
|
|
8768
8855
|
filePath = urlByAbsentLocalPath?.get(filePath) ?? filePath;
|
|
@@ -8945,7 +9032,7 @@ async function parseSubCompositions(html, projectDir, downloadDir, visited = /*
|
|
|
8945
9032
|
const { html: compiledSub } = await compileHtmlFile(
|
|
8946
9033
|
rewriteUnresolvableGsapToCdn(item.rawSubHtml, projectDir, item.srcPath),
|
|
8947
9034
|
projectDir,
|
|
8948
|
-
|
|
9035
|
+
dirname10(item.filePath),
|
|
8949
9036
|
downloadDir,
|
|
8950
9037
|
void 0,
|
|
8951
9038
|
urlByAbsentLocalPath,
|
|
@@ -9116,6 +9203,7 @@ function coalesceHeadStylesAndBodyScripts(html) {
|
|
|
9116
9203
|
}
|
|
9117
9204
|
function inlineSubCompositions(html, subCompositions, projectDir, variableOverrides, assetRoot, outsideFiles, budget) {
|
|
9118
9205
|
const { document: document2 } = parseHTML5(html);
|
|
9206
|
+
dropAuthoredCompositionFiles(document2);
|
|
9119
9207
|
budget.chargeElements(ENTRY_PAGE, document2.querySelectorAll("*").length);
|
|
9120
9208
|
const head = document2.querySelector("head");
|
|
9121
9209
|
const body = document2.querySelector("body");
|
|
@@ -9518,7 +9606,7 @@ var REMOTE_MEDIA_SUBDIR = "_remote_media";
|
|
|
9518
9606
|
async function downloadAndRewriteUrls(urlSet, html, remoteDir, warnLabel, logLabel, assets, extraRewrite) {
|
|
9519
9607
|
assets?.reserve(urlSet);
|
|
9520
9608
|
if (urlSet.size === 0) return { html, remoteMediaAssets: /* @__PURE__ */ new Map() };
|
|
9521
|
-
if (!existsSync11(remoteDir))
|
|
9609
|
+
if (!existsSync11(remoteDir)) mkdirSync10(remoteDir, { recursive: true });
|
|
9522
9610
|
const urlToLocal = /* @__PURE__ */ new Map();
|
|
9523
9611
|
await Promise.all(
|
|
9524
9612
|
[...urlSet].map(async (url) => {
|
|
@@ -9715,11 +9803,11 @@ function projectStylesheetFontFamilies(html, projectDir) {
|
|
|
9715
9803
|
if (!href || /^(?:[a-z][a-z\d+.-]*:|\/\/)/i.test(href)) continue;
|
|
9716
9804
|
const sheet = resolve8(projectDir, decodedUrlPath(href).replace(/^(?:\.?\/)+/, ""));
|
|
9717
9805
|
if (!isPathInside(sheet, projectDir) || !existsSync11(sheet)) continue;
|
|
9718
|
-
for (const face of extractFontFaceBlocks(
|
|
9806
|
+
for (const face of extractFontFaceBlocks(readFileSync9(sheet, "utf8"))) {
|
|
9719
9807
|
const family = /font-family\s*:\s*([^;}]+)/i.exec(face)?.[1]?.trim().replace(/^['"]|['"]$/g, "");
|
|
9720
9808
|
const shipsFile = [...localFontFaceUrlMatches(face)].some(({ parts: [, url = ""] }) => {
|
|
9721
9809
|
const path = decodedUrlPath(url);
|
|
9722
|
-
const file = path.startsWith("/") ? resolve8(projectDir, `.${path}`) : resolve8(
|
|
9810
|
+
const file = path.startsWith("/") ? resolve8(projectDir, `.${path}`) : resolve8(dirname10(sheet), path);
|
|
9723
9811
|
return isPathInside(file, projectDir) && existsSync11(file);
|
|
9724
9812
|
});
|
|
9725
9813
|
if (family && shipsFile) families.push(family);
|
|
@@ -10162,7 +10250,7 @@ async function compileWithAssets(projectDir, htmlPath, downloadDir, options, ass
|
|
|
10162
10250
|
for (const video of videos) {
|
|
10163
10251
|
if (isHttpUrl(video.src)) continue;
|
|
10164
10252
|
const videoPath = resolve8(projectDir, video.src);
|
|
10165
|
-
if (advised.has(videoPath) || namesAnotherNetworkRoot2(projectDir, videoPath) || !existsSync11(videoPath) || escapesAssetRoot(videoPath, assetRoot) || isPrivateUnderAssetRoots3(videoPath, [projectDir, downloadDir]))
|
|
10253
|
+
if (advised.has(videoPath) || namesAnotherNetworkRoot2(projectDir, videoPath) || !existsSync11(videoPath) || escapesAssetRoot(videoPath, assetRoot) || isPrivateUnderAssetRoots3(videoPath, [projectDir, downloadDir], assetRoot === void 0))
|
|
10166
10254
|
continue;
|
|
10167
10255
|
advised.add(videoPath);
|
|
10168
10256
|
const reencode = `ffmpeg -i "${video.src}" -c:v libx264 -r 30 -g 30 -keyint_min 30 -movflags +faststart -c:a copy output.mp4`;
|
|
@@ -10628,7 +10716,7 @@ function resolveCompileWorkerEntry(explicit, log) {
|
|
|
10628
10716
|
}
|
|
10629
10717
|
return void 0;
|
|
10630
10718
|
}
|
|
10631
|
-
const sibling = join22(
|
|
10719
|
+
const sibling = join22(dirname11(fileURLToPath3(import.meta.url)), "compileWorker.js");
|
|
10632
10720
|
return existsSync12(sibling) ? sibling : void 0;
|
|
10633
10721
|
}
|
|
10634
10722
|
function rebuildError({ name, message, stack, props }) {
|
|
@@ -10643,9 +10731,15 @@ async function compileForRenderInWorker(projectDir, htmlPath, downloadDir, optio
|
|
|
10643
10731
|
if (!entry) return compileForRender(projectDir, htmlPath, downloadDir, options);
|
|
10644
10732
|
abortSignal?.throwIfAborted();
|
|
10645
10733
|
const timeoutMs = worker.timeoutMs ?? compileTimeoutMs();
|
|
10646
|
-
return new Promise((
|
|
10734
|
+
return new Promise((resolve13, reject) => {
|
|
10647
10735
|
const thread = new Worker(entry, {
|
|
10648
|
-
workerData: {
|
|
10736
|
+
workerData: {
|
|
10737
|
+
projectDir,
|
|
10738
|
+
htmlPath,
|
|
10739
|
+
downloadDir,
|
|
10740
|
+
options: cloneable,
|
|
10741
|
+
emptyFolder: ffmpegCwd() !== void 0
|
|
10742
|
+
}
|
|
10649
10743
|
});
|
|
10650
10744
|
const children = /* @__PURE__ */ new Map();
|
|
10651
10745
|
const scratchRoots = [downloadDir, options.animatedGifCacheDir].flatMap(
|
|
@@ -10699,7 +10793,7 @@ async function compileForRenderInWorker(projectDir, htmlPath, downloadDir, optio
|
|
|
10699
10793
|
log?.[message.level](message.message ?? "", message.meta);
|
|
10700
10794
|
} else if (message.type === "result" && message.compiled) {
|
|
10701
10795
|
const { compiled } = message;
|
|
10702
|
-
settle(() =>
|
|
10796
|
+
settle(() => resolve13(compiled));
|
|
10703
10797
|
retire(ADVISORY_GRACE_MS);
|
|
10704
10798
|
} else if (message.type === "error" && message.error) {
|
|
10705
10799
|
const { error } = message;
|
|
@@ -10731,7 +10825,7 @@ async function compileForRenderInWorker(projectDir, htmlPath, downloadDir, optio
|
|
|
10731
10825
|
// src/services/render/stages/compileStage.ts
|
|
10732
10826
|
function animatedGifCacheDir(extractCacheDir) {
|
|
10733
10827
|
try {
|
|
10734
|
-
const root = extractCacheDir && privateCacheRoot(extractCacheDir);
|
|
10828
|
+
const root = extractCacheDir && privateCacheRoot(resolve9(extractCacheDir));
|
|
10735
10829
|
return root ? join23(root, "animated-gif") : void 0;
|
|
10736
10830
|
} catch {
|
|
10737
10831
|
return void 0;
|
|
@@ -10780,7 +10874,7 @@ function resolveEntryHtmlPath(input) {
|
|
|
10780
10874
|
);
|
|
10781
10875
|
}
|
|
10782
10876
|
const wrapperPath = join23(workDir, "standalone-entry.html");
|
|
10783
|
-
|
|
10877
|
+
writeFileSync5(wrapperPath, standaloneHtml, "utf-8");
|
|
10784
10878
|
log.info("Extracted standalone entry from index.html host context", { entryFile });
|
|
10785
10879
|
return wrapperPath;
|
|
10786
10880
|
}
|
|
@@ -10938,7 +11032,7 @@ async function runCompileStage(input) {
|
|
|
10938
11032
|
// src/services/render/stages/probeStage.ts
|
|
10939
11033
|
import { createHash as createHash7 } from "node:crypto";
|
|
10940
11034
|
import { basename as basename7, join as join24 } from "node:path";
|
|
10941
|
-
import { parseHTML as parseHTML6 } from "linkedom";
|
|
11035
|
+
import { parseHTML as parseHTML6 } from "@hyperframes/parsers/linkedom";
|
|
10942
11036
|
import {
|
|
10943
11037
|
closeCaptureSession as closeCaptureSession4,
|
|
10944
11038
|
compositionRequiresWebGpu,
|
|
@@ -12408,7 +12502,7 @@ import {
|
|
|
12408
12502
|
|
|
12409
12503
|
// src/services/render/audioDeliveryLimit.ts
|
|
12410
12504
|
import { existsSync as existsSync16 } from "node:fs";
|
|
12411
|
-
import { dirname as
|
|
12505
|
+
import { dirname as dirname13, join as join27 } from "node:path";
|
|
12412
12506
|
import {
|
|
12413
12507
|
applyAudioFxChain,
|
|
12414
12508
|
describeFfmpegFailure as describeFfmpegFailure3,
|
|
@@ -12417,9 +12511,9 @@ import {
|
|
|
12417
12511
|
} from "@hyperframes/engine";
|
|
12418
12512
|
|
|
12419
12513
|
// src/services/render/audioPadTrim.ts
|
|
12420
|
-
import { localContainerInputArgs } from "@hyperframes/parsers/ff-binaries";
|
|
12514
|
+
import { ffmpegCwd as ffmpegCwd2, localContainerInputArgs } from "@hyperframes/parsers/ff-binaries";
|
|
12421
12515
|
import { spawn } from "node:child_process";
|
|
12422
|
-
import { dirname as
|
|
12516
|
+
import { dirname as dirname12, join as join26 } from "node:path";
|
|
12423
12517
|
import {
|
|
12424
12518
|
DEFAULT_CONFIG,
|
|
12425
12519
|
describeFfmpegFailure as describeFfmpegFailure2,
|
|
@@ -12714,7 +12808,7 @@ async function cutSource(input, scratchDir, attenuationDb) {
|
|
|
12714
12808
|
async function enforceAacTruePeak(input) {
|
|
12715
12809
|
let scratchDir;
|
|
12716
12810
|
try {
|
|
12717
|
-
scratchDir = createStagingDir3(
|
|
12811
|
+
scratchDir = createStagingDir3(dirname12(input.audioPath), ".true-peak-");
|
|
12718
12812
|
const correctedPath = join26(scratchDir, "audio.m4a");
|
|
12719
12813
|
const measurements = [];
|
|
12720
12814
|
let attenuationDb = 0;
|
|
@@ -12888,6 +12982,7 @@ async function spawnFfprobeJson(args, env, signal) {
|
|
|
12888
12982
|
const proc = spawn(getFfprobeBinary(), args, {
|
|
12889
12983
|
...env && { env },
|
|
12890
12984
|
stdio: ["ignore", "pipe", "pipe"],
|
|
12985
|
+
cwd: ffmpegCwd2(),
|
|
12891
12986
|
windowsHide: true
|
|
12892
12987
|
});
|
|
12893
12988
|
trackChildProcess(proc);
|
|
@@ -12938,7 +13033,7 @@ async function limitDeliveryPeaks(input, deps = {
|
|
|
12938
13033
|
const peak = await deps.measure(audioPath, { timeoutMs, signal });
|
|
12939
13034
|
if (peak <= AAC_DELIVERY_TRUE_PEAK_DBFS) return { success: true };
|
|
12940
13035
|
const alternating = ["a", "b"].map(
|
|
12941
|
-
(k) => join27(
|
|
13036
|
+
(k) => join27(dirname13(sourcePath), `audio-source-limited-${k}.wav`)
|
|
12942
13037
|
);
|
|
12943
13038
|
let encodedFrom;
|
|
12944
13039
|
let ceiling = AAC_DELIVERY_TRUE_PEAK_DBFS;
|
|
@@ -13012,10 +13107,15 @@ function runAudioStage(input) {
|
|
|
13012
13107
|
async function runAudioStageScoped(input) {
|
|
13013
13108
|
const stageStart = Date.now();
|
|
13014
13109
|
const pcmSourcePath = join28(input.workDir, "audio-source.wav");
|
|
13015
|
-
const
|
|
13110
|
+
const seconds = (frames) => frames * input.fps.den / input.fps.num;
|
|
13111
|
+
const duration = seconds(input.totalFrames);
|
|
13112
|
+
const window2 = input.frameWindow && {
|
|
13113
|
+
startSeconds: seconds(input.frameWindow.startFrame),
|
|
13114
|
+
durationSeconds: seconds(input.frameWindow.endFrame - input.frameWindow.startFrame)
|
|
13115
|
+
};
|
|
13016
13116
|
let deliverySourcePath;
|
|
13017
13117
|
try {
|
|
13018
|
-
const result = await mixAudioForDelivery(input, duration, pcmSourcePath);
|
|
13118
|
+
const result = await mixAudioForDelivery(input, duration, pcmSourcePath, window2);
|
|
13019
13119
|
let audioLoweredDb;
|
|
13020
13120
|
if (result.hasAudio) {
|
|
13021
13121
|
const guardStart = Date.now();
|
|
@@ -13023,7 +13123,7 @@ async function runAudioStageScoped(input) {
|
|
|
13023
13123
|
input,
|
|
13024
13124
|
result.audioOutputPath,
|
|
13025
13125
|
pcmSourcePath,
|
|
13026
|
-
duration
|
|
13126
|
+
window2?.durationSeconds ?? duration
|
|
13027
13127
|
);
|
|
13028
13128
|
audioLoweredDb = guard.loweredDb;
|
|
13029
13129
|
input.log?.info("[audio] phases", { ...result.audioPhaseMs, guard: Date.now() - guardStart });
|
|
@@ -13061,7 +13161,7 @@ async function guardDeliveryPeaks(input, audioPath, sourcePath, duration) {
|
|
|
13061
13161
|
if (!peak.success) throw encoderFailureError("Audio true-peak check failed", peak);
|
|
13062
13162
|
return { loweredDb: peak.loweredDb, sourceStale: peak.sourceStale };
|
|
13063
13163
|
}
|
|
13064
|
-
async function mixAudioForDelivery(input, duration, pcmSourcePath) {
|
|
13164
|
+
async function mixAudioForDelivery(input, duration, pcmSourcePath, window2) {
|
|
13065
13165
|
const {
|
|
13066
13166
|
projectDir,
|
|
13067
13167
|
workDir,
|
|
@@ -13098,6 +13198,7 @@ async function mixAudioForDelivery(input, duration, pcmSourcePath) {
|
|
|
13098
13198
|
urlByAbsentLocalPath,
|
|
13099
13199
|
audioSidecarUrlByLocalPath,
|
|
13100
13200
|
keepEncoderInputAt: pcmSourcePath,
|
|
13201
|
+
window: window2,
|
|
13101
13202
|
assetRoots: input.allowOutsideProjectAssets ? void 0 : mediaAssetRoots(projectDir, compiledDir)
|
|
13102
13203
|
},
|
|
13103
13204
|
compiledDir
|
|
@@ -13169,6 +13270,7 @@ import {
|
|
|
13169
13270
|
completeDeferredDrawElementInit as completeDeferredDrawElementInit3,
|
|
13170
13271
|
createCaptureSession as createCaptureSession5,
|
|
13171
13272
|
getCapturePerfSummary as getCapturePerfSummary3,
|
|
13273
|
+
retainCapturePerf as retainCapturePerf4,
|
|
13172
13274
|
initializeSession as initializeSession5,
|
|
13173
13275
|
prepareCaptureSessionForReuse as prepareCaptureSessionForReuse3
|
|
13174
13276
|
} from "@hyperframes/engine";
|
|
@@ -13505,7 +13607,7 @@ async function captureSessionFrames(session, { input, rangeStart, rangeEnd, resu
|
|
|
13505
13607
|
assertNotAborted();
|
|
13506
13608
|
const absoluteIdx = rangeStart + i;
|
|
13507
13609
|
const time = absoluteIdx * job.config.fps.den / job.config.fps.num;
|
|
13508
|
-
const { encodeResult } = await captureFrameToBufferPipelined2(session,
|
|
13610
|
+
const { encodeResult } = await captureFrameToBufferPipelined2(session, absoluteIdx, time);
|
|
13509
13611
|
await drainPrev();
|
|
13510
13612
|
prev = { fileIndex: i, encodeResult };
|
|
13511
13613
|
}
|
|
@@ -13515,7 +13617,7 @@ async function captureSessionFrames(session, { input, rangeStart, rangeEnd, resu
|
|
|
13515
13617
|
assertNotAborted();
|
|
13516
13618
|
const absoluteIdx = rangeStart + i;
|
|
13517
13619
|
const time = absoluteIdx * job.config.fps.den / job.config.fps.num;
|
|
13518
|
-
await captureFrame(session,
|
|
13620
|
+
await captureFrame(session, absoluteIdx, time, i);
|
|
13519
13621
|
reportFrame(i);
|
|
13520
13622
|
}
|
|
13521
13623
|
}
|
|
@@ -13530,11 +13632,11 @@ async function captureSessionFrames(session, { input, rangeStart, rangeEnd, resu
|
|
|
13530
13632
|
},
|
|
13531
13633
|
false
|
|
13532
13634
|
);
|
|
13533
|
-
dedupPerfs
|
|
13635
|
+
retainCapturePerf4(dedupPerfs, getCapturePerfSummary3(session));
|
|
13534
13636
|
}
|
|
13535
13637
|
|
|
13536
13638
|
// src/services/render/stages/captureHdrStage.ts
|
|
13537
|
-
import { existsSync as existsSync20, mkdirSync as
|
|
13639
|
+
import { existsSync as existsSync20, mkdirSync as mkdirSync11 } from "node:fs";
|
|
13538
13640
|
import { join as join33 } from "node:path";
|
|
13539
13641
|
import {
|
|
13540
13642
|
closeCaptureSession as closeCaptureSession7,
|
|
@@ -13646,9 +13748,18 @@ async function runSequentialLayeredFrameLoop(input) {
|
|
|
13646
13748
|
output: Buffer.alloc(bufSize)
|
|
13647
13749
|
} : null;
|
|
13648
13750
|
const normalCanvas = Buffer.alloc(bufSize);
|
|
13751
|
+
const firstFrame = windowStartFrame(job.frameWindow);
|
|
13752
|
+
cleanupHdrVideosEndedBefore(firstFrame, job.config.fps, transitionRanges, {
|
|
13753
|
+
hdrVideoEndTimes,
|
|
13754
|
+
cleanedUpVideos,
|
|
13755
|
+
hdrVideoFrameSources,
|
|
13756
|
+
sceneElements,
|
|
13757
|
+
log
|
|
13758
|
+
});
|
|
13649
13759
|
for (let i = 0; i < totalFrames; i++) {
|
|
13650
13760
|
assertNotAborted();
|
|
13651
|
-
const
|
|
13761
|
+
const frame = firstFrame + i;
|
|
13762
|
+
const time = frame * job.config.fps.den / job.config.fps.num;
|
|
13652
13763
|
if (hdrPerf) hdrPerf.frames += 1;
|
|
13653
13764
|
const stackingInfo = await seekInjectAndQueryStacking(
|
|
13654
13765
|
domSession.page,
|
|
@@ -13660,11 +13771,11 @@ async function runSequentialLayeredFrameLoop(input) {
|
|
|
13660
13771
|
"frameInjectMs",
|
|
13661
13772
|
"stackingQueryMs"
|
|
13662
13773
|
);
|
|
13663
|
-
const activeTransition = transitionRanges
|
|
13774
|
+
const activeTransition = transitionAtFrame(transitionRanges, frame);
|
|
13664
13775
|
if (i % 30 === 0 && (log.isLevelEnabled?.("debug") ?? true)) {
|
|
13665
13776
|
const hdrEl = stackingInfo.find((e) => e.isHdr);
|
|
13666
13777
|
log.debug("[Render] HDR layer composite frame", {
|
|
13667
|
-
frame
|
|
13778
|
+
frame,
|
|
13668
13779
|
time: time.toFixed(2),
|
|
13669
13780
|
hdrElement: hdrEl ? { z: hdrEl.zIndex, visible: hdrEl.visible, width: hdrEl.width } : null,
|
|
13670
13781
|
stackingCount: stackingInfo.length,
|
|
@@ -13674,7 +13785,7 @@ async function runSequentialLayeredFrameLoop(input) {
|
|
|
13674
13785
|
if (activeTransition && transitionBuffers) {
|
|
13675
13786
|
if (hdrPerf) hdrPerf.transitionFrames += 1;
|
|
13676
13787
|
const transitionTimingStart = Date.now();
|
|
13677
|
-
const progress = activeTransition.endFrame === activeTransition.startFrame ? 1 : (
|
|
13788
|
+
const progress = activeTransition.endFrame === activeTransition.startFrame ? 1 : (frame - activeTransition.startFrame) / (activeTransition.endFrame - activeTransition.startFrame);
|
|
13678
13789
|
const sceneAIds = new Set(sceneElements[activeTransition.fromScene] ?? []);
|
|
13679
13790
|
const sceneBIds = new Set(sceneElements[activeTransition.toScene] ?? []);
|
|
13680
13791
|
timeHdrPhase(hdrPerf, "canvasClearMs", () => {
|
|
@@ -13703,7 +13814,7 @@ async function runSequentialLayeredFrameLoop(input) {
|
|
|
13703
13814
|
hdrTargetTransfer,
|
|
13704
13815
|
hdrPerf,
|
|
13705
13816
|
log,
|
|
13706
|
-
frameIdx:
|
|
13817
|
+
frameIdx: frame
|
|
13707
13818
|
});
|
|
13708
13819
|
}
|
|
13709
13820
|
const shaderName = activeTransition.shader;
|
|
@@ -13728,7 +13839,7 @@ async function runSequentialLayeredFrameLoop(input) {
|
|
|
13728
13839
|
await timeHdrPhaseAsync(
|
|
13729
13840
|
hdrPerf,
|
|
13730
13841
|
"normalCompositeMs",
|
|
13731
|
-
() => compositeHdrFrame(hdrCompositeCtx, normalCanvas, time, stackingInfo, void 0,
|
|
13842
|
+
() => compositeHdrFrame(hdrCompositeCtx, normalCanvas, time, stackingInfo, void 0, frame)
|
|
13732
13843
|
);
|
|
13733
13844
|
if (debugDumpEnabled && debugDumpDir && i % 30 === 0) {
|
|
13734
13845
|
writeFileExclusiveSync(
|
|
@@ -13778,7 +13889,7 @@ import {
|
|
|
13778
13889
|
// src/services/shaderTransitionWorkerPool.ts
|
|
13779
13890
|
import { Worker as Worker2 } from "node:worker_threads";
|
|
13780
13891
|
import { fileURLToPath as fileURLToPath4, pathToFileURL } from "node:url";
|
|
13781
|
-
import { dirname as
|
|
13892
|
+
import { dirname as dirname14, join as join31 } from "node:path";
|
|
13782
13893
|
import { createRequire } from "node:module";
|
|
13783
13894
|
import { usableCpuCount } from "@hyperframes/engine";
|
|
13784
13895
|
import { existsSync as existsSync19 } from "node:fs";
|
|
@@ -13791,7 +13902,7 @@ function resolveWorkerEntry(explicit) {
|
|
|
13791
13902
|
const isTs = override.endsWith(".ts");
|
|
13792
13903
|
return { path: override, isTs };
|
|
13793
13904
|
}
|
|
13794
|
-
const moduleDir =
|
|
13905
|
+
const moduleDir = dirname14(fileURLToPath4(import.meta.url));
|
|
13795
13906
|
const jsPath = join31(moduleDir, "shaderTransitionWorker.js");
|
|
13796
13907
|
if (existsSync19(jsPath)) return { path: jsPath, isTs: false };
|
|
13797
13908
|
const tsPath = join31(moduleDir, "shaderTransitionWorker.ts");
|
|
@@ -13937,8 +14048,8 @@ async function createShaderTransitionWorkerPool(opts) {
|
|
|
13937
14048
|
if (terminated) {
|
|
13938
14049
|
throw new Error("shader-blend pool already terminated");
|
|
13939
14050
|
}
|
|
13940
|
-
return new Promise((
|
|
13941
|
-
const task = traceEnabled ? { req, resolve:
|
|
14051
|
+
return new Promise((resolve13, reject) => {
|
|
14052
|
+
const task = traceEnabled ? { req, resolve: resolve13, reject, enqueuedAtMs: Date.now(), traceId: ++nextTaskId } : { req, resolve: resolve13, reject };
|
|
13942
14053
|
const idle = slots.find((s) => !s.busy && !s.dead);
|
|
13943
14054
|
if (idle) {
|
|
13944
14055
|
queue.unshift(task);
|
|
@@ -13999,7 +14110,8 @@ async function runHybridLayeredFrameLoop(input) {
|
|
|
13999
14110
|
assertNotAborted,
|
|
14000
14111
|
onProgress
|
|
14001
14112
|
} = input;
|
|
14002
|
-
const
|
|
14113
|
+
const firstFrame = windowStartFrame(job.frameWindow);
|
|
14114
|
+
const transitionFramesSet = partitionTransitionFrames(transitionRanges, totalFrames, firstFrame);
|
|
14003
14115
|
const hasTransitions = transitionRanges.length > 0;
|
|
14004
14116
|
const bufSize = width * height * 6;
|
|
14005
14117
|
const workerSessions = [];
|
|
@@ -14090,8 +14202,9 @@ async function runHybridLayeredFrameLoop(input) {
|
|
|
14090
14202
|
for (let i = range.start; i < range.end; i++) {
|
|
14091
14203
|
throwIfFailed();
|
|
14092
14204
|
assertNotAborted();
|
|
14093
|
-
const
|
|
14094
|
-
const
|
|
14205
|
+
const frame = firstFrame + i;
|
|
14206
|
+
const time = frame * job.config.fps.den / job.config.fps.num;
|
|
14207
|
+
const activeTransition = transitionFramesSet.has(frame) ? transitionAtFrame(transitionRanges, frame) : void 0;
|
|
14095
14208
|
if (activeTransition && ring) {
|
|
14096
14209
|
const slot = nextRingIdx;
|
|
14097
14210
|
nextRingIdx = (nextRingIdx + 1) % TRANSITION_RING_DEPTH;
|
|
@@ -14102,7 +14215,7 @@ async function runHybridLayeredFrameLoop(input) {
|
|
|
14102
14215
|
if (!buffers) continue;
|
|
14103
14216
|
await captureTransitionFrameOnWorker({
|
|
14104
14217
|
session,
|
|
14105
|
-
frameIdx:
|
|
14218
|
+
frameIdx: frame,
|
|
14106
14219
|
time,
|
|
14107
14220
|
transition: activeTransition,
|
|
14108
14221
|
buffers,
|
|
@@ -14117,7 +14230,7 @@ async function runHybridLayeredFrameLoop(input) {
|
|
|
14117
14230
|
hdrPerf,
|
|
14118
14231
|
log
|
|
14119
14232
|
});
|
|
14120
|
-
const progress = activeTransition.endFrame === activeTransition.startFrame ? 1 : (
|
|
14233
|
+
const progress = activeTransition.endFrame === activeTransition.startFrame ? 1 : (frame - activeTransition.startFrame) / (activeTransition.endFrame - activeTransition.startFrame);
|
|
14121
14234
|
const frameIdx = i;
|
|
14122
14235
|
const shaderName = activeTransition.shader;
|
|
14123
14236
|
const dispatch = (async () => {
|
|
@@ -14168,7 +14281,7 @@ async function runHybridLayeredFrameLoop(input) {
|
|
|
14168
14281
|
await timeHdrPhaseAsync(
|
|
14169
14282
|
hdrPerf,
|
|
14170
14283
|
"normalCompositeMs",
|
|
14171
|
-
() => compositeHdrFrame(wctx, canvas, time, stackingInfo, void 0,
|
|
14284
|
+
() => compositeHdrFrame(wctx, canvas, time, stackingInfo, void 0, frame)
|
|
14172
14285
|
);
|
|
14173
14286
|
if (debugDumpEnabled && debugDumpDir && i % 30 === 0) {
|
|
14174
14287
|
writeFileExclusiveSync(
|
|
@@ -14378,7 +14491,7 @@ async function runCaptureHdrStage(input) {
|
|
|
14378
14491
|
const debugDumpEnabled = process.env.KEEP_TEMP === "1";
|
|
14379
14492
|
const debugDumpDir = debugDumpEnabled ? join33(framesDir, "debug-composite") : null;
|
|
14380
14493
|
if (debugDumpDir && !existsSync20(debugDumpDir)) {
|
|
14381
|
-
|
|
14494
|
+
mkdirSync11(debugDumpDir, { recursive: true });
|
|
14382
14495
|
}
|
|
14383
14496
|
const compositeTransfer = resolveCompositeTransfer(hasHdrContent, effectiveHdr);
|
|
14384
14497
|
const hdrTargetTransfer = compositeTransfer === "srgb" ? void 0 : compositeTransfer;
|
|
@@ -14406,7 +14519,11 @@ async function runCaptureHdrStage(input) {
|
|
|
14406
14519
|
hdrPerf
|
|
14407
14520
|
};
|
|
14408
14521
|
const effectiveWorkerCount = Math.max(1, workerCount);
|
|
14409
|
-
const transitionFrameCount = partitionTransitionFrames(
|
|
14522
|
+
const transitionFrameCount = partitionTransitionFrames(
|
|
14523
|
+
transitionRanges,
|
|
14524
|
+
totalFrames,
|
|
14525
|
+
windowStartFrame(job.frameWindow)
|
|
14526
|
+
).size;
|
|
14410
14527
|
const useHybrid = shouldUseHybridLayeredPath({
|
|
14411
14528
|
hasHdrContent,
|
|
14412
14529
|
transitionFramesCount: transitionFrameCount,
|
|
@@ -14537,15 +14654,15 @@ async function runCaptureHdrStage(input) {
|
|
|
14537
14654
|
import {
|
|
14538
14655
|
copyFileSync as copyFileSync4,
|
|
14539
14656
|
existsSync as existsSync21,
|
|
14540
|
-
mkdirSync as
|
|
14657
|
+
mkdirSync as mkdirSync12,
|
|
14541
14658
|
readdirSync as readdirSync5,
|
|
14542
|
-
readFileSync as
|
|
14659
|
+
readFileSync as readFileSync10,
|
|
14543
14660
|
rmSync as rmSync12,
|
|
14544
14661
|
statSync as statSync9,
|
|
14545
|
-
writeFileSync as
|
|
14662
|
+
writeFileSync as writeFileSync6
|
|
14546
14663
|
} from "node:fs";
|
|
14547
14664
|
import { readFile as readFile2 } from "node:fs/promises";
|
|
14548
|
-
import { dirname as
|
|
14665
|
+
import { dirname as dirname15, join as join34 } from "node:path";
|
|
14549
14666
|
import {
|
|
14550
14667
|
encodeFramesChunkedConcat,
|
|
14551
14668
|
encodeFramesFromDir,
|
|
@@ -14633,12 +14750,12 @@ async function reencodeWithClearedWholeFrames(argsInput, run, startTime) {
|
|
|
14633
14750
|
const error = formatFfmpegError(result.exitCode, result.stderr);
|
|
14634
14751
|
return gifEncodeFailure(startTime, outputPath, error, result.failureReason);
|
|
14635
14752
|
}
|
|
14636
|
-
const gif =
|
|
14753
|
+
const gif = readFileSync10(outputPath);
|
|
14637
14754
|
if (!clearGifFramesBeforeNext(gif)) {
|
|
14638
14755
|
const error = "[FFmpeg] GIF output could not be parsed to clear its frames";
|
|
14639
14756
|
return gifEncodeFailure(startTime, outputPath, error);
|
|
14640
14757
|
}
|
|
14641
|
-
|
|
14758
|
+
writeFileSync6(outputPath, gif);
|
|
14642
14759
|
return null;
|
|
14643
14760
|
}
|
|
14644
14761
|
async function encodeGifFromDir(framesDir, framePattern, outputPath, input) {
|
|
@@ -14666,7 +14783,7 @@ async function encodeGifFromDir(framesDir, framePattern, outputPath, input) {
|
|
|
14666
14783
|
return gifEncodeFailure(startTime, outputPath, error, result.failureReason);
|
|
14667
14784
|
}
|
|
14668
14785
|
}
|
|
14669
|
-
if (input.preserveAlpha && gifClearsAfterLeavingFrameInPlace(
|
|
14786
|
+
if (input.preserveAlpha && gifClearsAfterLeavingFrameInPlace(readFileSync10(outputPath)) !== false) {
|
|
14670
14787
|
const failure = await reencodeWithClearedWholeFrames(argsInput, run, startTime);
|
|
14671
14788
|
if (failure) return failure;
|
|
14672
14789
|
}
|
|
@@ -14761,7 +14878,7 @@ function encodeWhileCapturing(input, totalFrames, captureBudget) {
|
|
|
14761
14878
|
const stream = await encoder;
|
|
14762
14879
|
for (let next = 0; next < totalFrames; next++) {
|
|
14763
14880
|
while (!landed.has(next) && !captureDone && !signal.aborted) {
|
|
14764
|
-
await new Promise((
|
|
14881
|
+
await new Promise((resolve13) => wake = resolve13);
|
|
14765
14882
|
}
|
|
14766
14883
|
if (signal.aborted) return;
|
|
14767
14884
|
const mergedPath = join34(input.framesDir, formatCaptureFrameName(next, "jpg"));
|
|
@@ -14839,7 +14956,7 @@ async function runEncodeStage(input) {
|
|
|
14839
14956
|
const stage5Start = Date.now();
|
|
14840
14957
|
if (isPngSequence) {
|
|
14841
14958
|
const encoded = startEncodeProgress(job, "Writing PNG sequence", onProgress);
|
|
14842
|
-
if (!existsSync21(outputPath))
|
|
14959
|
+
if (!existsSync21(outputPath)) mkdirSync12(outputPath, { recursive: true });
|
|
14843
14960
|
const captured = readdirSync5(framesDir).filter((name) => name.endsWith(".png")).sort();
|
|
14844
14961
|
if (captured.length === 0) {
|
|
14845
14962
|
throw new Error(
|
|
@@ -14871,7 +14988,7 @@ async function runEncodeStage(input) {
|
|
|
14871
14988
|
const encodeResult2 = await encodeGifFromDir(framesDir, framePattern2, outputPath, {
|
|
14872
14989
|
fps: job.config.fps,
|
|
14873
14990
|
loop,
|
|
14874
|
-
palettePath: join34(
|
|
14991
|
+
palettePath: join34(dirname15(videoOnlyPath), "gif-palette.png"),
|
|
14875
14992
|
preserveAlpha: needsAlpha,
|
|
14876
14993
|
signal: abortSignal,
|
|
14877
14994
|
timeout: engineCfg.ffmpegEncodeTimeout
|
|
@@ -15325,7 +15442,7 @@ function getNextRetryWorkerCount(currentWorkers) {
|
|
|
15325
15442
|
}
|
|
15326
15443
|
function resolveRenderWorkDirPrefix(outputPath, jobId, platform2 = process.platform, systemTempDir = tmpdir3()) {
|
|
15327
15444
|
if (platform2 === "win32" || platform2 === "darwin") return join35(systemTempDir, "hf-render-");
|
|
15328
|
-
return join35(
|
|
15445
|
+
return join35(dirname16(outputPath), `work-${jobId}-`);
|
|
15329
15446
|
}
|
|
15330
15447
|
var MAX_TRANSIENT_CAPTURE_RETRIES = 1;
|
|
15331
15448
|
function isTransientCaptureRetryEligible(failureKind, missing, retriesUsed) {
|
|
@@ -16053,16 +16170,28 @@ function deVerifyFallbackTelemetry(err) {
|
|
|
16053
16170
|
};
|
|
16054
16171
|
}
|
|
16055
16172
|
function resolveRenderDebugDir() {
|
|
16056
|
-
const producerRoot = process.env.PRODUCER_RENDERS_DIR ?
|
|
16173
|
+
const producerRoot = process.env.PRODUCER_RENDERS_DIR ? resolve10(process.env.PRODUCER_RENDERS_DIR, "..") : resolve10(dirname16(fileURLToPath5(import.meta.url)), "../..");
|
|
16057
16174
|
return join35(producerRoot, ".debug");
|
|
16058
16175
|
}
|
|
16059
|
-
|
|
16176
|
+
function executeRenderJob(job, projectDir, outputPath, progressSink, abortSignal, assertRenderActive) {
|
|
16177
|
+
return fromEmptyFolder(
|
|
16178
|
+
() => renderJob(
|
|
16179
|
+
job,
|
|
16180
|
+
resolve10(projectDir),
|
|
16181
|
+
resolve10(outputPath),
|
|
16182
|
+
progressSink,
|
|
16183
|
+
abortSignal,
|
|
16184
|
+
assertRenderActive
|
|
16185
|
+
)
|
|
16186
|
+
);
|
|
16187
|
+
}
|
|
16188
|
+
async function renderJob(job, projectDir, outputPath, progressSink, abortSignal, assertRenderActive) {
|
|
16060
16189
|
validateHlsRenderConfig(job.config);
|
|
16061
16190
|
validateDeliveryEncoderConfig(job.config);
|
|
16062
16191
|
validateChromaSubsamplingConfig(job.config);
|
|
16063
16192
|
const debugDir = resolveRenderDebugDir();
|
|
16064
|
-
const outputDir =
|
|
16065
|
-
if (!existsSync22(outputDir))
|
|
16193
|
+
const outputDir = dirname16(outputPath);
|
|
16194
|
+
if (!existsSync22(outputDir)) mkdirSync13(outputDir, { recursive: true });
|
|
16066
16195
|
const workDir = job.config.debug ? join35(debugDir, job.id) : createRenderWorkDir(resolveRenderWorkDirPrefix(outputPath, job.id), outputDir);
|
|
16067
16196
|
const pipelineStart = Date.now();
|
|
16068
16197
|
const baseLog = job.config.logger ?? defaultLogger;
|
|
@@ -16219,7 +16348,7 @@ async function executeRenderPipeline(input) {
|
|
|
16219
16348
|
job.startedAt = /* @__PURE__ */ new Date();
|
|
16220
16349
|
assertNotAborted();
|
|
16221
16350
|
assertConfiguredFfmpegBinariesExist();
|
|
16222
|
-
if (!existsSync22(workDir))
|
|
16351
|
+
if (!existsSync22(workDir)) mkdirSync13(workDir, { recursive: true });
|
|
16223
16352
|
if (job.config.debug) {
|
|
16224
16353
|
log.info("[Render] Debug artifacts enabled", { workDir, logPath });
|
|
16225
16354
|
}
|
|
@@ -16388,15 +16517,18 @@ async function executeRenderPipeline(input) {
|
|
|
16388
16517
|
if (resolvedCaptureBeyondViewport !== void 0) {
|
|
16389
16518
|
updateCaptureObservability({ captureBeyondViewport: resolvedCaptureBeyondViewport });
|
|
16390
16519
|
}
|
|
16391
|
-
job.duration = probeResult.duration;
|
|
16392
|
-
job.totalFrames = probeResult.totalFrames;
|
|
16393
|
-
const totalFrames = probeResult.totalFrames;
|
|
16394
|
-
captureTotalFrames = totalFrames;
|
|
16395
16520
|
validateRenderDuration({
|
|
16396
16521
|
duration: probeResult.duration,
|
|
16397
|
-
totalFrames,
|
|
16522
|
+
totalFrames: probeResult.totalFrames,
|
|
16398
16523
|
fps: fpsToNumber8(job.config.fps)
|
|
16399
16524
|
});
|
|
16525
|
+
const frameWindow = job.config.range ? resolveFrameWindow(job.config.range, job.config.fps, probeResult.totalFrames) : void 0;
|
|
16526
|
+
job.frameWindow = frameWindow;
|
|
16527
|
+
if (frameWindow) cfg.enableStreamingEncode = false;
|
|
16528
|
+
const totalFrames = frameWindow ? frameWindow.endFrame - frameWindow.startFrame : probeResult.totalFrames;
|
|
16529
|
+
job.totalFrames = totalFrames;
|
|
16530
|
+
job.duration = frameWindow ? totalFrames * job.config.fps.den / job.config.fps.num : probeResult.duration;
|
|
16531
|
+
captureTotalFrames = totalFrames;
|
|
16400
16532
|
const shownBoxes = largerThanCanvas.length > 0 && probeSession?.isInitialized ? await measureLocalShownBoxes(
|
|
16401
16533
|
probeSession.page,
|
|
16402
16534
|
largerThanCanvas,
|
|
@@ -16577,6 +16709,7 @@ async function executeRenderPipeline(input) {
|
|
|
16577
16709
|
workDir,
|
|
16578
16710
|
compiledDir,
|
|
16579
16711
|
totalFrames: probeResult.totalFrames,
|
|
16712
|
+
...frameWindow && { frameWindow },
|
|
16580
16713
|
fps: job.config.fps,
|
|
16581
16714
|
ffmpegProcessTimeout: cfg.ffmpegProcessTimeout,
|
|
16582
16715
|
audioGain: cfg.audioGain,
|
|
@@ -16623,7 +16756,7 @@ async function executeRenderPipeline(input) {
|
|
|
16623
16756
|
throw new Error("File server failed to initialize before frame capture");
|
|
16624
16757
|
}
|
|
16625
16758
|
const framesDir = join35(workDir, "captured-frames");
|
|
16626
|
-
if (!existsSync22(framesDir))
|
|
16759
|
+
if (!existsSync22(framesDir)) mkdirSync13(framesDir, { recursive: true });
|
|
16627
16760
|
updateJobStatus(job, "rendering", "Checking browser GPU", 25, onProgress, {
|
|
16628
16761
|
code: "start_browsers"
|
|
16629
16762
|
});
|
|
@@ -16631,6 +16764,23 @@ async function executeRenderPipeline(input) {
|
|
|
16631
16764
|
chromePath: resolveHeadlessShellPath(cfg),
|
|
16632
16765
|
browserTimeout: cfg.browserTimeout
|
|
16633
16766
|
});
|
|
16767
|
+
const closeProbeSession = async () => {
|
|
16768
|
+
if (!probeSession) return;
|
|
16769
|
+
lastBrowserConsole = probeSession.browserConsoleBuffer;
|
|
16770
|
+
await closeCaptureSession8(probeSession).catch(() => {
|
|
16771
|
+
});
|
|
16772
|
+
probeSession = null;
|
|
16773
|
+
};
|
|
16774
|
+
const gpuStore = cfg.browserGpuMode === "auto" && resolvedBrowserGpuMode === "hardware" ? gpuChoiceStore(cfg, await probedHardwareGpu()) : void 0;
|
|
16775
|
+
const storedGpuChoice = gpuStore && readGpuChoice(gpuStore);
|
|
16776
|
+
if (gpuStore && storedGpuChoice === "software") {
|
|
16777
|
+
log.info("[Render] Auto GPU mode: rendering in software, as measured on this machine.", {
|
|
16778
|
+
file: gpuStore.file
|
|
16779
|
+
});
|
|
16780
|
+
cfg.browserGpuMode = "software";
|
|
16781
|
+
resolvedBrowserGpuMode = "software";
|
|
16782
|
+
await closeProbeSession();
|
|
16783
|
+
}
|
|
16634
16784
|
startingFrameCapture();
|
|
16635
16785
|
captureForceScreenshot = applyConcreteGpuScreenshotClamp(
|
|
16636
16786
|
captureForceScreenshot,
|
|
@@ -16867,6 +17017,10 @@ async function executeRenderPipeline(input) {
|
|
|
16867
17017
|
totalMemoryMb: Math.round(totalmem2() / (1024 * 1024)),
|
|
16868
17018
|
minMemoryMb: deParallelMinMemoryMb
|
|
16869
17019
|
});
|
|
17020
|
+
if (frameWindow) {
|
|
17021
|
+
deInversionEligible = false;
|
|
17022
|
+
deParallelRouterEligible = false;
|
|
17023
|
+
}
|
|
16870
17024
|
if (probeSession === null && (deInversionEligible || deParallelRouterEligible)) {
|
|
16871
17025
|
try {
|
|
16872
17026
|
probeSession = await createCaptureSession8(
|
|
@@ -16931,7 +17085,9 @@ async function executeRenderPipeline(input) {
|
|
|
16931
17085
|
return "beginFrame";
|
|
16932
17086
|
}
|
|
16933
17087
|
});
|
|
16934
|
-
|
|
17088
|
+
const sizeByCalibration = job.config.workers === void 0 && totalFrames >= 60 && !htmlInCanvasDetected && !cfg.lowMemoryMode && !deInversionEligible && !deParallelRouterEligible;
|
|
17089
|
+
const measureGpuChoice = gpuStore !== void 0 && storedGpuChoice === void 0;
|
|
17090
|
+
if (sizeByCalibration || measureGpuChoice) {
|
|
16935
17091
|
updateJobStatus(job, "rendering", "Measuring capture speed", 25, onProgress, {
|
|
16936
17092
|
code: "start_browsers"
|
|
16937
17093
|
});
|
|
@@ -16971,7 +17127,7 @@ async function executeRenderPipeline(input) {
|
|
|
16971
17127
|
probeSession
|
|
16972
17128
|
});
|
|
16973
17129
|
probeSession = result.probeSession;
|
|
16974
|
-
if (shouldCalibrateSoftwareGpu(
|
|
17130
|
+
if (storedGpuChoice === void 0 && shouldCalibrateSoftwareGpu(
|
|
16975
17131
|
cfg.browserGpuMode,
|
|
16976
17132
|
resolvedBrowserGpuMode,
|
|
16977
17133
|
result.calibration?.estimate
|
|
@@ -16996,7 +17152,7 @@ async function executeRenderPipeline(input) {
|
|
|
16996
17152
|
calibrationFrames?.release();
|
|
16997
17153
|
}
|
|
16998
17154
|
startingFrameCapture();
|
|
16999
|
-
captureCalibration = outcome.calibration;
|
|
17155
|
+
if (sizeByCalibration) captureCalibration = outcome.calibration;
|
|
17000
17156
|
calibrationEvaluateTimedOut = outcome.calibrationEvaluateTimedOut;
|
|
17001
17157
|
captureForceScreenshot = outcome.forceScreenshot;
|
|
17002
17158
|
updateCaptureObservability({ forceScreenshot: captureForceScreenshot });
|
|
@@ -17016,19 +17172,31 @@ async function executeRenderPipeline(input) {
|
|
|
17016
17172
|
);
|
|
17017
17173
|
cfg.browserGpuMode = "software";
|
|
17018
17174
|
resolvedBrowserGpuMode = "software";
|
|
17019
|
-
captureCalibration = softwareOutcome.calibration;
|
|
17175
|
+
if (sizeByCalibration) captureCalibration = softwareOutcome.calibration;
|
|
17020
17176
|
captureForceScreenshot = softwareOutcome.forceScreenshot;
|
|
17021
|
-
|
|
17022
|
-
lastBrowserConsole = probeSession.browserConsoleBuffer;
|
|
17023
|
-
await closeCaptureSession8(probeSession).catch(() => {
|
|
17024
|
-
});
|
|
17025
|
-
probeSession = null;
|
|
17026
|
-
}
|
|
17177
|
+
await closeProbeSession();
|
|
17027
17178
|
updateCaptureObservability({
|
|
17028
17179
|
browserGpuMode: resolvedBrowserGpuMode,
|
|
17029
17180
|
forceScreenshot: captureForceScreenshot
|
|
17030
17181
|
});
|
|
17031
17182
|
}
|
|
17183
|
+
const settledGpuChoice = measureGpuChoice ? settleAutoGpuChoice(outcome.calibration?.estimate, softwareOutcome?.calibration?.estimate) : void 0;
|
|
17184
|
+
if (gpuStore && settledGpuChoice) {
|
|
17185
|
+
try {
|
|
17186
|
+
writeGpuChoice(gpuStore, settledGpuChoice, {
|
|
17187
|
+
hardwareP95Ms: outcome.calibration?.estimate.p95Ms,
|
|
17188
|
+
softwareP95Ms: softwareOutcome?.calibration?.estimate.p95Ms
|
|
17189
|
+
});
|
|
17190
|
+
} catch (error) {
|
|
17191
|
+
log.warn(
|
|
17192
|
+
"[Render] Could not save the measured GPU choice; the next render measures again.",
|
|
17193
|
+
{
|
|
17194
|
+
file: gpuStore.file,
|
|
17195
|
+
error: error instanceof Error ? error.message : String(error)
|
|
17196
|
+
}
|
|
17197
|
+
);
|
|
17198
|
+
}
|
|
17199
|
+
}
|
|
17032
17200
|
observability.checkpoint("capture_calibration", "resolved", {
|
|
17033
17201
|
forceScreenshot: captureForceScreenshot,
|
|
17034
17202
|
browserGpuMode: resolvedBrowserGpuMode,
|
|
@@ -17384,6 +17552,7 @@ async function executeRenderPipeline(input) {
|
|
|
17384
17552
|
});
|
|
17385
17553
|
const syncCapturePlan = () => {
|
|
17386
17554
|
assertMotionBlurSupported(job.config.motionBlur, capturePlan.kind);
|
|
17555
|
+
assertRangeSupported(job.frameWindow, capturePlan.kind);
|
|
17387
17556
|
assertOutputScaleSupported(deviceScaleFactor, capturePlan.kind);
|
|
17388
17557
|
workerCount = capturePlan.workerCount;
|
|
17389
17558
|
captureForceScreenshot = capturePlan.forceScreenshot;
|
|
@@ -17969,6 +18138,7 @@ async function executeRenderPipeline(input) {
|
|
|
17969
18138
|
framesDir,
|
|
17970
18139
|
job,
|
|
17971
18140
|
totalFrames,
|
|
18141
|
+
...job.frameWindow && { frameRange: job.frameWindow },
|
|
17972
18142
|
cfg,
|
|
17973
18143
|
plan: diskPlan,
|
|
17974
18144
|
log,
|
|
@@ -18009,7 +18179,7 @@ async function executeRenderPipeline(input) {
|
|
|
18009
18179
|
"drawElement capture failed; retrying with a fresh screenshot session"
|
|
18010
18180
|
);
|
|
18011
18181
|
rmSync13(framesDir, { recursive: true, force: true });
|
|
18012
|
-
|
|
18182
|
+
mkdirSync13(framesDir, { recursive: true });
|
|
18013
18183
|
resetCaptureAttemptProgress(job);
|
|
18014
18184
|
dedupPerfs.length = 0;
|
|
18015
18185
|
cfg.useDrawElement = false;
|
|
@@ -18188,7 +18358,7 @@ async function executeRenderPipeline(input) {
|
|
|
18188
18358
|
job.perfSummary = perfSummary;
|
|
18189
18359
|
if (job.config.debug) {
|
|
18190
18360
|
try {
|
|
18191
|
-
|
|
18361
|
+
writeFileSync7(perfOutputPath, JSON.stringify(perfSummary, null, 2), "utf-8");
|
|
18192
18362
|
} catch (err) {
|
|
18193
18363
|
log.debug("Failed to write perf summary", {
|
|
18194
18364
|
perfOutputPath,
|
|
@@ -18315,14 +18485,14 @@ async function executeRenderPipeline(input) {
|
|
|
18315
18485
|
// src/services/hyperframeLint.ts
|
|
18316
18486
|
import {
|
|
18317
18487
|
existsSync as existsSync23,
|
|
18318
|
-
readFileSync as
|
|
18488
|
+
readFileSync as readFileSync11,
|
|
18319
18489
|
statSync as statSync11,
|
|
18320
18490
|
openSync as openSync6,
|
|
18321
18491
|
fstatSync as fstatSync4,
|
|
18322
18492
|
closeSync as closeSync6,
|
|
18323
18493
|
constants as constants4
|
|
18324
18494
|
} from "node:fs";
|
|
18325
|
-
import { resolve as
|
|
18495
|
+
import { resolve as resolve11, join as join36, relative as relative6, isAbsolute as isAbsolute5, sep as sep5, dirname as dirname17 } from "node:path";
|
|
18326
18496
|
import { fileURLToPath as fileURLToPath6 } from "node:url";
|
|
18327
18497
|
import { Worker as Worker3 } from "node:worker_threads";
|
|
18328
18498
|
function isStringRecord(value) {
|
|
@@ -18362,7 +18532,7 @@ function readEntryHtml(filePath) {
|
|
|
18362
18532
|
}
|
|
18363
18533
|
try {
|
|
18364
18534
|
if (!fstatSync4(fd).isFile()) return null;
|
|
18365
|
-
return
|
|
18535
|
+
return readFileSync11(fd, "utf-8");
|
|
18366
18536
|
} finally {
|
|
18367
18537
|
closeSync6(fd);
|
|
18368
18538
|
}
|
|
@@ -18372,7 +18542,7 @@ function leavesProject(absProjectDir, absoluteEntryPath, isAllowedEntry) {
|
|
|
18372
18542
|
return entryRelativePath === ".." || entryRelativePath.startsWith(`..${sep5}`) || isAbsolute5(entryRelativePath) || isAllowedEntry !== void 0 && !isAllowedEntry(absoluteEntryPath);
|
|
18373
18543
|
}
|
|
18374
18544
|
function readProjectEntryFile(projectDir, preferredEntryFile, isAllowedEntry) {
|
|
18375
|
-
const absProjectDir =
|
|
18545
|
+
const absProjectDir = resolve11(projectDir);
|
|
18376
18546
|
if (!existsSync23(absProjectDir) || !statSync11(absProjectDir).isDirectory()) {
|
|
18377
18547
|
return { error: `Project directory not found: ${absProjectDir}` };
|
|
18378
18548
|
}
|
|
@@ -18380,7 +18550,7 @@ function readProjectEntryFile(projectDir, preferredEntryFile, isAllowedEntry) {
|
|
|
18380
18550
|
(value) => typeof value === "string" && value.trim().length > 0
|
|
18381
18551
|
);
|
|
18382
18552
|
for (const entryFile of entryCandidates) {
|
|
18383
|
-
const absoluteEntryPath =
|
|
18553
|
+
const absoluteEntryPath = resolve11(absProjectDir, entryFile);
|
|
18384
18554
|
if (leavesProject(absProjectDir, absoluteEntryPath, isAllowedEntry)) {
|
|
18385
18555
|
return { error: `Entry file must stay inside project directory: ${entryFile}` };
|
|
18386
18556
|
}
|
|
@@ -18440,16 +18610,16 @@ function takeLintSlot(limit, waitMs) {
|
|
|
18440
18610
|
running++;
|
|
18441
18611
|
return Promise.resolve(true);
|
|
18442
18612
|
}
|
|
18443
|
-
return new Promise((
|
|
18613
|
+
return new Promise((resolve13) => {
|
|
18444
18614
|
const entry = () => {
|
|
18445
18615
|
clearTimeout(timer);
|
|
18446
18616
|
running++;
|
|
18447
|
-
|
|
18617
|
+
resolve13(true);
|
|
18448
18618
|
};
|
|
18449
18619
|
const timer = setTimeout(
|
|
18450
18620
|
() => {
|
|
18451
18621
|
waiting.splice(waiting.indexOf(entry), 1);
|
|
18452
|
-
|
|
18622
|
+
resolve13(false);
|
|
18453
18623
|
},
|
|
18454
18624
|
Math.max(0, waitMs)
|
|
18455
18625
|
);
|
|
@@ -18461,7 +18631,7 @@ function freeLintSlot() {
|
|
|
18461
18631
|
waiting.shift()?.();
|
|
18462
18632
|
}
|
|
18463
18633
|
function resolveLintWorkerEntry() {
|
|
18464
|
-
const here =
|
|
18634
|
+
const here = dirname17(fileURLToPath6(import.meta.url));
|
|
18465
18635
|
for (const name of ["hyperframeLintWorker.js", "hyperframeLintWorker.ts"]) {
|
|
18466
18636
|
const candidate = join36(here, name);
|
|
18467
18637
|
if (existsSync23(candidate)) return candidate;
|
|
@@ -18534,7 +18704,7 @@ async function runHyperframeLint(prepared, options = {}) {
|
|
|
18534
18704
|
// src/services/healthWorker.ts
|
|
18535
18705
|
import { Worker as Worker4 } from "node:worker_threads";
|
|
18536
18706
|
import { fileURLToPath as fileURLToPath7 } from "node:url";
|
|
18537
|
-
import { dirname as
|
|
18707
|
+
import { dirname as dirname18, join as join37 } from "node:path";
|
|
18538
18708
|
import { existsSync as existsSync24 } from "node:fs";
|
|
18539
18709
|
var DEFAULT_HEALTH_PORT = 9848;
|
|
18540
18710
|
async function startHealthWorker(options = {}) {
|
|
@@ -18553,12 +18723,12 @@ async function startHealthWorker(options = {}) {
|
|
|
18553
18723
|
stdout: false,
|
|
18554
18724
|
stderr: false
|
|
18555
18725
|
});
|
|
18556
|
-
await new Promise((
|
|
18726
|
+
await new Promise((resolve13, reject) => {
|
|
18557
18727
|
const onMessage = (msg) => {
|
|
18558
18728
|
if (msg?.type === "listening") {
|
|
18559
18729
|
worker.off("error", onError);
|
|
18560
18730
|
worker.off("message", onMessage);
|
|
18561
|
-
|
|
18731
|
+
resolve13();
|
|
18562
18732
|
} else if (msg?.type === "listen-error") {
|
|
18563
18733
|
worker.off("error", onError);
|
|
18564
18734
|
worker.off("message", onMessage);
|
|
@@ -18609,7 +18779,7 @@ function defaultLogger2() {
|
|
|
18609
18779
|
};
|
|
18610
18780
|
}
|
|
18611
18781
|
function resolveWorkerEntry2() {
|
|
18612
|
-
const here =
|
|
18782
|
+
const here = dirname18(fileURLToPath7(import.meta.url));
|
|
18613
18783
|
const candidates = [join37(here, "healthWorkerThread.js"), join37(here, "healthWorkerThread.ts")];
|
|
18614
18784
|
for (const candidate of candidates) {
|
|
18615
18785
|
if (existsSync24(candidate)) return candidate;
|
|
@@ -18685,8 +18855,8 @@ import {
|
|
|
18685
18855
|
|
|
18686
18856
|
// src/services/distributed/shared.ts
|
|
18687
18857
|
import { execFile as execFileCallback } from "node:child_process";
|
|
18688
|
-
import { dirname as
|
|
18689
|
-
import { existsSync as existsSync25, readFileSync as
|
|
18858
|
+
import { dirname as dirname19, join as join38 } from "node:path";
|
|
18859
|
+
import { existsSync as existsSync25, readFileSync as readFileSync12 } from "node:fs";
|
|
18690
18860
|
import { fileURLToPath as fileURLToPath8 } from "node:url";
|
|
18691
18861
|
import { promisify as promisify2 } from "node:util";
|
|
18692
18862
|
import {
|
|
@@ -18698,13 +18868,13 @@ var execFile = promisify2(execFileCallback);
|
|
|
18698
18868
|
var cachedProducerVersion = null;
|
|
18699
18869
|
function readProducerVersion() {
|
|
18700
18870
|
if (cachedProducerVersion !== null) return cachedProducerVersion;
|
|
18701
|
-
const startDir =
|
|
18871
|
+
const startDir = dirname19(fileURLToPath8(import.meta.url));
|
|
18702
18872
|
let current = startDir;
|
|
18703
18873
|
for (let i = 0; i < 10; i++) {
|
|
18704
18874
|
const candidate = join38(current, "package.json");
|
|
18705
18875
|
if (existsSync25(candidate)) {
|
|
18706
18876
|
try {
|
|
18707
|
-
const pkg = JSON.parse(
|
|
18877
|
+
const pkg = JSON.parse(readFileSync12(candidate, "utf-8"));
|
|
18708
18878
|
if (pkg.name === "@hyperframes/producer" && typeof pkg.version === "string") {
|
|
18709
18879
|
cachedProducerVersion = pkg.version;
|
|
18710
18880
|
return pkg.version;
|
|
@@ -18712,7 +18882,7 @@ function readProducerVersion() {
|
|
|
18712
18882
|
} catch {
|
|
18713
18883
|
}
|
|
18714
18884
|
}
|
|
18715
|
-
const parent =
|
|
18885
|
+
const parent = dirname19(current);
|
|
18716
18886
|
if (parent === current) break;
|
|
18717
18887
|
current = parent;
|
|
18718
18888
|
}
|
|
@@ -19223,11 +19393,11 @@ function buildRenderJobConfig(input, outputPath, log) {
|
|
|
19223
19393
|
function resolvePreparedRenderOutput(prepared, rendersDir, log, confineOutput) {
|
|
19224
19394
|
const { input, cleanupProjectDir } = prepared;
|
|
19225
19395
|
const serverNamed = input.outputPath == null;
|
|
19226
|
-
const outputCandidate = input.outputPath ?? join40(rendersDir, `${basename8(
|
|
19396
|
+
const outputCandidate = input.outputPath ?? join40(rendersDir, `${basename8(resolve12(input.projectDir))}-${crypto.randomUUID()}.mp4`);
|
|
19227
19397
|
const absoluteOutputPath = resolveOutputPath(input.projectDir, outputCandidate, rendersDir, log);
|
|
19228
|
-
const outputDir =
|
|
19398
|
+
const outputDir = dirname20(absoluteOutputPath);
|
|
19229
19399
|
if (confineOutput) {
|
|
19230
|
-
|
|
19400
|
+
mkdirSync14(rendersDir, { recursive: true, mode: SERVER_FOLDER_MODE });
|
|
19231
19401
|
if (!isSafePath4(rendersDir, absoluteOutputPath)) {
|
|
19232
19402
|
throw new Error("outputPath must be inside the renders directory");
|
|
19233
19403
|
}
|
|
@@ -19238,14 +19408,14 @@ function resolvePreparedRenderOutput(prepared, rendersDir, log, confineOutput) {
|
|
|
19238
19408
|
);
|
|
19239
19409
|
}
|
|
19240
19410
|
}
|
|
19241
|
-
if (!existsSync26(outputDir))
|
|
19411
|
+
if (!existsSync26(outputDir)) mkdirSync14(outputDir, { recursive: true, mode: SERVER_FOLDER_MODE });
|
|
19242
19412
|
return { input, cleanupProjectDir, absoluteOutputPath, serverNamed };
|
|
19243
19413
|
}
|
|
19244
19414
|
var STICKY_BIT = 512;
|
|
19245
19415
|
var SERVER_FOLDER_MODE = 493;
|
|
19246
19416
|
function folderAnotherAccountCanChange(dir, rendersDir) {
|
|
19247
19417
|
const foreign = foreignWritablePath(dir, rendersDir);
|
|
19248
|
-
const stickyRoot = foreign ===
|
|
19418
|
+
const stickyRoot = foreign === resolve12(rendersDir) && (lstatSync4(foreign).mode & STICKY_BIT) !== 0;
|
|
19249
19419
|
return stickyRoot ? void 0 : foreign;
|
|
19250
19420
|
}
|
|
19251
19421
|
function prepareRenderJob(prepared, rendersDir, log, confineOutput) {
|
|
@@ -19306,7 +19476,7 @@ function validateOutputResolutionOverride(body) {
|
|
|
19306
19476
|
var MAX_PREVIEW_HTML_BYTES = 20 * 1024 * 1024;
|
|
19307
19477
|
function resolveRenderRequestPolicy(options) {
|
|
19308
19478
|
return {
|
|
19309
|
-
projectsDir:
|
|
19479
|
+
projectsDir: resolve12(
|
|
19310
19480
|
options.projectsDir ?? (process.env.PRODUCER_PROJECTS_DIR || process.cwd())
|
|
19311
19481
|
),
|
|
19312
19482
|
allowDebug: options.allowDebug ?? process.env.PRODUCER_ALLOW_DEBUG === "1"
|
|
@@ -19321,13 +19491,13 @@ function isAllowedEntryPath(policy, projectDir, path) {
|
|
|
19321
19491
|
function prepareProjectDirectory(projectDir, options, policy) {
|
|
19322
19492
|
const candidate = nonEmptyString(projectDir);
|
|
19323
19493
|
if (!candidate) return null;
|
|
19324
|
-
const absProjectDir = policy ?
|
|
19494
|
+
const absProjectDir = policy ? resolve12(policy.projectsDir, candidate) : resolve12(candidate);
|
|
19325
19495
|
const shown = policy ? candidate : absProjectDir;
|
|
19326
19496
|
if (policy && !isAllowedProjectPath(policy.projectsDir, absProjectDir) || !existsSync26(absProjectDir) || !statSync12(absProjectDir).isDirectory()) {
|
|
19327
19497
|
return { error: `Project directory not found: ${shown}` };
|
|
19328
19498
|
}
|
|
19329
19499
|
const entry = options.entryFile || "index.html";
|
|
19330
|
-
const entryPath =
|
|
19500
|
+
const entryPath = resolve12(absProjectDir, entry);
|
|
19331
19501
|
if (policy && !isAllowedEntryPath(policy, absProjectDir, entryPath) || !existsSync26(entryPath)) {
|
|
19332
19502
|
return { error: `Entry file "${entry}" not found in project directory: ${shown}` };
|
|
19333
19503
|
}
|
|
@@ -19350,7 +19520,7 @@ async function resolveInlineRenderHtml(body) {
|
|
|
19350
19520
|
function materializeInlineProject(html, options) {
|
|
19351
19521
|
const tempRoot = process.env.PRODUCER_TMP_PROJECT_DIR || tmpdir4();
|
|
19352
19522
|
const tempProjectDir = mkdtempSync(join40(tempRoot, "producer-project-"));
|
|
19353
|
-
|
|
19523
|
+
writeFileSync8(join40(tempProjectDir, "index.html"), html, "utf-8");
|
|
19354
19524
|
return {
|
|
19355
19525
|
prepared: {
|
|
19356
19526
|
input: { projectDir: tempProjectDir, ...options },
|
|
@@ -19378,7 +19548,7 @@ function resolveOutputPath(projectDir, outputCandidate, rendersDir, log) {
|
|
|
19378
19548
|
try {
|
|
19379
19549
|
return resolveRenderPaths(projectDir, outputCandidate, rendersDir).absoluteOutputPath;
|
|
19380
19550
|
} catch (error) {
|
|
19381
|
-
const fallbackPath =
|
|
19551
|
+
const fallbackPath = resolve12(rendersDir, `producer-fallback-${Date.now()}.mp4`);
|
|
19382
19552
|
log.warn("Failed to resolve output path, using fallback", {
|
|
19383
19553
|
fallback: fallbackPath,
|
|
19384
19554
|
error: error instanceof Error ? error.message : String(error)
|
|
@@ -19585,7 +19755,7 @@ function createRenderHandlers(options = {}) {
|
|
|
19585
19755
|
const lintProjectDir = nonEmptyString(body.projectDir);
|
|
19586
19756
|
let isAllowedEntry;
|
|
19587
19757
|
if (policy && lintProjectDir) {
|
|
19588
|
-
const absProjectDir =
|
|
19758
|
+
const absProjectDir = resolve12(policy.projectsDir, lintProjectDir);
|
|
19589
19759
|
if (!isAllowedProjectPath(policy.projectsDir, absProjectDir)) {
|
|
19590
19760
|
const error = `Project directory not found: ${lintProjectDir}`;
|
|
19591
19761
|
return c.json({ success: false, requestId, error }, 400);
|
|
@@ -19939,13 +20109,13 @@ function serverAuth(options, hostname2, port) {
|
|
|
19939
20109
|
`Refusing to listen on ${hostname2} without an auth token. Set authToken or PRODUCER_AUTH_TOKEN, or listen on a loopback address.`
|
|
19940
20110
|
);
|
|
19941
20111
|
}
|
|
19942
|
-
const file =
|
|
20112
|
+
const file = resolve12(
|
|
19943
20113
|
options.authTokenFile?.trim() || process.env.PRODUCER_AUTH_TOKEN_FILE?.trim() || join40(homedir(), ".hyperframes", "producer", `${port}.token`)
|
|
19944
20114
|
);
|
|
19945
20115
|
const token = crypto.randomBytes(32).toString("base64url");
|
|
19946
|
-
|
|
20116
|
+
mkdirSync14(dirname20(file), { recursive: true, mode: 448 });
|
|
19947
20117
|
rmSync14(file, { force: true });
|
|
19948
|
-
|
|
20118
|
+
writeFileSync8(file, `${token}
|
|
19949
20119
|
`, { flag: "wx", mode: 384 });
|
|
19950
20120
|
return { token, generatedFile: file };
|
|
19951
20121
|
}
|
|
@@ -19999,7 +20169,7 @@ function startServer(options = {}) {
|
|
|
19999
20169
|
process.on("SIGINT", () => shutdown("SIGINT"));
|
|
20000
20170
|
return server;
|
|
20001
20171
|
}
|
|
20002
|
-
var entryScript = process.argv[1] ?
|
|
20172
|
+
var entryScript = process.argv[1] ? resolve12(process.argv[1]) : "";
|
|
20003
20173
|
var isPublicServerEntry = entryScript.endsWith("/public-server.js") || entryScript.endsWith("/src/server.ts");
|
|
20004
20174
|
if (isPublicServerEntry) {
|
|
20005
20175
|
const { values } = parseArgs({
|