@hyperframes/producer 0.9.48 → 0.9.49
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 +23 -5
- package/dist/index.js +23 -5
- package/dist/public-server.js +23 -5
- package/dist/utils/urlDownloader.d.ts +1 -1
- package/package.json +7 -7
package/dist/distributed.js
CHANGED
|
@@ -2477,6 +2477,7 @@ import {
|
|
|
2477
2477
|
// src/utils/urlDownloader.ts
|
|
2478
2478
|
import {
|
|
2479
2479
|
downloadToTemp,
|
|
2480
|
+
fetchPublicHttpsBytes,
|
|
2480
2481
|
fetchPublicHttpsText,
|
|
2481
2482
|
isHttpUrl,
|
|
2482
2483
|
safeDownloadUrlIdentity,
|
|
@@ -3990,6 +3991,26 @@ function matchesScriptIntegrity(bytes, metadata) {
|
|
|
3990
3991
|
(hash) => hash[1]?.toLowerCase() === strongest && actual.equals(Buffer.from(hash[2], "base64"))
|
|
3991
3992
|
);
|
|
3992
3993
|
}
|
|
3994
|
+
var MAX_SCRIPT_BYTES = 16 * 1024 * 1024;
|
|
3995
|
+
function operatorGsapMirror() {
|
|
3996
|
+
const raw = process.env.HYPERFRAMES_GSAP_BASE_URL?.trim();
|
|
3997
|
+
if (!raw || raw.startsWith("/")) return void 0;
|
|
3998
|
+
try {
|
|
3999
|
+
return `${normalizeGsapBaseUrl(raw)}/`;
|
|
4000
|
+
} catch {
|
|
4001
|
+
return void 0;
|
|
4002
|
+
}
|
|
4003
|
+
}
|
|
4004
|
+
async function downloadScript(src, mirror) {
|
|
4005
|
+
if (mirror && new URL(src).href.startsWith(mirror)) {
|
|
4006
|
+
const response = await fetch(src, { redirect: "error", signal: AbortSignal.timeout(15e3) });
|
|
4007
|
+
if (!response.ok) throw new Error(`HTTP ${response.status} for ${src}`);
|
|
4008
|
+
const bytes = new Uint8Array(await response.arrayBuffer());
|
|
4009
|
+
if (bytes.byteLength > MAX_SCRIPT_BYTES) throw new Error(`Script over 16 MiB: ${src}`);
|
|
4010
|
+
return bytes;
|
|
4011
|
+
}
|
|
4012
|
+
return fetchPublicHttpsBytes(src, { maxBytes: MAX_SCRIPT_BYTES, timeoutMs: 15e3 });
|
|
4013
|
+
}
|
|
3993
4014
|
async function inlineExternalScripts(html) {
|
|
3994
4015
|
const fullHtml = ensureFullDocument(html);
|
|
3995
4016
|
const wrappedFragment = fullHtml !== html;
|
|
@@ -4003,6 +4024,7 @@ async function inlineExternalScripts(html) {
|
|
|
4003
4024
|
}
|
|
4004
4025
|
}
|
|
4005
4026
|
if (externalScripts.length === 0) return html;
|
|
4027
|
+
const mirror = operatorGsapMirror();
|
|
4006
4028
|
const downloads = await Promise.allSettled(
|
|
4007
4029
|
externalScripts.map(async ({ el, src }) => {
|
|
4008
4030
|
const integrity = el.getAttribute("integrity") || "";
|
|
@@ -4010,11 +4032,7 @@ async function inlineExternalScripts(html) {
|
|
|
4010
4032
|
if (bundled && matchesScriptIntegrity(bundled, integrity)) {
|
|
4011
4033
|
return { src, text: new TextDecoder().decode(bundled) };
|
|
4012
4034
|
}
|
|
4013
|
-
const
|
|
4014
|
-
signal: AbortSignal.timeout(15e3)
|
|
4015
|
-
});
|
|
4016
|
-
if (!response.ok) throw new Error(`HTTP ${response.status} for ${src}`);
|
|
4017
|
-
const bytes = new Uint8Array(await response.arrayBuffer());
|
|
4035
|
+
const bytes = await downloadScript(src, mirror);
|
|
4018
4036
|
if (!matchesScriptIntegrity(bytes, integrity)) {
|
|
4019
4037
|
throw new ScriptIntegrityError(`Subresource integrity mismatch for ${src}`);
|
|
4020
4038
|
}
|
package/dist/index.js
CHANGED
|
@@ -6767,6 +6767,7 @@ import {
|
|
|
6767
6767
|
// src/utils/urlDownloader.ts
|
|
6768
6768
|
import {
|
|
6769
6769
|
downloadToTemp,
|
|
6770
|
+
fetchPublicHttpsBytes,
|
|
6770
6771
|
fetchPublicHttpsText,
|
|
6771
6772
|
isHttpUrl,
|
|
6772
6773
|
safeDownloadUrlIdentity,
|
|
@@ -8280,6 +8281,26 @@ function matchesScriptIntegrity(bytes, metadata) {
|
|
|
8280
8281
|
(hash) => hash[1]?.toLowerCase() === strongest && actual.equals(Buffer.from(hash[2], "base64"))
|
|
8281
8282
|
);
|
|
8282
8283
|
}
|
|
8284
|
+
var MAX_SCRIPT_BYTES = 16 * 1024 * 1024;
|
|
8285
|
+
function operatorGsapMirror() {
|
|
8286
|
+
const raw = process.env.HYPERFRAMES_GSAP_BASE_URL?.trim();
|
|
8287
|
+
if (!raw || raw.startsWith("/")) return void 0;
|
|
8288
|
+
try {
|
|
8289
|
+
return `${normalizeGsapBaseUrl(raw)}/`;
|
|
8290
|
+
} catch {
|
|
8291
|
+
return void 0;
|
|
8292
|
+
}
|
|
8293
|
+
}
|
|
8294
|
+
async function downloadScript(src, mirror) {
|
|
8295
|
+
if (mirror && new URL(src).href.startsWith(mirror)) {
|
|
8296
|
+
const response = await fetch(src, { redirect: "error", signal: AbortSignal.timeout(15e3) });
|
|
8297
|
+
if (!response.ok) throw new Error(`HTTP ${response.status} for ${src}`);
|
|
8298
|
+
const bytes = new Uint8Array(await response.arrayBuffer());
|
|
8299
|
+
if (bytes.byteLength > MAX_SCRIPT_BYTES) throw new Error(`Script over 16 MiB: ${src}`);
|
|
8300
|
+
return bytes;
|
|
8301
|
+
}
|
|
8302
|
+
return fetchPublicHttpsBytes(src, { maxBytes: MAX_SCRIPT_BYTES, timeoutMs: 15e3 });
|
|
8303
|
+
}
|
|
8283
8304
|
async function inlineExternalScripts(html) {
|
|
8284
8305
|
const fullHtml = ensureFullDocument(html);
|
|
8285
8306
|
const wrappedFragment = fullHtml !== html;
|
|
@@ -8293,6 +8314,7 @@ async function inlineExternalScripts(html) {
|
|
|
8293
8314
|
}
|
|
8294
8315
|
}
|
|
8295
8316
|
if (externalScripts.length === 0) return html;
|
|
8317
|
+
const mirror = operatorGsapMirror();
|
|
8296
8318
|
const downloads = await Promise.allSettled(
|
|
8297
8319
|
externalScripts.map(async ({ el, src }) => {
|
|
8298
8320
|
const integrity = el.getAttribute("integrity") || "";
|
|
@@ -8300,11 +8322,7 @@ async function inlineExternalScripts(html) {
|
|
|
8300
8322
|
if (bundled && matchesScriptIntegrity(bundled, integrity)) {
|
|
8301
8323
|
return { src, text: new TextDecoder().decode(bundled) };
|
|
8302
8324
|
}
|
|
8303
|
-
const
|
|
8304
|
-
signal: AbortSignal.timeout(15e3)
|
|
8305
|
-
});
|
|
8306
|
-
if (!response.ok) throw new Error(`HTTP ${response.status} for ${src}`);
|
|
8307
|
-
const bytes = new Uint8Array(await response.arrayBuffer());
|
|
8325
|
+
const bytes = await downloadScript(src, mirror);
|
|
8308
8326
|
if (!matchesScriptIntegrity(bytes, integrity)) {
|
|
8309
8327
|
throw new ScriptIntegrityError(`Subresource integrity mismatch for ${src}`);
|
|
8310
8328
|
}
|
package/dist/public-server.js
CHANGED
|
@@ -6780,6 +6780,7 @@ import {
|
|
|
6780
6780
|
// src/utils/urlDownloader.ts
|
|
6781
6781
|
import {
|
|
6782
6782
|
downloadToTemp,
|
|
6783
|
+
fetchPublicHttpsBytes,
|
|
6783
6784
|
fetchPublicHttpsText,
|
|
6784
6785
|
isHttpUrl,
|
|
6785
6786
|
safeDownloadUrlIdentity,
|
|
@@ -8293,6 +8294,26 @@ function matchesScriptIntegrity(bytes, metadata) {
|
|
|
8293
8294
|
(hash) => hash[1]?.toLowerCase() === strongest && actual.equals(Buffer.from(hash[2], "base64"))
|
|
8294
8295
|
);
|
|
8295
8296
|
}
|
|
8297
|
+
var MAX_SCRIPT_BYTES = 16 * 1024 * 1024;
|
|
8298
|
+
function operatorGsapMirror() {
|
|
8299
|
+
const raw = process.env.HYPERFRAMES_GSAP_BASE_URL?.trim();
|
|
8300
|
+
if (!raw || raw.startsWith("/")) return void 0;
|
|
8301
|
+
try {
|
|
8302
|
+
return `${normalizeGsapBaseUrl(raw)}/`;
|
|
8303
|
+
} catch {
|
|
8304
|
+
return void 0;
|
|
8305
|
+
}
|
|
8306
|
+
}
|
|
8307
|
+
async function downloadScript(src, mirror) {
|
|
8308
|
+
if (mirror && new URL(src).href.startsWith(mirror)) {
|
|
8309
|
+
const response = await fetch(src, { redirect: "error", signal: AbortSignal.timeout(15e3) });
|
|
8310
|
+
if (!response.ok) throw new Error(`HTTP ${response.status} for ${src}`);
|
|
8311
|
+
const bytes = new Uint8Array(await response.arrayBuffer());
|
|
8312
|
+
if (bytes.byteLength > MAX_SCRIPT_BYTES) throw new Error(`Script over 16 MiB: ${src}`);
|
|
8313
|
+
return bytes;
|
|
8314
|
+
}
|
|
8315
|
+
return fetchPublicHttpsBytes(src, { maxBytes: MAX_SCRIPT_BYTES, timeoutMs: 15e3 });
|
|
8316
|
+
}
|
|
8296
8317
|
async function inlineExternalScripts(html) {
|
|
8297
8318
|
const fullHtml = ensureFullDocument(html);
|
|
8298
8319
|
const wrappedFragment = fullHtml !== html;
|
|
@@ -8306,6 +8327,7 @@ async function inlineExternalScripts(html) {
|
|
|
8306
8327
|
}
|
|
8307
8328
|
}
|
|
8308
8329
|
if (externalScripts.length === 0) return html;
|
|
8330
|
+
const mirror = operatorGsapMirror();
|
|
8309
8331
|
const downloads = await Promise.allSettled(
|
|
8310
8332
|
externalScripts.map(async ({ el, src }) => {
|
|
8311
8333
|
const integrity = el.getAttribute("integrity") || "";
|
|
@@ -8313,11 +8335,7 @@ async function inlineExternalScripts(html) {
|
|
|
8313
8335
|
if (bundled && matchesScriptIntegrity(bundled, integrity)) {
|
|
8314
8336
|
return { src, text: new TextDecoder().decode(bundled) };
|
|
8315
8337
|
}
|
|
8316
|
-
const
|
|
8317
|
-
signal: AbortSignal.timeout(15e3)
|
|
8318
|
-
});
|
|
8319
|
-
if (!response.ok) throw new Error(`HTTP ${response.status} for ${src}`);
|
|
8320
|
-
const bytes = new Uint8Array(await response.arrayBuffer());
|
|
8338
|
+
const bytes = await downloadScript(src, mirror);
|
|
8321
8339
|
if (!matchesScriptIntegrity(bytes, integrity)) {
|
|
8322
8340
|
throw new ScriptIntegrityError(`Subresource integrity mismatch for ${src}`);
|
|
8323
8341
|
}
|
|
@@ -2,4 +2,4 @@
|
|
|
2
2
|
* Re-exported from @hyperframes/engine.
|
|
3
3
|
* @see engine/src/utils/urlDownloader.ts for implementation.
|
|
4
4
|
*/
|
|
5
|
-
export { downloadToTemp, fetchPublicHttpsText, isHttpUrl, safeDownloadUrlIdentity, writeUrlDownloadTelemetry, type UrlDownloadTelemetry, } from "@hyperframes/engine";
|
|
5
|
+
export { downloadToTemp, fetchPublicHttpsBytes, fetchPublicHttpsText, isHttpUrl, safeDownloadUrlIdentity, writeUrlDownloadTelemetry, type UrlDownloadTelemetry, } from "@hyperframes/engine";
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@hyperframes/producer",
|
|
3
|
-
"version": "0.9.
|
|
3
|
+
"version": "0.9.49",
|
|
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/core": "0.9.
|
|
39
|
-
"@hyperframes/
|
|
40
|
-
"@hyperframes/lint": "0.9.
|
|
41
|
-
"@hyperframes/
|
|
42
|
-
"@hyperframes/studio-server": "0.9.
|
|
38
|
+
"@hyperframes/core": "0.9.49",
|
|
39
|
+
"@hyperframes/engine": "0.9.49",
|
|
40
|
+
"@hyperframes/lint": "0.9.49",
|
|
41
|
+
"@hyperframes/parsers": "0.9.49",
|
|
42
|
+
"@hyperframes/studio-server": "0.9.49"
|
|
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.49"
|
|
52
52
|
},
|
|
53
53
|
"engines": {
|
|
54
54
|
"node": ">=22"
|