sibujs 3.3.0 → 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 (54) hide show
  1. package/dist/browser.cjs +210 -26
  2. package/dist/browser.js +4 -4
  3. package/dist/build.cjs +193 -89
  4. package/dist/build.js +10 -10
  5. package/dist/cdn.global.js +7 -7
  6. package/dist/{chunk-24DBWDTK.js → chunk-37BUKSLH.js} +1 -1
  7. package/dist/{chunk-IHBVTURX.js → chunk-4UUMSLSL.js} +4 -4
  8. package/dist/{chunk-USDR2GFV.js → chunk-6LTFHJQG.js} +3 -3
  9. package/dist/{chunk-MWZFOIBG.js → chunk-AMIKDMLP.js} +4 -4
  10. package/dist/{chunk-JBXNCZSC.js → chunk-F7FXQ3QS.js} +1 -1
  11. package/dist/{chunk-BEIKESVL.js → chunk-IKLYI3RF.js} +9 -9
  12. package/dist/{chunk-NUWKIEHE.js → chunk-LU2MQXQQ.js} +2 -2
  13. package/dist/{chunk-WVJJUFPC.js → chunk-M5KBNOSJ.js} +2 -2
  14. package/dist/{chunk-7JHWAGRQ.js → chunk-MHBCEJQO.js} +1 -1
  15. package/dist/{chunk-Q2ERM6NT.js → chunk-NHKQKKZU.js} +1 -1
  16. package/dist/{chunk-6G6UNHZI.js → chunk-RYMOSG5B.js} +5 -5
  17. package/dist/{chunk-F4UM7QBJ.js → chunk-SLMFA3ZZ.js} +1 -1
  18. package/dist/{chunk-X3NHE2DK.js → chunk-TEFZT5PJ.js} +83 -17
  19. package/dist/{chunk-SLCUP2EK.js → chunk-ULLTNDRA.js} +3 -3
  20. package/dist/{chunk-M6WSIGYW.js → chunk-VOVVTOEA.js} +2 -2
  21. package/dist/{chunk-XQ7XSGYP.js → chunk-WL7BIR6O.js} +1 -1
  22. package/dist/{chunk-CVMMULHO.js → chunk-WW6DAGGR.js} +4 -4
  23. package/dist/{chunk-5K72I3UQ.js → chunk-WZG2SZOT.js} +21 -4
  24. package/dist/{chunk-S4FHR5ZZ.js → chunk-XH2RTYEQ.js} +3 -3
  25. package/dist/{chunk-4WXWJ4SW.js → chunk-Z37APKBV.js} +4 -4
  26. package/dist/data.cjs +161 -23
  27. package/dist/data.js +6 -6
  28. package/dist/devtools.cjs +245 -31
  29. package/dist/devtools.js +4 -4
  30. package/dist/ecosystem.cjs +183 -45
  31. package/dist/ecosystem.js +7 -7
  32. package/dist/extras.cjs +185 -86
  33. package/dist/extras.js +19 -19
  34. package/dist/index.cjs +193 -89
  35. package/dist/index.d.cts +59 -8
  36. package/dist/index.d.ts +59 -8
  37. package/dist/index.js +10 -10
  38. package/dist/motion.cjs +329 -13
  39. package/dist/motion.js +3 -3
  40. package/dist/patterns.cjs +161 -23
  41. package/dist/patterns.js +5 -5
  42. package/dist/performance.cjs +258 -23
  43. package/dist/performance.js +4 -4
  44. package/dist/plugins.cjs +244 -51
  45. package/dist/plugins.js +6 -6
  46. package/dist/ssr.cjs +183 -44
  47. package/dist/ssr.js +7 -7
  48. package/dist/testing.cjs +396 -5
  49. package/dist/testing.js +2 -2
  50. package/dist/ui.cjs +221 -32
  51. package/dist/ui.js +6 -6
  52. package/dist/widgets.cjs +146 -26
  53. package/dist/widgets.js +6 -6
  54. package/package.json +1 -1
package/dist/browser.cjs CHANGED
@@ -81,7 +81,7 @@ function devWarn(message) {
81
81
  }
82
82
  }
83
83
 
84
- // src/reactivity/track.ts
84
+ // src/reactivity/track-core.ts
85
85
  var _isDev2 = isDev();
86
86
  var POOL_MAX = 4096;
87
87
  var nodePool = [];
@@ -165,6 +165,7 @@ function unlinkSub(node) {
165
165
  else sub.depsTail = prev;
166
166
  }
167
167
  var currentSubscriber = null;
168
+ var suspendSavedSub = null;
168
169
  var notifyDepth = 0;
