@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.
Files changed (35) hide show
  1. package/README.md +83 -3
  2. package/dist/backward-color-BtbRcnna.js +108 -0
  3. package/dist/compile-BHCTPerD.js +30 -0
  4. package/dist/{delegation-DWwr4IXr.js → delegation-BQYCrP2p.js} +5 -9
  5. package/dist/{draw-svg-GURj9nin.js → draw-svg-CK9Qrly8.js} +13 -25
  6. package/dist/easing-serialize-D4LZCB6i.js +21 -0
  7. package/dist/engine/index.d.ts +422 -156
  8. package/dist/engine/index.js +16 -17
  9. package/dist/engine-CPK_udUQ.js +1172 -0
  10. package/dist/engine-DlpimZtM.js +3 -0
  11. package/dist/entry-D82NKUhP.js +148 -0
  12. package/dist/format-BdIvdLzG.js +114 -0
  13. package/dist/{group-vJcsHKN9.js → group-HM7N4uOE.js} +153 -123
  14. package/dist/handle-D4xrf_ya.js +21 -0
  15. package/dist/{ingest-S5hUe20K.js → ingest-_g6tfk2e.js} +2 -2
  16. package/dist/keyframes.d.ts +702 -178
  17. package/dist/keyframes.js +295 -74
  18. package/dist/morph-svg-KUrH9KnK.js +79 -0
  19. package/dist/motion-path-wM5tPfrY.js +26 -0
  20. package/dist/presets-DeDJYL4G.js +275 -0
  21. package/dist/{scheduler-CUtVnuoU.js → scheduler-CfGIC3GX.js} +1 -1
  22. package/dist/{scroll-CxpYFO4u.js → scroll-BEyCx0b_.js} +165 -58
  23. package/dist/{sequence-C_DCiOIQ.js → sequence-s0bL7Uul.js} +118 -90
  24. package/dist/{validate-DDeGnvSt.js → validate-xFZ_Ld1k.js} +7 -7
  25. package/dist/view-transition-BPJQxUTC.js +305 -0
  26. package/package.json +113 -83
  27. package/dist/animation-BGyzfzBq.js +0 -947
  28. package/dist/compile-CcSUwM8R.js +0 -276
  29. package/dist/engine-DEVgCTUy.js +0 -156
  30. package/dist/engine-DrBtsKaf.js +0 -4
  31. package/dist/format-C-Gi9r7L.js +0 -123
  32. package/dist/grammar-BLucehC4.js +0 -23
  33. package/dist/morph-svg-BToeumw5.js +0 -89
  34. package/dist/motion-path-pQVbamWT.js +0 -35
  35. package/dist/presets-BG2Fczzq.js +0 -275
