@mkbabb/keyframes.js 4.3.0 → 5.0.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 +33 -6
- package/dist/animate-CTWr6K7j.js +26 -0
- package/dist/{animations-DaMcGoCd.js → animations-CZxf0rep.js} +3 -3
- package/dist/compile-YRJRdpKF.js +251 -0
- package/dist/{draw-svg-CF2cTJj-.js → draw-svg-Dat9mHgi.js} +1 -1
- package/dist/engine-DQcb7CLW.js +1349 -0
- package/dist/errors-W8zkvPw4.js +21 -0
- package/dist/format-BUgCTjmr.js +123 -0
- package/dist/ingest-CU-kdYcM.js +160 -0
- package/dist/keyframes.d.ts +2495 -1659
- package/dist/keyframes.js +223 -87
- package/dist/morph-svg-83uyYxoW.js +84 -0
- package/dist/{motion-path-CqmlG74k.js → motion-path-C0OHqcA3.js} +1 -1
- package/dist/rolldown-runtime-Dy4uBu1J.js +11 -0
- package/dist/scheduler-7eIr_q1g.js +14 -0
- package/dist/scroll-grammar-B4kPvGh5.js +23 -0
- package/dist/{scroll-scene-JpRpH1uU.js → scroll-scene-DQxhxn9I.js} +18 -39
- package/dist/{sequence-COn8zk5o.js → sequence-cBr7thU8.js} +49 -7
- package/dist/{springTimingFunction-CcJEvGwN.js → springTimingFunction-D26gPkAy.js} +23 -11
- package/dist/{timeline-BjcmprQ6.js → timeline-vY3eD3Ax.js} +125 -111
- package/dist/utils-BPRImVl5.js +100 -0
- package/dist/validate-B1pE-Y_T.js +35 -0
- package/dist/{waapi-Bd5QadtA.js → waapi-D0ssxKy1.js} +90 -28
- package/package.json +61 -6
- package/dist/animate-D5KoLKwi.js +0 -21
- package/dist/binarySearch-DOP8erk-.js +0 -13
- package/dist/compile-C0xOTIC4.js +0 -249
- package/dist/engine-BKm1GcJT.js +0 -1028
- package/dist/ingest-BFBYGTH-.js +0 -139
|
@@ -1,63 +1,34 @@
|
|
|
1
|
-
|
|
2
|
-
|
|
3
|
-
option;
|
|
4
|
-
value;
|
|
5
|
-
code;
|
|
6
|
-
constructor(t, n, r, i) {
|
|
7
|
-
super(`Invalid value for animation option "${t}": ${e(n)} — ${r}`), this.name = "AnimationOptionError", this.option = t, this.value = n, i !== void 0 && (this.code = i);
|
|
8
|
-
}
|
|
9
|
-
}, n = class extends Error {
|
|
10
|
-
easingName;
|
|
11
|
-
constructor(t) {
|
|
12
|
-
super(`Unknown easing name ${e(t)} — not a value.js registry entry or cubic-bezier() literal. Pass a callable TimingFunction (or a typed Easing), or resolve the name first via \`await resolveEasing(name)\`.`), this.name = "UnknownEasingError", this.easingName = t;
|
|
13
|
-
}
|
|
14
|
-
};
|
|
15
|
-
function r(e, n, r, i) {
|
|
16
|
-
let a = r(n);
|
|
17
|
-
if (a === void 0) throw new t(e, n, i);
|
|
18
|
-
return a;
|
|
19
|
-
}
|
|
20
|
-
//#endregion
|
|
1
|
+
import { n as e, t } from "./errors-W8zkvPw4.js";
|
|
2
|
+
import { clamp as n, lerpArray as r, scale as i } from "@mkbabb/value.js/math";
|
|
21
3
|
//#region src/animation/easing.ts
|
|
22
|
-
var
|
|
4
|
+
var a = (e) => typeof e == "function" ? { fn: e } : e, o = /^(linear|ease|ease-in|ease-out|ease-in-out)$/, s = /^(cubic-bezier\(|steps\(|linear\(|step-start$|step-end$)/, c = (e) => {
|
|
23
5
|
let t = e.trim();
|
|
24
|
-
if (
|
|
6
|
+
if (o.test(t) || s.test(t)) return t;
|
|
25
7
|
};
|
|
26
|
-
async function
|
|
27
|
-
let
|
|
8
|
+
async function l(t) {
|
|
9
|
+
let n;
|
|
28
10
|
try {
|
|
29
|
-
|
|
30
|
-
} catch (
|
|
31
|
-
throw Error(`keyframes: the engine chunk failed to load while resolving easing "${
|
|
11
|
+
n = await import("./engine-DQcb7CLW.js");
|
|
12
|
+
} catch (e) {
|
|
13
|
+
throw Error(`keyframes: the engine chunk failed to load while resolving easing "${t}" — the easing registry is unreachable.`, { cause: e });
|
|
32
14
|
}
|
|
33
|
-
let r =
|
|
34
|
-
if (!r) throw new
|
|
35
|
-
let i = { fn: r }, a =
|
|
15
|
+
let r = n.getTimingFunction(t);
|
|
16
|
+
if (!r) throw new e(t);
|
|
17
|
+
let i = { fn: r }, a = c(t);
|
|
36
18
|
return a && (i.css = a), i;
|
|
37
19
|
}
|
|
38
20
|
//#endregion
|
|
39
21
|
//#region src/animation/internal/leaves.ts
|
|
40
|
-
var
|
|
41
|
-
function
|
|
42
|
-
return Math.min(Math.max(e, t), n);
|
|
43
|
-
}
|
|
44
|
-
function d(e, t, n, r = 0, i = 1) {
|
|
45
|
-
if (n === t) throw Error("fromMax and fromMin cannot be equal");
|
|
46
|
-
let a = (i - r) / (n - t);
|
|
47
|
-
return (e - t) * a + r;
|
|
48
|
-
}
|
|
49
|
-
function f(e, t, n) {
|
|
50
|
-
return (1 - n) * e + n * t;
|
|
51
|
-
}
|
|
52
|
-
function p(e) {
|
|
22
|
+
var u = 1e3 / 60;
|
|
23
|
+
function d(e) {
|
|
53
24
|
if (typeof window < "u" && window.requestAnimationFrame) return window.requestAnimationFrame(e);
|
|
54
|
-
let t =
|
|
25
|
+
let t = u, n = Date.now();
|
|
55
26
|
return setTimeout(() => {
|
|
56
27
|
let r = Date.now(), i = r - n;
|
|
57
|
-
n = r, t = Math.max(0,
|
|
28
|
+
n = r, t = Math.max(0, u - i), e(r);
|
|
58
29
|
}, t);
|
|
59
30
|
}
|
|
60
|
-
function
|
|
31
|
+
function f(e) {
|
|
61
32
|
if (e != null) {
|
|
62
33
|
if (typeof e == "number" && typeof window < "u" && window.cancelAnimationFrame) return window.cancelAnimationFrame(e);
|
|
63
34
|
clearTimeout(e);
|
|
@@ -65,23 +36,23 @@ function m(e) {
|
|
|
65
36
|
}
|
|
66
37
|
//#endregion
|
|
67
38
|
//#region src/animation/internal/reduced-motion.ts
|
|
68
|
-
var
|
|
69
|
-
function
|
|
39
|
+
var p = "(prefers-reduced-motion: reduce)", m = null, h;
|
|
40
|
+
function g() {
|
|
70
41
|
let e = typeof window > "u" ? void 0 : window.matchMedia;
|
|
71
|
-
return typeof e == "function" ?
|
|
42
|
+
return typeof e == "function" ? m !== null && h === e ? m : (h = e, m = e.call(window, p), m) : (m = null, h = e, null);
|
|
72
43
|
}
|
|
73
|
-
function
|
|
74
|
-
return
|
|
44
|
+
function _() {
|
|
45
|
+
return g()?.matches ?? !1;
|
|
75
46
|
}
|
|
76
|
-
function
|
|
77
|
-
return e === !1 || e === void 0 || !
|
|
47
|
+
function v(e) {
|
|
48
|
+
return e === !1 || e === void 0 || !_() ? 1 : e === !0 || e < 0 ? 0 : e > 1 ? 1 : e;
|
|
78
49
|
}
|
|
79
|
-
function
|
|
80
|
-
return !e && e !== 0 || !
|
|
50
|
+
function y(e, t, n) {
|
|
51
|
+
return !e && e !== 0 || !_() ? n() : e === !0 || e === 0 ? t() : n();
|
|
81
52
|
}
|
|
82
53
|
//#endregion
|
|
83
54
|
//#region src/animation/playback.ts
|
|
84
|
-
var
|
|
55
|
+
var b = class {
|
|
85
56
|
_rafId = null;
|
|
86
57
|
_startTime = void 0;
|
|
87
58
|
_lastFrameT = 0;
|
|
@@ -92,20 +63,20 @@ var S = class {
|
|
|
92
63
|
}
|
|
93
64
|
_run(e) {
|
|
94
65
|
let t = ++this._gen, n = (e) => {
|
|
95
|
-
t === this._gen && (e ? this._rafId =
|
|
66
|
+
t === this._gen && (e ? this._rafId = d(r) : this._cleanup());
|
|
96
67
|
}, r = (t) => {
|
|
97
68
|
let r = e(t);
|
|
98
69
|
r && typeof r.then == "function" ? r.then(n) : n(r);
|
|
99
70
|
};
|
|
100
|
-
this._rafId =
|
|
71
|
+
this._rafId = d(r);
|
|
101
72
|
}
|
|
102
|
-
play = (e, t,
|
|
73
|
+
play = (e, t, r) => {
|
|
103
74
|
if (e <= 0) throw Error("RAFPlayback.play() requires a duration > 0.");
|
|
104
|
-
return this.stop(),
|
|
105
|
-
this._resolve =
|
|
106
|
-
this._startTime === void 0 && (this._startTime =
|
|
107
|
-
let
|
|
108
|
-
return t(
|
|
75
|
+
return this.stop(), y(r?.respectReducedMotion, () => (t(1), Promise.resolve()), () => new Promise((r) => {
|
|
76
|
+
this._resolve = r, this._startTime = void 0, this._run((r) => {
|
|
77
|
+
this._startTime === void 0 && (this._startTime = r);
|
|
78
|
+
let i = n((r - this._startTime) / e, 0, 1);
|
|
79
|
+
return t(i), i < 1;
|
|
109
80
|
});
|
|
110
81
|
}));
|
|
111
82
|
};
|
|
@@ -119,30 +90,30 @@ var S = class {
|
|
|
119
90
|
this.stop(), this._run(e);
|
|
120
91
|
};
|
|
121
92
|
stop = () => {
|
|
122
|
-
this._gen++, this._rafId !== null &&
|
|
93
|
+
this._gen++, this._rafId !== null && f(this._rafId), this._cleanup();
|
|
123
94
|
};
|
|
124
95
|
_cleanup() {
|
|
125
96
|
this._rafId = null, this._startTime = void 0, this._lastFrameT = 0;
|
|
126
97
|
let e = this._resolve;
|
|
127
98
|
this._resolve = null, e?.();
|
|
128
99
|
}
|
|
129
|
-
},
|
|
100
|
+
}, x = {
|
|
130
101
|
damping: .1,
|
|
131
102
|
snapThreshold: .001,
|
|
132
103
|
targetEpsilon: 0,
|
|
133
104
|
initial: 0,
|
|
134
105
|
clamp: !0,
|
|
135
106
|
respectReducedMotion: !1
|
|
136
|
-
},
|
|
107
|
+
}, S = class {
|
|
137
108
|
options;
|
|
138
109
|
targetValue;
|
|
139
110
|
currentValue;
|
|
140
111
|
isSettled;
|
|
141
|
-
_playback = new
|
|
112
|
+
_playback = new b();
|
|
142
113
|
_onFrame = void 0;
|
|
143
114
|
constructor(e) {
|
|
144
115
|
this.options = {
|
|
145
|
-
...
|
|
116
|
+
...x,
|
|
146
117
|
...e
|
|
147
118
|
}, this.targetValue = this.options.initial, this.currentValue = this.options.initial, this.isSettled = !0;
|
|
148
119
|
}
|
|
@@ -156,9 +127,9 @@ var S = class {
|
|
|
156
127
|
return this.isSettled;
|
|
157
128
|
}
|
|
158
129
|
setTarget(e) {
|
|
159
|
-
this.options.clamp && (e =
|
|
130
|
+
this.options.clamp && (e = n(e, 0, 1));
|
|
160
131
|
let t = Math.abs(e - this.targetValue);
|
|
161
|
-
t > 0 && t >= this.options.targetEpsilon && (this.targetValue = e,
|
|
132
|
+
t > 0 && t >= this.options.targetEpsilon && (this.targetValue = e, y(this.options.respectReducedMotion, () => this._snapSettled(), () => {
|
|
162
133
|
this.isSettled = !1, this._onFrame && this._startLoop();
|
|
163
134
|
}));
|
|
164
135
|
}
|
|
@@ -168,7 +139,7 @@ var S = class {
|
|
|
168
139
|
tickDt(e) {
|
|
169
140
|
if (this.isSettled) return this.currentValue;
|
|
170
141
|
let t = 1 - Math.exp(-this.options.damping * e / 16.667);
|
|
171
|
-
return this.currentValue += (this.targetValue - this.currentValue) * t, Math.abs(this.targetValue - this.currentValue) < this.options.snapThreshold && (this.currentValue = this.targetValue, this.isSettled = !0), this.options.clamp && (this.currentValue =
|
|
142
|
+
return this.currentValue += (this.targetValue - this.currentValue) * t, Math.abs(this.targetValue - this.currentValue) < this.options.snapThreshold && (this.currentValue = this.targetValue, this.isSettled = !0), this.options.clamp && (this.currentValue = n(this.currentValue, 0, 1)), this.currentValue;
|
|
172
143
|
}
|
|
173
144
|
snap() {
|
|
174
145
|
this.currentValue = this.targetValue, this.isSettled = !0, this._playback.stop();
|
|
@@ -178,7 +149,7 @@ var S = class {
|
|
|
178
149
|
this.targetValue = t, this.currentValue = t, this.isSettled = !0, this._playback.stop();
|
|
179
150
|
}
|
|
180
151
|
play(e) {
|
|
181
|
-
this._onFrame = e,
|
|
152
|
+
this._onFrame = e, y(this.options.respectReducedMotion, () => this._snapSettled(), () => {
|
|
182
153
|
if (this.isSettled) {
|
|
183
154
|
e?.(this.currentValue);
|
|
184
155
|
return;
|
|
@@ -194,16 +165,32 @@ var S = class {
|
|
|
194
165
|
}
|
|
195
166
|
};
|
|
196
167
|
//#endregion
|
|
197
|
-
//#region src/animation/spring.ts
|
|
198
|
-
function
|
|
199
|
-
let { visualDuration: t, duration:
|
|
168
|
+
//#region src/animation/spring-duration.ts
|
|
169
|
+
function C(e) {
|
|
170
|
+
let { visualDuration: t, duration: r, bounce: i = 0, ...a } = e, o = t ?? r ?? .5, s = 1 - n(i, -1, 1);
|
|
200
171
|
return {
|
|
201
|
-
...
|
|
202
|
-
response:
|
|
203
|
-
dampingFraction:
|
|
172
|
+
...a,
|
|
173
|
+
response: o,
|
|
174
|
+
dampingFraction: s
|
|
204
175
|
};
|
|
205
176
|
}
|
|
206
|
-
|
|
177
|
+
//#endregion
|
|
178
|
+
//#region src/animation/spring-reseat.ts
|
|
179
|
+
function w(e) {
|
|
180
|
+
let t = e.curr.time - e.prev.time;
|
|
181
|
+
return t <= 0 ? 0 : (e.curr.value - e.prev.value) / (t / 1e3);
|
|
182
|
+
}
|
|
183
|
+
function T(e, t, n) {
|
|
184
|
+
let r = w(e), i = new O({
|
|
185
|
+
...n,
|
|
186
|
+
initial: e.curr.value,
|
|
187
|
+
initialVelocity: r
|
|
188
|
+
});
|
|
189
|
+
return i.target = t, i;
|
|
190
|
+
}
|
|
191
|
+
//#endregion
|
|
192
|
+
//#region src/animation/spring.ts
|
|
193
|
+
var E = new Float64Array(), D = {
|
|
207
194
|
response: .5,
|
|
208
195
|
dampingFraction: .86,
|
|
209
196
|
initial: 0,
|
|
@@ -211,7 +198,7 @@ var E = {
|
|
|
211
198
|
settleThreshold: .001,
|
|
212
199
|
velocitySettleThreshold: .001,
|
|
213
200
|
respectReducedMotion: !1
|
|
214
|
-
},
|
|
201
|
+
}, O = class e {
|
|
215
202
|
options;
|
|
216
203
|
targetValue;
|
|
217
204
|
currentValue;
|
|
@@ -226,16 +213,22 @@ var E = {
|
|
|
226
213
|
omegaD;
|
|
227
214
|
subscribers = /* @__PURE__ */ new Set();
|
|
228
215
|
disposed = !1;
|
|
229
|
-
|
|
216
|
+
vecOrigin = null;
|
|
217
|
+
vecOriginVel = null;
|
|
218
|
+
vecTarget = null;
|
|
219
|
+
vecCurrent = null;
|
|
220
|
+
vecVelocity = null;
|
|
221
|
+
vecElapsed = 0;
|
|
222
|
+
_playback = new b();
|
|
230
223
|
_onFrame = void 0;
|
|
231
224
|
constructor(e) {
|
|
232
225
|
this.options = {
|
|
233
|
-
...
|
|
226
|
+
...D,
|
|
234
227
|
...e
|
|
235
|
-
}, this.targetValue = this.options.initial, this.currentValue = this.options.initial, this.currentVelocity = this.options.initialVelocity, this.isSettled = this.options.initialVelocity === 0, this.elapsed = 0, this.originValue = this.currentValue, this.originVelocity = this.currentVelocity, this.amplitudeScale =
|
|
228
|
+
}, this.targetValue = this.options.initial, this.currentValue = this.options.initial, this.currentVelocity = this.options.initialVelocity, this.isSettled = this.options.initialVelocity === 0, this.elapsed = 0, this.originValue = this.currentValue, this.originVelocity = this.currentVelocity, this.amplitudeScale = v(this.options.respectReducedMotion), this.omega = 2 * Math.PI / this.options.response, this.zeta = this.options.dampingFraction, this.omegaD = this.zeta < 1 ? this.omega * Math.sqrt(1 - this.zeta * this.zeta) : 0;
|
|
236
229
|
}
|
|
237
230
|
static fromDuration(t) {
|
|
238
|
-
return new e(
|
|
231
|
+
return new e(C(t ?? {}));
|
|
239
232
|
}
|
|
240
233
|
get target() {
|
|
241
234
|
return this.targetValue;
|
|
@@ -253,8 +246,8 @@ var E = {
|
|
|
253
246
|
e === this.targetValue && !this.options.initialVelocity || this.reseatTarget(e);
|
|
254
247
|
}
|
|
255
248
|
reseatTarget(e) {
|
|
256
|
-
this.targetValue = e,
|
|
257
|
-
this.originValue = this.currentValue, this.originVelocity = this.currentVelocity, this.elapsed = 0, this.isSettled = !1, this.amplitudeScale =
|
|
249
|
+
this.targetValue = e, y(this.options.respectReducedMotion, () => this._snapSettled(), () => {
|
|
250
|
+
this.originValue = this.currentValue, this.originVelocity = this.currentVelocity, this.elapsed = 0, this.isSettled = !1, this.amplitudeScale = v(this.options.respectReducedMotion), this._onFrame && this._startLoop();
|
|
258
251
|
});
|
|
259
252
|
}
|
|
260
253
|
_snapSettled() {
|
|
@@ -292,7 +285,43 @@ var E = {
|
|
|
292
285
|
}
|
|
293
286
|
reset(e, t) {
|
|
294
287
|
let n = e ?? 0, r = t ?? 0;
|
|
295
|
-
this.targetValue = n, this.currentValue = n, this.currentVelocity = r, this.originValue = n, this.originVelocity = r, this.elapsed = 0, this.amplitudeScale =
|
|
288
|
+
this.targetValue = n, this.currentValue = n, this.currentVelocity = r, this.originValue = n, this.originVelocity = r, this.elapsed = 0, this.amplitudeScale = v(this.options.respectReducedMotion), this.isSettled = r === 0, this.emit(), this._playback.stop();
|
|
289
|
+
}
|
|
290
|
+
setTargets(e) {
|
|
291
|
+
let t = e.length;
|
|
292
|
+
if (this.vecTarget === null) this.vecOrigin = new Float64Array(t), this.vecOriginVel = new Float64Array(t), this.vecTarget = new Float64Array(t), this.vecCurrent = new Float64Array(t), this.vecVelocity = new Float64Array(t);
|
|
293
|
+
else if (this.vecTarget.length !== t) throw RangeError(`setTargets length ${t} does not match the armed lane count ${this.vecTarget.length}; the lane buffers are stable references — construct a new SpringProgress for a new arity.`);
|
|
294
|
+
this.vecOrigin.set(this.vecCurrent), this.vecOriginVel.set(this.vecVelocity), this.vecTarget.set(e), this.vecElapsed = 0;
|
|
295
|
+
}
|
|
296
|
+
get values() {
|
|
297
|
+
return this.vecCurrent ?? E;
|
|
298
|
+
}
|
|
299
|
+
get velocities() {
|
|
300
|
+
return this.vecVelocity ?? E;
|
|
301
|
+
}
|
|
302
|
+
tickVector(e) {
|
|
303
|
+
if (this.disposed || this.vecTarget === null || e <= 0) return this.values;
|
|
304
|
+
this.vecElapsed += e / 1e3;
|
|
305
|
+
let t = this.vecElapsed, n = this.omega, r = this.zeta, i = this.omegaD, a = this.vecOrigin, o = this.vecOriginVel, s = this.vecTarget, c = this.vecCurrent, l = this.vecVelocity, u = r < 1 ? Math.exp(-r * n * t) : 0, d = r < 1 ? Math.cos(i * t) : 0, f = r < 1 ? Math.sin(i * t) : 0, p = r === 1 ? Math.exp(-n * t) : 0, m = 0, h = 0, g = 0, _ = 0;
|
|
306
|
+
if (r > 1) {
|
|
307
|
+
let e = n * Math.sqrt(r * r - 1);
|
|
308
|
+
m = -r * n + e, h = -r * n - e, g = Math.exp(m * t), _ = Math.exp(h * t);
|
|
309
|
+
}
|
|
310
|
+
for (let e = 0; e < c.length; e++) {
|
|
311
|
+
let v = a[e] - s[e], y = o[e], b, x;
|
|
312
|
+
if (r < 1) {
|
|
313
|
+
let e = v, t = (y + r * n * v) / i;
|
|
314
|
+
b = u * (e * d + t * f), x = u * ((t * i - e * r * n) * d - (e * i + t * r * n) * f);
|
|
315
|
+
} else if (r === 1) {
|
|
316
|
+
let e = v, r = y + n * v;
|
|
317
|
+
b = p * (e + r * t), x = p * (r - n * (e + r * t));
|
|
318
|
+
} else {
|
|
319
|
+
let e = (y - h * v) / (m - h), t = v - e;
|
|
320
|
+
b = e * g + t * _, x = e * m * g + t * h * _;
|
|
321
|
+
}
|
|
322
|
+
c[e] = s[e] + b, l[e] = x;
|
|
323
|
+
}
|
|
324
|
+
return c;
|
|
296
325
|
}
|
|
297
326
|
subscribe(e) {
|
|
298
327
|
return this.subscribers.add(e), () => {
|
|
@@ -306,7 +335,7 @@ var E = {
|
|
|
306
335
|
this.disposed = !0, this._playback.stop(), this.subscribers.clear();
|
|
307
336
|
}
|
|
308
337
|
play(e) {
|
|
309
|
-
this.disposed || (this._onFrame = e,
|
|
338
|
+
this.disposed || (this._onFrame = e, y(this.options.respectReducedMotion, () => this._snapSettled(), () => {
|
|
310
339
|
if (this.isSettled) {
|
|
311
340
|
e?.(this.currentValue, this.currentVelocity);
|
|
312
341
|
return;
|
|
@@ -320,22 +349,7 @@ var E = {
|
|
|
320
349
|
_startLoop() {
|
|
321
350
|
this._playback.drive(this, () => this._onFrame?.(this.currentValue, this.currentVelocity));
|
|
322
351
|
}
|
|
323
|
-
}
|
|
324
|
-
function O(e) {
|
|
325
|
-
let t = e.curr.time - e.prev.time;
|
|
326
|
-
return t <= 0 ? 0 : (e.curr.value - e.prev.value) / (t / 1e3);
|
|
327
|
-
}
|
|
328
|
-
function k(e, t, n) {
|
|
329
|
-
let r = O(e), i = new D({
|
|
330
|
-
...n,
|
|
331
|
-
initial: e.curr.value,
|
|
332
|
-
initialVelocity: r
|
|
333
|
-
});
|
|
334
|
-
return i.target = t, i;
|
|
335
|
-
}
|
|
336
|
-
//#endregion
|
|
337
|
-
//#region src/animation/timeline.ts
|
|
338
|
-
var A = class {
|
|
352
|
+
}, k = class {
|
|
339
353
|
smoother;
|
|
340
354
|
_easingFn;
|
|
341
355
|
currentProgress = 0;
|
|
@@ -344,10 +358,10 @@ var A = class {
|
|
|
344
358
|
this.boundaryEpsilon = e?.boundaryEpsilon ?? .005;
|
|
345
359
|
let n = e?.easing;
|
|
346
360
|
if (typeof n == "string") throw new t("easing", n, "Timeline accepts a callable TimingFunction or a typed Easing; resolve a string name first via `await resolveEasing(name)`.");
|
|
347
|
-
this._easingFn = n == null ? (e) => e :
|
|
361
|
+
this._easingFn = n == null ? (e) => e : a(n).fn, e?.smoothing === !1 ? this.smoother = null : this.smoother = new S(e?.smoothing);
|
|
348
362
|
}
|
|
349
363
|
applyPipeline() {
|
|
350
|
-
let e =
|
|
364
|
+
let e = n(this.sample(), 0, 1);
|
|
351
365
|
e = this._easingFn(e);
|
|
352
366
|
let t = this.boundaryEpsilon;
|
|
353
367
|
return e <= t ? e = 0 : e >= 1 - t && (e = 1), e;
|
|
@@ -375,7 +389,7 @@ var A = class {
|
|
|
375
389
|
let t = e ?? 0;
|
|
376
390
|
this.smoother && this.smoother.reset(t), this.currentProgress = t;
|
|
377
391
|
}
|
|
378
|
-
},
|
|
392
|
+
}, A = class extends k {
|
|
379
393
|
threshold;
|
|
380
394
|
getScrollY;
|
|
381
395
|
getViewportHeight;
|
|
@@ -386,7 +400,7 @@ var A = class {
|
|
|
386
400
|
let e = this.getViewportHeight() * this.threshold;
|
|
387
401
|
return e <= 0 ? 0 : this.getScrollY() / e;
|
|
388
402
|
}
|
|
389
|
-
},
|
|
403
|
+
}, j = class extends k {
|
|
390
404
|
value = 0;
|
|
391
405
|
constructor(e) {
|
|
392
406
|
super({
|
|
@@ -401,7 +415,7 @@ var A = class {
|
|
|
401
415
|
return this.value;
|
|
402
416
|
}
|
|
403
417
|
};
|
|
404
|
-
function
|
|
418
|
+
function M(e) {
|
|
405
419
|
if (typeof window > "u") return null;
|
|
406
420
|
if (e.kind === "scroll") {
|
|
407
421
|
if (globalThis.ScrollTimeline === void 0) return null;
|
|
@@ -413,4 +427,4 @@ function N(e) {
|
|
|
413
427
|
return e.axis !== void 0 && (t.axis = e.axis), e.inset !== void 0 && (t.inset = e.inset), new globalThis.ViewTimeline(t);
|
|
414
428
|
}
|
|
415
429
|
//#endregion
|
|
416
|
-
export {
|
|
430
|
+
export { a as _, O as a, S as c, y as d, n as f, l as g, c as h, M as i, b as l, i as m, j as n, w as o, r as p, k as r, T as s, A as t, v as u };
|
|
@@ -0,0 +1,100 @@
|
|
|
1
|
+
import { t as e } from "./rolldown-runtime-Dy4uBu1J.js";
|
|
2
|
+
import { CSSCubicBezier as t, FunctionValue as n, ValueArray as r, ValueUnit as i, cssLinear as a, flattenObject as o, functionIdentityValue as s, memoize as c, normalizeValueUnits as l, parseCSSSubValue as u, parseLinearStops as d, parseSteps as f, prepareInterpVar as p, steppedEase as m, timingFunctions as h, unflattenObjectToString as g } from "@mkbabb/value.js";
|
|
3
|
+
//#region src/animation/utils.ts
|
|
4
|
+
var _ = /* @__PURE__ */ e({
|
|
5
|
+
calcFrameTime: () => k,
|
|
6
|
+
createInterpVarValue: () => O,
|
|
7
|
+
getTimingFunction: () => T,
|
|
8
|
+
parseAndFlattenObject: () => D,
|
|
9
|
+
transformTargetsStyle: () => j
|
|
10
|
+
}), v = (e) => e.fnName, y = (e, t) => {
|
|
11
|
+
if (e instanceof i) {
|
|
12
|
+
let n = e.clone();
|
|
13
|
+
return t !== void 0 && (n.fnName = t), [n];
|
|
14
|
+
}
|
|
15
|
+
if (e instanceof n) return e.values.flatMap((t) => y(t, e.name));
|
|
16
|
+
if (e instanceof r) return e.flatMap((e) => y(e, t));
|
|
17
|
+
throw TypeError(`Expected ValueUnit/FunctionValue/ValueArray, got ${typeof e}`);
|
|
18
|
+
}, b = (e) => {
|
|
19
|
+
let t = e.split(".").pop(), n = e.split(".").shift();
|
|
20
|
+
if (!t || !n) throw Error(`Invalid flattened key: ${e}`);
|
|
21
|
+
return {
|
|
22
|
+
mainKey: n,
|
|
23
|
+
childKey: t
|
|
24
|
+
};
|
|
25
|
+
}, x = (e, t, n) => (e.setProperty(t), n !== t && e.setSubProperty(n), e), S = /^\s*cubic-bezier\s*\(\s*(-?[\d.]+)\s*,\s*(-?[\d.]+)\s*,\s*(-?[\d.]+)\s*,\s*(-?[\d.]+)\s*\)\s*$/i, C = /^\s*steps\s*\(/i, w = /^\s*linear\s*\(/i, T = (e) => {
|
|
26
|
+
if (e == null) return;
|
|
27
|
+
if (typeof e != "string") return e;
|
|
28
|
+
let n = e.match(S);
|
|
29
|
+
if (n) {
|
|
30
|
+
let e = n.slice(1, 5).map((e) => Number.parseFloat(e ?? ""));
|
|
31
|
+
if (e.length === 4 && e.every((e) => Number.isFinite(e))) {
|
|
32
|
+
let [n, r, i, a] = e;
|
|
33
|
+
return t(n, r, i, a);
|
|
34
|
+
}
|
|
35
|
+
}
|
|
36
|
+
if (C.test(e)) try {
|
|
37
|
+
let { count: t, jumpTerm: n } = f(e);
|
|
38
|
+
return m(t, n);
|
|
39
|
+
} catch {}
|
|
40
|
+
if (e === "step-start") return m(1, "jump-start");
|
|
41
|
+
if (e === "step-end") return m(1, "jump-end");
|
|
42
|
+
if (w.test(e)) try {
|
|
43
|
+
return a(d(e));
|
|
44
|
+
} catch {}
|
|
45
|
+
let r = h[e];
|
|
46
|
+
if (typeof r == "function" && r.length <= 1) return r;
|
|
47
|
+
}, E = c((e, t) => y(u(t, { subProperty: e })), {
|
|
48
|
+
maxCacheSize: 2048,
|
|
49
|
+
keyFn: (e, t) => `${e}:${t}`
|
|
50
|
+
});
|
|
51
|
+
function D(e) {
|
|
52
|
+
let t = o(e), a = (e, t) => {
|
|
53
|
+
let { childKey: o, mainKey: s } = b(e);
|
|
54
|
+
return t instanceof i ? x(new r(...y(t)), s, o) : t instanceof n ? x(new r(...t.values.flatMap((n) => y(a(e, n), t.name))), s, o) : t instanceof r ? x(new r(...t.flatMap((t) => y(a(e, t)))), s, o) : x(new r(...E(o, String(t)).map((e) => e.clone())), s, o);
|
|
55
|
+
};
|
|
56
|
+
return Object.entries(t).reduce((e, [t, n]) => (e[t] = a(t, n), e), {});
|
|
57
|
+
}
|
|
58
|
+
var O = (e, t, n, r, a = "oklab", o) => {
|
|
59
|
+
let c = r[t], u = r[n];
|
|
60
|
+
if (!c || !u) throw Error(`Invalid interpolation frame bounds (${t} -> ${n}).`);
|
|
61
|
+
let d = c[e], f = u[e];
|
|
62
|
+
if (!d || !f) throw Error(`Missing variable "${e}" in interpolation bounds.`);
|
|
63
|
+
let m = Math.max(d.length, f.length), h = (t, n) => {
|
|
64
|
+
let r = t.map((t) => {
|
|
65
|
+
if (!(t instanceof i)) throw TypeError(`Interpolation for "${e}" requires ValueUnit leaves.`);
|
|
66
|
+
return t;
|
|
67
|
+
});
|
|
68
|
+
for (; r.length < m;) {
|
|
69
|
+
let e = n[r.length], t = e instanceof i ? v(e) : void 0, a = t ? s(t) : void 0;
|
|
70
|
+
r.push(a ?? new i(0));
|
|
71
|
+
}
|
|
72
|
+
return r;
|
|
73
|
+
}, g = h(d, f), _ = h(f, d);
|
|
74
|
+
return g.map((t, n) => {
|
|
75
|
+
let r = _[n];
|
|
76
|
+
if (!r) throw Error(`Missing right-hand interpolation value at index ${n}.`);
|
|
77
|
+
if (!(t instanceof i) || !(r instanceof i)) throw TypeError(`Interpolation for "${e}" requires ValueUnit leaves.`);
|
|
78
|
+
let s = { colorSpace: a };
|
|
79
|
+
return o !== void 0 && (s.hueMethod = o), p(l(t, r, s));
|
|
80
|
+
});
|
|
81
|
+
};
|
|
82
|
+
function k(e, t, n) {
|
|
83
|
+
let [r, i] = [e.start, t.start];
|
|
84
|
+
return {
|
|
85
|
+
start: r.value * n / 100,
|
|
86
|
+
stop: i.value * n / 100
|
|
87
|
+
};
|
|
88
|
+
}
|
|
89
|
+
var A = {};
|
|
90
|
+
function j(e, t, n = !0) {
|
|
91
|
+
e = n ? e : o(e);
|
|
92
|
+
let r = g(e, A);
|
|
93
|
+
t.forEach((e) => {
|
|
94
|
+
Object.entries(r).forEach(([t, n]) => {
|
|
95
|
+
e.style.setProperty(t, n);
|
|
96
|
+
});
|
|
97
|
+
});
|
|
98
|
+
}
|
|
99
|
+
//#endregion
|
|
100
|
+
export { j as a, D as i, O as n, _ as o, T as r, k as t };
|
|
@@ -0,0 +1,35 @@
|
|
|
1
|
+
import { n as e } from "./waapi-D0ssxKy1.js";
|
|
2
|
+
import { CSSKeyframesAnimation as t } from "./engine-DQcb7CLW.js";
|
|
3
|
+
import { compileToCSS as n } from "./compile-YRJRdpKF.js";
|
|
4
|
+
import { extractKeyframes as r, parseCSSStylesheet as i } from "@mkbabb/value.js";
|
|
5
|
+
//#region src/animation/validate.ts
|
|
6
|
+
var a = (e) => new t().fromString(e);
|
|
7
|
+
async function o(t, r = {}) {
|
|
8
|
+
let i = a(t), o = [...i.diagnostics], s = o.some((e) => e.code === "PARSE_ERROR" || e.code === "EMPTY_PARSE"), c = t.trim().length > 0 && !s, l = await n([i], r.compile ?? {}), u = e(i);
|
|
9
|
+
return {
|
|
10
|
+
parseable: c,
|
|
11
|
+
eligible: l.eligible,
|
|
12
|
+
refusals: l.refusals,
|
|
13
|
+
diagnostics: o,
|
|
14
|
+
waapi: u
|
|
15
|
+
};
|
|
16
|
+
}
|
|
17
|
+
var s = (e) => {
|
|
18
|
+
try {
|
|
19
|
+
return [...r(i(e)).keys()];
|
|
20
|
+
} catch {
|
|
21
|
+
return [];
|
|
22
|
+
}
|
|
23
|
+
};
|
|
24
|
+
async function c(e, t = {}) {
|
|
25
|
+
let n = await o(e, t), r = s(e), i = r.length > 0 ? r.join(", ") : "(no @keyframes block)", a = [];
|
|
26
|
+
a.push(`@keyframes ${i}:`), a.push(` parseable: ${n.parseable ? "yes" : "no"}`), a.push(` compile-eligible: ${n.eligible ? "yes" : "no"}`);
|
|
27
|
+
for (let e of n.refusals) a.push(` – ${e.reason}: ${e.message}`);
|
|
28
|
+
if (a.push(` waapi-eligible: ${n.waapi.eligible ? "yes" : "no"}`), n.waapi.eligible || a.push(` – ${n.waapi.reason}`), n.diagnostics.length > 0) {
|
|
29
|
+
a.push(" diagnostics:");
|
|
30
|
+
for (let e of n.diagnostics) a.push(` – ${e.code}: ${e.message}`);
|
|
31
|
+
}
|
|
32
|
+
return a.join("\n");
|
|
33
|
+
}
|
|
34
|
+
//#endregion
|
|
35
|
+
export { c as explain, o as validate };
|