@alpha2-sh/editor 0.4.5 → 0.5.0

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (81) hide show
  1. package/dist/browser/bridge.d.ts +15 -16
  2. package/dist/browser/bridge.js +533 -387
  3. package/dist/browser/extensions-worker.d.ts +12 -16
  4. package/dist/browser/extensions-worker.js +17 -24
  5. package/dist/browser/hash-worker.d.ts +4 -5
  6. package/dist/browser/hash-worker.js +7 -8
  7. package/dist/browser/jobs.d.ts +17 -19
  8. package/dist/browser/jobs.js +41 -28
  9. package/dist/browser/resources.d.ts +6 -11
  10. package/dist/browser/resources.js +5 -9
  11. package/dist/browser/runtime/assets.d.ts +52 -31
  12. package/dist/browser/runtime/assets.js +206 -47
  13. package/dist/browser/runtime/audio.d.ts +16 -11
  14. package/dist/browser/runtime/audio.js +58 -31
  15. package/dist/browser/runtime/budget.d.ts +4 -5
  16. package/dist/browser/runtime/budget.js +4 -5
  17. package/dist/browser/runtime/caption-fonts.d.ts +3 -7
  18. package/dist/browser/runtime/caption-fonts.js +4 -8
  19. package/dist/browser/runtime/engine.d.ts +40 -43
  20. package/dist/browser/runtime/engine.js +82 -63
  21. package/dist/browser/runtime/export-audio.d.ts +6 -6
  22. package/dist/browser/runtime/export-audio.js +8 -9
  23. package/dist/browser/runtime/exporter.d.ts +33 -66
  24. package/dist/browser/runtime/exporter.js +111 -137
  25. package/dist/browser/runtime/extension-import.d.ts +28 -35
  26. package/dist/browser/runtime/extension-import.js +36 -46
  27. package/dist/browser/runtime/fingerprint.d.ts +11 -14
  28. package/dist/browser/runtime/fingerprint.js +20 -24
  29. package/dist/browser/runtime/generators.d.ts +2 -3
  30. package/dist/browser/runtime/generators.js +5 -7
  31. package/dist/browser/runtime/locks.d.ts +5 -7
  32. package/dist/browser/runtime/locks.js +5 -7
  33. package/dist/browser/runtime/output.d.ts +7 -9
  34. package/dist/browser/runtime/output.js +17 -21
  35. package/dist/browser/runtime/preview-utils.js +10 -6
  36. package/dist/browser/runtime/proxies.d.ts +10 -17
  37. package/dist/browser/runtime/proxies.js +33 -45
  38. package/dist/browser/runtime/proxy-storage.d.ts +15 -19
  39. package/dist/browser/runtime/proxy-storage.js +20 -24
  40. package/dist/browser/runtime/sources.d.ts +23 -31
  41. package/dist/browser/runtime/sources.js +98 -105
  42. package/dist/browser/runtime/staging.d.ts +2 -6
  43. package/dist/browser/runtime/staging.js +7 -11
  44. package/dist/browser/runtime/still.d.ts +2 -6
  45. package/dist/browser/runtime/still.js +6 -12
  46. package/dist/browser/runtime/text.d.ts +14 -0
  47. package/dist/browser/runtime/text.js +27 -0
  48. package/dist/browser/runtime/wasm.d.ts +4 -5
  49. package/dist/browser/runtime/wasm.js +4 -5
  50. package/dist/browser/types.d.ts +243 -221
  51. package/dist/browser/worker.d.ts +8 -9
  52. package/dist/browser/worker.js +55 -22
  53. package/dist/core/captions.d.ts +8 -10
  54. package/dist/core/captions.js +10 -18
  55. package/dist/core/clip-time.d.ts +8 -10
  56. package/dist/core/clip-time.js +12 -15
  57. package/dist/core/commands.d.ts +46 -46
  58. package/dist/core/commands.js +38 -36
  59. package/dist/core/compositions.d.ts +78 -112
  60. package/dist/core/compositions.js +66 -94
  61. package/dist/core/document.d.ts +59 -92
  62. package/dist/core/document.js +65 -90
  63. package/dist/core/keyframes.d.ts +11 -12
  64. package/dist/core/keyframes.js +11 -13
  65. package/dist/core/presets.d.ts +14 -20
  66. package/dist/core/presets.js +12 -18
  67. package/dist/core/session.d.ts +26 -38
  68. package/dist/core/session.js +38 -53
  69. package/dist/core/text.d.ts +2 -3
  70. package/dist/core/text.js +2 -3
  71. package/dist/core/timeline-index.d.ts +2 -3
  72. package/dist/core/timeline-index.js +11 -7
  73. package/dist/core/transitions.js +4 -5
  74. package/dist/core/validated.d.ts +6 -7
  75. package/dist/core/validated.js +8 -11
  76. package/dist/native-client/index.d.ts +31 -32
  77. package/dist/native-client/index.js +40 -41
  78. package/dist/ports/index.d.ts +19 -19
  79. package/dist/react/index.d.ts +5 -6
  80. package/dist/react/index.js +5 -6
  81. package/package.json +4 -4
