sibujs 4.5.0 → 4.6.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 (109) hide show
  1. package/dist/browser.cjs +309 -129
  2. package/dist/browser.d.cts +46 -14
  3. package/dist/browser.d.ts +46 -14
  4. package/dist/browser.js +8 -6
  5. package/dist/build.cjs +184 -72
  6. package/dist/build.js +15 -16
  7. package/dist/cdn.dev.global.js +12 -12
  8. package/dist/cdn.full.dev.global.js +11 -11
  9. package/dist/cdn.full.global.js +10 -10
  10. package/dist/cdn.global.js +12 -12
  11. package/dist/{chunk-IXKSNWV5.js → chunk-2INLLLMZ.js} +1 -1
  12. package/dist/chunk-3ISI6ACU.js +44 -0
  13. package/dist/{chunk-ONOHFDLG.js → chunk-47M47FOM.js} +3 -3
  14. package/dist/chunk-5HZXGZ6T.js +24 -0
  15. package/dist/{chunk-KKLW7YWL.js → chunk-5MT6SJ3P.js} +275 -144
  16. package/dist/{chunk-UGRX3S57.js → chunk-5Q4R7HCL.js} +12 -3
  17. package/dist/{chunk-S373NSMK.js → chunk-7GQCWFOE.js} +150 -59
  18. package/dist/{chunk-FTIR4QW2.js → chunk-7NCARGJW.js} +6 -8
  19. package/dist/{chunk-5DXA2J44.js → chunk-7XHATCIH.js} +5 -2
  20. package/dist/{chunk-VZKNK2V7.js → chunk-AIF3Z2T7.js} +296 -38
  21. package/dist/{chunk-4PMLNECI.js → chunk-BAAG6ZTI.js} +98 -29
  22. package/dist/{chunk-XZZOBQAY.js → chunk-D33YTSX5.js} +2 -2
  23. package/dist/{chunk-TBYTO6BS.js → chunk-DKGBBKOF.js} +136 -80
  24. package/dist/{chunk-NIOYEGBQ.js → chunk-HURREPU2.js} +27 -13
  25. package/dist/{chunk-GW3SCCZG.js → chunk-HYXDKS4N.js} +153 -110
  26. package/dist/chunk-J6FW5TV6.js +233 -0
  27. package/dist/{chunk-PCT43HW3.js → chunk-JSXPZCET.js} +1 -1
  28. package/dist/chunk-NYNYSPK7.js +318 -0
  29. package/dist/{chunk-RJE2BNI4.js → chunk-ORMZXBKQ.js} +108 -45
  30. package/dist/{chunk-OMJJM3KM.js → chunk-OXUY2A6L.js} +287 -130
  31. package/dist/{chunk-3JZ4L5TJ.js → chunk-PK6FK2G2.js} +181 -66
  32. package/dist/{chunk-RBTPLM32.js → chunk-QE4TTDU3.js} +2 -2
  33. package/dist/{chunk-2DCGACUU.js → chunk-SXXVZMKZ.js} +251 -66
  34. package/dist/{chunk-R25EFXXC.js → chunk-TUCPL2HB.js} +3 -3
  35. package/dist/{chunk-7LN645I6.js → chunk-UZQ6ALFS.js} +3 -3
  36. package/dist/{chunk-KEISJXBU.js → chunk-VVWPJ543.js} +6 -8
  37. package/dist/{chunk-RIXRAYIU.js → chunk-XC4MEKGA.js} +3 -3
  38. package/dist/{chunk-B3WHI2QA.js → chunk-XRRZKZYX.js} +55 -31
  39. package/dist/{contracts-DBdg9J_a.d.cts → contracts-DRIuclVT.d.cts} +10 -2
  40. package/dist/{contracts-DBdg9J_a.d.ts → contracts-DRIuclVT.d.ts} +10 -2
  41. package/dist/{customElement-OB9CIsc5.d.cts → customElement-MmInOW1U.d.cts} +21 -0
  42. package/dist/{customElement-OB9CIsc5.d.ts → customElement-MmInOW1U.d.ts} +21 -0
  43. package/dist/data.cjs +213 -117
  44. package/dist/data.d.cts +47 -9
  45. package/dist/data.d.ts +47 -9
  46. package/dist/data.js +12 -9
  47. package/dist/devtools.cjs +81 -57
  48. package/dist/devtools.js +7 -8
  49. package/dist/dispose-GEIG2KOF.js +28 -0
  50. package/dist/ecosystem.cjs +309 -104
  51. package/dist/ecosystem.d.cts +19 -3
  52. package/dist/ecosystem.d.ts +19 -3
  53. package/dist/ecosystem.js +12 -12
  54. package/dist/extras.cjs +2133 -863
  55. package/dist/extras.d.cts +10 -9
  56. package/dist/extras.d.ts +10 -9
  57. package/dist/extras.js +39 -28
  58. package/dist/index.cjs +184 -72
  59. package/dist/index.d.cts +22 -5
  60. package/dist/index.d.ts +22 -5
  61. package/dist/index.js +24 -27
  62. package/dist/motion.cjs +107 -41
  63. package/dist/motion.js +5 -5
  64. package/dist/patterns.cjs +317 -39
  65. package/dist/patterns.d.cts +27 -9
  66. package/dist/patterns.d.ts +27 -9
  67. package/dist/patterns.js +8 -8
  68. package/dist/performance.cjs +308 -216
  69. package/dist/performance.d.cts +2 -2
  70. package/dist/performance.d.ts +2 -2
  71. package/dist/performance.js +8 -9
  72. package/dist/plugin-DVgSnTfK.d.cts +112 -0
  73. package/dist/plugin-DVgSnTfK.d.ts +112 -0
  74. package/dist/plugins.cjs +549 -202
  75. package/dist/plugins.d.cts +3 -3
  76. package/dist/plugins.d.ts +3 -3
  77. package/dist/plugins.js +35 -23
  78. package/dist/signal-EotCj4hS.d.cts +110 -0
  79. package/dist/signal-EotCj4hS.d.ts +110 -0
  80. package/dist/{ssr-BiPRdZ6n.d.cts → ssr-Bli9XRW5.d.cts} +5 -0
  81. package/dist/{ssr-BiPRdZ6n.d.ts → ssr-Bli9XRW5.d.ts} +5 -0
  82. package/dist/{ssr-Y7XOEPEN.js → ssr-XOTUASDO.js} +4 -5
  83. package/dist/ssr.cjs +176 -72
  84. package/dist/ssr.d.cts +9 -3
  85. package/dist/ssr.d.ts +9 -3
  86. package/dist/ssr.js +11 -12
  87. package/dist/{startup-BMpaiMhP.d.ts → startup-BLfSeL15.d.cts} +73 -22
  88. package/dist/{startup-BMpaiMhP.d.cts → startup-BLfSeL15.d.ts} +73 -22
  89. package/dist/{tagFactory-DVoDpHye.d.ts → tagFactory-DFstCLQV.d.cts} +2 -100
  90. package/dist/{tagFactory-DVoDpHye.d.cts → tagFactory-DkaNVUNV.d.ts} +2 -100
  91. package/dist/testing.cjs +2484 -2185
  92. package/dist/testing.d.cts +56 -5
  93. package/dist/testing.d.ts +56 -5
  94. package/dist/testing.js +580 -307
  95. package/dist/ui.cjs +707 -317
  96. package/dist/ui.d.cts +40 -7
  97. package/dist/ui.d.ts +40 -7
  98. package/dist/ui.js +151 -56
  99. package/dist/widgets.cjs +246 -278
  100. package/dist/widgets.js +9 -10
  101. package/package.json +1 -1
  102. package/dist/chunk-2WLZ6757.js +0 -149
  103. package/dist/chunk-CCSJMTRN.js +0 -15
  104. package/dist/chunk-QKRPLZ2V.js +0 -108
  105. package/dist/chunk-VUF4ALSW.js +0 -60
  106. package/dist/chunk-WWV3SJ3L.js +0 -131
  107. package/dist/dispose-46BOMMQJ.js +0 -19
  108. package/dist/plugin-D30wlGW5.d.cts +0 -71
  109. package/dist/plugin-D30wlGW5.d.ts +0 -71
