@hyperframes/producer 0.9.94 → 0.9.96

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.
@@ -1,6 +1,7 @@
1
1
  // src/services/compileWorker.ts
2
2
  import { parentPort, workerData } from "node:worker_threads";
3
3
  import { onTrackedChildProcess } from "@hyperframes/engine";
4
+ import { fromEmptyFolder } from "@hyperframes/parsers/ff-binaries";
4
5
 
5
6
  // src/services/compileScratch.ts
6
7
  import { basename } from "node:path";
@@ -245,6 +246,7 @@ import { gsapCdnDist, normalizeGsapBaseUrl } from "@hyperframes/core/gsap-cdn";
245
246
  import {
246
247
  assignBundledRuntimeCompositionIds,
247
248
  assignMediaRenderIds,
249
+ dropAuthoredCompositionFiles,
248
250
  emitVariablesByCompScript,
249
251
  inlineSubCompositions as inlineSubCompositionsShared,
250
252
  ensureExternalLinkTag,
@@ -2131,6 +2133,7 @@ function coalesceHeadStylesAndBodyScripts(html) {
2131
2133
  }
2132
2134
  function inlineSubCompositions(html, subCompositions, projectDir2, variableOverrides, assetRoot, outsideFiles, budget) {
2133
2135
  const { document: document2 } = parseHTML4(html);
2136
+ dropAuthoredCompositionFiles(document2);
2134
2137
  budget.chargeElements(ENTRY_PAGE, document2.querySelectorAll("*").length);
2135
2138
  const head = document2.querySelector("head");
2136
2139
  const body = document2.querySelector("body");
@@ -3227,7 +3230,7 @@ async function compileWithAssets(projectDir2, htmlPath2, downloadDir2, options2,
3227
3230
  }
3228
3231
 
3229
3232
  // src/services/compileWorker.ts
3230
- var { projectDir, htmlPath, downloadDir, options } = workerData;
3233
+ var { projectDir, htmlPath, downloadDir, options, emptyFolder } = workerData;
3231
3234
  function post(level, message, meta) {
3232
3235
  try {
3233
3236
  parentPort?.postMessage({ type: "log", level, message, meta });
@@ -3263,11 +3266,12 @@ onTrackedChildProcess((proc) => {
3263
3266
  proc.once("exit", () => parentPort?.postMessage({ type: "childExit", pid }));
3264
3267
  });
3265
3268
  try {
3266
- const compiled = await compileForRender(projectDir, htmlPath, downloadDir, {
3269
+ const compile = () => compileForRender(projectDir, htmlPath, downloadDir, {
3267
3270
  ...options,
3268
3271
  log,
3269
3272
  abortSignal: controller.signal
3270
3273
  });
3274
+ const compiled = await (emptyFolder ? fromEmptyFolder(compile) : compile());
3271
3275
  parentPort?.postMessage({ type: "result", compiled });
3272
3276
  } catch (error) {
3273
3277
  const props = {};
@@ -380,13 +380,18 @@ import {
380
380
  referenceBackgroundResult,
381
381
  createReferenceBackgroundRecorder
382
382
  } from "@hyperframes/engine";
383
- import { join as join19, dirname as dirname12, resolve as resolve7 } from "path";
383
+ import { join as join19, dirname as dirname12, resolve as resolve8 } from "path";
384
+ import { fromEmptyFolder } from "@hyperframes/parsers/ff-binaries";
384
385
  import { randomUUID as randomUUID3 } from "crypto";
385
386
 
386
387
  // src/services/fileServer.ts
387
388
  import { Hono } from "hono";
388
389
  import { serve } from "@hono/node-server";
389
- import { answerOwnLoopbackHostOnly, settleOnBrowserSafePort } from "@hyperframes/engine";
390
+ import {
391
+ answerOwnLoopbackHostOnly,
392
+ boundedPageText,
393
+ settleOnBrowserSafePort
394
+ } from "@hyperframes/engine";
390
395
  import {
391
396
  existsSync as existsSync2,
392
397
  realpathSync,
@@ -1020,12 +1025,13 @@ function closeFileServerSafely(fileServer, label, log = defaultLogger) {
1020
1025
  });
1021
1026
  }
1022
1027
  }
1028
+ var NO_FILE_AT_NAME = /* @__PURE__ */ new Set(["ENOENT", "ENOTDIR", "ENAMETOOLONG"]);
1023
1029
  function openRegularFile(filePath) {
1024
1030
  let fd;
1025
1031
  try {
1026
1032
  fd = openSync(filePath, constants.O_RDONLY | constants.O_NONBLOCK);
1027
1033
  } catch (error) {
1028
- if (error instanceof Error && "code" in error && (error.code === "ENOENT" || error.code === "ENOTDIR"))
1034
+ if (error instanceof Error && "code" in error && NO_FILE_AT_NAME.has(String(error.code)))
1029
1035
  return null;
1030
1036
  if (!statSync2(filePath, { throwIfNoEntry: false })?.isFile()) return null;
1031
1037
  throw error;
@@ -1088,7 +1094,7 @@ function createFileServer(options) {
1088
1094
  }
1089
1095
  if (!file) {
1090
1096
  if (!/favicon\.ico$/i.test(requestPath)) {
1091
- console.warn(`[FileServer] 404 Not Found: ${terminalText2(requestPath)}`);
1097
+ console.warn(`[FileServer] 404 Not Found: ${terminalText2(boundedPageText(requestPath))}`);
1092
1098
  }
1093
1099
  return c.text("Not found", 404);
1094
1100
  }
@@ -1162,13 +1168,13 @@ function createFileServer(options) {
1162
1168
  if (!streamOwnsFd) closeSync(fd);
1163
1169
  }
1164
1170
  });
1165
- return new Promise((resolve10, reject) => {
1171
+ return new Promise((resolve11, reject) => {
1166
1172
  const connections = /* @__PURE__ */ new Set();
1167
1173
  const server = serve({ fetch: app.fetch, port, hostname: "127.0.0.1" }, (info) => {
1168
1174
  const bound = port === 0 ? settleOnBrowserSafePort(server, "127.0.0.1") : Promise.resolve(info.port);
1169
1175
  bound.then((boundPort) => {
1170
1176
  listeningPort = boundPort;
1171
- resolve10({
1177
+ resolve11({
1172
1178
  url: `http://localhost:${boundPort}`,
1173
1179
  port: boundPort,
1174
1180
  addPreHeadScript: (script) => {
@@ -1657,6 +1663,7 @@ import {
1657
1663
  concatVideoFiles,
1658
1664
  createCaptureSession as createCaptureSession2,
1659
1665
  getCapturePerfSummary as getCapturePerfSummary2,
1666
+ retainCapturePerf as retainCapturePerf3,
1660
1667
  initializeSession as initializeSession2,
1661
1668
  prepareCaptureSessionForReuse as prepareCaptureSessionForReuse2,
1662
1669
  resolveDeVerifyMinDb as resolveDeVerifyMinDb2,
@@ -1669,10 +1676,10 @@ import { CaptureFailure, classifyCaptureFailure } from "@hyperframes/engine";
1669
1676
 
1670
1677
  // src/services/render/perfSummary.ts
1671
1678
  import { fpsToNumber as fpsToNumber2 } from "@hyperframes/core";
1672
- import { hostCpuCount } from "@hyperframes/engine";
1679
+ import { hostCpuCount, retainCapturePerf } from "@hyperframes/engine";
1673
1680
  function pushWorkerDedupPerfs(results, sink) {
1674
1681
  for (const r of results) {
1675
- if (r.perf) sink.push(r.perf);
1682
+ if (r.perf) retainCapturePerf(sink, r.perf);
1676
1683
  }
1677
1684
  }
1678
1685
  function pushWorkerPageErrors(results, sink) {
@@ -1781,6 +1788,7 @@ import {
1781
1788
  distributeFramesInterleaved,
1782
1789
  executeParallelCapture,
1783
1790
  getCapturePerfSummary,
1791
+ retainCapturePerf as retainCapturePerf2,
1784
1792
  psnrDb,
1785
1793
  resolveDeVerifyMinDb,
1786
1794
  recaptureDrawElementFrameForVerify,
@@ -1836,7 +1844,7 @@ var SequentialCaptureStallError = class extends Error {
1836
1844
  }
1837
1845
  };
1838
1846
  function raceAgainstStall(promise, deadlineMs, input, signal) {
1839
- return new Promise((resolve10, reject) => {
1847
+ return new Promise((resolve11, reject) => {
1840
1848
  const clock = createStallClock();
1841
1849
  const trip = () => reject(
1842
1850
  signal?.aborted ? new Error(
@@ -1861,7 +1869,7 @@ function raceAgainstStall(promise, deadlineMs, input, signal) {
1861
1869
  promise.then(
1862
1870
  (value) => {
1863
1871
  clearTimeout(timer);
1864
- resolve10(value);
1872
+ resolve11(value);
1865
1873
  },
1866
1874
  (error) => {
1867
1875
  clearTimeout(timer);
@@ -2460,7 +2468,7 @@ function requireOutputDimensions(expected, width, height) {
2460
2468
 
2461
2469
  // src/services/render/stages/compileStage.ts
2462
2470
  import { existsSync as existsSync9, writeFileSync as writeFileSync3 } from "node:fs";
2463
- import { join as join11, relative as relative4 } from "node:path";
2471
+ import { join as join11, relative as relative4, resolve as resolve7 } from "node:path";
2464
2472
  import { privateCacheRoot } from "@hyperframes/engine";
2465
2473
  import { suggestMatchingPreset } from "@hyperframes/core";
2466
2474
  import { extractStandaloneEntryFromIndex, isTemplateEntry } from "@hyperframes/core/compiler";
@@ -2469,6 +2477,7 @@ import { assertCompositionFileSize as assertCompositionFileSize2 } from "@hyperf
2469
2477
 
2470
2478
  // src/services/compileInWorker.ts
2471
2479
  import { existsSync as existsSync8, rmSync as rmSync4 } from "node:fs";
2480
+ import { ffmpegCwd } from "@hyperframes/parsers/ff-binaries";
2472
2481
  import { dirname as dirname8, isAbsolute as isAbsolute3, join as join10, relative as relative3, resolve as resolvePath } from "node:path";
2473
2482
  import { fileURLToPath as fileURLToPath3 } from "node:url";
2474
2483
  import { Worker } from "node:worker_threads";
@@ -2540,6 +2549,7 @@ import { gsapCdnDist, normalizeGsapBaseUrl } from "@hyperframes/core/gsap-cdn";
2540
2549
  import {
2541
2550
  assignBundledRuntimeCompositionIds,
2542
2551
  assignMediaRenderIds,
2552
+ dropAuthoredCompositionFiles,
2543
2553
  emitVariablesByCompScript,
2544
2554
  inlineSubCompositions as inlineSubCompositionsShared,
2545
2555
  ensureExternalLinkTag,
@@ -3197,10 +3207,10 @@ var Semaphore = class {
3197
3207
  this.active++;
3198
3208
  return () => this.release();
3199
3209
  }
3200
- return new Promise((resolve10) => {
3210
+ return new Promise((resolve11) => {
3201
3211
  this.queue.push(() => {
3202
3212
  this.active++;
3203
- resolve10(() => this.release());
3213
+ resolve11(() => this.release());
3204
3214
  });
3205
3215
  });
3206
3216
  }
@@ -4002,7 +4012,7 @@ var AssetDownloads = class {
4002
4012
  }
4003
4013
  async download(url, destDir) {
4004
4014
  while (this.running >= ASSET_DOWNLOADS_AT_ONCE) {
4005
- await new Promise((resolve10) => this.queued.push(resolve10));
4015
+ await new Promise((resolve11) => this.queued.push(resolve11));
4006
4016
  }
4007
4017
  if (this.signal?.aborted) {
4008
4018
  this.queued.shift()?.();
@@ -4391,6 +4401,7 @@ function coalesceHeadStylesAndBodyScripts(html) {
4391
4401
  }
4392
4402
  function inlineSubCompositions(html, subCompositions, projectDir, variableOverrides, assetRoot, outsideFiles, budget) {
4393
4403
  const { document: document2 } = parseHTML5(html);
4404
+ dropAuthoredCompositionFiles(document2);
4394
4405
  budget.chargeElements(ENTRY_PAGE, document2.querySelectorAll("*").length);
4395
4406
  const head = document2.querySelector("head");
4396
4407
  const body = document2.querySelector("body");
@@ -5918,9 +5929,15 @@ async function compileForRenderInWorker(projectDir, htmlPath, downloadDir, optio
5918
5929
  if (!entry) return compileForRender(projectDir, htmlPath, downloadDir, options);
5919
5930
  abortSignal?.throwIfAborted();
5920
5931
  const timeoutMs = worker.timeoutMs ?? compileTimeoutMs();
5921
- return new Promise((resolve10, reject) => {
5932
+ return new Promise((resolve11, reject) => {
5922
5933
  const thread = new Worker(entry, {
5923
- workerData: { projectDir, htmlPath, downloadDir, options: cloneable }
5934
+ workerData: {
5935
+ projectDir,
5936
+ htmlPath,
5937
+ downloadDir,
5938
+ options: cloneable,
5939
+ emptyFolder: ffmpegCwd() !== void 0
5940
+ }
5924
5941
  });
5925
5942
  const children = /* @__PURE__ */ new Map();
5926
5943
  const scratchRoots = [downloadDir, options.animatedGifCacheDir].flatMap(
@@ -5974,7 +5991,7 @@ async function compileForRenderInWorker(projectDir, htmlPath, downloadDir, optio
5974
5991
  log?.[message.level](message.message ?? "", message.meta);
5975
5992
  } else if (message.type === "result" && message.compiled) {
5976
5993
  const { compiled } = message;
5977
- settle(() => resolve10(compiled));
5994
+ settle(() => resolve11(compiled));
5978
5995
  retire(ADVISORY_GRACE_MS);
5979
5996
  } else if (message.type === "error" && message.error) {
5980
5997
  const { error } = message;
@@ -6006,7 +6023,7 @@ async function compileForRenderInWorker(projectDir, htmlPath, downloadDir, optio
6006
6023
  // src/services/render/stages/compileStage.ts
6007
6024
  function animatedGifCacheDir(extractCacheDir) {
6008
6025
  try {
6009
- const root = extractCacheDir && privateCacheRoot(extractCacheDir);
6026
+ const root = extractCacheDir && privateCacheRoot(resolve7(extractCacheDir));
6010
6027
  return root ? join11(root, "animated-gif") : void 0;
6011
6028
  } catch {
6012
6029
  return void 0;
@@ -7650,7 +7667,7 @@ import {
7650
7667
  } from "@hyperframes/engine";
7651
7668
 
7652
7669
  // src/services/render/audioPadTrim.ts
7653
- import { localContainerInputArgs } from "@hyperframes/parsers/ff-binaries";
7670
+ import { ffmpegCwd as ffmpegCwd2, localContainerInputArgs } from "@hyperframes/parsers/ff-binaries";
7654
7671
  import { spawn } from "node:child_process";
7655
7672
  import { dirname as dirname9, join as join14 } from "node:path";
7656
7673
  import {
@@ -8121,6 +8138,7 @@ async function spawnFfprobeJson(args, env, signal) {
8121
8138
  const proc = spawn(getFfprobeBinary(), args, {
8122
8139
  ...env && { env },
8123
8140
  stdio: ["ignore", "pipe", "pipe"],
8141
+ cwd: ffmpegCwd2(),
8124
8142
  windowsHide: true
8125
8143
  });
8126
8144
  trackChildProcess(proc);
@@ -8408,6 +8426,7 @@ import {
8408
8426
  completeDeferredDrawElementInit as completeDeferredDrawElementInit3,
8409
8427
  createCaptureSession as createCaptureSession5,
8410
8428
  getCapturePerfSummary as getCapturePerfSummary3,
8429
+ retainCapturePerf as retainCapturePerf4,
8411
8430
  initializeSession as initializeSession5,
8412
8431
  prepareCaptureSessionForReuse as prepareCaptureSessionForReuse3
8413
8432
  } from "@hyperframes/engine";
@@ -8750,7 +8769,7 @@ async function captureSessionFrames(session, { input, rangeStart, rangeEnd, resu
8750
8769
  },
8751
8770
  false
8752
8771
  );
8753
- dedupPerfs.push(getCapturePerfSummary3(session));
8772
+ retainCapturePerf4(dedupPerfs, getCapturePerfSummary3(session));
8754
8773
  }
8755
8774
 
8756
8775
  // src/services/render/stages/captureHdrStage.ts
@@ -9016,7 +9035,7 @@ function encodeWhileCapturing(input, totalFrames, captureBudget) {
9016
9035
  const stream = await encoder;
9017
9036
  for (let next = 0; next < totalFrames; next++) {
9018
9037
  while (!landed.has(next) && !captureDone && !signal.aborted) {
9019
- await new Promise((resolve10) => wake = resolve10);
9038
+ await new Promise((resolve11) => wake = resolve11);
9020
9039
  }
9021
9040
  if (signal.aborted) return;
9022
9041
  const mergedPath = join18(input.framesDir, formatCaptureFrameName(next, "jpg"));
@@ -10241,7 +10260,7 @@ async function readPlanReferenceBackground(input) {
10241
10260
 
10242
10261
  // src/services/render/stages/freezePlan.ts
10243
10262
  import { existsSync as existsSync18, mkdirSync as mkdirSync7, readFileSync as readFileSync8, readdirSync as readdirSync5, writeFileSync as writeFileSync6 } from "node:fs";
10244
- import { join as join24, relative as relative5, resolve as resolve8 } from "node:path";
10263
+ import { join as join24, relative as relative5, resolve as resolve9 } from "node:path";
10245
10264
  import {
10246
10265
  REFERENCE_BACKGROUND_FIELD,
10247
10266
  referenceBackgroundResult as referenceBackgroundResult3
@@ -10455,7 +10474,7 @@ function stripUndefined(value) {
10455
10474
  }
10456
10475
  function listPlanFiles(planDir) {
10457
10476
  const results = [];
10458
- const rootResolved = resolve8(planDir);
10477
+ const rootResolved = resolve9(planDir);
10459
10478
  function walk(dir) {
10460
10479
  const entries = readdirSync5(dir, { withFileTypes: true });
10461
10480
  for (const entry of entries) {
@@ -12262,7 +12281,7 @@ import {
12262
12281
  writeFileSync as writeFileSync10
12263
12282
  } from "node:fs";
12264
12283
  import { tmpdir } from "node:os";
12265
- import { dirname as dirname16, isAbsolute as isAbsolute5, join as join31, relative as relative8, resolve as resolve9, sep as sep5 } from "node:path";
12284
+ import { dirname as dirname16, isAbsolute as isAbsolute5, join as join31, relative as relative8, resolve as resolve10, sep as sep5 } from "node:path";
12266
12285
  import { DISTRIBUTED_FPS, isDistributedFps } from "@hyperframes/core";
12267
12286
  import {
12268
12287
  createFrameLookupTable as createFrameLookupTable5,
@@ -12421,7 +12440,7 @@ function assertSafeRelativePath(path) {
12421
12440
  }
12422
12441
  function listFiles(root) {
12423
12442
  const files = [];
12424
- const rootResolved = resolve9(root);
12443
+ const rootResolved = resolve10(root);
12425
12444
  function walk(dir) {
12426
12445
  for (const entry of readdirSync7(dir, { withFileTypes: true })) {
12427
12446
  const absolutePath = join31(dir, entry.name);
@@ -12467,8 +12486,8 @@ function isExtractionCacheCompleteSentinelPath(path) {
12467
12486
  return segments.length === 3 && segments[0] === "video-frames" && segments[1] !== "" && segments[2] === EXTRACTION_CACHE_COMPLETE_SENTINEL;
12468
12487
  }
12469
12488
  function resolveExtractedVideoOutputDir(planDir, videoId) {
12470
- const videoRoot = resolve9(planDir, "video-frames");
12471
- const outputDir = resolve9(videoRoot, mediaIdPathSegment4(videoId));
12489
+ const videoRoot = resolve10(planDir, "video-frames");
12490
+ const outputDir = resolve10(videoRoot, mediaIdPathSegment4(videoId));
12472
12491
  if (outputDir === videoRoot || !outputDir.startsWith(`${videoRoot}${sep5}`)) {
12473
12492
  throw new PlanV2IntegrityError(`unsafe extracted video id: ${JSON.stringify(videoId)}`);
12474
12493
  }
@@ -12629,7 +12648,7 @@ function collectChunkVideoDependencies(input) {
12629
12648
  for (let frame = chunk.startFrame; frame < chunk.endFrame; frame++) {
12630
12649
  const globalTime = frame * input.fpsDen / input.fpsNum;
12631
12650
  for (const [videoId, payload] of input.table.getActiveFramePayloads(globalTime)) {
12632
- const path = input.deferredSources.get(videoId) ?? relative8(resolve9(input.executionPlanDir), payload.framePath).split(sep5).join("/");
12651
+ const path = input.deferredSources.get(videoId) ?? relative8(resolve10(input.executionPlanDir), payload.framePath).split(sep5).join("/");
12633
12652
  assertSafeRelativePath(path);
12634
12653
  const indexes = mutable.get(path) ?? /* @__PURE__ */ new Set();
12635
12654
  indexes.add(chunk.index);
@@ -13820,8 +13839,8 @@ async function renderChunk(planDir, chunkIndex, outputChunkPath, options) {
13820
13839
  const verifyInWorker = chunkWorkerCount > 1 && !forceScreenshotForChunk;
13821
13840
  let boxesMeasured;
13822
13841
  let boxesFailed;
13823
- const boxesReady = new Promise((resolve10, reject) => {
13824
- boxesMeasured = resolve10;
13842
+ const boxesReady = new Promise((resolve11, reject) => {
13843
+ boxesMeasured = resolve11;
13825
13844
  boxesFailed = reject;
13826
13845
  });
13827
13846
  boxesReady.catch(() => {
@@ -1,7 +1,7 @@
1
1
  {
2
2
  "version": "0.1.0",
3
3
  "buildId": "dev",
4
- "sha256": "874346801fcf8668e76936bb5e768da21e3eee11045954a39fba983539dcb51b",
4
+ "sha256": "96c37dedbb04b1a6a1ad46cb3c586dfca48336064cb007c2ee06424d2cec3f96",
5
5
  "artifacts": {
6
6
  "iife": "hyperframe.runtime.iife.js",
7
7
  "esm": "hyperframe.runtime.mjs"