sibujs 3.3.0 → 3.3.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.
Files changed (60) hide show
  1. package/dist/browser.cjs +230 -40
  2. package/dist/browser.js +5 -5
  3. package/dist/build.cjs +240 -108
  4. package/dist/build.js +13 -13
  5. package/dist/cdn.global.js +7 -7
  6. package/dist/{chunk-BEIKESVL.js → chunk-2ARSB7NG.js} +36 -13
  7. package/dist/{chunk-X3NHE2DK.js → chunk-4NJEAPLI.js} +83 -17
  8. package/dist/{chunk-JBXNCZSC.js → chunk-5VH3GIDX.js} +1 -1
  9. package/dist/{chunk-6G6UNHZI.js → chunk-62V653X2.js} +16 -21
  10. package/dist/{chunk-S4FHR5ZZ.js → chunk-655B7MMR.js} +3 -3
  11. package/dist/{chunk-24DBWDTK.js → chunk-6TCOWMGY.js} +1 -1
  12. package/dist/{chunk-USDR2GFV.js → chunk-A7CZH3GN.js} +3 -3
  13. package/dist/{chunk-SLCUP2EK.js → chunk-AEOLHSSQ.js} +3 -3
  14. package/dist/chunk-CCSJMTRN.js +15 -0
  15. package/dist/{chunk-R3QEDXFS.js → chunk-EX77FXTT.js} +1 -1
  16. package/dist/{chunk-ZUVLC7TM.js → chunk-FJIRS3FM.js} +1 -1
  17. package/dist/{chunk-4WXWJ4SW.js → chunk-FJO2ZL4Q.js} +4 -4
  18. package/dist/{chunk-CVMMULHO.js → chunk-G6N3LMO2.js} +4 -4
  19. package/dist/{chunk-XQ7XSGYP.js → chunk-IQJ36UTJ.js} +1 -1
  20. package/dist/{chunk-5K72I3UQ.js → chunk-JCQG2I2G.js} +21 -4
  21. package/dist/{chunk-7JHWAGRQ.js → chunk-N5TQVEKE.js} +2 -2
  22. package/dist/{chunk-IHBVTURX.js → chunk-P7C7SEJV.js} +4 -4
  23. package/dist/{chunk-M6WSIGYW.js → chunk-Q46YIQYW.js} +2 -2
  24. package/dist/{chunk-Q2ERM6NT.js → chunk-QCFBIVIQ.js} +1 -1
  25. package/dist/{chunk-F4UM7QBJ.js → chunk-RLTFJYDN.js} +2 -2
  26. package/dist/{chunk-GOJMFRBL.js → chunk-S3NFJO6L.js} +20 -14
  27. package/dist/{chunk-MWZFOIBG.js → chunk-YUBEOWII.js} +5 -5
  28. package/dist/{chunk-WVJJUFPC.js → chunk-YUR5SX7F.js} +2 -2
  29. package/dist/{chunk-NUWKIEHE.js → chunk-ZEUP4TUD.js} +2 -2
  30. package/dist/data.cjs +181 -37
  31. package/dist/data.js +7 -7
  32. package/dist/devtools.cjs +265 -45
  33. package/dist/devtools.js +5 -5
  34. package/dist/ecosystem.cjs +203 -59
  35. package/dist/ecosystem.js +8 -8
  36. package/dist/extras.cjs +216 -116
  37. package/dist/extras.js +22 -22
  38. package/dist/index.cjs +242 -108
  39. package/dist/index.d.cts +78 -14
  40. package/dist/index.d.ts +78 -14
  41. package/dist/index.js +17 -13
  42. package/dist/motion.cjs +329 -13
  43. package/dist/motion.js +3 -3
  44. package/dist/patterns.cjs +181 -37
  45. package/dist/patterns.js +6 -6
  46. package/dist/performance.cjs +278 -37
  47. package/dist/performance.js +6 -6
  48. package/dist/plugins.cjs +353 -153
  49. package/dist/plugins.js +95 -94
  50. package/dist/{ssr-6D67RAVB.js → ssr-2PPULEK2.js} +2 -2
  51. package/dist/ssr.cjs +203 -58
  52. package/dist/ssr.js +9 -9
  53. package/dist/testing.cjs +416 -19
  54. package/dist/testing.js +3 -3
  55. package/dist/ui.cjs +256 -65
  56. package/dist/ui.js +8 -8
  57. package/dist/widgets.cjs +166 -40
  58. package/dist/widgets.js +7 -7
  59. package/package.json +1 -1
  60. package/dist/chunk-YT6HQ6AM.js +0 -14
