sibujs 4.5.0 → 4.7.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 (116) hide show
  1. package/README.md +1 -1
  2. package/dist/browser.cjs +326 -133
  3. package/dist/browser.d.cts +46 -14
  4. package/dist/browser.d.ts +46 -14
  5. package/dist/browser.js +8 -6
  6. package/dist/build.cjs +2094 -1033
  7. package/dist/build.d.cts +133 -44
  8. package/dist/build.d.ts +133 -44
  9. package/dist/build.js +1372 -574
  10. package/dist/cdn.dev.global.js +10 -10
  11. package/dist/cdn.full.dev.global.js +11 -11
  12. package/dist/cdn.full.global.js +10 -10
  13. package/dist/cdn.global.js +10 -10
  14. package/dist/{chunk-2DCGACUU.js → chunk-2BPG2XDA.js} +251 -66
  15. package/dist/{chunk-IXKSNWV5.js → chunk-2INLLLMZ.js} +1 -1
  16. package/dist/{chunk-4PMLNECI.js → chunk-3QWBSL5R.js} +98 -29
  17. package/dist/{chunk-KKLW7YWL.js → chunk-4AWA2PVD.js} +275 -144
  18. package/dist/chunk-5HZXGZ6T.js +24 -0
  19. package/dist/{chunk-PCT43HW3.js → chunk-7LUJQAOJ.js} +1 -1
  20. package/dist/{chunk-5DXA2J44.js → chunk-7XHATCIH.js} +5 -2
  21. package/dist/chunk-BC2SECJD.js +44 -0
  22. package/dist/{chunk-TBYTO6BS.js → chunk-BSY63EM6.js} +136 -80
  23. package/dist/{chunk-FTIR4QW2.js → chunk-DKXRACVN.js} +6 -8
  24. package/dist/{chunk-ONOHFDLG.js → chunk-FNJXNGYZ.js} +3 -3
  25. package/dist/{chunk-XZZOBQAY.js → chunk-FQRUXCEE.js} +6 -5
  26. package/dist/{chunk-NIOYEGBQ.js → chunk-HURREPU2.js} +27 -13
  27. package/dist/chunk-J6FW5TV6.js +233 -0
  28. package/dist/{chunk-UGRX3S57.js → chunk-JWKYU5GV.js} +22 -4
  29. package/dist/chunk-NYNYSPK7.js +318 -0
  30. package/dist/{chunk-RBTPLM32.js → chunk-RUSSKG6G.js} +13 -12
  31. package/dist/{chunk-7LN645I6.js → chunk-SLM3IA34.js} +3 -3
  32. package/dist/{chunk-R25EFXXC.js → chunk-TUCPL2HB.js} +3 -3
  33. package/dist/{chunk-B3WHI2QA.js → chunk-UNWRJRKC.js} +55 -31
  34. package/dist/{chunk-KEISJXBU.js → chunk-UOL2ECCS.js} +44 -17
  35. package/dist/{chunk-RJE2BNI4.js → chunk-VZSG24LS.js} +108 -45
  36. package/dist/{chunk-RIXRAYIU.js → chunk-WEQ3DMVL.js} +10 -4
  37. package/dist/{chunk-3JZ4L5TJ.js → chunk-WOLJZUFQ.js} +354 -90
  38. package/dist/{chunk-S373NSMK.js → chunk-XYV3EDB7.js} +283 -123
  39. package/dist/{chunk-VZKNK2V7.js → chunk-XZR4PXRE.js} +296 -38
  40. package/dist/{chunk-GW3SCCZG.js → chunk-Z3OHK6QT.js} +153 -110
  41. package/dist/{chunk-OMJJM3KM.js → chunk-ZVL7TY4K.js} +287 -130
  42. package/dist/{contracts-DBdg9J_a.d.ts → contracts-CLqzJnOV.d.ts} +36 -17
  43. package/dist/{contracts-DBdg9J_a.d.cts → contracts-CTOJXu-x.d.cts} +36 -17
  44. package/dist/{customElement-OB9CIsc5.d.cts → customElement-MmInOW1U.d.cts} +21 -0
  45. package/dist/{customElement-OB9CIsc5.d.ts → customElement-MmInOW1U.d.ts} +21 -0
  46. package/dist/data.cjs +410 -155
  47. package/dist/data.d.cts +166 -12
  48. package/dist/data.d.ts +166 -12
  49. package/dist/data.js +12 -9
  50. package/dist/devtools.cjs +98 -61
  51. package/dist/devtools.js +7 -8
  52. package/dist/dispose-GEIG2KOF.js +28 -0
  53. package/dist/ecosystem.cjs +372 -126
  54. package/dist/ecosystem.d.cts +20 -3
  55. package/dist/ecosystem.d.ts +20 -3
  56. package/dist/ecosystem.js +12 -12
  57. package/dist/extras.cjs +2366 -909
  58. package/dist/extras.d.cts +11 -9
  59. package/dist/extras.d.ts +11 -9
  60. package/dist/extras.js +39 -28
  61. package/dist/index.cjs +421 -158
  62. package/dist/index.d.cts +213 -171
  63. package/dist/index.d.ts +213 -171
  64. package/dist/index.js +24 -27
  65. package/dist/motion.cjs +118 -44
  66. package/dist/motion.js +5 -5
  67. package/dist/patterns.cjs +344 -53
  68. package/dist/patterns.d.cts +28 -9
  69. package/dist/patterns.d.ts +28 -9
  70. package/dist/patterns.js +8 -8
  71. package/dist/performance.cjs +325 -220
  72. package/dist/performance.d.cts +2 -2
  73. package/dist/performance.d.ts +2 -2
  74. package/dist/performance.js +8 -9
  75. package/dist/plugin-DVgSnTfK.d.cts +112 -0
  76. package/dist/plugin-DVgSnTfK.d.ts +112 -0
  77. package/dist/plugins.cjs +664 -233
  78. package/dist/plugins.d.cts +127 -14
  79. package/dist/plugins.d.ts +127 -14
  80. package/dist/plugins.js +96 -42
  81. package/dist/signal-EotCj4hS.d.cts +110 -0
  82. package/dist/signal-EotCj4hS.d.ts +110 -0
  83. package/dist/{ssr-BiPRdZ6n.d.cts → ssr-Bli9XRW5.d.cts} +5 -0
  84. package/dist/{ssr-BiPRdZ6n.d.ts → ssr-Bli9XRW5.d.ts} +5 -0
  85. package/dist/{ssr-Y7XOEPEN.js → ssr-XOTUASDO.js} +4 -5
  86. package/dist/ssr.cjs +229 -84
  87. package/dist/ssr.d.cts +9 -3
  88. package/dist/ssr.d.ts +9 -3
  89. package/dist/ssr.js +11 -12
  90. package/dist/{startup-BMpaiMhP.d.ts → startup-BLfSeL15.d.cts} +73 -22
  91. package/dist/{startup-BMpaiMhP.d.cts → startup-BLfSeL15.d.ts} +73 -22
  92. package/dist/tagFactory-8qL9LCIx.d.cts +156 -0
  93. package/dist/tagFactory-BL2fymez.d.ts +156 -0
  94. package/dist/testing.cjs +2503 -2191
  95. package/dist/testing.d.cts +56 -5
  96. package/dist/testing.d.ts +56 -5
  97. package/dist/testing.js +580 -307
  98. package/dist/types-CJFViL6Q.d.cts +26 -0
  99. package/dist/types-CJFViL6Q.d.ts +26 -0
  100. package/dist/ui.cjs +732 -329
  101. package/dist/ui.d.cts +41 -7
  102. package/dist/ui.d.ts +41 -7
  103. package/dist/ui.js +151 -56
  104. package/dist/widgets.cjs +267 -291
  105. package/dist/widgets.js +9 -10
  106. package/package.json +4 -2
  107. package/dist/chunk-2WLZ6757.js +0 -149
  108. package/dist/chunk-CCSJMTRN.js +0 -15
  109. package/dist/chunk-QKRPLZ2V.js +0 -108
  110. package/dist/chunk-VUF4ALSW.js +0 -60
  111. package/dist/chunk-WWV3SJ3L.js +0 -131
  112. package/dist/dispose-46BOMMQJ.js +0 -19
  113. package/dist/plugin-D30wlGW5.d.cts +0 -71
  114. package/dist/plugin-D30wlGW5.d.ts +0 -71
  115. package/dist/tagFactory-DVoDpHye.d.cts +0 -215
  116. package/dist/tagFactory-DVoDpHye.d.ts +0 -215
@@ -1,215 +0,0 @@
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 };
@@ -1,215 +0,0 @@
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 };