@mkbabb/keyframes.js 4.4.0 → 5.1.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 +36 -221
- package/dist/animation-BGyzfzBq.js +947 -0
- package/dist/compile-CcSUwM8R.js +276 -0
- package/dist/{waapi-D9MHMm_9.js → delegation-DWwr4IXr.js} +116 -32
- package/dist/{draw-svg-DYRDxBlL.js → draw-svg-GURj9nin.js} +17 -13
- package/dist/easing-registry-DHV2-5gA.js +27 -0
- package/dist/easing-registry-y1p9McFy.js +2 -0
- package/dist/engine/index.d.ts +2873 -0
- package/dist/engine/index.js +17 -0
- package/dist/engine-DEVgCTUy.js +156 -0
- package/dist/engine-DrBtsKaf.js +4 -0
- package/dist/{format-BUgCTjmr.js → format-C-Gi9r7L.js} +4 -4
- package/dist/{scroll-grammar-B4kPvGh5.js → grammar-BLucehC4.js} +1 -1
- package/dist/group-vJcsHKN9.js +360 -0
- package/dist/{ingest-CNM5xkQT.js → ingest-S5hUe20K.js} +62 -56
- package/dist/keyframes.d.ts +585 -989
- package/dist/keyframes.js +188 -129
- package/dist/morph-svg-BToeumw5.js +89 -0
- package/dist/{motion-path-J-RSNmRQ.js → motion-path-pQVbamWT.js} +16 -12
- package/dist/parse-flatten-DRMHFytp.js +2 -0
- package/dist/parse-flatten-ZZUSEQEL.js +63 -0
- package/dist/{animations-5nf2kBkv.js → presets-BG2Fczzq.js} +124 -73
- package/dist/{scheduler-7eIr_q1g.js → scheduler-CUtVnuoU.js} +1 -1
- package/dist/{scroll-scene-CXEgM49Q.js → scroll-CxpYFO4u.js} +50 -46
- package/dist/sequence-C_DCiOIQ.js +708 -0
- package/dist/validate-DDeGnvSt.js +39 -0
- package/package.json +45 -6
- package/dist/animate-CuUJt2Tb.js +0 -26
- package/dist/compile-DgNRG6Lo.js +0 -251
- package/dist/decay-BvNmFk51.js +0 -25
- package/dist/engine-CNHvTgpw.js +0 -1122
- package/dist/errors-W8zkvPw4.js +0 -21
- package/dist/morph-svg-DRjl9Hfz.js +0 -62
- package/dist/rolldown-runtime-Dy4uBu1J.js +0 -11
- package/dist/sequence-CF5hazqz.js +0 -198
- package/dist/springTimingFunction-CDHZ00JQ.js +0 -63
- package/dist/timeline-B7SV3T_E.js +0 -442
- package/dist/utils-D7nuAND5.js +0 -97
- package/dist/validate-8r6Yo-uc.js +0 -35
|
@@ -0,0 +1,276 @@
|
|
|
1
|
+
import { n as e } from "./presets-BG2Fczzq.js";
|
|
2
|
+
import { t } from "./sequence-C_DCiOIQ.js";
|
|
3
|
+
import { c as n, l as r, n as i, s as a, u as o } from "./animation-BGyzfzBq.js";
|
|
4
|
+
import { n as s, r as c, t as l } from "./parse-flatten-ZZUSEQEL.js";
|
|
5
|
+
import { t as u } from "./easing-registry-DHV2-5gA.js";
|
|
6
|
+
import { n as d } from "./group-vJcsHKN9.js";
|
|
7
|
+
import { a as f } from "./grammar-BLucehC4.js";
|
|
8
|
+
import { a as p, c as m, i as h, l as g, n as _, r as v, s as y, t as b } from "./format-C-Gi9r7L.js";
|
|
9
|
+
import { COLOR_SPACE_RANGES as x, color2 as S, deltaEOK as C, formatCSS as w, normalizeColorUnit as T, reverseCSSTime as E, sampleColorRamp as D, scale as O } from "@mkbabb/value.js";
|
|
10
|
+
//#region src/animation/compile/backward-walk.ts
|
|
11
|
+
function k(e) {
|
|
12
|
+
let t = [];
|
|
13
|
+
for (let n of Object.keys(e.animations)) {
|
|
14
|
+
let r = e.animations[n], a = r.layer.blendMode, o = a === "weighted" && r.layer.weightSpring != null, s = a === "weighted" && r.layer.weightSpring == null, c = a === "add" ? "add" : s ? "accumulate" : "replace";
|
|
15
|
+
t.push({
|
|
16
|
+
animation: r.animation,
|
|
17
|
+
name: M(i(r.animation)),
|
|
18
|
+
composition: c,
|
|
19
|
+
weighted: o,
|
|
20
|
+
...s ? { staticWeight: r.layer.weight } : {},
|
|
21
|
+
delay: 0
|
|
22
|
+
});
|
|
23
|
+
}
|
|
24
|
+
return t;
|
|
25
|
+
}
|
|
26
|
+
function A(e) {
|
|
27
|
+
return e.entries.map((e) => ({
|
|
28
|
+
animation: e.animation,
|
|
29
|
+
name: M(i(e.animation)),
|
|
30
|
+
composition: "replace",
|
|
31
|
+
weighted: !1,
|
|
32
|
+
delay: e.at
|
|
33
|
+
}));
|
|
34
|
+
}
|
|
35
|
+
function j(e) {
|
|
36
|
+
return e.map((e, t) => {
|
|
37
|
+
let n = "animation" in e ? e.animation : e;
|
|
38
|
+
return {
|
|
39
|
+
animation: n,
|
|
40
|
+
name: M(i(n) || `anim-${t}`),
|
|
41
|
+
composition: "replace",
|
|
42
|
+
weighted: !1,
|
|
43
|
+
delay: 0
|
|
44
|
+
};
|
|
45
|
+
});
|
|
46
|
+
}
|
|
47
|
+
function M(e) {
|
|
48
|
+
let t = e.replace(/[^a-zA-Z0-9_-]/g, "-");
|
|
49
|
+
return /^[a-zA-Z_]/.test(t) ? t : `a${t}`;
|
|
50
|
+
}
|
|
51
|
+
//#endregion
|
|
52
|
+
//#region src/animation/compile/backward-color.ts
|
|
53
|
+
var N = x.oklab.a.number.min, P = x.oklab.a.number.max, F = x.oklab.b.number.min, I = x.oklab.b.number.max, L = (e) => Math.round(e * 1e4) / 1e4, R = (e) => typeof e == "object" && !!e && e.unit === "color", z = (e) => T(e).value, B = (e) => {
|
|
54
|
+
let t = S(e, "oklab");
|
|
55
|
+
return [
|
|
56
|
+
t.l,
|
|
57
|
+
O(t.a, 0, 1, N, P),
|
|
58
|
+
O(t.b, 0, 1, F, I)
|
|
59
|
+
];
|
|
60
|
+
}, V = (e) => {
|
|
61
|
+
let [t, n, r] = B(e);
|
|
62
|
+
return `oklab(${L(t)} ${L(n)} ${L(r)})`;
|
|
63
|
+
}, H = (e, t) => {
|
|
64
|
+
let [n, r, i] = B(e), [a, o, s] = B(t);
|
|
65
|
+
return C(n, r, i, a, o, s);
|
|
66
|
+
}, U = (e, t, n) => S({
|
|
67
|
+
colorSpace: "oklab",
|
|
68
|
+
l: e,
|
|
69
|
+
a: O(t, N, P, 0, 1),
|
|
70
|
+
b: O(n, F, I, 0, 1),
|
|
71
|
+
alpha: 1
|
|
72
|
+
}, "oklab"), W = (e, t) => {
|
|
73
|
+
let [n, r, i] = B(e), [a, o, s] = B(t);
|
|
74
|
+
return U((n + a) / 2, (r + o) / 2, (i + s) / 2);
|
|
75
|
+
}, G = (e) => {
|
|
76
|
+
let t = /([\d.]+)\s*%/.exec(e.toString());
|
|
77
|
+
return t ? parseFloat(t[1]) : 0;
|
|
78
|
+
}, K = (e, t, n) => {
|
|
79
|
+
let r = (e.parsedVars[t] ?? {})[n];
|
|
80
|
+
if (Array.isArray(r)) return r.find((e) => R(e));
|
|
81
|
+
};
|
|
82
|
+
function q(e, t, n, r, i) {
|
|
83
|
+
let a = t.replace(/([a-z0-9])([A-Z])/g, "$1-$2").toLowerCase(), o = [], s = 0;
|
|
84
|
+
for (let a = 0; a + 1 < e.templateFrames.length; a++) {
|
|
85
|
+
let c = K(e, a, t), l = K(e, a + 1, t);
|
|
86
|
+
if (!c || !l) continue;
|
|
87
|
+
let u = G(e.templateFrames[a].start), d = G(e.templateFrames[a + 1].start);
|
|
88
|
+
if (c.toString() === l.toString()) {
|
|
89
|
+
o.push({
|
|
90
|
+
pct: u,
|
|
91
|
+
css: c.toString()
|
|
92
|
+
});
|
|
93
|
+
continue;
|
|
94
|
+
}
|
|
95
|
+
let f = z(c), p = z(l), m = D(f, p, n, {
|
|
96
|
+
space: r,
|
|
97
|
+
...i
|
|
98
|
+
});
|
|
99
|
+
for (let e = 0; e < m.length; e++) {
|
|
100
|
+
let t = e / (m.length - 1), n = u + (d - u) * t;
|
|
101
|
+
o.push({
|
|
102
|
+
pct: L(n),
|
|
103
|
+
css: V(m[e])
|
|
104
|
+
});
|
|
105
|
+
}
|
|
106
|
+
for (let e = 0; e + 1 < m.length; e++) {
|
|
107
|
+
let t = (e + .5) / (m.length - 1), n = D(f, p, 1024, {
|
|
108
|
+
space: r,
|
|
109
|
+
...i
|
|
110
|
+
})[Math.round(t * 1023)], a = W(m[e], m[e + 1]);
|
|
111
|
+
s = Math.max(s, H(a, n));
|
|
112
|
+
}
|
|
113
|
+
}
|
|
114
|
+
let c = e.templateFrames.length - 1, l = K(e, c, t);
|
|
115
|
+
if (l) {
|
|
116
|
+
let t = G(e.templateFrames[c].start);
|
|
117
|
+
o[o.length - 1]?.pct !== t && o.push({
|
|
118
|
+
pct: t,
|
|
119
|
+
css: l.toString()
|
|
120
|
+
});
|
|
121
|
+
}
|
|
122
|
+
return {
|
|
123
|
+
cssProp: a,
|
|
124
|
+
stops: o,
|
|
125
|
+
worstDelta: s
|
|
126
|
+
};
|
|
127
|
+
}
|
|
128
|
+
function J(e, t, n, r) {
|
|
129
|
+
let i = [], a = /* @__PURE__ */ new Set();
|
|
130
|
+
for (let t = 0; t + 1 < e.templateFrames.length; t++) {
|
|
131
|
+
let n = e.parsedVars[t] ?? {};
|
|
132
|
+
for (let [r, o] of Object.entries(n)) {
|
|
133
|
+
if (a.has(r) || !Array.isArray(o) || !o.some((e) => R(e))) continue;
|
|
134
|
+
let n = K(e, t, r), s = K(e, t + 1, r);
|
|
135
|
+
n && s && n.toString() !== s.toString() && (i.push(r), a.add(r));
|
|
136
|
+
}
|
|
137
|
+
}
|
|
138
|
+
if (i.length === 0) return null;
|
|
139
|
+
let o = Math.max(3, n), s = e.options.colorSpace === "oklch" ? "oklch" : "oklab", c = e.options.hueMethod ? { hueMethod: e.options.hueMethod } : {}, l = 0, u = /* @__PURE__ */ new Map(), d = [];
|
|
140
|
+
for (let t of i) {
|
|
141
|
+
let n = q(e, t, o, s, c);
|
|
142
|
+
l = Math.max(l, n.worstDelta);
|
|
143
|
+
for (let { pct: e, css: t } of n.stops) {
|
|
144
|
+
let r = u.get(e);
|
|
145
|
+
r || (r = [], u.set(e, r), d.push(e)), r.push(`${n.cssProp}: ${t};`);
|
|
146
|
+
}
|
|
147
|
+
}
|
|
148
|
+
if (l > r) return {
|
|
149
|
+
refused: !0,
|
|
150
|
+
delta: l
|
|
151
|
+
};
|
|
152
|
+
d.sort((e, t) => e - t);
|
|
153
|
+
let f = "";
|
|
154
|
+
for (let e of d) {
|
|
155
|
+
let t = u.get(e);
|
|
156
|
+
f += `${e}% {\n ${t.join("\n ")}\n}\n`;
|
|
157
|
+
}
|
|
158
|
+
return { block: `@keyframes ${t} {\n${f}}` };
|
|
159
|
+
}
|
|
160
|
+
//#endregion
|
|
161
|
+
//#region src/animation/compile/backward.ts
|
|
162
|
+
var Y = .04;
|
|
163
|
+
function X(e) {
|
|
164
|
+
for (let t = 0; t < e.templateFrames.length; t++) {
|
|
165
|
+
let n = e.parsedVars[t] ?? {};
|
|
166
|
+
for (let [e, t] of Object.entries(n)) if (!Array.isArray(t) || t.length === 0) return e;
|
|
167
|
+
}
|
|
168
|
+
}
|
|
169
|
+
function Z(e, t, n) {
|
|
170
|
+
let { animation: r, name: i } = e;
|
|
171
|
+
if (e.weighted) return n.push({
|
|
172
|
+
name: i,
|
|
173
|
+
reason: "weighted-blend",
|
|
174
|
+
message: "weighted layer blend has no animation-composition equivalent (CSS composites replace/add/accumulate only); the weighted axis is kf's unique blend tier — the JS playback is the only faithful path"
|
|
175
|
+
}), null;
|
|
176
|
+
for (let e of r.frames) if (!r.usesDefaultRenderer(e.transform)) return n.push({
|
|
177
|
+
name: i,
|
|
178
|
+
reason: "custom-renderer",
|
|
179
|
+
message: "custom renderer (a transform closure, not the default DOM-style renderer) cannot be expressed as CSS — the JS playback is the only faithful path"
|
|
180
|
+
}), null;
|
|
181
|
+
let a = X(r);
|
|
182
|
+
if (a) return n.push({
|
|
183
|
+
name: i,
|
|
184
|
+
reason: "computed-unit-drift",
|
|
185
|
+
message: `computed-unit drift on "${a}" — the declared value cannot be re-emitted as a faithful authored string; the JS playback is the only faithful path`
|
|
186
|
+
}), null;
|
|
187
|
+
let o = J(r, i, t.densifyStops ?? 16, t.deltaEEpsilon ?? .04);
|
|
188
|
+
if (o && "refused" in o) return n.push({
|
|
189
|
+
name: i,
|
|
190
|
+
reason: "perceptual-oklab",
|
|
191
|
+
message: `perceptual oklab color track exceeds the densify ΔE-ε threshold (ΔE ${L(o.delta)} > ${t.deltaEEpsilon ?? .04}) — a faithful pure-CSS twin is not available; the JS playback is the only faithful path`
|
|
192
|
+
}), null;
|
|
193
|
+
let s;
|
|
194
|
+
if (e.staticWeight != null) {
|
|
195
|
+
let t = m(r, i, e.staticWeight);
|
|
196
|
+
if ("refused" in t) return n.push({
|
|
197
|
+
name: i,
|
|
198
|
+
reason: "weighted-blend",
|
|
199
|
+
message: `static-weight pre-multiply cannot scale the non-numeric leaf "${t.key}" (a color/string has no scalar weight) — the weighted blend is kf's unique tier; the JS playback is the only faithful path`
|
|
200
|
+
}), null;
|
|
201
|
+
s = t.block;
|
|
202
|
+
}
|
|
203
|
+
let c = s ?? (o && "block" in o ? o.block : y(r, i)), l;
|
|
204
|
+
try {
|
|
205
|
+
l = h(r.options, i);
|
|
206
|
+
} catch {
|
|
207
|
+
return n.push({
|
|
208
|
+
name: i,
|
|
209
|
+
reason: "custom-renderer",
|
|
210
|
+
message: "easing has no faithful CSS timing-function twin (a custom closure cannot be CSS) — attach an Easing.css twin or use a registry name / cubic-bezier() / linear(); the JS playback is the only faithful path"
|
|
211
|
+
}), null;
|
|
212
|
+
}
|
|
213
|
+
let u = v(e.composition), d = u ? `\n ${u}` : "", f = e.delay > 0 ? `\n animation-delay: ${E(e.delay)};` : "", p = Q(r);
|
|
214
|
+
return `${c}\n\n${`.${i} {\n animation: ${l};${d}${f}${p}\n}`}`;
|
|
215
|
+
}
|
|
216
|
+
function Q(e) {
|
|
217
|
+
let t = e.scrollOptions;
|
|
218
|
+
if (t == null) return "";
|
|
219
|
+
let n = f(t), r = "";
|
|
220
|
+
for (let [e, t] of Object.entries(n)) t != null && (r += `\n ${e}: ${t};`);
|
|
221
|
+
return r;
|
|
222
|
+
}
|
|
223
|
+
async function $(e, n = {}) {
|
|
224
|
+
let r = e instanceof d ? k(e) : e instanceof t ? A(e) : j(e), i = /* @__PURE__ */ new Map();
|
|
225
|
+
for (let e of r) {
|
|
226
|
+
let t = i.get(e.name) ?? 0;
|
|
227
|
+
i.set(e.name, t + 1), t > 0 && (e.name = `${e.name}-${t + 1}`);
|
|
228
|
+
}
|
|
229
|
+
n.staggerDelays && r.forEach((e, t) => {
|
|
230
|
+
let r = n.staggerDelays[t];
|
|
231
|
+
typeof r == "number" && r > 0 && (e.delay += r);
|
|
232
|
+
});
|
|
233
|
+
let a = [], o = [];
|
|
234
|
+
for (let e of r) {
|
|
235
|
+
let t = Z(e, n, a);
|
|
236
|
+
t && o.push(t);
|
|
237
|
+
}
|
|
238
|
+
let s = a.length === 0;
|
|
239
|
+
if (o.length === 0) return {
|
|
240
|
+
css: "",
|
|
241
|
+
eligible: s,
|
|
242
|
+
refusals: a
|
|
243
|
+
};
|
|
244
|
+
let c = o.join("\n\n"), l;
|
|
245
|
+
try {
|
|
246
|
+
l = await w(c, n.printWidth);
|
|
247
|
+
} catch {
|
|
248
|
+
l = c;
|
|
249
|
+
}
|
|
250
|
+
return {
|
|
251
|
+
css: l,
|
|
252
|
+
eligible: s,
|
|
253
|
+
refusals: a
|
|
254
|
+
};
|
|
255
|
+
}
|
|
256
|
+
//#endregion
|
|
257
|
+
//#region src/animation/compile/index.ts
|
|
258
|
+
var ee = /* @__PURE__ */ e({
|
|
259
|
+
CSSKeyframesToString: () => b,
|
|
260
|
+
CSSKeyframesToStrings: () => _,
|
|
261
|
+
DEFAULT_DELTA_E_EPSILON: () => Y,
|
|
262
|
+
DEFAULT_DENSIFY_STOPS: () => 16,
|
|
263
|
+
FrameCompiler: () => a,
|
|
264
|
+
NAMED_SELECTOR_SUPERTYPE: () => r,
|
|
265
|
+
compileToCSS: () => $,
|
|
266
|
+
createInterpVarValue: () => l,
|
|
267
|
+
formatCSSKeyframeString: () => p,
|
|
268
|
+
getTimingFunction: () => u,
|
|
269
|
+
namedSelectorToFraction: () => o,
|
|
270
|
+
parseAndFlattenObject: () => s,
|
|
271
|
+
resolveEasingOption: () => n,
|
|
272
|
+
serializeEasing: () => g,
|
|
273
|
+
transformTargetsStyle: () => c
|
|
274
|
+
});
|
|
275
|
+
//#endregion
|
|
276
|
+
export { $ as n, ee as t };
|
|
@@ -1,7 +1,24 @@
|
|
|
1
|
-
import { f as e, i as t } from "./
|
|
1
|
+
import { f as e, i as t } from "./sequence-C_DCiOIQ.js";
|
|
2
2
|
import { COMPUTED_UNITS as n, unflattenObjectToString as r } from "@mkbabb/value.js";
|
|
3
|
-
//#region src/animation/
|
|
4
|
-
var i =
|
|
3
|
+
//#region src/animation/internal/scroll-phases.ts
|
|
4
|
+
var i = {
|
|
5
|
+
entry: {
|
|
6
|
+
start: 0,
|
|
7
|
+
end: .25
|
|
8
|
+
},
|
|
9
|
+
cover: {
|
|
10
|
+
start: .25,
|
|
11
|
+
end: .75
|
|
12
|
+
},
|
|
13
|
+
contain: {
|
|
14
|
+
start: .375,
|
|
15
|
+
end: .625
|
|
16
|
+
},
|
|
17
|
+
exit: {
|
|
18
|
+
start: .75,
|
|
19
|
+
end: 1
|
|
20
|
+
}
|
|
21
|
+
}, a = new Set([
|
|
5
22
|
...n,
|
|
6
23
|
"%",
|
|
7
24
|
"vh",
|
|
@@ -34,8 +51,8 @@ var i = new Set([
|
|
|
34
51
|
"cqb",
|
|
35
52
|
"cqmin",
|
|
36
53
|
"cqmax"
|
|
37
|
-
]),
|
|
38
|
-
function
|
|
54
|
+
]), o = (e) => typeof e == "string" && a.has(e), s = new Set(["offset-distance"]), c = (e) => s.has(e) || s.has(e.split(".").pop() ?? e), l = () => typeof globalThis.webkitConvertPointFromNodeToPage == "function";
|
|
55
|
+
function u(e) {
|
|
39
56
|
if (!e.targets || e.targets.length === 0) return {
|
|
40
57
|
eligible: !1,
|
|
41
58
|
reason: "no DOM targets"
|
|
@@ -63,14 +80,14 @@ function l(e) {
|
|
|
63
80
|
eligible: !1,
|
|
64
81
|
reason: "easing has no faithful CSS twin (would run bare linear on the compositor)"
|
|
65
82
|
};
|
|
66
|
-
if (t?.css?.startsWith("linear(") &&
|
|
83
|
+
if (t?.css?.startsWith("linear(") && l()) return {
|
|
67
84
|
eligible: !1,
|
|
68
85
|
reason: "WebKit refuses HW-accel for linear() easing — the spring twin stays on the rAF path (CE-1.0)"
|
|
69
86
|
};
|
|
70
87
|
for (let t of e.frames) for (let [e, n] of Object.entries(t.interpVars)) {
|
|
71
|
-
let t =
|
|
88
|
+
let t = c(e);
|
|
72
89
|
for (let e of n) {
|
|
73
|
-
let n =
|
|
90
|
+
let n = o(e.start?.unit) && !(t && e.start?.unit === "%"), r = o(e.stop?.unit) && !(t && e.stop?.unit === "%");
|
|
74
91
|
if (n || r) return {
|
|
75
92
|
eligible: !1,
|
|
76
93
|
reason: `layout-dependent unit (${String(e.start?.unit ?? e.stop?.unit)}) would freeze to px under WAAPI`
|
|
@@ -83,15 +100,78 @@ function l(e) {
|
|
|
83
100
|
}
|
|
84
101
|
return { eligible: !0 };
|
|
85
102
|
}
|
|
86
|
-
var
|
|
87
|
-
|
|
103
|
+
var d = .005, f = (e, t) => {
|
|
104
|
+
let n = /* @__PURE__ */ new Map(), r = e.interpFrames(t, !1);
|
|
105
|
+
for (let e in r) {
|
|
106
|
+
let t = r[e];
|
|
107
|
+
if (t !== void 0) for (let r = 0; r < t.length; r++) {
|
|
108
|
+
let i = t[r]?.value;
|
|
109
|
+
typeof i == "number" && Number.isFinite(i) && n.set(t.length > 1 ? `${e}.${r}` : e, i);
|
|
110
|
+
}
|
|
111
|
+
}
|
|
112
|
+
return n;
|
|
113
|
+
}, p = 64, m = (e, t, n) => {
|
|
114
|
+
let r = /* @__PURE__ */ new Map(), i = /* @__PURE__ */ new Map(), a = n - t;
|
|
115
|
+
for (let n = 0; n <= p; n++) {
|
|
116
|
+
let o = f(e, t + a * n / p);
|
|
117
|
+
for (let [e, t] of o) {
|
|
118
|
+
let n = r.get(e), a = i.get(e);
|
|
119
|
+
(n === void 0 || t < n) && r.set(e, t), (a === void 0 || t > a) && i.set(e, t);
|
|
120
|
+
}
|
|
121
|
+
}
|
|
122
|
+
let o = /* @__PURE__ */ new Map();
|
|
123
|
+
for (let [e, t] of r) o.set(e, (i.get(e) ?? t) - t);
|
|
124
|
+
return o;
|
|
125
|
+
}, h = (e, t, n, r, i, a) => {
|
|
126
|
+
let o = r - t, s = 0;
|
|
127
|
+
for (let r of [.25, .75]) {
|
|
128
|
+
let c = f(e, t + o * r);
|
|
129
|
+
for (let [e, t] of c) {
|
|
130
|
+
let o = n.get(e), c = i.get(e);
|
|
131
|
+
if (o === void 0 || c === void 0) continue;
|
|
132
|
+
let l = a.get(e);
|
|
133
|
+
if (l === void 0 || l === 0) continue;
|
|
134
|
+
let u = o + (c - o) * r, d = Math.abs(t - u) / l;
|
|
135
|
+
d > s && (s = d);
|
|
136
|
+
}
|
|
137
|
+
}
|
|
138
|
+
return s;
|
|
139
|
+
};
|
|
140
|
+
function g(e, t, n) {
|
|
141
|
+
let r = /* @__PURE__ */ new Set();
|
|
142
|
+
if (n <= 0) return r;
|
|
143
|
+
for (let n = 1; n < t.length; n++) {
|
|
144
|
+
let i = t[n - 1], a = t[n];
|
|
145
|
+
if (a - i <= 0) continue;
|
|
146
|
+
let o = m(e, i, a), s = f(e, i), c = f(e, a), l = (t, n, r, i) => ({
|
|
147
|
+
a: t,
|
|
148
|
+
sampleA: n,
|
|
149
|
+
b: r,
|
|
150
|
+
sampleB: i,
|
|
151
|
+
error: h(e, t, n, r, i, o)
|
|
152
|
+
}), u = [l(i, s, a, c)], p = 16;
|
|
153
|
+
for (; p > 0;) {
|
|
154
|
+
let t = -1, n = d;
|
|
155
|
+
for (let e = 0; e < u.length; e++) u[e].error > n && (n = u[e].error, t = e);
|
|
156
|
+
if (t === -1) break;
|
|
157
|
+
let i = u[t], a = (i.a + i.b) / 2;
|
|
158
|
+
if (a <= i.a || a >= i.b) {
|
|
159
|
+
u.splice(t, 1);
|
|
160
|
+
continue;
|
|
161
|
+
}
|
|
162
|
+
let o = f(e, a);
|
|
163
|
+
r.add(a), p--, u.splice(t, 1, l(i.a, i.sampleA, a, o), l(a, o, i.b, i.sampleB));
|
|
164
|
+
}
|
|
165
|
+
}
|
|
166
|
+
return r;
|
|
167
|
+
}
|
|
168
|
+
//#endregion
|
|
169
|
+
//#region src/animation/waapi/emission.ts
|
|
170
|
+
function _(t) {
|
|
88
171
|
let n = t.options.duration, i = [], a = /* @__PURE__ */ new Set();
|
|
89
172
|
for (let e of t.frames) a.add(e.time.start), a.add(e.time.stop);
|
|
90
173
|
let o = [...a].sort((e, t) => e - t), s = new Set(o);
|
|
91
|
-
|
|
92
|
-
let t = o[e - 1], n = o[e] - t;
|
|
93
|
-
if (!(n <= 0)) for (let e = 1; e <= u; e++) s.add(t + n * e / 9);
|
|
94
|
-
}
|
|
174
|
+
for (let e of g(t, o, n)) s.add(e);
|
|
95
175
|
for (let a of [...s].sort((e, t) => e - t)) {
|
|
96
176
|
let o = t.interpFrames(a, !1);
|
|
97
177
|
if (Object.keys(o).length === 0) continue;
|
|
@@ -103,32 +183,34 @@ function d(t) {
|
|
|
103
183
|
}
|
|
104
184
|
return i;
|
|
105
185
|
}
|
|
106
|
-
|
|
186
|
+
//#endregion
|
|
187
|
+
//#region src/animation/waapi/options.ts
|
|
188
|
+
var v = {
|
|
107
189
|
normal: "normal",
|
|
108
190
|
reverse: "reverse",
|
|
109
191
|
alternate: "alternate",
|
|
110
192
|
"alternate-reverse": "alternate-reverse"
|
|
111
|
-
},
|
|
193
|
+
}, y = {
|
|
112
194
|
none: "none",
|
|
113
195
|
forwards: "forwards",
|
|
114
196
|
backwards: "backwards",
|
|
115
197
|
both: "both"
|
|
116
|
-
},
|
|
198
|
+
}, b = {
|
|
117
199
|
replace: "replace",
|
|
118
200
|
add: "add",
|
|
119
201
|
accumulate: "accumulate"
|
|
120
|
-
},
|
|
202
|
+
}, x = (e) => {
|
|
121
203
|
for (let t of e.frames) {
|
|
122
204
|
let e = t.composition;
|
|
123
|
-
if (e != null && e !== "replace") return
|
|
205
|
+
if (e != null && e !== "replace") return b[e] ?? "replace";
|
|
124
206
|
}
|
|
125
207
|
return "replace";
|
|
126
208
|
};
|
|
127
|
-
function
|
|
128
|
-
let t = e.options, n =
|
|
209
|
+
function S(e) {
|
|
210
|
+
let t = e.options, n = v[t.direction], r = y[t.fillMode];
|
|
129
211
|
if (n == null) throw TypeError(`Unrecognised animation direction "${t.direction}".`);
|
|
130
212
|
if (r == null) throw TypeError(`Unrecognised animation fill mode "${t.fillMode}".`);
|
|
131
|
-
let i = (e.frames[0]?.timingFunction ?? e.options.timingFunction).css ?? "linear", a =
|
|
213
|
+
let i = (e.frames[0]?.timingFunction ?? e.options.timingFunction).css ?? "linear", a = x(e), o = {
|
|
132
214
|
duration: t.duration,
|
|
133
215
|
delay: t.delay,
|
|
134
216
|
iterations: t.iterationCount === Infinity ? Infinity : t.iterationCount,
|
|
@@ -138,9 +220,11 @@ function g(e) {
|
|
|
138
220
|
};
|
|
139
221
|
return a !== "replace" && (o.composite = a), o;
|
|
140
222
|
}
|
|
141
|
-
|
|
142
|
-
|
|
143
|
-
|
|
223
|
+
//#endregion
|
|
224
|
+
//#region src/animation/waapi/delegation.ts
|
|
225
|
+
async function C(e) {
|
|
226
|
+
let t = _(e), n = S(e), r = e.targets.map((e) => e.animate(t, n));
|
|
227
|
+
e._playback._waAnimations = r, e.playback.loop(async (t) => {
|
|
144
228
|
if (e.done) return !1;
|
|
145
229
|
if (await e.advanceTo(t), e.paused) for (let e of r) e.pause();
|
|
146
230
|
else for (let e of r) e.playState === "paused" && e.play();
|
|
@@ -152,11 +236,11 @@ async function _(e) {
|
|
|
152
236
|
e.restPosition === "final" && typeof t.commitStyles == "function" && t.commitStyles(), t.cancel();
|
|
153
237
|
} catch {}
|
|
154
238
|
} catch {} finally {
|
|
155
|
-
e.playback.stop(), e._waAnimations = [];
|
|
239
|
+
e.playback.stop(), e._playback._waAnimations = [];
|
|
156
240
|
}
|
|
157
241
|
}
|
|
158
|
-
function
|
|
159
|
-
let r =
|
|
242
|
+
function w(e, n) {
|
|
243
|
+
let r = u(e);
|
|
160
244
|
if (!r.eligible) return {
|
|
161
245
|
attached: !1,
|
|
162
246
|
reason: r.reason
|
|
@@ -166,14 +250,14 @@ function v(e, n) {
|
|
|
166
250
|
attached: !1,
|
|
167
251
|
reason: "native scroll/view timeline unavailable (feature absent)"
|
|
168
252
|
};
|
|
169
|
-
let a =
|
|
170
|
-
...
|
|
253
|
+
let a = _(e), o = {
|
|
254
|
+
...S(e),
|
|
171
255
|
timeline: i
|
|
172
256
|
}, s = e.targets.map((e) => e.animate(a, o));
|
|
173
|
-
return e._waAnimations = s, {
|
|
257
|
+
return e._playback._waAnimations = s, {
|
|
174
258
|
attached: !0,
|
|
175
259
|
animations: s
|
|
176
260
|
};
|
|
177
261
|
}
|
|
178
262
|
//#endregion
|
|
179
|
-
export {
|
|
263
|
+
export { i, C as n, u as r, w as t };
|
|
@@ -1,6 +1,10 @@
|
|
|
1
|
-
import {
|
|
2
|
-
|
|
3
|
-
|
|
1
|
+
import { n as e } from "./presets-BG2Fczzq.js";
|
|
2
|
+
import { t } from "./engine-DEVgCTUy.js";
|
|
3
|
+
//#region src/animation/svg/draw-svg.ts
|
|
4
|
+
var n = /* @__PURE__ */ e({
|
|
5
|
+
DrawSVG: () => a,
|
|
6
|
+
fromDrawSVG: () => i
|
|
7
|
+
}), r = (e) => {
|
|
4
8
|
if (typeof e == "number") {
|
|
5
9
|
if (!Number.isFinite(e) || e < 0 || e > 1) throw Error(`fromDrawSVG(): a numeric draw position is a 0..1 fraction, got ${JSON.stringify(e)} — pass a fraction in [0, 1] or a percent string ("0%".."100%").`);
|
|
6
10
|
return e;
|
|
@@ -8,21 +12,21 @@ var t = (e) => {
|
|
|
8
12
|
if (!/^\s*\d*\.?\d+\s*%\s*$/.test(e)) throw Error(`fromDrawSVG(): invalid draw position ${JSON.stringify(e)} — pass a percent string ("0%".."100%") or a 0..1 number.`);
|
|
9
13
|
return parseFloat(e) / 100;
|
|
10
14
|
};
|
|
11
|
-
function
|
|
12
|
-
let { from: i = "0%", to: a = "100%", autoPlay: o = !0, ...s } =
|
|
13
|
-
if (
|
|
14
|
-
let c =
|
|
15
|
-
|
|
15
|
+
function i(e, n = {}) {
|
|
16
|
+
let { from: i = "0%", to: a = "100%", autoPlay: o = !0, ...s } = n;
|
|
17
|
+
if (e == null || typeof e.getTotalLength != "function") throw Error("fromDrawSVG(): `target` must be an SVG geometry element exposing getTotalLength() (a <path>/<line>/<circle>/<rect>/<polygon>/…).");
|
|
18
|
+
let c = r(i), l = r(a), u = e.getTotalLength();
|
|
19
|
+
e.style.strokeDasharray = `${u}`;
|
|
16
20
|
let d = {
|
|
17
21
|
"0%": { "stroke-dashoffset": u * (1 - c) },
|
|
18
22
|
"100%": { "stroke-dashoffset": u * (1 - l) }
|
|
19
|
-
}, f = new
|
|
20
|
-
return f.setTargets(
|
|
23
|
+
}, f = new t(s).fromKeyframes(d);
|
|
24
|
+
return f.setTargets(e), o && f.play(), f;
|
|
21
25
|
}
|
|
22
|
-
var
|
|
26
|
+
var a = class {
|
|
23
27
|
animation;
|
|
24
28
|
constructor(e, t = {}) {
|
|
25
|
-
this.animation =
|
|
29
|
+
this.animation = i(e, t);
|
|
26
30
|
}
|
|
27
31
|
play() {
|
|
28
32
|
return this.animation.play();
|
|
@@ -38,4 +42,4 @@ var r = class {
|
|
|
38
42
|
}
|
|
39
43
|
};
|
|
40
44
|
//#endregion
|
|
41
|
-
export {
|
|
45
|
+
export { n, i as r, a as t };
|
|
@@ -0,0 +1,27 @@
|
|
|
1
|
+
import { CSSCubicBezier as e, cssLinear as t, parseLinearStops as n, parseSteps as r, steppedEase as i, timingFunctions as a } from "@mkbabb/value.js";
|
|
2
|
+
//#region src/animation/compile/easing-registry.ts
|
|
3
|
+
var o = /^\s*cubic-bezier\s*\(\s*(-?[\d.]+)\s*,\s*(-?[\d.]+)\s*,\s*(-?[\d.]+)\s*,\s*(-?[\d.]+)\s*\)\s*$/i, s = /^\s*steps\s*\(/i, c = /^\s*linear\s*\(/i, l = (l) => {
|
|
4
|
+
if (l == null) return;
|
|
5
|
+
if (typeof l != "string") return l;
|
|
6
|
+
let u = l.match(o);
|
|
7
|
+
if (u) {
|
|
8
|
+
let t = u.slice(1, 5).map((e) => Number.parseFloat(e ?? ""));
|
|
9
|
+
if (t.length === 4 && t.every((e) => Number.isFinite(e))) {
|
|
10
|
+
let [n, r, i, a] = t;
|
|
11
|
+
return e(n, r, i, a);
|
|
12
|
+
}
|
|
13
|
+
}
|
|
14
|
+
if (s.test(l)) try {
|
|
15
|
+
let { count: e, jumpTerm: t } = r(l);
|
|
16
|
+
return i(e, t);
|
|
17
|
+
} catch {}
|
|
18
|
+
if (l === "step-start") return i(1, "jump-start");
|
|
19
|
+
if (l === "step-end") return i(1, "jump-end");
|
|
20
|
+
if (c.test(l)) try {
|
|
21
|
+
return t(n(l));
|
|
22
|
+
} catch {}
|
|
23
|
+
let d = a[l];
|
|
24
|
+
if (typeof d == "function" && d.length <= 1) return d;
|
|
25
|
+
};
|
|
26
|
+
//#endregion
|
|
27
|
+
export { l as t };
|