169
170
  var pendingQueue = [];
170
171
  var pendingSet = /* @__PURE__ */ new Set();
@@ -176,6 +177,35 @@ function safeInvoke(sub) {
176
177
  if (_isDev2) devWarn(`Subscriber threw during notification: ${err instanceof Error ? err.message : String(err)}`);
177
178
  }
178
179
  }
180
+ var suspendDepth = 0;
181
+ var trackingSuspended = false;
182
+ function suspendTracking() {
183
+ if (suspendDepth === 0) {
184
+ suspendSavedSub = currentSubscriber;
185
+ currentSubscriber = null;
186
+ trackingSuspended = true;
187
+ }
188
+ suspendDepth++;
189
+ }
190
+ function resumeTracking() {
191
+ suspendDepth--;
192
+ if (suspendDepth === 0) {
193
+ currentSubscriber = suspendSavedSub;
194
+ suspendSavedSub = null;
195
+ trackingSuspended = false;
196
+ }
197
+ }
198
+ function isTrackingSuspended() {
199
+ return trackingSuspended;
200
+ }
201
+ function untracked(fn) {
202
+ suspendTracking();
203
+ try {
204
+ return fn();
205
+ } finally {
206
+ resumeTracking();
207
+ }
208
+ }
179
209
  var subscriberEpochCounter = 0;
180
210
  function retrack(effectFn, subscriber) {
181
211
  const prev = currentSubscriber;
@@ -208,6 +238,51 @@ function retrack(effectFn, subscriber) {
208
238
  }
209
239
  }
210
240
  }
