@ersbeth/picoflow 0.2.4 → 1.0.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 (248) hide show
  1. package/.cursor/plans/update-js-e795d61b.plan.md +567 -0
  2. package/.gitlab-ci.yml +24 -0
  3. package/.vscode/settings.json +3 -3
  4. package/CHANGELOG.md +51 -0
  5. package/IMPLEMENTATION_GUIDE.md +1578 -0
  6. package/README.md +62 -25
  7. package/biome.json +32 -32
  8. package/dist/picoflow.js +610 -436
  9. package/dist/types/advanced/array.d.ts +0 -6
  10. package/dist/types/advanced/array.d.ts.map +1 -1
  11. package/dist/types/advanced/index.d.ts +5 -5
  12. package/dist/types/advanced/index.d.ts.map +1 -1
  13. package/dist/types/advanced/map.d.ts +114 -23
  14. package/dist/types/advanced/map.d.ts.map +1 -1
  15. package/dist/types/advanced/resource.d.ts +51 -12
  16. package/dist/types/advanced/resource.d.ts.map +1 -1
  17. package/dist/types/advanced/resourceAsync.d.ts +28 -13
  18. package/dist/types/advanced/resourceAsync.d.ts.map +1 -1
  19. package/dist/types/advanced/stream.d.ts +74 -16
  20. package/dist/types/advanced/stream.d.ts.map +1 -1
  21. package/dist/types/advanced/streamAsync.d.ts +69 -15
  22. package/dist/types/advanced/streamAsync.d.ts.map +1 -1
  23. package/dist/types/basic/constant.d.ts +44 -16
  24. package/dist/types/basic/constant.d.ts.map +1 -1
  25. package/dist/types/basic/derivation.d.ts +73 -24
  26. package/dist/types/basic/derivation.d.ts.map +1 -1
  27. package/dist/types/basic/disposable.d.ts +65 -6
  28. package/dist/types/basic/disposable.d.ts.map +1 -1
  29. package/dist/types/basic/effect.d.ts +27 -16
  30. package/dist/types/basic/effect.d.ts.map +1 -1
  31. package/dist/types/basic/index.d.ts +7 -8
  32. package/dist/types/basic/index.d.ts.map +1 -1
  33. package/dist/types/basic/observable.d.ts +62 -13
  34. package/dist/types/basic/observable.d.ts.map +1 -1
  35. package/dist/types/basic/signal.d.ts +35 -6
  36. package/dist/types/basic/signal.d.ts.map +1 -1
  37. package/dist/types/basic/state.d.ts +25 -4
  38. package/dist/types/basic/state.d.ts.map +1 -1
  39. package/dist/types/basic/trackingContext.d.ts +33 -0
  40. package/dist/types/basic/trackingContext.d.ts.map +1 -0
  41. package/dist/types/creators.d.ts +271 -26
  42. package/dist/types/creators.d.ts.map +1 -1
  43. package/dist/types/index.d.ts +60 -7
  44. package/dist/types/index.d.ts.map +1 -1
  45. package/dist/types/solid/converters.d.ts +5 -5
  46. package/dist/types/solid/converters.d.ts.map +1 -1
  47. package/dist/types/solid/index.d.ts +2 -2
  48. package/dist/types/solid/index.d.ts.map +1 -1
  49. package/dist/types/solid/primitives.d.ts +96 -4
  50. package/dist/types/solid/primitives.d.ts.map +1 -1
  51. package/docs/.vitepress/config.mts +110 -0
  52. package/docs/api/classes/FlowArray.md +489 -0
  53. package/docs/api/classes/FlowConstant.md +350 -0
  54. package/docs/api/classes/FlowDerivation.md +334 -0
  55. package/docs/api/classes/FlowEffect.md +100 -0
  56. package/docs/api/classes/FlowMap.md +512 -0
  57. package/docs/api/classes/FlowObservable.md +306 -0
  58. package/docs/api/classes/FlowResource.md +380 -0
  59. package/docs/api/classes/FlowResourceAsync.md +362 -0
  60. package/docs/api/classes/FlowSignal.md +160 -0
  61. package/docs/api/classes/FlowState.md +368 -0
  62. package/docs/api/classes/FlowStream.md +367 -0
  63. package/docs/api/classes/FlowStreamAsync.md +364 -0
  64. package/docs/api/classes/SolidDerivation.md +75 -0
  65. package/docs/api/classes/SolidResource.md +91 -0
  66. package/docs/api/classes/SolidState.md +71 -0
  67. package/docs/api/classes/TrackingContext.md +33 -0
  68. package/docs/api/functions/array.md +58 -0
  69. package/docs/api/functions/constant.md +45 -0
  70. package/docs/api/functions/derivation.md +53 -0
  71. package/docs/api/functions/effect.md +49 -0
  72. package/docs/api/functions/from.md +220 -0
  73. package/docs/api/functions/isDisposable.md +49 -0
  74. package/docs/api/functions/map.md +57 -0
  75. package/docs/api/functions/resource.md +52 -0
  76. package/docs/api/functions/resourceAsync.md +50 -0
  77. package/docs/api/functions/signal.md +36 -0
  78. package/docs/api/functions/state.md +47 -0
  79. package/docs/api/functions/stream.md +53 -0
  80. package/docs/api/functions/streamAsync.md +50 -0
  81. package/docs/api/index.md +118 -0
  82. package/docs/api/interfaces/FlowDisposable.md +65 -0
  83. package/docs/api/interfaces/SolidObservable.md +19 -0
  84. package/docs/api/type-aliases/FlowArrayAction.md +49 -0
  85. package/docs/api/type-aliases/FlowStreamDisposer.md +15 -0
  86. package/docs/api/type-aliases/FlowStreamSetter.md +27 -0
  87. package/docs/api/type-aliases/FlowStreamUpdater.md +32 -0
  88. package/docs/api/type-aliases/NotPromise.md +18 -0
  89. package/docs/api/type-aliases/SolidGetter.md +17 -0
  90. package/docs/api/typedoc-sidebar.json +1 -0
  91. package/docs/examples/examples.md +2313 -0
  92. package/docs/examples/patterns.md +649 -0
  93. package/docs/guide/advanced/disposal.md +426 -0
  94. package/docs/guide/advanced/solidjs.md +221 -0
  95. package/docs/guide/advanced/upgrading.md +464 -0
  96. package/docs/guide/introduction/concepts.md +56 -0
  97. package/docs/guide/introduction/conventions.md +61 -0
  98. package/docs/guide/introduction/getting-started.md +134 -0
  99. package/docs/guide/introduction/lifecycle.md +371 -0
  100. package/docs/guide/primitives/array.md +400 -0
  101. package/docs/guide/primitives/constant.md +380 -0
  102. package/docs/guide/primitives/derivations.md +348 -0
  103. package/docs/guide/primitives/effects.md +458 -0
  104. package/docs/guide/primitives/map.md +387 -0
  105. package/docs/guide/primitives/overview.md +175 -0
  106. package/docs/guide/primitives/resources.md +858 -0
  107. package/docs/guide/primitives/signal.md +259 -0
  108. package/docs/guide/primitives/state.md +368 -0
  109. package/docs/guide/primitives/streams.md +931 -0
  110. package/docs/index.md +47 -0
  111. package/docs/public/logo.svg +1 -0
  112. package/package.json +57 -41
  113. package/src/advanced/array.ts +208 -210
  114. package/src/advanced/index.ts +7 -7
  115. package/src/advanced/map.ts +178 -68
  116. package/src/advanced/resource.ts +87 -43
  117. package/src/advanced/resourceAsync.ts +62 -42
  118. package/src/advanced/stream.ts +113 -50
  119. package/src/advanced/streamAsync.ts +120 -61
  120. package/src/basic/constant.ts +82 -49
  121. package/src/basic/derivation.ts +128 -84
  122. package/src/basic/disposable.ts +74 -15
  123. package/src/basic/effect.ts +85 -77
  124. package/src/basic/index.ts +7 -8
  125. package/src/basic/observable.ts +94 -36
  126. package/src/basic/signal.ts +133 -105
  127. package/src/basic/state.ts +46 -25
  128. package/src/basic/trackingContext.ts +45 -0
  129. package/src/creators.ts +297 -54
  130. package/src/index.ts +96 -43
  131. package/src/solid/converters.ts +186 -67
  132. package/src/solid/index.ts +8 -2
  133. package/src/solid/primitives.ts +167 -65
  134. package/test/array.test.ts +592 -612
  135. package/test/constant.test.ts +31 -33
  136. package/test/derivation.test.ts +531 -536
  137. package/test/effect.test.ts +21 -21
  138. package/test/map.test.ts +233 -137
  139. package/test/resource.test.ts +119 -121
  140. package/test/resourceAsync.test.ts +98 -100
  141. package/test/signal.test.ts +51 -55
  142. package/test/state.test.ts +186 -168
  143. package/test/stream.test.ts +189 -189
  144. package/test/streamAsync.test.ts +186 -186
  145. package/tsconfig.json +19 -18
  146. package/typedoc.json +37 -0
  147. package/vite.config.ts +23 -23
  148. package/vitest.config.ts +7 -7
  149. package/api/doc/index.md +0 -31
  150. package/api/doc/picoflow.array.md +0 -55
  151. package/api/doc/picoflow.constant.md +0 -55
  152. package/api/doc/picoflow.derivation.md +0 -55
  153. package/api/doc/picoflow.effect.md +0 -55
  154. package/api/doc/picoflow.flowarray._constructor_.md +0 -49
  155. package/api/doc/picoflow.flowarray._lastaction.md +0 -13
  156. package/api/doc/picoflow.flowarray.clear.md +0 -17
  157. package/api/doc/picoflow.flowarray.dispose.md +0 -55
  158. package/api/doc/picoflow.flowarray.get.md +0 -19
  159. package/api/doc/picoflow.flowarray.length.md +0 -13
  160. package/api/doc/picoflow.flowarray.md +0 -273
  161. package/api/doc/picoflow.flowarray.pop.md +0 -17
  162. package/api/doc/picoflow.flowarray.push.md +0 -53
  163. package/api/doc/picoflow.flowarray.set.md +0 -53
  164. package/api/doc/picoflow.flowarray.setitem.md +0 -69
  165. package/api/doc/picoflow.flowarray.shift.md +0 -17
  166. package/api/doc/picoflow.flowarray.splice.md +0 -85
  167. package/api/doc/picoflow.flowarray.unshift.md +0 -53
  168. package/api/doc/picoflow.flowarrayaction.md +0 -37
  169. package/api/doc/picoflow.flowconstant._constructor_.md +0 -49
  170. package/api/doc/picoflow.flowconstant.get.md +0 -25
  171. package/api/doc/picoflow.flowconstant.md +0 -88
  172. package/api/doc/picoflow.flowderivation._constructor_.md +0 -49
  173. package/api/doc/picoflow.flowderivation.get.md +0 -23
  174. package/api/doc/picoflow.flowderivation.md +0 -86
  175. package/api/doc/picoflow.flowdisposable.dispose.md +0 -55
  176. package/api/doc/picoflow.flowdisposable.md +0 -43
  177. package/api/doc/picoflow.floweffect._constructor_.md +0 -54
  178. package/api/doc/picoflow.floweffect.dispose.md +0 -21
  179. package/api/doc/picoflow.floweffect.disposed.md +0 -13
  180. package/api/doc/picoflow.floweffect.md +0 -131
  181. package/api/doc/picoflow.flowgetter.md +0 -15
  182. package/api/doc/picoflow.flowmap._lastdeleted.md +0 -21
  183. package/api/doc/picoflow.flowmap._lastset.md +0 -21
  184. package/api/doc/picoflow.flowmap.delete.md +0 -61
  185. package/api/doc/picoflow.flowmap.md +0 -133
  186. package/api/doc/picoflow.flowmap.setat.md +0 -77
  187. package/api/doc/picoflow.flowobservable.get.md +0 -19
  188. package/api/doc/picoflow.flowobservable.md +0 -68
  189. package/api/doc/picoflow.flowobservable.subscribe.md +0 -55
  190. package/api/doc/picoflow.flowresource._constructor_.md +0 -49
  191. package/api/doc/picoflow.flowresource.fetch.md +0 -27
  192. package/api/doc/picoflow.flowresource.get.md +0 -23
  193. package/api/doc/picoflow.flowresource.md +0 -100
  194. package/api/doc/picoflow.flowresourceasync._constructor_.md +0 -49
  195. package/api/doc/picoflow.flowresourceasync.fetch.md +0 -27
  196. package/api/doc/picoflow.flowresourceasync.get.md +0 -23
  197. package/api/doc/picoflow.flowresourceasync.md +0 -100
  198. package/api/doc/picoflow.flowsignal.dispose.md +0 -59
  199. package/api/doc/picoflow.flowsignal.disposed.md +0 -18
  200. package/api/doc/picoflow.flowsignal.md +0 -112
  201. package/api/doc/picoflow.flowsignal.trigger.md +0 -21
  202. package/api/doc/picoflow.flowstate.md +0 -52
  203. package/api/doc/picoflow.flowstate.set.md +0 -61
  204. package/api/doc/picoflow.flowstream._constructor_.md +0 -49
  205. package/api/doc/picoflow.flowstream.dispose.md +0 -21
  206. package/api/doc/picoflow.flowstream.get.md +0 -23
  207. package/api/doc/picoflow.flowstream.md +0 -100
  208. package/api/doc/picoflow.flowstreamasync._constructor_.md +0 -54
  209. package/api/doc/picoflow.flowstreamasync.dispose.md +0 -21
  210. package/api/doc/picoflow.flowstreamasync.get.md +0 -23
  211. package/api/doc/picoflow.flowstreamasync.md +0 -100
  212. package/api/doc/picoflow.flowstreamdisposer.md +0 -13
  213. package/api/doc/picoflow.flowstreamsetter.md +0 -13
  214. package/api/doc/picoflow.flowstreamupdater.md +0 -19
  215. package/api/doc/picoflow.flowwatcher.md +0 -15
  216. package/api/doc/picoflow.from.md +0 -55
  217. package/api/doc/picoflow.from_1.md +0 -55
  218. package/api/doc/picoflow.from_2.md +0 -55
  219. package/api/doc/picoflow.from_3.md +0 -55
  220. package/api/doc/picoflow.from_4.md +0 -55
  221. package/api/doc/picoflow.from_5.md +0 -55
  222. package/api/doc/picoflow.isdisposable.md +0 -55
  223. package/api/doc/picoflow.map.md +0 -59
  224. package/api/doc/picoflow.md +0 -544
  225. package/api/doc/picoflow.resource.md +0 -55
  226. package/api/doc/picoflow.resourceasync.md +0 -55
  227. package/api/doc/picoflow.signal.md +0 -19
  228. package/api/doc/picoflow.solidderivation._constructor_.md +0 -49
  229. package/api/doc/picoflow.solidderivation.get.md +0 -13
  230. package/api/doc/picoflow.solidderivation.md +0 -94
  231. package/api/doc/picoflow.solidgetter.md +0 -13
  232. package/api/doc/picoflow.solidobservable.get.md +0 -13
  233. package/api/doc/picoflow.solidobservable.md +0 -57
  234. package/api/doc/picoflow.solidresource._constructor_.md +0 -49
  235. package/api/doc/picoflow.solidresource.get.md +0 -13
  236. package/api/doc/picoflow.solidresource.latest.md +0 -13
  237. package/api/doc/picoflow.solidresource.md +0 -157
  238. package/api/doc/picoflow.solidresource.refetch.md +0 -13
  239. package/api/doc/picoflow.solidresource.state.md +0 -13
  240. package/api/doc/picoflow.solidstate._constructor_.md +0 -49
  241. package/api/doc/picoflow.solidstate.get.md +0 -13
  242. package/api/doc/picoflow.solidstate.md +0 -115
  243. package/api/doc/picoflow.solidstate.set.md +0 -13
  244. package/api/doc/picoflow.state.md +0 -55
  245. package/api/doc/picoflow.stream.md +0 -55
  246. package/api/doc/picoflow.streamasync.md +0 -55
  247. package/api/picoflow.public.api.md +0 -244
  248. package/api-extractor.json +0 -61