package/dist/data.d.cts CHANGED
@@ -1,3 +1,5 @@
1
+ import { D as DisposableAccessor } from './signal-EotCj4hS.cjs';
2
+
1
3
  /**
2
4
  * Configurable retry strategies for async operations.
3
5
  * Used by `resource` and `query` for automatic error recovery.
@@ -278,7 +280,8 @@ declare function infiniteQuery<TData, TPageParam = number>(key: string | (() =>
278
280
  * Returns `undefined` on first read (there is no previous value yet).
279
281
  *
280
282
  * @param getter A reactive getter to track
281
- * @returns A reactive getter for the previous value
283
+ * @returns A reactive getter for the previous value, with `dispose()` to stop
284
+ * tracking the source
282
285
  *
283
286
  * @example
284
287
  * ```ts
@@ -291,7 +294,7 @@ declare function infiniteQuery<TData, TPageParam = number>(key: string | (() =>
291
294
  * prev(); // 5
292
295
  * ```
293
296
  */
294
- declare function previous<T>(getter: () => T): () => T | undefined;
297
+ declare function previous<T>(getter: () => T): DisposableAccessor<T | undefined>;
295
298
 
296
299
  /**
297
300
  * Returns a debounced reactive getter that only updates after `delay` ms
@@ -299,7 +302,8 @@ declare function previous<T>(getter: () => T): () => T | undefined;
299
302
  *
300
303
  * @param getter A reactive getter to debounce
301
304
  * @param delay Debounce delay in milliseconds
302
- * @returns A reactive getter for the debounced value
305
+ * @returns A reactive getter for the debounced value, with `dispose()` to stop
306
+ * tracking the source and cancel the pending timer
303
307
  *
304
308
  * @example
305
309
  * ```ts
@@ -308,7 +312,7 @@ declare function previous<T>(getter: () => T): () => T | undefined;
308
312
  * // debouncedSearch() only updates 300ms after the last setSearch call
309
313
  * ```
310
314
  */
