@hyperframes/producer 0.9.94 → 0.9.95

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
@@ -361,7 +361,8 @@ import {
361
361
  referenceBackgroundResult,
362
362
  createReferenceBackgroundRecorder
363
363
  } from "@hyperframes/engine";
364
- import { join as join35, dirname as dirname16, resolve as resolve9 } from "path";
364
+ import { join as join35, dirname as dirname16, resolve as resolve10 } from "path";
365
+ import { fromEmptyFolder } from "@hyperframes/parsers/ff-binaries";
365
366
  import { totalmem as totalmem2 } from "node:os";
366
367
  import { randomUUID as randomUUID3 } from "crypto";
367
368
  import { fileURLToPath as fileURLToPath5 } from "url";
@@ -1271,13 +1272,13 @@ function createFileServer(options) {
1271
1272
  if (!streamOwnsFd) closeSync(fd);
1272
1273
  }
1273
1274
  });
1274
- return new Promise((resolve14, reject) => {
1275
+ return new Promise((resolve15, reject) => {
1275
1276
  const connections = /* @__PURE__ */ new Set();
1276
1277
  const server = serve({ fetch: app.fetch, port, hostname: "127.0.0.1" }, (info) => {
1277
1278
  const bound = port === 0 ? settleOnBrowserSafePort(server, "127.0.0.1") : Promise.resolve(info.port);
1278
1279
  bound.then((boundPort) => {
1279
1280
  listeningPort = boundPort;
1280
- resolve14({
1281
+ resolve15({
1281
1282
  url: `http://localhost:${boundPort}`,
1282
1283
  port: boundPort,
1283
1284
  addPreHeadScript: (script) => {
@@ -1968,8 +1969,8 @@ var OrderedRenderEventPublisher = class {
1968
1969
  let timer;
1969
1970
  const drained = await Promise.race([
1970
1971
  this.tail.then(() => true),
1971
- new Promise((resolve14) => {
1972
- timer = setTimeout(() => resolve14(false), FLUSH_TIMEOUT_MS);
1972
+ new Promise((resolve15) => {
1973
+ timer = setTimeout(() => resolve15(false), FLUSH_TIMEOUT_MS);
1973
1974
  })
1974
1975
  ]);
1975
1976
  clearTimeout(timer);
@@ -2645,6 +2646,7 @@ import {
2645
2646
  concatVideoFiles,
2646
2647
  createCaptureSession as createCaptureSession2,
2647
2648
  getCapturePerfSummary as getCapturePerfSummary2,
2649
+ retainCapturePerf as retainCapturePerf3,
2648
2650
  initializeSession as initializeSession2,
2649
2651
  prepareCaptureSessionForReuse as prepareCaptureSessionForReuse2,
2650
2652
  resolveDeVerifyMinDb as resolveDeVerifyMinDb2,
@@ -2658,7 +2660,7 @@ import { CaptureFailure, classifyCaptureFailure } from "@hyperframes/engine";
2658
2660
  // src/services/render/perfSummary.ts
2659
2661
  import { arch, platform, totalmem } from "node:os";
2660
2662
  import { fpsToNumber as fpsToNumber2 } from "@hyperframes/core";
2661
- import { hostCpuCount } from "@hyperframes/engine";
2663
+ import { hostCpuCount, retainCapturePerf } from "@hyperframes/engine";
2662
2664
 
2663
2665
  // src/services/render/hdrPerf.ts
2664
2666
  function createHdrPerfCollector() {
@@ -2774,7 +2776,7 @@ function worstSubTimelineWaitOutcome(perfs) {
2774
2776
  }
2775
2777
  function pushWorkerDedupPerfs(results, sink) {
2776
2778
  for (const r of results) {
2777
- if (r.perf) sink.push(r.perf);
2779
+ if (r.perf) retainCapturePerf(sink, r.perf);
2778
2780
  }
2779
2781
  }
2780
2782
  function capturedBeyondViewport(perfs, fallback) {
@@ -4612,6 +4614,7 @@ import {
4612
4614
  distributeFramesInterleaved,
4613
4615
  executeParallelCapture,
4614
4616
  getCapturePerfSummary,
4617
+ retainCapturePerf as retainCapturePerf2,
4615
4618
  psnrDb,
4616
4619
  resolveDeVerifyMinDb,
4617
4620
  recaptureDrawElementFrameForVerify,
@@ -4693,7 +4696,7 @@ var SequentialCaptureStallError = class extends Error {
4693
4696
  }
4694
4697
  };
4695
4698
  function raceAgainstStall(promise, deadlineMs, input, signal) {
4696
- return new Promise((resolve14, reject) => {
4699
+ return new Promise((resolve15, reject) => {
4697
4700
  const clock = createStallClock();
4698
4701
  const trip = () => reject(
4699
4702
  signal?.aborted ? new Error(
@@ -4718,7 +4721,7 @@ function raceAgainstStall(promise, deadlineMs, input, signal) {
4718
4721
  promise.then(
4719
4722
  (value) => {
4720
4723
  clearTimeout(timer);
4721
- resolve14(value);
4724
+ resolve15(value);
4722
4725
  },
4723
4726
  (error) => {
4724
4727
  clearTimeout(timer);
@@ -5340,7 +5343,7 @@ async function runCaptureStreamingStage(input) {
5340
5343
  );
5341
5344
  }
5342
5345
  }
5343
- dedupPerfs.push(getCapturePerfSummary(session));
5346
+ retainCapturePerf2(dedupPerfs, getCapturePerfSummary(session));
5344
5347
  } catch (error) {
5345
5348
  lastBrowserConsole = session.browserConsoleBuffer;
5346
5349
  if (!resumesAfterStall(error, abortSignal, resume, resumes)) {
@@ -5640,7 +5643,7 @@ async function openSegmentWorkersTogether(run, workersToCloseLater) {
5640
5643
  if (failure && failure.status === "rejected") throw failure.reason;
5641
5644
  }
5642
5645
  async function recycleWorkerSession(run, worker, why) {
5643
- run.input.dedupPerfs.push(getCapturePerfSummary2(worker.ctx.session));
5646
+ retainCapturePerf3(run.input.dedupPerfs, getCapturePerfSummary2(worker.ctx.session));
5644
5647
  const memory = worker.ctx.session.chromeMemory?.stats();
5645
5648
  await run.deps.closeSession(worker.ctx.session);
5646
5649
  const { frames } = worker.ctx;
@@ -5769,7 +5772,8 @@ async function runCaptureSegmentedStage(input) {
5769
5772
  assertNotAborted();
5770
5773
  await openSegmentWorkersTogether(run, workers);
5771
5774
  const outcomes = await Promise.allSettled(workers.map((w) => runWorkerLoop(w)));
5772
- for (const worker of workers) dedupPerfs.push(getCapturePerfSummary2(worker.ctx.session));
5775
+ for (const worker of workers)
5776
+ retainCapturePerf3(dedupPerfs, getCapturePerfSummary2(worker.ctx.session));
5773
5777
  const failure = outcomes.find((o) => o.status === "rejected");
5774
5778
  if (failure && failure.status === "rejected") throw failure.reason;
5775
5779
  } catch (error) {
@@ -7244,7 +7248,7 @@ function requireOutputDimensions(expected, width, height) {
7244
7248
 
7245
7249
  // src/services/render/stages/compileStage.ts
7246
7250
  import { existsSync as existsSync13, writeFileSync as writeFileSync5 } from "node:fs";
7247
- import { join as join23, relative as relative5 } from "node:path";
7251
+ import { join as join23, relative as relative5, resolve as resolve9 } from "node:path";
7248
7252
  import { privateCacheRoot } from "@hyperframes/engine";
7249
7253
  import { suggestMatchingPreset } from "@hyperframes/core";
7250
7254
  import { extractStandaloneEntryFromIndex, isTemplateEntry } from "@hyperframes/core/compiler";
@@ -7253,6 +7257,7 @@ import { assertCompositionFileSize as assertCompositionFileSize2 } from "@hyperf
7253
7257
 
7254
7258
  // src/services/compileInWorker.ts
7255
7259
  import { existsSync as existsSync12, rmSync as rmSync11 } from "node:fs";
7260
+ import { ffmpegCwd } from "@hyperframes/parsers/ff-binaries";
7256
7261
  import { dirname as dirname11, isAbsolute as isAbsolute4, join as join22, relative as relative4, resolve as resolvePath } from "node:path";
7257
7262
  import { fileURLToPath as fileURLToPath3 } from "node:url";
7258
7263
  import { Worker } from "node:worker_threads";
@@ -7324,6 +7329,7 @@ import { gsapCdnDist, normalizeGsapBaseUrl } from "@hyperframes/core/gsap-cdn";
7324
7329
  import {
7325
7330
  assignBundledRuntimeCompositionIds,
7326
7331
  assignMediaRenderIds,
7332
+ dropAuthoredCompositionFiles,
7327
7333
  emitVariablesByCompScript,
7328
7334
  inlineSubCompositions as inlineSubCompositionsShared,
7329
7335
  ensureExternalLinkTag,
@@ -7981,10 +7987,10 @@ var Semaphore = class {
7981
7987
  this.active++;
7982
7988
  return () => this.release();
7983
7989
  }
7984
- return new Promise((resolve14) => {
7990
+ return new Promise((resolve15) => {
7985
7991
  this.queue.push(() => {
7986
7992
  this.active++;
7987
- resolve14(() => this.release());
7993
+ resolve15(() => this.release());
7988
7994
  });
7989
7995
  });
7990
7996
  }
@@ -8786,7 +8792,7 @@ var AssetDownloads = class {
8786
8792
  }
8787
8793
  async download(url, destDir) {
8788
8794
  while (this.running >= ASSET_DOWNLOADS_AT_ONCE) {
8789
- await new Promise((resolve14) => this.queued.push(resolve14));
8795
+ await new Promise((resolve15) => this.queued.push(resolve15));
8790
8796
  }
8791
8797
  if (this.signal?.aborted) {
8792
8798
  this.queued.shift()?.();
@@ -9175,6 +9181,7 @@ function coalesceHeadStylesAndBodyScripts(html) {
9175
9181
  }
9176
9182
  function inlineSubCompositions(html, subCompositions, projectDir, variableOverrides, assetRoot, outsideFiles, budget) {
9177
9183
  const { document: document2 } = parseHTML5(html);
9184
+ dropAuthoredCompositionFiles(document2);
9178
9185
  budget.chargeElements(ENTRY_PAGE, document2.querySelectorAll("*").length);
9179
9186
  const head = document2.querySelector("head");
9180
9187
  const body = document2.querySelector("body");
@@ -10705,9 +10712,15 @@ async function compileForRenderInWorker(projectDir, htmlPath, downloadDir, optio
10705
10712
  if (!entry) return compileForRender(projectDir, htmlPath, downloadDir, options);
10706
10713
  abortSignal?.throwIfAborted();
10707
10714
  const timeoutMs = worker.timeoutMs ?? compileTimeoutMs();
10708
- return new Promise((resolve14, reject) => {
10715
+ return new Promise((resolve15, reject) => {
10709
10716
  const thread = new Worker(entry, {
10710
- workerData: { projectDir, htmlPath, downloadDir, options: cloneable }
10717
+ workerData: {
10718
+ projectDir,
10719
+ htmlPath,
10720
+ downloadDir,
10721
+ options: cloneable,
10722
+ emptyFolder: ffmpegCwd() !== void 0
10723
+ }
10711
10724
  });
10712
10725
  const children = /* @__PURE__ */ new Map();
10713
10726
  const scratchRoots = [downloadDir, options.animatedGifCacheDir].flatMap(
@@ -10761,7 +10774,7 @@ async function compileForRenderInWorker(projectDir, htmlPath, downloadDir, optio
10761
10774
  log?.[message.level](message.message ?? "", message.meta);
10762
10775
  } else if (message.type === "result" && message.compiled) {
10763
10776
  const { compiled } = message;
10764
- settle(() => resolve14(compiled));
10777
+ settle(() => resolve15(compiled));
10765
10778
  retire(ADVISORY_GRACE_MS);
10766
10779
  } else if (message.type === "error" && message.error) {
10767
10780
  const { error } = message;
@@ -10793,7 +10806,7 @@ async function compileForRenderInWorker(projectDir, htmlPath, downloadDir, optio
10793
10806
  // src/services/render/stages/compileStage.ts
10794
10807
  function animatedGifCacheDir(extractCacheDir) {
10795
10808
  try {
10796
- const root = extractCacheDir && privateCacheRoot(extractCacheDir);
10809
+ const root = extractCacheDir && privateCacheRoot(resolve9(extractCacheDir));
10797
10810
  return root ? join23(root, "animated-gif") : void 0;
10798
10811
  } catch {
10799
10812
  return void 0;
@@ -12516,7 +12529,7 @@ import {
12516
12529
  } from "@hyperframes/engine";
12517
12530
 
12518
12531
  // src/services/render/audioPadTrim.ts
12519
- import { localContainerInputArgs } from "@hyperframes/parsers/ff-binaries";
12532
+ import { ffmpegCwd as ffmpegCwd2, localContainerInputArgs } from "@hyperframes/parsers/ff-binaries";
12520
12533
  import { spawn } from "node:child_process";
12521
12534
  import { dirname as dirname12, join as join26 } from "node:path";
12522
12535
  import {
@@ -12987,6 +13000,7 @@ async function spawnFfprobeJson(args, env, signal) {
12987
13000
  const proc = spawn(getFfprobeBinary(), args, {
12988
13001
  ...env && { env },
12989
13002
  stdio: ["ignore", "pipe", "pipe"],
13003
+ cwd: ffmpegCwd2(),
12990
13004
  windowsHide: true
12991
13005
  });
12992
13006
  trackChildProcess(proc);
@@ -13274,6 +13288,7 @@ import {
13274
13288
  completeDeferredDrawElementInit as completeDeferredDrawElementInit3,
13275
13289
  createCaptureSession as createCaptureSession5,
13276
13290
  getCapturePerfSummary as getCapturePerfSummary3,
13291
+ retainCapturePerf as retainCapturePerf4,
13277
13292
  initializeSession as initializeSession5,
13278
13293
  prepareCaptureSessionForReuse as prepareCaptureSessionForReuse3
13279
13294
  } from "@hyperframes/engine";
@@ -13635,7 +13650,7 @@ async function captureSessionFrames(session, { input, rangeStart, rangeEnd, resu
13635
13650
  },
13636
13651
  false
13637
13652
  );
13638
- dedupPerfs.push(getCapturePerfSummary3(session));
13653
+ retainCapturePerf4(dedupPerfs, getCapturePerfSummary3(session));
13639
13654
  }
13640
13655
 
13641
13656
  // src/services/render/stages/captureHdrStage.ts
@@ -14051,8 +14066,8 @@ async function createShaderTransitionWorkerPool(opts) {
14051
14066
  if (terminated) {
14052
14067
  throw new Error("shader-blend pool already terminated");
14053
14068
  }
14054
- return new Promise((resolve14, reject) => {
14055
- const task = traceEnabled ? { req, resolve: resolve14, reject, enqueuedAtMs: Date.now(), traceId: ++nextTaskId } : { req, resolve: resolve14, reject };
14069
+ return new Promise((resolve15, reject) => {
14070
+ const task = traceEnabled ? { req, resolve: resolve15, reject, enqueuedAtMs: Date.now(), traceId: ++nextTaskId } : { req, resolve: resolve15, reject };
14056
14071
  const idle = slots.find((s) => !s.busy && !s.dead);
14057
14072
  if (idle) {
14058
14073
  queue.unshift(task);
@@ -14881,7 +14896,7 @@ function encodeWhileCapturing(input, totalFrames, captureBudget) {
14881
14896
  const stream = await encoder;
14882
14897
  for (let next = 0; next < totalFrames; next++) {
14883
14898
  while (!landed.has(next) && !captureDone && !signal.aborted) {
14884
- await new Promise((resolve14) => wake = resolve14);
14899
+ await new Promise((resolve15) => wake = resolve15);
14885
14900
  }
14886
14901
  if (signal.aborted) return;
14887
14902
  const mergedPath = join34(input.framesDir, formatCaptureFrameName(next, "jpg"));
@@ -16173,10 +16188,22 @@ function deVerifyFallbackTelemetry(err) {
16173
16188
  };
16174
16189
  }
16175
16190
  function resolveRenderDebugDir() {
16176
- const producerRoot = process.env.PRODUCER_RENDERS_DIR ? resolve9(process.env.PRODUCER_RENDERS_DIR, "..") : resolve9(dirname16(fileURLToPath5(import.meta.url)), "../..");
16191
+ const producerRoot = process.env.PRODUCER_RENDERS_DIR ? resolve10(process.env.PRODUCER_RENDERS_DIR, "..") : resolve10(dirname16(fileURLToPath5(import.meta.url)), "../..");
16177
16192
  return join35(producerRoot, ".debug");
16178
16193
  }
16179
- async function executeRenderJob(job, projectDir, outputPath, progressSink, abortSignal, assertRenderActive) {
16194
+ function executeRenderJob(job, projectDir, outputPath, progressSink, abortSignal, assertRenderActive) {
16195
+ return fromEmptyFolder(
16196
+ () => renderJob(
16197
+ job,
16198
+ resolve10(projectDir),
16199
+ resolve10(outputPath),
16200
+ progressSink,
16201
+ abortSignal,
16202
+ assertRenderActive
16203
+ )
16204
+ );
16205
+ }
16206
+ async function renderJob(job, projectDir, outputPath, progressSink, abortSignal, assertRenderActive) {
16180
16207
  validateHlsRenderConfig(job.config);
16181
16208
  validateDeliveryEncoderConfig(job.config);
16182
16209
  validateChromaSubsamplingConfig(job.config);
@@ -19556,7 +19583,7 @@ async function readPlanReferenceBackground(input) {
19556
19583
 
19557
19584
  // src/services/render/stages/freezePlan.ts
19558
19585
  import { existsSync as existsSync25, mkdirSync as mkdirSync15, readFileSync as readFileSync12, readdirSync as readdirSync8, writeFileSync as writeFileSync8 } from "node:fs";
19559
- import { join as join41, relative as relative6, resolve as resolve10 } from "node:path";
19586
+ import { join as join41, relative as relative6, resolve as resolve11 } from "node:path";
19560
19587
  import {
19561
19588
  REFERENCE_BACKGROUND_FIELD,
19562
19589
  referenceBackgroundResult as referenceBackgroundResult3
@@ -19770,7 +19797,7 @@ function stripUndefined(value) {
19770
19797
  }
19771
19798
  function listPlanFiles(planDir) {
19772
19799
  const results = [];
19773
- const rootResolved = resolve10(planDir);
19800
+ const rootResolved = resolve11(planDir);
19774
19801
  function walk(dir) {
19775
19802
  const entries = readdirSync8(dir, { withFileTypes: true });
19776
19803
  for (const entry of entries) {
@@ -21201,7 +21228,7 @@ import {
21201
21228
  writeFileSync as writeFileSync12
21202
21229
  } from "node:fs";
21203
21230
  import { tmpdir as tmpdir4 } from "node:os";
21204
- import { dirname as dirname20, isAbsolute as isAbsolute6, join as join47, relative as relative9, resolve as resolve11, sep as sep6 } from "node:path";
21231
+ import { dirname as dirname20, isAbsolute as isAbsolute6, join as join47, relative as relative9, resolve as resolve12, sep as sep6 } from "node:path";
21205
21232
  import { DISTRIBUTED_FPS, isDistributedFps } from "@hyperframes/core";
21206
21233
  import {
21207
21234
  createFrameLookupTable as createFrameLookupTable5,
@@ -21360,7 +21387,7 @@ function assertSafeRelativePath(path) {
21360
21387
  }
21361
21388
  function listFiles(root) {
21362
21389
  const files = [];
21363
- const rootResolved = resolve11(root);
21390
+ const rootResolved = resolve12(root);
21364
21391
  function walk(dir) {
21365
21392
  for (const entry of readdirSync10(dir, { withFileTypes: true })) {
21366
21393
  const absolutePath = join47(dir, entry.name);
@@ -21406,8 +21433,8 @@ function isExtractionCacheCompleteSentinelPath(path) {
21406
21433
  return segments.length === 3 && segments[0] === "video-frames" && segments[1] !== "" && segments[2] === EXTRACTION_CACHE_COMPLETE_SENTINEL;
21407
21434
  }
21408
21435
  function resolveExtractedVideoOutputDir(planDir, videoId) {
21409
- const videoRoot = resolve11(planDir, "video-frames");
21410
- const outputDir = resolve11(videoRoot, mediaIdPathSegment4(videoId));
21436
+ const videoRoot = resolve12(planDir, "video-frames");
21437
+ const outputDir = resolve12(videoRoot, mediaIdPathSegment4(videoId));
21411
21438
  if (outputDir === videoRoot || !outputDir.startsWith(`${videoRoot}${sep6}`)) {
21412
21439
  throw new PlanV2IntegrityError(`unsafe extracted video id: ${JSON.stringify(videoId)}`);
21413
21440
  }
@@ -21568,7 +21595,7 @@ function collectChunkVideoDependencies(input) {
21568
21595
  for (let frame = chunk.startFrame; frame < chunk.endFrame; frame++) {
21569
21596
  const globalTime = frame * input.fpsDen / input.fpsNum;
21570
21597
  for (const [videoId, payload] of input.table.getActiveFramePayloads(globalTime)) {
21571
- const path = input.deferredSources.get(videoId) ?? relative9(resolve11(input.executionPlanDir), payload.framePath).split(sep6).join("/");
21598
+ const path = input.deferredSources.get(videoId) ?? relative9(resolve12(input.executionPlanDir), payload.framePath).split(sep6).join("/");
21572
21599
  assertSafeRelativePath(path);
21573
21600
  const indexes = mutable.get(path) ?? /* @__PURE__ */ new Set();
21574
21601
  indexes.add(chunk.index);
@@ -22390,8 +22417,8 @@ async function renderChunk(planDir, chunkIndex, outputChunkPath, options) {
22390
22417
  const verifyInWorker = chunkWorkerCount > 1 && !forceScreenshotForChunk;
22391
22418
  let boxesMeasured;
22392
22419
  let boxesFailed;
22393
- const boxesReady = new Promise((resolve14, reject) => {
22394
- boxesMeasured = resolve14;
22420
+ const boxesReady = new Promise((resolve15, reject) => {
22421
+ boxesMeasured = resolve15;
22395
22422
  boxesFailed = reject;
22396
22423
  });
22397
22424
  boxesReady.catch(() => {
@@ -23508,7 +23535,7 @@ import {
23508
23535
  createReadStream as createReadStream6
23509
23536
  } from "node:fs";
23510
23537
  import { AsyncLocalStorage } from "node:async_hooks";
23511
- import { basename as basename9, resolve as resolve13, dirname as dirname23, join as join52 } from "node:path";
23538
+ import { basename as basename9, resolve as resolve14, dirname as dirname23, join as join52 } from "node:path";
23512
23539
  import { homedir, tmpdir as tmpdir6 } from "node:os";
23513
23540
  import { parseArgs } from "node:util";
23514
23541
  import { isIP } from "node:net";
@@ -23534,7 +23561,7 @@ import {
23534
23561
  closeSync as closeSync8,
23535
23562
  constants as constants4
23536
23563
  } from "node:fs";
23537
- import { resolve as resolve12, join as join50, relative as relative10, isAbsolute as isAbsolute7, sep as sep7, dirname as dirname21 } from "node:path";
23564
+ import { resolve as resolve13, join as join50, relative as relative10, isAbsolute as isAbsolute7, sep as sep7, dirname as dirname21 } from "node:path";
23538
23565
  import { fileURLToPath as fileURLToPath7 } from "node:url";
23539
23566
  import { Worker as Worker3 } from "node:worker_threads";
23540
23567
  function isStringRecord(value) {
@@ -23584,7 +23611,7 @@ function leavesProject(absProjectDir, absoluteEntryPath, isAllowedEntry) {
23584
23611
  return entryRelativePath === ".." || entryRelativePath.startsWith(`..${sep7}`) || isAbsolute7(entryRelativePath) || isAllowedEntry !== void 0 && !isAllowedEntry(absoluteEntryPath);
23585
23612
  }
23586
23613
  function readProjectEntryFile(projectDir, preferredEntryFile, isAllowedEntry) {
23587
- const absProjectDir = resolve12(projectDir);
23614
+ const absProjectDir = resolve13(projectDir);
23588
23615
  if (!existsSync31(absProjectDir) || !statSync13(absProjectDir).isDirectory()) {
23589
23616
  return { error: `Project directory not found: ${absProjectDir}` };
23590
23617
  }
@@ -23592,7 +23619,7 @@ function readProjectEntryFile(projectDir, preferredEntryFile, isAllowedEntry) {
23592
23619
  (value) => typeof value === "string" && value.trim().length > 0
23593
23620
  );
23594
23621
  for (const entryFile of entryCandidates) {
23595
- const absoluteEntryPath = resolve12(absProjectDir, entryFile);
23622
+ const absoluteEntryPath = resolve13(absProjectDir, entryFile);
23596
23623
  if (leavesProject(absProjectDir, absoluteEntryPath, isAllowedEntry)) {
23597
23624
  return { error: `Entry file must stay inside project directory: ${entryFile}` };
23598
23625
  }
@@ -23652,16 +23679,16 @@ function takeLintSlot(limit, waitMs) {
23652
23679
  running++;
23653
23680
  return Promise.resolve(true);
23654
23681
  }
23655
- return new Promise((resolve14) => {
23682
+ return new Promise((resolve15) => {
23656
23683
  const entry = () => {
23657
23684
  clearTimeout(timer);
23658
23685
  running++;
23659
- resolve14(true);
23686
+ resolve15(true);
23660
23687
  };
23661
23688
  const timer = setTimeout(
23662
23689
  () => {
23663
23690
  waiting.splice(waiting.indexOf(entry), 1);
23664
- resolve14(false);
23691
+ resolve15(false);
23665
23692
  },
23666
23693
  Math.max(0, waitMs)
23667
23694
  );
@@ -23765,12 +23792,12 @@ async function startHealthWorker(options = {}) {
23765
23792
  stdout: false,
23766
23793
  stderr: false
23767
23794
  });
23768
- await new Promise((resolve14, reject) => {
23795
+ await new Promise((resolve15, reject) => {
23769
23796
  const onMessage = (msg) => {
23770
23797
  if (msg?.type === "listening") {
23771
23798
  worker.off("error", onError);
23772
23799
  worker.off("message", onMessage);
23773
- resolve14();
23800
+ resolve15();
23774
23801
  } else if (msg?.type === "listen-error") {
23775
23802
  worker.off("error", onError);
23776
23803
  worker.off("message", onMessage);
@@ -23987,7 +24014,7 @@ function buildRenderJobConfig(input, outputPath, log) {
23987
24014
  function resolvePreparedRenderOutput(prepared, rendersDir, log, confineOutput) {
23988
24015
  const { input, cleanupProjectDir } = prepared;
23989
24016
  const serverNamed = input.outputPath == null;
23990
- const outputCandidate = input.outputPath ?? join52(rendersDir, `${basename9(resolve13(input.projectDir))}-${crypto.randomUUID()}.mp4`);
24017
+ const outputCandidate = input.outputPath ?? join52(rendersDir, `${basename9(resolve14(input.projectDir))}-${crypto.randomUUID()}.mp4`);
23991
24018
  const absoluteOutputPath = resolveOutputPath(input.projectDir, outputCandidate, rendersDir, log);
23992
24019
  const outputDir = dirname23(absoluteOutputPath);
23993
24020
  if (confineOutput) {
@@ -24009,7 +24036,7 @@ var STICKY_BIT = 512;
24009
24036
  var SERVER_FOLDER_MODE = 493;
24010
24037
  function folderAnotherAccountCanChange(dir, rendersDir) {
24011
24038
  const foreign = foreignWritablePath(dir, rendersDir);
24012
- const stickyRoot = foreign === resolve13(rendersDir) && (lstatSync6(foreign).mode & STICKY_BIT) !== 0;
24039
+ const stickyRoot = foreign === resolve14(rendersDir) && (lstatSync6(foreign).mode & STICKY_BIT) !== 0;
24013
24040
  return stickyRoot ? void 0 : foreign;
24014
24041
  }
24015
24042
  function prepareRenderJob(prepared, rendersDir, log, confineOutput) {
@@ -24070,7 +24097,7 @@ function validateOutputResolutionOverride(body) {
24070
24097
  var MAX_PREVIEW_HTML_BYTES = 20 * 1024 * 1024;
24071
24098
  function resolveRenderRequestPolicy(options) {
24072
24099
  return {
24073
- projectsDir: resolve13(
24100
+ projectsDir: resolve14(
24074
24101
  options.projectsDir ?? (process.env.PRODUCER_PROJECTS_DIR || process.cwd())
24075
24102
  ),
24076
24103
  allowDebug: options.allowDebug ?? process.env.PRODUCER_ALLOW_DEBUG === "1"
@@ -24085,13 +24112,13 @@ function isAllowedEntryPath(policy, projectDir, path) {
24085
24112
  function prepareProjectDirectory(projectDir, options, policy) {
24086
24113
  const candidate = nonEmptyString(projectDir);
24087
24114
  if (!candidate) return null;
24088
- const absProjectDir = policy ? resolve13(policy.projectsDir, candidate) : resolve13(candidate);
24115
+ const absProjectDir = policy ? resolve14(policy.projectsDir, candidate) : resolve14(candidate);
24089
24116
  const shown = policy ? candidate : absProjectDir;
24090
24117
  if (policy && !isAllowedProjectPath(policy.projectsDir, absProjectDir) || !existsSync33(absProjectDir) || !statSync14(absProjectDir).isDirectory()) {
24091
24118
  return { error: `Project directory not found: ${shown}` };
24092
24119
  }
24093
24120
  const entry = options.entryFile || "index.html";
24094
- const entryPath = resolve13(absProjectDir, entry);
24121
+ const entryPath = resolve14(absProjectDir, entry);
24095
24122
  if (policy && !isAllowedEntryPath(policy, absProjectDir, entryPath) || !existsSync33(entryPath)) {
24096
24123
  return { error: `Entry file "${entry}" not found in project directory: ${shown}` };
24097
24124
  }
@@ -24142,7 +24169,7 @@ function resolveOutputPath(projectDir, outputCandidate, rendersDir, log) {
24142
24169
  try {
24143
24170
  return resolveRenderPaths(projectDir, outputCandidate, rendersDir).absoluteOutputPath;
24144
24171
  } catch (error) {
24145
- const fallbackPath = resolve13(rendersDir, `producer-fallback-${Date.now()}.mp4`);
24172
+ const fallbackPath = resolve14(rendersDir, `producer-fallback-${Date.now()}.mp4`);
24146
24173
  log.warn("Failed to resolve output path, using fallback", {
24147
24174
  fallback: fallbackPath,
24148
24175
  error: error instanceof Error ? error.message : String(error)
@@ -24349,7 +24376,7 @@ function createRenderHandlers(options = {}) {
24349
24376
  const lintProjectDir = nonEmptyString(body.projectDir);
24350
24377
  let isAllowedEntry;
24351
24378
  if (policy && lintProjectDir) {
24352
- const absProjectDir = resolve13(policy.projectsDir, lintProjectDir);
24379
+ const absProjectDir = resolve14(policy.projectsDir, lintProjectDir);
24353
24380
  if (!isAllowedProjectPath(policy.projectsDir, absProjectDir)) {
24354
24381
  const error = `Project directory not found: ${lintProjectDir}`;
24355
24382
  return c.json({ success: false, requestId, error }, 400);
@@ -24703,7 +24730,7 @@ function serverAuth(options, hostname2, port) {
24703
24730
  `Refusing to listen on ${hostname2} without an auth token. Set authToken or PRODUCER_AUTH_TOKEN, or listen on a loopback address.`
24704
24731
  );
24705
24732
  }
24706
- const file = resolve13(
24733
+ const file = resolve14(
24707
24734
  options.authTokenFile?.trim() || process.env.PRODUCER_AUTH_TOKEN_FILE?.trim() || join52(homedir(), ".hyperframes", "producer", `${port}.token`)
24708
24735
  );
24709
24736
  const token = crypto.randomBytes(32).toString("base64url");
@@ -24763,7 +24790,7 @@ function startServer(options = {}) {
24763
24790
  process.on("SIGINT", () => shutdown("SIGINT"));
24764
24791
  return server;
24765
24792
  }
24766
- var entryScript = process.argv[1] ? resolve13(process.argv[1]) : "";
24793
+ var entryScript = process.argv[1] ? resolve14(process.argv[1]) : "";
24767
24794
  var isPublicServerEntry = entryScript.endsWith("/public-server.js") || entryScript.endsWith("/src/server.ts");
24768
24795
  if (isPublicServerEntry) {
24769
24796
  const { values } = parseArgs({