sibujs 4.3.0 → 4.5.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 (77) hide show
  1. package/README.md +34 -4
  2. package/dist/browser.cjs +31 -2
  3. package/dist/browser.d.cts +15 -2
  4. package/dist/browser.d.ts +15 -2
  5. package/dist/browser.js +4 -4
  6. package/dist/build.cjs +92 -13
  7. package/dist/build.js +10 -10
  8. package/dist/cdn.dev.global.js +10 -10
  9. package/dist/cdn.full.dev.global.js +400 -0
  10. package/dist/cdn.full.global.js +398 -0
  11. package/dist/cdn.global.js +10 -10
  12. package/dist/{chunk-GZYQNIPS.js → chunk-2DCGACUU.js} +16 -9
  13. package/dist/{chunk-7BPN4MXR.js → chunk-3JZ4L5TJ.js} +10 -4
  14. package/dist/{chunk-R4EF7V3K.js → chunk-4PMLNECI.js} +4 -4
  15. package/dist/{chunk-IYHM4FWD.js → chunk-7LN645I6.js} +1 -1
  16. package/dist/{chunk-RE6KLGMV.js → chunk-B3WHI2QA.js} +1 -1
  17. package/dist/{chunk-ZVYNIUOG.js → chunk-FTIR4QW2.js} +13 -3
  18. package/dist/{chunk-G7GPNB6N.js → chunk-GW3SCCZG.js} +4 -4
  19. package/dist/{chunk-XGCZ45NH.js → chunk-KEISJXBU.js} +2 -2
  20. package/dist/{chunk-UD6YE2GW.js → chunk-OMJJM3KM.js} +2 -2
  21. package/dist/{chunk-7UBG6LDP.js → chunk-ONOHFDLG.js} +9 -1
  22. package/dist/{chunk-7UK6BSAT.js → chunk-PCT43HW3.js} +1 -1
  23. package/dist/{chunk-VJE6DDYM.js → chunk-R25EFXXC.js} +40 -26
  24. package/dist/{chunk-3E5YNK2F.js → chunk-RBTPLM32.js} +46 -8
  25. package/dist/{chunk-7BJLKDBI.js → chunk-RIXRAYIU.js} +1 -1
  26. package/dist/{chunk-7GQIRV27.js → chunk-RJE2BNI4.js} +3 -3
  27. package/dist/{chunk-2LSY4WDM.js → chunk-S373NSMK.js} +18 -13
  28. package/dist/{chunk-AAHT6AKT.js → chunk-TBYTO6BS.js} +2 -2
  29. package/dist/{chunk-TSL64O5L.js → chunk-UGRX3S57.js} +31 -2
  30. package/dist/{chunk-L4B3Y3OM.js → chunk-VUF4ALSW.js} +1 -1
  31. package/dist/{chunk-USS5ENJ2.js → chunk-VZKNK2V7.js} +9 -4
  32. package/dist/{chunk-MYA5HEK5.js → chunk-XZZOBQAY.js} +1 -1
  33. package/dist/{contracts-Hg6ITAEF.d.cts → contracts-DBdg9J_a.d.cts} +25 -4
  34. package/dist/{contracts-Hg6ITAEF.d.ts → contracts-DBdg9J_a.d.ts} +25 -4
  35. package/dist/{customElement-CNZxEB9G.d.ts → customElement-OB9CIsc5.d.cts} +38 -10
  36. package/dist/{customElement-CNZxEB9G.d.cts → customElement-OB9CIsc5.d.ts} +38 -10
  37. package/dist/data.cjs +81 -9
  38. package/dist/data.js +6 -6
  39. package/dist/devtools.cjs +41 -2
  40. package/dist/devtools.js +4 -4
  41. package/dist/ecosystem.cjs +83 -9
  42. package/dist/ecosystem.d.cts +13 -5
  43. package/dist/ecosystem.d.ts +13 -5
  44. package/dist/ecosystem.js +7 -7
  45. package/dist/extras.cjs +150 -40
  46. package/dist/extras.d.cts +3 -3
  47. package/dist/extras.d.ts +3 -3
  48. package/dist/extras.js +20 -20
  49. package/dist/index.cjs +92 -13
  50. package/dist/index.d.cts +24 -151
  51. package/dist/index.d.ts +24 -151
  52. package/dist/index.js +10 -10
  53. package/dist/motion.cjs +31 -2
  54. package/dist/motion.js +3 -3
  55. package/dist/patterns.cjs +116 -36
  56. package/dist/patterns.d.cts +6 -1
  57. package/dist/patterns.d.ts +6 -1
  58. package/dist/patterns.js +6 -6
  59. package/dist/performance.cjs +31 -2
  60. package/dist/performance.js +4 -4
  61. package/dist/plugins.cjs +39 -2
  62. package/dist/plugins.js +6 -6
  63. package/dist/ssr.cjs +39 -2
  64. package/dist/ssr.js +7 -7
  65. package/dist/tagFactory-DVoDpHye.d.cts +215 -0
  66. package/dist/tagFactory-DVoDpHye.d.ts +215 -0
  67. package/dist/testing.cjs +31 -2
  68. package/dist/testing.js +2 -2
  69. package/dist/ui.cjs +128 -39
  70. package/dist/ui.d.cts +2 -2
  71. package/dist/ui.d.ts +2 -2
  72. package/dist/ui.js +7 -7
  73. package/dist/widgets.cjs +75 -9
  74. package/dist/widgets.js +6 -6
  75. package/package.json +8 -2
  76. package/dist/tagFactory-Bzupt4Pj.d.cts +0 -55
  77. package/dist/tagFactory-Bzupt4Pj.d.ts +0 -55
