@alpha2-sh/editor 0.4.5 → 0.5.0

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 (81) hide show
  1. package/dist/browser/bridge.d.ts +15 -16
  2. package/dist/browser/bridge.js +533 -387
  3. package/dist/browser/extensions-worker.d.ts +12 -16
  4. package/dist/browser/extensions-worker.js +17 -24
  5. package/dist/browser/hash-worker.d.ts +4 -5
  6. package/dist/browser/hash-worker.js +7 -8
  7. package/dist/browser/jobs.d.ts +17 -19
  8. package/dist/browser/jobs.js +41 -28
  9. package/dist/browser/resources.d.ts +6 -11
  10. package/dist/browser/resources.js +5 -9
  11. package/dist/browser/runtime/assets.d.ts +52 -31
  12. package/dist/browser/runtime/assets.js +206 -47
  13. package/dist/browser/runtime/audio.d.ts +16 -11
  14. package/dist/browser/runtime/audio.js +58 -31
  15. package/dist/browser/runtime/budget.d.ts +4 -5
  16. package/dist/browser/runtime/budget.js +4 -5
  17. package/dist/browser/runtime/caption-fonts.d.ts +3 -7
  18. package/dist/browser/runtime/caption-fonts.js +4 -8
  19. package/dist/browser/runtime/engine.d.ts +40 -43
  20. package/dist/browser/runtime/engine.js +82 -63
  21. package/dist/browser/runtime/export-audio.d.ts +6 -6
  22. package/dist/browser/runtime/export-audio.js +8 -9
  23. package/dist/browser/runtime/exporter.d.ts +33 -66
  24. package/dist/browser/runtime/exporter.js +111 -137
  25. package/dist/browser/runtime/extension-import.d.ts +28 -35
  26. package/dist/browser/runtime/extension-import.js +36 -46
  27. package/dist/browser/runtime/fingerprint.d.ts +11 -14
  28. package/dist/browser/runtime/fingerprint.js +20 -24
  29. package/dist/browser/runtime/generators.d.ts +2 -3
  30. package/dist/browser/runtime/generators.js +5 -7
  31. package/dist/browser/runtime/locks.d.ts +5 -7
  32. package/dist/browser/runtime/locks.js +5 -7
  33. package/dist/browser/runtime/output.d.ts +7 -9
  34. package/dist/browser/runtime/output.js +17 -21
  35. package/dist/browser/runtime/preview-utils.js +10 -6
  36. package/dist/browser/runtime/proxies.d.ts +10 -17
  37. package/dist/browser/runtime/proxies.js +33 -45
  38. package/dist/browser/runtime/proxy-storage.d.ts +15 -19
  39. package/dist/browser/runtime/proxy-storage.js +20 -24
  40. package/dist/browser/runtime/sources.d.ts +23 -31
  41. package/dist/browser/runtime/sources.js +98 -105
  42. package/dist/browser/runtime/staging.d.ts +2 -6
  43. package/dist/browser/runtime/staging.js +7 -11
  44. package/dist/browser/runtime/still.d.ts +2 -6
  45. package/dist/browser/runtime/still.js +6 -12
  46. package/dist/browser/runtime/text.d.ts +14 -0
  47. package/dist/browser/runtime/text.js +27 -0
  48. package/dist/browser/runtime/wasm.d.ts +4 -5
  49. package/dist/browser/runtime/wasm.js +4 -5
  50. package/dist/browser/types.d.ts +243 -221
  51. package/dist/browser/worker.d.ts +8 -9
  52. package/dist/browser/worker.js +55 -22
  53. package/dist/core/captions.d.ts +8 -10
  54. package/dist/core/captions.js +10 -18
  55. package/dist/core/clip-time.d.ts +8 -10
  56. package/dist/core/clip-time.js +12 -15
  57. package/dist/core/commands.d.ts +46 -46
  58. package/dist/core/commands.js +38 -36
  59. package/dist/core/compositions.d.ts +78 -112
  60. package/dist/core/compositions.js +66 -94
  61. package/dist/core/document.d.ts +59 -92
  62. package/dist/core/document.js +65 -90
  63. package/dist/core/keyframes.d.ts +11 -12
  64. package/dist/core/keyframes.js +11 -13
  65. package/dist/core/presets.d.ts +14 -20
  66. package/dist/core/presets.js +12 -18
  67. package/dist/core/session.d.ts +26 -38
  68. package/dist/core/session.js +38 -53
  69. package/dist/core/text.d.ts +2 -3
  70. package/dist/core/text.js +2 -3
  71. package/dist/core/timeline-index.d.ts +2 -3
  72. package/dist/core/timeline-index.js +11 -7
  73. package/dist/core/transitions.js +4 -5
  74. package/dist/core/validated.d.ts +6 -7
  75. package/dist/core/validated.js +8 -11
  76. package/dist/native-client/index.d.ts +31 -32
  77. package/dist/native-client/index.js +40 -41
  78. package/dist/ports/index.d.ts +19 -19
  79. package/dist/react/index.d.ts +5 -6
  80. package/dist/react/index.js +5 -6
  81. package/package.json +4 -4