311
- declare function debounce<T>(getter: () => T, delay: number): () => T;
315
+ declare function debounce<T>(getter: () => T, delay: number): DisposableAccessor<T>;
312
316
 
313
317
  /**
314
318
  * Returns a throttled reactive getter that updates at most once per `interval` ms.
@@ -317,7 +321,8 @@ declare function debounce<T>(getter: () => T, delay: number): () => T;
317
321
  *
318
322
  * @param getter A reactive getter to throttle
319
323
  * @param interval Throttle interval in milliseconds
320
- * @returns A reactive getter for the throttled value
324
+ * @returns A reactive getter for the throttled value, with `dispose()` to stop
325
+ * tracking the source and clear the cooldown timer
321
326
  *
322
327
  * @example
323
328
  * ```ts
@@ -326,7 +331,7 @@ declare function debounce<T>(getter: () => T, delay: number): () => T;
326
331
  * // throttled() updates at most once every 100ms
327
332
  * ```
328
333
  */
329
- declare function throttle<T>(getter: () => T, interval: number): () => T;
334
+ declare function throttle<T>(getter: () => T, interval: number): DisposableAccessor<T>;
330
335
 
331
336
  /**
332
337
  * Lifecycle callbacks follow the shared data-layer contract: an exception
@@ -527,14 +532,47 @@ interface LoaderRoute {
527
532
  }
528
533
  /**
529
534
  * Execute a route loader and wrap its result in a reactive Resource.
535
+ *
536
+ * Executing a loader does not make its data visible to `loaderData()`; render
537
+ * the route's component inside {@link renderWithLoader} (or use
538
+ * {@link withLoader}) so the component reads its own route's data.
530
539
  */
531
540
  declare function executeLoader<T>(loader: RouteLoaderFn<T>, context: {
532
541
  params: Record<string, string>;
533
542
  path: string;
534
543
  }, options?: ResourceOptions<T>): Resource<T>;
