sibujs 4.9.0 → 4.10.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 (62) hide show
  1. package/dist/browser.cjs +41 -4
  2. package/dist/browser.js +4 -4
  3. package/dist/build.cjs +102 -38
  4. package/dist/build.js +10 -10
  5. package/dist/cdn.dev.global.js +14 -14
  6. package/dist/cdn.full.dev.global.js +13 -13
  7. package/dist/cdn.full.global.js +12 -12
  8. package/dist/cdn.global.js +15 -15
  9. package/dist/{chunk-7OV5Q2UU.js → chunk-2D47RVVK.js} +4 -4
  10. package/dist/{chunk-5MLWTIQE.js → chunk-2T73SWKF.js} +2 -2
  11. package/dist/{chunk-YW6HQKGO.js → chunk-42REZXE4.js} +2 -2
  12. package/dist/{chunk-SBTZEYNI.js → chunk-6DYRY2NF.js} +8 -1
  13. package/dist/{chunk-562UVHMM.js → chunk-ADJEMTRC.js} +11 -6
  14. package/dist/{chunk-SYHGGDNW.js → chunk-BNZDDNBR.js} +1 -1
  15. package/dist/{chunk-K6K5ACO6.js → chunk-CID4BYBF.js} +3 -3
  16. package/dist/{chunk-TV464N2M.js → chunk-CYUU3XXG.js} +3 -3
  17. package/dist/{chunk-FNOK662L.js → chunk-CZINTERN.js} +73 -43
  18. package/dist/{chunk-CDBKFGXN.js → chunk-DA2LJXK3.js} +1 -1
  19. package/dist/{chunk-MPWDSTYK.js → chunk-DS6PFIZK.js} +1 -1
  20. package/dist/{chunk-XJVTQUIV.js → chunk-GEQNWNYS.js} +5 -5
  21. package/dist/{chunk-FHCZMHHE.js → chunk-GVVZPMA5.js} +1 -1
  22. package/dist/{chunk-NQMKWBKU.js → chunk-HZQEL575.js} +1 -1
  23. package/dist/{chunk-CF2KCWRE.js → chunk-JZMLRF2G.js} +2 -2
  24. package/dist/{chunk-X7NRHFZR.js → chunk-LK3VK47W.js} +1 -1
  25. package/dist/{chunk-2K3Z3XO4.js → chunk-LYM6TT2R.js} +4 -4
  26. package/dist/{chunk-KG25XMGP.js → chunk-MJZUXQHR.js} +15 -8
  27. package/dist/{chunk-G2WHYEL7.js → chunk-NROLUUCO.js} +39 -4
  28. package/dist/{chunk-DRMLIF6M.js → chunk-WHZKRSHQ.js} +19 -12
  29. package/dist/{chunk-QBKCK6MJ.js → chunk-YNE4FSVX.js} +1 -1
  30. package/dist/data.cjs +48 -6
  31. package/dist/data.d.cts +9 -1
  32. package/dist/data.d.ts +9 -1
  33. package/dist/data.js +5 -5
  34. package/dist/devtools.cjs +41 -4
  35. package/dist/devtools.js +4 -4
  36. package/dist/ecosystem.cjs +41 -4
  37. package/dist/ecosystem.js +7 -7
  38. package/dist/extras.cjs +75 -25
  39. package/dist/extras.js +20 -20
  40. package/dist/index.cjs +102 -38
  41. package/dist/index.d.cts +32 -4
  42. package/dist/index.d.ts +32 -4
  43. package/dist/index.js +10 -10
  44. package/dist/motion.cjs +36 -4
  45. package/dist/motion.js +3 -3
  46. package/dist/patterns.cjs +41 -4
  47. package/dist/patterns.js +5 -5
  48. package/dist/performance.cjs +55 -14
  49. package/dist/performance.js +4 -4
  50. package/dist/plugins.cjs +163 -51
  51. package/dist/plugins.d.cts +56 -2
  52. package/dist/plugins.d.ts +56 -2
  53. package/dist/plugins.js +130 -52
  54. package/dist/ssr.cjs +50 -9
  55. package/dist/ssr.js +7 -7
  56. package/dist/testing.cjs +41 -4
  57. package/dist/testing.js +2 -2
  58. package/dist/ui.cjs +41 -4
  59. package/dist/ui.js +7 -7
  60. package/dist/widgets.cjs +36 -4
  61. package/dist/widgets.js +6 -6
  62. package/package.json +1 -1
