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/ssr.cjs CHANGED
@@ -1650,6 +1650,24 @@ function untracked(fn) {
1650
1650
  resumeTracking();
1651
1651
  }
1652
1652
  }
1653
+ var currentOwnerScope = null;
1654
+ function getOwnerScope() {
1655
+ return currentOwnerScope;
1656
+ }
1657
+ function runWithOwnerScope(scope, fn) {
1658
+ const prev = currentOwnerScope;
1659
+ currentOwnerScope = scope;
1660
+ try {
1661
+ return fn();
1662
+ } finally {
1663
+ currentOwnerScope = prev;
1664
+ }
1665
+ }
1666
+ function bindOwnerScope(fn) {
1667
+ const scope = currentOwnerScope;
1668
+ if (scope === null) return fn;
1669
+ return (...args) => runWithOwnerScope(scope, () => fn(...args));
1670
+ }
1653
1671
  var subscriberEpochCounter = 0;
1654
1672
  function retrack(effectFn, subscriber) {
1655
1673
  const prev = currentSubscriber;
@@ -1665,6 +1683,10 @@ function retrack(effectFn, subscriber) {
1665
1683
  currentSubscriber = subscriber;
1666
1684
  const sub2 = subscriber;
1667
1685
  if (sub2._cap === void 0) sub2._cap = currentDisposerCapture();
1686
+ const prevScope = currentOwnerScope;
1687
+ if (prevScope !== null && !sub2._epoch && sub2._scope === void 0) sub2._scope = prevScope;
1688
+ const scope = sub2._scope === void 0 ? null : sub2._scope;
1689
+ if (scope !== prevScope) currentOwnerScope = scope;
1668
1690
  const epoch = ++subscriberEpochCounter;
1669
1691
  sub2._epoch = epoch;
1670
1692
  sub2._structDirty = false;
@@ -1677,6 +1699,7 @@ function retrack(effectFn, subscriber) {
1677
1699
  effectFn();
1678
1700
  } finally {
1679
1701
  currentSubscriber = prev;
1702
+ currentOwnerScope = prevScope;
1680
1703
  if (savedDepth !== 0) {
1681
1704
  suspendDepth = savedDepth;
1682
1705
  suspendSavedSub = savedSuspendSub;
@@ -1711,23 +1734,26 @@ function track(effectFn, subscriber) {
1711
1734
  trackingSuspended = false;
1712
1735
  }
1713
1736
  currentSubscriber = subscriber;
1737
+ const sub2 = subscriber;
1738
+ if (sub2._scope === void 0) sub2._scope = currentOwnerScope;
1739
+ const prevScope = currentOwnerScope;
1740
+ currentOwnerScope = sub2._scope;
1714
1741
  try {
1715
1742
  effectFn();
1716
1743
  } finally {
1717
1744
  currentSubscriber = prev;
1745
+ currentOwnerScope = prevScope;
1718
1746
  if (savedDepth !== 0) {
1719
1747
  suspendDepth = savedDepth;
1720
1748
  suspendSavedSub = savedSuspendSub;
1721
1749
  trackingSuspended = true;
1722
1750
  }
1723
- const sub3 = subscriber;
1724
- for (let n = sub3.depsHead ?? null; n !== null; n = n.subNext) {
1751
+ for (let n = sub2.depsHead ?? null; n !== null; n = n.subNext) {
1725
1752
  const sig = n.sig;
1726
1753
  sig.__activeNode = n.prevActive;
1727
1754
  n.prevActive = null;
1728
1755
  }
1729
1756
  }
1730
- const sub2 = subscriber;
1731
1757
  return sub2._dispose ?? (sub2._dispose = () => cleanup(subscriber));
1732
1758
  }
1733
1759
  function reactiveBinding(commit, ownerNode) {
@@ -1997,7 +2023,7 @@ function forEachSubscriber(signal2, visit) {
1997
2023
  }
1998
2024
 
1999
2025
  // src/reactivity/track.ts
2000
- var _runtimeVersion = true ? "4.8.0" : "dev";
2026
+ var _runtimeVersion = true ? "4.10.0" : "dev";
2001
2027
  var REGISTRY_KEY = /* @__PURE__ */ Symbol.for("sibujs.reactive.v1");
2002
2028
  function resolveReactiveApi() {
2003
2029
  const g2 = globalThis;
@@ -2029,6 +2055,9 @@ function resolveReactiveApi() {
2029
2055
  getSubscriberCount,
2030
2056
  getSubscriberDeps,
2031
2057
  forEachSubscriber,
2058
+ getOwnerScope,
2059
+ runWithOwnerScope,
2060
+ bindOwnerScope,
2032
2061
  version: _runtimeVersion
2033
2062
  };
2034
2063
  g2[REGISTRY_KEY] = local;
@@ -2052,6 +2081,9 @@ var notifySubscribers2 = API.notifySubscribers;
2052
2081
  var getSubscriberCount2 = API.getSubscriberCount;
2053
2082
  var getSubscriberDeps2 = API.getSubscriberDeps;
2054
2083
  var forEachSubscriber2 = API.forEachSubscriber;
2084
+ var getOwnerScope2 = API.getOwnerScope ?? getOwnerScope;
2085
+ var runWithOwnerScope2 = API.runWithOwnerScope ?? runWithOwnerScope;
2086
+ var bindOwnerScope2 = API.bindOwnerScope ?? bindOwnerScope;
2055
2087
 
2056
2088
  // src/core/devtoolsHook.ts
2057
2089
  function emitDevtools(hook, event, payload) {
@@ -2068,6 +2100,11 @@ function flushUserCleanups(ctx) {
2068
2100
  const list = ctx.userCleanups;
2069
2101
  if (list.length === 0) return;
2070
2102
  ctx.userCleanups = [];
2103
+ const scope = ctx.subscriber._scope ?? null;
2104
+ if (scope === getOwnerScope2()) runCleanups(list);
2105
+ else runWithOwnerScope2(scope, () => runCleanups(list));
2106
+ }
2107
+ function runCleanups(list) {
2071
2108
  for (let i2 = list.length - 1; i2 >= 0; i2--) {
2072
2109
  try {
2073
2110
  list[i2]();
@@ -2601,7 +2638,7 @@ function createISR(options) {
2601
2638
  const [data2, setData] = signal(initialData);
2602
2639
  const [stale, setStale] = signal(initialData === void 0);
2603
2640
  const controller = new AbortController();
2604
- let inFlight = false;
2641
+ let inFlight = null;
2605
2642
  let disposed = false;
2606
2643
  let deadline;
2607
2644
  const clearDeadline = () => {
@@ -2621,10 +2658,7 @@ function createISR(options) {
2621
2658
  });
2622
2659
  }, revalidateAfter);
2623
2660
  };
2624
- const revalidate = async () => {
2625
- if (disposed || inFlight) return;
2626
- if (controller.signal.aborted) return;
2627
- inFlight = true;
2661
+ const run = async () => {
2628
2662
  try {
2629
2663
  const result = await fetcher({ signal: controller.signal });
2630
2664
  if (disposed || controller.signal.aborted) return;
@@ -2636,10 +2670,33 @@ function createISR(options) {
2636
2670
  } catch (err) {
2637
2671
  if (!disposed && !controller.signal.aborted) armDeadline();
2638
2672
  throw err;
2639
- } finally {
2640
- inFlight = false;
2641
2673
  }
2642
2674
  };
2675
+ const revalidate = () => {
2676
+ if (disposed || controller.signal.aborted) return Promise.resolve();
2677
+ if (inFlight) return inFlight;
2678
+ let resolve;
2679
+ let reject;
2680
+ const current = new Promise((res, rej) => {
2681
+ resolve = res;
2682
+ reject = rej;
2683
+ });
2684
+ inFlight = current;
2685
+ const release = () => {
2686
+ if (inFlight === current) inFlight = null;
2687
+ };
2688
+ run().then(
2689
+ () => {
2690
+ release();
2691
+ resolve();
2692
+ },
2693
+ (err) => {
2694
+ release();
2695
+ reject(err);
2696
+ }
2697
+ );
2698
+ return current;
2699
+ };
2643
2700
  if (initialData === void 0) {
2644
2701
  revalidate().catch((err) => {
2645
2702
  if (typeof console !== "undefined") console.warn("[SibuJS ISR] initial fetch failed", err);
@@ -3603,11 +3660,15 @@ function defineRemoteComponent(name, loader) {
3603
3660
  registerDisposer(container, () => {
3604
3661
  disposed = true;
3605
3662
  });
3606
- loader().then((mod) => {
3607
- cached = mod.default;
3608
- if (disposed) return;
3609
- replaceChildrenSafely(container, cached());
3610
- }).catch((err) => {
3663
+ loader().then(
3664
+ // Instantiated after the module resolves, in the owner scope of the
3665
+ // render that asked for it — as `lazy()` does.
3666
+ bindOwnerScope2((mod) => {
3667
+ cached = mod.default;
3668
+ if (disposed) return;
3669
+ replaceChildrenSafely(container, cached());
3670
+ })
3671
+ ).catch((err) => {
3611
3672
  if (disposed) return;
3612
3673
  const message = err instanceof Error ? err.message : String(err);
3613
3674
  replaceChildrenSafely(
package/dist/ssr.d.cts CHANGED
@@ -539,6 +539,10 @@ interface ISROptions<T> {
539
539
  * `true` while a revalidation is pending or after one fails, and returns to
540
540
  * `false` when a revalidation succeeds.
541
541
  *
542
+ * `revalidate()` called while a revalidation is running joins it instead of
543
+ * starting another: the fetcher runs once, and every caller's promise settles
544
+ * — resolving, or rejecting with the same error — when that fetch does.
545
+ *
542
546
  * @throws RangeError when `revalidateAfter` is not a positive finite number.
543
547
  */
544
548
  declare function createISR<T>(options: ISROptions<T>): {
package/dist/ssr.d.ts CHANGED
@@ -539,6 +539,10 @@ interface ISROptions<T> {
539
539
  * `true` while a revalidation is pending or after one fails, and returns to
540
540
  * `false` when a revalidation succeeds.
541
541
  *
542
+ * `revalidate()` called while a revalidation is running joins it instead of
543
+ * starting another: the fetcher runs once, and every caller's promise settles
544
+ * — resolving, or rejecting with the same error — when that fetch does.
545
+ *
542
546
  * @throws RangeError when `revalidateAfter` is not a positive finite number.
543
547
  */
544
548
  declare function createISR<T>(options: ISROptions<T>): {
package/dist/ssr.js CHANGED
@@ -23,9 +23,9 @@ import {
23
23
  wasm,
24
24
  worker,
25
25
  workerFn
26
- } from "./chunk-JUTFX2RM.js";
26
+ } from "./chunk-4DCVJ4YA.js";
27
27
  import "./chunk-52XFPGSN.js";
28
- import "./chunk-Q5J2LVKH.js";
28
+ import "./chunk-N6U4GOIU.js";
29
29
  import {
30
30
  collectStream,
31
31
  deserializeState,
@@ -47,15 +47,15 @@ import {
47
47
  trustHTML
48
48
  } from "./chunk-FC6KCJSA.js";
49
49
  import "./chunk-62BDYGAG.js";
50
- import "./chunk-VWT3VXPL.js";
51
- import "./chunk-O6TRVMJI.js";
50
+ import "./chunk-EVI4ZQO3.js";
51
+ import "./chunk-XUQUQJYE.js";
52
52
  import "./chunk-3ACAAQIN.js";
53
53
  import "./chunk-7ZHH77QA.js";
54
- import "./chunk-V3LHZSU5.js";
54
+ import "./chunk-7WIHYHWD.js";
55
55
  import "./chunk-EXXSN3BW.js";
56
56
  import "./chunk-7XHATCIH.js";
57
- import "./chunk-DSID757X.js";
58
- import "./chunk-TQQUN4WR.js";
57
+ import "./chunk-FYUEL5IW.js";
58
+ import "./chunk-D6HYFOWR.js";
59
59
  import "./chunk-NYNYSPK7.js";
60
60
  export {
61
61
  Head,
package/dist/testing.cjs CHANGED
@@ -407,6 +407,24 @@ function untracked(fn) {
407
407
  resumeTracking();
408
408
  }
409
409
  }
410
+ var currentOwnerScope = null;
411
+ function getOwnerScope() {
412
+ return currentOwnerScope;
413
+ }
414
+ function runWithOwnerScope(scope, fn) {
415
+ const prev = currentOwnerScope;
416
+ currentOwnerScope = scope;
417
+ try {
418
+ return fn();
419
+ } finally {
420
+ currentOwnerScope = prev;
421
+ }
422
+ }
423
+ function bindOwnerScope(fn) {
424
+ const scope = currentOwnerScope;
425
+ if (scope === null) return fn;
426
+ return (...args) => runWithOwnerScope(scope, () => fn(...args));
427
+ }
410
428
  var subscriberEpochCounter = 0;
411
429
  function retrack(effectFn, subscriber) {
412
430
  const prev = currentSubscriber;
@@ -422,6 +440,10 @@ function retrack(effectFn, subscriber) {
422
440
  currentSubscriber = subscriber;
423
441
  const sub = subscriber;
424
442
  if (sub._cap === void 0) sub._cap = currentDisposerCapture();
443
+ const prevScope = currentOwnerScope;
444
+ if (prevScope !== null && !sub._epoch && sub._scope === void 0) sub._scope = prevScope;
445
+ const scope = sub._scope === void 0 ? null : sub._scope;
446
+ if (scope !== prevScope) currentOwnerScope = scope;
425
447
  const epoch = ++subscriberEpochCounter;
426
448
  sub._epoch = epoch;
427
449
  sub._structDirty = false;
@@ -434,6 +456,7 @@ function retrack(effectFn, subscriber) {
434
456
  effectFn();
435
457
  } finally {
436
458
  currentSubscriber = prev;
459
+ currentOwnerScope = prevScope;
437
460
  if (savedDepth !== 0) {
438
461
  suspendDepth = savedDepth;
439
462
  suspendSavedSub = savedSuspendSub;
@@ -468,23 +491,26 @@ function track(effectFn, subscriber) {
468
491
  trackingSuspended = false;
469
492
  }
470
493
  currentSubscriber = subscriber;
494
+ const sub = subscriber;
495
+ if (sub._scope === void 0) sub._scope = currentOwnerScope;
496
+ const prevScope = currentOwnerScope;
497
+ currentOwnerScope = sub._scope;
471
498
  try {
472
499
  effectFn();
473
500
  } finally {
474
501
  currentSubscriber = prev;
502
+ currentOwnerScope = prevScope;
475
503
  if (savedDepth !== 0) {
476
504
  suspendDepth = savedDepth;
477
505
  suspendSavedSub = savedSuspendSub;
478
506
  trackingSuspended = true;
479
507
  }
480
- const sub2 = subscriber;
481
- for (let n = sub2.depsHead ?? null; n !== null; n = n.subNext) {
508
+ for (let n = sub.depsHead ?? null; n !== null; n = n.subNext) {
482
509
  const sig = n.sig;
483
510
  sig.__activeNode = n.prevActive;
484
511
  n.prevActive = null;
485
512
  }
486
513
  }
487
- const sub = subscriber;
488
514
  return sub._dispose ?? (sub._dispose = () => cleanup(subscriber));
489
515
  }
490
516
  function reactiveBinding(commit, ownerNode) {
@@ -754,7 +780,7 @@ function forEachSubscriber(signal, visit) {
754
780
  }
755
781
 
756
782
  // src/reactivity/track.ts
757
- var _runtimeVersion = true ? "4.8.0" : "dev";
783
+ var _runtimeVersion = true ? "4.10.0" : "dev";
758
784
  var REGISTRY_KEY = /* @__PURE__ */ Symbol.for("sibujs.reactive.v1");
759
785
  function resolveReactiveApi() {
760
786
  const g = globalThis;
@@ -786,6 +812,9 @@ function resolveReactiveApi() {
786
812
  getSubscriberCount,
787
813
  getSubscriberDeps,
788
814
  forEachSubscriber,
815
+ getOwnerScope,
816
+ runWithOwnerScope,
817
+ bindOwnerScope,
789
818
  version: _runtimeVersion
790
819
  };
791
820
  g[REGISTRY_KEY] = local;
@@ -809,6 +838,9 @@ var notifySubscribers2 = API.notifySubscribers;
809
838
  var getSubscriberCount2 = API.getSubscriberCount;
810
839
  var getSubscriberDeps2 = API.getSubscriberDeps;
811
840
  var forEachSubscriber2 = API.forEachSubscriber;
841
+ var getOwnerScope2 = API.getOwnerScope ?? getOwnerScope;
842
+ var runWithOwnerScope2 = API.runWithOwnerScope ?? runWithOwnerScope;
843
+ var bindOwnerScope2 = API.bindOwnerScope ?? bindOwnerScope;
812
844
 
813
845
  // src/core/devtoolsHook.ts
814
846
  function emitDevtools(hook, event, payload) {
@@ -864,6 +896,11 @@ function flushUserCleanups(ctx) {
864
896
  const list = ctx.userCleanups;
865
897
  if (list.length === 0) return;
866
898
  ctx.userCleanups = [];
899
+ const scope = ctx.subscriber._scope ?? null;
900
+ if (scope === getOwnerScope2()) runCleanups(list);
901
+ else runWithOwnerScope2(scope, () => runCleanups(list));
902
+ }
903
+ function runCleanups(list) {
867
904
  for (let i = list.length - 1; i >= 0; i--) {
868
905
  try {
869
906
  list[i]();
package/dist/testing.js CHANGED
@@ -3,9 +3,9 @@ import {
3
3
  } from "./chunk-7ZHH77QA.js";
4
4
  import {
5
5
  effect
6
- } from "./chunk-V3LHZSU5.js";
6
+ } from "./chunk-7WIHYHWD.js";
7
7
  import "./chunk-7XHATCIH.js";
8
- import "./chunk-TQQUN4WR.js";
8
+ import "./chunk-D6HYFOWR.js";
9
9
  import {
10
10
  dispose,
11
11
  replaceChildrenSafely,
package/dist/ui.cjs CHANGED
@@ -487,6 +487,24 @@ function untracked(fn) {
487
487
  resumeTracking();
488
488
  }
489
489
  }
490
+ var currentOwnerScope = null;
491
+ function getOwnerScope() {
492
+ return currentOwnerScope;
493
+ }
494
+ function runWithOwnerScope(scope, fn) {
495
+ const prev = currentOwnerScope;
496
+ currentOwnerScope = scope;
497
+ try {
498
+ return fn();
499
+ } finally {
500
+ currentOwnerScope = prev;
501
+ }
502
+ }
503
+ function bindOwnerScope(fn) {
504
+ const scope = currentOwnerScope;
505
+ if (scope === null) return fn;
506
+ return (...args) => runWithOwnerScope(scope, () => fn(...args));
507
+ }
490
508
  var subscriberEpochCounter = 0;
491
509
  function retrack(effectFn, subscriber) {
492
510
  const prev = currentSubscriber;
@@ -502,6 +520,10 @@ function retrack(effectFn, subscriber) {
502
520
  currentSubscriber = subscriber;
503
521
  const sub = subscriber;
504
522
  if (sub._cap === void 0) sub._cap = currentDisposerCapture();
523
+ const prevScope = currentOwnerScope;
524
+ if (prevScope !== null && !sub._epoch && sub._scope === void 0) sub._scope = prevScope;
525
+ const scope = sub._scope === void 0 ? null : sub._scope;
526
+ if (scope !== prevScope) currentOwnerScope = scope;
505
527
  const epoch = ++subscriberEpochCounter;
506
528
  sub._epoch = epoch;
507
529
  sub._structDirty = false;
@@ -514,6 +536,7 @@ function retrack(effectFn, subscriber) {
514
536
  effectFn();
515
537
  } finally {
516
538
  currentSubscriber = prev;
539
+ currentOwnerScope = prevScope;
517
540
  if (savedDepth !== 0) {
518
541
  suspendDepth = savedDepth;
519
542
  suspendSavedSub = savedSuspendSub;
@@ -548,23 +571,26 @@ function track(effectFn, subscriber) {
548
571
  trackingSuspended = false;
549
572
  }
550
573
  currentSubscriber = subscriber;
574
+ const sub = subscriber;
575
+ if (sub._scope === void 0) sub._scope = currentOwnerScope;
576
+ const prevScope = currentOwnerScope;
577
+ currentOwnerScope = sub._scope;
551
578
  try {
552
579
  effectFn();
553
580
  } finally {
554
581
  currentSubscriber = prev;
582
+ currentOwnerScope = prevScope;
555
583
  if (savedDepth !== 0) {
556
584
  suspendDepth = savedDepth;
557
585
  suspendSavedSub = savedSuspendSub;
558
586
  trackingSuspended = true;
559
587
  }
560
- const sub2 = subscriber;
561
- for (let n = sub2.depsHead ?? null; n !== null; n = n.subNext) {
588
+ for (let n = sub.depsHead ?? null; n !== null; n = n.subNext) {
562
589
  const sig = n.sig;
563
590
  sig.__activeNode = n.prevActive;
564
591
  n.prevActive = null;
565
592
  }
566
593
  }
567
- const sub = subscriber;
568
594
  return sub._dispose ?? (sub._dispose = () => cleanup(subscriber));
569
595
  }
570
596
  function reactiveBinding(commit, ownerNode) {
@@ -834,7 +860,7 @@ function forEachSubscriber(signal2, visit) {
834
860
  }
835
861
 
836
862
  // src/reactivity/track.ts
837
- var _runtimeVersion = true ? "4.8.0" : "dev";
863
+ var _runtimeVersion = true ? "4.10.0" : "dev";
838
864
  var REGISTRY_KEY = /* @__PURE__ */ Symbol.for("sibujs.reactive.v1");
839
865
  function resolveReactiveApi() {
840
866
  const g = globalThis;
@@ -866,6 +892,9 @@ function resolveReactiveApi() {
866
892
  getSubscriberCount,
867
893
  getSubscriberDeps,
868
894
  forEachSubscriber,
895
+ getOwnerScope,
896
+ runWithOwnerScope,
897
+ bindOwnerScope,
869
898
  version: _runtimeVersion
870
899
  };
871
900
  g[REGISTRY_KEY] = local;
@@ -889,6 +918,9 @@ var notifySubscribers2 = API.notifySubscribers;
889
918
  var getSubscriberCount2 = API.getSubscriberCount;
890
919
  var getSubscriberDeps2 = API.getSubscriberDeps;
891
920
  var forEachSubscriber2 = API.forEachSubscriber;
921
+ var getOwnerScope2 = API.getOwnerScope ?? getOwnerScope;
922
+ var runWithOwnerScope2 = API.runWithOwnerScope ?? runWithOwnerScope;
923
+ var bindOwnerScope2 = API.bindOwnerScope ?? bindOwnerScope;
892
924
 
893
925
  // src/core/devtoolsHook.ts
894
926
  function emitDevtools(hook, event, payload) {
@@ -3447,6 +3479,11 @@ function flushUserCleanups(ctx) {
3447
3479
  const list = ctx.userCleanups;
3448
3480
  if (list.length === 0) return;
3449
3481
  ctx.userCleanups = [];
3482
+ const scope = ctx.subscriber._scope ?? null;
3483
+ if (scope === getOwnerScope2()) runCleanups(list);
3484
+ else runWithOwnerScope2(scope, () => runCleanups(list));
3485
+ }
3486
+ function runCleanups(list) {
3450
3487
  for (let i = list.length - 1; i >= 0; i--) {
3451
3488
  try {
3452
3489
  list[i]();
@@ -3917,7 +3954,7 @@ function svgElement(tag, props = {}, ...nodes) {
3917
3954
  for (const child of nodes) {
3918
3955
  if (typeof child === "string") {
3919
3956
  el.appendChild(document.createTextNode(child));
3920
- } else if (child instanceof Node) {
3957
+ } else if (typeof child?.nodeType === "number") {
3921
3958
  el.appendChild(child);
3922
3959
  }
3923
3960
  }
package/dist/ui.js CHANGED
@@ -38,7 +38,7 @@ import {
38
38
  toast,
39
39
  withScopedStyle,
40
40
  zipMask
41
- } from "./chunk-ZVLHNEEL.js";
41
+ } from "./chunk-ITEL5KPL.js";
42
42
  import {
43
43
  RenderProp,
44
44
  assertType,
@@ -57,24 +57,24 @@ import {
57
57
  } from "./chunk-TUCPL2HB.js";
58
58
  import {
59
59
  createId
60
- } from "./chunk-C7AA2CZX.js";
61
- import "./chunk-O6TRVMJI.js";
60
+ } from "./chunk-GOL3FU5Q.js";
61
+ import "./chunk-XUQUQJYE.js";
62
62
  import "./chunk-3ACAAQIN.js";
63
- import "./chunk-KJ3UKABJ.js";
63
+ import "./chunk-5PC7OTQW.js";
64
64
  import {
65
65
  globalSingleton
66
66
  } from "./chunk-7ZHH77QA.js";
67
67
  import {
68
68
  effect
69
- } from "./chunk-V3LHZSU5.js";
69
+ } from "./chunk-7WIHYHWD.js";
70
70
  import "./chunk-EXXSN3BW.js";
71
71
  import "./chunk-7XHATCIH.js";
72
72
  import "./chunk-5HZXGZ6T.js";
73
73
  import {
74
74
  batch,
75
75
  signal
76
- } from "./chunk-DSID757X.js";
77
- import "./chunk-TQQUN4WR.js";
76
+ } from "./chunk-FYUEL5IW.js";
77
+ import "./chunk-D6HYFOWR.js";
78
78
  import {
79
79
  registerDisposer,
80
80
  unregisterDisposer
package/dist/widgets.cjs CHANGED
@@ -362,6 +362,24 @@ function untracked(fn) {
362
362
  resumeTracking();
363
363
  }
364
364
  }
365
+ var currentOwnerScope = null;
366
+ function getOwnerScope() {
367
+ return currentOwnerScope;
368
+ }
369
+ function runWithOwnerScope(scope, fn) {
370
+ const prev = currentOwnerScope;
371
+ currentOwnerScope = scope;
372
+ try {
373
+ return fn();
374
+ } finally {
375
+ currentOwnerScope = prev;
376
+ }
377
+ }
378
+ function bindOwnerScope(fn) {
379
+ const scope = currentOwnerScope;
380
+ if (scope === null) return fn;
381
+ return (...args) => runWithOwnerScope(scope, () => fn(...args));
382
+ }
365
383
  var subscriberEpochCounter = 0;
366
384
  function retrack(effectFn, subscriber) {
367
385
  const prev = currentSubscriber;
@@ -377,6 +395,10 @@ function retrack(effectFn, subscriber) {
377
395
  currentSubscriber = subscriber;
378
396
  const sub = subscriber;
379
397
  if (sub._cap === void 0) sub._cap = currentDisposerCapture();
398
+ const prevScope = currentOwnerScope;
399
+ if (prevScope !== null && !sub._epoch && sub._scope === void 0) sub._scope = prevScope;
400
+ const scope = sub._scope === void 0 ? null : sub._scope;
401
+ if (scope !== prevScope) currentOwnerScope = scope;
380
402
  const epoch = ++subscriberEpochCounter;
381
403
  sub._epoch = epoch;
382
404
  sub._structDirty = false;
@@ -389,6 +411,7 @@ function retrack(effectFn, subscriber) {
389
411
  effectFn();
390
412
  } finally {
391
413
  currentSubscriber = prev;
414
+ currentOwnerScope = prevScope;
392
415
  if (savedDepth !== 0) {
393
416
  suspendDepth = savedDepth;
394
417
  suspendSavedSub = savedSuspendSub;
@@ -423,23 +446,26 @@ function track(effectFn, subscriber) {
423
446
  trackingSuspended = false;
424
447
  }
425
448
  currentSubscriber = subscriber;
449
+ const sub = subscriber;
450
+ if (sub._scope === void 0) sub._scope = currentOwnerScope;
451
+ const prevScope = currentOwnerScope;
452
+ currentOwnerScope = sub._scope;
426
453
  try {
427
454
  effectFn();
428
455
  } finally {
429
456
  currentSubscriber = prev;
457
+ currentOwnerScope = prevScope;
430
458
  if (savedDepth !== 0) {
431
459
  suspendDepth = savedDepth;
432
460
  suspendSavedSub = savedSuspendSub;
433
461
  trackingSuspended = true;
434
462
  }
435
- const sub2 = subscriber;
436
- for (let n = sub2.depsHead ?? null; n !== null; n = n.subNext) {
463
+ for (let n = sub.depsHead ?? null; n !== null; n = n.subNext) {
437
464
  const sig = n.sig;
438
465
  sig.__activeNode = n.prevActive;
439
466
  n.prevActive = null;
440
467
  }
441
468
  }
442
- const sub = subscriber;
443
469
  return sub._dispose ?? (sub._dispose = () => cleanup(subscriber));
444
470
  }
445
471
  function reactiveBinding(commit, ownerNode) {
@@ -709,7 +735,7 @@ function forEachSubscriber(signal2, visit) {
709
735
  }
710
736
 
711
737
  // src/reactivity/track.ts
712
- var _runtimeVersion = true ? "4.8.0" : "dev";
738
+ var _runtimeVersion = true ? "4.10.0" : "dev";
713
739
  var REGISTRY_KEY = /* @__PURE__ */ Symbol.for("sibujs.reactive.v1");
714
740
  function resolveReactiveApi() {
715
741
  const g = globalThis;
@@ -741,6 +767,9 @@ function resolveReactiveApi() {
741
767
  getSubscriberCount,
742
768
  getSubscriberDeps,
743
769
  forEachSubscriber,
770
+ getOwnerScope,
771
+ runWithOwnerScope,
772
+ bindOwnerScope,
744
773
  version: _runtimeVersion
745
774
  };
746
775
  g[REGISTRY_KEY] = local;
@@ -764,6 +793,9 @@ var notifySubscribers2 = API.notifySubscribers;
764
793
  var getSubscriberCount2 = API.getSubscriberCount;
765
794
  var getSubscriberDeps2 = API.getSubscriberDeps;
766
795
  var forEachSubscriber2 = API.forEachSubscriber;
796
+ var getOwnerScope2 = API.getOwnerScope ?? getOwnerScope;
797
+ var runWithOwnerScope2 = API.runWithOwnerScope ?? runWithOwnerScope;
798
+ var bindOwnerScope2 = API.bindOwnerScope ?? bindOwnerScope;
767
799
 
768
800
  // src/core/devtoolsHook.ts
769
801
  function emitDevtools(hook, event, payload) {
package/dist/widgets.js CHANGED
@@ -8,14 +8,14 @@ import {
8
8
  select,
9
9
  tabs,
10
10
  tooltip
11
- } from "./chunk-GSGNX35Q.js";
12
- import "./chunk-CZPRSWSS.js";
13
- import "./chunk-C7AA2CZX.js";
14
- import "./chunk-KJ3UKABJ.js";
11
+ } from "./chunk-IFRIBZ4O.js";
12
+ import "./chunk-EVOK663Z.js";
13
+ import "./chunk-GOL3FU5Q.js";
14
+ import "./chunk-5PC7OTQW.js";
15
15
  import "./chunk-EXXSN3BW.js";
16
16
  import "./chunk-7XHATCIH.js";
17
- import "./chunk-DSID757X.js";
18
- import "./chunk-TQQUN4WR.js";
17
+ import "./chunk-FYUEL5IW.js";
18
+ import "./chunk-D6HYFOWR.js";
19
19
  import "./chunk-NYNYSPK7.js";
20
20
  export {
21
21
  accordion,
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "sibujs",
3
- "version": "4.8.0",
3
+ "version": "4.10.0",
4
4
  "description": "A function-based frontend framework with fine-grained reactivity and no virtual DOM. Tag factories return live DOM nodes you can hold and mutate, signals update only what changed, and nothing needs a compiler — it runs from a script tag or a bundler.",
5
5
  "keywords": [
6
6
  "frontend",