535
544
  /**
536
- * Access loader data from within a route component.
537
- * Must be called inside a component rendered by a route with a loader.
545
+ * Run `render` with `loader` as the loader data seen by `loaderData()`, then
546
+ * restore the previous scope — even if `render` throws. Scopes nest: an inner
547
+ * call shadows the outer one only for its own duration.
548
+ *
549
+ * `loaderData()` must be called synchronously while `render` runs (typically at
550
+ * the top of the component); the accessors it returns stay bound to `loader`
551
+ * afterwards.
552
+ *
553
+ * @example
554
+ * ```ts
555
+ * const data = executeLoader(route.loader, ctx);
556
+ * const view = renderWithLoader(data, () => route.component());
557
+ * ```
558
+ */
559
+ declare function renderWithLoader<T, R>(loader: Resource<T>, render: () => R): R;
560
+ /**
561
+ * Execute `loader` and render with its data in scope, in one step. Returns the
562
+ * rendered result together with the resource, which the caller disposes when
563
+ * the route unmounts.
564
+ */
565
+ declare function withLoader<T, R>(loader: RouteLoaderFn<T>, context: {
566
+ params: Record<string, string>;
567
+ path: string;
568
+ }, render: () => R, options?: ResourceOptions<T>): {
569
+ view: R;
570
+ resource: Resource<T>;
571
+ };
572
+ /**
573
+ * Access loader data from within a route component: the innermost
574
+ * {@link renderWithLoader} scope (per SSR request on the server). Throws when
575
+ * called outside such a scope, or when that scope's loader has been disposed.
538
576
  */
