@hyperframes/producer 0.9.70 → 0.9.72
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 +78 -38
- package/dist/hyperframe.manifest.json +1 -1
- package/dist/hyperframe.runtime.iife.js +70 -70
- package/dist/index.js +82 -41
- package/dist/public-server.js +79 -38
- package/dist/services/htmlCompiler.d.ts +16 -2
- package/package.json +7 -7
package/dist/distributed.js
CHANGED
|
@@ -143,7 +143,7 @@ function formatExportFrameName(index, ext) {
|
|
|
143
143
|
}
|
|
144
144
|
|
|
145
145
|
// src/services/renderOrchestrator.ts
|
|
146
|
-
import { audioFailureDiagnostics as audioFailureDiagnostics2,
|
|
146
|
+
import { audioFailureDiagnostics as audioFailureDiagnostics2, cpuBudget } from "@hyperframes/engine";
|
|
147
147
|
import {
|
|
148
148
|
existsSync as existsSync14,
|
|
149
149
|
mkdirSync as mkdirSync6,
|
|
@@ -2614,6 +2614,7 @@ import {
|
|
|
2614
2614
|
isJavaScriptType,
|
|
2615
2615
|
prepareFlattenedInnerRoot,
|
|
2616
2616
|
emitRootCompositionVariableStyles,
|
|
2617
|
+
dropAuthoredSvgReferenceAliases,
|
|
2617
2618
|
readDeclaredDefaults,
|
|
2618
2619
|
parseHostVariableValues,
|
|
2619
2620
|
boundMediaSrc,
|
|
@@ -4237,13 +4238,14 @@ function inlineSubCompositions(html, subCompositions, projectDir, variableOverri
|
|
|
4237
4238
|
const body = document2.querySelector("body");
|
|
4238
4239
|
const hosts = Array.from(document2.querySelectorAll("[data-composition-src]"));
|
|
4239
4240
|
if (!hosts.length) {
|
|
4241
|
+
const dropped = dropAuthoredSvgReferenceAliases(document2);
|
|
4240
4242
|
const emitted = emitRootCompositionVariableStyles(
|
|
4241
4243
|
document2,
|
|
4242
4244
|
{},
|
|
4243
4245
|
variableOverrides,
|
|
4244
4246
|
{ chargeBytes: (bytes) => budget.chargeGenerated("composition variables", bytes) }
|
|
4245
4247
|
);
|
|
4246
|
-
return { html: emitted ? document2.toString() : html, variablesByComp: {} };
|
|
4248
|
+
return { html: emitted || dropped ? document2.toString() : html, variablesByComp: {} };
|
|
4247
4249
|
}
|
|
4248
4250
|
const readOnce = /* @__PURE__ */ new Map();
|
|
4249
4251
|
const readMountHtml = (srcPath) => {
|
|
@@ -4435,18 +4437,31 @@ function operatorGsapMirror() {
|
|
|
4435
4437
|
return void 0;
|
|
4436
4438
|
}
|
|
4437
4439
|
}
|
|
4438
|
-
async function downloadScript(src, mirror) {
|
|
4440
|
+
async function downloadScript(src, mirror, signal) {
|
|
4439
4441
|
if (mirror && new URL(src).href.startsWith(mirror)) {
|
|
4440
|
-
const response = await fetch(src, {
|
|
4442
|
+
const response = await fetch(src, {
|
|
4443
|
+
redirect: "error",
|
|
4444
|
+
signal: AbortSignal.any([AbortSignal.timeout(15e3), signal])
|
|
4445
|
+
});
|
|
4441
4446
|
if (!response.ok) throw new Error(`HTTP ${response.status} for ${src}`);
|
|
4442
4447
|
const bytes = new Uint8Array(await response.arrayBuffer());
|
|
4443
4448
|
if (bytes.byteLength > MAX_SCRIPT_BYTES) throw new Error(`Script over 16 MiB: ${src}`);
|
|
4444
4449
|
return bytes;
|
|
4445
4450
|
}
|
|
4446
|
-
return fetchPublicHttpsBytes(src, { maxBytes: MAX_SCRIPT_BYTES, timeoutMs: 15e3 });
|
|
4451
|
+
return fetchPublicHttpsBytes(src, { maxBytes: MAX_SCRIPT_BYTES, timeoutMs: 15e3, signal });
|
|
4447
4452
|
}
|
|
4448
4453
|
var MAX_CONCURRENT_SCRIPT_FETCHES = 4;
|
|
4449
|
-
|
|
4454
|
+
var MAX_REMOTE_FETCHES = 32;
|
|
4455
|
+
var REMOTE_FETCH_DEADLINE_MS = 6e4;
|
|
4456
|
+
var fetchSignalOf = (signal) => typeof signal === "function" ? signal() : signal;
|
|
4457
|
+
function assertRemoteFetchCount(kind, count) {
|
|
4458
|
+
if (count > MAX_REMOTE_FETCHES) {
|
|
4459
|
+
throw new Error(
|
|
4460
|
+
`The composition links ${count} remote ${kind}; at most ${MAX_REMOTE_FETCHES} are downloaded at compile time`
|
|
4461
|
+
);
|
|
4462
|
+
}
|
|
4463
|
+
}
|
|
4464
|
+
async function inlineExternalScripts(html, budget = new CompositionExpansionBudget(), signal) {
|
|
4450
4465
|
const fullHtml = ensureFullDocument(html);
|
|
4451
4466
|
const wrappedFragment = fullHtml !== html;
|
|
4452
4467
|
const { document: document2 } = parseHTML5(fullHtml);
|
|
@@ -4459,9 +4474,19 @@ async function inlineExternalScripts(html, budget = new CompositionExpansionBudg
|
|
|
4459
4474
|
}
|
|
4460
4475
|
}
|
|
4461
4476
|
if (externalScripts.length === 0) return html;
|
|
4477
|
+
const bundled = /* @__PURE__ */ new Map();
|
|
4478
|
+
const local = externalScripts.map(({ el, src }) => {
|
|
4479
|
+
if (!bundled.has(src)) bundled.set(src, bundledScript(src));
|
|
4480
|
+
const bytes = bundled.get(src);
|
|
4481
|
+
return bytes && matchesScriptIntegrity(bytes, el.getAttribute("integrity") || "") ? bytes : null;
|
|
4482
|
+
});
|
|
4483
|
+
const remote = new Set(externalScripts.filter((_, i) => !local[i]).map(({ src }) => src));
|
|
4484
|
+
assertRemoteFetchCount("scripts", remote.size);
|
|
4462
4485
|
const mirror = operatorGsapMirror();
|
|
4463
4486
|
const limit = createConcurrencyLimit(MAX_CONCURRENT_SCRIPT_FETCHES);
|
|
4464
4487
|
const stop = new AbortController();
|
|
4488
|
+
const shared = remote.size > 0 ? fetchSignalOf(signal) : void 0;
|
|
4489
|
+
const fetchSignal = shared ? AbortSignal.any([stop.signal, shared]) : stop.signal;
|
|
4465
4490
|
const fail = (error) => {
|
|
4466
4491
|
stop.abort(error);
|
|
4467
4492
|
throw error;
|
|
@@ -4478,21 +4503,21 @@ async function inlineExternalScripts(html, budget = new CompositionExpansionBudg
|
|
|
4478
4503
|
let bytes = fetches.get(src);
|
|
4479
4504
|
if (!bytes) {
|
|
4480
4505
|
bytes = limit(async () => {
|
|
4481
|
-
|
|
4482
|
-
const downloaded = await downloadScript(src, mirror);
|
|
4506
|
+
fetchSignal.throwIfAborted();
|
|
4507
|
+
const downloaded = await downloadScript(src, mirror, fetchSignal);
|
|
4483
4508
|
charge(downloaded.byteLength);
|
|
4484
4509
|
return downloaded;
|
|
4485
|
-
},
|
|
4510
|
+
}, fetchSignal);
|
|
4486
4511
|
fetches.set(src, bytes);
|
|
4487
4512
|
}
|
|
4488
4513
|
return bytes;
|
|
4489
4514
|
};
|
|
4490
4515
|
const placed = /* @__PURE__ */ new Set();
|
|
4491
4516
|
const downloads = await Promise.allSettled(
|
|
4492
|
-
externalScripts.map(async ({ el, src }) => {
|
|
4517
|
+
externalScripts.map(async ({ el, src }, i) => {
|
|
4493
4518
|
const integrity = el.getAttribute("integrity") || "";
|
|
4494
|
-
let bytes =
|
|
4495
|
-
if (bytes
|
|
4519
|
+
let bytes = local[i];
|
|
4520
|
+
if (bytes) {
|
|
4496
4521
|
charge(bytes.byteLength);
|
|
4497
4522
|
} else {
|
|
4498
4523
|
bytes = await fetchOnce(src);
|
|
@@ -4689,12 +4714,13 @@ function isGoogleFontsUrl(href) {
|
|
|
4689
4714
|
}
|
|
4690
4715
|
}
|
|
4691
4716
|
var MAX_STYLESHEET_BYTES = 2 * 1024 * 1024;
|
|
4692
|
-
async function fetchExternalStylesheetCss(href) {
|
|
4717
|
+
async function fetchExternalStylesheetCss(href, signal) {
|
|
4693
4718
|
const identity = safeDownloadUrlIdentity(href);
|
|
4694
4719
|
try {
|
|
4695
4720
|
return await fetchPublicHttpsText(href, {
|
|
4696
4721
|
maxBytes: MAX_STYLESHEET_BYTES,
|
|
4697
|
-
timeoutMs: 15e3
|
|
4722
|
+
timeoutMs: 15e3,
|
|
4723
|
+
signal
|
|
4698
4724
|
});
|
|
4699
4725
|
} catch (err) {
|
|
4700
4726
|
defaultLogger.warn("[Compiler] External stylesheet fetch failed, preserving link tag.", {
|
|
@@ -4734,36 +4760,42 @@ function remoteFontStylesheetHref(tag) {
|
|
|
4734
4760
|
if (!href || !/^https?:\/\//i.test(href) || isGoogleFontsUrl(href)) return void 0;
|
|
4735
4761
|
return href;
|
|
4736
4762
|
}
|
|
4737
|
-
async function inlineExternalFontStylesheets(html, budget = new CompositionExpansionBudget()) {
|
|
4763
|
+
async function inlineExternalFontStylesheets(html, budget = new CompositionExpansionBudget(), signal) {
|
|
4738
4764
|
const hrefs = /* @__PURE__ */ new Set();
|
|
4739
4765
|
for (const { parts } of stylesheetLinkMatches(html)) {
|
|
4740
4766
|
const href = remoteFontStylesheetHref(parts[0]);
|
|
4741
4767
|
if (href) hrefs.add(href);
|
|
4742
4768
|
}
|
|
4743
4769
|
if (hrefs.size === 0) return html;
|
|
4744
|
-
|
|
4770
|
+
assertRemoteFetchCount("stylesheets", hrefs.size);
|
|
4771
|
+
const limit = createConcurrencyLimit(MAX_CONCURRENT_SCRIPT_FETCHES);
|
|
4772
|
+
const stop = new AbortController();
|
|
4773
|
+
const shared = fetchSignalOf(signal);
|
|
4774
|
+
const fetchSignal = shared ? AbortSignal.any([stop.signal, shared]) : stop.signal;
|
|
4745
4775
|
const inlineByHref = /* @__PURE__ */ new Map();
|
|
4746
|
-
const
|
|
4747
|
-
|
|
4748
|
-
const
|
|
4749
|
-
|
|
4750
|
-
|
|
4751
|
-
const css = sheets[index];
|
|
4752
|
-
const fontFaceBlocks = css ? extractFontFaceBlocks(css) : [];
|
|
4753
|
-
if (fontFaceBlocks.length === 0) return;
|
|
4754
|
-
const inlineStyle = `<style>/* Inlined external font stylesheet */
|
|
4776
|
+
const inlineSheet = async (href) => {
|
|
4777
|
+
const css = await fetchExternalStylesheetCss(href, fetchSignal);
|
|
4778
|
+
const fontFaceBlocks = css ? extractFontFaceBlocks(css) : [];
|
|
4779
|
+
if (fontFaceBlocks.length === 0) return;
|
|
4780
|
+
const inlineStyle = `<style>/* Inlined external font stylesheet */
|
|
4755
4781
|
${fontFaceBlocks.join("\n")}
|
|
4756
4782
|
</style>`;
|
|
4783
|
+
try {
|
|
4757
4784
|
budget.chargeGenerated(REMOTE_STYLESHEETS, inlineStyle.length);
|
|
4758
|
-
|
|
4759
|
-
|
|
4760
|
-
|
|
4761
|
-
|
|
4762
|
-
|
|
4763
|
-
|
|
4764
|
-
|
|
4785
|
+
} catch (error) {
|
|
4786
|
+
stop.abort(error);
|
|
4787
|
+
throw error;
|
|
4788
|
+
}
|
|
4789
|
+
inlineByHref.set(href, inlineStyle);
|
|
4790
|
+
const identity = safeDownloadUrlIdentity(href);
|
|
4791
|
+
defaultLogger.debug("[Compiler] Inlined external @font-face rule(s)", {
|
|
4792
|
+
count: fontFaceBlocks.length,
|
|
4793
|
+
urlFingerprint: identity.urlFingerprint,
|
|
4794
|
+
host: identity.host
|
|
4765
4795
|
});
|
|
4766
|
-
}
|
|
4796
|
+
};
|
|
4797
|
+
await Promise.allSettled([...hrefs].map((href) => limit(() => inlineSheet(href), fetchSignal)));
|
|
4798
|
+
if (stop.signal.aborted) throw stop.signal.reason;
|
|
4767
4799
|
const placed = /* @__PURE__ */ new Set();
|
|
4768
4800
|
return replaceMatches(html, stylesheetLinkMatches(html), (tag) => {
|
|
4769
4801
|
const href = remoteFontStylesheetHref(tag);
|
|
@@ -5073,10 +5105,17 @@ async function compileForRender(projectDir, htmlPath, downloadDir, options = {})
|
|
|
5073
5105
|
const hasShaderTransitions = detectShaderTransitionUsage(sanitizedHtml);
|
|
5074
5106
|
const usesThreeDTransforms = detectThreeDTransformUsage(sanitizedHtml);
|
|
5075
5107
|
const hasAncestorBackgroundImage = detectAncestorBackgroundImage(sanitizedHtml);
|
|
5108
|
+
let deadline;
|
|
5109
|
+
const remoteFetches = () => deadline ??= AbortSignal.any([
|
|
5110
|
+
AbortSignal.timeout(REMOTE_FETCH_DEADLINE_MS),
|
|
5111
|
+
...options.abortSignal ? [options.abortSignal] : []
|
|
5112
|
+
]);
|
|
5076
5113
|
const fontSheetHtml = await inlineExternalFontStylesheets(
|
|
5077
5114
|
promoteCssImportsToLinkTags(sanitizedHtml),
|
|
5078
|
-
budget
|
|
5115
|
+
budget,
|
|
5116
|
+
remoteFetches
|
|
5079
5117
|
);
|
|
5118
|
+
options.abortSignal?.throwIfAborted();
|
|
5080
5119
|
const normalizedFontHtml = normalizeSystemFontPrimaryFamilies(
|
|
5081
5120
|
injectTextRenderingRule(coalesceHeadStylesAndBodyScripts(fontSheetHtml))
|
|
5082
5121
|
);
|
|
@@ -5087,7 +5126,8 @@ async function compileForRender(projectDir, htmlPath, downloadDir, options = {})
|
|
|
5087
5126
|
projectFontFamilies: projectStylesheetFontFamilies(fontSheetHtml, projectDir),
|
|
5088
5127
|
abortSignal: options.abortSignal
|
|
5089
5128
|
});
|
|
5090
|
-
const assembledHtml = await inlineExternalScripts(coalescedHtml, budget);
|
|
5129
|
+
const assembledHtml = await inlineExternalScripts(coalescedHtml, budget, remoteFetches);
|
|
5130
|
+
options.abortSignal?.throwIfAborted();
|
|
5091
5131
|
const htmlWithPositionScript = htmlHasStudioPositionEdits(assembledHtml) ? insertBeforeCloseTag(
|
|
5092
5132
|
assembledHtml,
|
|
5093
5133
|
"body",
|
|
@@ -13013,7 +13053,7 @@ import {
|
|
|
13013
13053
|
probeBeginFrameLiveness as probeBeginFrameLiveness2,
|
|
13014
13054
|
readWebGlVendorInfoFromCanvas,
|
|
13015
13055
|
resolveConfig as resolveConfig5,
|
|
13016
|
-
|
|
13056
|
+
cpuBudget as cpuBudget2
|
|
13017
13057
|
} from "@hyperframes/engine";
|
|
13018
13058
|
import { readWebGlVendorInfoFromCanvas as readWebGlVendorInfoFromCanvas2 } from "@hyperframes/engine";
|
|
13019
13059
|
var LEGACY_DISTRIBUTED_VP9_CPU_USED = 2;
|
|
@@ -13543,9 +13583,9 @@ async function renderChunk(planDir, chunkIndex, outputChunkPath, options) {
|
|
|
13543
13583
|
const captureSession = session;
|
|
13544
13584
|
session = null;
|
|
13545
13585
|
verifyStarted = Date.now();
|
|
13546
|
-
overlap.current = canEncodeWhileCapturing(encodeInput, chunkWorkerCount,
|
|
13586
|
+
overlap.current = canEncodeWhileCapturing(encodeInput, chunkWorkerCount, cpuBudget2()) ? encodeWhileCapturing(encodeInput, framesInChunk, {
|
|
13547
13587
|
workerCount: chunkWorkerCount,
|
|
13548
|
-
cpuCount:
|
|
13588
|
+
cpuCount: cpuBudget2()
|
|
13549
13589
|
}) : null;
|
|
13550
13590
|
await observeRenderStage(
|
|
13551
13591
|
new RenderObservabilityRecorder({ pipelineStartMs: start, log }),
|
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
{
|
|
2
2
|
"version": "0.1.0",
|
|
3
3
|
"buildId": "dev",
|
|
4
|
-
"sha256": "
|
|
4
|
+
"sha256": "03b1e23cf3c6edf67647df0e40ebe85fa36e18b824f7206253a60df1eb22aa1b",
|
|
5
5
|
"artifacts": {
|
|
6
6
|
"iife": "hyperframe.runtime.iife.js",
|
|
7
7
|
"esm": "hyperframe.runtime.mjs"
|