@hyperframes/producer 0.9.98 → 0.9.100

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
@@ -368,6 +368,7 @@ import { randomUUID as randomUUID3 } from "crypto";
368
368
  import { fileURLToPath as fileURLToPath5 } from "url";
369
369
 
370
370
  // src/services/fileServer.ts
371
+ import { referencedFontResponse } from "@hyperframes/share/referencedFont.mjs";
371
372
  import { Hono } from "hono";
372
373
  import { serve } from "@hono/node-server";
373
374
  import {
@@ -1202,6 +1203,8 @@ function createFileServer(options) {
1202
1203
  if (file) break;
1203
1204
  }
1204
1205
  if (!file) {
1206
+ const font = await referencedFontResponse(projectDir, new URL(c.req.url), c.req.raw.method);
1207
+ if (font) return font;
1205
1208
  if (!/favicon\.ico$/i.test(requestPath)) {
1206
1209
  console.warn(`[FileServer] 404 Not Found: ${terminalText2(boundedPageText(requestPath))}`);
1207
1210
  }
@@ -6506,7 +6509,7 @@ function segmentFramesDir(rootDir, index) {
6506
6509
  }
6507
6510
  function createSegmentVideoFrames(input) {
6508
6511
  const extractFrames = input.extractFrames ?? extractDeferredFrames;
6509
- const sourceOf = input.sourceOf ?? ((video) => video.srcPath);
6512
+ const sourceOf2 = input.sourceOf ?? ((video) => video.srcPath);
6510
6513
  const fullyExtracted = input.extracted.filter((video) => !video.deferredRange);
6511
6514
  const tableFor = async (frames, dir) => {
6512
6515
  const sliced = await extractFrames({
@@ -6517,7 +6520,7 @@ function createSegmentVideoFrames(input) {
6517
6520
  outputRoot: dir,
6518
6521
  cfg: input.cfg,
6519
6522
  signal: input.abortSignal,
6520
- sourceOf,
6523
+ sourceOf: sourceOf2,
6521
6524
  shownBoxes: input.shownBoxes,
6522
6525
  onMissingFrame: (video, index) => new Error(
6523
6526
  `[Render] video ${JSON.stringify(video.videoId)} has no frame ${index}; it was expected to have ${video.totalFrames} frames.`
@@ -7186,6 +7189,15 @@ import {
7186
7189
  } from "@hyperframes/engine";
7187
7190
  var SHORT_CLIP_ONE_FRAME_TOLERANCE_MIN_EXPECTED_FRAMES = 14;
7188
7191
  var SHORT_CLIP_ONE_FRAME_TOLERANCE_MAX_EXPECTED_FRAMES = 20;
7192
+ var s3 = (seconds) => seconds.toFixed(3);
7193
+ function sourceWords(report) {
7194
+ const s = report.source;
7195
+ if (!s) return "";
7196
+ const vfr = s.isVFR ? ", variable frame rate" : "";
7197
+ const lead = s.leadSeconds > 0 ? `, video from ${s3(s.leadSeconds)} s` : "";
7198
+ const speed = s.rate === "ramp" ? "on a speed ramp" : `at ${s.rate}x`;
7199
+ return `; source ${s.codec}, ${s.fps} fps${vfr}, plays to ${s3(s.playsTo)} s${lead}; clip ${s3(report.clipStart)}-${s3(report.clipEnd)} s reads source ${s3(s.readsFrom)}-${s3(s.readsTo)} s ${speed}`;
7200
+ }
7189
7201
  var VideoFrameCoverageError = class extends Error {
7190
7202
  // Read structurally by isVideoFrameCoverageError and cross-module callers.
7191
7203
  hyperframesVideoFrameCoverageError = true;
@@ -7232,6 +7244,19 @@ function expectedFramesForVideo(video, entry, fps) {
7232
7244
  const sourceFrames = expectedFramesForClip(0, sourceDuration, fps, rounding);
7233
7245
  return Math.min(slotFrames, sourceFrames);
7234
7246
  }
7247
+ function sourceOf(video, entry) {
7248
+ const rate = normalizeRateSpec(video.playbackRate);
7249
+ return {
7250
+ codec: entry.metadata.videoCodec,
7251
+ fps: entry.metadata.fps,
7252
+ isVFR: entry.metadata.isVFR,
7253
+ playsTo: resolvePlayableVideoDuration(entry.metadata),
7254
+ leadSeconds: entry.metadata.videoStreamLeadSeconds ?? 0,
7255
+ readsFrom: video.mediaStart,
7256
+ readsTo: video.mediaStart + sourceTimeAt(rate, Math.max(0, video.end - video.start)),
7257
+ rate: typeof rate === "number" ? rate : "ramp"
7258
+ };
7259
+ }
7235
7260
  function computeVideoFrameCoverage(videos, extracted, fps) {
7236
7261
  const byId = /* @__PURE__ */ new Map();
7237
7262
  for (const entry of extracted) byId.set(entry.videoId, entry);
@@ -7247,7 +7272,8 @@ function computeVideoFrameCoverage(videos, extracted, fps) {
7247
7272
  clipEnd: video.end,
7248
7273
  expectedFrames,
7249
7274
  capturedFrames,
7250
- ratio
7275
+ ratio,
7276
+ ...entry && { source: sourceOf(video, entry) }
7251
7277
  });
7252
7278
  }
7253
7279
  return reports;
@@ -7264,7 +7290,7 @@ function assertVideoFrameCoverage(reports, threshold) {
7264
7290
  const thresholdPct = (threshold * 100).toFixed(1);
7265
7291
  const suffix = sorted.length > 1 ? ` (+${sorted.length - 1} more clip(s) below threshold)` : "";
7266
7292
  throw new VideoFrameCoverageError(
7267
- `Video "${worst.videoId}" captured ${worst.capturedFrames} of expected ${worst.expectedFrames} frames (coverage ${pct}%, threshold ${thresholdPct}%). check/snapshot may pass while the encoded MP4 renders this clip blank, so the render is aborted to prevent shipping a wrong MP4.${suffix} Set HF_VIDEO_COVERAGE_THRESHOLD=0 to disable this gate.`,
7293
+ `Video "${worst.videoId}" captured ${worst.capturedFrames} of expected ${worst.expectedFrames} frames (coverage ${pct}%, threshold ${thresholdPct}%${sourceWords(worst)}). check/snapshot may pass while the encoded MP4 renders this clip blank, so the render is aborted to prevent shipping a wrong MP4.${suffix} Set HF_VIDEO_COVERAGE_THRESHOLD=0 to disable this gate.`,
7268
7294
  { threshold, worst, failedReports: sorted }
7269
7295
  );
7270
7296
  }
@@ -410,6 +410,7 @@ import { randomUUID as randomUUID3 } from "crypto";
410
410
  import { fileURLToPath as fileURLToPath5 } from "url";
411
411
 
412
412
  // src/services/fileServer.ts
413
+ import { referencedFontResponse } from "@hyperframes/share/referencedFont.mjs";
413
414
  import { Hono } from "hono";
414
415
  import { serve } from "@hono/node-server";
415
416
  import {
@@ -1244,6 +1245,8 @@ function createFileServer(options) {
1244
1245
  if (file) break;
1245
1246
  }
1246
1247
  if (!file) {
1248
+ const font = await referencedFontResponse(projectDir, new URL(c.req.url), c.req.raw.method);
1249
+ if (font) return font;
1247
1250
  if (!/favicon\.ico$/i.test(requestPath)) {
1248
1251
  console.warn(`[FileServer] 404 Not Found: ${terminalText2(boundedPageText(requestPath))}`);
1249
1252
  }
@@ -6544,7 +6547,7 @@ function segmentFramesDir(rootDir, index) {
6544
6547
  }
6545
6548
  function createSegmentVideoFrames(input) {
6546
6549
  const extractFrames = input.extractFrames ?? extractDeferredFrames;
6547
- const sourceOf = input.sourceOf ?? ((video) => video.srcPath);
6550
+ const sourceOf2 = input.sourceOf ?? ((video) => video.srcPath);
6548
6551
  const fullyExtracted = input.extracted.filter((video) => !video.deferredRange);
6549
6552
  const tableFor = async (frames, dir) => {
6550
6553
  const sliced = await extractFrames({
@@ -6555,7 +6558,7 @@ function createSegmentVideoFrames(input) {
6555
6558
  outputRoot: dir,
6556
6559
  cfg: input.cfg,
6557
6560
  signal: input.abortSignal,
6558
- sourceOf,
6561
+ sourceOf: sourceOf2,
6559
6562
  shownBoxes: input.shownBoxes,
6560
6563
  onMissingFrame: (video, index) => new Error(
6561
6564
  `[Render] video ${JSON.stringify(video.videoId)} has no frame ${index}; it was expected to have ${video.totalFrames} frames.`
@@ -7224,6 +7227,15 @@ import {
7224
7227
  } from "@hyperframes/engine";
7225
7228
  var SHORT_CLIP_ONE_FRAME_TOLERANCE_MIN_EXPECTED_FRAMES = 14;
7226
7229
  var SHORT_CLIP_ONE_FRAME_TOLERANCE_MAX_EXPECTED_FRAMES = 20;
7230
+ var s3 = (seconds) => seconds.toFixed(3);
7231
+ function sourceWords(report) {
7232
+ const s = report.source;
7233
+ if (!s) return "";
7234
+ const vfr = s.isVFR ? ", variable frame rate" : "";
7235
+ const lead = s.leadSeconds > 0 ? `, video from ${s3(s.leadSeconds)} s` : "";
7236
+ const speed = s.rate === "ramp" ? "on a speed ramp" : `at ${s.rate}x`;
7237
+ return `; source ${s.codec}, ${s.fps} fps${vfr}, plays to ${s3(s.playsTo)} s${lead}; clip ${s3(report.clipStart)}-${s3(report.clipEnd)} s reads source ${s3(s.readsFrom)}-${s3(s.readsTo)} s ${speed}`;
7238
+ }
7227
7239
  var VideoFrameCoverageError = class extends Error {
7228
7240
  // Read structurally by isVideoFrameCoverageError and cross-module callers.
7229
7241
  hyperframesVideoFrameCoverageError = true;
@@ -7270,6 +7282,19 @@ function expectedFramesForVideo(video, entry, fps) {
7270
7282
  const sourceFrames = expectedFramesForClip(0, sourceDuration, fps, rounding);
7271
7283
  return Math.min(slotFrames, sourceFrames);
7272
7284
  }
7285
+ function sourceOf(video, entry) {
7286
+ const rate = normalizeRateSpec(video.playbackRate);
7287
+ return {
7288
+ codec: entry.metadata.videoCodec,
7289
+ fps: entry.metadata.fps,
7290
+ isVFR: entry.metadata.isVFR,
7291
+ playsTo: resolvePlayableVideoDuration(entry.metadata),
7292
+ leadSeconds: entry.metadata.videoStreamLeadSeconds ?? 0,
7293
+ readsFrom: video.mediaStart,
7294
+ readsTo: video.mediaStart + sourceTimeAt(rate, Math.max(0, video.end - video.start)),
7295
+ rate: typeof rate === "number" ? rate : "ramp"
7296
+ };
7297
+ }
7273
7298
  function computeVideoFrameCoverage(videos, extracted, fps) {
7274
7299
  const byId = /* @__PURE__ */ new Map();
7275
7300
  for (const entry of extracted) byId.set(entry.videoId, entry);
@@ -7285,7 +7310,8 @@ function computeVideoFrameCoverage(videos, extracted, fps) {
7285
7310
  clipEnd: video.end,
7286
7311
  expectedFrames,
7287
7312
  capturedFrames,
7288
- ratio
7313
+ ratio,
7314
+ ...entry && { source: sourceOf(video, entry) }
7289
7315
  });
7290
7316
  }
7291
7317
  return reports;
@@ -7302,7 +7328,7 @@ function assertVideoFrameCoverage(reports, threshold) {
7302
7328
  const thresholdPct = (threshold * 100).toFixed(1);
7303
7329
  const suffix = sorted.length > 1 ? ` (+${sorted.length - 1} more clip(s) below threshold)` : "";
7304
7330
  throw new VideoFrameCoverageError(
7305
- `Video "${worst.videoId}" captured ${worst.capturedFrames} of expected ${worst.expectedFrames} frames (coverage ${pct}%, threshold ${thresholdPct}%). check/snapshot may pass while the encoded MP4 renders this clip blank, so the render is aborted to prevent shipping a wrong MP4.${suffix} Set HF_VIDEO_COVERAGE_THRESHOLD=0 to disable this gate.`,
7331
+ `Video "${worst.videoId}" captured ${worst.capturedFrames} of expected ${worst.expectedFrames} frames (coverage ${pct}%, threshold ${thresholdPct}%${sourceWords(worst)}). check/snapshot may pass while the encoded MP4 renders this clip blank, so the render is aborted to prevent shipping a wrong MP4.${suffix} Set HF_VIDEO_COVERAGE_THRESHOLD=0 to disable this gate.`,
7306
7332
  { threshold, worst, failedReports: sorted }
7307
7333
  );
7308
7334
  }
@@ -53,6 +53,21 @@ export interface VideoFrameCoverageReport {
53
53
  capturedFrames: number;
54
54
  /** `capturedFrames / expectedFrames`; `1` when `expectedFrames === 0` (nothing to cover). */
55
55
  ratio: number;
56
+ /** What the clip reads, when it was probed: the failure's message names it. */
57
+ source?: {
58
+ codec: string;
59
+ fps: number;
60
+ isVFR: boolean;
61
+ /** Where the video's last frame ends on the media timeline: the end the gate's expected frames stop at. */
62
+ playsTo: number;
63
+ /** Media time before the video's first frame, when the stream starts late. */
64
+ leadSeconds: number;
65
+ /** The span of source the clip's window reads, through its speed or ramp. */
66
+ readsFrom: number;
67
+ readsTo: number;
68
+ /** A number, or "ramp" when the speed changes over the clip. */
69
+ rate: number | "ramp";
70
+ };
56
71
  }
57
72
  /**
58
73
  * Discriminant-based error so callers cross-module (producer server,
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@hyperframes/producer",
3
- "version": "0.9.98",
3
+ "version": "0.9.100",
4
4
  "description": "HTML-to-video rendering engine using Chrome's BeginFrame API",
5
5
  "repository": {
6
6
  "type": "git",
@@ -35,11 +35,12 @@
35
35
  "postcss": "^8.4.0",
36
36
  "puppeteer": "~25.13.0",
37
37
  "puppeteer-core": "^25.13.0",
38
- "@hyperframes/core": "0.9.98",
39
- "@hyperframes/lint": "0.9.98",
40
- "@hyperframes/parsers": "0.9.98",
41
- "@hyperframes/studio-server": "0.9.98",
42
- "@hyperframes/engine": "0.9.98"
38
+ "@hyperframes/core": "0.9.100",
39
+ "@hyperframes/lint": "0.9.100",
40
+ "@hyperframes/parsers": "0.9.100",
41
+ "@hyperframes/engine": "0.9.100",
42
+ "@hyperframes/share": "0.9.100",
43
+ "@hyperframes/studio-server": "0.9.100"
43
44
  },
44
45
  "devDependencies": {
45
46
  "@types/node": "^25.0.10",
@@ -48,7 +49,7 @@
48
49
  "tsx": "^4.21.0",
49
50
  "typescript": "^5.7.2",
50
51
  "vitest": "^4.1.12",
51
- "@hyperframes/aws-lambda": "0.9.98"
52
+ "@hyperframes/aws-lambda": "0.9.100"
52
53
  },
53
54
  "engines": {
54
55
  "node": ">=22"