@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/public-server.js
CHANGED
|
@@ -359,7 +359,7 @@ function firstCompositionIdTag(html) {
|
|
|
359
359
|
// src/services/renderOrchestrator.ts
|
|
360
360
|
import { matchHtmlBodyCssHeightFirst, matchHtmlBodyCssWidthFirst } from "@hyperframes/parsers";
|
|
361
361
|
import {
|
|
362
|
-
extractMediaMetadata as
|
|
362
|
+
extractMediaMetadata as extractMediaMetadata6,
|
|
363
363
|
resolveConfig as resolveConfig2,
|
|
364
364
|
closeCaptureSession as closeCaptureSession8,
|
|
365
365
|
createCaptureSession as createCaptureSession8,
|
|
@@ -382,7 +382,7 @@ import {
|
|
|
382
382
|
scaleProtocolTimeoutForComposition,
|
|
383
383
|
classifyCaptureFailure as classifyCaptureFailure3,
|
|
384
384
|
cloneCaptureWarning,
|
|
385
|
-
isMemoryExhaustionError,
|
|
385
|
+
isMemoryExhaustionError as isMemoryExhaustionError2,
|
|
386
386
|
isTransientBrowserError as isTransientBrowserError2,
|
|
387
387
|
isDrawElementVerificationError,
|
|
388
388
|
isDrawElementCaptureError,
|
|
@@ -2129,9 +2129,9 @@ import { createStagingDir } from "@hyperframes/core/atomic-file";
|
|
|
2129
2129
|
var OWNER_FILE = "owner.json";
|
|
2130
2130
|
var TRANSACTION_BACKUP = "backup";
|
|
2131
2131
|
function pidScope() {
|
|
2132
|
-
const attempt = (
|
|
2132
|
+
const attempt = (read2) => {
|
|
2133
2133
|
try {
|
|
2134
|
-
return
|
|
2134
|
+
return read2();
|
|
2135
2135
|
} catch {
|
|
2136
2136
|
return void 0;
|
|
2137
2137
|
}
|
|
@@ -7139,13 +7139,21 @@ import { parseHTML as parseHTML5 } from "linkedom";
|
|
|
7139
7139
|
// src/services/bundledScripts.ts
|
|
7140
7140
|
import { existsSync as existsSync8, readFileSync as readFileSync5 } from "node:fs";
|
|
7141
7141
|
import { join as join17 } from "node:path";
|
|
7142
|
-
import {
|
|
7142
|
+
import { GSAP_CDN_VERSION } from "@hyperframes/core/gsap-cdn";
|
|
7143
7143
|
var GSAP_VENDOR_DIR_ENV = "HYPERFRAMES_GSAP_VENDOR_DIR";
|
|
7144
|
+
var DEFAULT_CDN_GSAP_3 = /^https:\/\/cdn\.jsdelivr\.net\/npm\/gsap@(3\.\d+\.\d+)\/dist\/([A-Za-z]+\.min\.js)$/;
|
|
7145
|
+
var read = (file) => existsSync8(file) ? readFileSync5(file) : null;
|
|
7144
7146
|
function bundledScript(url) {
|
|
7145
7147
|
const dir = process.env[GSAP_VENDOR_DIR_ENV];
|
|
7146
|
-
|
|
7147
|
-
|
|
7148
|
-
|
|
7148
|
+
const [, version, file] = DEFAULT_CDN_GSAP_3.exec(url) ?? [];
|
|
7149
|
+
if (!dir || !version || !file) return null;
|
|
7150
|
+
const at = version === GSAP_CDN_VERSION ? dir : join17(dir, "..", "..", `gsap@${version}`, "dist");
|
|
7151
|
+
return read(join17(at, file));
|
|
7152
|
+
}
|
|
7153
|
+
function bundledGsapStandIn(url) {
|
|
7154
|
+
const dir = process.env[GSAP_VENDOR_DIR_ENV];
|
|
7155
|
+
const [, , file] = DEFAULT_CDN_GSAP_3.exec(url) ?? [];
|
|
7156
|
+
return dir && file ? read(join17(dir, file)) : null;
|
|
7149
7157
|
}
|
|
7150
7158
|
|
|
7151
7159
|
// src/services/htmlCompiler.ts
|
|
@@ -7171,7 +7179,7 @@ import { MAX_AUDIO_GAIN } from "@hyperframes/core/audio-gain";
|
|
|
7171
7179
|
import { CAPTURE_CANVAS_SELECTOR } from "@hyperframes/core/html-in-canvas";
|
|
7172
7180
|
import { readPlaybackRate } from "@hyperframes/parsers/media-duration";
|
|
7173
7181
|
import { resolveRateSpec } from "@hyperframes/core/speed-ramp";
|
|
7174
|
-
import { gsapCdnDist
|
|
7182
|
+
import { gsapCdnDist, normalizeGsapBaseUrl } from "@hyperframes/core/gsap-cdn";
|
|
7175
7183
|
import {
|
|
7176
7184
|
assignBundledRuntimeCompositionIds,
|
|
7177
7185
|
assignMediaRenderIds,
|
|
@@ -8317,13 +8325,13 @@ function compositionPathProblem(projectDir, filePath, assetRoot, outsideFiles) {
|
|
|
8317
8325
|
}
|
|
8318
8326
|
function readSubCompositionFile(filePath, srcPath) {
|
|
8319
8327
|
assertCompositionFileSize(filePath, srcPath);
|
|
8320
|
-
const
|
|
8321
|
-
if (
|
|
8322
|
-
if (
|
|
8323
|
-
const validity = checkSubCompositionUsability(
|
|
8328
|
+
const read2 = readProjectFile(filePath);
|
|
8329
|
+
if (read2.kind === "missing") return { detail: "the file does not exist" };
|
|
8330
|
+
if (read2.kind === "folder") return { detail: "it is a folder, not an HTML file" };
|
|
8331
|
+
const validity = checkSubCompositionUsability(read2.text, parseSubCompHtmlForValidity);
|
|
8324
8332
|
if (!validity.ok)
|
|
8325
8333
|
return { detail: validity.detail ?? "the file is empty or could not be parsed" };
|
|
8326
|
-
return { bytes: Buffer.byteLength(
|
|
8334
|
+
return { bytes: Buffer.byteLength(read2.text), ...compositionSrcsIn(read2.text) };
|
|
8327
8335
|
}
|
|
8328
8336
|
function assertSubCompositionsUsable(html, projectDir, assetRoot, outsideFiles) {
|
|
8329
8337
|
const budget = new CompositionExpansionBudget();
|
|
@@ -8424,6 +8432,96 @@ var THREE_D_CONTEXT_PATTERN = /transform-style\s*:\s*preserve-3d|backface-visibi
|
|
|
8424
8432
|
function detectThreeDTransformUsage(html) {
|
|
8425
8433
|
return THREE_D_CONTEXT_PATTERN.test(html);
|
|
8426
8434
|
}
|
|
8435
|
+
var CSS_ESCAPE = /\\(?:[0-9a-fA-F]{1,6}[ \t\n\r\f]?|[^])?/y;
|
|
8436
|
+
function ancestorSelectorSteps(list) {
|
|
8437
|
+
const selectors = [];
|
|
8438
|
+
let steps = [];
|
|
8439
|
+
let combinators = [];
|
|
8440
|
+
let compound = "";
|
|
8441
|
+
let open = false;
|
|
8442
|
+
let combinator = null;
|
|
8443
|
+
const skipGroup = (at, close) => {
|
|
8444
|
+
let depth = 0;
|
|
8445
|
+
for (let i = at; i < list.length; i++) {
|
|
8446
|
+
const ch = list[i];
|
|
8447
|
+
if (ch === "\\") i++;
|
|
8448
|
+
else if (ch === '"' || ch === "'") {
|
|
8449
|
+
const end = list.indexOf(ch, i + 1);
|
|
8450
|
+
if (end < 0) return -1;
|
|
8451
|
+
i = end;
|
|
8452
|
+
} else if (ch === list[at]) depth++;
|
|
8453
|
+
else if (ch === close && --depth === 0) return i;
|
|
8454
|
+
}
|
|
8455
|
+
return -1;
|
|
8456
|
+
};
|
|
8457
|
+
const flush = () => {
|
|
8458
|
+
if (!open) return;
|
|
8459
|
+
if ((combinator === "+" || combinator === "~") && steps.length > 0) {
|
|
8460
|
+
steps.pop();
|
|
8461
|
+
combinator = combinators.pop() ?? null;
|
|
8462
|
+
}
|
|
8463
|
+
steps.push({ compound: compound || "*", child: combinator === ">" });
|
|
8464
|
+
combinators.push(combinator);
|
|
8465
|
+
compound = "";
|
|
8466
|
+
open = false;
|
|
8467
|
+
combinator = null;
|
|
8468
|
+
};
|
|
8469
|
+
for (let i = 0; i <= list.length; i++) {
|
|
8470
|
+
const ch = list[i];
|
|
8471
|
+
if (ch === void 0 || ch === ",") {
|
|
8472
|
+
flush();
|
|
8473
|
+
if (steps.length) selectors.push(steps);
|
|
8474
|
+
steps = [];
|
|
8475
|
+
combinators = [];
|
|
8476
|
+
combinator = null;
|
|
8477
|
+
} else if (ch === "\\") {
|
|
8478
|
+
CSS_ESCAPE.lastIndex = i;
|
|
8479
|
+
const escape = CSS_ESCAPE.exec(list)[0];
|
|
8480
|
+
compound += escape;
|
|
8481
|
+
i += escape.length - 1;
|
|
8482
|
+
open = true;
|
|
8483
|
+
} else if (ch === "[") {
|
|
8484
|
+
const end = skipGroup(i, "]");
|
|
8485
|
+
if (end < 0) return null;
|
|
8486
|
+
compound += list.slice(i, end + 1);
|
|
8487
|
+
open = true;
|
|
8488
|
+
i = end;
|
|
8489
|
+
} else if (ch === ":") {
|
|
8490
|
+
while (/[:\w-]/.test(list[i + 1] ?? "")) i++;
|
|
8491
|
+
if (list[i + 1] === "(") i = skipGroup(i + 1, ")");
|
|
8492
|
+
if (i < 0) return null;
|
|
8493
|
+
open = true;
|
|
8494
|
+
} else if (/\s/.test(ch)) {
|
|
8495
|
+
flush();
|
|
8496
|
+
if (steps.length) combinator ??= " ";
|
|
8497
|
+
} else if (ch === ">" || ch === "+" || ch === "~") {
|
|
8498
|
+
flush();
|
|
8499
|
+
combinator = ch;
|
|
8500
|
+
} else if (ch === "(" || ch === ")" || ch === "]") {
|
|
8501
|
+
return null;
|
|
8502
|
+
} else {
|
|
8503
|
+
compound += ch;
|
|
8504
|
+
open = true;
|
|
8505
|
+
}
|
|
8506
|
+
}
|
|
8507
|
+
return selectors;
|
|
8508
|
+
}
|
|
8509
|
+
function matchesAnAncestor(steps, ancestors) {
|
|
8510
|
+
let reach = ancestors.map((el) => el.matches(steps[0].compound));
|
|
8511
|
+
for (const step of steps.slice(1)) {
|
|
8512
|
+
let above = false;
|
|
8513
|
+
const next = ancestors.map(() => false);
|
|
8514
|
+
for (let j = ancestors.length - 1; j >= 0; j--) {
|
|
8515
|
+
const placed = step.child ? reach[j + 1] === true : above;
|
|
8516
|
+
next[j] = placed && ancestors[j].matches(step.compound);
|
|
8517
|
+
above ||= reach[j];
|
|
8518
|
+
}
|
|
8519
|
+
reach = next;
|
|
8520
|
+
}
|
|
8521
|
+
return reach.includes(true);
|
|
8522
|
+
}
|
|
8523
|
+
var MAX_ROOT_ANCESTORS = 256;
|
|
8524
|
+
var MAX_ANCESTOR_SELECTOR_CHECKS = 1e5;
|
|
8427
8525
|
function detectAncestorBackgroundImage(html) {
|
|
8428
8526
|
const { document: document2 } = parseHTML5(html);
|
|
8429
8527
|
const root = document2.querySelector("[data-composition-id]");
|
|
@@ -8433,6 +8531,8 @@ function detectAncestorBackgroundImage(html) {
|
|
|
8433
8531
|
if (document2.documentElement && !ancestors.includes(document2.documentElement)) {
|
|
8434
8532
|
ancestors.push(document2.documentElement);
|
|
8435
8533
|
}
|
|
8534
|
+
if (ancestors.length > MAX_ROOT_ANCESTORS) return true;
|
|
8535
|
+
let selectorChecks = 0;
|
|
8436
8536
|
for (const el of ancestors) {
|
|
8437
8537
|
const style = el.getAttribute("style");
|
|
8438
8538
|
if (style && hasBackgroundImageDeclaration(`{${style}}`)) return true;
|
|
@@ -8442,14 +8542,14 @@ function detectAncestorBackgroundImage(html) {
|
|
|
8442
8542
|
for (const { parts: rule } of cssRuleMatches(css)) {
|
|
8443
8543
|
const [, selectorList, declarations] = rule;
|
|
8444
8544
|
if (!hasBackgroundImageDeclaration(`{${declarations}}`)) continue;
|
|
8445
|
-
|
|
8446
|
-
|
|
8447
|
-
|
|
8448
|
-
|
|
8545
|
+
if (selectorList.trim().startsWith("@")) continue;
|
|
8546
|
+
const selectors = ancestorSelectorSteps(selectorList);
|
|
8547
|
+
if (!selectors) return true;
|
|
8548
|
+
for (const steps of selectors) {
|
|
8549
|
+
selectorChecks += steps.length * ancestors.length;
|
|
8550
|
+
if (selectorChecks > MAX_ANCESTOR_SELECTOR_CHECKS) return true;
|
|
8449
8551
|
try {
|
|
8450
|
-
|
|
8451
|
-
if (ancestors.includes(matched)) return true;
|
|
8452
|
-
}
|
|
8552
|
+
if (matchesAnAncestor(steps, ancestors)) return true;
|
|
8453
8553
|
} catch {
|
|
8454
8554
|
}
|
|
8455
8555
|
}
|
|
@@ -8698,11 +8798,11 @@ async function parseSubCompositions(html, projectDir, downloadDir, visited = /*
|
|
|
8698
8798
|
compiledSrcs.add(srcPath);
|
|
8699
8799
|
assertOutsideMarkupAsked(projectDir, filePath, srcPath, assetRoot, outsideFiles);
|
|
8700
8800
|
assertCompositionFileSize(filePath, srcPath);
|
|
8701
|
-
const
|
|
8702
|
-
if (
|
|
8801
|
+
const read2 = readProjectFile(filePath);
|
|
8802
|
+
if (read2.kind !== "file") {
|
|
8703
8803
|
continue;
|
|
8704
8804
|
}
|
|
8705
|
-
const rawSubHtml = normalizeCompositionSrcs(
|
|
8805
|
+
const rawSubHtml = normalizeCompositionSrcs(read2.text, projectDir);
|
|
8706
8806
|
const nestedVisited = new Set(visited);
|
|
8707
8807
|
nestedVisited.add(filePath);
|
|
8708
8808
|
workItems.push({ srcPath, filePath, rawSubHtml, nestedVisited });
|
|
@@ -8904,9 +9004,9 @@ function inlineSubCompositions(html, subCompositions, projectDir, variableOverri
|
|
|
8904
9004
|
assertOutsideMarkupAsked(projectDir, filePath, srcPath, assetRoot, outsideFiles);
|
|
8905
9005
|
assertCompositionFileSize(filePath, srcPath);
|
|
8906
9006
|
}
|
|
8907
|
-
const
|
|
8908
|
-
return
|
|
8909
|
-
normalizeCompositionSrcs(
|
|
9007
|
+
const read2 = filePath && !isPrivateCompositionFile(projectDir, filePath) ? readProjectFile(filePath) : null;
|
|
9008
|
+
return read2?.kind === "file" ? rewriteUnresolvableGsapToCdn(
|
|
9009
|
+
normalizeCompositionSrcs(read2.text, projectDir),
|
|
8910
9010
|
projectDir,
|
|
8911
9011
|
srcPath
|
|
8912
9012
|
) : null;
|
|
@@ -9133,6 +9233,9 @@ async function inlineExternalScripts(html, budget = new CompositionExpansionBudg
|
|
|
9133
9233
|
});
|
|
9134
9234
|
const remote = new Set(externalScripts.filter((_, i) => !local[i]).map(({ src }) => src));
|
|
9135
9235
|
assertRemoteFetchCount("scripts", remote.size);
|
|
9236
|
+
const pinned = new Set(
|
|
9237
|
+
externalScripts.filter(({ el }) => el.getAttribute("integrity")).map(({ src }) => src)
|
|
9238
|
+
);
|
|
9136
9239
|
const mirror = operatorGsapMirror();
|
|
9137
9240
|
const limit = createConcurrencyLimit(MAX_CONCURRENT_SCRIPT_FETCHES);
|
|
9138
9241
|
const stop = new AbortController();
|
|
@@ -9155,7 +9258,16 @@ async function inlineExternalScripts(html, budget = new CompositionExpansionBudg
|
|
|
9155
9258
|
if (!bytes) {
|
|
9156
9259
|
bytes = limit(async () => {
|
|
9157
9260
|
fetchSignal.throwIfAborted();
|
|
9158
|
-
const downloaded = await downloadScript(src, mirror, fetchSignal)
|
|
9261
|
+
const downloaded = await downloadScript(src, mirror, fetchSignal).catch(
|
|
9262
|
+
(error) => {
|
|
9263
|
+
const standIn = pinned.has(src) || fetchSignal.aborted ? null : bundledGsapStandIn(src);
|
|
9264
|
+
if (!standIn) throw error;
|
|
9265
|
+
defaultLogger.warn(
|
|
9266
|
+
`[Compiler] Could not download ${src} (${error}); using the host's own GSAP instead.`
|
|
9267
|
+
);
|
|
9268
|
+
return standIn;
|
|
9269
|
+
}
|
|
9270
|
+
);
|
|
9159
9271
|
charge(downloaded.byteLength);
|
|
9160
9272
|
return downloaded;
|
|
9161
9273
|
}, fetchSignal);
|
|
@@ -9639,7 +9751,7 @@ async function embedLocalFontFaces(html, projectDir, assetRoot, budget, log = de
|
|
|
9639
9751
|
}
|
|
9640
9752
|
function renderGsapDist() {
|
|
9641
9753
|
try {
|
|
9642
|
-
return
|
|
9754
|
+
return gsapCdnDist(void 0, normalizeGsapBaseUrl(process.env.HYPERFRAMES_GSAP_BASE_URL));
|
|
9643
9755
|
} catch (cause) {
|
|
9644
9756
|
throw new Error(
|
|
9645
9757
|
"Invalid HYPERFRAMES_GSAP_BASE_URL: use an absolute HTTPS npm mirror root (plain HTTP only for localhost) without credentials, query, or fragment",
|
|
@@ -10527,11 +10639,14 @@ import {
|
|
|
10527
10639
|
compositionRequiresWebGpu,
|
|
10528
10640
|
createCaptureSession as createCaptureSession4,
|
|
10529
10641
|
deriveBeginFrameProbeTimeTicks,
|
|
10642
|
+
extractMediaMetadata as extractMediaMetadata4,
|
|
10530
10643
|
getCompositionDuration,
|
|
10531
10644
|
getCompositionLengthSource,
|
|
10532
10645
|
initializeSession as initializeSession4,
|
|
10646
|
+
isMemoryExhaustionError,
|
|
10533
10647
|
isTransientBrowserError,
|
|
10534
10648
|
probeBeginFrameLiveness,
|
|
10649
|
+
resolveProjectRelativeSrc as resolveProjectRelativeSrc4,
|
|
10535
10650
|
videoAudioId
|
|
10536
10651
|
} from "@hyperframes/engine";
|
|
10537
10652
|
import {
|
|
@@ -10636,6 +10751,33 @@ function hasVariableBoundMedia(html, variables, variablesByComp = {}) {
|
|
|
10636
10751
|
);
|
|
10637
10752
|
});
|
|
10638
10753
|
}
|
|
10754
|
+
async function probeVideoHold(videos, html, projectDir, compiledDir) {
|
|
10755
|
+
const { document: document2 } = parseHTML6(html);
|
|
10756
|
+
const bound = /* @__PURE__ */ new Set();
|
|
10757
|
+
for (const video of document2.querySelectorAll("video")) {
|
|
10758
|
+
if (!video.matches("[data-var-src]") && !video.querySelector("source[data-var-src]")) continue;
|
|
10759
|
+
const id = video.getAttribute(MEDIA_RENDER_ID_ATTR2) || video.getAttribute("id");
|
|
10760
|
+
if (id) bound.add(id);
|
|
10761
|
+
}
|
|
10762
|
+
const hints = await Promise.all(
|
|
10763
|
+
videos.map(async ({ id, src }) => {
|
|
10764
|
+
if (bound.has(id) || /^https?:\/\//i.test(src)) return null;
|
|
10765
|
+
try {
|
|
10766
|
+
const path = resolveProjectRelativeSrc4(src, projectDir, compiledDir);
|
|
10767
|
+
const { width, height } = await extractMediaMetadata4(path);
|
|
10768
|
+
return width > 0 && height > 0 ? { id, width, height } : null;
|
|
10769
|
+
} catch {
|
|
10770
|
+
return null;
|
|
10771
|
+
}
|
|
10772
|
+
})
|
|
10773
|
+
);
|
|
10774
|
+
const held = hints.filter((hint) => hint !== null);
|
|
10775
|
+
return { skipReadinessVideoIds: held.map((hint) => hint.id), videoMetadataHints: held };
|
|
10776
|
+
}
|
|
10777
|
+
function probeHoldFitsCapture(probeHeld, captureHeld) {
|
|
10778
|
+
const held = new Set(captureHeld);
|
|
10779
|
+
return (probeHeld ?? []).every((id) => held.has(id));
|
|
10780
|
+
}
|
|
10639
10781
|
function authoredMediaStarts(html) {
|
|
10640
10782
|
const { document: document2 } = parseHTML6(html);
|
|
10641
10783
|
const starts = /* @__PURE__ */ new Map();
|
|
@@ -10772,6 +10914,16 @@ function reportedLengthSource(source) {
|
|
|
10772
10914
|
const srcHash = createHash7("sha256").update(name).digest("hex").slice(0, 12);
|
|
10773
10915
|
return { from: "media", tag: source.tag, trimmed: source.trimmed, srcHash };
|
|
10774
10916
|
}
|
|
10917
|
+
var STOPPED = "Preparing the render stopped while ";
|
|
10918
|
+
async function probeStep(step, call) {
|
|
10919
|
+
try {
|
|
10920
|
+
return await call();
|
|
10921
|
+
} catch (error) {
|
|
10922
|
+
if (error instanceof Error && !error.message.startsWith(STOPPED) && !isMemoryExhaustionError(error))
|
|
10923
|
+
error.message = `${STOPPED}${step}: ${error.message}`;
|
|
10924
|
+
throw error;
|
|
10925
|
+
}
|
|
10926
|
+
}
|
|
10775
10927
|
async function runProbeStage(input) {
|
|
10776
10928
|
const {
|
|
10777
10929
|
projectDir,
|
|
@@ -10844,6 +10996,12 @@ async function runProbeStage(input) {
|
|
|
10844
10996
|
assertNotAborted();
|
|
10845
10997
|
const motionBlur = job.config.motionBlur;
|
|
10846
10998
|
const captureOpts = {
|
|
10999
|
+
...await probeVideoHold(
|
|
11000
|
+
composition.videos,
|
|
11001
|
+
compiled.html,
|
|
11002
|
+
projectDir,
|
|
11003
|
+
join23(workDir, "compiled")
|
|
11004
|
+
),
|
|
10847
11005
|
recordReferenceBackground: input.recordReferenceBackground,
|
|
10848
11006
|
width,
|
|
10849
11007
|
height,
|
|
@@ -10882,7 +11040,8 @@ async function runProbeStage(input) {
|
|
|
10882
11040
|
log.info(`Still waiting for browser initialization... (${elapsed}s elapsed)`);
|
|
10883
11041
|
}, 3e4);
|
|
10884
11042
|
try {
|
|
10885
|
-
|
|
11043
|
+
const opening = probeSession;
|
|
11044
|
+
await probeStep("opening the film in the browser", () => initializeSession4(opening));
|
|
10886
11045
|
} finally {
|
|
10887
11046
|
clearInterval(heartbeat);
|
|
10888
11047
|
}
|
|
@@ -10961,7 +11120,8 @@ async function runProbeStage(input) {
|
|
|
10961
11120
|
null,
|
|
10962
11121
|
{ ...probeCfg, forceScreenshot: true }
|
|
10963
11122
|
);
|
|
10964
|
-
|
|
11123
|
+
const reopening = probeSession;
|
|
11124
|
+
await probeStep("opening the film in the browser", () => initializeSession4(reopening));
|
|
10965
11125
|
assertNotAborted();
|
|
10966
11126
|
lastBrowserConsole = probeSession.browserConsoleBuffer;
|
|
10967
11127
|
}
|
|
@@ -10969,8 +11129,13 @@ async function runProbeStage(input) {
|
|
|
10969
11129
|
const session = probeSession;
|
|
10970
11130
|
if (composition.duration <= 0) {
|
|
10971
11131
|
log.info("Discovering composition duration...");
|
|
10972
|
-
const discoveredDuration = await
|
|
10973
|
-
|
|
11132
|
+
const discoveredDuration = await probeStep(
|
|
11133
|
+
"reading the film's length",
|
|
11134
|
+
() => getCompositionDuration(session)
|
|
11135
|
+
);
|
|
11136
|
+
lengthSource = reportedLengthSource(
|
|
11137
|
+
await probeStep("reading the film's length", () => getCompositionLengthSource(session))
|
|
11138
|
+
);
|
|
10974
11139
|
assertNotAborted();
|
|
10975
11140
|
log.info("Probed composition duration from browser", {
|
|
10976
11141
|
discoveredDuration,
|
|
@@ -10984,9 +11149,9 @@ async function runProbeStage(input) {
|
|
|
10984
11149
|
});
|
|
10985
11150
|
}
|
|
10986
11151
|
if (compiled.unresolvedCompositions.length > 0) {
|
|
10987
|
-
const resolutions = await
|
|
10988
|
-
|
|
10989
|
-
compiled.unresolvedCompositions
|
|
11152
|
+
const resolutions = await probeStep(
|
|
11153
|
+
"reading each scene's length",
|
|
11154
|
+
() => resolveCompositionDurations(session.page, compiled.unresolvedCompositions)
|
|
10990
11155
|
);
|
|
10991
11156
|
assertNotAborted();
|
|
10992
11157
|
if (resolutions.length > 0) {
|
|
@@ -11006,7 +11171,10 @@ async function runProbeStage(input) {
|
|
|
11006
11171
|
}
|
|
11007
11172
|
}
|
|
11008
11173
|
log.info("Discovering media assets from browser DOM...");
|
|
11009
|
-
const browserMedia = await
|
|
11174
|
+
const browserMedia = await probeStep(
|
|
11175
|
+
"listing the film's videos, audio and images",
|
|
11176
|
+
() => discoverMediaFromBrowser(session.page)
|
|
11177
|
+
);
|
|
11010
11178
|
assertNotAborted();
|
|
11011
11179
|
if (browserMedia.length > 0) {
|
|
11012
11180
|
const existingVideoIds = new Set(composition.videos.map((v) => v.id));
|
|
@@ -11144,11 +11312,14 @@ async function runProbeStage(input) {
|
|
|
11144
11312
|
log.info("Discovering audio volume automation...", {
|
|
11145
11313
|
audioCount: composition.audios.length
|
|
11146
11314
|
});
|
|
11147
|
-
const automation = await
|
|
11148
|
-
|
|
11149
|
-
|
|
11150
|
-
|
|
11151
|
-
|
|
11315
|
+
const automation = await probeStep(
|
|
11316
|
+
"reading the audio's volume changes",
|
|
11317
|
+
() => discoverAudioVolumeAutomationFromTimeline(
|
|
11318
|
+
session.page,
|
|
11319
|
+
composition.audios.map((audio) => audio.id),
|
|
11320
|
+
composition.duration,
|
|
11321
|
+
fpsToNumber6(job.config.fps)
|
|
11322
|
+
)
|
|
11152
11323
|
);
|
|
11153
11324
|
assertNotAborted();
|
|
11154
11325
|
if (automation.length > 0) {
|
|
@@ -11167,9 +11338,9 @@ async function runProbeStage(input) {
|
|
|
11167
11338
|
log.info("Discovering video visibility windows...", {
|
|
11168
11339
|
videoCount: composition.videos.length
|
|
11169
11340
|
});
|
|
11170
|
-
const visibilityWindows = await
|
|
11171
|
-
|
|
11172
|
-
composition.duration
|
|
11341
|
+
const visibilityWindows = await probeStep(
|
|
11342
|
+
"finding when each video is on screen",
|
|
11343
|
+
() => discoverVideoVisibilityFromTimeline(session.page, composition.duration)
|
|
11173
11344
|
);
|
|
11174
11345
|
assertNotAborted();
|
|
11175
11346
|
for (const win of visibilityWindows) {
|
|
@@ -11336,7 +11507,7 @@ import {
|
|
|
11336
11507
|
createFrameLookupTable as createFrameLookupTable3,
|
|
11337
11508
|
detectTransfer,
|
|
11338
11509
|
extractAllVideoFrames,
|
|
11339
|
-
extractMediaMetadata as
|
|
11510
|
+
extractMediaMetadata as extractMediaMetadata5,
|
|
11340
11511
|
gradingKeepsSdr as gradingKeepsSdr2,
|
|
11341
11512
|
isVideoPastTimelineEnd,
|
|
11342
11513
|
isHdrColorSpace as isHdrColorSpace2,
|
|
@@ -11350,7 +11521,7 @@ import {
|
|
|
11350
11521
|
resolveRestrictPageNetwork,
|
|
11351
11522
|
isUrlNotPermittedError,
|
|
11352
11523
|
writeUrlDownloadTelemetry as writeUrlDownloadTelemetry2,
|
|
11353
|
-
resolveProjectRelativeSrc as
|
|
11524
|
+
resolveProjectRelativeSrc as resolveProjectRelativeSrc5,
|
|
11354
11525
|
runVideoExtractionWithRetry as runVideoExtractionWithRetry2,
|
|
11355
11526
|
safeVideoExtractionSourceIdentity,
|
|
11356
11527
|
videoAudioId as videoAudioId2
|
|
@@ -11561,7 +11732,7 @@ function applyVideoExtractionFailurePolicy(result, policy, log) {
|
|
|
11561
11732
|
}
|
|
11562
11733
|
async function probeColorSpaceSafely(path, log) {
|
|
11563
11734
|
try {
|
|
11564
|
-
const meta = await
|
|
11735
|
+
const meta = await extractMediaMetadata5(path);
|
|
11565
11736
|
return meta.colorSpace;
|
|
11566
11737
|
} catch (error) {
|
|
11567
11738
|
log?.warn("HDR color-space probe failed; treating source as SDR", {
|
|
@@ -11607,14 +11778,14 @@ async function runExtractVideosStage(input) {
|
|
|
11607
11778
|
log?.info("Probing video color spaces...", { videoCount: composition.videos.length });
|
|
11608
11779
|
const probeFailures = await Promise.all(
|
|
11609
11780
|
composition.videos.map(async (v) => {
|
|
11610
|
-
const videoPath =
|
|
11781
|
+
const videoPath = resolveProjectRelativeSrc5(v.src, projectDir, compiledDir);
|
|
11611
11782
|
if (!opensLocally(videoPath, assetRoots)) return null;
|
|
11612
11783
|
try {
|
|
11613
11784
|
const attempted = extractionPolicy.maxTransientRetries === 0 ? {
|
|
11614
|
-
result: await
|
|
11785
|
+
result: await extractMediaMetadata5(videoPath, { signal: abortSignal }),
|
|
11615
11786
|
retries: 0
|
|
11616
11787
|
} : await runVideoExtractionWithRetry2(
|
|
11617
|
-
() =>
|
|
11788
|
+
() => extractMediaMetadata5(videoPath, { signal: abortSignal }),
|
|
11618
11789
|
{
|
|
11619
11790
|
signal: abortSignal,
|
|
11620
11791
|
maxTransientRetries: extractionPolicy.maxTransientRetries,
|
|
@@ -11651,7 +11822,7 @@ async function runExtractVideosStage(input) {
|
|
|
11651
11822
|
if (probesHdr && composition.images.length > 0) {
|
|
11652
11823
|
const probed = await Promise.all(
|
|
11653
11824
|
composition.images.map(async (img) => {
|
|
11654
|
-
const imgPath =
|
|
11825
|
+
const imgPath = resolveProjectRelativeSrc5(img.src, projectDir, compiledDir);
|
|
11655
11826
|
if (!opensLocally(imgPath, assetRoots)) return null;
|
|
11656
11827
|
const colorSpace = await probeColorSpaceSafely(imgPath, log);
|
|
11657
11828
|
if (isHdrColorSpace2(colorSpace)) {
|
|
@@ -11786,7 +11957,7 @@ function opensLocally(path, assetRoots) {
|
|
|
11786
11957
|
return existsSync13(path) && (!assetRoots || assetRootsRefusal(path, assetRoots) === null);
|
|
11787
11958
|
}
|
|
11788
11959
|
function localProbeSource(src, input) {
|
|
11789
|
-
const path =
|
|
11960
|
+
const path = resolveProjectRelativeSrc5(src, input.projectDir, input.compiledDir);
|
|
11790
11961
|
const readFrom = input.urlByAbsentLocalPath?.get(path) ?? path;
|
|
11791
11962
|
const roots = input.allowOutsideProjectAssets ? void 0 : mediaAssetRoots(input.projectDir, input.compiledDir);
|
|
11792
11963
|
return isHttpUrl3(readFrom) || opensLocally(readFrom, roots) ? readFrom : null;
|
|
@@ -11817,7 +11988,7 @@ async function appendVideoAudioFromProbe(input) {
|
|
|
11817
11988
|
videos.map(async (video) => {
|
|
11818
11989
|
const readFrom = isHttpUrl3(video.src) ? await remoteProbeSource(video, input) : localProbeSource(video.src, input);
|
|
11819
11990
|
if (readFrom === null) return null;
|
|
11820
|
-
const metadata = await
|
|
11991
|
+
const metadata = await extractMediaMetadata5(readFrom, { signal: input.signal });
|
|
11821
11992
|
const window2 = await resolveFinalFrameExtractionWindow2(
|
|
11822
11993
|
readFrom,
|
|
11823
11994
|
video,
|
|
@@ -11841,7 +12012,7 @@ import {
|
|
|
11841
12012
|
buildVideoLayerInput,
|
|
11842
12013
|
isHttpUrl as isHttpUrl4,
|
|
11843
12014
|
qualifyVideoLayer,
|
|
11844
|
-
resolveProjectRelativeSrc as
|
|
12015
|
+
resolveProjectRelativeSrc as resolveProjectRelativeSrc6
|
|
11845
12016
|
} from "@hyperframes/engine";
|
|
11846
12017
|
var SAMPLES = 9;
|
|
11847
12018
|
function inspectVideoLayout(id, w, h, time) {
|
|
@@ -11903,7 +12074,7 @@ async function planVideoLayerPassthrough(input) {
|
|
|
11903
12074
|
if (!q.qualifies) return { reason: q.reason };
|
|
11904
12075
|
const { video } = q;
|
|
11905
12076
|
if (isHttpUrl4(video.src)) return { reason: "remote_source" };
|
|
11906
|
-
const path =
|
|
12077
|
+
const path = resolveProjectRelativeSrc6(video.src, input.projectDir, input.compiledDir);
|
|
11907
12078
|
if (!existsSync14(path)) return { reason: "source_missing" };
|
|
11908
12079
|
const layout = await probeVideoLayout(input.page, video.id, input.canvas, input.duration);
|
|
11909
12080
|
if ("reason" in layout) return layout;
|
|
@@ -14866,7 +15037,7 @@ function isRecoverableParallelCaptureError(error) {
|
|
|
14866
15037
|
return kind === "transient_browser" || kind === "protocol_timeout";
|
|
14867
15038
|
}
|
|
14868
15039
|
function describeMemoryExhaustion(error, ctx) {
|
|
14869
|
-
if (!
|
|
15040
|
+
if (!isMemoryExhaustionError2(error)) return null;
|
|
14870
15041
|
const raw = normalizeErrorMessage(error);
|
|
14871
15042
|
const dims = ctx.width && ctx.height ? ` (${ctx.width}\xD7${ctx.height}${ctx.totalFrames ? `, ${ctx.totalFrames} frames` : ""})` : "";
|
|
14872
15043
|
return `Render ran out of memory${dims}: ${raw}
|
|
@@ -16012,6 +16183,11 @@ async function executeRenderPipeline(input) {
|
|
|
16012
16183
|
failureToEnforce
|
|
16013
16184
|
} = extractResult;
|
|
16014
16185
|
perfStages.videoExtractMs = extractResult.videoExtractMs;
|
|
16186
|
+
if (probeSession && !probeHoldFitsCapture(probeSession.options.skipReadinessVideoIds, videoReadinessSkipIds)) {
|
|
16187
|
+
const held = probeSession;
|
|
16188
|
+
probeSession = null;
|
|
16189
|
+
await closeCaptureSession8(held);
|
|
16190
|
+
}
|
|
16015
16191
|
const coverageReports = extractionResult ? computeVideoFrameCoverage(composition.videos, extractionResult.extracted, job.config.fps) : [];
|
|
16016
16192
|
const coverageThreshold = resolveVideoCoverageThreshold();
|
|
16017
16193
|
const authoredTimedClipCount = countAuthoredTimedClips(compiled.html);
|
|
@@ -17033,7 +17209,7 @@ async function executeRenderPipeline(input) {
|
|
|
17033
17209
|
totalFrames,
|
|
17034
17210
|
segmentFrames,
|
|
17035
17211
|
key: manifestKey,
|
|
17036
|
-
probeFrames: (path) => probeSegmentFrameCount(path,
|
|
17212
|
+
probeFrames: (path) => probeSegmentFrameCount(path, extractMediaMetadata6)
|
|
17037
17213
|
});
|
|
17038
17214
|
segmentManifest.completed = existing.completed.filter(
|
|
17039
17215
|
(entry) => completedSegments.has(entry.index)
|
|
@@ -17269,7 +17445,7 @@ async function executeRenderPipeline(input) {
|
|
|
17269
17445
|
isBeginFrameCapture: !capturePlan.forceScreenshot && !cfg.useDrawElement && parallelCaptureMode === "beginframe"
|
|
17270
17446
|
}))
|
|
17271
17447
|
throw err;
|
|
17272
|
-
const isMemoryExhaustion = !isVerifyError &&
|
|
17448
|
+
const isMemoryExhaustion = !isVerifyError && isMemoryExhaustionError2(err);
|
|
17273
17449
|
deSelfVerifyFallback = isVerifyError;
|
|
17274
17450
|
if (isVerifyError) {
|
|
17275
17451
|
const t = deVerifyFallbackTelemetry(err);
|
|
@@ -1,4 +1,6 @@
|
|
|
1
|
-
/** The
|
|
1
|
+
/** The host's GSAP_CDN_VERSION files; other versions it ships sit beside them at `../../gsap@<version>/dist`. */
|
|
2
2
|
export declare const GSAP_VENDOR_DIR_ENV = "HYPERFRAMES_GSAP_VENDOR_DIR";
|
|
3
|
-
/** The host's bytes for exactly
|
|
3
|
+
/** The host's bytes for exactly this default-CDN GSAP file, at any version the host ships. */
|
|
4
4
|
export declare function bundledScript(url: string): Uint8Array | null;
|
|
5
|
+
/** The same file at the host's own GSAP version, for one the network could not bring. */
|
|
6
|
+
export declare function bundledGsapStandIn(url: string): Uint8Array | null;
|
|
@@ -98,6 +98,16 @@ type VariablesByComp = Record<string, Record<string, unknown>>;
|
|
|
98
98
|
* element's variable has a value (the render's, its scope's compiled table entry, its mount's, a declared default).
|
|
99
99
|
*/
|
|
100
100
|
export declare function hasVariableBoundMedia(html: string, variables: Record<string, unknown> | undefined, variablesByComp?: VariablesByComp): boolean;
|
|
101
|
+
/**
|
|
102
|
+
* Videos the probe page holds at preload none with their FFmpeg size, as capture pages hold extracted ones:
|
|
103
|
+
* live, 40 clips of one 4K file stop Chrome answering. A runtime-set or sizeless source stays live.
|
|
104
|
+
*/
|
|
105
|
+
export declare function probeVideoHold(videos: readonly {
|
|
106
|
+
id: string;
|
|
107
|
+
src: string;
|
|
108
|
+
}[], html: string, projectDir: string, compiledDir: string): Promise<Pick<CaptureOptions, "skipReadinessVideoIds" | "videoMetadataHints">>;
|
|
109
|
+
/** A probe page can serve capture only when capture holds every video it held: an unextracted one needs Chrome. */
|
|
110
|
+
export declare function probeHoldFitsCapture(probeHeld: readonly string[] | undefined, captureHeld: readonly string[]): boolean;
|
|
101
111
|
/**
|
|
102
112
|
* Runtime-created media does not exist when the static compiler scans the HTML.
|
|
103
113
|
* Launch a browser probe so discoverMediaFromBrowser can reconcile it before
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@hyperframes/producer",
|
|
3
|
-
"version": "0.9.
|
|
3
|
+
"version": "0.9.83",
|
|
4
4
|
"description": "HTML-to-video rendering engine using Chrome's BeginFrame API",
|
|
5
5
|
"repository": {
|
|
6
6
|
"type": "git",
|
|
@@ -35,11 +35,11 @@
|
|
|
35
35
|
"postcss": "^8.4.0",
|
|
36
36
|
"puppeteer": "~25.13.0",
|
|
37
37
|
"puppeteer-core": "^25.13.0",
|
|
38
|
-
"@hyperframes/
|
|
39
|
-
"@hyperframes/
|
|
40
|
-
"@hyperframes/
|
|
41
|
-
"@hyperframes/
|
|
42
|
-
"@hyperframes/
|
|
38
|
+
"@hyperframes/engine": "0.9.83",
|
|
39
|
+
"@hyperframes/lint": "0.9.83",
|
|
40
|
+
"@hyperframes/parsers": "0.9.83",
|
|
41
|
+
"@hyperframes/studio-server": "0.9.83",
|
|
42
|
+
"@hyperframes/core": "0.9.83"
|
|
43
43
|
},
|
|
44
44
|
"devDependencies": {
|
|
45
45
|
"@types/node": "^25.0.10",
|
|
@@ -48,7 +48,7 @@
|
|
|
48
48
|
"tsx": "^4.21.0",
|
|
49
49
|
"typescript": "^5.7.2",
|
|
50
50
|
"vitest": "^4.1.12",
|
|
51
|
-
"@hyperframes/aws-lambda": "0.9.
|
|
51
|
+
"@hyperframes/aws-lambda": "0.9.83"
|
|
52
52
|
},
|
|
53
53
|
"engines": {
|
|
54
54
|
"node": ">=22"
|