@mengine/medeo-client 2.0.1-alpha.6 → 2.0.1-alpha.8

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/index.d.ts CHANGED
@@ -1,5 +1,5 @@
1
1
  import { t as index_d_exports } from "./index-CMa6ZCtX.js";
2
- import { $ as SequenceRange, A as generatePartId, At as VideoDraft, B as ResolvedEntityClipPlacement, Bt as Track$1, C as PlannedSemanticOpKind, Ct as TrackItemTimePosition, D as SnapshotReadable, Dt as VideoDocumentSchemaVersion, E as SchemaValidator, Et as VideoDocument, F as videoDocumentMirrorSchema, Ft as CaptionPart$1, G as EntityTimelineProjectionError, H as ResolvedEntityTrack, I as VideoDocumentValidationError, It as CaptionStyle, J as RelationRow, K as EntityRelationRows, L as assertValidVideoDocument, Lt as PartAggregation, M as TrackItemDraft, Mt as effectiveVideoClipDurationMs, N as VideoDocumentDraft, Nt as speedOf, O as ValidationError, Ot as VideoDocumentValidationIssue, P as VideoDocumentMirrorSchema, Pt as Attachment, Q as SequenceDuration, R as validateVideoDocument, Rt as SpeedShift, S as ImplementedSemanticOpKind, St as TrackItem, T as isImplementedSemanticOpKind, Tt as VideoClipPart, U as resolveEntityTimelineLayout, V as ResolvedEntityTimelineLayout, Vt as TrackItem$1, W as projectEntityTimeline, X as CaptionStyleFields, Y as CaptionSegmentSelection, Z as ScriptTextSegment, _ as SemanticEditor, _t as PartKind, a as PlainMemoryAdapter, at as buildInitialVideoDocument, b as TransactAudit, bt as Timeline, c as MirrorVideoDocumentAdapter, ct as buildSpeechHostMap, d as createMirrorVideoDocument, dt as toVideoDocument, et as VoiceDescriptor, f as createMirrorVideoDocumentAdapter, ft as BgmPart, g as SemanticDocumentAdapter, gt as ENTITY_TIMELINE_PROJECTION_SCHEMA_VERSION, h as OpActor, ht as DEFAULT_UNIT_TIME_MS, i as JournalEntry, it as InitialDocumentFacts, j as TrackDraft, jt as VideoDraftPartUnion, k as PartIdFactory, kt as VideoDocumentValidationIssueCode, l as MirrorVideoDocumentOptions, lt as derivePositionFromAbs, m as CommitOptions, mt as CaptionPart, n as videoDocumentSchema, nt as JsonValue, o as PlainMemoryAdapterOptions, ot as DerivedItemPosition, p as writeVideoDocumentToDraft, pt as CaptionDisplayCue, q as EntityRow, r as readVideoDocumentFromDraft, rt as EntityId, s as createPlainMemoryAdapter, st as SpeechHostMap, t as partUnionSchema, tt as JsonObject, u as applyEntityTimelineProjection, ut as fromVideoDocument, v as SemanticOpInput, vt as PartUnion, w as SemanticOpKind, wt as VIDEO_DOCUMENT_SCHEMA_VERSION, x as IMPLEMENTED_SEMANTIC_OP_KINDS, xt as Track, y as SemanticOpName, yt as SpeechPart, z as EntityTimelineTrackRole, zt as Timeline$1 } from "./index-B31KeDzA.js";
2
+ import { $ as SpeechHostMap, A as assertValidVideoDocument, At as VideoDocumentValidationIssueCode, B as EntityRow, Bt as SpeedShift, C as isImplementedSemanticOpKind, Ct as Timeline, D as PartIdFactory, Dt as VideoClipPart, E as ValidationError, Et as TrackItemTimePosition, F as ResolvedEntityTrack, Ft as speedOf, G as SequenceDuration, H as CaptionSegmentSelection, Ht as Track$1, I as resolveEntityTimelineLayout, It as Attachment, J as JsonObject, K as SequenceRange, L as projectEntityTimeline, Lt as CaptionPart$1, M as EntityTimelineTrackRole, Mt as VideoDraftContent, N as ResolvedEntityClipPlacement, Nt as VideoDraftPartUnion, O as generatePartId, Ot as VideoDocument, P as ResolvedEntityTimelineLayout, Pt as effectiveVideoClipDurationMs, Q as DerivedItemPosition, R as EntityTimelineProjectionError, Rt as CaptionStyle, S as SemanticOpKind, St as SpeechPart, T as SnapshotReadable, Tt as TrackItem, U as CaptionStyleFields, Ut as TrackItem$1, V as RelationRow, Vt as Timeline$1, W as ScriptTextSegment, X as EntityId, Y as JsonValue, Z as buildInitialVideoDocument, _ as SemanticOpName, _t as CaptionDisplayCue, a as PlainMemoryAdapter, at as LaneKind, b as ImplementedSemanticOpKind, bt as PartKind, c as MirrorVideoDocumentAdapter, ct as findLaneTrack, d as createMirrorVideoDocumentAdapter, dt as TrackDraft, et as buildSpeechHostMap, f as CommitOptions, ft as TrackItemDraft, g as SemanticOpInput, gt as BgmPart, h as SemanticEditor, ht as videoDocumentMirrorSchema, i as JournalEntry, it as LANE_KINDS_IN_STACK_ORDER, j as validateVideoDocument, jt as VideoDraft, k as VideoDocumentValidationError, kt as VideoDocumentValidationIssue, l as MirrorVideoDocumentOptions, lt as laneTrackId, m as SemanticDocumentAdapter, mt as VideoDocumentMirrorSchema, n as videoDocumentSchema, nt as fromVideoDocument, o as PlainMemoryAdapterOptions, ot as SolvedVideoDocument, p as OpActor, pt as VideoDocumentDraft, q as VoiceDescriptor, r as readVideoDocumentFromDraft, rt as toVideoDocument, s as createPlainMemoryAdapter, st as ensureLaneTrack, t as partUnionSchema, tt as derivePositionFromAbs, u as createMirrorVideoDocument, ut as solveVideoDocument, v as TransactAudit, vt as CaptionPart, w as SchemaValidator, wt as Track, x as PlannedSemanticOpKind, xt as PartUnion, y as IMPLEMENTED_SEMANTIC_OP_KINDS, yt as DEFAULT_UNIT_TIME_MS, z as EntityRelationRows, zt as PartAggregation } from "./index-CDrPUhBH.js";
3
3
  import { LoroDoc, PeerID } from "loro-crdt";
