sibujs 3.1.0 → 3.2.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 (78) hide show
  1. package/README.md +6 -0
  2. package/dist/browser.cjs +16 -8
  3. package/dist/browser.js +6 -5
  4. package/dist/build.cjs +235 -147
  5. package/dist/build.js +35 -24
  6. package/dist/cdn.global.js +7 -7
  7. package/dist/{chunk-WYU7CYJ3.js → chunk-2C4E3HBM.js} +5 -5
  8. package/dist/{chunk-3DYB5B3S.js → chunk-4JCAUOLN.js} +45 -23
  9. package/dist/{chunk-2HAGQWDV.js → chunk-5N74TKLD.js} +1 -1
  10. package/dist/{chunk-SVVAUX7J.js → chunk-7XDYVJLE.js} +19 -9
  11. package/dist/{chunk-2N2UL7O4.js → chunk-BGNLPNGV.js} +20 -12
  12. package/dist/{chunk-RK4BQG25.js → chunk-C427DVQF.js} +1 -1
  13. package/dist/{chunk-ZIBE2SAT.js → chunk-FDY42FIU.js} +3 -2
  14. package/dist/{chunk-GQ7RRFPU.js → chunk-FOI23UJL.js} +11 -1
  15. package/dist/{chunk-2RA7SHDA.js → chunk-GOJMFRBL.js} +20 -4
  16. package/dist/{chunk-IVOUCSZL.js → chunk-GOUM4JCT.js} +6 -6
  17. package/dist/chunk-H3SRKIYX.js +17 -0
  18. package/dist/{chunk-3DJH25UO.js → chunk-H6PCHJZQ.js} +2 -2
  19. package/dist/{chunk-UCS6AMJ7.js → chunk-HMJFCBRR.js} +26 -3
  20. package/dist/{chunk-JYD2PWXH.js → chunk-HXMS4SNP.js} +22 -15
  21. package/dist/{chunk-SC437AMI.js → chunk-JYXOEYI4.js} +12 -18
  22. package/dist/{chunk-KB3BA2XK.js → chunk-NFYWLRUO.js} +11 -18
  23. package/dist/{chunk-QNQY5DUS.js → chunk-NPIEEKPT.js} +20 -11
  24. package/dist/{chunk-UYX2NDOH.js → chunk-OYLPZO4N.js} +33 -15
  25. package/dist/{chunk-LYTCUZ7H.js → chunk-RDRSWYNP.js} +1 -1
  26. package/dist/{chunk-2ZJ7TSW4.js → chunk-RLUJL2MV.js} +4 -8
  27. package/dist/{chunk-CR4MXPHB.js → chunk-V2MTG5FT.js} +99 -36
  28. package/dist/{chunk-CNZ35WI2.js → chunk-VJE6DDYM.js} +2 -2
  29. package/dist/{chunk-PMSDFTK3.js → chunk-VOCE4NNK.js} +157 -75
  30. package/dist/{chunk-WKUXSE7V.js → chunk-X67UYC74.js} +12 -11
  31. package/dist/{chunk-EFOAE5NC.js → chunk-YFDGQWDA.js} +1 -1
  32. package/dist/{chunk-3U4ZVXVD.js → chunk-Z2FWAE4B.js} +6 -2
  33. package/dist/data.cjs +190 -94
  34. package/dist/data.d.cts +7 -1
  35. package/dist/data.d.ts +7 -1
  36. package/dist/data.js +8 -8
  37. package/dist/devtools.cjs +38 -10
  38. package/dist/devtools.d.cts +1 -1
  39. package/dist/devtools.d.ts +1 -1
  40. package/dist/devtools.js +6 -6
  41. package/dist/ecosystem.cjs +123 -63
  42. package/dist/ecosystem.js +9 -9
  43. package/dist/extras.cjs +380 -196
  44. package/dist/extras.d.cts +2 -2
  45. package/dist/extras.d.ts +2 -2
  46. package/dist/extras.js +27 -24
  47. package/dist/index.cjs +214 -136
  48. package/dist/index.d.cts +15 -2
  49. package/dist/index.d.ts +15 -2
  50. package/dist/index.js +15 -13
  51. package/dist/{introspect-BZWKvQUZ.d.ts → introspect-DOZfmC-4.d.ts} +1 -1
  52. package/dist/{introspect-DsJlDD2T.d.cts → introspect-RjLfIFpL.d.cts} +1 -1
  53. package/dist/motion.cjs +10 -0
  54. package/dist/motion.js +3 -3
  55. package/dist/patterns.cjs +45 -40
  56. package/dist/patterns.js +8 -7
  57. package/dist/performance.cjs +101 -25
  58. package/dist/performance.d.cts +2 -2
  59. package/dist/performance.d.ts +2 -2
  60. package/dist/performance.js +8 -7
  61. package/dist/plugins.cjs +234 -160
  62. package/dist/plugins.d.cts +1 -1
  63. package/dist/plugins.d.ts +1 -1
  64. package/dist/plugins.js +127 -69
  65. package/dist/{ssr-FXD2PPMC.js → ssr-2QDQ27EV.js} +5 -3
  66. package/dist/{ssr-CrVNy6Pa.d.cts → ssr-D62yFwuw.d.cts} +8 -1
  67. package/dist/{ssr-CrVNy6Pa.d.ts → ssr-D62yFwuw.d.ts} +8 -1
  68. package/dist/ssr.cjs +145 -66
  69. package/dist/ssr.d.cts +1 -1
  70. package/dist/ssr.d.ts +1 -1
  71. package/dist/ssr.js +12 -10
  72. package/dist/testing.cjs +9 -4
  73. package/dist/testing.js +3 -3
  74. package/dist/ui.cjs +54 -38
  75. package/dist/ui.js +10 -9
  76. package/dist/widgets.cjs +40 -24
  77. package/dist/widgets.js +8 -8
  78. package/package.json +3 -1
