@hyperframes/producer 0.9.55 → 0.9.58
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/README.md +1 -1
- package/dist/distributed.d.ts +1 -1
- package/dist/distributed.js +316 -119
- package/dist/hyperframe.manifest.json +1 -1
- package/dist/hyperframe.runtime.iife.js +76 -76
- package/dist/index.js +456 -123
- package/dist/logger.d.ts +1 -1
- package/dist/public-server.js +448 -120
- package/dist/services/assetMediaType.d.ts +1 -1
- package/dist/services/distributed/projectHash.d.ts +8 -2
- package/dist/services/htmlTagScans.d.ts +57 -0
- package/dist/services/render/stages/captureHdrResources.d.ts +19 -4
- package/package.json +7 -7
package/dist/distributed.js
CHANGED
|
@@ -31,6 +31,7 @@ import {
|
|
|
31
31
|
} from "@hyperframes/engine";
|
|
32
32
|
|
|
33
33
|
// src/logger.ts
|
|
34
|
+
import { terminalText } from "@hyperframes/core";
|
|
34
35
|
var LOG_LEVEL_PRIORITY = {
|
|
35
36
|
error: 0,
|
|
36
37
|
warn: 1,
|
|
@@ -40,26 +41,26 @@ var LOG_LEVEL_PRIORITY = {
|
|
|
40
41
|
function createConsoleLogger(level = "info") {
|
|
41
42
|
const threshold = LOG_LEVEL_PRIORITY[level];
|
|
42
43
|
const shouldLog = (msgLevel) => LOG_LEVEL_PRIORITY[msgLevel] <= threshold;
|
|
43
|
-
const formatMeta = (meta) => meta ? ` ${JSON.stringify(meta)}` : "";
|
|
44
|
+
const formatMeta = (meta) => meta ? ` ${terminalText(JSON.stringify(meta))}` : "";
|
|
44
45
|
return {
|
|
45
46
|
error(message, meta) {
|
|
46
47
|
if (shouldLog("error")) {
|
|
47
|
-
console.error(`[ERROR] ${message}${formatMeta(meta)}`);
|
|
48
|
+
console.error(`[ERROR] ${terminalText(message)}${formatMeta(meta)}`);
|
|
48
49
|
}
|
|
49
50
|
},
|
|
50
51
|
warn(message, meta) {
|
|
51
52
|
if (shouldLog("warn")) {
|
|
52
|
-
console.warn(`[WARN] ${message}${formatMeta(meta)}`);
|
|
53
|
+
console.warn(`[WARN] ${terminalText(message)}${formatMeta(meta)}`);
|
|
53
54
|
}
|
|
54
55
|
},
|
|
55
56
|
info(message, meta) {
|
|
56
57
|
if (shouldLog("info")) {
|
|
57
|
-
console.error(`[INFO] ${message}${formatMeta(meta)}`);
|
|
58
|
+
console.error(`[INFO] ${terminalText(message)}${formatMeta(meta)}`);
|
|
58
59
|
}
|
|
59
60
|
},
|
|
60
61
|
debug(message, meta) {
|
|
61
62
|
if (shouldLog("debug")) {
|
|
62
|
-
console.error(`[DEBUG] ${message}${formatMeta(meta)}`);
|
|
63
|
+
console.error(`[DEBUG] ${terminalText(message)}${formatMeta(meta)}`);
|
|
63
64
|
}
|
|
64
65
|
},
|
|
65
66
|
isLevelEnabled(msgLevel) {
|
|
@@ -160,7 +161,177 @@ import {
|
|
|
160
161
|
toFps as toFps2
|
|
161
162
|
} from "@hyperframes/core";
|
|
162
163
|
import { HF_AUDIO_GROUP_TAG } from "@hyperframes/core/audio-groups";
|
|
163
|
-
|
|
164
|
+
|
|
165
|
+
// src/services/htmlTagScans.ts
|
|
166
|
+
function forwardFinder(text, pattern) {
|
|
167
|
+
let start = -1;
|
|
168
|
+
let found = null;
|
|
169
|
+
return (from) => {
|
|
170
|
+
if (start < 0 || from < start || found !== null && from > found.index) {
|
|
171
|
+
start = from;
|
|
172
|
+
pattern.lastIndex = from;
|
|
173
|
+
found = pattern.exec(text);
|
|
174
|
+
}
|
|
175
|
+
return found;
|
|
176
|
+
};
|
|
177
|
+
}
|
|
178
|
+
function indexFinder(text, pattern) {
|
|
179
|
+
const find = forwardFinder(text, pattern);
|
|
180
|
+
return (from) => find(from)?.index ?? -1;
|
|
181
|
+
}
|
|
182
|
+
function* inlineScriptBlocks(html) {
|
|
183
|
+
const opener = /<script\b/gi;
|
|
184
|
+
const closer = /<\/script>/gi;
|
|
185
|
+
for (let open2 = opener.exec(html); open2; open2 = opener.exec(html)) {
|
|
186
|
+
const attrsStart = open2.index + open2[0].length;
|
|
187
|
+
const gt = html.indexOf(">", attrsStart);
|
|
188
|
+
if (gt < 0) return;
|
|
189
|
+
closer.lastIndex = gt + 1;
|
|
190
|
+
const close = closer.exec(html);
|
|
191
|
+
if (!close) return;
|
|
192
|
+
yield { attrs: html.slice(attrsStart, gt), body: html.slice(gt + 1, close.index) };
|
|
193
|
+
opener.lastIndex = close.index + close[0].length;
|
|
194
|
+
}
|
|
195
|
+
}
|
|
196
|
+
function removeDelimitedRuns(source, start, end) {
|
|
197
|
+
let out = "";
|
|
198
|
+
let kept = 0;
|
|
199
|
+
for (let open2 = source.indexOf(start); open2 >= 0; open2 = source.indexOf(start, kept)) {
|
|
200
|
+
const close = source.indexOf(end, open2 + start.length);
|
|
201
|
+
if (close < 0) break;
|
|
202
|
+
out += source.slice(kept, open2);
|
|
203
|
+
kept = close + end.length;
|
|
204
|
+
}
|
|
205
|
+
return out + source.slice(kept);
|
|
206
|
+
}
|
|
207
|
+
function gsapDistFile(value) {
|
|
208
|
+
let dist = -1;
|
|
209
|
+
const distPattern = /\/dist\//gi;
|
|
210
|
+
for (let m = distPattern.exec(value); m; m = distPattern.exec(value)) {
|
|
211
|
+
if (m.index + 6 < value.length) dist = m.index;
|
|
212
|
+
distPattern.lastIndex = m.index + 1;
|
|
213
|
+
}
|
|
214
|
+
const gsap = dist < 0 ? null : /gsap/i.exec(value);
|
|
215
|
+
return gsap && gsap.index + 4 <= dist ? value.slice(dist + 6) : void 0;
|
|
216
|
+
}
|
|
217
|
+
function lastGsapMatch(html, finders, tagStart, gt) {
|
|
218
|
+
const { nextSrc, nextQuote, nextGt } = finders;
|
|
219
|
+
let match;
|
|
220
|
+
for (let src = nextSrc(tagStart); src && src.index < gt; src = nextSrc(src.index + 1)) {
|
|
221
|
+
const valueStart = src.index + 5;
|
|
222
|
+
const close = nextQuote(valueStart);
|
|
223
|
+
const end = close < 0 ? -1 : nextGt(close + 1);
|
|
224
|
+
if (end < 0) return { match, laterTagsFail: true };
|
|
225
|
+
const file = gsapDistFile(html.slice(valueStart, close));
|
|
226
|
+
if (file !== void 0) match = { valueStart, close, end, file };
|
|
227
|
+
}
|
|
228
|
+
return { match, laterTagsFail: false };
|
|
229
|
+
}
|
|
230
|
+
function replaceGsapDistScripts(html, replace) {
|
|
231
|
+
const opener = /<script\b/gi;
|
|
232
|
+
const finders = {
|
|
233
|
+
nextSrc: forwardFinder(html, /\bsrc=["']/gi),
|
|
234
|
+
nextQuote: indexFinder(html, /["']/g),
|
|
235
|
+
nextGt: indexFinder(html, />/g)
|
|
236
|
+
};
|
|
237
|
+
let out = "";
|
|
238
|
+
let kept = 0;
|
|
239
|
+
for (let open2 = opener.exec(html); open2; open2 = opener.exec(html)) {
|
|
240
|
+
const gt = finders.nextGt(open2.index);
|
|
241
|
+
if (gt < 0) break;
|
|
242
|
+
const { match, laterTagsFail } = lastGsapMatch(html, finders, open2.index, gt);
|
|
243
|
+
if (match) {
|
|
244
|
+
const { valueStart, close, end, file } = match;
|
|
245
|
+
const full = html.slice(open2.index, end + 1);
|
|
246
|
+
const src = html.slice(valueStart, close);
|
|
247
|
+
out += html.slice(kept, open2.index);
|
|
248
|
+
out += replace(
|
|
249
|
+
full,
|
|
250
|
+
html.slice(open2.index, valueStart),
|
|
251
|
+
src,
|
|
252
|
+
file,
|
|
253
|
+
html.slice(close, end + 1)
|
|
254
|
+
);
|
|
255
|
+
kept = end + 1;
|
|
256
|
+
}
|
|
257
|
+
if (laterTagsFail) break;
|
|
258
|
+
opener.lastIndex = match ? kept : gt;
|
|
259
|
+
}
|
|
260
|
+
return out + html.slice(kept);
|
|
261
|
+
}
|
|
262
|
+
function removeSpanPerTag(html, opener, spanIn) {
|
|
263
|
+
const nextGt = indexFinder(html, />/g);
|
|
264
|
+
let out = "";
|
|
265
|
+
let kept = 0;
|
|
266
|
+
for (let open2 = opener.exec(html); open2; open2 = opener.exec(html)) {
|
|
267
|
+
const attrsStart = open2.index + open2[0].length;
|
|
268
|
+
const gt = nextGt(attrsStart);
|
|
269
|
+
const span = spanIn(attrsStart, gt < 0 ? html.length : gt);
|
|
270
|
+
if (span) {
|
|
271
|
+
out += html.slice(kept, span[0]);
|
|
272
|
+
kept = span[1];
|
|
273
|
+
} else if (gt < 0) break;
|
|
274
|
+
opener.lastIndex = span ? kept : gt;
|
|
275
|
+
}
|
|
276
|
+
return out + html.slice(kept);
|
|
277
|
+
}
|
|
278
|
+
function stripCrossoriginAttr(html, tagName) {
|
|
279
|
+
const nextQuote = indexFinder(html, /["']/g);
|
|
280
|
+
const nextAttr = forwardFinder(html, /\scrossorigin/gi);
|
|
281
|
+
return removeSpanPerTag(html, new RegExp(`<${tagName}\\b`, "gi"), (attrsStart, tagEnd) => {
|
|
282
|
+
let last = -1;
|
|
283
|
+
for (let at = nextAttr(attrsStart); at && at.index < tagEnd; at = nextAttr(at.index + 12)) {
|
|
284
|
+
last = at.index;
|
|
285
|
+
}
|
|
286
|
+
if (last < 0) return void 0;
|
|
287
|
+
const nameEnd = last + 12;
|
|
288
|
+
const quote = html[nameEnd + 1];
|
|
289
|
+
const quoted = html[nameEnd] === "=" && (quote === '"' || quote === "'");
|
|
290
|
+
const close = quoted ? nextQuote(nameEnd + 2) : -1;
|
|
291
|
+
return [last, close < 0 ? nameEnd : close + 1];
|
|
292
|
+
});
|
|
293
|
+
}
|
|
294
|
+
function stripPreloadNone(html) {
|
|
295
|
+
const nextAttr = forwardFinder(html, /(?<!\s)\s+preload\s*=\s*["']none["']/gi);
|
|
296
|
+
return removeSpanPerTag(html, /<(?:video|audio)\b/gi, (attrsStart, tagEnd) => {
|
|
297
|
+
const attr = nextAttr(attrsStart);
|
|
298
|
+
return attr && attr.index < tagEnd ? [attr.index, attr.index + attr[0].length] : void 0;
|
|
299
|
+
});
|
|
300
|
+
}
|
|
301
|
+
var REMOTE_SRC_TAGS = {
|
|
302
|
+
media: { opener: "<(?:video|audio)\\b", attr: /\bsrc\s*=\s*["'](https?:\/\/)/gi },
|
|
303
|
+
source: { opener: "<source\\b", attr: /\bsrc\s*=\s*["'](https?:\/\/)/gi },
|
|
304
|
+
img: { opener: "<img\\b", attr: /(?<![\w-])src\s*=\s*["'](https?:\/\/)/gi }
|
|
305
|
+
};
|
|
306
|
+
function remoteSrcUrls(html, tag) {
|
|
307
|
+
const opener = new RegExp(REMOTE_SRC_TAGS[tag].opener, "gi");
|
|
308
|
+
const nextAttr = forwardFinder(html, new RegExp(REMOTE_SRC_TAGS[tag].attr));
|
|
309
|
+
const nextGt = indexFinder(html, />/g);
|
|
310
|
+
const nextQuote = indexFinder(html, /["']/g);
|
|
311
|
+
const urls = [];
|
|
312
|
+
for (let open2 = opener.exec(html); open2; open2 = opener.exec(html)) {
|
|
313
|
+
const attrsStart = open2.index + open2[0].length;
|
|
314
|
+
const gt = nextGt(attrsStart);
|
|
315
|
+
if (gt < 0) break;
|
|
316
|
+
let resumeAt = gt;
|
|
317
|
+
for (let attr = nextAttr(attrsStart); attr && attr.index < gt; attr = nextAttr(attr.index + 1)) {
|
|
318
|
+
const urlRest = attr.index + attr[0].length;
|
|
319
|
+
const close = nextQuote(urlRest);
|
|
320
|
+
if (close < 0) return urls;
|
|
321
|
+
if (close === urlRest) continue;
|
|
322
|
+
const end = nextGt(close + 1);
|
|
323
|
+
if (end < 0) return urls;
|
|
324
|
+
urls.push(html.slice(urlRest - attr[1].length, close));
|
|
325
|
+
resumeAt = end + 1;
|
|
326
|
+
break;
|
|
327
|
+
}
|
|
328
|
+
opener.lastIndex = resumeAt;
|
|
329
|
+
}
|
|
330
|
+
return urls;
|
|
331
|
+
}
|
|
332
|
+
|
|
333
|
+
// src/services/renderOrchestrator.ts
|
|
334
|
+
import { matchHtmlBodyCssHeightFirst, matchHtmlBodyCssWidthFirst } from "@hyperframes/parsers";
|
|
164
335
|
import {
|
|
165
336
|
extractMediaMetadata as extractMediaMetadata5,
|
|
166
337
|
resolveConfig as resolveConfig2,
|
|
@@ -222,7 +393,7 @@ import { join as join2, extname, resolve as resolve2, sep as sep2 } from "node:p
|
|
|
222
393
|
import { injectScriptsAtHeadStart, injectScriptsIntoHtml } from "@hyperframes/core/compiler";
|
|
223
394
|
import { injectTagsAtHeadStart } from "@hyperframes/core/compiler/html-document";
|
|
224
395
|
import { PREVIEW_FOR_ANOTHER_SITE_META } from "@hyperframes/core/studio-preview-mark";
|
|
225
|
-
import { fpsToNumber } from "@hyperframes/core";
|
|
396
|
+
import { fpsToNumber, terminalText as terminalText2 } from "@hyperframes/core";
|
|
226
397
|
import { isPrivateFileUnder, isStudioPrivatePath } from "@hyperframes/core/safe-path";
|
|
227
398
|
import { stripSdrPngColourTags } from "@hyperframes/core/compiler/png-colour-tags";
|
|
228
399
|
import { openRangeEnd } from "@hyperframes/studio-server/media-range";
|
|
@@ -871,7 +1042,7 @@ function createFileServer(options) {
|
|
|
871
1042
|
const headScripts = options.headScripts ?? [getVerifiedHyperframeRuntimeSource()];
|
|
872
1043
|
const bodyScripts = options.bodyScripts ?? [buildRenderModeScript(options.fps), HF_BRIDGE_SCRIPT];
|
|
873
1044
|
const app = new Hono();
|
|
874
|
-
const warnLeftOut = (line) => console.warn(`[FileServer] ${line}`);
|
|
1045
|
+
const warnLeftOut = (line) => console.warn(`[FileServer] ${terminalText2(line)}`);
|
|
875
1046
|
let listeningPort = -1;
|
|
876
1047
|
app.use(async function loadEachFileOnlyAsItsNamedType(c, next) {
|
|
877
1048
|
await next();
|
|
@@ -895,7 +1066,7 @@ function createFileServer(options) {
|
|
|
895
1066
|
}
|
|
896
1067
|
if (!file) {
|
|
897
1068
|
if (!/favicon\.ico$/i.test(requestPath)) {
|
|
898
|
-
console.warn(`[FileServer] 404 Not Found: ${requestPath}`);
|
|
1069
|
+
console.warn(`[FileServer] 404 Not Found: ${terminalText2(requestPath)}`);
|
|
899
1070
|
}
|
|
900
1071
|
return c.text("Not found", 404);
|
|
901
1072
|
}
|
|
@@ -1062,7 +1233,8 @@ import {
|
|
|
1062
1233
|
import { basename as basename2, dirname as dirname2, isAbsolute, join as join3, relative, resolve as resolve3 } from "node:path";
|
|
1063
1234
|
import {
|
|
1064
1235
|
CANVAS_DIMENSIONS,
|
|
1065
|
-
checkOutputResolutionCompatibility
|
|
1236
|
+
checkOutputResolutionCompatibility,
|
|
1237
|
+
terminalText as terminalText3
|
|
1066
1238
|
} from "@hyperframes/core";
|
|
1067
1239
|
import {
|
|
1068
1240
|
mediaIdPathSegment
|
|
@@ -1097,7 +1269,7 @@ function writeCompiledArtifacts(compiled, workDir, includeSummary) {
|
|
|
1097
1269
|
for (const [srcPath, html] of compiled.subCompositions) {
|
|
1098
1270
|
const outPath = join3(compileDir, srcPath);
|
|
1099
1271
|
if (!isPathInside(outPath, compileDir)) {
|
|
1100
|
-
console.warn(`[Render] Skipping sub-composition with unsafe path: ${srcPath}`);
|
|
1272
|
+
console.warn(`[Render] Skipping sub-composition with unsafe path: ${terminalText3(srcPath)}`);
|
|
1101
1273
|
continue;
|
|
1102
1274
|
}
|
|
1103
1275
|
mkdirSync(dirname2(outPath), { recursive: true });
|
|
@@ -1106,7 +1278,9 @@ function writeCompiledArtifacts(compiled, workDir, includeSummary) {
|
|
|
1106
1278
|
for (const [relativePath, absolutePath] of compiled.externalAssets) {
|
|
1107
1279
|
const outPath = resolve3(join3(compileDir, relativePath));
|
|
1108
1280
|
if (!isPathInside(outPath, compileDir)) {
|
|
1109
|
-
console.warn(
|
|
1281
|
+
console.warn(
|
|
1282
|
+
`[Render] Skipping external asset with unsafe path: ${terminalText3(relativePath)}`
|
|
1283
|
+
);
|
|
1110
1284
|
continue;
|
|
1111
1285
|
}
|
|
1112
1286
|
mkdirSync(dirname2(outPath), { recursive: true });
|
|
@@ -1549,6 +1723,7 @@ import {
|
|
|
1549
1723
|
resolveProjectRelativeSrc,
|
|
1550
1724
|
resolveVideoExtractionWindow,
|
|
1551
1725
|
runFfmpeg,
|
|
1726
|
+
urlInputArgs,
|
|
1552
1727
|
videoStartOnMediaTimeline
|
|
1553
1728
|
} from "@hyperframes/engine";
|
|
1554
1729
|
import { fpsToFfmpegArg, fpsToNumber as fpsToNumber3 } from "@hyperframes/core";
|
|
@@ -2288,7 +2463,8 @@ import {
|
|
|
2288
2463
|
rewriteAssetPath,
|
|
2289
2464
|
rewriteAssetPaths,
|
|
2290
2465
|
rewriteCssAssetUrls,
|
|
2291
|
-
rewriteInlineStyleAssetUrls
|
|
2466
|
+
rewriteInlineStyleAssetUrls,
|
|
2467
|
+
terminalText as terminalText4
|
|
2292
2468
|
} from "@hyperframes/core";
|
|
2293
2469
|
import { MAX_AUDIO_GAIN } from "@hyperframes/core/audio-gain";
|
|
2294
2470
|
import { CAPTURE_CANVAS_SELECTOR } from "@hyperframes/core/html-in-canvas";
|
|
@@ -2499,6 +2675,7 @@ function placeAudio(audio, window2) {
|
|
|
2499
2675
|
import {
|
|
2500
2676
|
analyzeKeyframeIntervals,
|
|
2501
2677
|
assertMediaPayload,
|
|
2678
|
+
isPrivateUnderAssetRoots as isPrivateUnderAssetRoots3,
|
|
2502
2679
|
NotMediaPayloadError as NotMediaPayloadError2,
|
|
2503
2680
|
parseMasterFxChain,
|
|
2504
2681
|
probeMediaProfile as probeMediaProfile2
|
|
@@ -2526,7 +2703,13 @@ import { copyFileSync as copyFileSync2, existsSync as existsSync5, mkdirSync as
|
|
|
2526
2703
|
import { dirname as dirname4, isAbsolute as isAbsolute2, join as join6, resolve as resolve4 } from "node:path";
|
|
2527
2704
|
import { parseHTML as parseHTML3 } from "linkedom";
|
|
2528
2705
|
import { parseAnimatedGifMetadata } from "@hyperframes/core";
|
|
2529
|
-
import {
|
|
2706
|
+
import {
|
|
2707
|
+
DEFAULT_VP9_CPU_USED,
|
|
2708
|
+
isPrivateUnderAssetRoots,
|
|
2709
|
+
runFfmpeg as runFfmpeg2,
|
|
2710
|
+
renameWithRetry as renameWithRetry3,
|
|
2711
|
+
urlInputArgs as urlInputArgs2
|
|
2712
|
+
} from "@hyperframes/engine";
|
|
2530
2713
|
import { namesAnotherNetworkRoot } from "@hyperframes/parsers/asset-resolution";
|
|
2531
2714
|
var PREPARED_GIF_SUBDIR = "_animated_gif";
|
|
2532
2715
|
var CACHE_SCHEMA = "hfgif-v1";
|
|
@@ -2564,14 +2747,13 @@ function resolveLocalImageSourcePath(src, options) {
|
|
|
2564
2747
|
const mapped = options.sourceAssets?.get(trimmed) ?? options.sourceAssets?.get(basePath) ?? options.sourceAssets?.get(normalizedBase);
|
|
2565
2748
|
if (mapped && existsSync5(mapped)) return mapped;
|
|
2566
2749
|
if (isHttpUrl(trimmed)) return null;
|
|
2567
|
-
const protocolRelativeUrlOnShare = basePath.startsWith("/") && namesAnotherNetworkRoot(options.projectDir, basePath);
|
|
2568
2750
|
const projectRelative = basePath.startsWith("/") ? basePath.slice(1) : basePath;
|
|
2569
2751
|
const candidates = [
|
|
2570
|
-
|
|
2752
|
+
isAbsolute2(basePath) ? basePath : resolve4(options.projectDir, projectRelative),
|
|
2571
2753
|
resolve4(options.downloadDir, normalizedBase)
|
|
2572
2754
|
];
|
|
2573
|
-
const allowed = (candidate) => !escapesAssetRoot(candidate, options.assetRoot) && outsideAssetRefusal(options.projectDir, candidate) !== "blocklisted" || !escapesAssetRoot(candidate, options.downloadDir);
|
|
2574
|
-
return candidates.find((candidate) =>
|
|
2755
|
+
const allowed = (candidate) => !namesAnotherNetworkRoot(options.projectDir, candidate) && !isPrivateUnderAssetRoots(candidate, [options.projectDir, options.downloadDir]) && (!escapesAssetRoot(candidate, options.assetRoot) && outsideAssetRefusal(options.projectDir, candidate) !== "blocklisted" || !escapesAssetRoot(candidate, options.downloadDir));
|
|
2756
|
+
return candidates.find((candidate) => allowed(candidate) && existsSync5(candidate)) ?? null;
|
|
2575
2757
|
}
|
|
2576
2758
|
function isUsableFile(path) {
|
|
2577
2759
|
try {
|
|
@@ -2639,6 +2821,7 @@ function buildAnimatedGifTranscodeArgs(input) {
|
|
|
2639
2821
|
args.push(
|
|
2640
2822
|
"-ignore_loop",
|
|
2641
2823
|
"1",
|
|
2824
|
+
...urlInputArgs2(input.inputPath),
|
|
2642
2825
|
"-i",
|
|
2643
2826
|
input.inputPath,
|
|
2644
2827
|
"-an",
|
|
@@ -2844,7 +3027,7 @@ import {
|
|
|
2844
3027
|
} from "node:fs";
|
|
2845
3028
|
import { dirname as dirname5, join as join7, resolve as resolve5 } from "node:path";
|
|
2846
3029
|
import { parseHTML as parseHTML4 } from "linkedom";
|
|
2847
|
-
import { renameWithRetry as renameWithRetry4, runFfmpeg as runFfmpeg3, runFfprobe } from "@hyperframes/engine";
|
|
3030
|
+
import { renameWithRetry as renameWithRetry4, runFfmpeg as runFfmpeg3, runFfprobe, urlInputArgs as urlInputArgs3 } from "@hyperframes/engine";
|
|
2848
3031
|
|
|
2849
3032
|
// src/services/heifRotation.ts
|
|
2850
3033
|
function* boxes(buf, start, end) {
|
|
@@ -3043,6 +3226,7 @@ async function convertHeifToJpeg(request) {
|
|
|
3043
3226
|
"-hide_banner",
|
|
3044
3227
|
"-loglevel",
|
|
3045
3228
|
"error",
|
|
3229
|
+
...urlInputArgs3(request.inputPath),
|
|
3046
3230
|
"-i",
|
|
3047
3231
|
request.inputPath,
|
|
3048
3232
|
...mapArgs,
|
|
@@ -3166,7 +3350,9 @@ import {
|
|
|
3166
3350
|
fingerprintElementId,
|
|
3167
3351
|
isHttpUrl as isHttpUrl2,
|
|
3168
3352
|
isInsideAssetRoots,
|
|
3353
|
+
isNotImagePayload,
|
|
3169
3354
|
isNotMediaPayload,
|
|
3355
|
+
isPrivateUnderAssetRoots as isPrivateUnderAssetRoots2,
|
|
3170
3356
|
playlistLeavesItsFolder,
|
|
3171
3357
|
NotMediaPayloadError,
|
|
3172
3358
|
probeMediaProfile,
|
|
@@ -3221,6 +3407,10 @@ function dropMediaOutsideProject(input) {
|
|
|
3221
3407
|
const staysInside = ({ id, src }) => {
|
|
3222
3408
|
if (!src || isHttpUrl2(src)) return true;
|
|
3223
3409
|
const path = resolveProjectRelativeSrc3(src, projectDir, compiledDir);
|
|
3410
|
+
if (isPrivateUnderAssetRoots2(path, roots)) {
|
|
3411
|
+
log.warn(`[Render] Media "${id}" source is missing: it is a private project file`, { src });
|
|
3412
|
+
return false;
|
|
3413
|
+
}
|
|
3224
3414
|
if (isInsideAssetRoots(path, roots)) return true;
|
|
3225
3415
|
if (input.allowOutsideProjectAssets) {
|
|
3226
3416
|
const refusal = outsideAssetRefusal(projectDir, path);
|
|
@@ -3237,6 +3427,8 @@ function dropMediaOutsideProject(input) {
|
|
|
3237
3427
|
async function notMediaReferences(path, references) {
|
|
3238
3428
|
const videos = references.filter((ref) => ref.expected === "video");
|
|
3239
3429
|
if (videos.length > 0 && await isNotMediaPayload(path)) return videos;
|
|
3430
|
+
const images = references.filter((ref) => ref.expected === "image");
|
|
3431
|
+
if (images.length > 0 && await isNotImagePayload(path)) return images;
|
|
3240
3432
|
return await playlistLeavesItsFolder(path) ? references : [];
|
|
3241
3433
|
}
|
|
3242
3434
|
async function preflightCompositionAssetMediaTypes(input) {
|
|
@@ -3433,20 +3625,13 @@ function assertSubCompositionsUsable(html, projectDir, assetRoot, visited = /* @
|
|
|
3433
3625
|
throw new EmptyCompositionError(problems);
|
|
3434
3626
|
}
|
|
3435
3627
|
}
|
|
3436
|
-
var INLINE_SCRIPT_PATTERN = /<script\b([^>]*)>([\s\S]*?)<\/script>/gi;
|
|
3437
3628
|
var COMPILER_MOUNT_BLOCK_START = "/* __HF_COMPILER_MOUNT_START__ */";
|
|
3438
3629
|
var COMPILER_MOUNT_BLOCK_END = "/* __HF_COMPILER_MOUNT_END__ */";
|
|
3439
3630
|
function stripJsComments(source) {
|
|
3440
|
-
return source.replace(/\/\/.*$/gm, "")
|
|
3631
|
+
return removeDelimitedRuns(source.replace(/\/\/.*$/gm, ""), "/*", "*/");
|
|
3441
3632
|
}
|
|
3442
3633
|
function stripCompilerMountBootstrap(source) {
|
|
3443
|
-
return source
|
|
3444
|
-
new RegExp(
|
|
3445
|
-
`${COMPILER_MOUNT_BLOCK_START.replace(/[.*+?^${}()|[\]\\]/g, "\\$&")}[\\s\\S]*?${COMPILER_MOUNT_BLOCK_END.replace(/[.*+?^${}()|[\]\\]/g, "\\$&")}`,
|
|
3446
|
-
"g"
|
|
3447
|
-
),
|
|
3448
|
-
""
|
|
3449
|
-
);
|
|
3634
|
+
return removeDelimitedRuns(source, COMPILER_MOUNT_BLOCK_START, COMPILER_MOUNT_BLOCK_END);
|
|
3450
3635
|
}
|
|
3451
3636
|
function runtimeRoot(document2) {
|
|
3452
3637
|
return document2.querySelector('[data-composition-id][data-root="true"]') ?? document2.querySelector("[data-composition-id]");
|
|
@@ -3471,12 +3656,9 @@ function detectRenderModeHints(html, pageMotionBlur) {
|
|
|
3471
3656
|
message: "Detected <iframe> in the composition DOM. Nested iframe animation is routed through screenshot capture mode for compatibility."
|
|
3472
3657
|
});
|
|
3473
3658
|
}
|
|
3474
|
-
|
|
3475
|
-
const scriptPattern = new RegExp(INLINE_SCRIPT_PATTERN.source, INLINE_SCRIPT_PATTERN.flags);
|
|
3476
|
-
while ((scriptMatch = scriptPattern.exec(html)) !== null) {
|
|
3477
|
-
const attrs = scriptMatch[1] || "";
|
|
3659
|
+
for (const { attrs, body } of inlineScriptBlocks(html)) {
|
|
3478
3660
|
if (/\bsrc\s*=/i.test(attrs)) continue;
|
|
3479
|
-
const content = stripJsComments(stripCompilerMountBootstrap(
|
|
3661
|
+
const content = stripJsComments(stripCompilerMountBootstrap(body));
|
|
3480
3662
|
if (!/requestAnimationFrame\s*\(/.test(content)) continue;
|
|
3481
3663
|
reasons.push({
|
|
3482
3664
|
code: "requestAnimationFrame",
|
|
@@ -3528,17 +3710,14 @@ function detectAncestorBackgroundImage(html) {
|
|
|
3528
3710
|
}
|
|
3529
3711
|
var SHADER_TRANSITION_USAGE_PATTERN = /\b(?:(?:window|globalThis)\s*\.\s*)?HyperShader\s*\.\s*init\s*\(|\b__hf\s*\.\s*transitions\s*=/;
|
|
3530
3712
|
function detectShaderTransitionUsage(html) {
|
|
3531
|
-
|
|
3532
|
-
const scriptPattern = new RegExp(INLINE_SCRIPT_PATTERN.source, INLINE_SCRIPT_PATTERN.flags);
|
|
3533
|
-
while ((scriptMatch = scriptPattern.exec(html)) !== null) {
|
|
3534
|
-
const attrs = scriptMatch[1] || "";
|
|
3713
|
+
for (const { attrs, body } of inlineScriptBlocks(html)) {
|
|
3535
3714
|
if (/\bsrc\s*=/i.test(attrs)) continue;
|
|
3536
|
-
const content = stripJsComments(stripCompilerMountBootstrap(
|
|
3715
|
+
const content = stripJsComments(stripCompilerMountBootstrap(body));
|
|
3537
3716
|
if (SHADER_TRANSITION_USAGE_PATTERN.test(content)) return true;
|
|
3538
3717
|
}
|
|
3539
3718
|
return false;
|
|
3540
3719
|
}
|
|
3541
|
-
async function resolveMediaDuration(src, mediaStart, playbackRate, baseDir, downloadDir, tagName, elementIdentity, log, urlByAbsentLocalPath, probes, assetRoot) {
|
|
3720
|
+
async function resolveMediaDuration(src, mediaStart, playbackRate, projectDir, baseDir, downloadDir, tagName, elementIdentity, log, urlByAbsentLocalPath, probes, assetRoot) {
|
|
3542
3721
|
let filePath = src;
|
|
3543
3722
|
if (isHttpUrl(src)) {
|
|
3544
3723
|
const remoteDir = join9(downloadDir, REMOTE_MEDIA_SUBDIR);
|
|
@@ -3553,7 +3732,9 @@ async function resolveMediaDuration(src, mediaStart, playbackRate, baseDir, down
|
|
|
3553
3732
|
} else {
|
|
3554
3733
|
filePath = decodedUrlPath(src);
|
|
3555
3734
|
if (!filePath.startsWith("/")) filePath = join9(baseDir, filePath);
|
|
3556
|
-
if (escapesAssetRoot(filePath, assetRoot)
|
|
3735
|
+
if (escapesAssetRoot(filePath, assetRoot) || isPrivateUnderAssetRoots3(filePath, [projectDir, downloadDir])) {
|
|
3736
|
+
return { duration: null, resolvedPath: filePath };
|
|
3737
|
+
}
|
|
3557
3738
|
filePath = urlByAbsentLocalPath?.get(filePath) ?? filePath;
|
|
3558
3739
|
if (!isHttpUrl(filePath) && namesAnotherNetworkRoot2(baseDir, filePath)) {
|
|
3559
3740
|
return { duration: null, resolvedPath: filePath };
|
|
@@ -3629,7 +3810,7 @@ function markInferredVariableMediaDurations(html, unresolvedMedia) {
|
|
|
3629
3810
|
}
|
|
3630
3811
|
return changed ? document2.toString() : html;
|
|
3631
3812
|
}
|
|
3632
|
-
async function compileHtmlFile(html, baseDir, downloadDir, log, urlByAbsentLocalPath, probes, assetRoot) {
|
|
3813
|
+
async function compileHtmlFile(html, projectDir, baseDir, downloadDir, log, urlByAbsentLocalPath, probes, assetRoot) {
|
|
3633
3814
|
const { html: staticCompiled, unresolved } = compileTimingAttrs(html);
|
|
3634
3815
|
const mediaUnresolved = unresolved.filter(
|
|
3635
3816
|
(el) => (el.tagName === "video" || el.tagName === "audio") && el.src
|
|
@@ -3641,6 +3822,7 @@ async function compileHtmlFile(html, baseDir, downloadDir, log, urlByAbsentLocal
|
|
|
3641
3822
|
el.src,
|
|
3642
3823
|
el.mediaStart,
|
|
3643
3824
|
el.playbackRate,
|
|
3825
|
+
projectDir,
|
|
3644
3826
|
baseDir,
|
|
3645
3827
|
downloadDir,
|
|
3646
3828
|
el.tagName,
|
|
@@ -3665,6 +3847,7 @@ async function compileHtmlFile(html, baseDir, downloadDir, log, urlByAbsentLocal
|
|
|
3665
3847
|
el.src,
|
|
3666
3848
|
el.mediaStart,
|
|
3667
3849
|
el.playbackRate,
|
|
3850
|
+
projectDir,
|
|
3668
3851
|
baseDir,
|
|
3669
3852
|
downloadDir,
|
|
3670
3853
|
el.tagName,
|
|
@@ -3689,9 +3872,9 @@ async function compileHtmlFile(html, baseDir, downloadDir, log, urlByAbsentLocal
|
|
|
3689
3872
|
if (clampList.length > 0) {
|
|
3690
3873
|
compiledHtml = clampDurations(compiledHtml, clampList);
|
|
3691
3874
|
}
|
|
3692
|
-
compiledHtml = compiledHtml
|
|
3693
|
-
compiledHtml = compiledHtml
|
|
3694
|
-
compiledHtml = compiledHtml
|
|
3875
|
+
compiledHtml = stripCrossoriginAttr(compiledHtml, "video");
|
|
3876
|
+
compiledHtml = stripCrossoriginAttr(compiledHtml, "img");
|
|
3877
|
+
compiledHtml = stripCrossoriginAttr(compiledHtml, "audio");
|
|
3695
3878
|
return { html: compiledHtml, unresolvedCompositions };
|
|
3696
3879
|
}
|
|
3697
3880
|
async function parseSubCompositions(html, projectDir, downloadDir, visited = /* @__PURE__ */ new Set(), urlByAbsentLocalPath, probes, assetRoot) {
|
|
@@ -3720,6 +3903,7 @@ async function parseSubCompositions(html, projectDir, downloadDir, visited = /*
|
|
|
3720
3903
|
workItems.map(async (item) => {
|
|
3721
3904
|
const { html: compiledSub } = await compileHtmlFile(
|
|
3722
3905
|
rewriteUnresolvableGsapToCdn(item.rawSubHtml, projectDir, item.srcPath),
|
|
3906
|
+
projectDir,
|
|
3723
3907
|
dirname7(item.filePath),
|
|
3724
3908
|
downloadDir,
|
|
3725
3909
|
void 0,
|
|
@@ -3922,7 +4106,9 @@ function inlineSubCompositions(html, subCompositions, projectDir, variableOverri
|
|
|
3922
4106
|
flattenInnerRoot: prepareFlattenedInnerRoot,
|
|
3923
4107
|
onMissingComposition: (srcPath, reason) => {
|
|
3924
4108
|
console.warn(
|
|
3925
|
-
|
|
4109
|
+
terminalText4(
|
|
4110
|
+
`[Compiler] Skipping sub-composition "${srcPath}": ${reason ?? "the file is missing or empty"}.`
|
|
4111
|
+
)
|
|
3926
4112
|
);
|
|
3927
4113
|
}
|
|
3928
4114
|
}
|
|
@@ -4117,7 +4303,7 @@ ${safeText}
|
|
|
4117
4303
|
function collectExternalAssets(html, projectDir, log = defaultLogger, file = "index.html") {
|
|
4118
4304
|
const absProjectDir = resolve6(projectDir);
|
|
4119
4305
|
const externalAssets = /* @__PURE__ */ new Map();
|
|
4120
|
-
const
|
|
4306
|
+
const leftOut = /* @__PURE__ */ new Set();
|
|
4121
4307
|
function processPath(rawPath) {
|
|
4122
4308
|
const trimmed = rawPath.trim();
|
|
4123
4309
|
if (isNonRelativeUrl(trimmed)) return null;
|
|
@@ -4125,11 +4311,12 @@ function collectExternalAssets(html, projectDir, log = defaultLogger, file = "in
|
|
|
4125
4311
|
if (isPathInside(absPath, absProjectDir)) {
|
|
4126
4312
|
return null;
|
|
4127
4313
|
}
|
|
4128
|
-
|
|
4129
|
-
|
|
4314
|
+
const onShare = namesAnotherNetworkRoot2(absProjectDir, absPath);
|
|
4315
|
+
if (!onShare && !existsSync7(absPath)) return null;
|
|
4316
|
+
const refusal = onShare ? "network_share" : outsideAssetRefusal(absProjectDir, absPath);
|
|
4130
4317
|
if (refusal) {
|
|
4131
|
-
if (!
|
|
4132
|
-
|
|
4318
|
+
if (!leftOut.has(trimmed)) log.warn(`[Compiler] ${leftOutOfRender(file, trimmed, refusal)}`);
|
|
4319
|
+
leftOut.add(trimmed);
|
|
4133
4320
|
return null;
|
|
4134
4321
|
}
|
|
4135
4322
|
const safeKey = toExternalAssetKey(absPath);
|
|
@@ -4176,9 +4363,6 @@ function collectExternalAssets(html, projectDir, log = defaultLogger, file = "in
|
|
|
4176
4363
|
};
|
|
4177
4364
|
}
|
|
4178
4365
|
var REMOTE_MEDIA_SUBDIR = "_remote_media";
|
|
4179
|
-
var REMOTE_MEDIA_TAG_RE = /<(?:video|audio)\b[^>]*?\bsrc\s*=\s*["'](https?:\/\/[^"']+)["'][^>]*>/gi;
|
|
4180
|
-
var REMOTE_SOURCE_TAG_RE = /<source\b[^>]*?\bsrc\s*=\s*["'](https?:\/\/[^"']+)["'][^>]*>/gi;
|
|
4181
|
-
var REMOTE_IMG_TAG_RE = /<img\b[^>]*?(?<![\w-])src\s*=\s*["'](https?:\/\/[^"']+)["'][^>]*>/gi;
|
|
4182
4366
|
async function downloadAndRewriteUrls(urlSet, html, remoteDir, warnLabel, logLabel, extraRewrite) {
|
|
4183
4367
|
if (urlSet.size === 0) return { html, remoteMediaAssets: /* @__PURE__ */ new Map() };
|
|
4184
4368
|
if (!existsSync7(remoteDir)) mkdirSync4(remoteDir, { recursive: true });
|
|
@@ -4217,14 +4401,7 @@ async function downloadAndRewriteUrls(urlSet, html, remoteDir, warnLabel, logLab
|
|
|
4217
4401
|
return { html: result, remoteMediaAssets };
|
|
4218
4402
|
}
|
|
4219
4403
|
async function localizeRemoteMediaSources(html, downloadDir) {
|
|
4220
|
-
const urlSet = /* @__PURE__ */ new Set();
|
|
4221
|
-
for (const tagRe of [REMOTE_MEDIA_TAG_RE, REMOTE_SOURCE_TAG_RE]) {
|
|
4222
|
-
const re = new RegExp(tagRe.source, tagRe.flags);
|
|
4223
|
-
let m;
|
|
4224
|
-
while ((m = re.exec(html)) !== null) {
|
|
4225
|
-
if (m[1]) urlSet.add(m[1]);
|
|
4226
|
-
}
|
|
4227
|
-
}
|
|
4404
|
+
const urlSet = /* @__PURE__ */ new Set([...remoteSrcUrls(html, "media"), ...remoteSrcUrls(html, "source")]);
|
|
4228
4405
|
const localized = await downloadAndRewriteUrls(
|
|
4229
4406
|
urlSet,
|
|
4230
4407
|
html,
|
|
@@ -4247,12 +4424,7 @@ function dropBindingOnLocalizedMedia(html) {
|
|
|
4247
4424
|
return changed ? document2.toString() : html;
|
|
4248
4425
|
}
|
|
4249
4426
|
async function localizeRemoteImageSources(html, downloadDir) {
|
|
4250
|
-
const urlSet =
|
|
4251
|
-
const re = new RegExp(REMOTE_IMG_TAG_RE.source, REMOTE_IMG_TAG_RE.flags);
|
|
4252
|
-
let m;
|
|
4253
|
-
while ((m = re.exec(html)) !== null) {
|
|
4254
|
-
if (m[1]) urlSet.add(m[1]);
|
|
4255
|
-
}
|
|
4427
|
+
const urlSet = new Set(remoteSrcUrls(html, "img"));
|
|
4256
4428
|
return downloadAndRewriteUrls(
|
|
4257
4429
|
urlSet,
|
|
4258
4430
|
html,
|
|
@@ -4462,6 +4634,7 @@ async function embedLocalFontFaces(html, projectDir, assetRoot, log = defaultLog
|
|
|
4462
4634
|
embeddedPaths.add(localPath);
|
|
4463
4635
|
continue;
|
|
4464
4636
|
}
|
|
4637
|
+
if (isPrivateCompositionFile(projectDir, absPath)) continue;
|
|
4465
4638
|
const ext = absPath.match(/\.(woff2?|ttf|otf|ttc)$/i)?.[1]?.toLowerCase() ?? "ttf";
|
|
4466
4639
|
try {
|
|
4467
4640
|
if (fileBackedAbsolutePaths.has(absPath)) {
|
|
@@ -4513,16 +4686,13 @@ function rewriteUnresolvableGsapToCdn(html, projectDir, compSrcPath) {
|
|
|
4513
4686
|
const file = resolve6(projectDir, path);
|
|
4514
4687
|
return !namesAnotherNetworkRoot2(projectDir, file) && existsSync7(file);
|
|
4515
4688
|
};
|
|
4516
|
-
return html
|
|
4517
|
-
|
|
4518
|
-
(
|
|
4519
|
-
|
|
4520
|
-
|
|
4521
|
-
|
|
4522
|
-
|
|
4523
|
-
return `${prefix}${gsapDist}${file}${suffix}`;
|
|
4524
|
-
}
|
|
4525
|
-
);
|
|
4689
|
+
return replaceGsapDistScripts(html, (full, prefix, src, file, suffix) => {
|
|
4690
|
+
if (/^https?:\/\//i.test(src)) return full;
|
|
4691
|
+
if (exists(compSrcPath ? rewriteAssetPath(compSrcPath, src, exists) : src)) return full;
|
|
4692
|
+
gsapDist ??= renderGsapDist();
|
|
4693
|
+
defaultLogger.debug(`[Compiler] Rewriting missing gsap script: ${src} \u2192 ${gsapDist}${file}`);
|
|
4694
|
+
return `${prefix}${gsapDist}${file}${suffix}`;
|
|
4695
|
+
});
|
|
4526
4696
|
}
|
|
4527
4697
|
function rebaseDirectEntryAssetPaths(html, projectDir, htmlPath) {
|
|
4528
4698
|
if (!isPathInside(htmlPath, projectDir)) return html;
|
|
@@ -4586,6 +4756,7 @@ async function compileForRender(projectDir, htmlPath, downloadDir, options = {})
|
|
|
4586
4756
|
const { html: compiledHtml, unresolvedCompositions } = await compileHtmlFile(
|
|
4587
4757
|
rawHtml,
|
|
4588
4758
|
projectDir,
|
|
4759
|
+
projectDir,
|
|
4589
4760
|
downloadDir,
|
|
4590
4761
|
options.log,
|
|
4591
4762
|
options.urlByAbsentLocalPath,
|
|
@@ -4609,10 +4780,7 @@ async function compileForRender(projectDir, htmlPath, downloadDir, options = {})
|
|
|
4609
4780
|
options.variables ?? {},
|
|
4610
4781
|
assetRoot
|
|
4611
4782
|
);
|
|
4612
|
-
const sanitizedHtml = inlinedHtml
|
|
4613
|
-
/(<(?:video|audio)\b[^>]*?)\s+preload\s*=\s*["']none["']/gi,
|
|
4614
|
-
"$1"
|
|
4615
|
-
);
|
|
4783
|
+
const sanitizedHtml = stripPreloadNone(inlinedHtml);
|
|
4616
4784
|
const renderModeHints = detectRenderModeHints(sanitizedHtml, options.pageMotionBlur);
|
|
4617
4785
|
const hasShaderTransitions = detectShaderTransitionUsage(sanitizedHtml);
|
|
4618
4786
|
const usesThreeDTransforms = detectThreeDTransformUsage(sanitizedHtml);
|
|
@@ -4721,7 +4889,7 @@ async function compileForRender(projectDir, htmlPath, downloadDir, options = {})
|
|
|
4721
4889
|
for (const video of videos) {
|
|
4722
4890
|
if (isHttpUrl(video.src)) continue;
|
|
4723
4891
|
const videoPath = resolve6(projectDir, video.src);
|
|
4724
|
-
if (advised.has(videoPath) || namesAnotherNetworkRoot2(projectDir, videoPath) || !existsSync7(videoPath) || escapesAssetRoot(videoPath, assetRoot))
|
|
4892
|
+
if (advised.has(videoPath) || namesAnotherNetworkRoot2(projectDir, videoPath) || !existsSync7(videoPath) || escapesAssetRoot(videoPath, assetRoot) || isPrivateUnderAssetRoots3(videoPath, [projectDir, downloadDir]))
|
|
4725
4893
|
continue;
|
|
4726
4894
|
advised.add(videoPath);
|
|
4727
4895
|
const reencode = `ffmpeg -i "${video.src}" -c:v libx264 -r 30 -g 30 -keyint_min 30 -movflags +faststart -c:a copy output.mp4`;
|
|
@@ -5351,7 +5519,8 @@ import {
|
|
|
5351
5519
|
readMediaStart as readMediaStart2,
|
|
5352
5520
|
shiftRateLane as shiftRateLane2,
|
|
5353
5521
|
sourceTimeAt as sourceTimeAt3,
|
|
5354
|
-
timeAtSourceTime
|
|
5522
|
+
timeAtSourceTime,
|
|
5523
|
+
terminalText as terminalText5
|
|
5355
5524
|
} from "@hyperframes/core";
|
|
5356
5525
|
import { parseHostVariableValues as parseHostVariableValues2, readDeclaredDefaults as readDeclaredDefaults2 } from "@hyperframes/core/compiler";
|
|
5357
5526
|
import { extractMediaSrcMutations } from "@hyperframes/parsers";
|
|
@@ -5984,7 +6153,7 @@ async function runProbeStage(input) {
|
|
|
5984
6153
|
failures: failedRequests.slice(0, 10)
|
|
5985
6154
|
});
|
|
5986
6155
|
for (const line of failedRequests.slice(0, 5)) {
|
|
5987
|
-
console.warn(`[Render] Asset load failure: ${line}`);
|
|
6156
|
+
console.warn(`[Render] Asset load failure: ${terminalText5(line)}`);
|
|
5988
6157
|
}
|
|
5989
6158
|
}
|
|
5990
6159
|
}
|
|
@@ -6097,7 +6266,7 @@ import {
|
|
|
6097
6266
|
resolveFinalFrameExtractionWindow as resolveFinalFrameExtractionWindow2,
|
|
6098
6267
|
resolveVideoExtractionWindow as resolveVideoExtractionWindow2,
|
|
6099
6268
|
isHttpUrl as isHttpUrl3,
|
|
6100
|
-
|
|
6269
|
+
assetRootsRefusal,
|
|
6101
6270
|
assertPublicHttpsUrl,
|
|
6102
6271
|
downloadToTemp as downloadToTemp2,
|
|
6103
6272
|
resolveRestrictPageNetwork,
|
|
@@ -6535,7 +6704,7 @@ function isPublicHttpsUrl(url) {
|
|
|
6535
6704
|
}
|
|
6536
6705
|
}
|
|
6537
6706
|
function opensLocally(path, assetRoots) {
|
|
6538
|
-
return existsSync9(path) && (!assetRoots ||
|
|
6707
|
+
return existsSync9(path) && (!assetRoots || assetRootsRefusal(path, assetRoots) === null);
|
|
6539
6708
|
}
|
|
6540
6709
|
function localProbeSource(src, input) {
|
|
6541
6710
|
const path = resolveProjectRelativeSrc4(src, input.projectDir, input.compiledDir);
|
|
@@ -10596,9 +10765,12 @@ function resolveDistributedEngineConfig(config) {
|
|
|
10596
10765
|
forceScreenshotExplicitlyOptedOut: true
|
|
10597
10766
|
};
|
|
10598
10767
|
}
|
|
10768
|
+
function leavesRoot(rel) {
|
|
10769
|
+
return rel === ".." || rel.startsWith(`..${sep4}`) || isAbsolute3(rel);
|
|
10770
|
+
}
|
|
10599
10771
|
function pathInside(root, path) {
|
|
10600
10772
|
const rel = relative6(root, path);
|
|
10601
|
-
return rel === "" ||
|
|
10773
|
+
return rel === "" || leavesRoot(rel) ? null : rel;
|
|
10602
10774
|
}
|
|
10603
10775
|
function stableSourcePath(roots, srcPath) {
|
|
10604
10776
|
for (const [root, prefix] of roots) {
|
|
@@ -10692,7 +10864,8 @@ async function compilePlanComposition(projectDir, config, planDir, options) {
|
|
|
10692
10864
|
dereference: true,
|
|
10693
10865
|
filter: (src) => {
|
|
10694
10866
|
const rel = relative6(projectDir, src);
|
|
10695
|
-
if (rel === ""
|
|
10867
|
+
if (rel === "") return true;
|
|
10868
|
+
if (leavesRoot(rel)) return false;
|
|
10696
10869
|
if (job.config.allowOutsideProjectAssets) {
|
|
10697
10870
|
if (refusesOutsideLink(projectDir, src, (line) => log.warn(`[Plan] ${line}`))) return false;
|
|
10698
10871
|
} else if (!isSafePath2(projectDir, src)) return false;
|
|
@@ -13448,40 +13621,56 @@ function validateIntDimension(field, value) {
|
|
|
13448
13621
|
import { closeSync as closeSync5, openSync as openSync5, readdirSync as readdirSync10, readSync as readSync4, realpathSync as realpathSync2, statSync as statSync10 } from "node:fs";
|
|
13449
13622
|
import { createHash as createHash9 } from "node:crypto";
|
|
13450
13623
|
import { join as join34 } from "node:path";
|
|
13624
|
+
import { isPrivateFileUnder as isPrivateFileUnder3, isStudioPrivatePath as isStudioPrivatePath3 } from "@hyperframes/core/safe-path";
|
|
13451
13625
|
var SITE_ID_SCHEME = "site-v2\0";
|
|
13452
13626
|
var READ_CHUNK_BYTES = 256 * 1024;
|
|
13453
|
-
var
|
|
13454
|
-
|
|
13455
|
-
|
|
13627
|
+
var isPrivateSitePath = (relPath) => isStudioPrivatePath3(relPath);
|
|
13628
|
+
function statEntry(full, relPath) {
|
|
13629
|
+
try {
|
|
13630
|
+
return statSync10(full);
|
|
13631
|
+
} catch (err) {
|
|
13632
|
+
throw new Error(`[listSiteFiles] cannot read ${relPath} (dangling symlink?)`, { cause: err });
|
|
13633
|
+
}
|
|
13634
|
+
}
|
|
13635
|
+
function listSiteFiles(projectDir, onPrivate) {
|
|
13456
13636
|
const files = [];
|
|
13457
13637
|
const ancestors = /* @__PURE__ */ new Set([realpathSync2(projectDir)]);
|
|
13638
|
+
function visit(full, relPath) {
|
|
13639
|
+
if (isPrivateFileUnder3(projectDir, full, isStudioPrivatePath3)) return void onPrivate?.(relPath);
|
|
13640
|
+
const stat = statEntry(full, relPath);
|
|
13641
|
+
if (stat.isFile()) return void files.push(relPath);
|
|
13642
|
+
if (!stat.isDirectory()) return;
|
|
13643
|
+
const real = realpathSync2(full);
|
|
13644
|
+
if (ancestors.has(real)) return;
|
|
13645
|
+
ancestors.add(real);
|
|
13646
|
+
walk(full, relPath);
|
|
13647
|
+
ancestors.delete(real);
|
|
13648
|
+
}
|
|
13458
13649
|
function walk(dir, rel) {
|
|
13459
13650
|
for (const name of readdirSync10(dir).sort()) {
|
|
13460
|
-
if (
|
|
13461
|
-
|
|
13462
|
-
const relPath = rel === "" ? name : `${rel}/${name}`;
|
|
13463
|
-
let stat;
|
|
13464
|
-
try {
|
|
13465
|
-
stat = statSync10(full);
|
|
13466
|
-
} catch (err) {
|
|
13467
|
-
throw new Error(`[listSiteFiles] cannot read ${relPath} (dangling symlink?)`, {
|
|
13468
|
-
cause: err
|
|
13469
|
-
});
|
|
13470
|
-
}
|
|
13471
|
-
if (stat.isFile()) {
|
|
13472
|
-
files.push(relPath);
|
|
13473
|
-
} else if (stat.isDirectory()) {
|
|
13474
|
-
const real = realpathSync2(full);
|
|
13475
|
-
if (ancestors.has(real)) continue;
|
|
13476
|
-
ancestors.add(real);
|
|
13477
|
-
walk(full, relPath);
|
|
13478
|
-
ancestors.delete(real);
|
|
13479
|
-
}
|
|
13651
|
+
if (rel === "" && PLAN_PROJECT_DIR_SKIP_SEGMENTS.has(name)) continue;
|
|
13652
|
+
visit(join34(dir, name), rel === "" ? name : `${rel}/${name}`);
|
|
13480
13653
|
}
|
|
13481
13654
|
}
|
|
13482
13655
|
walk(projectDir, "");
|
|
13483
13656
|
return files;
|
|
13484
13657
|
}
|
|
13658
|
+
var printablePath = (path) => [...path].map((ch) => {
|
|
13659
|
+
const code = ch.charCodeAt(0);
|
|
13660
|
+
const control = code < 32 && code !== 9 || code >= 127 && code <= 159;
|
|
13661
|
+
return control ? `\\x${code.toString(16).padStart(2, "0")}` : ch;
|
|
13662
|
+
}).join("");
|
|
13663
|
+
function listSiteFilesForUpload(projectDir, onNotice) {
|
|
13664
|
+
const leftOut = [];
|
|
13665
|
+
const files = listSiteFiles(projectDir, (path) => leftOut.push(path));
|
|
13666
|
+
if (leftOut.length > 0) {
|
|
13667
|
+
const more = leftOut.length > 5 ? ` and ${leftOut.length - 5} more` : "";
|
|
13668
|
+
onNotice?.(
|
|
13669
|
+
`[deploySite] left out private files no composition loads (env, Git, credentials, tool state): ${leftOut.slice(0, 5).map(printablePath).join(", ")}${more}`
|
|
13670
|
+
);
|
|
13671
|
+
}
|
|
13672
|
+
return files;
|
|
13673
|
+
}
|
|
13485
13674
|
function hashProjectDir(projectDir, files = listSiteFiles(projectDir)) {
|
|
13486
13675
|
const hash = createHash9("sha256").update(SITE_ID_SCHEME);
|
|
13487
13676
|
const chunk = Buffer.allocUnsafe(READ_CHUNK_BYTES);
|
|
@@ -13502,7 +13691,7 @@ function hashProjectDir(projectDir, files = listSiteFiles(projectDir)) {
|
|
|
13502
13691
|
}
|
|
13503
13692
|
|
|
13504
13693
|
// src/services/distributed/audioSidecar.ts
|
|
13505
|
-
import { extractAudioMetadata as extractAudioMetadata4, runFfmpeg as runFfmpeg9 } from "@hyperframes/engine";
|
|
13694
|
+
import { extractAudioMetadata as extractAudioMetadata4, runFfmpeg as runFfmpeg9, urlInputArgs as urlInputArgs4 } from "@hyperframes/engine";
|
|
13506
13695
|
import { extname as extname5 } from "node:path";
|
|
13507
13696
|
var AUDIO_SIDECAR_MIN_BYTES = 32 * 1024 * 1024;
|
|
13508
13697
|
var AUDIO_SIDECAR_SOURCE_EXTENSIONS = /* @__PURE__ */ new Set([".mp4", ".mov", ".m4v"]);
|
|
@@ -13514,13 +13703,19 @@ async function buildAudioSidecar(inputPath, outputPath, signal) {
|
|
|
13514
13703
|
if (!audio) return await ffmpegIsMissing(signal) ? "unavailable" : "none";
|
|
13515
13704
|
if (audio.audioStreamCount !== 1 || (audio.audioStreamLeadSeconds ?? 0) > 0) return "none";
|
|
13516
13705
|
const result = await runFfmpeg9(
|
|
13517
|
-
[
|
|
13518
|
-
"-
|
|
13519
|
-
"
|
|
13520
|
-
"-
|
|
13521
|
-
|
|
13522
|
-
|
|
13523
|
-
|
|
13706
|
+
[
|
|
13707
|
+
"-v",
|
|
13708
|
+
"error",
|
|
13709
|
+
"-y",
|
|
13710
|
+
...urlInputArgs4(inputPath),
|
|
13711
|
+
"-i",
|
|
13712
|
+
inputPath,
|
|
13713
|
+
"-map",
|
|
13714
|
+
"0:a:0",
|
|
13715
|
+
"-vn",
|
|
13716
|
+
"-c:a",
|
|
13717
|
+
"copy"
|
|
13718
|
+
].concat(["-movflags", "+faststart", "-f", "mp4", outputPath]),
|
|
13524
13719
|
{ signal }
|
|
13525
13720
|
);
|
|
13526
13721
|
if (result.success) return "built";
|
|
@@ -13593,8 +13788,10 @@ export {
|
|
|
13593
13788
|
hashProjectDir,
|
|
13594
13789
|
isPlanAudioArtifactPath,
|
|
13595
13790
|
isPlanV2DeferredSourceArtifact,
|
|
13791
|
+
isPrivateSitePath,
|
|
13596
13792
|
listPlanV2ArtifactsForTarget,
|
|
13597
13793
|
listSiteFiles,
|
|
13794
|
+
listSiteFilesForUpload,
|
|
13598
13795
|
materializePlanV2Target,
|
|
13599
13796
|
measurePlanDirBytes,
|
|
13600
13797
|
muxChunkWithAudio,
|