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/motion.cjs CHANGED
@@ -288,7 +288,13 @@ async function sequence(steps) {
288
288
 
289
289
  // src/core/dev.ts
290
290
  function isDev() {
291
- return typeof globalThis.__SIBU_DEV__ !== "undefined" ? !!globalThis.__SIBU_DEV__ : typeof __SIBU_DEV__ !== "undefined" ? __SIBU_DEV__ : typeof process !== "undefined" && process.env?.NODE_ENV !== "production";
291
+ return typeof globalThis.__SIBU_DEV__ !== "undefined" ? !!globalThis.__SIBU_DEV__ : (
292
+ // The bare `__SIBU_DEV__` is a bundler define that only exists in
293
+ // production builds; under the test runner it is always undefined, so
294
+ // this branch is unreachable here.
295
+ /* v8 ignore next 2 */
296
+ typeof __SIBU_DEV__ !== "undefined" ? __SIBU_DEV__ : typeof process !== "undefined" && process.env?.NODE_ENV !== "production"
297
+ );
292
298
  }
293
299
  var _isDev = isDev();
294
300
  function devWarn(message) {
@@ -297,8 +303,9 @@ function devWarn(message) {
297
303
  }
298
304
  }
299
305
 
300
- // src/reactivity/track.ts
306
+ // src/reactivity/track-core.ts
301
307
  var _isDev2 = isDev();
308
+ var POOL_MAX = 4096;
302
309
  var nodePool = [];
303
310
  function createNode() {
304
311
  return {
@@ -326,6 +333,16 @@ function allocNode(sig, sub, epoch) {
326
333
  fresh.epoch = epoch;
327
334
  return fresh;
328
335
  }
336
+ function freeNode(node) {
337
+ node.sig = null;
338
+ node.sub = null;
339
+ node.sigPrev = null;
340
+ node.sigNext = null;
341
+ node.subPrev = null;
342
+ node.subNext = null;
343
+ node.prevActive = null;
344
+ if (nodePool.length < POOL_MAX) nodePool.push(node);
345
+ }
329
346
  function linkSignal(sig, node) {
330
347
  const oldHead = sig.subsHead ?? null;
331
348
  node.sigPrev = null;
@@ -335,6 +352,22 @@ function linkSignal(sig, node) {
335
352
  sig.subsHead = node;
336
353
  sig.__sc = (sig.__sc ?? 0) + 1;
337
354
  }
355
+ function unlinkSignal(node) {
356
+ const sig = node.sig;
357
+ if (!sig) return;
358
+ const prev = node.sigPrev;
359
+ const next = node.sigNext;
360
+ if (prev) prev.sigNext = next;
361
+ else sig.subsHead = next;
362
+ if (next) next.sigPrev = prev;
363
+ else sig.subsTail = prev;
364
+ sig.__sc = (sig.__sc ?? 1) - 1;
365
+ if (sig.__activeNode === node) sig.__activeNode = node.prevActive;
366
+ if (sig.__sc === 0) {
367
+ sig.subsHead = null;
368
+ sig.subsTail = null;
369
+ }
370
+ }
338
371
  function linkSub(sub, node) {
339
372
  const oldTail = sub.depsTail ?? null;
340
373
  node.subPrev = oldTail;
@@ -343,7 +376,18 @@ function linkSub(sub, node) {
343
376
  else sub.depsHead = node;
344
377
  sub.depsTail = node;
345
378
  }
379
+ function unlinkSub(node) {
380
+ const sub = node.sub;
381
+ if (!sub) return;
382
+ const prev = node.subPrev;
383
+ const next = node.subNext;
384
+ if (prev) prev.subNext = next;
385
+ else sub.depsHead = next;
386
+ if (next) next.subPrev = prev;
387
+ else sub.depsTail = prev;
388
+ }
346
389
  var currentSubscriber = null;
390
+ var suspendSavedSub = null;
347
391
  var notifyDepth = 0;
348
392
  var pendingQueue = [];
349
393
  var pendingSet = /* @__PURE__ */ new Set();
@@ -355,6 +399,112 @@ function safeInvoke(sub) {
355
399
  if (_isDev2) devWarn(`Subscriber threw during notification: ${err instanceof Error ? err.message : String(err)}`);
356
400
  }
357
401
  }
402
+ var suspendDepth = 0;
403
+ var trackingSuspended = false;
404
+ function suspendTracking() {
405
+ if (suspendDepth === 0) {
406
+ suspendSavedSub = currentSubscriber;
407
+ currentSubscriber = null;
408
+ trackingSuspended = true;
409
+ }
410
+ suspendDepth++;
411
+ }
412
+ function resumeTracking() {
413
+ suspendDepth--;
414
+ if (suspendDepth === 0) {
415
+ currentSubscriber = suspendSavedSub;
416
+ suspendSavedSub = null;
417
+ trackingSuspended = false;
418
+ }
419
+ }
420
+ function isTrackingSuspended() {
421
+ return trackingSuspended;
422
+ }
423
+ function untracked(fn) {
424
+ suspendTracking();
425
+ try {
426
+ return fn();
427
+ } finally {
428
+ resumeTracking();
429
+ }
430
+ }
431
+ var subscriberEpochCounter = 0;
432
+ function retrack(effectFn, subscriber) {
433
+ const prev = currentSubscriber;
434
+ currentSubscriber = subscriber;
435
+ const sub = subscriber;
436
+ const epoch = ++subscriberEpochCounter;
437
+ sub._epoch = epoch;
438
+ sub._structDirty = false;
439
+ for (let n = sub.depsHead ?? null; n !== null; n = n.subNext) {
440
+ const sig = n.sig;
441
+ n.prevActive = sig.__activeNode ?? null;
442
+ sig.__activeNode = n;
443
+ }
444
+ try {
445
+ effectFn();
446
+ } finally {
447
+ currentSubscriber = prev;
448
+ let node = sub.depsHead ?? null;
449
+ while (node !== null) {
450
+ const next = node.subNext;
451
+ const sig = node.sig;
452
+ sig.__activeNode = node.prevActive;
453
+ node.prevActive = null;
454
+ if (node.epoch !== epoch) {
455
+ unlinkSub(node);
456
+ unlinkSignal(node);
457
+ freeNode(node);
458
+ }
459
+ node = next;
460
+ }
461
+ }
462
+ }
463
+ function track(effectFn, subscriber) {
464
+ if (!subscriber) return reactiveBinding(effectFn);
465
+ cleanup(subscriber);
466
+ const prev = currentSubscriber;
467
+ currentSubscriber = subscriber;
468
+ try {
469
+ effectFn();
470
+ } finally {
471
+ currentSubscriber = prev;
472
+ const sub2 = subscriber;
473
+ for (let n = sub2.depsHead ?? null; n !== null; n = n.subNext) {
474
+ const sig = n.sig;
475
+ sig.__activeNode = n.prevActive;
476
+ n.prevActive = null;
477
+ }
478
+ }
479
+ const sub = subscriber;
480
+ return sub._dispose ?? (sub._dispose = () => cleanup(subscriber));
481
+ }
482
+ function reactiveBinding(commit) {
483
+ const run = () => {
484
+ const s = subscriber;
485
+ if (s._disposed || s._reentrant) return;
486
+ s._reentrant = true;
487
+ try {
488
+ retrack(commit, subscriber);
489
+ } finally {
490
+ s._reentrant = false;
491
+ }
492
+ };
493
+ const subscriber = run;
494
+ subscriber.depsHead = null;
495
+ subscriber.depsTail = null;
496
+ subscriber._epoch = 0;
497
+ subscriber._structDirty = false;
498
+ subscriber._runEpoch = 0;
499
+ subscriber._runs = 0;
500
+ subscriber._reentrant = false;
501
+ subscriber._disposed = false;
502
+ run();
503
+ return subscriber._dispose ?? (subscriber._dispose = () => {
504
+ subscriber._disposed = true;
505
+ cleanup(subscriber);
506
+ });
507
+ }
358
508
  function recordDependency(signal2) {
359
509
  if (!currentSubscriber) return;
360
510
  const sub = currentSubscriber;
@@ -372,9 +522,31 @@ function recordDependency(signal2) {
372
522
  linkSignal(sig, node);
373
523
  sub._structDirty = true;
374
524
  }
525
+ function cleanup(subscriber) {
526
+ const sub = subscriber;
527
+ let node = sub.depsHead ?? null;
528
+ sub.depsHead = null;
529
+ sub.depsTail = null;
530
+ while (node) {
531
+ const next = node.subNext;
532
+ unlinkSignal(node);
533
+ freeNode(node);
534
+ node = next;
535
+ }
536
+ }
375
537
  var maxSubscriberRepeats = 50;
376
538
  var maxDrainIterations = 1e6;
377
539
  var drainEpoch = 0;
540
+ function setMaxSubscriberRepeats(n) {
541
+ const prev = maxSubscriberRepeats;
542
+ if (Number.isFinite(n) && n > 0) maxSubscriberRepeats = Math.floor(n);
543
+ return prev;
544
+ }
545
+ function setMaxDrainIterations(n) {
546
+ const prev = maxDrainIterations;
547
+ if (Number.isFinite(n) && n > 0) maxDrainIterations = Math.floor(n);
548
+ return prev;
549
+ }
378
550
  function tickRepeat(sub) {
379
551
  const s = sub;
380
552
  if (s._runEpoch !== drainEpoch) {
@@ -416,6 +588,20 @@ function drainQueue() {
416
588
  safeInvoke(sub);
417
589
  }
418
590
  }
591
+ function drainNotificationQueue() {
592
+ if (notifyDepth > 0) return;
593
+ notifyDepth++;
594
+ drainEpoch++;
595
+ try {
596
+ drainQueue();
597
+ } finally {
598
+ notifyDepth--;
599
+ if (notifyDepth === 0) {
600
+ pendingQueue.length = 0;
601
+ pendingSet.clear();
602
+ }
603
+ }
604
+ }
419
605
  function propagateDirty(sub) {
420
606
  sub();
421
607
  const rootSig = sub._sig;
@@ -448,6 +634,22 @@ function propagateDirty(sub) {
448
634
  }
449
635
  }
450
636
  }
637
+ function queueSignalNotification(signal2) {
638
+ const sig = signal2;
639
+ let node = sig.subsHead ?? null;
640
+ while (node) {
641
+ const s = node.sub;
642
+ if (s) {
643
+ if (s._c) {
644
+ propagateDirty(s);
645
+ } else if (!pendingSet.has(s)) {
646
+ pendingSet.add(s);
647
+ pendingQueue.push(s);
648
+ }
649
+ }
650
+ node = node.sigNext;
651
+ }
652
+ }
451
653
  function notifySubscribers(signal2) {
452
654
  const sig = signal2;
453
655
  const head = sig.subsHead;
@@ -493,19 +695,139 @@ function notifySubscribers(signal2) {
493
695
  }
494
696
  }
495
697
  }
698
+ function getSubscriberCount(signal2) {
699
+ return signal2.__sc ?? 0;
700
+ }
701
+ function getSubscriberDeps(subscriber) {
702
+ const sub = subscriber;
703
+ const out = [];
704
+ let node = sub.depsHead ?? null;
705
+ while (node) {
706
+ if (node.sig) out.push(node.sig);
707
+ node = node.subNext;
708
+ }
709
+ return out;
710
+ }
711
+ function forEachSubscriber(signal2, visit) {
712
+ let node = signal2.subsHead ?? null;
713
+ while (node) {
714
+ const s = node.sub;
715
+ if (s) visit(s);
716
+ node = node.sigNext;
717
+ }
718
+ }
719
+
720
+ // src/reactivity/track.ts
721
+ var _isDev3 = isDev();
722
+ var _runtimeVersion = typeof __SIBU_VERSION__ !== "undefined" ? __SIBU_VERSION__ : "dev";
723
+ var REGISTRY_KEY = /* @__PURE__ */ Symbol.for("sibujs.reactive.v1");
724
+ function resolveReactiveApi() {
725
+ const g = globalThis;
726
+ const existing = g[REGISTRY_KEY];
727
+ if (existing) {
728
+ if (_isDev3 && !existing.__dupWarned) {
729
+ existing.__dupWarned = true;
730
+ devWarn(
731
+ `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']).`
732
+ );
733
+ }
734
+ return existing;
735
+ }
736
+ const local = {
737
+ suspendTracking,
738
+ resumeTracking,
739
+ isTrackingSuspended,
740
+ untracked,
741
+ retrack,
742
+ track,
743
+ reactiveBinding,
744
+ recordDependency,
745
+ cleanup,
746
+ setMaxSubscriberRepeats,
747
+ setMaxDrainIterations,
748
+ drainNotificationQueue,
749
+ queueSignalNotification,
750
+ notifySubscribers,
751
+ getSubscriberCount,
752
+ getSubscriberDeps,
753
+ forEachSubscriber,
754
+ version: _runtimeVersion
755
+ };
756
+ g[REGISTRY_KEY] = local;
757
+ return local;
758
+ }
759
+ var API = resolveReactiveApi();
760
+ var suspendTracking2 = API.suspendTracking;
761
+ var resumeTracking2 = API.resumeTracking;
762
+ var isTrackingSuspended2 = API.isTrackingSuspended;
763
+ var untracked2 = API.untracked;
764
+ var retrack2 = API.retrack;
765
+ var track2 = API.track;
766
+ var reactiveBinding2 = API.reactiveBinding;
767
+ var recordDependency2 = API.recordDependency;
768
+ var cleanup2 = API.cleanup;
769
+ var setMaxSubscriberRepeats2 = API.setMaxSubscriberRepeats;
770
+ var setMaxDrainIterations2 = API.setMaxDrainIterations;
771
+ var drainNotificationQueue2 = API.drainNotificationQueue;
772
+ var queueSignalNotification2 = API.queueSignalNotification;
773
+ var notifySubscribers2 = API.notifySubscribers;
774
+ var getSubscriberCount2 = API.getSubscriberCount;
775
+ var getSubscriberDeps2 = API.getSubscriberDeps;
776
+ var forEachSubscriber2 = API.forEachSubscriber;
496
777
 
497
778
  // src/reactivity/batch.ts
498
779
  var batchDepth = 0;
499
780
  var pendingSignals = /* @__PURE__ */ new Set();
500
- function enqueueBatchedSignal(signal2) {
781
+ function batchImpl(fn) {
782
+ batchDepth++;
783
+ try {
784
+ return fn();
785
+ } finally {
786
+ batchDepth--;
787
+ if (batchDepth === 0) {
788
+ flushBatch();
789
+ }
790
+ }
791
+ }
792
+ function enqueueBatchedSignalImpl(signal2) {
501
793
  if (batchDepth === 0) return false;
502
794
  pendingSignals.add(signal2);
503
795
  return true;
504
796
  }
797
+ function isBatchingImpl() {
798
+ return batchDepth > 0;
799
+ }
800
+ function flushBatch() {
801
+ try {
802
+ for (const signal2 of pendingSignals) {
803
+ queueSignalNotification2(signal2);
804
+ }
805
+ } finally {
806
+ pendingSignals.clear();
807
+ }
808
+ drainNotificationQueue2();
809
+ }
810
+ var BATCH_REGISTRY_KEY = /* @__PURE__ */ Symbol.for("sibujs.reactive.batch.v1");
811
+ function resolveBatchApi() {
812
+ const g = globalThis;
813
+ const existing = g[BATCH_REGISTRY_KEY];
814
+ if (existing) return existing;
815
+ const local = {
816
+ batch: batchImpl,
817
+ enqueueBatchedSignal: enqueueBatchedSignalImpl,
818
+ isBatching: isBatchingImpl
819
+ };
820
+ g[BATCH_REGISTRY_KEY] = local;
821
+ return local;
822
+ }
823
+ var API2 = resolveBatchApi();
824
+ var batch = API2.batch;
825
+ var enqueueBatchedSignal = API2.enqueueBatchedSignal;
826
+ var isBatching = API2.isBatching;
505
827
 
506
828
  // src/core/signals/signal.ts
507
829
  var _g = globalThis;
508
- var _isDev3 = isDev();
830
+ var _isDev4 = isDev();
509
831
  function signal(initial, options) {
510
832
  const state = {
511
833
  value: initial,
@@ -516,11 +838,11 @@ function signal(initial, options) {
516
838
  __activeNode: null,
517
839
  __name: void 0
518
840
  };
519
- const debugName = _isDev3 ? options?.name : void 0;
841
+ const debugName = _isDev4 ? options?.name : void 0;
520
842
  const equalsFn = options?.equals;
521
843
  if (debugName) state.__name = debugName;
522
844
  function get() {
523
- recordDependency(state);
845
+ recordDependency2(state);
524
846
  return state.value;
525
847
  }
526
848
  get.__signal = state;
@@ -533,15 +855,15 @@ function signal(initial, options) {
533
855
  if (equalsFn(prev, newValue)) return;
534
856
  state.value = newValue;
535
857
  state.__v++;
536
- if (_isDev3) {
858
+ if (_isDev4) {
537
859
  const hook = _g.__SIBU_DEVTOOLS_GLOBAL_HOOK__;
538
860
  if (hook) hook.emit("signal:update", { signal: state, name: debugName, oldValue: prev, newValue });
539
861
  }
540
862
  if (!enqueueBatchedSignal(state)) {
541
- notifySubscribers(state);
863
+ notifySubscribers2(state);
542
864
  }
543
865
  };
544
- } else if (_isDev3) {
866
+ } else if (_isDev4) {
545
867
  set = (next) => {
546
868
  const prev = state.value;
547
869
  const newValue = typeof next === "function" ? next(prev) : next;
@@ -551,7 +873,7 @@ function signal(initial, options) {
551
873
  const hook = _g.__SIBU_DEVTOOLS_GLOBAL_HOOK__;
552
874
  if (hook) hook.emit("signal:update", { signal: state, name: debugName, oldValue: prev, newValue });
553
875
  if (!enqueueBatchedSignal(state)) {
554
- notifySubscribers(state);
876
+ notifySubscribers2(state);
555
877
  }
556
878
  };
557
879
  } else {
@@ -562,11 +884,11 @@ function signal(initial, options) {
562
884
  state.value = newValue;
563
885
  state.__v++;
564
886
  if (!enqueueBatchedSignal(state)) {
565
- notifySubscribers(state);
887
+ notifySubscribers2(state);
566
888
  }
567
889
  };
568
890
  }
569
- if (_isDev3) {
891
+ if (_isDev4) {
570
892
  const hook = _g.__SIBU_DEVTOOLS_GLOBAL_HOOK__;
571
893
  if (hook) hook.emit("signal:create", { signal: state, name: debugName, getter: get, initial });
572
894
  }
@@ -589,7 +911,7 @@ function TransitionGroup(options) {
589
911
  }
590
912
  setElements((prev) => prev.filter((e) => e !== el));
591
913
  }
592
- function track(newElements) {
914
+ function track3(newElements) {
593
915
  const oldPositions = /* @__PURE__ */ new Map();
594
916
  for (const el of elements()) {
595
917
  if (typeof el.getBoundingClientRect === "function") {
@@ -631,7 +953,7 @@ function TransitionGroup(options) {
631
953
  }
632
954
  }
633
955
  }
634
- return { add, remove, track };
956
+ return { add, remove, track: track3 };
635
957
  }
636
958
 
637
959
  // src/ui/viewTransition.ts
package/dist/motion.js CHANGED
@@ -19,10 +19,10 @@ import {
19
19
  stagger,
20
20
  transition,
21
21
  viewTransition
22
- } from "./chunk-FOI23UJL.js";
23
- import "./chunk-C427DVQF.js";
24
- import "./chunk-Z2FWAE4B.js";
25
- import "./chunk-LMLD24FC.js";
22
+ } from "./chunk-WL7BIR6O.js";
23
+ import "./chunk-WZG2SZOT.js";
24
+ import "./chunk-TEFZT5PJ.js";
25
+ import "./chunk-COY6PUD2.js";
26
26
  export {
27
27
  TransitionGroup,
28
28
  animate,