sibujs 3.2.2 → 3.3.1

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 +217 -27
  2. package/dist/browser.js +5 -5
  3. package/dist/build.cjs +236 -105
  4. package/dist/build.js +14 -14
  5. package/dist/cdn.global.js +7 -7
  6. package/dist/{chunk-5N74TKLD.js → chunk-37BUKSLH.js} +1 -1
  7. package/dist/{chunk-BGNLPNGV.js → chunk-4UUMSLSL.js} +4 -4
  8. package/dist/{chunk-2UPRY23K.js → chunk-5VGSK6D2.js} +1 -1
  9. package/dist/{chunk-OYLPZO4N.js → chunk-6LTFHJQG.js} +4 -4
  10. package/dist/{chunk-VOCE4NNK.js → chunk-AMIKDMLP.js} +5 -5
  11. package/dist/{chunk-LMLD24FC.js → chunk-COY6PUD2.js} +7 -1
  12. package/dist/{chunk-YFDGQWDA.js → chunk-F7FXQ3QS.js} +1 -1
  13. package/dist/{chunk-V2MTG5FT.js → chunk-IKLYI3RF.js} +33 -16
  14. package/dist/{chunk-HMJFCBRR.js → chunk-L3GAGWCC.js} +10 -1
  15. package/dist/{chunk-X67UYC74.js → chunk-LU2MQXQQ.js} +14 -24
  16. package/dist/{chunk-4JCAUOLN.js → chunk-M5KBNOSJ.js} +22 -12
  17. package/dist/{chunk-FDY42FIU.js → chunk-MHBCEJQO.js} +2 -2
  18. package/dist/{chunk-RLUJL2MV.js → chunk-NHKQKKZU.js} +6 -7
  19. package/dist/{chunk-HXMS4SNP.js → chunk-R3QEDXFS.js} +2 -2
  20. package/dist/{chunk-NPIEEKPT.js → chunk-RYMOSG5B.js} +6 -6
  21. package/dist/{chunk-H6PCHJZQ.js → chunk-SLMFA3ZZ.js} +11 -3
  22. package/dist/{chunk-Z2FWAE4B.js → chunk-TEFZT5PJ.js} +84 -16
  23. package/dist/{chunk-7XDYVJLE.js → chunk-ULLTNDRA.js} +6 -6
  24. package/dist/{chunk-GOUM4JCT.js → chunk-VOVVTOEA.js} +2 -2
  25. package/dist/{chunk-FOI23UJL.js → chunk-WL7BIR6O.js} +1 -1
  26. package/dist/{chunk-JYXOEYI4.js → chunk-WW6DAGGR.js} +5 -5
  27. package/dist/{chunk-C427DVQF.js → chunk-WZG2SZOT.js} +22 -5
  28. package/dist/{chunk-NFYWLRUO.js → chunk-XH2RTYEQ.js} +3 -3
  29. package/dist/{chunk-2C4E3HBM.js → chunk-Z37APKBV.js} +5 -5
  30. package/dist/{chunk-RDRSWYNP.js → chunk-ZUVLC7TM.js} +1 -1
  31. package/dist/data.cjs +168 -24
  32. package/dist/data.js +8 -8
  33. package/dist/devtools.cjs +252 -32
  34. package/dist/devtools.js +7 -7
  35. package/dist/ecosystem.cjs +205 -64
  36. package/dist/ecosystem.js +10 -10
  37. package/dist/extras.cjs +245 -112
  38. package/dist/extras.js +24 -24
  39. package/dist/index.cjs +236 -105
  40. package/dist/index.d.cts +72 -8
  41. package/dist/index.d.ts +72 -8
  42. package/dist/index.js +14 -14
  43. package/dist/motion.cjs +336 -14
  44. package/dist/motion.js +4 -4
  45. package/dist/patterns.cjs +168 -24
  46. package/dist/patterns.js +6 -6
  47. package/dist/performance.cjs +305 -32
  48. package/dist/performance.js +8 -8
  49. package/dist/plugins.cjs +268 -69
  50. package/dist/plugins.js +12 -12
  51. package/dist/{ssr-2QDQ27EV.js → ssr-6D67RAVB.js} +3 -3
  52. package/dist/ssr.cjs +205 -63
  53. package/dist/ssr.js +11 -11
  54. package/dist/testing.cjs +415 -12
  55. package/dist/testing.js +16 -10
  56. package/dist/ui.cjs +248 -36
  57. package/dist/ui.js +9 -9
  58. package/dist/widgets.cjs +176 -26
  59. package/dist/widgets.js +8 -8
  60. package/package.json +1 -1
