@hyperframes/producer 0.9.68 → 0.9.70
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 +74 -65
- package/dist/hyperframe.manifest.json +1 -1
- package/dist/hyperframe.runtime.iife.js +68 -67
- package/dist/index.js +309 -267
- package/dist/public-server.js +198 -158
- package/dist/services/render/audioPadTrim.d.ts +2 -1
- package/dist/services/render/segmentManifest.d.ts +3 -4
- package/dist/services/renderOrchestrator.d.ts +1 -1
- package/package.json +7 -7
package/dist/public-server.js
CHANGED
|
@@ -18,11 +18,11 @@ function requireOutputDimensions(expected, width, height) {
|
|
|
18
18
|
|
|
19
19
|
// src/server.ts
|
|
20
20
|
import {
|
|
21
|
-
existsSync as
|
|
21
|
+
existsSync as existsSync25,
|
|
22
22
|
mkdirSync as mkdirSync13,
|
|
23
23
|
statSync as statSync12,
|
|
24
24
|
mkdtempSync,
|
|
25
|
-
writeFileSync as
|
|
25
|
+
writeFileSync as writeFileSync7,
|
|
26
26
|
rmSync as rmSync13,
|
|
27
27
|
createReadStream as createReadStream4
|
|
28
28
|
} from "node:fs";
|
|
@@ -39,17 +39,17 @@ import {
|
|
|
39
39
|
REFERENCE_BACKGROUND_FIELD as REFERENCE_BACKGROUND_FIELD3,
|
|
40
40
|
referenceBackgroundResult as referenceBackgroundResult5
|
|
41
41
|
} from "@hyperframes/engine";
|
|
42
|
-
import { isSafePath as
|
|
42
|
+
import { isSafePath as isSafePath4 } from "@hyperframes/core/safe-path";
|
|
43
43
|
|
|
44
44
|
// src/services/renderOrchestrator.ts
|
|
45
45
|
import { audioFailureDiagnostics as audioFailureDiagnostics2, usableCpuCount as usableCpuCount2 } from "@hyperframes/engine";
|
|
46
46
|
import {
|
|
47
|
-
existsSync as
|
|
47
|
+
existsSync as existsSync21,
|
|
48
48
|
mkdirSync as mkdirSync12,
|
|
49
49
|
readdirSync as readdirSync6,
|
|
50
50
|
rmSync as rmSync12,
|
|
51
51
|
statSync as statSync10,
|
|
52
|
-
writeFileSync as
|
|
52
|
+
writeFileSync as writeFileSync6,
|
|
53
53
|
copyFileSync as copyFileSync5,
|
|
54
54
|
appendFileSync
|
|
55
55
|
} from "fs";
|
|
@@ -2624,7 +2624,7 @@ function replanAfterFailure(plan, failure) {
|
|
|
2624
2624
|
}
|
|
2625
2625
|
|
|
2626
2626
|
// src/services/render/stages/captureSegmentedStage.ts
|
|
2627
|
-
import { existsSync as
|
|
2627
|
+
import { existsSync as existsSync7, mkdirSync as mkdirSync4, rmSync as rmSync6, statSync as statSync4 } from "node:fs";
|
|
2628
2628
|
import { join as join12 } from "node:path";
|
|
2629
2629
|
import {
|
|
2630
2630
|
captureFrameToBuffer as captureFrameToBuffer2,
|
|
@@ -4356,16 +4356,25 @@ function createSegmentQueue(slices) {
|
|
|
4356
4356
|
// src/services/render/segmentManifest.ts
|
|
4357
4357
|
import { createHash as createHash2, createHmac, timingSafeEqual } from "node:crypto";
|
|
4358
4358
|
import {
|
|
4359
|
+
closeSync as closeSync4,
|
|
4360
|
+
constants as constants3,
|
|
4359
4361
|
createReadStream as createReadStream2,
|
|
4360
|
-
|
|
4362
|
+
fstatSync as fstatSync3,
|
|
4361
4363
|
lstatSync as lstatSync3,
|
|
4362
4364
|
mkdirSync as mkdirSync3,
|
|
4363
|
-
|
|
4364
|
-
|
|
4365
|
+
openSync as openSync4,
|
|
4366
|
+
readFileSync as readFileSync4
|
|
4365
4367
|
} from "node:fs";
|
|
4366
4368
|
import { join as join10 } from "node:path";
|
|
4369
|
+
import {
|
|
4370
|
+
assertPrivateCachePath,
|
|
4371
|
+
ensurePrivateCacheDir,
|
|
4372
|
+
hyperframesCacheDir
|
|
4373
|
+
} from "@hyperframes/core/cache-dir";
|
|
4374
|
+
import { isSafePath as isSafePath2, realpath } from "@hyperframes/core/safe-path";
|
|
4375
|
+
import { isPathInside as isPathInside3 } from "@hyperframes/parsers/asset-paths";
|
|
4367
4376
|
import { previewToken } from "@hyperframes/core/preview-proof";
|
|
4368
|
-
import {
|
|
4377
|
+
import { replaceFileAtomically } from "@hyperframes/core/atomic-file";
|
|
4369
4378
|
var MANIFEST_FILENAME = "segments.json";
|
|
4370
4379
|
function computeSegmentPlanHash(input) {
|
|
4371
4380
|
const ordered = [
|
|
@@ -4391,8 +4400,20 @@ function computeSegmentPlanHash(input) {
|
|
|
4391
4400
|
if (delivery.some((v) => v !== "")) ordered.push(...delivery.map(String));
|
|
4392
4401
|
return createHash2("sha256").update(ordered.join(" ")).digest("hex").slice(0, 16);
|
|
4393
4402
|
}
|
|
4394
|
-
function segmentDirFor(
|
|
4395
|
-
|
|
4403
|
+
function segmentDirFor(projectDir, planHash) {
|
|
4404
|
+
const root = hyperframesCacheDir();
|
|
4405
|
+
const projectKey = createHash2("sha256").update(realpath(projectDir)).digest("hex");
|
|
4406
|
+
const parent = join10(root, "segments", projectKey);
|
|
4407
|
+
const dir = join10(parent, planHash);
|
|
4408
|
+
if (isPathInside3(root, projectDir) || isSafePath2(projectDir, root) || isSafePath2(projectDir, parent) || isSafePath2(projectDir, dir)) {
|
|
4409
|
+
throw new Error("Segmented capture requires HYPERFRAMES_CACHE_DIR outside the project.");
|
|
4410
|
+
}
|
|
4411
|
+
assertPrivateCachePath(root, root);
|
|
4412
|
+
ensurePrivateCacheDir(parent, root);
|
|
4413
|
+
if (!isSafePath2(parent, dir) || lstatSync3(dir, { throwIfNoEntry: false })?.isSymbolicLink()) {
|
|
4414
|
+
throw new Error("Invalid segment cache directory");
|
|
4415
|
+
}
|
|
4416
|
+
return dir;
|
|
4396
4417
|
}
|
|
4397
4418
|
function hasNumber(value, key) {
|
|
4398
4419
|
return key in value && typeof Reflect.get(value, key) === "number";
|
|
@@ -4411,12 +4432,22 @@ function isManifest(value) {
|
|
|
4411
4432
|
}
|
|
4412
4433
|
function readSegmentManifest(segmentDir) {
|
|
4413
4434
|
const path = join10(segmentDir, MANIFEST_FILENAME);
|
|
4414
|
-
|
|
4435
|
+
let fd;
|
|
4415
4436
|
try {
|
|
4416
|
-
|
|
4437
|
+
fd = openSync4(
|
|
4438
|
+
path,
|
|
4439
|
+
constants3.O_RDONLY | (constants3.O_NOFOLLOW ?? 0) | (constants3.O_NONBLOCK ?? 0)
|
|
4440
|
+
);
|
|
4441
|
+
const opened = fstatSync3(fd);
|
|
4442
|
+
if (!opened.isFile() || opened.nlink !== 1) return null;
|
|
4443
|
+
const named = lstatSync3(path);
|
|
4444
|
+
if (!named.isFile() || named.dev !== opened.dev || named.ino !== opened.ino) return null;
|
|
4445
|
+
const parsed = JSON.parse(readFileSync4(fd, "utf-8"));
|
|
4417
4446
|
return isManifest(parsed) ? parsed : null;
|
|
4418
4447
|
} catch {
|
|
4419
4448
|
return null;
|
|
4449
|
+
} finally {
|
|
4450
|
+
if (fd !== void 0) closeSync4(fd);
|
|
4420
4451
|
}
|
|
4421
4452
|
}
|
|
4422
4453
|
function segmentManifestKey(token = previewToken()) {
|
|
@@ -4449,9 +4480,11 @@ async function hashSegmentFile(path) {
|
|
|
4449
4480
|
}
|
|
4450
4481
|
function writeSegmentManifest(segmentDir, manifest, key) {
|
|
4451
4482
|
mkdirSync3(segmentDir, { recursive: true });
|
|
4452
|
-
|
|
4453
|
-
|
|
4454
|
-
|
|
4483
|
+
replaceFileAtomically(
|
|
4484
|
+
join10(segmentDir, MANIFEST_FILENAME),
|
|
4485
|
+
JSON.stringify(signSegmentManifest(manifest, key), null, 2),
|
|
4486
|
+
384
|
|
4487
|
+
);
|
|
4455
4488
|
}
|
|
4456
4489
|
async function probeSegmentFrameCount(path, probe) {
|
|
4457
4490
|
try {
|
|
@@ -4471,19 +4504,27 @@ function plannedSlice(entry, plan) {
|
|
|
4471
4504
|
}
|
|
4472
4505
|
return slice;
|
|
4473
4506
|
}
|
|
4474
|
-
function
|
|
4475
|
-
|
|
4476
|
-
|
|
4507
|
+
async function matchesSegmentFile(path, entry) {
|
|
4508
|
+
try {
|
|
4509
|
+
const stat = lstatSync3(path, { throwIfNoEntry: false });
|
|
4510
|
+
if (!stat?.isFile() || stat.nlink !== 1 || stat.size <= 0 || stat.size !== entry.bytes) {
|
|
4511
|
+
return false;
|
|
4512
|
+
}
|
|
4513
|
+
return await hashSegmentFile(path) === entry.sha256;
|
|
4514
|
+
} catch {
|
|
4515
|
+
return false;
|
|
4516
|
+
}
|
|
4477
4517
|
}
|
|
4478
4518
|
async function validateCompletedSegments(manifest, check) {
|
|
4479
4519
|
const ok = /* @__PURE__ */ new Set();
|
|
4480
|
-
if (manifest.planHash !== check.expectedHash || !hasValidMac(manifest, check.key))
|
|
4520
|
+
if (manifest.totalFrames !== check.totalFrames || manifest.segmentFrames !== check.segmentFrames || manifest.planHash !== check.expectedHash || !hasValidMac(manifest, check.key))
|
|
4521
|
+
return ok;
|
|
4522
|
+
const plan = planSegments(check.totalFrames, check.segmentFrames);
|
|
4481
4523
|
for (const entry of manifest.completed) {
|
|
4482
|
-
const slice = plannedSlice(entry,
|
|
4524
|
+
const slice = plannedSlice(entry, plan);
|
|
4483
4525
|
if (!slice) continue;
|
|
4484
4526
|
const path = segmentOutputPath(check.segmentDir, slice.index);
|
|
4485
|
-
if (!
|
|
4486
|
-
if (await hashSegmentFile(path) !== entry.sha256) continue;
|
|
4527
|
+
if (entry.path !== path || !await matchesSegmentFile(path, entry)) continue;
|
|
4487
4528
|
const frames = await check.probeFrames(path);
|
|
4488
4529
|
if (frames !== slice.endFrame - slice.startFrame) continue;
|
|
4489
4530
|
ok.add(slice.index);
|
|
@@ -5374,6 +5415,7 @@ async function captureSegment(ctx, segment) {
|
|
|
5374
5415
|
}
|
|
5375
5416
|
async function captureSegmentToEncoder(ctx, segment) {
|
|
5376
5417
|
const segmentPath = segmentOutputPath(ctx.segmentDir, segment.index);
|
|
5418
|
+
rmSync6(segmentPath, { force: true });
|
|
5377
5419
|
let encoder;
|
|
5378
5420
|
try {
|
|
5379
5421
|
encoder = await ctx.spawnEncoder(
|
|
@@ -5402,8 +5444,8 @@ async function captureSegmentToEncoder(ctx, segment) {
|
|
|
5402
5444
|
path: segmentPath,
|
|
5403
5445
|
// Recorded so resume can prove the file on disk is the one that
|
|
5404
5446
|
// finished; absent only in unit tests, whose fake encoder writes none.
|
|
5405
|
-
bytes:
|
|
5406
|
-
sha256:
|
|
5447
|
+
bytes: existsSync7(segmentPath) ? statSync4(segmentPath).size : 0,
|
|
5448
|
+
sha256: existsSync7(segmentPath) ? await hashSegmentFile(segmentPath) : ""
|
|
5407
5449
|
});
|
|
5408
5450
|
return encodeResult;
|
|
5409
5451
|
} finally {
|
|
@@ -7066,7 +7108,7 @@ function countAuthoredTimedClips(html) {
|
|
|
7066
7108
|
}
|
|
7067
7109
|
|
|
7068
7110
|
// src/services/render/stages/compileStage.ts
|
|
7069
|
-
import { existsSync as
|
|
7111
|
+
import { existsSync as existsSync12, writeFileSync as writeFileSync4 } from "node:fs";
|
|
7070
7112
|
import { join as join22, relative as relative4 } from "node:path";
|
|
7071
7113
|
import { privateCacheRoot } from "@hyperframes/engine";
|
|
7072
7114
|
import { suggestMatchingPreset } from "@hyperframes/core";
|
|
@@ -7078,7 +7120,7 @@ import { statSync as statSync6 } from "node:fs";
|
|
|
7078
7120
|
var MAX_COMPOSITION_HTML_BYTES = 16 * 1024 * 1024;
|
|
7079
7121
|
var COMPOSITION_TOO_LARGE = "COMPOSITION_TOO_LARGE";
|
|
7080
7122
|
var megabytes = (bytes) => `${(bytes / (1024 * 1024)).toFixed(1)} MB`;
|
|
7081
|
-
var MAX_EXPANDED_COMPOSITION_BYTES =
|
|
7123
|
+
var MAX_EXPANDED_COMPOSITION_BYTES = 4 * MAX_COMPOSITION_HTML_BYTES;
|
|
7082
7124
|
var MAX_COMPOSITION_MOUNTS = 1e4;
|
|
7083
7125
|
var CompositionTooLargeError = class extends Error {
|
|
7084
7126
|
constructor(message, publicMetadata) {
|
|
@@ -7175,12 +7217,12 @@ import {
|
|
|
7175
7217
|
stylesheetLinkMatches
|
|
7176
7218
|
} from "@hyperframes/parsers/css-url-scans";
|
|
7177
7219
|
import { createHash as createHash6 } from "node:crypto";
|
|
7178
|
-
import { createReadStream as createReadStream3, existsSync as
|
|
7220
|
+
import { createReadStream as createReadStream3, existsSync as existsSync11, mkdirSync as mkdirSync9, readFileSync as readFileSync8 } from "fs";
|
|
7179
7221
|
import { join as join21, dirname as dirname9, resolve as resolve8, basename as basename6, relative as relative3, sep as sep4 } from "path";
|
|
7180
7222
|
import { parseHTML as parseHTML5 } from "linkedom";
|
|
7181
7223
|
|
|
7182
7224
|
// src/services/bundledScripts.ts
|
|
7183
|
-
import { existsSync as
|
|
7225
|
+
import { existsSync as existsSync8, readFileSync as readFileSync5 } from "node:fs";
|
|
7184
7226
|
import { join as join17 } from "node:path";
|
|
7185
7227
|
import { gsapCdnDist } from "@hyperframes/core/gsap-cdn";
|
|
7186
7228
|
var GSAP_VENDOR_DIR_ENV = "HYPERFRAMES_GSAP_VENDOR_DIR";
|
|
@@ -7188,7 +7230,7 @@ function bundledScript(url) {
|
|
|
7188
7230
|
const dir = process.env[GSAP_VENDOR_DIR_ENV];
|
|
7189
7231
|
if (!dir || url !== `${gsapCdnDist()}gsap.min.js`) return null;
|
|
7190
7232
|
const file = join17(dir, "gsap.min.js");
|
|
7191
|
-
return
|
|
7233
|
+
return existsSync8(file) ? readFileSync5(file) : null;
|
|
7192
7234
|
}
|
|
7193
7235
|
|
|
7194
7236
|
// src/services/htmlCompiler.ts
|
|
@@ -7446,7 +7488,7 @@ import {
|
|
|
7446
7488
|
|
|
7447
7489
|
// src/services/animatedGifPrep.ts
|
|
7448
7490
|
import { createHash as createHash4 } from "node:crypto";
|
|
7449
|
-
import { copyFileSync as copyFileSync2, existsSync as
|
|
7491
|
+
import { copyFileSync as copyFileSync2, existsSync as existsSync9, mkdirSync as mkdirSync7, readFileSync as readFileSync6, rmSync as rmSync9, statSync as statSync7 } from "node:fs";
|
|
7450
7492
|
import { dirname as dirname6, isAbsolute as isAbsolute3, join as join18, resolve as resolve6 } from "node:path";
|
|
7451
7493
|
import { parseHTML as parseHTML3 } from "linkedom";
|
|
7452
7494
|
import { parseAnimatedGifMetadata } from "@hyperframes/core";
|
|
@@ -7454,7 +7496,7 @@ import {
|
|
|
7454
7496
|
DEFAULT_VP9_CPU_USED,
|
|
7455
7497
|
isPrivateUnderAssetRoots,
|
|
7456
7498
|
runFfmpeg as runFfmpeg2,
|
|
7457
|
-
renameWithRetry as
|
|
7499
|
+
renameWithRetry as renameWithRetry2,
|
|
7458
7500
|
urlInputArgs as urlInputArgs2
|
|
7459
7501
|
} from "@hyperframes/engine";
|
|
7460
7502
|
import { namesAnotherNetworkRoot } from "@hyperframes/parsers/asset-resolution";
|
|
@@ -7492,7 +7534,7 @@ function resolveLocalImageSourcePath(src, options) {
|
|
|
7492
7534
|
const { basePath } = splitUrlSuffix(trimmed);
|
|
7493
7535
|
const normalizedBase = normalizeRelPath(basePath);
|
|
7494
7536
|
const mapped = options.sourceAssets?.get(trimmed) ?? options.sourceAssets?.get(basePath) ?? options.sourceAssets?.get(normalizedBase);
|
|
7495
|
-
if (mapped &&
|
|
7537
|
+
if (mapped && existsSync9(mapped)) return mapped;
|
|
7496
7538
|
if (isHttpUrl(trimmed)) return null;
|
|
7497
7539
|
const projectRelative = basePath.startsWith("/") ? basePath.slice(1) : basePath;
|
|
7498
7540
|
const candidates = [
|
|
@@ -7501,7 +7543,7 @@ function resolveLocalImageSourcePath(src, options) {
|
|
|
7501
7543
|
];
|
|
7502
7544
|
const assetRoot = options.allowOutsideFiles ? void 0 : options.projectDir;
|
|
7503
7545
|
const allowed = (candidate) => !namesAnotherNetworkRoot(options.projectDir, candidate) && !isPrivateUnderAssetRoots(candidate, [options.projectDir, options.downloadDir]) && (!escapesAssetRoot(candidate, assetRoot) && outsideAssetRefusal(options.projectDir, candidate) !== "blocklisted" || !escapesAssetRoot(candidate, options.downloadDir));
|
|
7504
|
-
return candidates.find((candidate) => allowed(candidate) &&
|
|
7546
|
+
return candidates.find((candidate) => allowed(candidate) && existsSync9(candidate)) ?? null;
|
|
7505
7547
|
}
|
|
7506
7548
|
function isUsableFile(path) {
|
|
7507
7549
|
try {
|
|
@@ -7613,10 +7655,10 @@ async function runAnimatedGifTranscode(request) {
|
|
|
7613
7655
|
throw result.error ?? new Error(`Animated GIF transcode failed (${result.exitCode}): ${result.stderr.slice(-500)}`);
|
|
7614
7656
|
}
|
|
7615
7657
|
async function ensurePreparedWebm(input) {
|
|
7616
|
-
if (!
|
|
7658
|
+
if (!existsSync9(dirname6(input.cachePath))) {
|
|
7617
7659
|
mkdirSync7(dirname6(input.cachePath), { recursive: true });
|
|
7618
7660
|
}
|
|
7619
|
-
if (!
|
|
7661
|
+
if (!existsSync9(dirname6(input.outputPath))) {
|
|
7620
7662
|
mkdirSync7(dirname6(input.outputPath), { recursive: true });
|
|
7621
7663
|
}
|
|
7622
7664
|
if (!isUsableFile(input.cachePath)) {
|
|
@@ -7639,7 +7681,7 @@ async function ensurePreparedWebm(input) {
|
|
|
7639
7681
|
throw new Error("Animated GIF transcode produced an empty output");
|
|
7640
7682
|
}
|
|
7641
7683
|
if (!isUsableFile(input.cachePath)) {
|
|
7642
|
-
|
|
7684
|
+
renameWithRetry2(tmpPath, input.cachePath);
|
|
7643
7685
|
} else {
|
|
7644
7686
|
rmSync9(tmpPath, { force: true });
|
|
7645
7687
|
}
|
|
@@ -7763,19 +7805,19 @@ async function prepareAnimatedGifInputs(html, options) {
|
|
|
7763
7805
|
// src/services/heifImagePrep.ts
|
|
7764
7806
|
import { createHash as createHash5 } from "node:crypto";
|
|
7765
7807
|
import {
|
|
7766
|
-
closeSync as
|
|
7808
|
+
closeSync as closeSync5,
|
|
7767
7809
|
copyFileSync as copyFileSync3,
|
|
7768
7810
|
mkdirSync as mkdirSync8,
|
|
7769
|
-
openSync as
|
|
7811
|
+
openSync as openSync5,
|
|
7770
7812
|
readFileSync as readFileSync7,
|
|
7771
7813
|
readSync as readSync3,
|
|
7772
7814
|
rmSync as rmSync10,
|
|
7773
7815
|
statSync as statSync8,
|
|
7774
|
-
writeFileSync as
|
|
7816
|
+
writeFileSync as writeFileSync3
|
|
7775
7817
|
} from "node:fs";
|
|
7776
7818
|
import { dirname as dirname7, join as join19, resolve as resolve7 } from "node:path";
|
|
7777
7819
|
import { parseHTML as parseHTML4 } from "linkedom";
|
|
7778
|
-
import { renameWithRetry as
|
|
7820
|
+
import { renameWithRetry as renameWithRetry3, runFfmpeg as runFfmpeg3, runFfprobe, urlInputArgs as urlInputArgs3 } from "@hyperframes/engine";
|
|
7779
7821
|
|
|
7780
7822
|
// src/services/heifRotation.ts
|
|
7781
7823
|
function* boxes(buf, start, end) {
|
|
@@ -7922,13 +7964,13 @@ function isHeifBytes(head) {
|
|
|
7922
7964
|
function readHead(path) {
|
|
7923
7965
|
let fd;
|
|
7924
7966
|
try {
|
|
7925
|
-
fd =
|
|
7967
|
+
fd = openSync5(path, "r");
|
|
7926
7968
|
const buf = Buffer.alloc(4096);
|
|
7927
7969
|
return buf.subarray(0, readSync3(fd, buf, 0, buf.length, 0));
|
|
7928
7970
|
} catch {
|
|
7929
7971
|
return null;
|
|
7930
7972
|
} finally {
|
|
7931
|
-
if (fd !== void 0)
|
|
7973
|
+
if (fd !== void 0) closeSync5(fd);
|
|
7932
7974
|
}
|
|
7933
7975
|
}
|
|
7934
7976
|
async function probeJson(path, withGroups) {
|
|
@@ -8027,14 +8069,14 @@ async function ensurePreparedJpeg(source, cachePath, outputPath, options) {
|
|
|
8027
8069
|
const inlinePath = `${tmpPath}.heic`;
|
|
8028
8070
|
const inputPath = source.path ?? inlinePath;
|
|
8029
8071
|
try {
|
|
8030
|
-
if (!source.path)
|
|
8072
|
+
if (!source.path) writeFileSync3(inlinePath, source.bytes);
|
|
8031
8073
|
await (options.transcode ?? convertHeifToJpeg)({
|
|
8032
8074
|
inputPath,
|
|
8033
8075
|
outputPath: tmpPath,
|
|
8034
8076
|
timeoutMs: options.timeoutMs
|
|
8035
8077
|
});
|
|
8036
8078
|
if (!isUsableFile2(tmpPath)) throw new Error("conversion produced an empty file");
|
|
8037
|
-
|
|
8079
|
+
renameWithRetry3(tmpPath, cachePath);
|
|
8038
8080
|
} catch (error) {
|
|
8039
8081
|
const reason = error instanceof Error ? error.message : String(error);
|
|
8040
8082
|
throw TOOL_FAILURE_RE.test(reason) ? new HeifToolUnavailableError(source.label, reason) : new HeifImageConversionError(source.label, reason);
|
|
@@ -8088,11 +8130,14 @@ async function prepareHeifImageInputs(html, options) {
|
|
|
8088
8130
|
}
|
|
8089
8131
|
|
|
8090
8132
|
// src/services/htmlCompiler.ts
|
|
8091
|
-
import {
|
|
8133
|
+
import {
|
|
8134
|
+
createStudioPositionSeekReapplyScript,
|
|
8135
|
+
htmlHasStudioPositionEdits
|
|
8136
|
+
} from "@hyperframes/studio-server/manual-edits-render-script";
|
|
8092
8137
|
import { getPositionEditsRenderScript } from "@hyperframes/core/runtime/position-edits-render";
|
|
8093
8138
|
|
|
8094
8139
|
// src/services/assetMediaType.ts
|
|
8095
|
-
import { existsSync as
|
|
8140
|
+
import { existsSync as existsSync10 } from "node:fs";
|
|
8096
8141
|
import { dirname as dirname8, join as join20 } from "node:path";
|
|
8097
8142
|
import {
|
|
8098
8143
|
fingerprintElementId,
|
|
@@ -8205,7 +8250,7 @@ async function preflightCompositionAssetMediaTypes(input) {
|
|
|
8205
8250
|
input.projectDir,
|
|
8206
8251
|
input.compiledDir
|
|
8207
8252
|
);
|
|
8208
|
-
if (!
|
|
8253
|
+
if (!existsSync10(resolvedPath)) continue;
|
|
8209
8254
|
byPath.set(resolvedPath, [...byPath.get(resolvedPath) ?? [], reference]);
|
|
8210
8255
|
}
|
|
8211
8256
|
const mismatches = [];
|
|
@@ -8502,7 +8547,7 @@ async function resolveMediaDuration(src, mediaStart, playbackRate, projectDir, b
|
|
|
8502
8547
|
let filePath = src;
|
|
8503
8548
|
if (isHttpUrl(src)) {
|
|
8504
8549
|
const remoteDir = join21(downloadDir, REMOTE_MEDIA_SUBDIR);
|
|
8505
|
-
if (!
|
|
8550
|
+
if (!existsSync11(remoteDir)) mkdirSync9(remoteDir, { recursive: true });
|
|
8506
8551
|
try {
|
|
8507
8552
|
filePath = await downloadToTemp(src, remoteDir, void 0, void 0, void 0, {
|
|
8508
8553
|
onTelemetry: logRemoteDownloadTelemetry
|
|
@@ -8521,7 +8566,7 @@ async function resolveMediaDuration(src, mediaStart, playbackRate, projectDir, b
|
|
|
8521
8566
|
return { duration: null, resolvedPath: filePath };
|
|
8522
8567
|
}
|
|
8523
8568
|
}
|
|
8524
|
-
if (!isHttpUrl(filePath) && !
|
|
8569
|
+
if (!isHttpUrl(filePath) && !existsSync11(filePath)) {
|
|
8525
8570
|
return { duration: null, resolvedPath: filePath };
|
|
8526
8571
|
}
|
|
8527
8572
|
const withSrcContext = (error) => {
|
|
@@ -9153,7 +9198,7 @@ function collectExternalAssets(html, projectDir, log = defaultLogger, file = "in
|
|
|
9153
9198
|
return null;
|
|
9154
9199
|
}
|
|
9155
9200
|
const onShare = namesAnotherNetworkRoot2(absProjectDir, absPath);
|
|
9156
|
-
if (!onShare && !
|
|
9201
|
+
if (!onShare && !existsSync11(absPath)) return null;
|
|
9157
9202
|
const refusal = onShare ? "network_share" : outsideAssetRefusal(absProjectDir, absPath, policy);
|
|
9158
9203
|
if (refusal) {
|
|
9159
9204
|
if (!leftOut.has(trimmed)) log.warn(`[Compiler] ${leftOutOfRender(file, trimmed, refusal)}`);
|
|
@@ -9206,7 +9251,7 @@ function collectExternalAssets(html, projectDir, log = defaultLogger, file = "in
|
|
|
9206
9251
|
var REMOTE_MEDIA_SUBDIR = "_remote_media";
|
|
9207
9252
|
async function downloadAndRewriteUrls(urlSet, html, remoteDir, warnLabel, logLabel, extraRewrite) {
|
|
9208
9253
|
if (urlSet.size === 0) return { html, remoteMediaAssets: /* @__PURE__ */ new Map() };
|
|
9209
|
-
if (!
|
|
9254
|
+
if (!existsSync11(remoteDir)) mkdirSync9(remoteDir, { recursive: true });
|
|
9210
9255
|
const urlToLocal = /* @__PURE__ */ new Map();
|
|
9211
9256
|
await Promise.all(
|
|
9212
9257
|
[...urlSet].map(async (url) => {
|
|
@@ -9392,13 +9437,13 @@ function projectStylesheetFontFamilies(html, projectDir) {
|
|
|
9392
9437
|
const href = /\bhref=["']([^"']+)["']/i.exec(tag)?.[1];
|
|
9393
9438
|
if (!href || /^(?:[a-z][a-z\d+.-]*:|\/\/)/i.test(href)) continue;
|
|
9394
9439
|
const sheet = resolve8(projectDir, decodedUrlPath(href).replace(/^(?:\.?\/)+/, ""));
|
|
9395
|
-
if (!isPathInside(sheet, projectDir) || !
|
|
9440
|
+
if (!isPathInside(sheet, projectDir) || !existsSync11(sheet)) continue;
|
|
9396
9441
|
for (const face of extractFontFaceBlocks(readFileSync8(sheet, "utf8"))) {
|
|
9397
9442
|
const family = /font-family\s*:\s*([^;}]+)/i.exec(face)?.[1]?.trim().replace(/^['"]|['"]$/g, "");
|
|
9398
9443
|
const shipsFile = [...localFontFaceUrlMatches(face)].some(({ parts: [, url = ""] }) => {
|
|
9399
9444
|
const path = decodedUrlPath(url);
|
|
9400
9445
|
const file = path.startsWith("/") ? resolve8(projectDir, `.${path}`) : resolve8(dirname9(sheet), path);
|
|
9401
|
-
return isPathInside(file, projectDir) &&
|
|
9446
|
+
return isPathInside(file, projectDir) && existsSync11(file);
|
|
9402
9447
|
});
|
|
9403
9448
|
if (family && shipsFile) families.push(family);
|
|
9404
9449
|
}
|
|
@@ -9547,7 +9592,7 @@ function rewriteUnresolvableGsapToCdn(html, projectDir, compSrcPath) {
|
|
|
9547
9592
|
let gsapDist;
|
|
9548
9593
|
const exists = (path) => {
|
|
9549
9594
|
const file = resolve8(projectDir, path);
|
|
9550
|
-
return !namesAnotherNetworkRoot2(projectDir, file) &&
|
|
9595
|
+
return !namesAnotherNetworkRoot2(projectDir, file) && existsSync11(file);
|
|
9551
9596
|
};
|
|
9552
9597
|
return replaceGsapDistScripts(html, (full, prefix, src, file, suffix) => {
|
|
9553
9598
|
if (/^https?:\/\//i.test(src)) return full;
|
|
@@ -9698,14 +9743,7 @@ async function compileForRender(projectDir, htmlPath, downloadDir, options = {})
|
|
|
9698
9743
|
abortSignal: options.abortSignal
|
|
9699
9744
|
});
|
|
9700
9745
|
const assembledHtml = await inlineExternalScripts(coalescedHtml, budget);
|
|
9701
|
-
const
|
|
9702
|
-
'data-hf-studio-path-offset="true"',
|
|
9703
|
-
'data-hf-studio-box-size="true"',
|
|
9704
|
-
'data-hf-studio-rotation="true"',
|
|
9705
|
-
'data-hf-studio-motion="'
|
|
9706
|
-
];
|
|
9707
|
-
const hasPositionEdits = HF_POSITION_ATTRS.some((attr) => assembledHtml.includes(attr));
|
|
9708
|
-
const htmlWithPositionScript = hasPositionEdits ? insertBeforeCloseTag(
|
|
9746
|
+
const htmlWithPositionScript = htmlHasStudioPositionEdits(assembledHtml) ? insertBeforeCloseTag(
|
|
9709
9747
|
assembledHtml,
|
|
9710
9748
|
"body",
|
|
9711
9749
|
`<script>${createStudioPositionSeekReapplyScript()}
|
|
@@ -9790,7 +9828,7 @@ async function compileForRender(projectDir, htmlPath, downloadDir, options = {})
|
|
|
9790
9828
|
for (const video of videos) {
|
|
9791
9829
|
if (isHttpUrl(video.src)) continue;
|
|
9792
9830
|
const videoPath = resolve8(projectDir, video.src);
|
|
9793
|
-
if (advised.has(videoPath) || namesAnotherNetworkRoot2(projectDir, videoPath) || !
|
|
9831
|
+
if (advised.has(videoPath) || namesAnotherNetworkRoot2(projectDir, videoPath) || !existsSync11(videoPath) || escapesAssetRoot(videoPath, assetRoot) || isPrivateUnderAssetRoots3(videoPath, [projectDir, downloadDir]))
|
|
9794
9832
|
continue;
|
|
9795
9833
|
advised.add(videoPath);
|
|
9796
9834
|
const reencode = `ffmpeg -i "${video.src}" -c:v libx264 -r 30 -g 30 -keyint_min 30 -movflags +faststart -c:a copy output.mp4`;
|
|
@@ -10237,7 +10275,7 @@ function resolveEntryHtmlPath(input) {
|
|
|
10237
10275
|
const rawEntry = readEntry(htmlPath);
|
|
10238
10276
|
if (entryFile === "index.html" || !isTemplateEntry(rawEntry)) return htmlPath;
|
|
10239
10277
|
const projectIndexPath = join22(projectDir, "index.html");
|
|
10240
|
-
if (!
|
|
10278
|
+
if (!existsSync12(projectIndexPath)) {
|
|
10241
10279
|
throw new Error(
|
|
10242
10280
|
`Template entry file "${entryFile}" requires a project index.html to extract its render shell.`
|
|
10243
10281
|
);
|
|
@@ -10253,7 +10291,7 @@ function resolveEntryHtmlPath(input) {
|
|
|
10253
10291
|
);
|
|
10254
10292
|
}
|
|
10255
10293
|
const wrapperPath = join22(workDir, "standalone-entry.html");
|
|
10256
|
-
|
|
10294
|
+
writeFileSync4(wrapperPath, standaloneHtml, "utf-8");
|
|
10257
10295
|
log.info("Extracted standalone entry from index.html host context", { entryFile });
|
|
10258
10296
|
return wrapperPath;
|
|
10259
10297
|
}
|
|
@@ -11214,7 +11252,7 @@ function validateRenderDuration(input) {
|
|
|
11214
11252
|
}
|
|
11215
11253
|
|
|
11216
11254
|
// src/services/render/stages/extractVideosStage.ts
|
|
11217
|
-
import { existsSync as
|
|
11255
|
+
import { existsSync as existsSync13 } from "node:fs";
|
|
11218
11256
|
import { join as join24 } from "node:path";
|
|
11219
11257
|
import {
|
|
11220
11258
|
classifyVideoExtractionError,
|
|
@@ -11662,7 +11700,7 @@ function isPublicHttpsUrl(url) {
|
|
|
11662
11700
|
}
|
|
11663
11701
|
}
|
|
11664
11702
|
function opensLocally(path, assetRoots) {
|
|
11665
|
-
return
|
|
11703
|
+
return existsSync13(path) && (!assetRoots || assetRootsRefusal(path, assetRoots) === null);
|
|
11666
11704
|
}
|
|
11667
11705
|
function localProbeSource(src, input) {
|
|
11668
11706
|
const path = resolveProjectRelativeSrc4(src, input.projectDir, input.compiledDir);
|
|
@@ -11715,7 +11753,7 @@ async function appendVideoAudioFromProbe(input) {
|
|
|
11715
11753
|
}
|
|
11716
11754
|
|
|
11717
11755
|
// src/services/render/videoLayerPassthroughPlan.ts
|
|
11718
|
-
import { existsSync as
|
|
11756
|
+
import { existsSync as existsSync14 } from "node:fs";
|
|
11719
11757
|
import {
|
|
11720
11758
|
buildVideoLayerInput,
|
|
11721
11759
|
isHttpUrl as isHttpUrl4,
|
|
@@ -11783,7 +11821,7 @@ async function planVideoLayerPassthrough(input) {
|
|
|
11783
11821
|
const { video } = q;
|
|
11784
11822
|
if (isHttpUrl4(video.src)) return { reason: "remote_source" };
|
|
11785
11823
|
const path = resolveProjectRelativeSrc5(video.src, input.projectDir, input.compiledDir);
|
|
11786
|
-
if (!
|
|
11824
|
+
if (!existsSync14(path)) return { reason: "source_missing" };
|
|
11787
11825
|
const layout = await probeVideoLayout(input.page, video.id, input.canvas, input.duration);
|
|
11788
11826
|
if ("reason" in layout) return layout;
|
|
11789
11827
|
const layer = await buildVideoLayerInput(
|
|
@@ -11798,7 +11836,7 @@ async function planVideoLayerPassthrough(input) {
|
|
|
11798
11836
|
}
|
|
11799
11837
|
|
|
11800
11838
|
// src/services/render/stages/audioStage.ts
|
|
11801
|
-
import { existsSync as
|
|
11839
|
+
import { existsSync as existsSync16 } from "node:fs";
|
|
11802
11840
|
import { join as join27 } from "node:path";
|
|
11803
11841
|
import {
|
|
11804
11842
|
MIXED_AUDIO_FILENAME,
|
|
@@ -11810,16 +11848,17 @@ import {
|
|
|
11810
11848
|
} from "@hyperframes/engine";
|
|
11811
11849
|
|
|
11812
11850
|
// src/services/render/audioDeliveryLimit.ts
|
|
11813
|
-
import { existsSync as
|
|
11851
|
+
import { existsSync as existsSync15 } from "node:fs";
|
|
11814
11852
|
import { dirname as dirname11, join as join26 } from "node:path";
|
|
11815
11853
|
import {
|
|
11816
11854
|
applyAudioFxChain,
|
|
11817
11855
|
describeFfmpegFailure as describeFfmpegFailure3,
|
|
11818
11856
|
encodeAac as encodeAac2,
|
|
11819
|
-
renameWithRetry as
|
|
11857
|
+
renameWithRetry as renameWithRetry5
|
|
11820
11858
|
} from "@hyperframes/engine";
|
|
11821
11859
|
|
|
11822
11860
|
// src/services/render/audioPadTrim.ts
|
|
11861
|
+
import { localContainerInputArgs } from "@hyperframes/parsers/ff-binaries";
|
|
11823
11862
|
import { spawn } from "node:child_process";
|
|
11824
11863
|
import { dirname as dirname10, join as join25 } from "node:path";
|
|
11825
11864
|
import {
|
|
@@ -11830,7 +11869,7 @@ import {
|
|
|
11830
11869
|
getFfprobeBinary,
|
|
11831
11870
|
ManagedChildProcess,
|
|
11832
11871
|
removeScratch,
|
|
11833
|
-
renameWithRetry as
|
|
11872
|
+
renameWithRetry as renameWithRetry4,
|
|
11834
11873
|
runFfmpeg as runFfmpeg5,
|
|
11835
11874
|
trackChildProcess,
|
|
11836
11875
|
withPublicOnlyProxy
|
|
@@ -11971,10 +12010,10 @@ function sanitizeProbeFailure(reason, paths) {
|
|
|
11971
12010
|
}
|
|
11972
12011
|
async function padOrTrimAudioToVideoFrameCount(input) {
|
|
11973
12012
|
const probeVideo = input.probeVideoFrameInfo ?? ((videoPath) => defaultProbeVideoFrameInfo(videoPath, input.signal));
|
|
11974
|
-
const probeAudio = input.probeAudioInfo ?? defaultProbeAudioInfo;
|
|
12013
|
+
const probeAudio = input.probeAudioInfo ?? ((path, signal) => defaultProbeAudioInfo(path, signal, input.audioContainer));
|
|
11975
12014
|
const timeoutMs = input.timeoutMs ?? DEFAULT_CONFIG.ffmpegProcessTimeout;
|
|
11976
12015
|
const runner = input.runFfmpeg ?? ((args) => defaultRunFfmpeg(args, timeoutMs, input.signal));
|
|
11977
|
-
const encode = input.encodeAac ?? defaultAacEncoder(timeoutMs, input.signal, input.sourcePath);
|
|
12016
|
+
const encode = input.encodeAac ?? defaultAacEncoder(timeoutMs, input.signal, input.sourcePath, input.audioContainer);
|
|
11978
12017
|
const probeTruePeak = input.probeAudioTruePeakDbfs ?? (input.runFfmpeg || input.encodeAac ? void 0 : (audioPath, signal) => measureTruePeakDbfs(audioPath, { timeoutMs, signal }));
|
|
11979
12018
|
const [videoResult, audioResult] = await Promise.allSettled([
|
|
11980
12019
|
probeVideo(input.videoPath),
|
|
@@ -12022,7 +12061,7 @@ async function padOrTrimAudioToVideoFrameCount(input) {
|
|
|
12022
12061
|
);
|
|
12023
12062
|
try {
|
|
12024
12063
|
for (const step of plan.steps) {
|
|
12025
|
-
const ffmpegResult = step.kind === "copy" ? await runner(step.args) : await encode(
|
|
12064
|
+
const ffmpegResult = step.kind === "copy" ? await runner([...localContainerInputArgs(input.audioContainer), ...step.args]) : await encode(
|
|
12026
12065
|
input.sourcePath ?? input.audioPath,
|
|
12027
12066
|
input.outputPath,
|
|
12028
12067
|
targetDurationSeconds,
|
|
@@ -12106,7 +12145,7 @@ async function cutSource(input, scratchDir, attenuationDb) {
|
|
|
12106
12145
|
try {
|
|
12107
12146
|
const result = await input.rewriteSource(input.sourcePath, cutPath, gainFilter(attenuationDb));
|
|
12108
12147
|
if (!result.success) throw new Error(result.error);
|
|
12109
|
-
|
|
12148
|
+
renameWithRetry4(cutPath, input.sourcePath, { copyFallback: true });
|
|
12110
12149
|
return true;
|
|
12111
12150
|
} catch {
|
|
12112
12151
|
removeScratch(input.sourcePath);
|
|
@@ -12133,7 +12172,7 @@ async function enforceAacTruePeak(input) {
|
|
|
12133
12172
|
if (truePeakDbfs <= AAC_DELIVERY_TRUE_PEAK_DBFS) {
|
|
12134
12173
|
if (measuredPath !== correctedPath) return { success: true };
|
|
12135
12174
|
const sourceCut = await cutSource(input, scratchDir, attenuationDb);
|
|
12136
|
-
|
|
12175
|
+
renameWithRetry4(correctedPath, input.audioPath, { copyFallback: true });
|
|
12137
12176
|
const loweredDb = Number((-attenuationDb).toFixed(2));
|
|
12138
12177
|
return sourceCut ? { success: true, loweredDb } : { success: true, loweredDb, sourceStale: true };
|
|
12139
12178
|
}
|
|
@@ -12188,7 +12227,8 @@ function failResult(outputPath, target, source, error) {
|
|
|
12188
12227
|
error
|
|
12189
12228
|
};
|
|
12190
12229
|
}
|
|
12191
|
-
async function defaultProbeVideoFrameInfo(videoPath, signal) {
|
|
12230
|
+
async function defaultProbeVideoFrameInfo(videoPath, signal, container) {
|
|
12231
|
+
const inputArgs = localContainerInputArgs(container);
|
|
12192
12232
|
const fastInfo = await runFfprobeJson(
|
|
12193
12233
|
[
|
|
12194
12234
|
"-v",
|
|
@@ -12199,6 +12239,7 @@ async function defaultProbeVideoFrameInfo(videoPath, signal) {
|
|
|
12199
12239
|
"stream=nb_frames,r_frame_rate",
|
|
12200
12240
|
"-of",
|
|
12201
12241
|
"json",
|
|
12242
|
+
...inputArgs,
|
|
12202
12243
|
"--",
|
|
12203
12244
|
videoPath
|
|
12204
12245
|
],
|
|
@@ -12220,6 +12261,7 @@ async function defaultProbeVideoFrameInfo(videoPath, signal) {
|
|
|
12220
12261
|
"stream=nb_read_packets,r_frame_rate",
|
|
12221
12262
|
"-of",
|
|
12222
12263
|
"json",
|
|
12264
|
+
...inputArgs,
|
|
12223
12265
|
"--",
|
|
12224
12266
|
videoPath
|
|
12225
12267
|
],
|
|
@@ -12242,8 +12284,8 @@ function parseFrameRate(rate) {
|
|
|
12242
12284
|
}
|
|
12243
12285
|
return { fpsNum, fpsDen };
|
|
12244
12286
|
}
|
|
12245
|
-
async function defaultProbeAudioInfo(audioPath, signal) {
|
|
12246
|
-
const metadata = await extractAudioMetadata3(audioPath, { signal });
|
|
12287
|
+
async function defaultProbeAudioInfo(audioPath, signal, inputContainer) {
|
|
12288
|
+
const metadata = await extractAudioMetadata3(audioPath, { signal, inputContainer });
|
|
12247
12289
|
return {
|
|
12248
12290
|
durationSeconds: metadata.durationSeconds,
|
|
12249
12291
|
sampleRate: metadata.sampleRate,
|
|
@@ -12254,9 +12296,9 @@ async function defaultProbeAudioInfo(audioPath, signal) {
|
|
|
12254
12296
|
async function defaultRunFfmpeg(args, timeoutMs, signal) {
|
|
12255
12297
|
return toStepResult(await runFfmpeg5(args, { signal, timeout: timeoutMs }), timeoutMs);
|
|
12256
12298
|
}
|
|
12257
|
-
function defaultAacEncoder(timeoutMs, signal, pcmSourcePath) {
|
|
12299
|
+
function defaultAacEncoder(timeoutMs, signal, pcmSourcePath, inputContainer) {
|
|
12258
12300
|
return async (inputPath, outputPath, durationSeconds, filter) => {
|
|
12259
|
-
const options = pcmSourcePath ? { signal, timeout: timeoutMs, filter } : { signal, timeout: timeoutMs, filter, segments: 1 };
|
|
12301
|
+
const options = pcmSourcePath ? { signal, timeout: timeoutMs, filter } : { signal, timeout: timeoutMs, filter, segments: 1, inputContainer };
|
|
12260
12302
|
return toStepResult(
|
|
12261
12303
|
await encodeAac(pcmSourcePath ?? inputPath, outputPath, durationSeconds, options),
|
|
12262
12304
|
timeoutMs
|
|
@@ -12329,8 +12371,8 @@ async function limitDeliveryPeaks(input, deps = {
|
|
|
12329
12371
|
measure: measureTruePeakDbfs,
|
|
12330
12372
|
applyChain: applyAudioFxChain,
|
|
12331
12373
|
encode: encodeAac2,
|
|
12332
|
-
rename:
|
|
12333
|
-
sourceExists:
|
|
12374
|
+
rename: renameWithRetry5,
|
|
12375
|
+
sourceExists: existsSync15
|
|
12334
12376
|
}) {
|
|
12335
12377
|
const { audioPath, sourcePath, signal, timeoutMs } = input;
|
|
12336
12378
|
if (!deps.sourceExists(sourcePath)) return { success: true };
|
|
@@ -12426,7 +12468,7 @@ async function runAudioStageScoped(input) {
|
|
|
12426
12468
|
);
|
|
12427
12469
|
audioLoweredDb = guard.loweredDb;
|
|
12428
12470
|
input.log?.info("[audio] phases", { ...result.audioPhaseMs, guard: Date.now() - guardStart });
|
|
12429
|
-
if (input.keepDeliverySource && !guard.sourceStale &&
|
|
12471
|
+
if (input.keepDeliverySource && !guard.sourceStale && existsSync16(pcmSourcePath)) {
|
|
12430
12472
|
deliverySourcePath = pcmSourcePath;
|
|
12431
12473
|
}
|
|
12432
12474
|
}
|
|
@@ -12555,7 +12597,7 @@ async function mixAudioForDelivery(input, duration, pcmSourcePath) {
|
|
|
12555
12597
|
}
|
|
12556
12598
|
|
|
12557
12599
|
// src/services/render/stages/captureStage.ts
|
|
12558
|
-
import { existsSync as
|
|
12600
|
+
import { existsSync as existsSync17, readdirSync as readdirSync4, statfsSync as statfsSync2 } from "node:fs";
|
|
12559
12601
|
import { join as join28 } from "node:path";
|
|
12560
12602
|
import {
|
|
12561
12603
|
classifyCaptureFailure as classifyCaptureFailure2,
|
|
@@ -12626,7 +12668,7 @@ function diskCaptureShortfallError(needBytes, freeBytes, framesDir, basis, remed
|
|
|
12626
12668
|
}
|
|
12627
12669
|
function measureCaptureFrameBytes(workDir, framesDir) {
|
|
12628
12670
|
let total = sampleDirectoryBytes(framesDir);
|
|
12629
|
-
if (!
|
|
12671
|
+
if (!existsSync17(workDir)) return total;
|
|
12630
12672
|
for (const attempt of readdirSync4(workDir)) {
|
|
12631
12673
|
if (/^retry-\d+-batch-\d+-worker-\d+$/.test(attempt)) {
|
|
12632
12674
|
total += sampleDirectoryBytes(join28(workDir, attempt));
|
|
@@ -12933,7 +12975,7 @@ async function captureSessionFrames(session, { input, rangeStart, rangeEnd, resu
|
|
|
12933
12975
|
}
|
|
12934
12976
|
|
|
12935
12977
|
// src/services/render/stages/captureHdrStage.ts
|
|
12936
|
-
import { existsSync as
|
|
12978
|
+
import { existsSync as existsSync19, mkdirSync as mkdirSync10 } from "node:fs";
|
|
12937
12979
|
import { join as join32 } from "node:path";
|
|
12938
12980
|
import {
|
|
12939
12981
|
closeCaptureSession as closeCaptureSession7,
|
|
@@ -13180,7 +13222,7 @@ import { fileURLToPath as fileURLToPath3, pathToFileURL } from "node:url";
|
|
|
13180
13222
|
import { dirname as dirname12, join as join30 } from "node:path";
|
|
13181
13223
|
import { createRequire } from "node:module";
|
|
13182
13224
|
import { usableCpuCount } from "@hyperframes/engine";
|
|
13183
|
-
import { existsSync as
|
|
13225
|
+
import { existsSync as existsSync18 } from "node:fs";
|
|
13184
13226
|
function resolveWorkerEntry(explicit) {
|
|
13185
13227
|
if (explicit && explicit.length > 0) {
|
|
13186
13228
|
return { path: explicit, isTs: explicit.endsWith(".ts") };
|
|
@@ -13192,7 +13234,7 @@ function resolveWorkerEntry(explicit) {
|
|
|
13192
13234
|
}
|
|
13193
13235
|
const moduleDir = dirname12(fileURLToPath3(import.meta.url));
|
|
13194
13236
|
const jsPath = join30(moduleDir, "shaderTransitionWorker.js");
|
|
13195
|
-
if (
|
|
13237
|
+
if (existsSync18(jsPath)) return { path: jsPath, isTs: false };
|
|
13196
13238
|
const tsPath = join30(moduleDir, "shaderTransitionWorker.ts");
|
|
13197
13239
|
return { path: tsPath, isTs: true };
|
|
13198
13240
|
}
|
|
@@ -13758,7 +13800,7 @@ async function runCaptureHdrStage(input) {
|
|
|
13758
13800
|
}
|
|
13759
13801
|
const debugDumpEnabled = process.env.KEEP_TEMP === "1";
|
|
13760
13802
|
const debugDumpDir = debugDumpEnabled ? join32(framesDir, "debug-composite") : null;
|
|
13761
|
-
if (debugDumpDir && !
|
|
13803
|
+
if (debugDumpDir && !existsSync19(debugDumpDir)) {
|
|
13762
13804
|
mkdirSync10(debugDumpDir, { recursive: true });
|
|
13763
13805
|
}
|
|
13764
13806
|
const compositeTransfer = resolveCompositeTransfer(hasHdrContent, effectiveHdr);
|
|
@@ -13917,13 +13959,13 @@ async function runCaptureHdrStage(input) {
|
|
|
13917
13959
|
// src/services/render/stages/encodeStage.ts
|
|
13918
13960
|
import {
|
|
13919
13961
|
copyFileSync as copyFileSync4,
|
|
13920
|
-
existsSync as
|
|
13962
|
+
existsSync as existsSync20,
|
|
13921
13963
|
mkdirSync as mkdirSync11,
|
|
13922
13964
|
readdirSync as readdirSync5,
|
|
13923
13965
|
readFileSync as readFileSync9,
|
|
13924
13966
|
rmSync as rmSync11,
|
|
13925
13967
|
statSync as statSync9,
|
|
13926
|
-
writeFileSync as
|
|
13968
|
+
writeFileSync as writeFileSync5
|
|
13927
13969
|
} from "node:fs";
|
|
13928
13970
|
import { readFile as readFile2 } from "node:fs/promises";
|
|
13929
13971
|
import { dirname as dirname13, join as join33 } from "node:path";
|
|
@@ -14019,7 +14061,7 @@ async function reencodeWithClearedWholeFrames(argsInput, run, startTime) {
|
|
|
14019
14061
|
const error = "[FFmpeg] GIF output could not be parsed to clear its frames";
|
|
14020
14062
|
return gifEncodeFailure(startTime, outputPath, error);
|
|
14021
14063
|
}
|
|
14022
|
-
|
|
14064
|
+
writeFileSync5(outputPath, gif);
|
|
14023
14065
|
return null;
|
|
14024
14066
|
}
|
|
14025
14067
|
async function encodeGifFromDir(framesDir, framePattern, outputPath, input) {
|
|
@@ -14051,7 +14093,7 @@ async function encodeGifFromDir(framesDir, framePattern, outputPath, input) {
|
|
|
14051
14093
|
const failure = await reencodeWithClearedWholeFrames(argsInput, run, startTime);
|
|
14052
14094
|
if (failure) return failure;
|
|
14053
14095
|
}
|
|
14054
|
-
const fileSize =
|
|
14096
|
+
const fileSize = existsSync20(outputPath) ? statSync9(outputPath).size : 0;
|
|
14055
14097
|
return {
|
|
14056
14098
|
success: true,
|
|
14057
14099
|
outputPath,
|
|
@@ -14220,7 +14262,7 @@ async function runEncodeStage(input) {
|
|
|
14220
14262
|
const stage5Start = Date.now();
|
|
14221
14263
|
if (isPngSequence) {
|
|
14222
14264
|
const encoded = startEncodeProgress(job, "Writing PNG sequence", onProgress);
|
|
14223
|
-
if (!
|
|
14265
|
+
if (!existsSync20(outputPath)) mkdirSync11(outputPath, { recursive: true });
|
|
14224
14266
|
const captured = readdirSync5(framesDir).filter((name) => name.endsWith(".png")).sort();
|
|
14225
14267
|
if (captured.length === 0) {
|
|
14226
14268
|
throw new Error(
|
|
@@ -14231,7 +14273,7 @@ async function runEncodeStage(input) {
|
|
|
14231
14273
|
const dst = join33(outputPath, formatExportFrameName(i, "png"));
|
|
14232
14274
|
copyFileSync4(join33(framesDir, name), dst);
|
|
14233
14275
|
});
|
|
14234
|
-
if (hasAudio && audioOutputPath &&
|
|
14276
|
+
if (hasAudio && audioOutputPath && existsSync20(audioOutputPath)) {
|
|
14235
14277
|
copyFileSync4(audioOutputPath, join33(outputPath, MIXED_AUDIO_FILENAME2));
|
|
14236
14278
|
log.info(
|
|
14237
14279
|
`[Render] png-sequence: ${MIXED_AUDIO_FILENAME2} sidecar written to ${outputPath}/${MIXED_AUDIO_FILENAME2}`
|
|
@@ -14622,7 +14664,7 @@ function findMissingFrameRanges(totalFrames, framesDir, frameExt) {
|
|
|
14622
14664
|
let rangeStart = null;
|
|
14623
14665
|
for (let frameIndex = 0; frameIndex < totalFrames; frameIndex++) {
|
|
14624
14666
|
const framePath = join34(framesDir, formatCaptureFrameName(frameIndex, frameExt));
|
|
14625
|
-
const missing = !
|
|
14667
|
+
const missing = !existsSync21(framePath) || statSync10(framePath).size <= 8;
|
|
14626
14668
|
if (missing && rangeStart === null) {
|
|
14627
14669
|
rangeStart = frameIndex;
|
|
14628
14670
|
} else if (!missing && rangeStart !== null) {
|
|
@@ -14755,7 +14797,7 @@ function countCapturedFrames(totalFrames, framesDir, frameExt) {
|
|
|
14755
14797
|
let captured = 0;
|
|
14756
14798
|
for (let frameIndex = 0; frameIndex < totalFrames; frameIndex++) {
|
|
14757
14799
|
const framePath = join34(framesDir, formatCaptureFrameName(frameIndex, frameExt));
|
|
14758
|
-
if (
|
|
14800
|
+
if (existsSync21(framePath)) captured++;
|
|
14759
14801
|
}
|
|
14760
14802
|
return captured;
|
|
14761
14803
|
}
|
|
@@ -15436,7 +15478,7 @@ async function executeRenderJob(job, projectDir, outputPath, progressSink, abort
|
|
|
15436
15478
|
validateChromaSubsamplingConfig(job.config);
|
|
15437
15479
|
const debugDir = resolveRenderDebugDir();
|
|
15438
15480
|
const outputDir = dirname14(outputPath);
|
|
15439
|
-
if (!
|
|
15481
|
+
if (!existsSync21(outputDir)) mkdirSync12(outputDir, { recursive: true });
|
|
15440
15482
|
const workDir = job.config.debug ? join34(debugDir, job.id) : createRenderWorkDir(resolveRenderWorkDirPrefix(outputPath, job.id), outputDir);
|
|
15441
15483
|
const pipelineStart = Date.now();
|
|
15442
15484
|
const baseLog = job.config.logger ?? defaultLogger;
|
|
@@ -15593,7 +15635,7 @@ async function executeRenderPipeline(input) {
|
|
|
15593
15635
|
job.startedAt = /* @__PURE__ */ new Date();
|
|
15594
15636
|
assertNotAborted();
|
|
15595
15637
|
assertConfiguredFfmpegBinariesExist();
|
|
15596
|
-
if (!
|
|
15638
|
+
if (!existsSync21(workDir)) mkdirSync12(workDir, { recursive: true });
|
|
15597
15639
|
if (job.config.debug) {
|
|
15598
15640
|
log.info("[Render] Debug artifacts enabled", { workDir, logPath });
|
|
15599
15641
|
}
|
|
@@ -15623,7 +15665,7 @@ async function executeRenderPipeline(input) {
|
|
|
15623
15665
|
});
|
|
15624
15666
|
const entryFile = job.config.entryFile || "index.html";
|
|
15625
15667
|
const htmlPath = join34(projectDir, entryFile);
|
|
15626
|
-
if (!
|
|
15668
|
+
if (!existsSync21(htmlPath)) {
|
|
15627
15669
|
throw new Error(`Entry file not found: ${htmlPath}`);
|
|
15628
15670
|
}
|
|
15629
15671
|
assertNotAborted();
|
|
@@ -15991,7 +16033,7 @@ async function executeRenderPipeline(input) {
|
|
|
15991
16033
|
throw new Error("File server failed to initialize before frame capture");
|
|
15992
16034
|
}
|
|
15993
16035
|
const framesDir = join34(workDir, "captured-frames");
|
|
15994
|
-
if (!
|
|
16036
|
+
if (!existsSync21(framesDir)) mkdirSync12(framesDir, { recursive: true });
|
|
15995
16037
|
updateJobStatus(job, "rendering", "Checking browser GPU", 25, onProgress, {
|
|
15996
16038
|
code: "start_browsers"
|
|
15997
16039
|
});
|
|
@@ -16888,29 +16930,8 @@ async function executeRenderPipeline(input) {
|
|
|
16888
16930
|
pageMotionBlur: job.config.pageMotionBlur,
|
|
16889
16931
|
captureQuality: captureOptions.quality
|
|
16890
16932
|
});
|
|
16891
|
-
const segmentDir = segmentDirFor(
|
|
16933
|
+
const segmentDir = segmentDirFor(projectDir, segmentPlanHash);
|
|
16892
16934
|
const manifestKey = loadResumeKeyOrWarn(job.config.resumeSegments === true, log);
|
|
16893
|
-
let completedSegments = /* @__PURE__ */ new Set();
|
|
16894
|
-
if (job.config.resumeSegments === true) {
|
|
16895
|
-
const existing = readSegmentManifest(segmentDir);
|
|
16896
|
-
if (existing) {
|
|
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
|
-
});
|
|
16904
|
-
log.info(`[Render] resuming: ${completedSegments.size} segments complete`, {
|
|
16905
|
-
segmentDir
|
|
16906
|
-
});
|
|
16907
|
-
}
|
|
16908
|
-
if (completedSegments.size === 0) {
|
|
16909
|
-
rmSync12(segmentDir, { recursive: true, force: true });
|
|
16910
|
-
}
|
|
16911
|
-
} else {
|
|
16912
|
-
rmSync12(segmentDir, { recursive: true, force: true });
|
|
16913
|
-
}
|
|
16914
16935
|
const emptySegmentManifest = () => ({
|
|
16915
16936
|
version: 1,
|
|
16916
16937
|
planHash: segmentPlanHash,
|
|
@@ -16918,7 +16939,26 @@ async function executeRenderPipeline(input) {
|
|
|
16918
16939
|
segmentFrames,
|
|
16919
16940
|
completed: []
|
|
16920
16941
|
});
|
|
16921
|
-
let segmentManifest =
|
|
16942
|
+
let segmentManifest = emptySegmentManifest();
|
|
16943
|
+
let completedSegments = /* @__PURE__ */ new Set();
|
|
16944
|
+
const existing = job.config.resumeSegments ? readSegmentManifest(segmentDir) : null;
|
|
16945
|
+
if (existing) {
|
|
16946
|
+
completedSegments = await validateCompletedSegments(existing, {
|
|
16947
|
+
expectedHash: segmentPlanHash,
|
|
16948
|
+
segmentDir,
|
|
16949
|
+
totalFrames,
|
|
16950
|
+
segmentFrames,
|
|
16951
|
+
key: manifestKey,
|
|
16952
|
+
probeFrames: (path) => probeSegmentFrameCount(path, extractMediaMetadata5)
|
|
16953
|
+
});
|
|
16954
|
+
segmentManifest.completed = existing.completed.filter(
|
|
16955
|
+
(entry) => completedSegments.has(entry.index)
|
|
16956
|
+
);
|
|
16957
|
+
log.info(`[Render] resuming: ${completedSegments.size} segments complete`, {
|
|
16958
|
+
segmentDir
|
|
16959
|
+
});
|
|
16960
|
+
}
|
|
16961
|
+
if (completedSegments.size === 0) rmSync12(segmentDir, { recursive: true, force: true });
|
|
16922
16962
|
const invokeSegmented = () => {
|
|
16923
16963
|
if (capturePlan.kind !== "sdr_segmented") {
|
|
16924
16964
|
throw new Error(`Cannot invoke segmented stage with ${capturePlan.kind} plan`);
|
|
@@ -17435,7 +17475,7 @@ async function executeRenderPipeline(input) {
|
|
|
17435
17475
|
})
|
|
17436
17476
|
);
|
|
17437
17477
|
const totalElapsed = Date.now() - pipelineStart;
|
|
17438
|
-
const tmpPeakBytes =
|
|
17478
|
+
const tmpPeakBytes = existsSync21(workDir) ? sampleDirectoryBytes(workDir) : 0;
|
|
17439
17479
|
recordTransientRetryObservability();
|
|
17440
17480
|
observability.checkpoint("pipeline", "artifact validated", { totalElapsedMs: totalElapsed });
|
|
17441
17481
|
const observabilitySummary = observability.summary({
|
|
@@ -17507,7 +17547,7 @@ async function executeRenderPipeline(input) {
|
|
|
17507
17547
|
job.perfSummary = perfSummary;
|
|
17508
17548
|
if (job.config.debug) {
|
|
17509
17549
|
try {
|
|
17510
|
-
|
|
17550
|
+
writeFileSync6(perfOutputPath, JSON.stringify(perfSummary, null, 2), "utf-8");
|
|
17511
17551
|
} catch (err) {
|
|
17512
17552
|
log.debug("Failed to write perf summary", {
|
|
17513
17553
|
perfOutputPath,
|
|
@@ -17516,7 +17556,7 @@ async function executeRenderPipeline(input) {
|
|
|
17516
17556
|
}
|
|
17517
17557
|
}
|
|
17518
17558
|
if (job.config.debug) {
|
|
17519
|
-
if (!isPngSequence && !isHls &&
|
|
17559
|
+
if (!isPngSequence && !isHls && existsSync21(stagedOutputPath)) {
|
|
17520
17560
|
const debugOutput = join34(workDir, `output${videoExt}`);
|
|
17521
17561
|
copyFileSync5(stagedOutputPath, debugOutput);
|
|
17522
17562
|
}
|
|
@@ -17632,13 +17672,13 @@ async function executeRenderPipeline(input) {
|
|
|
17632
17672
|
|
|
17633
17673
|
// src/services/hyperframeLint.ts
|
|
17634
17674
|
import {
|
|
17635
|
-
existsSync as
|
|
17675
|
+
existsSync as existsSync22,
|
|
17636
17676
|
readFileSync as readFileSync10,
|
|
17637
17677
|
statSync as statSync11,
|
|
17638
|
-
openSync as
|
|
17639
|
-
fstatSync as
|
|
17640
|
-
closeSync as
|
|
17641
|
-
constants as
|
|
17678
|
+
openSync as openSync6,
|
|
17679
|
+
fstatSync as fstatSync4,
|
|
17680
|
+
closeSync as closeSync6,
|
|
17681
|
+
constants as constants4
|
|
17642
17682
|
} from "node:fs";
|
|
17643
17683
|
import { resolve as resolve10, join as join35, relative as relative5, isAbsolute as isAbsolute4, sep as sep5, dirname as dirname15 } from "node:path";
|
|
17644
17684
|
import { fileURLToPath as fileURLToPath5 } from "node:url";
|
|
@@ -17671,7 +17711,7 @@ function pickEntryFile(files, preferredEntryFile) {
|
|
|
17671
17711
|
function readEntryHtml(filePath) {
|
|
17672
17712
|
let fd;
|
|
17673
17713
|
try {
|
|
17674
|
-
fd =
|
|
17714
|
+
fd = openSync6(filePath, constants4.O_RDONLY | constants4.O_NONBLOCK);
|
|
17675
17715
|
} catch (error) {
|
|
17676
17716
|
if (error instanceof Error && "code" in error && (error.code === "ENOENT" || error.code === "ENOTDIR"))
|
|
17677
17717
|
return null;
|
|
@@ -17679,10 +17719,10 @@ function readEntryHtml(filePath) {
|
|
|
17679
17719
|
throw error;
|
|
17680
17720
|
}
|
|
17681
17721
|
try {
|
|
17682
|
-
if (!
|
|
17722
|
+
if (!fstatSync4(fd).isFile()) return null;
|
|
17683
17723
|
return readFileSync10(fd, "utf-8");
|
|
17684
17724
|
} finally {
|
|
17685
|
-
|
|
17725
|
+
closeSync6(fd);
|
|
17686
17726
|
}
|
|
17687
17727
|
}
|
|
17688
17728
|
function leavesProject(absProjectDir, absoluteEntryPath, isAllowedEntry) {
|
|
@@ -17691,7 +17731,7 @@ function leavesProject(absProjectDir, absoluteEntryPath, isAllowedEntry) {
|
|
|
17691
17731
|
}
|
|
17692
17732
|
function readProjectEntryFile(projectDir, preferredEntryFile, isAllowedEntry) {
|
|
17693
17733
|
const absProjectDir = resolve10(projectDir);
|
|
17694
|
-
if (!
|
|
17734
|
+
if (!existsSync22(absProjectDir) || !statSync11(absProjectDir).isDirectory()) {
|
|
17695
17735
|
return { error: `Project directory not found: ${absProjectDir}` };
|
|
17696
17736
|
}
|
|
17697
17737
|
const entryCandidates = [preferredEntryFile, "index.html", "src/index.html"].filter(
|
|
@@ -17782,7 +17822,7 @@ function resolveLintWorkerEntry() {
|
|
|
17782
17822
|
const here = dirname15(fileURLToPath5(import.meta.url));
|
|
17783
17823
|
for (const name of ["hyperframeLintWorker.js", "hyperframeLintWorker.ts"]) {
|
|
17784
17824
|
const candidate = join35(here, name);
|
|
17785
|
-
if (
|
|
17825
|
+
if (existsSync22(candidate)) return candidate;
|
|
17786
17826
|
}
|
|
17787
17827
|
return void 0;
|
|
17788
17828
|
}
|
|
@@ -17853,7 +17893,7 @@ async function runHyperframeLint(prepared, options = {}) {
|
|
|
17853
17893
|
import { Worker as Worker3 } from "node:worker_threads";
|
|
17854
17894
|
import { fileURLToPath as fileURLToPath6 } from "node:url";
|
|
17855
17895
|
import { dirname as dirname16, join as join36 } from "node:path";
|
|
17856
|
-
import { existsSync as
|
|
17896
|
+
import { existsSync as existsSync23 } from "node:fs";
|
|
17857
17897
|
var DEFAULT_HEALTH_PORT = 9848;
|
|
17858
17898
|
async function startHealthWorker(options = {}) {
|
|
17859
17899
|
const log = options.logger ?? defaultLogger2();
|
|
@@ -17930,7 +17970,7 @@ function resolveWorkerEntry2() {
|
|
|
17930
17970
|
const here = dirname16(fileURLToPath6(import.meta.url));
|
|
17931
17971
|
const candidates = [join36(here, "healthWorkerThread.js"), join36(here, "healthWorkerThread.ts")];
|
|
17932
17972
|
for (const candidate of candidates) {
|
|
17933
|
-
if (
|
|
17973
|
+
if (existsSync23(candidate)) return candidate;
|
|
17934
17974
|
}
|
|
17935
17975
|
return void 0;
|
|
17936
17976
|
}
|
|
@@ -17975,14 +18015,14 @@ import {
|
|
|
17975
18015
|
fpsToNumber as fpsToNumber9,
|
|
17976
18016
|
HF_COLOR_GRADING_ATTR as HF_COLOR_GRADING_ATTR2
|
|
17977
18017
|
} from "@hyperframes/core";
|
|
17978
|
-
import { isSafePath as
|
|
18018
|
+
import { isSafePath as isSafePath3 } from "@hyperframes/core/safe-path";
|
|
17979
18019
|
import {
|
|
17980
18020
|
getEncoderPreset as getEncoderPreset4,
|
|
17981
18021
|
keyframeIntervalToGopSize as keyframeIntervalToGopSize3,
|
|
17982
18022
|
normalizeVp9CpuUsed,
|
|
17983
18023
|
resolveConfig as resolveConfig3,
|
|
17984
18024
|
declareContentAddressedUrl,
|
|
17985
|
-
renameWithRetry as
|
|
18025
|
+
renameWithRetry as renameWithRetry7,
|
|
17986
18026
|
declareProbeFactsUrl
|
|
17987
18027
|
} from "@hyperframes/engine";
|
|
17988
18028
|
|
|
@@ -18004,7 +18044,7 @@ import {
|
|
|
18004
18044
|
// src/services/distributed/shared.ts
|
|
18005
18045
|
import { execFile as execFileCallback } from "node:child_process";
|
|
18006
18046
|
import { dirname as dirname17, join as join37 } from "node:path";
|
|
18007
|
-
import { existsSync as
|
|
18047
|
+
import { existsSync as existsSync24, readFileSync as readFileSync11 } from "node:fs";
|
|
18008
18048
|
import { fileURLToPath as fileURLToPath7 } from "node:url";
|
|
18009
18049
|
import { promisify as promisify2 } from "node:util";
|
|
18010
18050
|
import {
|
|
@@ -18020,7 +18060,7 @@ function readProducerVersion() {
|
|
|
18020
18060
|
let current = startDir;
|
|
18021
18061
|
for (let i = 0; i < 10; i++) {
|
|
18022
18062
|
const candidate = join37(current, "package.json");
|
|
18023
|
-
if (
|
|
18063
|
+
if (existsSync24(candidate)) {
|
|
18024
18064
|
try {
|
|
18025
18065
|
const pkg = JSON.parse(readFileSync11(candidate, "utf-8"));
|
|
18026
18066
|
if (pkg.name === "@hyperframes/producer" && typeof pkg.version === "string") {
|
|
@@ -18096,7 +18136,7 @@ var FIELD_DELIMITER = Buffer.from([0]);
|
|
|
18096
18136
|
import { appendRenderProvenanceArgs, describeFfmpegFailure as describeFfmpegFailure4, runFfmpeg as runFfmpeg7 } from "@hyperframes/engine";
|
|
18097
18137
|
|
|
18098
18138
|
// src/services/distributed/mp4Stitch.ts
|
|
18099
|
-
import { renameWithRetry as
|
|
18139
|
+
import { renameWithRetry as renameWithRetry6 } from "@hyperframes/engine";
|
|
18100
18140
|
import { createStagingDir as createStagingDir4 } from "@hyperframes/core/atomic-file";
|
|
18101
18141
|
var SCAN_BYTES = 64 * 1024;
|
|
18102
18142
|
|
|
@@ -18542,12 +18582,12 @@ function resolvePreparedRenderOutput(prepared, rendersDir, log, confineOutput) {
|
|
|
18542
18582
|
const absoluteOutputPath = resolveOutputPath(input.projectDir, input.outputPath, rendersDir, log);
|
|
18543
18583
|
if (confineOutput) {
|
|
18544
18584
|
mkdirSync13(rendersDir, { recursive: true });
|
|
18545
|
-
if (!
|
|
18585
|
+
if (!isSafePath4(rendersDir, absoluteOutputPath)) {
|
|
18546
18586
|
throw new Error("outputPath must be inside the renders directory");
|
|
18547
18587
|
}
|
|
18548
18588
|
}
|
|
18549
18589
|
const outputDir = dirname18(absoluteOutputPath);
|
|
18550
|
-
if (!
|
|
18590
|
+
if (!existsSync25(outputDir)) mkdirSync13(outputDir, { recursive: true });
|
|
18551
18591
|
return { input, cleanupProjectDir, absoluteOutputPath };
|
|
18552
18592
|
}
|
|
18553
18593
|
function prepareRenderJob(prepared, rendersDir, log, confineOutput) {
|
|
@@ -18615,22 +18655,22 @@ function resolveRenderRequestPolicy(options) {
|
|
|
18615
18655
|
};
|
|
18616
18656
|
}
|
|
18617
18657
|
function isAllowedProjectPath(projectsDir, path) {
|
|
18618
|
-
return
|
|
18658
|
+
return isSafePath4(projectsDir, path) && !isSafePath4(resolveRenderDebugDir(), path);
|
|
18619
18659
|
}
|
|
18620
18660
|
function isAllowedEntryPath(policy, projectDir, path) {
|
|
18621
|
-
return
|
|
18661
|
+
return isSafePath4(projectDir, path) && isAllowedProjectPath(policy.projectsDir, path);
|
|
18622
18662
|
}
|
|
18623
18663
|
function prepareProjectDirectory(projectDir, options, policy) {
|
|
18624
18664
|
const candidate = nonEmptyString(projectDir);
|
|
18625
18665
|
if (!candidate) return null;
|
|
18626
18666
|
const absProjectDir = policy ? resolve11(policy.projectsDir, candidate) : resolve11(candidate);
|
|
18627
18667
|
const shown = policy ? candidate : absProjectDir;
|
|
18628
|
-
if (policy && !isAllowedProjectPath(policy.projectsDir, absProjectDir) || !
|
|
18668
|
+
if (policy && !isAllowedProjectPath(policy.projectsDir, absProjectDir) || !existsSync25(absProjectDir) || !statSync12(absProjectDir).isDirectory()) {
|
|
18629
18669
|
return { error: `Project directory not found: ${shown}` };
|
|
18630
18670
|
}
|
|
18631
18671
|
const entry = options.entryFile || "index.html";
|
|
18632
18672
|
const entryPath = resolve11(absProjectDir, entry);
|
|
18633
|
-
if (policy && !isAllowedEntryPath(policy, absProjectDir, entryPath) || !
|
|
18673
|
+
if (policy && !isAllowedEntryPath(policy, absProjectDir, entryPath) || !existsSync25(entryPath)) {
|
|
18634
18674
|
return { error: `Entry file "${entry}" not found in project directory: ${shown}` };
|
|
18635
18675
|
}
|
|
18636
18676
|
return { prepared: { input: { projectDir: absProjectDir, ...options } } };
|
|
@@ -18652,7 +18692,7 @@ async function resolveInlineRenderHtml(body) {
|
|
|
18652
18692
|
function materializeInlineProject(html, options) {
|
|
18653
18693
|
const tempRoot = process.env.PRODUCER_TMP_PROJECT_DIR || tmpdir4();
|
|
18654
18694
|
const tempProjectDir = mkdtempSync(join39(tempRoot, "producer-project-"));
|
|
18655
|
-
|
|
18695
|
+
writeFileSync7(join39(tempProjectDir, "index.html"), html, "utf-8");
|
|
18656
18696
|
return {
|
|
18657
18697
|
prepared: {
|
|
18658
18698
|
input: { projectDir: tempProjectDir, ...options },
|
|
@@ -18728,7 +18768,7 @@ function publicPerfSummary(job) {
|
|
|
18728
18768
|
return job.perfSummary ? { ...job.perfSummary, renderId: void 0 } : null;
|
|
18729
18769
|
}
|
|
18730
18770
|
function outputFileSize(path) {
|
|
18731
|
-
return
|
|
18771
|
+
return existsSync25(path) ? statSync12(path).size : 0;
|
|
18732
18772
|
}
|
|
18733
18773
|
function createBlockingProgressReporter(log, requestId) {
|
|
18734
18774
|
let lastLoggedPct = -10;
|
|
@@ -19055,7 +19095,7 @@ function createRenderHandlers(options = {}) {
|
|
|
19055
19095
|
if (!artifact) {
|
|
19056
19096
|
return c.json({ success: false, error: "Output artifact not found or expired" }, 404);
|
|
19057
19097
|
}
|
|
19058
|
-
if (!
|
|
19098
|
+
if (!existsSync25(artifact.path)) {
|
|
19059
19099
|
store.delete(token);
|
|
19060
19100
|
return c.json({ success: false, error: "Output artifact file missing" }, 404);
|
|
19061
19101
|
}
|