@mengine/medeo-tool 1.4.1-alpha.1 → 1.4.1-alpha.3

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.
@@ -19,70 +19,25 @@ interface BoundedNativeSequencePayload extends JsonObject {
19
19
  sampling: 'native';
20
20
  coordinateSpace: JsonValue;
21
21
  }
22
- /** Business editing surface. Infrastructure Assets are assembled by the host. */
22
+ /** Business editing surface. Reads are assembled snapshots; writes preserve native operation intent. */
23
23
  interface BusinessEntityFacade {
24
24
  list(): SandboxEntity[];
25
25
  get(entityId: string): SandboxEntity | null;
26
- readCaptionContent(entityId: string): ComposedScriptContent;
27
- readPhoneticScriptContent(entityId: string): ComposedPhoneticContent;
28
26
  create(input: Exclude<CreateEntityInput, {
29
27
  entity_kind: 'asset';
30
28
  }>): string;
31
- update(input: UpdateEntityInput): void;
29
+ update(input: EntityUpdateInput): void;
32
30
  declareFields(input: UpdateEntityInput): void;
33
31
  delete(input: DeleteEntityInput): void;
34
32
  }
35
- /** Physical Asset bindings are maintained outside the sandbox. */
33
+ /** Endpoint order is retained; each relation kind defines its endpoint semantics. */
36
34
  interface BusinessRelationFacade {
37
35
  list(): SandboxRelation[];
38
36
  of(entityId: string, relationKind?: KnownRelationKind): SandboxRelation[];
39
- link(input: Exclude<LinkRelationInput, {
40
- relation_kind: 'physical-asset';
41
- }>): string;
42
- linkGenerated(input: LinkGeneratedRelationInput): string;
43
- linkClipAnchor(input: LinkClipAnchorRelationInput): string;
44
- linkPhoneticScriptRender(input: LinkPhoneticScriptRenderRelationInput): string;
45
- linkAudioScriptSource(input: LinkAudioScriptSourceRelationInput): string;
37
+ link(input: LinkRelationInput): string;
38
+ update(input: RelationUpdateInput): void;
46
39
  unlink(input: UnlinkRelationInput): void;
47
40
  }
