@hyperframes/engine 0.6.119 → 0.6.121

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.
Files changed (73) hide show
  1. package/package.json +24 -7
  2. package/scripts/generate-lut-reference.py +0 -168
  3. package/scripts/test-fitTextFontSize-browser.ts +0 -135
  4. package/src/cdp-headless-experimental.d.ts +0 -54
  5. package/src/config.test.ts +0 -213
  6. package/src/config.ts +0 -417
  7. package/src/index.ts +0 -273
  8. package/src/services/audioMixer.test.ts +0 -326
  9. package/src/services/audioMixer.ts +0 -604
  10. package/src/services/audioMixer.types.ts +0 -35
  11. package/src/services/audioVolumeEnvelope.test.ts +0 -176
  12. package/src/services/audioVolumeEnvelope.ts +0 -138
  13. package/src/services/browserManager.test.ts +0 -330
  14. package/src/services/browserManager.ts +0 -670
  15. package/src/services/chunkEncoder.test.ts +0 -1415
  16. package/src/services/chunkEncoder.ts +0 -831
  17. package/src/services/chunkEncoder.types.ts +0 -60
  18. package/src/services/extractionCache.test.ts +0 -199
  19. package/src/services/extractionCache.ts +0 -216
  20. package/src/services/fileServer.ts +0 -110
  21. package/src/services/frameCapture-discardWarmup.test.ts +0 -183
  22. package/src/services/frameCapture-namePolyfill.test.ts +0 -78
  23. package/src/services/frameCapture-pollImagesReady.test.ts +0 -153
  24. package/src/services/frameCapture-staticDedupIndex.test.ts +0 -76
  25. package/src/services/frameCapture-warmupTicks.test.ts +0 -174
  26. package/src/services/frameCapture.test.ts +0 -192
  27. package/src/services/frameCapture.ts +0 -1934
  28. package/src/services/hdrCapture.test.ts +0 -159
  29. package/src/services/hdrCapture.ts +0 -315
  30. package/src/services/parallelCoordinator.test.ts +0 -139
  31. package/src/services/parallelCoordinator.ts +0 -437
  32. package/src/services/screenshotService.test.ts +0 -510
  33. package/src/services/screenshotService.ts +0 -615
  34. package/src/services/streamingEncoder.test.ts +0 -832
  35. package/src/services/streamingEncoder.ts +0 -594
  36. package/src/services/systemMemory.test.ts +0 -324
  37. package/src/services/systemMemory.ts +0 -180
  38. package/src/services/videoFrameExtractor.test.ts +0 -1062
  39. package/src/services/videoFrameExtractor.ts +0 -1139
  40. package/src/services/videoFrameInjector.test.ts +0 -300
  41. package/src/services/videoFrameInjector.ts +0 -687
  42. package/src/services/vp9Options.ts +0 -13
  43. package/src/types.ts +0 -191
  44. package/src/utils/alphaBlit.test.ts +0 -1349
  45. package/src/utils/alphaBlit.ts +0 -1015
  46. package/src/utils/assertSwiftShader.test.ts +0 -130
  47. package/src/utils/assertSwiftShader.ts +0 -126
  48. package/src/utils/ffmpegBinaries.test.ts +0 -43
  49. package/src/utils/ffmpegBinaries.ts +0 -63
  50. package/src/utils/ffprobe.test.ts +0 -342
  51. package/src/utils/ffprobe.ts +0 -457
  52. package/src/utils/gpuEncoder.test.ts +0 -140
  53. package/src/utils/gpuEncoder.ts +0 -268
  54. package/src/utils/hdr.test.ts +0 -191
  55. package/src/utils/hdr.ts +0 -137
  56. package/src/utils/hdrCompositing.test.ts +0 -130
  57. package/src/utils/htmlTemplate.test.ts +0 -42
  58. package/src/utils/htmlTemplate.ts +0 -42
  59. package/src/utils/layerCompositor.test.ts +0 -150
  60. package/src/utils/layerCompositor.ts +0 -58
  61. package/src/utils/parityContract.ts +0 -1
  62. package/src/utils/processTracker.test.ts +0 -74
  63. package/src/utils/processTracker.ts +0 -41
  64. package/src/utils/readWebGlVendorInfoFromCanvas.ts +0 -52
  65. package/src/utils/runFfmpeg.test.ts +0 -102
  66. package/src/utils/runFfmpeg.ts +0 -136
  67. package/src/utils/shaderTransitions.test.ts +0 -738
  68. package/src/utils/shaderTransitions.ts +0 -1130
  69. package/src/utils/uint16-alignment-audit.test.ts +0 -125
  70. package/src/utils/urlDownloader.test.ts +0 -65
  71. package/src/utils/urlDownloader.ts +0 -143
  72. package/tsconfig.json +0 -19
  73. package/vitest.config.ts +0 -7
