@mengine/medeo-client 2.1.1-dsl.7 → 2.1.1-dsl.9
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 +10 -9
- package/dist/{dsl-DbYqFFOb.js → dsl-COyzz7Fp.js} +622 -298
- package/dist/dsl.d.ts +2 -2
- package/dist/dsl.js +2 -2
- package/dist/{index-DHcMMn2M.d.ts → index-C5wDKYqC.d.ts} +60 -35
- package/dist/{index-Cx5DojM1.d.ts → index-CHiPztZr.d.ts} +22 -7
- package/dist/{index-Dpl4bT94.d.ts → index-DAfOkcnZ.d.ts} +1 -1
- package/dist/index.d.ts +4 -4
- package/dist/index.js +2 -2
- package/dist/legacy.d.ts +2 -2
- package/dist/legacy.js +1 -1
- package/dist/testing.d.ts +2 -2
- package/dist/testing.js +4 -7
- package/dist/{video-draft-types-Ce8NDenQ.js → video-draft-types-BnbfWrBx.js} +64 -42
- package/dist/{video-draft-types-Bq15tPBP.d.ts → video-draft-types-GqXnsOzA.d.ts} +69 -21
- package/package.json +4 -4
package/README.md
CHANGED
|
@@ -44,13 +44,14 @@ Reopening uses the stored Loro history and the server's version vector to derive
|
|
|
44
44
|
- Placement: sequential, absolute or anchored. Reordering and replacement require an explicit associated-content policy.
|
|
45
45
|
- Voiceover: `applyVoiceover` consumes materialized recording/script/caption results in one commit. Upload, ASR and TTS belong to the host.
|
|
46
46
|
- BGM: `setBgm` requires full resource facts and explicitly fills the Timeline; trim/speed are not enabled.
|
|
47
|
-
-
|
|
47
|
+
- AudioScript: segmented text; segments are inserted, moved and deleted by id, each with its own native Text.
|
|
48
|
+
- Caption: independent native Text or a selection of one script segment (whole, or a Cursor run inside it); style and source switching.
|
|
48
49
|
|
|
49
50
|
`resolveDslLayout`, `toVideoDraft`, `fromVideoDraft`, `MedeoDsl` and the model types are exported from the root and `/dsl`. Projection returns diagnostics; unrepresentable legacy output throws `DslProjectionError`. `MengineHttpClient.fetchDraft()` / `fetchDraftAt(seq)` read the server's content, diagnostics and matching version.
|
|
50
51
|
|
|
51
52
|
## The DSL document
|
|
52
53
|
|
|
53
|
-
The live document lives here: `src/dsl/document` holds the `MedeoDsl` handle, transactions, draft guards and native reads; `src/dsl/projection` holds layout solving, VideoDraft conversion and the generated IDL types. Definitions, the Loro schema and change constraints come from the private `@mengine/medeo-dsl` and are re-exported by name, so the published API does not grow when the DSL does. Transactions ask the DSL's constraint functions; only what needs a live Loro document —
|
|
54
|
+
The live document lives here: `src/dsl/document` holds the `MedeoDsl` handle, transactions, draft guards and native reads; `src/dsl/projection` holds layout solving, VideoDraft conversion and the generated IDL types. Definitions, the Loro schema and change constraints come from the private `@mengine/medeo-dsl` and are re-exported by name, so the published API does not grow when the DSL does. Transactions ask the DSL's constraint functions; only what needs a live Loro document — selections of a segment's current text, Tree identities, Mirror's K03 limit — is checked here. See [RFC 04](../../docs/projects/medeo-dsl/rfc/04-entity-relation-to-loro-mapping.md).
|
|
54
55
|
|
|
55
56
|
### Using the editor
|
|
56
57
|
|
|
@@ -86,10 +87,10 @@ dsl.dispose();
|
|
|
86
87
|
- `getSnapshot()` returns a frozen, read-only `MedeoDslSnapshot`: entity tables, the voice-timbre and derived-from relation tables, effective containment, rich-text runs, resolved Caption text and diagnostics. A relation an entity holds at most one of is a field of its row: a Clip's `source` and `anchor`, a Caption's `selection`, a PhoneticScript's `phoneme`. An unreadable optional field is dropped from the row with a diagnostic; the row stays. A Caption's own text wins over its selection when a merge leaves both. It does not compute layout or VideoDraft. Reads reuse the same snapshot until a DSL content event invalidates it; no-op Actions and repeated imports retain it. Reading never commits changes.
|
|
87
88
|
- `subscribe(listener)` includes text-only and marks-only changes. The returned function unsubscribes; dispose is idempotent. As with other synchronous document observers, listeners should not throw or initiate nested writes.
|
|
88
89
|
- `applyMutations(mutations, audit)` is the preferred interface for typed entity, relation, Tree, Text and Caption-selection commands. It opens one `transact`; `tx.applyMutations` inside an existing callback uses the same draft and commit.
|
|
89
|
-
- `transact(edit, audit)` exposes a guarded `tx.draft` for ordinary fields and Tree, `tx.editText(scriptId, edits, expectedBodyId?)`, `tx.editCaptionText(captionId, edits, expectedBodyId?)`,
|
|
90
|
-
- `editText(scriptId, expectedBodyId, edits, audit)` delegates to the same transaction. Text supports insert/delete/mark/unmark/editing Delta; offsets are UTF-16 and cannot split surrogate pairs. `tx.draft` exposes the text preview after preceding edits, while existing body strings are never sent through Mirror's full-text diff. A supplied body identity must match the current Text; Actions editing an existing body retain that stale-view check.
|
|
90
|
+
- `transact(edit, audit)` exposes a guarded `tx.draft` for ordinary fields and Tree, `tx.editText(scriptId, segmentId, edits, expectedBodyId?)`, `tx.editCaptionText(captionId, edits, expectedBodyId?)`, `tx.insertSegment` / `tx.moveSegment` / `tx.deleteSegment`, `tx.setCaptionContent({captionId, audioScriptId, segmentId, start?, end?})` and `tx.setPhoneme({phoneticScriptId, audioScriptId, segmentId, start?, end?, phonemeScript?})`. The synchronous callback and every draft reference expire on return. Async callbacks, nested writes, identity changes, direct overwrites of existing bodies, and same-transaction entity deletion/recreation are rejected. Catching a guard/command error inside the callback does not allow a partial commit.
|
|
91
|
+
- `editText(scriptId, segmentId, expectedBodyId, edits, audit)` delegates to the same transaction. Text supports insert/delete/mark/unmark/editing Delta; offsets are UTF-16 and cannot split surrogate pairs. `tx.draft` exposes the text preview after preceding edits, while existing body strings are never sent through Mirror's full-text diff. A supplied body identity must match the current Text; Actions editing an existing body retain that stale-view check.
|
|
91
92
|
- Caption selections are interpreted at their position in the command sequence. Their Cursors are created after earlier native edits, and follow later edits. New selections are deferred commands, not synthetic Cursor values in `tx.draft`; do not read a Caption's `selection` from the draft to retrieve a pending one. Explicit Cursor values written to `selection`, and its removal, also replay in sequence with Text edits.
|
|
92
|
-
- `textRange(scriptId, start, end)` returns native Cursors for a nonempty
|
|
93
|
+
- `textRange(scriptId, segmentId, start, end)` returns native Cursors for a nonempty run inside one segment. A Caption's `selection` stores their native bytes through the central codec. The permanent first-boundary limitation remains deferred.
|
|
93
94
|
|
|
94
95
|
Every business write requires a structured `DslAudit`: `{semantic_op, payload, intent?, actor?}`. The transaction exit serializes the existing server envelope exactly once; initialization alone uses an internal unaudited path. No-op transactions add no history. External pending native operations must be committed separately first. Known preparation failures write nothing; unexpected native/runtime failures do not receive database-style rollback.
|
|
95
96
|
|
|
@@ -101,11 +102,11 @@ const audit = {
|
|
|
101
102
|
};
|
|
102
103
|
|
|
103
104
|
dsl.transact((tx) => {
|
|
104
|
-
tx.draft['audio-script-entities']['script-1'] = {
|
|
105
|
+
tx.draft['audio-script-entities']['script-1'] = { segments: [{ id: 'segment-1', text: 'hello' }] };
|
|
105
106
|
tx.draft['caption-entities']['caption-1'] = {};
|
|
106
|
-
tx.editText('script-1', [{ type: 'insert', at: 5, text: ' world' }]);
|
|
107
|
+
tx.editText('script-1', 'segment-1', [{ type: 'insert', at: 5, text: ' world' }]);
|
|
107
108
|
// Reads the prepared preview: "hello world". The native Text does not yet exist.
|
|
108
|
-
tx.setCaptionContent({ captionId: 'caption-1', audioScriptId: 'script-1', start: 0, end: 5 });
|
|
109
|
+
tx.setCaptionContent({ captionId: 'caption-1', audioScriptId: 'script-1', segmentId: 'segment-1', start: 0, end: 5 });
|
|
109
110
|
}, audit);
|
|
110
111
|
```
|
|
111
112
|
|
|
@@ -153,7 +154,7 @@ try {
|
|
|
153
154
|
|
|
154
155
|
Caption text is matched forward in `speech.caption_ids` order. A failed exact match preserves the text in the Caption's own optional **LoroText**, without advancing the match cursor or inventing another AudioScript. Inline text is also available through `DslEditor.createCaption({text, style?})`, `setCaptionText`, and `editCaptionText`. Switching to a reference clears the inline field in the same transaction; direct `transact` callers must clear the other source explicitly. Concurrent coexistence reads the reference, even when it later becomes invalid (no stale-text fallback).
|
|
155
156
|
|
|
156
|
-
`richText` is keyed by
|
|
157
|
+
`richText` is keyed by script segment ID or inline Caption entity ID; `captionText` resolves either content source and `phoneticText` what each PhoneticScript selects. Optional Caption Texts have ordinary identities and are created in the native hook, preserving mergeable style/font while avoiding duplicate text on mergeable-Text deletion Undo. See [RFC 02](../../docs/projects/medeo-dsl/rfc/02-videodraft-projection.md) for layout, import normalization and compatibility limits.
|
|
157
158
|
|
|
158
159
|
## Legacy consumers
|
|
159
160
|
|