@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.
Files changed (77) hide show
  1. package/CHANGELOG.md +36 -0
  2. package/LICENSE +21 -0
  3. package/README.md +162 -0
  4. package/dist/chunk-27XCNVPR.js +5969 -0
  5. package/dist/chunk-6PDBJDHM.js +2263 -0
  6. package/dist/chunk-BWPS6NQT.js +7465 -0
  7. package/dist/chunk-FBOYSUYV.js +1280 -0
  8. package/dist/chunk-FR632TZX.js +1870 -0
  9. package/dist/chunk-HW4Z7YLJ.js +1242 -0
  10. package/dist/chunk-HWW62IFH.js +5424 -0
  11. package/dist/chunk-I2GZXRH4.js +4790 -0
  12. package/dist/chunk-JQZE3OK4.js +1255 -0
  13. package/dist/chunk-KF7JNK2F.js +1864 -0
  14. package/dist/chunk-KR3P2DYK.js +5655 -0
  15. package/dist/chunk-MO5DSFSW.js +2214 -0
  16. package/dist/chunk-MQAW33RJ.js +5530 -0
  17. package/dist/chunk-N4WUWZZX.js +2833 -0
  18. package/dist/chunk-NRJV7I4C.js +1331 -0
  19. package/dist/chunk-NXG52532.js +2230 -0
  20. package/dist/chunk-PVXF67CN.js +1278 -0
  21. package/dist/chunk-QSB6DHIF.js +5429 -0
  22. package/dist/chunk-QYWJT7HR.js +5837 -0
  23. package/dist/chunk-SWBRCMW7.js +7466 -0
  24. package/dist/chunk-TAT3ULSV.js +2214 -0
  25. package/dist/chunk-TTDP5JUM.js +2228 -0
  26. package/dist/chunk-UAGP4VPG.js +1739 -0
  27. package/dist/chunk-WIG6SY7A.js +1183 -0
  28. package/dist/chunk-YJ2K5N2R.js +6187 -0
  29. package/dist/index-3Lr_vKBd.d.cts +2810 -0
  30. package/dist/index-3Lr_vKBd.d.ts +2810 -0
  31. package/dist/index-7IPJn1yM.d.cts +1146 -0
  32. package/dist/index-7IPJn1yM.d.ts +1146 -0
  33. package/dist/index-B0xOv0V0.d.cts +3259 -0
  34. package/dist/index-B0xOv0V0.d.ts +3259 -0
  35. package/dist/index-B2m3zwg7.d.cts +1381 -0
  36. package/dist/index-B2m3zwg7.d.ts +1381 -0
  37. package/dist/index-B3sUrU_X.d.cts +1249 -0
  38. package/dist/index-B3sUrU_X.d.ts +1249 -0
  39. package/dist/index-B6wla7ZJ.d.cts +2751 -0
  40. package/dist/index-B6wla7ZJ.d.ts +2751 -0
  41. package/dist/index-BIv8RWWT.d.cts +1574 -0
  42. package/dist/index-BIv8RWWT.d.ts +1574 -0
  43. package/dist/index-BJv6hDHL.d.cts +3255 -0
  44. package/dist/index-BJv6hDHL.d.ts +3255 -0
  45. package/dist/index-BUCimS2e.d.cts +1393 -0
  46. package/dist/index-BUCimS2e.d.ts +1393 -0
  47. package/dist/index-Bw_nvNcG.d.cts +1275 -0
  48. package/dist/index-Bw_nvNcG.d.ts +1275 -0
  49. package/dist/index-ByG0gOtd.d.cts +1167 -0
  50. package/dist/index-ByG0gOtd.d.ts +1167 -0
  51. package/dist/index-CDGd2XXv.d.cts +2492 -0
  52. package/dist/index-CDGd2XXv.d.ts +2492 -0
  53. package/dist/index-CznAVeJ6.d.cts +1145 -0
  54. package/dist/index-CznAVeJ6.d.ts +1145 -0
  55. package/dist/index-DQD9IMh7.d.cts +2534 -0
  56. package/dist/index-DQD9IMh7.d.ts +2534 -0
  57. package/dist/index-Dl3qtJEI.d.cts +2178 -0
  58. package/dist/index-Dl3qtJEI.d.ts +2178 -0
  59. package/dist/index-DnE2A-Nz.d.cts +2603 -0
  60. package/dist/index-DnE2A-Nz.d.ts +2603 -0
  61. package/dist/index-DrOA6QmW.d.cts +2492 -0
  62. package/dist/index-DrOA6QmW.d.ts +2492 -0
  63. package/dist/index-Vpa3rPEM.d.cts +1402 -0
  64. package/dist/index-Vpa3rPEM.d.ts +1402 -0
  65. package/dist/index-jP6BomSd.d.cts +2640 -0
  66. package/dist/index-jP6BomSd.d.ts +2640 -0
  67. package/dist/index-wiGRwVyY.d.cts +3259 -0
  68. package/dist/index-wiGRwVyY.d.ts +3259 -0
  69. package/dist/index.cjs +7386 -0
  70. package/dist/index.d.cts +1 -0
  71. package/dist/index.d.ts +1 -0
  72. package/dist/index.js +263 -0
  73. package/dist/internal.cjs +7721 -0
  74. package/dist/internal.d.cts +704 -0
  75. package/dist/internal.d.ts +704 -0
  76. package/dist/internal.js +405 -0
  77. package/package.json +58 -0
