@hyperframes/producer 0.9.107 → 0.10.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/README.md +1 -1
- package/dist/distributed.js +65 -19
- package/dist/index.js +65 -19
- package/dist/public-server.js +10 -8
- package/dist/services/distributed/renderChunk.d.ts +22 -1
- package/dist/services/render/stages/captureStage.d.ts +3 -1
- package/dist/services/renderOrchestrator.d.ts +3 -1
- package/package.json +9 -9
package/README.md
CHANGED
|
@@ -8,7 +8,7 @@ Full HTML-to-video rendering pipeline: capture frames with Chrome's BeginFrame A
|
|
|
8
8
|
npm install @hyperframes/producer
|
|
9
9
|
```
|
|
10
10
|
|
|
11
|
-
**Requirements:** Node.js >= 22, FFmpeg, and the pinned `chrome-headless-shell`: run `npx hyperframes browser ensure` once, or name a browser in `PRODUCER_HEADLESS_SHELL_PATH`. A cached browser is used only when its files match the pinned build. HDR capture needs a full Chrome named in `HYPERFRAMES_BROWSER_PATH`.
|
|
11
|
+
**Requirements:** Node.js >= 22.19, FFmpeg, and the pinned `chrome-headless-shell`: run `npx hyperframes browser ensure` once, or name a browser in `PRODUCER_HEADLESS_SHELL_PATH`. A cached browser is used only when its files match the pinned build. HDR capture needs a full Chrome named in `HYPERFRAMES_BROWSER_PATH`.
|
|
12
12
|
|
|
13
13
|
## Usage
|
|
14
14
|
|
package/dist/distributed.js
CHANGED
|
@@ -400,11 +400,8 @@ import { promisify } from "node:util";
|
|
|
400
400
|
import { Readable } from "node:stream";
|
|
401
401
|
import { join as join2, extname, resolve as resolve2, sep as sep2 } from "node:path";
|
|
402
402
|
import { injectScriptsAtHeadStart, injectScriptsIntoHtml } from "@hyperframes/core/compiler";
|
|
403
|
-
import {
|
|
404
|
-
import {
|
|
405
|
-
PREVIEW_FOR_ANOTHER_SITE_META,
|
|
406
|
-
serviceWorkerScriptFetch
|
|
407
|
-
} from "@hyperframes/core/studio-preview-mark";
|
|
403
|
+
import { markForAnotherSite } from "@hyperframes/core/compiler/html-document";
|
|
404
|
+
import { serviceWorkerScriptFetch } from "@hyperframes/core/studio-preview-mark";
|
|
408
405
|
import { fpsToNumber, terminalText as terminalText2 } from "@hyperframes/core";
|
|
409
406
|
import { isPrivateFileUnder as isPrivateFileUnder2, isStudioPrivatePath as isStudioPrivatePath2 } from "@hyperframes/core/safe-path";
|
|
410
407
|
import { stripSdrPngColourTags } from "@hyperframes/core/compiler/png-colour-tags";
|
|
@@ -1007,7 +1004,6 @@ var HF_BRIDGE_SCRIPT = `(function() {
|
|
|
1007
1004
|
if (bridge()) __realClearInterval(iv);
|
|
1008
1005
|
}, 50);
|
|
1009
1006
|
})();`;
|
|
1010
|
-
var OFFER_NO_FRAMING_SITE_AN_EDITING_PORT = `<meta name="${PREVIEW_FOR_ANOTHER_SITE_META}">`;
|
|
1011
1007
|
var RENDER_CAPTURE_MODE_SHIM = "globalThis.__HF_RENDER_CAPTURE_MODE = true;";
|
|
1012
1008
|
function closeFileServerSafely(fileServer, label, log = defaultLogger) {
|
|
1013
1009
|
try {
|
|
@@ -1106,7 +1102,7 @@ function createFileServer(options) {
|
|
|
1106
1102
|
html = injectScriptsAtHeadStart(html, preHeadScripts);
|
|
1107
1103
|
}
|
|
1108
1104
|
html = isIndex ? injectScriptsIntoHtml(html, headScripts, bodyScripts, stripEmbeddedRuntime) : html;
|
|
1109
|
-
html =
|
|
1105
|
+
html = markForAnotherSite(html);
|
|
1110
1106
|
return c.text(html, 200, { "Content-Type": contentType });
|
|
1111
1107
|
}
|
|
1112
1108
|
if (ext === ".png") {
|
|
@@ -8827,6 +8823,8 @@ async function runCaptureStage(input) {
|
|
|
8827
8823
|
pageErrorLines: workerPageErrors,
|
|
8828
8824
|
openAttempt: input.openAttempt,
|
|
8829
8825
|
verifyFirstSession: input.verifyFirstSession,
|
|
8826
|
+
prepareSession: input.prepareSession,
|
|
8827
|
+
onSessionUnprepared: input.onSessionUnprepared,
|
|
8830
8828
|
onProgress: (progress) => {
|
|
8831
8829
|
if (progress.latestWorkerPhase) {
|
|
8832
8830
|
if (progress.capturedFrames === 0) reportWorkerStartup(job, progress, onProgress);
|
|
@@ -9740,7 +9738,11 @@ async function executeDiskCaptureWithAdaptiveRetry(options) {
|
|
|
9740
9738
|
} : void 0,
|
|
9741
9739
|
void 0,
|
|
9742
9740
|
options.cfg,
|
|
9743
|
-
{
|
|
9741
|
+
{
|
|
9742
|
+
verifyFirstSession: options.verifyFirstSession,
|
|
9743
|
+
prepareSession: options.prepareSession,
|
|
9744
|
+
onSessionUnprepared: options.onSessionUnprepared
|
|
9745
|
+
}
|
|
9744
9746
|
);
|
|
9745
9747
|
pushWorkerDedupPerfs(workerResults, options.dedupPerfs);
|
|
9746
9748
|
if (options.pageErrorLines) pushWorkerPageErrors(workerResults, options.pageErrorLines);
|
|
@@ -12123,7 +12125,7 @@ async function compilePlanComposition(projectDir, config, planDir, options) {
|
|
|
12123
12125
|
const composition = compileResult.composition;
|
|
12124
12126
|
const { deviceScaleFactor } = compileResult;
|
|
12125
12127
|
let forceScreenshot = compileResult.forceScreenshot;
|
|
12126
|
-
if (cfg.lowMemoryMode) forceScreenshot = true;
|
|
12128
|
+
if (cfg.lowMemoryMode || deviceScaleFactor !== 1) forceScreenshot = true;
|
|
12127
12129
|
const { width, height } = composition;
|
|
12128
12130
|
if (config.rejectOnSystemFonts !== false) {
|
|
12129
12131
|
validateNoSystemFonts(compiled.html);
|
|
@@ -13805,6 +13807,8 @@ import {
|
|
|
13805
13807
|
getEncoderPreset as getEncoderPreset6,
|
|
13806
13808
|
initializeSession as initializeSession10,
|
|
13807
13809
|
measureVideoShownBoxes,
|
|
13810
|
+
measureVideoShownBoxPart,
|
|
13811
|
+
mergeVideoShownBoxParts,
|
|
13808
13812
|
probeBeginFrameLiveness as probeBeginFrameLiveness2,
|
|
13809
13813
|
readWebGlVendorInfoFromCanvas,
|
|
13810
13814
|
resolveConfig as resolveConfig5,
|
|
@@ -13924,6 +13928,35 @@ async function beginFrameSessionNeedsScreenshotFallback(session, probe = probeBe
|
|
|
13924
13928
|
);
|
|
13925
13929
|
return !await probe(session.page, timeoutMs, probeTick, session.beginFrameIntervalMs);
|
|
13926
13930
|
}
|
|
13931
|
+
function createSharedBoxMeasure(onDone) {
|
|
13932
|
+
const started = Date.now();
|
|
13933
|
+
let done = false;
|
|
13934
|
+
let workerCount = 0;
|
|
13935
|
+
const shares = /* @__PURE__ */ new Map();
|
|
13936
|
+
return {
|
|
13937
|
+
settled: () => done,
|
|
13938
|
+
fullSize: () => {
|
|
13939
|
+
if (done) return;
|
|
13940
|
+
done = true;
|
|
13941
|
+
onDone(void 0);
|
|
13942
|
+
},
|
|
13943
|
+
add: (worker, part, cost) => {
|
|
13944
|
+
if (done) return;
|
|
13945
|
+
if (worker.workerCount !== workerCount) shares.clear();
|
|
13946
|
+
workerCount = worker.workerCount;
|
|
13947
|
+
shares.set(worker.workerId, { part, ...cost });
|
|
13948
|
+
if (shares.size < workerCount) return;
|
|
13949
|
+
done = true;
|
|
13950
|
+
const all = [...shares.values()];
|
|
13951
|
+
onDone(mergeVideoShownBoxParts(all.map((share) => share.part)), {
|
|
13952
|
+
workers: workerCount,
|
|
13953
|
+
frames: all.reduce((sum2, share) => sum2 + share.frames, 0),
|
|
13954
|
+
durationMs: Date.now() - started,
|
|
13955
|
+
slowestShareMs: Math.max(...all.map((share) => share.durationMs))
|
|
13956
|
+
});
|
|
13957
|
+
}
|
|
13958
|
+
};
|
|
13959
|
+
}
|
|
13927
13960
|
function hashChunkOutput(outputPath, kind) {
|
|
13928
13961
|
if (kind === "file") return sha256Hex(readFileSync12(outputPath));
|
|
13929
13962
|
const entries = readdirSync9(outputPath).filter((name) => /\.(png|jpg|jpeg)$/i.test(name)).sort();
|
|
@@ -14129,14 +14162,26 @@ async function renderChunk(planDir, chunkIndex, outputChunkPath, options) {
|
|
|
14129
14162
|
});
|
|
14130
14163
|
boxesReady.catch(() => {
|
|
14131
14164
|
});
|
|
14165
|
+
const shownVideoIds = [...shownFrames.keys()];
|
|
14166
|
+
const chunkFrameTimes = chunkFrameNumbers.map(
|
|
14167
|
+
(frame) => frame * chunkFps.den / chunkFps.num
|
|
14168
|
+
);
|
|
14132
14169
|
const measureBoxes = async (page) => {
|
|
14133
|
-
shownBoxes = await measureVideoShownBoxes(
|
|
14134
|
-
page,
|
|
14135
|
-
[...shownFrames.keys()],
|
|
14136
|
-
chunkFrameNumbers.map((frame) => frame * chunkFps.den / chunkFps.num)
|
|
14137
|
-
);
|
|
14170
|
+
shownBoxes = await measureVideoShownBoxes(page, shownVideoIds, chunkFrameTimes);
|
|
14138
14171
|
boxesMeasured();
|
|
14139
14172
|
};
|
|
14173
|
+
const sharedBoxes = createSharedBoxMeasure((boxes2, pass) => {
|
|
14174
|
+
shownBoxes = boxes2;
|
|
14175
|
+
boxesMeasured();
|
|
14176
|
+
if (pass) log.info("[renderChunk] video boxes measured", { chunkIndex, ...pass });
|
|
14177
|
+
});
|
|
14178
|
+
const measureShare = async (session2, worker) => {
|
|
14179
|
+
if (sharedBoxes.settled()) return;
|
|
14180
|
+
const started = Date.now();
|
|
14181
|
+
const times = chunkFrameTimes.filter((_, i) => i % worker.workerCount === worker.workerId);
|
|
14182
|
+
const part = await measureVideoShownBoxPart(session2.page, shownVideoIds, times);
|
|
14183
|
+
sharedBoxes.add(worker, part, { frames: times.length, durationMs: Date.now() - started });
|
|
14184
|
+
};
|
|
14140
14185
|
if (chunkWorkerCount === 1) {
|
|
14141
14186
|
const bootStarted = Date.now();
|
|
14142
14187
|
session = await createVerifiedDistributedCaptureSession(
|
|
@@ -14178,14 +14223,13 @@ async function renderChunk(planDir, chunkIndex, outputChunkPath, options) {
|
|
|
14178
14223
|
);
|
|
14179
14224
|
sessionBootMs += Date.now() - screenshotBootStarted;
|
|
14180
14225
|
}
|
|
14181
|
-
} else if (!verifyInWorker) {
|
|
14182
|
-
|
|
14226
|
+
} else if (!verifyInWorker || shownVideoIds.length === 0) {
|
|
14227
|
+
sharedBoxes.fullSize();
|
|
14183
14228
|
}
|
|
14184
14229
|
let verification;
|
|
14185
14230
|
const verifyFirstWorker = (first) => verification ??= (async () => {
|
|
14186
14231
|
sessionBootMs = Date.now() - verifyStarted;
|
|
14187
14232
|
try {
|
|
14188
|
-
await measureBoxes(first.page);
|
|
14189
14233
|
const selectedScreenshot = first.launchCaptureMode === "screenshot";
|
|
14190
14234
|
if (selectedScreenshot || await beginFrameSessionNeedsScreenshotFallback(first)) {
|
|
14191
14235
|
forceScreenshotForChunk = true;
|
|
@@ -14370,7 +14414,9 @@ async function renderChunk(planDir, chunkIndex, outputChunkPath, options) {
|
|
|
14370
14414
|
onFrameLanded: (frame) => overlap.current?.onFrameLanded(frame),
|
|
14371
14415
|
interleaveFrames: interleavesCapture(overlap.current !== null, options),
|
|
14372
14416
|
openAttempt,
|
|
14373
|
-
verifyFirstSession: forceScreenshot || !verifyInWorker ? void 0 : verifyFirstWorker
|
|
14417
|
+
verifyFirstSession: forceScreenshot || !verifyInWorker ? void 0 : verifyFirstWorker,
|
|
14418
|
+
prepareSession: forceScreenshot || !verifyInWorker ? void 0 : measureShare,
|
|
14419
|
+
onSessionUnprepared: () => sharedBoxes.fullSize()
|
|
14374
14420
|
}),
|
|
14375
14421
|
{ stall: frameStallRule(job, framesInChunk, void 0) }
|
|
14376
14422
|
).catch(async (captureError) => {
|
|
@@ -14382,7 +14428,7 @@ async function renderChunk(planDir, chunkIndex, outputChunkPath, options) {
|
|
|
14382
14428
|
},
|
|
14383
14429
|
resetForScreenshotRetry: () => {
|
|
14384
14430
|
rmSync12(workDir, { recursive: true, force: true, maxRetries: 3, retryDelay: 100 });
|
|
14385
|
-
|
|
14431
|
+
sharedBoxes.fullSize();
|
|
14386
14432
|
mkdirSync15(framesDir, { recursive: true });
|
|
14387
14433
|
capturePerfs.length = 0;
|
|
14388
14434
|
captureAttempts.length = 0;
|
package/dist/index.js
CHANGED
|
@@ -392,11 +392,8 @@ import { promisify } from "node:util";
|
|
|
392
392
|
import { Readable } from "node:stream";
|
|
393
393
|
import { join as join2, extname, resolve as resolve2, sep as sep2 } from "node:path";
|
|
394
394
|
import { injectScriptsAtHeadStart, injectScriptsIntoHtml } from "@hyperframes/core/compiler";
|
|
395
|
-
import {
|
|
396
|
-
import {
|
|
397
|
-
PREVIEW_FOR_ANOTHER_SITE_META,
|
|
398
|
-
serviceWorkerScriptFetch
|
|
399
|
-
} from "@hyperframes/core/studio-preview-mark";
|
|
395
|
+
import { markForAnotherSite } from "@hyperframes/core/compiler/html-document";
|
|
396
|
+
import { serviceWorkerScriptFetch } from "@hyperframes/core/studio-preview-mark";
|
|
400
397
|
import { fpsToNumber, terminalText as terminalText2 } from "@hyperframes/core";
|
|
401
398
|
import { isPrivateFileUnder as isPrivateFileUnder2, isStudioPrivatePath as isStudioPrivatePath2 } from "@hyperframes/core/safe-path";
|
|
402
399
|
import { stripSdrPngColourTags } from "@hyperframes/core/compiler/png-colour-tags";
|
|
@@ -1116,7 +1113,6 @@ var HF_BRIDGE_SCRIPT = `(function() {
|
|
|
1116
1113
|
if (bridge()) __realClearInterval(iv);
|
|
1117
1114
|
}, 50);
|
|
1118
1115
|
})();`;
|
|
1119
|
-
var OFFER_NO_FRAMING_SITE_AN_EDITING_PORT = `<meta name="${PREVIEW_FOR_ANOTHER_SITE_META}">`;
|
|
1120
1116
|
var RENDER_CAPTURE_MODE_SHIM = "globalThis.__HF_RENDER_CAPTURE_MODE = true;";
|
|
1121
1117
|
function closeFileServerSafely(fileServer, label, log = defaultLogger) {
|
|
1122
1118
|
try {
|
|
@@ -1215,7 +1211,7 @@ function createFileServer(options) {
|
|
|
1215
1211
|
html = injectScriptsAtHeadStart(html, preHeadScripts);
|
|
1216
1212
|
}
|
|
1217
1213
|
html = isIndex ? injectScriptsIntoHtml(html, headScripts, bodyScripts, stripEmbeddedRuntime) : html;
|
|
1218
|
-
html =
|
|
1214
|
+
html = markForAnotherSite(html);
|
|
1219
1215
|
return c.text(html, 200, { "Content-Type": contentType });
|
|
1220
1216
|
}
|
|
1221
1217
|
if (ext === ".png") {
|
|
@@ -13672,6 +13668,8 @@ async function runCaptureStage(input) {
|
|
|
13672
13668
|
pageErrorLines: workerPageErrors,
|
|
13673
13669
|
openAttempt: input.openAttempt,
|
|
13674
13670
|
verifyFirstSession: input.verifyFirstSession,
|
|
13671
|
+
prepareSession: input.prepareSession,
|
|
13672
|
+
onSessionUnprepared: input.onSessionUnprepared,
|
|
13675
13673
|
onProgress: (progress) => {
|
|
13676
13674
|
if (progress.latestWorkerPhase) {
|
|
13677
13675
|
if (progress.capturedFrames === 0) reportWorkerStartup(job, progress, onProgress);
|
|
@@ -15840,7 +15838,11 @@ async function executeDiskCaptureWithAdaptiveRetry(options) {
|
|
|
15840
15838
|
} : void 0,
|
|
15841
15839
|
void 0,
|
|
15842
15840
|
options.cfg,
|
|
15843
|
-
{
|
|
15841
|
+
{
|
|
15842
|
+
verifyFirstSession: options.verifyFirstSession,
|
|
15843
|
+
prepareSession: options.prepareSession,
|
|
15844
|
+
onSessionUnprepared: options.onSessionUnprepared
|
|
15845
|
+
}
|
|
15844
15846
|
);
|
|
15845
15847
|
pushWorkerDedupPerfs(workerResults, options.dedupPerfs);
|
|
15846
15848
|
if (options.pageErrorLines) pushWorkerPageErrors(workerResults, options.pageErrorLines);
|
|
@@ -21031,7 +21033,7 @@ async function compilePlanComposition(projectDir, config, planDir, options) {
|
|
|
21031
21033
|
const composition = compileResult.composition;
|
|
21032
21034
|
const { deviceScaleFactor } = compileResult;
|
|
21033
21035
|
let forceScreenshot = compileResult.forceScreenshot;
|
|
21034
|
-
if (cfg.lowMemoryMode) forceScreenshot = true;
|
|
21036
|
+
if (cfg.lowMemoryMode || deviceScaleFactor !== 1) forceScreenshot = true;
|
|
21035
21037
|
const { width, height } = composition;
|
|
21036
21038
|
if (config.rejectOnSystemFonts !== false) {
|
|
21037
21039
|
validateNoSystemFonts(compiled.html);
|
|
@@ -21464,6 +21466,8 @@ import {
|
|
|
21464
21466
|
getEncoderPreset as getEncoderPreset5,
|
|
21465
21467
|
initializeSession as initializeSession10,
|
|
21466
21468
|
measureVideoShownBoxes,
|
|
21469
|
+
measureVideoShownBoxPart,
|
|
21470
|
+
mergeVideoShownBoxParts,
|
|
21467
21471
|
probeBeginFrameLiveness as probeBeginFrameLiveness2,
|
|
21468
21472
|
readWebGlVendorInfoFromCanvas,
|
|
21469
21473
|
resolveConfig as resolveConfig4,
|
|
@@ -22477,6 +22481,35 @@ async function beginFrameSessionNeedsScreenshotFallback(session, probe = probeBe
|
|
|
22477
22481
|
);
|
|
22478
22482
|
return !await probe(session.page, timeoutMs, probeTick, session.beginFrameIntervalMs);
|
|
22479
22483
|
}
|
|
22484
|
+
function createSharedBoxMeasure(onDone) {
|
|
22485
|
+
const started = Date.now();
|
|
22486
|
+
let done = false;
|
|
22487
|
+
let workerCount = 0;
|
|
22488
|
+
const shares = /* @__PURE__ */ new Map();
|
|
22489
|
+
return {
|
|
22490
|
+
settled: () => done,
|
|
22491
|
+
fullSize: () => {
|
|
22492
|
+
if (done) return;
|
|
22493
|
+
done = true;
|
|
22494
|
+
onDone(void 0);
|
|
22495
|
+
},
|
|
22496
|
+
add: (worker, part, cost) => {
|
|
22497
|
+
if (done) return;
|
|
22498
|
+
if (worker.workerCount !== workerCount) shares.clear();
|
|
22499
|
+
workerCount = worker.workerCount;
|
|
22500
|
+
shares.set(worker.workerId, { part, ...cost });
|
|
22501
|
+
if (shares.size < workerCount) return;
|
|
22502
|
+
done = true;
|
|
22503
|
+
const all = [...shares.values()];
|
|
22504
|
+
onDone(mergeVideoShownBoxParts(all.map((share) => share.part)), {
|
|
22505
|
+
workers: workerCount,
|
|
22506
|
+
frames: all.reduce((sum2, share) => sum2 + share.frames, 0),
|
|
22507
|
+
durationMs: Date.now() - started,
|
|
22508
|
+
slowestShareMs: Math.max(...all.map((share) => share.durationMs))
|
|
22509
|
+
});
|
|
22510
|
+
}
|
|
22511
|
+
};
|
|
22512
|
+
}
|
|
22480
22513
|
function hashChunkOutput(outputPath, kind) {
|
|
22481
22514
|
if (kind === "file") return sha256Hex(readFileSync15(outputPath));
|
|
22482
22515
|
const entries = readdirSync11(outputPath).filter((name) => /\.(png|jpg|jpeg)$/i.test(name)).sort();
|
|
@@ -22682,14 +22715,26 @@ async function renderChunk(planDir, chunkIndex, outputChunkPath, options) {
|
|
|
22682
22715
|
});
|
|
22683
22716
|
boxesReady.catch(() => {
|
|
22684
22717
|
});
|
|
22718
|
+
const shownVideoIds = [...shownFrames.keys()];
|
|
22719
|
+
const chunkFrameTimes = chunkFrameNumbers.map(
|
|
22720
|
+
(frame) => frame * chunkFps.den / chunkFps.num
|
|
22721
|
+
);
|
|
22685
22722
|
const measureBoxes = async (page) => {
|
|
22686
|
-
shownBoxes = await measureVideoShownBoxes(
|
|
22687
|
-
page,
|
|
22688
|
-
[...shownFrames.keys()],
|
|
22689
|
-
chunkFrameNumbers.map((frame) => frame * chunkFps.den / chunkFps.num)
|
|
22690
|
-
);
|
|
22723
|
+
shownBoxes = await measureVideoShownBoxes(page, shownVideoIds, chunkFrameTimes);
|
|
22691
22724
|
boxesMeasured();
|
|
22692
22725
|
};
|
|
22726
|
+
const sharedBoxes = createSharedBoxMeasure((boxes2, pass) => {
|
|
22727
|
+
shownBoxes = boxes2;
|
|
22728
|
+
boxesMeasured();
|
|
22729
|
+
if (pass) log.info("[renderChunk] video boxes measured", { chunkIndex, ...pass });
|
|
22730
|
+
});
|
|
22731
|
+
const measureShare = async (session2, worker) => {
|
|
22732
|
+
if (sharedBoxes.settled()) return;
|
|
22733
|
+
const started = Date.now();
|
|
22734
|
+
const times = chunkFrameTimes.filter((_, i) => i % worker.workerCount === worker.workerId);
|
|
22735
|
+
const part = await measureVideoShownBoxPart(session2.page, shownVideoIds, times);
|
|
22736
|
+
sharedBoxes.add(worker, part, { frames: times.length, durationMs: Date.now() - started });
|
|
22737
|
+
};
|
|
22693
22738
|
if (chunkWorkerCount === 1) {
|
|
22694
22739
|
const bootStarted = Date.now();
|
|
22695
22740
|
session = await createVerifiedDistributedCaptureSession(
|
|
@@ -22731,14 +22776,13 @@ async function renderChunk(planDir, chunkIndex, outputChunkPath, options) {
|
|
|
22731
22776
|
);
|
|
22732
22777
|
sessionBootMs += Date.now() - screenshotBootStarted;
|
|
22733
22778
|
}
|
|
22734
|
-
} else if (!verifyInWorker) {
|
|
22735
|
-
|
|
22779
|
+
} else if (!verifyInWorker || shownVideoIds.length === 0) {
|
|
22780
|
+
sharedBoxes.fullSize();
|
|
22736
22781
|
}
|
|
22737
22782
|
let verification;
|
|
22738
22783
|
const verifyFirstWorker = (first) => verification ??= (async () => {
|
|
22739
22784
|
sessionBootMs = Date.now() - verifyStarted;
|
|
22740
22785
|
try {
|
|
22741
|
-
await measureBoxes(first.page);
|
|
22742
22786
|
const selectedScreenshot = first.launchCaptureMode === "screenshot";
|
|
22743
22787
|
if (selectedScreenshot || await beginFrameSessionNeedsScreenshotFallback(first)) {
|
|
22744
22788
|
forceScreenshotForChunk = true;
|
|
@@ -22923,7 +22967,9 @@ async function renderChunk(planDir, chunkIndex, outputChunkPath, options) {
|
|
|
22923
22967
|
onFrameLanded: (frame) => overlap.current?.onFrameLanded(frame),
|
|
22924
22968
|
interleaveFrames: interleavesCapture(overlap.current !== null, options),
|
|
22925
22969
|
openAttempt,
|
|
22926
|
-
verifyFirstSession: forceScreenshot || !verifyInWorker ? void 0 : verifyFirstWorker
|
|
22970
|
+
verifyFirstSession: forceScreenshot || !verifyInWorker ? void 0 : verifyFirstWorker,
|
|
22971
|
+
prepareSession: forceScreenshot || !verifyInWorker ? void 0 : measureShare,
|
|
22972
|
+
onSessionUnprepared: () => sharedBoxes.fullSize()
|
|
22927
22973
|
}),
|
|
22928
22974
|
{ stall: frameStallRule(job, framesInChunk, void 0) }
|
|
22929
22975
|
).catch(async (captureError) => {
|
|
@@ -22935,7 +22981,7 @@ async function renderChunk(planDir, chunkIndex, outputChunkPath, options) {
|
|
|
22935
22981
|
},
|
|
22936
22982
|
resetForScreenshotRetry: () => {
|
|
22937
22983
|
rmSync18(workDir, { recursive: true, force: true, maxRetries: 3, retryDelay: 100 });
|
|
22938
|
-
|
|
22984
|
+
sharedBoxes.fullSize();
|
|
22939
22985
|
mkdirSync22(framesDir, { recursive: true });
|
|
22940
22986
|
capturePerfs.length = 0;
|
|
22941
22987
|
captureAttempts.length = 0;
|
package/dist/public-server.js
CHANGED
|
@@ -434,11 +434,8 @@ import { promisify } from "node:util";
|
|
|
434
434
|
import { Readable } from "node:stream";
|
|
435
435
|
import { join as join2, extname, resolve as resolve2, sep as sep2 } from "node:path";
|
|
436
436
|
import { injectScriptsAtHeadStart, injectScriptsIntoHtml } from "@hyperframes/core/compiler";
|
|
437
|
-
import {
|
|
438
|
-
import {
|
|
439
|
-
PREVIEW_FOR_ANOTHER_SITE_META,
|
|
440
|
-
serviceWorkerScriptFetch
|
|
441
|
-
} from "@hyperframes/core/studio-preview-mark";
|
|
437
|
+
import { markForAnotherSite } from "@hyperframes/core/compiler/html-document";
|
|
438
|
+
import { serviceWorkerScriptFetch } from "@hyperframes/core/studio-preview-mark";
|
|
442
439
|
import { fpsToNumber, terminalText as terminalText2 } from "@hyperframes/core";
|
|
443
440
|
import { isPrivateFileUnder as isPrivateFileUnder2, isStudioPrivatePath as isStudioPrivatePath2 } from "@hyperframes/core/safe-path";
|
|
444
441
|
import { stripSdrPngColourTags } from "@hyperframes/core/compiler/png-colour-tags";
|
|
@@ -1158,7 +1155,6 @@ var HF_BRIDGE_SCRIPT = `(function() {
|
|
|
1158
1155
|
if (bridge()) __realClearInterval(iv);
|
|
1159
1156
|
}, 50);
|
|
1160
1157
|
})();`;
|
|
1161
|
-
var OFFER_NO_FRAMING_SITE_AN_EDITING_PORT = `<meta name="${PREVIEW_FOR_ANOTHER_SITE_META}">`;
|
|
1162
1158
|
var RENDER_CAPTURE_MODE_SHIM = "globalThis.__HF_RENDER_CAPTURE_MODE = true;";
|
|
1163
1159
|
function closeFileServerSafely(fileServer, label, log = defaultLogger) {
|
|
1164
1160
|
try {
|
|
@@ -1257,7 +1253,7 @@ function createFileServer(options) {
|
|
|
1257
1253
|
html = injectScriptsAtHeadStart(html, preHeadScripts);
|
|
1258
1254
|
}
|
|
1259
1255
|
html = isIndex ? injectScriptsIntoHtml(html, headScripts, bodyScripts, stripEmbeddedRuntime) : html;
|
|
1260
|
-
html =
|
|
1256
|
+
html = markForAnotherSite(html);
|
|
1261
1257
|
return c.text(html, 200, { "Content-Type": contentType });
|
|
1262
1258
|
}
|
|
1263
1259
|
if (ext === ".png") {
|
|
@@ -13654,6 +13650,8 @@ async function runCaptureStage(input) {
|
|
|
13654
13650
|
pageErrorLines: workerPageErrors,
|
|
13655
13651
|
openAttempt: input.openAttempt,
|
|
13656
13652
|
verifyFirstSession: input.verifyFirstSession,
|
|
13653
|
+
prepareSession: input.prepareSession,
|
|
13654
|
+
onSessionUnprepared: input.onSessionUnprepared,
|
|
13657
13655
|
onProgress: (progress) => {
|
|
13658
13656
|
if (progress.latestWorkerPhase) {
|
|
13659
13657
|
if (progress.capturedFrames === 0) reportWorkerStartup(job, progress, onProgress);
|
|
@@ -15822,7 +15820,11 @@ async function executeDiskCaptureWithAdaptiveRetry(options) {
|
|
|
15822
15820
|
} : void 0,
|
|
15823
15821
|
void 0,
|
|
15824
15822
|
options.cfg,
|
|
15825
|
-
{
|
|
15823
|
+
{
|
|
15824
|
+
verifyFirstSession: options.verifyFirstSession,
|
|
15825
|
+
prepareSession: options.prepareSession,
|
|
15826
|
+
onSessionUnprepared: options.onSessionUnprepared
|
|
15827
|
+
}
|
|
15826
15828
|
);
|
|
15827
15829
|
pushWorkerDedupPerfs(workerResults, options.dedupPerfs);
|
|
15828
15830
|
if (options.pageErrorLines) pushWorkerPageErrors(workerResults, options.pageErrorLines);
|
|
@@ -32,7 +32,7 @@
|
|
|
32
32
|
* Every other determinism toggle above is opt-in — only this primitive enables them.
|
|
33
33
|
* In-process renders (`executeRenderJob`) leave them off.
|
|
34
34
|
*/
|
|
35
|
-
import { assertSwiftShader, type CaptureOptions, type CaptureMode, type CapturePerfSummary, type CaptureSession, closeCaptureSession, createCaptureSession, type EngineConfig, initializeSession, probeBeginFrameLiveness, readWebGlVendorInfoFromCanvas } from "@hyperframes/engine";
|
|
35
|
+
import { assertSwiftShader, type CaptureOptions, type CaptureMode, type CapturePerfSummary, type CaptureSession, closeCaptureSession, createCaptureSession, type EngineConfig, initializeSession, type ShownBoxPart, probeBeginFrameLiveness, readWebGlVendorInfoFromCanvas, type ShownBox } from "@hyperframes/engine";
|
|
36
36
|
import { type ChunkSliceJson, type LockedRenderConfig } from "../render/stages/freezePlan.js";
|
|
37
37
|
import { type PlanVideosJson } from "./shared.js";
|
|
38
38
|
export { CHUNK_FRAME_RANGE_INVALID, CHUNK_INDEX_OUT_OF_RANGE, createChunkVideoFrameInjectorFactory, extractDeferredVideoFramesForChunk, FFMPEG_VERSION_MISMATCH, INVALID_VIDEO_METADATA, MISSING_PLAN_ARTIFACT, MISSING_RUNTIME_ENV_SNAPSHOT, PLAN_HASH_MISMATCH, rebuildExtractedFramesFromPlanDir, RenderChunkValidationError, } from "./chunkFrames.js";
|
|
@@ -166,6 +166,27 @@ export declare function runCaptureWithScreenshotFallback<T>(input: {
|
|
|
166
166
|
* and frame zero. `true` means the entire chunk should use screenshot mode.
|
|
167
167
|
*/
|
|
168
168
|
export declare function beginFrameSessionNeedsScreenshotFallback(session: Pick<CaptureSession, "page" | "launchCaptureMode" | "beginFrameTimeTicks" | "beginFrameIntervalMs">, probe?: typeof probeBeginFrameLiveness): Promise<boolean>;
|
|
169
|
+
/**
|
|
170
|
+
* Joins the shares of the box-measuring pass that a chunk's capture workers each run on their own page.
|
|
171
|
+
* `onDone` gets the merged boxes once every worker of one pool has reported, or none when the chunk extracts
|
|
172
|
+
* at full size. It runs once; later shares are dropped.
|
|
173
|
+
*/
|
|
174
|
+
export declare function createSharedBoxMeasure(onDone: (boxes: Map<string, ShownBox> | undefined, pass?: {
|
|
175
|
+
workers: number;
|
|
176
|
+
frames: number;
|
|
177
|
+
durationMs: number;
|
|
178
|
+
slowestShareMs: number;
|
|
179
|
+
}) => void): {
|
|
180
|
+
add: (worker: {
|
|
181
|
+
workerId: number;
|
|
182
|
+
workerCount: number;
|
|
183
|
+
}, part: ShownBoxPart, cost: {
|
|
184
|
+
frames: number;
|
|
185
|
+
durationMs: number;
|
|
186
|
+
}) => void;
|
|
187
|
+
fullSize: () => void;
|
|
188
|
+
settled: () => boolean;
|
|
189
|
+
};
|
|
169
190
|
/**
|
|
170
191
|
* Re-export the runtime-env apply helper so adapters that import only
|
|
171
192
|
* this subpath can prime `process.env` before instantiating their own
|
|
@@ -30,7 +30,7 @@
|
|
|
30
30
|
* `renderOrchestrator.ts`, which imports the stage (a cycle that resolves at module init). The
|
|
31
31
|
* capture helpers should move to a shared module so stages stop reaching back into the orchestrator.
|
|
32
32
|
*/
|
|
33
|
-
import { type BeforeCaptureHook, type CaptureOptions, type CapturePerfSummary, type CaptureSession, type EngineConfig, type LandedFrame } from "@hyperframes/engine";
|
|
33
|
+
import { type BeforeCaptureHook, type CaptureOptions, type CapturePerfSummary, type CaptureSession, type EngineConfig, type LandedFrame, type ParallelCaptureHooks } from "@hyperframes/engine";
|
|
34
34
|
import type { FileServerHandle } from "../../fileServer.js";
|
|
35
35
|
import type { ProducerLogger } from "../../../logger.js";
|
|
36
36
|
import { type CaptureAttemptSummary, type ProgressCallback, type RenderConfig, type RenderJob } from "../../renderOrchestrator.js";
|
|
@@ -89,6 +89,8 @@ export interface CaptureStageInput {
|
|
|
89
89
|
/** Each capture attempt opens one, so a stalled attempt is retried by the ladders below. */
|
|
90
90
|
openAttempt?: OpenStallAttempt;
|
|
91
91
|
verifyFirstSession?: (session: CaptureSession) => Promise<void>;
|
|
92
|
+
prepareSession?: ParallelCaptureHooks["prepareSession"];
|
|
93
|
+
onSessionUnprepared?: ParallelCaptureHooks["onSessionUnprepared"];
|
|
92
94
|
}
|
|
93
95
|
export interface CaptureStageResult {
|
|
94
96
|
/** Final worker count after any adaptive retry. */
|
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
import type { ExpectedOutputDimensions } from "./render/outputDimensions.js";
|
|
2
2
|
import { type CanvasResolution, type Fps, type FpsInput, type HfVfxCapture } from "@hyperframes/core";
|
|
3
3
|
import type { CompileForRenderOptions } from "./htmlCompiler.js";
|
|
4
|
-
import { type EngineConfig, type ExtractionPhaseBreakdown, type VideoFrameFormat, closeCaptureSession, initializeSession, type CaptureOptions, type CaptureVideoMetadataHint, type CaptureSession, type BeforeCaptureHook, type ProresProfile, type ParallelProgress, type WorkerTask, type CapturePerfSummary, type CaptureWarning, type SubTimelineWaitOutcome, type WorkerSizing, type StaticVerificationOutcome, explainDrawElementDisabled, type CaptureFailureKind, displaySize, type ChromaSubsampling, type MotionBlurOptions, type PageMotionBlurSummary } from "@hyperframes/engine";
|
|
4
|
+
import { type EngineConfig, type ExtractionPhaseBreakdown, type VideoFrameFormat, closeCaptureSession, initializeSession, type CaptureOptions, type CaptureVideoMetadataHint, type CaptureSession, type BeforeCaptureHook, type ProresProfile, type ParallelProgress, type WorkerTask, type CapturePerfSummary, type CaptureWarning, type SubTimelineWaitOutcome, type WorkerSizing, type StaticVerificationOutcome, explainDrawElementDisabled, type CaptureFailureKind, displaySize, type ChromaSubsampling, type MotionBlurOptions, type PageMotionBlurSummary, type ParallelCaptureHooks } from "@hyperframes/engine";
|
|
5
5
|
import { type ReferenceBackgroundResult } from "@hyperframes/engine";
|
|
6
6
|
import { type ProducerLogger } from "../logger.js";
|
|
7
7
|
import { type RenderOutputFormat } from "./render/renderFormat.js";
|
|
@@ -648,6 +648,8 @@ export declare function executeDiskCaptureWithAdaptiveRetry(options: {
|
|
|
648
648
|
pageErrorLines?: string[];
|
|
649
649
|
openAttempt?: OpenStallAttempt;
|
|
650
650
|
verifyFirstSession?: (session: CaptureSession) => Promise<void>;
|
|
651
|
+
prepareSession?: ParallelCaptureHooks["prepareSession"];
|
|
652
|
+
onSessionUnprepared?: ParallelCaptureHooks["onSessionUnprepared"];
|
|
651
653
|
}): Promise<CaptureAttemptSummary[]>;
|
|
652
654
|
export type RenderConfigInput = Omit<RenderConfig, "fps"> & {
|
|
653
655
|
fps: FpsInput;
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@hyperframes/producer",
|
|
3
|
-
"version": "0.
|
|
3
|
+
"version": "0.10.0",
|
|
4
4
|
"description": "HTML-to-video rendering engine using Chrome's BeginFrame API",
|
|
5
5
|
"repository": {
|
|
6
6
|
"type": "git",
|
|
@@ -35,12 +35,12 @@
|
|
|
35
35
|
"postcss": "^8.4.0",
|
|
36
36
|
"puppeteer": "~25.13.0",
|
|
37
37
|
"puppeteer-core": "^25.13.0",
|
|
38
|
-
"@hyperframes/
|
|
39
|
-
"@hyperframes/
|
|
40
|
-
"@hyperframes/
|
|
41
|
-
"@hyperframes/
|
|
42
|
-
"@hyperframes/
|
|
43
|
-
"@hyperframes/
|
|
38
|
+
"@hyperframes/engine": "0.10.0",
|
|
39
|
+
"@hyperframes/core": "0.10.0",
|
|
40
|
+
"@hyperframes/lint": "0.10.0",
|
|
41
|
+
"@hyperframes/parsers": "0.10.0",
|
|
42
|
+
"@hyperframes/share": "0.10.0",
|
|
43
|
+
"@hyperframes/studio-server": "0.10.0"
|
|
44
44
|
},
|
|
45
45
|
"devDependencies": {
|
|
46
46
|
"@types/node": "^25.0.10",
|
|
@@ -49,10 +49,10 @@
|
|
|
49
49
|
"tsx": "^4.21.0",
|
|
50
50
|
"typescript": "^5.7.2",
|
|
51
51
|
"vitest": "^4.1.12",
|
|
52
|
-
"@hyperframes/aws-lambda": "0.
|
|
52
|
+
"@hyperframes/aws-lambda": "0.10.0"
|
|
53
53
|
},
|
|
54
54
|
"engines": {
|
|
55
|
-
"node": ">=22"
|
|
55
|
+
"node": ">=22.19.0"
|
|
56
56
|
},
|
|
57
57
|
"scripts": {
|
|
58
58
|
"build": "bun run build:hf-early-stub && bun run --cwd ../.. build:hyperframes-runtime:modular && node build.mjs",
|