package/dist/data.cjs CHANGED
@@ -66,7 +66,7 @@ function devWarn(message) {
66
66
  }
67
67
  }
68
68
 
69
- // src/reactivity/track.ts
69
+ // src/reactivity/track-core.ts
70
70
  var _isDev2 = isDev();
71
71
  var POOL_MAX = 4096;
72
72
  var nodePool = [];
@@ -150,6 +150,7 @@ function unlinkSub(node) {
150
150
  else sub.depsTail = prev;
151
151
  }
152
152
  var currentSubscriber = null;
153
+ var suspendSavedSub = null;
153
154
  var notifyDepth = 0;
154
155
  var pendingQueue = [];
155
156
  var pendingSet = /* @__PURE__ */ new Set();
@@ -161,7 +162,35 @@ function safeInvoke(sub) {
161
162
  if (_isDev2) devWarn(`Subscriber threw during notification: ${err instanceof Error ? err.message : String(err)}`);
162
163
  }
163
164
  }
165
+ var suspendDepth = 0;
164
166
  var trackingSuspended = false;
167
+ function suspendTracking() {
168
+ if (suspendDepth === 0) {
169
+ suspendSavedSub = currentSubscriber;
170
+ currentSubscriber = null;
171
+ trackingSuspended = true;
172
+ }
173
+ suspendDepth++;
174
+ }
175
+ function resumeTracking() {
176
+ suspendDepth--;
177
+ if (suspendDepth === 0) {
178
+ currentSubscriber = suspendSavedSub;
179
+ suspendSavedSub = null;
180
+ trackingSuspended = false;
181
+ }
182
+ }
183
+ function isTrackingSuspended() {
184
+ return trackingSuspended;
185
+ }
186
+ function untracked(fn) {
187
+ suspendTracking();
188
+ try {
189
+ return fn();
190
+ } finally {
191
+ resumeTracking();
192
+ }
193
+ }
165
194
  var subscriberEpochCounter = 0;