@@ -0,0 +1,3259 @@
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
+ declare const toMarkerId: (s: string) => MarkerId;
455
+ type MarkerScope = 'global' | 'personal' | 'export';
456
+ type Marker = {
457
+ readonly type: 'point';
458
+ readonly id: MarkerId;
459
+ readonly frame: TimelineFrame;
460
+ readonly label: string;
461
+ readonly color: string;
462
+ readonly scope: MarkerScope;
463
+ readonly linkedClipId: ClipId | null;
464
+ readonly clipId?: ClipId;
465
+ } | {
466
+ readonly type: 'range';
467
+ readonly id: MarkerId;
468
+ readonly frameStart: TimelineFrame;
469
+ readonly frameEnd: TimelineFrame;
470
+ readonly label: string;
471
+ readonly color: string;
472
+ readonly scope: MarkerScope;
473
+ readonly linkedClipId: ClipId | null;
474
+ readonly clipId?: ClipId;
475
+ };
476
+ type BeatGrid = {
477
+ readonly bpm: number;
478
+ readonly timeSignature: readonly [number, number];
479
+ readonly offset: TimelineFrame;
480
+ };
481
+
482
+ /**
483
+ * LINK GROUP — Phase 4
484
+ *
485
+ * Locks A/V clips in sync; when one moves, all move together.
486
+ */
487
+
488
+ type LinkGroupId = string & {
489
+ readonly __brand: 'LinkGroupId';
490
+ };
491
+ declare function toLinkGroupId(s: string): LinkGroupId;
492
+ type LinkGroup = {
493
+ readonly id: LinkGroupId;
494
+ /** Min 2 clips. */
495
+ readonly clipIds: readonly ClipId[];
496
+ };
497
+ declare function createLinkGroup(id: LinkGroupId, clipIds: readonly ClipId[]): LinkGroup;
498
+
499
+ /**
500
+ * TIMELINE MODEL — Phase 0 + Phase 3
501
+ */
502
+
503
+ type SequenceSettings = {
504
+ readonly pixelAspectRatio: number;
505
+ readonly fieldOrder: 'progressive' | 'upper' | 'lower';
506
+ readonly colorSpace: string;
507
+ readonly audioSampleRate: number;
508
+ readonly audioChannelCount: number;
509
+ };
510
+ type Timeline = {
511
+ readonly id: string;
512
+ readonly name: string;
513
+ readonly fps: FrameRate;
514
+ readonly duration: TimelineFrame;
515
+ readonly startTimecode: Timecode;
516
+ readonly tracks: readonly Track[];
517
+ readonly sequenceSettings: SequenceSettings;
518
+ /**
519
+ * Increments by 1 on every successfully committed Transaction.
520
+ * Use this to detect stale references without deep equality checks.
521
+ */
522
+ readonly version: number;
523
+ readonly markers: readonly Marker[];
524
+ readonly beatGrid: BeatGrid | null;
525
+ readonly inPoint: TimelineFrame | null;
526
+ readonly outPoint: TimelineFrame | null;
527
+ readonly trackGroups?: readonly TrackGroup[];
528
+ readonly linkGroups?: readonly LinkGroup[];
529
+ };
530
+ declare function createTimeline(params: {
531
+ id: string;
532
+ name: string;
533
+ fps: FrameRate;
534
+ duration: TimelineFrame;
535
+ startTimecode?: Timecode;
536
+ tracks?: readonly Track[];
537
+ sequenceSettings?: Partial<SequenceSettings>;
538
+ markers?: readonly Marker[];
539
+ beatGrid?: BeatGrid | null;
540
+ inPoint?: TimelineFrame | null;
541
+ outPoint?: TimelineFrame | null;
542
+ trackGroups?: readonly TrackGroup[];
543
+ linkGroups?: readonly LinkGroup[];
544
+ }): Timeline;
545
+
546
+ /**
547
+ * TIMELINE STATE — Phase 0 compliant
548
+ *
549
+ * TimelineState is the single source of truth for the engine.
550
+ * Phase 0 only: timeline + assetRegistry. No Phase 2 fields.
551
+ *
552
+ * RULE: Every function that changes state returns a NEW TimelineState.
553
+ * Never mutate the existing state.
554
+ */
555
+
556
+ type AssetRegistry = ReadonlyMap<AssetId, Asset>;
557
+ /**
558
+ * Increment this whenever TimelineState gains a new required field or
559
+ * a field's semantics change in a breaking way.
560
+ *
561
+ * The schemaVersion invariant check rejects loading a future schema
562
+ * into an older engine (prevents silent data corruption on downgrade).
563
+ */
564
+ declare const CURRENT_SCHEMA_VERSION: 2;
565
+ type TimelineState = {
566
+ readonly schemaVersion: number;
567
+ readonly timeline: Timeline;
568
+ readonly assetRegistry: AssetRegistry;
569
+ };
570
+ declare function createTimelineState(params: {
571
+ timeline: Timeline;
572
+ assetRegistry?: AssetRegistry;
573
+ /** @deprecated use assetRegistry. Kept for test backward-compat only. */
574
+ assets?: Map<string, Asset>;
575
+ }): TimelineState;
576
+
577
+ /**
578
+ * FRAME UTILITIES
579
+ *
580
+ * Pure functions for working with frame-based time values.
581
+ *
582
+ * These utilities handle:
583
+ * - Converting between frames and seconds
584
+ * - Formatting frames as timecode (HH:MM:SS:FF)
585
+ * - Frame arithmetic (clamping, rounding)
586
+ *
587
+ * CRITICAL RULES:
588
+ * - All conversions must quantize to whole frames
589
+ * - No floating-point frame values allowed
590
+ * - Always round/floor/ceil explicitly
591
+ *
592
+ * USAGE:
593
+ * ```typescript
594
+ * const fps = frameRate(30);
595
+ * const frames = secondsToFrames(5.5, fps); // 165 frames
596
+ * const seconds = framesToSeconds(frames, fps); // 5.5 seconds
597
+ * const timecode = framesToTimecode(frames, fps); // "00:00:05:15"
598
+ * ```
599
+ */
600
+
601
+ /**
602
+ * Convert frames to seconds
603
+ *
604
+ * @param frames - Frame number
605
+ * @param fps - Frames per second
606
+ * @returns Time in seconds (may be fractional)
607
+ */
608
+ declare function framesToSeconds(frames: TimelineFrame, fps: FrameRate): number;
609
+ /**
610
+ * Convert seconds to frames
611
+ *
612
+ * IMPORTANT: This rounds to the nearest frame.
613
+ * If you need different rounding behavior, use Math.floor or Math.ceil explicitly.
614
+ *
615
+ * @param seconds - Time in seconds
616
+ * @param fps - Frames per second
617
+ * @returns Frame number (rounded to nearest frame)
618
+ */
619
+ declare function secondsToFrames(seconds: number, fps: FrameRate): TimelineFrame;
620
+ /**
621
+ * Convert frames to timecode format (HH:MM:SS:FF)
622
+ *
623
+ * Example: 3825 frames at 30fps = "00:02:07:15"
624
+ *
625
+ * @param frames - Frame number
626
+ * @param fps - Frames per second
627
+ * @returns Timecode string
628
+ */
629
+ declare function framesToTimecode(frames: TimelineFrame, fps: FrameRate): string;
630
+ /**
631
+ * Convert frames to simple MM:SS format
632
+ *
633
+ * Example: 3825 frames at 30fps = "02:07"
634
+ *
635
+ * @param frames - Frame number
636
+ * @param fps - Frames per second
637
+ * @returns Time string in MM:SS format
638
+ */
639
+ declare function framesToMinutesSeconds(frames: TimelineFrame, fps: FrameRate): string;
640
+ /**
641
+ * Clamp a frame value between min and max
642
+ *
643
+ * @param value - Frame to clamp
644
+ * @param min - Minimum frame (inclusive)
645
+ * @param max - Maximum frame (inclusive)
646
+ * @returns Clamped frame value
647
+ */
648
+ declare function clampFrame(value: TimelineFrame, min: TimelineFrame, max: TimelineFrame): TimelineFrame;
649
+ /**
650
+ * Add two frame values
651
+ *
652
+ * @param a - First frame
653
+ * @param b - Second frame
654
+ * @returns Sum of frames
655
+ */
656
+ declare function addFrames(a: TimelineFrame, b: TimelineFrame): TimelineFrame;
657
+ /**
658
+ * Subtract two frame values
659
+ *
660
+ * @param a - First frame
661
+ * @param b - Second frame (subtracted from a)
662
+ * @returns Difference of frames (clamped to 0 if negative)
663
+ */
664
+ declare function subtractFrames(a: TimelineFrame, b: TimelineFrame): TimelineFrame;
665
+ /**
666
+ * Calculate duration between two frames
667
+ *
668
+ * @param start - Start frame
669
+ * @param end - End frame
670
+ * @returns Duration in frames (end - start)
671
+ */
672
+ declare function frameDuration(start: TimelineFrame, end: TimelineFrame): TimelineFrame;
673
+
674
+ /**
675
+ * TIMELINE ENGINE
676
+ *
677
+ * The main public API for the timeline editing kernel.
678
+ *
679
+ * WHAT IS THE TIMELINE ENGINE?
680
+ * - A thin wrapper around the history and dispatch systems
681
+ * - Provides a convenient, object-oriented API
682
+ * - Manages internal state
683
+ * - Coordinates operations, validation, and history
684
+ *
685
+ * WHY A CLASS?
686
+ * - Encapsulates state management
687
+ * - Provides a clean API for users
688
+ * - Hides complexity of history and dispatch
689
+ * - Familiar OOP interface for most developers
690
+ *
691
+ * USAGE:
692
+ * ```typescript
693
+ * const engine = new TimelineEngine(initialState);
694
+ *
695
+ * // Add a clip
696
+ * const result = engine.addClip(trackId, clip);
697
+ * if (!result.success) {
698
+ * console.error('Failed to add clip:', result.errors);
699
+ * }
700
+ *
701
+ * // Undo/redo
702
+ * engine.undo();
703
+ * engine.redo();
704
+ *
705
+ * // Query state
706
+ * const clip = engine.findClipById('clip_1');
707
+ * const state = engine.getState();
708
+ * ```
709
+ *
710
+ * DESIGN PHILOSOPHY:
711
+ * - Business logic lives in pure modules (operations, validation, etc.)
712
+ * - Engine is just a thin orchestration layer
713
+ * - Easy to test (can test pure functions independently)
714
+ */
715
+
716
+ /**
717
+ * TimelineEngine - The main timeline editing engine
718
+ *
719
+ * Provides a high-level API for timeline editing with built-in
720
+ * undo/redo, validation, and state management.
721
+ */
722
+ declare class TimelineEngine {
723
+ private history;
724
+ private listeners;
725
+ /**
726
+ * Create a new timeline engine
727
+ *
728
+ * @param initialState - Initial timeline state
729
+ * @param historyLimit - Maximum number of undo steps (default: 50)
730
+ */
731
+ constructor(initialState: TimelineState, historyLimit?: number);
732
+ /**
733
+ * Subscribe to state changes
734
+ *
735
+ * The listener will be called whenever the timeline state changes,
736
+ * with the new state passed as an argument.
737
+ * This is used by framework adapters (e.g., React) to trigger re-renders.
738
+ *
739
+ * @param listener - Function to call on state changes, receives new state
740
+ * @returns Unsubscribe function
741
+ *
742
+ * @example
743
+ * ```typescript
744
+ * const unsubscribe = engine.subscribe((state) => {
745
+ * console.log('State changed:', state);
746
+ * });
747
+ *
748
+ * // Later...
749
+ * unsubscribe();
750
+ * ```
751
+ */
752
+ subscribe(listener: (state: TimelineState) => void): () => void;
753
+ /**
754
+ * Notify all subscribers of a state change
755
+ *
756
+ * This is called internally after any operation that modifies state.
757
+ * Framework adapters use this to trigger re-renders.
758
+ */
759
+ private notify;
760
+ /**
761
+ * Get the current timeline state
762
+ *
763
+ * @returns Current timeline state
764
+ */
765
+ getState(): TimelineState;
766
+ /**
767
+ * Register an asset
768
+ *
769
+ * @param asset - Asset to register
770
+ * @returns Dispatch result
771
+ */
772
+ registerAsset(asset: Asset): {
773
+ accepted: boolean;
774
+ errors?: {
775
+ code: string;
776
+ message: string;
777
+ }[];
778
+ };
779
+ /**
780
+ * Get an asset by ID
781
+ *
782
+ * @param assetId - Asset ID
783
+ * @returns The asset, or undefined if not found
784
+ */
785
+ getAsset(assetId: string): Asset | undefined;
786
+ /**
787
+ * Add a clip to a track
788
+ *
789
+ * @param trackId - ID of the track to add to
790
+ * @param clip - Clip to add
791
+ * @returns Dispatch result
792
+ */
793
+ addClip(trackId: string, clip: Clip): {
794
+ accepted: boolean;
795
+ errors?: {
796
+ code: string;
797
+ message: string;
798
+ }[];
799
+ };
800
+ /**
801
+ * Remove a clip
802
+ *
803
+ * @param clipId - ID of the clip to remove
804
+ * @returns Dispatch result
805
+ */
806
+ removeClip(clipId: string): {
807
+ accepted: boolean;
808
+ errors?: {
809
+ code: string;
810
+ message: string;
811
+ }[];
812
+ };
813
+ /**
814
+ * Move a clip to a new timeline position
815
+ *
816
+ * @param clipId - ID of the clip to move
817
+ * @param newStart - New timeline start frame
818
+ * @returns Dispatch result
819
+ */
820
+ moveClip(clipId: string, newStart: TimelineFrame): {
821
+ accepted: boolean;
822
+ errors?: {
823
+ code: string;
824
+ message: string;
825
+ }[];
826
+ };
827
+ /**
828
+ * Resize a clip
829
+ *
830
+ * @param clipId - ID of the clip to resize
831
+ * @param newStart - New timeline start frame
832
+ * @param newEnd - New timeline end frame
833
+ * @returns Dispatch result
834
+ */
835
+ resizeClip(clipId: string, newStart: TimelineFrame, newEnd: TimelineFrame): {
836
+ accepted: boolean;
837
+ errors?: {
838
+ code: string;
839
+ message: string;
840
+ }[];
841
+ };
842
+ /**
843
+ * Trim a clip (change media bounds)
844
+ *
845
+ * @param clipId - ID of the clip to trim
846
+ * @param newMediaIn - New media in frame
847
+ * @param newMediaOut - New media out frame
848
+ * @returns Dispatch result
849
+ */
850
+ trimClip(clipId: string, newMediaIn: TimelineFrame, newMediaOut: TimelineFrame): {
851
+ accepted: boolean;
852
+ errors?: {
853
+ code: string;
854
+ message: string;
855
+ }[];
856
+ };
857
+ /**
858
+ * Move a clip to a different track
859
+ *
860
+ * @param clipId - ID of the clip to move
861
+ * @param targetTrackId - ID of the target track
862
+ * @returns Dispatch result
863
+ */
864
+ moveClipToTrack(clipId: string, targetTrackId: string): {
865
+ accepted: boolean;
866
+ errors?: {
867
+ code: string;
868
+ message: string;
869
+ }[];
870
+ };
871
+ /**
872
+ * Add a track
873
+ *
874
+ * @param track - Track to add
875
+ * @returns Dispatch result
876
+ */
877
+ addTrack(track: Track): {
878
+ accepted: boolean;
879
+ errors?: {
880
+ code: string;
881
+ message: string;
882
+ }[];
883
+ };
884
+ /**
885
+ * Remove a track
886
+ *
887
+ * @param trackId - ID of the track to remove
888
+ * @returns Dispatch result
889
+ */
890
+ removeTrack(trackId: string): {
891
+ accepted: boolean;
892
+ errors?: {
893
+ code: string;
894
+ message: string;
895
+ }[];
896
+ };
897
+ /**
898
+ * Move a track to a new position
899
+ *
900
+ * @param trackId - ID of the track to move
901
+ * @param newIndex - New index position
902
+ * @returns Dispatch result
903
+ */
904
+ moveTrack(trackId: string, newIndex: number): {
905
+ accepted: boolean;
906
+ errors?: {
907
+ code: string;
908
+ message: string;
909
+ }[];
910
+ };
911
+ /**
912
+ * Toggle track mute
913
+ *
914
+ * @param trackId - ID of the track
915
+ * @returns Dispatch result
916
+ */
917
+ toggleTrackMute(trackId: string): {
918
+ accepted: boolean;
919
+ errors?: {
920
+ code: string;
921
+ message: string;
922
+ }[];
923
+ };
924
+ /**
925
+ * Toggle track lock
926
+ *
927
+ * @param trackId - ID of the track
928
+ * @returns Dispatch result
929
+ */
930
+ toggleTrackLock(trackId: string): {
931
+ accepted: boolean;
932
+ errors?: {
933
+ code: string;
934
+ message: string;
935
+ }[];
936
+ };
937
+ /**
938
+ * Toggle track solo
939
+ *
940
+ * @param trackId - ID of the track
941
+ * @returns Dispatch result
942
+ */
943
+ toggleTrackSolo(trackId: string): {
944
+ accepted: boolean;
945
+ errors?: {
946
+ code: string;
947
+ message: string;
948
+ }[];
949
+ };
950
+ /**
951
+ * Set track height
952
+ *
953
+ * @param trackId - ID of the track
954
+ * @param height - New height in pixels
955
+ * @returns Dispatch result
956
+ */
957
+ setTrackHeight(trackId: string, height: number): {
958
+ accepted: boolean;
959
+ errors?: {
960
+ code: string;
961
+ message: string;
962
+ }[];
963
+ };
964
+ /**
965
+ * Set timeline duration
966
+ *
967
+ * @param duration - New duration in frames
968
+ * @returns Dispatch result
969
+ */
970
+ setTimelineDuration(duration: TimelineFrame): {
971
+ accepted: boolean;
972
+ errors?: {
973
+ code: string;
974
+ message: string;
975
+ }[];
976
+ };
977
+ /**
978
+ * Set timeline name
979
+ *
980
+ * @param name - New timeline name
981
+ * @returns Dispatch result
982
+ */
983
+ setTimelineName(name: string): {
984
+ accepted: boolean;
985
+ errors?: {
986
+ code: string;
987
+ message: string;
988
+ }[];
989
+ };
990
+ /**
991
+ * Undo the last action
992
+ *
993
+ * @returns true if undo was performed
994
+ */
995
+ undo(): boolean;
996
+ /**
997
+ * Redo the last undone action
998
+ *
999
+ * @returns true if redo was performed
1000
+ */
1001
+ redo(): boolean;
1002
+ /**
1003
+ * Check if undo is available
1004
+ *
1005
+ * @returns true if undo is available
1006
+ */
1007
+ canUndo(): boolean;
1008
+ /**
1009
+ * Check if redo is available
1010
+ *
1011
+ * @returns true if redo is available
1012
+ */
1013
+ canRedo(): boolean;
1014
+ /**
1015
+ * Find a clip by ID
1016
+ *
1017
+ * @param clipId - Clip ID
1018
+ * @returns The clip, or undefined if not found
1019
+ */
1020
+ findClipById(clipId: string): Clip | undefined;
1021
+ /**
1022
+ * Find a track by ID
1023
+ *
1024
+ * @param trackId - Track ID
1025
+ * @returns The track, or undefined if not found
1026
+ */
1027
+ findTrackById(trackId: string): Track | undefined;
1028
+ /**
1029
+ * Get all clips on a track
1030
+ *
1031
+ * @param trackId - Track ID
1032
+ * @returns Array of clips on the track
1033
+ */
1034
+ getClipsOnTrack(trackId: string): Clip[];
1035
+ /**
1036
+ * Get all clips at a specific frame
1037
+ *
1038
+ * @param frame - Frame to check
1039
+ * @returns Array of clips at that frame
1040
+ */
1041
+ getClipsAtFrame(f: TimelineFrame): Clip[];
1042
+ /**
1043
+ * Get all clips in a frame range
1044
+ *
1045
+ * @param start - Start frame
1046
+ * @param end - End frame
1047
+ * @returns Array of clips in the range
1048
+ */
1049
+ getClipsInRange(start: TimelineFrame, end: TimelineFrame): Clip[];
1050
+ /**
1051
+ * Get all clips in the timeline
1052
+ *
1053
+ * @returns Array of all clips
1054
+ */
1055
+ getAllClips(): Clip[];
1056
+ /**
1057
+ * Get all tracks in the timeline
1058
+ *
1059
+ * @returns Array of all tracks
1060
+ */
1061
+ getAllTracks(): readonly Track[];
1062
+ /**
1063
+ * Ripple delete - delete clip and shift subsequent clips left
1064
+ *
1065
+ * @param clipId - ID of the clip to delete
1066
+ * @returns Dispatch result
1067
+ */
1068
+ rippleDelete(clipId: string): {
1069
+ accepted: boolean;
1070
+ errors?: {
1071
+ code: string;
1072
+ message: string;
1073
+ }[];
1074
+ };
1075
+ /**
1076
+ * Ripple trim - trim clip end and shift subsequent clips
1077
+ *
1078
+ * @param clipId - ID of the clip to trim
1079
+ * @param newEnd - New end frame for the clip
1080
+ * @returns Dispatch result
1081
+ */
1082
+ rippleTrim(clipId: string, newEnd: TimelineFrame): {
1083
+ accepted: boolean;
1084
+ errors?: {
1085
+ code: string;
1086
+ message: string;
1087
+ }[];
1088
+ };
1089
+ /**
1090
+ * Insert edit - insert clip and shift subsequent clips right
1091
+ *
1092
+ * @param trackId - ID of the track to insert into
1093
+ * @param clip - Clip to insert
1094
+ * @param atFrame - Frame to insert at
1095
+ * @returns Dispatch result
1096
+ */
1097
+ insertEdit(trackId: string, clip: Clip, atFrame: TimelineFrame): {
1098
+ accepted: boolean;
1099
+ errors?: {
1100
+ code: string;
1101
+ message: string;
1102
+ }[];
1103
+ };
1104
+ /**
1105
+ * Ripple move - move clip and shift surrounding clips to accommodate
1106
+ *
1107
+ * This moves a clip to a new position while maintaining timeline continuity:
1108
+ * - Closes the gap at the source position
1109
+ * - Makes space at the destination position
1110
+ * - All operations are atomic (single undo entry)
1111
+ *
1112
+ * @param clipId - ID of the clip to move
1113
+ * @param newStart - New start frame for the clip
1114
+ * @returns Dispatch result
1115
+ */
1116
+ rippleMove(clipId: string, newStart: TimelineFrame): {
1117
+ accepted: boolean;
1118
+ errors?: {
1119
+ code: string;
1120
+ message: string;
1121
+ }[];
1122
+ };
1123
+ /**
1124
+ * Insert move - move clip and shift destination clips right
1125
+ *
1126
+ * This moves a clip to a new position without closing the gap at source:
1127
+ * - Leaves gap at the source position
1128
+ * - Pushes all clips at destination right to make space
1129
+ * - All operations are atomic (single undo entry)
1130
+ *
1131
+ * @param clipId - ID of the clip to move
1132
+ * @param newStart - New start frame for the clip
1133
+ * @returns Dispatch result
1134
+ */
1135
+ insertMove(clipId: string, newStart: TimelineFrame): {
1136
+ accepted: boolean;
1137
+ errors?: {
1138
+ code: string;
1139
+ message: string;
1140
+ }[];
1141
+ };
1142
+ }
1143
+
1144
+ /**
1145
+ * OPERATION PRIMITIVES — Phase 0 compliant
1146
+ *
1147
+ * The ONLY way to express a mutation in the engine.
1148
+ * All mutations flow through: OperationPrimitive[] → Transaction → Dispatcher.
1149
+ *
1150
+ * RULE: Never add a new mutation function.
1151
+ * Add a new type to OperationPrimitive, handle it in the Dispatcher switch,
1152
+ * update the InvariantChecker, and update OPERATIONS.md.
1153
+ *
1154
+ * RULE: Transactions are all-or-nothing.
1155
+ * If any primitive fails validation, the entire Transaction is rejected.
1156
+ */
1157
+
1158
+ type OperationPrimitive = {
1159
+ type: 'MOVE_CLIP';
1160
+ clipId: ClipId;
1161
+ newTimelineStart: TimelineFrame;
1162
+ targetTrackId?: TrackId;
1163
+ } | {
1164
+ type: 'RESIZE_CLIP';
1165
+ clipId: ClipId;
1166
+ edge: 'start' | 'end';
1167
+ newFrame: TimelineFrame;
1168
+ } | {
1169
+ type: 'SLICE_CLIP';
1170
+ clipId: ClipId;
1171
+ atFrame: TimelineFrame;
1172
+ } | {
1173
+ type: 'DELETE_CLIP';
1174
+ clipId: ClipId;
1175
+ } | {
1176
+ type: 'INSERT_CLIP';
1177
+ clip: Clip;
1178
+ trackId: TrackId;
1179
+ } | {
1180
+ type: 'SET_MEDIA_BOUNDS';
1181
+ clipId: ClipId;
1182
+ mediaIn: TimelineFrame;
1183
+ mediaOut: TimelineFrame;
1184
+ } | {
1185
+ type: 'SET_CLIP_ENABLED';
1186
+ clipId: ClipId;
1187
+ enabled: boolean;
1188
+ } | {
1189
+ type: 'SET_CLIP_REVERSED';
1190
+ clipId: ClipId;
1191
+ reversed: boolean;
1192
+ } | {
1193
+ type: 'SET_CLIP_SPEED';
1194
+ clipId: ClipId;
1195
+ speed: number;
1196
+ } | {
1197
+ type: 'SET_CLIP_COLOR';
1198
+ clipId: ClipId;
1199
+ color: string | null;
1200
+ } | {
1201
+ type: 'SET_CLIP_NAME';
1202
+ clipId: ClipId;
1203
+ name: string | null;
1204
+ } | {
1205
+ type: 'ADD_TRACK';
1206
+ track: Track;
1207
+ } | {
1208
+ type: 'DELETE_TRACK';
1209
+ trackId: TrackId;
1210
+ } | {
1211
+ type: 'REORDER_TRACK';
1212
+ trackId: TrackId;
1213
+ newIndex: number;
1214
+ } | {
1215
+ type: 'SET_TRACK_HEIGHT';
1216
+ trackId: TrackId;
1217
+ height: number;
1218
+ } | {
1219
+ type: 'SET_TRACK_NAME';
1220
+ trackId: TrackId;
1221
+ name: string;
1222
+ } | {
1223
+ type: 'REGISTER_ASSET';
1224
+ asset: Asset;
1225
+ } | {
1226
+ type: 'UNREGISTER_ASSET';
1227
+ assetId: AssetId;
1228
+ } | {
1229
+ type: 'SET_ASSET_STATUS';
1230
+ assetId: AssetId;
1231
+ status: AssetStatus;
1232
+ } | {
1233
+ type: 'RENAME_TIMELINE';
1234
+ name: string;
1235
+ } | {
1236
+ type: 'SET_TIMELINE_DURATION';
1237
+ duration: TimelineFrame;
1238
+ } | {
1239
+ type: 'SET_TIMELINE_START_TC';
1240
+ startTimecode: Timecode;
1241
+ } | {
1242
+ type: 'SET_SEQUENCE_SETTINGS';
1243
+ settings: Partial<SequenceSettings>;
1244
+ } | {
1245
+ type: 'ADD_MARKER';
1246
+ marker: Marker;
1247
+ } | {
1248
+ type: 'MOVE_MARKER';
1249
+ markerId: MarkerId;
1250
+ newFrame: TimelineFrame;
1251
+ } | {
1252
+ type: 'DELETE_MARKER';
1253
+ markerId: MarkerId;
1254
+ } | {
1255
+ type: 'SET_IN_POINT';
1256
+ frame: TimelineFrame | null;
1257
+ } | {
1258
+ type: 'SET_OUT_POINT';
1259
+ frame: TimelineFrame | null;
1260
+ } | {
1261
+ type: 'ADD_BEAT_GRID';
1262
+ beatGrid: BeatGrid;
1263
+ } | {
1264
+ type: 'REMOVE_BEAT_GRID';
1265
+ } | {
1266
+ type: 'INSERT_GENERATOR';
1267
+ generator: Generator;
1268
+ trackId: TrackId;
1269
+ atFrame: TimelineFrame;
1270
+ } | {
1271
+ type: 'ADD_CAPTION';
1272
+ caption: Omit<Caption, 'style'> & {
1273
+ style?: CaptionStyle;
1274
+ };
1275
+ trackId: TrackId;
1276
+ } | {
1277
+ type: 'EDIT_CAPTION';
1278
+ captionId: CaptionId;
1279
+ trackId: TrackId;
1280
+ text?: string;
1281
+ language?: string;
1282
+ style?: Partial<CaptionStyle>;
1283
+ burnIn?: boolean;
1284
+ startFrame?: TimelineFrame;
1285
+ endFrame?: TimelineFrame;
1286
+ } | {
1287
+ type: 'DELETE_CAPTION';
1288
+ captionId: CaptionId;
1289
+ trackId: TrackId;
1290
+ } | {
1291
+ type: 'ADD_EFFECT';
1292
+ clipId: ClipId;
1293
+ effect: Effect;
1294
+ } | {
1295
+ type: 'REMOVE_EFFECT';
1296
+ clipId: ClipId;
1297
+ effectId: EffectId;
1298
+ } | {
1299
+ type: 'REORDER_EFFECT';
1300
+ clipId: ClipId;
1301
+ effectId: EffectId;
1302
+ newIndex: number;
1303
+ } | {
1304
+ type: 'SET_EFFECT_ENABLED';
1305
+ clipId: ClipId;
1306
+ effectId: EffectId;
1307
+ enabled: boolean;
1308
+ } | {
1309
+ type: 'SET_EFFECT_PARAM';
1310
+ clipId: ClipId;
1311
+ effectId: EffectId;
1312
+ key: string;
1313
+ value: number | string | boolean;
1314
+ } | {
1315
+ type: 'ADD_KEYFRAME';
1316
+ clipId: ClipId;
1317
+ effectId: EffectId;
1318
+ keyframe: Keyframe;
1319
+ } | {
1320
+ type: 'MOVE_KEYFRAME';
1321
+ clipId: ClipId;
1322
+ effectId: EffectId;
1323
+ keyframeId: KeyframeId;
1324
+ newFrame: TimelineFrame;
1325
+ } | {
1326
+ type: 'DELETE_KEYFRAME';
1327
+ clipId: ClipId;
1328
+ effectId: EffectId;
1329
+ keyframeId: KeyframeId;
1330
+ } | {
1331
+ type: 'SET_KEYFRAME_EASING';
1332
+ clipId: ClipId;
1333
+ effectId: EffectId;
1334
+ keyframeId: KeyframeId;
1335
+ easing: EasingCurve;
1336
+ } | {
1337
+ type: 'SET_CLIP_TRANSFORM';
1338
+ clipId: ClipId;
1339
+ transform: Partial<ClipTransform>;
1340
+ } | {
1341
+ type: 'SET_AUDIO_PROPERTIES';
1342
+ clipId: ClipId;
1343
+ properties: Partial<AudioProperties>;
1344
+ } | {
1345
+ type: 'ADD_TRANSITION';
1346
+ clipId: ClipId;
1347
+ transition: Transition;
1348
+ } | {
1349
+ type: 'DELETE_TRANSITION';
1350
+ clipId: ClipId;
1351
+ } | {
1352
+ type: 'SET_TRANSITION_DURATION';
1353
+ clipId: ClipId;
1354
+ durationFrames: number;
1355
+ } | {
1356
+ type: 'SET_TRANSITION_ALIGNMENT';
1357
+ clipId: ClipId;
1358
+ alignment: TransitionAlignment;
1359
+ } | {
1360
+ type: 'LINK_CLIPS';
1361
+ linkGroup: LinkGroup;
1362
+ } | {
1363
+ type: 'UNLINK_CLIPS';
1364
+ linkGroupId: LinkGroupId;
1365
+ } | {
1366
+ type: 'ADD_TRACK_GROUP';
1367
+ trackGroup: TrackGroup;
1368
+ } | {
1369
+ type: 'DELETE_TRACK_GROUP';
1370
+ trackGroupId: TrackGroupId;
1371
+ } | {
1372
+ type: 'SET_TRACK_BLEND_MODE';
1373
+ trackId: TrackId;
1374
+ blendMode: string;
1375
+ } | {
1376
+ type: 'SET_TRACK_OPACITY';
1377
+ trackId: TrackId;
1378
+ opacity: number;
1379
+ };
1380
+ /**
1381
+ * Transaction — an atomic, labeled batch of OperationPrimitives.
1382
+ *
1383
+ * All primitives in a Transaction are validated before any are applied.
1384
+ * If one fails, none are applied. This is the all-or-nothing rule.
1385
+ */
1386
+ type Transaction = {
1387
+ readonly id: string;
1388
+ readonly label: string;
1389
+ readonly timestamp: number;
1390
+ readonly operations: readonly OperationPrimitive[];
1391
+ };
1392
+ 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';
1393
+ type DispatchResult = {
1394
+ accepted: true;
1395
+ nextState: TimelineState;
1396
+ } | {
1397
+ accepted: false;
1398
+ reason: RejectionReason;
1399
+ message: string;
1400
+ };
1401
+ 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';
1402
+ type InvariantViolation = {
1403
+ readonly type: ViolationType;
1404
+ readonly entityId: string;
1405
+ readonly message: string;
1406
+ };
1407
+
1408
+ /**
1409
+ * DISPATCHER — Phase 0 compliant
1410
+ *
1411
+ * The ONLY entry point for mutating TimelineState.
1412
+ * Validates first, applies atomically, checks invariants.
1413
+ *
1414
+ * Algorithm:
1415
+ * 1. For each operation: run per-primitive validator → reject immediately on failure
1416
+ * 2. Apply all operations sequentially to get proposedState
1417
+ * 3. Run checkInvariants(proposedState) → reject on any violation
1418
+ * 4. Bump timeline.version by 1 and return accepted
1419
+ *
1420
+ * RULE: If one primitive fails, zero primitives are applied.
1421
+ */
1422
+
1423
+ declare function dispatch(state: TimelineState, transaction: Transaction): DispatchResult;
1424
+
1425
+ /**
1426
+ * INVARIANT CHECKER — Phase 0 compliant
1427
+ *
1428
+ * The most critical file in the engine.
1429
+ * checkInvariants() runs after every proposed state change inside the Dispatcher.
1430
+ * Zero violations is the only acceptable result in tests and at commit time.
1431
+ *
1432
+ * RULE: Run checkInvariants in EVERY test after every state mutation.
1433
+ */
1434
+
1435
+ declare function checkInvariants(state: TimelineState): InvariantViolation[];
1436
+
1437
+ /**
1438
+ * Transaction compression policy — Phase 7 Step 3
1439
+ *
1440
+ * Rapid same-type ops within a time window can be merged
1441
+ * into a single history entry (last-write-wins).
1442
+ */
1443
+ type CompressionPolicy = {
1444
+ readonly kind: 'none';
1445
+ } | {
1446
+ readonly kind: 'last-write-wins';
1447
+ readonly windowMs: number;
1448
+ };
1449
+ type CompressibleOpType = 'MOVE_CLIP' | 'SET_CLIP_TRANSFORM' | 'SET_AUDIO_PROPERTIES' | 'SET_EFFECT_PARAM' | 'MOVE_KEYFRAME' | 'SET_TRANSITION_DURATION' | 'MOVE_MARKER' | 'SET_IN_POINT' | 'SET_OUT_POINT' | 'SET_TRACK_OPACITY';
1450
+ declare const DEFAULT_COMPRESSION_POLICY: CompressionPolicy;
1451
+ declare const NO_COMPRESSION: CompressionPolicy;
1452
+
1453
+ /**
1454
+ * HISTORY ENGINE
1455
+ *
1456
+ * Snapshot-based undo/redo system for timeline state.
1457
+ *
1458
+ * Two APIs:
1459
+ * - HistoryState + pure functions (createHistory, pushHistory, undo, redo)
1460
+ * - HistoryStack class with compression, checkpoints, and persistence
1461
+ */
1462
+
1463
+ /**
1464
+ * HistoryState - The history container
1465
+ *
1466
+ * Contains:
1467
+ * - past: Array of previous states (oldest first)
1468
+ * - present: Current state
1469
+ * - future: Array of states that can be redone (newest first)
1470
+ * - limit: Maximum number of past states to keep
1471
+ */
1472
+ interface HistoryState {
1473
+ past: TimelineState[];
1474
+ present: TimelineState;
1475
+ future: TimelineState[];
1476
+ limit: number;
1477
+ }
1478
+ /**
1479
+ * Create a new history state
1480
+ *
1481
+ * @param initialState - Initial timeline state
1482
+ * @param limit - Maximum number of past states to keep (default: 50)
1483
+ * @returns A new HistoryState
1484
+ */
1485
+ declare function createHistory(initialState: TimelineState, limit?: number): HistoryState;
1486
+ /**
1487
+ * Push a new state to history
1488
+ *
1489
+ * Moves current state to past, sets new state as present,
1490
+ * and clears future (can't redo after new action).
1491
+ *
1492
+ * @param history - Current history state
1493
+ * @param newState - New timeline state to push
1494
+ * @returns New history state with new state pushed
1495
+ */
1496
+ declare function pushHistory(history: HistoryState, newState: TimelineState): HistoryState;
1497
+ /**
1498
+ * Undo the last action
1499
+ *
1500
+ * Moves current state to future, pops last state from past
1501
+ * and sets it as present.
1502
+ *
1503
+ * @param history - Current history state
1504
+ * @returns New history state with undo applied
1505
+ */
1506
+ declare function undo(history: HistoryState): HistoryState;
1507
+ /**
1508
+ * Redo the last undone action
1509
+ *
1510
+ * Moves current state to past, pops first state from future
1511
+ * and sets it as present.
1512
+ *
1513
+ * @param history - Current history state
1514
+ * @returns New history state with redo applied
1515
+ */
1516
+ declare function redo(history: HistoryState): HistoryState;
1517
+ /**
1518
+ * Check if undo is available
1519
+ *
1520
+ * @param history - Current history state
1521
+ * @returns true if undo is available
1522
+ */
1523
+ declare function canUndo(history: HistoryState): boolean;
1524
+ /**
1525
+ * Check if redo is available
1526
+ *
1527
+ * @param history - Current history state
1528
+ * @returns true if redo is available
1529
+ */
1530
+ declare function canRedo(history: HistoryState): boolean;
1531
+ /**
1532
+ * Get the current state from history
1533
+ *
1534
+ * @param history - Current history state
1535
+ * @returns The current timeline state
1536
+ */
1537
+ declare function getCurrentState(history: HistoryState): TimelineState;
1538
+ type HistoryEntry = {
1539
+ readonly state: TimelineState;
1540
+ readonly transaction: Transaction;
1541
+ };
1542
+ declare class HistoryStack {
1543
+ private entries;
1544
+ private undoIndex;
1545
+ private limit;
1546
+ private compressor;
1547
+ private clock;
1548
+ private checkpoints;
1549
+ constructor(limit?: number, policy?: CompressionPolicy, clock?: () => number);
1550
+ push(entry: HistoryEntry): void;
1551
+ pushWithCompression(entry: HistoryEntry, transaction: Transaction): void;
1552
+ resetCompression(): void;
1553
+ undo(): TimelineState | null;
1554
+ redo(): TimelineState | null;
1555
+ getCurrentState(): TimelineState | null;
1556
+ canUndo(): boolean;
1557
+ canRedo(): boolean;
1558
+ saveCheckpoint(name: string): void;
1559
+ restoreCheckpoint(name: string): HistoryEntry | null;
1560
+ listCheckpoints(): string[];
1561
+ clearCheckpoint(name: string): void;
1562
+ serialize(): string;
1563
+ static deserialize(raw: string, limit?: number, policy?: CompressionPolicy, clock?: () => number): HistoryStack;
1564
+ softLimitWarning(): boolean;
1565
+ }
1566
+
1567
+ /**
1568
+ * TransactionCompressor — Phase 7 Step 3
1569
+ *
1570
+ * Decides whether a transaction should be merged into the previous
1571
+ * history entry (same op type within window).
1572
+ */
1573
+
1574
+ declare class TransactionCompressor {
1575
+ private lastOpType;
1576
+ private lastTime;
1577
+ private policy;
1578
+ private clock;
1579
+ constructor(policy?: CompressionPolicy, clock?: () => number);
1580
+ shouldCompress(transaction: Transaction, now: number): boolean;
1581
+ record(transaction: Transaction, now: number): void;
1582
+ reset(): void;
1583
+ }
1584
+
1585
+ /**
1586
+ * SNAP INDEX — Phase 1
1587
+ *
1588
+ * Pure functions. Zero React/DOM imports. Zero mutation.
1589
+ *
1590
+ * Phase 1 snap sources: ClipStart, ClipEnd, Playhead.
1591
+ * Phase 2 will add: Marker, InPoint, OutPoint.
1592
+ * Phase 3 will add: BeatGrid.
1593
+ *
1594
+ * Priority table (do not change values):
1595
+ * Marker: 100
1596
+ * InPoint: 90
1597
+ * OutPoint: 90
1598
+ * ClipStart: 80
1599
+ * ClipEnd: 80
1600
+ * Playhead: 70
1601
+ * BeatGrid: 50
1602
+ */
1603
+
1604
+ /**
1605
+ * All snap point sources across phases.
1606
+ * Defined in full now so SnapPoint & allowedTypes filters are stable.
1607
+ */
1608
+ type SnapPointType = 'ClipStart' | 'ClipEnd' | 'Playhead' | 'Marker' | 'InPoint' | 'OutPoint' | 'BeatGrid';
1609
+ type SnapPoint = {
1610
+ readonly frame: TimelineFrame;
1611
+ readonly type: SnapPointType;
1612
+ readonly priority: number;
1613
+ readonly trackId: TrackId | null;
1614
+ readonly sourceId: string;
1615
+ };
1616
+ type SnapIndex = {
1617
+ readonly points: readonly SnapPoint[];
1618
+ readonly builtAt: number;
1619
+ readonly enabled: boolean;
1620
+ };
1621
+ /**
1622
+ * Build a SnapIndex from committed state + playhead position.
1623
+ *
1624
+ * RULE: Call via queueMicrotask after accepted dispatch.
1625
+ * Never call during a drag (pointer move).
1626
+ *
1627
+ * Phase 1 sources pulled (in order):
1628
+ * 1. ClipStart + ClipEnd from every clip on every track
1629
+ * 2. Playhead position (trackId = null)
1630
+ */
1631
+ declare function buildSnapIndex(state: TimelineState, playheadFrame: TimelineFrame, enabled?: boolean): SnapIndex;
1632
+ /**
1633
+ * Find the highest-priority snap candidate within radiusFrames.
1634
+ *
1635
+ * Returns null when:
1636
+ * - index.enabled is false
1637
+ * - no point is within radiusFrames of frame
1638
+ *
1639
+ * Tiebreak (equidistant candidates): highest priority wins.
1640
+ * Second tiebreak (equal priority): first in sorted order.
1641
+ *
1642
+ * @param exclude sourceIds to skip (e.g. the clip being dragged)
1643
+ * @param allowedTypes if provided, only consider points of these types
1644
+ */
1645
+ declare function nearest(index: SnapIndex, frame: TimelineFrame, radiusFrames: number, exclude?: readonly string[], allowedTypes?: readonly SnapPointType[]): SnapPoint | null;
1646
+ /**
1647
+ * Return a new SnapIndex with enabled toggled.
1648
+ * Does NOT rebuild points — pure field update.
1649
+ */
1650
+ declare function toggleSnap(index: SnapIndex, enabled: boolean): SnapIndex;
1651
+
1652
+ /**
1653
+ * SnapIndexManager — Phase 7 Step 2
1654
+ *
1655
+ * Debounces SnapIndex rebuilds using queueMicrotask.
1656
+ * Multiple scheduleRebuild() calls in one turn → single rebuild.
1657
+ */
1658
+
1659
+ declare class SnapIndexManager {
1660
+ private index;
1661
+ private state;
1662
+ private pending;
1663
+ getIndex(): SnapIndex | null;
1664
+ scheduleRebuild(state: TimelineState): void;
1665
+ rebuildSync(state: TimelineState): void;
1666
+ get isPending(): boolean;
1667
+ }
1668
+
1669
+ /**
1670
+ * TOOL CONTRACT TYPES — Phase 1
1671
+ *
1672
+ * Zero implementation. Zero imports from React or DOM.
1673
+ * Every ITool must satisfy this interface exactly.
1674
+ *
1675
+ * RULES (from ITOOL_CONTRACT.md):
1676
+ * - onPointerMove NEVER calls dispatch
1677
+ * - onPointerUp NEVER mutates instance state
1678
+ * - onKeyDown, onKeyUp, onCancel are REQUIRED — implement as no-ops if unused
1679
+ */
1680
+
1681
+ type ToolId = string & {
1682
+ readonly __brand: 'ToolId';
1683
+ };
1684
+ declare function toToolId(s: string): ToolId;
1685
+ /** Keyboard modifier state — available on ToolContext so getCursor() can
1686
+ * react to held keys even when no pointer event is firing. */
1687
+ type Modifiers = {
1688
+ readonly shift: boolean;
1689
+ readonly alt: boolean;
1690
+ readonly ctrl: boolean;
1691
+ readonly meta: boolean;
1692
+ };
1693
+ /** Normalised pointer event in frame-space.
1694
+ * ToolRouter populates clipId/trackId via hit-test — tools never recompute it.
1695
+ * Optional edge is set when click is within clip left/right hit zone (e.g. for trim). */
1696
+ type TimelinePointerEvent = {
1697
+ readonly frame: TimelineFrame;
1698
+ readonly trackId: TrackId | null;
1699
+ readonly clipId: ClipId | null;
1700
+ readonly x: number;
1701
+ readonly y: number;
1702
+ readonly buttons: number;
1703
+ readonly shiftKey: boolean;
1704
+ readonly altKey: boolean;
1705
+ readonly metaKey: boolean;
1706
+ /** When over a clip: 'left' | 'right' if within edge hit zone, else 'none'. */
1707
+ readonly edge?: 'left' | 'right' | 'none';
1708
+ };
1709
+ type TimelineKeyEvent = {
1710
+ readonly key: string;
1711
+ readonly code: string;
1712
+ readonly shiftKey: boolean;
1713
+ readonly altKey: boolean;
1714
+ readonly metaKey: boolean;
1715
+ readonly ctrlKey: boolean;
1716
+ /** True when key is held and OS is firing repeated keydowns. */
1717
+ readonly repeat?: boolean;
1718
+ };
1719
+ /** Pixel + frame region swept by a rubber-band (marquee) selection drag.
1720
+ * Populated by SelectionTool during rubber-band drags. */
1721
+ type RubberBandRegion = {
1722
+ readonly startFrame: TimelineFrame;
1723
+ readonly endFrame: TimelineFrame;
1724
+ readonly startY: number;
1725
+ readonly endY: number;
1726
+ };
1727
+ /** Ghost state produced by onPointerMove.
1728
+ * isProvisional: true is a compile-time discriminant so resolveClip()
1729
+ * can distinguish provisional from committed Clip[] arrays. */
1730
+ type ProvisionalState = {
1731
+ readonly clips: readonly Clip[];
1732
+ readonly rubberBand?: RubberBandRegion;
1733
+ readonly isProvisional: true;
1734
+ };
1735
+ /** Injected by TimelineEngine on every event call.
1736
+ * Tools never import TimelineEngine. They never call dispatch() directly. */
1737
+ type ToolContext = {
1738
+ readonly state: TimelineState;
1739
+ readonly snapIndex: SnapIndex;
1740
+ readonly pixelsPerFrame: number;
1741
+ /** Current modifier key state — updates on every pointer/key event. */
1742
+ readonly modifiers: Modifiers;
1743
+ /** Convert a client-pixel x-position to a TimelineFrame. */
1744
+ readonly frameAtX: (x: number) => TimelineFrame;
1745
+ /** Return the TrackId whose row contains client-pixel y, or null. */
1746
+ readonly trackAtY: (y: number) => TrackId | null;
1747
+ /** Query snap and return the snapped frame (or original if no hit).
1748
+ * Handles enabled/disabled, radius, exclusion, and type filter internally.
1749
+ * Tools never see radiusFrames or the enabled flag. */
1750
+ readonly snap: (frame: TimelineFrame, exclude?: readonly string[], allowedTypes?: readonly SnapPointType[]) => TimelineFrame;
1751
+ };
1752
+ interface ITool {
1753
+ readonly id: ToolId;
1754
+ /** Single-character keyboard shortcut, e.g. 'v', 'b', 'r'. Empty string = no shortcut. */
1755
+ readonly shortcutKey: string;
1756
+ /** Return the CSS cursor string for the current tool + modifier state.
1757
+ * Called on every pointermove — must be cheap. */
1758
+ getCursor(ctx: ToolContext): string;
1759
+ /** Return the SnapPointType categories this tool snaps to.
1760
+ * Used by ctx.snap() to filter the snap index automatically. */
1761
+ getSnapCandidateTypes(): readonly SnapPointType[];
1762
+ onPointerDown(event: TimelinePointerEvent, ctx: ToolContext): void;
1763
+ /** Return ProvisionalState for ghost rendering.
1764
+ * MUST NOT call dispatch. MUST NOT call engine methods. */
1765
+ onPointerMove(event: TimelinePointerEvent, ctx: ToolContext): ProvisionalState | null;
1766
+ /** Return a Transaction to commit, or null if this gesture produces no edit.
1767
+ * MUST NOT mutate any instance state. */
1768
+ onPointerUp(event: TimelinePointerEvent, ctx: ToolContext): Transaction | null;
1769
+ /** Handle a keydown — return a Transaction or null.
1770
+ * Required — implement as `return null` if unused. */
1771
+ onKeyDown(event: TimelineKeyEvent, ctx: ToolContext): Transaction | null;
1772
+ /** Handle a keyup — no return value.
1773
+ * Required — implement as no-op if unused. */
1774
+ onKeyUp(event: TimelineKeyEvent, ctx: ToolContext): void;
1775
+ /** Called when a gesture is interrupted (Escape, tool switch mid-drag).
1776
+ * Required — implement as no-op if unused. */
1777
+ onCancel(): void;
1778
+ }
1779
+
1780
+ /**
1781
+ * TOOL REGISTRY — Phase 1
1782
+ *
1783
+ * Pure functions. No classes. No React. No state mutation.
1784
+ *
1785
+ * ToolRegistry is immutable data — activateTool returns a NEW registry.
1786
+ * The active tool lives here, not on TimelineEngine, keeping the engine thin.
1787
+ *
1788
+ * RULES:
1789
+ * - activateTool calls outgoing.onCancel() before switching
1790
+ * - activateTool throws on unknown id (programmer error, never user error)
1791
+ * - NoOpTool is the canonical do-nothing ITool (test double + startup default)
1792
+ */
1793
+
1794
+ type ToolRegistry = {
1795
+ readonly tools: ReadonlyMap<ToolId, ITool>;
1796
+ readonly activeToolId: ToolId;
1797
+ };
1798
+ /**
1799
+ * Create an initial registry from an array of tools.
1800
+ *
1801
+ * @throws if defaultId is not present in the tools array
1802
+ */
1803
+ declare function createRegistry(tools: readonly ITool[], defaultId: ToolId): ToolRegistry;
1804
+ /**
1805
+ * Activate a new tool.
1806
+ *
1807
+ * Steps (must run in order):
1808
+ * 1. Call outgoing tool's onCancel() — cleans up any in-progress drag state
1809
+ * 2. Validate that the new id exists in the registry
1810
+ * 3. Return a new ToolRegistry with activeToolId updated
1811
+ *
1812
+ * @throws if id is not registered
1813
+ */
1814
+ declare function activateTool(registry: ToolRegistry, id: ToolId): ToolRegistry;
1815
+ /**
1816
+ * Return the currently active ITool.
1817
+ * Never returns undefined — registry invariant guarantees activeToolId is registered.
1818
+ */
1819
+ declare function getActiveTool(registry: ToolRegistry): ITool;
1820
+ /**
1821
+ * Return a new registry with the tool added.
1822
+ * If a tool with the same id already exists, it is replaced.
1823
+ * activeToolId is unchanged.
1824
+ */
1825
+ declare function registerTool(registry: ToolRegistry, tool: ITool): ToolRegistry;
1826
+ /**
1827
+ * Satisfies ITool with no side effects.
1828
+ *
1829
+ * Use for:
1830
+ * - Test doubles (spread and override only the methods you need)
1831
+ * - Default active tool on engine startup
1832
+ * - ToolRouter smoke tests
1833
+ *
1834
+ * onCancel() is a deliberate no-op: NoOpTool has no drag state to clean up.
1835
+ * Real tools will clear instance variables there.
1836
+ */
1837
+ declare const NoOpTool: ITool;
1838
+
1839
+ /**
1840
+ * PROVISIONAL MANAGER — Phase 1
1841
+ *
1842
+ * Manages ghost state during pointer drags.
1843
+ *
1844
+ * RULES (from ITOOL_CONTRACT.md):
1845
+ * - setProvisional / clearProvisional return NEW objects — never mutate
1846
+ * - resolveClip checks provisional first, then committed state
1847
+ * - The engine calls clearProvisional() BEFORE dispatching onPointerUp's tx
1848
+ * - Provisional updates trigger notify() so ghosts render immediately
1849
+ *
1850
+ * resolveClip priority:
1851
+ * 1. provisional.clips has a clip with this id → return ghost version
1852
+ * 2. clip exists in committed state → return committed
1853
+ * 3. clip absent from both (deleted mid-drag) → return undefined
1854
+ */
1855
+
1856
+ type ProvisionalManager = {
1857
+ readonly current: ProvisionalState | null;
1858
+ };
1859
+ /** Create an empty provisional manager (current = null). */
1860
+ declare function createProvisionalManager(): ProvisionalManager;
1861
+ /** Return a new manager with current set to state.
1862
+ * Pure — never mutates the original manager. */
1863
+ declare function setProvisional(_manager: ProvisionalManager, state: ProvisionalState): ProvisionalManager;
1864
+ /** Return a new manager with current set to null.
1865
+ * Pure — never mutates the original manager. */
1866
+ declare function clearProvisional(_manager: ProvisionalManager): ProvisionalManager;
1867
+ /**
1868
+ * Resolve which version of a clip to render.
1869
+ *
1870
+ * Priority:
1871
+ * 1. If manager.current has a clip with this id → return provisional (ghost)
1872
+ * 2. Otherwise → search committed state
1873
+ * 3. If absent from both (clip deleted mid-drag) → return undefined
1874
+ *
1875
+ * Returns undefined if the clip has been deleted from committed state
1876
+ * and is not in provisional. Components must handle this:
1877
+ * const clip = useClip(id)
1878
+ * if (!clip) return null ← required, not optional
1879
+ *
1880
+ * Call site in useClip selector:
1881
+ * () => resolveClip(id, engine.getSnapshot(), engine.getProvisionalManager())
1882
+ */
1883
+ declare function resolveClip(clipId: ClipId, state: TimelineState, manager: ProvisionalManager): Clip | undefined;
1884
+
1885
+ /**
1886
+ * MARKER SEARCH API — Phase 3 Step 2
1887
+ *
1888
+ * Pure functions. Search state.timeline.markers only.
1889
+ */
1890
+
1891
+ /**
1892
+ * Returns markers whose color exactly matches the given string.
1893
+ */
1894
+ declare function findMarkersByColor(state: TimelineState, color: string): Marker[];
1895
+ /**
1896
+ * Returns markers whose label contains the given string (case-insensitive).
1897
+ */
1898
+ declare function findMarkersByLabel(state: TimelineState, label: string): Marker[];
1899
+
1900
+ /**
1901
+ * SUBTITLE IMPORT — Phase 3 Step 3
1902
+ *
1903
+ * Pure functions for parsing SRT/VTT into Caption[].
1904
+ * No file IO. No DOM. No external deps.
1905
+ */
1906
+
1907
+ declare const defaultCaptionStyle: CaptionStyle;
1908
+ type SRTParseOptions = {
1909
+ language?: string;
1910
+ burnIn?: boolean;
1911
+ defaultStyle?: Partial<CaptionStyle>;
1912
+ };
1913
+ type VTTParseOptions = SRTParseOptions;
1914
+ declare function parseSRT(raw: string, fps: number, options?: SRTParseOptions): Caption[];
1915
+ declare function parseVTT(raw: string, fps: number, options?: VTTParseOptions): Caption[];
1916
+ declare function subtitleImportToOps(captions: Caption[], trackId: TrackId): OperationPrimitive[];
1917
+
1918
+ /**
1919
+ * SelectionTool — Phase 2
1920
+ *
1921
+ * The most complex tool. Handles four interaction modes:
1922
+ * MODE 1: Single click → select/deselect clip (no drag)
1923
+ * MODE 2: Single drag → move one clip, produce MOVE_CLIP Transaction
1924
+ * MODE 3: Multi drag → move all selected clips by uniform delta, N× MOVE_CLIP
1925
+ * MODE 4: Rubber-band → marquee select clips, no Transaction
1926
+ *
1927
+ * SELECTION CONTRACT:
1928
+ * Selection lives on this instance as Set<ClipId>.
1929
+ * It is NOT in TimelineState. It is NOT undoable.
1930
+ * onCancel() resets all instance state, including selection.
1931
+ *
1932
+ * GHOST CLIP CONTRACT (corrected in design review):
1933
+ * Ghost clips are ALWAYS built by reading the live clip from ctx.state
1934
+ * then overriding position fields. Never spread a stored clip snapshot.
1935
+ * originalPositions is ONLY used in onPointerUp for MOVE_CLIP delta math.
1936
+ *
1937
+ * RULES:
1938
+ * - Zero imports from React, DOM, @timeline/react, @timeline/ui
1939
+ * - onPointerMove must never call dispatch
1940
+ * - onPointerUp must never mutate instance state
1941
+ * - Every instance variable appears in onCancel() — no exceptions
1942
+ */
1943
+
1944
+ declare class SelectionTool implements ITool {
1945
+ readonly id: ToolId;
1946
+ readonly shortcutKey: string;
1947
+ private readonly selected;
1948
+ private mode;
1949
+ private dragStartFrame;
1950
+ private dragStartX;
1951
+ private dragStartY;
1952
+ private dragClipId;
1953
+ private isMultiDrag;
1954
+ /** Frame values only — no Clip objects. Used only in onPointerUp for delta math. */
1955
+ private originalPositions;
1956
+ private rubberBandStartFrame;
1957
+ private rubberBandStartY;
1958
+ private lastClientX;
1959
+ private lastHitEdge;
1960
+ getSelection(): ReadonlySet<ClipId>;
1961
+ clearSelection(): void;
1962
+ getCursor(_ctx: ToolContext): string;
1963
+ private _lastHoveredClipId;
1964
+ getSnapCandidateTypes(): readonly SnapPointType[];
1965
+ onPointerDown(event: TimelinePointerEvent, ctx: ToolContext): void;
1966
+ onPointerMove(event: TimelinePointerEvent, ctx: ToolContext): ProvisionalState | null;
1967
+ onPointerUp(event: TimelinePointerEvent, ctx: ToolContext): Transaction | null;
1968
+ onKeyDown(_event: TimelineKeyEvent, _ctx: ToolContext): Transaction | null;
1969
+ onKeyUp(_event: TimelineKeyEvent, _ctx: ToolContext): void;
1970
+ /**
1971
+ * Reset ALL instance state.
1972
+ * Every instance variable must appear here.
1973
+ * If a new variable is added to the class, it MUST be added here too.
1974
+ */
1975
+ onCancel(): void;
1976
+ /** Reset per-gesture drag state WITHOUT clearing selection. */
1977
+ private _resetDragState;
1978
+ }
1979
+
1980
+ /**
1981
+ * RazorTool — Phase 2 Step 2
1982
+ *
1983
+ * Click on a clip at any frame → split it into two clips at that frame.
1984
+ * Shift+click (ctx.modifiers.shift) → split ALL clips at that frame across ALL tracks.
1985
+ *
1986
+ * CONTRACT:
1987
+ * - No drag, no provisional ghost, no rubber-band
1988
+ * - onPointerMove always returns null
1989
+ * - Every Transaction is DELETE_CLIP + INSERT_CLIP(left) + INSERT_CLIP(right), per clip
1990
+ * - New ClipIds are generated by generateId() — replaceable in tests via _setIdGenerator()
1991
+ *
1992
+ * RULES:
1993
+ * - Zero imports from React, DOM, @timeline/react, @timeline/ui
1994
+ * - ctx.modifiers.shift is the authoritative source for shift detection (not event.shiftKey)
1995
+ * - Both halves need strictly positive duration — reject if atFrame is at clip boundary
1996
+ */
1997
+
1998
+ declare class RazorTool implements ITool {
1999
+ readonly id: ToolId;
2000
+ readonly shortcutKey: string;
2001
+ /** Snapped slice frame captured at onPointerDown. */
2002
+ private pendingFrame;
2003
+ /** ClipId hit at onPointerDown. null if clicking empty space or for shift+all. */
2004
+ private pendingClipId;
2005
+ getCursor(_ctx: ToolContext): string;
2006
+ getSnapCandidateTypes(): readonly SnapPointType[];
2007
+ onPointerDown(event: TimelinePointerEvent, ctx: ToolContext): void;
2008
+ onPointerMove(_event: TimelinePointerEvent, _ctx: ToolContext): ProvisionalState | null;
2009
+ onPointerUp(event: TimelinePointerEvent, ctx: ToolContext): Transaction | null;
2010
+ onKeyDown(_event: TimelineKeyEvent, _ctx: ToolContext): Transaction | null;
2011
+ onKeyUp(_event: TimelineKeyEvent, _ctx: ToolContext): void;
2012
+ /**
2013
+ * Reset ALL instance state.
2014
+ * Every instance variable must appear here.
2015
+ */
2016
+ onCancel(): void;
2017
+ private _findClip;
2018
+ /**
2019
+ * Slice every clip that contains `atFrame` across all tracks.
2020
+ * Groups operations per-clip: DELETE then INSERT left then INSERT right.
2021
+ * Tracks where no clip spans `atFrame` contribute zero operations.
2022
+ */
2023
+ private _sliceAllTracks;
2024
+ }
2025
+
2026
+ /**
2027
+ * RippleTrimTool — Phase 2 Step 3
2028
+ *
2029
+ * Drag a clip edge (start or end). The dragged edge moves.
2030
+ * All clips downstream of the edit point shift by the same delta.
2031
+ *
2032
+ * DOWNSTREAM DEFINITION:
2033
+ * END edge trim: clips with timelineStart >= original.timelineEnd (to the right)
2034
+ * START edge trim: clips with timelineEnd <= original.timelineStart (to the left)
2035
+ *
2036
+ * START EDGE SEMANTICS:
2037
+ * When the start edge moves right (+delta), left clips also shift right (+delta).
2038
+ * When the start edge moves left (-delta), left clips also shift left (-delta).
2039
+ * This is standard NLE ripple trim behavior (Premiere / Resolve convention).
2040
+ *
2041
+ * TRANSACTION ORDER:
2042
+ * RESIZE_CLIP first, then N× MOVE_CLIP.
2043
+ * Rolling-state validation means MOVE_CLIPs validate after RESIZE is applied.
2044
+ *
2045
+ * CLAMPING (applied before ghost and Transaction):
2046
+ * 1. Min duration: clip must remain ≥ 1 frame
2047
+ * 2. Media bounds: mediaIn must stay < mediaOut - 1 (START); mediaOut > mediaIn + 1 (END)
2048
+ * 3. Frame-0: for START trim, leftward shift must not push any left-clip below frame 0
2049
+ *
2050
+ * RULES:
2051
+ * - Zero imports from React, DOM, @timeline/react, @timeline/ui
2052
+ * - onPointerMove never dispatches
2053
+ * - onPointerUp never mutates instance state
2054
+ * - Every instance variable appears in onCancel()
2055
+ */
2056
+
2057
+ declare class RippleTrimTool implements ITool {
2058
+ readonly id: ToolId;
2059
+ readonly shortcutKey: string;
2060
+ private dragClipId;
2061
+ private dragEdge;
2062
+ /** Original clip bounds — frame values only, never a stale Clip object. */
2063
+ private dragOrigStart;
2064
+ private dragOrigEnd;
2065
+ private dragOrigMediaIn;
2066
+ private dragOrigMediaOut;
2067
+ /**
2068
+ * Original positions of downstream clips.
2069
+ * Keyed by ClipId. Both timelineStart and timelineEnd stored — ghost needs
2070
+ * both to render, MOVE_CLIP only needs start (but duration is end - start).
2071
+ */
2072
+ private originalDownstream;
2073
+ private lastHitEdge;
2074
+ private lastHoveredClipId;
2075
+ getCursor(_ctx: ToolContext): string;
2076
+ getSnapCandidateTypes(): readonly SnapPointType[];
2077
+ onPointerDown(event: TimelinePointerEvent, ctx: ToolContext): void;
2078
+ onPointerMove(event: TimelinePointerEvent, ctx: ToolContext): ProvisionalState | null;
2079
+ onPointerUp(event: TimelinePointerEvent, ctx: ToolContext): Transaction | null;
2080
+ onKeyDown(_event: TimelineKeyEvent, _ctx: ToolContext): Transaction | null;
2081
+ onKeyUp(_event: TimelineKeyEvent, _ctx: ToolContext): void;
2082
+ /** Reset ALL instance state. Every variable must appear here. */
2083
+ onCancel(): void;
2084
+ /**
2085
+ * Apply all clamping rules to the candidate newFrame.
2086
+ * Returns null if the resulting trim would produce a zero-or-negative-duration clip.
2087
+ */
2088
+ private _clampFrame;
2089
+ /**
2090
+ * Build the ProvisionalState showing trimmed clip + all shifted downstream clips.
2091
+ * Always reads live clip data from ctx.state — never spreads stored clip objects.
2092
+ */
2093
+ private _buildGhost;
2094
+ /** Reset per-drag instance state. Does NOT touch getCursor vars. */
2095
+ private _resetDragState;
2096
+ }
2097
+
2098
+ /**
2099
+ * RollTrimTool — Phase 2 Step 4
2100
+ *
2101
+ * Drag the boundary between two adjacent clips.
2102
+ * Left clip's end and right clip's start move together to the same frame.
2103
+ * Combined duration of both clips is unchanged.
2104
+ * No downstream ripple. No upstream ripple.
2105
+ *
2106
+ * TRANSACTION: 2× RESIZE_CLIP with identical newFrame. One history entry.
2107
+ *
2108
+ * CLAMP (precomputed at onPointerDown — only 5 instance vars needed):
2109
+ * minBoundary = max(leftOrig.timelineStart + 1,
2110
+ * origBoundary - (leftOrig.mediaOut - leftOrig.mediaIn - 1))
2111
+ * maxBoundary = min(rightOrig.timelineEnd - 1,
2112
+ * origBoundary + (rightOrig.mediaOut - rightOrig.mediaIn - 1))
2113
+ *
2114
+ * ORIGBOUNDARY AT onPointerUp:
2115
+ * Read from ctx.state (committed, not yet changed) — avoids a 6th instance var.
2116
+ *
2117
+ * RULES:
2118
+ * - Zero imports from React, DOM, @timeline/react, @timeline/ui
2119
+ * - onPointerMove never dispatches
2120
+ * - onPointerUp never mutates instance state
2121
+ * - Every instance variable appears in onCancel()
2122
+ * - Capture-before-reset pattern: compute clamp BEFORE _resetDragState()
2123
+ */
2124
+
2125
+ declare class RollTrimTool implements ITool {
2126
+ readonly id: ToolId;
2127
+ readonly shortcutKey: string;
2128
+ private leftClipId;
2129
+ private rightClipId;
2130
+ /**
2131
+ * Precomputed clamp bounds — computed once at onPointerDown from all 4 constraints.
2132
+ * Avoids storing all 8 original clip bounds as separate instance vars.
2133
+ */
2134
+ private minBoundary;
2135
+ private maxBoundary;
2136
+ /** True when the pointer is hovering a valid cut point (within EDGE_ZONE). */
2137
+ private isHoveringCut;
2138
+ getCursor(_ctx: ToolContext): string;
2139
+ getSnapCandidateTypes(): readonly SnapPointType[];
2140
+ onPointerDown(event: TimelinePointerEvent, ctx: ToolContext): void;
2141
+ onPointerMove(event: TimelinePointerEvent, ctx: ToolContext): ProvisionalState | null;
2142
+ onPointerUp(event: TimelinePointerEvent, ctx: ToolContext): Transaction | null;
2143
+ onKeyDown(_event: TimelineKeyEvent, _ctx: ToolContext): Transaction | null;
2144
+ onKeyUp(_event: TimelineKeyEvent, _ctx: ToolContext): void;
2145
+ /** Reset ALL instance state. Every variable must appear here. */
2146
+ onCancel(): void;
2147
+ private _buildGhost;
2148
+ private _resetDragState;
2149
+ }
2150
+
2151
+ /**
2152
+ * SlipTool — Phase 2 Step 5
2153
+ *
2154
+ * Drag a clip to shift its media window. The clip's timeline position is
2155
+ * unchanged — only mediaIn and mediaOut move together by the same delta.
2156
+ *
2157
+ * OPERATION: Single SET_MEDIA_BOUNDS. No MOVE_CLIP. No RESIZE_CLIP. Nothing else.
2158
+ *
2159
+ * DELTA: rawDelta = event.frame - dragStartFrame (no snapping — slip is in media space)
2160
+ *
2161
+ * CLAMP:
2162
+ * minDelta = -clip.mediaIn → mediaIn + delta >= 0
2163
+ * maxDelta = asset.intrinsicDuration - clip.mediaOut → mediaOut + delta <= intrinsicDuration
2164
+ * clampedDelta = clamp(rawDelta, minDelta, maxDelta)
2165
+ *
2166
+ * SNAP: none. getSnapCandidateTypes returns [].
2167
+ *
2168
+ * RULES:
2169
+ * - Zero imports from React, DOM, @timeline/react, @timeline/ui
2170
+ * - onPointerMove never dispatches
2171
+ * - onPointerUp never mutates instance state
2172
+ * - Every instance variable appears in onCancel()
2173
+ * - Capture-before-reset: compute delta BEFORE _resetDragState()
2174
+ */
2175
+
2176
+ declare class SlipTool implements ITool {
2177
+ readonly id: ToolId;
2178
+ readonly shortcutKey: string;
2179
+ /** Clip being slipped. Null when idle. */
2180
+ private dragClipId;
2181
+ /** Frame at which pointer went down. Delta = currentFrame - dragStartFrame. */
2182
+ private dragStartFrame;
2183
+ /** Staged by onPointerMove — getCursor() has no event parameter. */
2184
+ private isHoveringClip;
2185
+ getCursor(_ctx: ToolContext): string;
2186
+ getSnapCandidateTypes(): readonly SnapPointType[];
2187
+ onPointerDown(event: TimelinePointerEvent, _ctx: ToolContext): void;
2188
+ onPointerMove(event: TimelinePointerEvent, ctx: ToolContext): ProvisionalState | null;
2189
+ onPointerUp(event: TimelinePointerEvent, ctx: ToolContext): Transaction | null;
2190
+ onKeyDown(_event: TimelineKeyEvent, _ctx: ToolContext): Transaction | null;
2191
+ onKeyUp(_event: TimelineKeyEvent, _ctx: ToolContext): void;
2192
+ /** Reset ALL instance state. Every variable must appear here. */
2193
+ onCancel(): void;
2194
+ private _resetDragState;
2195
+ }
2196
+
2197
+ /**
2198
+ * RippleDeleteTool — Phase 2 Step 6
2199
+ *
2200
+ * Click a clip to delete it. All clips to the right on the same track
2201
+ * shift left by the deleted clip's duration. No drag. No provisional state.
2202
+ *
2203
+ * TRANSACTION:
2204
+ * DELETE_CLIP { clipId }
2205
+ * MOVE_CLIP×N — one per downstream clip, sorted LEFT-TO-RIGHT
2206
+ *
2207
+ * MOVE_CLIP ordering rule (OPERATIONS.md: delta is negative → left-to-right):
2208
+ * Leftmost clip moves first into space vacated by DELETE_CLIP.
2209
+ * Each subsequent clip moves into space vacated by the one before it.
2210
+ * Wrong order → OVERLAP rejection from rolling-state validator.
2211
+ *
2212
+ * ACTIVATION: RippleDeleteTool is activated programmatically (e.g. when Delete
2213
+ * is pressed while a clip is selected in SelectionTool). shortcutKey is empty
2214
+ * because 'delete' is not a single-char tool-activation key.
2215
+ *
2216
+ * RULES:
2217
+ * - Zero imports from React, DOM, @timeline/react, @timeline/ui
2218
+ * - onPointerMove never dispatches (returns null always)
2219
+ * - onPointerUp never mutates instance state
2220
+ * - Every instance variable appears in onCancel()
2221
+ * - Capture-before-reset pattern applied in onPointerUp
2222
+ */
2223
+
2224
+ declare class RippleDeleteTool implements ITool {
2225
+ readonly id: ToolId;
2226
+ readonly shortcutKey: string;
2227
+ /**
2228
+ * Clip targeted at onPointerDown. Read and cleared at onPointerUp.
2229
+ * No drag, no delta, no edge — this tool is click-only.
2230
+ */
2231
+ private pendingClipId;
2232
+ /** Staged by onPointerMove — getCursor() has no event parameter. */
2233
+ private isHoveringClip;
2234
+ getCursor(_ctx: ToolContext): string;
2235
+ getSnapCandidateTypes(): readonly SnapPointType[];
2236
+ onPointerDown(event: TimelinePointerEvent, _ctx: ToolContext): void;
2237
+ onPointerMove(event: TimelinePointerEvent, _ctx: ToolContext): ProvisionalState | null;
2238
+ onPointerUp(_event: TimelinePointerEvent, ctx: ToolContext): Transaction | null;
2239
+ onKeyDown(_event: TimelineKeyEvent, _ctx: ToolContext): Transaction | null;
2240
+ onKeyUp(_event: TimelineKeyEvent, _ctx: ToolContext): void;
2241
+ /** Reset ALL instance state. Every variable must appear here. */
2242
+ onCancel(): void;
2243
+ private _resetState;
2244
+ }
2245
+
2246
+ /**
2247
+ * RippleInsertTool — Phase 2 Step 7
2248
+ *
2249
+ * Drag a clip from an asset and drop it onto a track.
2250
+ * Clips at or after the drop point shift RIGHT by insertDuration.
2251
+ * The inserted clip lands exactly at the drop point.
2252
+ *
2253
+ * TRANSACTION ORDER — critical:
2254
+ * MOVE_CLIPs first (RIGHT-TO-LEFT — +delta rule)
2255
+ * INSERT_CLIP last (gap is now open after all MOVE_CLIPs)
2256
+ *
2257
+ * INSTANCE VARIABLE GROUPS:
2258
+ * Group A (pending-insert): set by setPendingInsert(), preserved across drops,
2259
+ * cleared only by onCancel(). Cannot be changed mid-drag (guard in setPendingInsert).
2260
+ * Group B (drag-tracking): set by onPointerDown(), cleared by onPointerUp() and onCancel().
2261
+ *
2262
+ * PROVISIONAL STATE:
2263
+ * Ghost inserted clip (sentinel id 'provisional-insert') + all shifted right-clips.
2264
+ * Ghost id is NEVER written to committed state — real clip gets new id at onPointerUp.
2265
+ *
2266
+ * RULES:
2267
+ * - Zero imports from React, DOM, @timeline/react, @timeline/ui
2268
+ * - onPointerMove never dispatches
2269
+ * - onPointerUp never mutates instance state (capture-before-reset)
2270
+ * - Every instance variable appears in onCancel()
2271
+ */
2272
+
2273
+ declare class RippleInsertTool implements ITool {
2274
+ readonly id: ToolId;
2275
+ readonly shortcutKey: string;
2276
+ private pendingAsset;
2277
+ private pendingMediaIn;
2278
+ private pendingMediaOut;
2279
+ private isDragging;
2280
+ /**
2281
+ * Configure what clip will be inserted on the next drag.
2282
+ * Preserves across drops — can be called once per asset, then drag many times.
2283
+ *
2284
+ * Guard: ignored if a drag is in progress — prevents ghost/Transaction mismatch
2285
+ * from async React state updates firing setPendingInsert mid-drag.
2286
+ */
2287
+ setPendingInsert(asset: Asset, mediaIn: TimelineFrame, mediaOut: TimelineFrame): void;
2288
+ getCursor(_ctx: ToolContext): string;
2289
+ getSnapCandidateTypes(): readonly SnapPointType[];
2290
+ onPointerDown(event: TimelinePointerEvent, _ctx: ToolContext): void;
2291
+ onPointerMove(event: TimelinePointerEvent, ctx: ToolContext): ProvisionalState | null;
2292
+ onPointerUp(event: TimelinePointerEvent, ctx: ToolContext): Transaction | null;
2293
+ onKeyDown(_event: TimelineKeyEvent, _ctx: ToolContext): Transaction | null;
2294
+ onKeyUp(_event: TimelineKeyEvent, _ctx: ToolContext): void;
2295
+ /** Reset ALL instance state. Every variable must appear here. */
2296
+ onCancel(): void;
2297
+ /** Reset Group B only. Group A (pending-insert) is preserved for re-use. */
2298
+ private _resetDragState;
2299
+ }
2300
+
2301
+ /**
2302
+ * HandTool — Phase 2 Step 8
2303
+ *
2304
+ * Scroll/pan the timeline viewport by dragging.
2305
+ * This tool has ZERO effect on TimelineState.
2306
+ *
2307
+ * - Never produces a Transaction (onPointerUp returns null always)
2308
+ * - Never calls dispatch
2309
+ * - Never returns ProvisionalState (onPointerMove returns null always)
2310
+ * - Never creates ClipIds (_setIdGenerator not needed)
2311
+ *
2312
+ * THE SCROLL CALLBACK:
2313
+ * The UI registers a callback via setScrollCallback().
2314
+ * On every onPointerMove during drag, HandTool fires:
2315
+ * scrollCallback(event.x - lastX) ← pixel delta, not frame delta
2316
+ * The UI handles scrollLeft adjustment. HandTool has no DOM access.
2317
+ *
2318
+ * The callback is optional — drag tracking activates regardless.
2319
+ * If no callback is registered, delta is computed but discarded.
2320
+ * This allows testing drag tracking without a live callback.
2321
+ *
2322
+ * RULES:
2323
+ * - Zero imports from React, DOM, @timeline/react, @timeline/ui
2324
+ * - Every instance variable appears in onCancel()
2325
+ */
2326
+
2327
+ declare class HandTool implements ITool {
2328
+ readonly id: ToolId;
2329
+ readonly shortcutKey: string;
2330
+ /**
2331
+ * Registered by the UI layer once at mount. Persists across drags and
2332
+ * cancels — not per-drag state. Pass null to unregister.
2333
+ */
2334
+ private scrollCallback;
2335
+ /** Gates delta computation and cursor. */
2336
+ private isDragging;
2337
+ /**
2338
+ * X position (pixels) at the last pointer event.
2339
+ * Delta is event-to-event (not from start): deltaX = event.x - lastX.
2340
+ * Incremental delta is what UI scroll handlers expect (scrollLeft += deltaX).
2341
+ */
2342
+ private lastX;
2343
+ /**
2344
+ * Register the UI's scroll handler. Called once at mount, not per-drag.
2345
+ * @param cb Receives pixel deltaX per move event. Pass null to unregister.
2346
+ */
2347
+ setScrollCallback(cb: ((deltaX: number) => void) | null): void;
2348
+ getCursor(_ctx: ToolContext): string;
2349
+ getSnapCandidateTypes(): readonly SnapPointType[];
2350
+ onPointerDown(event: TimelinePointerEvent, _ctx: ToolContext): void;
2351
+ onPointerMove(event: TimelinePointerEvent, _ctx: ToolContext): ProvisionalState | null;
2352
+ onPointerUp(_event: TimelinePointerEvent, _ctx: ToolContext): Transaction | null;
2353
+ onKeyDown(_event: TimelineKeyEvent, _ctx: ToolContext): Transaction | null;
2354
+ onKeyUp(_event: TimelineKeyEvent, _ctx: ToolContext): void;
2355
+ /**
2356
+ * Resets per-drag state only.
2357
+ * scrollCallback is NOT cleared — it persists across cancels.
2358
+ * Re-registering on every cancelled drag would be unnecessary UI burden.
2359
+ */
2360
+ onCancel(): void;
2361
+ }
2362
+
2363
+ /**
2364
+ * TransitionTool — Phase 4 Step 4
2365
+ *
2366
+ * Drag from a clip's right edge to create or resize a transition.
2367
+ * Click on an existing transition area to delete it.
2368
+ *
2369
+ * RULES:
2370
+ * - onPointerMove never dispatches; returns ProvisionalState for preview
2371
+ * - onPointerUp never mutates instance state (capture-before-reset)
2372
+ * - Every instance variable reset in onCancel()
2373
+ */
2374
+
2375
+ declare class TransitionTool implements ITool {
2376
+ readonly id: ToolId;
2377
+ readonly shortcutKey: string;
2378
+ private pendingClipId;
2379
+ private dragStartX;
2380
+ private pendingDeleteTransitionClipId;
2381
+ getCursor(_ctx: ToolContext): string;
2382
+ getSnapCandidateTypes(): readonly SnapPointType[];
2383
+ onPointerDown(event: TimelinePointerEvent, ctx: ToolContext): void;
2384
+ onPointerMove(event: TimelinePointerEvent, ctx: ToolContext): ProvisionalState | null;
2385
+ onPointerUp(event: TimelinePointerEvent, ctx: ToolContext): Transaction | null;
2386
+ onKeyDown(_event: TimelineKeyEvent, _ctx: ToolContext): Transaction | null;
2387
+ onKeyUp(_event: TimelineKeyEvent, _ctx: ToolContext): void;
2388
+ onCancel(): void;
2389
+ }
2390
+
2391
+ /**
2392
+ * KeyframeTool (Pen tool) — Phase 4 Step 4
2393
+ *
2394
+ * Click on a clip's effect lane to add a keyframe.
2395
+ * Click an existing keyframe to delete (via Delete key). Drag keyframe to move.
2396
+ *
2397
+ * RULES:
2398
+ * - onPointerMove never dispatches; returns ProvisionalState for preview
2399
+ * - onPointerUp never mutates instance state (capture-before-reset)
2400
+ * - Every instance variable reset in onCancel()
2401
+ */
2402
+
2403
+ declare class KeyframeTool implements ITool {
2404
+ readonly id: ToolId;
2405
+ readonly shortcutKey: string;
2406
+ private draggingKeyframe;
2407
+ private activeClipId;
2408
+ private activeEffectId;
2409
+ private pendingAddKeyframe;
2410
+ getCursor(_ctx: ToolContext): string;
2411
+ getSnapCandidateTypes(): readonly SnapPointType[];
2412
+ onPointerDown(event: TimelinePointerEvent, ctx: ToolContext): void;
2413
+ onPointerMove(event: TimelinePointerEvent, ctx: ToolContext): ProvisionalState | null;
2414
+ onPointerUp(event: TimelinePointerEvent, ctx: ToolContext): Transaction | null;
2415
+ onKeyDown(event: TimelineKeyEvent, ctx: ToolContext): Transaction | null;
2416
+ onKeyUp(_event: TimelineKeyEvent, _ctx: ToolContext): void;
2417
+ onCancel(): void;
2418
+ }
2419
+
2420
+ /**
2421
+ * SlideTool — Phase 7 Step 5
2422
+ *
2423
+ * Moves a clip left/right on the timeline. Neighbors trim to fill:
2424
+ * left neighbor's end resizes to abut; right neighbor moves and resizes.
2425
+ * No ripple — total duration unchanged.
2426
+ *
2427
+ * Uses: MOVE_CLIP, RESIZE_CLIP (edge 'start' | 'end').
2428
+ * Capture-before-reset in onPointerUp.
2429
+ */
2430
+
2431
+ declare class SlideTool implements ITool {
2432
+ readonly id: ToolId;
2433
+ readonly shortcutKey = "Y";
2434
+ private draggingClipId;
2435
+ private dragStartX;
2436
+ private originalStart;
2437
+ getCursor(_ctx: ToolContext): string;
2438
+ getSnapCandidateTypes(): readonly SnapPointType[];
2439
+ onPointerDown(event: TimelinePointerEvent, _ctx: ToolContext): void;
2440
+ onPointerMove(event: TimelinePointerEvent, ctx: ToolContext): ProvisionalState | null;
2441
+ onPointerUp(event: TimelinePointerEvent, ctx: ToolContext): Transaction | null;
2442
+ onKeyDown(_event: TimelineKeyEvent, _ctx: ToolContext): Transaction | null;
2443
+ onKeyUp(_event: TimelineKeyEvent, _ctx: ToolContext): void;
2444
+ onCancel(): void;
2445
+ }
2446
+
2447
+ /**
2448
+ * ZoomTool — Phase 7 Step 5
2449
+ *
2450
+ * Adjusts pixelsPerFrame (zoom level) via callback only.
2451
+ * Does NOT dispatch any operations; pixelsPerFrame is UI state.
2452
+ */
2453
+
2454
+ type ZoomToolOptions = {
2455
+ onZoomChange: (pixelsPerFrame: number) => void;
2456
+ minPixelsPerFrame?: number;
2457
+ maxPixelsPerFrame?: number;
2458
+ initialPixelsPerFrame?: number;
2459
+ };
2460
+ declare class ZoomTool implements ITool {
2461
+ readonly id: ToolId;
2462
+ readonly shortcutKey = "Z";
2463
+ private dragStartX;
2464
+ private dragStartZoom;
2465
+ private readonly options;
2466
+ constructor(options: ZoomToolOptions);
2467
+ getCursor(_ctx: ToolContext): string;
2468
+ getSnapCandidateTypes(): readonly SnapPointType[];
2469
+ onPointerDown(event: TimelinePointerEvent, ctx: ToolContext): void;
2470
+ onPointerMove(event: TimelinePointerEvent, ctx: ToolContext): null;
2471
+ onPointerUp(_event: TimelinePointerEvent, _ctx: ToolContext): null;
2472
+ onKeyDown(event: TimelineKeyEvent, ctx: ToolContext): null;
2473
+ onKeyUp(_event: TimelineKeyEvent, _ctx: ToolContext): void;
2474
+ onCancel(): void;
2475
+ }
2476
+ /** Returns an ITool that wraps ZoomTool with the given options (for host registration). */
2477
+ declare function createZoomTool(options: ZoomToolOptions): ITool;
2478
+
2479
+ /**
2480
+ * SerializationError — Phase 5 Step 1
2481
+ *
2482
+ * Thrown when deserialization or migration fails.
2483
+ */
2484
+
2485
+ declare class SerializationError extends Error {
2486
+ readonly violations?: InvariantViolation[] | undefined;
2487
+ constructor(message: string, violations?: InvariantViolation[] | undefined);
2488
+ }
2489
+
2490
+ /**
2491
+ * Timeline serialization — Phase 5 Step 1
2492
+ *
2493
+ * Pure functions. No IO. No DOM. No external deps.
2494
+ * serializeTimeline / deserializeTimeline round-trip TimelineState.
2495
+ */
2496
+
2497
+ /**
2498
+ * Serialize state to JSON string.
2499
+ * Converts assetRegistry Map to plain object for JSON compatibility.
2500
+ */
2501
+ declare function serializeTimeline(state: TimelineState): string;
2502
+ /**
2503
+ * Parse JSON string, migrate to current schema, validate invariants.
2504
+ * Throws SerializationError on invalid JSON, missing schemaVersion,
2505
+ * unknown version, or invariant violations.
2506
+ */
2507
+ declare function deserializeTimeline(raw: string): TimelineState;
2508
+ type AssetRemapCallback = (asset: FileAsset) => FileAsset;
2509
+ /**
2510
+ * Walk assetRegistry; for each FileAsset replace with remap(asset).
2511
+ * GeneratorAssets unchanged. Returns new state (immutable).
2512
+ */
2513
+ declare function remapAssetPaths(state: TimelineState, remap: AssetRemapCallback): TimelineState;
2514
+ type OfflineAsset = {
2515
+ readonly assetId: AssetId;
2516
+ readonly path: string;
2517
+ readonly clipIds: readonly ClipId[];
2518
+ };
2519
+ /**
2520
+ * For each FileAsset where isOnline(asset) === false, collect clip IDs
2521
+ * that reference it. Host provides isOnline; core does not do filesystem checks.
2522
+ */
2523
+ declare function findOfflineAssets(state: TimelineState, isOnline: (asset: FileAsset) => boolean): OfflineAsset[];
2524
+
2525
+ /**
2526
+ * OTIO export — Phase 5 Step 2
2527
+ *
2528
+ * Pure function. Produces OTIO JSON-serializable document from TimelineState.
2529
+ * No external OTIO library. Hand-rolled mapping.
2530
+ */
2531
+
2532
+ type OTIORationalTime = {
2533
+ value: number;
2534
+ rate: number;
2535
+ };
2536
+ type OTIOTimeRange = {
2537
+ OTIO_SCHEMA: string;
2538
+ start_time: OTIORationalTime;
2539
+ duration: OTIORationalTime;
2540
+ };
2541
+ type OTIOExternalReference = {
2542
+ OTIO_SCHEMA: string;
2543
+ target_url: string;
2544
+ available_range: OTIOTimeRange;
2545
+ };
2546
+ type OTIOGeneratorReference = {
2547
+ OTIO_SCHEMA: string;
2548
+ generator_kind: string;
2549
+ };
2550
+ type OTIOMissingReference = {
2551
+ OTIO_SCHEMA: string;
2552
+ };
2553
+ type OTIOClip = {
2554
+ OTIO_SCHEMA: string;
2555
+ name: string;
2556
+ source_range: OTIOTimeRange;
2557
+ media_reference: OTIOExternalReference | OTIOGeneratorReference | OTIOMissingReference;
2558
+ effects?: OTIOEffect[];
2559
+ };
2560
+ type OTIOGap = {
2561
+ OTIO_SCHEMA: string;
2562
+ source_range: OTIOTimeRange;
2563
+ };
2564
+ type OTIOEffect = {
2565
+ OTIO_SCHEMA: string;
2566
+ name: string;
2567
+ effect_name: string;
2568
+ enabled: boolean;
2569
+ metadata: {
2570
+ params: readonly {
2571
+ key: string;
2572
+ value: number | string | boolean;
2573
+ }[];
2574
+ };
2575
+ };
2576
+ type OTIOTrack = {
2577
+ OTIO_SCHEMA: string;
2578
+ kind: string;
2579
+ children: (OTIOClip | OTIOGap)[];
2580
+ };
2581
+ type OTIOStack = {
2582
+ OTIO_SCHEMA: string;
2583
+ children: OTIOTrack[];
2584
+ };
2585
+ type OTIOMarker = {
2586
+ OTIO_SCHEMA: string;
2587
+ name: string;
2588
+ color: string;
2589
+ marked_range: OTIOTimeRange;
2590
+ };
2591
+ type OTIODocument = {
2592
+ OTIO_SCHEMA: string;
2593
+ name: string;
2594
+ global_start_time: OTIORationalTime;
2595
+ tracks: OTIOStack;
2596
+ markers: OTIOMarker[];
2597
+ };
2598
+ /**
2599
+ * Export TimelineState to an OTIO document (plain object).
2600
+ * Caller can JSON.stringify the result.
2601
+ */
2602
+ declare function exportToOTIO(state: TimelineState): OTIODocument;
2603
+
2604
+ /**
2605
+ * OTIO import — Phase 5 Step 2
2606
+ *
2607
+ * Pure function. Builds TimelineState from OTIO document.
2608
+ * Throws SerializationError on invalid doc or invariant violations.
2609
+ */
2610
+
2611
+ type OTIOImportOptions = {
2612
+ /** Override fps; default: from doc global_start_time.rate or first clip rate, fallback 30 */
2613
+ fps?: number;
2614
+ /** Override timeline name */
2615
+ name?: string;
2616
+ };
2617
+ declare function importFromOTIO(doc: unknown, options?: OTIOImportOptions): TimelineState;
2618
+
2619
+ /**
2620
+ * CMX3600 EDL export — Phase 5 Step 3
2621
+ *
2622
+ * Single video track only. Pure function, returns string.
2623
+ * No IO.
2624
+ */
2625
+
2626
+ type EDLExportOptions = {
2627
+ /** Default: state.timeline.name */
2628
+ title?: string;
2629
+ /** Default: false (non-drop). True = 29.97 drop frame only. */
2630
+ dropFrame?: boolean;
2631
+ /** Which video track to export. Default: 0 (first video track). */
2632
+ trackIndex?: number;
2633
+ };
2634
+ /**
2635
+ * Convert frame count to timecode string.
2636
+ * dropFrame true: only 29.97fps uses real drop-frame; others fall back to non-drop.
2637
+ */
2638
+ declare function frameToTimecode(frame: number, fps: number, dropFrame: boolean): string;
2639
+ /**
2640
+ * FileAsset: filename without extension, truncate 8 chars, uppercase.
2641
+ * GeneratorAsset or undefined: "AX".
2642
+ */
2643
+ declare function reelName(asset: Asset | undefined): string;
2644
+ /**
2645
+ * Export a single video track to CMX3600 EDL string.
2646
+ * trackIndex selects which video track (default 0).
2647
+ */
2648
+ declare function exportToEDL(state: TimelineState, options?: EDLExportOptions): string;
2649
+
2650
+ /**
2651
+ * AAF XML export — Phase 5 Step 4
2652
+ *
2653
+ * Simplified AAF XML representation for Avid interchange.
2654
+ * Pure function, returns string. No IO.
2655
+ */
2656
+
2657
+ type AAFExportOptions = {
2658
+ /** Default: timeline name */
2659
+ projectName?: string;
2660
+ /** Default: derived from state (e.g. 30 → "30/1") */
2661
+ frameRate?: string;
2662
+ };
2663
+ declare function exportToAAF(state: TimelineState, options?: AAFExportOptions): string;
2664
+
2665
+ /**
2666
+ * FCP XML (FCPX) export — Phase 5 Step 4
2667
+ *
2668
+ * Final Cut Pro XML 1.10 interchange. Pure function, returns string. No IO.
2669
+ */
2670
+
2671
+ type FCPXMLExportOptions = {
2672
+ libraryName?: string;
2673
+ eventName?: string;
2674
+ };
2675
+ /**
2676
+ * FCPXML rational time: "0s" or "{frames}/{fps}s".
2677
+ */
2678
+ declare function toFCPTime(frames: number, fps: number): string;
2679
+ declare function exportToFCPXML(state: TimelineState, options?: FCPXMLExportOptions): string;
2680
+
2681
+ /**
2682
+ * PROJECT MODEL — Phase 5 Step 5
2683
+ *
2684
+ * A Project is a multi-timeline container with a shared bin hierarchy.
2685
+ * Pure types + factories only. No IO.
2686
+ */
2687
+
2688
+ type ProjectId = string & {
2689
+ readonly __brand: 'ProjectId';
2690
+ };
2691
+ declare function toProjectId(s: string): ProjectId;
2692
+ type BinId = string & {
2693
+ readonly __brand: 'BinId';
2694
+ };
2695
+ declare function toBinId(s: string): BinId;
2696
+ type BinItem = {
2697
+ readonly kind: 'asset';
2698
+ readonly assetId: AssetId;
2699
+ } | {
2700
+ readonly kind: 'sequence';
2701
+ readonly timelineId: string;
2702
+ } | {
2703
+ readonly kind: 'bin';
2704
+ readonly binId: BinId;
2705
+ };
2706
+ type Bin = {
2707
+ readonly id: BinId;
2708
+ readonly label: string;
2709
+ readonly parentId: BinId | null;
2710
+ readonly items: readonly BinItem[];
2711
+ readonly color?: string;
2712
+ };
2713
+ declare function createBin(id: BinId, label: string, parentId?: BinId | null): Bin;
2714
+ type Project = {
2715
+ readonly id: ProjectId;
2716
+ readonly name: string;
2717
+ readonly timelines: readonly TimelineState[];
2718
+ readonly bins: readonly Bin[];
2719
+ readonly rootBinIds: readonly BinId[];
2720
+ readonly createdAt: number;
2721
+ readonly updatedAt: number;
2722
+ readonly schemaVersion: number;
2723
+ };
2724
+ declare function createProject(id: ProjectId, name: string, timelines?: readonly TimelineState[]): Project;
2725
+
2726
+ declare function addTimeline(project: Project, state: TimelineState): Project;
2727
+ declare function removeTimeline(project: Project, timelineId: string): Project;
2728
+ declare function addBin(project: Project, bin: Bin): Project;
2729
+ declare function removeBin(project: Project, binId: BinId): Project;
2730
+ declare function addItemToBin(project: Project, binId: BinId, item: BinItem): Project;
2731
+ declare function removeItemFromBin(project: Project, binId: BinId, item: BinItem): Project;
2732
+ declare function moveItemBetweenBins(project: Project, fromBinId: BinId, toBinId: BinId, item: BinItem): Project;
2733
+
2734
+ /**
2735
+ * Project serialization — Phase 5 Step 5
2736
+ *
2737
+ * Pure functions. No IO. Uses timeline migrate() + checkInvariants().
2738
+ */
2739
+
2740
+ declare function serializeProject(project: Project): string;
2741
+ declare function deserializeProject(raw: string): Project;
2742
+
2743
+ /**
2744
+ * Playhead types — Phase 6 Step 1 + Step 5
2745
+ *
2746
+ * Playback position and quality. No DOM deps.
2747
+ */
2748
+
2749
+ type PlaybackRate = number;
2750
+ type PlaybackQuality = 'full' | 'half' | 'quarter' | 'proxy';
2751
+ type LoopRegion = {
2752
+ readonly startFrame: TimelineFrame;
2753
+ readonly endFrame: TimelineFrame;
2754
+ };
2755
+ type PlayheadState = {
2756
+ readonly currentFrame: TimelineFrame;
2757
+ readonly isPlaying: boolean;
2758
+ readonly playbackRate: PlaybackRate;
2759
+ readonly quality: PlaybackQuality;
2760
+ readonly durationFrames: number;
2761
+ readonly fps: number;
2762
+ readonly loopRegion: LoopRegion | null;
2763
+ readonly prerollFrames: number;
2764
+ readonly postrollFrames: number;
2765
+ };
2766
+ type PlayheadEventType = 'play' | 'pause' | 'seek' | 'loop' | 'frame-dropped' | 'ended' | 'loop-point' | 'state';
2767
+ type PlayheadEvent = {
2768
+ readonly type: PlayheadEventType;
2769
+ readonly frame: TimelineFrame;
2770
+ readonly data?: unknown;
2771
+ };
2772
+ type PlayheadListener = (event: PlayheadEvent) => void;
2773
+ /** Return type of PlayheadController.on() — call to unsubscribe. */
2774
+ type PlayheadUnsubscribe = () => void;
2775
+
2776
+ /**
2777
+ * Clock abstraction — Phase 6 Step 1
2778
+ *
2779
+ * Allows PlayheadController to run without real rAF (swapped for mock in tests).
2780
+ */
2781
+ type ClockCallback = (timestamp: number) => void;
2782
+ type Clock = {
2783
+ requestFrame: (cb: ClockCallback) => number;
2784
+ cancelFrame: (id: number) => void;
2785
+ now: () => number;
2786
+ };
2787
+ declare const browserClock: Clock;
2788
+ declare const nodeClock: Clock;
2789
+ declare function createTestClock(): {
2790
+ clock: Clock;
2791
+ tick: (ms: number) => void;
2792
+ getCallbacks: () => ClockCallback[];
2793
+ };
2794
+
2795
+ /**
2796
+ * PlayheadController — Phase 6 Step 1
2797
+ *
2798
+ * Manages playback position only. Decoupled from Dispatcher and TimelineState.
2799
+ * Never calls dispatch(). Uses clock abstraction for testability.
2800
+ */
2801
+
2802
+ declare class PlayheadController {
2803
+ private state;
2804
+ private listeners;
2805
+ private rafId;
2806
+ private lastTimestamp;
2807
+ private frameAccum;
2808
+ private clock;
2809
+ constructor(initialState: Pick<PlayheadState, 'durationFrames' | 'fps'>, clock?: Clock);
2810
+ getState(): PlayheadState;
2811
+ play(): void;
2812
+ pause(): void;
2813
+ seekTo(frame: TimelineFrame): void;
2814
+ setPlaybackRate(rate: PlaybackRate): void;
2815
+ setQuality(quality: PlaybackQuality): void;
2816
+ setDuration(durationFrames: number): void;
2817
+ setLoopRegion(region: LoopRegion | null): void;
2818
+ setPreroll(frames: number): void;
2819
+ setPostroll(frames: number): void;
2820
+ private scheduleFrame;
2821
+ private onFrame;
2822
+ on(listener: PlayheadListener): PlayheadUnsubscribe;
2823
+ private emit;
2824
+ destroy(): void;
2825
+ }
2826
+
2827
+ /**
2828
+ * Pipeline contracts — Phase 6 Step 2
2829
+ *
2830
+ * Core defines the CONTRACT (types + interfaces).
2831
+ * Host app provides the IMPLEMENTATION.
2832
+ * Core never does actual decoding or compositing.
2833
+ */
2834
+
2835
+ type VideoFrameRequest = {
2836
+ readonly clipId: ClipId;
2837
+ readonly mediaFrame: TimelineFrame;
2838
+ readonly quality: PlaybackQuality;
2839
+ };
2840
+ type AudioChunkRequest = {
2841
+ readonly clipId: ClipId;
2842
+ readonly mediaFrame: TimelineFrame;
2843
+ readonly durationFrames: number;
2844
+ readonly sampleRate: number;
2845
+ };
2846
+ type VideoFrameResult = {
2847
+ readonly clipId: ClipId;
2848
+ readonly mediaFrame: TimelineFrame;
2849
+ readonly width: number;
2850
+ readonly height: number;
2851
+ readonly bitmap: unknown;
2852
+ };
2853
+ type AudioChunkResult = {
2854
+ readonly clipId: ClipId;
2855
+ readonly mediaFrame: TimelineFrame;
2856
+ readonly samples: unknown;
2857
+ readonly sampleRate: number;
2858
+ };
2859
+ type VideoDecoder = (request: VideoFrameRequest) => Promise<VideoFrameResult>;
2860
+ type AudioDecoder = (request: AudioChunkRequest) => Promise<AudioChunkResult>;
2861
+ type CompositeLayer = {
2862
+ readonly clipId: ClipId;
2863
+ readonly trackId: TrackId;
2864
+ readonly trackIndex: number;
2865
+ readonly frame: VideoFrameResult;
2866
+ readonly transform: ClipTransform;
2867
+ readonly opacity: number;
2868
+ readonly blendMode: string;
2869
+ readonly effects: readonly Effect[];
2870
+ };
2871
+ /** Layer spec from resolveFrame (no decoded frame yet). */
2872
+ type ResolvedLayer = {
2873
+ readonly clipId: ClipId;
2874
+ readonly trackId: TrackId;
2875
+ readonly trackIndex: number;
2876
+ readonly mediaFrame: TimelineFrame;
2877
+ readonly transform: ClipTransform;
2878
+ readonly opacity: number;
2879
+ readonly blendMode: string;
2880
+ readonly effects: readonly Effect[];
2881
+ };
2882
+ type CompositeRequest = {
2883
+ readonly timelineFrame: TimelineFrame;
2884
+ readonly layers: readonly CompositeLayer[];
2885
+ readonly width: number;
2886
+ readonly height: number;
2887
+ readonly quality: PlaybackQuality;
2888
+ };
2889
+ type CompositeResult = {
2890
+ readonly timelineFrame: TimelineFrame;
2891
+ readonly bitmap: unknown;
2892
+ };
2893
+ /** Result of resolveFrame (layers have mediaFrame, not decoded frame). */
2894
+ type ResolvedCompositeRequest = {
2895
+ readonly timelineFrame: TimelineFrame;
2896
+ readonly layers: readonly ResolvedLayer[];
2897
+ readonly width: number;
2898
+ readonly height: number;
2899
+ readonly quality: PlaybackQuality;
2900
+ };
2901
+ type Compositor = (request: CompositeRequest) => Promise<CompositeResult>;
2902
+ type ThumbnailRequest = {
2903
+ readonly clipId: ClipId;
2904
+ readonly mediaFrame: TimelineFrame;
2905
+ readonly width: number;
2906
+ readonly height: number;
2907
+ };
2908
+ type ThumbnailResult = {
2909
+ readonly clipId: ClipId;
2910
+ readonly mediaFrame: TimelineFrame;
2911
+ readonly bitmap: unknown;
2912
+ };
2913
+ type ThumbnailProvider = (request: ThumbnailRequest) => Promise<ThumbnailResult>;
2914
+ type PipelineConfig = {
2915
+ readonly videoDecoder: VideoDecoder;
2916
+ readonly audioDecoder?: AudioDecoder;
2917
+ readonly compositor: Compositor;
2918
+ readonly thumbnailProvider?: ThumbnailProvider;
2919
+ };
2920
+
2921
+ /**
2922
+ * TrackIndex — Phase 7 Step 1
2923
+ *
2924
+ * Wraps IntervalTree per track for O(log n + k) getClipsAtFrame.
2925
+ */
2926
+
2927
+ type ClipEntry = {
2928
+ clip: Clip;
2929
+ track: Track;
2930
+ trackIndex: number;
2931
+ };
2932
+ declare class TrackIndex {
2933
+ private tree;
2934
+ private built;
2935
+ build(state: TimelineState): void;
2936
+ query(frame: number): ClipEntry[];
2937
+ get isBuilt(): boolean;
2938
+ invalidate(): void;
2939
+ }
2940
+
2941
+ /**
2942
+ * Frame resolver — Phase 6 Step 2 + Step 3
2943
+ *
2944
+ * Given a TimelineFrame, resolves which clips are visible and builds
2945
+ * the composite request. Pure function — no async, no decoding.
2946
+ */
2947
+
2948
+ /**
2949
+ * Returns the media-space frame for a clip at the given timeline frame.
2950
+ * mediaFrame = timelineFrame - clip.timelineStart + clip.mediaIn
2951
+ */
2952
+ declare function mediaFrameForClip(clip: Clip, timelineFrame: TimelineFrame): TimelineFrame;
2953
+ /**
2954
+ * Returns all clips visible at the given timeline frame, with their
2955
+ * parent track and track index (z-order).
2956
+ * If index is provided and built, uses O(log n + k) lookup; else linear scan.
2957
+ */
2958
+ declare function getClipsAtFrame(state: TimelineState, timelineFrame: TimelineFrame, index?: TrackIndex): Array<{
2959
+ clip: Clip;
2960
+ track: Track;
2961
+ trackIndex: number;
2962
+ }>;
2963
+ /**
2964
+ * Resolves the composite request for a timeline frame: which layers are
2965
+ * visible and their transform/opacity/blend/effects. Does not decode.
2966
+ * Pass optional index for O(log n + k) clip lookup.
2967
+ */
2968
+ declare function resolveFrame(state: TimelineState, timelineFrame: TimelineFrame, quality: PlaybackQuality, dimensions: {
2969
+ width: number;
2970
+ height: number;
2971
+ }, index?: TrackIndex): ResolvedCompositeRequest;
2972
+ /**
2973
+ * Returns the nearest frame strictly after fromFrame where any clip
2974
+ * starts or ends on any track. Returns null if none.
2975
+ */
2976
+ declare function findNextClipBoundary(state: TimelineState, fromFrame: TimelineFrame): TimelineFrame | null;
2977
+ /**
2978
+ * Returns the nearest frame strictly before fromFrame where any clip
2979
+ * starts or ends on any track. Returns null if none.
2980
+ */
2981
+ declare function findPrevClipBoundary(state: TimelineState, fromFrame: TimelineFrame): TimelineFrame | null;
2982
+ /**
2983
+ * Returns the marker with the smallest anchor strictly after fromFrame.
2984
+ * Point markers use .frame; range markers use .frameStart as anchor.
2985
+ */
2986
+ declare function findNextMarker(state: TimelineState, fromFrame: TimelineFrame): Marker | null;
2987
+ /**
2988
+ * Returns the marker with the largest anchor strictly before fromFrame.
2989
+ */
2990
+ declare function findPrevMarker(state: TimelineState, fromFrame: TimelineFrame): Marker | null;
2991
+ /**
2992
+ * Searches all tracks for a clip with the given id.
2993
+ * Returns clip + parent track + trackIndex, or null if not found.
2994
+ */
2995
+ declare function findClipById(state: TimelineState, clipId: ClipId): {
2996
+ clip: Clip;
2997
+ track: Track;
2998
+ trackIndex: number;
2999
+ } | null;
3000
+
3001
+ /**
3002
+ * Centered interval tree — Phase 7 Step 1
3003
+ *
3004
+ * Stores intervals [start, end) and answers query(point):
3005
+ * all intervals containing point. O(log n + k).
3006
+ */
3007
+ type Interval<T> = {
3008
+ readonly start: number;
3009
+ readonly end: number;
3010
+ readonly data: T;
3011
+ };
3012
+ declare class IntervalTree<T> {
3013
+ private root;
3014
+ private _size;
3015
+ build(intervals: Interval<T>[]): void;
3016
+ query(point: number): T[];
3017
+ size(): number;
3018
+ }
3019
+
3020
+ declare class PlaybackEngine {
3021
+ private controller;
3022
+ private pipeline;
3023
+ private state;
3024
+ private dimensions;
3025
+ private trackIndex;
3026
+ private snapManager;
3027
+ private unsubscribe;
3028
+ constructor(state: TimelineState, pipeline: PipelineConfig, dimensions: {
3029
+ width: number;
3030
+ height: number;
3031
+ }, clock?: Clock);
3032
+ updateState(state: TimelineState): void;
3033
+ play(): void;
3034
+ pause(): void;
3035
+ seekTo(frame: TimelineFrame): void;
3036
+ seekToNextClipBoundary(): void;
3037
+ seekToPrevClipBoundary(): void;
3038
+ seekToNextMarker(): void;
3039
+ seekToPrevMarker(): void;
3040
+ seekToStart(): void;
3041
+ seekToEnd(): void;
3042
+ setPlaybackRate(rate: PlaybackRate): void;
3043
+ setQuality(quality: PlaybackQuality): void;
3044
+ setLoopRegion(region: LoopRegion | null): void;
3045
+ setPreroll(frames: number): void;
3046
+ setPostroll(frames: number): void;
3047
+ getState(): PlayheadState;
3048
+ getCurrentTimelineState(): TimelineState;
3049
+ on(listener: PlayheadListener): () => void;
3050
+ renderFrame(timelineFrame: TimelineFrame): Promise<CompositeResult>;
3051
+ destroy(): void;
3052
+ }
3053
+
3054
+ /**
3055
+ * Virtual rendering contract — Phase 7 Step 2
3056
+ *
3057
+ * Defines what is "visible" so the React layer can mount
3058
+ * only visible clip components.
3059
+ */
3060
+
3061
+ type VirtualWindow = {
3062
+ readonly startFrame: TimelineFrame;
3063
+ readonly endFrame: TimelineFrame;
3064
+ readonly pixelsPerFrame: number;
3065
+ };
3066
+ type VirtualClipEntry = {
3067
+ readonly clip: Clip;
3068
+ readonly track: Track;
3069
+ readonly trackIndex: number;
3070
+ readonly isVisible: boolean;
3071
+ readonly left: number;
3072
+ readonly width: number;
3073
+ };
3074
+ /**
3075
+ * Returns all clips with visibility and layout (left, width).
3076
+ * Sorted by trackIndex ascending, then by clip timelineStart ascending.
3077
+ */
3078
+ declare function getVisibleClips(state: TimelineState, window: VirtualWindow): VirtualClipEntry[];
3079
+ /**
3080
+ * Builds a VirtualWindow from viewport dimensions and scroll.
3081
+ */
3082
+ declare function getVisibleFrameRange(viewportWidth: number, scrollLeft: number, pixelsPerFrame: number): VirtualWindow;
3083
+
3084
+ /**
3085
+ * StateChange diff — Phase 7 Step 2
3086
+ *
3087
+ * Lightweight diff for hook optimization: compare prev vs next
3088
+ * by reference so hooks can skip re-render when nothing relevant changed.
3089
+ */
3090
+
3091
+ type StateChange = {
3092
+ readonly trackIds: boolean;
3093
+ readonly clipIds: ReadonlySet<ClipId>;
3094
+ readonly markers: boolean;
3095
+ readonly timeline: boolean;
3096
+ readonly playhead: boolean;
3097
+ };
3098
+ declare const EMPTY_STATE_CHANGE: StateChange;
3099
+ /**
3100
+ * Diffs prev and next state by reference.
3101
+ * clipIds: set of clip ids whose clip reference changed or were added/removed.
3102
+ */
3103
+ declare function diffStates(prev: TimelineState, next: TimelineState): StateChange;
3104
+
3105
+ /**
3106
+ * Worker contracts — Phase 7 Step 4
3107
+ *
3108
+ * Core defines message/response types only.
3109
+ * No Worker instantiation — host responsibility.
3110
+ */
3111
+
3112
+ type WaveformRequest = {
3113
+ readonly requestId: string;
3114
+ readonly assetId: AssetId;
3115
+ readonly channel: number;
3116
+ readonly startFrame: TimelineFrame;
3117
+ readonly endFrame: TimelineFrame;
3118
+ readonly buckets: number;
3119
+ readonly sampleRate: number;
3120
+ };
3121
+ type WaveformPeak = {
3122
+ readonly min: number;
3123
+ readonly max: number;
3124
+ readonly rms: number;
3125
+ };
3126
+ type WaveformResult = {
3127
+ readonly requestId: string;
3128
+ readonly assetId: AssetId;
3129
+ readonly peaks: readonly WaveformPeak[];
3130
+ readonly error?: string;
3131
+ };
3132
+ type WaveformWorkerMessage = {
3133
+ type: 'request';
3134
+ payload: WaveformRequest;
3135
+ } | {
3136
+ type: 'cancel';
3137
+ requestId: string;
3138
+ };
3139
+ type WaveformWorkerResponse = {
3140
+ type: 'result';
3141
+ payload: WaveformResult;
3142
+ } | {
3143
+ type: 'progress';
3144
+ requestId: string;
3145
+ progress: number;
3146
+ } | {
3147
+ type: 'error';
3148
+ requestId: string;
3149
+ message: string;
3150
+ };
3151
+ type ThumbnailPriority = 'high' | 'normal' | 'low';
3152
+ type ThumbnailQueueEntry = {
3153
+ readonly request: ThumbnailRequest;
3154
+ readonly priority: ThumbnailPriority;
3155
+ readonly addedAt: number;
3156
+ };
3157
+ type ThumbnailWorkerMessage = {
3158
+ type: 'request';
3159
+ payload: ThumbnailQueueEntry;
3160
+ } | {
3161
+ type: 'cancel';
3162
+ requestId: string;
3163
+ } | {
3164
+ type: 'set-priority';
3165
+ requestId: string;
3166
+ priority: ThumbnailPriority;
3167
+ };
3168
+ type ThumbnailWorkerResponse = {
3169
+ type: 'result';
3170
+ payload: ThumbnailResult;
3171
+ } | {
3172
+ type: 'error';
3173
+ requestId: string;
3174
+ message: string;
3175
+ };
3176
+
3177
+ /**
3178
+ * ThumbnailCache — Phase 7 Step 4
3179
+ *
3180
+ * In-memory LRU cache for thumbnail results.
3181
+ * No Worker — sits between pipeline and host's thumbnail provider.
3182
+ */
3183
+
3184
+ declare class ThumbnailCache {
3185
+ private cache;
3186
+ private order;
3187
+ private maxSize;
3188
+ constructor(maxSize?: number);
3189
+ private key;
3190
+ get(request: ThumbnailRequest): ThumbnailResult | null;
3191
+ set(request: ThumbnailRequest, result: ThumbnailResult): void;
3192
+ has(request: ThumbnailRequest): boolean;
3193
+ invalidateClip(clipId: ClipId): void;
3194
+ clear(): void;
3195
+ get size(): number;
3196
+ }
3197
+
3198
+ /**
3199
+ * ThumbnailQueue — Phase 7 Step 4
3200
+ *
3201
+ * Priority queue for thumbnail requests.
3202
+ * Visible clips get 'high', off-screen get 'low'.
3203
+ */
3204
+
3205
+ declare class ThumbnailQueue {
3206
+ private entries;
3207
+ enqueue(request: ThumbnailRequest, priority?: ThumbnailPriority): void;
3208
+ dequeue(): ThumbnailQueueEntry | null;
3209
+ cancel(clipId: ClipId): void;
3210
+ setPriority(clipId: ClipId, mediaFrame: TimelineFrame, priority: ThumbnailPriority): void;
3211
+ get length(): number;
3212
+ peek(): ThumbnailQueueEntry | null;
3213
+ clear(): void;
3214
+ }
3215
+
3216
+ /**
3217
+ * Keyboard contract — Phase 6 Step 4 + Step 5
3218
+ *
3219
+ * Key bindings and actions for J/K/L jog-shuttle and timeline navigation.
3220
+ */
3221
+
3222
+ 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';
3223
+ type KeyBinding = {
3224
+ readonly code: string;
3225
+ readonly shift?: boolean;
3226
+ readonly alt?: boolean;
3227
+ readonly meta?: boolean;
3228
+ readonly ctrl?: boolean;
3229
+ readonly action: TimelineKeyAction;
3230
+ readonly repeat?: boolean;
3231
+ };
3232
+ declare const DEFAULT_KEY_BINDINGS: KeyBinding[];
3233
+ type KeyboardHandlerOptions = {
3234
+ bindings?: KeyBinding[];
3235
+ onMarkIn?: (frame: TimelineFrame) => void;
3236
+ onMarkOut?: (frame: TimelineFrame) => void;
3237
+ getTimelineState?: () => TimelineState;
3238
+ };
3239
+
3240
+ /**
3241
+ * KeyboardHandler — Phase 6 Step 4
3242
+ *
3243
+ * J/K/L jog-shuttle and keyboard contract. Zero DOM deps;
3244
+ * accepts TimelineKeyEvent (host maps from KeyboardEvent).
3245
+ */
3246
+
3247
+ declare class KeyboardHandler {
3248
+ private bindings;
3249
+ private engine;
3250
+ private jogLevel;
3251
+ private onMarkIn;
3252
+ private onMarkOut;
3253
+ private getTimelineState;
3254
+ constructor(engine: PlaybackEngine, options?: KeyboardHandlerOptions);
3255
+ handleKeyDown(event: TimelineKeyEvent): boolean;
3256
+ private dispatchAction;
3257
+ }
3258
+
3259
+ export { type InvariantViolation as $, type Asset as A, type Bin as B, type Clip as C, DEFAULT_AUDIO_PROPERTIES as D, DEFAULT_CLIP_TRANSFORM as E, DEFAULT_COMPRESSION_POLICY as F, DEFAULT_KEY_BINDINGS as G, type DispatchResult as H, type EDLExportOptions as I, EMPTY_STATE_CHANGE as J, type EasingCurve as K, type Effect as L, type EffectId as M, type EffectParam as N, type EffectType as O, type FCPXMLExportOptions as P, type FrameRate as Q, FrameRates as R, HOLD_EASING as S, type TimelineState as T, HandTool as U, type HistoryEntry as V, HistoryStack as W, type HistoryState as X, type ITool as Y, type Interval as Z, IntervalTree as _, type Track as a, type Timeline as a$, type KeyBinding as a0, KeyboardHandler as a1, type KeyboardHandlerOptions as a2, type Keyframe as a3, type KeyframeId as a4, KeyframeTool as a5, LINEAR_EASING as a6, type LinkGroup as a7, type LinkGroupId as a8, type LoopRegion as a9, RippleDeleteTool as aA, RippleInsertTool as aB, RippleTrimTool as aC, RollTrimTool as aD, type RubberBandRegion as aE, type SRTParseOptions as aF, SelectionTool as aG, type SequenceSettings as aH, SerializationError as aI, SlideTool as aJ, SlipTool as aK, type SnapIndex as aL, SnapIndexManager as aM, type SnapPoint as aN, type SnapPointType as aO, type StateChange as aP, ThumbnailCache as aQ, type ThumbnailPriority as aR, type ThumbnailProvider as aS, ThumbnailQueue as aT, type ThumbnailQueueEntry as aU, type ThumbnailRequest as aV, type ThumbnailResult as aW, type ThumbnailWorkerMessage as aX, type ThumbnailWorkerResponse as aY, type TimeRange as aZ, type Timecode as a_, type MarkerId as aa, type Modifiers as ab, NO_COMPRESSION as ac, NoOpTool as ad, type OTIODocument as ae, type OTIOImportOptions as af, type OfflineAsset as ag, type OperationPrimitive as ah, type PipelineConfig as ai, PlaybackEngine as aj, type PlaybackQuality as ak, type PlaybackRate as al, PlayheadController as am, type PlayheadEvent as an, type PlayheadEventType as ao, type PlayheadListener as ap, type PlayheadState as aq, type PlayheadUnsubscribe as ar, type Project as as, type ProjectId as at, type ProvisionalManager as au, type ProvisionalState as av, type RationalTime as aw, RazorTool as ax, type RejectionReason as ay, type RenderStage as az, type TimelineFrame as b, createTransition as b$, TimelineEngine as b0, type TimelineKeyAction as b1, type TimelineKeyEvent as b2, type TimelinePointerEvent as b3, type ToolContext as b4, type ToolId as b5, type ToolRegistry as b6, type TrackGroup as b7, type TrackGroupId as b8, type TrackId as b9, addFrames as bA, addItemToBin as bB, addTimeline as bC, browserClock as bD, buildSnapIndex as bE, canRedo as bF, canUndo as bG, checkInvariants as bH, clampFrame as bI, clearProvisional as bJ, clipContainsFrame as bK, clipsOverlap as bL, createAnimatableProperty as bM, createAsset as bN, createBin as bO, createClip as bP, createEffect as bQ, createHistory as bR, createLinkGroup as bS, createProject as bT, createProvisionalManager as bU, createRegistry as bV, createTestClock as bW, createTimeline as bX, createTimelineState as bY, createTrack as bZ, createTrackGroup as b_, TrackIndex as ba, type TrackType as bb, type Transaction as bc, TransactionCompressor as bd, type Transition as be, type TransitionAlignment as bf, type TransitionId as bg, type TransitionParam as bh, TransitionTool as bi, type TransitionType as bj, type VTTParseOptions as bk, type VideoDecoder as bl, type VideoFrameRequest as bm, type VideoFrameResult as bn, type ViolationType as bo, type VirtualClipEntry as bp, type VirtualWindow as bq, type WaveformPeak as br, type WaveformRequest as bs, type WaveformResult as bt, type WaveformWorkerMessage as bu, type WaveformWorkerResponse as bv, ZoomTool as bw, type ZoomToolOptions as bx, activateTool as by, addBin as bz, type AAFExportOptions as c, toLinkGroupId as c$, createZoomTool as c0, defaultCaptionStyle as c1, deserializeProject as c2, deserializeTimeline as c3, diffStates as c4, dispatch as c5, exportToAAF as c6, exportToEDL as c7, exportToFCPXML as c8, exportToOTIO as c9, nodeClock as cA, parseSRT as cB, parseVTT as cC, pushHistory as cD, redo as cE, reelName as cF, registerTool as cG, remapAssetPaths as cH, removeBin as cI, removeItemFromBin as cJ, removeTimeline as cK, resolveClip as cL, resolveFrame as cM, secondsToFrames as cN, serializeProject as cO, serializeTimeline as cP, setProvisional as cQ, sortTrackClips as cR, subtitleImportToOps as cS, subtractFrames as cT, toAssetId as cU, toBinId as cV, toClipId as cW, toEffectId as cX, toFCPTime as cY, toFrame as cZ, toKeyframeId as c_, findMarkersByColor as ca, findMarkersByLabel as cb, findNextClipBoundary as cc, findNextMarker as cd, findOfflineAssets as ce, findPrevClipBoundary as cf, findPrevMarker as cg, frame as ch, frameDuration as ci, frameRate as cj, frameToTimecode as ck, framesToMinutesSeconds as cl, framesToSeconds as cm, framesToTimecode as cn, getActiveTool as co, getClipDuration as cp, getClipMediaDuration as cq, getCurrentState as cr, getVisibleClips as cs, getVisibleFrameRange as ct, importFromOTIO as cu, isDropFrame as cv, isValidFrame as cw, mediaFrameForClip as cx, moveItemBetweenBins as cy, nearest as cz, type AnimatableProperty as d, toMarkerId as d0, toProjectId as d1, toTimecode as d2, toToolId as d3, toTrackGroupId as d4, toTrackId as d5, toTransitionId as d6, toggleSnap as d7, undo as d8, findClipById as d9, getClipsAtFrame as da, 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 ClipEntry as q, type ClipId as r, type ClipTransform as s, type Clock as t, type CompositeLayer as u, type CompositeRequest as v, type CompositeResult as w, type Compositor as x, type CompressibleOpType as y, type CompressionPolicy as z };