@algorisys/tinyfly 0.64.0

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 (140) hide show
  1. package/LICENSE +21 -0
  2. package/README.md +672 -0
  3. package/bin/tinyfly.mjs +59 -0
  4. package/lib/addons/adapters.js +756 -0
  5. package/lib/addons/dom-adapter-ChrbtkLC.js +243 -0
  6. package/lib/addons/drivers.js +72 -0
  7. package/lib/addons/export.js +1169 -0
  8. package/lib/addons/gsap-compat.js +2576 -0
  9. package/lib/addons/interaction.js +225 -0
  10. package/lib/addons/smooth-scroll-DaSacemU.js +671 -0
  11. package/lib/addons/teach.js +215 -0
  12. package/lib/browser/tinyfly.iife.js +2 -0
  13. package/lib/browser/tinyfly.js +6372 -0
  14. package/lib/browser/tinyfly.umd.js +2 -0
  15. package/lib/cli/tools.js +2325 -0
  16. package/lib/embed/tinyfly-embed.iife.js +18 -0
  17. package/lib/embed/tinyfly-embed.js +2316 -0
  18. package/lib/engine/tinyfly-engine.js +1972 -0
  19. package/lib/engine/tinyfly-engine.umd.cjs +2 -0
  20. package/lib/frameworks/react.js +32 -0
  21. package/lib/frameworks/solid.js +27 -0
  22. package/lib/frameworks/svelte.js +15 -0
  23. package/lib/frameworks/vue.js +29 -0
  24. package/lib/player/tinyfly-player.es.js +2306 -0
  25. package/lib/player/tinyfly-player.iife.js +2 -0
  26. package/lib/player/tinyfly-player.umd.js +2 -0
  27. package/lib/types/adapters/canvas/canvas-adapter.d.ts +238 -0
  28. package/lib/types/adapters/canvas/index.d.ts +1 -0
  29. package/lib/types/adapters/dom/dom-adapter.d.ts +50 -0
  30. package/lib/types/adapters/dom/flip.d.ts +60 -0
  31. package/lib/types/adapters/dom/index.d.ts +2 -0
  32. package/lib/types/adapters/filter-utils.d.ts +32 -0
  33. package/lib/types/adapters/index.d.ts +5 -0
  34. package/lib/types/adapters/shine-utils.d.ts +26 -0
  35. package/lib/types/adapters/svg/index.d.ts +1 -0
  36. package/lib/types/adapters/svg/svg-adapter.d.ts +47 -0
  37. package/lib/types/adapters/svg-transform-box.d.ts +13 -0
  38. package/lib/types/adapters/text-content.d.ts +11 -0
  39. package/lib/types/adapters/webgl/index.d.ts +1 -0
  40. package/lib/types/adapters/webgl/webgl-adapter.d.ts +69 -0
  41. package/lib/types/browser/index.d.ts +41 -0
  42. package/lib/types/compat/gsap/custom-eases.d.ts +28 -0
  43. package/lib/types/compat/gsap/defaults.d.ts +19 -0
  44. package/lib/types/compat/gsap/draw-svg-vars.d.ts +36 -0
  45. package/lib/types/compat/gsap/ease-map.d.ts +51 -0
  46. package/lib/types/compat/gsap/image-sequence.d.ts +61 -0
  47. package/lib/types/compat/gsap/index.d.ts +65 -0
  48. package/lib/types/compat/gsap/inertia-vars.d.ts +39 -0
  49. package/lib/types/compat/gsap/keyframes-vars.d.ts +8 -0
  50. package/lib/types/compat/gsap/layout.d.ts +6 -0
  51. package/lib/types/compat/gsap/live-context.d.ts +87 -0
  52. package/lib/types/compat/gsap/live-draggable.d.ts +75 -0
  53. package/lib/types/compat/gsap/live-flip.d.ts +73 -0
  54. package/lib/types/compat/gsap/live-morph.d.ts +18 -0
  55. package/lib/types/compat/gsap/live-motion-path.d.ts +33 -0
  56. package/lib/types/compat/gsap/live-scroll-to.d.ts +52 -0
  57. package/lib/types/compat/gsap/live-scroll.d.ts +108 -0
  58. package/lib/types/compat/gsap/live-transition.d.ts +40 -0
  59. package/lib/types/compat/gsap/live.d.ts +341 -0
  60. package/lib/types/compat/gsap/morph-vars.d.ts +21 -0
  61. package/lib/types/compat/gsap/motion-path-vars.d.ts +38 -0
  62. package/lib/types/compat/gsap/playhead-crossings.d.ts +47 -0
  63. package/lib/types/compat/gsap/position.d.ts +37 -0
  64. package/lib/types/compat/gsap/quick-play.d.ts +38 -0
  65. package/lib/types/compat/gsap/split-text.d.ts +66 -0
  66. package/lib/types/compat/gsap/spring-vars.d.ts +34 -0
  67. package/lib/types/compat/gsap/stage.d.ts +182 -0
  68. package/lib/types/compat/gsap/stagger-grid.d.ts +30 -0
  69. package/lib/types/compat/gsap/text-vars.d.ts +39 -0
  70. package/lib/types/compat/gsap/timeline.d.ts +161 -0
  71. package/lib/types/compat/gsap/utils.d.ts +60 -0
  72. package/lib/types/compat/gsap/vars.d.ts +79 -0
  73. package/lib/types/drivers/index.d.ts +8 -0
  74. package/lib/types/drivers/scroll-driver.d.ts +218 -0
  75. package/lib/types/drivers/scroll-markers.d.ts +41 -0
  76. package/lib/types/drivers/scroll-math.d.ts +87 -0
  77. package/lib/types/drivers/scroll-pin.d.ts +45 -0
  78. package/lib/types/drivers/scroll-snap.d.ts +47 -0
  79. package/lib/types/drivers/smooth-scroll.d.ts +118 -0
  80. package/lib/types/drivers/types.d.ts +23 -0
  81. package/lib/types/drivers/visibility-driver.d.ts +56 -0
  82. package/lib/types/embed/controls.d.ts +46 -0
  83. package/lib/types/embed/index.d.ts +17 -0
  84. package/lib/types/embed/mount.d.ts +41 -0
  85. package/lib/types/embed/tools.d.ts +33 -0
  86. package/lib/types/engine/authoring/custom-ease.d.ts +49 -0
  87. package/lib/types/engine/authoring/index.d.ts +3 -0
  88. package/lib/types/engine/authoring/random.d.ts +38 -0
  89. package/lib/types/engine/authoring/resolve-values.d.ts +57 -0
  90. package/lib/types/engine/core/bake.d.ts +66 -0
  91. package/lib/types/engine/core/clock.d.ts +44 -0
  92. package/lib/types/engine/core/index.d.ts +8 -0
  93. package/lib/types/engine/core/inertia.d.ts +30 -0
  94. package/lib/types/engine/core/playhead-crossings.d.ts +47 -0
  95. package/lib/types/engine/core/spring.d.ts +132 -0
  96. package/lib/types/engine/core/stagger.d.ts +40 -0
  97. package/lib/types/engine/core/timeline.d.ts +203 -0
  98. package/lib/types/engine/core/track.d.ts +90 -0
  99. package/lib/types/engine/export/byte-writer.d.ts +36 -0
  100. package/lib/types/engine/export/css.d.ts +31 -0
  101. package/lib/types/engine/export/gif-decode.test-helper.d.ts +24 -0
  102. package/lib/types/engine/export/gif.d.ts +134 -0
  103. package/lib/types/engine/export/index.d.ts +9 -0
  104. package/lib/types/engine/export/lottie.d.ts +104 -0
  105. package/lib/types/engine/export/mp4.d.ts +64 -0
  106. package/lib/types/engine/export/quantize.d.ts +56 -0
  107. package/lib/types/engine/export/sprite-sheet.d.ts +46 -0
  108. package/lib/types/engine/export/video.d.ts +99 -0
  109. package/lib/types/engine/export/webp.d.ts +82 -0
  110. package/lib/types/engine/index.d.ts +7 -0
  111. package/lib/types/engine/interpolation/easing.d.ts +65 -0
  112. package/lib/types/engine/interpolation/index.d.ts +2 -0
  113. package/lib/types/engine/interpolation/interpolators.d.ts +25 -0
  114. package/lib/types/engine/path/index.d.ts +11 -0
  115. package/lib/types/engine/path/motion-path.d.ts +24 -0
  116. package/lib/types/engine/path/path-builders.d.ts +38 -0
  117. package/lib/types/engine/path/path-morph.d.ts +47 -0
  118. package/lib/types/engine/path/path-utils.d.ts +73 -0
  119. package/lib/types/engine/serialization/index.d.ts +1 -0
  120. package/lib/types/engine/serialization/json.d.ts +30 -0
  121. package/lib/types/engine/text/index.d.ts +2 -0
  122. package/lib/types/engine/text/text-value.d.ts +16 -0
  123. package/lib/types/engine/types.d.ts +401 -0
  124. package/lib/types/frameworks/react.d.ts +35 -0
  125. package/lib/types/frameworks/solid.d.ts +16 -0
  126. package/lib/types/frameworks/svelte.d.ts +19 -0
  127. package/lib/types/frameworks/vue.d.ts +27 -0
  128. package/lib/types/interaction/draggable.d.ts +133 -0
  129. package/lib/types/interaction/index.d.ts +3 -0
  130. package/lib/types/interaction/observer.d.ts +80 -0
  131. package/lib/types/interaction/snap.d.ts +30 -0
  132. package/lib/types/player/index.d.ts +7 -0
  133. package/lib/types/player/media-sync.d.ts +60 -0
  134. package/lib/types/player/player.d.ts +238 -0
  135. package/lib/types/player/sequence-types.d.ts +68 -0
  136. package/lib/types/player/sequencer.d.ts +91 -0
  137. package/lib/types/teach/diagrams.d.ts +137 -0
  138. package/lib/types/teach/index.d.ts +11 -0
  139. package/lib/types/teach/lesson.d.ts +55 -0
  140. package/package.json +170 -0
