@hyperframes/producer 0.9.41 → 0.9.42
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 +174 -108
- package/dist/hyperframe.manifest.json +1 -1
- package/dist/hyperframe.runtime.iife.js +65 -65
- package/dist/index.js +194 -128
- package/dist/public-server.js +173 -109
- package/dist/services/assetMediaType.d.ts +1 -0
- package/dist/services/htmlCompiler.d.ts +1 -1
- package/dist/utils/paths.d.ts +6 -0
- package/package.json +10 -10
package/dist/index.js
CHANGED
|
@@ -13,7 +13,7 @@ import {
|
|
|
13
13
|
mkdirSync as mkdirSync12,
|
|
14
14
|
readdirSync as readdirSync6,
|
|
15
15
|
rmSync as rmSync12,
|
|
16
|
-
statSync as
|
|
16
|
+
statSync as statSync10,
|
|
17
17
|
writeFileSync as writeFileSync7,
|
|
18
18
|
copyFileSync as copyFileSync5,
|
|
19
19
|
appendFileSync
|
|
@@ -79,7 +79,7 @@ import { settleOnBrowserSafePort } from "@hyperframes/engine";
|
|
|
79
79
|
import {
|
|
80
80
|
existsSync as existsSync2,
|
|
81
81
|
realpathSync,
|
|
82
|
-
statSync,
|
|
82
|
+
statSync as statSync2,
|
|
83
83
|
createReadStream,
|
|
84
84
|
openSync,
|
|
85
85
|
fstatSync,
|
|
@@ -89,7 +89,7 @@ import {
|
|
|
89
89
|
} from "node:fs";
|
|
90
90
|
import { promisify } from "node:util";
|
|
91
91
|
import { Readable } from "node:stream";
|
|
92
|
-
import { join, extname, resolve as resolve2, sep } from "node:path";
|
|
92
|
+
import { join as join2, extname, resolve as resolve2, sep as sep2 } from "node:path";
|
|
93
93
|
import { injectScriptsAtHeadStart, injectScriptsIntoHtml } from "@hyperframes/core/compiler";
|
|
94
94
|
import { fpsToNumber } from "@hyperframes/core";
|
|
95
95
|
import { stripSdrPngColourTags } from "@hyperframes/core/compiler/png-colour-tags";
|
|
@@ -210,12 +210,86 @@ var defaultLogger = createConsoleLogger(
|
|
|
210
210
|
process.env.HF_DEBUG_RENDER === "1" ? "debug" : "info"
|
|
211
211
|
);
|
|
212
212
|
|
|
213
|
+
// src/utils/paths.ts
|
|
214
|
+
import {
|
|
215
|
+
basename,
|
|
216
|
+
join,
|
|
217
|
+
sep,
|
|
218
|
+
resolve as nodeResolve,
|
|
219
|
+
relative as nodeRelative,
|
|
220
|
+
isAbsolute as nodeIsAbsolute
|
|
221
|
+
} from "node:path";
|
|
222
|
+
import { statSync } from "node:fs";
|
|
223
|
+
import { fileURLToPath as fileURLToPath2 } from "node:url";
|
|
224
|
+
import { isSafePath } from "@hyperframes/core/safe-path";
|
|
225
|
+
import {
|
|
226
|
+
isCopiedOutsideFileType,
|
|
227
|
+
isPrivateOutsideFile,
|
|
228
|
+
leftOutWarning,
|
|
229
|
+
linksOutside
|
|
230
|
+
} from "@hyperframes/studio-server/outside-file";
|
|
231
|
+
import { realFilePath } from "@hyperframes/studio-server/safe-path";
|
|
232
|
+
var DEFAULT_RENDERS_DIR = process.env.PRODUCER_RENDERS_DIR ?? // fileURLToPath (not URL.pathname): on Windows .pathname is "/D:/..." which
|
|
233
|
+
// resolves to a bogus renders dir.
|
|
234
|
+
nodeResolve(fileURLToPath2(import.meta.url), "../../..", "renders");
|
|
235
|
+
var LEADING_PARENT_SEGMENT_RE = /^\.\.(?:[\\/]|$)/;
|
|
236
|
+
function isPathInside(childPath, parentPath, options = {}) {
|
|
237
|
+
const resolvePath = options.pathModule?.resolve ?? nodeResolve;
|
|
238
|
+
const relativePath = options.pathModule?.relative ?? nodeRelative;
|
|
239
|
+
const isPathAbsolute = options.pathModule?.isAbsolute ?? nodeIsAbsolute;
|
|
240
|
+
const absChild = resolvePath(childPath);
|
|
241
|
+
const absParent = resolvePath(parentPath);
|
|
242
|
+
if (absChild === absParent) return true;
|
|
243
|
+
const rel = relativePath(absParent, absChild);
|
|
244
|
+
return rel !== "" && !LEADING_PARENT_SEGMENT_RE.test(rel) && !isPathAbsolute(rel);
|
|
245
|
+
}
|
|
246
|
+
function escapesAssetRoot(path, assetRoot) {
|
|
247
|
+
return assetRoot !== void 0 && !isSafePath(assetRoot, path);
|
|
248
|
+
}
|
|
249
|
+
function outsideAssetRefusal(projectDir, path) {
|
|
250
|
+
if (!linksOutside(projectDir, path)) return null;
|
|
251
|
+
if (isPrivateOutsideFile(projectDir, path)) return "blocklisted";
|
|
252
|
+
const folder = statSync(path, { throwIfNoEntry: false })?.isDirectory();
|
|
253
|
+
return folder || isCopiedOutsideFileType(path) ? null : "file_type";
|
|
254
|
+
}
|
|
255
|
+
var leftOutOfRender = (file, reference, reason) => leftOutWarning(file, reference, reason, "render");
|
|
256
|
+
function refusesOutsideLink(projectDir, path, warn) {
|
|
257
|
+
const refusal = outsideAssetRefusal(projectDir, path);
|
|
258
|
+
if (!refusal) return false;
|
|
259
|
+
const file = nodeRelative(projectDir, path).split(sep).join("/");
|
|
260
|
+
warn(leftOutOfRender(file, realFilePath(path), refusal));
|
|
261
|
+
return true;
|
|
262
|
+
}
|
|
263
|
+
function toExternalAssetKey(absPath) {
|
|
264
|
+
if (absPath.startsWith("hf-ext/")) return absPath;
|
|
265
|
+
let normalised = absPath.replace(/\\/g, "/");
|
|
266
|
+
normalised = normalised.replace(/^\/\/\?\/UNC\//i, "//");
|
|
267
|
+
normalised = normalised.replace(/^\/\/\?\//, "");
|
|
268
|
+
normalised = normalised.replace(/^\/\/([^/]+)\//, "unc/$1/");
|
|
269
|
+
normalised = normalised.replace(/^\/+/, "");
|
|
270
|
+
normalised = normalised.replace(/^([A-Za-z]):\/?/, "$1/");
|
|
271
|
+
return "hf-ext/" + normalised;
|
|
272
|
+
}
|
|
273
|
+
function formatCaptureFrameName(index, ext) {
|
|
274
|
+
return `frame_${String(index).padStart(6, "0")}.${ext}`;
|
|
275
|
+
}
|
|
276
|
+
function formatExportFrameName(index, ext) {
|
|
277
|
+
return `frame_${String(index + 1).padStart(6, "0")}.${ext}`;
|
|
278
|
+
}
|
|
279
|
+
function resolveRenderPaths(projectDir, outputPath, rendersDir = DEFAULT_RENDERS_DIR) {
|
|
280
|
+
const absoluteProjectDir = nodeResolve(projectDir);
|
|
281
|
+
const projectName = basename(absoluteProjectDir);
|
|
282
|
+
const resolvedOutputPath = outputPath ?? join(rendersDir, `${projectName}.mp4`);
|
|
283
|
+
const absoluteOutputPath = nodeResolve(resolvedOutputPath);
|
|
284
|
+
return { absoluteProjectDir, absoluteOutputPath };
|
|
285
|
+
}
|
|
286
|
+
|
|
213
287
|
// src/services/fileServer.ts
|
|
214
288
|
var readFileAsync = promisify(readFile);
|
|
215
|
-
function
|
|
289
|
+
function isPathInside2(child3, parent, options = {}) {
|
|
216
290
|
const { resolveSymlinks = false, pathModule } = options;
|
|
217
291
|
const resolveFn = pathModule?.resolve ?? resolve2;
|
|
218
|
-
const separator = pathModule?.sep ??
|
|
292
|
+
const separator = pathModule?.sep ?? sep2;
|
|
219
293
|
const resolvedChild = resolveFn(child3);
|
|
220
294
|
const resolvedParent = resolveFn(parent);
|
|
221
295
|
const normalizedChild = resolveSymlinks && existsSync2(resolvedChild) ? realpathSync.native(resolvedChild) : resolvedChild;
|
|
@@ -742,7 +816,7 @@ function openRegularFile(filePath) {
|
|
|
742
816
|
} catch (error) {
|
|
743
817
|
if (error instanceof Error && "code" in error && (error.code === "ENOENT" || error.code === "ENOTDIR"))
|
|
744
818
|
return null;
|
|
745
|
-
if (!
|
|
819
|
+
if (!statSync2(filePath, { throwIfNoEntry: false })?.isFile()) return null;
|
|
746
820
|
throw error;
|
|
747
821
|
}
|
|
748
822
|
let accepted = false;
|
|
@@ -771,6 +845,7 @@ function createFileServer(options) {
|
|
|
771
845
|
const headScripts = options.headScripts ?? [getVerifiedHyperframeRuntimeSource()];
|
|
772
846
|
const bodyScripts = options.bodyScripts ?? [buildRenderModeScript(options.fps), HF_BRIDGE_SCRIPT];
|
|
773
847
|
const app = new Hono();
|
|
848
|
+
const warnLeftOut = (line) => console.warn(`[FileServer] ${line}`);
|
|
774
849
|
app.get("/*", async (c) => {
|
|
775
850
|
let requestPath = c.req.path;
|
|
776
851
|
if (requestPath === "/") requestPath = "/index.html";
|
|
@@ -783,9 +858,12 @@ function createFileServer(options) {
|
|
|
783
858
|
}).join("/");
|
|
784
859
|
let file = null;
|
|
785
860
|
for (const root of compiledDir ? [compiledDir, projectDir] : [projectDir]) {
|
|
786
|
-
const candidate =
|
|
861
|
+
const candidate = join2(root, relativePath);
|
|
787
862
|
const resolveSymlinks = !allowOutsideProjectAssets && root !== compiledDir;
|
|
788
|
-
if (
|
|
863
|
+
if (!isPathInside2(candidate, root, { resolveSymlinks })) continue;
|
|
864
|
+
const checksLinks = allowOutsideProjectAssets && root !== compiledDir;
|
|
865
|
+
if (checksLinks && refusesOutsideLink(root, candidate, warnLeftOut)) continue;
|
|
866
|
+
file = openRegularFile(candidate);
|
|
789
867
|
if (file) break;
|
|
790
868
|
}
|
|
791
869
|
if (!file) {
|
|
@@ -1034,59 +1112,6 @@ import {
|
|
|
1034
1112
|
import {
|
|
1035
1113
|
mediaIdPathSegment
|
|
1036
1114
|
} from "@hyperframes/engine";
|
|
1037
|
-
|
|
1038
|
-
// src/utils/paths.ts
|
|
1039
|
-
import {
|
|
1040
|
-
basename,
|
|
1041
|
-
join as join2,
|
|
1042
|
-
resolve as nodeResolve,
|
|
1043
|
-
relative as nodeRelative,
|
|
1044
|
-
isAbsolute as nodeIsAbsolute
|
|
1045
|
-
} from "node:path";
|
|
1046
|
-
import { fileURLToPath as fileURLToPath2 } from "node:url";
|
|
1047
|
-
import { isSafePath } from "@hyperframes/core/safe-path";
|
|
1048
|
-
var DEFAULT_RENDERS_DIR = process.env.PRODUCER_RENDERS_DIR ?? // fileURLToPath (not URL.pathname): on Windows .pathname is "/D:/..." which
|
|
1049
|
-
// resolves to a bogus renders dir.
|
|
1050
|
-
nodeResolve(fileURLToPath2(import.meta.url), "../../..", "renders");
|
|
1051
|
-
var LEADING_PARENT_SEGMENT_RE = /^\.\.(?:[\\/]|$)/;
|
|
1052
|
-
function isPathInside2(childPath, parentPath, options = {}) {
|
|
1053
|
-
const resolvePath = options.pathModule?.resolve ?? nodeResolve;
|
|
1054
|
-
const relativePath = options.pathModule?.relative ?? nodeRelative;
|
|
1055
|
-
const isPathAbsolute = options.pathModule?.isAbsolute ?? nodeIsAbsolute;
|
|
1056
|
-
const absChild = resolvePath(childPath);
|
|
1057
|
-
const absParent = resolvePath(parentPath);
|
|
1058
|
-
if (absChild === absParent) return true;
|
|
1059
|
-
const rel = relativePath(absParent, absChild);
|
|
1060
|
-
return rel !== "" && !LEADING_PARENT_SEGMENT_RE.test(rel) && !isPathAbsolute(rel);
|
|
1061
|
-
}
|
|
1062
|
-
function escapesAssetRoot(path, assetRoot) {
|
|
1063
|
-
return assetRoot !== void 0 && !isSafePath(assetRoot, path);
|
|
1064
|
-
}
|
|
1065
|
-
function toExternalAssetKey(absPath) {
|
|
1066
|
-
if (absPath.startsWith("hf-ext/")) return absPath;
|
|
1067
|
-
let normalised = absPath.replace(/\\/g, "/");
|
|
1068
|
-
normalised = normalised.replace(/^\/\/\?\/UNC\//i, "//");
|
|
1069
|
-
normalised = normalised.replace(/^\/\/\?\//, "");
|
|
1070
|
-
normalised = normalised.replace(/^\/\/([^/]+)\//, "unc/$1/");
|
|
1071
|
-
normalised = normalised.replace(/^\/+/, "");
|
|
1072
|
-
normalised = normalised.replace(/^([A-Za-z]):\/?/, "$1/");
|
|
1073
|
-
return "hf-ext/" + normalised;
|
|
1074
|
-
}
|
|
1075
|
-
function formatCaptureFrameName(index, ext) {
|
|
1076
|
-
return `frame_${String(index).padStart(6, "0")}.${ext}`;
|
|
1077
|
-
}
|
|
1078
|
-
function formatExportFrameName(index, ext) {
|
|
1079
|
-
return `frame_${String(index + 1).padStart(6, "0")}.${ext}`;
|
|
1080
|
-
}
|
|
1081
|
-
function resolveRenderPaths(projectDir, outputPath, rendersDir = DEFAULT_RENDERS_DIR) {
|
|
1082
|
-
const absoluteProjectDir = nodeResolve(projectDir);
|
|
1083
|
-
const projectName = basename(absoluteProjectDir);
|
|
1084
|
-
const resolvedOutputPath = outputPath ?? join2(rendersDir, `${projectName}.mp4`);
|
|
1085
|
-
const absoluteOutputPath = nodeResolve(resolvedOutputPath);
|
|
1086
|
-
return { absoluteProjectDir, absoluteOutputPath };
|
|
1087
|
-
}
|
|
1088
|
-
|
|
1089
|
-
// src/services/render/shared.ts
|
|
1090
1115
|
var BROWSER_MEDIA_EPSILON = 1e-4;
|
|
1091
1116
|
function resolveBrowserMediaEnd(start, end, duration) {
|
|
1092
1117
|
return Number.isFinite(duration) && duration > 0 ? start + duration : end;
|
|
@@ -1123,7 +1148,7 @@ function writeCompiledArtifacts(compiled, workDir, includeSummary) {
|
|
|
1123
1148
|
writeFileSync(join3(compileDir, "index.html"), compiled.html, "utf-8");
|
|
1124
1149
|
for (const [srcPath, html] of compiled.subCompositions) {
|
|
1125
1150
|
const outPath = join3(compileDir, srcPath);
|
|
1126
|
-
if (!
|
|
1151
|
+
if (!isPathInside(outPath, compileDir)) {
|
|
1127
1152
|
console.warn(`[Render] Skipping sub-composition with unsafe path: ${srcPath}`);
|
|
1128
1153
|
continue;
|
|
1129
1154
|
}
|
|
@@ -1132,7 +1157,7 @@ function writeCompiledArtifacts(compiled, workDir, includeSummary) {
|
|
|
1132
1157
|
}
|
|
1133
1158
|
for (const [relativePath, absolutePath] of compiled.externalAssets) {
|
|
1134
1159
|
const outPath = resolve3(join3(compileDir, relativePath));
|
|
1135
|
-
if (!
|
|
1160
|
+
if (!isPathInside(outPath, compileDir)) {
|
|
1136
1161
|
console.warn(`[Render] Skipping external asset with unsafe path: ${relativePath}`);
|
|
1137
1162
|
continue;
|
|
1138
1163
|
}
|
|
@@ -1394,7 +1419,7 @@ function materializeExtractedFramesForCompiledDir(extracted, compiledDir, option
|
|
|
1394
1419
|
const compiledFrameRoot = pathModule.join(resolvedCompiledDir, "__hyperframes_video_frames");
|
|
1395
1420
|
for (const ext of extracted) {
|
|
1396
1421
|
const resolvedOut = pathModule.resolve(ext.outputDir);
|
|
1397
|
-
if (
|
|
1422
|
+
if (isPathInside(resolvedOut, resolvedCompiledDir, { pathModule })) continue;
|
|
1398
1423
|
const linkPath = pathModule.join(compiledFrameRoot, mediaIdPathSegment(ext.videoId));
|
|
1399
1424
|
if (!fileSystem.existsSync(linkPath)) {
|
|
1400
1425
|
fileSystem.mkdirSync(pathModule.dirname(linkPath), { recursive: true });
|
|
@@ -2125,7 +2150,7 @@ function replanAfterFailure(plan2, failure) {
|
|
|
2125
2150
|
}
|
|
2126
2151
|
|
|
2127
2152
|
// src/services/render/stages/captureSegmentedStage.ts
|
|
2128
|
-
import { existsSync as existsSync6, mkdirSync as mkdirSync3, rmSync as rmSync6, statSync as
|
|
2153
|
+
import { existsSync as existsSync6, mkdirSync as mkdirSync3, rmSync as rmSync6, statSync as statSync4 } from "node:fs";
|
|
2129
2154
|
import { join as join9 } from "node:path";
|
|
2130
2155
|
import {
|
|
2131
2156
|
captureFrameToBuffer as captureFrameToBuffer2,
|
|
@@ -3020,7 +3045,7 @@ async function compositeHdrFrame(ctx, canvas, time, fullStacking, elementFilter,
|
|
|
3020
3045
|
}
|
|
3021
3046
|
|
|
3022
3047
|
// src/services/render/stages/captureHdrResources.ts
|
|
3023
|
-
import { mkdirSync as mkdirSync2, readFileSync as readFileSync3, rmSync as rmSync5, statSync as
|
|
3048
|
+
import { mkdirSync as mkdirSync2, readFileSync as readFileSync3, rmSync as rmSync5, statSync as statSync3, statfsSync } from "node:fs";
|
|
3024
3049
|
import {
|
|
3025
3050
|
decodePngToRgb48le,
|
|
3026
3051
|
extractMediaMetadata as extractMediaMetadata2,
|
|
@@ -3435,7 +3460,7 @@ async function extractHdrVideoFrames(args) {
|
|
|
3435
3460
|
failureReason: result.failureReason
|
|
3436
3461
|
});
|
|
3437
3462
|
}
|
|
3438
|
-
return Math.min(Math.floor(
|
|
3463
|
+
return Math.min(Math.floor(statSync3(spec.path).size / frameSize), spec.frames);
|
|
3439
3464
|
}
|
|
3440
3465
|
});
|
|
3441
3466
|
const first = await windows.lease(0);
|
|
@@ -4730,7 +4755,7 @@ async function captureSegmentToEncoder(ctx, segment) {
|
|
|
4730
4755
|
path: segmentPath,
|
|
4731
4756
|
// Recorded so resume can prove the file on disk is the one that
|
|
4732
4757
|
// finished; absent only in unit tests, whose fake encoder writes none.
|
|
4733
|
-
bytes: existsSync6(segmentPath) ?
|
|
4758
|
+
bytes: existsSync6(segmentPath) ? statSync4(segmentPath).size : 0
|
|
4734
4759
|
});
|
|
4735
4760
|
return encodeResult;
|
|
4736
4761
|
} finally {
|
|
@@ -5765,7 +5790,7 @@ function createSegmentVideoFrames(input) {
|
|
|
5765
5790
|
}
|
|
5766
5791
|
|
|
5767
5792
|
// src/services/render/videoFrameWindow.ts
|
|
5768
|
-
import { readdirSync as readdirSync3, statSync as
|
|
5793
|
+
import { readdirSync as readdirSync3, statSync as statSync5 } from "node:fs";
|
|
5769
5794
|
import { join as join13 } from "node:path";
|
|
5770
5795
|
function shouldWindowVideoFrames(args) {
|
|
5771
5796
|
return args.segmented && args.env.HF_VIDEO_FRAME_WINDOW?.trim().toLowerCase() === "true";
|
|
@@ -5781,7 +5806,7 @@ function directoryBytes(path) {
|
|
|
5781
5806
|
for (const entry of entries) {
|
|
5782
5807
|
const child3 = join13(path, entry.name);
|
|
5783
5808
|
try {
|
|
5784
|
-
bytes += entry.isDirectory() ? directoryBytes(child3) :
|
|
5809
|
+
bytes += entry.isDirectory() ? directoryBytes(child3) : statSync5(child3).size;
|
|
5785
5810
|
} catch {
|
|
5786
5811
|
}
|
|
5787
5812
|
}
|
|
@@ -5810,7 +5835,7 @@ function trackSegmentFramePeak(frames, rootDir, onPeak) {
|
|
|
5810
5835
|
|
|
5811
5836
|
// src/services/render/segmentManifest.ts
|
|
5812
5837
|
import { createHash as createHash2 } from "node:crypto";
|
|
5813
|
-
import { existsSync as existsSync7, mkdirSync as mkdirSync6, readFileSync as readFileSync4, statSync as
|
|
5838
|
+
import { existsSync as existsSync7, mkdirSync as mkdirSync6, readFileSync as readFileSync4, statSync as statSync6, writeFileSync as writeFileSync3 } from "node:fs";
|
|
5814
5839
|
import { join as join14 } from "node:path";
|
|
5815
5840
|
import { renameWithRetry as renameWithRetry2 } from "@hyperframes/engine";
|
|
5816
5841
|
var MANIFEST_FILENAME = "segments.json";
|
|
@@ -5888,7 +5913,7 @@ async function validateCompletedSegments(manifest, expectedHash, probeFrames) {
|
|
|
5888
5913
|
if (manifest.planHash !== expectedHash) return ok;
|
|
5889
5914
|
for (const entry of manifest.completed) {
|
|
5890
5915
|
if (!existsSync7(entry.path)) continue;
|
|
5891
|
-
const size =
|
|
5916
|
+
const size = statSync6(entry.path).size;
|
|
5892
5917
|
if (size <= 0 || size !== entry.bytes) continue;
|
|
5893
5918
|
const frames = await probeFrames(entry.path);
|
|
5894
5919
|
if (frames !== entry.endFrame - entry.startFrame) continue;
|
|
@@ -6486,7 +6511,7 @@ import { readTextFile as readTextFile2 } from "@hyperframes/parsers/asset-resolu
|
|
|
6486
6511
|
import { decodedUrlPath } from "@hyperframes/parsers/asset-paths";
|
|
6487
6512
|
import { createHash as createHash6 } from "node:crypto";
|
|
6488
6513
|
import { createReadStream as createReadStream2, existsSync as existsSync11, mkdirSync as mkdirSync9, readFileSync as readFileSync8 } from "fs";
|
|
6489
|
-
import { join as join19, dirname as dirname8, resolve as resolve7, basename as basename5, relative as relative2, sep as
|
|
6514
|
+
import { join as join19, dirname as dirname8, resolve as resolve7, basename as basename5, relative as relative2, sep as sep3 } from "path";
|
|
6490
6515
|
import { parseHTML as parseHTML5 } from "linkedom";
|
|
6491
6516
|
|
|
6492
6517
|
// src/services/bundledScripts.ts
|
|
@@ -6751,7 +6776,7 @@ import {
|
|
|
6751
6776
|
|
|
6752
6777
|
// src/services/animatedGifPrep.ts
|
|
6753
6778
|
import { createHash as createHash4 } from "node:crypto";
|
|
6754
|
-
import { copyFileSync as copyFileSync2, existsSync as existsSync9, mkdirSync as mkdirSync7, readFileSync as readFileSync6, rmSync as rmSync9, statSync as
|
|
6779
|
+
import { copyFileSync as copyFileSync2, existsSync as existsSync9, mkdirSync as mkdirSync7, readFileSync as readFileSync6, rmSync as rmSync9, statSync as statSync7 } from "node:fs";
|
|
6755
6780
|
import { dirname as dirname6, isAbsolute as isAbsolute2, join as join16, resolve as resolve5 } from "node:path";
|
|
6756
6781
|
import { parseHTML as parseHTML3 } from "linkedom";
|
|
6757
6782
|
import { parseAnimatedGifMetadata } from "@hyperframes/core";
|
|
@@ -6799,12 +6824,12 @@ function resolveLocalImageSourcePath(src, options) {
|
|
|
6799
6824
|
...protocolRelativeUrlOnShare ? [] : [isAbsolute2(basePath) ? basePath : resolve5(options.projectDir, projectRelative)],
|
|
6800
6825
|
resolve5(options.downloadDir, normalizedBase)
|
|
6801
6826
|
];
|
|
6802
|
-
const allowed = (candidate) => !escapesAssetRoot(candidate, options.assetRoot) || !escapesAssetRoot(candidate, options.downloadDir);
|
|
6827
|
+
const allowed = (candidate) => !escapesAssetRoot(candidate, options.assetRoot) && outsideAssetRefusal(options.projectDir, candidate) !== "blocklisted" || !escapesAssetRoot(candidate, options.downloadDir);
|
|
6803
6828
|
return candidates.find((candidate) => existsSync9(candidate) && allowed(candidate)) ?? null;
|
|
6804
6829
|
}
|
|
6805
6830
|
function isUsableFile(path) {
|
|
6806
6831
|
try {
|
|
6807
|
-
const stat =
|
|
6832
|
+
const stat = statSync7(path);
|
|
6808
6833
|
return stat.isFile() && stat.size > 0;
|
|
6809
6834
|
} catch {
|
|
6810
6835
|
return false;
|
|
@@ -7068,7 +7093,7 @@ import {
|
|
|
7068
7093
|
readFileSync as readFileSync7,
|
|
7069
7094
|
readSync as readSync3,
|
|
7070
7095
|
rmSync as rmSync10,
|
|
7071
|
-
statSync as
|
|
7096
|
+
statSync as statSync8,
|
|
7072
7097
|
writeFileSync as writeFileSync4
|
|
7073
7098
|
} from "node:fs";
|
|
7074
7099
|
import { dirname as dirname7, join as join17, resolve as resolve6 } from "node:path";
|
|
@@ -7311,7 +7336,7 @@ function resolveImageSource(src, options) {
|
|
|
7311
7336
|
}
|
|
7312
7337
|
function isUsableFile2(path) {
|
|
7313
7338
|
try {
|
|
7314
|
-
return
|
|
7339
|
+
return statSync8(path).size > 0;
|
|
7315
7340
|
} catch {
|
|
7316
7341
|
return false;
|
|
7317
7342
|
}
|
|
@@ -7445,6 +7470,11 @@ function dropMediaOutsideProject(input) {
|
|
|
7445
7470
|
if (!src || isRemoteOrInlineSource(src)) return true;
|
|
7446
7471
|
const path = resolveProjectRelativeSrc3(src, projectDir, compiledDir);
|
|
7447
7472
|
if (roots.some((root) => !escapesAssetRoot(path, root))) return true;
|
|
7473
|
+
if (input.allowOutsideProjectAssets) {
|
|
7474
|
+
const refusal = outsideAssetRefusal(projectDir, path);
|
|
7475
|
+
if (refusal) log.warn(`[Render] ${leftOutOfRender(`Media "${id}"`, src, refusal)}`);
|
|
7476
|
+
return refusal === null;
|
|
7477
|
+
}
|
|
7448
7478
|
log.warn(`[Render] Media "${id}" source is missing: it is outside the project folder`, { src });
|
|
7449
7479
|
return false;
|
|
7450
7480
|
};
|
|
@@ -7571,7 +7601,7 @@ function normalizeCompositionSrcs(html, projectDir) {
|
|
|
7571
7601
|
if (!value.includes("%") && !value.startsWith("/")) return whole;
|
|
7572
7602
|
const file = resolveCompositionSrc(projectDir, value);
|
|
7573
7603
|
if (file === null) return whole;
|
|
7574
|
-
return `${name}${quote}${relative2(projectDir, file).split(
|
|
7604
|
+
return `${name}${quote}${relative2(projectDir, file).split(sep3).join("/")}${quote}`;
|
|
7575
7605
|
});
|
|
7576
7606
|
}
|
|
7577
7607
|
function resolveCompositionFile(projectDir, src, assetRoot) {
|
|
@@ -7592,6 +7622,10 @@ function assertSubCompositionsUsable(html, projectDir, assetRoot, visited = /* @
|
|
|
7592
7622
|
problems.push({ srcPath, detail: "it is outside the project folder" });
|
|
7593
7623
|
continue;
|
|
7594
7624
|
}
|
|
7625
|
+
if (outsideAssetRefusal(projectDir, filePath) === "blocklisted") {
|
|
7626
|
+
problems.push({ srcPath, detail: "it is outside the project in a private location" });
|
|
7627
|
+
continue;
|
|
7628
|
+
}
|
|
7595
7629
|
if (isPrivateCompositionFile(projectDir, filePath)) {
|
|
7596
7630
|
problems.push({ srcPath, detail: "it is git metadata or an env file" });
|
|
7597
7631
|
continue;
|
|
@@ -8297,17 +8331,24 @@ ${safeText}
|
|
|
8297
8331
|
}
|
|
8298
8332
|
return wrappedFragment ? document2.body.innerHTML || "" : document2.toString();
|
|
8299
8333
|
}
|
|
8300
|
-
function collectExternalAssets(html, projectDir) {
|
|
8334
|
+
function collectExternalAssets(html, projectDir, log = defaultLogger, file = "index.html") {
|
|
8301
8335
|
const absProjectDir = resolve7(projectDir);
|
|
8302
8336
|
const externalAssets = /* @__PURE__ */ new Map();
|
|
8337
|
+
const leftOut = /* @__PURE__ */ new Set();
|
|
8303
8338
|
function processPath(rawPath) {
|
|
8304
8339
|
const trimmed = rawPath.trim();
|
|
8305
8340
|
if (isNonRelativeUrl(trimmed)) return null;
|
|
8306
8341
|
const absPath = resolve7(absProjectDir, trimmed);
|
|
8307
|
-
if (
|
|
8342
|
+
if (isPathInside(absPath, absProjectDir)) {
|
|
8308
8343
|
return null;
|
|
8309
8344
|
}
|
|
8310
8345
|
if (!existsSync11(absPath)) return null;
|
|
8346
|
+
const refusal = outsideAssetRefusal(absProjectDir, absPath);
|
|
8347
|
+
if (refusal) {
|
|
8348
|
+
if (!leftOut.has(trimmed)) log.warn(`[Compiler] ${leftOutOfRender(file, trimmed, refusal)}`);
|
|
8349
|
+
leftOut.add(trimmed);
|
|
8350
|
+
return null;
|
|
8351
|
+
}
|
|
8311
8352
|
const safeKey = toExternalAssetKey(absPath);
|
|
8312
8353
|
externalAssets.set(safeKey, absPath);
|
|
8313
8354
|
return safeKey;
|
|
@@ -8553,13 +8594,13 @@ function projectStylesheetFontFamilies(html, projectDir) {
|
|
|
8553
8594
|
const href = /\bhref=["']([^"']+)["']/i.exec(tag)?.[1];
|
|
8554
8595
|
if (!href || /^(?:[a-z][a-z\d+.-]*:|\/\/)/i.test(href)) continue;
|
|
8555
8596
|
const sheet = resolve7(projectDir, decodedUrlPath(href).replace(/^(?:\.?\/)+/, ""));
|
|
8556
|
-
if (!
|
|
8597
|
+
if (!isPathInside(sheet, projectDir) || !existsSync11(sheet)) continue;
|
|
8557
8598
|
for (const face of extractFontFaceBlocks(readFileSync8(sheet, "utf8"))) {
|
|
8558
8599
|
const family = /font-family\s*:\s*([^;}]+)/i.exec(face)?.[1]?.trim().replace(/^['"]|['"]$/g, "");
|
|
8559
8600
|
const shipsFile = [...face.matchAll(LOCAL_FONTFACE_URL_RE)].some(([, url = ""]) => {
|
|
8560
8601
|
const path = decodedUrlPath(url);
|
|
8561
8602
|
const file = path.startsWith("/") ? resolve7(projectDir, `.${path}`) : resolve7(dirname8(sheet), path);
|
|
8562
|
-
return
|
|
8603
|
+
return isPathInside(file, projectDir) && existsSync11(file);
|
|
8563
8604
|
});
|
|
8564
8605
|
if (family && shipsFile) families.push(family);
|
|
8565
8606
|
}
|
|
@@ -8628,7 +8669,7 @@ async function readLocalFont(absPath) {
|
|
|
8628
8669
|
}
|
|
8629
8670
|
return { kind: "inline", buffer: Buffer.concat(chunks, totalBytes) };
|
|
8630
8671
|
}
|
|
8631
|
-
async function embedLocalFontFaces(html, projectDir, assetRoot) {
|
|
8672
|
+
async function embedLocalFontFaces(html, projectDir, assetRoot, log = defaultLogger) {
|
|
8632
8673
|
const { fontToDataUri: toDataUri } = await import("@hyperframes/core/fonts/embed");
|
|
8633
8674
|
const styleBlockRe = /<style\b[^>]*>([\s\S]*?)<\/style>/gi;
|
|
8634
8675
|
const fontFaceRe = /@font-face\s*\{([^}]*)\}/gi;
|
|
@@ -8649,7 +8690,11 @@ async function embedLocalFontFaces(html, projectDir, assetRoot) {
|
|
|
8649
8690
|
const localPath = urlMatch[1];
|
|
8650
8691
|
if (!localPath || embeddedPaths.has(localPath)) continue;
|
|
8651
8692
|
const absPath = localPath.startsWith("/") ? localPath : resolve7(projectDir, localPath);
|
|
8652
|
-
if (!
|
|
8693
|
+
if (!isPathInside(absPath, projectDir) || escapesAssetRoot(absPath, assetRoot)) continue;
|
|
8694
|
+
if (refusesOutsideLink(projectDir, absPath, (line) => log.warn(`[Compiler] ${line}`))) {
|
|
8695
|
+
embeddedPaths.add(localPath);
|
|
8696
|
+
continue;
|
|
8697
|
+
}
|
|
8653
8698
|
const ext = absPath.match(/\.(woff2?|ttf|otf|ttc)$/i)?.[1]?.toLowerCase() ?? "ttf";
|
|
8654
8699
|
try {
|
|
8655
8700
|
if (fileBackedAbsolutePaths.has(absPath)) {
|
|
@@ -8713,7 +8758,7 @@ function rewriteUnresolvableGsapToCdn(html, projectDir, compSrcPath) {
|
|
|
8713
8758
|
);
|
|
8714
8759
|
}
|
|
8715
8760
|
function rebaseDirectEntryAssetPaths(html, projectDir, htmlPath) {
|
|
8716
|
-
if (!
|
|
8761
|
+
if (!isPathInside(htmlPath, projectDir)) return html;
|
|
8717
8762
|
const entryPath = relative2(projectDir, htmlPath).replace(/\\/g, "/");
|
|
8718
8763
|
if (!entryPath.includes("/")) return html;
|
|
8719
8764
|
const { document: document2 } = parseHTML5(html);
|
|
@@ -8755,9 +8800,10 @@ function bindVariableMediaSources(html, variables) {
|
|
|
8755
8800
|
}
|
|
8756
8801
|
return changed ? document2.toString() : html;
|
|
8757
8802
|
}
|
|
8803
|
+
var entryFileName = (projectDir, htmlPath) => isPathInside(htmlPath, projectDir) ? relative2(projectDir, htmlPath).split(sep3).join("/") : basename5(htmlPath);
|
|
8758
8804
|
async function compileForRender(projectDir, htmlPath, downloadDir, options = {}) {
|
|
8759
8805
|
const assetRoot = options.allowOutsideProjectAssets ? void 0 : projectDir;
|
|
8760
|
-
if (
|
|
8806
|
+
if (isPathInside(htmlPath, projectDir) && escapesAssetRoot(htmlPath, assetRoot)) {
|
|
8761
8807
|
throw new Error(`Entry file ${htmlPath} leads outside the project folder`);
|
|
8762
8808
|
}
|
|
8763
8809
|
const entryHtml = rebaseDirectEntryAssetPaths(readTextFile(htmlPath), projectDir, htmlPath);
|
|
@@ -8869,8 +8915,18 @@ async function compileForRender(projectDir, htmlPath, downloadDir, options = {})
|
|
|
8869
8915
|
if (preparedGifs.length > 0) {
|
|
8870
8916
|
defaultLogger.debug(`[Compiler] Prepared ${preparedGifs.length} animated GIF input(s) as WebM`);
|
|
8871
8917
|
}
|
|
8872
|
-
const embeddedHtml = await embedLocalFontFaces(
|
|
8873
|
-
|
|
8918
|
+
const embeddedHtml = await embedLocalFontFaces(
|
|
8919
|
+
htmlWithPreparedGifs,
|
|
8920
|
+
projectDir,
|
|
8921
|
+
assetRoot,
|
|
8922
|
+
options.log
|
|
8923
|
+
);
|
|
8924
|
+
const { html, externalAssets } = options.allowOutsideProjectAssets ? collectExternalAssets(
|
|
8925
|
+
embeddedHtml,
|
|
8926
|
+
projectDir,
|
|
8927
|
+
options.log,
|
|
8928
|
+
entryFileName(projectDir, htmlPath)
|
|
8929
|
+
) : { html: embeddedHtml, externalAssets: /* @__PURE__ */ new Map() };
|
|
8874
8930
|
for (const [relPath, absPath] of remoteMediaAssets) {
|
|
8875
8931
|
externalAssets.set(relPath, absPath);
|
|
8876
8932
|
}
|
|
@@ -9441,9 +9497,13 @@ async function runCompileStage(input) {
|
|
|
9441
9497
|
width: compiled.width,
|
|
9442
9498
|
height: compiled.height
|
|
9443
9499
|
};
|
|
9444
|
-
|
|
9445
|
-
|
|
9446
|
-
|
|
9500
|
+
dropMediaOutsideProject({
|
|
9501
|
+
projectDir,
|
|
9502
|
+
workDir,
|
|
9503
|
+
composition,
|
|
9504
|
+
log,
|
|
9505
|
+
allowOutsideProjectAssets: job.config.allowOutsideProjectAssets
|
|
9506
|
+
});
|
|
9447
9507
|
await preflightCompositionAssetMediaTypes({
|
|
9448
9508
|
projectDir,
|
|
9449
9509
|
compiledDir: join20(workDir, "compiled"),
|
|
@@ -10068,9 +10128,13 @@ async function runProbeStage(input) {
|
|
|
10068
10128
|
}
|
|
10069
10129
|
}
|
|
10070
10130
|
}
|
|
10071
|
-
|
|
10072
|
-
|
|
10073
|
-
|
|
10131
|
+
dropMediaOutsideProject({
|
|
10132
|
+
projectDir,
|
|
10133
|
+
workDir,
|
|
10134
|
+
composition,
|
|
10135
|
+
log,
|
|
10136
|
+
allowOutsideProjectAssets: job.config.allowOutsideProjectAssets
|
|
10137
|
+
});
|
|
10074
10138
|
await preflightCompositionAssetMediaTypes({
|
|
10075
10139
|
projectDir,
|
|
10076
10140
|
compiledDir: join21(workDir, "compiled"),
|
|
@@ -12881,7 +12945,7 @@ import {
|
|
|
12881
12945
|
readdirSync as readdirSync5,
|
|
12882
12946
|
readFileSync as readFileSync9,
|
|
12883
12947
|
rmSync as rmSync11,
|
|
12884
|
-
statSync as
|
|
12948
|
+
statSync as statSync9,
|
|
12885
12949
|
writeFileSync as writeFileSync6
|
|
12886
12950
|
} from "node:fs";
|
|
12887
12951
|
import { readFile as readFile2 } from "node:fs/promises";
|
|
@@ -13010,7 +13074,7 @@ async function encodeGifFromDir(framesDir, framePattern, outputPath, input) {
|
|
|
13010
13074
|
const failure = await reencodeWithClearedWholeFrames(argsInput, run, startTime);
|
|
13011
13075
|
if (failure) return failure;
|
|
13012
13076
|
}
|
|
13013
|
-
const fileSize = existsSync20(outputPath) ?
|
|
13077
|
+
const fileSize = existsSync20(outputPath) ? statSync9(outputPath).size : 0;
|
|
13014
13078
|
return {
|
|
13015
13079
|
success: true,
|
|
13016
13080
|
outputPath,
|
|
@@ -13416,7 +13480,7 @@ function sampleDirectoryBytes(dir) {
|
|
|
13416
13480
|
for (const name of entries) {
|
|
13417
13481
|
const full = join32(current, name);
|
|
13418
13482
|
try {
|
|
13419
|
-
const st =
|
|
13483
|
+
const st = statSync10(full);
|
|
13420
13484
|
if (st.isDirectory()) {
|
|
13421
13485
|
stack.push(full);
|
|
13422
13486
|
} else if (st.isFile()) {
|
|
@@ -13571,7 +13635,7 @@ function findMissingFrameRanges(totalFrames, framesDir, frameExt) {
|
|
|
13571
13635
|
let rangeStart = null;
|
|
13572
13636
|
for (let frameIndex = 0; frameIndex < totalFrames; frameIndex++) {
|
|
13573
13637
|
const framePath = join32(framesDir, formatCaptureFrameName(frameIndex, frameExt));
|
|
13574
|
-
const missing = !existsSync21(framePath) ||
|
|
13638
|
+
const missing = !existsSync21(framePath) || statSync10(framePath).size <= 8;
|
|
13575
13639
|
if (missing && rangeStart === null) {
|
|
13576
13640
|
rangeStart = frameIndex;
|
|
13577
13641
|
} else if (!missing && rangeStart !== null) {
|
|
@@ -16909,7 +16973,7 @@ import {
|
|
|
16909
16973
|
rmSync as rmSync14,
|
|
16910
16974
|
writeFileSync as writeFileSync10
|
|
16911
16975
|
} from "node:fs";
|
|
16912
|
-
import { extname as extname6, isAbsolute as isAbsolute3, join as join41, relative as relative6, sep as
|
|
16976
|
+
import { extname as extname6, isAbsolute as isAbsolute3, join as join41, relative as relative6, sep as sep4 } from "node:path";
|
|
16913
16977
|
import {
|
|
16914
16978
|
fpsToNumber as fpsToNumber9,
|
|
16915
16979
|
HF_COLOR_GRADING_ATTR as HF_COLOR_GRADING_ATTR2
|
|
@@ -18618,7 +18682,7 @@ function pathInside(root, path) {
|
|
|
18618
18682
|
function stableSourcePath(roots, srcPath) {
|
|
18619
18683
|
for (const [root, prefix] of roots) {
|
|
18620
18684
|
const rel = pathInside(root, srcPath);
|
|
18621
|
-
if (rel !== null) return [prefix, ...rel.split(
|
|
18685
|
+
if (rel !== null) return [prefix, ...rel.split(sep4)].filter(Boolean).join("/");
|
|
18622
18686
|
}
|
|
18623
18687
|
return srcPath;
|
|
18624
18688
|
}
|
|
@@ -18633,7 +18697,7 @@ function createVideoSourceShipper(input) {
|
|
|
18633
18697
|
for (const root of stagedRel === null ? [input.workCompiledDir, input.projectDir] : []) {
|
|
18634
18698
|
const rel = pathInside(root, srcPath);
|
|
18635
18699
|
if (rel !== null && (existsSync26(join41(input.planDir, "compiled", rel)) || input.isRemote(srcPath))) {
|
|
18636
|
-
result = ["compiled", ...rel.split(
|
|
18700
|
+
result = ["compiled", ...rel.split(sep4)].join("/");
|
|
18637
18701
|
break;
|
|
18638
18702
|
}
|
|
18639
18703
|
}
|
|
@@ -18708,8 +18772,10 @@ async function compilePlanComposition(projectDir, config, planDir, options) {
|
|
|
18708
18772
|
filter: (src) => {
|
|
18709
18773
|
const rel = relative6(projectDir, src);
|
|
18710
18774
|
if (rel === "" || rel.startsWith("..")) return true;
|
|
18711
|
-
if (
|
|
18712
|
-
|
|
18775
|
+
if (job.config.allowOutsideProjectAssets) {
|
|
18776
|
+
if (refusesOutsideLink(projectDir, src, (line) => log.warn(`[Plan] ${line}`))) return false;
|
|
18777
|
+
} else if (!isSafePath2(projectDir, src)) return false;
|
|
18778
|
+
const firstSegment = rel.split(sep4, 1)[0];
|
|
18713
18779
|
return firstSegment === void 0 || !PLAN_PROJECT_DIR_SKIP_SEGMENTS.has(firstSegment);
|
|
18714
18780
|
}
|
|
18715
18781
|
});
|
|
@@ -19208,11 +19274,11 @@ import {
|
|
|
19208
19274
|
readFileSync as readFileSync13,
|
|
19209
19275
|
readdirSync as readdirSync10,
|
|
19210
19276
|
rmSync as rmSync16,
|
|
19211
|
-
statSync as
|
|
19277
|
+
statSync as statSync12,
|
|
19212
19278
|
writeFileSync as writeFileSync12
|
|
19213
19279
|
} from "node:fs";
|
|
19214
19280
|
import { tmpdir as tmpdir3 } from "node:os";
|
|
19215
|
-
import { dirname as dirname17, isAbsolute as isAbsolute4, join as join44, relative as relative7, resolve as resolve10, sep as
|
|
19281
|
+
import { dirname as dirname17, isAbsolute as isAbsolute4, join as join44, relative as relative7, resolve as resolve10, sep as sep5 } from "node:path";
|
|
19216
19282
|
import { DISTRIBUTED_FPS, isDistributedFps } from "@hyperframes/core";
|
|
19217
19283
|
import {
|
|
19218
19284
|
createFrameLookupTable as createFrameLookupTable5,
|
|
@@ -19227,7 +19293,7 @@ import {
|
|
|
19227
19293
|
linkSync as linkSync2,
|
|
19228
19294
|
mkdirSync as mkdirSync17,
|
|
19229
19295
|
rmSync as rmSync15,
|
|
19230
|
-
statSync as
|
|
19296
|
+
statSync as statSync11,
|
|
19231
19297
|
writeFileSync as writeFileSync11
|
|
19232
19298
|
} from "node:fs";
|
|
19233
19299
|
import { renameWithRetry as renameWithRetry9 } from "@hyperframes/engine";
|
|
@@ -19302,7 +19368,7 @@ var LocalPlanV2ArtifactPublisher = class {
|
|
|
19302
19368
|
}
|
|
19303
19369
|
async putBlob(blob) {
|
|
19304
19370
|
const digest = assertPlanV2Sha256(blob.sha256, "published blob sha256");
|
|
19305
|
-
const sourceSize =
|
|
19371
|
+
const sourceSize = statSync11(blob.sourcePath).size;
|
|
19306
19372
|
if (sourceSize !== blob.sizeBytes) {
|
|
19307
19373
|
throw new PlanV2IntegrityError(
|
|
19308
19374
|
`published blob size changed for ${digest}: expected ${blob.sizeBytes}, got ${sourceSize}`
|
|
@@ -19384,7 +19450,7 @@ function listFiles(root) {
|
|
|
19384
19450
|
walk(absolutePath);
|
|
19385
19451
|
} else if (entry.isFile()) {
|
|
19386
19452
|
files.push({
|
|
19387
|
-
path: relative7(rootResolved, absolutePath).split(
|
|
19453
|
+
path: relative7(rootResolved, absolutePath).split(sep5).join("/"),
|
|
19388
19454
|
absolutePath
|
|
19389
19455
|
});
|
|
19390
19456
|
} else {
|
|
@@ -19424,7 +19490,7 @@ function isExtractionCacheCompleteSentinelPath(path) {
|
|
|
19424
19490
|
function resolveExtractedVideoOutputDir(planDir, videoId) {
|
|
19425
19491
|
const videoRoot = resolve10(planDir, "video-frames");
|
|
19426
19492
|
const outputDir = resolve10(videoRoot, mediaIdPathSegment4(videoId));
|
|
19427
|
-
if (outputDir === videoRoot || !outputDir.startsWith(`${videoRoot}${
|
|
19493
|
+
if (outputDir === videoRoot || !outputDir.startsWith(`${videoRoot}${sep5}`)) {
|
|
19428
19494
|
throw new PlanV2IntegrityError(`unsafe extracted video id: ${JSON.stringify(videoId)}`);
|
|
19429
19495
|
}
|
|
19430
19496
|
return outputDir;
|
|
@@ -19584,7 +19650,7 @@ function collectChunkVideoDependencies(input) {
|
|
|
19584
19650
|
for (let frame = chunk.startFrame; frame < chunk.endFrame; frame++) {
|
|
19585
19651
|
const globalTime = frame * input.fpsDen / input.fpsNum;
|
|
19586
19652
|
for (const [videoId, payload] of input.table.getActiveFramePayloads(globalTime)) {
|
|
19587
|
-
const path = input.deferredSources.get(videoId) ?? relative7(resolve10(input.executionPlanDir), payload.framePath).split(
|
|
19653
|
+
const path = input.deferredSources.get(videoId) ?? relative7(resolve10(input.executionPlanDir), payload.framePath).split(sep5).join("/");
|
|
19588
19654
|
assertSafeRelativePath(path);
|
|
19589
19655
|
const indexes = mutable.get(path) ?? /* @__PURE__ */ new Set();
|
|
19590
19656
|
indexes.add(chunk.index);
|
|
@@ -19616,7 +19682,7 @@ function publishBlobFor(absolutePath, digests) {
|
|
|
19616
19682
|
return {
|
|
19617
19683
|
sourcePath: absolutePath,
|
|
19618
19684
|
sha256: planFileSha256(absolutePath, digests),
|
|
19619
|
-
sizeBytes:
|
|
19685
|
+
sizeBytes: statSync12(absolutePath).size
|
|
19620
19686
|
};
|
|
19621
19687
|
}
|
|
19622
19688
|
async function putBlobs(publisher, blobs) {
|
|
@@ -19984,7 +20050,7 @@ function verifyBlob(planV2Dir, artifact) {
|
|
|
19984
20050
|
if (!existsSync28(sourcePath)) {
|
|
19985
20051
|
throw new PlanV2IntegrityError(`missing content-addressed artifact ${artifact.sha256}`);
|
|
19986
20052
|
}
|
|
19987
|
-
const stats =
|
|
20053
|
+
const stats = statSync12(sourcePath);
|
|
19988
20054
|
if (!stats.isFile() || stats.size !== artifact.sizeBytes) {
|
|
19989
20055
|
throw new PlanV2IntegrityError(`artifact size mismatch for ${artifact.path}`);
|
|
19990
20056
|
}
|
|
@@ -20077,7 +20143,7 @@ function readValidatedPlanV2Materialization(planDir, expectedTarget) {
|
|
|
20077
20143
|
for (const artifact of required) {
|
|
20078
20144
|
if (Object.hasOwn(remoteSources, artifact.path)) continue;
|
|
20079
20145
|
const path = join44(planDir, ...artifact.path.split("/"));
|
|
20080
|
-
if (!existsSync28(path) ||
|
|
20146
|
+
if (!existsSync28(path) || statSync12(path).size !== artifact.sizeBytes) {
|
|
20081
20147
|
throw new PlanV2IntegrityError(
|
|
20082
20148
|
`materialized artifact missing or truncated: ${artifact.path}`
|
|
20083
20149
|
);
|
|
@@ -21483,7 +21549,7 @@ import {
|
|
|
21483
21549
|
import {
|
|
21484
21550
|
existsSync as existsSync32,
|
|
21485
21551
|
mkdirSync as mkdirSync21,
|
|
21486
|
-
statSync as
|
|
21552
|
+
statSync as statSync14,
|
|
21487
21553
|
mkdtempSync as mkdtempSync2,
|
|
21488
21554
|
writeFileSync as writeFileSync14,
|
|
21489
21555
|
rmSync as rmSync19,
|
|
@@ -21506,13 +21572,13 @@ import {
|
|
|
21506
21572
|
import {
|
|
21507
21573
|
existsSync as existsSync30,
|
|
21508
21574
|
readFileSync as readFileSync16,
|
|
21509
|
-
statSync as
|
|
21575
|
+
statSync as statSync13,
|
|
21510
21576
|
openSync as openSync7,
|
|
21511
21577
|
fstatSync as fstatSync3,
|
|
21512
21578
|
closeSync as closeSync7,
|
|
21513
21579
|
constants as constants3
|
|
21514
21580
|
} from "node:fs";
|
|
21515
|
-
import { resolve as resolve11, join as join47, relative as relative8, isAbsolute as isAbsolute5, sep as
|
|
21581
|
+
import { resolve as resolve11, join as join47, relative as relative8, isAbsolute as isAbsolute5, sep as sep6 } from "node:path";
|
|
21516
21582
|
import { lintHyperframeHtml } from "@hyperframes/lint";
|
|
21517
21583
|
function isStringRecord(value) {
|
|
21518
21584
|
if (!value || typeof value !== "object" || Array.isArray(value)) {
|
|
@@ -21546,7 +21612,7 @@ function readEntryHtml(filePath) {
|
|
|
21546
21612
|
} catch (error) {
|
|
21547
21613
|
if (error instanceof Error && "code" in error && (error.code === "ENOENT" || error.code === "ENOTDIR"))
|
|
21548
21614
|
return null;
|
|
21549
|
-
if (!
|
|
21615
|
+
if (!statSync13(filePath, { throwIfNoEntry: false })?.isFile()) return null;
|
|
21550
21616
|
throw error;
|
|
21551
21617
|
}
|
|
21552
21618
|
try {
|
|
@@ -21558,7 +21624,7 @@ function readEntryHtml(filePath) {
|
|
|
21558
21624
|
}
|
|
21559
21625
|
function readProjectEntryFile(projectDir, preferredEntryFile) {
|
|
21560
21626
|
const absProjectDir = resolve11(projectDir);
|
|
21561
|
-
if (!existsSync30(absProjectDir) || !
|
|
21627
|
+
if (!existsSync30(absProjectDir) || !statSync13(absProjectDir).isDirectory()) {
|
|
21562
21628
|
return { error: `Project directory not found: ${absProjectDir}` };
|
|
21563
21629
|
}
|
|
21564
21630
|
const entryCandidates = [preferredEntryFile, "index.html", "src/index.html"].filter(
|
|
@@ -21567,7 +21633,7 @@ function readProjectEntryFile(projectDir, preferredEntryFile) {
|
|
|
21567
21633
|
for (const entryFile of entryCandidates) {
|
|
21568
21634
|
const absoluteEntryPath = resolve11(absProjectDir, entryFile);
|
|
21569
21635
|
const entryRelativePath = relative8(absProjectDir, absoluteEntryPath);
|
|
21570
|
-
if (entryRelativePath === ".." || entryRelativePath.startsWith(`..${
|
|
21636
|
+
if (entryRelativePath === ".." || entryRelativePath.startsWith(`..${sep6}`) || isAbsolute5(entryRelativePath)) {
|
|
21571
21637
|
return { error: `Entry file must stay inside project directory: ${entryFile}` };
|
|
21572
21638
|
}
|
|
21573
21639
|
const html = readEntryHtml(absoluteEntryPath);
|
|
@@ -21926,7 +21992,7 @@ function prepareProjectDirectory(projectDir, options) {
|
|
|
21926
21992
|
const candidate = nonEmptyString(projectDir);
|
|
21927
21993
|
if (!candidate) return null;
|
|
21928
21994
|
const absProjectDir = resolve12(candidate);
|
|
21929
|
-
if (!existsSync32(absProjectDir) || !
|
|
21995
|
+
if (!existsSync32(absProjectDir) || !statSync14(absProjectDir).isDirectory()) {
|
|
21930
21996
|
return { error: `Project directory not found: ${absProjectDir}` };
|
|
21931
21997
|
}
|
|
21932
21998
|
const entry = options.entryFile || "index.html";
|
|
@@ -22022,7 +22088,7 @@ function cleanupTempDir(dir, log) {
|
|
|
22022
22088
|
}
|
|
22023
22089
|
}
|
|
22024
22090
|
function outputFileSize(path) {
|
|
22025
|
-
return existsSync32(path) ?
|
|
22091
|
+
return existsSync32(path) ? statSync14(path).size : 0;
|
|
22026
22092
|
}
|
|
22027
22093
|
function createBlockingProgressReporter(log, requestId) {
|
|
22028
22094
|
let lastLoggedPct = -10;
|
|
@@ -22339,7 +22405,7 @@ function createRenderHandlers(options = {}) {
|
|
|
22339
22405
|
store.delete(token);
|
|
22340
22406
|
return c.json({ success: false, error: "Output artifact file missing" }, 404);
|
|
22341
22407
|
}
|
|
22342
|
-
const stats =
|
|
22408
|
+
const stats = statSync14(artifact.path);
|
|
22343
22409
|
return new Response(createReadStream5(artifact.path), {
|
|
22344
22410
|
headers: {
|
|
22345
22411
|
"content-type": "video/mp4",
|
|
@@ -22463,7 +22529,7 @@ import {
|
|
|
22463
22529
|
readFileSync as readFileSync17,
|
|
22464
22530
|
readdirSync as readdirSync12,
|
|
22465
22531
|
rmSync as rmSync20,
|
|
22466
|
-
statSync as
|
|
22532
|
+
statSync as statSync15,
|
|
22467
22533
|
writeFileSync as writeFileSync15
|
|
22468
22534
|
} from "node:fs";
|
|
22469
22535
|
import { basename as basename8, dirname as dirname20, join as join50 } from "node:path";
|
|
@@ -22508,7 +22574,7 @@ async function assemble(planDir, chunkOutputs, audioPath, outputPath, options) {
|
|
|
22508
22574
|
outputPath,
|
|
22509
22575
|
durationMs: Date.now() - start,
|
|
22510
22576
|
framesEncoded: plan2.totalFrames,
|
|
22511
|
-
fileSize:
|
|
22577
|
+
fileSize: statSync15(outputPath).size
|
|
22512
22578
|
};
|
|
22513
22579
|
}
|
|
22514
22580
|
const format = plan2.dimensions.format;
|
|
@@ -22555,7 +22621,7 @@ async function assemble(planDir, chunkOutputs, audioPath, outputPath, options) {
|
|
|
22555
22621
|
});
|
|
22556
22622
|
}
|
|
22557
22623
|
}
|
|
22558
|
-
const fileSize = existsSync33(outputPath) ?
|
|
22624
|
+
const fileSize = existsSync33(outputPath) ? statSync15(outputPath).size : 0;
|
|
22559
22625
|
return {
|
|
22560
22626
|
...referenceBackgroundResult8(plan2[REFERENCE_BACKGROUND_FIELD6]),
|
|
22561
22627
|
outputPath,
|
|
@@ -22753,7 +22819,7 @@ function mergePngFrameDirs(chunkPaths, outputPath, totalFrames, audioPath, start
|
|
|
22753
22819
|
mkdirSync22(outputPath, { recursive: true });
|
|
22754
22820
|
let globalIdx = 0;
|
|
22755
22821
|
for (const chunkDir of chunkPaths) {
|
|
22756
|
-
if (!
|
|
22822
|
+
if (!statSync15(chunkDir).isDirectory()) {
|
|
22757
22823
|
throw new Error(
|
|
22758
22824
|
`[assemble] png-sequence chunk must be a directory: ${chunkDir} (got a file)`
|
|
22759
22825
|
);
|
|
@@ -22780,7 +22846,7 @@ function mergePngFrameDirs(chunkPaths, outputPath, totalFrames, audioPath, start
|
|
|
22780
22846
|
let fileSize = 0;
|
|
22781
22847
|
for (const name of readdirSync12(outputPath)) {
|
|
22782
22848
|
try {
|
|
22783
|
-
fileSize +=
|
|
22849
|
+
fileSize += statSync15(join50(outputPath, name)).size;
|
|
22784
22850
|
} catch {
|
|
22785
22851
|
}
|
|
22786
22852
|
}
|