alpha2 0.4.6 → 0.5.1

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 (123) hide show
  1. package/README.md +5 -4
  2. package/THIRD_PARTY_NOTICES.md +4 -0
  3. package/dist/abort.d.ts +12 -0
  4. package/dist/abort.js +48 -0
  5. package/dist/active-clock.d.ts +35 -0
  6. package/dist/active-clock.js +99 -0
  7. package/dist/assets.d.ts +51 -22
  8. package/dist/assets.js +8 -12
  9. package/dist/audio-layout.d.ts +52 -74
  10. package/dist/audio-layout.js +114 -148
  11. package/dist/audio-timeline.d.ts +89 -117
  12. package/dist/audio-timeline.js +102 -118
  13. package/dist/audio-worker.d.ts +12 -21
  14. package/dist/audio-worker.js +8 -13
  15. package/dist/audio-worklet-processor.js +45 -58
  16. package/dist/audio-worklet.d.ts +45 -76
  17. package/dist/audio-worklet.js +44 -79
  18. package/dist/audio.d.ts +15 -23
  19. package/dist/audio.js +9 -13
  20. package/dist/builder.d.ts +45 -63
  21. package/dist/builder.js +49 -45
  22. package/dist/capabilities.d.ts +99 -16
  23. package/dist/capabilities.js +2 -2
  24. package/dist/captions.d.ts +45 -22
  25. package/dist/captions.js +60 -15
  26. package/dist/chroma-siting.d.ts +24 -41
  27. package/dist/chroma-siting.js +38 -71
  28. package/dist/containers.d.ts +41 -30
  29. package/dist/containers.js +59 -27
  30. package/dist/decoder-fallback.d.ts +13 -0
  31. package/dist/decoder-fallback.js +38 -0
  32. package/dist/decoder-order.d.ts +24 -39
  33. package/dist/decoder-order.js +28 -42
  34. package/dist/edit.d.ts +77 -154
  35. package/dist/edit.js +98 -180
  36. package/dist/effects.d.ts +125 -176
  37. package/dist/effects.js +7 -9
  38. package/dist/export-destination.d.ts +25 -41
  39. package/dist/export-destination.js +20 -32
  40. package/dist/export-failure.d.ts +34 -59
  41. package/dist/export-failure.js +54 -48
  42. package/dist/export-metrics.d.ts +116 -0
  43. package/dist/export-metrics.js +74 -0
  44. package/dist/export-retry.d.ts +46 -29
  45. package/dist/export-retry.js +86 -51
  46. package/dist/exporter.d.ts +67 -116
  47. package/dist/exporter.js +133 -133
  48. package/dist/extensions.d.ts +69 -115
  49. package/dist/extensions.js +55 -82
  50. package/dist/frame-intake.d.ts +92 -0
  51. package/dist/frame-intake.js +114 -0
  52. package/dist/frame-supply.d.ts +96 -162
  53. package/dist/frame-supply.js +181 -171
  54. package/dist/frames.d.ts +23 -0
  55. package/dist/frames.js +34 -0
  56. package/dist/generated/project-schema.d.ts +712 -485
  57. package/dist/generated/project-schema.js +55 -2
  58. package/dist/generated/project-shape.js +276 -16
  59. package/dist/geometry.d.ts +28 -34
  60. package/dist/geometry.js +18 -23
  61. package/dist/gpu-recovery.d.ts +92 -0
  62. package/dist/gpu-recovery.js +135 -0
  63. package/dist/hdr-frames.d.ts +82 -67
  64. package/dist/hdr-frames.js +112 -49
  65. package/dist/index.d.ts +6 -0
  66. package/dist/index.js +6 -0
  67. package/dist/json-text.d.ts +13 -23
  68. package/dist/json-text.js +10 -20
  69. package/dist/layout-values.d.ts +14 -22
  70. package/dist/layout-values.js +18 -21
  71. package/dist/layout.d.ts +48 -63
  72. package/dist/layout.js +37 -37
  73. package/dist/loudness.d.ts +27 -32
  74. package/dist/loudness.js +19 -23
  75. package/dist/media.d.ts +85 -237
  76. package/dist/media.js +133 -287
  77. package/dist/mediabunny.d.ts +178 -246
  78. package/dist/mediabunny.js +781 -583
  79. package/dist/paint.d.ts +23 -0
  80. package/dist/paint.js +37 -0
  81. package/dist/physical-frames.d.ts +5 -17
  82. package/dist/physical-frames.js +4 -11
  83. package/dist/player.d.ts +56 -47
  84. package/dist/player.js +155 -40
  85. package/dist/presented-frames.d.ts +2 -7
  86. package/dist/presented-frames.js +3 -8
  87. package/dist/project.d.ts +74 -118
  88. package/dist/project.js +384 -445
  89. package/dist/rate-control.d.ts +9 -23
  90. package/dist/rate-control.js +7 -18
  91. package/dist/renderer-choice.d.ts +41 -0
  92. package/dist/renderer-choice.js +82 -0
  93. package/dist/repacked-bytes.d.ts +0 -2
  94. package/dist/repacked-bytes.js +2 -5
  95. package/dist/robustness.d.ts +25 -37
  96. package/dist/robustness.js +71 -54
  97. package/dist/sha256.d.ts +5 -13
  98. package/dist/sha256.js +9 -24
  99. package/dist/text.d.ts +97 -71
  100. package/dist/text.js +33 -70
  101. package/dist/video-frames.d.ts +7 -25
  102. package/dist/video-frames.js +12 -29
  103. package/dist/waveform.d.ts +5 -11
  104. package/dist/waveform.js +4 -9
  105. package/dist/worker-error.d.ts +5 -20
  106. package/dist/worker-error.js +8 -25
  107. package/dist/worker.d.ts +82 -95
  108. package/dist/worker.js +235 -143
  109. package/package.json +26 -2
  110. package/wasm/alpha2_audio_worklet.wasm +0 -0
  111. package/wasm/alpha2_extensions.d.ts +26 -47
  112. package/wasm/alpha2_extensions.js +26 -47
  113. package/wasm/alpha2_extensions_bg.wasm +0 -0
  114. package/wasm/alpha2_wasm.d.ts +501 -587
  115. package/wasm/alpha2_wasm.js +661 -616
  116. package/wasm/alpha2_wasm_bg.wasm +0 -0
  117. package/wasm/alpha2_wasm_bg.wasm.d.ts +22 -12
  118. package/wasm/rust-crate-licenses.md +2 -2
  119. package/wasm/snippets/{alpha2-wasm-c62e60c964e88a52 → alpha2-wasm-070d94113471ef0a}/inline1.js +1 -0
  120. package/wasm/snippets/alpha2-wasm-070d94113471ef0a/inline2.js +82 -0
  121. package/wasm/snippets/alpha2-wasm-c62e60c964e88a52/inline2.js +0 -52
  122. /package/wasm/snippets/{alpha2-wasm-c62e60c964e88a52 → alpha2-wasm-070d94113471ef0a}/inline0.js +0 -0
  123. /package/wasm/snippets/{alpha2-wasm-c62e60c964e88a52 → alpha2-wasm-070d94113471ef0a}/inline3.js +0 -0
