@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,225 @@
|
|
|
1
|
+
class c {
|
|
2
|
+
options;
|
|
3
|
+
target;
|
|
4
|
+
running = !1;
|
|
5
|
+
dragging = !1;
|
|
6
|
+
passedTolerance = !1;
|
|
7
|
+
lastX = 0;
|
|
8
|
+
lastY = 0;
|
|
9
|
+
startX = 0;
|
|
10
|
+
startY = 0;
|
|
11
|
+
velocityX = 0;
|
|
12
|
+
velocityY = 0;
|
|
13
|
+
lastTime = 0;
|
|
14
|
+
constructor(t) {
|
|
15
|
+
this.options = t, this.target = t.target;
|
|
16
|
+
}
|
|
17
|
+
start() {
|
|
18
|
+
if (this.running) return;
|
|
19
|
+
this.running = !0;
|
|
20
|
+
const t = this.options.type ?? ["pointer", "touch"];
|
|
21
|
+
t.includes("pointer") && (this.target.addEventListener("pointerdown", this.onPointerDown), this.target.addEventListener("pointermove", this.onPointerMove), this.target.addEventListener("pointerup", this.onPointerUp), this.target.addEventListener("pointercancel", this.onPointerUp)), t.includes("touch") && (this.target.addEventListener("touchstart", this.onTouchStart, { passive: !1 }), this.target.addEventListener("touchmove", this.onTouchMove, { passive: !1 }), this.target.addEventListener("touchend", this.onTouchEnd)), t.includes("wheel") && this.target.addEventListener("wheel", this.onWheel, { passive: !1 });
|
|
22
|
+
}
|
|
23
|
+
stop() {
|
|
24
|
+
this.running && (this.running = !1, this.target.removeEventListener("pointerdown", this.onPointerDown), this.target.removeEventListener("pointermove", this.onPointerMove), this.target.removeEventListener("pointerup", this.onPointerUp), this.target.removeEventListener("pointercancel", this.onPointerUp), this.target.removeEventListener("touchstart", this.onTouchStart), this.target.removeEventListener("touchmove", this.onTouchMove), this.target.removeEventListener("touchend", this.onTouchEnd), this.target.removeEventListener("wheel", this.onWheel));
|
|
25
|
+
}
|
|
26
|
+
destroy() {
|
|
27
|
+
this.stop();
|
|
28
|
+
}
|
|
29
|
+
/** Current velocity, in pixels per second. Read it on release for inertia. */
|
|
30
|
+
get velocity() {
|
|
31
|
+
return { x: this.velocityX, y: this.velocityY };
|
|
32
|
+
}
|
|
33
|
+
// --- gesture lifecycle --------------------------------------------------
|
|
34
|
+
begin(t, e, s) {
|
|
35
|
+
this.dragging = !0, this.passedTolerance = !1, this.startX = t, this.startY = e, this.lastX = t, this.lastY = e, this.velocityX = 0, this.velocityY = 0, this.lastTime = l(), this.options.onPress?.(this.stateFrom(0, 0, s));
|
|
36
|
+
}
|
|
37
|
+
move(t, e, s) {
|
|
38
|
+
if (!this.dragging) return;
|
|
39
|
+
const o = t - this.lastX, i = e - this.lastY;
|
|
40
|
+
this.lastX = t, this.lastY = e;
|
|
41
|
+
const n = t - this.startX, a = e - this.startY, h = this.options.tolerance ?? 3;
|
|
42
|
+
if (!this.passedTolerance) {
|
|
43
|
+
if (Math.hypot(n, a) < h) return;
|
|
44
|
+
this.passedTolerance = !0;
|
|
45
|
+
}
|
|
46
|
+
this.updateVelocity(o, i), this.options.preventDefault !== !1 && s.cancelable && s.preventDefault(), this.options.onMove?.(this.stateFrom(o, i, s));
|
|
47
|
+
}
|
|
48
|
+
end(t) {
|
|
49
|
+
this.dragging && (this.dragging = !1, this.options.onRelease?.(this.stateFrom(0, 0, t)));
|
|
50
|
+
}
|
|
51
|
+
updateVelocity(t, e) {
|
|
52
|
+
const s = l(), o = Math.max(1, s - this.lastTime);
|
|
53
|
+
this.lastTime = s;
|
|
54
|
+
const i = t / o * 1e3, n = e / o * 1e3;
|
|
55
|
+
this.velocityX += (i - this.velocityX) * 0.3, this.velocityY += (n - this.velocityY) * 0.3;
|
|
56
|
+
}
|
|
57
|
+
stateFrom(t, e, s) {
|
|
58
|
+
return {
|
|
59
|
+
deltaX: t,
|
|
60
|
+
deltaY: e,
|
|
61
|
+
velocityX: this.velocityX,
|
|
62
|
+
velocityY: this.velocityY,
|
|
63
|
+
totalX: this.lastX - this.startX,
|
|
64
|
+
totalY: this.lastY - this.startY,
|
|
65
|
+
isDragging: this.dragging,
|
|
66
|
+
event: s
|
|
67
|
+
};
|
|
68
|
+
}
|
|
69
|
+
// --- listeners ----------------------------------------------------------
|
|
70
|
+
onPointerDown = (t) => {
|
|
71
|
+
const e = t, s = this.target;
|
|
72
|
+
if (typeof e.pointerId == "number" && typeof s.setPointerCapture == "function")
|
|
73
|
+
try {
|
|
74
|
+
s.setPointerCapture(e.pointerId);
|
|
75
|
+
} catch {
|
|
76
|
+
}
|
|
77
|
+
this.begin(e.clientX, e.clientY, t);
|
|
78
|
+
};
|
|
79
|
+
onPointerMove = (t) => {
|
|
80
|
+
const e = t;
|
|
81
|
+
this.move(e.clientX, e.clientY, t);
|
|
82
|
+
};
|
|
83
|
+
onPointerUp = (t) => this.end(t);
|
|
84
|
+
onTouchStart = (t) => {
|
|
85
|
+
const e = t.touches[0];
|
|
86
|
+
e && this.begin(e.clientX, e.clientY, t);
|
|
87
|
+
};
|
|
88
|
+
onTouchMove = (t) => {
|
|
89
|
+
const e = t.touches[0];
|
|
90
|
+
e && this.move(e.clientX, e.clientY, t);
|
|
91
|
+
};
|
|
92
|
+
onTouchEnd = (t) => this.end(t);
|
|
93
|
+
onWheel = (t) => {
|
|
94
|
+
const e = t;
|
|
95
|
+
this.options.preventDefault !== !1 && e.cancelable && e.preventDefault(), this.updateVelocity(e.deltaX, e.deltaY), this.options.onMove?.({
|
|
96
|
+
deltaX: e.deltaX,
|
|
97
|
+
deltaY: e.deltaY,
|
|
98
|
+
velocityX: this.velocityX,
|
|
99
|
+
velocityY: this.velocityY,
|
|
100
|
+
totalX: 0,
|
|
101
|
+
totalY: 0,
|
|
102
|
+
isDragging: !1,
|
|
103
|
+
event: t
|
|
104
|
+
});
|
|
105
|
+
};
|
|
106
|
+
}
|
|
107
|
+
function l() {
|
|
108
|
+
return typeof performance < "u" ? performance.now() : Date.now();
|
|
109
|
+
}
|
|
110
|
+
function p(r, t, e) {
|
|
111
|
+
let s = { delta: 0, line: null }, o = e;
|
|
112
|
+
for (const i of r)
|
|
113
|
+
for (const n of t) {
|
|
114
|
+
const a = Math.abs(n - i);
|
|
115
|
+
a <= o && (o = a, s = { delta: n - i, line: n });
|
|
116
|
+
}
|
|
117
|
+
return s;
|
|
118
|
+
}
|
|
119
|
+
function u(r, t) {
|
|
120
|
+
return t <= 0 ? [] : r.map((e) => Math.round(e / t) * t);
|
|
121
|
+
}
|
|
122
|
+
class d {
|
|
123
|
+
options;
|
|
124
|
+
observer;
|
|
125
|
+
x;
|
|
126
|
+
y;
|
|
127
|
+
/** Position when the current gesture began */
|
|
128
|
+
originX = 0;
|
|
129
|
+
originY = 0;
|
|
130
|
+
/** Lines that caught on the last constraint pass, for guide drawing */
|
|
131
|
+
snappedX = null;
|
|
132
|
+
snappedY = null;
|
|
133
|
+
constructor(t) {
|
|
134
|
+
this.options = t, this.x = t.initialX ?? 0, this.y = t.initialY ?? 0, this.observer = new c({
|
|
135
|
+
target: t.target,
|
|
136
|
+
onPress: (e) => {
|
|
137
|
+
const s = t.getPosition?.();
|
|
138
|
+
s && (this.x = s.x, this.y = s.y), this.originX = this.x, this.originY = this.y, t.onPress?.(e);
|
|
139
|
+
},
|
|
140
|
+
onMove: (e) => this.handleMove(e),
|
|
141
|
+
onRelease: (e) => t.onRelease?.(e)
|
|
142
|
+
});
|
|
143
|
+
}
|
|
144
|
+
start() {
|
|
145
|
+
this.observer.start();
|
|
146
|
+
}
|
|
147
|
+
stop() {
|
|
148
|
+
this.observer.stop();
|
|
149
|
+
}
|
|
150
|
+
destroy() {
|
|
151
|
+
this.observer.destroy();
|
|
152
|
+
}
|
|
153
|
+
/** Current dragged position. */
|
|
154
|
+
get position() {
|
|
155
|
+
return { x: this.x, y: this.y };
|
|
156
|
+
}
|
|
157
|
+
/** Velocity at the last movement, in pixels per second. */
|
|
158
|
+
get velocity() {
|
|
159
|
+
return this.observer.velocity;
|
|
160
|
+
}
|
|
161
|
+
/** Move the target programmatically, applying bounds and snapping. */
|
|
162
|
+
setPosition(t, e) {
|
|
163
|
+
const s = this.options.axis ?? "both";
|
|
164
|
+
this.x = s === "y" ? this.x : this.applyConstraints(t, "x"), this.y = s === "x" ? this.y : this.applyConstraints(e, "y");
|
|
165
|
+
}
|
|
166
|
+
/** The snap lines that caught on the last move, for drawing guides. */
|
|
167
|
+
get snapLines() {
|
|
168
|
+
return { x: this.snappedX, y: this.snappedY };
|
|
169
|
+
}
|
|
170
|
+
/** See `snapThreshold` in the options. */
|
|
171
|
+
snapThreshold() {
|
|
172
|
+
if (this.options.snapThreshold !== void 0) return this.options.snapThreshold;
|
|
173
|
+
const t = this.options.snap ?? 0;
|
|
174
|
+
return t > 0 ? t / 2 : 8;
|
|
175
|
+
}
|
|
176
|
+
handleMove(t) {
|
|
177
|
+
this.setPosition(this.originX + t.totalX, this.originY + t.totalY), this.options.mode === "scrub" && this.scrub(), this.options.onDrag?.(this.position, t), this.options.onSnap?.(this.snapLines);
|
|
178
|
+
}
|
|
179
|
+
/** Map the dragged distance onto the timeline's playhead. */
|
|
180
|
+
scrub() {
|
|
181
|
+
const t = this.options.timeline;
|
|
182
|
+
if (!t) return;
|
|
183
|
+
const e = t.duration;
|
|
184
|
+
if (e <= 0) return;
|
|
185
|
+
const s = this.options.scrubDistance ?? 500;
|
|
186
|
+
if (s === 0) return;
|
|
187
|
+
const o = (this.options.axis ?? "both") === "y" ? this.y : this.x, i = v(o / s);
|
|
188
|
+
t.pause(), t.seek(i * e);
|
|
189
|
+
}
|
|
190
|
+
/**
|
|
191
|
+
* Apply snapping, then bounds. Snapping uses the shared `snapAxis` helper —
|
|
192
|
+
* the same one the editor stage snaps with — rather than a private rounding
|
|
193
|
+
* rule, so grid and edge snapping behave identically in both places.
|
|
194
|
+
*
|
|
195
|
+
* Bounds are applied last so a snap can never push the target out of range.
|
|
196
|
+
*/
|
|
197
|
+
applyConstraints(t, e) {
|
|
198
|
+
let s = t;
|
|
199
|
+
const o = [
|
|
200
|
+
...u([s], this.options.snap ?? 0),
|
|
201
|
+
...(e === "x" ? this.options.snapLinesX : this.options.snapLinesY) ?? []
|
|
202
|
+
], i = p([s], o, this.snapThreshold());
|
|
203
|
+
s += i.delta, e === "x" ? this.snappedX = i.line : this.snappedY = i.line;
|
|
204
|
+
const n = this.options.bounds;
|
|
205
|
+
if (n) {
|
|
206
|
+
const a = e === "x" ? n.minX : n.minY, h = e === "x" ? n.maxX : n.maxY;
|
|
207
|
+
a !== void 0 && (s = Math.max(a, s)), h !== void 0 && (s = Math.min(h, s));
|
|
208
|
+
}
|
|
209
|
+
return s;
|
|
210
|
+
}
|
|
211
|
+
}
|
|
212
|
+
function v(r) {
|
|
213
|
+
return r < 0 ? 0 : r > 1 ? 1 : r;
|
|
214
|
+
}
|
|
215
|
+
function g(r) {
|
|
216
|
+
const t = new d(r);
|
|
217
|
+
return t.start(), t;
|
|
218
|
+
}
|
|
219
|
+
export {
|
|
220
|
+
d as Draggable,
|
|
221
|
+
c as Observer,
|
|
222
|
+
g as draggable,
|
|
223
|
+
u as gridLinesFor,
|
|
224
|
+
p as snapAxis
|
|
225
|
+
};
|