package/dist/index.d.cts CHANGED
@@ -1171,18 +1171,30 @@ declare function Suspense({ nodes, fallback }: SuspenseProps): HTMLDivElement;
1171
1171
  * ```
1172
1172
  */
1173
1173
  type CleanupFn = () => void;
1174
+ /**
1175
+ * What an `onMount` callback may return: nothing, or a cleanup function.
1176
+ * `void` rather than `undefined`, because a block body with no `return` is
1177
+ * inferred as `() => void`. Any other return value — including a promise — is
1178
+ * not part of this type.
1179
+ */
1180
+ type MountCallback = () => void | CleanupFn;
1174
1181
  /**
1175
1182
  * Runs a callback once the component's element has been inserted into the DOM.
1176
1183
  * Uses queueMicrotask to defer execution until after the current synchronous
1177
1184
  * rendering pass completes.
1178
1185
  *
1179
- * Optionally returns a cleanup function that will be called on unmount
1180
- * (if you also use onUnmount, prefer that for explicit cleanup).
1186
+ * The callback may return nothing or a cleanup function. When an `element` is
1187
+ * provided, the returned cleanup runs once, when that element is unmounted or
1188
+ * disposed (if you also use onUnmount, prefer that for explicit cleanup).
1181
1189
  *
1182
- * @param callback Function to run after mount. May return a cleanup function.
1190
+ * Other return values are not part of the typed API; the runtime ignores them
1191
+ * if they are encountered. Async callbacks are not supported: a promise is not
1192
+ * a cleanup.
1193
+ *
1194
+ * @param callback Function to run after mount. Returns nothing or a cleanup function.
1183
1195
  * @param element Optional element to observe (HTML or SVG); if provided, waits until it's connected.
1184
1196
  */
1185
- declare function onMount(callback: () => undefined | CleanupFn, element?: Element): void;
1197
+ declare function onMount(callback: MountCallback, element?: Element): void;
1186
1198
  /**
1187
1199
  * Runs a callback when the given element is removed from the DOM.
1188
1200
  * Uses a shared MutationObserver to watch for disconnection, plus
@@ -2182,6 +2194,19 @@ declare function isTrackingSuspended(): boolean;
2182
2194
  * @returns Whatever `fn` returns.
2183
2195
  */
2184
2196
  declare function untracked$1<T>(fn: () => T): T;
2197
+ /** The owner scope in effect right now (`null` when there is none). @internal */
2198
+ declare function getOwnerScope(): unknown;
2199
+ /**
2200
+ * Run `fn` with `scope` as the current owner scope, restoring the previous
2201
+ * scope afterwards (even if `fn` throws). @internal
2202
+ */
2203
+ declare function runWithOwnerScope<T>(scope: unknown, fn: () => T): T;
2204
+ /**
2205
+ * Capture the current owner scope into `fn`, for work that runs later (a
2206
+ * deferred first render, a lifecycle callback). Returns `fn` itself when there
2207
+ * is no scope to carry. @internal
2208
+ */
2209
+ declare function bindOwnerScope<A extends unknown[], R>(fn: (...args: A) => R): (...args: A) => R;
2185
2210
  declare function retrack$1(effectFn: () => void, subscriber: Subscriber): void;
2186
2211
  declare function track(effectFn: () => void, subscriber?: Subscriber): () => void;
2187
2212
  declare function reactiveBinding(commit: () => void, ownerNode?: unknown): () => void;
@@ -2246,6 +2271,9 @@ interface ReactiveApi {
2246
2271
  getSubscriberCount: typeof getSubscriberCount;
2247
2272
  getSubscriberDeps: typeof getSubscriberDeps;
2248
2273
  forEachSubscriber: typeof forEachSubscriber;
2274
+ getOwnerScope?: typeof getOwnerScope;
2275
+ runWithOwnerScope?: typeof runWithOwnerScope;
2276
+ bindOwnerScope?: typeof bindOwnerScope;
2249
2277
  version: string;
2250
2278
  __dupWarned?: boolean;
2251
2279
  }
package/dist/index.d.ts CHANGED
@@ -1171,18 +1171,30 @@ declare function Suspense({ nodes, fallback }: SuspenseProps): HTMLDivElement;
1171
1171
  * ```
1172
1172
  */
1173
1173
  type CleanupFn = () => void;