package/dist/effects.d.ts CHANGED
@@ -5,16 +5,16 @@ import type { EngineVideoCodec } from "./rate-control.js";
5
5
  /** An effect filters one input; a transition blends two. */
6
6
  export type EffectKind = "effect" | "transition";
7
7
  /**
8
- * GPU capability tier: `a` is a full WebGPU-capable adapter, `b` a conservative downlevel one. An
9
- * effect whose `tierMin` is `a` does not compile on a tier `b` adapter.
8
+ * GPU tier: `a` is a full `WebGPU` adapter, `b` a downlevel one. Effects with `tierMin: "a"` do not
9
+ * compile on tier `b`.
10
10
  */
11
11
  export type CapabilityTier = "a" | "b";
12
- /** A resource an effect reads, by the name its shader binds it under. */
12
+ /** A resource an effect reads; `name` is its shader binding name. */
13
13
  export interface EffectResourceSpec {
14
14
  readonly name: string;
15
15
  readonly kind: EffectResourceKind;
16
16
  }
17
- /** An image an effect samples besides its source; an effect node binds it under `inputs.<name>`. */
17
+ /** An extra image an effect samples; an effect node binds it under `inputs.<name>`. */
18
18
  export interface EffectInputSpec {
19
19
  readonly name: string;
20
20
  }
