@webpacked-timeline/core 1.0.0-beta.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.
- package/CHANGELOG.md +36 -0
- package/LICENSE +21 -0
- package/README.md +162 -0
- package/dist/chunk-27XCNVPR.js +5969 -0
- package/dist/chunk-6PDBJDHM.js +2263 -0
- package/dist/chunk-BWPS6NQT.js +7465 -0
- package/dist/chunk-FBOYSUYV.js +1280 -0
- package/dist/chunk-FR632TZX.js +1870 -0
- package/dist/chunk-HW4Z7YLJ.js +1242 -0
- package/dist/chunk-HWW62IFH.js +5424 -0
- package/dist/chunk-I2GZXRH4.js +4790 -0
- package/dist/chunk-JQZE3OK4.js +1255 -0
- package/dist/chunk-KF7JNK2F.js +1864 -0
- package/dist/chunk-KR3P2DYK.js +5655 -0
- package/dist/chunk-MO5DSFSW.js +2214 -0
- package/dist/chunk-MQAW33RJ.js +5530 -0
- package/dist/chunk-N4WUWZZX.js +2833 -0
- package/dist/chunk-NRJV7I4C.js +1331 -0
- package/dist/chunk-NXG52532.js +2230 -0
- package/dist/chunk-PVXF67CN.js +1278 -0
- package/dist/chunk-QSB6DHIF.js +5429 -0
- package/dist/chunk-QYWJT7HR.js +5837 -0
- package/dist/chunk-SWBRCMW7.js +7466 -0
- package/dist/chunk-TAT3ULSV.js +2214 -0
- package/dist/chunk-TTDP5JUM.js +2228 -0
- package/dist/chunk-UAGP4VPG.js +1739 -0
- package/dist/chunk-WIG6SY7A.js +1183 -0
- package/dist/chunk-YJ2K5N2R.js +6187 -0
- package/dist/index-3Lr_vKBd.d.cts +2810 -0
- package/dist/index-3Lr_vKBd.d.ts +2810 -0
- package/dist/index-7IPJn1yM.d.cts +1146 -0
- package/dist/index-7IPJn1yM.d.ts +1146 -0
- package/dist/index-B0xOv0V0.d.cts +3259 -0
- package/dist/index-B0xOv0V0.d.ts +3259 -0
- package/dist/index-B2m3zwg7.d.cts +1381 -0
- package/dist/index-B2m3zwg7.d.ts +1381 -0
- package/dist/index-B3sUrU_X.d.cts +1249 -0
- package/dist/index-B3sUrU_X.d.ts +1249 -0
- package/dist/index-B6wla7ZJ.d.cts +2751 -0
- package/dist/index-B6wla7ZJ.d.ts +2751 -0
- package/dist/index-BIv8RWWT.d.cts +1574 -0
- package/dist/index-BIv8RWWT.d.ts +1574 -0
- package/dist/index-BJv6hDHL.d.cts +3255 -0
- package/dist/index-BJv6hDHL.d.ts +3255 -0
- package/dist/index-BUCimS2e.d.cts +1393 -0
- package/dist/index-BUCimS2e.d.ts +1393 -0
- package/dist/index-Bw_nvNcG.d.cts +1275 -0
- package/dist/index-Bw_nvNcG.d.ts +1275 -0
- package/dist/index-ByG0gOtd.d.cts +1167 -0
- package/dist/index-ByG0gOtd.d.ts +1167 -0
- package/dist/index-CDGd2XXv.d.cts +2492 -0
- package/dist/index-CDGd2XXv.d.ts +2492 -0
- package/dist/index-CznAVeJ6.d.cts +1145 -0
- package/dist/index-CznAVeJ6.d.ts +1145 -0
- package/dist/index-DQD9IMh7.d.cts +2534 -0
- package/dist/index-DQD9IMh7.d.ts +2534 -0
- package/dist/index-Dl3qtJEI.d.cts +2178 -0
- package/dist/index-Dl3qtJEI.d.ts +2178 -0
- package/dist/index-DnE2A-Nz.d.cts +2603 -0
- package/dist/index-DnE2A-Nz.d.ts +2603 -0
- package/dist/index-DrOA6QmW.d.cts +2492 -0
- package/dist/index-DrOA6QmW.d.ts +2492 -0
- package/dist/index-Vpa3rPEM.d.cts +1402 -0
- package/dist/index-Vpa3rPEM.d.ts +1402 -0
- package/dist/index-jP6BomSd.d.cts +2640 -0
- package/dist/index-jP6BomSd.d.ts +2640 -0
- package/dist/index-wiGRwVyY.d.cts +3259 -0
- package/dist/index-wiGRwVyY.d.ts +3259 -0
- package/dist/index.cjs +7386 -0
- package/dist/index.d.cts +1 -0
- package/dist/index.d.ts +1 -0
- package/dist/index.js +263 -0
- package/dist/internal.cjs +7721 -0
- package/dist/internal.d.cts +704 -0
- package/dist/internal.d.ts +704 -0
- package/dist/internal.js +405 -0
- package/package.json +58 -0
|
@@ -0,0 +1,2492 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* FRAME-BASED TIME REPRESENTATION
|
|
3
|
+
*
|
|
4
|
+
* Phase 0 compliant. All time values in state are TimelineFrame branded integers.
|
|
5
|
+
* FrameRate is a discriminated literal union — never a raw float.
|
|
6
|
+
*
|
|
7
|
+
* THREE INVIOLABLE RULES:
|
|
8
|
+
* 1. Core has ZERO UI framework imports.
|
|
9
|
+
* 2. Every function that changes state returns a NEW object.
|
|
10
|
+
* 3. Every frame value is a branded TimelineFrame integer — never a raw number.
|
|
11
|
+
*/
|
|
12
|
+
/**
|
|
13
|
+
* TimelineFrame — A discrete, non-negative integer point in time measured in frames.
|
|
14
|
+
*
|
|
15
|
+
* Branded so TypeScript prevents raw numbers from sneaking into frame positions.
|
|
16
|
+
* The ONLY way to create one is via toFrame().
|
|
17
|
+
*/
|
|
18
|
+
type TimelineFrame = number & {
|
|
19
|
+
readonly __brand: "TimelineFrame";
|
|
20
|
+
};
|
|
21
|
+
/** The canonical factory. Use this everywhere instead of casting. */
|
|
22
|
+
declare const toFrame: (n: number) => TimelineFrame;
|
|
23
|
+
/**
|
|
24
|
+
* Legacy alias kept for backward-compat during transition.
|
|
25
|
+
* Prefer toFrame() for new code.
|
|
26
|
+
*/
|
|
27
|
+
declare function frame(value: number): TimelineFrame;
|
|
28
|
+
/**
|
|
29
|
+
* FrameRate — The exact set of supported frame rates.
|
|
30
|
+
*
|
|
31
|
+
* RULE: Never pass 29.97 as a plain number. Use the literal type.
|
|
32
|
+
* This is a discriminated union — TypeScript enforces membership at compile time.
|
|
33
|
+
*/
|
|
34
|
+
type FrameRate = 23.976 | 24 | 25 | 29.97 | 30 | 50 | 59.94 | 60;
|
|
35
|
+
/**
|
|
36
|
+
* Named constants for the most common rates.
|
|
37
|
+
* Prefer these over raw literals where possible.
|
|
38
|
+
*/
|
|
39
|
+
declare const FrameRates: {
|
|
40
|
+
readonly CINEMA: FrameRate;
|
|
41
|
+
readonly PAL: FrameRate;
|
|
42
|
+
readonly NTSC_DF: FrameRate;
|
|
43
|
+
readonly NTSC: FrameRate;
|
|
44
|
+
readonly PAL_HFR: FrameRate;
|
|
45
|
+
readonly NTSC_HFR: FrameRate;
|
|
46
|
+
readonly HFR: FrameRate;
|
|
47
|
+
};
|
|
48
|
+
/**
|
|
49
|
+
* Legacy factory — kept for backward-compat with existing tests.
|
|
50
|
+
* This now validates that the value is a member of the FrameRate union.
|
|
51
|
+
* @throws if the value is not a recognised frame rate.
|
|
52
|
+
*/
|
|
53
|
+
declare function frameRate(value: number): FrameRate;
|
|
54
|
+
/**
|
|
55
|
+
* RationalTime — a frame count at a specific rate. Used only at
|
|
56
|
+
* ingest/export boundaries. Never stored in TimelineState.
|
|
57
|
+
*/
|
|
58
|
+
type RationalTime = {
|
|
59
|
+
readonly value: number;
|
|
60
|
+
readonly rate: FrameRate;
|
|
61
|
+
};
|
|
62
|
+
/**
|
|
63
|
+
* Timecode — SMPTE timecode string, display-only. Never use for arithmetic.
|
|
64
|
+
*/
|
|
65
|
+
type Timecode = string & {
|
|
66
|
+
readonly __brand: "Timecode";
|
|
67
|
+
};
|
|
68
|
+
declare const toTimecode: (s: string) => Timecode;
|
|
69
|
+
/**
|
|
70
|
+
* TimeRange — a start + duration pair, both in TimelineFrame units.
|
|
71
|
+
*/
|
|
72
|
+
type TimeRange = {
|
|
73
|
+
readonly startFrame: TimelineFrame;
|
|
74
|
+
readonly duration: TimelineFrame;
|
|
75
|
+
};
|
|
76
|
+
declare function isValidFrame(value: number): boolean;
|
|
77
|
+
declare function isDropFrame(fps: FrameRate): boolean;
|
|
78
|
+
|
|
79
|
+
/**
|
|
80
|
+
* GENERATOR MODEL — Phase 3
|
|
81
|
+
*
|
|
82
|
+
* Generators are synthetic "assets" (solid, bars, countdown, etc.)
|
|
83
|
+
* registered in AssetRegistry as GeneratorAsset. No filePath.
|
|
84
|
+
*/
|
|
85
|
+
|
|
86
|
+
type GeneratorId = string & {
|
|
87
|
+
readonly __brand: 'GeneratorId';
|
|
88
|
+
};
|
|
89
|
+
type GeneratorType = 'solid' | 'bars' | 'countdown' | 'noise' | 'text';
|
|
90
|
+
type Generator = {
|
|
91
|
+
readonly id: GeneratorId;
|
|
92
|
+
readonly type: GeneratorType;
|
|
93
|
+
readonly params: Record<string, unknown>;
|
|
94
|
+
readonly duration: TimelineFrame;
|
|
95
|
+
readonly name: string;
|
|
96
|
+
};
|
|
97
|
+
|
|
98
|
+
/**
|
|
99
|
+
* ASSET MODEL — Phase 0 + Phase 3
|
|
100
|
+
*
|
|
101
|
+
* Asset is FileAsset | GeneratorAsset. Multiple Clips can reference the same Asset.
|
|
102
|
+
* Assets never change their intrinsicDuration after registration.
|
|
103
|
+
*/
|
|
104
|
+
|
|
105
|
+
type AssetId = string & {
|
|
106
|
+
readonly __brand: 'AssetId';
|
|
107
|
+
};
|
|
108
|
+
declare const toAssetId: (s: string) => AssetId;
|
|
109
|
+
type AssetStatus = 'online' | 'offline' | 'proxy-only' | 'missing';
|
|
110
|
+
type FileAsset = {
|
|
111
|
+
readonly kind: 'file';
|
|
112
|
+
readonly id: AssetId;
|
|
113
|
+
readonly name: string;
|
|
114
|
+
readonly mediaType: TrackType;
|
|
115
|
+
readonly filePath: string;
|
|
116
|
+
readonly intrinsicDuration: TimelineFrame;
|
|
117
|
+
readonly nativeFps: FrameRate;
|
|
118
|
+
readonly sourceTimecodeOffset: TimelineFrame;
|
|
119
|
+
readonly status: AssetStatus;
|
|
120
|
+
};
|
|
121
|
+
type GeneratorAsset = {
|
|
122
|
+
readonly kind: 'generator';
|
|
123
|
+
readonly id: AssetId;
|
|
124
|
+
readonly name: string;
|
|
125
|
+
readonly mediaType: TrackType;
|
|
126
|
+
readonly intrinsicDuration: TimelineFrame;
|
|
127
|
+
readonly nativeFps: FrameRate;
|
|
128
|
+
readonly sourceTimecodeOffset: TimelineFrame;
|
|
129
|
+
readonly status: AssetStatus;
|
|
130
|
+
readonly generatorDef: Generator;
|
|
131
|
+
};
|
|
132
|
+
type Asset = FileAsset | GeneratorAsset;
|
|
133
|
+
declare function createAsset(params: {
|
|
134
|
+
id: string;
|
|
135
|
+
name: string;
|
|
136
|
+
mediaType: TrackType;
|
|
137
|
+
filePath: string;
|
|
138
|
+
intrinsicDuration: TimelineFrame;
|
|
139
|
+
nativeFps: FrameRate;
|
|
140
|
+
sourceTimecodeOffset: TimelineFrame;
|
|
141
|
+
status?: AssetStatus;
|
|
142
|
+
}): FileAsset;
|
|
143
|
+
|
|
144
|
+
/**
|
|
145
|
+
* EASING CURVES — Phase 4
|
|
146
|
+
*
|
|
147
|
+
* Discriminated union for keyframe/interpolation easing.
|
|
148
|
+
*/
|
|
149
|
+
type EasingCurve = {
|
|
150
|
+
readonly kind: 'Linear';
|
|
151
|
+
} | {
|
|
152
|
+
readonly kind: 'Hold';
|
|
153
|
+
} | {
|
|
154
|
+
readonly kind: 'EaseIn';
|
|
155
|
+
readonly power: number;
|
|
156
|
+
} | {
|
|
157
|
+
readonly kind: 'EaseOut';
|
|
158
|
+
readonly power: number;
|
|
159
|
+
} | {
|
|
160
|
+
readonly kind: 'EaseBoth';
|
|
161
|
+
readonly power: number;
|
|
162
|
+
} | {
|
|
163
|
+
readonly kind: 'BezierCurve';
|
|
164
|
+
readonly p1x: number;
|
|
165
|
+
readonly p1y: number;
|
|
166
|
+
readonly p2x: number;
|
|
167
|
+
readonly p2y: number;
|
|
168
|
+
};
|
|
169
|
+
declare const LINEAR_EASING: EasingCurve;
|
|
170
|
+
declare const HOLD_EASING: EasingCurve;
|
|
171
|
+
|
|
172
|
+
/**
|
|
173
|
+
* KEYFRAME MODEL — Phase 4
|
|
174
|
+
*
|
|
175
|
+
* Single keyframe for animatable values (effect params, transform, audio).
|
|
176
|
+
*/
|
|
177
|
+
|
|
178
|
+
type KeyframeId = string & {
|
|
179
|
+
readonly __brand: 'KeyframeId';
|
|
180
|
+
};
|
|
181
|
+
declare function toKeyframeId(s: string): KeyframeId;
|
|
182
|
+
/** Value is a plain number (opacity, scale, rotation, gain, etc.). */
|
|
183
|
+
type Keyframe = {
|
|
184
|
+
readonly id: KeyframeId;
|
|
185
|
+
readonly frame: TimelineFrame;
|
|
186
|
+
readonly value: number;
|
|
187
|
+
/** Easing out of this keyframe. */
|
|
188
|
+
readonly easing: EasingCurve;
|
|
189
|
+
};
|
|
190
|
+
|
|
191
|
+
/**
|
|
192
|
+
* EFFECT MODEL — Phase 4
|
|
193
|
+
*
|
|
194
|
+
* Effect applied to a clip (blur, LUT, color correct, host-defined).
|
|
195
|
+
*/
|
|
196
|
+
|
|
197
|
+
type EffectId = string & {
|
|
198
|
+
readonly __brand: 'EffectId';
|
|
199
|
+
};
|
|
200
|
+
declare function toEffectId(s: string): EffectId;
|
|
201
|
+
/** Open string: 'blur', 'lut', 'colorCorrect', host-defined. */
|
|
202
|
+
type EffectType = string;
|
|
203
|
+
type RenderStage = 'preComposite' | 'postComposite' | 'output';
|
|
204
|
+
type EffectParam = {
|
|
205
|
+
readonly key: string;
|
|
206
|
+
readonly value: number | string | boolean;
|
|
207
|
+
};
|
|
208
|
+
type Effect = {
|
|
209
|
+
readonly id: EffectId;
|
|
210
|
+
readonly effectType: EffectType;
|
|
211
|
+
readonly enabled: boolean;
|
|
212
|
+
readonly renderStage: RenderStage;
|
|
213
|
+
readonly params: readonly EffectParam[];
|
|
214
|
+
readonly keyframes: readonly Keyframe[];
|
|
215
|
+
};
|
|
216
|
+
declare function createEffect(id: EffectId, effectType: EffectType, renderStage?: RenderStage, params?: readonly EffectParam[]): Effect;
|
|
217
|
+
|
|
218
|
+
/**
|
|
219
|
+
* CLIP TRANSFORM — Phase 4
|
|
220
|
+
*
|
|
221
|
+
* Animatable position, scale, rotation, opacity, anchor.
|
|
222
|
+
* Each property: base value + optional keyframes.
|
|
223
|
+
*/
|
|
224
|
+
|
|
225
|
+
type AnimatableProperty = {
|
|
226
|
+
readonly value: number;
|
|
227
|
+
readonly keyframes: readonly Keyframe[];
|
|
228
|
+
};
|
|
229
|
+
declare function createAnimatableProperty(value: number): AnimatableProperty;
|
|
230
|
+
type ClipTransform = {
|
|
231
|
+
readonly positionX: AnimatableProperty;
|
|
232
|
+
readonly positionY: AnimatableProperty;
|
|
233
|
+
readonly scaleX: AnimatableProperty;
|
|
234
|
+
readonly scaleY: AnimatableProperty;
|
|
235
|
+
readonly rotation: AnimatableProperty;
|
|
236
|
+
readonly opacity: AnimatableProperty;
|
|
237
|
+
readonly anchorX: AnimatableProperty;
|
|
238
|
+
readonly anchorY: AnimatableProperty;
|
|
239
|
+
};
|
|
240
|
+
declare const DEFAULT_CLIP_TRANSFORM: ClipTransform;
|
|
241
|
+
|
|
242
|
+
/**
|
|
243
|
+
* AUDIO PROPERTIES — Phase 4
|
|
244
|
+
*
|
|
245
|
+
* Per-clip audio: gain, pan, mute, channel routing.
|
|
246
|
+
*/
|
|
247
|
+
|
|
248
|
+
type ChannelRouting = 'stereo' | 'mono' | 'left' | 'right';
|
|
249
|
+
type AudioProperties = {
|
|
250
|
+
readonly gain: AnimatableProperty;
|
|
251
|
+
readonly pan: AnimatableProperty;
|
|
252
|
+
readonly mute: boolean;
|
|
253
|
+
readonly channelRouting: ChannelRouting;
|
|
254
|
+
readonly normalizationGain: number;
|
|
255
|
+
};
|
|
256
|
+
declare const DEFAULT_AUDIO_PROPERTIES: AudioProperties;
|
|
257
|
+
|
|
258
|
+
/**
|
|
259
|
+
* TRANSITION MODEL — Phase 4
|
|
260
|
+
*
|
|
261
|
+
* Outgoing transition between clips (dissolve, wipe, etc.).
|
|
262
|
+
*/
|
|
263
|
+
|
|
264
|
+
type TransitionId = string & {
|
|
265
|
+
readonly __brand: 'TransitionId';
|
|
266
|
+
};
|
|
267
|
+
declare function toTransitionId(s: string): TransitionId;
|
|
268
|
+
/** 'dissolve' | 'wipe' | 'dip' | host-defined. */
|
|
269
|
+
type TransitionType = string;
|
|
270
|
+
type TransitionAlignment = 'centerOnCut' | 'endAtCut' | 'startAtCut';
|
|
271
|
+
type TransitionParam = {
|
|
272
|
+
readonly key: string;
|
|
273
|
+
readonly value: number | string | boolean;
|
|
274
|
+
};
|
|
275
|
+
type Transition = {
|
|
276
|
+
readonly id: TransitionId;
|
|
277
|
+
readonly type: TransitionType;
|
|
278
|
+
readonly durationFrames: number;
|
|
279
|
+
readonly alignment: TransitionAlignment;
|
|
280
|
+
readonly easing: EasingCurve;
|
|
281
|
+
readonly params: readonly TransitionParam[];
|
|
282
|
+
};
|
|
283
|
+
declare function createTransition(id: TransitionId, type: TransitionType, durationFrames: number, alignment?: TransitionAlignment, easing?: EasingCurve, params?: readonly TransitionParam[]): Transition;
|
|
284
|
+
|
|
285
|
+
/**
|
|
286
|
+
* CLIP MODEL — Phase 0 compliant
|
|
287
|
+
*
|
|
288
|
+
* A Clip is a time-bound reference to an Asset placed on a Track.
|
|
289
|
+
* All fields are readonly. Never mutate — always return a new object.
|
|
290
|
+
*/
|
|
291
|
+
|
|
292
|
+
type ClipId = string & {
|
|
293
|
+
readonly __brand: 'ClipId';
|
|
294
|
+
};
|
|
295
|
+
declare const toClipId: (s: string) => ClipId;
|
|
296
|
+
/**
|
|
297
|
+
* Clip — a time-bound viewport into an Asset on a Track.
|
|
298
|
+
*
|
|
299
|
+
* TIMELINE BOUNDS: timelineStart / timelineEnd — where it sits on the track.
|
|
300
|
+
* MEDIA BOUNDS: mediaIn / mediaOut — which portion of the asset plays.
|
|
301
|
+
*
|
|
302
|
+
* INVARIANTS (Phase 0, speed=1.0):
|
|
303
|
+
* timelineEnd > timelineStart
|
|
304
|
+
* mediaOut > mediaIn
|
|
305
|
+
* (mediaOut - mediaIn) === (timelineEnd - timelineStart)
|
|
306
|
+
* mediaIn >= 0
|
|
307
|
+
* mediaOut <= asset.intrinsicDuration
|
|
308
|
+
* timelineEnd <= timeline.duration
|
|
309
|
+
* speed > 0
|
|
310
|
+
*/
|
|
311
|
+
type Clip = {
|
|
312
|
+
readonly id: ClipId;
|
|
313
|
+
readonly assetId: AssetId;
|
|
314
|
+
readonly trackId: TrackId;
|
|
315
|
+
readonly timelineStart: TimelineFrame;
|
|
316
|
+
readonly timelineEnd: TimelineFrame;
|
|
317
|
+
readonly mediaIn: TimelineFrame;
|
|
318
|
+
readonly mediaOut: TimelineFrame;
|
|
319
|
+
readonly speed: number;
|
|
320
|
+
readonly enabled: boolean;
|
|
321
|
+
readonly reversed: boolean;
|
|
322
|
+
readonly name: string | null;
|
|
323
|
+
readonly color: string | null;
|
|
324
|
+
readonly metadata: Record<string, string>;
|
|
325
|
+
readonly effects?: readonly Effect[];
|
|
326
|
+
readonly transform?: ClipTransform;
|
|
327
|
+
readonly audio?: AudioProperties;
|
|
328
|
+
readonly transition?: Transition;
|
|
329
|
+
};
|
|
330
|
+
declare function createClip(params: {
|
|
331
|
+
id: string;
|
|
332
|
+
assetId: string;
|
|
333
|
+
trackId: string;
|
|
334
|
+
timelineStart: TimelineFrame;
|
|
335
|
+
timelineEnd: TimelineFrame;
|
|
336
|
+
mediaIn: TimelineFrame;
|
|
337
|
+
mediaOut: TimelineFrame;
|
|
338
|
+
speed?: number;
|
|
339
|
+
enabled?: boolean;
|
|
340
|
+
reversed?: boolean;
|
|
341
|
+
name?: string | null;
|
|
342
|
+
color?: string | null;
|
|
343
|
+
metadata?: Record<string, string>;
|
|
344
|
+
effects?: readonly Effect[];
|
|
345
|
+
transform?: ClipTransform;
|
|
346
|
+
audio?: AudioProperties;
|
|
347
|
+
transition?: Transition;
|
|
348
|
+
}): Clip;
|
|
349
|
+
declare function getClipDuration(clip: Clip): TimelineFrame;
|
|
350
|
+
declare function getClipMediaDuration(clip: Clip): TimelineFrame;
|
|
351
|
+
declare function clipContainsFrame(clip: Clip, f: TimelineFrame): boolean;
|
|
352
|
+
declare function clipsOverlap(a: Clip, b: Clip): boolean;
|
|
353
|
+
|
|
354
|
+
/**
|
|
355
|
+
* CAPTION MODEL — Phase 3
|
|
356
|
+
*
|
|
357
|
+
* Captions live on Track.captions[]. Used for SRT/VTT and burn-in.
|
|
358
|
+
*/
|
|
359
|
+
|
|
360
|
+
type CaptionId = string & {
|
|
361
|
+
readonly __brand: 'CaptionId';
|
|
362
|
+
};
|
|
363
|
+
type CaptionStyle = {
|
|
364
|
+
readonly fontFamily: string;
|
|
365
|
+
readonly fontSize: number;
|
|
366
|
+
readonly color: string;
|
|
367
|
+
readonly backgroundColor: string;
|
|
368
|
+
readonly hAlign: 'left' | 'center' | 'right';
|
|
369
|
+
readonly vAlign: 'top' | 'center' | 'bottom';
|
|
370
|
+
};
|
|
371
|
+
type Caption = {
|
|
372
|
+
readonly id: CaptionId;
|
|
373
|
+
readonly text: string;
|
|
374
|
+
readonly startFrame: TimelineFrame;
|
|
375
|
+
readonly endFrame: TimelineFrame;
|
|
376
|
+
readonly language: string;
|
|
377
|
+
readonly style: CaptionStyle;
|
|
378
|
+
readonly burnIn: boolean;
|
|
379
|
+
};
|
|
380
|
+
|
|
381
|
+
/**
|
|
382
|
+
* TRACK GROUP — Phase 4
|
|
383
|
+
*
|
|
384
|
+
* Logical grouping of tracks (e.g. for nesting or UI collapse).
|
|
385
|
+
*/
|
|
386
|
+
|
|
387
|
+
type TrackGroupId = string & {
|
|
388
|
+
readonly __brand: 'TrackGroupId';
|
|
389
|
+
};
|
|
390
|
+
declare function toTrackGroupId(s: string): TrackGroupId;
|
|
391
|
+
type TrackGroup = {
|
|
392
|
+
readonly id: TrackGroupId;
|
|
393
|
+
readonly label: string;
|
|
394
|
+
readonly trackIds: readonly TrackId[];
|
|
395
|
+
readonly collapsed: boolean;
|
|
396
|
+
};
|
|
397
|
+
declare function createTrackGroup(id: TrackGroupId, label: string, trackIds?: readonly TrackId[]): TrackGroup;
|
|
398
|
+
|
|
399
|
+
/**
|
|
400
|
+
* TRACK MODEL — Phase 0 + Phase 3
|
|
401
|
+
*
|
|
402
|
+
* A Track is a horizontal container for Clips, always sorted by timelineStart.
|
|
403
|
+
* Phase 3: captions[] for subtitle/caption items.
|
|
404
|
+
*/
|
|
405
|
+
|
|
406
|
+
type TrackId = string & {
|
|
407
|
+
readonly __brand: 'TrackId';
|
|
408
|
+
};
|
|
409
|
+
declare const toTrackId: (s: string) => TrackId;
|
|
410
|
+
type TrackType = 'video' | 'audio' | 'subtitle' | 'title';
|
|
411
|
+
type Track = {
|
|
412
|
+
readonly id: TrackId;
|
|
413
|
+
readonly name: string;
|
|
414
|
+
readonly type: TrackType;
|
|
415
|
+
readonly locked: boolean;
|
|
416
|
+
readonly muted: boolean;
|
|
417
|
+
readonly solo: boolean;
|
|
418
|
+
readonly height: number;
|
|
419
|
+
/** Always sorted ascending by timelineStart — invariant enforced by checkInvariants. */
|
|
420
|
+
readonly clips: readonly Clip[];
|
|
421
|
+
/** Phase 3: captions on this track (e.g. subtitle/title). */
|
|
422
|
+
readonly captions: readonly Caption[];
|
|
423
|
+
readonly blendMode?: string;
|
|
424
|
+
readonly opacity?: number;
|
|
425
|
+
readonly groupId?: TrackGroupId;
|
|
426
|
+
};
|
|
427
|
+
declare function createTrack(params: {
|
|
428
|
+
id: string;
|
|
429
|
+
name: string;
|
|
430
|
+
type: TrackType;
|
|
431
|
+
clips?: readonly Clip[];
|
|
432
|
+
captions?: readonly Caption[];
|
|
433
|
+
locked?: boolean;
|
|
434
|
+
muted?: boolean;
|
|
435
|
+
solo?: boolean;
|
|
436
|
+
height?: number;
|
|
437
|
+
blendMode?: string;
|
|
438
|
+
opacity?: number;
|
|
439
|
+
groupId?: TrackGroupId;
|
|
440
|
+
}): Track;
|
|
441
|
+
/** Returns a new track with clips sorted ascending by timelineStart. */
|
|
442
|
+
declare function sortTrackClips(track: Track): Track;
|
|
443
|
+
|
|
444
|
+
/**
|
|
445
|
+
* MARKER TYPES — Phase 3
|
|
446
|
+
*
|
|
447
|
+
* Discriminated union: point (single frame) or range (frameStart..frameEnd).
|
|
448
|
+
* Markers live on Timeline.markers[]. linkedClipId moves with clip on ripple.
|
|
449
|
+
*/
|
|
450
|
+
|
|
451
|
+
type MarkerId = string & {
|
|
452
|
+
readonly __brand: 'MarkerId';
|
|
453
|
+
};
|
|
454
|
+
type MarkerScope = 'global' | 'personal' | 'export';
|
|
455
|
+
type Marker = {
|
|
456
|
+
readonly type: 'point';
|
|
457
|
+
readonly id: MarkerId;
|
|
458
|
+
readonly frame: TimelineFrame;
|
|
459
|
+
readonly label: string;
|
|
460
|
+
readonly color: string;
|
|
461
|
+
readonly scope: MarkerScope;
|
|
462
|
+
readonly linkedClipId: ClipId | null;
|
|
463
|
+
readonly clipId?: ClipId;
|
|
464
|
+
} | {
|
|
465
|
+
readonly type: 'range';
|
|
466
|
+
readonly id: MarkerId;
|
|
467
|
+
readonly frameStart: TimelineFrame;
|
|
468
|
+
readonly frameEnd: TimelineFrame;
|
|
469
|
+
readonly label: string;
|
|
470
|
+
readonly color: string;
|
|
471
|
+
readonly scope: MarkerScope;
|
|
472
|
+
readonly linkedClipId: ClipId | null;
|
|
473
|
+
readonly clipId?: ClipId;
|
|
474
|
+
};
|
|
475
|
+
type BeatGrid = {
|
|
476
|
+
readonly bpm: number;
|
|
477
|
+
readonly timeSignature: readonly [number, number];
|
|
478
|
+
readonly offset: TimelineFrame;
|
|
479
|
+
};
|
|
480
|
+
|
|
481
|
+
/**
|
|
482
|
+
* LINK GROUP — Phase 4
|
|
483
|
+
*
|
|
484
|
+
* Locks A/V clips in sync; when one moves, all move together.
|
|
485
|
+
*/
|
|
486
|
+
|
|
487
|
+
type LinkGroupId = string & {
|
|
488
|
+
readonly __brand: 'LinkGroupId';
|
|
489
|
+
};
|
|
490
|
+
declare function toLinkGroupId(s: string): LinkGroupId;
|
|
491
|
+
type LinkGroup = {
|
|
492
|
+
readonly id: LinkGroupId;
|
|
493
|
+
/** Min 2 clips. */
|
|
494
|
+
readonly clipIds: readonly ClipId[];
|
|
495
|
+
};
|
|
496
|
+
declare function createLinkGroup(id: LinkGroupId, clipIds: readonly ClipId[]): LinkGroup;
|
|
497
|
+
|
|
498
|
+
/**
|
|
499
|
+
* TIMELINE MODEL — Phase 0 + Phase 3
|
|
500
|
+
*/
|
|
501
|
+
|
|
502
|
+
type SequenceSettings = {
|
|
503
|
+
readonly pixelAspectRatio: number;
|
|
504
|
+
readonly fieldOrder: 'progressive' | 'upper' | 'lower';
|
|
505
|
+
readonly colorSpace: string;
|
|
506
|
+
readonly audioSampleRate: number;
|
|
507
|
+
readonly audioChannelCount: number;
|
|
508
|
+
};
|
|
509
|
+
type Timeline = {
|
|
510
|
+
readonly id: string;
|
|
511
|
+
readonly name: string;
|
|
512
|
+
readonly fps: FrameRate;
|
|
513
|
+
readonly duration: TimelineFrame;
|
|
514
|
+
readonly startTimecode: Timecode;
|
|
515
|
+
readonly tracks: readonly Track[];
|
|
516
|
+
readonly sequenceSettings: SequenceSettings;
|
|
517
|
+
/**
|
|
518
|
+
* Increments by 1 on every successfully committed Transaction.
|
|
519
|
+
* Use this to detect stale references without deep equality checks.
|
|
520
|
+
*/
|
|
521
|
+
readonly version: number;
|
|
522
|
+
readonly markers: readonly Marker[];
|
|
523
|
+
readonly beatGrid: BeatGrid | null;
|
|
524
|
+
readonly inPoint: TimelineFrame | null;
|
|
525
|
+
readonly outPoint: TimelineFrame | null;
|
|
526
|
+
readonly trackGroups?: readonly TrackGroup[];
|
|
527
|
+
readonly linkGroups?: readonly LinkGroup[];
|
|
528
|
+
};
|
|
529
|
+
declare function createTimeline(params: {
|
|
530
|
+
id: string;
|
|
531
|
+
name: string;
|
|
532
|
+
fps: FrameRate;
|
|
533
|
+
duration: TimelineFrame;
|
|
534
|
+
startTimecode?: Timecode;
|
|
535
|
+
tracks?: readonly Track[];
|
|
536
|
+
sequenceSettings?: Partial<SequenceSettings>;
|
|
537
|
+
markers?: readonly Marker[];
|
|
538
|
+
beatGrid?: BeatGrid | null;
|
|
539
|
+
inPoint?: TimelineFrame | null;
|
|
540
|
+
outPoint?: TimelineFrame | null;
|
|
541
|
+
trackGroups?: readonly TrackGroup[];
|
|
542
|
+
linkGroups?: readonly LinkGroup[];
|
|
543
|
+
}): Timeline;
|
|
544
|
+
|
|
545
|
+
/**
|
|
546
|
+
* TIMELINE STATE — Phase 0 compliant
|
|
547
|
+
*
|
|
548
|
+
* TimelineState is the single source of truth for the engine.
|
|
549
|
+
* Phase 0 only: timeline + assetRegistry. No Phase 2 fields.
|
|
550
|
+
*
|
|
551
|
+
* RULE: Every function that changes state returns a NEW TimelineState.
|
|
552
|
+
* Never mutate the existing state.
|
|
553
|
+
*/
|
|
554
|
+
|
|
555
|
+
type AssetRegistry = ReadonlyMap<AssetId, Asset>;
|
|
556
|
+
/**
|
|
557
|
+
* Increment this whenever TimelineState gains a new required field or
|
|
558
|
+
* a field's semantics change in a breaking way.
|
|
559
|
+
*
|
|
560
|
+
* The schemaVersion invariant check rejects loading a future schema
|
|
561
|
+
* into an older engine (prevents silent data corruption on downgrade).
|
|
562
|
+
*/
|
|
563
|
+
declare const CURRENT_SCHEMA_VERSION: 2;
|
|
564
|
+
type TimelineState = {
|
|
565
|
+
readonly schemaVersion: number;
|
|
566
|
+
readonly timeline: Timeline;
|
|
567
|
+
readonly assetRegistry: AssetRegistry;
|
|
568
|
+
};
|
|
569
|
+
declare function createTimelineState(params: {
|
|
570
|
+
timeline: Timeline;
|
|
571
|
+
assetRegistry?: AssetRegistry;
|
|
572
|
+
/** @deprecated use assetRegistry. Kept for test backward-compat only. */
|
|
573
|
+
assets?: Map<string, Asset>;
|
|
574
|
+
}): TimelineState;
|
|
575
|
+
|
|
576
|
+
/**
|
|
577
|
+
* FRAME UTILITIES
|
|
578
|
+
*
|
|
579
|
+
* Pure functions for working with frame-based time values.
|
|
580
|
+
*
|
|
581
|
+
* These utilities handle:
|
|
582
|
+
* - Converting between frames and seconds
|
|
583
|
+
* - Formatting frames as timecode (HH:MM:SS:FF)
|
|
584
|
+
* - Frame arithmetic (clamping, rounding)
|
|
585
|
+
*
|
|
586
|
+
* CRITICAL RULES:
|
|
587
|
+
* - All conversions must quantize to whole frames
|
|
588
|
+
* - No floating-point frame values allowed
|
|
589
|
+
* - Always round/floor/ceil explicitly
|
|
590
|
+
*
|
|
591
|
+
* USAGE:
|
|
592
|
+
* ```typescript
|
|
593
|
+
* const fps = frameRate(30);
|
|
594
|
+
* const frames = secondsToFrames(5.5, fps); // 165 frames
|
|
595
|
+
* const seconds = framesToSeconds(frames, fps); // 5.5 seconds
|
|
596
|
+
* const timecode = framesToTimecode(frames, fps); // "00:00:05:15"
|
|
597
|
+
* ```
|
|
598
|
+
*/
|
|
599
|
+
|
|
600
|
+
/**
|
|
601
|
+
* Convert frames to seconds
|
|
602
|
+
*
|
|
603
|
+
* @param frames - Frame number
|
|
604
|
+
* @param fps - Frames per second
|
|
605
|
+
* @returns Time in seconds (may be fractional)
|
|
606
|
+
*/
|
|
607
|
+
declare function framesToSeconds(frames: TimelineFrame, fps: FrameRate): number;
|
|
608
|
+
/**
|
|
609
|
+
* Convert seconds to frames
|
|
610
|
+
*
|
|
611
|
+
* IMPORTANT: This rounds to the nearest frame.
|
|
612
|
+
* If you need different rounding behavior, use Math.floor or Math.ceil explicitly.
|
|
613
|
+
*
|
|
614
|
+
* @param seconds - Time in seconds
|
|
615
|
+
* @param fps - Frames per second
|
|
616
|
+
* @returns Frame number (rounded to nearest frame)
|
|
617
|
+
*/
|
|
618
|
+
declare function secondsToFrames(seconds: number, fps: FrameRate): TimelineFrame;
|
|
619
|
+
/**
|
|
620
|
+
* Convert frames to timecode format (HH:MM:SS:FF)
|
|
621
|
+
*
|
|
622
|
+
* Example: 3825 frames at 30fps = "00:02:07:15"
|
|
623
|
+
*
|
|
624
|
+
* @param frames - Frame number
|
|
625
|
+
* @param fps - Frames per second
|
|
626
|
+
* @returns Timecode string
|
|
627
|
+
*/
|
|
628
|
+
declare function framesToTimecode(frames: TimelineFrame, fps: FrameRate): string;
|
|
629
|
+
/**
|
|
630
|
+
* Convert frames to simple MM:SS format
|
|
631
|
+
*
|
|
632
|
+
* Example: 3825 frames at 30fps = "02:07"
|
|
633
|
+
*
|
|
634
|
+
* @param frames - Frame number
|
|
635
|
+
* @param fps - Frames per second
|
|
636
|
+
* @returns Time string in MM:SS format
|
|
637
|
+
*/
|
|
638
|
+
declare function framesToMinutesSeconds(frames: TimelineFrame, fps: FrameRate): string;
|
|
639
|
+
/**
|
|
640
|
+
* Clamp a frame value between min and max
|
|
641
|
+
*
|
|
642
|
+
* @param value - Frame to clamp
|
|
643
|
+
* @param min - Minimum frame (inclusive)
|
|
644
|
+
* @param max - Maximum frame (inclusive)
|
|
645
|
+
* @returns Clamped frame value
|
|
646
|
+
*/
|
|
647
|
+
declare function clampFrame(value: TimelineFrame, min: TimelineFrame, max: TimelineFrame): TimelineFrame;
|
|
648
|
+
/**
|
|
649
|
+
* Add two frame values
|
|
650
|
+
*
|
|
651
|
+
* @param a - First frame
|
|
652
|
+
* @param b - Second frame
|
|
653
|
+
* @returns Sum of frames
|
|
654
|
+
*/
|
|
655
|
+
declare function addFrames(a: TimelineFrame, b: TimelineFrame): TimelineFrame;
|
|
656
|
+
/**
|
|
657
|
+
* Subtract two frame values
|
|
658
|
+
*
|
|
659
|
+
* @param a - First frame
|
|
660
|
+
* @param b - Second frame (subtracted from a)
|
|
661
|
+
* @returns Difference of frames (clamped to 0 if negative)
|
|
662
|
+
*/
|
|
663
|
+
declare function subtractFrames(a: TimelineFrame, b: TimelineFrame): TimelineFrame;
|
|
664
|
+
/**
|
|
665
|
+
* Calculate duration between two frames
|
|
666
|
+
*
|
|
667
|
+
* @param start - Start frame
|
|
668
|
+
* @param end - End frame
|
|
669
|
+
* @returns Duration in frames (end - start)
|
|
670
|
+
*/
|
|
671
|
+
declare function frameDuration(start: TimelineFrame, end: TimelineFrame): TimelineFrame;
|
|
672
|
+
|
|
673
|
+
/**
|
|
674
|
+
* TIMELINE ENGINE
|
|
675
|
+
*
|
|
676
|
+
* The main public API for the timeline editing kernel.
|
|
677
|
+
*
|
|
678
|
+
* WHAT IS THE TIMELINE ENGINE?
|
|
679
|
+
* - A thin wrapper around the history and dispatch systems
|
|
680
|
+
* - Provides a convenient, object-oriented API
|
|
681
|
+
* - Manages internal state
|
|
682
|
+
* - Coordinates operations, validation, and history
|
|
683
|
+
*
|
|
684
|
+
* WHY A CLASS?
|
|
685
|
+
* - Encapsulates state management
|
|
686
|
+
* - Provides a clean API for users
|
|
687
|
+
* - Hides complexity of history and dispatch
|
|
688
|
+
* - Familiar OOP interface for most developers
|
|
689
|
+
*
|
|
690
|
+
* USAGE:
|
|
691
|
+
* ```typescript
|
|
692
|
+
* const engine = new TimelineEngine(initialState);
|
|
693
|
+
*
|
|
694
|
+
* // Add a clip
|
|
695
|
+
* const result = engine.addClip(trackId, clip);
|
|
696
|
+
* if (!result.success) {
|
|
697
|
+
* console.error('Failed to add clip:', result.errors);
|
|
698
|
+
* }
|
|
699
|
+
*
|
|
700
|
+
* // Undo/redo
|
|
701
|
+
* engine.undo();
|
|
702
|
+
* engine.redo();
|
|
703
|
+
*
|
|
704
|
+
* // Query state
|
|
705
|
+
* const clip = engine.findClipById('clip_1');
|
|
706
|
+
* const state = engine.getState();
|
|
707
|
+
* ```
|
|
708
|
+
*
|
|
709
|
+
* DESIGN PHILOSOPHY:
|
|
710
|
+
* - Business logic lives in pure modules (operations, validation, etc.)
|
|
711
|
+
* - Engine is just a thin orchestration layer
|
|
712
|
+
* - Easy to test (can test pure functions independently)
|
|
713
|
+
*/
|
|
714
|
+
|
|
715
|
+
/**
|
|
716
|
+
* TimelineEngine - The main timeline editing engine
|
|
717
|
+
*
|
|
718
|
+
* Provides a high-level API for timeline editing with built-in
|
|
719
|
+
* undo/redo, validation, and state management.
|
|
720
|
+
*/
|
|
721
|
+
declare class TimelineEngine {
|
|
722
|
+
private history;
|
|
723
|
+
private listeners;
|
|
724
|
+
/**
|
|
725
|
+
* Create a new timeline engine
|
|
726
|
+
*
|
|
727
|
+
* @param initialState - Initial timeline state
|
|
728
|
+
* @param historyLimit - Maximum number of undo steps (default: 50)
|
|
729
|
+
*/
|
|
730
|
+
constructor(initialState: TimelineState, historyLimit?: number);
|
|
731
|
+
/**
|
|
732
|
+
* Subscribe to state changes
|
|
733
|
+
*
|
|
734
|
+
* The listener will be called whenever the timeline state changes,
|
|
735
|
+
* with the new state passed as an argument.
|
|
736
|
+
* This is used by framework adapters (e.g., React) to trigger re-renders.
|
|
737
|
+
*
|
|
738
|
+
* @param listener - Function to call on state changes, receives new state
|
|
739
|
+
* @returns Unsubscribe function
|
|
740
|
+
*
|
|
741
|
+
* @example
|
|
742
|
+
* ```typescript
|
|
743
|
+
* const unsubscribe = engine.subscribe((state) => {
|
|
744
|
+
* console.log('State changed:', state);
|
|
745
|
+
* });
|
|
746
|
+
*
|
|
747
|
+
* // Later...
|
|
748
|
+
* unsubscribe();
|
|
749
|
+
* ```
|
|
750
|
+
*/
|
|
751
|
+
subscribe(listener: (state: TimelineState) => void): () => void;
|
|
752
|
+
/**
|
|
753
|
+
* Notify all subscribers of a state change
|
|
754
|
+
*
|
|
755
|
+
* This is called internally after any operation that modifies state.
|
|
756
|
+
* Framework adapters use this to trigger re-renders.
|
|
757
|
+
*/
|
|
758
|
+
private notify;
|
|
759
|
+
/**
|
|
760
|
+
* Get the current timeline state
|
|
761
|
+
*
|
|
762
|
+
* @returns Current timeline state
|
|
763
|
+
*/
|
|
764
|
+
getState(): TimelineState;
|
|
765
|
+
/**
|
|
766
|
+
* Register an asset
|
|
767
|
+
*
|
|
768
|
+
* @param asset - Asset to register
|
|
769
|
+
* @returns Dispatch result
|
|
770
|
+
*/
|
|
771
|
+
registerAsset(asset: Asset): {
|
|
772
|
+
accepted: boolean;
|
|
773
|
+
errors?: {
|
|
774
|
+
code: string;
|
|
775
|
+
message: string;
|
|
776
|
+
}[];
|
|
777
|
+
};
|
|
778
|
+
/**
|
|
779
|
+
* Get an asset by ID
|
|
780
|
+
*
|
|
781
|
+
* @param assetId - Asset ID
|
|
782
|
+
* @returns The asset, or undefined if not found
|
|
783
|
+
*/
|
|
784
|
+
getAsset(assetId: string): Asset | undefined;
|
|
785
|
+
/**
|
|
786
|
+
* Add a clip to a track
|
|
787
|
+
*
|
|
788
|
+
* @param trackId - ID of the track to add to
|
|
789
|
+
* @param clip - Clip to add
|
|
790
|
+
* @returns Dispatch result
|
|
791
|
+
*/
|
|
792
|
+
addClip(trackId: string, clip: Clip): {
|
|
793
|
+
accepted: boolean;
|
|
794
|
+
errors?: {
|
|
795
|
+
code: string;
|
|
796
|
+
message: string;
|
|
797
|
+
}[];
|
|
798
|
+
};
|
|
799
|
+
/**
|
|
800
|
+
* Remove a clip
|
|
801
|
+
*
|
|
802
|
+
* @param clipId - ID of the clip to remove
|
|
803
|
+
* @returns Dispatch result
|
|
804
|
+
*/
|
|
805
|
+
removeClip(clipId: string): {
|
|
806
|
+
accepted: boolean;
|
|
807
|
+
errors?: {
|
|
808
|
+
code: string;
|
|
809
|
+
message: string;
|
|
810
|
+
}[];
|
|
811
|
+
};
|
|
812
|
+
/**
|
|
813
|
+
* Move a clip to a new timeline position
|
|
814
|
+
*
|
|
815
|
+
* @param clipId - ID of the clip to move
|
|
816
|
+
* @param newStart - New timeline start frame
|
|
817
|
+
* @returns Dispatch result
|
|
818
|
+
*/
|
|
819
|
+
moveClip(clipId: string, newStart: TimelineFrame): {
|
|
820
|
+
accepted: boolean;
|
|
821
|
+
errors?: {
|
|
822
|
+
code: string;
|
|
823
|
+
message: string;
|
|
824
|
+
}[];
|
|
825
|
+
};
|
|
826
|
+
/**
|
|
827
|
+
* Resize a clip
|
|
828
|
+
*
|
|
829
|
+
* @param clipId - ID of the clip to resize
|
|
830
|
+
* @param newStart - New timeline start frame
|
|
831
|
+
* @param newEnd - New timeline end frame
|
|
832
|
+
* @returns Dispatch result
|
|
833
|
+
*/
|
|
834
|
+
resizeClip(clipId: string, newStart: TimelineFrame, newEnd: TimelineFrame): {
|
|
835
|
+
accepted: boolean;
|
|
836
|
+
errors?: {
|
|
837
|
+
code: string;
|
|
838
|
+
message: string;
|
|
839
|
+
}[];
|
|
840
|
+
};
|
|
841
|
+
/**
|
|
842
|
+
* Trim a clip (change media bounds)
|
|
843
|
+
*
|
|
844
|
+
* @param clipId - ID of the clip to trim
|
|
845
|
+
* @param newMediaIn - New media in frame
|
|
846
|
+
* @param newMediaOut - New media out frame
|
|
847
|
+
* @returns Dispatch result
|
|
848
|
+
*/
|
|
849
|
+
trimClip(clipId: string, newMediaIn: TimelineFrame, newMediaOut: TimelineFrame): {
|
|
850
|
+
accepted: boolean;
|
|
851
|
+
errors?: {
|
|
852
|
+
code: string;
|
|
853
|
+
message: string;
|
|
854
|
+
}[];
|
|
855
|
+
};
|
|
856
|
+
/**
|
|
857
|
+
* Move a clip to a different track
|
|
858
|
+
*
|
|
859
|
+
* @param clipId - ID of the clip to move
|
|
860
|
+
* @param targetTrackId - ID of the target track
|
|
861
|
+
* @returns Dispatch result
|
|
862
|
+
*/
|
|
863
|
+
moveClipToTrack(clipId: string, targetTrackId: string): {
|
|
864
|
+
accepted: boolean;
|
|
865
|
+
errors?: {
|
|
866
|
+
code: string;
|
|
867
|
+
message: string;
|
|
868
|
+
}[];
|
|
869
|
+
};
|
|
870
|
+
/**
|
|
871
|
+
* Add a track
|
|
872
|
+
*
|
|
873
|
+
* @param track - Track to add
|
|
874
|
+
* @returns Dispatch result
|
|
875
|
+
*/
|
|
876
|
+
addTrack(track: Track): {
|
|
877
|
+
accepted: boolean;
|
|
878
|
+
errors?: {
|
|
879
|
+
code: string;
|
|
880
|
+
message: string;
|
|
881
|
+
}[];
|
|
882
|
+
};
|
|
883
|
+
/**
|
|
884
|
+
* Remove a track
|
|
885
|
+
*
|
|
886
|
+
* @param trackId - ID of the track to remove
|
|
887
|
+
* @returns Dispatch result
|
|
888
|
+
*/
|
|
889
|
+
removeTrack(trackId: string): {
|
|
890
|
+
accepted: boolean;
|
|
891
|
+
errors?: {
|
|
892
|
+
code: string;
|
|
893
|
+
message: string;
|
|
894
|
+
}[];
|
|
895
|
+
};
|
|
896
|
+
/**
|
|
897
|
+
* Move a track to a new position
|
|
898
|
+
*
|
|
899
|
+
* @param trackId - ID of the track to move
|
|
900
|
+
* @param newIndex - New index position
|
|
901
|
+
* @returns Dispatch result
|
|
902
|
+
*/
|
|
903
|
+
moveTrack(trackId: string, newIndex: number): {
|
|
904
|
+
accepted: boolean;
|
|
905
|
+
errors?: {
|
|
906
|
+
code: string;
|
|
907
|
+
message: string;
|
|
908
|
+
}[];
|
|
909
|
+
};
|
|
910
|
+
/**
|
|
911
|
+
* Toggle track mute
|
|
912
|
+
*
|
|
913
|
+
* @param trackId - ID of the track
|
|
914
|
+
* @returns Dispatch result
|
|
915
|
+
*/
|
|
916
|
+
toggleTrackMute(trackId: string): {
|
|
917
|
+
accepted: boolean;
|
|
918
|
+
errors?: {
|
|
919
|
+
code: string;
|
|
920
|
+
message: string;
|
|
921
|
+
}[];
|
|
922
|
+
};
|
|
923
|
+
/**
|
|
924
|
+
* Toggle track lock
|
|
925
|
+
*
|
|
926
|
+
* @param trackId - ID of the track
|
|
927
|
+
* @returns Dispatch result
|
|
928
|
+
*/
|
|
929
|
+
toggleTrackLock(trackId: string): {
|
|
930
|
+
accepted: boolean;
|
|
931
|
+
errors?: {
|
|
932
|
+
code: string;
|
|
933
|
+
message: string;
|
|
934
|
+
}[];
|
|
935
|
+
};
|
|
936
|
+
/**
|
|
937
|
+
* Toggle track solo
|
|
938
|
+
*
|
|
939
|
+
* @param trackId - ID of the track
|
|
940
|
+
* @returns Dispatch result
|
|
941
|
+
*/
|
|
942
|
+
toggleTrackSolo(trackId: string): {
|
|
943
|
+
accepted: boolean;
|
|
944
|
+
errors?: {
|
|
945
|
+
code: string;
|
|
946
|
+
message: string;
|
|
947
|
+
}[];
|
|
948
|
+
};
|
|
949
|
+
/**
|
|
950
|
+
* Set track height
|
|
951
|
+
*
|
|
952
|
+
* @param trackId - ID of the track
|
|
953
|
+
* @param height - New height in pixels
|
|
954
|
+
* @returns Dispatch result
|
|
955
|
+
*/
|
|
956
|
+
setTrackHeight(trackId: string, height: number): {
|
|
957
|
+
accepted: boolean;
|
|
958
|
+
errors?: {
|
|
959
|
+
code: string;
|
|
960
|
+
message: string;
|
|
961
|
+
}[];
|
|
962
|
+
};
|
|
963
|
+
/**
|
|
964
|
+
* Set timeline duration
|
|
965
|
+
*
|
|
966
|
+
* @param duration - New duration in frames
|
|
967
|
+
* @returns Dispatch result
|
|
968
|
+
*/
|
|
969
|
+
setTimelineDuration(duration: TimelineFrame): {
|
|
970
|
+
accepted: boolean;
|
|
971
|
+
errors?: {
|
|
972
|
+
code: string;
|
|
973
|
+
message: string;
|
|
974
|
+
}[];
|
|
975
|
+
};
|
|
976
|
+
/**
|
|
977
|
+
* Set timeline name
|
|
978
|
+
*
|
|
979
|
+
* @param name - New timeline name
|
|
980
|
+
* @returns Dispatch result
|
|
981
|
+
*/
|
|
982
|
+
setTimelineName(name: string): {
|
|
983
|
+
accepted: boolean;
|
|
984
|
+
errors?: {
|
|
985
|
+
code: string;
|
|
986
|
+
message: string;
|
|
987
|
+
}[];
|
|
988
|
+
};
|
|
989
|
+
/**
|
|
990
|
+
* Undo the last action
|
|
991
|
+
*
|
|
992
|
+
* @returns true if undo was performed
|
|
993
|
+
*/
|
|
994
|
+
undo(): boolean;
|
|
995
|
+
/**
|
|
996
|
+
* Redo the last undone action
|
|
997
|
+
*
|
|
998
|
+
* @returns true if redo was performed
|
|
999
|
+
*/
|
|
1000
|
+
redo(): boolean;
|
|
1001
|
+
/**
|
|
1002
|
+
* Check if undo is available
|
|
1003
|
+
*
|
|
1004
|
+
* @returns true if undo is available
|
|
1005
|
+
*/
|
|
1006
|
+
canUndo(): boolean;
|
|
1007
|
+
/**
|
|
1008
|
+
* Check if redo is available
|
|
1009
|
+
*
|
|
1010
|
+
* @returns true if redo is available
|
|
1011
|
+
*/
|
|
1012
|
+
canRedo(): boolean;
|
|
1013
|
+
/**
|
|
1014
|
+
* Find a clip by ID
|
|
1015
|
+
*
|
|
1016
|
+
* @param clipId - Clip ID
|
|
1017
|
+
* @returns The clip, or undefined if not found
|
|
1018
|
+
*/
|
|
1019
|
+
findClipById(clipId: string): Clip | undefined;
|
|
1020
|
+
/**
|
|
1021
|
+
* Find a track by ID
|
|
1022
|
+
*
|
|
1023
|
+
* @param trackId - Track ID
|
|
1024
|
+
* @returns The track, or undefined if not found
|
|
1025
|
+
*/
|
|
1026
|
+
findTrackById(trackId: string): Track | undefined;
|
|
1027
|
+
/**
|
|
1028
|
+
* Get all clips on a track
|
|
1029
|
+
*
|
|
1030
|
+
* @param trackId - Track ID
|
|
1031
|
+
* @returns Array of clips on the track
|
|
1032
|
+
*/
|
|
1033
|
+
getClipsOnTrack(trackId: string): Clip[];
|
|
1034
|
+
/**
|
|
1035
|
+
* Get all clips at a specific frame
|
|
1036
|
+
*
|
|
1037
|
+
* @param frame - Frame to check
|
|
1038
|
+
* @returns Array of clips at that frame
|
|
1039
|
+
*/
|
|
1040
|
+
getClipsAtFrame(f: TimelineFrame): Clip[];
|
|
1041
|
+
/**
|
|
1042
|
+
* Get all clips in a frame range
|
|
1043
|
+
*
|
|
1044
|
+
* @param start - Start frame
|
|
1045
|
+
* @param end - End frame
|
|
1046
|
+
* @returns Array of clips in the range
|
|
1047
|
+
*/
|
|
1048
|
+
getClipsInRange(start: TimelineFrame, end: TimelineFrame): Clip[];
|
|
1049
|
+
/**
|
|
1050
|
+
* Get all clips in the timeline
|
|
1051
|
+
*
|
|
1052
|
+
* @returns Array of all clips
|
|
1053
|
+
*/
|
|
1054
|
+
getAllClips(): Clip[];
|
|
1055
|
+
/**
|
|
1056
|
+
* Get all tracks in the timeline
|
|
1057
|
+
*
|
|
1058
|
+
* @returns Array of all tracks
|
|
1059
|
+
*/
|
|
1060
|
+
getAllTracks(): readonly Track[];
|
|
1061
|
+
/**
|
|
1062
|
+
* Ripple delete - delete clip and shift subsequent clips left
|
|
1063
|
+
*
|
|
1064
|
+
* @param clipId - ID of the clip to delete
|
|
1065
|
+
* @returns Dispatch result
|
|
1066
|
+
*/
|
|
1067
|
+
rippleDelete(clipId: string): {
|
|
1068
|
+
accepted: boolean;
|
|
1069
|
+
errors?: {
|
|
1070
|
+
code: string;
|
|
1071
|
+
message: string;
|
|
1072
|
+
}[];
|
|
1073
|
+
};
|
|
1074
|
+
/**
|
|
1075
|
+
* Ripple trim - trim clip end and shift subsequent clips
|
|
1076
|
+
*
|
|
1077
|
+
* @param clipId - ID of the clip to trim
|
|
1078
|
+
* @param newEnd - New end frame for the clip
|
|
1079
|
+
* @returns Dispatch result
|
|
1080
|
+
*/
|
|
1081
|
+
rippleTrim(clipId: string, newEnd: TimelineFrame): {
|
|
1082
|
+
accepted: boolean;
|
|
1083
|
+
errors?: {
|
|
1084
|
+
code: string;
|
|
1085
|
+
message: string;
|
|
1086
|
+
}[];
|
|
1087
|
+
};
|
|
1088
|
+
/**
|
|
1089
|
+
* Insert edit - insert clip and shift subsequent clips right
|
|
1090
|
+
*
|
|
1091
|
+
* @param trackId - ID of the track to insert into
|
|
1092
|
+
* @param clip - Clip to insert
|
|
1093
|
+
* @param atFrame - Frame to insert at
|
|
1094
|
+
* @returns Dispatch result
|
|
1095
|
+
*/
|
|
1096
|
+
insertEdit(trackId: string, clip: Clip, atFrame: TimelineFrame): {
|
|
1097
|
+
accepted: boolean;
|
|
1098
|
+
errors?: {
|
|
1099
|
+
code: string;
|
|
1100
|
+
message: string;
|
|
1101
|
+
}[];
|
|
1102
|
+
};
|
|
1103
|
+
/**
|
|
1104
|
+
* Ripple move - move clip and shift surrounding clips to accommodate
|
|
1105
|
+
*
|
|
1106
|
+
* This moves a clip to a new position while maintaining timeline continuity:
|
|
1107
|
+
* - Closes the gap at the source position
|
|
1108
|
+
* - Makes space at the destination position
|
|
1109
|
+
* - All operations are atomic (single undo entry)
|
|
1110
|
+
*
|
|
1111
|
+
* @param clipId - ID of the clip to move
|
|
1112
|
+
* @param newStart - New start frame for the clip
|
|
1113
|
+
* @returns Dispatch result
|
|
1114
|
+
*/
|
|
1115
|
+
rippleMove(clipId: string, newStart: TimelineFrame): {
|
|
1116
|
+
accepted: boolean;
|
|
1117
|
+
errors?: {
|
|
1118
|
+
code: string;
|
|
1119
|
+
message: string;
|
|
1120
|
+
}[];
|
|
1121
|
+
};
|
|
1122
|
+
/**
|
|
1123
|
+
* Insert move - move clip and shift destination clips right
|
|
1124
|
+
*
|
|
1125
|
+
* This moves a clip to a new position without closing the gap at source:
|
|
1126
|
+
* - Leaves gap at the source position
|
|
1127
|
+
* - Pushes all clips at destination right to make space
|
|
1128
|
+
* - All operations are atomic (single undo entry)
|
|
1129
|
+
*
|
|
1130
|
+
* @param clipId - ID of the clip to move
|
|
1131
|
+
* @param newStart - New start frame for the clip
|
|
1132
|
+
* @returns Dispatch result
|
|
1133
|
+
*/
|
|
1134
|
+
insertMove(clipId: string, newStart: TimelineFrame): {
|
|
1135
|
+
accepted: boolean;
|
|
1136
|
+
errors?: {
|
|
1137
|
+
code: string;
|
|
1138
|
+
message: string;
|
|
1139
|
+
}[];
|
|
1140
|
+
};
|
|
1141
|
+
}
|
|
1142
|
+
|
|
1143
|
+
/**
|
|
1144
|
+
* OPERATION PRIMITIVES — Phase 0 compliant
|
|
1145
|
+
*
|
|
1146
|
+
* The ONLY way to express a mutation in the engine.
|
|
1147
|
+
* All mutations flow through: OperationPrimitive[] → Transaction → Dispatcher.
|
|
1148
|
+
*
|
|
1149
|
+
* RULE: Never add a new mutation function.
|
|
1150
|
+
* Add a new type to OperationPrimitive, handle it in the Dispatcher switch,
|
|
1151
|
+
* update the InvariantChecker, and update OPERATIONS.md.
|
|
1152
|
+
*
|
|
1153
|
+
* RULE: Transactions are all-or-nothing.
|
|
1154
|
+
* If any primitive fails validation, the entire Transaction is rejected.
|
|
1155
|
+
*/
|
|
1156
|
+
|
|
1157
|
+
type OperationPrimitive = {
|
|
1158
|
+
type: 'MOVE_CLIP';
|
|
1159
|
+
clipId: ClipId;
|
|
1160
|
+
newTimelineStart: TimelineFrame;
|
|
1161
|
+
targetTrackId?: TrackId;
|
|
1162
|
+
} | {
|
|
1163
|
+
type: 'RESIZE_CLIP';
|
|
1164
|
+
clipId: ClipId;
|
|
1165
|
+
edge: 'start' | 'end';
|
|
1166
|
+
newFrame: TimelineFrame;
|
|
1167
|
+
} | {
|
|
1168
|
+
type: 'SLICE_CLIP';
|
|
1169
|
+
clipId: ClipId;
|
|
1170
|
+
atFrame: TimelineFrame;
|
|
1171
|
+
} | {
|
|
1172
|
+
type: 'DELETE_CLIP';
|
|
1173
|
+
clipId: ClipId;
|
|
1174
|
+
} | {
|
|
1175
|
+
type: 'INSERT_CLIP';
|
|
1176
|
+
clip: Clip;
|
|
1177
|
+
trackId: TrackId;
|
|
1178
|
+
} | {
|
|
1179
|
+
type: 'SET_MEDIA_BOUNDS';
|
|
1180
|
+
clipId: ClipId;
|
|
1181
|
+
mediaIn: TimelineFrame;
|
|
1182
|
+
mediaOut: TimelineFrame;
|
|
1183
|
+
} | {
|
|
1184
|
+
type: 'SET_CLIP_ENABLED';
|
|
1185
|
+
clipId: ClipId;
|
|
1186
|
+
enabled: boolean;
|
|
1187
|
+
} | {
|
|
1188
|
+
type: 'SET_CLIP_REVERSED';
|
|
1189
|
+
clipId: ClipId;
|
|
1190
|
+
reversed: boolean;
|
|
1191
|
+
} | {
|
|
1192
|
+
type: 'SET_CLIP_SPEED';
|
|
1193
|
+
clipId: ClipId;
|
|
1194
|
+
speed: number;
|
|
1195
|
+
} | {
|
|
1196
|
+
type: 'SET_CLIP_COLOR';
|
|
1197
|
+
clipId: ClipId;
|
|
1198
|
+
color: string | null;
|
|
1199
|
+
} | {
|
|
1200
|
+
type: 'SET_CLIP_NAME';
|
|
1201
|
+
clipId: ClipId;
|
|
1202
|
+
name: string | null;
|
|
1203
|
+
} | {
|
|
1204
|
+
type: 'ADD_TRACK';
|
|
1205
|
+
track: Track;
|
|
1206
|
+
} | {
|
|
1207
|
+
type: 'DELETE_TRACK';
|
|
1208
|
+
trackId: TrackId;
|
|
1209
|
+
} | {
|
|
1210
|
+
type: 'REORDER_TRACK';
|
|
1211
|
+
trackId: TrackId;
|
|
1212
|
+
newIndex: number;
|
|
1213
|
+
} | {
|
|
1214
|
+
type: 'SET_TRACK_HEIGHT';
|
|
1215
|
+
trackId: TrackId;
|
|
1216
|
+
height: number;
|
|
1217
|
+
} | {
|
|
1218
|
+
type: 'SET_TRACK_NAME';
|
|
1219
|
+
trackId: TrackId;
|
|
1220
|
+
name: string;
|
|
1221
|
+
} | {
|
|
1222
|
+
type: 'REGISTER_ASSET';
|
|
1223
|
+
asset: Asset;
|
|
1224
|
+
} | {
|
|
1225
|
+
type: 'UNREGISTER_ASSET';
|
|
1226
|
+
assetId: AssetId;
|
|
1227
|
+
} | {
|
|
1228
|
+
type: 'SET_ASSET_STATUS';
|
|
1229
|
+
assetId: AssetId;
|
|
1230
|
+
status: AssetStatus;
|
|
1231
|
+
} | {
|
|
1232
|
+
type: 'RENAME_TIMELINE';
|
|
1233
|
+
name: string;
|
|
1234
|
+
} | {
|
|
1235
|
+
type: 'SET_TIMELINE_DURATION';
|
|
1236
|
+
duration: TimelineFrame;
|
|
1237
|
+
} | {
|
|
1238
|
+
type: 'SET_TIMELINE_START_TC';
|
|
1239
|
+
startTimecode: Timecode;
|
|
1240
|
+
} | {
|
|
1241
|
+
type: 'SET_SEQUENCE_SETTINGS';
|
|
1242
|
+
settings: Partial<SequenceSettings>;
|
|
1243
|
+
} | {
|
|
1244
|
+
type: 'ADD_MARKER';
|
|
1245
|
+
marker: Marker;
|
|
1246
|
+
} | {
|
|
1247
|
+
type: 'MOVE_MARKER';
|
|
1248
|
+
markerId: MarkerId;
|
|
1249
|
+
newFrame: TimelineFrame;
|
|
1250
|
+
} | {
|
|
1251
|
+
type: 'DELETE_MARKER';
|
|
1252
|
+
markerId: MarkerId;
|
|
1253
|
+
} | {
|
|
1254
|
+
type: 'SET_IN_POINT';
|
|
1255
|
+
frame: TimelineFrame | null;
|
|
1256
|
+
} | {
|
|
1257
|
+
type: 'SET_OUT_POINT';
|
|
1258
|
+
frame: TimelineFrame | null;
|
|
1259
|
+
} | {
|
|
1260
|
+
type: 'ADD_BEAT_GRID';
|
|
1261
|
+
beatGrid: BeatGrid;
|
|
1262
|
+
} | {
|
|
1263
|
+
type: 'REMOVE_BEAT_GRID';
|
|
1264
|
+
} | {
|
|
1265
|
+
type: 'INSERT_GENERATOR';
|
|
1266
|
+
generator: Generator;
|
|
1267
|
+
trackId: TrackId;
|
|
1268
|
+
atFrame: TimelineFrame;
|
|
1269
|
+
} | {
|
|
1270
|
+
type: 'ADD_CAPTION';
|
|
1271
|
+
caption: Omit<Caption, 'style'> & {
|
|
1272
|
+
style?: CaptionStyle;
|
|
1273
|
+
};
|
|
1274
|
+
trackId: TrackId;
|
|
1275
|
+
} | {
|
|
1276
|
+
type: 'EDIT_CAPTION';
|
|
1277
|
+
captionId: CaptionId;
|
|
1278
|
+
trackId: TrackId;
|
|
1279
|
+
text?: string;
|
|
1280
|
+
language?: string;
|
|
1281
|
+
style?: Partial<CaptionStyle>;
|
|
1282
|
+
burnIn?: boolean;
|
|
1283
|
+
startFrame?: TimelineFrame;
|
|
1284
|
+
endFrame?: TimelineFrame;
|
|
1285
|
+
} | {
|
|
1286
|
+
type: 'DELETE_CAPTION';
|
|
1287
|
+
captionId: CaptionId;
|
|
1288
|
+
trackId: TrackId;
|
|
1289
|
+
} | {
|
|
1290
|
+
type: 'ADD_EFFECT';
|
|
1291
|
+
clipId: ClipId;
|
|
1292
|
+
effect: Effect;
|
|
1293
|
+
} | {
|
|
1294
|
+
type: 'REMOVE_EFFECT';
|
|
1295
|
+
clipId: ClipId;
|
|
1296
|
+
effectId: EffectId;
|
|
1297
|
+
} | {
|
|
1298
|
+
type: 'REORDER_EFFECT';
|
|
1299
|
+
clipId: ClipId;
|
|
1300
|
+
effectId: EffectId;
|
|
1301
|
+
newIndex: number;
|
|
1302
|
+
} | {
|
|
1303
|
+
type: 'SET_EFFECT_ENABLED';
|
|
1304
|
+
clipId: ClipId;
|
|
1305
|
+
effectId: EffectId;
|
|
1306
|
+
enabled: boolean;
|
|
1307
|
+
} | {
|
|
1308
|
+
type: 'SET_EFFECT_PARAM';
|
|
1309
|
+
clipId: ClipId;
|
|
1310
|
+
effectId: EffectId;
|
|
1311
|
+
key: string;
|
|
1312
|
+
value: number | string | boolean;
|
|
1313
|
+
} | {
|
|
1314
|
+
type: 'ADD_KEYFRAME';
|
|
1315
|
+
clipId: ClipId;
|
|
1316
|
+
effectId: EffectId;
|
|
1317
|
+
keyframe: Keyframe;
|
|
1318
|
+
} | {
|
|
1319
|
+
type: 'MOVE_KEYFRAME';
|
|
1320
|
+
clipId: ClipId;
|
|
1321
|
+
effectId: EffectId;
|
|
1322
|
+
keyframeId: KeyframeId;
|
|
1323
|
+
newFrame: TimelineFrame;
|
|
1324
|
+
} | {
|
|
1325
|
+
type: 'DELETE_KEYFRAME';
|
|
1326
|
+
clipId: ClipId;
|
|
1327
|
+
effectId: EffectId;
|
|
1328
|
+
keyframeId: KeyframeId;
|
|
1329
|
+
} | {
|
|
1330
|
+
type: 'SET_KEYFRAME_EASING';
|
|
1331
|
+
clipId: ClipId;
|
|
1332
|
+
effectId: EffectId;
|
|
1333
|
+
keyframeId: KeyframeId;
|
|
1334
|
+
easing: EasingCurve;
|
|
1335
|
+
} | {
|
|
1336
|
+
type: 'SET_CLIP_TRANSFORM';
|
|
1337
|
+
clipId: ClipId;
|
|
1338
|
+
transform: Partial<ClipTransform>;
|
|
1339
|
+
} | {
|
|
1340
|
+
type: 'SET_AUDIO_PROPERTIES';
|
|
1341
|
+
clipId: ClipId;
|
|
1342
|
+
properties: Partial<AudioProperties>;
|
|
1343
|
+
} | {
|
|
1344
|
+
type: 'ADD_TRANSITION';
|
|
1345
|
+
clipId: ClipId;
|
|
1346
|
+
transition: Transition;
|
|
1347
|
+
} | {
|
|
1348
|
+
type: 'DELETE_TRANSITION';
|
|
1349
|
+
clipId: ClipId;
|
|
1350
|
+
} | {
|
|
1351
|
+
type: 'SET_TRANSITION_DURATION';
|
|
1352
|
+
clipId: ClipId;
|
|
1353
|
+
durationFrames: number;
|
|
1354
|
+
} | {
|
|
1355
|
+
type: 'SET_TRANSITION_ALIGNMENT';
|
|
1356
|
+
clipId: ClipId;
|
|
1357
|
+
alignment: TransitionAlignment;
|
|
1358
|
+
} | {
|
|
1359
|
+
type: 'LINK_CLIPS';
|
|
1360
|
+
linkGroup: LinkGroup;
|
|
1361
|
+
} | {
|
|
1362
|
+
type: 'UNLINK_CLIPS';
|
|
1363
|
+
linkGroupId: LinkGroupId;
|
|
1364
|
+
} | {
|
|
1365
|
+
type: 'ADD_TRACK_GROUP';
|
|
1366
|
+
trackGroup: TrackGroup;
|
|
1367
|
+
} | {
|
|
1368
|
+
type: 'DELETE_TRACK_GROUP';
|
|
1369
|
+
trackGroupId: TrackGroupId;
|
|
1370
|
+
} | {
|
|
1371
|
+
type: 'SET_TRACK_BLEND_MODE';
|
|
1372
|
+
trackId: TrackId;
|
|
1373
|
+
blendMode: string;
|
|
1374
|
+
} | {
|
|
1375
|
+
type: 'SET_TRACK_OPACITY';
|
|
1376
|
+
trackId: TrackId;
|
|
1377
|
+
opacity: number;
|
|
1378
|
+
};
|
|
1379
|
+
/**
|
|
1380
|
+
* Transaction — an atomic, labeled batch of OperationPrimitives.
|
|
1381
|
+
*
|
|
1382
|
+
* All primitives in a Transaction are validated before any are applied.
|
|
1383
|
+
* If one fails, none are applied. This is the all-or-nothing rule.
|
|
1384
|
+
*/
|
|
1385
|
+
type Transaction = {
|
|
1386
|
+
readonly id: string;
|
|
1387
|
+
readonly label: string;
|
|
1388
|
+
readonly timestamp: number;
|
|
1389
|
+
readonly operations: readonly OperationPrimitive[];
|
|
1390
|
+
};
|
|
1391
|
+
type RejectionReason = 'OVERLAP' | 'LOCKED_TRACK' | 'ASSET_MISSING' | 'TYPE_MISMATCH' | 'OUT_OF_BOUNDS' | 'MEDIA_BOUNDS_INVALID' | 'ASSET_IN_USE' | 'TRACK_NOT_EMPTY' | 'SPEED_INVALID' | 'INVARIANT_VIOLATED' | 'NOT_FOUND' | 'BEAT_GRID_EXISTS' | 'CLIP_NOT_FOUND' | 'DUPLICATE_EFFECT_ID' | 'EFFECT_NOT_FOUND' | 'EFFECT_INDEX_OUT_OF_RANGE' | 'KEYFRAME_NOT_FOUND' | 'DUPLICATE_KEYFRAME_ID' | 'INVALID_RANGE' | 'TRANSITION_NOT_FOUND' | 'LINK_GROUP_NOT_FOUND' | 'TRACK_GROUP_NOT_FOUND' | 'DUPLICATE_LINK_GROUP_ID' | 'DUPLICATE_TRACK_GROUP_ID' | 'INVALID_OPACITY' | 'TRACK_NOT_FOUND';
|
|
1392
|
+
type DispatchResult = {
|
|
1393
|
+
accepted: true;
|
|
1394
|
+
nextState: TimelineState;
|
|
1395
|
+
} | {
|
|
1396
|
+
accepted: false;
|
|
1397
|
+
reason: RejectionReason;
|
|
1398
|
+
message: string;
|
|
1399
|
+
};
|
|
1400
|
+
type ViolationType = 'OVERLAP' | 'MEDIA_BOUNDS_INVALID' | 'ASSET_MISSING' | 'TRACK_TYPE_MISMATCH' | 'CLIP_BEYOND_TIMELINE' | 'TRACK_NOT_SORTED' | 'DURATION_MISMATCH' | 'SPEED_INVALID' | 'SCHEMA_VERSION_MISMATCH' | 'MARKER_OUT_OF_BOUNDS' | 'IN_OUT_INVALID' | 'BEAT_GRID_INVALID' | 'CAPTION_OUT_OF_BOUNDS' | 'CAPTION_OVERLAP' | 'EFFECT_NOT_FOUND' | 'KEYFRAME_NOT_FOUND' | 'KEYFRAME_ORDER_VIOLATION' | 'EFFECT_INDEX_OUT_OF_RANGE' | 'INVALID_RENDER_STAGE' | 'TRACK_GROUP_NOT_FOUND' | 'INVALID_OPACITY' | 'INVALID_RANGE' | 'LINK_GROUP_NOT_FOUND';
|
|
1401
|
+
type InvariantViolation = {
|
|
1402
|
+
readonly type: ViolationType;
|
|
1403
|
+
readonly entityId: string;
|
|
1404
|
+
readonly message: string;
|
|
1405
|
+
};
|
|
1406
|
+
|
|
1407
|
+
/**
|
|
1408
|
+
* DISPATCHER — Phase 0 compliant
|
|
1409
|
+
*
|
|
1410
|
+
* The ONLY entry point for mutating TimelineState.
|
|
1411
|
+
* Validates first, applies atomically, checks invariants.
|
|
1412
|
+
*
|
|
1413
|
+
* Algorithm:
|
|
1414
|
+
* 1. For each operation: run per-primitive validator → reject immediately on failure
|
|
1415
|
+
* 2. Apply all operations sequentially to get proposedState
|
|
1416
|
+
* 3. Run checkInvariants(proposedState) → reject on any violation
|
|
1417
|
+
* 4. Bump timeline.version by 1 and return accepted
|
|
1418
|
+
*
|
|
1419
|
+
* RULE: If one primitive fails, zero primitives are applied.
|
|
1420
|
+
*/
|
|
1421
|
+
|
|
1422
|
+
declare function dispatch(state: TimelineState, transaction: Transaction): DispatchResult;
|
|
1423
|
+
|
|
1424
|
+
/**
|
|
1425
|
+
* INVARIANT CHECKER — Phase 0 compliant
|
|
1426
|
+
*
|
|
1427
|
+
* The most critical file in the engine.
|
|
1428
|
+
* checkInvariants() runs after every proposed state change inside the Dispatcher.
|
|
1429
|
+
* Zero violations is the only acceptable result in tests and at commit time.
|
|
1430
|
+
*
|
|
1431
|
+
* RULE: Run checkInvariants in EVERY test after every state mutation.
|
|
1432
|
+
*/
|
|
1433
|
+
|
|
1434
|
+
declare function checkInvariants(state: TimelineState): InvariantViolation[];
|
|
1435
|
+
|
|
1436
|
+
/**
|
|
1437
|
+
* HISTORY ENGINE
|
|
1438
|
+
*
|
|
1439
|
+
* Snapshot-based undo/redo system for timeline state.
|
|
1440
|
+
*
|
|
1441
|
+
* WHAT IS THE HISTORY ENGINE?
|
|
1442
|
+
* - Stores immutable snapshots of timeline state
|
|
1443
|
+
* - Provides undo/redo functionality
|
|
1444
|
+
* - Prevents state corruption
|
|
1445
|
+
*
|
|
1446
|
+
* HOW IT WORKS:
|
|
1447
|
+
* - past: Array of previous states
|
|
1448
|
+
* - present: Current state
|
|
1449
|
+
* - future: Array of states that can be redone
|
|
1450
|
+
*
|
|
1451
|
+
* WHY SNAPSHOTS?
|
|
1452
|
+
* - Simple and reliable (no complex diffing)
|
|
1453
|
+
* - Guaranteed to restore exact state
|
|
1454
|
+
* - No risk of partial corruption
|
|
1455
|
+
* - Easy to implement and test
|
|
1456
|
+
*
|
|
1457
|
+
* USAGE:
|
|
1458
|
+
* ```typescript
|
|
1459
|
+
* let history = createHistory(initialState);
|
|
1460
|
+
* history = pushHistory(history, newState);
|
|
1461
|
+
* history = undo(history);
|
|
1462
|
+
* history = redo(history);
|
|
1463
|
+
* ```
|
|
1464
|
+
*
|
|
1465
|
+
* ALL FUNCTIONS ARE PURE:
|
|
1466
|
+
* - Take history as input
|
|
1467
|
+
* - Return new history as output
|
|
1468
|
+
* - Never mutate input
|
|
1469
|
+
*/
|
|
1470
|
+
|
|
1471
|
+
/**
|
|
1472
|
+
* HistoryState - The history container
|
|
1473
|
+
*
|
|
1474
|
+
* Contains:
|
|
1475
|
+
* - past: Array of previous states (oldest first)
|
|
1476
|
+
* - present: Current state
|
|
1477
|
+
* - future: Array of states that can be redone (newest first)
|
|
1478
|
+
* - limit: Maximum number of past states to keep
|
|
1479
|
+
*/
|
|
1480
|
+
interface HistoryState {
|
|
1481
|
+
past: TimelineState[];
|
|
1482
|
+
present: TimelineState;
|
|
1483
|
+
future: TimelineState[];
|
|
1484
|
+
limit: number;
|
|
1485
|
+
}
|
|
1486
|
+
/**
|
|
1487
|
+
* Create a new history state
|
|
1488
|
+
*
|
|
1489
|
+
* @param initialState - Initial timeline state
|
|
1490
|
+
* @param limit - Maximum number of past states to keep (default: 50)
|
|
1491
|
+
* @returns A new HistoryState
|
|
1492
|
+
*/
|
|
1493
|
+
declare function createHistory(initialState: TimelineState, limit?: number): HistoryState;
|
|
1494
|
+
/**
|
|
1495
|
+
* Push a new state to history
|
|
1496
|
+
*
|
|
1497
|
+
* Moves current state to past, sets new state as present,
|
|
1498
|
+
* and clears future (can't redo after new action).
|
|
1499
|
+
*
|
|
1500
|
+
* @param history - Current history state
|
|
1501
|
+
* @param newState - New timeline state to push
|
|
1502
|
+
* @returns New history state with new state pushed
|
|
1503
|
+
*/
|
|
1504
|
+
declare function pushHistory(history: HistoryState, newState: TimelineState): HistoryState;
|
|
1505
|
+
/**
|
|
1506
|
+
* Undo the last action
|
|
1507
|
+
*
|
|
1508
|
+
* Moves current state to future, pops last state from past
|
|
1509
|
+
* and sets it as present.
|
|
1510
|
+
*
|
|
1511
|
+
* @param history - Current history state
|
|
1512
|
+
* @returns New history state with undo applied
|
|
1513
|
+
*/
|
|
1514
|
+
declare function undo(history: HistoryState): HistoryState;
|
|
1515
|
+
/**
|
|
1516
|
+
* Redo the last undone action
|
|
1517
|
+
*
|
|
1518
|
+
* Moves current state to past, pops first state from future
|
|
1519
|
+
* and sets it as present.
|
|
1520
|
+
*
|
|
1521
|
+
* @param history - Current history state
|
|
1522
|
+
* @returns New history state with redo applied
|
|
1523
|
+
*/
|
|
1524
|
+
declare function redo(history: HistoryState): HistoryState;
|
|
1525
|
+
/**
|
|
1526
|
+
* Check if undo is available
|
|
1527
|
+
*
|
|
1528
|
+
* @param history - Current history state
|
|
1529
|
+
* @returns true if undo is available
|
|
1530
|
+
*/
|
|
1531
|
+
declare function canUndo(history: HistoryState): boolean;
|
|
1532
|
+
/**
|
|
1533
|
+
* Check if redo is available
|
|
1534
|
+
*
|
|
1535
|
+
* @param history - Current history state
|
|
1536
|
+
* @returns true if redo is available
|
|
1537
|
+
*/
|
|
1538
|
+
declare function canRedo(history: HistoryState): boolean;
|
|
1539
|
+
/**
|
|
1540
|
+
* Get the current state from history
|
|
1541
|
+
*
|
|
1542
|
+
* @param history - Current history state
|
|
1543
|
+
* @returns The current timeline state
|
|
1544
|
+
*/
|
|
1545
|
+
declare function getCurrentState(history: HistoryState): TimelineState;
|
|
1546
|
+
|
|
1547
|
+
/**
|
|
1548
|
+
* SNAP INDEX — Phase 1
|
|
1549
|
+
*
|
|
1550
|
+
* Pure functions. Zero React/DOM imports. Zero mutation.
|
|
1551
|
+
*
|
|
1552
|
+
* Phase 1 snap sources: ClipStart, ClipEnd, Playhead.
|
|
1553
|
+
* Phase 2 will add: Marker, InPoint, OutPoint.
|
|
1554
|
+
* Phase 3 will add: BeatGrid.
|
|
1555
|
+
*
|
|
1556
|
+
* Priority table (do not change values):
|
|
1557
|
+
* Marker: 100
|
|
1558
|
+
* InPoint: 90
|
|
1559
|
+
* OutPoint: 90
|
|
1560
|
+
* ClipStart: 80
|
|
1561
|
+
* ClipEnd: 80
|
|
1562
|
+
* Playhead: 70
|
|
1563
|
+
* BeatGrid: 50
|
|
1564
|
+
*/
|
|
1565
|
+
|
|
1566
|
+
/**
|
|
1567
|
+
* All snap point sources across phases.
|
|
1568
|
+
* Defined in full now so SnapPoint & allowedTypes filters are stable.
|
|
1569
|
+
*/
|
|
1570
|
+
type SnapPointType = 'ClipStart' | 'ClipEnd' | 'Playhead' | 'Marker' | 'InPoint' | 'OutPoint' | 'BeatGrid';
|
|
1571
|
+
type SnapPoint = {
|
|
1572
|
+
readonly frame: TimelineFrame;
|
|
1573
|
+
readonly type: SnapPointType;
|
|
1574
|
+
readonly priority: number;
|
|
1575
|
+
readonly trackId: TrackId | null;
|
|
1576
|
+
readonly sourceId: string;
|
|
1577
|
+
};
|
|
1578
|
+
type SnapIndex = {
|
|
1579
|
+
readonly points: readonly SnapPoint[];
|
|
1580
|
+
readonly builtAt: number;
|
|
1581
|
+
readonly enabled: boolean;
|
|
1582
|
+
};
|
|
1583
|
+
/**
|
|
1584
|
+
* Build a SnapIndex from committed state + playhead position.
|
|
1585
|
+
*
|
|
1586
|
+
* RULE: Call via queueMicrotask after accepted dispatch.
|
|
1587
|
+
* Never call during a drag (pointer move).
|
|
1588
|
+
*
|
|
1589
|
+
* Phase 1 sources pulled (in order):
|
|
1590
|
+
* 1. ClipStart + ClipEnd from every clip on every track
|
|
1591
|
+
* 2. Playhead position (trackId = null)
|
|
1592
|
+
*/
|
|
1593
|
+
declare function buildSnapIndex(state: TimelineState, playheadFrame: TimelineFrame, enabled?: boolean): SnapIndex;
|
|
1594
|
+
/**
|
|
1595
|
+
* Find the highest-priority snap candidate within radiusFrames.
|
|
1596
|
+
*
|
|
1597
|
+
* Returns null when:
|
|
1598
|
+
* - index.enabled is false
|
|
1599
|
+
* - no point is within radiusFrames of frame
|
|
1600
|
+
*
|
|
1601
|
+
* Tiebreak (equidistant candidates): highest priority wins.
|
|
1602
|
+
* Second tiebreak (equal priority): first in sorted order.
|
|
1603
|
+
*
|
|
1604
|
+
* @param exclude sourceIds to skip (e.g. the clip being dragged)
|
|
1605
|
+
* @param allowedTypes if provided, only consider points of these types
|
|
1606
|
+
*/
|
|
1607
|
+
declare function nearest(index: SnapIndex, frame: TimelineFrame, radiusFrames: number, exclude?: readonly string[], allowedTypes?: readonly SnapPointType[]): SnapPoint | null;
|
|
1608
|
+
/**
|
|
1609
|
+
* Return a new SnapIndex with enabled toggled.
|
|
1610
|
+
* Does NOT rebuild points — pure field update.
|
|
1611
|
+
*/
|
|
1612
|
+
declare function toggleSnap(index: SnapIndex, enabled: boolean): SnapIndex;
|
|
1613
|
+
|
|
1614
|
+
/**
|
|
1615
|
+
* TOOL CONTRACT TYPES — Phase 1
|
|
1616
|
+
*
|
|
1617
|
+
* Zero implementation. Zero imports from React or DOM.
|
|
1618
|
+
* Every ITool must satisfy this interface exactly.
|
|
1619
|
+
*
|
|
1620
|
+
* RULES (from ITOOL_CONTRACT.md):
|
|
1621
|
+
* - onPointerMove NEVER calls dispatch
|
|
1622
|
+
* - onPointerUp NEVER mutates instance state
|
|
1623
|
+
* - onKeyDown, onKeyUp, onCancel are REQUIRED — implement as no-ops if unused
|
|
1624
|
+
*/
|
|
1625
|
+
|
|
1626
|
+
type ToolId = string & {
|
|
1627
|
+
readonly __brand: 'ToolId';
|
|
1628
|
+
};
|
|
1629
|
+
declare function toToolId(s: string): ToolId;
|
|
1630
|
+
/** Keyboard modifier state — available on ToolContext so getCursor() can
|
|
1631
|
+
* react to held keys even when no pointer event is firing. */
|
|
1632
|
+
type Modifiers = {
|
|
1633
|
+
readonly shift: boolean;
|
|
1634
|
+
readonly alt: boolean;
|
|
1635
|
+
readonly ctrl: boolean;
|
|
1636
|
+
readonly meta: boolean;
|
|
1637
|
+
};
|
|
1638
|
+
/** Normalised pointer event in frame-space.
|
|
1639
|
+
* ToolRouter populates clipId via hit-test — tools never recompute it. */
|
|
1640
|
+
type TimelinePointerEvent = {
|
|
1641
|
+
readonly frame: TimelineFrame;
|
|
1642
|
+
readonly trackId: TrackId | null;
|
|
1643
|
+
readonly clipId: ClipId | null;
|
|
1644
|
+
readonly x: number;
|
|
1645
|
+
readonly y: number;
|
|
1646
|
+
readonly buttons: number;
|
|
1647
|
+
readonly shiftKey: boolean;
|
|
1648
|
+
readonly altKey: boolean;
|
|
1649
|
+
readonly metaKey: boolean;
|
|
1650
|
+
};
|
|
1651
|
+
type TimelineKeyEvent = {
|
|
1652
|
+
readonly key: string;
|
|
1653
|
+
readonly code: string;
|
|
1654
|
+
readonly shiftKey: boolean;
|
|
1655
|
+
readonly altKey: boolean;
|
|
1656
|
+
readonly metaKey: boolean;
|
|
1657
|
+
readonly ctrlKey: boolean;
|
|
1658
|
+
/** True when key is held and OS is firing repeated keydowns. */
|
|
1659
|
+
readonly repeat?: boolean;
|
|
1660
|
+
};
|
|
1661
|
+
/** Pixel + frame region swept by a rubber-band (marquee) selection drag.
|
|
1662
|
+
* Populated by SelectionTool during rubber-band drags. */
|
|
1663
|
+
type RubberBandRegion = {
|
|
1664
|
+
readonly startFrame: TimelineFrame;
|
|
1665
|
+
readonly endFrame: TimelineFrame;
|
|
1666
|
+
readonly startY: number;
|
|
1667
|
+
readonly endY: number;
|
|
1668
|
+
};
|
|
1669
|
+
/** Ghost state produced by onPointerMove.
|
|
1670
|
+
* isProvisional: true is a compile-time discriminant so resolveClip()
|
|
1671
|
+
* can distinguish provisional from committed Clip[] arrays. */
|
|
1672
|
+
type ProvisionalState = {
|
|
1673
|
+
readonly clips: readonly Clip[];
|
|
1674
|
+
readonly rubberBand?: RubberBandRegion;
|
|
1675
|
+
readonly isProvisional: true;
|
|
1676
|
+
};
|
|
1677
|
+
/** Injected by TimelineEngine on every event call.
|
|
1678
|
+
* Tools never import TimelineEngine. They never call dispatch() directly. */
|
|
1679
|
+
type ToolContext = {
|
|
1680
|
+
readonly state: TimelineState;
|
|
1681
|
+
readonly snapIndex: SnapIndex;
|
|
1682
|
+
readonly pixelsPerFrame: number;
|
|
1683
|
+
/** Current modifier key state — updates on every pointer/key event. */
|
|
1684
|
+
readonly modifiers: Modifiers;
|
|
1685
|
+
/** Convert a client-pixel x-position to a TimelineFrame. */
|
|
1686
|
+
readonly frameAtX: (x: number) => TimelineFrame;
|
|
1687
|
+
/** Return the TrackId whose row contains client-pixel y, or null. */
|
|
1688
|
+
readonly trackAtY: (y: number) => TrackId | null;
|
|
1689
|
+
/** Query snap and return the snapped frame (or original if no hit).
|
|
1690
|
+
* Handles enabled/disabled, radius, exclusion, and type filter internally.
|
|
1691
|
+
* Tools never see radiusFrames or the enabled flag. */
|
|
1692
|
+
readonly snap: (frame: TimelineFrame, exclude?: readonly string[], allowedTypes?: readonly SnapPointType[]) => TimelineFrame;
|
|
1693
|
+
};
|
|
1694
|
+
interface ITool {
|
|
1695
|
+
readonly id: ToolId;
|
|
1696
|
+
/** Single-character keyboard shortcut, e.g. 'v', 'b', 'r'. Empty string = no shortcut. */
|
|
1697
|
+
readonly shortcutKey: string;
|
|
1698
|
+
/** Return the CSS cursor string for the current tool + modifier state.
|
|
1699
|
+
* Called on every pointermove — must be cheap. */
|
|
1700
|
+
getCursor(ctx: ToolContext): string;
|
|
1701
|
+
/** Return the SnapPointType categories this tool snaps to.
|
|
1702
|
+
* Used by ctx.snap() to filter the snap index automatically. */
|
|
1703
|
+
getSnapCandidateTypes(): readonly SnapPointType[];
|
|
1704
|
+
onPointerDown(event: TimelinePointerEvent, ctx: ToolContext): void;
|
|
1705
|
+
/** Return ProvisionalState for ghost rendering.
|
|
1706
|
+
* MUST NOT call dispatch. MUST NOT call engine methods. */
|
|
1707
|
+
onPointerMove(event: TimelinePointerEvent, ctx: ToolContext): ProvisionalState | null;
|
|
1708
|
+
/** Return a Transaction to commit, or null if this gesture produces no edit.
|
|
1709
|
+
* MUST NOT mutate any instance state. */
|
|
1710
|
+
onPointerUp(event: TimelinePointerEvent, ctx: ToolContext): Transaction | null;
|
|
1711
|
+
/** Handle a keydown — return a Transaction or null.
|
|
1712
|
+
* Required — implement as `return null` if unused. */
|
|
1713
|
+
onKeyDown(event: TimelineKeyEvent, ctx: ToolContext): Transaction | null;
|
|
1714
|
+
/** Handle a keyup — no return value.
|
|
1715
|
+
* Required — implement as no-op if unused. */
|
|
1716
|
+
onKeyUp(event: TimelineKeyEvent, ctx: ToolContext): void;
|
|
1717
|
+
/** Called when a gesture is interrupted (Escape, tool switch mid-drag).
|
|
1718
|
+
* Required — implement as no-op if unused. */
|
|
1719
|
+
onCancel(): void;
|
|
1720
|
+
}
|
|
1721
|
+
|
|
1722
|
+
/**
|
|
1723
|
+
* TOOL REGISTRY — Phase 1
|
|
1724
|
+
*
|
|
1725
|
+
* Pure functions. No classes. No React. No state mutation.
|
|
1726
|
+
*
|
|
1727
|
+
* ToolRegistry is immutable data — activateTool returns a NEW registry.
|
|
1728
|
+
* The active tool lives here, not on TimelineEngine, keeping the engine thin.
|
|
1729
|
+
*
|
|
1730
|
+
* RULES:
|
|
1731
|
+
* - activateTool calls outgoing.onCancel() before switching
|
|
1732
|
+
* - activateTool throws on unknown id (programmer error, never user error)
|
|
1733
|
+
* - NoOpTool is the canonical do-nothing ITool (test double + startup default)
|
|
1734
|
+
*/
|
|
1735
|
+
|
|
1736
|
+
type ToolRegistry = {
|
|
1737
|
+
readonly tools: ReadonlyMap<ToolId, ITool>;
|
|
1738
|
+
readonly activeToolId: ToolId;
|
|
1739
|
+
};
|
|
1740
|
+
/**
|
|
1741
|
+
* Create an initial registry from an array of tools.
|
|
1742
|
+
*
|
|
1743
|
+
* @throws if defaultId is not present in the tools array
|
|
1744
|
+
*/
|
|
1745
|
+
declare function createRegistry(tools: readonly ITool[], defaultId: ToolId): ToolRegistry;
|
|
1746
|
+
/**
|
|
1747
|
+
* Activate a new tool.
|
|
1748
|
+
*
|
|
1749
|
+
* Steps (must run in order):
|
|
1750
|
+
* 1. Call outgoing tool's onCancel() — cleans up any in-progress drag state
|
|
1751
|
+
* 2. Validate that the new id exists in the registry
|
|
1752
|
+
* 3. Return a new ToolRegistry with activeToolId updated
|
|
1753
|
+
*
|
|
1754
|
+
* @throws if id is not registered
|
|
1755
|
+
*/
|
|
1756
|
+
declare function activateTool(registry: ToolRegistry, id: ToolId): ToolRegistry;
|
|
1757
|
+
/**
|
|
1758
|
+
* Return the currently active ITool.
|
|
1759
|
+
* Never returns undefined — registry invariant guarantees activeToolId is registered.
|
|
1760
|
+
*/
|
|
1761
|
+
declare function getActiveTool(registry: ToolRegistry): ITool;
|
|
1762
|
+
/**
|
|
1763
|
+
* Return a new registry with the tool added.
|
|
1764
|
+
* If a tool with the same id already exists, it is replaced.
|
|
1765
|
+
* activeToolId is unchanged.
|
|
1766
|
+
*/
|
|
1767
|
+
declare function registerTool(registry: ToolRegistry, tool: ITool): ToolRegistry;
|
|
1768
|
+
/**
|
|
1769
|
+
* Satisfies ITool with no side effects.
|
|
1770
|
+
*
|
|
1771
|
+
* Use for:
|
|
1772
|
+
* - Test doubles (spread and override only the methods you need)
|
|
1773
|
+
* - Default active tool on engine startup
|
|
1774
|
+
* - ToolRouter smoke tests
|
|
1775
|
+
*
|
|
1776
|
+
* onCancel() is a deliberate no-op: NoOpTool has no drag state to clean up.
|
|
1777
|
+
* Real tools will clear instance variables there.
|
|
1778
|
+
*/
|
|
1779
|
+
declare const NoOpTool: ITool;
|
|
1780
|
+
|
|
1781
|
+
/**
|
|
1782
|
+
* PROVISIONAL MANAGER — Phase 1
|
|
1783
|
+
*
|
|
1784
|
+
* Manages ghost state during pointer drags.
|
|
1785
|
+
*
|
|
1786
|
+
* RULES (from ITOOL_CONTRACT.md):
|
|
1787
|
+
* - setProvisional / clearProvisional return NEW objects — never mutate
|
|
1788
|
+
* - resolveClip checks provisional first, then committed state
|
|
1789
|
+
* - The engine calls clearProvisional() BEFORE dispatching onPointerUp's tx
|
|
1790
|
+
* - Provisional updates trigger notify() so ghosts render immediately
|
|
1791
|
+
*
|
|
1792
|
+
* resolveClip priority:
|
|
1793
|
+
* 1. provisional.clips has a clip with this id → return ghost version
|
|
1794
|
+
* 2. clip exists in committed state → return committed
|
|
1795
|
+
* 3. clip absent from both (deleted mid-drag) → return undefined
|
|
1796
|
+
*/
|
|
1797
|
+
|
|
1798
|
+
type ProvisionalManager = {
|
|
1799
|
+
readonly current: ProvisionalState | null;
|
|
1800
|
+
};
|
|
1801
|
+
/** Create an empty provisional manager (current = null). */
|
|
1802
|
+
declare function createProvisionalManager(): ProvisionalManager;
|
|
1803
|
+
/** Return a new manager with current set to state.
|
|
1804
|
+
* Pure — never mutates the original manager. */
|
|
1805
|
+
declare function setProvisional(_manager: ProvisionalManager, state: ProvisionalState): ProvisionalManager;
|
|
1806
|
+
/** Return a new manager with current set to null.
|
|
1807
|
+
* Pure — never mutates the original manager. */
|
|
1808
|
+
declare function clearProvisional(_manager: ProvisionalManager): ProvisionalManager;
|
|
1809
|
+
/**
|
|
1810
|
+
* Resolve which version of a clip to render.
|
|
1811
|
+
*
|
|
1812
|
+
* Priority:
|
|
1813
|
+
* 1. If manager.current has a clip with this id → return provisional (ghost)
|
|
1814
|
+
* 2. Otherwise → search committed state
|
|
1815
|
+
* 3. If absent from both (clip deleted mid-drag) → return undefined
|
|
1816
|
+
*
|
|
1817
|
+
* Returns undefined if the clip has been deleted from committed state
|
|
1818
|
+
* and is not in provisional. Components must handle this:
|
|
1819
|
+
* const clip = useClip(id)
|
|
1820
|
+
* if (!clip) return null ← required, not optional
|
|
1821
|
+
*
|
|
1822
|
+
* Call site in useClip selector:
|
|
1823
|
+
* () => resolveClip(id, engine.getSnapshot(), engine.getProvisionalManager())
|
|
1824
|
+
*/
|
|
1825
|
+
declare function resolveClip(clipId: ClipId, state: TimelineState, manager: ProvisionalManager): Clip | undefined;
|
|
1826
|
+
|
|
1827
|
+
/**
|
|
1828
|
+
* MARKER SEARCH API — Phase 3 Step 2
|
|
1829
|
+
*
|
|
1830
|
+
* Pure functions. Search state.timeline.markers only.
|
|
1831
|
+
*/
|
|
1832
|
+
|
|
1833
|
+
/**
|
|
1834
|
+
* Returns markers whose color exactly matches the given string.
|
|
1835
|
+
*/
|
|
1836
|
+
declare function findMarkersByColor(state: TimelineState, color: string): Marker[];
|
|
1837
|
+
/**
|
|
1838
|
+
* Returns markers whose label contains the given string (case-insensitive).
|
|
1839
|
+
*/
|
|
1840
|
+
declare function findMarkersByLabel(state: TimelineState, label: string): Marker[];
|
|
1841
|
+
|
|
1842
|
+
/**
|
|
1843
|
+
* SUBTITLE IMPORT — Phase 3 Step 3
|
|
1844
|
+
*
|
|
1845
|
+
* Pure functions for parsing SRT/VTT into Caption[].
|
|
1846
|
+
* No file IO. No DOM. No external deps.
|
|
1847
|
+
*/
|
|
1848
|
+
|
|
1849
|
+
declare const defaultCaptionStyle: CaptionStyle;
|
|
1850
|
+
type SRTParseOptions = {
|
|
1851
|
+
language?: string;
|
|
1852
|
+
burnIn?: boolean;
|
|
1853
|
+
defaultStyle?: Partial<CaptionStyle>;
|
|
1854
|
+
};
|
|
1855
|
+
type VTTParseOptions = SRTParseOptions;
|
|
1856
|
+
declare function parseSRT(raw: string, fps: number, options?: SRTParseOptions): Caption[];
|
|
1857
|
+
declare function parseVTT(raw: string, fps: number, options?: VTTParseOptions): Caption[];
|
|
1858
|
+
declare function subtitleImportToOps(captions: Caption[], trackId: TrackId): OperationPrimitive[];
|
|
1859
|
+
|
|
1860
|
+
/**
|
|
1861
|
+
* TransitionTool — Phase 4 Step 4
|
|
1862
|
+
*
|
|
1863
|
+
* Drag from a clip's right edge to create or resize a transition.
|
|
1864
|
+
* Click on an existing transition area to delete it.
|
|
1865
|
+
*
|
|
1866
|
+
* RULES:
|
|
1867
|
+
* - onPointerMove never dispatches; returns ProvisionalState for preview
|
|
1868
|
+
* - onPointerUp never mutates instance state (capture-before-reset)
|
|
1869
|
+
* - Every instance variable reset in onCancel()
|
|
1870
|
+
*/
|
|
1871
|
+
|
|
1872
|
+
declare class TransitionTool implements ITool {
|
|
1873
|
+
readonly id: ToolId;
|
|
1874
|
+
readonly shortcutKey: string;
|
|
1875
|
+
private pendingClipId;
|
|
1876
|
+
private dragStartX;
|
|
1877
|
+
private pendingDeleteTransitionClipId;
|
|
1878
|
+
getCursor(_ctx: ToolContext): string;
|
|
1879
|
+
getSnapCandidateTypes(): readonly SnapPointType[];
|
|
1880
|
+
onPointerDown(event: TimelinePointerEvent, ctx: ToolContext): void;
|
|
1881
|
+
onPointerMove(event: TimelinePointerEvent, ctx: ToolContext): ProvisionalState | null;
|
|
1882
|
+
onPointerUp(event: TimelinePointerEvent, ctx: ToolContext): Transaction | null;
|
|
1883
|
+
onKeyDown(_event: TimelineKeyEvent, _ctx: ToolContext): Transaction | null;
|
|
1884
|
+
onKeyUp(_event: TimelineKeyEvent, _ctx: ToolContext): void;
|
|
1885
|
+
onCancel(): void;
|
|
1886
|
+
}
|
|
1887
|
+
|
|
1888
|
+
/**
|
|
1889
|
+
* KeyframeTool (Pen tool) — Phase 4 Step 4
|
|
1890
|
+
*
|
|
1891
|
+
* Click on a clip's effect lane to add a keyframe.
|
|
1892
|
+
* Click an existing keyframe to delete (via Delete key). Drag keyframe to move.
|
|
1893
|
+
*
|
|
1894
|
+
* RULES:
|
|
1895
|
+
* - onPointerMove never dispatches; returns ProvisionalState for preview
|
|
1896
|
+
* - onPointerUp never mutates instance state (capture-before-reset)
|
|
1897
|
+
* - Every instance variable reset in onCancel()
|
|
1898
|
+
*/
|
|
1899
|
+
|
|
1900
|
+
declare class KeyframeTool implements ITool {
|
|
1901
|
+
readonly id: ToolId;
|
|
1902
|
+
readonly shortcutKey: string;
|
|
1903
|
+
private draggingKeyframe;
|
|
1904
|
+
private activeClipId;
|
|
1905
|
+
private activeEffectId;
|
|
1906
|
+
private pendingAddKeyframe;
|
|
1907
|
+
getCursor(_ctx: ToolContext): string;
|
|
1908
|
+
getSnapCandidateTypes(): readonly SnapPointType[];
|
|
1909
|
+
onPointerDown(event: TimelinePointerEvent, ctx: ToolContext): void;
|
|
1910
|
+
onPointerMove(event: TimelinePointerEvent, ctx: ToolContext): ProvisionalState | null;
|
|
1911
|
+
onPointerUp(event: TimelinePointerEvent, ctx: ToolContext): Transaction | null;
|
|
1912
|
+
onKeyDown(event: TimelineKeyEvent, ctx: ToolContext): Transaction | null;
|
|
1913
|
+
onKeyUp(_event: TimelineKeyEvent, _ctx: ToolContext): void;
|
|
1914
|
+
onCancel(): void;
|
|
1915
|
+
}
|
|
1916
|
+
|
|
1917
|
+
/**
|
|
1918
|
+
* SerializationError — Phase 5 Step 1
|
|
1919
|
+
*
|
|
1920
|
+
* Thrown when deserialization or migration fails.
|
|
1921
|
+
*/
|
|
1922
|
+
|
|
1923
|
+
declare class SerializationError extends Error {
|
|
1924
|
+
readonly violations?: InvariantViolation[] | undefined;
|
|
1925
|
+
constructor(message: string, violations?: InvariantViolation[] | undefined);
|
|
1926
|
+
}
|
|
1927
|
+
|
|
1928
|
+
/**
|
|
1929
|
+
* Timeline serialization — Phase 5 Step 1
|
|
1930
|
+
*
|
|
1931
|
+
* Pure functions. No IO. No DOM. No external deps.
|
|
1932
|
+
* serializeTimeline / deserializeTimeline round-trip TimelineState.
|
|
1933
|
+
*/
|
|
1934
|
+
|
|
1935
|
+
/**
|
|
1936
|
+
* Serialize state to JSON string.
|
|
1937
|
+
* Converts assetRegistry Map to plain object for JSON compatibility.
|
|
1938
|
+
*/
|
|
1939
|
+
declare function serializeTimeline(state: TimelineState): string;
|
|
1940
|
+
/**
|
|
1941
|
+
* Parse JSON string, migrate to current schema, validate invariants.
|
|
1942
|
+
* Throws SerializationError on invalid JSON, missing schemaVersion,
|
|
1943
|
+
* unknown version, or invariant violations.
|
|
1944
|
+
*/
|
|
1945
|
+
declare function deserializeTimeline(raw: string): TimelineState;
|
|
1946
|
+
type AssetRemapCallback = (asset: FileAsset) => FileAsset;
|
|
1947
|
+
/**
|
|
1948
|
+
* Walk assetRegistry; for each FileAsset replace with remap(asset).
|
|
1949
|
+
* GeneratorAssets unchanged. Returns new state (immutable).
|
|
1950
|
+
*/
|
|
1951
|
+
declare function remapAssetPaths(state: TimelineState, remap: AssetRemapCallback): TimelineState;
|
|
1952
|
+
type OfflineAsset = {
|
|
1953
|
+
readonly assetId: AssetId;
|
|
1954
|
+
readonly path: string;
|
|
1955
|
+
readonly clipIds: readonly ClipId[];
|
|
1956
|
+
};
|
|
1957
|
+
/**
|
|
1958
|
+
* For each FileAsset where isOnline(asset) === false, collect clip IDs
|
|
1959
|
+
* that reference it. Host provides isOnline; core does not do filesystem checks.
|
|
1960
|
+
*/
|
|
1961
|
+
declare function findOfflineAssets(state: TimelineState, isOnline: (asset: FileAsset) => boolean): OfflineAsset[];
|
|
1962
|
+
|
|
1963
|
+
/**
|
|
1964
|
+
* OTIO export — Phase 5 Step 2
|
|
1965
|
+
*
|
|
1966
|
+
* Pure function. Produces OTIO JSON-serializable document from TimelineState.
|
|
1967
|
+
* No external OTIO library. Hand-rolled mapping.
|
|
1968
|
+
*/
|
|
1969
|
+
|
|
1970
|
+
type OTIORationalTime = {
|
|
1971
|
+
value: number;
|
|
1972
|
+
rate: number;
|
|
1973
|
+
};
|
|
1974
|
+
type OTIOTimeRange = {
|
|
1975
|
+
OTIO_SCHEMA: string;
|
|
1976
|
+
start_time: OTIORationalTime;
|
|
1977
|
+
duration: OTIORationalTime;
|
|
1978
|
+
};
|
|
1979
|
+
type OTIOExternalReference = {
|
|
1980
|
+
OTIO_SCHEMA: string;
|
|
1981
|
+
target_url: string;
|
|
1982
|
+
available_range: OTIOTimeRange;
|
|
1983
|
+
};
|
|
1984
|
+
type OTIOGeneratorReference = {
|
|
1985
|
+
OTIO_SCHEMA: string;
|
|
1986
|
+
generator_kind: string;
|
|
1987
|
+
};
|
|
1988
|
+
type OTIOMissingReference = {
|
|
1989
|
+
OTIO_SCHEMA: string;
|
|
1990
|
+
};
|
|
1991
|
+
type OTIOClip = {
|
|
1992
|
+
OTIO_SCHEMA: string;
|
|
1993
|
+
name: string;
|
|
1994
|
+
source_range: OTIOTimeRange;
|
|
1995
|
+
media_reference: OTIOExternalReference | OTIOGeneratorReference | OTIOMissingReference;
|
|
1996
|
+
effects?: OTIOEffect[];
|
|
1997
|
+
};
|
|
1998
|
+
type OTIOGap = {
|
|
1999
|
+
OTIO_SCHEMA: string;
|
|
2000
|
+
source_range: OTIOTimeRange;
|
|
2001
|
+
};
|
|
2002
|
+
type OTIOEffect = {
|
|
2003
|
+
OTIO_SCHEMA: string;
|
|
2004
|
+
name: string;
|
|
2005
|
+
effect_name: string;
|
|
2006
|
+
enabled: boolean;
|
|
2007
|
+
metadata: {
|
|
2008
|
+
params: readonly {
|
|
2009
|
+
key: string;
|
|
2010
|
+
value: number | string | boolean;
|
|
2011
|
+
}[];
|
|
2012
|
+
};
|
|
2013
|
+
};
|
|
2014
|
+
type OTIOTrack = {
|
|
2015
|
+
OTIO_SCHEMA: string;
|
|
2016
|
+
kind: string;
|
|
2017
|
+
children: (OTIOClip | OTIOGap)[];
|
|
2018
|
+
};
|
|
2019
|
+
type OTIOStack = {
|
|
2020
|
+
OTIO_SCHEMA: string;
|
|
2021
|
+
children: OTIOTrack[];
|
|
2022
|
+
};
|
|
2023
|
+
type OTIOMarker = {
|
|
2024
|
+
OTIO_SCHEMA: string;
|
|
2025
|
+
name: string;
|
|
2026
|
+
color: string;
|
|
2027
|
+
marked_range: OTIOTimeRange;
|
|
2028
|
+
};
|
|
2029
|
+
type OTIODocument = {
|
|
2030
|
+
OTIO_SCHEMA: string;
|
|
2031
|
+
name: string;
|
|
2032
|
+
global_start_time: OTIORationalTime;
|
|
2033
|
+
tracks: OTIOStack;
|
|
2034
|
+
markers: OTIOMarker[];
|
|
2035
|
+
};
|
|
2036
|
+
/**
|
|
2037
|
+
* Export TimelineState to an OTIO document (plain object).
|
|
2038
|
+
* Caller can JSON.stringify the result.
|
|
2039
|
+
*/
|
|
2040
|
+
declare function exportToOTIO(state: TimelineState): OTIODocument;
|
|
2041
|
+
|
|
2042
|
+
/**
|
|
2043
|
+
* OTIO import — Phase 5 Step 2
|
|
2044
|
+
*
|
|
2045
|
+
* Pure function. Builds TimelineState from OTIO document.
|
|
2046
|
+
* Throws SerializationError on invalid doc or invariant violations.
|
|
2047
|
+
*/
|
|
2048
|
+
|
|
2049
|
+
type OTIOImportOptions = {
|
|
2050
|
+
/** Override fps; default: from doc global_start_time.rate or first clip rate, fallback 30 */
|
|
2051
|
+
fps?: number;
|
|
2052
|
+
/** Override timeline name */
|
|
2053
|
+
name?: string;
|
|
2054
|
+
};
|
|
2055
|
+
declare function importFromOTIO(doc: unknown, options?: OTIOImportOptions): TimelineState;
|
|
2056
|
+
|
|
2057
|
+
/**
|
|
2058
|
+
* CMX3600 EDL export — Phase 5 Step 3
|
|
2059
|
+
*
|
|
2060
|
+
* Single video track only. Pure function, returns string.
|
|
2061
|
+
* No IO.
|
|
2062
|
+
*/
|
|
2063
|
+
|
|
2064
|
+
type EDLExportOptions = {
|
|
2065
|
+
/** Default: state.timeline.name */
|
|
2066
|
+
title?: string;
|
|
2067
|
+
/** Default: false (non-drop). True = 29.97 drop frame only. */
|
|
2068
|
+
dropFrame?: boolean;
|
|
2069
|
+
/** Which video track to export. Default: 0 (first video track). */
|
|
2070
|
+
trackIndex?: number;
|
|
2071
|
+
};
|
|
2072
|
+
/**
|
|
2073
|
+
* Convert frame count to timecode string.
|
|
2074
|
+
* dropFrame true: only 29.97fps uses real drop-frame; others fall back to non-drop.
|
|
2075
|
+
*/
|
|
2076
|
+
declare function frameToTimecode(frame: number, fps: number, dropFrame: boolean): string;
|
|
2077
|
+
/**
|
|
2078
|
+
* FileAsset: filename without extension, truncate 8 chars, uppercase.
|
|
2079
|
+
* GeneratorAsset or undefined: "AX".
|
|
2080
|
+
*/
|
|
2081
|
+
declare function reelName(asset: Asset | undefined): string;
|
|
2082
|
+
/**
|
|
2083
|
+
* Export a single video track to CMX3600 EDL string.
|
|
2084
|
+
* trackIndex selects which video track (default 0).
|
|
2085
|
+
*/
|
|
2086
|
+
declare function exportToEDL(state: TimelineState, options?: EDLExportOptions): string;
|
|
2087
|
+
|
|
2088
|
+
/**
|
|
2089
|
+
* AAF XML export — Phase 5 Step 4
|
|
2090
|
+
*
|
|
2091
|
+
* Simplified AAF XML representation for Avid interchange.
|
|
2092
|
+
* Pure function, returns string. No IO.
|
|
2093
|
+
*/
|
|
2094
|
+
|
|
2095
|
+
type AAFExportOptions = {
|
|
2096
|
+
/** Default: timeline name */
|
|
2097
|
+
projectName?: string;
|
|
2098
|
+
/** Default: derived from state (e.g. 30 → "30/1") */
|
|
2099
|
+
frameRate?: string;
|
|
2100
|
+
};
|
|
2101
|
+
declare function exportToAAF(state: TimelineState, options?: AAFExportOptions): string;
|
|
2102
|
+
|
|
2103
|
+
/**
|
|
2104
|
+
* FCP XML (FCPX) export — Phase 5 Step 4
|
|
2105
|
+
*
|
|
2106
|
+
* Final Cut Pro XML 1.10 interchange. Pure function, returns string. No IO.
|
|
2107
|
+
*/
|
|
2108
|
+
|
|
2109
|
+
type FCPXMLExportOptions = {
|
|
2110
|
+
libraryName?: string;
|
|
2111
|
+
eventName?: string;
|
|
2112
|
+
};
|
|
2113
|
+
/**
|
|
2114
|
+
* FCPXML rational time: "0s" or "{frames}/{fps}s".
|
|
2115
|
+
*/
|
|
2116
|
+
declare function toFCPTime(frames: number, fps: number): string;
|
|
2117
|
+
declare function exportToFCPXML(state: TimelineState, options?: FCPXMLExportOptions): string;
|
|
2118
|
+
|
|
2119
|
+
/**
|
|
2120
|
+
* PROJECT MODEL — Phase 5 Step 5
|
|
2121
|
+
*
|
|
2122
|
+
* A Project is a multi-timeline container with a shared bin hierarchy.
|
|
2123
|
+
* Pure types + factories only. No IO.
|
|
2124
|
+
*/
|
|
2125
|
+
|
|
2126
|
+
type ProjectId = string & {
|
|
2127
|
+
readonly __brand: 'ProjectId';
|
|
2128
|
+
};
|
|
2129
|
+
declare function toProjectId(s: string): ProjectId;
|
|
2130
|
+
type BinId = string & {
|
|
2131
|
+
readonly __brand: 'BinId';
|
|
2132
|
+
};
|
|
2133
|
+
declare function toBinId(s: string): BinId;
|
|
2134
|
+
type BinItem = {
|
|
2135
|
+
readonly kind: 'asset';
|
|
2136
|
+
readonly assetId: AssetId;
|
|
2137
|
+
} | {
|
|
2138
|
+
readonly kind: 'sequence';
|
|
2139
|
+
readonly timelineId: string;
|
|
2140
|
+
} | {
|
|
2141
|
+
readonly kind: 'bin';
|
|
2142
|
+
readonly binId: BinId;
|
|
2143
|
+
};
|
|
2144
|
+
type Bin = {
|
|
2145
|
+
readonly id: BinId;
|
|
2146
|
+
readonly label: string;
|
|
2147
|
+
readonly parentId: BinId | null;
|
|
2148
|
+
readonly items: readonly BinItem[];
|
|
2149
|
+
readonly color?: string;
|
|
2150
|
+
};
|
|
2151
|
+
declare function createBin(id: BinId, label: string, parentId?: BinId | null): Bin;
|
|
2152
|
+
type Project = {
|
|
2153
|
+
readonly id: ProjectId;
|
|
2154
|
+
readonly name: string;
|
|
2155
|
+
readonly timelines: readonly TimelineState[];
|
|
2156
|
+
readonly bins: readonly Bin[];
|
|
2157
|
+
readonly rootBinIds: readonly BinId[];
|
|
2158
|
+
readonly createdAt: number;
|
|
2159
|
+
readonly updatedAt: number;
|
|
2160
|
+
readonly schemaVersion: number;
|
|
2161
|
+
};
|
|
2162
|
+
declare function createProject(id: ProjectId, name: string, timelines?: readonly TimelineState[]): Project;
|
|
2163
|
+
|
|
2164
|
+
declare function addTimeline(project: Project, state: TimelineState): Project;
|
|
2165
|
+
declare function removeTimeline(project: Project, timelineId: string): Project;
|
|
2166
|
+
declare function addBin(project: Project, bin: Bin): Project;
|
|
2167
|
+
declare function removeBin(project: Project, binId: BinId): Project;
|
|
2168
|
+
declare function addItemToBin(project: Project, binId: BinId, item: BinItem): Project;
|
|
2169
|
+
declare function removeItemFromBin(project: Project, binId: BinId, item: BinItem): Project;
|
|
2170
|
+
declare function moveItemBetweenBins(project: Project, fromBinId: BinId, toBinId: BinId, item: BinItem): Project;
|
|
2171
|
+
|
|
2172
|
+
/**
|
|
2173
|
+
* Project serialization — Phase 5 Step 5
|
|
2174
|
+
*
|
|
2175
|
+
* Pure functions. No IO. Uses timeline migrate() + checkInvariants().
|
|
2176
|
+
*/
|
|
2177
|
+
|
|
2178
|
+
declare function serializeProject(project: Project): string;
|
|
2179
|
+
declare function deserializeProject(raw: string): Project;
|
|
2180
|
+
|
|
2181
|
+
/**
|
|
2182
|
+
* Playhead types — Phase 6 Step 1 + Step 5
|
|
2183
|
+
*
|
|
2184
|
+
* Playback position and quality. No DOM deps.
|
|
2185
|
+
*/
|
|
2186
|
+
|
|
2187
|
+
type PlaybackRate = number;
|
|
2188
|
+
type PlaybackQuality = 'full' | 'half' | 'quarter' | 'proxy';
|
|
2189
|
+
type LoopRegion = {
|
|
2190
|
+
readonly startFrame: TimelineFrame;
|
|
2191
|
+
readonly endFrame: TimelineFrame;
|
|
2192
|
+
};
|
|
2193
|
+
type PlayheadState = {
|
|
2194
|
+
readonly currentFrame: TimelineFrame;
|
|
2195
|
+
readonly isPlaying: boolean;
|
|
2196
|
+
readonly playbackRate: PlaybackRate;
|
|
2197
|
+
readonly quality: PlaybackQuality;
|
|
2198
|
+
readonly durationFrames: number;
|
|
2199
|
+
readonly fps: number;
|
|
2200
|
+
readonly loopRegion: LoopRegion | null;
|
|
2201
|
+
readonly prerollFrames: number;
|
|
2202
|
+
readonly postrollFrames: number;
|
|
2203
|
+
};
|
|
2204
|
+
type PlayheadEventType = 'play' | 'pause' | 'seek' | 'loop' | 'frame-dropped' | 'ended' | 'loop-point';
|
|
2205
|
+
type PlayheadEvent = {
|
|
2206
|
+
readonly type: PlayheadEventType;
|
|
2207
|
+
readonly frame: TimelineFrame;
|
|
2208
|
+
readonly data?: unknown;
|
|
2209
|
+
};
|
|
2210
|
+
type PlayheadListener = (event: PlayheadEvent) => void;
|
|
2211
|
+
/** Return type of PlayheadController.on() — call to unsubscribe. */
|
|
2212
|
+
type PlayheadUnsubscribe = () => void;
|
|
2213
|
+
|
|
2214
|
+
/**
|
|
2215
|
+
* Clock abstraction — Phase 6 Step 1
|
|
2216
|
+
*
|
|
2217
|
+
* Allows PlayheadController to run without real rAF (swapped for mock in tests).
|
|
2218
|
+
*/
|
|
2219
|
+
type ClockCallback = (timestamp: number) => void;
|
|
2220
|
+
type Clock = {
|
|
2221
|
+
requestFrame: (cb: ClockCallback) => number;
|
|
2222
|
+
cancelFrame: (id: number) => void;
|
|
2223
|
+
now: () => number;
|
|
2224
|
+
};
|
|
2225
|
+
declare const browserClock: Clock;
|
|
2226
|
+
declare const nodeClock: Clock;
|
|
2227
|
+
declare function createTestClock(): {
|
|
2228
|
+
clock: Clock;
|
|
2229
|
+
tick: (ms: number) => void;
|
|
2230
|
+
getCallbacks: () => ClockCallback[];
|
|
2231
|
+
};
|
|
2232
|
+
|
|
2233
|
+
/**
|
|
2234
|
+
* PlayheadController — Phase 6 Step 1
|
|
2235
|
+
*
|
|
2236
|
+
* Manages playback position only. Decoupled from Dispatcher and TimelineState.
|
|
2237
|
+
* Never calls dispatch(). Uses clock abstraction for testability.
|
|
2238
|
+
*/
|
|
2239
|
+
|
|
2240
|
+
declare class PlayheadController {
|
|
2241
|
+
private state;
|
|
2242
|
+
private listeners;
|
|
2243
|
+
private rafId;
|
|
2244
|
+
private lastTimestamp;
|
|
2245
|
+
private frameAccum;
|
|
2246
|
+
private clock;
|
|
2247
|
+
constructor(initialState: Pick<PlayheadState, 'durationFrames' | 'fps'>, clock?: Clock);
|
|
2248
|
+
getState(): PlayheadState;
|
|
2249
|
+
play(): void;
|
|
2250
|
+
pause(): void;
|
|
2251
|
+
seekTo(frame: TimelineFrame): void;
|
|
2252
|
+
setPlaybackRate(rate: PlaybackRate): void;
|
|
2253
|
+
setQuality(quality: PlaybackQuality): void;
|
|
2254
|
+
setDuration(durationFrames: number): void;
|
|
2255
|
+
setLoopRegion(region: LoopRegion | null): void;
|
|
2256
|
+
setPreroll(frames: number): void;
|
|
2257
|
+
setPostroll(frames: number): void;
|
|
2258
|
+
private scheduleFrame;
|
|
2259
|
+
private onFrame;
|
|
2260
|
+
on(listener: PlayheadListener): PlayheadUnsubscribe;
|
|
2261
|
+
private emit;
|
|
2262
|
+
destroy(): void;
|
|
2263
|
+
}
|
|
2264
|
+
|
|
2265
|
+
/**
|
|
2266
|
+
* Pipeline contracts — Phase 6 Step 2
|
|
2267
|
+
*
|
|
2268
|
+
* Core defines the CONTRACT (types + interfaces).
|
|
2269
|
+
* Host app provides the IMPLEMENTATION.
|
|
2270
|
+
* Core never does actual decoding or compositing.
|
|
2271
|
+
*/
|
|
2272
|
+
|
|
2273
|
+
type VideoFrameRequest = {
|
|
2274
|
+
readonly clipId: ClipId;
|
|
2275
|
+
readonly mediaFrame: TimelineFrame;
|
|
2276
|
+
readonly quality: PlaybackQuality;
|
|
2277
|
+
};
|
|
2278
|
+
type AudioChunkRequest = {
|
|
2279
|
+
readonly clipId: ClipId;
|
|
2280
|
+
readonly mediaFrame: TimelineFrame;
|
|
2281
|
+
readonly durationFrames: number;
|
|
2282
|
+
readonly sampleRate: number;
|
|
2283
|
+
};
|
|
2284
|
+
type VideoFrameResult = {
|
|
2285
|
+
readonly clipId: ClipId;
|
|
2286
|
+
readonly mediaFrame: TimelineFrame;
|
|
2287
|
+
readonly width: number;
|
|
2288
|
+
readonly height: number;
|
|
2289
|
+
readonly bitmap: unknown;
|
|
2290
|
+
};
|
|
2291
|
+
type AudioChunkResult = {
|
|
2292
|
+
readonly clipId: ClipId;
|
|
2293
|
+
readonly mediaFrame: TimelineFrame;
|
|
2294
|
+
readonly samples: unknown;
|
|
2295
|
+
readonly sampleRate: number;
|
|
2296
|
+
};
|
|
2297
|
+
type VideoDecoder = (request: VideoFrameRequest) => Promise<VideoFrameResult>;
|
|
2298
|
+
type AudioDecoder = (request: AudioChunkRequest) => Promise<AudioChunkResult>;
|
|
2299
|
+
type CompositeLayer = {
|
|
2300
|
+
readonly clipId: ClipId;
|
|
2301
|
+
readonly trackId: TrackId;
|
|
2302
|
+
readonly trackIndex: number;
|
|
2303
|
+
readonly frame: VideoFrameResult;
|
|
2304
|
+
readonly transform: ClipTransform;
|
|
2305
|
+
readonly opacity: number;
|
|
2306
|
+
readonly blendMode: string;
|
|
2307
|
+
readonly effects: readonly Effect[];
|
|
2308
|
+
};
|
|
2309
|
+
/** Layer spec from resolveFrame (no decoded frame yet). */
|
|
2310
|
+
type ResolvedLayer = {
|
|
2311
|
+
readonly clipId: ClipId;
|
|
2312
|
+
readonly trackId: TrackId;
|
|
2313
|
+
readonly trackIndex: number;
|
|
2314
|
+
readonly mediaFrame: TimelineFrame;
|
|
2315
|
+
readonly transform: ClipTransform;
|
|
2316
|
+
readonly opacity: number;
|
|
2317
|
+
readonly blendMode: string;
|
|
2318
|
+
readonly effects: readonly Effect[];
|
|
2319
|
+
};
|
|
2320
|
+
type CompositeRequest = {
|
|
2321
|
+
readonly timelineFrame: TimelineFrame;
|
|
2322
|
+
readonly layers: readonly CompositeLayer[];
|
|
2323
|
+
readonly width: number;
|
|
2324
|
+
readonly height: number;
|
|
2325
|
+
readonly quality: PlaybackQuality;
|
|
2326
|
+
};
|
|
2327
|
+
type CompositeResult = {
|
|
2328
|
+
readonly timelineFrame: TimelineFrame;
|
|
2329
|
+
readonly bitmap: unknown;
|
|
2330
|
+
};
|
|
2331
|
+
/** Result of resolveFrame (layers have mediaFrame, not decoded frame). */
|
|
2332
|
+
type ResolvedCompositeRequest = {
|
|
2333
|
+
readonly timelineFrame: TimelineFrame;
|
|
2334
|
+
readonly layers: readonly ResolvedLayer[];
|
|
2335
|
+
readonly width: number;
|
|
2336
|
+
readonly height: number;
|
|
2337
|
+
readonly quality: PlaybackQuality;
|
|
2338
|
+
};
|
|
2339
|
+
type Compositor = (request: CompositeRequest) => Promise<CompositeResult>;
|
|
2340
|
+
type ThumbnailRequest = {
|
|
2341
|
+
readonly clipId: ClipId;
|
|
2342
|
+
readonly mediaFrame: TimelineFrame;
|
|
2343
|
+
readonly width: number;
|
|
2344
|
+
readonly height: number;
|
|
2345
|
+
};
|
|
2346
|
+
type ThumbnailResult = {
|
|
2347
|
+
readonly clipId: ClipId;
|
|
2348
|
+
readonly mediaFrame: TimelineFrame;
|
|
2349
|
+
readonly bitmap: unknown;
|
|
2350
|
+
};
|
|
2351
|
+
type ThumbnailProvider = (request: ThumbnailRequest) => Promise<ThumbnailResult>;
|
|
2352
|
+
type PipelineConfig = {
|
|
2353
|
+
readonly videoDecoder: VideoDecoder;
|
|
2354
|
+
readonly audioDecoder?: AudioDecoder;
|
|
2355
|
+
readonly compositor: Compositor;
|
|
2356
|
+
readonly thumbnailProvider?: ThumbnailProvider;
|
|
2357
|
+
};
|
|
2358
|
+
|
|
2359
|
+
/**
|
|
2360
|
+
* Frame resolver — Phase 6 Step 2 + Step 3
|
|
2361
|
+
*
|
|
2362
|
+
* Given a TimelineFrame, resolves which clips are visible and builds
|
|
2363
|
+
* the composite request. Pure function — no async, no decoding.
|
|
2364
|
+
*/
|
|
2365
|
+
|
|
2366
|
+
/**
|
|
2367
|
+
* Returns the media-space frame for a clip at the given timeline frame.
|
|
2368
|
+
* mediaFrame = timelineFrame - clip.timelineStart + clip.mediaIn
|
|
2369
|
+
*/
|
|
2370
|
+
declare function mediaFrameForClip(clip: Clip, timelineFrame: TimelineFrame): TimelineFrame;
|
|
2371
|
+
/**
|
|
2372
|
+
* Returns all clips visible at the given timeline frame, with their
|
|
2373
|
+
* parent track and track index (z-order).
|
|
2374
|
+
*/
|
|
2375
|
+
declare function getClipsAtFrame(state: TimelineState, timelineFrame: TimelineFrame): Array<{
|
|
2376
|
+
clip: Clip;
|
|
2377
|
+
track: Track;
|
|
2378
|
+
trackIndex: number;
|
|
2379
|
+
}>;
|
|
2380
|
+
/**
|
|
2381
|
+
* Resolves the composite request for a timeline frame: which layers are
|
|
2382
|
+
* visible and their transform/opacity/blend/effects. Does not decode.
|
|
2383
|
+
*/
|
|
2384
|
+
declare function resolveFrame(state: TimelineState, timelineFrame: TimelineFrame, quality: PlaybackQuality, dimensions: {
|
|
2385
|
+
width: number;
|
|
2386
|
+
height: number;
|
|
2387
|
+
}): ResolvedCompositeRequest;
|
|
2388
|
+
/**
|
|
2389
|
+
* Returns the nearest frame strictly after fromFrame where any clip
|
|
2390
|
+
* starts or ends on any track. Returns null if none.
|
|
2391
|
+
*/
|
|
2392
|
+
declare function findNextClipBoundary(state: TimelineState, fromFrame: TimelineFrame): TimelineFrame | null;
|
|
2393
|
+
/**
|
|
2394
|
+
* Returns the nearest frame strictly before fromFrame where any clip
|
|
2395
|
+
* starts or ends on any track. Returns null if none.
|
|
2396
|
+
*/
|
|
2397
|
+
declare function findPrevClipBoundary(state: TimelineState, fromFrame: TimelineFrame): TimelineFrame | null;
|
|
2398
|
+
/**
|
|
2399
|
+
* Returns the marker with the smallest anchor strictly after fromFrame.
|
|
2400
|
+
* Point markers use .frame; range markers use .frameStart as anchor.
|
|
2401
|
+
*/
|
|
2402
|
+
declare function findNextMarker(state: TimelineState, fromFrame: TimelineFrame): Marker | null;
|
|
2403
|
+
/**
|
|
2404
|
+
* Returns the marker with the largest anchor strictly before fromFrame.
|
|
2405
|
+
*/
|
|
2406
|
+
declare function findPrevMarker(state: TimelineState, fromFrame: TimelineFrame): Marker | null;
|
|
2407
|
+
/**
|
|
2408
|
+
* Searches all tracks for a clip with the given id.
|
|
2409
|
+
* Returns clip + parent track + trackIndex, or null if not found.
|
|
2410
|
+
*/
|
|
2411
|
+
declare function findClipById(state: TimelineState, clipId: ClipId): {
|
|
2412
|
+
clip: Clip;
|
|
2413
|
+
track: Track;
|
|
2414
|
+
trackIndex: number;
|
|
2415
|
+
} | null;
|
|
2416
|
+
|
|
2417
|
+
declare class PlaybackEngine {
|
|
2418
|
+
private controller;
|
|
2419
|
+
private pipeline;
|
|
2420
|
+
private state;
|
|
2421
|
+
private dimensions;
|
|
2422
|
+
private unsubscribe;
|
|
2423
|
+
constructor(state: TimelineState, pipeline: PipelineConfig, dimensions: {
|
|
2424
|
+
width: number;
|
|
2425
|
+
height: number;
|
|
2426
|
+
}, clock?: Clock);
|
|
2427
|
+
updateState(state: TimelineState): void;
|
|
2428
|
+
play(): void;
|
|
2429
|
+
pause(): void;
|
|
2430
|
+
seekTo(frame: TimelineFrame): void;
|
|
2431
|
+
seekToNextClipBoundary(): void;
|
|
2432
|
+
seekToPrevClipBoundary(): void;
|
|
2433
|
+
seekToNextMarker(): void;
|
|
2434
|
+
seekToPrevMarker(): void;
|
|
2435
|
+
seekToStart(): void;
|
|
2436
|
+
seekToEnd(): void;
|
|
2437
|
+
setPlaybackRate(rate: PlaybackRate): void;
|
|
2438
|
+
setQuality(quality: PlaybackQuality): void;
|
|
2439
|
+
setLoopRegion(region: LoopRegion | null): void;
|
|
2440
|
+
setPreroll(frames: number): void;
|
|
2441
|
+
setPostroll(frames: number): void;
|
|
2442
|
+
getState(): PlayheadState;
|
|
2443
|
+
getCurrentTimelineState(): TimelineState;
|
|
2444
|
+
on(listener: PlayheadListener): () => void;
|
|
2445
|
+
renderFrame(timelineFrame: TimelineFrame): Promise<CompositeResult>;
|
|
2446
|
+
destroy(): void;
|
|
2447
|
+
}
|
|
2448
|
+
|
|
2449
|
+
/**
|
|
2450
|
+
* Keyboard contract — Phase 6 Step 4 + Step 5
|
|
2451
|
+
*
|
|
2452
|
+
* Key bindings and actions for J/K/L jog-shuttle and timeline navigation.
|
|
2453
|
+
*/
|
|
2454
|
+
|
|
2455
|
+
type TimelineKeyAction = 'play-pause' | 'stop' | 'jog-forward' | 'jog-backward' | 'jog-stop' | 'step-forward' | 'step-backward' | 'seek-start' | 'seek-end' | 'next-clip' | 'prev-clip' | 'next-marker' | 'prev-marker' | 'mark-in' | 'mark-out' | 'toggle-loop';
|
|
2456
|
+
type KeyBinding = {
|
|
2457
|
+
readonly code: string;
|
|
2458
|
+
readonly shift?: boolean;
|
|
2459
|
+
readonly alt?: boolean;
|
|
2460
|
+
readonly meta?: boolean;
|
|
2461
|
+
readonly ctrl?: boolean;
|
|
2462
|
+
readonly action: TimelineKeyAction;
|
|
2463
|
+
readonly repeat?: boolean;
|
|
2464
|
+
};
|
|
2465
|
+
declare const DEFAULT_KEY_BINDINGS: KeyBinding[];
|
|
2466
|
+
type KeyboardHandlerOptions = {
|
|
2467
|
+
bindings?: KeyBinding[];
|
|
2468
|
+
onMarkIn?: (frame: TimelineFrame) => void;
|
|
2469
|
+
onMarkOut?: (frame: TimelineFrame) => void;
|
|
2470
|
+
getTimelineState?: () => TimelineState;
|
|
2471
|
+
};
|
|
2472
|
+
|
|
2473
|
+
/**
|
|
2474
|
+
* KeyboardHandler — Phase 6 Step 4
|
|
2475
|
+
*
|
|
2476
|
+
* J/K/L jog-shuttle and keyboard contract. Zero DOM deps;
|
|
2477
|
+
* accepts TimelineKeyEvent (host maps from KeyboardEvent).
|
|
2478
|
+
*/
|
|
2479
|
+
|
|
2480
|
+
declare class KeyboardHandler {
|
|
2481
|
+
private bindings;
|
|
2482
|
+
private engine;
|
|
2483
|
+
private jogLevel;
|
|
2484
|
+
private onMarkIn;
|
|
2485
|
+
private onMarkOut;
|
|
2486
|
+
private getTimelineState;
|
|
2487
|
+
constructor(engine: PlaybackEngine, options?: KeyboardHandlerOptions);
|
|
2488
|
+
handleKeyDown(event: TimelineKeyEvent): boolean;
|
|
2489
|
+
private dispatchAction;
|
|
2490
|
+
}
|
|
2491
|
+
|
|
2492
|
+
export { type LoopRegion as $, type Asset as A, type Bin as B, type Clip as C, DEFAULT_AUDIO_PROPERTIES as D, type EDLExportOptions as E, type EasingCurve as F, type Effect as G, type EffectId as H, type EffectParam as I, type EffectType as J, type FCPXMLExportOptions as K, type FrameRate as L, FrameRates as M, HOLD_EASING as N, type HistoryState as O, type ITool as P, type InvariantViolation as Q, type KeyBinding as R, KeyboardHandler as S, type TimelineState as T, type KeyboardHandlerOptions as U, type Keyframe as V, type KeyframeId as W, KeyframeTool as X, LINEAR_EASING as Y, type LinkGroup as Z, type LinkGroupId as _, type Track as a, addTimeline as a$, type Modifiers as a0, NoOpTool as a1, type OTIODocument as a2, type OTIOImportOptions as a3, type OfflineAsset as a4, type OperationPrimitive as a5, type PipelineConfig as a6, PlaybackEngine as a7, type PlaybackQuality as a8, type PlaybackRate as a9, TimelineEngine as aA, type TimelineKeyAction as aB, type TimelineKeyEvent as aC, type TimelinePointerEvent as aD, type ToolContext as aE, type ToolId as aF, type ToolRegistry as aG, type TrackGroup as aH, type TrackGroupId as aI, type TrackId as aJ, type TrackType as aK, type Transaction as aL, type Transition as aM, type TransitionAlignment as aN, type TransitionId as aO, type TransitionParam as aP, TransitionTool as aQ, type TransitionType as aR, type VTTParseOptions as aS, type VideoDecoder as aT, type VideoFrameRequest as aU, type VideoFrameResult as aV, type ViolationType as aW, activateTool as aX, addBin as aY, addFrames as aZ, addItemToBin as a_, PlayheadController as aa, type PlayheadEvent as ab, type PlayheadEventType as ac, type PlayheadListener as ad, type PlayheadState as ae, type PlayheadUnsubscribe as af, type Project as ag, type ProjectId as ah, type ProvisionalManager as ai, type ProvisionalState as aj, type RationalTime as ak, type RejectionReason as al, type RenderStage as am, type RubberBandRegion as an, type SRTParseOptions as ao, type SequenceSettings as ap, SerializationError as aq, type SnapIndex as ar, type SnapPoint as as, type SnapPointType as at, type ThumbnailProvider as au, type ThumbnailRequest as av, type ThumbnailResult as aw, type TimeRange as ax, type Timecode as ay, type Timeline as az, type TimelineFrame as b, registerTool as b$, browserClock as b0, buildSnapIndex as b1, canRedo as b2, canUndo as b3, checkInvariants as b4, clampFrame as b5, clearProvisional as b6, clipContainsFrame as b7, clipsOverlap as b8, createAnimatableProperty as b9, findNextMarker as bA, findOfflineAssets as bB, findPrevClipBoundary as bC, findPrevMarker as bD, frame as bE, frameDuration as bF, frameRate as bG, frameToTimecode as bH, framesToMinutesSeconds as bI, framesToSeconds as bJ, framesToTimecode as bK, getActiveTool as bL, getClipDuration as bM, getClipMediaDuration as bN, getCurrentState as bO, importFromOTIO as bP, isDropFrame as bQ, isValidFrame as bR, mediaFrameForClip as bS, moveItemBetweenBins as bT, nearest as bU, nodeClock as bV, parseSRT as bW, parseVTT as bX, pushHistory as bY, redo as bZ, reelName as b_, createAsset as ba, createBin as bb, createClip as bc, createEffect as bd, createHistory as be, createLinkGroup as bf, createProject as bg, createProvisionalManager as bh, createRegistry as bi, createTestClock as bj, createTimeline as bk, createTimelineState as bl, createTrack as bm, createTrackGroup as bn, createTransition as bo, defaultCaptionStyle as bp, deserializeProject as bq, deserializeTimeline as br, dispatch as bs, exportToAAF as bt, exportToEDL as bu, exportToFCPXML as bv, exportToOTIO as bw, findMarkersByColor as bx, findMarkersByLabel as by, findNextClipBoundary as bz, type AAFExportOptions as c, remapAssetPaths as c0, removeBin as c1, removeItemFromBin as c2, removeTimeline as c3, resolveClip as c4, resolveFrame as c5, secondsToFrames as c6, serializeProject as c7, serializeTimeline as c8, setProvisional as c9, sortTrackClips as ca, subtitleImportToOps as cb, subtractFrames as cc, toAssetId as cd, toBinId as ce, toClipId as cf, toEffectId as cg, toFCPTime as ch, toFrame as ci, toKeyframeId as cj, toLinkGroupId as ck, toProjectId as cl, toTimecode as cm, toToolId as cn, toTrackGroupId as co, toTrackId as cp, toTransitionId as cq, toggleSnap as cr, undo as cs, findClipById as ct, getClipsAtFrame as cu, type AnimatableProperty as d, type AssetId as e, type AssetRegistry as f, type AssetRemapCallback as g, type AssetStatus as h, type AudioChunkRequest as i, type AudioChunkResult as j, type AudioDecoder as k, type AudioProperties as l, type BinId as m, type BinItem as n, CURRENT_SCHEMA_VERSION as o, type ChannelRouting as p, type ClipId as q, type ClipTransform as r, type Clock as s, type CompositeLayer as t, type CompositeRequest as u, type CompositeResult as v, type Compositor as w, DEFAULT_CLIP_TRANSFORM as x, DEFAULT_KEY_BINDINGS as y, type DispatchResult as z };
|