@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.
Files changed (39) hide show
  1. package/README.md +36 -221
  2. package/dist/animation-BGyzfzBq.js +947 -0
  3. package/dist/compile-CcSUwM8R.js +276 -0
  4. package/dist/{waapi-D9MHMm_9.js → delegation-DWwr4IXr.js} +116 -32
  5. package/dist/{draw-svg-DYRDxBlL.js → draw-svg-GURj9nin.js} +17 -13
  6. package/dist/easing-registry-DHV2-5gA.js +27 -0
  7. package/dist/easing-registry-y1p9McFy.js +2 -0
  8. package/dist/engine/index.d.ts +2873 -0
  9. package/dist/engine/index.js +17 -0
  10. package/dist/engine-DEVgCTUy.js +156 -0
  11. package/dist/engine-DrBtsKaf.js +4 -0
  12. package/dist/{format-BUgCTjmr.js → format-C-Gi9r7L.js} +4 -4
  13. package/dist/{scroll-grammar-B4kPvGh5.js → grammar-BLucehC4.js} +1 -1
  14. package/dist/group-vJcsHKN9.js +360 -0
  15. package/dist/{ingest-CNM5xkQT.js → ingest-S5hUe20K.js} +62 -56
  16. package/dist/keyframes.d.ts +585 -989
  17. package/dist/keyframes.js +188 -129
  18. package/dist/morph-svg-BToeumw5.js +89 -0
  19. package/dist/{motion-path-J-RSNmRQ.js → motion-path-pQVbamWT.js} +16 -12
  20. package/dist/parse-flatten-DRMHFytp.js +2 -0
  21. package/dist/parse-flatten-ZZUSEQEL.js +63 -0
  22. package/dist/{animations-5nf2kBkv.js → presets-BG2Fczzq.js} +124 -73
  23. package/dist/{scheduler-7eIr_q1g.js → scheduler-CUtVnuoU.js} +1 -1
  24. package/dist/{scroll-scene-CXEgM49Q.js → scroll-CxpYFO4u.js} +50 -46
  25. package/dist/sequence-C_DCiOIQ.js +708 -0
  26. package/dist/validate-DDeGnvSt.js +39 -0
  27. package/package.json +45 -6
  28. package/dist/animate-CuUJt2Tb.js +0 -26
  29. package/dist/compile-DgNRG6Lo.js +0 -251
  30. package/dist/decay-BvNmFk51.js +0 -25
  31. package/dist/engine-CNHvTgpw.js +0 -1122
  32. package/dist/errors-W8zkvPw4.js +0 -21
  33. package/dist/morph-svg-DRjl9Hfz.js +0 -62
  34. package/dist/rolldown-runtime-Dy4uBu1J.js +0 -11
  35. package/dist/sequence-CF5hazqz.js +0 -198
  36. package/dist/springTimingFunction-CDHZ00JQ.js +0 -63
  37. package/dist/timeline-B7SV3T_E.js +0 -442
  38. package/dist/utils-D7nuAND5.js +0 -97
  39. package/dist/validate-8r6Yo-uc.js +0 -35
