@mkbabb/keyframes.js 4.1.0 → 4.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 +520 -65
- package/dist/{animate-12YQKwyY.js → animate-D5KoLKwi.js} +2 -2
- package/dist/{animations-CcAWdZlW.js → animations-DaMcGoCd.js} +2 -2
- package/dist/binarySearch-DOP8erk-.js +13 -0
- package/dist/compile-C0xOTIC4.js +249 -0
- package/dist/decay-BvNmFk51.js +25 -0
- package/dist/{draw-svg-DwAa5cbU.js → draw-svg-CF2cTJj-.js} +1 -1
- package/dist/{engine-Cj0T6OIH.js → engine-BKm1GcJT.js} +338 -361
- package/dist/ingest-BFBYGTH-.js +139 -0
- package/dist/keyframes.d.ts +1068 -29
- package/dist/keyframes.js +82 -236
- package/dist/{motion-path-683GcEZK.js → motion-path-CqmlG74k.js} +1 -1
- package/dist/scroll-scene-JpRpH1uU.js +197 -0
- package/dist/sequence-COn8zk5o.js +156 -0
- package/dist/springTimingFunction-CcJEvGwN.js +51 -0
- package/dist/{timeline-BHz0o8dZ.js → timeline-BjcmprQ6.js} +184 -49
- package/dist/waapi-Bd5QadtA.js +179 -0
- package/package.json +110 -11
- package/dist/springTimingFunction-cMJnhbug.js +0 -178
|
@@ -0,0 +1,139 @@
|
|
|
1
|
+
import { CSSKeyframesAnimation as e } from "./engine-BKm1GcJT.js";
|
|
2
|
+
//#region src/animation/ingest-cssom.ts
|
|
3
|
+
var t = (e, t, n, r = {}) => {
|
|
4
|
+
e.push({
|
|
5
|
+
code: t,
|
|
6
|
+
message: n,
|
|
7
|
+
...r
|
|
8
|
+
});
|
|
9
|
+
}, n = (e) => {
|
|
10
|
+
if (typeof CSSKeyframesRule < "u" && e instanceof CSSKeyframesRule) return !0;
|
|
11
|
+
let t = e;
|
|
12
|
+
return t.type === 7 && typeof t.name == "string" && typeof t.cssText == "string";
|
|
13
|
+
}, r = (e, t, r) => {
|
|
14
|
+
let a = [];
|
|
15
|
+
for (let t = 0; t < e.length; t++) {
|
|
16
|
+
let n = e[t];
|
|
17
|
+
if (n == null) continue;
|
|
18
|
+
let r = n;
|
|
19
|
+
r.type === 1 && typeof r.cssText == "string" && a.push(r.cssText);
|
|
20
|
+
}
|
|
21
|
+
for (let o = 0; o < e.length; o++) {
|
|
22
|
+
let s = e[o];
|
|
23
|
+
if (s == null || !n(s)) continue;
|
|
24
|
+
let c = s.name;
|
|
25
|
+
if (r.animationName != null && c !== r.animationName) continue;
|
|
26
|
+
let l = RegExp(`\\banimation(?:-name)?\\s*:[^;}]*\\b${c}\\b`), u = a.find((e) => l.test(e)), d = [], f = i(s.cssText, u, r.options, d);
|
|
27
|
+
f != null && t.set(c, {
|
|
28
|
+
name: c,
|
|
29
|
+
animation: f,
|
|
30
|
+
diagnostics: d
|
|
31
|
+
});
|
|
32
|
+
}
|
|
33
|
+
}, i = (n, r, i, a) => {
|
|
34
|
+
try {
|
|
35
|
+
let t = new e(i ?? {}), o = r ? `${r}\n${n}` : n;
|
|
36
|
+
t.fromString(o);
|
|
37
|
+
for (let e of t.diagnostics) a.push(e);
|
|
38
|
+
return t;
|
|
39
|
+
} catch (e) {
|
|
40
|
+
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 });
|
|
41
|
+
return;
|
|
42
|
+
}
|
|
43
|
+
}, a = (e, n = {}) => {
|
|
44
|
+
let i = /* @__PURE__ */ new Map(), a = [], o;
|
|
45
|
+
if (e == null) {
|
|
46
|
+
if (typeof document > "u") return t(a, "CORS_SKIP", "no document in scope — resolveLiveKeyframes() needs a Document, a CSSStyleSheet[], or a CSSStyleSheet (SSR has no live CSSOM)"), {
|
|
47
|
+
animations: i,
|
|
48
|
+
diagnostics: a
|
|
49
|
+
};
|
|
50
|
+
o = Array.from(document.styleSheets);
|
|
51
|
+
} else o = Array.isArray(e) ? e : typeof Document < "u" && e instanceof Document ? Array.from(e.styleSheets) : [e];
|
|
52
|
+
for (let e of o) {
|
|
53
|
+
let o = null;
|
|
54
|
+
try {
|
|
55
|
+
o = e.cssRules;
|
|
56
|
+
} catch (n) {
|
|
57
|
+
let r = e.href ?? "(inline)";
|
|
58
|
+
t(a, "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 });
|
|
59
|
+
continue;
|
|
60
|
+
}
|
|
61
|
+
o != null && r(o, i, n);
|
|
62
|
+
}
|
|
63
|
+
return {
|
|
64
|
+
animations: i,
|
|
65
|
+
diagnostics: a
|
|
66
|
+
};
|
|
67
|
+
}, o = (e, t = {}) => a(e, t), s = (e, n = {}) => {
|
|
68
|
+
let r = /* @__PURE__ */ new Map(), i = [], o = e ?? (typeof document < "u" ? document : void 0);
|
|
69
|
+
if (o == null || typeof o.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)"), {
|
|
70
|
+
animations: r,
|
|
71
|
+
diagnostics: i
|
|
72
|
+
};
|
|
73
|
+
let s = /* @__PURE__ */ new Set();
|
|
74
|
+
for (let e of o.getAnimations()) {
|
|
75
|
+
let t = e.animationName;
|
|
76
|
+
typeof t == "string" && t.length > 0 && s.add(t);
|
|
77
|
+
}
|
|
78
|
+
let c = (o instanceof Document ? o : o.ownerDocument ?? (typeof document < "u" ? document : void 0)) ?? void 0;
|
|
79
|
+
for (let e of s) {
|
|
80
|
+
let t = a(c, {
|
|
81
|
+
...n,
|
|
82
|
+
animationName: e
|
|
83
|
+
});
|
|
84
|
+
for (let [e, n] of t.animations) r.set(e, n);
|
|
85
|
+
for (let e of t.diagnostics) i.push(e);
|
|
86
|
+
}
|
|
87
|
+
return {
|
|
88
|
+
animations: r,
|
|
89
|
+
diagnostics: i
|
|
90
|
+
};
|
|
91
|
+
}, c = async (e, t) => {
|
|
92
|
+
let n = [], { animationName: r, commit: i = !0 } = t;
|
|
93
|
+
if (typeof e.getAnimations != "function") return n.push({
|
|
94
|
+
code: "WAAPI_INELIGIBLE",
|
|
95
|
+
message: "the element has no getAnimations() — adoptRunning() needs the Web Animations API to read the running animation's playhead"
|
|
96
|
+
}), {
|
|
97
|
+
animation: null,
|
|
98
|
+
currentTime: 0,
|
|
99
|
+
diagnostics: n
|
|
100
|
+
};
|
|
101
|
+
let o = e.getAnimations().find((e) => e.animationName === r);
|
|
102
|
+
if (o == null) return n.push({
|
|
103
|
+
code: "WAAPI_INELIGIBLE",
|
|
104
|
+
message: `no running CSS animation named "${r}" on the element — adoptRunning() refuses (the takeover names exactly one running animation; nothing was silently adopted)`
|
|
105
|
+
}), {
|
|
106
|
+
animation: null,
|
|
107
|
+
currentTime: 0,
|
|
108
|
+
diagnostics: n
|
|
109
|
+
};
|
|
110
|
+
let s = o.currentTime, c = typeof s == "number" && Number.isFinite(s) ? s : 0, u = a(e.ownerDocument ?? (typeof document < "u" ? document : void 0) ?? void 0, {
|
|
111
|
+
...t,
|
|
112
|
+
animationName: r
|
|
113
|
+
});
|
|
114
|
+
for (let e of u.diagnostics) n.push(e);
|
|
115
|
+
let d = u.animations.get(r);
|
|
116
|
+
if (d == null) return n.push({
|
|
117
|
+
code: "PARSE_ERROR",
|
|
118
|
+
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`
|
|
119
|
+
}), {
|
|
120
|
+
animation: null,
|
|
121
|
+
currentTime: c,
|
|
122
|
+
diagnostics: n
|
|
123
|
+
};
|
|
124
|
+
let f = d.animation;
|
|
125
|
+
for (let e of d.diagnostics) n.push(e);
|
|
126
|
+
f.setTargets(e), i && f.interpFrames(c, !0);
|
|
127
|
+
try {
|
|
128
|
+
o.cancel();
|
|
129
|
+
} catch {}
|
|
130
|
+
return l(f, c), {
|
|
131
|
+
animation: f,
|
|
132
|
+
currentTime: c,
|
|
133
|
+
diagnostics: n
|
|
134
|
+
};
|
|
135
|
+
}, l = (e, t) => {
|
|
136
|
+
e.setUseWAAPI(!1), e.onStart(), e.started = !0, e.startTime = (typeof performance < "u" && performance.now ? performance.now() : Date.now()) - t, e.t = t, e.play();
|
|
137
|
+
};
|
|
138
|
+
//#endregion
|
|
139
|
+
export { c as adoptRunning, s as fromLiveAnimations, o as fromStyleSheets, a as resolveLiveKeyframes };
|