package/dist/index.d.ts CHANGED
@@ -1,7 +1,7 @@
1
1
  import { T as TagProps, N as NodeChildren, a as NodeChild } from './tagFactory-S17H2qxu.js';
2
2
  export { D as Dispose, S as SVG_NS, t as tagFactory } from './tagFactory-S17H2qxu.js';
3
3
  import { R as ReactiveSignal } from './signal-BnWpq6WB.js';
4
- export { T as TrustedHTML, t as trustHTML } from './ssr-CrVNy6Pa.js';
4
+ export { T as TrustedHTML, t as trustHTML } from './ssr-D62yFwuw.js';
5
5
 
6
6
  type reactive<T> = T | (() => T);
7
7
  interface AnchorProps extends TagProps {
@@ -1226,11 +1226,24 @@ declare function strictEffect(fn: () => void): () => void;
1226
1226
  interface SSRStore {
1227
1227
  ssr: boolean;
1228
1228
  suspenseIdCounter: number;
1229
+ /**
1230
+ * Per-request data caches (e.g. the query cache). Lazily created and keyed
1231
+ * by subsystem so request-scoped data never bleeds between concurrent
1232
+ * server renders. Typed loosely to avoid a dependency cycle with data/.
1233
+ */
1234
+ caches?: Map<string, Map<string, unknown>>;
1229
1235
  }
1230
1236
  /** Returns the active store (ALS or fallback). */
1231
1237
  declare function getSSRStore(): SSRStore;
1232
1238
  /** Returns true when running in SSR mode. */
1233
1239
  declare function isSSR(): boolean;
1240
+ /**
1241
+ * Returns a request-scoped cache map for the given subsystem when running
1242
+ * under SSR (so concurrent requests never share it), or `null` on the client
1243
+ * where a process-global cache is correct. On Node the store is backed by
1244
+ * AsyncLocalStorage, giving each request its own caches.
1245
+ */
1246
+ declare function getRequestScopedCache<V>(name: string): Map<string, V> | null;
1234
1247
  /** Enable SSR mode. Side effects (effect, watch, onMount) become no-ops. */
1235
1248
  declare function enableSSR(): void;
1236
1249
  /** Disable SSR mode. Side effects resume normal behavior. */
@@ -1538,4 +1551,4 @@ interface LoadingProps {
1538
1551
  */
1539
1552
  declare function Loading(props?: LoadingProps): HTMLElement;
1540
1553
 
1541
- export { type Accessor, type ActionFn, type AnchorProps, type ArrayActions, type AsyncDerivedState, type AudioProps, type ButtonProps, type Context, DynamicComponent, type EffectBody, type EffectOptions, ErrorBoundary, type ErrorBoundaryOptions, type ErrorBoundaryProps, ErrorDisplay, type ErrorDisplayProps, type ErrorSeverity, type FormProps, Fragment, type ImgProps, type InputProps, type InputType, KeepAlive, type KeepAliveOptions, type LabelProps, Loading, type LoadingProps, type LongPressOptions, type MediaProps, NodeChild, NodeChildren, type OnCleanup, type OptionProps, Portal, type Ref, type SSRStore, type SelectProps, type SignalOptions, type SlotFn, type Slots, type StoreActions, Suspense, type SuspenseProps, TagProps, type TextareaProps, type TypedTagFunction, type VideoProps, __resetIdCounter, a, abbr, action, address, area, array, article, aside, asyncDerived, audio, autoResize, b, base, batch, bdi, bdo, bindDynamic, blockquote, body, br, button, canvas, caption, catchError, catchErrorAsync, center, checkLeaks, circle, cite, clickOutside, clipPath, code, col, colgroup, context, copyOnClick, createId, customElement, data, datalist, dd, deepEqual, deepSignal, defer, defs, del, derived, details, dfn, dialog, disableSSR, dispose, div, dl, dt, each, effect, ellipse, em, embed, enableSSR, enqueueBatchedSignal, fieldset, figcaption, figure, font, footer, form, g, getSSRStore, getSlot, h1, h2, h3, h4, h5, h6, head, header, hr, html, i, iframe, img, input, ins, isBatching, isSSR, kbd, label, lazy, legend, li, line, linearGradient, link, longPress, main, map, mark, marker, marquee, mask, match, math, menu, meta, meter, mount, nav, nextTick, noscript, object, ol, on, onCleanup, onMount, onUnmount, optgroup, option, output, p, param, path, pattern, picture, polygon, polyline, portal, pre, progress, q, radialGradient, reactiveArray, rect, ref, registerComponent, registerDisposer, resolveComponent, retrack, rp, rt, ruby, runInSSRContext, s, samp, script, section, select, setGlobalErrorHandler, setMaxDrainIterations, show, signal, slot, small, source, span, stop, store, strict, strictEffect, strong, style, sub, summary, sup, svg, symbol, table, takePendingError, tbody, td, template, text, textarea, tfoot, th, thead, time, title, tr, track, transition, trapFocus, tspan, u, ul, unregisterComponent, untracked, use, var_, video, watch, when, withSSR, writable };
1554
+ export { type Accessor, type ActionFn, type AnchorProps, type ArrayActions, type AsyncDerivedState, type AudioProps, type ButtonProps, type Context, DynamicComponent, type EffectBody, type EffectOptions, ErrorBoundary, type ErrorBoundaryOptions, type ErrorBoundaryProps, ErrorDisplay, type ErrorDisplayProps, type ErrorSeverity, type FormProps, Fragment, type ImgProps, type InputProps, type InputType, KeepAlive, type KeepAliveOptions, type LabelProps, Loading, type LoadingProps, type LongPressOptions, type MediaProps, NodeChild, NodeChildren, type OnCleanup, type OptionProps, Portal, type Ref, type SSRStore, type SelectProps, type SignalOptions, type SlotFn, type Slots, type StoreActions, Suspense, type SuspenseProps, TagProps, type TextareaProps, type TypedTagFunction, type VideoProps, __resetIdCounter, a, abbr, action, address, area, array, article, aside, asyncDerived, audio, autoResize, b, base, batch, bdi, bdo, bindDynamic, blockquote, body, br, button, canvas, caption, catchError, catchErrorAsync, center, checkLeaks, circle, cite, clickOutside, clipPath, code, col, colgroup, context, copyOnClick, createId, customElement, data, datalist, dd, deepEqual, deepSignal, defer, defs, del, derived, details, dfn, dialog, disableSSR, dispose, div, dl, dt, each, effect, ellipse, em, embed, enableSSR, enqueueBatchedSignal, fieldset, figcaption, figure, font, footer, form, g, getRequestScopedCache, getSSRStore, getSlot, h1, h2, h3, h4, h5, h6, head, header, hr, html, i, iframe, img, input, ins, isBatching, isSSR, kbd, label, lazy, legend, li, line, linearGradient, link, longPress, main, map, mark, marker, marquee, mask, match, math, menu, meta, meter, mount, nav, nextTick, noscript, object, ol, on, onCleanup, onMount, onUnmount, optgroup, option, output, p, param, path, pattern, picture, polygon, polyline, portal, pre, progress, q, radialGradient, reactiveArray, rect, ref, registerComponent, registerDisposer, resolveComponent, retrack, rp, rt, ruby, runInSSRContext, s, samp, script, section, select, setGlobalErrorHandler, setMaxDrainIterations, show, signal, slot, small, source, span, stop, store, strict, strictEffect, strong, style, sub, summary, sup, svg, symbol, table, takePendingError, tbody, td, template, text, textarea, tfoot, th, thead, time, title, tr, track, transition, trapFocus, tspan, u, ul, unregisterComponent, untracked, use, var_, video, watch, when, withSSR, writable };
package/dist/index.js CHANGED
@@ -44,7 +44,7 @@ import {
44
44
  unregisterComponent,
45
45
  when,
46
46
  writable
47
- } from "./chunk-CR4MXPHB.js";
47
+ } from "./chunk-V2MTG5FT.js";
48
48
  import {
49
49
  __resetIdCounter,
50
50
  createId
@@ -186,55 +186,56 @@ import {
186
186
  use,
187
187
  var_,
188
188
  video
189
- } from "./chunk-2HAGQWDV.js";
189
+ } from "./chunk-5N74TKLD.js";
190
190
  import {
191
191
  watch
192
- } from "./chunk-3DJH25UO.js";
192
+ } from "./chunk-H6PCHJZQ.js";
193
193
  import {
194
194
  trustHTML
195
- } from "./chunk-JYD2PWXH.js";
195
+ } from "./chunk-HXMS4SNP.js";
196
196
  import {
197
197
  context
198
- } from "./chunk-EFOAE5NC.js";
198
+ } from "./chunk-YFDGQWDA.js";
199
199
  import {
200
200
  SVG_NS,
201
201
  tagFactory
202
- } from "./chunk-WKUXSE7V.js";
202
+ } from "./chunk-X67UYC74.js";
203
203
  import {
204
204
  bindDynamic
205
- } from "./chunk-2ZJ7TSW4.js";
205
+ } from "./chunk-RLUJL2MV.js";
206
206
  import {
207
207
  derived
208
- } from "./chunk-SC437AMI.js";
208
+ } from "./chunk-JYXOEYI4.js";
209
209
  import {
210
210
  checkLeaks,
211
211
  dispose,
212
212
  registerDisposer
213
213
  } from "./chunk-2UPRY23K.js";