539
577
  declare function loaderData<T = unknown>(): {
540
578
  data: () => T | undefined;
@@ -596,4 +634,4 @@ declare function stream(url: string, options?: {
596
634
  dispose: () => void;
597
635
  };
598
636
 
599
- export { type ConflictStrategy, type InfiniteQueryOptions, type InfiniteQueryResult, type LoaderRoute, type MutationOptions, type MutationResult, type OfflineStore, type OfflineStoreOptions, type QueryOptions, type QueryResult, type Resource, type ResourceOptions, type RetryOptions, type RouteLoaderFn, type SyncAdapter, type SyncChange, type SyncConflict, type SyncResult, __resetQueryCache, calculateDelay, clearQueryCache, debounce, executeLoader, getQueryData, infiniteQuery, invalidateQueries, loaderData, mutation, offlineStore, preloadRoute, previous, query, resource, setQueryData, socket, stream, syncAdapter, throttle, withRetry };
637
+ export { type ConflictStrategy, type InfiniteQueryOptions, type InfiniteQueryResult, type LoaderRoute, type MutationOptions, type MutationResult, type OfflineStore, type OfflineStoreOptions, type QueryOptions, type QueryResult, type Resource, type ResourceOptions, type RetryOptions, type RouteLoaderFn, type SyncAdapter, type SyncChange, type SyncConflict, type SyncResult, __resetQueryCache, calculateDelay, clearQueryCache, debounce, executeLoader, getQueryData, infiniteQuery, invalidateQueries, loaderData, mutation, offlineStore, preloadRoute, previous, query, renderWithLoader, resource, setQueryData, socket, stream, syncAdapter, throttle, withLoader, withRetry };
package/dist/data.d.ts CHANGED
@@ -1,3 +1,5 @@
1
+ import { D as DisposableAccessor } from './signal-EotCj4hS.js';
2
+
1
3
  /**
2
4
  * Configurable retry strategies for async operations.
3
5
  * Used by `resource` and `query` for automatic error recovery.
@@ -278,7 +280,8 @@ declare function infiniteQuery<TData, TPageParam = number>(key: string | (() =>
278
280
  * Returns `undefined` on first read (there is no previous value yet).
279
281
  *
280
282
  * @param getter A reactive getter to track
281
- * @returns A reactive getter for the previous value
283
+ * @returns A reactive getter for the previous value, with `dispose()` to stop
284
+ * tracking the source
282
285
  *
283
286
  * @example
284
287
  * ```ts
@@ -291,7 +294,7 @@ declare function infiniteQuery<TData, TPageParam = number>(key: string | (() =>
291
294
  * prev(); // 5
292
295
  * ```
293
296
  */
294
- declare function previous<T>(getter: () => T): () => T | undefined;
297
+ declare function previous<T>(getter: () => T): DisposableAccessor<T | undefined>;
295
298
 
296
299
  /**
297
300
  * Returns a debounced reactive getter that only updates after `delay` ms
@@ -299,7 +302,8 @@ declare function previous<T>(getter: () => T): () => T | undefined;
299
302
  *
300
303
  * @param getter A reactive getter to debounce
301
304
  * @param delay Debounce delay in milliseconds
302
- * @returns A reactive getter for the debounced value
305
+ * @returns A reactive getter for the debounced value, with `dispose()` to stop
306
+ * tracking the source and cancel the pending timer
303
307
  *
304
308
  * @example
305
309
  * ```ts
@@ -308,7 +312,7 @@ declare function previous<T>(getter: () => T): () => T | undefined;
308
312
  * // debouncedSearch() only updates 300ms after the last setSearch call
309
313
  * ```
310
314
  */
311
- declare function debounce<T>(getter: () => T, delay: number): () => T;
315
+ declare function debounce<T>(getter: () => T, delay: number): DisposableAccessor<T>;
312
316
 
313
317
  /**
314
318
  * Returns a throttled reactive getter that updates at most once per `interval` ms.
@@ -317,7 +321,8 @@ declare function debounce<T>(getter: () => T, delay: number): () => T;
317
321
  *
318
322
  * @param getter A reactive getter to throttle
319
323
  * @param interval Throttle interval in milliseconds
320
- * @returns A reactive getter for the throttled value
324
+ * @returns A reactive getter for the throttled value, with `dispose()` to stop
325
+ * tracking the source and clear the cooldown timer
321
326
  *
322
327
  * @example
323
328
  * ```ts
@@ -326,7 +331,7 @@ declare function debounce<T>(getter: () => T, delay: number): () => T;
326
331
  * // throttled() updates at most once every 100ms
327
332
  * ```
328
333
  */
329
- declare function throttle<T>(getter: () => T, interval: number): () => T;
334
+ declare function throttle<T>(getter: () => T, interval: number): DisposableAccessor<T>;
330
335
 
331
336
  /**
332
337
  * Lifecycle callbacks follow the shared data-layer contract: an exception
@@ -527,14 +532,47 @@ interface LoaderRoute {
527
532
  }
528
533
  /**
529
534
  * Execute a route loader and wrap its result in a reactive Resource.
535
+ *
536
+ * Executing a loader does not make its data visible to `loaderData()`; render
537
+ * the route's component inside {@link renderWithLoader} (or use
538
+ * {@link withLoader}) so the component reads its own route's data.
530
539
  */
531
540
  declare function executeLoader<T>(loader: RouteLoaderFn<T>, context: {
532
541
  params: Record<string, string>;
533
542
  path: string;
534
543
  }, options?: ResourceOptions<T>): Resource<T>;
535
544
  /**
536
- * Access loader data from within a route component.
537
- * Must be called inside a component rendered by a route with a loader.
545
+ * Run `render` with `loader` as the loader data seen by `loaderData()`, then
546
+ * restore the previous scope — even if `render` throws. Scopes nest: an inner
547
+ * call shadows the outer one only for its own duration.
548
+ *
549
+ * `loaderData()` must be called synchronously while `render` runs (typically at
550
+ * the top of the component); the accessors it returns stay bound to `loader`
551
+ * afterwards.
552
+ *
553
+ * @example
554
+ * ```ts
555
+ * const data = executeLoader(route.loader, ctx);
556
+ * const view = renderWithLoader(data, () => route.component());
557
+ * ```
558
+ */
559
+ declare function renderWithLoader<T, R>(loader: Resource<T>, render: () => R): R;
560
+ /**
561
+ * Execute `loader` and render with its data in scope, in one step. Returns the
562
+ * rendered result together with the resource, which the caller disposes when
563
+ * the route unmounts.
564
+ */
565
+ declare function withLoader<T, R>(loader: RouteLoaderFn<T>, context: {
566
+ params: Record<string, string>;
567
+ path: string;
568
+ }, render: () => R, options?: ResourceOptions<T>): {
569
+ view: R;
570
+ resource: Resource<T>;
571
+ };
572
+ /**
573
+ * Access loader data from within a route component: the innermost
574
+ * {@link renderWithLoader} scope (per SSR request on the server). Throws when
575
+ * called outside such a scope, or when that scope's loader has been disposed.
538
576
  */
539
577
  declare function loaderData<T = unknown>(): {
540
578
  data: () => T | undefined;
@@ -596,4 +634,4 @@ declare function stream(url: string, options?: {
596
634
  dispose: () => void;
597
635
  };
598
636
 
599
- export { type ConflictStrategy, type InfiniteQueryOptions, type InfiniteQueryResult, type LoaderRoute, type MutationOptions, type MutationResult, type OfflineStore, type OfflineStoreOptions, type QueryOptions, type QueryResult, type Resource, type ResourceOptions, type RetryOptions, type RouteLoaderFn, type SyncAdapter, type SyncChange, type SyncConflict, type SyncResult, __resetQueryCache, calculateDelay, clearQueryCache, debounce, executeLoader, getQueryData, infiniteQuery, invalidateQueries, loaderData, mutation, offlineStore, preloadRoute, previous, query, resource, setQueryData, socket, stream, syncAdapter, throttle, withRetry };
637
+ export { type ConflictStrategy, type InfiniteQueryOptions, type InfiniteQueryResult, type LoaderRoute, type MutationOptions, type MutationResult, type OfflineStore, type OfflineStoreOptions, type QueryOptions, type QueryResult, type Resource, type ResourceOptions, type RetryOptions, type RouteLoaderFn, type SyncAdapter, type SyncChange, type SyncConflict, type SyncResult, __resetQueryCache, calculateDelay, clearQueryCache, debounce, executeLoader, getQueryData, infiniteQuery, invalidateQueries, loaderData, mutation, offlineStore, preloadRoute, previous, query, renderWithLoader, resource, setQueryData, socket, stream, syncAdapter, throttle, withLoader, withRetry };
package/dist/data.js CHANGED
@@ -13,23 +13,24 @@ import {
13
13
  preloadRoute,
14
14
  previous,
15
15
  query,
16
+ renderWithLoader,
16
17
  resource,
17
18
  setQueryData,
18
19
  socket,
19
20
  stream,
20
21
  syncAdapter,
21
22
  throttle,
23
+ withLoader,
22
24
  withRetry
23
- } from "./chunk-3JZ4L5TJ.js";
24
- import "./chunk-VUF4ALSW.js";
25
- import "./chunk-RBTPLM32.js";
26
- import "./chunk-IXKSNWV5.js";
25
+ } from "./chunk-PK6FK2G2.js";
26
+ import "./chunk-QE4TTDU3.js";
27
+ import "./chunk-2INLLLMZ.js";
27
28
  import "./chunk-7ZHH77QA.js";
28
- import "./chunk-RIXRAYIU.js";
29
- import "./chunk-5DXA2J44.js";
30
- import "./chunk-XZZOBQAY.js";
31
- import "./chunk-UGRX3S57.js";
32
- import "./chunk-2WLZ6757.js";
29
+ import "./chunk-XC4MEKGA.js";
30
+ import "./chunk-7XHATCIH.js";
31
+ import "./chunk-D33YTSX5.js";
32
+ import "./chunk-5Q4R7HCL.js";
33
+ import "./chunk-NYNYSPK7.js";
33
34
  export {
34
35
  __resetQueryCache,
35
36
  calculateDelay,
@@ -45,11 +46,13 @@ export {
45
46
  preloadRoute,
46
47
  previous,
47
48
  query,
49
+ renderWithLoader,
48
50
  resource,
49
51
  setQueryData,
50
52
  socket,
51
53
  stream,
52
54
  syncAdapter,
53
55
  throttle,
56
+ withLoader,
54
57
  withRetry
55
58
  };
package/dist/devtools.cjs CHANGED
@@ -280,6 +280,79 @@ function reportError(error, context) {
280
280
  });
281
281
  }
282
282
 
283
+ // src/core/rendering/dispose.ts
284
+ var elementDisposers = /* @__PURE__ */ new WeakMap();
285
+ var MAX_DRAIN_TEARDOWNS = 1e4;
286
+ function reportDrainRunaway(label, executed, remaining) {
287
+ if (typeof console === "undefined") return;
288
+ console.error(
289
+ `[SibuJS ${label}] runaway cleanup: stopped after running ${executed} teardowns with ${remaining} still queued. Cleanup production did not stabilize before the teardown safety ceiling was reached \u2014 the remaining work was NOT run.`,
290
+ { executed, remaining }
291
+ );
292
+ }
293
+ var activeBindingCount = 0;
294
+ function resolveCapture(capture) {
295
+ let frame = capture;
296
+ while (frame?.closed) frame = frame.forwardTo;
297
+ return frame ?? null;
298
+ }
299
+ var registrationCaptures = [];
300
+ function currentDisposerCapture() {
301
+ return resolveCapture(registrationCaptures[registrationCaptures.length - 1]);
302
+ }
303
+ function beginDisposerCapture(capture) {
304
+ if (capture === null && registrationCaptures.length === 0) return false;
305
+ registrationCaptures.push(resolveCapture(capture));
306
+ return true;
307
+ }
308
+ function endDisposerCapture() {
309
+ registrationCaptures.pop();
310
+ }
311
+ function dispose(node) {
312
+ const stack = [node];
313
+ const order = [];
314
+ while (stack.length > 0) {
315
+ const current = stack.pop();
316
+ order.push(current);
317
+ const children = Array.from(current.childNodes);
318
+ for (let i = 0; i < children.length; i++) {
319
+ stack.push(children[i]);
320
+ }
321
+ }
322
+ for (let i = order.length - 1; i >= 0; i--) {
323
+ disposeNodeOwn(order[i]);
324
+ }
325
+ }
326
+ function disposeNodeOwn(node) {
327
+ if (!elementDisposers.has(node)) return;
328
+ let executed = 0;
329
+ let runaway = false;
330
+ while (!runaway) {
331
+ const pending = elementDisposers.get(node);
332
+ if (!pending || pending.length === 0) break;
333
+ const snapshot = pending.slice();
334
+ elementDisposers.delete(node);
335
+ if (DEV) activeBindingCount -= snapshot.length;
336
+ for (let i = 0; i < snapshot.length; i++) {
337
+ if (executed >= MAX_DRAIN_TEARDOWNS) {
338
+ const rest = snapshot.slice(i);
339
+ const added = elementDisposers.get(node);
340
+ elementDisposers.set(node, added ? rest.concat(added) : rest);
341
+ if (DEV) activeBindingCount += rest.length;
342
+ reportDrainRunaway("dispose", executed, rest.length + (added?.length ?? 0));
343
+ runaway = true;
344
+ break;
345
+ }
346
+ executed++;
347
+ try {
348
+ snapshot[i]();
349
+ } catch (err) {
350
+ reportError(err, { phase: "cleanup", name: "disposer" });
351
+ }
352
+ }
353
+ }
354
+ }
355
+
283
356
  // src/reactivity/track-core.ts
284
357
  var POOL_MAX = 4096;
285
358
  var nodePool = [];
@@ -438,6 +511,7 @@ function retrack(effectFn, subscriber) {
438
511
  }
439
512
  currentSubscriber = subscriber;
440
513
  const sub = subscriber;
514
+ if (sub._cap === void 0) sub._cap = currentDisposerCapture();
441
515
  const epoch = ++subscriberEpochCounter;
442
516
  sub._epoch = epoch;
443
517
  sub._structDirty = false;
@@ -629,7 +703,12 @@ function drainQueue() {
629
703
  quarantined.add(sub);
630
704
  continue;
631
705
  }
632
- safeInvoke(sub);
706
+ const pushed = beginDisposerCapture(sub._cap ?? null);
707
+ try {
708
+ safeInvoke(sub);
709
+ } finally {
710
+ if (pushed) endDisposerCapture();
711
+ }
633
712
  }
634
713
  }
