@mkbabb/keyframes.js 4.3.0 → 4.4.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 +28 -1
- package/dist/animate-CuUJt2Tb.js +26 -0
- package/dist/{animations-DaMcGoCd.js → animations-5nf2kBkv.js} +3 -3
- package/dist/compile-DgNRG6Lo.js +251 -0
- package/dist/{draw-svg-CF2cTJj-.js → draw-svg-DYRDxBlL.js} +1 -1
- package/dist/engine-CNHvTgpw.js +1122 -0
- package/dist/errors-W8zkvPw4.js +21 -0
- package/dist/format-BUgCTjmr.js +123 -0
- package/dist/ingest-CNM5xkQT.js +160 -0
- package/dist/keyframes.d.ts +2044 -1271
- package/dist/keyframes.js +226 -90
- package/dist/morph-svg-DRjl9Hfz.js +62 -0
- package/dist/{motion-path-CqmlG74k.js → motion-path-J-RSNmRQ.js} +1 -1
- package/dist/rolldown-runtime-Dy4uBu1J.js +11 -0
- package/dist/scheduler-7eIr_q1g.js +14 -0
- package/dist/scroll-grammar-B4kPvGh5.js +23 -0
- package/dist/{scroll-scene-JpRpH1uU.js → scroll-scene-CXEgM49Q.js} +18 -39
- package/dist/{sequence-COn8zk5o.js → sequence-CF5hazqz.js} +49 -7
- package/dist/{springTimingFunction-CcJEvGwN.js → springTimingFunction-CDHZ00JQ.js} +23 -11
- package/dist/{timeline-BjcmprQ6.js → timeline-B7SV3T_E.js} +127 -101
- package/dist/utils-D7nuAND5.js +97 -0
- package/dist/validate-8r6Yo-uc.js +35 -0
- package/dist/{waapi-Bd5QadtA.js → waapi-D9MHMm_9.js} +1 -1
- package/package.json +31 -6
- package/dist/animate-D5KoLKwi.js +0 -21
- package/dist/binarySearch-DOP8erk-.js +0 -13
- package/dist/compile-C0xOTIC4.js +0 -249
- package/dist/engine-BKm1GcJT.js +0 -1028
- package/dist/ingest-BFBYGTH-.js +0 -139
package/dist/engine-BKm1GcJT.js
DELETED
|
@@ -1,1028 +0,0 @@
|
|
|
1
|
-
import { a as e, b as t, d as n, h as r, l as i, v as a } from "./timeline-BjcmprQ6.js";
|
|
2
|
-
import { t as o } from "./binarySearch-DOP8erk-.js";
|
|
3
|
-
import { n as s, r as c } from "./waapi-Bd5QadtA.js";
|
|
4
|
-
import { COLOR_SPACE_RANGES as l, CSSCubicBezier as u, CSSFunction as d, CSSValues as f, FunctionValue as p, ValueArray as m, ValueUnit as h, clamp as g, cssLinear as ee, easeInOutCubic as te, extractAnimationOptions as ne, extractKeyframes as re, extractProperties as _, flattenObject as v, functionIdentityValue as y, isObject as b, lerp as x, lerpValue as S, memoize as C, normalizeValueUnits as w, parseCSSStylesheet as T, parseCSSTime as ie, parseCSSValueUnit as ae, parseLinearStops as oe, parseSteps as se, prepareInterpVar as ce, scale as le, seekPreviousValue as E, sleep as ue, steppedEase as D, timingFunctions as de, tryParse as fe, unflattenObject as pe, unflattenObjectToString as me } from "@mkbabb/value.js";
|
|
5
|
-
import { any as he } from "@mkbabb/parse-that";
|
|
6
|
-
//#region src/animation/adapter.ts
|
|
7
|
-
var ge = (e) => {
|
|
8
|
-
let t = {};
|
|
9
|
-
for (let n of e.declarations) t[n.name] = n.value;
|
|
10
|
-
return t;
|
|
11
|
-
}, _e = (e) => {
|
|
12
|
-
let t = [];
|
|
13
|
-
for (let n of e.selectors) n.kind === "percent" ? t.push(`${n.value}%`) : t.push(n.name);
|
|
14
|
-
return t;
|
|
15
|
-
}, O = (e) => {
|
|
16
|
-
let t = re(e);
|
|
17
|
-
for (let e of t.values()) if (e.length > 0) return e;
|
|
18
|
-
return [];
|
|
19
|
-
}, k = (e) => {
|
|
20
|
-
let t = [], n = (e, n) => {
|
|
21
|
-
t.push({
|
|
22
|
-
code: e,
|
|
23
|
-
message: n.message ?? e,
|
|
24
|
-
...n
|
|
25
|
-
});
|
|
26
|
-
}, r = typeof e == "string" ? T(e) : e, i = O(r);
|
|
27
|
-
typeof e == "string" && i.length === 0 && e.trim() && (r = T(`@keyframes anonymous {\n${e.trim()}\n}`), i = O(r)), typeof e == "string" && i.length === 0 && e.trim() && n("EMPTY_PARSE", {
|
|
28
|
-
message: "the input is non-empty but parsed to zero @keyframes rules (no animatable stops) — the resulting animation has no frames",
|
|
29
|
-
input: e
|
|
30
|
-
});
|
|
31
|
-
let a = /* @__PURE__ */ new Map(), o = /* @__PURE__ */ new Map(), s = /* @__PURE__ */ new Map();
|
|
32
|
-
for (let e of i) {
|
|
33
|
-
let t = ge(e);
|
|
34
|
-
for (let n of _e(e)) {
|
|
35
|
-
let r = a.get(n);
|
|
36
|
-
a.set(n, {
|
|
37
|
-
...r ?? {},
|
|
38
|
-
...t
|
|
39
|
-
}), e.timingFunction != null && o.set(n, e.timingFunction);
|
|
40
|
-
let i = e.composition;
|
|
41
|
-
i != null && s.set(n, i);
|
|
42
|
-
}
|
|
43
|
-
}
|
|
44
|
-
return {
|
|
45
|
-
keyframes: a,
|
|
46
|
-
timingFunctions: o,
|
|
47
|
-
composition: s,
|
|
48
|
-
properties: _(r),
|
|
49
|
-
options: ne(r),
|
|
50
|
-
diagnostics: t
|
|
51
|
-
};
|
|
52
|
-
}, A = [
|
|
53
|
-
"normal",
|
|
54
|
-
"reverse",
|
|
55
|
-
"alternate",
|
|
56
|
-
"alternate-reverse"
|
|
57
|
-
], j = [
|
|
58
|
-
"none",
|
|
59
|
-
"forwards",
|
|
60
|
-
"backwards",
|
|
61
|
-
"both"
|
|
62
|
-
], M = Object.keys(l), N = [
|
|
63
|
-
"shorter",
|
|
64
|
-
"longer",
|
|
65
|
-
"increasing",
|
|
66
|
-
"decreasing"
|
|
67
|
-
], P = () => {}, F = {
|
|
68
|
-
duration: 1e3,
|
|
69
|
-
delay: 0,
|
|
70
|
-
iterationCount: 1,
|
|
71
|
-
direction: "normal",
|
|
72
|
-
fillMode: "forwards",
|
|
73
|
-
timingFunction: { fn: te },
|
|
74
|
-
useWAAPI: !0,
|
|
75
|
-
respectReducedMotion: !1,
|
|
76
|
-
colorSpace: "oklab"
|
|
77
|
-
}, I = {
|
|
78
|
-
zIndex: 0,
|
|
79
|
-
weight: 1,
|
|
80
|
-
blendMode: "replace",
|
|
81
|
-
enabled: !0
|
|
82
|
-
}, L = null, ve = () => typeof MessageChannel == "function" ? () => new Promise((e) => {
|
|
83
|
-
let t = new MessageChannel();
|
|
84
|
-
t.port1.onmessage = () => {
|
|
85
|
-
t.port1.close(), e();
|
|
86
|
-
}, t.port2.postMessage(void 0);
|
|
87
|
-
}) : () => new Promise((e) => setTimeout(e, 0));
|
|
88
|
-
function ye() {
|
|
89
|
-
let e = globalThis.scheduler;
|
|
90
|
-
return e && typeof e.yield == "function" ? e.yield() : (L ??= ve(), L());
|
|
91
|
-
}
|
|
92
|
-
//#endregion
|
|
93
|
-
//#region src/animation/group.ts
|
|
94
|
-
var R = (e) => e instanceof h && typeof e.value == "number", z = class t {
|
|
95
|
-
animations = {};
|
|
96
|
-
transform = P;
|
|
97
|
-
superKey;
|
|
98
|
-
paused = !1;
|
|
99
|
-
started = !1;
|
|
100
|
-
done = !1;
|
|
101
|
-
respectReducedMotion = !1;
|
|
102
|
-
static YIELD_BATCH = 32;
|
|
103
|
-
singleTarget = !0;
|
|
104
|
-
lastTickTime = 0;
|
|
105
|
-
playback = new i();
|
|
106
|
-
resolvePromise = null;
|
|
107
|
-
_playingPromise = null;
|
|
108
|
-
_boundFrame;
|
|
109
|
-
_entries = [];
|
|
110
|
-
_entriesDirty = !0;
|
|
111
|
-
_grouped = {};
|
|
112
|
-
_groupedKeys = [];
|
|
113
|
-
_groupedKeysDirty = !0;
|
|
114
|
-
_hasLayerSprings = !1;
|
|
115
|
-
constructor(...e) {
|
|
116
|
-
this._boundFrame = this._frame.bind(this);
|
|
117
|
-
let t = [];
|
|
118
|
-
for (let n of e) {
|
|
119
|
-
let e, r;
|
|
120
|
-
n instanceof $ ? e = n : (e = n.animation, r = n.layer), this.transform === P && e.frames[0] != null && (this.transform = e.frames[0].transform);
|
|
121
|
-
let i = Q(e);
|
|
122
|
-
this.animations[i] = {
|
|
123
|
-
values: {},
|
|
124
|
-
animation: e,
|
|
125
|
-
layer: {
|
|
126
|
-
...I,
|
|
127
|
-
...r
|
|
128
|
-
}
|
|
129
|
-
}, e.managed = !0, t.push(e);
|
|
130
|
-
}
|
|
131
|
-
this.singleTarget = t.every((e) => e.targets[0] === t[0]?.targets[0]), this.invalidateEntries();
|
|
132
|
-
}
|
|
133
|
-
getEntries() {
|
|
134
|
-
return this._entriesDirty &&= (this._entries = Object.values(this.animations), this._entries.sort((e, t) => e.layer.zIndex - t.layer.zIndex), !1), this._entries;
|
|
135
|
-
}
|
|
136
|
-
invalidateEntries() {
|
|
137
|
-
this._entriesDirty = !0, this._groupedKeysDirty = !0;
|
|
138
|
-
}
|
|
139
|
-
computeGroupedKeys() {
|
|
140
|
-
let e = /* @__PURE__ */ new Set();
|
|
141
|
-
for (let t of this.getEntries()) {
|
|
142
|
-
let n = t.layer.properties;
|
|
143
|
-
for (let r of t.animation.flatKeys) n && !n.has(r) || e.add(r);
|
|
144
|
-
}
|
|
145
|
-
this._groupedKeys = [...e];
|
|
146
|
-
}
|
|
147
|
-
setSuperKey(e) {
|
|
148
|
-
this.superKey = e;
|
|
149
|
-
for (let t of this.getEntries()) t.animation.superKey = e;
|
|
150
|
-
return this;
|
|
151
|
-
}
|
|
152
|
-
setTargets(...e) {
|
|
153
|
-
let t = this.getEntries();
|
|
154
|
-
for (let n of t) n.animation.setTargets(...e);
|
|
155
|
-
return this.singleTarget = t.every((e) => e.animation.targets[0] === t[0]?.animation.targets[0]), this;
|
|
156
|
-
}
|
|
157
|
-
onStart() {
|
|
158
|
-
return this.started = !0, this;
|
|
159
|
-
}
|
|
160
|
-
onEnd() {
|
|
161
|
-
return this;
|
|
162
|
-
}
|
|
163
|
-
transformFramesGrouped(e) {
|
|
164
|
-
let t = this._grouped;
|
|
165
|
-
this._groupedKeysDirty &&= (this.computeGroupedKeys(), !1);
|
|
166
|
-
let n = this._groupedKeys;
|
|
167
|
-
for (let e = 0; e < n.length; e++) t[n[e]] = void 0;
|
|
168
|
-
let r = this.getEntries(), i = !0;
|
|
169
|
-
for (let e of r) {
|
|
170
|
-
let { animation: n, layer: r, values: a } = e;
|
|
171
|
-
if (i &&= n.done, !r.enabled) continue;
|
|
172
|
-
n.interpFrames(n.t, !1, a);
|
|
173
|
-
let o = r.properties;
|
|
174
|
-
switch (r.blendMode) {
|
|
175
|
-
case "replace":
|
|
176
|
-
for (let e in a) {
|
|
177
|
-
if (o && !o.has(e)) continue;
|
|
178
|
-
let n = a[e];
|
|
179
|
-
n !== void 0 && (t[e] = n);
|
|
180
|
-
}
|
|
181
|
-
break;
|
|
182
|
-
case "add":
|
|
183
|
-
for (let e in a) {
|
|
184
|
-
if (o && !o.has(e)) continue;
|
|
185
|
-
let n = a[e];
|
|
186
|
-
if (n === void 0) continue;
|
|
187
|
-
let r = t[e];
|
|
188
|
-
if (Array.isArray(r) && Array.isArray(n)) {
|
|
189
|
-
let e = Math.min(r.length, n.length);
|
|
190
|
-
for (let t = 0; t < e; t++) R(r[t]) && R(n[t]) ? r[t].value += n[t].value : r[t] = n[t];
|
|
191
|
-
} else t[e] = n;
|
|
192
|
-
}
|
|
193
|
-
break;
|
|
194
|
-
case "weighted": {
|
|
195
|
-
let e = r.weightSpring?.value ?? r.weight;
|
|
196
|
-
for (let n in a) {
|
|
197
|
-
if (o && !o.has(n)) continue;
|
|
198
|
-
let r = a[n];
|
|
199
|
-
if (r === void 0) continue;
|
|
200
|
-
let i = t[n];
|
|
201
|
-
if (Array.isArray(i) && Array.isArray(r)) {
|
|
202
|
-
let t = Math.min(i.length, r.length);
|
|
203
|
-
for (let n = 0; n < t; n++) R(i[n]) && R(r[n]) ? i[n].value = x(i[n].value, r[n].value, e) : i[n] = r[n];
|
|
204
|
-
} else t[n] = r;
|
|
205
|
-
}
|
|
206
|
-
break;
|
|
207
|
-
}
|
|
208
|
-
}
|
|
209
|
-
}
|
|
210
|
-
this.done = i;
|
|
211
|
-
for (let e = 0; e < n.length; e++) {
|
|
212
|
-
let r = n[e];
|
|
213
|
-
t[r] === void 0 && delete t[r];
|
|
214
|
-
}
|
|
215
|
-
if (this.transform === P) for (let e of this.getEntries()) {
|
|
216
|
-
let t = e.animation.frames[0];
|
|
217
|
-
if (t != null && t.transform != null) {
|
|
218
|
-
this.transform = t.transform;
|
|
219
|
-
break;
|
|
220
|
-
}
|
|
221
|
-
}
|
|
222
|
-
return this.transform(t, e), t;
|
|
223
|
-
}
|
|
224
|
-
render() {
|
|
225
|
-
let e = this.lastTickTime || performance.now();
|
|
226
|
-
if (this.singleTarget) this.transformFramesGrouped(e);
|
|
227
|
-
else for (let e of this.getEntries()) e.animation.interpFrames(e.animation.t, !0);
|
|
228
|
-
}
|
|
229
|
-
setChildTime(e, t) {
|
|
230
|
-
let n = typeof e == "string" ? e : Q(e), r = this.animations[n];
|
|
231
|
-
if (!r) throw Error(`AnimationGroup.setChildTime: no animation registered for key "${n}". Known keys: ${Object.keys(this.animations).join(", ") || "(none)"}.`);
|
|
232
|
-
let i = r.animation;
|
|
233
|
-
return i.t = t, i.startTime !== void 0 && (i.pausedTime = i.startTime + t), this;
|
|
234
|
-
}
|
|
235
|
-
advanceTo(e) {
|
|
236
|
-
let n = this.lastTickTime === 0 ? 0 : e - this.lastTickTime;
|
|
237
|
-
this._hasLayerSprings && this.advanceLayerSprings(n), this.lastTickTime = e, this.started || this.onStart();
|
|
238
|
-
let r = this.getEntries(), i = t.YIELD_BATCH, a = r.length <= i ? this._advanceSlice(r, e) : this._advanceBatched(r, e, i);
|
|
239
|
-
return a ? a.then(() => this._endAdvance()) : this._endAdvance();
|
|
240
|
-
}
|
|
241
|
-
async _advanceBatched(e, t, n) {
|
|
242
|
-
for (let r = 0; r < e.length; r += n) await this._advanceSlice(e.slice(r, r + n), t), r + n < e.length && await ye();
|
|
243
|
-
}
|
|
244
|
-
_endAdvance() {
|
|
245
|
-
return this.done && this.onEnd(), this;
|
|
246
|
-
}
|
|
247
|
-
_advanceSlice(e, t) {
|
|
248
|
-
let n;
|
|
249
|
-
for (let r of e) {
|
|
250
|
-
let e = r.animation;
|
|
251
|
-
if (e.paused && e.pausedTime !== 0) continue;
|
|
252
|
-
let i = e.advanceTo(t);
|
|
253
|
-
typeof i != "number" && (n ??= []).push(i);
|
|
254
|
-
}
|
|
255
|
-
return n && Promise.all(n).then(() => void 0);
|
|
256
|
-
}
|
|
257
|
-
_frame(e) {
|
|
258
|
-
let t = this.advanceTo(e);
|
|
259
|
-
return typeof t.then == "function" ? t.then(() => this._renderFrame(e)) : this._renderFrame(e);
|
|
260
|
-
}
|
|
261
|
-
_renderFrame(e) {
|
|
262
|
-
if (this.paused) return !1;
|
|
263
|
-
if (this.singleTarget) this.transformFramesGrouped(e);
|
|
264
|
-
else {
|
|
265
|
-
let e = !0;
|
|
266
|
-
for (let t of this.getEntries()) t.animation.interpFrames(t.animation.t, !0), e &&= t.animation.done;
|
|
267
|
-
this.done = e;
|
|
268
|
-
}
|
|
269
|
-
return this.done ? (this.settle(), this._resolvePlay(), !1) : !0;
|
|
270
|
-
}
|
|
271
|
-
_resolvePlay() {
|
|
272
|
-
let e = this.resolvePromise;
|
|
273
|
-
this.resolvePromise = null, e?.();
|
|
274
|
-
}
|
|
275
|
-
get finished() {
|
|
276
|
-
return this._playingPromise ?? Promise.resolve();
|
|
277
|
-
}
|
|
278
|
-
async play() {
|
|
279
|
-
if (this._playingPromise) return this._playingPromise;
|
|
280
|
-
let e = n(this.respectReducedMotion, () => this._playReducedMotion(), () => new Promise((e) => {
|
|
281
|
-
this.resolvePromise = e, this.playback.loop(this._boundFrame);
|
|
282
|
-
}));
|
|
283
|
-
return this._playingPromise = e, e.finally(() => {
|
|
284
|
-
this._playingPromise = null;
|
|
285
|
-
}), e;
|
|
286
|
-
}
|
|
287
|
-
_playReducedMotion() {
|
|
288
|
-
this.onStart();
|
|
289
|
-
let e = this.lastTickTime || performance.now();
|
|
290
|
-
this.lastTickTime = e;
|
|
291
|
-
for (let e of this.getEntries()) {
|
|
292
|
-
let t = e.animation;
|
|
293
|
-
t.started = !0, t.t = t.options.duration, t.interpFrames(t.t, !0);
|
|
294
|
-
}
|
|
295
|
-
return this.singleTarget && this.transformFramesGrouped(e), this.settle(), Promise.resolve();
|
|
296
|
-
}
|
|
297
|
-
pause() {
|
|
298
|
-
if (!this.started || this.paused) return this;
|
|
299
|
-
this.paused = !0;
|
|
300
|
-
let e = this.lastTickTime || performance.now();
|
|
301
|
-
for (let t of this.getEntries()) {
|
|
302
|
-
let n = t.animation;
|
|
303
|
-
n.pause(), n.pausedTime === 0 && (n.pausedTime = e);
|
|
304
|
-
}
|
|
305
|
-
return this.playback.stop(), this.render(), this;
|
|
306
|
-
}
|
|
307
|
-
resume() {
|
|
308
|
-
if (!this.started || !this.paused) return this;
|
|
309
|
-
this.paused = !1;
|
|
310
|
-
for (let e of this.getEntries()) e.animation.paused = !1;
|
|
311
|
-
return this.playback.loop(this._boundFrame), this;
|
|
312
|
-
}
|
|
313
|
-
toggle() {
|
|
314
|
-
return this.paused ? this.resume() : this.pause();
|
|
315
|
-
}
|
|
316
|
-
settle() {
|
|
317
|
-
for (let e of this.getEntries()) e.animation.managed = !1, e.animation.settle();
|
|
318
|
-
return this.started = !1, this.done = !1, this.paused = !1, this.lastTickTime = 0, this;
|
|
319
|
-
}
|
|
320
|
-
reset() {
|
|
321
|
-
for (let e of this.getEntries()) {
|
|
322
|
-
let t = e.animation;
|
|
323
|
-
t.started && t.frames.length > 0 && t.interpFrames(0, !0);
|
|
324
|
-
}
|
|
325
|
-
return this.settle();
|
|
326
|
-
}
|
|
327
|
-
stop() {
|
|
328
|
-
return this.playback.stop(), this.reset(), this._resolvePlay(), this;
|
|
329
|
-
}
|
|
330
|
-
playing() {
|
|
331
|
-
return !(!this.started || this.paused);
|
|
332
|
-
}
|
|
333
|
-
forcePause() {
|
|
334
|
-
this.paused = !0;
|
|
335
|
-
for (let e of this.getEntries()) e.animation.paused = !0;
|
|
336
|
-
}
|
|
337
|
-
forcePlay() {
|
|
338
|
-
this.paused = !1;
|
|
339
|
-
for (let e of this.getEntries()) e.animation.paused = !1;
|
|
340
|
-
}
|
|
341
|
-
setLayerConfig(e, t) {
|
|
342
|
-
let n = typeof e == "string" ? e : Q(e), r = this.animations[n];
|
|
343
|
-
if (!r) throw Error(`AnimationGroup.setLayerConfig: no animation registered for key "${n}". Known keys: ${Object.keys(this.animations).join(", ") || "(none)"}.`);
|
|
344
|
-
return Object.assign(r.layer, t), this.invalidateEntries(), this;
|
|
345
|
-
}
|
|
346
|
-
setLayerEnabled(e, t) {
|
|
347
|
-
return this.setLayerConfig(e, { enabled: t });
|
|
348
|
-
}
|
|
349
|
-
getLayerConfig(e) {
|
|
350
|
-
let t = typeof e == "string" ? e : Q(e);
|
|
351
|
-
return this.animations[t]?.layer;
|
|
352
|
-
}
|
|
353
|
-
requireEntry(e, t) {
|
|
354
|
-
let n = typeof e == "string" ? e : Q(e), r = this.animations[n];
|
|
355
|
-
if (!r) throw Error(`AnimationGroup.${t}: no animation registered for key "${n}". Known keys: ${Object.keys(this.animations).join(", ") || "(none)"}.`);
|
|
356
|
-
return r;
|
|
357
|
-
}
|
|
358
|
-
transitionLayer(t, n) {
|
|
359
|
-
let r = this.requireEntry(t, "transitionLayer").layer;
|
|
360
|
-
r.blendMode = "weighted";
|
|
361
|
-
let i = r.weightSpring;
|
|
362
|
-
if (i instanceof e) i.target = n.weight;
|
|
363
|
-
else {
|
|
364
|
-
let t = new e({
|
|
365
|
-
...n.spring,
|
|
366
|
-
initial: r.weight
|
|
367
|
-
});
|
|
368
|
-
t.target = n.weight, r.weightSpring = t;
|
|
369
|
-
}
|
|
370
|
-
return this._hasLayerSprings = !0, this.invalidateEntries(), this;
|
|
371
|
-
}
|
|
372
|
-
crossfade(e, t, n) {
|
|
373
|
-
let r = n?.spring;
|
|
374
|
-
return this.transitionLayer(e, {
|
|
375
|
-
weight: 0,
|
|
376
|
-
...r ? { spring: r } : {}
|
|
377
|
-
}), this.transitionLayer(t, {
|
|
378
|
-
weight: 1,
|
|
379
|
-
...r ? { spring: r } : {}
|
|
380
|
-
}), this;
|
|
381
|
-
}
|
|
382
|
-
advanceLayerSprings(e) {
|
|
383
|
-
let t = !1;
|
|
384
|
-
for (let n of this.getEntries()) {
|
|
385
|
-
let r = n.layer.weightSpring;
|
|
386
|
-
r !== void 0 && (e > 0 && r.tickDt(e), r.settled ? (n.layer.weight = r.value, delete n.layer.weightSpring) : t = !0);
|
|
387
|
-
}
|
|
388
|
-
this._hasLayerSprings = t;
|
|
389
|
-
}
|
|
390
|
-
}, B = Symbol("kf.fnName"), V = (e) => e[B], H = (e, t) => (t !== void 0 && (e[B] = t), e), U = (e, t) => {
|
|
391
|
-
if (e instanceof h) return [H(e.clone(), t ?? V(e))];
|
|
392
|
-
if (e instanceof p) return e.values.flatMap((t) => U(t, e.name));
|
|
393
|
-
if (e instanceof m) return e.flatMap((e) => U(e, t));
|
|
394
|
-
throw TypeError(`Expected ValueUnit/FunctionValue/ValueArray, got ${typeof e}`);
|
|
395
|
-
}, be = (e) => {
|
|
396
|
-
let t = e.split(".").pop(), n = e.split(".").shift();
|
|
397
|
-
if (!t || !n) throw Error(`Invalid flattened key: ${e}`);
|
|
398
|
-
return {
|
|
399
|
-
mainKey: n,
|
|
400
|
-
childKey: t
|
|
401
|
-
};
|
|
402
|
-
}, W = (e, t, n) => (e.setProperty(t), n !== t && e.setSubProperty(n), e), xe = /^\s*cubic-bezier\s*\(\s*(-?[\d.]+)\s*,\s*(-?[\d.]+)\s*,\s*(-?[\d.]+)\s*,\s*(-?[\d.]+)\s*\)\s*$/i, Se = /^\s*steps\s*\(/i, Ce = /^\s*linear\s*\(/i, G = (e) => {
|
|
403
|
-
if (e == null) return;
|
|
404
|
-
if (typeof e != "string") return e;
|
|
405
|
-
let t = e.match(xe);
|
|
406
|
-
if (t) {
|
|
407
|
-
let e = t.slice(1, 5).map((e) => Number.parseFloat(e ?? ""));
|
|
408
|
-
if (e.length === 4 && e.every((e) => Number.isFinite(e))) {
|
|
409
|
-
let [t, n, r, i] = e;
|
|
410
|
-
return u(t, n, r, i);
|
|
411
|
-
}
|
|
412
|
-
}
|
|
413
|
-
if (Se.test(e)) try {
|
|
414
|
-
let { count: t, jumpTerm: n } = se(e);
|
|
415
|
-
return D(t, n);
|
|
416
|
-
} catch {}
|
|
417
|
-
if (e === "step-start") return D(1, "jump-start");
|
|
418
|
-
if (e === "step-end") return D(1, "jump-end");
|
|
419
|
-
if (Ce.test(e)) {
|
|
420
|
-
let t = e.replace(/,\s*(-?[\d.]+%)/g, " $1");
|
|
421
|
-
try {
|
|
422
|
-
return ee(oe(t));
|
|
423
|
-
} catch {}
|
|
424
|
-
}
|
|
425
|
-
let n = de[e];
|
|
426
|
-
if (typeof n == "function" && n.length <= 1) return n;
|
|
427
|
-
}, we = C((e, t) => U(fe(he(d.FunctionArgs.map((t) => (t.setSubProperty(e), t)), f.Value), t)), {
|
|
428
|
-
maxCacheSize: 2048,
|
|
429
|
-
keyFn: (e, t) => `${e}:${t}`
|
|
430
|
-
});
|
|
431
|
-
function Te(e) {
|
|
432
|
-
let t = v(e), n = (e, t) => {
|
|
433
|
-
let { childKey: r, mainKey: i } = be(e);
|
|
434
|
-
return t instanceof h ? W(new m(...U(t)), i, r) : t instanceof p ? W(new m(...t.values.flatMap((r) => U(n(e, r), t.name))), i, r) : t instanceof m ? W(new m(...t.flatMap((t) => U(n(e, t)))), i, r) : W(new m(...we(r, String(t)).map((e) => H(e.clone(), V(e)))), i, r);
|
|
435
|
-
};
|
|
436
|
-
return Object.entries(t).reduce((e, [t, r]) => (e[t] = n(t, r), e), {});
|
|
437
|
-
}
|
|
438
|
-
var K = (e, t, n, r, i = "oklab", a) => {
|
|
439
|
-
let o = r[t], s = r[n];
|
|
440
|
-
if (!o || !s) throw Error(`Invalid interpolation frame bounds (${t} -> ${n}).`);
|
|
441
|
-
let c = o[e], l = s[e];
|
|
442
|
-
if (!c || !l) throw Error(`Missing variable "${e}" in interpolation bounds.`);
|
|
443
|
-
let u = Math.max(c.length, l.length), d = (t, n) => {
|
|
444
|
-
let r = t.map((t) => {
|
|
445
|
-
if (!(t instanceof h)) throw TypeError(`Interpolation for "${e}" requires ValueUnit leaves.`);
|
|
446
|
-
return t;
|
|
447
|
-
});
|
|
448
|
-
for (; r.length < u;) {
|
|
449
|
-
let e = n[r.length], t = e instanceof h ? V(e) : void 0, i = t ? y(t) : void 0;
|
|
450
|
-
r.push(i ?? new h(0));
|
|
451
|
-
}
|
|
452
|
-
return r;
|
|
453
|
-
}, f = d(c, l), p = d(l, c);
|
|
454
|
-
return f.map((t, n) => {
|
|
455
|
-
let r = p[n];
|
|
456
|
-
if (!r) throw Error(`Missing right-hand interpolation value at index ${n}.`);
|
|
457
|
-
if (!(t instanceof h) || !(r instanceof h)) throw TypeError(`Interpolation for "${e}" requires ValueUnit leaves.`);
|
|
458
|
-
let o = { colorSpace: i };
|
|
459
|
-
return a !== void 0 && (o.hueMethod = a), ce(w(t, r, o));
|
|
460
|
-
});
|
|
461
|
-
};
|
|
462
|
-
function Ee(e, t, n) {
|
|
463
|
-
let [r, i] = [e.start, t.start];
|
|
464
|
-
return {
|
|
465
|
-
start: r.value * n / 100,
|
|
466
|
-
stop: i.value * n / 100
|
|
467
|
-
};
|
|
468
|
-
}
|
|
469
|
-
function q(e, t, n = !0) {
|
|
470
|
-
e = n ? e : v(e);
|
|
471
|
-
let r = me(e);
|
|
472
|
-
t.forEach((e) => {
|
|
473
|
-
Object.entries(r).forEach(([t, n]) => {
|
|
474
|
-
e.style.setProperty(t, n);
|
|
475
|
-
});
|
|
476
|
-
});
|
|
477
|
-
}
|
|
478
|
-
//#endregion
|
|
479
|
-
//#region src/animation/frame-compiler.ts
|
|
480
|
-
var J = (e, t) => {
|
|
481
|
-
if (typeof t == "function") return { fn: t };
|
|
482
|
-
if (typeof t == "object") {
|
|
483
|
-
if (typeof t.fn == "function") return t;
|
|
484
|
-
throw new a(e, t, "an Easing must carry a callable `fn`");
|
|
485
|
-
}
|
|
486
|
-
let n = G(t);
|
|
487
|
-
if (!n) throw new a(e, t, "unknown timing function — pass a callable TimingFunction, a typed Easing, a registry name, or a cubic-bezier() literal", "UNKNOWN_TIMING_FN");
|
|
488
|
-
let i = r(t);
|
|
489
|
-
return i ? {
|
|
490
|
-
fn: n,
|
|
491
|
-
css: i
|
|
492
|
-
} : { fn: n };
|
|
493
|
-
}, De = 1e6, Y = /^(?:from|to)$/i, Oe = /^(?:\d+(?:\.\d+)?|\.\d+)(?:[eE][+-]?\d+)?%$/, X = "a keyframe selector must be a percentage 0%–100% (e.g. \"0%\", \"50%\") or the keyword 'from'/'to'", ke = class {
|
|
494
|
-
_options;
|
|
495
|
-
templateFrames = [];
|
|
496
|
-
parsedVars = [];
|
|
497
|
-
frames = [];
|
|
498
|
-
frameId = 0;
|
|
499
|
-
constructor(e) {
|
|
500
|
-
this._options = e;
|
|
501
|
-
}
|
|
502
|
-
get options() {
|
|
503
|
-
return this._options;
|
|
504
|
-
}
|
|
505
|
-
addFrame(e, t, n, r, i) {
|
|
506
|
-
typeof e == "number" ? e = String(e) + "%" : typeof e == "string" ? e = e : e instanceof h && (e = String(e));
|
|
507
|
-
let o = e.trim();
|
|
508
|
-
if (o === "") throw new a("start", e, `${X} — got an empty/blank string`, "EMPTY_PARSE");
|
|
509
|
-
if (!Y.test(o) && !(Oe.test(o) && parseFloat(o) <= 100)) throw new a("start", e, `${X} — got ${JSON.stringify(e)}`);
|
|
510
|
-
let s = ae(o), c = {
|
|
511
|
-
id: this.frameId,
|
|
512
|
-
start: s,
|
|
513
|
-
vars: t,
|
|
514
|
-
transform: n,
|
|
515
|
-
timingFunction: r == null ? this.options.timingFunction : J("timingFunction", r),
|
|
516
|
-
composition: i
|
|
517
|
-
};
|
|
518
|
-
this.templateFrames.push(c), this.frameId += 1;
|
|
519
|
-
}
|
|
520
|
-
createFrame(e, t) {
|
|
521
|
-
let n = this.templateFrames[e], r = this.templateFrames[t], i = {
|
|
522
|
-
start: e,
|
|
523
|
-
stop: t
|
|
524
|
-
}, a = Ee(n, r, this.options.duration), o = n.transform;
|
|
525
|
-
if (o == null) {
|
|
526
|
-
let t = E(e, this.templateFrames, (e) => e.transform != null);
|
|
527
|
-
o = (t === void 0 ? void 0 : this.templateFrames[t].transform) ?? P;
|
|
528
|
-
}
|
|
529
|
-
let s = n.timingFunction;
|
|
530
|
-
if (s == null) {
|
|
531
|
-
let t = E(e, this.templateFrames, (e) => e.timingFunction != null);
|
|
532
|
-
s = (t === void 0 ? void 0 : this.templateFrames[t].timingFunction) ?? this.options.timingFunction;
|
|
533
|
-
}
|
|
534
|
-
let c = e * De + t, l = r.composition;
|
|
535
|
-
return {
|
|
536
|
-
id: c,
|
|
537
|
-
ixs: i,
|
|
538
|
-
start: n.start,
|
|
539
|
-
time: a,
|
|
540
|
-
vars: void 0,
|
|
541
|
-
flatVars: void 0,
|
|
542
|
-
interpVars: {},
|
|
543
|
-
allInterpVars: [],
|
|
544
|
-
transform: o,
|
|
545
|
-
timingFunction: s,
|
|
546
|
-
...l == null ? {} : { composition: l }
|
|
547
|
-
};
|
|
548
|
-
}
|
|
549
|
-
buildVarIndex() {
|
|
550
|
-
let e = /* @__PURE__ */ new Map();
|
|
551
|
-
for (let t = 0; t < this.parsedVars.length; t++) for (let n of Object.keys(this.parsedVars[t])) {
|
|
552
|
-
let r = e.get(n);
|
|
553
|
-
r || (r = [], e.set(n, r)), r.push(t);
|
|
554
|
-
}
|
|
555
|
-
return e;
|
|
556
|
-
}
|
|
557
|
-
reconcileVars(e, t) {
|
|
558
|
-
let n = this.parsedVars[e];
|
|
559
|
-
if (n) for (let r of Object.keys(n)) {
|
|
560
|
-
let n = t.get(r);
|
|
561
|
-
if (!n) continue;
|
|
562
|
-
let i = -1;
|
|
563
|
-
for (let t of n) if (t > e) {
|
|
564
|
-
i = t;
|
|
565
|
-
break;
|
|
566
|
-
}
|
|
567
|
-
if (i === -1) continue;
|
|
568
|
-
let [a, o] = [e, i], s = this.frames.findIndex((e) => e.ixs.start === a && e.ixs.stop === o), c = s === -1 ? this.createFrame(a, o) : this.frames[s];
|
|
569
|
-
c.interpVars[r] = K(r, a, o, this.parsedVars, this.options.colorSpace, this.options.hueMethod), s === -1 && this.frames.push(c);
|
|
570
|
-
}
|
|
571
|
-
}
|
|
572
|
-
parse(e) {
|
|
573
|
-
this.frames = [], this.templateFrames.sort((e, t) => e.start.value - t.start.value), this.parsedVars = this.templateFrames.map((t) => {
|
|
574
|
-
let n = Te(t.vars);
|
|
575
|
-
return Object.values(n).forEach((t) => {
|
|
576
|
-
t.setTargets(e);
|
|
577
|
-
}), n;
|
|
578
|
-
});
|
|
579
|
-
for (let e = 0; e < this.templateFrames.length - 1; e++) this.frames.push(this.createFrame(e, e + 1));
|
|
580
|
-
let t = this.buildVarIndex();
|
|
581
|
-
this.frames.forEach((e, n) => this.reconcileVars(n, t)), this.frames.sort((e, t) => e.time.start === t.time.start ? e.time.stop - t.time.stop : e.time.start - t.time.start), this.frames = this.frames.filter((e) => e.interpVars != null && Object.keys(e.interpVars).length > 0), this.frames.forEach((e) => this.finalizeFrameVars(e));
|
|
582
|
-
}
|
|
583
|
-
finalizeFrameVars(e) {
|
|
584
|
-
e.flatVars = Object.entries(e.interpVars).reduce((e, [t, n]) => (e[t] = n.map((e) => e.value), e), {}), e.vars = pe(e.flatVars), e.allInterpVars = Object.values(e.interpVars).flat();
|
|
585
|
-
}
|
|
586
|
-
renormalizeColors() {
|
|
587
|
-
for (let e of this.frames) {
|
|
588
|
-
for (let t of Object.keys(e.interpVars)) e.interpVars[t] = K(t, e.ixs.start, e.ixs.stop, this.parsedVars, this.options.colorSpace, this.options.hueMethod);
|
|
589
|
-
this.finalizeFrameVars(e);
|
|
590
|
-
}
|
|
591
|
-
}
|
|
592
|
-
}, Z = (e) => {
|
|
593
|
-
try {
|
|
594
|
-
let t = ie(e);
|
|
595
|
-
return Number.isFinite(t) ? t : void 0;
|
|
596
|
-
} catch {
|
|
597
|
-
return;
|
|
598
|
-
}
|
|
599
|
-
}, Ae = (e) => typeof e != "object" || !e ? !1 : typeof e.clone == "function", Q = (e) => typeof e == "string" ? e : e.name ?? String(e.id), je = 0, $ = class {
|
|
600
|
-
id = je++;
|
|
601
|
-
name;
|
|
602
|
-
superKey;
|
|
603
|
-
targets;
|
|
604
|
-
options;
|
|
605
|
-
_compiler;
|
|
606
|
-
get compiler() {
|
|
607
|
-
return this._compiler;
|
|
608
|
-
}
|
|
609
|
-
playback = new i();
|
|
610
|
-
_waAnimations = [];
|
|
611
|
-
startTime = void 0;
|
|
612
|
-
pausedTime = 0;
|
|
613
|
-
t = 0;
|
|
614
|
-
iteration = 0;
|
|
615
|
-
diagnostics = [];
|
|
616
|
-
_compositionBase = /* @__PURE__ */ new Map();
|
|
617
|
-
_compositionFallbackSeen = /* @__PURE__ */ new Set();
|
|
618
|
-
_hasComposition = !1;
|
|
619
|
-
started = !1;
|
|
620
|
-
done = !1;
|
|
621
|
-
reversed = !1;
|
|
622
|
-
paused = !1;
|
|
623
|
-
managed = !1;
|
|
624
|
-
waapiIneligibleReason = void 0;
|
|
625
|
-
unflatten = !0;
|
|
626
|
-
resolvePromise = null;
|
|
627
|
-
_playingPromise = null;
|
|
628
|
-
_boundFrame = this._frame.bind(this);
|
|
629
|
-
_interpOut = {};
|
|
630
|
-
_stableKeys = [];
|
|
631
|
-
_ctorOptions = {};
|
|
632
|
-
get flatKeys() {
|
|
633
|
-
return this._stableKeys;
|
|
634
|
-
}
|
|
635
|
-
_defaultTransform = (e) => q(e, this.targets);
|
|
636
|
-
usesDefaultRenderer(e) {
|
|
637
|
-
return e === this._defaultTransform;
|
|
638
|
-
}
|
|
639
|
-
dispatchAnimationEvent(e) {
|
|
640
|
-
if (!(typeof AnimationEvent > "u")) for (let t of this.targets) typeof t?.dispatchEvent == "function" && t.dispatchEvent(new AnimationEvent(e, {
|
|
641
|
-
animationName: this.name ?? "",
|
|
642
|
-
elapsedTime: this.t / 1e3
|
|
643
|
-
}));
|
|
644
|
-
}
|
|
645
|
-
constructor(e, t, n, r) {
|
|
646
|
-
this.options = {}, this._compiler = new ke(this.options), this._ctorOptions = e ?? {}, this.setOptions({
|
|
647
|
-
...F,
|
|
648
|
-
...this._ctorOptions
|
|
649
|
-
}), this.targets = t == null ? [] : Array.isArray(t) ? t : [t], this.name = n, this.superKey = r;
|
|
650
|
-
}
|
|
651
|
-
get templateFrames() {
|
|
652
|
-
return this.compiler.templateFrames;
|
|
653
|
-
}
|
|
654
|
-
set templateFrames(e) {
|
|
655
|
-
this.compiler.templateFrames = e;
|
|
656
|
-
}
|
|
657
|
-
get parsedVars() {
|
|
658
|
-
return this.compiler.parsedVars;
|
|
659
|
-
}
|
|
660
|
-
get frames() {
|
|
661
|
-
return this.compiler.frames;
|
|
662
|
-
}
|
|
663
|
-
get frameId() {
|
|
664
|
-
return this.compiler.frameId;
|
|
665
|
-
}
|
|
666
|
-
addFrame(e, t, n, r, i) {
|
|
667
|
-
return this.compiler.addFrame(e, t, n, r, i), this;
|
|
668
|
-
}
|
|
669
|
-
parse() {
|
|
670
|
-
return this.compiler.parse(this.targets), this.computeStableKeys(), this.computeHasComposition(), this;
|
|
671
|
-
}
|
|
672
|
-
computeHasComposition() {
|
|
673
|
-
let e = !1;
|
|
674
|
-
for (let t of this.frames) if (t.composition != null && t.composition !== "replace") {
|
|
675
|
-
e = !0;
|
|
676
|
-
break;
|
|
677
|
-
}
|
|
678
|
-
this._hasComposition = e, this._compositionBase.clear(), this._compositionFallbackSeen.clear();
|
|
679
|
-
}
|
|
680
|
-
adoptCompiled(e) {
|
|
681
|
-
return this._compiler = e.compiler, this.options = this.compiler.options, this.unflatten = e.unflatten, this.computeStableKeys(), this.computeHasComposition(), this;
|
|
682
|
-
}
|
|
683
|
-
computeStableKeys() {
|
|
684
|
-
let e = /* @__PURE__ */ new Set();
|
|
685
|
-
for (let t of this.frames) for (let n in t.flatVars) e.add(n);
|
|
686
|
-
this._stableKeys = [...e];
|
|
687
|
-
}
|
|
688
|
-
setTimingFunction(e) {
|
|
689
|
-
return this.options.timingFunction = e == null ? F.timingFunction : J("timingFunction", e), this;
|
|
690
|
-
}
|
|
691
|
-
setIterationCount(e) {
|
|
692
|
-
return e == null ? (this.options.iterationCount = F.iterationCount, this) : e === "infinite" || e === "∞" || e === "Infinity" || e === Infinity ? (this.options.iterationCount = Infinity, this) : (this.options.iterationCount = t("iterationCount", e, (e) => {
|
|
693
|
-
let t = typeof e == "string" ? Number.parseFloat(e.trim()) : e;
|
|
694
|
-
return typeof t == "number" && !Number.isNaN(t) && t >= 0 ? t : void 0;
|
|
695
|
-
}, "expected a non-negative count, \"infinite\", or Infinity"), this);
|
|
696
|
-
}
|
|
697
|
-
setDuration(e) {
|
|
698
|
-
if (e == null) return this;
|
|
699
|
-
let n = t("duration", e, (e) => {
|
|
700
|
-
let t = typeof e == "string" ? Z(e) : e;
|
|
701
|
-
return typeof t == "number" && isFinite(t) && t > 0 ? t : void 0;
|
|
702
|
-
}, "expected a positive duration in milliseconds or a CSS time string"), r = n / this.options.duration;
|
|
703
|
-
for (let e = 0; e < this.frames.length; e++) {
|
|
704
|
-
let t = this.frames[e];
|
|
705
|
-
t.time.start *= r, t.time.stop *= r;
|
|
706
|
-
}
|
|
707
|
-
return this.options.duration = n, this;
|
|
708
|
-
}
|
|
709
|
-
setDelay(e) {
|
|
710
|
-
return e == null ? (this.options.delay = F.delay, this) : (this.options.delay = t("delay", e, (e) => {
|
|
711
|
-
let t = typeof e == "string" ? Z(e) : e;
|
|
712
|
-
return typeof t == "number" && isFinite(t) ? t : void 0;
|
|
713
|
-
}, "expected a delay in milliseconds or a CSS time string"), this);
|
|
714
|
-
}
|
|
715
|
-
setDirection(e) {
|
|
716
|
-
if (e == null) e = F.direction;
|
|
717
|
-
else if (!A.includes(e)) throw new a("direction", e, `expected one of: ${A.join(", ")}`);
|
|
718
|
-
return this.options.direction = e, this.reversed = !1, (this.options.direction === "reverse" || this.options.direction === "alternate-reverse" && this.iteration % 2 == 0 || this.options.direction === "alternate" && this.iteration % 2 == 1) && (this.reversed = !0), this;
|
|
719
|
-
}
|
|
720
|
-
setFillMode(e) {
|
|
721
|
-
if (e == null) e = F.fillMode;
|
|
722
|
-
else if (!j.includes(e)) throw new a("fillMode", e, `expected one of: ${j.join(", ")}`);
|
|
723
|
-
return this.options.fillMode = e, this;
|
|
724
|
-
}
|
|
725
|
-
setUseWAAPI(e) {
|
|
726
|
-
if (e == null) return this.options.useWAAPI = F.useWAAPI, this;
|
|
727
|
-
if (typeof e != "boolean") throw new a("useWAAPI", e, "expected a boolean");
|
|
728
|
-
return this.options.useWAAPI = e, this;
|
|
729
|
-
}
|
|
730
|
-
setRespectReducedMotion(e) {
|
|
731
|
-
if (e == null) return this.options.respectReducedMotion = F.respectReducedMotion, this;
|
|
732
|
-
if (typeof e != "boolean") throw new a("respectReducedMotion", e, "expected a boolean");
|
|
733
|
-
return this.options.respectReducedMotion = e, this;
|
|
734
|
-
}
|
|
735
|
-
setColorSpace(e) {
|
|
736
|
-
if (e == null) return this.options.colorSpace = F.colorSpace, this;
|
|
737
|
-
if (!M.includes(e)) throw new a("colorSpace", e, `expected one of: ${M.join(", ")}`);
|
|
738
|
-
return this.options.colorSpace = e, this.frames.length > 0 && this.compiler.renormalizeColors(), this;
|
|
739
|
-
}
|
|
740
|
-
setHueMethod(e) {
|
|
741
|
-
if (e == null) return this;
|
|
742
|
-
if (!N.includes(e)) throw new a("hueMethod", e, `expected one of: ${N.join(", ")}`);
|
|
743
|
-
return this.options.hueMethod = e, this.frames.length > 0 && this.compiler.renormalizeColors(), this;
|
|
744
|
-
}
|
|
745
|
-
setOptions(e) {
|
|
746
|
-
return this.setTimingFunction(e.timingFunction), this.setDuration(e.duration), this.setIterationCount(e.iterationCount), this.setDelay(e.delay), this.setDirection(e.direction), this.setFillMode(e.fillMode), this.setUseWAAPI(e.useWAAPI), this.setRespectReducedMotion(e.respectReducedMotion), this.setColorSpace(e.colorSpace), this.setHueMethod(e.hueMethod), this;
|
|
747
|
-
}
|
|
748
|
-
reverse() {
|
|
749
|
-
if (this.startTime !== void 0) {
|
|
750
|
-
let e = this.t, t = this.options.duration - 2 * e;
|
|
751
|
-
this.startTime -= t;
|
|
752
|
-
}
|
|
753
|
-
return this.reversed = !this.reversed, this;
|
|
754
|
-
}
|
|
755
|
-
fillForwards() {
|
|
756
|
-
this.interpFrames(this.options.duration, !0);
|
|
757
|
-
}
|
|
758
|
-
fillBackwards() {
|
|
759
|
-
this.interpFrames(0, !0);
|
|
760
|
-
}
|
|
761
|
-
get restPosition() {
|
|
762
|
-
return this.options.fillMode === "forwards" || this.options.fillMode === "both" ? "final" : "initial";
|
|
763
|
-
}
|
|
764
|
-
paintRest() {
|
|
765
|
-
this.restPosition === "final" ? this.fillForwards() : this.fillBackwards();
|
|
766
|
-
}
|
|
767
|
-
at(e, t = !1) {
|
|
768
|
-
let n = this.reversed;
|
|
769
|
-
this.reversed = !1;
|
|
770
|
-
let r = g(e, 0, 1) * this.options.duration, i = this.interpFrames(r, t);
|
|
771
|
-
return this.reversed = n, i;
|
|
772
|
-
}
|
|
773
|
-
interpFrames(e, t = !1, n) {
|
|
774
|
-
e = this.reversed ? this.options.duration - e : e;
|
|
775
|
-
let r = this.frames, i = r.length, a = o(r, e, (e) => e.time.start, (e) => e.time.stop);
|
|
776
|
-
if (a === -1) return n === void 0 ? {} : (this.clearBuffer(n), n);
|
|
777
|
-
let s = a, c = a;
|
|
778
|
-
for (let t = a - 1; t >= 0; t--) {
|
|
779
|
-
let n = r[t];
|
|
780
|
-
if (e < n.time.start || e > n.time.stop) break;
|
|
781
|
-
s = t;
|
|
782
|
-
}
|
|
783
|
-
for (let t = a + 1; t < i; t++) {
|
|
784
|
-
let n = r[t];
|
|
785
|
-
if (e < n.time.start || e > n.time.stop) break;
|
|
786
|
-
c = t;
|
|
787
|
-
}
|
|
788
|
-
for (let n = s; n <= c; n++) this.processFrame(r[n], e, t);
|
|
789
|
-
if (s === c) {
|
|
790
|
-
let e = r[a].flatVars;
|
|
791
|
-
return n === void 0 ? e : (this.clearBuffer(n), Object.assign(n, e), n);
|
|
792
|
-
}
|
|
793
|
-
let l = n ?? {};
|
|
794
|
-
n !== void 0 && this.clearBuffer(n);
|
|
795
|
-
for (let e = s; e <= c; e++) Object.assign(l, r[e].flatVars);
|
|
796
|
-
return l;
|
|
797
|
-
}
|
|
798
|
-
clearBuffer(e) {
|
|
799
|
-
let t = this._stableKeys;
|
|
800
|
-
for (let n = 0; n < t.length; n++) e[t[n]] = void 0;
|
|
801
|
-
}
|
|
802
|
-
processFrame(e, t, n) {
|
|
803
|
-
let { start: r, stop: i } = e.time, a = r === i ? 1 : le(t, r, i, 0, 1), o = e.timingFunction.fn(a);
|
|
804
|
-
for (let t of e.allInterpVars) S(o, t);
|
|
805
|
-
n && this._hasComposition && e.composition != null && this.applyComposition(e), n && e.transform(this.unflatten ? e.vars : e.flatVars, t);
|
|
806
|
-
}
|
|
807
|
-
applyComposition(e) {
|
|
808
|
-
let t = e.composition;
|
|
809
|
-
if (t == null || t === "replace") return;
|
|
810
|
-
let n = e.flatVars;
|
|
811
|
-
for (let r in n) {
|
|
812
|
-
let i = n[r];
|
|
813
|
-
if (!Array.isArray(i) || i.length === 0) continue;
|
|
814
|
-
if (!i.every((e) => e instanceof h && typeof e.value == "number")) {
|
|
815
|
-
this.emitCompositionFallback(r, t);
|
|
816
|
-
continue;
|
|
817
|
-
}
|
|
818
|
-
let a = this._compositionBase.get(r);
|
|
819
|
-
a === void 0 && (a = this.captureUnderlyingBase(r, i.length), this._compositionBase.set(r, a));
|
|
820
|
-
let o = t === "accumulate" ? this.iteration : 0;
|
|
821
|
-
for (let t = 0; t < i.length; t++) {
|
|
822
|
-
let n = i[t], s = a[t] ?? 0;
|
|
823
|
-
o > 0 ? n.value = s + o * (this.endValueFor(e, r, t) - s) + n.value : n.value = s + n.value;
|
|
824
|
-
}
|
|
825
|
-
}
|
|
826
|
-
}
|
|
827
|
-
captureUnderlyingBase(e, t) {
|
|
828
|
-
let n = Array(t).fill(0), r = this.targets[0];
|
|
829
|
-
if (r == null || r.style == null) return n;
|
|
830
|
-
let i = e.split(".").pop() ?? e, a = r.style.getPropertyValue(i) || r.style[i] || "";
|
|
831
|
-
if (!a) return n;
|
|
832
|
-
let o = a.match(/-?\d*\.?\d+(?:e[+-]?\d+)?/gi);
|
|
833
|
-
if (o == null) return n;
|
|
834
|
-
for (let e = 0; e < t && e < o.length; e++) {
|
|
835
|
-
let t = Number.parseFloat(o[e]);
|
|
836
|
-
Number.isFinite(t) && (n[e] = t);
|
|
837
|
-
}
|
|
838
|
-
return n;
|
|
839
|
-
}
|
|
840
|
-
endValueFor(e, t, n) {
|
|
841
|
-
let r = e.interpVars[t]?.[n]?.stop;
|
|
842
|
-
return r instanceof h && typeof r.value == "number" ? r.value : this._compositionBase.get(t)?.[n] ?? 0;
|
|
843
|
-
}
|
|
844
|
-
emitCompositionFallback(e, t) {
|
|
845
|
-
this._compositionFallbackSeen.has(e) || (this._compositionFallbackSeen.add(e), this.diagnostics.push({
|
|
846
|
-
code: "COMPOSITION_FALLBACK",
|
|
847
|
-
message: `animation-composition: ${t} on a non-numeric leaf "${e}" has no faithful numeric add — composited as \`replace\` (the lerped value), never a wrong sum`,
|
|
848
|
-
property: e
|
|
849
|
-
}));
|
|
850
|
-
}
|
|
851
|
-
onStart() {
|
|
852
|
-
if (this.reversed = !1, (this.options.direction === "reverse" || this.options.direction === "alternate-reverse" && this.iteration % 2 == 0 || this.options.direction === "alternate" && this.iteration % 2 == 1) && this.reverse(), (this.options.fillMode === "backwards" || this.options.fillMode === "both") && this.fillBackwards(), this.options.delay > 0) return this.paused = !0, ue(this.options.delay).then(() => {
|
|
853
|
-
this.paused = !1, this.started = !0;
|
|
854
|
-
});
|
|
855
|
-
this.started = !0;
|
|
856
|
-
}
|
|
857
|
-
onEnd() {
|
|
858
|
-
this.paintRest(), this.startTime = void 0, this.iteration >= this.options.iterationCount - 1 ? (this.done = !0, this.iteration = 0, this.dispatchAnimationEvent("animationend")) : (this.iteration += 1, this.dispatchAnimationEvent("animationiteration"));
|
|
859
|
-
}
|
|
860
|
-
advanceTo(e) {
|
|
861
|
-
if (this.startTime === void 0) {
|
|
862
|
-
let t = this.onStart(), n = () => (this.startTime = e + this.options.delay, this.dispatchAnimationEvent("animationstart"), this._advance(e));
|
|
863
|
-
return t ? t.then(n) : n();
|
|
864
|
-
}
|
|
865
|
-
return this._advance(e);
|
|
866
|
-
}
|
|
867
|
-
_advance(e) {
|
|
868
|
-
if (this.paused && this.pausedTime === 0) return this.pausedTime = e, this.t;
|
|
869
|
-
if (this.pausedTime > 0 && !this.paused) {
|
|
870
|
-
let t = e - this.pausedTime;
|
|
871
|
-
this.startTime += t, this.pausedTime = 0;
|
|
872
|
-
}
|
|
873
|
-
return this.t = e - this.startTime, this.t >= this.options.duration && (this.onEnd(), this.t = this.options.duration), this.t;
|
|
874
|
-
}
|
|
875
|
-
_frame(e) {
|
|
876
|
-
if (n(this.options.respectReducedMotion, () => !0, () => !1)) return this._snapToReducedMotion(), !1;
|
|
877
|
-
let t = this.advanceTo(e);
|
|
878
|
-
return typeof t == "number" ? this._renderFrame(t) : t.then((e) => this._renderFrame(e));
|
|
879
|
-
}
|
|
880
|
-
_renderFrame(e) {
|
|
881
|
-
return this.paused ? !1 : this.done ? (this.settle(), this._resolvePlay(), !1) : (this.interpFrames(e, !0, this._interpOut), !0);
|
|
882
|
-
}
|
|
883
|
-
_resolvePlay() {
|
|
884
|
-
let e = this.resolvePromise;
|
|
885
|
-
this.resolvePromise = null, e?.();
|
|
886
|
-
}
|
|
887
|
-
_playRAF() {
|
|
888
|
-
return new Promise((e) => {
|
|
889
|
-
this.resolvePromise = e, this.playback.loop(this._boundFrame);
|
|
890
|
-
});
|
|
891
|
-
}
|
|
892
|
-
async _playWAAPI() {
|
|
893
|
-
await c(this), this.settle();
|
|
894
|
-
}
|
|
895
|
-
_cancelWAAPI() {
|
|
896
|
-
if (this._waAnimations.length !== 0) {
|
|
897
|
-
for (let e of this._waAnimations) try {
|
|
898
|
-
e.cancel();
|
|
899
|
-
} catch {}
|
|
900
|
-
this._waAnimations = [];
|
|
901
|
-
}
|
|
902
|
-
}
|
|
903
|
-
async _playReducedMotion() {
|
|
904
|
-
this.started = !0, this.dispatchAnimationEvent("animationstart"), this.fillForwards(), this.iteration = 0, this.done = !0, this.dispatchAnimationEvent("animationend"), this.settle();
|
|
905
|
-
}
|
|
906
|
-
_snapToReducedMotion() {
|
|
907
|
-
this._cancelWAAPI(), this.fillForwards(), this.iteration = 0, this.done = !0, this.dispatchAnimationEvent("animationend"), this.settle(), this._resolvePlay();
|
|
908
|
-
}
|
|
909
|
-
get finished() {
|
|
910
|
-
return this._playingPromise ?? Promise.resolve();
|
|
911
|
-
}
|
|
912
|
-
async play() {
|
|
913
|
-
if (this.managed) throw Error("Animation.play() called on a managed animation — the AnimationGroup owns the rAF loop. Call group.play() instead.");
|
|
914
|
-
if (this._playingPromise) return this._playingPromise;
|
|
915
|
-
let e = n(this.options.respectReducedMotion, () => (this.waapiIneligibleReason = void 0, this._playReducedMotion()), () => {
|
|
916
|
-
if (this.options.useWAAPI) {
|
|
917
|
-
let e = s(this);
|
|
918
|
-
return e.eligible ? (this.waapiIneligibleReason = void 0, this._playWAAPI()) : (this.waapiIneligibleReason = e.reason, this._playRAF());
|
|
919
|
-
}
|
|
920
|
-
return this.waapiIneligibleReason = void 0, this._playRAF();
|
|
921
|
-
});
|
|
922
|
-
return this._playingPromise = e, e.finally(() => {
|
|
923
|
-
this._playingPromise = null;
|
|
924
|
-
}), e;
|
|
925
|
-
}
|
|
926
|
-
pause() {
|
|
927
|
-
return this.started && (this.paused = !0), this;
|
|
928
|
-
}
|
|
929
|
-
resume() {
|
|
930
|
-
if (this.started && this.paused) if (this.paused = !1, this._waAnimations.length > 0) for (let e of this._waAnimations) e.play();
|
|
931
|
-
else this.playback.running || this.playback.loop(this._boundFrame);
|
|
932
|
-
return this;
|
|
933
|
-
}
|
|
934
|
-
toggle() {
|
|
935
|
-
return this.paused ? this.resume() : this.pause();
|
|
936
|
-
}
|
|
937
|
-
stop() {
|
|
938
|
-
this._cancelWAAPI(), this.playback.stop(), this.settle(), this._resolvePlay();
|
|
939
|
-
}
|
|
940
|
-
playing() {
|
|
941
|
-
return !(!this.started || this.paused);
|
|
942
|
-
}
|
|
943
|
-
get effectiveT() {
|
|
944
|
-
return this.reversed ? this.options.duration - this.t : this.t;
|
|
945
|
-
}
|
|
946
|
-
settle() {
|
|
947
|
-
return this.done = !1, this.started = !1, this.paused = !1, this.reversed = !1, this.iteration = 0, this.startTime = void 0, this.pausedTime = 0, this.t = 0, this;
|
|
948
|
-
}
|
|
949
|
-
reset() {
|
|
950
|
-
return this._cancelWAAPI(), this.started && this.frames.length > 0 && this.fillBackwards(), this.settle();
|
|
951
|
-
}
|
|
952
|
-
setTargets(...e) {
|
|
953
|
-
return this.targets = e, this.frames.forEach((e) => {
|
|
954
|
-
Object.values(e.interpVars).forEach((e) => {
|
|
955
|
-
e.forEach(({ start: e, stop: t, value: n }) => {
|
|
956
|
-
e.setTargets(this.targets), t.setTargets(this.targets), n.setTargets(this.targets);
|
|
957
|
-
});
|
|
958
|
-
});
|
|
959
|
-
}), this;
|
|
960
|
-
}
|
|
961
|
-
group(...e) {
|
|
962
|
-
return new z(this, ...e);
|
|
963
|
-
}
|
|
964
|
-
}, Me = class extends $ {
|
|
965
|
-
constructor(e, ...t) {
|
|
966
|
-
super(e, t), this.unflatten = !1;
|
|
967
|
-
}
|
|
968
|
-
resolveTransform(e) {
|
|
969
|
-
return this.unflatten = e != null, e ?? this._defaultTransform;
|
|
970
|
-
}
|
|
971
|
-
fromVars(e, t) {
|
|
972
|
-
t = this.resolveTransform(t);
|
|
973
|
-
for (let n = 0; n < e.length; n++) {
|
|
974
|
-
let r = e[n], i = Math.round(n / (e.length - 1) * 100);
|
|
975
|
-
this.addFrame(i, r, t);
|
|
976
|
-
}
|
|
977
|
-
return this.parse(), this;
|
|
978
|
-
}
|
|
979
|
-
fromKeyframes(e, t) {
|
|
980
|
-
t = this.resolveTransform(t), b(e) && (e = new Map(Object.entries(e)));
|
|
981
|
-
let n = e instanceof Map ? e.entries() : Object.entries(e);
|
|
982
|
-
for (let [e, r] of n) this.addFrame(e, r, t);
|
|
983
|
-
return this.parse(), this;
|
|
984
|
-
}
|
|
985
|
-
propertyRegistry = /* @__PURE__ */ new Map();
|
|
986
|
-
fromString(e, t) {
|
|
987
|
-
t = this.resolveTransform(t);
|
|
988
|
-
let n = k(e);
|
|
989
|
-
this.propertyRegistry = n.properties, this.diagnostics = [...n.diagnostics];
|
|
990
|
-
let i = n.options, a = {};
|
|
991
|
-
i.duration != null && (a.duration = i.duration), i.timingFunction != null && (a.timingFunction = i.timingFunction), i.iterationCount !== void 0 && (a.iterationCount = i.iterationCount === null ? Infinity : i.iterationCount), i.direction != null && (a.direction = i.direction), i.delay != null && (a.delay = i.delay), i.fillMode != null && (a.fillMode = i.fillMode), Object.keys(a).length > 0 && this.setOptions({
|
|
992
|
-
...a,
|
|
993
|
-
...this._ctorOptions
|
|
994
|
-
});
|
|
995
|
-
for (let [e, i] of n.keyframes.entries()) {
|
|
996
|
-
let a = Object.fromEntries(Object.entries(i).map(([e, t]) => [e, Ae(t) ? t.clone() : t])), o = n.timingFunctions.get(e), s = o ? G(o) : void 0, c;
|
|
997
|
-
if (s) {
|
|
998
|
-
let e = o ? r(o) : void 0;
|
|
999
|
-
c = e ? {
|
|
1000
|
-
fn: s,
|
|
1001
|
-
css: e
|
|
1002
|
-
} : { fn: s };
|
|
1003
|
-
}
|
|
1004
|
-
let l = n.composition.get(e);
|
|
1005
|
-
this.addFrame(e, a, t, c, l);
|
|
1006
|
-
}
|
|
1007
|
-
return this.parse(), this.registerProperties(), this;
|
|
1008
|
-
}
|
|
1009
|
-
registerProperties() {
|
|
1010
|
-
if (!(typeof CSS > "u" || typeof CSS.registerProperty != "function")) for (let [e, t] of this.propertyRegistry) {
|
|
1011
|
-
if (t.syntax == null) continue;
|
|
1012
|
-
let n = {
|
|
1013
|
-
name: e,
|
|
1014
|
-
syntax: t.syntax,
|
|
1015
|
-
inherits: t.inherits ?? !1
|
|
1016
|
-
};
|
|
1017
|
-
t.initialValue != null && (n.initialValue = t.initialValue.toString());
|
|
1018
|
-
try {
|
|
1019
|
-
CSS.registerProperty(n);
|
|
1020
|
-
} catch {}
|
|
1021
|
-
}
|
|
1022
|
-
}
|
|
1023
|
-
transform(e) {
|
|
1024
|
-
q(e, this.targets);
|
|
1025
|
-
}
|
|
1026
|
-
};
|
|
1027
|
-
//#endregion
|
|
1028
|
-
export { $ as Animation, z as AnimationGroup, Me as CSSKeyframesAnimation, A as DIRECTIONS, j as FILL_MODES, I as defaultLayerConfig, F as defaultOptions, Q as getAnimationId, G as getTimingFunction, k as resolveKeyframes };
|