@@ -1,16 +1,17 @@
1
- import { CSSKeyframesAnimation as e } from "./engine-CNHvTgpw.js";
2
- //#region src/animation/ingest-cssom.ts
3
- var t = (e, t, n, r = {}) => {
1
+ import { n as e } from "./presets-BG2Fczzq.js";
2
+ import { t } from "./engine-DEVgCTUy.js";
3
+ //#region src/animation/ingest/cssom.ts
4
+ var n = (e, t, n, r = {}) => {
4
5
  e.push({
5
6
  code: t,
6
7
  message: n,
7
8
  ...r
8
9
  });
9
- }, n = (e) => {
10
+ }, r = (e) => {
10
11
  if (typeof CSSKeyframesRule < "u" && e instanceof CSSKeyframesRule) return !0;
11
12
  let t = e;
12
13
  return t.type === 7 && typeof t.name == "string" && typeof t.cssText == "string";
13
- }, r = 32, i = (e) => e.cssRules !== void 0 && !n(e), a = (e, t, s, c = 0) => {
14
+ }, i = 32, a = (e) => e.cssRules !== void 0 && !r(e), o = (e, t, n, c = 0) => {
14
15
  let l = [];
15
16
  for (let t = 0; t < e.length; t++) {
16
17
  let n = e[t];
@@ -18,59 +19,59 @@ var t = (e, t, n, r = {}) => {
18
19
  let r = n;
19
20
  r.type === 1 && typeof r.cssText == "string" && l.push(r.cssText);
20
21
  }
21
- for (let r = 0; r < e.length; r++) {
22
- let i = e[r];
23
- if (i == null || !n(i)) continue;
24
- let a = i.name;
25
- if (s.animationName != null && a !== s.animationName) continue;
26
- let c = RegExp(`\\banimation(?:-name)?\\s*:[^;}]*\\b${a}\\b`), u = l.find((e) => c.test(e)), d = [], f = o(i.cssText, u, s.options, d);
27
- f != null && t.set(a, {
28
- name: a,
22
+ for (let i = 0; i < e.length; i++) {
23
+ let a = e[i];
24
+ if (a == null || !r(a)) continue;
25
+ let o = a.name;
26
+ if (n.animationName != null && o !== n.animationName) continue;
27
+ let c = RegExp(`\\banimation(?:-name)?\\s*:[^;}]*\\b${o}\\b`), u = l.find((e) => c.test(e)), d = [], f = s(a.cssText, u, n.options, d);
28
+ f != null && t.set(o, {
29
+ name: o,
29
30
  animation: f,
30
31
  diagnostics: d
31
32
  });
32
33
  }
33
- if (c < r) for (let n = 0; n < e.length; n++) {
34
- let r = e[n];
35
- r == null || !i(r) || a(r.cssRules, t, s, c + 1);
34
+ if (c < i) for (let r = 0; r < e.length; r++) {
35
+ let i = e[r];
36
+ i == null || !a(i) || o(i.cssRules, t, n, c + 1);
36
37
  }
37
- }, o = (n, r, i, a) => {
38
+ }, s = (e, r, i, a) => {
38
39
  try {
39
- let t = new e(i ?? {}), o = r ? `${r}\n${n}` : n;
40
- t.fromString(o);
41
- for (let e of t.diagnostics) a.push(e);
42
- return t;
43
- } catch (e) {
44
- t(a, "PARSE_ERROR", `@keyframes rule could not be reconstructed: ${e instanceof Error ? e.message : String(e)} — the source CSS could not be parsed faithfully (refused, not approximated)`, { input: n });
40
+ let n = new t(i ?? {}), o = r ? `${r}\n${e}` : e;
41
+ n.fromString(o);
42
+ for (let e of n.diagnostics) a.push(e);
43
+ return n;
44
+ } catch (t) {
45
+ n(a, "PARSE_ERROR", `@keyframes rule could not be reconstructed: ${t instanceof Error ? t.message : String(t)} — the source CSS could not be parsed faithfully (refused, not approximated)`, { input: e });
45
46
  return;
46
47
  }
47
- }, s = (e, n = {}) => {
48
- let r = /* @__PURE__ */ new Map(), i = [], o;
48
+ }, c = (e, t = {}) => {
49
+ let r = /* @__PURE__ */ new Map(), i = [], a;
49
50
  if (e == null) {
50
- if (typeof document > "u") return t(i, "CORS_SKIP", "no document in scope — resolveLiveKeyframes() needs a Document, a ShadowRoot, a CSSStyleSheet[], or a CSSStyleSheet (SSR has no live CSSOM)"), {
51
+ if (typeof document > "u") return n(i, "CORS_SKIP", "no document in scope — resolveLiveKeyframes() needs a Document, a ShadowRoot, a CSSStyleSheet[], or a CSSStyleSheet (SSR has no live CSSOM)"), {
51
52
  animations: r,
52
53
  diagnostics: i
53
54
  };
54
- o = Array.from(document.styleSheets);
55
- } else o = Array.isArray(e) ? e : typeof Document < "u" && e instanceof Document ? Array.from(e.styleSheets) : typeof ShadowRoot < "u" && e instanceof ShadowRoot ? [...e.styleSheets == null ? [] : Array.from(e.styleSheets), ...e.adoptedStyleSheets ?? []] : [e];
56
- for (let e of o) {
57
- let o = null;
55
+ a = Array.from(document.styleSheets);
56
+ } else a = Array.isArray(e) ? e : typeof Document < "u" && e instanceof Document ? Array.from(e.styleSheets) : typeof ShadowRoot < "u" && e instanceof ShadowRoot ? [...e.styleSheets == null ? [] : Array.from(e.styleSheets), ...e.adoptedStyleSheets ?? []] : [e];
57
+ for (let e of a) {
58
+ let a = null;
58
59
  try {
59
- o = e.cssRules;
60
- } catch (n) {
60
+ a = e.cssRules;
61
+ } catch (t) {
61
62
  let r = e.href ?? "(inline)";
62
- t(i, "CORS_SKIP", `cross-origin stylesheet skipped: ${r} — its cssRules threw ${n instanceof Error ? n.name : "an error"} (no Access-Control-Allow-Origin + crossorigin). The sheet is REPORTED, not silently dropped.`, { input: r });
63
+ n(i, "CORS_SKIP", `cross-origin stylesheet skipped: ${r} — its cssRules threw ${t instanceof Error ? t.name : "an error"} (no Access-Control-Allow-Origin + crossorigin). The sheet is REPORTED, not silently dropped.`, { input: r });
63
64
  continue;
64
65
  }
65
- o != null && a(o, r, n);
66
+ a != null && o(a, r, t);
66
67
  }
67
68
  return {
68
69
  animations: r,
69
70
  diagnostics: i
70
71
  };
71
- }, c = (e, t = {}) => s(e, t), l = (e, n = {}) => {
72
+ }, l = (e, t = {}) => c(e, t), u = (e, t = {}) => {
72
73
  let r = /* @__PURE__ */ new Map(), i = [], a = e ?? (typeof document < "u" ? document : void 0);
73
- if (a == null || typeof a.getAnimations != "function") return t(i, "CORS_SKIP", "no getAnimations() in scope — fromLiveAnimations() needs a Document or Element with the Web Animations API (SSR has none)"), {
74
+ if (a == null || typeof a.getAnimations != "function") return n(i, "CORS_SKIP", "no getAnimations() in scope — fromLiveAnimations() needs a Document or Element with the Web Animations API (SSR has none)"), {
74
75
  animations: r,
75
76
  diagnostics: i
76
77
  };
@@ -79,24 +80,24 @@ var t = (e, t, n, r = {}) => {
79
80
  let t = e.animationName;
80
81
  typeof t == "string" && t.length > 0 && o.add(t);
81
82
  }
82
- let c = (a instanceof Document ? a : a.ownerDocument ?? (typeof document < "u" ? document : void 0)) ?? void 0;
83
+ let s = (a instanceof Document ? a : a.ownerDocument ?? (typeof document < "u" ? document : void 0)) ?? void 0;
83
84
  for (let e of o) {
84
- let t = s(c, {
85
- ...n,
85
+ let n = c(s, {
86
+ ...t,
86
87
  animationName: e
87
88
  });
88
- for (let [e, n] of t.animations) r.set(e, n);
89
- for (let e of t.diagnostics) i.push(e);
89
+ for (let [e, t] of n.animations) r.set(e, t);
90
+ for (let e of n.diagnostics) i.push(e);
90
91
  }
91
92
  return {
92
93
  animations: r,
93
94
  diagnostics: i
94
95
  };
95
- }, u = (e) => {
96
+ }, d = (e) => {
96
97
  if (typeof e != "object" || !e) return !1;
97
98
  let t = e;
98
99
  return typeof t.value == "number" && typeof t.unit == "string";
99
- }, d = async (e, t) => {
100
+ }, f = async (e, t) => {
100
101
  let n = [], { animationName: r, commit: i = !0 } = t;
101
102
  if (typeof e.getAnimations != "function") return n.push({
102
103
  code: "WAAPI_INELIGIBLE",
@@ -115,9 +116,9 @@ var t = (e, t, n, r = {}) => {
115
116
  currentTime: 0,
116
117
  diagnostics: n
117
118
  };
118
- let o = a.currentTime, c = null, l = 0;
119
+ let o = a.currentTime, s = null, l = 0;
119
120
  if (typeof o == "number" && Number.isFinite(o)) l = o;
120
- else if (u(o)) if (o.unit === "percent" && Number.isFinite(o.value)) c = o.value / 100;
121
+ else if (d(o)) if (o.unit === "percent" && Number.isFinite(o.value)) s = o.value / 100;
121
122
  else return n.push({
122
123
  code: "ADOPT_REFUSE",
123
124
  message: `the running animation "${r}" reports a currentTime in an unsupported unit "${String(o.unit)}" — adoptRunning() refuses (only a numeric ms playhead or a scroll-driven "percent" CSSUnitValue can seed the takeover faithfully)`
@@ -126,13 +127,13 @@ var t = (e, t, n, r = {}) => {
126
127
  currentTime: 0,
127
128
  diagnostics: n
128
129
  };
129
- let d = s(e.ownerDocument ?? (typeof document < "u" ? document : void 0) ?? void 0, {
130
+ let u = c(e.ownerDocument ?? (typeof document < "u" ? document : void 0) ?? void 0, {
130
131
  ...t,
131
132
  animationName: r
132
133
  });
133
- for (let e of d.diagnostics) n.push(e);
134
- let p = d.animations.get(r);
135
- if (p == null) return n.push({
134
+ for (let e of u.diagnostics) n.push(e);
135
+ let f = u.animations.get(r);
136
+ if (f == null) return n.push({
136
137
  code: "ADOPT_REFUSE",
137
138
  message: `the @keyframes rule for "${r}" could not be found or reconstructed from the CSSOM — adoptRunning() refuses rather than reconstruct from the lossy computed keyframe list`
138
139
  }), {
@@ -140,21 +141,26 @@ var t = (e, t, n, r = {}) => {
140
141
  currentTime: l,
141
142
  diagnostics: n
142
143
  };
143
- let m = p.animation;
144
- for (let e of p.diagnostics) n.push(e);
144
+ let m = f.animation;
145
+ for (let e of f.diagnostics) n.push(e);
145
146
  m.setTargets(e);
146
- let h = c == null ? l : c * m.options.duration;
147
+ let h = s == null ? l : s * m.options.duration;
147
148
  i && m.interpFrames(h, !0);
148
149
  try {
149
150
  a.cancel();
150
151
  } catch {}
151
- return f(m, h), {
152
+ return p(m, h), {
152
153
  animation: m,
153
154
  currentTime: h,
154
155
  diagnostics: n
155
156
  };
156
- }, f = (e, t) => {
157
+ }, p = (e, t) => {
157
158
  e.setUseWAAPI(!1), e.setDelay(0), e.onStart(), e.started = !0, e.startTime = (typeof performance < "u" && performance.now ? performance.now() : Date.now()) - t, e.t = t, e.play();
158
- };
159
+ }, m = /* @__PURE__ */ e({
160
+ adoptRunning: () => f,
161
+ fromLiveAnimations: () => u,
162
+ fromStyleSheets: () => l,
163
+ resolveLiveKeyframes: () => c
164
+ });
159
165
  //#endregion
160
- export { d as adoptRunning, l as fromLiveAnimations, c as fromStyleSheets, s as resolveLiveKeyframes };
166
+ export { c as a, l as i, f as n, u as r, m as t };