@mengine/medeo-client 2.0.1-alpha.0 → 2.0.1-alpha.10

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,6 +1,7 @@
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";
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-qAoWdqvp.js";
2
3
  import { LoroDoc, PeerID } from "loro-crdt";
3
- import { DocState, LocalSaveState } from "@mengine/sync";
4
+ import { DocState } from "@mengine/sync";
4
5
  import { BaseDocStorage, Connection, DocDiff, DocPushReceipt, DocSnapshotRecord, DocStorage, DocStorageOptions, DocUpdate, DocUpdateRecord } from "@mengine/storage";
5
6
 
6
7
  //#region src/client/base64.d.ts
@@ -173,36 +174,716 @@ interface MengineEventStreamOptions {
173
174
  /** Fired once the stream response is established (HTTP ok, body readable). */
174
175
  onOpen?(): void;
175
176
  onUpdate(event: MengineSseUpdateEvent): void;
177
+ /** A committed update omitted from live transport; fetch the missing operations by VV. */
178
+ onResync?(): void;
176
179
  }
177
180
  declare function readMengineEventStream(options: MengineEventStreamOptions): Promise<void>;
178
181
  //#endregion
179
- //#region src/editor/id-gen.d.ts
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
531
+ /**
532
+ * Graph-native timeline authoring over authoritative Medeo Entity and Relation rows.
533
+ *
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.
621
+ *
622
+ * Resources live on Asset entities and are reached through `from-asset`: no
623
+ * other entity carries a locator, one Asset claims each `(system, key)` pair,
624
+ * and media reaches at most one Asset. Media whose bytes are not named through
625
+ * that Relation is rejected rather than guessed at.
626
+ */
627
+ declare function assertCanonicalEditorResources(rows: EntityRelationRows): void;
180
628
  /**
181
- * Part-id generation, aligned with the online ecosystem.
629
+ * Commit-transition policy shared by the editor, the HTTP commit boundary, the
630
+ * host tool, and the entity stores. It compares the authoritative before and
631
+ * after rows of one CAS commit and enforces the resource rules on the complete
632
+ * after state, with no exemption for historical graphs:
182
633
  *
183
- * The authoritative online producers — agent-harness (`@harness/shared`
184
- * `genObjId`) and director.v2 (`common/obj_id.py` `gen_obj_id`) — both mint part
185
- * ids as `` `${prefix}_${ulid()}` ``, and real captured drafts use exactly that
186
- * shape (`clip_…` / `spe_…` / `cap_…` / `bgm_…`, each a 26-char ULID). The engine
187
- * previously emitted `vc_<base36 timestamp><6 random>`, a different prefix AND a
188
- * different encoding — the sole cross-repo id divergence. This module removes it
189
- * by emitting the same `<prefix>_<ULID>` bytes.
634
+ * 1. every media Entity reaches exactly one Asset through `from-asset`;
635
+ * 2. no entity other than an Asset carries a locator;
636
+ * 3. an Asset's locator is immutable — pointing it at other bytes would
637
+ * silently rewrite every entity already made from it.
190
638
  *
191
- * The ULID is generated inline (Crockford Base32, 48-bit time + 80-bit random)
192
- * rather than pulling the `ulid` npm package: the randomness class matches the
193
- * old generator (both `Math.random`-based) and it keeps `@mengine/medeo-client`
194
- * dependency-free for a purely mechanical id string. Part ids only need to be
195
- * unique and lexicographically time-sortable, which this satisfies.
639
+ * Deleting media is explicit and allowed.
196
640
  */
