@mkbabb/keyframes.js 5.1.0 → 5.2.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 +83 -3
- package/dist/backward-color-BtbRcnna.js +108 -0
- package/dist/compile-BHCTPerD.js +30 -0
- package/dist/{delegation-DWwr4IXr.js → delegation-BQYCrP2p.js} +5 -9
- package/dist/{draw-svg-GURj9nin.js → draw-svg-CK9Qrly8.js} +13 -25
- package/dist/easing-serialize-D4LZCB6i.js +21 -0
- package/dist/engine/index.d.ts +422 -156
- package/dist/engine/index.js +16 -17
- package/dist/engine-CPK_udUQ.js +1172 -0
- package/dist/engine-DlpimZtM.js +3 -0
- package/dist/entry-D82NKUhP.js +148 -0
- package/dist/format-BdIvdLzG.js +114 -0
- package/dist/{group-vJcsHKN9.js → group-HM7N4uOE.js} +153 -123
- package/dist/handle-D4xrf_ya.js +21 -0
- package/dist/{ingest-S5hUe20K.js → ingest-_g6tfk2e.js} +2 -2
- package/dist/keyframes.d.ts +702 -178
- package/dist/keyframes.js +295 -74
- package/dist/morph-svg-KUrH9KnK.js +79 -0
- package/dist/motion-path-wM5tPfrY.js +26 -0
- package/dist/presets-DeDJYL4G.js +275 -0
- package/dist/{scheduler-CUtVnuoU.js → scheduler-CfGIC3GX.js} +1 -1
- package/dist/{scroll-CxpYFO4u.js → scroll-BEyCx0b_.js} +165 -58
- package/dist/{sequence-C_DCiOIQ.js → sequence-s0bL7Uul.js} +118 -90
- package/dist/{validate-DDeGnvSt.js → validate-xFZ_Ld1k.js} +7 -7
- package/dist/view-transition-BPJQxUTC.js +305 -0
- package/package.json +113 -83
- package/dist/animation-BGyzfzBq.js +0 -947
- package/dist/compile-CcSUwM8R.js +0 -276
- 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/morph-svg-BToeumw5.js +0 -89
- package/dist/motion-path-pQVbamWT.js +0 -35
- package/dist/presets-BG2Fczzq.js +0 -275
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 };
|
package/dist/engine-DEVgCTUy.js
DELETED
|
@@ -1,156 +0,0 @@
|
|
|
1
|
-
import { g as e } from "./sequence-C_DCiOIQ.js";
|
|
2
|
-
import { a as t, i as n, o as r, r as i, t as a, u as o } from "./animation-BGyzfzBq.js";
|
|
3
|
-
import { r as s } from "./parse-flatten-ZZUSEQEL.js";
|
|
4
|
-
import { t as c } from "./easing-registry-DHV2-5gA.js";
|
|
5
|
-
import { ValueArray as l, ValueUnit as u, extractAnimationOptions as d, extractFunctions as f, extractKeyframes as p, extractProperties as m, extractTimelineOptions as h, isObject as g, parseCSSStylesheet as _ } from "@mkbabb/value.js";
|
|
6
|
-
//#region src/animation/adapter.ts
|
|
7
|
-
var v = (e, r) => {
|
|
8
|
-
let a = {};
|
|
9
|
-
for (let o of e.declarations) {
|
|
10
|
-
let e = o.value;
|
|
11
|
-
if (e instanceof l && i(e)) {
|
|
12
|
-
let i = n(e, r);
|
|
13
|
-
if (i === t) continue;
|
|
14
|
-
e = i;
|
|
15
|
-
}
|
|
16
|
-
a[o.name] = e;
|
|
17
|
-
}
|
|
18
|
-
return a;
|
|
19
|
-
}, y = (e) => {
|
|
20
|
-
let t = [];
|
|
21
|
-
for (let n of e.selectors) n.kind === "percent" ? t.push(`${n.value}%`) : t.push(n.name);
|
|
22
|
-
return t;
|
|
23
|
-
}, b = (e) => {
|
|
24
|
-
let t = p(e);
|
|
25
|
-
for (let e of t.values()) if (e.length > 0) return e;
|
|
26
|
-
return [];
|
|
27
|
-
}, x = (e, t) => {
|
|
28
|
-
let n = [], i = (e, t) => {
|
|
29
|
-
n.push({
|
|
30
|
-
code: e,
|
|
31
|
-
message: t.message ?? e,
|
|
32
|
-
...t
|
|
33
|
-
});
|
|
34
|
-
}, a = typeof e == "string" ? _(e) : e, o = b(a);
|
|
35
|
-
typeof e == "string" && o.length === 0 && e.trim() && (a = _(`@keyframes anonymous {\n${e.trim()}\n}`), o = b(a)), typeof e == "string" && o.length === 0 && e.trim() && i("EMPTY_PARSE", {
|
|
36
|
-
message: "the input is non-empty but parsed to zero @keyframes rules (no animatable stops) — the resulting animation has no frames",
|
|
37
|
-
input: e
|
|
38
|
-
});
|
|
39
|
-
let s = /* @__PURE__ */ new Map(), c = /* @__PURE__ */ new Map(), l = /* @__PURE__ */ new Map(), u = f(a), p = r(u, t, n);
|
|
40
|
-
for (let e of o) {
|
|
41
|
-
let t = v(e, p);
|
|
42
|
-
for (let n of y(e)) {
|
|
43
|
-
let r = s.get(n);
|
|
44
|
-
s.set(n, {
|
|
45
|
-
...r ?? {},
|
|
46
|
-
...t
|
|
47
|
-
}), e.timingFunction != null && c.set(n, e.timingFunction);
|
|
48
|
-
let i = e.composition;
|
|
49
|
-
i != null && l.set(n, i);
|
|
50
|
-
}
|
|
51
|
-
}
|
|
52
|
-
return {
|
|
53
|
-
keyframes: s,
|
|
54
|
-
timingFunctions: c,
|
|
55
|
-
composition: l,
|
|
56
|
-
properties: m(a),
|
|
57
|
-
functions: u,
|
|
58
|
-
options: d(a),
|
|
59
|
-
diagnostics: n,
|
|
60
|
-
stylesheet: a
|
|
61
|
-
};
|
|
62
|
-
};
|
|
63
|
-
//#endregion
|
|
64
|
-
//#region src/animation/engine/css-metadata.ts
|
|
65
|
-
function S(e) {
|
|
66
|
-
let t = {};
|
|
67
|
-
return e.duration != null && (t.duration = e.duration), e.timingFunction != null && (t.timingFunction = e.timingFunction), e.iterationCount !== void 0 && (t.iterationCount = e.iterationCount === null ? Infinity : e.iterationCount), e.direction != null && (t.direction = e.direction), e.delay != null && (t.delay = e.delay), e.fillMode != null && (t.fillMode = e.fillMode), e.composition != null && (t.composite = e.composition), t;
|
|
68
|
-
}
|
|
69
|
-
function C(e) {
|
|
70
|
-
let t = h(e);
|
|
71
|
-
return Object.keys(t).length > 0 ? t : void 0;
|
|
72
|
-
}
|
|
73
|
-
function w(e, t) {
|
|
74
|
-
if (!(typeof CSS > "u" || typeof CSS.registerProperty != "function")) for (let [n, r] of e) {
|
|
75
|
-
if (r.syntax == null) continue;
|
|
76
|
-
let e = {
|
|
77
|
-
name: n,
|
|
78
|
-
syntax: r.syntax,
|
|
79
|
-
inherits: r.inherits ?? !1
|
|
80
|
-
};
|
|
81
|
-
r.initialValue != null && (e.initialValue = r.initialValue.toString());
|
|
82
|
-
try {
|
|
83
|
-
CSS.registerProperty(e);
|
|
84
|
-
} catch (e) {
|
|
85
|
-
if (e instanceof DOMException && e.name === "InvalidModificationError") continue;
|
|
86
|
-
t.push({
|
|
87
|
-
code: "PROPERTY_REGISTER_REJECTED",
|
|
88
|
-
property: n,
|
|
89
|
-
message: `CSS.registerProperty refused @property ${n}: ${String(e)}`
|
|
90
|
-
});
|
|
91
|
-
}
|
|
92
|
-
}
|
|
93
|
-
}
|
|
94
|
-
//#endregion
|
|
95
|
-
//#region src/animation/engine/css-animation.ts
|
|
96
|
-
var T = (e) => typeof e != "object" || !e ? !1 : typeof e.clone == "function", E = class extends a {
|
|
97
|
-
_boundTimeline;
|
|
98
|
-
constructor(e, ...t) {
|
|
99
|
-
super(e, t), this.unflatten = !1;
|
|
100
|
-
}
|
|
101
|
-
bindTimeline(e) {
|
|
102
|
-
this._boundTimeline = e;
|
|
103
|
-
let t = !1;
|
|
104
|
-
for (let e of this.compiler.templateFrames) e.start.superType?.includes("named-selector") && (e.start = new u(o(String(e.start.value)) * 100, "%"), t = !0);
|
|
105
|
-
return t && this.compiler.frames.length > 0 && this.parse(), this;
|
|
106
|
-
}
|
|
107
|
-
resolveTransform(e) {
|
|
108
|
-
return this.unflatten = e != null, e ?? this._defaultTransform;
|
|
109
|
-
}
|
|
110
|
-
fromVars(e, t) {
|
|
111
|
-
t = this.resolveTransform(t);
|
|
112
|
-
for (let n = 0; n < e.length; n++) {
|
|
113
|
-
let r = e[n], i = Math.round(n / (e.length - 1) * 100);
|
|
114
|
-
this.addFrame(i, r, t);
|
|
115
|
-
}
|
|
116
|
-
return this.parse(), this;
|
|
117
|
-
}
|
|
118
|
-
fromKeyframes(e, t) {
|
|
119
|
-
t = this.resolveTransform(t), g(e) && (e = new Map(Object.entries(e)));
|
|
120
|
-
let n = e instanceof Map ? e.entries() : Object.entries(e);
|
|
121
|
-
for (let [e, r] of n) this.addFrame(e, r, t);
|
|
122
|
-
return this.parse(), this;
|
|
123
|
-
}
|
|
124
|
-
propertyRegistry = /* @__PURE__ */ new Map();
|
|
125
|
-
scrollOptions;
|
|
126
|
-
fromString(t, n) {
|
|
127
|
-
n = this.resolveTransform(n);
|
|
128
|
-
let r = x(t);
|
|
129
|
-
this.propertyRegistry = r.properties;
|
|
130
|
-
let i = C(r.stylesheet);
|
|
131
|
-
i === void 0 ? delete this.scrollOptions : this.scrollOptions = i, this.diagnostics = [...r.diagnostics];
|
|
132
|
-
let a = S(r.options);
|
|
133
|
-
Object.keys(a).length > 0 && this.setOptions({
|
|
134
|
-
...a,
|
|
135
|
-
...this._ctorOptions
|
|
136
|
-
});
|
|
137
|
-
for (let [t, i] of r.keyframes.entries()) {
|
|
138
|
-
let a = Object.fromEntries(Object.entries(i).map(([e, t]) => [e, T(t) ? t.clone() : t])), o = r.timingFunctions.get(t), s = o ? c(o) : void 0, l;
|
|
139
|
-
if (s) {
|
|
140
|
-
let t = o ? e(o) : void 0;
|
|
141
|
-
l = t ? {
|
|
142
|
-
fn: s,
|
|
143
|
-
css: t
|
|
144
|
-
} : { fn: s };
|
|
145
|
-
}
|
|
146
|
-
let u = r.composition.get(t);
|
|
147
|
-
this.addFrame(t, a, n, l, u);
|
|
148
|
-
}
|
|
149
|
-
return this.parse(), w(this.propertyRegistry, this.diagnostics), this;
|
|
150
|
-
}
|
|
151
|
-
transform(e) {
|
|
152
|
-
s(e, this.targets);
|
|
153
|
-
}
|
|
154
|
-
};
|
|
155
|
-
//#endregion
|
|
156
|
-
export { x as n, E as t };
|
package/dist/engine-DrBtsKaf.js
DELETED
|
@@ -1,4 +0,0 @@
|
|
|
1
|
-
import { f as e, g as t, h as n, n as r, p as i, t as a } from "./animation-BGyzfzBq.js";
|
|
2
|
-
import { t as o } from "./easing-registry-DHV2-5gA.js";
|
|
3
|
-
import { n as s, t as c } from "./engine-DEVgCTUy.js";
|
|
4
|
-
export { c as CSSKeyframesAnimation, e as DIRECTIONS, i as FILL_MODES, a as KeyframesAnimation, n as defaultLayerConfig, t as defaultOptions, r as getAnimationId, o as getTimingFunction, s as resolveKeyframes };
|
package/dist/format-C-Gi9r7L.js
DELETED
|
@@ -1,123 +0,0 @@
|
|
|
1
|
-
import { n as e } from "./presets-BG2Fczzq.js";
|
|
2
|
-
import { y as t } from "./sequence-C_DCiOIQ.js";
|
|
3
|
-
import { camelCaseToHyphen as n, formatCSS as r, reverseAnimationShorthand as i, reverseCSSTime as a, serializeStylesheetItem as o, timingFunctions as s, unflattenObjectToString as c } from "@mkbabb/value.js";
|
|
4
|
-
//#region src/animation/compile/format.ts
|
|
5
|
-
var l = /* @__PURE__ */ e({
|
|
6
|
-
CSSKeyframesToString: () => w,
|
|
7
|
-
CSSKeyframesToStrings: () => h,
|
|
8
|
-
animationComposition: () => S,
|
|
9
|
-
animationOptionsToString: () => _,
|
|
10
|
-
animationShorthand: () => x,
|
|
11
|
-
declaredKeyframeBodyFor: () => v,
|
|
12
|
-
formatCSSKeyframeString: () => g,
|
|
13
|
-
keyframesBlock: () => y,
|
|
14
|
-
premultipliedKeyframesBlock: () => b,
|
|
15
|
-
serializeEasing: () => u
|
|
16
|
-
});
|
|
17
|
-
function u(e) {
|
|
18
|
-
if (e.css !== void 0) return e.css;
|
|
19
|
-
let r = Object.entries(s).find(([t, n]) => n === e.fn)?.[0];
|
|
20
|
-
if (r === void 0) throw new t("timingFunction", e.fn, "a custom TimingFunction has no CSS animation-timing-function representation — attach a faithful Easing.css twin, or use a registry name / cubic-bezier() / linear() literal");
|
|
21
|
-
return n(r);
|
|
22
|
-
}
|
|
23
|
-
var d = 80, f = "@keyframes animation {\n", p = "\n}";
|
|
24
|
-
function m(e, t, r) {
|
|
25
|
-
let i = e.parsedVars[t] ?? {}, a = e.templateFrames[t], o = Object.entries(c(i)).map(([e, t]) => ` ${n(e)}: ${t};`), s = a.timingFunction ? u(a.timingFunction) : r;
|
|
26
|
-
s !== r && o.push(` animation-timing-function: ${s};`);
|
|
27
|
-
let l = a.composition;
|
|
28
|
-
return l != null && l !== "replace" && o.push(` animation-composition: ${l};`), `{\n${o.join("\n").trim()}\n}`;
|
|
29
|
-
}
|
|
30
|
-
var h = async (e) => {
|
|
31
|
-
let t = u(e.options.timingFunction), n = e.templateFrames.map(async (n, i) => {
|
|
32
|
-
let a = m(e, i, t);
|
|
33
|
-
return a = `${n.start}\n${a}\n`, a = f + a + p, a = await r(a, d), a.replace(f, "").replace(p, "");
|
|
34
|
-
});
|
|
35
|
-
return Promise.all(n);
|
|
36
|
-
};
|
|
37
|
-
function g(e) {
|
|
38
|
-
let t = e.replace(/^[^{]*{/, "").replace(/^ /gm, "").replace(/}\s*$/, "");
|
|
39
|
-
return t = t.trim(), t = t.replace(/^ /, ""), t;
|
|
40
|
-
}
|
|
41
|
-
function _(e, t = "animation") {
|
|
42
|
-
let n = "";
|
|
43
|
-
n += ` animation-name: ${t};\n`;
|
|
44
|
-
let r = a(e.duration);
|
|
45
|
-
n += ` animation-duration: ${r};\n`, n += ` animation-timing-function: ${u(e.timingFunction)};\n`, n += ` animation-iteration-count: ${isFinite(e.iterationCount) ? e.iterationCount : "infinite"};\n`, n += ` animation-direction: ${e.direction};\n`, n += ` animation-fill-mode: ${e.fillMode};\n`, e.delay > 0 && (n += ` animation-delay: ${a(e.delay)};\n`);
|
|
46
|
-
let i = e.composite == null ? void 0 : S(e.composite);
|
|
47
|
-
return i != null && (n += ` ${i}\n`), n = `.${t} {\n${n}}\n`, n;
|
|
48
|
-
}
|
|
49
|
-
function v(e, t, n) {
|
|
50
|
-
return m(e, t, n);
|
|
51
|
-
}
|
|
52
|
-
function y(e, t, n) {
|
|
53
|
-
let r = u(e.options.timingFunction), i = /* @__PURE__ */ new Map();
|
|
54
|
-
e.templateFrames.forEach((t, a) => {
|
|
55
|
-
let o = n?.get(a) ?? m(e, a, r), s = i.get(o);
|
|
56
|
-
s ? s.push(t.start) : i.set(o, [t.start]);
|
|
57
|
-
});
|
|
58
|
-
let a = "";
|
|
59
|
-
for (let [e, t] of i) a += `${t.join(", ")} ${e}\n`;
|
|
60
|
-
return `@keyframes ${t} {\n${a}}`;
|
|
61
|
-
}
|
|
62
|
-
function b(e, t, r) {
|
|
63
|
-
let i = u(e.options.timingFunction), a = /* @__PURE__ */ new Map();
|
|
64
|
-
for (let t = 0; t < e.templateFrames.length; t++) {
|
|
65
|
-
let o = e.templateFrames[t], s = e.parsedVars[t] ?? {}, l = {};
|
|
66
|
-
for (let [e, t] of Object.entries(s)) {
|
|
67
|
-
let n = t.clone();
|
|
68
|
-
for (let t of n) if (typeof t.value == "number") t.value *= r;
|
|
69
|
-
else if (t.unit === "color" || typeof t.value == "string") return {
|
|
70
|
-
refused: !0,
|
|
71
|
-
key: e
|
|
72
|
-
};
|
|
73
|
-
l[e] = n;
|
|
74
|
-
}
|
|
75
|
-
let d = Object.entries(c(l)).map(([e, t]) => ` ${n(e)}: ${t};`), f = o.timingFunction ? u(o.timingFunction) : i;
|
|
76
|
-
f !== i && d.push(` animation-timing-function: ${f};`);
|
|
77
|
-
let p = o.composition;
|
|
78
|
-
p != null && p !== "replace" && d.push(` animation-composition: ${p};`);
|
|
79
|
-
let m = `{\n${d.join("\n").trim()}\n}`, h = a.get(m);
|
|
80
|
-
h ? h.push(o.start) : a.set(m, [o.start]);
|
|
81
|
-
}
|
|
82
|
-
let o = "";
|
|
83
|
-
for (let [e, t] of a) o += `${t.join(", ")} ${e}\n`;
|
|
84
|
-
return { block: `@keyframes ${t} {\n${o}}` };
|
|
85
|
-
}
|
|
86
|
-
function x(e, t) {
|
|
87
|
-
let n = {
|
|
88
|
-
name: t,
|
|
89
|
-
duration: e.duration,
|
|
90
|
-
timingFunction: u(e.timingFunction),
|
|
91
|
-
iterationCount: isFinite(e.iterationCount) ? e.iterationCount : Infinity,
|
|
92
|
-
direction: e.direction,
|
|
93
|
-
fillMode: e.fillMode
|
|
94
|
-
};
|
|
95
|
-
return e.delay > 0 && (n.delay = e.delay), i(n);
|
|
96
|
-
}
|
|
97
|
-
function S(e) {
|
|
98
|
-
return e === "replace" ? void 0 : `animation-composition: ${e};`;
|
|
99
|
-
}
|
|
100
|
-
function C(e) {
|
|
101
|
-
let t = e.propertyRegistry;
|
|
102
|
-
if (t == null || t.size === 0) return "";
|
|
103
|
-
let n = [];
|
|
104
|
-
for (let [e, r] of t) n.push(o({
|
|
105
|
-
kind: "property",
|
|
106
|
-
name: e,
|
|
107
|
-
descriptor: r
|
|
108
|
-
}));
|
|
109
|
-
return n.join("\n");
|
|
110
|
-
}
|
|
111
|
-
async function w(e, t = "animation", n = void 0) {
|
|
112
|
-
let i = e.options, a = /* @__PURE__ */ new Map(), o = u(i.timingFunction);
|
|
113
|
-
e.templateFrames.forEach((t, n) => {
|
|
114
|
-
let r = t.start, i = m(e, n, o);
|
|
115
|
-
a.has(i) ? a.get(i).push(r) : a.set(i, [r]);
|
|
116
|
-
});
|
|
117
|
-
let s = "";
|
|
118
|
-
for (let [e, t] of a) s += `${t.join(", ")} ${e}`;
|
|
119
|
-
let c = _(i, t), l = C(e);
|
|
120
|
-
return (await r(`${l ? `${l}\n\n` : ""}${c}\n@keyframes ${t} {\n${s}}`, n)).replace(/\(\s*\{/g, "{").replace(/\}\s*\)/g, "}");
|
|
121
|
-
}
|
|
122
|
-
//#endregion
|
|
123
|
-
export { g as a, b as c, x as i, u as l, h as n, l as o, S as r, y as s, w as t };
|
package/dist/grammar-BLucehC4.js
DELETED
|
@@ -1,23 +0,0 @@
|
|
|
1
|
-
import { extractTimelineOptions as e, parseAnimationRange as t, parseAnimationTimeline as n, parseCSSStylesheet as r, serializeTimelineOptions as i } from "@mkbabb/value.js";
|
|
2
|
-
//#region src/animation/scroll/grammar.ts
|
|
3
|
-
function a(e) {
|
|
4
|
-
return n(e);
|
|
5
|
-
}
|
|
6
|
-
function o(e) {
|
|
7
|
-
return t(e);
|
|
8
|
-
}
|
|
9
|
-
function s(t) {
|
|
10
|
-
return e(typeof t == "string" ? r(t) : t);
|
|
11
|
-
}
|
|
12
|
-
function c(e) {
|
|
13
|
-
return i(e);
|
|
14
|
-
}
|
|
15
|
-
function l(e) {
|
|
16
|
-
let t = s(e);
|
|
17
|
-
return {
|
|
18
|
-
options: t,
|
|
19
|
-
declarations: c(t)
|
|
20
|
-
};
|
|
21
|
-
}
|
|
22
|
-
//#endregion
|
|
23
|
-
export { c as a, l as i, o as n, a as r, s as t };
|
|
@@ -1,89 +0,0 @@
|
|
|
1
|
-
import { n as e } from "./presets-BG2Fczzq.js";
|
|
2
|
-
import { y as t } from "./sequence-C_DCiOIQ.js";
|
|
3
|
-
import { t as n } from "./engine-DEVgCTUy.js";
|
|
4
|
-
import { PathGeometry as r } from "@mkbabb/value.js";
|
|
5
|
-
//#region src/animation/svg/morph-svg.ts
|
|
6
|
-
var i = /* @__PURE__ */ e({
|
|
7
|
-
MorphSVG: () => m,
|
|
8
|
-
fromMorphSVG: () => p
|
|
9
|
-
}), a = 64, o = (e) => `--morph-${e}-x`, s = (e) => `--morph-${e}-y`, c = (e) => `--morph-${e}-angle`, l = (e, t, n) => {
|
|
10
|
-
let r = Array(t + 1);
|
|
11
|
-
for (let i = 0; i <= t; i++) if (n) {
|
|
12
|
-
let n = e.sampleAtLength(e.totalLength * (i / t));
|
|
13
|
-
r[i] = {
|
|
14
|
-
x: n.x,
|
|
15
|
-
y: n.y,
|
|
16
|
-
angle: n.angle
|
|
17
|
-
};
|
|
18
|
-
} else r[i] = e.getPointAtT(i / t);
|
|
19
|
-
return r;
|
|
20
|
-
}, u = (e) => Number.isInteger(e) ? `${e}` : e.toFixed(3), d = (e) => {
|
|
21
|
-
if (e.length === 0) return "";
|
|
22
|
-
let t = `M ${u(e[0].x)} ${u(e[0].y)}`;
|
|
23
|
-
for (let n = 1; n < e.length; n++) t += ` L ${u(e[n].x)} ${u(e[n].y)}`;
|
|
24
|
-
return t;
|
|
25
|
-
}, f = (e, t) => {
|
|
26
|
-
let n = Array(t + 1);
|
|
27
|
-
for (let e = 0; e <= t; e++) n[e] = {
|
|
28
|
-
x: 0,
|
|
29
|
-
y: 0
|
|
30
|
-
};
|
|
31
|
-
return (r) => {
|
|
32
|
-
let i = r;
|
|
33
|
-
for (let e = 0; e <= t; e++) {
|
|
34
|
-
let t = n[e], r = i[o(e)]?.[0]?.value, a = i[s(e)]?.[0]?.value;
|
|
35
|
-
if (r === void 0 || a === void 0) throw Error(`morph render: point ${e} lost its coordinate leaf (engine invariant violated — xKey/yKey seeded at construction)`);
|
|
36
|
-
t.x = r, t.y = a;
|
|
37
|
-
}
|
|
38
|
-
let a = d(n);
|
|
39
|
-
e.style.setProperty("--morph-d", a), e.style.setProperty("d", `path("${a}")`);
|
|
40
|
-
};
|
|
41
|
-
};
|
|
42
|
-
function p(e, i, u = {}) {
|
|
43
|
-
let { samples: d = a, target: p, orient: m = !1, autoPlay: h = !0, ...g } = u;
|
|
44
|
-
if (typeof e != "string" || e.length === 0) throw new t("from", e, "fromMorphSVG(): `from` must be a non-empty SVG path `d` string.");
|
|
45
|
-
if (typeof i != "string" || i.length === 0) throw new t("to", i, "fromMorphSVG(): `to` must be a non-empty SVG path `d` string.");
|
|
46
|
-
if (!Number.isInteger(d) || d < 2) throw new t("samples", d, "fromMorphSVG(): `samples` must be an integer >= 2 (a 1-sample morph is just the two endpoints, with no body to interpolate).");
|
|
47
|
-
let _ = new r(e), v = new r(i);
|
|
48
|
-
if (_.totalLength === 0) throw new t("from", e, "fromMorphSVG(): the `from` path has zero arc-length — a morph between a zero-length path and anything is malformed input, not an identity animation.");
|
|
49
|
-
if (v.totalLength === 0) throw new t("to", i, "fromMorphSVG(): the `to` path has zero arc-length — a morph between a zero-length path and anything is malformed input, not an identity animation.");
|
|
50
|
-
let y = l(_, d, m), b = l(v, d, m), x = {}, S = {};
|
|
51
|
-
for (let e = 0; e <= d; e++) x[o(e)] = y[e].x, x[s(e)] = y[e].y, S[o(e)] = b[e].x, S[s(e)] = b[e].y, m && (x[c(e)] = y[e].angle ?? 0, S[c(e)] = b[e].angle ?? 0);
|
|
52
|
-
let C = {
|
|
53
|
-
"0%": x,
|
|
54
|
-
"100%": S
|
|
55
|
-
}, w = p == null ? void 0 : f(p, d), T = new n(g).fromKeyframes(C, w);
|
|
56
|
-
return h && T.play(), T;
|
|
57
|
-
}
|
|
58
|
-
var m = class {
|
|
59
|
-
animation;
|
|
60
|
-
samples;
|
|
61
|
-
constructor(e, t, n = {}) {
|
|
62
|
-
this.animation = p(e, t, n), this.samples = n.samples ?? a;
|
|
63
|
-
}
|
|
64
|
-
sampleD(e) {
|
|
65
|
-
let t = (e < 0 ? 0 : e > 1 ? 1 : e) * this.animation.options.duration, n = this.animation.interpFrames(t, !1), r = Array(this.samples + 1);
|
|
66
|
-
for (let e = 0; e <= this.samples; e++) {
|
|
67
|
-
let t = n[o(e)]?.[0]?.value, i = n[s(e)]?.[0]?.value;
|
|
68
|
-
r[e] = {
|
|
69
|
-
x: t ?? 0,
|
|
70
|
-
y: i ?? 0
|
|
71
|
-
};
|
|
72
|
-
}
|
|
73
|
-
return d(r);
|
|
74
|
-
}
|
|
75
|
-
play() {
|
|
76
|
-
return this.animation.play();
|
|
77
|
-
}
|
|
78
|
-
pause() {
|
|
79
|
-
return this.animation.pause(), this;
|
|
80
|
-
}
|
|
81
|
-
stop() {
|
|
82
|
-
return this.animation.stop(), this;
|
|
83
|
-
}
|
|
84
|
-
get finished() {
|
|
85
|
-
return this.animation.finished;
|
|
86
|
-
}
|
|
87
|
-
};
|
|
88
|
-
//#endregion
|
|
89
|
-
export { p as n, i as r, m as t };
|