@@ -1,94 +1,339 @@
1
1
  import { FlowMap, FlowResource, FlowResourceAsync, FlowStream, FlowStreamAsync } from './advanced/';
2
2
  import { FlowArray } from './advanced/array';
3
- import { FlowConstant, FlowDerivation, FlowEffect, FlowSignal, FlowState, FlowGetter, FlowWatcher } from './basic/';
3
+ import { TrackingContext, FlowConstant, FlowDerivation, FlowEffect, FlowSignal, FlowState } from './basic/';
4
4
  /**
5
5
  * Creates a new reactive signal.
6
+ *
6
7
  * @returns A new instance of {@link FlowSignal}.
8
+ *
9
+ * @remarks
10
+ * A signal is the simplest reactive primitive - it doesn't hold a value, but can be triggered
11
+ * to notify dependent effects and derivations. Use signals when you need event-like notifications
12
+ * without associated data.
13
+ *
14
+ * @example
15
+ * ```typescript
16
+ * const $refresh = signal();
17
+ *
18
+ * effect((t) => {
19
+ * $refresh.watch(t);
20
+ * console.log('Refreshing...');
21
+ * });
22
+ *
23
+ * $refresh.trigger(); // Logs: "Refreshing..."
24
+ * ```
25
+ *
7
26
  * @public
8
27
  */
