@hyperframes/producer 0.9.93 → 0.9.94
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 +18 -11
- package/dist/distributed.js +41 -27
- package/dist/hyperframe.manifest.json +1 -1
- package/dist/hyperframe.runtime.iife.js +66 -66
- package/dist/index.js +369 -226
- package/dist/public-server.js +281 -138
- 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 resolve11, dirname as
|
|
35
|
+
import { basename as basename8, resolve as resolve11, 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,7 @@ 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 resolve9 } from "path";
|
|
406
407
|
import { totalmem as totalmem2 } from "node:os";
|
|
407
408
|
import { randomUUID as randomUUID3 } from "crypto";
|
|
408
409
|
import { fileURLToPath as fileURLToPath5 } from "url";
|
|
@@ -432,7 +433,7 @@ import {
|
|
|
432
433
|
serviceWorkerScriptFetch
|
|
433
434
|
} from "@hyperframes/core/studio-preview-mark";
|
|
434
435
|
import { fpsToNumber, terminalText as terminalText2 } from "@hyperframes/core";
|
|
435
|
-
import { isPrivateFileUnder, isStudioPrivatePath } from "@hyperframes/core/safe-path";
|
|
436
|
+
import { isPrivateFileUnder as isPrivateFileUnder2, isStudioPrivatePath as isStudioPrivatePath2 } from "@hyperframes/core/safe-path";
|
|
436
437
|
import { stripSdrPngColourTags } from "@hyperframes/core/compiler/png-colour-tags";
|
|
437
438
|
import { openRangeEnd } from "@hyperframes/studio-server/media-range";
|
|
438
439
|
|
|
@@ -574,7 +575,7 @@ import {
|
|
|
574
575
|
} from "node:path";
|
|
575
576
|
import { statSync } from "node:fs";
|
|
576
577
|
import { fileURLToPath as fileURLToPath2 } from "node:url";
|
|
577
|
-
import { isSafePath } from "@hyperframes/core/safe-path";
|
|
578
|
+
import { isPrivateFileUnder, isSafePath, isStudioPrivatePath } from "@hyperframes/core/safe-path";
|
|
578
579
|
import {
|
|
579
580
|
isCopiedOutsideFileType,
|
|
580
581
|
isPrivateOutsideFile,
|
|
@@ -601,7 +602,10 @@ function escapesAssetRoot(path, assetRoot) {
|
|
|
601
602
|
return assetRoot !== void 0 && !isSafePath(assetRoot, path);
|
|
602
603
|
}
|
|
603
604
|
function outsideAssetRefusal(projectDir, path, policy = {}) {
|
|
604
|
-
if (!linksOutside(projectDir, path))
|
|
605
|
+
if (!linksOutside(projectDir, path)) {
|
|
606
|
+
const privateByAnotherSpelling = !isPathInside(path, projectDir) && isPrivateFileUnder(projectDir, path, isStudioPrivatePath);
|
|
607
|
+
return privateByAnotherSpelling ? "blocklisted" : null;
|
|
608
|
+
}
|
|
605
609
|
if (isPrivateOutsideFile(projectDir, path)) return "blocklisted";
|
|
606
610
|
const folder = statSync(path, { throwIfNoEntry: false })?.isDirectory();
|
|
607
611
|
if (folder || isUploadedOutsideFileType(path)) return null;
|
|
@@ -1227,7 +1231,7 @@ function createFileServer(options) {
|
|
|
1227
1231
|
const candidate = join2(root, relativePath);
|
|
1228
1232
|
const resolveSymlinks = !allowOutsideProjectAssets && root !== compiledDir;
|
|
1229
1233
|
if (!isPathInside2(candidate, root, { resolveSymlinks })) continue;
|
|
1230
|
-
if (
|
|
1234
|
+
if (isPrivateFileUnder2(root, candidate, isStudioPrivatePath2)) continue;
|
|
1231
1235
|
const checksLinks = allowOutsideProjectAssets && root !== compiledDir;
|
|
1232
1236
|
if (checksLinks && refusesOutsideLink(root, candidate, warnLeftOut, outsidePolicy)) continue;
|
|
1233
1237
|
file = openRegularFile(candidate);
|
|
@@ -4167,12 +4171,12 @@ function distributeLayeredHybridFrameRanges(totalFrames, workerCount) {
|
|
|
4167
4171
|
}
|
|
4168
4172
|
return ranges;
|
|
4169
4173
|
}
|
|
4170
|
-
function partitionTransitionFrames(transitionRanges, totalFrames) {
|
|
4174
|
+
function partitionTransitionFrames(transitionRanges, totalFrames, firstFrame = 0) {
|
|
4171
4175
|
const frames = /* @__PURE__ */ new Set();
|
|
4172
4176
|
if (totalFrames <= 0) return frames;
|
|
4173
4177
|
for (const range of transitionRanges) {
|
|
4174
|
-
const start = Math.max(
|
|
4175
|
-
const end = Math.min(totalFrames - 1, range.endFrame);
|
|
4178
|
+
const start = Math.max(firstFrame, range.startFrame);
|
|
4179
|
+
const end = Math.min(firstFrame + totalFrames - 1, range.endFrame);
|
|
4176
4180
|
for (let i = start; i <= end; i++) frames.add(i);
|
|
4177
4181
|
}
|
|
4178
4182
|
return frames;
|
|
@@ -4382,6 +4386,18 @@ function cleanupEndedHdrVideos(args) {
|
|
|
4382
4386
|
}
|
|
4383
4387
|
}
|
|
4384
4388
|
}
|
|
4389
|
+
function transitionAtFrame(transitionRanges, frame) {
|
|
4390
|
+
return transitionRanges.find((t) => frame >= t.startFrame && frame <= t.endFrame);
|
|
4391
|
+
}
|
|
4392
|
+
function cleanupHdrVideosEndedBefore(firstFrame, fps, transitionRanges, state) {
|
|
4393
|
+
for (let frame = 0; frame < firstFrame; frame++) {
|
|
4394
|
+
cleanupEndedHdrVideos({
|
|
4395
|
+
...state,
|
|
4396
|
+
time: frame * fps.den / fps.num,
|
|
4397
|
+
activeTransition: transitionAtFrame(transitionRanges, frame)
|
|
4398
|
+
});
|
|
4399
|
+
}
|
|
4400
|
+
}
|
|
4385
4401
|
|
|
4386
4402
|
// src/services/render/segmentPlan.ts
|
|
4387
4403
|
import { join as join9 } from "node:path";
|
|
@@ -6039,10 +6055,15 @@ function estimateMeasuredCaptureCostMultiplier(samples) {
|
|
|
6039
6055
|
function shouldCalibrateSoftwareGpu(requestedMode, resolvedMode, hardware) {
|
|
6040
6056
|
return requestedMode === "auto" && resolvedMode === "hardware" && hardware !== void 0 && hardware.multiplier > 1 && hardware.p95Ms !== void 0;
|
|
6041
6057
|
}
|
|
6042
|
-
function
|
|
6043
|
-
if (hardware
|
|
6058
|
+
function settleAutoGpuChoice(hardware, software) {
|
|
6059
|
+
if (hardware?.p95Ms === void 0) return void 0;
|
|
6060
|
+
if (hardware.multiplier <= 1) return "hardware";
|
|
6061
|
+
if (software?.p95Ms === void 0) return void 0;
|
|
6044
6062
|
return software.p95Ms < hardware.p95Ms ? "software" : "hardware";
|
|
6045
6063
|
}
|
|
6064
|
+
function pickAutoGpuModeFromCalibration(hardware, software) {
|
|
6065
|
+
return settleAutoGpuChoice(hardware, software) ?? "hardware";
|
|
6066
|
+
}
|
|
6046
6067
|
function selectCaptureCalibrationFrames(totalFrames) {
|
|
6047
6068
|
if (totalFrames <= 0) return [];
|
|
6048
6069
|
const lastFrame = totalFrames - 1;
|
|
@@ -6057,8 +6078,8 @@ function selectCaptureCalibrationFrames(totalFrames) {
|
|
|
6057
6078
|
new Set(candidates.map((frame) => Math.max(0, Math.min(lastFrame, frame))))
|
|
6058
6079
|
).sort((a, b) => a - b);
|
|
6059
6080
|
}
|
|
6060
|
-
async function measureCaptureCostFromSession(session, totalFrames, fps, log) {
|
|
6061
|
-
const sampledFrames = selectCaptureCalibrationFrames(totalFrames);
|
|
6081
|
+
async function measureCaptureCostFromSession(session, totalFrames, fps, log, firstFrame = 0) {
|
|
6082
|
+
const sampledFrames = selectCaptureCalibrationFrames(totalFrames).map((i) => firstFrame + i);
|
|
6062
6083
|
const samples = [];
|
|
6063
6084
|
const totalSamples = sampledFrames.length;
|
|
6064
6085
|
const savedStaticFrames = session.staticFrames;
|
|
@@ -6154,7 +6175,13 @@ async function runCaptureCalibration(input) {
|
|
|
6154
6175
|
}
|
|
6155
6176
|
assertNotAborted();
|
|
6156
6177
|
log.info("Calibration session ready, capturing test frames...");
|
|
6157
|
-
const result = await measureCaptureCostFromSession(
|
|
6178
|
+
const result = await measureCaptureCostFromSession(
|
|
6179
|
+
session,
|
|
6180
|
+
totalFrames,
|
|
6181
|
+
fps,
|
|
6182
|
+
log,
|
|
6183
|
+
job.frameWindow?.startFrame
|
|
6184
|
+
);
|
|
6158
6185
|
logCaptureCalibrationResult(result, log);
|
|
6159
6186
|
return result;
|
|
6160
6187
|
};
|
|
@@ -6715,6 +6742,57 @@ function resolveVideoCaptureBeyondViewport(videoCount) {
|
|
|
6715
6742
|
return true;
|
|
6716
6743
|
}
|
|
6717
6744
|
|
|
6745
|
+
// src/services/render/gpuChoice.ts
|
|
6746
|
+
import { mkdirSync as mkdirSync7, readFileSync as readFileSync5, renameSync, writeFileSync as writeFileSync3 } from "node:fs";
|
|
6747
|
+
import { dirname as dirname6 } from "node:path";
|
|
6748
|
+
function gpuChoiceStore(cfg, gpu) {
|
|
6749
|
+
if (!cfg.gpuChoiceFile || !cfg.hyperframesVersion || !gpu) return void 0;
|
|
6750
|
+
return { file: cfg.gpuChoiceFile, key: `${cfg.hyperframesVersion} | ${gpu}` };
|
|
6751
|
+
}
|
|
6752
|
+
function readGpuChoice(store) {
|
|
6753
|
+
let record;
|
|
6754
|
+
try {
|
|
6755
|
+
record = JSON.parse(readFileSync5(store.file, "utf8"));
|
|
6756
|
+
} catch {
|
|
6757
|
+
return void 0;
|
|
6758
|
+
}
|
|
6759
|
+
if (record?.key !== store.key) return void 0;
|
|
6760
|
+
return record.mode === "software" || record.mode === "hardware" ? record.mode : void 0;
|
|
6761
|
+
}
|
|
6762
|
+
function writeGpuChoice(store, mode, measured) {
|
|
6763
|
+
mkdirSync7(dirname6(store.file), { recursive: true });
|
|
6764
|
+
const temp = `${store.file}.${process.pid}.tmp`;
|
|
6765
|
+
const record = { key: store.key, mode, ...measured, measuredAt: (/* @__PURE__ */ new Date()).toISOString() };
|
|
6766
|
+
writeFileSync3(temp, `${JSON.stringify(record, null, 2)}
|
|
6767
|
+
`);
|
|
6768
|
+
renameSync(temp, store.file);
|
|
6769
|
+
}
|
|
6770
|
+
|
|
6771
|
+
// src/services/render/frameWindow.ts
|
|
6772
|
+
function resolveFrameWindow(range, fps, filmFrames) {
|
|
6773
|
+
const frameAt = (seconds) => Math.round(seconds * fps.num / fps.den);
|
|
6774
|
+
const startFrame = frameAt(range.startSeconds);
|
|
6775
|
+
const endFrame = Math.min(
|
|
6776
|
+
range.endSeconds === void 0 ? filmFrames : frameAt(range.endSeconds),
|
|
6777
|
+
filmFrames
|
|
6778
|
+
);
|
|
6779
|
+
if (!(endFrame > startFrame)) {
|
|
6780
|
+
throw new Error(
|
|
6781
|
+
`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.`
|
|
6782
|
+
);
|
|
6783
|
+
}
|
|
6784
|
+
return { startFrame, endFrame };
|
|
6785
|
+
}
|
|
6786
|
+
function windowStartFrame(frameWindow) {
|
|
6787
|
+
return frameWindow?.startFrame ?? 0;
|
|
6788
|
+
}
|
|
6789
|
+
function assertRangeSupported(frameWindow, route) {
|
|
6790
|
+
if (!frameWindow || route === "sdr_disk" || route === "hdr_layered") return;
|
|
6791
|
+
throw new Error(
|
|
6792
|
+
`This composition renders on the "${route}" capture route, which renders the whole film only; render it without a start or end.`
|
|
6793
|
+
);
|
|
6794
|
+
}
|
|
6795
|
+
|
|
6718
6796
|
// src/services/render/observability.ts
|
|
6719
6797
|
import { createHash as createHash3 } from "node:crypto";
|
|
6720
6798
|
import { redactTelemetryString } from "@hyperframes/core";
|
|
@@ -7086,7 +7164,7 @@ function emitFallbackCaptureProfile(recorder, perfSummaries, env = process.env)
|
|
|
7086
7164
|
}
|
|
7087
7165
|
|
|
7088
7166
|
// src/services/render/videoFrameCoverage.ts
|
|
7089
|
-
import { parseHTML } from "linkedom";
|
|
7167
|
+
import { parseHTML } from "@hyperframes/parsers/linkedom";
|
|
7090
7168
|
import {
|
|
7091
7169
|
fpsToNumber as fpsToNumber5,
|
|
7092
7170
|
normalizeRateSpec,
|
|
@@ -7101,7 +7179,6 @@ var SHORT_CLIP_ONE_FRAME_TOLERANCE_MIN_EXPECTED_FRAMES = 14;
|
|
|
7101
7179
|
var SHORT_CLIP_ONE_FRAME_TOLERANCE_MAX_EXPECTED_FRAMES = 20;
|
|
7102
7180
|
var VideoFrameCoverageError = class extends Error {
|
|
7103
7181
|
// Read structurally by isVideoFrameCoverageError and cross-module callers.
|
|
7104
|
-
// fallow-ignore-next-line unused-class-member
|
|
7105
7182
|
hyperframesVideoFrameCoverageError = true;
|
|
7106
7183
|
threshold;
|
|
7107
7184
|
worst;
|
|
@@ -7188,7 +7265,7 @@ function countAuthoredTimedClips(html) {
|
|
|
7188
7265
|
}
|
|
7189
7266
|
|
|
7190
7267
|
// src/services/render/stages/compileStage.ts
|
|
7191
|
-
import { existsSync as existsSync13, writeFileSync as
|
|
7268
|
+
import { existsSync as existsSync13, writeFileSync as writeFileSync5 } from "node:fs";
|
|
7192
7269
|
import { join as join23, relative as relative5 } from "node:path";
|
|
7193
7270
|
import { privateCacheRoot } from "@hyperframes/engine";
|
|
7194
7271
|
import { suggestMatchingPreset } from "@hyperframes/core";
|
|
@@ -7198,7 +7275,7 @@ import { assertCompositionFileSize as assertCompositionFileSize2 } from "@hyperf
|
|
|
7198
7275
|
|
|
7199
7276
|
// src/services/compileInWorker.ts
|
|
7200
7277
|
import { existsSync as existsSync12, rmSync as rmSync11 } from "node:fs";
|
|
7201
|
-
import { dirname as
|
|
7278
|
+
import { dirname as dirname11, isAbsolute as isAbsolute4, join as join22, relative as relative4, resolve as resolvePath } from "node:path";
|
|
7202
7279
|
import { fileURLToPath as fileURLToPath3 } from "node:url";
|
|
7203
7280
|
import { Worker } from "node:worker_threads";
|
|
7204
7281
|
|
|
@@ -7218,17 +7295,17 @@ import {
|
|
|
7218
7295
|
stylesheetLinkMatches
|
|
7219
7296
|
} from "@hyperframes/parsers/css-url-scans";
|
|
7220
7297
|
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";
|
|
7298
|
+
import { createReadStream as createReadStream3, existsSync as existsSync11, mkdirSync as mkdirSync10, readFileSync as readFileSync9, statSync as statSync8 } from "fs";
|
|
7299
|
+
import { join as join21, dirname as dirname10, resolve as resolve8, basename as basename6, relative as relative3, sep as sep4 } from "path";
|
|
7300
|
+
import { parseHTML as parseHTML5 } from "@hyperframes/parsers/linkedom";
|
|
7224
7301
|
|
|
7225
7302
|
// src/services/bundledScripts.ts
|
|
7226
|
-
import { existsSync as existsSync8, readFileSync as
|
|
7303
|
+
import { existsSync as existsSync8, readFileSync as readFileSync6 } from "node:fs";
|
|
7227
7304
|
import { join as join17 } from "node:path";
|
|
7228
7305
|
import { GSAP_CDN_VERSION } from "@hyperframes/core/gsap-cdn";
|
|
7229
7306
|
var GSAP_VENDOR_DIR_ENV = "HYPERFRAMES_GSAP_VENDOR_DIR";
|
|
7230
7307
|
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) ?
|
|
7308
|
+
var read = (file) => existsSync8(file) ? readFileSync6(file) : null;
|
|
7232
7309
|
function bundledScript(url) {
|
|
7233
7310
|
const dir = process.env[GSAP_VENDOR_DIR_ENV];
|
|
7234
7311
|
const [, version, file] = DEFAULT_CDN_GSAP_3.exec(url) ?? [];
|
|
@@ -7302,7 +7379,7 @@ import {
|
|
|
7302
7379
|
readTextFile,
|
|
7303
7380
|
resolveCompositionSrc
|
|
7304
7381
|
} from "@hyperframes/parsers/asset-resolution";
|
|
7305
|
-
import { isPrivateFileUnder as
|
|
7382
|
+
import { isPrivateFileUnder as isPrivateFileUnder3, isStudioPrivatePath as isStudioPrivatePath3 } from "@hyperframes/core/safe-path";
|
|
7306
7383
|
import { linksOutside as linksOutside2 } from "@hyperframes/studio-server/outside-file";
|
|
7307
7384
|
import {
|
|
7308
7385
|
assertCompositionFileSize,
|
|
@@ -7313,7 +7390,7 @@ import {
|
|
|
7313
7390
|
} from "@hyperframes/core/compiler";
|
|
7314
7391
|
|
|
7315
7392
|
// src/services/renderMediaCollector.ts
|
|
7316
|
-
import { parseHTML as parseHTML2 } from "linkedom";
|
|
7393
|
+
import { parseHTML as parseHTML2 } from "@hyperframes/parsers/linkedom";
|
|
7317
7394
|
import {
|
|
7318
7395
|
MEDIA_RENDER_ID_ATTR,
|
|
7319
7396
|
normalizeRateSpec as normalizeRateSpec2,
|
|
@@ -7505,9 +7582,9 @@ import {
|
|
|
7505
7582
|
|
|
7506
7583
|
// src/services/animatedGifPrep.ts
|
|
7507
7584
|
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";
|
|
7585
|
+
import { copyFileSync as copyFileSync2, existsSync as existsSync9, mkdirSync as mkdirSync8, readFileSync as readFileSync7, rmSync as rmSync9, statSync as statSync6 } from "node:fs";
|
|
7586
|
+
import { dirname as dirname7, isAbsolute as isAbsolute3, join as join18, resolve as resolve6 } from "node:path";
|
|
7587
|
+
import { parseHTML as parseHTML3 } from "@hyperframes/parsers/linkedom";
|
|
7511
7588
|
import { parseAnimatedGifMetadata } from "@hyperframes/core";
|
|
7512
7589
|
import {
|
|
7513
7590
|
DEFAULT_VP9_CPU_USED,
|
|
@@ -7559,7 +7636,11 @@ function resolveLocalImageSourcePath(src, options) {
|
|
|
7559
7636
|
resolve6(options.downloadDir, normalizedBase)
|
|
7560
7637
|
];
|
|
7561
7638
|
const assetRoot = options.allowOutsideFiles ? void 0 : options.projectDir;
|
|
7562
|
-
const allowed = (candidate) => !namesAnotherNetworkRoot(options.projectDir, candidate) && !isPrivateUnderAssetRoots(
|
|
7639
|
+
const allowed = (candidate) => !namesAnotherNetworkRoot(options.projectDir, candidate) && !isPrivateUnderAssetRoots(
|
|
7640
|
+
candidate,
|
|
7641
|
+
[options.projectDir, options.downloadDir],
|
|
7642
|
+
options.allowOutsideFiles
|
|
7643
|
+
) && (!escapesAssetRoot(candidate, assetRoot) && outsideAssetRefusal(options.projectDir, candidate) !== "blocklisted" || !escapesAssetRoot(candidate, options.downloadDir));
|
|
7563
7644
|
return candidates.find((candidate) => allowed(candidate) && existsSync9(candidate)) ?? null;
|
|
7564
7645
|
}
|
|
7565
7646
|
function isUsableFile(path) {
|
|
@@ -7688,11 +7769,11 @@ async function runAnimatedGifTranscode(request) {
|
|
|
7688
7769
|
throw result.error ?? new Error(`Animated GIF transcode failed (${result.exitCode}): ${result.stderr.slice(-500)}`);
|
|
7689
7770
|
}
|
|
7690
7771
|
async function ensurePreparedWebm(input) {
|
|
7691
|
-
if (!existsSync9(
|
|
7692
|
-
|
|
7772
|
+
if (!existsSync9(dirname7(input.cachePath))) {
|
|
7773
|
+
mkdirSync8(dirname7(input.cachePath), { recursive: true });
|
|
7693
7774
|
}
|
|
7694
|
-
if (!existsSync9(
|
|
7695
|
-
|
|
7775
|
+
if (!existsSync9(dirname7(input.outputPath))) {
|
|
7776
|
+
mkdirSync8(dirname7(input.outputPath), { recursive: true });
|
|
7696
7777
|
}
|
|
7697
7778
|
if (!isUsableFile(input.cachePath)) {
|
|
7698
7779
|
const tmpPath = `${input.cachePath}.tmp-${process.pid}-${randomUUID()}`;
|
|
@@ -7793,7 +7874,7 @@ async function prepareAnimatedGifInputs(html, options) {
|
|
|
7793
7874
|
if (!hasGifExtension(src)) continue;
|
|
7794
7875
|
const sourcePath = resolveLocalImageSourcePath(src, options);
|
|
7795
7876
|
if (!sourcePath) continue;
|
|
7796
|
-
const bytes =
|
|
7877
|
+
const bytes = readFileSync7(sourcePath);
|
|
7797
7878
|
const metadata = parseAnimatedGifMetadata(bytes);
|
|
7798
7879
|
if (!metadata?.animated) continue;
|
|
7799
7880
|
const loopOverride = readLoopOverride(img);
|
|
@@ -7845,16 +7926,16 @@ import { createHash as createHash5, randomUUID as randomUUID2 } from "node:crypt
|
|
|
7845
7926
|
import {
|
|
7846
7927
|
closeSync as closeSync5,
|
|
7847
7928
|
copyFileSync as copyFileSync3,
|
|
7848
|
-
mkdirSync as
|
|
7929
|
+
mkdirSync as mkdirSync9,
|
|
7849
7930
|
openSync as openSync5,
|
|
7850
|
-
readFileSync as
|
|
7931
|
+
readFileSync as readFileSync8,
|
|
7851
7932
|
readSync as readSync3,
|
|
7852
7933
|
rmSync as rmSync10,
|
|
7853
7934
|
statSync as statSync7,
|
|
7854
|
-
writeFileSync as
|
|
7935
|
+
writeFileSync as writeFileSync4
|
|
7855
7936
|
} from "node:fs";
|
|
7856
|
-
import { dirname as
|
|
7857
|
-
import { parseHTML as parseHTML4 } from "linkedom";
|
|
7937
|
+
import { dirname as dirname8, join as join19, resolve as resolve7 } from "node:path";
|
|
7938
|
+
import { parseHTML as parseHTML4 } from "@hyperframes/parsers/linkedom";
|
|
7858
7939
|
import { renameWithRetry as renameWithRetry3, runFfmpeg as runFfmpeg3, runFfprobe, urlInputArgs as urlInputArgs3 } from "@hyperframes/engine";
|
|
7859
7940
|
|
|
7860
7941
|
// src/services/heifRotation.ts
|
|
@@ -8038,7 +8119,7 @@ function primaryGrid(probed) {
|
|
|
8038
8119
|
async function convertHeifToJpeg(request) {
|
|
8039
8120
|
const probed = await probeJson(request.inputPath, true);
|
|
8040
8121
|
const grid = primaryGrid(probed);
|
|
8041
|
-
const rotation = readHeifPrimaryRotation(
|
|
8122
|
+
const rotation = readHeifPrimaryRotation(readFileSync8(request.inputPath));
|
|
8042
8123
|
const filters = [];
|
|
8043
8124
|
let inputs = [];
|
|
8044
8125
|
let size = probed.streams?.[0];
|
|
@@ -8102,7 +8183,7 @@ function resolveImageSource(src, options) {
|
|
|
8102
8183
|
const path = resolveLocalImageSourcePath(src, options);
|
|
8103
8184
|
const head = path ? readHead(path) : null;
|
|
8104
8185
|
if (!path || !head || !isHeifBytes(head)) return null;
|
|
8105
|
-
return { path, bytes:
|
|
8186
|
+
return { path, bytes: readFileSync8(path), label: `"${splitUrlSuffix(src).basePath}"` };
|
|
8106
8187
|
}
|
|
8107
8188
|
function isUsableFile2(path) {
|
|
8108
8189
|
try {
|
|
@@ -8112,14 +8193,14 @@ function isUsableFile2(path) {
|
|
|
8112
8193
|
}
|
|
8113
8194
|
}
|
|
8114
8195
|
async function ensurePreparedJpeg(source, cachePath, outputPath, options) {
|
|
8115
|
-
|
|
8116
|
-
|
|
8196
|
+
mkdirSync9(dirname8(cachePath), { recursive: true });
|
|
8197
|
+
mkdirSync9(dirname8(outputPath), { recursive: true });
|
|
8117
8198
|
if (!isUsableFile2(cachePath)) {
|
|
8118
8199
|
const tmpPath = `${cachePath}.tmp-${process.pid}-${randomUUID2()}`;
|
|
8119
8200
|
const inlinePath = `${tmpPath}.heic`;
|
|
8120
8201
|
const inputPath = source.path ?? inlinePath;
|
|
8121
8202
|
try {
|
|
8122
|
-
if (!source.path)
|
|
8203
|
+
if (!source.path) writeFileSync4(inlinePath, source.bytes);
|
|
8123
8204
|
await (options.transcode ?? convertHeifToJpeg)({
|
|
8124
8205
|
inputPath,
|
|
8125
8206
|
outputPath: tmpPath,
|
|
@@ -8192,7 +8273,7 @@ import { getPositionEditsRenderScript } from "@hyperframes/core/runtime/position
|
|
|
8192
8273
|
|
|
8193
8274
|
// src/services/assetMediaType.ts
|
|
8194
8275
|
import { existsSync as existsSync10 } from "node:fs";
|
|
8195
|
-
import { dirname as
|
|
8276
|
+
import { dirname as dirname9, join as join20 } from "node:path";
|
|
8196
8277
|
import {
|
|
8197
8278
|
fingerprintElementId,
|
|
8198
8279
|
isHttpUrl as isHttpUrl2,
|
|
@@ -8246,7 +8327,7 @@ function assertAssetMediaTypeProfile(expected, profile, elementIdentity) {
|
|
|
8246
8327
|
]);
|
|
8247
8328
|
}
|
|
8248
8329
|
function mediaAssetRoots(projectDir, compiledDir) {
|
|
8249
|
-
return [projectDir, compiledDir, join20(
|
|
8330
|
+
return [projectDir, compiledDir, join20(dirname9(compiledDir), "downloads")];
|
|
8250
8331
|
}
|
|
8251
8332
|
function dropMediaOutsideProject(input) {
|
|
8252
8333
|
const { projectDir, workDir, composition, log } = input;
|
|
@@ -8255,7 +8336,7 @@ function dropMediaOutsideProject(input) {
|
|
|
8255
8336
|
const staysInside = ({ id, src }) => {
|
|
8256
8337
|
if (!src || isHttpUrl2(src)) return true;
|
|
8257
8338
|
const path = resolveProjectRelativeSrc3(src, projectDir, compiledDir);
|
|
8258
|
-
if (isPrivateUnderAssetRoots2(path, roots)) {
|
|
8339
|
+
if (isPrivateUnderAssetRoots2(path, roots, input.allowOutsideProjectAssets)) {
|
|
8259
8340
|
log.warn(`[Render] Media "${id}" source is missing: it is a private project file`, { src });
|
|
8260
8341
|
return false;
|
|
8261
8342
|
}
|
|
@@ -8425,7 +8506,7 @@ function assertOutsideMarkupAsked(projectDir, filePath, srcPath, assetRoot, outs
|
|
|
8425
8506
|
throw new EmptyCompositionError([{ srcPath, detail: OUTSIDE_COMPOSITION_NEEDS_FLAG }]);
|
|
8426
8507
|
}
|
|
8427
8508
|
}
|
|
8428
|
-
var isPrivateCompositionFile = (projectDir, filePath) =>
|
|
8509
|
+
var isPrivateCompositionFile = (projectDir, filePath) => isPrivateFileUnder3(projectDir, filePath, isStudioPrivatePath3);
|
|
8429
8510
|
function compositionSrcsIn(html) {
|
|
8430
8511
|
const { document: document2 } = parseHTML5(html);
|
|
8431
8512
|
const mounts = [];
|
|
@@ -8751,7 +8832,7 @@ async function resolveMediaDuration(src, mediaStart, playbackRate, projectDir, b
|
|
|
8751
8832
|
let filePath = src;
|
|
8752
8833
|
if (isHttpUrl(src)) {
|
|
8753
8834
|
const remoteDir = join21(downloadDir, REMOTE_MEDIA_SUBDIR);
|
|
8754
|
-
if (!existsSync11(remoteDir))
|
|
8835
|
+
if (!existsSync11(remoteDir)) mkdirSync10(remoteDir, { recursive: true });
|
|
8755
8836
|
run?.assets.reserve([src]);
|
|
8756
8837
|
try {
|
|
8757
8838
|
filePath = await downloadAsset(src, remoteDir, run?.assets);
|
|
@@ -8762,7 +8843,7 @@ async function resolveMediaDuration(src, mediaStart, playbackRate, projectDir, b
|
|
|
8762
8843
|
} else {
|
|
8763
8844
|
filePath = decodedUrlPath(src);
|
|
8764
8845
|
if (!filePath.startsWith("/")) filePath = join21(baseDir, filePath);
|
|
8765
|
-
if (escapesAssetRoot(filePath, assetRoot) || isPrivateUnderAssetRoots3(filePath, [projectDir, downloadDir])) {
|
|
8846
|
+
if (escapesAssetRoot(filePath, assetRoot) || isPrivateUnderAssetRoots3(filePath, [projectDir, downloadDir], assetRoot === void 0)) {
|
|
8766
8847
|
return { duration: null, resolvedPath: filePath };
|
|
8767
8848
|
}
|
|
8768
8849
|
filePath = urlByAbsentLocalPath?.get(filePath) ?? filePath;
|
|
@@ -8945,7 +9026,7 @@ async function parseSubCompositions(html, projectDir, downloadDir, visited = /*
|
|
|
8945
9026
|
const { html: compiledSub } = await compileHtmlFile(
|
|
8946
9027
|
rewriteUnresolvableGsapToCdn(item.rawSubHtml, projectDir, item.srcPath),
|
|
8947
9028
|
projectDir,
|
|
8948
|
-
|
|
9029
|
+
dirname10(item.filePath),
|
|
8949
9030
|
downloadDir,
|
|
8950
9031
|
void 0,
|
|
8951
9032
|
urlByAbsentLocalPath,
|
|
@@ -9518,7 +9599,7 @@ var REMOTE_MEDIA_SUBDIR = "_remote_media";
|
|
|
9518
9599
|
async function downloadAndRewriteUrls(urlSet, html, remoteDir, warnLabel, logLabel, assets, extraRewrite) {
|
|
9519
9600
|
assets?.reserve(urlSet);
|
|
9520
9601
|
if (urlSet.size === 0) return { html, remoteMediaAssets: /* @__PURE__ */ new Map() };
|
|
9521
|
-
if (!existsSync11(remoteDir))
|
|
9602
|
+
if (!existsSync11(remoteDir)) mkdirSync10(remoteDir, { recursive: true });
|
|
9522
9603
|
const urlToLocal = /* @__PURE__ */ new Map();
|
|
9523
9604
|
await Promise.all(
|
|
9524
9605
|
[...urlSet].map(async (url) => {
|
|
@@ -9715,11 +9796,11 @@ function projectStylesheetFontFamilies(html, projectDir) {
|
|
|
9715
9796
|
if (!href || /^(?:[a-z][a-z\d+.-]*:|\/\/)/i.test(href)) continue;
|
|
9716
9797
|
const sheet = resolve8(projectDir, decodedUrlPath(href).replace(/^(?:\.?\/)+/, ""));
|
|
9717
9798
|
if (!isPathInside(sheet, projectDir) || !existsSync11(sheet)) continue;
|
|
9718
|
-
for (const face of extractFontFaceBlocks(
|
|
9799
|
+
for (const face of extractFontFaceBlocks(readFileSync9(sheet, "utf8"))) {
|
|
9719
9800
|
const family = /font-family\s*:\s*([^;}]+)/i.exec(face)?.[1]?.trim().replace(/^['"]|['"]$/g, "");
|
|
9720
9801
|
const shipsFile = [...localFontFaceUrlMatches(face)].some(({ parts: [, url = ""] }) => {
|
|
9721
9802
|
const path = decodedUrlPath(url);
|
|
9722
|
-
const file = path.startsWith("/") ? resolve8(projectDir, `.${path}`) : resolve8(
|
|
9803
|
+
const file = path.startsWith("/") ? resolve8(projectDir, `.${path}`) : resolve8(dirname10(sheet), path);
|
|
9723
9804
|
return isPathInside(file, projectDir) && existsSync11(file);
|
|
9724
9805
|
});
|
|
9725
9806
|
if (family && shipsFile) families.push(family);
|
|
@@ -10162,7 +10243,7 @@ async function compileWithAssets(projectDir, htmlPath, downloadDir, options, ass
|
|
|
10162
10243
|
for (const video of videos) {
|
|
10163
10244
|
if (isHttpUrl(video.src)) continue;
|
|
10164
10245
|
const videoPath = resolve8(projectDir, video.src);
|
|
10165
|
-
if (advised.has(videoPath) || namesAnotherNetworkRoot2(projectDir, videoPath) || !existsSync11(videoPath) || escapesAssetRoot(videoPath, assetRoot) || isPrivateUnderAssetRoots3(videoPath, [projectDir, downloadDir]))
|
|
10246
|
+
if (advised.has(videoPath) || namesAnotherNetworkRoot2(projectDir, videoPath) || !existsSync11(videoPath) || escapesAssetRoot(videoPath, assetRoot) || isPrivateUnderAssetRoots3(videoPath, [projectDir, downloadDir], assetRoot === void 0))
|
|
10166
10247
|
continue;
|
|
10167
10248
|
advised.add(videoPath);
|
|
10168
10249
|
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 +10709,7 @@ function resolveCompileWorkerEntry(explicit, log) {
|
|
|
10628
10709
|
}
|
|
10629
10710
|
return void 0;
|
|
10630
10711
|
}
|
|
10631
|
-
const sibling = join22(
|
|
10712
|
+
const sibling = join22(dirname11(fileURLToPath3(import.meta.url)), "compileWorker.js");
|
|
10632
10713
|
return existsSync12(sibling) ? sibling : void 0;
|
|
10633
10714
|
}
|
|
10634
10715
|
function rebuildError({ name, message, stack, props }) {
|
|
@@ -10780,7 +10861,7 @@ function resolveEntryHtmlPath(input) {
|
|
|
10780
10861
|
);
|
|
10781
10862
|
}
|
|
10782
10863
|
const wrapperPath = join23(workDir, "standalone-entry.html");
|
|
10783
|
-
|
|
10864
|
+
writeFileSync5(wrapperPath, standaloneHtml, "utf-8");
|
|
10784
10865
|
log.info("Extracted standalone entry from index.html host context", { entryFile });
|
|
10785
10866
|
return wrapperPath;
|
|
10786
10867
|
}
|
|
@@ -10938,7 +11019,7 @@ async function runCompileStage(input) {
|
|
|
10938
11019
|
// src/services/render/stages/probeStage.ts
|
|
10939
11020
|
import { createHash as createHash7 } from "node:crypto";
|
|
10940
11021
|
import { basename as basename7, join as join24 } from "node:path";
|
|
10941
|
-
import { parseHTML as parseHTML6 } from "linkedom";
|
|
11022
|
+
import { parseHTML as parseHTML6 } from "@hyperframes/parsers/linkedom";
|
|
10942
11023
|
import {
|
|
10943
11024
|
closeCaptureSession as closeCaptureSession4,
|
|
10944
11025
|
compositionRequiresWebGpu,
|
|
@@ -12408,7 +12489,7 @@ import {
|
|
|
12408
12489
|
|
|
12409
12490
|
// src/services/render/audioDeliveryLimit.ts
|
|
12410
12491
|
import { existsSync as existsSync16 } from "node:fs";
|
|
12411
|
-
import { dirname as
|
|
12492
|
+
import { dirname as dirname13, join as join27 } from "node:path";
|
|
12412
12493
|
import {
|
|
12413
12494
|
applyAudioFxChain,
|
|
12414
12495
|
describeFfmpegFailure as describeFfmpegFailure3,
|
|
@@ -12419,7 +12500,7 @@ import {
|
|
|
12419
12500
|
// src/services/render/audioPadTrim.ts
|
|
12420
12501
|
import { localContainerInputArgs } from "@hyperframes/parsers/ff-binaries";
|
|
12421
12502
|
import { spawn } from "node:child_process";
|
|
12422
|
-
import { dirname as
|
|
12503
|
+
import { dirname as dirname12, join as join26 } from "node:path";
|
|
12423
12504
|
import {
|
|
12424
12505
|
DEFAULT_CONFIG,
|
|
12425
12506
|
describeFfmpegFailure as describeFfmpegFailure2,
|
|
@@ -12714,7 +12795,7 @@ async function cutSource(input, scratchDir, attenuationDb) {
|
|
|
12714
12795
|
async function enforceAacTruePeak(input) {
|
|
12715
12796
|
let scratchDir;
|
|
12716
12797
|
try {
|
|
12717
|
-
scratchDir = createStagingDir3(
|
|
12798
|
+
scratchDir = createStagingDir3(dirname12(input.audioPath), ".true-peak-");
|
|
12718
12799
|
const correctedPath = join26(scratchDir, "audio.m4a");
|
|
12719
12800
|
const measurements = [];
|
|
12720
12801
|
let attenuationDb = 0;
|
|
@@ -12938,7 +13019,7 @@ async function limitDeliveryPeaks(input, deps = {
|
|
|
12938
13019
|
const peak = await deps.measure(audioPath, { timeoutMs, signal });
|
|
12939
13020
|
if (peak <= AAC_DELIVERY_TRUE_PEAK_DBFS) return { success: true };
|
|
12940
13021
|
const alternating = ["a", "b"].map(
|
|
12941
|
-
(k) => join27(
|
|
13022
|
+
(k) => join27(dirname13(sourcePath), `audio-source-limited-${k}.wav`)
|
|
12942
13023
|
);
|
|
12943
13024
|
let encodedFrom;
|
|
12944
13025
|
let ceiling = AAC_DELIVERY_TRUE_PEAK_DBFS;
|
|
@@ -13012,10 +13093,15 @@ function runAudioStage(input) {
|
|
|
13012
13093
|
async function runAudioStageScoped(input) {
|
|
13013
13094
|
const stageStart = Date.now();
|
|
13014
13095
|
const pcmSourcePath = join28(input.workDir, "audio-source.wav");
|
|
13015
|
-
const
|
|
13096
|
+
const seconds = (frames) => frames * input.fps.den / input.fps.num;
|
|
13097
|
+
const duration = seconds(input.totalFrames);
|
|
13098
|
+
const window2 = input.frameWindow && {
|
|
13099
|
+
startSeconds: seconds(input.frameWindow.startFrame),
|
|
13100
|
+
durationSeconds: seconds(input.frameWindow.endFrame - input.frameWindow.startFrame)
|
|
13101
|
+
};
|
|
13016
13102
|
let deliverySourcePath;
|
|
13017
13103
|
try {
|
|
13018
|
-
const result = await mixAudioForDelivery(input, duration, pcmSourcePath);
|
|
13104
|
+
const result = await mixAudioForDelivery(input, duration, pcmSourcePath, window2);
|
|
13019
13105
|
let audioLoweredDb;
|
|
13020
13106
|
if (result.hasAudio) {
|
|
13021
13107
|
const guardStart = Date.now();
|
|
@@ -13023,7 +13109,7 @@ async function runAudioStageScoped(input) {
|
|
|
13023
13109
|
input,
|
|
13024
13110
|
result.audioOutputPath,
|
|
13025
13111
|
pcmSourcePath,
|
|
13026
|
-
duration
|
|
13112
|
+
window2?.durationSeconds ?? duration
|
|
13027
13113
|
);
|
|
13028
13114
|
audioLoweredDb = guard.loweredDb;
|
|
13029
13115
|
input.log?.info("[audio] phases", { ...result.audioPhaseMs, guard: Date.now() - guardStart });
|
|
@@ -13061,7 +13147,7 @@ async function guardDeliveryPeaks(input, audioPath, sourcePath, duration) {
|
|
|
13061
13147
|
if (!peak.success) throw encoderFailureError("Audio true-peak check failed", peak);
|
|
13062
13148
|
return { loweredDb: peak.loweredDb, sourceStale: peak.sourceStale };
|
|
13063
13149
|
}
|
|
13064
|
-
async function mixAudioForDelivery(input, duration, pcmSourcePath) {
|
|
13150
|
+
async function mixAudioForDelivery(input, duration, pcmSourcePath, window2) {
|
|
13065
13151
|
const {
|
|
13066
13152
|
projectDir,
|
|
13067
13153
|
workDir,
|
|
@@ -13098,6 +13184,7 @@ async function mixAudioForDelivery(input, duration, pcmSourcePath) {
|
|
|
13098
13184
|
urlByAbsentLocalPath,
|
|
13099
13185
|
audioSidecarUrlByLocalPath,
|
|
13100
13186
|
keepEncoderInputAt: pcmSourcePath,
|
|
13187
|
+
window: window2,
|
|
13101
13188
|
assetRoots: input.allowOutsideProjectAssets ? void 0 : mediaAssetRoots(projectDir, compiledDir)
|
|
13102
13189
|
},
|
|
13103
13190
|
compiledDir
|
|
@@ -13505,7 +13592,7 @@ async function captureSessionFrames(session, { input, rangeStart, rangeEnd, resu
|
|
|
13505
13592
|
assertNotAborted();
|
|
13506
13593
|
const absoluteIdx = rangeStart + i;
|
|
13507
13594
|
const time = absoluteIdx * job.config.fps.den / job.config.fps.num;
|
|
13508
|
-
const { encodeResult } = await captureFrameToBufferPipelined2(session,
|
|
13595
|
+
const { encodeResult } = await captureFrameToBufferPipelined2(session, absoluteIdx, time);
|
|
13509
13596
|
await drainPrev();
|
|
13510
13597
|
prev = { fileIndex: i, encodeResult };
|
|
13511
13598
|
}
|
|
@@ -13515,7 +13602,7 @@ async function captureSessionFrames(session, { input, rangeStart, rangeEnd, resu
|
|
|
13515
13602
|
assertNotAborted();
|
|
13516
13603
|
const absoluteIdx = rangeStart + i;
|
|
13517
13604
|
const time = absoluteIdx * job.config.fps.den / job.config.fps.num;
|
|
13518
|
-
await captureFrame(session,
|
|
13605
|
+
await captureFrame(session, absoluteIdx, time, i);
|
|
13519
13606
|
reportFrame(i);
|
|
13520
13607
|
}
|
|
13521
13608
|
}
|
|
@@ -13534,7 +13621,7 @@ async function captureSessionFrames(session, { input, rangeStart, rangeEnd, resu
|
|
|
13534
13621
|
}
|
|
13535
13622
|
|
|
13536
13623
|
// src/services/render/stages/captureHdrStage.ts
|
|
13537
|
-
import { existsSync as existsSync20, mkdirSync as
|
|
13624
|
+
import { existsSync as existsSync20, mkdirSync as mkdirSync11 } from "node:fs";
|
|
13538
13625
|
import { join as join33 } from "node:path";
|
|
13539
13626
|
import {
|
|
13540
13627
|
closeCaptureSession as closeCaptureSession7,
|
|
@@ -13646,9 +13733,18 @@ async function runSequentialLayeredFrameLoop(input) {
|
|
|
13646
13733
|
output: Buffer.alloc(bufSize)
|
|
13647
13734
|
} : null;
|
|
13648
13735
|
const normalCanvas = Buffer.alloc(bufSize);
|
|
13736
|
+
const firstFrame = windowStartFrame(job.frameWindow);
|
|
13737
|
+
cleanupHdrVideosEndedBefore(firstFrame, job.config.fps, transitionRanges, {
|
|
13738
|
+
hdrVideoEndTimes,
|
|
13739
|
+
cleanedUpVideos,
|
|
13740
|
+
hdrVideoFrameSources,
|
|
13741
|
+
sceneElements,
|
|
13742
|
+
log
|
|
13743
|
+
});
|
|
13649
13744
|
for (let i = 0; i < totalFrames; i++) {
|
|
13650
13745
|
assertNotAborted();
|
|
13651
|
-
const
|
|
13746
|
+
const frame = firstFrame + i;
|
|
13747
|
+
const time = frame * job.config.fps.den / job.config.fps.num;
|
|
13652
13748
|
if (hdrPerf) hdrPerf.frames += 1;
|
|
13653
13749
|
const stackingInfo = await seekInjectAndQueryStacking(
|
|
13654
13750
|
domSession.page,
|
|
@@ -13660,11 +13756,11 @@ async function runSequentialLayeredFrameLoop(input) {
|
|
|
13660
13756
|
"frameInjectMs",
|
|
13661
13757
|
"stackingQueryMs"
|
|
13662
13758
|
);
|
|
13663
|
-
const activeTransition = transitionRanges
|
|
13759
|
+
const activeTransition = transitionAtFrame(transitionRanges, frame);
|
|
13664
13760
|
if (i % 30 === 0 && (log.isLevelEnabled?.("debug") ?? true)) {
|
|
13665
13761
|
const hdrEl = stackingInfo.find((e) => e.isHdr);
|
|
13666
13762
|
log.debug("[Render] HDR layer composite frame", {
|
|
13667
|
-
frame
|
|
13763
|
+
frame,
|
|
13668
13764
|
time: time.toFixed(2),
|
|
13669
13765
|
hdrElement: hdrEl ? { z: hdrEl.zIndex, visible: hdrEl.visible, width: hdrEl.width } : null,
|
|
13670
13766
|
stackingCount: stackingInfo.length,
|
|
@@ -13674,7 +13770,7 @@ async function runSequentialLayeredFrameLoop(input) {
|
|
|
13674
13770
|
if (activeTransition && transitionBuffers) {
|
|
13675
13771
|
if (hdrPerf) hdrPerf.transitionFrames += 1;
|
|
13676
13772
|
const transitionTimingStart = Date.now();
|
|
13677
|
-
const progress = activeTransition.endFrame === activeTransition.startFrame ? 1 : (
|
|
13773
|
+
const progress = activeTransition.endFrame === activeTransition.startFrame ? 1 : (frame - activeTransition.startFrame) / (activeTransition.endFrame - activeTransition.startFrame);
|
|
13678
13774
|
const sceneAIds = new Set(sceneElements[activeTransition.fromScene] ?? []);
|
|
13679
13775
|
const sceneBIds = new Set(sceneElements[activeTransition.toScene] ?? []);
|
|
13680
13776
|
timeHdrPhase(hdrPerf, "canvasClearMs", () => {
|
|
@@ -13703,7 +13799,7 @@ async function runSequentialLayeredFrameLoop(input) {
|
|
|
13703
13799
|
hdrTargetTransfer,
|
|
13704
13800
|
hdrPerf,
|
|
13705
13801
|
log,
|
|
13706
|
-
frameIdx:
|
|
13802
|
+
frameIdx: frame
|
|
13707
13803
|
});
|
|
13708
13804
|
}
|
|
13709
13805
|
const shaderName = activeTransition.shader;
|
|
@@ -13728,7 +13824,7 @@ async function runSequentialLayeredFrameLoop(input) {
|
|
|
13728
13824
|
await timeHdrPhaseAsync(
|
|
13729
13825
|
hdrPerf,
|
|
13730
13826
|
"normalCompositeMs",
|
|
13731
|
-
() => compositeHdrFrame(hdrCompositeCtx, normalCanvas, time, stackingInfo, void 0,
|
|
13827
|
+
() => compositeHdrFrame(hdrCompositeCtx, normalCanvas, time, stackingInfo, void 0, frame)
|
|
13732
13828
|
);
|
|
13733
13829
|
if (debugDumpEnabled && debugDumpDir && i % 30 === 0) {
|
|
13734
13830
|
writeFileExclusiveSync(
|
|
@@ -13778,7 +13874,7 @@ import {
|
|
|
13778
13874
|
// src/services/shaderTransitionWorkerPool.ts
|
|
13779
13875
|
import { Worker as Worker2 } from "node:worker_threads";
|
|
13780
13876
|
import { fileURLToPath as fileURLToPath4, pathToFileURL } from "node:url";
|
|
13781
|
-
import { dirname as
|
|
13877
|
+
import { dirname as dirname14, join as join31 } from "node:path";
|
|
13782
13878
|
import { createRequire } from "node:module";
|
|
13783
13879
|
import { usableCpuCount } from "@hyperframes/engine";
|
|
13784
13880
|
import { existsSync as existsSync19 } from "node:fs";
|
|
@@ -13791,7 +13887,7 @@ function resolveWorkerEntry(explicit) {
|
|
|
13791
13887
|
const isTs = override.endsWith(".ts");
|
|
13792
13888
|
return { path: override, isTs };
|
|
13793
13889
|
}
|
|
13794
|
-
const moduleDir =
|
|
13890
|
+
const moduleDir = dirname14(fileURLToPath4(import.meta.url));
|
|
13795
13891
|
const jsPath = join31(moduleDir, "shaderTransitionWorker.js");
|
|
13796
13892
|
if (existsSync19(jsPath)) return { path: jsPath, isTs: false };
|
|
13797
13893
|
const tsPath = join31(moduleDir, "shaderTransitionWorker.ts");
|
|
@@ -13999,7 +14095,8 @@ async function runHybridLayeredFrameLoop(input) {
|
|
|
13999
14095
|
assertNotAborted,
|
|
14000
14096
|
onProgress
|
|
14001
14097
|
} = input;
|
|
14002
|
-
const
|
|
14098
|
+
const firstFrame = windowStartFrame(job.frameWindow);
|
|
14099
|
+
const transitionFramesSet = partitionTransitionFrames(transitionRanges, totalFrames, firstFrame);
|
|
14003
14100
|
const hasTransitions = transitionRanges.length > 0;
|
|
14004
14101
|
const bufSize = width * height * 6;
|
|
14005
14102
|
const workerSessions = [];
|
|
@@ -14090,8 +14187,9 @@ async function runHybridLayeredFrameLoop(input) {
|
|
|
14090
14187
|
for (let i = range.start; i < range.end; i++) {
|
|
14091
14188
|
throwIfFailed();
|
|
14092
14189
|
assertNotAborted();
|
|
14093
|
-
const
|
|
14094
|
-
const
|
|
14190
|
+
const frame = firstFrame + i;
|
|
14191
|
+
const time = frame * job.config.fps.den / job.config.fps.num;
|
|
14192
|
+
const activeTransition = transitionFramesSet.has(frame) ? transitionAtFrame(transitionRanges, frame) : void 0;
|
|
14095
14193
|
if (activeTransition && ring) {
|
|
14096
14194
|
const slot = nextRingIdx;
|
|
14097
14195
|
nextRingIdx = (nextRingIdx + 1) % TRANSITION_RING_DEPTH;
|
|
@@ -14102,7 +14200,7 @@ async function runHybridLayeredFrameLoop(input) {
|
|
|
14102
14200
|
if (!buffers) continue;
|
|
14103
14201
|
await captureTransitionFrameOnWorker({
|
|
14104
14202
|
session,
|
|
14105
|
-
frameIdx:
|
|
14203
|
+
frameIdx: frame,
|
|
14106
14204
|
time,
|
|
14107
14205
|
transition: activeTransition,
|
|
14108
14206
|
buffers,
|
|
@@ -14117,7 +14215,7 @@ async function runHybridLayeredFrameLoop(input) {
|
|
|
14117
14215
|
hdrPerf,
|
|
14118
14216
|
log
|
|
14119
14217
|
});
|
|
14120
|
-
const progress = activeTransition.endFrame === activeTransition.startFrame ? 1 : (
|
|
14218
|
+
const progress = activeTransition.endFrame === activeTransition.startFrame ? 1 : (frame - activeTransition.startFrame) / (activeTransition.endFrame - activeTransition.startFrame);
|
|
14121
14219
|
const frameIdx = i;
|
|
14122
14220
|
const shaderName = activeTransition.shader;
|
|
14123
14221
|
const dispatch = (async () => {
|
|
@@ -14168,7 +14266,7 @@ async function runHybridLayeredFrameLoop(input) {
|
|
|
14168
14266
|
await timeHdrPhaseAsync(
|
|
14169
14267
|
hdrPerf,
|
|
14170
14268
|
"normalCompositeMs",
|
|
14171
|
-
() => compositeHdrFrame(wctx, canvas, time, stackingInfo, void 0,
|
|
14269
|
+
() => compositeHdrFrame(wctx, canvas, time, stackingInfo, void 0, frame)
|
|
14172
14270
|
);
|
|
14173
14271
|
if (debugDumpEnabled && debugDumpDir && i % 30 === 0) {
|
|
14174
14272
|
writeFileExclusiveSync(
|
|
@@ -14378,7 +14476,7 @@ async function runCaptureHdrStage(input) {
|
|
|
14378
14476
|
const debugDumpEnabled = process.env.KEEP_TEMP === "1";
|
|
14379
14477
|
const debugDumpDir = debugDumpEnabled ? join33(framesDir, "debug-composite") : null;
|
|
14380
14478
|
if (debugDumpDir && !existsSync20(debugDumpDir)) {
|
|
14381
|
-
|
|
14479
|
+
mkdirSync11(debugDumpDir, { recursive: true });
|
|
14382
14480
|
}
|
|
14383
14481
|
const compositeTransfer = resolveCompositeTransfer(hasHdrContent, effectiveHdr);
|
|
14384
14482
|
const hdrTargetTransfer = compositeTransfer === "srgb" ? void 0 : compositeTransfer;
|
|
@@ -14406,7 +14504,11 @@ async function runCaptureHdrStage(input) {
|
|
|
14406
14504
|
hdrPerf
|
|
14407
14505
|
};
|
|
14408
14506
|
const effectiveWorkerCount = Math.max(1, workerCount);
|
|
14409
|
-
const transitionFrameCount = partitionTransitionFrames(
|
|
14507
|
+
const transitionFrameCount = partitionTransitionFrames(
|
|
14508
|
+
transitionRanges,
|
|
14509
|
+
totalFrames,
|
|
14510
|
+
windowStartFrame(job.frameWindow)
|
|
14511
|
+
).size;
|
|
14410
14512
|
const useHybrid = shouldUseHybridLayeredPath({
|
|
14411
14513
|
hasHdrContent,
|
|
14412
14514
|
transitionFramesCount: transitionFrameCount,
|
|
@@ -14537,15 +14639,15 @@ async function runCaptureHdrStage(input) {
|
|
|
14537
14639
|
import {
|
|
14538
14640
|
copyFileSync as copyFileSync4,
|
|
14539
14641
|
existsSync as existsSync21,
|
|
14540
|
-
mkdirSync as
|
|
14642
|
+
mkdirSync as mkdirSync12,
|
|
14541
14643
|
readdirSync as readdirSync5,
|
|
14542
|
-
readFileSync as
|
|
14644
|
+
readFileSync as readFileSync10,
|
|
14543
14645
|
rmSync as rmSync12,
|
|
14544
14646
|
statSync as statSync9,
|
|
14545
|
-
writeFileSync as
|
|
14647
|
+
writeFileSync as writeFileSync6
|
|
14546
14648
|
} from "node:fs";
|
|
14547
14649
|
import { readFile as readFile2 } from "node:fs/promises";
|
|
14548
|
-
import { dirname as
|
|
14650
|
+
import { dirname as dirname15, join as join34 } from "node:path";
|
|
14549
14651
|
import {
|
|
14550
14652
|
encodeFramesChunkedConcat,
|
|
14551
14653
|
encodeFramesFromDir,
|
|
@@ -14633,12 +14735,12 @@ async function reencodeWithClearedWholeFrames(argsInput, run, startTime) {
|
|
|
14633
14735
|
const error = formatFfmpegError(result.exitCode, result.stderr);
|
|
14634
14736
|
return gifEncodeFailure(startTime, outputPath, error, result.failureReason);
|
|
14635
14737
|
}
|
|
14636
|
-
const gif =
|
|
14738
|
+
const gif = readFileSync10(outputPath);
|
|
14637
14739
|
if (!clearGifFramesBeforeNext(gif)) {
|
|
14638
14740
|
const error = "[FFmpeg] GIF output could not be parsed to clear its frames";
|
|
14639
14741
|
return gifEncodeFailure(startTime, outputPath, error);
|
|
14640
14742
|
}
|
|
14641
|
-
|
|
14743
|
+
writeFileSync6(outputPath, gif);
|
|
14642
14744
|
return null;
|
|
14643
14745
|
}
|
|
14644
14746
|
async function encodeGifFromDir(framesDir, framePattern, outputPath, input) {
|
|
@@ -14666,7 +14768,7 @@ async function encodeGifFromDir(framesDir, framePattern, outputPath, input) {
|
|
|
14666
14768
|
return gifEncodeFailure(startTime, outputPath, error, result.failureReason);
|
|
14667
14769
|
}
|
|
14668
14770
|
}
|
|
14669
|
-
if (input.preserveAlpha && gifClearsAfterLeavingFrameInPlace(
|
|
14771
|
+
if (input.preserveAlpha && gifClearsAfterLeavingFrameInPlace(readFileSync10(outputPath)) !== false) {
|
|
14670
14772
|
const failure = await reencodeWithClearedWholeFrames(argsInput, run, startTime);
|
|
14671
14773
|
if (failure) return failure;
|
|
14672
14774
|
}
|
|
@@ -14839,7 +14941,7 @@ async function runEncodeStage(input) {
|
|
|
14839
14941
|
const stage5Start = Date.now();
|
|
14840
14942
|
if (isPngSequence) {
|
|
14841
14943
|
const encoded = startEncodeProgress(job, "Writing PNG sequence", onProgress);
|
|
14842
|
-
if (!existsSync21(outputPath))
|
|
14944
|
+
if (!existsSync21(outputPath)) mkdirSync12(outputPath, { recursive: true });
|
|
14843
14945
|
const captured = readdirSync5(framesDir).filter((name) => name.endsWith(".png")).sort();
|
|
14844
14946
|
if (captured.length === 0) {
|
|
14845
14947
|
throw new Error(
|
|
@@ -14871,7 +14973,7 @@ async function runEncodeStage(input) {
|
|
|
14871
14973
|
const encodeResult2 = await encodeGifFromDir(framesDir, framePattern2, outputPath, {
|
|
14872
14974
|
fps: job.config.fps,
|
|
14873
14975
|
loop,
|
|
14874
|
-
palettePath: join34(
|
|
14976
|
+
palettePath: join34(dirname15(videoOnlyPath), "gif-palette.png"),
|
|
14875
14977
|
preserveAlpha: needsAlpha,
|
|
14876
14978
|
signal: abortSignal,
|
|
14877
14979
|
timeout: engineCfg.ffmpegEncodeTimeout
|
|
@@ -15325,7 +15427,7 @@ function getNextRetryWorkerCount(currentWorkers) {
|
|
|
15325
15427
|
}
|
|
15326
15428
|
function resolveRenderWorkDirPrefix(outputPath, jobId, platform2 = process.platform, systemTempDir = tmpdir3()) {
|
|
15327
15429
|
if (platform2 === "win32" || platform2 === "darwin") return join35(systemTempDir, "hf-render-");
|
|
15328
|
-
return join35(
|
|
15430
|
+
return join35(dirname16(outputPath), `work-${jobId}-`);
|
|
15329
15431
|
}
|
|
15330
15432
|
var MAX_TRANSIENT_CAPTURE_RETRIES = 1;
|
|
15331
15433
|
function isTransientCaptureRetryEligible(failureKind, missing, retriesUsed) {
|
|
@@ -16053,7 +16155,7 @@ function deVerifyFallbackTelemetry(err) {
|
|
|
16053
16155
|
};
|
|
16054
16156
|
}
|
|
16055
16157
|
function resolveRenderDebugDir() {
|
|
16056
|
-
const producerRoot = process.env.PRODUCER_RENDERS_DIR ? resolve9(process.env.PRODUCER_RENDERS_DIR, "..") : resolve9(
|
|
16158
|
+
const producerRoot = process.env.PRODUCER_RENDERS_DIR ? resolve9(process.env.PRODUCER_RENDERS_DIR, "..") : resolve9(dirname16(fileURLToPath5(import.meta.url)), "../..");
|
|
16057
16159
|
return join35(producerRoot, ".debug");
|
|
16058
16160
|
}
|
|
16059
16161
|
async function executeRenderJob(job, projectDir, outputPath, progressSink, abortSignal, assertRenderActive) {
|
|
@@ -16061,8 +16163,8 @@ async function executeRenderJob(job, projectDir, outputPath, progressSink, abort
|
|
|
16061
16163
|
validateDeliveryEncoderConfig(job.config);
|
|
16062
16164
|
validateChromaSubsamplingConfig(job.config);
|
|
16063
16165
|
const debugDir = resolveRenderDebugDir();
|
|
16064
|
-
const outputDir =
|
|
16065
|
-
if (!existsSync22(outputDir))
|
|
16166
|
+
const outputDir = dirname16(outputPath);
|
|
16167
|
+
if (!existsSync22(outputDir)) mkdirSync13(outputDir, { recursive: true });
|
|
16066
16168
|
const workDir = job.config.debug ? join35(debugDir, job.id) : createRenderWorkDir(resolveRenderWorkDirPrefix(outputPath, job.id), outputDir);
|
|
16067
16169
|
const pipelineStart = Date.now();
|
|
16068
16170
|
const baseLog = job.config.logger ?? defaultLogger;
|
|
@@ -16219,7 +16321,7 @@ async function executeRenderPipeline(input) {
|
|
|
16219
16321
|
job.startedAt = /* @__PURE__ */ new Date();
|
|
16220
16322
|
assertNotAborted();
|
|
16221
16323
|
assertConfiguredFfmpegBinariesExist();
|
|
16222
|
-
if (!existsSync22(workDir))
|
|
16324
|
+
if (!existsSync22(workDir)) mkdirSync13(workDir, { recursive: true });
|
|
16223
16325
|
if (job.config.debug) {
|
|
16224
16326
|
log.info("[Render] Debug artifacts enabled", { workDir, logPath });
|
|
16225
16327
|
}
|
|
@@ -16388,15 +16490,18 @@ async function executeRenderPipeline(input) {
|
|
|
16388
16490
|
if (resolvedCaptureBeyondViewport !== void 0) {
|
|
16389
16491
|
updateCaptureObservability({ captureBeyondViewport: resolvedCaptureBeyondViewport });
|
|
16390
16492
|
}
|
|
16391
|
-
job.duration = probeResult.duration;
|
|
16392
|
-
job.totalFrames = probeResult.totalFrames;
|
|
16393
|
-
const totalFrames = probeResult.totalFrames;
|
|
16394
|
-
captureTotalFrames = totalFrames;
|
|
16395
16493
|
validateRenderDuration({
|
|
16396
16494
|
duration: probeResult.duration,
|
|
16397
|
-
totalFrames,
|
|
16495
|
+
totalFrames: probeResult.totalFrames,
|
|
16398
16496
|
fps: fpsToNumber8(job.config.fps)
|
|
16399
16497
|
});
|
|
16498
|
+
const frameWindow = job.config.range ? resolveFrameWindow(job.config.range, job.config.fps, probeResult.totalFrames) : void 0;
|
|
16499
|
+
job.frameWindow = frameWindow;
|
|
16500
|
+
if (frameWindow) cfg.enableStreamingEncode = false;
|
|
16501
|
+
const totalFrames = frameWindow ? frameWindow.endFrame - frameWindow.startFrame : probeResult.totalFrames;
|
|
16502
|
+
job.totalFrames = totalFrames;
|
|
16503
|
+
job.duration = frameWindow ? totalFrames * job.config.fps.den / job.config.fps.num : probeResult.duration;
|
|
16504
|
+
captureTotalFrames = totalFrames;
|
|
16400
16505
|
const shownBoxes = largerThanCanvas.length > 0 && probeSession?.isInitialized ? await measureLocalShownBoxes(
|
|
16401
16506
|
probeSession.page,
|
|
16402
16507
|
largerThanCanvas,
|
|
@@ -16577,6 +16682,7 @@ async function executeRenderPipeline(input) {
|
|
|
16577
16682
|
workDir,
|
|
16578
16683
|
compiledDir,
|
|
16579
16684
|
totalFrames: probeResult.totalFrames,
|
|
16685
|
+
...frameWindow && { frameWindow },
|
|
16580
16686
|
fps: job.config.fps,
|
|
16581
16687
|
ffmpegProcessTimeout: cfg.ffmpegProcessTimeout,
|
|
16582
16688
|
audioGain: cfg.audioGain,
|
|
@@ -16623,7 +16729,7 @@ async function executeRenderPipeline(input) {
|
|
|
16623
16729
|
throw new Error("File server failed to initialize before frame capture");
|
|
16624
16730
|
}
|
|
16625
16731
|
const framesDir = join35(workDir, "captured-frames");
|
|
16626
|
-
if (!existsSync22(framesDir))
|
|
16732
|
+
if (!existsSync22(framesDir)) mkdirSync13(framesDir, { recursive: true });
|
|
16627
16733
|
updateJobStatus(job, "rendering", "Checking browser GPU", 25, onProgress, {
|
|
16628
16734
|
code: "start_browsers"
|
|
16629
16735
|
});
|
|
@@ -16631,6 +16737,23 @@ async function executeRenderPipeline(input) {
|
|
|
16631
16737
|
chromePath: resolveHeadlessShellPath(cfg),
|
|
16632
16738
|
browserTimeout: cfg.browserTimeout
|
|
16633
16739
|
});
|
|
16740
|
+
const closeProbeSession = async () => {
|
|
16741
|
+
if (!probeSession) return;
|
|
16742
|
+
lastBrowserConsole = probeSession.browserConsoleBuffer;
|
|
16743
|
+
await closeCaptureSession8(probeSession).catch(() => {
|
|
16744
|
+
});
|
|
16745
|
+
probeSession = null;
|
|
16746
|
+
};
|
|
16747
|
+
const gpuStore = cfg.browserGpuMode === "auto" && resolvedBrowserGpuMode === "hardware" ? gpuChoiceStore(cfg, await probedHardwareGpu()) : void 0;
|
|
16748
|
+
const storedGpuChoice = gpuStore && readGpuChoice(gpuStore);
|
|
16749
|
+
if (gpuStore && storedGpuChoice === "software") {
|
|
16750
|
+
log.info("[Render] Auto GPU mode: rendering in software, as measured on this machine.", {
|
|
16751
|
+
file: gpuStore.file
|
|
16752
|
+
});
|
|
16753
|
+
cfg.browserGpuMode = "software";
|
|
16754
|
+
resolvedBrowserGpuMode = "software";
|
|
16755
|
+
await closeProbeSession();
|
|
16756
|
+
}
|
|
16634
16757
|
startingFrameCapture();
|
|
16635
16758
|
captureForceScreenshot = applyConcreteGpuScreenshotClamp(
|
|
16636
16759
|
captureForceScreenshot,
|
|
@@ -16867,6 +16990,10 @@ async function executeRenderPipeline(input) {
|
|
|
16867
16990
|
totalMemoryMb: Math.round(totalmem2() / (1024 * 1024)),
|
|
16868
16991
|
minMemoryMb: deParallelMinMemoryMb
|
|
16869
16992
|
});
|
|
16993
|
+
if (frameWindow) {
|
|
16994
|
+
deInversionEligible = false;
|
|
16995
|
+
deParallelRouterEligible = false;
|
|
16996
|
+
}
|
|
16870
16997
|
if (probeSession === null && (deInversionEligible || deParallelRouterEligible)) {
|
|
16871
16998
|
try {
|
|
16872
16999
|
probeSession = await createCaptureSession8(
|
|
@@ -16931,7 +17058,9 @@ async function executeRenderPipeline(input) {
|
|
|
16931
17058
|
return "beginFrame";
|
|
16932
17059
|
}
|
|
16933
17060
|
});
|
|
16934
|
-
|
|
17061
|
+
const sizeByCalibration = job.config.workers === void 0 && totalFrames >= 60 && !htmlInCanvasDetected && !cfg.lowMemoryMode && !deInversionEligible && !deParallelRouterEligible;
|
|
17062
|
+
const measureGpuChoice = gpuStore !== void 0 && storedGpuChoice === void 0;
|
|
17063
|
+
if (sizeByCalibration || measureGpuChoice) {
|
|
16935
17064
|
updateJobStatus(job, "rendering", "Measuring capture speed", 25, onProgress, {
|
|
16936
17065
|
code: "start_browsers"
|
|
16937
17066
|
});
|
|
@@ -16971,7 +17100,7 @@ async function executeRenderPipeline(input) {
|
|
|
16971
17100
|
probeSession
|
|
16972
17101
|
});
|
|
16973
17102
|
probeSession = result.probeSession;
|
|
16974
|
-
if (shouldCalibrateSoftwareGpu(
|
|
17103
|
+
if (storedGpuChoice === void 0 && shouldCalibrateSoftwareGpu(
|
|
16975
17104
|
cfg.browserGpuMode,
|
|
16976
17105
|
resolvedBrowserGpuMode,
|
|
16977
17106
|
result.calibration?.estimate
|
|
@@ -16996,7 +17125,7 @@ async function executeRenderPipeline(input) {
|
|
|
16996
17125
|
calibrationFrames?.release();
|
|
16997
17126
|
}
|
|
16998
17127
|
startingFrameCapture();
|
|
16999
|
-
captureCalibration = outcome.calibration;
|
|
17128
|
+
if (sizeByCalibration) captureCalibration = outcome.calibration;
|
|
17000
17129
|
calibrationEvaluateTimedOut = outcome.calibrationEvaluateTimedOut;
|
|
17001
17130
|
captureForceScreenshot = outcome.forceScreenshot;
|
|
17002
17131
|
updateCaptureObservability({ forceScreenshot: captureForceScreenshot });
|
|
@@ -17016,19 +17145,31 @@ async function executeRenderPipeline(input) {
|
|
|
17016
17145
|
);
|
|
17017
17146
|
cfg.browserGpuMode = "software";
|
|
17018
17147
|
resolvedBrowserGpuMode = "software";
|
|
17019
|
-
captureCalibration = softwareOutcome.calibration;
|
|
17148
|
+
if (sizeByCalibration) captureCalibration = softwareOutcome.calibration;
|
|
17020
17149
|
captureForceScreenshot = softwareOutcome.forceScreenshot;
|
|
17021
|
-
|
|
17022
|
-
lastBrowserConsole = probeSession.browserConsoleBuffer;
|
|
17023
|
-
await closeCaptureSession8(probeSession).catch(() => {
|
|
17024
|
-
});
|
|
17025
|
-
probeSession = null;
|
|
17026
|
-
}
|
|
17150
|
+
await closeProbeSession();
|
|
17027
17151
|
updateCaptureObservability({
|
|
17028
17152
|
browserGpuMode: resolvedBrowserGpuMode,
|
|
17029
17153
|
forceScreenshot: captureForceScreenshot
|
|
17030
17154
|
});
|
|
17031
17155
|
}
|
|
17156
|
+
const settledGpuChoice = measureGpuChoice ? settleAutoGpuChoice(outcome.calibration?.estimate, softwareOutcome?.calibration?.estimate) : void 0;
|
|
17157
|
+
if (gpuStore && settledGpuChoice) {
|
|
17158
|
+
try {
|
|
17159
|
+
writeGpuChoice(gpuStore, settledGpuChoice, {
|
|
17160
|
+
hardwareP95Ms: outcome.calibration?.estimate.p95Ms,
|
|
17161
|
+
softwareP95Ms: softwareOutcome?.calibration?.estimate.p95Ms
|
|
17162
|
+
});
|
|
17163
|
+
} catch (error) {
|
|
17164
|
+
log.warn(
|
|
17165
|
+
"[Render] Could not save the measured GPU choice; the next render measures again.",
|
|
17166
|
+
{
|
|
17167
|
+
file: gpuStore.file,
|
|
17168
|
+
error: error instanceof Error ? error.message : String(error)
|
|
17169
|
+
}
|
|
17170
|
+
);
|
|
17171
|
+
}
|
|
17172
|
+
}
|
|
17032
17173
|
observability.checkpoint("capture_calibration", "resolved", {
|
|
17033
17174
|
forceScreenshot: captureForceScreenshot,
|
|
17034
17175
|
browserGpuMode: resolvedBrowserGpuMode,
|
|
@@ -17384,6 +17525,7 @@ async function executeRenderPipeline(input) {
|
|
|
17384
17525
|
});
|
|
17385
17526
|
const syncCapturePlan = () => {
|
|
17386
17527
|
assertMotionBlurSupported(job.config.motionBlur, capturePlan.kind);
|
|
17528
|
+
assertRangeSupported(job.frameWindow, capturePlan.kind);
|
|
17387
17529
|
assertOutputScaleSupported(deviceScaleFactor, capturePlan.kind);
|
|
17388
17530
|
workerCount = capturePlan.workerCount;
|
|
17389
17531
|
captureForceScreenshot = capturePlan.forceScreenshot;
|
|
@@ -17969,6 +18111,7 @@ async function executeRenderPipeline(input) {
|
|
|
17969
18111
|
framesDir,
|
|
17970
18112
|
job,
|
|
17971
18113
|
totalFrames,
|
|
18114
|
+
...job.frameWindow && { frameRange: job.frameWindow },
|
|
17972
18115
|
cfg,
|
|
17973
18116
|
plan: diskPlan,
|
|
17974
18117
|
log,
|
|
@@ -18009,7 +18152,7 @@ async function executeRenderPipeline(input) {
|
|
|
18009
18152
|
"drawElement capture failed; retrying with a fresh screenshot session"
|
|
18010
18153
|
);
|
|
18011
18154
|
rmSync13(framesDir, { recursive: true, force: true });
|
|
18012
|
-
|
|
18155
|
+
mkdirSync13(framesDir, { recursive: true });
|
|
18013
18156
|
resetCaptureAttemptProgress(job);
|
|
18014
18157
|
dedupPerfs.length = 0;
|
|
18015
18158
|
cfg.useDrawElement = false;
|
|
@@ -18188,7 +18331,7 @@ async function executeRenderPipeline(input) {
|
|
|
18188
18331
|
job.perfSummary = perfSummary;
|
|
18189
18332
|
if (job.config.debug) {
|
|
18190
18333
|
try {
|
|
18191
|
-
|
|
18334
|
+
writeFileSync7(perfOutputPath, JSON.stringify(perfSummary, null, 2), "utf-8");
|
|
18192
18335
|
} catch (err) {
|
|
18193
18336
|
log.debug("Failed to write perf summary", {
|
|
18194
18337
|
perfOutputPath,
|
|
@@ -18315,14 +18458,14 @@ async function executeRenderPipeline(input) {
|
|
|
18315
18458
|
// src/services/hyperframeLint.ts
|
|
18316
18459
|
import {
|
|
18317
18460
|
existsSync as existsSync23,
|
|
18318
|
-
readFileSync as
|
|
18461
|
+
readFileSync as readFileSync11,
|
|
18319
18462
|
statSync as statSync11,
|
|
18320
18463
|
openSync as openSync6,
|
|
18321
18464
|
fstatSync as fstatSync4,
|
|
18322
18465
|
closeSync as closeSync6,
|
|
18323
18466
|
constants as constants4
|
|
18324
18467
|
} from "node:fs";
|
|
18325
|
-
import { resolve as resolve10, join as join36, relative as relative6, isAbsolute as isAbsolute5, sep as sep5, dirname as
|
|
18468
|
+
import { resolve as resolve10, join as join36, relative as relative6, isAbsolute as isAbsolute5, sep as sep5, dirname as dirname17 } from "node:path";
|
|
18326
18469
|
import { fileURLToPath as fileURLToPath6 } from "node:url";
|
|
18327
18470
|
import { Worker as Worker3 } from "node:worker_threads";
|
|
18328
18471
|
function isStringRecord(value) {
|
|
@@ -18362,7 +18505,7 @@ function readEntryHtml(filePath) {
|
|
|
18362
18505
|
}
|
|
18363
18506
|
try {
|
|
18364
18507
|
if (!fstatSync4(fd).isFile()) return null;
|
|
18365
|
-
return
|
|
18508
|
+
return readFileSync11(fd, "utf-8");
|
|
18366
18509
|
} finally {
|
|
18367
18510
|
closeSync6(fd);
|
|
18368
18511
|
}
|
|
@@ -18461,7 +18604,7 @@ function freeLintSlot() {
|
|
|
18461
18604
|
waiting.shift()?.();
|
|
18462
18605
|
}
|
|
18463
18606
|
function resolveLintWorkerEntry() {
|
|
18464
|
-
const here =
|
|
18607
|
+
const here = dirname17(fileURLToPath6(import.meta.url));
|
|
18465
18608
|
for (const name of ["hyperframeLintWorker.js", "hyperframeLintWorker.ts"]) {
|
|
18466
18609
|
const candidate = join36(here, name);
|
|
18467
18610
|
if (existsSync23(candidate)) return candidate;
|
|
@@ -18534,7 +18677,7 @@ async function runHyperframeLint(prepared, options = {}) {
|
|
|
18534
18677
|
// src/services/healthWorker.ts
|
|
18535
18678
|
import { Worker as Worker4 } from "node:worker_threads";
|
|
18536
18679
|
import { fileURLToPath as fileURLToPath7 } from "node:url";
|
|
18537
|
-
import { dirname as
|
|
18680
|
+
import { dirname as dirname18, join as join37 } from "node:path";
|
|
18538
18681
|
import { existsSync as existsSync24 } from "node:fs";
|
|
18539
18682
|
var DEFAULT_HEALTH_PORT = 9848;
|
|
18540
18683
|
async function startHealthWorker(options = {}) {
|
|
@@ -18609,7 +18752,7 @@ function defaultLogger2() {
|
|
|
18609
18752
|
};
|
|
18610
18753
|
}
|
|
18611
18754
|
function resolveWorkerEntry2() {
|
|
18612
|
-
const here =
|
|
18755
|
+
const here = dirname18(fileURLToPath7(import.meta.url));
|
|
18613
18756
|
const candidates = [join37(here, "healthWorkerThread.js"), join37(here, "healthWorkerThread.ts")];
|
|
18614
18757
|
for (const candidate of candidates) {
|
|
18615
18758
|
if (existsSync24(candidate)) return candidate;
|
|
@@ -18685,8 +18828,8 @@ import {
|
|
|
18685
18828
|
|
|
18686
18829
|
// src/services/distributed/shared.ts
|
|
18687
18830
|
import { execFile as execFileCallback } from "node:child_process";
|
|
18688
|
-
import { dirname as
|
|
18689
|
-
import { existsSync as existsSync25, readFileSync as
|
|
18831
|
+
import { dirname as dirname19, join as join38 } from "node:path";
|
|
18832
|
+
import { existsSync as existsSync25, readFileSync as readFileSync12 } from "node:fs";
|
|
18690
18833
|
import { fileURLToPath as fileURLToPath8 } from "node:url";
|
|
18691
18834
|
import { promisify as promisify2 } from "node:util";
|
|
18692
18835
|
import {
|
|
@@ -18698,13 +18841,13 @@ var execFile = promisify2(execFileCallback);
|
|
|
18698
18841
|
var cachedProducerVersion = null;
|
|
18699
18842
|
function readProducerVersion() {
|
|
18700
18843
|
if (cachedProducerVersion !== null) return cachedProducerVersion;
|
|
18701
|
-
const startDir =
|
|
18844
|
+
const startDir = dirname19(fileURLToPath8(import.meta.url));
|
|
18702
18845
|
let current = startDir;
|
|
18703
18846
|
for (let i = 0; i < 10; i++) {
|
|
18704
18847
|
const candidate = join38(current, "package.json");
|
|
18705
18848
|
if (existsSync25(candidate)) {
|
|
18706
18849
|
try {
|
|
18707
|
-
const pkg = JSON.parse(
|
|
18850
|
+
const pkg = JSON.parse(readFileSync12(candidate, "utf-8"));
|
|
18708
18851
|
if (pkg.name === "@hyperframes/producer" && typeof pkg.version === "string") {
|
|
18709
18852
|
cachedProducerVersion = pkg.version;
|
|
18710
18853
|
return pkg.version;
|
|
@@ -18712,7 +18855,7 @@ function readProducerVersion() {
|
|
|
18712
18855
|
} catch {
|
|
18713
18856
|
}
|
|
18714
18857
|
}
|
|
18715
|
-
const parent =
|
|
18858
|
+
const parent = dirname19(current);
|
|
18716
18859
|
if (parent === current) break;
|
|
18717
18860
|
current = parent;
|
|
18718
18861
|
}
|
|
@@ -19225,9 +19368,9 @@ function resolvePreparedRenderOutput(prepared, rendersDir, log, confineOutput) {
|
|
|
19225
19368
|
const serverNamed = input.outputPath == null;
|
|
19226
19369
|
const outputCandidate = input.outputPath ?? join40(rendersDir, `${basename8(resolve11(input.projectDir))}-${crypto.randomUUID()}.mp4`);
|
|
19227
19370
|
const absoluteOutputPath = resolveOutputPath(input.projectDir, outputCandidate, rendersDir, log);
|
|
19228
|
-
const outputDir =
|
|
19371
|
+
const outputDir = dirname20(absoluteOutputPath);
|
|
19229
19372
|
if (confineOutput) {
|
|
19230
|
-
|
|
19373
|
+
mkdirSync14(rendersDir, { recursive: true, mode: SERVER_FOLDER_MODE });
|
|
19231
19374
|
if (!isSafePath4(rendersDir, absoluteOutputPath)) {
|
|
19232
19375
|
throw new Error("outputPath must be inside the renders directory");
|
|
19233
19376
|
}
|
|
@@ -19238,7 +19381,7 @@ function resolvePreparedRenderOutput(prepared, rendersDir, log, confineOutput) {
|
|
|
19238
19381
|
);
|
|
19239
19382
|
}
|
|
19240
19383
|
}
|
|
19241
|
-
if (!existsSync26(outputDir))
|
|
19384
|
+
if (!existsSync26(outputDir)) mkdirSync14(outputDir, { recursive: true, mode: SERVER_FOLDER_MODE });
|
|
19242
19385
|
return { input, cleanupProjectDir, absoluteOutputPath, serverNamed };
|
|
19243
19386
|
}
|
|
19244
19387
|
var STICKY_BIT = 512;
|
|
@@ -19350,7 +19493,7 @@ async function resolveInlineRenderHtml(body) {
|
|
|
19350
19493
|
function materializeInlineProject(html, options) {
|
|
19351
19494
|
const tempRoot = process.env.PRODUCER_TMP_PROJECT_DIR || tmpdir4();
|
|
19352
19495
|
const tempProjectDir = mkdtempSync(join40(tempRoot, "producer-project-"));
|
|
19353
|
-
|
|
19496
|
+
writeFileSync8(join40(tempProjectDir, "index.html"), html, "utf-8");
|
|
19354
19497
|
return {
|
|
19355
19498
|
prepared: {
|
|
19356
19499
|
input: { projectDir: tempProjectDir, ...options },
|
|
@@ -19943,9 +20086,9 @@ function serverAuth(options, hostname2, port) {
|
|
|
19943
20086
|
options.authTokenFile?.trim() || process.env.PRODUCER_AUTH_TOKEN_FILE?.trim() || join40(homedir(), ".hyperframes", "producer", `${port}.token`)
|
|
19944
20087
|
);
|
|
19945
20088
|
const token = crypto.randomBytes(32).toString("base64url");
|
|
19946
|
-
|
|
20089
|
+
mkdirSync14(dirname20(file), { recursive: true, mode: 448 });
|
|
19947
20090
|
rmSync14(file, { force: true });
|
|
19948
|
-
|
|
20091
|
+
writeFileSync8(file, `${token}
|
|
19949
20092
|
`, { flag: "wx", mode: 384 });
|
|
19950
20093
|
return { token, generatedFile: file };
|
|
19951
20094
|
}
|