@hyperframes/producer 0.9.66 → 0.9.67

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
package/dist/index.js CHANGED
@@ -9,7 +9,7 @@ import {
9
9
  // src/services/renderOrchestrator.ts
10
10
  import { audioFailureDiagnostics as audioFailureDiagnostics2, usableCpuCount as usableCpuCount2 } from "@hyperframes/engine";
11
11
  import {
12
- existsSync as existsSync21,
12
+ existsSync as existsSync22,
13
13
  mkdirSync as mkdirSync12,
14
14
  readdirSync as readdirSync6,
15
15
  rmSync as rmSync12,
@@ -18,7 +18,7 @@ import {
18
18
  copyFileSync as copyFileSync5,
19
19
  appendFileSync
20
20
  } from "fs";
21
- import { tmpdir as tmpdir2 } from "node:os";
21
+ import { tmpdir as tmpdir3 } from "node:os";
22
22
  import {
23
23
  chainCapture,
24
24
  fpsToNumber as fpsToNumber8,
@@ -360,7 +360,7 @@ import {
360
360
  referenceBackgroundResult,
361
361
  createReferenceBackgroundRecorder
362
362
  } from "@hyperframes/engine";
363
- import { join as join32, dirname as dirname14, resolve as resolve8 } from "path";
363
+ import { join as join33, dirname as dirname14, resolve as resolve9 } from "path";
364
364
  import { totalmem as totalmem2 } from "node:os";
365
365
  import { randomUUID } from "crypto";
366
366
  import { fileURLToPath as fileURLToPath4 } from "url";
@@ -1267,13 +1267,13 @@ function createFileServer(options) {
1267
1267
  if (!streamOwnsFd) closeSync(fd);
1268
1268
  }
1269
1269
  });
1270
- return new Promise((resolve13, reject) => {
1270
+ return new Promise((resolve14, reject) => {
1271
1271
  const connections = /* @__PURE__ */ new Set();
1272
1272
  const server = serve({ fetch: app.fetch, port, hostname: "127.0.0.1" }, (info) => {
1273
1273
  const bound = port === 0 ? settleOnBrowserSafePort(server, "127.0.0.1") : Promise.resolve(info.port);
1274
1274
  bound.then((boundPort) => {
1275
1275
  listeningPort = boundPort;
1276
- resolve13({
1276
+ resolve14({
1277
1277
  url: `http://localhost:${boundPort}`,
1278
1278
  port: boundPort,
1279
1279
  addPreHeadScript: (script) => {
@@ -1839,10 +1839,96 @@ function buildRenderErrorDetails(input) {
1839
1839
  perfStages: Object.keys(input.perfStages).length > 0 ? { ...input.perfStages } : void 0,
1840
1840
  hdrDiagnostics: input.hdrDiagnostics.videoExtractionFailures > 0 || input.hdrDiagnostics.imageDecodeFailures > 0 ? { ...input.hdrDiagnostics } : void 0,
1841
1841
  observability: input.observability,
1842
- subTimelineWait: input.subTimelineWait
1842
+ subTimelineWait: input.subTimelineWait,
1843
+ missingPath: input.missingPath
1843
1844
  };
1844
1845
  }
1845
1846
 
1847
+ // src/services/render/missingPath.ts
1848
+ import { existsSync as existsSync4, lstatSync, readlinkSync } from "node:fs";
1849
+ import { tmpdir } from "node:os";
1850
+ import { basename as basename3, join as join4, relative as relative2, resolve as resolve4, isAbsolute as isAbsolute2, sep as sep3 } from "node:path";
1851
+ import { errnoMissingPathOf } from "@hyperframes/core/missing-path";
1852
+ var SYNCED = /onedrive|dropbox|icloud|mobile documents|clouddocs|google ?drive|cloudstorage/i;
1853
+ var inside = (path, folder) => {
1854
+ const rel = relative2(resolve4(folder), resolve4(path));
1855
+ return rel === "" || !rel.startsWith("..") && !isAbsolute2(rel);
1856
+ };
1857
+ function lstatOrNull(path) {
1858
+ try {
1859
+ return lstatSync(path);
1860
+ } catch {
1861
+ return null;
1862
+ }
1863
+ }
1864
+ var ROOT_SCOPES = [
1865
+ ["tempRoot", "temp_root"],
1866
+ ["cacheDir", "cache_root"],
1867
+ ["workDir", "work_dir"]
1868
+ ];
1869
+ var NAME_SCOPES = [
1870
+ [/\.partial/, "cache_partial"],
1871
+ [/^hfcache-/, "cache_entry"],
1872
+ [/^hyperframes-extract-cache/, "cache_root"],
1873
+ [/^(hf-render-|work-[0-9a-f]{8}-)/, "work_dir"]
1874
+ ];
1875
+ function scopeOfGone(path, where, throughLink) {
1876
+ const root = ROOT_SCOPES.find(([key]) => {
1877
+ const dir = where[key];
1878
+ return !!dir && resolve4(path) === resolve4(dir);
1879
+ });
1880
+ if (root) return root[1];
1881
+ const name = basename3(path);
1882
+ return NAME_SCOPES.find(([pattern]) => pattern.test(name))?.[1] ?? (throughLink ? "link_target" : "other");
1883
+ }
1884
+ var MAX_LINK_HOPS = 4;
1885
+ function rootOf(path, where) {
1886
+ if (inside(path, where.tempRoot)) return "system_temp";
1887
+ if (where.cacheDir && inside(path, where.cacheDir)) return "cache_dir";
1888
+ return "other";
1889
+ }
1890
+ var ownerOf = (path, where) => [where.tempRoot, where.cacheDir, where.workDir].filter((root) => !!root && inside(path, root)).sort((a, b) => resolve4(a).length - resolve4(b).length)[0];
1891
+ var linkTarget = (link, folder) => resolve4(folder, readlinkSync(link).replace(/^\\\\\?\\/, ""));
1892
+ function goneAt(path, last, where, hops) {
1893
+ const scope = scopeOfGone(path, where, hops > 0);
1894
+ return last && scope === "other" ? "file" : scope;
1895
+ }
1896
+ function highestGone(path, where, hops = 0) {
1897
+ const root = ownerOf(path, where);
1898
+ if (!root || hops > MAX_LINK_HOPS) return "link_target";
1899
+ if (!existsSync4(root)) return scopeOfGone(root, where, hops > 0);
1900
+ const parts = relative2(resolve4(root), resolve4(path)).split(sep3).filter(Boolean);
1901
+ let at = resolve4(root);
1902
+ for (const [index, part] of parts.entries()) {
1903
+ const next = join4(at, part);
1904
+ const stat = lstatOrNull(next);
1905
+ if (!stat) return goneAt(next, index === parts.length - 1, where, hops);
1906
+ at = stat.isSymbolicLink() ? linkTarget(next, at) : next;
1907
+ const gone = at === next ? void 0 : highestGone(at, where, hops + 1);
1908
+ if (gone) return gone;
1909
+ }
1910
+ return void 0;
1911
+ }
1912
+ var isSpawnFailure = (error) => !!error?.syscall?.startsWith("spawn");
1913
+ function describeMissingPath(error, {
1914
+ cacheDir,
1915
+ workDir,
1916
+ tempRoot = tmpdir()
1917
+ } = {}) {
1918
+ try {
1919
+ const path = errnoMissingPathOf(error);
1920
+ if (!path || isSpawnFailure(error)) return void 0;
1921
+ const where = { tempRoot, cacheDir, workDir };
1922
+ return {
1923
+ scope: ownerOf(path, where) ? highestGone(path, where) ?? "other" : scopeOfGone(path, where, false),
1924
+ synced: SYNCED.test(path),
1925
+ root: rootOf(path, where)
1926
+ };
1927
+ } catch {
1928
+ return void 0;
1929
+ }
1930
+ }
1931
+
1846
1932
  // src/services/render/renderEventPublisher.ts
1847
1933
  import { cloneCaptureWarnings } from "@hyperframes/engine";
1848
1934
  var FLUSH_TIMEOUT_MS = 1e4;
@@ -1878,8 +1964,8 @@ var OrderedRenderEventPublisher = class {
1878
1964
  let timer;
1879
1965
  const drained = await Promise.race([
1880
1966
  this.tail.then(() => true),
1881
- new Promise((resolve13) => {
1882
- timer = setTimeout(() => resolve13(false), FLUSH_TIMEOUT_MS);
1967
+ new Promise((resolve14) => {
1968
+ timer = setTimeout(() => resolve14(false), FLUSH_TIMEOUT_MS);
1883
1969
  })
1884
1970
  ]);
1885
1971
  clearTimeout(timer);
@@ -1983,8 +2069,8 @@ var RenderExecutionContext = class {
1983
2069
  };
1984
2070
 
1985
2071
  // src/services/render/artifactTransaction.ts
1986
- import { closeSync as closeSync2, existsSync as existsSync5, fstatSync as fstatSync2, openSync as openSync2, readSync, readdirSync as readdirSync2, rmSync as rmSync3 } from "node:fs";
1987
- import { basename as basename4, dirname as dirname4, extname as extname2, join as join5, resolve as resolve4 } from "node:path";
2072
+ import { closeSync as closeSync2, existsSync as existsSync6, fstatSync as fstatSync2, openSync as openSync2, readSync, readdirSync as readdirSync2, rmSync as rmSync3 } from "node:fs";
2073
+ import { basename as basename5, dirname as dirname4, extname as extname2, join as join6, resolve as resolve5 } from "node:path";
1988
2074
  import { HLS_MASTER_PLAYLIST, HLS_VIDEO_PLAYLIST, renameWithRetry } from "@hyperframes/engine";
1989
2075
 
1990
2076
  // src/utils/ffprobe.ts
@@ -1996,16 +2082,16 @@ import {
1996
2082
 
1997
2083
  // src/services/render/renderDirOwner.ts
1998
2084
  import {
1999
- existsSync as existsSync4,
2000
- lstatSync,
2085
+ existsSync as existsSync5,
2086
+ lstatSync as lstatSync2,
2001
2087
  readFileSync as readFileSync2,
2002
2088
  readdirSync,
2003
- readlinkSync,
2089
+ readlinkSync as readlinkSync2,
2004
2090
  rmSync as rmSync2,
2005
2091
  writeFileSync as writeFileSync2
2006
2092
  } from "node:fs";
2007
2093
  import { hostname, uptime } from "node:os";
2008
- import { basename as basename3, dirname as dirname3, join as join4 } from "node:path";
2094
+ import { basename as basename4, dirname as dirname3, join as join5 } from "node:path";
2009
2095
  import { RENDER_TEMP_DIR } from "@hyperframes/core/project-folders";
2010
2096
  import { createStagingDir } from "@hyperframes/core/atomic-file";
2011
2097
  var OWNER_FILE = "owner.json";
@@ -2023,13 +2109,13 @@ function pidScope() {
2023
2109
  host: hostname(),
2024
2110
  // Without /proc (macOS, Windows) the boot time, to the minute, stands in for the boot id.
2025
2111
  boot: attempt(() => readFileSync2("/proc/sys/kernel/random/boot_id", "utf-8").trim()) ?? attempt(() => String(Math.round(Date.now() / 6e4 - uptime() / 60))),
2026
- pidns: attempt(() => readlinkSync("/proc/self/ns/pid"))
2112
+ pidns: attempt(() => readlinkSync2("/proc/self/ns/pid"))
2027
2113
  };
2028
2114
  }
2029
2115
  function createOwnedRenderDir(prefix) {
2030
- const dir = createStagingDir(dirname3(prefix), basename3(prefix));
2116
+ const dir = createStagingDir(dirname3(prefix), basename4(prefix));
2031
2117
  const owner = { pid: process.pid, ...pidScope() };
2032
- writeFileSync2(join4(dir, OWNER_FILE), JSON.stringify(owner));
2118
+ writeFileSync2(join5(dir, OWNER_FILE), JSON.stringify(owner));
2033
2119
  return dir;
2034
2120
  }
2035
2121
  function alive(pid) {
@@ -2052,7 +2138,7 @@ function inThisPidScope(owner) {
2052
2138
  function ownerState(dir) {
2053
2139
  let owner;
2054
2140
  try {
2055
- owner = JSON.parse(readFileSync2(join4(dir, OWNER_FILE), "utf-8"));
2141
+ owner = JSON.parse(readFileSync2(join5(dir, OWNER_FILE), "utf-8"));
2056
2142
  } catch (error) {
2057
2143
  return error.code === "ENOENT" ? "none" : "unknown";
2058
2144
  }
@@ -2063,16 +2149,16 @@ function ownerState(dir) {
2063
2149
  return alive(pid) ? "live" : "gone";
2064
2150
  }
2065
2151
  function newestWriteMs(path) {
2066
- const stat = lstatSync(path);
2152
+ const stat = lstatSync2(path);
2067
2153
  if (!stat.isDirectory()) return stat.mtimeMs;
2068
2154
  return readdirSync(path).reduce(
2069
- (newest, name) => Math.max(newest, newestWriteMs(join4(path, name))),
2155
+ (newest, name) => Math.max(newest, newestWriteMs(join5(path, name))),
2070
2156
  stat.mtimeMs
2071
2157
  );
2072
2158
  }
2073
2159
  function isAbandoned(dir, ownerlessIdleMs, now) {
2074
2160
  try {
2075
- if (!lstatSync(dir).isDirectory() || existsSync4(join4(dir, TRANSACTION_BACKUP))) return false;
2161
+ if (!lstatSync2(dir).isDirectory() || existsSync5(join5(dir, TRANSACTION_BACKUP))) return false;
2076
2162
  const owner = ownerState(dir);
2077
2163
  if (owner === "gone") return true;
2078
2164
  return owner === "none" && ownerlessIdleMs !== void 0 && now - newestWriteMs(dir) >= ownerlessIdleMs;
@@ -2088,7 +2174,7 @@ function listAbandonedRenderDirs(parent, options = {}) {
2088
2174
  return [];
2089
2175
  }
2090
2176
  const now = Date.now();
2091
- return names.filter((name) => (options.names ?? RENDER_TEMP_DIR).test(name)).map((name) => join4(parent, name)).filter((dir) => isAbandoned(dir, options.ownerlessIdleMs, now));
2177
+ return names.filter((name) => (options.names ?? RENDER_TEMP_DIR).test(name)).map((name) => join5(parent, name)).filter((dir) => isAbandoned(dir, options.ownerlessIdleMs, now));
2092
2178
  }
2093
2179
  function createRenderWorkDir(prefix, outputDir) {
2094
2180
  for (const parent of /* @__PURE__ */ new Set([outputDir, dirname3(prefix)])) {
@@ -2104,7 +2190,7 @@ function createRenderWorkDir(prefix, outputDir) {
2104
2190
 
2105
2191
  // src/services/render/artifactTransaction.ts
2106
2192
  var defaultFileSystem = {
2107
- existsSync: existsSync5,
2193
+ existsSync: existsSync6,
2108
2194
  renameSync: (source, destination) => renameWithRetry(source, destination),
2109
2195
  rmSync: rmSync3
2110
2196
  };
@@ -2137,8 +2223,8 @@ function buildArtifactExpectation(input) {
2137
2223
  function createSiblingTransactionDirectory(destination) {
2138
2224
  const parent = dirname4(destination);
2139
2225
  const extension = extname2(destination);
2140
- const stem = extension ? basename4(destination, extension) : basename4(destination);
2141
- return createOwnedRenderDir(join5(parent, `.${stem}.hf-transaction-`));
2226
+ const stem = extension ? basename5(destination, extension) : basename5(destination);
2227
+ return createOwnedRenderDir(join6(parent, `.${stem}.hf-transaction-`));
2142
2228
  }
2143
2229
  function assertReadableNonEmptyFile(path) {
2144
2230
  const fd = openSync2(path, "r");
@@ -2156,7 +2242,7 @@ function collectDirectoryFiles(root) {
2156
2242
  const files = [];
2157
2243
  const visit = (directory) => {
2158
2244
  for (const entry of readdirSync2(directory, { withFileTypes: true })) {
2159
- const path = join5(directory, entry.name);
2245
+ const path = join6(directory, entry.name);
2160
2246
  if (entry.isDirectory()) visit(path);
2161
2247
  else if (entry.isFile()) files.push(path);
2162
2248
  }
@@ -2211,10 +2297,10 @@ var ArtifactTransaction = class {
2211
2297
  this.kind = kind;
2212
2298
  this.fileSystem = fileSystem;
2213
2299
  this.logger = logger;
2214
- this.destinationPath = resolve4(destinationPath);
2300
+ this.destinationPath = resolve5(destinationPath);
2215
2301
  this.transactionDirectory = createSiblingTransactionDirectory(this.destinationPath);
2216
- this.stagingPath = join5(this.transactionDirectory, basename4(this.destinationPath));
2217
- this.backupPath = join5(this.transactionDirectory, TRANSACTION_BACKUP);
2302
+ this.stagingPath = join6(this.transactionDirectory, basename5(this.destinationPath));
2303
+ this.backupPath = join6(this.transactionDirectory, TRANSACTION_BACKUP);
2218
2304
  this.durationProbe = durationProbe;
2219
2305
  }
2220
2306
  kind;
@@ -2257,19 +2343,19 @@ var ArtifactTransaction = class {
2257
2343
  */
2258
2344
  async assertDirectoryExpectation(expected, files) {
2259
2345
  for (const required of expected.requiredFiles ?? []) {
2260
- const path = join5(this.stagingPath, required);
2261
- if (!existsSync5(path)) {
2346
+ const path = join6(this.stagingPath, required);
2347
+ if (!existsSync6(path)) {
2262
2348
  throw new Error(`Render artifact directory is missing ${required}: ${this.stagingPath}`);
2263
2349
  }
2264
2350
  assertReadableNonEmptyFile(path);
2265
2351
  }
2266
2352
  if (expected.probeTarget !== void 0) {
2267
- await this.assertArtifactDuration(expected, join5(this.stagingPath, expected.probeTarget));
2353
+ await this.assertArtifactDuration(expected, join6(this.stagingPath, expected.probeTarget));
2268
2354
  return;
2269
2355
  }
2270
2356
  if (expected.expectedFrames === void 0) return;
2271
2357
  const frameCount = files.filter(
2272
- (file) => dirname4(file) === this.stagingPath && /^frame_\d+\.png$/.test(basename4(file))
2358
+ (file) => dirname4(file) === this.stagingPath && /^frame_\d+\.png$/.test(basename5(file))
2273
2359
  ).length;
2274
2360
  if (frameCount === 0) {
2275
2361
  throw new Error(
@@ -2507,8 +2593,8 @@ function replanAfterFailure(plan2, failure) {
2507
2593
  }
2508
2594
 
2509
2595
  // src/services/render/stages/captureSegmentedStage.ts
2510
- import { existsSync as existsSync6, mkdirSync as mkdirSync3, rmSync as rmSync6, statSync as statSync4 } from "node:fs";
2511
- import { join as join9 } from "node:path";
2596
+ import { existsSync as existsSync7, mkdirSync as mkdirSync3, rmSync as rmSync6, statSync as statSync4 } from "node:fs";
2597
+ import { join as join10 } from "node:path";
2512
2598
  import {
2513
2599
  captureFrameToBuffer as captureFrameToBuffer2,
2514
2600
  closeCaptureSession as closeCaptureSession2,
@@ -2929,7 +3015,7 @@ import {
2929
3015
 
2930
3016
  // src/services/hdrCompositor.ts
2931
3017
  import { readSync as readSync2 } from "fs";
2932
- import { join as join6 } from "path";
3018
+ import { join as join7 } from "path";
2933
3019
  import {
2934
3020
  captureAlphaPng,
2935
3021
  applyDomLayerMask,
@@ -3369,7 +3455,7 @@ async function compositeHdrFrame(ctx, canvas, time, fullStacking, elementFilter,
3369
3455
  if (shouldLog && debugDumpDir) {
3370
3456
  const after = countNonZeroRgb48(canvas);
3371
3457
  const dumpName = `frame_${String(debugFrameIndex).padStart(4, "0")}_layer_${String(layerIdx).padStart(2, "0")}_dom.png`;
3372
- const dumpPath = join6(debugDumpDir, dumpName);
3458
+ const dumpPath = join7(debugDumpDir, dumpName);
3373
3459
  writeFileExclusiveSync(dumpPath, domPng);
3374
3460
  log.info("[diag] dom layer blit", {
3375
3461
  frame: debugFrameIndex,
@@ -3424,7 +3510,7 @@ import { fpsToFfmpegArg, fpsToNumber as fpsToNumber3 } from "@hyperframes/core";
3424
3510
 
3425
3511
  // src/services/hdrFrameWindows.ts
3426
3512
  import { closeSync as closeSync3, constants as constants2, openSync as openSync3, rmSync as rmSync4 } from "node:fs";
3427
- import { join as join7 } from "node:path";
3513
+ import { join as join8 } from "node:path";
3428
3514
  function createHdrFrameWindows(opts) {
3429
3515
  const { dir, frameSize, windowFrames, maxResident, extract } = opts;
3430
3516
  let totalFrames = opts.totalFrames;
@@ -3448,7 +3534,7 @@ function createHdrFrameWindows(opts) {
3448
3534
  const firstFrame = index * windowFrames;
3449
3535
  const w = {
3450
3536
  firstFrame,
3451
- path: join7(dir, `window-${index}.rgb48le`),
3537
+ path: join8(dir, `window-${index}.rgb48le`),
3452
3538
  frames: 0,
3453
3539
  fd: -1,
3454
3540
  pins: 0,
@@ -4248,8 +4334,8 @@ function isTargetLossError(error) {
4248
4334
 
4249
4335
  // src/services/render/stages/captureStreamingStage.ts
4250
4336
  import { mkdtemp, writeFile } from "node:fs/promises";
4251
- import { tmpdir } from "node:os";
4252
- import { join as join8 } from "node:path";
4337
+ import { tmpdir as tmpdir2 } from "node:os";
4338
+ import { join as join9 } from "node:path";
4253
4339
  import {
4254
4340
  DrawElementVerificationError,
4255
4341
  captureFrameToBuffer,
@@ -4343,7 +4429,7 @@ var SequentialCaptureStallError = class extends Error {
4343
4429
  }
4344
4430
  };
4345
4431
  function raceAgainstStall(promise, deadlineMs, input, signal) {
4346
- return new Promise((resolve13, reject) => {
4432
+ return new Promise((resolve14, reject) => {
4347
4433
  const clock = createStallClock();
4348
4434
  const trip = () => reject(
4349
4435
  signal?.aborted ? new Error(
@@ -4368,7 +4454,7 @@ function raceAgainstStall(promise, deadlineMs, input, signal) {
4368
4454
  promise.then(
4369
4455
  (value) => {
4370
4456
  clearTimeout(timer);
4371
- resolve13(value);
4457
+ resolve14(value);
4372
4458
  },
4373
4459
  (error) => {
4374
4460
  clearTimeout(timer);
@@ -4472,11 +4558,11 @@ async function verifyDrawElementSample(session, idx, buf, ctx) {
4472
4558
  return;
4473
4559
  }
4474
4560
  if (db < verifyMinDb) {
4475
- const dumpDir = await mkdtemp(join8(tmpdir(), "hf-de-verify-fail-")).catch(() => null);
4561
+ const dumpDir = await mkdtemp(join9(tmpdir2(), "hf-de-verify-fail-")).catch(() => null);
4476
4562
  if (dumpDir) {
4477
4563
  await Promise.all([
4478
- writeFile(join8(dumpDir, `frame-${idx}-de.jpg`), buf),
4479
- writeFile(join8(dumpDir, `frame-${idx}-truth.jpg`), truth)
4564
+ writeFile(join9(dumpDir, `frame-${idx}-de.jpg`), buf),
4565
+ writeFile(join9(dumpDir, `frame-${idx}-truth.jpg`), truth)
4480
4566
  ]).catch(() => {
4481
4567
  });
4482
4568
  }
@@ -5047,7 +5133,7 @@ async function runCaptureStreamingStage(input) {
5047
5133
 
5048
5134
  // src/services/render/stages/captureSegmentedStage.ts
5049
5135
  function segmentOutputPath(segmentDir, index) {
5050
- return join9(segmentDir, `segment_${String(index).padStart(5, "0")}.mp4`);
5136
+ return join10(segmentDir, `segment_${String(index).padStart(5, "0")}.mp4`);
5051
5137
  }
5052
5138
  function segmentEncoderOptions(base, segment) {
5053
5139
  return {
@@ -5146,7 +5232,7 @@ async function captureSegmentToEncoder(ctx, segment) {
5146
5232
  path: segmentPath,
5147
5233
  // Recorded so resume can prove the file on disk is the one that
5148
5234
  // finished; absent only in unit tests, whose fake encoder writes none.
5149
- bytes: existsSync6(segmentPath) ? statSync4(segmentPath).size : 0
5235
+ bytes: existsSync7(segmentPath) ? statSync4(segmentPath).size : 0
5150
5236
  });
5151
5237
  return encodeResult;
5152
5238
  } finally {
@@ -5380,7 +5466,7 @@ async function runCaptureSegmentedStage(input) {
5380
5466
  const { log, dedupPerfs, assertNotAborted } = input;
5381
5467
  const deps = { ...DEFAULT_DEPS, ...input.deps };
5382
5468
  const segments = planSegments(input.totalFrames, input.segmentFrames);
5383
- const segmentDir = input.segmentDir ?? join9(input.workDir, "segments");
5469
+ const segmentDir = input.segmentDir ?? join10(input.workDir, "segments");
5384
5470
  mkdirSync3(segmentDir, { recursive: true });
5385
5471
  const skip = input.completedSegments ?? /* @__PURE__ */ new Set();
5386
5472
  const pending = segments.filter((s) => !skip.has(s.index));
@@ -5536,7 +5622,7 @@ function startRenderEtaGuard(options) {
5536
5622
  }
5537
5623
 
5538
5624
  // src/services/render/captureCost.ts
5539
- import { join as join10 } from "node:path";
5625
+ import { join as join11 } from "node:path";
5540
5626
  import { fpsToNumber as fpsToNumber4 } from "@hyperframes/core";
5541
5627
  import {
5542
5628
  calculateOptimalWorkers,
@@ -5789,7 +5875,7 @@ async function runCaptureCalibration(input) {
5789
5875
  });
5790
5876
  let calibration;
5791
5877
  try {
5792
- calibration = await runOneCalibration(join10(workDir, "capture-calibration"), calibrationCfg);
5878
+ calibration = await runOneCalibration(join11(workDir, "capture-calibration"), calibrationCfg);
5793
5879
  } catch (error) {
5794
5880
  const shouldFallback = !forceScreenshot && shouldFallbackToScreenshotAfterCalibrationError(error);
5795
5881
  if (!shouldFallback) {
@@ -5823,7 +5909,7 @@ async function runCaptureCalibration(input) {
5823
5909
  const screenshotCfg = createCaptureCalibrationConfig({ ...cfg, forceScreenshot: true });
5824
5910
  try {
5825
5911
  calibration = await runOneCalibration(
5826
- join10(workDir, "capture-calibration-screenshot"),
5912
+ join11(workDir, "capture-calibration-screenshot"),
5827
5913
  screenshotCfg
5828
5914
  );
5829
5915
  } catch (fallbackError) {
@@ -5888,7 +5974,7 @@ function checkPageNeverReady(input) {
5888
5974
 
5889
5975
  // src/services/render/deferredVideoFrames.ts
5890
5976
  import { mkdirSync as mkdirSync4, rmSync as rmSync7 } from "node:fs";
5891
- import { dirname as dirname5, join as join11 } from "node:path";
5977
+ import { dirname as dirname5, join as join12 } from "node:path";
5892
5978
  import {
5893
5979
  createFrameLookupTable,
5894
5980
  extractVideoFramesRange,
@@ -5933,7 +6019,7 @@ async function extractDeferredFrames(input) {
5933
6019
  const shown = shownDeferredFrameIndexes(input, input.frames, input.fps);
5934
6020
  return Promise.all(
5935
6021
  deferred.map(async (video) => {
5936
- const outputDir = join11(input.outputRoot, mediaIdPathSegment2(video.videoId));
6022
+ const outputDir = join12(input.outputRoot, mediaIdPathSegment2(video.videoId));
5937
6023
  const indexes = [...shown.get(video.videoId) ?? []].sort((a, b) => a - b);
5938
6024
  if (indexes.length === 0) {
5939
6025
  return { ...video, outputDir, framePaths: /* @__PURE__ */ new Map(), ownedByLookup: false };
@@ -6081,13 +6167,13 @@ async function measureLocalShownBoxes(page, videos, fps, duration, log) {
6081
6167
 
6082
6168
  // src/services/render/segmentVideoFrames.ts
6083
6169
  import { mkdirSync as mkdirSync5, rmSync as rmSync8 } from "node:fs";
6084
- import { join as join12 } from "node:path";
6170
+ import { join as join13 } from "node:path";
6085
6171
  import {
6086
6172
  createFrameLookupTable as createFrameLookupTable2,
6087
6173
  createVideoFrameInjector
6088
6174
  } from "@hyperframes/engine";
6089
6175
  function segmentFramesDir(rootDir, index) {
6090
- return join12(rootDir, "segment-frames", `segment_${String(index).padStart(5, "0")}`);
6176
+ return join13(rootDir, "segment-frames", `segment_${String(index).padStart(5, "0")}`);
6091
6177
  }
6092
6178
  function createSegmentVideoFrames(input) {
6093
6179
  const extractFrames = input.extractFrames ?? extractDeferredFrames;
@@ -6118,7 +6204,7 @@ function createSegmentVideoFrames(input) {
6118
6204
  let onDemandCalls = 0;
6119
6205
  const onDemandHook = () => Object.assign(
6120
6206
  async (page, time, heldVideoTime) => {
6121
- const dir = join12(
6207
+ const dir = join13(
6122
6208
  input.rootDir,
6123
6209
  "segment-frames",
6124
6210
  `on-demand_${String(onDemandCalls++).padStart(5, "0")}`
@@ -6135,7 +6221,7 @@ function createSegmentVideoFrames(input) {
6135
6221
  );
6136
6222
  return {
6137
6223
  async forFrames(frames, name) {
6138
- const dir = join12(input.rootDir, "segment-frames", name);
6224
+ const dir = join13(input.rootDir, "segment-frames", name);
6139
6225
  const release = () => rmSync8(dir, { recursive: true, force: true });
6140
6226
  try {
6141
6227
  release();
@@ -6188,7 +6274,7 @@ function createSegmentVideoFrames(input) {
6188
6274
 
6189
6275
  // src/services/render/videoFrameWindow.ts
6190
6276
  import { readdirSync as readdirSync3, statSync as statSync5 } from "node:fs";
6191
- import { join as join13 } from "node:path";
6277
+ import { join as join14 } from "node:path";
6192
6278
  function shouldWindowVideoFrames(args) {
6193
6279
  return args.segmented && args.env.HF_VIDEO_FRAME_WINDOW?.trim().toLowerCase() === "true";
6194
6280
  }
@@ -6201,7 +6287,7 @@ function directoryBytes(path) {
6201
6287
  return 0;
6202
6288
  }
6203
6289
  for (const entry of entries) {
6204
- const child3 = join13(path, entry.name);
6290
+ const child3 = join14(path, entry.name);
6205
6291
  try {
6206
6292
  bytes += entry.isDirectory() ? directoryBytes(child3) : statSync5(child3).size;
6207
6293
  } catch {
@@ -6219,7 +6305,7 @@ function trackSegmentFramePeak(frames, rootDir, onPeak) {
6219
6305
  ...worker,
6220
6306
  async prepare(segment) {
6221
6307
  await worker.prepare(segment);
6222
- const held = directoryBytes(join13(rootDir, "segment-frames"));
6308
+ const held = directoryBytes(join14(rootDir, "segment-frames"));
6223
6309
  if (held > peak) {
6224
6310
  peak = held;
6225
6311
  onPeak(peak);
@@ -6232,8 +6318,8 @@ function trackSegmentFramePeak(frames, rootDir, onPeak) {
6232
6318
 
6233
6319
  // src/services/render/segmentManifest.ts
6234
6320
  import { createHash as createHash2 } from "node:crypto";
6235
- import { existsSync as existsSync7, mkdirSync as mkdirSync6, readFileSync as readFileSync4, statSync as statSync6, writeFileSync as writeFileSync3 } from "node:fs";
6236
- import { join as join14 } from "node:path";
6321
+ import { existsSync as existsSync8, mkdirSync as mkdirSync6, readFileSync as readFileSync4, statSync as statSync6, writeFileSync as writeFileSync3 } from "node:fs";
6322
+ import { join as join15 } from "node:path";
6237
6323
  import { renameWithRetry as renameWithRetry2 } from "@hyperframes/engine";
6238
6324
  var MANIFEST_FILENAME = "segments.json";
6239
6325
  function computeSegmentPlanHash(input) {
@@ -6261,7 +6347,7 @@ function computeSegmentPlanHash(input) {
6261
6347
  return createHash2("sha256").update(ordered.join(" ")).digest("hex").slice(0, 16);
6262
6348
  }
6263
6349
  function segmentDirFor(projectRendersDir, planHash) {
6264
- return join14(projectRendersDir, ".hf-segments", planHash);
6350
+ return join15(projectRendersDir, ".hf-segments", planHash);
6265
6351
  }
6266
6352
  function hasNumber(value, key) {
6267
6353
  return key in value && typeof Reflect.get(value, key) === "number";
@@ -6279,8 +6365,8 @@ function isManifest(value) {
6279
6365
  return Reflect.get(value, "version") === 1 && hasString(value, "planHash") && hasNumber(value, "totalFrames") && hasNumber(value, "segmentFrames") && Array.isArray(completed) && completed.every(isEntry);
6280
6366
  }
6281
6367
  function readSegmentManifest(segmentDir) {
6282
- const path = join14(segmentDir, MANIFEST_FILENAME);
6283
- if (!existsSync7(path)) return null;
6368
+ const path = join15(segmentDir, MANIFEST_FILENAME);
6369
+ if (!existsSync8(path)) return null;
6284
6370
  try {
6285
6371
  const parsed = JSON.parse(readFileSync4(path, "utf-8"));
6286
6372
  return isManifest(parsed) ? parsed : null;
@@ -6290,9 +6376,9 @@ function readSegmentManifest(segmentDir) {
6290
6376
  }
6291
6377
  function writeSegmentManifest(segmentDir, manifest) {
6292
6378
  mkdirSync6(segmentDir, { recursive: true });
6293
- const tmp = join14(segmentDir, `${MANIFEST_FILENAME}.${process.pid}.tmp`);
6379
+ const tmp = join15(segmentDir, `${MANIFEST_FILENAME}.${process.pid}.tmp`);
6294
6380
  writeFileSync3(tmp, JSON.stringify(manifest, null, 2), "utf-8");
6295
- renameWithRetry2(tmp, join14(segmentDir, MANIFEST_FILENAME));
6381
+ renameWithRetry2(tmp, join15(segmentDir, MANIFEST_FILENAME));
6296
6382
  }
6297
6383
  async function probeSegmentFrameCount(path, probe) {
6298
6384
  try {
@@ -6309,7 +6395,7 @@ async function validateCompletedSegments(manifest, expectedHash, probeFrames) {
6309
6395
  const ok = /* @__PURE__ */ new Set();
6310
6396
  if (manifest.planHash !== expectedHash) return ok;
6311
6397
  for (const entry of manifest.completed) {
6312
- if (!existsSync7(entry.path)) continue;
6398
+ if (!existsSync8(entry.path)) continue;
6313
6399
  const size = statSync6(entry.path).size;
6314
6400
  if (size <= 0 || size !== entry.bytes) continue;
6315
6401
  const frames = await probeFrames(entry.path);
@@ -6914,8 +7000,8 @@ function requireOutputDimensions(expected, width, height) {
6914
7000
  }
6915
7001
 
6916
7002
  // src/services/render/stages/compileStage.ts
6917
- import { existsSync as existsSync12, writeFileSync as writeFileSync5 } from "node:fs";
6918
- import { join as join20, relative as relative3 } from "node:path";
7003
+ import { existsSync as existsSync13, writeFileSync as writeFileSync5 } from "node:fs";
7004
+ import { join as join21, relative as relative4 } from "node:path";
6919
7005
  import { privateCacheRoot } from "@hyperframes/engine";
6920
7006
  import { suggestMatchingPreset } from "@hyperframes/core";
6921
7007
  import { extractStandaloneEntryFromIndex, isTemplateEntry } from "@hyperframes/core/compiler";
@@ -6945,6 +7031,8 @@ var fileTooLarge = (file, bytes) => new CompositionTooLargeError(
6945
7031
  { bytes, limitBytes: MAX_COMPOSITION_HTML_BYTES }
6946
7032
  );
6947
7033
  var limitText = `One render generates at most ${megabytes(MAX_EXPANDED_COMPOSITION_BYTES)}`;
7034
+ var REMOTE_SCRIPTS = "remote scripts";
7035
+ var REMOTE_STYLESHEETS = "remote stylesheets";
6948
7036
  function generatedTooLarge(file, bytes) {
6949
7037
  if (file === "composition variables") {
6950
7038
  return `Composition variable styles add up to ${megabytes(bytes)}. ${limitText}. Shorten the variable values or declare them on fewer elements.`;
@@ -6952,6 +7040,9 @@ function generatedTooLarge(file, bytes) {
6952
7040
  if (file === "variable media sources") {
6953
7041
  return `Variable-bound media sources add up to ${megabytes(bytes)}. ${limitText}. Use shorter URLs or bind fewer elements.`;
6954
7042
  }
7043
+ if (file === REMOTE_SCRIPTS || file === REMOTE_STYLESHEETS) {
7044
+ return `Inlined ${file} add up to ${megabytes(bytes)}. ${limitText}. Bundle scripts and fonts with the project, or link each one once.`;
7045
+ }
6955
7046
  return `Scripts, styles and rebased asset paths generated for compositions, ending at "${file}", add up to ${megabytes(bytes)}. One render generates at most ${megabytes(MAX_EXPANDED_COMPOSITION_BYTES)} for its mounts. Merge small inline scripts and style rules, keep data-composition-id values short, or mount scenes fewer times.`;
6956
7047
  }
6957
7048
  var CompositionExpansionBudget = class {
@@ -7018,20 +7109,20 @@ import {
7018
7109
  stylesheetLinkMatches
7019
7110
  } from "@hyperframes/parsers/css-url-scans";
7020
7111
  import { createHash as createHash6 } from "node:crypto";
7021
- import { createReadStream as createReadStream2, existsSync as existsSync11, mkdirSync as mkdirSync9, readFileSync as readFileSync8 } from "fs";
7022
- import { join as join19, dirname as dirname9, resolve as resolve7, basename as basename5, relative as relative2, sep as sep3 } from "path";
7112
+ import { createReadStream as createReadStream2, existsSync as existsSync12, mkdirSync as mkdirSync9, readFileSync as readFileSync8 } from "fs";
7113
+ import { join as join20, dirname as dirname9, resolve as resolve8, basename as basename6, relative as relative3, sep as sep4 } from "path";
7023
7114
  import { parseHTML as parseHTML5 } from "linkedom";
7024
7115
 
7025
7116
  // src/services/bundledScripts.ts
7026
- import { existsSync as existsSync8, readFileSync as readFileSync5 } from "node:fs";
7027
- import { join as join15 } from "node:path";
7117
+ import { existsSync as existsSync9, readFileSync as readFileSync5 } from "node:fs";
7118
+ import { join as join16 } from "node:path";
7028
7119
  import { gsapCdnDist } from "@hyperframes/core/gsap-cdn";
7029
7120
  var GSAP_VENDOR_DIR_ENV = "HYPERFRAMES_GSAP_VENDOR_DIR";
7030
7121
  function bundledScript(url) {
7031
7122
  const dir = process.env[GSAP_VENDOR_DIR_ENV];
7032
7123
  if (!dir || url !== `${gsapCdnDist()}gsap.min.js`) return null;
7033
- const file = join15(dir, "gsap.min.js");
7034
- return existsSync8(file) ? readFileSync5(file) : null;
7124
+ const file = join16(dir, "gsap.min.js");
7125
+ return existsSync9(file) ? readFileSync5(file) : null;
7035
7126
  }
7036
7127
 
7037
7128
  // src/services/htmlCompiler.ts
@@ -7264,6 +7355,7 @@ function placeAudio(audio, window2) {
7264
7355
  import {
7265
7356
  analyzeKeyframeIntervals,
7266
7357
  assertMediaPayload,
7358
+ createConcurrencyLimit,
7267
7359
  isPrivateUnderAssetRoots as isPrivateUnderAssetRoots3,
7268
7360
  NotMediaPayloadError as NotMediaPayloadError2,
7269
7361
  parseMasterFxChain,
@@ -7288,8 +7380,8 @@ import {
7288
7380
 
7289
7381
  // src/services/animatedGifPrep.ts
7290
7382
  import { createHash as createHash4 } from "node:crypto";
7291
- import { copyFileSync as copyFileSync2, existsSync as existsSync9, mkdirSync as mkdirSync7, readFileSync as readFileSync6, rmSync as rmSync9, statSync as statSync8 } from "node:fs";
7292
- import { dirname as dirname6, isAbsolute as isAbsolute2, join as join16, resolve as resolve5 } from "node:path";
7383
+ import { copyFileSync as copyFileSync2, existsSync as existsSync10, mkdirSync as mkdirSync7, readFileSync as readFileSync6, rmSync as rmSync9, statSync as statSync8 } from "node:fs";
7384
+ import { dirname as dirname6, isAbsolute as isAbsolute3, join as join17, resolve as resolve6 } from "node:path";
7293
7385
  import { parseHTML as parseHTML3 } from "linkedom";
7294
7386
  import { parseAnimatedGifMetadata } from "@hyperframes/core";
7295
7387
  import {
@@ -7334,16 +7426,16 @@ function resolveLocalImageSourcePath(src, options) {
7334
7426
  const { basePath } = splitUrlSuffix(trimmed);
7335
7427
  const normalizedBase = normalizeRelPath(basePath);
7336
7428
  const mapped = options.sourceAssets?.get(trimmed) ?? options.sourceAssets?.get(basePath) ?? options.sourceAssets?.get(normalizedBase);
7337
- if (mapped && existsSync9(mapped)) return mapped;
7429
+ if (mapped && existsSync10(mapped)) return mapped;
7338
7430
  if (isHttpUrl(trimmed)) return null;
7339
7431
  const projectRelative = basePath.startsWith("/") ? basePath.slice(1) : basePath;
7340
7432
  const candidates = [
7341
- isAbsolute2(basePath) ? basePath : resolve5(options.projectDir, projectRelative),
7342
- resolve5(options.downloadDir, normalizedBase)
7433
+ isAbsolute3(basePath) ? basePath : resolve6(options.projectDir, projectRelative),
7434
+ resolve6(options.downloadDir, normalizedBase)
7343
7435
  ];
7344
7436
  const assetRoot = options.allowOutsideFiles ? void 0 : options.projectDir;
7345
7437
  const allowed = (candidate) => !namesAnotherNetworkRoot(options.projectDir, candidate) && !isPrivateUnderAssetRoots(candidate, [options.projectDir, options.downloadDir]) && (!escapesAssetRoot(candidate, assetRoot) && outsideAssetRefusal(options.projectDir, candidate) !== "blocklisted" || !escapesAssetRoot(candidate, options.downloadDir));
7346
- return candidates.find((candidate) => allowed(candidate) && existsSync9(candidate)) ?? null;
7438
+ return candidates.find((candidate) => allowed(candidate) && existsSync10(candidate)) ?? null;
7347
7439
  }
7348
7440
  function isUsableFile(path) {
7349
7441
  try {
@@ -7455,10 +7547,10 @@ async function runAnimatedGifTranscode(request) {
7455
7547
  throw result.error ?? new Error(`Animated GIF transcode failed (${result.exitCode}): ${result.stderr.slice(-500)}`);
7456
7548
  }
7457
7549
  async function ensurePreparedWebm(input) {
7458
- if (!existsSync9(dirname6(input.cachePath))) {
7550
+ if (!existsSync10(dirname6(input.cachePath))) {
7459
7551
  mkdirSync7(dirname6(input.cachePath), { recursive: true });
7460
7552
  }
7461
- if (!existsSync9(dirname6(input.outputPath))) {
7553
+ if (!existsSync10(dirname6(input.outputPath))) {
7462
7554
  mkdirSync7(dirname6(input.outputPath), { recursive: true });
7463
7555
  }
7464
7556
  if (!isUsableFile(input.cachePath)) {
@@ -7490,7 +7582,7 @@ async function ensurePreparedWebm(input) {
7490
7582
  throw error;
7491
7583
  }
7492
7584
  }
7493
- if (resolve5(input.outputPath) !== resolve5(input.cachePath) && !isUsableFile(input.outputPath)) {
7585
+ if (resolve6(input.outputPath) !== resolve6(input.cachePath) && !isUsableFile(input.outputPath)) {
7494
7586
  copyFileSync2(input.cachePath, input.outputPath);
7495
7587
  }
7496
7588
  }
@@ -7542,7 +7634,7 @@ function replaceImageWithVideo(input) {
7542
7634
  return video;
7543
7635
  }
7544
7636
  async function prepareAnimatedGifInputs(html, options) {
7545
- const outputDir = options.outputDir ?? join16(options.downloadDir, PREPARED_GIF_SUBDIR);
7637
+ const outputDir = options.outputDir ?? join17(options.downloadDir, PREPARED_GIF_SUBDIR);
7546
7638
  const outputSrcPrefix = normalizeRelPath(options.outputSrcPrefix ?? PREPARED_GIF_SUBDIR);
7547
7639
  const cacheDir = options.cacheDir ?? outputDir;
7548
7640
  const { document: document2 } = parseHTML3(html);
@@ -7569,8 +7661,8 @@ async function prepareAnimatedGifInputs(html, options) {
7569
7661
  );
7570
7662
  const hash = computePreparedGifHash(bytes, loopIterations, padSeconds);
7571
7663
  const filename = `${CACHE_SCHEMA}-${hash.slice(0, 24)}.webm`;
7572
- const cachePath = join16(cacheDir, filename);
7573
- const outputPath = join16(outputDir, filename);
7664
+ const cachePath = join17(cacheDir, filename);
7665
+ const outputPath = join17(outputDir, filename);
7574
7666
  const outputSrc = `${outputSrcPrefix}/${filename}`;
7575
7667
  await ensurePreparedWebm({
7576
7668
  sourcePath,
@@ -7615,7 +7707,7 @@ import {
7615
7707
  statSync as statSync9,
7616
7708
  writeFileSync as writeFileSync4
7617
7709
  } from "node:fs";
7618
- import { dirname as dirname7, join as join17, resolve as resolve6 } from "node:path";
7710
+ import { dirname as dirname7, join as join18, resolve as resolve7 } from "node:path";
7619
7711
  import { parseHTML as parseHTML4 } from "linkedom";
7620
7712
  import { renameWithRetry as renameWithRetry4, runFfmpeg as runFfmpeg3, runFfprobe, urlInputArgs as urlInputArgs3 } from "@hyperframes/engine";
7621
7713
 
@@ -7684,10 +7776,10 @@ var Semaphore = class {
7684
7776
  this.active++;
7685
7777
  return () => this.release();
7686
7778
  }
7687
- return new Promise((resolve13) => {
7779
+ return new Promise((resolve14) => {
7688
7780
  this.queue.push(() => {
7689
7781
  this.active++;
7690
- resolve13(() => this.release());
7782
+ resolve14(() => this.release());
7691
7783
  });
7692
7784
  });
7693
7785
  }
@@ -7885,12 +7977,12 @@ async function ensurePreparedJpeg(source, cachePath, outputPath, options) {
7885
7977
  rmSync10(inlinePath, { force: true });
7886
7978
  }
7887
7979
  }
7888
- if (resolve6(outputPath) !== resolve6(cachePath) && !isUsableFile2(outputPath)) {
7980
+ if (resolve7(outputPath) !== resolve7(cachePath) && !isUsableFile2(outputPath)) {
7889
7981
  copyFileSync3(cachePath, outputPath);
7890
7982
  }
7891
7983
  }
7892
7984
  async function prepareHeifImageInputs(html, options) {
7893
- const outputDir = options.outputDir ?? join17(options.downloadDir, PREPARED_HEIF_SUBDIR);
7985
+ const outputDir = options.outputDir ?? join18(options.downloadDir, PREPARED_HEIF_SUBDIR);
7894
7986
  const outputSrcPrefix = normalizeRelPath(options.outputSrcPrefix ?? PREPARED_HEIF_SUBDIR);
7895
7987
  const cacheDir = options.cacheDir ?? outputDir;
7896
7988
  const preparedAssets = /* @__PURE__ */ new Map();
@@ -7911,7 +8003,7 @@ async function prepareHeifImageInputs(html, options) {
7911
8003
  await Promise.all(
7912
8004
  [...unique].map(
7913
8005
  ([filename, source]) => withMediaProbeSlot(
7914
- () => ensurePreparedJpeg(source, join17(cacheDir, filename), join17(outputDir, filename), options)
8006
+ () => ensurePreparedJpeg(source, join18(cacheDir, filename), join18(outputDir, filename), options)
7915
8007
  ).catch((error) => {
7916
8008
  if (!options.onFailure) throw error;
7917
8009
  failed.add(filename);
@@ -7923,8 +8015,8 @@ async function prepareHeifImageInputs(html, options) {
7923
8015
  if (failed.has(filename)) continue;
7924
8016
  const outputSrc = `${outputSrcPrefix}/${filename}`;
7925
8017
  img.setAttribute("src", outputSrc);
7926
- preparedAssets.set(outputSrc, join17(outputDir, filename));
7927
- preparedImages.push({ sourceSrc: src, outputSrc, outputPath: join17(outputDir, filename) });
8018
+ preparedAssets.set(outputSrc, join18(outputDir, filename));
8019
+ preparedImages.push({ sourceSrc: src, outputSrc, outputPath: join18(outputDir, filename) });
7928
8020
  }
7929
8021
  return { html: document2.toString(), preparedAssets, preparedImages };
7930
8022
  }
@@ -7934,8 +8026,8 @@ import { createStudioPositionSeekReapplyScript } from "@hyperframes/studio-serve
7934
8026
  import { getPositionEditsRenderScript } from "@hyperframes/core/runtime/position-edits-render";
7935
8027
 
7936
8028
  // src/services/assetMediaType.ts
7937
- import { existsSync as existsSync10 } from "node:fs";
7938
- import { dirname as dirname8, join as join18 } from "node:path";
8029
+ import { existsSync as existsSync11 } from "node:fs";
8030
+ import { dirname as dirname8, join as join19 } from "node:path";
7939
8031
  import {
7940
8032
  fingerprintElementId,
7941
8033
  isHttpUrl as isHttpUrl2,
@@ -7988,11 +8080,11 @@ function assertAssetMediaTypeProfile(expected, profile, elementIdentity) {
7988
8080
  ]);
7989
8081
  }
7990
8082
  function mediaAssetRoots(projectDir, compiledDir) {
7991
- return [projectDir, compiledDir, join18(dirname8(compiledDir), "downloads")];
8083
+ return [projectDir, compiledDir, join19(dirname8(compiledDir), "downloads")];
7992
8084
  }
7993
8085
  function dropMediaOutsideProject(input) {
7994
8086
  const { projectDir, workDir, composition, log } = input;
7995
- const compiledDir = join18(workDir, "compiled");
8087
+ const compiledDir = join19(workDir, "compiled");
7996
8088
  const roots = mediaAssetRoots(projectDir, compiledDir);
7997
8089
  const staysInside = ({ id, src }) => {
7998
8090
  if (!src || isHttpUrl2(src)) return true;
@@ -8047,7 +8139,7 @@ async function preflightCompositionAssetMediaTypes(input) {
8047
8139
  input.projectDir,
8048
8140
  input.compiledDir
8049
8141
  );
8050
- if (!existsSync10(resolvedPath)) continue;
8142
+ if (!existsSync11(resolvedPath)) continue;
8051
8143
  byPath.set(resolvedPath, [...byPath.get(resolvedPath) ?? [], reference]);
8052
8144
  }
8053
8145
  const mismatches = [];
@@ -8138,7 +8230,7 @@ function normalizeCompositionSrcs(html, projectDir) {
8138
8230
  if (!value.includes("%") && !/^\.?[\\/]/.test(value)) return whole;
8139
8231
  const file = resolveCompositionSrc(projectDir, value);
8140
8232
  if (file === null) return whole;
8141
- return `${name}${quote}${relative2(projectDir, file).split(sep3).join("/")}${quote}`;
8233
+ return `${name}${quote}${relative3(projectDir, file).split(sep4).join("/")}${quote}`;
8142
8234
  });
8143
8235
  }
8144
8236
  var COMPOSITION_FILE = /\.html?$/i;
@@ -8343,8 +8435,8 @@ function detectShaderTransitionUsage(html) {
8343
8435
  async function resolveMediaDuration(src, mediaStart, playbackRate, projectDir, baseDir, downloadDir, tagName, elementIdentity, log, urlByAbsentLocalPath, probes, assetRoot) {
8344
8436
  let filePath = src;
8345
8437
  if (isHttpUrl(src)) {
8346
- const remoteDir = join19(downloadDir, REMOTE_MEDIA_SUBDIR);
8347
- if (!existsSync11(remoteDir)) mkdirSync9(remoteDir, { recursive: true });
8438
+ const remoteDir = join20(downloadDir, REMOTE_MEDIA_SUBDIR);
8439
+ if (!existsSync12(remoteDir)) mkdirSync9(remoteDir, { recursive: true });
8348
8440
  try {
8349
8441
  filePath = await downloadToTemp(src, remoteDir, void 0, void 0, void 0, {
8350
8442
  onTelemetry: logRemoteDownloadTelemetry
@@ -8354,7 +8446,7 @@ async function resolveMediaDuration(src, mediaStart, playbackRate, projectDir, b
8354
8446
  }
8355
8447
  } else {
8356
8448
  filePath = decodedUrlPath(src);
8357
- if (!filePath.startsWith("/")) filePath = join19(baseDir, filePath);
8449
+ if (!filePath.startsWith("/")) filePath = join20(baseDir, filePath);
8358
8450
  if (escapesAssetRoot(filePath, assetRoot) || isPrivateUnderAssetRoots3(filePath, [projectDir, downloadDir])) {
8359
8451
  return { duration: null, resolvedPath: filePath };
8360
8452
  }
@@ -8363,7 +8455,7 @@ async function resolveMediaDuration(src, mediaStart, playbackRate, projectDir, b
8363
8455
  return { duration: null, resolvedPath: filePath };
8364
8456
  }
8365
8457
  }
8366
- if (!isHttpUrl(filePath) && !existsSync11(filePath)) {
8458
+ if (!isHttpUrl(filePath) && !existsSync12(filePath)) {
8367
8459
  return { duration: null, resolvedPath: filePath };
8368
8460
  }
8369
8461
  const withSrcContext = (error) => {
@@ -8733,7 +8825,7 @@ function inlineSubCompositions(html, subCompositions, projectDir, variableOverri
8733
8825
  parseHostVariables: parseHostVariableValues,
8734
8826
  resolveFilePath: (srcPath) => {
8735
8827
  const file = resolveCompositionFile(projectDir, srcPath, assetRoot);
8736
- return file && relative2(projectDir, file).split(sep3).join("/");
8828
+ return file && relative3(projectDir, file).split(sep4).join("/");
8737
8829
  },
8738
8830
  resolveHtml: (srcPath) => {
8739
8831
  const compHtml = resolveMountHtml(srcPath);
@@ -8897,7 +8989,8 @@ async function downloadScript(src, mirror) {
8897
8989
  }
8898
8990
  return fetchPublicHttpsBytes(src, { maxBytes: MAX_SCRIPT_BYTES, timeoutMs: 15e3 });
8899
8991
  }
8900
- async function inlineExternalScripts(html) {
8992
+ var MAX_CONCURRENT_SCRIPT_FETCHES = 4;
8993
+ async function inlineExternalScripts(html, budget = new CompositionExpansionBudget()) {
8901
8994
  const fullHtml = ensureFullDocument(html);
8902
8995
  const wrappedFragment = fullHtml !== html;
8903
8996
  const { document: document2 } = parseHTML5(fullHtml);
@@ -8911,20 +9004,52 @@ async function inlineExternalScripts(html) {
8911
9004
  }
8912
9005
  if (externalScripts.length === 0) return html;
8913
9006
  const mirror = operatorGsapMirror();
9007
+ const limit = createConcurrencyLimit(MAX_CONCURRENT_SCRIPT_FETCHES);
9008
+ const stop = new AbortController();
9009
+ const fail = (error) => {
9010
+ stop.abort(error);
9011
+ throw error;
9012
+ };
9013
+ const charge = (bytes) => {
9014
+ try {
9015
+ budget.chargeGenerated(REMOTE_SCRIPTS, bytes);
9016
+ } catch (error) {
9017
+ fail(error);
9018
+ }
9019
+ };
9020
+ const fetches = /* @__PURE__ */ new Map();
9021
+ const fetchOnce = (src) => {
9022
+ let bytes = fetches.get(src);
9023
+ if (!bytes) {
9024
+ bytes = limit(async () => {
9025
+ if (stop.signal.aborted) throw stop.signal.reason;
9026
+ const downloaded = await downloadScript(src, mirror);
9027
+ charge(downloaded.byteLength);
9028
+ return downloaded;
9029
+ }, stop.signal);
9030
+ fetches.set(src, bytes);
9031
+ }
9032
+ return bytes;
9033
+ };
9034
+ const placed = /* @__PURE__ */ new Set();
8914
9035
  const downloads = await Promise.allSettled(
8915
9036
  externalScripts.map(async ({ el, src }) => {
8916
9037
  const integrity = el.getAttribute("integrity") || "";
8917
- const bundled = bundledScript(src);
8918
- if (bundled && matchesScriptIntegrity(bundled, integrity)) {
8919
- return { src, text: new TextDecoder().decode(bundled) };
8920
- }
8921
- const bytes = await downloadScript(src, mirror);
8922
- if (!matchesScriptIntegrity(bytes, integrity)) {
8923
- throw new ScriptIntegrityError(`Subresource integrity mismatch for ${src}`);
9038
+ let bytes = bundledScript(src);
9039
+ if (bytes && matchesScriptIntegrity(bytes, integrity)) {
9040
+ charge(bytes.byteLength);
9041
+ } else {
9042
+ bytes = await fetchOnce(src);
9043
+ if (!matchesScriptIntegrity(bytes, integrity)) {
9044
+ fail(new ScriptIntegrityError(`Subresource integrity mismatch for ${src}`));
9045
+ }
9046
+ if (placed.has(src)) charge(bytes.byteLength);
9047
+ placed.add(src);
8924
9048
  }
8925
9049
  return { src, text: new TextDecoder().decode(bytes) };
8926
9050
  })
8927
9051
  );
9052
+ if (stop.signal.aborted) throw stop.signal.reason;
8928
9053
  for (let i = 0; i < downloads.length; i++) {
8929
9054
  const download = downloads[i];
8930
9055
  const { el, src } = externalScripts[i];
@@ -8951,18 +9076,18 @@ ${safeText}
8951
9076
  return wrappedFragment ? document2.body.innerHTML || "" : document2.toString();
8952
9077
  }
8953
9078
  function collectExternalAssets(html, projectDir, log = defaultLogger, file = "index.html", policy = {}) {
8954
- const absProjectDir = resolve7(projectDir);
9079
+ const absProjectDir = resolve8(projectDir);
8955
9080
  const externalAssets = /* @__PURE__ */ new Map();
8956
9081
  const leftOut = /* @__PURE__ */ new Set();
8957
9082
  function processPath(rawPath) {
8958
9083
  const trimmed = rawPath.trim();
8959
9084
  if (isNonRelativeUrl(trimmed)) return null;
8960
- const absPath = resolve7(absProjectDir, trimmed);
9085
+ const absPath = resolve8(absProjectDir, trimmed);
8961
9086
  if (isPathInside(absPath, absProjectDir)) {
8962
9087
  return null;
8963
9088
  }
8964
9089
  const onShare = namesAnotherNetworkRoot2(absProjectDir, absPath);
8965
- if (!onShare && !existsSync11(absPath)) return null;
9090
+ if (!onShare && !existsSync12(absPath)) return null;
8966
9091
  const refusal = onShare ? "network_share" : outsideAssetRefusal(absProjectDir, absPath, policy);
8967
9092
  if (refusal) {
8968
9093
  if (!leftOut.has(trimmed)) log.warn(`[Compiler] ${leftOutOfRender(file, trimmed, refusal)}`);
@@ -9015,7 +9140,7 @@ function collectExternalAssets(html, projectDir, log = defaultLogger, file = "in
9015
9140
  var REMOTE_MEDIA_SUBDIR = "_remote_media";
9016
9141
  async function downloadAndRewriteUrls(urlSet, html, remoteDir, warnLabel, logLabel, extraRewrite) {
9017
9142
  if (urlSet.size === 0) return { html, remoteMediaAssets: /* @__PURE__ */ new Map() };
9018
- if (!existsSync11(remoteDir)) mkdirSync9(remoteDir, { recursive: true });
9143
+ if (!existsSync12(remoteDir)) mkdirSync9(remoteDir, { recursive: true });
9019
9144
  const urlToLocal = /* @__PURE__ */ new Map();
9020
9145
  await Promise.all(
9021
9146
  [...urlSet].map(async (url) => {
@@ -9038,7 +9163,7 @@ async function downloadAndRewriteUrls(urlSet, html, remoteDir, warnLabel, logLab
9038
9163
  const remoteMediaAssets = /* @__PURE__ */ new Map();
9039
9164
  const urlToRelPath = /* @__PURE__ */ new Map();
9040
9165
  for (const [url, absPath] of urlToLocal) {
9041
- const relPath = `${REMOTE_MEDIA_SUBDIR}/${basename5(absPath)}`;
9166
+ const relPath = `${REMOTE_MEDIA_SUBDIR}/${basename6(absPath)}`;
9042
9167
  remoteMediaAssets.set(relPath, absPath);
9043
9168
  urlToRelPath.set(url, relPath);
9044
9169
  }
@@ -9055,7 +9180,7 @@ async function localizeRemoteMediaSources(html, downloadDir) {
9055
9180
  const localized = await downloadAndRewriteUrls(
9056
9181
  urlSet,
9057
9182
  html,
9058
- join19(downloadDir, REMOTE_MEDIA_SUBDIR),
9183
+ join20(downloadDir, REMOTE_MEDIA_SUBDIR),
9059
9184
  "Remote media download failed",
9060
9185
  "Localized remote media source(s)"
9061
9186
  );
@@ -9078,7 +9203,7 @@ async function localizeRemoteImageSources(html, downloadDir) {
9078
9203
  return downloadAndRewriteUrls(
9079
9204
  urlSet,
9080
9205
  html,
9081
- join19(downloadDir, REMOTE_MEDIA_SUBDIR),
9206
+ join20(downloadDir, REMOTE_MEDIA_SUBDIR),
9082
9207
  "Remote image download failed",
9083
9208
  "Localized remote image source(s)"
9084
9209
  );
@@ -9091,7 +9216,7 @@ async function localizeRemoteBackgroundImages(html, downloadDir) {
9091
9216
  return downloadAndRewriteUrls(
9092
9217
  urlSet,
9093
9218
  html,
9094
- join19(downloadDir, REMOTE_MEDIA_SUBDIR),
9219
+ join20(downloadDir, REMOTE_MEDIA_SUBDIR),
9095
9220
  "Remote background-image download failed",
9096
9221
  "Localized remote background-image(s)",
9097
9222
  // Quoted url('..')/url("..") are rewritten by downloadAndRewriteUrls' default
@@ -9148,48 +9273,50 @@ function matchingBraces(css) {
9148
9273
  }
9149
9274
  return closes;
9150
9275
  }
9151
- async function inlineExternalFontStylesheets(html) {
9152
- const hrefRe = /\bhref=["']([^"']+)["']/i;
9153
- const linkMatches = [];
9276
+ function remoteFontStylesheetHref(tag) {
9277
+ const href = /\bhref=["']([^"']+)["']/i.exec(tag)?.[1];
9278
+ if (!href || !/^https?:\/\//i.test(href) || isGoogleFontsUrl(href)) return void 0;
9279
+ return href;
9280
+ }
9281
+ async function inlineExternalFontStylesheets(html, budget = new CompositionExpansionBudget()) {
9282
+ const hrefs = /* @__PURE__ */ new Set();
9154
9283
  for (const { parts } of stylesheetLinkMatches(html)) {
9155
- const tag = parts[0];
9156
- const hrefMatch = hrefRe.exec(tag);
9157
- if (!hrefMatch?.[1]) continue;
9158
- const href = hrefMatch[1];
9159
- if (!/^https?:\/\//i.test(href)) continue;
9160
- if (isGoogleFontsUrl(href)) continue;
9161
- linkMatches.push({ fullMatch: tag, href });
9162
- }
9163
- if (linkMatches.length === 0) return html;
9164
- const MAX_CONCURRENT_STYLESHEET_FETCHES = 4;
9165
- const fetches = [];
9166
- for (let i = 0; i < linkMatches.length; i += MAX_CONCURRENT_STYLESHEET_FETCHES) {
9167
- const batch = linkMatches.slice(i, i + MAX_CONCURRENT_STYLESHEET_FETCHES);
9168
- const results = await Promise.all(
9169
- batch.map(async ({ fullMatch, href }) => {
9170
- const css = await fetchExternalStylesheetCss(href);
9171
- return { fullMatch, href, css };
9172
- })
9173
- );
9174
- fetches.push(...results);
9284
+ const href = remoteFontStylesheetHref(parts[0]);
9285
+ if (href) hrefs.add(href);
9175
9286
  }
9176
- let result = html;
9177
- for (const { fullMatch, href, css } of fetches) {
9178
- if (css === null) continue;
9179
- const fontFaceBlocks = extractFontFaceBlocks(css);
9180
- if (fontFaceBlocks.length === 0) continue;
9181
- const identity = safeDownloadUrlIdentity(href);
9182
- const inlineStyle = `<style>/* Inlined external font stylesheet */
9287
+ if (hrefs.size === 0) return html;
9288
+ const MAX_CONCURRENT_STYLESHEET_FETCHES = 4;
9289
+ const inlineByHref = /* @__PURE__ */ new Map();
9290
+ const unique = [...hrefs];
9291
+ for (let i = 0; i < unique.length; i += MAX_CONCURRENT_STYLESHEET_FETCHES) {
9292
+ const batch = unique.slice(i, i + MAX_CONCURRENT_STYLESHEET_FETCHES);
9293
+ const sheets = await Promise.all(batch.map(fetchExternalStylesheetCss));
9294
+ batch.forEach((href, index) => {
9295
+ const css = sheets[index];
9296
+ const fontFaceBlocks = css ? extractFontFaceBlocks(css) : [];
9297
+ if (fontFaceBlocks.length === 0) return;
9298
+ const inlineStyle = `<style>/* Inlined external font stylesheet */
9183
9299
  ${fontFaceBlocks.join("\n")}
9184
9300
  </style>`;
9185
- result = result.replace(fullMatch, inlineStyle);
9186
- defaultLogger.debug("[Compiler] Inlined external @font-face rule(s)", {
9187
- count: fontFaceBlocks.length,
9188
- urlFingerprint: identity.urlFingerprint,
9189
- host: identity.host
9301
+ budget.chargeGenerated(REMOTE_STYLESHEETS, inlineStyle.length);
9302
+ inlineByHref.set(href, inlineStyle);
9303
+ const identity = safeDownloadUrlIdentity(href);
9304
+ defaultLogger.debug("[Compiler] Inlined external @font-face rule(s)", {
9305
+ count: fontFaceBlocks.length,
9306
+ urlFingerprint: identity.urlFingerprint,
9307
+ host: identity.host
9308
+ });
9190
9309
  });
9191
9310
  }
9192
- return result;
9311
+ const placed = /* @__PURE__ */ new Set();
9312
+ return replaceMatches(html, stylesheetLinkMatches(html), (tag) => {
9313
+ const href = remoteFontStylesheetHref(tag);
9314
+ const inlineStyle = href ? inlineByHref.get(href) : void 0;
9315
+ if (!href || !inlineStyle) return tag;
9316
+ if (placed.has(href)) budget.chargeGenerated(REMOTE_STYLESHEETS, inlineStyle.length);
9317
+ placed.add(href);
9318
+ return inlineStyle;
9319
+ });
9193
9320
  }
9194
9321
  function projectStylesheetFontFamilies(html, projectDir) {
9195
9322
  const families = [];
@@ -9198,14 +9325,14 @@ function projectStylesheetFontFamilies(html, projectDir) {
9198
9325
  } of stylesheetLinkMatches(html)) {
9199
9326
  const href = /\bhref=["']([^"']+)["']/i.exec(tag)?.[1];
9200
9327
  if (!href || /^(?:[a-z][a-z\d+.-]*:|\/\/)/i.test(href)) continue;
9201
- const sheet = resolve7(projectDir, decodedUrlPath(href).replace(/^(?:\.?\/)+/, ""));
9202
- if (!isPathInside(sheet, projectDir) || !existsSync11(sheet)) continue;
9328
+ const sheet = resolve8(projectDir, decodedUrlPath(href).replace(/^(?:\.?\/)+/, ""));
9329
+ if (!isPathInside(sheet, projectDir) || !existsSync12(sheet)) continue;
9203
9330
  for (const face of extractFontFaceBlocks(readFileSync8(sheet, "utf8"))) {
9204
9331
  const family = /font-family\s*:\s*([^;}]+)/i.exec(face)?.[1]?.trim().replace(/^['"]|['"]$/g, "");
9205
9332
  const shipsFile = [...localFontFaceUrlMatches(face)].some(({ parts: [, url = ""] }) => {
9206
9333
  const path = decodedUrlPath(url);
9207
- const file = path.startsWith("/") ? resolve7(projectDir, `.${path}`) : resolve7(dirname9(sheet), path);
9208
- return isPathInside(file, projectDir) && existsSync11(file);
9334
+ const file = path.startsWith("/") ? resolve8(projectDir, `.${path}`) : resolve8(dirname9(sheet), path);
9335
+ return isPathInside(file, projectDir) && existsSync12(file);
9209
9336
  });
9210
9337
  if (family && shipsFile) families.push(family);
9211
9338
  }
@@ -9245,7 +9372,7 @@ function localizeFontFaceUrls(html, downloadDir) {
9245
9372
  return downloadAndRewriteUrls(
9246
9373
  collectFontFaceUrls(html),
9247
9374
  html,
9248
- join19(downloadDir, REMOTE_MEDIA_SUBDIR),
9375
+ join20(downloadDir, REMOTE_MEDIA_SUBDIR),
9249
9376
  "Remote font download failed",
9250
9377
  "Localized remote font face(s)",
9251
9378
  (h, url, relPath) => h.replaceAll(`url(${url})`, `url("${relPath}")`)
@@ -9266,7 +9393,7 @@ async function readLocalFont(absPath) {
9266
9393
  return { kind: "inline", buffer: Buffer.concat(chunks, totalBytes) };
9267
9394
  }
9268
9395
  async function localFontDataUri(localPath, projectDir, assetRoot, dataUriByAbsolutePath, log) {
9269
- const absPath = localPath.startsWith("/") ? localPath : resolve7(projectDir, localPath);
9396
+ const absPath = localPath.startsWith("/") ? localPath : resolve8(projectDir, localPath);
9270
9397
  if (!isPathInside(absPath, projectDir) || escapesAssetRoot(absPath, assetRoot)) return void 0;
9271
9398
  if (refusesOutsideLink(projectDir, absPath, (line) => log.warn(`[Compiler] ${line}`))) {
9272
9399
  return void 0;
@@ -9356,8 +9483,8 @@ function renderGsapDist() {
9356
9483
  function rewriteUnresolvableGsapToCdn(html, projectDir, compSrcPath) {
9357
9484
  let gsapDist;
9358
9485
  const exists = (path) => {
9359
- const file = resolve7(projectDir, path);
9360
- return !namesAnotherNetworkRoot2(projectDir, file) && existsSync11(file);
9486
+ const file = resolve8(projectDir, path);
9487
+ return !namesAnotherNetworkRoot2(projectDir, file) && existsSync12(file);
9361
9488
  };
9362
9489
  return replaceGsapDistScripts(html, (full, prefix, src, file, suffix) => {
9363
9490
  if (/^https?:\/\//i.test(src)) return full;
@@ -9369,7 +9496,7 @@ function rewriteUnresolvableGsapToCdn(html, projectDir, compSrcPath) {
9369
9496
  }
9370
9497
  function rebaseDirectEntryAssetPaths(html, projectDir, htmlPath, budget) {
9371
9498
  if (!isPathInside(htmlPath, projectDir)) return html;
9372
- const entryPath = relative2(projectDir, htmlPath).replace(/\\/g, "/");
9499
+ const entryPath = relative3(projectDir, htmlPath).replace(/\\/g, "/");
9373
9500
  if (!entryPath.includes("/")) return html;
9374
9501
  const { document: document2 } = parseHTML5(html);
9375
9502
  const assetExists = projectAssetExists(projectDir);
@@ -9429,7 +9556,7 @@ function bindVariableMediaSources(html, variables, budget, log) {
9429
9556
  }
9430
9557
  return changed ? document2.toString() : html;
9431
9558
  }
9432
- var entryFileName = (projectDir, htmlPath) => isPathInside(htmlPath, projectDir) ? relative2(projectDir, htmlPath).split(sep3).join("/") : basename5(htmlPath);
9559
+ var entryFileName = (projectDir, htmlPath) => isPathInside(htmlPath, projectDir) ? relative3(projectDir, htmlPath).split(sep4).join("/") : basename6(htmlPath);
9433
9560
  async function compileForRender(projectDir, htmlPath, downloadDir, options = {}) {
9434
9561
  const assetRoot = options.allowOutsideProjectAssets ? void 0 : projectDir;
9435
9562
  const outsideFiles = { includeScripts: options.includeOutsideScripts };
@@ -9442,7 +9569,7 @@ async function compileForRender(projectDir, htmlPath, downloadDir, options = {})
9442
9569
  if (!COMPOSITION_FILE.test(htmlPath)) {
9443
9570
  throw new Error(`Entry file ${htmlPath} is not an .html file, so it is refused`);
9444
9571
  }
9445
- assertCompositionFileSize(htmlPath, basename5(htmlPath));
9572
+ assertCompositionFileSize(htmlPath, basename6(htmlPath));
9446
9573
  const budget = new CompositionExpansionBudget();
9447
9574
  const entryHtml = rebaseDirectEntryAssetPaths(
9448
9575
  readTextFile(htmlPath),
@@ -9494,7 +9621,8 @@ async function compileForRender(projectDir, htmlPath, downloadDir, options = {})
9494
9621
  const usesThreeDTransforms = detectThreeDTransformUsage(sanitizedHtml);
9495
9622
  const hasAncestorBackgroundImage = detectAncestorBackgroundImage(sanitizedHtml);
9496
9623
  const fontSheetHtml = await inlineExternalFontStylesheets(
9497
- promoteCssImportsToLinkTags(sanitizedHtml)
9624
+ promoteCssImportsToLinkTags(sanitizedHtml),
9625
+ budget
9498
9626
  );
9499
9627
  const normalizedFontHtml = normalizeSystemFontPrimaryFamilies(
9500
9628
  injectTextRenderingRule(coalesceHeadStylesAndBodyScripts(fontSheetHtml))
@@ -9506,7 +9634,7 @@ async function compileForRender(projectDir, htmlPath, downloadDir, options = {})
9506
9634
  projectFontFamilies: projectStylesheetFontFamilies(fontSheetHtml, projectDir),
9507
9635
  abortSignal: options.abortSignal
9508
9636
  });
9509
- const assembledHtml = await inlineExternalScripts(coalescedHtml);
9637
+ const assembledHtml = await inlineExternalScripts(coalescedHtml, budget);
9510
9638
  const HF_POSITION_ATTRS = [
9511
9639
  'data-hf-studio-path-offset="true"',
9512
9640
  'data-hf-studio-box-size="true"',
@@ -9598,8 +9726,8 @@ async function compileForRender(projectDir, htmlPath, downloadDir, options = {})
9598
9726
  const advised = /* @__PURE__ */ new Set();
9599
9727
  for (const video of videos) {
9600
9728
  if (isHttpUrl(video.src)) continue;
9601
- const videoPath = resolve7(projectDir, video.src);
9602
- if (advised.has(videoPath) || namesAnotherNetworkRoot2(projectDir, videoPath) || !existsSync11(videoPath) || escapesAssetRoot(videoPath, assetRoot) || isPrivateUnderAssetRoots3(videoPath, [projectDir, downloadDir]))
9729
+ const videoPath = resolve8(projectDir, video.src);
9730
+ if (advised.has(videoPath) || namesAnotherNetworkRoot2(projectDir, videoPath) || !existsSync12(videoPath) || escapesAssetRoot(videoPath, assetRoot) || isPrivateUnderAssetRoots3(videoPath, [projectDir, downloadDir]))
9603
9731
  continue;
9604
9732
  advised.add(videoPath);
9605
9733
  const reencode = `ffmpeg -i "${video.src}" -c:v libx264 -r 30 -g 30 -keyint_min 30 -movflags +faststart -c:a copy output.mp4`;
@@ -10014,7 +10142,7 @@ async function recompileWithResolutions(compiled, resolutions, projectDir, downl
10014
10142
  function animatedGifCacheDir(extractCacheDir) {
10015
10143
  try {
10016
10144
  const root = extractCacheDir && privateCacheRoot(extractCacheDir);
10017
- return root ? join20(root, "animated-gif") : void 0;
10145
+ return root ? join21(root, "animated-gif") : void 0;
10018
10146
  } catch {
10019
10147
  return void 0;
10020
10148
  }
@@ -10036,17 +10164,17 @@ function resolveEntryHtmlPath(input) {
10036
10164
  const readEntry = (path) => {
10037
10165
  if (escapesAssetRoot(path, input.assetRoot)) {
10038
10166
  throw new Error(
10039
- `Entry file "${relative3(projectDir, path)}" leads outside the project folder`
10167
+ `Entry file "${relative4(projectDir, path)}" leads outside the project folder`
10040
10168
  );
10041
10169
  }
10042
- assertCompositionFileSize(path, relative3(projectDir, path));
10170
+ assertCompositionFileSize(path, relative4(projectDir, path));
10043
10171
  return readTextFile2(path);
10044
10172
  };
10045
- const htmlPath = join20(projectDir, entryFile);
10173
+ const htmlPath = join21(projectDir, entryFile);
10046
10174
  const rawEntry = readEntry(htmlPath);
10047
10175
  if (entryFile === "index.html" || !isTemplateEntry(rawEntry)) return htmlPath;
10048
- const projectIndexPath = join20(projectDir, "index.html");
10049
- if (!existsSync12(projectIndexPath)) {
10176
+ const projectIndexPath = join21(projectDir, "index.html");
10177
+ if (!existsSync13(projectIndexPath)) {
10050
10178
  throw new Error(
10051
10179
  `Template entry file "${entryFile}" requires a project index.html to extract its render shell.`
10052
10180
  );
@@ -10061,7 +10189,7 @@ function resolveEntryHtmlPath(input) {
10061
10189
  `Entry file "${entryFile}" is not mounted from index.html via data-composition-src, so it cannot be rendered independently.`
10062
10190
  );
10063
10191
  }
10064
- const wrapperPath = join20(workDir, "standalone-entry.html");
10192
+ const wrapperPath = join21(workDir, "standalone-entry.html");
10065
10193
  writeFileSync5(wrapperPath, standaloneHtml, "utf-8");
10066
10194
  log.info("Extracted standalone entry from index.html host context", { entryFile });
10067
10195
  return wrapperPath;
@@ -10091,7 +10219,7 @@ async function runCompileStage(input) {
10091
10219
  const assetRoot = job.config.allowOutsideProjectAssets ? void 0 : projectDir;
10092
10220
  const htmlPath = resolveEntryHtmlPath({ projectDir, workDir, entryFile, log, assetRoot });
10093
10221
  const compileStart = Date.now();
10094
- const compiled = await compileForRender(projectDir, htmlPath, join20(workDir, "downloads"), {
10222
+ const compiled = await compileForRender(projectDir, htmlPath, join21(workDir, "downloads"), {
10095
10223
  log,
10096
10224
  failClosedFontFetch: failClosedFontFetch === true,
10097
10225
  allowSystemFontCapture,
@@ -10166,7 +10294,7 @@ async function runCompileStage(input) {
10166
10294
  });
10167
10295
  await preflightCompositionAssetMediaTypes({
10168
10296
  projectDir,
10169
- compiledDir: join20(workDir, "compiled"),
10297
+ compiledDir: join21(workDir, "compiled"),
10170
10298
  composition,
10171
10299
  signal: abortSignal
10172
10300
  });
@@ -10214,7 +10342,7 @@ async function runCompileStage(input) {
10214
10342
 
10215
10343
  // src/services/render/stages/probeStage.ts
10216
10344
  import { createHash as createHash7 } from "node:crypto";
10217
- import { basename as basename6, join as join21 } from "node:path";
10345
+ import { basename as basename7, join as join22 } from "node:path";
10218
10346
  import { parseHTML as parseHTML6 } from "linkedom";
10219
10347
  import {
10220
10348
  closeCaptureSession as closeCaptureSession4,
@@ -10462,7 +10590,7 @@ function probeRequiresBrowser(args) {
10462
10590
  function reportedLengthSource(source) {
10463
10591
  if (!source) return null;
10464
10592
  if (source.from !== "media") return { from: source.from };
10465
- const name = basename6(source.src.split(/[?#]/, 1)[0] ?? "");
10593
+ const name = basename7(source.src.split(/[?#]/, 1)[0] ?? "");
10466
10594
  const srcHash = createHash7("sha256").update(name).digest("hex").slice(0, 12);
10467
10595
  return { from: "media", tag: source.tag, trimmed: source.trimmed, srcHash };
10468
10596
  }
@@ -10528,7 +10656,7 @@ async function runProbeStage(input) {
10528
10656
  });
10529
10657
  fileServer = await createFileServer({
10530
10658
  projectDir,
10531
- compiledDir: join21(workDir, "compiled"),
10659
+ compiledDir: join22(workDir, "compiled"),
10532
10660
  port: 0,
10533
10661
  preHeadScripts: [VIRTUAL_TIME_SHIM],
10534
10662
  fps: job.config.fps,
@@ -10565,7 +10693,7 @@ async function runProbeStage(input) {
10565
10693
  log.info("Creating capture session...", { attempt, maxAttempts: PROBE_MAX_ATTEMPTS });
10566
10694
  probeSession = await createCaptureSession4(
10567
10695
  fileServer.url,
10568
- join21(workDir, "probe"),
10696
+ join22(workDir, "probe"),
10569
10697
  captureOpts,
10570
10698
  null,
10571
10699
  probeCfg
@@ -10650,7 +10778,7 @@ async function runProbeStage(input) {
10650
10778
  });
10651
10779
  probeSession = await createCaptureSession4(
10652
10780
  fileServer.url,
10653
- join21(workDir, "probe-screenshot"),
10781
+ join22(workDir, "probe-screenshot"),
10654
10782
  captureOpts,
10655
10783
  null,
10656
10784
  { ...probeCfg, forceScreenshot: true }
@@ -10688,7 +10816,7 @@ async function runProbeStage(input) {
10688
10816
  compiled,
10689
10817
  resolutions,
10690
10818
  projectDir,
10691
- join21(workDir, "downloads"),
10819
+ join22(workDir, "downloads"),
10692
10820
  job.config.allowOutsideProjectAssets ? void 0 : projectDir,
10693
10821
  { includeScripts: job.config.includeOutsideScripts }
10694
10822
  );
@@ -10888,7 +11016,7 @@ async function runProbeStage(input) {
10888
11016
  });
10889
11017
  await preflightCompositionAssetMediaTypes({
10890
11018
  projectDir,
10891
- compiledDir: join21(workDir, "compiled"),
11019
+ compiledDir: join22(workDir, "compiled"),
10892
11020
  composition,
10893
11021
  signal: abortSignal
10894
11022
  });
@@ -11055,8 +11183,8 @@ function validateDistributedDuration(input) {
11055
11183
  }
11056
11184
 
11057
11185
  // src/services/render/stages/extractVideosStage.ts
11058
- import { existsSync as existsSync13 } from "node:fs";
11059
- import { join as join22 } from "node:path";
11186
+ import { existsSync as existsSync14 } from "node:fs";
11187
+ import { join as join23 } from "node:path";
11060
11188
  import {
11061
11189
  classifyVideoExtractionError,
11062
11190
  createFrameLookupTable as createFrameLookupTable3,
@@ -11420,7 +11548,7 @@ async function runExtractVideosStage(input) {
11420
11548
  // because short boundary counts can differ by one frame.
11421
11549
  {
11422
11550
  fps: job.config.fps,
11423
- outputDir: join22(compiledDir, "__hyperframes_video_frames"),
11551
+ outputDir: join23(compiledDir, "__hyperframes_video_frames"),
11424
11552
  format: job.config.videoFrameFormat ?? "auto",
11425
11553
  toneMapHdrToSdr: rendersSdrOnly(job.config, composition),
11426
11554
  timelineEnd: composition.duration,
@@ -11428,7 +11556,7 @@ async function runExtractVideosStage(input) {
11428
11556
  collectProbeFailures: extractionPolicy.failureMode === "enforce",
11429
11557
  deferRangeExtraction,
11430
11558
  shownBoxes,
11431
- contentKeyedDirs: [join22(compiledDir, REMOTE_MEDIA_SUBDIR)],
11559
+ contentKeyedDirs: [join23(compiledDir, REMOTE_MEDIA_SUBDIR)],
11432
11560
  urlByAbsentLocalPath,
11433
11561
  assetRoots,
11434
11562
  onProgress: ({ planned = 0, done = 0 }) => {
@@ -11508,7 +11636,7 @@ function isPublicHttpsUrl(url) {
11508
11636
  }
11509
11637
  }
11510
11638
  function opensLocally(path, assetRoots) {
11511
- return existsSync13(path) && (!assetRoots || assetRootsRefusal(path, assetRoots) === null);
11639
+ return existsSync14(path) && (!assetRoots || assetRootsRefusal(path, assetRoots) === null);
11512
11640
  }
11513
11641
  function localProbeSource(src, input) {
11514
11642
  const path = resolveProjectRelativeSrc4(src, input.projectDir, input.compiledDir);
@@ -11520,7 +11648,7 @@ async function remoteProbeSource(video, input) {
11520
11648
  if (!isPublicHttpsUrl(video.src)) return null;
11521
11649
  if (!resolveRestrictPageNetwork()) return video.src;
11522
11650
  if (!video.hasAudio || video.hidden) return null;
11523
- const downloadDir = input.downloadDir ?? join22(input.compiledDir, REMOTE_MEDIA_SUBDIR);
11651
+ const downloadDir = input.downloadDir ?? join23(input.compiledDir, REMOTE_MEDIA_SUBDIR);
11524
11652
  try {
11525
11653
  return await downloadToTemp2(video.src, downloadDir, void 0, input.signal, void 0, {
11526
11654
  onTelemetry: writeUrlDownloadTelemetry2
@@ -11561,7 +11689,7 @@ async function appendVideoAudioFromProbe(input) {
11561
11689
  }
11562
11690
 
11563
11691
  // src/services/render/videoLayerPassthroughPlan.ts
11564
- import { existsSync as existsSync14 } from "node:fs";
11692
+ import { existsSync as existsSync15 } from "node:fs";
11565
11693
  import {
11566
11694
  buildVideoLayerInput,
11567
11695
  isHttpUrl as isHttpUrl4,
@@ -11629,7 +11757,7 @@ async function planVideoLayerPassthrough(input) {
11629
11757
  const { video } = q;
11630
11758
  if (isHttpUrl4(video.src)) return { reason: "remote_source" };
11631
11759
  const path = resolveProjectRelativeSrc5(video.src, input.projectDir, input.compiledDir);
11632
- if (!existsSync14(path)) return { reason: "source_missing" };
11760
+ if (!existsSync15(path)) return { reason: "source_missing" };
11633
11761
  const layout = await probeVideoLayout(input.page, video.id, input.canvas, input.duration);
11634
11762
  if ("reason" in layout) return layout;
11635
11763
  const layer = await buildVideoLayerInput(
@@ -11644,8 +11772,8 @@ async function planVideoLayerPassthrough(input) {
11644
11772
  }
11645
11773
 
11646
11774
  // src/services/render/stages/audioStage.ts
11647
- import { existsSync as existsSync16 } from "node:fs";
11648
- import { join as join25 } from "node:path";
11775
+ import { existsSync as existsSync17 } from "node:fs";
11776
+ import { join as join26 } from "node:path";
11649
11777
  import {
11650
11778
  MIXED_AUDIO_FILENAME,
11651
11779
  audioFailureDiagnostics,
@@ -11656,8 +11784,8 @@ import {
11656
11784
  } from "@hyperframes/engine";
11657
11785
 
11658
11786
  // src/services/render/audioDeliveryLimit.ts
11659
- import { existsSync as existsSync15 } from "node:fs";
11660
- import { dirname as dirname11, join as join24 } from "node:path";
11787
+ import { existsSync as existsSync16 } from "node:fs";
11788
+ import { dirname as dirname11, join as join25 } from "node:path";
11661
11789
  import {
11662
11790
  applyAudioFxChain,
11663
11791
  describeFfmpegFailure as describeFfmpegFailure3,
@@ -11667,7 +11795,7 @@ import {
11667
11795
 
11668
11796
  // src/services/render/audioPadTrim.ts
11669
11797
  import { spawn } from "node:child_process";
11670
- import { dirname as dirname10, join as join23 } from "node:path";
11798
+ import { dirname as dirname10, join as join24 } from "node:path";
11671
11799
  import {
11672
11800
  DEFAULT_CONFIG,
11673
11801
  describeFfmpegFailure as describeFfmpegFailure2,
@@ -11948,7 +12076,7 @@ async function constrainAacTruePeak(input) {
11948
12076
  }
11949
12077
  async function cutSource(input, scratchDir, attenuationDb) {
11950
12078
  if (!input.sourcePath || !input.rewriteSource) return true;
11951
- const cutPath = join23(scratchDir, "source.wav");
12079
+ const cutPath = join24(scratchDir, "source.wav");
11952
12080
  try {
11953
12081
  const result = await input.rewriteSource(input.sourcePath, cutPath, gainFilter(attenuationDb));
11954
12082
  if (!result.success) throw new Error(result.error);
@@ -11963,7 +12091,7 @@ async function enforceAacTruePeak(input) {
11963
12091
  let scratchDir;
11964
12092
  try {
11965
12093
  scratchDir = createStagingDir3(dirname10(input.audioPath), ".true-peak-");
11966
- const correctedPath = join23(scratchDir, "audio.m4a");
12094
+ const correctedPath = join24(scratchDir, "audio.m4a");
11967
12095
  const measurements = [];
11968
12096
  let attenuationDb = 0;
11969
12097
  let sourcePeakDbfs;
@@ -12176,14 +12304,14 @@ async function limitDeliveryPeaks(input, deps = {
12176
12304
  applyChain: applyAudioFxChain,
12177
12305
  encode: encodeAac2,
12178
12306
  rename: renameWithRetry6,
12179
- sourceExists: existsSync15
12307
+ sourceExists: existsSync16
12180
12308
  }) {
12181
12309
  const { audioPath, sourcePath, signal, timeoutMs } = input;
12182
12310
  if (!deps.sourceExists(sourcePath)) return { success: true };
12183
12311
  const peak = await deps.measure(audioPath, { timeoutMs, signal });
12184
12312
  if (peak <= AAC_DELIVERY_TRUE_PEAK_DBFS) return { success: true };
12185
12313
  const alternating = ["a", "b"].map(
12186
- (k) => join24(dirname11(sourcePath), `audio-source-limited-${k}.wav`)
12314
+ (k) => join25(dirname11(sourcePath), `audio-source-limited-${k}.wav`)
12187
12315
  );
12188
12316
  let encodedFrom;
12189
12317
  let ceiling = AAC_DELIVERY_TRUE_PEAK_DBFS;
@@ -12256,7 +12384,7 @@ function runAudioStage(input) {
12256
12384
  }
12257
12385
  async function runAudioStageScoped(input) {
12258
12386
  const stageStart = Date.now();
12259
- const pcmSourcePath = join25(input.workDir, "audio-source.wav");
12387
+ const pcmSourcePath = join26(input.workDir, "audio-source.wav");
12260
12388
  const duration = input.totalFrames * input.fps.den / input.fps.num;
12261
12389
  let deliverySourcePath;
12262
12390
  try {
@@ -12272,7 +12400,7 @@ async function runAudioStageScoped(input) {
12272
12400
  );
12273
12401
  audioLoweredDb = guard.loweredDb;
12274
12402
  input.log?.info("[audio] phases", { ...result.audioPhaseMs, guard: Date.now() - guardStart });
12275
- if (input.keepDeliverySource && !guard.sourceStale && existsSync16(pcmSourcePath)) {
12403
+ if (input.keepDeliverySource && !guard.sourceStale && existsSync17(pcmSourcePath)) {
12276
12404
  deliverySourcePath = pcmSourcePath;
12277
12405
  }
12278
12406
  }
@@ -12321,7 +12449,7 @@ async function mixAudioForDelivery(input, duration, pcmSourcePath) {
12321
12449
  assertNotAborted,
12322
12450
  log
12323
12451
  } = input;
12324
- const audioOutputPath = join25(workDir, MIXED_AUDIO_FILENAME);
12452
+ const audioOutputPath = join26(workDir, MIXED_AUDIO_FILENAME);
12325
12453
  let hasAudio = false;
12326
12454
  let audioError;
12327
12455
  let audioFailures;
@@ -12401,8 +12529,8 @@ async function mixAudioForDelivery(input, duration, pcmSourcePath) {
12401
12529
  }
12402
12530
 
12403
12531
  // src/services/render/stages/captureStage.ts
12404
- import { existsSync as existsSync17, readdirSync as readdirSync4, statfsSync as statfsSync2 } from "node:fs";
12405
- import { join as join26 } from "node:path";
12532
+ import { existsSync as existsSync18, readdirSync as readdirSync4, statfsSync as statfsSync2 } from "node:fs";
12533
+ import { join as join27 } from "node:path";
12406
12534
  import {
12407
12535
  classifyCaptureFailure as classifyCaptureFailure2,
12408
12536
  frameFileExtension,
@@ -12472,16 +12600,16 @@ function diskCaptureShortfallError(needBytes, freeBytes, framesDir, basis, remed
12472
12600
  }
12473
12601
  function measureCaptureFrameBytes(workDir, framesDir) {
12474
12602
  let total = sampleDirectoryBytes(framesDir);
12475
- if (!existsSync17(workDir)) return total;
12603
+ if (!existsSync18(workDir)) return total;
12476
12604
  for (const attempt of readdirSync4(workDir)) {
12477
12605
  if (/^retry-\d+-batch-\d+-worker-\d+$/.test(attempt)) {
12478
- total += sampleDirectoryBytes(join26(workDir, attempt));
12606
+ total += sampleDirectoryBytes(join27(workDir, attempt));
12479
12607
  continue;
12480
12608
  }
12481
12609
  if (!/^capture-attempt-\d+$/.test(attempt)) continue;
12482
- const attemptDir = join26(workDir, attempt);
12610
+ const attemptDir = join27(workDir, attempt);
12483
12611
  for (const name of readdirSync4(attemptDir)) {
12484
- if (/^worker-\d+$/.test(name)) total += sampleDirectoryBytes(join26(attemptDir, name));
12612
+ if (/^worker-\d+$/.test(name)) total += sampleDirectoryBytes(join27(attemptDir, name));
12485
12613
  }
12486
12614
  }
12487
12615
  return total;
@@ -12779,8 +12907,8 @@ async function captureSessionFrames(session, { input, rangeStart, rangeEnd, resu
12779
12907
  }
12780
12908
 
12781
12909
  // src/services/render/stages/captureHdrStage.ts
12782
- import { existsSync as existsSync19, mkdirSync as mkdirSync10 } from "node:fs";
12783
- import { join as join30 } from "node:path";
12910
+ import { existsSync as existsSync20, mkdirSync as mkdirSync10 } from "node:fs";
12911
+ import { join as join31 } from "node:path";
12784
12912
  import {
12785
12913
  closeCaptureSession as closeCaptureSession7,
12786
12914
  cloneCaptureWarnings as cloneCaptureWarnings2,
@@ -12852,7 +12980,7 @@ function createHdrImageTransferCache(options = {}) {
12852
12980
  }
12853
12981
 
12854
12982
  // src/services/render/stages/captureHdrSequentialLoop.ts
12855
- import { join as join27 } from "node:path";
12983
+ import { join as join28 } from "node:path";
12856
12984
  import {
12857
12985
  TRANSITIONS,
12858
12986
  crossfade
@@ -12977,7 +13105,7 @@ async function runSequentialLayeredFrameLoop(input) {
12977
13105
  );
12978
13106
  if (debugDumpEnabled && debugDumpDir && i % 30 === 0) {
12979
13107
  writeFileExclusiveSync(
12980
- join27(debugDumpDir, `frame_${String(i).padStart(4, "0")}_final_rgb48le.bin`),
13108
+ join28(debugDumpDir, `frame_${String(i).padStart(4, "0")}_final_rgb48le.bin`),
12981
13109
  normalCanvas
12982
13110
  );
12983
13111
  }
@@ -13009,7 +13137,7 @@ async function runSequentialLayeredFrameLoop(input) {
13009
13137
  }
13010
13138
 
13011
13139
  // src/services/render/stages/captureHdrHybridLoop.ts
13012
- import { join as join29 } from "node:path";
13140
+ import { join as join30 } from "node:path";
13013
13141
  import {
13014
13142
  TRANSITIONS as TRANSITIONS2,
13015
13143
  closeCaptureSession as closeCaptureSession6,
@@ -13023,10 +13151,10 @@ import {
13023
13151
  // src/services/shaderTransitionWorkerPool.ts
13024
13152
  import { Worker } from "node:worker_threads";
13025
13153
  import { fileURLToPath as fileURLToPath3, pathToFileURL } from "node:url";
13026
- import { dirname as dirname12, join as join28 } from "node:path";
13154
+ import { dirname as dirname12, join as join29 } from "node:path";
13027
13155
  import { createRequire } from "node:module";
13028
13156
  import { usableCpuCount } from "@hyperframes/engine";
13029
- import { existsSync as existsSync18 } from "node:fs";
13157
+ import { existsSync as existsSync19 } from "node:fs";
13030
13158
  function resolveWorkerEntry(explicit) {
13031
13159
  if (explicit && explicit.length > 0) {
13032
13160
  return { path: explicit, isTs: explicit.endsWith(".ts") };
@@ -13037,9 +13165,9 @@ function resolveWorkerEntry(explicit) {
13037
13165
  return { path: override, isTs };
13038
13166
  }
13039
13167
  const moduleDir = dirname12(fileURLToPath3(import.meta.url));
13040
- const jsPath = join28(moduleDir, "shaderTransitionWorker.js");
13041
- if (existsSync18(jsPath)) return { path: jsPath, isTs: false };
13042
- const tsPath = join28(moduleDir, "shaderTransitionWorker.ts");
13168
+ const jsPath = join29(moduleDir, "shaderTransitionWorker.js");
13169
+ if (existsSync19(jsPath)) return { path: jsPath, isTs: false };
13170
+ const tsPath = join29(moduleDir, "shaderTransitionWorker.ts");
13043
13171
  return { path: tsPath, isTs: true };
13044
13172
  }
13045
13173
  function buildExecArgv(entryIsTs) {
@@ -13182,8 +13310,8 @@ async function createShaderTransitionWorkerPool(opts) {
13182
13310
  if (terminated) {
13183
13311
  throw new Error("shader-blend pool already terminated");
13184
13312
  }
13185
- return new Promise((resolve13, reject) => {
13186
- const task = traceEnabled ? { req, resolve: resolve13, reject, enqueuedAtMs: Date.now(), traceId: ++nextTaskId } : { req, resolve: resolve13, reject };
13313
+ return new Promise((resolve14, reject) => {
13314
+ const task = traceEnabled ? { req, resolve: resolve14, reject, enqueuedAtMs: Date.now(), traceId: ++nextTaskId } : { req, resolve: resolve14, reject };
13187
13315
  const idle = slots.find((s) => !s.busy && !s.dead);
13188
13316
  if (idle) {
13189
13317
  queue.unshift(task);
@@ -13407,7 +13535,7 @@ async function runHybridLayeredFrameLoop(input) {
13407
13535
  );
13408
13536
  if (debugDumpEnabled && debugDumpDir && i % 30 === 0) {
13409
13537
  writeFileExclusiveSync(
13410
- join29(debugDumpDir, `frame_${String(i).padStart(4, "0")}_final_rgb48le.bin`),
13538
+ join30(debugDumpDir, `frame_${String(i).padStart(4, "0")}_final_rgb48le.bin`),
13411
13539
  canvas
13412
13540
  );
13413
13541
  }
@@ -13603,8 +13731,8 @@ async function runCaptureHdrStage(input) {
13603
13731
  if (hdrVideoFrameSources.has(v.id)) hdrVideoEndTimes.set(v.id, v.end);
13604
13732
  }
13605
13733
  const debugDumpEnabled = process.env.KEEP_TEMP === "1";
13606
- const debugDumpDir = debugDumpEnabled ? join30(framesDir, "debug-composite") : null;
13607
- if (debugDumpDir && !existsSync19(debugDumpDir)) {
13734
+ const debugDumpDir = debugDumpEnabled ? join31(framesDir, "debug-composite") : null;
13735
+ if (debugDumpDir && !existsSync20(debugDumpDir)) {
13608
13736
  mkdirSync10(debugDumpDir, { recursive: true });
13609
13737
  }
13610
13738
  const compositeTransfer = resolveCompositeTransfer(hasHdrContent, effectiveHdr);
@@ -13763,7 +13891,7 @@ async function runCaptureHdrStage(input) {
13763
13891
  // src/services/render/stages/encodeStage.ts
13764
13892
  import {
13765
13893
  copyFileSync as copyFileSync4,
13766
- existsSync as existsSync20,
13894
+ existsSync as existsSync21,
13767
13895
  mkdirSync as mkdirSync11,
13768
13896
  readdirSync as readdirSync5,
13769
13897
  readFileSync as readFileSync9,
@@ -13772,7 +13900,7 @@ import {
13772
13900
  writeFileSync as writeFileSync6
13773
13901
  } from "node:fs";
13774
13902
  import { readFile as readFile2 } from "node:fs/promises";
13775
- import { dirname as dirname13, join as join31 } from "node:path";
13903
+ import { dirname as dirname13, join as join32 } from "node:path";
13776
13904
  import {
13777
13905
  encodeFramesChunkedConcat,
13778
13906
  encodeFramesFromDir,
@@ -13897,7 +14025,7 @@ async function encodeGifFromDir(framesDir, framePattern, outputPath, input) {
13897
14025
  const failure = await reencodeWithClearedWholeFrames(argsInput, run, startTime);
13898
14026
  if (failure) return failure;
13899
14027
  }
13900
- const fileSize = existsSync20(outputPath) ? statSync10(outputPath).size : 0;
14028
+ const fileSize = existsSync21(outputPath) ? statSync10(outputPath).size : 0;
13901
14029
  return {
13902
14030
  success: true,
13903
14031
  outputPath,
@@ -13988,10 +14116,10 @@ function encodeWhileCapturing(input, totalFrames, captureBudget) {
13988
14116
  const stream = await encoder;
13989
14117
  for (let next = 0; next < totalFrames; next++) {
13990
14118
  while (!landed.has(next) && !captureDone && !signal.aborted) {
13991
- await new Promise((resolve13) => wake = resolve13);
14119
+ await new Promise((resolve14) => wake = resolve14);
13992
14120
  }
13993
14121
  if (signal.aborted) return;
13994
- const mergedPath = join31(input.framesDir, formatCaptureFrameName(next, "jpg"));
14122
+ const mergedPath = join32(input.framesDir, formatCaptureFrameName(next, "jpg"));
13995
14123
  const frame = await readLandedFrame(landed.get(next), mergedPath);
13996
14124
  landed.delete(next);
13997
14125
  if (!await stream.writeFrame(frame)) {
@@ -14066,7 +14194,7 @@ async function runEncodeStage(input) {
14066
14194
  const stage5Start = Date.now();
14067
14195
  if (isPngSequence) {
14068
14196
  const encoded = startEncodeProgress(job, "Writing PNG sequence", onProgress);
14069
- if (!existsSync20(outputPath)) mkdirSync11(outputPath, { recursive: true });
14197
+ if (!existsSync21(outputPath)) mkdirSync11(outputPath, { recursive: true });
14070
14198
  const captured = readdirSync5(framesDir).filter((name) => name.endsWith(".png")).sort();
14071
14199
  if (captured.length === 0) {
14072
14200
  throw new Error(
@@ -14074,11 +14202,11 @@ async function runEncodeStage(input) {
14074
14202
  );
14075
14203
  }
14076
14204
  captured.forEach((name, i) => {
14077
- const dst = join31(outputPath, formatExportFrameName(i, "png"));
14078
- copyFileSync4(join31(framesDir, name), dst);
14205
+ const dst = join32(outputPath, formatExportFrameName(i, "png"));
14206
+ copyFileSync4(join32(framesDir, name), dst);
14079
14207
  });
14080
- if (hasAudio && audioOutputPath && existsSync20(audioOutputPath)) {
14081
- copyFileSync4(audioOutputPath, join31(outputPath, MIXED_AUDIO_FILENAME2));
14208
+ if (hasAudio && audioOutputPath && existsSync21(audioOutputPath)) {
14209
+ copyFileSync4(audioOutputPath, join32(outputPath, MIXED_AUDIO_FILENAME2));
14082
14210
  log.info(
14083
14211
  `[Render] png-sequence: ${MIXED_AUDIO_FILENAME2} sidecar written to ${outputPath}/${MIXED_AUDIO_FILENAME2}`
14084
14212
  );
@@ -14098,7 +14226,7 @@ async function runEncodeStage(input) {
14098
14226
  const encodeResult2 = await encodeGifFromDir(framesDir, framePattern2, outputPath, {
14099
14227
  fps: job.config.fps,
14100
14228
  loop,
14101
- palettePath: join31(dirname13(videoOnlyPath), "gif-palette.png"),
14229
+ palettePath: join32(dirname13(videoOnlyPath), "gif-palette.png"),
14102
14230
  preserveAlpha: needsAlpha,
14103
14231
  signal: abortSignal,
14104
14232
  timeout: engineCfg.ffmpegEncodeTimeout
@@ -14309,7 +14437,7 @@ function sampleDirectoryBytes(dir) {
14309
14437
  continue;
14310
14438
  }
14311
14439
  for (const name of entries) {
14312
- const full = join32(current, name);
14440
+ const full = join33(current, name);
14313
14441
  try {
14314
14442
  const st = statSync11(full);
14315
14443
  if (st.isDirectory()) {
@@ -14345,6 +14473,7 @@ function summarizeExtractionObservability(extractionResult, videoCount, coverage
14345
14473
  vfrPreflightCount: phaseBreakdown?.vfrPreflightCount,
14346
14474
  cacheHits: phaseBreakdown?.cacheHits,
14347
14475
  cacheMisses: phaseBreakdown?.cacheMisses,
14476
+ cachePublishFailures: phaseBreakdown?.cachePublishFailures,
14348
14477
  transientRetries: phaseBreakdown?.transientRetries,
14349
14478
  ...coverageGauges,
14350
14479
  authoredTimedClipCount
@@ -14466,8 +14595,8 @@ function findMissingFrameRanges(totalFrames, framesDir, frameExt) {
14466
14595
  const ranges = [];
14467
14596
  let rangeStart = null;
14468
14597
  for (let frameIndex = 0; frameIndex < totalFrames; frameIndex++) {
14469
- const framePath = join32(framesDir, formatCaptureFrameName(frameIndex, frameExt));
14470
- const missing = !existsSync21(framePath) || statSync11(framePath).size <= 8;
14598
+ const framePath = join33(framesDir, formatCaptureFrameName(frameIndex, frameExt));
14599
+ const missing = !existsSync22(framePath) || statSync11(framePath).size <= 8;
14471
14600
  if (missing && rangeStart === null) {
14472
14601
  rangeStart = frameIndex;
14473
14602
  } else if (!missing && rangeStart !== null) {
@@ -14483,7 +14612,7 @@ function findMissingFrameRanges(totalFrames, framesDir, frameExt) {
14483
14612
  function buildMissingFrameRetryBatches(ranges, maxWorkers, workDir, attempt, rangeStart = 0, stride = 1) {
14484
14613
  const workersPerBatch = Math.max(1, Math.floor(maxWorkers));
14485
14614
  const batches = [];
14486
- const outputDirFor = (batchIndex, workerId) => join32(workDir, `retry-${attempt}-batch-${batchIndex}-worker-${workerId}`);
14615
+ const outputDirFor = (batchIndex, workerId) => join33(workDir, `retry-${attempt}-batch-${batchIndex}-worker-${workerId}`);
14487
14616
  if (stride > 1) {
14488
14617
  const spans = /* @__PURE__ */ new Map();
14489
14618
  for (const range of ranges) {
@@ -14542,9 +14671,9 @@ function createCaptureObservabilityUpdater(observability, platform2 = process.pl
14542
14671
  function getNextRetryWorkerCount(currentWorkers) {
14543
14672
  return Math.max(1, Math.floor(currentWorkers / 2));
14544
14673
  }
14545
- function resolveRenderWorkDirPrefix(outputPath, jobId, platform2 = process.platform, systemTempDir = tmpdir2()) {
14546
- if (platform2 === "win32" || platform2 === "darwin") return join32(systemTempDir, "hf-render-");
14547
- return join32(dirname14(outputPath), `work-${jobId}-`);
14674
+ function resolveRenderWorkDirPrefix(outputPath, jobId, platform2 = process.platform, systemTempDir = tmpdir3()) {
14675
+ if (platform2 === "win32" || platform2 === "darwin") return join33(systemTempDir, "hf-render-");
14676
+ return join33(dirname14(outputPath), `work-${jobId}-`);
14548
14677
  }
14549
14678
  var MAX_TRANSIENT_CAPTURE_RETRIES = 1;
14550
14679
  function isTransientCaptureRetryEligible(failureKind, missing, retriesUsed) {
@@ -14599,8 +14728,8 @@ The composition is too large for the available memory. To reduce memory pressure
14599
14728
  function countCapturedFrames(totalFrames, framesDir, frameExt) {
14600
14729
  let captured = 0;
14601
14730
  for (let frameIndex = 0; frameIndex < totalFrames; frameIndex++) {
14602
- const framePath = join32(framesDir, formatCaptureFrameName(frameIndex, frameExt));
14603
- if (existsSync21(framePath)) captured++;
14731
+ const framePath = join33(framesDir, formatCaptureFrameName(frameIndex, frameExt));
14732
+ if (existsSync22(framePath)) captured++;
14604
14733
  }
14605
14734
  return captured;
14606
14735
  }
@@ -14625,7 +14754,7 @@ async function executeDiskCaptureWithAdaptiveRetry(options) {
14625
14754
  reason: attempt === 0 ? "initial" : pendingTransientRetry ? "transient-retry" : "retry"
14626
14755
  });
14627
14756
  pendingTransientRetry = false;
14628
- const attemptWorkDir = join32(options.workDir, `capture-attempt-${attempt}`);
14757
+ const attemptWorkDir = join33(options.workDir, `capture-attempt-${attempt}`);
14629
14758
  const batches = missingRanges ? buildMissingFrameRetryBatches(
14630
14759
  missingRanges,
14631
14760
  currentWorkers,
@@ -15272,8 +15401,8 @@ function deVerifyFallbackTelemetry(err) {
15272
15401
  };
15273
15402
  }
15274
15403
  function resolveRenderDebugDir() {
15275
- const producerRoot = process.env.PRODUCER_RENDERS_DIR ? resolve8(process.env.PRODUCER_RENDERS_DIR, "..") : resolve8(dirname14(fileURLToPath4(import.meta.url)), "../..");
15276
- return join32(producerRoot, ".debug");
15404
+ const producerRoot = process.env.PRODUCER_RENDERS_DIR ? resolve9(process.env.PRODUCER_RENDERS_DIR, "..") : resolve9(dirname14(fileURLToPath4(import.meta.url)), "../..");
15405
+ return join33(producerRoot, ".debug");
15277
15406
  }
15278
15407
  async function executeRenderJob(job, projectDir, outputPath, progressSink, abortSignal, assertRenderActive) {
15279
15408
  validateHlsRenderConfig(job.config);
@@ -15281,11 +15410,11 @@ async function executeRenderJob(job, projectDir, outputPath, progressSink, abort
15281
15410
  validateChromaSubsamplingConfig(job.config);
15282
15411
  const debugDir = resolveRenderDebugDir();
15283
15412
  const outputDir = dirname14(outputPath);
15284
- if (!existsSync21(outputDir)) mkdirSync12(outputDir, { recursive: true });
15285
- const workDir = job.config.debug ? join32(debugDir, job.id) : createRenderWorkDir(resolveRenderWorkDirPrefix(outputPath, job.id), outputDir);
15413
+ if (!existsSync22(outputDir)) mkdirSync12(outputDir, { recursive: true });
15414
+ const workDir = job.config.debug ? join33(debugDir, job.id) : createRenderWorkDir(resolveRenderWorkDirPrefix(outputPath, job.id), outputDir);
15286
15415
  const pipelineStart = Date.now();
15287
15416
  const baseLog = job.config.logger ?? defaultLogger;
15288
- const logPath = job.config.debug ? join32(workDir, "render.log") : null;
15417
+ const logPath = job.config.debug ? join33(workDir, "render.log") : null;
15289
15418
  const execution = new RenderExecutionContext({
15290
15419
  request: { renderJobId: job.id, projectDir, outputPath },
15291
15420
  logger: logPath ? createRenderFileLogger(logPath, baseLog) : baseLog,
@@ -15353,7 +15482,7 @@ async function executeRenderPipeline(input) {
15353
15482
  imageDecodeFailures: 0
15354
15483
  };
15355
15484
  let hdrPerf;
15356
- const perfOutputPath = join32(workDir, "perf-summary.json");
15485
+ const perfOutputPath = join33(workDir, "perf-summary.json");
15357
15486
  const cfg = { ...job.config.producerConfig ?? resolveConfig2() };
15358
15487
  const observability = new RenderObservabilityRecorder({
15359
15488
  pipelineStartMs: pipelineStart,
@@ -15429,7 +15558,7 @@ async function executeRenderPipeline(input) {
15429
15558
  job.startedAt = /* @__PURE__ */ new Date();
15430
15559
  assertNotAborted();
15431
15560
  assertConfiguredFfmpegBinariesExist();
15432
- if (!existsSync21(workDir)) mkdirSync12(workDir, { recursive: true });
15561
+ if (!existsSync22(workDir)) mkdirSync12(workDir, { recursive: true });
15433
15562
  if (job.config.debug) {
15434
15563
  log.info("[Render] Debug artifacts enabled", { workDir, logPath });
15435
15564
  }
@@ -15458,8 +15587,8 @@ async function executeRenderPipeline(input) {
15458
15587
  requestedWorkers: job.config.workers ?? "auto"
15459
15588
  });
15460
15589
  const entryFile = job.config.entryFile || "index.html";
15461
- const htmlPath = join32(projectDir, entryFile);
15462
- if (!existsSync21(htmlPath)) {
15590
+ const htmlPath = join33(projectDir, entryFile);
15591
+ if (!existsSync22(htmlPath)) {
15463
15592
  throw new Error(`Entry file not found: ${htmlPath}`);
15464
15593
  }
15465
15594
  assertNotAborted();
@@ -15555,7 +15684,7 @@ async function executeRenderPipeline(input) {
15555
15684
  const largerThanCanvas = await oversizedVideos(
15556
15685
  composition.videos,
15557
15686
  projectDir,
15558
- join32(workDir, "compiled"),
15687
+ join33(workDir, "compiled"),
15559
15688
  { width: outputWidth, height: outputHeight }
15560
15689
  );
15561
15690
  const probeResult = await observeRenderStage(
@@ -15652,7 +15781,7 @@ async function executeRenderPipeline(input) {
15652
15781
  canvas: { width, height },
15653
15782
  page: probeSession.page,
15654
15783
  projectDir,
15655
- compiledDir: join32(workDir, "compiled")
15784
+ compiledDir: join33(workDir, "compiled")
15656
15785
  });
15657
15786
  if (videoLayerPlan.videoId === void 0) {
15658
15787
  log.info(`[Render] Video layer passthrough off: ${videoLayerPlan.reason}`);
@@ -15670,7 +15799,7 @@ async function executeRenderPipeline(input) {
15670
15799
  updateJobStatus(job, "preprocessing", "Extracting video frames", 10, onProgress, {
15671
15800
  code: "extract_video"
15672
15801
  });
15673
- const compiledDir = join32(workDir, "compiled");
15802
+ const compiledDir = join33(workDir, "compiled");
15674
15803
  const segmentsCapture = (layeredOrEffectRoute) => shouldSegmentCapture({
15675
15804
  env: process.env,
15676
15805
  durationSeconds: probeResult.duration,
@@ -15806,7 +15935,7 @@ async function executeRenderPipeline(input) {
15806
15935
  try {
15807
15936
  fileServer = await createFileServer({
15808
15937
  projectDir,
15809
- compiledDir: join32(workDir, "compiled"),
15938
+ compiledDir: join33(workDir, "compiled"),
15810
15939
  port: 0,
15811
15940
  preHeadScripts: [VIRTUAL_TIME_SHIM],
15812
15941
  fps: job.config.fps,
@@ -15826,8 +15955,8 @@ async function executeRenderPipeline(input) {
15826
15955
  if (!activeFileServer) {
15827
15956
  throw new Error("File server failed to initialize before frame capture");
15828
15957
  }
15829
- const framesDir = join32(workDir, "captured-frames");
15830
- if (!existsSync21(framesDir)) mkdirSync12(framesDir, { recursive: true });
15958
+ const framesDir = join33(workDir, "captured-frames");
15959
+ if (!existsSync22(framesDir)) mkdirSync12(framesDir, { recursive: true });
15831
15960
  updateJobStatus(job, "rendering", "Checking browser GPU", 25, onProgress, {
15832
15961
  code: "start_browsers"
15833
15962
  });
@@ -16407,7 +16536,7 @@ async function executeRenderPipeline(input) {
16407
16536
  hls: ".mp4"
16408
16537
  };
16409
16538
  const videoExt = FORMAT_EXT[outputFormat] ?? ".mp4";
16410
- const videoOnlyPath = join32(workDir, `video-only${videoExt}`);
16539
+ const videoOnlyPath = join33(workDir, `video-only${videoExt}`);
16411
16540
  let usePageSideCompositingForTransitions = (cfg.enablePageSideCompositing || isGif) && compiled.hasShaderTransitions && !hasHdrContent && outputSupportsPageSideShaderCompositing(outputFormat);
16412
16541
  if (usePageSideCompositingForTransitions) {
16413
16542
  activeFileServer.addPreHeadScript(HF_PAGE_SIDE_COMPOSITING_STUB);
@@ -16724,7 +16853,7 @@ async function executeRenderPipeline(input) {
16724
16853
  pageMotionBlur: job.config.pageMotionBlur,
16725
16854
  captureQuality: captureOptions.quality
16726
16855
  });
16727
- const segmentDir = segmentDirFor(join32(projectDir, "renders"), segmentPlanHash);
16856
+ const segmentDir = segmentDirFor(join33(projectDir, "renders"), segmentPlanHash);
16728
16857
  let completedSegments = /* @__PURE__ */ new Set();
16729
16858
  if (job.config.resumeSegments === true) {
16730
16859
  const existing = readSegmentManifest(segmentDir);
@@ -17268,7 +17397,7 @@ async function executeRenderPipeline(input) {
17268
17397
  })
17269
17398
  );
17270
17399
  const totalElapsed = Date.now() - pipelineStart;
17271
- const tmpPeakBytes = existsSync21(workDir) ? sampleDirectoryBytes(workDir) : 0;
17400
+ const tmpPeakBytes = existsSync22(workDir) ? sampleDirectoryBytes(workDir) : 0;
17272
17401
  recordTransientRetryObservability();
17273
17402
  observability.checkpoint("pipeline", "artifact validated", { totalElapsedMs: totalElapsed });
17274
17403
  const observabilitySummary = observability.summary({
@@ -17349,8 +17478,8 @@ async function executeRenderPipeline(input) {
17349
17478
  }
17350
17479
  }
17351
17480
  if (job.config.debug) {
17352
- if (!isPngSequence && !isHls && existsSync21(stagedOutputPath)) {
17353
- const debugOutput = join32(workDir, `output${videoExt}`);
17481
+ if (!isPngSequence && !isHls && existsSync22(stagedOutputPath)) {
17482
+ const debugOutput = join33(workDir, `output${videoExt}`);
17354
17483
  copyFileSync5(stagedOutputPath, debugOutput);
17355
17484
  }
17356
17485
  }
@@ -17429,7 +17558,8 @@ async function executeRenderPipeline(input) {
17429
17558
  perfStages,
17430
17559
  hdrDiagnostics,
17431
17560
  observability: observabilitySummary,
17432
- subTimelineWait: worstSubTimelineWaitOutcome(dedupPerfs)
17561
+ subTimelineWait: worstSubTimelineWaitOutcome(dedupPerfs),
17562
+ missingPath: describeMissingPath(error, { cacheDir: cfg.extractCacheDir, workDir })
17433
17563
  });
17434
17564
  publishRenderFailure(
17435
17565
  job,
@@ -17468,14 +17598,14 @@ import {
17468
17598
  referenceBackgroundResult as referenceBackgroundResult6
17469
17599
  } from "@hyperframes/engine";
17470
17600
  import { mkdirSync as mkdirSync20, mkdtempSync, readFileSync as readFileSync15, rmSync as rmSync18 } from "node:fs";
17471
- import { join as join46 } from "node:path";
17472
- import { tmpdir as tmpdir4 } from "node:os";
17601
+ import { join as join47 } from "node:path";
17602
+ import { tmpdir as tmpdir5 } from "node:os";
17473
17603
 
17474
17604
  // src/services/distributed/mp4Stitch.ts
17475
17605
  import { createReadStream as createReadStream3, createWriteStream, mkdirSync as mkdirSync13, rmSync as rmSync13 } from "node:fs";
17476
17606
  import { open } from "node:fs/promises";
17477
17607
  import { renameWithRetry as renameWithRetry7 } from "@hyperframes/engine";
17478
- import { basename as basename7, dirname as dirname15, join as join33 } from "node:path";
17608
+ import { basename as basename8, dirname as dirname15, join as join34 } from "node:path";
17479
17609
  import { finished, pipeline } from "node:stream/promises";
17480
17610
  import { createStagingDir as createStagingDir4 } from "@hyperframes/core/atomic-file";
17481
17611
  function boxAt(src, off, at, limit) {
@@ -17841,14 +17971,14 @@ async function writeStitchedMp4(chunkPaths, outputPath, audioPath) {
17841
17971
  const layouts = await Promise.all(sourcePaths.map((path) => readMp4Layout(fileRange(path))));
17842
17972
  const header = audioPath ? buildStitchedHeader(layouts.slice(1), layouts[0]) : buildStitchedHeader(layouts);
17843
17973
  mkdirSync13(dirname15(outputPath), { recursive: true });
17844
- const workDir = createStagingDir4(dirname15(outputPath), `${basename7(outputPath)}.stitch-`);
17845
- const out = createWriteStream(join33(workDir, "out.mp4"));
17974
+ const workDir = createStagingDir4(dirname15(outputPath), `${basename8(outputPath)}.stitch-`);
17975
+ const out = createWriteStream(join34(workDir, "out.mp4"));
17846
17976
  try {
17847
17977
  out.write(header);
17848
17978
  for (const [i, path] of sourcePaths.entries()) await copyPayload(path, layouts[i], i, out);
17849
17979
  out.end();
17850
17980
  await finished(out);
17851
- renameWithRetry7(join33(workDir, "out.mp4"), outputPath);
17981
+ renameWithRetry7(join34(workDir, "out.mp4"), outputPath);
17852
17982
  } finally {
17853
17983
  out.destroy();
17854
17984
  rmSync13(workDir, { recursive: true, force: true });
@@ -17865,13 +17995,13 @@ import { audioFailureDiagnostics as audioFailureDiagnostics3 } from "@hyperframe
17865
17995
  import {
17866
17996
  copyFileSync as copyFileSync6,
17867
17997
  cpSync as cpSync2,
17868
- existsSync as existsSync26,
17998
+ existsSync as existsSync27,
17869
17999
  linkSync,
17870
18000
  mkdirSync as mkdirSync16,
17871
18001
  rmSync as rmSync14,
17872
18002
  writeFileSync as writeFileSync10
17873
18003
  } from "node:fs";
17874
- import { extname as extname6, isAbsolute as isAbsolute3, join as join41, relative as relative6, sep as sep4 } from "node:path";
18004
+ import { extname as extname6, isAbsolute as isAbsolute4, join as join42, relative as relative7, sep as sep5 } from "node:path";
17875
18005
  import {
17876
18006
  fpsToNumber as fpsToNumber9,
17877
18007
  HF_COLOR_GRADING_ATTR as HF_COLOR_GRADING_ATTR2
@@ -17888,7 +18018,7 @@ import {
17888
18018
  } from "@hyperframes/engine";
17889
18019
 
17890
18020
  // src/services/distributed/planFrameCost.ts
17891
- import { join as join36 } from "node:path";
18021
+ import { join as join37 } from "node:path";
17892
18022
  import {
17893
18023
  closeCaptureSession as closeCaptureSession9,
17894
18024
  createCaptureSession as createCaptureSession9,
@@ -17897,8 +18027,8 @@ import {
17897
18027
  } from "@hyperframes/engine";
17898
18028
 
17899
18029
  // src/services/distributed/chunkFrames.ts
17900
- import { existsSync as existsSync23, readdirSync as readdirSync7 } from "node:fs";
17901
- import { extname as extname4, join as join35 } from "node:path";
18030
+ import { existsSync as existsSync24, readdirSync as readdirSync7 } from "node:fs";
18031
+ import { extname as extname4, join as join36 } from "node:path";
17902
18032
  import {
17903
18033
  compositionRequiresWebGpu as compositionRequiresWebGpu3,
17904
18034
  createVideoFrameInjector as createVideoFrameInjector3,
@@ -17907,8 +18037,8 @@ import {
17907
18037
 
17908
18038
  // src/services/distributed/shared.ts
17909
18039
  import { execFile as execFileCallback } from "node:child_process";
17910
- import { dirname as dirname16, join as join34 } from "node:path";
17911
- import { existsSync as existsSync22, readFileSync as readFileSync10 } from "node:fs";
18040
+ import { dirname as dirname16, join as join35 } from "node:path";
18041
+ import { existsSync as existsSync23, readFileSync as readFileSync10 } from "node:fs";
17912
18042
  import { fileURLToPath as fileURLToPath5 } from "node:url";
17913
18043
  import { promisify as promisify2 } from "node:util";
17914
18044
  import {
@@ -17923,8 +18053,8 @@ function isPlanAudioArtifactPath(path) {
17923
18053
  }
17924
18054
  function resolvePlanAudioPath(planDir) {
17925
18055
  for (const name of [PLAN_AUDIO_RELATIVE_PATH, PLAN_AUDIO_LEGACY_RELATIVE_PATH]) {
17926
- const candidate = join34(planDir, name);
17927
- if (existsSync22(candidate)) return candidate;
18056
+ const candidate = join35(planDir, name);
18057
+ if (existsSync23(candidate)) return candidate;
17928
18058
  }
17929
18059
  return null;
17930
18060
  }
@@ -18188,8 +18318,8 @@ function readProducerVersion() {
18188
18318
  const startDir = dirname16(fileURLToPath5(import.meta.url));
18189
18319
  let current = startDir;
18190
18320
  for (let i = 0; i < 10; i++) {
18191
- const candidate = join34(current, "package.json");
18192
- if (existsSync22(candidate)) {
18321
+ const candidate = join35(current, "package.json");
18322
+ if (existsSync23(candidate)) {
18193
18323
  try {
18194
18324
  const pkg = JSON.parse(readFileSync10(candidate, "utf-8"));
18195
18325
  if (pkg.name === "@hyperframes/producer" && typeof pkg.version === "string") {
@@ -18243,8 +18373,8 @@ function frameNumberFromFileName(name) {
18243
18373
  function rebuildExtractedFramesFromPlanDir(planDir, videos, indexMode = "dense-v1") {
18244
18374
  const result = [];
18245
18375
  for (const v of videos) {
18246
- const outputDir = join35(planDir, "video-frames", mediaIdPathSegment3(v.videoId));
18247
- if (!existsSync23(outputDir)) {
18376
+ const outputDir = join36(planDir, "video-frames", mediaIdPathSegment3(v.videoId));
18377
+ if (!existsSync24(outputDir)) {
18248
18378
  throw new Error(
18249
18379
  `[renderChunk] planDir missing extracted video frames for ${JSON.stringify(v.videoId)}: ${outputDir} not present. plan() should have written frames here; the planDir is malformed.`
18250
18380
  );
@@ -18262,7 +18392,7 @@ function rebuildExtractedFramesFromPlanDir(planDir, videos, indexMode = "dense-v
18262
18392
  if (!frameName) continue;
18263
18393
  const frameNumber = indexMode === "sparse-v2" ? frameNumberFromFileName(frameName) : null;
18264
18394
  const frameIndex = frameNumber === null ? i : frameNumber - 1;
18265
- framePaths.set(frameIndex, join35(outputDir, frameName));
18395
+ framePaths.set(frameIndex, join36(outputDir, frameName));
18266
18396
  }
18267
18397
  result.push({
18268
18398
  videoId: v.videoId,
@@ -18342,8 +18472,8 @@ async function extractDeferredVideoFramesForChunk(input) {
18342
18472
  sourceOf: (video) => {
18343
18473
  const range = planned.get(video.videoId).deferredRange;
18344
18474
  const remoteUrl = remoteSources[range.sourcePath];
18345
- const sourcePath = remoteUrl ?? join35(input.planDir, ...range.sourcePath.split("/"));
18346
- if (remoteUrl === void 0 && !existsSync23(sourcePath)) {
18475
+ const sourcePath = remoteUrl ?? join36(input.planDir, ...range.sourcePath.split("/"));
18476
+ if (remoteUrl === void 0 && !existsSync24(sourcePath)) {
18347
18477
  throw new RenderChunkValidationError(
18348
18478
  MISSING_PLAN_ARTIFACT,
18349
18479
  `[renderChunk] planDir is missing the source for video ${JSON.stringify(video.videoId)}: ${range.sourcePath}`
@@ -18373,12 +18503,12 @@ async function measurePlanSecondsPerFrame(input) {
18373
18503
  planVideos,
18374
18504
  frames: sampled,
18375
18505
  fps: fpsRatio,
18376
- outputRoot: join36(workDir, "frame-cost-video-frames"),
18506
+ outputRoot: join37(workDir, "frame-cost-video-frames"),
18377
18507
  cfg: input.cfg
18378
18508
  })
18379
18509
  ];
18380
18510
  const lookup = extracted.length > 0 ? createFrameLookupTable4(planVideos.videos, extracted, resolveRenderFpsConfig(fpsRatio).value) : null;
18381
- const compiledDir = join36(planDir, "compiled");
18511
+ const compiledDir = join37(planDir, "compiled");
18382
18512
  const fileServer = await createFileServer({
18383
18513
  projectDir: compiledDir,
18384
18514
  compiledDir,
@@ -18390,7 +18520,7 @@ async function measurePlanSecondsPerFrame(input) {
18390
18520
  try {
18391
18521
  session = await createCaptureSession9(
18392
18522
  fileServer.url,
18393
- join36(workDir, "frame-cost"),
18523
+ join37(workDir, "frame-cost"),
18394
18524
  buildChunkCaptureOptions({
18395
18525
  dimensions: { ...input, fpsNum: fps, fpsDen: 1 },
18396
18526
  encoder: input,
@@ -18487,7 +18617,7 @@ function buildWeightedChunkSlices(weights, chunkCount, minFrames, maxFrames) {
18487
18617
  }
18488
18618
 
18489
18619
  // src/services/render/planReferenceBackground.ts
18490
- import { join as join37 } from "node:path";
18620
+ import { join as join38 } from "node:path";
18491
18621
  import {
18492
18622
  closeCaptureSession as closeCaptureSession10,
18493
18623
  createCaptureSession as createCaptureSession10,
@@ -18500,14 +18630,14 @@ async function readPlanReferenceBackground(input) {
18500
18630
  try {
18501
18631
  server = await createFileServer({
18502
18632
  projectDir: input.projectDir,
18503
- compiledDir: join37(input.workDir, "compiled"),
18633
+ compiledDir: join38(input.workDir, "compiled"),
18504
18634
  port: 0,
18505
18635
  preHeadScripts: [VIRTUAL_TIME_SHIM],
18506
18636
  fps: input.options.fps
18507
18637
  });
18508
18638
  session = await createCaptureSession10(
18509
18639
  server.url,
18510
- join37(input.workDir, "reference"),
18640
+ join38(input.workDir, "reference"),
18511
18641
  {
18512
18642
  ...input.options,
18513
18643
  requiresWebGpu: false
@@ -18543,8 +18673,8 @@ async function readPlanReferenceBackground(input) {
18543
18673
  }
18544
18674
 
18545
18675
  // src/services/render/stages/freezePlan.ts
18546
- import { existsSync as existsSync24, mkdirSync as mkdirSync14, readFileSync as readFileSync11, readdirSync as readdirSync8, writeFileSync as writeFileSync8 } from "node:fs";
18547
- import { join as join38, relative as relative4, resolve as resolve9 } from "node:path";
18676
+ import { existsSync as existsSync25, mkdirSync as mkdirSync14, readFileSync as readFileSync11, readdirSync as readdirSync8, writeFileSync as writeFileSync8 } from "node:fs";
18677
+ import { join as join39, relative as relative5, resolve as resolve10 } from "node:path";
18548
18678
  import {
18549
18679
  REFERENCE_BACKGROUND_FIELD,
18550
18680
  referenceBackgroundResult as referenceBackgroundResult3
@@ -18737,7 +18867,7 @@ function planFileSha256(absolutePath, digests) {
18737
18867
  return sha256;
18738
18868
  }
18739
18869
  async function prehashPlanFiles(dir, digests) {
18740
- if (!existsSync24(dir)) return;
18870
+ if (!existsSync25(dir)) return;
18741
18871
  for (const { absolutePath } of listPlanFiles(dir)) {
18742
18872
  if (!digests.has(absolutePath)) digests.set(absolutePath, await sha256FileAsync(absolutePath));
18743
18873
  }
@@ -18758,16 +18888,16 @@ function stripUndefined(value) {
18758
18888
  }
18759
18889
  function listPlanFiles(planDir) {
18760
18890
  const results = [];
18761
- const rootResolved = resolve9(planDir);
18891
+ const rootResolved = resolve10(planDir);
18762
18892
  function walk(dir) {
18763
18893
  const entries = readdirSync8(dir, { withFileTypes: true });
18764
18894
  for (const entry of entries) {
18765
- const full = join38(dir, entry.name);
18895
+ const full = join39(dir, entry.name);
18766
18896
  if (entry.isDirectory()) {
18767
18897
  walk(full);
18768
18898
  } else if (entry.isFile()) {
18769
18899
  results.push({
18770
- planRelativePath: relative4(rootResolved, full).split(/[\\/]+/).join("/"),
18900
+ planRelativePath: relative5(rootResolved, full).split(/[\\/]+/).join("/"),
18771
18901
  absolutePath: full
18772
18902
  });
18773
18903
  }
@@ -18803,19 +18933,19 @@ var PLAN_REMOTE_FILES_RELATIVE_PATH = "meta/remote-files.json";
18803
18933
  function writePlanRemoteFiles(planDir, files) {
18804
18934
  if (files.length === 0) return;
18805
18935
  const sorted = [...files].sort((a, b) => a.path < b.path ? -1 : 1);
18806
- writeFileSync8(join38(planDir, PLAN_REMOTE_FILES_RELATIVE_PATH), JSON.stringify(sorted), "utf-8");
18936
+ writeFileSync8(join39(planDir, PLAN_REMOTE_FILES_RELATIVE_PATH), JSON.stringify(sorted), "utf-8");
18807
18937
  }
18808
18938
  function readPlanRemoteFiles(planDir) {
18809
- const path = join38(planDir, PLAN_REMOTE_FILES_RELATIVE_PATH);
18810
- return existsSync24(path) ? JSON.parse(readFileSync11(path, "utf-8")) : [];
18939
+ const path = join39(planDir, PLAN_REMOTE_FILES_RELATIVE_PATH);
18940
+ return existsSync25(path) ? JSON.parse(readFileSync11(path, "utf-8")) : [];
18811
18941
  }
18812
18942
  function recomputePlanHashFromPlanDir(planDir, digests) {
18813
- const planJsonPath = join38(planDir, "plan.json");
18814
- const encoderJsonPath = join38(planDir, "meta", "encoder.json");
18815
- if (!existsSync24(planJsonPath)) {
18943
+ const planJsonPath = join39(planDir, "plan.json");
18944
+ const encoderJsonPath = join39(planDir, "meta", "encoder.json");
18945
+ if (!existsSync25(planJsonPath)) {
18816
18946
  throw new Error(`[freezePlan] plan.json missing: ${planJsonPath}`);
18817
18947
  }
18818
- if (!existsSync24(encoderJsonPath)) {
18948
+ if (!existsSync25(encoderJsonPath)) {
18819
18949
  throw new Error(`[freezePlan] meta/encoder.json missing: ${encoderJsonPath}`);
18820
18950
  }
18821
18951
  const planJson = JSON.parse(readFileSync11(planJsonPath, "utf-8"));
@@ -18845,21 +18975,21 @@ async function freezePlan(input) {
18845
18975
  hasAudio,
18846
18976
  digests
18847
18977
  } = input;
18848
- if (!existsSync24(planDir)) {
18978
+ if (!existsSync25(planDir)) {
18849
18979
  throw new Error(`[freezePlan] planDir does not exist: ${planDir}`);
18850
18980
  }
18851
- const metaDir = join38(planDir, "meta");
18852
- if (!existsSync24(metaDir)) mkdirSync14(metaDir, { recursive: true });
18981
+ const metaDir = join39(planDir, "meta");
18982
+ if (!existsSync25(metaDir)) mkdirSync14(metaDir, { recursive: true });
18853
18983
  writeFileSync8(
18854
- join38(metaDir, "composition.json"),
18984
+ join39(metaDir, "composition.json"),
18855
18985
  `${JSON.stringify(composition, null, 2)}
18856
18986
  `,
18857
18987
  "utf-8"
18858
18988
  );
18859
18989
  const encoderForCanonical = stripUndefined(encoder);
18860
18990
  const encoderConfigCanonicalJson = canonicalJsonStringify(encoderForCanonical);
18861
- writeFileSync8(join38(metaDir, "encoder.json"), encoderConfigCanonicalJson, "utf-8");
18862
- writeFileSync8(join38(metaDir, "chunks.json"), `${JSON.stringify(chunks, null, 2)}
18991
+ writeFileSync8(join39(metaDir, "encoder.json"), encoderConfigCanonicalJson, "utf-8");
18992
+ writeFileSync8(join39(metaDir, "chunks.json"), `${JSON.stringify(chunks, null, 2)}
18863
18993
  `, "utf-8");
18864
18994
  const { compositionHtml, assets } = collectPlanAssetShas(planDir, digests);
18865
18995
  const planHash = computePlanHash({
@@ -18884,7 +19014,7 @@ async function freezePlan(input) {
18884
19014
  duration: durationSeconds,
18885
19015
  hasAudio
18886
19016
  };
18887
- const planJsonPath = join38(planDir, "plan.json");
19017
+ const planJsonPath = join39(planDir, "plan.json");
18888
19018
  writeFileSync8(planJsonPath, `${JSON.stringify(planJson, null, 2)}
18889
19019
  `, "utf-8");
18890
19020
  return { planJsonPath, planHash };
@@ -18926,9 +19056,9 @@ function applyRuntimeEnvSnapshot(snapshot, env = process.env) {
18926
19056
  }
18927
19057
 
18928
19058
  // src/services/distributed/chunkAudio.ts
18929
- import { closeSync as closeSync6, existsSync as existsSync25, ftruncateSync, mkdirSync as mkdirSync15, openSync as openSync6, readFileSync as readFileSync12 } from "node:fs";
19059
+ import { closeSync as closeSync6, existsSync as existsSync26, ftruncateSync, mkdirSync as mkdirSync15, openSync as openSync6, readFileSync as readFileSync12 } from "node:fs";
18930
19060
  import { writeFileSync as writeFileSync9, writeSync } from "node:fs";
18931
- import { join as join39 } from "node:path";
19061
+ import { join as join40 } from "node:path";
18932
19062
  import { appendRenderProvenanceArgs, describeFfmpegFailure as describeFfmpegFailure4, runFfmpeg as runFfmpeg7 } from "@hyperframes/engine";
18933
19063
  function audioCutForChunk(grid, chunks, index, fps) {
18934
19064
  const firstPacketAt = (frame) => Math.min(
@@ -19016,7 +19146,7 @@ async function writeChunkAudioSlices(input) {
19016
19146
  });
19017
19147
  const bytes = readFileSync12(input.audioPath);
19018
19148
  const layout = { sizeBytes: bytes.length, payloadStart, payloadEnd, partStarts: {} };
19019
- mkdirSync15(join39(input.planDir, SLICE_DIR), { recursive: true });
19149
+ mkdirSync15(join40(input.planDir, SLICE_DIR), { recursive: true });
19020
19150
  input.chunks.forEach((_, index) => {
19021
19151
  const cut = audioCutForChunk(grid, input.chunks, index, input.fps);
19022
19152
  if (!cut) return;
@@ -19024,17 +19154,17 @@ async function writeChunkAudioSlices(input) {
19024
19154
  const start = offsets[cut.firstPacket];
19025
19155
  layout.partStarts[index] = start;
19026
19156
  const end = offsets[last] + track.sizes[last];
19027
- writeFileSync9(join39(input.planDir, chunkAudioSlicePath(index)), bytes.subarray(start, end));
19157
+ writeFileSync9(join40(input.planDir, chunkAudioSlicePath(index)), bytes.subarray(start, end));
19028
19158
  });
19029
19159
  const frame = [bytes.subarray(0, payloadStart), bytes.subarray(payloadEnd)];
19030
- writeFileSync9(join39(input.planDir, SLICE_FRAME), Buffer.concat(frame));
19031
- writeFileSync9(join39(input.planDir, SLICE_LAYOUT), JSON.stringify(layout));
19160
+ writeFileSync9(join40(input.planDir, SLICE_FRAME), Buffer.concat(frame));
19161
+ writeFileSync9(join40(input.planDir, SLICE_LAYOUT), JSON.stringify(layout));
19032
19162
  }
19033
19163
  function chunkAudioSource(planDir, chunkIndex, scratchPath) {
19034
- const layoutPath = join39(planDir, SLICE_LAYOUT);
19035
- if (!existsSync25(layoutPath)) return resolvePlanAudioPath(planDir);
19164
+ const layoutPath = join40(planDir, SLICE_LAYOUT);
19165
+ if (!existsSync26(layoutPath)) return resolvePlanAudioPath(planDir);
19036
19166
  const layout = JSON.parse(readFileSync12(layoutPath, "utf-8"));
19037
- const frame = readFileSync12(join39(planDir, SLICE_FRAME));
19167
+ const frame = readFileSync12(join40(planDir, SLICE_FRAME));
19038
19168
  const fd = openSync6(scratchPath, "w");
19039
19169
  try {
19040
19170
  writeSync(fd, frame, 0, layout.payloadStart, 0);
@@ -19047,7 +19177,7 @@ function chunkAudioSource(planDir, chunkIndex, scratchPath) {
19047
19177
  );
19048
19178
  const start = layout.partStarts[chunkIndex];
19049
19179
  if (start !== void 0) {
19050
- const part = readFileSync12(join39(planDir, chunkAudioSlicePath(chunkIndex)));
19180
+ const part = readFileSync12(join40(planDir, chunkAudioSlicePath(chunkIndex)));
19051
19181
  writeSync(fd, part, 0, part.length, start);
19052
19182
  }
19053
19183
  ftruncateSync(fd, layout.sizeBytes);
@@ -19102,8 +19232,8 @@ async function muxChunkWithAudio(input) {
19102
19232
 
19103
19233
  // src/services/distributed/planSize.ts
19104
19234
  import { createHash as createHash9 } from "node:crypto";
19105
- import { lstatSync as lstatSync2, readdirSync as readdirSync9 } from "node:fs";
19106
- import { extname as extname5, join as join40, relative as relative5 } from "node:path";
19235
+ import { lstatSync as lstatSync3, readdirSync as readdirSync9 } from "node:fs";
19236
+ import { extname as extname5, join as join41, relative as relative6 } from "node:path";
19107
19237
  var MAX_TOP_COMPONENTS = 10;
19108
19238
  var SOURCE_MEDIA_EXTENSIONS = /* @__PURE__ */ new Set([
19109
19239
  ".aac",
@@ -19186,13 +19316,13 @@ function addCategoryBytes(result, category, filePath, sizeBytes) {
19186
19316
  function recordFile(result, components, rootDir, rootKind, filePath) {
19187
19317
  let sizeBytes;
19188
19318
  try {
19189
- const stat = lstatSync2(filePath);
19319
+ const stat = lstatSync3(filePath);
19190
19320
  if (!stat.isFile()) return;
19191
19321
  sizeBytes = stat.size;
19192
19322
  } catch {
19193
19323
  return;
19194
19324
  }
19195
- const rel = relative5(rootDir, filePath);
19325
+ const rel = relative6(rootDir, filePath);
19196
19326
  const segments = rel.split(/[\\/]+/).filter(Boolean);
19197
19327
  const classified = classifyFile(segments, rootKind);
19198
19328
  result.totalBytes += sizeBytes;
@@ -19215,7 +19345,7 @@ function walkRegularFiles(dir, visit) {
19215
19345
  return;
19216
19346
  }
19217
19347
  for (const entry of entries) {
19218
- const full = join40(dir, entry.name);
19348
+ const full = join41(dir, entry.name);
19219
19349
  if (entry.isDirectory()) {
19220
19350
  walkRegularFiles(full, visit);
19221
19351
  } else if (entry.isFile()) {
@@ -19431,13 +19561,13 @@ function assertPositiveInteger2(name, value) {
19431
19561
  }
19432
19562
  var FREEZE_OWNED_PLAN_FILES = [
19433
19563
  "plan.json",
19434
- join41("meta", "composition.json"),
19435
- join41("meta", "encoder.json"),
19436
- join41("meta", "chunks.json")
19564
+ join42("meta", "composition.json"),
19565
+ join42("meta", "encoder.json"),
19566
+ join42("meta", "chunks.json")
19437
19567
  ];
19438
19568
  function removeFreezeOwnedPlanFiles(planDir) {
19439
19569
  for (const relativePath of FREEZE_OWNED_PLAN_FILES) {
19440
- rmSync14(join41(planDir, relativePath), { force: true });
19570
+ rmSync14(join42(planDir, relativePath), { force: true });
19441
19571
  }
19442
19572
  }
19443
19573
  function buildChunkSlices(totalFrames, chunkCount, effectiveChunkSize) {
@@ -19576,16 +19706,16 @@ function resolveDistributedEngineConfig(config) {
19576
19706
  };
19577
19707
  }
19578
19708
  function leavesRoot(rel) {
19579
- return rel === ".." || rel.startsWith(`..${sep4}`) || isAbsolute3(rel);
19709
+ return rel === ".." || rel.startsWith(`..${sep5}`) || isAbsolute4(rel);
19580
19710
  }
19581
19711
  function pathInside(root, path) {
19582
- const rel = relative6(root, path);
19712
+ const rel = relative7(root, path);
19583
19713
  return rel === "" || leavesRoot(rel) ? null : rel;
19584
19714
  }
19585
19715
  function stableSourcePath(roots, srcPath) {
19586
19716
  for (const [root, prefix] of roots) {
19587
19717
  const rel = pathInside(root, srcPath);
19588
- if (rel !== null) return [prefix, ...rel.split(sep4)].filter(Boolean).join("/");
19718
+ if (rel !== null) return [prefix, ...rel.split(sep5)].filter(Boolean).join("/");
19589
19719
  }
19590
19720
  return srcPath;
19591
19721
  }
@@ -19595,19 +19725,19 @@ function createVideoSourceShipper(input) {
19595
19725
  const known = shipped.get(srcPath);
19596
19726
  if (known) return known;
19597
19727
  const stagedRel = pathInside(input.workVideoFramesDir, srcPath);
19598
- const current = stagedRel === null ? srcPath : join41(input.planDir, "video-frames", stagedRel);
19728
+ const current = stagedRel === null ? srcPath : join42(input.planDir, "video-frames", stagedRel);
19599
19729
  let result = null;
19600
19730
  for (const root of stagedRel === null ? [input.workCompiledDir, input.projectDir] : []) {
19601
19731
  const rel = pathInside(root, srcPath);
19602
- if (rel !== null && (existsSync26(join41(input.planDir, "compiled", rel)) || input.isRemote(srcPath))) {
19603
- result = ["compiled", ...rel.split(sep4)].join("/");
19732
+ if (rel !== null && (existsSync27(join42(input.planDir, "compiled", rel)) || input.isRemote(srcPath))) {
19733
+ result = ["compiled", ...rel.split(sep5)].join("/");
19604
19734
  break;
19605
19735
  }
19606
19736
  }
19607
19737
  if (result === null) {
19608
19738
  result = `video-sources/${shipped.size}${extname6(current)}`;
19609
- const destination = join41(input.planDir, ...result.split("/"));
19610
- mkdirSync16(join41(input.planDir, "video-sources"), { recursive: true });
19739
+ const destination = join42(input.planDir, ...result.split("/"));
19740
+ mkdirSync16(join42(input.planDir, "video-sources"), { recursive: true });
19611
19741
  try {
19612
19742
  linkSync(current, destination);
19613
19743
  } catch {
@@ -19627,7 +19757,7 @@ async function compilePlanComposition(projectDir, config, planDir, options) {
19627
19757
  useGpu: false,
19628
19758
  browserGpuMode: "software"
19629
19759
  });
19630
- if (!existsSync26(planDir)) mkdirSync16(planDir, { recursive: true });
19760
+ if (!existsSync27(planDir)) mkdirSync16(planDir, { recursive: true });
19631
19761
  const log = config.logger ?? defaultLogger;
19632
19762
  const sizeLimitBytes = options.executionPlanSizeLimitBytes ?? config.planDirSizeLimitBytes ?? PLAN_DIR_SIZE_LIMIT_BYTES;
19633
19763
  const abortSignal = config.abortSignal;
@@ -19661,21 +19791,21 @@ async function compilePlanComposition(projectDir, config, planDir, options) {
19661
19791
  includeOutsideScripts: options.includeOutsideScripts === true
19662
19792
  });
19663
19793
  const entryFile = config.entryFile ?? "index.html";
19664
- const htmlPath = join41(projectDir, entryFile);
19665
- if (!existsSync26(htmlPath)) {
19794
+ const htmlPath = join42(projectDir, entryFile);
19795
+ if (!existsSync27(htmlPath)) {
19666
19796
  throw new Error(`[plan] entry file not found: ${htmlPath}`);
19667
19797
  }
19668
- const workDir = join41(planDir, ".plan-work");
19798
+ const workDir = join42(planDir, ".plan-work");
19669
19799
  rmSync14(workDir, { recursive: true, force: true });
19670
19800
  mkdirSync16(workDir, { recursive: true });
19671
- const compiledDir = join41(workDir, "compiled");
19801
+ const compiledDir = join42(workDir, "compiled");
19672
19802
  mkdirSync16(compiledDir, { recursive: true });
19673
19803
  let stageStarted = Date.now();
19674
19804
  cpSync2(projectDir, compiledDir, {
19675
19805
  recursive: true,
19676
19806
  dereference: true,
19677
19807
  filter: (src) => {
19678
- const rel = relative6(projectDir, src);
19808
+ const rel = relative7(projectDir, src);
19679
19809
  if (rel === "") return true;
19680
19810
  if (leavesRoot(rel)) return false;
19681
19811
  if (job.config.allowOutsideProjectAssets) {
@@ -19683,15 +19813,15 @@ async function compilePlanComposition(projectDir, config, planDir, options) {
19683
19813
  const policy = { includeScripts: job.config.includeOutsideScripts };
19684
19814
  if (refusesOutsideLink(projectDir, src, warn, policy)) return false;
19685
19815
  } else if (!isSafePath2(projectDir, src)) return false;
19686
- const firstSegment = rel.split(sep4, 1)[0];
19816
+ const firstSegment = rel.split(sep5, 1)[0];
19687
19817
  return firstSegment === void 0 || !PLAN_PROJECT_DIR_SKIP_SEGMENTS.has(firstSegment);
19688
19818
  }
19689
19819
  });
19690
19820
  logPlanStage(log, "copy", stageStarted);
19691
- const finalCompiledDir = join41(planDir, "compiled");
19821
+ const finalCompiledDir = join42(planDir, "compiled");
19692
19822
  const needsAlpha = outputNeedsAlpha(config.format);
19693
19823
  const remoteFiles = Object.entries(options.remoteFiles ?? {});
19694
- const remoteLocalPath = (rel) => join41(projectDir, ...rel.split("/"));
19824
+ const remoteLocalPath = (rel) => join42(projectDir, ...rel.split("/"));
19695
19825
  for (const [, file] of remoteFiles) {
19696
19826
  declareContentAddressedUrl(file.url, file.sha256);
19697
19827
  if (file.probeFactsUrl) declareProbeFactsUrl(file.url, file.probeFactsUrl);
@@ -19896,17 +20026,17 @@ async function buildLocalExecutionPlan(projectDir, config, executionPlanDir, opt
19896
20026
  let stageStarted = Date.now();
19897
20027
  const extractResult = await extractPlanVideos(c, options.deferVideoExtraction);
19898
20028
  logPlanStage(log, "extract", stageStarted);
19899
- const stagedVideoFrames = join41(compiledDir, "__hyperframes_video_frames");
19900
- const videoFramesDst = join41(planDir, "video-frames");
19901
- if (existsSync26(videoFramesDst)) rmSync14(videoFramesDst, { recursive: true, force: true });
19902
- const videoSourcesDir = join41(planDir, "video-sources");
20029
+ const stagedVideoFrames = join42(compiledDir, "__hyperframes_video_frames");
20030
+ const videoFramesDst = join42(planDir, "video-frames");
20031
+ if (existsSync27(videoFramesDst)) rmSync14(videoFramesDst, { recursive: true, force: true });
20032
+ const videoSourcesDir = join42(planDir, "video-sources");
19903
20033
  rmSync14(videoSourcesDir, { recursive: true, force: true });
19904
- if (existsSync26(stagedVideoFrames)) {
20034
+ if (existsSync27(stagedVideoFrames)) {
19905
20035
  renameWithRetry8(stagedVideoFrames, videoFramesDst);
19906
20036
  } else {
19907
20037
  mkdirSync16(videoFramesDst, { recursive: true });
19908
20038
  }
19909
- if (existsSync26(finalCompiledDir)) rmSync14(finalCompiledDir, { recursive: true, force: true });
20039
+ if (existsSync27(finalCompiledDir)) rmSync14(finalCompiledDir, { recursive: true, force: true });
19910
20040
  renameWithRetry8(compiledDir, finalCompiledDir);
19911
20041
  const shipVideoSource = createVideoSourceShipper({
19912
20042
  planDir,
@@ -19936,7 +20066,7 @@ async function buildLocalExecutionPlan(projectDir, config, executionPlanDir, opt
19936
20066
  };
19937
20067
  })
19938
20068
  });
19939
- mkdirSync16(join41(planDir, "meta"), { recursive: true });
20069
+ mkdirSync16(join42(planDir, "meta"), { recursive: true });
19940
20070
  writePlanRemoteFiles(
19941
20071
  planDir,
19942
20072
  remoteFiles.map(([rel, { sha256, sizeBytes }]) => ({
@@ -19946,7 +20076,7 @@ async function buildLocalExecutionPlan(projectDir, config, executionPlanDir, opt
19946
20076
  }))
19947
20077
  );
19948
20078
  writeFileSync10(
19949
- join41(planDir, PLAN_VIDEOS_META_RELATIVE_PATH),
20079
+ join42(planDir, PLAN_VIDEOS_META_RELATIVE_PATH),
19950
20080
  JSON.stringify(planVideosJson, null, 2),
19951
20081
  "utf-8"
19952
20082
  );
@@ -20026,11 +20156,11 @@ async function buildLocalExecutionPlan(projectDir, config, executionPlanDir, opt
20026
20156
  if (audioResult?.audioError) {
20027
20157
  applyDistributedAudioWarningPolicy(job, audioResult.audioError, audioResult.audioFailures, log);
20028
20158
  }
20029
- const planAudioPath = join41(planDir, PLAN_AUDIO_RELATIVE_PATH);
20030
- if (audioResult?.hasAudio && existsSync26(audioResult.audioOutputPath)) {
20159
+ const planAudioPath = join42(planDir, PLAN_AUDIO_RELATIVE_PATH);
20160
+ if (audioResult?.hasAudio && existsSync27(audioResult.audioOutputPath)) {
20031
20161
  renameWithRetry8(audioResult.audioOutputPath, planAudioPath);
20032
20162
  }
20033
- if (chunksCarryAudio && existsSync26(planAudioPath)) {
20163
+ if (chunksCarryAudio && existsSync27(planAudioPath)) {
20034
20164
  if (options.sliceChunkAudio) {
20035
20165
  stageStarted = Date.now();
20036
20166
  await writeChunkAudioSlices({
@@ -20152,8 +20282,8 @@ async function plan(projectDir, config, planDir, options = {}) {
20152
20282
 
20153
20283
  // src/services/distributed/renderChunk.ts
20154
20284
  import { randomBytes } from "node:crypto";
20155
- import { existsSync as existsSync29, mkdirSync as mkdirSync19, readFileSync as readFileSync14, readdirSync as readdirSync11, rmSync as rmSync17, writeFileSync as writeFileSync13 } from "node:fs";
20156
- import { join as join45 } from "node:path";
20285
+ import { existsSync as existsSync30, mkdirSync as mkdirSync19, readFileSync as readFileSync14, readdirSync as readdirSync11, rmSync as rmSync17, writeFileSync as writeFileSync13 } from "node:fs";
20286
+ import { join as join46 } from "node:path";
20157
20287
  import {
20158
20288
  assertSwiftShader,
20159
20289
  BROWSER_GPU_NOT_SOFTWARE as BROWSER_GPU_NOT_SOFTWARE4,
@@ -20179,8 +20309,8 @@ import {
20179
20309
  } from "@hyperframes/engine";
20180
20310
  import {
20181
20311
  copyFileSync as copyFileSync8,
20182
- existsSync as existsSync28,
20183
- lstatSync as lstatSync3,
20312
+ existsSync as existsSync29,
20313
+ lstatSync as lstatSync4,
20184
20314
  mkdirSync as mkdirSync18,
20185
20315
  readFileSync as readFileSync13,
20186
20316
  readdirSync as readdirSync10,
@@ -20188,8 +20318,8 @@ import {
20188
20318
  statSync as statSync13,
20189
20319
  writeFileSync as writeFileSync12
20190
20320
  } from "node:fs";
20191
- import { tmpdir as tmpdir3 } from "node:os";
20192
- import { dirname as dirname18, isAbsolute as isAbsolute4, join as join44, relative as relative7, resolve as resolve10, sep as sep5 } from "node:path";
20321
+ import { tmpdir as tmpdir4 } from "node:os";
20322
+ import { dirname as dirname18, isAbsolute as isAbsolute5, join as join45, relative as relative8, resolve as resolve11, sep as sep6 } from "node:path";
20193
20323
  import { DISTRIBUTED_FPS, isDistributedFps } from "@hyperframes/core";
20194
20324
  import {
20195
20325
  createFrameLookupTable as createFrameLookupTable5,
@@ -20200,7 +20330,7 @@ import {
20200
20330
  // src/services/distributed/planV2Publisher.ts
20201
20331
  import {
20202
20332
  copyFileSync as copyFileSync7,
20203
- existsSync as existsSync27,
20333
+ existsSync as existsSync28,
20204
20334
  linkSync as linkSync2,
20205
20335
  mkdirSync as mkdirSync17,
20206
20336
  rmSync as rmSync15,
@@ -20208,7 +20338,7 @@ import {
20208
20338
  writeFileSync as writeFileSync11
20209
20339
  } from "node:fs";
20210
20340
  import { renameWithRetry as renameWithRetry9 } from "@hyperframes/engine";
20211
- import { dirname as dirname17, join as join43 } from "node:path";
20341
+ import { dirname as dirname17, join as join44 } from "node:path";
20212
20342
 
20213
20343
  // src/services/distributed/planV2Errors.ts
20214
20344
  var PLAN_V2_INTEGRITY_UNRECOVERABLE = "PLAN_V2_INTEGRITY_UNRECOVERABLE";
@@ -20223,7 +20353,7 @@ var PlanV2IntegrityError = class extends Error {
20223
20353
  };
20224
20354
 
20225
20355
  // src/services/distributed/planV2Layout.ts
20226
- import { join as join42 } from "node:path";
20356
+ import { join as join43 } from "node:path";
20227
20357
  var SHA256_PATTERN = /^[0-9a-f]{64}$/;
20228
20358
  function assertPlanV2Sha256(value, field) {
20229
20359
  if (typeof value !== "string" || !SHA256_PATTERN.test(value)) {
@@ -20233,7 +20363,7 @@ function assertPlanV2Sha256(value, field) {
20233
20363
  }
20234
20364
  function planV2BlobPath(root, sha256) {
20235
20365
  const digest = assertPlanV2Sha256(sha256, "artifact sha256");
20236
- return join42(root, "artifacts", "sha256", digest.slice(0, 2), digest);
20366
+ return join43(root, "artifacts", "sha256", digest.slice(0, 2), digest);
20237
20367
  }
20238
20368
 
20239
20369
  // src/services/distributed/planV2Publisher.ts
@@ -20264,7 +20394,7 @@ var LocalPlanV2ArtifactPublisher = class {
20264
20394
  #linkFile;
20265
20395
  #committed = false;
20266
20396
  constructor(destinationDir, options = {}) {
20267
- if (existsSync27(destinationDir)) {
20397
+ if (existsSync28(destinationDir)) {
20268
20398
  throw new PlanV2IntegrityError(`output directory already exists: ${destinationDir}`);
20269
20399
  }
20270
20400
  this.destinationDir = destinationDir;
@@ -20281,10 +20411,10 @@ var LocalPlanV2ArtifactPublisher = class {
20281
20411
  );
20282
20412
  }
20283
20413
  const destinationPath = planV2BlobPath(this.temporaryDir, digest);
20284
- if (existsSync27(destinationPath)) return;
20414
+ if (existsSync28(destinationPath)) return;
20285
20415
  mkdirSync17(dirname17(destinationPath), { recursive: true });
20286
20416
  const stagingDir = createStagingDir5(dirname17(destinationPath), ".plan-v2-blob-");
20287
- const temporaryPath = join43(stagingDir, "blob");
20417
+ const temporaryPath = join44(stagingDir, "blob");
20288
20418
  try {
20289
20419
  try {
20290
20420
  this.#linkFile(blob.sourcePath, temporaryPath);
@@ -20299,13 +20429,13 @@ var LocalPlanV2ArtifactPublisher = class {
20299
20429
  }
20300
20430
  async commitManifest(manifestBytes) {
20301
20431
  for (const digest of new Set(manifestDigests(manifestBytes))) {
20302
- if (!existsSync27(planV2BlobPath(this.temporaryDir, digest))) {
20432
+ if (!existsSync28(planV2BlobPath(this.temporaryDir, digest))) {
20303
20433
  throw new PlanV2IntegrityError(
20304
20434
  `cannot commit manifest before referenced blob is durable: ${digest}`
20305
20435
  );
20306
20436
  }
20307
20437
  }
20308
- writeFileSync11(join43(this.temporaryDir, "plan.json"), manifestBytes, "utf-8");
20438
+ writeFileSync11(join44(this.temporaryDir, "plan.json"), manifestBytes, "utf-8");
20309
20439
  renameWithRetry9(this.temporaryDir, this.destinationDir);
20310
20440
  this.#committed = true;
20311
20441
  }
@@ -20342,21 +20472,21 @@ function readJsonFile(path, label) {
20342
20472
  }
20343
20473
  function assertSafeRelativePath(path) {
20344
20474
  const normalized = path.split(/[\\/]+/);
20345
- if (path.length === 0 || isAbsolute4(path) || normalized.some((part) => part === "" || part === "." || part === "..")) {
20475
+ if (path.length === 0 || isAbsolute5(path) || normalized.some((part) => part === "" || part === "." || part === "..")) {
20346
20476
  throw new PlanV2IntegrityError(`unsafe artifact path: ${JSON.stringify(path)}`);
20347
20477
  }
20348
20478
  }
20349
20479
  function listFiles(root) {
20350
20480
  const files = [];
20351
- const rootResolved = resolve10(root);
20481
+ const rootResolved = resolve11(root);
20352
20482
  function walk(dir) {
20353
20483
  for (const entry of readdirSync10(dir, { withFileTypes: true })) {
20354
- const absolutePath = join44(dir, entry.name);
20484
+ const absolutePath = join45(dir, entry.name);
20355
20485
  if (entry.isDirectory()) {
20356
20486
  walk(absolutePath);
20357
20487
  } else if (entry.isFile()) {
20358
20488
  files.push({
20359
- path: relative7(rootResolved, absolutePath).split(sep5).join("/"),
20489
+ path: relative8(rootResolved, absolutePath).split(sep6).join("/"),
20360
20490
  absolutePath
20361
20491
  });
20362
20492
  } else {
@@ -20370,7 +20500,7 @@ function listFiles(root) {
20370
20500
  return files.sort((a, b) => a.path.localeCompare(b.path));
20371
20501
  }
20372
20502
  function assertValidExtractionCacheCompleteSentinel(path) {
20373
- const sentinel = lstatSync3(path);
20503
+ const sentinel = lstatSync4(path);
20374
20504
  if (!sentinel.isFile() || sentinel.size !== 0) {
20375
20505
  throw new PlanV2IntegrityError(
20376
20506
  `${EXTRACTION_CACHE_COMPLETE_SENTINEL} must be a zero-byte regular file`
@@ -20378,13 +20508,13 @@ function assertValidExtractionCacheCompleteSentinel(path) {
20378
20508
  }
20379
20509
  }
20380
20510
  function validateExtractionCacheCompleteSentinels(executionPlanDir) {
20381
- const videoRoot = join44(executionPlanDir, "video-frames");
20382
- if (!existsSync28(videoRoot)) return;
20511
+ const videoRoot = join45(executionPlanDir, "video-frames");
20512
+ if (!existsSync29(videoRoot)) return;
20383
20513
  for (const videoEntry of readdirSync10(videoRoot, { withFileTypes: true })) {
20384
20514
  if (!videoEntry.isDirectory()) continue;
20385
- const videoDir = join44(videoRoot, videoEntry.name);
20515
+ const videoDir = join45(videoRoot, videoEntry.name);
20386
20516
  if (readdirSync10(videoDir).includes(EXTRACTION_CACHE_COMPLETE_SENTINEL)) {
20387
- const sentinelPath = join44(videoDir, EXTRACTION_CACHE_COMPLETE_SENTINEL);
20517
+ const sentinelPath = join45(videoDir, EXTRACTION_CACHE_COMPLETE_SENTINEL);
20388
20518
  assertValidExtractionCacheCompleteSentinel(sentinelPath);
20389
20519
  }
20390
20520
  }
@@ -20394,9 +20524,9 @@ function isExtractionCacheCompleteSentinelPath(path) {
20394
20524
  return segments.length === 3 && segments[0] === "video-frames" && segments[1] !== "" && segments[2] === EXTRACTION_CACHE_COMPLETE_SENTINEL;
20395
20525
  }
20396
20526
  function resolveExtractedVideoOutputDir(planDir, videoId) {
20397
- const videoRoot = resolve10(planDir, "video-frames");
20398
- const outputDir = resolve10(videoRoot, mediaIdPathSegment4(videoId));
20399
- if (outputDir === videoRoot || !outputDir.startsWith(`${videoRoot}${sep5}`)) {
20527
+ const videoRoot = resolve11(planDir, "video-frames");
20528
+ const outputDir = resolve11(videoRoot, mediaIdPathSegment4(videoId));
20529
+ if (outputDir === videoRoot || !outputDir.startsWith(`${videoRoot}${sep6}`)) {
20400
20530
  throw new PlanV2IntegrityError(`unsafe extracted video id: ${JSON.stringify(videoId)}`);
20401
20531
  }
20402
20532
  return outputDir;
@@ -20431,7 +20561,7 @@ function listVideoFramePaths(executionPlanDir, videos) {
20431
20561
  if (video.deferredRange) {
20432
20562
  const framePaths2 = /* @__PURE__ */ new Map();
20433
20563
  for (let index = 0; index < video.totalFrames; index++) {
20434
- framePaths2.set(index, join44(outputDir, String(index)));
20564
+ framePaths2.set(index, join45(outputDir, String(index)));
20435
20565
  }
20436
20566
  return { ...video, outputDir, framePaths: framePaths2, ownedByLookup: false };
20437
20567
  }
@@ -20439,7 +20569,7 @@ function listVideoFramePaths(executionPlanDir, videos) {
20439
20569
  const framePaths = /* @__PURE__ */ new Map();
20440
20570
  for (const frameName of frameNames) {
20441
20571
  if (frameName === EXTRACTION_CACHE_COMPLETE_SENTINEL) {
20442
- assertValidExtractionCacheCompleteSentinel(join44(outputDir, frameName));
20572
+ assertValidExtractionCacheCompleteSentinel(join45(outputDir, frameName));
20443
20573
  continue;
20444
20574
  }
20445
20575
  const match = /(\d+)(?=\.[^.]+$)/.exec(frameName);
@@ -20458,7 +20588,7 @@ function listVideoFramePaths(executionPlanDir, videos) {
20458
20588
  `duplicate extracted frame index ${frameIndex} in ${outputDir}`
20459
20589
  );
20460
20590
  }
20461
- framePaths.set(frameIndex, join44(outputDir, frameName));
20591
+ framePaths.set(frameIndex, join45(outputDir, frameName));
20462
20592
  }
20463
20593
  return {
20464
20594
  ...video,
@@ -20479,8 +20609,8 @@ function parsePlanVideosJson2(value) {
20479
20609
  }
20480
20610
  }
20481
20611
  function materializeExtractedVideoDirectories(planDir) {
20482
- const videosPath = join44(planDir, PLAN_VIDEOS_META_RELATIVE_PATH);
20483
- if (!existsSync28(videosPath)) return;
20612
+ const videosPath = join45(planDir, PLAN_VIDEOS_META_RELATIVE_PATH);
20613
+ if (!existsSync29(videosPath)) return;
20484
20614
  const videos = parsePlanVideosJson2(readJsonFile(videosPath, PLAN_VIDEOS_META_RELATIVE_PATH));
20485
20615
  for (const video of videos.extracted) {
20486
20616
  mkdirSync18(resolveExtractedVideoOutputDir(planDir, video.videoId), { recursive: true });
@@ -20513,13 +20643,13 @@ function parseChunkSlices(value) {
20513
20643
  });
20514
20644
  }
20515
20645
  function buildVideoChunkDependencies(executionPlanDir, dimensions) {
20516
- const videoRoot = join44(executionPlanDir, "video-frames");
20517
- const hasExtractedFrames = existsSync28(videoRoot) && listFiles(videoRoot).length > 0;
20518
- const videosPath = join44(executionPlanDir, PLAN_VIDEOS_META_RELATIVE_PATH);
20519
- if (!existsSync28(videosPath)) {
20646
+ const videoRoot = join45(executionPlanDir, "video-frames");
20647
+ const hasExtractedFrames = existsSync29(videoRoot) && listFiles(videoRoot).length > 0;
20648
+ const videosPath = join45(executionPlanDir, PLAN_VIDEOS_META_RELATIVE_PATH);
20649
+ if (!existsSync29(videosPath)) {
20520
20650
  return hasExtractedFrames ? { mode: "full-source-pack", dependencies: null } : { mode: "exact-rendered-frames", dependencies: /* @__PURE__ */ new Map() };
20521
20651
  }
20522
- const chunksPath = join44(executionPlanDir, "meta", "chunks.json");
20652
+ const chunksPath = join45(executionPlanDir, "meta", "chunks.json");
20523
20653
  const videos = readJsonFile(videosPath, PLAN_VIDEOS_META_RELATIVE_PATH);
20524
20654
  const chunks = readJsonFile(chunksPath, "meta/chunks.json");
20525
20655
  const parsedVideos = parsePlanVideosJson2(videos);
@@ -20556,7 +20686,7 @@ function collectChunkVideoDependencies(input) {
20556
20686
  for (let frame = chunk.startFrame; frame < chunk.endFrame; frame++) {
20557
20687
  const globalTime = frame * input.fpsDen / input.fpsNum;
20558
20688
  for (const [videoId, payload] of input.table.getActiveFramePayloads(globalTime)) {
20559
- const path = input.deferredSources.get(videoId) ?? relative7(resolve10(input.executionPlanDir), payload.framePath).split(sep5).join("/");
20689
+ const path = input.deferredSources.get(videoId) ?? relative8(resolve11(input.executionPlanDir), payload.framePath).split(sep6).join("/");
20560
20690
  assertSafeRelativePath(path);
20561
20691
  const indexes = mutable.get(path) ?? /* @__PURE__ */ new Set();
20562
20692
  indexes.add(chunk.index);
@@ -20573,10 +20703,10 @@ function computeManifestHash(manifest) {
20573
20703
  return sha256Hex(`${PLAN_V2_HASH_PREFIX}${canonicalJsonStringify(manifestPayload(manifest))}`);
20574
20704
  }
20575
20705
  function writeBlob(sourcePath, destinationPath) {
20576
- if (existsSync28(destinationPath)) return;
20706
+ if (existsSync29(destinationPath)) return;
20577
20707
  mkdirSync18(dirname18(destinationPath), { recursive: true });
20578
20708
  const temporaryDir = createStagingDir6(dirname18(destinationPath), ".plan-v2-blob-");
20579
- const temporaryPath = join44(temporaryDir, "blob");
20709
+ const temporaryPath = join45(temporaryDir, "blob");
20580
20710
  try {
20581
20711
  copyFileSync8(sourcePath, temporaryPath);
20582
20712
  renameWithRetry10(temporaryPath, destinationPath);
@@ -20612,8 +20742,8 @@ async function putTasks(tasks) {
20612
20742
  if (failure) throw failure.reason;
20613
20743
  }
20614
20744
  function buildPlanV2Publication(executionPlanDir, digests) {
20615
- const executionPlanPath = join44(executionPlanDir, "plan.json");
20616
- if (!existsSync28(executionPlanPath)) {
20745
+ const executionPlanPath = join45(executionPlanDir, "plan.json");
20746
+ if (!existsSync29(executionPlanPath)) {
20617
20747
  throw new PlanV2IntegrityError(`execution plan is missing plan.json: ${executionPlanPath}`);
20618
20748
  }
20619
20749
  const executionPlanValue = readJsonFile(executionPlanPath, "execution plan.json");
@@ -20640,7 +20770,7 @@ function buildPlanV2Publication(executionPlanDir, digests) {
20640
20770
  }
20641
20771
  validateExtractionCacheCompleteSentinels(executionPlanDir);
20642
20772
  const videoDependencyPlan = buildVideoChunkDependencies(executionPlanDir, dimensions);
20643
- const encoder = readJsonFile(join44(executionPlanDir, "meta", "encoder.json"), "meta/encoder.json");
20773
+ const encoder = readJsonFile(join45(executionPlanDir, "meta", "encoder.json"), "meta/encoder.json");
20644
20774
  const files = listFiles(executionPlanDir);
20645
20775
  const chunkAudio = !isRecord3(encoder) || encoder.chunksCarryAudio !== true ? "none" : files.some((file) => chunkAudioSliceTarget(file.path) !== null) ? "sliced" : "whole";
20646
20776
  for (const file of files) {
@@ -20693,7 +20823,7 @@ function buildPlanV2Publication(executionPlanDir, digests) {
20693
20823
  };
20694
20824
  }
20695
20825
  function createPlanV2FromExecutionPlan(executionPlanDir, planV2Dir) {
20696
- if (existsSync28(planV2Dir)) {
20826
+ if (existsSync29(planV2Dir)) {
20697
20827
  throw new PlanV2IntegrityError(`output directory already exists: ${planV2Dir}`);
20698
20828
  }
20699
20829
  const publication = buildPlanV2Publication(executionPlanDir);
@@ -20707,7 +20837,7 @@ function createPlanV2FromExecutionPlan(executionPlanDir, planV2Dir) {
20707
20837
  writeBlob(blob.sourcePath, planV2BlobPath(tempDir, blob.sha256));
20708
20838
  }
20709
20839
  writeFileSync12(
20710
- join44(tempDir, "plan.json"),
20840
+ join45(tempDir, "plan.json"),
20711
20841
  canonicalJsonStringify(publication.manifest),
20712
20842
  "utf-8"
20713
20843
  );
@@ -20748,7 +20878,7 @@ async function publishExecutionPlan(executionPlanDir, publisher, { digests, log
20748
20878
  }
20749
20879
  }
20750
20880
  async function planV2WithPublisher(projectDir, config, publisher, options = {}) {
20751
- const stagingRoot = createStagingDir6(options.stagingParentDir ?? tmpdir3(), ".execution-plan-");
20881
+ const stagingRoot = createStagingDir6(options.stagingParentDir ?? tmpdir4(), ".execution-plan-");
20752
20882
  const digests = /* @__PURE__ */ new Map();
20753
20883
  try {
20754
20884
  const planned = await buildLocalExecutionPlan(projectDir, config, stagingRoot, {
@@ -20759,7 +20889,7 @@ async function planV2WithPublisher(projectDir, config, publisher, options = {})
20759
20889
  // artifactTargets ships every compiled/ file to all chunks, so each is in the manifest.
20760
20890
  whileAudioMixes: () => putBlobs(
20761
20891
  publisher,
20762
- listFiles(join44(stagingRoot, "compiled")).map(
20892
+ listFiles(join45(stagingRoot, "compiled")).map(
20763
20893
  (file) => publishBlobFor(file.absolutePath, digests)
20764
20894
  )
20765
20895
  ),
@@ -20783,7 +20913,7 @@ async function planV2WithPublisher(projectDir, config, publisher, options = {})
20783
20913
  }
20784
20914
  }
20785
20915
  async function planV2(projectDir, config, planV2Dir) {
20786
- if (existsSync28(planV2Dir)) {
20916
+ if (existsSync29(planV2Dir)) {
20787
20917
  throw new PlanV2IntegrityError(`output directory already exists: ${planV2Dir}`);
20788
20918
  }
20789
20919
  const publisher = new LocalPlanV2ArtifactPublisher(planV2Dir);
@@ -20800,7 +20930,7 @@ function resultFromManifest(planV2Dir, manifest) {
20800
20930
  isRecord3(executionPlan) ? executionPlan[REFERENCE_BACKGROUND_FIELD3] : void 0
20801
20931
  ),
20802
20932
  planDir: planV2Dir,
20803
- manifestPath: join44(planV2Dir, "plan.json"),
20933
+ manifestPath: join45(planV2Dir, "plan.json"),
20804
20934
  planProtocol: PLAN_PROTOCOL_V2,
20805
20935
  planHash: manifest.planHash,
20806
20936
  sourcePlanV1Hash: getPlanV2ExecutionPlanHash(manifest),
@@ -20936,8 +21066,8 @@ function parsePlanV2Manifest(value) {
20936
21066
  return parsed;
20937
21067
  }
20938
21068
  function readPlanV2Manifest(planV2Dir) {
20939
- const manifestPath = join44(planV2Dir, "plan.json");
20940
- if (!existsSync28(manifestPath)) {
21069
+ const manifestPath = join45(planV2Dir, "plan.json");
21070
+ if (!existsSync29(manifestPath)) {
20941
21071
  throw new PlanV2IntegrityError(`missing v2 manifest: ${manifestPath}`);
20942
21072
  }
20943
21073
  const value = readJsonFile(manifestPath, "v2 manifest");
@@ -20956,7 +21086,7 @@ function listPlanV2ArtifactsForTarget(manifest, target) {
20956
21086
  }
20957
21087
  function verifyBlob(planV2Dir, artifact) {
20958
21088
  const sourcePath = planV2BlobPath(planV2Dir, artifact.sha256);
20959
- if (!existsSync28(sourcePath)) {
21089
+ if (!existsSync29(sourcePath)) {
20960
21090
  throw new PlanV2IntegrityError(`missing content-addressed artifact ${artifact.sha256}`);
20961
21091
  }
20962
21092
  const stats = statSync13(sourcePath);
@@ -20969,7 +21099,7 @@ function verifyBlob(planV2Dir, artifact) {
20969
21099
  return sourcePath;
20970
21100
  }
20971
21101
  function materializePlanV2Target(planV2Dir, target, destinationDir, options = {}) {
20972
- if (existsSync28(destinationDir)) {
21102
+ if (existsSync29(destinationDir)) {
20973
21103
  throw new PlanV2IntegrityError(`materialization destination already exists: ${destinationDir}`);
20974
21104
  }
20975
21105
  const manifest = readPlanV2Manifest(planV2Dir);
@@ -20985,13 +21115,13 @@ function materializePlanV2Target(planV2Dir, target, destinationDir, options = {}
20985
21115
  const tempDir = createStagingDir6(dirname18(destinationDir), ".plan-v2-materialize-");
20986
21116
  try {
20987
21117
  for (const { artifact, sourcePath } of verified) {
20988
- const destinationPath = join44(tempDir, ...artifact.path.split("/"));
21118
+ const destinationPath = join45(tempDir, ...artifact.path.split("/"));
20989
21119
  mkdirSync18(dirname18(destinationPath), { recursive: true });
20990
21120
  copyFileSync8(sourcePath, destinationPath);
20991
21121
  }
20992
21122
  if (target.role === "chunk") materializeExtractedVideoDirectories(tempDir);
20993
21123
  writeFileSync12(
20994
- join44(tempDir, PLAN_V2_MATERIALIZATION_MARKER),
21124
+ join45(tempDir, PLAN_V2_MATERIALIZATION_MARKER),
20995
21125
  canonicalJsonStringify({
20996
21126
  manifest,
20997
21127
  target,
@@ -21014,7 +21144,7 @@ function materializePlanV2Target(planV2Dir, target, destinationDir, options = {}
21014
21144
  // Join the artifact's OWN name, not the current constant: a plan written
21015
21145
  // before the container change carries the legacy name, and materializing it
21016
21146
  // under the new one would point at a file that was never written.
21017
- audioPath: target.role === "assembler" ? audioArtifact ? join44(destinationDir, audioArtifact.path) : null : null
21147
+ audioPath: target.role === "assembler" ? audioArtifact ? join45(destinationDir, audioArtifact.path) : null : null
21018
21148
  };
21019
21149
  }
21020
21150
  function assertRemoteSources(remoteSources, artifacts) {
@@ -21033,8 +21163,8 @@ function validatePlanV2MaterializedTarget(planDir, expectedTarget) {
21033
21163
  return readValidatedPlanV2Materialization(planDir, expectedTarget)?.manifest ?? null;
21034
21164
  }
21035
21165
  function readValidatedPlanV2Materialization(planDir, expectedTarget) {
21036
- const markerPath = join44(planDir, PLAN_V2_MATERIALIZATION_MARKER);
21037
- if (!existsSync28(markerPath)) return null;
21166
+ const markerPath = join45(planDir, PLAN_V2_MATERIALIZATION_MARKER);
21167
+ if (!existsSync29(markerPath)) return null;
21038
21168
  const marker = readJsonFile(markerPath, "materialization marker");
21039
21169
  if (!isRecord3(marker) || !isRecord3(marker.manifest) || !isRecord3(marker.target)) {
21040
21170
  throw new PlanV2IntegrityError("malformed materialization marker");
@@ -21051,8 +21181,8 @@ function readValidatedPlanV2Materialization(planDir, expectedTarget) {
21051
21181
  assertRemoteSources(remoteSources, required);
21052
21182
  for (const artifact of required) {
21053
21183
  if (Object.hasOwn(remoteSources, artifact.path)) continue;
21054
- const path = join44(planDir, ...artifact.path.split("/"));
21055
- if (!existsSync28(path) || statSync13(path).size !== artifact.sizeBytes) {
21184
+ const path = join45(planDir, ...artifact.path.split("/"));
21185
+ if (!existsSync29(path) || statSync13(path).size !== artifact.sizeBytes) {
21056
21186
  throw new PlanV2IntegrityError(
21057
21187
  `materialized artifact missing or truncated: ${artifact.path}`
21058
21188
  );
@@ -21183,7 +21313,7 @@ function hashChunkOutput(outputPath, kind) {
21183
21313
  if (kind === "file") return sha256Hex(readFileSync14(outputPath));
21184
21314
  const entries = readdirSync11(outputPath).filter((name) => /\.(png|jpg|jpeg)$/i.test(name)).sort();
21185
21315
  const lines = entries.map(
21186
- (name) => `${name}\0${sha256Hex(readFileSync14(join45(outputPath, name)))}`
21316
+ (name) => `${name}\0${sha256Hex(readFileSync14(join46(outputPath, name)))}`
21187
21317
  );
21188
21318
  return sha256Hex(lines.join("\0"));
21189
21319
  }
@@ -21200,10 +21330,10 @@ function resolveLockedVp9CpuUsed(lockedEncoder) {
21200
21330
  async function renderChunk(planDir, chunkIndex, outputChunkPath, options) {
21201
21331
  const start = Date.now();
21202
21332
  const log = defaultLogger;
21203
- const planJsonPath = join45(planDir, "plan.json");
21204
- const encoderJsonPath = join45(planDir, "meta", "encoder.json");
21205
- const chunksJsonPath = join45(planDir, "meta", "chunks.json");
21206
- if (!existsSync29(planJsonPath)) {
21333
+ const planJsonPath = join46(planDir, "plan.json");
21334
+ const encoderJsonPath = join46(planDir, "meta", "encoder.json");
21335
+ const chunksJsonPath = join46(planDir, "meta", "chunks.json");
21336
+ if (!existsSync30(planJsonPath)) {
21207
21337
  throw new RenderChunkValidationError(
21208
21338
  MISSING_PLAN_ARTIFACT,
21209
21339
  `[renderChunk] planDir is missing required artifact: ${planJsonPath}`
@@ -21219,7 +21349,7 @@ async function renderChunk(planDir, chunkIndex, outputChunkPath, options) {
21219
21349
  const v2Manifest = v2Materialization?.manifest ?? null;
21220
21350
  const remoteSources = v2Materialization?.remoteSources ?? {};
21221
21351
  for (const required of [encoderJsonPath, chunksJsonPath]) {
21222
- if (!existsSync29(required)) {
21352
+ if (!existsSync30(required)) {
21223
21353
  throw new RenderChunkValidationError(
21224
21354
  MISSING_PLAN_ARTIFACT,
21225
21355
  `[renderChunk] planDir is missing required artifact: ${required}`
@@ -21228,9 +21358,9 @@ async function renderChunk(planDir, chunkIndex, outputChunkPath, options) {
21228
21358
  }
21229
21359
  const encoder = JSON.parse(readFileSync14(encoderJsonPath, "utf-8"));
21230
21360
  const chunks = JSON.parse(readFileSync14(chunksJsonPath, "utf-8"));
21231
- const videosJsonPath = join45(planDir, PLAN_VIDEOS_META_RELATIVE_PATH);
21361
+ const videosJsonPath = join46(planDir, PLAN_VIDEOS_META_RELATIVE_PATH);
21232
21362
  let planVideos = null;
21233
- if (existsSync29(videosJsonPath)) {
21363
+ if (existsSync30(videosJsonPath)) {
21234
21364
  try {
21235
21365
  planVideos = validatePlanVideosForChunk(JSON.parse(readFileSync14(videosJsonPath, "utf-8")));
21236
21366
  } catch (err) {
@@ -21260,8 +21390,8 @@ async function renderChunk(planDir, chunkIndex, outputChunkPath, options) {
21260
21390
  }
21261
21391
  const range = resolveChunkFrameRange(slice, chunkIndex, options?.frameRange);
21262
21392
  const framesInChunk = range.endFrame - range.startFrame;
21263
- const compiledDir = join45(planDir, "compiled");
21264
- if (!existsSync29(compiledDir)) {
21393
+ const compiledDir = join46(planDir, "compiled");
21394
+ if (!existsSync30(compiledDir)) {
21265
21395
  throw new RenderChunkValidationError(
21266
21396
  MISSING_PLAN_ARTIFACT,
21267
21397
  `[renderChunk] planDir missing compiled/ directory: ${compiledDir}`
@@ -21319,7 +21449,7 @@ async function renderChunk(planDir, chunkIndex, outputChunkPath, options) {
21319
21449
  };
21320
21450
  const workDir = `${outputChunkPath}.work.${process.pid}.${randomBytes(4).toString("hex")}`;
21321
21451
  mkdirSync19(workDir, { recursive: true });
21322
- const framesDir = join45(workDir, "captured-frames");
21452
+ const framesDir = join46(workDir, "captured-frames");
21323
21453
  mkdirSync19(framesDir, { recursive: true });
21324
21454
  const videoFramesDir = `${workDir}.video-frames`;
21325
21455
  const chunkFrameNumbers = Array.from({ length: framesInChunk }, (_, i) => range.startFrame + i);
@@ -21344,7 +21474,7 @@ async function renderChunk(planDir, chunkIndex, outputChunkPath, options) {
21344
21474
  dimensions: plan2.dimensions,
21345
21475
  encoder,
21346
21476
  videoCount: planVideos?.videos.length ?? 0,
21347
- html: readFileSync14(join45(compiledDir, "index.html"), "utf-8"),
21477
+ html: readFileSync14(join46(compiledDir, "index.html"), "utf-8"),
21348
21478
  // The plan ships a deferred source only to chunks that show it; don't wait on the rest.
21349
21479
  skipReadinessVideoIds: deferredVideos.filter(
21350
21480
  (video) => !shownFrames.get(video.videoId)?.size || remoteVideoIds.has(video.videoId)
@@ -21378,8 +21508,8 @@ async function renderChunk(planDir, chunkIndex, outputChunkPath, options) {
21378
21508
  const verifyInWorker = chunkWorkerCount > 1 && !forceScreenshotForChunk;
21379
21509
  let boxesMeasured;
21380
21510
  let boxesFailed;
21381
- const boxesReady = new Promise((resolve13, reject) => {
21382
- boxesMeasured = resolve13;
21511
+ const boxesReady = new Promise((resolve14, reject) => {
21512
+ boxesMeasured = resolve14;
21383
21513
  boxesFailed = reject;
21384
21514
  });
21385
21515
  boxesReady.catch(() => {
@@ -21513,10 +21643,10 @@ async function renderChunk(planDir, chunkIndex, outputChunkPath, options) {
21513
21643
  const effectiveBitrate = encoder.crf != null ? void 0 : encoder.bitrate;
21514
21644
  const videoOnlyPath = encoder.chunksCarryAudio ? `${outputChunkPath}.video.mp4` : outputChunkPath;
21515
21645
  if (isPngSequence) {
21516
- if (!existsSync29(outputChunkPath)) mkdirSync19(outputChunkPath, { recursive: true });
21646
+ if (!existsSync30(outputChunkPath)) mkdirSync19(outputChunkPath, { recursive: true });
21517
21647
  } else {
21518
- const outDir = join45(outputChunkPath, "..");
21519
- if (!existsSync29(outDir)) mkdirSync19(outDir, { recursive: true });
21648
+ const outDir = join46(outputChunkPath, "..");
21649
+ if (!existsSync30(outDir)) mkdirSync19(outDir, { recursive: true });
21520
21650
  }
21521
21651
  const encodeInput = {
21522
21652
  job,
@@ -21792,10 +21922,10 @@ async function renderSpan(projectDir, config, span, outputPath, options = {}) {
21792
21922
  if (config.cfr === true) {
21793
21923
  throw new RenderSpanUnsupportedError("--start/--end cannot be combined with a cfr re-encode.");
21794
21924
  }
21795
- const workDir = mkdtempSync(join46(tmpdir4(), "hf-render-span-"));
21925
+ const workDir = mkdtempSync(join47(tmpdir5(), "hf-render-span-"));
21796
21926
  try {
21797
- const planDir = join46(workDir, "plan");
21798
- const partsDir = join46(workDir, "parts");
21927
+ const planDir = join47(workDir, "plan");
21928
+ const partsDir = join47(workDir, "parts");
21799
21929
  mkdirSync20(partsDir, { recursive: true });
21800
21930
  const planned = await plan(
21801
21931
  projectDir,
@@ -21814,7 +21944,7 @@ async function renderSpan(projectDir, config, span, outputPath, options = {}) {
21814
21944
  planned.totalFrames
21815
21945
  );
21816
21946
  const slices = JSON.parse(
21817
- readFileSync15(join46(planDir, "meta", "chunks.json"), "utf-8")
21947
+ readFileSync15(join47(planDir, "meta", "chunks.json"), "utf-8")
21818
21948
  );
21819
21949
  const parts = [];
21820
21950
  for (const slice of slices) {
@@ -21824,7 +21954,7 @@ async function renderSpan(projectDir, config, span, outputPath, options = {}) {
21824
21954
  };
21825
21955
  if (range.endFrame <= range.startFrame) continue;
21826
21956
  throwIfAborted(config.abortSignal);
21827
- const part = join46(partsDir, `part-${String(parts.length).padStart(4, "0")}.mp4`);
21957
+ const part = join47(partsDir, `part-${String(parts.length).padStart(4, "0")}.mp4`);
21828
21958
  await renderChunk(planDir, slice.index, part, { frameRange: range });
21829
21959
  parts.push(part);
21830
21960
  }
@@ -22480,7 +22610,7 @@ import {
22480
22610
 
22481
22611
  // src/server.ts
22482
22612
  import {
22483
- existsSync as existsSync32,
22613
+ existsSync as existsSync33,
22484
22614
  mkdirSync as mkdirSync21,
22485
22615
  statSync as statSync15,
22486
22616
  mkdtempSync as mkdtempSync2,
@@ -22488,8 +22618,8 @@ import {
22488
22618
  rmSync as rmSync19,
22489
22619
  createReadStream as createReadStream5
22490
22620
  } from "node:fs";
22491
- import { resolve as resolve12, dirname as dirname21, join as join49 } from "node:path";
22492
- import { tmpdir as tmpdir5 } from "node:os";
22621
+ import { resolve as resolve13, dirname as dirname21, join as join50 } from "node:path";
22622
+ import { tmpdir as tmpdir6 } from "node:os";
22493
22623
  import { parseArgs } from "node:util";
22494
22624
  import { isIP } from "node:net";
22495
22625
  import crypto from "node:crypto";
@@ -22505,7 +22635,7 @@ import { isSafePath as isSafePath3 } from "@hyperframes/core/safe-path";
22505
22635
 
22506
22636
  // src/services/hyperframeLint.ts
22507
22637
  import {
22508
- existsSync as existsSync30,
22638
+ existsSync as existsSync31,
22509
22639
  readFileSync as readFileSync16,
22510
22640
  statSync as statSync14,
22511
22641
  openSync as openSync7,
@@ -22513,7 +22643,7 @@ import {
22513
22643
  closeSync as closeSync7,
22514
22644
  constants as constants3
22515
22645
  } from "node:fs";
22516
- import { resolve as resolve11, join as join47, relative as relative8, isAbsolute as isAbsolute5, sep as sep6, dirname as dirname19 } from "node:path";
22646
+ import { resolve as resolve12, join as join48, relative as relative9, isAbsolute as isAbsolute6, sep as sep7, dirname as dirname19 } from "node:path";
22517
22647
  import { fileURLToPath as fileURLToPath6 } from "node:url";
22518
22648
  import { Worker as Worker2 } from "node:worker_threads";
22519
22649
  function isStringRecord(value) {
@@ -22559,19 +22689,19 @@ function readEntryHtml(filePath) {
22559
22689
  }
22560
22690
  }
22561
22691
  function leavesProject(absProjectDir, absoluteEntryPath, isAllowedEntry) {
22562
- const entryRelativePath = relative8(absProjectDir, absoluteEntryPath);
22563
- return entryRelativePath === ".." || entryRelativePath.startsWith(`..${sep6}`) || isAbsolute5(entryRelativePath) || isAllowedEntry !== void 0 && !isAllowedEntry(absoluteEntryPath);
22692
+ const entryRelativePath = relative9(absProjectDir, absoluteEntryPath);
22693
+ return entryRelativePath === ".." || entryRelativePath.startsWith(`..${sep7}`) || isAbsolute6(entryRelativePath) || isAllowedEntry !== void 0 && !isAllowedEntry(absoluteEntryPath);
22564
22694
  }
22565
22695
  function readProjectEntryFile(projectDir, preferredEntryFile, isAllowedEntry) {
22566
- const absProjectDir = resolve11(projectDir);
22567
- if (!existsSync30(absProjectDir) || !statSync14(absProjectDir).isDirectory()) {
22696
+ const absProjectDir = resolve12(projectDir);
22697
+ if (!existsSync31(absProjectDir) || !statSync14(absProjectDir).isDirectory()) {
22568
22698
  return { error: `Project directory not found: ${absProjectDir}` };
22569
22699
  }
22570
22700
  const entryCandidates = [preferredEntryFile, "index.html", "src/index.html"].filter(
22571
22701
  (value) => typeof value === "string" && value.trim().length > 0
22572
22702
  );
22573
22703
  for (const entryFile of entryCandidates) {
22574
- const absoluteEntryPath = resolve11(absProjectDir, entryFile);
22704
+ const absoluteEntryPath = resolve12(absProjectDir, entryFile);
22575
22705
  if (leavesProject(absProjectDir, absoluteEntryPath, isAllowedEntry)) {
22576
22706
  return { error: `Entry file must stay inside project directory: ${entryFile}` };
22577
22707
  }
@@ -22585,7 +22715,7 @@ function readProjectEntryFile(projectDir, preferredEntryFile, isAllowedEntry) {
22585
22715
  }
22586
22716
  }
22587
22717
  return {
22588
- error: `No HTML entry file found in project directory: ${join47(absProjectDir, preferredEntryFile || "index.html")}`
22718
+ error: `No HTML entry file found in project directory: ${join48(absProjectDir, preferredEntryFile || "index.html")}`
22589
22719
  };
22590
22720
  }
22591
22721
  function prepareHyperframeLintBody(body, isAllowedEntry) {
@@ -22631,16 +22761,16 @@ function takeLintSlot(limit, waitMs) {
22631
22761
  running++;
22632
22762
  return Promise.resolve(true);
22633
22763
  }
22634
- return new Promise((resolve13) => {
22764
+ return new Promise((resolve14) => {
22635
22765
  const entry = () => {
22636
22766
  clearTimeout(timer);
22637
22767
  running++;
22638
- resolve13(true);
22768
+ resolve14(true);
22639
22769
  };
22640
22770
  const timer = setTimeout(
22641
22771
  () => {
22642
22772
  waiting.splice(waiting.indexOf(entry), 1);
22643
- resolve13(false);
22773
+ resolve14(false);
22644
22774
  },
22645
22775
  Math.max(0, waitMs)
22646
22776
  );
@@ -22654,8 +22784,8 @@ function freeLintSlot() {
22654
22784
  function resolveLintWorkerEntry() {
22655
22785
  const here = dirname19(fileURLToPath6(import.meta.url));
22656
22786
  for (const name of ["hyperframeLintWorker.js", "hyperframeLintWorker.ts"]) {
22657
- const candidate = join47(here, name);
22658
- if (existsSync30(candidate)) return candidate;
22787
+ const candidate = join48(here, name);
22788
+ if (existsSync31(candidate)) return candidate;
22659
22789
  }
22660
22790
  return void 0;
22661
22791
  }
@@ -22725,8 +22855,8 @@ async function runHyperframeLint(prepared, options = {}) {
22725
22855
  // src/services/healthWorker.ts
22726
22856
  import { Worker as Worker3 } from "node:worker_threads";
22727
22857
  import { fileURLToPath as fileURLToPath7 } from "node:url";
22728
- import { dirname as dirname20, join as join48 } from "node:path";
22729
- import { existsSync as existsSync31 } from "node:fs";
22858
+ import { dirname as dirname20, join as join49 } from "node:path";
22859
+ import { existsSync as existsSync32 } from "node:fs";
22730
22860
  var DEFAULT_HEALTH_PORT = 9848;
22731
22861
  async function startHealthWorker(options = {}) {
22732
22862
  const log = options.logger ?? defaultLogger2();
@@ -22744,12 +22874,12 @@ async function startHealthWorker(options = {}) {
22744
22874
  stdout: false,
22745
22875
  stderr: false
22746
22876
  });
22747
- await new Promise((resolve13, reject) => {
22877
+ await new Promise((resolve14, reject) => {
22748
22878
  const onMessage = (msg) => {
22749
22879
  if (msg?.type === "listening") {
22750
22880
  worker.off("error", onError);
22751
22881
  worker.off("message", onMessage);
22752
- resolve13();
22882
+ resolve14();
22753
22883
  } else if (msg?.type === "listen-error") {
22754
22884
  worker.off("error", onError);
22755
22885
  worker.off("message", onMessage);
@@ -22801,9 +22931,9 @@ function defaultLogger2() {
22801
22931
  }
22802
22932
  function resolveWorkerEntry2() {
22803
22933
  const here = dirname20(fileURLToPath7(import.meta.url));
22804
- const candidates = [join48(here, "healthWorkerThread.js"), join48(here, "healthWorkerThread.ts")];
22934
+ const candidates = [join49(here, "healthWorkerThread.js"), join49(here, "healthWorkerThread.ts")];
22805
22935
  for (const candidate of candidates) {
22806
- if (existsSync31(candidate)) return candidate;
22936
+ if (existsSync32(candidate)) return candidate;
22807
22937
  }
22808
22938
  return void 0;
22809
22939
  }
@@ -22973,7 +23103,7 @@ function resolvePreparedRenderOutput(prepared, rendersDir, log, confineOutput) {
22973
23103
  }
22974
23104
  }
22975
23105
  const outputDir = dirname21(absoluteOutputPath);
22976
- if (!existsSync32(outputDir)) mkdirSync21(outputDir, { recursive: true });
23106
+ if (!existsSync33(outputDir)) mkdirSync21(outputDir, { recursive: true });
22977
23107
  return { input, cleanupProjectDir, absoluteOutputPath };
22978
23108
  }
22979
23109
  function prepareRenderJob(prepared, rendersDir, log, confineOutput) {
@@ -23034,7 +23164,7 @@ function validateOutputResolutionOverride(body) {
23034
23164
  var MAX_PREVIEW_HTML_BYTES = 20 * 1024 * 1024;
23035
23165
  function resolveRenderRequestPolicy(options) {
23036
23166
  return {
23037
- projectsDir: resolve12(
23167
+ projectsDir: resolve13(
23038
23168
  options.projectsDir ?? (process.env.PRODUCER_PROJECTS_DIR || process.cwd())
23039
23169
  ),
23040
23170
  allowDebug: options.allowDebug ?? process.env.PRODUCER_ALLOW_DEBUG === "1"
@@ -23049,14 +23179,14 @@ function isAllowedEntryPath(policy, projectDir, path) {
23049
23179
  function prepareProjectDirectory(projectDir, options, policy) {
23050
23180
  const candidate = nonEmptyString(projectDir);
23051
23181
  if (!candidate) return null;
23052
- const absProjectDir = policy ? resolve12(policy.projectsDir, candidate) : resolve12(candidate);
23182
+ const absProjectDir = policy ? resolve13(policy.projectsDir, candidate) : resolve13(candidate);
23053
23183
  const shown = policy ? candidate : absProjectDir;
23054
- if (policy && !isAllowedProjectPath(policy.projectsDir, absProjectDir) || !existsSync32(absProjectDir) || !statSync15(absProjectDir).isDirectory()) {
23184
+ if (policy && !isAllowedProjectPath(policy.projectsDir, absProjectDir) || !existsSync33(absProjectDir) || !statSync15(absProjectDir).isDirectory()) {
23055
23185
  return { error: `Project directory not found: ${shown}` };
23056
23186
  }
23057
23187
  const entry = options.entryFile || "index.html";
23058
- const entryPath = resolve12(absProjectDir, entry);
23059
- if (policy && !isAllowedEntryPath(policy, absProjectDir, entryPath) || !existsSync32(entryPath)) {
23188
+ const entryPath = resolve13(absProjectDir, entry);
23189
+ if (policy && !isAllowedEntryPath(policy, absProjectDir, entryPath) || !existsSync33(entryPath)) {
23060
23190
  return { error: `Entry file "${entry}" not found in project directory: ${shown}` };
23061
23191
  }
23062
23192
  return { prepared: { input: { projectDir: absProjectDir, ...options } } };
@@ -23076,9 +23206,9 @@ async function resolveInlineRenderHtml(body) {
23076
23206
  }
23077
23207
  }
23078
23208
  function materializeInlineProject(html, options) {
23079
- const tempRoot = process.env.PRODUCER_TMP_PROJECT_DIR || tmpdir5();
23080
- const tempProjectDir = mkdtempSync2(join49(tempRoot, "producer-project-"));
23081
- writeFileSync14(join49(tempProjectDir, "index.html"), html, "utf-8");
23209
+ const tempRoot = process.env.PRODUCER_TMP_PROJECT_DIR || tmpdir6();
23210
+ const tempProjectDir = mkdtempSync2(join50(tempRoot, "producer-project-"));
23211
+ writeFileSync14(join50(tempProjectDir, "index.html"), html, "utf-8");
23082
23212
  return {
23083
23213
  prepared: {
23084
23214
  input: { projectDir: tempProjectDir, ...options },
@@ -23106,7 +23236,7 @@ function resolveOutputPath(projectDir, outputCandidate, rendersDir, log) {
23106
23236
  try {
23107
23237
  return resolveRenderPaths(projectDir, outputCandidate, rendersDir).absoluteOutputPath;
23108
23238
  } catch (error) {
23109
- const fallbackPath = resolve12(rendersDir, `producer-fallback-${Date.now()}.mp4`);
23239
+ const fallbackPath = resolve13(rendersDir, `producer-fallback-${Date.now()}.mp4`);
23110
23240
  log.warn("Failed to resolve output path, using fallback", {
23111
23241
  fallback: fallbackPath,
23112
23242
  error: error instanceof Error ? error.message : String(error)
@@ -23154,7 +23284,7 @@ function publicPerfSummary(job) {
23154
23284
  return job.perfSummary ? { ...job.perfSummary, renderId: void 0 } : null;
23155
23285
  }
23156
23286
  function outputFileSize(path) {
23157
- return existsSync32(path) ? statSync15(path).size : 0;
23287
+ return existsSync33(path) ? statSync15(path).size : 0;
23158
23288
  }
23159
23289
  function createBlockingProgressReporter(log, requestId) {
23160
23290
  let lastLoggedPct = -10;
@@ -23274,7 +23404,7 @@ function createRenderHandlers(options = {}) {
23274
23404
  const lintProjectDir = nonEmptyString(body.projectDir);
23275
23405
  let isAllowedEntry;
23276
23406
  if (policy && lintProjectDir) {
23277
- const absProjectDir = resolve12(policy.projectsDir, lintProjectDir);
23407
+ const absProjectDir = resolve13(policy.projectsDir, lintProjectDir);
23278
23408
  if (!isAllowedProjectPath(policy.projectsDir, absProjectDir)) {
23279
23409
  const error = `Project directory not found: ${lintProjectDir}`;
23280
23410
  return c.json({ success: false, requestId, error }, 400);
@@ -23481,7 +23611,7 @@ function createRenderHandlers(options = {}) {
23481
23611
  if (!artifact) {
23482
23612
  return c.json({ success: false, error: "Output artifact not found or expired" }, 404);
23483
23613
  }
23484
- if (!existsSync32(artifact.path)) {
23614
+ if (!existsSync33(artifact.path)) {
23485
23615
  store.delete(token);
23486
23616
  return c.json({ success: false, error: "Output artifact file missing" }, 404);
23487
23617
  }
@@ -23646,7 +23776,7 @@ function startServer(options = {}) {
23646
23776
  process.on("SIGINT", () => shutdown("SIGINT"));
23647
23777
  return server;
23648
23778
  }
23649
- var entryScript = process.argv[1] ? resolve12(process.argv[1]) : "";
23779
+ var entryScript = process.argv[1] ? resolve13(process.argv[1]) : "";
23650
23780
  var isPublicServerEntry = entryScript.endsWith("/public-server.js") || entryScript.endsWith("/src/server.ts");
23651
23781
  if (isPublicServerEntry) {
23652
23782
  const { values } = parseArgs({
@@ -23671,8 +23801,8 @@ import { quantizeTimeToFrame, MEDIA_VISUAL_STYLE_PROPERTIES } from "@hyperframes
23671
23801
 
23672
23802
  // src/services/distributed/planV2Execution.ts
23673
23803
  import { mkdtempSync as mkdtempSync3, rmSync as rmSync21 } from "node:fs";
23674
- import { tmpdir as tmpdir6 } from "node:os";
23675
- import { join as join51 } from "node:path";
23804
+ import { tmpdir as tmpdir7 } from "node:os";
23805
+ import { join as join52 } from "node:path";
23676
23806
 
23677
23807
  // src/services/distributed/assemble.ts
23678
23808
  import {
@@ -23681,7 +23811,7 @@ import {
23681
23811
  } from "@hyperframes/engine";
23682
23812
  import {
23683
23813
  cpSync as cpSync3,
23684
- existsSync as existsSync33,
23814
+ existsSync as existsSync34,
23685
23815
  mkdirSync as mkdirSync22,
23686
23816
  readFileSync as readFileSync17,
23687
23817
  readdirSync as readdirSync12,
@@ -23689,7 +23819,7 @@ import {
23689
23819
  statSync as statSync16,
23690
23820
  writeFileSync as writeFileSync15
23691
23821
  } from "node:fs";
23692
- import { basename as basename8, dirname as dirname22, join as join50 } from "node:path";
23822
+ import { basename as basename9, dirname as dirname22, join as join51 } from "node:path";
23693
23823
  import {
23694
23824
  appendRateCapArgs as appendRateCapArgs2,
23695
23825
  appendRenderProvenanceArgs as appendRenderProvenanceArgs2,
@@ -23736,10 +23866,10 @@ async function assemble(planDir, chunkOutputs, audioPath, outputPath, options) {
23736
23866
  }
23737
23867
  const format = plan2.dimensions.format;
23738
23868
  const cfrEncoder = cfr ? readCfrEncoder(planDir, format) : null;
23739
- if (!existsSync33(dirname22(outputPath))) {
23869
+ if (!existsSync34(dirname22(outputPath))) {
23740
23870
  mkdirSync22(dirname22(outputPath), { recursive: true });
23741
23871
  }
23742
- const workDir = createStagingDir7(dirname22(outputPath), `${basename8(outputPath)}.assemble-work-`);
23872
+ const workDir = createStagingDir7(dirname22(outputPath), `${basename9(outputPath)}.assemble-work-`);
23743
23873
  const fps = { num: plan2.dimensions.fpsNum, den: plan2.dimensions.fpsDen };
23744
23874
  const stageMs = {};
23745
23875
  const ctx = {
@@ -23759,8 +23889,8 @@ async function assemble(planDir, chunkOutputs, audioPath, outputPath, options) {
23759
23889
  };
23760
23890
  try {
23761
23891
  const videoSources = cfrEncoder ? [await reencodeCfr(ctx, chunkPaths, cfrEncoder)] : chunkPaths;
23762
- const finalPath = join50(workDir, `output.${format}`);
23763
- const audio = audioPath !== null && existsSync33(audioPath) ? audioPath : null;
23892
+ const finalPath = join51(workDir, `output.${format}`);
23893
+ const audio = audioPath !== null && existsSync34(audioPath) ? audioPath : null;
23764
23894
  await writeJoined(ctx, videoSources, audio, finalPath);
23765
23895
  renameWithRetry11(finalPath, outputPath);
23766
23896
  log.info("[assemble] stage timings", {
@@ -23778,7 +23908,7 @@ async function assemble(planDir, chunkOutputs, audioPath, outputPath, options) {
23778
23908
  });
23779
23909
  }
23780
23910
  }
23781
- const fileSize = existsSync33(outputPath) ? statSync16(outputPath).size : 0;
23911
+ const fileSize = existsSync34(outputPath) ? statSync16(outputPath).size : 0;
23782
23912
  return {
23783
23913
  ...referenceBackgroundResult8(plan2[REFERENCE_BACKGROUND_FIELD6]),
23784
23914
  outputPath,
@@ -23788,15 +23918,15 @@ async function assemble(planDir, chunkOutputs, audioPath, outputPath, options) {
23788
23918
  };
23789
23919
  }
23790
23920
  function readAssemblePlan(planDir, chunkPaths) {
23791
- const planJsonPath = join50(planDir, "plan.json");
23792
- const chunksJsonPath = join50(planDir, "meta", "chunks.json");
23793
- if (!existsSync33(planJsonPath)) {
23921
+ const planJsonPath = join51(planDir, "plan.json");
23922
+ const chunksJsonPath = join51(planDir, "meta", "chunks.json");
23923
+ if (!existsSync34(planJsonPath)) {
23794
23924
  throw new Error(`[assemble] planDir missing plan.json: ${planJsonPath}`);
23795
23925
  }
23796
23926
  const plan2 = JSON.parse(readFileSync17(planJsonPath, "utf-8"));
23797
23927
  readPlanProtocolV1(plan2, DISTRIBUTED_RENDER_CAPABILITIES.roles.assembler);
23798
23928
  validatePlanV2MaterializedTarget(planDir, { role: "assembler" });
23799
- if (!existsSync33(chunksJsonPath)) {
23929
+ if (!existsSync34(chunksJsonPath)) {
23800
23930
  throw new Error(`[assemble] planDir missing meta/chunks.json: ${chunksJsonPath}`);
23801
23931
  }
23802
23932
  const chunks = JSON.parse(readFileSync17(chunksJsonPath, "utf-8"));
@@ -23811,7 +23941,7 @@ function readAssemblePlan(planDir, chunkPaths) {
23811
23941
  }
23812
23942
  }
23813
23943
  for (const path of chunkPaths.flat()) {
23814
- if (!existsSync33(path)) {
23944
+ if (!existsSync34(path)) {
23815
23945
  throw new Error(`[assemble] chunk path does not exist: ${path}`);
23816
23946
  }
23817
23947
  }
@@ -23840,7 +23970,7 @@ function cfrEncodeArgs(inputArgs, encoder, fpsArg) {
23840
23970
  return args;
23841
23971
  }
23842
23972
  async function reencodeCfr(ctx, chunkPaths, encoder) {
23843
- const cfrOutputPath = join50(ctx.workDir, `cfr.${ctx.format}`);
23973
+ const cfrOutputPath = join51(ctx.workDir, `cfr.${ctx.format}`);
23844
23974
  const cfrArgs = cfrEncodeArgs(videoInputArgs(ctx, chunkPaths), encoder, ctx.fpsArg);
23845
23975
  appendRenderProvenanceArgs2(cfrArgs, cfrOutputPath);
23846
23976
  cfrArgs.push("-y", cfrOutputPath);
@@ -23867,7 +23997,7 @@ async function writeJoined(ctx, videoSources, audioPath, finalPath) {
23867
23997
  );
23868
23998
  return;
23869
23999
  }
23870
- const paddedAudioPath = join50(ctx.workDir, "audio-padded.m4a");
24000
+ const paddedAudioPath = join51(ctx.workDir, "audio-padded.m4a");
23871
24001
  const padTrimResult = await ctx.timed(
23872
24002
  "audioMs",
23873
24003
  () => padOrTrimAudioToVideoFrameCount({
@@ -23907,7 +24037,7 @@ async function writeJoined(ctx, videoSources, audioPath, finalPath) {
23907
24037
  }
23908
24038
  }
23909
24039
  function concatDemuxerInput(chunkPaths, workDir, fpsArg) {
23910
- const listPath = join50(workDir, "concat-list.txt");
24040
+ const listPath = join51(workDir, "concat-list.txt");
23911
24041
  const body = chunkPaths.map((path) => `file '${path.replace(/'/g, "'\\''")}'`).join("\n");
23912
24042
  writeFileSync15(listPath, `${body}
23913
24043
  `, "utf-8");
@@ -23945,12 +24075,12 @@ function stitchesSeparateAudio(planDir) {
23945
24075
  return lockedAudio(planDir).separateAudio === true;
23946
24076
  }
23947
24077
  function planFormat(planDir) {
23948
- const plan2 = JSON.parse(readFileSync17(join50(planDir, "plan.json"), "utf-8"));
24078
+ const plan2 = JSON.parse(readFileSync17(join51(planDir, "plan.json"), "utf-8"));
23949
24079
  return plan2.dimensions.format;
23950
24080
  }
23951
24081
  function lockedAudio(planDir) {
23952
- const encoderJsonPath = join50(planDir, "meta", "encoder.json");
23953
- if (!existsSync33(encoderJsonPath)) return {};
24082
+ const encoderJsonPath = join51(planDir, "meta", "encoder.json");
24083
+ if (!existsSync34(encoderJsonPath)) return {};
23954
24084
  return JSON.parse(readFileSync17(encoderJsonPath, "utf-8"));
23955
24085
  }
23956
24086
  function readCfrEncoder(planDir, format) {
@@ -23959,8 +24089,8 @@ function readCfrEncoder(planDir, format) {
23959
24089
  `[assemble] cfr=true is only supported for format="mp4" (got "${format}"). Stream-copy paths for webm and mov already produce exact avg_frame_rate; cfr re-encode is not needed.`
23960
24090
  );
23961
24091
  }
23962
- const encoderJsonPath = join50(planDir, "meta", "encoder.json");
23963
- if (!existsSync33(encoderJsonPath)) {
24092
+ const encoderJsonPath = join51(planDir, "meta", "encoder.json");
24093
+ if (!existsSync34(encoderJsonPath)) {
23964
24094
  throw new Error(`[assemble] planDir missing meta/encoder.json: ${encoderJsonPath}`);
23965
24095
  }
23966
24096
  const encoderJson = JSON.parse(readFileSync17(encoderJsonPath, "utf-8"));
@@ -23972,7 +24102,7 @@ function readCfrEncoder(planDir, format) {
23972
24102
  return encoderJson;
23973
24103
  }
23974
24104
  function mergePngFrameDirs(chunkPaths, outputPath, totalFrames, audioPath, startTimeMs) {
23975
- if (existsSync33(outputPath)) rmSync20(outputPath, { recursive: true, force: true });
24105
+ if (existsSync34(outputPath)) rmSync20(outputPath, { recursive: true, force: true });
23976
24106
  mkdirSync22(outputPath, { recursive: true });
23977
24107
  let globalIdx = 0;
23978
24108
  for (const chunkDir of chunkPaths) {
@@ -23986,8 +24116,8 @@ function mergePngFrameDirs(chunkPaths, outputPath, totalFrames, audioPath, start
23986
24116
  throw new Error(`[assemble] png-sequence chunk has no frames: ${chunkDir}`);
23987
24117
  }
23988
24118
  for (const frame of frames) {
23989
- const dst = join50(outputPath, formatExportFrameName(globalIdx, "png"));
23990
- cpSync3(join50(chunkDir, frame), dst);
24119
+ const dst = join51(outputPath, formatExportFrameName(globalIdx, "png"));
24120
+ cpSync3(join51(chunkDir, frame), dst);
23991
24121
  globalIdx += 1;
23992
24122
  }
23993
24123
  }
@@ -23996,14 +24126,14 @@ function mergePngFrameDirs(chunkPaths, outputPath, totalFrames, audioPath, start
23996
24126
  `[assemble] png-sequence frame count mismatch: merged ${globalIdx} frames vs plan.totalFrames=${totalFrames}. Using on-disk count.`
23997
24127
  );
23998
24128
  }
23999
- if (audioPath !== null && existsSync33(audioPath)) {
24000
- const sidecar = join50(outputPath, MIXED_AUDIO_FILENAME4);
24129
+ if (audioPath !== null && existsSync34(audioPath)) {
24130
+ const sidecar = join51(outputPath, MIXED_AUDIO_FILENAME4);
24001
24131
  cpSync3(audioPath, sidecar);
24002
24132
  }
24003
24133
  let fileSize = 0;
24004
24134
  for (const name of readdirSync12(outputPath)) {
24005
24135
  try {
24006
- fileSize += statSync16(join50(outputPath, name)).size;
24136
+ fileSize += statSync16(join51(outputPath, name)).size;
24007
24137
  } catch {
24008
24138
  }
24009
24139
  }
@@ -24017,8 +24147,8 @@ function mergePngFrameDirs(chunkPaths, outputPath, totalFrames, audioPath, start
24017
24147
 
24018
24148
  // src/services/distributed/planV2Execution.ts
24019
24149
  async function renderChunkV2(planV2Dir, chunkIndex, outputChunkPath, options) {
24020
- const workRoot = mkdtempSync3(join51(tmpdir6(), "hf-plan-v2-chunk-"));
24021
- const materializedPlanDir = join51(workRoot, "plan");
24150
+ const workRoot = mkdtempSync3(join52(tmpdir7(), "hf-plan-v2-chunk-"));
24151
+ const materializedPlanDir = join52(workRoot, "plan");
24022
24152
  try {
24023
24153
  materializePlanV2Target(planV2Dir, { role: "chunk", chunkIndex }, materializedPlanDir);
24024
24154
  return await renderChunk(materializedPlanDir, chunkIndex, outputChunkPath, options);
@@ -24027,8 +24157,8 @@ async function renderChunkV2(planV2Dir, chunkIndex, outputChunkPath, options) {
24027
24157
  }
24028
24158
  }
24029
24159
  async function assembleV2(planV2Dir, chunkPaths, outputPath, options) {
24030
- const workRoot = mkdtempSync3(join51(tmpdir6(), "hf-plan-v2-assembler-"));
24031
- const materializedPlanDir = join51(workRoot, "plan");
24160
+ const workRoot = mkdtempSync3(join52(tmpdir7(), "hf-plan-v2-assembler-"));
24161
+ const materializedPlanDir = join52(workRoot, "plan");
24032
24162
  try {
24033
24163
  const materialized = materializePlanV2Target(
24034
24164
  planV2Dir,