@hyperframes/producer 0.9.32 → 0.9.34
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/distributed.js +232 -164
- package/dist/hyperframe.manifest.json +1 -1
- package/dist/hyperframe.runtime.iife.js +61 -61
- package/dist/index.js +283 -190
- package/dist/public-server.js +208 -127
- package/dist/renderRequest.d.ts +1 -0
- package/dist/server.d.ts +2 -0
- package/dist/services/distributed/plan.d.ts +6 -0
- package/dist/services/distributed/planV2.d.ts +3 -0
- package/dist/services/distributed/shared.d.ts +1 -0
- package/dist/services/render/observability.d.ts +2 -0
- package/dist/services/render/shared.d.ts +3 -0
- package/dist/services/render/stages/probeStage.d.ts +9 -13
- package/dist/services/renderOrchestrator.d.ts +2 -0
- package/dist/utils/paths.d.ts +0 -2
- package/package.json +7 -7
package/dist/public-server.js
CHANGED
|
@@ -2,7 +2,7 @@
|
|
|
2
2
|
|
|
3
3
|
// src/server.ts
|
|
4
4
|
import {
|
|
5
|
-
existsSync as
|
|
5
|
+
existsSync as existsSync25,
|
|
6
6
|
mkdirSync as mkdirSync13,
|
|
7
7
|
statSync as statSync11,
|
|
8
8
|
mkdtempSync,
|
|
@@ -26,7 +26,7 @@ import {
|
|
|
26
26
|
// src/services/renderOrchestrator.ts
|
|
27
27
|
import { audioFailureDiagnostics as audioFailureDiagnostics2 } from "@hyperframes/engine";
|
|
28
28
|
import {
|
|
29
|
-
existsSync as
|
|
29
|
+
existsSync as existsSync21,
|
|
30
30
|
mkdirSync as mkdirSync12,
|
|
31
31
|
readdirSync as readdirSync6,
|
|
32
32
|
rmSync as rmSync12,
|
|
@@ -223,7 +223,9 @@ function createConsoleLogger(level = "info") {
|
|
|
223
223
|
}
|
|
224
224
|
};
|
|
225
225
|
}
|
|
226
|
-
var defaultLogger = createConsoleLogger(
|
|
226
|
+
var defaultLogger = createConsoleLogger(
|
|
227
|
+
process.env.HF_DEBUG_RENDER === "1" ? "debug" : "info"
|
|
228
|
+
);
|
|
227
229
|
|
|
228
230
|
// src/services/fileServer.ts
|
|
229
231
|
var readFileAsync = promisify(readFile);
|
|
@@ -1025,7 +1027,7 @@ function assertChromaSubsamplingSdr(config, hasHdrContent) {
|
|
|
1025
1027
|
import {
|
|
1026
1028
|
copyFileSync,
|
|
1027
1029
|
cpSync,
|
|
1028
|
-
existsSync as
|
|
1030
|
+
existsSync as existsSync3,
|
|
1029
1031
|
mkdirSync,
|
|
1030
1032
|
rmSync,
|
|
1031
1033
|
symlinkSync,
|
|
@@ -1048,9 +1050,7 @@ import {
|
|
|
1048
1050
|
relative as nodeRelative,
|
|
1049
1051
|
isAbsolute as nodeIsAbsolute
|
|
1050
1052
|
} from "node:path";
|
|
1051
|
-
import { existsSync as existsSync3 } from "node:fs";
|
|
1052
1053
|
import { fileURLToPath as fileURLToPath2 } from "node:url";
|
|
1053
|
-
import { decodedUrlPath } from "@hyperframes/parsers/asset-paths";
|
|
1054
1054
|
var DEFAULT_RENDERS_DIR = process.env.PRODUCER_RENDERS_DIR ?? // fileURLToPath (not URL.pathname): on Windows .pathname is "/D:/..." which
|
|
1055
1055
|
// resolves to a bogus renders dir.
|
|
1056
1056
|
nodeResolve(fileURLToPath2(import.meta.url), "../../..", "renders");
|
|
@@ -1088,13 +1088,6 @@ function resolveRenderPaths(projectDir, outputPath, rendersDir = DEFAULT_RENDERS
|
|
|
1088
1088
|
const absoluteOutputPath = nodeResolve(resolvedOutputPath);
|
|
1089
1089
|
return { absoluteProjectDir, absoluteOutputPath };
|
|
1090
1090
|
}
|
|
1091
|
-
function resolveCompositionSrc(projectDir, src) {
|
|
1092
|
-
const rooted = (value) => nodeResolve(projectDir, value.replace(/^(?:\.?[\\/])+/, ""));
|
|
1093
|
-
const decoded = rooted(decodedUrlPath(src));
|
|
1094
|
-
if (!isPathInside2(decoded, projectDir)) return null;
|
|
1095
|
-
const raw = rooted(src);
|
|
1096
|
-
return !existsSync3(decoded) && isPathInside2(raw, projectDir) && existsSync3(raw) ? raw : decoded;
|
|
1097
|
-
}
|
|
1098
1091
|
|
|
1099
1092
|
// src/services/render/shared.ts
|
|
1100
1093
|
var BROWSER_MEDIA_EPSILON = 1e-4;
|
|
@@ -1269,6 +1262,13 @@ var workerPhasesByJob = /* @__PURE__ */ new WeakMap();
|
|
|
1269
1262
|
function forgetWorkerPhases(job) {
|
|
1270
1263
|
workerPhasesByJob.delete(job);
|
|
1271
1264
|
}
|
|
1265
|
+
var staticDedupActivityByJob = /* @__PURE__ */ new WeakMap();
|
|
1266
|
+
function noteStaticDedupActivity(job) {
|
|
1267
|
+
staticDedupActivityByJob.set(job, (staticDedupActivityByJob.get(job) ?? 0) + 1);
|
|
1268
|
+
}
|
|
1269
|
+
function staticDedupActivity(job) {
|
|
1270
|
+
return staticDedupActivityByJob.get(job) ?? 0;
|
|
1271
|
+
}
|
|
1272
1272
|
function describeWorkerPhases(job) {
|
|
1273
1273
|
const phases = workerPhasesByJob.get(job);
|
|
1274
1274
|
if (!phases?.size) return void 0;
|
|
@@ -1302,7 +1302,7 @@ var materializePathModule = {
|
|
|
1302
1302
|
isAbsolute
|
|
1303
1303
|
};
|
|
1304
1304
|
var materializeFileSystem = {
|
|
1305
|
-
existsSync:
|
|
1305
|
+
existsSync: existsSync3,
|
|
1306
1306
|
mkdirSync,
|
|
1307
1307
|
symlinkSync,
|
|
1308
1308
|
cpSync,
|
|
@@ -1604,7 +1604,7 @@ var RenderExecutionContext = class {
|
|
|
1604
1604
|
};
|
|
1605
1605
|
|
|
1606
1606
|
// src/services/render/artifactTransaction.ts
|
|
1607
|
-
import { closeSync as closeSync2, existsSync as
|
|
1607
|
+
import { closeSync as closeSync2, existsSync as existsSync5, fstatSync as fstatSync2, openSync as openSync2, readSync, readdirSync as readdirSync2, rmSync as rmSync3 } from "node:fs";
|
|
1608
1608
|
import { basename as basename4, dirname as dirname4, extname as extname2, join as join5, resolve as resolve4 } from "node:path";
|
|
1609
1609
|
import { HLS_MASTER_PLAYLIST, HLS_VIDEO_PLAYLIST, renameWithRetry } from "@hyperframes/engine";
|
|
1610
1610
|
|
|
@@ -1617,7 +1617,7 @@ import {
|
|
|
1617
1617
|
|
|
1618
1618
|
// src/services/render/renderDirOwner.ts
|
|
1619
1619
|
import {
|
|
1620
|
-
existsSync as
|
|
1620
|
+
existsSync as existsSync4,
|
|
1621
1621
|
lstatSync,
|
|
1622
1622
|
readFileSync as readFileSync2,
|
|
1623
1623
|
readdirSync,
|
|
@@ -1692,7 +1692,7 @@ function newestWriteMs(path) {
|
|
|
1692
1692
|
}
|
|
1693
1693
|
function isAbandoned(dir, ownerlessIdleMs, now) {
|
|
1694
1694
|
try {
|
|
1695
|
-
if (!lstatSync(dir).isDirectory() ||
|
|
1695
|
+
if (!lstatSync(dir).isDirectory() || existsSync4(join4(dir, TRANSACTION_BACKUP))) return false;
|
|
1696
1696
|
const owner = ownerState(dir);
|
|
1697
1697
|
if (owner === "gone") return true;
|
|
1698
1698
|
return owner === "none" && ownerlessIdleMs !== void 0 && now - newestWriteMs(dir) >= ownerlessIdleMs;
|
|
@@ -1724,7 +1724,7 @@ function createRenderWorkDir(prefix, outputDir) {
|
|
|
1724
1724
|
|
|
1725
1725
|
// src/services/render/artifactTransaction.ts
|
|
1726
1726
|
var defaultFileSystem = {
|
|
1727
|
-
existsSync:
|
|
1727
|
+
existsSync: existsSync5,
|
|
1728
1728
|
renameSync: (source, destination) => renameWithRetry(source, destination),
|
|
1729
1729
|
rmSync: rmSync3
|
|
1730
1730
|
};
|
|
@@ -1878,7 +1878,7 @@ var ArtifactTransaction = class {
|
|
|
1878
1878
|
async assertDirectoryExpectation(expected, files) {
|
|
1879
1879
|
for (const required of expected.requiredFiles ?? []) {
|
|
1880
1880
|
const path = join5(this.stagingPath, required);
|
|
1881
|
-
if (!
|
|
1881
|
+
if (!existsSync5(path)) {
|
|
1882
1882
|
throw new Error(`Render artifact directory is missing ${required}: ${this.stagingPath}`);
|
|
1883
1883
|
}
|
|
1884
1884
|
assertReadableNonEmptyFile(path);
|
|
@@ -2127,7 +2127,7 @@ function replanAfterFailure(plan, failure) {
|
|
|
2127
2127
|
}
|
|
2128
2128
|
|
|
2129
2129
|
// src/services/render/stages/captureSegmentedStage.ts
|
|
2130
|
-
import { existsSync as
|
|
2130
|
+
import { existsSync as existsSync6, mkdirSync as mkdirSync3, rmSync as rmSync6, statSync as statSync3 } from "node:fs";
|
|
2131
2131
|
import { join as join9 } from "node:path";
|
|
2132
2132
|
import {
|
|
2133
2133
|
captureFrameToBuffer as captureFrameToBuffer2,
|
|
@@ -4473,7 +4473,7 @@ async function runCaptureStreamingStage(input) {
|
|
|
4473
4473
|
const session = probeSession ?? await openSession();
|
|
4474
4474
|
captureBeyondViewport = session.options.captureBeyondViewport;
|
|
4475
4475
|
if (probeSession) {
|
|
4476
|
-
prepareCaptureSessionForReuse(session, framesDir, videoInjector);
|
|
4476
|
+
await prepareCaptureSessionForReuse(session, framesDir, videoInjector);
|
|
4477
4477
|
probeSession = null;
|
|
4478
4478
|
}
|
|
4479
4479
|
let riskSession = null;
|
|
@@ -4731,7 +4731,7 @@ async function captureSegmentToEncoder(ctx, segment) {
|
|
|
4731
4731
|
path: segmentPath,
|
|
4732
4732
|
// Recorded so resume can prove the file on disk is the one that
|
|
4733
4733
|
// finished; absent only in unit tests, whose fake encoder writes none.
|
|
4734
|
-
bytes:
|
|
4734
|
+
bytes: existsSync6(segmentPath) ? statSync3(segmentPath).size : 0
|
|
4735
4735
|
});
|
|
4736
4736
|
return encodeResult;
|
|
4737
4737
|
} finally {
|
|
@@ -4778,8 +4778,13 @@ function defaultSessionFactory(input) {
|
|
|
4778
4778
|
};
|
|
4779
4779
|
const session = probeSession ?? await openSession();
|
|
4780
4780
|
if (probeSession) {
|
|
4781
|
-
|
|
4781
|
+
const reused = probeSession;
|
|
4782
4782
|
probeSession = null;
|
|
4783
|
+
await openSegmentedSessionReuse(input, reused, injector).catch(async (error) => {
|
|
4784
|
+
await closeCaptureSession2(reused).catch(() => {
|
|
4785
|
+
});
|
|
4786
|
+
throw error;
|
|
4787
|
+
});
|
|
4783
4788
|
}
|
|
4784
4789
|
try {
|
|
4785
4790
|
if (!session.isInitialized) await withinInitBudget(initializeSession2(session), session);
|
|
@@ -4793,8 +4798,8 @@ function defaultSessionFactory(input) {
|
|
|
4793
4798
|
}
|
|
4794
4799
|
};
|
|
4795
4800
|
}
|
|
4796
|
-
function openSegmentedSessionReuse(input, session, injector) {
|
|
4797
|
-
prepareCaptureSessionForReuse2(session, input.framesDir, injector());
|
|
4801
|
+
async function openSegmentedSessionReuse(input, session, injector) {
|
|
4802
|
+
await prepareCaptureSessionForReuse2(session, input.framesDir, injector());
|
|
4798
4803
|
}
|
|
4799
4804
|
async function openSegmentedSession(input, injector) {
|
|
4800
4805
|
const captureCfg = input.cfg.forceScreenshot === input.plan.forceScreenshot ? input.cfg : { ...input.cfg, forceScreenshot: input.plan.forceScreenshot };
|
|
@@ -5732,7 +5737,7 @@ function trackSegmentFramePeak(frames, rootDir, onPeak) {
|
|
|
5732
5737
|
|
|
5733
5738
|
// src/services/render/segmentManifest.ts
|
|
5734
5739
|
import { createHash as createHash2 } from "node:crypto";
|
|
5735
|
-
import { existsSync as
|
|
5740
|
+
import { existsSync as existsSync7, mkdirSync as mkdirSync6, readFileSync as readFileSync4, statSync as statSync5, writeFileSync as writeFileSync3 } from "node:fs";
|
|
5736
5741
|
import { join as join14 } from "node:path";
|
|
5737
5742
|
import { renameWithRetry as renameWithRetry2 } from "@hyperframes/engine";
|
|
5738
5743
|
var MANIFEST_FILENAME = "segments.json";
|
|
@@ -5780,7 +5785,7 @@ function isManifest(value) {
|
|
|
5780
5785
|
}
|
|
5781
5786
|
function readSegmentManifest(segmentDir) {
|
|
5782
5787
|
const path = join14(segmentDir, MANIFEST_FILENAME);
|
|
5783
|
-
if (!
|
|
5788
|
+
if (!existsSync7(path)) return null;
|
|
5784
5789
|
try {
|
|
5785
5790
|
const parsed = JSON.parse(readFileSync4(path, "utf-8"));
|
|
5786
5791
|
return isManifest(parsed) ? parsed : null;
|
|
@@ -5809,7 +5814,7 @@ async function validateCompletedSegments(manifest, expectedHash, probeFrames) {
|
|
|
5809
5814
|
const ok = /* @__PURE__ */ new Set();
|
|
5810
5815
|
if (manifest.planHash !== expectedHash) return ok;
|
|
5811
5816
|
for (const entry of manifest.completed) {
|
|
5812
|
-
if (!
|
|
5817
|
+
if (!existsSync7(entry.path)) continue;
|
|
5813
5818
|
const size = statSync5(entry.path).size;
|
|
5814
5819
|
if (size <= 0 || size !== entry.bytes) continue;
|
|
5815
5820
|
const frames = await probeFrames(entry.path);
|
|
@@ -6177,26 +6182,26 @@ var STALL_POLL_MS = 5e3;
|
|
|
6177
6182
|
function watchStall(phase, rule) {
|
|
6178
6183
|
const detail = rule.detail ?? (() => void 0);
|
|
6179
6184
|
let last = rule.progress();
|
|
6185
|
+
let lastActivity = rule.activity?.();
|
|
6180
6186
|
let budgetMs = rule.firstProgressMs;
|
|
6181
6187
|
const silence = createStallClock();
|
|
6182
6188
|
const pollMs = Math.min(STALL_POLL_MS, rule.noProgressMs, rule.firstProgressMs);
|
|
6183
6189
|
let attempt;
|
|
6184
6190
|
let timer;
|
|
6185
6191
|
let inTail = false;
|
|
6192
|
+
const activityMoved = () => {
|
|
6193
|
+
const activity = rule.activity?.();
|
|
6194
|
+
if (activity === lastActivity) return false;
|
|
6195
|
+
lastActivity = activity;
|
|
6196
|
+
return true;
|
|
6197
|
+
};
|
|
6186
6198
|
const restartWindow = (ms) => {
|
|
6187
6199
|
last = rule.progress();
|
|
6188
6200
|
budgetMs = ms;
|
|
6189
6201
|
silence.reset();
|
|
6190
6202
|
};
|
|
6191
6203
|
const tripped = new Promise((_, reject) => {
|
|
6192
|
-
|
|
6193
|
-
const current = rule.progress();
|
|
6194
|
-
if (rule.complete?.() && !inTail) {
|
|
6195
|
-
inTail = true;
|
|
6196
|
-
return restartWindow(rule.tailMs ?? rule.noProgressMs);
|
|
6197
|
-
}
|
|
6198
|
-
if (current !== last) return restartWindow(rule.noProgressMs);
|
|
6199
|
-
if (silence.idle(pollMs) < budgetMs) return;
|
|
6204
|
+
const trip = (current) => {
|
|
6200
6205
|
const error = new RenderStageStalledError(phase, budgetMs, current, detail());
|
|
6201
6206
|
if (attempt && !attempt.signal.aborted) {
|
|
6202
6207
|
attempt.abort(error);
|
|
@@ -6204,6 +6209,16 @@ function watchStall(phase, rule) {
|
|
|
6204
6209
|
}
|
|
6205
6210
|
clearInterval(timer);
|
|
6206
6211
|
reject(error);
|
|
6212
|
+
};
|
|
6213
|
+
timer = setInterval(() => {
|
|
6214
|
+
const current = rule.progress();
|
|
6215
|
+
if (rule.complete?.() && !inTail) {
|
|
6216
|
+
inTail = true;
|
|
6217
|
+
return restartWindow(rule.tailMs ?? rule.noProgressMs);
|
|
6218
|
+
}
|
|
6219
|
+
if (current !== last) return restartWindow(rule.noProgressMs);
|
|
6220
|
+
if (activityMoved()) return silence.reset();
|
|
6221
|
+
if (silence.idle(pollMs) >= budgetMs) trip(current);
|
|
6207
6222
|
}, pollMs);
|
|
6208
6223
|
});
|
|
6209
6224
|
const openAttempt = (parent) => {
|
|
@@ -6388,21 +6403,21 @@ function countAuthoredTimedClips(html) {
|
|
|
6388
6403
|
}
|
|
6389
6404
|
|
|
6390
6405
|
// src/services/render/stages/compileStage.ts
|
|
6391
|
-
import { existsSync as
|
|
6406
|
+
import { existsSync as existsSync12, writeFileSync as writeFileSync5 } from "node:fs";
|
|
6392
6407
|
import { join as join19 } from "node:path";
|
|
6393
6408
|
import { suggestMatchingPreset } from "@hyperframes/core";
|
|
6394
6409
|
import { extractStandaloneEntryFromIndex, isTemplateEntry } from "@hyperframes/core/compiler";
|
|
6395
6410
|
import { readTextFile as readTextFile2 } from "@hyperframes/parsers/asset-resolution";
|
|
6396
6411
|
|
|
6397
6412
|
// src/services/htmlCompiler.ts
|
|
6398
|
-
import { decodedUrlPath
|
|
6413
|
+
import { decodedUrlPath } from "@hyperframes/parsers/asset-paths";
|
|
6399
6414
|
import { createHash as createHash6 } from "node:crypto";
|
|
6400
|
-
import { createReadStream as createReadStream2, existsSync as
|
|
6415
|
+
import { createReadStream as createReadStream2, existsSync as existsSync11, mkdirSync as mkdirSync9, readFileSync as readFileSync8 } from "fs";
|
|
6401
6416
|
import { join as join18, dirname as dirname8, resolve as resolve7, basename as basename5, relative as relative2, sep as sep2 } from "path";
|
|
6402
6417
|
import { parseHTML as parseHTML5 } from "linkedom";
|
|
6403
6418
|
|
|
6404
6419
|
// src/services/bundledScripts.ts
|
|
6405
|
-
import { existsSync as
|
|
6420
|
+
import { existsSync as existsSync8, readFileSync as readFileSync5 } from "node:fs";
|
|
6406
6421
|
import { join as join15 } from "node:path";
|
|
6407
6422
|
import { gsapCdnDist } from "@hyperframes/core/gsap-cdn";
|
|
6408
6423
|
var GSAP_VENDOR_DIR_ENV = "HYPERFRAMES_GSAP_VENDOR_DIR";
|
|
@@ -6410,7 +6425,7 @@ function bundledScript(url) {
|
|
|
6410
6425
|
const dir = process.env[GSAP_VENDOR_DIR_ENV];
|
|
6411
6426
|
if (!dir || url !== `${gsapCdnDist()}gsap.min.js`) return null;
|
|
6412
6427
|
const file = join15(dir, "gsap.min.js");
|
|
6413
|
-
return
|
|
6428
|
+
return existsSync8(file) ? readFileSync5(file) : null;
|
|
6414
6429
|
}
|
|
6415
6430
|
|
|
6416
6431
|
// src/services/htmlCompiler.ts
|
|
@@ -6450,6 +6465,7 @@ import {
|
|
|
6450
6465
|
emitRootCompositionVariableStyles,
|
|
6451
6466
|
readDeclaredDefaults,
|
|
6452
6467
|
parseHostVariableValues,
|
|
6468
|
+
boundMediaSrc,
|
|
6453
6469
|
headStyleRuns,
|
|
6454
6470
|
isAlwaysAppliedStyle,
|
|
6455
6471
|
dedupeFontFaceRules,
|
|
@@ -6464,8 +6480,10 @@ import {
|
|
|
6464
6480
|
} from "@hyperframes/parsers/sub-composition-validity";
|
|
6465
6481
|
import {
|
|
6466
6482
|
isUnresolvedAssetPlaceholder,
|
|
6483
|
+
namesAnotherNetworkRoot as namesAnotherNetworkRoot2,
|
|
6467
6484
|
readProjectFile,
|
|
6468
|
-
readTextFile
|
|
6485
|
+
readTextFile,
|
|
6486
|
+
resolveCompositionSrc
|
|
6469
6487
|
} from "@hyperframes/parsers/asset-resolution";
|
|
6470
6488
|
|
|
6471
6489
|
// src/services/renderMediaCollector.ts
|
|
@@ -6658,11 +6676,12 @@ import {
|
|
|
6658
6676
|
|
|
6659
6677
|
// src/services/animatedGifPrep.ts
|
|
6660
6678
|
import { createHash as createHash4 } from "node:crypto";
|
|
6661
|
-
import { copyFileSync as copyFileSync2, existsSync as
|
|
6679
|
+
import { copyFileSync as copyFileSync2, existsSync as existsSync9, mkdirSync as mkdirSync7, readFileSync as readFileSync6, rmSync as rmSync9, statSync as statSync6 } from "node:fs";
|
|
6662
6680
|
import { dirname as dirname6, isAbsolute as isAbsolute2, join as join16, resolve as resolve5 } from "node:path";
|
|
6663
6681
|
import { parseHTML as parseHTML3 } from "linkedom";
|
|
6664
6682
|
import { parseAnimatedGifMetadata } from "@hyperframes/core";
|
|
6665
6683
|
import { DEFAULT_VP9_CPU_USED, runFfmpeg as runFfmpeg2, renameWithRetry as renameWithRetry3 } from "@hyperframes/engine";
|
|
6684
|
+
import { namesAnotherNetworkRoot } from "@hyperframes/parsers/asset-resolution";
|
|
6666
6685
|
var PREPARED_GIF_SUBDIR = "_animated_gif";
|
|
6667
6686
|
var CACHE_SCHEMA = "hfgif-v1";
|
|
6668
6687
|
function splitUrlSuffix(src) {
|
|
@@ -6697,14 +6716,15 @@ function resolveLocalImageSourcePath(src, options) {
|
|
|
6697
6716
|
const { basePath } = splitUrlSuffix(trimmed);
|
|
6698
6717
|
const normalizedBase = normalizeRelPath(basePath);
|
|
6699
6718
|
const mapped = options.sourceAssets?.get(trimmed) ?? options.sourceAssets?.get(basePath) ?? options.sourceAssets?.get(normalizedBase);
|
|
6700
|
-
if (mapped &&
|
|
6719
|
+
if (mapped && existsSync9(mapped)) return mapped;
|
|
6701
6720
|
if (isHttpUrl(trimmed)) return null;
|
|
6721
|
+
const protocolRelativeUrlOnShare = basePath.startsWith("/") && namesAnotherNetworkRoot(options.projectDir, basePath);
|
|
6702
6722
|
const projectRelative = basePath.startsWith("/") ? basePath.slice(1) : basePath;
|
|
6703
6723
|
const candidates = [
|
|
6704
|
-
isAbsolute2(basePath) ? basePath : resolve5(options.projectDir, projectRelative),
|
|
6724
|
+
...protocolRelativeUrlOnShare ? [] : [isAbsolute2(basePath) ? basePath : resolve5(options.projectDir, projectRelative)],
|
|
6705
6725
|
resolve5(options.downloadDir, normalizedBase)
|
|
6706
6726
|
];
|
|
6707
|
-
return candidates.find((candidate) =>
|
|
6727
|
+
return candidates.find((candidate) => existsSync9(candidate)) ?? null;
|
|
6708
6728
|
}
|
|
6709
6729
|
function isUsableFile(path) {
|
|
6710
6730
|
try {
|
|
@@ -6815,10 +6835,10 @@ async function runAnimatedGifTranscode(request) {
|
|
|
6815
6835
|
throw result.error ?? new Error(`Animated GIF transcode failed (${result.exitCode}): ${result.stderr.slice(-500)}`);
|
|
6816
6836
|
}
|
|
6817
6837
|
async function ensurePreparedWebm(input) {
|
|
6818
|
-
if (!
|
|
6838
|
+
if (!existsSync9(dirname6(input.cachePath))) {
|
|
6819
6839
|
mkdirSync7(dirname6(input.cachePath), { recursive: true });
|
|
6820
6840
|
}
|
|
6821
|
-
if (!
|
|
6841
|
+
if (!existsSync9(dirname6(input.outputPath))) {
|
|
6822
6842
|
mkdirSync7(dirname6(input.outputPath), { recursive: true });
|
|
6823
6843
|
}
|
|
6824
6844
|
if (!isUsableFile(input.cachePath)) {
|
|
@@ -7293,7 +7313,7 @@ import { createStudioPositionSeekReapplyScript } from "@hyperframes/studio-serve
|
|
|
7293
7313
|
import { getPositionEditsRenderScript } from "@hyperframes/core/runtime/position-edits-render";
|
|
7294
7314
|
|
|
7295
7315
|
// src/services/assetMediaType.ts
|
|
7296
|
-
import { existsSync as
|
|
7316
|
+
import { existsSync as existsSync10 } from "node:fs";
|
|
7297
7317
|
import {
|
|
7298
7318
|
fingerprintElementId,
|
|
7299
7319
|
isNotMediaPayload,
|
|
@@ -7366,7 +7386,7 @@ async function preflightCompositionAssetMediaTypes(input) {
|
|
|
7366
7386
|
input.projectDir,
|
|
7367
7387
|
input.compiledDir
|
|
7368
7388
|
);
|
|
7369
|
-
if (!
|
|
7389
|
+
if (!existsSync10(resolvedPath)) continue;
|
|
7370
7390
|
byPath.set(resolvedPath, [...byPath.get(resolvedPath) ?? [], reference]);
|
|
7371
7391
|
}
|
|
7372
7392
|
const mismatches = [];
|
|
@@ -7406,7 +7426,7 @@ async function preflightCompositionAssetMediaTypes(input) {
|
|
|
7406
7426
|
|
|
7407
7427
|
// src/services/htmlCompiler.ts
|
|
7408
7428
|
function logRemoteDownloadTelemetry(event) {
|
|
7409
|
-
defaultLogger.
|
|
7429
|
+
defaultLogger.debug("[Compiler] Remote asset download integrity", { ...event });
|
|
7410
7430
|
}
|
|
7411
7431
|
var INFERRED_MEDIA_DURATION_ATTR = "data-hf-inferred-duration";
|
|
7412
7432
|
function parseSubCompHtmlForValidity(html) {
|
|
@@ -7620,7 +7640,7 @@ async function resolveMediaDuration(src, mediaStart, playbackRate, baseDir, down
|
|
|
7620
7640
|
let filePath = src;
|
|
7621
7641
|
if (isHttpUrl(src)) {
|
|
7622
7642
|
const remoteDir = join18(downloadDir, REMOTE_MEDIA_SUBDIR);
|
|
7623
|
-
if (!
|
|
7643
|
+
if (!existsSync11(remoteDir)) mkdirSync9(remoteDir, { recursive: true });
|
|
7624
7644
|
try {
|
|
7625
7645
|
filePath = await downloadToTemp(src, remoteDir, void 0, void 0, void 0, {
|
|
7626
7646
|
onTelemetry: logRemoteDownloadTelemetry
|
|
@@ -7629,11 +7649,14 @@ async function resolveMediaDuration(src, mediaStart, playbackRate, baseDir, down
|
|
|
7629
7649
|
return { duration: null, resolvedPath: src };
|
|
7630
7650
|
}
|
|
7631
7651
|
} else {
|
|
7632
|
-
filePath =
|
|
7652
|
+
filePath = decodedUrlPath(src);
|
|
7633
7653
|
if (!filePath.startsWith("/")) filePath = join18(baseDir, filePath);
|
|
7634
7654
|
filePath = urlByAbsentLocalPath?.get(filePath) ?? filePath;
|
|
7655
|
+
if (!isHttpUrl(filePath) && namesAnotherNetworkRoot2(baseDir, filePath)) {
|
|
7656
|
+
return { duration: null, resolvedPath: filePath };
|
|
7657
|
+
}
|
|
7635
7658
|
}
|
|
7636
|
-
if (!isHttpUrl(filePath) && !
|
|
7659
|
+
if (!isHttpUrl(filePath) && !existsSync11(filePath)) {
|
|
7637
7660
|
return { duration: null, resolvedPath: filePath };
|
|
7638
7661
|
}
|
|
7639
7662
|
const withSrcContext = (error) => {
|
|
@@ -7982,7 +8005,7 @@ function inlineSubCompositions(html, subCompositions, projectDir, variableOverri
|
|
|
7982
8005
|
parseHtml: (htmlStr) => parseHTML5(htmlStr).document,
|
|
7983
8006
|
// Mirrors the preview bundler: a sub-composition's SIBLING assets resolve
|
|
7984
8007
|
// against its own directory, project-root refs stay as authored.
|
|
7985
|
-
assetExists: (path) =>
|
|
8008
|
+
assetExists: (path) => existsSync11(resolve7(projectDir, path)),
|
|
7986
8009
|
// Preserve the authored root wrapper as a child of the host, matching
|
|
7987
8010
|
// the preview bundler's shape (htmlBundler.ts's prepareFlattenedInnerRoot,
|
|
7988
8011
|
// which the runtime compositionLoader mirrors with its own copy for the
|
|
@@ -8158,7 +8181,7 @@ ${safeText}
|
|
|
8158
8181
|
//# sourceURL=${new URL(src).href}
|
|
8159
8182
|
`;
|
|
8160
8183
|
el.replaceWith(inlineScript);
|
|
8161
|
-
defaultLogger.
|
|
8184
|
+
defaultLogger.debug(`[Compiler] Inlined CDN script: ${src}`);
|
|
8162
8185
|
} else {
|
|
8163
8186
|
if (download.reason instanceof ScriptIntegrityError) throw download.reason;
|
|
8164
8187
|
defaultLogger.warn(
|
|
@@ -8178,7 +8201,7 @@ function collectExternalAssets(html, projectDir) {
|
|
|
8178
8201
|
if (isPathInside2(absPath, absProjectDir)) {
|
|
8179
8202
|
return null;
|
|
8180
8203
|
}
|
|
8181
|
-
if (!
|
|
8204
|
+
if (!existsSync11(absPath)) return null;
|
|
8182
8205
|
const safeKey = toExternalAssetKey(absPath);
|
|
8183
8206
|
externalAssets.set(safeKey, absPath);
|
|
8184
8207
|
return safeKey;
|
|
@@ -8213,7 +8236,7 @@ function collectExternalAssets(html, projectDir) {
|
|
|
8213
8236
|
if (rewritten !== style) el.setAttribute("style", rewritten);
|
|
8214
8237
|
}
|
|
8215
8238
|
if (externalAssets.size > 0) {
|
|
8216
|
-
defaultLogger.
|
|
8239
|
+
defaultLogger.debug(
|
|
8217
8240
|
`[Compiler] Found ${externalAssets.size} asset(s) outside project directory, will copy to render output`
|
|
8218
8241
|
);
|
|
8219
8242
|
}
|
|
@@ -8228,7 +8251,7 @@ var REMOTE_SOURCE_TAG_RE = /<source\b[^>]*?\bsrc\s*=\s*["'](https?:\/\/[^"']+)["
|
|
|
8228
8251
|
var REMOTE_IMG_TAG_RE = /<img\b[^>]*?(?<![\w-])src\s*=\s*["'](https?:\/\/[^"']+)["'][^>]*>/gi;
|
|
8229
8252
|
async function downloadAndRewriteUrls(urlSet, html, remoteDir, warnLabel, logLabel, extraRewrite) {
|
|
8230
8253
|
if (urlSet.size === 0) return { html, remoteMediaAssets: /* @__PURE__ */ new Map() };
|
|
8231
|
-
if (!
|
|
8254
|
+
if (!existsSync11(remoteDir)) mkdirSync9(remoteDir, { recursive: true });
|
|
8232
8255
|
const urlToLocal = /* @__PURE__ */ new Map();
|
|
8233
8256
|
await Promise.all(
|
|
8234
8257
|
[...urlSet].map(async (url) => {
|
|
@@ -8260,7 +8283,7 @@ async function downloadAndRewriteUrls(urlSet, html, remoteDir, warnLabel, logLab
|
|
|
8260
8283
|
result = result.replaceAll(`"${url}"`, `"${relPath}"`).replaceAll(`'${url}'`, `'${relPath}'`);
|
|
8261
8284
|
if (extraRewrite) result = extraRewrite(result, url, relPath);
|
|
8262
8285
|
}
|
|
8263
|
-
defaultLogger.
|
|
8286
|
+
defaultLogger.debug(`[Compiler] ${logLabel} ${urlToLocal.size} to ${REMOTE_MEDIA_SUBDIR}/`);
|
|
8264
8287
|
return { html: result, remoteMediaAssets };
|
|
8265
8288
|
}
|
|
8266
8289
|
async function localizeRemoteMediaSources(html, downloadDir) {
|
|
@@ -8397,7 +8420,7 @@ async function inlineExternalFontStylesheets(html) {
|
|
|
8397
8420
|
${fontFaceBlocks.join("\n")}
|
|
8398
8421
|
</style>`;
|
|
8399
8422
|
result = result.replace(fullMatch, inlineStyle);
|
|
8400
|
-
defaultLogger.
|
|
8423
|
+
defaultLogger.debug("[Compiler] Inlined external @font-face rule(s)", {
|
|
8401
8424
|
count: fontFaceBlocks.length,
|
|
8402
8425
|
urlFingerprint: identity.urlFingerprint,
|
|
8403
8426
|
host: identity.host
|
|
@@ -8410,14 +8433,14 @@ function projectStylesheetFontFamilies(html, projectDir) {
|
|
|
8410
8433
|
for (const [tag] of html.matchAll(/<link\b[^>]*\brel=["']stylesheet["'][^>]*>/gi)) {
|
|
8411
8434
|
const href = /\bhref=["']([^"']+)["']/i.exec(tag)?.[1];
|
|
8412
8435
|
if (!href || /^(?:[a-z][a-z\d+.-]*:|\/\/)/i.test(href)) continue;
|
|
8413
|
-
const sheet = resolve7(projectDir,
|
|
8414
|
-
if (!isPathInside2(sheet, projectDir) || !
|
|
8436
|
+
const sheet = resolve7(projectDir, decodedUrlPath(href).replace(/^(?:\.?\/)+/, ""));
|
|
8437
|
+
if (!isPathInside2(sheet, projectDir) || !existsSync11(sheet)) continue;
|
|
8415
8438
|
for (const face of extractFontFaceBlocks(readFileSync8(sheet, "utf8"))) {
|
|
8416
8439
|
const family = /font-family\s*:\s*([^;}]+)/i.exec(face)?.[1]?.trim().replace(/^['"]|['"]$/g, "");
|
|
8417
8440
|
const shipsFile = [...face.matchAll(LOCAL_FONTFACE_URL_RE)].some(([, url = ""]) => {
|
|
8418
|
-
const path =
|
|
8441
|
+
const path = decodedUrlPath(url);
|
|
8419
8442
|
const file = path.startsWith("/") ? resolve7(projectDir, `.${path}`) : resolve7(dirname8(sheet), path);
|
|
8420
|
-
return isPathInside2(file, projectDir) &&
|
|
8443
|
+
return isPathInside2(file, projectDir) && existsSync11(file);
|
|
8421
8444
|
});
|
|
8422
8445
|
if (family && shipsFile) families.push(family);
|
|
8423
8446
|
}
|
|
@@ -8516,7 +8539,7 @@ async function embedLocalFontFaces(html, projectDir) {
|
|
|
8516
8539
|
const font = await readLocalFont(absPath);
|
|
8517
8540
|
if (font.kind === "file-backed") {
|
|
8518
8541
|
fileBackedAbsolutePaths.add(absPath);
|
|
8519
|
-
defaultLogger.
|
|
8542
|
+
defaultLogger.debug(
|
|
8520
8543
|
`[Compiler] Kept large local font file-backed: ${localPath} (> ${(MAX_LOCAL_FONT_DATA_URI_BYTES / 1024 / 1024).toFixed(1)} MB)`
|
|
8521
8544
|
);
|
|
8522
8545
|
embeddedPaths.add(localPath);
|
|
@@ -8524,7 +8547,7 @@ async function embedLocalFontFaces(html, projectDir) {
|
|
|
8524
8547
|
}
|
|
8525
8548
|
dataUri = await toDataUri(font.buffer, ext, { compressToWoff2: false });
|
|
8526
8549
|
dataUriByAbsolutePath.set(absPath, dataUri);
|
|
8527
|
-
defaultLogger.
|
|
8550
|
+
defaultLogger.debug(
|
|
8528
8551
|
`[Compiler] Embedded local font file: ${localPath} (${(font.buffer.length / 1024).toFixed(0)} KB \u2192 data URI)`
|
|
8529
8552
|
);
|
|
8530
8553
|
}
|
|
@@ -8552,14 +8575,17 @@ function renderGsapDist() {
|
|
|
8552
8575
|
}
|
|
8553
8576
|
function rewriteUnresolvableGsapToCdn(html, projectDir, compSrcPath) {
|
|
8554
8577
|
let gsapDist;
|
|
8555
|
-
const exists = (path) =>
|
|
8578
|
+
const exists = (path) => {
|
|
8579
|
+
const file = resolve7(projectDir, path);
|
|
8580
|
+
return !namesAnotherNetworkRoot2(projectDir, file) && existsSync11(file);
|
|
8581
|
+
};
|
|
8556
8582
|
return html.replace(
|
|
8557
8583
|
/(<script\b[^>]*\bsrc=["'])([^"']*gsap[^"']*\/dist\/([^"']+))(["'][^>]*>)/gi,
|
|
8558
8584
|
(full, prefix, src, file, suffix) => {
|
|
8559
8585
|
if (/^https?:\/\//i.test(src)) return full;
|
|
8560
8586
|
if (exists(compSrcPath ? rewriteAssetPath(compSrcPath, src, exists) : src)) return full;
|
|
8561
8587
|
gsapDist ??= renderGsapDist();
|
|
8562
|
-
defaultLogger.
|
|
8588
|
+
defaultLogger.debug(`[Compiler] Rewriting missing gsap script: ${src} \u2192 ${gsapDist}${file}`);
|
|
8563
8589
|
return `${prefix}${gsapDist}${file}${suffix}`;
|
|
8564
8590
|
}
|
|
8565
8591
|
);
|
|
@@ -8569,7 +8595,7 @@ function rebaseDirectEntryAssetPaths(html, projectDir, htmlPath) {
|
|
|
8569
8595
|
const entryPath = relative2(projectDir, htmlPath).replace(/\\/g, "/");
|
|
8570
8596
|
if (!entryPath.includes("/")) return html;
|
|
8571
8597
|
const { document: document2 } = parseHTML5(html);
|
|
8572
|
-
const assetExists = (path) =>
|
|
8598
|
+
const assetExists = (path) => existsSync11(resolve7(projectDir, path));
|
|
8573
8599
|
rewriteAssetPaths(
|
|
8574
8600
|
document2.querySelectorAll("[src], [href], [srcset]"),
|
|
8575
8601
|
entryPath,
|
|
@@ -8589,11 +8615,29 @@ function rebaseDirectEntryAssetPaths(html, projectDir, htmlPath) {
|
|
|
8589
8615
|
}
|
|
8590
8616
|
return document2.toString();
|
|
8591
8617
|
}
|
|
8618
|
+
function bindVariableMediaSources(html, variables) {
|
|
8619
|
+
if (!html.includes("data-var-src")) return html;
|
|
8620
|
+
const { document: document2 } = parseHTML5(html);
|
|
8621
|
+
const declared = {};
|
|
8622
|
+
for (const el of document2.querySelectorAll("[data-composition-variables]")) {
|
|
8623
|
+
Object.assign(declared, readDeclaredDefaults(el));
|
|
8624
|
+
}
|
|
8625
|
+
const values = { ...declared, ...variables };
|
|
8626
|
+
let changed = false;
|
|
8627
|
+
for (const el of document2.querySelectorAll("video[data-var-src], audio[data-var-src]")) {
|
|
8628
|
+
if (el.closest("[data-variable-values]")) continue;
|
|
8629
|
+
const src = boundMediaSrc(el, values);
|
|
8630
|
+
if (src === null || el.getAttribute("src") === src) continue;
|
|
8631
|
+
el.setAttribute("src", src);
|
|
8632
|
+
changed = true;
|
|
8633
|
+
}
|
|
8634
|
+
return changed ? document2.toString() : html;
|
|
8635
|
+
}
|
|
8592
8636
|
async function compileForRender(projectDir, htmlPath, downloadDir, options = {}) {
|
|
8593
8637
|
const entryHtml = rebaseDirectEntryAssetPaths(readTextFile(htmlPath), projectDir, htmlPath);
|
|
8594
|
-
const rawHtml =
|
|
8595
|
-
rewriteUnresolvableGsapToCdn(entryHtml, projectDir),
|
|
8596
|
-
|
|
8638
|
+
const rawHtml = bindVariableMediaSources(
|
|
8639
|
+
normalizeCompositionSrcs(rewriteUnresolvableGsapToCdn(entryHtml, projectDir), projectDir),
|
|
8640
|
+
options.variables ?? {}
|
|
8597
8641
|
);
|
|
8598
8642
|
assertSubCompositionsUsable(rawHtml, projectDir);
|
|
8599
8643
|
const probes = /* @__PURE__ */ new Map();
|
|
@@ -8677,7 +8721,7 @@ async function compileForRender(projectDir, htmlPath, downloadDir, options = {})
|
|
|
8677
8721
|
timeoutMs: options.ffmpegProcessTimeout
|
|
8678
8722
|
});
|
|
8679
8723
|
if (preparedHeifImages.length > 0) {
|
|
8680
|
-
defaultLogger.
|
|
8724
|
+
defaultLogger.debug(`[Compiler] Converted ${preparedHeifImages.length} HEIC image(s) to JPEG`);
|
|
8681
8725
|
}
|
|
8682
8726
|
const gifSourceAssets = new Map(remoteImageAssets);
|
|
8683
8727
|
const {
|
|
@@ -8692,7 +8736,7 @@ async function compileForRender(projectDir, htmlPath, downloadDir, options = {})
|
|
|
8692
8736
|
timeoutMs: options.ffmpegProcessTimeout
|
|
8693
8737
|
});
|
|
8694
8738
|
if (preparedGifs.length > 0) {
|
|
8695
|
-
defaultLogger.
|
|
8739
|
+
defaultLogger.debug(`[Compiler] Prepared ${preparedGifs.length} animated GIF input(s) as WebM`);
|
|
8696
8740
|
}
|
|
8697
8741
|
const embeddedHtml = await embedLocalFontFaces(htmlWithPreparedGifs, projectDir);
|
|
8698
8742
|
const { html, externalAssets } = collectExternalAssets(embeddedHtml, projectDir);
|
|
@@ -8720,7 +8764,7 @@ async function compileForRender(projectDir, htmlPath, downloadDir, options = {})
|
|
|
8720
8764
|
for (const video of videos) {
|
|
8721
8765
|
if (isHttpUrl(video.src)) continue;
|
|
8722
8766
|
const videoPath = resolve7(projectDir, video.src);
|
|
8723
|
-
if (advised.has(videoPath)) continue;
|
|
8767
|
+
if (advised.has(videoPath) || namesAnotherNetworkRoot2(projectDir, videoPath)) continue;
|
|
8724
8768
|
advised.add(videoPath);
|
|
8725
8769
|
const reencode = `ffmpeg -i "${video.src}" -c:v libx264 -r 30 -g 30 -keyint_min 30 -movflags +faststart -c:a copy output.mp4`;
|
|
8726
8770
|
(async () => {
|
|
@@ -9139,7 +9183,7 @@ function resolveEntryHtmlPath(input) {
|
|
|
9139
9183
|
const rawEntry = readTextFile2(htmlPath);
|
|
9140
9184
|
if (entryFile === "index.html" || !isTemplateEntry(rawEntry)) return htmlPath;
|
|
9141
9185
|
const projectIndexPath = join19(projectDir, "index.html");
|
|
9142
|
-
if (!
|
|
9186
|
+
if (!existsSync12(projectIndexPath)) {
|
|
9143
9187
|
throw new Error(
|
|
9144
9188
|
`Template entry file "${entryFile}" requires a project index.html to extract its render shell.`
|
|
9145
9189
|
);
|
|
@@ -9447,8 +9491,15 @@ function hasRuntimeMediaChanges(html) {
|
|
|
9447
9491
|
}
|
|
9448
9492
|
return false;
|
|
9449
9493
|
}
|
|
9494
|
+
function checksVariablesInBrowser(config) {
|
|
9495
|
+
return config.strictVariables === true && Object.keys(config.variables ?? {}).length > 0;
|
|
9496
|
+
}
|
|
9497
|
+
function strictVariablesAttestation(config, probeSession) {
|
|
9498
|
+
if (config.strictVariables !== true) return void 0;
|
|
9499
|
+
return !checksVariablesInBrowser(config) || probeSession?.strictVariablesChecked === true;
|
|
9500
|
+
}
|
|
9450
9501
|
function probeRequiresBrowser(args) {
|
|
9451
|
-
return args.durationSeconds <= 0 || args.unresolvedCompositionCount > 0 || args.hasAutoStart || args.hasScriptedAudio || args.hasVariableMedia || args.hasInsertedMedia;
|
|
9502
|
+
return args.requiresVariablesCheck === true || args.durationSeconds <= 0 || args.unresolvedCompositionCount > 0 || args.hasAutoStart || args.hasScriptedAudio || args.hasVariableMedia || args.hasInsertedMedia;
|
|
9452
9503
|
}
|
|
9453
9504
|
function reportedLengthSource(source) {
|
|
9454
9505
|
if (!source) return null;
|
|
@@ -9472,7 +9523,8 @@ async function runProbeStage(input) {
|
|
|
9472
9523
|
height,
|
|
9473
9524
|
needsAlpha,
|
|
9474
9525
|
deviceScaleFactor,
|
|
9475
|
-
subTimelineWaitMemo
|
|
9526
|
+
subTimelineWaitMemo,
|
|
9527
|
+
staticDedupMemo
|
|
9476
9528
|
} = input;
|
|
9477
9529
|
let { compiled } = input;
|
|
9478
9530
|
const probeCfg = cfg.forceScreenshot === forceScreenshot ? cfg : { ...cfg, forceScreenshot };
|
|
@@ -9495,7 +9547,8 @@ async function runProbeStage(input) {
|
|
|
9495
9547
|
hasAutoStart,
|
|
9496
9548
|
hasScriptedAudio,
|
|
9497
9549
|
hasVariableMedia,
|
|
9498
|
-
hasInsertedMedia
|
|
9550
|
+
hasInsertedMedia,
|
|
9551
|
+
requiresVariablesCheck: checksVariablesInBrowser(job.config)
|
|
9499
9552
|
});
|
|
9500
9553
|
try {
|
|
9501
9554
|
if (needsBrowser) {
|
|
@@ -9529,11 +9582,16 @@ async function runProbeStage(input) {
|
|
|
9529
9582
|
job.config.quality
|
|
9530
9583
|
),
|
|
9531
9584
|
variables: job.config.variables,
|
|
9585
|
+
strictVariables: job.config.strictVariables,
|
|
9532
9586
|
deviceScaleFactor,
|
|
9533
9587
|
motionBlur,
|
|
9534
9588
|
pageMotionBlur: job.config.pageMotionBlur,
|
|
9535
9589
|
requiresWebGpu: compositionRequiresWebGpu(compiled.html),
|
|
9536
|
-
subTimelineWaitMemo
|
|
9590
|
+
subTimelineWaitMemo,
|
|
9591
|
+
staticDedupMemo,
|
|
9592
|
+
compositionHash: computeCompositionObservabilityHash(compiled.html),
|
|
9593
|
+
deferStaticDedup: true,
|
|
9594
|
+
onStaticDedupActivity: () => noteStaticDedupActivity(job)
|
|
9537
9595
|
};
|
|
9538
9596
|
const PROBE_MAX_ATTEMPTS = 2;
|
|
9539
9597
|
for (let attempt = 1; attempt <= PROBE_MAX_ATTEMPTS; attempt++) {
|
|
@@ -9930,6 +9988,7 @@ async function runProbeStage(input) {
|
|
|
9930
9988
|
}
|
|
9931
9989
|
}
|
|
9932
9990
|
return {
|
|
9991
|
+
strictVariablesChecked: strictVariablesAttestation(job.config, probeSession),
|
|
9933
9992
|
compiled,
|
|
9934
9993
|
fileServer,
|
|
9935
9994
|
probeSession,
|
|
@@ -9990,7 +10049,7 @@ function validateRenderDuration(input) {
|
|
|
9990
10049
|
}
|
|
9991
10050
|
|
|
9992
10051
|
// src/services/render/stages/extractVideosStage.ts
|
|
9993
|
-
import { existsSync as
|
|
10052
|
+
import { existsSync as existsSync13 } from "node:fs";
|
|
9994
10053
|
import { join as join21 } from "node:path";
|
|
9995
10054
|
import {
|
|
9996
10055
|
classifyVideoExtractionError,
|
|
@@ -10260,7 +10319,7 @@ async function runExtractVideosStage(input) {
|
|
|
10260
10319
|
const probeFailures = await Promise.all(
|
|
10261
10320
|
composition.videos.map(async (v) => {
|
|
10262
10321
|
const videoPath = resolveProjectRelativeSrc3(v.src, projectDir, compiledDir);
|
|
10263
|
-
if (!
|
|
10322
|
+
if (!existsSync13(videoPath)) return null;
|
|
10264
10323
|
try {
|
|
10265
10324
|
const attempted = extractionPolicy.maxTransientRetries === 0 ? { result: await extractMediaMetadata3(videoPath), retries: 0 } : await runVideoExtractionWithRetry2(() => extractMediaMetadata3(videoPath), {
|
|
10266
10325
|
signal: abortSignal,
|
|
@@ -10298,7 +10357,7 @@ async function runExtractVideosStage(input) {
|
|
|
10298
10357
|
const probed = await Promise.all(
|
|
10299
10358
|
composition.images.map(async (img) => {
|
|
10300
10359
|
const imgPath = resolveProjectRelativeSrc3(img.src, projectDir, compiledDir);
|
|
10301
|
-
if (!
|
|
10360
|
+
if (!existsSync13(imgPath)) return null;
|
|
10302
10361
|
const colorSpace = await probeColorSpaceSafely(imgPath, log);
|
|
10303
10362
|
if (isHdrColorSpace2(colorSpace)) {
|
|
10304
10363
|
nativeHdrImageIds.add(img.id);
|
|
@@ -10418,7 +10477,7 @@ async function appendVideoAudioFromProbe(input) {
|
|
|
10418
10477
|
videos.map(async (video) => {
|
|
10419
10478
|
const path = isHttpUrl2(video.src) ? video.src : resolveProjectRelativeSrc3(video.src, projectDir, compiledDir);
|
|
10420
10479
|
const readFrom = urlByAbsentLocalPath?.get(path) ?? path;
|
|
10421
|
-
if (!isHttpUrl2(readFrom) && !
|
|
10480
|
+
if (!isHttpUrl2(readFrom) && !existsSync13(readFrom)) return null;
|
|
10422
10481
|
const metadata = await extractMediaMetadata3(readFrom);
|
|
10423
10482
|
const window2 = await resolveFinalFrameExtractionWindow2(
|
|
10424
10483
|
readFrom,
|
|
@@ -10438,7 +10497,7 @@ async function appendVideoAudioFromProbe(input) {
|
|
|
10438
10497
|
}
|
|
10439
10498
|
|
|
10440
10499
|
// src/services/render/videoLayerPassthroughPlan.ts
|
|
10441
|
-
import { existsSync as
|
|
10500
|
+
import { existsSync as existsSync14 } from "node:fs";
|
|
10442
10501
|
import {
|
|
10443
10502
|
buildVideoLayerInput,
|
|
10444
10503
|
isHttpUrl as isHttpUrl3,
|
|
@@ -10506,7 +10565,7 @@ async function planVideoLayerPassthrough(input) {
|
|
|
10506
10565
|
const { video } = q;
|
|
10507
10566
|
if (isHttpUrl3(video.src)) return { reason: "remote_source" };
|
|
10508
10567
|
const path = resolveProjectRelativeSrc4(video.src, input.projectDir, input.compiledDir);
|
|
10509
|
-
if (!
|
|
10568
|
+
if (!existsSync14(path)) return { reason: "source_missing" };
|
|
10510
10569
|
const layout = await probeVideoLayout(input.page, video.id, input.canvas, input.duration);
|
|
10511
10570
|
if ("reason" in layout) return layout;
|
|
10512
10571
|
const layer = await buildVideoLayerInput(
|
|
@@ -10521,7 +10580,7 @@ async function planVideoLayerPassthrough(input) {
|
|
|
10521
10580
|
}
|
|
10522
10581
|
|
|
10523
10582
|
// src/services/render/stages/audioStage.ts
|
|
10524
|
-
import { existsSync as
|
|
10583
|
+
import { existsSync as existsSync16 } from "node:fs";
|
|
10525
10584
|
import { join as join24 } from "node:path";
|
|
10526
10585
|
import {
|
|
10527
10586
|
MIXED_AUDIO_FILENAME,
|
|
@@ -10532,7 +10591,7 @@ import {
|
|
|
10532
10591
|
} from "@hyperframes/engine";
|
|
10533
10592
|
|
|
10534
10593
|
// src/services/render/audioDeliveryLimit.ts
|
|
10535
|
-
import { existsSync as
|
|
10594
|
+
import { existsSync as existsSync15 } from "node:fs";
|
|
10536
10595
|
import { dirname as dirname10, join as join23 } from "node:path";
|
|
10537
10596
|
import {
|
|
10538
10597
|
applyAudioFxChain,
|
|
@@ -11041,7 +11100,7 @@ async function limitDeliveryPeaks(input, deps = {
|
|
|
11041
11100
|
applyChain: applyAudioFxChain,
|
|
11042
11101
|
encode: encodeAac2,
|
|
11043
11102
|
rename: renameWithRetry6,
|
|
11044
|
-
sourceExists:
|
|
11103
|
+
sourceExists: existsSync15
|
|
11045
11104
|
}) {
|
|
11046
11105
|
const { audioPath, sourcePath, signal, timeoutMs } = input;
|
|
11047
11106
|
if (!deps.sourceExists(sourcePath)) return { success: true };
|
|
@@ -11136,7 +11195,7 @@ async function runAudioStageScoped(input) {
|
|
|
11136
11195
|
);
|
|
11137
11196
|
audioLoweredDb = guard.loweredDb;
|
|
11138
11197
|
input.log?.info("[audio] phases", { ...result.audioPhaseMs, guard: Date.now() - guardStart });
|
|
11139
|
-
if (input.keepDeliverySource && !guard.sourceStale &&
|
|
11198
|
+
if (input.keepDeliverySource && !guard.sourceStale && existsSync16(pcmSourcePath)) {
|
|
11140
11199
|
deliverySourcePath = pcmSourcePath;
|
|
11141
11200
|
}
|
|
11142
11201
|
}
|
|
@@ -11264,7 +11323,7 @@ async function mixAudioForDelivery(input, duration, pcmSourcePath) {
|
|
|
11264
11323
|
}
|
|
11265
11324
|
|
|
11266
11325
|
// src/services/render/stages/captureStage.ts
|
|
11267
|
-
import { existsSync as
|
|
11326
|
+
import { existsSync as existsSync17, readdirSync as readdirSync4, statfsSync as statfsSync2 } from "node:fs";
|
|
11268
11327
|
import { join as join25 } from "node:path";
|
|
11269
11328
|
import {
|
|
11270
11329
|
classifyCaptureFailure as classifyCaptureFailure2,
|
|
@@ -11335,7 +11394,7 @@ function diskCaptureShortfallError(needBytes, freeBytes, framesDir, basis, remed
|
|
|
11335
11394
|
}
|
|
11336
11395
|
function measureCaptureFrameBytes(workDir, framesDir) {
|
|
11337
11396
|
let total = sampleDirectoryBytes(framesDir);
|
|
11338
|
-
if (!
|
|
11397
|
+
if (!existsSync17(workDir)) return total;
|
|
11339
11398
|
for (const attempt of readdirSync4(workDir)) {
|
|
11340
11399
|
if (/^retry-\d+-batch-\d+-worker-\d+$/.test(attempt)) {
|
|
11341
11400
|
total += sampleDirectoryBytes(join25(workDir, attempt));
|
|
@@ -11517,7 +11576,7 @@ async function runSequentialDiskCapture(input, captureOptions, captureCfg, check
|
|
|
11517
11576
|
captureBeyondViewport = session.options.captureBeyondViewport;
|
|
11518
11577
|
try {
|
|
11519
11578
|
if (probeSession) {
|
|
11520
|
-
prepareCaptureSessionForReuse3(session, framesDir, videoInjector);
|
|
11579
|
+
await prepareCaptureSessionForReuse3(session, framesDir, videoInjector);
|
|
11521
11580
|
probeSession = null;
|
|
11522
11581
|
}
|
|
11523
11582
|
await ensureSessionReady(session, {
|
|
@@ -11642,7 +11701,7 @@ async function captureSessionFrames(session, { input, rangeStart, rangeEnd, resu
|
|
|
11642
11701
|
}
|
|
11643
11702
|
|
|
11644
11703
|
// src/services/render/stages/captureHdrStage.ts
|
|
11645
|
-
import { existsSync as
|
|
11704
|
+
import { existsSync as existsSync19, mkdirSync as mkdirSync10 } from "node:fs";
|
|
11646
11705
|
import { join as join29 } from "node:path";
|
|
11647
11706
|
import {
|
|
11648
11707
|
closeCaptureSession as closeCaptureSession7,
|
|
@@ -11888,7 +11947,7 @@ import { Worker } from "node:worker_threads";
|
|
|
11888
11947
|
import { fileURLToPath as fileURLToPath3, pathToFileURL } from "node:url";
|
|
11889
11948
|
import { dirname as dirname11, join as join27 } from "node:path";
|
|
11890
11949
|
import { createRequire } from "node:module";
|
|
11891
|
-
import { existsSync as
|
|
11950
|
+
import { existsSync as existsSync18 } from "node:fs";
|
|
11892
11951
|
import { cpus as cpus2 } from "node:os";
|
|
11893
11952
|
function resolveWorkerEntry(explicit) {
|
|
11894
11953
|
if (explicit && explicit.length > 0) {
|
|
@@ -11901,7 +11960,7 @@ function resolveWorkerEntry(explicit) {
|
|
|
11901
11960
|
}
|
|
11902
11961
|
const moduleDir = dirname11(fileURLToPath3(import.meta.url));
|
|
11903
11962
|
const jsPath = join27(moduleDir, "shaderTransitionWorker.js");
|
|
11904
|
-
if (
|
|
11963
|
+
if (existsSync18(jsPath)) return { path: jsPath, isTs: false };
|
|
11905
11964
|
const tsPath = join27(moduleDir, "shaderTransitionWorker.ts");
|
|
11906
11965
|
return { path: tsPath, isTs: true };
|
|
11907
11966
|
}
|
|
@@ -12462,7 +12521,7 @@ async function runCaptureHdrStage(input) {
|
|
|
12462
12521
|
}
|
|
12463
12522
|
const debugDumpEnabled = process.env.KEEP_TEMP === "1";
|
|
12464
12523
|
const debugDumpDir = debugDumpEnabled ? join29(framesDir, "debug-composite") : null;
|
|
12465
|
-
if (debugDumpDir && !
|
|
12524
|
+
if (debugDumpDir && !existsSync19(debugDumpDir)) {
|
|
12466
12525
|
mkdirSync10(debugDumpDir, { recursive: true });
|
|
12467
12526
|
}
|
|
12468
12527
|
const compositeTransfer = resolveCompositeTransfer(hasHdrContent, effectiveHdr);
|
|
@@ -12619,7 +12678,7 @@ async function runCaptureHdrStage(input) {
|
|
|
12619
12678
|
// src/services/render/stages/encodeStage.ts
|
|
12620
12679
|
import {
|
|
12621
12680
|
copyFileSync as copyFileSync4,
|
|
12622
|
-
existsSync as
|
|
12681
|
+
existsSync as existsSync20,
|
|
12623
12682
|
mkdirSync as mkdirSync11,
|
|
12624
12683
|
readdirSync as readdirSync5,
|
|
12625
12684
|
readFileSync as readFileSync9,
|
|
@@ -12753,7 +12812,7 @@ async function encodeGifFromDir(framesDir, framePattern, outputPath, input) {
|
|
|
12753
12812
|
const failure = await reencodeWithClearedWholeFrames(argsInput, run, startTime);
|
|
12754
12813
|
if (failure) return failure;
|
|
12755
12814
|
}
|
|
12756
|
-
const fileSize =
|
|
12815
|
+
const fileSize = existsSync20(outputPath) ? statSync8(outputPath).size : 0;
|
|
12757
12816
|
return {
|
|
12758
12817
|
success: true,
|
|
12759
12818
|
outputPath,
|
|
@@ -12914,7 +12973,7 @@ async function runEncodeStage(input) {
|
|
|
12914
12973
|
const stage5Start = Date.now();
|
|
12915
12974
|
if (isPngSequence) {
|
|
12916
12975
|
const encoded = startEncodeProgress(job, "Writing PNG sequence", onProgress);
|
|
12917
|
-
if (!
|
|
12976
|
+
if (!existsSync20(outputPath)) mkdirSync11(outputPath, { recursive: true });
|
|
12918
12977
|
const captured = readdirSync5(framesDir).filter((name) => name.endsWith(".png")).sort();
|
|
12919
12978
|
if (captured.length === 0) {
|
|
12920
12979
|
throw new Error(
|
|
@@ -12925,7 +12984,7 @@ async function runEncodeStage(input) {
|
|
|
12925
12984
|
const dst = join30(outputPath, formatExportFrameName(i, "png"));
|
|
12926
12985
|
copyFileSync4(join30(framesDir, name), dst);
|
|
12927
12986
|
});
|
|
12928
|
-
if (hasAudio && audioOutputPath &&
|
|
12987
|
+
if (hasAudio && audioOutputPath && existsSync20(audioOutputPath)) {
|
|
12929
12988
|
copyFileSync4(audioOutputPath, join30(outputPath, MIXED_AUDIO_FILENAME2));
|
|
12930
12989
|
log.info(
|
|
12931
12990
|
`[Render] png-sequence: ${MIXED_AUDIO_FILENAME2} sidecar written to ${outputPath}/${MIXED_AUDIO_FILENAME2}`
|
|
@@ -13314,7 +13373,7 @@ function findMissingFrameRanges(totalFrames, framesDir, frameExt) {
|
|
|
13314
13373
|
let rangeStart = null;
|
|
13315
13374
|
for (let frameIndex = 0; frameIndex < totalFrames; frameIndex++) {
|
|
13316
13375
|
const framePath = join31(framesDir, formatCaptureFrameName(frameIndex, frameExt));
|
|
13317
|
-
const missing = !
|
|
13376
|
+
const missing = !existsSync21(framePath) || statSync9(framePath).size <= 8;
|
|
13318
13377
|
if (missing && rangeStart === null) {
|
|
13319
13378
|
rangeStart = frameIndex;
|
|
13320
13379
|
} else if (!missing && rangeStart !== null) {
|
|
@@ -13421,7 +13480,8 @@ function frameStallRule(job, totalFrames, probeStartupMs) {
|
|
|
13421
13480
|
complete: () => (job.framesRendered ?? 0) >= totalFrames,
|
|
13422
13481
|
tailMs: Math.max(TAIL_STALL_MS, noProgressMs),
|
|
13423
13482
|
detail: () => describeWorkerPhases(job),
|
|
13424
|
-
attemptOpened: () => forgetWorkerPhases(job)
|
|
13483
|
+
attemptOpened: () => forgetWorkerPhases(job),
|
|
13484
|
+
activity: () => staticDedupActivity(job)
|
|
13425
13485
|
};
|
|
13426
13486
|
}
|
|
13427
13487
|
function isRecoverableParallelCaptureError(error) {
|
|
@@ -13446,7 +13506,7 @@ function countCapturedFrames(totalFrames, framesDir, frameExt) {
|
|
|
13446
13506
|
let captured = 0;
|
|
13447
13507
|
for (let frameIndex = 0; frameIndex < totalFrames; frameIndex++) {
|
|
13448
13508
|
const framePath = join31(framesDir, formatCaptureFrameName(frameIndex, frameExt));
|
|
13449
|
-
if (
|
|
13509
|
+
if (existsSync21(framePath)) captured++;
|
|
13450
13510
|
}
|
|
13451
13511
|
return captured;
|
|
13452
13512
|
}
|
|
@@ -14112,7 +14172,7 @@ async function executeRenderJob(job, projectDir, outputPath, progressSink, abort
|
|
|
14112
14172
|
validateChromaSubsamplingConfig(job.config);
|
|
14113
14173
|
const debugDir = resolveRenderDebugDir();
|
|
14114
14174
|
const outputDir = dirname13(outputPath);
|
|
14115
|
-
if (!
|
|
14175
|
+
if (!existsSync21(outputDir)) mkdirSync12(outputDir, { recursive: true });
|
|
14116
14176
|
const workDir = job.config.debug ? join31(debugDir, job.id) : createRenderWorkDir(resolveRenderWorkDirPrefix(outputPath, job.id), outputDir);
|
|
14117
14177
|
const pipelineStart = Date.now();
|
|
14118
14178
|
const baseLog = job.config.logger ?? defaultLogger;
|
|
@@ -14254,7 +14314,7 @@ async function executeRenderPipeline(input) {
|
|
|
14254
14314
|
job.startedAt = /* @__PURE__ */ new Date();
|
|
14255
14315
|
assertNotAborted();
|
|
14256
14316
|
assertConfiguredFfmpegBinariesExist();
|
|
14257
|
-
if (!
|
|
14317
|
+
if (!existsSync21(workDir)) mkdirSync12(workDir, { recursive: true });
|
|
14258
14318
|
if (job.config.debug) {
|
|
14259
14319
|
log.info("[Render] Debug artifacts enabled", { workDir, logPath });
|
|
14260
14320
|
}
|
|
@@ -14284,7 +14344,7 @@ async function executeRenderPipeline(input) {
|
|
|
14284
14344
|
});
|
|
14285
14345
|
const entryFile = job.config.entryFile || "index.html";
|
|
14286
14346
|
const htmlPath = join31(projectDir, entryFile);
|
|
14287
|
-
if (!
|
|
14347
|
+
if (!existsSync21(htmlPath)) {
|
|
14288
14348
|
throw new Error(`Entry file not found: ${htmlPath}`);
|
|
14289
14349
|
}
|
|
14290
14350
|
assertNotAborted();
|
|
@@ -14376,6 +14436,7 @@ async function executeRenderPipeline(input) {
|
|
|
14376
14436
|
(result) => Object.assign(job, result)
|
|
14377
14437
|
);
|
|
14378
14438
|
const subTimelineWaitMemo = {};
|
|
14439
|
+
const staticDedupMemo = {};
|
|
14379
14440
|
const probeResult = await observeRenderStage(
|
|
14380
14441
|
observability,
|
|
14381
14442
|
"browser_probe",
|
|
@@ -14396,6 +14457,7 @@ async function executeRenderPipeline(input) {
|
|
|
14396
14457
|
needsAlpha,
|
|
14397
14458
|
deviceScaleFactor,
|
|
14398
14459
|
subTimelineWaitMemo,
|
|
14460
|
+
staticDedupMemo,
|
|
14399
14461
|
recordReferenceBackground
|
|
14400
14462
|
}),
|
|
14401
14463
|
// Browser probe is pre-capture; report `browser calibrating` so a
|
|
@@ -14407,6 +14469,7 @@ async function executeRenderPipeline(input) {
|
|
|
14407
14469
|
compositionHash = computeCompositionObservabilityHash(compiled.html);
|
|
14408
14470
|
fileServer = probeResult.fileServer;
|
|
14409
14471
|
probeSession = probeResult.probeSession;
|
|
14472
|
+
job.strictVariablesChecked = probeResult.strictVariablesChecked;
|
|
14410
14473
|
lastBrowserConsole = probeResult.lastBrowserConsole;
|
|
14411
14474
|
let resolvedCaptureBeyondViewport = probeSession?.options.captureBeyondViewport;
|
|
14412
14475
|
if (resolvedCaptureBeyondViewport !== void 0) {
|
|
@@ -14628,7 +14691,7 @@ async function executeRenderPipeline(input) {
|
|
|
14628
14691
|
throw new Error("File server failed to initialize before frame capture");
|
|
14629
14692
|
}
|
|
14630
14693
|
const framesDir = join31(workDir, "captured-frames");
|
|
14631
|
-
if (!
|
|
14694
|
+
if (!existsSync21(framesDir)) mkdirSync12(framesDir, { recursive: true });
|
|
14632
14695
|
updateJobStatus(job, "rendering", "Checking browser GPU", 25, onProgress, {
|
|
14633
14696
|
code: "start_browsers"
|
|
14634
14697
|
});
|
|
@@ -14687,6 +14750,9 @@ async function executeRenderPipeline(input) {
|
|
|
14687
14750
|
videoMetadataHints,
|
|
14688
14751
|
skipReadinessVideoIds: videoReadinessSkipIds,
|
|
14689
14752
|
subTimelineWaitMemo,
|
|
14753
|
+
staticDedupMemo,
|
|
14754
|
+
compositionHash,
|
|
14755
|
+
onStaticDedupActivity: () => noteStaticDedupActivity(job),
|
|
14690
14756
|
// Probe-resolved duration: drawElement self-verification derives its
|
|
14691
14757
|
// sample frame indices from this so they land inside the drained range.
|
|
14692
14758
|
compositionDurationSeconds: job.duration,
|
|
@@ -16033,7 +16099,7 @@ async function executeRenderPipeline(input) {
|
|
|
16033
16099
|
})
|
|
16034
16100
|
);
|
|
16035
16101
|
const totalElapsed = Date.now() - pipelineStart;
|
|
16036
|
-
const tmpPeakBytes =
|
|
16102
|
+
const tmpPeakBytes = existsSync21(workDir) ? sampleDirectoryBytes(workDir) : 0;
|
|
16037
16103
|
recordTransientRetryObservability();
|
|
16038
16104
|
observability.checkpoint("pipeline", "artifact validated", { totalElapsedMs: totalElapsed });
|
|
16039
16105
|
const observabilitySummary = observability.summary({
|
|
@@ -16114,7 +16180,7 @@ async function executeRenderPipeline(input) {
|
|
|
16114
16180
|
}
|
|
16115
16181
|
}
|
|
16116
16182
|
if (job.config.debug) {
|
|
16117
|
-
if (!isPngSequence && !isHls &&
|
|
16183
|
+
if (!isPngSequence && !isHls && existsSync21(stagedOutputPath)) {
|
|
16118
16184
|
const debugOutput = join31(workDir, `output${videoExt}`);
|
|
16119
16185
|
copyFileSync5(stagedOutputPath, debugOutput);
|
|
16120
16186
|
}
|
|
@@ -16226,7 +16292,7 @@ async function executeRenderPipeline(input) {
|
|
|
16226
16292
|
|
|
16227
16293
|
// src/services/hyperframeLint.ts
|
|
16228
16294
|
import {
|
|
16229
|
-
existsSync as
|
|
16295
|
+
existsSync as existsSync22,
|
|
16230
16296
|
readFileSync as readFileSync10,
|
|
16231
16297
|
statSync as statSync10,
|
|
16232
16298
|
openSync as openSync5,
|
|
@@ -16280,7 +16346,7 @@ function readEntryHtml(filePath) {
|
|
|
16280
16346
|
}
|
|
16281
16347
|
function readProjectEntryFile(projectDir, preferredEntryFile) {
|
|
16282
16348
|
const absProjectDir = resolve9(projectDir);
|
|
16283
|
-
if (!
|
|
16349
|
+
if (!existsSync22(absProjectDir) || !statSync10(absProjectDir).isDirectory()) {
|
|
16284
16350
|
return { error: `Project directory not found: ${absProjectDir}` };
|
|
16285
16351
|
}
|
|
16286
16352
|
const entryCandidates = [preferredEntryFile, "index.html", "src/index.html"].filter(
|
|
@@ -16349,7 +16415,7 @@ async function runHyperframeLint(prepared) {
|
|
|
16349
16415
|
import { Worker as Worker2 } from "node:worker_threads";
|
|
16350
16416
|
import { fileURLToPath as fileURLToPath5 } from "node:url";
|
|
16351
16417
|
import { dirname as dirname14, join as join33 } from "node:path";
|
|
16352
|
-
import { existsSync as
|
|
16418
|
+
import { existsSync as existsSync23 } from "node:fs";
|
|
16353
16419
|
var DEFAULT_HEALTH_PORT = 9848;
|
|
16354
16420
|
async function startHealthWorker(options = {}) {
|
|
16355
16421
|
const log = options.logger ?? defaultLogger2();
|
|
@@ -16426,7 +16492,7 @@ function resolveWorkerEntry2() {
|
|
|
16426
16492
|
const here = dirname14(fileURLToPath5(import.meta.url));
|
|
16427
16493
|
const candidates = [join33(here, "healthWorkerThread.js"), join33(here, "healthWorkerThread.ts")];
|
|
16428
16494
|
for (const candidate of candidates) {
|
|
16429
|
-
if (
|
|
16495
|
+
if (existsSync23(candidate)) return candidate;
|
|
16430
16496
|
}
|
|
16431
16497
|
return void 0;
|
|
16432
16498
|
}
|
|
@@ -16499,7 +16565,7 @@ import {
|
|
|
16499
16565
|
// src/services/distributed/shared.ts
|
|
16500
16566
|
import { execFile as execFileCallback } from "node:child_process";
|
|
16501
16567
|
import { dirname as dirname15, join as join34 } from "node:path";
|
|
16502
|
-
import { existsSync as
|
|
16568
|
+
import { existsSync as existsSync24, readFileSync as readFileSync11 } from "node:fs";
|
|
16503
16569
|
import { fileURLToPath as fileURLToPath6 } from "node:url";
|
|
16504
16570
|
import { promisify as promisify2 } from "node:util";
|
|
16505
16571
|
import {
|
|
@@ -16515,7 +16581,7 @@ function readProducerVersion() {
|
|
|
16515
16581
|
let current = startDir;
|
|
16516
16582
|
for (let i = 0; i < 10; i++) {
|
|
16517
16583
|
const candidate = join34(current, "package.json");
|
|
16518
|
-
if (
|
|
16584
|
+
if (existsSync24(candidate)) {
|
|
16519
16585
|
try {
|
|
16520
16586
|
const pkg = JSON.parse(readFileSync11(candidate, "utf-8"));
|
|
16521
16587
|
if (pkg.name === "@hyperframes/producer" && typeof pkg.version === "string") {
|
|
@@ -16788,6 +16854,9 @@ function assertRequestOptionObjects(options) {
|
|
|
16788
16854
|
if (options.variables !== void 0 && !isPlainObject(options.variables)) {
|
|
16789
16855
|
throw new Error("Render request variables must be a JSON object");
|
|
16790
16856
|
}
|
|
16857
|
+
if (options.strictVariables !== void 0 && typeof options.strictVariables !== "boolean") {
|
|
16858
|
+
throw new Error("Render request strictVariables must be a boolean");
|
|
16859
|
+
}
|
|
16791
16860
|
if (options.distributed !== void 0) assertDistributedOptions(options.distributed);
|
|
16792
16861
|
}
|
|
16793
16862
|
function assertRequestOptions(options) {
|
|
@@ -16862,7 +16931,8 @@ var SAFE_RENDER_ERROR_CODES = /* @__PURE__ */ new Set([
|
|
|
16862
16931
|
"ENCODER_INTERRUPTED",
|
|
16863
16932
|
"RENDER_TOO_SLOW",
|
|
16864
16933
|
"RENDER_STAGE_STALLED",
|
|
16865
|
-
"PAGE_NEVER_READY"
|
|
16934
|
+
"PAGE_NEVER_READY",
|
|
16935
|
+
"VARIABLES_INVALID"
|
|
16866
16936
|
]);
|
|
16867
16937
|
function extractSafeRenderErrorCode(error) {
|
|
16868
16938
|
if (typeof error !== "object" || error === null || !("code" in error)) return void 0;
|
|
@@ -16886,6 +16956,9 @@ function extractSafeRenderErrorMetadata(error) {
|
|
|
16886
16956
|
...isPlainObject2(publicMetadata) ? { errorMetadata: publicMetadata } : {}
|
|
16887
16957
|
};
|
|
16888
16958
|
}
|
|
16959
|
+
function strictVariablesResult(job) {
|
|
16960
|
+
return job.strictVariablesChecked === void 0 ? {} : { strictVariablesChecked: job.strictVariablesChecked };
|
|
16961
|
+
}
|
|
16889
16962
|
function parseServerFps(value) {
|
|
16890
16963
|
if (typeof value !== "number" && typeof value !== "string") return DEFAULT_SERVER_FPS;
|
|
16891
16964
|
const parsed = parseFps(value);
|
|
@@ -16944,7 +17017,7 @@ function parseRenderOptions(body) {
|
|
|
16944
17017
|
bufferSize,
|
|
16945
17018
|
chromaSubsampling
|
|
16946
17019
|
} = encoder.ok ? encoder.options : {};
|
|
16947
|
-
const { variables, outputResolution, outputResolutionAspectAgnostic } = parseRenderOverrides(body);
|
|
17020
|
+
const { variables, strictVariables, outputResolution, outputResolutionAspectAgnostic } = parseRenderOverrides(body);
|
|
16948
17021
|
return {
|
|
16949
17022
|
outputPath,
|
|
16950
17023
|
fps,
|
|
@@ -16965,6 +17038,7 @@ function parseRenderOptions(body) {
|
|
|
16965
17038
|
format,
|
|
16966
17039
|
outputDynamicRange,
|
|
16967
17040
|
variables,
|
|
17041
|
+
strictVariables,
|
|
16968
17042
|
outputResolution,
|
|
16969
17043
|
outputResolutionAspectAgnostic,
|
|
16970
17044
|
videoFrameFormat
|
|
@@ -16975,10 +17049,11 @@ function isPlainObject2(value) {
|
|
|
16975
17049
|
}
|
|
16976
17050
|
function parseRenderOverrides(body) {
|
|
16977
17051
|
const variables = isPlainObject2(body.variables) ? body.variables : void 0;
|
|
17052
|
+
const strictVariables = body.strictVariables === true ? true : void 0;
|
|
16978
17053
|
const rawOutputResolution = typeof body.outputResolution === "string" ? body.outputResolution : void 0;
|
|
16979
17054
|
const outputResolution = rawOutputResolution ? normalizeResolutionFlag(rawOutputResolution) : void 0;
|
|
16980
17055
|
const outputResolutionAspectAgnostic = outputResolution ? isAspectAgnosticResolutionAlias(rawOutputResolution) : void 0;
|
|
16981
|
-
return { variables, outputResolution, outputResolutionAspectAgnostic };
|
|
17056
|
+
return { variables, strictVariables, outputResolution, outputResolutionAspectAgnostic };
|
|
16982
17057
|
}
|
|
16983
17058
|
function buildRenderJobConfig(input, outputPath, log) {
|
|
16984
17059
|
const request = createRenderRequest({
|
|
@@ -17002,6 +17077,7 @@ function buildRenderJobConfig(input, outputPath, log) {
|
|
|
17002
17077
|
strictness: input.strictness,
|
|
17003
17078
|
entryFile: input.entryFile,
|
|
17004
17079
|
variables: input.variables,
|
|
17080
|
+
strictVariables: input.strictVariables,
|
|
17005
17081
|
outputResolution: input.outputResolution,
|
|
17006
17082
|
outputResolutionAspectAgnostic: input.outputResolutionAspectAgnostic,
|
|
17007
17083
|
videoFrameFormat: input.videoFrameFormat,
|
|
@@ -17015,7 +17091,7 @@ function resolvePreparedRenderOutput(prepared, rendersDir, log) {
|
|
|
17015
17091
|
const { input, cleanupProjectDir } = prepared;
|
|
17016
17092
|
const absoluteOutputPath = resolveOutputPath(input.projectDir, input.outputPath, rendersDir, log);
|
|
17017
17093
|
const outputDir = dirname16(absoluteOutputPath);
|
|
17018
|
-
if (!
|
|
17094
|
+
if (!existsSync25(outputDir)) mkdirSync13(outputDir, { recursive: true });
|
|
17019
17095
|
return { input, cleanupProjectDir, absoluteOutputPath };
|
|
17020
17096
|
}
|
|
17021
17097
|
function prepareRenderJob(prepared, rendersDir, log) {
|
|
@@ -17040,6 +17116,9 @@ function validateRenderOverrides(body) {
|
|
|
17040
17116
|
if (body.variables !== void 0 && !isPlainObject2(body.variables)) {
|
|
17041
17117
|
return 'variables must be a JSON object keyed by variable id (e.g. {"title":"Hello"})';
|
|
17042
17118
|
}
|
|
17119
|
+
if (body.strictVariables !== void 0 && typeof body.strictVariables !== "boolean") {
|
|
17120
|
+
return "strictVariables must be a boolean";
|
|
17121
|
+
}
|
|
17043
17122
|
if (body.outputDynamicRange !== void 0 && parseServerOutputDynamicRange(body.outputDynamicRange) === void 0) {
|
|
17044
17123
|
return 'outputDynamicRange must be one of: "auto", "hdr", "sdr"';
|
|
17045
17124
|
}
|
|
@@ -17072,11 +17151,11 @@ function prepareProjectDirectory(projectDir, options) {
|
|
|
17072
17151
|
const candidate = nonEmptyString(projectDir);
|
|
17073
17152
|
if (!candidate) return null;
|
|
17074
17153
|
const absProjectDir = resolve10(candidate);
|
|
17075
|
-
if (!
|
|
17154
|
+
if (!existsSync25(absProjectDir) || !statSync11(absProjectDir).isDirectory()) {
|
|
17076
17155
|
return { error: `Project directory not found: ${absProjectDir}` };
|
|
17077
17156
|
}
|
|
17078
17157
|
const entry = options.entryFile || "index.html";
|
|
17079
|
-
if (!
|
|
17158
|
+
if (!existsSync25(resolve10(absProjectDir, entry))) {
|
|
17080
17159
|
return { error: `Entry file "${entry}" not found in project directory: ${absProjectDir}` };
|
|
17081
17160
|
}
|
|
17082
17161
|
return { prepared: { input: { projectDir: absProjectDir, ...options } } };
|
|
@@ -17168,7 +17247,7 @@ function cleanupTempDir(dir, log) {
|
|
|
17168
17247
|
}
|
|
17169
17248
|
}
|
|
17170
17249
|
function outputFileSize(path) {
|
|
17171
|
-
return
|
|
17250
|
+
return existsSync25(path) ? statSync11(path).size : 0;
|
|
17172
17251
|
}
|
|
17173
17252
|
function createBlockingProgressReporter(log, requestId) {
|
|
17174
17253
|
let lastLoggedPct = -10;
|
|
@@ -17358,7 +17437,8 @@ function createRenderHandlers(options = {}) {
|
|
|
17358
17437
|
videoDurationSeconds: job.duration ?? null,
|
|
17359
17438
|
outcome: job.outcome ?? "completed",
|
|
17360
17439
|
warnings: job.warnings,
|
|
17361
|
-
perf: job.perfSummary ?? null
|
|
17440
|
+
perf: job.perfSummary ?? null,
|
|
17441
|
+
...strictVariablesResult(job)
|
|
17362
17442
|
});
|
|
17363
17443
|
} catch (error) {
|
|
17364
17444
|
const durationMs = Date.now() - t0;
|
|
@@ -17454,7 +17534,8 @@ function createRenderHandlers(options = {}) {
|
|
|
17454
17534
|
outcome: job.outcome ?? "completed",
|
|
17455
17535
|
warnings: job.warnings,
|
|
17456
17536
|
perf: job.perfSummary ?? null,
|
|
17457
|
-
producerVersion: readProducerVersion()
|
|
17537
|
+
producerVersion: readProducerVersion(),
|
|
17538
|
+
...strictVariablesResult(job)
|
|
17458
17539
|
})
|
|
17459
17540
|
});
|
|
17460
17541
|
} catch (error) {
|
|
@@ -17479,7 +17560,7 @@ function createRenderHandlers(options = {}) {
|
|
|
17479
17560
|
if (!artifact) {
|
|
17480
17561
|
return c.json({ success: false, error: "Output artifact not found or expired" }, 404);
|
|
17481
17562
|
}
|
|
17482
|
-
if (!
|
|
17563
|
+
if (!existsSync25(artifact.path)) {
|
|
17483
17564
|
store.delete(token);
|
|
17484
17565
|
return c.json({ success: false, error: "Output artifact file missing" }, 404);
|
|
17485
17566
|
}
|