@mengine/medeo-client 2.0.1-alpha.9 → 2.1.0

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,7 +1,6 @@
1
- import { t as index_d_exports } from "./index-CMa6ZCtX.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";
1
+ import { $ as VideoDraft, A as assertValidVideoDocument, B as CaptionPart, C as index_d_exports, D as VideoDocumentMirrorSchema, E as VideoDocumentDraft, F as buildSpeechHostMap, G as Timeline, H as PartKind, I as derivePositionFromAbs, J as TrackItemTimePosition, K as Track, L as fromVideoDocument, M as buildInitialVideoDocument, N as DerivedItemPosition, O as videoDocumentMirrorSchema, P as SpeechHostMap, Q as VideoDocumentValidationIssueCode, R as toVideoDocument, S as ValidationError, T as TrackItemDraft, U as PartUnion, V as DEFAULT_UNIT_TIME_MS, W as SpeechPart, X as VideoDocument, Y as VideoClipPart, Z as VideoDocumentValidationIssue, _ as PlannedSemanticOpKind, a as MirrorVideoDocumentOptions, at as PartAggregation, b as SchemaValidator, c as CommitOptions, ct as Track$1, d as SemanticEditor, et as VideoDraftContent, f as SemanticOpInput, g as ImplementedSemanticOpKind, h as IMPLEMENTED_SEMANTIC_OP_KINDS, i as MirrorVideoDocumentAdapter, it as CaptionStyle, j as validateVideoDocument, k as VideoDocumentValidationError, l as OpActor, lt as TrackItem$1, m as TransactAudit, n as videoDocumentSchema, nt as Attachment, o as createMirrorVideoDocument, ot as SpeedShift, p as SemanticOpName, q as TrackItem, r as readVideoDocumentFromDraft, rt as CaptionPart$1, s as createMirrorVideoDocumentAdapter, st as Timeline$1, t as partUnionSchema, tt as VideoDraftPartUnion, u as SemanticDocumentAdapter, v as SemanticOpKind, w as TrackDraft, x as SnapshotReadable, y as isImplementedSemanticOpKind, z as BgmPart } from "./index-CnZ9l3rb.js";
3
2
  import { LoroDoc, PeerID } from "loro-crdt";
4
- import { DocState } from "@mengine/sync";
3
+ import { DocState, LocalSaveState } from "@mengine/sync";
5
4
  import { BaseDocStorage, Connection, DocDiff, DocPushReceipt, DocSnapshotRecord, DocStorage, DocStorageOptions, DocUpdate, DocUpdateRecord } from "@mengine/storage";
6
5
 
7
6
  //#region src/client/base64.d.ts
@@ -179,709 +178,33 @@ interface MengineEventStreamOptions {
179
178
  }
180
179
  declare function readMengineEventStream(options: MengineEventStreamOptions): Promise<void>;
181
180
  //#endregion