9
28
  export declare function signal(): FlowSignal;
10
29
  /**
11
30
  * Creates a new reactive constant.
12
- * @param value - The value or a function that returns the value.
31
+ *
32
+ * @typeParam T - The type of the constant value.
33
+ * @param value - The value or a function that returns the value (for lazy initialization).
13
34
  * @returns A new instance of {@link FlowConstant}.
35
+ *
36
+ * @remarks
37
+ * A constant is an immutable reactive value that never changes after initialization.
38
+ * It can be initialized eagerly (direct value) or lazily (function). Use constants for
39
+ * configuration, computed-once values, or expensive initialization that should only run once.
40
+ *
41
+ * @example
42
+ * ```typescript
43
+ * // Eager initialization
44
+ * const $config = constant({ apiUrl: 'https://api.example.com' });
45
+ *
46
+ * // Lazy initialization
47
+ * const $computed = constant(() => expensiveCalculation());
48
+ * ```
49
+ *
14
50
  * @public
15
51
  */
16
52
  export declare function constant<T>(value: T | (() => T)): FlowConstant<T>;
17
53
  /**
18
- * Creates a new reactive state holding a value.
19
- * @typeparam T - The type of the state value.
20
- * @param value - The initial value for the state.
54
+ * Creates a new reactive state holding a mutable value.
55
+ *
56
+ * @typeParam T - The type of the state value.
57
+ * @param value - The initial value for the state, or a function returning the initial value.
21
58
  * @returns A new instance of {@link FlowState}.
59
+ *
60
+ * @remarks
61
+ * State is the most common reactive primitive - a mutable container that notifies dependents
62
+ * when its value changes. Use `set()` to update the value and `get(t)` or `pick()` to read it.
63
+ *
64
+ * @example
65
+ * ```typescript
66
+ * const $count = state(0);
67
+ *
68
+ * effect((t) => {
69
+ * console.log($count.get(t));
70
+ * });
71
+ *
72
+ * $count.set(1); // Logs: 1
73
+ * $count.set(n => n + 1); // Logs: 2
74
+ * ```
75
+ *
22
76
  * @public
23
77
  */
