virtua 0.49.0 → 0.49.2

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/lib/core/index.js CHANGED
@@ -1,10 +1,10 @@
1
- const e = null, {min: t, max: o, abs: r, floor: s} = Math, n = (e, r, s) => t(s, o(r, e)), i = e => [ ...e ].sort(((e, t) => e - t)), c = "function" == typeof queueMicrotask ? queueMicrotask : e => {
1
+ const e = null, {min: t, max: o, abs: r, floor: s} = Math, n = (e, r, s) => t(s, o(r, e)), i = e => [ ...e ].sort((e, t) => e - t), c = "function" == typeof queueMicrotask ? queueMicrotask : e => {
2
2
  Promise.resolve().then(e);
3
3
  }, l = () => {
4
4
  let e;
5
- return [ new Promise((t => {
5
+ return [ new Promise(t => {
6
6
  e = t;
7
- })), e ];
7
+ }), e ];
8
8
  }, f = e => {
9
9
  let t;
10
10
  return () => (e && (t = e(), e = void 0), t);
@@ -35,8 +35,8 @@ const e = null, {min: t, max: o, abs: r, floor: s} = Math, n = (e, r, s) => t(s,
35
35
  }, h = (e, o, r) => {
36
36
  const s = o - e.l;
37
37
  return e.i = r ? -1 : t(o - 1, e.i), e.l = o, s > 0 ? (a(e.u, s), a(e.t, s, r),
38
- e.o * s) : (e.u.splice(s), (r ? e.t.splice(0, -s) : e.t.splice(s)).reduce(((t, o) => t - (-1 === o ? e.o : o)), 0));
39
- }, g = "undefined" != typeof window, m = e => e.documentElement, v = e => e.ownerDocument, b = e => e.defaultView, w = /*#__PURE__*/ f((() => !!/iP(hone|od|ad)/.test(navigator.userAgent) || "MacIntel" === navigator.platform && navigator.maxTouchPoints > 0)), S = /*#__PURE__*/ f((() => "scrollBehavior" in m(document).style)), k = 5, I = 6, y = 1, x = 4, _ = 8, z = e => o(e.$getTotalSize(), e.$getViewportSize()), T = (s, n = 40, c = 0, l, f = !1) => {
38
+ e.o * s) : (e.u.splice(s), (r ? e.t.splice(0, -s) : e.t.splice(s)).reduce((t, o) => t - (-1 === o ? e.o : o), 0));
39
+ }, g = "undefined" != typeof window, m = e => e.documentElement, v = e => e.ownerDocument, b = e => e.defaultView, w = /*#__PURE__*/ f(() => !!/iP(hone|od|ad)/.test(navigator.userAgent) || "MacIntel" === navigator.platform && navigator.maxTouchPoints > 0), S = /*#__PURE__*/ f(() => "scrollBehavior" in m(document).style), k = 5, I = 6, y = 1, x = 4, _ = 8, z = e => o(e.$getTotalSize(), e.$getViewportSize()), T = (s, n = 40, c = 0, l, f = !1) => {
40
40
  let g = !!c, m = 1, v = 0, b = 0, S = 0, k = 0, I = 0, y = 0, x = 0, _ = 0, z = e, T = [ 0, g ? o(c - 1, 0) : -1 ], M = 0, R = !1;
41
41
  const J = ((e, r, s) => ({
42
42
  o: r,
@@ -113,16 +113,16 @@ const e = null, {min: t, max: o, abs: r, floor: s} = Math, n = (e, r, s) => t(s,
113
113
 
114
114
  case 3:
115
115
  {
116
- const e = s.filter((([e, t]) => !q(e, t)));
116
+ const e = s.filter(([e, t]) => !q(e, t));
117
117
  if (!e.length) break;
118
- V(e.reduce(((e, [t, o]) => {
118
+ V(e.reduce((e, [t, o]) => {
119
119
  let r;
120
120
  if (2 === _) r = !0; else if (z && 1 === _) r = t < z[0]; else {
121
121
  const e = W(), o = O(t), s = P(t);
122
- r = 1 !== x && 0 === _ ? o + s < e : o < e && o + s < e + v;
122
+ r = 1 !== x && 0 === _ ? o + s <= e : o < e && o + s < e + v;
123
123
  }
124
124
  return r && (e += o - P(t)), e;
125
- }), 0));
125
+ }, 0));
126
126
  for (const [t, o] of e) {
127
127
  const e = P(t), r = $(J, t, o);
128
128
  f && (M += r ? o : o - e);
@@ -130,9 +130,9 @@ const e = null, {min: t, max: o, abs: r, floor: s} = Math, n = (e, r, s) => t(s,
130
130
  f && v && M > v && (V(((e, t) => {
131
131
  let r = 0;
132
132
  const s = [];
133
- e.t.forEach(((e, o) => {
133
+ e.t.forEach((e, o) => {
134
134
  -1 !== e && (s.push(e), o < t && r++);
135
- })), e.i = -1;
135
+ }), e.i = -1;
136
136
  const n = i(s), c = n.length, l = c / 2 | 0, f = c % 2 == 0 ? (n[l - 1] + n[l]) / 2 : n[l], a = e.o;
137
137
  return ((e.o = f) - a) * o(t - r, 0);
138
138
  })(J, p(J, B()))), f = !1), l = 3, c = !0;
@@ -158,9 +158,9 @@ const e = null, {min: t, max: o, abs: r, floor: s} = Math, n = (e, r, s) => t(s,
158
158
  case 8:
159
159
  z = L(s, s + v), l = 1;
160
160
  }
161
- l && (m = 1 + (2147483647 & m), n && I && (k += I, I = 0), C.forEach((([e, t]) => {
161
+ l && (m = 1 + (2147483647 & m), n && I && (k += I, I = 0), C.forEach(([e, t]) => {
162
162
  l & e && t(c);
163
- })));
163
+ }));
164
164
  }
165
165
  };
166
166
  }, M = setTimeout, R = (e, t) => t ? -e : e, J = (t, o, r, s, n, i) => {
@@ -171,12 +171,12 @@ const e = null, {min: t, max: o, abs: r, floor: s} = Math, n = (e, r, s) => t(s,
171
171
  const r = () => {
172
172
  o != e && clearTimeout(o);
173
173
  }, s = () => {
174
- r(), o = M((() => {
174
+ r(), o = M(() => {
175
175
  o = e, (() => {
176
176
  if (f || a) return f = !1, void d();
177
177
  u = !1, t.$update(2);
178
178
  })();
179
- }), 150);
179
+ }, 150);
180
180
  };
181
181
  return s.p = r, s;
182
182
  })(), p = () => {
@@ -215,11 +215,11 @@ const e = null, {min: t, max: o, abs: r, floor: s} = Math, n = (e, r, s) => t(s,
215
215
  const [t, o] = l();
216
216
  return r = () => {
217
217
  o(!1);
218
- }, e.$getViewportSize() && M(r, 150), [ t, e.$subscribe(2, (() => {
218
+ }, e.$getViewportSize() && M(r, 150), [ t, e.$subscribe(2, () => {
219
219
  o(!0);
220
- })) ];
220
+ }) ];
221
221
  };
222
- if (n && S()) e.$update(8, s()), c((async () => {
222
+ if (n && S()) e.$update(8, s()), c(async () => {
223
223
  for (;;) {
224
224
  let t = !0;
225
225
  for (let [o, r] = e.$getRange(); o <= r; o++) if (e.$isUnmeasuredItem(o)) {
@@ -235,7 +235,7 @@ const e = null, {min: t, max: o, abs: r, floor: s} = Math, n = (e, r, s) => t(s,
235
235
  }
236
236
  }
237
237
  e.$update(7), o(s(), n);
238
- })); else for (;;) {
238
+ }); else for (;;) {
239
239
  const [t, r] = i();
240
240
  try {
241
241
  if (e.$update(7), o(s()), !await t) return;
@@ -248,33 +248,33 @@ const e = null, {min: t, max: o, abs: r, floor: s} = Math, n = (e, r, s) => t(s,
248
248
  } ];
249
249
  }, W = (e, t) => {
250
250
  let o, r, s = l(), i = !1;
251
- const c = t ? "scrollLeft" : "scrollTop", f = t ? "overflowX" : "overflowY", [a, u] = C(e, (() => s[0]), ((e, r) => {
251
+ const c = t ? "scrollLeft" : "scrollTop", f = t ? "overflowX" : "overflowY", [a, u] = C(e, () => s[0], (e, r) => {
252
252
  e = R(e, i), r ? o.scrollTo({
253
253
  [t ? "left" : "top"]: e,
254
254
  behavior: "smooth"
255
255
  }) : o[c] = e;
256
- }));
256
+ });
257
257
  return {
258
258
  $observe(n, l) {
259
- o = l, t && (i = "rtl" === getComputedStyle(l).direction), r = J(e, l, t, (() => R(l[c], i)), ((t, o, r) => {
259
+ o = l, t && (i = "rtl" === getComputedStyle(l).direction), r = J(e, l, t, () => R(l[c], i), (t, o, r) => {
260
260
  if (r) {
261
261
  const e = l.style, t = e[f];
262
- e[f] = "hidden", M((() => {
262
+ e[f] = "hidden", M(() => {
263
263
  e[f] = t;
264
- }));
264
+ });
265
265
  }
266
266
  l[c] = R(e.$getScrollOffset() + t, i), o && u();
267
- })), s[1](!0);
267
+ }), s[1](!0);
268
268
  },
269
269
  $dispose() {
270
270
  r && r.h(), s[1](!1), s = l();
271
271
  },
272
272
  $isNegative: () => i,
273
273
  $scrollTo(e) {
274
- a((() => e));
274
+ a(() => e);
275
275
  },
276
276
  $scrollBy(t) {
277
- t += e.$getScrollOffset(), a((() => t));
277
+ t += e.$getScrollOffset(), a(() => t);
278
278
  },
279
279
  $scrollToIndex(t, {align: o, smooth: r, offset: s = 0} = {}) {
280
280
  if (t = n(t, 0, e.$getItemsLength() - 1), "nearest" === o) {
@@ -284,7 +284,7 @@ const e = null, {min: t, max: o, abs: r, floor: s} = Math, n = (e, r, s) => t(s,
284
284
  o = "end";
285
285
  }
286
286
  }
287
- a((() => s + e.$getStartSpacerSize() + e.$getItemOffset(t) + ("end" === o ? e.$getItemSize(t) - e.$getViewportSize() : "center" === o ? (e.$getItemSize(t) - e.$getViewportSize()) / 2 : 0)), r);
287
+ a(() => s + e.$getStartSpacerSize() + e.$getItemOffset(t) + ("end" === o ? e.$getItemSize(t) - e.$getViewportSize() : "center" === o ? (e.$getItemSize(t) - e.$getViewportSize()) / 2 : 0), r);
288
288
  },
289
289
  $fixScrollJump: () => {
290
290
  r && r.m();
@@ -292,7 +292,7 @@ const e = null, {min: t, max: o, abs: r, floor: s} = Math, n = (e, r, s) => t(s,
292
292
  };
293
293
  }, B = (e, t) => {
294
294
  let o, r, s = l(), i = !1;
295
- const c = t ? "left" : "top", [f] = C(e, (() => s[0]), ((e, t) => {
295
+ const c = t ? "left" : "top", [f] = C(e, () => s[0], (e, t) => {
296
296
  e = R(e, i);
297
297
  const r = b(v(o));
298
298
  t ? r.scroll({
@@ -301,7 +301,7 @@ const e = null, {min: t, max: o, abs: r, floor: s} = Math, n = (e, r, s) => t(s,
301
301
  }) : r.scroll({
302
302
  [c]: e
303
303
  });
304
- })), a = (e, t, o, r, s = 0) => {
304
+ }), a = (e, t, o, r, s = 0) => {
305
305
  const n = r ? "offsetLeft" : "offsetTop", c = s + (r && i ? o.innerWidth - e[n] - e.offsetWidth : e[n]), l = e.offsetParent;
306
306
  return e !== t && l ? a(l, t, o, r, c) : c;
307
307
  };
@@ -309,13 +309,13 @@ const e = null, {min: t, max: o, abs: r, floor: s} = Math, n = (e, r, s) => t(s,
309
309
  $observe(n) {
310
310
  o = n;
311
311
  const l = t ? "scrollX" : "scrollY", f = v(n), u = b(f);
312
- t && (i = "rtl" === getComputedStyle(m(f)).direction), r = J(e, u, t, (() => R(u[l], i)), ((t, o) => {
312
+ t && (i = "rtl" === getComputedStyle(m(f)).direction), r = J(e, u, t, () => R(u[l], i), (t, o) => {
313
313
  o ? u.scroll({
314
314
  [c]: R(e.$getScrollOffset() + t, i)
315
315
  }) : u.scrollBy({
316
316
  [c]: R(t, i)
317
317
  });
318
- }), (() => a(n, f.body, u, t))), s[1](!0);
318
+ }, () => a(n, f.body, u, t)), s[1](!0);
319
319
  },
320
320
  $dispose() {
321
321
  r && r.h(), o = void 0, s[1](!1), s = l();
@@ -334,7 +334,7 @@ const e = null, {min: t, max: o, abs: r, floor: s} = Math, n = (e, r, s) => t(s,
334
334
  }
335
335
  }
336
336
  const l = v(o), u = b(l), $ = m(l), d = () => e.$getViewportSize() - (t ? $.clientWidth : $.clientHeight);
337
- f((() => c + a(o, l.body, u, t) + e.$getItemOffset(r) + ("end" === s ? e.$getItemSize(r) - (e.$getViewportSize() - d()) : "center" === s ? (e.$getItemSize(r) - (e.$getViewportSize() - d())) / 2 : 0)), i);
337
+ f(() => c + a(o, l.body, u, t) + e.$getItemOffset(r) + ("end" === s ? e.$getItemSize(r) - (e.$getViewportSize() - d()) : "center" === s ? (e.$getItemSize(r) - (e.$getViewportSize() - d())) / 2 : 0), i);
338
338
  }
339
339
  };
340
340
  }, L = (e, t) => {
@@ -375,14 +375,14 @@ const e = null, {min: t, max: o, abs: r, floor: s} = Math, n = (e, r, s) => t(s,
375
375
  };
376
376
  }, O = (t, o) => {
377
377
  let r;
378
- const s = o ? "width" : "height", n = new WeakMap, i = N((o => {
378
+ const s = o ? "width" : "height", n = new WeakMap, i = N(o => {
379
379
  const i = [];
380
380
  for (const {target: c, contentRect: l} of o) if (c.offsetParent) if (c === r) t.$update(4, l[s]); else {
381
381
  const t = n.get(c);
382
382
  t != e && i.push([ t, l[s] ]);
383
383
  }
384
384
  i.length && t.$update(3, i);
385
- }));
385
+ });
386
386
  return {
387
387
  $observeRoot(e) {
388
388
  i.v(r = e);
@@ -393,7 +393,7 @@ const e = null, {min: t, max: o, abs: r, floor: s} = Math, n = (e, r, s) => t(s,
393
393
  $dispose: i.h
394
394
  };
395
395
  }, P = (t, o) => {
396
- const r = o ? "width" : "height", s = o ? "innerWidth" : "innerHeight", n = new WeakMap, i = N((o => {
396
+ const r = o ? "width" : "height", s = o ? "innerWidth" : "innerHeight", n = new WeakMap, i = N(o => {
397
397
  const s = [];
398
398
  for (const {target: t, contentRect: i} of o) {
399
399
  if (!t.offsetParent) continue;
@@ -401,7 +401,7 @@ const e = null, {min: t, max: o, abs: r, floor: s} = Math, n = (e, r, s) => t(s,
401
401
  o != e && s.push([ o, i[r] ]);
402
402
  }
403
403
  s.length && t.$update(3, s);
404
- }));
404
+ });
405
405
  let l;
406
406
  return {
407
407
  $observeRoot(e) {
@@ -421,7 +421,7 @@ const e = null, {min: t, max: o, abs: r, floor: s} = Math, n = (e, r, s) => t(s,
421
421
  };
422
422
  }, q = (e, t) => {
423
423
  let r;
424
- const s = new WeakMap, n = new Set, i = new Set, c = new Map, l = (e, t) => `${e}-${t}`, f = N((f => {
424
+ const s = new WeakMap, n = new Set, i = new Set, c = new Map, l = (e, t) => `${e}-${t}`, f = N(f => {
425
425
  const a = new Set, u = new Set;
426
426
  for (const {target: o, contentRect: {width: n, height: i}} of f) if (o.offsetParent) if (o === r) e.$update(4, i),
427
427
  t.$update(4, n); else {
@@ -435,25 +435,25 @@ const e = null, {min: t, max: o, abs: r, floor: s} = Math, n = (e, r, s) => t(s,
435
435
  }
436
436
  if (a.size) {
437
437
  const t = [];
438
- a.forEach((e => {
438
+ a.forEach(e => {
439
439
  let r = 0;
440
- i.forEach((t => {
440
+ i.forEach(t => {
441
441
  const s = c.get(l(e, t));
442
442
  s && (r = o(r, s[0]));
443
- })), r && t.push([ e, r ]);
444
- })), e.$update(3, t);
443
+ }), r && t.push([ e, r ]);
444
+ }), e.$update(3, t);
445
445
  }
446
446
  if (u.size) {
447
447
  const e = [];
448
- u.forEach((t => {
448
+ u.forEach(t => {
449
449
  let r = 0;
450
- n.forEach((e => {
450
+ n.forEach(e => {
451
451
  const s = c.get(l(e, t));
452
452
  s && (r = o(r, s[1]));
453
- })), r && e.push([ t, r ]);
454
- })), t.$update(3, e);
453
+ }), r && e.push([ t, r ]);
454
+ }), t.$update(3, e);
455
455
  }
456
- }));
456
+ });
457
457
  return {
458
458
  $observeRoot(e) {
459
459
  f.v(r = e);