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/data.d.cts CHANGED
@@ -133,12 +133,33 @@ type StructuralSharingOption<T> = boolean | ((prev: T, next: T) => T);
133
133
  * mutation rather than a notification — see `MutationOptions.onMutate`.
134
134
  */
135
135
  interface QueryOptions<T> {
136
- /** Time in ms before cached data is considered stale. Default: 0 (always stale) */
136
+ /**
137
+ * Time in ms before cached data is considered stale. Default: 0 (always stale)
138
+ *
139
+ * Staleness is acted on when the query mounts, when its resolved key
140
+ * changes, when `enabled` turns on, and by the explicit triggers (`refetch()`,
141
+ * `invalidateQueries`, the interval, focus, reconnect). A key getter that
142
+ * re-runs and resolves to the SAME key is not a key change and never
143
+ * refetches, whatever the data's age — no `derived()` wrapper needed.
144
+ */
137
145
  staleTime?: number;
138
146
  /** Time in ms to keep unused cache entries. Default: 300000 (5 min) */
139
147
  cacheTime?: number;
140
- /** Whether to fetch on creation. Default: true */
141
- enabled?: boolean;
148
+ /**
149
+ * Whether the query may fetch. Default: `true`.
150
+ *
151
+ * A function is reactive: while it returns `false` the query stays idle
152
+ * (nothing fetches — not the key effect, `refetch()`, `invalidateQueries`,
153
+ * the interval, focus or reconnect), and it fetches as soon as it returns
154
+ * `true`, following the usual staleness rules.
155
+ *
156
+ * ```ts
157
+ * query(() => `user:${userId()}`, fetchUser, { enabled: () => userId() != null });
158
+ * ```
159
+ *
160
+ * An empty key (`""`) also holds a query idle, without creating a cache entry.
161
+ */
162
+ enabled?: boolean | (() => boolean);
142
163
  /** Retry options for failed fetches */
143
164
  retry?: RetryOptions;
144
165
  /** Initial data before first fetch */
@@ -325,8 +346,14 @@ interface InfiniteQueryOptions<TData, TPageParam = number> {
325
346
  * unbounded.
326
347
  */
327
348
  maxPages?: number;
328
- /** Whether to fetch on creation. Default: true */
329
- enabled?: boolean;
349
+ /**
350
+ * Whether the query may load its first page. Default: `true`.
351
+ *
352
+ * A function is reactive: while it returns `false` the query stays idle, and
353
+ * each time it turns `true` the query loads from `initialPageParam`, as a key
354
+ * change does.
355
+ */
356
+ enabled?: boolean | (() => boolean);
330
357
  /** Retry options */
331
358
  retry?: RetryOptions;
332
359
  /** Called on successful page fetch */
package/dist/data.d.ts CHANGED
@@ -133,12 +133,33 @@ type StructuralSharingOption<T> = boolean | ((prev: T, next: T) => T);
133
133
  * mutation rather than a notification — see `MutationOptions.onMutate`.
134
134
  */
135
135
  interface QueryOptions<T> {
136
- /** Time in ms before cached data is considered stale. Default: 0 (always stale) */
136
+ /**
137
+ * Time in ms before cached data is considered stale. Default: 0 (always stale)
138
+ *
139
+ * Staleness is acted on when the query mounts, when its resolved key
140
+ * changes, when `enabled` turns on, and by the explicit triggers (`refetch()`,
141
+ * `invalidateQueries`, the interval, focus, reconnect). A key getter that
142
+ * re-runs and resolves to the SAME key is not a key change and never
143
+ * refetches, whatever the data's age — no `derived()` wrapper needed.
144
+ */
137
145
  staleTime?: number;
138
146
  /** Time in ms to keep unused cache entries. Default: 300000 (5 min) */
139
147
  cacheTime?: number;
140
- /** Whether to fetch on creation. Default: true */
141
- enabled?: boolean;
148
+ /**
149
+ * Whether the query may fetch. Default: `true`.
150
+ *
151
+ * A function is reactive: while it returns `false` the query stays idle
152
+ * (nothing fetches — not the key effect, `refetch()`, `invalidateQueries`,
153
+ * the interval, focus or reconnect), and it fetches as soon as it returns
154
+ * `true`, following the usual staleness rules.
155
+ *
156
+ * ```ts
157
+ * query(() => `user:${userId()}`, fetchUser, { enabled: () => userId() != null });
158
+ * ```
159
+ *
160
+ * An empty key (`""`) also holds a query idle, without creating a cache entry.
161
+ */
162
+ enabled?: boolean | (() => boolean);
142
163
  /** Retry options for failed fetches */
143
164
  retry?: RetryOptions;
144
165
  /** Initial data before first fetch */
@@ -325,8 +346,14 @@ interface InfiniteQueryOptions<TData, TPageParam = number> {
325
346
  * unbounded.
326
347
  */
327
348
  maxPages?: number;
328
- /** Whether to fetch on creation. Default: true */
329
- enabled?: boolean;
349
+ /**
350
+ * Whether the query may load its first page. Default: `true`.
351
+ *
352
+ * A function is reactive: while it returns `false` the query stays idle, and
353
+ * each time it turns `true` the query loads from `initialPageParam`, as a key
354
+ * change does.
355
+ */
356
+ enabled?: boolean | (() => boolean);
330
357
  /** Retry options */
331
358
  retry?: RetryOptions;
332
359
  /** Called on successful page fetch */
package/dist/data.js CHANGED
@@ -22,14 +22,14 @@ import {
22
22
  throttle,
23
23
  withLoader,
24
24
  withRetry
25
- } from "./chunk-UCNP3HVM.js";
26
- import "./chunk-KJ3UKABJ.js";
25
+ } from "./chunk-GMMDHJJT.js";
26
+ import "./chunk-5PC7OTQW.js";
27
27
  import "./chunk-7ZHH77QA.js";
28
- import "./chunk-V3LHZSU5.js";
28
+ import "./chunk-7WIHYHWD.js";
29
29
  import "./chunk-EXXSN3BW.js";
30
30
  import "./chunk-7XHATCIH.js";
31
- import "./chunk-DSID757X.js";
32
- import "./chunk-TQQUN4WR.js";
31
+ import "./chunk-FYUEL5IW.js";
32
+ import "./chunk-D6HYFOWR.js";
33
33
  import "./chunk-NYNYSPK7.js";
34
34
  export {
35
35
  __resetQueryCache,
package/dist/devtools.cjs CHANGED
@@ -497,6 +497,24 @@ function untracked(fn) {
497
497
  resumeTracking();
498
498
  }
499
499
  }
500
+ var currentOwnerScope = null;
501
+ function getOwnerScope() {
502
+ return currentOwnerScope;
503
+ }
504
+ function runWithOwnerScope(scope, fn) {
505
+ const prev = currentOwnerScope;
506
+ currentOwnerScope = scope;
507
+ try {
508
+ return fn();
509
+ } finally {
510
+ currentOwnerScope = prev;
511
+ }
512
+ }
513
+ function bindOwnerScope(fn) {
514
+ const scope = currentOwnerScope;
515
+ if (scope === null) return fn;
516
+ return (...args) => runWithOwnerScope(scope, () => fn(...args));
517
+ }
500
518
  var subscriberEpochCounter = 0;
501
519
  function retrack(effectFn, subscriber) {
502
520
  const prev = currentSubscriber;
@@ -512,6 +530,10 @@ function retrack(effectFn, subscriber) {
512
530
  currentSubscriber = subscriber;
513
531
  const sub = subscriber;
514
532
  if (sub._cap === void 0) sub._cap = currentDisposerCapture();
533
+ const prevScope = currentOwnerScope;
534
+ if (prevScope !== null && !sub._epoch && sub._scope === void 0) sub._scope = prevScope;
535
+ const scope = sub._scope === void 0 ? null : sub._scope;
536
+ if (scope !== prevScope) currentOwnerScope = scope;
515
537
  const epoch = ++subscriberEpochCounter;
516
538
  sub._epoch = epoch;
517
539
  sub._structDirty = false;
@@ -524,6 +546,7 @@ function retrack(effectFn, subscriber) {
524
546
  effectFn();
525
547
  } finally {
526
548
  currentSubscriber = prev;
549
+ currentOwnerScope = prevScope;
527
550
  if (savedDepth !== 0) {
528
551
  suspendDepth = savedDepth;
529
552
  suspendSavedSub = savedSuspendSub;
@@ -558,23 +581,26 @@ function track(effectFn, subscriber) {
558
581
  trackingSuspended = false;
559
582
  }
560
583
  currentSubscriber = subscriber;
584
+ const sub = subscriber;
585
+ if (sub._scope === void 0) sub._scope = currentOwnerScope;
586
+ const prevScope = currentOwnerScope;
587
+ currentOwnerScope = sub._scope;
561
588
  try {
562
589
  effectFn();
563
590
  } finally {
564
591
  currentSubscriber = prev;
592
+ currentOwnerScope = prevScope;
565
593
  if (savedDepth !== 0) {
566
594
  suspendDepth = savedDepth;
567
595
  suspendSavedSub = savedSuspendSub;
568
596
  trackingSuspended = true;
569
597
  }
570
- const sub2 = subscriber;
571
- for (let n = sub2.depsHead ?? null; n !== null; n = n.subNext) {
598
+ for (let n = sub.depsHead ?? null; n !== null; n = n.subNext) {
572
599
  const sig = n.sig;
573
600
  sig.__activeNode = n.prevActive;
574
601
  n.prevActive = null;
575
602
  }
576
603
  }
577
- const sub = subscriber;
578
604
  return sub._dispose ?? (sub._dispose = () => cleanup(subscriber));
579
605
  }
580
606
  function reactiveBinding(commit, ownerNode) {
@@ -844,7 +870,7 @@ function forEachSubscriber(signal2, visit) {
844
870
  }
845
871
 
846
872
  // src/reactivity/track.ts
847
- var _runtimeVersion = true ? "4.8.0" : "dev";
873
+ var _runtimeVersion = true ? "4.10.0" : "dev";
848
874
  var REGISTRY_KEY = /* @__PURE__ */ Symbol.for("sibujs.reactive.v1");
849
875
  function resolveReactiveApi() {
850
876
  const g = globalThis;
@@ -876,6 +902,9 @@ function resolveReactiveApi() {
876
902
  getSubscriberCount,
877
903
  getSubscriberDeps,
878
904
  forEachSubscriber,
905
+ getOwnerScope,
906
+ runWithOwnerScope,
907
+ bindOwnerScope,
879
908
  version: _runtimeVersion
880
909
  };
881
910
  g[REGISTRY_KEY] = local;
@@ -899,6 +928,9 @@ var notifySubscribers2 = API.notifySubscribers;
899
928
  var getSubscriberCount2 = API.getSubscriberCount;
900
929
  var getSubscriberDeps2 = API.getSubscriberDeps;
901
930
  var forEachSubscriber2 = API.forEachSubscriber;
931
+ var getOwnerScope2 = API.getOwnerScope ?? getOwnerScope;
932
+ var runWithOwnerScope2 = API.runWithOwnerScope ?? runWithOwnerScope;
933
+ var bindOwnerScope2 = API.bindOwnerScope ?? bindOwnerScope;
902
934
 
903
935
  // src/reactivity/batch.ts
904
936
  var batchDepth = 0;
@@ -2064,6 +2096,11 @@ function flushUserCleanups(ctx) {
2064
2096
  const list = ctx.userCleanups;
2065
2097
  if (list.length === 0) return;
2066
2098
  ctx.userCleanups = [];
2099
+ const scope = ctx.subscriber._scope ?? null;
2100
+ if (scope === getOwnerScope2()) runCleanups2(list);
2101
+ else runWithOwnerScope2(scope, () => runCleanups2(list));
2102
+ }
2103
+ function runCleanups2(list) {
2067
2104
  for (let i = list.length - 1; i >= 0; i--) {
2068
2105
  try {
2069
2106
  list[i]();
package/dist/devtools.js CHANGED
@@ -35,13 +35,13 @@ import {
35
35
  trackCleanup,
36
36
  walkDependencyGraph,
37
37
  withErrorTracking
38
- } from "./chunk-44MTL7ED.js";
38
+ } from "./chunk-BMCR7TXG.js";
39
39
  import "./chunk-7ZHH77QA.js";
40
- import "./chunk-V3LHZSU5.js";
40
+ import "./chunk-7WIHYHWD.js";
41
41
  import "./chunk-EXXSN3BW.js";
42
42
  import "./chunk-7XHATCIH.js";
43
- import "./chunk-DSID757X.js";
44
- import "./chunk-TQQUN4WR.js";
43
+ import "./chunk-FYUEL5IW.js";
44
+ import "./chunk-D6HYFOWR.js";
45
45
  import {
46
46
  isDev
47
47
  } from "./chunk-NYNYSPK7.js";
@@ -369,6 +369,24 @@ function untracked(fn) {
369
369
  resumeTracking();
370
370
  }
371
371
  }
372
+ var currentOwnerScope = null;
373
+ function getOwnerScope() {
374
+ return currentOwnerScope;
375
+ }
376
+ function runWithOwnerScope(scope, fn) {
377
+ const prev = currentOwnerScope;
378
+ currentOwnerScope = scope;
379
+ try {
380
+ return fn();
381
+ } finally {
382
+ currentOwnerScope = prev;
383
+ }
384
+ }
385
+ function bindOwnerScope(fn) {
386
+ const scope = currentOwnerScope;
387
+ if (scope === null) return fn;
388
+ return (...args) => runWithOwnerScope(scope, () => fn(...args));
389
+ }
372
390
  var subscriberEpochCounter = 0;
373
391
  function retrack(effectFn, subscriber) {
374
392
  const prev = currentSubscriber;
@@ -384,6 +402,10 @@ function retrack(effectFn, subscriber) {
384
402
  currentSubscriber = subscriber;
385
403
  const sub = subscriber;
386
404
  if (sub._cap === void 0) sub._cap = currentDisposerCapture();
405
+ const prevScope = currentOwnerScope;
406
+ if (prevScope !== null && !sub._epoch && sub._scope === void 0) sub._scope = prevScope;
407
+ const scope = sub._scope === void 0 ? null : sub._scope;
408
+ if (scope !== prevScope) currentOwnerScope = scope;
387
409
  const epoch = ++subscriberEpochCounter;
388
410
  sub._epoch = epoch;
389
411
  sub._structDirty = false;
@@ -396,6 +418,7 @@ function retrack(effectFn, subscriber) {
396
418
  effectFn();
397
419
  } finally {
398
420
  currentSubscriber = prev;
421
+ currentOwnerScope = prevScope;
399
422
  if (savedDepth !== 0) {
400
423
  suspendDepth = savedDepth;
401
424
  suspendSavedSub = savedSuspendSub;
@@ -430,23 +453,26 @@ function track(effectFn, subscriber) {
430
453
  trackingSuspended = false;
431
454
  }
432
455
  currentSubscriber = subscriber;
456
+ const sub = subscriber;
457
+ if (sub._scope === void 0) sub._scope = currentOwnerScope;
458
+ const prevScope = currentOwnerScope;
459
+ currentOwnerScope = sub._scope;
433
460
  try {
434
461
  effectFn();
435
462
  } finally {
436
463
  currentSubscriber = prev;
464
+ currentOwnerScope = prevScope;
437
465
  if (savedDepth !== 0) {
438
466
  suspendDepth = savedDepth;
439
467
  suspendSavedSub = savedSuspendSub;
440
468
  trackingSuspended = true;
441
469
  }
442
- const sub2 = subscriber;
443
- for (let n = sub2.depsHead ?? null; n !== null; n = n.subNext) {
470
+ for (let n = sub.depsHead ?? null; n !== null; n = n.subNext) {
444
471
  const sig = n.sig;
445
472
  sig.__activeNode = n.prevActive;
446
473
  n.prevActive = null;
447
474
  }
448
475
  }
449
- const sub = subscriber;
450
476
  return sub._dispose ?? (sub._dispose = () => cleanup(subscriber));
451
477
  }
452
478
  function reactiveBinding(commit, ownerNode) {
@@ -716,7 +742,7 @@ function forEachSubscriber(signal2, visit) {
716
742
  }
717
743
 
718
744
  // src/reactivity/track.ts
719
- var _runtimeVersion = true ? "4.8.0" : "dev";
745
+ var _runtimeVersion = true ? "4.10.0" : "dev";
720
746
  var REGISTRY_KEY = /* @__PURE__ */ Symbol.for("sibujs.reactive.v1");
721
747
  function resolveReactiveApi() {
722
748
  const g = globalThis;
@@ -748,6 +774,9 @@ function resolveReactiveApi() {
748
774
  getSubscriberCount,
749
775
  getSubscriberDeps,
750
776
  forEachSubscriber,
777
+ getOwnerScope,
778
+ runWithOwnerScope,
779
+ bindOwnerScope,
751
780
  version: _runtimeVersion
752
781
  };
753
782
  g[REGISTRY_KEY] = local;
@@ -771,6 +800,9 @@ var notifySubscribers2 = API.notifySubscribers;
771
800
  var getSubscriberCount2 = API.getSubscriberCount;
772
801
  var getSubscriberDeps2 = API.getSubscriberDeps;
773
802
  var forEachSubscriber2 = API.forEachSubscriber;
803
+ var getOwnerScope2 = API.getOwnerScope ?? getOwnerScope;
804
+ var runWithOwnerScope2 = API.runWithOwnerScope ?? runWithOwnerScope;
805
+ var bindOwnerScope2 = API.bindOwnerScope ?? bindOwnerScope;
774
806
 
775
807
  // src/core/devtoolsHook.ts
776
808
  function emitDevtools(hook, event, payload) {
@@ -826,6 +858,11 @@ function flushUserCleanups(ctx) {
826
858
  const list = ctx.userCleanups;
827
859
  if (list.length === 0) return;
828
860
  ctx.userCleanups = [];
861
+ const scope = ctx.subscriber._scope ?? null;
862
+ if (scope === getOwnerScope2()) runCleanups(list);
863
+ else runWithOwnerScope2(scope, () => runCleanups(list));
864
+ }
865
+ function runCleanups(list) {
829
866
  for (let i = list.length - 1; i >= 0; i--) {
830
867
  try {
831
868
  list[i]();
package/dist/ecosystem.js CHANGED
@@ -7,19 +7,19 @@ import {
7
7
  mobXAdapter,
8
8
  reduxAdapter,
9
9
  zustandAdapter
10
- } from "./chunk-4WMSTZ7J.js";
10
+ } from "./chunk-VWPMWV7O.js";
11
11
  import "./chunk-J6FW5TV6.js";
12
- import "./chunk-VWT3VXPL.js";
13
- import "./chunk-O6TRVMJI.js";
12
+ import "./chunk-EVI4ZQO3.js";
13
+ import "./chunk-XUQUQJYE.js";
14
14
  import "./chunk-3ACAAQIN.js";
15
- import "./chunk-KJ3UKABJ.js";
15
+ import "./chunk-5PC7OTQW.js";
16
16
  import "./chunk-7ZHH77QA.js";
17
- import "./chunk-V3LHZSU5.js";
17
+ import "./chunk-7WIHYHWD.js";
18
18
  import "./chunk-EXXSN3BW.js";
19
19
  import "./chunk-7XHATCIH.js";
20
20
  import "./chunk-5HZXGZ6T.js";
21
- import "./chunk-DSID757X.js";
22
- import "./chunk-TQQUN4WR.js";
21
+ import "./chunk-FYUEL5IW.js";
22
+ import "./chunk-D6HYFOWR.js";
23
23
  import "./chunk-NYNYSPK7.js";
24
24
  export {
25
25
  antdAdapter,