@@ -1,32 +1,27 @@
1
1
  import type { ExportFailureCode } from "alpha2/export-failure";
2
2
  import type { Canonical, CanonicalProject } from "alpha2/project";
3
3
  import type { ClipTransition, MediaFingerprint, Project, Track, ProjectSettings, TimeRange } from "alpha2/project";
4
- /** A JSON value: what editor metadata and asset authoring data may hold. */
4
+ /** A JSON value, as editor metadata and asset authoring data hold. */
5
5
  export type Json = null | boolean | number | string | readonly Json[] | {
6
6
  readonly [key: string]: Json;
7
7
  };
8
8
  /** A bin asset: what the editor knows about a project source or effect resource. */
9
9
  export interface AssetDescriptor {
10
- /** The id of the project source or effect resource it describes. */
10
+ /** Id of the project source or effect resource it describes. */
11
11
  readonly id: string;
12
- /**
13
- * The source kind (`video`, `image`, `generated`, ...), or an editor-only kind such as
14
- * `captions`.
15
- */
12
+ /** Source kind (`video`, `image`, `generated`, ...) or an editor-only kind like `captions`. */
16
13
  readonly kind: string;
17
14
  /** The display name, usually the imported file's name. */
18
15
  readonly name: string;
19
- /**
20
- * A non-negative safe integer that changes whenever the asset's content is replaced (a relink).
21
- */
16
+ /** A non-negative safe integer that changes whenever the content is replaced (a relink). */
22
17
  readonly contentRevision: number;
23
18
  /** Whether the asset's media is offline. */
24
19
  readonly missing?: boolean;
25
20
  /** Where the media is read from, when it is not kept in the document. */
26
21
  readonly locator?: string;
27
- /** Data the asset is built from: a text asset's `text` style, a captions asset's cue rows. */
22
+ /** Data the asset is built from, such as a text asset's style or a captions asset's cues. */
28
23
  readonly authoring?: Json;
29
- /** Evidence of the file imported, as the project source records it too. */
24
+ /** Evidence of the imported file, also recorded on the project source. */
30
25
  readonly fingerprint?: MediaFingerprint;
31
26
  }
32
27
  /**
@@ -38,10 +33,7 @@ export interface TrackMetadata {
38
33
  readonly enabled?: boolean;
39
34
  /** A `#rrggbb` color. */
40
35
  readonly color?: string;
41
- /**
42
- * Whether a ripple edit on another track moves this track's content after the edit point too,
43
- * keeping it in sync.
44
- */
36
+ /** Whether a ripple edit on another track also moves this track's later content. */
45
37
  readonly syncLock?: boolean;
