@mengine/medeo-tool 1.2.1-alpha.8 → 1.3.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.
@@ -29,6 +29,18 @@ interface CaptionFontDescriptor {
29
29
  readonly system: 'font-library';
30
30
  readonly key: string;
31
31
  }
32
+ /**
33
+ * One ordered entry of the Caption's segment selection. `segmentId` quotes the
34
+ * composed AudioScript's own stable segment identity — a local id quoted by the
35
+ * variant, never a peer Entity reference. Text itself is never copied here;
36
+ * complete Caption content is assembled through its direct baseEntityIds.
37
+ * The optional `textRange` narrows one Segment to an intra-Segment sub-span
38
+ * (intra-segment re-segmentation); without it the whole Segment text is selected.
39
+ */
40
+ type CaptionSegmentSelection = JsonObject & {
41
+ readonly segmentId: string;
42
+ readonly textRange?: CaptionTextRange;
43
+ };
32
44
  interface CaptionStyleFields {
33
45
  readonly font?: CaptionFontDescriptor;
34
46
  readonly fontSize?: number;
@@ -41,6 +53,23 @@ interface CaptionStyleFields {
41
53
  readonly positionX?: number;
42
54
  readonly positionY?: number;
43
55
  }
56
+ /**
57
+ * Half-open `[start, end)` position window inside one Segment's text, counted
58
+ * in Unicode code points (not UTF-16 code units), so a boundary never splits a
59
+ * surrogate pair. Positions are non-negative safe integers with `start < end`;
60
+ * `end` must not exceed the Segment's code-point length.
61
+ */
62
+ interface CaptionTextRange extends JsonObject {
63
+ readonly start: number;
64
+ readonly end: number;
65
+ }
66
+ type CaptionTextSelection = JsonObject & {
67
+ segmentId: string; /** Half-open Unicode code-point range within the selected source segment. */
68
+ textRange?: {
69
+ start: number;
70
+ end: number;
71
+ };
72
+ };
44
73
  type ClipEntityId = EntityId;
45
74
  type ClipPlacement = {
46
75
  readonly kind: 'sequential';
@@ -53,10 +82,20 @@ type ClipPlacement = {
53
82
  readonly hostClipEntityId: string;
54
83
  readonly anchorOffset: number;
55
84
  };
85
+ interface ComposedPhoneticContent extends ComposedScriptContent {
86
+ phonemeScript?: string;
87
+ prosody?: JsonObject;
88
+ }
89
+ /** Read result only: base text is assembled from the real AudioScript row. */
90
+ interface ComposedScriptContent {
91
+ audio_script_entity_id: string;
92
+ text: string;
93
+ segments: ScriptTextSegment[];
94
+ }
56
95
  type CreateEntityInput = { [K in KnownEntityKind]: {
57
96
  entity_id?: string;
58
97
  entity_kind: K;
59
- payload: EntityPayloadByKind[K];
98
+ payload: StoredEntityPayload<K>;
60
99
  } }[KnownEntityKind];
61
100
  interface DeleteBgmInput {
62
101
  readonly timelineEntityId: string;
@@ -74,19 +113,28 @@ interface DeleteEntityInput {
74
113
  interface DeleteVoiceoverInput {
75
114
  readonly voiceoverClipEntityIds: readonly string[];
76
115
  }
77
- type EmptyRelationKind = 'timeline-track' | 'track-clip' | 'clip-marker' | 'marker-content' | 'axvideo-marker' | 'marker-timeline';
116
+ type EmptyRelationKind = 'timeline-track' | 'track-clip' | 'clip-marker' | 'marker-content' | 'axvideo-marker' | 'marker-timeline' | 'audio-script-marker';
78
117
  interface EntityFacade {
118
+ /** Read complete assembled fields; returned objects are snapshots. Use update to persist edits. */
79
119
  list(): SandboxEntity[];
80
120
  get(entityId: string): SandboxEntity | null;
81
- /** Return every explicitly imported Asset entity for a Memota asset id. */
82
- findByAssetId(assetId: string): SandboxEntity<'asset'>[];
121
+ /** Find document resources by external Memota asset id, including directly composed media variants. */
122
+ findByAssetId(assetId: string): SandboxEntity<ResourceEntityKind>[];
123
+ /** Assemble selected Caption text; missing composition is an error. */
124
+ readCaptionContent(entityId: string): ComposedScriptContent;
125
+ /** Assemble base text and pronunciation fields before generating Voice. */
126
+ readPhoneticScriptContent(entityId: string): ComposedPhoneticContent;
83
127
  create(input: CreateEntityInput): string;
84
- /** Replace one Entity's owned payload without changing its identity or kind. */
128
+ /** Patch assembled fields, routing inherited fields to their declaring entity. */
85
129
  update(input: UpdateEntityInput): void;
130
+ /** Explicitly declare own fields, overriding unambiguous bases without modifying them. Ordinary edits use update. */
131
+ declareFields(input: UpdateEntityInput): void;
86
132
  /** Delete an Entity only after all of its incident Relations have been explicitly unlinked. */
87
133
  delete(input: DeleteEntityInput): void;
88
- /** Import one physical asset without implying a one-to-one media Entity mapping. */
89
- importAsset(input: ImportAssetInput): string;
134
+ /** Get or create one typed Asset by factual external id and return its single content identity. Never creates a Clip. */
135
+ ensureMedia(fact: MediaAssetFact): {
136
+ contentEntityId: string;
137
+ };
90
138
  }
91
139
  type EntityId = string;
92
140
  interface EntityPayloadByKind {
@@ -97,12 +145,12 @@ interface EntityPayloadByKind {
97
145
  role?: string;
98
146
  };
99
147
  clip: JsonObject;
100
- /** Asset-owned metadata. Peer media associations belong in physical-asset Relations. */
148
+ /** Physical resource fields; never a copy of Caption content. */
101
149
  asset: JsonObject;
102
- video: BoundedNativeSequencePayload;
103
- audio: BoundedNativeSequencePayload;
104
- voice: BoundedNativeSequencePayload;
105
- image: UnboundedConstantSequencePayload;
150
+ video: BoundedNativeSequencePayload & MediaAssetPayload;
151
+ audio: BoundedNativeSequencePayload & MediaAssetPayload;
152
+ voice: BoundedNativeSequencePayload & MediaAssetPayload;
153
+ image: UnboundedConstantSequencePayload & MediaAssetPayload;
106
154
  'sequence-marker': JsonObject & {
107
155
  sourceRange: {
108
156
  start: number;
@@ -120,19 +168,34 @@ interface EntityPayloadByKind {
120
168
  };
121
169
  timeRemapping?: JsonValue;
122
170
  anchorOffset?: number;
123
- durationPolicy?: 'timeline';
171
+ durationPolicy?: 'timeline'; /** Directly assigned AudioScript annotation times; annotation Markers only. */
172
+ segmentRanges?: {
173
+ segmentId: string;
174
+ startMs: number;
175
+ endMs: number;
176
+ }[];
124
177
  };
125
178
  viewport: JsonObject;
126
179
  'audio-script': JsonObject & {
127
180
  segments: ScriptTextSegment[];
128
181
  };
129
182
  'phonetic-script': JsonObject & {
130
- segments: ScriptTextSegment[];
183
+ baseEntityIds: string[];
184
+ phonemeScript?: string;
185
+ prosody?: JsonObject;
186
+ };
187
+ caption: BoundedNativeSequencePayload & {
188
+ baseEntityIds: string[];
189
+ selections: CaptionTextSelection[];
190
+ style?: JsonObject;
131
191
  };
132
- caption: BoundedNativeSequencePayload;
133
192
  }
134
193
  interface EntityStoreSnapshot {
194
+ /** Causal compiler baseline; required for publishing edits. */
195
+ loroSnapshot?: string;
135
196
  revision: number;
197
+ /** Current AudioScript version attached to the project; initialized projects always attach a script, possibly empty. */
198
+ audioScriptEntityId: string | null;
136
199
  entities: SandboxEntity[];
137
200
  relations: SandboxRelation[];
138
201
  }
@@ -141,10 +204,18 @@ interface ImageMediaAssetFact {
141
204
  readonly kind: 'image';
142
205
  readonly storageKey?: string;
143
206
  }
144
- interface ImportAssetInput {
145
- asset_id: string;
146
- entity_id?: string;
147
- payload?: JsonObject;
207
+ interface InsertCaptionClipInput {
208
+ readonly timelineEntityId: string;
209
+ /** Stable placed caption identity, distinct from the Caption content identity. */
210
+ readonly captionClipEntityId?: string;
211
+ /** Existing bases composed by this variant; includes an AudioScript text owner. */
212
+ readonly baseEntityIds: readonly string[];
213
+ /** Ordered selection of the AudioScript segments this Caption displays. */
214
+ readonly selections: readonly CaptionSegmentSelection[];
215
+ /** Intrinsic cue length of the Caption entity itself; display comes from the placement. */
216
+ readonly durationMs: number;
217
+ readonly style?: CaptionStyleFields;
218
+ readonly placement: ClipPlacement;
148
219
  }
149
220
  interface InsertClipInput {
150
221
  readonly trackEntityId: string;
@@ -186,16 +257,17 @@ interface JsonObject {
186
257
  type JsonPrimitive = string | number | boolean | null;
187
258
  type JsonValue = JsonPrimitive | JsonObject | JsonValue[];
188
259
  type KnownEntityKind = 'axvideo' | 'timeline' | 'track' | 'clip' | 'asset' | 'video' | 'audio' | 'voice' | 'image' | 'sequence-marker' | 'viewport' | 'audio-script' | 'phonetic-script' | 'caption';
189
- type KnownRelationKind = 'timeline-track' | 'track-clip' | 'clip-marker' | 'marker-content' | 'axvideo-marker' | 'marker-timeline' | 'physical-asset' | 'generated' | 'phonetic-script-provenance' | 'caption-provenance' | 'caption-alignment' | 'clip-anchor' | 'audio-script-render';
260
+ type KnownRelationKind = 'timeline-track' | 'track-clip' | 'clip-marker' | 'marker-content' | 'axvideo-marker' | 'marker-timeline' | 'physical-asset' | 'generated' | 'caption-alignment' | 'clip-anchor' | 'phonetic-script-render' | 'audio-script-source' | 'audio-script-marker';
190
261
  interface LinearClipSpeed {
191
262
  readonly kind: 'linear';
192
263
  readonly rate: number;
193
264
  readonly mode?: string;
194
265
  }
195
- interface LinkAudioScriptRenderRelationInput {
266
+ /** `audio-script-source(script, source)`; the script was transcribed from the source media. */
267
+ interface LinkAudioScriptSourceRelationInput {
196
268
  relation_id?: string;
197
- output_entity_id: string;
198
269
  script_entity_id: string;
270
+ source_entity_id: string;
199
271
  trace?: JsonObject;
200
272
  }
201
273
  interface LinkClipAnchorRelationInput {
@@ -210,6 +282,12 @@ interface LinkGeneratedRelationInput {
210
282
  input_entity_id: string;
211
283
  trace?: JsonObject;
212
284
  }
285
+ interface LinkPhoneticScriptRenderRelationInput {
286
+ relation_id?: string;
287
+ output_entity_id: string;
288
+ phonetic_script_entity_id: string;
289
+ trace?: JsonObject;
290
+ }
213
291
  interface LinkRelationBase {
214
292
  relation_id?: string;
215
293
  endpoint_0_entity_id: string;
@@ -224,17 +302,21 @@ type LinkRelationInput = (LinkRelationBase & {
224
302
  }) | (LinkRelationBase & {
225
303
  relation_kind: 'physical-asset';
226
304
  metadata?: JsonObject;
227
- }) | (LinkRelationBase & {
228
- relation_kind: 'phonetic-script-provenance' | 'caption-provenance';
229
- metadata: JsonObject & {
230
- segmentAlignment: JsonValue;
231
- };
232
305
  }) | (LinkRelationBase & {
233
306
  relation_kind: 'caption-alignment';
234
307
  metadata: JsonObject & {
235
308
  alignment: JsonValue;
236
309
  };
237
310
  });
311
+ /** Facts resolved from media storage. A trim window never substitutes for intrinsic duration. */
312
+ type MediaAssetFact = ImageMediaAssetFact | VideoMediaAssetFact | AudioMediaAssetFact | VoiceMediaAssetFact;
313
+ type MediaAssetPayload = JsonObject & {
314
+ external: {
315
+ system: 'memota' | 'memota-speech';
316
+ key: string;
317
+ };
318
+ storageKey?: string;
319
+ };
238
320
  type MediaClipInsertion = {
239
321
  readonly kind: 'before';
240
322
  readonly clipEntityId: string;
@@ -275,14 +357,16 @@ interface RelationFacade {
275
357
  list(): SandboxRelation[];
276
358
  /** Incident lookup is endpoint-agnostic; persisted endpoint positions stay unchanged. */
277
359
  of(entityId: string, relationKind?: KnownRelationKind): SandboxRelation[];
278
- /** For physical-asset use sequence media as endpoint 0 and Asset as endpoint 1. */
360
+ /** Link existing entities through ordinary associations; variant bases are stored directly on the variant. */
279
361
  link(input: LinkRelationInput): string;
280
362
  /** Author ordered generated(output,input); generic link() deliberately rejects this kind. */
281
363
  linkGenerated(input: LinkGeneratedRelationInput): string;
282
364
  /** Author ordered clip-anchor(child,host) without positional endpoint ambiguity. */
283
365
  linkClipAnchor(input: LinkClipAnchorRelationInput): string;
284
- /** Author ordered audio-script-render(output,script) without positional endpoint ambiguity. */
285
- linkAudioScriptRender(input: LinkAudioScriptRenderRelationInput): string;
366
+ /** Author ordered phonetic-script-render(output,script) without positional endpoint ambiguity. */
367
+ linkPhoneticScriptRender(input: LinkPhoneticScriptRenderRelationInput): string;
368
+ /** Author ordered audio-script-source(script,source) without positional endpoint ambiguity. */
369
+ linkAudioScriptSource(input: LinkAudioScriptSourceRelationInput): string;
286
370
  /** Remove a Relation by identity; endpoint replacement is an explicit unlink plus link. */
287
371
  unlink(input: UnlinkRelationInput): void;
288
372
  }
@@ -312,10 +396,12 @@ interface ReplacementMediaClipInput {
312
396
  readonly sourceRange: SequenceRange<number>;
313
397
  readonly volume?: number;
314
398
  }
399
+ /** Asset identity, either an old physical-only row or a directly composed media variant. */
400
+ type ResourceEntityKind = 'image' | 'video' | 'audio' | 'voice';
315
401
  interface SandboxEntity<K extends KnownEntityKind = KnownEntityKind> {
316
402
  entity_id: string;
317
403
  entity_kind: K;
318
- payload: EntityPayloadByKind[K];
404
+ payload: StoredEntityPayload<K>;
319
405
  }
320
406
  interface SandboxRelation {
321
407
  relation_id: string;
@@ -369,6 +455,10 @@ interface SetClipVolumeInput {
369
455
  /** Playback gain in decibels. */
370
456
  readonly volume: number;
371
457
  }
458
+ /** Stored own fields; a variant may obtain required content fields from its declared bases. */
459
+ type StoredEntityPayload<K extends KnownEntityKind> = EntityPayloadByKind[K] | (JsonObject & Partial<EntityPayloadByKind[K]> & {
460
+ baseEntityIds: string[];
461
+ });
372
462
  interface TrimClipInput {
373
463
  readonly clipEntityId: string;
374
464
  readonly sourceRange: SequenceRange<number>;
@@ -398,6 +488,7 @@ interface UpdateClipMarkerInput {
398
488
  /** Passing `undefined` explicitly removes the optional remapping value. */
399
489
  readonly timeRemapping?: JsonValue | undefined;
400
490
  }
491
+ /** Patch supplied fields on the assembled entity; omitted fields remain unchanged. */
401
492
  interface UpdateEntityInput {
402
493
  entity_id: string;
403
494
  payload: JsonObject;
@@ -420,31 +511,42 @@ interface VoiceMediaAssetFact {
420
511
  readonly kind: 'voice';
421
512
  readonly durationMs: number;
422
513
  readonly storageKey: string;
423
- readonly voice: VoiceDescriptor;
514
+ /** Present for synthesized voice, absent for original recorded audio. */
515
+ readonly voice?: VoiceDescriptor;
424
516
  }
425
517
  interface VoiceoverCaptionFact {
426
518
  /** Stable placed caption identity supplied by the materialized side effect. */
427
519
  readonly captionClipEntityId: string;
428
- readonly text: string;
520
+ /** Directly held bases; includes the AudioScript used by the Voice. */
521
+ readonly baseEntityIds: readonly string[];
522
+ /** Ordered selection of AudioScript segments; caption text is never passed inline. */
523
+ readonly selections: readonly CaptionSegmentSelection[];
429
524
  readonly startMs: number;
430
525
  readonly durationMs: number;
431
526
  readonly style?: CaptionStyleFields;
432
527
  }
433
- interface VoiceoverTakeInput {
434
- readonly timelineEntityId: string;
435
- /** Stable placed speech identity, distinct from media.assetId. */
528
+ type VoiceoverTakeInput = {
529
+ readonly timelineEntityId: string; /** Stable placed speech identity, distinct from media.assetId. */
436
530
  readonly voiceoverClipEntityId: string;
437
- readonly hostClipEntityId: string;
438
- readonly anchorOffset: number;
439
- readonly media: VoiceMediaAssetFact;
440
- /** Complete spoken text; the editor owns the deterministic local script segment identity. */
441
- readonly scriptText: string;
531
+ readonly media: VoiceMediaAssetFact; /** Existing pronunciation variant; its composed AudioScript stays the text owner. */
532
+ readonly phoneticScriptEntityId: string;
442
533
  readonly volume: number;
443
534
  readonly captions: readonly VoiceoverCaptionFact[];
444
- }
535
+ } & ({
536
+ readonly placement: ClipPlacement;
537
+ readonly hostClipEntityId?: never;
538
+ readonly anchorOffset?: never;
539
+ } | {
540
+ readonly placement?: never;
541
+ readonly hostClipEntityId: string;
542
+ readonly anchorOffset: number;
543
+ });
445
544
  interface VoiceoverTakeResult {
446
545
  readonly voiceoverClipEntityId: string;
447
546
  readonly voiceEntityId: string;
547
+ /** The pronunciation variant the Voice was rendered from. */
548
+ readonly phoneticScriptEntityId: string;
549
+ /** The base-text owner resolved from the PhoneticScript baseEntityIds. */
448
550
  readonly audioScriptEntityId: string;
449
551
  readonly captionClipEntityIds: readonly string[];
450
552
  }
@@ -475,9 +577,12 @@ interface EditApi {
475
577
  deleteBgm(input: DeleteBgmInput): void;
476
578
  setCaptionVisibility(input: SetCaptionVisibilityInput): void;
477
579
  patchCaptionStyle(input: PatchCaptionStyleInput): void;
580
+ insertCaptionClip(input: InsertCaptionClipInput): ClipEntityId;
478
581
  }
479
582
  interface TimelineApi {
480
- snapshot(): EntityStoreSnapshot;
583
+ snapshot(): EntityStoreSnapshot & {
584
+ audioScriptEntityId: string;
585
+ };
481
586
  }
482
587
  interface SandboxCheckpoint {
483
588
  readonly index: number;
@@ -490,5 +595,5 @@ declare function checkpoint(): SandboxCheckpoint;
490
595
  declare function rollbackTo(cp: SandboxCheckpoint): void;
491
596
  declare const inputs: Readonly<Record<string, unknown>>;
492
597
  //#endregion
493
- export type { AudioMediaAssetFact, BoundedDerivedSequencePayload, BoundedNativeSequencePayload, CaptionFontDescriptor, CaptionStyleFields, ClipEntityId, ClipPlacement, CreateEntityInput, DeleteBgmInput, DeleteClipInput, DeleteClipTreeInput, DeleteEntityInput, DeleteVoiceoverInput, EditApi, EmptyRelationKind, EntityFacade, EntityId, EntityPayloadByKind, EntityStoreSnapshot, ImageMediaAssetFact, ImportAssetInput, InsertClipInput, InsertMediaClipInput, InsertMediaClipsInput, InsertPlacedClipInput, JsonObject, JsonPrimitive, JsonValue, KnownEntityKind, KnownRelationKind, LinearClipSpeed, LinkAudioScriptRenderRelationInput, LinkClipAnchorRelationInput, LinkGeneratedRelationInput, LinkRelationInput, MediaClipInsertion, MoveClipInput, MoveClipsToStartsInput, MoveSequentialClipsInput, MoveVoiceoverInput, PatchCaptionStyleInput, RelationFacade, ReplaceClipContentInput, ReplaceMediaClipInput, ReplaceSequentialClipsInput, ReplacementMediaClipInput, SandboxCheckpoint, SandboxEntity, SandboxRelation, ScriptTextSegment, SequenceDuration, SequenceRange, SequentialClipAnchor, SetBgmInput, SetCaptionVisibilityInput, SetClipPlacementInput, SetClipSpeedInput, SetClipVolumeInput, TimelineApi, TrimClipInput, UnboundedConstantSequencePayload, UnlinkRelationInput, UpdateClipInput, UpdateClipMarkerInput, UpdateEntityInput, VideoMediaAssetFact, VisualMediaAssetFact, VoiceDescriptor, VoiceMediaAssetFact, VoiceoverCaptionFact, VoiceoverTakeInput, VoiceoverTakeResult, checkpoint, edit, entities, inputs, relations, rollbackTo, timeline };
598
+ export type { AudioMediaAssetFact, BoundedDerivedSequencePayload, BoundedNativeSequencePayload, CaptionFontDescriptor, CaptionSegmentSelection, CaptionStyleFields, CaptionTextRange, CaptionTextSelection, ClipEntityId, ClipPlacement, ComposedPhoneticContent, ComposedScriptContent, CreateEntityInput, DeleteBgmInput, DeleteClipInput, DeleteClipTreeInput, DeleteEntityInput, DeleteVoiceoverInput, EditApi, EmptyRelationKind, EntityFacade, EntityId, EntityPayloadByKind, EntityStoreSnapshot, ImageMediaAssetFact, InsertCaptionClipInput, InsertClipInput, InsertMediaClipInput, InsertMediaClipsInput, InsertPlacedClipInput, JsonObject, JsonPrimitive, JsonValue, KnownEntityKind, KnownRelationKind, LinearClipSpeed, LinkAudioScriptSourceRelationInput, LinkClipAnchorRelationInput, LinkGeneratedRelationInput, LinkPhoneticScriptRenderRelationInput, LinkRelationInput, MediaAssetFact, MediaAssetPayload, MediaClipInsertion, MoveClipInput, MoveClipsToStartsInput, MoveSequentialClipsInput, MoveVoiceoverInput, PatchCaptionStyleInput, RelationFacade, ReplaceClipContentInput, ReplaceMediaClipInput, ReplaceSequentialClipsInput, ReplacementMediaClipInput, ResourceEntityKind, SandboxCheckpoint, SandboxEntity, SandboxRelation, ScriptTextSegment, SequenceDuration, SequenceRange, SequentialClipAnchor, SetBgmInput, SetCaptionVisibilityInput, SetClipPlacementInput, SetClipSpeedInput, SetClipVolumeInput, StoredEntityPayload, TimelineApi, TrimClipInput, UnboundedConstantSequencePayload, UnlinkRelationInput, UpdateClipInput, UpdateClipMarkerInput, UpdateEntityInput, VideoMediaAssetFact, VisualMediaAssetFact, VoiceDescriptor, VoiceMediaAssetFact, VoiceoverCaptionFact, VoiceoverTakeInput, VoiceoverTakeResult, checkpoint, edit, entities, inputs, relations, rollbackTo, timeline };
494
599
  //# sourceMappingURL=sandbox-api.d.mts.map