@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.
@@ -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,7 +380,8 @@ 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
@@ -1162,13 +1163,13 @@ function createFileServer(options) {
1162
1163
  if (!streamOwnsFd) closeSync(fd);
1163
1164
  }
1164
1165
  });
1165
- return new Promise((resolve10, reject) => {
1166
+ return new Promise((resolve11, reject) => {
1166
1167
  const connections = /* @__PURE__ */ new Set();
1167
1168
  const server = serve({ fetch: app.fetch, port, hostname: "127.0.0.1" }, (info) => {
1168
1169
  const bound = port === 0 ? settleOnBrowserSafePort(server, "127.0.0.1") : Promise.resolve(info.port);
1169
1170
  bound.then((boundPort) => {
1170
1171
  listeningPort = boundPort;
1171
- resolve10({
1172
+ resolve11({
1172
1173
  url: `http://localhost:${boundPort}`,
1173
1174
  port: boundPort,
1174
1175
  addPreHeadScript: (script) => {
@@ -1657,6 +1658,7 @@ import {
1657
1658
  concatVideoFiles,
1658
1659
  createCaptureSession as createCaptureSession2,
1659
1660
  getCapturePerfSummary as getCapturePerfSummary2,
1661
+ retainCapturePerf as retainCapturePerf3,
1660
1662
  initializeSession as initializeSession2,
1661
1663
  prepareCaptureSessionForReuse as prepareCaptureSessionForReuse2,
1662
1664
  resolveDeVerifyMinDb as resolveDeVerifyMinDb2,
@@ -1669,10 +1671,10 @@ import { CaptureFailure, classifyCaptureFailure } from "@hyperframes/engine";
1669
1671
 
1670
1672
  // src/services/render/perfSummary.ts
1671
1673
  import { fpsToNumber as fpsToNumber2 } from "@hyperframes/core";
1672
- import { hostCpuCount } from "@hyperframes/engine";
1674
+ import { hostCpuCount, retainCapturePerf } from "@hyperframes/engine";
1673
1675
  function pushWorkerDedupPerfs(results, sink) {
1674
1676
  for (const r of results) {
1675
- if (r.perf) sink.push(r.perf);
1677
+ if (r.perf) retainCapturePerf(sink, r.perf);
1676
1678
  }
1677
1679
  }
1678
1680
  function pushWorkerPageErrors(results, sink) {
@@ -1781,6 +1783,7 @@ import {
1781
1783
  distributeFramesInterleaved,
1782
1784
  executeParallelCapture,
1783
1785
  getCapturePerfSummary,
1786
+ retainCapturePerf as retainCapturePerf2,
1784
1787
  psnrDb,
1785
1788
  resolveDeVerifyMinDb,
1786
1789
  recaptureDrawElementFrameForVerify,
@@ -1836,7 +1839,7 @@ var SequentialCaptureStallError = class extends Error {
1836
1839
  }
1837
1840
  };
1838
1841
  function raceAgainstStall(promise, deadlineMs, input, signal) {
1839
- return new Promise((resolve10, reject) => {
1842
+ return new Promise((resolve11, reject) => {
1840
1843
  const clock = createStallClock();
1841
1844
  const trip = () => reject(
1842
1845
  signal?.aborted ? new Error(
@@ -1861,7 +1864,7 @@ function raceAgainstStall(promise, deadlineMs, input, signal) {
1861
1864
  promise.then(
1862
1865
  (value) => {
1863
1866
  clearTimeout(timer);
1864
- resolve10(value);
1867
+ resolve11(value);
1865
1868
  },
1866
1869
  (error) => {
1867
1870
  clearTimeout(timer);
@@ -2460,7 +2463,7 @@ function requireOutputDimensions(expected, width, height) {
2460
2463
 
2461
2464
  // src/services/render/stages/compileStage.ts
2462
2465
  import { existsSync as existsSync9, writeFileSync as writeFileSync3 } from "node:fs";
2463
- import { join as join11, relative as relative4 } from "node:path";
2466
+ import { join as join11, relative as relative4, resolve as resolve7 } from "node:path";
2464
2467
  import { privateCacheRoot } from "@hyperframes/engine";
2465
2468
  import { suggestMatchingPreset } from "@hyperframes/core";
2466
2469
  import { extractStandaloneEntryFromIndex, isTemplateEntry } from "@hyperframes/core/compiler";
@@ -2469,6 +2472,7 @@ import { assertCompositionFileSize as assertCompositionFileSize2 } from "@hyperf
2469
2472
 
2470
2473
  // src/services/compileInWorker.ts
2471
2474
  import { existsSync as existsSync8, rmSync as rmSync4 } from "node:fs";
2475
+ import { ffmpegCwd } from "@hyperframes/parsers/ff-binaries";
2472
2476
  import { dirname as dirname8, isAbsolute as isAbsolute3, join as join10, relative as relative3, resolve as resolvePath } from "node:path";
2473
2477
  import { fileURLToPath as fileURLToPath3 } from "node:url";
2474
2478
  import { Worker } from "node:worker_threads";
@@ -2540,6 +2544,7 @@ import { gsapCdnDist, normalizeGsapBaseUrl } from "@hyperframes/core/gsap-cdn";
2540
2544
  import {
2541
2545
  assignBundledRuntimeCompositionIds,
2542
2546
  assignMediaRenderIds,
2547
+ dropAuthoredCompositionFiles,
2543
2548
  emitVariablesByCompScript,
2544
2549
  inlineSubCompositions as inlineSubCompositionsShared,
2545
2550
  ensureExternalLinkTag,
@@ -3197,10 +3202,10 @@ var Semaphore = class {
3197
3202
  this.active++;
3198
3203
  return () => this.release();
3199
3204
  }
3200
- return new Promise((resolve10) => {
3205
+ return new Promise((resolve11) => {
3201
3206
  this.queue.push(() => {
3202
3207
  this.active++;
3203
- resolve10(() => this.release());
3208
+ resolve11(() => this.release());
3204
3209
  });
3205
3210
  });
3206
3211
  }
@@ -4002,7 +4007,7 @@ var AssetDownloads = class {
4002
4007
  }
4003
4008
  async download(url, destDir) {
4004
4009
  while (this.running >= ASSET_DOWNLOADS_AT_ONCE) {
4005
- await new Promise((resolve10) => this.queued.push(resolve10));
4010
+ await new Promise((resolve11) => this.queued.push(resolve11));
4006
4011
  }
4007
4012
  if (this.signal?.aborted) {
4008
4013
  this.queued.shift()?.();
@@ -4391,6 +4396,7 @@ function coalesceHeadStylesAndBodyScripts(html) {
4391
4396
  }
4392
4397
  function inlineSubCompositions(html, subCompositions, projectDir, variableOverrides, assetRoot, outsideFiles, budget) {
4393
4398
  const { document: document2 } = parseHTML5(html);
4399
+ dropAuthoredCompositionFiles(document2);
4394
4400
  budget.chargeElements(ENTRY_PAGE, document2.querySelectorAll("*").length);
4395
4401
  const head = document2.querySelector("head");
4396
4402
  const body = document2.querySelector("body");
@@ -5918,9 +5924,15 @@ async function compileForRenderInWorker(projectDir, htmlPath, downloadDir, optio
5918
5924
  if (!entry) return compileForRender(projectDir, htmlPath, downloadDir, options);
5919
5925
  abortSignal?.throwIfAborted();
5920
5926
  const timeoutMs = worker.timeoutMs ?? compileTimeoutMs();
5921
- return new Promise((resolve10, reject) => {
5927
+ return new Promise((resolve11, reject) => {
5922
5928
  const thread = new Worker(entry, {
5923
- workerData: { projectDir, htmlPath, downloadDir, options: cloneable }
5929
+ workerData: {
5930
+ projectDir,
5931
+ htmlPath,
5932
+ downloadDir,
5933
+ options: cloneable,
5934
+ emptyFolder: ffmpegCwd() !== void 0
5935
+ }
5924
5936
  });
5925
5937
  const children = /* @__PURE__ */ new Map();
5926
5938
  const scratchRoots = [downloadDir, options.animatedGifCacheDir].flatMap(
@@ -5974,7 +5986,7 @@ async function compileForRenderInWorker(projectDir, htmlPath, downloadDir, optio
5974
5986
  log?.[message.level](message.message ?? "", message.meta);
5975
5987
  } else if (message.type === "result" && message.compiled) {
5976
5988
  const { compiled } = message;
5977
- settle(() => resolve10(compiled));
5989
+ settle(() => resolve11(compiled));
5978
5990
  retire(ADVISORY_GRACE_MS);
5979
5991
  } else if (message.type === "error" && message.error) {
5980
5992
  const { error } = message;
@@ -6006,7 +6018,7 @@ async function compileForRenderInWorker(projectDir, htmlPath, downloadDir, optio
6006
6018
  // src/services/render/stages/compileStage.ts
6007
6019
  function animatedGifCacheDir(extractCacheDir) {
6008
6020
  try {
6009
- const root = extractCacheDir && privateCacheRoot(extractCacheDir);
6021
+ const root = extractCacheDir && privateCacheRoot(resolve7(extractCacheDir));
6010
6022
  return root ? join11(root, "animated-gif") : void 0;
6011
6023
  } catch {
6012
6024
  return void 0;
@@ -7650,7 +7662,7 @@ import {
7650
7662
  } from "@hyperframes/engine";
7651
7663
 
7652
7664
  // src/services/render/audioPadTrim.ts
7653
- import { localContainerInputArgs } from "@hyperframes/parsers/ff-binaries";
7665
+ import { ffmpegCwd as ffmpegCwd2, localContainerInputArgs } from "@hyperframes/parsers/ff-binaries";
7654
7666
  import { spawn } from "node:child_process";
7655
7667
  import { dirname as dirname9, join as join14 } from "node:path";
7656
7668
  import {
@@ -8121,6 +8133,7 @@ async function spawnFfprobeJson(args, env, signal) {
8121
8133
  const proc = spawn(getFfprobeBinary(), args, {
8122
8134
  ...env && { env },
8123
8135
  stdio: ["ignore", "pipe", "pipe"],
8136
+ cwd: ffmpegCwd2(),
8124
8137
  windowsHide: true
8125
8138
  });
8126
8139
  trackChildProcess(proc);
@@ -8408,6 +8421,7 @@ import {
8408
8421
  completeDeferredDrawElementInit as completeDeferredDrawElementInit3,
8409
8422
  createCaptureSession as createCaptureSession5,
8410
8423
  getCapturePerfSummary as getCapturePerfSummary3,
8424
+ retainCapturePerf as retainCapturePerf4,
8411
8425
  initializeSession as initializeSession5,
8412
8426
  prepareCaptureSessionForReuse as prepareCaptureSessionForReuse3
8413
8427
  } from "@hyperframes/engine";
@@ -8750,7 +8764,7 @@ async function captureSessionFrames(session, { input, rangeStart, rangeEnd, resu
8750
8764
  },
8751
8765
  false
8752
8766
  );
8753
- dedupPerfs.push(getCapturePerfSummary3(session));
8767
+ retainCapturePerf4(dedupPerfs, getCapturePerfSummary3(session));
8754
8768
  }
8755
8769
 
8756
8770
  // src/services/render/stages/captureHdrStage.ts
@@ -9016,7 +9030,7 @@ function encodeWhileCapturing(input, totalFrames, captureBudget) {
9016
9030
  const stream = await encoder;
9017
9031
  for (let next = 0; next < totalFrames; next++) {
9018
9032
  while (!landed.has(next) && !captureDone && !signal.aborted) {
9019
- await new Promise((resolve10) => wake = resolve10);
9033
+ await new Promise((resolve11) => wake = resolve11);
9020
9034
  }
9021
9035
  if (signal.aborted) return;
9022
9036
  const mergedPath = join18(input.framesDir, formatCaptureFrameName(next, "jpg"));
@@ -10241,7 +10255,7 @@ async function readPlanReferenceBackground(input) {
10241
10255
 
10242
10256
  // src/services/render/stages/freezePlan.ts
10243
10257
  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";
10258
+ import { join as join24, relative as relative5, resolve as resolve9 } from "node:path";
10245
10259
  import {
10246
10260
  REFERENCE_BACKGROUND_FIELD,
10247
10261
  referenceBackgroundResult as referenceBackgroundResult3
@@ -10455,7 +10469,7 @@ function stripUndefined(value) {
10455
10469
  }
10456
10470
  function listPlanFiles(planDir) {
10457
10471
  const results = [];
10458
- const rootResolved = resolve8(planDir);
10472
+ const rootResolved = resolve9(planDir);
10459
10473
  function walk(dir) {
10460
10474
  const entries = readdirSync5(dir, { withFileTypes: true });
10461
10475
  for (const entry of entries) {
@@ -12262,7 +12276,7 @@ import {
12262
12276
  writeFileSync as writeFileSync10
12263
12277
  } from "node:fs";
12264
12278
  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";
12279
+ import { dirname as dirname16, isAbsolute as isAbsolute5, join as join31, relative as relative8, resolve as resolve10, sep as sep5 } from "node:path";
12266
12280
  import { DISTRIBUTED_FPS, isDistributedFps } from "@hyperframes/core";
12267
12281
  import {
12268
12282
  createFrameLookupTable as createFrameLookupTable5,
@@ -12421,7 +12435,7 @@ function assertSafeRelativePath(path) {
12421
12435
  }
12422
12436
  function listFiles(root) {
12423
12437
  const files = [];
12424
- const rootResolved = resolve9(root);
12438
+ const rootResolved = resolve10(root);
12425
12439
  function walk(dir) {
12426
12440
  for (const entry of readdirSync7(dir, { withFileTypes: true })) {
12427
12441
  const absolutePath = join31(dir, entry.name);
@@ -12467,8 +12481,8 @@ function isExtractionCacheCompleteSentinelPath(path) {
12467
12481
  return segments.length === 3 && segments[0] === "video-frames" && segments[1] !== "" && segments[2] === EXTRACTION_CACHE_COMPLETE_SENTINEL;
12468
12482
  }
12469
12483
  function resolveExtractedVideoOutputDir(planDir, videoId) {
12470
- const videoRoot = resolve9(planDir, "video-frames");
12471
- const outputDir = resolve9(videoRoot, mediaIdPathSegment4(videoId));
12484
+ const videoRoot = resolve10(planDir, "video-frames");
12485
+ const outputDir = resolve10(videoRoot, mediaIdPathSegment4(videoId));
12472
12486
  if (outputDir === videoRoot || !outputDir.startsWith(`${videoRoot}${sep5}`)) {
12473
12487
  throw new PlanV2IntegrityError(`unsafe extracted video id: ${JSON.stringify(videoId)}`);
12474
12488
  }
@@ -12629,7 +12643,7 @@ function collectChunkVideoDependencies(input) {
12629
12643
  for (let frame = chunk.startFrame; frame < chunk.endFrame; frame++) {
12630
12644
  const globalTime = frame * input.fpsDen / input.fpsNum;
12631
12645
  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("/");
12646
+ const path = input.deferredSources.get(videoId) ?? relative8(resolve10(input.executionPlanDir), payload.framePath).split(sep5).join("/");
12633
12647
  assertSafeRelativePath(path);
12634
12648
  const indexes = mutable.get(path) ?? /* @__PURE__ */ new Set();
12635
12649
  indexes.add(chunk.index);
@@ -13820,8 +13834,8 @@ async function renderChunk(planDir, chunkIndex, outputChunkPath, options) {
13820
13834
  const verifyInWorker = chunkWorkerCount > 1 && !forceScreenshotForChunk;
13821
13835
  let boxesMeasured;
13822
13836
  let boxesFailed;
13823
- const boxesReady = new Promise((resolve10, reject) => {
13824
- boxesMeasured = resolve10;
13837
+ const boxesReady = new Promise((resolve11, reject) => {
13838
+ boxesMeasured = resolve11;
13825
13839
  boxesFailed = reject;
13826
13840
  });
13827
13841
  boxesReady.catch(() => {
@@ -1,7 +1,7 @@
1
1
  {
2
2
  "version": "0.1.0",
3
3
  "buildId": "dev",
4
- "sha256": "874346801fcf8668e76936bb5e768da21e3eee11045954a39fba983539dcb51b",
4
+ "sha256": "0b99302d663728ad95650844ac9700edb5812e98ea415ffc91779b67b5066328",
5
5
  "artifacts": {
6
6
  "iife": "hyperframe.runtime.iife.js",
7
7
  "esm": "hyperframe.runtime.mjs"