182
- //#region ../medeo-dsl/src/composition.d.ts
183
- type ScriptCompositionIssueCode = 'field_conflict' | 'composition_cycle' | 'invalid_bases' | 'composition_missing' | 'composition_ambiguous' | 'composition_dangling' | 'unknown_segment' | 'empty_selection' | 'invalid_script' | 'invalid_selection';
184
- /** Assembly fails explicitly when declared bases cannot provide valid, unambiguous content. */
185
- declare class ScriptCompositionError extends Error {
186
- readonly code: ScriptCompositionIssueCode;
187
- readonly entityId: EntityId;
188
- constructor(code: ScriptCompositionIssueCode, entityId: EntityId, message: string);
189
- }
190
- interface AssembledCaptionContent {
191
- readonly caption: EntityRow<'caption'>;
192
- readonly audioScript: EntityRow<'audio-script'>;
193
- /** Selected AudioScript segments in Caption selection order. */
194
- readonly segments: readonly ScriptTextSegment[];
195
- /**
196
- * Where the selected segment sits in the AudioScript's ordered segments.
197
- *
198
- * A Caption locates its text as AudioScript plus index. The selection is
199
- * stored as the segment's own stable id rather than this ordinal, so a
200
- * concurrent insert or re-segmentation cannot silently slide a Caption onto
201
- * different text; the ordinal is derived here for readers that want the
202
- * position.
203
- */
204
- readonly segmentIndex: number;
205
- /** Complete display text: the selected segments' text joined in order. */
206
- readonly text: string;
207
- }
208
- interface AssembledPhoneticScriptContent {
209
- readonly phoneticScript: EntityRow<'phonetic-script'>;
210
- readonly audioScript: EntityRow<'audio-script'>;
211
- /** All AudioScript segments in script order; the pronunciation variant never reorders text. */
212
- readonly segments: readonly ScriptTextSegment[];
213
- /** Complete base text owned by the AudioScript. */
214
- readonly text: string;
215
- }
216
- /** Validate all base providers before applying explicit own fields; ordering cannot resolve ambiguity. */
217
- declare function assembleEntityContent(rows: EntityRelationRows, entityId: EntityId): EntityRow;
218
- /** Find the actual AudioScript text owner through direct variant bases. */
219
- declare function findComposedAudioScript(rows: EntityRelationRows, variantEntityId: EntityId, variantKind: 'caption' | 'phonetic-script'): EntityRow<'audio-script'>;
220
- /** Join the whole AudioScript text in segment order. */
221
- declare function assembleScriptText(script: EntityRow<'audio-script'>): string;
222
- /** Assemble selected text after base-field validation and explicit variant overrides. */
223
- declare function assembleCaptionContent(rows: EntityRelationRows, captionEntityId: EntityId): AssembledCaptionContent;
224
- /**
225
- * Assemble the complete Phonetic Script content for TTS: the composed
226
- * AudioScript's base text plus the variant's own phoneme and prosody fields.
227
- */
228
- declare function assemblePhoneticScriptContent(rows: EntityRelationRows, phoneticScriptEntityId: EntityId): AssembledPhoneticScriptContent;
229
- /** Select source text without creating another authoritative text field. */
230
- declare function selectAudioScriptSegment(script: EntityRow<'audio-script'>, selection: CaptionSegmentSelection): ScriptTextSegment;
231
- //#endregion
232
- //#region src/entity-editor/entity-graph-http-client.d.ts
233
- /** One authenticated revision of the authoritative Medeo Entity graph. */
234
- interface EntityGraphState {
235
- /** Current AudioScript content version attached to the project. */
236
- readonly audioScriptEntityId: string;
237
- readonly revision: number;
238
- readonly loroSnapshot: string;
239
- readonly rows: EntityRelationRows;
240
- }
241
- interface EntityGraphCommitOptions {
242
- /** Server version vector proving the explicit legacy-to-Entity migration baseline. */
243
- readonly migrationBaseVv?: string;
244
- }
245
- /** Browser-safe authenticated Loro client for a document's Entity graph. */
246
- declare class EntityGraphHttpClient {
247
- private readonly options;
248
- private readonly transport;
249
- private readonly endpoint;
250
- constructor(options: MengineHttpClientOptions);
251
- fetchState(): Promise<EntityGraphState>;
252
- /**
253
- * Compile edits against the original causal snapshot and publish native Loro operations.
254
- *
255
- * Deletion intent is derived from baseline IDs omitted from `nextRows`, so a
256
- * transient create-then-remove never becomes a request to delete unknown
257
- * persisted data.
258
- */
259
- commit(baseState: Pick<EntityGraphState, 'revision' | 'rows' | 'loroSnapshot'>, nextRows: EntityRelationRows, options?: EntityGraphCommitOptions): Promise<EntityGraphState>;
260
- /** Send the same prepared bytes on retry; never recompile an unconfirmed edit. */
261
- commitUpdate(update: string): Promise<EntityGraphState>;
262
- private request;
263
- }
264
- //#endregion
265
- //#region src/entity-editor/types.d.ts
266
- /** Injectable domain-id mint shared by Entity and Relation authoring surfaces. */
267
- type EntityTimelineIdFactory = (prefix: 'entity' | 'relation') => string;
268
- interface ImageMediaAssetFact {
269
- readonly assetId: string;
270
- readonly kind: 'image';
271
- readonly storageKey?: string;
272
- }
273
- interface VideoMediaAssetFact {
274
- readonly assetId: string;
275
- readonly kind: 'video';
276
- readonly durationMs: number;
277
- readonly storageKey?: string;
278
- }
279
- interface AudioMediaAssetFact {
280
- readonly assetId: string;
281
- readonly kind: 'audio';
282
- readonly durationMs: number;
283
- readonly storageKey: string;
284
- }
285
- /**
286
- * A speech recording. It materializes as an `audio` entity like every other
287
- * playable sound; `voice` names the timbre identity it was synthesized with,
288
- * which becomes its own Voice entity linked by a `voice-timbre` Relation.
289
- */
290
- interface VoiceoverMediaAssetFact {
291
- /** Stable external speech result id, independent of the placed Clip id. */
292
- readonly assetId: string;
293
- readonly kind: 'voiceover';
294
- readonly durationMs: number;
295
- readonly storageKey: string;
296
- /** Present for synthesized speech, absent for original recorded audio. */
297
- readonly voice?: VoiceDescriptor;
298
- }
299
- /** Facts resolved from media storage. A trim window never substitutes for intrinsic duration. */
300
- type MediaAssetFact = ImageMediaAssetFact | VideoMediaAssetFact | AudioMediaAssetFact | VoiceoverMediaAssetFact;
301
- type ClipPlacement = {
302
- readonly kind: 'sequential';
303
- readonly order: number;
304
- } | {
305
- readonly kind: 'absolute';
306
- readonly targetRange: SequenceRange<number>;
307
- } | {
308
- readonly kind: 'anchored';
309
- readonly hostClipEntityId: string;
310
- readonly anchorOffset: number;
311
- };
312
- interface InsertPlacedClipInput {
313
- readonly trackEntityId: string;
314
- readonly contentEntityId: string;
315
- readonly sourceRange: SequenceRange<number>;
316
- readonly duration: SequenceDuration<number>;
317
- readonly placement: ClipPlacement;
318
- readonly clipPayload?: JsonObject;
319
- /** Stable caller-owned placement identity, when one already exists outside the graph. */
320
- readonly clipEntityId?: string;
321
- }
322
- interface SetClipPlacementInput {
323
- readonly clipEntityId: string;
324
- readonly placement: ClipPlacement;
325
- }
326
- type SequentialClipAnchor = {
327
- readonly position: 'before' | 'after';
328
- readonly clipEntityId: string;
329
- } | {
330
- readonly position: 'trackStart';
331
- };
332
- interface MoveSequentialClipsInput {
333
- readonly clipEntityIds: readonly string[];
334
- readonly anchor: SequentialClipAnchor;
335
- readonly onAnchored: 'follow' | 'keepAbsolute';
336
- }
337
- interface MoveClipsToStartsInput {
338
- readonly moves: readonly {
339
- readonly clipEntityId: string;
340
- readonly newStartMs: number;
341
- }[];
342
- /** Absolute-time drags preserve every voiceover's current visible landing. */
343
- readonly onAnchored: 'keepAbsolute';
344
- }
345
- interface DeleteClipTreeInput {
346
- readonly clipEntityIds: readonly string[];
347
- readonly onAnchored: 'cascade' | 'detach';
348
- }
349
- interface VoiceoverCaptionFact {
350
- /** Stable placed caption identity supplied by the materialized side effect. */
351
- readonly captionClipEntityId: string;
352
- /** Directly held bases; includes the AudioScript the voiceover was rendered from. */
353
- readonly baseEntityIds: readonly string[];
354
- /** Ordered selection of AudioScript segments; caption text is never passed inline. */
355
- readonly selection: CaptionSegmentSelection;
356
- readonly startMs: number;
357
- readonly durationMs: number;
358
- readonly style?: CaptionStyleFields;
359
- }
360
- type VoiceoverTakeInput = {
361
- readonly timelineEntityId: string; /** Stable placed speech identity, distinct from media.assetId. */
362
- readonly voiceoverClipEntityId: string;
363
- readonly media: VoiceoverMediaAssetFact; /** Existing pronunciation variant; its composed AudioScript stays the text owner. */
364
- readonly phoneticScriptEntityId: string;
365
- readonly volume: number;
366
- readonly captions: readonly VoiceoverCaptionFact[];
367
- } & ({
368
- readonly placement: ClipPlacement;
369
- readonly hostClipEntityId?: never;
370
- readonly anchorOffset?: never;
371
- } | {
372
- readonly placement?: never;
373
- readonly hostClipEntityId: string;
374
- readonly anchorOffset: number;
375
- });
376
- type VisualMediaAssetFact = ImageMediaAssetFact | VideoMediaAssetFact;
377
- interface InsertMediaClipInput {
378
- readonly timelineEntityId: string;
379
- readonly clipEntityId?: string;
380
- readonly media: VisualMediaAssetFact;
381
- /** Source/display window in whole milliseconds. Images use this as their finite display span. */
382
- readonly sourceRange: SequenceRange<number>;
383
- readonly placement: ClipPlacement;
384
- readonly volume?: number;
385
- }
386
- interface ReplaceMediaClipInput {
387
- readonly clipEntityId: string;
388
- readonly media: VisualMediaAssetFact;
389
- readonly sourceRange: SequenceRange<number>;
390
- }
391
- interface ReplacementMediaClipInput {
392
- readonly clipEntityId?: string;
393
- readonly media: VisualMediaAssetFact;
394
- readonly sourceRange: SequenceRange<number>;
395
- readonly volume?: number;
396
- }
397
- type MediaClipInsertion = {
398
- readonly kind: 'before';
399
- readonly clipEntityId: string;
400
- } | {
401
- readonly kind: 'after';
402
- readonly clipEntityId: string;
403
- } | {
404
- readonly kind: 'firstStart';
405
- readonly startMs: number;
406
- };
407
- interface InsertMediaClipsInput {
408
- readonly timelineEntityId: string;
409
- readonly clips: readonly ReplacementMediaClipInput[];
410
- /** One placement decision for the whole input-ordered block. */
411
- readonly insertion: MediaClipInsertion;
412
- }
413
- interface ReplaceSequentialClipsInput {
414
- readonly timelineEntityId: string;
415
- readonly oldClipEntityIds: readonly string[];
416
- readonly newClips: readonly ReplacementMediaClipInput[];
417
- readonly onAnchored: 'remap' | 'cascade';
418
- }
419
- interface SetClipVolumeInput {
420
- readonly clipEntityId: string;
421
- /** Playback gain in decibels. */
422
- readonly volume: number;
423
- }
424
- interface LinearClipSpeed {
425
- readonly kind: 'linear';
426
- readonly rate: number;
427
- readonly mode?: string;
428
- }
429
- interface SetClipSpeedInput {
430
- readonly clipEntityId: string;
431
- readonly timeRemapping: LinearClipSpeed | null;
432
- }
433
- interface TrimClipInput {
434
- readonly clipEntityId: string;
435
- readonly sourceRange: SequenceRange<number>;
436
- }
437
- interface VoiceoverTakeResult {
438
- readonly voiceoverClipEntityId: string;
439
- /** The rendered voiceover Audio entity. */
440
- readonly voiceoverAudioEntityId: string;
441
- /** The timbre identity it was synthesized with, when the take declared one. */
442
- readonly voiceEntityId?: string;
443
- /** The pronunciation variant the voiceover was rendered from. */
444
- readonly phoneticScriptEntityId: string;
445
- /** The base-text owner resolved from the PhoneticScript baseEntityIds. */
446
- readonly audioScriptEntityId: string;
447
- readonly captionClipEntityIds: readonly string[];
448
- }
449
- interface MoveVoiceoverInput {
450
- readonly voiceoverClipEntityId: string;
451
- /** Absolute requested timeline start; MEngine resolves and persists the host relation. */
452
- readonly newStartMs: number;
453
- }
454
- interface DeleteVoiceoverInput {
455
- readonly voiceoverClipEntityIds: readonly string[];
456
- }
457
- interface SetBgmInput {
458
- readonly timelineEntityId: string;
459
- readonly bgmClipEntityId: string;
460
- readonly media: AudioMediaAssetFact;
461
- readonly volume: number;
462
- }
463
- interface DeleteBgmInput {
464
- readonly timelineEntityId: string;
465
- }
466
- interface SetCaptionVisibilityInput {
467
- readonly timelineEntityId: string;
468
- readonly hidden: boolean;
469
- }
470
- interface PatchCaptionStyleInput {
471
- readonly timelineEntityId: string;
472
- readonly style: CaptionStyleFields;
473
- }
474
- interface InsertCaptionClipInput {
475
- readonly timelineEntityId: string;
476
- /** Existing generation identity for newly materialized Caption content, distinct from its Clip. */
477
- readonly captionEntityId?: string;
478
- /** Stable placed caption identity, distinct from the Caption content identity. */
479
- readonly captionClipEntityId?: string;
480
- /** Existing bases composed by this variant; includes an AudioScript text owner. */
481
- readonly baseEntityIds: readonly string[];
482
- /** Ordered selection of the AudioScript segments this Caption displays. */
483
- readonly selection: CaptionSegmentSelection;
484
- /** Intrinsic cue length of the Caption entity itself; display comes from the placement. */
485
- readonly durationMs: number;
486
- readonly style?: CaptionStyleFields;
487
- readonly placement: ClipPlacement;
488
- }
489
- interface InsertClipInput {
490
- readonly trackEntityId: string;
491
- /** Existing Sequence media Entity id. Asset ids and URLs are not content ids. */
492
- readonly contentEntityId: string;
493
- readonly sourceRange: SequenceRange<number>;
494
- readonly duration: SequenceDuration<number>;
495
- readonly targetRange?: SequenceRange<number>;
496
- readonly clipPayload?: JsonObject;
497
- }
498
- interface UpdateClipMarkerInput {
499
- readonly clipEntityId: string;
500
- readonly sourceRange?: SequenceRange<number>;
501
- /** Passing `undefined` explicitly removes the optional target range. */
502
- readonly targetRange?: SequenceRange<number> | undefined;
503
- readonly duration?: SequenceDuration<number>;
504
- /** Passing `undefined` explicitly removes the optional remapping value. */
505
- readonly timeRemapping?: JsonValue | undefined;
506
- }
507
- interface MoveClipInput {
508
- readonly clipEntityId: string;
509
- readonly trackEntityId: string;
510
- }
511
- interface ReplaceClipContentInput {
512
- readonly clipEntityId: string;
513
- /** Existing Sequence media Entity id. Asset ids and URLs are not content ids. */
514
- readonly contentEntityId: string;
515
- readonly sourceRange: SequenceRange<number>;
516
- readonly duration: SequenceDuration<number>;
517
- readonly targetRange?: SequenceRange<number>;
518
- readonly timeRemapping?: JsonValue;
519
- }
520
- interface DeleteClipInput {
521
- readonly clipEntityId: string;
522
- }
523
- interface UpdateClipInput {
524
- readonly clipEntityId: string;
525
- /** Complete replacement for the Clip-owned payload. */
526
- readonly payload: JsonObject;
527
- }
528
- type ClipEntityId = EntityId;
529
- //#endregion
530
- //#region src/entity-editor/entity-timeline-editor.d.ts
181
+ //#region src/editor/id-gen.d.ts
531
182
  /**
532
- * Graph-native timeline authoring over authoritative Medeo Entity and Relation rows.
183
+ * Part-id generation, aligned with the online ecosystem.
533
184
  *
534
- * Each mutation is applied to a detached graph, validated as a complete DSL set,
535
- * and committed only after validation succeeds.
536
- */
537
- declare class EntityTimelineEditor {
538
- private readonly idFactory;
539
- private state;
540
- constructor(initialRows: EntityRelationRows, idFactory?: EntityTimelineIdFactory);
541
- rows(): EntityRelationRows;
542
- insertClip(input: InsertClipInput): ClipEntityId;
543
- insertPlacedClip(input: InsertPlacedClipInput): ClipEntityId;
544
- updateClipMarker(input: UpdateClipMarkerInput): void;
545
- setClipPlacement(input: SetClipPlacementInput): void;
546
- moveSequentialClips(input: MoveSequentialClipsInput): void;
547
- moveClipsToStarts(input: MoveClipsToStartsInput): void;
548
- moveClip(input: MoveClipInput): void;
549
- replaceClipContent(input: ReplaceClipContentInput): void;
550
- insertMediaClip(input: InsertMediaClipInput): ClipEntityId;
551
- insertMediaClips(input: InsertMediaClipsInput): readonly ClipEntityId[];
552
- replaceMediaClip(input: ReplaceMediaClipInput): void;
553
- setClipVolume(input: SetClipVolumeInput): void;
554
- setClipSpeed(input: SetClipSpeedInput): void;
555
- trimClip(input: TrimClipInput): void;
556
- replaceSequentialClips(input: ReplaceSequentialClipsInput): readonly ClipEntityId[];
557
- deleteClip(input: DeleteClipInput): void;
558
- deleteClipTree(input: DeleteClipTreeInput): void;
559
- updateClip(input: UpdateClipInput): void;
560
- upsertVoiceoverTake(input: VoiceoverTakeInput): VoiceoverTakeResult;
561
- moveVoiceover(input: MoveVoiceoverInput): void;
562
- deleteVoiceover(input: DeleteVoiceoverInput): void;
563
- setBgm(input: SetBgmInput): ClipEntityId;
564
- deleteBgm(input: DeleteBgmInput): void;
565
- setCaptionVisibility(input: SetCaptionVisibilityInput): void;
566
- patchCaptionStyle(input: PatchCaptionStyleInput): void;
567
- /**
568
- * Place a Caption as a composed variant of an existing AudioScript: the
569
- * entity stores baseEntityIds, selection, optional style, and inherent cue-bounded
570
- * Sequence. This helper does not copy base text. The Clip and its display Marker describe this use;
571
- * moving or stretching the returned Clip later changes the Clip/Marker,
572
- * never the Caption entity or the AudioScript.
573
- */
574
- insertCaptionClip(input: InsertCaptionClipInput): ClipEntityId;
575
- private insertPlacedClipIntoDraft;
576
- private ensureRoleTrack;
577
- /** The existing pronunciation variant a voiceover consumes; composition is required. */
578
- private requireComposedPhoneticScript;
579
- /** Preserve the factual synthesis input, regardless of persisted endpoint positions. */
580
- private ensurePhoneticRender;
581
- private reconcileVoiceoverCaptions;
582
- private ensureRoleTrackForClip;
583
- private replaceCaptionAlignment;
584
- /**
585
- * Remove one placed Caption use. The composed AudioScript outlives the
586
- * caption: it may anchor further captions and remains the text owner.
587
- */
588
- private removeCaptionClipGraph;
589
- private replaceAnchorHost;
590
- /** Rebuild the legacy edit baseline from current visual order before a high-level cascade. */
591
- private normalizeMainSequential;
592
- private resolveOneVoiceoverOverlap;
593
- private applyClipPlacement;
594
- private reanchorAtAbsolute;
595
- private removeAnchoredDescendants;
596
- private removeClipGraph;
597
- private transact;
598
- private mintEntityId;
599
- private createRelation;
600
- private relinkRelation;
601
- private mintRelationId;
602
- }
603
- //#endregion
604
- //#region src/entity-editor/editor-resources.d.ts
605
- declare const roleOrder: {
606
- readonly caption: 0;
607
- readonly video_clip: 1;
608
- readonly speech: 2;
609
- readonly bgm: 3;
610
- };
611
- type EditorTrackRole = keyof typeof roleOrder;
612
- interface EditorFoundation {
613
- readonly rows: EntityRelationRows;
614
- readonly timelineEntityId: string;
615
- readonly trackEntityIds: Readonly<Record<EditorTrackRole, string>>;
616
- /** Initial or current AudioScript content ID selected by the foundation. */
617
- readonly audioScriptEntityId: string;
618
- }
619
- /**
620
- * MEngine editor policy, not a cardinality restriction on the general-purpose DSL.
185
+ * The authoritative online producers — agent-harness (`@harness/shared`
186
+ * `genObjId`) and director.v2 (`common/obj_id.py` `gen_obj_id`) — both mint part
187
+ * ids as `` `${prefix}_${ulid()}` ``, and real captured drafts use exactly that
188
+ * shape (`clip_…` / `spe_…` / `cap_…` / `bgm_…`, each a 26-char ULID). The engine
189
+ * previously emitted `vc_<base36 timestamp><6 random>`, a different prefix AND a
190
+ * different encoding — the sole cross-repo id divergence. This module removes it
191
+ * by emitting the same `<prefix>_<ULID>` bytes.
621
192
  *
622
- * Media variants share one entity identity with their Asset: every
623
- * Image/Video/Audio/Voice Entity must carry its own external locator, every
624
- * external asset id has exactly one claimant, and no media variant may be
625
- * bound through a legacy `physical-asset` Relation. Dual-entity media graphs
626
- * are rejected, not migrated. Caption composes AudioScript text and may associate with a physical text Asset.
193
+ * The ULID is generated inline (Crockford Base32, 48-bit time + 80-bit random)
194
+ * rather than pulling the `ulid` npm package: the randomness class matches the
195
+ * old generator (both `Math.random`-based) and it keeps `@mengine/medeo-client`
196
+ * dependency-free for a purely mechanical id string. Part ids only need to be
197
+ * unique and lexicographically time-sortable, which this satisfies.
627
198
  */