641
+ declare function assertMediaAssetWritePolicy(before: EntityRelationRows, after: EntityRelationRows): void;
642
+ /** Add only missing editor structure; existing identities and owned settings are never replaced. */
643
+ declare function ensureEditorFoundation(initial: EntityRelationRows, idFactory?: EntityTimelineIdFactory, timelinePayload?: EntityRow['payload'], selectedAudioScriptEntityId?: string | null): EditorFoundation;
644
+ //#endregion
645
+ //#region src/entity-editor/media-asset-import.d.ts
646
+ interface ImportedMediaAsset {
647
+ readonly rows: EntityRelationRows;
648
+ /** The media entity for this asset id. */
649
+ readonly contentEntityId: string;
650
+ /** The Asset the media was made from; shared by every entity naming the same bytes. */
651
+ readonly assetEntityId: string;
652
+ /** The timbre identity of a synthesized voiceover; absent for recorded media. */
653
+ readonly voiceEntityId?: string;
654
+ }
197
655
  /**
198
- * Online part-id semantic prefixes. `clip` (video clip) is the only value the
199
- * engine currently mints (see `addVideoClips`); the rest are declared so the
200
- * type documents the shared vocabulary and guards against reintroducing the old
201
- * `vc`/`sp`/`cp`/`bg` names. Speech/caption/bgm ids arrive pre-minted in op
202
- * payloads, so the engine never generates them itself.
656
+ * Import at the editor boundary, not at asset generation time. Existing
657
+ * provenance is retained.
658
+ *
659
+ * The bytes are named once, on an Asset entity, and the media entity reaches
660
+ * them through a `from-asset` Relation. Re-importing the same `(system, key)`
661
+ * reuses that Asset and the media already made from it, so one stored resource
662
+ * is never copied into several rows.
203
663
  */
