@algorisys/tinyfly 0.74.1 → 0.75.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/README.md +9 -6
- package/lib/addons/adapters.js +236 -121
- package/lib/addons/characters.js +316 -144
- package/lib/addons/{dom-adapter-ChrbtkLC.js → dom-adapter-CrNwoomd.js} +52 -52
- package/lib/addons/gsap-compat.js +1 -1
- package/lib/addons/sketch-CB6VNfnR.js +128 -0
- package/lib/browser/tinyfly.iife.js +4 -4
- package/lib/browser/tinyfly.js +3110 -2819
- package/lib/browser/tinyfly.umd.js +4 -4
- package/lib/cli/tools.js +2 -0
- package/lib/embed/tinyfly-embed.iife.js +4 -4
- package/lib/embed/tinyfly-embed.js +70 -70
- package/lib/headless/headless.js +300 -1
- package/lib/player/tinyfly-player.es.js +73 -73
- package/lib/player/tinyfly-player.iife.js +2 -2
- package/lib/player/tinyfly-player.umd.js +2 -2
- package/lib/types/adapters/canvas/canvas-adapter.d.ts +18 -0
- package/lib/types/adapters/canvas/index.d.ts +3 -0
- package/lib/types/adapters/canvas/outline.d.ts +26 -0
- package/lib/types/adapters/canvas/polyline.d.ts +12 -0
- package/lib/types/adapters/canvas/sketch.d.ts +54 -0
- package/lib/types/characters/erase.d.ts +31 -0
- package/lib/types/characters/hand.d.ts +81 -0
- package/lib/types/characters/index.d.ts +7 -1
- package/lib/types/characters/polyline.d.ts +12 -0
- package/lib/types/characters/sketch.d.ts +54 -0
- package/lib/types/characters/stick-figure.d.ts +29 -4
- package/package.json +1 -1
|
@@ -7,25 +7,25 @@ const w = /* @__PURE__ */ new Set([
|
|
|
7
7
|
"shadowY",
|
|
8
8
|
"shadowBlur",
|
|
9
9
|
"shadowColor"
|
|
10
|
-
]), b = "#ffffff",
|
|
11
|
-
function
|
|
10
|
+
]), b = "#ffffff", R = "rgba(0, 0, 0, 0.5)";
|
|
11
|
+
function x(r) {
|
|
12
12
|
const t = [];
|
|
13
13
|
if (r.blur !== void 0 && t.push(`blur(${Math.max(0, r.blur)}px)`), r.brightness !== void 0 && t.push(`brightness(${Math.max(0, r.brightness)})`), r.glow !== void 0 && t.push(`drop-shadow(0 0 ${Math.max(0, r.glow)}px ${r.glowColor ?? b})`), r.shadowX !== void 0 || r.shadowY !== void 0 || r.shadowBlur !== void 0) {
|
|
14
|
-
const o = r.shadowX ?? 0,
|
|
15
|
-
t.push(`drop-shadow(${o}px ${
|
|
14
|
+
const o = r.shadowX ?? 0, e = r.shadowY ?? 0, a = Math.max(0, r.shadowBlur ?? 0);
|
|
15
|
+
t.push(`drop-shadow(${o}px ${e}px ${a}px ${r.shadowColor ?? R})`);
|
|
16
16
|
}
|
|
17
17
|
return t.length > 0 ? t.join(" ") : null;
|
|
18
18
|
}
|
|
19
|
-
function
|
|
19
|
+
function S(r, t) {
|
|
20
20
|
const o = r.childNodes.length === 1 ? r.firstChild : null;
|
|
21
21
|
if (o && o.nodeType === 3) {
|
|
22
|
-
const
|
|
23
|
-
|
|
22
|
+
const e = o;
|
|
23
|
+
e.data !== t && (e.data = t);
|
|
24
24
|
return;
|
|
25
25
|
}
|
|
26
26
|
r.textContent !== t && (r.textContent = t);
|
|
27
27
|
}
|
|
28
|
-
function
|
|
28
|
+
function $(r) {
|
|
29
29
|
if (!("ownerSVGElement" in r)) return;
|
|
30
30
|
const t = r.style;
|
|
31
31
|
!t || t.transformBox || (t.transformBox = "fill-box", t.transformOrigin || (t.transformOrigin = "50% 50%"));
|
|
@@ -56,7 +56,7 @@ const d = /* @__PURE__ */ new Set([
|
|
|
56
56
|
"gap",
|
|
57
57
|
"rowGap",
|
|
58
58
|
"columnGap"
|
|
59
|
-
]),
|
|
59
|
+
]), m = /* @__PURE__ */ new Set([
|
|
60
60
|
"x",
|
|
61
61
|
"y",
|
|
62
62
|
"z",
|
|
@@ -74,7 +74,7 @@ const d = /* @__PURE__ */ new Set([
|
|
|
74
74
|
"motionPathX",
|
|
75
75
|
"motionPathY",
|
|
76
76
|
"motionPathRotate"
|
|
77
|
-
]),
|
|
77
|
+
]), k = /* @__PURE__ */ new Set(["originX", "originY"]), O = /* @__PURE__ */ new Set(["clipTop", "clipRight", "clipBottom", "clipLeft"]), T = /* @__PURE__ */ new Set(["drawOn"]), C = {
|
|
78
78
|
fill: "backgroundColor",
|
|
79
79
|
stroke: "borderColor",
|
|
80
80
|
strokeWidth: "borderWidth",
|
|
@@ -89,8 +89,8 @@ const d = /* @__PURE__ */ new Set([
|
|
|
89
89
|
strokeDashoffset: "strokeDashoffset",
|
|
90
90
|
fillOpacity: "fillOpacity",
|
|
91
91
|
strokeOpacity: "strokeOpacity"
|
|
92
|
-
},
|
|
93
|
-
class
|
|
92
|
+
}, Y = "http://www.w3.org/2000/svg";
|
|
93
|
+
class E {
|
|
94
94
|
targets = /* @__PURE__ */ new Map();
|
|
95
95
|
/**
|
|
96
96
|
* Register an HTML element as an animation target.
|
|
@@ -120,53 +120,53 @@ class Y {
|
|
|
120
120
|
* Apply animation state to all registered targets.
|
|
121
121
|
*/
|
|
122
122
|
applyState(t) {
|
|
123
|
-
for (const [o,
|
|
123
|
+
for (const [o, e] of t.values) {
|
|
124
124
|
const a = this.targets.get(o);
|
|
125
|
-
a && this.applyProperties(a,
|
|
125
|
+
a && this.applyProperties(a, e);
|
|
126
126
|
}
|
|
127
127
|
}
|
|
128
128
|
/**
|
|
129
129
|
* Apply properties to a single element.
|
|
130
130
|
*/
|
|
131
131
|
applyProperties(t, o) {
|
|
132
|
-
const
|
|
133
|
-
let a = null,
|
|
132
|
+
const e = [];
|
|
133
|
+
let a = null, n = null, c = null;
|
|
134
134
|
const h = o.has("motionPathX"), y = o.has("motionPathY"), P = o.has("motionPathRotate");
|
|
135
|
-
for (const [
|
|
136
|
-
if (!(
|
|
137
|
-
if (
|
|
138
|
-
const l = this.buildTransformPart(
|
|
139
|
-
l &&
|
|
140
|
-
} else if (
|
|
141
|
-
typeof
|
|
142
|
-
else if (
|
|
143
|
-
typeof
|
|
144
|
-
else if (w.has(
|
|
145
|
-
(c ??= {})[
|
|
146
|
-
else if (
|
|
147
|
-
if (
|
|
148
|
-
|
|
149
|
-
else if (
|
|
135
|
+
for (const [s, i] of o)
|
|
136
|
+
if (!(s === "x" && h) && !(s === "y" && y) && !((s === "rotate" || s === "rotateZ") && P) && !T.has(s)) {
|
|
137
|
+
if (m.has(s)) {
|
|
138
|
+
const l = this.buildTransformPart(s, i);
|
|
139
|
+
l && e.push(l);
|
|
140
|
+
} else if (k.has(s))
|
|
141
|
+
typeof i == "number" && ((a ??= {})[s] = i);
|
|
142
|
+
else if (O.has(s))
|
|
143
|
+
typeof i == "number" && ((n ??= {})[s] = i);
|
|
144
|
+
else if (w.has(s))
|
|
145
|
+
(c ??= {})[s] = i;
|
|
146
|
+
else if (s !== "perspective") {
|
|
147
|
+
if (s !== "shine") if (s === "text" && typeof i == "string")
|
|
148
|
+
S(t, i);
|
|
149
|
+
else if (s === "d" && typeof i == "string") {
|
|
150
150
|
const l = t;
|
|
151
|
-
(l.tagName?.toLowerCase() === "path" ? l : l.querySelector?.("path"))?.setAttribute?.("d",
|
|
151
|
+
(l.tagName?.toLowerCase() === "path" ? l : l.querySelector?.("path"))?.setAttribute?.("d", i);
|
|
152
152
|
} else
|
|
153
|
-
this.applyStyleProperty(t,
|
|
153
|
+
this.applyStyleProperty(t, s, i);
|
|
154
154
|
}
|
|
155
155
|
}
|
|
156
156
|
const f = o.get("shine");
|
|
157
157
|
typeof f == "number" && this.applyShine(t, f);
|
|
158
158
|
const g = o.get("perspective");
|
|
159
|
-
if (typeof g == "number" &&
|
|
160
|
-
const
|
|
161
|
-
t.style.transformOrigin = `${
|
|
159
|
+
if (typeof g == "number" && e.unshift(`perspective(${g}px)`), e.length > 0 && (t.style.transform = e.join(" "), $(t)), a) {
|
|
160
|
+
const s = a.originX ?? 50, i = a.originY ?? 50;
|
|
161
|
+
t.style.transformOrigin = `${s}% ${i}%`;
|
|
162
162
|
}
|
|
163
|
-
if (
|
|
164
|
-
const
|
|
165
|
-
t.style.clipPath = `inset(${
|
|
163
|
+
if (n) {
|
|
164
|
+
const s = n.clipTop ?? 0, i = n.clipRight ?? 0, l = n.clipBottom ?? 0, p = n.clipLeft ?? 0;
|
|
165
|
+
t.style.clipPath = `inset(${s}% ${i}% ${l}% ${p}%)`;
|
|
166
166
|
}
|
|
167
167
|
if (c) {
|
|
168
|
-
const
|
|
169
|
-
|
|
168
|
+
const s = x(c);
|
|
169
|
+
s && (t.style.filter = s);
|
|
170
170
|
}
|
|
171
171
|
}
|
|
172
172
|
/**
|
|
@@ -217,27 +217,27 @@ class Y {
|
|
|
217
217
|
*/
|
|
218
218
|
applyShine(t, o) {
|
|
219
219
|
t.dataset.shineBase || (t.dataset.shineBase = t.style.color || "currentColor");
|
|
220
|
-
const
|
|
221
|
-
|
|
220
|
+
const e = t.dataset.shineBase, a = -20 + o * 140, n = t.style;
|
|
221
|
+
n.color = "transparent", n.backgroundImage = `linear-gradient(105deg, transparent 40%, rgba(255, 255, 255, 0.9) 50%, transparent 60%), linear-gradient(${e}, ${e})`, n.backgroundSize = "250% 100%, 100% 100%", n.backgroundPosition = `${a}% 0, 0 0`, n.backgroundRepeat = "no-repeat", n.webkitBackgroundClip = "text", n.backgroundClip = "text";
|
|
222
222
|
}
|
|
223
223
|
/**
|
|
224
224
|
* Apply a single style property to an element.
|
|
225
225
|
*/
|
|
226
|
-
applyStyleProperty(t, o,
|
|
226
|
+
applyStyleProperty(t, o, e) {
|
|
227
227
|
let a;
|
|
228
|
-
if (t.namespaceURI ===
|
|
229
|
-
const h = Array.isArray(
|
|
228
|
+
if (t.namespaceURI === Y && o in u) {
|
|
229
|
+
const h = Array.isArray(e) ? e.join(", ") : String(e);
|
|
230
230
|
t.style[u[o]] = h;
|
|
231
231
|
return;
|
|
232
|
-
} else o === "fill" && t.dataset?.elementType === "text" ? a = "color" : a =
|
|
232
|
+
} else o === "fill" && t.dataset?.elementType === "text" ? a = "color" : a = C[o] ?? o;
|
|
233
233
|
let c;
|
|
234
|
-
typeof
|
|
234
|
+
typeof e == "number" ? d.has(o) || d.has(a) ? c = `${e}px` : c = String(e) : Array.isArray(e) ? c = e.join(", ") : c = e, t.style[a] = c;
|
|
235
235
|
}
|
|
236
236
|
}
|
|
237
237
|
export {
|
|
238
|
-
|
|
238
|
+
E as D,
|
|
239
239
|
w as F,
|
|
240
|
-
|
|
241
|
-
|
|
242
|
-
|
|
240
|
+
x as c,
|
|
241
|
+
$ as e,
|
|
242
|
+
S as s
|
|
243
243
|
};
|
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
import { getEasingFunction as F, staggerOffset as qt, maxStaggerDistance as Bt, getInterpolator as at, pointsToPath as Ut, isPathData as z, naturalRest as H, SPRING_PRESETS as _, Timeline as Wt, createTrack as ct, springDuration as zt, inertiaDuration as _t, inertiaRest as Gt, staggerSpan as Yt, isParametricEasing as Xt, bakeEasing as Ht, shapeToPathData as et, customBounce as Kt, customEase as Zt, customWiggle as Jt, playheadCrossings as Qt, staggerOffsets as lt } from "@algorisys/tinyfly";
|
|
2
2
|
import { backOut as Er, bounceOut as Ar, elasticOut as Cr, playheadCrossings as Rr, stepsEasing as Fr } from "@algorisys/tinyfly";
|
|
3
|
-
import { D as St } from "./dom-adapter-
|
|
3
|
+
import { D as St } from "./dom-adapter-CrNwoomd.js";
|
|
4
4
|
import { a as Mt, d as ht } from "./smooth-scroll-DaSacemU.js";
|
|
5
5
|
import { Draggable as te } from "./interaction.js";
|
|
6
6
|
const q = {
|
|
@@ -0,0 +1,128 @@
|
|
|
1
|
+
import { createRandom as S, hashSeed as q } from "@algorisys/tinyfly";
|
|
2
|
+
function E(t) {
|
|
3
|
+
let n = 0;
|
|
4
|
+
for (let s = 1; s < t.length; s++) n += Math.hypot(t[s].x - t[s - 1].x, t[s].y - t[s - 1].y);
|
|
5
|
+
return n;
|
|
6
|
+
}
|
|
7
|
+
function $(t, n) {
|
|
8
|
+
const s = Math.min(1, Math.max(0, n));
|
|
9
|
+
if (t.length < 2 || s === 1) return t.slice();
|
|
10
|
+
if (s === 0) return t.slice(0, 1);
|
|
11
|
+
let e = E(t) * s;
|
|
12
|
+
const a = [t[0]];
|
|
13
|
+
for (let c = 1; c < t.length; c++) {
|
|
14
|
+
const f = t[c - 1], y = t[c], h = Math.hypot(y.x - f.x, y.y - f.y);
|
|
15
|
+
if (h >= e) {
|
|
16
|
+
const b = h === 0 ? 0 : e / h;
|
|
17
|
+
return a.push({ x: f.x + (y.x - f.x) * b, y: f.y + (y.y - f.y) * b }), a;
|
|
18
|
+
}
|
|
19
|
+
a.push(y), e -= h;
|
|
20
|
+
}
|
|
21
|
+
return a;
|
|
22
|
+
}
|
|
23
|
+
function p(t, n) {
|
|
24
|
+
const s = $(t, n);
|
|
25
|
+
return s[s.length - 1];
|
|
26
|
+
}
|
|
27
|
+
function F(t, n) {
|
|
28
|
+
return n > 0 ? Math.floor(Math.max(0, t) * n / 1e3) : 0;
|
|
29
|
+
}
|
|
30
|
+
function B(t, n, s) {
|
|
31
|
+
const e = n.roughness ?? 2, a = Math.max(1, Math.round(n.passes ?? 2)), c = F(s, n.boil ?? 8);
|
|
32
|
+
let f = 0;
|
|
33
|
+
const y = () => {
|
|
34
|
+
const o = f++;
|
|
35
|
+
return (x) => S(q(`${n.seed ?? 1}:${c}:${o}:${x}`));
|
|
36
|
+
}, h = (o, x) => (o.next() * 2 - 1) * x, b = (o) => {
|
|
37
|
+
const x = y(), u = t.lineWidth, i = t.globalAlpha;
|
|
38
|
+
for (let r = 0; r < a; r++)
|
|
39
|
+
t.lineWidth = r === 0 ? u : u * 0.55, t.globalAlpha = r === 0 ? i : i * 0.6, o(x(r));
|
|
40
|
+
t.lineWidth = u, t.globalAlpha = i;
|
|
41
|
+
}, C = (o, x = 1) => {
|
|
42
|
+
if (o.length < 2) return;
|
|
43
|
+
const u = o.slice(1).map((r, l) => Math.hypot(r.x - o[l].x, r.y - o[l].y)), i = u.reduce((r, l) => r + l, 0) * Math.min(1, Math.max(0, x));
|
|
44
|
+
b((r) => {
|
|
45
|
+
const l = [], k = [];
|
|
46
|
+
if (o.forEach((g, M) => {
|
|
47
|
+
l.push({ x: g.x + h(r, e * 0.5), y: g.y + h(r, e * 0.5) }), M > 0 && k.push([r.next() * 2 - 1, r.next() * 2 - 1]);
|
|
48
|
+
}), i <= 0) return;
|
|
49
|
+
t.beginPath(), t.moveTo(l[0].x, l[0].y);
|
|
50
|
+
let m = 0;
|
|
51
|
+
for (let g = 1; g < l.length; g++) {
|
|
52
|
+
const M = L(l[g - 1], l[g], e, k[g - 1]), w = u[g - 1];
|
|
53
|
+
if (m + w <= i) {
|
|
54
|
+
t.bezierCurveTo(M[1].x, M[1].y, M[2].x, M[2].y, M[3].x, M[3].y), m += w;
|
|
55
|
+
continue;
|
|
56
|
+
}
|
|
57
|
+
const d = R(M, w === 0 ? 1 : (i - m) / w);
|
|
58
|
+
t.bezierCurveTo(d[1].x, d[1].y, d[2].x, d[2].y, d[3].x, d[3].y);
|
|
59
|
+
break;
|
|
60
|
+
}
|
|
61
|
+
t.stroke();
|
|
62
|
+
});
|
|
63
|
+
}, P = (o, x, u, i, r = 1) => {
|
|
64
|
+
b((l) => {
|
|
65
|
+
const m = l.next() * Math.PI * 2, g = Math.PI * 2 + 0.15 + l.next() * 0.3, M = [];
|
|
66
|
+
for (let d = 0; d <= 14; d++) {
|
|
67
|
+
const v = m + g * d / 14, T = h(l, e * 0.6);
|
|
68
|
+
M.push({ x: o + Math.cos(v) * (u + T), y: x + Math.sin(v) * (i + T) });
|
|
69
|
+
}
|
|
70
|
+
const w = $(M, r);
|
|
71
|
+
w.length < 2 || (W(t, w), t.stroke());
|
|
72
|
+
});
|
|
73
|
+
};
|
|
74
|
+
return {
|
|
75
|
+
line: C,
|
|
76
|
+
curve(o, x = 1) {
|
|
77
|
+
if (o.length < 2) return;
|
|
78
|
+
const u = o[0], i = o[o.length - 1], r = Math.hypot(i.x - u.x, i.y - u.y) || 1, l = -(i.y - u.y) / r, k = (i.x - u.x) / r;
|
|
79
|
+
b((m) => {
|
|
80
|
+
const g = { x: h(m, e * 0.5), y: h(m, e * 0.5) }, M = { x: h(m, e * 0.5), y: h(m, e * 0.5) }, w = h(m, e * Math.min(1.5, Math.max(0.3, r / 80))), d = o.map((T, z) => {
|
|
81
|
+
const A = z / (o.length - 1), I = Math.sin(Math.PI * A) * w;
|
|
82
|
+
return {
|
|
83
|
+
x: T.x + g.x + (M.x - g.x) * A + l * I,
|
|
84
|
+
y: T.y + g.y + (M.y - g.y) * A + k * I
|
|
85
|
+
};
|
|
86
|
+
}), v = $(d, x);
|
|
87
|
+
v.length < 2 || (W(t, v), t.stroke());
|
|
88
|
+
});
|
|
89
|
+
},
|
|
90
|
+
circle(o, x, u, i = 1) {
|
|
91
|
+
P(o, x, u, u, i);
|
|
92
|
+
},
|
|
93
|
+
ellipse: P,
|
|
94
|
+
nudge(o = 0.5) {
|
|
95
|
+
const x = y()(0);
|
|
96
|
+
return { x: h(x, e * o), y: h(x, e * o) };
|
|
97
|
+
}
|
|
98
|
+
};
|
|
99
|
+
}
|
|
100
|
+
function L(t, n, s, e) {
|
|
101
|
+
const a = n.x - t.x, c = n.y - t.y, f = Math.hypot(a, c) || 1, y = s * Math.min(1.5, Math.max(0.3, f / 80)), h = -c / f, b = a / f;
|
|
102
|
+
return [
|
|
103
|
+
t,
|
|
104
|
+
{ x: t.x + a / 3 + h * e[0] * y, y: t.y + c / 3 + b * e[0] * y },
|
|
105
|
+
{ x: t.x + 2 * a / 3 + h * e[1] * y, y: t.y + 2 * c / 3 + b * e[1] * y },
|
|
106
|
+
n
|
|
107
|
+
];
|
|
108
|
+
}
|
|
109
|
+
function R([t, n, s, e], a) {
|
|
110
|
+
const c = (P, o) => ({ x: P.x + (o.x - P.x) * a, y: P.y + (o.y - P.y) * a }), f = c(t, n), y = c(n, s), h = c(s, e), b = c(f, y), C = c(y, h);
|
|
111
|
+
return [t, f, b, c(b, C)];
|
|
112
|
+
}
|
|
113
|
+
function W(t, n) {
|
|
114
|
+
t.beginPath(), t.moveTo(n[0].x, n[0].y);
|
|
115
|
+
for (let e = 1; e < n.length - 1; e++) {
|
|
116
|
+
const a = { x: (n[e].x + n[e + 1].x) / 2, y: (n[e].y + n[e + 1].y) / 2 };
|
|
117
|
+
t.quadraticCurveTo(n[e].x, n[e].y, a.x, a.y);
|
|
118
|
+
}
|
|
119
|
+
const s = n[n.length - 1];
|
|
120
|
+
t.lineTo(s.x, s.y);
|
|
121
|
+
}
|
|
122
|
+
export {
|
|
123
|
+
p as a,
|
|
124
|
+
F as b,
|
|
125
|
+
E as c,
|
|
126
|
+
$ as p,
|
|
127
|
+
B as s
|
|
128
|
+
};
|