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/patterns.cjs CHANGED
@@ -310,6 +310,24 @@ function untracked(fn) {
310
310
  resumeTracking();
311
311
  }
312
312
  }
313
+ var currentOwnerScope = null;
314
+ function getOwnerScope() {
315
+ return currentOwnerScope;
316
+ }
317
+ function runWithOwnerScope(scope, fn) {
318
+ const prev = currentOwnerScope;
319
+ currentOwnerScope = scope;
320
+ try {
321
+ return fn();
322
+ } finally {
323
+ currentOwnerScope = prev;
324
+ }
325
+ }
326
+ function bindOwnerScope(fn) {
327
+ const scope = currentOwnerScope;
328
+ if (scope === null) return fn;
329
+ return (...args) => runWithOwnerScope(scope, () => fn(...args));
330
+ }
313
331
  var subscriberEpochCounter = 0;
314
332
  function retrack(effectFn, subscriber) {
315
333
  const prev = currentSubscriber;
@@ -325,6 +343,10 @@ function retrack(effectFn, subscriber) {
325
343
  currentSubscriber = subscriber;
326
344
  const sub = subscriber;
327
345
  if (sub._cap === void 0) sub._cap = currentDisposerCapture();
346
+ const prevScope = currentOwnerScope;
347
+ if (prevScope !== null && !sub._epoch && sub._scope === void 0) sub._scope = prevScope;
348
+ const scope = sub._scope === void 0 ? null : sub._scope;
349
+ if (scope !== prevScope) currentOwnerScope = scope;
328
350
  const epoch = ++subscriberEpochCounter;
329
351
  sub._epoch = epoch;
330
352
  sub._structDirty = false;
@@ -337,6 +359,7 @@ function retrack(effectFn, subscriber) {
337
359
  effectFn();
338
360
  } finally {
339
361
  currentSubscriber = prev;
362
+ currentOwnerScope = prevScope;
340
363
  if (savedDepth !== 0) {
341
364
  suspendDepth = savedDepth;
342
365
  suspendSavedSub = savedSuspendSub;
@@ -371,23 +394,26 @@ function track(effectFn, subscriber) {
371
394
  trackingSuspended = false;
372
395
  }
373
396
  currentSubscriber = subscriber;
397
+ const sub = subscriber;
398
+ if (sub._scope === void 0) sub._scope = currentOwnerScope;
399
+ const prevScope = currentOwnerScope;
400
+ currentOwnerScope = sub._scope;
374
401
  try {
375
402
  effectFn();
376
403
  } finally {
377
404
  currentSubscriber = prev;
405
+ currentOwnerScope = prevScope;
378
406
  if (savedDepth !== 0) {
379
407
  suspendDepth = savedDepth;
380
408
  suspendSavedSub = savedSuspendSub;
381
409
  trackingSuspended = true;
382
410
  }
383
- const sub2 = subscriber;
384
- for (let n = sub2.depsHead ?? null; n !== null; n = n.subNext) {
411
+ for (let n = sub.depsHead ?? null; n !== null; n = n.subNext) {
385
412
  const sig = n.sig;
386
413
  sig.__activeNode = n.prevActive;
387
414
  n.prevActive = null;
388
415
  }
389
416
  }
390
- const sub = subscriber;
391
417
  return sub._dispose ?? (sub._dispose = () => cleanup(subscriber));
392
418
  }
393
419
  function reactiveBinding(commit, ownerNode) {
@@ -657,7 +683,7 @@ function forEachSubscriber(signal2, visit) {
657
683
  }
658
684
 
659
685
  // src/reactivity/track.ts
660
- var _runtimeVersion = true ? "4.8.0" : "dev";
686
+ var _runtimeVersion = true ? "4.10.0" : "dev";
661
687
  var REGISTRY_KEY = /* @__PURE__ */ Symbol.for("sibujs.reactive.v1");
662
688
  function resolveReactiveApi() {
663
689
  const g = globalThis;
@@ -689,6 +715,9 @@ function resolveReactiveApi() {
689
715
  getSubscriberCount,
690
716
  getSubscriberDeps,
691
717
  forEachSubscriber,
718
+ getOwnerScope,
719
+ runWithOwnerScope,
720
+ bindOwnerScope,
692
721
  version: _runtimeVersion
693
722
  };
694
723
  g[REGISTRY_KEY] = local;
@@ -712,6 +741,9 @@ var notifySubscribers2 = API.notifySubscribers;
712
741
  var getSubscriberCount2 = API.getSubscriberCount;
713
742
  var getSubscriberDeps2 = API.getSubscriberDeps;
714
743
  var forEachSubscriber2 = API.forEachSubscriber;
744
+ var getOwnerScope2 = API.getOwnerScope ?? getOwnerScope;
745
+ var runWithOwnerScope2 = API.runWithOwnerScope ?? runWithOwnerScope;
746
+ var bindOwnerScope2 = API.bindOwnerScope ?? bindOwnerScope;
715
747
 
716
748
  // src/reactivity/batch.ts
717
749
  var batchDepth = 0;
@@ -997,6 +1029,11 @@ function flushUserCleanups(ctx) {
997
1029
  const list = ctx.userCleanups;
998
1030
  if (list.length === 0) return;
999
1031
  ctx.userCleanups = [];
1032
+ const scope = ctx.subscriber._scope ?? null;
1033
+ if (scope === getOwnerScope2()) runCleanups(list);
1034
+ else runWithOwnerScope2(scope, () => runCleanups(list));
1035
+ }
1036
+ function runCleanups(list) {
1000
1037
  for (let i = list.length - 1; i >= 0; i--) {
1001
1038
  try {
1002
1039
  list[i]();
package/dist/patterns.js CHANGED
@@ -5,7 +5,7 @@ import {
5
5
  optimisticList,
6
6
  persisted,
7
7
  timeline
8
- } from "./chunk-RGLPEBDE.js";
8
+ } from "./chunk-JCKUWWHU.js";
9
9
  import {
10
10
  RenderProp,
11
11
  assertType,
@@ -23,11 +23,11 @@ import {
23
23
  withWrapper
24
24
  } from "./chunk-TUCPL2HB.js";
25
25
  import "./chunk-62BDYGAG.js";
26
- import "./chunk-KJ3UKABJ.js";
27
- import "./chunk-V3LHZSU5.js";
26
+ import "./chunk-5PC7OTQW.js";
27
+ import "./chunk-7WIHYHWD.js";
28
28
  import "./chunk-7XHATCIH.js";
29
- import "./chunk-DSID757X.js";
30
- import "./chunk-TQQUN4WR.js";
29
+ import "./chunk-FYUEL5IW.js";
30
+ import "./chunk-D6HYFOWR.js";
31
31
  import "./chunk-NYNYSPK7.js";
32
32
  export {
33
33
  RenderProp,
@@ -576,6 +576,24 @@ function untracked(fn) {
576
576
  resumeTracking();
577
577
  }
578
578
  }
579
+ var currentOwnerScope = null;
580
+ function getOwnerScope() {
581
+ return currentOwnerScope;
582
+ }
583
+ function runWithOwnerScope(scope, fn) {
584
+ const prev = currentOwnerScope;
585
+ currentOwnerScope = scope;
586
+ try {
587
+ return fn();
588
+ } finally {
589
+ currentOwnerScope = prev;
590
+ }
591
+ }
592
+ function bindOwnerScope(fn) {
593
+ const scope = currentOwnerScope;
594
+ if (scope === null) return fn;
595
+ return (...args) => runWithOwnerScope(scope, () => fn(...args));
596
+ }
579
597
  var subscriberEpochCounter = 0;
580
598
  function retrack(effectFn, subscriber) {
581
599
  const prev = currentSubscriber;
@@ -591,6 +609,10 @@ function retrack(effectFn, subscriber) {
591
609
  currentSubscriber = subscriber;
592
610
  const sub = subscriber;
593
611
  if (sub._cap === void 0) sub._cap = currentDisposerCapture();
612
+ const prevScope = currentOwnerScope;
613
+ if (prevScope !== null && !sub._epoch && sub._scope === void 0) sub._scope = prevScope;
614
+ const scope = sub._scope === void 0 ? null : sub._scope;
615
+ if (scope !== prevScope) currentOwnerScope = scope;
594
616
  const epoch = ++subscriberEpochCounter;
595
617
  sub._epoch = epoch;
596
618
  sub._structDirty = false;
@@ -603,6 +625,7 @@ function retrack(effectFn, subscriber) {
603
625
  effectFn();
604
626
  } finally {
605
627
  currentSubscriber = prev;
628
+ currentOwnerScope = prevScope;
606
629
  if (savedDepth !== 0) {
607
630
  suspendDepth = savedDepth;
608
631
  suspendSavedSub = savedSuspendSub;
@@ -637,23 +660,26 @@ function track(effectFn, subscriber) {
637
660
  trackingSuspended = false;
638
661
  }
639
662
  currentSubscriber = subscriber;
663
+ const sub = subscriber;
664
+ if (sub._scope === void 0) sub._scope = currentOwnerScope;
665
+ const prevScope = currentOwnerScope;
666
+ currentOwnerScope = sub._scope;
640
667
  try {
641
668
  effectFn();
642
669
  } finally {
643
670
  currentSubscriber = prev;
671
+ currentOwnerScope = prevScope;
644
672
  if (savedDepth !== 0) {
645
673
  suspendDepth = savedDepth;
646
674
  suspendSavedSub = savedSuspendSub;
647
675
  trackingSuspended = true;
648
676
  }
649
- const sub2 = subscriber;
650
- for (let n = sub2.depsHead ?? null; n !== null; n = n.subNext) {
677
+ for (let n = sub.depsHead ?? null; n !== null; n = n.subNext) {
651
678
  const sig = n.sig;
652
679
  sig.__activeNode = n.prevActive;
653
680
  n.prevActive = null;
654
681
  }
655
682
  }
656
- const sub = subscriber;
657
683
  return sub._dispose ?? (sub._dispose = () => cleanup(subscriber));
658
684
  }
659
685
  function reactiveBinding(commit, ownerNode) {
@@ -923,7 +949,7 @@ function forEachSubscriber(signal2, visit) {
923
949
  }
924
950
 
925
951
  // src/reactivity/track.ts
926
- var _runtimeVersion = true ? "4.8.0" : "dev";
952
+ var _runtimeVersion = true ? "4.10.0" : "dev";
927
953
  var REGISTRY_KEY = /* @__PURE__ */ Symbol.for("sibujs.reactive.v1");
928
954
  function resolveReactiveApi() {
929
955
  const g = globalThis;
@@ -955,6 +981,9 @@ function resolveReactiveApi() {
955
981
  getSubscriberCount,
956
982
  getSubscriberDeps,
957
983
  forEachSubscriber,
984
+ getOwnerScope,
985
+ runWithOwnerScope,
986
+ bindOwnerScope,
958
987
  version: _runtimeVersion
959
988
  };
960
989
  g[REGISTRY_KEY] = local;
@@ -978,6 +1007,9 @@ var notifySubscribers2 = API.notifySubscribers;
978
1007
  var getSubscriberCount2 = API.getSubscriberCount;
979
1008
  var getSubscriberDeps2 = API.getSubscriberDeps;
980
1009
  var forEachSubscriber2 = API.forEachSubscriber;
1010
+ var getOwnerScope2 = API.getOwnerScope ?? getOwnerScope;
1011
+ var runWithOwnerScope2 = API.runWithOwnerScope ?? runWithOwnerScope;
1012
+ var bindOwnerScope2 = API.bindOwnerScope ?? bindOwnerScope;
981
1013
 
982
1014
  // src/core/devtoolsHook.ts
983
1015
  function emitDevtools(hook, event, payload) {
@@ -1033,6 +1065,11 @@ function flushUserCleanups(ctx) {
1033
1065
  const list = ctx.userCleanups;
1034
1066
  if (list.length === 0) return;
1035
1067
  ctx.userCleanups = [];
1068
+ const scope = ctx.subscriber._scope ?? null;
1069
+ if (scope === getOwnerScope2()) runCleanups(list);
1070
+ else runWithOwnerScope2(scope, () => runCleanups(list));
1071
+ }
1072
+ function runCleanups(list) {
1036
1073
  for (let i = list.length - 1; i >= 0; i--) {
1037
1074
  try {
1038
1075
  list[i]();
@@ -1920,16 +1957,20 @@ function lazyChunk(id, loader, registry, fallback) {
1920
1957
  registry.load(id, async () => {
1921
1958
  const mod = await loader();
1922
1959
  return typeof mod === "function" ? mod : mod.default;
1923
- }).then((component) => {
1924
- if (disposed) return;
1925
- const node = component();
1926
- if (disposed) {
1927
- dispose(node);
1928
- return;
1929
- }
1930
- clearChildren(container);
1931
- container.appendChild(node);
1932
- }).catch((err) => {
1960
+ }).then(
1961
+ // Instantiated after the chunk resolves, in the owner scope of the
1962
+ // render that asked for it — as `lazy()` does.
1963
+ bindOwnerScope2((component) => {
1964
+ if (disposed) return;
1965
+ const node = component();
1966
+ if (disposed) {
1967
+ dispose(node);
1968
+ return;
1969
+ }
1970
+ clearChildren(container);
1971
+ container.appendChild(node);
1972
+ })
1973
+ ).catch((err) => {
1933
1974
  if (disposed) return;
1934
1975
  clearChildren(container);
1935
1976
  const errorEl = document.createElement("div");
@@ -33,18 +33,18 @@ import {
33
33
  transitionState,
34
34
  uniqueId,
35
35
  yieldToMain
36
- } from "./chunk-C5PEWEGH.js";
36
+ } from "./chunk-IL5MMSCL.js";
37
37
  import {
38
38
  trustHTML
39
39
  } from "./chunk-FC6KCJSA.js";
40
40
  import "./chunk-62BDYGAG.js";
41
41
  import "./chunk-3ACAAQIN.js";
42
42
  import "./chunk-7ZHH77QA.js";
43
- import "./chunk-V3LHZSU5.js";
43
+ import "./chunk-7WIHYHWD.js";
44
44
  import "./chunk-EXXSN3BW.js";
45
45
  import "./chunk-7XHATCIH.js";
46
- import "./chunk-DSID757X.js";
47
- import "./chunk-TQQUN4WR.js";
46
+ import "./chunk-FYUEL5IW.js";
47
+ import "./chunk-D6HYFOWR.js";
48
48
  import "./chunk-NYNYSPK7.js";
49
49
  export {
50
50
  DOMPool,