204
- type PartIdPrefix = 'clip' | 'spe' | 'cap' | 'bgm' | 'ti';
205
- declare function generatePartId(prefix: PartIdPrefix): string;
664
+ declare function importMediaAsset(initial: EntityRelationRows, fact: MediaAssetFact, idFactory?: EntityTimelineIdFactory): ImportedMediaAsset;
665
+ //#endregion
666
+ //#region src/entity-editor/legacy-entity-migration.d.ts
667
+ /** One-time import only. Ordinary editor operations must never reverse-diff a legacy document. */
668
+ declare function migrateLegacyTimelineToEntities(legacy: VideoDocument, assetFacts: readonly MediaAssetFact[], initial?: EntityRelationRows, idFactory?: EntityTimelineIdFactory): EntityRelationRows;
669
+ /** Server gate: a cutover may change representation, never the existing render facts. */
670
+ declare function assertEntityProjectionPreservesLegacy(legacy: VideoDocument, projection: VideoDocument, rows: EntityRelationRows): void;
671
+ //#endregion
672
+ //#region src/entity-editor/caption-content.d.ts
673
+ interface CaptionContentInput {
674
+ readonly contentEntityId: string;
675
+ readonly audioScriptEntityId: string;
676
+ readonly text: string;
677
+ readonly selection?: CaptionSegmentSelection;
678
+ readonly durationMs: number;
679
+ }
680
+ /** Author Caption content from semantic intent; callers never reconcile variant bases or assembled fields. */
681
+ declare function prepareCaptionContent(rows: EntityRelationRows, input: CaptionContentInput): EntityRow<'caption'>;
682
+ //#endregion
683
+ //#region src/entity-editor/document-audio-script.d.ts
684
+ interface DocumentAudioScript {
685
+ readonly entityId: string;
686
+ readonly segments: readonly (ScriptTextSegment & Readonly<Record<string, unknown>>)[];
687
+ }
688
+ /** State exposing the current AudioScript content version attached to the project. */
689
+ interface DocumentAudioScriptState {
690
+ readonly rows: EntityRelationRows;
691
+ /** Current attachment; initialized projects point to a real script, including an empty one. */
692
+ readonly audioScriptEntityId: string | null;
693
+ }
694
+ /** Read only the attached version and preserve every segment; never aggregate other scripts. */
695
+ declare function readDocumentAudioScript(state: DocumentAudioScriptState): DocumentAudioScript;
696
+ //#endregion
697
+ //#region src/entity-crdt/field-changes.d.ts
698
+ /** List members are addressed by identity, never a transient array offset. */
699
+ type FieldPath = readonly (string | {
700
+ elementId: string;
701
+ })[];
702
+ type FieldChange = {
703
+ op: 'set';
704
+ path: FieldPath;
705
+ value: JsonValue;
706
+ } | {
707
+ op: 'unset';
708
+ path: FieldPath;
709
+ } | {
710
+ op: 'text.splice';
711
+ path: FieldPath;
712
+ index: number;
713
+ deleteCount: number;
714
+ text: string;
715
+ } | {
716
+ op: 'list.insert';
717
+ path: FieldPath;
718
+ value: JsonValue;
719
+ beforeElementId: string | null;
720
+ } | {
721
+ op: 'list.move';
722
+ path: FieldPath;
723
+ elementId: string;
724
+ beforeElementId: string | null;
725
+ } | {
726
+ op: 'list.remove';
727
+ path: FieldPath;
728
+ elementId: string;
729
+ };
730
+ declare function assertFieldChanges(changes: readonly FieldChange[]): void;
731
+ /** Resolve against the sequential causal view; the numeric path never crosses the API boundary. */
732
+ declare function resolveFieldPath(payload: JsonObject, path: FieldPath): (string | number)[];
733
+ /** Detached plan evaluation. Native compilation replays the original operations, not this snapshot. */
734
+ declare function applyFieldChanges(payload: JsonObject, changes: readonly FieldChange[]): JsonObject;
735
+ //#endregion
736
+ //#region src/entity-crdt/entity-document.d.ts
737
+ declare const LORO_ENTITY_SCHEMA = "medeo.entities.loro.v1";
738
+ interface EntityDocumentState {
739
+ readonly rows: EntityRelationRows;
740
+ readonly project: Readonly<Record<string, string>>;
741
+ }
742
+ type Command = {
743
+ type: 'create';
744
+ row: EntityRow;
745
+ } | {
746
+ type: 'selection-baseline';
747
+ root: string;
748
+ fingerprint: string;
749
+ } | {
750
+ type: 'order';
751
+ group: string;
752
+ roots: string[];
753
+ token: string;
754
+ } | {
755
+ type: 'write';
756
+ root: string;
757
+ payload: JsonObject;
758
+ token: string;
759
+ } | {
760
+ type: 'text';
761
+ root: string;
762
+ path: readonly (string | number)[];
763
+ start: number;
764
+ deleteCount: number;
765
+ text: string;
766
+ token: string;
767
+ } | {
768
+ type: 'field';
769
+ root: string;
770
+ path: (string | number)[];
771
+ change: FieldChange;
772
+ token: string;
773
+ } | {
774
+ type: 'relation-field';
775
+ root: string;
776
+ path: (string | number)[];
777
+ change: FieldChange;
778
+ } | {
779
+ type: 'delete';
780
+ root: string;
781
+ } | {
782
+ type: 'relation';
783
+ row: RelationRow;
784
+ } | {
785
+ type: 'relation-fields';
786
+ root: string;
787
+ metadata: JsonObject;
788
+ trace: JsonObject;
789
+ } | {
790
+ type: 'unlink';
791
+ root: string;
792
+ } | {
793
+ type: 'attach';
794
+ slot: string;
795
+ entityId: string;
796
+ };
797
+ /** Plain domain objects assembled from native Loro state, never a second writable authority. */
798
+ declare function readEntityDocument(doc: LoroDoc, allowSelectionConflicts?: boolean): EntityDocumentState;
799
+ /** Native editing containers survive domain version changes and merge independently. */
800
+ declare class LoroEntityDocument {
801
+ readonly doc: LoroDoc;
802
+ private readonly validate?;
803
+ private readonly undoManager;
804
+ constructor(doc: LoroDoc, validate?: ((state: EntityDocumentState) => void) | undefined);
805
+ /** Open a causal snapshot using the same Loro runtime as the compiler. */
806
+ static fromSnapshot(snapshot: Uint8Array, validate?: (state: EntityDocumentState) => void): LoroEntityDocument;
807
+ static create(rows: EntityRelationRows, project?: Readonly<Record<string, string>>, peerId?: PeerID): LoroEntityDocument;
808
+ snapshot(): EntityDocumentState;
809
+ relationsOf(entityId: string): readonly RelationRow[];
810
+ /** Resolve a queued edit target through its native identity without changing history. */
811
+ resolveCurrentEntityId(id: string): string;
812
+ getVersion(id: string): EntityRow | undefined;
813
+ /** The callback and every domain validation execute on a causally complete fork first. */
814
+ transact(edit: (draft: LoroEntityDraft) => void): Uint8Array;
815
+ /** Import preserves native operation identities; projection errors never discard remote operations. */
816
+ import(update: Uint8Array): void;
817
+ /**
818
+ * Bind a saved snapshot without rewriting text operations or resolving
819
+ * selection conflicts. The script names the bytes the same way everything
820
+ * else does — an Asset entity plus a `from-asset` Relation — and keeps only
821
+ * the fingerprint that tells a stale snapshot from a current one.
822
+ */
823
+ bindAudioScriptAsset(entityId: string, assetId: string, expectedContentHash: string): Uint8Array;
824
+ canUndo(): boolean;
825
+ canRedo(): boolean;
826
+ undo(): boolean;
827
+ redo(): boolean;
828
+ private historyEdit;
829
+ }
830
+ declare class LoroEntityDraft {
831
+ private readonly doc;
832
+ readonly commands: Command[];
833
+ private readonly selectedRoots;
834
+ private readonly relationAliases;
835
+ constructor(doc: LoroDoc);
836
+ snapshot(): EntityDocumentState;
837
+ order(groupId: string, entityIds: readonly string[]): void;
838
+ /** Project the final scalar placement intents onto the existing native ordering containers. */
839
+ reconcileOrder(rows: EntityRelationRows): void;
840
+ create(row: EntityRow): void;
841
+ delete(entityId: string): void;
842
+ attach(slot: string, entityId: string): void;
843
+ link(row: RelationRow): void;
844
+ patchRelation(relationId: string, metadata: JsonObject, trace: JsonObject): void;
845
+ unlink(relationId: string): void;
846
+ private relationRoot;
847
+ update(entityId: string, fields: JsonObject): void;
848
+ declare(entityId: string, fields: JsonObject): void;
849
+ replaceOwned(entityId: string, payload: JsonObject): void;
850
+ editText(entityId: string, path: readonly (string | number)[], start: number, deleteCount: number, text: string): void;
851
+ /** Generic assembled-field edit compiled at the author's causal position. */
852
+ change(entityId: string, changes: readonly FieldChange[]): void;
853
+ changeRelation(relationId: string, changes: readonly FieldChange[]): void;
854
+ captureSelectionBaselines(): void;
855
+ private record;
856
+ }
857
+ //#endregion
858
+ //#region src/entity-crdt/compile-rows.d.ts
859
+ /** Lower a detached ordinary-object edit against its actual causal Loro baseline. */
860
+ declare function compileEntityRows(snapshot: Uint8Array, rows: EntityRelationRows, validate?: (state: EntityDocumentState) => void): {
861
+ update: Uint8Array;
862
+ state: EntityDocumentState;
863
+ };
864
+ /** Compile an edit on an existing peer, retaining its native local undo history. */
865
+ declare function applyEntityRows(editor: LoroEntityDocument, rows: EntityRelationRows): {
866
+ update: Uint8Array;
867
+ state: EntityDocumentState;
868
+ };
869
+ //#endregion
870
+ //#region src/editor/journal.d.ts
871
+ /**
872
+ * Wire a plain-memory adapter + editor that share a recording id factory, so
873
+ * every mutating transact lands in `journal` with ordered `generated_ids`.
874
+ */
875
+ declare function createEditSandbox(document: VideoDocument, options?: PlainMemoryAdapterOptions): {
876
+ adapter: PlainMemoryAdapter;
877
+ editor: SemanticEditor;
878
+ journal: readonly JournalEntry[];
879
+ };
880
+ /**
881
+ * Re-drive `doc` from a recorded journal, forcing each entry's `generated_ids`
882
+ * through a queue-backed id factory. Never mints fresh ids: an empty queue on
883
+ * demand throws `unrecorded id`; leftover ids after an entry throws
884
+ * `unconsumed ids`. Legacy entries without `generated_ids` are treated as `[]`.
885
+ */
886
+ declare function replayJournal(doc: SemanticDocumentAdapter, journal: readonly JournalEntry[]): Promise<void>;
206
887
  //#endregion
