@nil-/xit 0.4.15 → 0.4.17

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,13 +1,14 @@
1
- var et = (e) => {
1
+ var v = (e) => {
2
2
  throw TypeError(e);
3
3
  };
4
- var X = (e, t, s) => t.has(e) || et("Cannot " + s);
5
- var r = (e, t, s) => (X(e, t, "read from private field"), s ? s.call(e) : t.get(e)), c = (e, t, s) => t.has(e) ? et("Cannot add the same private member more than once") : t instanceof WeakSet ? t.add(e) : t.set(e, s), h = (e, t, s, i) => (X(e, t, "write to private field"), i ? i.call(e, s) : t.set(e, s), s), st = (e, t, s) => (X(e, t, "access private method"), s);
4
+ var W = (e, t, s) => t.has(e) || v("Cannot " + s);
5
+ var r = (e, t, s) => (W(e, t, "read from private field"), s ? s.call(e) : t.get(e)), c = (e, t, s) => t.has(e) ? v("Cannot add the same private member more than once") : t instanceof WeakSet ? t.add(e) : t.set(e, s), d = (e, t, s, i) => (W(e, t, "write to private field"), i ? i.call(e, s) : t.set(e, s), s), tt = (e, t, s) => (W(e, t, "access private method"), s);
6
6
  import "./internal/client.js";
7
- import { o as dt, b as O, c as rt, a as g, k as lt, n as ut, g as S } from "./index.js";
8
- import { c as mt, w as nt } from "./store.js";
9
- import { linear as it } from "./easing.js";
10
- const pt = () => performance.now(), u = {
7
+ import { MediaQuery as ct } from "./reactivity.js";
8
+ import { w as et } from "./store.js";
9
+ import { b as z, c as st, a as g, l as ht, n as dt, g as D } from "./index.js";
10
+ import { linear as rt } from "./easing.js";
11
+ const ut = () => performance.now(), m = {
11
12
  // don't access requestAnimationFrame eagerly outside method
12
13
  // this allows basic testing of user code without JSDOM
13
14
  // bunder will eval and remove ternary when the user's app is built
@@ -15,66 +16,33 @@ const pt = () => performance.now(), u = {
15
16
  /** @param {any} _ */
16
17
  (e) => requestAnimationFrame(e)
17
18
  ),
18
- now: () => pt(),
19
+ now: () => ut(),
19
20
  tasks: /* @__PURE__ */ new Set()
20
21
  };
21
- function ot() {
22
- const e = u.now();
23
- u.tasks.forEach((t) => {
24
- t.c(e) || (u.tasks.delete(t), t.f());
25
- }), u.tasks.size !== 0 && u.tick(ot);
22
+ function it() {
23
+ const e = m.now();
24
+ m.tasks.forEach((t) => {
25
+ t.c(e) || (m.tasks.delete(t), t.f());
26
+ }), m.tasks.size !== 0 && m.tick(it);
26
27
  }
27
28
  function U(e) {
28
29
  let t;
29
- return u.tasks.size === 0 && u.tick(ot), {
30
+ return m.tasks.size === 0 && m.tick(it), {
30
31
  promise: new Promise((s) => {
31
- u.tasks.add(t = { c: e, f: s });
32
+ m.tasks.add(t = { c: e, f: s });
32
33
  }),
33
34
  abort() {
34
- u.tasks.delete(t);
35
+ m.tasks.delete(t);
35
36
  }
36
37
  };
37
38
  }
38
- var q, B;
39
- class gt {
40
- /**
41
- *
42
- * @param {() => T} fn
43
- * @param {(update: () => void) => void} onsubscribe
44
- */
45
- constructor(t, s) {
46
- c(this, q);
47
- c(this, B);
48
- h(this, q, t), h(this, B, mt(s));
49
- }
50
- get current() {
51
- return r(this, B).call(this), r(this, q).call(this);
52
- }
53
- }
54
- q = new WeakMap(), B = new WeakMap();
55
- const bt = /\(.+\)/, yt = /* @__PURE__ */ new Set(["all", "print", "screen", "and", "or", "not", "only"]);
56
- class wt extends gt {
57
- /**
58
- * @param {string} query A media query string
59
- * @param {boolean} [fallback] Fallback value for the server
60
- */
61
- constructor(t, s) {
62
- let i = bt.test(t) || // we need to use `some` here because technically this `window.matchMedia('random,screen')` still returns true
63
- t.split(/[\s,]+/).some((n) => yt.has(n.trim())) ? t : `(${t})`;
64
- const o = window.matchMedia(i);
65
- super(
66
- () => o.matches,
67
- (n) => dt(o, "change", n)
68
- );
69
- }
70
- }
71
39
  function J(e) {
72
40
  return Object.prototype.toString.call(e) === "[object Date]";
73
41
  }
74
42
  function K(e, t, s, i) {
75
43
  if (typeof s == "number" || J(s)) {
76
- const o = i - s, n = (s - t) / (e.dt || 1 / 60), f = e.opts.stiffness * o, a = e.opts.damping * n, d = (f - a) * e.inv_mass, m = (n + d) * e.dt;
77
- return Math.abs(m) < e.opts.precision && Math.abs(o) < e.opts.precision ? i : (e.settled = !1, J(s) ? new Date(s.getTime() + m) : s + m);
44
+ const o = i - s, n = (s - t) / (e.dt || 1 / 60), f = e.opts.stiffness * o, a = e.opts.damping * n, h = (f - a) * e.inv_mass, l = (n + h) * e.dt;
45
+ return Math.abs(l) < e.opts.precision && Math.abs(o) < e.opts.precision ? i : (e.settled = !1, J(s) ? new Date(s.getTime() + l) : s + l);
78
46
  } else {
79
47
  if (Array.isArray(s))
80
48
  return s.map(
@@ -92,42 +60,42 @@ function K(e, t, s, i) {
92
60
  throw new Error(`Cannot spring ${typeof s} values`);
93
61
  }
94
62
  }
95
- function kt(e, t = {}) {
96
- const s = nt(e), { stiffness: i = 0.15, damping: o = 0.8, precision: n = 0.01 } = t;
97
- let f, a, d, m = (
63
+ function mt(e, t = {}) {
64
+ const s = et(e), { stiffness: i = 0.15, damping: o = 0.8, precision: n = 0.01 } = t;
65
+ let f, a, h, l = (
98
66
  /** @type {T} */
99
67
  e
100
- ), b = (
68
+ ), y = (
101
69
  /** @type {T | undefined} */
102
70
  e
103
- ), l = 1, P = 0, y = !1;
104
- function A(_, w = {}) {
105
- b = _;
106
- const at = d = {};
107
- return e == null || w.hard || E.stiffness >= 1 && E.damping >= 1 ? (y = !0, f = u.now(), m = _, s.set(e = b), Promise.resolve()) : (w.soft && (P = 1 / ((w.soft === !0 ? 0.5 : +w.soft) * 60), l = 0), a || (f = u.now(), y = !1, a = U((V) => {
108
- if (y)
109
- return y = !1, a = null, !1;
110
- l = Math.min(l + P, 1);
111
- const ct = Math.min(V - f, 1e3 / 30), W = {
112
- inv_mass: l,
71
+ ), u = 1, P = 0, b = !1;
72
+ function A(O, w = {}) {
73
+ y = O;
74
+ const ot = h = {};
75
+ return e == null || w.hard || E.stiffness >= 1 && E.damping >= 1 ? (b = !0, f = m.now(), l = O, s.set(e = y), Promise.resolve()) : (w.soft && (P = 1 / ((w.soft === !0 ? 0.5 : +w.soft) * 60), u = 0), a || (f = m.now(), b = !1, a = U((B) => {
76
+ if (b)
77
+ return b = !1, a = null, !1;
78
+ u = Math.min(u + P, 1);
79
+ const ft = Math.min(B - f, 1e3 / 30), V = {
80
+ inv_mass: u,
113
81
  opts: E,
114
82
  settled: !0,
115
- dt: ct * 60 / 1e3
116
- }, ht = K(W, m, e, b);
117
- return f = V, m = /** @type {T} */
83
+ dt: ft * 60 / 1e3
84
+ }, at = K(V, l, e, y);
85
+ return f = B, l = /** @type {T} */
118
86
  e, s.set(e = /** @type {T} */
119
- ht), W.settled && (a = null), !W.settled;
120
- })), new Promise((V) => {
87
+ at), V.settled && (a = null), !V.settled;
88
+ })), new Promise((B) => {
121
89
  a.promise.then(() => {
122
- at === d && V();
90
+ ot === h && B();
123
91
  });
124
92
  }));
125
93
  }
126
94
  const E = {
127
95
  set: A,
128
- update: (_, w) => A(_(
96
+ update: (O, w) => A(O(
129
97
  /** @type {T} */
130
- b,
98
+ y,
131
99
  /** @type {T} */
132
100
  e
133
101
  ), w),
@@ -138,34 +106,34 @@ function kt(e, t = {}) {
138
106
  };
139
107
  return E;
140
108
  }
141
- var z, D, T, p, j, C, x, R, G, k, F, N, ft;
142
- const v = class v {
109
+ var S, T, C, p, j, _, Q, q, G, k, R, N, nt;
110
+ const Z = class Z {
143
111
  /**
144
112
  * @param {T} value
145
113
  * @param {SpringOpts} [options]
146
114
  */
147
115
  constructor(t, s = {}) {
148
116
  c(this, N);
149
- c(this, z, O(0.15));
150
- c(this, D, O(0.8));
151
- c(this, T, O(0.01));
152
- c(this, p, O(
117
+ c(this, S, z(0.15));
118
+ c(this, T, z(0.8));
119
+ c(this, C, z(0.01));
120
+ c(this, p, z(
153
121
  /** @type {T} */
154
122
  void 0
155
123
  ));
156
- c(this, j, O(
124
+ c(this, j, z(
157
125
  /** @type {T} */
158
126
  void 0
159
127
  ));
160
- c(this, C);
161
- c(this, x, 0);
162
- c(this, R, 1);
128
+ c(this, _);
129
+ c(this, Q, 0);
130
+ c(this, q, 1);
163
131
  c(this, G, 0);
164
132
  /** @type {import('../internal/client/types').Task | null} */
165
133
  c(this, k, null);
166
134
  /** @type {ReturnType<typeof deferred> | null} */
167
- c(this, F, null);
168
- r(this, p).v = r(this, j).v = t, typeof s.stiffness == "number" && (r(this, z).v = I(s.stiffness, 0, 1)), typeof s.damping == "number" && (r(this, D).v = I(s.damping, 0, 1)), typeof s.precision == "number" && (r(this, T).v = s.precision);
135
+ c(this, R, null);
136
+ r(this, p).v = r(this, j).v = t, typeof s.stiffness == "number" && (r(this, S).v = I(s.stiffness, 0, 1)), typeof s.damping == "number" && (r(this, T).v = I(s.damping, 0, 1)), typeof s.precision == "number" && (r(this, C).v = s.precision);
169
137
  }
170
138
  /**
171
139
  * Create a spring whose value is bound to the return value of `fn`. This must be called
@@ -185,8 +153,8 @@ const v = class v {
185
153
  * @param {SpringOpts} [options]
186
154
  */
187
155
  static of(t, s) {
188
- const i = new v(t(), s);
189
- return rt(() => {
156
+ const i = new Z(t(), s);
157
+ return st(() => {
190
158
  i.set(t());
191
159
  }), i;
192
160
  }
@@ -203,67 +171,67 @@ const v = class v {
203
171
  */
204
172
  set(t, s) {
205
173
  var o, n;
206
- if ((o = r(this, F)) == null || o.reject(new Error("Aborted")), s != null && s.instant || r(this, p).v === void 0)
207
- return (n = r(this, k)) == null || n.abort(), h(this, k, null), g(r(this, p), g(r(this, j), t)), h(this, C, t), Promise.resolve();
208
- s != null && s.preserveMomentum && (h(this, R, 0), h(this, G, s.preserveMomentum));
209
- var i = h(this, F, lt());
210
- return i.promise.catch(ut), st(this, N, ft).call(this, t).then(() => {
211
- i === r(this, F) && i.resolve(void 0);
174
+ if ((o = r(this, R)) == null || o.reject(new Error("Aborted")), s != null && s.instant || r(this, p).v === void 0)
175
+ return (n = r(this, k)) == null || n.abort(), d(this, k, null), g(r(this, p), g(r(this, j), t)), d(this, _, t), Promise.resolve();
176
+ s != null && s.preserveMomentum && (d(this, q, 0), d(this, G, s.preserveMomentum));
177
+ var i = d(this, R, ht());
178
+ return i.promise.catch(dt), tt(this, N, nt).call(this, t).then(() => {
179
+ i === r(this, R) && i.resolve(void 0);
212
180
  }), i.promise;
213
181
  }
214
182
  get current() {
215
- return S(r(this, p));
183
+ return D(r(this, p));
216
184
  }
217
185
  get damping() {
218
- return S(r(this, D));
186
+ return D(r(this, T));
219
187
  }
220
188
  set damping(t) {
221
- g(r(this, D), I(t, 0, 1));
189
+ g(r(this, T), I(t, 0, 1));
222
190
  }
223
191
  get precision() {
224
- return S(r(this, T));
192
+ return D(r(this, C));
225
193
  }
226
194
  set precision(t) {
227
- g(r(this, T), t);
195
+ g(r(this, C), t);
228
196
  }
229
197
  get stiffness() {
230
- return S(r(this, z));
198
+ return D(r(this, S));
231
199
  }
232
200
  set stiffness(t) {
233
- g(r(this, z), I(t, 0, 1));
201
+ g(r(this, S), I(t, 0, 1));
234
202
  }
235
203
  get target() {
236
- return S(r(this, j));
204
+ return D(r(this, j));
237
205
  }
238
206
  set target(t) {
239
207
  this.set(t);
240
208
  }
241
209
  };
242
- z = new WeakMap(), D = new WeakMap(), T = new WeakMap(), p = new WeakMap(), j = new WeakMap(), C = new WeakMap(), x = new WeakMap(), R = new WeakMap(), G = new WeakMap(), k = new WeakMap(), F = new WeakMap(), N = new WeakSet(), /** @param {T} value */
243
- ft = function(t) {
210
+ S = new WeakMap(), T = new WeakMap(), C = new WeakMap(), p = new WeakMap(), j = new WeakMap(), _ = new WeakMap(), Q = new WeakMap(), q = new WeakMap(), G = new WeakMap(), k = new WeakMap(), R = new WeakMap(), N = new WeakSet(), /** @param {T} value */
211
+ nt = function(t) {
244
212
  var i;
245
- if (g(r(this, j), t), (i = r(this, p)).v ?? (i.v = t), r(this, C) ?? h(this, C, r(this, p).v), !r(this, k)) {
246
- h(this, x, u.now());
213
+ if (g(r(this, j), t), (i = r(this, p)).v ?? (i.v = t), r(this, _) ?? d(this, _, r(this, p).v), !r(this, k)) {
214
+ d(this, Q, m.now());
247
215
  var s = 1e3 / (r(this, G) * 60);
248
- r(this, k) ?? h(this, k, U((o) => {
249
- h(this, R, Math.min(r(this, R) + s, 1));
250
- const n = Math.min(o - r(this, x), 1e3 / 30), f = {
251
- inv_mass: r(this, R),
216
+ r(this, k) ?? d(this, k, U((o) => {
217
+ d(this, q, Math.min(r(this, q) + s, 1));
218
+ const n = Math.min(o - r(this, Q), 1e3 / 30), f = {
219
+ inv_mass: r(this, q),
252
220
  opts: {
253
- stiffness: r(this, z).v,
254
- damping: r(this, D).v,
255
- precision: r(this, T).v
221
+ stiffness: r(this, S).v,
222
+ damping: r(this, T).v,
223
+ precision: r(this, C).v
256
224
  },
257
225
  settled: !0,
258
226
  dt: n * 60 / 1e3
259
227
  };
260
- var a = K(f, r(this, C), r(this, p).v, r(this, j).v);
261
- return h(this, C, r(this, p).v), h(this, x, o), g(r(this, p), a), f.settled && h(this, k, null), !f.settled;
228
+ var a = K(f, r(this, _), r(this, p).v, r(this, j).v);
229
+ return d(this, _, r(this, p).v), d(this, Q, o), g(r(this, p), a), f.settled && d(this, k, null), !f.settled;
262
230
  }));
263
231
  }
264
232
  return r(this, k).promise;
265
233
  };
266
- let Y = v;
234
+ let X = Z;
267
235
  function I(e, t, s) {
268
236
  return Math.max(t, Math.min(s, e));
269
237
  }
@@ -288,7 +256,7 @@ function L(e, t) {
288
256
  throw new Error("Object cannot be null");
289
257
  if (J(e) && J(t)) {
290
258
  const n = e.getTime(), a = t.getTime() - n;
291
- return (d) => new Date(n + d * a);
259
+ return (h) => new Date(n + h * a);
292
260
  }
293
261
  const i = Object.keys(t), o = {};
294
262
  return i.forEach((n) => {
@@ -310,36 +278,36 @@ function L(e, t) {
310
278
  }
311
279
  return () => t;
312
280
  }
313
- function Mt(e, t = {}) {
314
- const s = nt(e);
281
+ function lt(e, t = {}) {
282
+ const s = et(e);
315
283
  let i, o = e;
316
284
  function n(f, a) {
317
285
  if (o = f, e == null)
318
286
  return s.set(e = f), Promise.resolve();
319
- let d = i, m = !1, {
320
- delay: b = 0,
321
- duration: l = 400,
322
- easing: P = it,
323
- interpolate: y = L
287
+ let h = i, l = !1, {
288
+ delay: y = 0,
289
+ duration: u = 400,
290
+ easing: P = rt,
291
+ interpolate: b = L
324
292
  } = { ...t, ...a };
325
- if (l === 0)
326
- return d && (d.abort(), d = null), s.set(e = o), Promise.resolve();
327
- const A = u.now() + b;
293
+ if (u === 0)
294
+ return h && (h.abort(), h = null), s.set(e = o), Promise.resolve();
295
+ const A = m.now() + y;
328
296
  let E;
329
- return i = U((_) => {
330
- if (_ < A) return !0;
331
- m || (E = y(
297
+ return i = U((O) => {
298
+ if (O < A) return !0;
299
+ l || (E = b(
332
300
  /** @type {any} */
333
301
  e,
334
302
  f
335
- ), typeof l == "function" && (l = l(
303
+ ), typeof u == "function" && (u = u(
336
304
  /** @type {any} */
337
305
  e,
338
306
  f
339
- )), m = !0), d && (d.abort(), d = null);
340
- const w = _ - A;
307
+ )), l = !0), h && (h.abort(), h = null);
308
+ const w = O - A;
341
309
  return w > /** @type {number} */
342
- l ? (s.set(e = f), !1) : (s.set(e = E(P(w / l))), !0);
310
+ u ? (s.set(e = f), !1) : (s.set(e = E(P(w / u))), !0);
343
311
  }), i.promise;
344
312
  }
345
313
  return {
@@ -353,26 +321,26 @@ function Mt(e, t = {}) {
353
321
  subscribe: s.subscribe
354
322
  };
355
323
  }
356
- var M, Q, H, $;
357
- const tt = class tt {
324
+ var M, $, H, F;
325
+ const x = class x {
358
326
  /**
359
327
  * @param {T} value
360
328
  * @param {TweenedOptions<T>} options
361
329
  */
362
330
  constructor(t, s = {}) {
363
- c(this, M, O(
331
+ c(this, M, z(
364
332
  /** @type {T} */
365
333
  void 0
366
334
  ));
367
- c(this, Q, O(
335
+ c(this, $, z(
368
336
  /** @type {T} */
369
337
  void 0
370
338
  ));
371
339
  /** @type {TweenedOptions<T>} */
372
340
  c(this, H);
373
341
  /** @type {import('../internal/client/types').Task | null} */
374
- c(this, $, null);
375
- r(this, M).v = r(this, Q).v = t, h(this, H, s);
342
+ c(this, F, null);
343
+ r(this, M).v = r(this, $).v = t, d(this, H, s);
376
344
  }
377
345
  /**
378
346
  * Create a tween whose value is bound to the return value of `fn`. This must be called
@@ -392,8 +360,8 @@ const tt = class tt {
392
360
  * @param {TweenedOptions<U>} [options]
393
361
  */
394
362
  static of(t, s) {
395
- const i = new tt(t(), s);
396
- return rt(() => {
363
+ const i = new x(t(), s);
364
+ return st(() => {
397
365
  i.set(t());
398
366
  }), i;
399
367
  }
@@ -406,56 +374,56 @@ const tt = class tt {
406
374
  * @returns
407
375
  */
408
376
  set(t, s) {
409
- var l;
410
- g(r(this, Q), t);
377
+ var u;
378
+ g(r(this, $), t);
411
379
  let {
412
380
  delay: i = 0,
413
381
  duration: o = 400,
414
- easing: n = it,
382
+ easing: n = rt,
415
383
  interpolate: f = L
416
384
  } = { ...r(this, H), ...s };
417
385
  if (o === 0)
418
- return (l = r(this, $)) == null || l.abort(), g(r(this, M), t), Promise.resolve();
419
- const a = u.now() + i;
420
- let d, m = !1, b = r(this, $);
421
- return h(this, $, U((P) => {
386
+ return (u = r(this, F)) == null || u.abort(), g(r(this, M), t), Promise.resolve();
387
+ const a = m.now() + i;
388
+ let h, l = !1, y = r(this, F);
389
+ return d(this, F, U((P) => {
422
390
  if (P < a)
423
391
  return !0;
424
- if (!m) {
425
- m = !0;
392
+ if (!l) {
393
+ l = !0;
426
394
  const A = r(this, M).v;
427
- d = f(A, t), typeof o == "function" && (o = o(A, t)), b == null || b.abort();
395
+ h = f(A, t), typeof o == "function" && (o = o(A, t)), y == null || y.abort();
428
396
  }
429
- const y = P - a;
430
- return y > /** @type {number} */
431
- o ? (g(r(this, M), t), !1) : (g(r(this, M), d(n(y / /** @type {number} */
397
+ const b = P - a;
398
+ return b > /** @type {number} */
399
+ o ? (g(r(this, M), t), !1) : (g(r(this, M), h(n(b / /** @type {number} */
432
400
  o))), !0);
433
- })), r(this, $).promise;
401
+ })), r(this, F).promise;
434
402
  }
435
403
  get current() {
436
- return S(r(this, M));
404
+ return D(r(this, M));
437
405
  }
438
406
  get target() {
439
- return S(r(this, Q));
407
+ return D(r(this, $));
440
408
  }
441
409
  set target(t) {
442
410
  this.set(t);
443
411
  }
444
412
  };
445
- M = new WeakMap(), Q = new WeakMap(), H = new WeakMap(), $ = new WeakMap();
446
- let Z = tt;
447
- const At = /* @__PURE__ */ new wt(
413
+ M = new WeakMap(), $ = new WeakMap(), H = new WeakMap(), F = new WeakMap();
414
+ let Y = x;
415
+ const pt = /* @__PURE__ */ new ct(
448
416
  "(prefers-reduced-motion: reduce)"
449
- ), St = /* @__PURE__ */ Object.freeze(/* @__PURE__ */ Object.defineProperty({
417
+ ), At = /* @__PURE__ */ Object.freeze(/* @__PURE__ */ Object.defineProperty({
450
418
  __proto__: null,
451
- Spring: Y,
452
- Tween: Z,
453
- prefersReducedMotion: At,
454
- spring: kt,
455
- tweened: Mt
419
+ Spring: X,
420
+ Tween: Y,
421
+ prefersReducedMotion: pt,
422
+ spring: mt,
423
+ tweened: lt
456
424
  }, Symbol.toStringTag, { value: "Module" }));
457
425
  export {
458
- St as i,
426
+ At as i,
459
427
  U as l,
460
- u as r
428
+ m as r
461
429
  };