628
- declare function assertCanonicalEditorResources(rows: EntityRelationRows): void;
629
199
  /**
630
- * Commit-transition policy shared by the editor, the HTTP commit boundary, the
631
- * host tool, and the entity stores. It compares the authoritative before and
632
- * after rows of one CAS commit and enforces the single-identity write rules
633
- * on the complete after state, with no exemption for historical graphs:
634
- *
635
- * 1. every Image/Video/Audio/Voice Entity carries its own Asset `external`
636
- * identity;
637
- * 2. no `physical-asset` Relation may bind a media variant;
638
- * 3. a self-carried media identity is immutable — it cannot be rewritten to
639
- * another asset id.
640
- *
641
- * Dual-entity media graphs are rejected instead of being migrated or merged
642
- * implicitly. Deleting media is explicit and allowed.
200
+ * Online part-id semantic prefixes. `clip` (video clip) is the only value the
201
+ * engine currently mints (see `addVideoClips`); the rest are declared so the
202
+ * type documents the shared vocabulary and guards against reintroducing the old
203
+ * `vc`/`sp`/`cp`/`bg` names. Speech/caption/bgm ids arrive pre-minted in op
204
+ * payloads, so the engine never generates them itself.
643
205
  */
644
- declare function assertMediaAssetWritePolicy(before: EntityRelationRows, after: EntityRelationRows): void;
645
- /** Add only missing editor structure; existing identities and owned settings are never replaced. */
646
- declare function ensureEditorFoundation(initial: EntityRelationRows, idFactory?: EntityTimelineIdFactory, timelinePayload?: EntityRow['payload'], selectedAudioScriptEntityId?: string | null): EditorFoundation;
647
- //#endregion
648
- //#region src/entity-editor/media-asset-import.d.ts
649
- interface ImportedMediaAsset {
650
- readonly rows: EntityRelationRows;
651
- /** The single media variant identity for this asset id; it is its own Asset. */
652
- readonly contentEntityId: string;
653
- /** The timbre identity of a synthesized voiceover; absent for recorded media. */
654
- readonly voiceEntityId?: string;
655
- }
656
- /**
657
- * Import at the editor boundary, not at asset generation time. Existing
658
- * provenance is retained.
659
- *
660
- * A media variant is a logical facet of its Asset and shares one entity
661
- * identity: the import mints exactly one entity of the media kind that carries
662
- * the external locator itself, and deduplicates only against existing variants
663
- * that already carry the same `(system, key)`. Legacy dual-entity graphs
664
- * (`asset` row plus a `physical-asset` binding) are not reused and are
665
- * rejected by the canonical resource policy instead of being migrated.
666
- */
667
- declare function importMediaAsset(initial: EntityRelationRows, fact: MediaAssetFact, idFactory?: EntityTimelineIdFactory): ImportedMediaAsset;
668
- //#endregion
669
- //#region src/entity-editor/legacy-entity-migration.d.ts
670
- /** One-time import only. Ordinary editor operations must never reverse-diff a legacy document. */
671
- declare function migrateLegacyTimelineToEntities(legacy: VideoDocument, assetFacts: readonly MediaAssetFact[], initial?: EntityRelationRows, idFactory?: EntityTimelineIdFactory): EntityRelationRows;
672
- /** Server gate: a cutover may change representation, never the existing render facts. */
673
- declare function assertEntityProjectionPreservesLegacy(legacy: VideoDocument, projection: VideoDocument, rows: EntityRelationRows): void;
674
- //#endregion
675
- //#region src/entity-editor/caption-content.d.ts
676
- interface CaptionContentInput {
677
- readonly contentEntityId: string;
678
- readonly audioScriptEntityId: string;
679
- readonly text: string;
680
- readonly selection?: CaptionSegmentSelection;
681
- readonly durationMs: number;
682
- }
683
- /** Author Caption content from semantic intent; callers never reconcile variant bases or assembled fields. */
684
- declare function prepareCaptionContent(rows: EntityRelationRows, input: CaptionContentInput): EntityRow<'caption'>;
685
- //#endregion
686
- //#region src/entity-editor/document-audio-script.d.ts
687
- interface DocumentAudioScript {
688
- readonly entityId: string;
689
- readonly segments: readonly (ScriptTextSegment & Readonly<Record<string, unknown>>)[];
690
- }
691
- /** State exposing the current AudioScript content version attached to the project. */
692
- interface DocumentAudioScriptState {
693
- readonly rows: EntityRelationRows;
694
- /** Current attachment; initialized projects point to a real script, including an empty one. */
695
- readonly audioScriptEntityId: string | null;
696
- }
697
- /** Read only the attached version and preserve every segment; never aggregate other scripts. */
698
- declare function readDocumentAudioScript(state: DocumentAudioScriptState): DocumentAudioScript;
699
- //#endregion
700
- //#region src/entity-crdt/field-changes.d.ts
701
- /** List members are addressed by identity, never a transient array offset. */
702
- type FieldPath = readonly (string | {
703
- elementId: string;
704
- })[];
705
- type FieldChange = {
706
- op: 'set';
707
- path: FieldPath;
708
- value: JsonValue;
709
- } | {
710
- op: 'unset';
711
- path: FieldPath;
712
- } | {
713
- op: 'text.splice';
714
- path: FieldPath;
715
- index: number;
716
- deleteCount: number;
717
- text: string;
718
- } | {
719
- op: 'list.insert';
720
- path: FieldPath;
721
- value: JsonValue;
722
- beforeElementId: string | null;
723
- } | {
724
- op: 'list.move';
725
- path: FieldPath;
726
- elementId: string;
727
- beforeElementId: string | null;
728
- } | {
729
- op: 'list.remove';
730
- path: FieldPath;
731
- elementId: string;
732
- };
733
- declare function assertFieldChanges(changes: readonly FieldChange[]): void;
734
- /** Resolve against the sequential causal view; the numeric path never crosses the API boundary. */
735
- declare function resolveFieldPath(payload: JsonObject, path: FieldPath): (string | number)[];
736
- /** Detached plan evaluation. Native compilation replays the original operations, not this snapshot. */
737
- declare function applyFieldChanges(payload: JsonObject, changes: readonly FieldChange[]): JsonObject;
738
- //#endregion
739
- //#region src/entity-crdt/entity-document.d.ts
740
- declare const LORO_ENTITY_SCHEMA = "medeo.entities.loro.v1";
741
- interface EntityDocumentState {
742
- readonly rows: EntityRelationRows;
743
- readonly project: Readonly<Record<string, string>>;
744
- }
745
- type Command = {
746
- type: 'create';
747
- row: EntityRow;
748
- } | {
749
- type: 'selection-baseline';
750
- root: string;
751
- fingerprint: string;
752
- } | {
753
- type: 'order';
754
- group: string;
755
- roots: string[];
756
- token: string;
757
- } | {
758
- type: 'write';
759
- root: string;
760
- payload: JsonObject;
761
- token: string;
762
- } | {
763
- type: 'text';
764
- root: string;
765
- path: readonly (string | number)[];
766
- start: number;
767
- deleteCount: number;
768
- text: string;
769
- token: string;
770
- } | {
771
- type: 'field';
772
- root: string;
773
- path: (string | number)[];
774
- change: FieldChange;
775
- token: string;
776
- } | {
777
- type: 'relation-field';
778
- root: string;
779
- path: (string | number)[];
780
- change: FieldChange;
781
- } | {
782
- type: 'delete';
783
- root: string;
784
- } | {
785
- type: 'relation';
786
- row: RelationRow;
787
- } | {
788
- type: 'relation-fields';
789
- root: string;
790
- metadata: JsonObject;
791
- trace: JsonObject;
792
- } | {
793
- type: 'unlink';
794
- root: string;
795
- } | {
796
- type: 'attach';
797
- slot: string;
798
- entityId: string;
799
- };
800
- /** Plain domain objects assembled from native Loro state, never a second writable authority. */
801
- declare function readEntityDocument(doc: LoroDoc, allowSelectionConflicts?: boolean): EntityDocumentState;
802
- /** Native editing containers survive domain version changes and merge independently. */
803
- declare class LoroEntityDocument {
804
- readonly doc: LoroDoc;
805
- private readonly validate?;
806
- private readonly undoManager;
807
- constructor(doc: LoroDoc, validate?: ((state: EntityDocumentState) => void) | undefined);
808
- /** Open a causal snapshot using the same Loro runtime as the compiler. */
809
- static fromSnapshot(snapshot: Uint8Array, validate?: (state: EntityDocumentState) => void): LoroEntityDocument;
810
- static create(rows: EntityRelationRows, project?: Readonly<Record<string, string>>, peerId?: PeerID): LoroEntityDocument;
811
- snapshot(): EntityDocumentState;
812
- relationsOf(entityId: string): readonly RelationRow[];
813
- /** Resolve a queued edit target through its native identity without changing history. */
814
- resolveCurrentEntityId(id: string): string;
815
- getVersion(id: string): EntityRow | undefined;
816
- /** The callback and every domain validation execute on a causally complete fork first. */
817
- transact(edit: (draft: LoroEntityDraft) => void): Uint8Array;
818
- /** Import preserves native operation identities; projection errors never discard remote operations. */
819
- import(update: Uint8Array): void;
820
- /** Bind a saved snapshot without rewriting text operations or resolving selection conflicts. */
821
- bindAudioScriptAsset(entityId: string, assetId: string, expectedContentHash: string): Uint8Array;
822
- canUndo(): boolean;
823
- canRedo(): boolean;
824
- undo(): boolean;
825
- redo(): boolean;
826
- private historyEdit;
827
- }
828
- declare class LoroEntityDraft {
829
- private readonly doc;
830
- readonly commands: Command[];
831
- private readonly selectedRoots;
832
- private readonly relationAliases;
833
- constructor(doc: LoroDoc);
834
- snapshot(): EntityDocumentState;
835
- order(groupId: string, entityIds: readonly string[]): void;
836
- /** Project the final scalar placement intents onto the existing native ordering containers. */
837
- reconcileOrder(rows: EntityRelationRows): void;
838
- create(row: EntityRow): void;
839
- delete(entityId: string): void;
840
- attach(slot: string, entityId: string): void;
841
- link(row: RelationRow): void;
842
- patchRelation(relationId: string, metadata: JsonObject, trace: JsonObject): void;
843
- unlink(relationId: string): void;
844
- private relationRoot;
845
- update(entityId: string, fields: JsonObject): void;
846
- declare(entityId: string, fields: JsonObject): void;
847
- replaceOwned(entityId: string, payload: JsonObject): void;
848
- editText(entityId: string, path: readonly (string | number)[], start: number, deleteCount: number, text: string): void;
849
- /** Generic assembled-field edit compiled at the author's causal position. */
850
- change(entityId: string, changes: readonly FieldChange[]): void;
851
- changeRelation(relationId: string, changes: readonly FieldChange[]): void;
852
- captureSelectionBaselines(): void;
853
- private record;
854
- }
855
- //#endregion
856
- //#region src/entity-crdt/compile-rows.d.ts
857
- /** Lower a detached ordinary-object edit against its actual causal Loro baseline. */
858
- declare function compileEntityRows(snapshot: Uint8Array, rows: EntityRelationRows, validate?: (state: EntityDocumentState) => void): {
859
- update: Uint8Array;
860
- state: EntityDocumentState;
861
- };
862
- /** Compile an edit on an existing peer, retaining its native local undo history. */
863
- declare function applyEntityRows(editor: LoroEntityDocument, rows: EntityRelationRows): {
864
- update: Uint8Array;
865
- state: EntityDocumentState;
866
- };
867
- //#endregion
868
- //#region src/editor/journal.d.ts
869
- /**
870
- * Wire a plain-memory adapter + editor that share a recording id factory, so
871
- * every mutating transact lands in `journal` with ordered `generated_ids`.
872
- */
873
- declare function createEditSandbox(document: VideoDocument, options?: PlainMemoryAdapterOptions): {
874
- adapter: PlainMemoryAdapter;
875
- editor: SemanticEditor;
876
- journal: readonly JournalEntry[];
877
- };
878
- /**
879
- * Re-drive `doc` from a recorded journal, forcing each entry's `generated_ids`
880
- * through a queue-backed id factory. Never mints fresh ids: an empty queue on
881
- * demand throws `unrecorded id`; leftover ids after an entry throws
882
- * `unconsumed ids`. Legacy entries without `generated_ids` are treated as `[]`.
883
- */
884
- declare function replayJournal(doc: SemanticDocumentAdapter, journal: readonly JournalEntry[]): Promise<void>;
206
+ type PartIdPrefix = 'clip' | 'spe' | 'cap' | 'bgm' | 'ti';
207
+ declare function generatePartId(prefix: PartIdPrefix): string;
885
208
  //#endregion