214
- import "./chunk-UCS6AMJ7.js";
214
+ import "./chunk-HMJFCBRR.js";
215
215
  import {
216
216
  effect,
217
217
  on
218
- } from "./chunk-ZIBE2SAT.js";
218
+ } from "./chunk-FDY42FIU.js";
219
219
  import {
220
220
  disableSSR,
221
221
  enableSSR,
222
+ getRequestScopedCache,
222
223
  getSSRStore,
223
224
  isSSR,
224
225
  runInSSRContext,
225
226
  withSSR
226
- } from "./chunk-2RA7SHDA.js";
227
+ } from "./chunk-GOJMFRBL.js";
227
228
  import {
228
229
  batch,
229
230
  enqueueBatchedSignal,
230
231
  isBatching,
231
232
  signal
232
- } from "./chunk-RK4BQG25.js";
233
+ } from "./chunk-C427DVQF.js";
233
234
  import {
234
235
  retrack,
235
236
  setMaxDrainIterations,
236
237
  untracked
237
- } from "./chunk-3U4ZVXVD.js";
238
+ } from "./chunk-Z2FWAE4B.js";
238
239
  import "./chunk-LMLD24FC.js";
239
240
  export {
240
241
  DynamicComponent,
@@ -316,6 +317,7 @@ export {
316
317
  footer,
317
318
  form,
318
319
  g,
320
+ getRequestScopedCache,
319
321
  getSSRStore,
320
322
  getSlot,
321
323
  h1,
@@ -370,7 +370,7 @@ declare function withErrorTracking(name: string, component: () => HTMLElement, r
370
370
  */
371
371
  declare function formatError(error: Error, context?: {
372
372
  component?: string;
373
- }): string;
373
+ }, seen?: Set<Error>): string;
374
374
 
375
375
  /**
376
376
  * Registers a reactive value for DevTools inspection.
@@ -370,7 +370,7 @@ declare function withErrorTracking(name: string, component: () => HTMLElement, r
370
370
  */
371
371
  declare function formatError(error: Error, context?: {
372
372
  component?: string;
373
- }): string;
373
+ }, seen?: Set<Error>): string;
374
374
 