241
+ function track(effectFn, subscriber) {
242
+ if (!subscriber) return reactiveBinding(effectFn);
243
+ cleanup(subscriber);
244
+ const prev = currentSubscriber;
245
+ currentSubscriber = subscriber;
246
+ try {
247
+ effectFn();
248
+ } finally {
249
+ currentSubscriber = prev;
250
+ const sub2 = subscriber;
251
+ for (let n = sub2.depsHead ?? null; n !== null; n = n.subNext) {
252
+ const sig = n.sig;
253
+ sig.__activeNode = n.prevActive;
254
+ n.prevActive = null;
255
+ }
256
+ }
257
+ const sub = subscriber;
258
+ return sub._dispose ?? (sub._dispose = () => cleanup(subscriber));
259
+ }
260
+ function reactiveBinding(commit) {
261
+ const run = () => {
262
+ const s = subscriber;
263
+ if (s._disposed || s._reentrant) return;
264
+ s._reentrant = true;
265
+ try {
266
+ retrack(commit, subscriber);
267
+ } finally {
268
+ s._reentrant = false;
269
+ }
270
+ };
271
+ const subscriber = run;
272
+ subscriber.depsHead = null;
273
+ subscriber.depsTail = null;
274
+ subscriber._epoch = 0;
275
+ subscriber._structDirty = false;
276
+ subscriber._runEpoch = 0;
277
+ subscriber._runs = 0;
278
+ subscriber._reentrant = false;
279
+ subscriber._disposed = false;
280
+ run();
281
+ return subscriber._dispose ?? (subscriber._dispose = () => {
282
+ subscriber._disposed = true;
283
+ cleanup(subscriber);
284
+ });
285
+ }
211
286
  function recordDependency(signal2) {
212
287
  if (!currentSubscriber) return;
213
288
  const sub = currentSubscriber;
@@ -240,6 +315,16 @@ function cleanup(subscriber) {
240
315
  var maxSubscriberRepeats = 50;
241
316
  var maxDrainIterations = 1e6;
242
317
  var drainEpoch = 0;
318
+ function setMaxSubscriberRepeats(n) {
319
+ const prev = maxSubscriberRepeats;
320
+ if (Number.isFinite(n) && n > 0) maxSubscriberRepeats = Math.floor(n);
321
+ return prev;
322
+ }
323
+ function setMaxDrainIterations(n) {
324
+ const prev = maxDrainIterations;
325
+ if (Number.isFinite(n) && n > 0) maxDrainIterations = Math.floor(n);
326
+ return prev;
327
+ }
243
328
  function tickRepeat(sub) {
244
329
  const s = sub;
245
330
  if (s._runEpoch !== drainEpoch) {
@@ -388,11 +473,90 @@ function notifySubscribers(signal2) {
388
473
  }
389
474
  }
390
475
  }
476
+ function getSubscriberCount(signal2) {
477
+ return signal2.__sc ?? 0;
478
+ }
479
+ function getSubscriberDeps(subscriber) {
480
+ const sub = subscriber;
481
+ const out = [];
482
+ let node = sub.depsHead ?? null;
483
+ while (node) {
484
+ if (node.sig) out.push(node.sig);
485
+ node = node.subNext;
486
+ }
487
+ return out;
488
+ }
489
+ function forEachSubscriber(signal2, visit) {
490
+ let node = signal2.subsHead ?? null;
491
+ while (node) {
492
+ const s = node.sub;
493
+ if (s) visit(s);
494
+ node = node.sigNext;
495
+ }
496
+ }
497
+
498
+ // src/reactivity/track.ts
499
+ var _isDev3 = isDev();
500
+ var _runtimeVersion = typeof __SIBU_VERSION__ !== "undefined" ? __SIBU_VERSION__ : "dev";
501
+ var REGISTRY_KEY = /* @__PURE__ */ Symbol.for("sibujs.reactive.v1");
502
+ function resolveReactiveApi() {
503
+ const g = globalThis;
504
+ const existing = g[REGISTRY_KEY];
505
+ if (existing) {
506
+ if (_isDev3 && !existing.__dupWarned) {
507
+ existing.__dupWarned = true;
508
+ devWarn(
509
+ `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']).`
510
+ );
511
+ }
512
+ return existing;
513
+ }
514
+ const local = {
515
+ suspendTracking,
516
+ resumeTracking,
517
+ isTrackingSuspended,
518
+ untracked,
519
+ retrack,
520
+ track,
521
+ reactiveBinding,
522
+ recordDependency,
523
+ cleanup,
524
+ setMaxSubscriberRepeats,
525
+ setMaxDrainIterations,
526
+ drainNotificationQueue,
527
+ queueSignalNotification,
528
+ notifySubscribers,
529
+ getSubscriberCount,
530
+ getSubscriberDeps,
531
+ forEachSubscriber,
532
+ version: _runtimeVersion
533
+ };
534
+ g[REGISTRY_KEY] = local;
535
+ return local;
536
+ }
537
+ var API = resolveReactiveApi();
538
+ var suspendTracking2 = API.suspendTracking;
539
+ var resumeTracking2 = API.resumeTracking;
540
+ var isTrackingSuspended2 = API.isTrackingSuspended;
541
+ var untracked2 = API.untracked;
542
+ var retrack2 = API.retrack;
543
+ var track2 = API.track;
544
+ var reactiveBinding2 = API.reactiveBinding;
545
+ var recordDependency2 = API.recordDependency;
546
+ var cleanup2 = API.cleanup;
547
+ var setMaxSubscriberRepeats2 = API.setMaxSubscriberRepeats;
548
+ var setMaxDrainIterations2 = API.setMaxDrainIterations;
549
+ var drainNotificationQueue2 = API.drainNotificationQueue;
550
+ var queueSignalNotification2 = API.queueSignalNotification;
551
+ var notifySubscribers2 = API.notifySubscribers;
552
+ var getSubscriberCount2 = API.getSubscriberCount;
553
+ var getSubscriberDeps2 = API.getSubscriberDeps;
554
+ var forEachSubscriber2 = API.forEachSubscriber;
391
555
 
392
556
  // src/reactivity/batch.ts
393
557
  var batchDepth = 0;
394
558
  var pendingSignals = /* @__PURE__ */ new Set();
395
- function batch(fn) {
559
+ function batchImpl(fn) {
396
560
  batchDepth++;
397
561
  try {
398
562
  return fn();
@@ -403,25 +567,45 @@ function batch(fn) {
403
567
  }
404
568
  }
405
569
  }
406
- function enqueueBatchedSignal(signal2) {
570
+ function enqueueBatchedSignalImpl(signal2) {
407
571
  if (batchDepth === 0) return false;
408
572
  pendingSignals.add(signal2);
409
573
  return true;
410
574
  }
575
+ function isBatchingImpl() {
576
+ return batchDepth > 0;
577
+ }
411
578
  function flushBatch() {
412
579
  try {
413
580
  for (const signal2 of pendingSignals) {
414
- queueSignalNotification(signal2);
581
+ queueSignalNotification2(signal2);
415
582
  }
416
583
  } finally {
417
584
  pendingSignals.clear();
418
585
  }
419
- drainNotificationQueue();
586
+ drainNotificationQueue2();
587
+ }
588
+ var BATCH_REGISTRY_KEY = /* @__PURE__ */ Symbol.for("sibujs.reactive.batch.v1");
589
+ function resolveBatchApi() {
590
+ const g = globalThis;
591
+ const existing = g[BATCH_REGISTRY_KEY];
592
+ if (existing) return existing;
593
+ const local = {
594
+ batch: batchImpl,
595
+ enqueueBatchedSignal: enqueueBatchedSignalImpl,
596
+ isBatching: isBatchingImpl
597
+ };
598
+ g[BATCH_REGISTRY_KEY] = local;
599
+ return local;
420
600
  }
601
+ var API2 = resolveBatchApi();
602
+ var batch = API2.batch;
603
+ var enqueueBatchedSignal = API2.enqueueBatchedSignal;
604
+ var isBatching = API2.isBatching;
421
605
 
422
606
  // src/core/signals/signal.ts
423
607
  var _g = globalThis;
424
- var _isDev3 = isDev();
608
+ var _isDev4 = isDev();
425
609
  function signal(initial, options) {
426
610
  const state = {
427
611
  value: initial,
@@ -432,11 +616,11 @@ function signal(initial, options) {
432
616
  __activeNode: null,
433
617
  __name: void 0
434
618
  };
435
- const debugName = _isDev3 ? options?.name : void 0;
619
+ const debugName = _isDev4 ? options?.name : void 0;
436
620
  const equalsFn = options?.equals;
437
621
  if (debugName) state.__name = debugName;
438
622
  function get() {
439
- recordDependency(state);
623
+ recordDependency2(state);
440
624
  return state.value;
441
625
  }
442
626
  get.__signal = state;
@@ -449,15 +633,15 @@ function signal(initial, options) {
449
633
  if (equalsFn(prev, newValue)) return;
450
634
  state.value = newValue;
451
635
  state.__v++;
452
- if (_isDev3) {
636
+ if (_isDev4) {
453
637
  const hook = _g.__SIBU_DEVTOOLS_GLOBAL_HOOK__;
454
638
  if (hook) hook.emit("signal:update", { signal: state, name: debugName, oldValue: prev, newValue });
455
639
  }
456
640
  if (!enqueueBatchedSignal(state)) {
457
- notifySubscribers(state);
641
+ notifySubscribers2(state);
458
642
  }
459
643
  };
460
- } else if (_isDev3) {
644
+ } else if (_isDev4) {
461
645
  set = (next) => {
462
646
  const prev = state.value;
463
647
  const newValue = typeof next === "function" ? next(prev) : next;
@@ -467,7 +651,7 @@ function signal(initial, options) {
467
651
  const hook = _g.__SIBU_DEVTOOLS_GLOBAL_HOOK__;
468
652
  if (hook) hook.emit("signal:update", { signal: state, name: debugName, oldValue: prev, newValue });
469
653
  if (!enqueueBatchedSignal(state)) {
470
- notifySubscribers(state);
654
+ notifySubscribers2(state);
471
655
  }
472
656
  };
473
657
  } else {
@@ -478,11 +662,11 @@ function signal(initial, options) {
478
662
  state.value = newValue;
479
663
  state.__v++;
480
664
  if (!enqueueBatchedSignal(state)) {
481
- notifySubscribers(state);
665
+ notifySubscribers2(state);
482
666
  }
483
667
  };
484
668
  }
485
- if (_isDev3) {
669
+ if (_isDev4) {
486
670
  const hook = _g.__SIBU_DEVTOOLS_GLOBAL_HOOK__;
487
671
  if (hook) hook.emit("signal:create", { signal: state, name: debugName, getter: get, initial });
488
672
  }
@@ -557,7 +741,7 @@ function drainReruns(ctx) {
557
741
  do {
558
742
  ctx.rerunPending = false;
559
743
  if (ctx.userCleanups.length > 0) flushUserCleanups(ctx);
560
- retrack(ctx.bodyFn, ctx.subscriber);
744
+ retrack2(ctx.bodyFn, ctx.subscriber);
561
745
  } while (ctx.rerunPending && ++reruns <= MAX_RERUNS);
562
746
  if (ctx.rerunPending) {
563
747
  ctx.rerunPending = false;
@@ -586,7 +770,7 @@ function disposeEffect(ctx) {
586
770
  }
587
771
  }
588
772
  try {
589
- cleanup(ctx.subscriber);
773
+ cleanup2(ctx.subscriber);
590
774
  } catch (err) {
591
775
  if (typeof console !== "undefined") {
592
776
  console.warn("[SibuJS effect] dispose threw:", err);
@@ -631,7 +815,7 @@ function effect(effectFn, options) {
631
815
  try {
632
816
  ctx.rerunPending = false;
633
817
  if (ctx.userCleanups.length > 0) flushUserCleanups(ctx);
634
- retrack(ctx.bodyFn, sub);
818
+ retrack2(ctx.bodyFn, sub);
635
819
  if (ctx.rerunPending) drainReruns(ctx);
636
820
  } finally {
637
821
  ctx.running = false;
@@ -647,7 +831,7 @@ function effect(effectFn, options) {
647
831
  ctx.subscriber = sub;
648
832
  ctx.running = true;
649
833
  try {
650
- retrack(ctx.bodyFn, ctx.subscriber);
834
+ retrack2(ctx.bodyFn, ctx.subscriber);
651
835
  if (ctx.rerunPending) drainReruns(ctx);
652
836
  } finally {
653
837
  ctx.running = false;
@@ -671,7 +855,7 @@ function resize(target) {
671
855
  } };
672
856
  }
673
857
  const getter = resolveTarget(target);
674
- const cleanup2 = effect(() => {
858
+ const cleanup3 = effect(() => {
675
859
  const el = getter();
676
860
  if (observer) {
677
861
  observer.disconnect();
@@ -690,7 +874,7 @@ function resize(target) {
690
874
  observer.observe(el);
691
875
  });
692
876
  function dispose() {
693
- cleanup2();
877
+ cleanup3();
694
878
  if (observer) {
695
879
  observer.disconnect();
696
880
  observer = null;
@@ -967,7 +1151,7 @@ function draggable(element, data) {
967
1151
  let onDragStart = null;
968
1152
  let onDragEnd = null;
969
1153
  const getter = resolveTarget2(element);
970
- const cleanup2 = effect(() => {
1154
+ const cleanup3 = effect(() => {
971
1155
  if (currentEl && onDragStart && onDragEnd) {
972
1156
  currentEl.removeEventListener("dragstart", onDragStart);
973
1157
  currentEl.removeEventListener("dragend", onDragEnd);
@@ -989,7 +1173,7 @@ function draggable(element, data) {
989
1173
  el.addEventListener("dragend", onDragEnd);
990
1174
  });
991
1175
  function dispose() {
992
- cleanup2();
1176
+ cleanup3();
993
1177
  if (currentEl && onDragStart && onDragEnd) {
994
1178
  currentEl.removeEventListener("dragstart", onDragStart);
995
1179
  currentEl.removeEventListener("dragend", onDragEnd);
@@ -1010,7 +1194,7 @@ function dropZone(element, options) {
1010
1194
  let onDragLeave = null;
1011
1195
  let onDrop = null;
1012
1196
  const getter = resolveTarget2(element);
1013
- const cleanup2 = effect(() => {
1197
+ const cleanup3 = effect(() => {
1014
1198
  if (currentEl && onDragOver && onDragEnter && onDragLeave && onDrop) {
1015
1199
  currentEl.removeEventListener("dragover", onDragOver);
1016
1200
  currentEl.removeEventListener("dragenter", onDragEnter);
@@ -1052,7 +1236,7 @@ function dropZone(element, options) {
1052
1236
  el.addEventListener("drop", onDrop);
1053
1237
  });
1054
1238
  function dispose() {
1055
- cleanup2();
1239
+ cleanup3();
1056
1240
  if (currentEl && onDragOver && onDragEnter && onDragLeave && onDrop) {
1057
1241
  currentEl.removeEventListener("dragover", onDragOver);
1058
1242
  currentEl.removeEventListener("dragenter", onDragEnter);
@@ -1072,11 +1256,11 @@ function title(value) {
1072
1256
  }
1073
1257
  const previousTitle = document.title;
1074
1258
  if (typeof value === "function") {
1075
- const cleanup2 = effect(() => {
1259
+ const cleanup3 = effect(() => {
1076
1260
  document.title = value();
1077
1261
  });
1078
1262
  return () => {
1079
- cleanup2();
1263
+ cleanup3();
1080
1264
  document.title = previousTitle;
1081
1265
  };
1082
1266
  }
package/dist/browser.js CHANGED
@@ -35,12 +35,12 @@ import {
35
35
  visibility,
36
36
  wakeLock,
37
37
  windowSize
38
- } from "./chunk-M6WSIGYW.js";
38
+ } from "./chunk-VOVVTOEA.js";
39
39
  import "./chunk-H3SRKIYX.js";
40
- import "./chunk-7JHWAGRQ.js";
40
+ import "./chunk-MHBCEJQO.js";
41
41
  import "./chunk-GOJMFRBL.js";
42
- import "./chunk-5K72I3UQ.js";
43
- import "./chunk-X3NHE2DK.js";
42
+ import "./chunk-WZG2SZOT.js";
43
+ import "./chunk-TEFZT5PJ.js";
44
44
  import "./chunk-COY6PUD2.js";
45
45
  export {
46
46
  animationFrame,