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