@mkbabb/keyframes.js 5.1.0 → 5.3.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 +98 -8
- package/dist/easing-registry-BAgudUsG.js +2 -0
- package/dist/{easing-registry-DHV2-5gA.js → easing-registry-BlbS88NR.js} +2 -2
- package/dist/engine/index.d.ts +570 -323
- package/dist/engine/index.js +3710 -17
- package/dist/keyframes.d.ts +1043 -454
- package/dist/keyframes.js +277 -107
- package/dist/{sequence-C_DCiOIQ.js → sequence-CES7o7hs.js} +258 -182
- package/package.json +104 -100
- package/dist/animation-BGyzfzBq.js +0 -947
- package/dist/compile-CcSUwM8R.js +0 -276
- package/dist/delegation-DWwr4IXr.js +0 -263
- package/dist/draw-svg-GURj9nin.js +0 -45
- package/dist/easing-registry-y1p9McFy.js +0 -2
- package/dist/engine-DEVgCTUy.js +0 -156
- package/dist/engine-DrBtsKaf.js +0 -4
- package/dist/format-C-Gi9r7L.js +0 -123
- package/dist/grammar-BLucehC4.js +0 -23
- package/dist/group-vJcsHKN9.js +0 -360
- package/dist/ingest-S5hUe20K.js +0 -166
- package/dist/morph-svg-BToeumw5.js +0 -89
- package/dist/motion-path-pQVbamWT.js +0 -35
- package/dist/parse-flatten-DRMHFytp.js +0 -2
- package/dist/parse-flatten-ZZUSEQEL.js +0 -63
- package/dist/presets-BG2Fczzq.js +0 -275
- package/dist/scheduler-CUtVnuoU.js +0 -14
- package/dist/scroll-CxpYFO4u.js +0 -180
- package/dist/validate-DDeGnvSt.js +0 -39
package/dist/compile-CcSUwM8R.js
DELETED
|
@@ -1,276 +0,0 @@
|
|
|
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,263 +0,0 @@
|
|
|
1
|
-
import { f as e, i as t } from "./sequence-C_DCiOIQ.js";
|
|
2
|
-
import { COMPUTED_UNITS as n, unflattenObjectToString as r } from "@mkbabb/value.js";
|
|
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([
|
|
22
|
-
...n,
|
|
23
|
-
"%",
|
|
24
|
-
"vh",
|
|
25
|
-
"vw",
|
|
26
|
-
"vmin",
|
|
27
|
-
"vmax",
|
|
28
|
-
"vi",
|
|
29
|
-
"vb",
|
|
30
|
-
"svh",
|
|
31
|
-
"svw",
|
|
32
|
-
"svmin",
|
|
33
|
-
"svmax",
|
|
34
|
-
"svi",
|
|
35
|
-
"svb",
|
|
36
|
-
"lvh",
|
|
37
|
-
"lvw",
|
|
38
|
-
"lvmin",
|
|
39
|
-
"lvmax",
|
|
40
|
-
"lvi",
|
|
41
|
-
"lvb",
|
|
42
|
-
"dvh",
|
|
43
|
-
"dvw",
|
|
44
|
-
"dvmin",
|
|
45
|
-
"dvmax",
|
|
46
|
-
"dvi",
|
|
47
|
-
"dvb",
|
|
48
|
-
"cqw",
|
|
49
|
-
"cqh",
|
|
50
|
-
"cqi",
|
|
51
|
-
"cqb",
|
|
52
|
-
"cqmin",
|
|
53
|
-
"cqmax"
|
|
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) {
|
|
56
|
-
if (!e.targets || e.targets.length === 0) return {
|
|
57
|
-
eligible: !1,
|
|
58
|
-
reason: "no DOM targets"
|
|
59
|
-
};
|
|
60
|
-
if (typeof e.targets[0]?.animate != "function") return {
|
|
61
|
-
eligible: !1,
|
|
62
|
-
reason: "target does not implement Element.animate()"
|
|
63
|
-
};
|
|
64
|
-
for (let t of e.frames) if (!e.usesDefaultRenderer(t.transform)) return {
|
|
65
|
-
eligible: !1,
|
|
66
|
-
reason: "custom transform function (not the default DOM renderer)"
|
|
67
|
-
};
|
|
68
|
-
let t = e.frames[0]?.timingFunction;
|
|
69
|
-
if (t && e.frames.length > 1) {
|
|
70
|
-
for (let n = 1; n < e.frames.length; n++) if (e.frames[n].timingFunction.fn !== t.fn) return {
|
|
71
|
-
eligible: !1,
|
|
72
|
-
reason: "non-uniform per-frame timing function (WAAPI supports one easing per animation)"
|
|
73
|
-
};
|
|
74
|
-
if (t.css !== void 0) return {
|
|
75
|
-
eligible: !1,
|
|
76
|
-
reason: "CSS-twinned easing across multiple segments (WAAPI restarts the curve per segment)"
|
|
77
|
-
};
|
|
78
|
-
}
|
|
79
|
-
if (t && t.css === void 0) return {
|
|
80
|
-
eligible: !1,
|
|
81
|
-
reason: "easing has no faithful CSS twin (would run bare linear on the compositor)"
|
|
82
|
-
};
|
|
83
|
-
if (t?.css?.startsWith("linear(") && l()) return {
|
|
84
|
-
eligible: !1,
|
|
85
|
-
reason: "WebKit refuses HW-accel for linear() easing — the spring twin stays on the rAF path (CE-1.0)"
|
|
86
|
-
};
|
|
87
|
-
for (let t of e.frames) for (let [e, n] of Object.entries(t.interpVars)) {
|
|
88
|
-
let t = c(e);
|
|
89
|
-
for (let e of n) {
|
|
90
|
-
let n = o(e.start?.unit) && !(t && e.start?.unit === "%"), r = o(e.stop?.unit) && !(t && e.stop?.unit === "%");
|
|
91
|
-
if (n || r) return {
|
|
92
|
-
eligible: !1,
|
|
93
|
-
reason: `layout-dependent unit (${String(e.start?.unit ?? e.stop?.unit)}) would freeze to px under WAAPI`
|
|
94
|
-
};
|
|
95
|
-
if (e.start?.unit === "color" || e.stop?.unit === "color") return {
|
|
96
|
-
eligible: !1,
|
|
97
|
-
reason: "color interpolation requires perceptual lerp"
|
|
98
|
-
};
|
|
99
|
-
}
|
|
100
|
-
}
|
|
101
|
-
return { eligible: !0 };
|
|
102
|
-
}
|
|
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) {
|
|
171
|
-
let n = t.options.duration, i = [], a = /* @__PURE__ */ new Set();
|
|
172
|
-
for (let e of t.frames) a.add(e.time.start), a.add(e.time.stop);
|
|
173
|
-
let o = [...a].sort((e, t) => e - t), s = new Set(o);
|
|
174
|
-
for (let e of g(t, o, n)) s.add(e);
|
|
175
|
-
for (let a of [...s].sort((e, t) => e - t)) {
|
|
176
|
-
let o = t.interpFrames(a, !1);
|
|
177
|
-
if (Object.keys(o).length === 0) continue;
|
|
178
|
-
let s = r(o);
|
|
179
|
-
i.push({
|
|
180
|
-
offset: e(a / n, 0, 1),
|
|
181
|
-
...s
|
|
182
|
-
});
|
|
183
|
-
}
|
|
184
|
-
return i;
|
|
185
|
-
}
|
|
186
|
-
//#endregion
|
|
187
|
-
//#region src/animation/waapi/options.ts
|
|
188
|
-
var v = {
|
|
189
|
-
normal: "normal",
|
|
190
|
-
reverse: "reverse",
|
|
191
|
-
alternate: "alternate",
|
|
192
|
-
"alternate-reverse": "alternate-reverse"
|
|
193
|
-
}, y = {
|
|
194
|
-
none: "none",
|
|
195
|
-
forwards: "forwards",
|
|
196
|
-
backwards: "backwards",
|
|
197
|
-
both: "both"
|
|
198
|
-
}, b = {
|
|
199
|
-
replace: "replace",
|
|
200
|
-
add: "add",
|
|
201
|
-
accumulate: "accumulate"
|
|
202
|
-
}, x = (e) => {
|
|
203
|
-
for (let t of e.frames) {
|
|
204
|
-
let e = t.composition;
|
|
205
|
-
if (e != null && e !== "replace") return b[e] ?? "replace";
|
|
206
|
-
}
|
|
207
|
-
return "replace";
|
|
208
|
-
};
|
|
209
|
-
function S(e) {
|
|
210
|
-
let t = e.options, n = v[t.direction], r = y[t.fillMode];
|
|
211
|
-
if (n == null) throw TypeError(`Unrecognised animation direction "${t.direction}".`);
|
|
212
|
-
if (r == null) throw TypeError(`Unrecognised animation fill mode "${t.fillMode}".`);
|
|
213
|
-
let i = (e.frames[0]?.timingFunction ?? e.options.timingFunction).css ?? "linear", a = x(e), o = {
|
|
214
|
-
duration: t.duration,
|
|
215
|
-
delay: t.delay,
|
|
216
|
-
iterations: t.iterationCount === Infinity ? Infinity : t.iterationCount,
|
|
217
|
-
direction: n,
|
|
218
|
-
fill: r,
|
|
219
|
-
easing: i
|
|
220
|
-
};
|
|
221
|
-
return a !== "replace" && (o.composite = a), o;
|
|
222
|
-
}
|
|
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) => {
|
|
228
|
-
if (e.done) return !1;
|
|
229
|
-
if (await e.advanceTo(t), e.paused) for (let e of r) e.pause();
|
|
230
|
-
else for (let e of r) e.playState === "paused" && e.play();
|
|
231
|
-
return !e.done;
|
|
232
|
-
});
|
|
233
|
-
try {
|
|
234
|
-
await Promise.all(r.map((e) => e.finished));
|
|
235
|
-
for (let t of r) try {
|
|
236
|
-
e.restPosition === "final" && typeof t.commitStyles == "function" && t.commitStyles(), t.cancel();
|
|
237
|
-
} catch {}
|
|
238
|
-
} catch {} finally {
|
|
239
|
-
e.playback.stop(), e._playback._waAnimations = [];
|
|
240
|
-
}
|
|
241
|
-
}
|
|
242
|
-
function w(e, n) {
|
|
243
|
-
let r = u(e);
|
|
244
|
-
if (!r.eligible) return {
|
|
245
|
-
attached: !1,
|
|
246
|
-
reason: r.reason
|
|
247
|
-
};
|
|
248
|
-
let i = t(n);
|
|
249
|
-
if (i == null) return {
|
|
250
|
-
attached: !1,
|
|
251
|
-
reason: "native scroll/view timeline unavailable (feature absent)"
|
|
252
|
-
};
|
|
253
|
-
let a = _(e), o = {
|
|
254
|
-
...S(e),
|
|
255
|
-
timeline: i
|
|
256
|
-
}, s = e.targets.map((e) => e.animate(a, o));
|
|
257
|
-
return e._playback._waAnimations = s, {
|
|
258
|
-
attached: !0,
|
|
259
|
-
animations: s
|
|
260
|
-
};
|
|
261
|
-
}
|
|
262
|
-
//#endregion
|
|
263
|
-
export { i, C as n, u as r, w as t };
|
|
@@ -1,45 +0,0 @@
|
|
|
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) => {
|
|
8
|
-
if (typeof e == "number") {
|
|
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%").`);
|
|
10
|
-
return e;
|
|
11
|
-
}
|
|
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.`);
|
|
13
|
-
return parseFloat(e) / 100;
|
|
14
|
-
};
|
|
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}`;
|
|
20
|
-
let d = {
|
|
21
|
-
"0%": { "stroke-dashoffset": u * (1 - c) },
|
|
22
|
-
"100%": { "stroke-dashoffset": u * (1 - l) }
|
|
23
|
-
}, f = new t(s).fromKeyframes(d);
|
|
24
|
-
return f.setTargets(e), o && f.play(), f;
|
|
25
|
-
}
|
|
26
|
-
var a = class {
|
|
27
|
-
animation;
|
|
28
|
-
constructor(e, t = {}) {
|
|
29
|
-
this.animation = i(e, t);
|
|
30
|
-
}
|
|
31
|
-
play() {
|
|
32
|
-
return this.animation.play();
|
|
33
|
-
}
|
|
34
|
-
pause() {
|
|
35
|
-
return this.animation.pause(), this;
|
|
36
|
-
}
|
|
37
|
-
stop() {
|
|
38
|
-
return this.animation.stop(), this;
|
|
39
|
-
}
|
|
40
|
-
get finished() {
|
|
41
|
-
return this.animation.finished;
|
|
42
|
-
}
|
|
43
|
-
};
|
|
44
|
-
//#endregion
|
|
45
|
-
export { n, i as r, a as t };
|