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

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