@mkbabb/keyframes.js 4.1.0 → 4.3.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/README.md +520 -65
- package/dist/{animate-12YQKwyY.js → animate-D5KoLKwi.js} +2 -2
- package/dist/{animations-CcAWdZlW.js → animations-DaMcGoCd.js} +2 -2
- package/dist/binarySearch-DOP8erk-.js +13 -0
- package/dist/compile-C0xOTIC4.js +249 -0
- package/dist/decay-BvNmFk51.js +25 -0
- package/dist/{draw-svg-DwAa5cbU.js → draw-svg-CF2cTJj-.js} +1 -1
- package/dist/{engine-Cj0T6OIH.js → engine-BKm1GcJT.js} +338 -361
- package/dist/ingest-BFBYGTH-.js +139 -0
- package/dist/keyframes.d.ts +1068 -29
- package/dist/keyframes.js +82 -236
- package/dist/{motion-path-683GcEZK.js → motion-path-CqmlG74k.js} +1 -1
- package/dist/scroll-scene-JpRpH1uU.js +197 -0
- package/dist/sequence-COn8zk5o.js +156 -0
- package/dist/springTimingFunction-CcJEvGwN.js +51 -0
- package/dist/{timeline-BHz0o8dZ.js → timeline-BjcmprQ6.js} +184 -49
- package/dist/waapi-Bd5QadtA.js +179 -0
- package/package.json +110 -11
- package/dist/springTimingFunction-cMJnhbug.js +0 -178
|
@@ -1,41 +1,53 @@
|
|
|
1
|
-
import {
|
|
2
|
-
import {
|
|
3
|
-
import {
|
|
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";
|
|
4
6
|
//#region src/animation/adapter.ts
|
|
5
|
-
var
|
|
7
|
+
var ge = (e) => {
|
|
6
8
|
let t = {};
|
|
7
9
|
for (let n of e.declarations) t[n.name] = n.value;
|
|
8
10
|
return t;
|
|
9
|
-
},
|
|
11
|
+
}, _e = (e) => {
|
|
10
12
|
let t = [];
|
|
11
13
|
for (let n of e.selectors) n.kind === "percent" ? t.push(`${n.value}%`) : t.push(n.name);
|
|
12
14
|
return t;
|
|
13
15
|
}, O = (e) => {
|
|
14
|
-
let t =
|
|
16
|
+
let t = re(e);
|
|
15
17
|
for (let e of t.values()) if (e.length > 0) return e;
|
|
16
18
|
return [];
|
|
17
19
|
}, k = (e) => {
|
|
18
|
-
let t =
|
|
19
|
-
|
|
20
|
-
|
|
21
|
-
|
|
22
|
-
|
|
23
|
-
|
|
24
|
-
|
|
25
|
-
|
|
26
|
-
|
|
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 ?? {},
|
|
27
38
|
...t
|
|
28
|
-
}), e.timingFunction != null &&
|
|
29
|
-
let
|
|
30
|
-
|
|
39
|
+
}), e.timingFunction != null && o.set(n, e.timingFunction);
|
|
40
|
+
let i = e.composition;
|
|
41
|
+
i != null && s.set(n, i);
|
|
31
42
|
}
|
|
32
43
|
}
|
|
33
44
|
return {
|
|
34
|
-
keyframes:
|
|
35
|
-
timingFunctions:
|
|
36
|
-
composition:
|
|
37
|
-
properties:
|
|
38
|
-
options:
|
|
45
|
+
keyframes: a,
|
|
46
|
+
timingFunctions: o,
|
|
47
|
+
composition: s,
|
|
48
|
+
properties: _(r),
|
|
49
|
+
options: ne(r),
|
|
50
|
+
diagnostics: t
|
|
39
51
|
};
|
|
40
52
|
}, A = [
|
|
41
53
|
"normal",
|
|
@@ -47,41 +59,41 @@ var pe = (e) => {
|
|
|
47
59
|
"forwards",
|
|
48
60
|
"backwards",
|
|
49
61
|
"both"
|
|
50
|
-
], M = Object.keys(
|
|
62
|
+
], M = Object.keys(l), N = [
|
|
51
63
|
"shorter",
|
|
52
64
|
"longer",
|
|
53
65
|
"increasing",
|
|
54
66
|
"decreasing"
|
|
55
|
-
], P = {
|
|
67
|
+
], P = () => {}, F = {
|
|
56
68
|
duration: 1e3,
|
|
57
69
|
delay: 0,
|
|
58
70
|
iterationCount: 1,
|
|
59
71
|
direction: "normal",
|
|
60
72
|
fillMode: "forwards",
|
|
61
|
-
timingFunction: { fn:
|
|
73
|
+
timingFunction: { fn: te },
|
|
62
74
|
useWAAPI: !0,
|
|
63
75
|
respectReducedMotion: !1,
|
|
64
76
|
colorSpace: "oklab"
|
|
65
|
-
},
|
|
77
|
+
}, I = {
|
|
66
78
|
zIndex: 0,
|
|
67
79
|
weight: 1,
|
|
68
80
|
blendMode: "replace",
|
|
69
81
|
enabled: !0
|
|
70
|
-
},
|
|
82
|
+
}, L = null, ve = () => typeof MessageChannel == "function" ? () => new Promise((e) => {
|
|
71
83
|
let t = new MessageChannel();
|
|
72
84
|
t.port1.onmessage = () => {
|
|
73
85
|
t.port1.close(), e();
|
|
74
86
|
}, t.port2.postMessage(void 0);
|
|
75
87
|
}) : () => new Promise((e) => setTimeout(e, 0));
|
|
76
|
-
function
|
|
88
|
+
function ye() {
|
|
77
89
|
let e = globalThis.scheduler;
|
|
78
|
-
return e && typeof e.yield == "function" ? e.yield() : (
|
|
90
|
+
return e && typeof e.yield == "function" ? e.yield() : (L ??= ve(), L());
|
|
79
91
|
}
|
|
80
92
|
//#endregion
|
|
81
93
|
//#region src/animation/group.ts
|
|
82
|
-
var
|
|
94
|
+
var R = (e) => e instanceof h && typeof e.value == "number", z = class t {
|
|
83
95
|
animations = {};
|
|
84
|
-
transform;
|
|
96
|
+
transform = P;
|
|
85
97
|
superKey;
|
|
86
98
|
paused = !1;
|
|
87
99
|
started = !1;
|
|
@@ -90,7 +102,7 @@ var z = (e) => e instanceof m && typeof e.value == "number", B = class e {
|
|
|
90
102
|
static YIELD_BATCH = 32;
|
|
91
103
|
singleTarget = !0;
|
|
92
104
|
lastTickTime = 0;
|
|
93
|
-
playback = new
|
|
105
|
+
playback = new i();
|
|
94
106
|
resolvePromise = null;
|
|
95
107
|
_playingPromise = null;
|
|
96
108
|
_boundFrame;
|
|
@@ -99,18 +111,19 @@ var z = (e) => e instanceof m && typeof e.value == "number", B = class e {
|
|
|
99
111
|
_grouped = {};
|
|
100
112
|
_groupedKeys = [];
|
|
101
113
|
_groupedKeysDirty = !0;
|
|
114
|
+
_hasLayerSprings = !1;
|
|
102
115
|
constructor(...e) {
|
|
103
116
|
this._boundFrame = this._frame.bind(this);
|
|
104
117
|
let t = [];
|
|
105
118
|
for (let n of e) {
|
|
106
119
|
let e, r;
|
|
107
|
-
n instanceof $ ? e = n : (e = n.animation, r = n.layer), this.transform
|
|
120
|
+
n instanceof $ ? e = n : (e = n.animation, r = n.layer), this.transform === P && e.frames[0] != null && (this.transform = e.frames[0].transform);
|
|
108
121
|
let i = Q(e);
|
|
109
122
|
this.animations[i] = {
|
|
110
123
|
values: {},
|
|
111
124
|
animation: e,
|
|
112
125
|
layer: {
|
|
113
|
-
...
|
|
126
|
+
...I,
|
|
114
127
|
...r
|
|
115
128
|
}
|
|
116
129
|
}, e.managed = !0, t.push(e);
|
|
@@ -174,22 +187,24 @@ var z = (e) => e instanceof m && typeof e.value == "number", B = class e {
|
|
|
174
187
|
let r = t[e];
|
|
175
188
|
if (Array.isArray(r) && Array.isArray(n)) {
|
|
176
189
|
let e = Math.min(r.length, n.length);
|
|
177
|
-
for (let t = 0; t < e; t++)
|
|
190
|
+
for (let t = 0; t < e; t++) R(r[t]) && R(n[t]) ? r[t].value += n[t].value : r[t] = n[t];
|
|
178
191
|
} else t[e] = n;
|
|
179
192
|
}
|
|
180
193
|
break;
|
|
181
|
-
case "weighted":
|
|
182
|
-
|
|
183
|
-
|
|
184
|
-
|
|
185
|
-
|
|
186
|
-
|
|
187
|
-
|
|
188
|
-
|
|
189
|
-
|
|
190
|
-
|
|
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;
|
|
191
205
|
}
|
|
192
206
|
break;
|
|
207
|
+
}
|
|
193
208
|
}
|
|
194
209
|
}
|
|
195
210
|
this.done = i;
|
|
@@ -197,6 +212,13 @@ var z = (e) => e instanceof m && typeof e.value == "number", B = class e {
|
|
|
197
212
|
let r = n[e];
|
|
198
213
|
t[r] === void 0 && delete t[r];
|
|
199
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
|
+
}
|
|
200
222
|
return this.transform(t, e), t;
|
|
201
223
|
}
|
|
202
224
|
render() {
|
|
@@ -210,23 +232,34 @@ var z = (e) => e instanceof m && typeof e.value == "number", B = class e {
|
|
|
210
232
|
let i = r.animation;
|
|
211
233
|
return i.t = t, i.startTime !== void 0 && (i.pausedTime = i.startTime + t), this;
|
|
212
234
|
}
|
|
213
|
-
|
|
214
|
-
this.lastTickTime
|
|
215
|
-
|
|
216
|
-
|
|
217
|
-
|
|
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() {
|
|
218
245
|
return this.done && this.onEnd(), this;
|
|
219
246
|
}
|
|
220
|
-
|
|
221
|
-
let n
|
|
247
|
+
_advanceSlice(e, t) {
|
|
248
|
+
let n;
|
|
222
249
|
for (let r of e) {
|
|
223
250
|
let e = r.animation;
|
|
224
|
-
(
|
|
251
|
+
if (e.paused && e.pausedTime !== 0) continue;
|
|
252
|
+
let i = e.advanceTo(t);
|
|
253
|
+
typeof i != "number" && (n ??= []).push(i);
|
|
225
254
|
}
|
|
226
|
-
|
|
255
|
+
return n && Promise.all(n).then(() => void 0);
|
|
227
256
|
}
|
|
228
|
-
|
|
229
|
-
|
|
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;
|
|
230
263
|
if (this.singleTarget) this.transformFramesGrouped(e);
|
|
231
264
|
else {
|
|
232
265
|
let e = !0;
|
|
@@ -244,7 +277,7 @@ var z = (e) => e instanceof m && typeof e.value == "number", B = class e {
|
|
|
244
277
|
}
|
|
245
278
|
async play() {
|
|
246
279
|
if (this._playingPromise) return this._playingPromise;
|
|
247
|
-
let e =
|
|
280
|
+
let e = n(this.respectReducedMotion, () => this._playReducedMotion(), () => new Promise((e) => {
|
|
248
281
|
this.resolvePromise = e, this.playback.loop(this._boundFrame);
|
|
249
282
|
}));
|
|
250
283
|
return this._playingPromise = e, e.finally(() => {
|
|
@@ -317,76 +350,88 @@ var z = (e) => e instanceof m && typeof e.value == "number", B = class e {
|
|
|
317
350
|
let t = typeof e == "string" ? e : Q(e);
|
|
318
351
|
return this.animations[t]?.layer;
|
|
319
352
|
}
|
|
320
|
-
|
|
321
|
-
|
|
322
|
-
|
|
323
|
-
|
|
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));
|
|
324
394
|
throw TypeError(`Expected ValueUnit/FunctionValue/ValueArray, got ${typeof e}`);
|
|
325
|
-
},
|
|
395
|
+
}, be = (e) => {
|
|
326
396
|
let t = e.split(".").pop(), n = e.split(".").shift();
|
|
327
397
|
if (!t || !n) throw Error(`Invalid flattened key: ${e}`);
|
|
328
398
|
return {
|
|
329
399
|
mainKey: n,
|
|
330
400
|
childKey: t
|
|
331
401
|
};
|
|
332
|
-
},
|
|
333
|
-
let t = [];
|
|
334
|
-
for (let n of e.split(",")) {
|
|
335
|
-
let e = n.trim().split(/\s+/).filter(Boolean);
|
|
336
|
-
if (e.length === 0) return;
|
|
337
|
-
let r = Number.parseFloat(e[0]);
|
|
338
|
-
if (!Number.isFinite(r)) return;
|
|
339
|
-
let i = e.slice(1);
|
|
340
|
-
if (i.length === 0) {
|
|
341
|
-
t.push({ output: r });
|
|
342
|
-
continue;
|
|
343
|
-
}
|
|
344
|
-
for (let e of i) {
|
|
345
|
-
let n = Number.parseFloat(e.endsWith("%") ? e.slice(0, -1) : e);
|
|
346
|
-
if (!Number.isFinite(n)) return;
|
|
347
|
-
t.push({
|
|
348
|
-
output: r,
|
|
349
|
-
input: n
|
|
350
|
-
});
|
|
351
|
-
}
|
|
352
|
-
}
|
|
353
|
-
return t.length >= 2 ? t : void 0;
|
|
354
|
-
}, W = (e) => {
|
|
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) => {
|
|
355
403
|
if (e == null) return;
|
|
356
404
|
if (typeof e != "string") return e;
|
|
357
|
-
let t = e.match(
|
|
405
|
+
let t = e.match(xe);
|
|
358
406
|
if (t) {
|
|
359
407
|
let e = t.slice(1, 5).map((e) => Number.parseFloat(e ?? ""));
|
|
360
408
|
if (e.length === 4 && e.every((e) => Number.isFinite(e))) {
|
|
361
409
|
let [t, n, r, i] = e;
|
|
362
|
-
return
|
|
410
|
+
return u(t, n, r, i);
|
|
363
411
|
}
|
|
364
412
|
}
|
|
365
|
-
|
|
366
|
-
|
|
367
|
-
|
|
368
|
-
|
|
369
|
-
|
|
370
|
-
if (e === "step-
|
|
371
|
-
if (e
|
|
372
|
-
|
|
373
|
-
|
|
374
|
-
|
|
375
|
-
|
|
376
|
-
}
|
|
377
|
-
let
|
|
378
|
-
if (typeof
|
|
379
|
-
},
|
|
380
|
-
|
|
381
|
-
|
|
382
|
-
|
|
383
|
-
|
|
384
|
-
|
|
385
|
-
|
|
386
|
-
|
|
387
|
-
if (s) return H(s.clone(), i, r);
|
|
388
|
-
let c = H(new p(...V(ue(fe(u.FunctionArgs.map((e) => (e.setSubProperty(r), e)), d.Value), a))), i, r);
|
|
389
|
-
return G.set(o, c.clone()), c;
|
|
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);
|
|
390
435
|
};
|
|
391
436
|
return Object.entries(t).reduce((e, [t, r]) => (e[t] = n(t, r), e), {});
|
|
392
437
|
}
|
|
@@ -395,23 +440,26 @@ var K = (e, t, n, r, i = "oklab", a) => {
|
|
|
395
440
|
if (!o || !s) throw Error(`Invalid interpolation frame bounds (${t} -> ${n}).`);
|
|
396
441
|
let c = o[e], l = s[e];
|
|
397
442
|
if (!c || !l) throw Error(`Missing variable "${e}" in interpolation bounds.`);
|
|
398
|
-
let u = Math.max(c.length, l.length), d = (t) => {
|
|
399
|
-
let
|
|
400
|
-
if (!(t instanceof
|
|
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.`);
|
|
401
446
|
return t;
|
|
402
447
|
});
|
|
403
|
-
for (;
|
|
404
|
-
|
|
405
|
-
|
|
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);
|
|
406
454
|
return f.map((t, n) => {
|
|
407
455
|
let r = p[n];
|
|
408
456
|
if (!r) throw Error(`Missing right-hand interpolation value at index ${n}.`);
|
|
409
|
-
if (!(t instanceof
|
|
457
|
+
if (!(t instanceof h) || !(r instanceof h)) throw TypeError(`Interpolation for "${e}" requires ValueUnit leaves.`);
|
|
410
458
|
let o = { colorSpace: i };
|
|
411
|
-
return a !== void 0 && (o.hueMethod = a), ce(
|
|
459
|
+
return a !== void 0 && (o.hueMethod = a), ce(w(t, r, o));
|
|
412
460
|
});
|
|
413
461
|
};
|
|
414
|
-
function
|
|
462
|
+
function Ee(e, t, n) {
|
|
415
463
|
let [r, i] = [e.start, t.start];
|
|
416
464
|
return {
|
|
417
465
|
start: r.value * n / 100,
|
|
@@ -419,8 +467,8 @@ function be(e, t, n) {
|
|
|
419
467
|
};
|
|
420
468
|
}
|
|
421
469
|
function q(e, t, n = !0) {
|
|
422
|
-
e = n ? e :
|
|
423
|
-
let r =
|
|
470
|
+
e = n ? e : v(e);
|
|
471
|
+
let r = me(e);
|
|
424
472
|
t.forEach((e) => {
|
|
425
473
|
Object.entries(r).forEach(([t, n]) => {
|
|
426
474
|
e.style.setProperty(t, n);
|
|
@@ -433,16 +481,16 @@ var J = (e, t) => {
|
|
|
433
481
|
if (typeof t == "function") return { fn: t };
|
|
434
482
|
if (typeof t == "object") {
|
|
435
483
|
if (typeof t.fn == "function") return t;
|
|
436
|
-
throw new
|
|
484
|
+
throw new a(e, t, "an Easing must carry a callable `fn`");
|
|
437
485
|
}
|
|
438
|
-
let n =
|
|
439
|
-
if (!n) throw new
|
|
440
|
-
let
|
|
441
|
-
return
|
|
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 ? {
|
|
442
490
|
fn: n,
|
|
443
|
-
css:
|
|
491
|
+
css: i
|
|
444
492
|
} : { fn: n };
|
|
445
|
-
},
|
|
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 {
|
|
446
494
|
_options;
|
|
447
495
|
templateFrames = [];
|
|
448
496
|
parsedVars = [];
|
|
@@ -454,40 +502,38 @@ var J = (e, t) => {
|
|
|
454
502
|
get options() {
|
|
455
503
|
return this._options;
|
|
456
504
|
}
|
|
457
|
-
|
|
458
|
-
|
|
459
|
-
|
|
460
|
-
|
|
461
|
-
}
|
|
462
|
-
|
|
463
|
-
}
|
|
464
|
-
addFrame(e, t, n, r) {
|
|
465
|
-
typeof e == "number" ? e = String(e) + "%" : typeof e == "string" ? e = e : e instanceof m && (e = String(e));
|
|
466
|
-
let i = se(e), a = {
|
|
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 = {
|
|
467
511
|
id: this.frameId,
|
|
468
|
-
start:
|
|
512
|
+
start: s,
|
|
469
513
|
vars: t,
|
|
470
514
|
transform: n,
|
|
471
|
-
timingFunction: r == null ? this.options.timingFunction : J("timingFunction", r)
|
|
515
|
+
timingFunction: r == null ? this.options.timingFunction : J("timingFunction", r),
|
|
516
|
+
composition: i
|
|
472
517
|
};
|
|
473
|
-
this.
|
|
518
|
+
this.templateFrames.push(c), this.frameId += 1;
|
|
474
519
|
}
|
|
475
520
|
createFrame(e, t) {
|
|
476
521
|
let n = this.templateFrames[e], r = this.templateFrames[t], i = {
|
|
477
522
|
start: e,
|
|
478
523
|
stop: t
|
|
479
|
-
}, a =
|
|
524
|
+
}, a = Ee(n, r, this.options.duration), o = n.transform;
|
|
480
525
|
if (o == null) {
|
|
481
|
-
let t =
|
|
482
|
-
o = this.templateFrames[t].transform;
|
|
526
|
+
let t = E(e, this.templateFrames, (e) => e.transform != null);
|
|
527
|
+
o = (t === void 0 ? void 0 : this.templateFrames[t].transform) ?? P;
|
|
483
528
|
}
|
|
484
529
|
let s = n.timingFunction;
|
|
485
530
|
if (s == null) {
|
|
486
|
-
let t =
|
|
487
|
-
s = this.templateFrames[t].timingFunction;
|
|
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;
|
|
488
533
|
}
|
|
534
|
+
let c = e * De + t, l = r.composition;
|
|
489
535
|
return {
|
|
490
|
-
id:
|
|
536
|
+
id: c,
|
|
491
537
|
ixs: i,
|
|
492
538
|
start: n.start,
|
|
493
539
|
time: a,
|
|
@@ -496,7 +542,8 @@ var J = (e, t) => {
|
|
|
496
542
|
interpVars: {},
|
|
497
543
|
allInterpVars: [],
|
|
498
544
|
transform: o,
|
|
499
|
-
timingFunction: s
|
|
545
|
+
timingFunction: s,
|
|
546
|
+
...l == null ? {} : { composition: l }
|
|
500
547
|
};
|
|
501
548
|
}
|
|
502
549
|
buildVarIndex() {
|
|
@@ -524,7 +571,7 @@ var J = (e, t) => {
|
|
|
524
571
|
}
|
|
525
572
|
parse(e) {
|
|
526
573
|
this.frames = [], this.templateFrames.sort((e, t) => e.start.value - t.start.value), this.parsedVars = this.templateFrames.map((t) => {
|
|
527
|
-
let n =
|
|
574
|
+
let n = Te(t.vars);
|
|
528
575
|
return Object.values(n).forEach((t) => {
|
|
529
576
|
t.setTargets(e);
|
|
530
577
|
}), n;
|
|
@@ -534,7 +581,7 @@ var J = (e, t) => {
|
|
|
534
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));
|
|
535
582
|
}
|
|
536
583
|
finalizeFrameVars(e) {
|
|
537
|
-
e.flatVars = Object.entries(e.interpVars).reduce((e, [t, n]) => (e[t] = n.map((e) => e.value), e), {}), e.vars =
|
|
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();
|
|
538
585
|
}
|
|
539
586
|
renormalizeColors() {
|
|
540
587
|
for (let e of this.frames) {
|
|
@@ -542,157 +589,15 @@ var J = (e, t) => {
|
|
|
542
589
|
this.finalizeFrameVars(e);
|
|
543
590
|
}
|
|
544
591
|
}
|
|
545
|
-
},
|
|
546
|
-
...c,
|
|
547
|
-
"%",
|
|
548
|
-
"vh",
|
|
549
|
-
"vw",
|
|
550
|
-
"vmin",
|
|
551
|
-
"vmax",
|
|
552
|
-
"vi",
|
|
553
|
-
"vb",
|
|
554
|
-
"svh",
|
|
555
|
-
"svw",
|
|
556
|
-
"svmin",
|
|
557
|
-
"svmax",
|
|
558
|
-
"svi",
|
|
559
|
-
"svb",
|
|
560
|
-
"lvh",
|
|
561
|
-
"lvw",
|
|
562
|
-
"lvmin",
|
|
563
|
-
"lvmax",
|
|
564
|
-
"lvi",
|
|
565
|
-
"lvb",
|
|
566
|
-
"dvh",
|
|
567
|
-
"dvw",
|
|
568
|
-
"dvmin",
|
|
569
|
-
"dvmax",
|
|
570
|
-
"dvi",
|
|
571
|
-
"dvb",
|
|
572
|
-
"cqw",
|
|
573
|
-
"cqh",
|
|
574
|
-
"cqi",
|
|
575
|
-
"cqb",
|
|
576
|
-
"cqmin",
|
|
577
|
-
"cqmax"
|
|
578
|
-
]), Y = (e) => typeof e == "string" && Ce.has(e), X = new Set(["offset-distance"]), we = (e) => X.has(e) || X.has(e.split(".").pop() ?? e);
|
|
579
|
-
function Te(e) {
|
|
580
|
-
if (!e.targets || e.targets.length === 0) return {
|
|
581
|
-
eligible: !1,
|
|
582
|
-
reason: "no DOM targets"
|
|
583
|
-
};
|
|
584
|
-
if (typeof e.targets[0]?.animate != "function") return {
|
|
585
|
-
eligible: !1,
|
|
586
|
-
reason: "target does not implement Element.animate()"
|
|
587
|
-
};
|
|
588
|
-
for (let t of e.frames) if (!e.usesDefaultRenderer(t.transform)) return {
|
|
589
|
-
eligible: !1,
|
|
590
|
-
reason: "custom transform function (not the default DOM renderer)"
|
|
591
|
-
};
|
|
592
|
-
let t = e.frames[0]?.timingFunction;
|
|
593
|
-
if (t && e.frames.length > 1) {
|
|
594
|
-
for (let n = 1; n < e.frames.length; n++) if (e.frames[n].timingFunction.fn !== t.fn) return {
|
|
595
|
-
eligible: !1,
|
|
596
|
-
reason: "non-uniform per-frame timing function (WAAPI supports one easing per animation)"
|
|
597
|
-
};
|
|
598
|
-
if (t.css !== void 0) return {
|
|
599
|
-
eligible: !1,
|
|
600
|
-
reason: "CSS-twinned easing across multiple segments (WAAPI restarts the curve per segment)"
|
|
601
|
-
};
|
|
602
|
-
}
|
|
603
|
-
if (t && t.css === void 0) return {
|
|
604
|
-
eligible: !1,
|
|
605
|
-
reason: "easing has no faithful CSS twin (would run bare linear on the compositor)"
|
|
606
|
-
};
|
|
607
|
-
for (let t of e.frames) for (let [e, n] of Object.entries(t.interpVars)) {
|
|
608
|
-
let t = we(e);
|
|
609
|
-
for (let e of n) {
|
|
610
|
-
let n = Y(e.start?.unit) && !(t && e.start?.unit === "%"), r = Y(e.stop?.unit) && !(t && e.stop?.unit === "%");
|
|
611
|
-
if (n || r) return {
|
|
612
|
-
eligible: !1,
|
|
613
|
-
reason: `layout-dependent unit (${String(e.start?.unit ?? e.stop?.unit)}) would freeze to px under WAAPI`
|
|
614
|
-
};
|
|
615
|
-
if (e.start?.unit === "color" || e.stop?.unit === "color") return {
|
|
616
|
-
eligible: !1,
|
|
617
|
-
reason: "color interpolation requires perceptual lerp"
|
|
618
|
-
};
|
|
619
|
-
}
|
|
620
|
-
}
|
|
621
|
-
return { eligible: !0 };
|
|
622
|
-
}
|
|
623
|
-
var Ee = 8;
|
|
624
|
-
function De(e) {
|
|
625
|
-
let n = e.options.duration, r = [], i = /* @__PURE__ */ new Set();
|
|
626
|
-
for (let t of e.frames) i.add(t.time.start), i.add(t.time.stop);
|
|
627
|
-
let a = [...i].sort((e, t) => e - t), o = new Set(a);
|
|
628
|
-
if (n > 0) for (let e = 1; e < a.length; e++) {
|
|
629
|
-
let t = a[e - 1], n = a[e] - t;
|
|
630
|
-
if (!(n <= 0)) for (let e = 1; e <= Ee; e++) o.add(t + n * e / 9);
|
|
631
|
-
}
|
|
632
|
-
for (let i of [...o].sort((e, t) => e - t)) {
|
|
633
|
-
let a = e.interpFrames(i, !1);
|
|
634
|
-
if (Object.keys(a).length === 0) continue;
|
|
635
|
-
let o = D(a);
|
|
636
|
-
r.push({
|
|
637
|
-
offset: t(i / n, 0, 1),
|
|
638
|
-
...o
|
|
639
|
-
});
|
|
640
|
-
}
|
|
641
|
-
return r;
|
|
642
|
-
}
|
|
643
|
-
var Oe = {
|
|
644
|
-
normal: "normal",
|
|
645
|
-
reverse: "reverse",
|
|
646
|
-
alternate: "alternate",
|
|
647
|
-
"alternate-reverse": "alternate-reverse"
|
|
648
|
-
}, ke = {
|
|
649
|
-
none: "none",
|
|
650
|
-
forwards: "forwards",
|
|
651
|
-
backwards: "backwards",
|
|
652
|
-
both: "both"
|
|
653
|
-
};
|
|
654
|
-
function Ae(e) {
|
|
655
|
-
let t = e.options, n = Oe[t.direction], r = ke[t.fillMode];
|
|
656
|
-
if (n == null) throw TypeError(`Unrecognised animation direction "${t.direction}".`);
|
|
657
|
-
if (r == null) throw TypeError(`Unrecognised animation fill mode "${t.fillMode}".`);
|
|
658
|
-
let i = (e.frames[0]?.timingFunction ?? e.options.timingFunction).css ?? "linear";
|
|
659
|
-
return {
|
|
660
|
-
duration: t.duration,
|
|
661
|
-
delay: t.delay,
|
|
662
|
-
iterations: t.iterationCount === Infinity ? Infinity : t.iterationCount,
|
|
663
|
-
direction: n,
|
|
664
|
-
fill: r,
|
|
665
|
-
easing: i
|
|
666
|
-
};
|
|
667
|
-
}
|
|
668
|
-
async function je(e) {
|
|
669
|
-
let t = De(e), n = Ae(e), r = e.targets.map((e) => e.animate(t, n));
|
|
670
|
-
e._waAnimations = r, e.playback.loop(async (t) => {
|
|
671
|
-
if (e.done) return !1;
|
|
672
|
-
if (await e.advanceTo(t), e.paused) for (let e of r) e.pause();
|
|
673
|
-
else for (let e of r) e.playState === "paused" && e.play();
|
|
674
|
-
return !e.done;
|
|
675
|
-
});
|
|
592
|
+
}, Z = (e) => {
|
|
676
593
|
try {
|
|
677
|
-
|
|
678
|
-
for (let t of r) try {
|
|
679
|
-
e.restPosition === "final" && typeof t.commitStyles == "function" && t.commitStyles(), t.cancel();
|
|
680
|
-
} catch {}
|
|
681
|
-
} catch {} finally {
|
|
682
|
-
e.playback.stop(), e._waAnimations = [];
|
|
683
|
-
}
|
|
684
|
-
}
|
|
685
|
-
//#endregion
|
|
686
|
-
//#region src/animation/engine.ts
|
|
687
|
-
var Z = (e) => {
|
|
688
|
-
try {
|
|
689
|
-
let t = S(e);
|
|
594
|
+
let t = ie(e);
|
|
690
595
|
return Number.isFinite(t) ? t : void 0;
|
|
691
596
|
} catch {
|
|
692
597
|
return;
|
|
693
598
|
}
|
|
694
|
-
},
|
|
695
|
-
id =
|
|
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++;
|
|
696
601
|
name;
|
|
697
602
|
superKey;
|
|
698
603
|
targets;
|
|
@@ -701,12 +606,16 @@ var Z = (e) => {
|
|
|
701
606
|
get compiler() {
|
|
702
607
|
return this._compiler;
|
|
703
608
|
}
|
|
704
|
-
playback = new
|
|
609
|
+
playback = new i();
|
|
705
610
|
_waAnimations = [];
|
|
706
611
|
startTime = void 0;
|
|
707
612
|
pausedTime = 0;
|
|
708
613
|
t = 0;
|
|
709
614
|
iteration = 0;
|
|
615
|
+
diagnostics = [];
|
|
616
|
+
_compositionBase = /* @__PURE__ */ new Map();
|
|
617
|
+
_compositionFallbackSeen = /* @__PURE__ */ new Set();
|
|
618
|
+
_hasComposition = !1;
|
|
710
619
|
started = !1;
|
|
711
620
|
done = !1;
|
|
712
621
|
reversed = !1;
|
|
@@ -734,8 +643,8 @@ var Z = (e) => {
|
|
|
734
643
|
}));
|
|
735
644
|
}
|
|
736
645
|
constructor(e, t, n, r) {
|
|
737
|
-
this.options = {}, this._compiler = new
|
|
738
|
-
...
|
|
646
|
+
this.options = {}, this._compiler = new ke(this.options), this._ctorOptions = e ?? {}, this.setOptions({
|
|
647
|
+
...F,
|
|
739
648
|
...this._ctorOptions
|
|
740
649
|
}), this.targets = t == null ? [] : Array.isArray(t) ? t : [t], this.name = n, this.superKey = r;
|
|
741
650
|
}
|
|
@@ -754,14 +663,22 @@ var Z = (e) => {
|
|
|
754
663
|
get frameId() {
|
|
755
664
|
return this.compiler.frameId;
|
|
756
665
|
}
|
|
757
|
-
addFrame(e, t, n, r) {
|
|
758
|
-
return this.compiler.addFrame(e, t, n, r), this;
|
|
666
|
+
addFrame(e, t, n, r, i) {
|
|
667
|
+
return this.compiler.addFrame(e, t, n, r, i), this;
|
|
759
668
|
}
|
|
760
669
|
parse() {
|
|
761
|
-
return this.compiler.parse(this.targets), this.computeStableKeys(), this;
|
|
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();
|
|
762
679
|
}
|
|
763
680
|
adoptCompiled(e) {
|
|
764
|
-
return this._compiler = e.compiler, this.options = this.compiler.options, this.unflatten = e.unflatten, this.computeStableKeys(), this;
|
|
681
|
+
return this._compiler = e.compiler, this.options = this.compiler.options, this.unflatten = e.unflatten, this.computeStableKeys(), this.computeHasComposition(), this;
|
|
765
682
|
}
|
|
766
683
|
computeStableKeys() {
|
|
767
684
|
let e = /* @__PURE__ */ new Set();
|
|
@@ -769,17 +686,17 @@ var Z = (e) => {
|
|
|
769
686
|
this._stableKeys = [...e];
|
|
770
687
|
}
|
|
771
688
|
setTimingFunction(e) {
|
|
772
|
-
return this.options.timingFunction = e == null ?
|
|
689
|
+
return this.options.timingFunction = e == null ? F.timingFunction : J("timingFunction", e), this;
|
|
773
690
|
}
|
|
774
|
-
setIterationCount(
|
|
775
|
-
return
|
|
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) => {
|
|
776
693
|
let t = typeof e == "string" ? Number.parseFloat(e.trim()) : e;
|
|
777
694
|
return typeof t == "number" && !Number.isNaN(t) && t >= 0 ? t : void 0;
|
|
778
695
|
}, "expected a non-negative count, \"infinite\", or Infinity"), this);
|
|
779
696
|
}
|
|
780
|
-
setDuration(
|
|
781
|
-
if (
|
|
782
|
-
let n =
|
|
697
|
+
setDuration(e) {
|
|
698
|
+
if (e == null) return this;
|
|
699
|
+
let n = t("duration", e, (e) => {
|
|
783
700
|
let t = typeof e == "string" ? Z(e) : e;
|
|
784
701
|
return typeof t == "number" && isFinite(t) && t > 0 ? t : void 0;
|
|
785
702
|
}, "expected a positive duration in milliseconds or a CSS time string"), r = n / this.options.duration;
|
|
@@ -789,40 +706,40 @@ var Z = (e) => {
|
|
|
789
706
|
}
|
|
790
707
|
return this.options.duration = n, this;
|
|
791
708
|
}
|
|
792
|
-
setDelay(
|
|
793
|
-
return
|
|
709
|
+
setDelay(e) {
|
|
710
|
+
return e == null ? (this.options.delay = F.delay, this) : (this.options.delay = t("delay", e, (e) => {
|
|
794
711
|
let t = typeof e == "string" ? Z(e) : e;
|
|
795
712
|
return typeof t == "number" && isFinite(t) ? t : void 0;
|
|
796
713
|
}, "expected a delay in milliseconds or a CSS time string"), this);
|
|
797
714
|
}
|
|
798
715
|
setDirection(e) {
|
|
799
|
-
if (e == null) e =
|
|
800
|
-
else if (!A.includes(e)) throw new
|
|
716
|
+
if (e == null) e = F.direction;
|
|
717
|
+
else if (!A.includes(e)) throw new a("direction", e, `expected one of: ${A.join(", ")}`);
|
|
801
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;
|
|
802
719
|
}
|
|
803
720
|
setFillMode(e) {
|
|
804
|
-
if (e == null) e =
|
|
805
|
-
else if (!j.includes(e)) throw new
|
|
721
|
+
if (e == null) e = F.fillMode;
|
|
722
|
+
else if (!j.includes(e)) throw new a("fillMode", e, `expected one of: ${j.join(", ")}`);
|
|
806
723
|
return this.options.fillMode = e, this;
|
|
807
724
|
}
|
|
808
725
|
setUseWAAPI(e) {
|
|
809
|
-
if (e == null) return this.options.useWAAPI =
|
|
810
|
-
if (typeof e != "boolean") throw new
|
|
726
|
+
if (e == null) return this.options.useWAAPI = F.useWAAPI, this;
|
|
727
|
+
if (typeof e != "boolean") throw new a("useWAAPI", e, "expected a boolean");
|
|
811
728
|
return this.options.useWAAPI = e, this;
|
|
812
729
|
}
|
|
813
730
|
setRespectReducedMotion(e) {
|
|
814
|
-
if (e == null) return this.options.respectReducedMotion =
|
|
815
|
-
if (typeof e != "boolean") throw new
|
|
731
|
+
if (e == null) return this.options.respectReducedMotion = F.respectReducedMotion, this;
|
|
732
|
+
if (typeof e != "boolean") throw new a("respectReducedMotion", e, "expected a boolean");
|
|
816
733
|
return this.options.respectReducedMotion = e, this;
|
|
817
734
|
}
|
|
818
735
|
setColorSpace(e) {
|
|
819
|
-
if (e == null) return this.options.colorSpace =
|
|
820
|
-
if (!M.includes(e)) throw new
|
|
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(", ")}`);
|
|
821
738
|
return this.options.colorSpace = e, this.frames.length > 0 && this.compiler.renormalizeColors(), this;
|
|
822
739
|
}
|
|
823
740
|
setHueMethod(e) {
|
|
824
741
|
if (e == null) return this;
|
|
825
|
-
if (!N.includes(e)) throw new
|
|
742
|
+
if (!N.includes(e)) throw new a("hueMethod", e, `expected one of: ${N.join(", ")}`);
|
|
826
743
|
return this.options.hueMethod = e, this.frames.length > 0 && this.compiler.renormalizeColors(), this;
|
|
827
744
|
}
|
|
828
745
|
setOptions(e) {
|
|
@@ -850,32 +767,32 @@ var Z = (e) => {
|
|
|
850
767
|
at(e, t = !1) {
|
|
851
768
|
let n = this.reversed;
|
|
852
769
|
this.reversed = !1;
|
|
853
|
-
let r =
|
|
770
|
+
let r = g(e, 0, 1) * this.options.duration, i = this.interpFrames(r, t);
|
|
854
771
|
return this.reversed = n, i;
|
|
855
772
|
}
|
|
856
|
-
interpFrames(e, t = !1,
|
|
773
|
+
interpFrames(e, t = !1, n) {
|
|
857
774
|
e = this.reversed ? this.options.duration - e : e;
|
|
858
|
-
let
|
|
859
|
-
if (
|
|
860
|
-
let s =
|
|
861
|
-
for (let t =
|
|
862
|
-
let n =
|
|
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];
|
|
863
780
|
if (e < n.time.start || e > n.time.stop) break;
|
|
864
781
|
s = t;
|
|
865
782
|
}
|
|
866
|
-
for (let t =
|
|
867
|
-
let n =
|
|
783
|
+
for (let t = a + 1; t < i; t++) {
|
|
784
|
+
let n = r[t];
|
|
868
785
|
if (e < n.time.start || e > n.time.stop) break;
|
|
869
786
|
c = t;
|
|
870
787
|
}
|
|
871
|
-
for (let n = s; n <= c; n++) this.processFrame(
|
|
788
|
+
for (let n = s; n <= c; n++) this.processFrame(r[n], e, t);
|
|
872
789
|
if (s === c) {
|
|
873
|
-
let e =
|
|
874
|
-
return
|
|
790
|
+
let e = r[a].flatVars;
|
|
791
|
+
return n === void 0 ? e : (this.clearBuffer(n), Object.assign(n, e), n);
|
|
875
792
|
}
|
|
876
|
-
let l =
|
|
877
|
-
|
|
878
|
-
for (let e = s; e <= c; e++) Object.assign(l,
|
|
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);
|
|
879
796
|
return l;
|
|
880
797
|
}
|
|
881
798
|
clearBuffer(e) {
|
|
@@ -884,25 +801,84 @@ var Z = (e) => {
|
|
|
884
801
|
}
|
|
885
802
|
processFrame(e, t, n) {
|
|
886
803
|
let { start: r, stop: i } = e.time, a = r === i ? 1 : le(t, r, i, 0, 1), o = e.timingFunction.fn(a);
|
|
887
|
-
for (let t of e.allInterpVars)
|
|
888
|
-
n && e.transform(this.unflatten ? e.vars : e.flatVars, t);
|
|
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;
|
|
889
839
|
}
|
|
890
|
-
|
|
891
|
-
|
|
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;
|
|
892
843
|
}
|
|
893
|
-
|
|
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() {
|
|
894
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"));
|
|
895
859
|
}
|
|
896
|
-
|
|
897
|
-
if (this.startTime === void 0
|
|
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;
|
|
898
869
|
if (this.pausedTime > 0 && !this.paused) {
|
|
899
870
|
let t = e - this.pausedTime;
|
|
900
871
|
this.startTime += t, this.pausedTime = 0;
|
|
901
872
|
}
|
|
902
|
-
return this.t = e - this.startTime, this.t >= this.options.duration && (
|
|
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));
|
|
903
879
|
}
|
|
904
|
-
|
|
905
|
-
return
|
|
880
|
+
_renderFrame(e) {
|
|
881
|
+
return this.paused ? !1 : this.done ? (this.settle(), this._resolvePlay(), !1) : (this.interpFrames(e, !0, this._interpOut), !0);
|
|
906
882
|
}
|
|
907
883
|
_resolvePlay() {
|
|
908
884
|
let e = this.resolvePromise;
|
|
@@ -914,7 +890,7 @@ var Z = (e) => {
|
|
|
914
890
|
});
|
|
915
891
|
}
|
|
916
892
|
async _playWAAPI() {
|
|
917
|
-
await
|
|
893
|
+
await c(this), this.settle();
|
|
918
894
|
}
|
|
919
895
|
_cancelWAAPI() {
|
|
920
896
|
if (this._waAnimations.length !== 0) {
|
|
@@ -927,7 +903,7 @@ var Z = (e) => {
|
|
|
927
903
|
async _playReducedMotion() {
|
|
928
904
|
this.started = !0, this.dispatchAnimationEvent("animationstart"), this.fillForwards(), this.iteration = 0, this.done = !0, this.dispatchAnimationEvent("animationend"), this.settle();
|
|
929
905
|
}
|
|
930
|
-
|
|
906
|
+
_snapToReducedMotion() {
|
|
931
907
|
this._cancelWAAPI(), this.fillForwards(), this.iteration = 0, this.done = !0, this.dispatchAnimationEvent("animationend"), this.settle(), this._resolvePlay();
|
|
932
908
|
}
|
|
933
909
|
get finished() {
|
|
@@ -936,9 +912,9 @@ var Z = (e) => {
|
|
|
936
912
|
async play() {
|
|
937
913
|
if (this.managed) throw Error("Animation.play() called on a managed animation — the AnimationGroup owns the rAF loop. Call group.play() instead.");
|
|
938
914
|
if (this._playingPromise) return this._playingPromise;
|
|
939
|
-
let e =
|
|
915
|
+
let e = n(this.options.respectReducedMotion, () => (this.waapiIneligibleReason = void 0, this._playReducedMotion()), () => {
|
|
940
916
|
if (this.options.useWAAPI) {
|
|
941
|
-
let e =
|
|
917
|
+
let e = s(this);
|
|
942
918
|
return e.eligible ? (this.waapiIneligibleReason = void 0, this._playWAAPI()) : (this.waapiIneligibleReason = e.reason, this._playRAF());
|
|
943
919
|
}
|
|
944
920
|
return this.waapiIneligibleReason = void 0, this._playRAF();
|
|
@@ -983,9 +959,9 @@ var Z = (e) => {
|
|
|
983
959
|
}), this;
|
|
984
960
|
}
|
|
985
961
|
group(...e) {
|
|
986
|
-
return new
|
|
962
|
+
return new z(this, ...e);
|
|
987
963
|
}
|
|
988
|
-
},
|
|
964
|
+
}, Me = class extends $ {
|
|
989
965
|
constructor(e, ...t) {
|
|
990
966
|
super(e, t), this.unflatten = !1;
|
|
991
967
|
}
|
|
@@ -1001,7 +977,7 @@ var Z = (e) => {
|
|
|
1001
977
|
return this.parse(), this;
|
|
1002
978
|
}
|
|
1003
979
|
fromKeyframes(e, t) {
|
|
1004
|
-
t = this.resolveTransform(t),
|
|
980
|
+
t = this.resolveTransform(t), b(e) && (e = new Map(Object.entries(e)));
|
|
1005
981
|
let n = e instanceof Map ? e.entries() : Object.entries(e);
|
|
1006
982
|
for (let [e, r] of n) this.addFrame(e, r, t);
|
|
1007
983
|
return this.parse(), this;
|
|
@@ -1010,14 +986,14 @@ var Z = (e) => {
|
|
|
1010
986
|
fromString(e, t) {
|
|
1011
987
|
t = this.resolveTransform(t);
|
|
1012
988
|
let n = k(e);
|
|
1013
|
-
this.propertyRegistry = n.properties;
|
|
989
|
+
this.propertyRegistry = n.properties, this.diagnostics = [...n.diagnostics];
|
|
1014
990
|
let i = n.options, a = {};
|
|
1015
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({
|
|
1016
992
|
...a,
|
|
1017
993
|
...this._ctorOptions
|
|
1018
994
|
});
|
|
1019
995
|
for (let [e, i] of n.keyframes.entries()) {
|
|
1020
|
-
let a = Object.fromEntries(Object.entries(i).map(([e, t]) => [e,
|
|
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;
|
|
1021
997
|
if (s) {
|
|
1022
998
|
let e = o ? r(o) : void 0;
|
|
1023
999
|
c = e ? {
|
|
@@ -1025,7 +1001,8 @@ var Z = (e) => {
|
|
|
1025
1001
|
css: e
|
|
1026
1002
|
} : { fn: s };
|
|
1027
1003
|
}
|
|
1028
|
-
|
|
1004
|
+
let l = n.composition.get(e);
|
|
1005
|
+
this.addFrame(e, a, t, c, l);
|
|
1029
1006
|
}
|
|
1030
1007
|
return this.parse(), this.registerProperties(), this;
|
|
1031
1008
|
}
|
|
@@ -1048,4 +1025,4 @@ var Z = (e) => {
|
|
|
1048
1025
|
}
|
|
1049
1026
|
};
|
|
1050
1027
|
//#endregion
|
|
1051
|
-
export { $ as Animation,
|
|
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 };
|