4
4
  import { DocState } from "@mengine/sync";
5
5
  import { BaseDocStorage, Connection, DocDiff, DocPushReceipt, DocSnapshotRecord, DocStorage, DocStorageOptions, DocUpdate, DocUpdateRecord } from "@mengine/storage";
@@ -134,7 +134,6 @@ declare class MengineHttpClient {
134
134
  private readonly fetchImpl;
135
135
  constructor(options: MengineHttpClientOptions);
136
136
  fetchSnapshot(): Promise<MengineSnapshotResponse>;
137
- bootstrapSnapshot(snapshot: Uint8Array): Promise<MengineSnapshotResponse>;
138
137
  /**
139
138
  * Loro VV-diff pull: send the caller's oplog `VersionVector.encode` as `from`
140
139
  * (omit for a full pull) and receive exactly the updates it is missing plus
@@ -175,6 +174,8 @@ interface MengineEventStreamOptions {
175
174
  /** Fired once the stream response is established (HTTP ok, body readable). */
176
175
  onOpen?(): void;
177
176
  onUpdate(event: MengineSseUpdateEvent): void;
177
+ /** A committed update omitted from live transport; fetch the missing operations by VV. */
178
+ onResync?(): void;
178
179
  }
179
180
  declare function readMengineEventStream(options: MengineEventStreamOptions): Promise<void>;
180
181
  //#endregion
@@ -271,17 +272,22 @@ interface AudioMediaAssetFact {
271
272
  readonly durationMs: number;
272
273
  readonly storageKey: string;
273
274
  }