48
- interface CaptionFontDescriptor {
49
- readonly system: 'font-library';
50
- readonly key: string;
51
- }
52
- /**
53
- * One ordered entry of the Caption's segment selection. `segmentId` quotes the
54
- * composed AudioScript's own stable segment identity — a local id quoted by the
55
- * variant, never a peer Entity reference. Text itself is never copied here;
56
- * complete Caption content is assembled through its direct baseEntityIds.
57
- * The optional `textRange` narrows one Segment to an intra-Segment sub-span
58
- * (intra-segment re-segmentation); without it the whole Segment text is selected.
59
- */
60
- type CaptionSegmentSelection = JsonObject & {
61
- readonly segmentId: string;
62
- readonly textRange?: CaptionTextRange;
63
- };
64
- interface CaptionStyleFields {
65
- readonly font?: CaptionFontDescriptor;
66
- readonly fontSize?: number;
67
- readonly fontColor?: string;
68
- readonly fontWeight?: number;
69
- readonly entranceAnimation?: string;
70
- readonly entranceAnimationDurationMs?: number;
71
- readonly strokeColor?: string;
72
- readonly strokeWidth?: number;
73
- readonly positionX?: number;
74
- readonly positionY?: number;
75
- }
76
- /**
77
- * Half-open `[start, end)` position window inside one Segment's text, counted
78
- * in Unicode code points (not UTF-16 code units), so a boundary never splits a
79
- * surrogate pair. Positions are non-negative safe integers with `start < end`;
80
- * `end` must not exceed the Segment's code-point length.
81
- */
82
- interface CaptionTextRange extends JsonObject {
83
- readonly start: number;
84
- readonly end: number;
85
- }
86
41
  type CaptionTextSelection = JsonObject & {
87
42
  segmentId: string; /** Half-open Unicode code-point range within the selected source segment. */
88
43
  textRange?: {
@@ -90,51 +45,19 @@ type CaptionTextSelection = JsonObject & {
90
45
  end: number;
91
46
  };
92
47
  };
93
- type ClipEntityId = EntityId;
94
- type ClipPlacement = {
95
- readonly kind: 'sequential';
96
- readonly order: number;
97
- } | {
98
- readonly kind: 'absolute';
99
- readonly targetRange: SequenceRange<number>;
100
- } | {
101
- readonly kind: 'anchored';
102
- readonly hostClipEntityId: string;
103
- readonly anchorOffset: number;
104
- };
105
- interface ComposedPhoneticContent extends ComposedScriptContent {
106
- phonemeScript?: string;
107
- prosody?: JsonObject;
108
- }
109
- /** Read result only: base text is assembled from the real AudioScript row. */
110
- interface ComposedScriptContent {
111
- audio_script_entity_id: string;
112
- text: string;
113
- segments: ScriptTextSegment[];
114
- }
115
48
  type CreateEntityInput = { [K in KnownEntityKind]: {
116
49
  entity_id?: string;
117
50
  entity_kind: K;
118
51
  payload: StoredEntityPayload<K>;
119
52
  } }[KnownEntityKind];
120
- interface DeleteBgmInput {
121
- readonly timelineEntityId: string;
122
- }
123
- interface DeleteClipInput {
124
- readonly clipEntityId: string;
125
- }
126
- interface DeleteClipTreeInput {
127
- readonly clipEntityIds: readonly string[];
128
- readonly onAnchored: 'cascade' | 'detach';
129
- }
130
53
  interface DeleteEntityInput {
131
54
  entity_id: string;
132
55
  }
133
- interface DeleteVoiceoverInput {
134
- readonly voiceoverClipEntityIds: readonly string[];
56
+ /** Immutable resource content resolved by the host for a document Entity. */
57
+ interface EntityAssetContent {
58
+ assetId: string;
59
+ content: JsonValue;
135
60
  }
136
- type EmptyRelationKind = 'timeline-track' | 'track-clip' | 'clip-marker' | 'marker-content' | 'axvideo-marker' | 'marker-timeline' | 'audio-script-marker';
137
- type EntityId = string;
138
61
  interface EntityPayloadByKind {
139
62
  axvideo: BoundedDerivedSequencePayload;
140
63
  timeline: JsonObject;
@@ -143,10 +66,10 @@ interface EntityPayloadByKind {
143
66
  role?: string;
144
67
  };
145
68
  clip: JsonObject;
146
- video: BoundedNativeSequencePayload;
147
- audio: BoundedNativeSequencePayload;
148
- voice: BoundedNativeSequencePayload;
149
- image: UnboundedConstantSequencePayload;
69
+ video: BoundedNativeSequencePayload & MediaAssetPayload;
70
+ audio: BoundedNativeSequencePayload & MediaAssetPayload;
71
+ voice: BoundedNativeSequencePayload & MediaAssetPayload;
72
+ image: UnboundedConstantSequencePayload & MediaAssetPayload;
150
73
  'sequence-marker': JsonObject & {
151
74
  sourceRange: {
152
75
  start: number;
@@ -184,51 +107,53 @@ interface EntityPayloadByKind {
184
107
  baseEntityIds: string[];
185
108
  selections: CaptionTextSelection[];
186
109
  style?: JsonObject;
110
+ segmentRanges?: {
111
+ segmentId: string;
112
+ startMs: number;
113
+ endMs: number;
114
+ }[];
187
115
  };
188
116
  }
189
- interface EntityStoreSnapshot {
190
- /** Causal compiler baseline; required for publishing edits. */
191
- loroSnapshot?: string;
192
- revision: number;
193
- /** Current AudioScript version attached to the project; initialized projects always attach a script, possibly empty. */
194
- audioScriptEntityId: string | null;
195
- entities: SandboxEntity[];
196
- relations: SandboxRelation[];
197
- }
198
- interface InsertCaptionClipInput {
199
- readonly timelineEntityId: string;
200
- /** Existing generation identity for newly materialized Caption content, distinct from its Clip. */
201
- readonly captionEntityId?: string;
202
- /** Stable placed caption identity, distinct from the Caption content identity. */
203
- readonly captionClipEntityId?: string;
204
- /** Existing bases composed by this variant; includes an AudioScript text owner. */
205
- readonly baseEntityIds: readonly string[];
206
- /** Ordered selection of the AudioScript segments this Caption displays. */
207
- readonly selections: readonly CaptionSegmentSelection[];
208
- /** Intrinsic cue length of the Caption entity itself; display comes from the placement. */
209
- readonly durationMs: number;
210
- readonly style?: CaptionStyleFields;
211
- readonly placement: ClipPlacement;
212
- }
213
- interface InsertClipInput {
214
- readonly trackEntityId: string;
215
- /** Existing Sequence media Entity id. Asset ids and URLs are not content ids. */
216
- readonly contentEntityId: string;
217
- readonly sourceRange: SequenceRange<number>;
218
- readonly duration: SequenceDuration<number>;
219
- readonly targetRange?: SequenceRange<number>;
220
- readonly clipPayload?: JsonObject;
117
+ /** Tokens have no script-authored data; only the creating session can validate them. */
118
+ interface EntitySandboxCheckpoint {
119
+ readonly __checkpoint: unique symbol;
221
120
  }
222
- interface InsertPlacedClipInput {
223
- readonly trackEntityId: string;
224
- readonly contentEntityId: string;
225
- readonly sourceRange: SequenceRange<number>;
226
- readonly duration: SequenceDuration<number>;
227
- readonly placement: ClipPlacement;
228
- readonly clipPayload?: JsonObject;
229
- /** Stable caller-owned placement identity, when one already exists outside the graph. */
230
- readonly clipEntityId?: string;
121
+ interface EntityUpdateInput {
122
+ entity_id: string;
123
+ changes: FieldChange[];
231
124
  }
125
+ type FieldChange = {
126
+ op: 'set';
127
+ path: FieldPath;
128
+ value: JsonValue;
129
+ } | {
130
+ op: 'unset';
131
+ path: FieldPath;
132
+ } | {
133
+ op: 'text.splice';
134
+ path: FieldPath;
135
+ index: number;
136
+ deleteCount: number;
137
+ text: string;
138
+ } | {
139
+ op: 'list.insert';
140
+ path: FieldPath;
141
+ value: JsonValue;
142
+ beforeElementId: string | null;
143
+ } | {
144
+ op: 'list.move';
145
+ path: FieldPath;
146
+ elementId: string;
147
+ beforeElementId: string | null;
148
+ } | {
149
+ op: 'list.remove';
150
+ path: FieldPath;
151
+ elementId: string;
152
+ };
153
+ /** List members are addressed by identity, never a transient array offset. */
154
+ type FieldPath = readonly (string | {
155
+ elementId: string;
156
+ })[];
232
157
  interface JsonObject {
233
158
  [key: string]: JsonValue;
234
159
  }
@@ -236,90 +161,25 @@ type JsonPrimitive = string | number | boolean | null;
236
161
  type JsonValue = JsonPrimitive | JsonObject | JsonValue[];
237
162
  type KnownEntityKind = 'axvideo' | 'timeline' | 'track' | 'clip' | 'video' | 'audio' | 'voice' | 'image' | 'sequence-marker' | 'viewport' | 'audio-script' | 'phonetic-script' | 'caption';
238
163
  type KnownRelationKind = 'timeline-track' | 'track-clip' | 'clip-marker' | 'marker-content' | 'axvideo-marker' | 'marker-timeline' | 'generated' | 'caption-alignment' | 'clip-anchor' | 'phonetic-script-render' | 'audio-script-source' | 'audio-script-marker';
239
- interface LinearClipSpeed {
240
- readonly kind: 'linear';
241
- readonly rate: number;
242
- readonly mode?: string;
243
- }
244
- /** `audio-script-source(script, source)`; the script was transcribed from the source media. */
245
- interface LinkAudioScriptSourceRelationInput {
246
- relation_id?: string;
247
- script_entity_id: string;
248
- source_entity_id: string;
249
- trace?: JsonObject;
250
- }
251
- interface LinkClipAnchorRelationInput {
252
- relation_id?: string;
253
- child_clip_entity_id: string;
254
- host_clip_entity_id: string;
255
- trace?: JsonObject;
256
- }
257
- interface LinkGeneratedRelationInput {
258
- relation_id?: string;
259
- output_entity_id: string;
260
- input_entity_id: string;
261
- trace?: JsonObject;
262
- }
263
- interface LinkPhoneticScriptRenderRelationInput {
264
- relation_id?: string;
265
- output_entity_id: string;
266
- phonetic_script_entity_id: string;
267
- trace?: JsonObject;
268
- }
269
164
  interface LinkRelationBase {
270
165
  relation_id?: string;
271
166
  endpoint_0_entity_id: string;
272
167
  endpoint_1_entity_id: string;
273
168
  trace?: JsonObject;
274
169
  }
275
- type LinkRelationInput = (LinkRelationBase & {
276
- relation_kind: EmptyRelationKind;
277
- metadata?: {
278
- [key: string]: never;
279
- };
280
- }) | (LinkRelationBase & {
281
- relation_kind: 'physical-asset';
170
+ interface LinkRelationInput extends LinkRelationBase {
171
+ relation_kind: KnownRelationKind;
282
172
  metadata?: JsonObject;
283
- }) | (LinkRelationBase & {
284
- relation_kind: 'caption-alignment';
285
- metadata: JsonObject & {
286
- alignment: JsonValue;
287
- };
288
- });
289
- interface MoveClipInput {
290
- readonly clipEntityId: string;
291
- readonly trackEntityId: string;
292
- }
293
- interface MoveClipsToStartsInput {
294
- readonly moves: readonly {
295
- readonly clipEntityId: string;
296
- readonly newStartMs: number;
297
- }[];
298
- /** Absolute-time drags preserve every voiceover's current visible landing. */
299
- readonly onAnchored: 'keepAbsolute';
300
- }
301
- interface MoveSequentialClipsInput {
302
- readonly clipEntityIds: readonly string[];
303
- readonly anchor: SequentialClipAnchor;
304
- readonly onAnchored: 'follow' | 'keepAbsolute';
305
- }
306
- interface MoveVoiceoverInput {
307
- readonly voiceoverClipEntityId: string;
308
- /** Absolute requested timeline start; MEngine resolves and persists the host relation. */
309
- readonly newStartMs: number;
310
173
  }
311
- interface PatchCaptionStyleInput {
312
- readonly timelineEntityId: string;
313
- readonly style: CaptionStyleFields;
314
- }
315
- interface ReplaceClipContentInput {
316
- readonly clipEntityId: string;
317
- /** Existing Sequence media Entity id. Asset ids and URLs are not content ids. */
318
- readonly contentEntityId: string;
319
- readonly sourceRange: SequenceRange<number>;
320
- readonly duration: SequenceDuration<number>;
321
- readonly targetRange?: SequenceRange<number>;
322
- readonly timeRemapping?: JsonValue;
174
+ type MediaAssetPayload = JsonObject & {
175
+ external: {
176
+ system: 'memota' | 'memota-speech';
177
+ key: string;
178
+ };
179
+ };
180
+ interface RelationUpdateInput {
181
+ relation_id: string;
182
+ changes: FieldChange[];
323
183
  }
324
184
  interface SandboxEntity<K extends KnownEntityKind = KnownEntityKind> {
325
185
  entity_id: string;
@@ -339,47 +199,10 @@ type ScriptTextSegment = JsonObject & {
339
199
  text: string;
340
200
  language?: string;
341
201
  };
342
- type SequenceDuration<Span = unknown> = {
343
- readonly mode: 'from-source';
344
- } | {
345
- readonly mode: 'fixed';
346
- readonly value: Span;
347
- };
348
- interface SequenceRange<Point = unknown> {
349
- readonly start: Point;
350
- readonly end: Point;
351
- }
352
- type SequentialClipAnchor = {
353
- readonly position: 'before' | 'after';
354
- readonly clipEntityId: string;
355
- } | {
356
- readonly position: 'trackStart';
357
- };
358
- interface SetCaptionVisibilityInput {
359
- readonly timelineEntityId: string;
360
- readonly hidden: boolean;
361
- }
362
- interface SetClipPlacementInput {
363
- readonly clipEntityId: string;
364
- readonly placement: ClipPlacement;
365
- }
366
- interface SetClipSpeedInput {
367
- readonly clipEntityId: string;
368
- readonly timeRemapping: LinearClipSpeed | null;
369
- }
370
- interface SetClipVolumeInput {
371
- readonly clipEntityId: string;
372
- /** Playback gain in decibels. */
373
- readonly volume: number;
374
- }
375
202
  /** Stored own fields; a variant may obtain required content fields from its declared bases. */
376
- type StoredEntityPayload<K extends KnownEntityKind> = EntityPayloadByKind[K] | (JsonObject & Partial<EntityPayloadByKind[K]> & {
203
+ type StoredEntityPayload<K extends KnownEntityKind> = EntityPayloadByKind[K] | (K extends 'caption' ? JsonObject & Pick<MediaAssetPayload, 'external'> : never) | (JsonObject & Partial<EntityPayloadByKind[K]> & {
377
204
  baseEntityIds: string[];
378
205
  });
379
- interface TrimClipInput {
380
- readonly clipEntityId: string;
381
- readonly sourceRange: SequenceRange<number>;
382
- }
383
206
  interface UnboundedConstantSequencePayload extends JsonObject {
384
207
  extent: {
385
208
  kind: 'unbounded';
@@ -391,63 +214,24 @@ interface UnboundedConstantSequencePayload extends JsonObject {
391
214
  interface UnlinkRelationInput {
392
215
  relation_id: string;
393
216
  }
394
- interface UpdateClipInput {
395
- readonly clipEntityId: string;
396
- /** Complete replacement for the Clip-owned payload. */
397
- readonly payload: JsonObject;
398
- }
399
- interface UpdateClipMarkerInput {
400
- readonly clipEntityId: string;
401
- readonly sourceRange?: SequenceRange<number>;
402
- /** Passing `undefined` explicitly removes the optional target range. */
403
- readonly targetRange?: SequenceRange<number> | undefined;
404
- readonly duration?: SequenceDuration<number>;
405
- /** Passing `undefined` explicitly removes the optional remapping value. */
406
- readonly timeRemapping?: JsonValue | undefined;
407
- }
408
217
  /** Patch supplied fields on the assembled entity; omitted fields remain unchanged. */
409
218
  interface UpdateEntityInput {
410
219
  entity_id: string;
411
220
  payload: JsonObject;
412
221
  }
413
- /** Timeline writes accept existing media Entity ids, never Memota asset ids or URLs. */
414
- interface EditApi {
415
- insertClip(input: InsertClipInput): ClipEntityId;
416
- insertPlacedClip(input: InsertPlacedClipInput): ClipEntityId;
417
- updateClipMarker(input: UpdateClipMarkerInput): void;
418
- setClipPlacement(input: SetClipPlacementInput): void;
419
- moveSequentialClips(input: MoveSequentialClipsInput): void;
420
- moveClip(input: MoveClipInput): void;
421
- replaceClipContent(input: ReplaceClipContentInput): void;
422
- setClipVolume(input: SetClipVolumeInput): void;
423
- setClipSpeed(input: SetClipSpeedInput): void;
424
- trimClip(input: TrimClipInput): void;
425
- deleteClip(input: DeleteClipInput): void;
426
- deleteClipTree(input: DeleteClipTreeInput): void;
427
- updateClip(input: UpdateClipInput): void;
428
- moveVoiceover(input: MoveVoiceoverInput): void;
429
- moveClipsToStarts(input: MoveClipsToStartsInput): void;
430
- deleteVoiceover(input: DeleteVoiceoverInput): void;
431
- deleteBgm(input: DeleteBgmInput): void;
432
- setCaptionVisibility(input: SetCaptionVisibilityInput): void;
433
- patchCaptionStyle(input: PatchCaptionStyleInput): void;
434
- insertCaptionClip(input: InsertCaptionClipInput): ClipEntityId;
435
- }
436
- interface TimelineApi {
437
- snapshot(): EntityStoreSnapshot & {
438
- audioScriptEntityId: string;
439
- };
440
- }
441
- interface SandboxCheckpoint {
442
- readonly index: number;
443
- }
444
- declare const edit: EditApi;
445
- declare const timeline: TimelineApi;
446
222
  declare const entities: BusinessEntityFacade;
447
223
  declare const relations: BusinessRelationFacade;
448
- declare function checkpoint(): SandboxCheckpoint;
449
- declare function rollbackTo(cp: SandboxCheckpoint): void;
224
+ /** Resolve this Entity's attached resource through the host; await before using an uninitialized Caption. */
225
+ declare function rgetAssetFromEntity(entityId: string): Promise<EntityAssetContent>;
226
+ declare function checkpoint(): EntitySandboxCheckpoint;
227
+ declare function rollbackTo(cp: EntitySandboxCheckpoint): void;
450
228
  declare const inputs: Readonly<Record<string, unknown>>;
229
+ declare const console: {
230
+ log(...values: unknown[]): void;
231
+ info(...values: unknown[]): void;
232
+ warn(...values: unknown[]): void;
233
+ error(...values: unknown[]): void;
234
+ };
451
235
  //#endregion
452
- export type { BoundedDerivedSequencePayload, BoundedNativeSequencePayload, BusinessEntityFacade, BusinessRelationFacade, CaptionFontDescriptor, CaptionSegmentSelection, CaptionStyleFields, CaptionTextRange, CaptionTextSelection, ClipEntityId, ClipPlacement, ComposedPhoneticContent, ComposedScriptContent, CreateEntityInput, DeleteBgmInput, DeleteClipInput, DeleteClipTreeInput, DeleteEntityInput, DeleteVoiceoverInput, EditApi, EmptyRelationKind, EntityId, EntityPayloadByKind, EntityStoreSnapshot, InsertCaptionClipInput, InsertClipInput, InsertPlacedClipInput, JsonObject, JsonPrimitive, JsonValue, KnownEntityKind, KnownRelationKind, LinearClipSpeed, LinkAudioScriptSourceRelationInput, LinkClipAnchorRelationInput, LinkGeneratedRelationInput, LinkPhoneticScriptRenderRelationInput, LinkRelationInput, MoveClipInput, MoveClipsToStartsInput, MoveSequentialClipsInput, MoveVoiceoverInput, PatchCaptionStyleInput, ReplaceClipContentInput, SandboxCheckpoint, SandboxEntity, SandboxRelation, ScriptTextSegment, SequenceDuration, SequenceRange, SequentialClipAnchor, SetCaptionVisibilityInput, SetClipPlacementInput, SetClipSpeedInput, SetClipVolumeInput, StoredEntityPayload, TimelineApi, TrimClipInput, UnboundedConstantSequencePayload, UnlinkRelationInput, UpdateClipInput, UpdateClipMarkerInput, UpdateEntityInput, checkpoint, edit, entities, inputs, relations, rollbackTo, timeline };
236
+ export type { BoundedDerivedSequencePayload, BoundedNativeSequencePayload, BusinessEntityFacade, BusinessRelationFacade, CaptionTextSelection, CreateEntityInput, DeleteEntityInput, EntityAssetContent, EntityPayloadByKind, EntitySandboxCheckpoint, EntityUpdateInput, FieldChange, FieldPath, JsonObject, JsonPrimitive, JsonValue, KnownEntityKind, KnownRelationKind, LinkRelationInput, MediaAssetPayload, RelationUpdateInput, SandboxEntity, SandboxRelation, ScriptTextSegment, StoredEntityPayload, UnboundedConstantSequencePayload, UnlinkRelationInput, UpdateEntityInput, checkpoint, console, entities, inputs, relations, rgetAssetFromEntity, rollbackTo };
453
237
  //# sourceMappingURL=sandbox-api.d.mts.map
@@ -1,4 +1,4 @@
1
- import { s as EntityStoreSnapshot } from "./entity-contract-DHasvrhq.mjs";
1
+ import { l as EntityStoreSnapshot } from "./entity-contract-DQ56Ihrh.mjs";
2
2
  import { VideoDocument } from "@mengine/medeo-client";
3
3
 
4
4
  //#region src/sandbox/worker-entry.d.ts
@@ -15,7 +15,6 @@ interface WorkerData {
15
15
  inputs?: Record<string, unknown>;
16
16
  entityState?: EntityStoreSnapshot;
17
17
  idLabel?: string;
18
- entityOnly?: boolean;
19
18
  }
20
19
  //#endregion
21
20
  export { WorkerData };