@@ -0,0 +1,215 @@
1
+ declare const __accessor: unique symbol;
2
+ /**
3
+ * A reactive signal getter returned by signal(), derived(), and similar primitives.
4
+ *
5
+ * Pass an Accessor directly into reactive prop positions — never call it there:
6
+ * ```ts
7
+ * const [count, setCount] = signal(0);
8
+ *
9
+ * div(count) // ✓ reactive — Accessor passed directly
10
+ * div(() => count()) // ✓ reactive — explicit arrow wrapper
11
+ * div(count()) // ✗ static — evaluated once, not reactive
12
+ * ```
13
+ */
14
+ type Accessor<T> = (() => T) & {
15
+ readonly [__accessor]?: never;
16
+ };
17
+ type SetState<T> = (next: T | ((prev: T) => T)) => void;
18
+ type StateTuple<T> = [Accessor<T>, SetState<T>];
19
+ /** Options for signal */
20
+ interface SignalOptions<T = unknown> {
21
+ /** Debug name for devtools inspection. Only used in development. */
22
+ name?: string;
23
+ /** Custom equality function. Defaults to Object.is(). */
24
+ equals?: (prev: T, next: T) => boolean;
25
+ }
26
+ /**
27
+ * signal creates a reactive signal that holds a value of type T.
28
+ * Returns a tuple: [getter, setter].
29
+ *
30
+ * @param initial Initial value
31
+ * @param options Optional config: `{ name: "count" }` for devtools labeling
32
+ * @returns A `[getter, setter]` tuple. Calling the getter inside a reactive
33
+ * context subscribes to the signal; the setter accepts a value or an updater.
34
+ */
35
+ declare function signal<T>(initial: T, options?: SignalOptions<T>): StateTuple<T>;
36
+ /**
37
+ * A valueless reactive token standing in for state SibuJS does not own.
38
+ *
39
+ * See {@link external}.
40
+ */
41
+ interface ExternalSource {
42
+ /**
43
+ * Declare, from inside a reactive computation, that it reads the external
44
+ * state this source represents. Call it in the same places you would read a
45
+ * signal — the top of a binding getter, a `derived()` body, an `effect()`.
46
+ *
47
+ * Outside a tracking context it is a no-op, exactly like reading a signal.
48
+ */
49
+ track(): void;
50
+ /**
51
+ * Declare that the external state changed. Every consumer that called
52
+ * {@link ExternalSource.track} is invalidated.
53
+ *
54
+ * Participates in `batch()` like any signal write: inside a batch, consumers
55
+ * are notified once when the outermost batch flushes.
56
+ */
57
+ invalidate(): void;
58
+ }
59
+ /**
60
+ * Create a reactive source for state that lives outside SibuJS — a domain
61
+ * engine, a media element, a canvas scene, an editor document, a cache a
62
+ * socket writes into.
63
+ *
64
+ * The pattern is two lines: `track()` where you read, `invalidate()` after you
65
+ * mutate.
66
+ *
67
+ * ```ts
68
+ * import { Chess } from "chess.js";
69
+ * import { external } from "sibujs";
70
+ *
71
+ * const game = new Chess(); // owns the rules and the mutable state
72
+ * const moved = external(); // owns "something changed"
73
+ *
74
+ * ctx.text("@status", () => {
75
+ * moved.track(); // this binding reads the engine
76
+ * return game.isCheckmate() ? "Checkmate" : `${game.turn()} to move`;
77
+ * });
78
+ *
79
+ * game.move({ from: "e2", to: "e4" });
80
+ * moved.invalidate(); // every consumer above re-reads
81
+ * ```
82
+ *
83
+ * **One source is one invalidation domain.** Every consumer of a source
84
+ * re-runs on every `invalidate()`, so the granularity of your updates is
85
+ * exactly the granularity of your sources: one for a whole engine is the
86
+ * cheapest to write, several (`board`, `clock`, `history`) let an update touch
87
+ * only what it affects. See `docs/architecture/external-state.md` for the
88
+ * trade-offs and when subdividing is worth it.
89
+ *
90
+ * Ownership, disposal and error routing are the consumer's, not the source's:
91
+ * a disposed binding or effect is never invalidated, and a consumer that
92
+ * throws is reported through the normal runtime error pipeline with its own
93
+ * phase and node.
94
+ *
95
+ * @param options `name` labels the source in devtools (development only).
96
+ */
97
+ declare function external(options?: {
98
+ name?: string;
99
+ }): ExternalSource;
100
+
101
+ /**
102
+ * derived creates a derived reactive signal whose value updates when dependencies change.
103
+ *
104
+ * Uses lazy pull-based evaluation with a single dirty flag:
105
+ * - When a dependency changes, the computed is marked dirty (no re-evaluation).
106
+ * - Dirtiness propagates downstream via propagateDirty.
107
+ * - The getter only re-evaluates when actually read (pull-based).
108
+ * - On re-evaluation, dependencies are re-tracked via retrack() so that
109
+ * derived-of-derived chains propagate correctly without paying the full
110
+ * Set-delete + re-add cost of track()'s cleanup phase.
111
+ *
112
+ * STABILIZATION — why a dirty flag is enough:
113
+ *
114
+ * A dirty computed does NOT imply a changed value. Downstream effects are
115
+ * enqueued by `propagateDirty` at write time, before this computed has had a
116
+ * chance to recompute and compare. Rather than adding a three-color
117
+ * (CLEAN/CHECK/DIRTY) propagation pass — which an earlier revision measured as
118
+ * a regression on every benchmark, because the extra state has nothing to skip
119
+ * when values genuinely change — the engine settles the question lazily at
120
+ * DRAIN time: `cs._validate` recomputes a dirty computed and `cs.__v` is bumped
121
+ * ONLY when the new value differs under this computed's comparator. The
122
+ * scheduler compares that version against what each subscriber last observed
123
+ * and suppresses the run when nothing changed (see `depsChanged` in
124
+ * ../../reactivity/track-core.ts).
125
+ *
126
+ * That keeps the cheap boolean dirty flag AND makes `equals` actually stop
127
+ * propagation, with recomputation still fully lazy: `_validate` only ever runs
128
+ * when an effect is genuinely about to observe the value.
129
+ *
130
+ * DISPOSAL — a derived subscribes to its sources when it is created, and those
131
+ * edges live as long as the sources do. A derived created per mount (one per
132
+ * virtualized row, say) must be released when its owner goes away:
133
+ * `flag.dispose()`, or `onCleanup(flag.dispose, rowNode)` to tie it to a node.
134
+ * A disposed accessor is inert: it keeps returning the last value it settled,
135
+ * never recomputes, never re-subscribes, and never wakes downstream readers.
136
+ * Disposal is idempotent.
137
+ *
138
+ * ERRORS — a recomputation that throws is thrown to the next reader, in that
139
+ * reader's context: a binding reports it with its node (so the nearest
140
+ * `ErrorBoundary` can claim it), an effect reports it, a direct caller can catch
141
+ * it, and a derived reading another derived passes it on. A live derived stays
142
+ * dirty and recomputes on the following read; a derived that disposed itself
143
+ * during the failing run returns its frozen value afterwards.
144
+ *
145
+ * @returns An accessor for the computed value. It recomputes lazily on read
146
+ * after any dependency changes, and carries `dispose()` to release its source
147
+ * subscriptions.
148
+ */
149
+ declare function derived<T>(getter: () => T, options?: {
150
+ name?: string;
151
+ /** Custom equality — when the recomputed value equals the previous,
152
+ * downstream subscribers are not notified. Defaults to `Object.is`. */
153
+ equals?: (a: T, b: T) => boolean;
154
+ }): DerivedAccessor<T>;
155
+ /** Accessor returned by {@link derived}: read it like any getter, release it with `dispose()`. */
156
+ type DerivedAccessor<T> = Accessor<T> & {
157
+ /** Release every source subscription. The accessor then returns its last settled value. Idempotent. */
158
+ dispose: () => void;
159
+ };
160
+
161
+ /**
162
+ * Canonical disposer/teardown signature used across the framework.
163
+ *
164
+ * Returned by `effect()`, `track()`, widget `bind()` methods, and other
165
+ * subscription/lifecycle helpers. All disposers MUST be idempotent — calling
166
+ * twice should be a no-op rather than an error.
167
+ */
168
+ type Dispose = () => void;
169
+ type NodeChild = Node | Element | Text | Comment | string | number | boolean | (() => NodeChild) | null | undefined;
170
+ type NodeChildren = NodeChild | NodeChild[] | NodeChild[][] | (() => NodeChild | NodeChild[]);
171
+
172
+ declare const SVG_NS = "http://www.w3.org/2000/svg";
173
+ interface TagProps {
174
+ id?: string;
175
+ class?: string | (() => string) | Record<string, boolean | (() => boolean)>;
176
+ style?: Record<string, string | number | (() => string | number)> | string | (() => string);
177
+ ref?: {
178
+ current: Element | null;
179
+ };
180
+ nodes?: NodeChildren;
181
+ on?: Record<string, (ev: Event) => void>;
182
+ /** Called with the element after creation — useful for imperative bindings */
183
+ onElement?: (el: HTMLElement) => void;
184
+ [attr: string]: unknown;
185
+ }
186
+ /**
187
+ * Factory for creating HTML or SVG elements with reactive props and nodes.
188
+ *
189
+ * Calling conventions:
190
+ *
191
+ * tag() empty element
192
+ * tag("text") element with text content
193
+ * tag(42) element with numeric text content
194
+ * tag([childA, childB]) element with children (array)
195
+ * tag(node) element wrapping a single existing node
196
+ * tag(getter) element with a reactive child
197
+ * tag("className", children) positional: class + children
198
+ * tag({ ...props }) full props object (children via props.nodes)
199
+ * tag({ ...props }, children) props + children (no need for `nodes:` key!)
200
+ *
201
+ * The last form is the "deeply-nested shorthand" the codebase favours:
202
+ *
203
+ * div({ class: "card" }, [
204
+ * h1({ class: "title" }, "Hello"),
205
+ * p({ class: "body" }, "World"),
206
+ * div({ class: "row" }, [
207
+ * span({ id: "x" }, "child"),
208
+ * ]),
209
+ * ])
210
+ *
211
+ * `children` overrides `props.nodes` when both are present.
212
+ */
213
+ declare const tagFactory: (tag: string, ns?: string) => (first?: TagProps | NodeChildren, second?: NodeChildren) => Element;
214
+
215
+ export { type Accessor as A, type DerivedAccessor as D, type ExternalSource as E, type NodeChild as N, SVG_NS as S, type TagProps as T, type NodeChildren as a, type Dispose as b, type SignalOptions as c, derived as d, external as e, signal as s, tagFactory as t };
package/dist/testing.cjs CHANGED
@@ -1821,6 +1821,15 @@ function untracked(fn) {
1821
1821
  var subscriberEpochCounter = 0;
1822
1822
  function retrack(effectFn, subscriber) {
1823
1823
  const prev = currentSubscriber;
1824
+ let savedDepth = 0;
1825
+ let savedSuspendSub = null;
1826
+ if (trackingSuspended) {
1827
+ savedDepth = suspendDepth;
1828
+ savedSuspendSub = suspendSavedSub;
1829
+ suspendDepth = 0;
1830
+ suspendSavedSub = null;
1831
+ trackingSuspended = false;
1832
+ }
1824
1833
  currentSubscriber = subscriber;
1825
1834
  const sub = subscriber;
1826
1835
  const epoch = ++subscriberEpochCounter;
@@ -1835,6 +1844,11 @@ function retrack(effectFn, subscriber) {
1835
1844
  effectFn();
1836
1845
  } finally {
1837
1846
  currentSubscriber = prev;
1847
+ if (savedDepth !== 0) {
1848
+ suspendDepth = savedDepth;
1849
+ suspendSavedSub = savedSuspendSub;
1850
+ trackingSuspended = true;
1851
+ }
1838
1852
  let node = sub.depsHead ?? null;
1839
1853
  while (node !== null) {
1840
1854
  const next = node.subNext;
@@ -1854,11 +1868,25 @@ function track(effectFn, subscriber) {
1854
1868
  if (!subscriber) return reactiveBinding(effectFn);
1855
1869
  cleanup(subscriber);
1856
1870
  const prev = currentSubscriber;
1871
+ let savedDepth = 0;
1872
+ let savedSuspendSub = null;
1873
+ if (trackingSuspended) {
1874
+ savedDepth = suspendDepth;
1875
+ savedSuspendSub = suspendSavedSub;
1876
+ suspendDepth = 0;
1877
+ suspendSavedSub = null;
1878
+ trackingSuspended = false;
1879
+ }
1857
1880
  currentSubscriber = subscriber;
1858
1881
  try {
1859
1882
  effectFn();
1860
1883
  } finally {
1861
1884
  currentSubscriber = prev;
1885
+ if (savedDepth !== 0) {
1886
+ suspendDepth = savedDepth;
1887
+ suspendSavedSub = savedSuspendSub;
1888
+ trackingSuspended = true;
1889
+ }
1862
1890
  const sub2 = subscriber;
1863
1891
  for (let n = sub2.depsHead ?? null; n !== null; n = n.subNext) {
1864
1892
  const sig = n.sig;
@@ -2029,8 +2057,9 @@ function propagateDirty(sub) {
2029
2057
  if (s._c) {
2030
2058
  const nSig = s._sig;
2031
2059
  if (nSig) {
2032
- if (!nSig._d) {
2060
+ if (!nSig._d || nSig._f === true) {
2033
2061
  nSig._d = true;
2062
+ nSig._f = false;
2034
2063
  stack.push(nSig);
2035
2064
  }
2036
2065
  } else {
@@ -2130,7 +2159,7 @@ function forEachSubscriber(signal, visit) {
2130
2159
  }
2131
2160
 
2132
2161
  // src/reactivity/track.ts
2133
- var _runtimeVersion = true ? "4.3.0" : "dev";
2162
+ var _runtimeVersion = true ? "4.5.0" : "dev";
2134
2163
  var REGISTRY_KEY = /* @__PURE__ */ Symbol.for("sibujs.reactive.v1");
2135
2164
  function resolveReactiveApi() {
2136
2165
  const g = globalThis;
package/dist/testing.js CHANGED
@@ -3,12 +3,12 @@ import {
3
3
  } from "./chunk-7ZHH77QA.js";
4
4
  import {
5
5
  effect
6
- } from "./chunk-7BJLKDBI.js";
6
+ } from "./chunk-RIXRAYIU.js";
7
7
  import "./chunk-5DXA2J44.js";
8
8
  import {
9
9
  replaceChildrenSafely
10
10
  } from "./chunk-QKRPLZ2V.js";
11
- import "./chunk-TSL64O5L.js";
11
+ import "./chunk-UGRX3S57.js";
12
12
  import "./chunk-2WLZ6757.js";
13
13
 
14
14
  // src/testing/a11y.ts
package/dist/ui.cjs CHANGED
@@ -417,6 +417,15 @@ function untracked(fn) {
417
417
  var subscriberEpochCounter = 0;
418
418
  function retrack(effectFn, subscriber) {
419
419
  const prev = currentSubscriber;
420
+ let savedDepth = 0;
421
+ let savedSuspendSub = null;
422
+ if (trackingSuspended) {
423
+ savedDepth = suspendDepth;
424
+ savedSuspendSub = suspendSavedSub;
425
+ suspendDepth = 0;
426
+ suspendSavedSub = null;
427
+ trackingSuspended = false;
428
+ }
420
429
  currentSubscriber = subscriber;
421
430
  const sub = subscriber;
422
431
  const epoch = ++subscriberEpochCounter;
@@ -431,6 +440,11 @@ function retrack(effectFn, subscriber) {
431
440
  effectFn();
432
441
  } finally {
433
442
  currentSubscriber = prev;
443
+ if (savedDepth !== 0) {
444
+ suspendDepth = savedDepth;
445
+ suspendSavedSub = savedSuspendSub;
446
+ trackingSuspended = true;
447
+ }
434
448
  let node = sub.depsHead ?? null;
435
449
  while (node !== null) {
436
450
  const next = node.subNext;
@@ -450,11 +464,25 @@ function track(effectFn, subscriber) {
450
464
  if (!subscriber) return reactiveBinding(effectFn);
451
465
  cleanup(subscriber);
452
466
  const prev = currentSubscriber;
467
+ let savedDepth = 0;
468
+ let savedSuspendSub = null;
469
+ if (trackingSuspended) {
470
+ savedDepth = suspendDepth;
471
+ savedSuspendSub = suspendSavedSub;
472
+ suspendDepth = 0;
473
+ suspendSavedSub = null;
474
+ trackingSuspended = false;
475
+ }
453
476
  currentSubscriber = subscriber;
454
477
  try {
455
478
  effectFn();
456
479
  } finally {
457
480
  currentSubscriber = prev;
481
+ if (savedDepth !== 0) {
482
+ suspendDepth = savedDepth;
483
+ suspendSavedSub = savedSuspendSub;
484
+ trackingSuspended = true;
485
+ }
458
486
  const sub2 = subscriber;
459
487
  for (let n = sub2.depsHead ?? null; n !== null; n = n.subNext) {
460
488
  const sig = n.sig;
@@ -625,8 +653,9 @@ function propagateDirty(sub) {
625
653
  if (s._c) {
626
654
  const nSig = s._sig;
627
655
  if (nSig) {
628
- if (!nSig._d) {
656
+ if (!nSig._d || nSig._f === true) {
629
657
  nSig._d = true;
658
+ nSig._f = false;
630
659
  stack.push(nSig);
631
660
  }
632
661
  } else {
@@ -726,7 +755,7 @@ function forEachSubscriber(signal2, visit) {
726
755
  }
727
756
 
728
757
  // src/reactivity/track.ts
729
- var _runtimeVersion = true ? "4.3.0" : "dev";
758
+ var _runtimeVersion = true ? "4.5.0" : "dev";
730
759
  var REGISTRY_KEY = /* @__PURE__ */ Symbol.for("sibujs.reactive.v1");
731
760
  function resolveReactiveApi() {
732
761
  const g = globalThis;
@@ -790,10 +819,14 @@ function derived(getter, options) {
790
819
  const cs = {};
791
820
  cs._d = false;
792
821
  cs._init = false;
822
+ cs._f = false;
793
823
  cs._g = getter;
794
824
  cs.__v = 0;
825
+ let evaluating = false;
826
+ let disposed = false;
827
+ let pendingError;
795
828
  const markDirty = () => {
796
- if (cs._d) return;
829
+ if (cs._d || disposed) return;
797
830
  cs._d = true;
798
831
  };
799
832
  markDirty._c = 1;
@@ -816,33 +849,53 @@ function derived(getter, options) {
816
849
  }
817
850
  }, markDirty);
818
851
  const hook = globalThis.__SIBU_DEVTOOLS_GLOBAL_HOOK__;
819
- let evaluating = false;
820
852
  const validate = () => {
821
- if (!cs._d) return;
853
+ if (!cs._d || disposed || pendingError !== void 0) return;
822
854
  const oldValue = cs._v;
823
855
  evaluating = true;
824
856
  try {
825
857
  retrack2(recompute, markDirty);
826
858
  if (!Object.is(oldValue, cs._v)) cs.__v++;
859
+ } catch (err) {
860
+ pendingError = { error: err };
861
+ cs.__v++;
862
+ if (disposed) cs._d = true;
863
+ else cs._f = true;
827
864
  } finally {
828
865
  evaluating = false;
866
+ if (disposed) cleanup2(markDirty);
829
867
  }
830
- if (hook && !Object.is(oldValue, cs._v)) {
868
+ if (hook && !disposed && !Object.is(oldValue, cs._v)) {
831
869
  hook.emit("computed:update", { signal: cs, oldValue, newValue: cs._v });
832
870
  }
833
871
  };
834
872
  cs._validate = validate;
873
+ const throwPending = () => {
874
+ const { error } = pendingError;
875
+ pendingError = void 0;
876
+ if (disposed) cs._d = false;
877
+ throw error;
878
+ };
835
879
  function computedGetter() {
836
880
  if (evaluating) {
837
881
  throw new Error(
838
882
  `[SibuJS] Circular dependency detected in derived${debugName ? ` "${debugName}"` : ""}. A derived signal cannot read itself (directly or through a chain).`
839
883
  );
840
884
  }
841
- if (isTrackingSuspended2()) {
842
- if (cs._d) validate();
885
+ if (isTrackingSuspended2() || disposed) {
886
+ if (cs._d) {
887
+ validate();
888
+ if (pendingError !== void 0) throwPending();
889
+ }
843
890
  return cs._v;
844
891
  }
845
- if (cs._d) validate();
892
+ if (cs._d) {
893
+ validate();
894
+ if (pendingError !== void 0) {
895
+ recordDependency2(cs);
896
+ throwPending();
897
+ }
898
+ }
846
899
  recordDependency2(cs);
847
900
  return cs._v;
848
901
  }
@@ -851,6 +904,19 @@ function derived(getter, options) {
851
904
  cs.__name = debugName;
852
905
  }
853
906
  computedGetter.__signal = cs;
907
+ computedGetter.dispose = () => {
908
+ if (disposed) return;
909
+ disposed = true;
910
+ cs._d = pendingError !== void 0;
911
+ cleanup2(markDirty);
912
+ const h = globalThis.__SIBU_DEVTOOLS_GLOBAL_HOOK__;
913
+ if (h) {
914
+ try {
915
+ h.emit("computed:destroy", { signal: cs, getter: computedGetter });
916
+ } catch {
917
+ }
918
+ }
919
+ };
854
920
  if (hook) hook.emit("computed:create", { signal: cs, name: debugName, getter: computedGetter });
855
921
  return computedGetter;
856
922
  }
@@ -2488,6 +2554,14 @@ function setSafeAttribute(el, name, value, options = {}) {
2488
2554
  const html = isHtmlElement(el);
2489
2555
  const idlName = html ? name.toLowerCase() : name;
2490
2556
  if (typeof value === "boolean") {
2557
+ if (name.length > 5 && name.slice(0, 5).toLowerCase() === "aria-") {
2558
+ const token = value ? "true" : "false";
2559
+ if ((ns ? el.getAttributeNS(ns, localName) : el.getAttribute(name)) !== token) {
2560
+ if (ns) el.setAttributeNS(ns, name, token);
2561
+ else el.setAttribute(name, token);
2562
+ }
2563
+ return true;
2564
+ }
2491
2565
  if (html && BOOLEAN_IDL_ATTRS.has(idlName) && idlName in el) {
2492
2566
  setProp(el, idlName, value);
2493
2567
  } else if (value) {
@@ -2561,13 +2635,13 @@ function bindBoolAttr(el, attr, getter) {
2561
2635
  let value;
2562
2636
  try {
2563
2637
  value = reactiveGetter();
2564
- } catch {
2638
+ } catch (err) {
2639
+ reportError(err, { phase: "binding", name: "bindBoolAttr", node: el });
2565
2640
  return;
2566
2641
  }
2567
2642
  setSafeAttribute(el, attr, Boolean(value), { label: "bindBoolAttr" });
2568
2643
  }
2569
- const teardown = track2(commit);
2570
- return teardown;
2644
+ return reactiveBinding2(commit, el);
2571
2645
  }
2572
2646
  function bindData(el, key, getter) {
2573
2647
  const dataAttr = `data-${key}`;
@@ -2831,7 +2905,13 @@ function pagination(options) {
2831
2905
  const clamped = Math.max(1, Math.min(target, totalPages()));
2832
2906
  setPage(clamped);
2833
2907
  }
2834
- return { page: currentPage, pageSize, totalPages, next, prev, goTo, startIndex, endIndex };
2908
+ function dispose2() {
2909
+ startIndex.dispose();
2910
+ endIndex.dispose();
2911
+ currentPage.dispose();
2912
+ totalPages.dispose();
2913
+ }
2914
+ return { page: currentPage, pageSize, totalPages, next, prev, goTo, startIndex, endIndex, dispose: dispose2 };
2835
2915
  }
2836
2916
 
2837
2917
  // src/ui/eventBus.ts
@@ -3188,31 +3268,39 @@ var validators = {
3188
3268
  };
3189
3269
  function validateProps(props, schema) {
3190
3270
  const result = { ...props };
3191
- const errors = [];
3192
- const isDev = typeof process === "undefined" || process?.env?.NODE_ENV !== "production";
3193
- for (const [key, def] of Object.entries(schema)) {
3194
- const propDef = typeof def === "function" ? { type: def } : def;
3195
- if (result[key] == null && propDef.default !== void 0) {
3196
- result[key] = typeof propDef.default === "function" ? propDef.default() : propDef.default;
3197
- }
3198
- if (!isDev) continue;
3199
- if (propDef.required && result[key] == null) {
3200
- errors.push(`Prop '${key}' is required`);
3201
- continue;
3202
- }
3203
- if (result[key] == null) continue;
3204
- if (propDef.type) {
3205
- const typeResult = propDef.type(result[key], key);
3206
- if (typeResult !== true) errors.push(typeResult);
3271
+ if (typeof __SIBU_DEV__ !== "undefined" ? __SIBU_DEV__ : DEV) {
3272
+ const errors = [];
3273
+ for (const [key, def] of Object.entries(schema)) {
3274
+ const propDef = typeof def === "function" ? { type: def } : def;
3275
+ if (result[key] == null && propDef.default !== void 0) {
3276
+ result[key] = typeof propDef.default === "function" ? propDef.default() : propDef.default;
3277
+ }
3278
+ if (propDef.required && result[key] == null) {
3279
+ errors.push(`Prop '${key}' is required`);
3280
+ continue;
3281
+ }
3282
+ if (result[key] == null) continue;
3283
+ if (propDef.type) {
3284
+ const typeResult = propDef.type(result[key], key);
3285
+ if (typeResult !== true) errors.push(typeResult);
3286
+ }
3287
+ if (propDef.validator) {
3288
+ const validResult = propDef.validator(result[key], key);
3289
+ if (validResult !== true) errors.push(validResult);
3290
+ }
3207
3291
  }
3208
- if (propDef.validator) {
3209
- const validResult = propDef.validator(result[key], key);
3210
- if (validResult !== true) errors.push(validResult);
3292
+ if (errors.length > 0) {
3293
+ devWarn(`Prop validation errors:
3294
+ ${errors.map((e) => ` - ${e}`).join("\n")}`);
3211
3295
  }
3296
+ return result;
3212
3297
  }
3213
- if (errors.length > 0 && isDev) {
3214
- console.warn(`[SibuJS] Prop validation errors:
3215
- ${errors.map((e) => ` - ${e}`).join("\n")}`);
3298
+ for (const [key, def] of Object.entries(schema)) {
3299
+ if (typeof def === "function") continue;
3300
+ const fallback = def.default;
3301
+ if (result[key] == null && fallback !== void 0) {
3302
+ result[key] = typeof fallback === "function" ? fallback() : fallback;
3303
+ }
3216
3304
  }
3217
3305
  return result;
3218
3306
  }
@@ -3223,10 +3311,11 @@ function defineStrictComponent(config) {
3223
3311
  };
3224
3312
  }
3225
3313
  function assertType(value, validator, label) {
3226
- if (typeof process !== "undefined" && process?.env?.NODE_ENV === "production") return;
3227
- const result = validator(value, label || "value");
3228
- if (result !== true) {
3229
- throw new TypeError(`[SibuJS Contract] ${result}`);
3314
+ if (typeof __SIBU_DEV__ !== "undefined" ? __SIBU_DEV__ : DEV) {
3315
+ const result = validator(value, label || "value");
3316
+ if (result !== true) {
3317
+ throw new TypeError(`[SibuJS Contract] ${result}`);
3318
+ }
3230
3319
  }
3231
3320
  }
3232
3321
  function createGuard(validator) {
package/dist/ui.d.cts CHANGED
@@ -1,5 +1,5 @@
1
- export { A as AttributeSource, a as AttributeValue, B as BoundFieldProps, C as CustomElementOptions, F as FieldConfig, b as FocusTrap, c as FormConfig, d as FormField, e as FormReturn, I as IntersectionResult, M as MaskOptions, T as Toast, f as ToastInstance, V as ValidatorFn, g as VirtualList, h as VirtualListProps, _ as __resetDialogStack, i as announce, j as aria, k as bindAttrs, l as bindBoolAttr, m as bindData, n as bindField, o as creditCardMask, p as custom, q as dateMask, r as defineElement, s as dialog, t as email, u as eventBus, v as focus, w as form, x as hotkey, y as infiniteScroll, z as inputMask, D as intersection, E as lazyLoad, G as matchesPattern, H as max, J as maxLength, K as min, L as minLength, N as pagination, O as phoneMask, P as removeScopedStyle, Q as required, R as scopedStyle, S as ssnMask, U as svgElement, W as timeMask, X as toast, Y as withScopedStyle, Z as zipMask } from './customElement-CNZxEB9G.cjs';
2
- export { C as ComponentProps, P as PropDef, a as PropSchema, R as RenderProp, V as Validator, b as assertType, c as compose, d as createGuard, e as createSlots, f as defineComponent, g as defineSlottedComponent, h as defineStrictComponent, v as validateProps, i as validators, w as withBoundary, j as withDefaults, k as withProps, l as withWrapper } from './contracts-Hg6ITAEF.cjs';
1
+ export { A as AttributeSource, a as AttributeValue, B as BoundFieldProps, C as CustomElementOptions, F as FieldConfig, b as FocusTrap, c as FormConfig, d as FormField, e as FormReturn, I as IntersectionResult, M as MaskOptions, P as PaginationResult, T as Toast, f as ToastInstance, V as ValidatorFn, g as VirtualList, h as VirtualListProps, _ as __resetDialogStack, i as announce, j as aria, k as bindAttrs, l as bindBoolAttr, m as bindData, n as bindField, o as creditCardMask, p as custom, q as dateMask, r as defineElement, s as dialog, t as email, u as eventBus, v as focus, w as form, x as hotkey, y as infiniteScroll, z as inputMask, D as intersection, E as lazyLoad, G as matchesPattern, H as max, J as maxLength, K as min, L as minLength, N as pagination, O as phoneMask, Q as removeScopedStyle, R as required, S as scopedStyle, U as ssnMask, W as svgElement, X as timeMask, Y as toast, Z as withScopedStyle, $ as zipMask } from './customElement-OB9CIsc5.cjs';
2
+ export { C as ComponentProps, P as PropDef, a as PropSchema, R as RenderProp, V as Validator, b as assertType, c as compose, d as createGuard, e as createSlots, f as defineComponent, g as defineSlottedComponent, h as defineStrictComponent, v as validateProps, i as validators, w as withBoundary, j as withDefaults, k as withProps, l as withWrapper } from './contracts-DBdg9J_a.cjs';
3
3
 
4
4
  interface FormActionHandle<TArgs extends unknown[], TResult> {
5
5
  /** Invoke the action. Rejections become `error()`, resolutions `result()`. */
package/dist/ui.d.ts CHANGED
@@ -1,5 +1,5 @@
1
- export { A as AttributeSource, a as AttributeValue, B as BoundFieldProps, C as CustomElementOptions, F as FieldConfig, b as FocusTrap, c as FormConfig, d as FormField, e as FormReturn, I as IntersectionResult, M as MaskOptions, T as Toast, f as ToastInstance, V as ValidatorFn, g as VirtualList, h as VirtualListProps, _ as __resetDialogStack, i as announce, j as aria, k as bindAttrs, l as bindBoolAttr, m as bindData, n as bindField, o as creditCardMask, p as custom, q as dateMask, r as defineElement, s as dialog, t as email, u as eventBus, v as focus, w as form, x as hotkey, y as infiniteScroll, z as inputMask, D as intersection, E as lazyLoad, G as matchesPattern, H as max, J as maxLength, K as min, L as minLength, N as pagination, O as phoneMask, P as removeScopedStyle, Q as required, R as scopedStyle, S as ssnMask, U as svgElement, W as timeMask, X as toast, Y as withScopedStyle, Z as zipMask } from './customElement-CNZxEB9G.js';
2
- export { C as ComponentProps, P as PropDef, a as PropSchema, R as RenderProp, V as Validator, b as assertType, c as compose, d as createGuard, e as createSlots, f as defineComponent, g as defineSlottedComponent, h as defineStrictComponent, v as validateProps, i as validators, w as withBoundary, j as withDefaults, k as withProps, l as withWrapper } from './contracts-Hg6ITAEF.js';
1
+ export { A as AttributeSource, a as AttributeValue, B as BoundFieldProps, C as CustomElementOptions, F as FieldConfig, b as FocusTrap, c as FormConfig, d as FormField, e as FormReturn, I as IntersectionResult, M as MaskOptions, P as PaginationResult, T as Toast, f as ToastInstance, V as ValidatorFn, g as VirtualList, h as VirtualListProps, _ as __resetDialogStack, i as announce, j as aria, k as bindAttrs, l as bindBoolAttr, m as bindData, n as bindField, o as creditCardMask, p as custom, q as dateMask, r as defineElement, s as dialog, t as email, u as eventBus, v as focus, w as form, x as hotkey, y as infiniteScroll, z as inputMask, D as intersection, E as lazyLoad, G as matchesPattern, H as max, J as maxLength, K as min, L as minLength, N as pagination, O as phoneMask, Q as removeScopedStyle, R as required, S as scopedStyle, U as ssnMask, W as svgElement, X as timeMask, Y as toast, Z as withScopedStyle, $ as zipMask } from './customElement-OB9CIsc5.js';
2
+ export { C as ComponentProps, P as PropDef, a as PropSchema, R as RenderProp, V as Validator, b as assertType, c as compose, d as createGuard, e as createSlots, f as defineComponent, g as defineSlottedComponent, h as defineStrictComponent, v as validateProps, i as validators, w as withBoundary, j as withDefaults, k as withProps, l as withWrapper } from './contracts-DBdg9J_a.js';
3
3
 
4
4
  interface FormActionHandle<TArgs extends unknown[], TResult> {
5
5
  /** Invoke the action. Rejections become `error()`, resolutions `result()`. */
package/dist/ui.js CHANGED
@@ -38,7 +38,7 @@ import {
38
38
  toast,
39
39
  withScopedStyle,
40
40
  zipMask
41
- } from "./chunk-GZYQNIPS.js";
41
+ } from "./chunk-2DCGACUU.js";
42
42
  import {
43
43
  RenderProp,
44
44
  assertType,
@@ -54,27 +54,27 @@ import {
54
54
  withDefaults,
55
55
  withProps,
56
56
  withWrapper
57
- } from "./chunk-VJE6DDYM.js";
57
+ } from "./chunk-R25EFXXC.js";
58
58
  import {
59
59
  createId
60
60
  } from "./chunk-CCSJMTRN.js";
61
- import "./chunk-7UBG6LDP.js";
62
- import "./chunk-3E5YNK2F.js";
61
+ import "./chunk-ONOHFDLG.js";
62
+ import "./chunk-RBTPLM32.js";
63
63
  import "./chunk-IXKSNWV5.js";
64
64
  import {
65
65
  globalSingleton
66
66
  } from "./chunk-7ZHH77QA.js";
67
67
  import {
68
68
  effect
69
- } from "./chunk-7BJLKDBI.js";
69
+ } from "./chunk-RIXRAYIU.js";
70
70
  import "./chunk-5DXA2J44.js";
71
71
  import {
72
72
  registerDisposer
73
73
  } from "./chunk-QKRPLZ2V.js";
74
74
  import {
75
75
  signal
76
- } from "./chunk-MYA5HEK5.js";
77
- import "./chunk-TSL64O5L.js";
76
+ } from "./chunk-XZZOBQAY.js";
77
+ import "./chunk-UGRX3S57.js";
78
78
  import "./chunk-2WLZ6757.js";
79
79
 
80
80
  // src/ui/formAction.ts