1174
+ /**
1175
+ * What an `onMount` callback may return: nothing, or a cleanup function.
1176
+ * `void` rather than `undefined`, because a block body with no `return` is
1177
+ * inferred as `() => void`. Any other return value — including a promise — is
1178
+ * not part of this type.
1179
+ */
1180
+ type MountCallback = () => void | CleanupFn;
1174
1181
  /**
1175
1182
  * Runs a callback once the component's element has been inserted into the DOM.
1176
1183
  * Uses queueMicrotask to defer execution until after the current synchronous
1177
1184
  * rendering pass completes.
1178
1185
  *
1179
- * Optionally returns a cleanup function that will be called on unmount
1180
- * (if you also use onUnmount, prefer that for explicit cleanup).
1186
+ * The callback may return nothing or a cleanup function. When an `element` is
1187
+ * provided, the returned cleanup runs once, when that element is unmounted or
1188
+ * disposed (if you also use onUnmount, prefer that for explicit cleanup).
1181
1189
  *
1182
- * @param callback Function to run after mount. May return a cleanup function.
1190
+ * Other return values are not part of the typed API; the runtime ignores them
1191
+ * if they are encountered. Async callbacks are not supported: a promise is not
1192
+ * a cleanup.
1193
+ *
1194
+ * @param callback Function to run after mount. Returns nothing or a cleanup function.
1183
1195
  * @param element Optional element to observe (HTML or SVG); if provided, waits until it's connected.
1184
1196
  */
1185
- declare function onMount(callback: () => undefined | CleanupFn, element?: Element): void;
1197
+ declare function onMount(callback: MountCallback, element?: Element): void;
1186
1198
  /**
1187
1199
  * Runs a callback when the given element is removed from the DOM.
1188
1200
  * Uses a shared MutationObserver to watch for disconnection, plus
@@ -2182,6 +2194,19 @@ declare function isTrackingSuspended(): boolean;
2182
2194
  * @returns Whatever `fn` returns.
2183
2195
  */
2184
2196
  declare function untracked$1<T>(fn: () => T): T;
2197
+ /** The owner scope in effect right now (`null` when there is none). @internal */
2198
+ declare function getOwnerScope(): unknown;
2199
+ /**
2200
+ * Run `fn` with `scope` as the current owner scope, restoring the previous
2201
+ * scope afterwards (even if `fn` throws). @internal
2202
+ */
2203
+ declare function runWithOwnerScope<T>(scope: unknown, fn: () => T): T;
2204
+ /**
2205
+ * Capture the current owner scope into `fn`, for work that runs later (a
2206
+ * deferred first render, a lifecycle callback). Returns `fn` itself when there
2207
+ * is no scope to carry. @internal
2208
+ */
2209
+ declare function bindOwnerScope<A extends unknown[], R>(fn: (...args: A) => R): (...args: A) => R;
2185
2210
  declare function retrack$1(effectFn: () => void, subscriber: Subscriber): void;
2186
2211
  declare function track(effectFn: () => void, subscriber?: Subscriber): () => void;
2187
2212
  declare function reactiveBinding(commit: () => void, ownerNode?: unknown): () => void;
@@ -2246,6 +2271,9 @@ interface ReactiveApi {
2246
2271
  getSubscriberCount: typeof getSubscriberCount;
2247
2272
  getSubscriberDeps: typeof getSubscriberDeps;
2248
2273
  forEachSubscriber: typeof forEachSubscriber;
2274
+ getOwnerScope?: typeof getOwnerScope;
2275
+ runWithOwnerScope?: typeof runWithOwnerScope;
2276
+ bindOwnerScope?: typeof bindOwnerScope;
2249
2277
  version: string;
2250
2278
  __dupWarned?: boolean;
2251
2279
  }
package/dist/index.js CHANGED
@@ -54,7 +54,7 @@ import {
54
54
  unregisterIsland,
55
55
  when,
56
56
  writable
57
- } from "./chunk-FNOK662L.js";
57
+ } from "./chunk-CZINTERN.js";
58
58
  import {
59
59
  a,
60
60
  abbr,
@@ -192,34 +192,34 @@ import {
192
192
  use,
193
193
  var_,
194
194
  video
195
- } from "./chunk-QBKCK6MJ.js";
195
+ } from "./chunk-YNE4FSVX.js";
196
196
  import {
197
197
  trustHTML
198
198
  } from "./chunk-FC6KCJSA.js";
199
199
  import {
200
200
  watch
201
- } from "./chunk-CDBKFGXN.js";
201
+ } from "./chunk-DA2LJXK3.js";
202
202
  import {
203
203
  __resetIdCounter,
204
204
  createId
205
- } from "./chunk-FHCZMHHE.js";
205
+ } from "./chunk-GVVZPMA5.js";
206
206
  import "./chunk-62BDYGAG.js";
