@hyperframes/producer 0.9.81 → 0.9.83
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 +225 -58
- package/dist/hyperframe.manifest.json +1 -1
- package/dist/hyperframe.runtime.iife.js +69 -69
- package/dist/index.js +237 -61
- package/dist/public-server.js +235 -59
- package/dist/services/bundledScripts.d.ts +4 -2
- package/dist/services/render/stages/probeStage.d.ts +10 -0
- package/package.json +7 -7
package/dist/distributed.js
CHANGED
|
@@ -340,7 +340,7 @@ function remoteSrcUrls(html, tag) {
|
|
|
340
340
|
// src/services/renderOrchestrator.ts
|
|
341
341
|
import { matchHtmlBodyCssHeightFirst, matchHtmlBodyCssWidthFirst } from "@hyperframes/parsers";
|
|
342
342
|
import {
|
|
343
|
-
extractMediaMetadata as
|
|
343
|
+
extractMediaMetadata as extractMediaMetadata6,
|
|
344
344
|
resolveConfig as resolveConfig2,
|
|
345
345
|
closeCaptureSession as closeCaptureSession8,
|
|
346
346
|
createCaptureSession as createCaptureSession8,
|
|
@@ -363,7 +363,7 @@ import {
|
|
|
363
363
|
scaleProtocolTimeoutForComposition,
|
|
364
364
|
classifyCaptureFailure as classifyCaptureFailure3,
|
|
365
365
|
cloneCaptureWarning,
|
|
366
|
-
isMemoryExhaustionError,
|
|
366
|
+
isMemoryExhaustionError as isMemoryExhaustionError2,
|
|
367
367
|
isTransientBrowserError as isTransientBrowserError2,
|
|
368
368
|
isDrawElementVerificationError,
|
|
369
369
|
isDrawElementCaptureError,
|
|
@@ -2484,13 +2484,21 @@ import { parseHTML as parseHTML5 } from "linkedom";
|
|
|
2484
2484
|
// src/services/bundledScripts.ts
|
|
2485
2485
|
import { existsSync as existsSync4, readFileSync as readFileSync2 } from "node:fs";
|
|
2486
2486
|
import { join as join5 } from "node:path";
|
|
2487
|
-
import {
|
|
2487
|
+
import { GSAP_CDN_VERSION } from "@hyperframes/core/gsap-cdn";
|
|
2488
2488
|
var GSAP_VENDOR_DIR_ENV = "HYPERFRAMES_GSAP_VENDOR_DIR";
|
|
2489
|
+
var DEFAULT_CDN_GSAP_3 = /^https:\/\/cdn\.jsdelivr\.net\/npm\/gsap@(3\.\d+\.\d+)\/dist\/([A-Za-z]+\.min\.js)$/;
|
|
2490
|
+
var read = (file) => existsSync4(file) ? readFileSync2(file) : null;
|
|
2489
2491
|
function bundledScript(url) {
|
|
2490
2492
|
const dir = process.env[GSAP_VENDOR_DIR_ENV];
|
|
2491
|
-
|
|
2492
|
-
|
|
2493
|
-
|
|
2493
|
+
const [, version, file] = DEFAULT_CDN_GSAP_3.exec(url) ?? [];
|
|
2494
|
+
if (!dir || !version || !file) return null;
|
|
2495
|
+
const at = version === GSAP_CDN_VERSION ? dir : join5(dir, "..", "..", `gsap@${version}`, "dist");
|
|
2496
|
+
return read(join5(at, file));
|
|
2497
|
+
}
|
|
2498
|
+
function bundledGsapStandIn(url) {
|
|
2499
|
+
const dir = process.env[GSAP_VENDOR_DIR_ENV];
|
|
2500
|
+
const [, , file] = DEFAULT_CDN_GSAP_3.exec(url) ?? [];
|
|
2501
|
+
return dir && file ? read(join5(dir, file)) : null;
|
|
2494
2502
|
}
|
|
2495
2503
|
|
|
2496
2504
|
// src/services/htmlCompiler.ts
|
|
@@ -2516,7 +2524,7 @@ import { MAX_AUDIO_GAIN } from "@hyperframes/core/audio-gain";
|
|
|
2516
2524
|
import { CAPTURE_CANVAS_SELECTOR } from "@hyperframes/core/html-in-canvas";
|
|
2517
2525
|
import { readPlaybackRate } from "@hyperframes/parsers/media-duration";
|
|
2518
2526
|
import { resolveRateSpec } from "@hyperframes/core/speed-ramp";
|
|
2519
|
-
import { gsapCdnDist
|
|
2527
|
+
import { gsapCdnDist, normalizeGsapBaseUrl } from "@hyperframes/core/gsap-cdn";
|
|
2520
2528
|
import {
|
|
2521
2529
|
assignBundledRuntimeCompositionIds,
|
|
2522
2530
|
assignMediaRenderIds,
|
|
@@ -3662,13 +3670,13 @@ function compositionPathProblem(projectDir, filePath, assetRoot, outsideFiles) {
|
|
|
3662
3670
|
}
|
|
3663
3671
|
function readSubCompositionFile(filePath, srcPath) {
|
|
3664
3672
|
assertCompositionFileSize(filePath, srcPath);
|
|
3665
|
-
const
|
|
3666
|
-
if (
|
|
3667
|
-
if (
|
|
3668
|
-
const validity = checkSubCompositionUsability(
|
|
3673
|
+
const read2 = readProjectFile(filePath);
|
|
3674
|
+
if (read2.kind === "missing") return { detail: "the file does not exist" };
|
|
3675
|
+
if (read2.kind === "folder") return { detail: "it is a folder, not an HTML file" };
|
|
3676
|
+
const validity = checkSubCompositionUsability(read2.text, parseSubCompHtmlForValidity);
|
|
3669
3677
|
if (!validity.ok)
|
|
3670
3678
|
return { detail: validity.detail ?? "the file is empty or could not be parsed" };
|
|
3671
|
-
return { bytes: Buffer.byteLength(
|
|
3679
|
+
return { bytes: Buffer.byteLength(read2.text), ...compositionSrcsIn(read2.text) };
|
|
3672
3680
|
}
|
|
3673
3681
|
function assertSubCompositionsUsable(html, projectDir, assetRoot, outsideFiles) {
|
|
3674
3682
|
const budget = new CompositionExpansionBudget();
|
|
@@ -3769,6 +3777,96 @@ var THREE_D_CONTEXT_PATTERN = /transform-style\s*:\s*preserve-3d|backface-visibi
|
|
|
3769
3777
|
function detectThreeDTransformUsage(html) {
|
|
3770
3778
|
return THREE_D_CONTEXT_PATTERN.test(html);
|
|
3771
3779
|
}
|
|
3780
|
+
var CSS_ESCAPE = /\\(?:[0-9a-fA-F]{1,6}[ \t\n\r\f]?|[^])?/y;
|
|
3781
|
+
function ancestorSelectorSteps(list) {
|
|
3782
|
+
const selectors = [];
|
|
3783
|
+
let steps = [];
|
|
3784
|
+
let combinators = [];
|
|
3785
|
+
let compound = "";
|
|
3786
|
+
let open2 = false;
|
|
3787
|
+
let combinator = null;
|
|
3788
|
+
const skipGroup = (at, close) => {
|
|
3789
|
+
let depth = 0;
|
|
3790
|
+
for (let i = at; i < list.length; i++) {
|
|
3791
|
+
const ch = list[i];
|
|
3792
|
+
if (ch === "\\") i++;
|
|
3793
|
+
else if (ch === '"' || ch === "'") {
|
|
3794
|
+
const end = list.indexOf(ch, i + 1);
|
|
3795
|
+
if (end < 0) return -1;
|
|
3796
|
+
i = end;
|
|
3797
|
+
} else if (ch === list[at]) depth++;
|
|
3798
|
+
else if (ch === close && --depth === 0) return i;
|
|
3799
|
+
}
|
|
3800
|
+
return -1;
|
|
3801
|
+
};
|
|
3802
|
+
const flush = () => {
|
|
3803
|
+
if (!open2) return;
|
|
3804
|
+
if ((combinator === "+" || combinator === "~") && steps.length > 0) {
|
|
3805
|
+
steps.pop();
|
|
3806
|
+
combinator = combinators.pop() ?? null;
|
|
3807
|
+
}
|
|
3808
|
+
steps.push({ compound: compound || "*", child: combinator === ">" });
|
|
3809
|
+
combinators.push(combinator);
|
|
3810
|
+
compound = "";
|
|
3811
|
+
open2 = false;
|
|
3812
|
+
combinator = null;
|
|
3813
|
+
};
|
|
3814
|
+
for (let i = 0; i <= list.length; i++) {
|
|
3815
|
+
const ch = list[i];
|
|
3816
|
+
if (ch === void 0 || ch === ",") {
|
|
3817
|
+
flush();
|
|
3818
|
+
if (steps.length) selectors.push(steps);
|
|
3819
|
+
steps = [];
|
|
3820
|
+
combinators = [];
|
|
3821
|
+
combinator = null;
|
|
3822
|
+
} else if (ch === "\\") {
|
|
3823
|
+
CSS_ESCAPE.lastIndex = i;
|
|
3824
|
+
const escape = CSS_ESCAPE.exec(list)[0];
|
|
3825
|
+
compound += escape;
|
|
3826
|
+
i += escape.length - 1;
|
|
3827
|
+
open2 = true;
|
|
3828
|
+
} else if (ch === "[") {
|
|
3829
|
+
const end = skipGroup(i, "]");
|
|
3830
|
+
if (end < 0) return null;
|
|
3831
|
+
compound += list.slice(i, end + 1);
|
|
3832
|
+
open2 = true;
|
|
3833
|
+
i = end;
|
|
3834
|
+
} else if (ch === ":") {
|
|
3835
|
+
while (/[:\w-]/.test(list[i + 1] ?? "")) i++;
|
|
3836
|
+
if (list[i + 1] === "(") i = skipGroup(i + 1, ")");
|
|
3837
|
+
if (i < 0) return null;
|
|
3838
|
+
open2 = true;
|
|
3839
|
+
} else if (/\s/.test(ch)) {
|
|
3840
|
+
flush();
|
|
3841
|
+
if (steps.length) combinator ??= " ";
|
|
3842
|
+
} else if (ch === ">" || ch === "+" || ch === "~") {
|
|
3843
|
+
flush();
|
|
3844
|
+
combinator = ch;
|
|
3845
|
+
} else if (ch === "(" || ch === ")" || ch === "]") {
|
|
3846
|
+
return null;
|
|
3847
|
+
} else {
|
|
3848
|
+
compound += ch;
|
|
3849
|
+
open2 = true;
|
|
3850
|
+
}
|
|
3851
|
+
}
|
|
3852
|
+
return selectors;
|
|
3853
|
+
}
|
|
3854
|
+
function matchesAnAncestor(steps, ancestors) {
|
|
3855
|
+
let reach = ancestors.map((el) => el.matches(steps[0].compound));
|
|
3856
|
+
for (const step of steps.slice(1)) {
|
|
3857
|
+
let above = false;
|
|
3858
|
+
const next = ancestors.map(() => false);
|
|
3859
|
+
for (let j = ancestors.length - 1; j >= 0; j--) {
|
|
3860
|
+
const placed = step.child ? reach[j + 1] === true : above;
|
|
3861
|
+
next[j] = placed && ancestors[j].matches(step.compound);
|
|
3862
|
+
above ||= reach[j];
|
|
3863
|
+
}
|
|
3864
|
+
reach = next;
|
|
3865
|
+
}
|
|
3866
|
+
return reach.includes(true);
|
|
3867
|
+
}
|
|
3868
|
+
var MAX_ROOT_ANCESTORS = 256;
|
|
3869
|
+
var MAX_ANCESTOR_SELECTOR_CHECKS = 1e5;
|
|
3772
3870
|
function detectAncestorBackgroundImage(html) {
|
|
3773
3871
|
const { document: document2 } = parseHTML5(html);
|
|
3774
3872
|
const root = document2.querySelector("[data-composition-id]");
|
|
@@ -3778,6 +3876,8 @@ function detectAncestorBackgroundImage(html) {
|
|
|
3778
3876
|
if (document2.documentElement && !ancestors.includes(document2.documentElement)) {
|
|
3779
3877
|
ancestors.push(document2.documentElement);
|
|
3780
3878
|
}
|
|
3879
|
+
if (ancestors.length > MAX_ROOT_ANCESTORS) return true;
|
|
3880
|
+
let selectorChecks = 0;
|
|
3781
3881
|
for (const el of ancestors) {
|
|
3782
3882
|
const style = el.getAttribute("style");
|
|
3783
3883
|
if (style && hasBackgroundImageDeclaration(`{${style}}`)) return true;
|
|
@@ -3787,14 +3887,14 @@ function detectAncestorBackgroundImage(html) {
|
|
|
3787
3887
|
for (const { parts: rule } of cssRuleMatches(css)) {
|
|
3788
3888
|
const [, selectorList, declarations] = rule;
|
|
3789
3889
|
if (!hasBackgroundImageDeclaration(`{${declarations}}`)) continue;
|
|
3790
|
-
|
|
3791
|
-
|
|
3792
|
-
|
|
3793
|
-
|
|
3890
|
+
if (selectorList.trim().startsWith("@")) continue;
|
|
3891
|
+
const selectors = ancestorSelectorSteps(selectorList);
|
|
3892
|
+
if (!selectors) return true;
|
|
3893
|
+
for (const steps of selectors) {
|
|
3894
|
+
selectorChecks += steps.length * ancestors.length;
|
|
3895
|
+
if (selectorChecks > MAX_ANCESTOR_SELECTOR_CHECKS) return true;
|
|
3794
3896
|
try {
|
|
3795
|
-
|
|
3796
|
-
if (ancestors.includes(matched)) return true;
|
|
3797
|
-
}
|
|
3897
|
+
if (matchesAnAncestor(steps, ancestors)) return true;
|
|
3798
3898
|
} catch {
|
|
3799
3899
|
}
|
|
3800
3900
|
}
|
|
@@ -4043,11 +4143,11 @@ async function parseSubCompositions(html, projectDir, downloadDir, visited = /*
|
|
|
4043
4143
|
compiledSrcs.add(srcPath);
|
|
4044
4144
|
assertOutsideMarkupAsked(projectDir, filePath, srcPath, assetRoot, outsideFiles);
|
|
4045
4145
|
assertCompositionFileSize(filePath, srcPath);
|
|
4046
|
-
const
|
|
4047
|
-
if (
|
|
4146
|
+
const read2 = readProjectFile(filePath);
|
|
4147
|
+
if (read2.kind !== "file") {
|
|
4048
4148
|
continue;
|
|
4049
4149
|
}
|
|
4050
|
-
const rawSubHtml = normalizeCompositionSrcs(
|
|
4150
|
+
const rawSubHtml = normalizeCompositionSrcs(read2.text, projectDir);
|
|
4051
4151
|
const nestedVisited = new Set(visited);
|
|
4052
4152
|
nestedVisited.add(filePath);
|
|
4053
4153
|
workItems.push({ srcPath, filePath, rawSubHtml, nestedVisited });
|
|
@@ -4249,9 +4349,9 @@ function inlineSubCompositions(html, subCompositions, projectDir, variableOverri
|
|
|
4249
4349
|
assertOutsideMarkupAsked(projectDir, filePath, srcPath, assetRoot, outsideFiles);
|
|
4250
4350
|
assertCompositionFileSize(filePath, srcPath);
|
|
4251
4351
|
}
|
|
4252
|
-
const
|
|
4253
|
-
return
|
|
4254
|
-
normalizeCompositionSrcs(
|
|
4352
|
+
const read2 = filePath && !isPrivateCompositionFile(projectDir, filePath) ? readProjectFile(filePath) : null;
|
|
4353
|
+
return read2?.kind === "file" ? rewriteUnresolvableGsapToCdn(
|
|
4354
|
+
normalizeCompositionSrcs(read2.text, projectDir),
|
|
4255
4355
|
projectDir,
|
|
4256
4356
|
srcPath
|
|
4257
4357
|
) : null;
|
|
@@ -4478,6 +4578,9 @@ async function inlineExternalScripts(html, budget = new CompositionExpansionBudg
|
|
|
4478
4578
|
});
|
|
4479
4579
|
const remote = new Set(externalScripts.filter((_, i) => !local[i]).map(({ src }) => src));
|
|
4480
4580
|
assertRemoteFetchCount("scripts", remote.size);
|
|
4581
|
+
const pinned = new Set(
|
|
4582
|
+
externalScripts.filter(({ el }) => el.getAttribute("integrity")).map(({ src }) => src)
|
|
4583
|
+
);
|
|
4481
4584
|
const mirror = operatorGsapMirror();
|
|
4482
4585
|
const limit = createConcurrencyLimit(MAX_CONCURRENT_SCRIPT_FETCHES);
|
|
4483
4586
|
const stop = new AbortController();
|
|
@@ -4500,7 +4603,16 @@ async function inlineExternalScripts(html, budget = new CompositionExpansionBudg
|
|
|
4500
4603
|
if (!bytes) {
|
|
4501
4604
|
bytes = limit(async () => {
|
|
4502
4605
|
fetchSignal.throwIfAborted();
|
|
4503
|
-
const downloaded = await downloadScript(src, mirror, fetchSignal)
|
|
4606
|
+
const downloaded = await downloadScript(src, mirror, fetchSignal).catch(
|
|
4607
|
+
(error) => {
|
|
4608
|
+
const standIn = pinned.has(src) || fetchSignal.aborted ? null : bundledGsapStandIn(src);
|
|
4609
|
+
if (!standIn) throw error;
|
|
4610
|
+
defaultLogger.warn(
|
|
4611
|
+
`[Compiler] Could not download ${src} (${error}); using the host's own GSAP instead.`
|
|
4612
|
+
);
|
|
4613
|
+
return standIn;
|
|
4614
|
+
}
|
|
4615
|
+
);
|
|
4504
4616
|
charge(downloaded.byteLength);
|
|
4505
4617
|
return downloaded;
|
|
4506
4618
|
}, fetchSignal);
|
|
@@ -4984,7 +5096,7 @@ async function embedLocalFontFaces(html, projectDir, assetRoot, budget, log = de
|
|
|
4984
5096
|
}
|
|
4985
5097
|
function renderGsapDist() {
|
|
4986
5098
|
try {
|
|
4987
|
-
return
|
|
5099
|
+
return gsapCdnDist(void 0, normalizeGsapBaseUrl(process.env.HYPERFRAMES_GSAP_BASE_URL));
|
|
4988
5100
|
} catch (cause) {
|
|
4989
5101
|
throw new Error(
|
|
4990
5102
|
"Invalid HYPERFRAMES_GSAP_BASE_URL: use an absolute HTTPS npm mirror root (plain HTTP only for localhost) without credentials, query, or fragment",
|
|
@@ -5872,11 +5984,14 @@ import {
|
|
|
5872
5984
|
compositionRequiresWebGpu,
|
|
5873
5985
|
createCaptureSession as createCaptureSession4,
|
|
5874
5986
|
deriveBeginFrameProbeTimeTicks,
|
|
5987
|
+
extractMediaMetadata as extractMediaMetadata4,
|
|
5875
5988
|
getCompositionDuration,
|
|
5876
5989
|
getCompositionLengthSource,
|
|
5877
5990
|
initializeSession as initializeSession4,
|
|
5991
|
+
isMemoryExhaustionError,
|
|
5878
5992
|
isTransientBrowserError,
|
|
5879
5993
|
probeBeginFrameLiveness,
|
|
5994
|
+
resolveProjectRelativeSrc as resolveProjectRelativeSrc4,
|
|
5880
5995
|
videoAudioId
|
|
5881
5996
|
} from "@hyperframes/engine";
|
|
5882
5997
|
import {
|
|
@@ -5981,6 +6096,29 @@ function hasVariableBoundMedia(html, variables, variablesByComp = {}) {
|
|
|
5981
6096
|
);
|
|
5982
6097
|
});
|
|
5983
6098
|
}
|
|
6099
|
+
async function probeVideoHold(videos, html, projectDir, compiledDir) {
|
|
6100
|
+
const { document: document2 } = parseHTML6(html);
|
|
6101
|
+
const bound = /* @__PURE__ */ new Set();
|
|
6102
|
+
for (const video of document2.querySelectorAll("video")) {
|
|
6103
|
+
if (!video.matches("[data-var-src]") && !video.querySelector("source[data-var-src]")) continue;
|
|
6104
|
+
const id = video.getAttribute(MEDIA_RENDER_ID_ATTR2) || video.getAttribute("id");
|
|
6105
|
+
if (id) bound.add(id);
|
|
6106
|
+
}
|
|
6107
|
+
const hints = await Promise.all(
|
|
6108
|
+
videos.map(async ({ id, src }) => {
|
|
6109
|
+
if (bound.has(id) || /^https?:\/\//i.test(src)) return null;
|
|
6110
|
+
try {
|
|
6111
|
+
const path = resolveProjectRelativeSrc4(src, projectDir, compiledDir);
|
|
6112
|
+
const { width, height } = await extractMediaMetadata4(path);
|
|
6113
|
+
return width > 0 && height > 0 ? { id, width, height } : null;
|
|
6114
|
+
} catch {
|
|
6115
|
+
return null;
|
|
6116
|
+
}
|
|
6117
|
+
})
|
|
6118
|
+
);
|
|
6119
|
+
const held = hints.filter((hint) => hint !== null);
|
|
6120
|
+
return { skipReadinessVideoIds: held.map((hint) => hint.id), videoMetadataHints: held };
|
|
6121
|
+
}
|
|
5984
6122
|
function authoredMediaStarts(html) {
|
|
5985
6123
|
const { document: document2 } = parseHTML6(html);
|
|
5986
6124
|
const starts = /* @__PURE__ */ new Map();
|
|
@@ -6117,6 +6255,16 @@ function reportedLengthSource(source) {
|
|
|
6117
6255
|
const srcHash = createHash6("sha256").update(name).digest("hex").slice(0, 12);
|
|
6118
6256
|
return { from: "media", tag: source.tag, trimmed: source.trimmed, srcHash };
|
|
6119
6257
|
}
|
|
6258
|
+
var STOPPED = "Preparing the render stopped while ";
|
|
6259
|
+
async function probeStep(step, call) {
|
|
6260
|
+
try {
|
|
6261
|
+
return await call();
|
|
6262
|
+
} catch (error) {
|
|
6263
|
+
if (error instanceof Error && !error.message.startsWith(STOPPED) && !isMemoryExhaustionError(error))
|
|
6264
|
+
error.message = `${STOPPED}${step}: ${error.message}`;
|
|
6265
|
+
throw error;
|
|
6266
|
+
}
|
|
6267
|
+
}
|
|
6120
6268
|
async function runProbeStage(input) {
|
|
6121
6269
|
const {
|
|
6122
6270
|
projectDir,
|
|
@@ -6189,6 +6337,12 @@ async function runProbeStage(input) {
|
|
|
6189
6337
|
assertNotAborted();
|
|
6190
6338
|
const motionBlur = job.config.motionBlur;
|
|
6191
6339
|
const captureOpts = {
|
|
6340
|
+
...await probeVideoHold(
|
|
6341
|
+
composition.videos,
|
|
6342
|
+
compiled.html,
|
|
6343
|
+
projectDir,
|
|
6344
|
+
join11(workDir, "compiled")
|
|
6345
|
+
),
|
|
6192
6346
|
recordReferenceBackground: input.recordReferenceBackground,
|
|
6193
6347
|
width,
|
|
6194
6348
|
height,
|
|
@@ -6227,7 +6381,8 @@ async function runProbeStage(input) {
|
|
|
6227
6381
|
log.info(`Still waiting for browser initialization... (${elapsed}s elapsed)`);
|
|
6228
6382
|
}, 3e4);
|
|
6229
6383
|
try {
|
|
6230
|
-
|
|
6384
|
+
const opening = probeSession;
|
|
6385
|
+
await probeStep("opening the film in the browser", () => initializeSession4(opening));
|
|
6231
6386
|
} finally {
|
|
6232
6387
|
clearInterval(heartbeat);
|
|
6233
6388
|
}
|
|
@@ -6306,7 +6461,8 @@ async function runProbeStage(input) {
|
|
|
6306
6461
|
null,
|
|
6307
6462
|
{ ...probeCfg, forceScreenshot: true }
|
|
6308
6463
|
);
|
|
6309
|
-
|
|
6464
|
+
const reopening = probeSession;
|
|
6465
|
+
await probeStep("opening the film in the browser", () => initializeSession4(reopening));
|
|
6310
6466
|
assertNotAborted();
|
|
6311
6467
|
lastBrowserConsole = probeSession.browserConsoleBuffer;
|
|
6312
6468
|
}
|
|
@@ -6314,8 +6470,13 @@ async function runProbeStage(input) {
|
|
|
6314
6470
|
const session = probeSession;
|
|
6315
6471
|
if (composition.duration <= 0) {
|
|
6316
6472
|
log.info("Discovering composition duration...");
|
|
6317
|
-
const discoveredDuration = await
|
|
6318
|
-
|
|
6473
|
+
const discoveredDuration = await probeStep(
|
|
6474
|
+
"reading the film's length",
|
|
6475
|
+
() => getCompositionDuration(session)
|
|
6476
|
+
);
|
|
6477
|
+
lengthSource = reportedLengthSource(
|
|
6478
|
+
await probeStep("reading the film's length", () => getCompositionLengthSource(session))
|
|
6479
|
+
);
|
|
6319
6480
|
assertNotAborted();
|
|
6320
6481
|
log.info("Probed composition duration from browser", {
|
|
6321
6482
|
discoveredDuration,
|
|
@@ -6329,9 +6490,9 @@ async function runProbeStage(input) {
|
|
|
6329
6490
|
});
|
|
6330
6491
|
}
|
|
6331
6492
|
if (compiled.unresolvedCompositions.length > 0) {
|
|
6332
|
-
const resolutions = await
|
|
6333
|
-
|
|
6334
|
-
compiled.unresolvedCompositions
|
|
6493
|
+
const resolutions = await probeStep(
|
|
6494
|
+
"reading each scene's length",
|
|
6495
|
+
() => resolveCompositionDurations(session.page, compiled.unresolvedCompositions)
|
|
6335
6496
|
);
|
|
6336
6497
|
assertNotAborted();
|
|
6337
6498
|
if (resolutions.length > 0) {
|
|
@@ -6351,7 +6512,10 @@ async function runProbeStage(input) {
|
|
|
6351
6512
|
}
|
|
6352
6513
|
}
|
|
6353
6514
|
log.info("Discovering media assets from browser DOM...");
|
|
6354
|
-
const browserMedia = await
|
|
6515
|
+
const browserMedia = await probeStep(
|
|
6516
|
+
"listing the film's videos, audio and images",
|
|
6517
|
+
() => discoverMediaFromBrowser(session.page)
|
|
6518
|
+
);
|
|
6355
6519
|
assertNotAborted();
|
|
6356
6520
|
if (browserMedia.length > 0) {
|
|
6357
6521
|
const existingVideoIds = new Set(composition.videos.map((v) => v.id));
|
|
@@ -6489,11 +6653,14 @@ async function runProbeStage(input) {
|
|
|
6489
6653
|
log.info("Discovering audio volume automation...", {
|
|
6490
6654
|
audioCount: composition.audios.length
|
|
6491
6655
|
});
|
|
6492
|
-
const automation = await
|
|
6493
|
-
|
|
6494
|
-
|
|
6495
|
-
|
|
6496
|
-
|
|
6656
|
+
const automation = await probeStep(
|
|
6657
|
+
"reading the audio's volume changes",
|
|
6658
|
+
() => discoverAudioVolumeAutomationFromTimeline(
|
|
6659
|
+
session.page,
|
|
6660
|
+
composition.audios.map((audio) => audio.id),
|
|
6661
|
+
composition.duration,
|
|
6662
|
+
fpsToNumber6(job.config.fps)
|
|
6663
|
+
)
|
|
6497
6664
|
);
|
|
6498
6665
|
assertNotAborted();
|
|
6499
6666
|
if (automation.length > 0) {
|
|
@@ -6512,9 +6679,9 @@ async function runProbeStage(input) {
|
|
|
6512
6679
|
log.info("Discovering video visibility windows...", {
|
|
6513
6680
|
videoCount: composition.videos.length
|
|
6514
6681
|
});
|
|
6515
|
-
const visibilityWindows = await
|
|
6516
|
-
|
|
6517
|
-
composition.duration
|
|
6682
|
+
const visibilityWindows = await probeStep(
|
|
6683
|
+
"finding when each video is on screen",
|
|
6684
|
+
() => discoverVideoVisibilityFromTimeline(session.page, composition.duration)
|
|
6518
6685
|
);
|
|
6519
6686
|
assertNotAborted();
|
|
6520
6687
|
for (const win of visibilityWindows) {
|
|
@@ -6713,7 +6880,7 @@ import {
|
|
|
6713
6880
|
createFrameLookupTable as createFrameLookupTable3,
|
|
6714
6881
|
detectTransfer,
|
|
6715
6882
|
extractAllVideoFrames,
|
|
6716
|
-
extractMediaMetadata as
|
|
6883
|
+
extractMediaMetadata as extractMediaMetadata5,
|
|
6717
6884
|
gradingKeepsSdr as gradingKeepsSdr2,
|
|
6718
6885
|
isVideoPastTimelineEnd,
|
|
6719
6886
|
isHdrColorSpace as isHdrColorSpace2,
|
|
@@ -6727,7 +6894,7 @@ import {
|
|
|
6727
6894
|
resolveRestrictPageNetwork,
|
|
6728
6895
|
isUrlNotPermittedError,
|
|
6729
6896
|
writeUrlDownloadTelemetry as writeUrlDownloadTelemetry2,
|
|
6730
|
-
resolveProjectRelativeSrc as
|
|
6897
|
+
resolveProjectRelativeSrc as resolveProjectRelativeSrc5,
|
|
6731
6898
|
runVideoExtractionWithRetry as runVideoExtractionWithRetry2,
|
|
6732
6899
|
safeVideoExtractionSourceIdentity,
|
|
6733
6900
|
videoAudioId as videoAudioId2
|
|
@@ -6943,7 +7110,7 @@ function applyVideoExtractionFailurePolicy(result, policy, log) {
|
|
|
6943
7110
|
}
|
|
6944
7111
|
async function probeColorSpaceSafely(path, log) {
|
|
6945
7112
|
try {
|
|
6946
|
-
const meta = await
|
|
7113
|
+
const meta = await extractMediaMetadata5(path);
|
|
6947
7114
|
return meta.colorSpace;
|
|
6948
7115
|
} catch (error) {
|
|
6949
7116
|
log?.warn("HDR color-space probe failed; treating source as SDR", {
|
|
@@ -6989,14 +7156,14 @@ async function runExtractVideosStage(input) {
|
|
|
6989
7156
|
log?.info("Probing video color spaces...", { videoCount: composition.videos.length });
|
|
6990
7157
|
const probeFailures = await Promise.all(
|
|
6991
7158
|
composition.videos.map(async (v) => {
|
|
6992
|
-
const videoPath =
|
|
7159
|
+
const videoPath = resolveProjectRelativeSrc5(v.src, projectDir, compiledDir);
|
|
6993
7160
|
if (!opensLocally(videoPath, assetRoots)) return null;
|
|
6994
7161
|
try {
|
|
6995
7162
|
const attempted = extractionPolicy.maxTransientRetries === 0 ? {
|
|
6996
|
-
result: await
|
|
7163
|
+
result: await extractMediaMetadata5(videoPath, { signal: abortSignal }),
|
|
6997
7164
|
retries: 0
|
|
6998
7165
|
} : await runVideoExtractionWithRetry2(
|
|
6999
|
-
() =>
|
|
7166
|
+
() => extractMediaMetadata5(videoPath, { signal: abortSignal }),
|
|
7000
7167
|
{
|
|
7001
7168
|
signal: abortSignal,
|
|
7002
7169
|
maxTransientRetries: extractionPolicy.maxTransientRetries,
|
|
@@ -7033,7 +7200,7 @@ async function runExtractVideosStage(input) {
|
|
|
7033
7200
|
if (probesHdr && composition.images.length > 0) {
|
|
7034
7201
|
const probed = await Promise.all(
|
|
7035
7202
|
composition.images.map(async (img) => {
|
|
7036
|
-
const imgPath =
|
|
7203
|
+
const imgPath = resolveProjectRelativeSrc5(img.src, projectDir, compiledDir);
|
|
7037
7204
|
if (!opensLocally(imgPath, assetRoots)) return null;
|
|
7038
7205
|
const colorSpace = await probeColorSpaceSafely(imgPath, log);
|
|
7039
7206
|
if (isHdrColorSpace2(colorSpace)) {
|
|
@@ -7168,7 +7335,7 @@ function opensLocally(path, assetRoots) {
|
|
|
7168
7335
|
return existsSync9(path) && (!assetRoots || assetRootsRefusal(path, assetRoots) === null);
|
|
7169
7336
|
}
|
|
7170
7337
|
function localProbeSource(src, input) {
|
|
7171
|
-
const path =
|
|
7338
|
+
const path = resolveProjectRelativeSrc5(src, input.projectDir, input.compiledDir);
|
|
7172
7339
|
const readFrom = input.urlByAbsentLocalPath?.get(path) ?? path;
|
|
7173
7340
|
const roots = input.allowOutsideProjectAssets ? void 0 : mediaAssetRoots(input.projectDir, input.compiledDir);
|
|
7174
7341
|
return isHttpUrl3(readFrom) || opensLocally(readFrom, roots) ? readFrom : null;
|
|
@@ -7199,7 +7366,7 @@ async function appendVideoAudioFromProbe(input) {
|
|
|
7199
7366
|
videos.map(async (video) => {
|
|
7200
7367
|
const readFrom = isHttpUrl3(video.src) ? await remoteProbeSource(video, input) : localProbeSource(video.src, input);
|
|
7201
7368
|
if (readFrom === null) return null;
|
|
7202
|
-
const metadata = await
|
|
7369
|
+
const metadata = await extractMediaMetadata5(readFrom, { signal: input.signal });
|
|
7203
7370
|
const window2 = await resolveFinalFrameExtractionWindow2(
|
|
7204
7371
|
readFrom,
|
|
7205
7372
|
video,
|
|
@@ -7222,7 +7389,7 @@ import {
|
|
|
7222
7389
|
buildVideoLayerInput,
|
|
7223
7390
|
isHttpUrl as isHttpUrl4,
|
|
7224
7391
|
qualifyVideoLayer,
|
|
7225
|
-
resolveProjectRelativeSrc as
|
|
7392
|
+
resolveProjectRelativeSrc as resolveProjectRelativeSrc6
|
|
7226
7393
|
} from "@hyperframes/engine";
|
|
7227
7394
|
|
|
7228
7395
|
// src/services/render/stages/audioStage.ts
|
|
@@ -10252,14 +10419,14 @@ function child2(buf, parent, type) {
|
|
|
10252
10419
|
return found;
|
|
10253
10420
|
}
|
|
10254
10421
|
var SCAN_BYTES = 64 * 1024;
|
|
10255
|
-
async function readMp4Layout(
|
|
10422
|
+
async function readMp4Layout(read2) {
|
|
10256
10423
|
const found = /* @__PURE__ */ new Map();
|
|
10257
10424
|
let payload;
|
|
10258
10425
|
let buf = Buffer.alloc(0);
|
|
10259
10426
|
let bufAt = 0;
|
|
10260
10427
|
const load = async (start, end) => {
|
|
10261
10428
|
if (start >= bufAt && end <= bufAt + buf.length) return;
|
|
10262
|
-
buf = await
|
|
10429
|
+
buf = await read2(start, Math.max(end, start + SCAN_BYTES));
|
|
10263
10430
|
bufAt = start;
|
|
10264
10431
|
};
|
|
10265
10432
|
for (let at = 0; !(found.has("ftyp") && found.has("moov") && payload); ) {
|
|
@@ -14203,9 +14370,9 @@ function hashProjectDir(projectDir, files = listSiteFiles(projectDir)) {
|
|
|
14203
14370
|
hash.update("\0");
|
|
14204
14371
|
const fd = openSync5(join34(projectDir, rel), "r");
|
|
14205
14372
|
try {
|
|
14206
|
-
let
|
|
14207
|
-
while ((
|
|
14208
|
-
hash.update(chunk.subarray(0,
|
|
14373
|
+
let read2;
|
|
14374
|
+
while ((read2 = readSync4(fd, chunk, 0, chunk.length, null)) > 0) {
|
|
14375
|
+
hash.update(chunk.subarray(0, read2));
|
|
14209
14376
|
}
|
|
14210
14377
|
} finally {
|
|
14211
14378
|
closeSync5(fd);
|
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
{
|
|
2
2
|
"version": "0.1.0",
|
|
3
3
|
"buildId": "dev",
|
|
4
|
-
"sha256": "
|
|
4
|
+
"sha256": "d56d279eab6240b740f1086bddc68b57ad9bfc1c4db4a35329612330e3830ae6",
|
|
5
5
|
"artifacts": {
|
|
6
6
|
"iife": "hyperframe.runtime.iife.js",
|
|
7
7
|
"esm": "hyperframe.runtime.mjs"
|