@mengine/medeo-tool 1.2.1-alpha.9 → 1.3.1-alpha.8

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
@@ -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,31 @@ 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 {
135
194
  revision: number;
195
+ audioScriptEntityId: string | null;
136
196
  entities: SandboxEntity[];
137
197
  relations: SandboxRelation[];
138
198
  }
@@ -141,10 +201,18 @@ interface ImageMediaAssetFact {
141
201
  readonly kind: 'image';
142
202
  readonly storageKey?: string;
143
203
  }
144
- interface ImportAssetInput {
145
- asset_id: string;
146
- entity_id?: string;
147
- payload?: JsonObject;
204
+ interface InsertCaptionClipInput {
205
+ readonly timelineEntityId: string;
206
+ /** Stable placed caption identity, distinct from the Caption content identity. */
207
+ readonly captionClipEntityId?: string;
208
+ /** Existing bases composed by this variant; includes an AudioScript text owner. */
209
+ readonly baseEntityIds: readonly string[];
210
+ /** Ordered selection of the AudioScript segments this Caption displays. */
211
+ readonly selections: readonly CaptionSegmentSelection[];
212
+ /** Intrinsic cue length of the Caption entity itself; display comes from the placement. */
213
+ readonly durationMs: number;
214
+ readonly style?: CaptionStyleFields;
215
+ readonly placement: ClipPlacement;
148
216
  }
149
217
  interface InsertClipInput {
150
218
  readonly trackEntityId: string;
@@ -186,16 +254,17 @@ interface JsonObject {
186
254
  type JsonPrimitive = string | number | boolean | null;
187
255
  type JsonValue = JsonPrimitive | JsonObject | JsonValue[];
188
256
  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';
257
+ 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
258
  interface LinearClipSpeed {
191
259
  readonly kind: 'linear';
192
260
  readonly rate: number;
193
261
  readonly mode?: string;
194
262
  }
195
- interface LinkAudioScriptRenderRelationInput {
263
+ /** `audio-script-source(script, source)`; the script was transcribed from the source media. */
264
+ interface LinkAudioScriptSourceRelationInput {
196
265
  relation_id?: string;
197
- output_entity_id: string;
198
266
  script_entity_id: string;
267
+ source_entity_id: string;
199
268
  trace?: JsonObject;
200
269
  }
201
270
  interface LinkClipAnchorRelationInput {
@@ -210,6 +279,12 @@ interface LinkGeneratedRelationInput {
210
279
  input_entity_id: string;
211
280
  trace?: JsonObject;
212
281
  }
282
+ interface LinkPhoneticScriptRenderRelationInput {
283
+ relation_id?: string;
284
+ output_entity_id: string;
285
+ phonetic_script_entity_id: string;
286
+ trace?: JsonObject;
287
+ }
213
288
  interface LinkRelationBase {
214
289
  relation_id?: string;
215
290
  endpoint_0_entity_id: string;
@@ -224,17 +299,21 @@ type LinkRelationInput = (LinkRelationBase & {
224
299
  }) | (LinkRelationBase & {
225
300
  relation_kind: 'physical-asset';
226
301
  metadata?: JsonObject;
227
- }) | (LinkRelationBase & {
228
- relation_kind: 'phonetic-script-provenance' | 'caption-provenance';
229
- metadata: JsonObject & {
230
- segmentAlignment: JsonValue;
231
- };
232
302
  }) | (LinkRelationBase & {
233
303
  relation_kind: 'caption-alignment';
234
304
  metadata: JsonObject & {
235
305
  alignment: JsonValue;
236
306
  };
237
307
  });
308
+ /** Facts resolved from media storage. A trim window never substitutes for intrinsic duration. */
309
+ type MediaAssetFact = ImageMediaAssetFact | VideoMediaAssetFact | AudioMediaAssetFact | VoiceMediaAssetFact;
310
+ type MediaAssetPayload = JsonObject & {
311
+ external: {
312
+ system: 'memota' | 'memota-speech';
313
+ key: string;
314
+ };
315
+ storageKey?: string;
316
+ };
238
317
  type MediaClipInsertion = {
239
318
  readonly kind: 'before';
240
319
  readonly clipEntityId: string;
@@ -275,14 +354,16 @@ interface RelationFacade {
275
354
  list(): SandboxRelation[];
276
355
  /** Incident lookup is endpoint-agnostic; persisted endpoint positions stay unchanged. */
277
356
  of(entityId: string, relationKind?: KnownRelationKind): SandboxRelation[];
278
- /** For physical-asset use sequence media as endpoint 0 and Asset as endpoint 1. */
357
+ /** Link existing entities through ordinary associations; variant bases are stored directly on the variant. */
279
358
  link(input: LinkRelationInput): string;
280
359
  /** Author ordered generated(output,input); generic link() deliberately rejects this kind. */
281
360
  linkGenerated(input: LinkGeneratedRelationInput): string;
282
361
  /** Author ordered clip-anchor(child,host) without positional endpoint ambiguity. */
283
362
  linkClipAnchor(input: LinkClipAnchorRelationInput): string;
284
- /** Author ordered audio-script-render(output,script) without positional endpoint ambiguity. */
285
- linkAudioScriptRender(input: LinkAudioScriptRenderRelationInput): string;
363
+ /** Author ordered phonetic-script-render(output,script) without positional endpoint ambiguity. */
364
+ linkPhoneticScriptRender(input: LinkPhoneticScriptRenderRelationInput): string;
365
+ /** Author ordered audio-script-source(script,source) without positional endpoint ambiguity. */
366
+ linkAudioScriptSource(input: LinkAudioScriptSourceRelationInput): string;
286
367
  /** Remove a Relation by identity; endpoint replacement is an explicit unlink plus link. */
287
368
  unlink(input: UnlinkRelationInput): void;
288
369
  }
@@ -312,10 +393,12 @@ interface ReplacementMediaClipInput {
312
393
  readonly sourceRange: SequenceRange<number>;
313
394
  readonly volume?: number;
314
395
  }
396
+ /** Asset identity, either an old physical-only row or a directly composed media variant. */
397
+ type ResourceEntityKind = 'image' | 'video' | 'audio' | 'voice';
315
398
  interface SandboxEntity<K extends KnownEntityKind = KnownEntityKind> {
316
399
  entity_id: string;
317
400
  entity_kind: K;
318
- payload: EntityPayloadByKind[K];
401
+ payload: StoredEntityPayload<K>;
319
402
  }
320
403
  interface SandboxRelation {
321
404
  relation_id: string;
@@ -369,6 +452,10 @@ interface SetClipVolumeInput {
369
452
  /** Playback gain in decibels. */
370
453
  readonly volume: number;
371
454
  }
455
+ /** Stored own fields; a variant may obtain required content fields from its declared bases. */
456
+ type StoredEntityPayload<K extends KnownEntityKind> = EntityPayloadByKind[K] | (JsonObject & Partial<EntityPayloadByKind[K]> & {
457
+ baseEntityIds: string[];
458
+ });
372
459
  interface TrimClipInput {
373
460
  readonly clipEntityId: string;
374
461
  readonly sourceRange: SequenceRange<number>;
@@ -398,6 +485,7 @@ interface UpdateClipMarkerInput {
398
485
  /** Passing `undefined` explicitly removes the optional remapping value. */
399
486
  readonly timeRemapping?: JsonValue | undefined;
400
487
  }
488
+ /** Patch supplied fields on the assembled entity; omitted fields remain unchanged. */
401
489
  interface UpdateEntityInput {
402
490
  entity_id: string;
403
491
  payload: JsonObject;
@@ -420,36 +508,49 @@ interface VoiceMediaAssetFact {
420
508
  readonly kind: 'voice';
421
509
  readonly durationMs: number;
422
510
  readonly storageKey: string;
423
- readonly voice: VoiceDescriptor;
511
+ /** Present for synthesized voice, absent for original recorded audio. */
512
+ readonly voice?: VoiceDescriptor;
424
513
  }
425
514
  interface VoiceoverCaptionFact {
426
515
  /** Stable placed caption identity supplied by the materialized side effect. */
427
516
  readonly captionClipEntityId: string;
428
- readonly text: string;
517
+ /** Directly held bases; includes the AudioScript used by the Voice. */
518
+ readonly baseEntityIds: readonly string[];
519
+ /** Ordered selection of AudioScript segments; caption text is never passed inline. */
520
+ readonly selections: readonly CaptionSegmentSelection[];
429
521
  readonly startMs: number;
430
522
  readonly durationMs: number;
431
523
  readonly style?: CaptionStyleFields;
432
524
  }
433
- interface VoiceoverTakeInput {
434
- readonly timelineEntityId: string;
435
- /** Stable placed speech identity, distinct from media.assetId. */
525
+ type VoiceoverTakeInput = {
526
+ readonly timelineEntityId: string; /** Stable placed speech identity, distinct from media.assetId. */
436
527
  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;
528
+ readonly media: VoiceMediaAssetFact; /** Existing pronunciation variant; its composed AudioScript stays the text owner. */
529
+ readonly phoneticScriptEntityId: string;
442
530
  readonly volume: number;
443
531
  readonly captions: readonly VoiceoverCaptionFact[];
444
- }
532
+ } & ({
533
+ readonly placement: ClipPlacement;
534
+ readonly hostClipEntityId?: never;
535
+ readonly anchorOffset?: never;
536
+ } | {
537
+ readonly placement?: never;
538
+ readonly hostClipEntityId: string;
539
+ readonly anchorOffset: number;
540
+ });
445
541
  interface VoiceoverTakeResult {
446
542
  readonly voiceoverClipEntityId: string;
447
543
  readonly voiceEntityId: string;
544
+ /** The pronunciation variant the Voice was rendered from. */
545
+ readonly phoneticScriptEntityId: string;
546
+ /** The base-text owner resolved from the PhoneticScript baseEntityIds. */
448
547
  readonly audioScriptEntityId: string;
449
548
  readonly captionClipEntityIds: readonly string[];
450
549
  }
451
550
  /** Timeline writes accept existing media Entity ids, never Memota asset ids or URLs. */
452
551
  interface EditApi {
552
+ /** Select the document AudioScript, or clear the optional association with null. */
553
+ setDocumentAudioScript(entityId: string | null): void;
453
554
  insertClip(input: InsertClipInput): ClipEntityId;
454
555
  insertPlacedClip(input: InsertPlacedClipInput): ClipEntityId;
455
556
  updateClipMarker(input: UpdateClipMarkerInput): void;
@@ -475,6 +576,7 @@ interface EditApi {
475
576
  deleteBgm(input: DeleteBgmInput): void;
476
577
  setCaptionVisibility(input: SetCaptionVisibilityInput): void;
477
578
  patchCaptionStyle(input: PatchCaptionStyleInput): void;
579
+ insertCaptionClip(input: InsertCaptionClipInput): ClipEntityId;
478
580
  }
479
581
  interface TimelineApi {
480
582
  snapshot(): EntityStoreSnapshot;
@@ -490,5 +592,5 @@ declare function checkpoint(): SandboxCheckpoint;
490
592
  declare function rollbackTo(cp: SandboxCheckpoint): void;
491
593
  declare const inputs: Readonly<Record<string, unknown>>;
492
594
  //#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 };
595
+ 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
596
  //# sourceMappingURL=sandbox-api.d.mts.map