@hyperframes/producer 0.9.54 → 0.9.56

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/README.md CHANGED
@@ -8,7 +8,7 @@ Full HTML-to-video rendering pipeline: capture frames with Chrome's BeginFrame A
8
8
  npm install @hyperframes/producer
9
9
  ```
10
10
 
11
- **Requirements:** Node.js >= 22, Chrome/Chromium (auto-downloaded), FFmpeg
11
+ **Requirements:** Node.js >= 22, FFmpeg, and the pinned `chrome-headless-shell`: run `npx hyperframes browser ensure` once, or name a browser in `PRODUCER_HEADLESS_SHELL_PATH`. A cached browser is used only when its files match the pinned build. HDR capture needs a full Chrome named in `HYPERFRAMES_BROWSER_PATH`.
12
12
 
13
13
  ## Usage
14
14
 
@@ -39,7 +39,7 @@ export { assemble, chunksAreStitchedMp4, stitchesSeparateAudio, type AssembleChu
39
39
  export { muxChunkWithAudio } from "./services/distributed/chunkAudio.js";
40
40
  export { buildStitchedHeader, readMp4Layout, type Mp4Layout, type ReadRange, } from "./services/distributed/mp4Stitch.js";
41
41
  export { InvalidConfigError, type SerializableDistributedRenderConfig, validateDistributedRenderConfig, validateVariablesPayload, } from "./services/distributed/renderConfigValidation.js";
42
- export { hashProjectDir, listSiteFiles } from "./services/distributed/projectHash.js";
42
+ export { hashProjectDir, isPrivateSitePath, listSiteFiles, listSiteFilesForUpload, } from "./services/distributed/projectHash.js";
43
43
  export { AUDIO_SIDECAR_MIN_BYTES, buildAudioSidecar, wantsAudioSidecar, type AudioSidecarOutcome, } from "./services/distributed/audioSidecar.js";
44
44
  export { buildProbeFacts, wantsProbeFacts, type ProbeFactsOutcome, } from "./services/distributed/probeFacts.js";
45
45
  export { PLAN_PROTOCOL_V2, PLAN_PROTOCOL_UNSUPPORTED, PLAN_V2_ARTIFACT_LAYOUT, PLAN_V2_HASH_SCHEMA, PLAN_V2_SCHEMA_VERSION, PlanProtocolUnsupportedError, type PlanProtocolDescriptor, type PlanProtocolV2Descriptor, } from "./services/distributed/planProtocol.js";
@@ -160,7 +160,177 @@ import {
160
160
  toFps as toFps2
161
161
  } from "@hyperframes/core";
162
162
  import { HF_AUDIO_GROUP_TAG } from "@hyperframes/core/audio-groups";
163
- import { HTML_BODY_CSS_HEIGHT_FIRST_RE, HTML_BODY_CSS_WIDTH_FIRST_RE } from "@hyperframes/parsers";
163
+
164
+ // src/services/htmlTagScans.ts
165
+ function forwardFinder(text, pattern) {
166
+ let start = -1;
167
+ let found = null;
168
+ return (from) => {
169
+ if (start < 0 || from < start || found !== null && from > found.index) {
170
+ start = from;
171
+ pattern.lastIndex = from;
172
+ found = pattern.exec(text);
173
+ }
174
+ return found;
175
+ };
176
+ }
177
+ function indexFinder(text, pattern) {
178
+ const find = forwardFinder(text, pattern);
179
+ return (from) => find(from)?.index ?? -1;
180
+ }
181
+ function* inlineScriptBlocks(html) {
182
+ const opener = /<script\b/gi;
183
+ const closer = /<\/script>/gi;
184
+ for (let open2 = opener.exec(html); open2; open2 = opener.exec(html)) {
185
+ const attrsStart = open2.index + open2[0].length;
186
+ const gt = html.indexOf(">", attrsStart);
187
+ if (gt < 0) return;
188
+ closer.lastIndex = gt + 1;
189
+ const close = closer.exec(html);
190
+ if (!close) return;
191
+ yield { attrs: html.slice(attrsStart, gt), body: html.slice(gt + 1, close.index) };
192
+ opener.lastIndex = close.index + close[0].length;
193
+ }
194
+ }
195
+ function removeDelimitedRuns(source, start, end) {
196
+ let out = "";
197
+ let kept = 0;
198
+ for (let open2 = source.indexOf(start); open2 >= 0; open2 = source.indexOf(start, kept)) {
199
+ const close = source.indexOf(end, open2 + start.length);
200
+ if (close < 0) break;
201
+ out += source.slice(kept, open2);
202
+ kept = close + end.length;
203
+ }
204
+ return out + source.slice(kept);
205
+ }
206
+ function gsapDistFile(value) {
207
+ let dist = -1;
208
+ const distPattern = /\/dist\//gi;
209
+ for (let m = distPattern.exec(value); m; m = distPattern.exec(value)) {
210
+ if (m.index + 6 < value.length) dist = m.index;
211
+ distPattern.lastIndex = m.index + 1;
212
+ }
213
+ const gsap = dist < 0 ? null : /gsap/i.exec(value);
214
+ return gsap && gsap.index + 4 <= dist ? value.slice(dist + 6) : void 0;
215
+ }
216
+ function lastGsapMatch(html, finders, tagStart, gt) {
217
+ const { nextSrc, nextQuote, nextGt } = finders;
218
+ let match;
219
+ for (let src = nextSrc(tagStart); src && src.index < gt; src = nextSrc(src.index + 1)) {
220
+ const valueStart = src.index + 5;
221
+ const close = nextQuote(valueStart);
222
+ const end = close < 0 ? -1 : nextGt(close + 1);
223
+ if (end < 0) return { match, laterTagsFail: true };
224
+ const file = gsapDistFile(html.slice(valueStart, close));
225
+ if (file !== void 0) match = { valueStart, close, end, file };
226
+ }
227
+ return { match, laterTagsFail: false };
228
+ }
229
+ function replaceGsapDistScripts(html, replace) {
230
+ const opener = /<script\b/gi;
231
+ const finders = {
232
+ nextSrc: forwardFinder(html, /\bsrc=["']/gi),
233
+ nextQuote: indexFinder(html, /["']/g),
234
+ nextGt: indexFinder(html, />/g)
235
+ };
236
+ let out = "";
237
+ let kept = 0;
238
+ for (let open2 = opener.exec(html); open2; open2 = opener.exec(html)) {
239
+ const gt = finders.nextGt(open2.index);
240
+ if (gt < 0) break;
241
+ const { match, laterTagsFail } = lastGsapMatch(html, finders, open2.index, gt);
242
+ if (match) {
243
+ const { valueStart, close, end, file } = match;
244
+ const full = html.slice(open2.index, end + 1);
245
+ const src = html.slice(valueStart, close);
246
+ out += html.slice(kept, open2.index);
247
+ out += replace(
248
+ full,
249
+ html.slice(open2.index, valueStart),
250
+ src,
251
+ file,
252
+ html.slice(close, end + 1)
253
+ );
254
+ kept = end + 1;
255
+ }
256
+ if (laterTagsFail) break;
257
+ opener.lastIndex = match ? kept : gt;
258
+ }
259
+ return out + html.slice(kept);
260
+ }
261
+ function removeSpanPerTag(html, opener, spanIn) {
262
+ const nextGt = indexFinder(html, />/g);
263
+ let out = "";
264
+ let kept = 0;
265
+ for (let open2 = opener.exec(html); open2; open2 = opener.exec(html)) {
266
+ const attrsStart = open2.index + open2[0].length;
267
+ const gt = nextGt(attrsStart);
268
+ const span = spanIn(attrsStart, gt < 0 ? html.length : gt);
269
+ if (span) {
270
+ out += html.slice(kept, span[0]);
271
+ kept = span[1];
272
+ } else if (gt < 0) break;
273
+ opener.lastIndex = span ? kept : gt;
274
+ }
275
+ return out + html.slice(kept);
276
+ }
277
+ function stripCrossoriginAttr(html, tagName) {
278
+ const nextQuote = indexFinder(html, /["']/g);
279
+ const nextAttr = forwardFinder(html, /\scrossorigin/gi);
280
+ return removeSpanPerTag(html, new RegExp(`<${tagName}\\b`, "gi"), (attrsStart, tagEnd) => {
281
+ let last = -1;
282
+ for (let at = nextAttr(attrsStart); at && at.index < tagEnd; at = nextAttr(at.index + 12)) {
283
+ last = at.index;
284
+ }
285
+ if (last < 0) return void 0;
286
+ const nameEnd = last + 12;
287
+ const quote = html[nameEnd + 1];
288
+ const quoted = html[nameEnd] === "=" && (quote === '"' || quote === "'");
289
+ const close = quoted ? nextQuote(nameEnd + 2) : -1;
290
+ return [last, close < 0 ? nameEnd : close + 1];
291
+ });
292
+ }
293
+ function stripPreloadNone(html) {
294
+ const nextAttr = forwardFinder(html, /(?<!\s)\s+preload\s*=\s*["']none["']/gi);
295
+ return removeSpanPerTag(html, /<(?:video|audio)\b/gi, (attrsStart, tagEnd) => {
296
+ const attr = nextAttr(attrsStart);
297
+ return attr && attr.index < tagEnd ? [attr.index, attr.index + attr[0].length] : void 0;
298
+ });
299
+ }
300
+ var REMOTE_SRC_TAGS = {
301
+ media: { opener: "<(?:video|audio)\\b", attr: /\bsrc\s*=\s*["'](https?:\/\/)/gi },
302
+ source: { opener: "<source\\b", attr: /\bsrc\s*=\s*["'](https?:\/\/)/gi },
303
+ img: { opener: "<img\\b", attr: /(?<![\w-])src\s*=\s*["'](https?:\/\/)/gi }
304
+ };
305
+ function remoteSrcUrls(html, tag) {
306
+ const opener = new RegExp(REMOTE_SRC_TAGS[tag].opener, "gi");
307
+ const nextAttr = forwardFinder(html, new RegExp(REMOTE_SRC_TAGS[tag].attr));
308
+ const nextGt = indexFinder(html, />/g);
309
+ const nextQuote = indexFinder(html, /["']/g);
310
+ const urls = [];
311
+ for (let open2 = opener.exec(html); open2; open2 = opener.exec(html)) {
312
+ const attrsStart = open2.index + open2[0].length;
313
+ const gt = nextGt(attrsStart);
314
+ if (gt < 0) break;
315
+ let resumeAt = gt;
316
+ for (let attr = nextAttr(attrsStart); attr && attr.index < gt; attr = nextAttr(attr.index + 1)) {
317
+ const urlRest = attr.index + attr[0].length;
318
+ const close = nextQuote(urlRest);
319
+ if (close < 0) return urls;
320
+ if (close === urlRest) continue;
321
+ const end = nextGt(close + 1);
322
+ if (end < 0) return urls;
323
+ urls.push(html.slice(urlRest - attr[1].length, close));
324
+ resumeAt = end + 1;
325
+ break;
326
+ }
327
+ opener.lastIndex = resumeAt;
328
+ }
329
+ return urls;
330
+ }
331
+
332
+ // src/services/renderOrchestrator.ts
333
+ import { matchHtmlBodyCssHeightFirst, matchHtmlBodyCssWidthFirst } from "@hyperframes/parsers";
164
334
  import {
165
335
  extractMediaMetadata as extractMediaMetadata5,
166
336
  resolveConfig as resolveConfig2,
@@ -220,6 +390,8 @@ import { promisify } from "node:util";
220
390
  import { Readable } from "node:stream";
221
391
  import { join as join2, extname, resolve as resolve2, sep as sep2 } from "node:path";
222
392
  import { injectScriptsAtHeadStart, injectScriptsIntoHtml } from "@hyperframes/core/compiler";
393
+ import { injectTagsAtHeadStart } from "@hyperframes/core/compiler/html-document";
394
+ import { PREVIEW_FOR_ANOTHER_SITE_META } from "@hyperframes/core/studio-preview-mark";
223
395
  import { fpsToNumber } from "@hyperframes/core";
224
396
  import { isPrivateFileUnder, isStudioPrivatePath } from "@hyperframes/core/safe-path";
225
397
  import { stripSdrPngColourTags } from "@hyperframes/core/compiler/png-colour-tags";
@@ -822,6 +994,7 @@ var HF_BRIDGE_SCRIPT = `(function() {
822
994
  if (bridge()) __realClearInterval(iv);
823
995
  }, 50);
