@mengine/medeo-client 2.1.1-dsl.1 → 2.1.1-dsl.11

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.
@@ -1,6 +1,6 @@
1
- import { G as ResourceSystem, et as TrackRole, z as MedeoDslSnapshot } from "./video-draft-types-c_shaRyq.js";
2
- import { _ as MedeoDsl, f as DslEditor, i as VideoDraftProjection } from "./index-Cu7SdKN5.js";
3
- import { a as MengineDocSessionOptions, h as ManualSyncTransport, m as ManualSyncDocOptions, n as DocumentSession, r as DocumentSessionUpdateEvent } from "./index-B7fC7q7P.js";
1
+ import { G as ResourceSystem, R as MedeoDslSnapshot, rt as TrackRole } from "./video-draft-types-GqXnsOzA.js";
2
+ import { b as MedeoDsl, h as UploadText, i as AudioScriptView, m as DslEditor, o as VideoDraftProjection } from "./index-DSpKN_ta.js";
3
+ import { _ as ManualSyncTransport, a as MengineDocSessionOptions, g as ManualSyncDocOptions, n as DocumentSession, r as DocumentSessionUpdateEvent } from "./index-DAfOkcnZ.js";
4
4
 
5
5
  //#region src/manual-sync/manual-sync-doc.d.ts
6
6
  /** Explicit synchronization over the same DSL/editor used by the live Session. */