@@ -1,8 +1,6 @@
1
1
  /**
2
- * Sources that contribute to the mix, paired with their browser-side asset.
3
- *
4
- * A video file with a sound track counts: it declares `has_audio`, so its clip on a video track is
5
- * mixed without a second clip on an audio lane.
2
+ * Sources that contribute to the mix, with their browser-side asset. A video file with a sound
3
+ * track declares `has_audio`, so its clip on a video track is mixed without a separate audio clip.
6
4
  */
7
5
  export function audibleSources(project: any, library: any): {
8
6
  id: any;
@@ -13,8 +11,8 @@ export function mixBlock(engine: any, startSample: any, frames: any, playing?: b
13
11
  /** Sources the most recent mix could not read, as reported by the engine. */
14
12
  export function missingAudioSources(engine: any): any;
15
13
  /**
16
- * The sample playback from `tick` starts at: the first one at or after it. The audio clock reports
17
- * the tick at or before the sample heard, so rounding to nearest could be heard a frame early.
14
+ * The first sample at or after `tick`. The audio clock reports the tick at or before the sample
15
+ * heard, so rounding to nearest could be heard a frame early.
18
16
  */
19
17
  export function playbackStartSample(tick: any, sampleRate: any): number;
20
18
  /**
@@ -35,19 +33,26 @@ export class AudioWindowSupplier {
35
33
  * thread; the worklet applies no second master chain.
36
34
  */
37
35
  export class EngineAudioMixer {
38
- constructor(runtimeAssets?: {}, { enabled }?: {
36
+ /**
37
+ * `onInterrupted` is called after the mixer stops because output stopped under playing audio
38
+ * (context suspended or interrupted by the system, as when another app takes the device).
39
+ */
40
+ constructor(runtimeAssets?: {}, { enabled, onInterrupted }?: {
39
41
  enabled?: boolean | undefined;
40
42
  });
41
43
  runtimeAssets: {};
42
44
  get tick(): number | null;
45
+ /** Where the playing clock's output latency comes from (`AudioLatencySource`), else null. */
46
+ get latencySource(): any;
47
+ /** Sets the A/V offset in milliseconds (positive shows the picture later), playing or not. */
48
+ setLatencyOffset(ms: any): void;
43
49
  volume: number;
44
50
  get supported(): boolean;
45
51
  get context(): null;
46
52
  /**
47
- * Associates a loaded project with the preview mixer. Safe to call again.
48
- *
49
- * Worklet creation is deferred to `resume()`: a suspended AudioContext may not construct an
50
- * AudioWorkletProcessor until a user gesture.
53
+ * Associates a loaded project with the preview mixer. Safe to call again. Worklet creation waits
54
+ * for `resume()`, since a suspended AudioContext may not construct an AudioWorkletProcessor
55
+ * before a user gesture.
51
56
  */
52
57
  attach(engine: any, project: any, supplier: any, onUnderrun: any, onError: any): Promise<boolean>;
53
58
  setMasterVolume(value: any): void;
@@ -9,14 +9,11 @@ import { MediabunnyAudioDecoder } from "alpha2/mediabunny";
9
9
  import * as engineBinding from "alpha2/wasm";
10
10
  const TICKS_PER_SECOND = 120000n;
11
11
  const PREFETCH_TICKS = 2n * TICKS_PER_SECOND;
12
- /** How much of a source is kept behind the earliest tick a mix still reads (backward prefetch). */
12
+ /** How much of a source is kept behind the earliest tick a mix reads (backward prefetch). */
13
13
  const KEEP_BEHIND_TICKS = PREFETCH_TICKS;
14
14
  /** How far that point moves forward before the source is trimmed again. */
15
15
  const TRIM_STEP_TICKS = PREFETCH_TICKS;
16
- /**
17
- * Sorts one source's needed tick ranges and joins the ones less than a prefetch apart, which are
18
- * cheaper to decode as one window than as two.
19
- */
16
+ /** Sorts a source's needed tick ranges, joining those closer than a prefetch into one window. */
20
17
  function coalesceRanges(ranges) {
21
18
  const sorted = [...ranges].sort((a, b) => a.start < b.start ? -1 : a.start > b.start ? 1 : 0);
22
19
  const merged = [];
@@ -36,10 +33,8 @@ function minBigInt(a, b) {
36
33
  return a < b ? a : b;
37
34
  }
38
35
  /**
39
- * Sources that contribute to the mix, paired with their browser-side asset.
40
- *
41
- * A video file with a sound track counts: it declares `has_audio`, so its clip on a video track is
42
- * mixed without a second clip on an audio lane.
36
+ * Sources that contribute to the mix, with their browser-side asset. A video file with a sound
37
+ * track declares `has_audio`, so its clip on a video track is mixed without a separate audio clip.
43
38
  */
44
39
  export function audibleSources(project, library) {
45
40
  const items = [];
@@ -65,7 +60,7 @@ export class AudioWindowSupplier {
65
60
  #decoders = new Map();
66
61
  /** Per source, the earliest tick the previous request needed. */
67
62
  #lastStarts = new Map();
68
- /** Per source, the tick the engine's audio was last trimmed below, or would have been. */
63
+ /** Per source, the tick the engine's audio was last trimmed below (or would have been). */
69
64
  #trimmed = new Map();
70
65
  /** The earliest tick each running `supply` needs, per source. */
71
66
  #inFlight = new Set();
@@ -121,7 +116,7 @@ export class AudioWindowSupplier {
121
116
  // and each prefetch stops short of the next request.
122
117
  await Promise.all([...bySource].map(async ([sourceId, ranges]) => {
123
118
  const requests = coalesceRanges(ranges);
124
- // A reversed clip or ping-pong backward pass reads backwards, so prefetch goes that way.
119
+ // Reversed clips and ping-pong backward passes read backwards, so prefetch goes that way.
125
120
  const previous = this.#lastStarts.get(sourceId);
126
121
  const backward = previous !== undefined &&
127
122
  requests[0].start < previous &&
@@ -156,8 +151,8 @@ export class AudioWindowSupplier {
156
151
  }
157
152
  }
158
153
  /**
159
- * Drops what the engine holds of `sourceId` well before `start`, stopping short of the earliest
160
- * tick any running mix needs. Runs once per `TRIM_STEP_TICKS` of progress; a seek back resets it.
154
+ * Drops what the engine holds of `sourceId` well before `start`, short of the earliest tick any
155
+ * running mix needs. Runs once per `TRIM_STEP_TICKS` of progress; seeking back resets it.
161
156
  */
162
157
  #trim(sourceId, start) {
163
158
  let floor = start;
@@ -183,7 +178,7 @@ export class AudioWindowSupplier {
183
178
  const engine = this.#engine;
184
179
  const requiredStart = Math.max(0, ticksToSampleFloor(startTicks, this.#sampleRate) - 2);
185
180
  const requiredEnd = ticksToSampleCeil(endTicks, this.#sampleRate) + 2;
186
- // Ask the engine what it holds: it extends, replaces and drops windows on its own terms.
181
+ // The engine extends, replaces and drops windows itself, so ask what it holds.
187
182
  if (!forced &&
188
183
  JSON.parse(engine.audioRetainedWindows(sourceId)).some((window) => window.startSample <= requiredStart &&
189
184
  window.endSample >= requiredEnd))
@@ -192,7 +187,7 @@ export class AudioWindowSupplier {
192
187
  if (!asset)
193
188
  throw new Error(`audio source ${sourceId} is unavailable`);
194
189
  if (asset.audioDecodable === false && !asset.audioBuffer) {
195
- // Undecodable here (`RuntimeAsset.audioDecodable`): silent, while the document keeps it.
190
+ // Undecodable here (`RuntimeAsset.audioDecodable`): silent, though the document keeps it.
196
191
  engine.uploadAudioBlock(sourceId, BigInt(requiredStart), this.#sampleRate, 1, new Float32Array(Math.max(1, requiredEnd - requiredStart)));
197
192
  return;
198
193
  }
@@ -221,7 +216,7 @@ export class AudioWindowSupplier {
221
216
  closeDecoder(entry.promise);
222
217
  entry = {
223
218
  file: asset.file,
224
- // The engine's own resampler, as on native; alpha2/wasm is loaded by the time this decodes.
219
+ // The engine's own resampler, as on native; alpha2/wasm is loaded by now.
225
220
  promise: MediabunnyAudioDecoder.open(sourceId, asset.file, engineBinding),
226
221
  };
227
222
  this.#decoders.set(sourceId, entry);
@@ -261,15 +256,33 @@ const PUMP_INTERVAL_MS = 40;
261
256
  * thread; the worklet applies no second master chain.
262
257
  */
263
258
  export class EngineAudioMixer {
264
- constructor(runtimeAssets = {}, { enabled = true } = {}) {
259
+ /**
260
+ * `onInterrupted` is called after the mixer stops because output stopped under playing audio
261
+ * (context suspended or interrupted by the system, as when another app takes the device).
262
+ */
263
+ constructor(runtimeAssets = {}, { enabled = true, onInterrupted } = {}) {
265
264
  this.runtimeAssets = runtimeAssets;
266
265
  this.#enabled = enabled;
266
+ this.#onInterrupted = onInterrupted ?? null;
267
267
  }
268
268
  #enabled = true;
269
269
  #clock = null;
270
+ #onInterrupted = null;
271
+ /** User A/V offset in milliseconds, for output delay the browser does not report. */
272
+ #offsetMs = 0;
270
273
  get tick() {
271
274
  return this.#clock ? Number(this.#clock.timelineTicks) : null;
272
275
  }
276
+ /** Where the playing clock's output latency comes from (`AudioLatencySource`), else null. */
277
+ get latencySource() {
278
+ return this.#clock?.latencySource ?? null;
279
+ }
280
+ /** Sets the A/V offset in milliseconds (positive shows the picture later), playing or not. */
281
+ setLatencyOffset(ms) {
282
+ this.#offsetMs = ms;
283
+ if (this.#clock)
284
+ this.#clock.latencyOffsetSeconds = ms / 1000;
285
+ }
273
286
  #context = null;
274
287
  #node = null;
275
288
  #setup = null;
@@ -291,10 +304,9 @@ export class EngineAudioMixer {
291
304
  return this.#context;
292
305
  }
293
306
  /**
294
- * Associates a loaded project with the preview mixer. Safe to call again.
295
- *
296
- * Worklet creation is deferred to `resume()`: a suspended AudioContext may not construct an
297
- * AudioWorkletProcessor until a user gesture.
307
+ * Associates a loaded project with the preview mixer. Safe to call again. Worklet creation waits
308
+ * for `resume()`, since a suspended AudioContext may not construct an AudioWorkletProcessor
309
+ * before a user gesture.
298
310
  */
299
311
  async attach(engine, project, supplier, onUnderrun, onError) {
300
312
  this.stop();
@@ -303,8 +315,8 @@ export class EngineAudioMixer {
303
315
  const sampleRate = project.settings.sample_rate;
304
316
  if (this.#context && this.#sampleRate !== sampleRate)
305
317
  await this.close();
306
- // Continue across a gap of a block or less instead of replaying effect history; seeks reset
307
- // and export is exact either way.
318
+ // Continue across gaps of a block or less instead of replaying effect history; seeks reset and
319
+ // export is exact either way.
308
320
  engine.setAudioContinuity("continue-small-gaps");
309
321
  this.#engine = engine;
310
322
  this.#supplier = supplier;
@@ -346,7 +358,7 @@ export class EngineAudioMixer {
346
358
  return this.#setup;
347
359
  const setup = this.#create(context);
348
360
  this.#setup = setup;
349
- // A rejected setup must be retryable on a later Play click, even if its caller was interrupted.
361
+ // A rejected setup must be retryable on a later Play, even if its caller was interrupted.
350
362
  void setup.catch(() => {
351
363
  if (this.#setup === setup)
352
364
  this.#setup = null;
@@ -360,7 +372,19 @@ export class EngineAudioMixer {
360
372
  if (!this.supported || !this.#engine)
361
373
  return;
362
374
  // Construct and resume before the first await to keep Play's user activation.
363
- const context = this.#context ?? new AudioContext({ sampleRate: this.#sampleRate });
375
+ let context = this.#context;
376
+ if (!context) {
377
+ context = new AudioContext({ sampleRate: this.#sampleRate });
378
+ context.addEventListener("statechange", () => {
379
+ // Only while playing; stopping clears the clock, so a stop reports once.
380
+ if (!this.#clock || this.#context !== context)
381
+ return;
382
+ if (context.state !== "suspended" && context.state !== "interrupted")
383
+ return;
384
+ this.stop();
385
+ this.#onInterrupted?.(context.state);
386
+ });
387
+ }
364
388
  this.#context = context;
365
389
  const resumed = context.state === "suspended" ? context.resume() : Promise.resolve();
366
390
  const setup = this.#node ? Promise.resolve() : this.#beginSetup(context);
@@ -374,7 +398,7 @@ export class EngineAudioMixer {
374
398
  return;
375
399
  if (!this.#node || !this.#ring || !this.#engine)
376
400
  return;
377
- // Playback rate is a preview-only concern; the engine always mixes at 1x.
401
+ // Playback rate is preview-only; the engine always mixes at 1x.
378
402
  if (rate !== 1) {
379
403
  this.stop();
380
404
  return;
@@ -397,7 +421,7 @@ export class EngineAudioMixer {
397
421
  await this.#pump.fill();
398
422
  }
399
423
  catch (error) {
400
- // A stop or close while the first block was decoding ends this start quietly.
424
+ // A stop or close during the first block's decode ends this start quietly.
401
425
  if (signal.aborted)
402
426
  return;
403
427
  throw error;
@@ -408,7 +432,10 @@ export class EngineAudioMixer {
408
432
  }
409
433
  if (signal.aborted)
410
434
  return;
411
- this.#clock = new AudioPlaybackClock(this.#pump, this.#ring, this.#context, Alpha2AudioWorkletHost.latency(this.#node));
435
+ this.#clock = new AudioPlaybackClock(this.#pump, this.#ring, this.#context, {
436
+ processing: Alpha2AudioWorkletHost.latency(this.#node),
437
+ latencyOffsetSeconds: this.#offsetMs / 1000,
438
+ });
412
439
  this.#timer = setInterval(() => {
413
440
  void this.#pump?.fill().catch((error) => {
414
441
  if (error?.name === "AbortError")
@@ -431,7 +458,7 @@ export class EngineAudioMixer {
431
458
  }
432
459
  async close() {
433
460
  this.stop();
434
- // Let any in-flight setup settle so it cannot resurrect a closed node.
461
+ // Let in-flight setup settle so it cannot resurrect a closed node.
435
462
  await this.#setup?.catch(() => { });
436
463
  this.#setup = null;
437
464
  if (this.#node)
@@ -506,8 +533,8 @@ function flattenPlanes(channels) {
506
533
  return flat;
507
534
  }
508
535
  /**
509
- * The sample playback from `tick` starts at: the first one at or after it. The audio clock reports
510
- * the tick at or before the sample heard, so rounding to nearest could be heard a frame early.
536
+ * The first sample at or after `tick`. The audio clock reports the tick at or before the sample
537
+ * heard, so rounding to nearest could be heard a frame early.
511
538
  */
512
539
  export function playbackStartSample(tick, sampleRate) {
513
540
  return ticksToSampleCeil(BigInt(Math.max(0, tick)), sampleRate);
@@ -1,11 +1,10 @@
1
1
  /**
2
- * The export options one attempt runs with: a retry that asks for less in flight scales the byte
3
- * budget by its profile, but never below one frame's working set, which would only turn the retry
4
- * into a refusal.
2
+ * The export options for one attempt. A retry scales the byte budget by its profile, but never
3
+ * below one frame's working set, which would only turn the retry into a refusal.
5
4
  */
6
5
  export function attemptOptions(options: any, attempt: any, settings: any): any;
7
6
  /**
8
- * Bytes of rendered frames an export keeps in flight unless asked otherwise: the SDK's
9
- * `maxInFlightBytes` default.
7
+ * Default bytes of rendered frames an export keeps in flight, matching the SDK's
8
+ * `maxInFlightBytes`.
10
9
  */
11
10
  export const DEFAULT_IN_FLIGHT_BYTES: number;
@@ -1,14 +1,13 @@
1
1
  // The browser export's byte budget, readable without loading the runtime.
2
2
  import { minimumExportWorkingSet } from "./staging.js";
3
3
  /**
4
- * Bytes of rendered frames an export keeps in flight unless asked otherwise: the SDK's
5
- * `maxInFlightBytes` default.
4
+ * Default bytes of rendered frames an export keeps in flight, matching the SDK's
5
+ * `maxInFlightBytes`.
6
6
  */
7
7
  export const DEFAULT_IN_FLIGHT_BYTES = 128 * 1024 * 1024;
8
8
  /**
9
- * The export options one attempt runs with: a retry that asks for less in flight scales the byte
10
- * budget by its profile, but never below one frame's working set, which would only turn the retry
11
- * into a refusal.
9
+ * The export options for one attempt. A retry scales the byte budget by its profile, but never
10
+ * below one frame's working set, which would only turn the retry into a refusal.
12
11
  */
13
12
  export function attemptOptions(options, attempt, settings) {
14
13
  const scale = attempt?.profile?.memoryScale ?? 1;
@@ -1,7 +1,7 @@
1
1
  /**
2
2
  * Replaces an engine registry's caption fonts with `fonts`, in order. A font the engine cannot
3
- * parse costs only itself: it is left out and every other font is still registered, the built-in
4
- * fallbacks among them. Returns what was left out, as `{ font, error }`, for the host to report.
3
+ * parse is left out and the rest, built-in fallbacks included, still register. Returns what was
4
+ * left out as `{ font, error }`.
5
5
  */
6
6
  export function registerCaptionFonts(registry: any, fonts: any): {
7
7
  font: any;
@@ -15,13 +15,9 @@ export class CaptionFonts {
15
15
  name: any;
16
16
  builtIn: any;
17
17
  }[];
18
- /** The fonts in fallback order, for an engine to register. */
19
18
  get stack(): any[];
20
19
  loadDefault(): Promise<void>;
21
- /**
22
- * Adds a font file ahead of the others, so it draws every glyph it has and the fonts after it
23
- * fill in the rest (a Korean font before DejaVu, say).
24
- */
20
+ /** Adds a font ahead of the others, so the fonts after it fill in glyphs it lacks. */
25
21
  add(file: any): Promise<{
26
22
  id: string;
27
23
  name: any;
@@ -1,5 +1,5 @@
1
1
  // Fonts caption tracks draw with, in fallback order. The engine rasterizes captions from these
2
- // files, so preview and every export draw the same pixels; fonts are not part of the document.
2
+ // files, so preview and every export draw the same pixels. Fonts are not part of the document.
3
3
  export class CaptionFonts {
4
4
  constructor(defaultFontUrl) {
5
5
  this.defaultFontUrl = defaultFontUrl;
@@ -10,7 +10,6 @@ export class CaptionFonts {
10
10
  get list() {
11
11
  return this.#fonts.map(({ id, name, builtIn }) => ({ id, name, builtIn }));
12
12
  }
13
- /** The fonts in fallback order, for an engine to register. */
14
13
  get stack() {
15
14
  return this.#fonts;
16
15
  }
@@ -28,10 +27,7 @@ export class CaptionFonts {
28
27
  builtIn: true,
29
28
  });
30
29
  }
31
- /**
32
- * Adds a font file ahead of the others, so it draws every glyph it has and the fonts after it
33
- * fill in the rest (a Korean font before DejaVu, say).
34
- */
30
+ /** Adds a font ahead of the others, so the fonts after it fill in glyphs it lacks. */
35
31
  async add(file) {
36
32
  const bytes = new Uint8Array(await file.arrayBuffer());
37
33
  const font = {
@@ -50,8 +46,8 @@ export class CaptionFonts {
50
46
  }
51
47
  /**
52
48
  * Replaces an engine registry's caption fonts with `fonts`, in order. A font the engine cannot
53
- * parse costs only itself: it is left out and every other font is still registered, the built-in
54
- * fallbacks among them. Returns what was left out, as `{ font, error }`, for the host to report.
49
+ * parse is left out and the rest, built-in fallbacks included, still register. Returns what was
50
+ * left out as `{ font, error }`.
55
51
  */
56
52
  export function registerCaptionFonts(registry, fonts) {
57
53
  registry.clearFonts();
@@ -3,10 +3,16 @@
3
3
  * render queue that collapses to the newest request.
4
4
  */
5
5
  export class Engine {
6
- constructor(canvas: any, sources: any, library: any, runtimeAssets?: {}, { unreadableFrames }?: {});
6
+ constructor(canvas: any, sources: any, library: any, runtimeAssets?: {}, { unreadableFrames, videoConversion, opaqueEngineFrames, renderer, }?: {
7
+ renderer?: string | undefined;
8
+ });
9
+ /** `"auto"` (hardware GPU, else CPU), `"gpu"` or `"cpu"`, as `createRenderer` takes them. */
10
+ renderer: string;
11
+ rendererChoice: import("alpha2/renderer-choice").RendererChoice | null;
7
12
  runtimeAssets: {};
8
- /** What the frame supply does with a frame the browser cannot read back (`FrameSupply`). */
9
13
  unreadableFrames: any;
14
+ videoConversion: any;
15
+ opaqueEngineFrames: any;
10
16
  canvas: any;
11
17
  sources: any;
12
18
  library: any;
@@ -24,61 +30,56 @@ export class Engine {
24
30
  }>;
25
31
  catalog: any;
26
32
  /**
27
- * Turns per-pass GPU and CPU timing on or off; the passes then appear in `lastDiagnostics`.
28
- * Off by default: timing is profiling cost, not rendering work.
33
+ * Turns per-pass GPU and CPU timing on or off (off by default); passes appear in
34
+ * `lastDiagnostics`.
29
35
  */
30
36
  setPassTiming(enabled: any): void;
31
37
  /**
32
- * Sets the preview resolution scale (the engine's `QualityProfile` resolution scale; 1 renders
33
- * at the document's size) and returns the loaded project's render size as `[width, height]`, or
34
- * null with no project loaded. Throws for a scale the engine refuses.
38
+ * Sets the preview resolution scale (1 renders at the document's size) and returns the loaded
39
+ * project's render size as `[width, height]`, or null with no project. Throws for a scale the
40
+ * engine refuses.
35
41
  */
36
42
  setPreviewScale(scale: any): any[] | null;
37
- /** The loaded project's render size at the preview scale, `[width, height]`, or null. */
38
43
  get previewSize(): any[] | null;
39
- /** The renderer's part of the capability report: GPU, color, and playback. */
44
+ /**
45
+ * The renderer's part of the capability report: GPU, color, playback, and `renderer` (which
46
+ * renderer draws and whether it runs runtime effects).
47
+ */
40
48
  capabilityReport(): any;
49
+ /** The `GpuLossReport` after a GPU loss; undefined before a loss and on the CPU renderer. */
50
+ lossReport(): import("alpha2/gpu-recovery").GpuLossReport | undefined;
41
51
  /** A clock for one run of playback; see the engine's `PlaybackPolicy`. */
42
52
  playbackClock(policy: any, frameRate: any, rate: any, tick: any, now: any): PlaybackClock;
43
- /** Whether sound plays under `policy` at `rate`. */
44
53
  audible(policy: any, rate: any): boolean;
45
54
  get ready(): boolean;
46
55
  get deviceLost(): any;
47
56
  /**
48
- * Raw source video the frame supply copied through script memory, and the frames it could not
49
- * read back and how it recovered them; cumulative.
57
+ * Cumulative: raw source video copied through script memory, and frames that could not be read
58
+ * back and how they were recovered.
50
59
  */
51
60
  get sourceTransfer(): any;
52
- /** The wasm object, for callers that drive audio directly. */
53
61
  get wasm(): null;
54
- /** Engine instance used by the realtime browser audio transport. */
55
62
  get audioEngine(): null;
56
- /** The project document most recently handed to the engine. */
57
63
  get project(): null;
58
64
  /**
59
- * Loads `project` into the engine and syncs its LUT resources with the library: those the project
60
- * draws (`drawnEffectResources`), the only ones a render asks for; a resource nothing drawn names
61
- * is neither required nor registered. Bumps the revision so in-flight renders for the old project
62
- * are dropped.
65
+ * Loads `project` and syncs its LUT resources with the library, registering only those the
66
+ * project draws (`drawnEffectResources`). Bumps the revision so in-flight renders for the old
67
+ * project are dropped.
63
68
  *
64
- * Throws `missing_asset` naming a drawn resource the library does not hold, and
65
- * `invalid_effect_resource` naming one the engine cannot parse; resources registered before the
66
- * failure stay known, so the next load neither leaks nor repeats them.
69
+ * Throws `missing_asset` for a drawn resource the library lacks and `invalid_effect_resource` for
70
+ * one the engine cannot parse. Resources registered before the failure stay known, so the next
71
+ * load neither leaks nor repeats them.
67
72
  */
68
73
  loadProject(project: any, operation?: string): void;
69
74
  /**
70
- * Compiles runtime effect definitions (`alpha2/effects` `EffectDefinition`s) on this renderer's
71
- * device and registers them, all or none. An `id@version` this renderer holds already is skipped:
72
- * a definition never changes under its version.
73
- *
74
- * Throws `invalid_effect` naming the first definition the engine refuses, with its diagnostics;
75
- * then none of the call's definitions is registered.
75
+ * Compiles runtime effect definitions on this renderer's device and registers them, all or none.
76
+ * An `id@version` already held is skipped, since a definition never changes under its version.
77
+ * Throws `invalid_effect` naming the first refused definition, with its diagnostics.
76
78
  */
77
79
  registerEffects(definitions: any, operation?: string): Promise<void>;
78
80
  /**
79
- * Registers the fonts caption tracks draw with, in fallback order. An SVG's text draws with the
80
- * same fonts, as the native host draws it with its caption fonts. Returns the fonts the engine
81
- * could not parse, as `{ font, error }`: they are left out, and the others draw.
81
+ * Registers caption fonts in fallback order; SVG text uses them too, as on the native host.
82
+ * Returns the fonts the engine could not parse as `{ font, error }`; those are left out.
82
83
  */
83
84
  setCaptionFonts(fonts: any): {
84
85
  font: any;
@@ -86,29 +87,25 @@ export class Engine {
86
87
  }[];
87
88
  resize(width: any, height: any): void;
88
89
  /**
89
- * Uploads the sources the engine needs at a timestamp without rendering.
90
- *
91
- * Export uses this: the engine owns its frame schedule, so the host only satisfies `frameNeeds`.
92
- * The uploads stay until `beginExportFrame` renders their frame; retired earlier, a frame whose
93
- * uploads outgrow the retained budget would evict its own first ones and wait forever.
90
+ * Uploads the sources the engine needs at a timestamp without rendering, for export, where the
91
+ * engine owns the frame schedule. Uploads stay until `beginExportFrame` renders their frame;
92
+ * retiring them earlier could make a frame evict its own first uploads and wait forever.
94
93
  */
95
94
  supply(seconds: any, { context }: {
96
95
  context: any;
97
96
  }): Promise<boolean>;
98
97
  /**
99
- * Renders the next export frame (see `beginExport` on the engine). Once a ticket is not
100
- * `waiting`, the engine has consumed what `supply` uploaded for it, so those uploads are retired
101
- * here.
98
+ * Renders the next export frame. Once a ticket is not `waiting`, the engine has consumed the
99
+ * frame's uploads, so they are retired here.
102
100
  */
103
101
  beginExportFrame(): any;
104
102
  /** Invalidates outstanding playback renders, for example on seek or pause. */
105
103
  invalidate(): number;
106
104
  get generation(): number;
107
105
  /**
108
- * Requests one frame. Concurrent requests collapse to the most recent one so that scrubbing never
109
- * queues a backlog of stale frames. Resolves `{ rendered, unchanged }`: `rendered` is false when
110
- * the request was superseded, and `unchanged` says the frame equals the one already shown, so
111
- * nothing was drawn or presented and the surface still shows it.
106
+ * Requests one frame. Concurrent requests collapse to the newest so scrubbing never queues stale
107
+ * frames. Resolves `{ rendered, unchanged }`: `rendered` is false when superseded, and
108
+ * `unchanged` means the frame equals the one shown, so nothing was drawn or presented.
112
109
  */
113
110
  render(seconds: any, { generation, context }?: {
114
111
  generation?: null | undefined;