@alpha2-sh/editor 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 (81) hide show
  1. package/dist/browser/bridge.d.ts +15 -16
  2. package/dist/browser/bridge.js +393 -312
  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 -28
  12. package/dist/browser/runtime/assets.js +136 -45
  13. package/dist/browser/runtime/audio.d.ts +16 -11
  14. package/dist/browser/runtime/audio.js +102 -59
  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 +44 -44
  20. package/dist/browser/runtime/engine.js +87 -64
  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 +19 -19
  37. package/dist/browser/runtime/proxies.js +72 -51
  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 +85 -103
  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 +244 -239
  51. package/dist/browser/worker.d.ts +10 -10
  52. package/dist/browser/worker.js +64 -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 -20
  79. package/dist/react/index.d.ts +5 -6
  80. package/dist/react/index.js +5 -6
  81. package/package.json +4 -4
@@ -1,44 +1,36 @@
1
1
  import type { Generator, MediaFingerprint, Project } from "alpha2/project";
2
2
  import type { LayoutBounds } from "alpha2/layout";
3
- import type { AssetBinding, ConformReport, MediaPurpose } from "alpha2/assets";
3
+ import type { AssetBinding, AudioStreamFacts, ConformReport, MediaPurpose } from "alpha2/assets";
4
4
  import type { BuiltinEffectCatalog, EffectDefinition } from "alpha2/effects";
5
+ import type { TrackDecodeFacts } from "alpha2/hdr-frames";
5
6
  import type { EditorSession } from "../core/session.js";
6
7
  import type { CapabilityReport, PlaybackPolicy } from "alpha2";
7
8
  import type { Capability } from "../ports/index.js";
8
9
  import type { Json } from "../core/document.js";
9
10
  import type { ExportJob } from "./jobs.js";
