@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.
- package/LICENSE +21 -0
- package/README.md +672 -0
- package/bin/tinyfly.mjs +59 -0
- package/lib/addons/adapters.js +756 -0
- package/lib/addons/dom-adapter-ChrbtkLC.js +243 -0
- package/lib/addons/drivers.js +72 -0
- package/lib/addons/export.js +1169 -0
- package/lib/addons/gsap-compat.js +2576 -0
- package/lib/addons/interaction.js +225 -0
- package/lib/addons/smooth-scroll-DaSacemU.js +671 -0
- package/lib/addons/teach.js +215 -0
- package/lib/browser/tinyfly.iife.js +2 -0
- package/lib/browser/tinyfly.js +6372 -0
- package/lib/browser/tinyfly.umd.js +2 -0
- package/lib/cli/tools.js +2325 -0
- package/lib/embed/tinyfly-embed.iife.js +18 -0
- package/lib/embed/tinyfly-embed.js +2316 -0
- package/lib/engine/tinyfly-engine.js +1972 -0
- package/lib/engine/tinyfly-engine.umd.cjs +2 -0
- package/lib/frameworks/react.js +32 -0
- package/lib/frameworks/solid.js +27 -0
- package/lib/frameworks/svelte.js +15 -0
- package/lib/frameworks/vue.js +29 -0
- package/lib/player/tinyfly-player.es.js +2306 -0
- package/lib/player/tinyfly-player.iife.js +2 -0
- package/lib/player/tinyfly-player.umd.js +2 -0
- package/lib/types/adapters/canvas/canvas-adapter.d.ts +238 -0
- package/lib/types/adapters/canvas/index.d.ts +1 -0
- package/lib/types/adapters/dom/dom-adapter.d.ts +50 -0
- package/lib/types/adapters/dom/flip.d.ts +60 -0
- package/lib/types/adapters/dom/index.d.ts +2 -0
- package/lib/types/adapters/filter-utils.d.ts +32 -0
- package/lib/types/adapters/index.d.ts +5 -0
- package/lib/types/adapters/shine-utils.d.ts +26 -0
- package/lib/types/adapters/svg/index.d.ts +1 -0
- package/lib/types/adapters/svg/svg-adapter.d.ts +47 -0
- package/lib/types/adapters/svg-transform-box.d.ts +13 -0
- package/lib/types/adapters/text-content.d.ts +11 -0
- package/lib/types/adapters/webgl/index.d.ts +1 -0
- package/lib/types/adapters/webgl/webgl-adapter.d.ts +69 -0
- package/lib/types/browser/index.d.ts +41 -0
- package/lib/types/compat/gsap/custom-eases.d.ts +28 -0
- package/lib/types/compat/gsap/defaults.d.ts +19 -0
- package/lib/types/compat/gsap/draw-svg-vars.d.ts +36 -0
- package/lib/types/compat/gsap/ease-map.d.ts +51 -0
- package/lib/types/compat/gsap/image-sequence.d.ts +61 -0
- package/lib/types/compat/gsap/index.d.ts +65 -0
- package/lib/types/compat/gsap/inertia-vars.d.ts +39 -0
- package/lib/types/compat/gsap/keyframes-vars.d.ts +8 -0
- package/lib/types/compat/gsap/layout.d.ts +6 -0
- package/lib/types/compat/gsap/live-context.d.ts +87 -0
- package/lib/types/compat/gsap/live-draggable.d.ts +75 -0
- package/lib/types/compat/gsap/live-flip.d.ts +73 -0
- package/lib/types/compat/gsap/live-morph.d.ts +18 -0
- package/lib/types/compat/gsap/live-motion-path.d.ts +33 -0
- package/lib/types/compat/gsap/live-scroll-to.d.ts +52 -0
- package/lib/types/compat/gsap/live-scroll.d.ts +108 -0
- package/lib/types/compat/gsap/live-transition.d.ts +40 -0
- package/lib/types/compat/gsap/live.d.ts +341 -0
- package/lib/types/compat/gsap/morph-vars.d.ts +21 -0
- package/lib/types/compat/gsap/motion-path-vars.d.ts +38 -0
- package/lib/types/compat/gsap/playhead-crossings.d.ts +47 -0
- package/lib/types/compat/gsap/position.d.ts +37 -0
- package/lib/types/compat/gsap/quick-play.d.ts +38 -0
- package/lib/types/compat/gsap/split-text.d.ts +66 -0
- package/lib/types/compat/gsap/spring-vars.d.ts +34 -0
- package/lib/types/compat/gsap/stage.d.ts +182 -0
- package/lib/types/compat/gsap/stagger-grid.d.ts +30 -0
- package/lib/types/compat/gsap/text-vars.d.ts +39 -0
- package/lib/types/compat/gsap/timeline.d.ts +161 -0
- package/lib/types/compat/gsap/utils.d.ts +60 -0
- package/lib/types/compat/gsap/vars.d.ts +79 -0
- package/lib/types/drivers/index.d.ts +8 -0
- package/lib/types/drivers/scroll-driver.d.ts +218 -0
- package/lib/types/drivers/scroll-markers.d.ts +41 -0
- package/lib/types/drivers/scroll-math.d.ts +87 -0
- package/lib/types/drivers/scroll-pin.d.ts +45 -0
- package/lib/types/drivers/scroll-snap.d.ts +47 -0
- package/lib/types/drivers/smooth-scroll.d.ts +118 -0
- package/lib/types/drivers/types.d.ts +23 -0
- package/lib/types/drivers/visibility-driver.d.ts +56 -0
- package/lib/types/embed/controls.d.ts +46 -0
- package/lib/types/embed/index.d.ts +17 -0
- package/lib/types/embed/mount.d.ts +41 -0
- package/lib/types/embed/tools.d.ts +33 -0
- package/lib/types/engine/authoring/custom-ease.d.ts +49 -0
- package/lib/types/engine/authoring/index.d.ts +3 -0
- package/lib/types/engine/authoring/random.d.ts +38 -0
- package/lib/types/engine/authoring/resolve-values.d.ts +57 -0
- package/lib/types/engine/core/bake.d.ts +66 -0
- package/lib/types/engine/core/clock.d.ts +44 -0
- package/lib/types/engine/core/index.d.ts +8 -0
- package/lib/types/engine/core/inertia.d.ts +30 -0
- package/lib/types/engine/core/playhead-crossings.d.ts +47 -0
- package/lib/types/engine/core/spring.d.ts +132 -0
- package/lib/types/engine/core/stagger.d.ts +40 -0
- package/lib/types/engine/core/timeline.d.ts +203 -0
- package/lib/types/engine/core/track.d.ts +90 -0
- package/lib/types/engine/export/byte-writer.d.ts +36 -0
- package/lib/types/engine/export/css.d.ts +31 -0
- package/lib/types/engine/export/gif-decode.test-helper.d.ts +24 -0
- package/lib/types/engine/export/gif.d.ts +134 -0
- package/lib/types/engine/export/index.d.ts +9 -0
- package/lib/types/engine/export/lottie.d.ts +104 -0
- package/lib/types/engine/export/mp4.d.ts +64 -0
- package/lib/types/engine/export/quantize.d.ts +56 -0
- package/lib/types/engine/export/sprite-sheet.d.ts +46 -0
- package/lib/types/engine/export/video.d.ts +99 -0
- package/lib/types/engine/export/webp.d.ts +82 -0
- package/lib/types/engine/index.d.ts +7 -0
- package/lib/types/engine/interpolation/easing.d.ts +65 -0
- package/lib/types/engine/interpolation/index.d.ts +2 -0
- package/lib/types/engine/interpolation/interpolators.d.ts +25 -0
- package/lib/types/engine/path/index.d.ts +11 -0
- package/lib/types/engine/path/motion-path.d.ts +24 -0
- package/lib/types/engine/path/path-builders.d.ts +38 -0
- package/lib/types/engine/path/path-morph.d.ts +47 -0
- package/lib/types/engine/path/path-utils.d.ts +73 -0
- package/lib/types/engine/serialization/index.d.ts +1 -0
- package/lib/types/engine/serialization/json.d.ts +30 -0
- package/lib/types/engine/text/index.d.ts +2 -0
- package/lib/types/engine/text/text-value.d.ts +16 -0
- package/lib/types/engine/types.d.ts +401 -0
- package/lib/types/frameworks/react.d.ts +35 -0
- package/lib/types/frameworks/solid.d.ts +16 -0
- package/lib/types/frameworks/svelte.d.ts +19 -0
- package/lib/types/frameworks/vue.d.ts +27 -0
- package/lib/types/interaction/draggable.d.ts +133 -0
- package/lib/types/interaction/index.d.ts +3 -0
- package/lib/types/interaction/observer.d.ts +80 -0
- package/lib/types/interaction/snap.d.ts +30 -0
- package/lib/types/player/index.d.ts +7 -0
- package/lib/types/player/media-sync.d.ts +60 -0
- package/lib/types/player/player.d.ts +238 -0
- package/lib/types/player/sequence-types.d.ts +68 -0
- package/lib/types/player/sequencer.d.ts +91 -0
- package/lib/types/teach/diagrams.d.ts +137 -0
- package/lib/types/teach/index.d.ts +11 -0
- package/lib/types/teach/lesson.d.ts +55 -0
- package/package.json +170 -0
|
@@ -0,0 +1,182 @@
|
|
|
1
|
+
import { type LiveUtils } from './utils';
|
|
2
|
+
import type { Timeline, AnimatableValue } from '../../engine';
|
|
3
|
+
import type { ContextCollector, ContextHost } from './live-context';
|
|
4
|
+
/**
|
|
5
|
+
* The shared runtime behind the live facade: one frame loop, one DOM adapter,
|
|
6
|
+
* and a record of the values currently applied to each element. Plain objects
|
|
7
|
+
* are targets too — their values are assigned straight onto them — and the
|
|
8
|
+
* ticker lets other rendering (canvas, WebGL) run on the same frame.
|
|
9
|
+
*
|
|
10
|
+
* Why one stage rather than a loop per animation. The DOM adapter composes
|
|
11
|
+
* `transform` from the properties in the state it is given, so two independent
|
|
12
|
+
* timelines — one moving `x`, one turning `rotate` — would each write a
|
|
13
|
+
* transform that omits the other's property, and the element would flicker
|
|
14
|
+
* between them. The stage merges every active timeline's values per element
|
|
15
|
+
* before applying, so they compose instead of overwriting.
|
|
16
|
+
*
|
|
17
|
+
* Merge rule: timelines are ticked in activation order and write into the same
|
|
18
|
+
* per-element map, so when two drive the same property at once, the one played
|
|
19
|
+
* most recently wins. This mirrors the engine's own rule for tracks, where
|
|
20
|
+
* the one that started most recently wins.
|
|
21
|
+
*
|
|
22
|
+
* The stage holds only *playing* timelines. A timeline that finishes or pauses
|
|
23
|
+
* drops out after its last frame is applied — its final values stay in the
|
|
24
|
+
* applied map, so later tweens compose with (and start from) them — and is
|
|
25
|
+
* re-activated by playing it again. Nothing is retained for finished one-off
|
|
26
|
+
* tweens beyond their element's last values.
|
|
27
|
+
*/
|
|
28
|
+
/**
|
|
29
|
+
* A plain JavaScript object animated directly: its numeric (or colour) properties
|
|
30
|
+
* are written back onto it each frame — `{ x: 0 }`, a Three.js `mesh.position`,
|
|
31
|
+
* a shader uniform. Arrays and node lists are lists of targets, not objects.
|
|
32
|
+
*/
|
|
33
|
+
export type ObjectTarget = object;
|
|
34
|
+
/** Anything the live facade accepts as a target. */
|
|
35
|
+
export type TargetInput = string | Element | ObjectTarget | ArrayLike<Element> | ReadonlyArray<string | Element | ObjectTarget>;
|
|
36
|
+
/**
|
|
37
|
+
* Called once per frame, after that frame's values are applied — the place to
|
|
38
|
+
* render a canvas or a WebGL scene from objects tinyfly is animating.
|
|
39
|
+
* `time` is seconds since the ticker started, `deltaTime` milliseconds since the
|
|
40
|
+
* previous frame, `frame` a frame counter (GSAP's ticker signature).
|
|
41
|
+
*/
|
|
42
|
+
export type TickerCallback = (time: number, deltaTime: number, frame: number) => void;
|
|
43
|
+
export interface Ticker {
|
|
44
|
+
add(callback: TickerCallback): void;
|
|
45
|
+
remove(callback: TickerCallback): void;
|
|
46
|
+
}
|
|
47
|
+
/** Frame scheduling, injectable so the stage can be driven by tests. */
|
|
48
|
+
export interface FrameScheduler {
|
|
49
|
+
request(callback: (timestamp: number) => void): number;
|
|
50
|
+
cancel(id: number): void;
|
|
51
|
+
}
|
|
52
|
+
export interface StageOptions {
|
|
53
|
+
scheduler?: FrameScheduler;
|
|
54
|
+
/** Document used to resolve selector targets (default: the global document) */
|
|
55
|
+
root?: ParentNode;
|
|
56
|
+
}
|
|
57
|
+
interface ActiveEntry {
|
|
58
|
+
onUpdate?: () => void;
|
|
59
|
+
}
|
|
60
|
+
export declare class Stage implements ContextHost {
|
|
61
|
+
private readonly adapter;
|
|
62
|
+
private readonly scheduler;
|
|
63
|
+
private readonly rootOption?;
|
|
64
|
+
/** Element → engine target name. The engine only ever sees names. */
|
|
65
|
+
private names;
|
|
66
|
+
private readonly elements;
|
|
67
|
+
private nameCounter;
|
|
68
|
+
/** Plain-object targets, named like elements but written directly. */
|
|
69
|
+
private objectNames;
|
|
70
|
+
private readonly objects;
|
|
71
|
+
/** Things created for this stage that outlive a timeline (scroll triggers, pins). */
|
|
72
|
+
private readonly owned;
|
|
73
|
+
private currentCollector;
|
|
74
|
+
private readonly tickerCallbacks;
|
|
75
|
+
private tickerTime;
|
|
76
|
+
private tickerFrame;
|
|
77
|
+
/**
|
|
78
|
+
* Live timelines that may still move something — playing, paused or scroll
|
|
79
|
+
* driven — for `live.killTweensOf`. Finished one-off timelines leave it.
|
|
80
|
+
*/
|
|
81
|
+
readonly liveTimelines: Set<{
|
|
82
|
+
killTweensOf(names: string[], properties?: string[]): void;
|
|
83
|
+
}>;
|
|
84
|
+
/** GSAP-style utilities, with this stage's seeded random sequence (`live.utils`). */
|
|
85
|
+
readonly utils: LiveUtils;
|
|
86
|
+
/** Playing timelines, in activation order. */
|
|
87
|
+
private readonly active;
|
|
88
|
+
/** Last applied value per target name and property. */
|
|
89
|
+
private readonly applied;
|
|
90
|
+
/** Targets written since the last apply. */
|
|
91
|
+
private readonly dirty;
|
|
92
|
+
private frameId;
|
|
93
|
+
private lastTimestamp;
|
|
94
|
+
private destroyed;
|
|
95
|
+
constructor(options?: StageOptions);
|
|
96
|
+
/**
|
|
97
|
+
* Where selector targets are resolved: the given root, or the document.
|
|
98
|
+
* Read lazily so a stage can be created where there is no document (Node, a
|
|
99
|
+
* Worker) as long as nothing is resolved there.
|
|
100
|
+
*/
|
|
101
|
+
get root(): ParentNode;
|
|
102
|
+
/**
|
|
103
|
+
* Resolve selectors, elements, plain objects and lists of them to engine
|
|
104
|
+
* target names, registering each element with the adapter (and each object
|
|
105
|
+
* with the stage) the first time it is seen.
|
|
106
|
+
* Returns an empty array when nothing matches.
|
|
107
|
+
*/
|
|
108
|
+
resolveTargets(input: TargetInput): string[];
|
|
109
|
+
/** Find one element the way selector targets are found: within the stage's root (or the collecting context's scope). */
|
|
110
|
+
query(selector: string): Element | null;
|
|
111
|
+
/** The context collecting what is created right now, if any (see live-context.ts). */
|
|
112
|
+
get collector(): ContextCollector | undefined;
|
|
113
|
+
setCollector(collector: ContextCollector | undefined): void;
|
|
114
|
+
/** Drop the values applied to a target, so the next animation starts from its natural state. */
|
|
115
|
+
forget(name: string): void;
|
|
116
|
+
private get selectorRoot();
|
|
117
|
+
/** The element registered under a target name. */
|
|
118
|
+
elementFor(name: string): Element | undefined;
|
|
119
|
+
/** The plain object registered under a target name. */
|
|
120
|
+
objectFor(name: string): ObjectTarget | undefined;
|
|
121
|
+
/** Last value the stage applied to a target's property, if any. */
|
|
122
|
+
appliedValue(name: string, property: string): AnimatableValue | undefined;
|
|
123
|
+
/**
|
|
124
|
+
* How fast a property is changing right now, in units per second, taken from
|
|
125
|
+
* the most recently played timeline that animates it — so a spring started
|
|
126
|
+
* mid-motion carries the momentum. A finite difference over a few milliseconds
|
|
127
|
+
* of that timeline's own (deterministic) state; undefined when nothing playing
|
|
128
|
+
* animates the property.
|
|
129
|
+
*/
|
|
130
|
+
velocityOf(name: string, property: string): number | undefined;
|
|
131
|
+
/**
|
|
132
|
+
* Run a callback every frame, after animations are applied. The frame loop
|
|
133
|
+
* keeps going while any callback is registered, even with nothing playing.
|
|
134
|
+
*/
|
|
135
|
+
readonly ticker: Ticker;
|
|
136
|
+
/**
|
|
137
|
+
* Add a timeline to the running set and make sure the loop is going. The
|
|
138
|
+
* timeline must already be playing; activating an already active timeline
|
|
139
|
+
* moves it to the end of the order, so it wins merges.
|
|
140
|
+
*/
|
|
141
|
+
activate(timeline: Timeline, entry?: ActiveEntry): void;
|
|
142
|
+
/** Remove a timeline from the running set. Its applied values remain. */
|
|
143
|
+
deactivate(timeline: Timeline): void;
|
|
144
|
+
/** Destroy `resource` along with the stage. Returns it. */
|
|
145
|
+
own<T extends {
|
|
146
|
+
destroy(): void;
|
|
147
|
+
}>(resource: T): T;
|
|
148
|
+
/**
|
|
149
|
+
* Stop everything on this stage and release its elements. Animations that
|
|
150
|
+
* are still running stop where they are; elements keep the styles last
|
|
151
|
+
* applied. A destroyed stage ignores later playback, so a timeline whose
|
|
152
|
+
* autoplay was already queued cannot restart the loop.
|
|
153
|
+
*/
|
|
154
|
+
destroy(): void;
|
|
155
|
+
/**
|
|
156
|
+
* Write values for one target straight away, without a timeline — for direct
|
|
157
|
+
* manipulation such as dragging, where every pointer move sets a position.
|
|
158
|
+
* The values join the applied state, so later tweens start from them.
|
|
159
|
+
*/
|
|
160
|
+
apply(name: string, values: Record<string, AnimatableValue>): void;
|
|
161
|
+
/** Apply a timeline's state at its current time, immediately. */
|
|
162
|
+
render(timeline: Timeline): void;
|
|
163
|
+
/**
|
|
164
|
+
* Advance every active timeline by `deltaMs` and apply the merged result.
|
|
165
|
+
* The frame loop calls this; it is public so hosts that own their own loop
|
|
166
|
+
* (or tests) can drive the stage directly.
|
|
167
|
+
*/
|
|
168
|
+
tick(deltaMs: number): void;
|
|
169
|
+
/** Whether the frame loop has work: something playing, or a ticker callback. */
|
|
170
|
+
private get running();
|
|
171
|
+
private runTicker;
|
|
172
|
+
private write;
|
|
173
|
+
private flush;
|
|
174
|
+
private readonly frame;
|
|
175
|
+
private startLoop;
|
|
176
|
+
private stopLoop;
|
|
177
|
+
private targetsOf;
|
|
178
|
+
private nameFor;
|
|
179
|
+
private objectName;
|
|
180
|
+
private elementName;
|
|
181
|
+
}
|
|
182
|
+
export {};
|
|
@@ -0,0 +1,30 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* GSAP's advanced stagger — `grid`, `from: 'random'` or `[x, y]`, `axis` and
|
|
3
|
+
* `ease` — worked out into one explicit offset per target (milliseconds). The
|
|
4
|
+
* engine stores them as `stagger.offsets`, so the result is still plain JSON.
|
|
5
|
+
*
|
|
6
|
+
* stagger: { grid: [5, 8], from: 'center', amount: 1.2, ease: 'power2.in' }
|
|
7
|
+
*
|
|
8
|
+
* Distances are measured in grid cells from the origin (Euclidean, or along one
|
|
9
|
+
* `axis`), then scaled: `amount` is the total spread, `each` the time per cell.
|
|
10
|
+
*/
|
|
11
|
+
export type GridFrom = 'start' | 'end' | 'center' | 'edges' | 'random' | number | [number, number];
|
|
12
|
+
export interface GridStagger {
|
|
13
|
+
each?: number;
|
|
14
|
+
amount?: number;
|
|
15
|
+
from?: GridFrom;
|
|
16
|
+
/** `[rows, columns]`, or `'auto'` to read rows from the layout */
|
|
17
|
+
grid?: [number, number] | 'auto';
|
|
18
|
+
axis?: 'x' | 'y';
|
|
19
|
+
ease?: string;
|
|
20
|
+
}
|
|
21
|
+
/** Whether a stagger needs explicit offsets rather than the engine's 1D forms. */
|
|
22
|
+
export declare function needsExplicitOffsets(stagger: unknown): boolean;
|
|
23
|
+
/**
|
|
24
|
+
* Offsets in seconds for `count` targets. `columnsFromLayout` answers `grid: 'auto'`
|
|
25
|
+
* (how many targets share the first row); `random` draws for `from: 'random'`.
|
|
26
|
+
*/
|
|
27
|
+
export declare function gridOffsets(count: number, stagger: GridStagger, options?: {
|
|
28
|
+
columnsFromLayout?: () => number;
|
|
29
|
+
random?: () => number;
|
|
30
|
+
}): number[];
|
|
@@ -0,0 +1,39 @@
|
|
|
1
|
+
import type { TextChars, TextConfig } from '../../engine';
|
|
2
|
+
/**
|
|
3
|
+
* GSAP's TextPlugin (`text`) and ScrambleTextPlugin (`scrambleText`) tween
|
|
4
|
+
* options, desugared to a text track.
|
|
5
|
+
*
|
|
6
|
+
* tl.to('title', { text: 'Hello', duration: 1 })
|
|
7
|
+
* tl.to('title', { scrambleText: { text: 'Hello', chars: 'numbers' }, duration: 1.5 })
|
|
8
|
+
*
|
|
9
|
+
* The starting text is the one this timeline last set, or empty; `live` reads
|
|
10
|
+
* the element's current text instead. Scramble characters are seeded from the
|
|
11
|
+
* target and text, so the same script always scrambles the same way.
|
|
12
|
+
*/
|
|
13
|
+
export interface TypeTextVars {
|
|
14
|
+
value: string;
|
|
15
|
+
rightToLeft?: boolean;
|
|
16
|
+
}
|
|
17
|
+
export interface ScrambleTextVars {
|
|
18
|
+
text: string;
|
|
19
|
+
/** `upperCase` (default), `lowerCase`, `upperAndLowerCase`, `numbers`, or your own characters */
|
|
20
|
+
chars?: TextChars;
|
|
21
|
+
/** Seconds before characters start to settle */
|
|
22
|
+
revealDelay?: number;
|
|
23
|
+
/** How fast random characters change: 1 is the default 20 per second */
|
|
24
|
+
speed?: number;
|
|
25
|
+
/** Grow or shrink the length over the tween (default true) */
|
|
26
|
+
tweenLength?: boolean;
|
|
27
|
+
rightToLeft?: boolean;
|
|
28
|
+
/** Fix the random sequence; by default it is derived from the target and text */
|
|
29
|
+
seed?: number;
|
|
30
|
+
}
|
|
31
|
+
export type TextValue = string | TypeTextVars;
|
|
32
|
+
export type ScrambleTextValue = string | ScrambleTextVars;
|
|
33
|
+
/** Everything but the start text, which the timeline resolves. */
|
|
34
|
+
export type TextConfigWithoutFrom = Omit<TextConfig, 'from'>;
|
|
35
|
+
/**
|
|
36
|
+
* The text config a `text` or `scrambleText` value describes, or undefined if
|
|
37
|
+
* neither is set. `durationMs` converts `revealDelay` seconds into a fraction.
|
|
38
|
+
*/
|
|
39
|
+
export declare function compileTextVars(properties: Record<string, unknown>, target: string, durationMs: number): TextConfigWithoutFrom | undefined;
|
|
@@ -0,0 +1,161 @@
|
|
|
1
|
+
import { Timeline, type AnimatableValue, type TimelineDefinition } from '../../engine';
|
|
2
|
+
import { type Position } from './position';
|
|
3
|
+
import { type TweenVars } from './vars';
|
|
4
|
+
/**
|
|
5
|
+
* A GSAP-flavoured facade over the tinyfly engine.
|
|
6
|
+
*
|
|
7
|
+
* This is a *desugarer*, not a compatibility layer. Every call compiles down to
|
|
8
|
+
* ordinary `Track` data and is handed to a normal `Timeline`, so anything
|
|
9
|
+
* authored here opens in the editor and round-trips as JSON. Nothing new enters
|
|
10
|
+
* the engine.
|
|
11
|
+
*
|
|
12
|
+
* What it deliberately does not do: plugins, `gsap.utils`, runtime function
|
|
13
|
+
* values, live DOM reads for implicit start values, or tween-level overwrite.
|
|
14
|
+
* See docs/gsap-compat.md.
|
|
15
|
+
*/
|
|
16
|
+
export interface CompatTimelineOptions {
|
|
17
|
+
/** Id for the underlying engine timeline */
|
|
18
|
+
id?: string;
|
|
19
|
+
name?: string;
|
|
20
|
+
/** Repeat count; -1 for infinite (GSAP's `repeat`) */
|
|
21
|
+
repeat?: number;
|
|
22
|
+
/** Alternate direction each repeat (GSAP's `yoyo`) */
|
|
23
|
+
yoyo?: boolean;
|
|
24
|
+
/** Seconds to wait between repeats */
|
|
25
|
+
repeatDelay?: number;
|
|
26
|
+
/** Playback rate */
|
|
27
|
+
timeScale?: number;
|
|
28
|
+
/**
|
|
29
|
+
* Starting values for properties that have no earlier keyframe — step 3 of
|
|
30
|
+
* the resolution chain in `defaults.ts`.
|
|
31
|
+
*/
|
|
32
|
+
defaults?: Record<string, number>;
|
|
33
|
+
/**
|
|
34
|
+
* Look up a start value for a target+property this timeline has not authored
|
|
35
|
+
* yet — consulted between step 2 and step 3 of the resolution chain. The live
|
|
36
|
+
* runtime uses it to start a new tween from the value an earlier tween left
|
|
37
|
+
* on the element. It is called once, at build time; the resolved number is
|
|
38
|
+
* what lands in the JSON.
|
|
39
|
+
*/
|
|
40
|
+
startValue?: (target: string, property: string) => AnimatableValue | undefined;
|
|
41
|
+
/**
|
|
42
|
+
* The velocity (units per second) a property is already moving at, for a
|
|
43
|
+
* `spring` tween that does not give one — so interrupting a motion carries its
|
|
44
|
+
* momentum. Called once, at build time.
|
|
45
|
+
*/
|
|
46
|
+
startVelocity?: (target: string, property: string) => number | undefined;
|
|
47
|
+
/**
|
|
48
|
+
* Sample elastic, bounce, back and steps eases into intermediate keyframes
|
|
49
|
+
* instead of keeping them as parametric eases — for players that predate
|
|
50
|
+
* parametric eases. Off by default: the parametric form is exact and small.
|
|
51
|
+
*/
|
|
52
|
+
bakeEases?: boolean;
|
|
53
|
+
/** Interval between baked keyframes, in milliseconds (default: one 60fps frame) */
|
|
54
|
+
bakeIntervalMs?: number;
|
|
55
|
+
/** Called when a start value falls through to a static default */
|
|
56
|
+
onWarning?: (message: string) => void;
|
|
57
|
+
/** For `stagger: { grid: 'auto' }`: how many of these targets share the first row */
|
|
58
|
+
layoutColumns?: (targets: string[]) => number;
|
|
59
|
+
/** Random draws for `stagger: { from: 'random' }` (default: seeded from 1) */
|
|
60
|
+
random?: () => number;
|
|
61
|
+
}
|
|
62
|
+
/** Handle for one compiled tween — the nearest thing we have to a GSAP Tween. */
|
|
63
|
+
export interface TweenHandle {
|
|
64
|
+
/** Ids of the tracks this tween produced */
|
|
65
|
+
trackIds: string[];
|
|
66
|
+
/** Start time in milliseconds */
|
|
67
|
+
start: number;
|
|
68
|
+
/** End time in milliseconds */
|
|
69
|
+
end: number;
|
|
70
|
+
/** Remove this tween's tracks from the timeline */
|
|
71
|
+
kill(): void;
|
|
72
|
+
}
|
|
73
|
+
export declare class CompatTimeline {
|
|
74
|
+
/** The engine timeline. Use it for anything the facade does not cover. */
|
|
75
|
+
readonly timeline: Timeline;
|
|
76
|
+
private options;
|
|
77
|
+
private cursor;
|
|
78
|
+
private readonly fallbackRandom;
|
|
79
|
+
private previousStart;
|
|
80
|
+
private previousEnd;
|
|
81
|
+
private labels;
|
|
82
|
+
private trackCounter;
|
|
83
|
+
/** Last authored value per "target|property", for the resolution chain. */
|
|
84
|
+
private lastValues;
|
|
85
|
+
constructor(options?: CompatTimelineOptions);
|
|
86
|
+
/** Animate to the given values. */
|
|
87
|
+
to(target: string | string[], vars: TweenVars, position?: Position): TweenHandle;
|
|
88
|
+
/** Animate from the given values to where the property already is. */
|
|
89
|
+
from(target: string | string[], vars: TweenVars, position?: Position): TweenHandle;
|
|
90
|
+
/** Animate between two explicit sets of values. */
|
|
91
|
+
fromTo(target: string | string[], fromVars: TweenVars, toVars: TweenVars, position?: Position): TweenHandle;
|
|
92
|
+
/** Set values instantly — a single held keyframe. */
|
|
93
|
+
set(target: string | string[], vars: TweenVars, position?: Position): TweenHandle;
|
|
94
|
+
/** Start of the tween (after its delay) or call added last, in milliseconds. */
|
|
95
|
+
get lastStart(): number;
|
|
96
|
+
/** End of the tween or call added last, in milliseconds. */
|
|
97
|
+
get lastEnd(): number;
|
|
98
|
+
/**
|
|
99
|
+
* Place a zero-length event (a callback or a pause) at a position, as a tween of
|
|
100
|
+
* no duration would be: `'<'` and `'>'` after it refer to it. Returns its time in ms.
|
|
101
|
+
*/
|
|
102
|
+
addEvent(position?: Position): number;
|
|
103
|
+
/** Resolve a position (seconds, label, relative) to milliseconds without adding anything. */
|
|
104
|
+
timeOf(position: Position): number;
|
|
105
|
+
/** Name a point in time, for use as a position parameter. */
|
|
106
|
+
addLabel(name: string, position?: Position): this;
|
|
107
|
+
/** Time of a label, in milliseconds. */
|
|
108
|
+
/** Every label's time in milliseconds, in time order. */
|
|
109
|
+
labelTimes(): number[];
|
|
110
|
+
labelTime(name: string): number | undefined;
|
|
111
|
+
/**
|
|
112
|
+
* Merge another compat timeline in at a position.
|
|
113
|
+
*
|
|
114
|
+
* Nested timelines are flattened at compile time — every keyframe is offset
|
|
115
|
+
* and copied in — so there is no nested-timeline runtime and the output is
|
|
116
|
+
* one flat, serializable track list.
|
|
117
|
+
*/
|
|
118
|
+
add(child: CompatTimeline, position?: Position): this;
|
|
119
|
+
play(): this;
|
|
120
|
+
pause(): this;
|
|
121
|
+
restart(): this;
|
|
122
|
+
reverse(): this;
|
|
123
|
+
kill(): this;
|
|
124
|
+
/**
|
|
125
|
+
* Remove every tween and forget the cursor, labels and chained start values,
|
|
126
|
+
* so the same calls can build it again from scratch (`invalidate` in `live`).
|
|
127
|
+
*/
|
|
128
|
+
reset(): this;
|
|
129
|
+
/** Seek to a time in seconds, or to a label. */
|
|
130
|
+
seek(position: number | string): this;
|
|
131
|
+
/** Progress through the timeline, 0..1. */
|
|
132
|
+
progress(value?: number): number;
|
|
133
|
+
/** Playback rate. */
|
|
134
|
+
timeScale(value?: number): number;
|
|
135
|
+
/** Total duration in seconds (GSAP's unit). */
|
|
136
|
+
duration(): number;
|
|
137
|
+
/** Advance by `deltaMs` — the host still owns the animation loop. */
|
|
138
|
+
tick(deltaMs: number): this;
|
|
139
|
+
/** The compiled animation, as plain JSON. */
|
|
140
|
+
toDefinition(): TimelineDefinition;
|
|
141
|
+
/**
|
|
142
|
+
* Compile one tween into tracks.
|
|
143
|
+
*
|
|
144
|
+
* `fromProperties` holds explicit start values (fromTo / from); when absent,
|
|
145
|
+
* each property's start comes from the resolution chain.
|
|
146
|
+
*/
|
|
147
|
+
private build;
|
|
148
|
+
/**
|
|
149
|
+
* Two keyframes, or a baked sequence when the ease has no closed form.
|
|
150
|
+
*/
|
|
151
|
+
private keyframesFor;
|
|
152
|
+
/** Resolve a start value through the documented chain. */
|
|
153
|
+
private resolveStart;
|
|
154
|
+
private easingFor;
|
|
155
|
+
private targetsOf;
|
|
156
|
+
private context;
|
|
157
|
+
private nextTrackId;
|
|
158
|
+
private warn;
|
|
159
|
+
}
|
|
160
|
+
/** Create a GSAP-flavoured timeline. */
|
|
161
|
+
export declare function timeline(options?: CompatTimelineOptions): CompatTimeline;
|
|
@@ -0,0 +1,60 @@
|
|
|
1
|
+
import { type AnimatableValue, type StaggerFrom } from '../../engine';
|
|
2
|
+
/**
|
|
3
|
+
* `live.utils` — GSAP's utility functions, as pure functions.
|
|
4
|
+
*
|
|
5
|
+
* Like GSAP, most of them return a reusable function when the last argument is
|
|
6
|
+
* left out: `const toPercent = utils.mapRange(0, 800, 0, 100)`.
|
|
7
|
+
*
|
|
8
|
+
* **Randomness is seeded.** `random`, `shuffle` and `"random(…)"` strings draw from
|
|
9
|
+
* one sequence that starts from `seed` (default 1), so a page builds the same
|
|
10
|
+
* "random" layout every time it loads and a replay is identical — the engine's
|
|
11
|
+
* determinism rule. Call `utils.seed(Date.now())` if you do want it to differ.
|
|
12
|
+
*/
|
|
13
|
+
export type Snap = number | number[] | {
|
|
14
|
+
values: number[];
|
|
15
|
+
radius?: number;
|
|
16
|
+
} | {
|
|
17
|
+
increment: number;
|
|
18
|
+
radius?: number;
|
|
19
|
+
};
|
|
20
|
+
/** A small, fast seeded generator (mulberry32). */
|
|
21
|
+
export declare function seededRandom(seed: number): () => number;
|
|
22
|
+
export declare function isRandomString(value: unknown): value is string;
|
|
23
|
+
export interface LiveUtils {
|
|
24
|
+
clamp(min: number, max: number): (value: number) => number;
|
|
25
|
+
clamp(min: number, max: number, value: number): number;
|
|
26
|
+
mapRange(inMin: number, inMax: number, outMin: number, outMax: number): (value: number) => number;
|
|
27
|
+
mapRange(inMin: number, inMax: number, outMin: number, outMax: number, value: number): number;
|
|
28
|
+
normalize(min: number, max: number): (value: number) => number;
|
|
29
|
+
normalize(min: number, max: number, value: number): number;
|
|
30
|
+
interpolate<T extends AnimatableValue | Record<string, AnimatableValue>>(start: T, end: T): (progress: number) => T;
|
|
31
|
+
interpolate<T extends AnimatableValue | Record<string, AnimatableValue>>(start: T, end: T, progress: number): T;
|
|
32
|
+
wrap(min: number, max: number): (value: number) => number;
|
|
33
|
+
wrap(min: number, max: number, value: number): number;
|
|
34
|
+
wrap<T>(values: T[]): (index: number) => T;
|
|
35
|
+
wrap<T>(values: T[], index: number): T;
|
|
36
|
+
wrapYoyo(min: number, max: number): (value: number) => number;
|
|
37
|
+
wrapYoyo(min: number, max: number, value: number): number;
|
|
38
|
+
snap(snap: Snap): (value: number) => number;
|
|
39
|
+
snap(snap: Snap, value: number): number;
|
|
40
|
+
random(min: number, max: number, snapIncrement?: number): number;
|
|
41
|
+
random(min: number, max: number, snapIncrement: number | undefined, returnFunction: true): () => number;
|
|
42
|
+
random<T>(values: T[]): T;
|
|
43
|
+
random<T>(values: T[], returnFunction: true): () => T;
|
|
44
|
+
shuffle<T>(values: T[]): T[];
|
|
45
|
+
distribute(config: {
|
|
46
|
+
base?: number;
|
|
47
|
+
amount?: number;
|
|
48
|
+
each?: number;
|
|
49
|
+
from?: StaggerFrom;
|
|
50
|
+
ease?: (t: number) => number;
|
|
51
|
+
}): (index: number, target: unknown, targets: ArrayLike<unknown>) => number;
|
|
52
|
+
pipe<T>(...functions: Array<(value: T) => T>): (value: T) => T;
|
|
53
|
+
splitColor(color: string): [number, number, number] | [number, number, number, number];
|
|
54
|
+
getUnit(value: string | number): string;
|
|
55
|
+
/** Start the random sequence again from `value` */
|
|
56
|
+
seed(value: number): void;
|
|
57
|
+
/** Resolve a `"random(…)"` string to a value (used by tween vars) */
|
|
58
|
+
resolveRandomString(value: string): unknown;
|
|
59
|
+
}
|
|
60
|
+
export declare function createUtils(initialSeed?: number): LiveUtils;
|
|
@@ -0,0 +1,79 @@
|
|
|
1
|
+
import type { EasingType } from '../../engine';
|
|
2
|
+
import type { StaggerConfig, StaggerFrom } from '../../engine';
|
|
3
|
+
import type { Position } from './position';
|
|
4
|
+
import type { ScrollTriggerVars } from './live-scroll';
|
|
5
|
+
import type { SpringVars } from './spring-vars';
|
|
6
|
+
/**
|
|
7
|
+
* Splitting a GSAP `vars` object into scheduling and animated properties.
|
|
8
|
+
*
|
|
9
|
+
* Everything GSAP recognises as configuration is reserved; everything else is
|
|
10
|
+
* treated as a property to animate. That is how GSAP behaves, and it is why
|
|
11
|
+
* a typo like `opactiy` silently animates nothing rather than erroring.
|
|
12
|
+
*/
|
|
13
|
+
/** Keys that configure the tween rather than naming a property to animate. */
|
|
14
|
+
export declare const RESERVED_KEYS: Set<string>;
|
|
15
|
+
export interface TweenVars {
|
|
16
|
+
/** Seconds (GSAP's unit), converted to milliseconds by the facade */
|
|
17
|
+
duration?: number;
|
|
18
|
+
delay?: number;
|
|
19
|
+
ease?: string | EasingType | ((t: number) => number);
|
|
20
|
+
repeat?: number;
|
|
21
|
+
repeatDelay?: number;
|
|
22
|
+
yoyo?: boolean;
|
|
23
|
+
stagger?: number | GsapStagger;
|
|
24
|
+
onComplete?: () => void;
|
|
25
|
+
onUpdate?: () => void;
|
|
26
|
+
onStart?: () => void;
|
|
27
|
+
/** Each time a repeat begins */
|
|
28
|
+
onRepeat?: () => void;
|
|
29
|
+
/** On arriving back at the start after `reverse()` */
|
|
30
|
+
onReverseComplete?: () => void;
|
|
31
|
+
/** Rebuild on every repeat, so function and `"random(…)"` values are drawn again each loop */
|
|
32
|
+
repeatRefresh?: boolean;
|
|
33
|
+
/** Consecutive segments: an array of tweens, percentages of `duration`, or value arrays (live) */
|
|
34
|
+
keyframes?: unknown;
|
|
35
|
+
/** The ease of each segment in percentage / value-array keyframes (default 'power1.inOut') */
|
|
36
|
+
easeEach?: string;
|
|
37
|
+
id?: string;
|
|
38
|
+
paused?: boolean;
|
|
39
|
+
/** Animate numeric properties with spring physics instead of duration + ease — see spring-vars.ts */
|
|
40
|
+
spring?: SpringVars;
|
|
41
|
+
/** Tie the tween to scrolling (live only) — see live-scroll.ts */
|
|
42
|
+
scrollTrigger?: ScrollTriggerVars;
|
|
43
|
+
/** Any other key is a property to animate */
|
|
44
|
+
[property: string]: unknown;
|
|
45
|
+
}
|
|
46
|
+
/** GSAP's stagger object, in seconds. */
|
|
47
|
+
export interface GsapStagger {
|
|
48
|
+
each?: number;
|
|
49
|
+
amount?: number;
|
|
50
|
+
/** Where the ripple starts; `'random'` and `[x, y]` ratios too, with explicit offsets */
|
|
51
|
+
from?: StaggerFrom | 'random' | [number, number];
|
|
52
|
+
/** `[rows, columns]`, or `'auto'` to read rows from the layout (live) */
|
|
53
|
+
grid?: [number, number] | 'auto';
|
|
54
|
+
/** Measure distance along one axis only */
|
|
55
|
+
axis?: 'x' | 'y';
|
|
56
|
+
/** Distribute the offsets through an ease */
|
|
57
|
+
ease?: string;
|
|
58
|
+
}
|
|
59
|
+
export interface SplitVars {
|
|
60
|
+
/** Scheduling and lifecycle options */
|
|
61
|
+
config: TweenVars;
|
|
62
|
+
/** Property name → target value */
|
|
63
|
+
properties: Record<string, unknown>;
|
|
64
|
+
}
|
|
65
|
+
/** Split a vars object into its configuration and its animated properties. */
|
|
66
|
+
export declare function splitVars(vars: TweenVars): SplitVars;
|
|
67
|
+
/** Convert GSAP's seconds to the engine's milliseconds. */
|
|
68
|
+
export declare function toMs(seconds: number | undefined, fallback: number): number;
|
|
69
|
+
/** What an advanced stagger (grid, random, eased) needs to be worked out. */
|
|
70
|
+
export interface StaggerContext {
|
|
71
|
+
count: number;
|
|
72
|
+
/** How many targets share the first row, for `grid: 'auto'` */
|
|
73
|
+
columnsFromLayout?: () => number;
|
|
74
|
+
random?: () => number;
|
|
75
|
+
}
|
|
76
|
+
/** Convert a GSAP stagger (seconds) to the engine's StaggerConfig (ms). */
|
|
77
|
+
export declare function toStaggerConfig(stagger: number | GsapStagger | undefined, context?: StaggerContext): StaggerConfig | undefined;
|
|
78
|
+
/** Re-exported so callers only import from one place. */
|
|
79
|
+
export type { Position };
|
|
@@ -0,0 +1,8 @@
|
|
|
1
|
+
export * from './types';
|
|
2
|
+
export * from './scroll-math';
|
|
3
|
+
export * from './visibility-driver';
|
|
4
|
+
export * from './scroll-driver';
|
|
5
|
+
export * from './scroll-pin';
|
|
6
|
+
export * from './scroll-snap';
|
|
7
|
+
export * from './scroll-markers';
|
|
8
|
+
export * from './smooth-scroll';
|