375
375
  /**
376
376
  * Registers a reactive value for DevTools inspection.
package/dist/motion.cjs CHANGED
@@ -58,11 +58,17 @@ function transition(element, options = {}) {
58
58
  } = options;
59
59
  const transitionValue = `${property} ${duration}ms ${easing} ${delay}ms`;
60
60
  let activeTimer = null;
61
+ let pendingResolve = null;
61
62
  function cancelPending() {
62
63
  if (activeTimer !== null) {
63
64
  clearTimeout(activeTimer);
64
65
  activeTimer = null;
65
66
  }
67
+ if (pendingResolve !== null) {
68
+ const resolvePrev = pendingResolve;
69
+ pendingResolve = null;
70
+ resolvePrev();
71
+ }
66
72
  }
67
73
  function enter() {
68
74
  return new Promise((resolve) => {
@@ -74,11 +80,13 @@ function transition(element, options = {}) {
74
80
  if (activeClass) element.classList.add(activeClass);
75
81
  const done = () => {
76
82
  activeTimer = null;
83
+ pendingResolve = null;
77
84
  if (enterClass) element.classList.remove(enterClass);
78
85
  onEnterDone?.();
79
86
  resolve();
80
87
  };
81
88
  if (duration > 0) {
89
+ pendingResolve = resolve;
82
90
  activeTimer = setTimeout(done, duration + delay);
83
91
  } else {
84
92
  done();
@@ -94,11 +102,13 @@ function transition(element, options = {}) {
94
102
  if (enterClass) element.classList.remove(enterClass);
95
103
  const done = () => {
96
104
  activeTimer = null;
105
+ pendingResolve = null;
97
106
  if (leaveClass) element.classList.remove(leaveClass);
98
107
  onLeaveDone?.();
99
108
  resolve();
100
109
  };
101
110
  if (duration > 0) {
111
+ pendingResolve = resolve;
102
112
  activeTimer = setTimeout(done, duration + delay);
103
113
  } else {
104
114
  done();
package/dist/motion.js CHANGED
@@ -19,9 +19,9 @@ import {
19
19
  stagger,
20
20
  transition,
21
21
  viewTransition
22
- } from "./chunk-GQ7RRFPU.js";
23
- import "./chunk-RK4BQG25.js";
24
- import "./chunk-3U4ZVXVD.js";
22
+ } from "./chunk-FOI23UJL.js";
23
+ import "./chunk-C427DVQF.js";
24
+ import "./chunk-Z2FWAE4B.js";
25
25
  import "./chunk-LMLD24FC.js";
26
26
  export {
27
27
  TransitionGroup,
package/dist/patterns.cjs CHANGED
@@ -209,7 +209,7 @@ function track(effectFn, subscriber) {
209
209
  function reactiveBinding(commit) {
210
210
  const run = () => {
211
211
  const s = subscriber;
212
- if (s._reentrant) return;
212
+ if (s._disposed || s._reentrant) return;
213
213
  s._reentrant = true;
214
214
  try {
215
215
  retrack(commit, subscriber);
@@ -225,8 +225,12 @@ function reactiveBinding(commit) {
225
225
  subscriber._runEpoch = 0;
226
226
  subscriber._runs = 0;
227
227
  subscriber._reentrant = false;
228
+ subscriber._disposed = false;
228
229
  run();
229
- return subscriber._dispose ?? (subscriber._dispose = () => cleanup(subscriber));
230
+ return subscriber._dispose ?? (subscriber._dispose = () => {
231
+ subscriber._disposed = true;
232
+ cleanup(subscriber);
233
+ });
230
234
  }
231
235
  function recordDependency(signal2) {
232
236
  if (!currentSubscriber) return;
@@ -509,6 +513,19 @@ function signal(initial, options) {
509
513
  return [get, set];
510
514
  }
511
515
 
516
+ // src/utils/guards.ts
517
+ var UNSAFE_KEYS = /* @__PURE__ */ new Set(["__proto__", "constructor", "prototype"]);
518
+ function isUnsafeKey(key) {
519
+ return UNSAFE_KEYS.has(key);
520
+ }
521
+ function stripUnsafeKeys(obj) {
522
+ const out = {};
523
+ for (const k of Object.keys(obj)) {
524
+ if (!isUnsafeKey(k)) out[k] = obj[k];
525
+ }
526
+ return out;
527
+ }
528
+
512
529
  // src/patterns/machine.ts