@@ -0,0 +1,203 @@
1
+ import type { TimelineConfig, TimelineMarker, TimelineDefinition, AnimationState, PlaybackState, PlaybackDirection, AnyTrack } from '../types';
2
+ /** Selects a subset of a timeline's tracks. All given fields must match. */
3
+ export interface TrackFilter {
4
+ /** Match tracks driving this target (including one of a multi-target set) */
5
+ target?: string;
6
+ /** Match tracks driving this property */
7
+ property?: string;
8
+ /** Match tracks whose active span overlaps [from, to] in milliseconds */
9
+ timeRange?: {
10
+ from: number;
11
+ to: number;
12
+ };
13
+ /** Match a track by id */
14
+ id?: string;
15
+ }
16
+ /**
17
+ * Two tracks writing the same property of the same target over an overlapping
18
+ * span. The track that starts later wins (ties: added later); see `Timeline.findConflicts`.
19
+ */
20
+ export interface TrackConflict {
21
+ target: string;
22
+ property: string;
23
+ /** Track whose values are discarded where the spans overlap */
24
+ losingTrackId: string;
25
+ /** Track whose values are applied */
26
+ winningTrackId: string;
27
+ }
28
+ export type UpdateCallback = (state: AnimationState) => void;
29
+ export type CompleteCallback = () => void;
30
+ export interface TimelineOptions {
31
+ id: string;
32
+ name?: string;
33
+ tracks?: AnyTrack[];
34
+ config?: TimelineConfig;
35
+ /** Caption text per language, per marker id (carried through unchanged) */
36
+ captions?: Record<string, Record<string, string>>;
37
+ }
38
+ /**
39
+ * Timeline orchestrates playback of multiple tracks.
40
+ */
41
+ export declare class Timeline {
42
+ readonly id: string;
43
+ readonly name?: string;
44
+ /** Caption text per language, per marker id */
45
+ readonly captions?: Record<string, Record<string, string>>;
46
+ private _tracks;
47
+ private _trackPlayers;
48
+ private _motionPathTracks;
49
+ private _springTracks;
50
+ private _textTracks;
51
+ private _config;
52
+ private _currentTime;
53
+ private _playbackState;
54
+ private _direction;
55
+ private _loopIteration;
56
+ private _explicitDuration?;
57
+ /** Milliseconds still to wait at a loop boundary before the next iteration */
58
+ private _repeatDelayRemaining;
59
+ /**
60
+ * A forward loop reached its end with a repeat delay armed: the playhead
61
+ * holds on the last frame for the delay, then returns to the start.
62
+ */
63
+ private _wrapAfterDelay;
64
+ onUpdate: UpdateCallback | null;
65
+ onComplete: CompleteCallback | null;
66
+ constructor(options: TimelineOptions);
67
+ get tracks(): AnyTrack[];
68
+ get duration(): number;
69
+ /**
70
+ * Set an explicit timeline duration (ms). Pass `undefined` to fall back to the
71
+ * duration calculated from the last keyframe across all tracks.
72
+ */
73
+ setDuration(duration: number | undefined): void;
74
+ get currentTime(): number;
75
+ get playbackState(): PlaybackState;
76
+ get direction(): PlaybackDirection;
77
+ get loopIteration(): number;
78
+ /** Milliseconds of `repeatDelay` still to wait at a loop boundary (0 when not waiting). */
79
+ get repeatDelayRemaining(): number;
80
+ get speed(): number;
81
+ set speed(value: number);
82
+ /**
83
+ * Start or resume playback.
84
+ * If at the end and direction is forward, reset to beginning.
85
+ * If at the beginning and direction is reverse, reset to end.
86
+ */
87
+ play(): void;
88
+ /**
89
+ * Pause playback at current position.
90
+ */
91
+ pause(): void;
92
+ /**
93
+ * Stop playback and reset to beginning.
94
+ */
95
+ stop(): void;
96
+ /**
97
+ * Seek to a specific time.
98
+ */
99
+ seek(time: number): void;
100
+ /**
101
+ * Toggle or set playback direction.
102
+ */
103
+ reverse(): void;
104
+ /**
105
+ * Advance the timeline by delta milliseconds.
106
+ * Call this from your animation loop or clock.
107
+ */
108
+ tick(delta: number): void;
109
+ /**
110
+ * Get the animation state at a specific time.
111
+ */
112
+ getStateAtTime(time: number): AnimationState;
113
+ /**
114
+ * Several tracks drive the same target+property. Which one applies at `time`:
115
+ *
116
+ * 1. Of the tracks that have started (their first keyframe, plus delay and
117
+ * stagger, is at or before `time`), the one that started LAST.
118
+ * 2. If none has started yet, the one that starts FIRST — so the value before
119
+ * anything plays is the first animation's starting value.
120
+ * 3. Ties on start time go to the track added LAST.
121
+ *
122
+ * This is what makes a sequence of tweens on one property play as a sequence:
123
+ * a later tween holds its starting value, but does not apply it until its
124
+ * turn. `findConflicts()` reports overlaps by the same rule.
125
+ */
126
+ private _resolveShared;
127
+ /**
128
+ * Write one track's value for a target, expanding the progress of motion paths
129
+ * (into x/y/rotation) and text tracks (into the string). `elapsed` is the time
130
+ * since this target's animation on the track started.
131
+ */
132
+ private _write;
133
+ /** Cached: does any target+property have more than one track? */
134
+ private _sharedWrites;
135
+ private _hasSharedWrites;
136
+ /**
137
+ * Add a track to the timeline.
138
+ */
139
+ addTrack(track: AnyTrack): void;
140
+ /**
141
+ * Replace a track with a new version, keeping its place in the track order
142
+ * (which decides ties when tracks overlap). The new track may have a
143
+ * different id. Does nothing if no track has `trackId`.
144
+ */
145
+ replaceTrack(trackId: string, track: AnyTrack): void;
146
+ /**
147
+ * Remove a track by its ID.
148
+ */
149
+ removeTrack(trackId: string): void;
150
+ /**
151
+ * Tracks matching a filter. All provided fields must match (AND).
152
+ *
153
+ * This is the closest principled equivalent to GSAP's per-tween handle: we
154
+ * have no live tween objects to hold, so a "tween" is addressed by describing
155
+ * the tracks it produced.
156
+ */
157
+ getTracks(filter?: TrackFilter): AnyTrack[];
158
+ /**
159
+ * Remove every track matching a filter. Returns the ids removed.
160
+ *
161
+ * `timeline.removeTracks({ target: 'box' })` is the equivalent of killing all
162
+ * tweens on an element.
163
+ */
164
+ removeTracks(filter?: TrackFilter): string[];
165
+ /**
166
+ * The time span a track is active over: [start, end] in milliseconds.
167
+ */
168
+ getTrackSpan(trackId: string): {
169
+ from: number;
170
+ to: number;
171
+ } | undefined;
172
+ /**
173
+ * Overlapping writes to the same target+property.
174
+ *
175
+ * Where two spans overlap, the track that starts later wins from the moment it
176
+ * starts (ties: the one added later) — see `_resolveShared`. That is
177
+ * predictable but silent, so an authoring tool should call this and warn,
178
+ * because a silently discarded stretch of a track looks like a bug.
179
+ */
180
+ findConflicts(): TrackConflict[];
181
+ private _matches;
182
+ /**
183
+ * Export timeline as a serializable definition.
184
+ */
185
+ toDefinition(): TimelineDefinition;
186
+ /** The playback configuration, as loaded (read-only). */
187
+ get config(): Readonly<TimelineConfig>;
188
+ /** The timeline's markers, in time order (empty when it has none). */
189
+ get markers(): TimelineMarker[];
190
+ /** Start the between-iterations pause, if the timeline configures one. */
191
+ private _armRepeatDelay;
192
+ private _calculateDuration;
193
+ /**
194
+ * Handle reaching the end of the timeline.
195
+ * Returns true if we looped and should continue, false if we stopped.
196
+ */
197
+ private _handleEndReached;
198
+ /**
199
+ * Handle reaching the start of the timeline (in reverse).
200
+ * Returns true if we looped and should continue, false if we stopped.
201
+ */
202
+ private _handleStartReached;
203
+ }
@@ -0,0 +1,90 @@
1
+ import type { Track, AnimatableValue, SpringTrack, InertiaTrack } from '../types';
2
+ /**
3
+ * Create a track with sorted keyframes.
4
+ */
5
+ export declare function createTrack<T extends AnimatableValue>(options: Track<T>): Track<T>;
6
+ /** One target's value at a point in time. */
7
+ export interface TargetValue<T extends AnimatableValue = AnimatableValue> {
8
+ target: string;
9
+ value: T;
10
+ /** When this target's animation on the track starts, in timeline milliseconds */
11
+ start: number;
12
+ }
13
+ /**
14
+ * The targets a track drives, in order. A track either names one `target` or
15
+ * fans across `targets`; the multi-target form is what runtime stagger uses.
16
+ */
17
+ export declare function trackTargets(track: {
18
+ target: string;
19
+ targets?: string[];
20
+ }): string[];
21
+ /**
22
+ * TrackPlayer computes interpolated values for a track at any given time.
23
+ */
24
+ export declare class TrackPlayer<T extends AnimatableValue = AnimatableValue> {
25
+ private track;
26
+ private targets;
27
+ constructor(track: Track<T>);
28
+ /**
29
+ * Get the interpolated value at a specific time.
30
+ *
31
+ * For a multi-target track this returns the *first* target's value; callers
32
+ * that need every target should use `getTargetValues`.
33
+ */
34
+ getValueAtTime(time: number): T | undefined;
35
+ /**
36
+ * Every target's value at a specific time, in target order.
37
+ *
38
+ * Single-target tracks yield one entry; staggered tracks yield one per target,
39
+ * each sampled at its own offset time.
40
+ */
41
+ getTargetValues(time: number): TargetValue<T>[];
42
+ /**
43
+ * Get the duration of this track — the last keyframe, plus any delay, the
44
+ * widest stagger offset, and any trailing hold.
45
+ */
46
+ getDuration(): number;
47
+ /**
48
+ * Get the track metadata.
49
+ */
50
+ getTrack(): Track<T>;
51
+ /** Interpolated value at a time already shifted into the track's own frame. */
52
+ private valueForOffset;
53
+ /**
54
+ * Find the keyframes surrounding a given time.
55
+ */
56
+ private findSurroundingKeyframes;
57
+ }
58
+ /**
59
+ * SpringTrackPlayer evaluates a spring track.
60
+ *
61
+ * Mirrors `TrackPlayer`'s surface so `Timeline` can treat both the same way.
62
+ * The underlying `SpringSampler` caches its simulation, so scrubbing is cheap
63
+ * after the first pass.
64
+ */
65
+ export declare class SpringTrackPlayer {
66
+ private track;
67
+ private targets;
68
+ private sampler;
69
+ constructor(track: SpringTrack);
70
+ getValueAtTime(time: number): number;
71
+ getTargetValues(time: number): TargetValue<number>[];
72
+ /** Settle time plus delay and the widest stagger offset. */
73
+ getDuration(): number;
74
+ getTrack(): SpringTrack;
75
+ }
76
+ /**
77
+ * InertiaTrackPlayer evaluates a throw. The motion is closed-form, so there is
78
+ * nothing to simulate or cache: each value is computed directly from time.
79
+ */
80
+ export declare class InertiaTrackPlayer {
81
+ private track;
82
+ private targets;
83
+ private duration;
84
+ constructor(track: InertiaTrack);
85
+ getValueAtTime(time: number): number;
86
+ getTargetValues(time: number): TargetValue<number>[];
87
+ /** Settle time plus delay and the widest stagger offset. */
88
+ getDuration(): number;
89
+ getTrack(): InertiaTrack;
90
+ }
@@ -0,0 +1,36 @@
1
+ /**
2
+ * Growable byte buffer shared by the binary exporters (GIF, WebP, MP4).
3
+ *
4
+ * Container formats need to append bytes of mixed widths and endianness, and
5
+ * occasionally patch a length back into an earlier offset. Doing that with a
6
+ * plain number array is slow and error-prone, so everything funnels through
7
+ * this one small writer.
8
+ */
9
+ export declare class ByteWriter {
10
+ private buf;
11
+ private len;
12
+ constructor(initialCapacity?: number);
13
+ /** Bytes written so far — also the offset the next write lands at. */
14
+ get length(): number;
15
+ private ensure;
16
+ byte(value: number): void;
17
+ bytes(values: ArrayLike<number>): void;
18
+ /** Each character's low byte, e.g. a FourCC or an MP4 box type. */
19
+ ascii(text: string): void;
20
+ uint16LE(value: number): void;
21
+ uint24LE(value: number): void;
22
+ uint32LE(value: number): void;
23
+ uint16BE(value: number): void;
24
+ uint24BE(value: number): void;
25
+ uint32BE(value: number): void;
26
+ /** 64-bit big-endian, written as two 32-bit halves (safe up to 2^53). */
27
+ uint64BE(value: number): void;
28
+ /** Overwrite a previously written 32-bit big-endian value, e.g. a box size. */
29
+ patchUint32BE(offset: number, value: number): void;
30
+ /** Overwrite a previously written 32-bit little-endian value. */
31
+ patchUint32LE(offset: number, value: number): void;
32
+ /** A view over the written bytes. Not a copy — do not retain across writes. */
33
+ toUint8Array(): Uint8Array<ArrayBuffer>;
34
+ /** A standalone copy of the written bytes, safe to hand to a Blob. */
35
+ toBytes(): Uint8Array<ArrayBuffer>;
36
+ }
@@ -0,0 +1,31 @@
1
+ import type { Timeline } from '../core/timeline';
2
+ /**
3
+ * CSS export options
4
+ */
5
+ export interface CSSExportOptions {
6
+ /** Class name prefix for generated selectors */
7
+ classPrefix?: string;
8
+ /** Whether to include @keyframes declarations */
9
+ includeKeyframes?: boolean;
10
+ /** Whether to include animation shorthand properties */
11
+ includeAnimation?: boolean;
12
+ /** Whether to minify the output */
13
+ minify?: boolean;
14
+ /** Custom property mappings (e.g., 'x' -> 'left') */
15
+ propertyMap?: Record<string, string>;
16
+ }
17
+ /**
18
+ * Exported CSS result
19
+ */
20
+ export interface CSSExportResult {
21
+ /** Full CSS output string */
22
+ css: string;
23
+ /** Individual keyframes by animation name */
24
+ keyframes: Map<string, string>;
25
+ /** Individual selectors with animation properties */
26
+ selectors: Map<string, string>;
27
+ }
28
+ /**
29
+ * Export a timeline to CSS keyframes and animation properties.
30
+ */
31
+ export declare function exportToCSS(timeline: Timeline, options?: CSSExportOptions): CSSExportResult;
@@ -0,0 +1,24 @@
1
+ /**
2
+ * Minimal GIF89a reader used by the export tests.
3
+ *
4
+ * This exists so the encoder is verified by actually decoding its output back to
5
+ * pixels rather than by asserting the blob is non-empty. It supports only what
6
+ * our encoder emits: full-canvas frames with local colour tables.
7
+ */
8
+ export interface DecodedFrame {
9
+ /** RGBA pixels, `width * height * 4` bytes. */
10
+ rgba: Uint8Array;
11
+ /** Delay in centiseconds. */
12
+ delay: number;
13
+ /** Transparent colour index, or -1 when the frame is opaque. */
14
+ transparentIndex: number;
15
+ /** Disposal method from the graphic control extension. */
16
+ disposal: number;
17
+ }
18
+ export interface DecodedGIF {
19
+ width: number;
20
+ height: number;
21
+ loops: number;
22
+ frames: DecodedFrame[];
23
+ }
24
+ export declare function decodeGIF(bytes: Uint8Array): DecodedGIF;
@@ -0,0 +1,134 @@
1
+ import type { Timeline } from '../core/timeline';
2
+ import type { AnimatableValue } from '../types';
3
+ /**
4
+ * Animated GIF export.
5
+ *
6
+ * Frames are quantized to a 255-colour local palette (index 0 is reserved for
7
+ * transparency), LZW-compressed, and written as a GIF89a stream. Encoding is
8
+ * pure byte manipulation — the only DOM dependency is the canvas used to
9
+ * rasterise frames, so `GIFEncoder` itself runs anywhere, including Workers.
10
+ */
11
+ /**
12
+ * GIF export options
13
+ */
14
+ export interface GIFExportOptions {
15
+ /** Canvas width */
16
+ width: number;
17
+ /** Canvas height */
18
+ height: number;
19
+ /** Frame rate (default: 30) */
20
+ frameRate?: number;
21
+ /** Background color (default: transparent) */
22
+ backgroundColor?: string;
23
+ /** Number of loops (0 = infinite, default: 0) */
24
+ loops?: number;
25
+ /** Diffuse quantization error into neighbouring pixels (default: true) */
26
+ dither?: boolean;
27
+ /** Palette size per frame, 2-255 (default: 255) */
28
+ maxColors?: number;
29
+ /** Custom render function for each frame */
30
+ renderFrame?: (ctx: CanvasRenderingContext2D, values: Map<string, Map<string, AnimatableValue>>, time: number) => void | Promise<void>;
31
+ /** Progress callback, 0..1 */
32
+ onProgress?: (fraction: number) => void;
33
+ /** Abort the export early */
34
+ signal?: AbortSignal;
35
+ }
36
+ /**
37
+ * GIF frame data
38
+ */
39
+ export interface GIFFrame {
40
+ /** Frame time in milliseconds */
41
+ time: number;
42
+ /** Frame image data */
43
+ imageData: ImageData;
44
+ /** Frame delay in centiseconds (1/100th of a second) */
45
+ delay: number;
46
+ }
47
+ /**
48
+ * GIF export result
49
+ */
50
+ export interface GIFExportResult {
51
+ /** Array of frames ready for encoding */
52
+ frames: GIFFrame[];
53
+ /** Total duration in milliseconds */
54
+ duration: number;
55
+ /** Number of frames */
56
+ frameCount: number;
57
+ }
58
+ /** Minimal image shape the encoder needs — matches `ImageData`. */
59
+ interface RGBAImage {
60
+ data: Uint8ClampedArray | Uint8Array;
61
+ width: number;
62
+ height: number;
63
+ }
64
+ /**
65
+ * LZW-compress palette indices into GIF image data (sub-block framing included,
66
+ * minus the leading minimum-code-size byte).
67
+ *
68
+ * Codes are written LSB-first and the dictionary is reset with a clear code
69
+ * whenever it fills, as the GIF89a spec requires.
70
+ */
71
+ export declare function lzwEncode(indices: Uint8Array, minCodeSize: number): Uint8Array;
72
+ export interface GIFEncoderOptions {
73
+ /** Number of loops (0 = infinite, default: 0) */
74
+ loops?: number;
75
+ /** Diffuse quantization error into neighbouring pixels (default: true) */
76
+ dither?: boolean;
77
+ /** Palette size per frame, 2-255 (default: 255) */
78
+ maxColors?: number;
79
+ }
80
+ /**
81
+ * Animated GIF encoder.
82
+ *
83
+ * Each frame is quantized and compressed as it is added, so only compressed
84
+ * bytes are retained — memory stays proportional to output size rather than to
85
+ * frame count times canvas area.
86
+ */
87
+ export declare class GIFEncoder {
88
+ private readonly width;
89
+ private readonly height;
90
+ private readonly loops;
91
+ private readonly dither;
92
+ private readonly maxColors;
93
+ /** Fully-encoded blocks (GCE + descriptor + palette + data) per frame. */
94
+ private frames;
95
+ constructor(width: number, height: number, loopsOrOptions?: number | GIFEncoderOptions);
96
+ /** Number of frames added so far. */
97
+ get frameCount(): number;
98
+ /**
99
+ * Quantize and compress one frame.
100
+ *
101
+ * @param delay Frame delay in centiseconds (1/100s), as GIF stores it.
102
+ */
103
+ addFrame(imageData: RGBAImage, delay: number): void;
104
+ /** Assemble the full GIF byte stream. */
105
+ encodeToBytes(): Uint8Array;
106
+ /** Encode and return the GIF as a Blob. */
107
+ encode(): Blob;
108
+ }
109
+ /**
110
+ * @deprecated Use {@link GIFEncoder}. Kept as an alias for existing callers.
111
+ */
112
+ export declare const SimpleGIFEncoder: typeof GIFEncoder;
113
+ /**
114
+ * Extract animation frames from a timeline as raw `ImageData`.
115
+ *
116
+ * Useful when you want to post-process frames yourself; {@link exportToGIF}
117
+ * uses the same rasterisation path and encodes in one step.
118
+ *
119
+ * Note: requires a DOM environment (canvas element).
120
+ */
121
+ export declare function extractFrames(timeline: Timeline, options: GIFExportOptions): GIFExportResult;
122
+ /**
123
+ * Render a timeline to an animated GIF blob.
124
+ *
125
+ * The `renderFrame` callback draws the animation state onto an already-cleared
126
+ * (and optionally background-filled) canvas; it may be async, which lets callers
127
+ * seek video layers before each frame.
128
+ */
129
+ export declare function exportToGIF(timeline: Timeline, options: GIFExportOptions): Promise<Blob>;
130
+ /**
131
+ * Download a GIF blob as a file
132
+ */
133
+ export declare function downloadGIF(blob: Blob, filename?: string): void;
134
+ export {};
@@ -0,0 +1,9 @@
1
+ export * from './css';
2
+ export * from './lottie';
3
+ export * from './gif';
4
+ export * from './webp';
5
+ export * from './mp4';
6
+ export * from './video';
7
+ export * from './sprite-sheet';
8
+ export * from './quantize';
9
+ export * from './byte-writer';
@@ -0,0 +1,104 @@
1
+ import type { Timeline } from '../core/timeline';
2
+ /**
3
+ * Lottie export options
4
+ */
5
+ export interface LottieExportOptions {
6
+ /** Animation name */
7
+ name?: string;
8
+ /** Frame rate (default: 60) */
9
+ frameRate?: number;
10
+ /** Canvas width (default: 512) */
11
+ width?: number;
12
+ /** Canvas height (default: 512) */
13
+ height?: number;
14
+ /** Background color (default: transparent) */
15
+ backgroundColor?: string;
16
+ }
17
+ /**
18
+ * Lottie JSON structure (simplified)
19
+ * Full spec: https://lottiefiles.github.io/lottie-docs/
20
+ */
21
+ export interface LottieAnimation {
22
+ v: string;
23
+ nm: string;
24
+ fr: number;
25
+ ip: number;
26
+ op: number;
27
+ w: number;
28
+ h: number;
29
+ ddd: number;
30
+ assets: LottieAsset[];
31
+ layers: LottieLayer[];
32
+ }
33
+ interface LottieAsset {
34
+ id: string;
35
+ [key: string]: unknown;
36
+ }
37
+ interface LottieLayer {
38
+ ddd: number;
39
+ ind: number;
40
+ ty: number;
41
+ nm: string;
42
+ sr: number;
43
+ ks: LottieTransform;
44
+ ao: number;
45
+ shapes?: LottieShape[];
46
+ ip: number;
47
+ op: number;
48
+ st: number;
49
+ bm: number;
50
+ }
51
+ interface LottieTransform {
52
+ o?: LottieAnimatedValue;
53
+ r?: LottieAnimatedValue;
54
+ p?: LottieAnimatedMultiValue;
55
+ a?: LottieAnimatedMultiValue;
56
+ s?: LottieAnimatedMultiValue;
57
+ }
58
+ interface LottieAnimatedValue {
59
+ a: number;
60
+ k: number | LottieKeyframe[];
61
+ }
62
+ interface LottieAnimatedMultiValue {
63
+ a: number;
64
+ k: number[] | LottieMultiKeyframe[];
65
+ }
66
+ interface LottieKeyframe {
67
+ t: number;
68
+ s: number[];
69
+ e?: number[];
70
+ i?: {
71
+ x: number[];
72
+ y: number[];
73
+ };
74
+ o?: {
75
+ x: number[];
76
+ y: number[];
77
+ };
78
+ }
79
+ interface LottieMultiKeyframe {
80
+ t: number;
81
+ s: number[];
82
+ e?: number[];
83
+ i?: {
84
+ x: number[];
85
+ y: number[];
86
+ };
87
+ o?: {
88
+ x: number[];
89
+ y: number[];
90
+ };
91
+ }
92
+ interface LottieShape {
93
+ ty: string;
94
+ [key: string]: unknown;
95
+ }
96
+ /**
97
+ * Export a timeline to Lottie JSON format.
98
+ */
99
+ export declare function exportToLottie(timeline: Timeline, options?: LottieExportOptions): LottieAnimation;
100
+ /**
101
+ * Export timeline to Lottie JSON string
102
+ */
103
+ export declare function exportToLottieJSON(timeline: Timeline, options?: LottieExportOptions): string;
104
+ export {};