24
78
  export declare function state<T>(value: T | (() => T)): FlowState<T>;
25
79
  /**
26
- * Creates a new reactive resource that asynchronously fetches its value.
27
- * @typeparam T - The type of the resource value.
80
+ * Creates a new reactive resource that asynchronously fetches its value, returning `T | undefined`.
81
+ *
82
+ * @typeParam T - The type of the resource value.
28
83
  * @param fn - An asynchronous function that fetches the resource value.
29
84
  * @returns A new instance of {@link FlowResource}.
85
+ *
86
+ * @remarks
87
+ * A resource manages async data fetching with reactive updates. Unlike {@link resourceAsync},
88
+ * this returns the resolved value directly (or `undefined` if not fetched yet), making it
89
+ * easier to work with in synchronous contexts. Call `fetch()` to trigger the async operation.
90
+ *
91
+ * @example
92
+ * ```typescript
93
+ * const $user = resource(() => fetch('/api/user').then(r => r.json()));
94
+ *
95
+ * // Trigger fetch
96
+ * await $user.fetch();
97
+ *
98
+ * // Use in effect
99
+ * effect((t) => {
100
+ * const user = $user.get(t);
101
+ * if (user) {
102
+ * console.log(user.name);
103
+ * }
104
+ * });
105
+ * ```
106
+ *
30
107
  * @public
31
108
  */
32
109
  export declare function resource<T>(fn: () => Promise<T>): FlowResource<T>;
33
110
  /**
34
- * Creates a new reactive asynchronous resource that fetches its value.
35
- * @typeparam T - The type of the resource value.
111
+ * Creates a new reactive asynchronous resource that always returns a Promise.
112
+ *
113
+ * @typeParam T - The type of the resource value.
36
114
  * @param fn - An asynchronous function that fetches the resource value.
37
115
  * @returns A new instance of {@link FlowResourceAsync}.
116
+ *
117
+ * @remarks
118
+ * An async resource manages async data fetching and always returns a Promise, making it
119
+ * ideal for async/await patterns. Unlike {@link resource}, the Promise is created lazily
120
+ * on first access and cached. Call `fetch()` to create a new Promise and trigger a refetch.
121
+ *
122
+ * @example
123
+ * ```typescript
124
+ * const $data = resourceAsync(() => fetch('/api/data').then(r => r.json()));
125
+ *
126
+ * // Use with async/await
127
+ * effect(async (t) => {
128
+ * const data = await $data.get(t);
129
+ * console.log(data);
130
+ * });
131
+ *
132
+ * // Refetch
133
+ * await $data.fetch();
134
+ * ```
135
+ *
38
136
  * @public
39
137
  */
40
138
  export declare function resourceAsync<T>(fn: () => Promise<T>): FlowResourceAsync<T>;
41
139
  /**
42
- * Creates a new reactive stream.
43
- * @typeparam T - The type of the stream value.
140
+ * Creates a new reactive stream that bridges external event sources with PicoFlow's reactive system.
141
+ *
142
+ * @typeParam T - The type of the stream value.
44
143
  * @param updater - A function that receives a setter to update the stream's value.
45
144
  * It should return a disposer function to clean up resources.
46
145
  * @returns A new instance of {@link FlowStream}.
146
+ *
147
+ * @remarks
148
+ * Streams are ideal for integrating push-based data sources like WebSockets, DOM events,
149
+ * timers, or any event emitter. The updater sets up subscriptions and calls the setter
150
+ * when new data arrives. The returned disposer is called on cleanup.
151
+ *
152
+ * @example
153
+ * ```typescript
154
+ * // WebSocket stream
155
+ * const $messages = stream<string>((set) => {
156
+ * const ws = new WebSocket('ws://example.com');
157
+ * ws.onmessage = (e) => set(e.data);
158
+ * return () => ws.close();
159
+ * });
160
+ *
161
+ * // Timer stream
162
+ * const $tick = stream<number>((set) => {
163
+ * let count = 0;
164
+ * const id = setInterval(() => set(count++), 1000);
165
+ * return () => clearInterval(id);
166
+ * });
167
+ * ```
168
+ *
47
169
  * @public
48
170
  */
49
171
  export declare function stream<T>(updater: (set: (value: T) => void) => () => void): FlowStream<T>;
50
172
  /**
51
- * Creates a new reactive asynchronous stream.
52
- * @typeparam T - The type of the stream value.
173
+ * Creates a new reactive asynchronous stream that always returns a Promise.
174
+ *
175
+ * @typeParam T - The type of the stream value.
53
176
  * @param updater - A function that receives a setter to update the stream's value.
54
177
  * It should return a disposer function to clean up resources.
55
178
  * @returns A new instance of {@link FlowStreamAsync}.
179
+ *
180
+ * @remarks
181
+ * Async streams are ideal for push-based async data sources where you want to use async/await.
182
+ * Unlike {@link stream}, this always returns a Promise that resolves to the value. The initial
183
+ * Promise is created on construction and resolves when the setter is first called.
184
+ *
185
+ * @example
186
+ * ```typescript
187
+ * const $asyncMessages = streamAsync<string>((set) => {
188
+ * const ws = new WebSocket('ws://example.com');
189
+ * ws.onmessage = (e) => set(e.data);
190
+ * return () => ws.close();
191
+ * });
192
+ *
193
+ * effect(async (t) => {
194
+ * const message = await $asyncMessages.get(t);
195
+ * console.log('Received:', message);
196
+ * });
197
+ * ```
198
+ *
56
199
  * @public
57
200
  */
58
201
  export declare function streamAsync<T>(updater: (set: (value: T) => void) => () => void): FlowStreamAsync<T>;
59
202
  /**
60
203
  * Creates a new reactive derivation whose value is computed based on other reactive signals.
61
- * @typeparam T - The type of the derived value.
62
- * @param fn - A function that computes the derived value. It receives a getter and a watcher
63
- * function to access and register dependencies.
204
+ *
205
+ * @typeParam T - The type of the derived value.
206
+ * @param fn - A function that computes the derived value using a tracking context.
64
207
  * @returns A new instance of {@link FlowDerivation}.
208
+ *
209
+ * @remarks
210
+ * A derivation is a computed reactive value that automatically tracks its dependencies and
211
+ * recomputes when they change. The computation is lazy - it runs only when the value is
212
+ * accessed, not on construction. Use derivations to create derived state without manual
213
+ * dependency management.
214
+ *
215
+ * @example
216
+ * ```typescript
217
+ * const $firstName = state('John');
218
+ * const $lastName = state('Doe');
219
+ *
220
+ * const $fullName = derivation((t) => {
221
+ * return `${$firstName.get(t)} ${$lastName.get(t)}`;
222
+ * });
223
+ *
224
+ * effect((t) => {
225
+ * console.log($fullName.get(t)); // Logs: "John Doe"
226
+ * });
227
+ *
228
+ * $firstName.set('Jane'); // Logs: "Jane Doe"
229
+ * ```
230
+ *
65
231
  * @public
66
232
  */