207
207
  import {
208
208
  SVG_NS,
209
209
  tagFactory
210
- } from "./chunk-5MLWTIQE.js";
210
+ } from "./chunk-2T73SWKF.js";
211
211
  import {
212
212
  bindDynamic
213
- } from "./chunk-MPWDSTYK.js";
213
+ } from "./chunk-DS6PFIZK.js";
214
214
  import "./chunk-3ACAAQIN.js";
215
215
  import {
216
216
  derived
217
- } from "./chunk-X7NRHFZR.js";
217
+ } from "./chunk-LK3VK47W.js";
218
218
  import "./chunk-7ZHH77QA.js";
219
219
  import {
220
220
  effect,
221
221
  on
222
- } from "./chunk-SBTZEYNI.js";
222
+ } from "./chunk-6DYRY2NF.js";
223
223
  import "./chunk-EXXSN3BW.js";
224
224
  import {
225
225
  disableSSR,
@@ -237,12 +237,12 @@ import {
237
237
  external,
238
238
  isBatching,
239
239
  signal
240
- } from "./chunk-SYHGGDNW.js";
240
+ } from "./chunk-BNZDDNBR.js";
241
241
  import {
242
242
  retrack,
243
243
  setMaxDrainIterations,
244
244
  untracked
245
- } from "./chunk-G2WHYEL7.js";
245
+ } from "./chunk-NROLUUCO.js";
246
246
  import {
247
247
  MAX_DRAIN_TEARDOWNS,
248
248
  checkLeaks,
package/dist/motion.cjs CHANGED
@@ -414,6 +414,24 @@ function untracked(fn) {
414
414
  resumeTracking();
415
415
  }
416
416
  }
417
+ var currentOwnerScope = null;
418
+ function getOwnerScope() {
419
+ return currentOwnerScope;
420
+ }
421
+ function runWithOwnerScope(scope, fn) {
422
+ const prev = currentOwnerScope;
423
+ currentOwnerScope = scope;
424
+ try {
425
+ return fn();
426
+ } finally {
427
+ currentOwnerScope = prev;
428
+ }
429
+ }
430
+ function bindOwnerScope(fn) {
431
+ const scope = currentOwnerScope;
432
+ if (scope === null) return fn;
433
+ return (...args) => runWithOwnerScope(scope, () => fn(...args));
434
+ }
417
435
  var subscriberEpochCounter = 0;