10
- /**
11
- * Where a bundler put the runtime's code and data. Each URL defaults to the location the
12
- * packaged module resolves on its own.
13
- */
11
+ /** Bundled locations of the runtime's code and data. Each URL defaults to the packaged one. */
14
12
  export interface RuntimeAssets {
15
13
  /**
16
- * Creates a worker running `installEditorWorker`. With one, the preview renders in that
17
- * worker; without, it renders on the main thread.
14
+ * Creates a worker running `installEditorWorker`. Without one the preview renders on the main
15
+ * thread.
18
16
  */
19
17
  readonly workerFactory?: () => Worker;
20
18
  /**
21
- * Creates a worker running the `@alpha2-sh/editor/hash-worker` entry. With one, each imported or
22
- * relinked file is hashed in a worker of its own; without, on the page's thread, which lets
23
- * other tasks run every few milliseconds but spends the page's CPU (about 5 ms a megabyte).
19
+ * Creates a worker running the `@alpha2-sh/editor/hash-worker` entry for import hashing. Without
20
+ * one, files hash on the page's thread at about 5 ms per megabyte.
24
21
  */
25
22
  readonly hashWorkerFactory?: () => Worker;
26
23
  /**
27
- * Creates a worker running the `@alpha2-sh/editor/extensions-worker` entry. With one, each file an
28
- * extension provider reads (SVG, animated image, Lottie, OpenEXR) is probed, opened and drawn for
29
- * its thumbnail at import, and an SVG opened again for its font report, in a worker of its own,
30
- * which a cancelled import terminates, as does a call running past `EXTENSIONS_CALL_TIMEOUT_MS`
31
- * (40 s; the import fails as `provider_stalled`). Without one, or when the worker cannot start,
32
- * those calls run on the page's thread, which waits for each: an animated image's open decodes
33
- * every frame.
24
+ * Creates a worker running the `@alpha2-sh/editor/extensions-worker` entry, which probes, opens
25
+ * and thumbnails files read by extension providers (SVG, animated image, Lottie, OpenEXR). A
26
+ * cancelled import terminates it, as does a call past `EXTENSIONS_CALL_TIMEOUT_MS` (40 s, failing
27
+ * the import as `provider_stalled`). Without one, or if it cannot start, those calls block the
28
+ * page's thread.
34
29
  */
35
30
  readonly extensionsWorkerFactory?: () => Worker;
36
31
  /** The engine's wasm binary (`alpha2/wasm`). */
37
32
  readonly wasmUrl?: string | URL;
38
- /**
39
- * Where a bundler put `alpha2_extensions_bg.wasm`, loaded when an SVG, animated image, or image
40
- * sequence is opened.
41
- */
33
+ /** `alpha2_extensions_bg.wasm`, loaded when an SVG, animated image or image sequence opens. */
42
34
  readonly extensionsWasmUrl?: string | URL;
43
35
  /** The audio worklet's wasm binary, loaded on the first Play. */
44
36
  readonly audioWasmUrl?: string | URL;
@@ -58,18 +50,15 @@ export interface RuntimeFont {
58
50
  /** The face to read in a collection file (`.ttc`/`.otc`); 0 for a single-face file. */
59
51
  readonly faceIndex: number;
60
52
  }
61
- /**
62
- * A source's media as this browser session holds it. Never part of the project document or its
63
- * history.
64
- */
53
+ /** A source's media as this browser session holds it; never part of the document or its history. */
65
54
  export interface RuntimeAsset {
66
55
  readonly id: string;
67
56
  /** `video`, `image`, `audio`, `text`, `font`, `lut3d`, or `generated`. */
68
57
  readonly kind: string;
69
58
  readonly name?: string;
70
59
  /**
71
- * What the source is read from. A still is decoded from it each time a frame needs its raster and
72
- * the cache does not hold it: no decoded picture stays with the asset.
60
+ * What the source is read from. A still is decoded from it on each raster cache miss; no decoded
61
+ * picture is kept with the asset.
73
62
  */
74
63
  readonly file?: File;
75
64
  /** Small preview canvas; `dataUrl` is a ready-to-use image URL. */
@@ -83,17 +72,27 @@ export interface RuntimeAsset {
83
72
  readonly height?: number;
84
73
  /** Seconds; 0 for a still. */
85
74
  readonly duration?: number;
86
- /**
87
- * Whether the file has an audio stream: what the document records as the source's `has_audio`,
88
- * whichever browser imported it.
89
- */
75
+ /** Whether the file has an audio stream, as the document records in `has_audio`. */
90
76
  readonly hasAudio?: boolean;
91
77
  /**
92
78
  * `false` when this browser cannot decode the file's audio (Safari before 26 has no
93
- * `AudioDecoder`): it plays and exports silent in this session, and the document still says the
94
- * source has audio, which a native host and other browsers hear.
79
+ * `AudioDecoder`). It then plays and exports silent in this session, while the document still
80
+ * records the audio for native hosts and other browsers.
95
81
  */
96
82
  readonly audioDecodable?: boolean;
83
+ /** When `audioDecodable` is `false`, what the trial decode at import found. */
84
+ readonly audioDecodeFacts?: TrackDecodeFacts;
85
+ /**
86
+ * Every audio stream of the file, which a clip's `audio.stream` counts over. Conform refuses a
87
+ * clip choosing a stream or channel not listed here.
88
+ */
89
+ readonly audioStreams?: readonly AudioStreamFacts[];
90
+ /**
91
+ * For a video, `unavailable` when this browser decodes it only to frames the engine cannot read
92
+ * (HDR, see `BrowserBridgeOptions.hdrWithoutPlanes`). It then previews degraded and cannot export
93
+ * in this session.
94
+ */
95
+ readonly planarDecode?: "available" | "unavailable";
97
96
  /** Per-bucket peak magnitudes across the whole file, for audio sources. */
98
97
  readonly peaks?: Float32Array | null;
99
98
  /** `native`: drawn centred at its own pixel size (text); otherwise contained. */
@@ -112,21 +111,16 @@ export interface StagedAsset {
112
111
  /** Decodes and probes files for import. `createMediaAdapter` makes the default one. */
113
112
  export interface BrowserMediaAdapter {
114
113
  /**
115
- * Stages one file. The bridge may stage several files of one import at once, at most four.
116
- * Rejects with an `EditorError`: `unsupported_media` for a file that is no media the adapter
117
- * imports, `unreadable_media` for media this browser could not read (a codec it does not decode,
118
- * a damaged file, or one an extension provider refuses, such as one whose drawing is past its
119
- * budgets; the decoder's or provider's reason is in the message and is the `cause`), `too_large`
120
- * for a Lottie, dotLottie or SVG file larger than the engine parses (`MAX_LOTTIE_DOCUMENT_BYTES`,
121
- * `MAX_PROVIDER_DOCUMENT_BYTES` for a dotLottie package, `MAX_SVG_DOCUMENT_BYTES`),
122
- * `provider_stalled` for one the extensions worker read past `EXTENSIONS_CALL_TIMEOUT_MS`, and
123
- * when `signal` aborts.
114
+ * Stages one file. The bridge stages at most four files of one import at once.
115
+ *
116
+ * Rejects with an `EditorError` coded `unsupported_media` for a file the adapter does not import,
117
+ * `unreadable_media` when this browser or an extension provider cannot read it (the reason is the
118
+ * message and `cause`), `too_large` for Lottie, dotLottie or SVG past the engine's parse limits
119
+ * (`MAX_LOTTIE_DOCUMENT_BYTES`, `MAX_PROVIDER_DOCUMENT_BYTES`, `MAX_SVG_DOCUMENT_BYTES`),
120
+ * `provider_stalled` past `EXTENSIONS_CALL_TIMEOUT_MS`, and when `signal` aborts.
124
121
  */
125
122
  stage(file: File, signal: AbortSignal, options?: {
126
- /**
127
- * `false` when the caller has no use for the file's fingerprint and it need not be computed:
128
- * the bridge adopts a kept proxy by its original's hash. Default `true`.
129
- */
123
+ /** Pass `false` to skip computing the fingerprint. Default `true`. */
130
124
  readonly fingerprint?: boolean;
131
125
  }): Promise<StagedAsset>;
132
126
  /** Stages numbered PNGs or OpenEXR images as one image sequence. */
@@ -136,28 +130,20 @@ export interface BrowserMediaAdapter {
136
130
  readonly den: number;
137
131
  };
138
132
  readonly missing: "reject" | "hold" | "blank";
139
- /**
140
- * The source ID the frames are staged under: the asset's own for a relink, a new one
141
- * otherwise.
142
- */
133
+ /** Source ID to stage the frames under: the asset's own for a relink, else a new one. */
143
134
  readonly id?: string;
144
135
  }, signal: AbortSignal): Promise<StagedAsset & {
145
136
  readonly name?: string;
146
137
  }>;
147
138
  }
148
- /**
149
- * What `installEditorWorker` uses of a dedicated worker's global (`self` in the worker): its
150
- * message handler and `postMessage`.
151
- */
139
+ /** The parts of a dedicated worker's global (`self`) that `installEditorWorker` uses. */
152
140
  export interface EditorWorkerScope {
153
141
  onmessage: ((event: MessageEvent) => void) | null;
154
142
  postMessage(message: unknown, transfer?: Transferable[]): void;
155
143
  }
156
144
  /** Options of `createBrowserBridge`. */
157
145
  export interface BrowserBridgeOptions {
158
- /**
159
- * The session the bridge previews, imports into, and exports. Disposing it disposes the bridge.
160
- */
146
+ /** Session the bridge previews, imports into and exports. Disposing it disposes the bridge. */
161
147
  readonly editor: EditorSession;
162
148
  readonly runtimeAssets?: RuntimeAssets;
163
149
  /** Defaults to `createMediaAdapter(runtimeAssets)`. */
@@ -167,14 +153,11 @@ export interface BrowserBridgeOptions {
167
153
  * default 128. An import past it is refused with `EditorError` `resource_budget`.
168
154
  */
169
155
  readonly resourceLimit?: number;
170
- /**
171
- * `false` renders picture only: no AudioContext is opened and playback runs on the wall clock
172
- * (thumbnails and other silent previews).
173
- */
156
+ /** `false` renders picture only: no AudioContext opens and playback runs on the wall clock. */
174
157
  readonly audio?: boolean;
175
158
  /**
176
- * Receives errors no caller awaits: a preview render that failed, audio that did not start,
177
- * a refresh after an edit. The bridge keeps running after each.
159
+ * Receives errors no caller awaits, such as a failed preview render or audio that did not start.
160
+ * The bridge keeps running after each.
178
161
  */
179
162
  readonly onError?: (error: unknown) => void;
180
163
  /**
@@ -183,67 +166,76 @@ export interface BrowserBridgeOptions {
183
166
  */
184
167
  readonly assetDecisions?: AssetBinding;
185
168
  /**
186
- * The preview resolution scale, default 0.5: frames render at the document's size times it
187
- * (rounded as the engine rounds), above 0 and at most 8. At 1 the preview renders at the
188
- * document's resolution, and text and effects match export pixel for pixel. See
189
- * `BrowserBridge.setPreviewScale`.
169
+ * Preview resolution scale relative to the document's size, above 0 and at most 8, default 0.5.
170
+ * At 1, text and effects match export pixel for pixel. See `BrowserBridge.setPreviewScale`.
190
171
  */
191
172
  readonly previewScale?: number;
192
173
  /**
193
- * Who converts decoded SDR video frames to the engine's pixels, in the preview and in exports
194
- * (an export may choose otherwise, see `BrowserExportOptions.videoConversion`). `engine` (the
195
- * default) copies each frame's planes out and converts them with the engine's shader, as a
196
- * native export converts the same stream. `browser` hands the frame to the browser instead,
197
- * which saves that copy (1 to 4 ms a frame per video layer) but leaves the conversion to the
198
- * browser, which does not read the stream's chroma siting: Chrome places H.264 and HEVC chroma
199
- * half a sample off (27 codes on a chroma stripe), so sharp chroma edges differ from a native
200
- * export's. HDR frames, and frames of a source whose color the project declares, are the
201
- * engine's either way. Another value is refused when the bridge is made, with an `EditorError`
174
+ * Who converts decoded SDR video frames to the engine's pixels, in preview and export (an export
175
+ * may override it with `BrowserExportOptions.videoConversion`). `engine` (the default) copies the
176
+ * planes out and converts them with the engine's shader, as a native export does. `browser`
177
+ * saves that copy (1 to 4 ms per frame per video layer) but ignores the stream's chroma siting,
178
+ * so sharp chroma edges can differ from a native export (Chrome places H.264 and HEVC chroma half
179
+ * a sample off). HDR frames and sources whose color the project declares always use the engine.
180
+ * Another value is refused when the bridge is made, with an `EditorError`
202
181
  * `invalid_video_conversion`.
203
182
  */
204
183
  readonly videoConversion?: "engine" | "browser";
184
+ /**
185
+ * `"auto"` (the default) draws with a hardware GPU through WebGPU or WebGL2, else with the
186
+ * engine's CPU renderer (also when only a software adapter exists). `"gpu"` accepts any adapter,
187
+ * software included. `"cpu"` uses the CPU renderer, which cannot draw runtime effects. GPU-loss
188
+ * recovery may still move the preview, or an export retry that draws no runtime effect, to the
189
+ * CPU. `capabilities.renderer`
190
+ * reports the preview's. Another value is refused when the bridge is made, with a `RangeError`.
191
+ */
192
+ readonly renderer?: "auto" | "gpu" | "cpu";
193
+ /**
194
+ * Handling of HDR video this browser decodes only to frames the engine cannot read and has no
195
+ * software decoder for (10-bit HEVC HDR in Chrome). `preview-degraded` (the default) imports it,
196
+ * previews it through the browser's tone mapping with `previewIssue` set, and makes `startExport`
197
+ * refuse exports that show it (`unsupported_media`, its cause a `PlanarDecodeUnavailableError`).
198
+ * The native host (`@alpha2-sh/editor/native-client`) can export such a project. `refuse`
199
+ * refuses the import (`unsupported_media`). Another value is refused when the bridge is made
200
+ * (`RangeError`).
201
+ */
202
+ readonly hdrWithoutPlanes?: "refuse" | "preview-degraded";
205
203
  }
206
204
  /** Options of `BrowserBridge.startExport`. */
207
205
  export interface BrowserExportOptions {
208
206
  /**
209
- * The file format, default `mp4`. It names the file and decides which codecs an export may ask
210
- * for (see `alpha2/containers`): `mov` takes no VP9, AV1 or Opus, and `webm` takes only VP9, AV1
211
- * and Opus. A codec the container does not offer is refused before the export renders, as
212
- * `INVALID_INPUT`.
207
+ * File format, default `mp4`. It limits the codecs (see `alpha2/containers`): `mov` takes no
208
+ * VP9, AV1 or Opus, and `webm` takes only VP9, AV1 and Opus. Other codecs are refused before the
209
+ * export renders, as `INVALID_INPUT`.
213
210
  */
214
211
  readonly container?: "mp4" | "mov" | "mkv" | "webm";
215
212
  /**
216
- * Default: the container's (`avc`, or `vp9` for `webm`). Whether this browser encodes it is the
217
- * browser's to say ({@link BrowserBridge.videoEncoders}); an export with one it does not is
218
- * refused before it renders, as `INVALID_INPUT`.
213
+ * Defaults to the container's (`avc`, or `vp9` for `webm`). A codec this browser does not encode
214
+ * ({@link BrowserBridge.videoEncoders}) is refused before the export renders, as `INVALID_INPUT`.
219
215
  */
220
216
  readonly videoCodec?: "avc" | "hevc" | "vp9" | "av1";
221
217
  /**
222
- * Default: the first of the container's audio codecs this browser encodes, in the container's
223
- * order (AAC, then Opus, for `mp4` and `mkv`; AAC for `mov`; Opus for `webm`). A codec asked for
224
- * that this browser cannot encode is refused before the export renders, as `INVALID_INPUT`.
218
+ * Defaults to the first of the container's audio codecs this browser encodes (AAC then Opus for
219
+ * `mp4` and `mkv`, AAC for `mov`, Opus for `webm`). A codec this browser cannot encode is refused
220
+ * before the export renders, as `INVALID_INPUT`.
225
221
  */
226
222
  readonly audioCodec?: "aac" | "opus";
227
223
  /**
228
- * One of the engine's quality levels (`very-low`, `low`, `medium`, `high`, `very-high`),
229
- * default `high`. The engine resolves it to a bitrate for the codec, size, and frame rate,
230
- * as it does for a native export.
224
+ * Engine quality level (`very-low`, `low`, `medium`, `high`, `very-high`), default `high`. The
225
+ * engine resolves it to a bitrate for the codec, size and frame rate, as for a native export.
231
226
  */
232
227
  readonly videoQuality?: string;
233
228
  /** An engine quality level for the audio, default `high`. */
234
229
  readonly audioQuality?: string;
235
230
  /**
236
- * Default `true`. Audio is written only when an audible source is shown. An export with
237
- * audio is refused before it renders on a browser that encodes none of the container's audio
238
- * codecs.
231
+ * Default `true`. Audio is written only when an audible source is shown. An export with audio is
232
+ * refused before it renders if this browser encodes none of the container's audio codecs.
239
233
  */
240
234
  readonly includeAudio?: boolean;
241
235
  /**
242
- * The exact rate to export at instead of the project's, frames per second as `num / den`
243
- * (`{ num: 30000, den: 1001 }` for 29.97), as the project states its own: both backends export
244
- * exactly this rate. One the engine cannot read (`num` and `den` positive 32-bit integers, a
245
- * frame at least one tick long) is refused when the export starts, with an `EditorError`
246
- * `invalid_frame_rate`.
236
+ * Exact export frame rate as `num / den` (`{ num: 30000, den: 1001 }` for 29.97), instead of the
237
+ * project's. `num` and `den` must be positive 32-bit integers giving a frame at least one tick
238
+ * long, else the export is refused when it starts with an `EditorError` `invalid_frame_rate`.
247
239
  */
248
240
  readonly frameRate?: {
249
241
  readonly num: number;
@@ -255,40 +247,35 @@ export interface BrowserExportOptions {
255
247
  */
256
248
  readonly media?: "original" | "proxies";
257
249
  /**
258
- * Where the file is written. `opfs` (the default where the browser supports it) streams it to a
259
- * temporary origin-private file, which the job's artifact holds until released; `file` streams it
260
- * into a file the user picked (`showSaveFilePicker`, obtained during the click that started the
261
- * export); `memory` keeps it in memory, for small outputs only: the export is refused before it
262
- * starts when its estimated size, with room for the buffer's growth and copies, passes `maxBytes`
263
- * (default 512 MiB). Without a disk API the export falls back to `memory` under the same limit,
264
- * never to an unbounded buffer.
250
+ * Where the file is written. `opfs` (the default where supported) streams to a temporary
251
+ * origin-private file that the job's artifact holds until released. `file` streams to a file the
252
+ * user picked (`showSaveFilePicker`, obtained during the click that started the export). `memory`
253
+ * is for small outputs: the export is refused before it starts when its estimated size, with
254
+ * room for buffer growth and copies, passes `maxBytes` (default 512 MiB). Without a disk API the
255
+ * export falls back to `memory` under the same limit.
265
256
  */
266
257
  readonly output?: ExportOutputTarget;
267
258
  /**
268
- * `inFlightBytes` bounds the rendered frames the export holds at once (GPU readbacks and the
269
- * copies queued for the encoder), default 128 MiB. The export submits a frame only when it fits,
270
- * gives back the renderer's idle GPU memory when the budget stops it, and is refused before it
271
- * starts when one frame's readback and copy cannot fit. The result's `performance.memory` reports
272
- * the budget, the least one frame needed, the most held, and how often the budget waited.
259
+ * `inFlightBytes` bounds the rendered frames held at once (GPU readbacks and copies queued for
260
+ * the encoder), default 128 MiB. The export is refused before it starts when one frame's readback
261
+ * and copy cannot fit. The result's `performance.memory` reports the budget, the least one frame
262
+ * needed, the most held, and how often the budget waited.
273
263
  */
274
264
  readonly memory?: {
275
265
  readonly inFlightBytes?: number;
276
266
  };
277
267
  /**
278
- * How source video decodes: `auto` (the default) lets the browser pick, a hardware decoder where
279
- * it has one; `software` decodes on the CPU, so no frame is read back from the GPU, except a
280
- * source the browser has no software decoder for, which decodes as `auto` and is reported in the
281
- * result's `report.decodeFallbacks` (`kind: "software-unavailable"`). Either way the engine
282
- * converts the same decoded values; a frame the browser cannot read back is decoded again in
283
- * software. Another value is refused when the export starts, with an `EditorError`
284
- * `invalid_video_decode`.
268
+ * `auto` (the default) lets the browser pick, a hardware decoder where it has one. `software`
269
+ * decodes on the CPU so no frame is read back from the GPU; a source the browser has no software
270
+ * decoder for decodes as `auto` and is listed in the result's `report.decodeFallbacks`
271
+ * (`kind: "software-unavailable"`). Another value is refused when the export starts, with an
272
+ * `EditorError` `invalid_video_decode`.
285
273
  */
286
274
  readonly videoDecode?: "auto" | "software";
287
275
  /**
288
- * Who converts decoded SDR video frames for this export, `engine` or `browser`; default the
289
- * bridge's (see `BrowserBridgeOptions.videoConversion`). The result's `report.videoConversion`
290
- * says which ran. Another value is refused when the export starts, with an `EditorError`
291
- * `invalid_video_conversion`.
276
+ * Overrides `BrowserBridgeOptions.videoConversion` for this export; the result's
277
+ * `report.videoConversion` says which ran. Another value is refused when the export starts, with
278
+ * an `EditorError` `invalid_video_conversion`.
292
279
  */
293
280
  readonly videoConversion?: "engine" | "browser";
294
281
  }
@@ -321,11 +308,6 @@ export interface ProxyRemoval {
321
308
  readonly removed: readonly string[];
322
309
  readonly inUse: readonly string[];
323
310
  }
324
- /**
325
- * The browser runtime of one editor session, made by `createBrowserBridge`. Times are integer
326
- * ticks (120000 per second). Methods that change the document dispatch through the session, so
327
- * they are undoable.
328
- */
329
311
  /** A rectangle in fractions of the canvas, y down, as a text style's `position` is. */
330
312
  export interface CanvasRect {
331
313
  readonly left: number;
@@ -334,83 +316,109 @@ export interface CanvasRect {
334
316
  readonly bottom: number;
335
317
  }
336
318
  /**
337
- * Where a text generator's text lies on the picture it draws, before its clip's transform and
338
- * effects: what {@link BrowserBridge.measureText} answers.
319
+ * Where a text generator's text lies on its picture, before the clip's transform and effects.
320
+ * Returned by {@link BrowserBridge.measureText}.
339
321
  */
340
322
  export interface TextBounds {
341
323
  /**
342
324
  * The box the style's `anchor` and `position` place: `max_width` wide, every line's em box tall,
343
- * and the whole pixels of outline and background padding around that.
325
+ * plus outline and background padding.
344
326
  */
345
327
  readonly layout: CanvasRect;
346
328
  /**
347
- * From the start of the line that starts farthest left to the end of the one that ends farthest
348
- * right, as tall as `layout`, with the same decorations around it. It moves only as the lines'
349
- * advances do, not as glyphs with more or less ink are typed: steady handles for a text clip.
329
+ * From the leftmost line start to the rightmost line end, as tall as `layout`, with the same
330
+ * padding. It moves only when line advances change, not glyph ink, so it gives steady handles.
350
331
  */
351
332
  readonly content: CanvasRect;
352
333
  /**
353
- * What the text draws: its glyphs, their outline, and the background's boxes. Every pixel the
354
- * frame gives the text meets it, give or take the pixel the texture's sampling spreads it by;
355
- * `null` when the text draws nothing (only spaces).
334
+ * What the text draws (glyphs, outline, background boxes), within about a pixel of sampling
335
+ * spread. `null` when the text draws nothing (only spaces).
356
336
  */
357
337
  readonly ink: CanvasRect | null;
358
338
  readonly lineCount: number;
359
339
  }
340
+ /** The renderer that draws the bound preview, in {@link BrowserBridge.capabilities}. */
341
+ export interface PreviewRenderer {
342
+ /** `"gpu"`, or `"cpu"`: the engine's CPU renderer in wasm. */
343
+ readonly renderer: "gpu" | "cpu";
344
+ /**
345
+ * Why it draws on the CPU: no hardware GPU (a refused software adapter is named), or a GPU loss
346
+ * moved the preview there. `null` on a GPU.
347
+ */
348
+ readonly rendererReason: string | null;
349
+ readonly backend: "webgpu" | "webgl2" | "cpu" | null;
350
+ /** The GPU adapter as the browser names it; `null` on the CPU or when it names none. */
351
+ readonly adapter: string | null;
352
+ /**
353
+ * Whether runtime effects draw. On the CPU renderer each one a loaded project draws is reported
354
+ * once as `effect_unavailable`, and an export that draws one fails with `EFFECT_ERROR`.
355
+ */
356
+ readonly runtimeEffects: boolean;
357
+ }
358
+ /**
359
+ * The browser runtime of one editor session, made by `createBrowserBridge`. Times are integer
360
+ * ticks (120000 per second). Methods that change the document dispatch through the session, so
361
+ * they are undoable.
362
+ */
360
363
  export interface BrowserBridge {
361
364
  /** Where the preview renders: nowhere until `bindPreview`, then a worker or the main thread. */
362
365
  readonly previewBackend: "unbound" | "worker" | "main-thread";
363
366
  /** How many times the preview was made again after its GPU device or WebGL context was lost. */
364
367
  readonly previewRecoveries: number;
365
- /** What this page can do; `gpu` and `color` are `null` until a preview is bound. */
368
+ /**
369
+ * What this page can do; `gpu`, `color` and `renderer` are `null` until a preview is bound.
370
+ * `features.preview` and `features.export` need no GPU: without one the engine draws on the CPU.
371
+ */
366
372
  readonly capabilities: CapabilityReport<null, null> & {
373
+ readonly renderer: PreviewRenderer | null;
367
374
  readonly features: Readonly<Record<"preview" | "audioPreview" | "transportRate" | "worker" | "export", Capability>>;
368
375
  };
369
- /** The playhead. */
376
+ /** The playhead, in ticks. */
370
377
  readonly tick: number;
371
378
  readonly playing: boolean;
372
379
  /** Runtime resources currently held (see `BrowserBridgeOptions.resourceLimit`). */
373
380
  readonly resourceCount: number;
374
381
  /**
375
- * Preview output volume from 0 to 1; a monitor control, not part of the project or exports.
376
- * The bridge keeps it: set before a preview is bound, or across bindings, it applies to every
377
- * preview's sound. Throws for a value outside that range.
382
+ * Preview output volume from 0 to 1, a monitor control outside the project and exports. Kept by
383
+ * the bridge across bindings. Throws for a value outside that range.
378
384
  */
379
385
  setMonitorVolume(value: number): void;
380
386
  /** The monitor volume `setMonitorVolume` last set; 1 until then. */
381
387
  readonly monitorVolume: number;
382
388
  /**
383
- * Logs every source upload of the renderer that draws the preview (the worker's in worker mode)
384
- * to the console, for debugging. Kept for later bindings.
389
+ * Shifts the preview picture against its sound by `ms` milliseconds (positive shows it later),
390
+ * for output delay the browser does not report, such as a wireless headset's. Kept across
391
+ * bindings. Throws for a value that is not finite or beyond 2000 ms either way.
385
392
  */
393
+ setAudioOffset(ms: number): void;
394
+ /** The offset `setAudioOffset` last set; 0 until then. */
395
+ readonly audioOffsetMs: number;
396
+ /** Logs every source upload of the preview renderer to the console. Kept across bindings. */
386
397
  setTraceUploads(value: boolean): void;
387
398
  /**
388
- * Turns per-pass GPU and CPU timing of the renderer that draws the preview on or off; the
389
- * passes then appear in `diagnostics`. Off by default, since timing is profiling cost. Kept for
390
- * later bindings.
399
+ * Turns per-pass GPU and CPU timing of the preview renderer on or off (off by default); the
400
+ * passes then appear in `diagnostics`. Kept across bindings.
391
401
  */
392
402
  setPassTiming(enabled: boolean): void;
393
403
  /** The preview resolution scale (see `BrowserBridgeOptions.previewScale`). */
394
404
  readonly previewScale: number;
395
405
  /**
396
- * Renders the preview at `scale` times the document's size from now on, and draws the current
397
- * frame again; resolves once it is drawn. The bound canvas's backing store is always the size
398
- * frames render at, not the document's: a host sizes the canvas on the page with CSS (as
399
- * `EditorPreview` does). Rejects with `invalid_preview_scale` for a scale that is not above 0 and at
400
- * most 8.
406
+ * Renders the preview at `scale` times the document's size and redraws the current frame;
407
+ * resolves once drawn. The bound canvas's backing store takes the render size, so size the canvas
408
+ * on the page with CSS (as `EditorPreview` does). Rejects with `invalid_preview_scale` unless the
409
+ * scale is above 0 and at most 8.
401
410
  */
402
411
  setPreviewScale(scale: number): Promise<void>;
403
412
  /**
404
- * The latest diagnostics sample of the renderer that draws the preview (taken at most every
405
- * 250 ms; in worker mode the worker's), or `null`. Its `host` block holds, with the renderer's
406
- * timing:
413
+ * The latest diagnostics sample of the preview renderer (taken at most every 250 ms), or `null`.
414
+ * Its `host` block adds to the renderer's timing:
407
415
  * - `renders`: frames the player drew;
408
- * - `unchanged`: frames found equal to the one shown, so neither drawn nor presented;
409
- * - `skippedRequests`: playback refreshes that asked for no frame, the one shown being the
410
- * frame the clock asked for;
416
+ * - `unchanged`: frames equal to the one shown, so neither drawn nor presented;
417
+ * - `skippedRequests`: playback refreshes that needed no new frame;
411
418
  * - `bitmapTransfers`: frames copied to the bound canvas from another surface;
412
419
  * - `renderSize`: `[width, height]` frames render at;
413
- * - `previewScale`, and `backend` (`worker` or `main-thread`).
420
+ * - `previewScale`, and `backend` (`worker` or `main-thread`);
421
+ * - `audioLatencySource`: `output-latency`, `output-timestamp`, `base-only`, or `null` if silent.
414
422
  * Counters are cumulative (`renders` and `unchanged` per renderer, the others since
415
423
  * `bindPreview`): subtract two samples for a rate.
416
424
  */
@@ -418,52 +426,46 @@ export interface BrowserBridge {
418
426
  /** The engine's built-in effects and transitions; `null` until a preview is bound. */
419
427
  readonly catalog: BuiltinEffectCatalog | null;
420
428
  /**
421
- * Adds runtime effects (and transitions) beyond the built-in catalog, so the document can draw
422
- * them by `id@version`: every renderer the bridge makes registers them, the preview's (in its
423
- * worker and on the main thread, and again after a lost GPU) and each export attempt's. They
424
- * belong to the bridge, not the document: loading another project keeps them.
429
+ * Adds runtime effects and transitions beyond the built-in catalog, addressable by `id@version`.
430
+ * They belong to the bridge, not the document: every renderer the bridge makes registers them
431
+ * (preview, a preview remade after GPU loss, each export attempt), and loading another project
432
+ * keeps them.
425
433
  *
426
- * With a preview bound, the definitions are compiled on its device, all or none, and the current
427
- * frame is drawn again; the call rejects with `invalid_effect` naming the first one the engine
428
- * refuses, and keeps none of them. Without one they are kept unchecked: `bindPreview` compiles
429
- * them, and one refused then is dropped and reported to `onError` as `invalid_effect`. An export
430
- * registers those kept when it starts, and an export attempt the engine refuses one in fails with
434
+ * With a preview bound, the definitions compile on its device all or none, and the call rejects
435
+ * with `invalid_effect` naming the first one the engine refuses. Without one they are kept
436
+ * unchecked; `bindPreview` compiles them and drops any refused one, reporting it to `onError` as
437
+ * `invalid_effect`. An export attempt in which the engine refuses one fails with
431
438
  * `invalid_effect`.
432
439
  *
433
- * A definition registered already under the same `id@version` is skipped; a different one under
434
- * it is refused (`effect_conflict`): a changed effect takes another version. Rejects with
435
- * `invalid_effect` for a definition without a string `id` and an integer `version`, and once the
436
- * bridge is disposed (`disposed`).
440
+ * Registering the same definition under an `id@version` again is skipped; a different one is
441
+ * refused with `effect_conflict` (change the version instead). Also rejects with `invalid_effect`
442
+ * for a definition without a string `id` and an integer `version`, and with `disposed` after the
443
+ * bridge is disposed.
437
444
  */
438
445
  registerEffects(definitions: readonly EffectDefinition[]): Promise<void>;
439
446
  /**
440
- * Source `id` of the draft: its original while it is online, even where preview reads a proxy
441
- * (see {@link BrowserBridge.setPreviewMedia}), else the kept proxy standing in for it; opened
442
- * with the provider settings the document names. Use {@link BrowserBridge.hasOriginal} to ask
443
- * whether the original itself is linked.
447
+ * Source `id` of the draft: its original while online, even where preview reads a proxy (see
448
+ * {@link BrowserBridge.setPreviewMedia}), else the kept proxy standing in for it. Use
449
+ * {@link BrowserBridge.hasOriginal} to ask whether the original itself is linked.
444
450
  */
445
451
  getAsset(id: string): RuntimeAsset | null;
446
- /**
447
- * Notifies when derived runtime data (such as waveform peaks) becomes available for an already
448
- * imported asset.
449
- */
452
+ /** Notifies when derived runtime data (such as waveform peaks) arrives for an imported asset. */
450
453
  subscribeAssets(listener: () => void): () => void;
451
454
  /**
452
- * Why the viewer holds its last frame instead of the current one, or `null` when it is current: a
453
- * composition the playhead shows cannot draw its output yet.
455
+ * Why the viewer holds its last frame, or `null` when it is current (a composition at the
456
+ * playhead cannot draw its output yet). Also set while an HDR source shows through the browser's
457
+ * own tone mapping (see `BrowserBridgeOptions.hdrWithoutPlanes`), which cannot export here.
454
458
  */
455
459
  readonly previewIssue: string | null;
456
460
  /** Notifies when {@link previewIssue} changes. */
457
461
  subscribePreview(listener: () => void): () => void;
458
462
  /**
459
463
  * Draws the preview on `canvas`. Rejects only when the surface cannot be bound (the GPU would not
460
- * start); a first frame that cannot render, such as one whose media is not linked yet, goes to
461
- * `onError` like any later frame and is drawn by the next edit or seek. A preview worker that
462
- * fails, to start or later, is given up for the main-thread renderer, which draws on the same
463
- * surface: `previewBackend` then says `main-thread` and `onError` hears why, once, as an
464
- * `EditorError` `preview_worker_failed` (a worker that lost its GPU is recovered from without a
465
- * report, as a lost GPU on the main thread is). A given-up worker is not started again until the
466
- * next `bindPreview`, not even by a preview made again after a lost GPU.
464
+ * start); a first frame that cannot render, such as one with unlinked media, goes to `onError`
465
+ * and is drawn by the next edit or seek. If the preview worker fails, the main-thread renderer
466
+ * takes over the same surface: `previewBackend` becomes `main-thread` and `onError` receives one
467
+ * `EditorError` `preview_worker_failed` (a worker that loses its GPU recovers without a report).
468
+ * The worker is not restarted until the next `bindPreview`.
467
469
  */
468
470
  bindPreview(canvas: HTMLCanvasElement | OffscreenCanvas): Promise<{
469
471
  readonly canvas: HTMLCanvasElement | OffscreenCanvas;
@@ -505,9 +507,9 @@ export interface BrowserBridge {
505
507
  assetIds: string[];
506
508
  }>;
507
509
  /**
508
- * Relinks an image sequence to its frames, at the frame rate and gap rule the project recorded:
509
- * the asset keeps its ID and clips, and the engine decides whether the frames are the sequence it
510
- * recorded. Refused for an asset that is not an image sequence.
510
+ * Relinks an image sequence to its frames at the recorded frame rate and gap rule, keeping its ID
511
+ * and clips; the engine decides whether the frames match the recorded sequence. Refused for an
512
+ * asset that is not an image sequence.
511
513
  */
512
514
  relinkSequence(id: string, files: readonly File[], options?: {
513
515
  signal?: AbortSignal;
@@ -535,43 +537,43 @@ export interface BrowserBridge {
535
537
  /** Stops playback and audio; the playhead stays where it was. */
536
538
  pause(): void;
537
539
  /**
538
- * Reads a subtitle file (`.srt`, or `.vtt` for WebVTT) into a captions asset in the bin
539
- * (`captionsAsset`); `skipped` counts blocks that were not cues. Nothing reaches the timeline
540
- * until the asset is inserted (`captionTrackCommands`).
540
+ * Reads a subtitle file (`.srt`, or `.vtt` for WebVTT) into a captions asset in the bin;
541
+ * `skipped` counts blocks that were not cues. Nothing reaches the timeline until the asset is
542
+ * inserted (`captionTrackCommands`).
541
543
  *
542
- * Throws an `EditorError` (`invalid_captions`) for a file larger than `MAX_CAPTION_FILE_BYTES`,
543
- * which is not read, and for one the engine refuses: a WebVTT file without its header, more than
544
- * `MAX_CAPTION_FILE_CUES` cues, or cues that need more caption tracks than a project holds.
544
+ * Rejects with an `EditorError` `invalid_captions` for a file larger than
545
+ * `MAX_CAPTION_FILE_BYTES` (not read), a WebVTT file without its header, more than
546
+ * `MAX_CAPTION_FILE_CUES` cues, or cues that need more caption tracks than a project holds, and
547
+ * with `invalid_text` for a file that is neither UTF-8 nor UTF-16 with a byte order mark.
545
548
  */
546
549
  importCaptions(file: File): Promise<{
547
550
  assetId: string;
548
551
  skipped: number;
549
552
  }>;
550
553
  /**
551
- * The font families caption styles can name in `font_family`: those of the document's font assets
552
- * and the runtime's fonts, in fallback order, each once, as the engine reads them from the fonts'
553
- * name tables.
554
+ * The font families caption styles can name in `font_family`: the document's font assets and
555
+ * the runtime's fonts, in fallback order, deduplicated, as read from the fonts' name tables.
554
556
  */
555
557
  captionFontFamilies(): Promise<string[]>;
556
558
  /**
557
- * Where the engine draws a text generator's text (see {@link TextBounds}): laid out as preview
558
- * lays it out, with the same fonts, at the draft's canvas size, without rendering. A clip's
559
- * transform maps these rectangles as it maps the rest of its picture.
559
+ * Where the engine draws a text generator's text (see {@link TextBounds}), laid out as preview
560
+ * does at the draft's canvas size, without rendering. The clip's transform maps these rectangles
561
+ * like the rest of its picture.
560
562
  *
561
- * Rejects a generator that is not a valid text generator (`INVALID_INPUT`), with no fonts to
562
- * draw it, and once the bridge is disposed (`disposed`).
563
+ * Rejects an invalid text generator (`INVALID_INPUT`), one with no fonts to draw it, and after
564
+ * the bridge is disposed (`disposed`).
563
565
  */
564
566
  measureText(generator: Extract<Generator, {
565
567
  type: "text";
566
568
  }>): Promise<TextBounds>;
567
569
  /**
568
570
  * Where every box of a layout generator lies at picture time `time` (whole ticks) and whether
569
- * anything overflows (see `alpha2/layout`'s `LayoutBounds`): laid out as preview lays it out,
570
- * with the same fonts, at the draft's canvas size, without rendering. A clip's transform maps
571
- * these rectangles as it maps the rest of its picture.
571
+ * anything overflows (see `alpha2/layout`'s `LayoutBounds`), laid out as preview does at the
572
+ * draft's canvas size, without rendering. The clip's transform maps these rectangles like the
573
+ * rest of its picture.
572
574
  *
573
- * Rejects a generator that is not a valid layout generator (`INVALID_INPUT`), a layout with text
574
- * and no fonts to draw it, and once the bridge is disposed (`disposed`).
575
+ * Rejects an invalid layout generator (`INVALID_INPUT`), a layout with text and no fonts to draw
576
+ * it, and after the bridge is disposed (`disposed`).
575
577
  */
576
578
  measureLayout(generator: Extract<Generator, {
577
579
  type: "layout";
@@ -589,13 +591,13 @@ export interface BrowserBridge {
589
591
  */
590
592
  conform(purpose: MediaPurpose, document?: import("../core/document.js").EditorDocument): Promise<ConformReport>;
591
593
  /**
592
- * Makes and keeps a proxy of a source whose original this session holds. Proxies are made one
593
- * at a time and never beside an export: this waits for a running export and for a proxy of
594
- * another source being made, and an export that starts stops the conversion, which starts again
595
- * from the beginning once the export ends (`proxyStatus` shows its progress back at 0). Rejects
596
- * for a source without a single video file (`unsupported_media`, including HDR video), without
597
- * its original in this session (`missing_asset`), with a proxy of it already being made
598
- * (`proxy_busy`), or when `signal` aborts.
594
+ * Makes and keeps a proxy of a source whose original this session holds. Proxies are made one at
595
+ * a time and never during an export: this waits for a running export or another proxy, and an
596
+ * export that starts restarts the conversion from 0 once it ends. Rejects for a source without a
597
+ * single video file (`unsupported_media`, including HDR video), without its original in this
598
+ * session (`missing_asset`), with a proxy already being made (`proxy_busy`), when the conversion
599
+ * makes no progress for 30 s (`proxy_stalled`; preview keeps reading the original), or when
600
+ * `signal` aborts.
599
601
  */
600
602
  generateProxy(id: string, options?: {
601
603
  signal?: AbortSignal;
@@ -604,22 +606,18 @@ export interface BrowserBridge {
604
606
  proxyStatus(id: string): ProxyStatus;
605
607
  /**
606
608
  * Which video codecs this browser encodes for an export of the current document (its size and
607
- * frame rate) at `videoQuality` (default `high`). WebCodecs leaves the codecs to the browser;
608
- * an export with one answered `false` is refused before it renders (`INVALID_INPUT`).
609
+ * frame rate) at `videoQuality` (default `high`). An export with a codec answered `false` is
610
+ * refused before it renders (`INVALID_INPUT`).
609
611
  */
610
612
  videoEncoders(options?: {
611
613
  readonly videoQuality?: string;
612
614
  }): Promise<Readonly<Record<NonNullable<BrowserExportOptions["videoCodec"]>, boolean>>>;
613
- /**
614
- * The proxies this browser keeps, for every project: each original's SHA-256 and the bytes its
615
- * proxy takes.
616
- */
615
+ /** Proxies this browser keeps for all projects: each original's SHA-256 and its proxy's bytes. */
617
616
  listProxies(): Promise<KeptProxy[]>;
618
617
  /**
619
- * Removes the kept proxies of `hashes` (originals' SHA-256). This session lets go of its own
620
- * first and refreshes the preview; a proxy still read after that (by the preview, for a source
621
- * whose original is offline, by an export, or by another page of the origin) is left and listed
622
- * in `inUse`.
618
+ * Removes the kept proxies of `hashes` (originals' SHA-256). This session releases its own first
619
+ * and refreshes the preview; a proxy still read afterwards (by the preview for an offline
620
+ * original, by an export, or by another page of the origin) stays and is listed in `inUse`.
623
621
  */
624
622
  removeProxies(hashes: Iterable<string>): Promise<ProxyRemoval>;
625
623
  /**
@@ -655,8 +653,8 @@ export interface BrowserBridge {
655
653
  selectAnimation(id: string, animation: string): void;
656
654
  /**
657
655
  * Reads an OpenEXR source's linear RGB in `primaries`, overriding what the file declares; `null`
658
- * goes back to the file's.
659
- * Throws `EditorError` `unsupported_media` for a source whose primaries cannot be chosen.
656
+ * goes back to the file's. Throws `EditorError` `unsupported_media` for a source whose primaries
657
+ * cannot be chosen.
660
658
  */
661
659
  setLinearPrimaries(id: string, primaries: import("alpha2").LinearPrimaries | null): void;
662
660
  /**
@@ -666,9 +664,11 @@ export interface BrowserBridge {
666
664
  * Throws synchronously when the bridge is disposed (`disposed`), another export runs
667
665
  * (`export_busy`), `frameRate` is not one the engine reads (`invalid_frame_rate`), `videoDecode`
668
666
  * is not `auto` or `software` (`invalid_video_decode`), `videoConversion` is not `engine` or
669
- * `browser` (`invalid_video_conversion`), the asset
670
- * decisions are not loaded (`conform_pending`), the media is not ready (`ConformError`), or the
671
- * document does not compile. Everything later is reported through the job's `result`.
667
+ * `browser` (`invalid_video_conversion`), the asset decisions are not loaded (`conform_pending`),
668
+ * the media is not ready (`ConformError`), the document does not compile, or it shows an HDR
669
+ * source this browser previews only degraded (`unsupported_media`, its `cause` a
670
+ * `PlanarDecodeUnavailableError` naming the sources). Later failures arrive through the job's
671
+ * `result`.
672
672
  */
673
673
  startExport(options?: BrowserExportOptions): ExportJob;
674
674
  /**
@@ -689,11 +689,15 @@ export interface WorkerPreviewOptions {
689
689
  readonly runtimeAssets?: RuntimeAssets;
690
690
  /** A canvas to render into, transferred to the worker. */
691
691
  readonly canvas?: OffscreenCanvas;
692
+ /** `engine` (the default) or `browser`; see `BrowserBridgeOptions.videoConversion`. */
693
+ readonly videoConversion?: "engine" | "browser";
692
694
  /**
693
- * Who converts decoded SDR video frames, `engine` (the default) or `browser`; see
694
- * `BrowserBridgeOptions.videoConversion`.
695
+ * `present-degraded` shows an HDR source without planes through the browser's own conversion
696
+ * (`FrameSupply`'s `opaqueEngineFrames`); `refuse` (the default) fails its frames.
695
697
  */
696
- readonly videoConversion?: "engine" | "browser";
698
+ readonly opaqueEngineFrames?: "refuse" | "present-degraded";
699
+ /** `"auto"` (the default: a hardware GPU, else the CPU renderer), `"gpu"` or `"cpu"`. */
700
+ readonly renderer?: "auto" | "gpu" | "cpu";
697
701
  }
698
702
  /** The main-thread side of a preview renderer running in a worker. */
699
703
  export interface WorkerPreview {
@@ -709,16 +713,17 @@ export interface WorkerPreview {
709
713
  renderSize: readonly [number, number] | null;
710
714
  }>;
711
715
  /**
712
- * Renders the frame at `tick`. `rendered` is `false` for an empty project or a render
713
- * cancelled meanwhile. `unchanged` says the frame equals the one already shown, so nothing was
714
- * drawn or presented and no `bitmap` comes: the surface it was copied to still shows it.
715
- * `bitmap` is present only with `bitmapOutput`, and the caller owns it. `diagnostics` are the
716
- * source decoders'; `engineDiagnostics` is the renderer's diagnostics sample, present when it
717
- * is newer than the one the last reply carried.
716
+ * Renders the frame at `tick`. `rendered` is `false` for an empty project or a render cancelled
717
+ * meanwhile. `unchanged` means the frame equals the one already shown, so nothing was drawn and
718
+ * no `bitmap` comes. `bitmap` is present only with `bitmapOutput`, and the caller owns it.
719
+ * `diagnostics` are the source decoders'; `engineDiagnostics` is the renderer's sample, present
720
+ * when newer than the one the last reply carried.
718
721
  */
719
722
  seek(tick: number): Promise<{
720
723
  rendered: boolean;
721
724
  unchanged: boolean;
725
+ /** Sources the frame showed through the browser's own conversion. */
726
+ degradedSources: readonly string[];
722
727
  bitmap?: ImageBitmap;
723
728
  diagnostics: Readonly<Record<string, number>>;
724
729
  engineDiagnostics?: Readonly<Record<string, unknown>>;