hyperframes 0.6.18 → 0.6.19

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.
Files changed (2) hide show
  1. package/dist/cli.js +1665 -464
  2. package/package.json +2 -1
package/dist/cli.js CHANGED
@@ -54,7 +54,7 @@ var VERSION;
54
54
  var init_version = __esm({
55
55
  "src/version.ts"() {
56
56
  "use strict";
57
- VERSION = true ? "0.6.18" : "0.0.0-dev";
57
+ VERSION = true ? "0.6.19" : "0.0.0-dev";
58
58
  }
59
59
  });
60
60
 
@@ -11438,7 +11438,7 @@ import { get as httpsGet } from "https";
11438
11438
  import { pipeline } from "stream/promises";
11439
11439
  function downloadFile(url, dest) {
11440
11440
  const tmp = `${dest}.tmp`;
11441
- return new Promise((resolve43, reject) => {
11441
+ return new Promise((resolve45, reject) => {
11442
11442
  const follow = (u) => {
11443
11443
  httpsGet(u, (res) => {
11444
11444
  if (res.statusCode === 301 || res.statusCode === 302) {
@@ -11455,7 +11455,7 @@ function downloadFile(url, dest) {
11455
11455
  const file = createWriteStream(tmp);
11456
11456
  pipeline(res, file).then(() => {
11457
11457
  renameSync(tmp, dest);
11458
- resolve43();
11458
+ resolve45();
11459
11459
  }).catch((err) => {
11460
11460
  try {
11461
11461
  unlinkSync(tmp);
@@ -12180,7 +12180,7 @@ function hasNpx() {
12180
12180
  }
12181
12181
  }
12182
12182
  function runSkillsAdd(repo) {
12183
- return new Promise((resolve43, reject) => {
12183
+ return new Promise((resolve45, reject) => {
12184
12184
  const child = spawn("npx", ["skills", "add", repo, "--all"], {
12185
12185
  stdio: "inherit",
12186
12186
  timeout: 12e4,
@@ -12194,7 +12194,7 @@ function runSkillsAdd(repo) {
12194
12194
  env: { ...process.env, GIT_CLONE_PROTECTION_ACTIVE: "0" }
12195
12195
  });
12196
12196
  child.on("close", (code, signal) => {
12197
- if (code === 0) resolve43();
12197
+ if (code === 0) resolve45();
12198
12198
  else if (signal === "SIGINT" || code === 130) process.exit(0);
12199
12199
  else reject(new Error(`npx skills add exited with code ${code}`));
12200
12200
  });
@@ -13109,7 +13109,7 @@ function computePeaks(floats, count) {
13109
13109
  return peaks.map((p2) => p2 / maxPeak);
13110
13110
  }
13111
13111
  function decodeAudioPeaks(audioPath) {
13112
- return new Promise((resolve43, reject) => {
13112
+ return new Promise((resolve45, reject) => {
13113
13113
  const proc = spawn3(
13114
13114
  "ffmpeg",
13115
13115
  [
@@ -13142,7 +13142,7 @@ function decodeAudioPeaks(audioPath) {
13142
13142
  return;
13143
13143
  }
13144
13144
  const ab = buf.buffer.slice(buf.byteOffset, buf.byteOffset + numSamples * 4);
13145
- resolve43(computePeaks(new Float32Array(ab), PEAK_COUNT));
13145
+ resolve45(computePeaks(new Float32Array(ab), PEAK_COUNT));
13146
13146
  });
13147
13147
  proc.on("error", reject);
13148
13148
  });
@@ -16617,10 +16617,10 @@ function compareDocumentPosition(nodeA, nodeB) {
16617
16617
  function uniqueSort(nodes) {
16618
16618
  nodes = nodes.filter((node, i2, arr) => !arr.includes(node, i2 + 1));
16619
16619
  nodes.sort((a, b2) => {
16620
- const relative10 = compareDocumentPosition(a, b2);
16621
- if (relative10 & DocumentPosition.PRECEDING) {
16620
+ const relative11 = compareDocumentPosition(a, b2);
16621
+ if (relative11 & DocumentPosition.PRECEDING) {
16622
16622
  return -1;
16623
- } else if (relative10 & DocumentPosition.FOLLOWING) {
16623
+ } else if (relative11 & DocumentPosition.FOLLOWING) {
16624
16624
  return 1;
16625
16625
  }
16626
16626
  return 0;
@@ -17082,8 +17082,8 @@ var init_custom_element_registry = __esm({
17082
17082
  } : (element) => element.localName === localName;
17083
17083
  registry.set(localName, { Class, check });
17084
17084
  if (waiting.has(localName)) {
17085
- for (const resolve43 of waiting.get(localName))
17086
- resolve43(Class);
17085
+ for (const resolve45 of waiting.get(localName))
17086
+ resolve45(Class);
17087
17087
  waiting.delete(localName);
17088
17088
  }
17089
17089
  ownerDocument.querySelectorAll(
@@ -17123,13 +17123,13 @@ var init_custom_element_registry = __esm({
17123
17123
  */
17124
17124
  whenDefined(localName) {
17125
17125
  const { registry, waiting } = this;
17126
- return new Promise((resolve43) => {
17126
+ return new Promise((resolve45) => {
17127
17127
  if (registry.has(localName))
17128
- resolve43(registry.get(localName).Class);
17128
+ resolve45(registry.get(localName).Class);
17129
17129
  else {
17130
17130
  if (!waiting.has(localName))
17131
17131
  waiting.set(localName, []);
17132
- waiting.get(localName).push(resolve43);
17132
+ waiting.get(localName).push(resolve45);
17133
17133
  }
17134
17134
  });
17135
17135
  }
@@ -29355,7 +29355,7 @@ var init_screenshotService = __esm({
29355
29355
  import { existsSync as existsSync19, mkdirSync as mkdirSync10, writeFileSync as writeFileSync11 } from "fs";
29356
29356
  import { join as join23 } from "path";
29357
29357
  async function driveWarmupTicks(options, state) {
29358
- const sleep2 = options.sleep ?? realSleep;
29358
+ const sleep3 = options.sleep ?? realSleep;
29359
29359
  while (true) {
29360
29360
  if (options.lockWarmupTicks) {
29361
29361
  if (state.ticks >= LOCKED_WARMUP_TICKS) return;
@@ -29367,7 +29367,7 @@ async function driveWarmupTicks(options, state) {
29367
29367
  state.ticks += 1;
29368
29368
  } catch {
29369
29369
  }
29370
- await sleep2(options.intervalMs);
29370
+ await sleep3(options.intervalMs);
29371
29371
  }
29372
29372
  }
29373
29373
  async function waitForCloseWithTimeout(promise) {
@@ -29378,10 +29378,10 @@ async function waitForCloseWithTimeout(promise) {
29378
29378
  () => void 0,
29379
29379
  () => void 0
29380
29380
  ),
29381
- new Promise((resolve43) => {
29381
+ new Promise((resolve45) => {
29382
29382
  timer = setTimeout(() => {
29383
29383
  timedOut = true;
29384
- resolve43();
29384
+ resolve45();
29385
29385
  }, CAPTURE_SESSION_CLOSE_TIMEOUT_MS);
29386
29386
  })
29387
29387
  ]);
@@ -29479,7 +29479,7 @@ async function pollPageExpression(page, expression, timeoutMs, intervalMs = 100)
29479
29479
  while (Date.now() < deadline) {
29480
29480
  const ready = Boolean(await page.evaluate(expression));
29481
29481
  if (ready) return true;
29482
- await new Promise((resolve43) => setTimeout(resolve43, intervalMs));
29482
+ await new Promise((resolve45) => setTimeout(resolve45, intervalMs));
29483
29483
  }
29484
29484
  return Boolean(await page.evaluate(expression));
29485
29485
  }
@@ -29496,7 +29496,7 @@ async function pollVideosReady(page, skipIds, timeoutMs, intervalMs = 100) {
29496
29496
  const deadline = Date.now() + timeoutMs;
29497
29497
  while (Date.now() < deadline) {
29498
29498
  if (await check()) return true;
29499
- await new Promise((resolve43) => setTimeout(resolve43, intervalMs));
29499
+ await new Promise((resolve45) => setTimeout(resolve45, intervalMs));
29500
29500
  }
29501
29501
  return check();
29502
29502
  }
@@ -29530,7 +29530,7 @@ async function waitForOptionalTailwindReady(page, timeoutMs) {
29530
29530
  page.evaluate(
29531
29531
  `Promise.resolve(window.__tailwindReady).then(() => true, () => false)`
29532
29532
  ),
29533
- new Promise((resolve43) => setTimeout(() => resolve43(false), timeoutMs))
29533
+ new Promise((resolve45) => setTimeout(() => resolve45(false), timeoutMs))
29534
29534
  ]);
29535
29535
  if (!ready) {
29536
29536
  throw new Error(
@@ -29883,14 +29883,14 @@ var init_frameCapture = __esm({
29883
29883
  BROWSER_CONSOLE_BUFFER_SIZE = 200;
29884
29884
  CAPTURE_SESSION_CLOSE_TIMEOUT_MS = 5e3;
29885
29885
  LOCKED_WARMUP_TICKS = 60;
29886
- realSleep = (ms) => new Promise((resolve43) => setTimeout(resolve43, ms));
29886
+ realSleep = (ms) => new Promise((resolve45) => setTimeout(resolve45, ms));
29887
29887
  }
29888
29888
  });
29889
29889
 
29890
29890
  // ../engine/src/utils/gpuEncoder.ts
29891
29891
  import { spawn as spawn4 } from "child_process";
29892
29892
  async function detectGpuEncoder() {
29893
- return new Promise((resolve43) => {
29893
+ return new Promise((resolve45) => {
29894
29894
  const ffmpeg = spawn4("ffmpeg", ["-encoders"], {
29895
29895
  stdio: ["pipe", "pipe", "pipe"]
29896
29896
  });
@@ -29899,13 +29899,13 @@ async function detectGpuEncoder() {
29899
29899
  stdout2 += data.toString();
29900
29900
  });
29901
29901
  ffmpeg.on("close", () => {
29902
- if (stdout2.includes("h264_nvenc")) resolve43("nvenc");
29903
- else if (stdout2.includes("h264_videotoolbox")) resolve43("videotoolbox");
29904
- else if (stdout2.includes("h264_vaapi")) resolve43("vaapi");
29905
- else if (stdout2.includes("h264_qsv")) resolve43("qsv");
29906
- else resolve43(null);
29902
+ if (stdout2.includes("h264_nvenc")) resolve45("nvenc");
29903
+ else if (stdout2.includes("h264_videotoolbox")) resolve45("videotoolbox");
29904
+ else if (stdout2.includes("h264_vaapi")) resolve45("vaapi");
29905
+ else if (stdout2.includes("h264_qsv")) resolve45("qsv");
29906
+ else resolve45(null);
29907
29907
  });
29908
- ffmpeg.on("error", () => resolve43(null));
29908
+ ffmpeg.on("error", () => resolve45(null));
29909
29909
  });
29910
29910
  }
29911
29911
  async function getCachedGpuEncoder() {
@@ -30026,7 +30026,7 @@ async function runFfmpeg(args, opts) {
30026
30026
  const signal = opts?.signal;
30027
30027
  const timeout = opts?.timeout ?? DEFAULT_TIMEOUT;
30028
30028
  const onStderr = opts?.onStderr;
30029
- return new Promise((resolve43) => {
30029
+ return new Promise((resolve45) => {
30030
30030
  const ffmpeg = spawn5("ffmpeg", args);
30031
30031
  let stderr = "";
30032
30032
  const onAbort = () => {
@@ -30052,7 +30052,7 @@ async function runFfmpeg(args, opts) {
30052
30052
  ffmpeg.on("close", (code) => {
30053
30053
  clearTimeout(timer);
30054
30054
  if (signal) signal.removeEventListener("abort", onAbort);
30055
- resolve43({
30055
+ resolve45({
30056
30056
  success: !signal?.aborted && code === 0,
30057
30057
  exitCode: code,
30058
30058
  stderr,
@@ -30062,7 +30062,7 @@ async function runFfmpeg(args, opts) {
30062
30062
  ffmpeg.on("error", (err) => {
30063
30063
  clearTimeout(timer);
30064
30064
  if (signal) signal.removeEventListener("abort", onAbort);
30065
- resolve43({
30065
+ resolve45({
30066
30066
  success: false,
30067
30067
  exitCode: null,
30068
30068
  stderr: err.message,
@@ -30293,7 +30293,7 @@ async function encodeFramesFromDir(framesDir, framePattern, outputPath, options,
30293
30293
  const inputPath = join24(framesDir, framePattern);
30294
30294
  const inputArgs = ["-framerate", fpsToFfmpegArg(options.fps), "-i", inputPath];
30295
30295
  const args = buildEncoderArgs(options, inputArgs, outputPath, gpuEncoder);
30296
- return new Promise((resolve43) => {
30296
+ return new Promise((resolve45) => {
30297
30297
  const ffmpeg = spawn6("ffmpeg", args);
30298
30298
  let stderr = "";
30299
30299
  const onAbort = () => {
@@ -30318,7 +30318,7 @@ async function encodeFramesFromDir(framesDir, framePattern, outputPath, options,
30318
30318
  if (signal) signal.removeEventListener("abort", onAbort);
30319
30319
  const durationMs = Date.now() - startTime;
30320
30320
  if (signal?.aborted) {
30321
- resolve43({
30321
+ resolve45({
30322
30322
  success: false,
30323
30323
  outputPath,
30324
30324
  durationMs,
@@ -30329,7 +30329,7 @@ async function encodeFramesFromDir(framesDir, framePattern, outputPath, options,
30329
30329
  return;
30330
30330
  }
30331
30331
  if (code !== 0) {
30332
- resolve43({
30332
+ resolve45({
30333
30333
  success: false,
30334
30334
  outputPath,
30335
30335
  durationMs,
@@ -30340,12 +30340,12 @@ async function encodeFramesFromDir(framesDir, framePattern, outputPath, options,
30340
30340
  return;
30341
30341
  }
30342
30342
  const fileSize = existsSync20(outputPath) ? statSync6(outputPath).size : 0;
30343
- resolve43({ success: true, outputPath, durationMs, framesEncoded: frameCount, fileSize });
30343
+ resolve45({ success: true, outputPath, durationMs, framesEncoded: frameCount, fileSize });
30344
30344
  });
30345
30345
  ffmpeg.on("error", (err) => {
30346
30346
  clearTimeout(timer);
30347
30347
  if (signal) signal.removeEventListener("abort", onAbort);
30348
- resolve43({
30348
+ resolve45({
30349
30349
  success: false,
30350
30350
  outputPath,
30351
30351
  durationMs: Date.now() - startTime,
@@ -30403,18 +30403,18 @@ async function encodeFramesChunkedConcat(framesDir, framePattern, outputPath, op
30403
30403
  let gpuEncoder = null;
30404
30404
  if (options.useGpu) gpuEncoder = await getCachedGpuEncoder();
30405
30405
  const args = buildEncoderArgs(options, inputArgs, chunkPath, gpuEncoder);
30406
- const chunkResult = await new Promise((resolve43) => {
30406
+ const chunkResult = await new Promise((resolve45) => {
30407
30407
  const ffmpeg = spawn6("ffmpeg", args);
30408
30408
  let stderr = "";
30409
30409
  ffmpeg.stderr.on("data", (d2) => {
30410
30410
  stderr += d2.toString();
30411
30411
  });
30412
30412
  ffmpeg.on("close", (code) => {
30413
- if (code === 0) resolve43({ success: true });
30414
- else resolve43({ success: false, error: `Chunk ${i2} encode failed: ${stderr.slice(-400)}` });
30413
+ if (code === 0) resolve45({ success: true });
30414
+ else resolve45({ success: false, error: `Chunk ${i2} encode failed: ${stderr.slice(-400)}` });
30415
30415
  });
30416
30416
  ffmpeg.on("error", (err) => {
30417
- resolve43({ success: false, error: `Chunk ${i2} encode error: ${err.message}` });
30417
+ resolve45({ success: false, error: `Chunk ${i2} encode error: ${err.message}` });
30418
30418
  });
30419
30419
  });
30420
30420
  if (!chunkResult.success) {
@@ -30444,18 +30444,18 @@ async function encodeFramesChunkedConcat(framesDir, framePattern, outputPath, op
30444
30444
  "-y",
30445
30445
  outputPath
30446
30446
  ];
30447
- const concatResult = await new Promise((resolve43) => {
30447
+ const concatResult = await new Promise((resolve45) => {
30448
30448
  const ffmpeg = spawn6("ffmpeg", concatArgs);
30449
30449
  let stderr = "";
30450
30450
  ffmpeg.stderr.on("data", (d2) => {
30451
30451
  stderr += d2.toString();
30452
30452
  });
30453
30453
  ffmpeg.on("close", (code) => {
30454
- if (code === 0) resolve43({ success: true });
30455
- else resolve43({ success: false, error: `Chunk concat failed: ${stderr.slice(-400)}` });
30454
+ if (code === 0) resolve45({ success: true });
30455
+ else resolve45({ success: false, error: `Chunk concat failed: ${stderr.slice(-400)}` });
30456
30456
  });
30457
30457
  ffmpeg.on("error", (err) => {
30458
- resolve43({ success: false, error: `Chunk concat error: ${err.message}` });
30458
+ resolve45({ success: false, error: `Chunk concat error: ${err.message}` });
30459
30459
  });
30460
30460
  });
30461
30461
  if (!concatResult.success) {
@@ -30557,37 +30557,37 @@ import { dirname as dirname8 } from "path";
30557
30557
  function createFrameReorderBuffer(startFrame, endFrame) {
30558
30558
  let cursor = startFrame;
30559
30559
  const pending = /* @__PURE__ */ new Map();
30560
- const enqueueAt = (frame, resolve43) => {
30560
+ const enqueueAt = (frame, resolve45) => {
30561
30561
  const list = pending.get(frame);
30562
30562
  if (list === void 0) {
30563
- pending.set(frame, [resolve43]);
30563
+ pending.set(frame, [resolve45]);
30564
30564
  } else {
30565
- list.push(resolve43);
30565
+ list.push(resolve45);
30566
30566
  }
30567
30567
  };
30568
30568
  const flushAt = (frame) => {
30569
30569
  const list = pending.get(frame);
30570
30570
  if (list === void 0) return;
30571
30571
  pending.delete(frame);
30572
- for (const resolve43 of list) resolve43();
30572
+ for (const resolve45 of list) resolve45();
30573
30573
  };
30574
- const waitForFrame = (frame) => new Promise((resolve43) => {
30574
+ const waitForFrame = (frame) => new Promise((resolve45) => {
30575
30575
  if (frame === cursor) {
30576
- resolve43();
30576
+ resolve45();
30577
30577
  return;
30578
30578
  }
30579
- enqueueAt(frame, resolve43);
30579
+ enqueueAt(frame, resolve45);
30580
30580
  });
30581
30581
  const advanceTo = (frame) => {
30582
30582
  cursor = frame;
30583
30583
  flushAt(frame);
30584
30584
  };
30585
- const waitForAllDone = () => new Promise((resolve43) => {
30585
+ const waitForAllDone = () => new Promise((resolve45) => {
30586
30586
  if (cursor >= endFrame) {
30587
- resolve43();
30587
+ resolve45();
30588
30588
  return;
30589
30589
  }
30590
- enqueueAt(endFrame, resolve43);
30590
+ enqueueAt(endFrame, resolve45);
30591
30591
  });
30592
30592
  return { waitForFrame, advanceTo, waitForAllDone };
30593
30593
  }
@@ -30768,7 +30768,7 @@ async function spawnStreamingEncoder(outputPath, options, signal, config) {
30768
30768
  let stderr = "";
30769
30769
  let exitCode = null;
30770
30770
  let exitPromiseResolve = null;
30771
- const exitPromise = new Promise((resolve43) => exitPromiseResolve = resolve43);
30771
+ const exitPromise = new Promise((resolve45) => exitPromiseResolve = resolve45);
30772
30772
  ffmpeg.stderr?.on("data", (data) => {
30773
30773
  stderr += data.toString();
30774
30774
  });
@@ -30828,8 +30828,8 @@ Process error: ${err.message}`;
30828
30828
  if (signal) signal.removeEventListener("abort", onAbort);
30829
30829
  const stdin = ffmpeg.stdin;
30830
30830
  if (stdin && !stdin.destroyed) {
30831
- await new Promise((resolve43) => {
30832
- stdin.end(() => resolve43());
30831
+ await new Promise((resolve45) => {
30832
+ stdin.end(() => resolve45());
30833
30833
  });
30834
30834
  }
30835
30835
  await exitPromise;
@@ -30873,7 +30873,7 @@ import { spawn as spawn8 } from "child_process";
30873
30873
  import { readFileSync as readFileSync18 } from "fs";
30874
30874
  import { extname as extname5 } from "path";
30875
30875
  function runFfprobe(args) {
30876
- return new Promise((resolve43, reject) => {
30876
+ return new Promise((resolve45, reject) => {
30877
30877
  const proc = spawn8("ffprobe", args);
30878
30878
  let stdout2 = "";
30879
30879
  let stderr = "";
@@ -30887,7 +30887,7 @@ function runFfprobe(args) {
30887
30887
  if (code !== 0) {
30888
30888
  reject(new Error(`[FFmpeg] ffprobe exited with code ${code}: ${stderr}`));
30889
30889
  } else {
30890
- resolve43(stdout2);
30890
+ resolve45(stdout2);
30891
30891
  }
30892
30892
  });
30893
30893
  proc.on("error", (err) => {
@@ -31738,9 +31738,165 @@ var init_staticGuard = __esm({
31738
31738
  }
31739
31739
  });
31740
31740
 
31741
+ // ../core/src/compiler/inlineSubCompositions.ts
31742
+ function defaultBuildScopeSelector(compId) {
31743
+ const escaped = compId.replace(/\\/g, "\\\\").replace(/"/g, '\\"');
31744
+ return `[data-composition-id="${escaped}"]`;
31745
+ }
31746
+ function inlineSubCompositions(document2, hosts, options) {
31747
+ const {
31748
+ resolveHtml,
31749
+ parseHtml: parseHtml2,
31750
+ hostIdentityMap,
31751
+ rewriteInlineStyles = false,
31752
+ flattenInnerRoot,
31753
+ readVariableDefaults,
31754
+ parseHostVariables,
31755
+ buildScopeSelector = defaultBuildScopeSelector,
31756
+ scriptErrorLabel = "[HyperFrames] composition script error:",
31757
+ onMissingComposition
31758
+ } = options;
31759
+ const styles = [];
31760
+ const scripts = [];
31761
+ const externalScriptSrcs = [];
31762
+ const variablesByComp = {};
31763
+ for (const hostEl of hosts) {
31764
+ const src = hostEl.getAttribute("data-composition-src");
31765
+ if (!src) continue;
31766
+ const compHtml = resolveHtml(src);
31767
+ if (compHtml == null) {
31768
+ if (onMissingComposition) {
31769
+ onMissingComposition(src);
31770
+ }
31771
+ continue;
31772
+ }
31773
+ const compDoc = parseHtml2(compHtml);
31774
+ let compId;
31775
+ let runtimeCompId;
31776
+ if (hostIdentityMap) {
31777
+ const identity = hostIdentityMap.get(hostEl);
31778
+ compId = identity?.authoredCompositionId || null;
31779
+ runtimeCompId = identity?.runtimeCompositionId || compId || "";
31780
+ } else {
31781
+ compId = hostEl.getAttribute("data-composition-id") || null;
31782
+ runtimeCompId = compId || "";
31783
+ }
31784
+ const contentRoot = compDoc.querySelector("template");
31785
+ const contentHtml = contentRoot ? contentRoot.innerHTML || "" : compDoc.body?.innerHTML || "";
31786
+ const contentDoc = parseHtml2(contentHtml);
31787
+ const innerRoot = compId ? contentDoc.querySelector(`[data-composition-id="${compId}"]`) : contentDoc.querySelector("[data-composition-id]");
31788
+ const inferredCompId = innerRoot?.getAttribute("data-composition-id")?.trim() || "";
31789
+ const authoredRootId = innerRoot?.getAttribute("id")?.trim() || null;
31790
+ const scopeCompId = compId || inferredCompId;
31791
+ const runtimeScope = runtimeCompId ? buildScopeSelector(runtimeCompId) : "";
31792
+ if (readVariableDefaults && parseHostVariables && runtimeCompId) {
31793
+ const mergedVariables = {
31794
+ ...readVariableDefaults(compDoc.documentElement),
31795
+ ...parseHostVariables(hostEl)
31796
+ };
31797
+ if (Object.keys(mergedVariables).length > 0) {
31798
+ variablesByComp[runtimeCompId] = mergedVariables;
31799
+ }
31800
+ }
31801
+ if (!contentRoot && compDoc.head) {
31802
+ for (const s2 of [...compDoc.head.querySelectorAll("style")]) {
31803
+ const css = rewriteCssAssetUrls(s2.textContent || "", src);
31804
+ styles.push(
31805
+ scopeCompId ? scopeCssToComposition(css, scopeCompId, runtimeScope || void 0, authoredRootId) : css
31806
+ );
31807
+ }
31808
+ for (const s2 of [...compDoc.head.querySelectorAll("script")]) {
31809
+ const externalSrc = (s2.getAttribute("src") || "").trim();
31810
+ if (externalSrc && !externalScriptSrcs.includes(externalSrc)) {
31811
+ externalScriptSrcs.push(externalSrc);
31812
+ }
31813
+ }
31814
+ }
31815
+ for (const s2 of [...contentDoc.querySelectorAll("style")]) {
31816
+ const css = rewriteCssAssetUrls(s2.textContent || "", src);
31817
+ styles.push(
31818
+ scopeCompId ? scopeCssToComposition(css, scopeCompId, runtimeScope || void 0, authoredRootId) : css
31819
+ );
31820
+ s2.remove();
31821
+ }
31822
+ for (const s2 of [...contentDoc.querySelectorAll("script")]) {
31823
+ const externalSrc = (s2.getAttribute("src") || "").trim();
31824
+ if (externalSrc) {
31825
+ if (!externalScriptSrcs.includes(externalSrc)) {
31826
+ externalScriptSrcs.push(externalSrc);
31827
+ }
31828
+ } else {
31829
+ scripts.push(
31830
+ scopeCompId ? wrapScopedCompositionScript(
31831
+ s2.textContent || "",
31832
+ scopeCompId,
31833
+ scriptErrorLabel,
31834
+ runtimeScope || void 0,
31835
+ runtimeCompId || scopeCompId,
31836
+ authoredRootId
31837
+ ) : `(function(){ try { ${s2.textContent || ""} } catch (_err) { console.error(${JSON.stringify(scriptErrorLabel)}, _err); } })();`
31838
+ );
31839
+ }
31840
+ s2.remove();
31841
+ }
31842
+ const assetEls = innerRoot ? innerRoot.querySelectorAll("[src], [href]") : contentDoc.querySelectorAll("[src], [href]");
31843
+ rewriteAssetPaths(
31844
+ assetEls,
31845
+ src,
31846
+ (el, attr) => el.getAttribute(attr),
31847
+ (el, attr, val) => {
31848
+ el.setAttribute(attr, val);
31849
+ }
31850
+ );
31851
+ if (rewriteInlineStyles) {
31852
+ const styledEls = innerRoot ? innerRoot.querySelectorAll("[style]") : contentDoc.querySelectorAll("[style]");
31853
+ rewriteInlineStyleAssetUrls(
31854
+ styledEls,
31855
+ src,
31856
+ (el) => el.getAttribute("style"),
31857
+ (el, val) => {
31858
+ el.setAttribute("style", val);
31859
+ }
31860
+ );
31861
+ }
31862
+ if (innerRoot) {
31863
+ const innerW = innerRoot.getAttribute("data-width");
31864
+ const innerH = innerRoot.getAttribute("data-height");
31865
+ if (innerW && !hostEl.getAttribute("data-width")) hostEl.setAttribute("data-width", innerW);
31866
+ if (innerH && !hostEl.getAttribute("data-height")) {
31867
+ hostEl.setAttribute("data-height", innerH);
31868
+ }
31869
+ }
31870
+ if (innerRoot) {
31871
+ innerRoot.setAttribute("data-composition-file", src);
31872
+ for (const child of [...innerRoot.querySelectorAll("style, script")]) child.remove();
31873
+ if (flattenInnerRoot) {
31874
+ const prepared = flattenInnerRoot(innerRoot);
31875
+ hostEl.innerHTML = prepared.outerHTML || "";
31876
+ } else {
31877
+ hostEl.innerHTML = compId ? innerRoot.innerHTML || "" : innerRoot.outerHTML || "";
31878
+ }
31879
+ } else {
31880
+ for (const child of [...contentDoc.querySelectorAll("style, script")]) child.remove();
31881
+ const bodyHtml = contentDoc.body?.innerHTML || "";
31882
+ hostEl.innerHTML = bodyHtml || contentDoc.documentElement?.outerHTML || "";
31883
+ }
31884
+ hostEl.setAttribute("data-composition-file", src);
31885
+ hostEl.removeAttribute("data-composition-src");
31886
+ }
31887
+ return { styles, scripts, externalScriptSrcs, variablesByComp };
31888
+ }
31889
+ var init_inlineSubCompositions = __esm({
31890
+ "../core/src/compiler/inlineSubCompositions.ts"() {
31891
+ "use strict";
31892
+ init_rewriteSubCompPaths();
31893
+ init_compositionScoping();
31894
+ }
31895
+ });
31896
+
31741
31897
  // ../core/src/compiler/htmlBundler.ts
31742
31898
  import { readFileSync as readFileSync19, existsSync as existsSync23 } from "fs";
31743
- import { join as join26, resolve as resolve14, isAbsolute as isAbsolute3, sep as sep3 } from "path";
31899
+ import { join as join26, resolve as resolve14, relative as relative3, dirname as dirname9, isAbsolute as isAbsolute3, sep as sep3 } from "path";
31744
31900
  import { transformSync } from "esbuild";
31745
31901
  function safePath(projectDir, relativePath) {
31746
31902
  const resolved = resolve14(projectDir, relativePath);
@@ -31794,6 +31950,70 @@ function safeReadFile(filePath) {
31794
31950
  return null;
31795
31951
  }
31796
31952
  }
31953
+ function withCommentsStripped(css, fn) {
31954
+ const comments = [];
31955
+ const stripped = css.replace(CSS_COMMENT_RE, (m2) => {
31956
+ const idx = comments.length;
31957
+ comments.push(m2);
31958
+ return `/*__hf_c${idx}__*/`;
31959
+ });
31960
+ const result = fn(stripped);
31961
+ const restore = (s2) => {
31962
+ let out = s2;
31963
+ for (let i2 = 0; i2 < comments.length; i2++) {
31964
+ out = out.replace(`/*__hf_c${i2}__*/`, comments[i2]);
31965
+ }
31966
+ return out;
31967
+ };
31968
+ return { result, restore };
31969
+ }
31970
+ function rebaseCssUrls(css, cssFileDir, projectDir) {
31971
+ const resolvedRoot = resolve14(projectDir);
31972
+ const resolvedDir = resolve14(cssFileDir);
31973
+ if (resolvedDir === resolvedRoot) return css;
31974
+ return css.replace(REBASE_URL_RE, (full, quote, urlValue) => {
31975
+ if (!urlValue || !isRelativeUrl(urlValue)) return full;
31976
+ const { basePath, suffix } = splitUrlSuffix(urlValue.trim());
31977
+ if (!basePath) return full;
31978
+ const absolutePath = resolve14(resolvedDir, basePath);
31979
+ const rebased = relative3(resolvedRoot, absolutePath).split(sep3).join("/");
31980
+ if (rebased === basePath) return full;
31981
+ return `url(${quote || ""}${rebased}${suffix}${quote || ""})`;
31982
+ });
31983
+ }
31984
+ function inlineCssFile(css, cssFileDir, projectDir, visited = /* @__PURE__ */ new Set()) {
31985
+ const { result: strippedCss, restore: restoreComments } = withCommentsStripped(css, (s2) => s2);
31986
+ const importPlaceholders = [];
31987
+ const withPlaceholders = strippedCss.replace(
31988
+ CSS_IMPORT_RE,
31989
+ (full, _q1, urlPath, _q2, barePath, mediaQuery) => {
31990
+ const importPath = urlPath ?? barePath;
31991
+ if (!importPath || !isRelativeUrl(importPath)) return full;
31992
+ const resolved = resolve14(cssFileDir, importPath);
31993
+ const normalizedBase = resolve14(projectDir) + sep3;
31994
+ if (!resolved.startsWith(normalizedBase)) return full;
31995
+ if (visited.has(resolved)) return "";
31996
+ const content = safeReadFile(resolved);
31997
+ if (content == null) return full;
31998
+ visited.add(resolved);
31999
+ const inlined = inlineCssFile(content, dirname9(resolved), projectDir, visited);
32000
+ const trimmedMedia = (mediaQuery || "").trim();
32001
+ const block = trimmedMedia ? `@media ${trimmedMedia} {
32002
+ ${inlined}
32003
+ }
32004
+ ` : inlined + "\n";
32005
+ const idx = importPlaceholders.length;
32006
+ importPlaceholders.push(block);
32007
+ return `/*__hf_import_${idx}__*/`;
32008
+ }
32009
+ );
32010
+ let rebased = rebaseCssUrls(withPlaceholders, cssFileDir, projectDir);
32011
+ rebased = restoreComments(rebased);
32012
+ for (let i2 = 0; i2 < importPlaceholders.length; i2++) {
32013
+ rebased = rebased.replace(`/*__hf_import_${i2}__*/`, importPlaceholders[i2]);
32014
+ }
32015
+ return rebased;
32016
+ }
31797
32017
  function safeReadFileBuffer(filePath) {
31798
32018
  if (!existsSync23(filePath)) return null;
31799
32019
  try {
@@ -32107,9 +32327,10 @@ async function bundleToSingleHtml(projectDir, options) {
32107
32327
  const href = el.getAttribute("href");
32108
32328
  if (!href || !isRelativeUrl(href)) continue;
32109
32329
  const cssPath = safePath(projectDir, href);
32110
- const css = cssPath ? safeReadFile(cssPath) : null;
32330
+ if (!cssPath) continue;
32331
+ const css = safeReadFile(cssPath);
32111
32332
  if (css == null) continue;
32112
- localCssChunks.push(css);
32333
+ localCssChunks.push(inlineCssFile(css, dirname9(cssPath), projectDir));
32113
32334
  if (!cssAnchorPlaced) {
32114
32335
  const anchor = document2.createElement("style");
32115
32336
  anchor.setAttribute("data-hf-bundled-local-css", "1");
@@ -32160,118 +32381,35 @@ async function bundleToSingleHtml(projectDir, options) {
32160
32381
  document2.body.appendChild(script);
32161
32382
  }
32162
32383
  }
32163
- const compStyleChunks = [];
32164
- const compScriptChunks = [];
32165
- const compExternalScriptSrcs = [];
32166
- const compVariablesByComp = {};
32167
32384
  const trackedCompositionHosts = getBundledTrackedCompositionHosts(document2);
32168
32385
  const hostIdentityByElement = assignBundledRuntimeCompositionIds(trackedCompositionHosts);
32169
32386
  const subCompositionHosts = trackedCompositionHosts.filter(
32170
32387
  (host) => host.hasAttribute("data-composition-src")
32171
32388
  );
32172
- for (const hostEl of subCompositionHosts) {
32173
- const src = hostEl.getAttribute("data-composition-src");
32174
- if (!src || !isRelativeUrl(src)) continue;
32175
- const compPath = safePath(projectDir, src);
32176
- const compHtml = compPath ? safeReadFile(compPath) : null;
32177
- if (compHtml == null) {
32178
- console.warn(`[Bundler] Composition file not found: ${src}`);
32179
- continue;
32180
- }
32181
- const compDoc = parseHTMLContent(compHtml);
32182
- const hostIdentity = hostIdentityByElement.get(hostEl);
32183
- const compId = hostIdentity?.authoredCompositionId || null;
32184
- const runtimeCompId = hostIdentity?.runtimeCompositionId || compId || "";
32185
- const contentRoot = compDoc.querySelector("template");
32186
- const contentHtml = contentRoot ? contentRoot.innerHTML || "" : compDoc.body.innerHTML || "";
32187
- const contentDoc = parseHTMLContent(contentHtml);
32188
- const innerRoot = compId ? contentDoc.querySelector(`[data-composition-id="${compId}"]`) : contentDoc.querySelector("[data-composition-id]");
32189
- const inferredCompId = innerRoot?.getAttribute("data-composition-id")?.trim() || "";
32190
- const authoredRootId = innerRoot?.getAttribute("id")?.trim() || null;
32191
- const scopeCompId = compId || inferredCompId;
32192
- const runtimeScope = runtimeCompId ? cssAttributeSelector("data-composition-id", runtimeCompId) : "";
32193
- const mergedVariables = runtimeCompId ? {
32194
- ...readDeclaredDefaults(compDoc.documentElement),
32195
- ...parseHostVariableValues(hostEl)
32196
- } : {};
32197
- if (runtimeCompId && Object.keys(mergedVariables).length > 0) {
32198
- compVariablesByComp[runtimeCompId] = mergedVariables;
32199
- }
32200
- if (!contentRoot && compDoc.head) {
32201
- for (const s2 of [...compDoc.head.querySelectorAll("style")]) {
32202
- const css = rewriteCssAssetUrls(s2.textContent || "", src);
32203
- compStyleChunks.push(
32204
- scopeCompId ? scopeCssToComposition(css, scopeCompId, runtimeScope, authoredRootId) : css
32205
- );
32206
- }
32207
- for (const s2 of [...compDoc.head.querySelectorAll("script")]) {
32208
- const externalSrc = (s2.getAttribute("src") || "").trim();
32209
- if (externalSrc && !compExternalScriptSrcs.includes(externalSrc)) {
32210
- compExternalScriptSrcs.push(externalSrc);
32211
- }
32212
- }
32213
- }
32214
- for (const s2 of [...contentDoc.querySelectorAll("style")]) {
32215
- const css = rewriteCssAssetUrls(s2.textContent || "", src);
32216
- compStyleChunks.push(
32217
- scopeCompId ? scopeCssToComposition(css, scopeCompId, runtimeScope, authoredRootId) : css
32218
- );
32219
- s2.remove();
32220
- }
32221
- for (const s2 of [...contentDoc.querySelectorAll("script")]) {
32222
- const externalSrc = (s2.getAttribute("src") || "").trim();
32223
- if (externalSrc) {
32224
- if (!compExternalScriptSrcs.includes(externalSrc)) {
32225
- compExternalScriptSrcs.push(externalSrc);
32226
- }
32227
- } else {
32228
- compScriptChunks.push(
32229
- scopeCompId ? wrapScopedCompositionScript(
32230
- s2.textContent || "",
32231
- scopeCompId,
32232
- "[HyperFrames] composition script error:",
32233
- runtimeScope,
32234
- runtimeCompId || scopeCompId,
32235
- authoredRootId
32236
- ) : `(function(){ try { ${s2.textContent || ""} } catch (_err) { console.error('[HyperFrames] composition script error:', _err); } })();`
32237
- );
32238
- }
32239
- s2.remove();
32240
- }
32241
- const assetEls = innerRoot ? innerRoot.querySelectorAll("[src], [href]") : contentDoc.querySelectorAll("[src], [href]");
32242
- rewriteAssetPaths(
32243
- assetEls,
32244
- src,
32245
- (el, attr) => el.getAttribute(attr),
32246
- (el, attr, val) => {
32247
- el.setAttribute(attr, val);
32248
- }
32249
- );
32250
- const styledEls = innerRoot ? innerRoot.querySelectorAll("[style]") : contentDoc.querySelectorAll("[style]");
32251
- rewriteInlineStyleAssetUrls(
32252
- styledEls,
32253
- src,
32254
- (el) => el.getAttribute("style"),
32255
- (el, val) => {
32256
- el.setAttribute("style", val);
32257
- }
32258
- );
32259
- if (innerRoot) {
32260
- const innerW = innerRoot.getAttribute("data-width");
32261
- const innerH = innerRoot.getAttribute("data-height");
32262
- if (innerW && !hostEl.getAttribute("data-width")) hostEl.setAttribute("data-width", innerW);
32263
- if (innerH && !hostEl.getAttribute("data-height")) hostEl.setAttribute("data-height", innerH);
32264
- innerRoot.setAttribute("data-composition-file", src);
32265
- for (const child of [...innerRoot.querySelectorAll("style, script")]) child.remove();
32266
- const preparedInnerRoot = prepareFlattenedInnerRoot(innerRoot);
32267
- hostEl.innerHTML = preparedInnerRoot.outerHTML || "";
32268
- } else {
32269
- for (const child of [...contentDoc.querySelectorAll("style, script")]) child.remove();
32270
- hostEl.innerHTML = contentDoc.body.innerHTML || "";
32389
+ const subCompResult = inlineSubCompositions(document2, subCompositionHosts, {
32390
+ resolveHtml: (srcPath) => {
32391
+ if (!isRelativeUrl(srcPath)) return null;
32392
+ const compPath = safePath(projectDir, srcPath);
32393
+ return compPath ? safeReadFile(compPath) : null;
32394
+ },
32395
+ parseHtml: parseHTMLContent,
32396
+ hostIdentityMap: hostIdentityByElement,
32397
+ rewriteInlineStyles: true,
32398
+ flattenInnerRoot: prepareFlattenedInnerRoot,
32399
+ readVariableDefaults: readDeclaredDefaults,
32400
+ parseHostVariables: parseHostVariableValues,
32401
+ buildScopeSelector: (compId) => cssAttributeSelector("data-composition-id", compId),
32402
+ scriptErrorLabel: "[HyperFrames] composition script error:",
32403
+ onMissingComposition: (srcPath) => {
32404
+ console.warn(`[Bundler] Composition file not found: ${srcPath}`);
32271
32405
  }
32272
- hostEl.setAttribute("data-composition-file", src);
32273
- hostEl.removeAttribute("data-composition-src");
32274
- }
32406
+ });
32407
+ const compStyleChunks = [...subCompResult.styles];
32408
+ const compScriptChunks = [...subCompResult.scripts];
32409
+ const compExternalScriptSrcs = [...subCompResult.externalScriptSrcs];
32410
+ const compVariablesByComp = {
32411
+ ...subCompResult.variablesByComp
32412
+ };
32275
32413
  const candidateInlineHosts = trackedCompositionHosts.filter(
32276
32414
  (host) => !host.hasAttribute("data-composition-src")
32277
32415
  );
@@ -32409,18 +32547,21 @@ async function bundleToSingleHtml(projectDir, options) {
32409
32547
  }
32410
32548
  return document2.toString();
32411
32549
  }
32412
- var DEFAULT_RUNTIME_SCRIPT_URL, FLATTENED_INNER_ROOT_STRIP_ATTRS;
32550
+ var DEFAULT_RUNTIME_SCRIPT_URL, CSS_IMPORT_RE, REBASE_URL_RE, CSS_COMMENT_RE, FLATTENED_INNER_ROOT_STRIP_ATTRS;
32413
32551
  var init_htmlBundler = __esm({
32414
32552
  "../core/src/compiler/htmlBundler.ts"() {
32415
32553
  "use strict";
32416
32554
  init_htmlCompiler();
32417
32555
  init_htmlDocument();
32418
- init_rewriteSubCompPaths();
32419
32556
  init_compositionScoping();
32420
32557
  init_staticGuard();
32421
32558
  init_runtime_inline();
32422
32559
  init_getVariables();
32560
+ init_inlineSubCompositions();
32423
32561
  DEFAULT_RUNTIME_SCRIPT_URL = "";
32562
+ CSS_IMPORT_RE = /@import\s+(?:url\(\s*(["']?)([^)"']+)\1\s*\)|(["'])([^"']+)\3)\s*([^;]*);\s*/g;
32563
+ REBASE_URL_RE = /\burl\(\s*(["']?)([^)"']+)\1\s*\)/g;
32564
+ CSS_COMMENT_RE = /\/\*[\s\S]*?\*\//g;
32424
32565
  FLATTENED_INNER_ROOT_STRIP_ATTRS = [
32425
32566
  "data-composition-id",
32426
32567
  "data-composition-file",
@@ -32448,6 +32589,7 @@ __export(compiler_exports, {
32448
32589
  injectDurations: () => injectDurations,
32449
32590
  injectScriptsAtHeadStart: () => injectScriptsAtHeadStart,
32450
32591
  injectScriptsIntoHtml: () => injectScriptsIntoHtml,
32592
+ inlineSubCompositions: () => inlineSubCompositions,
32451
32593
  parseHTMLContent: () => parseHTMLContent,
32452
32594
  scopeCssToComposition: () => scopeCssToComposition,
32453
32595
  shouldClampMediaDuration: () => shouldClampMediaDuration,
@@ -32464,6 +32606,7 @@ var init_compiler = __esm({
32464
32606
  init_htmlDocument();
32465
32607
  init_staticGuard();
32466
32608
  init_compositionScoping();
32609
+ init_inlineSubCompositions();
32467
32610
  }
32468
32611
  });
32469
32612
 
@@ -32675,7 +32818,7 @@ async function extractVideoFramesRange(videoPath, videoId, startTime, duration,
32675
32818
  args.push("-q:v", format === "jpg" ? String(Math.ceil((100 - quality) / 3)) : "0");
32676
32819
  if (format === "png") args.push("-compression_level", "6");
32677
32820
  args.push("-y", outputPattern);
32678
- return new Promise((resolve43, reject) => {
32821
+ return new Promise((resolve45, reject) => {
32679
32822
  const ffmpeg = spawn9("ffmpeg", args);
32680
32823
  let stderr = "";
32681
32824
  const onAbort = () => {
@@ -32710,7 +32853,7 @@ async function extractVideoFramesRange(videoPath, videoId, startTime, duration,
32710
32853
  files.forEach((file, index) => {
32711
32854
  framePaths.set(index, join28(videoOutputDir, file));
32712
32855
  });
32713
- resolve43({
32856
+ resolve45({
32714
32857
  videoId,
32715
32858
  srcPath: videoPath,
32716
32859
  outputDir: videoOutputDir,
@@ -33645,7 +33788,7 @@ var init_videoFrameInjector = __esm({
33645
33788
 
33646
33789
  // ../engine/src/services/audioMixer.ts
33647
33790
  import { existsSync as existsSync26, mkdirSync as mkdirSync16, rmSync as rmSync6 } from "fs";
33648
- import { isAbsolute as isAbsolute5, join as join29, dirname as dirname9 } from "path";
33791
+ import { isAbsolute as isAbsolute5, join as join29, dirname as dirname10 } from "path";
33649
33792
  function parseAudioElements(html) {
33650
33793
  const elements = [];
33651
33794
  const { document: document2 } = parseHTML(unwrapTemplate(html));
@@ -33695,7 +33838,7 @@ function parseAudioElements(html) {
33695
33838
  }
33696
33839
  async function extractAudioFromVideo(videoPath, outputPath, options, signal, config) {
33697
33840
  const ffmpegProcessTimeout = config?.ffmpegProcessTimeout ?? DEFAULT_CONFIG2.ffmpegProcessTimeout;
33698
- const outputDir = dirname9(outputPath);
33841
+ const outputDir = dirname10(outputPath);
33699
33842
  if (!existsSync26(outputDir)) mkdirSync16(outputDir, { recursive: true });
33700
33843
  const args = ["-i", videoPath];
33701
33844
  if (options?.startTime !== void 0) args.push("-ss", String(options.startTime));
@@ -33722,7 +33865,7 @@ async function extractAudioFromVideo(videoPath, outputPath, options, signal, con
33722
33865
  }
33723
33866
  async function prepareAudioTrack(srcPath, outputPath, mediaStart, duration, signal, config) {
33724
33867
  const ffmpegProcessTimeout = config?.ffmpegProcessTimeout ?? DEFAULT_CONFIG2.ffmpegProcessTimeout;
33725
- const outputDir = dirname9(outputPath);
33868
+ const outputDir = dirname10(outputPath);
33726
33869
  if (!existsSync26(outputDir)) mkdirSync16(outputDir, { recursive: true });
33727
33870
  const args = [
33728
33871
  "-ss",
@@ -33758,7 +33901,7 @@ async function prepareAudioTrack(srcPath, outputPath, mediaStart, duration, sign
33758
33901
  }
33759
33902
  async function generateSilence(outputPath, duration, signal, config) {
33760
33903
  const ffmpegProcessTimeout = config?.ffmpegProcessTimeout ?? DEFAULT_CONFIG2.ffmpegProcessTimeout;
33761
- const outputDir = dirname9(outputPath);
33904
+ const outputDir = dirname10(outputPath);
33762
33905
  if (!existsSync26(outputDir)) mkdirSync16(outputDir, { recursive: true });
33763
33906
  const args = [
33764
33907
  "-f",
@@ -33801,7 +33944,7 @@ async function mixAudioTracks(tracks, outputPath, totalDuration, signal, config)
33801
33944
  error: result2.error
33802
33945
  };
33803
33946
  }
33804
- const outputDir = dirname9(outputPath);
33947
+ const outputDir = dirname10(outputPath);
33805
33948
  if (!existsSync26(outputDir)) mkdirSync16(outputDir, { recursive: true });
33806
33949
  const inputs = [];
33807
33950
  const filterParts = [];
@@ -34288,11 +34431,11 @@ function createFileServer(options) {
34288
34431
  headers: { "Content-Type": contentType }
34289
34432
  });
34290
34433
  });
34291
- return new Promise((resolve43) => {
34434
+ return new Promise((resolve45) => {
34292
34435
  const server = serve({ fetch: app.fetch, port }, (info) => {
34293
34436
  const actualPort = info.port;
34294
34437
  const url = `http://localhost:${actualPort}`;
34295
- resolve43({
34438
+ resolve45({
34296
34439
  url,
34297
34440
  port: actualPort,
34298
34441
  close: () => server.close()
@@ -36378,7 +36521,7 @@ var init_deterministicFonts = __esm({
36378
36521
  // ../producer/src/services/hyperframeRuntimeLoader.ts
36379
36522
  import { createHash as createHash5 } from "crypto";
36380
36523
  import { existsSync as existsSync31, readFileSync as readFileSync22 } from "fs";
36381
- import { dirname as dirname10, resolve as resolve16 } from "path";
36524
+ import { dirname as dirname11, resolve as resolve16 } from "path";
36382
36525
  import { fileURLToPath as fileURLToPath2 } from "url";
36383
36526
  function resolveHyperframeManifestPath() {
36384
36527
  if (process.env.PRODUCER_HYPERFRAME_MANIFEST_PATH) {
@@ -36414,7 +36557,7 @@ function resolveVerifiedHyperframeRuntime() {
36414
36557
  `[HyperframeRuntimeLoader] Invalid manifest at ${manifestPath}; missing iife artifact or sha256.`
36415
36558
  );
36416
36559
  }
36417
- const runtimePath = resolve16(dirname10(manifestPath), runtimeFileName);
36560
+ const runtimePath = resolve16(dirname11(manifestPath), runtimeFileName);
36418
36561
  if (!existsSync31(runtimePath)) {
36419
36562
  throw new Error(`[HyperframeRuntimeLoader] Missing runtime artifact at ${runtimePath}.`);
36420
36563
  }
@@ -36437,7 +36580,7 @@ var PRODUCER_DIR, SIBLING_MANIFEST_PATH, MODULE_RELATIVE_MANIFEST_PATH, CWD_RELA
36437
36580
  var init_hyperframeRuntimeLoader = __esm({
36438
36581
  "../producer/src/services/hyperframeRuntimeLoader.ts"() {
36439
36582
  "use strict";
36440
- PRODUCER_DIR = dirname10(fileURLToPath2(import.meta.url));
36583
+ PRODUCER_DIR = dirname11(fileURLToPath2(import.meta.url));
36441
36584
  SIBLING_MANIFEST_PATH = resolve16(PRODUCER_DIR, "hyperframe.manifest.json");
36442
36585
  MODULE_RELATIVE_MANIFEST_PATH = resolve16(
36443
36586
  PRODUCER_DIR,
@@ -36667,10 +36810,10 @@ function createFileServer2(options) {
36667
36810
  headers: { "Content-Type": contentType }
36668
36811
  });
36669
36812
  });
36670
- return new Promise((resolve43) => {
36813
+ return new Promise((resolve45) => {
36671
36814
  const connections = /* @__PURE__ */ new Set();
36672
36815
  const server = serve2({ fetch: app.fetch, port }, (info) => {
36673
- resolve43({
36816
+ resolve45({
36674
36817
  url: `http://localhost:${info.port}`,
36675
36818
  port: info.port,
36676
36819
  addPreHeadScript: (script) => {
@@ -36971,11 +37114,11 @@ import {
36971
37114
  isAbsolute as nodeIsAbsolute
36972
37115
  } from "path";
36973
37116
  function isPathInside2(childPath, parentPath, options = {}) {
36974
- const resolvePath = options.pathModule?.resolve ?? nodeResolve;
37117
+ const resolvePath3 = options.pathModule?.resolve ?? nodeResolve;
36975
37118
  const relativePath = options.pathModule?.relative ?? nodeRelative;
36976
37119
  const isPathAbsolute = options.pathModule?.isAbsolute ?? nodeIsAbsolute;
36977
- const absChild = resolvePath(childPath);
36978
- const absParent = resolvePath(parentPath);
37120
+ const absChild = resolvePath3(childPath);
37121
+ const absParent = resolvePath3(parentPath);
36979
37122
  if (absChild === absParent) return true;
36980
37123
  const rel = relativePath(absParent, absChild);
36981
37124
  return rel !== "" && !rel.startsWith("..") && !isPathAbsolute(rel);
@@ -37007,7 +37150,7 @@ var init_paths = __esm({
37007
37150
 
37008
37151
  // ../producer/src/services/render/shared.ts
37009
37152
  import { copyFileSync as copyFileSync2, cpSync, existsSync as existsSync33, mkdirSync as mkdirSync19, symlinkSync, writeFileSync as writeFileSync15 } from "fs";
37010
- import { basename as basename4, dirname as dirname11, isAbsolute as isAbsolute6, join as join36, relative as relative3, resolve as resolve18 } from "path";
37153
+ import { basename as basename4, dirname as dirname12, isAbsolute as isAbsolute6, join as join36, relative as relative4, resolve as resolve18 } from "path";
37011
37154
  function projectBrowserEndToCompositionTimeline(existingStart, browserStart, browserEnd) {
37012
37155
  return browserEnd + (existingStart - browserStart);
37013
37156
  }
@@ -37048,7 +37191,7 @@ function writeCompiledArtifacts(compiled, workDir, includeSummary) {
37048
37191
  writeFileSync15(join36(compileDir, "index.html"), compiled.html, "utf-8");
37049
37192
  for (const [srcPath, html] of compiled.subCompositions) {
37050
37193
  const outPath = join36(compileDir, srcPath);
37051
- mkdirSync19(dirname11(outPath), { recursive: true });
37194
+ mkdirSync19(dirname12(outPath), { recursive: true });
37052
37195
  writeFileSync15(outPath, html, "utf-8");
37053
37196
  }
37054
37197
  for (const [relativePath, absolutePath] of compiled.externalAssets) {
@@ -37057,7 +37200,7 @@ function writeCompiledArtifacts(compiled, workDir, includeSummary) {
37057
37200
  console.warn(`[Render] Skipping external asset with unsafe path: ${relativePath}`);
37058
37201
  continue;
37059
37202
  }
37060
- mkdirSync19(dirname11(outPath), { recursive: true });
37203
+ mkdirSync19(dirname12(outPath), { recursive: true });
37061
37204
  copyFileSync2(absolutePath, outPath);
37062
37205
  }
37063
37206
  if (includeSummary) {
@@ -37108,7 +37251,7 @@ function createCompiledFrameSrcResolver(compiledDir) {
37108
37251
  return (framePath) => {
37109
37252
  const resolvedFramePath = resolve18(framePath);
37110
37253
  if (!isPathInside2(resolvedFramePath, compiledRoot)) return null;
37111
- const relativePath = relative3(compiledRoot, resolvedFramePath);
37254
+ const relativePath = relative4(compiledRoot, resolvedFramePath);
37112
37255
  if (!relativePath || relativePath.startsWith("..") || isAbsolute6(relativePath)) {
37113
37256
  return null;
37114
37257
  }
@@ -37187,9 +37330,9 @@ var init_shared = __esm({
37187
37330
  materializePathModule = {
37188
37331
  resolve: resolve18,
37189
37332
  join: join36,
37190
- dirname: dirname11,
37333
+ dirname: dirname12,
37191
37334
  basename: basename4,
37192
- relative: relative3,
37335
+ relative: relative4,
37193
37336
  isAbsolute: isAbsolute6
37194
37337
  };
37195
37338
  materializeFileSystem = {
@@ -37730,7 +37873,7 @@ var init_urlDownloader2 = __esm({
37730
37873
 
37731
37874
  // ../producer/src/services/htmlCompiler.ts
37732
37875
  import { readFileSync as readFileSync24, existsSync as existsSync34, mkdirSync as mkdirSync20 } from "fs";
37733
- import { join as join38, dirname as dirname12, resolve as resolve19 } from "path";
37876
+ import { join as join38, dirname as dirname13, resolve as resolve19 } from "path";
37734
37877
  function dedupeElementsById(elements) {
37735
37878
  const deduped = /* @__PURE__ */ new Map();
37736
37879
  for (const element of elements) {
@@ -37890,7 +38033,7 @@ async function parseSubCompositions(html, projectDir, downloadDir, parentOffset
37890
38033
  workItems.map(async (item) => {
37891
38034
  const { html: compiledSub } = await compileHtmlFile(
37892
38035
  item.rawSubHtml,
37893
- dirname12(item.filePath),
38036
+ dirname13(item.filePath),
37894
38037
  downloadDir
37895
38038
  );
37896
38039
  const nested = await parseSubCompositions(
@@ -38052,108 +38195,31 @@ function coalesceHeadStylesAndBodyScripts2(html) {
38052
38195
  }
38053
38196
  return document2.toString();
38054
38197
  }
38055
- function inlineSubCompositions(html, subCompositions, projectDir) {
38198
+ function inlineSubCompositions2(html, subCompositions, projectDir) {
38056
38199
  const { document: document2 } = parseHTML(html);
38057
38200
  const head = document2.querySelector("head");
38058
38201
  const body = document2.querySelector("body");
38059
- const hosts = document2.querySelectorAll("[data-composition-src]");
38202
+ const hosts = Array.from(document2.querySelectorAll("[data-composition-src]"));
38060
38203
  if (!hosts.length) return html;
38061
- const collectedStyles = [];
38062
- const collectedScripts = [];
38063
- const collectedExternalScriptSrcs = [];
38064
- for (const host of hosts) {
38065
- const srcPath = host.getAttribute("data-composition-src");
38066
- if (!srcPath) continue;
38067
- let compHtml = subCompositions.get(srcPath) || null;
38068
- if (!compHtml) {
38069
- const filePath = resolve19(projectDir, srcPath);
38070
- if (existsSync34(filePath)) {
38071
- compHtml = readFileSync24(filePath, "utf-8");
38072
- }
38073
- }
38074
- if (!compHtml) {
38075
- continue;
38076
- }
38077
- const compDoc = parseHTML(compHtml).document;
38078
- const compId = host.getAttribute("data-composition-id");
38079
- const templateEl = compDoc.querySelector("template");
38080
- const bodyEl = compDoc.querySelector("body");
38081
- const contentHtml = templateEl ? templateEl.innerHTML || "" : bodyEl ? bodyEl.innerHTML || "" : compDoc.toString();
38082
- const contentDoc = parseHTML(contentHtml).document;
38083
- const innerRoot = compId ? contentDoc.querySelector(`[data-composition-id="${compId}"]`) : contentDoc.querySelector("[data-composition-id]");
38084
- const inferredCompId = innerRoot?.getAttribute("data-composition-id")?.trim() || null;
38085
- if (!templateEl) {
38086
- const compHead = compDoc.querySelector("head");
38087
- if (compHead) {
38088
- for (const styleEl of compHead.querySelectorAll("style")) {
38089
- const css = rewriteCssAssetUrls(styleEl.textContent || "", srcPath);
38090
- const scopeId = compId || inferredCompId;
38091
- if (scopeId && css.trim()) {
38092
- collectedStyles.push(scopeCssToComposition(css, scopeId));
38093
- } else {
38094
- collectedStyles.push(css);
38095
- }
38096
- }
38097
- for (const scriptEl of compHead.querySelectorAll("script")) {
38098
- const src = (scriptEl.getAttribute("src") || "").trim();
38099
- if (src && !collectedExternalScriptSrcs.includes(src)) {
38100
- collectedExternalScriptSrcs.push(src);
38204
+ const result = inlineSubCompositions(
38205
+ document2,
38206
+ hosts,
38207
+ {
38208
+ resolveHtml: (srcPath) => {
38209
+ let compHtml = subCompositions.get(srcPath) || null;
38210
+ if (!compHtml) {
38211
+ const filePath = resolve19(projectDir, srcPath);
38212
+ if (existsSync34(filePath)) {
38213
+ compHtml = readFileSync24(filePath, "utf-8");
38101
38214
  }
38102
38215
  }
38103
- }
38104
- }
38105
- for (const styleEl of contentDoc.querySelectorAll("style")) {
38106
- const css = rewriteCssAssetUrls(styleEl.textContent || "", srcPath);
38107
- const scopeId = compId || inferredCompId;
38108
- if (scopeId && css.trim()) {
38109
- collectedStyles.push(scopeCssToComposition(css, scopeId));
38110
- } else {
38111
- collectedStyles.push(css);
38112
- }
38113
- styleEl.remove();
38114
- }
38115
- for (const scriptEl of contentDoc.querySelectorAll("script")) {
38116
- const src = (scriptEl.getAttribute("src") || "").trim();
38117
- if (src) {
38118
- if (!collectedExternalScriptSrcs.includes(src)) {
38119
- collectedExternalScriptSrcs.push(src);
38120
- }
38121
- scriptEl.remove();
38122
- continue;
38123
- }
38124
- const content = (scriptEl.textContent || "").trim();
38125
- if (content) {
38126
- const scriptMountCompId = compId || inferredCompId || "";
38127
- collectedScripts.push(
38128
- scriptMountCompId ? wrapScopedCompositionScript(
38129
- content,
38130
- scriptMountCompId,
38131
- "[Compiler] Composition script failed"
38132
- ) : `(function(){ try { ${content} } catch (_err) { console.error("[Compiler] Composition script failed", _err); } })()`
38133
- );
38134
- }
38135
- scriptEl.remove();
38136
- }
38137
- const rewriteTarget = innerRoot || contentDoc;
38138
- rewriteAssetPaths(
38139
- rewriteTarget.querySelectorAll("[src], [href]"),
38140
- srcPath,
38141
- (el, attr) => (el.getAttribute(attr) || "").trim(),
38142
- (el, attr, val) => el.setAttribute(attr, val)
38143
- );
38144
- if (innerRoot) {
38145
- const innerW = innerRoot.getAttribute("data-width");
38146
- const innerH = innerRoot.getAttribute("data-height");
38147
- if (innerW && !host.getAttribute("data-width")) host.setAttribute("data-width", innerW);
38148
- if (innerH && !host.getAttribute("data-height")) host.setAttribute("data-height", innerH);
38149
- innerRoot.querySelectorAll("style, script").forEach((el) => el.remove());
38150
- host.innerHTML = compId ? innerRoot.innerHTML || "" : innerRoot.outerHTML || "";
38151
- } else {
38152
- contentDoc.querySelectorAll("style, script").forEach((el) => el.remove());
38153
- host.innerHTML = contentDoc.toString();
38216
+ return compHtml;
38217
+ },
38218
+ parseHtml: (htmlStr) => parseHTML(htmlStr).document,
38219
+ scriptErrorLabel: "[Compiler] Composition script failed"
38154
38220
  }
38155
- host.setAttribute("data-composition-file", srcPath);
38156
- host.removeAttribute("data-composition-src");
38221
+ );
38222
+ for (const host of hosts) {
38157
38223
  const hostW = host.getAttribute("data-width");
38158
38224
  const hostH = host.getAttribute("data-height");
38159
38225
  if (hostW && hostH) {
@@ -38169,18 +38235,18 @@ function inlineSubCompositions(html, subCompositions, projectDir) {
38169
38235
  }
38170
38236
  }
38171
38237
  }
38172
- if (collectedStyles.length && head) {
38238
+ if (result.styles.length && head) {
38173
38239
  const styleEl = document2.createElement("style");
38174
- styleEl.textContent = collectedStyles.join("\n\n");
38240
+ styleEl.textContent = result.styles.join("\n\n");
38175
38241
  head.appendChild(styleEl);
38176
38242
  }
38177
- if (collectedExternalScriptSrcs.length && body) {
38243
+ if (result.externalScriptSrcs.length && body) {
38178
38244
  const existingScriptSrcs = new Set(
38179
38245
  Array.from(document2.querySelectorAll("script[src]")).map(
38180
38246
  (el) => (el.getAttribute("src") || "").trim()
38181
38247
  )
38182
38248
  );
38183
- for (const src of collectedExternalScriptSrcs) {
38249
+ for (const src of result.externalScriptSrcs) {
38184
38250
  if (!existingScriptSrcs.has(src)) {
38185
38251
  const scriptEl = document2.createElement("script");
38186
38252
  scriptEl.setAttribute("src", src);
@@ -38189,9 +38255,9 @@ function inlineSubCompositions(html, subCompositions, projectDir) {
38189
38255
  }
38190
38256
  }
38191
38257
  }
38192
- if (collectedScripts.length && body) {
38258
+ if (result.scripts.length && body) {
38193
38259
  const scriptEl = document2.createElement("script");
38194
- scriptEl.textContent = collectedScripts.join("\n;\n");
38260
+ scriptEl.textContent = result.scripts.join("\n;\n");
38195
38261
  body.appendChild(scriptEl);
38196
38262
  }
38197
38263
  return document2.toString();
@@ -38328,7 +38394,7 @@ async function compileForRender(projectDir, htmlPath, downloadDir, options = {})
38328
38394
  subCompositions
38329
38395
  } = await parseSubCompositions(compiledHtml, projectDir, downloadDir);
38330
38396
  const fullHtml = ensureFullDocument(compiledHtml);
38331
- const inlinedHtml = inlineSubCompositions(fullHtml, subCompositions, projectDir);
38397
+ const inlinedHtml = inlineSubCompositions2(fullHtml, subCompositions, projectDir);
38332
38398
  const sanitizedHtml = inlinedHtml.replace(
38333
38399
  /(<(?:video|audio)\b[^>]*?)\s+preload\s*=\s*["']none["']/gi,
38334
38400
  "$1"
@@ -40033,7 +40099,7 @@ var init_captureHdrSequentialLoop = __esm({
40033
40099
  // ../producer/src/services/shaderTransitionWorkerPool.ts
40034
40100
  import { Worker } from "worker_threads";
40035
40101
  import { fileURLToPath as fileURLToPath3, pathToFileURL } from "url";
40036
- import { dirname as dirname13, join as join45 } from "path";
40102
+ import { dirname as dirname14, join as join45 } from "path";
40037
40103
  import { createRequire } from "module";
40038
40104
  import { existsSync as existsSync36 } from "fs";
40039
40105
  import { cpus as cpus3 } from "os";
@@ -40046,7 +40112,7 @@ function resolveWorkerEntry(explicit) {
40046
40112
  const isTs = override.endsWith(".ts");
40047
40113
  return { path: override, isTs };
40048
40114
  }
40049
- const moduleDir = dirname13(fileURLToPath3(import.meta.url));
40115
+ const moduleDir = dirname14(fileURLToPath3(import.meta.url));
40050
40116
  const jsPath = join45(moduleDir, "shaderTransitionWorker.js");
40051
40117
  if (existsSync36(jsPath)) return { path: jsPath, isTs: false };
40052
40118
  const tsPath = join45(moduleDir, "shaderTransitionWorker.ts");
@@ -40181,8 +40247,8 @@ async function createShaderTransitionWorkerPool(opts) {
40181
40247
  if (terminated) {
40182
40248
  throw new Error("shader-blend pool already terminated");
40183
40249
  }
40184
- return new Promise((resolve43, reject) => {
40185
- const task = traceEnabled ? { req, resolve: resolve43, reject, enqueuedAtMs: Date.now(), traceId: ++nextTaskId } : { req, resolve: resolve43, reject };
40250
+ return new Promise((resolve45, reject) => {
40251
+ const task = traceEnabled ? { req, resolve: resolve45, reject, enqueuedAtMs: Date.now(), traceId: ++nextTaskId } : { req, resolve: resolve45, reject };
40186
40252
  const idle = slots.find((s2) => !s2.busy);
40187
40253
  if (idle) {
40188
40254
  queue.unshift(task);
@@ -40915,7 +40981,7 @@ import {
40915
40981
  copyFileSync as copyFileSync4,
40916
40982
  appendFileSync
40917
40983
  } from "fs";
40918
- import { join as join49, dirname as dirname14, resolve as resolve20 } from "path";
40984
+ import { join as join49, dirname as dirname15, resolve as resolve20 } from "path";
40919
40985
  import { randomUUID as randomUUID2 } from "crypto";
40920
40986
  import { fileURLToPath as fileURLToPath4 } from "url";
40921
40987
  function sampleDirectoryBytes(dir) {
@@ -41596,10 +41662,10 @@ function extractStandaloneEntryFromIndex(indexHtml, entryFile) {
41596
41662
  return document2.toString();
41597
41663
  }
41598
41664
  async function executeRenderJob(job, projectDir, outputPath, onProgress, abortSignal) {
41599
- const moduleDir = dirname14(fileURLToPath4(import.meta.url));
41665
+ const moduleDir = dirname15(fileURLToPath4(import.meta.url));
41600
41666
  const producerRoot = process.env.PRODUCER_RENDERS_DIR ? resolve20(process.env.PRODUCER_RENDERS_DIR, "..") : resolve20(moduleDir, "../..");
41601
41667
  const debugDir = join49(producerRoot, ".debug");
41602
- const workDir = job.config.debug ? join49(debugDir, job.id) : join49(dirname14(outputPath), `work-${job.id}`);
41668
+ const workDir = job.config.debug ? join49(debugDir, job.id) : join49(dirname15(outputPath), `work-${job.id}`);
41603
41669
  const pipelineStart = Date.now();
41604
41670
  const log2 = job.config.logger ?? defaultLogger;
41605
41671
  let fileServer = null;
@@ -42291,10 +42357,10 @@ var init_semaphore = __esm({
42291
42357
  this.active++;
42292
42358
  return () => this.release();
42293
42359
  }
42294
- return new Promise((resolve43) => {
42360
+ return new Promise((resolve45) => {
42295
42361
  this.queue.push(() => {
42296
42362
  this.active++;
42297
- resolve43(() => this.release());
42363
+ resolve45(() => this.release());
42298
42364
  });
42299
42365
  });
42300
42366
  }
@@ -42325,7 +42391,7 @@ import {
42325
42391
  rmSync as rmSync10,
42326
42392
  createReadStream
42327
42393
  } from "fs";
42328
- import { resolve as resolve22, dirname as dirname15, join as join51 } from "path";
42394
+ import { resolve as resolve22, dirname as dirname16, join as join51 } from "path";
42329
42395
  import { tmpdir as tmpdir3 } from "os";
42330
42396
  import { parseArgs as parseArgs2 } from "util";
42331
42397
  import crypto2 from "crypto";
@@ -42502,7 +42568,7 @@ function createRenderHandlers(options = {}) {
42502
42568
  rendersDir,
42503
42569
  log2
42504
42570
  );
42505
- const outputDir = dirname15(absoluteOutputPath);
42571
+ const outputDir = dirname16(absoluteOutputPath);
42506
42572
  if (!existsSync41(outputDir)) mkdirSync25(outputDir, { recursive: true });
42507
42573
  const release2 = await renderSemaphore.acquire();
42508
42574
  log2.info("render started", {
@@ -42613,7 +42679,7 @@ function createRenderHandlers(options = {}) {
42613
42679
  rendersDir,
42614
42680
  log2
42615
42681
  );
42616
- const outputDir = dirname15(absoluteOutputPath);
42682
+ const outputDir = dirname16(absoluteOutputPath);
42617
42683
  if (!existsSync41(outputDir)) mkdirSync25(outputDir, { recursive: true });
42618
42684
  log2.info("render-stream started", { requestId, projectDir: input.projectDir });
42619
42685
  const job = createRenderJob({
@@ -42914,7 +42980,7 @@ var init_runtimeEnvSnapshot = __esm({
42914
42980
 
42915
42981
  // ../producer/src/services/render/stages/freezePlan.ts
42916
42982
  import { existsSync as existsSync42, mkdirSync as mkdirSync26, readFileSync as readFileSync28, readdirSync as readdirSync17, writeFileSync as writeFileSync20 } from "fs";
42917
- import { join as join52, relative as relative4, resolve as resolve23 } from "path";
42983
+ import { join as join52, relative as relative5, resolve as resolve23 } from "path";
42918
42984
  function stripUndefined(value) {
42919
42985
  if (Array.isArray(value)) return value.map(stripUndefined);
42920
42986
  if (value !== null && typeof value === "object") {
@@ -42940,7 +43006,7 @@ function listPlanFiles(planDir) {
42940
43006
  walk(full);
42941
43007
  } else if (entry.isFile()) {
42942
43008
  results.push({
42943
- planRelativePath: relative4(rootResolved, full).split(/[\\/]+/).join("/"),
43009
+ planRelativePath: relative5(rootResolved, full).split(/[\\/]+/).join("/"),
42944
43010
  absolutePath: full
42945
43011
  });
42946
43012
  }
@@ -43110,7 +43176,7 @@ var init_planValidation = __esm({
43110
43176
 
43111
43177
  // ../producer/src/services/distributed/shared.ts
43112
43178
  import { execFile as execFileCallback } from "child_process";
43113
- import { dirname as dirname16, join as join53 } from "path";
43179
+ import { dirname as dirname17, join as join53 } from "path";
43114
43180
  import { existsSync as existsSync43, readFileSync as readFileSync29 } from "fs";
43115
43181
  import { fileURLToPath as fileURLToPath5 } from "url";
43116
43182
  import { promisify as promisify2 } from "util";
@@ -43145,7 +43211,7 @@ function buildSyntheticRenderJob(input) {
43145
43211
  }
43146
43212
  function readProducerVersion() {
43147
43213
  if (cachedProducerVersion !== null) return cachedProducerVersion;
43148
- const startDir = dirname16(fileURLToPath5(import.meta.url));
43214
+ const startDir = dirname17(fileURLToPath5(import.meta.url));
43149
43215
  let current = startDir;
43150
43216
  for (let i2 = 0; i2 < 10; i2++) {
43151
43217
  const candidate = join53(current, "package.json");
@@ -43159,7 +43225,7 @@ function readProducerVersion() {
43159
43225
  } catch {
43160
43226
  }
43161
43227
  }
43162
- const parent = dirname16(current);
43228
+ const parent = dirname17(current);
43163
43229
  if (parent === current) break;
43164
43230
  current = parent;
43165
43231
  }
@@ -43190,7 +43256,7 @@ import {
43190
43256
  statSync as statSync15,
43191
43257
  writeFileSync as writeFileSync21
43192
43258
  } from "fs";
43193
- import { join as join54, relative as relative5, sep as sep6 } from "path";
43259
+ import { join as join54, relative as relative6, sep as sep6 } from "path";
43194
43260
  function formatBytes(bytes) {
43195
43261
  if (bytes < 1024) return `${bytes} B`;
43196
43262
  if (bytes < 1024 * 1024) return `${(bytes / 1024).toFixed(1)} KiB`;
@@ -43375,7 +43441,7 @@ async function plan(projectDir, config, planDir) {
43375
43441
  recursive: true,
43376
43442
  dereference: true,
43377
43443
  filter: (src) => {
43378
- const rel = relative5(projectDir, src);
43444
+ const rel = relative6(projectDir, src);
43379
43445
  if (rel === "" || rel.startsWith("..")) return true;
43380
43446
  const firstSegment = rel.split(sep6, 1)[0];
43381
43447
  return firstSegment === void 0 || !PLAN_PROJECT_DIR_SKIP_SEGMENTS.has(firstSegment);
@@ -44119,7 +44185,7 @@ async function defaultRunFfmpeg(args) {
44119
44185
  };
44120
44186
  }
44121
44187
  function runFfprobeJson(args) {
44122
- return new Promise((resolve43, reject) => {
44188
+ return new Promise((resolve45, reject) => {
44123
44189
  const proc = spawn10("ffprobe", args);
44124
44190
  let stdout2 = "";
44125
44191
  let stderr = "";
@@ -44142,7 +44208,7 @@ function runFfprobeJson(args) {
44142
44208
  return;
44143
44209
  }
44144
44210
  try {
44145
- resolve43(JSON.parse(stdout2));
44211
+ resolve45(JSON.parse(stdout2));
44146
44212
  } catch (err) {
44147
44213
  reject(new Error(`Failed to parse ffprobe output: ${err.message}`));
44148
44214
  }
@@ -44169,7 +44235,7 @@ import {
44169
44235
  statSync as statSync16,
44170
44236
  writeFileSync as writeFileSync23
44171
44237
  } from "fs";
44172
- import { dirname as dirname17, join as join56 } from "path";
44238
+ import { dirname as dirname18, join as join56 } from "path";
44173
44239
  async function assemble(planDir, chunkPaths, audioPath, outputPath, options) {
44174
44240
  const start = Date.now();
44175
44241
  const log2 = options?.logger ?? defaultLogger;
@@ -44197,8 +44263,8 @@ async function assemble(planDir, chunkPaths, audioPath, outputPath, options) {
44197
44263
  if (plan2.dimensions.format === "png-sequence") {
44198
44264
  return mergePngFrameDirs(chunkPaths, outputPath, plan2.totalFrames, audioPath, start);
44199
44265
  }
44200
- if (!existsSync46(dirname17(outputPath))) {
44201
- mkdirSync29(dirname17(outputPath), { recursive: true });
44266
+ if (!existsSync46(dirname18(outputPath))) {
44267
+ mkdirSync29(dirname18(outputPath), { recursive: true });
44202
44268
  }
44203
44269
  const workDir = `${outputPath}.assemble-work`;
44204
44270
  if (existsSync46(workDir)) rmSync13(workDir, { recursive: true, force: true });
@@ -44810,13 +44876,13 @@ __export(preview_exports, {
44810
44876
  });
44811
44877
  import { spawn as spawn11 } from "child_process";
44812
44878
  import { existsSync as existsSync48, lstatSync as lstatSync2, symlinkSync as symlinkSync2, unlinkSync as unlinkSync5, readlinkSync, mkdirSync as mkdirSync30 } from "fs";
44813
- import { resolve as resolve25, dirname as dirname18, basename as basename6, join as join58 } from "path";
44879
+ import { resolve as resolve25, dirname as dirname19, basename as basename6, join as join58 } from "path";
44814
44880
  import { fileURLToPath as fileURLToPath6 } from "url";
44815
44881
  import { createRequire as createRequire2 } from "module";
44816
44882
  async function runDevMode(dir, options) {
44817
44883
  const thisFile = fileURLToPath6(import.meta.url);
44818
- const repoRoot = resolve25(dirname18(thisFile), "..", "..", "..", "..");
44819
- const projectsDir = join58(repoRoot, "packages", "studio", "data", "projects");
44884
+ const repoRoot2 = resolve25(dirname19(thisFile), "..", "..", "..", "..");
44885
+ const projectsDir = join58(repoRoot2, "packages", "studio", "data", "projects");
44820
44886
  const pName = options?.projectName ?? basename6(dir);
44821
44887
  const symlinkPath = join58(projectsDir, pName);
44822
44888
  mkdirSync30(projectsDir, { recursive: true });
@@ -44842,7 +44908,7 @@ async function runDevMode(dir, options) {
44842
44908
  ge(c2.bold("hyperframes preview"));
44843
44909
  const s2 = ft();
44844
44910
  s2.start("Starting studio...");
44845
- const studioPkgDir = join58(repoRoot, "packages", "studio");
44911
+ const studioPkgDir = join58(repoRoot2, "packages", "studio");
44846
44912
  const child = spawn11("bun", ["run", "dev"], {
44847
44913
  cwd: studioPkgDir,
44848
44914
  stdio: ["ignore", "pipe", "pipe"]
@@ -44885,8 +44951,8 @@ async function runDevMode(dir, options) {
44885
44951
  }
44886
44952
  });
44887
44953
  }
44888
- return new Promise((resolve43) => {
44889
- child.on("close", () => resolve43());
44954
+ return new Promise((resolve45) => {
44955
+ child.on("close", () => resolve45());
44890
44956
  });
44891
44957
  }
44892
44958
  function hasLocalStudio(dir) {
@@ -44900,7 +44966,7 @@ function hasLocalStudio(dir) {
44900
44966
  }
44901
44967
  async function runLocalStudioMode(dir, options) {
44902
44968
  const req = createRequire2(join58(dir, "package.json"));
44903
- const studioPkgPath = dirname18(req.resolve("@hyperframes/studio/package.json"));
44969
+ const studioPkgPath = dirname19(req.resolve("@hyperframes/studio/package.json"));
44904
44970
  const pName = options?.projectName ?? basename6(dir);
44905
44971
  const projectsDir = join58(studioPkgPath, "data", "projects");
44906
44972
  const symlinkPath = join58(projectsDir, pName);
@@ -44960,8 +45026,8 @@ async function runLocalStudioMode(dir, options) {
44960
45026
  }
44961
45027
  });
44962
45028
  }
44963
- return new Promise((resolve43) => {
44964
- child.on("close", () => resolve43());
45029
+ return new Promise((resolve45) => {
45030
+ child.on("close", () => resolve45());
44965
45031
  });
44966
45032
  }
44967
45033
  async function runEmbeddedMode(dir, startPort, options) {
@@ -45209,7 +45275,7 @@ import {
45209
45275
  readFileSync as readFileSync33,
45210
45276
  readdirSync as readdirSync21
45211
45277
  } from "fs";
45212
- import { resolve as resolve26, basename as basename7, join as join59, dirname as dirname19 } from "path";
45278
+ import { resolve as resolve26, basename as basename7, join as join59, dirname as dirname20 } from "path";
45213
45279
  import { fileURLToPath as fileURLToPath7 } from "url";
45214
45280
  import { execFileSync as execFileSync5, spawn as spawn12 } from "child_process";
45215
45281
  function probeVideo(filePath) {
@@ -45278,7 +45344,7 @@ function transcodeToMp4(inputPath, outputPath) {
45278
45344
  });
45279
45345
  }
45280
45346
  function resolveAssetDir(devSegments, builtSegments) {
45281
- const base = dirname19(fileURLToPath7(import.meta.url));
45347
+ const base = dirname20(fileURLToPath7(import.meta.url));
45282
45348
  const devPath = resolve26(base, ...devSegments);
45283
45349
  const builtPath = resolve26(base, ...builtSegments);
45284
45350
  return existsSync49(devPath) ? devPath : builtPath;
@@ -46064,7 +46130,7 @@ __export(add_exports, {
46064
46130
  runAdd: () => runAdd
46065
46131
  });
46066
46132
  import { existsSync as existsSync50 } from "fs";
46067
- import { resolve as resolve27, relative as relative6 } from "path";
46133
+ import { resolve as resolve27, relative as relative7 } from "path";
46068
46134
  function remapTarget(item, originalTarget, paths) {
46069
46135
  if (item.type === "hyperframes:block") {
46070
46136
  const blocksDir = paths.blocks.replace(/\/+$/, "");
@@ -46206,7 +46272,7 @@ var init_add = __esm({
46206
46272
  console.log("");
46207
46273
  console.log(`${c2.success("\u2713")} Added ${c2.accent(result.name)} (${result.type})`);
46208
46274
  for (const file of result.written) {
46209
- console.log(` ${c2.dim(relative6(projectDir, file))}`);
46275
+ console.log(` ${c2.dim(relative7(projectDir, file))}`);
46210
46276
  }
46211
46277
  if (result.snippet) {
46212
46278
  console.log("");
@@ -46479,9 +46545,9 @@ __export(play_exports, {
46479
46545
  examples: () => examples5
46480
46546
  });
46481
46547
  import { existsSync as existsSync52, readFileSync as readFileSync34 } from "fs";
46482
- import { resolve as resolve30, dirname as dirname20 } from "path";
46548
+ import { resolve as resolve30, dirname as dirname21 } from "path";
46483
46549
  function commandDir() {
46484
- return dirname20(new URL(import.meta.url).pathname);
46550
+ return dirname21(new URL(import.meta.url).pathname);
46485
46551
  }
46486
46552
  function resolveRuntimePath2() {
46487
46553
  const d2 = commandDir();
@@ -46712,7 +46778,7 @@ var init_play = __esm({
46712
46778
  });
46713
46779
 
46714
46780
  // src/utils/publishProject.ts
46715
- import { basename as basename9, join as join60, relative as relative7 } from "path";
46781
+ import { basename as basename9, join as join60, relative as relative8 } from "path";
46716
46782
  import { readdirSync as readdirSync22, readFileSync as readFileSync35, statSync as statSync19 } from "fs";
46717
46783
  import AdmZip from "adm-zip";
46718
46784
  function isRecord2(value) {
@@ -46814,7 +46880,7 @@ function collectProjectFiles(rootDir, currentDir, paths) {
46814
46880
  for (const entry of readdirSync22(currentDir, { withFileTypes: true })) {
46815
46881
  if (shouldIgnoreSegment(entry.name)) continue;
46816
46882
  const absolutePath = join60(currentDir, entry.name);
46817
- const relativePath = relative7(rootDir, absolutePath).replaceAll("\\", "/");
46883
+ const relativePath = relative8(rootDir, absolutePath).replaceAll("\\", "/");
46818
46884
  if (!relativePath) continue;
46819
46885
  if (entry.isDirectory()) {
46820
46886
  collectProjectFiles(rootDir, absolutePath, paths);
@@ -47187,7 +47253,7 @@ __export(render_exports, {
47187
47253
  });
47188
47254
  import { mkdirSync as mkdirSync32, readdirSync as readdirSync23, readFileSync as readFileSync36, statSync as statSync20, writeFileSync as writeFileSync26, rmSync as rmSync14 } from "fs";
47189
47255
  import { cpus as cpus4, freemem as freemem3, tmpdir as tmpdir4 } from "os";
47190
- import { resolve as resolve32, dirname as dirname21, join as join62, basename as basename11 } from "path";
47256
+ import { resolve as resolve32, dirname as dirname22, join as join62, basename as basename11 } from "path";
47191
47257
  import { execFileSync as execFileSync6, spawn as spawn13 } from "child_process";
47192
47258
  function formatFpsParseError(input, reason) {
47193
47259
  switch (reason) {
@@ -47378,7 +47444,7 @@ async function renderDocker(projectDir, outputPath, options) {
47378
47444
  );
47379
47445
  process.exit(1);
47380
47446
  }
47381
- const outputDir = dirname21(outputPath);
47447
+ const outputDir = dirname22(outputPath);
47382
47448
  const outputFilename = basename11(outputPath);
47383
47449
  const dockerArgs = buildDockerRunArgs({
47384
47450
  imageTag,
@@ -47798,7 +47864,7 @@ var init_render2 = __esm({
47798
47864
  const datePart = now.toISOString().slice(0, 10);
47799
47865
  const timePart = now.toTimeString().slice(0, 8).replace(/:/g, "-");
47800
47866
  const outputPath = args.output ? resolve32(args.output) : join62(rendersDir, `${project.name}_${datePart}_${timePart}${ext}`);
47801
- mkdirSync32(dirname21(outputPath), { recursive: true });
47867
+ mkdirSync32(dirname22(outputPath), { recursive: true });
47802
47868
  const useDocker = args.docker ?? false;
47803
47869
  const useGpu = args.gpu ?? false;
47804
47870
  const browserGpuArg = args["browser-gpu"];
@@ -48214,7 +48280,7 @@ var init_lint3 = __esm({
48214
48280
  // src/utils/staticProjectServer.ts
48215
48281
  import { createServer } from "http";
48216
48282
  import { existsSync as existsSync54, readFileSync as readFileSync37 } from "fs";
48217
- import { isAbsolute as isAbsolute8, relative as relative8, resolve as resolve33 } from "path";
48283
+ import { isAbsolute as isAbsolute8, relative as relative9, resolve as resolve33 } from "path";
48218
48284
  async function serveStaticProjectHtml(projectDir, html, bindErrorMessage = "Failed to bind local HTTP server") {
48219
48285
  const server = createServer((req, res) => {
48220
48286
  const url = req.url ?? "/";
@@ -48224,7 +48290,7 @@ async function serveStaticProjectHtml(projectDir, html, bindErrorMessage = "Fail
48224
48290
  return;
48225
48291
  }
48226
48292
  const filePath = resolve33(projectDir, decodeURIComponent(url).replace(/^\//, ""));
48227
- const rel = relative8(projectDir, filePath);
48293
+ const rel = relative9(projectDir, filePath);
48228
48294
  if (rel.startsWith("..") || isAbsolute8(rel)) {
48229
48295
  res.writeHead(403);
48230
48296
  res.end();
@@ -48409,7 +48475,7 @@ __export(layout_exports, {
48409
48475
  examples: () => examples9
48410
48476
  });
48411
48477
  import { existsSync as existsSync55, readFileSync as readFileSync38 } from "fs";
48412
- import { dirname as dirname22, join as join63 } from "path";
48478
+ import { dirname as dirname23, join as join63 } from "path";
48413
48479
  import { fileURLToPath as fileURLToPath8 } from "url";
48414
48480
  async function getCompositionDuration2(page) {
48415
48481
  return page.evaluate(() => {
@@ -48461,7 +48527,7 @@ async function seekTo(page, time) {
48461
48527
  if (!fonts?.ready) return Promise.resolve();
48462
48528
  return Promise.race([
48463
48529
  fonts.ready.then(() => void 0),
48464
- new Promise((resolve43) => setTimeout(resolve43, 500))
48530
+ new Promise((resolve45) => setTimeout(resolve45, 500))
48465
48531
  ]);
48466
48532
  }).catch(() => {
48467
48533
  });
@@ -48521,7 +48587,7 @@ async function runLayoutAudit(projectDir, opts) {
48521
48587
  if (!fonts?.ready) return Promise.resolve();
48522
48588
  return Promise.race([
48523
48589
  fonts.ready.then(() => void 0),
48524
- new Promise((resolve43) => setTimeout(resolve43, 750))
48590
+ new Promise((resolve45) => setTimeout(resolve45, 750))
48525
48591
  ]);
48526
48592
  }).catch(() => {
48527
48593
  });
@@ -48726,7 +48792,7 @@ var init_layout2 = __esm({
48726
48792
  init_updateCheck();
48727
48793
  init_layoutAudit();
48728
48794
  __filename = fileURLToPath8(import.meta.url);
48729
- __dirname2 = dirname22(__filename);
48795
+ __dirname2 = dirname23(__filename);
48730
48796
  SEEK_SETTLE_MS = 120;
48731
48797
  INSPECT_SCHEMA_VERSION = 1;
48732
48798
  examples9 = [
@@ -48864,7 +48930,7 @@ __export(compositions_exports, {
48864
48930
  parseSubComposition: () => parseSubComposition
48865
48931
  });
48866
48932
  import { existsSync as existsSync56, readFileSync as readFileSync40 } from "fs";
48867
- import { resolve as resolve34, dirname as dirname23 } from "path";
48933
+ import { resolve as resolve34, dirname as dirname24 } from "path";
48868
48934
  function countRenderableDescendants(root) {
48869
48935
  return Array.from(root.querySelectorAll("*")).filter(
48870
48936
  (el) => !NON_RENDERED_TAGS.has(el.tagName.toLowerCase())
@@ -49003,7 +49069,7 @@ var init_compositions = __esm({
49003
49069
  const project = resolveProject(args.dir);
49004
49070
  const html = readFileSync40(project.indexPath, "utf-8");
49005
49071
  ensureDOMParser();
49006
- const compositions = parseCompositions(html, dirname23(project.indexPath));
49072
+ const compositions = parseCompositions(html, dirname24(project.indexPath));
49007
49073
  if (compositions.length === 0) {
49008
49074
  console.log(`${c2.success("\u25C7")} ${c2.accent(project.name)} \u2014 no compositions found`);
49009
49075
  return;
@@ -49841,12 +49907,12 @@ async function runPipeline(options, session, media, format, bgFormat) {
49841
49907
  const drains = [];
49842
49908
  if (!fgWroteFully) {
49843
49909
  drains.push(
49844
- new Promise((resolve43) => fg.proc.stdin.once("drain", () => resolve43()))
49910
+ new Promise((resolve45) => fg.proc.stdin.once("drain", () => resolve45()))
49845
49911
  );
49846
49912
  }
49847
49913
  if (!bgWroteFully && bg) {
49848
49914
  drains.push(
49849
- new Promise((resolve43) => bg.proc.stdin.once("drain", () => resolve43()))
49915
+ new Promise((resolve45) => bg.proc.stdin.once("drain", () => resolve45()))
49850
49916
  );
49851
49917
  }
49852
49918
  await Promise.all(drains);
@@ -49879,11 +49945,11 @@ ${decoder.getStderr().slice(-400)}`
49879
49945
  return processed;
49880
49946
  }
49881
49947
  function waitForExit(proc, label2, getStderr) {
49882
- return new Promise((resolve43, reject) => {
49948
+ return new Promise((resolve45, reject) => {
49883
49949
  proc.on("error", reject);
49884
49950
  proc.on("exit", (code, signal) => {
49885
49951
  if (code === 0 && !signal) {
49886
- resolve43();
49952
+ resolve45();
49887
49953
  return;
49888
49954
  }
49889
49955
  const cause = signal ? `killed by ${signal}` : `exited with code ${code}`;
@@ -50384,7 +50450,7 @@ __export(synthesize_exports, {
50384
50450
  });
50385
50451
  import { execFileSync as execFileSync7 } from "child_process";
50386
50452
  import { existsSync as existsSync62, writeFileSync as writeFileSync28, mkdirSync as mkdirSync35, readdirSync as readdirSync25, unlinkSync as unlinkSync6 } from "fs";
50387
- import { join as join69, dirname as dirname24, basename as basename12 } from "path";
50453
+ import { join as join69, dirname as dirname25, basename as basename12 } from "path";
50388
50454
  import { homedir as homedir11 } from "os";
50389
50455
  function findPython() {
50390
50456
  for (const name of ["python3", "python"]) {
@@ -50462,7 +50528,7 @@ async function synthesize(text, outputPath, options) {
50462
50528
  ensureVoices({ onProgress: options?.onProgress })
50463
50529
  ]);
50464
50530
  const scriptPath = ensureSynthScript();
50465
- mkdirSync35(dirname24(outputPath), { recursive: true });
50531
+ mkdirSync35(dirname25(outputPath), { recursive: true });
50466
50532
  options?.onProgress?.(`Generating speech with voice ${voice} (${lang})...`);
50467
50533
  try {
50468
50534
  const stdout2 = execFileSync7(
@@ -50753,11 +50819,11 @@ __export(docs_exports, {
50753
50819
  examples: () => examples18
50754
50820
  });
50755
50821
  import { readFileSync as readFileSync42, existsSync as existsSync64 } from "fs";
50756
- import { resolve as resolve39, dirname as dirname25, join as join70 } from "path";
50822
+ import { resolve as resolve39, dirname as dirname26, join as join70 } from "path";
50757
50823
  import { fileURLToPath as fileURLToPath9 } from "url";
50758
50824
  function docsDir() {
50759
50825
  const thisFile = fileURLToPath9(import.meta.url);
50760
- const dir = dirname25(thisFile);
50826
+ const dir = dirname26(thisFile);
50761
50827
  const devPath = resolve39(dir, "..", "docs");
50762
50828
  const builtPath = resolve39(dir, "docs");
50763
50829
  return existsSync64(devPath) ? devPath : builtPath;
@@ -51354,7 +51420,7 @@ __export(validate_exports, {
51354
51420
  shouldIgnoreRequestFailure: () => shouldIgnoreRequestFailure
51355
51421
  });
51356
51422
  import { existsSync as existsSync65, readFileSync as readFileSync43 } from "fs";
51357
- import { join as join71, dirname as dirname26 } from "path";
51423
+ import { join as join71, dirname as dirname27 } from "path";
51358
51424
  import { fileURLToPath as fileURLToPath10 } from "url";
51359
51425
  function shouldIgnoreRequestFailure(url, errorText) {
51360
51426
  if (errorText !== "net::ERR_ABORTED") return false;
@@ -51525,7 +51591,7 @@ var init_validate = __esm({
51525
51591
  init_colors();
51526
51592
  init_updateCheck();
51527
51593
  __filename2 = fileURLToPath10(import.meta.url);
51528
- __dirname3 = dirname26(__filename2);
51594
+ __dirname3 = dirname27(__filename2);
51529
51595
  CONTRAST_SAMPLES = 5;
51530
51596
  SEEK_SETTLE_MS2 = 150;
51531
51597
  MEDIA_EXTENSIONS = /\.(aac|flac|m4a|mov|mp3|mp4|oga|ogg|wav|webm)$/i;
@@ -51631,7 +51697,7 @@ __export(snapshot_exports, {
51631
51697
  import { spawn as spawn15 } from "child_process";
51632
51698
  import { existsSync as existsSync66, mkdtempSync as mkdtempSync3, readFileSync as readFileSync44, mkdirSync as mkdirSync36, rmSync as rmSync15 } from "fs";
51633
51699
  import { tmpdir as tmpdir5 } from "os";
51634
- import { resolve as resolve40, join as join72, relative as relative9, isAbsolute as isAbsolute9 } from "path";
51700
+ import { resolve as resolve40, join as join72, relative as relative10, isAbsolute as isAbsolute9 } from "path";
51635
51701
  async function extractVideoFrameToBuffer(videoPath, timeSeconds, useVp9AlphaDecoder = false) {
51636
51702
  const tmp = mkdtempSync3(join72(tmpdir5(), "hf-snapshot-frame-"));
51637
51703
  const outPath = join72(tmp, "frame.png");
@@ -51816,7 +51882,7 @@ async function captureSnapshots(projectDir, opts) {
51816
51882
  const url = new URL(v2.src);
51817
51883
  const decodedPath = decodeURIComponent(url.pathname).replace(/^\//, "");
51818
51884
  const candidate = resolve40(projectDir, decodedPath);
51819
- const rel = relative9(projectDir, candidate);
51885
+ const rel = relative10(projectDir, candidate);
51820
51886
  if (!rel.startsWith("..") && !isAbsolute9(rel) && existsSync66(candidate)) {
51821
51887
  filePath = candidate;
51822
51888
  }
@@ -53408,7 +53474,7 @@ var require_p_retry = __commonJS({
53408
53474
  return error;
53409
53475
  };
53410
53476
  var isNetworkError = (errorMessage) => networkErrorMsgs.includes(errorMessage);
53411
- var pRetry2 = (input, options) => new Promise((resolve43, reject) => {
53477
+ var pRetry2 = (input, options) => new Promise((resolve45, reject) => {
53412
53478
  options = {
53413
53479
  onFailedAttempt: () => {
53414
53480
  },
@@ -53418,7 +53484,7 @@ var require_p_retry = __commonJS({
53418
53484
  const operation = retry.operation(options);
53419
53485
  operation.attempt(async (attemptNumber) => {
53420
53486
  try {
53421
- resolve43(await input(attemptNumber));
53487
+ resolve45(await input(attemptNumber));
53422
53488
  } catch (error) {
53423
53489
  if (!(error instanceof Error)) {
53424
53490
  reject(new TypeError(`Non-error was thrown: "${error}". You should only throw errors.`));
@@ -53954,8 +54020,8 @@ var require_retry3 = __commonJS({
53954
54020
  }
53955
54021
  const delay = getNextRetryDelay(config);
53956
54022
  err.config.retryConfig.currentRetryAttempt += 1;
53957
- const backoff = config.retryBackoff ? config.retryBackoff(err, delay) : new Promise((resolve43) => {
53958
- setTimeout(resolve43, delay);
54023
+ const backoff = config.retryBackoff ? config.retryBackoff(err, delay) : new Promise((resolve45) => {
54024
+ setTimeout(resolve45, delay);
53959
54025
  });
53960
54026
  if (config.onRetryAttempt) {
53961
54027
  await config.onRetryAttempt(err);
@@ -54863,8 +54929,8 @@ var require_helpers = __commonJS({
54863
54929
  function req(url, opts = {}) {
54864
54930
  const href = typeof url === "string" ? url : url.href;
54865
54931
  const req2 = (href.startsWith("https:") ? https2 : http4).request(url, opts);
54866
- const promise = new Promise((resolve43, reject) => {
54867
- req2.once("response", resolve43).once("error", reject).end();
54932
+ const promise = new Promise((resolve45, reject) => {
54933
+ req2.once("response", resolve45).once("error", reject).end();
54868
54934
  });
54869
54935
  req2.then = promise.then.bind(promise);
54870
54936
  return req2;
@@ -55041,7 +55107,7 @@ var require_parse_proxy_response = __commonJS({
55041
55107
  var debug_1 = __importDefault(require_src2());
55042
55108
  var debug = (0, debug_1.default)("https-proxy-agent:parse-proxy-response");
55043
55109
  function parseProxyResponse(socket) {
55044
- return new Promise((resolve43, reject) => {
55110
+ return new Promise((resolve45, reject) => {
55045
55111
  let buffersLength = 0;
55046
55112
  const buffers = [];
55047
55113
  function read() {
@@ -55107,7 +55173,7 @@ var require_parse_proxy_response = __commonJS({
55107
55173
  }
55108
55174
  debug("got proxy server response: %o %o", firstLine, headers);
55109
55175
  cleanup();
55110
- resolve43({
55176
+ resolve45({
55111
55177
  connect: {
55112
55178
  statusCode,
55113
55179
  statusText,
@@ -55351,7 +55417,7 @@ var require_ponyfill_es2018 = __commonJS({
55351
55417
  return new originalPromise(executor);
55352
55418
  }
55353
55419
  function promiseResolvedWith(value) {
55354
- return newPromise((resolve43) => resolve43(value));
55420
+ return newPromise((resolve45) => resolve45(value));
55355
55421
  }
55356
55422
  function promiseRejectedWith(reason) {
55357
55423
  return originalPromiseReject(reason);
@@ -55521,8 +55587,8 @@ var require_ponyfill_es2018 = __commonJS({
55521
55587
  return new TypeError("Cannot " + name + " a stream using a released reader");
55522
55588
  }
55523
55589
  function defaultReaderClosedPromiseInitialize(reader) {
55524
- reader._closedPromise = newPromise((resolve43, reject) => {
55525
- reader._closedPromise_resolve = resolve43;
55590
+ reader._closedPromise = newPromise((resolve45, reject) => {
55591
+ reader._closedPromise_resolve = resolve45;
55526
55592
  reader._closedPromise_reject = reject;
55527
55593
  });
55528
55594
  }
@@ -55696,8 +55762,8 @@ var require_ponyfill_es2018 = __commonJS({
55696
55762
  }
55697
55763
  let resolvePromise;
55698
55764
  let rejectPromise;
55699
- const promise = newPromise((resolve43, reject) => {
55700
- resolvePromise = resolve43;
55765
+ const promise = newPromise((resolve45, reject) => {
55766
+ resolvePromise = resolve45;
55701
55767
  rejectPromise = reject;
55702
55768
  });
55703
55769
  const readRequest = {
@@ -55802,8 +55868,8 @@ var require_ponyfill_es2018 = __commonJS({
55802
55868
  const reader = this._reader;
55803
55869
  let resolvePromise;
55804
55870
  let rejectPromise;
55805
- const promise = newPromise((resolve43, reject) => {
55806
- resolvePromise = resolve43;
55871
+ const promise = newPromise((resolve45, reject) => {
55872
+ resolvePromise = resolve45;
55807
55873
  rejectPromise = reject;
55808
55874
  });
55809
55875
  const readRequest = {
@@ -56822,8 +56888,8 @@ var require_ponyfill_es2018 = __commonJS({
56822
56888
  }
56823
56889
  let resolvePromise;
56824
56890
  let rejectPromise;
56825
- const promise = newPromise((resolve43, reject) => {
56826
- resolvePromise = resolve43;
56891
+ const promise = newPromise((resolve45, reject) => {
56892
+ resolvePromise = resolve45;
56827
56893
  rejectPromise = reject;
56828
56894
  });
56829
56895
  const readIntoRequest = {
@@ -57135,10 +57201,10 @@ var require_ponyfill_es2018 = __commonJS({
57135
57201
  wasAlreadyErroring = true;
57136
57202
  reason = void 0;
57137
57203
  }
57138
- const promise = newPromise((resolve43, reject) => {
57204
+ const promise = newPromise((resolve45, reject) => {
57139
57205
  stream._pendingAbortRequest = {
57140
57206
  _promise: void 0,
57141
- _resolve: resolve43,
57207
+ _resolve: resolve45,
57142
57208
  _reject: reject,
57143
57209
  _reason: reason,
57144
57210
  _wasAlreadyErroring: wasAlreadyErroring
@@ -57155,9 +57221,9 @@ var require_ponyfill_es2018 = __commonJS({
57155
57221
  if (state === "closed" || state === "errored") {
57156
57222
  return promiseRejectedWith(new TypeError(`The stream (in ${state} state) is not in the writable state and cannot be closed`));
57157
57223
  }
57158
- const promise = newPromise((resolve43, reject) => {
57224
+ const promise = newPromise((resolve45, reject) => {
57159
57225
  const closeRequest = {
57160
- _resolve: resolve43,
57226
+ _resolve: resolve45,
57161
57227
  _reject: reject
57162
57228
  };
57163
57229
  stream._closeRequest = closeRequest;
@@ -57170,9 +57236,9 @@ var require_ponyfill_es2018 = __commonJS({
57170
57236
  return promise;
57171
57237
  }
57172
57238
  function WritableStreamAddWriteRequest(stream) {
57173
- const promise = newPromise((resolve43, reject) => {
57239
+ const promise = newPromise((resolve45, reject) => {
57174
57240
  const writeRequest = {
57175
- _resolve: resolve43,
57241
+ _resolve: resolve45,
57176
57242
  _reject: reject
57177
57243
  };
57178
57244
  stream._writeRequests.push(writeRequest);
@@ -57788,8 +57854,8 @@ var require_ponyfill_es2018 = __commonJS({
57788
57854
  return new TypeError("Cannot " + name + " a stream using a released writer");
57789
57855
  }
57790
57856
  function defaultWriterClosedPromiseInitialize(writer) {
57791
- writer._closedPromise = newPromise((resolve43, reject) => {
57792
- writer._closedPromise_resolve = resolve43;
57857
+ writer._closedPromise = newPromise((resolve45, reject) => {
57858
+ writer._closedPromise_resolve = resolve45;
57793
57859
  writer._closedPromise_reject = reject;
57794
57860
  writer._closedPromiseState = "pending";
57795
57861
  });
@@ -57825,8 +57891,8 @@ var require_ponyfill_es2018 = __commonJS({
57825
57891
  writer._closedPromiseState = "resolved";
57826
57892
  }
57827
57893
  function defaultWriterReadyPromiseInitialize(writer) {
57828
- writer._readyPromise = newPromise((resolve43, reject) => {
57829
- writer._readyPromise_resolve = resolve43;
57894
+ writer._readyPromise = newPromise((resolve45, reject) => {
57895
+ writer._readyPromise_resolve = resolve45;
57830
57896
  writer._readyPromise_reject = reject;
57831
57897
  });
57832
57898
  writer._readyPromiseState = "pending";
@@ -57913,7 +57979,7 @@ var require_ponyfill_es2018 = __commonJS({
57913
57979
  source._disturbed = true;
57914
57980
  let shuttingDown = false;
57915
57981
  let currentWrite = promiseResolvedWith(void 0);
57916
- return newPromise((resolve43, reject) => {
57982
+ return newPromise((resolve45, reject) => {
57917
57983
  let abortAlgorithm;
57918
57984
  if (signal !== void 0) {
57919
57985
  abortAlgorithm = () => {
@@ -58058,7 +58124,7 @@ var require_ponyfill_es2018 = __commonJS({
58058
58124
  if (isError) {
58059
58125
  reject(error);
58060
58126
  } else {
58061
- resolve43(void 0);
58127
+ resolve45(void 0);
58062
58128
  }
58063
58129
  return null;
58064
58130
  }
@@ -58339,8 +58405,8 @@ var require_ponyfill_es2018 = __commonJS({
58339
58405
  let branch1;
58340
58406
  let branch2;
58341
58407
  let resolveCancelPromise;
58342
- const cancelPromise = newPromise((resolve43) => {
58343
- resolveCancelPromise = resolve43;
58408
+ const cancelPromise = newPromise((resolve45) => {
58409
+ resolveCancelPromise = resolve45;
58344
58410
  });
58345
58411
  function pullAlgorithm() {
58346
58412
  if (reading) {
@@ -58431,8 +58497,8 @@ var require_ponyfill_es2018 = __commonJS({
58431
58497
  let branch1;
58432
58498
  let branch2;
58433
58499
  let resolveCancelPromise;
58434
- const cancelPromise = newPromise((resolve43) => {
58435
- resolveCancelPromise = resolve43;
58500
+ const cancelPromise = newPromise((resolve45) => {
58501
+ resolveCancelPromise = resolve45;
58436
58502
  });
58437
58503
  function forwardReaderError(thisReader) {
58438
58504
  uponRejection(thisReader._closedPromise, (r2) => {
@@ -59212,8 +59278,8 @@ var require_ponyfill_es2018 = __commonJS({
59212
59278
  const writableHighWaterMark = ExtractHighWaterMark(writableStrategy, 1);
59213
59279
  const writableSizeAlgorithm = ExtractSizeAlgorithm(writableStrategy);
59214
59280
  let startPromise_resolve;
59215
- const startPromise = newPromise((resolve43) => {
59216
- startPromise_resolve = resolve43;
59281
+ const startPromise = newPromise((resolve45) => {
59282
+ startPromise_resolve = resolve45;
59217
59283
  });
59218
59284
  InitializeTransformStream(this, startPromise, writableHighWaterMark, writableSizeAlgorithm, readableHighWaterMark, readableSizeAlgorithm);
59219
59285
  SetUpTransformStreamDefaultControllerFromTransformer(this, transformer);
@@ -59306,8 +59372,8 @@ var require_ponyfill_es2018 = __commonJS({
59306
59372
  if (stream._backpressureChangePromise !== void 0) {
59307
59373
  stream._backpressureChangePromise_resolve();
59308
59374
  }
59309
- stream._backpressureChangePromise = newPromise((resolve43) => {
59310
- stream._backpressureChangePromise_resolve = resolve43;
59375
+ stream._backpressureChangePromise = newPromise((resolve45) => {
59376
+ stream._backpressureChangePromise_resolve = resolve45;
59311
59377
  });
59312
59378
  stream._backpressure = backpressure;
59313
59379
  }
@@ -59475,8 +59541,8 @@ var require_ponyfill_es2018 = __commonJS({
59475
59541
  return controller._finishPromise;
59476
59542
  }
59477
59543
  const readable = stream._readable;
59478
- controller._finishPromise = newPromise((resolve43, reject) => {
59479
- controller._finishPromise_resolve = resolve43;
59544
+ controller._finishPromise = newPromise((resolve45, reject) => {
59545
+ controller._finishPromise_resolve = resolve45;
59480
59546
  controller._finishPromise_reject = reject;
59481
59547
  });
59482
59548
  const cancelPromise = controller._cancelAlgorithm(reason);
@@ -59502,8 +59568,8 @@ var require_ponyfill_es2018 = __commonJS({
59502
59568
  return controller._finishPromise;
59503
59569
  }
59504
59570
  const readable = stream._readable;
59505
- controller._finishPromise = newPromise((resolve43, reject) => {
59506
- controller._finishPromise_resolve = resolve43;
59571
+ controller._finishPromise = newPromise((resolve45, reject) => {
59572
+ controller._finishPromise_resolve = resolve45;
59507
59573
  controller._finishPromise_reject = reject;
59508
59574
  });
59509
59575
  const flushPromise = controller._flushAlgorithm();
@@ -59533,8 +59599,8 @@ var require_ponyfill_es2018 = __commonJS({
59533
59599
  return controller._finishPromise;
59534
59600
  }
59535
59601
  const writable = stream._writable;
59536
- controller._finishPromise = newPromise((resolve43, reject) => {
59537
- controller._finishPromise_resolve = resolve43;
59602
+ controller._finishPromise = newPromise((resolve45, reject) => {
59603
+ controller._finishPromise_resolve = resolve45;
59538
59604
  controller._finishPromise_reject = reject;
59539
59605
  });
59540
59606
  const cancelPromise = controller._cancelAlgorithm(reason);
@@ -61503,7 +61569,7 @@ import zlib from "zlib";
61503
61569
  import Stream2, { PassThrough as PassThrough2, pipeline as pump } from "stream";
61504
61570
  import { Buffer as Buffer3 } from "buffer";
61505
61571
  async function fetch3(url, options_) {
61506
- return new Promise((resolve43, reject) => {
61572
+ return new Promise((resolve45, reject) => {
61507
61573
  const request = new Request2(url, options_);
61508
61574
  const { parsedURL, options } = getNodeRequestOptions(request);
61509
61575
  if (!supportedSchemas.has(parsedURL.protocol)) {
@@ -61512,7 +61578,7 @@ async function fetch3(url, options_) {
61512
61578
  if (parsedURL.protocol === "data:") {
61513
61579
  const data = dist_default3(request.url);
61514
61580
  const response2 = new Response2(data, { headers: { "Content-Type": data.typeFull } });
61515
- resolve43(response2);
61581
+ resolve45(response2);
61516
61582
  return;
61517
61583
  }
61518
61584
  const send = (parsedURL.protocol === "https:" ? https : http3).request;
@@ -61634,7 +61700,7 @@ async function fetch3(url, options_) {
61634
61700
  if (responseReferrerPolicy) {
61635
61701
  requestOptions.referrerPolicy = responseReferrerPolicy;
61636
61702
  }
61637
- resolve43(fetch3(new Request2(locationURL, requestOptions)));
61703
+ resolve45(fetch3(new Request2(locationURL, requestOptions)));
61638
61704
  finalize();
61639
61705
  return;
61640
61706
  }
@@ -61667,7 +61733,7 @@ async function fetch3(url, options_) {
61667
61733
  const codings = headers.get("Content-Encoding");
61668
61734
  if (!request.compress || request.method === "HEAD" || codings === null || response_.statusCode === 204 || response_.statusCode === 304) {
61669
61735
  response = new Response2(body, responseOptions);
61670
- resolve43(response);
61736
+ resolve45(response);
61671
61737
  return;
61672
61738
  }
61673
61739
  const zlibOptions = {
@@ -61681,7 +61747,7 @@ async function fetch3(url, options_) {
61681
61747
  }
61682
61748
  });
61683
61749
  response = new Response2(body, responseOptions);
61684
- resolve43(response);
61750
+ resolve45(response);
61685
61751
  return;
61686
61752
  }
61687
61753
  if (codings === "deflate" || codings === "x-deflate") {
@@ -61705,12 +61771,12 @@ async function fetch3(url, options_) {
61705
61771
  });
61706
61772
  }
61707
61773
  response = new Response2(body, responseOptions);
61708
- resolve43(response);
61774
+ resolve45(response);
61709
61775
  });
61710
61776
  raw.once("end", () => {
61711
61777
  if (!response) {
61712
61778
  response = new Response2(body, responseOptions);
61713
- resolve43(response);
61779
+ resolve45(response);
61714
61780
  }
61715
61781
  });
61716
61782
  return;
@@ -61722,11 +61788,11 @@ async function fetch3(url, options_) {
61722
61788
  }
61723
61789
  });
61724
61790
  response = new Response2(body, responseOptions);
61725
- resolve43(response);
61791
+ resolve45(response);
61726
61792
  return;
61727
61793
  }
61728
61794
  response = new Response2(body, responseOptions);
61729
- resolve43(response);
61795
+ resolve45(response);
61730
61796
  });
61731
61797
  writeToStream(request_, request).catch(reject);
61732
61798
  });
@@ -67808,7 +67874,7 @@ var require_jwtaccess = __commonJS({
67808
67874
  }
67809
67875
  }
67810
67876
  fromStreamAsync(inputStream) {
67811
- return new Promise((resolve43, reject) => {
67877
+ return new Promise((resolve45, reject) => {
67812
67878
  if (!inputStream) {
67813
67879
  reject(new Error("Must pass in a stream containing the service account auth settings."));
67814
67880
  }
@@ -67817,7 +67883,7 @@ var require_jwtaccess = __commonJS({
67817
67883
  try {
67818
67884
  const data = JSON.parse(s2);
67819
67885
  this.fromJSON(data);
67820
- resolve43();
67886
+ resolve45();
67821
67887
  } catch (err) {
67822
67888
  reject(err);
67823
67889
  }
@@ -68056,7 +68122,7 @@ var require_jwtclient = __commonJS({
68056
68122
  }
68057
68123
  }
68058
68124
  fromStreamAsync(inputStream) {
68059
- return new Promise((resolve43, reject) => {
68125
+ return new Promise((resolve45, reject) => {
68060
68126
  if (!inputStream) {
68061
68127
  throw new Error("Must pass in a stream containing the service account auth settings.");
68062
68128
  }
@@ -68065,7 +68131,7 @@ var require_jwtclient = __commonJS({
68065
68131
  try {
68066
68132
  const data = JSON.parse(s2);
68067
68133
  this.fromJSON(data);
68068
- resolve43();
68134
+ resolve45();
68069
68135
  } catch (e3) {
68070
68136
  reject(e3);
68071
68137
  }
@@ -68198,7 +68264,7 @@ var require_refreshclient = __commonJS({
68198
68264
  }
68199
68265
  }
68200
68266
  async fromStreamAsync(inputStream) {
68201
- return new Promise((resolve43, reject) => {
68267
+ return new Promise((resolve45, reject) => {
68202
68268
  if (!inputStream) {
68203
68269
  return reject(new Error("Must pass in a stream containing the user refresh token."));
68204
68270
  }
@@ -68207,7 +68273,7 @@ var require_refreshclient = __commonJS({
68207
68273
  try {
68208
68274
  const data = JSON.parse(s2);
68209
68275
  this.fromJSON(data);
68210
- return resolve43();
68276
+ return resolve45();
68211
68277
  } catch (err) {
68212
68278
  return reject(err);
68213
68279
  }
@@ -70040,7 +70106,7 @@ var require_pluggable_auth_handler = __commonJS({
70040
70106
  * @return A promise that resolves with the executable response.
70041
70107
  */
70042
70108
  retrieveResponseFromExecutable(envMap) {
70043
- return new Promise((resolve43, reject) => {
70109
+ return new Promise((resolve45, reject) => {
70044
70110
  const child = childProcess.spawn(this.commandComponents[0], this.commandComponents.slice(1), {
70045
70111
  env: { ...process.env, ...Object.fromEntries(envMap) }
70046
70112
  });
@@ -70062,7 +70128,7 @@ var require_pluggable_auth_handler = __commonJS({
70062
70128
  try {
70063
70129
  const responseJson = JSON.parse(output);
70064
70130
  const response = new executable_response_1.ExecutableResponse(responseJson);
70065
- return resolve43(response);
70131
+ return resolve45(response);
70066
70132
  } catch (error) {
70067
70133
  if (error instanceof executable_response_1.ExecutableResponseError) {
70068
70134
  return reject(error);
@@ -70965,7 +71031,7 @@ var require_googleauth = __commonJS({
70965
71031
  }
70966
71032
  }
70967
71033
  fromStreamAsync(inputStream, options) {
70968
- return new Promise((resolve43, reject) => {
71034
+ return new Promise((resolve45, reject) => {
70969
71035
  if (!inputStream) {
70970
71036
  throw new Error("Must pass in a stream containing the Google auth settings.");
70971
71037
  }
@@ -70975,7 +71041,7 @@ var require_googleauth = __commonJS({
70975
71041
  try {
70976
71042
  const data = JSON.parse(chunks.join(""));
70977
71043
  const r2 = this._cacheClientFromJSON(data, options);
70978
- return resolve43(r2);
71044
+ return resolve45(r2);
70979
71045
  } catch (err) {
70980
71046
  if (!this.keyFilename)
70981
71047
  throw err;
@@ -70985,7 +71051,7 @@ var require_googleauth = __commonJS({
70985
71051
  });
70986
71052
  this.cachedCredential = client;
70987
71053
  this.setGapicJWTValues(client);
70988
- return resolve43(client);
71054
+ return resolve45(client);
70989
71055
  }
70990
71056
  } catch (err) {
70991
71057
  return reject(err);
@@ -71021,17 +71087,17 @@ var require_googleauth = __commonJS({
71021
71087
  * Run the Google Cloud SDK command that prints the default project ID
71022
71088
  */
71023
71089
  async getDefaultServiceProjectId() {
71024
- return new Promise((resolve43) => {
71090
+ return new Promise((resolve45) => {
71025
71091
  (0, child_process_1.exec)("gcloud config config-helper --format json", (err, stdout2) => {
71026
71092
  if (!err && stdout2) {
71027
71093
  try {
71028
71094
  const projectId = JSON.parse(stdout2).configuration.properties.core.project;
71029
- resolve43(projectId);
71095
+ resolve45(projectId);
71030
71096
  return;
71031
71097
  } catch (e3) {
71032
71098
  }
71033
71099
  }
71034
- resolve43(null);
71100
+ resolve45(null);
71035
71101
  });
71036
71102
  });
71037
71103
  }
@@ -78874,14 +78940,14 @@ function __asyncValues(o) {
78874
78940
  }, i2);
78875
78941
  function verb(n) {
78876
78942
  i2[n] = o[n] && function(v2) {
78877
- return new Promise(function(resolve43, reject) {
78878
- v2 = o[n](v2), settle(resolve43, reject, v2.done, v2.value);
78943
+ return new Promise(function(resolve45, reject) {
78944
+ v2 = o[n](v2), settle(resolve45, reject, v2.done, v2.value);
78879
78945
  });
78880
78946
  };
78881
78947
  }
78882
- function settle(resolve43, reject, d2, v2) {
78948
+ function settle(resolve45, reject, d2, v2) {
78883
78949
  Promise.resolve(v2).then(function(v3) {
78884
- resolve43({ value: v3, done: d2 });
78950
+ resolve45({ value: v3, done: d2 });
78885
78951
  }, reject);
78886
78952
  }
78887
78953
  }
@@ -89371,8 +89437,8 @@ var init_node4 = __esm({
89371
89437
  const url = `${websocketBaseUrl}/ws/google.ai.generativelanguage.${apiVersion}.GenerativeService.BidiGenerateMusic?key=${apiKey}`;
89372
89438
  let onopenResolve = () => {
89373
89439
  };
89374
- const onopenPromise = new Promise((resolve43) => {
89375
- onopenResolve = resolve43;
89440
+ const onopenPromise = new Promise((resolve45) => {
89441
+ onopenResolve = resolve45;
89376
89442
  });
89377
89443
  const callbacks = params.callbacks;
89378
89444
  const onopenAwaitedCallback = function() {
@@ -89578,8 +89644,8 @@ var init_node4 = __esm({
89578
89644
  }
89579
89645
  let onopenResolve = () => {
89580
89646
  };
89581
- const onopenPromise = new Promise((resolve43) => {
89582
- onopenResolve = resolve43;
89647
+ const onopenPromise = new Promise((resolve45) => {
89648
+ onopenResolve = resolve45;
89583
89649
  });
89584
89650
  const callbacks = params.callbacks;
89585
89651
  const onopenAwaitedCallback = function() {
@@ -91927,7 +91993,7 @@ var init_node4 = __esm({
91927
91993
  return void 0;
91928
91994
  }
91929
91995
  };
91930
- sleep$1 = (ms) => new Promise((resolve43) => setTimeout(resolve43, ms));
91996
+ sleep$1 = (ms) => new Promise((resolve45) => setTimeout(resolve45, ms));
91931
91997
  FallbackEncoder = ({ headers, body }) => {
91932
91998
  return {
91933
91999
  bodyHeaders: {
@@ -92436,8 +92502,8 @@ ${underline2}`);
92436
92502
  };
92437
92503
  APIPromise = class _APIPromise extends Promise {
92438
92504
  constructor(client, responsePromise, parseResponse = defaultParseResponse) {
92439
- super((resolve43) => {
92440
- resolve43(null);
92505
+ super((resolve45) => {
92506
+ resolve45(null);
92441
92507
  });
92442
92508
  this.responsePromise = responsePromise;
92443
92509
  this.parseResponse = parseResponse;
@@ -94895,11 +94961,11 @@ var init_capture2 = __esm({
94895
94961
  } catch (err) {
94896
94962
  const errMsg = err instanceof Error ? err.message : String(err);
94897
94963
  try {
94898
- const { mkdirSync: mkdirSync42, writeFileSync: writeFileSync35 } = await import("fs");
94899
- mkdirSync42(outputDir, { recursive: true });
94964
+ const { mkdirSync: mkdirSync43, writeFileSync: writeFileSync36 } = await import("fs");
94965
+ mkdirSync43(outputDir, { recursive: true });
94900
94966
  const isTimeout = /timeout|timed out/i.test(errMsg);
94901
94967
  const reason = isTimeout ? "Page navigation timed out \u2014 the site may be blocking headless browsers or requires authentication." : `Capture failed: ${errMsg}`;
94902
- writeFileSync35(
94968
+ writeFileSync36(
94903
94969
  `${outputDir}/BLOCKED.md`,
94904
94970
  `# Capture Failed
94905
94971
 
@@ -94931,6 +94997,1136 @@ URL: ${url}
94931
94997
  }
94932
94998
  });
94933
94999
 
95000
+ // src/commands/lambda/state.ts
95001
+ var state_exports = {};
95002
+ __export(state_exports, {
95003
+ DEFAULT_STACK_NAME: () => DEFAULT_STACK_NAME,
95004
+ deleteStackOutputs: () => deleteStackOutputs,
95005
+ listStackNames: () => listStackNames,
95006
+ readStackOutputs: () => readStackOutputs,
95007
+ requireStack: () => requireStack,
95008
+ stateFilePath: () => stateFilePath,
95009
+ writeStackOutputs: () => writeStackOutputs
95010
+ });
95011
+ import { existsSync as existsSync69, mkdirSync as mkdirSync41, readdirSync as readdirSync28, readFileSync as readFileSync48, rmSync as rmSync16, writeFileSync as writeFileSync35 } from "fs";
95012
+ import { dirname as dirname28, join as join80 } from "path";
95013
+ function stateFilePath(stackName = DEFAULT_STACK_NAME, cwd = process.cwd()) {
95014
+ return join80(cwd, STATE_DIR_NAME, `${STATE_FILE_PREFIX}${stackName}.json`);
95015
+ }
95016
+ function writeStackOutputs(outputs, cwd = process.cwd()) {
95017
+ const path2 = stateFilePath(outputs.stackName, cwd);
95018
+ mkdirSync41(dirname28(path2), { recursive: true });
95019
+ writeFileSync35(path2, JSON.stringify(outputs, null, 2) + "\n");
95020
+ return path2;
95021
+ }
95022
+ function readStackOutputs(stackName = DEFAULT_STACK_NAME, cwd = process.cwd()) {
95023
+ const path2 = stateFilePath(stackName, cwd);
95024
+ if (!existsSync69(path2)) return null;
95025
+ try {
95026
+ return JSON.parse(readFileSync48(path2, "utf-8"));
95027
+ } catch {
95028
+ return null;
95029
+ }
95030
+ }
95031
+ function deleteStackOutputs(stackName = DEFAULT_STACK_NAME, cwd = process.cwd()) {
95032
+ const path2 = stateFilePath(stackName, cwd);
95033
+ if (existsSync69(path2)) rmSync16(path2);
95034
+ }
95035
+ function listStackNames(cwd = process.cwd()) {
95036
+ const dir = join80(cwd, STATE_DIR_NAME);
95037
+ if (!existsSync69(dir)) return [];
95038
+ return readdirSync28(dir).filter((f3) => f3.startsWith(STATE_FILE_PREFIX) && f3.endsWith(".json")).map((f3) => f3.slice(STATE_FILE_PREFIX.length, -".json".length));
95039
+ }
95040
+ function requireStack(stackName, cwd = process.cwd()) {
95041
+ const stack = readStackOutputs(stackName, cwd);
95042
+ if (!stack) {
95043
+ const known = listStackNames(cwd);
95044
+ let hint = `Run \`hyperframes lambda deploy${stackName === DEFAULT_STACK_NAME ? "" : ` --stack-name=${stackName}`}\` first.`;
95045
+ if (known.length) {
95046
+ hint += ` Known stacks here: ${known.join(", ")}.`;
95047
+ }
95048
+ console.error(
95049
+ `[hyperframes lambda] no stack state for "${stackName}" at ${stateFilePath(stackName, cwd)}. ${hint}`
95050
+ );
95051
+ process.exit(1);
95052
+ }
95053
+ return stack;
95054
+ }
95055
+ var STATE_DIR_NAME, STATE_FILE_PREFIX, DEFAULT_STACK_NAME;
95056
+ var init_state = __esm({
95057
+ "src/commands/lambda/state.ts"() {
95058
+ "use strict";
95059
+ STATE_DIR_NAME = ".hyperframes";
95060
+ STATE_FILE_PREFIX = "lambda-stack-";
95061
+ DEFAULT_STACK_NAME = "hyperframes-default";
95062
+ }
95063
+ });
95064
+
95065
+ // src/commands/lambda/sam.ts
95066
+ import { execFileSync as execFileSync9, spawnSync as spawnSync4 } from "child_process";
95067
+ import { existsSync as existsSync70 } from "fs";
95068
+ import { join as join81 } from "path";
95069
+ function assertSamAvailable() {
95070
+ try {
95071
+ execFileSync9("sam", ["--version"], { stdio: "ignore" });
95072
+ } catch {
95073
+ throw new Error(
95074
+ "`sam` CLI not found on PATH. Install AWS SAM CLI from https://docs.aws.amazon.com/serverless-application-model/latest/developerguide/install-sam-cli.html and retry."
95075
+ );
95076
+ }
95077
+ }
95078
+ function assertAwsCliAvailable() {
95079
+ try {
95080
+ execFileSync9("aws", ["--version"], { stdio: "ignore" });
95081
+ } catch {
95082
+ throw new Error(
95083
+ "`aws` CLI not found on PATH. Install from https://docs.aws.amazon.com/cli/latest/userguide/getting-started-install.html and configure credentials before retrying."
95084
+ );
95085
+ }
95086
+ }
95087
+ function locateSamTemplate(repoRoot2) {
95088
+ const candidate = join81(repoRoot2, "examples", "aws-lambda", "template.yaml");
95089
+ if (!existsSync70(candidate)) {
95090
+ throw new Error(
95091
+ `[lambda] SAM template not found at ${candidate}. If you're running from an installed package, point --sam-template at your local copy of examples/aws-lambda/template.yaml.`
95092
+ );
95093
+ }
95094
+ return candidate;
95095
+ }
95096
+ function samDeploy(opts) {
95097
+ assertSamAvailable();
95098
+ const paramOverrides = [
95099
+ `ChromeSource=${opts.chromeSource ?? "sparticuz"}`,
95100
+ `ReservedConcurrency=${opts.reservedConcurrency ?? -1}`
95101
+ ];
95102
+ if (opts.lambdaMemoryMb !== void 0) {
95103
+ paramOverrides.push(`LambdaMemoryMb=${opts.lambdaMemoryMb}`);
95104
+ }
95105
+ const args = [
95106
+ "deploy",
95107
+ "--stack-name",
95108
+ opts.stackName,
95109
+ "--region",
95110
+ opts.region,
95111
+ "--resolve-s3",
95112
+ "--capabilities",
95113
+ "CAPABILITY_IAM",
95114
+ "--no-confirm-changeset",
95115
+ "--no-fail-on-empty-changeset",
95116
+ "--parameter-overrides",
95117
+ ...paramOverrides
95118
+ ];
95119
+ if (opts.awsProfile) {
95120
+ args.push("--profile", opts.awsProfile);
95121
+ }
95122
+ const samDir = join81(opts.repoRoot, "examples", "aws-lambda");
95123
+ const result = spawnSync4("sam", args, { cwd: samDir, stdio: opts.stdio ?? "inherit" });
95124
+ if (result.status !== 0) {
95125
+ throw new Error(`[lambda] sam deploy exited with code ${result.status ?? "unknown"}`);
95126
+ }
95127
+ }
95128
+ function samDelete(opts) {
95129
+ assertSamAvailable();
95130
+ const args = ["delete", "--stack-name", opts.stackName, "--region", opts.region, "--no-prompts"];
95131
+ if (opts.awsProfile) {
95132
+ args.push("--profile", opts.awsProfile);
95133
+ }
95134
+ const samDir = join81(opts.repoRoot, "examples", "aws-lambda");
95135
+ const result = spawnSync4("sam", args, { cwd: samDir, stdio: opts.stdio ?? "inherit" });
95136
+ if (result.status !== 0) {
95137
+ throw new Error(`[lambda] sam delete exited with code ${result.status ?? "unknown"}`);
95138
+ }
95139
+ }
95140
+ function fetchStackOutputs(opts) {
95141
+ assertAwsCliAvailable();
95142
+ const args = [
95143
+ "cloudformation",
95144
+ "describe-stacks",
95145
+ "--stack-name",
95146
+ opts.stackName,
95147
+ "--region",
95148
+ opts.region,
95149
+ "--query",
95150
+ "Stacks[0].Outputs",
95151
+ "--output",
95152
+ "json"
95153
+ ];
95154
+ if (opts.awsProfile) {
95155
+ args.unshift("--profile", opts.awsProfile);
95156
+ }
95157
+ const out = execFileSync9("aws", args, { encoding: "utf-8" });
95158
+ const parsed = JSON.parse(out);
95159
+ const byKey = new Map(parsed.map((o) => [o.OutputKey, o.OutputValue]));
95160
+ const bucketName = byKey.get("RenderBucketName");
95161
+ const functionName = byKey.get("RenderFunctionArn");
95162
+ const stateMachineArn = byKey.get("RenderStateMachineArn");
95163
+ if (!bucketName || !functionName || !stateMachineArn) {
95164
+ throw new Error(
95165
+ `[lambda] stack ${opts.stackName} is missing one of RenderBucketName/RenderFunctionArn/RenderStateMachineArn. Got keys: ${[...byKey.keys()].join(", ")}`
95166
+ );
95167
+ }
95168
+ return {
95169
+ bucketName,
95170
+ // RenderFunctionArn is the full ARN; the Lambda function name is the
95171
+ // last colon-segment, which downstream `getRenderProgress` calls use
95172
+ // for cost math + CloudWatch lookups.
95173
+ functionName: functionName.split(":").pop() ?? functionName,
95174
+ stateMachineArn
95175
+ };
95176
+ }
95177
+ var init_sam = __esm({
95178
+ "src/commands/lambda/sam.ts"() {
95179
+ "use strict";
95180
+ }
95181
+ });
95182
+
95183
+ // src/commands/lambda/repoRoot.ts
95184
+ import { existsSync as existsSync71 } from "fs";
95185
+ import { dirname as dirname29, resolve as resolve43 } from "path";
95186
+ import { fileURLToPath as fileURLToPath11 } from "url";
95187
+ function repoRoot() {
95188
+ const override = process.env.HYPERFRAMES_REPO_ROOT;
95189
+ if (override && existsSync71(resolve43(override, "packages", "aws-lambda", "package.json"))) {
95190
+ return override;
95191
+ }
95192
+ let dir = dirname29(fileURLToPath11(import.meta.url));
95193
+ for (let depth = 0; depth < 12; depth++) {
95194
+ if (existsSync71(resolve43(dir, "packages", "aws-lambda", "package.json"))) {
95195
+ return dir;
95196
+ }
95197
+ const parent = dirname29(dir);
95198
+ if (parent === dir) break;
95199
+ dir = parent;
95200
+ }
95201
+ throw new Error(
95202
+ "[hyperframes lambda] could not find the repo root (no packages/aws-lambda/ above this CLI's source). Run `hyperframes lambda` from within a hyperframes checkout, or set HYPERFRAMES_REPO_ROOT explicitly."
95203
+ );
95204
+ }
95205
+ var init_repoRoot = __esm({
95206
+ "src/commands/lambda/repoRoot.ts"() {
95207
+ "use strict";
95208
+ }
95209
+ });
95210
+
95211
+ // src/commands/lambda/deploy.ts
95212
+ var deploy_exports = {};
95213
+ __export(deploy_exports, {
95214
+ runDeploy: () => runDeploy
95215
+ });
95216
+ import { spawnSync as spawnSync5 } from "child_process";
95217
+ import { existsSync as existsSync72 } from "fs";
95218
+ import { join as join82, resolve as resolve44 } from "path";
95219
+ async function runDeploy(args = {}) {
95220
+ const resolved = {
95221
+ stackName: args.stackName ?? DEFAULT_STACK_NAME,
95222
+ region: args.region ?? process.env.AWS_REGION ?? DEFAULT_REGION,
95223
+ awsProfile: args.awsProfile ?? process.env.AWS_PROFILE,
95224
+ reservedConcurrency: args.reservedConcurrency ?? DEFAULT_CONCURRENCY,
95225
+ chromeSource: args.chromeSource ?? "sparticuz",
95226
+ lambdaMemoryMb: args.lambdaMemoryMb ?? DEFAULT_MEMORY_MB,
95227
+ skipBuild: args.skipBuild ?? false
95228
+ };
95229
+ const root = repoRoot();
95230
+ locateSamTemplate(root);
95231
+ if (!resolved.skipBuild) {
95232
+ console.log(c2.dim("\u2192 Building handler ZIP"));
95233
+ buildHandlerZip(root);
95234
+ } else {
95235
+ const zip = join82(root, "packages", "aws-lambda", "dist", "handler.zip");
95236
+ if (!existsSync72(zip)) {
95237
+ throw new Error(
95238
+ `--skip-build set but ${zip} does not exist. Run \`bun run --cwd packages/aws-lambda build:zip\` first or drop --skip-build.`
95239
+ );
95240
+ }
95241
+ }
95242
+ console.log(c2.dim(`\u2192 sam deploy (stack=${resolved.stackName} region=${resolved.region})`));
95243
+ samDeploy({
95244
+ repoRoot: root,
95245
+ stackName: resolved.stackName,
95246
+ region: resolved.region,
95247
+ awsProfile: resolved.awsProfile,
95248
+ reservedConcurrency: resolved.reservedConcurrency,
95249
+ lambdaMemoryMb: resolved.lambdaMemoryMb,
95250
+ chromeSource: resolved.chromeSource
95251
+ });
95252
+ console.log(c2.dim("\u2192 Reading stack outputs"));
95253
+ const outputs = fetchStackOutputs({
95254
+ stackName: resolved.stackName,
95255
+ region: resolved.region,
95256
+ awsProfile: resolved.awsProfile
95257
+ });
95258
+ const statePath = writeStackOutputs({
95259
+ stackName: resolved.stackName,
95260
+ region: resolved.region,
95261
+ bucketName: outputs.bucketName,
95262
+ stateMachineArn: outputs.stateMachineArn,
95263
+ functionName: outputs.functionName,
95264
+ lambdaMemoryMb: resolved.lambdaMemoryMb,
95265
+ deployedAt: (/* @__PURE__ */ new Date()).toISOString()
95266
+ });
95267
+ console.log();
95268
+ console.log(c2.success("Stack deployed."));
95269
+ console.log(` ${c2.dim("Bucket:")} ${outputs.bucketName}`);
95270
+ console.log(` ${c2.dim("State machine:")} ${outputs.stateMachineArn}`);
95271
+ console.log(` ${c2.dim("Function:")} ${outputs.functionName}`);
95272
+ console.log(` ${c2.dim("State file:")} ${resolve44(statePath)}`);
95273
+ console.log();
95274
+ console.log(c2.dim(`Render with: hyperframes lambda render <project-dir>`));
95275
+ }
95276
+ function buildHandlerZip(root) {
95277
+ const result = spawnSync5(
95278
+ "bun",
95279
+ ["run", "--cwd", join82(root, "packages", "aws-lambda"), "build:zip"],
95280
+ { stdio: "inherit" }
95281
+ );
95282
+ if (result.status !== 0) {
95283
+ throw new Error(
95284
+ `[lambda deploy] handler ZIP build exited with code ${result.status ?? "unknown"}`
95285
+ );
95286
+ }
95287
+ }
95288
+ var DEFAULT_REGION, DEFAULT_MEMORY_MB, DEFAULT_CONCURRENCY;
95289
+ var init_deploy = __esm({
95290
+ "src/commands/lambda/deploy.ts"() {
95291
+ "use strict";
95292
+ init_colors();
95293
+ init_sam();
95294
+ init_repoRoot();
95295
+ init_state();
95296
+ DEFAULT_REGION = "us-east-1";
95297
+ DEFAULT_MEMORY_MB = 10240;
95298
+ DEFAULT_CONCURRENCY = 8;
95299
+ }
95300
+ });
95301
+
95302
+ // src/commands/lambda/sites.ts
95303
+ var sites_exports = {};
95304
+ __export(sites_exports, {
95305
+ runSitesCreate: () => runSitesCreate
95306
+ });
95307
+ import { resolve as resolvePath } from "path";
95308
+ async function loadSDK() {
95309
+ return import("@hyperframes/aws-lambda/sdk");
95310
+ }
95311
+ async function runSitesCreate(args) {
95312
+ const stack = requireStack(args.stackName);
95313
+ const projectDir = resolvePath(args.projectDir);
95314
+ const { deploySite } = await loadSDK();
95315
+ const handle = await deploySite({
95316
+ projectDir,
95317
+ bucketName: stack.bucketName,
95318
+ region: stack.region,
95319
+ siteId: args.siteId
95320
+ });
95321
+ if (args.json) {
95322
+ console.log(JSON.stringify(handle, null, 2));
95323
+ return;
95324
+ }
95325
+ console.log(
95326
+ c2.success(handle.uploaded ? "Site uploaded." : "Site already up to date (skipped upload).")
95327
+ );
95328
+ console.log(` ${c2.dim("Site ID:")} ${handle.siteId}`);
95329
+ console.log(` ${c2.dim("S3 URI:")} ${handle.projectS3Uri}`);
95330
+ console.log(` ${c2.dim("Bytes:")} ${handle.bytes}`);
95331
+ console.log(` ${c2.dim("Uploaded at:")} ${handle.uploadedAt}`);
95332
+ console.log();
95333
+ console.log(
95334
+ c2.dim(
95335
+ `Render with: hyperframes lambda render ${args.projectDir} --site-id=${handle.siteId}` + (args.stackName === DEFAULT_STACK_NAME ? "" : ` --stack-name=${args.stackName}`)
95336
+ )
95337
+ );
95338
+ }
95339
+ var init_sites = __esm({
95340
+ "src/commands/lambda/sites.ts"() {
95341
+ "use strict";
95342
+ init_colors();
95343
+ init_state();
95344
+ }
95345
+ });
95346
+
95347
+ // src/commands/lambda/render.ts
95348
+ var render_exports2 = {};
95349
+ __export(render_exports2, {
95350
+ runRender: () => runRender
95351
+ });
95352
+ import { resolve as resolvePath2 } from "path";
95353
+ async function loadSDK2() {
95354
+ return import("@hyperframes/aws-lambda/sdk");
95355
+ }
95356
+ async function runRender(args) {
95357
+ const stack = requireStack(args.stackName);
95358
+ const projectDir = resolvePath2(args.projectDir);
95359
+ const config = {
95360
+ fps: args.fps,
95361
+ width: args.width,
95362
+ height: args.height,
95363
+ format: args.format,
95364
+ codec: args.codec,
95365
+ quality: args.quality,
95366
+ chunkSize: args.chunkSize,
95367
+ maxParallelChunks: args.maxParallelChunks,
95368
+ runtimeCap: "lambda"
95369
+ };
95370
+ const siteHandle = args.siteId ? {
95371
+ siteId: args.siteId,
95372
+ bucketName: stack.bucketName,
95373
+ projectS3Uri: `s3://${stack.bucketName}/sites/${args.siteId}/project.tar.gz`,
95374
+ bytes: 0,
95375
+ uploadedAt: "",
95376
+ uploaded: false
95377
+ } : void 0;
95378
+ const { renderToLambda } = await loadSDK2();
95379
+ const handle = await renderToLambda({
95380
+ projectDir: siteHandle ? void 0 : projectDir,
95381
+ siteHandle,
95382
+ bucketName: stack.bucketName,
95383
+ stateMachineArn: stack.stateMachineArn,
95384
+ region: stack.region,
95385
+ config,
95386
+ executionName: args.executionName,
95387
+ outputKey: args.outputKey
95388
+ });
95389
+ if (args.json) {
95390
+ if (args.wait) {
95391
+ await waitForCompletion(handle.executionArn, stack, args.waitIntervalMs, args.json);
95392
+ } else {
95393
+ console.log(JSON.stringify(handle, null, 2));
95394
+ }
95395
+ return;
95396
+ }
95397
+ console.log(c2.success("Render started."));
95398
+ console.log(` ${c2.dim("Render ID:")} ${handle.renderId}`);
95399
+ console.log(` ${c2.dim("Execution ARN:")} ${handle.executionArn}`);
95400
+ console.log(` ${c2.dim("Output S3 URI:")} ${handle.outputS3Uri}`);
95401
+ console.log(` ${c2.dim("Project S3:")} ${handle.projectS3Uri}`);
95402
+ console.log(` ${c2.dim("Stack state:")} ${stateFilePath(args.stackName)}`);
95403
+ console.log();
95404
+ if (args.wait) {
95405
+ await waitForCompletion(handle.executionArn, stack, args.waitIntervalMs, args.json);
95406
+ return;
95407
+ }
95408
+ console.log(c2.dim(`Poll with: hyperframes lambda progress ${handle.renderId}`));
95409
+ }
95410
+ async function waitForCompletion(executionArn, stack, intervalMs, json) {
95411
+ const { getRenderProgress } = await loadSDK2();
95412
+ let lastRendered = -1;
95413
+ while (true) {
95414
+ const progress = await getRenderProgress({
95415
+ executionArn,
95416
+ region: stack.region,
95417
+ defaultMemorySizeMb: stack.lambdaMemoryMb
95418
+ });
95419
+ if (!json && progress.framesRendered !== lastRendered) {
95420
+ lastRendered = progress.framesRendered;
95421
+ const total = progress.totalFrames ?? "?";
95422
+ const pct = Math.round(progress.overallProgress * 100);
95423
+ console.log(
95424
+ ` ${c2.dim(`[${progress.status}]`)} ${pct}% \u2022 ${progress.framesRendered}/${total} frames \u2022 ${progress.costs.displayCost}`
95425
+ );
95426
+ }
95427
+ if (progress.status !== "RUNNING") {
95428
+ if (json) {
95429
+ console.log(JSON.stringify(progress, null, 2));
95430
+ } else if (progress.status === "SUCCEEDED" && progress.outputFile) {
95431
+ console.log();
95432
+ console.log(c2.success("Render complete."));
95433
+ console.log(` ${c2.dim("Output:")} ${progress.outputFile.s3Uri}`);
95434
+ console.log(` ${c2.dim("Size:")} ${progress.outputFile.bytes ?? "?"} bytes`);
95435
+ console.log(` ${c2.dim("Total cost:")} ${progress.costs.displayCost}`);
95436
+ } else {
95437
+ console.log();
95438
+ console.log(c2.error(`Render ended with status ${progress.status}.`));
95439
+ for (const err of progress.errors) {
95440
+ console.log(` ${c2.dim(err.state)}: ${err.error} \u2014 ${err.cause}`);
95441
+ }
95442
+ process.exitCode = 1;
95443
+ }
95444
+ return;
95445
+ }
95446
+ await sleep2(intervalMs);
95447
+ }
95448
+ }
95449
+ function sleep2(ms) {
95450
+ return new Promise((res) => setTimeout(res, ms));
95451
+ }
95452
+ var init_render3 = __esm({
95453
+ "src/commands/lambda/render.ts"() {
95454
+ "use strict";
95455
+ init_colors();
95456
+ init_state();
95457
+ }
95458
+ });
95459
+
95460
+ // src/commands/lambda/progress.ts
95461
+ var progress_exports = {};
95462
+ __export(progress_exports, {
95463
+ runProgress: () => runProgress
95464
+ });
95465
+ async function runProgress(args) {
95466
+ const stack = requireStack(args.stackName);
95467
+ const executionArn = args.target.startsWith("arn:") ? args.target : executionArnFromName(stack.stateMachineArn, args.target);
95468
+ const { getRenderProgress } = await import("@hyperframes/aws-lambda/sdk");
95469
+ const progress = await getRenderProgress({
95470
+ executionArn,
95471
+ region: stack.region,
95472
+ defaultMemorySizeMb: stack.lambdaMemoryMb
95473
+ });
95474
+ if (args.json) {
95475
+ console.log(JSON.stringify(progress, null, 2));
95476
+ return;
95477
+ }
95478
+ const pct = Math.round(progress.overallProgress * 100);
95479
+ console.log(`${c2.dim("Status:")} ${statusColor(progress.status)}`);
95480
+ console.log(`${c2.dim("Progress:")} ${pct}%`);
95481
+ console.log(
95482
+ `${c2.dim("Frames:")} ${progress.framesRendered}${progress.totalFrames === null ? "" : ` / ${progress.totalFrames}`}`
95483
+ );
95484
+ console.log(`${c2.dim("Lambdas:")} ${progress.lambdasInvoked}`);
95485
+ console.log(
95486
+ `${c2.dim("Cost:")} ${progress.costs.displayCost} (Lambda $${progress.costs.breakdown.lambdaUsd.toFixed(4)} + SFN $${progress.costs.breakdown.stepFunctionsUsd.toFixed(4)})`
95487
+ );
95488
+ if (progress.outputFile) {
95489
+ console.log(`${c2.dim("Output:")} ${progress.outputFile.s3Uri}`);
95490
+ }
95491
+ if (progress.errors.length > 0) {
95492
+ console.log();
95493
+ console.log(c2.error("Errors:"));
95494
+ for (const err of progress.errors) {
95495
+ console.log(` ${c2.dim(err.state)}: ${err.error} \u2014 ${err.cause}`);
95496
+ }
95497
+ }
95498
+ if (progress.fatalErrorEncountered) {
95499
+ process.exitCode = 1;
95500
+ }
95501
+ }
95502
+ function executionArnFromName(stateMachineArn, name) {
95503
+ return stateMachineArn.replace(":stateMachine:", ":execution:") + `:${name}`;
95504
+ }
95505
+ function statusColor(status) {
95506
+ switch (status) {
95507
+ case "SUCCEEDED":
95508
+ return c2.success(status);
95509
+ case "FAILED":
95510
+ case "TIMED_OUT":
95511
+ case "ABORTED":
95512
+ return c2.error(status);
95513
+ default:
95514
+ return status;
95515
+ }
95516
+ }
95517
+ var init_progress2 = __esm({
95518
+ "src/commands/lambda/progress.ts"() {
95519
+ "use strict";
95520
+ init_colors();
95521
+ init_state();
95522
+ }
95523
+ });
95524
+
95525
+ // src/commands/lambda/destroy.ts
95526
+ var destroy_exports = {};
95527
+ __export(destroy_exports, {
95528
+ runDestroy: () => runDestroy
95529
+ });
95530
+ async function runDestroy(args) {
95531
+ const stack = requireStack(args.stackName);
95532
+ console.log(c2.dim(`\u2192 sam delete (stack=${stack.stackName} region=${stack.region})`));
95533
+ samDelete({
95534
+ repoRoot: repoRoot(),
95535
+ stackName: stack.stackName,
95536
+ region: stack.region,
95537
+ awsProfile: args.awsProfile ?? process.env.AWS_PROFILE
95538
+ });
95539
+ deleteStackOutputs(args.stackName);
95540
+ console.log();
95541
+ console.log(c2.success("Stack torn down."));
95542
+ console.log(
95543
+ c2.dim(
95544
+ `Note: the render bucket "${stack.bucketName}" was deployed with Retain \u2014 empty + delete it via the AWS console or CLI if you want to fully reclaim storage.`
95545
+ )
95546
+ );
95547
+ }
95548
+ var init_destroy = __esm({
95549
+ "src/commands/lambda/destroy.ts"() {
95550
+ "use strict";
95551
+ init_colors();
95552
+ init_state();
95553
+ init_sam();
95554
+ init_repoRoot();
95555
+ }
95556
+ });
95557
+
95558
+ // src/commands/lambda/policies.ts
95559
+ var policies_exports = {};
95560
+ __export(policies_exports, {
95561
+ REQUIRED_ACTIONS: () => REQUIRED_ACTIONS,
95562
+ allRequiredActions: () => allRequiredActions,
95563
+ buildPolicyDocument: () => buildPolicyDocument,
95564
+ buildRoleTrustPolicy: () => buildRoleTrustPolicy,
95565
+ runPolicies: () => runPolicies,
95566
+ validatePolicy: () => validatePolicy
95567
+ });
95568
+ import { readFileSync as readFileSync49 } from "fs";
95569
+ function allRequiredActions() {
95570
+ const set = /* @__PURE__ */ new Set();
95571
+ for (const group of Object.values(REQUIRED_ACTIONS)) {
95572
+ for (const action of group) set.add(action);
95573
+ }
95574
+ return [...set].sort();
95575
+ }
95576
+ function buildPolicyDocument() {
95577
+ return {
95578
+ Version: "2012-10-17",
95579
+ Statement: [
95580
+ {
95581
+ Effect: "Allow",
95582
+ Action: allRequiredActions(),
95583
+ Resource: "*"
95584
+ }
95585
+ ]
95586
+ };
95587
+ }
95588
+ function buildRoleTrustPolicy() {
95589
+ return {
95590
+ Version: "2012-10-17",
95591
+ Statement: [
95592
+ {
95593
+ Effect: "Allow",
95594
+ Principal: { Service: "cloudformation.amazonaws.com" },
95595
+ Action: "sts:AssumeRole"
95596
+ }
95597
+ ]
95598
+ };
95599
+ }
95600
+ async function runPolicies(args) {
95601
+ switch (args.verb) {
95602
+ case "user": {
95603
+ const doc = buildPolicyDocument();
95604
+ console.log(JSON.stringify(doc, null, 2));
95605
+ if (!args.json) {
95606
+ console.error(
95607
+ c2.dim(
95608
+ "\n# Attach the above as an inline policy to the IAM user/role that runs `hyperframes lambda *`.\n# Scope `Resource` to your stack's ARNs after the first successful deploy."
95609
+ )
95610
+ );
95611
+ }
95612
+ return;
95613
+ }
95614
+ case "role": {
95615
+ const trust = buildRoleTrustPolicy();
95616
+ const inline = buildPolicyDocument();
95617
+ const wrapped = {
95618
+ TrustRelationship: trust,
95619
+ InlinePolicy: inline
95620
+ };
95621
+ console.log(JSON.stringify(wrapped, null, 2));
95622
+ return;
95623
+ }
95624
+ case "validate": {
95625
+ if (!args.inputPath) {
95626
+ const msg = "[lambda policies validate] usage: hyperframes lambda policies validate <policy.json>";
95627
+ if (args.json) {
95628
+ console.log(JSON.stringify({ ok: false, error: msg }, null, 2));
95629
+ process.exitCode = 1;
95630
+ return;
95631
+ }
95632
+ throw new Error(msg);
95633
+ }
95634
+ let result;
95635
+ try {
95636
+ result = validatePolicy(args.inputPath);
95637
+ } catch (err) {
95638
+ const msg = err instanceof Error ? err.message : String(err);
95639
+ if (args.json) {
95640
+ console.log(JSON.stringify({ ok: false, error: msg }, null, 2));
95641
+ process.exitCode = 1;
95642
+ return;
95643
+ }
95644
+ console.error(c2.error(`Failed to validate ${args.inputPath}: ${msg}`));
95645
+ process.exitCode = 1;
95646
+ return;
95647
+ }
95648
+ if (args.json) {
95649
+ console.log(JSON.stringify({ ok: result.missing.length === 0, ...result }, null, 2));
95650
+ if (result.missing.length > 0) process.exitCode = 1;
95651
+ return;
95652
+ }
95653
+ for (const warning of result.warnings) {
95654
+ console.warn(c2.dim(`Warning: ${warning}`));
95655
+ }
95656
+ if (result.missing.length === 0) {
95657
+ console.log(c2.success(`Policy covers all ${result.required.length} required actions.`));
95658
+ return;
95659
+ }
95660
+ console.log(c2.error(`Policy is missing ${result.missing.length} required action(s):`));
95661
+ for (const action of result.missing) {
95662
+ console.log(` \u2022 ${action}`);
95663
+ }
95664
+ console.log();
95665
+ console.log(
95666
+ c2.dim("Run `hyperframes lambda policies user` to print the full required policy.")
95667
+ );
95668
+ process.exitCode = 1;
95669
+ return;
95670
+ }
95671
+ }
95672
+ }
95673
+ function validatePolicy(policyPath) {
95674
+ const raw = readFileSync49(policyPath, "utf-8");
95675
+ const parsed = JSON.parse(raw);
95676
+ const statements = Array.isArray(parsed.Statement) ? parsed.Statement : parsed.Statement ? [
95677
+ parsed.Statement
95678
+ ] : [];
95679
+ const grantedPatterns = [];
95680
+ const warnings = [];
95681
+ for (const stmt of statements) {
95682
+ if (stmt.Effect !== "Allow") continue;
95683
+ if (stmt.NotAction !== void 0) {
95684
+ warnings.push(
95685
+ "Allow statement uses NotAction; the validator only checks positive Action grants, so this statement is being ignored. Convert to an explicit Action list to validate it."
95686
+ );
95687
+ continue;
95688
+ }
95689
+ if (stmt.NotResource !== void 0) {
95690
+ warnings.push(
95691
+ "Allow statement uses NotResource; resource-scoping is not modelled by this validator. Treating the statement as fully granted on its Action set."
95692
+ );
95693
+ }
95694
+ const actions = stmt.Action;
95695
+ if (typeof actions === "string") {
95696
+ grantedPatterns.push(actions);
95697
+ } else if (Array.isArray(actions)) {
95698
+ for (const a of actions) if (typeof a === "string") grantedPatterns.push(a);
95699
+ }
95700
+ }
95701
+ for (const pattern of grantedPatterns) {
95702
+ if (hasMidStringWildcard(pattern)) {
95703
+ warnings.push(
95704
+ `Action pattern ${JSON.stringify(pattern)} contains a mid-string wildcard the validator can't expand; only end-anchored wildcards (\`*\`, \`service:*\`, \`prefix*\`) are honoured.`
95705
+ );
95706
+ }
95707
+ }
95708
+ const required = allRequiredActions();
95709
+ const granted = [];
95710
+ const missing = [];
95711
+ for (const action of required) {
95712
+ if (grantedPatterns.some((pattern) => actionMatches(pattern, action))) {
95713
+ granted.push(action);
95714
+ } else {
95715
+ missing.push(action);
95716
+ }
95717
+ }
95718
+ return { required, granted, missing, warnings };
95719
+ }
95720
+ function hasMidStringWildcard(pattern) {
95721
+ if (pattern === "*") return false;
95722
+ if (pattern.endsWith(":*")) return false;
95723
+ if (pattern.endsWith("*") && !pattern.slice(0, -1).includes("*")) return false;
95724
+ return pattern.includes("*") || pattern.includes("?");
95725
+ }
95726
+ function actionMatches(pattern, action) {
95727
+ if (pattern === "*") return true;
95728
+ if (pattern === action) return true;
95729
+ if (pattern.endsWith(":*")) {
95730
+ const service = pattern.slice(0, -2);
95731
+ return action.startsWith(`${service}:`);
95732
+ }
95733
+ if (pattern.endsWith("*")) {
95734
+ return action.startsWith(pattern.slice(0, -1));
95735
+ }
95736
+ return false;
95737
+ }
95738
+ var REQUIRED_ACTIONS;
95739
+ var init_policies = __esm({
95740
+ "src/commands/lambda/policies.ts"() {
95741
+ "use strict";
95742
+ init_colors();
95743
+ REQUIRED_ACTIONS = {
95744
+ cloudformation: [
95745
+ "cloudformation:CreateChangeSet",
95746
+ "cloudformation:CreateStack",
95747
+ "cloudformation:DeleteChangeSet",
95748
+ "cloudformation:DeleteStack",
95749
+ "cloudformation:DescribeChangeSet",
95750
+ "cloudformation:DescribeStackEvents",
95751
+ "cloudformation:DescribeStackResource",
95752
+ "cloudformation:DescribeStackResources",
95753
+ "cloudformation:DescribeStacks",
95754
+ "cloudformation:ExecuteChangeSet",
95755
+ "cloudformation:GetTemplate",
95756
+ "cloudformation:GetTemplateSummary",
95757
+ "cloudformation:ListStacks",
95758
+ "cloudformation:UpdateStack",
95759
+ "cloudformation:ValidateTemplate"
95760
+ ],
95761
+ cloudwatchAlarms: [
95762
+ "cloudwatch:DeleteAlarms",
95763
+ "cloudwatch:DescribeAlarms",
95764
+ "cloudwatch:PutMetricAlarm"
95765
+ ],
95766
+ iam: [
95767
+ "iam:AttachRolePolicy",
95768
+ "iam:CreateRole",
95769
+ "iam:DeleteRole",
95770
+ "iam:DeleteRolePolicy",
95771
+ "iam:DetachRolePolicy",
95772
+ "iam:GetRole",
95773
+ "iam:GetRolePolicy",
95774
+ "iam:PassRole",
95775
+ "iam:PutRolePolicy",
95776
+ "iam:TagRole",
95777
+ "iam:UntagRole"
95778
+ ],
95779
+ lambda: [
95780
+ "lambda:AddPermission",
95781
+ "lambda:CreateFunction",
95782
+ "lambda:DeleteFunction",
95783
+ "lambda:GetFunction",
95784
+ "lambda:GetFunctionConfiguration",
95785
+ "lambda:InvokeFunction",
95786
+ "lambda:ListFunctions",
95787
+ "lambda:PutFunctionConcurrency",
95788
+ "lambda:RemovePermission",
95789
+ "lambda:TagResource",
95790
+ "lambda:UntagResource",
95791
+ "lambda:UpdateFunctionCode",
95792
+ "lambda:UpdateFunctionConfiguration"
95793
+ ],
95794
+ logs: [
95795
+ "logs:CreateLogGroup",
95796
+ "logs:DeleteLogGroup",
95797
+ "logs:DescribeLogGroups",
95798
+ "logs:PutRetentionPolicy",
95799
+ "logs:TagResource"
95800
+ ],
95801
+ s3Bucket: [
95802
+ "s3:CreateBucket",
95803
+ "s3:DeleteBucket",
95804
+ "s3:DeleteBucketPolicy",
95805
+ "s3:GetBucketLocation",
95806
+ "s3:GetBucketPolicy",
95807
+ "s3:GetBucketTagging",
95808
+ "s3:GetBucketVersioning",
95809
+ "s3:GetLifecycleConfiguration",
95810
+ "s3:ListAllMyBuckets",
95811
+ "s3:ListBucket",
95812
+ "s3:PutBucketPolicy",
95813
+ "s3:PutBucketTagging",
95814
+ "s3:PutBucketVersioning",
95815
+ "s3:PutLifecycleConfiguration",
95816
+ "s3:PutPublicAccessBlock"
95817
+ ],
95818
+ s3Object: ["s3:DeleteObject", "s3:GetObject", "s3:PutObject"],
95819
+ states: [
95820
+ "states:CreateStateMachine",
95821
+ "states:DeleteStateMachine",
95822
+ "states:DescribeExecution",
95823
+ "states:DescribeStateMachine",
95824
+ "states:GetExecutionHistory",
95825
+ "states:ListExecutions",
95826
+ "states:ListStateMachines",
95827
+ "states:StartExecution",
95828
+ "states:StopExecution",
95829
+ "states:TagResource",
95830
+ "states:UntagResource",
95831
+ "states:UpdateStateMachine"
95832
+ ]
95833
+ };
95834
+ }
95835
+ });
95836
+
95837
+ // src/commands/lambda.ts
95838
+ var lambda_exports = {};
95839
+ __export(lambda_exports, {
95840
+ default: () => lambda_default,
95841
+ examples: () => examples24
95842
+ });
95843
+ function parseIntFlag(raw) {
95844
+ if (raw === void 0 || raw === null || raw === "") return void 0;
95845
+ const n = Number.parseInt(String(raw), 10);
95846
+ return Number.isFinite(n) ? n : void 0;
95847
+ }
95848
+ function parsePositiveInt(raw, flagName) {
95849
+ const n = parseIntFlag(raw);
95850
+ if (n === void 0) return void 0;
95851
+ if (!Number.isInteger(n) || n < 1) {
95852
+ throw new Error(`[lambda] ${flagName} must be a positive integer; got ${n}`);
95853
+ }
95854
+ return n;
95855
+ }
95856
+ function parseEnum(raw, allowed, errorPrefix, defaultValue) {
95857
+ if (raw === void 0 || raw === null || raw === "") return defaultValue;
95858
+ const s2 = String(raw);
95859
+ if (allowed.includes(s2)) return s2;
95860
+ throw new Error(`${errorPrefix} must be ${allowed.join("|")}; got ${s2}`);
95861
+ }
95862
+ var examples24, HELP, lambda_default, FORMATS, CODECS, QUALITIES2, CHROME_SOURCES, parseFormat, parseCodec, parseQuality, parseChromeSource;
95863
+ var init_lambda = __esm({
95864
+ "src/commands/lambda.ts"() {
95865
+ "use strict";
95866
+ init_dist();
95867
+ init_colors();
95868
+ examples24 = [
95869
+ ["Deploy the Lambda render stack to AWS", "hyperframes lambda deploy"],
95870
+ [
95871
+ "Render a composition on the deployed stack",
95872
+ "hyperframes lambda render ./my-project --width 1920 --height 1080"
95873
+ ],
95874
+ [
95875
+ "Render and stream progress until done",
95876
+ "hyperframes lambda render ./my-project --width 1920 --height 1080 --wait"
95877
+ ],
95878
+ ["Check progress for a started render", "hyperframes lambda progress hf-render-abcd1234"],
95879
+ [
95880
+ "Pre-upload a project so multiple renders share the upload",
95881
+ "hyperframes lambda sites create ./my-project"
95882
+ ],
95883
+ ["Tear the stack down", "hyperframes lambda destroy"],
95884
+ ["Print the IAM policy the CLI needs", "hyperframes lambda policies user"],
95885
+ [
95886
+ "Validate a checked-in IAM policy still covers the CLI",
95887
+ "hyperframes lambda policies validate ./infra/iam/hyperframes.json"
95888
+ ]
95889
+ ];
95890
+ HELP = `
95891
+ ${c2.bold("hyperframes lambda")} ${c2.dim("<subcommand> [args]")}
95892
+
95893
+ Deploy + drive distributed video renders on AWS Lambda.
95894
+
95895
+ ${c2.bold("SUBCOMMANDS:")}
95896
+ ${c2.accent("deploy")} ${c2.dim("Provision the Lambda + Step Functions + S3 stack via SAM")}
95897
+ ${c2.accent("sites create")} ${c2.dim("Tar + upload a project to S3 (reusable across renders)")}
95898
+ ${c2.accent("render")} ${c2.dim("Start a distributed render (returns a renderId)")}
95899
+ ${c2.accent("progress")} ${c2.dim("Print progress + cost for an in-flight or finished render")}
95900
+ ${c2.accent("destroy")} ${c2.dim("Tear the stack down (S3 bucket is retained)")}
95901
+ ${c2.accent("policies")} ${c2.dim("Print or validate the IAM permissions the CLI needs")}
95902
+
95903
+ ${c2.bold("FIRST RUN:")}
95904
+ ${c2.accent("hyperframes lambda deploy")}
95905
+ ${c2.accent("hyperframes lambda render ./my-project --width 1920 --height 1080 --wait")}
95906
+
95907
+ ${c2.bold("REQUIREMENTS:")}
95908
+ \u2022 AWS CLI configured (env vars, ~/.aws/credentials, or SSO)
95909
+ \u2022 AWS SAM CLI installed (https://docs.aws.amazon.com/serverless-application-model/latest/developerguide/install-sam-cli.html)
95910
+ \u2022 bun on PATH (used to build the handler ZIP)
95911
+ `;
95912
+ lambda_default = defineCommand({
95913
+ meta: { name: "lambda", description: "Deploy and drive renders on AWS Lambda" },
95914
+ args: {
95915
+ subcommand: {
95916
+ type: "positional",
95917
+ required: false,
95918
+ description: "deploy | sites | render | progress | destroy | policies"
95919
+ },
95920
+ target: {
95921
+ type: "positional",
95922
+ required: false,
95923
+ description: "Subcommand-specific positional (project dir, render id, policies verb, etc.)"
95924
+ },
95925
+ extra: {
95926
+ type: "positional",
95927
+ required: false,
95928
+ description: "Extra positional (e.g. `sites create <projectDir>` or `policies validate <policy.json>`)"
95929
+ },
95930
+ // Stack identity
95931
+ "stack-name": {
95932
+ type: "string",
95933
+ description: "CloudFormation stack name (default: hyperframes-default)"
95934
+ },
95935
+ region: { type: "string", description: "AWS region (default: AWS_REGION env or us-east-1)" },
95936
+ profile: { type: "string", description: "AWS profile name (default: AWS_PROFILE env)" },
95937
+ // deploy
95938
+ concurrency: { type: "string", description: "Lambda reserved concurrency (default: 8)" },
95939
+ "chrome-source": {
95940
+ type: "string",
95941
+ description: "sparticuz | chrome-headless-shell (default: sparticuz)"
95942
+ },
95943
+ memory: { type: "string", description: "Lambda memory MB (default: 10240)" },
95944
+ "skip-build": { type: "boolean", description: "Reuse existing handler.zip (deploy)" },
95945
+ // sites / render
95946
+ "site-id": { type: "string", description: "Explicit site id (overrides content hash)" },
95947
+ width: { type: "string", description: "Render width in pixels" },
95948
+ height: { type: "string", description: "Render height in pixels" },
95949
+ fps: { type: "string", description: "Render fps (24 | 30 | 60)" },
95950
+ format: { type: "string", description: "mp4 | mov | png-sequence (default: mp4)" },
95951
+ codec: { type: "string", description: "h264 | h265 (mp4 only)" },
95952
+ quality: { type: "string", description: "draft | standard | high" },
95953
+ "chunk-size": { type: "string", description: "Frames per chunk (default: 240)" },
95954
+ "max-parallel-chunks": { type: "string", description: "Max concurrent chunks (default: 16)" },
95955
+ "execution-name": {
95956
+ type: "string",
95957
+ description: "Step Functions execution name (default: hf-render-<uuid>)"
95958
+ },
95959
+ "output-key": {
95960
+ type: "string",
95961
+ description: "Final output S3 key (default: renders/<exec>/output.<ext>)"
95962
+ },
95963
+ wait: { type: "boolean", description: "Block until the render finishes" },
95964
+ "wait-interval-ms": {
95965
+ type: "string",
95966
+ description: "Poll cadence in ms when --wait is set (default: 5000)"
95967
+ },
95968
+ // shared
95969
+ json: { type: "boolean", description: "Emit machine-readable JSON" }
95970
+ },
95971
+ async run({ args }) {
95972
+ const subcommand = args.subcommand;
95973
+ if (!subcommand) {
95974
+ console.log(HELP);
95975
+ return;
95976
+ }
95977
+ const stackName = args["stack-name"] ?? // Lazy-imported so the dispatcher doesn't pull state.ts (and its
95978
+ // node:fs deps) on every CLI invocation — only on lambda runs.
95979
+ (await Promise.resolve().then(() => (init_state(), state_exports))).DEFAULT_STACK_NAME;
95980
+ const profileFlag = args.profile;
95981
+ if (profileFlag) process.env.AWS_PROFILE = profileFlag;
95982
+ const regionFlag = args.region;
95983
+ if (regionFlag) process.env.AWS_REGION = regionFlag;
95984
+ const verbsNeedingSDK = /* @__PURE__ */ new Set(["deploy", "sites", "render", "progress", "destroy"]);
95985
+ if (verbsNeedingSDK.has(subcommand)) {
95986
+ try {
95987
+ await import("@hyperframes/aws-lambda/sdk");
95988
+ } catch (err) {
95989
+ if (err.code === "ERR_MODULE_NOT_FOUND") {
95990
+ console.error(
95991
+ `${c2.error("@hyperframes/aws-lambda is not installed.")} The ${c2.accent(`hyperframes lambda ${subcommand}`)} command needs it at runtime.
95992
+ Install it alongside the CLI:
95993
+ ${c2.accent("npm install -g @hyperframes/aws-lambda")}
95994
+ Or, for an opt-in dev setup:
95995
+ ${c2.accent("npm install @hyperframes/aws-lambda")}`
95996
+ );
95997
+ process.exit(1);
95998
+ }
95999
+ throw err;
96000
+ }
96001
+ }
96002
+ switch (subcommand) {
96003
+ case "deploy": {
96004
+ const { runDeploy: runDeploy2 } = await Promise.resolve().then(() => (init_deploy(), deploy_exports));
96005
+ await runDeploy2({
96006
+ stackName,
96007
+ region: args.region,
96008
+ awsProfile: args.profile,
96009
+ reservedConcurrency: parsePositiveInt(args.concurrency, "--concurrency"),
96010
+ chromeSource: parseChromeSource(args["chrome-source"]),
96011
+ lambdaMemoryMb: parsePositiveInt(args.memory, "--memory"),
96012
+ skipBuild: Boolean(args["skip-build"])
96013
+ });
96014
+ return;
96015
+ }
96016
+ case "sites": {
96017
+ if (args.target !== "create") {
96018
+ console.error(
96019
+ `[lambda sites] unknown verb "${String(args.target)}". Only "create" is supported.`
96020
+ );
96021
+ process.exit(1);
96022
+ }
96023
+ const projectDir = args.extra;
96024
+ if (!projectDir) {
96025
+ console.error(
96026
+ "[lambda sites create] usage: hyperframes lambda sites create <projectDir>"
96027
+ );
96028
+ process.exit(1);
96029
+ }
96030
+ const { runSitesCreate: runSitesCreate2 } = await Promise.resolve().then(() => (init_sites(), sites_exports));
96031
+ await runSitesCreate2({
96032
+ projectDir,
96033
+ stackName,
96034
+ siteId: args["site-id"],
96035
+ json: Boolean(args.json)
96036
+ });
96037
+ return;
96038
+ }
96039
+ case "render": {
96040
+ const projectDir = args.target;
96041
+ if (!projectDir) {
96042
+ console.error(
96043
+ "[lambda render] usage: hyperframes lambda render <projectDir> --width <px> --height <px>"
96044
+ );
96045
+ process.exit(1);
96046
+ }
96047
+ const width = parsePositiveInt(args.width, "--width");
96048
+ const height = parsePositiveInt(args.height, "--height");
96049
+ if (width === void 0 || height === void 0) {
96050
+ console.error("[lambda render] --width and --height are required.");
96051
+ process.exit(1);
96052
+ }
96053
+ const fpsRaw = parseIntFlag(args.fps) ?? 30;
96054
+ if (fpsRaw !== 24 && fpsRaw !== 30 && fpsRaw !== 60) {
96055
+ console.error(`[lambda render] --fps must be 24, 30, or 60; got ${fpsRaw}.`);
96056
+ process.exit(1);
96057
+ }
96058
+ const { runRender: runRender2 } = await Promise.resolve().then(() => (init_render3(), render_exports2));
96059
+ await runRender2({
96060
+ projectDir,
96061
+ stackName,
96062
+ siteId: args["site-id"],
96063
+ fps: fpsRaw,
96064
+ width,
96065
+ height,
96066
+ format: parseFormat(args.format),
96067
+ codec: parseCodec(args.codec),
96068
+ quality: parseQuality(args.quality),
96069
+ chunkSize: parsePositiveInt(args["chunk-size"], "--chunk-size"),
96070
+ maxParallelChunks: parsePositiveInt(args["max-parallel-chunks"], "--max-parallel-chunks"),
96071
+ executionName: args["execution-name"],
96072
+ outputKey: args["output-key"],
96073
+ json: Boolean(args.json),
96074
+ wait: Boolean(args.wait),
96075
+ waitIntervalMs: parsePositiveInt(args["wait-interval-ms"], "--wait-interval-ms") ?? 5e3
96076
+ });
96077
+ return;
96078
+ }
96079
+ case "progress": {
96080
+ const target = args.target;
96081
+ if (!target) {
96082
+ console.error(
96083
+ "[lambda progress] usage: hyperframes lambda progress <renderId | executionArn>"
96084
+ );
96085
+ process.exit(1);
96086
+ }
96087
+ const { runProgress: runProgress2 } = await Promise.resolve().then(() => (init_progress2(), progress_exports));
96088
+ await runProgress2({ target, stackName, json: Boolean(args.json) });
96089
+ return;
96090
+ }
96091
+ case "destroy": {
96092
+ const { runDestroy: runDestroy2 } = await Promise.resolve().then(() => (init_destroy(), destroy_exports));
96093
+ await runDestroy2({ stackName, awsProfile: args.profile });
96094
+ return;
96095
+ }
96096
+ case "policies": {
96097
+ const verb = args.target;
96098
+ if (verb !== "role" && verb !== "user" && verb !== "validate") {
96099
+ console.error(
96100
+ `[lambda policies] usage: hyperframes lambda policies <role|user|validate> [args]`
96101
+ );
96102
+ process.exit(1);
96103
+ }
96104
+ const { runPolicies: runPolicies2 } = await Promise.resolve().then(() => (init_policies(), policies_exports));
96105
+ await runPolicies2({
96106
+ verb,
96107
+ inputPath: args.extra,
96108
+ json: Boolean(args.json)
96109
+ });
96110
+ return;
96111
+ }
96112
+ default:
96113
+ console.error(`${c2.error("Unknown subcommand:")} ${subcommand}
96114
+ ${HELP}`);
96115
+ process.exit(1);
96116
+ }
96117
+ }
96118
+ });
96119
+ FORMATS = ["mp4", "mov", "png-sequence"];
96120
+ CODECS = ["h264", "h265"];
96121
+ QUALITIES2 = ["draft", "standard", "high"];
96122
+ CHROME_SOURCES = ["sparticuz", "chrome-headless-shell"];
96123
+ parseFormat = (raw) => parseEnum(raw, FORMATS, "[lambda render] --format", "mp4");
96124
+ parseCodec = (raw) => parseEnum(raw, CODECS, "[lambda render] --codec", void 0);
96125
+ parseQuality = (raw) => parseEnum(raw, QUALITIES2, "[lambda render] --quality", void 0);
96126
+ parseChromeSource = (raw) => parseEnum(raw, CHROME_SOURCES, "[lambda deploy] --chrome-source", "sparticuz");
96127
+ }
96128
+ });
96129
+
94934
96130
  // src/telemetry/index.ts
94935
96131
  var telemetry_exports2 = {};
94936
96132
  __export(telemetry_exports2, {
@@ -95063,9 +96259,9 @@ __export(autoUpdate_exports, {
95063
96259
  scheduleBackgroundInstall: () => scheduleBackgroundInstall
95064
96260
  });
95065
96261
  import { spawn as spawn16 } from "child_process";
95066
- import { appendFileSync as appendFileSync2, mkdirSync as mkdirSync41, openSync as openSync2 } from "fs";
96262
+ import { appendFileSync as appendFileSync2, mkdirSync as mkdirSync42, openSync as openSync2 } from "fs";
95067
96263
  import { homedir as homedir12 } from "os";
95068
- import { join as join80 } from "path";
96264
+ import { join as join83 } from "path";
95069
96265
  import { compareVersions as compareVersions2 } from "compare-versions";
95070
96266
  function isAutoInstallDisabled() {
95071
96267
  if (isDevMode()) return true;
@@ -95080,15 +96276,15 @@ function majorOf(version) {
95080
96276
  }
95081
96277
  function log(line) {
95082
96278
  try {
95083
- mkdirSync41(CONFIG_DIR2, { recursive: true, mode: 448 });
96279
+ mkdirSync42(CONFIG_DIR2, { recursive: true, mode: 448 });
95084
96280
  appendFileSync2(LOG_FILE, `${(/* @__PURE__ */ new Date()).toISOString()} ${line}
95085
96281
  `, { mode: 384 });
95086
96282
  } catch {
95087
96283
  }
95088
96284
  }
95089
96285
  function launchDetachedInstall(installCommand, version) {
95090
- mkdirSync41(CONFIG_DIR2, { recursive: true, mode: 448 });
95091
- const configFile = join80(CONFIG_DIR2, "config.json");
96286
+ mkdirSync42(CONFIG_DIR2, { recursive: true, mode: 448 });
96287
+ const configFile = join83(CONFIG_DIR2, "config.json");
95092
96288
  const nodeScript = `
95093
96289
  const { exec } = require("node:child_process");
95094
96290
  const { readFileSync, renameSync, writeFileSync } = require("node:fs");
@@ -95207,8 +96403,8 @@ var init_autoUpdate = __esm({
95207
96403
  init_config();
95208
96404
  init_env();
95209
96405
  init_installerDetection();
95210
- CONFIG_DIR2 = join80(homedir12(), ".hyperframes");
95211
- LOG_FILE = join80(CONFIG_DIR2, "auto-update.log");
96406
+ CONFIG_DIR2 = join83(homedir12(), ".hyperframes");
96407
+ LOG_FILE = join83(CONFIG_DIR2, "auto-update.log");
95212
96408
  PENDING_TIMEOUT_MS = 10 * 60 * 1e3;
95213
96409
  }
95214
96410
  });
@@ -95286,10 +96482,10 @@ function renderRootHelp() {
95286
96482
  lines.push(`Run ${c2.cyan("hyperframes <command> --help")} for more information about a command.`);
95287
96483
  return lines.join("\n");
95288
96484
  }
95289
- function formatExamples(examples24) {
96485
+ function formatExamples(examples25) {
95290
96486
  const lines = [];
95291
96487
  lines.push(c2.bold("Examples:"));
95292
- for (const [comment, command2] of examples24) {
96488
+ for (const [comment, command2] of examples25) {
95293
96489
  lines.push(` ${c2.gray(`# ${comment}`)}`);
95294
96490
  lines.push(` ${command2}`);
95295
96491
  lines.push("");
@@ -95306,9 +96502,9 @@ async function showUsage2(cmd, parent) {
95306
96502
  console.log(usage + "\n");
95307
96503
  const name = meta?.name;
95308
96504
  if (name) {
95309
- const examples24 = STATIC_EXAMPLES[name] ?? await loadExamples(name);
95310
- if (examples24) {
95311
- console.log(formatExamples(examples24) + "\n");
96505
+ const examples25 = STATIC_EXAMPLES[name] ?? await loadExamples(name);
96506
+ if (examples25) {
96507
+ console.log(formatExamples(examples25) + "\n");
95312
96508
  }
95313
96509
  }
95314
96510
  }
@@ -95356,6 +96552,10 @@ var init_help = __esm({
95356
96552
  ["upgrade", "Check for updates and show upgrade instructions"]
95357
96553
  ]
95358
96554
  },
96555
+ {
96556
+ title: "Deploy",
96557
+ commands: [["lambda", "Deploy and drive distributed renders on AWS Lambda"]]
96558
+ },
95359
96559
  {
95360
96560
  title: "AI & Integrations",
95361
96561
  commands: [
@@ -95392,17 +96592,17 @@ var init_help = __esm({
95392
96592
  // src/cli.ts
95393
96593
  init_version();
95394
96594
  init_dist();
95395
- import { dirname as dirname27, join as join81 } from "path";
95396
- import { fileURLToPath as fileURLToPath11 } from "url";
95397
- import { existsSync as existsSync69 } from "fs";
96595
+ import { dirname as dirname30, join as join84 } from "path";
96596
+ import { fileURLToPath as fileURLToPath12 } from "url";
96597
+ import { existsSync as existsSync73 } from "fs";
95398
96598
  (() => {
95399
- const here = dirname27(fileURLToPath11(import.meta.url));
95400
- const shader = join81(here, "shaderTransitionWorker.js");
95401
- const png = join81(here, "pngDecodeBlitWorker.js");
95402
- if (!process.env.HF_SHADER_WORKER_ENTRY && existsSync69(shader)) {
96599
+ const here = dirname30(fileURLToPath12(import.meta.url));
96600
+ const shader = join84(here, "shaderTransitionWorker.js");
96601
+ const png = join84(here, "pngDecodeBlitWorker.js");
96602
+ if (!process.env.HF_SHADER_WORKER_ENTRY && existsSync73(shader)) {
95403
96603
  process.env.HF_SHADER_WORKER_ENTRY = shader;
95404
96604
  }
95405
- if (!process.env.HF_PNG_DECODE_BLIT_WORKER_ENTRY && existsSync69(png)) {
96605
+ if (!process.env.HF_PNG_DECODE_BLIT_WORKER_ENTRY && existsSync73(png)) {
95406
96606
  process.env.HF_PNG_DECODE_BLIT_WORKER_ENTRY = png;
95407
96607
  }
95408
96608
  })();
@@ -95439,7 +96639,8 @@ var subCommands = {
95439
96639
  telemetry: () => Promise.resolve().then(() => (init_telemetry(), telemetry_exports)).then((m2) => m2.default),
95440
96640
  validate: () => Promise.resolve().then(() => (init_validate(), validate_exports)).then((m2) => m2.default),
95441
96641
  snapshot: () => Promise.resolve().then(() => (init_snapshot(), snapshot_exports)).then((m2) => m2.default),
95442
- capture: () => Promise.resolve().then(() => (init_capture2(), capture_exports2)).then((m2) => m2.default)
96642
+ capture: () => Promise.resolve().then(() => (init_capture2(), capture_exports2)).then((m2) => m2.default),
96643
+ lambda: () => Promise.resolve().then(() => (init_lambda(), lambda_exports)).then((m2) => m2.default)
95443
96644
  };
95444
96645
  var main = defineCommand({
95445
96646
  meta: {