886
209
  //#region src/editor/snapshot-utils.d.ts
887
210
  /** Main-track item identity read from a raw snapshot (only `part_id` is needed). */
@@ -1070,8 +393,6 @@ declare class ManualSyncDoc {
1070
393
  private readonly client;
1071
394
  private readonly doc;
1072
395
  private readonly adapter;
1073
- /** Whether this document's timeline is owned by the Entity graph. */
1074
- isEntityDocument(): boolean;
1075
396
  readonly editor: SemanticEditor;
1076
397
  /**
1077
398
  * The version the server is known to hold. Starts empty (nothing confirmed)
@@ -1103,16 +424,6 @@ declare class ManualSyncDoc {
1103
424
  editorPeerId(): PeerID;
1104
425
  /** Current content projected into the compatible track and part read shape. */
1105
426
  content(): VideoDraftContent;
1106
- /**
1107
- * Replay a deterministic sandbox journal into this document.
1108
- *
1109
- * The adapter stays private so callers cannot bypass the manual-sync
1110
- * lifecycle; journal replay is the one host-side operation that needs the
1111
- * adapter's transaction boundary and recorded id queue. Durability is still
1112
- * explicit: call {@link push} after replay and report success only from its
1113
- * verdict.
1114
- */
1115
- replayJournal(journal: readonly JournalEntry[]): Promise<void>;
1116
427
  /**
1117
428
  * Mark the document state the caller has just observed, for a later
1118
429
  * {@link hasChangedSince}.
@@ -1321,13 +632,18 @@ declare class MengineAckFailedError extends Error {
1321
632
  readonly cause: Error | undefined;
1322
633
  constructor(reason: 'timeout' | 'rejected' | 'failed', code: string | undefined, cause: Error | undefined, message: string);
1323
634
  }
635
+ type MengineLocalSaveState = LocalSaveState;
636
+ interface WaitForLocalSaveOptions {
637
+ /** Only limits waiting, never cancels persistence. */
638
+ timeoutMs?: number;
639
+ }
1324
640
  interface WaitForServerAckOptions {
1325
641
  /** Deadline in ms. Rejects with reason `timeout` when it elapses. */
1326
642
  timeoutMs?: number;
1327
643
  }
