@alpha2-sh/editor 0.5.3 → 0.6.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/README.md +58 -1
- package/dist/browser/bridge.js +275 -52
- package/dist/browser/jobs.d.ts +17 -0
- package/dist/browser/jobs.js +40 -0
- package/dist/browser/resources.d.ts +9 -4
- package/dist/browser/resources.js +17 -5
- package/dist/browser/runtime/assets.d.ts +14 -2
- package/dist/browser/runtime/assets.js +37 -27
- package/dist/browser/runtime/audio.d.ts +12 -2
- package/dist/browser/runtime/audio.js +124 -14
- package/dist/browser/runtime/engine.js +8 -1
- package/dist/browser/runtime/exporter.d.ts +2 -1
- package/dist/browser/runtime/exporter.js +15 -4
- package/dist/browser/runtime/preview-utils.d.ts +12 -0
- package/dist/browser/runtime/preview-utils.js +45 -0
- package/dist/browser/runtime/sources.js +11 -34
- package/dist/browser/types.d.ts +105 -19
- package/dist/browser/worker.d.ts +4 -2
- package/dist/browser/worker.js +73 -24
- package/dist/core/commands.d.ts +46 -3
- package/dist/core/commands.js +212 -40
- package/dist/core/compositions.d.ts +27 -0
- package/dist/core/compositions.js +43 -0
- package/dist/core/data.d.ts +34 -0
- package/dist/core/data.js +69 -0
- package/dist/core/document.d.ts +10 -1
- package/dist/core/document.js +127 -6
- package/dist/core/keyframes.d.ts +3 -2
- package/dist/core/keyframes.js +6 -2
- package/dist/core/sameness.d.ts +6 -0
- package/dist/core/sameness.js +42 -0
- package/dist/core/session.d.ts +85 -7
- package/dist/core/session.js +124 -13
- package/dist/index.d.ts +1 -0
- package/dist/index.js +1 -0
- package/dist/native-client/index.d.ts +2 -2
- package/dist/native-client/index.js +2 -2
- package/dist/ports/index.d.ts +5 -4
- package/package.json +3 -3
package/README.md
CHANGED
|
@@ -31,11 +31,68 @@ editor.dispose();
|
|
|
31
31
|
```
|
|
32
32
|
|
|
33
33
|
- An editor document holds an engine project (`document.project`), the editor's metadata, and a descriptor of each asset. `serializeDocument` and `parseDocument` write and read it as JSON; `parseDocument` also reads a plain engine project.
|
|
34
|
-
- `dispatch` applies one `Command` (the typed union covers the project, tracks, clips, effects, transitions, caption cues, composition graphs, assets and markers); a `transaction` applies several and is checked once, by the document it ends with. A command the document's rules refuse returns `{ ok: false, error }` and changes nothing. `canExecute` asks without applying.
|
|
34
|
+
- `dispatch` applies one `Command` (the typed union covers the project, tracks, clips, effects, transitions, caption cues, composition graphs, assets, data sets and markers); a `transaction` applies several and is checked once, by the document it ends with. A command the document's rules refuse returns `{ ok: false, error }` and changes nothing. `canExecute` asks without applying.
|
|
35
35
|
- Every change that commits is one undo step. The history keeps up to 120 steps and 64 MiB by default (`createEditor({ historyLimit, historyByteLimit })`).
|
|
36
36
|
- `beginGesture()` previews a drag: each `update(command)` shows a candidate in `editor.draft` without touching the document or the history, and `commit()` adds one undo step (`cancel()` adds none).
|
|
37
37
|
- `subscribe`, `getSnapshot` and `subscribeSelector` notify views of changes. A refusal is an `EditorError`, whose `code` says which check failed.
|
|
38
38
|
|
|
39
|
+
## Data sets
|
|
40
|
+
|
|
41
|
+
A project's data sets (tracking points, levels, words, intervals an extractor returned) are changed by commands, so adding one and binding to it is one undo step.
|
|
42
|
+
|
|
43
|
+
```js
|
|
44
|
+
import { dataValue } from "@alpha2-sh/editor";
|
|
45
|
+
|
|
46
|
+
editor.dispatch({
|
|
47
|
+
type: "transaction",
|
|
48
|
+
commands: [
|
|
49
|
+
{ type: "data.put", dataSet: faceTrack }, // replaces the set with its id in place
|
|
50
|
+
{
|
|
51
|
+
type: "clip.update",
|
|
52
|
+
id: "title",
|
|
53
|
+
patch: { visual: { position: dataValue({ data: faceTrack.id, channel: "face", via: { clip: "interview" }, space: "canvas" }) } },
|
|
54
|
+
},
|
|
55
|
+
],
|
|
56
|
+
});
|
|
57
|
+
```
|
|
58
|
+
|
|
59
|
+
- `data.remove` is refused with `data_referenced` while anything reads the set; `error.details.references` lists the places (`dataReferences` from `alpha2/project` lists them for any project). `asset.remove`, `clip.delete` and `track.remove` are refused the same way while a data set is anchored to the source or a binding reads through the clip.
|
|
60
|
+
- Timeline commands keep data consistent as the engine's edit operations do: a ripple that reaches every track (every other track sync-locked) cuts or opens timeline-anchored sets with the timeline, a split points the right part's bindings that read through the clip at the new part, and a pasted clip's bindings through itself read through its new id. Source-anchored sets never change.
|
|
61
|
+
- Keyframe helpers throw `data_bound` on a value that follows data (`isDataBound`).
|
|
62
|
+
- A replaced set is held whole in the undo history, so a put of a set near `MAX_DATA_VALUES` can evict most of it under the 64 MiB default.
|
|
63
|
+
|
|
64
|
+
## Edit operations
|
|
65
|
+
|
|
66
|
+
The engine's edit operations (`remove_ranges`, `split_at`, `bake`) run in the runtime you already have; the session applies the result as one undo step, refusing it (`stale_edit`) when the document changed after the project was read.
|
|
67
|
+
|
|
68
|
+
```js
|
|
69
|
+
// Desktop: @alpha2-sh/node computes, no WebAssembly in the app.
|
|
70
|
+
const request = { op: "remove_ranges", ranges: { data: "silence" }, target: { track: "v1" } };
|
|
71
|
+
const { project, read } = editor.editProject();
|
|
72
|
+
const applied = await client.edit(project, request);
|
|
73
|
+
const result = editor.applyEdit(applied, { read, request }); // { document, report }
|
|
74
|
+
|
|
75
|
+
// Bake a binding and drop its data set in the same step.
|
|
76
|
+
editor.applyEdit(baked, { read, request: bakeRequest, then: [{ type: "data.remove", id: "face" }] });
|
|
77
|
+
```
|
|
78
|
+
|
|
79
|
+
- In a page, `bridge.applyEdit(request, { then, label })` does all of it with the bridge's own engine and waits for the engine to load.
|
|
80
|
+
- Refusals (`unknown_data`, `nothing_to_bake`, ...) come from the engine call itself. Clips the operation creates keep the editor metadata of the clip they were cut from (`report.created[].from`).
|
|
81
|
+
- A step applied with a label (by default the operation's name) shows it as `snapshot.undoLabel` and `snapshot.redoLabel`.
|
|
82
|
+
|
|
83
|
+
## Extraction
|
|
84
|
+
|
|
85
|
+
Extractors run in the runtime too; the session puts their data sets in as one undo step. A timeline-anchored result is refused (`stale_extraction`) when the timeline changed while the extractor ran; data put in between does not count.
|
|
86
|
+
|
|
87
|
+
```js
|
|
88
|
+
const { project, read } = editor.extractionProject();
|
|
89
|
+
const { dataSets } = await client.extract({ project, assets, request, plugin: { manifest, sha256 } });
|
|
90
|
+
editor.applyExtraction({ dataSets, timings: {} }, { read });
|
|
91
|
+
```
|
|
92
|
+
|
|
93
|
+
- In a page, `bridge.extract(run, { plugin, signal, onProgress })` reads the source's original media held by the bridge and resolves with `{ result, read }` for `applyExtraction`. It reads source input; timeline input is refused there.
|
|
94
|
+
- `bridge.conform()` lists data sets made from media that has since changed in `stale_data`; their `made_by` says how to run them again.
|
|
95
|
+
|
|
39
96
|
## Browser bridge
|
|
40
97
|
|
|
41
98
|
`@alpha2-sh/editor/browser` connects a session to the engine in the browser: import, preview, playback with audio, and export to an MP4, MOV, MKV or WebM file through WebCodecs.
|