@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.
package/dist/dsl.d.ts CHANGED
@@ -1,3 +1,3 @@
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
- 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 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, MedeoDsl, type MedeoDslDraft, type MedeoDslLoroState, type MedeoDslSnapshot, type Media, type MoveDslClipsInput, type OpActor, 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, assertDslDocument, captionContentCodec, createInitialMedeoDsl, defaultIdFactory, documentFormat, fromVideoDraft, isInvalidAtomic, medeoDslLoroShape, 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
+ 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 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, MedeoDsl, type MedeoDslDraft, type MedeoDslLoroState, type MedeoDslSnapshot, type Media, type MoveDslClipsInput, type OpActor, 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, assertDslDocument, captionContentCodec, createInitialMedeoDsl, defaultIdFactory, documentFormat, fromVideoDraft, isInvalidAtomic, medeoDslLoroShape, relationId, resolveDslLayout, resourceId, timeAnchorCodec, toAudioScriptViews, toVideoDraft, tupleHash };
package/dist/dsl.js CHANGED
@@ -1,3 +1,3 @@
1
- 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";
2
- 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";
3
- export { DEFAULT_UNIT_TIME_MS, DslEditor, DslProjectionError, MedeoDsl, UnsupportedDocumentFormatError, assertDslDocument, captionContentCodec, createInitialMedeoDsl, defaultIdFactory, documentFormat, fromVideoDraft, isInvalidAtomic, medeoDslLoroShape, relationId, resolveDslLayout, resourceId, timeAnchorCodec, toVideoDraft, tupleHash };
1
+ 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";
2
+ 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";
3
+ export { DEFAULT_UNIT_TIME_MS, DslEditor, DslProjectionError, MedeoDsl, UnsupportedDocumentFormatError, assertDslDocument, captionContentCodec, createInitialMedeoDsl, defaultIdFactory, documentFormat, fromVideoDraft, isInvalidAtomic, medeoDslLoroShape, relationId, resolveDslLayout, resourceId, timeAnchorCodec, toAudioScriptViews, toVideoDraft, tupleHash };
@@ -1,6 +1,6 @@
1
- import { M as DslDiagnostic, o as VideoDraftContent, p as CommitOptions } from "./video-draft-types-c_shaRyq.js";
1
+ import { j as DslDiagnostic, o as VideoDraftContent, p as CommitOptions } from "./video-draft-types-GqXnsOzA.js";
2
2
  import { LoroDoc, PeerID, VersionVector } from "loro-crdt";
3
- import { DocState } from "@mengine/sync";
3
+ import { DocState, LocalSaveState } from "@mengine/sync";
4
4
  import { BaseDocStorage, Connection, DocDiff, DocPushReceipt, DocSnapshotRecord, DocStorage, DocStorageOptions, DocUpdate, DocUpdateRecord } from "@mengine/storage";
5
5
 
6
6
  //#region src/client/base64.d.ts
@@ -532,13 +532,18 @@ declare class MengineAckFailedError extends Error {
532
532
  readonly cause: Error | undefined;
533
533
  constructor(reason: 'timeout' | 'rejected' | 'failed', code: string | undefined, cause: Error | undefined, message: string);
534
534
  }
535
+ type MengineLocalSaveState = LocalSaveState;
536
+ interface WaitForLocalSaveOptions {
537
+ /** Only limits waiting, never cancels persistence. */
538
+ timeoutMs?: number;
539
+ }
535
540
  interface WaitForServerAckOptions {
536
541
  /** Deadline in ms. Rejects with reason `timeout` when it elapses. */
537
542
  timeoutMs?: number;
538
543
  }
539
544
  /** Document-level confirmation is independent of local operation completion. */
