@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
|
@@ -0,0 +1,305 @@
|
|
|
1
|
+
import { n as e } from "./presets-DeDJYL4G.js";
|
|
2
|
+
import { t } from "./sequence-s0bL7Uul.js";
|
|
3
|
+
import { i as n } from "./engine-CPK_udUQ.js";
|
|
4
|
+
import { n as r } from "./group-HM7N4uOE.js";
|
|
5
|
+
import { o as i } from "./scroll-BEyCx0b_.js";
|
|
6
|
+
import { t as a } from "./easing-serialize-D4LZCB6i.js";
|
|
7
|
+
import { c as o, l as s, o as c, r as l, s as u } from "./format-BdIvdLzG.js";
|
|
8
|
+
import { i as d, n as f } from "./backward-color-BtbRcnna.js";
|
|
9
|
+
import { camelCaseToHyphen as p, formatCSS as m, reverseCSSTime as h, unflattenObjectToString as g } from "@mkbabb/value.js";
|
|
10
|
+
//#region src/animation/compile/backward/backward-walk.ts
|
|
11
|
+
function _(e) {
|
|
12
|
+
let t = [];
|
|
13
|
+
for (let r of Object.keys(e.animations)) {
|
|
14
|
+
let i = e.animations[r], a = i.layer.blendMode, o = a === "weighted" && i.layer.weightSpring != null, s = a === "weighted" && i.layer.weightSpring == null, c = a === "add" ? "add" : s ? "accumulate" : "replace";
|
|
15
|
+
t.push({
|
|
16
|
+
animation: i.animation,
|
|
17
|
+
name: b(n(i.animation)),
|
|
18
|
+
composition: c,
|
|
19
|
+
weighted: o,
|
|
20
|
+
...s ? { staticWeight: i.layer.weight } : {},
|
|
21
|
+
delay: 0
|
|
22
|
+
});
|
|
23
|
+
}
|
|
24
|
+
return t;
|
|
25
|
+
}
|
|
26
|
+
function v(e) {
|
|
27
|
+
return e.entries.map((e) => ({
|
|
28
|
+
animation: e.animation,
|
|
29
|
+
name: b(n(e.animation)),
|
|
30
|
+
composition: "replace",
|
|
31
|
+
weighted: !1,
|
|
32
|
+
delay: e.at
|
|
33
|
+
}));
|
|
34
|
+
}
|
|
35
|
+
function y(e) {
|
|
36
|
+
return e.map((e, t) => {
|
|
37
|
+
let r = "animation" in e ? e.animation : e;
|
|
38
|
+
return {
|
|
39
|
+
animation: r,
|
|
40
|
+
name: b(n(r) || `anim-${t}`),
|
|
41
|
+
composition: "replace",
|
|
42
|
+
weighted: !1,
|
|
43
|
+
delay: 0
|
|
44
|
+
};
|
|
45
|
+
});
|
|
46
|
+
}
|
|
47
|
+
function b(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/densify.ts
|
|
53
|
+
var x = (e) => {
|
|
54
|
+
let t = /([\d.]+)\s*%/.exec(String(e));
|
|
55
|
+
return t ? parseFloat(t[1]) : 0;
|
|
56
|
+
};
|
|
57
|
+
function S(e, t, n, r) {
|
|
58
|
+
let i = e.parsedVars[t] ?? {}, o = Object.fromEntries(Object.entries(i).filter(([e]) => !r.has(e))), s = Object.entries(g(o)).map(([e, t]) => `${p(e)}: ${t};`), c = e.templateFrames[t], l = c.timingFunction ? a(c.timingFunction) : n;
|
|
59
|
+
l !== n && s.push(`animation-timing-function: ${l};`);
|
|
60
|
+
let u = c.composition;
|
|
61
|
+
return u != null && u !== "replace" && s.push(`animation-composition: ${u};`), s;
|
|
62
|
+
}
|
|
63
|
+
function C(e, t, n) {
|
|
64
|
+
let r = a(e.options.timingFunction), i = new Set(n.keys), o = /* @__PURE__ */ new Map(), s = [], c = (e) => {
|
|
65
|
+
let t = o.get(e);
|
|
66
|
+
return t || (t = [], o.set(e, t), s.push(e)), t;
|
|
67
|
+
};
|
|
68
|
+
for (let [e, t] of n.byPct) c(e).push(...t);
|
|
69
|
+
e.templateFrames.forEach((t, n) => {
|
|
70
|
+
let a = S(e, n, r, i);
|
|
71
|
+
a.length > 0 && c(x(t.start)).push(...a);
|
|
72
|
+
}), s.sort((e, t) => e - t);
|
|
73
|
+
let l = "";
|
|
74
|
+
for (let e of s) l += `${e}% {\n ${o.get(e).join("\n ")}\n}\n`;
|
|
75
|
+
return `@keyframes ${t} {\n${l}}`;
|
|
76
|
+
}
|
|
77
|
+
//#endregion
|
|
78
|
+
//#region src/animation/compile/backward/backward.ts
|
|
79
|
+
var w = .04, T = 16;
|
|
80
|
+
function E(e) {
|
|
81
|
+
for (let t = 0; t < e.templateFrames.length; t++) {
|
|
82
|
+
let n = e.parsedVars[t] ?? {};
|
|
83
|
+
for (let [e, t] of Object.entries(n)) if (!Array.isArray(t) || t.length === 0) return e;
|
|
84
|
+
}
|
|
85
|
+
}
|
|
86
|
+
function D(e, t, n) {
|
|
87
|
+
let { animation: r, name: i } = e;
|
|
88
|
+
if (e.weighted) return n.push({
|
|
89
|
+
name: i,
|
|
90
|
+
reason: "weighted-blend",
|
|
91
|
+
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"
|
|
92
|
+
}), null;
|
|
93
|
+
for (let e of r.frames) if (!r.usesDefaultRenderer(e.transform)) return n.push({
|
|
94
|
+
name: i,
|
|
95
|
+
reason: "custom-renderer",
|
|
96
|
+
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"
|
|
97
|
+
}), null;
|
|
98
|
+
let a = E(r);
|
|
99
|
+
if (a) return n.push({
|
|
100
|
+
name: i,
|
|
101
|
+
reason: "computed-unit-drift",
|
|
102
|
+
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`
|
|
103
|
+
}), null;
|
|
104
|
+
let l = f(r, t.densifyStops ?? 16, t.deltaEEpsilon ?? .04);
|
|
105
|
+
if (l && "refused" in l) return n.push({
|
|
106
|
+
name: i,
|
|
107
|
+
reason: "perceptual-oklab",
|
|
108
|
+
message: `perceptual oklab color track exceeds the densify ΔE-ε threshold (ΔE ${d(l.delta)} > ${t.deltaEEpsilon ?? .04}) — a faithful pure-CSS twin is not available; the JS playback is the only faithful path`
|
|
109
|
+
}), null;
|
|
110
|
+
let p;
|
|
111
|
+
if (e.staticWeight != null) {
|
|
112
|
+
let t = u(r, i, e.staticWeight);
|
|
113
|
+
if ("refused" in t) return n.push({
|
|
114
|
+
name: i,
|
|
115
|
+
reason: "weighted-blend",
|
|
116
|
+
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`
|
|
117
|
+
}), null;
|
|
118
|
+
p = t.block;
|
|
119
|
+
}
|
|
120
|
+
let m = p ?? (l && "byPct" in l ? C(r, i, l) : c(r, i)), g;
|
|
121
|
+
try {
|
|
122
|
+
g = s(r.options, i);
|
|
123
|
+
} catch {
|
|
124
|
+
return n.push({
|
|
125
|
+
name: i,
|
|
126
|
+
reason: "custom-renderer",
|
|
127
|
+
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"
|
|
128
|
+
}), null;
|
|
129
|
+
}
|
|
130
|
+
let _ = o(e.composition), v = _ ? `\n ${_}` : "", y = e.delay > 0 ? `\n animation-delay: ${h(e.delay)};` : "", b = O(r);
|
|
131
|
+
return `${m}\n\n${`${t.selectorFor ? t.selectorFor(i) : `.${i}`} {\n animation: ${g};${v}${y}${b}\n}`}`;
|
|
132
|
+
}
|
|
133
|
+
function O(e) {
|
|
134
|
+
let t = e.scrollOptions;
|
|
135
|
+
if (t == null) return "";
|
|
136
|
+
let n = i(t), r = "";
|
|
137
|
+
for (let [e, t] of Object.entries(n)) t != null && (r += `\n ${e}: ${t};`);
|
|
138
|
+
return r;
|
|
139
|
+
}
|
|
140
|
+
async function k(e, n = {}) {
|
|
141
|
+
let i = e instanceof r ? _(e) : e instanceof t ? v(e) : y(e), a = /* @__PURE__ */ new Map();
|
|
142
|
+
for (let e of i) {
|
|
143
|
+
let t = a.get(e.name) ?? 0;
|
|
144
|
+
a.set(e.name, t + 1), t > 0 && (e.name = `${e.name}-${t + 1}`);
|
|
145
|
+
}
|
|
146
|
+
n.staggerDelays && i.forEach((e, t) => {
|
|
147
|
+
let r = n.staggerDelays[t];
|
|
148
|
+
typeof r == "number" && r > 0 && (e.delay += r);
|
|
149
|
+
});
|
|
150
|
+
let o = [], s = [];
|
|
151
|
+
for (let e of i) {
|
|
152
|
+
let t = D(e, n, o);
|
|
153
|
+
t && s.push(t);
|
|
154
|
+
}
|
|
155
|
+
let c = o.length === 0;
|
|
156
|
+
if (s.length === 0) return {
|
|
157
|
+
css: "",
|
|
158
|
+
eligible: c,
|
|
159
|
+
refusals: o
|
|
160
|
+
};
|
|
161
|
+
let l = s.join("\n\n"), u;
|
|
162
|
+
try {
|
|
163
|
+
u = await m(l, n.printWidth);
|
|
164
|
+
} catch {
|
|
165
|
+
u = l;
|
|
166
|
+
}
|
|
167
|
+
return {
|
|
168
|
+
css: u,
|
|
169
|
+
eligible: c,
|
|
170
|
+
refusals: o
|
|
171
|
+
};
|
|
172
|
+
}
|
|
173
|
+
//#endregion
|
|
174
|
+
//#region src/animation/compile/view-transition.ts
|
|
175
|
+
var A = /* @__PURE__ */ e({ compileToViewTransition: () => L }), j = new Set([
|
|
176
|
+
"transform",
|
|
177
|
+
"opacity",
|
|
178
|
+
"filter",
|
|
179
|
+
"backdrop-filter",
|
|
180
|
+
"mix-blend-mode",
|
|
181
|
+
"clip-path"
|
|
182
|
+
]), M = /\b-?\d*\.?\d+cq(w|h|i|b|min|max)\b/i;
|
|
183
|
+
function N(e) {
|
|
184
|
+
let t = a(e.options.timingFunction), n = [];
|
|
185
|
+
for (let r = 0; r < e.templateFrames.length; r++) {
|
|
186
|
+
let i = l(e, r, t);
|
|
187
|
+
for (let e of i.matchAll(/([\w-]+)\s*:\s*([^;]+);/g)) n.push({
|
|
188
|
+
prop: e[1].trim(),
|
|
189
|
+
value: e[2].trim()
|
|
190
|
+
});
|
|
191
|
+
}
|
|
192
|
+
return n;
|
|
193
|
+
}
|
|
194
|
+
var P = (e) => e.split(".")[0].replace(/([a-z0-9])([A-Z])/g, "$1-$2").toLowerCase();
|
|
195
|
+
function F(e, t, n, r, i, a) {
|
|
196
|
+
let o = [], s = `${t}-${e}`;
|
|
197
|
+
if (r.scrollOptions != null) return o.push({
|
|
198
|
+
name: s,
|
|
199
|
+
reason: "vt-scroll-grammar",
|
|
200
|
+
message: `scroll grammar on the ${e} role has no defined behavior on a time-driven ::view-transition pseudo (animation-timeline is undefined there) — the JS ScrollScene driver is the only faithful path`
|
|
201
|
+
}), {
|
|
202
|
+
chunk: null,
|
|
203
|
+
refusals: o
|
|
204
|
+
};
|
|
205
|
+
for (let { prop: t, value: n } of N(r)) {
|
|
206
|
+
if (M.test(n) || /\bvar\(/.test(n)) return o.push({
|
|
207
|
+
name: s,
|
|
208
|
+
reason: "vt-element-scoped-computed",
|
|
209
|
+
message: `"${t}" is element-scoped (${M.test(n) ? "a container-query unit" : "a var()"}) — the ::view-transition pseudo tree hangs off the ROOT, so an element-scoped custom property / container context does not reach it`
|
|
210
|
+
}), {
|
|
211
|
+
chunk: null,
|
|
212
|
+
refusals: o
|
|
213
|
+
};
|
|
214
|
+
if (!j.has(P(t))) return o.push({
|
|
215
|
+
name: s,
|
|
216
|
+
reason: "vt-snapshot-inapplicable",
|
|
217
|
+
message: `"${t}" does not apply to a replaced-content ::view-transition-${e} snapshot (only transform/opacity/filter/mix-blend-mode animate there) — refused per property, never silently dropped`
|
|
218
|
+
}), {
|
|
219
|
+
chunk: null,
|
|
220
|
+
refusals: o
|
|
221
|
+
};
|
|
222
|
+
}
|
|
223
|
+
let c = `${i}::view-transition-${e}(${n})`, l = {
|
|
224
|
+
animation: r,
|
|
225
|
+
name: s,
|
|
226
|
+
composition: "replace",
|
|
227
|
+
weighted: !1,
|
|
228
|
+
delay: 0
|
|
229
|
+
}, u = [], d = D(l, {
|
|
230
|
+
...a.densifyStops == null ? {} : { densifyStops: a.densifyStops },
|
|
231
|
+
...a.deltaEEpsilon == null ? {} : { deltaEEpsilon: a.deltaEEpsilon },
|
|
232
|
+
selectorFor: () => c
|
|
233
|
+
}, u);
|
|
234
|
+
for (let e of u) o.push(e);
|
|
235
|
+
return {
|
|
236
|
+
chunk: d,
|
|
237
|
+
refusals: o
|
|
238
|
+
};
|
|
239
|
+
}
|
|
240
|
+
function I(e) {
|
|
241
|
+
let t = e.group;
|
|
242
|
+
if (t != null) return "options" in t && "templateFrames" in t ? {
|
|
243
|
+
duration: t.options.duration,
|
|
244
|
+
easing: a(t.options.timingFunction)
|
|
245
|
+
} : {
|
|
246
|
+
duration: t.duration,
|
|
247
|
+
easing: a(t.timingFunction)
|
|
248
|
+
};
|
|
249
|
+
let n = e.new ?? e.old;
|
|
250
|
+
return n == null ? null : {
|
|
251
|
+
duration: n.options.duration,
|
|
252
|
+
easing: a(n.options.timingFunction)
|
|
253
|
+
};
|
|
254
|
+
}
|
|
255
|
+
async function L(e, t = {}) {
|
|
256
|
+
let n = [], r = [], i = [], a = t.types, o = a && a.length > 0 ? `:root:active-view-transition-type(${a.join(", ")})` : "", s = t.emitGroup ?? !0, c = /* @__PURE__ */ new Map();
|
|
257
|
+
for (let t of Object.keys(e)) {
|
|
258
|
+
let e = b(t), n = c.get(e);
|
|
259
|
+
n ? n.push(t) : c.set(e, [t]);
|
|
260
|
+
}
|
|
261
|
+
let l = /* @__PURE__ */ new Set();
|
|
262
|
+
for (let [e, t] of c) if (t.length > 1) for (let r of t) l.add(r), n.push({
|
|
263
|
+
name: r,
|
|
264
|
+
reason: "vt-name-collision",
|
|
265
|
+
message: `"${r}" collapses to the CSS ident "${e}" already used by ${t.filter((e) => e !== r).map((e) => `"${e}"`).join(", ")} — the ≤1-element-per-view-transition-name platform rule is violated; a REFUSAL, not a silent rename (rename the colliding key)`
|
|
266
|
+
});
|
|
267
|
+
for (let [a, c] of Object.entries(e)) {
|
|
268
|
+
if (l.has(a)) continue;
|
|
269
|
+
let e = b(a), u = c.class ? `.${b(c.class)}` : e;
|
|
270
|
+
i.push(e);
|
|
271
|
+
for (let i of ["old", "new"]) {
|
|
272
|
+
let a = c[i];
|
|
273
|
+
if (a == null) continue;
|
|
274
|
+
let { chunk: s, refusals: l } = F(i, e, u, a, o, t);
|
|
275
|
+
for (let e of l) n.push(e);
|
|
276
|
+
s && r.push(s);
|
|
277
|
+
}
|
|
278
|
+
if (s && (c.old != null || c.new != null || c.group != null)) {
|
|
279
|
+
let e = I(c);
|
|
280
|
+
e != null && r.push(`${o}::view-transition-group(${u}) {\n animation-duration: ${h(e.duration)};\n animation-timing-function: ${e.easing};\n}`);
|
|
281
|
+
}
|
|
282
|
+
}
|
|
283
|
+
t.crossDocument && r.unshift("@view-transition {\n navigation: auto;\n}"), (t.reducedMotion ?? !0) && r.push("@media (prefers-reduced-motion: reduce) {\n ::view-transition-group(*),\n ::view-transition-old(*),\n ::view-transition-new(*) {\n animation: none !important;\n }\n}");
|
|
284
|
+
let u = n.length === 0;
|
|
285
|
+
if (r.length === 0) return {
|
|
286
|
+
css: "",
|
|
287
|
+
eligible: u,
|
|
288
|
+
refusals: n,
|
|
289
|
+
names: i
|
|
290
|
+
};
|
|
291
|
+
let d = r.join("\n\n"), f;
|
|
292
|
+
try {
|
|
293
|
+
f = await m(d, t.printWidth);
|
|
294
|
+
} catch {
|
|
295
|
+
f = d;
|
|
296
|
+
}
|
|
297
|
+
return {
|
|
298
|
+
css: f,
|
|
299
|
+
eligible: u,
|
|
300
|
+
refusals: n,
|
|
301
|
+
names: i
|
|
302
|
+
};
|
|
303
|
+
}
|
|
304
|
+
//#endregion
|
|
305
|
+
export { k as a, T as i, A as n, w as r, L as t };
|