67
- export declare function derivation<T>(fn: (get: FlowGetter, watch: FlowWatcher) => T): FlowDerivation<T>;
233
+ export declare function derivation<T>(fn: (t: TrackingContext) => T): FlowDerivation<T>;
68
234
  /**
69
235
  * Creates a new reactive effect that executes a side-effect function based on its dependencies.
70
- * @param fn - A function that performs side effects. It receives a getter and a watcher
71
- * function for tracking reactive dependencies.
236
+ *
237
+ * @param fn - A function that performs side effects using a tracking context.
72
238
  * @returns A new instance of {@link FlowEffect}.
239
+ *
240
+ * @remarks
241
+ * An effect is a reactive computation that runs immediately and re-runs whenever its tracked
242
+ * dependencies change. Use effects for side effects like logging, DOM updates, network requests,
243
+ * or any operation that should respond to reactive state changes.
244
+ *
245
+ * The effect executes immediately upon creation and provides a tracking context (`t`) that you
246
+ * use to explicitly mark dependencies via `observable.get(t)`. Use `observable.pick()` for
247
+ * reads that shouldn't trigger re-runs.
248
+ *
249
+ * @example
250
+ * ```typescript
251
+ * const $count = state(0);
252
+ *
253
+ * const fx = effect((t) => {
254
+ * console.log('Count is:', $count.get(t));
255
+ * });
256
+ *
257
+ * $count.set(1); // Logs: "Count is: 1"
258
+ * $count.set(2); // Logs: "Count is: 2"
259
+ *
260
+ * // Clean up when done
261
+ * fx.dispose();
262
+ * ```
263
+ *
73
264
  * @public
74
265
  */
75
- export declare function effect(fn: (get: FlowGetter, watch: FlowWatcher) => void): FlowEffect;
266
+ export declare function effect(fn: (t: TrackingContext) => void): FlowEffect;
76
267
  /**
77
- * Creates a new reactive map state.
78
- * @typeparam K - The type of the keys.
79
- * @typeparam V - The type of the values.
268
+ * Creates a new reactive map state with fine-grained tracking of operations.
269
+ *
270
+ * @typeParam K - The type of the keys.
271
+ * @typeParam V - The type of the values.
80
272
  * @param initial - An optional record of key-value pairs to initialize the map.
81
273
  * @returns A new instance of {@link FlowMap}.
274
+ *
82
275
  * @remarks
83
- * The initial record is converted to a native Map before being used.
276
+ * A reactive map wraps a native JavaScript Map and provides multiple levels of reactivity:
277
+ * tracking the entire map, tracking individual set operations, and tracking individual
278
+ * delete operations. The initial record (if provided) is converted to a native Map.
279
+ *
280
+ * @example
281
+ * ```typescript
282
+ * const $users = map<string, User>({
283
+ * 'user1': { name: 'John', age: 30 }
284
+ * });
285
+ *
286
+ * // Track the whole map
287
+ * effect((t) => {
288
+ * console.log('Users:', $users.get(t).size);
289
+ * });
290
+ *
291
+ * // Track additions
292
+ * effect((t) => {
293
+ * const { key, value } = $users.$lastSet.get(t);
294
+ * if (key) console.log(`Added: ${key}`);
295
+ * });
296
+ *
297
+ * $users.setAt('user2', { name: 'Jane', age: 25 });
298
+ * ```
299
+ *
84
300
  * @public
85
301
  */
86
302
  export declare function map<K extends string | number | symbol, V>(initial?: Record<K, V>): FlowMap<K, V>;
87
303
  /**
88
- * Creates a new reactive array.
89
- * @typeparam T - The type of the array elements.
304
+ * Creates a new reactive array with mutation methods and fine-grained action tracking.
305
+ *
306
+ * @typeParam T - The type of the array elements.
90
307
  * @param initial - An optional array of initial values.
91
308
  * @returns A new instance of {@link FlowArray}.
309
+ *
310
+ * @remarks
311
+ * A reactive array provides array-like mutation methods (push, pop, shift, unshift, splice)
312
+ * and tracks the last operation performed via `$lastAction`. This enables both whole-array
313
+ * reactivity and fine-grained tracking of specific mutations.
314
+ *
315
+ * The array automatically disposes disposable items when they are removed (if they implement
316
+ * the FlowDisposable interface).
317
+ *
318
+ * @example
319
+ * ```typescript
320
+ * const $items = array([1, 2, 3]);
321
+ *
322
+ * // Track the whole array
323
+ * effect((t) => {
324
+ * console.log('Items:', $items.get(t));
325
+ * });
326
+ *
327
+ * // Track the last action
328
+ * effect((t) => {
329
+ * const action = $items.$lastAction.get(t);
330
+ * console.log('Action:', action.type);
331
+ * });
332
+ *
333
+ * $items.push(4); // Logs action: "push"
334
+ * $items.pop(); // Logs action: "pop"
335
+ * ```
336
+ *
92
337
  * @public
93
338
  */
94
339
  export declare function array<T>(initial?: T[]): FlowArray<T>;