@@ -0,0 +1,3 @@
1
+ import { d as e, f as t, h as n, i as r, m as i, n as a, r as o, t as s } from "./engine-CPK_udUQ.js";
2
+ import { t as c } from "./easing-registry-DHV2-5gA.js";
3
+ export { s as CSSKeyframesAnimation, e as DIRECTIONS, t as FILL_MODES, o as KeyframesAnimation, i as defaultLayerConfig, n as defaultOptions, r as getAnimationId, c as getTimingFunction, a as resolveKeyframes };
@@ -0,0 +1,148 @@
1
+ import { n as e } from "./presets-DeDJYL4G.js";
2
+ import { t } from "./easing-serialize-D4LZCB6i.js";
3
+ import { r as n, t as r } from "./backward-color-BtbRcnna.js";
4
+ import { camelCaseToHyphen as i, formatCSS as a, reverseCSSTime as o, unflattenObjectToString as s } from "@mkbabb/value.js";
5
+ //#region src/animation/compile/entry.ts
6
+ var c = /* @__PURE__ */ e({ compileToEntry: () => v });
7
+ function l(e, t) {
8
+ let a = e.parsedVars[t] ?? {}, o = /* @__PURE__ */ new Map();
9
+ for (let [e, t] of Object.entries(a)) if (Array.isArray(t)) {
10
+ let r = t.find(n);
11
+ r && o.set(i(e.split(".")[0]), r);
12
+ }
13
+ let c = [];
14
+ for (let [e, t] of Object.entries(s(a))) {
15
+ let n = i(e), a = o.get(n);
16
+ c.push({
17
+ prop: n,
18
+ value: a ? r(a) : String(t)
19
+ });
20
+ }
21
+ return c;
22
+ }
23
+ function u(e) {
24
+ let t = e.templateFrames.length;
25
+ return e.options.direction === "reverse" ? [t - 1, 0] : [0, t - 1];
26
+ }
27
+ function d(e) {
28
+ for (let t = 0; t < e.templateFrames.length; t++) {
29
+ let r = e.parsedVars[t] ?? {};
30
+ for (let e of Object.values(r)) if (Array.isArray(e) && e.some(n)) return !0;
31
+ }
32
+ return !1;
33
+ }
34
+ function f(e) {
35
+ for (let t = 0; t < e.templateFrames.length; t++) {
36
+ let n = e.parsedVars[t] ?? {};
37
+ for (let [e, t] of Object.entries(n)) if (!Array.isArray(t) || t.length === 0) return e;
38
+ }
39
+ }
40
+ function p(e) {
41
+ let n = e.options;
42
+ if (e.templateFrames.length > 2) return {
43
+ reason: "entry-multi-keyframe",
44
+ detail: `${e.templateFrames.length} declared stops — a transition is a two-endpoint grammar; intermediate stops have no CSS twin`
45
+ };
46
+ if (n.iterationCount !== 1 || n.direction === "alternate" || n.direction === "alternate-reverse") return {
47
+ reason: "entry-iteration",
48
+ detail: `iterationCount=${n.iterationCount}, direction=${n.direction} — transitions run once, forward (reverse is an endpoint swap, not a refusal)`
49
+ };
50
+ let r = n.composite, i = e.templateFrames.some((e) => e.composition != null && e.composition !== "replace");
51
+ if (r != null && r !== "replace" || i) return {
52
+ reason: "entry-composition",
53
+ detail: "add/accumulate composition has no transition twin (transitions always replace) — never silently flattened"
54
+ };
55
+ if (e.scrollOptions != null) return {
56
+ reason: "entry-scroll-grammar",
57
+ detail: "scroll grammar has no transition twin — the JS ScrollScene driver is the only faithful path"
58
+ };
59
+ if ((n.colorSpace === "oklch" || n.hueMethod != null) && d(e)) return {
60
+ reason: "entry-color-space",
61
+ detail: `colorSpace=${n.colorSpace}${n.hueMethod ? `, hueMethod=${n.hueMethod}` : ""} — transitions expose no interpolation-space control; native Oklab is the default feature (only non-default spaces refuse)`
62
+ };
63
+ let a = f(e);
64
+ if (a != null) return {
65
+ reason: "computed-unit-drift",
66
+ detail: `"${a}" has an empty declared value — it cannot be re-emitted as a faithful transition endpoint`
67
+ };
68
+ for (let t of e.frames) if (!e.usesDefaultRenderer(t.transform)) return {
69
+ reason: "custom-renderer",
70
+ detail: "a custom transform closure cannot be a CSS transition endpoint"
71
+ };
72
+ try {
73
+ t(n.timingFunction);
74
+ } catch {
75
+ return {
76
+ reason: "entry-easing-twin",
77
+ detail: "the easing has no faithful CSS timing-function twin (attach an Easing.css twin or use a registry name / cubic-bezier() / linear())"
78
+ };
79
+ }
80
+ }
81
+ var m = {
82
+ "custom-renderer": "custom renderer — the JS playback is the only faithful path",
83
+ "weighted-blend": "weighted layer blend has no transition twin",
84
+ "computed-unit-drift": "computed-unit drift — the endpoint cannot be re-emitted faithfully",
85
+ "entry-multi-keyframe": "more than two declared stops — a transition is a two-endpoint grammar",
86
+ "entry-iteration": "iteration/alternate-direction — transitions run once, forward",
87
+ "entry-composition": "add/accumulate composition has no transition twin",
88
+ "entry-scroll-grammar": "scroll grammar has no transition twin",
89
+ "entry-color-space": "a non-default color space (oklch/hueMethod) — transitions expose no space control",
90
+ "entry-easing-twin": "the easing has no faithful CSS timing-function twin"
91
+ };
92
+ function h(e, t) {
93
+ let n = /* @__PURE__ */ new Set();
94
+ for (let t of e) n.add(t.prop);
95
+ for (let e of t) n.add(e.prop);
96
+ return [...n];
97
+ }
98
+ function g(e, t, n, r) {
99
+ let i = e.filter((e) => e !== "display" && e !== "overlay").map((e) => `${e} ${t} ${n}`);
100
+ return i.push(`display ${t} allow-discrete`), r && i.push(`overlay ${t} allow-discrete`), i.join(", ");
101
+ }
102
+ var _ = (e, t) => [...e.map((e) => ` ${e.prop}: ${e.value};`), ...t].join("\n");
103
+ async function v(e, n = {}) {
104
+ let r = n.openSelector ?? ".open", i = n.display ?? "block", s = n.overlay ?? !0, c = [], d = [];
105
+ for (let [n, a] of Object.entries(e)) {
106
+ let e = a.enter;
107
+ if (e == null) continue;
108
+ let f = a.exit ? [e, a.exit] : [e], v = !1;
109
+ for (let e of f) {
110
+ let t = p(e);
111
+ if (t) {
112
+ c.push({
113
+ name: n,
114
+ reason: t.reason,
115
+ message: `${m[t.reason]} — ${t.detail}`
116
+ }), v = !0;
117
+ break;
118
+ }
119
+ }
120
+ if (v) continue;
121
+ let [y, b] = u(e), x = l(e, y), S = l(e, b), C = h(x, S), w = o(e.options.duration), T = t(e.options.timingFunction), E, D, O, k;
122
+ if (a.exit) {
123
+ let [, e] = u(a.exit), n = u(a.exit)[0];
124
+ E = l(a.exit, e), D = h(l(a.exit, n), E), O = o(a.exit.options.duration), k = t(a.exit.options.timingFunction);
125
+ } else E = x, D = C, O = w, k = T;
126
+ let A = `${n}${r}`, j = `${n} {\n${_(E, [" display: none;", ` transition: ${g(D, O, k, s)};`])}\n}`, M = `${A} {\n${_(S, [` display: ${i};`, ` transition: ${g(C, w, T, s)};`])}\n}`, N = `@starting-style {\n ${A} {\n${_(x, []).split("\n").map((e) => ` ${e}`).join("\n")}\n }\n}`;
127
+ d.push(`${j}\n\n${M}\n\n${N}`);
128
+ }
129
+ let f = c.length === 0;
130
+ if (d.length === 0) return {
131
+ css: "",
132
+ eligible: f,
133
+ refusals: c
134
+ };
135
+ let v = d.join("\n\n"), y;
136
+ try {
137
+ y = await a(v, n.printWidth);
138
+ } catch {
139
+ y = v;
140
+ }
141
+ return {
142
+ css: y,
143
+ eligible: f,
144
+ refusals: c
145
+ };
146
+ }
147
+ //#endregion
148
+ export { c as n, v as t };
@@ -0,0 +1,114 @@
1
+ import { n as e } from "./presets-DeDJYL4G.js";
2
+ import { t } from "./easing-serialize-D4LZCB6i.js";
3
+ import { camelCaseToHyphen as n, formatCSS as r, reverseAnimationShorthand as i, reverseCSSTime as a, serializeStylesheetItem as o, unflattenObjectToString as s } from "@mkbabb/value.js";
4
+ //#region src/animation/compile/backward/format-options.ts
5
+ function c(e, n = "animation") {
6
+ let r = "";
7
+ r += ` animation-name: ${n};\n`;
8
+ let i = a(e.duration);
9
+ r += ` animation-duration: ${i};\n`, r += ` animation-timing-function: ${t(e.timingFunction)};\n`, r += ` animation-iteration-count: ${isFinite(e.iterationCount) ? e.iterationCount : "infinite"};\n`, r += ` animation-direction: ${e.direction};\n`, r += ` animation-fill-mode: ${e.fillMode};\n`, e.delay > 0 && (r += ` animation-delay: ${a(e.delay)};\n`);
10
+ let o = e.composite == null ? void 0 : u(e.composite);
11
+ return o != null && (r += ` ${o}\n`), r = `.${n} {\n${r}}\n`, r;
12
+ }
13
+ function l(e, n) {
14
+ let r = {
15
+ name: n,
16
+ duration: e.duration,
17
+ timingFunction: t(e.timingFunction),
18
+ iterationCount: isFinite(e.iterationCount) ? e.iterationCount : Infinity,
19
+ direction: e.direction,
20
+ fillMode: e.fillMode
21
+ };
22
+ return e.delay > 0 && (r.delay = e.delay), i(r);
23
+ }
24
+ function u(e) {
25
+ return e === "replace" ? void 0 : `animation-composition: ${e};`;
26
+ }
27
+ function d(e) {
28
+ let t = e.propertyRegistry;
29
+ if (t == null || t.size === 0) return "";
30
+ let n = [];
31
+ for (let [e, r] of t) n.push(o({
32
+ kind: "property",
33
+ name: e,
34
+ descriptor: r
35
+ }));
36
+ return n.join("\n");
37
+ }
38
+ //#endregion
39
+ //#region src/animation/compile/backward/format.ts
40
+ var f = /* @__PURE__ */ e({
41
+ CSSKeyframesToString: () => S,
42
+ CSSKeyframesToStrings: () => _,
43
+ declaredKeyframeBodyFor: () => y,
44
+ formatCSSKeyframeString: () => v,
45
+ keyframesBlock: () => b,
46
+ premultipliedKeyframesBlock: () => x
47
+ }), p = 80, m = "@keyframes animation {\n", h = "\n}";
48
+ function g(e, r, i) {
49
+ let a = e.parsedVars[r] ?? {}, o = e.templateFrames[r], c = Object.entries(s(a)).map(([e, t]) => ` ${n(e)}: ${t};`), l = o.timingFunction ? t(o.timingFunction) : i;
50
+ l !== i && c.push(` animation-timing-function: ${l};`);
51
+ let u = o.composition;
52
+ return u != null && u !== "replace" && c.push(` animation-composition: ${u};`), `{\n${c.join("\n").trim()}\n}`;
53
+ }
54
+ var _ = async (e) => {
55
+ let n = t(e.options.timingFunction), i = e.templateFrames.map(async (t, i) => {
56
+ let a = g(e, i, n);
57
+ return a = `${t.start}\n${a}\n`, a = m + a + h, a = await r(a, p), a.replace(m, "").replace(h, "");
58
+ });
59
+ return Promise.all(i);
60
+ };
61
+ function v(e) {
62
+ let t = e.replace(/^[^{]*{/, "").replace(/^ /gm, "").replace(/}\s*$/, "");
63
+ return t = t.trim(), t = t.replace(/^ /, ""), t;
64
+ }
65
+ function y(e, t, n) {
66
+ return g(e, t, n);
67
+ }
68
+ function b(e, n, r) {
69
+ let i = t(e.options.timingFunction), a = /* @__PURE__ */ new Map();
70
+ e.templateFrames.forEach((t, n) => {
71
+ let o = r?.get(n) ?? g(e, n, i), s = a.get(o);
72
+ s ? s.push(t.start) : a.set(o, [t.start]);
73
+ });
74
+ let o = "";
75
+ for (let [e, t] of a) o += `${t.join(", ")} ${e}\n`;
76
+ return `@keyframes ${n} {\n${o}}`;
77
+ }
78
+ function x(e, r, i) {
79
+ let a = t(e.options.timingFunction), o = /* @__PURE__ */ new Map();
80
+ for (let r = 0; r < e.templateFrames.length; r++) {
81
+ let c = e.templateFrames[r], l = e.parsedVars[r] ?? {}, u = {};
82
+ for (let [e, t] of Object.entries(l)) {
83
+ let n = t.clone();
84
+ for (let t of n) if (typeof t.value == "number") t.value *= i;
85
+ else if (t.unit === "color" || typeof t.value == "string") return {
86
+ refused: !0,
87
+ key: e
88
+ };
89
+ u[e] = n;
90
+ }
91
+ let d = Object.entries(s(u)).map(([e, t]) => ` ${n(e)}: ${t};`), f = c.timingFunction ? t(c.timingFunction) : a;
92
+ f !== a && d.push(` animation-timing-function: ${f};`);
93
+ let p = c.composition;
94
+ p != null && p !== "replace" && d.push(` animation-composition: ${p};`);
95
+ let m = `{\n${d.join("\n").trim()}\n}`, h = o.get(m);
96
+ h ? h.push(c.start) : o.set(m, [c.start]);
97
+ }
98
+ let c = "";
99
+ for (let [e, t] of o) c += `${t.join(", ")} ${e}\n`;
100
+ return { block: `@keyframes ${r} {\n${c}}` };
101
+ }
102
+ async function S(e, n = "animation", i = void 0) {
103
+ let a = e.options, o = /* @__PURE__ */ new Map(), s = t(a.timingFunction);
104
+ e.templateFrames.forEach((t, n) => {
105
+ let r = t.start, i = g(e, n, s);
106
+ o.has(i) ? o.get(i).push(r) : o.set(i, [r]);
107
+ });
108
+ let l = "";
109
+ for (let [e, t] of o) l += `${t.join(", ")} ${e}`;
110
+ let u = c(a, n), f = d(e);
111
+ return (await r(`${f ? `${f}\n\n` : ""}${u}\n@keyframes ${n} {\n${l}}`, i)).replace(/\(\s*\{/g, "{").replace(/\}\s*\)/g, "}");
112
+ }
113
+ //#endregion
114
+ export { f as a, u as c, v as i, l, _ as n, b as o, y as r, x as s, S as t };