package/dist/widgets.cjs CHANGED
@@ -34,7 +34,13 @@ module.exports = __toCommonJS(widgets_exports);
34
34
 
35
35
  // src/core/dev.ts
36
36
  function isDev() {
37
- return typeof globalThis.__SIBU_DEV__ !== "undefined" ? !!globalThis.__SIBU_DEV__ : typeof __SIBU_DEV__ !== "undefined" ? __SIBU_DEV__ : typeof process !== "undefined" && process.env?.NODE_ENV !== "production";
37
+ return typeof globalThis.__SIBU_DEV__ !== "undefined" ? !!globalThis.__SIBU_DEV__ : (
38
+ // The bare `__SIBU_DEV__` is a bundler define that only exists in
39
+ // production builds; under the test runner it is always undefined, so
40
+ // this branch is unreachable here.
41
+ /* v8 ignore next 2 */
42
+ typeof __SIBU_DEV__ !== "undefined" ? __SIBU_DEV__ : typeof process !== "undefined" && process.env?.NODE_ENV !== "production"
43
+ );
38
44
  }
39
45
  var _isDev = isDev();
40
46
  function devAssert(condition, message) {
@@ -48,7 +54,7 @@ function devWarn(message) {
48
54
  }
49
55
  }
50
56
 
51
- // src/reactivity/track.ts
57
+ // src/reactivity/track-core.ts
52
58
  var _isDev2 = isDev();
53
59
  var POOL_MAX = 4096;
54
60
  var nodePool = [];
@@ -132,6 +138,7 @@ function unlinkSub(node) {
132
138
  else sub.depsTail = prev;
133
139
  }
134
140
  var currentSubscriber = null;
141
+ var suspendSavedSub = null;
135
142
  var notifyDepth = 0;
136
143
  var pendingQueue = [];
137
144
  var pendingSet = /* @__PURE__ */ new Set();
@@ -143,7 +150,35 @@ function safeInvoke(sub) {
143
150
  if (_isDev2) devWarn(`Subscriber threw during notification: ${err instanceof Error ? err.message : String(err)}`);
144
151
  }
145
152
  }
153
+ var suspendDepth = 0;
146
154
  var trackingSuspended = false;
155
+ function suspendTracking() {
156
+ if (suspendDepth === 0) {
157
+ suspendSavedSub = currentSubscriber;
158
+ currentSubscriber = null;
159
+ trackingSuspended = true;
160
+ }
161
+ suspendDepth++;
162
+ }
163
+ function resumeTracking() {
164
+ suspendDepth--;
165
+ if (suspendDepth === 0) {
166
+ currentSubscriber = suspendSavedSub;
167
+ suspendSavedSub = null;
168
+ trackingSuspended = false;
169
+ }
170
+ }
171
+ function isTrackingSuspended() {
172
+ return trackingSuspended;
173
+ }
174
+ function untracked(fn) {
175
+ suspendTracking();
176
+ try {
177
+ return fn();
178
+ } finally {
179
+ resumeTracking();
180
+ }
181
+ }
147
182
  var subscriberEpochCounter = 0;
