@hyperframes/producer 0.10.7 → 0.10.8
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/compileWorker.js +74 -18
- package/dist/distributed.js +79 -20
- package/dist/hyperframe.manifest.json +1 -1
- package/dist/hyperframe.runtime.iife.js +70 -70
- package/dist/index.js +85 -23
- package/dist/public-server.js +85 -23
- package/dist/services/htmlCompiler.d.ts +2 -0
- package/dist/services/render/observability.d.ts +1 -0
- package/package.json +8 -8
package/dist/compileWorker.js
CHANGED
|
@@ -530,7 +530,8 @@ import {
|
|
|
530
530
|
isPrivateUnderAssetRoots as isPrivateUnderAssetRoots3,
|
|
531
531
|
NotMediaPayloadError as NotMediaPayloadError2,
|
|
532
532
|
parseMasterFxChain,
|
|
533
|
-
probeMediaProfile as probeMediaProfile2
|
|
533
|
+
probeMediaProfile as probeMediaProfile2,
|
|
534
|
+
resolveRestrictPageNetwork
|
|
534
535
|
} from "@hyperframes/engine";
|
|
535
536
|
|
|
536
537
|
// src/utils/urlDownloader.ts
|
|
@@ -2329,16 +2330,61 @@ function operatorGsapMirror() {
|
|
|
2329
2330
|
return void 0;
|
|
2330
2331
|
}
|
|
2331
2332
|
}
|
|
2333
|
+
var MIRROR_GSAP_FILE = /^gsap@\d+(?:\.\d+)*\/dist\/[A-Za-z0-9][\w-]*(?:\.[\w-]+)*\.js$/;
|
|
2334
|
+
function isOperatorMirrorGsapUrl(src, mirror) {
|
|
2335
|
+
if (!mirror || /[?#%\\]/.test(src) || !URL.canParse(src)) return false;
|
|
2336
|
+
const url = new URL(src);
|
|
2337
|
+
if (url.search || url.hash || !url.href.startsWith(mirror)) return false;
|
|
2338
|
+
return MIRROR_GSAP_FILE.test(url.href.slice(mirror.length));
|
|
2339
|
+
}
|
|
2340
|
+
var warnedRestrictedMirror = false;
|
|
2341
|
+
function mirrorExemptionAllowed() {
|
|
2342
|
+
if (!resolveRestrictPageNetwork()) return true;
|
|
2343
|
+
if (!warnedRestrictedMirror) {
|
|
2344
|
+
warnedRestrictedMirror = true;
|
|
2345
|
+
defaultLogger.warn(
|
|
2346
|
+
"[Compiler] PRODUCER_RESTRICT_PAGE_NETWORK is on, so HYPERFRAMES_GSAP_BASE_URL is fetched only from a public HTTPS address."
|
|
2347
|
+
);
|
|
2348
|
+
}
|
|
2349
|
+
return false;
|
|
2350
|
+
}
|
|
2351
|
+
async function readCappedBody(response, src) {
|
|
2352
|
+
const tooLarge = () => new Error(`Script over 16 MiB: ${src}`);
|
|
2353
|
+
const declared = Number(response.headers.get("content-length"));
|
|
2354
|
+
if (Number.isFinite(declared) && declared > MAX_SCRIPT_BYTES) {
|
|
2355
|
+
await response.body?.cancel().catch(() => {
|
|
2356
|
+
});
|
|
2357
|
+
throw tooLarge();
|
|
2358
|
+
}
|
|
2359
|
+
if (!response.body) return new Uint8Array();
|
|
2360
|
+
const reader = response.body.getReader();
|
|
2361
|
+
const chunks = [];
|
|
2362
|
+
let received = 0;
|
|
2363
|
+
for (; ; ) {
|
|
2364
|
+
const { done, value } = await reader.read();
|
|
2365
|
+
if (done) break;
|
|
2366
|
+
received += value.byteLength;
|
|
2367
|
+
if (received > MAX_SCRIPT_BYTES) {
|
|
2368
|
+
await reader.cancel().catch(() => {
|
|
2369
|
+
});
|
|
2370
|
+
throw tooLarge();
|
|
2371
|
+
}
|
|
2372
|
+
chunks.push(value);
|
|
2373
|
+
}
|
|
2374
|
+
return Buffer.concat(chunks);
|
|
2375
|
+
}
|
|
2332
2376
|
async function downloadScript(src, mirror, signal) {
|
|
2333
|
-
if (mirror &&
|
|
2334
|
-
const response = await fetch(src, {
|
|
2377
|
+
if (isOperatorMirrorGsapUrl(src, mirror) && mirrorExemptionAllowed()) {
|
|
2378
|
+
const response = await fetch(new URL(src).href, {
|
|
2335
2379
|
redirect: "error",
|
|
2336
2380
|
signal: AbortSignal.any([AbortSignal.timeout(15e3), signal])
|
|
2337
2381
|
});
|
|
2338
|
-
if (!response.ok)
|
|
2339
|
-
|
|
2340
|
-
|
|
2341
|
-
|
|
2382
|
+
if (!response.ok) {
|
|
2383
|
+
await response.body?.cancel().catch(() => {
|
|
2384
|
+
});
|
|
2385
|
+
throw new Error(`HTTP ${response.status} for ${src}`);
|
|
2386
|
+
}
|
|
2387
|
+
return readCappedBody(response, src);
|
|
2342
2388
|
}
|
|
2343
2389
|
return fetchPublicHttpsBytes(src, { maxBytes: MAX_SCRIPT_BYTES, timeoutMs: 15e3, signal });
|
|
2344
2390
|
}
|
|
@@ -2662,15 +2708,22 @@ function matchingBraces(css) {
|
|
|
2662
2708
|
}
|
|
2663
2709
|
return closes;
|
|
2664
2710
|
}
|
|
2665
|
-
|
|
2666
|
-
|
|
2711
|
+
var attributeInAnyCase = (el, name) => [...el.attributes].find((attribute) => attribute.name.toLowerCase() === name)?.value;
|
|
2712
|
+
var WHERE_A_BROWSER_LOADS_NO_LINK = "noscript, iframe, noembed, noframes, plaintext, svg, math";
|
|
2713
|
+
function remoteFontStylesheetHref(link) {
|
|
2714
|
+
if (attributeInAnyCase(link, "rel")?.toLowerCase() !== "stylesheet") return void 0;
|
|
2715
|
+
if (link.closest(WHERE_A_BROWSER_LOADS_NO_LINK)) return void 0;
|
|
2716
|
+
const href = attributeInAnyCase(link, "href");
|
|
2667
2717
|
if (!href || !/^https?:\/\//i.test(href) || isGoogleFontsUrl(href)) return void 0;
|
|
2668
2718
|
return href;
|
|
2669
2719
|
}
|
|
2670
2720
|
async function inlineExternalFontStylesheets(html, budget = new CompositionExpansionBudget(), signal) {
|
|
2721
|
+
if (!/<link\b/i.test(html)) return html;
|
|
2722
|
+
const { document: document2 } = parseHTML4(html);
|
|
2723
|
+
const linkElements = [...document2.querySelectorAll("link")];
|
|
2671
2724
|
const hrefs = /* @__PURE__ */ new Set();
|
|
2672
|
-
for (const
|
|
2673
|
-
const href = remoteFontStylesheetHref(
|
|
2725
|
+
for (const link of linkElements) {
|
|
2726
|
+
const href = remoteFontStylesheetHref(link);
|
|
2674
2727
|
if (href) hrefs.add(href);
|
|
2675
2728
|
}
|
|
2676
2729
|
if (hrefs.size === 0) return html;
|
|
@@ -2685,9 +2738,9 @@ async function inlineExternalFontStylesheets(html, budget = new CompositionExpan
|
|
|
2685
2738
|
const fontFaceBlocks = css ? extractFontFaceBlocks(css) : [];
|
|
2686
2739
|
if (fontFaceBlocks.length === 0) return;
|
|
2687
2740
|
const fontCssWithLtAsCssEscape = fontFaceBlocks.join("\n").replace(/</g, "\\3c ");
|
|
2688
|
-
const inlineStyle =
|
|
2741
|
+
const inlineStyle = `/* Inlined external font stylesheet */
|
|
2689
2742
|
${fontCssWithLtAsCssEscape}
|
|
2690
|
-
|
|
2743
|
+
`;
|
|
2691
2744
|
try {
|
|
2692
2745
|
budget.chargeGenerated(REMOTE_STYLESHEETS, inlineStyle.length);
|
|
2693
2746
|
} catch (error) {
|
|
@@ -2705,14 +2758,17 @@ ${fontCssWithLtAsCssEscape}
|
|
|
2705
2758
|
await Promise.allSettled([...hrefs].map((href) => limit(() => inlineSheet(href), fetchSignal)));
|
|
2706
2759
|
if (stop.signal.aborted) throw stop.signal.reason;
|
|
2707
2760
|
const placed = /* @__PURE__ */ new Set();
|
|
2708
|
-
|
|
2709
|
-
const href = remoteFontStylesheetHref(
|
|
2761
|
+
for (const link of linkElements) {
|
|
2762
|
+
const href = remoteFontStylesheetHref(link);
|
|
2710
2763
|
const inlineStyle = href ? inlineByHref.get(href) : void 0;
|
|
2711
|
-
if (!href || !inlineStyle)
|
|
2764
|
+
if (!href || !inlineStyle) continue;
|
|
2712
2765
|
if (placed.has(href)) budget.chargeGenerated(REMOTE_STYLESHEETS, inlineStyle.length);
|
|
2713
2766
|
placed.add(href);
|
|
2714
|
-
|
|
2715
|
-
|
|
2767
|
+
const style = document2.createElement("style");
|
|
2768
|
+
style.textContent = inlineStyle;
|
|
2769
|
+
link.replaceWith(style);
|
|
2770
|
+
}
|
|
2771
|
+
return placed.size === 0 ? html : document2.toString();
|
|
2716
2772
|
}
|
|
2717
2773
|
function projectStylesheetFontFamilies(html, projectDir2) {
|
|
2718
2774
|
const families = [];
|
package/dist/distributed.js
CHANGED
|
@@ -1769,6 +1769,9 @@ import { isPathInside as isPathInside3 } from "@hyperframes/parsers/asset-paths"
|
|
|
1769
1769
|
import { previewToken } from "@hyperframes/core/preview-proof";
|
|
1770
1770
|
import { replaceFileAtomically } from "@hyperframes/core/atomic-file";
|
|
1771
1771
|
|
|
1772
|
+
// src/services/render/segmentRecycle.ts
|
|
1773
|
+
import { isTransientScreenshotRefusal } from "@hyperframes/engine";
|
|
1774
|
+
|
|
1772
1775
|
// src/services/render/stages/captureStreamingStage.ts
|
|
1773
1776
|
import {
|
|
1774
1777
|
DrawElementVerificationError,
|
|
@@ -2816,7 +2819,8 @@ import {
|
|
|
2816
2819
|
isPrivateUnderAssetRoots as isPrivateUnderAssetRoots3,
|
|
2817
2820
|
NotMediaPayloadError as NotMediaPayloadError2,
|
|
2818
2821
|
parseMasterFxChain,
|
|
2819
|
-
probeMediaProfile as probeMediaProfile2
|
|
2822
|
+
probeMediaProfile as probeMediaProfile2,
|
|
2823
|
+
resolveRestrictPageNetwork
|
|
2820
2824
|
} from "@hyperframes/engine";
|
|
2821
2825
|
|
|
2822
2826
|
// src/utils/urlDownloader.ts
|
|
@@ -4656,16 +4660,61 @@ function operatorGsapMirror() {
|
|
|
4656
4660
|
return void 0;
|
|
4657
4661
|
}
|
|
4658
4662
|
}
|
|
4663
|
+
var MIRROR_GSAP_FILE = /^gsap@\d+(?:\.\d+)*\/dist\/[A-Za-z0-9][\w-]*(?:\.[\w-]+)*\.js$/;
|
|
4664
|
+
function isOperatorMirrorGsapUrl(src, mirror) {
|
|
4665
|
+
if (!mirror || /[?#%\\]/.test(src) || !URL.canParse(src)) return false;
|
|
4666
|
+
const url = new URL(src);
|
|
4667
|
+
if (url.search || url.hash || !url.href.startsWith(mirror)) return false;
|
|
4668
|
+
return MIRROR_GSAP_FILE.test(url.href.slice(mirror.length));
|
|
4669
|
+
}
|
|
4670
|
+
var warnedRestrictedMirror = false;
|
|
4671
|
+
function mirrorExemptionAllowed() {
|
|
4672
|
+
if (!resolveRestrictPageNetwork()) return true;
|
|
4673
|
+
if (!warnedRestrictedMirror) {
|
|
4674
|
+
warnedRestrictedMirror = true;
|
|
4675
|
+
defaultLogger.warn(
|
|
4676
|
+
"[Compiler] PRODUCER_RESTRICT_PAGE_NETWORK is on, so HYPERFRAMES_GSAP_BASE_URL is fetched only from a public HTTPS address."
|
|
4677
|
+
);
|
|
4678
|
+
}
|
|
4679
|
+
return false;
|
|
4680
|
+
}
|
|
4681
|
+
async function readCappedBody(response, src) {
|
|
4682
|
+
const tooLarge = () => new Error(`Script over 16 MiB: ${src}`);
|
|
4683
|
+
const declared = Number(response.headers.get("content-length"));
|
|
4684
|
+
if (Number.isFinite(declared) && declared > MAX_SCRIPT_BYTES) {
|
|
4685
|
+
await response.body?.cancel().catch(() => {
|
|
4686
|
+
});
|
|
4687
|
+
throw tooLarge();
|
|
4688
|
+
}
|
|
4689
|
+
if (!response.body) return new Uint8Array();
|
|
4690
|
+
const reader = response.body.getReader();
|
|
4691
|
+
const chunks = [];
|
|
4692
|
+
let received = 0;
|
|
4693
|
+
for (; ; ) {
|
|
4694
|
+
const { done, value } = await reader.read();
|
|
4695
|
+
if (done) break;
|
|
4696
|
+
received += value.byteLength;
|
|
4697
|
+
if (received > MAX_SCRIPT_BYTES) {
|
|
4698
|
+
await reader.cancel().catch(() => {
|
|
4699
|
+
});
|
|
4700
|
+
throw tooLarge();
|
|
4701
|
+
}
|
|
4702
|
+
chunks.push(value);
|
|
4703
|
+
}
|
|
4704
|
+
return Buffer.concat(chunks);
|
|
4705
|
+
}
|
|
4659
4706
|
async function downloadScript(src, mirror, signal) {
|
|
4660
|
-
if (mirror &&
|
|
4661
|
-
const response = await fetch(src, {
|
|
4707
|
+
if (isOperatorMirrorGsapUrl(src, mirror) && mirrorExemptionAllowed()) {
|
|
4708
|
+
const response = await fetch(new URL(src).href, {
|
|
4662
4709
|
redirect: "error",
|
|
4663
4710
|
signal: AbortSignal.any([AbortSignal.timeout(15e3), signal])
|
|
4664
4711
|
});
|
|
4665
|
-
if (!response.ok)
|
|
4666
|
-
|
|
4667
|
-
|
|
4668
|
-
|
|
4712
|
+
if (!response.ok) {
|
|
4713
|
+
await response.body?.cancel().catch(() => {
|
|
4714
|
+
});
|
|
4715
|
+
throw new Error(`HTTP ${response.status} for ${src}`);
|
|
4716
|
+
}
|
|
4717
|
+
return readCappedBody(response, src);
|
|
4669
4718
|
}
|
|
4670
4719
|
return fetchPublicHttpsBytes(src, { maxBytes: MAX_SCRIPT_BYTES, timeoutMs: 15e3, signal });
|
|
4671
4720
|
}
|
|
@@ -4989,15 +5038,22 @@ function matchingBraces(css) {
|
|
|
4989
5038
|
}
|
|
4990
5039
|
return closes;
|
|
4991
5040
|
}
|
|
4992
|
-
|
|
4993
|
-
|
|
5041
|
+
var attributeInAnyCase = (el, name) => [...el.attributes].find((attribute) => attribute.name.toLowerCase() === name)?.value;
|
|
5042
|
+
var WHERE_A_BROWSER_LOADS_NO_LINK = "noscript, iframe, noembed, noframes, plaintext, svg, math";
|
|
5043
|
+
function remoteFontStylesheetHref(link) {
|
|
5044
|
+
if (attributeInAnyCase(link, "rel")?.toLowerCase() !== "stylesheet") return void 0;
|
|
5045
|
+
if (link.closest(WHERE_A_BROWSER_LOADS_NO_LINK)) return void 0;
|
|
5046
|
+
const href = attributeInAnyCase(link, "href");
|
|
4994
5047
|
if (!href || !/^https?:\/\//i.test(href) || isGoogleFontsUrl(href)) return void 0;
|
|
4995
5048
|
return href;
|
|
4996
5049
|
}
|
|
4997
5050
|
async function inlineExternalFontStylesheets(html, budget = new CompositionExpansionBudget(), signal) {
|
|
5051
|
+
if (!/<link\b/i.test(html)) return html;
|
|
5052
|
+
const { document: document2 } = parseHTML5(html);
|
|
5053
|
+
const linkElements = [...document2.querySelectorAll("link")];
|
|
4998
5054
|
const hrefs = /* @__PURE__ */ new Set();
|
|
4999
|
-
for (const
|
|
5000
|
-
const href = remoteFontStylesheetHref(
|
|
5055
|
+
for (const link of linkElements) {
|
|
5056
|
+
const href = remoteFontStylesheetHref(link);
|
|
5001
5057
|
if (href) hrefs.add(href);
|
|
5002
5058
|
}
|
|
5003
5059
|
if (hrefs.size === 0) return html;
|
|
@@ -5012,9 +5068,9 @@ async function inlineExternalFontStylesheets(html, budget = new CompositionExpan
|
|
|
5012
5068
|
const fontFaceBlocks = css ? extractFontFaceBlocks(css) : [];
|
|
5013
5069
|
if (fontFaceBlocks.length === 0) return;
|
|
5014
5070
|
const fontCssWithLtAsCssEscape = fontFaceBlocks.join("\n").replace(/</g, "\\3c ");
|
|
5015
|
-
const inlineStyle =
|
|
5071
|
+
const inlineStyle = `/* Inlined external font stylesheet */
|
|
5016
5072
|
${fontCssWithLtAsCssEscape}
|
|
5017
|
-
|
|
5073
|
+
`;
|
|
5018
5074
|
try {
|
|
5019
5075
|
budget.chargeGenerated(REMOTE_STYLESHEETS, inlineStyle.length);
|
|
5020
5076
|
} catch (error) {
|
|
@@ -5032,14 +5088,17 @@ ${fontCssWithLtAsCssEscape}
|
|
|
5032
5088
|
await Promise.allSettled([...hrefs].map((href) => limit(() => inlineSheet(href), fetchSignal)));
|
|
5033
5089
|
if (stop.signal.aborted) throw stop.signal.reason;
|
|
5034
5090
|
const placed = /* @__PURE__ */ new Set();
|
|
5035
|
-
|
|
5036
|
-
const href = remoteFontStylesheetHref(
|
|
5091
|
+
for (const link of linkElements) {
|
|
5092
|
+
const href = remoteFontStylesheetHref(link);
|
|
5037
5093
|
const inlineStyle = href ? inlineByHref.get(href) : void 0;
|
|
5038
|
-
if (!href || !inlineStyle)
|
|
5094
|
+
if (!href || !inlineStyle) continue;
|
|
5039
5095
|
if (placed.has(href)) budget.chargeGenerated(REMOTE_STYLESHEETS, inlineStyle.length);
|
|
5040
5096
|
placed.add(href);
|
|
5041
|
-
|
|
5042
|
-
|
|
5097
|
+
const style = document2.createElement("style");
|
|
5098
|
+
style.textContent = inlineStyle;
|
|
5099
|
+
link.replaceWith(style);
|
|
5100
|
+
}
|
|
5101
|
+
return placed.size === 0 ? html : document2.toString();
|
|
5043
5102
|
}
|
|
5044
5103
|
function projectStylesheetFontFamilies(html, projectDir) {
|
|
5045
5104
|
const families = [];
|
|
@@ -7417,7 +7476,7 @@ import {
|
|
|
7417
7476
|
assetRootsRefusal,
|
|
7418
7477
|
assertPublicHttpsUrl,
|
|
7419
7478
|
downloadToTemp as downloadToTemp2,
|
|
7420
|
-
resolveRestrictPageNetwork,
|
|
7479
|
+
resolveRestrictPageNetwork as resolveRestrictPageNetwork2,
|
|
7421
7480
|
isUrlNotPermittedError,
|
|
7422
7481
|
writeUrlDownloadTelemetry as writeUrlDownloadTelemetry2,
|
|
7423
7482
|
resolveProjectRelativeSrc as resolveProjectRelativeSrc5,
|
|
@@ -7870,7 +7929,7 @@ function localProbeSource(src, input) {
|
|
|
7870
7929
|
}
|
|
7871
7930
|
async function remoteProbeSource(video, input) {
|
|
7872
7931
|
if (!isPublicHttpsUrl(video.src)) return null;
|
|
7873
|
-
if (!
|
|
7932
|
+
if (!resolveRestrictPageNetwork2()) return video.src;
|
|
7874
7933
|
if (!video.hasAudio || video.hidden) return null;
|
|
7875
7934
|
const downloadDir = input.downloadDir ?? join14(input.compiledDir, REMOTE_MEDIA_SUBDIR);
|
|
7876
7935
|
try {
|
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
{
|
|
2
2
|
"version": "0.1.0",
|
|
3
3
|
"buildId": "dev",
|
|
4
|
-
"sha256": "
|
|
4
|
+
"sha256": "8cd6cfc653504d62a4c77d19ff00377b60b8a9a4ef66ee7ac4d84d1d17855c7c",
|
|
5
5
|
"artifacts": {
|
|
6
6
|
"iife": "hyperframe.runtime.iife.js",
|
|
7
7
|
"esm": "hyperframe.runtime.mjs"
|