package/src/types.ts DELETED
@@ -1,191 +0,0 @@
1
- /**
2
- * @hyperframes/engine — Protocol Types
3
- *
4
- * The engine's page contract. Any web page that wants to be rendered
5
- * as video must expose `window.__hf` implementing the HfProtocol interface.
6
- */
7
- import type { Fps } from "@hyperframes/core";
8
-
9
- // ── Seek Protocol ──────────────────────────────────────────────────────────────
10
-
11
- /**
12
- * Declares a media element the engine should handle.
13
- *
14
- * Headless Chrome in BeginFrame mode cannot play <video> or produce audio.
15
- * The engine pre-extracts video frames and audio tracks from declared media
16
- * elements and handles injection/mixing automatically.
17
- */
18
- export interface HfMediaElement {
19
- /** DOM id of the <video> or <audio> element */
20
- elementId: string;
21
- /** Source file path or URL */
22
- src: string;
23
- /** When in the composition this element appears (seconds) */
24
- startTime: number;
25
- /** When in the composition this element disappears (seconds) */
26
- endTime: number;
27
- /** Offset into the source file (seconds, default: 0) */
28
- mediaOffset?: number;
29
- /** Audio volume 0-1 (default: 1) */
30
- volume?: number;
31
- /** Whether this element has audio that should be extracted */
32
- hasAudio?: boolean;
33
- }
34
-
35
- /**
36
- * Metadata for a shader transition between two scenes.
37
- *
38
- * Compositions using @hyperframes/shader-transitions populate
39
- * `window.__hf.transitions` with one entry per transition so the
40
- * producer can pre-compute scene ranges, capture per-scene buffers,
41
- * and apply the transition in HDR-aware compositing.
42
- */
43
- export interface HfTransitionMeta {
44
- /** Time the transition starts (seconds) */
45
- time: number;
46
- /** Transition duration (seconds) */
47
- duration: number;
48
- /** Shader identifier. Undefined when the transition is a CSS crossfade. */
49
- shader?: string;
50
- /** GSAP easing string (e.g. "power2.inOut") */
51
- ease: string;
52
- /** Scene id the transition starts from */
53
- fromScene: string;
54
- /** Scene id the transition ends on */
55
- toScene: string;
56
- }
57
-
58
- /**
59
- * The seek protocol. The only contract between the engine and a page.
60
- *
61
- * The engine reads `duration` to calculate total frames, calls `seek(time)`
62
- * before each frame capture, and uses `media` (if provided) to handle
63
- * video frame injection and audio mixing.
64
- *
65
- * The engine does NOT care what animation framework drives the page.
66
- * GSAP, Framer Motion, CSS animations, Three.js — anything works as long
67
- * as `seek()` produces deterministic visual output for a given time.
68
- */
69
- export interface HfProtocol {
70
- /** Total duration of the composition in seconds */
71
- duration: number;
72
- /** Seek to a specific time. Must produce deterministic visual output. */
73
- seek(time: number): void;
74
- /** Optional: media elements the engine should handle */
75
- media?: HfMediaElement[];
76
- /** Optional: shader transition metadata, populated by @hyperframes/shader-transitions */
77
- transitions?: HfTransitionMeta[];
78
- }
79
-
80
- // ── Capture Types ──────────────────────────────────────────────────────────────
81
-
82
- export interface CaptureOptions {
83
- width: number;
84
- height: number;
85
- /**
86
- * Frame rate as an exact rational. Integer fps is `{ num: 30, den: 1 }`;
87
- * NTSC is `{ num: 30000, den: 1001 }`. Captures are scheduled by the
88
- * decimal interval (1000 * den / num ms) but FFmpeg arg builders emit the
89
- * rational form verbatim — see `fpsToFfmpegArg`.
90
- */
91
- fps: Fps;
92
- format?: "jpeg" | "png";
93
- quality?: number;
94
- deviceScaleFactor?: number;
95
- /**
96
- * FFmpeg-probed intrinsic dimensions for videos whose frames are injected
97
- * out-of-band. Applied before the readiness wait so layout that depends on
98
- * video aspect ratio (e.g. `height:auto`) stays stable even if Chromium never
99
- * loads native metadata.
100
- */
101
- videoMetadataHints?: readonly CaptureVideoMetadataHint[];
102
- /**
103
- * Video element IDs to exclude from the in-page readiness check that waits
104
- * for `video.readyState >= 1` before capture starts.
105
- *
106
- * Use for videos whose frames are supplied out-of-band, including standard
107
- * FFmpeg frame injection and native HDR extraction. Pair with
108
- * `videoMetadataHints` for any skipped video whose CSS layout may depend on
109
- * intrinsic media dimensions.
110
- */
111
- skipReadinessVideoIds?: readonly string[];
112
- /**
113
- * Render-time variable overrides for the composition. The engine injects
114
- * these as `window.__hfVariables` via `evaluateOnNewDocument` before any
115
- * page script runs, so the runtime helper `getVariables()` returns the
116
- * merged result of declared defaults (`data-composition-variables`) and
117
- * these overrides on its first call.
118
- *
119
- * The CLI populates this from `--variables '<json>'` /
120
- * `--variables-file <path>`. Must be a JSON-serializable plain object.
121
- */
122
- variables?: Record<string, unknown>;
123
- /**
124
- * When `true`, the BeginFrame warmup loop driven during page navigation
125
- * runs exactly `LOCKED_WARMUP_TICKS` (60) iterations regardless of how
126
- * long the page load takes, making `session.beginFrameTimeTicks`
127
- * deterministic across machines with different page-load latencies.
128
- *
129
- * Default `false`: wall-clock-bounded driver — ticks until page-readiness
130
- * completes, accumulating whatever count the host CPU manages. Preserves
131
- * the in-process renderer's BeginFrame timing baselines.
132
- *
133
- * Has no effect outside BeginFrame mode (screenshot capture never runs a
134
- * warmup loop).
135
- */
136
- lockWarmupTicks?: boolean;
137
- }
138
-
139
- export interface CaptureVideoMetadataHint {
140
- id: string;
141
- width: number;
142
- height: number;
143
- }
144
-
145
- export interface CaptureResult {
146
- frameIndex: number;
147
- time: number;
148
- path: string;
149
- captureTimeMs: number;
150
- }
151
-
152
- export interface CaptureBufferResult {
153
- buffer: Buffer;
154
- captureTimeMs: number;
155
- }
156
-
157
- export interface CapturePerfSummary {
158
- frames: number;
159
- avgTotalMs: number;
160
- avgSeekMs: number;
161
- avgBeforeCaptureMs: number;
162
- avgScreenshotMs: number;
163
- /**
164
- * Frames served from the static-dedup cache instead of a real seek+screenshot
165
- * (opt-out HF_STATIC_DEDUP=false). 0 when dedup was off or never armed. NOT counted
166
- * in `frames` (reuses are excluded so they don't dilute the per-frame
167
- * averages) — the captured total this session is `frames + staticDedupReused`.
168
- */
169
- staticDedupReused: number;
170
- /** `HF_STATIC_DEDUP=true` was set for this render (adoption signal). */
171
- staticDedupEnabled: boolean;
172
- /** Dedup passed every gate + verification and was active. */
173
- staticDedupArmed: boolean;
174
- /** Predicted reusable frame count when armed; 0 otherwise. */
175
- staticDedupPredicted: number;
176
- /**
177
- * Low-cardinality reason dedup did not arm: `capture_mode` | `video_injection`
178
- * | `page_composite` | `ineligible` | `verification_failed` | `verification_budget`.
179
- * Undefined when armed or when dedup was disabled. (Render-level aggregation may
180
- * `|`-join distinct reasons when parallel workers diverge.)
181
- */
182
- staticDedupSkipReason?: string;
183
- }
184
-
185
- // ── Global Augmentation ────────────────────────────────────────────────────────
186
-
187
- declare global {
188
- interface Window {
189
- __hf?: HfProtocol;
190
- }
191
- }