207
888
  //#region src/editor/snapshot-utils.d.ts
208
889
  /** Main-track item identity read from a raw snapshot (only `part_id` is needed). */
@@ -391,6 +1072,8 @@ declare class ManualSyncDoc {
391
1072
  private readonly client;
392
1073
  private readonly doc;
393
1074
  private readonly adapter;
1075
+ /** Whether this document's timeline is owned by the Entity graph. */
1076
+ isEntityDocument(): boolean;
394
1077
  readonly editor: SemanticEditor;
395
1078
  /**
396
1079
  * The version the server is known to hold. Starts empty (nothing confirmed)
@@ -422,6 +1105,16 @@ declare class ManualSyncDoc {
422
1105
  editorPeerId(): PeerID;
423
1106
  /** Current content projected into the compatible track and part read shape. */
424
1107
  content(): VideoDraftContent;
1108
+ /**
1109
+ * Replay a deterministic sandbox journal into this document.
1110
+ *
1111
+ * The adapter stays private so callers cannot bypass the manual-sync
1112
+ * lifecycle; journal replay is the one host-side operation that needs the
1113
+ * adapter's transaction boundary and recorded id queue. Durability is still
1114
+ * explicit: call {@link push} after replay and report success only from its
1115
+ * verdict.
1116
+ */
1117
+ replayJournal(journal: readonly JournalEntry[]): Promise<void>;
425
1118
  /**
426
1119
  * Mark the document state the caller has just observed, for a later
427
1120
  * {@link hasChangedSince}.
@@ -574,6 +1267,8 @@ declare class MedeoHttpDocStorage implements DocStorage {
574
1267
  * tool-level ack wait) subscribe here.
575
1268
  */
576
1269
  subscribePushOutcome(callback: (outcome: PushOutcome) => void): () => void;
1270
+ /** Observe live hints that require VV catch-up without replacing the SSE connection. */
1271
+ subscribeResync(callback: () => void): () => void;
577
1272
  /** Authoritative HTTP reads and accepted pushes, never inferred from SSE bytes. */
578
1273
  subscribeServerVersion(callback: (version: Uint8Array) => void): () => void;
579
1274
  private reportServerVersion;
@@ -628,11 +1323,6 @@ declare class MengineAckFailedError extends Error {
628
1323
  readonly cause: Error | undefined;
629
1324
  constructor(reason: 'timeout' | 'rejected' | 'failed', code: string | undefined, cause: Error | undefined, message: string);
630
1325
  }
631
- type MengineLocalSaveState = LocalSaveState;
632
- interface WaitForLocalSaveOptions {
633
- /** Only limits waiting, never cancels persistence. */
634
- timeoutMs?: number;
635
- }
636
1326
  interface WaitForServerAckOptions {
637
1327
  /** Deadline in ms. Rejects with reason `timeout` when it elapses. */
638
1328
  timeoutMs?: number;
@@ -654,10 +1344,12 @@ interface MengineDocSessionOptions {
654
1344
  * Browsers should pass an `IndexedDBDocStorage` for refresh/cross-tab support.
655
1345
  */
656
1346
  localStorage?: DocStorageLike;
657
- /** A freshly fetched remote snapshot to merge into storage before loading.
658
- * Existing local changes are retained; the host owns any online startup gate. */
659
- initialSnapshot?: Uint8Array;
660
1347
  sseReconnectDelayMs?: number;
1348
+ /**
1349
+ * Keep remote synchronization read-only: pull snapshot/diffs and subscribe to
1350
+ * SSE updates, but never POST local Loro updates to the server.
1351
+ */
1352
+ readonlyMode?: boolean;
661
1353
  }
662
1354
  /**
663
1355
  * A live editing session for one Medeo document — the single entry point clients
@@ -693,7 +1385,6 @@ declare class MengineDocSession {
693
1385
  private started;
694
1386
  private startTask;
695
1387
  private destroyed;
696
- private closeTask;
697
1388
  private lifetime;
698
1389
  private hasConnected;
699
1390
  private initialVersionValue;
@@ -744,6 +1435,18 @@ declare class MengineDocSession {
744
1435
  * step. The committed change drives DocManager's local-update push.
745
1436
  */
746
1437
  get editor(): SemanticEditor;
1438
+ /**
1439
+ * Opaque version token of the local oplog (base64 `VersionVector.encode`).
1440
+ * Equality-comparable only: equal means no observed change (local or
1441
+ * remote-arrived) since the token was taken. Throws when not started.
1442
+ */
1443
+ version(): string;
1444
+ /**
1445
+ * The live document adapter, exposed for journal replay (commit channel).
1446
+ * Replaying through it still goes SemanticEditor → Loro → mengine-server —
1447
+ * no write bypass. Typed by the narrow interface on purpose.
1448
+ */
1449
+ get documentAdapter(): SemanticDocumentAdapter;
747
1450
  /** Current document snapshot (read model). */
748
1451
  snapshot(): VideoDocument;
749
1452
  /** Current-session undo/redo availability. Loading and closed sessions report false. */
@@ -787,15 +1490,6 @@ declare class MengineDocSession {
787
1490
  */
788
1491
  start(): Promise<VideoDocument>;
789
1492
  private open;
790
- getLocalSaveState(): MengineLocalSaveState;
791
- /** Immediately reports local transaction state; independent of server confirmation. */
792
- subscribeLocalSaveState(cb: (state: MengineLocalSaveState) => void): () => void;
793
- /** Waits for commits present now to reach local storage. Does not wait for the network. */
794
- waitForLocalSave(options?: WaitForLocalSaveOptions): Promise<void>;
795
- /** Stop accepting edits and drain local persistence before releasing resources.
796
- * A failed local write keeps retrying, even after the host has unmounted.
797
- * Hosts should use this for normal teardown; destroy() is immediate cancellation. */
798
- close(): Promise<void>;
799
1493
  getSyncState(): MengineDocSyncState;
800
1494
  private confirmationTarget;
801
1495
  /** Immediately supplies current state; unsubscribe when the host changes docs. */
@@ -993,103 +1687,6 @@ type MakeEmptyPart = (durationMs: number) => {
993
1687
  */
994
1688
  declare function cascadeAfterVideoClipChanges(doc: TimelineDoc, makeEmptyPart: MakeEmptyPart): void;
995
1689
  //#endregion
996
- //#region src/timeline-core/bridge.d.ts
997
- /**
998
- * Bridge between the authoritative `VideoDocument` (position-only facts) and the
999
- * flat `TimelineDoc` the cascade primitives solve over.
1000
- *
1001
- * The data flow is single-directional (RFC 02 §7/§10): ops write only facts
1002
- * (`time_position`, parts) to `VideoDocument`; absolute time, `part_aggregations`,
1003
- * total duration, and gap fillers are NOT stored — the projection derives them
1004
- * on read by running the cascade. There is no write-back of solved positions.
1005
- *
1006
- * - `solveVideoDocument` seeds a `TimelineDoc` from each item's `time_position`,
1007
- * runs the full cascade, and returns the derived read-view (abs / aggregations
1008
- * / duration). It is the single solve shared by the legacy `VideoDraft`
1009
- * projection.
1010
- * - `ensureLaneTrack` / `findLaneTrack` locate (or mint) a secondary lane's
1011
- * track row in the draft, so ops can write authoritative facts onto the right
1012
- * named container (lane = container).
1013
- */
1014
- /** The projection-derived read-view of a `VideoDocument` (RFC 02 §7). */
1015
- interface SolvedVideoDocument {
1016
- absByPartId: Map<string, number>;
1017
- aggregations: PartAggregation[];
1018
- durationMs: number;
1019
- partLibrary: Record<string, PartUnion>;
1020
- /**
1021
- * Part ids of the gap fillers this solve minted.
1022
- *
1023
- * They exist only inside the solve: gap filling needs them so the clips after a
1024
- * gap land at the right absolute time, but they are not authoritative state and
1025
- * the read view does not carry them (see `fromVideoDocument`).
1026
- *
1027
- * Reported as ids rather than left for the caller to detect, because the caller
1028
- * *cannot* detect them. The obvious predicate — `origin_media_id === ''` — also
1029
- * matches an empty clip a writer placed on purpose (`batch_replace_video_clip_sequence`
1030
- * documents "Omit to create an empty clip placeholder"), and those are
1031
- * authoritative parts that must survive the projection. The mint callback is the
1032
- * only place that knows the difference.
1033
- *
1034
- * Note this deliberately excludes the fillers that gap filling *extended* rather
1035
- * than minted (`fillMainTrackTimeGaps` cases 1 and 2): those are authoritative
1036
- * empty clips already in `part_library`, and only their length is derived.
1037
- */
1038
- derivedFillerPartIds: Set<string>;
1039
- }
1040
- /**
1041
- * Solve a `VideoDocument` (authoritative, position-only) into its derived
1042
- * read-view: absolute time per item, `part_aggregations`, and total duration.
1043
- * This is the read side of the single-directional flow — never written back.
1044
- */
1045
- declare function solveVideoDocument(document: VideoDocument): SolvedVideoDocument;
1046
- /** The named container a secondary lane lives in. */
1047
- type SecondaryLane = 'speech' | 'caption' | 'bgm';
1048
- /** A lane's track kind: the `video_clip` main lane plus the three secondary lanes. */
1049
- type LaneKind = SecondaryLane | 'video_clip';
1050
- /**
1051
- * The four lanes in top-to-bottom stack order — the order a `tracks` list holds
1052
- * them in (see {@link laneRank}).
1053
- *
1054
- * Exported so a document can be seeded with all four lanes up front. That seed is
1055
- * not cosmetic: {@link ensureLaneTrack} is find-then-mint over a `LoroMovableList`,
1056
- * so two concurrent writers that each mint the same absent lane both keep their
1057
- * row, and the merged document holds two tracks for one lane. For the main lane
1058
- * that is fatal — `videoDocumentSchema` allows at most one `video_clip` track, so
1059
- * the merged document stops being projectable at all, symmetrically on both
1060
- * replicas. Pre-seeding every lane makes `ensureLaneTrack` always take its find
1061
- * branch, which removes the race by construction rather than by detection.
1062
- *
1063
- * What closes the race is that a track with the lane's `parts_kind` EXISTS — the
1064
- * lookup is by kind, not by id. So a seed is only safe if it covers every lane:
1065
- * a partial seed leaves the uncovered lanes exactly as exposed as before.
1066
- */
1067
- declare const LANE_KINDS_IN_STACK_ORDER: readonly LaneKind[];
1068
- /**
1069
- * The conventional track id for a lane (`main_track`, `<kind>_track`). Shared by
1070
- * the up-front seed and {@link ensureLaneTrack}'s lazy mint so a document's lane
1071
- * ids do not depend on which of the two created the track.
1072
- *
1073
- * Ids are cosmetic to the merge itself — lane lookup goes by `parts_kind`, so
1074
- * drifting them apart would not reopen the concurrent-mint race. They matter to
1075
- * readers that address a lane by id (the FE editor's panes, fixtures), which is
1076
- * why there is one convention rather than two.
1077
- */
1078
- declare function laneTrackId(kind: LaneKind): string;
1079
- /**
1080
- * Locate a lane's track row in the single `tracks` list by kind, minting an empty
1081
- * row in lane-stacking order if absent (reference/17 §4: lane = `parts_kind`).
1082
- * Ops use this to write authoritative items onto the right lane. The track id
1083
- * comes from {@link laneTrackId}, shared with the up-front seed.
1084
- *
1085
- * The mint branch is a concurrency hazard, not a convenience: see
1086
- * {@link LANE_KINDS_IN_STACK_ORDER}. A document seeded with all four lanes never
1087
- * reaches it.
1088
- */
1089
- declare function ensureLaneTrack(draft: VideoDocumentDraft, kind: LaneKind): TrackDraft;
1090
- /** Find a secondary lane's track row without minting it. */
1091
- declare function findLaneTrack(draft: VideoDocumentDraft, kind: SecondaryLane): TrackDraft | undefined;
1092
- //#endregion
1093
1690
  //#region src/timeline-core/locate.d.ts
1094
1691
  /**
1095
1692
  * Forward positioning for write-time ops (RFC 02 §9.1) — NOT a cascade.
@@ -1133,4 +1730,17 @@ declare function hostForAbsMs(ranges: MainClipRange[], absMs: number): MainClipR
1133
1730
  */
1134
1731
  declare function relativePositionForAbs(ranges: MainClipRange[], absMs: number): TrackItemTimePosition;
1135
1732
  //#endregion
1136
- 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 };
1733
+ //#region src/entity-crdt/audio-script-assets.d.ts
1734
+ /** A resource is a snapshot of text; the native Loro text remains the editing authority. */
1735
+ declare function audioScriptAssetContent(payload: JsonObject): JsonObject;
1736
+ declare function audioScriptAssetHash(payload: JsonObject): string;
1737
+ /**
1738
+ * The Asset a script was written out to, read from the graph rather than the
1739
+ * script's own row: like every other entity, a script names its bytes through
1740
+ * a `from-asset` Relation and stores no locator itself.
1741
+ */
1742
+ declare function audioScriptAssetOf(rows: EntityRelationRows, entityId: string): EntityRow | undefined;
1743
+ /** Internal fingerprint prevents a resource from silently describing an older text revision. */
1744
+ declare function audioScriptAssetFields(payload: JsonObject): JsonObject;
1745
+ //#endregion
1746
+ 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, audioScriptAssetOf, base64ToBytes, buildInitialVideoDocument, buildSpeechHostMap, bytesToBase64, cascadeAfterVideoClipChanges, compileEntityRows, createEditSandbox, createMirrorVideoDocument, createMirrorVideoDocumentAdapter, createPlainMemoryAdapter, decodeDocVersionMark, derivePositionFromAbs, effectiveVideoClipDurationMs, encodeDocVersionMark, ensureEditorFoundation, ensureLaneTrack, fillMainTrackTimeGaps, findComposedAudioScript, findLaneTrack, fromVideoDocument, generatePartId, getAt, 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 };