@hyperframes/producer 0.4.15 → 0.4.17

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.
@@ -0,0 +1,76 @@
1
+ /**
2
+ * Frame Directory Max-Index Cache
3
+ *
4
+ * Module-scoped cache of the maximum 1-based frame index present in each
5
+ * pre-extracted frame directory (e.g. `frame_0001.png … frame_0150.png` → 150).
6
+ * The directory is read once on first access and the max is computed by parsing
7
+ * filenames.
8
+ *
9
+ * Used by the render orchestrator to bounds-check `videoFrameIndex` against
10
+ * the directory size before calling `existsSync` per frame, which avoids
11
+ * redundant filesystem syscalls when the requested time falls past the last
12
+ * extracted frame (e.g. a clip shorter than the composition's effective video
13
+ * range).
14
+ *
15
+ * The cache is module-scoped on purpose: it must be shared across the many
16
+ * frame-capture call sites within a single render job. To prevent it from
17
+ * growing monotonically across jobs (Chunk 5B), callers MUST invoke
18
+ * `clearMaxFrameIndex(frameDir)` for every directory they registered, in their
19
+ * cleanup path. The render orchestrator does this in its outer `finally`.
20
+ *
21
+ * As defense in depth (PR #381 review feedback), the cache also enforces a
22
+ * hard MAX_ENTRIES cap with LRU eviction. The orchestrator's `finally`
23
+ * remains the primary boundedness mechanism; the LRU cap exists so that a
24
+ * future code path which forgets to call `clearMaxFrameIndex` cannot leak
25
+ * memory without bound — it self-limits to a working set ~100× larger than a
26
+ * single job needs.
27
+ *
28
+ * Lives in its own module (rather than as a private to renderOrchestrator.ts)
29
+ * so the cross-job isolation contract can be unit-tested directly.
30
+ */
31
+ /**
32
+ * Hard upper bound on cached entries. Sized at ~100× the working set of a
33
+ * single render job (which typically registers <10 frame directories, one
34
+ * per HDR video source) so that well-behaved callers never trip the cap.
35
+ *
36
+ * Worst-case resident size: 1000 × (~64-byte path string + ~24-byte map
37
+ * entry) ≈ 88 KB. Cheap insurance.
38
+ *
39
+ * Exported for observability and tests. Production code MUST NOT branch on
40
+ * this value to gate behavior — the cap is intentionally invisible to
41
+ * callers that follow the clearMaxFrameIndex contract.
42
+ */
43
+ export declare const MAX_ENTRIES = 1000;
44
+ /**
45
+ * Returns the maximum 1-based frame index found in `frameDir`, computed by
46
+ * parsing `frame_NNNN.png` filenames. Subsequent calls with the same path
47
+ * return the cached value without touching the filesystem. Returns 0 if the
48
+ * directory is missing, unreadable, or contains no frame files.
49
+ *
50
+ * On every access (hit or miss), the entry is bumped to most-recently-used so
51
+ * that the LRU-eviction path under cache pressure removes the entry that has
52
+ * been idle longest, not whichever one happened to be inserted earliest.
53
+ */
54
+ export declare function getMaxFrameIndex(frameDir: string): number;
55
+ /**
56
+ * Removes the cached max-index for a single directory. Called by the render
57
+ * orchestrator in its cleanup path so that subsequent jobs do not inherit
58
+ * stale entries (or worse, hold references to torn-down workDir paths).
59
+ *
60
+ * Returns `true` if an entry was removed, `false` if the path was not cached.
61
+ */
62
+ export declare function clearMaxFrameIndex(frameDir: string): boolean;
63
+ /**
64
+ * Returns the current number of cached entries. Intended for tests and
65
+ * diagnostic logging only — production code should not branch on this value.
66
+ */
67
+ export declare function getMaxFrameIndexCacheSize(): number;
68
+ /**
69
+ * Drops every cached entry. Intended exclusively for tests that need to
70
+ * reset module state between cases. Production code MUST use
71
+ * `clearMaxFrameIndex` for the directories it owns.
72
+ *
73
+ * @internal
74
+ */
75
+ export declare function __resetMaxFrameIndexCacheForTests(): void;
76
+ //# sourceMappingURL=frameDirCache.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"frameDirCache.d.ts","sourceRoot":"","sources":["../../src/services/frameDirCache.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;;;;;;;;;;;;;;;;;;;GA6BG;AAQH;;;;;;;;;;;GAWG;AACH,eAAO,MAAM,WAAW,OAAO,CAAC;AAEhC;;;;;;;;;GASG;AACH,wBAAgB,gBAAgB,CAAC,QAAQ,EAAE,MAAM,GAAG,MAAM,CAgCzD;AAED;;;;;;GAMG;AACH,wBAAgB,kBAAkB,CAAC,QAAQ,EAAE,MAAM,GAAG,OAAO,CAE5D;AAED;;;GAGG;AACH,wBAAgB,yBAAyB,IAAI,MAAM,CAElD;AAED;;;;;;GAMG;AACH,wBAAgB,iCAAiC,IAAI,IAAI,CAExD"}
@@ -56,6 +56,23 @@ export interface RenderPerfSummary {
56
56
  stages: Record<string, number>;
57
57
  captureAvgMs?: number;
58
58
  capturePeakMs?: number;
59
+ /**
60
+ * Peak resident set size (RSS) observed during the render, in MiB.
61
+ *
62
+ * Sampled every 250ms by a process-wide poller; surfaces gross memory
63
+ * regressions (e.g. unbounded image-cache growth) that wall-clock numbers
64
+ * miss. Optional because callers can serialize older `RenderPerfSummary`
65
+ * shapes back into this type.
66
+ */
67
+ peakRssMb?: number;
68
+ /**
69
+ * Peak V8 heap used observed during the render, in MiB.
70
+ *
71
+ * Useful as a finer-grained complement to {@link peakRssMb} — RSS includes
72
+ * native ffmpeg/Chrome allocations, while heapUsed isolates JS-object growth
73
+ * inside the orchestrator. Optional for the same back-compat reason.
74
+ */
75
+ peakHeapUsedMb?: number;
59
76
  hdrDiagnostics?: HdrDiagnostics;
60
77
  }
