@mkbabb/keyframes.js 6.2.2 → 6.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.
@@ -1,162 +0,0 @@
1
- import { CubicBezier as e, bezierPresets as t, easing as n, linearEasing as r, steppedEase as i } from "@mkbabb/value.js/easing";
2
- import { collectAnimationOptions as a, collectCustomFunctions as o, collectKeyframes as s, collectPropertyDescriptors as c, collectStyleRules as l, collectTimelineOptions as u, parseAnimationRange as d, parseAnimationTimeline as f, parseCssScalar as p, parseCssValues as m, parseKeyframeSelector as h, parseStylesheet as g, parseTimingFunction as _, serializeCssValue as v, serializeTimelineOptions as y } from "@mkbabb/value.js/css";
3
- //#region src/animation/compile/emit/serialize-value.ts
4
- var b = class extends Error {
5
- value;
6
- issue;
7
- code = "SERIALIZE_INVARIANT";
8
- constructor(e, t) {
9
- super(`ingest admitted a value the serializer refuses (${t.code}).`), this.value = e, this.issue = t, this.name = "SerializeInvariantError";
10
- }
11
- }, x = (e) => {
12
- let t = v(e);
13
- if (!t.ok) throw new b(e, t.error);
14
- return t.value;
15
- }, S = (e, t) => {
16
- let n = `${e / 1e3}s`, r = `${e}ms`;
17
- return t === "s" ? n : t === "ms" ? r : n.length <= r.length ? n : r;
18
- }, C = (e) => e === Infinity ? "infinite" : String(e), w = (e) => [
19
- e.duration == null ? void 0 : S(e.duration, e.durationUnit),
20
- e.timingFunction == null ? void 0 : T(e.timingFunction),
21
- e.delay == null ? void 0 : S(e.delay, e.delayUnit),
22
- e.iterationCount == null ? void 0 : C(e.iterationCount),
23
- e.direction,
24
- e.fillMode,
25
- e.composition,
26
- e.name
27
- ].filter((e) => e !== void 0).join(" "), T = (e) => {
28
- switch (e.kind) {
29
- case "keyword": return e.name;
30
- case "cubic-bezier": return `cubic-bezier(${e.x1}, ${e.y1}, ${e.x2}, ${e.y2})`;
31
- case "steps": return `steps(${e.count}, ${e.position})`;
32
- case "linear-function": return `linear(${e.stops.map((e) => `${e.output}${e.input.map((e) => ` ${e * 100}%`).join("")}`).join(", ")})`;
33
- }
34
- }, E = (e) => e.kind === "percent" ? `${e.value * 100}%` : e.offset === void 0 ? e.name : `${e.name} ${e.offset * 100}%`, D = (e) => `${e.name}: ${x(e.value)}${e.important ? " !important" : ""}`, O = (e) => e.split("\n").map((e) => ` ${e}`).join("\n"), k = (e) => {
35
- switch (e.kind) {
36
- case "keyframes": return `@keyframes ${e.name} {\n${e.rules.map((e) => O(`${e.selectors.map(E).join(", ")} {\n${e.declarations.map((e) => O(`${D(e)};`)).join("\n")}\n}`)).join("\n")}\n}`;
37
- case "property": {
38
- let t = [];
39
- return e.descriptor.syntax !== void 0 && t.push(`syntax: ${e.descriptor.syntax};`), e.descriptor.inherits !== void 0 && t.push(`inherits: ${e.descriptor.inherits};`), e.descriptor.initialValue !== void 0 && t.push(`initial-value: ${x(e.descriptor.initialValue)};`), `@property ${e.name} {\n${t.map(O).join("\n")}\n}`;
40
- }
41
- case "function": {
42
- let t = e.descriptor.parameters?.map((e) => {
43
- let t = e.syntax === void 0 ? "" : ` ${e.syntax}`, n = e.default === void 0 ? "" : `: ${x(e.default)}`;
44
- return `${e.name}${t}${n}`;
45
- }).join(", ") ?? "", n = e.descriptor.declarations?.map((e) => `${D(e)};`) ?? [];
46
- return `@function ${e.name}(${t}) {\n${n.map(O).join("\n")}\n}`;
47
- }
48
- case "style": {
49
- let t = e.declarations.map((e) => `${D(e)};`), n = e.children?.map((e) => k(e)) ?? [];
50
- return `${e.selectors.join(", ")} {\n${[...t, ...n].map(O).join("\n")}\n}`;
51
- }
52
- case "scope": return `@scope (${e.root?.join(", ") ?? ""})${e.limit === void 0 ? "" : ` to (${e.limit.join(", ")})`} {\n${e.children.map((e) => O(k(e))).join("\n")}\n}`;
53
- case "starting-style": return `@starting-style {\n${e.children.map((e) => O(k(e))).join("\n")}\n}`;
54
- case "scroll-timeline": {
55
- let t = Object.entries(e.descriptor).map(([e, t]) => `${e}: ${t};`);
56
- return `@scroll-timeline ${e.name} {\n${t.map(O).join("\n")}\n}`;
57
- }
58
- case "view-timeline": {
59
- let t = Object.entries(e.descriptor).map(([e, t]) => `${e}: ${t};`);
60
- return `@view-timeline ${e.name} {\n${t.map(O).join("\n")}\n}`;
61
- }
62
- case "unknown": {
63
- let t = e.prelude === "" ? "" : ` ${e.prelude}`;
64
- return e.children === void 0 ? e.body === null ? `@${e.atName}${t};` : `@${e.atName}${t} {${e.body}}` : `@${e.atName}${t} {\n${e.children.map((e) => O(k(e))).join("\n")}\n}`;
65
- }
66
- }
67
- }, A = (e) => `${e.code} at ${e.start}-${e.end}: expected ${e.expected.join(" or ")}, got ${e.actual ?? "end of input"}`;
68
- function j(e, t) {
69
- if (e.ok) return e.value;
70
- throw t(e.diagnostics);
71
- }
72
- function M(e, t) {
73
- return e.ok ? {
74
- value: e.value,
75
- issues: []
76
- } : {
77
- value: t,
78
- issues: e.diagnostics
79
- };
80
- }
81
- function N(e, t, n) {
82
- try {
83
- let r = e();
84
- return r.ok ? t(r.value) : n;
85
- } catch {
86
- return n;
87
- }
88
- }
89
- function P(e, t) {
90
- return e.ok ? e.value : t;
91
- }
92
- //#endregion
93
- //#region src/animation/compile/easing/registry.ts
94
- var F = [
95
- "easeOutCubic",
96
- "easeInOutSine",
97
- "easeInOutCubic",
98
- "easeInOutQuad",
99
- "easeInOutExpo",
100
- "easeInOutCirc",
101
- "easeOutExpo",
102
- "smoothStep3",
103
- "easeInBounce"
104
- ], I = [
105
- ...Object.keys(t),
106
- "ease-in-bounce",
107
- ...F
108
- ], L = (e) => {
109
- let t = n(e);
110
- if (!t.ok) throw Error(`value.js rejected its own easing ${JSON.stringify(e)}: ${t.error.code}`);
111
- return t.value;
112
- }, R = I.map((e) => [e, L(e)]), z = new Set(I), B = (e) => {
113
- let t = e.flatMap(({ output: e, input: t }) => t.length === 2 ? [{
114
- output: e,
115
- input: t[0]
116
- }, {
117
- output: e,
118
- input: t[1]
119
- }] : [{
120
- output: e,
121
- input: t[0]
122
- }]);
123
- t[0].input ??= 0, t[t.length - 1].input ??= 1;
124
- let n = t[0].input;
125
- for (let e = 1; e < t.length; e++) {
126
- let r = t[e].input;
127
- r !== void 0 && (t[e].input = Math.max(n, r), n = t[e].input);
128
- }
129
- for (let e = 0; e < t.length - 1;) {
130
- let n = e + 1;
131
- for (; t[n].input === void 0;) n++;
132
- let r = t[e].input, i = t[n].input;
133
- for (let a = e + 1; a < n; a++) t[a].input = r + (i - r) * (a - e) / (n - e);
134
- e = n;
135
- }
136
- return t;
137
- }, V = (t) => {
138
- switch (t.kind) {
139
- case "keyword": {
140
- let e = n(t.name);
141
- if (e.ok) return e.value;
142
- throw TypeError(`Invalid timing function: ${e.error.code}.`);
143
- }
144
- case "cubic-bezier": {
145
- let n = e(t.x1, t.y1, t.x2, t.y2);
146
- if (n.ok) return n.value;
147
- throw TypeError(`Invalid cubic-bezier(): ${n.error.code}.`);
148
- }
149
- case "steps": {
150
- let e = i(t.count, t.position);
151
- if (e.ok) return e.value;
152
- throw TypeError(`Invalid steps(): ${e.error.code}.`);
153
- }
154
- case "linear-function": {
155
- let e = r(B(t.stops));
156
- if (e.ok) return e.value;
157
- throw TypeError(`Invalid linear(): ${e.error.code}.`);
158
- }
159
- }
160
- }, H = (e) => typeof e == "string" ? z.has(e) ? L(e) : V(j(_(e), () => /* @__PURE__ */ TypeError(`Unknown timing function "${e}".`))) : e;
161
- //#endregion
162
- export { S as C, x as D, T as E, w as S, k as T, g as _, o as a, y as b, l as c, P as d, d as f, h as g, m as h, a as i, u as l, p as m, R as n, s as o, f as p, M as r, c as s, H as t, A as u, _ as v, E as w, N as x, j as y };