824
996
  })();`;
997
+ var OFFER_NO_FRAMING_SITE_AN_EDITING_PORT = `<meta name="${PREVIEW_FOR_ANOTHER_SITE_META}">`;
825
998
  var RENDER_CAPTURE_MODE_SHIM = "globalThis.__HF_RENDER_CAPTURE_MODE = true;";
826
999
  function closeFileServerSafely(fileServer, label, log = defaultLogger) {
827
1000
  try {
@@ -909,6 +1082,7 @@ function createFileServer(options) {
909
1082
  html = injectScriptsAtHeadStart(html, preHeadScripts);
910
1083
  }
911
1084
  html = isIndex ? injectScriptsIntoHtml(html, headScripts, bodyScripts, stripEmbeddedRuntime) : html;
1085
+ html = injectTagsAtHeadStart(html, OFFER_NO_FRAMING_SITE_AN_EDITING_PORT);
912
1086
  return c.text(html, 200, { "Content-Type": contentType });
913
1087
  }
914
1088
  if (ext === ".png") {
@@ -2560,14 +2734,13 @@ function resolveLocalImageSourcePath(src, options) {
2560
2734
  const mapped = options.sourceAssets?.get(trimmed) ?? options.sourceAssets?.get(basePath) ?? options.sourceAssets?.get(normalizedBase);
2561
2735
  if (mapped && existsSync5(mapped)) return mapped;
2562
2736
  if (isHttpUrl(trimmed)) return null;
2563
- const protocolRelativeUrlOnShare = basePath.startsWith("/") && namesAnotherNetworkRoot(options.projectDir, basePath);
2564
2737
  const projectRelative = basePath.startsWith("/") ? basePath.slice(1) : basePath;
2565
2738
  const candidates = [
2566
- ...protocolRelativeUrlOnShare ? [] : [isAbsolute2(basePath) ? basePath : resolve4(options.projectDir, projectRelative)],
2739
+ isAbsolute2(basePath) ? basePath : resolve4(options.projectDir, projectRelative),
2567
2740
  resolve4(options.downloadDir, normalizedBase)
2568
2741
  ];
2569
- const allowed = (candidate) => !escapesAssetRoot(candidate, options.assetRoot) && outsideAssetRefusal(options.projectDir, candidate) !== "blocklisted" || !escapesAssetRoot(candidate, options.downloadDir);
2570
- return candidates.find((candidate) => existsSync5(candidate) && allowed(candidate)) ?? null;
2742
+ const allowed = (candidate) => !namesAnotherNetworkRoot(options.projectDir, candidate) && (!escapesAssetRoot(candidate, options.assetRoot) && outsideAssetRefusal(options.projectDir, candidate) !== "blocklisted" || !escapesAssetRoot(candidate, options.downloadDir));
2743
+ return candidates.find((candidate) => allowed(candidate) && existsSync5(candidate)) ?? null;
2571
2744
  }
2572
2745
  function isUsableFile(path) {
2573
2746
  try {
@@ -3429,20 +3602,13 @@ function assertSubCompositionsUsable(html, projectDir, assetRoot, visited = /* @
3429
3602
  throw new EmptyCompositionError(problems);
3430
3603
  }
3431
3604
  }
3432
- var INLINE_SCRIPT_PATTERN = /<script\b([^>]*)>([\s\S]*?)<\/script>/gi;
3433
3605
  var COMPILER_MOUNT_BLOCK_START = "/* __HF_COMPILER_MOUNT_START__ */";
3434
3606
  var COMPILER_MOUNT_BLOCK_END = "/* __HF_COMPILER_MOUNT_END__ */";
3435
3607
  function stripJsComments(source) {
3436
- return source.replace(/\/\/.*$/gm, "").replace(/\/\*[\s\S]*?\*\//g, "");
3608
+ return removeDelimitedRuns(source.replace(/\/\/.*$/gm, ""), "/*", "*/");
3437
3609
  }
3438
3610
  function stripCompilerMountBootstrap(source) {
3439
- return source.replace(
3440
- new RegExp(
3441
- `${COMPILER_MOUNT_BLOCK_START.replace(/[.*+?^${}()|[\]\\]/g, "\\$&")}[\\s\\S]*?${COMPILER_MOUNT_BLOCK_END.replace(/[.*+?^${}()|[\]\\]/g, "\\$&")}`,
3442
- "g"
3443
- ),
3444
- ""
3445
- );
3611
+ return removeDelimitedRuns(source, COMPILER_MOUNT_BLOCK_START, COMPILER_MOUNT_BLOCK_END);
3446
3612
  }
3447
3613
  function runtimeRoot(document2) {
3448
3614
  return document2.querySelector('[data-composition-id][data-root="true"]') ?? document2.querySelector("[data-composition-id]");
@@ -3467,12 +3633,9 @@ function detectRenderModeHints(html, pageMotionBlur) {
3467
3633
  message: "Detected <iframe> in the composition DOM. Nested iframe animation is routed through screenshot capture mode for compatibility."
3468
3634
  });
3469
3635
  }
3470
- let scriptMatch;
3471
- const scriptPattern = new RegExp(INLINE_SCRIPT_PATTERN.source, INLINE_SCRIPT_PATTERN.flags);
3472
- while ((scriptMatch = scriptPattern.exec(html)) !== null) {
3473
- const attrs = scriptMatch[1] || "";
3636
+ for (const { attrs, body } of inlineScriptBlocks(html)) {
3474
3637
  if (/\bsrc\s*=/i.test(attrs)) continue;
3475
- const content = stripJsComments(stripCompilerMountBootstrap(scriptMatch[2] || ""));
3638
+ const content = stripJsComments(stripCompilerMountBootstrap(body));
3476
3639
  if (!/requestAnimationFrame\s*\(/.test(content)) continue;
3477
3640
  reasons.push({
3478
3641
  code: "requestAnimationFrame",
@@ -3524,12 +3687,9 @@ function detectAncestorBackgroundImage(html) {
3524
3687
  }
3525
3688
  var SHADER_TRANSITION_USAGE_PATTERN = /\b(?:(?:window|globalThis)\s*\.\s*)?HyperShader\s*\.\s*init\s*\(|\b__hf\s*\.\s*transitions\s*=/;
3526
3689
  function detectShaderTransitionUsage(html) {
3527
- let scriptMatch;
3528
- const scriptPattern = new RegExp(INLINE_SCRIPT_PATTERN.source, INLINE_SCRIPT_PATTERN.flags);
3529
- while ((scriptMatch = scriptPattern.exec(html)) !== null) {
3530
- const attrs = scriptMatch[1] || "";
3690
+ for (const { attrs, body } of inlineScriptBlocks(html)) {
3531
3691
  if (/\bsrc\s*=/i.test(attrs)) continue;
3532
- const content = stripJsComments(stripCompilerMountBootstrap(scriptMatch[2] || ""));
3692
+ const content = stripJsComments(stripCompilerMountBootstrap(body));
3533
3693
  if (SHADER_TRANSITION_USAGE_PATTERN.test(content)) return true;
3534
3694
  }
3535
3695
  return false;
@@ -3685,9 +3845,9 @@ async function compileHtmlFile(html, baseDir, downloadDir, log, urlByAbsentLocal
3685
3845
  if (clampList.length > 0) {
3686
3846
  compiledHtml = clampDurations(compiledHtml, clampList);
3687
3847
  }
3688
- compiledHtml = compiledHtml.replace(/(<video\b[^>]*)\s+crossorigin(?:=["'][^"']*["'])?/gi, "$1");
3689
- compiledHtml = compiledHtml.replace(/(<img\b[^>]*)\s+crossorigin(?:=["'][^"']*["'])?/gi, "$1");
3690
- compiledHtml = compiledHtml.replace(/(<audio\b[^>]*)\s+crossorigin(?:=["'][^"']*["'])?/gi, "$1");
3848
+ compiledHtml = stripCrossoriginAttr(compiledHtml, "video");
3849
+ compiledHtml = stripCrossoriginAttr(compiledHtml, "img");
3850
+ compiledHtml = stripCrossoriginAttr(compiledHtml, "audio");
3691
3851
  return { html: compiledHtml, unresolvedCompositions };
3692
3852
  }
3693
3853
  async function parseSubCompositions(html, projectDir, downloadDir, visited = /* @__PURE__ */ new Set(), urlByAbsentLocalPath, probes, assetRoot) {
@@ -4113,7 +4273,7 @@ ${safeText}
4113
4273
  function collectExternalAssets(html, projectDir, log = defaultLogger, file = "index.html") {
4114
4274
  const absProjectDir = resolve6(projectDir);
4115
4275
  const externalAssets = /* @__PURE__ */ new Map();
4116
- const leftOut2 = /* @__PURE__ */ new Set();
4276
+ const leftOut = /* @__PURE__ */ new Set();
4117
4277
  function processPath(rawPath) {
4118
4278
  const trimmed = rawPath.trim();
4119
4279
  if (isNonRelativeUrl(trimmed)) return null;
@@ -4121,11 +4281,12 @@ function collectExternalAssets(html, projectDir, log = defaultLogger, file = "in
4121
4281
  if (isPathInside(absPath, absProjectDir)) {
4122
4282
  return null;
4123
4283
  }
4124
- if (!existsSync7(absPath)) return null;
4125
- const refusal = outsideAssetRefusal(absProjectDir, absPath);
4284
+ const onShare = namesAnotherNetworkRoot2(absProjectDir, absPath);
4285
+ if (!onShare && !existsSync7(absPath)) return null;
4286
+ const refusal = onShare ? "network_share" : outsideAssetRefusal(absProjectDir, absPath);
4126
4287
  if (refusal) {
4127
- if (!leftOut2.has(trimmed)) log.warn(`[Compiler] ${leftOutOfRender(file, trimmed, refusal)}`);
4128
- leftOut2.add(trimmed);
4288
+ if (!leftOut.has(trimmed)) log.warn(`[Compiler] ${leftOutOfRender(file, trimmed, refusal)}`);
4289
+ leftOut.add(trimmed);
4129
4290
  return null;
4130
4291
  }
4131
4292
  const safeKey = toExternalAssetKey(absPath);
@@ -4172,9 +4333,6 @@ function collectExternalAssets(html, projectDir, log = defaultLogger, file = "in
4172
4333
  };
4173
4334
  }
4174
4335
  var REMOTE_MEDIA_SUBDIR = "_remote_media";
4175
- var REMOTE_MEDIA_TAG_RE = /<(?:video|audio)\b[^>]*?\bsrc\s*=\s*["'](https?:\/\/[^"']+)["'][^>]*>/gi;
4176
- var REMOTE_SOURCE_TAG_RE = /<source\b[^>]*?\bsrc\s*=\s*["'](https?:\/\/[^"']+)["'][^>]*>/gi;
4177
- var REMOTE_IMG_TAG_RE = /<img\b[^>]*?(?<![\w-])src\s*=\s*["'](https?:\/\/[^"']+)["'][^>]*>/gi;
4178
4336
  async function downloadAndRewriteUrls(urlSet, html, remoteDir, warnLabel, logLabel, extraRewrite) {
4179
4337
  if (urlSet.size === 0) return { html, remoteMediaAssets: /* @__PURE__ */ new Map() };
4180
4338
  if (!existsSync7(remoteDir)) mkdirSync4(remoteDir, { recursive: true });
@@ -4213,14 +4371,7 @@ async function downloadAndRewriteUrls(urlSet, html, remoteDir, warnLabel, logLab
4213
4371
  return { html: result, remoteMediaAssets };
4214
4372
  }
4215
4373
  async function localizeRemoteMediaSources(html, downloadDir) {
4216
- const urlSet = /* @__PURE__ */ new Set();
4217
- for (const tagRe of [REMOTE_MEDIA_TAG_RE, REMOTE_SOURCE_TAG_RE]) {
4218
- const re = new RegExp(tagRe.source, tagRe.flags);
4219
- let m;
4220
- while ((m = re.exec(html)) !== null) {
4221
- if (m[1]) urlSet.add(m[1]);
4222
- }
4223
- }
4374
+ const urlSet = /* @__PURE__ */ new Set([...remoteSrcUrls(html, "media"), ...remoteSrcUrls(html, "source")]);
4224
4375
  const localized = await downloadAndRewriteUrls(
4225
4376
  urlSet,
4226
4377
  html,
@@ -4243,12 +4394,7 @@ function dropBindingOnLocalizedMedia(html) {
4243
4394
  return changed ? document2.toString() : html;
4244
4395
  }
4245
4396
  async function localizeRemoteImageSources(html, downloadDir) {
4246
- const urlSet = /* @__PURE__ */ new Set();
4247
- const re = new RegExp(REMOTE_IMG_TAG_RE.source, REMOTE_IMG_TAG_RE.flags);
4248
- let m;
4249
- while ((m = re.exec(html)) !== null) {
4250
- if (m[1]) urlSet.add(m[1]);
4251
- }
4397
+ const urlSet = new Set(remoteSrcUrls(html, "img"));
4252
4398
  return downloadAndRewriteUrls(
4253
4399
  urlSet,
4254
4400
  html,
@@ -4509,16 +4655,13 @@ function rewriteUnresolvableGsapToCdn(html, projectDir, compSrcPath) {
4509
4655
  const file = resolve6(projectDir, path);
4510
4656
  return !namesAnotherNetworkRoot2(projectDir, file) && existsSync7(file);
4511
4657
  };
4512
- return html.replace(
4513
- /(<script\b[^>]*\bsrc=["'])([^"']*gsap[^"']*\/dist\/([^"']+))(["'][^>]*>)/gi,
4514
- (full, prefix, src, file, suffix) => {
4515
- if (/^https?:\/\//i.test(src)) return full;
4516
- if (exists(compSrcPath ? rewriteAssetPath(compSrcPath, src, exists) : src)) return full;
4517
- gsapDist ??= renderGsapDist();
4518
- defaultLogger.debug(`[Compiler] Rewriting missing gsap script: ${src} \u2192 ${gsapDist}${file}`);
4519
- return `${prefix}${gsapDist}${file}${suffix}`;
4520
- }
4521
- );
4658
+ return replaceGsapDistScripts(html, (full, prefix, src, file, suffix) => {
4659
+ if (/^https?:\/\//i.test(src)) return full;
4660
+ if (exists(compSrcPath ? rewriteAssetPath(compSrcPath, src, exists) : src)) return full;
4661
+ gsapDist ??= renderGsapDist();
4662
+ defaultLogger.debug(`[Compiler] Rewriting missing gsap script: ${src} \u2192 ${gsapDist}${file}`);
4663
+ return `${prefix}${gsapDist}${file}${suffix}`;
4664
+ });
4522
4665
  }
4523
4666
  function rebaseDirectEntryAssetPaths(html, projectDir, htmlPath) {
4524
4667
  if (!isPathInside(htmlPath, projectDir)) return html;
@@ -4605,10 +4748,7 @@ async function compileForRender(projectDir, htmlPath, downloadDir, options = {})
4605
4748
  options.variables ?? {},
4606
4749
  assetRoot
4607
4750
  );
4608
- const sanitizedHtml = inlinedHtml.replace(
4609
- /(<(?:video|audio)\b[^>]*?)\s+preload\s*=\s*["']none["']/gi,
4610
- "$1"
4611
- );
4751
+ const sanitizedHtml = stripPreloadNone(inlinedHtml);
4612
4752
  const renderModeHints = detectRenderModeHints(sanitizedHtml, options.pageMotionBlur);
4613
4753
  const hasShaderTransitions = detectShaderTransitionUsage(sanitizedHtml);
4614
4754
  const usesThreeDTransforms = detectThreeDTransformUsage(sanitizedHtml);
@@ -13444,40 +13584,56 @@ function validateIntDimension(field, value) {
13444
13584
  import { closeSync as closeSync5, openSync as openSync5, readdirSync as readdirSync10, readSync as readSync4, realpathSync as realpathSync2, statSync as statSync10 } from "node:fs";
13445
13585
  import { createHash as createHash9 } from "node:crypto";
13446
13586
  import { join as join34 } from "node:path";
13587
+ import { isPrivateFileUnder as isPrivateFileUnder3, isStudioPrivatePath as isStudioPrivatePath3 } from "@hyperframes/core/safe-path";
13447
13588
  var SITE_ID_SCHEME = "site-v2\0";
13448
13589
  var READ_CHUNK_BYTES = 256 * 1024;
13449
- var ENV_FILE = /^\.env([._-].*|rc)?$/i;
13450
- var leftOut = (rel, name) => rel === "" && PLAN_PROJECT_DIR_SKIP_SEGMENTS.has(name) || ENV_FILE.test(name);
13451
- function listSiteFiles(projectDir) {
13590
+ var isPrivateSitePath = (relPath) => isStudioPrivatePath3(relPath);
13591
+ function statEntry(full, relPath) {
13592
+ try {
13593
+ return statSync10(full);
13594
+ } catch (err) {
13595
+ throw new Error(`[listSiteFiles] cannot read ${relPath} (dangling symlink?)`, { cause: err });
13596
+ }
13597
+ }
13598
+ function listSiteFiles(projectDir, onPrivate) {
13452
13599
  const files = [];
13453
13600
  const ancestors = /* @__PURE__ */ new Set([realpathSync2(projectDir)]);
13601
+ function visit(full, relPath) {
13602
+ if (isPrivateFileUnder3(projectDir, full, isStudioPrivatePath3)) return void onPrivate?.(relPath);
13603
+ const stat = statEntry(full, relPath);
13604
+ if (stat.isFile()) return void files.push(relPath);
13605
+ if (!stat.isDirectory()) return;
13606
+ const real = realpathSync2(full);
13607
+ if (ancestors.has(real)) return;
13608
+ ancestors.add(real);
13609
+ walk(full, relPath);
13610
+ ancestors.delete(real);
13611
+ }
13454
13612
  function walk(dir, rel) {
13455
13613
  for (const name of readdirSync10(dir).sort()) {
13456
- if (leftOut(rel, name)) continue;
13457
- const full = join34(dir, name);
13458
- const relPath = rel === "" ? name : `${rel}/${name}`;
13459
- let stat;
13460
- try {
13461
- stat = statSync10(full);
13462
- } catch (err) {
13463
- throw new Error(`[listSiteFiles] cannot read ${relPath} (dangling symlink?)`, {
13464
- cause: err
13465
- });
13466
- }
13467
- if (stat.isFile()) {
13468
- files.push(relPath);
13469
- } else if (stat.isDirectory()) {
13470
- const real = realpathSync2(full);
13471
- if (ancestors.has(real)) continue;
13472
- ancestors.add(real);
13473
- walk(full, relPath);
13474
- ancestors.delete(real);
13475
- }
13614
+ if (rel === "" && PLAN_PROJECT_DIR_SKIP_SEGMENTS.has(name)) continue;
13615
+ visit(join34(dir, name), rel === "" ? name : `${rel}/${name}`);
13476
13616
  }
13477
13617
  }
13478
13618
  walk(projectDir, "");
13479
13619
  return files;
13480
13620
  }
13621
+ var printablePath = (path) => [...path].map((ch) => {
13622
+ const code = ch.charCodeAt(0);
13623
+ const control = code < 32 && code !== 9 || code >= 127 && code <= 159;
13624
+ return control ? `\\x${code.toString(16).padStart(2, "0")}` : ch;
13625
+ }).join("");
13626
+ function listSiteFilesForUpload(projectDir, onNotice) {
13627
+ const leftOut = [];
13628
+ const files = listSiteFiles(projectDir, (path) => leftOut.push(path));
13629
+ if (leftOut.length > 0) {
13630
+ const more = leftOut.length > 5 ? ` and ${leftOut.length - 5} more` : "";
13631
+ onNotice?.(
13632
+ `[deploySite] left out private files no composition loads (env, Git, credentials, tool state): ${leftOut.slice(0, 5).map(printablePath).join(", ")}${more}`
13633
+ );
13634
+ }
13635
+ return files;
13636
+ }
13481
13637
  function hashProjectDir(projectDir, files = listSiteFiles(projectDir)) {
13482
13638
  const hash = createHash9("sha256").update(SITE_ID_SCHEME);
13483
13639
  const chunk = Buffer.allocUnsafe(READ_CHUNK_BYTES);
@@ -13589,8 +13745,10 @@ export {
13589
13745
  hashProjectDir,
13590
13746
  isPlanAudioArtifactPath,
13591
13747
  isPlanV2DeferredSourceArtifact,
13748
+ isPrivateSitePath,
13592
13749
  listPlanV2ArtifactsForTarget,
13593
13750
  listSiteFiles,
13751
+ listSiteFilesForUpload,
13594
13752
  materializePlanV2Target,
13595
13753
  measurePlanDirBytes,
13596
13754
  muxChunkWithAudio,
@@ -1,7 +1,7 @@
1
1
  {
2
2
  "version": "0.1.0",
3
3
  "buildId": "dev",
4
- "sha256": "e9989f5a4b18bb0ae30ba9492234771124c21fc43876f62959ee41098d128b14",
4
+ "sha256": "b41b128e65eba9f85332f59b3a6597b8ef52f4375bed38cbd8f6d0fddc1a0bc1",
5
5
  "artifacts": {
6
6
  "iife": "hyperframe.runtime.iife.js",
7
7
  "esm": "hyperframe.runtime.mjs"