513
530
  function machine(config) {
514
531
  const [state, setState] = signal(config.initial);
@@ -540,11 +557,7 @@ function machine(config) {
540
557
  }
541
558
  if (action) {
542
559
  const rawPatch = action(ctx);
543
- const next = { ...ctx };
544
- for (const key of Object.keys(rawPatch)) {
545
- if (key === "__proto__" || key === "constructor" || key === "prototype") continue;
546
- next[key] = rawPatch[key];
547
- }
560
+ const next = { ...ctx, ...stripUnsafeKeys(rawPatch) };
548
561
  setContext(next);
549
562
  }
550
563
  setState(target);
@@ -575,11 +588,15 @@ function machine(config) {
575
588
  var als = null;
576
589
  try {
577
590
  if (typeof process !== "undefined" && process.versions && process.versions.node) {
578
- const req = Function("return typeof require==='function'?require:null")();
579
- if (req) {
580
- const mod = req("node:async_hooks");
581
- als = new mod.AsyncLocalStorage();
591
+ let mod = null;
592
+ const getBuiltin = process.getBuiltinModule;
593
+ if (typeof getBuiltin === "function") {
594
+ mod = getBuiltin("node:async_hooks");
595
+ } else {
596
+ const req = Function("return typeof require==='function'?require:null")();
597
+ if (req) mod = req("node:async_hooks");
582
598
  }
599
+ if (mod) als = new mod.AsyncLocalStorage();
583
600
  }
584
601
  } catch {
585
602
  als = null;
@@ -681,6 +698,7 @@ function effect(effectFn, options) {
681
698
  ctx.fn(ctx.onCleanup);
682
699
  };
683
700
  const sub = (() => {
701
+ if (ctx.disposed) return;
684
702
  if (ctx.running) {
685
703
  ctx.rerunPending = true;
686
704
  return;
@@ -720,10 +738,7 @@ function effect(effectFn, options) {
720
738
  function persisted(key, initial, options = {}) {
721
739
  const storage = options.session ? sessionStorage : localStorage;
722
740
  const serialize = options.serialize || JSON.stringify;
723
- const safeReviver = (k, v) => {
724
- if (k === "__proto__" || k === "constructor" || k === "prototype") return void 0;
725
- return v;
726
- };
741
+ const safeReviver = (k, v) => isUnsafeKey(k) ? void 0 : v;
727
742
  const deserialize = options.deserialize || ((raw) => JSON.parse(raw, safeReviver));
728
743
  const encrypt = options.encrypt;
729
744
  const decrypt = options.decrypt;
@@ -945,6 +960,7 @@ function derived(getter, options) {
945
960
  const equals = options?.equals;
946
961
  const cs = {};
947
962
  cs._d = false;
963
+ cs._init = false;
948
964
  cs._g = getter;
949
965
  cs.__v = 0;
950
966
  const markDirty = () => {
@@ -953,11 +969,18 @@ function derived(getter, options) {
953
969
  };
954
970
  markDirty._c = 1;
955
971
  markDirty._sig = cs;
972
+ const recompute = () => {
973
+ const next = getter();
974
+ cs._v = equals && cs._init ? equals(cs._v, next) ? cs._v : next : next;
975
+ cs._d = false;
976
+ cs._init = true;
977
+ };
956
978
  track(() => {
957
979
  let threw = true;
958
980
  try {
959
981
  cs._v = getter();
960
982
  cs._d = false;
983
+ cs._init = true;
961
984
  threw = false;
962
985
  } finally {
963
986
  if (threw) cs._d = true;
@@ -973,20 +996,13 @@ function derived(getter, options) {
973
996
  }
974
997
  if (trackingSuspended) {
975
998
  if (cs._d) {
999
+ const prev = cs._v;
976
1000
  evaluating = true;
977
- let threw = true;
978
1001
  try {
979
- const prev = cs._v;
980
- retrack(() => {
981
- const next = getter();
982
- cs._v = equals && cs._v !== void 0 ? equals(cs._v, next) ? cs._v : next : next;
983
- cs._d = false;
984
- threw = false;
985
- }, markDirty);
1002
+ retrack(recompute, markDirty);
986
1003
  if (!Object.is(prev, cs._v)) cs.__v++;
987
1004
  } finally {
988
1005
  evaluating = false;
989
- if (threw) cs._d = true;
990
1006
  }
991
1007
  }
992
1008
  return cs._v;
@@ -995,18 +1011,11 @@ function derived(getter, options) {
995
1011
  if (cs._d) {
996
1012
  const oldValue = cs._v;
997
1013
  evaluating = true;
998
- let threw = true;
999
1014
  try {
1000
- retrack(() => {
1001
- const next = getter();
1002
- cs._v = equals && cs._v !== void 0 ? equals(cs._v, next) ? cs._v : next : next;
1003
- cs._d = false;
1004
- threw = false;
1005
- }, markDirty);
1015
+ retrack(recompute, markDirty);
1006
1016
  if (!Object.is(oldValue, cs._v)) cs.__v++;
1007
1017
  } finally {
1008
1018
  evaluating = false;
1009
- if (threw) cs._d = true;
1010
1019
  }
1011
1020
  if (hook && oldValue !== cs._v) {
1012
1021
  hook.emit("computed:update", { signal: cs, oldValue, newValue: cs._v });
@@ -1098,6 +1107,7 @@ function deepClone(value) {
1098
1107
  if (Array.isArray(v)) return v.map(clone);
1099
1108
  const out = {};
1100
1109
  for (const k of Object.keys(v)) {
1110
+ if (k === "__proto__") continue;
1101
1111
  out[k] = clone(v[k]);
1102
1112
  }
1103
1113
  return out;
@@ -1115,12 +1125,7 @@ function globalStore(config) {
1115
1125
  const execute = () => {
1116
1126
  const current = getState();
1117
1127
  const rawPatch = actionFn(current, payload);
1118
- const patch = {};
1119
- for (const key of Object.keys(rawPatch)) {
1120
- if (key !== "__proto__" && key !== "constructor" && key !== "prototype") {
1121
- patch[key] = rawPatch[key];
1122
- }
1123
- }
1128
+ const patch = stripUnsafeKeys(rawPatch);
1124
1129
  setState({ ...current, ...patch });
1125
1130
  const newState = getState();
1126
1131
  for (const listener of listeners) {
@@ -1193,7 +1198,7 @@ function withBoundary(name, component) {
1193
1198
  function createSlots(slots) {
1194
1199
  return {
1195
1200
  renderSlot(name, fallback) {
1196
- const slotFn = slots[name];
1201
+ const slotFn = Object.hasOwn(slots, name) ? slots[name] : void 0;
1197
1202
  if (slotFn) {
1198
1203
  const result = slotFn();
1199
1204
  if (Array.isArray(result)) {
@@ -1207,7 +1212,7 @@ function createSlots(slots) {
1207
1212
  return fallback ? fallback() : null;
1208
1213
  },
1209
1214
  hasSlot(name) {
1210
- return name in slots;
1215
+ return Object.hasOwn(slots, name);
1211
1216
  }
1212
1217
  };
1213
1218
  }
package/dist/patterns.js CHANGED
@@ -5,7 +5,7 @@ import {
5
5
  optimisticList,
6
6
  persisted,
7
7
  timeline
8
- } from "./chunk-KB3BA2XK.js";
8
+ } from "./chunk-NFYWLRUO.js";
9
9
  import {
10
10
  RenderProp,
11
11
  assertType,
@@ -21,12 +21,13 @@ import {
21
21
  withDefaults,
22
22
  withProps,
23
23
  withWrapper
24
- } from "./chunk-CNZ35WI2.js";
25
- import "./chunk-SC437AMI.js";
26
- import "./chunk-ZIBE2SAT.js";
27
- import "./chunk-2RA7SHDA.js";
28
- import "./chunk-RK4BQG25.js";
29
- import "./chunk-3U4ZVXVD.js";
24
+ } from "./chunk-VJE6DDYM.js";
25
+ import "./chunk-H3SRKIYX.js";
26
+ import "./chunk-JYXOEYI4.js";
27
+ import "./chunk-FDY42FIU.js";
28
+ import "./chunk-GOJMFRBL.js";
29
+ import "./chunk-C427DVQF.js";
30
+ import "./chunk-Z2FWAE4B.js";
30
31
  import "./chunk-LMLD24FC.js";
31
32
  export {
32
33
  RenderProp,
@@ -105,11 +105,26 @@ function processQueue() {
105
105
  scheduleFrame();
106
106
  }
107
107
  }
108
+ var TIER_SPEED = { microtask: 0, frame: 1, timeout: 2, idle: 3 };
109
+ function cancelScheduled() {
110
+ if (scheduledHandle !== null) {
111
+ if (scheduledKind === "frame") cancelAnimationFrame(scheduledHandle);
112
+ else if (scheduledKind === "idle" && typeof cancelIdleCallback !== "undefined") cancelIdleCallback(scheduledHandle);
113
+ else if (scheduledKind === "timeout") clearTimeout(scheduledHandle);
114
+ }
115
+ scheduledHandle = null;
116
+ scheduledKind = null;
117
+ }
108
118
  function scheduleFrame() {
109
- if (scheduledKind !== null || microtaskScheduled) return;
110
119
  const nextTask = taskQueue.find((t) => !t.cancelled);
111
120
  if (!nextTask) return;
112
- if (nextTask.priority <= Priority.USER_BLOCKING) {
121
+ const desired = nextTask.priority <= Priority.USER_BLOCKING ? "microtask" : nextTask.priority === Priority.IDLE ? typeof requestIdleCallback !== "undefined" ? "idle" : "timeout" : "frame";
122
+ if (microtaskScheduled) return;
123
+ if (scheduledKind !== null) {
124
+ if (TIER_SPEED[scheduledKind] <= TIER_SPEED[desired]) return;
125
+ cancelScheduled();
126
+ }
127
+ if (desired === "microtask") {
113
128
  microtaskScheduled = true;
114
129
  scheduledKind = "microtask";
115
130
  queueMicrotask(() => {
@@ -117,22 +132,20 @@ function scheduleFrame() {
117
132
  scheduledKind = null;
118
133
  processQueue();
119
134
  });
120
- } else if (nextTask.priority === Priority.IDLE) {
121
- if (typeof requestIdleCallback !== "undefined") {
122
- scheduledKind = "idle";
123
- scheduledHandle = requestIdleCallback(() => {
124
- scheduledKind = null;
125
- scheduledHandle = null;
126
- processQueue();
127
- });
128
- } else {
129
- scheduledKind = "timeout";
130
- scheduledHandle = setTimeout(() => {
131
- scheduledKind = null;
132
- scheduledHandle = null;
133
- processQueue();
134
- }, 50);
135
- }
135
+ } else if (desired === "idle") {
136
+ scheduledKind = "idle";
137
+ scheduledHandle = requestIdleCallback(() => {
138
+ scheduledKind = null;
139
+ scheduledHandle = null;
140
+ processQueue();
141
+ });
142
+ } else if (desired === "timeout") {
143
+ scheduledKind = "timeout";
144
+ scheduledHandle = setTimeout(() => {
145
+ scheduledKind = null;
146
+ scheduledHandle = null;
147
+ processQueue();
148
+ }, 50);
136
149
  } else {
137
150
  scheduledKind = "frame";
138
151
  scheduledHandle = requestAnimationFrame(() => {
@@ -197,7 +210,7 @@ function yieldToMain() {
197
210
  async function processInChunks(items, processor, chunkSize = 50) {
198
211
  for (let i = 0; i < items.length; i++) {
199
212
  processor(items[i], i);
200
- if (i > 0 && i % chunkSize === 0) {
213
+ if ((i + 1) % chunkSize === 0 && i + 1 < items.length) {
201
214
  await yieldToMain();
202
215
  }
203
216
  }
@@ -501,11 +514,15 @@ function notifySubscribers(signal2) {
501
514
  var als = null;
502
515
  try {
503
516
  if (typeof process !== "undefined" && process.versions && process.versions.node) {
504
- const req = Function("return typeof require==='function'?require:null")();
505
- if (req) {
506
- const mod = req("node:async_hooks");
507
- als = new mod.AsyncLocalStorage();
517
+ let mod = null;
518
+ const getBuiltin = process.getBuiltinModule;
519
+ if (typeof getBuiltin === "function") {
520
+ mod = getBuiltin("node:async_hooks");
521
+ } else {
522
+ const req = Function("return typeof require==='function'?require:null")();
523
+ if (req) mod = req("node:async_hooks");
508
524
  }
525
+ if (mod) als = new mod.AsyncLocalStorage();
509
526
  }
510
527
  } catch {
511
528
  als = null;
@@ -607,6 +624,7 @@ function effect(effectFn, options) {
607
624
  ctx.fn(ctx.onCleanup);
608
625
  };
609
626
  const sub = (() => {
627
+ if (ctx.disposed) return;
610
628
  if (ctx.running) {
611
629
  ctx.rerunPending = true;
612
630
  return;
@@ -1053,7 +1071,65 @@ function denormalize(id, entities, schema) {
1053
1071
  return result;
1054
1072
  }
1055
1073
 
1074
+ // src/core/rendering/dispose.ts
1075
+ var elementDisposers = /* @__PURE__ */ new WeakMap();
1076
+ var _isDev6 = isDev();
1077
+ var activeBindingCount = 0;
1078
+ function dispose(node) {
1079
+ const stack = [node];
1080
+ const order = [];
1081
+ while (stack.length > 0) {
1082
+ const current = stack.pop();
1083
+ order.push(current);
1084
+ const children = Array.from(current.childNodes);
1085
+ for (let i = 0; i < children.length; i++) {
1086
+ stack.push(children[i]);
1087
+ }
1088
+ }
1089
+ for (let i = order.length - 1; i >= 0; i--) {
1090
+ const current = order[i];
1091
+ const disposers = elementDisposers.get(current);
1092
+ if (disposers) {
1093
+ const snapshot = disposers.slice();
1094
+ elementDisposers.delete(current);
1095
+ if (_isDev6) activeBindingCount -= snapshot.length;
1096
+ for (const d of snapshot) {
1097
+ try {
1098
+ d();
1099
+ } catch (err) {
1100
+ if (_isDev6 && typeof console !== "undefined") {
1101
+ console.warn("[SibuJS] Disposer threw during cleanup:", err);
1102
+ }
1103
+ }
1104
+ }
1105
+ let extraPasses = 0;
1106
+ while (extraPasses++ < 8) {
1107
+ const added = elementDisposers.get(current);
1108
+ if (!added || added.length === 0) break;
1109
+ const moreSnapshot = added.slice();
1110
+ elementDisposers.delete(current);
1111
+ if (_isDev6) activeBindingCount -= moreSnapshot.length;
1112
+ for (const d of moreSnapshot) {
1113
+ try {
1114
+ d();
1115
+ } catch (err) {
1116
+ if (_isDev6 && typeof console !== "undefined") {
1117
+ console.warn("[SibuJS] Disposer threw during cleanup:", err);
1118
+ }
1119
+ }
1120
+ }
1121
+ }
1122
+ }
1123
+ }
1124
+ }
1125
+
1056
1126
  // src/performance/chunkLoader.ts
1127
+ function clearChildren(el) {
1128
+ while (el.firstChild) {
1129
+ dispose(el.firstChild);
1130
+ el.removeChild(el.firstChild);
1131
+ }
1132
+ }
1057
1133
  function createChunkRegistry(config = {}) {
1058
1134
  const {
1059
1135
  maxCacheSize = 50,
@@ -1218,10 +1294,10 @@ function lazyChunk(id, loader, registry, fallback) {
1218
1294
  const mod = await loader();
1219
1295
  return typeof mod === "function" ? mod : mod.default;
1220
1296
  }).then((component) => {
1221
- container.innerHTML = "";
1297
+ clearChildren(container);
1222
1298
  container.appendChild(component());
1223
1299
  }).catch((err) => {
1224
- container.innerHTML = "";
1300
+ clearChildren(container);
1225
1301
  const errorEl = document.createElement("div");
1226
1302
  errorEl.textContent = `Failed to load chunk '${id}': ${err.message}`;
1227
1303
  container.appendChild(errorEl);
@@ -1,5 +1,5 @@
1
- import { T as TrustedHTML } from './ssr-CrVNy6Pa.cjs';
2
- export { t as trustHTML } from './ssr-CrVNy6Pa.cjs';
1
+ import { T as TrustedHTML } from './ssr-D62yFwuw.cjs';
2
+ export { t as trustHTML } from './ssr-D62yFwuw.cjs';
3
3
 
4
4
  declare const Priority: {
5
5
  readonly IMMEDIATE: 0;
@@ -1,5 +1,5 @@
1
- import { T as TrustedHTML } from './ssr-CrVNy6Pa.js';
2
- export { t as trustHTML } from './ssr-CrVNy6Pa.js';
1
+ import { T as TrustedHTML } from './ssr-D62yFwuw.js';
2
+ export { t as trustHTML } from './ssr-D62yFwuw.js';
3
3
 
4
4
  declare const Priority: {
5
5
  readonly IMMEDIATE: 0;
@@ -33,15 +33,16 @@ import {
33
33
  transitionState,
34
34
  uniqueId,
35
35
  yieldToMain
36
- } from "./chunk-3DYB5B3S.js";
36
+ } from "./chunk-4JCAUOLN.js";
37
37
  import {
38
38
  trustHTML
39
- } from "./chunk-JYD2PWXH.js";
40
- import "./chunk-UCS6AMJ7.js";
41
- import "./chunk-ZIBE2SAT.js";
42
- import "./chunk-2RA7SHDA.js";
43
- import "./chunk-RK4BQG25.js";
44
- import "./chunk-3U4ZVXVD.js";
39
+ } from "./chunk-HXMS4SNP.js";
40
+ import "./chunk-2UPRY23K.js";
41
+ import "./chunk-HMJFCBRR.js";
42
+ import "./chunk-FDY42FIU.js";
43
+ import "./chunk-GOJMFRBL.js";
44
+ import "./chunk-C427DVQF.js";
45
+ import "./chunk-Z2FWAE4B.js";
45
46
  import "./chunk-LMLD24FC.js";
46
47
  export {
47
48
  DOMPool,