274
- interface VoiceMediaAssetFact {
275
+ /**
276
+ * A speech recording. It materializes as an `audio` entity like every other
277
+ * playable sound; `voice` names the timbre identity it was synthesized with,
278
+ * which becomes its own Voice entity linked by a `voice-timbre` Relation.
279
+ */
280
+ interface VoiceoverMediaAssetFact {
275
281
  /** Stable external speech result id, independent of the placed Clip id. */
276
282
  readonly assetId: string;
277
- readonly kind: 'voice';
283
+ readonly kind: 'voiceover';
278
284
  readonly durationMs: number;
279
285
  readonly storageKey: string;
280
- /** Present for synthesized voice, absent for original recorded audio. */
286
+ /** Present for synthesized speech, absent for original recorded audio. */
281
287
  readonly voice?: VoiceDescriptor;
282
288
  }
283
289
  /** Facts resolved from media storage. A trim window never substitutes for intrinsic duration. */
284
- type MediaAssetFact = ImageMediaAssetFact | VideoMediaAssetFact | AudioMediaAssetFact | VoiceMediaAssetFact;
290
+ type MediaAssetFact = ImageMediaAssetFact | VideoMediaAssetFact | AudioMediaAssetFact | VoiceoverMediaAssetFact;
285
291
  type ClipPlacement = {
286
292
  readonly kind: 'sequential';
287
293
  readonly order: number;
@@ -333,7 +339,7 @@ interface DeleteClipTreeInput {
333
339
  interface VoiceoverCaptionFact {
334
340
  /** Stable placed caption identity supplied by the materialized side effect. */
335
341
  readonly captionClipEntityId: string;
336
- /** Directly held bases; includes the AudioScript used by the Voice. */
342
+ /** Directly held bases; includes the AudioScript the voiceover was rendered from. */
337
343
  readonly baseEntityIds: readonly string[];
338
344
  /** Ordered selection of AudioScript segments; caption text is never passed inline. */
339
345
  readonly selection: CaptionSegmentSelection;
@@ -344,7 +350,7 @@ interface VoiceoverCaptionFact {
344
350
  type VoiceoverTakeInput = {
345
351
  readonly timelineEntityId: string; /** Stable placed speech identity, distinct from media.assetId. */
346
352
  readonly voiceoverClipEntityId: string;
347
- readonly media: VoiceMediaAssetFact; /** Existing pronunciation variant; its composed AudioScript stays the text owner. */
353
+ readonly media: VoiceoverMediaAssetFact; /** Existing pronunciation variant; its composed AudioScript stays the text owner. */
348
354
  readonly phoneticScriptEntityId: string;
349
355
  readonly volume: number;
350
356
  readonly captions: readonly VoiceoverCaptionFact[];
@@ -420,8 +426,11 @@ interface TrimClipInput {
420
426
  }
421
427
  interface VoiceoverTakeResult {
422
428
  readonly voiceoverClipEntityId: string;
423
- readonly voiceEntityId: string;
424
- /** The pronunciation variant the Voice was rendered from. */
429
+ /** The rendered voiceover Audio entity. */
430
+ readonly voiceoverAudioEntityId: string;
431
+ /** The timbre identity it was synthesized with, when the take declared one. */
432
+ readonly voiceEntityId?: string;
433
+ /** The pronunciation variant the voiceover was rendered from. */
425
434
  readonly phoneticScriptEntityId: string;
426
435
  /** The base-text owner resolved from the PhoneticScript baseEntityIds. */
427
436
  readonly audioScriptEntityId: string;
@@ -555,7 +564,7 @@ declare class EntityTimelineEditor {
555
564
  insertCaptionClip(input: InsertCaptionClipInput): ClipEntityId;
556
565
  private insertPlacedClipIntoDraft;
557
566
  private ensureRoleTrack;
558
- /** The existing pronunciation variant a Voice consumes; composition is required. */
567
+ /** The existing pronunciation variant a voiceover consumes; composition is required. */
559
568
  private requireComposedPhoneticScript;
560
569
  /** Preserve the factual synthesis input, regardless of persisted endpoint positions. */
561
570
  private ensurePhoneticRender;
@@ -631,6 +640,8 @@ interface ImportedMediaAsset {
631
640
  readonly rows: EntityRelationRows;
632
641
  /** The single media variant identity for this asset id; it is its own Asset. */
633
642
  readonly contentEntityId: string;
643
+ /** The timbre identity of a synthesized voiceover; absent for recorded media. */
644
+ readonly voiceEntityId?: string;
634
645
  }
635
646
  /**
636
647
  * Import at the editor boundary, not at asset generation time. Existing
@@ -953,7 +964,9 @@ type PushResultKind = 'ack' | 'duplicate' | 'rejected' | 'failed' | 'nothing_to_
953
964
  */
954
965
  interface PushResult {
955
966
  kind: PushResultKind;
956
- /** Server-allocated sequence number; only present for `ack`. */
967
+ /** Server document sequence observed after a successful `ack` or `duplicate`. */
968
+ mengineUpdateSeq?: number | undefined;
969
+ /** @deprecated Ack-only sequence retained until consumers adopt `mengineUpdateSeq`. */
957
970
  updateSeq?: number | undefined;
958
971
  /** Whether the server held ops the local document lacked. See above. */
959
972
  collaborated: boolean;
@@ -1047,6 +1060,8 @@ declare class ManualSyncDoc {
1047
1060
  private readonly client;
1048
1061
  private readonly doc;
1049
1062
  private readonly adapter;
1063
+ /** Whether this document's timeline is owned by the Entity graph. */
1064
+ isEntityDocument(): boolean;
1050
1065
  readonly editor: SemanticEditor;
1051
1066
  /**
1052
1067
  * The version the server is known to hold. Starts empty (nothing confirmed)
@@ -1060,8 +1075,7 @@ declare class ManualSyncDoc {
1060
1075
  * Fetches the snapshot up front rather than starting empty and converging: the
1061
1076
  * agent's first act is to read the document, so there is no useful state before
1062
1077
  * the snapshot lands. This also fails fast and loudly on a document that does
1063
- * not exist, instead of `MengineDocSession.waitForContent()`'s behavior of
1064
- * waiting forever for content that will never arrive.
1078
+ * not exist or whose first snapshot is incomplete or invalid.
1065
1079
  */
1066
1080
  static open(options: ManualSyncDocOptions): Promise<ManualSyncDoc>;
1067
1081
  /** Current document read model (authoritative shape). */
@@ -1077,8 +1091,8 @@ declare class ManualSyncDoc {
1077
1091
  * was passed to the constructor.
1078
1092
  */
1079
1093
  editorPeerId(): PeerID;
1080
- /** Current document projected to the legacy `VideoDraft` read shape. */
1081
- draft(): VideoDraft;
1094
+ /** Current content projected into the compatible track and part read shape. */
1095
+ content(): VideoDraftContent;
1082
1096
  /**
1083
1097
  * Replay a deterministic sandbox journal into this document.
1084
1098
  *
@@ -1095,9 +1109,8 @@ declare class ManualSyncDoc {
1095
1109
  *
1096
1110
  * This pair replaces the legacy integer-version comparison that
1097
1111
  * `DraftVersionDetector` used to tell the LLM "the draft was modified
1098
- * externally, reload before editing". Under mengine `meta.version` never
1099
- * changes, so that detector would go permanently silent; comparing version
1100
- * vectors restores the same capability.
1112
+ * externally, reload before editing". Comparing Loro version vectors covers
1113
+ * all collaborative edits without a business revision field in the document.
1101
1114
  *
1102
1115
  * Same capability, not a stronger one: like the legacy detector, this only
1103
1116
  * reports what changed between two moments the caller chose to sample.
@@ -1242,12 +1255,24 @@ declare class MedeoHttpDocStorage implements DocStorage {
1242
1255
  * tool-level ack wait) subscribe here.
1243
1256
  */
1244
1257
  subscribePushOutcome(callback: (outcome: PushOutcome) => void): () => void;
1258
+ /** Observe live hints that require VV catch-up without replacing the SSE connection. */
1259
+ subscribeResync(callback: () => void): () => void;
1260
+ /** Authoritative HTTP reads and accepted pushes, never inferred from SSE bytes. */
1261
+ subscribeServerVersion(callback: (version: Uint8Array) => void): () => void;
1262
+ private reportServerVersion;
1245
1263
  deleteDoc(_docId: string): Promise<void>;
1246
1264
  subscribeDocUpdate(callback: (update: DocUpdate, origin: unknown) => void): () => void;
1247
1265
  private assertDocId;
1248
1266
  private emitUpdate;
1249
1267
  }
1250
1268
  //#endregion
1269
+ //#region src/session/document-undo-manager.d.ts
1270
+ /** Availability for this document's current editing session, not server revisions. */
1271
+ interface MengineUndoState {
1272
+ readonly canUndo: boolean;
1273
+ readonly canRedo: boolean;
1274
+ }
1275
+ //#endregion
1251
1276
  //#region src/session/types.d.ts
1252
1277
  /**
1253
1278
  * Local storage contract the runtime depends on. Aliased to the engine
@@ -1290,6 +1315,14 @@ interface WaitForServerAckOptions {
1290
1315
  /** Deadline in ms. Rejects with reason `timeout` when it elapses. */
1291
1316
  timeoutMs?: number;
1292
1317
  }
1318
+ /** Document-level confirmation is independent of local operation completion. */
1319
+ interface MengineDocSyncState {
1320
+ /** Remote-only imports do not create a new local confirmation obligation. */
1321
+ readonly confirmation: 'unknown' | 'pending' | 'confirmed';
1322
+ /** Transport/activity phase. Idle does not imply confirmation; failure details
1323
+ * remain available through push outcomes and confirmation wait errors. */
1324
+ readonly phase: 'connecting' | 'idle' | 'syncing' | 'offline' | 'failed';
1325
+ }
1293
1326
  interface MengineDocSessionOptions {
1294
1327
  docId: string;
1295
1328
  client: MengineHttpClient;
@@ -1310,13 +1343,9 @@ interface MengineDocSessionOptions {
1310
1343
  * A live editing session for one Medeo document — the single entry point clients
1311
1344
  * (FE draft driver, Agent, embeds) use to open, edit, and observe a document.
1312
1345
  *
1313
- * It assembles the engine sync stack around one Medeo document:
1314
- *
1315
- * local DocStorage ─┐
1316
- * ├─ ClientServerSynchronizer ── DocManager ── LoroDoc
1317
- * MedeoHttpDocStorage┘ │
1318
- * (remote = Rust mengine-server) ▼
1319
- * MirrorVideoDocumentAdapter + SemanticEditor
1346
+ * SemanticEditor writes through MirrorVideoDocumentAdapter directly, while
1347
+ * DocumentUndoManager observes the same LoroDoc independently. Both mutation
1348
+ * paths use the session's DocumentMutationGuard, closed before teardown.
1320
1349
  *
1321
1350
  * `DocManager` owns the `LoroDoc`: local edits committed on the adapter are
1322
1351
  * picked up via `subscribeLocalUpdates`, saved to local storage, then pushed to
@@ -1337,11 +1366,20 @@ declare class MengineDocSession {
1337
1366
  private readonly manager;
1338
1367
  private readonly events;
1339
1368
  private readonly disposables;
1369
+ private readonly mutationGuard;
1340
1370
  private adapterValue;
1341
1371
  private editorValue;
1372
+ private undoManagerValue;
1342
1373
  private started;
1374
+ private startTask;
1375
+ private destroyed;
1376
+ private lifetime;
1377
+ private hasConnected;
1378
+ private initialVersionValue;
1379
+ private localVersionValue;
1380
+ private pushErrorValue;
1343
1381
  /**
1344
- * Latest server oplog version seen on a push outcome. Lets `waitForServerAck`
1382
+ * Latest server oplog version seen on an authoritative HTTP response. Lets `waitForServerAck`
1345
1383
  * return without waiting when the server is already known to cover the local
1346
1384
  * doc (e.g. nothing was edited since the last confirmed push).
1347
1385
  */
@@ -1356,14 +1394,14 @@ declare class MengineDocSession {
1356
1394
  */
1357
1395
  subscribePushOutcome(callback: (outcome: PushOutcome) => void): () => void;
1358
1396
  /**
1359
- * Resolve once the server has durably accepted the local document state as of
1397
+ * Resolve once the server has durably accepted the local commits as of
1360
1398
  * *now* — the capability an Agent tool needs to answer "did my edit land?"
1361
1399
  * before reporting success.
1362
1400
  *
1363
1401
  * Call it right after the editor ops whose durability matters. It snapshots the
1364
- * local doc's current version and resolves on the first push outcome whose
1365
- * `serverVV` covers that version, i.e. the server log is at least as advanced as
1366
- * the local doc was when this was called.
1402
+ * latest local commit's version (or the loaded baseline before any edit) and
1403
+ * resolves when an authoritative server version covers it. Remote-only
1404
+ * imports do not extend this target, matching the displayed confirmation state.
1367
1405
  *
1368
1406
  * Version coverage, not byte identity, is the acceptance test — for two reasons:
1369
1407
  * the ops may reach the server inside a merged blob rather than as the exact
@@ -1399,29 +1437,58 @@ declare class MengineDocSession {
1399
1437
  get documentAdapter(): SemanticDocumentAdapter;
1400
1438
  /** Current document snapshot (read model). */
1401
1439
  snapshot(): VideoDocument;
1440
+ /** Current-session undo/redo availability. Loading and closed sessions report false. */
1441
+ getUndoState(): MengineUndoState;
1442
+ /**
1443
+ * Supplies current availability immediately, then coalesces stack changes in a
1444
+ * microtask. Session teardown publishes empty availability synchronously.
1445
+ */
1446
+ subscribeUndoState(cb: (state: MengineUndoState) => void): () => void;
1447
+ /**
1448
+ * Undo a local edit immediately; server confirmation remains asynchronous.
1449
+ * On a shared LWW field this writes its prior value, potentially overwriting a
1450
+ * later remote edit to that same field. Returns false if no update is produced.
1451
+ */
1452
+ undo(options?: CommitOptions): boolean;
1453
+ /**
1454
+ * Restore the state visible before undo without rerunning external side effects.
1455
+ * Returns false if no update is produced; durable confirmation is separate.
1456
+ */
1457
+ redo(options?: CommitOptions): boolean;
1458
+ /**
1459
+ * Combine existing semantic operations (e.g. trim a clip and adjust its volume)
1460
+ * or repeated commits during one drag gesture into a single undo step. A gesture
1461
+ * that only previews locally and commits once on release needs no group.
1462
+ * Each commit is immediately visible locally and enters sync independently;
1463
+ * a later failure does not roll it back.
1464
+ * Always pair with endUndoGroup in a finally block. Conflicting remote imports
1465
+ * can end/split the group early, and unrelated local edits would join it.
1466
+ * Complete asynchronous asset preparation before opening the group.
1467
+ */
1468
+ beginUndoGroup(): void;
1469
+ /** End a gesture, including one already split by a conflicting remote import. */
1470
+ endUndoGroup(): void;
1402
1471
  /**
1403
1472
  * Start the sync stack and connect the document.
1404
1473
  *
1405
- * Returns once the local snapshot has loaded into the Loro doc so callers can
1406
- * read an initial snapshot. Remote convergence continues in the background and
1407
- * surfaces through `subscribe`.
1474
+ * Returns after DocManager loads a local snapshot, or after the first remote
1475
+ * sync when no local snapshot exists. A valid empty document is ready too.
1476
+ * Cached documents can open before SSE connects; subsequent remote changes
1477
+ * surface through `subscribe`.
1408
1478
  */
1409
1479
  start(): Promise<VideoDocument>;
1480
+ private open;
1481
+ getSyncState(): MengineDocSyncState;
1482
+ private confirmationTarget;
1483
+ /** Immediately supplies current state; unsubscribe when the host changes docs. */
1484
+ subscribeSyncState(cb: (state: MengineDocSyncState) => void): () => void;
1485
+ private emitSyncState;
1410
1486
  subscribe(cb: (event: MengineDocSessionUpdateEvent) => void): () => void;
1411
1487
  onStateChange(cb: (state: DocState) => void): () => void;
1412
1488
  getState(): DocState;
1413
1489
  destroy(): void;
1414
- /**
1415
- * Resolve once the Loro doc holds the document root.
1416
- *
1417
- * `DocManager` loads from local storage, which starts empty for a fresh
1418
- * client; the server snapshot arrives asynchronously via the first sync job.
1419
- * `loaded` only means the local load ran, so we wait for actual content
1420
- * (populated schema roots) instead, surfaced by the doc subscription set up
1421
- * in `start()`.
1422
- */
1423
- private waitForContent;
1424
- private hasContent;
1490
+ /** Local absence needs a remote sync; empty business content does not. */
1491
+ private waitForInitialLoad;
1425
1492
  }
1426
1493
  //#endregion
1427
1494
  //#region src/storage/memory-doc-storage.d.ts
@@ -1608,103 +1675,6 @@ type MakeEmptyPart = (durationMs: number) => {
1608
1675
  */
1609
1676
  declare function cascadeAfterVideoClipChanges(doc: TimelineDoc, makeEmptyPart: MakeEmptyPart): void;
1610
1677
  //#endregion
1611
- //#region src/timeline-core/bridge.d.ts
1612
- /**
1613
- * Bridge between the authoritative `VideoDocument` (position-only facts) and the
1614
- * flat `TimelineDoc` the cascade primitives solve over.
1615
- *
1616
- * The data flow is single-directional (RFC 02 §7/§10): ops write only facts
1617
- * (`time_position`, parts) to `VideoDocument`; absolute time, `part_aggregations`,
1618
- * total duration, and gap fillers are NOT stored — the projection derives them
1619
- * on read by running the cascade. There is no write-back of solved positions.
1620
- *
1621
- * - `solveVideoDocument` seeds a `TimelineDoc` from each item's `time_position`,
1622
- * runs the full cascade, and returns the derived read-view (abs / aggregations
1623
- * / duration). It is the single solve shared by the legacy `VideoDraft`
1624
- * projection.
1625
- * - `ensureLaneTrack` / `findLaneTrack` locate (or mint) a secondary lane's
1626
- * track row in the draft, so ops can write authoritative facts onto the right
1627
- * named container (lane = container).
1628
- */
1629
- /** The projection-derived read-view of a `VideoDocument` (RFC 02 §7). */
1630
- interface SolvedVideoDocument {
1631
- absByPartId: Map<string, number>;
1632
- aggregations: PartAggregation[];
1633
- durationMs: number;
1634
- partLibrary: Record<string, PartUnion>;
1635
- /**
1636
- * Part ids of the gap fillers this solve minted.
1637
- *
1638
- * They exist only inside the solve: gap filling needs them so the clips after a
1639
- * gap land at the right absolute time, but they are not authoritative state and
1640
- * the read view does not carry them (see `fromVideoDocument`).
1641
- *
1642
- * Reported as ids rather than left for the caller to detect, because the caller
1643
- * *cannot* detect them. The obvious predicate — `origin_media_id === ''` — also
1644
- * matches an empty clip a writer placed on purpose (`batch_replace_video_clip_sequence`
1645
- * documents "Omit to create an empty clip placeholder"), and those are
1646
- * authoritative parts that must survive the projection. The mint callback is the
1647
- * only place that knows the difference.
1648
- *
1649
- * Note this deliberately excludes the fillers that gap filling *extended* rather
1650
- * than minted (`fillMainTrackTimeGaps` cases 1 and 2): those are authoritative
1651
- * empty clips already in `part_library`, and only their length is derived.
1652
- */
1653
- derivedFillerPartIds: Set<string>;
1654
- }
1655
- /**
1656
- * Solve a `VideoDocument` (authoritative, position-only) into its derived
1657
- * read-view: absolute time per item, `part_aggregations`, and total duration.
1658
- * This is the read side of the single-directional flow — never written back.
1659
- */
1660
- declare function solveVideoDocument(document: VideoDocument): SolvedVideoDocument;
1661
- /** The named container a secondary lane lives in. */
1662
- type SecondaryLane = 'speech' | 'caption' | 'bgm';
1663
- /** A lane's track kind: the `video_clip` main lane plus the three secondary lanes. */
1664
- type LaneKind = SecondaryLane | 'video_clip';
1665
- /**
1666
- * The four lanes in top-to-bottom stack order — the order a `tracks` list holds
1667
- * them in (see {@link laneRank}).
1668
- *
1669
- * Exported so a document can be seeded with all four lanes up front. That seed is
1670
- * not cosmetic: {@link ensureLaneTrack} is find-then-mint over a `LoroMovableList`,
1671
- * so two concurrent writers that each mint the same absent lane both keep their
1672
- * row, and the merged document holds two tracks for one lane. For the main lane
1673
- * that is fatal — `videoDocumentSchema` allows at most one `video_clip` track, so
1674
- * the merged document stops being projectable at all, symmetrically on both
1675
- * replicas. Pre-seeding every lane makes `ensureLaneTrack` always take its find
1676
- * branch, which removes the race by construction rather than by detection.
1677
- *
1678
- * What closes the race is that a track with the lane's `parts_kind` EXISTS — the
1679
- * lookup is by kind, not by id. So a seed is only safe if it covers every lane:
1680
- * a partial seed leaves the uncovered lanes exactly as exposed as before.
1681
- */
1682
- declare const LANE_KINDS_IN_STACK_ORDER: readonly LaneKind[];
1683
- /**
1684
- * The conventional track id for a lane (`main_track`, `<kind>_track`). Shared by
1685
- * the up-front seed and {@link ensureLaneTrack}'s lazy mint so a document's lane
1686
- * ids do not depend on which of the two created the track.
1687
- *
1688
- * Ids are cosmetic to the merge itself — lane lookup goes by `parts_kind`, so
1689
- * drifting them apart would not reopen the concurrent-mint race. They matter to
1690
- * readers that address a lane by id (the FE editor's panes, fixtures), which is
1691
- * why there is one convention rather than two.
1692
- */
1693
- declare function laneTrackId(kind: LaneKind): string;
1694
- /**
1695
- * Locate a lane's track row in the single `tracks` list by kind, minting an empty
1696
- * row in lane-stacking order if absent (reference/17 §4: lane = `parts_kind`).
1697
- * Ops use this to write authoritative items onto the right lane. The track id
1698
- * comes from {@link laneTrackId}, shared with the up-front seed.
1699
- *
1700
- * The mint branch is a concurrency hazard, not a convenience: see
1701
- * {@link LANE_KINDS_IN_STACK_ORDER}. A document seeded with all four lanes never
1702
- * reaches it.
1703
- */
1704
- declare function ensureLaneTrack(draft: VideoDocumentDraft, kind: LaneKind): TrackDraft;
1705
- /** Find a secondary lane's track row without minting it. */
1706
- declare function findLaneTrack(draft: VideoDocumentDraft, kind: SecondaryLane): TrackDraft | undefined;
1707
- //#endregion
1708
1678
  //#region src/timeline-core/locate.d.ts
1709
1679
  /**
1710
1680
  * Forward positioning for write-time ops (RFC 02 §9.1) — NOT a cascade.
@@ -1756,4 +1726,4 @@ declare function hasAudioScriptAsset(payload: JsonObject): boolean;
1756
1726
  /** Internal fingerprint prevents a resource from silently describing an older text revision. */
1757
1727
  declare function audioScriptAssetFields(payload: JsonObject, assetId: string): JsonObject;
1758
1728
  //#endregion
1759
- export { type Aggregation, type AssembledCaptionContent, type AssembledPhoneticScriptContent, type Attachment, type AudioMediaAssetFact, type BgmPart, type CaptionContentInput, type CaptionDisplayCue, type CaptionPart, type CaptionSegmentSelection, type CaptionStyle, type ClipEntityId, type ClipPlacement, type CommitOptions, DEFAULT_UNIT_TIME_MS, type DeleteBgmInput, type DeleteClipInput, type DeleteClipTreeInput, type DeleteVoiceoverInput, type DerivedItemPosition, type DocStorageLike, type DocVersionMark, type DocumentAudioScript, type DocumentAudioScriptState, ENTITY_TIMELINE_PROJECTION_SCHEMA_VERSION, type EditorFoundation, EntityDocumentState, type EntityGraphCommitOptions, EntityGraphHttpClient, type EntityGraphState, EntityTimelineEditor, type EntityTimelineIdFactory, EntityTimelineProjectionError, type EntityTimelineTrackRole, type FieldChange, type FieldPath, IMPLEMENTED_SEMANTIC_OP_KINDS, type ImageMediaAssetFact, type ImplementedSemanticOpKind, type ImportedMediaAsset, type InitialDocumentFacts, type InsertCaptionClipInput, type InsertClipInput, type InsertMediaClipInput, type InsertMediaClipsInput, type InsertPlacedClipInput, type JournalEntry, LANE_KINDS_IN_STACK_ORDER, LORO_ENTITY_SCHEMA, type LaneKind, type LinearClipSpeed, LoroEntityDocument, LoroEntityDraft, type MainClipRange, type MakeEmptyPart, ManualSyncDoc, type ManualSyncDocOptions, MedeoHttpDocStorage, type MedeoHttpDocStorageOptions, type MediaAssetFact, type MediaClipInsertion, MemoryDocStorage, MengineAckFailedError, type MengineAuditEntry, type MengineAuditResponse, MengineDocSession, type MengineDocSessionOptions, type MengineDocSessionUpdateEvent, type MengineDocumentVersion, type MengineEventStreamOptions, MengineHttpClient, type MengineHttpClientOptions, MengineHttpRequestError, MenginePushRejectedError, type MenginePushResponse, type MenginePushUpdateResponse, type MengineRejectedResponse, type MengineSnapshotResponse, type MengineSseUpdateEvent, type MengineSyncResponse, type MengineUpdateMeta, MirrorVideoDocumentAdapter, type MirrorVideoDocumentOptions, type MoveClipInput, type MoveClipsToStartsInput, type MoveSequentialClipsInput, type MoveVoiceoverInput, type OpActor, type PartAggregation, type PartIdFactory, type PartKind, type PartUnion, type PatchCaptionStyleInput, PlainMemoryAdapter, type PlainMemoryAdapterOptions, type PlannedSemanticOpKind, type PullFailureReason, type PullResult, type PushOutcome, type PushOutcomeKind, type PushResult, type PushResultKind, type ReplaceClipContentInput, type ReplaceMediaClipInput, type ReplaceSequentialClipsInput, type ReplacementMediaClipInput, type ResolvedEntityClipPlacement, type ResolvedEntityTimelineLayout, type ResolvedEntityTrack, SchemaValidator, ScriptCompositionError, type SemanticDocumentAdapter, SemanticEditor, type SemanticOpInput, type SemanticOpKind, type SemanticOpName, type SequentialClipAnchor, type SetBgmInput, type SetCaptionVisibilityInput, type SetClipPlacementInput, type SetClipSpeedInput, type SetClipVolumeInput, type SnapshotReadable, type SolvedVideoDocument, type SpeechHostMap, type SpeechPart, type SpeedShift, TIMELINE_SKELETON_DURATION_MS, type Timeline, type TimelineDoc, type TimelineItem, type Track, type TrackDraft, type TrackItem, type TrackItemDraft, type TrackItemTimePosition, type TransactAudit, type TrimClipInput, type UpdateClipInput, type UpdateClipMarkerInput, VIDEO_DOCUMENT_SCHEMA_VERSION, ValidationError, type VideoClipPart, type VideoDocument, type VideoDocumentDraft, type VideoDocumentMirrorSchema, type VideoDocumentSchemaVersion, VideoDocumentValidationError, type VideoDocumentValidationIssue, type VideoDocumentValidationIssueCode, type VideoDraft, type CaptionPart$1 as VideoDraftCaptionPart, type VideoDraftPartUnion, type Timeline$1 as VideoDraftTimeline, type Track$1 as VideoDraftTrack, type TrackItem$1 as VideoDraftTrackItem, type VideoMediaAssetFact, type VisualMediaAssetFact, type VoiceMediaAssetFact, type VoiceoverCaptionFact, type VoiceoverTakeInput, type VoiceoverTakeResult, type WaitForServerAckOptions, applyEntityRows, applyEntityTimelineProjection, applyFieldChanges, arrangeMainTrackSeamlessly, assembleCaptionContent, assembleEntityContent, assemblePhoneticScriptContent, assembleScriptText, assertCanonicalEditorResources, assertEntityProjectionPreservesLegacy, assertFieldChanges, assertMediaAssetWritePolicy, assertValidVideoDocument, audioScriptAssetContent, audioScriptAssetFields, audioScriptAssetHash, base64ToBytes, buildInitialVideoDocument, buildSpeechHostMap, bytesToBase64, cascadeAfterVideoClipChanges, compileEntityRows, createEditSandbox, createMirrorVideoDocument, createMirrorVideoDocumentAdapter, createPlainMemoryAdapter, decodeDocVersionMark, derivePositionFromAbs, effectiveVideoClipDurationMs, encodeDocVersionMark, ensureEditorFoundation, ensureLaneTrack, fillMainTrackTimeGaps, findComposedAudioScript, findLaneTrack, fromVideoDocument, generatePartId, getAt, hasAudioScriptAsset, hostForAbsMs, importMediaAsset, isEmptyVideoClip, isImplementedSemanticOpKind, isMap, laneTrackId, mainTrackRanges, migrateLegacyTimelineToEntities, partDurationMs, partUnionSchema, prepareCaptionContent, projectEntityTimeline, readDocumentAudioScript, readEntityDocument, readMainTrackItems, readMengineEventStream, readPart, readPartDurationMs, readVideoDocumentFromDraft, reassignSpeechesToVideoClipsByTime, recalculateTimelineDuration, relativePositionForAbs, replayJournal, resolveAllSpeechOverlaps, resolveEntityTimelineLayout, resolveFieldPath, resolveSpeechOverlapByShiftingVideos, safeDurationMs, index_d_exports as schemas, selectAudioScriptSegment, snapshotToPlain, solveVideoDocument, speedOf, syncAggregatedClipsTimePosition, toVideoDocument, validateVideoDocument, videoDocumentMirrorSchema, videoDocumentSchema, writeVideoDocumentToDraft };
1729
+ export { type Aggregation, type AssembledCaptionContent, type AssembledPhoneticScriptContent, type Attachment, type AudioMediaAssetFact, type BgmPart, type CaptionContentInput, type CaptionDisplayCue, type CaptionPart, type CaptionSegmentSelection, type CaptionStyle, type ClipEntityId, type ClipPlacement, type CommitOptions, DEFAULT_UNIT_TIME_MS, type DeleteBgmInput, type DeleteClipInput, type DeleteClipTreeInput, type DeleteVoiceoverInput, type DerivedItemPosition, type DocStorageLike, type DocVersionMark, type DocumentAudioScript, type DocumentAudioScriptState, type EditorFoundation, EntityDocumentState, type EntityGraphCommitOptions, EntityGraphHttpClient, type EntityGraphState, EntityTimelineEditor, type EntityTimelineIdFactory, EntityTimelineProjectionError, type EntityTimelineTrackRole, type FieldChange, type FieldPath, IMPLEMENTED_SEMANTIC_OP_KINDS, type ImageMediaAssetFact, type ImplementedSemanticOpKind, type ImportedMediaAsset, type InsertCaptionClipInput, type InsertClipInput, type InsertMediaClipInput, type InsertMediaClipsInput, type InsertPlacedClipInput, type JournalEntry, LANE_KINDS_IN_STACK_ORDER, LORO_ENTITY_SCHEMA, type LaneKind, type LinearClipSpeed, LoroEntityDocument, LoroEntityDraft, type MainClipRange, type MakeEmptyPart, ManualSyncDoc, type ManualSyncDocOptions, MedeoHttpDocStorage, type MedeoHttpDocStorageOptions, type MediaAssetFact, type MediaClipInsertion, MemoryDocStorage, MengineAckFailedError, type MengineAuditEntry, type MengineAuditResponse, MengineDocSession, type MengineDocSessionOptions, type MengineDocSessionUpdateEvent, type MengineDocSyncState, type MengineDocumentVersion, type MengineEventStreamOptions, MengineHttpClient, type MengineHttpClientOptions, MengineHttpRequestError, MenginePushRejectedError, type MenginePushResponse, type MenginePushUpdateResponse, type MengineRejectedResponse, type MengineSnapshotResponse, type MengineSseUpdateEvent, type MengineSyncResponse, type MengineUndoState, type MengineUpdateMeta, MirrorVideoDocumentAdapter, type MirrorVideoDocumentOptions, type MoveClipInput, type MoveClipsToStartsInput, type MoveSequentialClipsInput, type MoveVoiceoverInput, type OpActor, type PartAggregation, type PartIdFactory, type PartKind, type PartUnion, type PatchCaptionStyleInput, PlainMemoryAdapter, type PlainMemoryAdapterOptions, type PlannedSemanticOpKind, type PullFailureReason, type PullResult, type PushOutcome, type PushOutcomeKind, type PushResult, type PushResultKind, type ReplaceClipContentInput, type ReplaceMediaClipInput, type ReplaceSequentialClipsInput, type ReplacementMediaClipInput, type ResolvedEntityClipPlacement, type ResolvedEntityTimelineLayout, type ResolvedEntityTrack, SchemaValidator, ScriptCompositionError, type SemanticDocumentAdapter, SemanticEditor, type SemanticOpInput, type SemanticOpKind, type SemanticOpName, type SequentialClipAnchor, type SetBgmInput, type SetCaptionVisibilityInput, type SetClipPlacementInput, type SetClipSpeedInput, type SetClipVolumeInput, type SnapshotReadable, type SolvedVideoDocument, type SpeechHostMap, type SpeechPart, type SpeedShift, TIMELINE_SKELETON_DURATION_MS, type Timeline, type TimelineDoc, type TimelineItem, type Track, type TrackDraft, type TrackItem, type TrackItemDraft, type TrackItemTimePosition, type TransactAudit, type TrimClipInput, type UpdateClipInput, type UpdateClipMarkerInput, ValidationError, type VideoClipPart, type VideoDocument, type VideoDocumentDraft, type VideoDocumentMirrorSchema, VideoDocumentValidationError, type VideoDocumentValidationIssue, type VideoDocumentValidationIssueCode, type VideoDraft, type CaptionPart$1 as VideoDraftCaptionPart, type VideoDraftContent, type VideoDraftPartUnion, type Timeline$1 as VideoDraftTimeline, type Track$1 as VideoDraftTrack, type TrackItem$1 as VideoDraftTrackItem, type VideoMediaAssetFact, type VisualMediaAssetFact, type VoiceoverCaptionFact, type VoiceoverMediaAssetFact, type VoiceoverTakeInput, type VoiceoverTakeResult, type WaitForServerAckOptions, applyEntityRows, applyFieldChanges, arrangeMainTrackSeamlessly, assembleCaptionContent, assembleEntityContent, assemblePhoneticScriptContent, assembleScriptText, assertCanonicalEditorResources, assertEntityProjectionPreservesLegacy, assertFieldChanges, assertMediaAssetWritePolicy, assertValidVideoDocument, audioScriptAssetContent, audioScriptAssetFields, audioScriptAssetHash, base64ToBytes, buildInitialVideoDocument, buildSpeechHostMap, bytesToBase64, cascadeAfterVideoClipChanges, compileEntityRows, createEditSandbox, createMirrorVideoDocument, createMirrorVideoDocumentAdapter, createPlainMemoryAdapter, decodeDocVersionMark, derivePositionFromAbs, effectiveVideoClipDurationMs, encodeDocVersionMark, ensureEditorFoundation, ensureLaneTrack, fillMainTrackTimeGaps, findComposedAudioScript, findLaneTrack, fromVideoDocument, generatePartId, getAt, hasAudioScriptAsset, hostForAbsMs, importMediaAsset, isEmptyVideoClip, isImplementedSemanticOpKind, isMap, laneTrackId, mainTrackRanges, migrateLegacyTimelineToEntities, partDurationMs, partUnionSchema, prepareCaptionContent, projectEntityTimeline, readDocumentAudioScript, readEntityDocument, readMainTrackItems, readMengineEventStream, readPart, readPartDurationMs, readVideoDocumentFromDraft, reassignSpeechesToVideoClipsByTime, recalculateTimelineDuration, relativePositionForAbs, replayJournal, resolveAllSpeechOverlaps, resolveEntityTimelineLayout, resolveFieldPath, resolveSpeechOverlapByShiftingVideos, safeDurationMs, index_d_exports as schemas, selectAudioScriptSegment, snapshotToPlain, solveVideoDocument, speedOf, syncAggregatedClipsTimePosition, toVideoDocument, validateVideoDocument, videoDocumentMirrorSchema, videoDocumentSchema };