635
714
  function drainNotificationQueue() {
@@ -765,7 +844,7 @@ function forEachSubscriber(signal2, visit) {
765
844
  }
766
845
 
767
846
  // src/reactivity/track.ts
768
- var _runtimeVersion = true ? "4.5.0" : "dev";
847
+ var _runtimeVersion = true ? "4.6.0" : "dev";
769
848
  var REGISTRY_KEY = /* @__PURE__ */ Symbol.for("sibujs.reactive.v1");
770
849
  function resolveReactiveApi() {
771
850
  const g = globalThis;
@@ -1637,61 +1716,6 @@ function devState(name, initial) {
1637
1716
  return [get, trackedSet];
1638
1717
  }
1639
1718
 
1640
- // src/core/rendering/dispose.ts
1641
- var elementDisposers = /* @__PURE__ */ new WeakMap();
1642
- var MAX_DRAIN_TEARDOWNS = 1e4;
1643
- function reportDrainRunaway(label, executed, remaining) {
1644
- if (typeof console === "undefined") return;
1645
- console.error(
1646
- `[SibuJS ${label}] runaway cleanup: stopped after running ${executed} teardowns with ${remaining} still queued. Cleanup production did not stabilize before the teardown safety ceiling was reached \u2014 the remaining work was NOT run.`,
1647
- { executed, remaining }
1648
- );
1649
- }
1650
- var activeBindingCount = 0;
1651
- function dispose(node) {
1652
- const stack = [node];
1653
- const order = [];
1654
- while (stack.length > 0) {
1655
- const current = stack.pop();
1656
- order.push(current);
1657
- const children = Array.from(current.childNodes);
1658
- for (let i = 0; i < children.length; i++) {
1659
- stack.push(children[i]);
1660
- }
1661
- }
1662
- for (let i = order.length - 1; i >= 0; i--) {
1663
- const current = order[i];
1664
- if (elementDisposers.has(current)) {
1665
- let executed = 0;
1666
- let runaway = false;
1667
- while (!runaway) {
1668
- const pending = elementDisposers.get(current);
1669
- if (!pending || pending.length === 0) break;
1670
- const snapshot = pending.slice();
1671
- elementDisposers.delete(current);
1672
- if (DEV) activeBindingCount -= snapshot.length;
1673
- for (let i2 = 0; i2 < snapshot.length; i2++) {
1674
- if (executed >= MAX_DRAIN_TEARDOWNS) {
1675
- const rest = snapshot.slice(i2);
1676
- const added = elementDisposers.get(current);
1677
- elementDisposers.set(current, added ? rest.concat(added) : rest);
1678
- if (DEV) activeBindingCount += rest.length;
1679
- reportDrainRunaway("dispose", executed, rest.length + (added?.length ?? 0));
1680
- runaway = true;
1681
- break;
1682
- }
1683
- executed++;
1684
- try {
1685
- snapshot[i2]();
1686
- } catch (err) {
1687
- reportError(err, { phase: "cleanup", name: "disposer" });
1688
- }
1689
- }
1690
- }
1691
- }
1692
- }
1693
- }
1694
-
1695
1719
  // src/devtools/hmr.ts
1696
1720
  var HMR_STORE_MAX_SIZE = 200;
1697
1721
  var hmrStateStore = /* @__PURE__ */ new Map();
package/dist/devtools.js CHANGED
@@ -35,17 +35,16 @@ import {
35
35
  trackCleanup,
36
36
  walkDependencyGraph,
37
37
  withErrorTracking
38
- } from "./chunk-FTIR4QW2.js";
39
- import "./chunk-IXKSNWV5.js";
38
+ } from "./chunk-7NCARGJW.js";
39
+ import "./chunk-2INLLLMZ.js";
40
40
  import "./chunk-7ZHH77QA.js";
41
- import "./chunk-RIXRAYIU.js";
42
- import "./chunk-5DXA2J44.js";
43
- import "./chunk-QKRPLZ2V.js";
44
- import "./chunk-XZZOBQAY.js";
45
- import "./chunk-UGRX3S57.js";
41
+ import "./chunk-XC4MEKGA.js";
42
+ import "./chunk-7XHATCIH.js";
43
+ import "./chunk-D33YTSX5.js";
44
+ import "./chunk-5Q4R7HCL.js";
46
45
  import {
47
46
  isDev
48
- } from "./chunk-2WLZ6757.js";
47
+ } from "./chunk-NYNYSPK7.js";
49
48
 
50
49
  // src/devtools/signalGraph.ts
51
50
  function getHook() {
@@ -0,0 +1,28 @@
1
+ import {
2
+ MAX_DRAIN_TEARDOWNS,
3
+ beginDisposerCapture,
4
+ checkLeaks,
5
+ currentDisposerCapture,
6
+ dispose,
7
+ disposeNodeOwn,
8
+ endDisposerCapture,
9
+ registerDisposer,
10
+ replaceChildrenSafely,
11
+ reportDrainRunaway,
12
+ unregisterDisposer,
13
+ withDisposerRollback
14
+ } from "./chunk-NYNYSPK7.js";
15
+ export {
16
+ MAX_DRAIN_TEARDOWNS,
17
+ beginDisposerCapture,
18
+ checkLeaks,
19
+ currentDisposerCapture,
20
+ dispose,
21
+ disposeNodeOwn,
22
+ endDisposerCapture,
23
+ registerDisposer,
24
+ replaceChildrenSafely,
25
+ reportDrainRunaway,
26
+ unregisterDisposer,
27
+ withDisposerRollback
28
+ };