@hyperframes/producer 0.9.67 → 0.9.68
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 +6 -4
- package/dist/hyperframe.manifest.json +1 -1
- package/dist/hyperframe.runtime.iife.js +64 -64
- package/dist/index.js +445 -381
- package/dist/public-server.js +309 -246
- package/dist/services/render/segmentManifest.d.ts +29 -6
- package/dist/services/render/segmentPlan.d.ts +2 -5
- package/dist/services/render/stages/captureSegmentedStage.d.ts +1 -2
- package/package.json +7 -7
package/dist/public-server.js
CHANGED
|
@@ -20,13 +20,13 @@ function requireOutputDimensions(expected, width, height) {
|
|
|
20
20
|
import {
|
|
21
21
|
existsSync as existsSync26,
|
|
22
22
|
mkdirSync as mkdirSync13,
|
|
23
|
-
statSync as
|
|
23
|
+
statSync as statSync12,
|
|
24
24
|
mkdtempSync,
|
|
25
25
|
writeFileSync as writeFileSync8,
|
|
26
26
|
rmSync as rmSync13,
|
|
27
|
-
createReadStream as
|
|
27
|
+
createReadStream as createReadStream4
|
|
28
28
|
} from "node:fs";
|
|
29
|
-
import { resolve as resolve11, dirname as dirname18, join as
|
|
29
|
+
import { resolve as resolve11, dirname as dirname18, join as join39 } from "node:path";
|
|
30
30
|
import { tmpdir as tmpdir4 } from "node:os";
|
|
31
31
|
import { parseArgs } from "node:util";
|
|
32
32
|
import { isIP } from "node:net";
|
|
@@ -48,7 +48,7 @@ import {
|
|
|
48
48
|
mkdirSync as mkdirSync12,
|
|
49
49
|
readdirSync as readdirSync6,
|
|
50
50
|
rmSync as rmSync12,
|
|
51
|
-
statSync as
|
|
51
|
+
statSync as statSync10,
|
|
52
52
|
writeFileSync as writeFileSync7,
|
|
53
53
|
copyFileSync as copyFileSync5,
|
|
54
54
|
appendFileSync
|
|
@@ -395,7 +395,7 @@ import {
|
|
|
395
395
|
referenceBackgroundResult,
|
|
396
396
|
createReferenceBackgroundRecorder
|
|
397
397
|
} from "@hyperframes/engine";
|
|
398
|
-
import { join as
|
|
398
|
+
import { join as join34, dirname as dirname14, resolve as resolve9 } from "path";
|
|
399
399
|
import { totalmem as totalmem2 } from "node:os";
|
|
400
400
|
import { randomUUID } from "crypto";
|
|
401
401
|
import { fileURLToPath as fileURLToPath4 } from "url";
|
|
@@ -2624,8 +2624,8 @@ function replanAfterFailure(plan, failure) {
|
|
|
2624
2624
|
}
|
|
2625
2625
|
|
|
2626
2626
|
// src/services/render/stages/captureSegmentedStage.ts
|
|
2627
|
-
import { existsSync as
|
|
2628
|
-
import { join as
|
|
2627
|
+
import { existsSync as existsSync8, mkdirSync as mkdirSync4, rmSync as rmSync6, statSync as statSync4 } from "node:fs";
|
|
2628
|
+
import { join as join12 } from "node:path";
|
|
2629
2629
|
import {
|
|
2630
2630
|
captureFrameToBuffer as captureFrameToBuffer2,
|
|
2631
2631
|
closeCaptureSession as closeCaptureSession2,
|
|
@@ -4312,6 +4312,7 @@ function cleanupEndedHdrVideos(args) {
|
|
|
4312
4312
|
}
|
|
4313
4313
|
|
|
4314
4314
|
// src/services/render/segmentPlan.ts
|
|
4315
|
+
import { join as join9 } from "node:path";
|
|
4315
4316
|
var DEFAULT_SEGMENT_FRAMES = 3e3;
|
|
4316
4317
|
var MIN_SEGMENT_FRAMES = 30;
|
|
4317
4318
|
function assertPositiveInteger(name, value) {
|
|
@@ -4332,6 +4333,9 @@ function planSegments(totalFrames, segmentFrames) {
|
|
|
4332
4333
|
}
|
|
4333
4334
|
return slices;
|
|
4334
4335
|
}
|
|
4336
|
+
function segmentOutputPath(segmentDir, index) {
|
|
4337
|
+
return join9(segmentDir, `segment_${String(index).padStart(5, "0")}.mp4`);
|
|
4338
|
+
}
|
|
4335
4339
|
function resolveSegmentFrames(env) {
|
|
4336
4340
|
const raw = env.HF_SEGMENT_FRAMES;
|
|
4337
4341
|
if (raw === void 0 || raw.trim() === "") return DEFAULT_SEGMENT_FRAMES;
|
|
@@ -4349,6 +4353,144 @@ function createSegmentQueue(slices) {
|
|
|
4349
4353
|
};
|
|
4350
4354
|
}
|
|
4351
4355
|
|
|
4356
|
+
// src/services/render/segmentManifest.ts
|
|
4357
|
+
import { createHash as createHash2, createHmac, timingSafeEqual } from "node:crypto";
|
|
4358
|
+
import {
|
|
4359
|
+
createReadStream as createReadStream2,
|
|
4360
|
+
existsSync as existsSync7,
|
|
4361
|
+
lstatSync as lstatSync3,
|
|
4362
|
+
mkdirSync as mkdirSync3,
|
|
4363
|
+
readFileSync as readFileSync4,
|
|
4364
|
+
writeFileSync as writeFileSync3
|
|
4365
|
+
} from "node:fs";
|
|
4366
|
+
import { join as join10 } from "node:path";
|
|
4367
|
+
import { previewToken } from "@hyperframes/core/preview-proof";
|
|
4368
|
+
import { renameWithRetry as renameWithRetry2 } from "@hyperframes/engine";
|
|
4369
|
+
var MANIFEST_FILENAME = "segments.json";
|
|
4370
|
+
function computeSegmentPlanHash(input) {
|
|
4371
|
+
const ordered = [
|
|
4372
|
+
input.compositionHash,
|
|
4373
|
+
input.cliVersion,
|
|
4374
|
+
String(input.totalFrames),
|
|
4375
|
+
String(input.segmentFrames),
|
|
4376
|
+
`${input.fps.num}/${input.fps.den}`,
|
|
4377
|
+
`${input.width}x${input.height}`,
|
|
4378
|
+
input.codec,
|
|
4379
|
+
input.preset,
|
|
4380
|
+
input.quality === void 0 ? "" : String(input.quality),
|
|
4381
|
+
input.bitrate ?? "",
|
|
4382
|
+
input.pixelFormat ?? "",
|
|
4383
|
+
input.imageFormat,
|
|
4384
|
+
input.useGpu ? "gpu" : "cpu",
|
|
4385
|
+
`${input.outputWidth}x${input.outputHeight}`,
|
|
4386
|
+
input.motionBlur,
|
|
4387
|
+
input.pageMotionBlur ?? "",
|
|
4388
|
+
input.captureQuality === void 0 ? "" : String(input.captureQuality)
|
|
4389
|
+
];
|
|
4390
|
+
const delivery = [input.maxBitrate, input.bufferSize, input.gopSize].map((v) => v ?? "");
|
|
4391
|
+
if (delivery.some((v) => v !== "")) ordered.push(...delivery.map(String));
|
|
4392
|
+
return createHash2("sha256").update(ordered.join(" ")).digest("hex").slice(0, 16);
|
|
4393
|
+
}
|
|
4394
|
+
function segmentDirFor(projectRendersDir, planHash) {
|
|
4395
|
+
return join10(projectRendersDir, ".hf-segments", planHash);
|
|
4396
|
+
}
|
|
4397
|
+
function hasNumber(value, key) {
|
|
4398
|
+
return key in value && typeof Reflect.get(value, key) === "number";
|
|
4399
|
+
}
|
|
4400
|
+
function hasString(value, key) {
|
|
4401
|
+
return key in value && typeof Reflect.get(value, key) === "string";
|
|
4402
|
+
}
|
|
4403
|
+
function isEntry(value) {
|
|
4404
|
+
if (typeof value !== "object" || value === null) return false;
|
|
4405
|
+
return hasNumber(value, "index") && hasNumber(value, "startFrame") && hasNumber(value, "endFrame") && hasString(value, "path") && hasNumber(value, "bytes") && hasString(value, "sha256") && hasString(value, "completedAt");
|
|
4406
|
+
}
|
|
4407
|
+
function isManifest(value) {
|
|
4408
|
+
if (typeof value !== "object" || value === null) return false;
|
|
4409
|
+
const completed = Reflect.get(value, "completed");
|
|
4410
|
+
return Reflect.get(value, "version") === 1 && hasString(value, "planHash") && hasNumber(value, "totalFrames") && hasNumber(value, "segmentFrames") && Array.isArray(completed) && completed.every(isEntry);
|
|
4411
|
+
}
|
|
4412
|
+
function readSegmentManifest(segmentDir) {
|
|
4413
|
+
const path = join10(segmentDir, MANIFEST_FILENAME);
|
|
4414
|
+
if (!existsSync7(path)) return null;
|
|
4415
|
+
try {
|
|
4416
|
+
const parsed = JSON.parse(readFileSync4(path, "utf-8"));
|
|
4417
|
+
return isManifest(parsed) ? parsed : null;
|
|
4418
|
+
} catch {
|
|
4419
|
+
return null;
|
|
4420
|
+
}
|
|
4421
|
+
}
|
|
4422
|
+
function segmentManifestKey(token = previewToken()) {
|
|
4423
|
+
return token ? createHmac("sha256", token).update("segment-manifest").digest() : null;
|
|
4424
|
+
}
|
|
4425
|
+
function manifestMac(manifest, key) {
|
|
4426
|
+
const signed = [
|
|
4427
|
+
manifest.planHash,
|
|
4428
|
+
manifest.totalFrames,
|
|
4429
|
+
manifest.segmentFrames,
|
|
4430
|
+
manifest.completed.map((e) => [e.index, e.startFrame, e.endFrame, e.bytes, e.sha256])
|
|
4431
|
+
];
|
|
4432
|
+
return createHmac("sha256", key).update(JSON.stringify(signed)).digest("hex");
|
|
4433
|
+
}
|
|
4434
|
+
function signSegmentManifest(manifest, key) {
|
|
4435
|
+
const { version, planHash, totalFrames, segmentFrames, completed } = manifest;
|
|
4436
|
+
const unsigned = { version, planHash, totalFrames, segmentFrames, completed };
|
|
4437
|
+
return key ? { ...unsigned, mac: manifestMac(unsigned, key) } : unsigned;
|
|
4438
|
+
}
|
|
4439
|
+
function hasValidMac(manifest, key) {
|
|
4440
|
+
if (!key || typeof manifest.mac !== "string") return false;
|
|
4441
|
+
const expected = Buffer.from(manifestMac(manifest, key), "hex");
|
|
4442
|
+
const actual = Buffer.from(manifest.mac, "hex");
|
|
4443
|
+
return actual.length === expected.length && timingSafeEqual(actual, expected);
|
|
4444
|
+
}
|
|
4445
|
+
async function hashSegmentFile(path) {
|
|
4446
|
+
const hash = createHash2("sha256");
|
|
4447
|
+
for await (const chunk of createReadStream2(path)) hash.update(chunk);
|
|
4448
|
+
return hash.digest("hex");
|
|
4449
|
+
}
|
|
4450
|
+
function writeSegmentManifest(segmentDir, manifest, key) {
|
|
4451
|
+
mkdirSync3(segmentDir, { recursive: true });
|
|
4452
|
+
const tmp = join10(segmentDir, `${MANIFEST_FILENAME}.${process.pid}.tmp`);
|
|
4453
|
+
writeFileSync3(tmp, JSON.stringify(signSegmentManifest(manifest, key), null, 2), "utf-8");
|
|
4454
|
+
renameWithRetry2(tmp, join10(segmentDir, MANIFEST_FILENAME));
|
|
4455
|
+
}
|
|
4456
|
+
async function probeSegmentFrameCount(path, probe) {
|
|
4457
|
+
try {
|
|
4458
|
+
const meta = await probe(path);
|
|
4459
|
+
if (!Number.isFinite(meta.videoStreamDurationSeconds) || !Number.isFinite(meta.fps))
|
|
4460
|
+
return null;
|
|
4461
|
+
if (meta.fps <= 0) return null;
|
|
4462
|
+
return Math.round(meta.videoStreamDurationSeconds * meta.fps);
|
|
4463
|
+
} catch {
|
|
4464
|
+
return null;
|
|
4465
|
+
}
|
|
4466
|
+
}
|
|
4467
|
+
function plannedSlice(entry, plan) {
|
|
4468
|
+
const slice = Number.isInteger(entry.index) ? plan[entry.index] : void 0;
|
|
4469
|
+
if (!slice || slice.startFrame !== entry.startFrame || slice.endFrame !== entry.endFrame) {
|
|
4470
|
+
return void 0;
|
|
4471
|
+
}
|
|
4472
|
+
return slice;
|
|
4473
|
+
}
|
|
4474
|
+
function isPlainFileOfSize(path, bytes) {
|
|
4475
|
+
const stat = lstatSync3(path, { throwIfNoEntry: false });
|
|
4476
|
+
return stat !== void 0 && stat.isFile() && stat.size > 0 && stat.size === bytes;
|
|
4477
|
+
}
|
|
4478
|
+
async function validateCompletedSegments(manifest, check) {
|
|
4479
|
+
const ok = /* @__PURE__ */ new Set();
|
|
4480
|
+
if (manifest.planHash !== check.expectedHash || !hasValidMac(manifest, check.key)) return ok;
|
|
4481
|
+
for (const entry of manifest.completed) {
|
|
4482
|
+
const slice = plannedSlice(entry, check.plan);
|
|
4483
|
+
if (!slice) continue;
|
|
4484
|
+
const path = segmentOutputPath(check.segmentDir, slice.index);
|
|
4485
|
+
if (!isPlainFileOfSize(path, entry.bytes)) continue;
|
|
4486
|
+
if (await hashSegmentFile(path) !== entry.sha256) continue;
|
|
4487
|
+
const frames = await check.probeFrames(path);
|
|
4488
|
+
if (frames !== slice.endFrame - slice.startFrame) continue;
|
|
4489
|
+
ok.add(slice.index);
|
|
4490
|
+
}
|
|
4491
|
+
return ok;
|
|
4492
|
+
}
|
|
4493
|
+
|
|
4352
4494
|
// src/services/render/segmentRecycle.ts
|
|
4353
4495
|
var DEFAULT_SEGMENT_BROWSER_RECYCLE = 3;
|
|
4354
4496
|
function resolveSegmentBrowserRecycle(env) {
|
|
@@ -4366,7 +4508,7 @@ function isTargetLossError(error) {
|
|
|
4366
4508
|
// src/services/render/stages/captureStreamingStage.ts
|
|
4367
4509
|
import { mkdtemp, writeFile } from "node:fs/promises";
|
|
4368
4510
|
import { tmpdir as tmpdir2 } from "node:os";
|
|
4369
|
-
import { join as
|
|
4511
|
+
import { join as join11 } from "node:path";
|
|
4370
4512
|
import {
|
|
4371
4513
|
DrawElementVerificationError,
|
|
4372
4514
|
captureFrameToBuffer,
|
|
@@ -4589,11 +4731,11 @@ async function verifyDrawElementSample(session, idx, buf, ctx) {
|
|
|
4589
4731
|
return;
|
|
4590
4732
|
}
|
|
4591
4733
|
if (db < verifyMinDb) {
|
|
4592
|
-
const dumpDir = await mkdtemp(
|
|
4734
|
+
const dumpDir = await mkdtemp(join11(tmpdir2(), "hf-de-verify-fail-")).catch(() => null);
|
|
4593
4735
|
if (dumpDir) {
|
|
4594
4736
|
await Promise.all([
|
|
4595
|
-
writeFile(
|
|
4596
|
-
writeFile(
|
|
4737
|
+
writeFile(join11(dumpDir, `frame-${idx}-de.jpg`), buf),
|
|
4738
|
+
writeFile(join11(dumpDir, `frame-${idx}-truth.jpg`), truth)
|
|
4597
4739
|
]).catch(() => {
|
|
4598
4740
|
});
|
|
4599
4741
|
}
|
|
@@ -5163,9 +5305,6 @@ async function runCaptureStreamingStage(input) {
|
|
|
5163
5305
|
}
|
|
5164
5306
|
|
|
5165
5307
|
// src/services/render/stages/captureSegmentedStage.ts
|
|
5166
|
-
function segmentOutputPath(segmentDir, index) {
|
|
5167
|
-
return join10(segmentDir, `segment_${String(index).padStart(5, "0")}.mp4`);
|
|
5168
|
-
}
|
|
5169
5308
|
function segmentEncoderOptions(base, segment) {
|
|
5170
5309
|
return {
|
|
5171
5310
|
...base,
|
|
@@ -5263,7 +5402,8 @@ async function captureSegmentToEncoder(ctx, segment) {
|
|
|
5263
5402
|
path: segmentPath,
|
|
5264
5403
|
// Recorded so resume can prove the file on disk is the one that
|
|
5265
5404
|
// finished; absent only in unit tests, whose fake encoder writes none.
|
|
5266
|
-
bytes:
|
|
5405
|
+
bytes: existsSync8(segmentPath) ? statSync4(segmentPath).size : 0,
|
|
5406
|
+
sha256: existsSync8(segmentPath) ? await hashSegmentFile(segmentPath) : ""
|
|
5267
5407
|
});
|
|
5268
5408
|
return encodeResult;
|
|
5269
5409
|
} finally {
|
|
@@ -5497,8 +5637,8 @@ async function runCaptureSegmentedStage(input) {
|
|
|
5497
5637
|
const { log, dedupPerfs, assertNotAborted } = input;
|
|
5498
5638
|
const deps = { ...DEFAULT_DEPS, ...input.deps };
|
|
5499
5639
|
const segments = planSegments(input.totalFrames, input.segmentFrames);
|
|
5500
|
-
const segmentDir = input.segmentDir ??
|
|
5501
|
-
|
|
5640
|
+
const segmentDir = input.segmentDir ?? join12(input.workDir, "segments");
|
|
5641
|
+
mkdirSync4(segmentDir, { recursive: true });
|
|
5502
5642
|
const skip = input.completedSegments ?? /* @__PURE__ */ new Set();
|
|
5503
5643
|
const pending = segments.filter((s) => !skip.has(s.index));
|
|
5504
5644
|
for (const index of skip) log.info("[Render] segment skipped (resume)", { index });
|
|
@@ -5653,7 +5793,7 @@ function startRenderEtaGuard(options) {
|
|
|
5653
5793
|
}
|
|
5654
5794
|
|
|
5655
5795
|
// src/services/render/captureCost.ts
|
|
5656
|
-
import { join as
|
|
5796
|
+
import { join as join13 } from "node:path";
|
|
5657
5797
|
import { fpsToNumber as fpsToNumber4 } from "@hyperframes/core";
|
|
5658
5798
|
import {
|
|
5659
5799
|
calculateOptimalWorkers,
|
|
@@ -5906,7 +6046,7 @@ async function runCaptureCalibration(input) {
|
|
|
5906
6046
|
});
|
|
5907
6047
|
let calibration;
|
|
5908
6048
|
try {
|
|
5909
|
-
calibration = await runOneCalibration(
|
|
6049
|
+
calibration = await runOneCalibration(join13(workDir, "capture-calibration"), calibrationCfg);
|
|
5910
6050
|
} catch (error) {
|
|
5911
6051
|
const shouldFallback = !forceScreenshot && shouldFallbackToScreenshotAfterCalibrationError(error);
|
|
5912
6052
|
if (!shouldFallback) {
|
|
@@ -5940,7 +6080,7 @@ async function runCaptureCalibration(input) {
|
|
|
5940
6080
|
const screenshotCfg = createCaptureCalibrationConfig({ ...cfg, forceScreenshot: true });
|
|
5941
6081
|
try {
|
|
5942
6082
|
calibration = await runOneCalibration(
|
|
5943
|
-
|
|
6083
|
+
join13(workDir, "capture-calibration-screenshot"),
|
|
5944
6084
|
screenshotCfg
|
|
5945
6085
|
);
|
|
5946
6086
|
} catch (fallbackError) {
|
|
@@ -6004,8 +6144,8 @@ function checkPageNeverReady(input) {
|
|
|
6004
6144
|
}
|
|
6005
6145
|
|
|
6006
6146
|
// src/services/render/deferredVideoFrames.ts
|
|
6007
|
-
import { mkdirSync as
|
|
6008
|
-
import { dirname as dirname5, join as
|
|
6147
|
+
import { mkdirSync as mkdirSync5, rmSync as rmSync7 } from "node:fs";
|
|
6148
|
+
import { dirname as dirname5, join as join14 } from "node:path";
|
|
6009
6149
|
import {
|
|
6010
6150
|
createFrameLookupTable,
|
|
6011
6151
|
extractVideoFramesRange,
|
|
@@ -6050,7 +6190,7 @@ async function extractDeferredFrames(input) {
|
|
|
6050
6190
|
const shown = shownDeferredFrameIndexes(input, input.frames, input.fps);
|
|
6051
6191
|
return Promise.all(
|
|
6052
6192
|
deferred.map(async (video) => {
|
|
6053
|
-
const outputDir =
|
|
6193
|
+
const outputDir = join14(input.outputRoot, mediaIdPathSegment2(video.videoId));
|
|
6054
6194
|
const indexes = [...shown.get(video.videoId) ?? []].sort((a, b) => a - b);
|
|
6055
6195
|
if (indexes.length === 0) {
|
|
6056
6196
|
return { ...video, outputDir, framePaths: /* @__PURE__ */ new Map(), ownedByLookup: false };
|
|
@@ -6106,7 +6246,7 @@ async function extractAllDeferredFrames(extracted, input) {
|
|
|
6106
6246
|
maxTransientRetries: input.maxTransientRetries,
|
|
6107
6247
|
onRetry: () => {
|
|
6108
6248
|
rmSync7(video.outputDir, { recursive: true, force: true });
|
|
6109
|
-
|
|
6249
|
+
mkdirSync5(video.outputDir, { recursive: true });
|
|
6110
6250
|
}
|
|
6111
6251
|
}
|
|
6112
6252
|
);
|
|
@@ -6197,14 +6337,14 @@ async function measureLocalShownBoxes(page, videos, fps, duration, log) {
|
|
|
6197
6337
|
}
|
|
6198
6338
|
|
|
6199
6339
|
// src/services/render/segmentVideoFrames.ts
|
|
6200
|
-
import { mkdirSync as
|
|
6201
|
-
import { join as
|
|
6340
|
+
import { mkdirSync as mkdirSync6, rmSync as rmSync8 } from "node:fs";
|
|
6341
|
+
import { join as join15 } from "node:path";
|
|
6202
6342
|
import {
|
|
6203
6343
|
createFrameLookupTable as createFrameLookupTable2,
|
|
6204
6344
|
createVideoFrameInjector
|
|
6205
6345
|
} from "@hyperframes/engine";
|
|
6206
6346
|
function segmentFramesDir(rootDir, index) {
|
|
6207
|
-
return
|
|
6347
|
+
return join15(rootDir, "segment-frames", `segment_${String(index).padStart(5, "0")}`);
|
|
6208
6348
|
}
|
|
6209
6349
|
function createSegmentVideoFrames(input) {
|
|
6210
6350
|
const extractFrames = input.extractFrames ?? extractDeferredFrames;
|
|
@@ -6235,7 +6375,7 @@ function createSegmentVideoFrames(input) {
|
|
|
6235
6375
|
let onDemandCalls = 0;
|
|
6236
6376
|
const onDemandHook = () => Object.assign(
|
|
6237
6377
|
async (page, time, heldVideoTime) => {
|
|
6238
|
-
const dir =
|
|
6378
|
+
const dir = join15(
|
|
6239
6379
|
input.rootDir,
|
|
6240
6380
|
"segment-frames",
|
|
6241
6381
|
`on-demand_${String(onDemandCalls++).padStart(5, "0")}`
|
|
@@ -6252,11 +6392,11 @@ function createSegmentVideoFrames(input) {
|
|
|
6252
6392
|
);
|
|
6253
6393
|
return {
|
|
6254
6394
|
async forFrames(frames, name) {
|
|
6255
|
-
const dir =
|
|
6395
|
+
const dir = join15(input.rootDir, "segment-frames", name);
|
|
6256
6396
|
const release = () => rmSync8(dir, { recursive: true, force: true });
|
|
6257
6397
|
try {
|
|
6258
6398
|
release();
|
|
6259
|
-
|
|
6399
|
+
mkdirSync6(dir, { recursive: true });
|
|
6260
6400
|
const table = await tableFor([...frames], dir);
|
|
6261
6401
|
return { injector: () => createVideoFrameInjector(table, input.injectorOptions), release };
|
|
6262
6402
|
} catch (error) {
|
|
@@ -6285,7 +6425,7 @@ function createSegmentVideoFrames(input) {
|
|
|
6285
6425
|
folder = dir;
|
|
6286
6426
|
try {
|
|
6287
6427
|
rmSync8(dir, { recursive: true, force: true });
|
|
6288
|
-
|
|
6428
|
+
mkdirSync6(dir, { recursive: true });
|
|
6289
6429
|
injector = await injectorFor(
|
|
6290
6430
|
Array.from(
|
|
6291
6431
|
{ length: segment.endFrame - segment.startFrame },
|
|
@@ -6305,7 +6445,7 @@ function createSegmentVideoFrames(input) {
|
|
|
6305
6445
|
|
|
6306
6446
|
// src/services/render/videoFrameWindow.ts
|
|
6307
6447
|
import { readdirSync as readdirSync3, statSync as statSync5 } from "node:fs";
|
|
6308
|
-
import { join as
|
|
6448
|
+
import { join as join16 } from "node:path";
|
|
6309
6449
|
function shouldWindowVideoFrames(args) {
|
|
6310
6450
|
return args.segmented && args.env.HF_VIDEO_FRAME_WINDOW?.trim().toLowerCase() === "true";
|
|
6311
6451
|
}
|
|
@@ -6318,7 +6458,7 @@ function directoryBytes(path) {
|
|
|
6318
6458
|
return 0;
|
|
6319
6459
|
}
|
|
6320
6460
|
for (const entry of entries) {
|
|
6321
|
-
const child2 =
|
|
6461
|
+
const child2 = join16(path, entry.name);
|
|
6322
6462
|
try {
|
|
6323
6463
|
bytes += entry.isDirectory() ? directoryBytes(child2) : statSync5(child2).size;
|
|
6324
6464
|
} catch {
|
|
@@ -6336,7 +6476,7 @@ function trackSegmentFramePeak(frames, rootDir, onPeak) {
|
|
|
6336
6476
|
...worker,
|
|
6337
6477
|
async prepare(segment) {
|
|
6338
6478
|
await worker.prepare(segment);
|
|
6339
|
-
const held = directoryBytes(
|
|
6479
|
+
const held = directoryBytes(join16(rootDir, "segment-frames"));
|
|
6340
6480
|
if (held > peak) {
|
|
6341
6481
|
peak = held;
|
|
6342
6482
|
onPeak(peak);
|
|
@@ -6347,95 +6487,6 @@ function trackSegmentFramePeak(frames, rootDir, onPeak) {
|
|
|
6347
6487
|
};
|
|
6348
6488
|
}
|
|
6349
6489
|
|
|
6350
|
-
// src/services/render/segmentManifest.ts
|
|
6351
|
-
import { createHash as createHash2 } from "node:crypto";
|
|
6352
|
-
import { existsSync as existsSync8, mkdirSync as mkdirSync6, readFileSync as readFileSync4, statSync as statSync6, writeFileSync as writeFileSync3 } from "node:fs";
|
|
6353
|
-
import { join as join15 } from "node:path";
|
|
6354
|
-
import { renameWithRetry as renameWithRetry2 } from "@hyperframes/engine";
|
|
6355
|
-
var MANIFEST_FILENAME = "segments.json";
|
|
6356
|
-
function computeSegmentPlanHash(input) {
|
|
6357
|
-
const ordered = [
|
|
6358
|
-
input.compositionHash,
|
|
6359
|
-
input.cliVersion,
|
|
6360
|
-
String(input.totalFrames),
|
|
6361
|
-
String(input.segmentFrames),
|
|
6362
|
-
`${input.fps.num}/${input.fps.den}`,
|
|
6363
|
-
`${input.width}x${input.height}`,
|
|
6364
|
-
input.codec,
|
|
6365
|
-
input.preset,
|
|
6366
|
-
input.quality === void 0 ? "" : String(input.quality),
|
|
6367
|
-
input.bitrate ?? "",
|
|
6368
|
-
input.pixelFormat ?? "",
|
|
6369
|
-
input.imageFormat,
|
|
6370
|
-
input.useGpu ? "gpu" : "cpu",
|
|
6371
|
-
`${input.outputWidth}x${input.outputHeight}`,
|
|
6372
|
-
input.motionBlur,
|
|
6373
|
-
input.pageMotionBlur ?? "",
|
|
6374
|
-
input.captureQuality === void 0 ? "" : String(input.captureQuality)
|
|
6375
|
-
];
|
|
6376
|
-
const delivery = [input.maxBitrate, input.bufferSize, input.gopSize].map((v) => v ?? "");
|
|
6377
|
-
if (delivery.some((v) => v !== "")) ordered.push(...delivery.map(String));
|
|
6378
|
-
return createHash2("sha256").update(ordered.join(" ")).digest("hex").slice(0, 16);
|
|
6379
|
-
}
|
|
6380
|
-
function segmentDirFor(projectRendersDir, planHash) {
|
|
6381
|
-
return join15(projectRendersDir, ".hf-segments", planHash);
|
|
6382
|
-
}
|
|
6383
|
-
function hasNumber(value, key) {
|
|
6384
|
-
return key in value && typeof Reflect.get(value, key) === "number";
|
|
6385
|
-
}
|
|
6386
|
-
function hasString(value, key) {
|
|
6387
|
-
return key in value && typeof Reflect.get(value, key) === "string";
|
|
6388
|
-
}
|
|
6389
|
-
function isEntry(value) {
|
|
6390
|
-
if (typeof value !== "object" || value === null) return false;
|
|
6391
|
-
return hasNumber(value, "index") && hasNumber(value, "startFrame") && hasNumber(value, "endFrame") && hasString(value, "path") && hasNumber(value, "bytes") && hasString(value, "completedAt");
|
|
6392
|
-
}
|
|
6393
|
-
function isManifest(value) {
|
|
6394
|
-
if (typeof value !== "object" || value === null) return false;
|
|
6395
|
-
const completed = Reflect.get(value, "completed");
|
|
6396
|
-
return Reflect.get(value, "version") === 1 && hasString(value, "planHash") && hasNumber(value, "totalFrames") && hasNumber(value, "segmentFrames") && Array.isArray(completed) && completed.every(isEntry);
|
|
6397
|
-
}
|
|
6398
|
-
function readSegmentManifest(segmentDir) {
|
|
6399
|
-
const path = join15(segmentDir, MANIFEST_FILENAME);
|
|
6400
|
-
if (!existsSync8(path)) return null;
|
|
6401
|
-
try {
|
|
6402
|
-
const parsed = JSON.parse(readFileSync4(path, "utf-8"));
|
|
6403
|
-
return isManifest(parsed) ? parsed : null;
|
|
6404
|
-
} catch {
|
|
6405
|
-
return null;
|
|
6406
|
-
}
|
|
6407
|
-
}
|
|
6408
|
-
function writeSegmentManifest(segmentDir, manifest) {
|
|
6409
|
-
mkdirSync6(segmentDir, { recursive: true });
|
|
6410
|
-
const tmp = join15(segmentDir, `${MANIFEST_FILENAME}.${process.pid}.tmp`);
|
|
6411
|
-
writeFileSync3(tmp, JSON.stringify(manifest, null, 2), "utf-8");
|
|
6412
|
-
renameWithRetry2(tmp, join15(segmentDir, MANIFEST_FILENAME));
|
|
6413
|
-
}
|
|
6414
|
-
async function probeSegmentFrameCount(path, probe) {
|
|
6415
|
-
try {
|
|
6416
|
-
const meta = await probe(path);
|
|
6417
|
-
if (!Number.isFinite(meta.videoStreamDurationSeconds) || !Number.isFinite(meta.fps))
|
|
6418
|
-
return null;
|
|
6419
|
-
if (meta.fps <= 0) return null;
|
|
6420
|
-
return Math.round(meta.videoStreamDurationSeconds * meta.fps);
|
|
6421
|
-
} catch {
|
|
6422
|
-
return null;
|
|
6423
|
-
}
|
|
6424
|
-
}
|
|
6425
|
-
async function validateCompletedSegments(manifest, expectedHash, probeFrames) {
|
|
6426
|
-
const ok = /* @__PURE__ */ new Set();
|
|
6427
|
-
if (manifest.planHash !== expectedHash) return ok;
|
|
6428
|
-
for (const entry of manifest.completed) {
|
|
6429
|
-
if (!existsSync8(entry.path)) continue;
|
|
6430
|
-
const size = statSync6(entry.path).size;
|
|
6431
|
-
if (size <= 0 || size !== entry.bytes) continue;
|
|
6432
|
-
const frames = await probeFrames(entry.path);
|
|
6433
|
-
if (frames !== entry.endFrame - entry.startFrame) continue;
|
|
6434
|
-
ok.add(entry.index);
|
|
6435
|
-
}
|
|
6436
|
-
return ok;
|
|
6437
|
-
}
|
|
6438
|
-
|
|
6439
6490
|
// src/services/render/hdrMode.ts
|
|
6440
6491
|
import {
|
|
6441
6492
|
analyzeCompositionHdr,
|
|
@@ -7016,14 +7067,14 @@ function countAuthoredTimedClips(html) {
|
|
|
7016
7067
|
|
|
7017
7068
|
// src/services/render/stages/compileStage.ts
|
|
7018
7069
|
import { existsSync as existsSync13, writeFileSync as writeFileSync5 } from "node:fs";
|
|
7019
|
-
import { join as
|
|
7070
|
+
import { join as join22, relative as relative4 } from "node:path";
|
|
7020
7071
|
import { privateCacheRoot } from "@hyperframes/engine";
|
|
7021
7072
|
import { suggestMatchingPreset } from "@hyperframes/core";
|
|
7022
7073
|
import { extractStandaloneEntryFromIndex, isTemplateEntry } from "@hyperframes/core/compiler";
|
|
7023
7074
|
import { readTextFile as readTextFile2 } from "@hyperframes/parsers/asset-resolution";
|
|
7024
7075
|
|
|
7025
7076
|
// src/services/compositionSizeLimit.ts
|
|
7026
|
-
import { statSync as
|
|
7077
|
+
import { statSync as statSync6 } from "node:fs";
|
|
7027
7078
|
var MAX_COMPOSITION_HTML_BYTES = 16 * 1024 * 1024;
|
|
7028
7079
|
var COMPOSITION_TOO_LARGE = "COMPOSITION_TOO_LARGE";
|
|
7029
7080
|
var megabytes = (bytes) => `${(bytes / (1024 * 1024)).toFixed(1)} MB`;
|
|
@@ -7099,7 +7150,7 @@ var CompositionExpansionBudget = class {
|
|
|
7099
7150
|
function assertCompositionFileSize(path, file) {
|
|
7100
7151
|
let bytes;
|
|
7101
7152
|
try {
|
|
7102
|
-
const stats =
|
|
7153
|
+
const stats = statSync6(path);
|
|
7103
7154
|
if (!stats.isFile()) return;
|
|
7104
7155
|
bytes = stats.size;
|
|
7105
7156
|
} catch {
|
|
@@ -7124,19 +7175,19 @@ import {
|
|
|
7124
7175
|
stylesheetLinkMatches
|
|
7125
7176
|
} from "@hyperframes/parsers/css-url-scans";
|
|
7126
7177
|
import { createHash as createHash6 } from "node:crypto";
|
|
7127
|
-
import { createReadStream as
|
|
7128
|
-
import { join as
|
|
7178
|
+
import { createReadStream as createReadStream3, existsSync as existsSync12, mkdirSync as mkdirSync9, readFileSync as readFileSync8 } from "fs";
|
|
7179
|
+
import { join as join21, dirname as dirname9, resolve as resolve8, basename as basename6, relative as relative3, sep as sep4 } from "path";
|
|
7129
7180
|
import { parseHTML as parseHTML5 } from "linkedom";
|
|
7130
7181
|
|
|
7131
7182
|
// src/services/bundledScripts.ts
|
|
7132
7183
|
import { existsSync as existsSync9, readFileSync as readFileSync5 } from "node:fs";
|
|
7133
|
-
import { join as
|
|
7184
|
+
import { join as join17 } from "node:path";
|
|
7134
7185
|
import { gsapCdnDist } from "@hyperframes/core/gsap-cdn";
|
|
7135
7186
|
var GSAP_VENDOR_DIR_ENV = "HYPERFRAMES_GSAP_VENDOR_DIR";
|
|
7136
7187
|
function bundledScript(url) {
|
|
7137
7188
|
const dir = process.env[GSAP_VENDOR_DIR_ENV];
|
|
7138
7189
|
if (!dir || url !== `${gsapCdnDist()}gsap.min.js`) return null;
|
|
7139
|
-
const file =
|
|
7190
|
+
const file = join17(dir, "gsap.min.js");
|
|
7140
7191
|
return existsSync9(file) ? readFileSync5(file) : null;
|
|
7141
7192
|
}
|
|
7142
7193
|
|
|
@@ -7395,8 +7446,8 @@ import {
|
|
|
7395
7446
|
|
|
7396
7447
|
// src/services/animatedGifPrep.ts
|
|
7397
7448
|
import { createHash as createHash4 } from "node:crypto";
|
|
7398
|
-
import { copyFileSync as copyFileSync2, existsSync as existsSync10, mkdirSync as mkdirSync7, readFileSync as readFileSync6, rmSync as rmSync9, statSync as
|
|
7399
|
-
import { dirname as dirname6, isAbsolute as isAbsolute3, join as
|
|
7449
|
+
import { copyFileSync as copyFileSync2, existsSync as existsSync10, mkdirSync as mkdirSync7, readFileSync as readFileSync6, rmSync as rmSync9, statSync as statSync7 } from "node:fs";
|
|
7450
|
+
import { dirname as dirname6, isAbsolute as isAbsolute3, join as join18, resolve as resolve6 } from "node:path";
|
|
7400
7451
|
import { parseHTML as parseHTML3 } from "linkedom";
|
|
7401
7452
|
import { parseAnimatedGifMetadata } from "@hyperframes/core";
|
|
7402
7453
|
import {
|
|
@@ -7454,7 +7505,7 @@ function resolveLocalImageSourcePath(src, options) {
|
|
|
7454
7505
|
}
|
|
7455
7506
|
function isUsableFile(path) {
|
|
7456
7507
|
try {
|
|
7457
|
-
const stat =
|
|
7508
|
+
const stat = statSync7(path);
|
|
7458
7509
|
return stat.isFile() && stat.size > 0;
|
|
7459
7510
|
} catch {
|
|
7460
7511
|
return false;
|
|
@@ -7649,7 +7700,7 @@ function replaceImageWithVideo(input) {
|
|
|
7649
7700
|
return video;
|
|
7650
7701
|
}
|
|
7651
7702
|
async function prepareAnimatedGifInputs(html, options) {
|
|
7652
|
-
const outputDir = options.outputDir ??
|
|
7703
|
+
const outputDir = options.outputDir ?? join18(options.downloadDir, PREPARED_GIF_SUBDIR);
|
|
7653
7704
|
const outputSrcPrefix = normalizeRelPath(options.outputSrcPrefix ?? PREPARED_GIF_SUBDIR);
|
|
7654
7705
|
const cacheDir = options.cacheDir ?? outputDir;
|
|
7655
7706
|
const { document: document2 } = parseHTML3(html);
|
|
@@ -7676,8 +7727,8 @@ async function prepareAnimatedGifInputs(html, options) {
|
|
|
7676
7727
|
);
|
|
7677
7728
|
const hash = computePreparedGifHash(bytes, loopIterations, padSeconds);
|
|
7678
7729
|
const filename = `${CACHE_SCHEMA}-${hash.slice(0, 24)}.webm`;
|
|
7679
|
-
const cachePath =
|
|
7680
|
-
const outputPath =
|
|
7730
|
+
const cachePath = join18(cacheDir, filename);
|
|
7731
|
+
const outputPath = join18(outputDir, filename);
|
|
7681
7732
|
const outputSrc = `${outputSrcPrefix}/${filename}`;
|
|
7682
7733
|
await ensurePreparedWebm({
|
|
7683
7734
|
sourcePath,
|
|
@@ -7719,10 +7770,10 @@ import {
|
|
|
7719
7770
|
readFileSync as readFileSync7,
|
|
7720
7771
|
readSync as readSync3,
|
|
7721
7772
|
rmSync as rmSync10,
|
|
7722
|
-
statSync as
|
|
7773
|
+
statSync as statSync8,
|
|
7723
7774
|
writeFileSync as writeFileSync4
|
|
7724
7775
|
} from "node:fs";
|
|
7725
|
-
import { dirname as dirname7, join as
|
|
7776
|
+
import { dirname as dirname7, join as join19, resolve as resolve7 } from "node:path";
|
|
7726
7777
|
import { parseHTML as parseHTML4 } from "linkedom";
|
|
7727
7778
|
import { renameWithRetry as renameWithRetry4, runFfmpeg as runFfmpeg3, runFfprobe, urlInputArgs as urlInputArgs3 } from "@hyperframes/engine";
|
|
7728
7779
|
|
|
@@ -7963,7 +8014,7 @@ function resolveImageSource(src, options) {
|
|
|
7963
8014
|
}
|
|
7964
8015
|
function isUsableFile2(path) {
|
|
7965
8016
|
try {
|
|
7966
|
-
return
|
|
8017
|
+
return statSync8(path).size > 0;
|
|
7967
8018
|
} catch {
|
|
7968
8019
|
return false;
|
|
7969
8020
|
}
|
|
@@ -7997,7 +8048,7 @@ async function ensurePreparedJpeg(source, cachePath, outputPath, options) {
|
|
|
7997
8048
|
}
|
|
7998
8049
|
}
|
|
7999
8050
|
async function prepareHeifImageInputs(html, options) {
|
|
8000
|
-
const outputDir = options.outputDir ??
|
|
8051
|
+
const outputDir = options.outputDir ?? join19(options.downloadDir, PREPARED_HEIF_SUBDIR);
|
|
8001
8052
|
const outputSrcPrefix = normalizeRelPath(options.outputSrcPrefix ?? PREPARED_HEIF_SUBDIR);
|
|
8002
8053
|
const cacheDir = options.cacheDir ?? outputDir;
|
|
8003
8054
|
const preparedAssets = /* @__PURE__ */ new Map();
|
|
@@ -8018,7 +8069,7 @@ async function prepareHeifImageInputs(html, options) {
|
|
|
8018
8069
|
await Promise.all(
|
|
8019
8070
|
[...unique].map(
|
|
8020
8071
|
([filename, source]) => withMediaProbeSlot(
|
|
8021
|
-
() => ensurePreparedJpeg(source,
|
|
8072
|
+
() => ensurePreparedJpeg(source, join19(cacheDir, filename), join19(outputDir, filename), options)
|
|
8022
8073
|
).catch((error) => {
|
|
8023
8074
|
if (!options.onFailure) throw error;
|
|
8024
8075
|
failed.add(filename);
|
|
@@ -8030,8 +8081,8 @@ async function prepareHeifImageInputs(html, options) {
|
|
|
8030
8081
|
if (failed.has(filename)) continue;
|
|
8031
8082
|
const outputSrc = `${outputSrcPrefix}/${filename}`;
|
|
8032
8083
|
img.setAttribute("src", outputSrc);
|
|
8033
|
-
preparedAssets.set(outputSrc,
|
|
8034
|
-
preparedImages.push({ sourceSrc: src, outputSrc, outputPath:
|
|
8084
|
+
preparedAssets.set(outputSrc, join19(outputDir, filename));
|
|
8085
|
+
preparedImages.push({ sourceSrc: src, outputSrc, outputPath: join19(outputDir, filename) });
|
|
8035
8086
|
}
|
|
8036
8087
|
return { html: document2.toString(), preparedAssets, preparedImages };
|
|
8037
8088
|
}
|
|
@@ -8042,7 +8093,7 @@ import { getPositionEditsRenderScript } from "@hyperframes/core/runtime/position
|
|
|
8042
8093
|
|
|
8043
8094
|
// src/services/assetMediaType.ts
|
|
8044
8095
|
import { existsSync as existsSync11 } from "node:fs";
|
|
8045
|
-
import { dirname as dirname8, join as
|
|
8096
|
+
import { dirname as dirname8, join as join20 } from "node:path";
|
|
8046
8097
|
import {
|
|
8047
8098
|
fingerprintElementId,
|
|
8048
8099
|
isHttpUrl as isHttpUrl2,
|
|
@@ -8095,11 +8146,11 @@ function assertAssetMediaTypeProfile(expected, profile, elementIdentity) {
|
|
|
8095
8146
|
]);
|
|
8096
8147
|
}
|
|
8097
8148
|
function mediaAssetRoots(projectDir, compiledDir) {
|
|
8098
|
-
return [projectDir, compiledDir,
|
|
8149
|
+
return [projectDir, compiledDir, join20(dirname8(compiledDir), "downloads")];
|
|
8099
8150
|
}
|
|
8100
8151
|
function dropMediaOutsideProject(input) {
|
|
8101
8152
|
const { projectDir, workDir, composition, log } = input;
|
|
8102
|
-
const compiledDir =
|
|
8153
|
+
const compiledDir = join20(workDir, "compiled");
|
|
8103
8154
|
const roots = mediaAssetRoots(projectDir, compiledDir);
|
|
8104
8155
|
const staysInside = ({ id, src }) => {
|
|
8105
8156
|
if (!src || isHttpUrl2(src)) return true;
|
|
@@ -8450,7 +8501,7 @@ function detectShaderTransitionUsage(html) {
|
|
|
8450
8501
|
async function resolveMediaDuration(src, mediaStart, playbackRate, projectDir, baseDir, downloadDir, tagName, elementIdentity, log, urlByAbsentLocalPath, probes, assetRoot) {
|
|
8451
8502
|
let filePath = src;
|
|
8452
8503
|
if (isHttpUrl(src)) {
|
|
8453
|
-
const remoteDir =
|
|
8504
|
+
const remoteDir = join21(downloadDir, REMOTE_MEDIA_SUBDIR);
|
|
8454
8505
|
if (!existsSync12(remoteDir)) mkdirSync9(remoteDir, { recursive: true });
|
|
8455
8506
|
try {
|
|
8456
8507
|
filePath = await downloadToTemp(src, remoteDir, void 0, void 0, void 0, {
|
|
@@ -8461,7 +8512,7 @@ async function resolveMediaDuration(src, mediaStart, playbackRate, projectDir, b
|
|
|
8461
8512
|
}
|
|
8462
8513
|
} else {
|
|
8463
8514
|
filePath = decodedUrlPath(src);
|
|
8464
|
-
if (!filePath.startsWith("/")) filePath =
|
|
8515
|
+
if (!filePath.startsWith("/")) filePath = join21(baseDir, filePath);
|
|
8465
8516
|
if (escapesAssetRoot(filePath, assetRoot) || isPrivateUnderAssetRoots3(filePath, [projectDir, downloadDir])) {
|
|
8466
8517
|
return { duration: null, resolvedPath: filePath };
|
|
8467
8518
|
}
|
|
@@ -9195,7 +9246,7 @@ async function localizeRemoteMediaSources(html, downloadDir) {
|
|
|
9195
9246
|
const localized = await downloadAndRewriteUrls(
|
|
9196
9247
|
urlSet,
|
|
9197
9248
|
html,
|
|
9198
|
-
|
|
9249
|
+
join21(downloadDir, REMOTE_MEDIA_SUBDIR),
|
|
9199
9250
|
"Remote media download failed",
|
|
9200
9251
|
"Localized remote media source(s)"
|
|
9201
9252
|
);
|
|
@@ -9218,7 +9269,7 @@ async function localizeRemoteImageSources(html, downloadDir) {
|
|
|
9218
9269
|
return downloadAndRewriteUrls(
|
|
9219
9270
|
urlSet,
|
|
9220
9271
|
html,
|
|
9221
|
-
|
|
9272
|
+
join21(downloadDir, REMOTE_MEDIA_SUBDIR),
|
|
9222
9273
|
"Remote image download failed",
|
|
9223
9274
|
"Localized remote image source(s)"
|
|
9224
9275
|
);
|
|
@@ -9231,7 +9282,7 @@ async function localizeRemoteBackgroundImages(html, downloadDir) {
|
|
|
9231
9282
|
return downloadAndRewriteUrls(
|
|
9232
9283
|
urlSet,
|
|
9233
9284
|
html,
|
|
9234
|
-
|
|
9285
|
+
join21(downloadDir, REMOTE_MEDIA_SUBDIR),
|
|
9235
9286
|
"Remote background-image download failed",
|
|
9236
9287
|
"Localized remote background-image(s)",
|
|
9237
9288
|
// Quoted url('..')/url("..") are rewritten by downloadAndRewriteUrls' default
|
|
@@ -9384,7 +9435,7 @@ function localizeFontFaceUrls(html, downloadDir) {
|
|
|
9384
9435
|
return downloadAndRewriteUrls(
|
|
9385
9436
|
collectFontFaceUrls(html),
|
|
9386
9437
|
html,
|
|
9387
|
-
|
|
9438
|
+
join21(downloadDir, REMOTE_MEDIA_SUBDIR),
|
|
9388
9439
|
"Remote font download failed",
|
|
9389
9440
|
"Localized remote font face(s)",
|
|
9390
9441
|
(h, url, relPath) => h.replaceAll(`url(${url})`, `url("${relPath}")`)
|
|
@@ -9394,7 +9445,7 @@ var MAX_LOCAL_FONT_DATA_URI_BYTES = 5 * 1024 * 1024;
|
|
|
9394
9445
|
async function readLocalFont(absPath) {
|
|
9395
9446
|
const chunks = [];
|
|
9396
9447
|
let totalBytes = 0;
|
|
9397
|
-
for await (const chunk of
|
|
9448
|
+
for await (const chunk of createReadStream3(absPath)) {
|
|
9398
9449
|
const buffer = Buffer.isBuffer(chunk) ? chunk : Buffer.from(chunk);
|
|
9399
9450
|
totalBytes += buffer.length;
|
|
9400
9451
|
if (totalBytes > MAX_LOCAL_FONT_DATA_URI_BYTES) {
|
|
@@ -10154,7 +10205,7 @@ async function recompileWithResolutions(compiled, resolutions, projectDir, downl
|
|
|
10154
10205
|
function animatedGifCacheDir(extractCacheDir) {
|
|
10155
10206
|
try {
|
|
10156
10207
|
const root = extractCacheDir && privateCacheRoot(extractCacheDir);
|
|
10157
|
-
return root ?
|
|
10208
|
+
return root ? join22(root, "animated-gif") : void 0;
|
|
10158
10209
|
} catch {
|
|
10159
10210
|
return void 0;
|
|
10160
10211
|
}
|
|
@@ -10182,10 +10233,10 @@ function resolveEntryHtmlPath(input) {
|
|
|
10182
10233
|
assertCompositionFileSize(path, relative4(projectDir, path));
|
|
10183
10234
|
return readTextFile2(path);
|
|
10184
10235
|
};
|
|
10185
|
-
const htmlPath =
|
|
10236
|
+
const htmlPath = join22(projectDir, entryFile);
|
|
10186
10237
|
const rawEntry = readEntry(htmlPath);
|
|
10187
10238
|
if (entryFile === "index.html" || !isTemplateEntry(rawEntry)) return htmlPath;
|
|
10188
|
-
const projectIndexPath =
|
|
10239
|
+
const projectIndexPath = join22(projectDir, "index.html");
|
|
10189
10240
|
if (!existsSync13(projectIndexPath)) {
|
|
10190
10241
|
throw new Error(
|
|
10191
10242
|
`Template entry file "${entryFile}" requires a project index.html to extract its render shell.`
|
|
@@ -10201,7 +10252,7 @@ function resolveEntryHtmlPath(input) {
|
|
|
10201
10252
|
`Entry file "${entryFile}" is not mounted from index.html via data-composition-src, so it cannot be rendered independently.`
|
|
10202
10253
|
);
|
|
10203
10254
|
}
|
|
10204
|
-
const wrapperPath =
|
|
10255
|
+
const wrapperPath = join22(workDir, "standalone-entry.html");
|
|
10205
10256
|
writeFileSync5(wrapperPath, standaloneHtml, "utf-8");
|
|
10206
10257
|
log.info("Extracted standalone entry from index.html host context", { entryFile });
|
|
10207
10258
|
return wrapperPath;
|
|
@@ -10231,7 +10282,7 @@ async function runCompileStage(input) {
|
|
|
10231
10282
|
const assetRoot = job.config.allowOutsideProjectAssets ? void 0 : projectDir;
|
|
10232
10283
|
const htmlPath = resolveEntryHtmlPath({ projectDir, workDir, entryFile, log, assetRoot });
|
|
10233
10284
|
const compileStart = Date.now();
|
|
10234
|
-
const compiled = await compileForRender(projectDir, htmlPath,
|
|
10285
|
+
const compiled = await compileForRender(projectDir, htmlPath, join22(workDir, "downloads"), {
|
|
10235
10286
|
log,
|
|
10236
10287
|
failClosedFontFetch: failClosedFontFetch === true,
|
|
10237
10288
|
allowSystemFontCapture,
|
|
@@ -10306,7 +10357,7 @@ async function runCompileStage(input) {
|
|
|
10306
10357
|
});
|
|
10307
10358
|
await preflightCompositionAssetMediaTypes({
|
|
10308
10359
|
projectDir,
|
|
10309
|
-
compiledDir:
|
|
10360
|
+
compiledDir: join22(workDir, "compiled"),
|
|
10310
10361
|
composition,
|
|
10311
10362
|
signal: abortSignal
|
|
10312
10363
|
});
|
|
@@ -10354,7 +10405,7 @@ async function runCompileStage(input) {
|
|
|
10354
10405
|
|
|
10355
10406
|
// src/services/render/stages/probeStage.ts
|
|
10356
10407
|
import { createHash as createHash7 } from "node:crypto";
|
|
10357
|
-
import { basename as basename7, join as
|
|
10408
|
+
import { basename as basename7, join as join23 } from "node:path";
|
|
10358
10409
|
import { parseHTML as parseHTML6 } from "linkedom";
|
|
10359
10410
|
import {
|
|
10360
10411
|
closeCaptureSession as closeCaptureSession4,
|
|
@@ -10668,7 +10719,7 @@ async function runProbeStage(input) {
|
|
|
10668
10719
|
});
|
|
10669
10720
|
fileServer = await createFileServer({
|
|
10670
10721
|
projectDir,
|
|
10671
|
-
compiledDir:
|
|
10722
|
+
compiledDir: join23(workDir, "compiled"),
|
|
10672
10723
|
port: 0,
|
|
10673
10724
|
preHeadScripts: [VIRTUAL_TIME_SHIM],
|
|
10674
10725
|
fps: job.config.fps,
|
|
@@ -10705,7 +10756,7 @@ async function runProbeStage(input) {
|
|
|
10705
10756
|
log.info("Creating capture session...", { attempt, maxAttempts: PROBE_MAX_ATTEMPTS });
|
|
10706
10757
|
probeSession = await createCaptureSession4(
|
|
10707
10758
|
fileServer.url,
|
|
10708
|
-
|
|
10759
|
+
join23(workDir, "probe"),
|
|
10709
10760
|
captureOpts,
|
|
10710
10761
|
null,
|
|
10711
10762
|
probeCfg
|
|
@@ -10790,7 +10841,7 @@ async function runProbeStage(input) {
|
|
|
10790
10841
|
});
|
|
10791
10842
|
probeSession = await createCaptureSession4(
|
|
10792
10843
|
fileServer.url,
|
|
10793
|
-
|
|
10844
|
+
join23(workDir, "probe-screenshot"),
|
|
10794
10845
|
captureOpts,
|
|
10795
10846
|
null,
|
|
10796
10847
|
{ ...probeCfg, forceScreenshot: true }
|
|
@@ -10828,7 +10879,7 @@ async function runProbeStage(input) {
|
|
|
10828
10879
|
compiled,
|
|
10829
10880
|
resolutions,
|
|
10830
10881
|
projectDir,
|
|
10831
|
-
|
|
10882
|
+
join23(workDir, "downloads"),
|
|
10832
10883
|
job.config.allowOutsideProjectAssets ? void 0 : projectDir,
|
|
10833
10884
|
{ includeScripts: job.config.includeOutsideScripts }
|
|
10834
10885
|
);
|
|
@@ -11028,7 +11079,7 @@ async function runProbeStage(input) {
|
|
|
11028
11079
|
});
|
|
11029
11080
|
await preflightCompositionAssetMediaTypes({
|
|
11030
11081
|
projectDir,
|
|
11031
|
-
compiledDir:
|
|
11082
|
+
compiledDir: join23(workDir, "compiled"),
|
|
11032
11083
|
composition,
|
|
11033
11084
|
signal: abortSignal
|
|
11034
11085
|
});
|
|
@@ -11164,7 +11215,7 @@ function validateRenderDuration(input) {
|
|
|
11164
11215
|
|
|
11165
11216
|
// src/services/render/stages/extractVideosStage.ts
|
|
11166
11217
|
import { existsSync as existsSync14 } from "node:fs";
|
|
11167
|
-
import { join as
|
|
11218
|
+
import { join as join24 } from "node:path";
|
|
11168
11219
|
import {
|
|
11169
11220
|
classifyVideoExtractionError,
|
|
11170
11221
|
createFrameLookupTable as createFrameLookupTable3,
|
|
@@ -11523,7 +11574,7 @@ async function runExtractVideosStage(input) {
|
|
|
11523
11574
|
// because short boundary counts can differ by one frame.
|
|
11524
11575
|
{
|
|
11525
11576
|
fps: job.config.fps,
|
|
11526
|
-
outputDir:
|
|
11577
|
+
outputDir: join24(compiledDir, "__hyperframes_video_frames"),
|
|
11527
11578
|
format: job.config.videoFrameFormat ?? "auto",
|
|
11528
11579
|
toneMapHdrToSdr: rendersSdrOnly(job.config, composition),
|
|
11529
11580
|
timelineEnd: composition.duration,
|
|
@@ -11531,7 +11582,7 @@ async function runExtractVideosStage(input) {
|
|
|
11531
11582
|
collectProbeFailures: extractionPolicy.failureMode === "enforce",
|
|
11532
11583
|
deferRangeExtraction,
|
|
11533
11584
|
shownBoxes,
|
|
11534
|
-
contentKeyedDirs: [
|
|
11585
|
+
contentKeyedDirs: [join24(compiledDir, REMOTE_MEDIA_SUBDIR)],
|
|
11535
11586
|
urlByAbsentLocalPath,
|
|
11536
11587
|
assetRoots,
|
|
11537
11588
|
onProgress: ({ planned = 0, done = 0 }) => {
|
|
@@ -11623,7 +11674,7 @@ async function remoteProbeSource(video, input) {
|
|
|
11623
11674
|
if (!isPublicHttpsUrl(video.src)) return null;
|
|
11624
11675
|
if (!resolveRestrictPageNetwork()) return video.src;
|
|
11625
11676
|
if (!video.hasAudio || video.hidden) return null;
|
|
11626
|
-
const downloadDir = input.downloadDir ??
|
|
11677
|
+
const downloadDir = input.downloadDir ?? join24(input.compiledDir, REMOTE_MEDIA_SUBDIR);
|
|
11627
11678
|
try {
|
|
11628
11679
|
return await downloadToTemp2(video.src, downloadDir, void 0, input.signal, void 0, {
|
|
11629
11680
|
onTelemetry: writeUrlDownloadTelemetry2
|
|
@@ -11748,7 +11799,7 @@ async function planVideoLayerPassthrough(input) {
|
|
|
11748
11799
|
|
|
11749
11800
|
// src/services/render/stages/audioStage.ts
|
|
11750
11801
|
import { existsSync as existsSync17 } from "node:fs";
|
|
11751
|
-
import { join as
|
|
11802
|
+
import { join as join27 } from "node:path";
|
|
11752
11803
|
import {
|
|
11753
11804
|
MIXED_AUDIO_FILENAME,
|
|
11754
11805
|
audioFailureDiagnostics,
|
|
@@ -11760,7 +11811,7 @@ import {
|
|
|
11760
11811
|
|
|
11761
11812
|
// src/services/render/audioDeliveryLimit.ts
|
|
11762
11813
|
import { existsSync as existsSync16 } from "node:fs";
|
|
11763
|
-
import { dirname as dirname11, join as
|
|
11814
|
+
import { dirname as dirname11, join as join26 } from "node:path";
|
|
11764
11815
|
import {
|
|
11765
11816
|
applyAudioFxChain,
|
|
11766
11817
|
describeFfmpegFailure as describeFfmpegFailure3,
|
|
@@ -11770,7 +11821,7 @@ import {
|
|
|
11770
11821
|
|
|
11771
11822
|
// src/services/render/audioPadTrim.ts
|
|
11772
11823
|
import { spawn } from "node:child_process";
|
|
11773
|
-
import { dirname as dirname10, join as
|
|
11824
|
+
import { dirname as dirname10, join as join25 } from "node:path";
|
|
11774
11825
|
import {
|
|
11775
11826
|
DEFAULT_CONFIG,
|
|
11776
11827
|
describeFfmpegFailure as describeFfmpegFailure2,
|
|
@@ -12051,7 +12102,7 @@ async function constrainAacTruePeak(input) {
|
|
|
12051
12102
|
}
|
|
12052
12103
|
async function cutSource(input, scratchDir, attenuationDb) {
|
|
12053
12104
|
if (!input.sourcePath || !input.rewriteSource) return true;
|
|
12054
|
-
const cutPath =
|
|
12105
|
+
const cutPath = join25(scratchDir, "source.wav");
|
|
12055
12106
|
try {
|
|
12056
12107
|
const result = await input.rewriteSource(input.sourcePath, cutPath, gainFilter(attenuationDb));
|
|
12057
12108
|
if (!result.success) throw new Error(result.error);
|
|
@@ -12066,7 +12117,7 @@ async function enforceAacTruePeak(input) {
|
|
|
12066
12117
|
let scratchDir;
|
|
12067
12118
|
try {
|
|
12068
12119
|
scratchDir = createStagingDir3(dirname10(input.audioPath), ".true-peak-");
|
|
12069
|
-
const correctedPath =
|
|
12120
|
+
const correctedPath = join25(scratchDir, "audio.m4a");
|
|
12070
12121
|
const measurements = [];
|
|
12071
12122
|
let attenuationDb = 0;
|
|
12072
12123
|
let sourcePeakDbfs;
|
|
@@ -12286,7 +12337,7 @@ async function limitDeliveryPeaks(input, deps = {
|
|
|
12286
12337
|
const peak = await deps.measure(audioPath, { timeoutMs, signal });
|
|
12287
12338
|
if (peak <= AAC_DELIVERY_TRUE_PEAK_DBFS) return { success: true };
|
|
12288
12339
|
const alternating = ["a", "b"].map(
|
|
12289
|
-
(k) =>
|
|
12340
|
+
(k) => join26(dirname11(sourcePath), `audio-source-limited-${k}.wav`)
|
|
12290
12341
|
);
|
|
12291
12342
|
let encodedFrom;
|
|
12292
12343
|
let ceiling = AAC_DELIVERY_TRUE_PEAK_DBFS;
|
|
@@ -12359,7 +12410,7 @@ function runAudioStage(input) {
|
|
|
12359
12410
|
}
|
|
12360
12411
|
async function runAudioStageScoped(input) {
|
|
12361
12412
|
const stageStart = Date.now();
|
|
12362
|
-
const pcmSourcePath =
|
|
12413
|
+
const pcmSourcePath = join27(input.workDir, "audio-source.wav");
|
|
12363
12414
|
const duration = input.totalFrames * input.fps.den / input.fps.num;
|
|
12364
12415
|
let deliverySourcePath;
|
|
12365
12416
|
try {
|
|
@@ -12424,7 +12475,7 @@ async function mixAudioForDelivery(input, duration, pcmSourcePath) {
|
|
|
12424
12475
|
assertNotAborted,
|
|
12425
12476
|
log
|
|
12426
12477
|
} = input;
|
|
12427
|
-
const audioOutputPath =
|
|
12478
|
+
const audioOutputPath = join27(workDir, MIXED_AUDIO_FILENAME);
|
|
12428
12479
|
let hasAudio = false;
|
|
12429
12480
|
let audioError;
|
|
12430
12481
|
let audioFailures;
|
|
@@ -12505,7 +12556,7 @@ async function mixAudioForDelivery(input, duration, pcmSourcePath) {
|
|
|
12505
12556
|
|
|
12506
12557
|
// src/services/render/stages/captureStage.ts
|
|
12507
12558
|
import { existsSync as existsSync18, readdirSync as readdirSync4, statfsSync as statfsSync2 } from "node:fs";
|
|
12508
|
-
import { join as
|
|
12559
|
+
import { join as join28 } from "node:path";
|
|
12509
12560
|
import {
|
|
12510
12561
|
classifyCaptureFailure as classifyCaptureFailure2,
|
|
12511
12562
|
frameFileExtension,
|
|
@@ -12578,13 +12629,13 @@ function measureCaptureFrameBytes(workDir, framesDir) {
|
|
|
12578
12629
|
if (!existsSync18(workDir)) return total;
|
|
12579
12630
|
for (const attempt of readdirSync4(workDir)) {
|
|
12580
12631
|
if (/^retry-\d+-batch-\d+-worker-\d+$/.test(attempt)) {
|
|
12581
|
-
total += sampleDirectoryBytes(
|
|
12632
|
+
total += sampleDirectoryBytes(join28(workDir, attempt));
|
|
12582
12633
|
continue;
|
|
12583
12634
|
}
|
|
12584
12635
|
if (!/^capture-attempt-\d+$/.test(attempt)) continue;
|
|
12585
|
-
const attemptDir =
|
|
12636
|
+
const attemptDir = join28(workDir, attempt);
|
|
12586
12637
|
for (const name of readdirSync4(attemptDir)) {
|
|
12587
|
-
if (/^worker-\d+$/.test(name)) total += sampleDirectoryBytes(
|
|
12638
|
+
if (/^worker-\d+$/.test(name)) total += sampleDirectoryBytes(join28(attemptDir, name));
|
|
12588
12639
|
}
|
|
12589
12640
|
}
|
|
12590
12641
|
return total;
|
|
@@ -12883,7 +12934,7 @@ async function captureSessionFrames(session, { input, rangeStart, rangeEnd, resu
|
|
|
12883
12934
|
|
|
12884
12935
|
// src/services/render/stages/captureHdrStage.ts
|
|
12885
12936
|
import { existsSync as existsSync20, mkdirSync as mkdirSync10 } from "node:fs";
|
|
12886
|
-
import { join as
|
|
12937
|
+
import { join as join32 } from "node:path";
|
|
12887
12938
|
import {
|
|
12888
12939
|
closeCaptureSession as closeCaptureSession7,
|
|
12889
12940
|
cloneCaptureWarnings as cloneCaptureWarnings2,
|
|
@@ -12955,7 +13006,7 @@ function createHdrImageTransferCache(options = {}) {
|
|
|
12955
13006
|
}
|
|
12956
13007
|
|
|
12957
13008
|
// src/services/render/stages/captureHdrSequentialLoop.ts
|
|
12958
|
-
import { join as
|
|
13009
|
+
import { join as join29 } from "node:path";
|
|
12959
13010
|
import {
|
|
12960
13011
|
TRANSITIONS,
|
|
12961
13012
|
crossfade
|
|
@@ -13080,7 +13131,7 @@ async function runSequentialLayeredFrameLoop(input) {
|
|
|
13080
13131
|
);
|
|
13081
13132
|
if (debugDumpEnabled && debugDumpDir && i % 30 === 0) {
|
|
13082
13133
|
writeFileExclusiveSync(
|
|
13083
|
-
|
|
13134
|
+
join29(debugDumpDir, `frame_${String(i).padStart(4, "0")}_final_rgb48le.bin`),
|
|
13084
13135
|
normalCanvas
|
|
13085
13136
|
);
|
|
13086
13137
|
}
|
|
@@ -13112,7 +13163,7 @@ async function runSequentialLayeredFrameLoop(input) {
|
|
|
13112
13163
|
}
|
|
13113
13164
|
|
|
13114
13165
|
// src/services/render/stages/captureHdrHybridLoop.ts
|
|
13115
|
-
import { join as
|
|
13166
|
+
import { join as join31 } from "node:path";
|
|
13116
13167
|
import {
|
|
13117
13168
|
TRANSITIONS as TRANSITIONS2,
|
|
13118
13169
|
closeCaptureSession as closeCaptureSession6,
|
|
@@ -13126,7 +13177,7 @@ import {
|
|
|
13126
13177
|
// src/services/shaderTransitionWorkerPool.ts
|
|
13127
13178
|
import { Worker } from "node:worker_threads";
|
|
13128
13179
|
import { fileURLToPath as fileURLToPath3, pathToFileURL } from "node:url";
|
|
13129
|
-
import { dirname as dirname12, join as
|
|
13180
|
+
import { dirname as dirname12, join as join30 } from "node:path";
|
|
13130
13181
|
import { createRequire } from "node:module";
|
|
13131
13182
|
import { usableCpuCount } from "@hyperframes/engine";
|
|
13132
13183
|
import { existsSync as existsSync19 } from "node:fs";
|
|
@@ -13140,9 +13191,9 @@ function resolveWorkerEntry(explicit) {
|
|
|
13140
13191
|
return { path: override, isTs };
|
|
13141
13192
|
}
|
|
13142
13193
|
const moduleDir = dirname12(fileURLToPath3(import.meta.url));
|
|
13143
|
-
const jsPath =
|
|
13194
|
+
const jsPath = join30(moduleDir, "shaderTransitionWorker.js");
|
|
13144
13195
|
if (existsSync19(jsPath)) return { path: jsPath, isTs: false };
|
|
13145
|
-
const tsPath =
|
|
13196
|
+
const tsPath = join30(moduleDir, "shaderTransitionWorker.ts");
|
|
13146
13197
|
return { path: tsPath, isTs: true };
|
|
13147
13198
|
}
|
|
13148
13199
|
function buildExecArgv(entryIsTs) {
|
|
@@ -13510,7 +13561,7 @@ async function runHybridLayeredFrameLoop(input) {
|
|
|
13510
13561
|
);
|
|
13511
13562
|
if (debugDumpEnabled && debugDumpDir && i % 30 === 0) {
|
|
13512
13563
|
writeFileExclusiveSync(
|
|
13513
|
-
|
|
13564
|
+
join31(debugDumpDir, `frame_${String(i).padStart(4, "0")}_final_rgb48le.bin`),
|
|
13514
13565
|
canvas
|
|
13515
13566
|
);
|
|
13516
13567
|
}
|
|
@@ -13706,7 +13757,7 @@ async function runCaptureHdrStage(input) {
|
|
|
13706
13757
|
if (hdrVideoFrameSources.has(v.id)) hdrVideoEndTimes.set(v.id, v.end);
|
|
13707
13758
|
}
|
|
13708
13759
|
const debugDumpEnabled = process.env.KEEP_TEMP === "1";
|
|
13709
|
-
const debugDumpDir = debugDumpEnabled ?
|
|
13760
|
+
const debugDumpDir = debugDumpEnabled ? join32(framesDir, "debug-composite") : null;
|
|
13710
13761
|
if (debugDumpDir && !existsSync20(debugDumpDir)) {
|
|
13711
13762
|
mkdirSync10(debugDumpDir, { recursive: true });
|
|
13712
13763
|
}
|
|
@@ -13871,11 +13922,11 @@ import {
|
|
|
13871
13922
|
readdirSync as readdirSync5,
|
|
13872
13923
|
readFileSync as readFileSync9,
|
|
13873
13924
|
rmSync as rmSync11,
|
|
13874
|
-
statSync as
|
|
13925
|
+
statSync as statSync9,
|
|
13875
13926
|
writeFileSync as writeFileSync6
|
|
13876
13927
|
} from "node:fs";
|
|
13877
13928
|
import { readFile as readFile2 } from "node:fs/promises";
|
|
13878
|
-
import { dirname as dirname13, join as
|
|
13929
|
+
import { dirname as dirname13, join as join33 } from "node:path";
|
|
13879
13930
|
import {
|
|
13880
13931
|
encodeFramesChunkedConcat,
|
|
13881
13932
|
encodeFramesFromDir,
|
|
@@ -14000,7 +14051,7 @@ async function encodeGifFromDir(framesDir, framePattern, outputPath, input) {
|
|
|
14000
14051
|
const failure = await reencodeWithClearedWholeFrames(argsInput, run, startTime);
|
|
14001
14052
|
if (failure) return failure;
|
|
14002
14053
|
}
|
|
14003
|
-
const fileSize = existsSync21(outputPath) ?
|
|
14054
|
+
const fileSize = existsSync21(outputPath) ? statSync9(outputPath).size : 0;
|
|
14004
14055
|
return {
|
|
14005
14056
|
success: true,
|
|
14006
14057
|
outputPath,
|
|
@@ -14094,7 +14145,7 @@ function encodeWhileCapturing(input, totalFrames, captureBudget) {
|
|
|
14094
14145
|
await new Promise((resolve12) => wake = resolve12);
|
|
14095
14146
|
}
|
|
14096
14147
|
if (signal.aborted) return;
|
|
14097
|
-
const mergedPath =
|
|
14148
|
+
const mergedPath = join33(input.framesDir, formatCaptureFrameName(next, "jpg"));
|
|
14098
14149
|
const frame = await readLandedFrame(landed.get(next), mergedPath);
|
|
14099
14150
|
landed.delete(next);
|
|
14100
14151
|
if (!await stream.writeFrame(frame)) {
|
|
@@ -14177,11 +14228,11 @@ async function runEncodeStage(input) {
|
|
|
14177
14228
|
);
|
|
14178
14229
|
}
|
|
14179
14230
|
captured.forEach((name, i) => {
|
|
14180
|
-
const dst =
|
|
14181
|
-
copyFileSync4(
|
|
14231
|
+
const dst = join33(outputPath, formatExportFrameName(i, "png"));
|
|
14232
|
+
copyFileSync4(join33(framesDir, name), dst);
|
|
14182
14233
|
});
|
|
14183
14234
|
if (hasAudio && audioOutputPath && existsSync21(audioOutputPath)) {
|
|
14184
|
-
copyFileSync4(audioOutputPath,
|
|
14235
|
+
copyFileSync4(audioOutputPath, join33(outputPath, MIXED_AUDIO_FILENAME2));
|
|
14185
14236
|
log.info(
|
|
14186
14237
|
`[Render] png-sequence: ${MIXED_AUDIO_FILENAME2} sidecar written to ${outputPath}/${MIXED_AUDIO_FILENAME2}`
|
|
14187
14238
|
);
|
|
@@ -14201,7 +14252,7 @@ async function runEncodeStage(input) {
|
|
|
14201
14252
|
const encodeResult2 = await encodeGifFromDir(framesDir, framePattern2, outputPath, {
|
|
14202
14253
|
fps: job.config.fps,
|
|
14203
14254
|
loop,
|
|
14204
|
-
palettePath:
|
|
14255
|
+
palettePath: join33(dirname13(videoOnlyPath), "gif-palette.png"),
|
|
14205
14256
|
preserveAlpha: needsAlpha,
|
|
14206
14257
|
signal: abortSignal,
|
|
14207
14258
|
timeout: engineCfg.ffmpegEncodeTimeout
|
|
@@ -14412,9 +14463,9 @@ function sampleDirectoryBytes(dir) {
|
|
|
14412
14463
|
continue;
|
|
14413
14464
|
}
|
|
14414
14465
|
for (const name of entries) {
|
|
14415
|
-
const full =
|
|
14466
|
+
const full = join34(current, name);
|
|
14416
14467
|
try {
|
|
14417
|
-
const st =
|
|
14468
|
+
const st = statSync10(full);
|
|
14418
14469
|
if (st.isDirectory()) {
|
|
14419
14470
|
stack.push(full);
|
|
14420
14471
|
} else if (st.isFile()) {
|
|
@@ -14570,8 +14621,8 @@ function findMissingFrameRanges(totalFrames, framesDir, frameExt) {
|
|
|
14570
14621
|
const ranges = [];
|
|
14571
14622
|
let rangeStart = null;
|
|
14572
14623
|
for (let frameIndex = 0; frameIndex < totalFrames; frameIndex++) {
|
|
14573
|
-
const framePath =
|
|
14574
|
-
const missing = !existsSync22(framePath) ||
|
|
14624
|
+
const framePath = join34(framesDir, formatCaptureFrameName(frameIndex, frameExt));
|
|
14625
|
+
const missing = !existsSync22(framePath) || statSync10(framePath).size <= 8;
|
|
14575
14626
|
if (missing && rangeStart === null) {
|
|
14576
14627
|
rangeStart = frameIndex;
|
|
14577
14628
|
} else if (!missing && rangeStart !== null) {
|
|
@@ -14587,7 +14638,7 @@ function findMissingFrameRanges(totalFrames, framesDir, frameExt) {
|
|
|
14587
14638
|
function buildMissingFrameRetryBatches(ranges, maxWorkers, workDir, attempt, rangeStart = 0, stride = 1) {
|
|
14588
14639
|
const workersPerBatch = Math.max(1, Math.floor(maxWorkers));
|
|
14589
14640
|
const batches = [];
|
|
14590
|
-
const outputDirFor = (batchIndex, workerId) =>
|
|
14641
|
+
const outputDirFor = (batchIndex, workerId) => join34(workDir, `retry-${attempt}-batch-${batchIndex}-worker-${workerId}`);
|
|
14591
14642
|
if (stride > 1) {
|
|
14592
14643
|
const spans = /* @__PURE__ */ new Map();
|
|
14593
14644
|
for (const range of ranges) {
|
|
@@ -14647,8 +14698,8 @@ function getNextRetryWorkerCount(currentWorkers) {
|
|
|
14647
14698
|
return Math.max(1, Math.floor(currentWorkers / 2));
|
|
14648
14699
|
}
|
|
14649
14700
|
function resolveRenderWorkDirPrefix(outputPath, jobId, platform2 = process.platform, systemTempDir = tmpdir3()) {
|
|
14650
|
-
if (platform2 === "win32" || platform2 === "darwin") return
|
|
14651
|
-
return
|
|
14701
|
+
if (platform2 === "win32" || platform2 === "darwin") return join34(systemTempDir, "hf-render-");
|
|
14702
|
+
return join34(dirname14(outputPath), `work-${jobId}-`);
|
|
14652
14703
|
}
|
|
14653
14704
|
var MAX_TRANSIENT_CAPTURE_RETRIES = 1;
|
|
14654
14705
|
function isTransientCaptureRetryEligible(failureKind, missing, retriesUsed) {
|
|
@@ -14703,7 +14754,7 @@ The composition is too large for the available memory. To reduce memory pressure
|
|
|
14703
14754
|
function countCapturedFrames(totalFrames, framesDir, frameExt) {
|
|
14704
14755
|
let captured = 0;
|
|
14705
14756
|
for (let frameIndex = 0; frameIndex < totalFrames; frameIndex++) {
|
|
14706
|
-
const framePath =
|
|
14757
|
+
const framePath = join34(framesDir, formatCaptureFrameName(frameIndex, frameExt));
|
|
14707
14758
|
if (existsSync22(framePath)) captured++;
|
|
14708
14759
|
}
|
|
14709
14760
|
return captured;
|
|
@@ -14729,7 +14780,7 @@ async function executeDiskCaptureWithAdaptiveRetry(options) {
|
|
|
14729
14780
|
reason: attempt === 0 ? "initial" : pendingTransientRetry ? "transient-retry" : "retry"
|
|
14730
14781
|
});
|
|
14731
14782
|
pendingTransientRetry = false;
|
|
14732
|
-
const attemptWorkDir =
|
|
14783
|
+
const attemptWorkDir = join34(options.workDir, `capture-attempt-${attempt}`);
|
|
14733
14784
|
const batches = missingRanges ? buildMissingFrameRetryBatches(
|
|
14734
14785
|
missingRanges,
|
|
14735
14786
|
currentWorkers,
|
|
@@ -15377,7 +15428,7 @@ function deVerifyFallbackTelemetry(err) {
|
|
|
15377
15428
|
}
|
|
15378
15429
|
function resolveRenderDebugDir() {
|
|
15379
15430
|
const producerRoot = process.env.PRODUCER_RENDERS_DIR ? resolve9(process.env.PRODUCER_RENDERS_DIR, "..") : resolve9(dirname14(fileURLToPath4(import.meta.url)), "../..");
|
|
15380
|
-
return
|
|
15431
|
+
return join34(producerRoot, ".debug");
|
|
15381
15432
|
}
|
|
15382
15433
|
async function executeRenderJob(job, projectDir, outputPath, progressSink, abortSignal, assertRenderActive) {
|
|
15383
15434
|
validateHlsRenderConfig(job.config);
|
|
@@ -15386,10 +15437,10 @@ async function executeRenderJob(job, projectDir, outputPath, progressSink, abort
|
|
|
15386
15437
|
const debugDir = resolveRenderDebugDir();
|
|
15387
15438
|
const outputDir = dirname14(outputPath);
|
|
15388
15439
|
if (!existsSync22(outputDir)) mkdirSync12(outputDir, { recursive: true });
|
|
15389
|
-
const workDir = job.config.debug ?
|
|
15440
|
+
const workDir = job.config.debug ? join34(debugDir, job.id) : createRenderWorkDir(resolveRenderWorkDirPrefix(outputPath, job.id), outputDir);
|
|
15390
15441
|
const pipelineStart = Date.now();
|
|
15391
15442
|
const baseLog = job.config.logger ?? defaultLogger;
|
|
15392
|
-
const logPath = job.config.debug ?
|
|
15443
|
+
const logPath = job.config.debug ? join34(workDir, "render.log") : null;
|
|
15393
15444
|
const execution = new RenderExecutionContext({
|
|
15394
15445
|
request: { renderJobId: job.id, projectDir, outputPath },
|
|
15395
15446
|
logger: logPath ? createRenderFileLogger(logPath, baseLog) : baseLog,
|
|
@@ -15420,6 +15471,15 @@ async function executeRenderJob(job, projectDir, outputPath, progressSink, abort
|
|
|
15420
15471
|
await execution.dispose();
|
|
15421
15472
|
}
|
|
15422
15473
|
}
|
|
15474
|
+
function loadResumeKeyOrWarn(resume, log) {
|
|
15475
|
+
const key = segmentManifestKey();
|
|
15476
|
+
if (resume && !key) {
|
|
15477
|
+
log.warn(
|
|
15478
|
+
"[Render] --resume: no preview token could be read or created, so every segment will be captured again"
|
|
15479
|
+
);
|
|
15480
|
+
}
|
|
15481
|
+
return key;
|
|
15482
|
+
}
|
|
15423
15483
|
async function executeRenderPipeline(input) {
|
|
15424
15484
|
const {
|
|
15425
15485
|
job,
|
|
@@ -15457,7 +15517,7 @@ async function executeRenderPipeline(input) {
|
|
|
15457
15517
|
imageDecodeFailures: 0
|
|
15458
15518
|
};
|
|
15459
15519
|
let hdrPerf;
|
|
15460
|
-
const perfOutputPath =
|
|
15520
|
+
const perfOutputPath = join34(workDir, "perf-summary.json");
|
|
15461
15521
|
const cfg = { ...job.config.producerConfig ?? resolveConfig2() };
|
|
15462
15522
|
const observability = new RenderObservabilityRecorder({
|
|
15463
15523
|
pipelineStartMs: pipelineStart,
|
|
@@ -15562,7 +15622,7 @@ async function executeRenderPipeline(input) {
|
|
|
15562
15622
|
requestedWorkers: job.config.workers ?? "auto"
|
|
15563
15623
|
});
|
|
15564
15624
|
const entryFile = job.config.entryFile || "index.html";
|
|
15565
|
-
const htmlPath =
|
|
15625
|
+
const htmlPath = join34(projectDir, entryFile);
|
|
15566
15626
|
if (!existsSync22(htmlPath)) {
|
|
15567
15627
|
throw new Error(`Entry file not found: ${htmlPath}`);
|
|
15568
15628
|
}
|
|
@@ -15659,7 +15719,7 @@ async function executeRenderPipeline(input) {
|
|
|
15659
15719
|
const largerThanCanvas = await oversizedVideos(
|
|
15660
15720
|
composition.videos,
|
|
15661
15721
|
projectDir,
|
|
15662
|
-
|
|
15722
|
+
join34(workDir, "compiled"),
|
|
15663
15723
|
{ width: outputWidth, height: outputHeight }
|
|
15664
15724
|
);
|
|
15665
15725
|
const probeResult = await observeRenderStage(
|
|
@@ -15756,7 +15816,7 @@ async function executeRenderPipeline(input) {
|
|
|
15756
15816
|
canvas: { width, height },
|
|
15757
15817
|
page: probeSession.page,
|
|
15758
15818
|
projectDir,
|
|
15759
|
-
compiledDir:
|
|
15819
|
+
compiledDir: join34(workDir, "compiled")
|
|
15760
15820
|
});
|
|
15761
15821
|
if (videoLayerPlan.videoId === void 0) {
|
|
15762
15822
|
log.info(`[Render] Video layer passthrough off: ${videoLayerPlan.reason}`);
|
|
@@ -15774,7 +15834,7 @@ async function executeRenderPipeline(input) {
|
|
|
15774
15834
|
updateJobStatus(job, "preprocessing", "Extracting video frames", 10, onProgress, {
|
|
15775
15835
|
code: "extract_video"
|
|
15776
15836
|
});
|
|
15777
|
-
const compiledDir =
|
|
15837
|
+
const compiledDir = join34(workDir, "compiled");
|
|
15778
15838
|
const segmentsCapture = (layeredOrEffectRoute) => shouldSegmentCapture({
|
|
15779
15839
|
env: process.env,
|
|
15780
15840
|
durationSeconds: probeResult.duration,
|
|
@@ -15910,7 +15970,7 @@ async function executeRenderPipeline(input) {
|
|
|
15910
15970
|
try {
|
|
15911
15971
|
fileServer = await createFileServer({
|
|
15912
15972
|
projectDir,
|
|
15913
|
-
compiledDir:
|
|
15973
|
+
compiledDir: join34(workDir, "compiled"),
|
|
15914
15974
|
port: 0,
|
|
15915
15975
|
preHeadScripts: [VIRTUAL_TIME_SHIM],
|
|
15916
15976
|
fps: job.config.fps,
|
|
@@ -15930,7 +15990,7 @@ async function executeRenderPipeline(input) {
|
|
|
15930
15990
|
if (!activeFileServer) {
|
|
15931
15991
|
throw new Error("File server failed to initialize before frame capture");
|
|
15932
15992
|
}
|
|
15933
|
-
const framesDir =
|
|
15993
|
+
const framesDir = join34(workDir, "captured-frames");
|
|
15934
15994
|
if (!existsSync22(framesDir)) mkdirSync12(framesDir, { recursive: true });
|
|
15935
15995
|
updateJobStatus(job, "rendering", "Checking browser GPU", 25, onProgress, {
|
|
15936
15996
|
code: "start_browsers"
|
|
@@ -16511,7 +16571,7 @@ async function executeRenderPipeline(input) {
|
|
|
16511
16571
|
hls: ".mp4"
|
|
16512
16572
|
};
|
|
16513
16573
|
const videoExt = FORMAT_EXT[outputFormat] ?? ".mp4";
|
|
16514
|
-
const videoOnlyPath =
|
|
16574
|
+
const videoOnlyPath = join34(workDir, `video-only${videoExt}`);
|
|
16515
16575
|
let usePageSideCompositingForTransitions = (cfg.enablePageSideCompositing || isGif) && compiled.hasShaderTransitions && !hasHdrContent && outputSupportsPageSideShaderCompositing(outputFormat);
|
|
16516
16576
|
if (usePageSideCompositingForTransitions) {
|
|
16517
16577
|
activeFileServer.addPreHeadScript(HF_PAGE_SIDE_COMPOSITING_STUB);
|
|
@@ -16828,16 +16888,19 @@ async function executeRenderPipeline(input) {
|
|
|
16828
16888
|
pageMotionBlur: job.config.pageMotionBlur,
|
|
16829
16889
|
captureQuality: captureOptions.quality
|
|
16830
16890
|
});
|
|
16831
|
-
const segmentDir = segmentDirFor(
|
|
16891
|
+
const segmentDir = segmentDirFor(join34(projectDir, "renders"), segmentPlanHash);
|
|
16892
|
+
const manifestKey = loadResumeKeyOrWarn(job.config.resumeSegments === true, log);
|
|
16832
16893
|
let completedSegments = /* @__PURE__ */ new Set();
|
|
16833
16894
|
if (job.config.resumeSegments === true) {
|
|
16834
16895
|
const existing = readSegmentManifest(segmentDir);
|
|
16835
16896
|
if (existing) {
|
|
16836
|
-
completedSegments = await validateCompletedSegments(
|
|
16837
|
-
|
|
16838
|
-
|
|
16839
|
-
|
|
16840
|
-
|
|
16897
|
+
completedSegments = await validateCompletedSegments(existing, {
|
|
16898
|
+
expectedHash: segmentPlanHash,
|
|
16899
|
+
segmentDir,
|
|
16900
|
+
plan: planSegments(totalFrames, segmentFrames),
|
|
16901
|
+
key: manifestKey,
|
|
16902
|
+
probeFrames: (path) => probeSegmentFrameCount(path, extractMediaMetadata5)
|
|
16903
|
+
});
|
|
16841
16904
|
log.info(`[Render] resuming: ${completedSegments.size} segments complete`, {
|
|
16842
16905
|
segmentDir
|
|
16843
16906
|
});
|
|
@@ -16911,7 +16974,7 @@ async function executeRenderPipeline(input) {
|
|
|
16911
16974
|
...segmentManifest.completed.filter((e) => e.index !== entry.index),
|
|
16912
16975
|
{ ...entry, completedAt: (/* @__PURE__ */ new Date()).toISOString() }
|
|
16913
16976
|
];
|
|
16914
|
-
writeSegmentManifest(segmentDir, segmentManifest);
|
|
16977
|
+
writeSegmentManifest(segmentDir, segmentManifest, manifestKey);
|
|
16915
16978
|
},
|
|
16916
16979
|
updateCaptureObservability
|
|
16917
16980
|
})
|
|
@@ -17454,7 +17517,7 @@ async function executeRenderPipeline(input) {
|
|
|
17454
17517
|
}
|
|
17455
17518
|
if (job.config.debug) {
|
|
17456
17519
|
if (!isPngSequence && !isHls && existsSync22(stagedOutputPath)) {
|
|
17457
|
-
const debugOutput =
|
|
17520
|
+
const debugOutput = join34(workDir, `output${videoExt}`);
|
|
17458
17521
|
copyFileSync5(stagedOutputPath, debugOutput);
|
|
17459
17522
|
}
|
|
17460
17523
|
}
|
|
@@ -17571,13 +17634,13 @@ async function executeRenderPipeline(input) {
|
|
|
17571
17634
|
import {
|
|
17572
17635
|
existsSync as existsSync23,
|
|
17573
17636
|
readFileSync as readFileSync10,
|
|
17574
|
-
statSync as
|
|
17637
|
+
statSync as statSync11,
|
|
17575
17638
|
openSync as openSync5,
|
|
17576
17639
|
fstatSync as fstatSync3,
|
|
17577
17640
|
closeSync as closeSync5,
|
|
17578
17641
|
constants as constants3
|
|
17579
17642
|
} from "node:fs";
|
|
17580
|
-
import { resolve as resolve10, join as
|
|
17643
|
+
import { resolve as resolve10, join as join35, relative as relative5, isAbsolute as isAbsolute4, sep as sep5, dirname as dirname15 } from "node:path";
|
|
17581
17644
|
import { fileURLToPath as fileURLToPath5 } from "node:url";
|
|
17582
17645
|
import { Worker as Worker2 } from "node:worker_threads";
|
|
17583
17646
|
function isStringRecord(value) {
|
|
@@ -17612,7 +17675,7 @@ function readEntryHtml(filePath) {
|
|
|
17612
17675
|
} catch (error) {
|
|
17613
17676
|
if (error instanceof Error && "code" in error && (error.code === "ENOENT" || error.code === "ENOTDIR"))
|
|
17614
17677
|
return null;
|
|
17615
|
-
if (!
|
|
17678
|
+
if (!statSync11(filePath, { throwIfNoEntry: false })?.isFile()) return null;
|
|
17616
17679
|
throw error;
|
|
17617
17680
|
}
|
|
17618
17681
|
try {
|
|
@@ -17628,7 +17691,7 @@ function leavesProject(absProjectDir, absoluteEntryPath, isAllowedEntry) {
|
|
|
17628
17691
|
}
|
|
17629
17692
|
function readProjectEntryFile(projectDir, preferredEntryFile, isAllowedEntry) {
|
|
17630
17693
|
const absProjectDir = resolve10(projectDir);
|
|
17631
|
-
if (!existsSync23(absProjectDir) || !
|
|
17694
|
+
if (!existsSync23(absProjectDir) || !statSync11(absProjectDir).isDirectory()) {
|
|
17632
17695
|
return { error: `Project directory not found: ${absProjectDir}` };
|
|
17633
17696
|
}
|
|
17634
17697
|
const entryCandidates = [preferredEntryFile, "index.html", "src/index.html"].filter(
|
|
@@ -17649,7 +17712,7 @@ function readProjectEntryFile(projectDir, preferredEntryFile, isAllowedEntry) {
|
|
|
17649
17712
|
}
|
|
17650
17713
|
}
|
|
17651
17714
|
return {
|
|
17652
|
-
error: `No HTML entry file found in project directory: ${
|
|
17715
|
+
error: `No HTML entry file found in project directory: ${join35(absProjectDir, preferredEntryFile || "index.html")}`
|
|
17653
17716
|
};
|
|
17654
17717
|
}
|
|
17655
17718
|
function prepareHyperframeLintBody(body, isAllowedEntry) {
|
|
@@ -17718,7 +17781,7 @@ function freeLintSlot() {
|
|
|
17718
17781
|
function resolveLintWorkerEntry() {
|
|
17719
17782
|
const here = dirname15(fileURLToPath5(import.meta.url));
|
|
17720
17783
|
for (const name of ["hyperframeLintWorker.js", "hyperframeLintWorker.ts"]) {
|
|
17721
|
-
const candidate =
|
|
17784
|
+
const candidate = join35(here, name);
|
|
17722
17785
|
if (existsSync23(candidate)) return candidate;
|
|
17723
17786
|
}
|
|
17724
17787
|
return void 0;
|
|
@@ -17789,7 +17852,7 @@ async function runHyperframeLint(prepared, options = {}) {
|
|
|
17789
17852
|
// src/services/healthWorker.ts
|
|
17790
17853
|
import { Worker as Worker3 } from "node:worker_threads";
|
|
17791
17854
|
import { fileURLToPath as fileURLToPath6 } from "node:url";
|
|
17792
|
-
import { dirname as dirname16, join as
|
|
17855
|
+
import { dirname as dirname16, join as join36 } from "node:path";
|
|
17793
17856
|
import { existsSync as existsSync24 } from "node:fs";
|
|
17794
17857
|
var DEFAULT_HEALTH_PORT = 9848;
|
|
17795
17858
|
async function startHealthWorker(options = {}) {
|
|
@@ -17865,7 +17928,7 @@ function defaultLogger2() {
|
|
|
17865
17928
|
}
|
|
17866
17929
|
function resolveWorkerEntry2() {
|
|
17867
17930
|
const here = dirname16(fileURLToPath6(import.meta.url));
|
|
17868
|
-
const candidates = [
|
|
17931
|
+
const candidates = [join36(here, "healthWorkerThread.js"), join36(here, "healthWorkerThread.ts")];
|
|
17869
17932
|
for (const candidate of candidates) {
|
|
17870
17933
|
if (existsSync24(candidate)) return candidate;
|
|
17871
17934
|
}
|
|
@@ -17907,7 +17970,7 @@ import {
|
|
|
17907
17970
|
createReferenceBackgroundRecorder as createReferenceBackgroundRecorder2
|
|
17908
17971
|
} from "@hyperframes/engine";
|
|
17909
17972
|
import { audioFailureDiagnostics as audioFailureDiagnostics3 } from "@hyperframes/engine";
|
|
17910
|
-
import { extname as extname4, isAbsolute as isAbsolute5, join as
|
|
17973
|
+
import { extname as extname4, isAbsolute as isAbsolute5, join as join38, relative as relative6, sep as sep6 } from "node:path";
|
|
17911
17974
|
import {
|
|
17912
17975
|
fpsToNumber as fpsToNumber9,
|
|
17913
17976
|
HF_COLOR_GRADING_ATTR as HF_COLOR_GRADING_ATTR2
|
|
@@ -17940,7 +18003,7 @@ import {
|
|
|
17940
18003
|
|
|
17941
18004
|
// src/services/distributed/shared.ts
|
|
17942
18005
|
import { execFile as execFileCallback } from "node:child_process";
|
|
17943
|
-
import { dirname as dirname17, join as
|
|
18006
|
+
import { dirname as dirname17, join as join37 } from "node:path";
|
|
17944
18007
|
import { existsSync as existsSync25, readFileSync as readFileSync11 } from "node:fs";
|
|
17945
18008
|
import { fileURLToPath as fileURLToPath7 } from "node:url";
|
|
17946
18009
|
import { promisify as promisify2 } from "node:util";
|
|
@@ -17956,7 +18019,7 @@ function readProducerVersion() {
|
|
|
17956
18019
|
const startDir = dirname17(fileURLToPath7(import.meta.url));
|
|
17957
18020
|
let current = startDir;
|
|
17958
18021
|
for (let i = 0; i < 10; i++) {
|
|
17959
|
-
const candidate =
|
|
18022
|
+
const candidate = join37(current, "package.json");
|
|
17960
18023
|
if (existsSync25(candidate)) {
|
|
17961
18024
|
try {
|
|
17962
18025
|
const pkg = JSON.parse(readFileSync11(candidate, "utf-8"));
|
|
@@ -18054,9 +18117,9 @@ var PLAN_ROOT_CATEGORY = {
|
|
|
18054
18117
|
var PLAN_DIR_SIZE_LIMIT_BYTES = 2 * 1024 * 1024 * 1024;
|
|
18055
18118
|
var FREEZE_OWNED_PLAN_FILES = [
|
|
18056
18119
|
"plan.json",
|
|
18057
|
-
|
|
18058
|
-
|
|
18059
|
-
|
|
18120
|
+
join38("meta", "composition.json"),
|
|
18121
|
+
join38("meta", "encoder.json"),
|
|
18122
|
+
join38("meta", "chunks.json")
|
|
18060
18123
|
];
|
|
18061
18124
|
|
|
18062
18125
|
// src/services/distributed/renderConfigValidation.ts
|
|
@@ -18562,7 +18625,7 @@ function prepareProjectDirectory(projectDir, options, policy) {
|
|
|
18562
18625
|
if (!candidate) return null;
|
|
18563
18626
|
const absProjectDir = policy ? resolve11(policy.projectsDir, candidate) : resolve11(candidate);
|
|
18564
18627
|
const shown = policy ? candidate : absProjectDir;
|
|
18565
|
-
if (policy && !isAllowedProjectPath(policy.projectsDir, absProjectDir) || !existsSync26(absProjectDir) || !
|
|
18628
|
+
if (policy && !isAllowedProjectPath(policy.projectsDir, absProjectDir) || !existsSync26(absProjectDir) || !statSync12(absProjectDir).isDirectory()) {
|
|
18566
18629
|
return { error: `Project directory not found: ${shown}` };
|
|
18567
18630
|
}
|
|
18568
18631
|
const entry = options.entryFile || "index.html";
|
|
@@ -18588,8 +18651,8 @@ async function resolveInlineRenderHtml(body) {
|
|
|
18588
18651
|
}
|
|
18589
18652
|
function materializeInlineProject(html, options) {
|
|
18590
18653
|
const tempRoot = process.env.PRODUCER_TMP_PROJECT_DIR || tmpdir4();
|
|
18591
|
-
const tempProjectDir = mkdtempSync(
|
|
18592
|
-
writeFileSync8(
|
|
18654
|
+
const tempProjectDir = mkdtempSync(join39(tempRoot, "producer-project-"));
|
|
18655
|
+
writeFileSync8(join39(tempProjectDir, "index.html"), html, "utf-8");
|
|
18593
18656
|
return {
|
|
18594
18657
|
prepared: {
|
|
18595
18658
|
input: { projectDir: tempProjectDir, ...options },
|
|
@@ -18665,7 +18728,7 @@ function publicPerfSummary(job) {
|
|
|
18665
18728
|
return job.perfSummary ? { ...job.perfSummary, renderId: void 0 } : null;
|
|
18666
18729
|
}
|
|
18667
18730
|
function outputFileSize(path) {
|
|
18668
|
-
return existsSync26(path) ?
|
|
18731
|
+
return existsSync26(path) ? statSync12(path).size : 0;
|
|
18669
18732
|
}
|
|
18670
18733
|
function createBlockingProgressReporter(log, requestId) {
|
|
18671
18734
|
let lastLoggedPct = -10;
|
|
@@ -18996,8 +19059,8 @@ function createRenderHandlers(options = {}) {
|
|
|
18996
19059
|
store.delete(token);
|
|
18997
19060
|
return c.json({ success: false, error: "Output artifact file missing" }, 404);
|
|
18998
19061
|
}
|
|
18999
|
-
const stats =
|
|
19000
|
-
return new Response(
|
|
19062
|
+
const stats = statSync12(artifact.path);
|
|
19063
|
+
return new Response(createReadStream4(artifact.path), {
|
|
19001
19064
|
headers: {
|
|
19002
19065
|
"content-type": "video/mp4",
|
|
19003
19066
|
"content-length": String(stats.size),
|