@hyperframes/producer 0.9.40 → 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 +191 -111
- package/dist/hyperframe.manifest.json +1 -1
- package/dist/hyperframe.runtime.iife.js +70 -70
- package/dist/index.js +211 -131
- package/dist/public-server.js +190 -112
- 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
|
|
@@ -6521,6 +6546,7 @@ import {
|
|
|
6521
6546
|
rewriteInlineStyleAssetUrls
|
|
6522
6547
|
} from "@hyperframes/core";
|
|
6523
6548
|
import { MAX_AUDIO_GAIN } from "@hyperframes/core/audio-gain";
|
|
6549
|
+
import { CAPTURE_CANVAS_SELECTOR } from "@hyperframes/core/html-in-canvas";
|
|
6524
6550
|
import { readPlaybackRate } from "@hyperframes/parsers/media-duration";
|
|
6525
6551
|
import { resolveRateSpec } from "@hyperframes/core/speed-ramp";
|
|
6526
6552
|
import { gsapCdnDist as gsapCdnDist2, normalizeGsapBaseUrl } from "@hyperframes/core/gsap-cdn";
|
|
@@ -6750,7 +6776,7 @@ import {
|
|
|
6750
6776
|
|
|
6751
6777
|
// src/services/animatedGifPrep.ts
|
|
6752
6778
|
import { createHash as createHash4 } from "node:crypto";
|
|
6753
|
-
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";
|
|
6754
6780
|
import { dirname as dirname6, isAbsolute as isAbsolute2, join as join16, resolve as resolve5 } from "node:path";
|
|
6755
6781
|
import { parseHTML as parseHTML3 } from "linkedom";
|
|
6756
6782
|
import { parseAnimatedGifMetadata } from "@hyperframes/core";
|
|
@@ -6798,12 +6824,12 @@ function resolveLocalImageSourcePath(src, options) {
|
|
|
6798
6824
|
...protocolRelativeUrlOnShare ? [] : [isAbsolute2(basePath) ? basePath : resolve5(options.projectDir, projectRelative)],
|
|
6799
6825
|
resolve5(options.downloadDir, normalizedBase)
|
|
6800
6826
|
];
|
|
6801
|
-
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);
|
|
6802
6828
|
return candidates.find((candidate) => existsSync9(candidate) && allowed(candidate)) ?? null;
|
|
6803
6829
|
}
|
|
6804
6830
|
function isUsableFile(path) {
|
|
6805
6831
|
try {
|
|
6806
|
-
const stat =
|
|
6832
|
+
const stat = statSync7(path);
|
|
6807
6833
|
return stat.isFile() && stat.size > 0;
|
|
6808
6834
|
} catch {
|
|
6809
6835
|
return false;
|
|
@@ -7067,7 +7093,7 @@ import {
|
|
|
7067
7093
|
readFileSync as readFileSync7,
|
|
7068
7094
|
readSync as readSync3,
|
|
7069
7095
|
rmSync as rmSync10,
|
|
7070
|
-
statSync as
|
|
7096
|
+
statSync as statSync8,
|
|
7071
7097
|
writeFileSync as writeFileSync4
|
|
7072
7098
|
} from "node:fs";
|
|
7073
7099
|
import { dirname as dirname7, join as join17, resolve as resolve6 } from "node:path";
|
|
@@ -7310,7 +7336,7 @@ function resolveImageSource(src, options) {
|
|
|
7310
7336
|
}
|
|
7311
7337
|
function isUsableFile2(path) {
|
|
7312
7338
|
try {
|
|
7313
|
-
return
|
|
7339
|
+
return statSync8(path).size > 0;
|
|
7314
7340
|
} catch {
|
|
7315
7341
|
return false;
|
|
7316
7342
|
}
|
|
@@ -7444,6 +7470,11 @@ function dropMediaOutsideProject(input) {
|
|
|
7444
7470
|
if (!src || isRemoteOrInlineSource(src)) return true;
|
|
7445
7471
|
const path = resolveProjectRelativeSrc3(src, projectDir, compiledDir);
|
|
7446
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
|
+
}
|
|
7447
7478
|
log.warn(`[Render] Media "${id}" source is missing: it is outside the project folder`, { src });
|
|
7448
7479
|
return false;
|
|
7449
7480
|
};
|
|
@@ -7570,7 +7601,7 @@ function normalizeCompositionSrcs(html, projectDir) {
|
|
|
7570
7601
|
if (!value.includes("%") && !value.startsWith("/")) return whole;
|
|
7571
7602
|
const file = resolveCompositionSrc(projectDir, value);
|
|
7572
7603
|
if (file === null) return whole;
|
|
7573
|
-
return `${name}${quote}${relative2(projectDir, file).split(
|
|
7604
|
+
return `${name}${quote}${relative2(projectDir, file).split(sep3).join("/")}${quote}`;
|
|
7574
7605
|
});
|
|
7575
7606
|
}
|
|
7576
7607
|
function resolveCompositionFile(projectDir, src, assetRoot) {
|
|
@@ -7591,6 +7622,10 @@ function assertSubCompositionsUsable(html, projectDir, assetRoot, visited = /* @
|
|
|
7591
7622
|
problems.push({ srcPath, detail: "it is outside the project folder" });
|
|
7592
7623
|
continue;
|
|
7593
7624
|
}
|
|
7625
|
+
if (outsideAssetRefusal(projectDir, filePath) === "blocklisted") {
|
|
7626
|
+
problems.push({ srcPath, detail: "it is outside the project in a private location" });
|
|
7627
|
+
continue;
|
|
7628
|
+
}
|
|
7594
7629
|
if (isPrivateCompositionFile(projectDir, filePath)) {
|
|
7595
7630
|
problems.push({ srcPath, detail: "it is git metadata or an env file" });
|
|
7596
7631
|
continue;
|
|
@@ -7651,7 +7686,7 @@ function runtimeRoot(document2) {
|
|
|
7651
7686
|
function detectRenderModeHints(html, pageMotionBlur) {
|
|
7652
7687
|
const reasons = [];
|
|
7653
7688
|
const { document: document2 } = parseHTML5(html);
|
|
7654
|
-
if (document2.querySelector(
|
|
7689
|
+
if (document2.querySelector(CAPTURE_CANVAS_SELECTOR)) {
|
|
7655
7690
|
reasons.push({
|
|
7656
7691
|
code: "htmlInCanvas",
|
|
7657
7692
|
message: "Detected html-in-canvas API (layoutsubtree canvas). Chrome does not support concurrent drawElementImage across multiple workers; render is pinned to a single worker."
|
|
@@ -7659,7 +7694,7 @@ function detectRenderModeHints(html, pageMotionBlur) {
|
|
|
7659
7694
|
} else if (pageMotionBlur !== "off" && runtimeRoot(document2)?.getAttribute("data-motion-blur") === "on") {
|
|
7660
7695
|
reasons.push({
|
|
7661
7696
|
code: "captureMotionBlur",
|
|
7662
|
-
message: 'Detected
|
|
7697
|
+
message: 'Detected motion blur (data-motion-blur="on"), drawn per frame with an SVG filter or, on the capture tier, html-in-canvas; routed through screenshot capture mode.'
|
|
7663
7698
|
});
|
|
7664
7699
|
}
|
|
7665
7700
|
if (document2.querySelector("iframe")) {
|
|
@@ -8296,17 +8331,24 @@ ${safeText}
|
|
|
8296
8331
|
}
|
|
8297
8332
|
return wrappedFragment ? document2.body.innerHTML || "" : document2.toString();
|
|
8298
8333
|
}
|
|
8299
|
-
function collectExternalAssets(html, projectDir) {
|
|
8334
|
+
function collectExternalAssets(html, projectDir, log = defaultLogger, file = "index.html") {
|
|
8300
8335
|
const absProjectDir = resolve7(projectDir);
|
|
8301
8336
|
const externalAssets = /* @__PURE__ */ new Map();
|
|
8337
|
+
const leftOut = /* @__PURE__ */ new Set();
|
|
8302
8338
|
function processPath(rawPath) {
|
|
8303
8339
|
const trimmed = rawPath.trim();
|
|
8304
8340
|
if (isNonRelativeUrl(trimmed)) return null;
|
|
8305
8341
|
const absPath = resolve7(absProjectDir, trimmed);
|
|
8306
|
-
if (
|
|
8342
|
+
if (isPathInside(absPath, absProjectDir)) {
|
|
8307
8343
|
return null;
|
|
8308
8344
|
}
|
|
8309
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
|
+
}
|
|
8310
8352
|
const safeKey = toExternalAssetKey(absPath);
|
|
8311
8353
|
externalAssets.set(safeKey, absPath);
|
|
8312
8354
|
return safeKey;
|
|
@@ -8400,13 +8442,26 @@ async function localizeRemoteMediaSources(html, downloadDir) {
|
|
|
8400
8442
|
if (m[1]) urlSet.add(m[1]);
|
|
8401
8443
|
}
|
|
8402
8444
|
}
|
|
8403
|
-
|
|
8445
|
+
const localized = await downloadAndRewriteUrls(
|
|
8404
8446
|
urlSet,
|
|
8405
8447
|
html,
|
|
8406
8448
|
join19(downloadDir, REMOTE_MEDIA_SUBDIR),
|
|
8407
8449
|
"Remote media download failed",
|
|
8408
8450
|
"Localized remote media source(s)"
|
|
8409
8451
|
);
|
|
8452
|
+
return { ...localized, html: dropBindingOnLocalizedMedia(localized.html) };
|
|
8453
|
+
}
|
|
8454
|
+
function dropBindingOnLocalizedMedia(html) {
|
|
8455
|
+
if (!html.includes("data-var-src")) return html;
|
|
8456
|
+
const { document: document2 } = parseHTML5(html);
|
|
8457
|
+
let changed = false;
|
|
8458
|
+
for (const el of document2.querySelectorAll("video[data-var-src], audio[data-var-src]")) {
|
|
8459
|
+
if (el.closest("[data-variable-values]")) continue;
|
|
8460
|
+
if (!el.getAttribute("src")?.startsWith(`${REMOTE_MEDIA_SUBDIR}/`)) continue;
|
|
8461
|
+
el.removeAttribute("data-var-src");
|
|
8462
|
+
changed = true;
|
|
8463
|
+
}
|
|
8464
|
+
return changed ? document2.toString() : html;
|
|
8410
8465
|
}
|
|
8411
8466
|
async function localizeRemoteImageSources(html, downloadDir) {
|
|
8412
8467
|
const urlSet = /* @__PURE__ */ new Set();
|
|
@@ -8539,13 +8594,13 @@ function projectStylesheetFontFamilies(html, projectDir) {
|
|
|
8539
8594
|
const href = /\bhref=["']([^"']+)["']/i.exec(tag)?.[1];
|
|
8540
8595
|
if (!href || /^(?:[a-z][a-z\d+.-]*:|\/\/)/i.test(href)) continue;
|
|
8541
8596
|
const sheet = resolve7(projectDir, decodedUrlPath(href).replace(/^(?:\.?\/)+/, ""));
|
|
8542
|
-
if (!
|
|
8597
|
+
if (!isPathInside(sheet, projectDir) || !existsSync11(sheet)) continue;
|
|
8543
8598
|
for (const face of extractFontFaceBlocks(readFileSync8(sheet, "utf8"))) {
|
|
8544
8599
|
const family = /font-family\s*:\s*([^;}]+)/i.exec(face)?.[1]?.trim().replace(/^['"]|['"]$/g, "");
|
|
8545
8600
|
const shipsFile = [...face.matchAll(LOCAL_FONTFACE_URL_RE)].some(([, url = ""]) => {
|
|
8546
8601
|
const path = decodedUrlPath(url);
|
|
8547
8602
|
const file = path.startsWith("/") ? resolve7(projectDir, `.${path}`) : resolve7(dirname8(sheet), path);
|
|
8548
|
-
return
|
|
8603
|
+
return isPathInside(file, projectDir) && existsSync11(file);
|
|
8549
8604
|
});
|
|
8550
8605
|
if (family && shipsFile) families.push(family);
|
|
8551
8606
|
}
|
|
@@ -8614,7 +8669,7 @@ async function readLocalFont(absPath) {
|
|
|
8614
8669
|
}
|
|
8615
8670
|
return { kind: "inline", buffer: Buffer.concat(chunks, totalBytes) };
|
|
8616
8671
|
}
|
|
8617
|
-
async function embedLocalFontFaces(html, projectDir, assetRoot) {
|
|
8672
|
+
async function embedLocalFontFaces(html, projectDir, assetRoot, log = defaultLogger) {
|
|
8618
8673
|
const { fontToDataUri: toDataUri } = await import("@hyperframes/core/fonts/embed");
|
|
8619
8674
|
const styleBlockRe = /<style\b[^>]*>([\s\S]*?)<\/style>/gi;
|
|
8620
8675
|
const fontFaceRe = /@font-face\s*\{([^}]*)\}/gi;
|
|
@@ -8635,7 +8690,11 @@ async function embedLocalFontFaces(html, projectDir, assetRoot) {
|
|
|
8635
8690
|
const localPath = urlMatch[1];
|
|
8636
8691
|
if (!localPath || embeddedPaths.has(localPath)) continue;
|
|
8637
8692
|
const absPath = localPath.startsWith("/") ? localPath : resolve7(projectDir, localPath);
|
|
8638
|
-
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
|
+
}
|
|
8639
8698
|
const ext = absPath.match(/\.(woff2?|ttf|otf|ttc)$/i)?.[1]?.toLowerCase() ?? "ttf";
|
|
8640
8699
|
try {
|
|
8641
8700
|
if (fileBackedAbsolutePaths.has(absPath)) {
|
|
@@ -8699,7 +8758,7 @@ function rewriteUnresolvableGsapToCdn(html, projectDir, compSrcPath) {
|
|
|
8699
8758
|
);
|
|
8700
8759
|
}
|
|
8701
8760
|
function rebaseDirectEntryAssetPaths(html, projectDir, htmlPath) {
|
|
8702
|
-
if (!
|
|
8761
|
+
if (!isPathInside(htmlPath, projectDir)) return html;
|
|
8703
8762
|
const entryPath = relative2(projectDir, htmlPath).replace(/\\/g, "/");
|
|
8704
8763
|
if (!entryPath.includes("/")) return html;
|
|
8705
8764
|
const { document: document2 } = parseHTML5(html);
|
|
@@ -8741,9 +8800,10 @@ function bindVariableMediaSources(html, variables) {
|
|
|
8741
8800
|
}
|
|
8742
8801
|
return changed ? document2.toString() : html;
|
|
8743
8802
|
}
|
|
8803
|
+
var entryFileName = (projectDir, htmlPath) => isPathInside(htmlPath, projectDir) ? relative2(projectDir, htmlPath).split(sep3).join("/") : basename5(htmlPath);
|
|
8744
8804
|
async function compileForRender(projectDir, htmlPath, downloadDir, options = {}) {
|
|
8745
8805
|
const assetRoot = options.allowOutsideProjectAssets ? void 0 : projectDir;
|
|
8746
|
-
if (
|
|
8806
|
+
if (isPathInside(htmlPath, projectDir) && escapesAssetRoot(htmlPath, assetRoot)) {
|
|
8747
8807
|
throw new Error(`Entry file ${htmlPath} leads outside the project folder`);
|
|
8748
8808
|
}
|
|
8749
8809
|
const entryHtml = rebaseDirectEntryAssetPaths(readTextFile(htmlPath), projectDir, htmlPath);
|
|
@@ -8855,8 +8915,18 @@ async function compileForRender(projectDir, htmlPath, downloadDir, options = {})
|
|
|
8855
8915
|
if (preparedGifs.length > 0) {
|
|
8856
8916
|
defaultLogger.debug(`[Compiler] Prepared ${preparedGifs.length} animated GIF input(s) as WebM`);
|
|
8857
8917
|
}
|
|
8858
|
-
const embeddedHtml = await embedLocalFontFaces(
|
|
8859
|
-
|
|
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() };
|
|
8860
8930
|
for (const [relPath, absPath] of remoteMediaAssets) {
|
|
8861
8931
|
externalAssets.set(relPath, absPath);
|
|
8862
8932
|
}
|
|
@@ -9427,9 +9497,13 @@ async function runCompileStage(input) {
|
|
|
9427
9497
|
width: compiled.width,
|
|
9428
9498
|
height: compiled.height
|
|
9429
9499
|
};
|
|
9430
|
-
|
|
9431
|
-
|
|
9432
|
-
|
|
9500
|
+
dropMediaOutsideProject({
|
|
9501
|
+
projectDir,
|
|
9502
|
+
workDir,
|
|
9503
|
+
composition,
|
|
9504
|
+
log,
|
|
9505
|
+
allowOutsideProjectAssets: job.config.allowOutsideProjectAssets
|
|
9506
|
+
});
|
|
9433
9507
|
await preflightCompositionAssetMediaTypes({
|
|
9434
9508
|
projectDir,
|
|
9435
9509
|
compiledDir: join20(workDir, "compiled"),
|
|
@@ -10054,9 +10128,13 @@ async function runProbeStage(input) {
|
|
|
10054
10128
|
}
|
|
10055
10129
|
}
|
|
10056
10130
|
}
|
|
10057
|
-
|
|
10058
|
-
|
|
10059
|
-
|
|
10131
|
+
dropMediaOutsideProject({
|
|
10132
|
+
projectDir,
|
|
10133
|
+
workDir,
|
|
10134
|
+
composition,
|
|
10135
|
+
log,
|
|
10136
|
+
allowOutsideProjectAssets: job.config.allowOutsideProjectAssets
|
|
10137
|
+
});
|
|
10060
10138
|
await preflightCompositionAssetMediaTypes({
|
|
10061
10139
|
projectDir,
|
|
10062
10140
|
compiledDir: join21(workDir, "compiled"),
|
|
@@ -12867,7 +12945,7 @@ import {
|
|
|
12867
12945
|
readdirSync as readdirSync5,
|
|
12868
12946
|
readFileSync as readFileSync9,
|
|
12869
12947
|
rmSync as rmSync11,
|
|
12870
|
-
statSync as
|
|
12948
|
+
statSync as statSync9,
|
|
12871
12949
|
writeFileSync as writeFileSync6
|
|
12872
12950
|
} from "node:fs";
|
|
12873
12951
|
import { readFile as readFile2 } from "node:fs/promises";
|
|
@@ -12996,7 +13074,7 @@ async function encodeGifFromDir(framesDir, framePattern, outputPath, input) {
|
|
|
12996
13074
|
const failure = await reencodeWithClearedWholeFrames(argsInput, run, startTime);
|
|
12997
13075
|
if (failure) return failure;
|
|
12998
13076
|
}
|
|
12999
|
-
const fileSize = existsSync20(outputPath) ?
|
|
13077
|
+
const fileSize = existsSync20(outputPath) ? statSync9(outputPath).size : 0;
|
|
13000
13078
|
return {
|
|
13001
13079
|
success: true,
|
|
13002
13080
|
outputPath,
|
|
@@ -13402,7 +13480,7 @@ function sampleDirectoryBytes(dir) {
|
|
|
13402
13480
|
for (const name of entries) {
|
|
13403
13481
|
const full = join32(current, name);
|
|
13404
13482
|
try {
|
|
13405
|
-
const st =
|
|
13483
|
+
const st = statSync10(full);
|
|
13406
13484
|
if (st.isDirectory()) {
|
|
13407
13485
|
stack.push(full);
|
|
13408
13486
|
} else if (st.isFile()) {
|
|
@@ -13557,7 +13635,7 @@ function findMissingFrameRanges(totalFrames, framesDir, frameExt) {
|
|
|
13557
13635
|
let rangeStart = null;
|
|
13558
13636
|
for (let frameIndex = 0; frameIndex < totalFrames; frameIndex++) {
|
|
13559
13637
|
const framePath = join32(framesDir, formatCaptureFrameName(frameIndex, frameExt));
|
|
13560
|
-
const missing = !existsSync21(framePath) ||
|
|
13638
|
+
const missing = !existsSync21(framePath) || statSync10(framePath).size <= 8;
|
|
13561
13639
|
if (missing && rangeStart === null) {
|
|
13562
13640
|
rangeStart = frameIndex;
|
|
13563
13641
|
} else if (!missing && rangeStart !== null) {
|
|
@@ -16895,7 +16973,7 @@ import {
|
|
|
16895
16973
|
rmSync as rmSync14,
|
|
16896
16974
|
writeFileSync as writeFileSync10
|
|
16897
16975
|
} from "node:fs";
|
|
16898
|
-
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";
|
|
16899
16977
|
import {
|
|
16900
16978
|
fpsToNumber as fpsToNumber9,
|
|
16901
16979
|
HF_COLOR_GRADING_ATTR as HF_COLOR_GRADING_ATTR2
|
|
@@ -18604,7 +18682,7 @@ function pathInside(root, path) {
|
|
|
18604
18682
|
function stableSourcePath(roots, srcPath) {
|
|
18605
18683
|
for (const [root, prefix] of roots) {
|
|
18606
18684
|
const rel = pathInside(root, srcPath);
|
|
18607
|
-
if (rel !== null) return [prefix, ...rel.split(
|
|
18685
|
+
if (rel !== null) return [prefix, ...rel.split(sep4)].filter(Boolean).join("/");
|
|
18608
18686
|
}
|
|
18609
18687
|
return srcPath;
|
|
18610
18688
|
}
|
|
@@ -18619,7 +18697,7 @@ function createVideoSourceShipper(input) {
|
|
|
18619
18697
|
for (const root of stagedRel === null ? [input.workCompiledDir, input.projectDir] : []) {
|
|
18620
18698
|
const rel = pathInside(root, srcPath);
|
|
18621
18699
|
if (rel !== null && (existsSync26(join41(input.planDir, "compiled", rel)) || input.isRemote(srcPath))) {
|
|
18622
|
-
result = ["compiled", ...rel.split(
|
|
18700
|
+
result = ["compiled", ...rel.split(sep4)].join("/");
|
|
18623
18701
|
break;
|
|
18624
18702
|
}
|
|
18625
18703
|
}
|
|
@@ -18694,8 +18772,10 @@ async function compilePlanComposition(projectDir, config, planDir, options) {
|
|
|
18694
18772
|
filter: (src) => {
|
|
18695
18773
|
const rel = relative6(projectDir, src);
|
|
18696
18774
|
if (rel === "" || rel.startsWith("..")) return true;
|
|
18697
|
-
if (
|
|
18698
|
-
|
|
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];
|
|
18699
18779
|
return firstSegment === void 0 || !PLAN_PROJECT_DIR_SKIP_SEGMENTS.has(firstSegment);
|
|
18700
18780
|
}
|
|
18701
18781
|
});
|
|
@@ -19194,11 +19274,11 @@ import {
|
|
|
19194
19274
|
readFileSync as readFileSync13,
|
|
19195
19275
|
readdirSync as readdirSync10,
|
|
19196
19276
|
rmSync as rmSync16,
|
|
19197
|
-
statSync as
|
|
19277
|
+
statSync as statSync12,
|
|
19198
19278
|
writeFileSync as writeFileSync12
|
|
19199
19279
|
} from "node:fs";
|
|
19200
19280
|
import { tmpdir as tmpdir3 } from "node:os";
|
|
19201
|
-
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";
|
|
19202
19282
|
import { DISTRIBUTED_FPS, isDistributedFps } from "@hyperframes/core";
|
|
19203
19283
|
import {
|
|
19204
19284
|
createFrameLookupTable as createFrameLookupTable5,
|
|
@@ -19213,7 +19293,7 @@ import {
|
|
|
19213
19293
|
linkSync as linkSync2,
|
|
19214
19294
|
mkdirSync as mkdirSync17,
|
|
19215
19295
|
rmSync as rmSync15,
|
|
19216
|
-
statSync as
|
|
19296
|
+
statSync as statSync11,
|
|
19217
19297
|
writeFileSync as writeFileSync11
|
|
19218
19298
|
} from "node:fs";
|
|
19219
19299
|
import { renameWithRetry as renameWithRetry9 } from "@hyperframes/engine";
|
|
@@ -19288,7 +19368,7 @@ var LocalPlanV2ArtifactPublisher = class {
|
|
|
19288
19368
|
}
|
|
19289
19369
|
async putBlob(blob) {
|
|
19290
19370
|
const digest = assertPlanV2Sha256(blob.sha256, "published blob sha256");
|
|
19291
|
-
const sourceSize =
|
|
19371
|
+
const sourceSize = statSync11(blob.sourcePath).size;
|
|
19292
19372
|
if (sourceSize !== blob.sizeBytes) {
|
|
19293
19373
|
throw new PlanV2IntegrityError(
|
|
19294
19374
|
`published blob size changed for ${digest}: expected ${blob.sizeBytes}, got ${sourceSize}`
|
|
@@ -19370,7 +19450,7 @@ function listFiles(root) {
|
|
|
19370
19450
|
walk(absolutePath);
|
|
19371
19451
|
} else if (entry.isFile()) {
|
|
19372
19452
|
files.push({
|
|
19373
|
-
path: relative7(rootResolved, absolutePath).split(
|
|
19453
|
+
path: relative7(rootResolved, absolutePath).split(sep5).join("/"),
|
|
19374
19454
|
absolutePath
|
|
19375
19455
|
});
|
|
19376
19456
|
} else {
|
|
@@ -19410,7 +19490,7 @@ function isExtractionCacheCompleteSentinelPath(path) {
|
|
|
19410
19490
|
function resolveExtractedVideoOutputDir(planDir, videoId) {
|
|
19411
19491
|
const videoRoot = resolve10(planDir, "video-frames");
|
|
19412
19492
|
const outputDir = resolve10(videoRoot, mediaIdPathSegment4(videoId));
|
|
19413
|
-
if (outputDir === videoRoot || !outputDir.startsWith(`${videoRoot}${
|
|
19493
|
+
if (outputDir === videoRoot || !outputDir.startsWith(`${videoRoot}${sep5}`)) {
|
|
19414
19494
|
throw new PlanV2IntegrityError(`unsafe extracted video id: ${JSON.stringify(videoId)}`);
|
|
19415
19495
|
}
|
|
19416
19496
|
return outputDir;
|
|
@@ -19570,7 +19650,7 @@ function collectChunkVideoDependencies(input) {
|
|
|
19570
19650
|
for (let frame = chunk.startFrame; frame < chunk.endFrame; frame++) {
|
|
19571
19651
|
const globalTime = frame * input.fpsDen / input.fpsNum;
|
|
19572
19652
|
for (const [videoId, payload] of input.table.getActiveFramePayloads(globalTime)) {
|
|
19573
|
-
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("/");
|
|
19574
19654
|
assertSafeRelativePath(path);
|
|
19575
19655
|
const indexes = mutable.get(path) ?? /* @__PURE__ */ new Set();
|
|
19576
19656
|
indexes.add(chunk.index);
|
|
@@ -19602,7 +19682,7 @@ function publishBlobFor(absolutePath, digests) {
|
|
|
19602
19682
|
return {
|
|
19603
19683
|
sourcePath: absolutePath,
|
|
19604
19684
|
sha256: planFileSha256(absolutePath, digests),
|
|
19605
|
-
sizeBytes:
|
|
19685
|
+
sizeBytes: statSync12(absolutePath).size
|
|
19606
19686
|
};
|
|
19607
19687
|
}
|
|
19608
19688
|
async function putBlobs(publisher, blobs) {
|
|
@@ -19970,7 +20050,7 @@ function verifyBlob(planV2Dir, artifact) {
|
|
|
19970
20050
|
if (!existsSync28(sourcePath)) {
|
|
19971
20051
|
throw new PlanV2IntegrityError(`missing content-addressed artifact ${artifact.sha256}`);
|
|
19972
20052
|
}
|
|
19973
|
-
const stats =
|
|
20053
|
+
const stats = statSync12(sourcePath);
|
|
19974
20054
|
if (!stats.isFile() || stats.size !== artifact.sizeBytes) {
|
|
19975
20055
|
throw new PlanV2IntegrityError(`artifact size mismatch for ${artifact.path}`);
|
|
19976
20056
|
}
|
|
@@ -20063,7 +20143,7 @@ function readValidatedPlanV2Materialization(planDir, expectedTarget) {
|
|
|
20063
20143
|
for (const artifact of required) {
|
|
20064
20144
|
if (Object.hasOwn(remoteSources, artifact.path)) continue;
|
|
20065
20145
|
const path = join44(planDir, ...artifact.path.split("/"));
|
|
20066
|
-
if (!existsSync28(path) ||
|
|
20146
|
+
if (!existsSync28(path) || statSync12(path).size !== artifact.sizeBytes) {
|
|
20067
20147
|
throw new PlanV2IntegrityError(
|
|
20068
20148
|
`materialized artifact missing or truncated: ${artifact.path}`
|
|
20069
20149
|
);
|
|
@@ -21469,7 +21549,7 @@ import {
|
|
|
21469
21549
|
import {
|
|
21470
21550
|
existsSync as existsSync32,
|
|
21471
21551
|
mkdirSync as mkdirSync21,
|
|
21472
|
-
statSync as
|
|
21552
|
+
statSync as statSync14,
|
|
21473
21553
|
mkdtempSync as mkdtempSync2,
|
|
21474
21554
|
writeFileSync as writeFileSync14,
|
|
21475
21555
|
rmSync as rmSync19,
|
|
@@ -21492,13 +21572,13 @@ import {
|
|
|
21492
21572
|
import {
|
|
21493
21573
|
existsSync as existsSync30,
|
|
21494
21574
|
readFileSync as readFileSync16,
|
|
21495
|
-
statSync as
|
|
21575
|
+
statSync as statSync13,
|
|
21496
21576
|
openSync as openSync7,
|
|
21497
21577
|
fstatSync as fstatSync3,
|
|
21498
21578
|
closeSync as closeSync7,
|
|
21499
21579
|
constants as constants3
|
|
21500
21580
|
} from "node:fs";
|
|
21501
|
-
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";
|
|
21502
21582
|
import { lintHyperframeHtml } from "@hyperframes/lint";
|
|
21503
21583
|
function isStringRecord(value) {
|
|
21504
21584
|
if (!value || typeof value !== "object" || Array.isArray(value)) {
|
|
@@ -21532,7 +21612,7 @@ function readEntryHtml(filePath) {
|
|
|
21532
21612
|
} catch (error) {
|
|
21533
21613
|
if (error instanceof Error && "code" in error && (error.code === "ENOENT" || error.code === "ENOTDIR"))
|
|
21534
21614
|
return null;
|
|
21535
|
-
if (!
|
|
21615
|
+
if (!statSync13(filePath, { throwIfNoEntry: false })?.isFile()) return null;
|
|
21536
21616
|
throw error;
|
|
21537
21617
|
}
|
|
21538
21618
|
try {
|
|
@@ -21544,7 +21624,7 @@ function readEntryHtml(filePath) {
|
|
|
21544
21624
|
}
|
|
21545
21625
|
function readProjectEntryFile(projectDir, preferredEntryFile) {
|
|
21546
21626
|
const absProjectDir = resolve11(projectDir);
|
|
21547
|
-
if (!existsSync30(absProjectDir) || !
|
|
21627
|
+
if (!existsSync30(absProjectDir) || !statSync13(absProjectDir).isDirectory()) {
|
|
21548
21628
|
return { error: `Project directory not found: ${absProjectDir}` };
|
|
21549
21629
|
}
|
|
21550
21630
|
const entryCandidates = [preferredEntryFile, "index.html", "src/index.html"].filter(
|
|
@@ -21553,7 +21633,7 @@ function readProjectEntryFile(projectDir, preferredEntryFile) {
|
|
|
21553
21633
|
for (const entryFile of entryCandidates) {
|
|
21554
21634
|
const absoluteEntryPath = resolve11(absProjectDir, entryFile);
|
|
21555
21635
|
const entryRelativePath = relative8(absProjectDir, absoluteEntryPath);
|
|
21556
|
-
if (entryRelativePath === ".." || entryRelativePath.startsWith(`..${
|
|
21636
|
+
if (entryRelativePath === ".." || entryRelativePath.startsWith(`..${sep6}`) || isAbsolute5(entryRelativePath)) {
|
|
21557
21637
|
return { error: `Entry file must stay inside project directory: ${entryFile}` };
|
|
21558
21638
|
}
|
|
21559
21639
|
const html = readEntryHtml(absoluteEntryPath);
|
|
@@ -21912,7 +21992,7 @@ function prepareProjectDirectory(projectDir, options) {
|
|
|
21912
21992
|
const candidate = nonEmptyString(projectDir);
|
|
21913
21993
|
if (!candidate) return null;
|
|
21914
21994
|
const absProjectDir = resolve12(candidate);
|
|
21915
|
-
if (!existsSync32(absProjectDir) || !
|
|
21995
|
+
if (!existsSync32(absProjectDir) || !statSync14(absProjectDir).isDirectory()) {
|
|
21916
21996
|
return { error: `Project directory not found: ${absProjectDir}` };
|
|
21917
21997
|
}
|
|
21918
21998
|
const entry = options.entryFile || "index.html";
|
|
@@ -22008,7 +22088,7 @@ function cleanupTempDir(dir, log) {
|
|
|
22008
22088
|
}
|
|
22009
22089
|
}
|
|
22010
22090
|
function outputFileSize(path) {
|
|
22011
|
-
return existsSync32(path) ?
|
|
22091
|
+
return existsSync32(path) ? statSync14(path).size : 0;
|
|
22012
22092
|
}
|
|
22013
22093
|
function createBlockingProgressReporter(log, requestId) {
|
|
22014
22094
|
let lastLoggedPct = -10;
|
|
@@ -22325,7 +22405,7 @@ function createRenderHandlers(options = {}) {
|
|
|
22325
22405
|
store.delete(token);
|
|
22326
22406
|
return c.json({ success: false, error: "Output artifact file missing" }, 404);
|
|
22327
22407
|
}
|
|
22328
|
-
const stats =
|
|
22408
|
+
const stats = statSync14(artifact.path);
|
|
22329
22409
|
return new Response(createReadStream5(artifact.path), {
|
|
22330
22410
|
headers: {
|
|
22331
22411
|
"content-type": "video/mp4",
|
|
@@ -22449,7 +22529,7 @@ import {
|
|
|
22449
22529
|
readFileSync as readFileSync17,
|
|
22450
22530
|
readdirSync as readdirSync12,
|
|
22451
22531
|
rmSync as rmSync20,
|
|
22452
|
-
statSync as
|
|
22532
|
+
statSync as statSync15,
|
|
22453
22533
|
writeFileSync as writeFileSync15
|
|
22454
22534
|
} from "node:fs";
|
|
22455
22535
|
import { basename as basename8, dirname as dirname20, join as join50 } from "node:path";
|
|
@@ -22494,7 +22574,7 @@ async function assemble(planDir, chunkOutputs, audioPath, outputPath, options) {
|
|
|
22494
22574
|
outputPath,
|
|
22495
22575
|
durationMs: Date.now() - start,
|
|
22496
22576
|
framesEncoded: plan2.totalFrames,
|
|
22497
|
-
fileSize:
|
|
22577
|
+
fileSize: statSync15(outputPath).size
|
|
22498
22578
|
};
|
|
22499
22579
|
}
|
|
22500
22580
|
const format = plan2.dimensions.format;
|
|
@@ -22541,7 +22621,7 @@ async function assemble(planDir, chunkOutputs, audioPath, outputPath, options) {
|
|
|
22541
22621
|
});
|
|
22542
22622
|
}
|
|
22543
22623
|
}
|
|
22544
|
-
const fileSize = existsSync33(outputPath) ?
|
|
22624
|
+
const fileSize = existsSync33(outputPath) ? statSync15(outputPath).size : 0;
|
|
22545
22625
|
return {
|
|
22546
22626
|
...referenceBackgroundResult8(plan2[REFERENCE_BACKGROUND_FIELD6]),
|
|
22547
22627
|
outputPath,
|
|
@@ -22739,7 +22819,7 @@ function mergePngFrameDirs(chunkPaths, outputPath, totalFrames, audioPath, start
|
|
|
22739
22819
|
mkdirSync22(outputPath, { recursive: true });
|
|
22740
22820
|
let globalIdx = 0;
|
|
22741
22821
|
for (const chunkDir of chunkPaths) {
|
|
22742
|
-
if (!
|
|
22822
|
+
if (!statSync15(chunkDir).isDirectory()) {
|
|
22743
22823
|
throw new Error(
|
|
22744
22824
|
`[assemble] png-sequence chunk must be a directory: ${chunkDir} (got a file)`
|
|
22745
22825
|
);
|
|
@@ -22766,7 +22846,7 @@ function mergePngFrameDirs(chunkPaths, outputPath, totalFrames, audioPath, start
|
|
|
22766
22846
|
let fileSize = 0;
|
|
22767
22847
|
for (const name of readdirSync12(outputPath)) {
|
|
22768
22848
|
try {
|
|
22769
|
-
fileSize +=
|
|
22849
|
+
fileSize += statSync15(join50(outputPath, name)).size;
|
|
22770
22850
|
} catch {
|
|
22771
22851
|
}
|
|
22772
22852
|
}
|