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