@@ -1 +1 @@
1
- {"version":3,"file":"creators.d.ts","sourceRoot":"","sources":["../../src/creators.ts"],"names":[],"mappings":"AAAA,OAAO,EACH,OAAO,EACP,YAAY,EACZ,iBAAiB,EACjB,UAAU,EACV,eAAe,EAClB,MAAM,aAAa,CAAC;AACrB,OAAO,EAAE,SAAS,EAAE,MAAM,kBAAkB,CAAC;AAC7C,OAAO,EACH,YAAY,EACZ,cAAc,EACd,UAAU,EACV,UAAU,EACV,SAAS,EACZ,MAAM,UAAU,CAAC;AAClB,OAAO,KAAK,EAAE,UAAU,EAAE,WAAW,EAAE,MAAM,UAAU,CAAC;AAExD;;;;GAIG;AACH,wBAAgB,MAAM,IAAI,UAAU,CAEnC;AAED;;;;;GAKG;AACH,wBAAgB,QAAQ,CAAC,CAAC,EAAE,KAAK,EAAE,CAAC,GAAG,CAAC,MAAM,CAAC,CAAC,GAAG,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PicoFlow is a lightweight reactive dataflow library that provides a set of
5
- * reactive primitives such as signals, state, resources, streams, derivations,
6
- * effects, and reactive maps.
4
+ * # PicoFlow
7
5
  *
6
+ * PicoFlow is a lightweight reactive dataflow library that provides a comprehensive set of
7
+ * reactive primitives for building reactive applications with explicit dependency tracking.
8
+ *
9
+ * ## Core Concepts
10
+ *
11
+ * **Reactive Primitives:**
12
+ * - {@link FlowSignal}: Event-like notifications without values
13
+ * - {@link FlowState}: Mutable reactive values
14
+ * - {@link FlowConstant}: Immutable reactive values (computed once)
15
+ * - {@link FlowDerivation}: Computed values that track dependencies
16
+ * - {@link FlowEffect}: Side effects that run when dependencies change
17
+ *
18
+ * **Advanced Primitives:**
19
+ * - {@link FlowArray}: Reactive arrays with mutation tracking
20
+ * - {@link FlowMap}: Reactive maps with operation tracking
21
+ * - {@link FlowResource}: Async data fetching returning `T | undefined`
22
+ * - {@link FlowResourceAsync}: Async data fetching returning `Promise<T>`
23
+ * - {@link FlowStream}: Event streams from external sources
24
+ * - {@link FlowStreamAsync}: Async event streams returning Promises
25
+ *
26
+ * **Tracking Context:**
27
+ * - {@link TrackingContext}: The core mechanism for explicit dependency tracking
28
+ * - Use `observable.get(t)` to read with tracking
29
+ * - Use `observable.pick()` to read without tracking
30
+ * - Use `signal.watch(t)` to track signals without values
31
+ *
32
+ * ## Key Features
33
+ *
34
+ * - **Explicit tracking**: Full control over what triggers re-execution via TrackingContext
35
+ * - **Lazy evaluation**: Derivations compute only when accessed
36
+ * - **Fine-grained reactivity**: Track specific operations on collections
37
+ * - **Resource management**: Automatic cleanup with dispose patterns
38
+ * - **SolidJS integration**: Seamless bridge to SolidJS primitives
39
+ *
40
+ * ## Basic Usage
41
+ *
42
+ * ```typescript
43
+ * import { state, effect, derivation } from 'picoflow';
44
+ *
45
+ * // Create reactive state
46
+ * const $count = state(0);
47
+ *
48
+ * // Create derived value
49
+ * const $double = derivation((t) => $count.get(t) * 2);
50
+ *
51
+ * // Create effect
52
+ * effect((t) => {
53
+ * console.log('Count:', $count.get(t), 'Double:', $double.get(t));
54
+ * });
55
+ *
56
+ * // Update state
57
+ * $count.set(1); // Logs: "Count: 1 Double: 2"
58
+ * ```
59
+ *
60
+ * @see {@link https://github.com/yourusername/picoflow | GitHub Repository}
8
61
  */
9
- export { signal, state, constant, resource, stream, derivation, effect, map, array, streamAsync, resourceAsync, } from './creators';
10
- export { isDisposable, FlowDerivation, FlowEffect, FlowObservable, FlowSignal, FlowState, FlowConstant, type FlowGetter, type FlowWatcher, type FlowDisposable, } from './basic/';
11
- export { FlowResource, FlowMap, FlowResourceAsync, FlowStreamAsync, FlowStream, FlowArray, type FlowStreamDisposer, type FlowStreamSetter, type FlowStreamUpdater, type FlowArrayAction, } from './advanced/';
12
- export { from, SolidState, SolidResource, SolidDerivation, type SolidObservable, type SolidGetter, } from './solid/';
62
+ export { FlowArray, type FlowArrayAction, FlowMap, FlowResource, FlowResourceAsync, FlowStream, FlowStreamAsync, type FlowStreamDisposer, type FlowStreamSetter, type FlowStreamUpdater, } from './advanced/';
63
+ export { FlowConstant, FlowDerivation, type FlowDisposable, FlowEffect, FlowObservable, FlowSignal, FlowState, isDisposable, TrackingContext, } from './basic/';
64
+ export { array, constant, derivation, effect, map, resource, resourceAsync, signal, state, stream, streamAsync, } from './creators';
65
+ export { from, type NotPromise, SolidDerivation, type SolidGetter, type SolidObservable, SolidResource, SolidState, } from './solid/';
13
66
  //# sourceMappingURL=index.d.ts.map
@@ -1 +1 @@
1
- {"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../src/index.ts"],"names":[],"mappings":"AAAA;;;;;;;GAOG;AACH,OAAO,EACH,MAAM,EACN,KAAK,EACL,QAAQ,EACR,QAAQ,EACR,MAAM,EACN,UAAU,EACV,MAAM,EACN,GAAG,EACH,KAAK,EACL,WAAW,EACX,aAAa,GAChB,MAAM,YAAY,CAAC;AAEpB,OAAO,EACH,YAAY,EACZ,cAAc,EACd,UAAU,EACV,cAAc,EACd,UAAU,EACV,SAAS,EACT,YAAY,EACZ,KAAK,UAAU,EACf,KAAK,WAAW,EAChB,KAAK,cAAc,GACtB,MAAM,UAAU,CAAC;AAElB,OAAO,EACH,YAAY,EACZ,OAAO,EACP,iBAAiB,EACjB,eAAe,EACf,UAAU,EACV,SAAS,EACT,KAAK,kBAAkB,EACvB,KAAK,gBAAgB,EACrB,KAAK,iBAAiB,EACtB,KAAK,eAAe,GACvB,MAAM,aAAa,CAAC;AAErB,OAAO,EACH,IAAI,EACJ,UAAU,EACV,aAAa,EACb,eAAe,EACf,KAAK,eAAe,EACpB,KAAK,WAAW,GACnB,MAAM,UAAU,CAAC"}
1
+ {"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../src/index.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;GA4DG;AAEH,OAAO,EACN,SAAS,EACT,KAAK,eAAe,EACpB,OAAO,EACP,YAAY,EACZ,iBAAiB,EACjB,UAAU,EACV,eAAe,EACf,KAAK,kBAAkB,EACvB,KAAK,gBAAgB,EACrB,KAAK,iBAAiB,GACtB,MAAM,aAAa,CAAC;AAErB,OAAO,EACN,YAAY,EACZ,cAAc,EACd,KAAK,cAAc,EACnB,UAAU,EACV,cAAc,EACd,UAAU,EACV,SAAS,EACT,YAAY,EACZ,eAAe,GACf,MAAM,UAAU,CAAC;AAClB,OAAO,EACN,KAAK,EACL,QAAQ,EACR,UAAU,EACV,MAAM,EACN,GAAG,EACH,QAAQ,EACR,aAAa,EACb,MAAM,EACN,KAAK,EACL,MAAM,EACN,WAAW,GACX,MAAM,YAAY,CAAC;AAEpB,OAAO,EACN,IAAI,EACJ,KAAK,UAAU,EACf,eAAe,EACf,KAAK,WAAW,EAChB,KAAK,eAAe,EACpB,aAAa,EACb,UAAU,GACV,MAAM,UAAU,CAAC"}
@@ -1,5 +1,5 @@
1
- import { SolidResource, SolidDerivation } from './primitives';
2
- import { FlowObservable, FlowGetter } from '../basic';
1
+ import { FlowObservable, TrackingContext } from '../basic';
2
+ import { SolidDerivation, SolidResource } from './primitives';
3
3
  /**
4
4
  * Utility type that excludes Promise types from T.
5
5
  * Used to ensure type safety for synchronous derivations/resources.
@@ -42,7 +42,7 @@ export declare function from<T>(flow: FlowObservable<Promise<NotPromise<T>>> | F
42
42
  *
43
43
  * @public
44
44
  */
45
- export declare function from<T>(flow: (get: FlowGetter) => NotPromise<T>): SolidDerivation<NotPromise<T>>;
45
+ export declare function from<T>(flow: (t: TrackingContext) => NotPromise<T>): SolidDerivation<NotPromise<T>>;
46
46
  /**
47
47
  * Converts a getter function returning a Promise into a SolidResource.
48
48
  *
@@ -51,7 +51,7 @@ export declare function from<T>(flow: (get: FlowGetter) => NotPromise<T>): Solid
51
51
  *
52
52
  * @public
53
53
  */
54
- export declare function from<T>(flow: (get: FlowGetter) => Promise<NotPromise<T>>): SolidResource<NotPromise<T>>;
54
+ export declare function from<T>(flow: (t: TrackingContext) => Promise<NotPromise<T>>): SolidResource<NotPromise<T>>;
55
55
  /**
56
56
  * Converts a getter function into a Solid derivation or resource, depending on whether the returned value is synchronous or asynchronous.
57
57
  *
@@ -60,5 +60,5 @@ export declare function from<T>(flow: (get: FlowGetter) => Promise<NotPromise<T>
60
60
  *
61
61
  * @public
62
62
  */
63
- export declare function from<T>(flow: ((get: FlowGetter) => NotPromise<T>) | ((get: FlowGetter) => Promise<NotPromise<T>>)): SolidDerivation<T> | SolidResource<T>;
63
+ export declare function from<T>(flow: ((t: TrackingContext) => NotPromise<T>) | ((t: TrackingContext) => Promise<NotPromise<T>>)): SolidDerivation<T> | SolidResource<T>;
64
64
  //# sourceMappingURL=converters.d.ts.map
@@ -1 +1 @@
1
- {"version":3,"file":"converters.d.ts","sourceRoot":"","sources":["../../../src/solid/converters.ts"],"names":[],"mappings":"AACA,OAAO,EAAE,aAAa,EAAc,KAAK,eAAe,EAAE,MAAM,cAAc,CAAC;AAC/E,OAAO,EAAc,cAAc,EA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AAC,CAAC,EACrB,IAAI,EAAE,CAAC,CAAC,EAAE,eAAe,KAAK,UAAU,CAAC,CAAC,CAAC,GACzC,eAAe,CAAC,UAAU,CAAC,CAAC,CAAC,CAAC,CAAC;AAClC;;;;;;;GAOG;AACH,wBAAgB,IAAI,CAAC,CAAC,EACrB,IAAI,EAAE,CAAC,CAAC,EAAE,eAAe,KAAK,OAAO,CAAC,UAAU,CAAC,CAAC,CAAC,CAAC,GAClD,aAAa,CAAC,UAAU,CAAC,CAAC,CAAC,CAAC,CAAC;AAChC;;;;;;;GAOG;AACH,wBAAgB,IAAI,CAAC,CAAC,EACrB,IAAI,EACD,CAAC,CAAC,CAAC,EAAE,eAAe,KAAK,UAAU,CAAC,CAAC,CAAC,CAAC,GACvC,CAAC,CAAC,CAAC,EAAE,eAAe,KAAK,OAAO,CAAC,UAAU,CAAC,CAAC,CAAC,CAAC,CAAC,GACjD,eAAe,CAAC,CAAC,CAAC,GAAG,aAAa,CAAC,CAAC,CAAC,CAAC"}
@@ -1,3 +1,3 @@
1
- export { from } from './converters';
2
- export { SolidState, SolidResource, SolidDerivation, type SolidObservable, type SolidGetter } from './primitives';
1
+ export { from, type NotPromise } from './converters';
2
+ export { SolidDerivation, type SolidGetter, type SolidObservable, SolidResource, SolidState, } from './primitives';
3
3
  //# sourceMappingURL=index.d.ts.map
@@ -1 +1 @@
1
- {"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../../src/solid/index.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,IAAI,EAAE,MAAM,cAAc,CAAC;AACpC,OAAO,EAAE,UAAU,EAAE,aAAa,EAAE,eAAe,EAAE,KAAK,eAAe,EAAE,KAAK,WAAW,EAAE,MAAM,cAAc,CAAC"}
1
+ {"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../../src/solid/index.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,IAAI,EAAE,KAAK,UAAU,EAAE,MAAM,cAAc,CAAC;AACrD,OAAO,EACN,eAAe,EACf,KAAK,WAAW,EAChB,KAAK,eAAe,EACpB,aAAa,EACb,UAAU,GACV,MAAM,cAAc,CAAC"}
@@ -19,7 +19,30 @@ export interface SolidObservable<T> {
19
19
  get: () => T;
20
20
  }
21
21
  /**
22
- * Solid-style state container, similar to a writable signal.
22
+ * Solid-style state container wrapping SolidJS's createSignal, providing a writable reactive signal.
23
+ *
24
+ * @remarks
25
+ * SolidState is a thin wrapper around SolidJS's `createSignal` that provides a class-based
26
+ * interface consistent with PicoFlow's API style. It's used internally by PicoFlow's Solid
27
+ * integration but can also be used directly in Solid components.
28
+ *
29
+ * Unlike PicoFlow's {@link FlowState} which uses explicit tracking context, SolidState
30
+ * relies on SolidJS's automatic dependency tracking within reactive contexts like
31
+ * `createEffect` or component render functions.
32
+ *
33
+ * @example
34
+ * ```typescript
35
+ * const count = new SolidState(0);
36
+ *
37
+ * // In a Solid component
38
+ * function Counter() {
39
+ * return <div>{count.get()}</div>; // Automatically reactive
40
+ * }
41
+ *
42
+ * // Update the value
43
+ * count.set(1);
44
+ * count.set(prev => prev + 1);
45
+ * ```
23
46
  *
24
47
  * @typeParam T - The value type.
25
48
  * @public
@@ -40,7 +63,35 @@ export declare class SolidState<T> implements SolidObservable<T> {
40
63
  constructor(initialValue: T);
41
64
  }
42
65
  /**
43
- * Solid-style derivation, similar to a computed/memoized value.
66
+ * Solid-style derivation wrapping SolidJS's createMemo, providing a computed reactive value.
67
+ *
68
+ * @remarks
69
+ * SolidDerivation is a thin wrapper around SolidJS's `createMemo` that provides a class-based
70
+ * interface consistent with PicoFlow's API style. It creates a memoized computation that
71
+ * automatically tracks its dependencies and recomputes only when they change.
72
+ *
73
+ * Unlike PicoFlow's {@link FlowDerivation} which uses explicit tracking context, SolidDerivation
74
+ * relies on SolidJS's automatic dependency tracking. The computation function runs within
75
+ * SolidJS's reactive scope and automatically subscribes to any signals accessed during execution.
76
+ *
77
+ * **Memoization:**
78
+ * The computed value is cached and only recomputed when tracked dependencies change,
79
+ * providing efficient derived state management.
80
+ *
81
+ * @example
82
+ * ```typescript
83
+ * const firstName = new SolidState('John');
84
+ * const lastName = new SolidState('Doe');
85
+ *
86
+ * const fullName = new SolidDerivation(() => {
87
+ * return `${firstName.get()} ${lastName.get()}`;
88
+ * });
89
+ *
90
+ * // In a Solid component
91
+ * function Display() {
92
+ * return <div>{fullName.get()}</div>; // Automatically updates
93
+ * }
94
+ * ```
44
95
  *
45
96
  * @typeParam T - The value type.
46
97
  * @public
@@ -57,7 +108,48 @@ export declare class SolidDerivation<T> implements SolidObservable<T> {
57
108
  constructor(calculator: SolidGetter<T>);
58
109
  }
59
110
  /**
60
- * Solid-style resource, similar to an async resource or data loader.
111
+ * Solid-style resource wrapping SolidJS's createResource, providing async data loading with reactive state.
112
+ *
113
+ * @remarks
114
+ * SolidResource is a thin wrapper around SolidJS's `createResource` that provides a class-based
115
+ * interface consistent with PicoFlow's API style. It manages asynchronous data fetching with
116
+ * built-in loading states, error handling, and automatic reactivity.
117
+ *
118
+ * Unlike PicoFlow's {@link FlowResource} or {@link FlowResourceAsync}, SolidResource integrates
119
+ * directly with SolidJS's Suspense and ErrorBoundary mechanisms, providing a first-class async
120
+ * data loading experience in Solid applications.
121
+ *
122
+ * **Resource States:**
123
+ * - `unresolved`: Initial state before first fetch
124
+ * - `pending`: Fetch is in progress
125
+ * - `ready`: Data has been successfully loaded
126
+ * - `refreshing`: Refetching while previous data is still available
127
+ * - `errored`: Fetch failed with an error
128
+ *
129
+ * **Properties:**
130
+ * - `get()`: Returns the current value (or undefined if not ready)
131
+ * - `state()`: Returns the current loading state
132
+ * - `latest()`: Returns the most recent successfully loaded value
133
+ * - `refetch()`: Triggers a new fetch operation
134
+ *
135
+ * @example
136
+ * ```typescript
137
+ * const user = new SolidResource(async () => {
138
+ * const res = await fetch('/api/user');
139
+ * return res.json();
140
+ * });
141
+ *
142
+ * // In a Solid component
143
+ * function UserProfile() {
144
+ * return (
145
+ * <div>
146
+ * {user.state() === 'pending' && <p>Loading...</p>}
147
+ * {user.state() === 'ready' && <p>Name: {user.get()?.name}</p>}
148
+ * <button onClick={() => user.refetch()}>Refresh</button>
149
+ * </div>
150
+ * );
151
+ * }
152
+ * ```
61
153
  *
62
154
  * @typeParam T - The value type.
63
155
  * @public
@@ -70,7 +162,7 @@ export declare class SolidResource<T> implements SolidObservable<T | undefined>
70
162
  /**
71
163
  * Returns the current resource state.
72
164
  */
73
- readonly state: () => 'unresolved' | 'pending' | 'errored' | 'ready' | 'refreshing';
165
+ readonly state: () => "unresolved" | "pending" | "errored" | "ready" | "refreshing";
74
166
  /**
75
167
  * Returns the latest successfully loaded value (or undefined).
76
168
  */
@@ -1 +1 @@
1
- {"version":3,"file":"primitives.d.ts","sourceRoot":"","sources":["../../../src/solid/primitives.ts"],"names":[],"mappings":"AAAA,OAAO,EAA4C,KAAK,eAAe,EAAG,MAAM,UAAU,CAAC;AAE3F;;;;;GAKG;AACH,MAAM,MAAM,WAAW,CAAC,CAAC,IAAI,CAAC,CAAC,QAAQ,EAAE,CAAC,KAAK,CAAC,CAAC,GAAG,CAAC,CAAC;AAEtD;;;;;GAKG;AACH,MAAM,WAAW,eAAe,CAAC,CAAC;IAC9B;;OAEG;IACH,GAAG,EAAE,MAAM,CAAC,CAAC;CAChB;AAED;;;;;GAKG;AACH,qBAAa,UAAU,CAAC,CAAC,CAAE,YAAW,eAAe,CAAC,CAAC,CAAC;IACpD;;OAEG;IACH,QAAQ,CAAC,GAAG,EAAE,MAAM,CAAC,CAAC;IACtB;;OAEG;IACH,QAAQ,CAAC,GAAG,EAAE,CAAC,KAAK,EAAE,WAAW,CAAC,CAAC,CAAC,KAAK,IAAI,CAAC;IAE9C;;;OAGG;gBACS,YAAY,EAAE,CAAC;CAK9B;AAGD;;;;;GAKG;AACH,qBAAa,eAAe,CAAC,CAAC,CAAE,YAAW,eAAe,CAAC,CAAC,CAAC;IACzD;;OAEG;IACH,QAAQ,CAAC,GAAG,EAAE,MAAM,CAAC,CAAC;IAEtB;;;OA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