@mengine/medeo-client 2.1.0 → 2.1.1-dsl.1

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.
@@ -0,0 +1,940 @@
1
+ import { B as Media, E as CaptionStyle, J as TextEdit, M as DslDiagnostic, N as DslMutation, Q as TimeAnchor, R as FieldPatch, T as CaptionSelection, c as VideoDraftInput, et as TrackRole, h as DslIdFactory, o as VideoDraftContent, p as CommitOptions, tt as Voice, w as CaptionContent, z as MedeoDslSnapshot } from "./video-draft-types-c_shaRyq.js";
2
+ import { ContainerType, Cursor, LoroDoc, PeerID, TreeID } from "loro-crdt";
3
+
4
+ //#region src/dsl/action-context.d.ts
5
+ type ClipPlacement = {
6
+ kind: 'sequential';
7
+ } | {
8
+ kind: 'absolute';
9
+ startMs: number;
10
+ } | {
11
+ kind: 'anchored';
12
+ clipId: string;
13
+ offsetMs: number;
14
+ };
15
+ //#endregion
16
+ //#region src/dsl/clip-actions.d.ts
17
+ type ClipSource = {
18
+ sourceId: string;
19
+ media?: never;
20
+ } | {
21
+ media: Media;
22
+ sourceId?: never;
23
+ };
24
+ type AddDslClip = ClipSource & {
25
+ inMs?: number;
26
+ outMs?: number;
27
+ speed?: {
28
+ rate: number;
29
+ };
30
+ volume?: number;
31
+ fillTimeline?: true;
32
+ placement?: ClipPlacement;
33
+ };
34
+ interface AddDslClipsInput {
35
+ trackId: string;
36
+ clips: readonly AddDslClip[];
37
+ index?: number;
38
+ }
39
+ interface MoveDslClipsInput {
40
+ clipIds: readonly string[];
41
+ trackId: string;
42
+ index: number;
43
+ onAnchored: 'follow' | 'keepAbsolute';
44
+ }
45
+ interface ReplaceDslClipsInput {
46
+ clipIds: readonly string[];
47
+ clips: readonly AddDslClip[];
48
+ onAnchored: 'remap' | 'cascade';
49
+ }
50
+ interface DslClipUpdate {
51
+ clipId: string;
52
+ inMs?: number;
53
+ outMs?: number;
54
+ speed?: {
55
+ rate: number;
56
+ };
57
+ volume?: number;
58
+ placement?: ClipPlacement;
59
+ }
60
+ //#endregion
61
+ //#region ../../node_modules/.pnpm/loro-mirror@2.3.3_patch_hash=a551a0e4aa4f61ec88b0d9e970a183b5ee2955107a2e0bb03b378bc510c2f395_loro-crdt@1.16.1/node_modules/loro-mirror/dist/schema/types.d.ts
62
+ /**
63
+ * Options for schema definitions
64
+ */
65
+ interface SchemaOptions {
66
+ /** Whether the field is required */
67
+ required?: boolean;
68
+ /** Default value for the field */
69
+ defaultValue?: unknown;
70
+ /** Description of the field */
71
+ description?: string;
72
+ /**
73
+ * Additional validation function.
74
+ * Receives the domain value to validate - this will be the transformed value if a transform is defined, otherwise the raw value (string | number | boolean).
75
+ * Return true if valid, or a string error message if invalid.
76
+ */
77
+ validate?: (value: unknown) => boolean | string;
78
+ /**
79
+ * When set on a `schema.LoroMap` or `schema.LoroMapRecord`, new direct child
80
+ * containers under that map's keys are created with Loro's `ensureMergeable*`
81
+ * APIs instead of `setContainer`.
82
+ *
83
+ * By default, two peers that concurrently create a child container under the
84
+ * same Map key produce distinct container IDs; the Map slot is
85
+ * last-writer-wins, so one peer's child (and its contents) is silently
86
+ * dropped after sync. With this enabled, the child's identity derives from
87
+ * its logical position (parent container id + key + type), so every peer
88
+ * resolves to the same CRDT object and their content merges.
89
+ *
90
+ * Opt-in (default `false`) to keep the document format compatible with older
91
+ * `setContainer` child-container semantics. All collaborating clients must
92
+ * use `loro-crdt >= 1.13.3`.
93
+ *
94
+ * @see https://loro.dev/blog/mergeable-containers
95
+ */
96
+ mergeableMapChildContainers?: boolean;
97
+ [key: string]: unknown;
98
+ }
99
+ type HasExplicitDefaultValue<S extends SchemaType> = S extends {
100
+ options: {
101
+ defaultValue: unknown;
102
+ };
103
+ } ? true : false;
104
+ type AnySchemaOptions = SchemaOptions & {
105
+ /**
106
+ * Per-Any inference overrides.
107
+ *
108
+ * Notes:
109
+ * - `defaultLoroText` defaults to `false` for Any when omitted (primitive string),
110
+ * overriding the global `inferOptions.defaultLoroText`.
111
+ * - `defaultMovableList` inherits from the global inference options unless specified.
112
+ */
113
+ defaultLoroText?: boolean;
114
+ defaultMovableList?: boolean;
115
+ };
116
+ /**
117
+ * Base interface for all schema types
118
+ */
119
+ interface BaseSchemaType {
120
+ type: string;
121
+ options: SchemaOptions;
122
+ getContainerType(): ContainerType | null;
123
+ }
124
+ /**
125
+ * Any schema type
126
+ *
127
+ * This schema defers container inference decisions to the runtime (Mirror).
128
+ */
129
+ interface AnySchemaType extends BaseSchemaType {
130
+ type: "any";
131
+ options: AnySchemaOptions;
132
+ }
133
+ /**
134
+ * String schema type
135
+ */
136
+ interface StringSchemaType<T extends string = string> extends BaseSchemaType {
137
+ type: "string";
138
+ _t: T;
139
+ }
140
+ /**
141
+ * Number schema type
142
+ */
143
+ interface NumberSchemaType extends BaseSchemaType {
144
+ type: "number";
145
+ }
146
+ /**
147
+ * Boolean schema type
148
+ */
149
+ interface BooleanSchemaType extends BaseSchemaType {
150
+ type: "boolean";
151
+ }
152
+ /**
153
+ * Ignored field schema type
154
+ */
155
+ interface IgnoreSchemaType extends BaseSchemaType {
156
+ type: "ignore";
157
+ }
158
+ /**
159
+ * Loro Map schema type
160
+ */
161
+ interface LoroMapSchema<T extends Record<string, SchemaType>> extends BaseSchemaType {
162
+ type: "loro-map";
163
+ definition: SchemaDefinition<T>;
164
+ }
165
+ /**
166
+ * Enhanced LoroMapSchema with catchall support
167
+ */
168
+ interface LoroMapSchemaWithCatchall<T extends Record<string, SchemaType>, C extends SchemaType> extends BaseSchemaType {
169
+ type: "loro-map";
170
+ definition: SchemaDefinition<T>;
171
+ catchallType: C;
172
+ catchall<NewC extends SchemaType>(catchallSchema: NewC): LoroMapSchemaWithCatchall<T, NewC>;
173
+ }
174
+ /**
175
+ * Loro List schema type
176
+ */
177
+ interface LoroListSchema<T extends SchemaType> extends BaseSchemaType {
178
+ type: "loro-list";
179
+ itemSchema: T;
180
+ idSelector?: (item: unknown) => string;
181
+ }
182
+ /**
183
+ * Loro Movable List schema type
184
+ */
185
+ interface LoroMovableListSchema<T extends SchemaType> extends BaseSchemaType {
186
+ type: "loro-movable-list";
187
+ itemSchema: T;
188
+ idSelector?: (item: unknown) => string;
189
+ }
190
+ /**
191
+ * Loro Text schema type
192
+ */
193
+ interface LoroTextSchemaType extends BaseSchemaType {
194
+ type: "loro-text";
195
+ }
196
+ /**
197
+ * Loro Tree schema type
198
+ *
199
+ * Represents a tree where each node has a `data` map described by `nodeSchema`.
200
+ */
201
+ interface LoroTreeSchema<T extends Record<string, SchemaType>> extends BaseSchemaType {
202
+ type: "loro-tree";
203
+ nodeSchema: LoroMapSchema<T>;
204
+ }
205
+ /**
206
+ * Field types allowed at the document root: containers, plus `Ignore`
207
+ * (a memory-only field that never touches the LoroDoc).
208
+ */
209
+ type RootFieldSchemaType = ContainerSchemaType | IgnoreSchemaType;
210
+ /**
211
+ * Root schema type
212
+ */
213
+ interface RootSchemaType<T extends Record<string, RootFieldSchemaType>> extends BaseSchemaType {
214
+ type: "schema";
215
+ definition: RootSchemaDefinition<T>;
216
+ }
217
+ /**
218
+ * Union of all schema types
219
+ */
220
+ type SchemaType = AnySchemaType | StringSchemaType | NumberSchemaType | BooleanSchemaType | IgnoreSchemaType | LoroMapSchema<Record<string, SchemaType>> | LoroMapSchemaWithCatchall<Record<string, SchemaType>, SchemaType> | LoroListSchema<SchemaType> | LoroMovableListSchema<SchemaType> | LoroTextSchemaType | LoroTreeSchema<Record<string, SchemaType>> | RootSchemaType<Record<string, RootFieldSchemaType>>;
221
+ type ContainerSchemaType = LoroMapSchema<Record<string, SchemaType>> | LoroMapSchemaWithCatchall<Record<string, SchemaType>, SchemaType> | LoroListSchema<SchemaType> | LoroMovableListSchema<SchemaType> | LoroTextSchemaType | LoroTreeSchema<Record<string, SchemaType>>;
222
+ /**
223
+ * Schema definition type
224
+ */
225
+ type RootSchemaDefinition<T extends Record<string, RootFieldSchemaType>> = { [K in keyof T]: T[K] };
226
+ /**
227
+ * Schema definition type
228
+ */
229
+ type SchemaDefinition<T extends Record<string, SchemaType>> = { [K in keyof T]: T[K] };
230
+ /**
231
+ * Check if a schema type is required
232
+ *
233
+ * true is default
234
+ */
235
+ type IsSchemaRequired<S extends SchemaType> = S extends {
236
+ options: {
237
+ required: true;
238
+ };
239
+ } ? true : S extends {
240
+ options: {
241
+ required: false;
242
+ };
243
+ } ? false : S extends {
244
+ options: {
245
+ required?: undefined;
246
+ };
247
+ } ? true : S extends {
248
+ options: {};
249
+ } ? true : true;
250
+ /**
251
+ * Infer the JavaScript type from a schema type.
252
+ */
253
+ type InferType<S extends SchemaType> = S extends {
254
+ transform: TransformDefinition<infer _C, infer D>;
255
+ } ? WithTransformStartupOptionality<D, S & SchemaType> : S extends StringSchemaType ? InferStringType<S> : S extends NumberSchemaType ? InferNumberType<S> : S extends BooleanSchemaType ? InferBooleanType<S> : IsSchemaRequired<S> extends false ? S extends AnySchemaType ? unknown : S extends IgnoreSchemaType ? unknown : S extends LoroTextSchemaType ? string | undefined : S extends LoroMapSchemaWithCatchall<infer M, infer C> ? keyof M extends never ? ({
256
+ [key: string]: InferType<C>;
257
+ } & {
258
+ $cid: string;
259
+ }) | undefined : (({ [K in keyof M]: InferType<M[K]> } & { [K in Exclude<string, keyof M>]: InferType<C> }) & {
260
+ $cid: string;
261
+ }) | undefined : S extends LoroMapSchema<infer M> ? ({ [K in keyof M]: InferType<M[K]> } & {
262
+ $cid: string;
263
+ }) | undefined : S extends LoroListSchema<infer I> ? Array<InferType<I>> | undefined : S extends LoroMovableListSchema<infer I> ? Array<InferType<I>> | undefined : S extends LoroTreeSchema<infer M> ? Array<InferTreeNodeTypeWithCid<M>> | undefined : S extends RootSchemaType<infer R> ? { [K in keyof R]: InferType<R[K]> } | undefined : never : S extends IgnoreSchemaType ? unknown : S extends LoroTextSchemaType ? string : S extends AnySchemaType ? unknown : S extends LoroMapSchemaWithCatchall<infer M, infer C> ? keyof M extends never ? {
264
+ [key: string]: InferType<C>;
265
+ } & {
266
+ $cid: string;
267
+ } : ({ [K in keyof M]: InferType<M[K]> } & { [K in Exclude<string, keyof M>]: InferType<C> }) & {
268
+ $cid: string;
269
+ } : S extends LoroMapSchema<infer M> ? { [K in keyof M]: InferType<M[K]> } & {
270
+ $cid: string;
271
+ } : S extends LoroListSchema<infer I> ? Array<InferType<I>> : S extends LoroMovableListSchema<infer I> ? Array<InferType<I>> : S extends LoroTreeSchema<infer M> ? Array<InferTreeNodeTypeWithCid<M>> : S extends RootSchemaType<infer R> ? { [K in keyof R]: InferType<R[K]> } : never;
272
+ /**
273
+ * Infer the input (write) type for setState updates.
274
+ * Identical to InferType<S> except that for any LoroMap shape, the `$cid` field is optional.
275
+ */
276
+ type InferInputType<S extends SchemaType> = S extends {
277
+ transform: TransformDefinition<infer _C, infer D>;
278
+ } ? WithTransformStartupOptionality<D, S & SchemaType> : S extends StringSchemaType ? InferStringType<S> : S extends NumberSchemaType ? InferNumberType<S> : S extends BooleanSchemaType ? InferBooleanType<S> : IsSchemaRequired<S> extends false ? S extends AnySchemaType ? unknown : S extends IgnoreSchemaType ? unknown : S extends LoroTextSchemaType ? string | undefined : S extends LoroMapSchemaWithCatchall<infer M, infer C> ? keyof M extends never ? ({
279
+ [key: string]: InferInputType<C>;
280
+ } & {
281
+ $cid?: string;
282
+ }) | undefined : (({ [K in keyof M]: InferInputType<M[K]> } & { [K in Exclude<string, keyof M>]: InferInputType<C> }) & {
283
+ $cid?: string;
284
+ }) | undefined : S extends LoroMapSchema<infer M> ? ({ [K in keyof M]: InferInputType<M[K]> } & {
285
+ $cid?: string;
286
+ }) | undefined : S extends LoroListSchema<infer I> ? Array<InferInputType<I>> | undefined : S extends LoroMovableListSchema<infer I> ? Array<InferInputType<I>> | undefined : S extends LoroTreeSchema<infer M> ? Array<InferInputTreeNodeType<M>> | undefined : S extends RootSchemaType<infer R> ? { [K in keyof R]: InferInputType<R[K]> } | undefined : never : S extends IgnoreSchemaType ? unknown : S extends LoroTextSchemaType ? string : S extends AnySchemaType ? unknown : S extends LoroMapSchemaWithCatchall<infer M, infer C> ? keyof M extends never ? {
287
+ [key: string]: InferInputType<C>;
288
+ } & {
289
+ $cid?: string;
290
+ } : ({ [K in keyof M]: InferInputType<M[K]> } & { [K in Exclude<string, keyof M>]: InferInputType<C> }) & {
291
+ $cid?: string;
292
+ } : S extends LoroMapSchema<infer M> ? { [K in keyof M]: InferInputType<M[K]> } & {
293
+ $cid?: string;
294
+ } : S extends LoroListSchema<infer I> ? Array<InferInputType<I>> : S extends LoroMovableListSchema<infer I> ? Array<InferInputType<I>> : S extends LoroTreeSchema<infer M> ? Array<InferInputTreeNodeType<M>> : S extends RootSchemaType<infer R> ? { [K in keyof R]: InferInputType<R[K]> } : never;
295
+ /**
296
+ * Helper: Infer the node type for a tree schema whose node.data map includes $cid
297
+ */
298
+ type InferTreeNodeTypeWithCid<M extends Record<string, SchemaType>> = {
299
+ id: string;
300
+ data: { [K in keyof M]: InferType<M[K]> } & {
301
+ $cid: string;
302
+ };
303
+ children: Array<InferTreeNodeTypeWithCid<M>>;
304
+ };
305
+ /**
306
+ * Helper: Input node type for a tree schema (node.data has optional $cid)
307
+ */
308
+ type InferInputTreeNodeType<M extends Record<string, SchemaType>> = {
309
+ id: string;
310
+ data: { [K in keyof M]: InferInputType<M[K]> } & {
311
+ $cid?: string;
312
+ };
313
+ children: Array<InferInputTreeNodeType<M>>;
314
+ };
315
+ /**
316
+ * Equality comparison strategy for transformed values.
317
+ *
318
+ * Reference equality is ALWAYS checked first.
319
+ * This setting controls what happens when references differ.
320
+ *
321
+ * - "reference-equality" (default): If refs differ, treat as not equal (no encoding).
322
+ * Correct for Immer-draftable types, immutable types, and copy-on-change patterns.
323
+ * Fast because no encoding is needed.
324
+ *
325
+ * - "encoded-value-equality": If refs differ, encode both and compare.
326
+ * Use when you may have different objects with the same encoded value
327
+ * and want to avoid redundant updates.
328
+ *
329
+ * - "deep-equality": If refs differ, perform a deep equality check on the domain values.
330
+ * This is rarely needed as Immer-draftable objects typically maintain reference equality when unchanged,
331
+ * but can be useful for non-Immer-managed objects that are slow to encode and have no simple equality check.
332
+ *
333
+ * - Custom function: Your own comparison logic. Receives the domain values.
334
+ */
335
+ type EqualityStrategy<DomainType> = "reference-equality" | "encoded-value-equality" | "deep-equality" | ((a: DomainType, b: DomainType) => boolean);
336
+ /**
337
+ * Transform definition for bidirectional conversion between CRDT primitives and domain types.
338
+ * It is strongly recommend that DomainType is immutable or
339
+ * [supported by Immer](https://immerjs.github.io/immer/complex-objects/) otherwise changes to transformed
340
+ * values may not be detected and converted to CRDT operations. Never mutate DomainType instances
341
+ * outside of Loro Mirror's setState function. CRDTType and DomainType can be null or undefined, but decode/encode functions
342
+ * will never receive null/undefined - they pass through as-is. Validation is performed on the domain type after transformation
343
+ * (or more precisely, validation on domain types happens before encoding).
344
+ */
345
+ interface TransformDefinition<CRDTType, DomainType> {
346
+ /**
347
+ * Convert CRDT primitive to domain type.
348
+ * Never called with null/undefined - they pass through as-is.
349
+ */
350
+ decode: (value: CRDTType & {}) => DomainType & {};
351
+ /**
352
+ * Convert domain type to CRDT primitive.
353
+ * Never called with null/undefined - they pass through as-is.
354
+ */
355
+ encode: (value: DomainType & {}) => CRDTType & {};
356
+ /**
357
+ * Validate the domain value.
358
+ * Called during schema validation after null/undefined checks pass.
359
+ * Return true if valid, or a string error message if invalid.
360
+ * The validate function passed to schema.String | Number | Boolean will also be called.
361
+ */
362
+ validate?: (value: DomainType & {}) => boolean | string;
363
+ /**
364
+ * How to compare domain values for equality.
365
+ *
366
+ * Reference equality (===) is always checked first.
367
+ * This setting controls behavior when references differ.
368
+ *
369
+ * @default "reference-equality"
370
+ */
371
+ isEqual?: EqualityStrategy<DomainType>;
372
+ /**
373
+ * Whether to validate that encode() returns the correct CRDT type during schema validation.
374
+ * When true, encode() is called on every validation to check the return type.
375
+ * When false, encode type checking is skipped for better performance.
376
+ *
377
+ * @default false
378
+ */
379
+ validateEncodedType?: boolean;
380
+ }
381
+ /**
382
+ * Add | undefined to T if schema is optional (required: false).
383
+ * Used by InferType to add optionality to both transformed and non-transformed fields.
384
+ */
385
+ type WithOptionality<T, S extends SchemaType> = IsSchemaRequired<S> extends false ? T | undefined : T;
386
+ type WithTransformStartupOptionality<T, S extends SchemaType> = IsSchemaRequired<S> extends false ? T | undefined : HasExplicitDefaultValue<S> extends true ? T : T | undefined;
387
+ type InferStringType<S extends SchemaType> = S extends {
388
+ transform: TransformDefinition<infer _C, infer D>;
389
+ } ? WithOptionality<D, S> : S extends StringSchemaType<infer T> ? WithOptionality<T, S> : WithOptionality<string, S>;
390
+ type InferNumberType<S extends SchemaType> = S extends {
391
+ transform: TransformDefinition<infer _C, infer D>;
392
+ } ? WithOptionality<D, S> : WithOptionality<number, S>;
393
+ type InferBooleanType<S extends SchemaType> = S extends {
394
+ transform: TransformDefinition<infer _C, infer D>;
395
+ } ? WithOptionality<D, S> : WithOptionality<boolean, S>;
396
+ //#endregion
397
+ //#region ../medeo-dsl/src/schema/codec.d.ts
398
+ interface InvalidAtomic {
399
+ invalid: true;
400
+ raw: string;
401
+ reason: string;
402
+ }
403
+ declare function isInvalidAtomic(value: unknown): value is InvalidAtomic;
404
+ interface AtomicCodec<T> {
405
+ encode(value: T | InvalidAtomic): string;
406
+ decode(raw: string): T | InvalidAtomic;
407
+ }
408
+ declare const timeAnchorCodec: AtomicCodec<TimeAnchor>;
409
+ declare const captionContentCodec: AtomicCodec<CaptionContent>;
410
+ //#endregion
411
+ //#region ../medeo-dsl/src/schema/loro-shape.d.ts
412
+ /** Only direct children inherit mergeable identity. Body and ordinary entity rows keep normal identities. */
413
+ declare const medeoDslLoroShape: RootSchemaType<{
414
+ 'timeline-entities': LoroMapSchemaWithCatchall<{}, LoroMapSchema<{}> & {
415
+ options: {};
416
+ } & {
417
+ catchall: <C extends SchemaType>(catchallSchema: C) => LoroMapSchemaWithCatchall<{}, C>;
418
+ }> & {
419
+ options: {};
420
+ };
421
+ 'track-entities': LoroMapSchemaWithCatchall<{}, LoroMapSchema<{
422
+ role: /*elided*/any;
423
+ hidden: /*elided*/any;
424
+ }> & {
425
+ options: {};
426
+ } & {
427
+ catchall: <C extends SchemaType>(catchallSchema: C) => LoroMapSchemaWithCatchall<{
428
+ role: /*elided*/any;
429
+ hidden: /*elided*/any;
430
+ }, C>;
431
+ }> & {
432
+ options: {};
433
+ };
434
+ 'clip-entities': LoroMapSchemaWithCatchall<{}, LoroMapSchema<{
435
+ seqMarker: /*elided*/any;
436
+ volume: /*elided*/any;
437
+ }> & {
438
+ options: {};
439
+ } & {
440
+ catchall: <C extends SchemaType>(catchallSchema: C) => LoroMapSchemaWithCatchall<{
441
+ seqMarker: /*elided*/any;
442
+ volume: /*elided*/any;
443
+ }, C>;
444
+ }> & {
445
+ options: {};
446
+ };
447
+ 'media-entities': LoroMapSchemaWithCatchall<{}, LoroMapSchema<{
448
+ kind: /*elided*/any;
449
+ system: /*elided*/any;
450
+ key: /*elided*/any;
451
+ storageKey: /*elided*/any;
452
+ durationMs: /*elided*/any;
453
+ digest: /*elided*/any;
454
+ }> & {
455
+ options: {};
456
+ } & {
457
+ catchall: <C extends SchemaType>(catchallSchema: C) => LoroMapSchemaWithCatchall<{
458
+ kind: /*elided*/any;
459
+ system: /*elided*/any;
460
+ key: /*elided*/any;
461
+ storageKey: /*elided*/any;
462
+ durationMs: /*elided*/any;
463
+ digest: /*elided*/any;
464
+ }, C>;
465
+ }> & {
466
+ options: {
467
+ readonly mergeableMapChildContainers: true;
468
+ };
469
+ };
470
+ 'audio-script-entities': LoroMapSchemaWithCatchall<{}, LoroMapSchema<{
471
+ body: /*elided*/any;
472
+ defaultLanguage: /*elided*/any;
473
+ }> & {
474
+ options: {};
475
+ } & {
476
+ catchall: <C extends SchemaType>(catchallSchema: C) => LoroMapSchemaWithCatchall<{
477
+ body: /*elided*/any;
478
+ defaultLanguage: /*elided*/any;
479
+ }, C>;
480
+ }> & {
481
+ options: {};
482
+ };
483
+ 'caption-entities': LoroMapSchemaWithCatchall<{}, LoroMapSchema<{
484
+ text: /*elided*/any;
485
+ style: /*elided*/any;
486
+ }> & {
487
+ options: {
488
+ readonly mergeableMapChildContainers: true;
489
+ };
490
+ } & {
491
+ catchall: <C extends SchemaType>(catchallSchema: C) => LoroMapSchemaWithCatchall<{
492
+ text: /*elided*/any;
493
+ style: /*elided*/any;
494
+ }, C>;
495
+ }> & {
496
+ options: {};
497
+ };
498
+ 'voice-entities': LoroMapSchemaWithCatchall<{}, LoroMapSchema<{
499
+ system: /*elided*/any;
500
+ key: /*elided*/any;
501
+ name: /*elided*/any;
502
+ }> & {
503
+ options: {};
504
+ } & {
505
+ catchall: <C extends SchemaType>(catchallSchema: C) => LoroMapSchemaWithCatchall<{
506
+ system: /*elided*/any;
507
+ key: /*elided*/any;
508
+ name: /*elided*/any;
509
+ }, C>;
510
+ }> & {
511
+ options: {
512
+ readonly mergeableMapChildContainers: true;
513
+ };
514
+ };
515
+ 'asset-entities': LoroMapSchemaWithCatchall<{}, LoroMapSchema<{
516
+ system: /*elided*/any;
517
+ key: /*elided*/any;
518
+ storageKey: /*elided*/any;
519
+ digest: /*elided*/any;
520
+ }> & {
521
+ options: {};
522
+ } & {
523
+ catchall: <C extends SchemaType>(catchallSchema: C) => LoroMapSchemaWithCatchall<{
524
+ system: /*elided*/any;
525
+ key: /*elided*/any;
526
+ storageKey: /*elided*/any;
527
+ digest: /*elided*/any;
528
+ }, C>;
529
+ }> & {
530
+ options: {
531
+ readonly mergeableMapChildContainers: true;
532
+ };
533
+ };
534
+ 'contain-relations': LoroTreeSchema<{
535
+ entityId: /*elided*/any;
536
+ }>;
537
+ 'clip-source-relations': LoroMapSchemaWithCatchall<{}, LoroMapSchema<Record<string, StringSchemaType<string> & {
538
+ options: {};
539
+ } & {
540
+ transform: <D>(def: TransformDefinition<string, D>) => StringSchemaType<string> & {
541
+ options: {};
542
+ transform: TransformDefinition<string, D>;
543
+ };
544
+ }>> & {
545
+ options: {};
546
+ } & {
547
+ catchall: <C extends SchemaType>(catchallSchema: C) => LoroMapSchemaWithCatchall<Record<string, StringSchemaType<string> & {
548
+ options: {};
549
+ } & {
550
+ transform: <D>(def: TransformDefinition<string, D>) => StringSchemaType<string> & {
551
+ options: {};
552
+ transform: TransformDefinition<string, D>;
553
+ };
554
+ }>, C>;
555
+ }> & {
556
+ options: {
557
+ readonly mergeableMapChildContainers: true;
558
+ };
559
+ };
560
+ 'time-anchor-relations': LoroMapSchemaWithCatchall<{}, StringSchemaType<string> & {
561
+ options: {};
562
+ transform: TransformDefinition<string, TimeAnchor | InvalidAtomic>;
563
+ }> & {
564
+ options: {};
565
+ };
566
+ 'caption-content-relations': LoroMapSchemaWithCatchall<{}, StringSchemaType<string> & {
567
+ options: {};
568
+ transform: TransformDefinition<string, CaptionContent | InvalidAtomic>;
569
+ }> & {
570
+ options: {};
571
+ };
572
+ 'caption-alignment-relations': LoroMapSchemaWithCatchall<{}, LoroMapSchema<{
573
+ captionId: /*elided*/any;
574
+ mediaId: /*elided*/any;
575
+ startMs: /*elided*/any;
576
+ endMs: /*elided*/any;
577
+ }> & {
578
+ options: {};
579
+ } & {
580
+ catchall: <C extends SchemaType>(catchallSchema: C) => LoroMapSchemaWithCatchall<{
581
+ captionId: /*elided*/any;
582
+ mediaId: /*elided*/any;
583
+ startMs: /*elided*/any;
584
+ endMs: /*elided*/any;
585
+ }, C>;
586
+ }> & {
587
+ options: {
588
+ readonly mergeableMapChildContainers: true;
589
+ };
590
+ };
591
+ 'voice-timbre-relations': LoroMapSchemaWithCatchall<{}, LoroMapSchema<Record<string, StringSchemaType<string> & {
592
+ options: {};
593
+ } & {
594
+ transform: <D>(def: TransformDefinition<string, D>) => StringSchemaType<string> & {
595
+ options: {};
596
+ transform: TransformDefinition<string, D>;
597
+ };
598
+ }>> & {
599
+ options: {};
600
+ } & {
601
+ catchall: <C extends SchemaType>(catchallSchema: C) => LoroMapSchemaWithCatchall<Record<string, StringSchemaType<string> & {
602
+ options: {};
603
+ } & {
604
+ transform: <D>(def: TransformDefinition<string, D>) => StringSchemaType<string> & {
605
+ options: {};
606
+ transform: TransformDefinition<string, D>;
607
+ };
608
+ }>, C>;
609
+ }> & {
610
+ options: {
611
+ readonly mergeableMapChildContainers: true;
612
+ };
613
+ };
614
+ 'derived-from-relations': LoroMapSchemaWithCatchall<{}, LoroMapSchema<Record<string, StringSchemaType<string> & {
615
+ options: {};
616
+ } & {
617
+ transform: <D>(def: TransformDefinition<string, D>) => StringSchemaType<string> & {
618
+ options: {};
619
+ transform: TransformDefinition<string, D>;
620
+ };
621
+ }>> & {
622
+ options: {};
623
+ } & {
624
+ catchall: <C extends SchemaType>(catchallSchema: C) => LoroMapSchemaWithCatchall<Record<string, StringSchemaType<string> & {
625
+ options: {};
626
+ } & {
627
+ transform: <D>(def: TransformDefinition<string, D>) => StringSchemaType<string> & {
628
+ options: {};
629
+ transform: TransformDefinition<string, D>;
630
+ };
631
+ }>, C>;
632
+ }> & {
633
+ options: {
634
+ readonly mergeableMapChildContainers: true;
635
+ };
636
+ };
637
+ 'from-asset-relations': LoroMapSchemaWithCatchall<{}, LoroMapSchema<Record<string, StringSchemaType<string> & {
638
+ options: {};
639
+ } & {
640
+ transform: <D>(def: TransformDefinition<string, D>) => StringSchemaType<string> & {
641
+ options: {};
642
+ transform: TransformDefinition<string, D>;
643
+ };
644
+ }>> & {
645
+ options: {};
646
+ } & {
647
+ catchall: <C extends SchemaType>(catchallSchema: C) => LoroMapSchemaWithCatchall<Record<string, StringSchemaType<string> & {
648
+ options: {};
649
+ } & {
650
+ transform: <D>(def: TransformDefinition<string, D>) => StringSchemaType<string> & {
651
+ options: {};
652
+ transform: TransformDefinition<string, D>;
653
+ };
654
+ }>, C>;
655
+ }> & {
656
+ options: {
657
+ readonly mergeableMapChildContainers: true;
658
+ };
659
+ };
660
+ 'to-asset-relations': LoroMapSchemaWithCatchall<{}, LoroMapSchema<Record<string, StringSchemaType<string> & {
661
+ options: {};
662
+ } & {
663
+ transform: <D>(def: TransformDefinition<string, D>) => StringSchemaType<string> & {
664
+ options: {};
665
+ transform: TransformDefinition<string, D>;
666
+ };
667
+ }>> & {
668
+ options: {};
669
+ } & {
670
+ catchall: <C extends SchemaType>(catchallSchema: C) => LoroMapSchemaWithCatchall<Record<string, StringSchemaType<string> & {
671
+ options: {};
672
+ } & {
673
+ transform: <D>(def: TransformDefinition<string, D>) => StringSchemaType<string> & {
674
+ options: {};
675
+ transform: TransformDefinition<string, D>;
676
+ };
677
+ }>, C>;
678
+ }> & {
679
+ options: {
680
+ readonly mergeableMapChildContainers: true;
681
+ };
682
+ };
683
+ }> & {
684
+ options: {};
685
+ };
686
+ type MedeoDslLoroState = InferType<typeof medeoDslLoroShape>;
687
+ /** Writable view: new containers do not yet have a $cid or TreeID. */
688
+ type Input = InferInputType<typeof medeoDslLoroShape>;
689
+ type ContainDraftNode = Omit<Input['contain-relations'][number], 'id' | 'children'> & {
690
+ readonly id?: string;
691
+ children: ContainDraftNode[];
692
+ };
693
+ type DraftFields<T> = T extends Cursor ? T : T extends (infer Item)[] ? DraftFields<Item>[] : T extends object ? { [K in keyof T as undefined extends T[K] ? never : K]: DraftFields<T[K]> } & { [K in keyof T as undefined extends T[K] ? K : never]?: DraftFields<T[K]> } : T;
694
+ type MedeoDslDraft = DraftFields<Omit<Input, 'contain-relations'>> & {
695
+ 'contain-relations': ContainDraftNode[];
696
+ };
697
+ //#endregion
698
+ //#region ../medeo-dsl/src/schema/document-format.d.ts
699
+ /** Format discrimination does not register containers or alter the document. */
700
+ declare function documentFormat(doc: LoroDoc): 'dsl' | 'legacy' | 'mixed' | 'unknown';
701
+ declare class UnsupportedDocumentFormatError extends Error {
702
+ readonly code = "unsupported_document_format";
703
+ constructor();
704
+ }
705
+ /** Run after initial import, before opening an editable handle. Empty new documents still have one Timeline. */
706
+ declare function assertDslDocument(doc: LoroDoc): void;
707
+ //#endregion
708
+ //#region src/dsl/document/types.d.ts
709
+ /** Serialized once at the transaction exit, using the existing server audit envelope. */
710
+ interface DslAudit {
711
+ semantic_op: string;
712
+ payload: unknown;
713
+ intent?: unknown;
714
+ actor?: {
715
+ user_id: string;
716
+ role: 'user' | 'agent';
717
+ } | null;
718
+ }
719
+ /** Synchronous, scoped draft. Never retain this context or any draft object after the callback. */
720
+ interface DslTransaction {
721
+ readonly draft: MedeoDslDraft;
722
+ applyMutations(mutations: readonly DslMutation[]): void;
723
+ /** Offsets use the preview after preceding edits. Existing Text identities are checked when supplied. */
724
+ editText(audioScriptId: string, edits: readonly TextEdit[], expectedBodyId?: string): void;
725
+ /** Creates real Cursors during application; pending ranges are not exposed as draft Cursor objects. */
726
+ editCaptionText(captionId: string, edits: readonly TextEdit[], expectedBodyId?: string): void;
727
+ setCaptionContent(selection: CaptionSelection): void;
728
+ }
729
+ //#endregion
730
+ //#region src/dsl/document/medeo-dsl.d.ts
731
+ interface CreateMedeoDslOptions {
732
+ timelineId?: string;
733
+ peerId?: PeerID;
734
+ idFactory?: DslIdFactory;
735
+ }
736
+ /** One live DSL document. Business Actions belong to medeo-client, not this storage interface. */
737
+ declare class MedeoDsl {
738
+ readonly doc: LoroDoc;
739
+ private readonly options;
740
+ private disposed;
741
+ private writing;
742
+ private rejectTransaction?;
743
+ private listeners;
744
+ private changeSource;
745
+ private snapshot?;
746
+ private dirty;
747
+ private notifying;
748
+ private readonly mirror;
749
+ private readonly unsubscribe;
750
+ private ownsDoc;
751
+ /** Opens a borrowed LoroDoc; dispose releases subscriptions but does not free the caller's doc. */
752
+ constructor(doc: LoroDoc, options?: {
753
+ mutationGuard?: {
754
+ run<T>(mutation: () => T): T;
755
+ };
756
+ });
757
+ /** Creates and owns a fresh document; this handle frees it on dispose. */
758
+ static create(options?: CreateMedeoDslOptions): MedeoDsl;
759
+ getSnapshot(): MedeoDslSnapshot;
760
+ subscribe(listener: (source: 'local' | 'remote') => void): () => void;
761
+ /** One synchronous, audited edit. Preparation errors discard the whole draft before native writes. */
762
+ transact(edit: (tx: DslTransaction) => void, audit: DslAudit): void;
763
+ /** Preferred vocabulary for ordinary entity/relation/Tree edits and serializable native commands. */
764
+ applyMutations(mutations: readonly DslMutation[], audit: DslAudit): void;
765
+ editText(scriptId: string, expectedBodyId: string, edits: readonly TextEdit[], audit: DslAudit): void;
766
+ editCaptionText(captionId: string, expectedBodyId: string, edits: readonly TextEdit[], audit: DslAudit): void;
767
+ /** Local ranges exclude insertions at their start and include insertions at their end. K01 remains deferred. */
768
+ textRange(scriptId: string, start: number, end: number): Omit<CaptionContent, 'captionId'>;
769
+ dispose(): void;
770
+ private mutate;
771
+ private notify;
772
+ private assertActive;
773
+ }
774
+ //#endregion
775
+ //#region src/dsl/voiceover-actions.d.ts
776
+ interface VoiceoverCaptionInput {
777
+ clipId?: string;
778
+ startMs: number;
779
+ durationMs: number;
780
+ /** UTF-16 selection in the supplied AudioScript; timing remains a separate fact. */
781
+ range: {
782
+ start: number;
783
+ end: number;
784
+ };
785
+ style?: CaptionStyle;
786
+ }
787
+ interface ApplyVoiceoverInput {
788
+ clipId?: string;
789
+ trackId: string;
790
+ captionTrackId?: string;
791
+ media: Extract<Media, {
792
+ kind: 'audio' | 'voiceover-recording';
793
+ }> & {
794
+ kind: 'voiceover-recording';
795
+ };
796
+ script: {
797
+ audioScriptId: string;
798
+ body?: never;
799
+ } | {
800
+ body: string;
801
+ audioScriptId?: never;
802
+ defaultLanguage?: string;
803
+ };
804
+ placement: ClipPlacement;
805
+ volume?: number;
806
+ voice?: Voice;
807
+ /** Complete generated caption set for this use. Other uses of the recording are untouched. */
808
+ captions: readonly VoiceoverCaptionInput[];
809
+ }
810
+ interface VoiceoverResult {
811
+ clipId: string;
812
+ mediaId: string;
813
+ audioScriptId: string;
814
+ captionClipIds: string[];
815
+ captionIds: string[];
816
+ }
817
+ //#endregion
818
+ //#region src/dsl/dsl-editor.d.ts
819
+ /** Business edits write DSL facts in one audited transaction; layout is derived on read. */
820
+ declare class DslEditor {
821
+ readonly dsl: MedeoDsl;
822
+ private readonly idFactory;
823
+ constructor(dsl: MedeoDsl, idFactory?: DslIdFactory);
824
+ createTrack(role: TrackRole, options?: CommitOptions): string;
825
+ registerMedia(media: Media, options?: CommitOptions): string;
826
+ addClips(input: AddDslClipsInput, options?: CommitOptions): string[];
827
+ /** index is measured in the target's children after removing the moved Clip. */
828
+ moveClip(clipId: string, trackId: string, index?: number, options?: CommitOptions): void;
829
+ trimClip(clipId: string, window: {
830
+ inMs?: number;
831
+ outMs?: number;
832
+ }, options?: CommitOptions): void;
833
+ setClipSpeed(clipId: string, speed: {
834
+ rate: number;
835
+ } | undefined, options?: CommitOptions): void;
836
+ setClipVolume(clipId: string, volume: number | undefined, options?: CommitOptions): void;
837
+ createAudioScript(body: string, defaultLanguage?: string, options?: CommitOptions): string;
838
+ editAudioScript(scriptId: string, expectedBodyId: string, edits: readonly TextEdit[], options?: CommitOptions): void;
839
+ createCaption(input: ({
840
+ audioScriptId: string;
841
+ start: number;
842
+ end: number;
843
+ text?: never;
844
+ } | {
845
+ text: string;
846
+ audioScriptId?: never;
847
+ start?: never;
848
+ end?: never;
849
+ }) & {
850
+ style?: CaptionStyle;
851
+ }, options?: CommitOptions): string;
852
+ setCaptionContent(captionId: string, audioScriptId: string, start: number, end: number, options?: CommitOptions): void;
853
+ setCaptionText(captionId: string, text: string, options?: CommitOptions): void;
854
+ editCaptionText(captionId: string, expectedBodyId: string, edits: readonly TextEdit[], options?: CommitOptions): void;
855
+ moveTrack(trackId: string, index: number, options?: CommitOptions): void;
856
+ setTrackHidden(trackId: string, hidden: boolean | undefined, options?: CommitOptions): void;
857
+ deleteTrack(trackId: string, onAnchored: 'cascade' | 'detach', options?: CommitOptions): void;
858
+ setClipPlacement(clipId: string, placement: ClipPlacement, options?: CommitOptions): void;
859
+ moveClips(input: MoveDslClipsInput, options?: CommitOptions): void;
860
+ deleteClips(clipIds: readonly string[], onAnchored: 'cascade' | 'detach', options?: CommitOptions): void;
861
+ replaceClipSource(clipId: string, input: ClipSource & {
862
+ inMs: number;
863
+ outMs: number;
864
+ }, options?: CommitOptions): void;
865
+ replaceClips(input: ReplaceDslClipsInput, options?: CommitOptions): string[];
866
+ updateClips(updates: readonly DslClipUpdate[], options?: CommitOptions): void;
867
+ patchCaptionStyle(captionIds: readonly string[], patch: FieldPatch<CaptionStyle>, options?: CommitOptions): void;
868
+ applyVoiceover(input: ApplyVoiceoverInput, options?: CommitOptions): VoiceoverResult;
869
+ setBgm(input: ClipSource & {
870
+ trackId: string;
871
+ clipId?: string;
872
+ volume?: number;
873
+ }, options?: CommitOptions): string;
874
+ private write;
875
+ }
876
+ //#endregion
877
+ //#region src/dsl/initial-document.d.ts
878
+ /** One server/host creates the foundation; peers import its binary identity instead of initializing independently. */
879
+ declare function createInitialMedeoDsl(options?: CreateMedeoDslOptions): MedeoDsl;
880
+ //#endregion
881
+ //#region src/dsl/projection/types.d.ts
882
+ interface DslClipLayout {
883
+ clipId: string;
884
+ trackId: string;
885
+ sourceId?: string;
886
+ inMs: number;
887
+ outMs: number;
888
+ rate: number;
889
+ volume: number;
890
+ startMs: number;
891
+ durationMs: number;
892
+ mode: 'sequential' | 'absolute' | 'anchored' | 'fallback';
893
+ anchorClipId?: string;
894
+ fillTimeline: boolean;
895
+ }
896
+ interface DslTrackLayout {
897
+ trackId: string;
898
+ role: TrackRole;
899
+ hidden: boolean;
900
+ clips: DslClipLayout[];
901
+ }
902
+ interface DslLayout {
903
+ timelineId: string;
904
+ tracks: DslTrackLayout[];
905
+ clips: Record<string, DslClipLayout>;
906
+ durationMs: number;
907
+ diagnostics: DslDiagnostic[];
908
+ }
909
+ /** Unsupported legacy representations fail explicitly; recoverable CRDT state is returned as diagnostics. */
910
+ declare class DslProjectionError extends Error {
911
+ readonly issues: readonly DslDiagnostic[];
912
+ constructor(issues: readonly DslDiagnostic[]);
913
+ }
914
+ //#endregion
915
+ //#region src/dsl/projection/layout.d.ts
916
+ /** Pure deterministic solve. Constraints only move sequential roots; anchors retain their exact offsets. */
917
+ declare function resolveDslLayout(snapshot: MedeoDslSnapshot): DslLayout;
918
+ //#endregion
919
+ //#region src/dsl/projection/to-video-draft.d.ts
920
+ interface VideoDraftProjection {
921
+ content: VideoDraftContent;
922
+ diagnostics: DslDiagnostic[];
923
+ }
924
+ /** A content read view, not an archive of authoring identities, rich-text marks or provenance. */
925
+ declare function toVideoDraft(snapshot: MedeoDslSnapshot): VideoDraftProjection;
926
+ //#endregion
927
+ //#region src/dsl/projection/from-video-draft.d.ts
928
+ interface FromVideoDraftOptions extends CreateMedeoDslOptions {
929
+ /** Complete physical media facts, keyed by their external system/key; no IO runs in the converter. */
930
+ mediaFacts?: readonly Media[];
931
+ audit: DslAudit;
932
+ }
933
+ interface ImportedVideoDraft {
934
+ dsl: MedeoDsl;
935
+ diagnostics: DslDiagnostic[];
936
+ }
937
+ /** One-time import into a newly owned document; never reverse-diff a live collaborative document. */
938
+ declare function fromVideoDraft(input: VideoDraftInput, options: FromVideoDraftOptions): ImportedVideoDraft;
939
+ //#endregion
940
+ export { AddDslClip as A, MedeoDslDraft as C, captionContentCodec as D, InvalidAtomic as E, ReplaceDslClipsInput as F, ClipPlacement as I, ClipSource as M, DslClipUpdate as N, isInvalidAtomic as O, MoveDslClipsInput as P, documentFormat as S, medeoDslLoroShape as T, MedeoDsl as _, toVideoDraft as a, UnsupportedDocumentFormatError as b, DslLayout as c, createInitialMedeoDsl as d, DslEditor as f, CreateMedeoDslOptions as g, VoiceoverResult as h, VideoDraftProjection as i, AddDslClipsInput as j, timeAnchorCodec as k, DslProjectionError as l, VoiceoverCaptionInput as m, ImportedVideoDraft as n, resolveDslLayout as o, ApplyVoiceoverInput as p, fromVideoDraft as r, DslClipLayout as s, FromVideoDraftOptions as t, DslTrackLayout as u, DslAudit as v, MedeoDslLoroState as w, assertDslDocument as x, DslTransaction as y };