@mkbabb/keyframes.js 5.0.0 → 5.1.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.
Files changed (39) hide show
  1. package/README.md +31 -216
  2. package/dist/animation-BGyzfzBq.js +947 -0
  3. package/dist/compile-CcSUwM8R.js +276 -0
  4. package/dist/{waapi-D0ssxKy1.js → delegation-DWwr4IXr.js} +115 -93
  5. package/dist/{draw-svg-Dat9mHgi.js → draw-svg-GURj9nin.js} +17 -13
  6. package/dist/easing-registry-DHV2-5gA.js +27 -0
  7. package/dist/easing-registry-y1p9McFy.js +2 -0
  8. package/dist/engine/index.d.ts +2873 -0
  9. package/dist/engine/index.js +17 -0
  10. package/dist/engine-DEVgCTUy.js +156 -0
  11. package/dist/engine-DrBtsKaf.js +4 -0
  12. package/dist/{format-BUgCTjmr.js → format-C-Gi9r7L.js} +4 -4
  13. package/dist/{scroll-grammar-B4kPvGh5.js → grammar-BLucehC4.js} +1 -1
  14. package/dist/group-vJcsHKN9.js +360 -0
  15. package/dist/{ingest-CU-kdYcM.js → ingest-S5hUe20K.js} +62 -56
  16. package/dist/keyframes.d.ts +475 -942
  17. package/dist/keyframes.js +196 -137
  18. package/dist/morph-svg-BToeumw5.js +89 -0
  19. package/dist/{motion-path-C0OHqcA3.js → motion-path-pQVbamWT.js} +16 -12
  20. package/dist/parse-flatten-DRMHFytp.js +2 -0
  21. package/dist/parse-flatten-ZZUSEQEL.js +63 -0
  22. package/dist/{animations-CZxf0rep.js → presets-BG2Fczzq.js} +124 -73
  23. package/dist/{scheduler-7eIr_q1g.js → scheduler-CUtVnuoU.js} +1 -1
  24. package/dist/{scroll-scene-DQxhxn9I.js → scroll-CxpYFO4u.js} +50 -46
  25. package/dist/sequence-C_DCiOIQ.js +708 -0
  26. package/dist/validate-DDeGnvSt.js +39 -0
  27. package/package.json +12 -3
  28. package/dist/animate-CTWr6K7j.js +0 -26
  29. package/dist/compile-YRJRdpKF.js +0 -251
  30. package/dist/decay-BvNmFk51.js +0 -25
  31. package/dist/engine-DQcb7CLW.js +0 -1349
  32. package/dist/errors-W8zkvPw4.js +0 -21
  33. package/dist/morph-svg-83uyYxoW.js +0 -84
  34. package/dist/rolldown-runtime-Dy4uBu1J.js +0 -11
  35. package/dist/sequence-cBr7thU8.js +0 -198
  36. package/dist/springTimingFunction-D26gPkAy.js +0 -63
  37. package/dist/timeline-vY3eD3Ax.js +0 -430
  38. package/dist/utils-BPRImVl5.js +0 -100
  39. package/dist/validate-B1pE-Y_T.js +0 -35