46
38
  }
47
39
  /** A clip's editor metadata. A clip without a `name` shows its source's name. */
@@ -51,15 +43,14 @@ export interface ClipMetadata {
51
43
  /** A timeline marker: an instant, or a range when it has an `end`. */
52
44
  export interface Marker {
53
45
  readonly id: string;
54
- /** Where it is, in timeline ticks. */
46
+ /** Timeline ticks. */
55
47
  readonly time: number;
56
- /** Where a range marker ends; after `time`. */
48
+ /** End of a range marker; after `time`. */
57
49
  readonly end?: number;
58
50
  readonly name: string;
59
51
  readonly note?: string;
60
52
  /** A `#rrggbb` color. */
61
53
  readonly color?: string;
62
- /** Whether what it notes is done. */
63
54
  readonly done?: boolean;
64
55
  }
65
56
  /** A node's place in the node editor, in canvas pixels. */
@@ -67,27 +58,24 @@ export interface GraphPosition {
67
58
  readonly x: number;
68
59
  readonly y: number;
69
60
  }
70
- /** Node positions by composition, then node: editor metadata, not render input. */
61
+ /** Node positions by composition, then node. Editor metadata, not render input. */
71
62
  export type GraphLayout = Readonly<Record<string, Readonly<Record<string, GraphPosition>>>>;
72
- /** What the editor keeps beside the engine project: none of it is render input. */
63
+ /** What the editor keeps beside the engine project. None of it is render input. */
73
64
  export interface EditorMetadata {
74
65
  /** By track id. */
75
66
  readonly tracks: Readonly<Record<string, TrackMetadata>>;
76
67
  /** By clip id. */
77
68
  readonly clips: Readonly<Record<string, ClipMetadata>>;
78
69
  /**
79
- * Stable ids for list items the project keeps without one, by list (`<trackId>/cues`,
70
+ * Stable ids for list items the project stores without one, by list (`<trackId>/cues`,
80
71
  * `<trackId>/transitions`, `<clipId>/masks`). Maintained by {@link withInstanceIds}.
81
72
  */
82
73
  readonly instanceIds: Readonly<Record<string, readonly string[]>>;
83
74
  readonly markers: readonly Marker[];
84
- /** The range an export renders by default, in timeline ticks; `null` for the whole timeline. */
75
+ /** Default export range in timeline ticks; `null` for the whole timeline. */
85
76
  readonly exportRange: TimeRange | null;
86
- /** Node positions of the effect graph view. */
87
77
  readonly graphLayout?: GraphLayout;
88
- /**
89
- * Names of compositions drawn as groups, by composition id: editor metadata, not render input.
90
- */
78
+ /** Names of compositions drawn as groups, by composition id. */
91
79
  readonly graphNames?: Readonly<Record<string, string>>;
92
80
  }
93
81
  /** An editor project file: the engine project plus editor metadata and bin assets. */
@@ -95,10 +83,9 @@ export interface EditorDocument {
95
83
  readonly format: "alpha2-editor-project";
96
84
  readonly version: 1;
97
85
  /**
98
- * The engine project, in the forms the engine writes ({@link CanonicalProject}): every color the
99
- * components object, every paint tagged, padding and margin the four sides, an offset `{ x, y }`.
100
- * A document is put in this form wherever it enters the editor (opened, created, or made by a
101
- * command), so reading it never meets CSS hex or a color standing for a paint.
86
+ * The engine project in the forms the engine writes ({@link CanonicalProject}): component colors,
87
+ * tagged paints, four-sided padding and margin, `{ x, y }` offsets. Every document entering the
88
+ * editor is converted to this form, so readers never see CSS hex or a bare color as a paint.
102
89
  */
103
90
  readonly project: CanonicalProject;
104
91
  readonly metadata: EditorMetadata;
@@ -119,8 +106,8 @@ export declare class EditorError extends Error {
119
106
  */
120
107
  constructor(code: string, message: string, operation: string, entityId?: string | undefined, recoverable?: boolean, options?: ErrorOptions);
121
108
  /**
122
- * The export failure class this error is evidence of, which `classifyBrowserFailure` reads: the
123
- * editor knows what its own refusals mean. `UNKNOWN` for a code without a class.
109
+ * The export failure class this error implies, read by `classifyBrowserFailure`. `UNKNOWN` for
110
+ * a code without a class.
124
111
  */
125
112
  get failureCode(): ExportFailureCode;
126
113
  }
@@ -135,89 +122,75 @@ export type Result<T> = {
135
122
  /** Deep-freezes `value` in place and returns it. Already frozen objects are not descended into. */
136
123
  export declare function freeze<T>(value: T): T;
137
124
  /**
138
- * The deepest nesting of arrays and objects an editor document may have: the engine's for its
139
- * project ({@link MAX_JSON_DEPTH}), and one more for the document that holds it.
125
+ * The deepest array and object nesting an editor document may have: the engine's project limit
126
+ * ({@link MAX_JSON_DEPTH}) plus one for the document that holds it.
140
127
  */
141
128
  export declare const MAX_DOCUMENT_JSON_DEPTH: number;
142
129
  /**
143
- * Throws an `EditorError` (`invalid_document`) unless `value` is plain JSON: finite numbers, and
144
- * arrays and plain objects of JSON values only, nested at most `maxDepth` arrays and objects deep
145
- * ({@link MAX_DOCUMENT_JSON_DEPTH} by default).
130
+ * Throws an `EditorError` (`invalid_document`) unless `value` is plain JSON (finite numbers, arrays
131
+ * and plain objects) nested at most `maxDepth` deep ({@link MAX_DOCUMENT_JSON_DEPTH} by default).
146
132
  */
147
133
  export declare function assertJson(value: unknown, maxDepth?: number): void;
148
134
  /**
149
135
  * Throws an `EditorError` unless `document` is a valid editor document: finite JSON within the
150
- * engine and editor file size limits, a supported format and version, a project the engine
151
- * accepts, and well-formed editor metadata and assets.
136
+ * engine and editor size limits, a supported format and version, a project the engine accepts,
137
+ * and well-formed editor metadata and assets.
152
138
  */
153
139
  export declare function validateDocument(document: EditorDocument): void;
154
140
  /**
155
- * Throws the first `invalid_projection` error of `document`'s projection (the project without what
156
- * disabled tracks draw and play), so a document that opens is one the engine renders.
141
+ * Throws the first `invalid_projection` error of `document`'s projection (the project without
142
+ * disabled tracks), so a document that opens is one the engine renders.
157
143
  */
158
144
  export declare function assertProjection(document: EditorDocument): void;
159
145
  /**
160
146
  * The checks a gesture's candidate needs on every pointer move: the format and the project's
161
- * rules. What `validateDocument` adds (every value is finite JSON, the engine JSON and the editor
162
- * file fit their size limits) walks or serializes the whole document, so a gesture runs it once,
163
- * when it commits. The project's rules cost a candidate the parts its command changed:
164
- * `validateProject` reuses what it found of the frozen parts the candidate shares with the
165
- * gesture's start. Throws an `EditorError` (`unsupported_version` or `invalid_project`).
147
+ * rules. The rest of `validateDocument` walks or serializes the whole document, so a gesture runs
148
+ * it once at commit. `validateProject` reuses its results for frozen parts the candidate shares
149
+ * with the gesture's start. Throws an `EditorError` (`unsupported_version` or `invalid_project`).
166
150
  */
167
151
  export declare function validateDocumentShape(document: EditorDocument): void;
168
- /**
169
- * The largest editor file {@link parseDocument} opens. Every document that validates fits it, as
170
- * {@link serializeDocument} writes it.
171
- */
152
+ /** The largest editor file {@link parseDocument} opens; every valid document fits in it. */
172
153
  export declare const MAX_EDITOR_FILE_BYTES: number;
173
154
  /**
174
155
  * A new frozen document holding a copy of `project`, with an asset for each source and effect
175
- * resource (offline unless generated or a composition) overridden by `assets`. Throws an
156
+ * resource (offline unless generated or a composition), overridden by `assets`. Throws an
176
157
  * `EditorError` when the result does not validate.
177
158
  */
178
159
  export declare function createDocument(project: Project, assets?: EditorDocument["assets"]): EditorDocument;
179
160
  /** A new document with no media: 1920x1080 at 30 fps and 48 kHz unless `settings` say otherwise. */
180
161
  export declare function createEmptyDocument(settings?: Partial<ProjectSettings>): EditorDocument;
181
162
  /**
182
- * The editor file of `document`: compact JSON, so a document that validates is a file
183
- * {@link parseDocument} opens. Throws an `EditorError` when the document does not validate.
163
+ * Serializes `document` as compact JSON that {@link parseDocument} opens. Throws an `EditorError`
164
+ * when the document does not validate.
184
165
  */
185
166
  export declare function serializeDocument(document: EditorDocument): string;
186
167
  /**
187
- * Opens an editor file, or a bare engine project (JSON with `schema_version`) as a new document.
188
- * Returns a frozen document. Every refusal is an `EditorError`: `too_large` for a file over
189
- * {@link MAX_EDITOR_FILE_BYTES}, `invalid_document` for text that is not an editor document's JSON,
190
- * and the code of the check a document (or project) fails otherwise.
168
+ * Opens an editor file, or a bare engine project (JSON with `schema_version`) as a new document,
169
+ * frozen. Every refusal is an `EditorError`: `too_large` past {@link MAX_EDITOR_FILE_BYTES},
170
+ * `invalid_document` for text that is not an editor document, else the code of the failed check.
191
171
  */
192
172
  export declare function parseDocument(text: string): EditorDocument;
193
173
  /**
194
- * The id of `transition` on track `trackId`: the edge it joins, which a track has one transition
195
- * on. It stays the transition's own while other transitions come and go, and changes when its clips
196
- * do (a split hands an outgoing transition to the right part).
174
+ * The id of `transition` on track `trackId`: the edge it joins (a track has one transition per
175
+ * edge). It is stable while other transitions change, and changes with its clips (a split hands
176
+ * an outgoing transition to the right part).
197
177
  */
198
178
  export declare function transitionInstanceId(trackId: string, transition: Pick<ClipTransition, "from_clip" | "to_clip">): string;
199
179
  /**
200
- * `document` with its project in the forms the engine writes ({@link canonicalProject}): every
201
- * color the components object, every paint tagged, padding and margin the four sides, an offset
202
- * `{ x, y }`. Returns `document` itself when its project is already in that form, shares the parts
203
- * that are, and leaves a document of the wrong shape, or a value it cannot read, for validation to
204
- * refuse. Each place a document enters the editor puts it in this form, so the editor's own code
205
- * and its callers read one form.
180
+ * `document` with its project in the forms the engine writes ({@link canonicalProject}). Returns
181
+ * `document` itself when already canonical and shares unchanged parts. A document of the wrong
182
+ * shape is left for validation to refuse.
206
183
  */
207
184
  export declare function canonicalDocument(document: Omit<EditorDocument, "project"> & {
208
185
  readonly project: Project;
209
186
  }): EditorDocument;
210
187
  /**
211
- * `document` with an instance id for every caption cue, transition and clip mask: each track's
212
- * transitions named by {@link transitionInstanceId}; cues and masks keep the ids they have, and
213
- * those without one get a new one no other in the list has. Returns `document` itself when nothing
214
- * changes, and leaves a document of the wrong shape for validation to refuse.
188
+ * `document` with an instance id for every caption cue, transition and clip mask. Transitions are
189
+ * named by {@link transitionInstanceId}; cues and masks keep their ids and new ones get unique ids.
190
+ * Returns `document` itself when nothing changes, and leaves a malformed document for validation.
215
191
  */
216
192
  export declare function withInstanceIds(document: EditorDocument): EditorDocument;
217
- /**
218
- * A document's tracks and clips by id: of an {@link EditorDocument}, in the forms the engine writes
219
- * (`Canonical<Track>`).
220
- */
193
+ /** A document's tracks and clips by id, in the engine's canonical forms by default. */
221
194
  export interface EntityIndex<T extends Track = Canonical<Track>> {
222
195
  readonly tracks: ReadonlyMap<string, T>;
223
196
  readonly clips: ReadonlyMap<string, {
@@ -232,37 +205,31 @@ export declare function indexDocument<D extends {
232
205
  /** What the engine renders of a document. */
233
206
  export interface CompiledEditorDocument {
234
207
  /**
235
- * The project as the engine renders it: what disabled tracks draw and play left out, the mattes
236
- * enabled clips name kept (see `compileEditorDocument`).
208
+ * The project as the engine renders it: disabled tracks left out except for mattes enabled clips
209
+ * name (see `compileEditorDocument`).
237
210
  */
238
211
  readonly project: Project;
239
212
  /** The engine's validation errors for `project`, as `invalid_projection` errors. */
240
213
  readonly diagnostics: readonly EditorError[];
241
- /** The projection's JSON: equal keys render the same. Serialized on first read. */
214
+ /** The projection's JSON, serialized on first read. Equal keys render the same. */
242
215
  readonly revisionKey: string;
243
216
  }
244
217
  /**
245
- * The project the engine renders for `document`. A disabled track draws and plays nothing: it is
246
- * left out, but for the clips enabled clips name as mattes (never drawn themselves), kept on it
247
- * muted; a track that ducks under a disabled track does not duck; a clip only disabled clips name
248
- * as their matte draws nothing but still plays. Never throws for an invalid projection; the errors
249
- * are in `diagnostics`. Cached for frozen documents.
218
+ * The project the engine renders for `document`; see `projectedTracks` for how disabled tracks
219
+ * project. Never throws for an invalid projection; the errors are in `diagnostics`. Cached for
220
+ * frozen documents.
250
221
  */
251
222
  export declare function compileEditorDocument(document: EditorDocument): CompiledEditorDocument;
252
- /**
253
- * Where `project`'s timeline ends, in ticks: the end of its last clip or caption cue, 0 when it has
254
- * neither.
255
- */
223
+ /** End of `project`'s timeline in ticks: its last clip or caption cue, or 0 when empty. */
256
224
  export declare function sequenceEnd(project: Project): number;
257
225
  /**
258
- * Where `document`'s program ends, in ticks: the {@link sequenceEnd} of what the engine renders of
259
- * it ({@link compileEditorDocument}), so a disabled track adds no length. Playback without an
260
- * export range stops there, an export without one ends there, and an export range with only its
261
- * start set runs to it.
226
+ * End of `document`'s program in ticks: the {@link sequenceEnd} of its projection, so disabled
227
+ * tracks add no length. Playback and export without an export range stop there, and so does a
228
+ * range with only its start set.
262
229
  */
263
230
  export declare function programEnd(document: EditorDocument): number;
264
231
  /**
265
- * Seeds the {@link indexDocument} cache of `next` from that of `previous`, rebuilding entries only
266
- * for tracks that changed. Does nothing when `previous` has no index.
232
+ * Seeds the {@link indexDocument} cache of `next` from `previous`, rebuilding only changed tracks.
233
+ * Does nothing when `previous` has no index.
267
234
  */
268
235
  export declare function inheritDocumentIndex(previous: EditorDocument, next: EditorDocument): void;