sibujs 4.8.0 → 4.10.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 (66) hide show
  1. package/dist/browser.cjs +44 -6
  2. package/dist/browser.d.cts +3 -2
  3. package/dist/browser.d.ts +3 -2
  4. package/dist/browser.js +4 -4
  5. package/dist/build.cjs +128 -56
  6. package/dist/build.js +10 -10
  7. package/dist/cdn.dev.global.js +14 -14
  8. package/dist/cdn.full.dev.global.js +13 -13
  9. package/dist/cdn.full.global.js +12 -12
  10. package/dist/cdn.global.js +15 -15
  11. package/dist/{chunk-J3YQ457H.js → chunk-2NWHJ2UJ.js} +99 -61
  12. package/dist/{chunk-JUTFX2RM.js → chunk-4DCVJ4YA.js} +42 -15
  13. package/dist/{chunk-QGMSESDD.js → chunk-54F4TPHK.js} +2 -2
  14. package/dist/{chunk-KJ3UKABJ.js → chunk-5PC7OTQW.js} +1 -1
  15. package/dist/{chunk-V3LHZSU5.js → chunk-7WIHYHWD.js} +8 -1
  16. package/dist/{chunk-44MTL7ED.js → chunk-BMCR7TXG.js} +3 -3
  17. package/dist/{chunk-TQQUN4WR.js → chunk-D6HYFOWR.js} +39 -4
  18. package/dist/{chunk-VWT3VXPL.js → chunk-EVI4ZQO3.js} +2 -2
  19. package/dist/{chunk-CZPRSWSS.js → chunk-EVOK663Z.js} +1 -1
  20. package/dist/{chunk-DSID757X.js → chunk-FYUEL5IW.js} +1 -1
  21. package/dist/{chunk-UCNP3HVM.js → chunk-GMMDHJJT.js} +30 -12
  22. package/dist/{chunk-C7AA2CZX.js → chunk-GOL3FU5Q.js} +1 -1
  23. package/dist/{chunk-EGUQLBHE.js → chunk-GTS35FLA.js} +5 -4
  24. package/dist/{chunk-GSGNX35Q.js → chunk-IFRIBZ4O.js} +4 -4
  25. package/dist/{chunk-C5PEWEGH.js → chunk-IL5MMSCL.js} +19 -12
  26. package/dist/{chunk-ZVLHNEEL.js → chunk-ITEL5KPL.js} +6 -6
  27. package/dist/{chunk-RGLPEBDE.js → chunk-JCKUWWHU.js} +3 -3
  28. package/dist/{chunk-Q5J2LVKH.js → chunk-N6U4GOIU.js} +1 -1
  29. package/dist/{chunk-LI4W3U6C.js → chunk-TOPRMXFY.js} +1 -1
  30. package/dist/{chunk-4WMSTZ7J.js → chunk-VWPMWV7O.js} +4 -4
  31. package/dist/{chunk-O6TRVMJI.js → chunk-XUQUQJYE.js} +1 -1
  32. package/dist/data.cjs +67 -12
  33. package/dist/data.d.cts +32 -5
  34. package/dist/data.d.ts +32 -5
  35. package/dist/data.js +5 -5
  36. package/dist/devtools.cjs +41 -4
  37. package/dist/devtools.js +4 -4
  38. package/dist/ecosystem.cjs +41 -4
  39. package/dist/ecosystem.js +7 -7
  40. package/dist/extras.cjs +125 -41
  41. package/dist/extras.js +20 -20
  42. package/dist/index.cjs +128 -56
  43. package/dist/index.d.cts +22 -0
  44. package/dist/index.d.ts +22 -0
  45. package/dist/index.js +10 -10
  46. package/dist/motion.cjs +36 -4
  47. package/dist/motion.js +3 -3
  48. package/dist/patterns.cjs +41 -4
  49. package/dist/patterns.js +5 -5
  50. package/dist/performance.cjs +55 -14
  51. package/dist/performance.js +4 -4
  52. package/dist/plugins.cjs +176 -60
  53. package/dist/plugins.d.cts +62 -2
  54. package/dist/plugins.d.ts +62 -2
  55. package/dist/plugins.js +143 -61
  56. package/dist/ssr.cjs +77 -16
  57. package/dist/ssr.d.cts +4 -0
  58. package/dist/ssr.d.ts +4 -0
  59. package/dist/ssr.js +7 -7
  60. package/dist/testing.cjs +41 -4
  61. package/dist/testing.js +2 -2
  62. package/dist/ui.cjs +42 -5
  63. package/dist/ui.js +7 -7
  64. package/dist/widgets.cjs +36 -4
  65. package/dist/widgets.js +6 -6
  66. package/package.json +1 -1