61
78
  export interface HdrDiagnostics {
@@ -1 +1 @@
1
- {"version":3,"file":"renderOrchestrator.d.ts","sourceRoot":"","sources":["../../src/services/renderOrchestrator.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;;;GAaG;AAaH,OAAO,EACL,KAAK,YAAY,EAIjB,KAAK,YAAY,EAoBjB,KAAK,YAAY,EACjB,KAAK,YAAY,EAiClB,MAAM,qBAAqB,CAAC;AAM7B,OAAO,EAKL,KAAK,mBAAmB,EACzB,MAAM,mBAAmB,CAAC;AAC3B,OAAO,EAAiB,KAAK,cAAc,EAAE,MAAM,cAAc,CAAC;AAkElE,MAAM,MAAM,YAAY,GACpB,QAAQ,GACR,eAAe,GACf,WAAW,GACX,UAAU,GACV,YAAY,GACZ,UAAU,GACV,QAAQ,GACR,WAAW,CAAC;AAEhB,MAAM,WAAW,YAAY;IAC3B,GAAG,EAAE,EAAE,GAAG,EAA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AC;AAEzE,qBAAa,oBAAqB,SAAQ,KAAK;IAC7C,MAAM,EAAE,gBAAgB,GAAG,SAAS,GAAG,SAAS,CAAC;gBAE/C,OAAO,GAAE,MAA2B,EACpC,MAAM,GAAE,gBAAgB,GAAG,SAAS,GAAG,SAAqB;CAM/D;AAED,MAAM,WAAW,mBAAmB;IAClC,QAAQ,EAAE,MAAM,CAAC;IACjB,MAAM,EAAE,YAAY,EAAE,CAAC;IACvB,MAAM,EAAE,YAAY,EAAE,CAAC;IACvB,MAAM,EAAE,YAAY,EAAE,CAAC;IACvB,KAAK,EAAE,MAAM,CAAC;IACd,MAAM,EAAE,MAAM,CAAC;CAChB;AAsDD;;GAEG;AAGH,wBAAgB,sBAAsB,CACpC,QAAQ,EAAE,mBAAmB,EAC7B,OAAO,EAAE,MAAM,EACf,cAAc,EAAE,OAAO,GACtB,IAAI,CAmDN;AAED,wBAAgB,oBAAoB,CAClC,GAAG,EAAE,YAAY,EACjB,QAAQ,EAAE,mBAAmB,EAC7B,GAAG,GAAE,cAA8B,GAClC,IAAI,CAQN;AAybD,wBAAgB,eAAe,CAAC,MAAM,EAAE,YAAY,GAAG,SAAS,CAS/D;AAMD;;GAEG;AAEH,wBAAgB,+BAA+B,CAC7C,SAAS,EAAE,MAAM,EACjB,SAAS,EAAE,MAAM,GAChB,MAAM,GAAG,IAAI,CAmCf;AAED,wBAAsB,gBAAgB,CACpC,GAAG,EAAE,SAAS,EACd,UAAU,EAAE,MAAM,EAClB,UAAU,EAAE,MAAM,EAClB,UAAU,CAAC,EAAE,gBAAgB,EAC7B,WAAW,CAAC,EAAE,WAAW,GACxB,OAAO,CAAC,IAAI,CAAC,CAwvDf"}
@@ -2,5 +2,5 @@
2
2
  * Re-exported from @hyperframes/engine.
3
3
  * @see engine/src/utils/ffprobe.ts for implementation.
4
4
  */
5
- export { extractVideoMetadata, extractAudioMetadata, type VideoMetadata, type AudioMetadata, } from "@hyperframes/engine";
5
+ export { extractMediaMetadata, extractVideoMetadata, extractAudioMetadata, type VideoMetadata, type AudioMetadata, } from "@hyperframes/engine";
6
6
  //# sourceMappingURL=ffprobe.d.ts.map
@@ -1 +1 @@
1
- {"version":3,"file":"ffprobe.d.ts","sourceRoot":"","sources":["../../src/utils/ffprobe.ts"],"names":[],"mappings":"AAAA;;;GAGG;AACH,OAAO,EACL,oBAAoB,EACpB,oBAAoB,EACpB,KAAK,aAAa,EAClB,KAAK,aAAa,GACnB,MAAM,qBAAqB,CAAC"}
1
+ {"version":3,"file":"ffprobe.d.ts","sourceRoot":"","sources":["../../src/utils/ffprobe.ts"],"names":[],"mappings":"AAAA;;;GAGG;AACH,OAAO,EACL,oBAAoB,EACpB,oBAAoB,EACpB,oBAAoB,EACpB,KAAK,aAAa,EAClB,KAAK,aAAa,GACnB,MAAM,qBAAqB,CAAC"}
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@hyperframes/producer",
3
- "version": "0.4.15",
3
+ "version": "0.4.17",
4
4
  "description": "HTML-to-video rendering engine using Chrome's BeginFrame API",
5
5
  "repository": {
6
6
  "type": "git",
@@ -44,8 +44,8 @@
44
44
  "postcss": "^8.4.0",
45
45
  "puppeteer": "^24.0.0",
46
46
  "puppeteer-core": "^24.39.1",
47
- "@hyperframes/core": "^0.4.15",
48
- "@hyperframes/engine": "^0.4.15"
47
+ "@hyperframes/core": "^0.4.17",
48
+ "@hyperframes/engine": "^0.4.17"
49
49
  },
50
50
  "devDependencies": {
51
51
  "@fontsource/lato": "^5.2.7",
@@ -75,6 +75,7 @@
75
75
  "perf:gate": "tsx src/perf-gate.ts",
76
76
  "check:runtime-conformance": "tsx src/runtime-conformance.ts",
77
77
  "benchmark": "tsx src/benchmark.ts",
78
+ "bench:hdr": "tsx src/benchmark.ts --tags hdr",
78
79
  "test": "tsx src/regression-harness.ts",
79
80
  "test:update": "tsx src/regression-harness.ts --update",
80
81
  "docker:build:test": "docker build -f ../../Dockerfile.test -t hyperframes-producer:test ../..",