@@ -8,7 +8,10 @@ declare class ManualSyncDoc extends ManualSyncTransport {
8
8
  readonly dsl: MedeoDsl;
9
9
  readonly editor: DslEditor;
10
10
  private constructor();
11
- static open(options: ManualSyncDocOptions): Promise<ManualSyncDoc>;
11
+ /** `uploadText` stores raw content the editor writes, such as a PhoneticScript's text, in Memota. */
12
+ static open(options: ManualSyncDocOptions & {
13
+ uploadText?: UploadText;
14
+ }): Promise<ManualSyncDoc>;
12
15
  snapshot(): {
13
16
  readonly "timeline-entities": {
14
17
  readonly [x: string]: {
@@ -30,6 +33,12 @@ declare class ManualSyncDoc extends ManualSyncTransport {
30
33
  readonly fillTimeline?: true | undefined;
31
34
  };
32
35
  readonly volume?: number | undefined;
36
+ readonly source: string;
37
+ readonly anchor?: {
38
+ readonly to: string;
39
+ readonly offsetMs: number;
40
+ readonly fallback_abs_ms: number;
41
+ } | undefined;
33
42
  };
34
43
  };
35
44
  readonly "media-entities": {
@@ -57,12 +66,36 @@ declare class ManualSyncDoc extends ManualSyncTransport {
57
66
  };
58
67
  readonly "audio-script-entities": {
59
68
  readonly [x: string]: {
60
- readonly body: string;
69
+ readonly segments: readonly {
70
+ readonly id: string;
71
+ readonly text: string;
72
+ }[];
61
73
  readonly defaultLanguage?: string | undefined;
62
74
  };
63
75
  };
76
+ readonly "phonetic-script-entities": {
77
+ readonly [x: string]: {
78
+ readonly phoneme: {
79
+ readonly phonemeScript?: string | undefined;
80
+ readonly audioScriptId: string;
81
+ readonly segmentId: string;
82
+ readonly start?: import("loro-crdt").Cursor | undefined;
83
+ readonly end?: import("loro-crdt").Cursor | undefined;
84
+ };
85
+ readonly system?: "memota" | undefined;
86
+ readonly key?: string | undefined;
87
+ readonly storageKey?: string | undefined;
88
+ readonly digest?: string | undefined;
89
+ };
90
+ };
64
91
  readonly "caption-entities": {
65
92
  readonly [x: string]: {
93
+ readonly selection?: {
94
+ readonly audioScriptId: string;
95
+ readonly segmentId: string;
96
+ readonly start?: import("loro-crdt").Cursor | undefined;
97
+ readonly end?: import("loro-crdt").Cursor | undefined;
98
+ } | undefined;
66
99
  readonly text?: string | undefined;
67
100
  readonly style?: {
68
101
  readonly font?: {
@@ -88,44 +121,6 @@ declare class ManualSyncDoc extends ManualSyncTransport {
88
121
  readonly name?: string | undefined;
89
122
  };
90
123
  };
91
- readonly "asset-entities": {
92
- readonly [x: string]: {
93
- readonly system: ResourceSystem;
94
- readonly key: string;
95
- readonly storageKey?: string | undefined;
96
- readonly digest?: string | undefined;
97
- };
98
- };
99
- readonly "clip-source-relations": {
100
- readonly [x: string]: {
101
- readonly clipId: string;
102
- readonly sourceId: string;
103
- };
104
- };
105
- readonly "time-anchor-relations": {
106
- readonly [x: string]: {
107
- readonly from: string;
108
- readonly to: string;
109
- readonly offsetMs: number;
110
- readonly fallback_abs_ms: number;
111
- };
112
- };
113
- readonly "caption-content-relations": {
114
- readonly [x: string]: {
115
- readonly captionId: string;
116
- readonly audioScriptId: string;
117
- readonly start: import("loro-crdt").Cursor;
118
- readonly end: import("loro-crdt").Cursor;
119
- };
120
- };
121
- readonly "caption-alignment-relations": {
122
- readonly [x: string]: {
123
- readonly captionId: string;
124
- readonly mediaId: string;
125
- readonly startMs: number;
126
- readonly endMs: number;
127
- };
128
- };
129
124
  readonly "voice-timbre-relations": {
130
125
  readonly [x: string]: {
131
126
  readonly recordingId: string;
@@ -136,18 +131,7 @@ declare class ManualSyncDoc extends ManualSyncTransport {
136
131
  readonly [x: string]: {
137
132
  readonly entityId: string;
138
133
  readonly sourceId: string;
139
- };
140
- };
141
- readonly "from-asset-relations": {
142
- readonly [x: string]: {
143
- readonly audioScriptId: string;
144
- readonly assetId: string;
145
- };
146
- };
147
- readonly "to-asset-relations": {
148
- readonly [x: string]: {
149
- readonly audioScriptId: string;
150
- readonly assetId: string;
134
+ readonly sourceDigest?: string | undefined;
151
135
  };
152
136
  };
153
137
  readonly 'contain-relations': readonly {
@@ -175,6 +159,14 @@ declare class ManualSyncDoc extends ManualSyncTransport {
175
159
  readonly bodyId: string;
176
160
  };
177
161
  };
162
+ readonly phoneticText: {
163
+ readonly [x: string]: {
164
+ readonly text: string;
165
+ readonly start: number;
166
+ readonly end: number;
167
+ readonly bodyId: string;
168
+ };
169
+ };
178
170
  readonly diagnostics: readonly {
179
171
  readonly code: string;
180
172
  readonly path: string;
@@ -189,9 +181,14 @@ declare class ManualSyncDoc extends ManualSyncTransport {
189
181
  type MengineDocSessionUpdateEvent = DocumentSessionUpdateEvent<MedeoDslSnapshot>;
190
182
  /** Default collaborative session: one DSL handle and one editor over the synchronized LoroDoc. */
191
183
  declare class MengineDocSession extends DocumentSession<MedeoDslSnapshot, DslEditor, MedeoDsl> {
192
- constructor(options: MengineDocSessionOptions);
184
+ /** `uploadText` stores raw content the editor writes, such as a PhoneticScript's text, in Memota. */
185
+ constructor(options: MengineDocSessionOptions & {
186
+ uploadText?: UploadText;
187
+ });
193
188
  get dsl(): MedeoDsl;
194
189
  projectVideoDraft(): VideoDraftProjection;
190
+ /** The document's AudioScripts with what says and shows them; read from the same snapshot as the VideoDraft. */
191
+ projectAudioScripts(): AudioScriptView[];
195
192
  }
196
193
  //#endregion
197
194
  export { MengineDocSessionUpdateEvent as n, ManualSyncDoc as r, MengineDocSession as t };
package/dist/index.d.ts CHANGED
@@ -1,5 +1,5 @@
1
- import { $ as Track, A as ContainNode, B as Media, C as Caption, D as CaptionText, E as CaptionStyle, F as EntityTable, G as ResourceSystem, H as RelationTable, I as EntityTables, J as TextEdit, K as RichTextSnapshot, L as EntityValues, M as DslDiagnostic, N as DslMutation, O as Clip, P as EntityMutation, Q as TimeAnchor, R as FieldPatch, S as AudioScript, T as CaptionSelection, U as RelationTables, V as RelationMutation, W as RelationValues, X as TextMutation, Y as TextMark, Z as TextRun, _ as defaultIdFactory, a as VideoDraftCaptionStyle, b as tupleHash, c as VideoDraftInput, d as VideoDraftTrack, et as TrackRole, f as VideoDraftTrackItem, g as EntityIdKind, h as DslIdFactory, i as VideoDraft, j as DeepReadonly, k as ContainMutation, l as VideoDraftPartUnion, m as OpActor, n as DEFAULT_UNIT_TIME_MS, o as VideoDraftContent, p as CommitOptions, q as TextDelta, r as VideoCreationSettings, s as VideoDraftContentPartUnion, t as CaptionDisplayCue, tt as Voice, u as VideoDraftTimeline, v as relationId, w as CaptionContent, x as Asset, y as resourceId, z as MedeoDslSnapshot } from "./video-draft-types-c_shaRyq.js";
2
- import { A as AddDslClip, C as MedeoDslDraft, D as captionContentCodec, E as InvalidAtomic, F as ReplaceDslClipsInput, I as ClipPlacement, M as ClipSource, N as DslClipUpdate, O as isInvalidAtomic, P as MoveDslClipsInput, S as documentFormat, T as medeoDslLoroShape, _ as MedeoDsl, a as toVideoDraft, b as UnsupportedDocumentFormatError, c as DslLayout, d as createInitialMedeoDsl, f as DslEditor, g as CreateMedeoDslOptions, h as VoiceoverResult, i as VideoDraftProjection, j as AddDslClipsInput, k as timeAnchorCodec, l as DslProjectionError, m as VoiceoverCaptionInput, n as ImportedVideoDraft, o as resolveDslLayout, p as ApplyVoiceoverInput, r as fromVideoDraft, s as DslClipLayout, t as FromVideoDraftOptions, u as DslTrackLayout, v as DslAudit, w as MedeoDslLoroState, x as assertDslDocument, y as DslTransaction } from "./index-Cu7SdKN5.js";
3
- import { A as MengineAuditResponse, B as base64ToBytes, C as MengineEventStreamOptions, D as MengineHttpRequestError, E as MengineHttpClientOptions, F as MengineRejectedResponse, I as MengineSnapshotResponse, L as MengineSseUpdateEvent, M as MengineDraftResponse, N as MenginePushResponse, O as MenginePushRejectedError, P as MenginePushUpdateResponse, R as MengineSyncResponse, S as PushResultKind, T as MengineHttpClient, V as bytesToBase64, _ as encodeDocVersionMark, a as MengineDocSessionOptions, b as PullResult, c as DocStorageLike, d as MedeoHttpDocStorageOptions, f as PushOutcome, g as decodeDocVersionMark, i as MengineAckFailedError, j as MengineDocumentVersion, k as MengineAuditEntry, l as MengineUndoState, m as ManualSyncDocOptions, o as MengineDocSyncState, p as PushOutcomeKind, s as WaitForServerAckOptions, t as MemoryDocStorage, u as MedeoHttpDocStorage, v as DocVersionMark, w as readMengineEventStream, x as PushResult, y as PullFailureReason, z as MengineUpdateMeta } from "./index-B7fC7q7P.js";
4
- import { n as MengineDocSessionUpdateEvent, r as ManualSyncDoc, t as MengineDocSession } from "./index-yifEtZSP.js";
5
- export { type AddDslClip, type AddDslClipsInput, type ApplyVoiceoverInput, type Asset, type AudioScript, type Caption, type CaptionContent, type CaptionDisplayCue, type CaptionSelection, type CaptionStyle, type CaptionText, type Clip, type ClipPlacement, type ClipSource, type CommitOptions, type ContainMutation, type ContainNode, type CreateMedeoDslOptions, DEFAULT_UNIT_TIME_MS, type DeepReadonly, type DocStorageLike, type DocVersionMark, type DslAudit, type DslClipLayout, type DslClipUpdate, type DslDiagnostic, DslEditor, type DslIdFactory, type DslLayout, type DslMutation, DslProjectionError, type DslTrackLayout, type DslTransaction, type EntityIdKind, type EntityMutation, type EntityTable, type EntityTables, type EntityValues, type FieldPatch, type FromVideoDraftOptions, type ImportedVideoDraft, type InvalidAtomic, ManualSyncDoc, type ManualSyncDocOptions, MedeoDsl, type MedeoDslDraft, type MedeoDslLoroState, type MedeoDslSnapshot, MedeoHttpDocStorage, type MedeoHttpDocStorageOptions, type Media, MemoryDocStorage, MengineAckFailedError, type MengineAuditEntry, type MengineAuditResponse, MengineDocSession, type MengineDocSessionOptions, type MengineDocSessionUpdateEvent, type MengineDocSyncState, type MengineDocumentVersion, type MengineDraftResponse, type MengineEventStreamOptions, MengineHttpClient, type MengineHttpClientOptions, MengineHttpRequestError, MenginePushRejectedError, type MenginePushResponse, type MenginePushUpdateResponse, type MengineRejectedResponse, type MengineSnapshotResponse, type MengineSseUpdateEvent, type MengineSyncResponse, type MengineUndoState, type MengineUpdateMeta, type MoveDslClipsInput, type OpActor, type PullFailureReason, type PullResult, type PushOutcome, type PushOutcomeKind, type PushResult, type PushResultKind, type RelationMutation, type RelationTable, type RelationTables, type RelationValues, type ReplaceDslClipsInput, type ResourceSystem, type RichTextSnapshot, type TextDelta, type TextEdit, type TextMark, type TextMutation, type TextRun, type TimeAnchor, type Track, type TrackRole, UnsupportedDocumentFormatError, type VideoCreationSettings, type VideoDraft, type VideoDraftCaptionStyle, type VideoDraftContent, type VideoDraftContentPartUnion, type VideoDraftInput, type VideoDraftPartUnion, type VideoDraftProjection, type VideoDraftTimeline, type VideoDraftTrack, type VideoDraftTrackItem, type Voice, type VoiceoverCaptionInput, type VoiceoverResult, type WaitForServerAckOptions, assertDslDocument, base64ToBytes, bytesToBase64, captionContentCodec, createInitialMedeoDsl, decodeDocVersionMark, defaultIdFactory, documentFormat, encodeDocVersionMark, fromVideoDraft, isInvalidAtomic, medeoDslLoroShape, readMengineEventStream, relationId, resolveDslLayout, resourceId, timeAnchorCodec, toVideoDraft, tupleHash };
1
+ import { $ as TextMutation, A as DeepReadonly, C as CaptionContent, D as Clip, E as CaptionText, F as EntityTables, G as ResourceSystem, H as RelationTable, I as EntityValues, K as RichTextSnapshot, L as FieldPatch, M as DslMutation, N as EntityMutation, O as ContainMutation, P as EntityTable, Q as TextMark, R as MedeoDslSnapshot, S as Caption, T as CaptionStyle, U as RelationTables, V as RelationMutation, W as RelationValues, X as TextDelta, Y as StoredFile, Z as TextEdit, _ as defaultIdFactory, a as VideoDraftCaptionStyle, b as tupleHash, c as VideoDraftInput, d as VideoDraftTrack, et as TextRun, f as VideoDraftTrackItem, g as EntityIdKind, h as DslIdFactory, i as VideoDraft, it as Voice, j as DslDiagnostic, k as ContainNode, l as VideoDraftPartUnion, m as OpActor, n as DEFAULT_UNIT_TIME_MS, nt as Track, o as VideoDraftContent, p as CommitOptions, r as VideoCreationSettings, rt as TrackRole, s as VideoDraftContentPartUnion, t as CaptionDisplayCue, tt as TimeAnchor, u as VideoDraftTimeline, v as relationId, w as CaptionSelection, x as AudioScript, y as resourceId, z as Media } from "./video-draft-types-GqXnsOzA.js";
2
+ import { A as MedeoDslDraft, C as UnsupportedDocumentFormatError, D as captionContentCodec, E as InvalidAtomic, F as ClipSource, I as DslClipUpdate, L as MoveDslClipsInput, M as medeoDslLoroShape, N as AddDslClip, O as isInvalidAtomic, P as AddDslClipsInput, R as ReplaceDslClipsInput, S as DslTransaction, T as documentFormat, _ as VoiceoverCaptionInput, a as toAudioScriptViews, b as MedeoDsl, c as resolveDslLayout, d as DslProjectionError, f as DslTrackLayout, g as ApplyVoiceoverInput, h as UploadText, i as AudioScriptView, j as MedeoDslLoroState, k as timeAnchorCodec, l as DslClipLayout, m as DslEditor, n as ImportedVideoDraft, o as VideoDraftProjection, p as createInitialMedeoDsl, r as fromVideoDraft, s as toVideoDraft, t as FromVideoDraftOptions, u as DslLayout, v as VoiceoverResult, w as assertDslDocument, x as DslAudit, y as CreateMedeoDslOptions, z as ClipPlacement } from "./index-DSpKN_ta.js";
3
+ import { A as MenginePushRejectedError, B as MengineSyncResponse, C as PushResult, D as MengineHttpClient, E as readMengineEventStream, F as MenginePushResponse, H as base64ToBytes, I as MenginePushUpdateResponse, L as MengineRejectedResponse, M as MengineAuditResponse, N as MengineDocumentVersion, O as MengineHttpClientOptions, P as MengineDraftResponse, R as MengineSnapshotResponse, S as PullResult, T as MengineEventStreamOptions, U as bytesToBase64, V as MengineUpdateMeta, a as MengineDocSessionOptions, b as DocVersionMark, c as WaitForLocalSaveOptions, d as MengineUndoState, f as MedeoHttpDocStorage, g as ManualSyncDocOptions, h as PushOutcomeKind, i as MengineAckFailedError, j as MengineAuditEntry, k as MengineHttpRequestError, l as WaitForServerAckOptions, m as PushOutcome, o as MengineDocSyncState, p as MedeoHttpDocStorageOptions, s as MengineLocalSaveState, t as MemoryDocStorage, u as DocStorageLike, v as decodeDocVersionMark, w as PushResultKind, x as PullFailureReason, y as encodeDocVersionMark, z as MengineSseUpdateEvent } from "./index-DAfOkcnZ.js";
4
+ import { n as MengineDocSessionUpdateEvent, r as ManualSyncDoc, t as MengineDocSession } from "./index-JWERGMrC.js";
5
+ export { type AddDslClip, type AddDslClipsInput, type ApplyVoiceoverInput, type AudioScript, type AudioScriptView, type Caption, type CaptionContent, type CaptionDisplayCue, type CaptionSelection, type CaptionStyle, type CaptionText, type Clip, type ClipPlacement, type ClipSource, type CommitOptions, type ContainMutation, type ContainNode, type CreateMedeoDslOptions, DEFAULT_UNIT_TIME_MS, type DeepReadonly, type DocStorageLike, type DocVersionMark, type DslAudit, type DslClipLayout, type DslClipUpdate, type DslDiagnostic, DslEditor, type DslIdFactory, type DslLayout, type DslMutation, DslProjectionError, type DslTrackLayout, type DslTransaction, type EntityIdKind, type EntityMutation, type EntityTable, type EntityTables, type EntityValues, type FieldPatch, type FromVideoDraftOptions, type ImportedVideoDraft, type InvalidAtomic, ManualSyncDoc, type ManualSyncDocOptions, MedeoDsl, type MedeoDslDraft, type MedeoDslLoroState, type MedeoDslSnapshot, MedeoHttpDocStorage, type MedeoHttpDocStorageOptions, type Media, MemoryDocStorage, MengineAckFailedError, type MengineAuditEntry, type MengineAuditResponse, MengineDocSession, type MengineDocSessionOptions, type MengineDocSessionUpdateEvent, type MengineDocSyncState, type MengineDocumentVersion, type MengineDraftResponse, type MengineEventStreamOptions, MengineHttpClient, type MengineHttpClientOptions, MengineHttpRequestError, type MengineLocalSaveState, MenginePushRejectedError, type MenginePushResponse, type MenginePushUpdateResponse, type MengineRejectedResponse, type MengineSnapshotResponse, type MengineSseUpdateEvent, type MengineSyncResponse, type MengineUndoState, type MengineUpdateMeta, type MoveDslClipsInput, type OpActor, type PullFailureReason, type PullResult, type PushOutcome, type PushOutcomeKind, type PushResult, type PushResultKind, type RelationMutation, type RelationTable, type RelationTables, type RelationValues, type ReplaceDslClipsInput, type ResourceSystem, type RichTextSnapshot, type StoredFile, type TextDelta, type TextEdit, type TextMark, type TextMutation, type TextRun, type TimeAnchor, type Track, type TrackRole, UnsupportedDocumentFormatError, type UploadText, type VideoCreationSettings, type VideoDraft, type VideoDraftCaptionStyle, type VideoDraftContent, type VideoDraftContentPartUnion, type VideoDraftInput, type VideoDraftPartUnion, type VideoDraftProjection, type VideoDraftTimeline, type VideoDraftTrack, type VideoDraftTrackItem, type Voice, type VoiceoverCaptionInput, type VoiceoverResult, type WaitForLocalSaveOptions, type WaitForServerAckOptions, assertDslDocument, base64ToBytes, bytesToBase64, captionContentCodec, createInitialMedeoDsl, decodeDocVersionMark, defaultIdFactory, documentFormat, encodeDocVersionMark, fromVideoDraft, isInvalidAtomic, medeoDslLoroShape, readMengineEventStream, relationId, resolveDslLayout, resourceId, timeAnchorCodec, toAudioScriptViews, toVideoDraft, tupleHash };
package/dist/index.js CHANGED
@@ -1,8 +1,8 @@
1
1
  import { n as bytesToBase64, t as base64ToBytes } from "./base64-D-jd-dr5.js";
2
2
  import { a as covers, c as readMengineEventStream, d as MenginePushRejectedError, i as openManualDocument, l as MengineHttpClient, n as MedeoHttpDocStorage, o as decodeDocVersionMark, r as ManualSyncTransport, s as encodeDocVersionMark, t as MemoryDocStorage, u as MengineHttpRequestError } from "./storage-BW3tI_ER.js";
3
- import { a as documentFormat, c as isInvalidAtomic, ct as relationId, i as assertDslDocument, l as timeAnchorCodec, lt as resourceId, o as medeoDslLoroShape, r as UnsupportedDocumentFormatError, s as captionContentCodec, st as defaultIdFactory, t as DEFAULT_UNIT_TIME_MS, ut as tupleHash } from "./video-draft-types-TXRv3wS6.js";
4
- import { a as MedeoDsl, i as DslEditor, n as toVideoDraft, o as resolveDslLayout, r as createInitialMedeoDsl, s as DslProjectionError, t as fromVideoDraft } from "./dsl-EV6kCdr6.js";
5
- import { UndoManager, VersionVector } from "loro-crdt";
3
+ import { _t as tupleHash, a as documentFormat, c as isInvalidAtomic, gt as resourceId, ht as relationId, i as assertDslDocument, mt as defaultIdFactory, o as medeoDslLoroShape, r as UnsupportedDocumentFormatError, s as captionContentCodec, t as DEFAULT_UNIT_TIME_MS, u as timeAnchorCodec } from "./video-draft-types-BnbfWrBx.js";
4
+ import { a as toAudioScriptViews, c as DslProjectionError, i as DslEditor, n as toVideoDraft, o as MedeoDsl, r as createInitialMedeoDsl, s as resolveDslLayout, t as fromVideoDraft } from "./dsl-Co3RI5F1.js";
5
+ import { UndoManager, VersionVector, decodeImportBlobMeta } from "loro-crdt";
6
6
  import { ClientServerSynchronizer, DocManager } from "@mengine/sync";
7
7
  import { DisposableSet, EventBus } from "@mengine/utils";
8
8
  //#region src/manual-sync/manual-sync-doc.ts
@@ -10,14 +10,15 @@ import { DisposableSet, EventBus } from "@mengine/utils";
10
10
  var ManualSyncDoc = class ManualSyncDoc extends ManualSyncTransport {
11
11
  dsl;
12
12
  editor;
13
- constructor(client, doc, watermark) {
13
+ constructor(client, doc, watermark, uploadText) {
14
14
  super(client, doc, watermark);
15
15
  assertDslDocument(doc);
16
16
  this.dsl = new MedeoDsl(doc);
17
- this.editor = new DslEditor(this.dsl);
17
+ this.editor = new DslEditor(this.dsl, void 0, uploadText);
18
18
  }
19
+ /** `uploadText` stores raw content the editor writes, such as a PhoneticScript's text, in Memota. */
19
20
  static open(options) {
20
- return openManualDocument(options, (doc, watermark) => new ManualSyncDoc(options.client, doc, watermark));
21
+ return openManualDocument(options, (doc, watermark) => new ManualSyncDoc(options.client, doc, watermark, options.uploadText));
21
22
  }
22
23
  snapshot() {
23
24
  this.assertActive();
@@ -222,6 +223,7 @@ var DocumentSession = class {
222
223
  started = false;
223
224
  startTask = null;
224
225
  destroyed = false;
226
+ closeTask = null;
225
227
  lifetime = null;
226
228
  hasConnected = false;
227
229
  initialVersionValue = null;
@@ -438,6 +440,13 @@ var DocumentSession = class {
438
440
  this.local.connection.connect();
439
441
  await this.local.connection.waitForConnected().abortOn(this.lifetime.signal);
440
442
  if (this.destroyed) throw new Error("mengine doc session destroyed");
443
+ if (this.options.initialSnapshot) {
444
+ await this.local.pushDocUpdate({
445
+ docId: this.docId,
446
+ data: this.options.initialSnapshot
447
+ }, "initial-snapshot");
448
+ if (this.destroyed) throw new Error("mengine doc session destroyed");
449
+ }
441
450
  this.server.connection.connect();
442
451
  this.synchronizer.start();
443
452
  this.manager.start();
@@ -446,6 +455,10 @@ var DocumentSession = class {
446
455
  const doc = this.manager.connectDoc(this.docId);
447
456
  this.disposables.add(() => this.manager.disconnectDoc(this.docId));
448
457
  if (this.options.peerId != null) doc.setPeerId(this.options.peerId);
458
+ this.disposables.add(this.manager.onLocalUpdateReceived(this.docId, (update) => {
459
+ this.trackLocalVersion(decodeImportBlobMeta(update, true).partialEndVersionVector);
460
+ this.emitSyncState();
461
+ }));
449
462
  this.disposables.add(this.manager.onDocStateChange(this.docId, (state) => {
450
463
  this.events.emit("state", state);
451
464
  this.emitSyncState();
@@ -455,7 +468,7 @@ var DocumentSession = class {
455
468
  this.adapterValue = this.model(doc, this.mutationGuard);
456
469
  this.disposables.add(this.adapterValue.subscribe((source) => {
457
470
  if (!this.adapterValue) return;
458
- if (source === "local") this.localVersionValue = doc.version();
471
+ if (source === "local") this.trackLocalVersion(doc.version());
459
472
  this.emitSyncState();
460
473
  this.events.emit("update", {
461
474
  source,
@@ -470,9 +483,39 @@ var DocumentSession = class {
470
483
  this.undoManagerValue = new DocumentUndoManager(doc, this.mutationGuard, () => this.events.emit("undoState"));
471
484
  this.editorValue = this.adapterValue.editor;
472
485
  this.initialVersionValue = doc.version();
486
+ if (this.localVersionValue) this.trackLocalVersion(this.initialVersionValue);
473
487
  this.emitSyncState();
474
488
  return this.snapshot();
475
489
  }
490
+ getLocalSaveState() {
491
+ return this.getState().localSave;
492
+ }
493
+ /** Immediately reports local transaction state; independent of server confirmation. */
494
+ subscribeLocalSaveState(cb) {
495
+ const off = this.events.on("state", () => cb(this.getLocalSaveState()));
496
+ cb(this.getLocalSaveState());
497
+ return off;
498
+ }
499
+ /** Waits until all local saves finish, including edits made while waiting. Does not wait for the network. */
500
+ async waitForLocalSave(options = {}) {
501
+ if (!this.editorValue || this.destroyed) throw new Error("mengine doc session is not started");
502
+ await this.manager.waitForLocalSave(this.docId).timeout(options.timeoutMs ?? 15e3);
503
+ }
504
+ /** Stop accepting edits and drain local persistence before releasing resources.
505
+ * A failed local write keeps retrying, even after the host has unmounted.
506
+ * Hosts should use this for normal teardown; destroy() is immediate cancellation. */
507
+ close() {
508
+ if (this.closeTask) return this.closeTask;
509
+ if (this.destroyed || !this.editorValue) {
510
+ this.destroy();
511
+ return Promise.resolve();
512
+ }
513
+ this.mutationGuard.close();
514
+ this.synchronizer.stop();
515
+ this.server.connection.disconnect();
516
+ this.closeTask = this.manager.waitForLocalSave(this.docId).then(() => this.destroy());
517
+ return this.closeTask;
518
+ }
476
519
  getSyncState() {
477
520
  const state = this.getState();
478
521
  const target = this.confirmationTarget();
@@ -483,6 +526,14 @@ var DocumentSession = class {
483
526
  phase: connection === "disconnected" ? "offline" : this.pushErrorValue != null || state.error != null ? "failed" : connection === "connecting" ? "connecting" : state.syncing ? "syncing" : "idle"
484
527
  };
485
528
  }
529
+ trackLocalVersion(version) {
530
+ const target = VersionVector.parseJSON(this.confirmationTarget()?.toJSON() ?? /* @__PURE__ */ new Map());
531
+ for (const [peer, counter] of version.toJSON()) if ((target.get(peer) ?? 0) < counter) target.setEnd({
532
+ peer,
533
+ counter
534
+ });
535
+ this.localVersionValue = target;
536
+ }
486
537
  confirmationTarget() {
487
538
  return this.localVersionValue ?? this.initialVersionValue;
488
539
  }
@@ -573,6 +624,7 @@ function serverCovers(serverVV, target) {
573
624
  //#region src/session/mengine-doc-session.ts
574
625
  /** Default collaborative session: one DSL handle and one editor over the synchronized LoroDoc. */
575
626
  var MengineDocSession = class extends DocumentSession {
627
+ /** `uploadText` stores raw content the editor writes, such as a PhoneticScript's text, in Memota. */
576
628
  constructor(options) {
577
629
  super(options, (doc, guard) => {
578
630
  assertDslDocument(doc);
@@ -580,7 +632,7 @@ var MengineDocSession = class extends DocumentSession {
580
632
  return {
581
633
  doc,
582
634
  document: dsl,
583
- editor: new DslEditor(dsl),
635
+ editor: new DslEditor(dsl, void 0, options.uploadText),
584
636
  snapshot: () => dsl.getSnapshot(),
585
637
  subscribe: (listener) => dsl.subscribe(listener),
586
638
  dispose: () => dsl.dispose()
@@ -593,6 +645,10 @@ var MengineDocSession = class extends DocumentSession {
593
645
  projectVideoDraft() {
594
646
  return toVideoDraft(this.snapshot());
595
647
  }
648
+ /** The document's AudioScripts with what says and shows them; read from the same snapshot as the VideoDraft. */
649
+ projectAudioScripts() {
650
+ return toAudioScriptViews(this.snapshot());
651
+ }
596
652
  };
597
653
  //#endregion
598
- export { DEFAULT_UNIT_TIME_MS, DslEditor, DslProjectionError, ManualSyncDoc, MedeoDsl, MedeoHttpDocStorage, MemoryDocStorage, MengineAckFailedError, MengineDocSession, MengineHttpClient, MengineHttpRequestError, MenginePushRejectedError, UnsupportedDocumentFormatError, assertDslDocument, base64ToBytes, bytesToBase64, captionContentCodec, createInitialMedeoDsl, decodeDocVersionMark, defaultIdFactory, documentFormat, encodeDocVersionMark, fromVideoDraft, isInvalidAtomic, medeoDslLoroShape, readMengineEventStream, relationId, resolveDslLayout, resourceId, timeAnchorCodec, toVideoDraft, tupleHash };
654
+ export { DEFAULT_UNIT_TIME_MS, DslEditor, DslProjectionError, ManualSyncDoc, MedeoDsl, MedeoHttpDocStorage, MemoryDocStorage, MengineAckFailedError, MengineDocSession, MengineHttpClient, MengineHttpRequestError, MenginePushRejectedError, UnsupportedDocumentFormatError, assertDslDocument, base64ToBytes, bytesToBase64, captionContentCodec, createInitialMedeoDsl, decodeDocVersionMark, defaultIdFactory, documentFormat, encodeDocVersionMark, fromVideoDraft, isInvalidAtomic, medeoDslLoroShape, readMengineEventStream, relationId, resolveDslLayout, resourceId, timeAnchorCodec, toAudioScriptViews, toVideoDraft, tupleHash };
package/dist/legacy.d.ts CHANGED
@@ -1,5 +1,5 @@
1
- import { i as VideoDraft, l as VideoDraftPartUnion, o as VideoDraftContent, p as CommitOptions, t as CaptionDisplayCue } from "./video-draft-types-c_shaRyq.js";
2
- import { A as MengineAuditResponse, B as base64ToBytes, C as MengineEventStreamOptions, D as MengineHttpRequestError, E as MengineHttpClientOptions, F as MengineRejectedResponse, I as MengineSnapshotResponse, L as MengineSseUpdateEvent, M as MengineDraftResponse, N as MenginePushResponse, O as MenginePushRejectedError, P as MenginePushUpdateResponse, R as MengineSyncResponse, S as PushResultKind, T as MengineHttpClient, V as bytesToBase64, _ as encodeDocVersionMark, a as MengineDocSessionOptions, b as PullResult, c as DocStorageLike, d as MedeoHttpDocStorageOptions, f as PushOutcome, g as decodeDocVersionMark, h as ManualSyncTransport, j as MengineDocumentVersion, k as MengineAuditEntry, l as MengineUndoState, m as ManualSyncDocOptions, o as MengineDocSyncState, p as PushOutcomeKind, s as WaitForServerAckOptions, t as MemoryDocStorage, u as MedeoHttpDocStorage, v as DocVersionMark, w as readMengineEventStream, x as PushResult, y as PullFailureReason, z as MengineUpdateMeta } from "./index-B7fC7q7P.js";
1
+ import { i as VideoDraft, l as VideoDraftPartUnion, o as VideoDraftContent, p as CommitOptions, t as CaptionDisplayCue } from "./video-draft-types-GqXnsOzA.js";
2
+ import { A as MenginePushRejectedError, B as MengineSyncResponse, C as PushResult, D as MengineHttpClient, E as readMengineEventStream, F as MenginePushResponse, H as base64ToBytes, I as MenginePushUpdateResponse, L as MengineRejectedResponse, M as MengineAuditResponse, N as MengineDocumentVersion, O as MengineHttpClientOptions, P as MengineDraftResponse, R as MengineSnapshotResponse, S as PullResult, T as MengineEventStreamOptions, U as bytesToBase64, V as MengineUpdateMeta, _ as ManualSyncTransport, a as MengineDocSessionOptions, b as DocVersionMark, d as MengineUndoState, f as MedeoHttpDocStorage, g as ManualSyncDocOptions, h as PushOutcomeKind, j as MengineAuditEntry, k as MengineHttpRequestError, l as WaitForServerAckOptions, m as PushOutcome, o as MengineDocSyncState, p as MedeoHttpDocStorageOptions, t as MemoryDocStorage, u as DocStorageLike, v as decodeDocVersionMark, w as PushResultKind, x as PullFailureReason, y as encodeDocVersionMark, z as MengineSseUpdateEvent } from "./index-DAfOkcnZ.js";
3
3
  import { LoroDoc, PeerID } from "loro-crdt";
4
4
 
5
5
  //#region ../medeo-dsl/depreacted/sandbox.d.ts
package/dist/legacy.js CHANGED
@@ -1,6 +1,6 @@
1
1
  import { n as bytesToBase64, t as base64ToBytes } from "./base64-D-jd-dr5.js";
2
2
  import { c as readMengineEventStream, d as MenginePushRejectedError, i as openManualDocument, l as MengineHttpClient, n as MedeoHttpDocStorage, o as decodeDocVersionMark, r as ManualSyncTransport, s as encodeDocVersionMark, t as MemoryDocStorage, u as MengineHttpRequestError } from "./storage-BW3tI_ER.js";
3
- import { a as documentFormat, r as UnsupportedDocumentFormatError, t as DEFAULT_UNIT_TIME_MS } from "./video-draft-types-TXRv3wS6.js";
3
+ import { a as documentFormat, r as UnsupportedDocumentFormatError, t as DEFAULT_UNIT_TIME_MS } from "./video-draft-types-BnbfWrBx.js";
4
4
  import { u as volumeSchema } from "./shared-iWnU2osE.js";
5
5
  import { sha256 } from "@noble/hashes/sha2.js";
6
6
  import { LoroDoc, LoroMap, LoroMovableList, LoroText, UndoManager } from "loro-crdt";
package/dist/testing.d.ts CHANGED
@@ -1,5 +1,5 @@
1
- import { i as VideoDraft } from "./video-draft-types-c_shaRyq.js";
2
- import { _ as MedeoDsl } from "./index-Cu7SdKN5.js";
1
+ import { i as VideoDraft } from "./video-draft-types-GqXnsOzA.js";
2
+ import { b as MedeoDsl } from "./index-DSpKN_ta.js";
3
3
  import { LoroDoc } from "loro-crdt";
4
4
 
5
5
  //#region src/testing/in-memory-mengine-server.d.ts
package/dist/testing.js CHANGED
@@ -1,6 +1,6 @@
1
1
  import { n as bytesToBase64, t as base64ToBytes } from "./base64-D-jd-dr5.js";
2
- import { a as documentFormat, i as assertDslDocument } from "./video-draft-types-TXRv3wS6.js";
3
- import { a as MedeoDsl, i as DslEditor, n as toVideoDraft, r as createInitialMedeoDsl } from "./dsl-EV6kCdr6.js";
2
+ import { a as documentFormat, i as assertDslDocument } from "./video-draft-types-BnbfWrBx.js";
3
+ import { i as DslEditor, n as toVideoDraft, o as MedeoDsl, r as createInitialMedeoDsl } from "./dsl-Co3RI5F1.js";
4
4
  import { t as classifyUpdate } from "./loro-relay-doc-Bi6JKqtQ.js";
5
5
  import { LoroDoc, VersionVector, encodeFrontiers } from "loro-crdt";
6
6
  //#region src/testing/in-memory-mengine-server.ts
@@ -450,7 +450,7 @@ function createTestDsl(options = {}) {
450
450
  durationMs: 1e3,
451
451
  storageKey: "speech.mp3"
452
452
  },
453
- script: { body: "hello" },
453
+ script: { segments: ["hello"] },
454
454
  volume: 1,
455
455
  voice: {
456
456
  system: "voice-library",
@@ -466,10 +466,7 @@ function createTestDsl(options = {}) {
466
466
  clipId: "caption",
467
467
  startMs: 0,
468
468
  durationMs: 1e3,
469
- range: {
470
- start: 0,
471
- end: 5
472
- },
469
+ segment: 0,
473
470
  style: {}
474
471
  }]
475
472
  });