@hyperframes/producer 0.9.93 → 0.9.95
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/dist/compileWorker.js +24 -13
- package/dist/distributed.js +82 -54
- package/dist/hyperframe.manifest.json +1 -1
- package/dist/hyperframe.runtime.iife.js +67 -67
- package/dist/index.js +445 -275
- package/dist/public-server.js +349 -179
- package/dist/services/render/captureCost.d.ts +4 -1
- package/dist/services/render/frameWindow.d.ts +17 -0
- package/dist/services/render/gpuChoice.d.ts +15 -0
- package/dist/services/render/stages/audioStage.d.ts +6 -1
- package/dist/services/render/stages/captureHdrFrameShared.d.ts +4 -1
- package/dist/services/renderOrchestrator.d.ts +5 -0
- package/package.json +7 -7
package/dist/compileWorker.js
CHANGED
|
@@ -1,6 +1,7 @@
|
|
|
1
1
|
// src/services/compileWorker.ts
|
|
2
2
|
import { parentPort, workerData } from "node:worker_threads";
|
|
3
3
|
import { onTrackedChildProcess } from "@hyperframes/engine";
|
|
4
|
+
import { fromEmptyFolder } from "@hyperframes/parsers/ff-binaries";
|
|
4
5
|
|
|
5
6
|
// src/services/compileScratch.ts
|
|
6
7
|
import { basename } from "node:path";
|
|
@@ -28,7 +29,7 @@ import {
|
|
|
28
29
|
import { createHash as createHash3 } from "node:crypto";
|
|
29
30
|
import { createReadStream, existsSync as existsSync3, mkdirSync as mkdirSync3, readFileSync as readFileSync4, statSync as statSync4 } from "fs";
|
|
30
31
|
import { join as join5, dirname as dirname3, resolve as resolve3, basename as basename3, relative, sep as sep2 } from "path";
|
|
31
|
-
import { parseHTML as parseHTML4 } from "linkedom";
|
|
32
|
+
import { parseHTML as parseHTML4 } from "@hyperframes/parsers/linkedom";
|
|
32
33
|
|
|
33
34
|
// src/services/bundledScripts.ts
|
|
34
35
|
import { existsSync, readFileSync } from "node:fs";
|
|
@@ -245,6 +246,7 @@ import { gsapCdnDist, normalizeGsapBaseUrl } from "@hyperframes/core/gsap-cdn";
|
|
|
245
246
|
import {
|
|
246
247
|
assignBundledRuntimeCompositionIds,
|
|
247
248
|
assignMediaRenderIds,
|
|
249
|
+
dropAuthoredCompositionFiles,
|
|
248
250
|
emitVariablesByCompScript,
|
|
249
251
|
inlineSubCompositions as inlineSubCompositionsShared,
|
|
250
252
|
ensureExternalLinkTag,
|
|
@@ -278,7 +280,7 @@ import {
|
|
|
278
280
|
readTextFile,
|
|
279
281
|
resolveCompositionSrc
|
|
280
282
|
} from "@hyperframes/parsers/asset-resolution";
|
|
281
|
-
import { isPrivateFileUnder, isStudioPrivatePath } from "@hyperframes/core/safe-path";
|
|
283
|
+
import { isPrivateFileUnder as isPrivateFileUnder2, isStudioPrivatePath as isStudioPrivatePath2 } from "@hyperframes/core/safe-path";
|
|
282
284
|
import { linksOutside as linksOutside2 } from "@hyperframes/studio-server/outside-file";
|
|
283
285
|
|
|
284
286
|
// src/utils/ffprobe.ts
|
|
@@ -308,7 +310,7 @@ import {
|
|
|
308
310
|
} from "node:path";
|
|
309
311
|
import { statSync } from "node:fs";
|
|
310
312
|
import { fileURLToPath } from "node:url";
|
|
311
|
-
import { isSafePath } from "@hyperframes/core/safe-path";
|
|
313
|
+
import { isPrivateFileUnder, isSafePath, isStudioPrivatePath } from "@hyperframes/core/safe-path";
|
|
312
314
|
import {
|
|
313
315
|
isCopiedOutsideFileType,
|
|
314
316
|
isPrivateOutsideFile,
|
|
@@ -335,7 +337,10 @@ function escapesAssetRoot(path, assetRoot) {
|
|
|
335
337
|
return assetRoot !== void 0 && !isSafePath(assetRoot, path);
|
|
336
338
|
}
|
|
337
339
|
function outsideAssetRefusal(projectDir2, path, policy = {}) {
|
|
338
|
-
if (!linksOutside(projectDir2, path))
|
|
340
|
+
if (!linksOutside(projectDir2, path)) {
|
|
341
|
+
const privateByAnotherSpelling = !isPathInside(path, projectDir2) && isPrivateFileUnder(projectDir2, path, isStudioPrivatePath);
|
|
342
|
+
return privateByAnotherSpelling ? "blocklisted" : null;
|
|
343
|
+
}
|
|
339
344
|
if (isPrivateOutsideFile(projectDir2, path)) return "blocklisted";
|
|
340
345
|
const folder = statSync(path, { throwIfNoEntry: false })?.isDirectory();
|
|
341
346
|
if (folder || isUploadedOutsideFileType(path)) return null;
|
|
@@ -362,7 +367,7 @@ function toExternalAssetKey(absPath) {
|
|
|
362
367
|
}
|
|
363
368
|
|
|
364
369
|
// src/services/renderMediaCollector.ts
|
|
365
|
-
import { parseHTML } from "linkedom";
|
|
370
|
+
import { parseHTML } from "@hyperframes/parsers/linkedom";
|
|
366
371
|
import {
|
|
367
372
|
MEDIA_RENDER_ID_ATTR,
|
|
368
373
|
normalizeRateSpec,
|
|
@@ -556,7 +561,7 @@ import {
|
|
|
556
561
|
import { createHash, randomUUID } from "node:crypto";
|
|
557
562
|
import { copyFileSync, existsSync as existsSync2, mkdirSync, readFileSync as readFileSync2, rmSync, statSync as statSync2 } from "node:fs";
|
|
558
563
|
import { dirname, isAbsolute, join as join3, resolve } from "node:path";
|
|
559
|
-
import { parseHTML as parseHTML2 } from "linkedom";
|
|
564
|
+
import { parseHTML as parseHTML2 } from "@hyperframes/parsers/linkedom";
|
|
560
565
|
import { parseAnimatedGifMetadata } from "@hyperframes/core";
|
|
561
566
|
import {
|
|
562
567
|
DEFAULT_VP9_CPU_USED,
|
|
@@ -631,7 +636,11 @@ function resolveLocalImageSourcePath(src, options2) {
|
|
|
631
636
|
resolve(options2.downloadDir, normalizedBase)
|
|
632
637
|
];
|
|
633
638
|
const assetRoot = options2.allowOutsideFiles ? void 0 : options2.projectDir;
|
|
634
|
-
const allowed = (candidate) => !namesAnotherNetworkRoot(options2.projectDir, candidate) && !isPrivateUnderAssetRoots(
|
|
639
|
+
const allowed = (candidate) => !namesAnotherNetworkRoot(options2.projectDir, candidate) && !isPrivateUnderAssetRoots(
|
|
640
|
+
candidate,
|
|
641
|
+
[options2.projectDir, options2.downloadDir],
|
|
642
|
+
options2.allowOutsideFiles
|
|
643
|
+
) && (!escapesAssetRoot(candidate, assetRoot) && outsideAssetRefusal(options2.projectDir, candidate) !== "blocklisted" || !escapesAssetRoot(candidate, options2.downloadDir));
|
|
635
644
|
return candidates.find((candidate) => allowed(candidate) && existsSync2(candidate)) ?? null;
|
|
636
645
|
}
|
|
637
646
|
function isUsableFile(path) {
|
|
@@ -926,7 +935,7 @@ import {
|
|
|
926
935
|
writeFileSync
|
|
927
936
|
} from "node:fs";
|
|
928
937
|
import { dirname as dirname2, join as join4, resolve as resolve2 } from "node:path";
|
|
929
|
-
import { parseHTML as parseHTML3 } from "linkedom";
|
|
938
|
+
import { parseHTML as parseHTML3 } from "@hyperframes/parsers/linkedom";
|
|
930
939
|
import { renameWithRetry as renameWithRetry2, runFfmpeg as runFfmpeg2, runFfprobe, urlInputArgs as urlInputArgs2 } from "@hyperframes/engine";
|
|
931
940
|
|
|
932
941
|
// src/services/heifRotation.ts
|
|
@@ -1433,7 +1442,7 @@ function assertOutsideMarkupAsked(projectDir2, filePath, srcPath, assetRoot, out
|
|
|
1433
1442
|
throw new EmptyCompositionError([{ srcPath, detail: OUTSIDE_COMPOSITION_NEEDS_FLAG }]);
|
|
1434
1443
|
}
|
|
1435
1444
|
}
|
|
1436
|
-
var isPrivateCompositionFile = (projectDir2, filePath) =>
|
|
1445
|
+
var isPrivateCompositionFile = (projectDir2, filePath) => isPrivateFileUnder2(projectDir2, filePath, isStudioPrivatePath2);
|
|
1437
1446
|
function compositionSrcsIn(html) {
|
|
1438
1447
|
const { document: document2 } = parseHTML4(html);
|
|
1439
1448
|
const mounts = [];
|
|
@@ -1770,7 +1779,7 @@ async function resolveMediaDuration(src, mediaStart, playbackRate, projectDir2,
|
|
|
1770
1779
|
} else {
|
|
1771
1780
|
filePath = decodedUrlPath(src);
|
|
1772
1781
|
if (!filePath.startsWith("/")) filePath = join5(baseDir, filePath);
|
|
1773
|
-
if (escapesAssetRoot(filePath, assetRoot) || isPrivateUnderAssetRoots3(filePath, [projectDir2, downloadDir2])) {
|
|
1782
|
+
if (escapesAssetRoot(filePath, assetRoot) || isPrivateUnderAssetRoots3(filePath, [projectDir2, downloadDir2], assetRoot === void 0)) {
|
|
1774
1783
|
return { duration: null, resolvedPath: filePath };
|
|
1775
1784
|
}
|
|
1776
1785
|
filePath = urlByAbsentLocalPath?.get(filePath) ?? filePath;
|
|
@@ -2124,6 +2133,7 @@ function coalesceHeadStylesAndBodyScripts(html) {
|
|
|
2124
2133
|
}
|
|
2125
2134
|
function inlineSubCompositions(html, subCompositions, projectDir2, variableOverrides, assetRoot, outsideFiles, budget) {
|
|
2126
2135
|
const { document: document2 } = parseHTML4(html);
|
|
2136
|
+
dropAuthoredCompositionFiles(document2);
|
|
2127
2137
|
budget.chargeElements(ENTRY_PAGE, document2.querySelectorAll("*").length);
|
|
2128
2138
|
const head = document2.querySelector("head");
|
|
2129
2139
|
const body = document2.querySelector("body");
|
|
@@ -3170,7 +3180,7 @@ async function compileWithAssets(projectDir2, htmlPath2, downloadDir2, options2,
|
|
|
3170
3180
|
for (const video of videos) {
|
|
3171
3181
|
if (isHttpUrl(video.src)) continue;
|
|
3172
3182
|
const videoPath = resolve3(projectDir2, video.src);
|
|
3173
|
-
if (advised.has(videoPath) || namesAnotherNetworkRoot2(projectDir2, videoPath) || !existsSync3(videoPath) || escapesAssetRoot(videoPath, assetRoot) || isPrivateUnderAssetRoots3(videoPath, [projectDir2, downloadDir2]))
|
|
3183
|
+
if (advised.has(videoPath) || namesAnotherNetworkRoot2(projectDir2, videoPath) || !existsSync3(videoPath) || escapesAssetRoot(videoPath, assetRoot) || isPrivateUnderAssetRoots3(videoPath, [projectDir2, downloadDir2], assetRoot === void 0))
|
|
3174
3184
|
continue;
|
|
3175
3185
|
advised.add(videoPath);
|
|
3176
3186
|
const reencode = `ffmpeg -i "${video.src}" -c:v libx264 -r 30 -g 30 -keyint_min 30 -movflags +faststart -c:a copy output.mp4`;
|
|
@@ -3220,7 +3230,7 @@ async function compileWithAssets(projectDir2, htmlPath2, downloadDir2, options2,
|
|
|
3220
3230
|
}
|
|
3221
3231
|
|
|
3222
3232
|
// src/services/compileWorker.ts
|
|
3223
|
-
var { projectDir, htmlPath, downloadDir, options } = workerData;
|
|
3233
|
+
var { projectDir, htmlPath, downloadDir, options, emptyFolder } = workerData;
|
|
3224
3234
|
function post(level, message, meta) {
|
|
3225
3235
|
try {
|
|
3226
3236
|
parentPort?.postMessage({ type: "log", level, message, meta });
|
|
@@ -3256,11 +3266,12 @@ onTrackedChildProcess((proc) => {
|
|
|
3256
3266
|
proc.once("exit", () => parentPort?.postMessage({ type: "childExit", pid }));
|
|
3257
3267
|
});
|
|
3258
3268
|
try {
|
|
3259
|
-
const
|
|
3269
|
+
const compile = () => compileForRender(projectDir, htmlPath, downloadDir, {
|
|
3260
3270
|
...options,
|
|
3261
3271
|
log,
|
|
3262
3272
|
abortSignal: controller.signal
|
|
3263
3273
|
});
|
|
3274
|
+
const compiled = await (emptyFolder ? fromEmptyFolder(compile) : compile());
|
|
3264
3275
|
parentPort?.postMessage({ type: "result", compiled });
|
|
3265
3276
|
} catch (error) {
|
|
3266
3277
|
const props = {};
|
package/dist/distributed.js
CHANGED
|
@@ -83,7 +83,7 @@ import {
|
|
|
83
83
|
} from "node:path";
|
|
84
84
|
import { statSync } from "node:fs";
|
|
85
85
|
import { fileURLToPath } from "node:url";
|
|
86
|
-
import { isSafePath } from "@hyperframes/core/safe-path";
|
|
86
|
+
import { isPrivateFileUnder, isSafePath, isStudioPrivatePath } from "@hyperframes/core/safe-path";
|
|
87
87
|
import {
|
|
88
88
|
isCopiedOutsideFileType,
|
|
89
89
|
isPrivateOutsideFile,
|
|
@@ -110,7 +110,10 @@ function escapesAssetRoot(path, assetRoot) {
|
|
|
110
110
|
return assetRoot !== void 0 && !isSafePath(assetRoot, path);
|
|
111
111
|
}
|
|
112
112
|
function outsideAssetRefusal(projectDir, path, policy = {}) {
|
|
113
|
-
if (!linksOutside(projectDir, path))
|
|
113
|
+
if (!linksOutside(projectDir, path)) {
|
|
114
|
+
const privateByAnotherSpelling = !isPathInside(path, projectDir) && isPrivateFileUnder(projectDir, path, isStudioPrivatePath);
|
|
115
|
+
return privateByAnotherSpelling ? "blocklisted" : null;
|
|
116
|
+
}
|
|
114
117
|
if (isPrivateOutsideFile(projectDir, path)) return "blocklisted";
|
|
115
118
|
const folder = statSync(path, { throwIfNoEntry: false })?.isDirectory();
|
|
116
119
|
if (folder || isUploadedOutsideFileType(path)) return null;
|
|
@@ -355,6 +358,7 @@ import {
|
|
|
355
358
|
LOW_MEMORY_TOTAL_MB_THRESHOLD,
|
|
356
359
|
assertConfiguredFfmpegBinariesExist,
|
|
357
360
|
resolveBrowserGpuMode,
|
|
361
|
+
probedHardwareGpu,
|
|
358
362
|
resolveHeadlessShellPath,
|
|
359
363
|
compositionRequiresWebGpu as compositionRequiresWebGpu2,
|
|
360
364
|
applyConcreteGpuScreenshotClamp,
|
|
@@ -376,7 +380,8 @@ import {
|
|
|
376
380
|
referenceBackgroundResult,
|
|
377
381
|
createReferenceBackgroundRecorder
|
|
378
382
|
} from "@hyperframes/engine";
|
|
379
|
-
import { join as join19, dirname as dirname12, resolve as
|
|
383
|
+
import { join as join19, dirname as dirname12, resolve as resolve8 } from "path";
|
|
384
|
+
import { fromEmptyFolder } from "@hyperframes/parsers/ff-binaries";
|
|
380
385
|
import { randomUUID as randomUUID3 } from "crypto";
|
|
381
386
|
|
|
382
387
|
// src/services/fileServer.ts
|
|
@@ -404,7 +409,7 @@ import {
|
|
|
404
409
|
serviceWorkerScriptFetch
|
|
405
410
|
} from "@hyperframes/core/studio-preview-mark";
|
|
406
411
|
import { fpsToNumber, terminalText as terminalText2 } from "@hyperframes/core";
|
|
407
|
-
import { isPrivateFileUnder, isStudioPrivatePath } from "@hyperframes/core/safe-path";
|
|
412
|
+
import { isPrivateFileUnder as isPrivateFileUnder2, isStudioPrivatePath as isStudioPrivatePath2 } from "@hyperframes/core/safe-path";
|
|
408
413
|
import { stripSdrPngColourTags } from "@hyperframes/core/compiler/png-colour-tags";
|
|
409
414
|
import { openRangeEnd } from "@hyperframes/studio-server/media-range";
|
|
410
415
|
|
|
@@ -1076,7 +1081,7 @@ function createFileServer(options) {
|
|
|
1076
1081
|
const candidate = join2(root, relativePath);
|
|
1077
1082
|
const resolveSymlinks = !allowOutsideProjectAssets && root !== compiledDir;
|
|
1078
1083
|
if (!isPathInside2(candidate, root, { resolveSymlinks })) continue;
|
|
1079
|
-
if (
|
|
1084
|
+
if (isPrivateFileUnder2(root, candidate, isStudioPrivatePath2)) continue;
|
|
1080
1085
|
const checksLinks = allowOutsideProjectAssets && root !== compiledDir;
|
|
1081
1086
|
if (checksLinks && refusesOutsideLink(root, candidate, warnLeftOut, outsidePolicy)) continue;
|
|
1082
1087
|
file = openRegularFile(candidate);
|
|
@@ -1158,13 +1163,13 @@ function createFileServer(options) {
|
|
|
1158
1163
|
if (!streamOwnsFd) closeSync(fd);
|
|
1159
1164
|
}
|
|
1160
1165
|
});
|
|
1161
|
-
return new Promise((
|
|
1166
|
+
return new Promise((resolve11, reject) => {
|
|
1162
1167
|
const connections = /* @__PURE__ */ new Set();
|
|
1163
1168
|
const server = serve({ fetch: app.fetch, port, hostname: "127.0.0.1" }, (info) => {
|
|
1164
1169
|
const bound = port === 0 ? settleOnBrowserSafePort(server, "127.0.0.1") : Promise.resolve(info.port);
|
|
1165
1170
|
bound.then((boundPort) => {
|
|
1166
1171
|
listeningPort = boundPort;
|
|
1167
|
-
|
|
1172
|
+
resolve11({
|
|
1168
1173
|
url: `http://localhost:${boundPort}`,
|
|
1169
1174
|
port: boundPort,
|
|
1170
1175
|
addPreHeadScript: (script) => {
|
|
@@ -1653,6 +1658,7 @@ import {
|
|
|
1653
1658
|
concatVideoFiles,
|
|
1654
1659
|
createCaptureSession as createCaptureSession2,
|
|
1655
1660
|
getCapturePerfSummary as getCapturePerfSummary2,
|
|
1661
|
+
retainCapturePerf as retainCapturePerf3,
|
|
1656
1662
|
initializeSession as initializeSession2,
|
|
1657
1663
|
prepareCaptureSessionForReuse as prepareCaptureSessionForReuse2,
|
|
1658
1664
|
resolveDeVerifyMinDb as resolveDeVerifyMinDb2,
|
|
@@ -1665,10 +1671,10 @@ import { CaptureFailure, classifyCaptureFailure } from "@hyperframes/engine";
|
|
|
1665
1671
|
|
|
1666
1672
|
// src/services/render/perfSummary.ts
|
|
1667
1673
|
import { fpsToNumber as fpsToNumber2 } from "@hyperframes/core";
|
|
1668
|
-
import { hostCpuCount } from "@hyperframes/engine";
|
|
1674
|
+
import { hostCpuCount, retainCapturePerf } from "@hyperframes/engine";
|
|
1669
1675
|
function pushWorkerDedupPerfs(results, sink) {
|
|
1670
1676
|
for (const r of results) {
|
|
1671
|
-
if (r.perf) sink
|
|
1677
|
+
if (r.perf) retainCapturePerf(sink, r.perf);
|
|
1672
1678
|
}
|
|
1673
1679
|
}
|
|
1674
1680
|
function pushWorkerPageErrors(results, sink) {
|
|
@@ -1777,6 +1783,7 @@ import {
|
|
|
1777
1783
|
distributeFramesInterleaved,
|
|
1778
1784
|
executeParallelCapture,
|
|
1779
1785
|
getCapturePerfSummary,
|
|
1786
|
+
retainCapturePerf as retainCapturePerf2,
|
|
1780
1787
|
psnrDb,
|
|
1781
1788
|
resolveDeVerifyMinDb,
|
|
1782
1789
|
recaptureDrawElementFrameForVerify,
|
|
@@ -1832,7 +1839,7 @@ var SequentialCaptureStallError = class extends Error {
|
|
|
1832
1839
|
}
|
|
1833
1840
|
};
|
|
1834
1841
|
function raceAgainstStall(promise, deadlineMs, input, signal) {
|
|
1835
|
-
return new Promise((
|
|
1842
|
+
return new Promise((resolve11, reject) => {
|
|
1836
1843
|
const clock = createStallClock();
|
|
1837
1844
|
const trip = () => reject(
|
|
1838
1845
|
signal?.aborted ? new Error(
|
|
@@ -1857,7 +1864,7 @@ function raceAgainstStall(promise, deadlineMs, input, signal) {
|
|
|
1857
1864
|
promise.then(
|
|
1858
1865
|
(value) => {
|
|
1859
1866
|
clearTimeout(timer);
|
|
1860
|
-
|
|
1867
|
+
resolve11(value);
|
|
1861
1868
|
},
|
|
1862
1869
|
(error) => {
|
|
1863
1870
|
clearTimeout(timer);
|
|
@@ -1941,8 +1948,8 @@ function selectCaptureCalibrationFrames(totalFrames) {
|
|
|
1941
1948
|
new Set(candidates.map((frame) => Math.max(0, Math.min(lastFrame, frame))))
|
|
1942
1949
|
).sort((a, b) => a - b);
|
|
1943
1950
|
}
|
|
1944
|
-
async function measureCaptureCostFromSession(session, totalFrames, fps, log) {
|
|
1945
|
-
const sampledFrames = selectCaptureCalibrationFrames(totalFrames);
|
|
1951
|
+
async function measureCaptureCostFromSession(session, totalFrames, fps, log, firstFrame = 0) {
|
|
1952
|
+
const sampledFrames = selectCaptureCalibrationFrames(totalFrames).map((i) => firstFrame + i);
|
|
1946
1953
|
const samples = [];
|
|
1947
1954
|
const totalSamples = sampledFrames.length;
|
|
1948
1955
|
const savedStaticFrames = session.staticFrames;
|
|
@@ -2426,7 +2433,7 @@ async function observeRenderStage(recorder, phase, data, fn, options = {}) {
|
|
|
2426
2433
|
}
|
|
2427
2434
|
|
|
2428
2435
|
// src/services/render/videoFrameCoverage.ts
|
|
2429
|
-
import { parseHTML } from "linkedom";
|
|
2436
|
+
import { parseHTML } from "@hyperframes/parsers/linkedom";
|
|
2430
2437
|
import {
|
|
2431
2438
|
fpsToNumber as fpsToNumber5,
|
|
2432
2439
|
normalizeRateSpec,
|
|
@@ -2456,7 +2463,7 @@ function requireOutputDimensions(expected, width, height) {
|
|
|
2456
2463
|
|
|
2457
2464
|
// src/services/render/stages/compileStage.ts
|
|
2458
2465
|
import { existsSync as existsSync9, writeFileSync as writeFileSync3 } from "node:fs";
|
|
2459
|
-
import { join as join11, relative as relative4 } from "node:path";
|
|
2466
|
+
import { join as join11, relative as relative4, resolve as resolve7 } from "node:path";
|
|
2460
2467
|
import { privateCacheRoot } from "@hyperframes/engine";
|
|
2461
2468
|
import { suggestMatchingPreset } from "@hyperframes/core";
|
|
2462
2469
|
import { extractStandaloneEntryFromIndex, isTemplateEntry } from "@hyperframes/core/compiler";
|
|
@@ -2465,6 +2472,7 @@ import { assertCompositionFileSize as assertCompositionFileSize2 } from "@hyperf
|
|
|
2465
2472
|
|
|
2466
2473
|
// src/services/compileInWorker.ts
|
|
2467
2474
|
import { existsSync as existsSync8, rmSync as rmSync4 } from "node:fs";
|
|
2475
|
+
import { ffmpegCwd } from "@hyperframes/parsers/ff-binaries";
|
|
2468
2476
|
import { dirname as dirname8, isAbsolute as isAbsolute3, join as join10, relative as relative3, resolve as resolvePath } from "node:path";
|
|
2469
2477
|
import { fileURLToPath as fileURLToPath3 } from "node:url";
|
|
2470
2478
|
import { Worker } from "node:worker_threads";
|
|
@@ -2487,7 +2495,7 @@ import {
|
|
|
2487
2495
|
import { createHash as createHash5 } from "node:crypto";
|
|
2488
2496
|
import { createReadStream as createReadStream2, existsSync as existsSync7, mkdirSync as mkdirSync4, readFileSync as readFileSync5, statSync as statSync5 } from "fs";
|
|
2489
2497
|
import { join as join9, dirname as dirname7, resolve as resolve6, basename as basename3, relative as relative2, sep as sep3 } from "path";
|
|
2490
|
-
import { parseHTML as parseHTML5 } from "linkedom";
|
|
2498
|
+
import { parseHTML as parseHTML5 } from "@hyperframes/parsers/linkedom";
|
|
2491
2499
|
|
|
2492
2500
|
// src/services/bundledScripts.ts
|
|
2493
2501
|
import { existsSync as existsSync4, readFileSync as readFileSync2 } from "node:fs";
|
|
@@ -2536,6 +2544,7 @@ import { gsapCdnDist, normalizeGsapBaseUrl } from "@hyperframes/core/gsap-cdn";
|
|
|
2536
2544
|
import {
|
|
2537
2545
|
assignBundledRuntimeCompositionIds,
|
|
2538
2546
|
assignMediaRenderIds,
|
|
2547
|
+
dropAuthoredCompositionFiles,
|
|
2539
2548
|
emitVariablesByCompScript,
|
|
2540
2549
|
inlineSubCompositions as inlineSubCompositionsShared,
|
|
2541
2550
|
ensureExternalLinkTag,
|
|
@@ -2569,7 +2578,7 @@ import {
|
|
|
2569
2578
|
readTextFile,
|
|
2570
2579
|
resolveCompositionSrc
|
|
2571
2580
|
} from "@hyperframes/parsers/asset-resolution";
|
|
2572
|
-
import { isPrivateFileUnder as
|
|
2581
|
+
import { isPrivateFileUnder as isPrivateFileUnder3, isStudioPrivatePath as isStudioPrivatePath3 } from "@hyperframes/core/safe-path";
|
|
2573
2582
|
import { linksOutside as linksOutside2 } from "@hyperframes/studio-server/outside-file";
|
|
2574
2583
|
import {
|
|
2575
2584
|
assertCompositionFileSize,
|
|
@@ -2580,7 +2589,7 @@ import {
|
|
|
2580
2589
|
} from "@hyperframes/core/compiler";
|
|
2581
2590
|
|
|
2582
2591
|
// src/services/renderMediaCollector.ts
|
|
2583
|
-
import { parseHTML as parseHTML2 } from "linkedom";
|
|
2592
|
+
import { parseHTML as parseHTML2 } from "@hyperframes/parsers/linkedom";
|
|
2584
2593
|
import {
|
|
2585
2594
|
MEDIA_RENDER_ID_ATTR,
|
|
2586
2595
|
normalizeRateSpec as normalizeRateSpec2,
|
|
@@ -2774,7 +2783,7 @@ import {
|
|
|
2774
2783
|
import { createHash as createHash3, randomUUID } from "node:crypto";
|
|
2775
2784
|
import { copyFileSync as copyFileSync2, existsSync as existsSync5, mkdirSync as mkdirSync2, readFileSync as readFileSync3, rmSync as rmSync2, statSync as statSync3 } from "node:fs";
|
|
2776
2785
|
import { dirname as dirname4, isAbsolute as isAbsolute2, join as join6, resolve as resolve4 } from "node:path";
|
|
2777
|
-
import { parseHTML as parseHTML3 } from "linkedom";
|
|
2786
|
+
import { parseHTML as parseHTML3 } from "@hyperframes/parsers/linkedom";
|
|
2778
2787
|
import { parseAnimatedGifMetadata } from "@hyperframes/core";
|
|
2779
2788
|
import {
|
|
2780
2789
|
DEFAULT_VP9_CPU_USED,
|
|
@@ -2826,7 +2835,11 @@ function resolveLocalImageSourcePath(src, options) {
|
|
|
2826
2835
|
resolve4(options.downloadDir, normalizedBase)
|
|
2827
2836
|
];
|
|
2828
2837
|
const assetRoot = options.allowOutsideFiles ? void 0 : options.projectDir;
|
|
2829
|
-
const allowed = (candidate) => !namesAnotherNetworkRoot(options.projectDir, candidate) && !isPrivateUnderAssetRoots(
|
|
2838
|
+
const allowed = (candidate) => !namesAnotherNetworkRoot(options.projectDir, candidate) && !isPrivateUnderAssetRoots(
|
|
2839
|
+
candidate,
|
|
2840
|
+
[options.projectDir, options.downloadDir],
|
|
2841
|
+
options.allowOutsideFiles
|
|
2842
|
+
) && (!escapesAssetRoot(candidate, assetRoot) && outsideAssetRefusal(options.projectDir, candidate) !== "blocklisted" || !escapesAssetRoot(candidate, options.downloadDir));
|
|
2830
2843
|
return candidates.find((candidate) => allowed(candidate) && existsSync5(candidate)) ?? null;
|
|
2831
2844
|
}
|
|
2832
2845
|
function isUsableFile(path) {
|
|
@@ -3121,7 +3134,7 @@ import {
|
|
|
3121
3134
|
writeFileSync as writeFileSync2
|
|
3122
3135
|
} from "node:fs";
|
|
3123
3136
|
import { dirname as dirname5, join as join7, resolve as resolve5 } from "node:path";
|
|
3124
|
-
import { parseHTML as parseHTML4 } from "linkedom";
|
|
3137
|
+
import { parseHTML as parseHTML4 } from "@hyperframes/parsers/linkedom";
|
|
3125
3138
|
import { renameWithRetry as renameWithRetry3, runFfmpeg as runFfmpeg3, runFfprobe, urlInputArgs as urlInputArgs3 } from "@hyperframes/engine";
|
|
3126
3139
|
|
|
3127
3140
|
// src/services/heifRotation.ts
|
|
@@ -3189,10 +3202,10 @@ var Semaphore = class {
|
|
|
3189
3202
|
this.active++;
|
|
3190
3203
|
return () => this.release();
|
|
3191
3204
|
}
|
|
3192
|
-
return new Promise((
|
|
3205
|
+
return new Promise((resolve11) => {
|
|
3193
3206
|
this.queue.push(() => {
|
|
3194
3207
|
this.active++;
|
|
3195
|
-
|
|
3208
|
+
resolve11(() => this.release());
|
|
3196
3209
|
});
|
|
3197
3210
|
});
|
|
3198
3211
|
}
|
|
@@ -3522,7 +3535,7 @@ function dropMediaOutsideProject(input) {
|
|
|
3522
3535
|
const staysInside = ({ id, src }) => {
|
|
3523
3536
|
if (!src || isHttpUrl2(src)) return true;
|
|
3524
3537
|
const path = resolveProjectRelativeSrc3(src, projectDir, compiledDir);
|
|
3525
|
-
if (isPrivateUnderAssetRoots2(path, roots)) {
|
|
3538
|
+
if (isPrivateUnderAssetRoots2(path, roots, input.allowOutsideProjectAssets)) {
|
|
3526
3539
|
log.warn(`[Render] Media "${id}" source is missing: it is a private project file`, { src });
|
|
3527
3540
|
return false;
|
|
3528
3541
|
}
|
|
@@ -3692,7 +3705,7 @@ function assertOutsideMarkupAsked(projectDir, filePath, srcPath, assetRoot, outs
|
|
|
3692
3705
|
throw new EmptyCompositionError([{ srcPath, detail: OUTSIDE_COMPOSITION_NEEDS_FLAG }]);
|
|
3693
3706
|
}
|
|
3694
3707
|
}
|
|
3695
|
-
var isPrivateCompositionFile = (projectDir, filePath) =>
|
|
3708
|
+
var isPrivateCompositionFile = (projectDir, filePath) => isPrivateFileUnder3(projectDir, filePath, isStudioPrivatePath3);
|
|
3696
3709
|
function compositionSrcsIn(html) {
|
|
3697
3710
|
const { document: document2 } = parseHTML5(html);
|
|
3698
3711
|
const mounts = [];
|
|
@@ -3994,7 +4007,7 @@ var AssetDownloads = class {
|
|
|
3994
4007
|
}
|
|
3995
4008
|
async download(url, destDir) {
|
|
3996
4009
|
while (this.running >= ASSET_DOWNLOADS_AT_ONCE) {
|
|
3997
|
-
await new Promise((
|
|
4010
|
+
await new Promise((resolve11) => this.queued.push(resolve11));
|
|
3998
4011
|
}
|
|
3999
4012
|
if (this.signal?.aborted) {
|
|
4000
4013
|
this.queued.shift()?.();
|
|
@@ -4029,7 +4042,7 @@ async function resolveMediaDuration(src, mediaStart, playbackRate, projectDir, b
|
|
|
4029
4042
|
} else {
|
|
4030
4043
|
filePath = decodedUrlPath(src);
|
|
4031
4044
|
if (!filePath.startsWith("/")) filePath = join9(baseDir, filePath);
|
|
4032
|
-
if (escapesAssetRoot(filePath, assetRoot) || isPrivateUnderAssetRoots3(filePath, [projectDir, downloadDir])) {
|
|
4045
|
+
if (escapesAssetRoot(filePath, assetRoot) || isPrivateUnderAssetRoots3(filePath, [projectDir, downloadDir], assetRoot === void 0)) {
|
|
4033
4046
|
return { duration: null, resolvedPath: filePath };
|
|
4034
4047
|
}
|
|
4035
4048
|
filePath = urlByAbsentLocalPath?.get(filePath) ?? filePath;
|
|
@@ -4383,6 +4396,7 @@ function coalesceHeadStylesAndBodyScripts(html) {
|
|
|
4383
4396
|
}
|
|
4384
4397
|
function inlineSubCompositions(html, subCompositions, projectDir, variableOverrides, assetRoot, outsideFiles, budget) {
|
|
4385
4398
|
const { document: document2 } = parseHTML5(html);
|
|
4399
|
+
dropAuthoredCompositionFiles(document2);
|
|
4386
4400
|
budget.chargeElements(ENTRY_PAGE, document2.querySelectorAll("*").length);
|
|
4387
4401
|
const head = document2.querySelector("head");
|
|
4388
4402
|
const body = document2.querySelector("body");
|
|
@@ -5429,7 +5443,7 @@ async function compileWithAssets(projectDir, htmlPath, downloadDir, options, ass
|
|
|
5429
5443
|
for (const video of videos) {
|
|
5430
5444
|
if (isHttpUrl(video.src)) continue;
|
|
5431
5445
|
const videoPath = resolve6(projectDir, video.src);
|
|
5432
|
-
if (advised.has(videoPath) || namesAnotherNetworkRoot2(projectDir, videoPath) || !existsSync7(videoPath) || escapesAssetRoot(videoPath, assetRoot) || isPrivateUnderAssetRoots3(videoPath, [projectDir, downloadDir]))
|
|
5446
|
+
if (advised.has(videoPath) || namesAnotherNetworkRoot2(projectDir, videoPath) || !existsSync7(videoPath) || escapesAssetRoot(videoPath, assetRoot) || isPrivateUnderAssetRoots3(videoPath, [projectDir, downloadDir], assetRoot === void 0))
|
|
5433
5447
|
continue;
|
|
5434
5448
|
advised.add(videoPath);
|
|
5435
5449
|
const reencode = `ffmpeg -i "${video.src}" -c:v libx264 -r 30 -g 30 -keyint_min 30 -movflags +faststart -c:a copy output.mp4`;
|
|
@@ -5910,9 +5924,15 @@ async function compileForRenderInWorker(projectDir, htmlPath, downloadDir, optio
|
|
|
5910
5924
|
if (!entry) return compileForRender(projectDir, htmlPath, downloadDir, options);
|
|
5911
5925
|
abortSignal?.throwIfAborted();
|
|
5912
5926
|
const timeoutMs = worker.timeoutMs ?? compileTimeoutMs();
|
|
5913
|
-
return new Promise((
|
|
5927
|
+
return new Promise((resolve11, reject) => {
|
|
5914
5928
|
const thread = new Worker(entry, {
|
|
5915
|
-
workerData: {
|
|
5929
|
+
workerData: {
|
|
5930
|
+
projectDir,
|
|
5931
|
+
htmlPath,
|
|
5932
|
+
downloadDir,
|
|
5933
|
+
options: cloneable,
|
|
5934
|
+
emptyFolder: ffmpegCwd() !== void 0
|
|
5935
|
+
}
|
|
5916
5936
|
});
|
|
5917
5937
|
const children = /* @__PURE__ */ new Map();
|
|
5918
5938
|
const scratchRoots = [downloadDir, options.animatedGifCacheDir].flatMap(
|
|
@@ -5966,7 +5986,7 @@ async function compileForRenderInWorker(projectDir, htmlPath, downloadDir, optio
|
|
|
5966
5986
|
log?.[message.level](message.message ?? "", message.meta);
|
|
5967
5987
|
} else if (message.type === "result" && message.compiled) {
|
|
5968
5988
|
const { compiled } = message;
|
|
5969
|
-
settle(() =>
|
|
5989
|
+
settle(() => resolve11(compiled));
|
|
5970
5990
|
retire(ADVISORY_GRACE_MS);
|
|
5971
5991
|
} else if (message.type === "error" && message.error) {
|
|
5972
5992
|
const { error } = message;
|
|
@@ -5998,7 +6018,7 @@ async function compileForRenderInWorker(projectDir, htmlPath, downloadDir, optio
|
|
|
5998
6018
|
// src/services/render/stages/compileStage.ts
|
|
5999
6019
|
function animatedGifCacheDir(extractCacheDir) {
|
|
6000
6020
|
try {
|
|
6001
|
-
const root = extractCacheDir && privateCacheRoot(extractCacheDir);
|
|
6021
|
+
const root = extractCacheDir && privateCacheRoot(resolve7(extractCacheDir));
|
|
6002
6022
|
return root ? join11(root, "animated-gif") : void 0;
|
|
6003
6023
|
} catch {
|
|
6004
6024
|
return void 0;
|
|
@@ -6205,7 +6225,7 @@ async function runCompileStage(input) {
|
|
|
6205
6225
|
// src/services/render/stages/probeStage.ts
|
|
6206
6226
|
import { createHash as createHash6 } from "node:crypto";
|
|
6207
6227
|
import { basename as basename4, join as join12 } from "node:path";
|
|
6208
|
-
import { parseHTML as parseHTML6 } from "linkedom";
|
|
6228
|
+
import { parseHTML as parseHTML6 } from "@hyperframes/parsers/linkedom";
|
|
6209
6229
|
import {
|
|
6210
6230
|
closeCaptureSession as closeCaptureSession4,
|
|
6211
6231
|
compositionRequiresWebGpu,
|
|
@@ -7642,7 +7662,7 @@ import {
|
|
|
7642
7662
|
} from "@hyperframes/engine";
|
|
7643
7663
|
|
|
7644
7664
|
// src/services/render/audioPadTrim.ts
|
|
7645
|
-
import { localContainerInputArgs } from "@hyperframes/parsers/ff-binaries";
|
|
7665
|
+
import { ffmpegCwd as ffmpegCwd2, localContainerInputArgs } from "@hyperframes/parsers/ff-binaries";
|
|
7646
7666
|
import { spawn } from "node:child_process";
|
|
7647
7667
|
import { dirname as dirname9, join as join14 } from "node:path";
|
|
7648
7668
|
import {
|
|
@@ -8113,6 +8133,7 @@ async function spawnFfprobeJson(args, env, signal) {
|
|
|
8113
8133
|
const proc = spawn(getFfprobeBinary(), args, {
|
|
8114
8134
|
...env && { env },
|
|
8115
8135
|
stdio: ["ignore", "pipe", "pipe"],
|
|
8136
|
+
cwd: ffmpegCwd2(),
|
|
8116
8137
|
windowsHide: true
|
|
8117
8138
|
});
|
|
8118
8139
|
trackChildProcess(proc);
|
|
@@ -8237,10 +8258,15 @@ function runAudioStage(input) {
|
|
|
8237
8258
|
async function runAudioStageScoped(input) {
|
|
8238
8259
|
const stageStart = Date.now();
|
|
8239
8260
|
const pcmSourcePath = join16(input.workDir, "audio-source.wav");
|
|
8240
|
-
const
|
|
8261
|
+
const seconds = (frames) => frames * input.fps.den / input.fps.num;
|
|
8262
|
+
const duration = seconds(input.totalFrames);
|
|
8263
|
+
const window2 = input.frameWindow && {
|
|
8264
|
+
startSeconds: seconds(input.frameWindow.startFrame),
|
|
8265
|
+
durationSeconds: seconds(input.frameWindow.endFrame - input.frameWindow.startFrame)
|
|
8266
|
+
};
|
|
8241
8267
|
let deliverySourcePath;
|
|
8242
8268
|
try {
|
|
8243
|
-
const result = await mixAudioForDelivery(input, duration, pcmSourcePath);
|
|
8269
|
+
const result = await mixAudioForDelivery(input, duration, pcmSourcePath, window2);
|
|
8244
8270
|
let audioLoweredDb;
|
|
8245
8271
|
if (result.hasAudio) {
|
|
8246
8272
|
const guardStart = Date.now();
|
|
@@ -8248,7 +8274,7 @@ async function runAudioStageScoped(input) {
|
|
|
8248
8274
|
input,
|
|
8249
8275
|
result.audioOutputPath,
|
|
8250
8276
|
pcmSourcePath,
|
|
8251
|
-
duration
|
|
8277
|
+
window2?.durationSeconds ?? duration
|
|
8252
8278
|
);
|
|
8253
8279
|
audioLoweredDb = guard.loweredDb;
|
|
8254
8280
|
input.log?.info("[audio] phases", { ...result.audioPhaseMs, guard: Date.now() - guardStart });
|
|
@@ -8286,7 +8312,7 @@ async function guardDeliveryPeaks(input, audioPath, sourcePath, duration) {
|
|
|
8286
8312
|
if (!peak.success) throw encoderFailureError("Audio true-peak check failed", peak);
|
|
8287
8313
|
return { loweredDb: peak.loweredDb, sourceStale: peak.sourceStale };
|
|
8288
8314
|
}
|
|
8289
|
-
async function mixAudioForDelivery(input, duration, pcmSourcePath) {
|
|
8315
|
+
async function mixAudioForDelivery(input, duration, pcmSourcePath, window2) {
|
|
8290
8316
|
const {
|
|
8291
8317
|
projectDir,
|
|
8292
8318
|
workDir,
|
|
@@ -8323,6 +8349,7 @@ async function mixAudioForDelivery(input, duration, pcmSourcePath) {
|
|
|
8323
8349
|
urlByAbsentLocalPath,
|
|
8324
8350
|
audioSidecarUrlByLocalPath,
|
|
8325
8351
|
keepEncoderInputAt: pcmSourcePath,
|
|
8352
|
+
window: window2,
|
|
8326
8353
|
assetRoots: input.allowOutsideProjectAssets ? void 0 : mediaAssetRoots(projectDir, compiledDir)
|
|
8327
8354
|
},
|
|
8328
8355
|
compiledDir
|
|
@@ -8394,6 +8421,7 @@ import {
|
|
|
8394
8421
|
completeDeferredDrawElementInit as completeDeferredDrawElementInit3,
|
|
8395
8422
|
createCaptureSession as createCaptureSession5,
|
|
8396
8423
|
getCapturePerfSummary as getCapturePerfSummary3,
|
|
8424
|
+
retainCapturePerf as retainCapturePerf4,
|
|
8397
8425
|
initializeSession as initializeSession5,
|
|
8398
8426
|
prepareCaptureSessionForReuse as prepareCaptureSessionForReuse3
|
|
8399
8427
|
} from "@hyperframes/engine";
|
|
@@ -8711,7 +8739,7 @@ async function captureSessionFrames(session, { input, rangeStart, rangeEnd, resu
|
|
|
8711
8739
|
assertNotAborted();
|
|
8712
8740
|
const absoluteIdx = rangeStart + i;
|
|
8713
8741
|
const time = absoluteIdx * job.config.fps.den / job.config.fps.num;
|
|
8714
|
-
const { encodeResult } = await captureFrameToBufferPipelined2(session,
|
|
8742
|
+
const { encodeResult } = await captureFrameToBufferPipelined2(session, absoluteIdx, time);
|
|
8715
8743
|
await drainPrev();
|
|
8716
8744
|
prev = { fileIndex: i, encodeResult };
|
|
8717
8745
|
}
|
|
@@ -8721,7 +8749,7 @@ async function captureSessionFrames(session, { input, rangeStart, rangeEnd, resu
|
|
|
8721
8749
|
assertNotAborted();
|
|
8722
8750
|
const absoluteIdx = rangeStart + i;
|
|
8723
8751
|
const time = absoluteIdx * job.config.fps.den / job.config.fps.num;
|
|
8724
|
-
await captureFrame(session,
|
|
8752
|
+
await captureFrame(session, absoluteIdx, time, i);
|
|
8725
8753
|
reportFrame(i);
|
|
8726
8754
|
}
|
|
8727
8755
|
}
|
|
@@ -8736,7 +8764,7 @@ async function captureSessionFrames(session, { input, rangeStart, rangeEnd, resu
|
|
|
8736
8764
|
},
|
|
8737
8765
|
false
|
|
8738
8766
|
);
|
|
8739
|
-
dedupPerfs
|
|
8767
|
+
retainCapturePerf4(dedupPerfs, getCapturePerfSummary3(session));
|
|
8740
8768
|
}
|
|
8741
8769
|
|
|
8742
8770
|
// src/services/render/stages/captureHdrStage.ts
|
|
@@ -9002,7 +9030,7 @@ function encodeWhileCapturing(input, totalFrames, captureBudget) {
|
|
|
9002
9030
|
const stream = await encoder;
|
|
9003
9031
|
for (let next = 0; next < totalFrames; next++) {
|
|
9004
9032
|
while (!landed.has(next) && !captureDone && !signal.aborted) {
|
|
9005
|
-
await new Promise((
|
|
9033
|
+
await new Promise((resolve11) => wake = resolve11);
|
|
9006
9034
|
}
|
|
9007
9035
|
if (signal.aborted) return;
|
|
9008
9036
|
const mergedPath = join18(input.framesDir, formatCaptureFrameName(next, "jpg"));
|
|
@@ -10227,7 +10255,7 @@ async function readPlanReferenceBackground(input) {
|
|
|
10227
10255
|
|
|
10228
10256
|
// src/services/render/stages/freezePlan.ts
|
|
10229
10257
|
import { existsSync as existsSync18, mkdirSync as mkdirSync7, readFileSync as readFileSync8, readdirSync as readdirSync5, writeFileSync as writeFileSync6 } from "node:fs";
|
|
10230
|
-
import { join as join24, relative as relative5, resolve as
|
|
10258
|
+
import { join as join24, relative as relative5, resolve as resolve9 } from "node:path";
|
|
10231
10259
|
import {
|
|
10232
10260
|
REFERENCE_BACKGROUND_FIELD,
|
|
10233
10261
|
referenceBackgroundResult as referenceBackgroundResult3
|
|
@@ -10441,7 +10469,7 @@ function stripUndefined(value) {
|
|
|
10441
10469
|
}
|
|
10442
10470
|
function listPlanFiles(planDir) {
|
|
10443
10471
|
const results = [];
|
|
10444
|
-
const rootResolved =
|
|
10472
|
+
const rootResolved = resolve9(planDir);
|
|
10445
10473
|
function walk(dir) {
|
|
10446
10474
|
const entries = readdirSync5(dir, { withFileTypes: true });
|
|
10447
10475
|
for (const entry of entries) {
|
|
@@ -12248,7 +12276,7 @@ import {
|
|
|
12248
12276
|
writeFileSync as writeFileSync10
|
|
12249
12277
|
} from "node:fs";
|
|
12250
12278
|
import { tmpdir } from "node:os";
|
|
12251
|
-
import { dirname as dirname16, isAbsolute as isAbsolute5, join as join31, relative as relative8, resolve as
|
|
12279
|
+
import { dirname as dirname16, isAbsolute as isAbsolute5, join as join31, relative as relative8, resolve as resolve10, sep as sep5 } from "node:path";
|
|
12252
12280
|
import { DISTRIBUTED_FPS, isDistributedFps } from "@hyperframes/core";
|
|
12253
12281
|
import {
|
|
12254
12282
|
createFrameLookupTable as createFrameLookupTable5,
|
|
@@ -12407,7 +12435,7 @@ function assertSafeRelativePath(path) {
|
|
|
12407
12435
|
}
|
|
12408
12436
|
function listFiles(root) {
|
|
12409
12437
|
const files = [];
|
|
12410
|
-
const rootResolved =
|
|
12438
|
+
const rootResolved = resolve10(root);
|
|
12411
12439
|
function walk(dir) {
|
|
12412
12440
|
for (const entry of readdirSync7(dir, { withFileTypes: true })) {
|
|
12413
12441
|
const absolutePath = join31(dir, entry.name);
|
|
@@ -12453,8 +12481,8 @@ function isExtractionCacheCompleteSentinelPath(path) {
|
|
|
12453
12481
|
return segments.length === 3 && segments[0] === "video-frames" && segments[1] !== "" && segments[2] === EXTRACTION_CACHE_COMPLETE_SENTINEL;
|
|
12454
12482
|
}
|
|
12455
12483
|
function resolveExtractedVideoOutputDir(planDir, videoId) {
|
|
12456
|
-
const videoRoot =
|
|
12457
|
-
const outputDir =
|
|
12484
|
+
const videoRoot = resolve10(planDir, "video-frames");
|
|
12485
|
+
const outputDir = resolve10(videoRoot, mediaIdPathSegment4(videoId));
|
|
12458
12486
|
if (outputDir === videoRoot || !outputDir.startsWith(`${videoRoot}${sep5}`)) {
|
|
12459
12487
|
throw new PlanV2IntegrityError(`unsafe extracted video id: ${JSON.stringify(videoId)}`);
|
|
12460
12488
|
}
|
|
@@ -12615,7 +12643,7 @@ function collectChunkVideoDependencies(input) {
|
|
|
12615
12643
|
for (let frame = chunk.startFrame; frame < chunk.endFrame; frame++) {
|
|
12616
12644
|
const globalTime = frame * input.fpsDen / input.fpsNum;
|
|
12617
12645
|
for (const [videoId, payload] of input.table.getActiveFramePayloads(globalTime)) {
|
|
12618
|
-
const path = input.deferredSources.get(videoId) ?? relative8(
|
|
12646
|
+
const path = input.deferredSources.get(videoId) ?? relative8(resolve10(input.executionPlanDir), payload.framePath).split(sep5).join("/");
|
|
12619
12647
|
assertSafeRelativePath(path);
|
|
12620
12648
|
const indexes = mutable.get(path) ?? /* @__PURE__ */ new Set();
|
|
12621
12649
|
indexes.add(chunk.index);
|
|
@@ -13806,8 +13834,8 @@ async function renderChunk(planDir, chunkIndex, outputChunkPath, options) {
|
|
|
13806
13834
|
const verifyInWorker = chunkWorkerCount > 1 && !forceScreenshotForChunk;
|
|
13807
13835
|
let boxesMeasured;
|
|
13808
13836
|
let boxesFailed;
|
|
13809
|
-
const boxesReady = new Promise((
|
|
13810
|
-
boxesMeasured =
|
|
13837
|
+
const boxesReady = new Promise((resolve11, reject) => {
|
|
13838
|
+
boxesMeasured = resolve11;
|
|
13811
13839
|
boxesFailed = reject;
|
|
13812
13840
|
});
|
|
13813
13841
|
boxesReady.catch(() => {
|
|
@@ -14525,10 +14553,10 @@ function validateIntDimension(field, value) {
|
|
|
14525
14553
|
import { closeSync as closeSync5, openSync as openSync5, readdirSync as readdirSync10, readSync as readSync4, realpathSync as realpathSync2, statSync as statSync11 } from "node:fs";
|
|
14526
14554
|
import { createHash as createHash9 } from "node:crypto";
|
|
14527
14555
|
import { join as join35, sep as sep6 } from "node:path";
|
|
14528
|
-
import { isPrivateFileUnder as
|
|
14556
|
+
import { isPrivateFileUnder as isPrivateFileUnder4, isStudioPrivatePath as isStudioPrivatePath4 } from "@hyperframes/core/safe-path";
|
|
14529
14557
|
var SITE_ID_SCHEME = "site-v2\0";
|
|
14530
14558
|
var READ_CHUNK_BYTES = 256 * 1024;
|
|
14531
|
-
var isPrivateSitePath = (relPath) =>
|
|
14559
|
+
var isPrivateSitePath = (relPath) => isStudioPrivatePath4(relPath);
|
|
14532
14560
|
function statEntry(full, relPath) {
|
|
14533
14561
|
try {
|
|
14534
14562
|
return statSync11(full);
|
|
@@ -14542,7 +14570,7 @@ function listSiteFiles(projectDir, onPrivate, onOutside = () => {
|
|
|
14542
14570
|
const root = realpathSync2(projectDir);
|
|
14543
14571
|
const ancestors = /* @__PURE__ */ new Set([root]);
|
|
14544
14572
|
function visit(full, relPath) {
|
|
14545
|
-
if (
|
|
14573
|
+
if (isPrivateFileUnder4(projectDir, full, isStudioPrivatePath4)) return void onPrivate?.(relPath);
|
|
14546
14574
|
const stat = statEntry(full, relPath);
|
|
14547
14575
|
if (!stat.isFile() && !stat.isDirectory()) return;
|
|
14548
14576
|
if (onOutside !== "include" && outsideFolder(root, realpathSync2(full))) {
|