@mkbabb/keyframes.js 4.3.0 → 4.4.0

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
@@ -1,63 +1,46 @@
1
- //#region src/animation/internal/errors.ts
2
- var e = (e) => typeof e == "string" ? JSON.stringify(e) : typeof e == "function" ? `[function ${e.name || "anonymous"}]` : String(e), t = class extends Error {
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";
21
2
  //#region src/animation/easing.ts
22
- var i = (e) => typeof e == "function" ? { fn: e } : e, a = /^(linear|ease|ease-in|ease-out|ease-in-out)$/, o = /^(cubic-bezier\(|steps\(|linear\(|step-start$|step-end$)/, s = (e) => {
3
+ var n = (e) => typeof e == "function" ? { fn: e } : e, r = /^(linear|ease|ease-in|ease-out|ease-in-out)$/, i = /^(cubic-bezier\(|steps\(|linear\(|step-start$|step-end$)/, a = (e) => {
23
4
  let t = e.trim();
24
- if (a.test(t) || o.test(t)) return t;
5
+ if (r.test(t) || i.test(t)) return t;
25
6
  };
26
- async function c(e) {
27
- let t;
7
+ async function o(t) {
8
+ let n;
28
9
  try {
29
- t = await import("./engine-BKm1GcJT.js");
30
- } catch (t) {
31
- throw Error(`keyframes: the engine chunk failed to load while resolving easing "${e}" — the easing registry is unreachable.`, { cause: t });
32
- }
33
- let r = t.getTimingFunction(e);
34
- if (!r) throw new n(e);
35
- let i = { fn: r }, a = s(e);
36
- return a && (i.css = a), i;
10
+ n = await import("./engine-CNHvTgpw.js");
11
+ } catch (e) {
12
+ throw Error(`keyframes: the engine chunk failed to load while resolving easing "${t}" — the easing registry is unreachable.`, { cause: e });
13
+ }
14
+ let r = n.getTimingFunction(t);
15
+ if (!r) throw new e(t);
16
+ let i = { fn: r }, o = a(t);
17
+ return o && (i.css = o), i;
37
18
  }
38
19
  //#endregion
39
20
  //#region src/animation/internal/leaves.ts
40
- var l = 1e3 / 60;
41
- function u(e, t, n) {
21
+ var s = 1e3 / 60;
22
+ function c(e, t, n) {
42
23
  return Math.min(Math.max(e, t), n);
43
24
  }
44
- function d(e, t, n, r = 0, i = 1) {
25
+ function l(e, t, n, r = 0, i = 1) {
45
26
  if (n === t) throw Error("fromMax and fromMin cannot be equal");
46
27
  let a = (i - r) / (n - t);
47
28
  return (e - t) * a + r;
48
29
  }
49
- function f(e, t, n) {
50
- return (1 - n) * e + n * t;
30
+ function u(e, t, n, r) {
31
+ let i = e.length, a = 1 - n;
32
+ for (let o = 0; o < i; o++) r[o] = a * e[o] + n * t[o];
33
+ return r;
51
34
  }
52
- function p(e) {
35
+ function d(e) {
53
36
  if (typeof window < "u" && window.requestAnimationFrame) return window.requestAnimationFrame(e);
54
- let t = l, n = Date.now();
37
+ let t = s, n = Date.now();
55
38
  return setTimeout(() => {
56
39
  let r = Date.now(), i = r - n;
57
- n = r, t = Math.max(0, l - i), e(r);
40
+ n = r, t = Math.max(0, s - i), e(r);
58
41
  }, t);
59
42
  }
60
- function m(e) {
43
+ function f(e) {
61
44
  if (e != null) {
62
45
  if (typeof e == "number" && typeof window < "u" && window.cancelAnimationFrame) return window.cancelAnimationFrame(e);
63
46
  clearTimeout(e);
@@ -65,23 +48,23 @@ function m(e) {
65
48
  }
66
49
  //#endregion
67
50
  //#region src/animation/internal/reduced-motion.ts
68
- var h = "(prefers-reduced-motion: reduce)", g = null, _;
69
- function v() {
51
+ var p = "(prefers-reduced-motion: reduce)", m = null, h;
52
+ function g() {
70
53
  let e = typeof window > "u" ? void 0 : window.matchMedia;
71
- return typeof e == "function" ? g !== null && _ === e ? g : (_ = e, g = e.call(window, h), g) : (g = null, _ = e, null);
54
+ return typeof e == "function" ? m !== null && h === e ? m : (h = e, m = e.call(window, p), m) : (m = null, h = e, null);
72
55
  }
73
- function y() {
74
- return v()?.matches ?? !1;
56
+ function _() {
57
+ return g()?.matches ?? !1;
75
58
  }
76
- function b(e) {
77
- return e === !1 || e === void 0 || !y() ? 1 : e === !0 || e < 0 ? 0 : e > 1 ? 1 : e;
59
+ function v(e) {
60
+ return e === !1 || e === void 0 || !_() ? 1 : e === !0 || e < 0 ? 0 : e > 1 ? 1 : e;
78
61
  }
79
- function x(e, t, n) {
80
- return !e && e !== 0 || !y() ? n() : e === !0 || e === 0 ? t() : n();
62
+ function y(e, t, n) {
63
+ return !e && e !== 0 || !_() ? n() : e === !0 || e === 0 ? t() : n();
81
64
  }
82
65
  //#endregion
83
66
  //#region src/animation/playback.ts
84
- var S = class {
67
+ var b = class {
85
68
  _rafId = null;
86
69
  _startTime = void 0;
87
70
  _lastFrameT = 0;
@@ -92,19 +75,19 @@ var S = class {
92
75
  }
93
76
  _run(e) {
94
77
  let t = ++this._gen, n = (e) => {
95
- t === this._gen && (e ? this._rafId = p(r) : this._cleanup());
78
+ t === this._gen && (e ? this._rafId = d(r) : this._cleanup());
96
79
  }, r = (t) => {
97
80
  let r = e(t);
98
81
  r && typeof r.then == "function" ? r.then(n) : n(r);
99
82
  };
100
- this._rafId = p(r);
83
+ this._rafId = d(r);
101
84
  }
102
85
  play = (e, t, n) => {
103
86
  if (e <= 0) throw Error("RAFPlayback.play() requires a duration > 0.");
104
- return this.stop(), x(n?.respectReducedMotion, () => (t(1), Promise.resolve()), () => new Promise((n) => {
87
+ return this.stop(), y(n?.respectReducedMotion, () => (t(1), Promise.resolve()), () => new Promise((n) => {
105
88
  this._resolve = n, this._startTime = void 0, this._run((n) => {
106
89
  this._startTime === void 0 && (this._startTime = n);
107
- let r = u((n - this._startTime) / e, 0, 1);
90
+ let r = c((n - this._startTime) / e, 0, 1);
108
91
  return t(r), r < 1;
109
92
  });
110
93
  }));
@@ -119,30 +102,30 @@ var S = class {
119
102
  this.stop(), this._run(e);
120
103
  };
121
104
  stop = () => {
122
- this._gen++, this._rafId !== null && m(this._rafId), this._cleanup();
105
+ this._gen++, this._rafId !== null && f(this._rafId), this._cleanup();
123
106
  };
124
107
  _cleanup() {
125
108
  this._rafId = null, this._startTime = void 0, this._lastFrameT = 0;
126
109
  let e = this._resolve;
127
110
  this._resolve = null, e?.();
128
111
  }
129
- }, C = {
112
+ }, x = {
130
113
  damping: .1,
131
114
  snapThreshold: .001,
132
115
  targetEpsilon: 0,
133
116
  initial: 0,
134
117
  clamp: !0,
135
118
  respectReducedMotion: !1
136
- }, w = class {
119
+ }, S = class {
137
120
  options;
138
121
  targetValue;
139
122
  currentValue;
140
123
  isSettled;
141
- _playback = new S();
124
+ _playback = new b();
142
125
  _onFrame = void 0;
143
126
  constructor(e) {
144
127
  this.options = {
145
- ...C,
128
+ ...x,
146
129
  ...e
147
130
  }, this.targetValue = this.options.initial, this.currentValue = this.options.initial, this.isSettled = !0;
148
131
  }
@@ -156,9 +139,9 @@ var S = class {
156
139
  return this.isSettled;
157
140
  }
158
141
  setTarget(e) {
159
- this.options.clamp && (e = u(e, 0, 1));
142
+ this.options.clamp && (e = c(e, 0, 1));
160
143
  let t = Math.abs(e - this.targetValue);
161
- t > 0 && t >= this.options.targetEpsilon && (this.targetValue = e, x(this.options.respectReducedMotion, () => this._snapSettled(), () => {
144
+ t > 0 && t >= this.options.targetEpsilon && (this.targetValue = e, y(this.options.respectReducedMotion, () => this._snapSettled(), () => {
162
145
  this.isSettled = !1, this._onFrame && this._startLoop();
163
146
  }));
164
147
  }
@@ -168,7 +151,7 @@ var S = class {
168
151
  tickDt(e) {
169
152
  if (this.isSettled) return this.currentValue;
170
153
  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 = u(this.currentValue, 0, 1)), this.currentValue;
154
+ 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 = c(this.currentValue, 0, 1)), this.currentValue;
172
155
  }
173
156
  snap() {
174
157
  this.currentValue = this.targetValue, this.isSettled = !0, this._playback.stop();
@@ -178,7 +161,7 @@ var S = class {
178
161
  this.targetValue = t, this.currentValue = t, this.isSettled = !0, this._playback.stop();
179
162
  }
180
163
  play(e) {
181
- this._onFrame = e, x(this.options.respectReducedMotion, () => this._snapSettled(), () => {
164
+ this._onFrame = e, y(this.options.respectReducedMotion, () => this._snapSettled(), () => {
182
165
  if (this.isSettled) {
183
166
  e?.(this.currentValue);
184
167
  return;
@@ -194,16 +177,32 @@ var S = class {
194
177
  }
195
178
  };
196
179
  //#endregion
197
- //#region src/animation/spring.ts
198
- function T(e) {
199
- let { visualDuration: t, duration: n, bounce: r = 0, ...i } = e, a = t ?? n ?? E.response, o = 1 - u(r, -1, 1);
180
+ //#region src/animation/spring-duration.ts
181
+ function C(e) {
182
+ let { visualDuration: t, duration: n, bounce: r = 0, ...i } = e, a = t ?? n ?? .5, o = 1 - c(r, -1, 1);
200
183
  return {
201
184
  ...i,
202
185
  response: a,
203
186
  dampingFraction: o
204
187
  };
205
188
  }
206
- var E = {
189
+ //#endregion
190
+ //#region src/animation/spring-reseat.ts
191
+ function w(e) {
192
+ let t = e.curr.time - e.prev.time;
193
+ return t <= 0 ? 0 : (e.curr.value - e.prev.value) / (t / 1e3);
194
+ }
195
+ function T(e, t, n) {
196
+ let r = w(e), i = new O({
197
+ ...n,
198
+ initial: e.curr.value,
199
+ initialVelocity: r
200
+ });
201
+ return i.target = t, i;
202
+ }
203
+ //#endregion
204
+ //#region src/animation/spring.ts
205
+ var E = new Float64Array(), D = {
207
206
  response: .5,
208
207
  dampingFraction: .86,
209
208
  initial: 0,
@@ -211,7 +210,7 @@ var E = {
211
210
  settleThreshold: .001,
212
211
  velocitySettleThreshold: .001,
213
212
  respectReducedMotion: !1
214
- }, D = class e {
213
+ }, O = class e {
215
214
  options;
216
215
  targetValue;
217
216
  currentValue;
@@ -226,16 +225,22 @@ var E = {
226
225
  omegaD;
227
226
  subscribers = /* @__PURE__ */ new Set();
228
227
  disposed = !1;
229
- _playback = new S();
228
+ vecOrigin = null;
229
+ vecOriginVel = null;
230
+ vecTarget = null;
231
+ vecCurrent = null;
232
+ vecVelocity = null;
233
+ vecElapsed = 0;
234
+ _playback = new b();
230
235
  _onFrame = void 0;
231
236
  constructor(e) {
232
237
  this.options = {
233
- ...E,
238
+ ...D,
234
239
  ...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 = b(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;
240
+ }, 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
241
  }
237
242
  static fromDuration(t) {
238
- return new e(T(t ?? {}));
243
+ return new e(C(t ?? {}));
239
244
  }
240
245
  get target() {
241
246
  return this.targetValue;
@@ -253,8 +258,8 @@ var E = {
253
258
  e === this.targetValue && !this.options.initialVelocity || this.reseatTarget(e);
254
259
  }
255
260
  reseatTarget(e) {
256
- this.targetValue = e, x(this.options.respectReducedMotion, () => this._snapSettled(), () => {
257
- this.originValue = this.currentValue, this.originVelocity = this.currentVelocity, this.elapsed = 0, this.isSettled = !1, this.amplitudeScale = b(this.options.respectReducedMotion), this._onFrame && this._startLoop();
261
+ this.targetValue = e, y(this.options.respectReducedMotion, () => this._snapSettled(), () => {
262
+ 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
263
  });
259
264
  }
260
265
  _snapSettled() {
@@ -292,7 +297,43 @@ var E = {
292
297
  }
293
298
  reset(e, t) {
294
299
  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 = b(this.options.respectReducedMotion), this.isSettled = r === 0, this.emit(), this._playback.stop();
300
+ 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();
301
+ }
302
+ setTargets(e) {
303
+ let t = e.length;
304
+ 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);
305
+ 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.`);
306
+ this.vecOrigin.set(this.vecCurrent), this.vecOriginVel.set(this.vecVelocity), this.vecTarget.set(e), this.vecElapsed = 0;
307
+ }
308
+ get values() {
309
+ return this.vecCurrent ?? E;
310
+ }
311
+ get velocities() {
312
+ return this.vecVelocity ?? E;
313
+ }
314
+ tickVector(e) {
315
+ if (this.disposed || this.vecTarget === null || e <= 0) return this.values;
316
+ this.vecElapsed += e / 1e3;
317
+ 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;
318
+ if (r > 1) {
319
+ let e = n * Math.sqrt(r * r - 1);
320
+ m = -r * n + e, h = -r * n - e, g = Math.exp(m * t), _ = Math.exp(h * t);
321
+ }
322
+ for (let e = 0; e < c.length; e++) {
323
+ let v = a[e] - s[e], y = o[e], b, x;
324
+ if (r < 1) {
325
+ let e = v, t = (y + r * n * v) / i;
326
+ b = u * (e * d + t * f), x = u * ((t * i - e * r * n) * d - (e * i + t * r * n) * f);
327
+ } else if (r === 1) {
328
+ let e = v, r = y + n * v;
329
+ b = p * (e + r * t), x = p * (r - n * (e + r * t));
330
+ } else {
331
+ let e = (y - h * v) / (m - h), t = v - e;
332
+ b = e * g + t * _, x = e * m * g + t * h * _;
333
+ }
334
+ c[e] = s[e] + b, l[e] = x;
335
+ }
336
+ return c;
296
337
  }
297
338
  subscribe(e) {
298
339
  return this.subscribers.add(e), () => {
@@ -306,7 +347,7 @@ var E = {
306
347
  this.disposed = !0, this._playback.stop(), this.subscribers.clear();
307
348
  }
308
349
  play(e) {
309
- this.disposed || (this._onFrame = e, x(this.options.respectReducedMotion, () => this._snapSettled(), () => {
350
+ this.disposed || (this._onFrame = e, y(this.options.respectReducedMotion, () => this._snapSettled(), () => {
310
351
  if (this.isSettled) {
311
352
  e?.(this.currentValue, this.currentVelocity);
312
353
  return;
@@ -320,34 +361,19 @@ var E = {
320
361
  _startLoop() {
321
362
  this._playback.drive(this, () => this._onFrame?.(this.currentValue, this.currentVelocity));
322
363
  }
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 {
364
+ }, k = class {
339
365
  smoother;
340
366
  _easingFn;
341
367
  currentProgress = 0;
342
368
  boundaryEpsilon;
343
369
  constructor(e) {
344
370
  this.boundaryEpsilon = e?.boundaryEpsilon ?? .005;
345
- let n = e?.easing;
346
- 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 : i(n).fn, e?.smoothing === !1 ? this.smoother = null : this.smoother = new w(e?.smoothing);
371
+ let r = e?.easing;
372
+ if (typeof r == "string") throw new t("easing", r, "Timeline accepts a callable TimingFunction or a typed Easing; resolve a string name first via `await resolveEasing(name)`.");
373
+ this._easingFn = r == null ? (e) => e : n(r).fn, e?.smoothing === !1 ? this.smoother = null : this.smoother = new S(e?.smoothing);
348
374
  }
349
375
  applyPipeline() {
350
- let e = u(this.sample(), 0, 1);
376
+ let e = c(this.sample(), 0, 1);
351
377
  e = this._easingFn(e);
352
378
  let t = this.boundaryEpsilon;
353
379
  return e <= t ? e = 0 : e >= 1 - t && (e = 1), e;
@@ -375,7 +401,7 @@ var A = class {
375
401
  let t = e ?? 0;
376
402
  this.smoother && this.smoother.reset(t), this.currentProgress = t;
377
403
  }
378
- }, j = class extends A {
404
+ }, A = class extends k {
379
405
  threshold;
380
406
  getScrollY;
381
407
  getViewportHeight;
@@ -386,7 +412,7 @@ var A = class {
386
412
  let e = this.getViewportHeight() * this.threshold;
387
413
  return e <= 0 ? 0 : this.getScrollY() / e;
388
414
  }
389
- }, M = class extends A {
415
+ }, j = class extends k {
390
416
  value = 0;
391
417
  constructor(e) {
392
418
  super({
@@ -401,7 +427,7 @@ var A = class {
401
427
  return this.value;
402
428
  }
403
429
  };
404
- function N(e) {
430
+ function M(e) {
405
431
  if (typeof window > "u") return null;
406
432
  if (e.kind === "scroll") {
407
433
  if (globalThis.ScrollTimeline === void 0) return null;
@@ -413,4 +439,4 @@ function N(e) {
413
439
  return e.axis !== void 0 && (t.axis = e.axis), e.inset !== void 0 && (t.inset = e.inset), new globalThis.ViewTimeline(t);
414
440
  }
415
441
  //#endregion
416
- export { i as _, D as a, r as b, w as c, x as d, u as f, c as g, s as h, N as i, S as l, d as m, j as n, O as o, f as p, A as r, k as s, M as t, b as u, t as v, n as y };
442
+ export { n as _, O as a, S as c, y as d, c as f, o as g, a as h, M as i, b as l, l as m, j as n, w as o, u as p, k as r, T as s, A as t, v as u };
@@ -0,0 +1,97 @@
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: () => j,
6
+ createInterpVarValue: () => A,
7
+ getTimingFunction: () => D,
8
+ parseAndFlattenObject: () => k,
9
+ transformTargetsStyle: () => N
10
+ }), v = /* @__PURE__ */ new WeakMap(), y = (e) => v.get(e), b = (e, t) => (t !== void 0 && v.set(e, t), e), x = (e, t) => {
11
+ if (e instanceof i) return [b(e.clone(), t ?? y(e))];
12
+ if (e instanceof n) return e.values.flatMap((t) => x(t, e.name));
13
+ if (e instanceof r) return e.flatMap((e) => x(e, t));
14
+ throw TypeError(`Expected ValueUnit/FunctionValue/ValueArray, got ${typeof e}`);
15
+ }, S = (e) => {
16
+ let t = e.split(".").pop(), n = e.split(".").shift();
17
+ if (!t || !n) throw Error(`Invalid flattened key: ${e}`);
18
+ return {
19
+ mainKey: n,
20
+ childKey: t
21
+ };
22
+ }, C = (e, t, n) => (e.setProperty(t), n !== t && e.setSubProperty(n), e), w = /^\s*cubic-bezier\s*\(\s*(-?[\d.]+)\s*,\s*(-?[\d.]+)\s*,\s*(-?[\d.]+)\s*,\s*(-?[\d.]+)\s*\)\s*$/i, T = /^\s*steps\s*\(/i, E = /^\s*linear\s*\(/i, D = (e) => {
23
+ if (e == null) return;
24
+ if (typeof e != "string") return e;
25
+ let n = e.match(w);
26
+ if (n) {
27
+ let e = n.slice(1, 5).map((e) => Number.parseFloat(e ?? ""));
28
+ if (e.length === 4 && e.every((e) => Number.isFinite(e))) {
29
+ let [n, r, i, a] = e;
30
+ return t(n, r, i, a);
31
+ }
32
+ }
33
+ if (T.test(e)) try {
34
+ let { count: t, jumpTerm: n } = f(e);
35
+ return m(t, n);
36
+ } catch {}
37
+ if (e === "step-start") return m(1, "jump-start");
38
+ if (e === "step-end") return m(1, "jump-end");
39
+ if (E.test(e)) try {
40
+ return a(d(e));
41
+ } catch {}
42
+ let r = h[e];
43
+ if (typeof r == "function" && r.length <= 1) return r;
44
+ }, O = c((e, t) => x(u(t, { subProperty: e })), {
45
+ maxCacheSize: 2048,
46
+ keyFn: (e, t) => `${e}:${t}`
47
+ });
48
+ function k(e) {
49
+ let t = o(e), a = (e, t) => {
50
+ let { childKey: o, mainKey: s } = S(e);
51
+ return t instanceof i ? C(new r(...x(t)), s, o) : t instanceof n ? C(new r(...t.values.flatMap((n) => x(a(e, n), t.name))), s, o) : t instanceof r ? C(new r(...t.flatMap((t) => x(a(e, t)))), s, o) : C(new r(...O(o, String(t)).map((e) => b(e.clone(), y(e)))), s, o);
52
+ };
53
+ return Object.entries(t).reduce((e, [t, n]) => (e[t] = a(t, n), e), {});
54
+ }
55
+ var A = (e, t, n, r, a = "oklab", o) => {
56
+ let c = r[t], u = r[n];
57
+ if (!c || !u) throw Error(`Invalid interpolation frame bounds (${t} -> ${n}).`);
58
+ let d = c[e], f = u[e];
59
+ if (!d || !f) throw Error(`Missing variable "${e}" in interpolation bounds.`);
60
+ let m = Math.max(d.length, f.length), h = (t, n) => {
61
+ let r = t.map((t) => {
62
+ if (!(t instanceof i)) throw TypeError(`Interpolation for "${e}" requires ValueUnit leaves.`);
63
+ return t;
64
+ });
65
+ for (; r.length < m;) {
66
+ let e = n[r.length], t = e instanceof i ? y(e) : void 0, a = t ? s(t) : void 0;
67
+ r.push(a ?? new i(0));
68
+ }
69
+ return r;
70
+ }, g = h(d, f), _ = h(f, d);
71
+ return g.map((t, n) => {
72
+ let r = _[n];
73
+ if (!r) throw Error(`Missing right-hand interpolation value at index ${n}.`);
74
+ if (!(t instanceof i) || !(r instanceof i)) throw TypeError(`Interpolation for "${e}" requires ValueUnit leaves.`);
75
+ let s = { colorSpace: a };
76
+ return o !== void 0 && (s.hueMethod = o), p(l(t, r, s));
77
+ });
78
+ };
79
+ function j(e, t, n) {
80
+ let [r, i] = [e.start, t.start];
81
+ return {
82
+ start: r.value * n / 100,
83
+ stop: i.value * n / 100
84
+ };
85
+ }
86
+ var M = {};
87
+ function N(e, t, n = !0) {
88
+ e = n ? e : o(e);
89
+ let r = g(e, M);
90
+ t.forEach((e) => {
91
+ Object.entries(r).forEach(([t, n]) => {
92
+ e.style.setProperty(t, n);
93
+ });
94
+ });
95
+ }
96
+ //#endregion
97
+ export { N as a, k as i, A as n, _ as o, D as r, j as t };
@@ -0,0 +1,35 @@
1
+ import { n as e } from "./waapi-D9MHMm_9.js";
2
+ import { CSSKeyframesAnimation as t } from "./engine-CNHvTgpw.js";
3
+ import { compileToCSS as n } from "./compile-DgNRG6Lo.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 };
@@ -1,4 +1,4 @@
1
- import { f as e, i as t } from "./timeline-BjcmprQ6.js";
1
+ import { f as e, i as t } from "./timeline-B7SV3T_E.js";
2
2
  import { COMPUTED_UNITS as n, unflattenObjectToString as r } from "@mkbabb/value.js";
3
3
  //#region src/animation/waapi.ts
4
4
  var i = new Set([
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@mkbabb/keyframes.js",
3
- "version": "4.3.0",
3
+ "version": "4.4.0",
4
4
  "description": "Create keyframe animations for anything in JavaScript; specify your keyframes in standards-complaint CSS.",
5
5
  "license": "MIT",
6
6
  "keywords": [
@@ -43,6 +43,7 @@
43
43
  "proof:boundary": "node scripts/proof-boundary.mjs",
44
44
  "proof:published-surface": "node scripts/proof-published-surface.mjs",
45
45
  "proof:agent-surface": "node scripts/proof-agent-surface.mjs",
46
+ "proof:agent-validate": "node scripts/proof-agent-validate.mjs && vitest run test/agent-validate.test.ts",
46
47
  "proof:demo-on-published-surface": "node scripts/proof-demo-on-published-surface.mjs",
47
48
  "proof:color-fidelity": "node scripts/proof-color-fidelity.mjs && vitest run test/color-fidelity.test.ts",
48
49
  "proof:readme-runs": "node scripts/proof-readme-runs.mjs",
@@ -62,8 +63,15 @@
62
63
  "proof:standalone-zero-alloc": "vitest run test/standalone-zero-alloc.test.ts",
63
64
  "proof:compile-deterministic": "vitest run test/compile-deterministic.test.ts",
64
65
  "proof:compile-replay": "node scripts/proof-compile-replay.mjs && vitest run test/compile-roundtrip.test.ts",
66
+ "proof:replay-equality": "node scripts/proof-replay-equality.mjs && vitest run test/replay-equality.test.ts",
65
67
  "proof:bench-runs": "node scripts/proof-bench-runs.mjs",
68
+ "proof:bench-taxonomy": "node scripts/proof-bench-taxonomy.mjs",
69
+ "proof:scheduler-posttask": "node scripts/proof-scheduler-posttask.mjs",
70
+ "proof:epf1-measure": "node scripts/proof-epf1-measure.mjs",
71
+ "proof:spring-vector": "node scripts/proof-spring-vector.mjs",
66
72
  "proof:orchestration": "node scripts/proof-orchestration.mjs",
73
+ "proof:animate-orchestration": "vitest run test/animate-orchestration.test.ts",
74
+ "proof:transport-events": "node scripts/proof-transport-events.mjs",
67
75
  "proof:interp-fastprops": "node --allow-natives-syntax scripts/proof-interp-fastprops.mjs && vitest run test/interp-fastprops.test.ts",
68
76
  "proof:sync-step": "vitest run test/sync-step.test.ts",
69
77
  "proof:event-ordering": "vitest run test/event-ordering.test.ts",
@@ -165,14 +173,32 @@
165
173
  "proof:motion-path-editable": "node scripts/proof-motion-path-editable.mjs",
166
174
  "proof:motion-path-copy": "node scripts/proof-motion-path-copy.mjs",
167
175
  "proof:easter-egg": "node scripts/proof-easter-egg.mjs",
176
+ "proof:crayon-preserved": "node scripts/proof-crayon-preserved.mjs",
177
+ "proof:design-refinement": "node scripts/proof-design-refinement.mjs",
168
178
  "proof:spring-slider-continuous": "node scripts/proof-spring-slider-continuous.mjs",
169
179
  "proof:taste-packet": "node scripts/proof-taste-packet.mjs",
170
180
  "proof:ci-coverage": "node scripts/proof-ci-coverage.mjs",
181
+ "proof:report-all": "node scripts/proof-report-all.mjs",
182
+ "proof:no-single-option-select": "node scripts/proof-no-single-option-select.mjs",
183
+ "proof:peer-satisfied": "node scripts/proof-peer-satisfied.mjs",
184
+ "proof:css-parity": "node scripts/proof-css-parity.mjs",
185
+ "proof:packrat-sound": "node scripts/proof-packrat-sound.mjs",
186
+ "proof:consume-bundle": "node scripts/proof-consume-bundle.mjs",
187
+ "proof:keyframes-vue-published": "node scripts/proof-keyframes-vue-published.mjs",
188
+ "proof:workaround-deletion": "node scripts/proof-workaround-deletion.mjs",
189
+ "proof:control-point-live": "node scripts/proof-control-point-live.mjs",
190
+ "proof:settle-is-predicate": "node scripts/proof-settle-is-predicate.mjs",
171
191
  "proof:manifest-sourced": "node scripts/proof-manifest-sourced.mjs",
172
192
  "proof:chronic-closure": "node scripts/proof-chronic-closure.mjs",
173
- "proof:correctness": "npm run proof:engine-no-throw-on-play && npm run proof:subject-animates && npm run proof:cold-entry && npm run proof:fsm-suspend-resume-live && npm run proof:easing-editor-live && npm run proof:amiga-subject-is-pivot && npm run proof:drag-gesture && npm run proof:control-surface-single-writer && npm run proof:sheet-reopen-scroll && npm run proof:perf-frame-budget && npm run proof:icon-paint-live && npm run proof:specular-absent-at-rest && npm run proof:demo-fonts && npm run proof:font-census && npm run proof:live-session && npm run proof:live-session-mobile && npm run proof:appearance-suffusion && npm run proof:spring-slider-continuous",
174
- "proof:hygiene": "npm run proof:deps-current && npm run proof:repin-witness && npm run proof:boundary && npm run proof:dogfood && npm run proof:engine && npm run proof:decomposition && npm run proof:no-deprecated-guard && npm run proof:single-writer && npm run proof:composable-encapsulation && npm run proof:demo-no-oversize && npm run proof:no-brittle-selector && npm run proof:no-dup-utility && npm run proof:demo-smoke && npm run proof:occlusion && npm run proof:cartoon-is-panel-depth && npm run proof:glass-and-cartoon && npm run proof:dock-popover-opens && npm run proof:single-toggle && npm run proof:darkmode-row-toggle && npm run proof:idle-fade && npm run proof:single-column-pack && npm run proof:label-subgrid && npm run proof:timeline-rail-width && npm run proof:demo-shell-grid && npm run proof:layout-cluster && npm run proof:stage-not-clipped && npm run proof:cartoon-shadow-unclipped && npm run proof:scene-machine-irrefragable && npm run proof:scene-control-dfa && npm run proof:scene-transition-perf && npm run proof:dock-zorder && npm run proof:drawer-spring && npm run proof:idioms && npm run proof:phi-leaf-zero && npm run proof:icon-idiom && npm run proof:styling-idioms && npm run proof:scene-parity && npm run proof:sequence-rows-draggable && npm run proof:motion-path-editable && npm run proof:motion-path-copy && npm run proof:easter-egg && npm run proof:typing-dots && npm run proof:dogfood-hero && npm run proof:easing-canvas-bounded && npm run proof:scene-uses-standard-ribbon && npm run proof:easing-sidebar-normalized && npm run proof:easing-sidebar-minimal && npm run proof:easing-stage-is-ball && npm run proof:scene-card-rounded && npm run proof:stage-glass-card && npm run proof:card-rounded-primitive && npm run proof:stage-within-docks && npm run proof:mobile-single-page && npm run proof:bezier-no-scroll && npm run proof:bezier-single-card && npm run proof:bezier-grown && npm run proof:pp-logo-svg && npm run proof:scene-perf-budget && npm run proof:hero-rung && npm run proof:hero-balance && npm run proof:hero-cls && npm run proof:brittleness && npm run proof:demo-elevate && npm run proof:modern-web && npm run proof:zero-alloc && npm run proof:engine-correctness && npm run proof:standalone-zero-alloc && npm run proof:compile-deterministic && npm run proof:compile-replay && npm run proof:platform-adopt && npm run proof:orchestration && npm run proof:interp-fastprops && npm run proof:sync-step && npm run proof:roundtrip-easing && npm run proof:adapter-capture && npm run proof:composition-honored && npm run proof:diagnostics-channel && npm run proof:scroll-roundtrip && npm run proof:motion-path && npm run proof:blend && npm run proof:spring-blend-weight && npm run proof:drawsvg && npm run proof:finished && npm run proof:adopt-compiled && npm run proof:interpolate-anything && npm run proof:roundtrip-fidelity && npm run proof:ingest-replay && npm run proof:orbital-rotate3d && npm run proof:asset-store-singleton && npm run proof:scene-raf-leak && npm run proof:scene-contract-identity && npm run proof:group-snapshot-identity && npm run proof:resize-tracks && npm run proof:cohesion && npm run proof:visual-lock && npm run proof:demo-usability && npm run proof:computed-real-dom && npm run proof:lighthouse-a11y && npm run proof:lighthouse-mobile && npm run proof:published-surface && npm run proof:agent-surface && npm run proof:demo-on-published-surface && npm run proof:color-fidelity && npm run proof:readme-runs && npm run proof:event-ordering && npm run proof:manifest-sourced && npm run proof:bench-runs && npm run proof:gate-is-runtime && npm run proof:chronic-closure && npm run proof:taste-packet && npm run proof:ci-coverage && vitest run",
175
- "proof:all": "npm run proof:correctness && npm run proof:hygiene",
193
+ "proof:no-foreign-symbol-stamp": "node scripts/proof-no-foreign-symbol-stamp.mjs",
194
+ "proof:soa-composite": "node scripts/proof-soa-composite.mjs && npm run proof:blend",
195
+ "proof:emerging-css-resolve-now": "node scripts/proof-emerging-css-resolve-now.mjs && vitest run test/emerging-css-resolve-now.test.ts",
196
+ "proof:morphsvg-consume": "node scripts/proof-morphsvg-consume.mjs && vitest run test/morph-svg.test.ts",
197
+ "proof:portable-perf": "node scripts/proof-portable-perf.mjs",
198
+ "proof:correctness": "npm run proof:engine-no-throw-on-play && npm run proof:subject-animates && npm run proof:cold-entry && npm run proof:fsm-suspend-resume-live && npm run proof:easing-editor-live && npm run proof:amiga-subject-is-pivot && npm run proof:drag-gesture && npm run proof:control-surface-single-writer && npm run proof:sheet-reopen-scroll && npm run proof:perf-frame-budget && npm run proof:icon-paint-live && npm run proof:specular-absent-at-rest && npm run proof:demo-fonts && npm run proof:font-census && npm run proof:live-session && npm run proof:live-session-mobile && npm run proof:appearance-suffusion && npm run proof:spring-slider-continuous && npm run proof:emerging-css-resolve-now",
199
+ "proof:hygiene": "npm run proof:deps-current && npm run proof:repin-witness && npm run proof:boundary && npm run proof:consume-bundle && npm run proof:css-parity && npm run proof:packrat-sound && npm run proof:workaround-deletion && npm run proof:dogfood && npm run proof:engine && npm run proof:decomposition && npm run proof:no-deprecated-guard && npm run proof:single-writer && npm run proof:composable-encapsulation && npm run proof:demo-no-oversize && npm run proof:no-brittle-selector && npm run proof:no-dup-utility && npm run proof:no-single-option-select && npm run proof:settle-is-predicate && npm run proof:demo-smoke && npm run proof:occlusion && npm run proof:cartoon-is-panel-depth && npm run proof:glass-and-cartoon && npm run proof:dock-popover-opens && npm run proof:single-toggle && npm run proof:darkmode-row-toggle && npm run proof:idle-fade && npm run proof:single-column-pack && npm run proof:label-subgrid && npm run proof:timeline-rail-width && npm run proof:demo-shell-grid && npm run proof:layout-cluster && npm run proof:stage-not-clipped && npm run proof:cartoon-shadow-unclipped && npm run proof:scene-machine-irrefragable && npm run proof:scene-control-dfa && npm run proof:scene-transition-perf && npm run proof:dock-zorder && npm run proof:drawer-spring && npm run proof:idioms && npm run proof:phi-leaf-zero && npm run proof:icon-idiom && npm run proof:styling-idioms && npm run proof:scene-parity && npm run proof:sequence-rows-draggable && npm run proof:motion-path-editable && npm run proof:motion-path-copy && npm run proof:easter-egg && npm run proof:crayon-preserved && npm run proof:design-refinement && npm run proof:typing-dots && npm run proof:dogfood-hero && npm run proof:easing-canvas-bounded && npm run proof:scene-uses-standard-ribbon && npm run proof:easing-sidebar-normalized && npm run proof:easing-sidebar-minimal && npm run proof:easing-stage-is-ball && npm run proof:scene-card-rounded && npm run proof:stage-glass-card && npm run proof:card-rounded-primitive && npm run proof:stage-within-docks && npm run proof:mobile-single-page && npm run proof:bezier-no-scroll && npm run proof:bezier-single-card && npm run proof:bezier-grown && npm run proof:pp-logo-svg && npm run proof:scene-perf-budget && npm run proof:hero-rung && npm run proof:hero-balance && npm run proof:hero-cls && npm run proof:brittleness && npm run proof:demo-elevate && npm run proof:modern-web && npm run proof:zero-alloc && npm run proof:engine-correctness && npm run proof:standalone-zero-alloc && npm run proof:compile-deterministic && npm run proof:compile-replay && npm run proof:replay-equality && npm run proof:platform-adopt && npm run proof:orchestration && npm run proof:transport-events && npm run proof:animate-orchestration && npm run proof:interp-fastprops && npm run proof:sync-step && npm run proof:roundtrip-easing && npm run proof:adapter-capture && npm run proof:composition-honored && npm run proof:diagnostics-channel && npm run proof:scroll-roundtrip && npm run proof:motion-path && npm run proof:blend && npm run proof:spring-blend-weight && npm run proof:drawsvg && npm run proof:finished && npm run proof:adopt-compiled && npm run proof:interpolate-anything && npm run proof:roundtrip-fidelity && npm run proof:ingest-replay && npm run proof:orbital-rotate3d && npm run proof:asset-store-singleton && npm run proof:scene-raf-leak && npm run proof:scene-contract-identity && npm run proof:group-snapshot-identity && npm run proof:resize-tracks && npm run proof:cohesion && npm run proof:visual-lock && npm run proof:demo-usability && npm run proof:computed-real-dom && npm run proof:lighthouse-a11y && npm run proof:lighthouse-mobile && npm run proof:published-surface && npm run proof:agent-surface && npm run proof:agent-validate && npm run proof:demo-on-published-surface && npm run proof:color-fidelity && npm run proof:readme-runs && npm run proof:event-ordering && npm run proof:manifest-sourced && npm run proof:bench-runs && npm run proof:bench-taxonomy && npm run proof:scheduler-posttask && npm run proof:epf1-measure && npm run proof:spring-vector && npm run proof:gate-is-runtime && npm run proof:chronic-closure && npm run proof:taste-packet && npm run proof:ci-coverage && npm run proof:no-foreign-symbol-stamp && npm run proof:soa-composite && npm run proof:morphsvg-consume && npm run proof:portable-perf && npm run proof:report-all && vitest run",
200
+ "proof:all": "node scripts/run-all.mjs --all",
201
+ "proof:all:demo": "npm run proof:demo-smoke && npm run proof:occlusion && npm run proof:peer-satisfied",
176
202
  "test": "vitest",
177
203
  "bench": "vitest bench",
178
204
  "bench:color-fidelity": "vitest run test/color-fidelity.test.ts && node scripts/color-fidelity-harness.mjs",
@@ -191,8 +217,7 @@
191
217
  },
192
218
  "homepage": "https://github.com/mkbabb/keyframes.js#readme",
193
219
  "dependencies": {
194
- "@mkbabb/parse-that": "^0.9.0",
195
- "@mkbabb/value.js": "^0.13.0"
220
+ "@mkbabb/value.js": "^1.1.0"
196
221
  },
197
222
  "optionalDependencies": {
198
223
  "@mkbabb/glass-ui": "~4.0.0"