148
183
  function retrack(effectFn, subscriber) {
149
184
  const prev = currentSubscriber;
@@ -253,6 +288,16 @@ function cleanup(subscriber) {
253
288
  var maxSubscriberRepeats = 50;
254
289
  var maxDrainIterations = 1e6;
255
290
  var drainEpoch = 0;
291
+ function setMaxSubscriberRepeats(n) {
292
+ const prev = maxSubscriberRepeats;
293
+ if (Number.isFinite(n) && n > 0) maxSubscriberRepeats = Math.floor(n);
294
+ return prev;
295
+ }
296
+ function setMaxDrainIterations(n) {
297
+ const prev = maxDrainIterations;
298
+ if (Number.isFinite(n) && n > 0) maxDrainIterations = Math.floor(n);
299
+ return prev;
300
+ }
256
301
  function tickRepeat(sub) {
257
302
  const s = sub;
258
303
  if (s._runEpoch !== drainEpoch) {
@@ -401,6 +446,85 @@ function notifySubscribers(signal2) {
401
446
  }
402
447
  }
403
448
  }
449
+ function getSubscriberCount(signal2) {
450
+ return signal2.__sc ?? 0;
451
+ }
452
+ function getSubscriberDeps(subscriber) {
453
+ const sub = subscriber;
454
+ const out = [];
455
+ let node = sub.depsHead ?? null;
456
+ while (node) {
457
+ if (node.sig) out.push(node.sig);
458
+ node = node.subNext;
459
+ }
460
+ return out;
461
+ }
462
+ function forEachSubscriber(signal2, visit) {
463
+ let node = signal2.subsHead ?? null;
464
+ while (node) {
465
+ const s = node.sub;
466
+ if (s) visit(s);
467
+ node = node.sigNext;
468
+ }
469
+ }
470
+
471
+ // src/reactivity/track.ts
472
+ var _isDev3 = isDev();
473
+ var _runtimeVersion = typeof __SIBU_VERSION__ !== "undefined" ? __SIBU_VERSION__ : "dev";
474
+ var REGISTRY_KEY = /* @__PURE__ */ Symbol.for("sibujs.reactive.v1");
475
+ function resolveReactiveApi() {
476
+ const g = globalThis;
477
+ const existing = g[REGISTRY_KEY];
478
+ if (existing) {
479
+ if (_isDev3 && !existing.__dupWarned) {
480
+ existing.__dupWarned = true;
481
+ devWarn(
482
+ `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']).`
483
+ );
484
+ }
485
+ return existing;
486
+ }
487
+ const local = {
488
+ suspendTracking,
489
+ resumeTracking,
490
+ isTrackingSuspended,
491
+ untracked,
492
+ retrack,
493
+ track,
494
+ reactiveBinding,
495
+ recordDependency,
496
+ cleanup,
497
+ setMaxSubscriberRepeats,
498
+ setMaxDrainIterations,
499
+ drainNotificationQueue,
500
+ queueSignalNotification,
501
+ notifySubscribers,
502
+ getSubscriberCount,
503
+ getSubscriberDeps,
504
+ forEachSubscriber,
505
+ version: _runtimeVersion
506
+ };
507
+ g[REGISTRY_KEY] = local;
508
+ return local;
509
+ }
510
+ var API = resolveReactiveApi();
511
+ var suspendTracking2 = API.suspendTracking;
512
+ var resumeTracking2 = API.resumeTracking;
513
+ var isTrackingSuspended2 = API.isTrackingSuspended;
514
+ var untracked2 = API.untracked;
515
+ var retrack2 = API.retrack;
516
+ var track2 = API.track;
517
+ var reactiveBinding2 = API.reactiveBinding;
518
+ var recordDependency2 = API.recordDependency;
519
+ var cleanup2 = API.cleanup;
520
+ var setMaxSubscriberRepeats2 = API.setMaxSubscriberRepeats;
521
+ var setMaxDrainIterations2 = API.setMaxDrainIterations;
522
+ var drainNotificationQueue2 = API.drainNotificationQueue;
523
+ var queueSignalNotification2 = API.queueSignalNotification;
524
+ var notifySubscribers2 = API.notifySubscribers;
525
+ var getSubscriberCount2 = API.getSubscriberCount;
526
+ var getSubscriberDeps2 = API.getSubscriberDeps;
527
+ var forEachSubscriber2 = API.forEachSubscriber;
404
528
 
405
529
  // src/core/signals/derived.ts
406
530
  function derived(getter, options) {
@@ -424,7 +548,7 @@ function derived(getter, options) {
424
548
  cs._d = false;
425
549
  cs._init = true;
426
550
  };
427
- track(() => {
551
+ track2(() => {
428
552
  let threw = true;
429
553
  try {
430
554
  cs._v = getter();
@@ -443,12 +567,12 @@ function derived(getter, options) {
443
567
  `[SibuJS] Circular dependency detected in derived${debugName ? ` "${debugName}"` : ""}. A derived signal cannot read itself (directly or through a chain).`
444
568
  );
445
569
  }
446
- if (trackingSuspended) {
570
+ if (isTrackingSuspended2()) {
447
571
  if (cs._d) {
448
572
  const prev = cs._v;
449
573
  evaluating = true;
450
574
  try {
451
- retrack(recompute, markDirty);
575
+ retrack2(recompute, markDirty);
452
576
  if (!Object.is(prev, cs._v)) cs.__v++;
453
577
  } finally {
454
578
  evaluating = false;
@@ -456,12 +580,12 @@ function derived(getter, options) {
456
580
  }
457
581
  return cs._v;
458
582
  }
459
- recordDependency(cs);
583
+ recordDependency2(cs);
460
584
  if (cs._d) {
461
585
  const oldValue = cs._v;
462
586
  evaluating = true;
463
587
  try {
464
- retrack(recompute, markDirty);
588
+ retrack2(recompute, markDirty);
465
589
  if (!Object.is(oldValue, cs._v)) cs.__v++;
466
590
  } finally {
467
591
  evaluating = false;
@@ -530,7 +654,7 @@ function drainReruns(ctx) {
530
654
  do {
531
655
  ctx.rerunPending = false;
532
656
  if (ctx.userCleanups.length > 0) flushUserCleanups(ctx);
533
- retrack(ctx.bodyFn, ctx.subscriber);
657
+ retrack2(ctx.bodyFn, ctx.subscriber);
534
658
  } while (ctx.rerunPending && ++reruns <= MAX_RERUNS);
535
659
  if (ctx.rerunPending) {
536
660
  ctx.rerunPending = false;
@@ -559,7 +683,7 @@ function disposeEffect(ctx) {
559
683
  }
560
684
  }
561
685
  try {
562
- cleanup(ctx.subscriber);
686
+ cleanup2(ctx.subscriber);
563
687
  } catch (err) {
564
688
  if (typeof console !== "undefined") {
565
689
  console.warn("[SibuJS effect] dispose threw:", err);
@@ -604,7 +728,7 @@ function effect(effectFn, options) {
604
728
  try {
605
729
  ctx.rerunPending = false;
606
730
  if (ctx.userCleanups.length > 0) flushUserCleanups(ctx);
607
- retrack(ctx.bodyFn, sub);
731
+ retrack2(ctx.bodyFn, sub);
608
732
  if (ctx.rerunPending) drainReruns(ctx);
609
733
  } finally {
610
734
  ctx.running = false;
@@ -620,7 +744,7 @@ function effect(effectFn, options) {
620
744
  ctx.subscriber = sub;
621
745
  ctx.running = true;
622
746
  try {
623
- retrack(ctx.bodyFn, ctx.subscriber);
747
+ retrack2(ctx.bodyFn, ctx.subscriber);
624
748
  if (ctx.rerunPending) drainReruns(ctx);
625
749
  } finally {
626
750
  ctx.running = false;
@@ -634,7 +758,7 @@ function effect(effectFn, options) {
634
758
  // src/reactivity/batch.ts
635
759
  var batchDepth = 0;
636
760
  var pendingSignals = /* @__PURE__ */ new Set();
637
- function batch(fn) {
761
+ function batchImpl(fn) {
638
762
  batchDepth++;
639
763
  try {
640
764
  return fn();
@@ -645,25 +769,45 @@ function batch(fn) {
645
769
  }
646
770
  }
647
771
  }
648
- function enqueueBatchedSignal(signal2) {
772
+ function enqueueBatchedSignalImpl(signal2) {
649
773
  if (batchDepth === 0) return false;
650
774
  pendingSignals.add(signal2);
651
775
  return true;
652
776
  }
777
+ function isBatchingImpl() {
778
+ return batchDepth > 0;
779
+ }
653
780
  function flushBatch() {
654
781
  try {
655
782
  for (const signal2 of pendingSignals) {
656
- queueSignalNotification(signal2);
783
+ queueSignalNotification2(signal2);
657
784
  }
658
785
  } finally {
659
786
  pendingSignals.clear();
660
787
  }
661
- drainNotificationQueue();
788
+ drainNotificationQueue2();
789
+ }
790
+ var BATCH_REGISTRY_KEY = /* @__PURE__ */ Symbol.for("sibujs.reactive.batch.v1");
791
+ function resolveBatchApi() {
792
+ const g = globalThis;
793
+ const existing = g[BATCH_REGISTRY_KEY];
794
+ if (existing) return existing;
795
+ const local = {
796
+ batch: batchImpl,
797
+ enqueueBatchedSignal: enqueueBatchedSignalImpl,
798
+ isBatching: isBatchingImpl
799
+ };
800
+ g[BATCH_REGISTRY_KEY] = local;
801
+ return local;
662
802
  }
803
+ var API2 = resolveBatchApi();
804
+ var batch = API2.batch;
805
+ var enqueueBatchedSignal = API2.enqueueBatchedSignal;
806
+ var isBatching = API2.isBatching;
663
807
 
664
808
  // src/core/signals/signal.ts
665
809
  var _g2 = globalThis;
666
- var _isDev3 = isDev();
810
+ var _isDev4 = isDev();
667
811
  function signal(initial, options) {
668
812
  const state = {
669
813
  value: initial,
@@ -674,11 +818,11 @@ function signal(initial, options) {
674
818
  __activeNode: null,
675
819
  __name: void 0
676
820
  };
677
- const debugName = _isDev3 ? options?.name : void 0;
821
+ const debugName = _isDev4 ? options?.name : void 0;
678
822
  const equalsFn = options?.equals;
679
823
  if (debugName) state.__name = debugName;
680
824
  function get() {
681
- recordDependency(state);
825
+ recordDependency2(state);
682
826
  return state.value;
683
827
  }
684
828
  get.__signal = state;
@@ -691,15 +835,15 @@ function signal(initial, options) {
691
835
  if (equalsFn(prev, newValue)) return;
692
836
  state.value = newValue;
693
837
  state.__v++;
694
- if (_isDev3) {
838
+ if (_isDev4) {
695
839
  const hook = _g2.__SIBU_DEVTOOLS_GLOBAL_HOOK__;
696
840
  if (hook) hook.emit("signal:update", { signal: state, name: debugName, oldValue: prev, newValue });
697
841
  }
698
842
  if (!enqueueBatchedSignal(state)) {
699
- notifySubscribers(state);
843
+ notifySubscribers2(state);
700
844
  }
701
845
  };
702
- } else if (_isDev3) {
846
+ } else if (_isDev4) {
703
847
  set = (next) => {
704
848
  const prev = state.value;
705
849
  const newValue = typeof next === "function" ? next(prev) : next;
@@ -709,7 +853,7 @@ function signal(initial, options) {
709
853
  const hook = _g2.__SIBU_DEVTOOLS_GLOBAL_HOOK__;
710
854
  if (hook) hook.emit("signal:update", { signal: state, name: debugName, oldValue: prev, newValue });
711
855
  if (!enqueueBatchedSignal(state)) {
712
- notifySubscribers(state);
856
+ notifySubscribers2(state);
713
857
  }
714
858
  };
715
859
  } else {
@@ -720,11 +864,11 @@ function signal(initial, options) {
720
864
  state.value = newValue;
721
865
  state.__v++;
722
866
  if (!enqueueBatchedSignal(state)) {
723
- notifySubscribers(state);
867
+ notifySubscribers2(state);
724
868
  }
725
869
  };
726
870
  }
727
- if (_isDev3) {
871
+ if (_isDev4) {
728
872
  const hook = _g2.__SIBU_DEVTOOLS_GLOBAL_HOOK__;
729
873
  if (hook) hook.emit("signal:create", { signal: state, name: debugName, getter: get, initial });
730
874
  }
@@ -747,11 +891,17 @@ function watch(getter, callback) {
747
891
  return;
748
892
  }
749
893
  if (!Object.is(newValue, oldValue)) {
750
- callback(newValue, oldValue);
894
+ const prev = oldValue;
751
895
  oldValue = newValue;
896
+ suspendTracking2();
897
+ try {
898
+ callback(newValue, prev);
899
+ } finally {
900
+ resumeTracking2();
901
+ }
752
902
  }
753
903
  };
754
- const teardown = track(subscriber);
904
+ const teardown = track2(subscriber);
755
905
  return teardown;
756
906
  }
757
907
 
package/dist/widgets.js CHANGED
@@ -8,15 +8,15 @@ import {
8
8
  select,
9
9
  tabs,
10
10
  tooltip
11
- } from "./chunk-2C4E3HBM.js";
12
- import "./chunk-H6PCHJZQ.js";
13
- import "./chunk-JYXOEYI4.js";
14
- import "./chunk-HMJFCBRR.js";
15
- import "./chunk-FDY42FIU.js";
11
+ } from "./chunk-Z37APKBV.js";
12
+ import "./chunk-SLMFA3ZZ.js";
13
+ import "./chunk-WW6DAGGR.js";
14
+ import "./chunk-L3GAGWCC.js";
15
+ import "./chunk-MHBCEJQO.js";
16
16
  import "./chunk-GOJMFRBL.js";
17
- import "./chunk-C427DVQF.js";
18
- import "./chunk-Z2FWAE4B.js";
19
- import "./chunk-LMLD24FC.js";
17
+ import "./chunk-WZG2SZOT.js";
18
+ import "./chunk-TEFZT5PJ.js";
19
+ import "./chunk-COY6PUD2.js";
20
20
  export {
21
21
  accordion,
22
22
  combobox,
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "sibujs",
3
- "version": "3.2.2",
3
+ "version": "3.3.1",
4
4
  "description": "A lightweight, function-based frontend framework that combines the best of React, Svelte, and Vue — with zero VDOM and maximum simplicity. Designed for developers who want fine-grained reactivity and full control without compilation or magic.",
5
5
  "keywords": [
6
6
  "frontend",