@hyperframes/producer 0.9.70 → 0.9.71

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/index.js CHANGED
@@ -7254,6 +7254,7 @@ import {
7254
7254
  isJavaScriptType,
7255
7255
  prepareFlattenedInnerRoot,
7256
7256
  emitRootCompositionVariableStyles,
7257
+ dropAuthoredSvgReferenceAliases,
7257
7258
  readDeclaredDefaults,
7258
7259
  parseHostVariableValues,
7259
7260
  boundMediaSrc,
@@ -8877,13 +8878,14 @@ function inlineSubCompositions(html, subCompositions, projectDir, variableOverri
8877
8878
  const body = document2.querySelector("body");
8878
8879
  const hosts = Array.from(document2.querySelectorAll("[data-composition-src]"));
8879
8880
  if (!hosts.length) {
8881
+ const dropped = dropAuthoredSvgReferenceAliases(document2);
8880
8882
  const emitted = emitRootCompositionVariableStyles(
8881
8883
  document2,
8882
8884
  {},
8883
8885
  variableOverrides,
8884
8886
  { chargeBytes: (bytes) => budget.chargeGenerated("composition variables", bytes) }
8885
8887
  );
8886
- return { html: emitted ? document2.toString() : html, variablesByComp: {} };
8888
+ return { html: emitted || dropped ? document2.toString() : html, variablesByComp: {} };
8887
8889
  }
8888
8890
  const readOnce = /* @__PURE__ */ new Map();
8889
8891
  const readMountHtml = (srcPath) => {
@@ -9075,18 +9077,31 @@ function operatorGsapMirror() {
9075
9077
  return void 0;
9076
9078
  }
9077
9079
  }
9078
- async function downloadScript(src, mirror) {
9080
+ async function downloadScript(src, mirror, signal) {
9079
9081
  if (mirror && new URL(src).href.startsWith(mirror)) {
9080
- const response = await fetch(src, { redirect: "error", signal: AbortSignal.timeout(15e3) });
9082
+ const response = await fetch(src, {
9083
+ redirect: "error",
9084
+ signal: AbortSignal.any([AbortSignal.timeout(15e3), signal])
9085
+ });
9081
9086
  if (!response.ok) throw new Error(`HTTP ${response.status} for ${src}`);
9082
9087
  const bytes = new Uint8Array(await response.arrayBuffer());
9083
9088
  if (bytes.byteLength > MAX_SCRIPT_BYTES) throw new Error(`Script over 16 MiB: ${src}`);
9084
9089
  return bytes;
9085
9090
  }
9086
- return fetchPublicHttpsBytes(src, { maxBytes: MAX_SCRIPT_BYTES, timeoutMs: 15e3 });
9091
+ return fetchPublicHttpsBytes(src, { maxBytes: MAX_SCRIPT_BYTES, timeoutMs: 15e3, signal });
9087
9092
  }
9088
9093
  var MAX_CONCURRENT_SCRIPT_FETCHES = 4;
9089
- async function inlineExternalScripts(html, budget = new CompositionExpansionBudget()) {
9094
+ var MAX_REMOTE_FETCHES = 32;
9095
+ var REMOTE_FETCH_DEADLINE_MS = 6e4;
9096
+ var fetchSignalOf = (signal) => typeof signal === "function" ? signal() : signal;
9097
+ function assertRemoteFetchCount(kind, count) {
9098
+ if (count > MAX_REMOTE_FETCHES) {
9099
+ throw new Error(
9100
+ `The composition links ${count} remote ${kind}; at most ${MAX_REMOTE_FETCHES} are downloaded at compile time`
9101
+ );
9102
+ }
9103
+ }
9104
+ async function inlineExternalScripts(html, budget = new CompositionExpansionBudget(), signal) {
9090
9105
  const fullHtml = ensureFullDocument(html);
9091
9106
  const wrappedFragment = fullHtml !== html;
9092
9107
  const { document: document2 } = parseHTML5(fullHtml);
@@ -9099,9 +9114,19 @@ async function inlineExternalScripts(html, budget = new CompositionExpansionBudg
9099
9114
  }
9100
9115
  }
9101
9116
  if (externalScripts.length === 0) return html;
9117
+ const bundled = /* @__PURE__ */ new Map();
9118
+ const local = externalScripts.map(({ el, src }) => {
9119
+ if (!bundled.has(src)) bundled.set(src, bundledScript(src));
9120
+ const bytes = bundled.get(src);
9121
+ return bytes && matchesScriptIntegrity(bytes, el.getAttribute("integrity") || "") ? bytes : null;
9122
+ });
9123
+ const remote = new Set(externalScripts.filter((_, i) => !local[i]).map(({ src }) => src));
9124
+ assertRemoteFetchCount("scripts", remote.size);
9102
9125
  const mirror = operatorGsapMirror();
9103
9126
  const limit = createConcurrencyLimit(MAX_CONCURRENT_SCRIPT_FETCHES);
9104
9127
  const stop = new AbortController();
9128
+ const shared = remote.size > 0 ? fetchSignalOf(signal) : void 0;
9129
+ const fetchSignal = shared ? AbortSignal.any([stop.signal, shared]) : stop.signal;
9105
9130
  const fail = (error) => {
9106
9131
  stop.abort(error);
9107
9132
  throw error;
@@ -9118,21 +9143,21 @@ async function inlineExternalScripts(html, budget = new CompositionExpansionBudg
9118
9143
  let bytes = fetches.get(src);
9119
9144
  if (!bytes) {
9120
9145
  bytes = limit(async () => {
9121
- if (stop.signal.aborted) throw stop.signal.reason;
9122
- const downloaded = await downloadScript(src, mirror);
9146
+ fetchSignal.throwIfAborted();
9147
+ const downloaded = await downloadScript(src, mirror, fetchSignal);
9123
9148
  charge(downloaded.byteLength);
9124
9149
  return downloaded;
9125
- }, stop.signal);
9150
+ }, fetchSignal);
9126
9151
  fetches.set(src, bytes);
9127
9152
  }
9128
9153
  return bytes;
9129
9154
  };
9130
9155
  const placed = /* @__PURE__ */ new Set();
9131
9156
  const downloads = await Promise.allSettled(
9132
- externalScripts.map(async ({ el, src }) => {
9157
+ externalScripts.map(async ({ el, src }, i) => {
9133
9158
  const integrity = el.getAttribute("integrity") || "";
9134
- let bytes = bundledScript(src);
9135
- if (bytes && matchesScriptIntegrity(bytes, integrity)) {
9159
+ let bytes = local[i];
9160
+ if (bytes) {
9136
9161
  charge(bytes.byteLength);
9137
9162
  } else {
9138
9163
  bytes = await fetchOnce(src);
@@ -9329,12 +9354,13 @@ function isGoogleFontsUrl(href) {
9329
9354
  }
9330
9355
  }
9331
9356
  var MAX_STYLESHEET_BYTES = 2 * 1024 * 1024;
9332
- async function fetchExternalStylesheetCss(href) {
9357
+ async function fetchExternalStylesheetCss(href, signal) {
9333
9358
  const identity = safeDownloadUrlIdentity(href);
9334
9359
  try {
9335
9360
  return await fetchPublicHttpsText(href, {
9336
9361
  maxBytes: MAX_STYLESHEET_BYTES,
9337
- timeoutMs: 15e3
9362
+ timeoutMs: 15e3,
9363
+ signal
9338
9364
  });
9339
9365
  } catch (err) {
9340
9366
  defaultLogger.warn("[Compiler] External stylesheet fetch failed, preserving link tag.", {
@@ -9374,36 +9400,42 @@ function remoteFontStylesheetHref(tag) {
9374
9400
  if (!href || !/^https?:\/\//i.test(href) || isGoogleFontsUrl(href)) return void 0;
9375
9401
  return href;
9376
9402
  }
9377
- async function inlineExternalFontStylesheets(html, budget = new CompositionExpansionBudget()) {
9403
+ async function inlineExternalFontStylesheets(html, budget = new CompositionExpansionBudget(), signal) {
9378
9404
  const hrefs = /* @__PURE__ */ new Set();
9379
9405
  for (const { parts } of stylesheetLinkMatches(html)) {
9380
9406
  const href = remoteFontStylesheetHref(parts[0]);
9381
9407
  if (href) hrefs.add(href);
9382
9408
  }
9383
9409
  if (hrefs.size === 0) return html;
9384
- const MAX_CONCURRENT_STYLESHEET_FETCHES = 4;
9410
+ assertRemoteFetchCount("stylesheets", hrefs.size);
9411
+ const limit = createConcurrencyLimit(MAX_CONCURRENT_SCRIPT_FETCHES);
9412
+ const stop = new AbortController();
9413
+ const shared = fetchSignalOf(signal);
9414
+ const fetchSignal = shared ? AbortSignal.any([stop.signal, shared]) : stop.signal;
9385
9415
  const inlineByHref = /* @__PURE__ */ new Map();
9386
- const unique = [...hrefs];
9387
- for (let i = 0; i < unique.length; i += MAX_CONCURRENT_STYLESHEET_FETCHES) {
9388
- const batch = unique.slice(i, i + MAX_CONCURRENT_STYLESHEET_FETCHES);
9389
- const sheets = await Promise.all(batch.map(fetchExternalStylesheetCss));
9390
- batch.forEach((href, index) => {
9391
- const css = sheets[index];
9392
- const fontFaceBlocks = css ? extractFontFaceBlocks(css) : [];
9393
- if (fontFaceBlocks.length === 0) return;
9394
- const inlineStyle = `<style>/* Inlined external font stylesheet */
9416
+ const inlineSheet = async (href) => {
9417
+ const css = await fetchExternalStylesheetCss(href, fetchSignal);
9418
+ const fontFaceBlocks = css ? extractFontFaceBlocks(css) : [];
9419
+ if (fontFaceBlocks.length === 0) return;
9420
+ const inlineStyle = `<style>/* Inlined external font stylesheet */
9395
9421
  ${fontFaceBlocks.join("\n")}
9396
9422
  </style>`;
9423
+ try {
9397
9424
  budget.chargeGenerated(REMOTE_STYLESHEETS, inlineStyle.length);
9398
- inlineByHref.set(href, inlineStyle);
9399
- const identity = safeDownloadUrlIdentity(href);
9400
- defaultLogger.debug("[Compiler] Inlined external @font-face rule(s)", {
9401
- count: fontFaceBlocks.length,
9402
- urlFingerprint: identity.urlFingerprint,
9403
- host: identity.host
9404
- });
9425
+ } catch (error) {
9426
+ stop.abort(error);
9427
+ throw error;
9428
+ }
9429
+ inlineByHref.set(href, inlineStyle);
9430
+ const identity = safeDownloadUrlIdentity(href);
9431
+ defaultLogger.debug("[Compiler] Inlined external @font-face rule(s)", {
9432
+ count: fontFaceBlocks.length,
9433
+ urlFingerprint: identity.urlFingerprint,
9434
+ host: identity.host
9405
9435
  });
9406
- }
9436
+ };
9437
+ await Promise.allSettled([...hrefs].map((href) => limit(() => inlineSheet(href), fetchSignal)));
9438
+ if (stop.signal.aborted) throw stop.signal.reason;
9407
9439
  const placed = /* @__PURE__ */ new Set();
9408
9440
  return replaceMatches(html, stylesheetLinkMatches(html), (tag) => {
9409
9441
  const href = remoteFontStylesheetHref(tag);
@@ -9716,10 +9748,17 @@ async function compileForRender(projectDir, htmlPath, downloadDir, options = {})
9716
9748
  const hasShaderTransitions = detectShaderTransitionUsage(sanitizedHtml);
9717
9749
  const usesThreeDTransforms = detectThreeDTransformUsage(sanitizedHtml);
9718
9750
  const hasAncestorBackgroundImage = detectAncestorBackgroundImage(sanitizedHtml);
9751
+ let deadline;
9752
+ const remoteFetches = () => deadline ??= AbortSignal.any([
9753
+ AbortSignal.timeout(REMOTE_FETCH_DEADLINE_MS),
9754
+ ...options.abortSignal ? [options.abortSignal] : []
9755
+ ]);
9719
9756
  const fontSheetHtml = await inlineExternalFontStylesheets(
9720
9757
  promoteCssImportsToLinkTags(sanitizedHtml),
9721
- budget
9758
+ budget,
9759
+ remoteFetches
9722
9760
  );
9761
+ options.abortSignal?.throwIfAborted();
9723
9762
  const normalizedFontHtml = normalizeSystemFontPrimaryFamilies(
9724
9763
  injectTextRenderingRule(coalesceHeadStylesAndBodyScripts(fontSheetHtml))
9725
9764
  );
@@ -9730,7 +9769,8 @@ async function compileForRender(projectDir, htmlPath, downloadDir, options = {})
9730
9769
  projectFontFamilies: projectStylesheetFontFamilies(fontSheetHtml, projectDir),
9731
9770
  abortSignal: options.abortSignal
9732
9771
  });
9733
- const assembledHtml = await inlineExternalScripts(coalescedHtml, budget);
9772
+ const assembledHtml = await inlineExternalScripts(coalescedHtml, budget, remoteFetches);
9773
+ options.abortSignal?.throwIfAborted();
9734
9774
  const htmlWithPositionScript = htmlHasStudioPositionEdits(assembledHtml) ? insertBeforeCloseTag(
9735
9775
  assembledHtml,
9736
9776
  "body",
@@ -15711,6 +15751,7 @@ async function executeRenderPipeline(input) {
15711
15751
  needsAlpha,
15712
15752
  log,
15713
15753
  assertNotAborted,
15754
+ abortSignal: executionSignal,
15714
15755
  variables: job.config.variables,
15715
15756
  pageMotionBlur: job.config.pageMotionBlur
15716
15757
  })
@@ -7269,6 +7269,7 @@ import {
7269
7269
  isJavaScriptType,
7270
7270
  prepareFlattenedInnerRoot,
7271
7271
  emitRootCompositionVariableStyles,
7272
+ dropAuthoredSvgReferenceAliases,
7272
7273
  readDeclaredDefaults,
7273
7274
  parseHostVariableValues,
7274
7275
  boundMediaSrc,
@@ -8892,13 +8893,14 @@ function inlineSubCompositions(html, subCompositions, projectDir, variableOverri
8892
8893
  const body = document2.querySelector("body");
8893
8894
  const hosts = Array.from(document2.querySelectorAll("[data-composition-src]"));
8894
8895
  if (!hosts.length) {
8896
+ const dropped = dropAuthoredSvgReferenceAliases(document2);
8895
8897
  const emitted = emitRootCompositionVariableStyles(
8896
8898
  document2,
8897
8899
  {},
8898
8900
  variableOverrides,
8899
8901
  { chargeBytes: (bytes) => budget.chargeGenerated("composition variables", bytes) }
8900
8902
  );
8901
- return { html: emitted ? document2.toString() : html, variablesByComp: {} };
8903
+ return { html: emitted || dropped ? document2.toString() : html, variablesByComp: {} };
8902
8904
  }
8903
8905
  const readOnce = /* @__PURE__ */ new Map();
8904
8906
  const readMountHtml = (srcPath) => {
@@ -9090,18 +9092,31 @@ function operatorGsapMirror() {
9090
9092
  return void 0;
9091
9093
  }
9092
9094
  }
9093
- async function downloadScript(src, mirror) {
9095
+ async function downloadScript(src, mirror, signal) {
9094
9096
  if (mirror && new URL(src).href.startsWith(mirror)) {
9095
- const response = await fetch(src, { redirect: "error", signal: AbortSignal.timeout(15e3) });
9097
+ const response = await fetch(src, {
9098
+ redirect: "error",
9099
+ signal: AbortSignal.any([AbortSignal.timeout(15e3), signal])
9100
+ });
9096
9101
  if (!response.ok) throw new Error(`HTTP ${response.status} for ${src}`);
9097
9102
  const bytes = new Uint8Array(await response.arrayBuffer());
9098
9103
  if (bytes.byteLength > MAX_SCRIPT_BYTES) throw new Error(`Script over 16 MiB: ${src}`);
9099
9104
  return bytes;
9100
9105
  }
9101
- return fetchPublicHttpsBytes(src, { maxBytes: MAX_SCRIPT_BYTES, timeoutMs: 15e3 });
9106
+ return fetchPublicHttpsBytes(src, { maxBytes: MAX_SCRIPT_BYTES, timeoutMs: 15e3, signal });
9102
9107
  }
9103
9108
  var MAX_CONCURRENT_SCRIPT_FETCHES = 4;
9104
- async function inlineExternalScripts(html, budget = new CompositionExpansionBudget()) {
9109
+ var MAX_REMOTE_FETCHES = 32;
9110
+ var REMOTE_FETCH_DEADLINE_MS = 6e4;
9111
+ var fetchSignalOf = (signal) => typeof signal === "function" ? signal() : signal;
9112
+ function assertRemoteFetchCount(kind, count) {
9113
+ if (count > MAX_REMOTE_FETCHES) {
9114
+ throw new Error(
9115
+ `The composition links ${count} remote ${kind}; at most ${MAX_REMOTE_FETCHES} are downloaded at compile time`
9116
+ );
9117
+ }
9118
+ }
9119
+ async function inlineExternalScripts(html, budget = new CompositionExpansionBudget(), signal) {
9105
9120
  const fullHtml = ensureFullDocument(html);
9106
9121
  const wrappedFragment = fullHtml !== html;
9107
9122
  const { document: document2 } = parseHTML5(fullHtml);
@@ -9114,9 +9129,19 @@ async function inlineExternalScripts(html, budget = new CompositionExpansionBudg
9114
9129
  }
9115
9130
  }
9116
9131
  if (externalScripts.length === 0) return html;
9132
+ const bundled = /* @__PURE__ */ new Map();
9133
+ const local = externalScripts.map(({ el, src }) => {
9134
+ if (!bundled.has(src)) bundled.set(src, bundledScript(src));
9135
+ const bytes = bundled.get(src);
9136
+ return bytes && matchesScriptIntegrity(bytes, el.getAttribute("integrity") || "") ? bytes : null;
9137
+ });
9138
+ const remote = new Set(externalScripts.filter((_, i) => !local[i]).map(({ src }) => src));
9139
+ assertRemoteFetchCount("scripts", remote.size);
9117
9140
  const mirror = operatorGsapMirror();
9118
9141
  const limit = createConcurrencyLimit(MAX_CONCURRENT_SCRIPT_FETCHES);
9119
9142
  const stop = new AbortController();
9143
+ const shared = remote.size > 0 ? fetchSignalOf(signal) : void 0;
9144
+ const fetchSignal = shared ? AbortSignal.any([stop.signal, shared]) : stop.signal;
9120
9145
  const fail = (error) => {
9121
9146
  stop.abort(error);
9122
9147
  throw error;
@@ -9133,21 +9158,21 @@ async function inlineExternalScripts(html, budget = new CompositionExpansionBudg
9133
9158
  let bytes = fetches.get(src);
9134
9159
  if (!bytes) {
9135
9160
  bytes = limit(async () => {
9136
- if (stop.signal.aborted) throw stop.signal.reason;
9137
- const downloaded = await downloadScript(src, mirror);
9161
+ fetchSignal.throwIfAborted();
9162
+ const downloaded = await downloadScript(src, mirror, fetchSignal);
9138
9163
  charge(downloaded.byteLength);
9139
9164
  return downloaded;
9140
- }, stop.signal);
9165
+ }, fetchSignal);
9141
9166
  fetches.set(src, bytes);
9142
9167
  }
9143
9168
  return bytes;
9144
9169
  };
9145
9170
  const placed = /* @__PURE__ */ new Set();
9146
9171
  const downloads = await Promise.allSettled(
9147
- externalScripts.map(async ({ el, src }) => {
9172
+ externalScripts.map(async ({ el, src }, i) => {
9148
9173
  const integrity = el.getAttribute("integrity") || "";
9149
- let bytes = bundledScript(src);
9150
- if (bytes && matchesScriptIntegrity(bytes, integrity)) {
9174
+ let bytes = local[i];
9175
+ if (bytes) {
9151
9176
  charge(bytes.byteLength);
9152
9177
  } else {
9153
9178
  bytes = await fetchOnce(src);
@@ -9344,12 +9369,13 @@ function isGoogleFontsUrl(href) {
9344
9369
  }
9345
9370
  }
9346
9371
  var MAX_STYLESHEET_BYTES = 2 * 1024 * 1024;
9347
- async function fetchExternalStylesheetCss(href) {
9372
+ async function fetchExternalStylesheetCss(href, signal) {
9348
9373
  const identity = safeDownloadUrlIdentity(href);
9349
9374
  try {
9350
9375
  return await fetchPublicHttpsText(href, {
9351
9376
  maxBytes: MAX_STYLESHEET_BYTES,
9352
- timeoutMs: 15e3
9377
+ timeoutMs: 15e3,
9378
+ signal
9353
9379
  });
9354
9380
  } catch (err) {
9355
9381
  defaultLogger.warn("[Compiler] External stylesheet fetch failed, preserving link tag.", {
@@ -9389,36 +9415,42 @@ function remoteFontStylesheetHref(tag) {
9389
9415
  if (!href || !/^https?:\/\//i.test(href) || isGoogleFontsUrl(href)) return void 0;
9390
9416
  return href;
9391
9417
  }
9392
- async function inlineExternalFontStylesheets(html, budget = new CompositionExpansionBudget()) {
9418
+ async function inlineExternalFontStylesheets(html, budget = new CompositionExpansionBudget(), signal) {
9393
9419
  const hrefs = /* @__PURE__ */ new Set();
9394
9420
  for (const { parts } of stylesheetLinkMatches(html)) {
9395
9421
  const href = remoteFontStylesheetHref(parts[0]);
9396
9422
  if (href) hrefs.add(href);
9397
9423
  }
9398
9424
  if (hrefs.size === 0) return html;
9399
- const MAX_CONCURRENT_STYLESHEET_FETCHES = 4;
9425
+ assertRemoteFetchCount("stylesheets", hrefs.size);
9426
+ const limit = createConcurrencyLimit(MAX_CONCURRENT_SCRIPT_FETCHES);
9427
+ const stop = new AbortController();
9428
+ const shared = fetchSignalOf(signal);
9429
+ const fetchSignal = shared ? AbortSignal.any([stop.signal, shared]) : stop.signal;
9400
9430
  const inlineByHref = /* @__PURE__ */ new Map();
9401
- const unique = [...hrefs];
9402
- for (let i = 0; i < unique.length; i += MAX_CONCURRENT_STYLESHEET_FETCHES) {
9403
- const batch = unique.slice(i, i + MAX_CONCURRENT_STYLESHEET_FETCHES);
9404
- const sheets = await Promise.all(batch.map(fetchExternalStylesheetCss));
9405
- batch.forEach((href, index) => {
9406
- const css = sheets[index];
9407
- const fontFaceBlocks = css ? extractFontFaceBlocks(css) : [];
9408
- if (fontFaceBlocks.length === 0) return;
9409
- const inlineStyle = `<style>/* Inlined external font stylesheet */
9431
+ const inlineSheet = async (href) => {
9432
+ const css = await fetchExternalStylesheetCss(href, fetchSignal);
9433
+ const fontFaceBlocks = css ? extractFontFaceBlocks(css) : [];
9434
+ if (fontFaceBlocks.length === 0) return;
9435
+ const inlineStyle = `<style>/* Inlined external font stylesheet */
9410
9436
  ${fontFaceBlocks.join("\n")}
9411
9437
  </style>`;
9438
+ try {
9412
9439
  budget.chargeGenerated(REMOTE_STYLESHEETS, inlineStyle.length);
9413
- inlineByHref.set(href, inlineStyle);
9414
- const identity = safeDownloadUrlIdentity(href);
9415
- defaultLogger.debug("[Compiler] Inlined external @font-face rule(s)", {
9416
- count: fontFaceBlocks.length,
9417
- urlFingerprint: identity.urlFingerprint,
9418
- host: identity.host
9419
- });
9440
+ } catch (error) {
9441
+ stop.abort(error);
9442
+ throw error;
9443
+ }
9444
+ inlineByHref.set(href, inlineStyle);
9445
+ const identity = safeDownloadUrlIdentity(href);
9446
+ defaultLogger.debug("[Compiler] Inlined external @font-face rule(s)", {
9447
+ count: fontFaceBlocks.length,
9448
+ urlFingerprint: identity.urlFingerprint,
9449
+ host: identity.host
9420
9450
  });
9421
- }
9451
+ };
9452
+ await Promise.allSettled([...hrefs].map((href) => limit(() => inlineSheet(href), fetchSignal)));
9453
+ if (stop.signal.aborted) throw stop.signal.reason;
9422
9454
  const placed = /* @__PURE__ */ new Set();
9423
9455
  return replaceMatches(html, stylesheetLinkMatches(html), (tag) => {
9424
9456
  const href = remoteFontStylesheetHref(tag);
@@ -9728,10 +9760,17 @@ async function compileForRender(projectDir, htmlPath, downloadDir, options = {})
9728
9760
  const hasShaderTransitions = detectShaderTransitionUsage(sanitizedHtml);
9729
9761
  const usesThreeDTransforms = detectThreeDTransformUsage(sanitizedHtml);
9730
9762
  const hasAncestorBackgroundImage = detectAncestorBackgroundImage(sanitizedHtml);
9763
+ let deadline;
9764
+ const remoteFetches = () => deadline ??= AbortSignal.any([
9765
+ AbortSignal.timeout(REMOTE_FETCH_DEADLINE_MS),
9766
+ ...options.abortSignal ? [options.abortSignal] : []
9767
+ ]);
9731
9768
  const fontSheetHtml = await inlineExternalFontStylesheets(
9732
9769
  promoteCssImportsToLinkTags(sanitizedHtml),
9733
- budget
9770
+ budget,
9771
+ remoteFetches
9734
9772
  );
9773
+ options.abortSignal?.throwIfAborted();
9735
9774
  const normalizedFontHtml = normalizeSystemFontPrimaryFamilies(
9736
9775
  injectTextRenderingRule(coalesceHeadStylesAndBodyScripts(fontSheetHtml))
9737
9776
  );
@@ -9742,7 +9781,8 @@ async function compileForRender(projectDir, htmlPath, downloadDir, options = {})
9742
9781
  projectFontFamilies: projectStylesheetFontFamilies(fontSheetHtml, projectDir),
9743
9782
  abortSignal: options.abortSignal
9744
9783
  });
9745
- const assembledHtml = await inlineExternalScripts(coalescedHtml, budget);
9784
+ const assembledHtml = await inlineExternalScripts(coalescedHtml, budget, remoteFetches);
9785
+ options.abortSignal?.throwIfAborted();
9746
9786
  const htmlWithPositionScript = htmlHasStudioPositionEdits(assembledHtml) ? insertBeforeCloseTag(
9747
9787
  assembledHtml,
9748
9788
  "body",
@@ -15686,6 +15726,7 @@ async function executeRenderPipeline(input) {
15686
15726
  needsAlpha,
15687
15727
  log,
15688
15728
  assertNotAborted,
15729
+ abortSignal: executionSignal,
15689
15730
  variables: job.config.variables,
15690
15731
  pageMotionBlur: job.config.pageMotionBlur
15691
15732
  })
@@ -55,13 +55,26 @@ export declare function detectThreeDTransformUsage(html: string): boolean;
55
55
  */
56
56
  export declare function detectAncestorBackgroundImage(html: string): boolean;
57
57
  export declare function detectShaderTransitionUsage(html: string): boolean;
58
+ /**
59
+ * Distinct remote addresses one compile downloads, per kind: scripts, and non-Google stylesheets (counted before
60
+ * their contents are read, so a stylesheet with no font rules counts too).
61
+ */
62
+ export declare const MAX_REMOTE_FETCHES = 32;
63
+ /**
64
+ * The script and stylesheet inliners' downloads share this much time, from the first one; what is still pending then
65
+ * counts as failed. Fonts and other assets keep their own per-request limits.
66
+ */
67
+ export declare const REMOTE_FETCH_DEADLINE_MS = 60000;
68
+ /** A signal, or a getter that starts one when the first download asks for it. */
69
+ type FetchSignal = AbortSignal | (() => AbortSignal);
58
70
  /**
59
71
  * Download external CDN scripts and inline them into the HTML so rendering
60
72
  * works without network access (Docker, CI, restricted environments). Each URL
61
73
  * is fetched once, a few at a time, and every inlined copy is charged to the
62
74
  * render's budget as it arrives, so going over stops the downloads still queued.
75
+ * Once `signal` aborts, pending downloads fail and their tags are left as they are.
63
76
  */
64
- export declare function inlineExternalScripts(html: string, budget?: CompositionExpansionBudget): Promise<string>;
77
+ export declare function inlineExternalScripts(html: string, budget?: CompositionExpansionBudget, signal?: FetchSignal): Promise<string>;
65
78
  /**
66
79
  * Scan compiled HTML for asset references that resolve outside projectDir.
67
80
  * For each, map the normalized in-HTML path to the real filesystem path so
@@ -184,7 +197,7 @@ export interface CompileForRenderOptions {
184
197
  * prevent host-specific font capture from leaking into the planDir.
185
198
  */
186
199
  allowSystemFontCapture?: boolean;
187
- /** Caller cancellation propagated through compile-time font fetches. */
200
+ /** Caller cancellation propagated through compile-time font, stylesheet and script fetches. */
188
201
  abortSignal?: AbortSignal;
189
202
  /** Persistent cache directory for the animated GIF and HEIC prep transcodes; defaults to downloadDir. */
190
203
  animatedGifCacheDir?: string;
@@ -259,3 +272,4 @@ export declare function resolveCompositionDurations(page: Page, unresolved: Unre
259
272
  * Injects durations into the HTML and re-parses sub-composition media with proper bounds.
260
273
  */
261
274
  export declare function recompileWithResolutions(compiled: CompiledComposition, resolutions: ResolvedDuration[], projectDir: string, downloadDir: string, assetRoot?: string, outsideFiles?: OutsideFilePolicy): Promise<CompiledComposition>;
275
+ export {};
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@hyperframes/producer",
3
- "version": "0.9.70",
3
+ "version": "0.9.71",
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.70",
39
- "@hyperframes/lint": "0.9.70",
40
- "@hyperframes/engine": "0.9.70",
41
- "@hyperframes/parsers": "0.9.70",
42
- "@hyperframes/studio-server": "0.9.70"
38
+ "@hyperframes/engine": "0.9.71",
39
+ "@hyperframes/core": "0.9.71",
40
+ "@hyperframes/parsers": "0.9.71",
41
+ "@hyperframes/lint": "0.9.71",
42
+ "@hyperframes/studio-server": "0.9.71"
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.70"
51
+ "@hyperframes/aws-lambda": "0.9.71"
52
52
  },
53
53
  "engines": {
54
54
  "node": ">=22"