@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.
- package/dist/browser/bridge.d.ts +15 -16
- package/dist/browser/bridge.js +393 -312
- package/dist/browser/extensions-worker.d.ts +12 -16
- package/dist/browser/extensions-worker.js +17 -24
- package/dist/browser/hash-worker.d.ts +4 -5
- package/dist/browser/hash-worker.js +7 -8
- package/dist/browser/jobs.d.ts +17 -19
- package/dist/browser/jobs.js +41 -28
- package/dist/browser/resources.d.ts +6 -11
- package/dist/browser/resources.js +5 -9
- package/dist/browser/runtime/assets.d.ts +52 -28
- package/dist/browser/runtime/assets.js +136 -45
- package/dist/browser/runtime/audio.d.ts +16 -11
- package/dist/browser/runtime/audio.js +102 -59
- package/dist/browser/runtime/budget.d.ts +4 -5
- package/dist/browser/runtime/budget.js +4 -5
- package/dist/browser/runtime/caption-fonts.d.ts +3 -7
- package/dist/browser/runtime/caption-fonts.js +4 -8
- package/dist/browser/runtime/engine.d.ts +44 -44
- package/dist/browser/runtime/engine.js +87 -64
- package/dist/browser/runtime/export-audio.d.ts +6 -6
- package/dist/browser/runtime/export-audio.js +8 -9
- package/dist/browser/runtime/exporter.d.ts +33 -66
- package/dist/browser/runtime/exporter.js +111 -137
- package/dist/browser/runtime/extension-import.d.ts +28 -35
- package/dist/browser/runtime/extension-import.js +36 -46
- package/dist/browser/runtime/fingerprint.d.ts +11 -14
- package/dist/browser/runtime/fingerprint.js +20 -24
- package/dist/browser/runtime/generators.d.ts +2 -3
- package/dist/browser/runtime/generators.js +5 -7
- package/dist/browser/runtime/locks.d.ts +5 -7
- package/dist/browser/runtime/locks.js +5 -7
- package/dist/browser/runtime/output.d.ts +7 -9
- package/dist/browser/runtime/output.js +17 -21
- package/dist/browser/runtime/preview-utils.js +10 -6
- package/dist/browser/runtime/proxies.d.ts +19 -19
- package/dist/browser/runtime/proxies.js +72 -51
- package/dist/browser/runtime/proxy-storage.d.ts +15 -19
- package/dist/browser/runtime/proxy-storage.js +20 -24
- package/dist/browser/runtime/sources.d.ts +23 -31
- package/dist/browser/runtime/sources.js +85 -103
- package/dist/browser/runtime/staging.d.ts +2 -6
- package/dist/browser/runtime/staging.js +7 -11
- package/dist/browser/runtime/still.d.ts +2 -6
- package/dist/browser/runtime/still.js +6 -12
- package/dist/browser/runtime/text.d.ts +14 -0
- package/dist/browser/runtime/text.js +27 -0
- package/dist/browser/runtime/wasm.d.ts +4 -5
- package/dist/browser/runtime/wasm.js +4 -5
- package/dist/browser/types.d.ts +244 -239
- package/dist/browser/worker.d.ts +10 -10
- package/dist/browser/worker.js +64 -22
- package/dist/core/captions.d.ts +8 -10
- package/dist/core/captions.js +10 -18
- package/dist/core/clip-time.d.ts +8 -10
- package/dist/core/clip-time.js +12 -15
- package/dist/core/commands.d.ts +46 -46
- package/dist/core/commands.js +38 -36
- package/dist/core/compositions.d.ts +78 -112
- package/dist/core/compositions.js +66 -94
- package/dist/core/document.d.ts +59 -92
- package/dist/core/document.js +65 -90
- package/dist/core/keyframes.d.ts +11 -12
- package/dist/core/keyframes.js +11 -13
- package/dist/core/presets.d.ts +14 -20
- package/dist/core/presets.js +12 -18
- package/dist/core/session.d.ts +26 -38
- package/dist/core/session.js +38 -53
- package/dist/core/text.d.ts +2 -3
- package/dist/core/text.js +2 -3
- package/dist/core/timeline-index.d.ts +2 -3
- package/dist/core/timeline-index.js +11 -7
- package/dist/core/transitions.js +4 -5
- package/dist/core/validated.d.ts +6 -7
- package/dist/core/validated.js +8 -11
- package/dist/native-client/index.d.ts +31 -32
- package/dist/native-client/index.js +40 -41
- package/dist/ports/index.d.ts +19 -20
- package/dist/react/index.d.ts +5 -6
- package/dist/react/index.js +5 -6
- package/package.json +4 -4
package/dist/core/document.d.ts
CHANGED
|
@@ -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
|
|
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
|
-
/**
|
|
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
|
|
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
|
|
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
|
-
/**
|
|
46
|
+
/** Timeline ticks. */
|
|
55
47
|
readonly time: number;
|
|
56
|
-
/**
|
|
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
|
|
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
|
|
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
|
|
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
|
-
/**
|
|
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
|
|
99
|
-
*
|
|
100
|
-
*
|
|
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
|
|
123
|
-
*
|
|
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
|
|
139
|
-
*
|
|
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
|
|
144
|
-
*
|
|
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
|
|
151
|
-
*
|
|
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
|
|
156
|
-
* disabled tracks
|
|
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.
|
|
162
|
-
*
|
|
163
|
-
*
|
|
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
|
-
*
|
|
183
|
-
*
|
|
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
|
-
*
|
|
189
|
-
*
|
|
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
|
|
195
|
-
*
|
|
196
|
-
*
|
|
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})
|
|
201
|
-
*
|
|
202
|
-
*
|
|
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
|
|
212
|
-
*
|
|
213
|
-
*
|
|
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:
|
|
236
|
-
*
|
|
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
|
|
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
|
|
246
|
-
*
|
|
247
|
-
*
|
|
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
|
-
*
|
|
259
|
-
*
|
|
260
|
-
*
|
|
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
|
|
266
|
-
*
|
|
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;
|