@mkbabb/keyframes.js 5.2.0 → 5.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,3 +0,0 @@
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 };
@@ -1,148 +0,0 @@
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 };
@@ -1,114 +0,0 @@
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 };
@@ -1,390 +0,0 @@
1
- import { n as e } from "./presets-DeDJYL4G.js";
2
- import { d as t, l as n, s as r } from "./sequence-s0bL7Uul.js";
3
- import { a as i, i as a, m as o, o as s, p as c, r as l } from "./engine-CPK_udUQ.js";
4
- import { n as u } from "./scheduler-CfGIC3GX.js";
5
- import { ValueUnit as d, lerp as f } from "@mkbabb/value.js";
6
- //#region src/animation/group/entries.ts
7
- var p = (e) => typeof e == "string" ? e : a(e), m = (e, t, n) => {
8
- let r = p(t), i = e[r];
9
- if (!i) throw Error(`AnimationGroup.${n}: no animation registered for key "${r}". Known keys: ${Object.keys(e).join(", ") || "(none)"}.`);
10
- return i;
11
- }, h = (e) => {
12
- let t = /* @__PURE__ */ new Set();
13
- for (let n of e) {
14
- let e = n.layer.properties;
15
- for (let r of n.animation.flatKeys) e && !e.has(r) || t.add(r);
16
- }
17
- return [...t];
18
- }, g = (e) => {
19
- let t = !0;
20
- for (let n of e) n.animation.interpFrames(n.animation.t, !0), t &&= n.animation.done;
21
- return t;
22
- }, _ = (e) => {
23
- for (let t of e) {
24
- let e = t.animation;
25
- e.started = !0, e.t = e.options.duration, e.interpFrames(e.t, !0);
26
- }
27
- }, v = (e, t) => {
28
- for (let n of e) n.animation.paused = t;
29
- }, y = (e, t) => {
30
- let n;
31
- for (let r of e) {
32
- let e = r.animation;
33
- if (e.paused && e.pausedTime !== 0) continue;
34
- let i = e.advanceTo(t);
35
- typeof i != "number" && (n ??= []).push(i);
36
- }
37
- return n && Promise.all(n).then(() => void 0);
38
- }, b = async (e, t, n) => {
39
- for (let r = 0; r < e.length; r += n) await y(e.slice(r, r + n), t), r + n < e.length && await u();
40
- }, x = (e, t, n) => {
41
- let i = new r({
42
- ...n,
43
- initial: e
44
- });
45
- return i.target = t, i;
46
- }, S = (e, t) => {
47
- let n = !1;
48
- for (let r of e) {
49
- let e = r.layer.weightSpring;
50
- e !== void 0 && (t > 0 && e.tickDt(t), e.settled ? (r.layer.weight = e.value, delete r.layer.weightSpring) : n = !0);
51
- }
52
- return n;
53
- }, C = (e) => e instanceof d && typeof e.value == "number", w = (e, t) => {
54
- let { carriers: n, incomings: r } = t, i = n.length;
55
- if (i !== 0) {
56
- for (let t = 0; t < i; t++) e[t] = n[t].value;
57
- if (t.weighted) {
58
- let n = t.layer.weightSpring?.value ?? t.layer.weight;
59
- for (let t = 0; t < i; t++) e[t] = f(e[t], r[t].value, n);
60
- } else for (let t = 0; t < i; t++) e[t] = e[t] + r[t].value;
61
- for (let t = 0; t < i; t++) n[t].value = e[t];
62
- }
63
- }, T = (e, t) => {
64
- let n = [], r = {}, i = 0;
65
- for (let t of e) {
66
- let { layer: e, values: a } = t;
67
- if (!e.enabled) continue;
68
- let o = e.properties, s = e.blendMode === "weighted";
69
- if (e.blendMode === "replace") {
70
- for (let e in a) {
71
- if (o && !o.has(e)) continue;
72
- let t = a[e];
73
- t !== void 0 && (r[e] = t);
74
- }
75
- continue;
76
- }
77
- let c = [], l = [], u = /* @__PURE__ */ new Set();
78
- for (let e in a) {
79
- if (o && !o.has(e)) continue;
80
- let t = a[e];
81
- if (t === void 0) continue;
82
- let n = r[e];
83
- if (Array.isArray(n) && Array.isArray(t)) {
84
- let r = Math.min(n.length, t.length), i = !0;
85
- for (let e = 0; e < r; e++) if (!C(n[e]) || !C(t[e])) {
86
- i = !1;
87
- break;
88
- }
89
- if (i) for (let e = 0; e < r; e++) c.push(n[e]), l.push(t[e]);
90
- else u.add(e);
91
- } else u.add(e), r[e] = t;
92
- }
93
- c.length > i && (i = c.length), n.push({
94
- layer: e,
95
- weighted: s,
96
- carriers: c,
97
- incomings: l,
98
- boxedKeys: u
99
- });
100
- }
101
- let a = t;
102
- return i > 0 && (a === null || a.length < i) && (a = new Float64Array(i)), {
103
- plans: n,
104
- compositeBuf: a
105
- };
106
- };
107
- //#endregion
108
- //#region src/animation/group/compositor.ts
109
- function E(e, t) {
110
- let n = e._grouped;
111
- e._groupedKeysDirty && (e._groupedKeys = h(e.getEntries()), e._groupedKeysDirty = !1, e._soaPlans = null, e._plainProj = null);
112
- let r = e._groupedKeys;
113
- for (let e = 0; e < r.length; e++) n[r[e]] = void 0;
114
- let a = e.getEntries(), o = e._soaPlans !== null, l = 0, u = !0;
115
- for (let t of a) {
116
- let { animation: r, layer: i, values: a } = t;
117
- if (u &&= r.done, !i.enabled) continue;
118
- r.interpFrames(r.t, !1, a);
119
- let s = i.properties;
120
- if (i.blendMode === "replace") {
121
- for (let e in a) {
122
- if (s && !s.has(e)) continue;
123
- let t = a[e];
124
- t !== void 0 && (n[e] = t);
125
- }
126
- continue;
127
- }
128
- if (o) {
129
- let t = e._soaPlans[l++];
130
- w(e._compositeBuf, t), t.boxedKeys.size > 0 && D(i, a, n, s, t.boxedKeys);
131
- } else D(i, a, n, s);
132
- }
133
- if (!o) {
134
- let { plans: t, compositeBuf: n } = T(a, e._compositeBuf);
135
- e._soaPlans = t, e._compositeBuf = n;
136
- }
137
- e.done = u;
138
- for (let e = 0; e < r.length; e++) {
139
- let t = r[e];
140
- n[t] === void 0 && delete n[t];
141
- }
142
- if (e.transform === c) for (let t of e.getEntries()) {
143
- let n = t.animation.frames[0];
144
- if (n != null && n.transform != null) {
145
- e.transform = n.transform, e.unflatten = t.animation.unflatten;
146
- break;
147
- }
148
- }
149
- if (e.unflatten) {
150
- let r = e._plainProj;
151
- r === null ? (r = i(n), e._plainProj = r) : s(r), e.transform(r.root, t);
152
- } else e.transform(n, t);
153
- return n;
154
- }
155
- function D(e, t, n, r, i) {
156
- if (e.blendMode === "add") {
157
- for (let e in t) {
158
- if (i && !i.has(e) || r && !r.has(e)) continue;
159
- let a = t[e];
160
- if (a === void 0) continue;
161
- let o = n[e];
162
- if (Array.isArray(o) && Array.isArray(a)) {
163
- let e = Math.min(o.length, a.length);
164
- for (let t = 0; t < e; t++) C(o[t]) && C(a[t]) ? o[t].value += a[t].value : o[t] = a[t];
165
- } else n[e] = a;
166
- }
167
- return;
168
- }
169
- let a = e.weightSpring?.value ?? e.weight;
170
- for (let e in t) {
171
- if (i && !i.has(e) || r && !r.has(e)) continue;
172
- let o = t[e];
173
- if (o === void 0) continue;
174
- let s = n[e];
175
- if (Array.isArray(s) && Array.isArray(o)) {
176
- let e = Math.min(s.length, o.length);
177
- for (let t = 0; t < e; t++) C(s[t]) && C(o[t]) ? s[t].value = f(s[t].value, o[t].value, a) : s[t] = o[t];
178
- } else n[e] = o;
179
- }
180
- }
181
- //#endregion
182
- //#region src/animation/group/layer-api.ts
183
- function O(e, t, n) {
184
- let r = m(e.animations, t, "setLayerConfig");
185
- Object.assign(r.layer, n), e.invalidateEntries();
186
- }
187
- function k(e, t) {
188
- return e.animations[p(t)]?.layer;
189
- }
190
- function A(e, t, n) {
191
- let i = m(e.animations, t, "transitionLayer").layer;
192
- i.blendMode = "weighted";
193
- let a = i.weightSpring;
194
- a instanceof r ? a.target = n.weight : i.weightSpring = x(i.weight, n.weight, n.spring), e._hasLayerSprings = !0, e.invalidateEntries();
195
- }
196
- function j(e, t, n, r) {
197
- let i = r?.spring;
198
- A(e, t, {
199
- weight: 0,
200
- ...i ? { spring: i } : {}
201
- }), A(e, n, {
202
- weight: 1,
203
- ...i ? { spring: i } : {}
204
- });
205
- }
206
- //#endregion
207
- //#region src/animation/group/lifecycle.ts
208
- function M(e) {
209
- let t = e.resolvePromise;
210
- e.resolvePromise = null, t?.();
211
- }
212
- async function N(e) {
213
- if (e._playingPromise) return e._playingPromise;
214
- let n = t(e.respectReducedMotion, () => P(e), () => new Promise((t) => {
215
- e.resolvePromise = t, e.playback.loop(e._boundFrame);
216
- }));
217
- return e._playingPromise = n, n.finally(() => {
218
- e._playingPromise = null;
219
- }), n;
220
- }
221
- function P(e) {
222
- e.started = !0;
223
- let t = e.lastTickTime;
224
- return _(e.getEntries()), e.singleTarget && E(e, t), e.settle(), Promise.resolve();
225
- }
226
- function F(e) {
227
- if (!e.started || e.paused) return;
228
- e.paused = !0;
229
- let t = e.lastTickTime;
230
- for (let n of e.getEntries()) {
231
- let e = n.animation;
232
- e.pause(), e.pausedTime === 0 && (e.pausedTime = t);
233
- }
234
- e.playback.stop(), e.render();
235
- }
236
- function I(e) {
237
- !e.started || !e.paused || (e.paused = !1, v(e.getEntries(), !1), e.playback.loop(e._boundFrame));
238
- }
239
- function L(e) {
240
- for (let t of e.getEntries()) t.animation.managed = !1, t.animation.settle();
241
- e.started = !1, e.done = !1, e.paused = !1, e.lastTickTime = 0;
242
- }
243
- function R(e) {
244
- for (let t of e.getEntries()) {
245
- let e = t.animation;
246
- e.started && e.frames.length > 0 && e.interpFrames(0, !0);
247
- }
248
- e.settle();
249
- }
250
- function z(e) {
251
- e.playback.stop(), e.reset(), M(e);
252
- }
253
- function B(e) {
254
- return !(!e.started || e.paused);
255
- }
256
- //#endregion
257
- //#region src/animation/group/group.ts
258
- var V = class e {
259
- animations = {};
260
- transform = c;
261
- superKey;
262
- paused = !1;
263
- started = !1;
264
- done = !1;
265
- respectReducedMotion = !1;
266
- static YIELD_BATCH = 32;
267
- static of(t, ...n) {
268
- return new e(t, ...n);
269
- }
270
- singleTarget = !0;
271
- unflatten = !1;
272
- lastTickTime = 0;
273
- playback = new n();
274
- resolvePromise = null;
275
- _playingPromise = null;
276
- _boundFrame;
277
- _entries = [];
278
- _entriesDirty = !0;
279
- _grouped = {};
280
- _groupedKeys = [];
281
- _groupedKeysDirty = !0;
282
- _soaPlans = null;
283
- _plainProj = null;
284
- _compositeBuf = null;
285
- _hasLayerSprings = !1;
286
- constructor(...e) {
287
- this._boundFrame = this._frame.bind(this);
288
- let t = [];
289
- for (let n of e) {
290
- let e, r;
291
- n instanceof l ? e = n : (e = n.animation, r = n.layer), this.transform === c && e.frames[0] != null && (this.transform = e.frames[0].transform, this.unflatten = e.unflatten);
292
- let i = a(e);
293
- this.animations[i] = {
294
- values: {},
295
- animation: e,
296
- layer: {
297
- ...o,
298
- ...r
299
- }
300
- }, e.managed = !0, t.push(e);
301
- }
302
- this.singleTarget = t.every((e) => e.targets[0] === t[0]?.targets[0]), this.invalidateEntries();
303
- }
304
- getEntries() {
305
- return this._entriesDirty &&= (this._entries = Object.values(this.animations), this._entries.sort((e, t) => e.layer.zIndex - t.layer.zIndex), !1), this._entries;
306
- }
307
- invalidateEntries() {
308
- this._entriesDirty = !0, this._groupedKeysDirty = !0;
309
- }
310
- setSuperKey(e) {
311
- this.superKey = e;
312
- for (let t of this.getEntries()) t.animation.superKey = e;
313
- return this;
314
- }
315
- setTargets(...e) {
316
- let t = this.getEntries();
317
- for (let n of t) n.animation.setTargets(...e);
318
- return this.singleTarget = t.every((e) => e.animation.targets[0] === t[0]?.animation.targets[0]), this;
319
- }
320
- transformFramesGrouped(e) {
321
- return E(this, e);
322
- }
323
- render(e = this.lastTickTime) {
324
- this.singleTarget ? this.transformFramesGrouped(e) : g(this.getEntries());
325
- }
326
- setChildTime(e, t) {
327
- let n = m(this.animations, e, "setChildTime").animation;
328
- return n.t = t, n.startTime !== void 0 && (n.pausedTime = n.startTime + t), this;
329
- }
330
- advanceTo(t) {
331
- let n = this.lastTickTime === 0 ? 0 : t - this.lastTickTime;
332
- this._hasLayerSprings && this.advanceLayerSprings(n), this.lastTickTime = t, this.started = !0;
333
- let r = this.getEntries(), i = e.YIELD_BATCH, a = r.length <= i ? y(r, t) : b(r, t, i);
334
- return a ? a.then(() => this) : this;
335
- }
336
- _frame(e) {
337
- let t = this.advanceTo(e);
338
- return typeof t.then == "function" ? t.then(() => this._renderFrame(e)) : this._renderFrame(e);
339
- }
340
- _renderFrame(e) {
341
- return this.paused ? !1 : (this.singleTarget ? this.transformFramesGrouped(e) : this.done = g(this.getEntries()), this.done ? (this.settle(), M(this), !1) : !0);
342
- }
343
- get finished() {
344
- return this._playingPromise ?? Promise.resolve();
345
- }
346
- async play() {
347
- return N(this);
348
- }
349
- pause() {
350
- return F(this), this;
351
- }
352
- resume() {
353
- return I(this), this;
354
- }
355
- toggle() {
356
- return this.paused ? this.resume() : this.pause();
357
- }
358
- settle() {
359
- return L(this), this;
360
- }
361
- reset() {
362
- return R(this), this;
363
- }
364
- stop() {
365
- return z(this), this;
366
- }
367
- playing() {
368
- return B(this);
369
- }
370
- setLayerConfig(e, t) {
371
- return O(this, e, t), this;
372
- }
373
- setLayerEnabled(e, t) {
374
- return this.setLayerConfig(e, { enabled: t });
375
- }
376
- getLayerConfig(e) {
377
- return k(this, e);
378
- }
379
- transitionLayer(e, t) {
380
- return A(this, e, t), this;
381
- }
382
- crossfade(e, t, n) {
383
- return j(this, e, t, n), this;
384
- }
385
- advanceLayerSprings(e) {
386
- this._hasLayerSprings = S(this.getEntries(), e);
387
- }
388
- }, H = /* @__PURE__ */ e({ AnimationGroup: () => V });
389
- //#endregion
390
- export { V as n, H as t };
@@ -1,21 +0,0 @@
1
- //#region src/animation/svg/handle.ts
2
- var e = class {
3
- animation;
4
- constructor(e) {
5
- this.animation = e;
6
- }
7
- play() {
8
- return this.animation.play();
9
- }
10
- pause() {
11
- return this.animation.pause(), this;
12
- }
13
- stop() {
14
- return this.animation.stop(), this;
15
- }
16
- get finished() {
17
- return this.animation.finished;
18
- }
19
- };
20
- //#endregion
21
- export { e as t };