540
545
  interface MengineDocSyncState {
541
- /** Remote-only imports do not create a new local confirmation obligation. */
546
+ /** Server-originated imports do not create a new local confirmation obligation. */
542
547
  readonly confirmation: 'unknown' | 'pending' | 'confirmed';
543
548
  /** Transport/activity phase. Idle does not imply confirmation; failure details
544
549
  * remain available through push outcomes and confirmation wait errors. */
@@ -553,6 +558,9 @@ interface MengineDocSessionOptions {
553
558
  * Browsers should pass an `IndexedDBDocStorage` for refresh/cross-tab support.
554
559
  */
555
560
  localStorage?: DocStorageLike;
561
+ /** A freshly fetched remote snapshot to merge into storage before loading.
562
+ * Existing local changes are retained; the host owns any online startup gate. */
563
+ initialSnapshot?: Uint8Array;
556
564
  sseReconnectDelayMs?: number;
557
565
  /**
558
566
  * Keep remote synchronization read-only: pull snapshot/diffs and subscribe to
@@ -587,6 +595,7 @@ declare class DocumentSession<Snapshot, Editor, Document> {
587
595
  private started;
588
596
  private startTask;
589
597
  private destroyed;
598
+ private closeTask;
590
599
  private lifetime;
591
600
  private hasConnected;
592
601
  private initialVersionValue;
@@ -687,7 +696,17 @@ declare class DocumentSession<Snapshot, Editor, Document> {
687
696
  */
688
697
  start(): Promise<Snapshot>;
689
698
  private open;
699
+ getLocalSaveState(): MengineLocalSaveState;
700
+ /** Immediately reports local transaction state; independent of server confirmation. */
701
+ subscribeLocalSaveState(cb: (state: MengineLocalSaveState) => void): () => void;
702
+ /** Waits until all local saves finish, including edits made while waiting. Does not wait for the network. */
703
+ waitForLocalSave(options?: WaitForLocalSaveOptions): Promise<void>;
704
+ /** Stop accepting edits and drain local persistence before releasing resources.
705
+ * A failed local write keeps retrying, even after the host has unmounted.
706
+ * Hosts should use this for normal teardown; destroy() is immediate cancellation. */
707
+ close(): Promise<void>;
690
708
  getSyncState(): MengineDocSyncState;
709
+ private trackLocalVersion;
691
710
  private confirmationTarget;
692
711
  /** Immediately supplies current state; unsubscribe when the host changes docs. */
693
712
  subscribeSyncState(cb: (state: MengineDocSyncState) => void): () => void;
@@ -725,4 +744,4 @@ declare class MemoryDocStorage extends BaseDocStorage {
725
744
  private now;
726
745
  }
727
746
  //#endregion
728
- export { MengineAuditResponse as A, base64ToBytes as B, MengineEventStreamOptions as C, MengineHttpRequestError as D, MengineHttpClientOptions as E, MengineRejectedResponse as F, MengineSnapshotResponse as I, MengineSseUpdateEvent as L, MengineDraftResponse as M, MenginePushResponse as N, MenginePushRejectedError as O, MenginePushUpdateResponse as P, MengineSyncResponse as R, PushResultKind as S, MengineHttpClient as T, bytesToBase64 as V, encodeDocVersionMark as _, MengineDocSessionOptions as a, PullResult as b, DocStorageLike as c, MedeoHttpDocStorageOptions as d, PushOutcome as f, decodeDocVersionMark as g, ManualSyncTransport as h, MengineAckFailedError as i, MengineDocumentVersion as j, MengineAuditEntry as k, MengineUndoState as l, ManualSyncDocOptions as m, DocumentSession as n, MengineDocSyncState as o, PushOutcomeKind as p, DocumentSessionUpdateEvent as r, WaitForServerAckOptions as s, MemoryDocStorage as t, MedeoHttpDocStorage as u, DocVersionMark as v, readMengineEventStream as w, PushResult as x, PullFailureReason as y, MengineUpdateMeta as z };
747
+ export { MenginePushRejectedError as A, MengineSyncResponse as B, PushResult as C, MengineHttpClient as D, readMengineEventStream as E, MenginePushResponse as F, base64ToBytes as H, MenginePushUpdateResponse as I, MengineRejectedResponse as L, MengineAuditResponse as M, MengineDocumentVersion as N, MengineHttpClientOptions as O, MengineDraftResponse as P, MengineSnapshotResponse as R, PullResult as S, MengineEventStreamOptions as T, bytesToBase64 as U, MengineUpdateMeta as V, ManualSyncTransport as _, MengineDocSessionOptions as a, DocVersionMark as b, WaitForLocalSaveOptions as c, MengineUndoState as d, MedeoHttpDocStorage as f, ManualSyncDocOptions as g, PushOutcomeKind as h, MengineAckFailedError as i, MengineAuditEntry as j, MengineHttpRequestError as k, WaitForServerAckOptions as l, PushOutcome as m, DocumentSession as n, MengineDocSyncState as o, MedeoHttpDocStorageOptions as p, DocumentSessionUpdateEvent as r, MengineLocalSaveState as s, MemoryDocStorage as t, DocStorageLike as u, decodeDocVersionMark as v, PushResultKind as w, PullFailureReason as x, encodeDocVersionMark as y, MengineSseUpdateEvent as z };
@@ -1,4 +1,4 @@
1
- import { B as Media, E as CaptionStyle, J as TextEdit, M as DslDiagnostic, N as DslMutation, Q as TimeAnchor, R as FieldPatch, T as CaptionSelection, c as VideoDraftInput, et as TrackRole, h as DslIdFactory, o as VideoDraftContent, p as CommitOptions, tt as Voice, w as CaptionContent, z as MedeoDslSnapshot } from "./video-draft-types-c_shaRyq.js";
1
+ import { B as PhonemeSelection, J as SegmentSelection, L as FieldPatch, M as DslMutation, R as MedeoDslSnapshot, T as CaptionStyle, Y as StoredFile, Z as TextEdit, c as VideoDraftInput, h as DslIdFactory, it as Voice, j as DslDiagnostic, o as VideoDraftContent, p as CommitOptions, q as SegmentRange, rt as TrackRole, tt as TimeAnchor, w as CaptionSelection, z as Media } from "./video-draft-types-GqXnsOzA.js";
2
2
  import { ContainerType, Cursor, LoroDoc, PeerID, TreeID } from "loro-crdt";
3
3
 
4
4
  //#region src/dsl/action-context.d.ts
@@ -394,22 +394,12 @@ type InferBooleanType<S extends SchemaType> = S extends {
394
394
  transform: TransformDefinition<infer _C, infer D>;
395
395
  } ? WithOptionality<D, S> : WithOptionality<boolean, S>;
396
396
  //#endregion
397
- //#region ../medeo-dsl/src/schema/codec.d.ts
398
- interface InvalidAtomic {
399
- invalid: true;
400
- raw: string;
401
- reason: string;
402
- }
403
- declare function isInvalidAtomic(value: unknown): value is InvalidAtomic;
404
- interface AtomicCodec<T> {
405
- encode(value: T | InvalidAtomic): string;
406
- decode(raw: string): T | InvalidAtomic;
407
- }
408
- declare const timeAnchorCodec: AtomicCodec<TimeAnchor>;
409
- declare const captionContentCodec: AtomicCodec<CaptionContent>;
410
- //#endregion
411
397
  //#region ../medeo-dsl/src/schema/loro-shape.d.ts
412
- /** Only direct children inherit mergeable identity. Body and ordinary entity rows keep normal identities. */
398
+ /**
399
+ * Only direct children inherit mergeable identity. Text and ordinary entity rows keep normal
400
+ * identities, so deleting a row also drops what a peer wrote into it concurrently: a relation an
401
+ * entity holds at most one of is a field of that row and never outlives it.
402
+ */
413
403
  declare const medeoDslLoroShape: RootSchemaType<{
414
404
  'timeline-entities': LoroMapSchemaWithCatchall<{}, LoroMapSchema<{}> & {
415
405
  options: {};
@@ -434,12 +424,16 @@ declare const medeoDslLoroShape: RootSchemaType<{
434
424
  'clip-entities': LoroMapSchemaWithCatchall<{}, LoroMapSchema<{
435
425
  seqMarker: /*elided*/any;
436
426
  volume: /*elided*/any;
427
+ source: /*elided*/any;
428
+ anchor: /*elided*/any;
437
429
  }> & {
438
430
  options: {};
439
431
  } & {
440
432
  catchall: <C extends SchemaType>(catchallSchema: C) => LoroMapSchemaWithCatchall<{
441
433
  seqMarker: /*elided*/any;
442
434
  volume: /*elided*/any;
435
+ source: /*elided*/any;
436
+ anchor: /*elided*/any;
443
437
  }, C>;
444
438
  }> & {
445
439
  options: {};
@@ -468,19 +462,39 @@ declare const medeoDslLoroShape: RootSchemaType<{
468
462
  };
469
463
  };
470
464
  'audio-script-entities': LoroMapSchemaWithCatchall<{}, LoroMapSchema<{
471
- body: /*elided*/any;
465
+ segments: /*elided*/any;
472
466
  defaultLanguage: /*elided*/any;
473
467
  }> & {
474
468
  options: {};
475
469
  } & {
476
470
  catchall: <C extends SchemaType>(catchallSchema: C) => LoroMapSchemaWithCatchall<{
477
- body: /*elided*/any;
471
+ segments: /*elided*/any;
478
472
  defaultLanguage: /*elided*/any;
479
473
  }, C>;
480
474
  }> & {
481
475
  options: {};
482
476
  };
477
+ 'phonetic-script-entities': LoroMapSchemaWithCatchall<{}, LoroMapSchema<{
478
+ phoneme: /*elided*/any;
479
+ system: /*elided*/any;
480
+ key: /*elided*/any;
481
+ storageKey: /*elided*/any;
482
+ digest: /*elided*/any;
483
+ }> & {
484
+ options: {};
485
+ } & {
486
+ catchall: <C extends SchemaType>(catchallSchema: C) => LoroMapSchemaWithCatchall<{
487
+ phoneme: /*elided*/any;
488
+ system: /*elided*/any;
489
+ key: /*elided*/any;
490
+ storageKey: /*elided*/any;
491
+ digest: /*elided*/any;
492
+ }, C>;
493
+ }> & {
494
+ options: {};
495
+ };
483
496
  'caption-entities': LoroMapSchemaWithCatchall<{}, LoroMapSchema<{
497
+ selection: /*elided*/any;
484
498
  text: /*elided*/any;
485
499
  style: /*elided*/any;
486
500
  }> & {
@@ -489,6 +503,7 @@ declare const medeoDslLoroShape: RootSchemaType<{
489
503
  };
490
504
  } & {
491
505
  catchall: <C extends SchemaType>(catchallSchema: C) => LoroMapSchemaWithCatchall<{
506
+ selection: /*elided*/any;
492
507
  text: /*elided*/any;
493
508
  style: /*elided*/any;
494
509
  }, C>;
@@ -512,29 +527,10 @@ declare const medeoDslLoroShape: RootSchemaType<{
512
527
  readonly mergeableMapChildContainers: true;
513
528
  };
514
529
  };
515
- 'asset-entities': LoroMapSchemaWithCatchall<{}, LoroMapSchema<{
516
- system: /*elided*/any;
517
- key: /*elided*/any;
518
- storageKey: /*elided*/any;
519
- digest: /*elided*/any;
520
- }> & {
521
- options: {};
522
- } & {
523
- catchall: <C extends SchemaType>(catchallSchema: C) => LoroMapSchemaWithCatchall<{
524
- system: /*elided*/any;
525
- key: /*elided*/any;
526
- storageKey: /*elided*/any;
527
- digest: /*elided*/any;
528
- }, C>;
529
- }> & {
530
- options: {
531
- readonly mergeableMapChildContainers: true;
532
- };
533
- };
534
530
  'contain-relations': LoroTreeSchema<{
535
531
  entityId: /*elided*/any;
536
532
  }>;
537
- 'clip-source-relations': LoroMapSchemaWithCatchall<{}, LoroMapSchema<Record<string, StringSchemaType<string> & {
533
+ 'voice-timbre-relations': LoroMapSchemaWithCatchall<{}, LoroMapSchema<Record<string, StringSchemaType<string> & {
538
534
  options: {};
539
535
  } & {
540
536
  transform: <D>(def: TransformDefinition<string, D>) => StringSchemaType<string> & {
@@ -557,129 +553,23 @@ declare const medeoDslLoroShape: RootSchemaType<{
557
553
  readonly mergeableMapChildContainers: true;
558
554
  };
559
555
  };
560
- 'time-anchor-relations': LoroMapSchemaWithCatchall<{}, StringSchemaType<string> & {
561
- options: {};
562
- transform: TransformDefinition<string, TimeAnchor | InvalidAtomic>;
563
- }> & {
564
- options: {};
565
- };
566
- 'caption-content-relations': LoroMapSchemaWithCatchall<{}, StringSchemaType<string> & {
567
- options: {};
568
- transform: TransformDefinition<string, CaptionContent | InvalidAtomic>;
569
- }> & {
570
- options: {};
571
- };
572
- 'caption-alignment-relations': LoroMapSchemaWithCatchall<{}, LoroMapSchema<{
573
- captionId: /*elided*/any;
574
- mediaId: /*elided*/any;
575
- startMs: /*elided*/any;
576
- endMs: /*elided*/any;
556
+ 'derived-from-relations': LoroMapSchemaWithCatchall<{}, LoroMapSchema<{
557
+ entityId: /*elided*/any;
558
+ sourceId: /*elided*/any;
559
+ sourceDigest: /*elided*/any;
577
560
  }> & {
578
561
  options: {};
579
562
  } & {
580
563
  catchall: <C extends SchemaType>(catchallSchema: C) => LoroMapSchemaWithCatchall<{
581
- captionId: /*elided*/any;
582
- mediaId: /*elided*/any;
583
- startMs: /*elided*/any;
584
- endMs: /*elided*/any;
564
+ entityId: /*elided*/any;
565
+ sourceId: /*elided*/any;
566
+ sourceDigest: /*elided*/any;
585
567
  }, C>;
586
568
  }> & {
587
569
  options: {
588
570
  readonly mergeableMapChildContainers: true;
589
571
  };
590
572
  };
591
- 'voice-timbre-relations': LoroMapSchemaWithCatchall<{}, LoroMapSchema<Record<string, StringSchemaType<string> & {
592
- options: {};
593
- } & {
594
- transform: <D>(def: TransformDefinition<string, D>) => StringSchemaType<string> & {
595
- options: {};
596
- transform: TransformDefinition<string, D>;
597
- };
598
- }>> & {
599
- options: {};
600
- } & {
601
- catchall: <C extends SchemaType>(catchallSchema: C) => LoroMapSchemaWithCatchall<Record<string, StringSchemaType<string> & {
602
- options: {};
603
- } & {
604
- transform: <D>(def: TransformDefinition<string, D>) => StringSchemaType<string> & {
605
- options: {};
606
- transform: TransformDefinition<string, D>;
607
- };
608
- }>, C>;
609
- }> & {
610
- options: {
611
- readonly mergeableMapChildContainers: true;
612
- };
613
- };
614
- 'derived-from-relations': LoroMapSchemaWithCatchall<{}, LoroMapSchema<Record<string, StringSchemaType<string> & {
615
- options: {};
616
- } & {
617
- transform: <D>(def: TransformDefinition<string, D>) => StringSchemaType<string> & {
618
- options: {};
619
- transform: TransformDefinition<string, D>;
620
- };
621
- }>> & {
622
- options: {};
623
- } & {
624
- catchall: <C extends SchemaType>(catchallSchema: C) => LoroMapSchemaWithCatchall<Record<string, StringSchemaType<string> & {
625
- options: {};
626
- } & {
627
- transform: <D>(def: TransformDefinition<string, D>) => StringSchemaType<string> & {
628
- options: {};
629
- transform: TransformDefinition<string, D>;
630
- };
631
- }>, C>;
632
- }> & {
633
- options: {
634
- readonly mergeableMapChildContainers: true;
635
- };
636
- };
637
- 'from-asset-relations': LoroMapSchemaWithCatchall<{}, LoroMapSchema<Record<string, StringSchemaType<string> & {
638
- options: {};
639
- } & {
640
- transform: <D>(def: TransformDefinition<string, D>) => StringSchemaType<string> & {
641
- options: {};
642
- transform: TransformDefinition<string, D>;
643
- };
644
- }>> & {
645
- options: {};
646
- } & {
647
- catchall: <C extends SchemaType>(catchallSchema: C) => LoroMapSchemaWithCatchall<Record<string, StringSchemaType<string> & {
648
- options: {};
649
- } & {
650
- transform: <D>(def: TransformDefinition<string, D>) => StringSchemaType<string> & {
651
- options: {};
652
- transform: TransformDefinition<string, D>;
653
- };
654
- }>, C>;
655
- }> & {
656
- options: {
657
- readonly mergeableMapChildContainers: true;
658
- };
659
- };
660
- 'to-asset-relations': LoroMapSchemaWithCatchall<{}, LoroMapSchema<Record<string, StringSchemaType<string> & {
661
- options: {};
662
- } & {
663
- transform: <D>(def: TransformDefinition<string, D>) => StringSchemaType<string> & {
664
- options: {};
665
- transform: TransformDefinition<string, D>;
666
- };
667
- }>> & {
668
- options: {};
669
- } & {
670
- catchall: <C extends SchemaType>(catchallSchema: C) => LoroMapSchemaWithCatchall<Record<string, StringSchemaType<string> & {
671
- options: {};
672
- } & {
673
- transform: <D>(def: TransformDefinition<string, D>) => StringSchemaType<string> & {
674
- options: {};
675
- transform: TransformDefinition<string, D>;
676
- };
677
- }>, C>;
678
- }> & {
679
- options: {
680
- readonly mergeableMapChildContainers: true;
681
- };
682
- };
683
573
  }> & {
684
574
  options: {};
685
575
  };
@@ -695,6 +585,22 @@ type MedeoDslDraft = DraftFields<Omit<Input, 'contain-relations'>> & {
695
585
  'contain-relations': ContainDraftNode[];
696
586
  };
697
587
  //#endregion
588
+ //#region ../medeo-dsl/src/schema/codec.d.ts
589
+ interface InvalidAtomic {
590
+ invalid: true;
591
+ raw: string;
592
+ reason: string;
593
+ }
594
+ declare function isInvalidAtomic(value: unknown): value is InvalidAtomic;
595
+ interface AtomicCodec<T> {
596
+ encode(value: T | InvalidAtomic): string;
597
+ decode(raw: string): T | InvalidAtomic;
598
+ }
599
+ /** A Clip's time anchor; the Clip holding it is the anchored end. */
600
+ declare const timeAnchorCodec: AtomicCodec<TimeAnchor>;
601
+ /** A Caption's selection. */
602
+ declare const captionContentCodec: AtomicCodec<SegmentSelection>;
603
+ //#endregion
698
604
  //#region ../medeo-dsl/src/schema/document-format.d.ts
699
605
  /** Format discrimination does not register containers or alter the document. */
700
606
  declare function documentFormat(doc: LoroDoc): 'dsl' | 'legacy' | 'mixed' | 'unknown';
@@ -721,10 +627,17 @@ interface DslTransaction {
721
627
  readonly draft: MedeoDslDraft;
722
628
  applyMutations(mutations: readonly DslMutation[]): void;
723
629
  /** Offsets use the preview after preceding edits. Existing Text identities are checked when supplied. */
724
- editText(audioScriptId: string, edits: readonly TextEdit[], expectedBodyId?: string): void;
725
- /** Creates real Cursors during application; pending ranges are not exposed as draft Cursor objects. */
630
+ editText(audioScriptId: string, segmentId: string, edits: readonly TextEdit[], expectedBodyId?: string): void;
726
631
  editCaptionText(captionId: string, edits: readonly TextEdit[], expectedBodyId?: string): void;
632
+ /** Adds a segment at `index` (the end by default); its id must be new to the script. */
633
+ insertSegment(audioScriptId: string, segmentId: string, text: string, index?: number): void;
634
+ /** `index` is measured after removing the segment. */
635
+ moveSegment(audioScriptId: string, segmentId: string, index: number): void;
636
+ deleteSegment(audioScriptId: string, segmentId: string): void;
637
+ /** Creates real Cursors during application; pending ranges are not exposed as draft Cursor objects. */
727
638
  setCaptionContent(selection: CaptionSelection): void;
639
+ /** Writes a PhoneticScript's phoneme, its run turned into Cursors like a Caption's. */
640
+ setPhoneme(selection: PhonemeSelection): void;
728
641
  }
729
642
  //#endregion
730
643
  //#region src/dsl/document/medeo-dsl.d.ts
@@ -762,10 +675,13 @@ declare class MedeoDsl {
762
675
  transact(edit: (tx: DslTransaction) => void, audit: DslAudit): void;
763
676
  /** Preferred vocabulary for ordinary entity/relation/Tree edits and serializable native commands. */
764
677
  applyMutations(mutations: readonly DslMutation[], audit: DslAudit): void;
765
- editText(scriptId: string, expectedBodyId: string, edits: readonly TextEdit[], audit: DslAudit): void;
678
+ editText(scriptId: string, segmentId: string, expectedBodyId: string, edits: readonly TextEdit[], audit: DslAudit): void;
766
679
  editCaptionText(captionId: string, expectedBodyId: string, edits: readonly TextEdit[], audit: DslAudit): void;
767
- /** Local ranges exclude insertions at their start and include insertions at their end. K01 remains deferred. */
768
- textRange(scriptId: string, start: number, end: number): Omit<CaptionContent, 'captionId'>;
680
+ /**
681
+ * A run inside one segment as native Cursors. Local ranges exclude insertions at their start and
682
+ * include insertions at their end. K01 remains deferred.
683
+ */
684
+ textRange(scriptId: string, segmentId: string, start: number, end: number): SegmentSelection;
769
685
  dispose(): void;
770
686
  private mutate;
771
687
  private notify;
@@ -777,8 +693,10 @@ interface VoiceoverCaptionInput {
777
693
  clipId?: string;
778
694
  startMs: number;
779
695
  durationMs: number;
780
- /** UTF-16 selection in the supplied AudioScript; timing remains a separate fact. */
781
- range: {
696
+ /** The segment of the voiceover's script it shows, by index; timing remains a separate fact. */
697
+ segment: number;
698
+ /** A UTF-16 run inside that segment; without one the whole segment shows. */
699
+ range?: {
782
700
  start: number;
783
701
  end: number;
784
702
  };
@@ -793,34 +711,61 @@ interface ApplyVoiceoverInput {
793
711
  }> & {
794
712
  kind: 'voiceover-recording';
795
713
  };
714
+ /**
715
+ * What the recording says: an existing AudioScript, a new one of these `segments`, or a
716
+ * PhoneticScript it was spoken from. A recording spoken from a PhoneticScript is derived-from it,
717
+ * and its captions select segments of that variant's base script.
718
+ */
796
719
  script: {
797
720
  audioScriptId: string;
798
- body?: never;
721
+ segments?: never;
722
+ phoneticScriptId?: never;
799
723
  } | {
800
- body: string;
724
+ segments: string[];
801
725
  audioScriptId?: never;
726
+ phoneticScriptId?: never;
802
727
  defaultLanguage?: string;
728
+ } | {
729
+ phoneticScriptId: string;
730
+ audioScriptId?: never;
731
+ segments?: never;
803
732
  };
804
733
  placement: ClipPlacement;
734
+ /**
735
+ * The digest of what the recording was synthesized from (D177): the PhoneticScript as it was
736
+ * read for synthesis. Absent, the source's digest as this voiceover leaves it is recorded.
737
+ */
738
+ sourceDigest?: string;
805
739
  volume?: number;
806
740
  voice?: Voice;
807
- /** Complete generated caption set for this use. Other uses of the recording are untouched. */
741
+ /**
742
+ * Complete generated caption set for this use. It replaces the Caption Clips showing what the
743
+ * use's current take says: those whose Caption selects it (D183).
744
+ */
808
745
  captions: readonly VoiceoverCaptionInput[];
809
746
  }
810
747
  interface VoiceoverResult {
811
748
  clipId: string;
812
749
  mediaId: string;
813
750
  audioScriptId: string;
751
+ /** Ids of a new script's segments, in order; empty when the script already exists. */
752
+ segmentIds: string[];
814
753
  captionClipIds: string[];
815
754
  captionIds: string[];
816
755
  }
817
756
  //#endregion
818
757
  //#region src/dsl/dsl-editor.d.ts
758
+ /**
759
+ * Stores raw content in Memota as a text file and returns the file's facts. The host owns the
760
+ * store; an entity with the Media File trait keeps the facts beside the content (D178).
761
+ */
762
+ type UploadText = (text: string) => Promise<StoredFile>;
819
763
  /** Business edits write DSL facts in one audited transaction; layout is derived on read. */
820
764
  declare class DslEditor {
821
765
  readonly dsl: MedeoDsl;
822
766
  private readonly idFactory;
823
- constructor(dsl: MedeoDsl, idFactory?: DslIdFactory);
767
+ private readonly uploadText?;
768
+ constructor(dsl: MedeoDsl, idFactory?: DslIdFactory, uploadText?: UploadText | undefined);
824
769
  createTrack(role: TrackRole, options?: CommitOptions): string;
825
770
  registerMedia(media: Media, options?: CommitOptions): string;
826
771
  addClips(input: AddDslClipsInput, options?: CommitOptions): string[];
@@ -834,22 +779,28 @@ declare class DslEditor {
834
779
  rate: number;
835
780
  } | undefined, options?: CommitOptions): void;
836
781
  setClipVolume(clipId: string, volume: number | undefined, options?: CommitOptions): void;
837
- createAudioScript(body: string, defaultLanguage?: string, options?: CommitOptions): string;
838
- editAudioScript(scriptId: string, expectedBodyId: string, edits: readonly TextEdit[], options?: CommitOptions): void;
839
- createCaption(input: ({
840
- audioScriptId: string;
841
- start: number;
842
- end: number;
782
+ /** A script of these segments, in order; each segment gets its own id. */
783
+ createAudioScript(segments: readonly string[], defaultLanguage?: string, options?: CommitOptions): string;
784
+ editAudioScript(scriptId: string, segmentId: string, expectedBodyId: string, edits: readonly TextEdit[], options?: CommitOptions): void;
785
+ /** Adds a segment at `index`, the end by default, and returns its id. */
786
+ insertScriptSegment(scriptId: string, text: string, index?: number, options?: CommitOptions): string;
787
+ /** `index` is measured after removing the segment. */
788
+ moveScriptSegment(scriptId: string, segmentId: string, index: number, options?: CommitOptions): void;
789
+ /** Captions and PhoneticScripts selecting the segment keep their selection, which then shows nothing (D72). */
790
+ deleteScriptSegment(scriptId: string, segmentId: string, options?: CommitOptions): void;
791
+ createCaption(input: ((SegmentRange & {
843
792
  text?: never;
844
- } | {
793
+ }) | {
845
794
  text: string;
846
795
  audioScriptId?: never;
796
+ segmentId?: never;
847
797
  start?: never;
848
798
  end?: never;
849
799
  }) & {
850
800
  style?: CaptionStyle;
851
801
  }, options?: CommitOptions): string;
852
- setCaptionContent(captionId: string, audioScriptId: string, start: number, end: number, options?: CommitOptions): void;
802
+ /** Show a segment of a script, or a run of it, in place of the Caption's own text. */
803
+ setCaptionContent(captionId: string, selection: SegmentRange, options?: CommitOptions): void;
853
804
  setCaptionText(captionId: string, text: string, options?: CommitOptions): void;
854
805
  editCaptionText(captionId: string, expectedBodyId: string, edits: readonly TextEdit[], options?: CommitOptions): void;
855
806
  moveTrack(trackId: string, index: number, options?: CommitOptions): void;
@@ -866,6 +817,19 @@ declare class DslEditor {
866
817
  updateClips(updates: readonly DslClipUpdate[], options?: CommitOptions): void;
867
818
  patchCaptionStyle(captionIds: readonly string[], patch: FieldPatch<CaptionStyle>, options?: CommitOptions): void;
868
819
  applyVoiceover(input: ApplyVoiceoverInput, options?: CommitOptions): VoiceoverResult;
820
+ private voiceoverScriptId;
821
+ /**
822
+ * Write a PhoneticScript: create one for a segment of a script, or a run of it, or, given
823
+ * `phoneticScriptId`, replace its selection and what to synthesize together (D181). A
824
+ * `phonemeScript` is stored as a Memota text file first, and the file's facts are written with
825
+ * it; an unchanged one keeps its file. Recordings already spoken from it keep their derived-from.
826
+ */
827
+ setPhoneticScript(input: SegmentRange & {
828
+ phoneticScriptId?: string;
829
+ phonemeScript?: string;
830
+ }, options?: CommitOptions): Promise<string>;
831
+ /** The file holding `text`: the one the PhoneticScript keeps while its text is unchanged, else a new upload. */
832
+ private fileFor;
869
833
  setBgm(input: ClipSource & {
870
834
  trackId: string;
871
835
  clipId?: string;
@@ -924,6 +888,58 @@ interface VideoDraftProjection {
924
888
  /** A content read view, not an archive of authoring identities, rich-text marks or provenance. */
925
889
  declare function toVideoDraft(snapshot: MedeoDslSnapshot): VideoDraftProjection;
926
890
  //#endregion
891
+ //#region src/dsl/projection/audio-scripts.d.ts
892
+ /**
893
+ * An AudioScript with everything that says or shows it, read from the same snapshot as the
894
+ * VideoDraft. Speeches and captions come in playback order.
895
+ */
896
+ interface AudioScriptView {
897
+ id: string;
898
+ /** Its segments, in order. */
899
+ segments: {
900
+ id: string;
901
+ text: string;
902
+ language?: string;
903
+ }[];
904
+ /** Media the script was read off (a transcript), through derived-from. */
905
+ sourceMediaIds: string[];
906
+ /**
907
+ * Its variants written for synthesis: the segment each is for (by index, absent once that
908
+ * segment is gone), what its selection holds, what to synthesize, and its file's digest.
909
+ */
910
+ phoneticScripts: {
911
+ id: string;
912
+ segment?: number;
913
+ text?: string;
914
+ phonemeScript?: string;
915
+ digest?: string;
916
+ }[];
917
+ /** Speech Clips playing a recording of these words. */
918
+ speeches: {
919
+ clipId: string;
920
+ recordingId: string; /** The PhoneticScript the recording was spoken from; absent when it derives from the script directly. */
921
+ phoneticScriptId?: string;
922
+ voices: {
923
+ voiceId: string;
924
+ key: string;
925
+ name?: string;
926
+ }[];
927
+ /**
928
+ * Whether the recording was synthesized from its source as it is now: the digest its
929
+ * derived-from records equals the source's digest (D177). Absent when either has none.
930
+ */
931
+ applied?: boolean;
932
+ }[];
933
+ /** Caption Clips showing one of its segments. A Caption with its own text shows none. */
934
+ captions: {
935
+ clipId: string;
936
+ captionId: string;
937
+ segment: number;
938
+ }[];
939
+ }
940
+ /** Every AudioScript in the document with its PhoneticScripts, the Speech Clips saying it and the Caption Clips showing it. */
941
+ declare function toAudioScriptViews(snapshot: MedeoDslSnapshot): AudioScriptView[];
942
+ //#endregion
927
943
  //#region src/dsl/projection/from-video-draft.d.ts
928
944
  interface FromVideoDraftOptions extends CreateMedeoDslOptions {
929
945
  /** Complete physical media facts, keyed by their external system/key; no IO runs in the converter. */
@@ -937,4 +953,4 @@ interface ImportedVideoDraft {
937
953
  /** One-time import into a newly owned document; never reverse-diff a live collaborative document. */
938
954
  declare function fromVideoDraft(input: VideoDraftInput, options: FromVideoDraftOptions): ImportedVideoDraft;
939
955
  //#endregion
940
- export { AddDslClip as A, MedeoDslDraft as C, captionContentCodec as D, InvalidAtomic as E, ReplaceDslClipsInput as F, ClipPlacement as I, ClipSource as M, DslClipUpdate as N, isInvalidAtomic as O, MoveDslClipsInput as P, documentFormat as S, medeoDslLoroShape as T, MedeoDsl as _, toVideoDraft as a, UnsupportedDocumentFormatError as b, DslLayout as c, createInitialMedeoDsl as d, DslEditor as f, CreateMedeoDslOptions as g, VoiceoverResult as h, VideoDraftProjection as i, AddDslClipsInput as j, timeAnchorCodec as k, DslProjectionError as l, VoiceoverCaptionInput as m, ImportedVideoDraft as n, resolveDslLayout as o, ApplyVoiceoverInput as p, fromVideoDraft as r, DslClipLayout as s, FromVideoDraftOptions as t, DslTrackLayout as u, DslAudit as v, MedeoDslLoroState as w, assertDslDocument as x, DslTransaction as y };
956
+ export { MedeoDslDraft as A, UnsupportedDocumentFormatError as C, captionContentCodec as D, InvalidAtomic as E, ClipSource as F, DslClipUpdate as I, MoveDslClipsInput as L, medeoDslLoroShape as M, AddDslClip as N, isInvalidAtomic as O, AddDslClipsInput as P, ReplaceDslClipsInput as R, DslTransaction as S, documentFormat as T, VoiceoverCaptionInput as _, toAudioScriptViews as a, MedeoDsl as b, resolveDslLayout as c, DslProjectionError as d, DslTrackLayout as f, ApplyVoiceoverInput as g, UploadText as h, AudioScriptView as i, MedeoDslLoroState as j, timeAnchorCodec as k, DslClipLayout as l, DslEditor as m, ImportedVideoDraft as n, VideoDraftProjection as o, createInitialMedeoDsl as p, fromVideoDraft as r, toVideoDraft as s, FromVideoDraftOptions as t, DslLayout as u, VoiceoverResult as v, assertDslDocument as w, DslAudit as x, CreateMedeoDslOptions as y, ClipPlacement as z };