@@ -1,430 +0,0 @@
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";
3
- //#region src/animation/easing.ts
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) => {
5
- let t = e.trim();
6
- if (o.test(t) || s.test(t)) return t;
7
- };
8
- async function l(t) {
9
- let n;
10
- try {
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 });
14
- }
15
- let r = n.getTimingFunction(t);
16
- if (!r) throw new e(t);
17
- let i = { fn: r }, a = c(t);
18
- return a && (i.css = a), i;
19
- }
20
- //#endregion
21
- //#region src/animation/internal/leaves.ts
22
- var u = 1e3 / 60;
23
- function d(e) {
24
- if (typeof window < "u" && window.requestAnimationFrame) return window.requestAnimationFrame(e);
25
- let t = u, n = Date.now();
26
- return setTimeout(() => {
27
- let r = Date.now(), i = r - n;
28
- n = r, t = Math.max(0, u - i), e(r);
29
- }, t);
30
- }
31
- function f(e) {
32
- if (e != null) {
33
- if (typeof e == "number" && typeof window < "u" && window.cancelAnimationFrame) return window.cancelAnimationFrame(e);
34
- clearTimeout(e);
35
- }
36
- }
37
- //#endregion
38
- //#region src/animation/internal/reduced-motion.ts
39
- var p = "(prefers-reduced-motion: reduce)", m = null, h;
40
- function g() {
41
- let e = typeof window > "u" ? void 0 : window.matchMedia;
42
- return typeof e == "function" ? m !== null && h === e ? m : (h = e, m = e.call(window, p), m) : (m = null, h = e, null);
43
- }
44
- function _() {
45
- return g()?.matches ?? !1;
46
- }
47
- function v(e) {
48
- return e === !1 || e === void 0 || !_() ? 1 : e === !0 || e < 0 ? 0 : e > 1 ? 1 : e;
49
- }
50
- function y(e, t, n) {
51
- return !e && e !== 0 || !_() ? n() : e === !0 || e === 0 ? t() : n();
52
- }
53
- //#endregion
54
- //#region src/animation/playback.ts
55
- var b = class {
56
- _rafId = null;
57
- _startTime = void 0;
58
- _lastFrameT = 0;
59
- _resolve = null;
60
- _gen = 0;
61
- get running() {
62
- return this._rafId !== null;
63
- }
64
- _run(e) {
65
- let t = ++this._gen, n = (e) => {
66
- t === this._gen && (e ? this._rafId = d(r) : this._cleanup());
67
- }, r = (t) => {
68
- let r = e(t);
69
- r && typeof r.then == "function" ? r.then(n) : n(r);
70
- };
71
- this._rafId = d(r);
72
- }
73
- play = (e, t, r) => {
74
- if (e <= 0) throw Error("RAFPlayback.play() requires a duration > 0.");
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;
80
- });
81
- }));
82
- };
83
- drive = (e, t) => {
84
- this._rafId === null && (this._lastFrameT = 0, this._run((n) => {
85
- let r = this._lastFrameT ? n - this._lastFrameT : 16.667;
86
- return this._lastFrameT = n, e.tickDt(r), t?.(), !e.settled;
87
- }));
88
- };
89
- loop = (e) => {
90
- this.stop(), this._run(e);
91
- };
92
- stop = () => {
93
- this._gen++, this._rafId !== null && f(this._rafId), this._cleanup();
94
- };
95
- _cleanup() {
96
- this._rafId = null, this._startTime = void 0, this._lastFrameT = 0;
97
- let e = this._resolve;
98
- this._resolve = null, e?.();
99
- }
100
- }, x = {
101
- damping: .1,
102
- snapThreshold: .001,
103
- targetEpsilon: 0,
104
- initial: 0,
105
- clamp: !0,
106
- respectReducedMotion: !1
107
- }, S = class {
108
- options;
109
- targetValue;
110
- currentValue;
111
- isSettled;
112
- _playback = new b();
113
- _onFrame = void 0;
114
- constructor(e) {
115
- this.options = {
116
- ...x,
117
- ...e
118
- }, this.targetValue = this.options.initial, this.currentValue = this.options.initial, this.isSettled = !0;
119
- }
120
- get target() {
121
- return this.targetValue;
122
- }
123
- get current() {
124
- return this.currentValue;
125
- }
126
- get settled() {
127
- return this.isSettled;
128
- }
129
- setTarget(e) {
130
- this.options.clamp && (e = n(e, 0, 1));
131
- let t = Math.abs(e - this.targetValue);
132
- t > 0 && t >= this.options.targetEpsilon && (this.targetValue = e, y(this.options.respectReducedMotion, () => this._snapSettled(), () => {
133
- this.isSettled = !1, this._onFrame && this._startLoop();
134
- }));
135
- }
136
- _snapSettled() {
137
- this.currentValue = this.targetValue, this.isSettled = !0, this._onFrame?.(this.currentValue), this._playback.stop();
138
- }
139
- tickDt(e) {
140
- if (this.isSettled) return this.currentValue;
141
- let t = 1 - Math.exp(-this.options.damping * e / 16.667);
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;
143
- }
144
- snap() {
145
- this.currentValue = this.targetValue, this.isSettled = !0, this._playback.stop();
146
- }
147
- reset(e) {
148
- let t = e ?? 0;
149
- this.targetValue = t, this.currentValue = t, this.isSettled = !0, this._playback.stop();
150
- }
151
- play(e) {
152
- this._onFrame = e, y(this.options.respectReducedMotion, () => this._snapSettled(), () => {
153
- if (this.isSettled) {
154
- e?.(this.currentValue);
155
- return;
156
- }
157
- this._startLoop();
158
- });
159
- }
160
- stop() {
161
- this._onFrame = void 0, this._playback.stop();
162
- }
163
- _startLoop() {
164
- this._playback.drive(this, () => this._onFrame?.(this.currentValue));
165
- }
166
- };
167
- //#endregion
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);
171
- return {
172
- ...a,
173
- response: o,
174
- dampingFraction: s
175
- };
176
- }
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 = {
194
- response: .5,
195
- dampingFraction: .86,
196
- initial: 0,
197
- initialVelocity: 0,
198
- settleThreshold: .001,
199
- velocitySettleThreshold: .001,
200
- respectReducedMotion: !1
201
- }, O = class e {
202
- options;
203
- targetValue;
204
- currentValue;
205
- currentVelocity;
206
- isSettled;
207
- elapsed;
208
- originValue;
209
- originVelocity;
210
- amplitudeScale = 1;
211
- omega;
212
- zeta;
213
- omegaD;
214
- subscribers = /* @__PURE__ */ new Set();
215
- disposed = !1;
216
- vecOrigin = null;
217
- vecOriginVel = null;
218
- vecTarget = null;
219
- vecCurrent = null;
220
- vecVelocity = null;
221
- vecElapsed = 0;
222
- _playback = new b();
223
- _onFrame = void 0;
224
- constructor(e) {
225
- this.options = {
226
- ...D,
227
- ...e
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;
229
- }
230
- static fromDuration(t) {
231
- return new e(C(t ?? {}));
232
- }
233
- get target() {
234
- return this.targetValue;
235
- }
236
- get value() {
237
- return this.currentValue;
238
- }
239
- get velocity() {
240
- return this.currentVelocity;
241
- }
242
- get settled() {
243
- return this.isSettled;
244
- }
245
- set target(e) {
246
- e === this.targetValue && !this.options.initialVelocity || this.reseatTarget(e);
247
- }
248
- reseatTarget(e) {
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();
251
- });
252
- }
253
- _snapSettled() {
254
- this.currentValue = this.targetValue, this.currentVelocity = 0, this.originValue = this.targetValue, this.originVelocity = 0, this.elapsed = 0, this.isSettled = !0, this.emit(), this._playback.stop();
255
- }
256
- tickDt(e) {
257
- return this._stepSeconds(e / 1e3);
258
- }
259
- _stepSeconds(e) {
260
- return this.disposed || this.isSettled || e <= 0 ? this.currentValue : (this.elapsed += e, this.evaluateAt(this.elapsed), this.checkSettled(), this.emit(), this.currentValue);
261
- }
262
- tickToTime(e) {
263
- return this.disposed || this.isSettled ? this.currentValue : (this.elapsed = Math.max(0, e), this.evaluateAt(this.elapsed), this.checkSettled(), this.emit(), this.currentValue);
264
- }
265
- evaluateAt(e) {
266
- let t = this.amplitudeScale, n = this.originValue + t * (this.targetValue - this.originValue), r = this.originValue - n, i = this.originVelocity, a = this.omega, o = this.zeta, s, c;
267
- if (o < 1) {
268
- let t = this.omegaD, n = Math.exp(-o * a * e), l = r, u = (i + o * a * r) / t, d = Math.cos(t * e), f = Math.sin(t * e);
269
- s = n * (l * d + u * f), c = n * ((u * t - l * o * a) * d - (l * t + u * o * a) * f);
270
- } else if (o === 1) {
271
- let t = Math.exp(-a * e), n = r, o = i + a * r;
272
- s = t * (n + o * e), c = t * (o - a * (n + o * e));
273
- } else {
274
- let t = a * Math.sqrt(o * o - 1), n = -o * a + t, l = -o * a - t, u = (i - l * r) / (n - l), d = r - u, f = Math.exp(n * e), p = Math.exp(l * e);
275
- s = u * f + d * p, c = u * n * f + d * l * p;
276
- }
277
- this.currentValue = n + s, this.currentVelocity = c;
278
- }
279
- checkSettled() {
280
- let e = this.amplitudeScale, t = this.originValue + e * (this.targetValue - this.originValue), n = Math.abs(this.currentValue - t), r = Math.abs(this.currentVelocity);
281
- n < this.options.settleThreshold && r < this.options.velocitySettleThreshold && (this.currentValue = t, this.currentVelocity = 0, this.isSettled = !0);
282
- }
283
- snap() {
284
- this._snapSettled();
285
- }
286
- reset(e, t) {
287
- let n = e ?? 0, r = t ?? 0;
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;
325
- }
326
- subscribe(e) {
327
- return this.subscribers.add(e), () => {
328
- this.subscribers.delete(e);
329
- };
330
- }
331
- emit() {
332
- if (this.subscribers.size !== 0) for (let e of this.subscribers) e(this.currentValue, this.currentVelocity);
333
- }
334
- dispose() {
335
- this.disposed = !0, this._playback.stop(), this.subscribers.clear();
336
- }
337
- play(e) {
338
- this.disposed || (this._onFrame = e, y(this.options.respectReducedMotion, () => this._snapSettled(), () => {
339
- if (this.isSettled) {
340
- e?.(this.currentValue, this.currentVelocity);
341
- return;
342
- }
343
- this._startLoop();
344
- }));
345
- }
346
- stop() {
347
- this._onFrame = void 0, this._playback.stop();
348
- }
349
- _startLoop() {
350
- this._playback.drive(this, () => this._onFrame?.(this.currentValue, this.currentVelocity));
351
- }
352
- }, k = class {
353
- smoother;
354
- _easingFn;
355
- currentProgress = 0;
356
- boundaryEpsilon;
357
- constructor(e) {
358
- this.boundaryEpsilon = e?.boundaryEpsilon ?? .005;
359
- let n = e?.easing;
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)`.");
361
- this._easingFn = n == null ? (e) => e : a(n).fn, e?.smoothing === !1 ? this.smoother = null : this.smoother = new S(e?.smoothing);
362
- }
363
- applyPipeline() {
364
- let e = n(this.sample(), 0, 1);
365
- e = this._easingFn(e);
366
- let t = this.boundaryEpsilon;
367
- return e <= t ? e = 0 : e >= 1 - t && (e = 1), e;
368
- }
369
- _advance(e) {
370
- let t = this.applyPipeline();
371
- return this.smoother ? (this.smoother.setTarget(t), t <= 0 || t >= 1 ? this.smoother.snap() : this.smoother.tickDt(e), this.currentProgress = this.smoother.current) : this.currentProgress = t, this.currentProgress;
372
- }
373
- tick() {
374
- return this._advance(16.667);
375
- }
376
- tickDt(e) {
377
- return this._advance(e);
378
- }
379
- get progress() {
380
- return this.currentProgress;
381
- }
382
- get settled() {
383
- return this.smoother == null || this.smoother.settled;
384
- }
385
- snap() {
386
- this.smoother?.snap(), this.smoother && (this.currentProgress = this.smoother.current);
387
- }
388
- reset(e) {
389
- let t = e ?? 0;
390
- this.smoother && this.smoother.reset(t), this.currentProgress = t;
391
- }
392
- }, A = class extends k {
393
- threshold;
394
- getScrollY;
395
- getViewportHeight;
396
- constructor(e) {
397
- super(e), this.threshold = e?.threshold ?? .35, this.getScrollY = e?.getScrollY ?? (() => window.scrollY), this.getViewportHeight = e?.getViewportHeight ?? (() => window.innerHeight);
398
- }
399
- sample() {
400
- let e = this.getViewportHeight() * this.threshold;
401
- return e <= 0 ? 0 : this.getScrollY() / e;
402
- }
403
- }, j = class extends k {
404
- value = 0;
405
- constructor(e) {
406
- super({
407
- smoothing: !1,
408
- ...e
409
- });
410
- }
411
- set(e) {
412
- this.value = e;
413
- }
414
- sample() {
415
- return this.value;
416
- }
417
- };
418
- function M(e) {
419
- if (typeof window > "u") return null;
420
- if (e.kind === "scroll") {
421
- if (globalThis.ScrollTimeline === void 0) return null;
422
- let t = {};
423
- return e.source !== void 0 && (t.source = e.source), e.axis !== void 0 && (t.axis = e.axis), new globalThis.ScrollTimeline(t);
424
- }
425
- if (globalThis.ViewTimeline === void 0) return null;
426
- let t = { subject: e.subject };
427
- return e.axis !== void 0 && (t.axis = e.axis), e.inset !== void 0 && (t.inset = e.inset), new globalThis.ViewTimeline(t);
428
- }
429
- //#endregion
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 };
@@ -1,100 +0,0 @@
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 };
@@ -1,35 +0,0 @@
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 };