package/dist/index.cjs CHANGED
@@ -1350,6 +1350,24 @@ function untracked(fn) {
1350
1350
  resumeTracking();
1351
1351
  }
1352
1352
  }
1353
+ var currentOwnerScope = null;
1354
+ function getOwnerScope() {
1355
+ return currentOwnerScope;
1356
+ }
1357
+ function runWithOwnerScope(scope, fn) {
1358
+ const prev = currentOwnerScope;
1359
+ currentOwnerScope = scope;
1360
+ try {
1361
+ return fn();
1362
+ } finally {
1363
+ currentOwnerScope = prev;
1364
+ }
1365
+ }
1366
+ function bindOwnerScope(fn) {
1367
+ const scope = currentOwnerScope;
1368
+ if (scope === null) return fn;
1369
+ return (...args) => runWithOwnerScope(scope, () => fn(...args));
1370
+ }
1353
1371
  var subscriberEpochCounter = 0;
1354
1372
  function retrack(effectFn, subscriber) {
1355
1373
  const prev = currentSubscriber;
@@ -1365,6 +1383,10 @@ function retrack(effectFn, subscriber) {
1365
1383
  currentSubscriber = subscriber;
1366
1384
  const sub2 = subscriber;
1367
1385
  if (sub2._cap === void 0) sub2._cap = currentDisposerCapture();
1386
+ const prevScope = currentOwnerScope;
1387
+ if (prevScope !== null && !sub2._epoch && sub2._scope === void 0) sub2._scope = prevScope;
1388
+ const scope = sub2._scope === void 0 ? null : sub2._scope;
1389
+ if (scope !== prevScope) currentOwnerScope = scope;
1368
1390
  const epoch = ++subscriberEpochCounter;
1369
1391
  sub2._epoch = epoch;
1370
1392
  sub2._structDirty = false;
@@ -1377,6 +1399,7 @@ function retrack(effectFn, subscriber) {
1377
1399
  effectFn();
1378
1400
  } finally {
1379
1401
  currentSubscriber = prev;
1402
+ currentOwnerScope = prevScope;
1380
1403
  if (savedDepth !== 0) {
1381
1404
  suspendDepth = savedDepth;
1382
1405
  suspendSavedSub = savedSuspendSub;
@@ -1411,23 +1434,26 @@ function track(effectFn, subscriber) {
1411
1434
  trackingSuspended = false;
1412
1435
  }
1413
1436
  currentSubscriber = subscriber;
1437
+ const sub2 = subscriber;
1438
+ if (sub2._scope === void 0) sub2._scope = currentOwnerScope;
1439
+ const prevScope = currentOwnerScope;
1440
+ currentOwnerScope = sub2._scope;
1414
1441
  try {
1415
1442
  effectFn();
1416
1443
  } finally {
1417
1444
  currentSubscriber = prev;
1445
+ currentOwnerScope = prevScope;
1418
1446
  if (savedDepth !== 0) {
1419
1447
  suspendDepth = savedDepth;
1420
1448
  suspendSavedSub = savedSuspendSub;
1421
1449
  trackingSuspended = true;
1422
1450
  }
1423
- const sub3 = subscriber;
1424
- for (let n = sub3.depsHead ?? null; n !== null; n = n.subNext) {
1451
+ for (let n = sub2.depsHead ?? null; n !== null; n = n.subNext) {
1425
1452
  const sig = n.sig;
1426
1453
  sig.__activeNode = n.prevActive;
1427
1454
  n.prevActive = null;
1428
1455
  }
1429
1456
  }
1430
- const sub2 = subscriber;
1431
1457
  return sub2._dispose ?? (sub2._dispose = () => cleanup(subscriber));
1432
1458
  }
1433
1459
  function reactiveBinding(commit, ownerNode) {
@@ -1697,7 +1723,7 @@ function forEachSubscriber(signal2, visit) {
1697
1723
  }
1698
1724
 
1699
1725
  // src/reactivity/track.ts
1700
- var _runtimeVersion = true ? "4.8.0" : "dev";
1726
+ var _runtimeVersion = true ? "4.10.0" : "dev";
1701
1727
  var REGISTRY_KEY = /* @__PURE__ */ Symbol.for("sibujs.reactive.v1");
1702
1728
  function resolveReactiveApi() {
1703
1729
  const g2 = globalThis;
@@ -1729,6 +1755,9 @@ function resolveReactiveApi() {
1729
1755
  getSubscriberCount,
1730
1756
  getSubscriberDeps,
1731
1757
  forEachSubscriber,
1758
+ getOwnerScope,
1759
+ runWithOwnerScope,
1760
+ bindOwnerScope,
1732
1761
  version: _runtimeVersion
1733
1762
  };
1734
1763
  g2[REGISTRY_KEY] = local;
@@ -1752,6 +1781,9 @@ var notifySubscribers2 = API.notifySubscribers;
1752
1781
  var getSubscriberCount2 = API.getSubscriberCount;
1753
1782
  var getSubscriberDeps2 = API.getSubscriberDeps;
1754
1783
  var forEachSubscriber2 = API.forEachSubscriber;
1784
+ var getOwnerScope2 = API.getOwnerScope ?? getOwnerScope;
1785
+ var runWithOwnerScope2 = API.runWithOwnerScope ?? runWithOwnerScope;
1786
+ var bindOwnerScope2 = API.bindOwnerScope ?? bindOwnerScope;
1755
1787
 
1756
1788
  // src/reactivity/bindAttribute.ts
1757
1789
  function bindAttribute(el, attr, getter) {
@@ -2425,12 +2457,16 @@ function lazy(importFn) {
2425
2457
  }
2426
2458
  const container = div({ class: "sibu-lazy" });
2427
2459
  let disposed = false;
2428
- importFn().then((mod) => {
2429
- if (disposed) return;
2430
- cached = mod.default;
2431
- const rendered = cached();
2432
- replaceChildrenSafely(container, rendered);
2433
- }).catch((err) => {
2460
+ importFn().then(
2461
+ // The component renders after the import resolves, in the owner scope
2462
+ // of whoever rendered the placeholder.
2463
+ bindOwnerScope2((mod) => {
2464
+ if (disposed) return;
2465
+ cached = mod.default;
2466
+ const rendered = cached();
2467
+ replaceChildrenSafely(container, rendered);
2468
+ })
2469
+ ).catch((err) => {
2434
2470
  if (disposed) return;
2435
2471
  const errorObj = err instanceof Error ? err : new Error(String(err));
2436
2472
  replaceChildrenSafely(
@@ -2461,7 +2497,7 @@ function Suspense({ nodes, fallback }) {
2461
2497
  }
2462
2498
  if (childEl && !container.contains(childEl)) dispose(childEl);
2463
2499
  });
2464
- queueMicrotask(() => {
2500
+ const renderContent = bindOwnerScope2(() => {
2465
2501
  if (suspenseDisposed) return;
2466
2502
  try {
2467
2503
  const el = nodes();
@@ -2489,10 +2525,14 @@ function Suspense({ nodes, fallback }) {
2489
2525
  dispatchPropagate(container, errorObj);
2490
2526
  }
2491
2527
  });
2528
+ queueMicrotask(renderContent);
2492
2529
  return container;
2493
2530
  }
2494
2531
 
2495
2532
  // src/core/rendering/lifecycle.ts
2533
+ function pinScope(scope, fn) {
2534
+ return () => getOwnerScope2() === scope ? fn() : runWithOwnerScope2(scope, fn);
2535
+ }
2496
2536
  function safeCall(cb, hookName) {
2497
2537
  try {
2498
2538
  return cb();
@@ -2502,13 +2542,14 @@ function safeCall(cb, hookName) {
2502
2542
  return void 0;
2503
2543
  }
2504
2544
  }
2505
- function runMountCallback(callback, hookName, element, isDisposed) {
2506
- const cleanup3 = safeCall(callback, hookName);
2507
- if (typeof cleanup3 !== "function") return;
2545
+ function runMountCallback(callback, hookName, element, isDisposed, scope) {
2546
+ const returned = safeCall(callback, hookName);
2547
+ if (typeof returned !== "function") return;
2548
+ const cleanup3 = pinScope(scope, returned);
2508
2549
  if (isDisposed() || !element.isConnected) {
2509
2550
  safeCall(cleanup3, "onUnmount");
2510
2551
  } else {
2511
- onUnmount(cleanup3, element);
2552
+ watchUnmount(cleanup3, element);
2512
2553
  }
2513
2554
  }
2514
2555
  var mountWatchers = /* @__PURE__ */ new WeakMap();
@@ -2668,6 +2709,8 @@ function registerUnmountWatcher(element, cb) {
2668
2709
  }
2669
2710
  function onMount(callback, element) {
2670
2711
  if (typeof document === "undefined") return;
2712
+ const scope = getOwnerScope2();
2713
+ callback = pinScope(scope, callback);
2671
2714
  if (element) {
2672
2715
  let disposed = false;
2673
2716
  const isDisposed = () => disposed;
@@ -2677,19 +2720,19 @@ function onMount(callback, element) {
2677
2720
  if (element.isConnected) {
2678
2721
  queueMicrotask(() => {
2679
2722
  if (disposed) return;
2680
- runMountCallback(callback, "onMount", element, isDisposed);
2723
+ runMountCallback(callback, "onMount", element, isDisposed, scope);
2681
2724
  });
2682
2725
  return;
2683
2726
  }
2684
2727
  queueMicrotask(() => {
2685
2728
  if (disposed) return;
2686
2729
  if (element.isConnected) {
2687
- runMountCallback(callback, "onMount", element, isDisposed);
2730
+ runMountCallback(callback, "onMount", element, isDisposed, scope);
2688
2731
  return;
2689
2732
  }
2690
2733
  const unregister = registerMountWatcher(element, () => {
2691
2734
  if (disposed) return;
2692
- runMountCallback(callback, "onMount", element, isDisposed);
2735
+ runMountCallback(callback, "onMount", element, isDisposed, scope);
2693
2736
  });
2694
2737
  registerDisposer(element, unregister);
2695
2738
  });
@@ -2701,6 +2744,9 @@ function onMount(callback, element) {
2701
2744
  }
2702
2745
  function onUnmount(callback, element) {
2703
2746
  if (typeof document === "undefined") return;
2747
+ watchUnmount(pinScope(getOwnerScope2(), callback), element);
2748
+ }
2749
+ function watchUnmount(callback, element) {
2704
2750
  let fired = false;
2705
2751
  const fireOnce = () => {
2706
2752
  if (fired) return;
@@ -2863,6 +2909,11 @@ function flushUserCleanups(ctx) {
2863
2909
  const list = ctx.userCleanups;
2864
2910
  if (list.length === 0) return;
2865
2911
  ctx.userCleanups = [];
2912
+ const scope = ctx.subscriber._scope ?? null;
2913
+ if (scope === getOwnerScope2()) runCleanups(list);
2914
+ else runWithOwnerScope2(scope, () => runCleanups(list));
2915
+ }
2916
+ function runCleanups(list) {
2866
2917
  for (let i2 = list.length - 1; i2 >= 0; i2--) {
2867
2918
  try {
2868
2919
  list[i2]();
@@ -3792,11 +3843,15 @@ function ErrorBoundary(optionsOrChildren, maybeChildren) {
3792
3843
  return;
3793
3844
  }
3794
3845
  replaceChildrenSafely(asyncContainer, el);
3795
- }).catch((e) => {
3796
- if (asyncDisposed) return;
3797
- const err = handleError(e);
3798
- replaceChildrenSafely(asyncContainer, tryRenderFallback(err));
3799
- });
3846
+ }).catch(
3847
+ // The fallback is rendered later, in the owner scope of the
3848
+ // render that produced the async child.
3849
+ bindOwnerScope2((e) => {
3850
+ if (asyncDisposed) return;
3851
+ const err = handleError(e);
3852
+ replaceChildrenSafely(asyncContainer, tryRenderFallback(err));
3853
+ })
3854
+ );
3800
3855
  return asyncContainer;
3801
3856
  }
3802
3857
  return result;
@@ -3966,37 +4021,44 @@ function action(element, action2, param2) {
3966
4021
  }
3967
4022
  }
3968
4023
  var clickOutside = (element, callback) => {
4024
+ const doc = element.ownerDocument;
3969
4025
  const handler = (e) => {
3970
- if (!element.contains(e.target)) {
3971
- callback();
3972
- }
4026
+ const target = e.target;
4027
+ if (!(typeof target?.nodeType === "number" && element.contains(target))) callback();
3973
4028
  };
3974
- document.addEventListener("pointerdown", handler, true);
3975
- return () => document.removeEventListener("pointerdown", handler, true);
4029
+ doc.addEventListener("pointerdown", handler, true);
4030
+ return () => doc.removeEventListener("pointerdown", handler, true);
3976
4031
  };
4032
+ var PRESS_END_EVENTS = ["pointerup", "pointerleave", "pointercancel"];
3977
4033
  var longPress = (element, options) => {
3978
4034
  const duration = options.duration ?? 500;
3979
4035
  let timer = null;
3980
- const start = () => {
3981
- timer = setTimeout(() => {
3982
- options.callback();
3983
- timer = null;
3984
- }, duration);
3985
- };
4036
+ let owner;
3986
4037
  const cancel = () => {
3987
4038
  if (timer !== null) {
3988
4039
  clearTimeout(timer);
3989
4040
  timer = null;
3990
4041
  }
3991
4042
  };
4043
+ const start = (e) => {
4044
+ const id = e.pointerId;
4045
+ if (timer !== null && id !== owner) return;
4046
+ cancel();
4047
+ owner = id;
4048
+ timer = setTimeout(() => {
4049
+ timer = null;
4050
+ options.callback();
4051
+ }, duration);
4052
+ };
4053
+ const end = (e) => {
4054
+ if (timer !== null && e.pointerId === owner) cancel();
4055
+ };
3992
4056
  element.addEventListener("pointerdown", start);
3993
- element.addEventListener("pointerup", cancel);
3994
- element.addEventListener("pointerleave", cancel);
4057
+ for (const type of PRESS_END_EVENTS) element.addEventListener(type, end);
3995
4058
  return () => {
3996
4059
  cancel();
3997
4060
  element.removeEventListener("pointerdown", start);
3998
- element.removeEventListener("pointerup", cancel);
3999
- element.removeEventListener("pointerleave", cancel);
4061
+ for (const type of PRESS_END_EVENTS) element.removeEventListener(type, end);
4000
4062
  };
4001
4063
  };
4002
4064
  var copyOnClick = (element, getText) => {
@@ -4030,10 +4092,11 @@ var trapFocus = (element) => {
4030
4092
  if (elements.length === 0) return;
4031
4093
  const first = elements[0];
4032
4094
  const last = elements[elements.length - 1];
4033
- if (e.shiftKey && document.activeElement === first) {
4095
+ const active = element.ownerDocument.activeElement;
4096
+ if (e.shiftKey && active === first) {
4034
4097
  e.preventDefault();
4035
4098
  last.focus();
4036
- } else if (!e.shiftKey && document.activeElement === last) {
4099
+ } else if (!e.shiftKey && active === last) {
4037
4100
  e.preventDefault();
4038
4101
  first.focus();
4039
4102
  }
@@ -4241,9 +4304,11 @@ function when(condition, thenBranch, elseBranch) {
4241
4304
  currentNode = null;
4242
4305
  });
4243
4306
  if (!initialized) {
4244
- queueMicrotask(() => {
4245
- if (!disposed && !initialized && anchor.parentNode) update();
4246
- });
4307
+ queueMicrotask(
4308
+ bindOwnerScope2(() => {
4309
+ if (!disposed && !initialized && anchor.parentNode) update();
4310
+ })
4311
+ );
4247
4312
  }
4248
4313
  return anchor;
4249
4314
  }
@@ -4282,9 +4347,11 @@ function match(value, cases, fallback) {
4282
4347
  currentNode = null;
4283
4348
  });
4284
4349
  if (!initialized) {
4285
- queueMicrotask(() => {
4286
- if (!disposed && !initialized && anchor.parentNode) update();
4287
- });
4350
+ queueMicrotask(
4351
+ bindOwnerScope2(() => {
4352
+ if (!disposed && !initialized && anchor.parentNode) update();
4353
+ })
4354
+ );
4288
4355
  }
4289
4356
  return anchor;
4290
4357
  }
@@ -4582,11 +4649,13 @@ function each(getArray, render, options) {
4582
4649
  };
4583
4650
  registerDisposer(anchor, disposeRange);
4584
4651
  if (!initialized) {
4585
- queueMicrotask(() => {
4586
- if (!initialized && !rangeDisposed && anchor.parentNode) {
4587
- update();
4588
- }
4589
- });
4652
+ queueMicrotask(
4653
+ bindOwnerScope2(() => {
4654
+ if (!initialized && !rangeDisposed && anchor.parentNode) {
4655
+ update();
4656
+ }
4657
+ })
4658
+ );
4590
4659
  }
4591
4660
  return anchor;
4592
4661
  }
@@ -5034,7 +5103,7 @@ function KeepAlive(activeKey, cases, options) {
5034
5103
  return;
5035
5104
  }
5036
5105
  node = factory();
5037
- if (node instanceof DocumentFragment) {
5106
+ if (node.nodeType === 11) {
5038
5107
  const wrapper = document.createElement("div");
5039
5108
  wrapper.style.display = "contents";
5040
5109
  wrapper.appendChild(node);
@@ -5064,9 +5133,11 @@ function KeepAlive(activeKey, cases, options) {
5064
5133
  };
5065
5134
  const untrack = track2(update);
5066
5135
  if (!initialized) {
5067
- queueMicrotask(() => {
5068
- if (!initialized && anchor.parentNode) update();
5069
- });
5136
+ queueMicrotask(
5137
+ bindOwnerScope2(() => {
5138
+ if (!initialized && anchor.parentNode) update();
5139
+ })
5140
+ );
5070
5141
  }
5071
5142
  registerDisposer(anchor, () => {
5072
5143
  disposed = true;
@@ -5171,7 +5242,7 @@ function Portal(nodes, target) {
5171
5242
  const container = target || document.body;
5172
5243
  let portalContent = null;
5173
5244
  let disposed = false;
5174
- queueMicrotask(() => {
5245
+ const renderContent = bindOwnerScope2(() => {
5175
5246
  if (disposed) return;
5176
5247
  try {
5177
5248
  portalContent = nodes();
@@ -5186,6 +5257,7 @@ function Portal(nodes, target) {
5186
5257
  });
5187
5258
  }
5188
5259
  });
5260
+ queueMicrotask(renderContent);
5189
5261
  registerDisposer(anchor, () => {
5190
5262
  disposed = true;
5191
5263
  if (portalContent) {
package/dist/index.d.cts CHANGED
@@ -289,6 +289,12 @@ interface LongPressOptions {
289
289
  /**
290
290
  * Fires a callback after a sustained press on the element.
291
291
  *
292
+ * One press at a time, owned by the pointer that started it: only that
293
+ * pointer's `pointerup`, `pointerleave` or `pointercancel` ends it, and another
294
+ * pointer going down meanwhile is ignored. The same pointer going down again
295
+ * restarts the press. Cleanup cancels a pending press, so the callback never
296
+ * fires after the action is disposed.
297
+ *
292
298
  * @example
293
299
  * ```ts
294
300
  * action(el, longPress, { duration: 800, callback: onLongPress });
@@ -2176,6 +2182,19 @@ declare function isTrackingSuspended(): boolean;
2176
2182
  * @returns Whatever `fn` returns.
2177
2183
  */
2178
2184
  declare function untracked$1<T>(fn: () => T): T;
2185
+ /** The owner scope in effect right now (`null` when there is none). @internal */
2186
+ declare function getOwnerScope(): unknown;
2187
+ /**
2188
+ * Run `fn` with `scope` as the current owner scope, restoring the previous
2189
+ * scope afterwards (even if `fn` throws). @internal
2190
+ */
2191
+ declare function runWithOwnerScope<T>(scope: unknown, fn: () => T): T;
2192
+ /**
2193
+ * Capture the current owner scope into `fn`, for work that runs later (a
2194
+ * deferred first render, a lifecycle callback). Returns `fn` itself when there
2195
+ * is no scope to carry. @internal
2196
+ */
2197
+ declare function bindOwnerScope<A extends unknown[], R>(fn: (...args: A) => R): (...args: A) => R;
2179
2198
  declare function retrack$1(effectFn: () => void, subscriber: Subscriber): void;
2180
2199
  declare function track(effectFn: () => void, subscriber?: Subscriber): () => void;
2181
2200
  declare function reactiveBinding(commit: () => void, ownerNode?: unknown): () => void;
@@ -2240,6 +2259,9 @@ interface ReactiveApi {
2240
2259
  getSubscriberCount: typeof getSubscriberCount;
2241
2260
  getSubscriberDeps: typeof getSubscriberDeps;
2242
2261
  forEachSubscriber: typeof forEachSubscriber;
2262
+ getOwnerScope?: typeof getOwnerScope;
2263
+ runWithOwnerScope?: typeof runWithOwnerScope;
2264
+ bindOwnerScope?: typeof bindOwnerScope;
2243
2265
  version: string;
2244
2266
  __dupWarned?: boolean;
2245
2267
  }
package/dist/index.d.ts CHANGED
@@ -289,6 +289,12 @@ interface LongPressOptions {
289
289
  /**
290
290
  * Fires a callback after a sustained press on the element.
291
291
  *
292
+ * One press at a time, owned by the pointer that started it: only that
293
+ * pointer's `pointerup`, `pointerleave` or `pointercancel` ends it, and another
294
+ * pointer going down meanwhile is ignored. The same pointer going down again
295
+ * restarts the press. Cleanup cancels a pending press, so the callback never
296
+ * fires after the action is disposed.
297
+ *
292
298
  * @example
293
299
  * ```ts
294
300
  * action(el, longPress, { duration: 800, callback: onLongPress });
@@ -2176,6 +2182,19 @@ declare function isTrackingSuspended(): boolean;
2176
2182
  * @returns Whatever `fn` returns.
2177
2183
  */
2178
2184
  declare function untracked$1<T>(fn: () => T): T;
2185
+ /** The owner scope in effect right now (`null` when there is none). @internal */
2186
+ declare function getOwnerScope(): unknown;
2187
+ /**
2188
+ * Run `fn` with `scope` as the current owner scope, restoring the previous
2189
+ * scope afterwards (even if `fn` throws). @internal
2190
+ */
2191
+ declare function runWithOwnerScope<T>(scope: unknown, fn: () => T): T;
2192
+ /**
2193
+ * Capture the current owner scope into `fn`, for work that runs later (a
2194
+ * deferred first render, a lifecycle callback). Returns `fn` itself when there
2195
+ * is no scope to carry. @internal
2196
+ */
2197
+ declare function bindOwnerScope<A extends unknown[], R>(fn: (...args: A) => R): (...args: A) => R;
2179
2198
  declare function retrack$1(effectFn: () => void, subscriber: Subscriber): void;
2180
2199
  declare function track(effectFn: () => void, subscriber?: Subscriber): () => void;
2181
2200
  declare function reactiveBinding(commit: () => void, ownerNode?: unknown): () => void;
@@ -2240,6 +2259,9 @@ interface ReactiveApi {
2240
2259
  getSubscriberCount: typeof getSubscriberCount;
2241
2260
  getSubscriberDeps: typeof getSubscriberDeps;
2242
2261
  forEachSubscriber: typeof forEachSubscriber;
2262
+ getOwnerScope?: typeof getOwnerScope;
2263
+ runWithOwnerScope?: typeof runWithOwnerScope;
2264
+ bindOwnerScope?: typeof bindOwnerScope;
2243
2265
  version: string;
2244
2266
  __dupWarned?: boolean;
2245
2267
  }
package/dist/index.js CHANGED
@@ -54,7 +54,7 @@ import {
54
54
  unregisterIsland,
55
55
  when,
56
56
  writable
57
- } from "./chunk-J3YQ457H.js";
57
+ } from "./chunk-2NWHJ2UJ.js";
58
58
  import {
59
59
  a,
60
60
  abbr,
@@ -192,34 +192,34 @@ import {
192
192
  use,
193
193
  var_,
194
194
  video
195
- } from "./chunk-Q5J2LVKH.js";
195
+ } from "./chunk-N6U4GOIU.js";
196
196
  import {
197
197
  trustHTML
198
198
  } from "./chunk-FC6KCJSA.js";
199
199
  import {
200
200
  watch
201
- } from "./chunk-CZPRSWSS.js";
201
+ } from "./chunk-EVOK663Z.js";
202
202
  import {
203
203
  __resetIdCounter,
204
204
  createId
205
- } from "./chunk-C7AA2CZX.js";
205
+ } from "./chunk-GOL3FU5Q.js";
206
206
  import "./chunk-62BDYGAG.js";
207
207
  import {
208
208
  SVG_NS,
209
209
  tagFactory
210
- } from "./chunk-VWT3VXPL.js";
210
+ } from "./chunk-EVI4ZQO3.js";
211
211
  import {
212
212
  bindDynamic
213
- } from "./chunk-O6TRVMJI.js";
213
+ } from "./chunk-XUQUQJYE.js";
214
214
  import "./chunk-3ACAAQIN.js";
215
215
  import {
216
216
  derived
217
- } from "./chunk-KJ3UKABJ.js";
217
+ } from "./chunk-5PC7OTQW.js";
218
218
  import "./chunk-7ZHH77QA.js";
219
219
  import {
220
220
  effect,
221
221
  on
222
- } from "./chunk-V3LHZSU5.js";
222
+ } from "./chunk-7WIHYHWD.js";
223
223
  import "./chunk-EXXSN3BW.js";
224
224
  import {
225
225
  disableSSR,
@@ -237,12 +237,12 @@ import {
237
237
  external,
238
238
  isBatching,
239
239
  signal
240
- } from "./chunk-DSID757X.js";
240
+ } from "./chunk-FYUEL5IW.js";
241
241
  import {
242
242
  retrack,
243
243
  setMaxDrainIterations,
244
244
  untracked
245
- } from "./chunk-TQQUN4WR.js";
245
+ } from "./chunk-D6HYFOWR.js";
246
246
  import {
247
247
  MAX_DRAIN_TEARDOWNS,
248
248
  checkLeaks,
package/dist/motion.cjs CHANGED
@@ -414,6 +414,24 @@ function untracked(fn) {
414
414
  resumeTracking();
415
415
  }
416
416
  }
417
+ var currentOwnerScope = null;
418
+ function getOwnerScope() {
419
+ return currentOwnerScope;
420
+ }
421
+ function runWithOwnerScope(scope, fn) {
422
+ const prev = currentOwnerScope;
423
+ currentOwnerScope = scope;
424
+ try {
425
+ return fn();
426
+ } finally {
427
+ currentOwnerScope = prev;
428
+ }
429
+ }
430
+ function bindOwnerScope(fn) {
431
+ const scope = currentOwnerScope;
432
+ if (scope === null) return fn;
433
+ return (...args) => runWithOwnerScope(scope, () => fn(...args));
434
+ }
417
435
  var subscriberEpochCounter = 0;
418
436
  function retrack(effectFn, subscriber) {
419
437
  const prev = currentSubscriber;
@@ -429,6 +447,10 @@ function retrack(effectFn, subscriber) {
429
447
  currentSubscriber = subscriber;
430
448
  const sub = subscriber;
431
449
  if (sub._cap === void 0) sub._cap = currentDisposerCapture();
450
+ const prevScope = currentOwnerScope;
451
+ if (prevScope !== null && !sub._epoch && sub._scope === void 0) sub._scope = prevScope;
452
+ const scope = sub._scope === void 0 ? null : sub._scope;
453
+ if (scope !== prevScope) currentOwnerScope = scope;
432
454
  const epoch = ++subscriberEpochCounter;
433
455
  sub._epoch = epoch;
434
456
  sub._structDirty = false;
@@ -441,6 +463,7 @@ function retrack(effectFn, subscriber) {
441
463
  effectFn();
442
464
  } finally {
443
465
  currentSubscriber = prev;
466
+ currentOwnerScope = prevScope;
444
467
  if (savedDepth !== 0) {
445
468
  suspendDepth = savedDepth;
446
469
  suspendSavedSub = savedSuspendSub;
@@ -475,23 +498,26 @@ function track(effectFn, subscriber) {
475
498
  trackingSuspended = false;
476
499
  }
477
500
  currentSubscriber = subscriber;
501
+ const sub = subscriber;
502
+ if (sub._scope === void 0) sub._scope = currentOwnerScope;
503
+ const prevScope = currentOwnerScope;
504
+ currentOwnerScope = sub._scope;
478
505
  try {
479
506
  effectFn();
480
507
  } finally {
481
508
  currentSubscriber = prev;
509
+ currentOwnerScope = prevScope;
482
510
  if (savedDepth !== 0) {
483
511
  suspendDepth = savedDepth;
484
512
  suspendSavedSub = savedSuspendSub;
485
513
  trackingSuspended = true;
486
514
  }
487
- const sub2 = subscriber;
488
- for (let n = sub2.depsHead ?? null; n !== null; n = n.subNext) {
515
+ for (let n = sub.depsHead ?? null; n !== null; n = n.subNext) {
489
516
  const sig = n.sig;
490
517
  sig.__activeNode = n.prevActive;
491
518
  n.prevActive = null;
492
519
  }
493
520
  }
494
- const sub = subscriber;
495
521
  return sub._dispose ?? (sub._dispose = () => cleanup(subscriber));
496
522
  }
497
523
  function reactiveBinding(commit, ownerNode) {
@@ -761,7 +787,7 @@ function forEachSubscriber(signal2, visit) {
761
787
  }
762
788
 
763
789
  // src/reactivity/track.ts
764
- var _runtimeVersion = true ? "4.8.0" : "dev";
790
+ var _runtimeVersion = true ? "4.10.0" : "dev";
765
791
  var REGISTRY_KEY = /* @__PURE__ */ Symbol.for("sibujs.reactive.v1");
766
792
  function resolveReactiveApi() {
767
793
  const g = globalThis;
@@ -793,6 +819,9 @@ function resolveReactiveApi() {
793
819
  getSubscriberCount,
794
820
  getSubscriberDeps,
795
821
  forEachSubscriber,
822
+ getOwnerScope,
823
+ runWithOwnerScope,
824
+ bindOwnerScope,
796
825
  version: _runtimeVersion
797
826
  };
798
827
  g[REGISTRY_KEY] = local;
@@ -816,6 +845,9 @@ var notifySubscribers2 = API.notifySubscribers;
816
845
  var getSubscriberCount2 = API.getSubscriberCount;
817
846
  var getSubscriberDeps2 = API.getSubscriberDeps;
818
847
  var forEachSubscriber2 = API.forEachSubscriber;
848
+ var getOwnerScope2 = API.getOwnerScope ?? getOwnerScope;
849
+ var runWithOwnerScope2 = API.runWithOwnerScope ?? runWithOwnerScope;
850
+ var bindOwnerScope2 = API.bindOwnerScope ?? bindOwnerScope;
819
851
 
820
852
  // src/reactivity/batch.ts
821
853
  var batchDepth = 0;
package/dist/motion.js CHANGED
@@ -20,10 +20,10 @@ import {
20
20
  stagger,
21
21
  transition,
22
22
  viewTransition
23
- } from "./chunk-LI4W3U6C.js";
23
+ } from "./chunk-TOPRMXFY.js";
24
24
  import "./chunk-5HZXGZ6T.js";
25
- import "./chunk-DSID757X.js";
26
- import "./chunk-TQQUN4WR.js";
25
+ import "./chunk-FYUEL5IW.js";
26
+ import "./chunk-D6HYFOWR.js";
27
27
  import "./chunk-NYNYSPK7.js";
28
28
  export {
29
29
  TransitionGroup,