1328
644
  /** Document-level confirmation is independent of local operation completion. */
1329
645
  interface MengineDocSyncState {
1330
- /** Remote-only imports do not create a new local confirmation obligation. */
646
+ /** Server-originated imports do not create a new local confirmation obligation. */
1331
647
  readonly confirmation: 'unknown' | 'pending' | 'confirmed';
1332
648
  /** Transport/activity phase. Idle does not imply confirmation; failure details
1333
649
  * remain available through push outcomes and confirmation wait errors. */
@@ -1342,12 +658,10 @@ interface MengineDocSessionOptions {
1342
658
  * Browsers should pass an `IndexedDBDocStorage` for refresh/cross-tab support.
1343
659
  */
1344
660
  localStorage?: DocStorageLike;
661
+ /** A freshly fetched remote snapshot to merge into storage before loading.
662
+ * Existing local changes are retained; the host owns any online startup gate. */
663
+ initialSnapshot?: Uint8Array;
1345
664
  sseReconnectDelayMs?: number;
1346
- /**
1347
- * Keep remote synchronization read-only: pull snapshot/diffs and subscribe to
1348
- * SSE updates, but never POST local Loro updates to the server.
1349
- */
1350
- readonlyMode?: boolean;
1351
665
  }
1352
666
  /**
1353
667
  * A live editing session for one Medeo document — the single entry point clients
@@ -1383,6 +697,7 @@ declare class MengineDocSession {
1383
697
  private started;
1384
698
  private startTask;
1385
699
  private destroyed;
700
+ private closeTask;
1386
701
  private lifetime;
1387
702
  private hasConnected;
1388
703
  private initialVersionValue;
@@ -1433,18 +748,6 @@ declare class MengineDocSession {
1433
748
  * step. The committed change drives DocManager's local-update push.
1434
749
  */
1435
750
  get editor(): SemanticEditor;
1436
- /**
1437
- * Opaque version token of the local oplog (base64 `VersionVector.encode`).
1438
- * Equality-comparable only: equal means no observed change (local or
1439
- * remote-arrived) since the token was taken. Throws when not started.
1440
- */
1441
- version(): string;
1442
- /**
1443
- * The live document adapter, exposed for journal replay (commit channel).
1444
- * Replaying through it still goes SemanticEditor → Loro → mengine-server —
1445
- * no write bypass. Typed by the narrow interface on purpose.
1446
- */
1447
- get documentAdapter(): SemanticDocumentAdapter;
1448
751
  /** Current document snapshot (read model). */
1449
752
  snapshot(): VideoDocument;
1450
753
  /** Current-session undo/redo availability. Loading and closed sessions report false. */
@@ -1488,7 +791,17 @@ declare class MengineDocSession {
1488
791
  */
1489
792
  start(): Promise<VideoDocument>;
1490
793
  private open;
794
+ getLocalSaveState(): MengineLocalSaveState;
795
+ /** Immediately reports local transaction state; independent of server confirmation. */
796
+ subscribeLocalSaveState(cb: (state: MengineLocalSaveState) => void): () => void;
797
+ /** Waits until all local saves finish, including edits made while waiting. Does not wait for the network. */
798
+ waitForLocalSave(options?: WaitForLocalSaveOptions): Promise<void>;
799
+ /** Stop accepting edits and drain local persistence before releasing resources.
800
+ * A failed local write keeps retrying, even after the host has unmounted.
801
+ * Hosts should use this for normal teardown; destroy() is immediate cancellation. */
802
+ close(): Promise<void>;
1491
803
  getSyncState(): MengineDocSyncState;
804
+ private trackLocalVersion;
1492
805
  private confirmationTarget;
1493
806
  /** Immediately supplies current state; unsubscribe when the host changes docs. */
1494
807
  subscribeSyncState(cb: (state: MengineDocSyncState) => void): () => void;
@@ -1685,6 +998,103 @@ type MakeEmptyPart = (durationMs: number) => {
1685
998
  */
1686
999
  declare function cascadeAfterVideoClipChanges(doc: TimelineDoc, makeEmptyPart: MakeEmptyPart): void;
1687
1000
  //#endregion
1001
+ //#region src/timeline-core/bridge.d.ts
1002
+ /**
1003
+ * Bridge between the authoritative `VideoDocument` (position-only facts) and the
1004
+ * flat `TimelineDoc` the cascade primitives solve over.
1005
+ *
1006
+ * The data flow is single-directional (RFC 02 §7/§10): ops write only facts
1007
+ * (`time_position`, parts) to `VideoDocument`; absolute time, `part_aggregations`,
1008
+ * total duration, and gap fillers are NOT stored — the projection derives them
1009
+ * on read by running the cascade. There is no write-back of solved positions.
1010
+ *
1011
+ * - `solveVideoDocument` seeds a `TimelineDoc` from each item's `time_position`,
1012
+ * runs the full cascade, and returns the derived read-view (abs / aggregations
1013
+ * / duration). It is the single solve shared by the legacy `VideoDraft`
1014
+ * projection.
1015
+ * - `ensureLaneTrack` / `findLaneTrack` locate (or mint) a secondary lane's
1016
+ * track row in the draft, so ops can write authoritative facts onto the right
1017
+ * named container (lane = container).
1018
+ */
1019
+ /** The projection-derived read-view of a `VideoDocument` (RFC 02 §7). */
1020
+ interface SolvedVideoDocument {
1021
+ absByPartId: Map<string, number>;
1022
+ aggregations: PartAggregation[];
1023
+ durationMs: number;
1024
+ partLibrary: Record<string, PartUnion>;
1025
+ /**
1026
+ * Part ids of the gap fillers this solve minted.
1027
+ *
1028
+ * They exist only inside the solve: gap filling needs them so the clips after a
1029
+ * gap land at the right absolute time, but they are not authoritative state and
1030
+ * the read view does not carry them (see `fromVideoDocument`).
1031
+ *
1032
+ * Reported as ids rather than left for the caller to detect, because the caller
1033
+ * *cannot* detect them. The obvious predicate — `origin_media_id === ''` — also
1034
+ * matches an empty clip a writer placed on purpose (`batch_replace_video_clip_sequence`
1035
+ * documents "Omit to create an empty clip placeholder"), and those are
1036
+ * authoritative parts that must survive the projection. The mint callback is the
1037
+ * only place that knows the difference.
1038
+ *
1039
+ * Note this deliberately excludes the fillers that gap filling *extended* rather
1040
+ * than minted (`fillMainTrackTimeGaps` cases 1 and 2): those are authoritative
1041
+ * empty clips already in `part_library`, and only their length is derived.
1042
+ */
1043
+ derivedFillerPartIds: Set<string>;
1044
+ }
1045
+ /**
1046
+ * Solve a `VideoDocument` (authoritative, position-only) into its derived
1047
+ * read-view: absolute time per item, `part_aggregations`, and total duration.
1048
+ * This is the read side of the single-directional flow — never written back.
1049
+ */
1050
+ declare function solveVideoDocument(document: VideoDocument): SolvedVideoDocument;
1051
+ /** The named container a secondary lane lives in. */
1052
+ type SecondaryLane = 'speech' | 'caption' | 'bgm';
1053
+ /** A lane's track kind: the `video_clip` main lane plus the three secondary lanes. */
1054
+ type LaneKind = SecondaryLane | 'video_clip';
1055
+ /**
1056
+ * The four lanes in top-to-bottom stack order — the order a `tracks` list holds
1057
+ * them in (see {@link laneRank}).
1058
+ *
1059
+ * Exported so a document can be seeded with all four lanes up front. That seed is
1060
+ * not cosmetic: {@link ensureLaneTrack} is find-then-mint over a `LoroMovableList`,
1061
+ * so two concurrent writers that each mint the same absent lane both keep their
1062
+ * row, and the merged document holds two tracks for one lane. For the main lane
1063
+ * that is fatal — `videoDocumentSchema` allows at most one `video_clip` track, so
1064
+ * the merged document stops being projectable at all, symmetrically on both
1065
+ * replicas. Pre-seeding every lane makes `ensureLaneTrack` always take its find
1066
+ * branch, which removes the race by construction rather than by detection.
1067
+ *
1068
+ * What closes the race is that a track with the lane's `parts_kind` EXISTS — the
1069
+ * lookup is by kind, not by id. So a seed is only safe if it covers every lane:
1070
+ * a partial seed leaves the uncovered lanes exactly as exposed as before.
1071
+ */
1072
+ declare const LANE_KINDS_IN_STACK_ORDER: readonly LaneKind[];
1073
+ /**
1074
+ * The conventional track id for a lane (`main_track`, `<kind>_track`). Shared by
1075
+ * the up-front seed and {@link ensureLaneTrack}'s lazy mint so a document's lane
1076
+ * ids do not depend on which of the two created the track.
1077
+ *
1078
+ * Ids are cosmetic to the merge itself — lane lookup goes by `parts_kind`, so
1079
+ * drifting them apart would not reopen the concurrent-mint race. They matter to
1080
+ * readers that address a lane by id (the FE editor's panes, fixtures), which is
1081
+ * why there is one convention rather than two.
1082
+ */
1083
+ declare function laneTrackId(kind: LaneKind): string;
1084
+ /**
1085
+ * Locate a lane's track row in the single `tracks` list by kind, minting an empty
1086
+ * row in lane-stacking order if absent (reference/17 §4: lane = `parts_kind`).
1087
+ * Ops use this to write authoritative items onto the right lane. The track id
1088
+ * comes from {@link laneTrackId}, shared with the up-front seed.
1089
+ *
1090
+ * The mint branch is a concurrency hazard, not a convenience: see
1091
+ * {@link LANE_KINDS_IN_STACK_ORDER}. A document seeded with all four lanes never
1092
+ * reaches it.
1093
+ */
1094
+ declare function ensureLaneTrack(draft: VideoDocumentDraft, kind: LaneKind): TrackDraft;
1095
+ /** Find a secondary lane's track row without minting it. */
1096
+ declare function findLaneTrack(draft: VideoDocumentDraft, kind: SecondaryLane): TrackDraft | undefined;
1097
+ //#endregion
1688
1098
  //#region src/timeline-core/locate.d.ts
1689
1099
  /**
1690
1100
  * Forward positioning for write-time ops (RFC 02 §9.1) — NOT a cascade.
@@ -1728,12 +1138,4 @@ declare function hostForAbsMs(ranges: MainClipRange[], absMs: number): MainClipR
1728
1138
  */
1729
1139
  declare function relativePositionForAbs(ranges: MainClipRange[], absMs: number): TrackItemTimePosition;
1730
1140
  //#endregion
1731
- //#region src/entity-crdt/audio-script-assets.d.ts
1732
- /** A resource is a snapshot of text; the native Loro text remains the editing authority. */
1733
- declare function audioScriptAssetContent(payload: JsonObject): JsonObject;
1734
- declare function audioScriptAssetHash(payload: JsonObject): string;
1735
- declare function hasAudioScriptAsset(payload: JsonObject): boolean;
1736
- /** Internal fingerprint prevents a resource from silently describing an older text revision. */
1737
- declare function audioScriptAssetFields(payload: JsonObject, assetId: string): JsonObject;
1738
- //#endregion
1739
- 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 };
1141
+ export { type Aggregation, type Attachment, type BgmPart, type CaptionPart, type CaptionStyle, type CommitOptions, DEFAULT_UNIT_TIME_MS, type DerivedItemPosition, type DocStorageLike, type DocVersionMark, IMPLEMENTED_SEMANTIC_OP_KINDS, type ImplementedSemanticOpKind, LANE_KINDS_IN_STACK_ORDER, type LaneKind, type MainClipRange, type MakeEmptyPart, ManualSyncDoc, type ManualSyncDocOptions, MedeoHttpDocStorage, type MedeoHttpDocStorageOptions, MemoryDocStorage, MengineAckFailedError, type MengineAuditEntry, type MengineAuditResponse, MengineDocSession, type MengineDocSessionOptions, type MengineDocSessionUpdateEvent, type MengineDocSyncState, type MengineDocumentVersion, 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, MirrorVideoDocumentAdapter, type MirrorVideoDocumentOptions, type OpActor, type PartAggregation, type PartKind, type PartUnion, type PlannedSemanticOpKind, type PullFailureReason, type PullResult, type PushOutcome, type PushOutcomeKind, type PushResult, type PushResultKind, SchemaValidator, type SemanticDocumentAdapter, SemanticEditor, type SemanticOpInput, type SemanticOpKind, type SemanticOpName, 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, 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 WaitForLocalSaveOptions, type WaitForServerAckOptions, arrangeMainTrackSeamlessly, assertValidVideoDocument, base64ToBytes, buildInitialVideoDocument, buildSpeechHostMap, bytesToBase64, cascadeAfterVideoClipChanges, createMirrorVideoDocument, createMirrorVideoDocumentAdapter, decodeDocVersionMark, derivePositionFromAbs, encodeDocVersionMark, ensureLaneTrack, fillMainTrackTimeGaps, findLaneTrack, fromVideoDocument, generatePartId, getAt, hostForAbsMs, isEmptyVideoClip, isImplementedSemanticOpKind, isMap, laneTrackId, mainTrackRanges, partDurationMs, partUnionSchema, readMainTrackItems, readMengineEventStream, readPart, readPartDurationMs, readVideoDocumentFromDraft, reassignSpeechesToVideoClipsByTime, recalculateTimelineDuration, relativePositionForAbs, resolveAllSpeechOverlaps, resolveSpeechOverlapByShiftingVideos, safeDurationMs, index_d_exports as schemas, snapshotToPlain, solveVideoDocument, syncAggregatedClipsTimePosition, toVideoDocument, validateVideoDocument, videoDocumentMirrorSchema, videoDocumentSchema };