166
195
  function retrack(effectFn, subscriber) {
167
196
  const prev = currentSubscriber;
@@ -271,6 +300,16 @@ function cleanup(subscriber) {
271
300
  var maxSubscriberRepeats = 50;
272
301
  var maxDrainIterations = 1e6;
273
302
  var drainEpoch = 0;
303
+ function setMaxSubscriberRepeats(n) {
304
+ const prev = maxSubscriberRepeats;
305
+ if (Number.isFinite(n) && n > 0) maxSubscriberRepeats = Math.floor(n);
306
+ return prev;
307
+ }
308
+ function setMaxDrainIterations(n) {
309
+ const prev = maxDrainIterations;
310
+ if (Number.isFinite(n) && n > 0) maxDrainIterations = Math.floor(n);
311
+ return prev;
312
+ }
274
313
  function tickRepeat(sub) {
275
314
  const s = sub;
276
315
  if (s._runEpoch !== drainEpoch) {
@@ -419,6 +458,85 @@ function notifySubscribers(signal2) {
419
458
  }
420
459
  }
421
460
  }
461
+ function getSubscriberCount(signal2) {
462
+ return signal2.__sc ?? 0;
463
+ }
464
+ function getSubscriberDeps(subscriber) {
465
+ const sub = subscriber;
466
+ const out = [];
467
+ let node = sub.depsHead ?? null;
468
+ while (node) {
469
+ if (node.sig) out.push(node.sig);
470
+ node = node.subNext;
471
+ }
472
+ return out;
473
+ }
474
+ function forEachSubscriber(signal2, visit) {
475
+ let node = signal2.subsHead ?? null;
476
+ while (node) {
477
+ const s = node.sub;
478
+ if (s) visit(s);
479
+ node = node.sigNext;
480
+ }
481
+ }
482
+
483
+ // src/reactivity/track.ts
484
+ var _isDev3 = isDev();
485
+ var _runtimeVersion = true ? "3.3.2" : "dev";
486
+ var REGISTRY_KEY = /* @__PURE__ */ Symbol.for("sibujs.reactive.v1");
487
+ function resolveReactiveApi() {
488
+ const g = globalThis;
489
+ const existing = g[REGISTRY_KEY];
490
+ if (existing) {
491
+ if (_isDev3 && !existing.__dupWarned) {
492
+ existing.__dupWarned = true;
493
+ devWarn(
494
+ `Multiple instances of the reactive runtime detected on this page (active: ${existing.version}, duplicate: ${_runtimeVersion}). Reactivity still works \u2014 all copies share the first one \u2014 but de-duplicate sibujs in your bundler (e.g. Vite optimizeDeps.exclude: ['sibujs'] or resolve.dedupe: ['sibujs']).`
495
+ );
496
+ }
497
+ return existing;
498
+ }
499
+ const local = {
500
+ suspendTracking,
501
+ resumeTracking,
502
+ isTrackingSuspended,
503
+ untracked,
504
+ retrack,
505
+ track,
506
+ reactiveBinding,
507
+ recordDependency,
508
+ cleanup,
509
+ setMaxSubscriberRepeats,
510
+ setMaxDrainIterations,
511
+ drainNotificationQueue,
512
+ queueSignalNotification,
513
+ notifySubscribers,
514
+ getSubscriberCount,
515
+ getSubscriberDeps,
516
+ forEachSubscriber,
517
+ version: _runtimeVersion
518
+ };
519
+ g[REGISTRY_KEY] = local;
520
+ return local;
521
+ }
522
+ var API = resolveReactiveApi();
523
+ var suspendTracking2 = API.suspendTracking;
524
+ var resumeTracking2 = API.resumeTracking;
525
+ var isTrackingSuspended2 = API.isTrackingSuspended;
526
+ var untracked2 = API.untracked;
527
+ var retrack2 = API.retrack;
528
+ var track2 = API.track;
529
+ var reactiveBinding2 = API.reactiveBinding;
530
+ var recordDependency2 = API.recordDependency;
531
+ var cleanup2 = API.cleanup;
532
+ var setMaxSubscriberRepeats2 = API.setMaxSubscriberRepeats;
533
+ var setMaxDrainIterations2 = API.setMaxDrainIterations;
534
+ var drainNotificationQueue2 = API.drainNotificationQueue;
535
+ var queueSignalNotification2 = API.queueSignalNotification;
536
+ var notifySubscribers2 = API.notifySubscribers;
537
+ var getSubscriberCount2 = API.getSubscriberCount;
538
+ var getSubscriberDeps2 = API.getSubscriberDeps;
539
+ var forEachSubscriber2 = API.forEachSubscriber;
422
540
 
423
541
  // src/core/signals/derived.ts
424
542
  function derived(getter, options) {
@@ -442,7 +560,7 @@ function derived(getter, options) {
442
560
  cs._d = false;
443
561
  cs._init = true;
444
562
  };
445
- track(() => {
563
+ track2(() => {
446
564
  let threw = true;
447
565
  try {
448
566
  cs._v = getter();
@@ -461,12 +579,12 @@ function derived(getter, options) {
461
579
  `[SibuJS] Circular dependency detected in derived${debugName ? ` "${debugName}"` : ""}. A derived signal cannot read itself (directly or through a chain).`
462
580
  );
463
581
  }
464
- if (trackingSuspended) {
582
+ if (isTrackingSuspended2()) {
465
583
  if (cs._d) {
466
584
  const prev = cs._v;
467
585
  evaluating = true;
468
586
  try {
469
- retrack(recompute, markDirty);
587
+ retrack2(recompute, markDirty);
470
588
  if (!Object.is(prev, cs._v)) cs.__v++;
471
589
  } finally {
472
590
  evaluating = false;
@@ -474,12 +592,12 @@ function derived(getter, options) {
474
592
  }
475
593
  return cs._v;
476
594
  }
477
- recordDependency(cs);
595
+ recordDependency2(cs);
478
596
  if (cs._d) {
479
597
  const oldValue = cs._v;
480
598
  evaluating = true;
481
599
  try {
482
- retrack(recompute, markDirty);
600
+ retrack2(recompute, markDirty);
483
601
  if (!Object.is(oldValue, cs._v)) cs.__v++;
484
602
  } finally {
485
603
  evaluating = false;
@@ -500,23 +618,29 @@ function derived(getter, options) {
500
618
  }
501
619
 
502
620
  // src/core/ssr-context.ts
503
- var als = null;
504
- try {
505
- if (typeof process !== "undefined" && process.versions && process.versions.node) {
506
- let mod = null;
507
- const getBuiltin = process.getBuiltinModule;
508
- if (typeof getBuiltin === "function") {
509
- mod = getBuiltin("node:async_hooks");
510
- } else {
511
- const req = Function("return typeof require==='function'?require:null")();
512
- if (req) mod = req("node:async_hooks");
621
+ var SSR_KEY = /* @__PURE__ */ Symbol.for("sibujs.ssr.v1");
622
+ function detectSSRShared() {
623
+ let detected = null;
624
+ try {
625
+ if (typeof process !== "undefined" && process.versions && process.versions.node) {
626
+ let mod = null;
627
+ const getBuiltin = process.getBuiltinModule;
628
+ if (typeof getBuiltin === "function") {
629
+ mod = getBuiltin("node:async_hooks");
630
+ } else {
631
+ const req = Function("return typeof require==='function'?require:null")();
632
+ if (req) mod = req("node:async_hooks");
633
+ }
634
+ if (mod) detected = new mod.AsyncLocalStorage();
513
635
  }
514
- if (mod) als = new mod.AsyncLocalStorage();
636
+ } catch {
637
+ detected = null;
515
638
  }
516
- } catch {
517
- als = null;
639
+ return { als: detected, fallbackStore: { ssr: false, suspenseIdCounter: 0 } };
518
640
  }
519
- var fallbackStore = { ssr: false, suspenseIdCounter: 0 };
641
+ var _shared = globalThis[SSR_KEY] ?? (globalThis[SSR_KEY] = detectSSRShared());
642
+ var als = _shared.als;
643
+ var fallbackStore = _shared.fallbackStore;
520
644
  function getSSRStore() {
521
645
  if (als) {
522
646
  const s = als.getStore();
@@ -559,7 +683,7 @@ function drainReruns(ctx) {
559
683
  do {
560
684
  ctx.rerunPending = false;
561
685
  if (ctx.userCleanups.length > 0) flushUserCleanups(ctx);
562
- retrack(ctx.bodyFn, ctx.subscriber);
686
+ retrack2(ctx.bodyFn, ctx.subscriber);
563
687
  } while (ctx.rerunPending && ++reruns <= MAX_RERUNS);
564
688
  if (ctx.rerunPending) {
565
689
  ctx.rerunPending = false;
@@ -588,7 +712,7 @@ function disposeEffect(ctx) {
588
712
  }
589
713
  }
590
714
  try {
591
- cleanup(ctx.subscriber);
715
+ cleanup2(ctx.subscriber);
592
716
  } catch (err) {
593
717
  if (typeof console !== "undefined") {
594
718
  console.warn("[SibuJS effect] dispose threw:", err);
@@ -633,7 +757,7 @@ function effect(effectFn, options) {
633
757
  try {
634
758
  ctx.rerunPending = false;
635
759
  if (ctx.userCleanups.length > 0) flushUserCleanups(ctx);
636
- retrack(ctx.bodyFn, sub);
760
+ retrack2(ctx.bodyFn, sub);
637
761
  if (ctx.rerunPending) drainReruns(ctx);
638
762
  } finally {
639
763
  ctx.running = false;
@@ -649,7 +773,7 @@ function effect(effectFn, options) {
649
773
  ctx.subscriber = sub;
650
774
  ctx.running = true;
651
775
  try {
652
- retrack(ctx.bodyFn, ctx.subscriber);
776
+ retrack2(ctx.bodyFn, ctx.subscriber);
653
777
  if (ctx.rerunPending) drainReruns(ctx);
654
778
  } finally {
655
779
  ctx.running = false;
@@ -663,7 +787,7 @@ function effect(effectFn, options) {
663
787
  // src/reactivity/batch.ts
664
788
  var batchDepth = 0;
665
789
  var pendingSignals = /* @__PURE__ */ new Set();
666
- function batch(fn) {
790
+ function batchImpl(fn) {
667
791
  batchDepth++;
668
792
  try {
669
793
  return fn();
@@ -674,25 +798,45 @@ function batch(fn) {
674
798
  }
675
799
  }
676
800
  }
677
- function enqueueBatchedSignal(signal2) {
801
+ function enqueueBatchedSignalImpl(signal2) {
678
802
  if (batchDepth === 0) return false;
679
803
  pendingSignals.add(signal2);
680
804
  return true;
681
805
  }
806
+ function isBatchingImpl() {
807
+ return batchDepth > 0;
808
+ }
682
809
  function flushBatch() {
683
810
  try {
684
811
  for (const signal2 of pendingSignals) {
685
- queueSignalNotification(signal2);
812
+ queueSignalNotification2(signal2);
686
813
  }
687
814
  } finally {
688
815
  pendingSignals.clear();
689
816
  }
690
- drainNotificationQueue();
817
+ drainNotificationQueue2();
818
+ }
819
+ var BATCH_REGISTRY_KEY = /* @__PURE__ */ Symbol.for("sibujs.reactive.batch.v1");
820
+ function resolveBatchApi() {
821
+ const g = globalThis;
822
+ const existing = g[BATCH_REGISTRY_KEY];
823
+ if (existing) return existing;
824
+ const local = {
825
+ batch: batchImpl,
826
+ enqueueBatchedSignal: enqueueBatchedSignalImpl,
827
+ isBatching: isBatchingImpl
828
+ };
829
+ g[BATCH_REGISTRY_KEY] = local;
830
+ return local;
691
831
  }
832
+ var API2 = resolveBatchApi();
833
+ var batch = API2.batch;
834
+ var enqueueBatchedSignal = API2.enqueueBatchedSignal;
835
+ var isBatching = API2.isBatching;
692
836
 
693
837
  // src/core/signals/signal.ts
694
838
  var _g2 = globalThis;
695
- var _isDev3 = isDev();
839
+ var _isDev4 = isDev();
696
840
  function signal(initial, options) {
697
841
  const state = {
698
842
  value: initial,
@@ -703,11 +847,11 @@ function signal(initial, options) {
703
847
  __activeNode: null,
704
848
  __name: void 0
705
849
  };
706
- const debugName = _isDev3 ? options?.name : void 0;
850
+ const debugName = _isDev4 ? options?.name : void 0;
707
851
  const equalsFn = options?.equals;
708
852
  if (debugName) state.__name = debugName;
709
853
  function get() {
710
- recordDependency(state);
854
+ recordDependency2(state);
711
855
  return state.value;
712
856
  }
713
857
  get.__signal = state;
@@ -720,15 +864,15 @@ function signal(initial, options) {
720
864
  if (equalsFn(prev, newValue)) return;
721
865
  state.value = newValue;
722
866
  state.__v++;
723
- if (_isDev3) {
867
+ if (_isDev4) {
724
868
  const hook = _g2.__SIBU_DEVTOOLS_GLOBAL_HOOK__;
725
869
  if (hook) hook.emit("signal:update", { signal: state, name: debugName, oldValue: prev, newValue });
726
870
  }
727
871
  if (!enqueueBatchedSignal(state)) {
728
- notifySubscribers(state);
872
+ notifySubscribers2(state);
729
873
  }
730
874
  };
731
- } else if (_isDev3) {
875
+ } else if (_isDev4) {
732
876
  set = (next) => {
733
877
  const prev = state.value;
734
878
  const newValue = typeof next === "function" ? next(prev) : next;
@@ -738,7 +882,7 @@ function signal(initial, options) {
738
882
  const hook = _g2.__SIBU_DEVTOOLS_GLOBAL_HOOK__;
739
883
  if (hook) hook.emit("signal:update", { signal: state, name: debugName, oldValue: prev, newValue });
740
884
  if (!enqueueBatchedSignal(state)) {
741
- notifySubscribers(state);
885
+ notifySubscribers2(state);
742
886
  }
743
887
  };
744
888
  } else {
@@ -749,11 +893,11 @@ function signal(initial, options) {
749
893
  state.value = newValue;
750
894
  state.__v++;
751
895
  if (!enqueueBatchedSignal(state)) {
752
- notifySubscribers(state);
896
+ notifySubscribers2(state);
753
897
  }
754
898
  };
755
899
  }
756
- if (_isDev3) {
900
+ if (_isDev4) {
757
901
  const hook = _g2.__SIBU_DEVTOOLS_GLOBAL_HOOK__;
758
902
  if (hook) hook.emit("signal:create", { signal: state, name: debugName, getter: get, initial });
759
903
  }
package/dist/data.js CHANGED
@@ -20,14 +20,14 @@ import {
20
20
  syncAdapter,
21
21
  throttle,
22
22
  withRetry
23
- } from "./chunk-MWZFOIBG.js";
24
- import "./chunk-JBXNCZSC.js";
25
- import "./chunk-CVMMULHO.js";
23
+ } from "./chunk-YUBEOWII.js";
24
+ import "./chunk-5VH3GIDX.js";
25
+ import "./chunk-G6N3LMO2.js";
26
26
  import "./chunk-L3GAGWCC.js";
27
- import "./chunk-7JHWAGRQ.js";
28
- import "./chunk-GOJMFRBL.js";
29
- import "./chunk-5K72I3UQ.js";
30
- import "./chunk-X3NHE2DK.js";
27
+ import "./chunk-N5TQVEKE.js";
28
+ import "./chunk-S3NFJO6L.js";
29
+ import "./chunk-JCQG2I2G.js";
30
+ import "./chunk-4NJEAPLI.js";
31
31
  import "./chunk-COY6PUD2.js";
32
32
  export {
33
33
  __resetQueryCache,