@@ -36,10 +36,7 @@ export interface BuiltinEffectCatalogEntry {
36
36
  readonly params: readonly (EffectParameter & {
37
37
  readonly label: string;
38
38
  readonly step?: number;
39
- /**
40
- * Whether a project may keyframe this parameter with an interpolating curve. Enum and bool
41
- * keyframes only hold.
42
- */
39
+ /** Whether keyframes interpolate; enum and bool keyframes only hold. */
43
40
  readonly animatable: boolean;
44
41
  })[];
45
42
  readonly resources: readonly EffectResourceSpec[];
@@ -68,10 +65,7 @@ export interface Vec2Parameter extends ParameterBase {
68
65
  readonly step?: number;
69
66
  readonly unit: "normalized";
70
67
  }
71
- /**
72
- * Four numbers that are not a color, such as per-channel thresholds; they keyframe component by
73
- * component.
74
- */
68
+ /** Four non-color numbers, such as per-channel thresholds; keyframed per component. */
75
69
  export interface Vec4Parameter extends ParameterBase {
76
70
  readonly type: "vec4";
77
71
  readonly default: readonly [number, number, number, number];
@@ -80,7 +74,7 @@ export interface Vec4Parameter extends ParameterBase {
80
74
  readonly step?: number;
81
75
  readonly unit: "normalized";
82
76
  }
83
- /** A straight sRGB RGBA color in 0..1; keyframes interpolate premultiplied. */
77
+ /** Straight sRGB RGBA in 0..1; keyframes interpolate premultiplied. */
84
78
  export interface ColorParameter extends ParameterBase {
85
79
  readonly type: "color";
86
80
  readonly default: readonly [number, number, number, number];
@@ -105,66 +99,65 @@ export interface EffectDefinition {
105
99
  readonly version: number;
106
100
  readonly kind: EffectKind;
107
101
  /**
108
- * Images the effect samples besides its source, at most 8; only `kind: "effect"` declares them.
109
- * The shader reads each as `sample_<name>(uv) -> vec4f` (premultiplied, sRGB-encoded, clamped at
110
- * the edges, as `sample_src`) and `size_<name>() -> vec2f` (the bound texture's size in texels).
111
- * The wrapper declares `input_<name>`, `sample_<name>` and `size_<name>`, so a body must not.
102
+ * Up to 8 extra images, for `kind: "effect"` only. The shader reads each with
103
+ * `sample_<name>(uv) -> vec4f` (premultiplied, sRGB-encoded, edge-clamped like `sample_src`) and
104
+ * `size_<name>() -> vec2f` in texels. The body must not redeclare `input_<name>`, `sample_<name>`
105
+ * or `size_<name>`.
112
106
  */
113
107
  readonly inputs?: readonly EffectInputSpec[];
114
108
  readonly params?: readonly EffectParameter[];
115
109
  readonly resources?: readonly EffectResourceSpec[];
116
- /** WGSL the engine places into its effect shader; compile errors reject registration. */
110
+ /** WGSL inserted into the engine's effect shader; compile errors reject registration. */
117
111
  readonly wgslBody: string;
118
112
  readonly tierMin?: CapabilityTier;
119
113
  readonly license?: string;
120
114
  }
121
- /** An effect the binding compiled, waiting to be registered on it. */
115
+ /** A compiled effect awaiting registration. */
122
116
  export interface WasmCompiledEffect {
123
- /** The `id@version` it registers under. */
117
+ /** `id@version`. */
124
118
  readonly id: string;
125
119
  }
126
120
  /** Minimal shape of the generated wasm-bindgen class. */
127
121
  export interface WasmEffectRegistry {
128
122
  /**
129
- * Compiles one effect definition. The call returns once the shader and pipeline exist; the
130
- * promise settles when the browser's compiler answers, and holds nothing of the binding
131
- * meanwhile. It rejects with `EFFECT_ERROR` and the shader's diagnostics.
123
+ * Compiles one effect definition without holding the binding while the browser compiles.
124
+ * Rejects with `EFFECT_ERROR` and the shader's diagnostics. The CPU renderer only validates the
125
+ * definition, since it cannot draw runtime effects.
132
126
  */
133
127
  compileEffect(definitionJson: string): Promise<WasmCompiledEffect>;
134
- /**
135
- * Adds an effect this binding compiled and returns its `id@version`; `EFFECT_ERROR` for one
136
- * registered meanwhile.
137
- */
128
+ /** Returns `id@version`; throws `EFFECT_ERROR` if that id was registered meanwhile. */
138
129
  registerCompiledEffect(compiled: WasmCompiledEffect): string;
139
130
  unregisterEffect(id: string, version: number): boolean;
140
131
  clearEffects(): void;
132
+ /**
133
+ * Registered runtime effects the loaded project can draw, as `id@version`. On the CPU renderer
134
+ * any of them makes rendering and export fail with `EFFECT_ERROR`.
135
+ */
136
+ projectRuntimeEffects(): string[];
141
137
  builtinCatalog(): string;
142
138
  registerLut3d(id: string, cube: string): void;
143
139
  unregisterEffectResource(id: string): boolean;
144
140
  clearEffectResources(): void;
145
141
  }
146
- /**
147
- * What `renderAudio` does with a block that does not start where the previous one ended:
148
- * `"exact"` replays the settling history and mixes what a fresh renderer would;
149
- * `"continue-small-gaps"` (live preview only) continues across a step of at most `audioMaxBlock`
150
- * samples either way without a replay.
151
- */
142
+ /** See `WasmCanvasRenderer.setAudioContinuity`. */
152
143
  export type AudioContinuity = "exact" | "continue-small-gaps";
153
- /**
154
- * Generated wasm surface used by the concrete render-worker host: the GPU renderer
155
- * (`createForCanvas`) or the CPU one (`createCpu`), which answer the same calls.
156
- */
144
+ /** Generated wasm renderer surface, shared by the GPU and CPU renderers. */
157
145
  export interface WasmCanvasRenderer extends WasmEffectRegistry {
158
146
  /**
159
- * Which renderer draws: `"gpu"` (WebGPU or WebGL2) or `"cpu"` (the engine's CPU renderer in
160
- * wasm, which refuses runtime effects with `EFFECT_ERROR`). Absent means `"gpu"`.
147
+ * Absent means `"gpu"`. The CPU renderer registers runtime effects but refuses a project that
148
+ * draws one with `EFFECT_ERROR`.
161
149
  */
162
150
  readonly renderer?: "gpu" | "cpu";
151
+ /** Absent on the CPU renderer. */
152
+ readonly backend?: "webgpu" | "webgl2";
153
+ /** Browser-reported adapter name; may be empty. */
154
+ readonly adapter?: string;
163
155
  /**
164
- * Whether the GPU device is gone: a WebGPU device-lost callback, or a WebGL canvas's
165
- * `webglcontextlost` event. A lost renderer rejects export readbacks and must be recreated. The
166
- * CPU renderer is never lost.
156
+ * After a loss, JSON `{ hung, gpuMs, watchdogMs, timeTicks, frameIndex, effects }` with
157
+ * `timeTicks` as a decimal string; `undefined` before any loss and on the CPU renderer.
167
158
  */
159
+ readonly lossReport?: string;
160
+ /** A lost renderer rejects export readbacks and must be recreated. Never set on the CPU. */
168
161
  readonly deviceLost: boolean;
169
162
  readonly uploadedFrameCount: number;
170
163
  readonly uploadedFrameBytes: bigint;
@@ -172,187 +165,149 @@ export interface WasmCanvasRenderer extends WasmEffectRegistry {
172
165
  loadProject(projectJson: string): void;
173
166
  uploadVideoFrame(sourceId: string, mediaTimeTicks: bigint, frame: VideoFrame): FrameUploadReceipt;
174
167
  uploadPresentedVideoFrame(sourceId: string, mediaTimeTicks: bigint, frame: VideoFrame, outputWidth: number, outputHeight: number, rotationDegrees: number, mirror: boolean): FrameUploadReceipt;
175
- /** `"direct"`, `"bitmap"`, `"untried"`, or `"canvas"` (WebGL2): see `uploadPresentedVideoFrame`. */
168
+ /** `"direct"`, `"bitmap"`, `"untried"` or `"canvas"` (WebGL2). */
176
169
  readonly videoFrameCopy: string;
177
170
  /** `uploadPresentedVideoFrame` for a bitmap made with `premultiplyAlpha: "none"`. */
178
171
  uploadPresentedImageBitmap(sourceId: string, mediaTimeTicks: bigint, bitmap: ImageBitmap, outputWidth: number, outputHeight: number, rotationDegrees: number, mirror: boolean): FrameUploadReceipt;
179
172
  uploadRgbaFrame(sourceId: string, mediaTimeTicks: bigint, width: number, height: number, pixels: Uint8Array): FrameUploadReceipt;
180
- /**
181
- * Planar YUV (a WebCodecs format) converted with the project's color pipeline: how HDR frames
182
- * arrive, so the project, not the browser, decides how they are tone-mapped.
183
- */
173
+ /** Planar YUV converted with the project's color pipeline, which controls tone mapping. */
184
174
  uploadYuvFrame(sourceId: string, mediaTimeTicks: bigint, format: string, codedWidth: number, codedHeight: number, data: Uint8Array, layout: Uint32Array, visibleRect: Uint32Array,
185
- /**
186
- * Size the visible picture is shown at before it turns (a `VideoFrame`'s display size): its
187
- * pixel aspect ratio.
188
- */
175
+ /** Display size before rotation; carries the pixel aspect ratio. */
189
176
  displayWidth: number, displayHeight: number, colorJson: string, chromaSiting: ChromaSiting, outputWidth: number, outputHeight: number, rotationDegrees: number, mirror: boolean): FrameUploadReceipt;
190
177
  /** Whether the loaded project declares `sourceId` HDR. */
191
178
  hdrSource(sourceId: string): boolean;
192
- /** The color the loaded project declares for `sourceId`, as JSON. */
179
+ /** Project-declared color for `sourceId`, as JSON. */
193
180
  sourceColorMetadata(sourceId: string): string | undefined;
194
181
  uploadRgbaImage(sourceId: string, width: number, height: number, pixels: Uint8Array): FrameUploadReceipt;
195
182
  aliasVideoFrame(sourceId: string, existingMediaTimeTicks: bigint, requestedMediaTimeTicks: bigint): boolean;
196
183
  releaseFrame(sourceId: string, mediaTimeTicks: bigint): boolean;
197
184
  releaseFrameGeneration(generation: bigint): boolean;
198
- /**
199
- * Whether the still `sourceId` is still the upload `generation` names: the engine drops stills on
200
- * its own, by its byte budget and a count limit.
201
- */
185
+ /** Whether the still for `sourceId` is still upload `generation`; the engine may evict stills. */
202
186
  holdsImage(sourceId: string, generation: bigint): boolean;
203
- /** Releases the frames and still of one source whose media changed. */
187
+ /** Releases a source's frames and still, such as after its media changed. */
204
188
  releaseSourceFrames(sourceId: string): boolean;
205
189
  clearFrames(): void;
206
- /**
207
- * Releases one source's frames before a time on that source's own timeline; other sources keep
208
- * theirs.
209
- */
190
+ /** Releases one source's frames before a time in that source's media timeline. */
210
191
  trimFramesBefore(sourceId: string, mediaTimeTicks: bigint): void;
211
192
  readonly retiredFrameCount: number;
212
193
  /** JSON clip/source/timestamp needs; decoder cursors are scoped by clip ID. */
213
194
  frameNeeds(timeTicks: bigint): string;
214
195
  renderAt(timeTicks: bigint): string;
215
196
  /**
216
- * Project-rate planar audio upload. `startSample` is the source sample index of the first sample,
217
- * at the project rate. `layout` names the speaker each plane feeds, in plane order (a block's
218
- * `speakers`), or is a channel count for the count's default layout (`FFmpeg`'s: 3 is 2.1, 4 is
219
- * 4.0), for a source that declares none. The source's 1 to 24 planes are supplied end to end; the
220
- * engine folds them into the project's channels by speaker.
197
+ * Uploads project-rate planar audio; `startSample` is the source sample index of the first
198
+ * sample. `layout` is the speaker per plane, or a channel count for `FFmpeg`'s default layout
199
+ * (3 is 2.1, 4 is 4.0). The 1 to 24 planes are concatenated; the engine folds them into the
200
+ * project's channels by speaker.
221
201
  *
222
- * The mix reads a window only where it holds every sample a block needs; a sample the store does
223
- * not hold is audio that has not arrived, not silence. Upload zeros past a source's end, or pass
224
- * `endsSource` with an upload that runs to the source's end, such as a whole decoded source.
202
+ * Missing samples mean audio not yet arrived, not silence, so a mix needs every sample of its
203
+ * block. Upload zeros past a source's end, or pass `endsSource` when the upload reaches it.
225
204
  *
226
- * An upload replaces the windows it overlaps and joins the ones it meets. It throws
227
- * `RESOURCE_LIMIT` (not fatal) when no window can hold it (over 600 s, or over the store's 512
228
- * MiB) and `INVALID_INPUT` when it is malformed.
205
+ * An upload replaces overlapping windows and joins adjacent ones. Throws `RESOURCE_LIMIT` (not
206
+ * fatal) over 600 s or the store's 512 MiB, and `INVALID_INPUT` when malformed. `stream` is the
207
+ * audio stream an {@link audioNeeds} entry names, absent for the default one; each stream of a
208
+ * source is held apart.
229
209
  */
230
- uploadAudioBlock(sourceId: string, startSample: bigint, sampleRate: number, layout: number | readonly AudioSpeaker[], samples: Float32Array, endsSource?: boolean): void;
231
- /** The most samples per channel one {@link renderAudio} call mixes. */
210
+ uploadAudioBlock(sourceId: string, startSample: bigint, sampleRate: number, layout: number | readonly AudioSpeaker[], samples: Float32Array, endsSource?: boolean, stream?: number): void;
211
+ /** Maximum samples per channel per {@link renderAudio} call. */
232
212
  readonly audioMaxBlock: number;
233
213
  /**
234
- * Mixes one block of at most {@link audioMaxBlock} samples per channel and returns its channels
235
- * end to end. A longer block throws `INVALID_INPUT` (not fatal) naming the limit: mix it as
236
- * consecutive calls.
214
+ * Mixes up to {@link audioMaxBlock} samples per channel and returns the channels concatenated.
215
+ * A longer block throws `INVALID_INPUT` (not fatal).
237
216
  */
238
217
  renderAudio(startSample: bigint, frames: number, playing: boolean): Float32Array;
239
- /** JSON source intervals required before a sample window can be mixed. */
218
+ /**
219
+ * JSON `[{sourceId, stream?, startTicks, endTicks}]`: source intervals required before a sample
220
+ * window can be mixed. `stream` is set for clips playing another audio stream than the default
221
+ * one (`audio.stream`).
222
+ */
240
223
  audioNeeds(startSample: bigint, frames: number): string;
241
224
  /**
242
- * Starts (from empty) or stops measuring the mix before the master limiter, over the complete
243
- * blocks `renderAudio` renders from now on. Starting removes the normalization gain, so it
244
- * measures the mix as authored.
225
+ * Starts (from empty) or stops loudness metering before the master limiter. Starting resets the
226
+ * normalization gain so the mix is measured as authored.
245
227
  */
246
228
  setLoudnessMetering(enabled: boolean): void;
247
229
  /** JSON `LoudnessReport` (`alpha2/loudness`) since metering started, or `null`. */
248
230
  loudnessReport(): string;
249
- /**
250
- * Static gain before the master limiter, dB; zero removes it, and so does starting to meter. It
251
- * stays until it is set again.
252
- */
231
+ /** Static gain in dB before the master limiter; 0 removes it, as does starting metering. */
253
232
  setNormalizationGainDb(gainDb: number): void;
254
233
  /**
255
- * Appends an OpenType font to the fallback stack caption tracks and text generators draw with.
256
- * The same font files as the export host give identical text.
234
+ * Appends an OpenType font to the text fallback stack. The same fonts as the export host give
235
+ * identical text.
257
236
  */
258
237
  addFont(family: string, bytes: Uint8Array, faceIndex: number): void;
259
- /**
260
- * Appends every face of an OpenType font file, in the file's order: each weight of a collection
261
- * (`.ttc`), as the export host registers a font file.
262
- */
238
+ /** Appends every face of an OpenType file (including `.ttc` collections) in file order. */
263
239
  addFontFile(family: string, bytes: Uint8Array): void;
264
- /** Drops every font. */
265
240
  clearFonts(): void;
266
- /** JSON source ids the most recent renderAudio call could not mix. */
241
+ /** JSON source ids the last `renderAudio` call could not mix. */
267
242
  audioMissingSources(): string;
268
243
  audioChannels(): number;
269
244
  audioSampleRate(): number;
270
245
  audioRetainedFrames(): number;
271
246
  audioRetainedBytes(): number;
272
247
  /**
273
- * JSON `[{startSample, endSample}]`: one source's retained windows as half-open project-rate
274
- * sample intervals, most recently uploaded first.
248
+ * JSON `[{startSample, endSample}]` of the retained half-open windows of a source's `stream`
249
+ * (absent for the default one), newest first.
275
250
  */
276
- audioRetainedWindows(sourceId: string): string;
251
+ audioRetainedWindows(sourceId: string, stream?: number): string;
277
252
  releaseAudioSource(sourceId: string): boolean;
278
253
  clearAudioSources(): void;
279
254
  /**
280
- * Drops one source's audio that ends before a time on that source's own timeline; other sources
281
- * keep theirs. A host calls it as playback moves on, a few seconds behind the earliest time a mix
282
- * still reads of the source, so what the store holds stays seconds rather than every window
283
- * decoded since a seek.
255
+ * Drops one source's audio ending before a time in its media timeline. Call it during playback,
256
+ * a few seconds behind the earliest time still mixed, to bound memory.
284
257
  */
285
258
  trimAudioBefore(sourceId: string, ticks: bigint): void;
286
259
  resetAudio(): void;
287
260
  /**
288
- * Chooses what `renderAudio` does outside an export with a block that does not start where the
289
- * previous one ended. `"exact"` (the default) resets and replays up to 30 s of settling history,
290
- * so the block is what a fresh renderer mixes. `"continue-small-gaps"` is for live preview: a
291
- * step of at most {@link audioMaxBlock} samples either way continues from the state the last
292
- * block left at the cost of one block, and only a longer jump, or the first block after
293
- * {@link resetAudio}, replays. Loudness measurements and other output that must repeat stay
294
- * exact; from `beginExport` to `endExport` the renderer is exact whatever is chosen. Choosing
295
- * another policy resets the audio. Any other name throws `INVALID_INPUT` (not fatal).
261
+ * How `renderAudio` handles a block that does not continue the previous one, outside an export.
262
+ * `"exact"` (default) replays up to 30 s of settling history, matching a fresh renderer.
263
+ * `"continue-small-gaps"` (live preview) continues across steps of up to {@link audioMaxBlock}
264
+ * samples and replays only on larger jumps or after {@link resetAudio}. Exports are always
265
+ * exact. Changing the policy resets the audio; an unknown name throws `INVALID_INPUT`.
296
266
  */
297
267
  setAudioContinuity(policy: AudioContinuity): void;
298
268
  /**
299
- * Starts a deterministic export over a half-open timeline range.
300
- *
301
- * Export renders offscreen at the engine's export quality and never touches the presentation
302
- * surface, so its output does not depend on the canvas, its size, or the browser compositor. Pass
303
- * a zero rate to use the project's. Frames are packed for `codec`: their chroma sits where that
304
- * codec implies.
269
+ * Starts a deterministic offscreen export over a half-open timeline range. A zero rate uses the
270
+ * project's. Frames are packed with the chroma siting `codec` implies.
305
271
  *
306
- * Until `endExport`, an audio block with a missing source is silence and advances nothing, so
307
- * rendering it again once the source is uploaded continues exactly. `loadProject` ends the
308
- * export.
272
+ * Until `endExport`, an audio block with a missing source returns silence without advancing, so
273
+ * it can be rendered again after the upload. `loadProject` ends the export.
309
274
  */
310
275
  beginExport(startTicks: bigint, endTicks: bigint, rateNum: number, rateDen: number, codec: EngineVideoCodec): void;
311
276
  /** Renders the next export frame. Waiting never advances the cursor. */
312
277
  exportFrame(): Promise<ExportFrameResult>;
313
- /** Starts a frame and exposes its readback promise without awaiting it. */
314
278
  beginExportFrame(): ExportFrameTicket;
315
279
  /**
316
- * Starts one exact timestamp, packed for `codec`, and exposes its readback separately. It belongs
317
- * to no export, so neither its frame nor a readback failure carries a frame index: the caller
318
- * numbers it. An odd 4:2:0 size is refused with `INVALID_INPUT` naming the nearest even size,
319
- * before anything renders.
280
+ * Renders one timestamp outside any export, packed for `codec`; results carry no frame index.
281
+ * An odd 4:2:0 size throws `INVALID_INPUT`. `pixels` is an `FFmpeg` pixel format (`yuva420p`
282
+ * keeps alpha with no background, `yuv420p10le` is 10-bit); default I420.
320
283
  */
321
- beginExportAt(timeTicks: bigint, codec: EngineVideoCodec): ExportAtTicket;
284
+ beginExportAt(timeTicks: bigint, codec: EngineVideoCodec, pixels?: string): ExportAtTicket;
322
285
  /**
323
286
  * JSON `{ completed, total, effectiveRange: { startTicks, endTicks }, audioWindow: { startSample,
324
- * frames } }` for the running export. Ticks and `startSample` are decimal strings.
325
- * `effectiveRange` is the request widened to the frame grid; its start is the output's zero.
326
- * `audioWindow` is the project-rate samples the export's audio covers, from that range.
287
+ * frames } }`; ticks and `startSample` are decimal strings. See `Alpha2Exporter.effectiveRange`
288
+ * and `audioWindow`.
327
289
  */
328
290
  exportProgress(): string;
329
291
  endExport(): void;
330
292
  diagnostics?(): string;
331
- /**
332
- * Turns per-pass timing collection on or off. Off by default, because timing reads a clock per
333
- * pass and allocates GPU timestamp resources; every other diagnostic field is always available.
334
- */
293
+ /** Per-pass timing, off by default because it costs a clock read and GPU timestamp resources. */
335
294
  setPassTiming?(enabled: boolean): void;
336
295
  resizeSurface?(width: number, height: number): void;
337
296
  resetPlayer(): void;
338
297
  free?(): void;
339
298
  }
340
- /** One engine-owned source texture generation and its physical byte cost. */
299
+ /** An uploaded source texture generation and its byte cost. */
341
300
  export interface FrameUploadReceipt {
342
301
  readonly generation: bigint;
343
302
  readonly retainedBytes: number;
344
303
  }
345
- /**
346
- * A source frame a render needed and did not have, from the snapshot it rendered. A trimmed,
347
- * offset, or retimed clip needs its source at a time other than the timeline's, so this is what to
348
- * decode.
349
- */
304
+ /** A source frame a render needed but did not have; `mediaTimeTicks` is the time to decode. */
350
305
  export interface WasmMissingFrame {
351
306
  readonly clipId: string;
352
- /** The composition step that reads the source; `null` when the clip reads it itself. */
307
+ /** Composition step that reads the source; `null` when the clip reads it directly. */
353
308
  readonly readerId: string | null;
354
309
  readonly sourceId: string;
355
- /** Source time in ticks, as a decimal string so every i64 bit survives. */
310
+ /** Decimal string to preserve full i64 precision. */
356
311
  readonly mediaTimeTicks: string;
357
312
  }
358
313
  /** One step of an engine-owned export. */
@@ -369,26 +324,14 @@ export type ExportFrameResult = {
369
324
  readonly timeTicks: string;
370
325
  readonly width: number;
371
326
  readonly height: number;
372
- readonly format: "I420";
373
- /**
374
- * What the planes are coded as: the engine's export coding (BT.709, limited range), which a
375
- * `VideoFrame` built from them carries so the encoder tags it, as the native encoder does.
376
- */
327
+ readonly format: "I420" | "I420A" | "I420P10" | "I420AP10";
328
+ /** BT.709 limited range; pass it to the `VideoFrame` so the encoder tags the stream. */
377
329
  readonly colorSpace: VideoColorSpaceInit;
378
- /**
379
- * Where the Y, U, and V planes sit in `pixels`. Rows are padded, so read them through this,
380
- * as a `VideoFrame` given it as its `layout` does, never as if the planes were tightly
381
- * packed.
382
- */
383
- readonly layout: readonly [
384
- ExportPlaneLayout,
385
- ExportPlaneLayout,
386
- ExportPlaneLayout
387
- ];
388
- /** Planar I420 at the offsets and strides of `layout`. */
330
+ /** Plane offsets and strides in `pixels`. Rows may be padded. */
331
+ readonly layout: readonly ExportPlaneLayout[];
332
+ /** Y, U, V, then alpha, as described by `layout`. */
389
333
  readonly pixels: Uint8Array;
390
334
  };
391
- /** One plane of an exported frame: its first byte and its row pitch. */
392
335
  export interface ExportPlaneLayout {
393
336
  readonly offset: number;
394
337
  readonly stride: number;
@@ -405,20 +348,17 @@ export type ExportFrameTicket = {
405
348
  readonly kind: "rendered";
406
349
  readonly index: number;
407
350
  readonly timeTicks: string;
408
- /** GPU readback buffer bytes retained by this ticket. */
351
+ /** GPU readback bytes held by this ticket. */
409
352
  readonly retainedBytes: number;
410
353
  readonly readback: Promise<Extract<ExportFrameResult, {
411
354
  kind: "rendered";
412
355
  }>>;
413
356
  };
414
- /** A frame `beginExportAt` rendered: an export frame without an index. */
357
+ /** A frame rendered by `beginExportAt`. */
415
358
  export type ExportAtFrame = Omit<Extract<ExportFrameResult, {
416
359
  kind: "rendered";
417
360
  }>, "index">;
418
- /**
419
- * What `beginExportAt` answers: waiting for sources, or a frame whose GPU mapping can remain in
420
- * flight.
421
- */
361
+ /** Result of `beginExportAt`; a rendered frame's GPU mapping can remain in flight. */
422
362
  export type ExportAtTicket = {
423
363
  readonly kind: "waiting";
424
364
  readonly timeTicks: string;
@@ -427,50 +367,59 @@ export type ExportAtTicket = {
427
367
  } | {
428
368
  readonly kind: "rendered";
429
369
  readonly timeTicks: string;
430
- /** GPU readback buffer bytes retained by this ticket. */
370
+ /** GPU readback bytes held by this ticket. */
431
371
  readonly retainedBytes: number;
432
372
  readonly readback: Promise<ExportAtFrame>;
433
373
  };
374
+ /** Options for the binding's canvas constructors. */
375
+ export interface CanvasRendererOptions {
376
+ /**
377
+ * `"refuse"` rejects software adapters (fallback adapter, SwiftShader, llvmpipe, WARP) with
378
+ * `GPU_INIT_FAILED` before binding the canvas. Default `"allow"`.
379
+ */
380
+ readonly softwareAdapter?: "allow" | "refuse";
381
+ }
434
382
  /** Constructor shape injected by a browser host after loading wasm. */
435
383
  export interface WasmEffectRegistryBinding {
436
384
  create(): Promise<WasmEffectRegistry>;
437
- createForCanvas?(canvas: OffscreenCanvas): Promise<WasmCanvasRenderer>;
438
- createForHtmlCanvas?(canvas: HTMLCanvasElement): Promise<WasmCanvasRenderer>;
439
385
  /**
440
- * The renderer that draws on the CPU, for a browser with no WebGPU adapter and no WebGL2
441
- * context: it presents on `canvas`'s 2D context (nowhere without a canvas) and needs no GPU. It
442
- * throws `INVALID_INPUT` for a canvas that already holds a WebGL or WebGPU context.
386
+ * GPU renderer on `canvas` (WebGPU, else WebGL2). On WebGPU a rejection happens before the canvas
387
+ * is bound, leaving it free for the CPU renderer.
388
+ */
389
+ createForCanvas?(canvas: OffscreenCanvas, options?: CanvasRendererOptions): Promise<WasmCanvasRenderer>;
390
+ createForHtmlCanvas?(canvas: HTMLCanvasElement, options?: CanvasRendererOptions): Promise<WasmCanvasRenderer>;
391
+ /**
392
+ * CPU renderer presenting on `canvas`'s 2D context, for browsers with no GPU path. Throws
393
+ * `INVALID_INPUT` for a canvas that already holds a WebGL or WebGPU context.
443
394
  */
444
395
  createCpu?(canvas?: OffscreenCanvas | HTMLCanvasElement): WasmCanvasRenderer;
445
396
  }
446
- /** Typed adapter that keeps JSON serialization out of product integrations. */
397
+ /** Typed wrapper over the effect registry binding. */
447
398
  export declare class RuntimeEffectRegistry {
448
399
  #private;
449
400
  private constructor();
450
401
  /** Creates a registry on a new binding instance; rejects when the binding cannot be created. */
451
402
  static create(binding: WasmEffectRegistryBinding): Promise<RuntimeEffectRegistry>;
452
403
  /**
453
- * Compiles and registers one effect and resolves to its `id@version`. Registrations may overlap:
454
- * neither holds the binding while the browser compiles.
404
+ * Compiles and registers one effect, resolving to its `id@version`. Registrations may overlap.
455
405
  *
456
- * Rejects with `EFFECT_ERROR` and the shader's diagnostics when the definition does not compile,
457
- * or when the same `id@version` was registered while it compiled.
406
+ * Rejects with `EFFECT_ERROR` and the shader's diagnostics when it does not compile, or when the
407
+ * same `id@version` was registered meanwhile.
458
408
  */
459
409
  register(definition: EffectDefinition): Promise<string>;
460
410
  /** Removes a host-registered effect; `false` when none was registered under `id@version`. */
461
411
  unregister(id: string, version: number): boolean;
462
412
  /** Removes every host-registered effect; built-in effects stay. */
463
413
  clearHostEffects(): void;
464
- /** The engine's built-in effects and transitions with their authoring metadata. */
414
+ /** Built-in effects and transitions with authoring metadata. */
465
415
  builtinCatalog(): BuiltinEffectCatalog;
466
416
  /**
467
- * Registers a 3D LUT under `resource.id` for projects to reference. Throws when the `.cube` text
468
- * is invalid or its edge length does not fit the device; a failed registration changes nothing.
417
+ * Registers a 3D LUT under `resource.id`. Throws, changing nothing, when the `.cube` text is
418
+ * invalid or too large for the device.
469
419
  */
470
420
  registerResource(resource: EffectResourceData): void;
471
421
  /** Removes a registered resource; `false` when none had `id`. */
472
422
  unregisterResource(id: string): boolean;
473
- /** Removes every registered resource. */
474
423
  clearResources(): void;
475
424
  }
476
425
  export {};
package/dist/effects.js CHANGED
@@ -1,4 +1,4 @@
1
- /** Typed adapter that keeps JSON serialization out of product integrations. */
1
+ /** Typed wrapper over the effect registry binding. */
2
2
  export class RuntimeEffectRegistry {
3
3
  #wasm;
4
4
  constructor(wasm) {
@@ -9,11 +9,10 @@ export class RuntimeEffectRegistry {
9
9
  return new RuntimeEffectRegistry(await binding.create());
10
10
  }
11
11
  /**
12
- * Compiles and registers one effect and resolves to its `id@version`. Registrations may overlap:
13
- * neither holds the binding while the browser compiles.
12
+ * Compiles and registers one effect, resolving to its `id@version`. Registrations may overlap.
14
13
  *
15
- * Rejects with `EFFECT_ERROR` and the shader's diagnostics when the definition does not compile,
16
- * or when the same `id@version` was registered while it compiled.
14
+ * Rejects with `EFFECT_ERROR` and the shader's diagnostics when it does not compile, or when the
15
+ * same `id@version` was registered meanwhile.
17
16
  */
18
17
  async register(definition) {
19
18
  const compiled = await this.#wasm.compileEffect(JSON.stringify(definition));
@@ -27,13 +26,13 @@ export class RuntimeEffectRegistry {
27
26
  clearHostEffects() {
28
27
  this.#wasm.clearEffects();
29
28
  }
30
- /** The engine's built-in effects and transitions with their authoring metadata. */
29
+ /** Built-in effects and transitions with authoring metadata. */
31
30
  builtinCatalog() {
32
31
  return JSON.parse(this.#wasm.builtinCatalog());
33
32
  }
34
33
  /**
35
- * Registers a 3D LUT under `resource.id` for projects to reference. Throws when the `.cube` text
36
- * is invalid or its edge length does not fit the device; a failed registration changes nothing.
34
+ * Registers a 3D LUT under `resource.id`. Throws, changing nothing, when the `.cube` text is
35
+ * invalid or too large for the device.
37
36
  */
38
37
  registerResource(resource) {
39
38
  this.#wasm.registerLut3d(resource.id, resource.data);
@@ -42,7 +41,6 @@ export class RuntimeEffectRegistry {
42
41
  unregisterResource(id) {
43
42
  return this.#wasm.unregisterEffectResource(id);
44
43
  }
45
- /** Removes every registered resource. */
46
44
  clearResources() {
47
45
  this.#wasm.clearEffectResources();
48
46
  }