418
436
  function retrack(effectFn, subscriber) {
419
437
  const prev = currentSubscriber;
@@ -429,6 +447,10 @@ function retrack(effectFn, subscriber) {
429
447
  currentSubscriber = subscriber;
430
448
  const sub = subscriber;
431
449
  if (sub._cap === void 0) sub._cap = currentDisposerCapture();
450
+ const prevScope = currentOwnerScope;
451
+ if (prevScope !== null && !sub._epoch && sub._scope === void 0) sub._scope = prevScope;
452
+ const scope = sub._scope === void 0 ? null : sub._scope;
453
+ if (scope !== prevScope) currentOwnerScope = scope;
432
454
  const epoch = ++subscriberEpochCounter;
433
455
  sub._epoch = epoch;
434
456
  sub._structDirty = false;
@@ -441,6 +463,7 @@ function retrack(effectFn, subscriber) {
441
463
  effectFn();
442
464
  } finally {
443
465
  currentSubscriber = prev;
466
+ currentOwnerScope = prevScope;
444
467
  if (savedDepth !== 0) {
445
468
  suspendDepth = savedDepth;
446
469
  suspendSavedSub = savedSuspendSub;
@@ -475,23 +498,26 @@ function track(effectFn, subscriber) {
475
498
  trackingSuspended = false;
476
499
  }
477
500
  currentSubscriber = subscriber;
501
+ const sub = subscriber;
502
+ if (sub._scope === void 0) sub._scope = currentOwnerScope;
503
+ const prevScope = currentOwnerScope;
504
+ currentOwnerScope = sub._scope;
478
505
  try {
479
506
  effectFn();
480
507
  } finally {
481
508
  currentSubscriber = prev;
509
+ currentOwnerScope = prevScope;
482
510
  if (savedDepth !== 0) {
483
511
  suspendDepth = savedDepth;
484
512
  suspendSavedSub = savedSuspendSub;
485
513
  trackingSuspended = true;
486
514
  }
487
- const sub2 = subscriber;
488
- for (let n = sub2.depsHead ?? null; n !== null; n = n.subNext) {
515
+ for (let n = sub.depsHead ?? null; n !== null; n = n.subNext) {
489
516
  const sig = n.sig;
490
517
  sig.__activeNode = n.prevActive;
491
518
  n.prevActive = null;
492
519
  }
493
520
  }
494
- const sub = subscriber;
495
521
  return sub._dispose ?? (sub._dispose = () => cleanup(subscriber));
496
522
  }
497
523
  function reactiveBinding(commit, ownerNode) {
@@ -761,7 +787,7 @@ function forEachSubscriber(signal2, visit) {
761
787
  }
762
788
 
763
789
  // src/reactivity/track.ts
764
- var _runtimeVersion = true ? "4.9.0" : "dev";
790
+ var _runtimeVersion = true ? "4.10.1" : "dev";
765
791
  var REGISTRY_KEY = /* @__PURE__ */ Symbol.for("sibujs.reactive.v1");
766
792
  function resolveReactiveApi() {
767
793
  const g = globalThis;
@@ -793,6 +819,9 @@ function resolveReactiveApi() {
793
819
  getSubscriberCount,
794
820
  getSubscriberDeps,
795
821
  forEachSubscriber,
822
+ getOwnerScope,
823
+ runWithOwnerScope,
824
+ bindOwnerScope,
796
825
  version: _runtimeVersion
797
826
  };
798
827
  g[REGISTRY_KEY] = local;
@@ -816,6 +845,9 @@ var notifySubscribers2 = API.notifySubscribers;
816
845
  var getSubscriberCount2 = API.getSubscriberCount;
817
846
  var getSubscriberDeps2 = API.getSubscriberDeps;
818
847
  var forEachSubscriber2 = API.forEachSubscriber;
848
+ var getOwnerScope2 = API.getOwnerScope ?? getOwnerScope;
849
+ var runWithOwnerScope2 = API.runWithOwnerScope ?? runWithOwnerScope;
850
+ var bindOwnerScope2 = API.bindOwnerScope ?? bindOwnerScope;
819
851
 
820
852
  // src/reactivity/batch.ts
821
853
  var batchDepth = 0;
package/dist/motion.js CHANGED
@@ -20,10 +20,10 @@ import {
20
20
  stagger,
21
21
  transition,
22
22
  viewTransition
23
- } from "./chunk-NQMKWBKU.js";
23
+ } from "./chunk-HZQEL575.js";
24
24
  import "./chunk-5HZXGZ6T.js";
25
- import "./chunk-SYHGGDNW.js";
26
- import "./chunk-G2WHYEL7.js";
25
+ import "./chunk-BNZDDNBR.js";
26
+ import "./chunk-NROLUUCO.js";
27
27
  import "./chunk-NYNYSPK7.js";
28
28
  export {
29
29
  TransitionGroup,
package/dist/patterns.cjs CHANGED
@@ -310,6 +310,24 @@ function untracked(fn) {
310
310
  resumeTracking();
311
311
  }
312
312
  }
313
+ var currentOwnerScope = null;
314
+ function getOwnerScope() {
315
+ return currentOwnerScope;
316
+ }
317
+ function runWithOwnerScope(scope, fn) {
318
+ const prev = currentOwnerScope;
319
+ currentOwnerScope = scope;
320
+ try {
321
+ return fn();
322
+ } finally {
323
+ currentOwnerScope = prev;
324
+ }
325
+ }
326
+ function bindOwnerScope(fn) {
327
+ const scope = currentOwnerScope;
328
+ if (scope === null) return fn;
329
+ return (...args) => runWithOwnerScope(scope, () => fn(...args));
330
+ }
313
331
  var subscriberEpochCounter = 0;
314
332
  function retrack(effectFn, subscriber) {
315
333
  const prev = currentSubscriber;
@@ -325,6 +343,10 @@ function retrack(effectFn, subscriber) {
325
343
  currentSubscriber = subscriber;
326
344
  const sub = subscriber;
327
345
  if (sub._cap === void 0) sub._cap = currentDisposerCapture();
346
+ const prevScope = currentOwnerScope;
347
+ if (prevScope !== null && !sub._epoch && sub._scope === void 0) sub._scope = prevScope;
348
+ const scope = sub._scope === void 0 ? null : sub._scope;
349
+ if (scope !== prevScope) currentOwnerScope = scope;
328
350
  const epoch = ++subscriberEpochCounter;
329
351
  sub._epoch = epoch;
330
352
  sub._structDirty = false;
@@ -337,6 +359,7 @@ function retrack(effectFn, subscriber) {
337
359
  effectFn();
338
360
  } finally {
339
361
  currentSubscriber = prev;
362
+ currentOwnerScope = prevScope;
340
363
  if (savedDepth !== 0) {
341
364
  suspendDepth = savedDepth;
342
365
  suspendSavedSub = savedSuspendSub;
@@ -371,23 +394,26 @@ function track(effectFn, subscriber) {
371
394
  trackingSuspended = false;
372
395
  }
373
396
  currentSubscriber = subscriber;
397
+ const sub = subscriber;
398
+ if (sub._scope === void 0) sub._scope = currentOwnerScope;
399
+ const prevScope = currentOwnerScope;
400
+ currentOwnerScope = sub._scope;
374
401
  try {
375
402
  effectFn();
376
403
  } finally {
377
404
  currentSubscriber = prev;
405
+ currentOwnerScope = prevScope;
378
406
  if (savedDepth !== 0) {
379
407
  suspendDepth = savedDepth;
380
408
  suspendSavedSub = savedSuspendSub;
381
409
  trackingSuspended = true;
382
410
  }
383
- const sub2 = subscriber;
384
- for (let n = sub2.depsHead ?? null; n !== null; n = n.subNext) {
411
+ for (let n = sub.depsHead ?? null; n !== null; n = n.subNext) {
385
412
  const sig = n.sig;
386
413
  sig.__activeNode = n.prevActive;
387
414
  n.prevActive = null;
388
415
  }
389
416
  }
390
- const sub = subscriber;
391
417
  return sub._dispose ?? (sub._dispose = () => cleanup(subscriber));
392
418
  }
393
419
  function reactiveBinding(commit, ownerNode) {
@@ -657,7 +683,7 @@ function forEachSubscriber(signal2, visit) {
657
683
  }
658
684
 
659
685
  // src/reactivity/track.ts
660
- var _runtimeVersion = true ? "4.9.0" : "dev";
686
+ var _runtimeVersion = true ? "4.10.1" : "dev";
661
687
  var REGISTRY_KEY = /* @__PURE__ */ Symbol.for("sibujs.reactive.v1");
662
688
  function resolveReactiveApi() {
663
689
  const g = globalThis;
@@ -689,6 +715,9 @@ function resolveReactiveApi() {
689
715
  getSubscriberCount,
690
716
  getSubscriberDeps,
691
717
  forEachSubscriber,
718
+ getOwnerScope,
719
+ runWithOwnerScope,
720
+ bindOwnerScope,
692
721
  version: _runtimeVersion
693
722
  };
694
723
  g[REGISTRY_KEY] = local;
@@ -712,6 +741,9 @@ var notifySubscribers2 = API.notifySubscribers;
712
741
  var getSubscriberCount2 = API.getSubscriberCount;
713
742
  var getSubscriberDeps2 = API.getSubscriberDeps;
714
743
  var forEachSubscriber2 = API.forEachSubscriber;
744
+ var getOwnerScope2 = API.getOwnerScope ?? getOwnerScope;
745
+ var runWithOwnerScope2 = API.runWithOwnerScope ?? runWithOwnerScope;
746
+ var bindOwnerScope2 = API.bindOwnerScope ?? bindOwnerScope;
715
747
 
716
748
  // src/reactivity/batch.ts
717
749
  var batchDepth = 0;
@@ -997,6 +1029,11 @@ function flushUserCleanups(ctx) {
997
1029
  const list = ctx.userCleanups;
998
1030
  if (list.length === 0) return;
999
1031
  ctx.userCleanups = [];
1032
+ const scope = ctx.subscriber._scope ?? null;
1033
+ if (scope === getOwnerScope2()) runCleanups(list);
1034
+ else runWithOwnerScope2(scope, () => runCleanups(list));
1035
+ }
1036
+ function runCleanups(list) {
1000
1037
  for (let i = list.length - 1; i >= 0; i--) {
1001
1038
  try {
1002
1039
  list[i]();
package/dist/patterns.js CHANGED
@@ -5,7 +5,7 @@ import {
5
5
  optimisticList,
6
6
  persisted,
7
7
  timeline
8
- } from "./chunk-TV464N2M.js";
8
+ } from "./chunk-CYUU3XXG.js";
9
9
  import {
10
10
  RenderProp,
11
11
  assertType,
@@ -23,11 +23,11 @@ import {
23
23
  withWrapper
24
24
  } from "./chunk-TUCPL2HB.js";
25
25
  import "./chunk-62BDYGAG.js";
26
- import "./chunk-X7NRHFZR.js";
27
- import "./chunk-SBTZEYNI.js";
26
+ import "./chunk-LK3VK47W.js";
27
+ import "./chunk-6DYRY2NF.js";
28
28
  import "./chunk-7XHATCIH.js";
29
- import "./chunk-SYHGGDNW.js";
30
- import "./chunk-G2WHYEL7.js";
29
+ import "./chunk-BNZDDNBR.js";
30
+ import "./chunk-NROLUUCO.js";
31
31
  import "./chunk-NYNYSPK7.js";
32
32
  export {
33
33
  RenderProp,
@@ -576,6 +576,24 @@ function untracked(fn) {
576
576
  resumeTracking();
577
577
  }
578
578
  }
579
+ var currentOwnerScope = null;
580
+ function getOwnerScope() {
581
+ return currentOwnerScope;
582
+ }
583
+ function runWithOwnerScope(scope, fn) {
584
+ const prev = currentOwnerScope;
585
+ currentOwnerScope = scope;
586
+ try {
587
+ return fn();
588
+ } finally {
589
+ currentOwnerScope = prev;
590
+ }
591
+ }
592
+ function bindOwnerScope(fn) {
593
+ const scope = currentOwnerScope;
594
+ if (scope === null) return fn;
595
+ return (...args) => runWithOwnerScope(scope, () => fn(...args));
596
+ }
579
597
  var subscriberEpochCounter = 0;
580
598
  function retrack(effectFn, subscriber) {
581
599
  const prev = currentSubscriber;
@@ -591,6 +609,10 @@ function retrack(effectFn, subscriber) {
591
609
  currentSubscriber = subscriber;
592
610
  const sub = subscriber;
593
611
  if (sub._cap === void 0) sub._cap = currentDisposerCapture();
612
+ const prevScope = currentOwnerScope;
613
+ if (prevScope !== null && !sub._epoch && sub._scope === void 0) sub._scope = prevScope;
614
+ const scope = sub._scope === void 0 ? null : sub._scope;
615
+ if (scope !== prevScope) currentOwnerScope = scope;
594
616
  const epoch = ++subscriberEpochCounter;
595
617
  sub._epoch = epoch;
596
618
  sub._structDirty = false;
@@ -603,6 +625,7 @@ function retrack(effectFn, subscriber) {
603
625
  effectFn();
604
626
  } finally {
605
627
  currentSubscriber = prev;
628
+ currentOwnerScope = prevScope;
606
629
  if (savedDepth !== 0) {
607
630
  suspendDepth = savedDepth;
608
631
  suspendSavedSub = savedSuspendSub;
@@ -637,23 +660,26 @@ function track(effectFn, subscriber) {
637
660
  trackingSuspended = false;
638
661
  }
639
662
  currentSubscriber = subscriber;
663
+ const sub = subscriber;
664
+ if (sub._scope === void 0) sub._scope = currentOwnerScope;
665
+ const prevScope = currentOwnerScope;
666
+ currentOwnerScope = sub._scope;
640
667
  try {
641
668
  effectFn();
642
669
  } finally {
643
670
  currentSubscriber = prev;
671
+ currentOwnerScope = prevScope;
644
672
  if (savedDepth !== 0) {
645
673
  suspendDepth = savedDepth;
646
674
  suspendSavedSub = savedSuspendSub;
647
675
  trackingSuspended = true;
648
676
  }
649
- const sub2 = subscriber;
650
- for (let n = sub2.depsHead ?? null; n !== null; n = n.subNext) {
677
+ for (let n = sub.depsHead ?? null; n !== null; n = n.subNext) {
651
678
  const sig = n.sig;
652
679
  sig.__activeNode = n.prevActive;
653
680
  n.prevActive = null;
654
681
  }
655
682
  }
656
- const sub = subscriber;
657
683
  return sub._dispose ?? (sub._dispose = () => cleanup(subscriber));
658
684
  }
659
685
  function reactiveBinding(commit, ownerNode) {
@@ -923,7 +949,7 @@ function forEachSubscriber(signal2, visit) {
923
949
  }
924
950
 
925
951
  // src/reactivity/track.ts
926
- var _runtimeVersion = true ? "4.9.0" : "dev";
952
+ var _runtimeVersion = true ? "4.10.1" : "dev";
927
953
  var REGISTRY_KEY = /* @__PURE__ */ Symbol.for("sibujs.reactive.v1");
928
954
  function resolveReactiveApi() {
929
955
  const g = globalThis;
@@ -955,6 +981,9 @@ function resolveReactiveApi() {
955
981
  getSubscriberCount,
956
982
  getSubscriberDeps,
957
983
  forEachSubscriber,
984
+ getOwnerScope,
985
+ runWithOwnerScope,
986
+ bindOwnerScope,
958
987
  version: _runtimeVersion
959
988
  };
960
989
  g[REGISTRY_KEY] = local;
@@ -978,6 +1007,9 @@ var notifySubscribers2 = API.notifySubscribers;
978
1007
  var getSubscriberCount2 = API.getSubscriberCount;
979
1008
  var getSubscriberDeps2 = API.getSubscriberDeps;
980
1009
  var forEachSubscriber2 = API.forEachSubscriber;
1010
+ var getOwnerScope2 = API.getOwnerScope ?? getOwnerScope;
1011
+ var runWithOwnerScope2 = API.runWithOwnerScope ?? runWithOwnerScope;
1012
+ var bindOwnerScope2 = API.bindOwnerScope ?? bindOwnerScope;
981
1013
 
982
1014
  // src/core/devtoolsHook.ts
983
1015
  function emitDevtools(hook, event, payload) {
@@ -1033,6 +1065,11 @@ function flushUserCleanups(ctx) {
1033
1065
  const list = ctx.userCleanups;
1034
1066
  if (list.length === 0) return;
1035
1067
  ctx.userCleanups = [];
1068
+ const scope = ctx.subscriber._scope ?? null;
1069
+ if (scope === getOwnerScope2()) runCleanups(list);
1070
+ else runWithOwnerScope2(scope, () => runCleanups(list));
1071
+ }
1072
+ function runCleanups(list) {
1036
1073
  for (let i = list.length - 1; i >= 0; i--) {
1037
1074
  try {
1038
1075
  list[i]();
@@ -1920,16 +1957,20 @@ function lazyChunk(id, loader, registry, fallback) {
1920
1957
  registry.load(id, async () => {
1921
1958
  const mod = await loader();
1922
1959
  return typeof mod === "function" ? mod : mod.default;
1923
- }).then((component) => {
1924
- if (disposed) return;
1925
- const node = component();
1926
- if (disposed) {
1927
- dispose(node);
1928
- return;
1929
- }
1930
- clearChildren(container);
1931
- container.appendChild(node);
1932
- }).catch((err) => {
1960
+ }).then(
1961
+ // Instantiated after the chunk resolves, in the owner scope of the
1962
+ // render that asked for it — as `lazy()` does.
1963
+ bindOwnerScope2((component) => {
1964
+ if (disposed) return;
1965
+ const node = component();
1966
+ if (disposed) {
1967
+ dispose(node);
1968
+ return;
1969
+ }
1970
+ clearChildren(container);
1971
+ container.appendChild(node);
1972
+ })
1973
+ ).catch((err) => {
1933
1974
  if (disposed) return;
1934
1975
  clearChildren(container);
1935
1976
  const errorEl = document.createElement("div");
@@ -33,18 +33,18 @@ import {
33
33
  transitionState,
34
34
  uniqueId,
35
35
  yieldToMain
36
- } from "./chunk-DRMLIF6M.js";
36
+ } from "./chunk-WHZKRSHQ.js";
37
37
  import {
38
38
  trustHTML
39
39
  } from "./chunk-FC6KCJSA.js";
40
40
  import "./chunk-62BDYGAG.js";
41
41
  import "./chunk-3ACAAQIN.js";
42
42
  import "./chunk-7ZHH77QA.js";
43
- import "./chunk-SBTZEYNI.js";
43
+ import "./chunk-6DYRY2NF.js";
44
44
  import "./chunk-EXXSN3BW.js";
45
45
  import "./chunk-7XHATCIH.js";
46
- import "./chunk-SYHGGDNW.js";
47
- import "./chunk-G2WHYEL7.js";
46
+ import "./chunk-BNZDDNBR.js";
47
+ import "./chunk-NROLUUCO.js";
48
48
  import "./chunk-NYNYSPK7.js";
49
49
  export {
50
50
  DOMPool,