@ersbeth/picoflow 0.2.3 → 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 +557 -1099
  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 -20
  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
@@ -0,0 +1,567 @@
1
+ <!-- e795d61b-15e2-4796-9ca1-7878e5c3709b fe8b0d3c-6bd4-436a-9d8b-a0eedf4b07e4 -->
2
+ # PicoFlow Guide Documentation Plan
3
+
4
+ ## Overview
5
+
6
+ Write complete documentation for PicoFlow targeting complete beginners with no prior reactive programming experience. Use a concepts-first approach followed by practical examples with Mermaid diagrams for visual explanations. All content in English.
7
+
8
+ ## Current State
9
+
10
+ Existing files in `docs/guide/`:
11
+
12
+ - [getting-started.md](docs/guide/getting-started.md) - Basic intro (40 lines)
13
+ - [installation.md](docs/guide/installation.md) - Complete (64 lines)
14
+ - [concepts.md](docs/guide/concepts.md) - Good foundation (88 lines)
15
+ - [state.md](docs/guide/state.md) - Stub (5 lines)
16
+ - [effects-derivations.md](docs/guide/effects-derivations.md) - Stub to split into two files
17
+ - [resources-streams.md](docs/guide/resources-streams.md) - Stub to split into two files
18
+ - [advanced.md](docs/guide/advanced.md) - Stub (5 lines)
19
+ - [examples.md](docs/guide/examples.md) - Stub (5 lines)
20
+
21
+ ## New File Structure
22
+
23
+ After implementation:
24
+
25
+ - [getting-started.md](docs/guide/getting-started.md)
26
+ - [installation.md](docs/guide/installation.md)
27
+ - [concepts.md](docs/guide/concepts.md)
28
+ - [state.md](docs/guide/state.md)
29
+ - [effects.md](docs/guide/effects.md) - NEW (split from effects-derivations.md)
30
+ - [derivations.md](docs/guide/derivations.md) - NEW (split from effects-derivations.md)
31
+ - [resources.md](docs/guide/resources.md) - NEW (split from resources-streams.md)
32
+ - [streams.md](docs/guide/streams.md) - NEW (split from resources-streams.md)
33
+ - [advanced.md](docs/guide/advanced.md)
34
+ - [examples.md](docs/guide/examples.md)
35
+
36
+ ## Documentation Structure
37
+
38
+ ### 1. Update [getting-started.md](docs/guide/getting-started.md)
39
+
40
+ **Goal**: Welcoming introduction that explains reactive programming from scratch
41
+
42
+ **Content to add**:
43
+
44
+ - What is reactive programming (analogy: spreadsheet cells)
45
+ - Why use reactive programming (automatic updates, declarative code)
46
+ - PicoFlow's philosophy (explicit tracking, fine-grained control)
47
+ - Comparison with imperative approach (before/after example)
48
+ - Enhanced quick example with annotations
49
+ - Clear next steps
50
+
51
+ **Mermaid diagrams**:
52
+
53
+ - Flow diagram showing reactive vs imperative updates
54
+
55
+ **Estimated length**: ~120-140 lines
56
+
57
+ ### 2. Keep [installation.md](docs/guide/installation.md) as-is
58
+
59
+ Already complete and well-structured.
60
+
61
+ ### 3. Enhance [concepts.md](docs/guide/concepts.md)
62
+
63
+ **Goal**: Deep dive into core concepts with beginner-friendly explanations
64
+
65
+ **Content to improve/add**:
66
+
67
+ - Explain "dependency" concept with simple analogy
68
+ - Visual metaphor for TrackingContext (like a notebook recording what you read)
69
+ - Detailed explanation of `.get(t)` vs `.pick()` with real-world scenarios
70
+ - Add section on "The $ prefix convention"
71
+ - Add section on "Disposal and cleanup"
72
+ - Expand primitives overview with when to use each
73
+ - Add common patterns section
74
+ - More visual examples
75
+
76
+ **Mermaid diagrams**:
77
+
78
+ - TrackingContext dependency registration flow
79
+ - Effect execution cycle
80
+ - Comparison diagram of `.get(t)` vs `.pick()`
81
+
82
+ **Estimated length**: ~180-200 lines
83
+
84
+ ### 4. Write [state.md](docs/guide/state.md)
85
+
86
+ **Goal**: Complete guide to mutable and immutable reactive values
87
+
88
+ **Sections**:
89
+
90
+ 1. Introduction to State
91
+
92
+ - What is state
93
+ - When to use state vs constants
94
+
95
+ 2. Creating State
96
+
97
+ - Basic usage with `state()`
98
+ - Initial values
99
+
100
+ 3. Reading State Values
101
+
102
+ - Reactive reads with `.get(t)`
103
+ - Non-reactive reads with `.pick()`
104
+
105
+ 4. Updating State
106
+
107
+ - Direct values with `.set(value)`
108
+ - Updater functions with `.set(fn)`
109
+
110
+ 5. Constants
111
+
112
+ - What are constants
113
+ - Lazy vs eager initialization
114
+ - Use cases
115
+
116
+ 6. Practical Examples
117
+
118
+ - Counter
119
+ - Form state
120
+ - Configuration values
121
+
122
+ 7. Best Practices
123
+
124
+ - When to use state vs constants
125
+ - Naming conventions
126
+ - Common pitfalls
127
+
128
+ **Mermaid diagrams**:
129
+
130
+ - State update and notification flow
131
+ - Lazy constant initialization diagram
132
+
133
+ **Estimated length**: ~200-220 lines
134
+
135
+ ### 5. Write [effects.md](docs/guide/effects.md) - NEW FILE
136
+
137
+ **Goal**: Comprehensive guide to side effects
138
+
139
+ **Sections**:
140
+
141
+ 1. Understanding Effects
142
+
143
+ - What are side effects
144
+ - Examples of side effects (DOM updates, logging, API calls)
145
+ - Why effects are needed in reactive systems
146
+
147
+ 2. How Effects Work
148
+
149
+ - The tracking context
150
+ - Automatic re-execution
151
+ - Effect lifecycle
152
+
153
+ 3. Creating Effects
154
+
155
+ - Basic syntax with `effect((t) => {})`
156
+ - The tracking parameter
157
+ - Immediate execution
158
+
159
+ 4. Effect Dependencies
160
+
161
+ - Explicit dependency tracking with `.get(t)`
162
+ - Multiple dependencies
163
+ - Conditional dependencies
164
+ - Avoiding dependencies with `.pick()`
165
+
166
+ 5. Effect Patterns
167
+
168
+ - Logging and debugging
169
+ - DOM manipulation
170
+ - Local storage sync
171
+ - Event handlers
172
+
173
+ 6. Disposal and Cleanup
174
+
175
+ - When to dispose effects
176
+ - Using `.dispose()`
177
+ - Memory leak prevention
178
+
179
+ 7. Practical Examples
180
+
181
+ - Console logging
182
+ - Document title updates
183
+ - Form validation feedback
184
+ - Auto-save
185
+
186
+ 8. Best Practices
187
+
188
+ - Keep effects focused
189
+ - Avoid effects in effects
190
+ - Error handling
191
+ - Common pitfalls
192
+
193
+ **Mermaid diagrams**:
194
+
195
+ - Effect execution and re-execution flow
196
+ - Dependency tracking visualization
197
+ - Effect lifecycle diagram
198
+
199
+ **Estimated length**: ~200-220 lines
200
+
201
+ ### 6. Write [derivations.md](docs/guide/derivations.md) - NEW FILE
202
+
203
+ **Goal**: Complete guide to computed values
204
+
205
+ **Sections**:
206
+
207
+ 1. Understanding Derivations
208
+
209
+ - What are computed values
210
+ - Pure functions concept
211
+ - Difference between effects and derivations
212
+
213
+ 2. How Derivations Work
214
+
215
+ - Lazy evaluation explained
216
+ - Caching behavior
217
+ - Dirty checking
218
+
219
+ 3. Creating Derivations
220
+
221
+ - Basic syntax with `derivation((t) => {})`
222
+ - Return values
223
+ - Type inference
224
+
225
+ 4. Derivation Dependencies
226
+
227
+ - Tracking with `.get(t)`
228
+ - Multiple source dependencies
229
+ - Chaining derivations
230
+
231
+ 5. Advanced Patterns
232
+
233
+ - Combining multiple derivations
234
+ - Conditional computations
235
+ - Complex calculations
236
+ - Performance considerations
237
+
238
+ 6. Practical Examples
239
+
240
+ - Mathematical calculations (sum, average, total)
241
+ - Filtered and sorted lists
242
+ - Formatted values (currency, dates)
243
+ - Derived UI state
244
+
245
+ 7. Best Practices
246
+
247
+ - Keep derivations pure (no side effects)
248
+ - Avoid expensive operations
249
+ - When to use constants vs derivations
250
+ - Common pitfalls
251
+
252
+ **Mermaid diagrams**:
253
+
254
+ - Derivation lazy evaluation flow
255
+ - Derivation caching and invalidation
256
+ - Comparison: derivation vs effect
257
+ - Chained derivations dependency graph
258
+
259
+ **Estimated length**: ~180-200 lines
260
+
261
+ ### 7. Write [resources.md](docs/guide/resources.md) - NEW FILE
262
+
263
+ **Goal**: Complete guide to resource management
264
+
265
+ **Sections**:
266
+
267
+ 1. Understanding Resources
268
+
269
+ - What are resources
270
+ - Difference from state
271
+ - When to use resources
272
+ - Pull-based data fetching
273
+
274
+ 2. Synchronous Resources
275
+
276
+ - Creating with `resource(fetchFn, initialValue)`
277
+ - The fetch function
278
+ - Initial values
279
+ - Undefined state handling
280
+
281
+ 3. Fetching and Refetching
282
+
283
+ - Manual fetch with `.fetch()`
284
+ - Reactive refetching
285
+ - Loading states
286
+
287
+ 4. Asynchronous Resources
288
+
289
+ - Creating with `resourceAsync(fetchFn)`
290
+ - Promise-based access
291
+ - Async/await patterns
292
+ - Promise resolution
293
+
294
+ 5. Practical Examples
295
+
296
+ - API data fetching
297
+ - File loading
298
+ - Database queries
299
+ - Configuration loading
300
+
301
+ 6. Error Handling
302
+
303
+ - Try-catch patterns
304
+ - Error states
305
+ - Retry logic
306
+
307
+ 7. Best Practices
308
+
309
+ - Resource cleanup
310
+ - Caching strategies
311
+ - Loading indicators
312
+ - Error boundaries
313
+ - Common pitfalls
314
+
315
+ **Mermaid diagrams**:
316
+
317
+ - Resource fetch lifecycle
318
+ - Sync vs async resource comparison
319
+ - Resource state transitions (idle -> fetching -> resolved/error)
320
+
321
+ **Estimated length**: ~180-200 lines
322
+
323
+ ### 8. Write [streams.md](docs/guide/streams.md) - NEW FILE
324
+
325
+ **Goal**: Complete guide to reactive streams
326
+
327
+ **Sections**:
328
+
329
+ 1. Understanding Streams
330
+
331
+ - What are streams
332
+ - Push-based vs pull-based data
333
+ - When to use streams vs resources
334
+ - Event-driven updates
335
+
336
+ 2. How Streams Work
337
+
338
+ - The updater function
339
+ - The setter callback
340
+ - The disposer pattern
341
+ - Initial undefined state
342
+
343
+ 3. Creating Streams
344
+
345
+ - Basic syntax with `stream((set) => disposer)`
346
+ - Setting up subscriptions
347
+ - Returning cleanup functions
348
+
349
+ 4. Stream Patterns
350
+
351
+ - WebSocket connections
352
+ - DOM event listeners
353
+ - Timers and intervals
354
+ - Server-sent events
355
+ - Observable integration
356
+
357
+ 5. Asynchronous Streams
358
+
359
+ - Creating with `streamAsync((set) => disposer)`
360
+ - Promise-based values
361
+ - Async/await in effects
362
+
363
+ 6. Practical Examples
364
+
365
+ - WebSocket message stream
366
+ - Mouse position tracker
367
+ - Timer/countdown
368
+ - Keyboard events
369
+ - Real-time notifications
370
+
371
+ 7. Cleanup and Disposal
372
+
373
+ - Disposer function importance
374
+ - Avoiding memory leaks
375
+ - Connection management
376
+
377
+ 8. Best Practices
378
+
379
+ - Always return disposers
380
+ - Handle errors in streams
381
+ - Avoid duplicate subscriptions
382
+ - Common pitfalls
383
+
384
+ **Mermaid diagrams**:
385
+
386
+ - Stream updater and disposer flow
387
+ - Push-based data flow visualization
388
+ - Stream lifecycle (setup -> updates -> disposal)
389
+ - Sync vs async stream comparison
390
+
391
+ **Estimated length**: ~200-220 lines
392
+
393
+ ### 9. Write [advanced.md](docs/guide/advanced.md)
394
+
395
+ **Goal**: Guide to reactive collections (Map and Array)
396
+
397
+ **Sections**:
398
+
399
+ 1. Introduction to Reactive Collections
400
+
401
+ - Why collections need special handling
402
+ - Fine-grained vs coarse-grained reactivity
403
+ - Performance benefits
404
+
405
+ 2. Reactive Maps
406
+
407
+ - Creating with `map()`
408
+ - Whole map tracking with `.get(t)`
409
+ - Fine-grained tracking with `$lastSet`
410
+ - Fine-grained tracking with `$lastDeleted`
411
+ - Methods: `setAt()`, `delete()`, `get()`, `pick()`
412
+
413
+ 3. Reactive Arrays
414
+
415
+ - Creating with `array()`
416
+ - Whole array tracking
417
+ - Fine-grained tracking with `$lastAction`
418
+ - Array methods: `push()`, `pop()`, `shift()`, `unshift()`, `splice()`, `clear()`
419
+
420
+ 4. Practical Examples
421
+
422
+ - User list management
423
+ - Shopping cart
424
+ - Todo list with granular updates
425
+ - Entity cache
426
+ - UI animations based on operations
427
+
428
+ 5. Patterns and Tips
429
+
430
+ - When to track whole vs operations
431
+ - Performance considerations
432
+ - Disposal of items
433
+ - Common patterns
434
+
435
+ **Mermaid diagrams**:
436
+
437
+ - Map operation tracking flow
438
+ - Array operation tracking flow
439
+ - Fine-grained vs coarse-grained reactivity comparison
440
+
441
+ **Estimated length**: ~180-200 lines
442
+
443
+ ### 10. Write [examples.md](docs/guide/examples.md)
444
+
445
+ **Goal**: Real-world complete examples showing PicoFlow in action
446
+
447
+ **Examples to include**:
448
+
449
+ 1. Todo List Application
450
+
451
+ - State management
452
+ - Derived values (completed count, filtered lists)
453
+ - Effects for persistence
454
+
455
+ 2. Form with Validation
456
+
457
+ - Form state
458
+ - Derived validation
459
+ - Computed error messages
460
+
461
+ 3. Real-time Data Dashboard
462
+
463
+ - WebSocket stream
464
+ - Derived statistics
465
+ - Multiple effects for UI updates
466
+
467
+ 4. Shopping Cart
468
+
469
+ - Reactive map for items
470
+ - Derived totals
471
+ - Fine-grained updates
472
+
473
+ 5. Auto-save Feature
474
+
475
+ - Debounced effects
476
+ - Resource fetching
477
+ - Error handling
478
+
479
+ Each example should:
480
+
481
+ - Have complete, runnable code
482
+ - Include explanatory comments
483
+ - Show best practices
484
+ - Demonstrate multiple features working together
485
+ - Include a Mermaid diagram showing data flow
486
+
487
+ **Mermaid diagrams**:
488
+
489
+ - Data flow diagram for each major example
490
+
491
+ **Estimated length**: ~280-320 lines
492
+
493
+ ### 11. Update VitePress config
494
+
495
+ Update [docs/.vitepress/config.mts](docs/.vitepress/config.mts) sidebar to reflect new file structure:
496
+
497
+ - Change "Effects & Derivations" to separate "Effects" and "Derivations" links
498
+ - Change "Resources & Streams" to separate "Resources" and "Streams" links
499
+
500
+ ## Documentation Principles
501
+
502
+ Throughout all files:
503
+
504
+ 1. **Beginner-Friendly Language**
505
+
506
+ - Avoid jargon without explanation
507
+ - Use analogies and metaphors
508
+ - Define technical terms when first used
509
+
510
+ 2. **Visual Aids**
511
+
512
+ - Use Mermaid diagrams for flows and concepts
513
+ - Flowcharts for decision trees
514
+ - Sequence diagrams for lifecycles
515
+ - Graph diagrams for dependencies
516
+
517
+ 3. **Progressive Complexity**
518
+
519
+ - Start simple, build up gradually
520
+ - Each concept builds on previous ones
521
+ - Clear section progression
522
+
523
+ 4. **Practical Examples**
524
+
525
+ - Every concept has an example
526
+ - Examples are realistic and relatable
527
+ - Code includes helpful comments
528
+
529
+ 5. **Clear Structure**
530
+
531
+ - Consistent heading hierarchy
532
+ - Visual separation of sections
533
+ - Frequent code examples
534
+
535
+ 6. **Cross-referencing**
536
+
537
+ - Link to related concepts
538
+ - Link to API reference
539
+ - Link to other guide sections
540
+
541
+ ## Implementation Order
542
+
543
+ 1. [concepts.md](docs/guide/concepts.md) - Foundation with diagrams
544
+ 2. [state.md](docs/guide/state.md) - Most basic primitive
545
+ 3. [effects.md](docs/guide/effects.md) - Side effects explained
546
+ 4. [derivations.md](docs/guide/derivations.md) - Computed values
547
+ 5. [resources.md](docs/guide/resources.md) - Data fetching
548
+ 6. [streams.md](docs/guide/streams.md) - Event streams
549
+ 7. [advanced.md](docs/guide/advanced.md) - Collections
550
+ 8. [examples.md](docs/guide/examples.md) - Complete examples
551
+ 9. [getting-started.md](docs/guide/getting-started.md) - Final polish
552
+ 10. Update VitePress config for new file structure
553
+
554
+ ### To-dos
555
+
556
+ - [ ] Install TypeDoc, plugins, and VitePress dependencies
557
+ - [ ] Create typedoc.json configuration file
558
+ - [ ] Create docs folder structure (.vitepress, guide, etc.)
559
+ - [ ] Create VitePress config with nav and sidebar
560
+ - [ ] Create docs/index.md homepage with hero and features
561
+ - [ ] Create getting-started and concepts guide pages
562
+ - [ ] Add docs:dev, docs:build, docs:preview scripts to package.json
563
+ - [ ] Archive or remove old API Extractor generated files
564
+ - [ ] Add VitePress generated folders to .gitignore
565
+ - [ ] Test docs generation and verify markdown rendering
566
+ - [ ] Test production build and preview
567
+ - [ ] Update README with new documentation links and workflow
package/.gitlab-ci.yml ADDED
@@ -0,0 +1,24 @@
1
+ image: node:20
2
+
3
+ cache:
4
+ paths:
5
+ - node_modules/
6
+ - .pnpm-store/
7
+
8
+ variables:
9
+ PNPM_VERSION: 8
10
+
11
+ before_script:
12
+ - npm install -g pnpm@${PNPM_VERSION}
13
+ - pnpm install
14
+
15
+ pages:
16
+ stage: deploy
17
+ script:
18
+ - pnpm docs:build
19
+ - cp -r docs/.vitepress/dist public
20
+ artifacts:
21
+ paths:
22
+ - public
23
+ rules:
24
+ - if: $CI_COMMIT_BRANCH == "main"
@@ -1,5 +1,5 @@
1
1
  {
2
- "files.associations": {
3
- "*.json": "jsonc"
4
- }
2
+ "files.associations": {
3
+ "*.json": "jsonc"
4
+ }
5
5
  }
package/CHANGELOG.md ADDED
@@ -0,0 +1,51 @@
1
+ # Changelog
2
+
3
+ All notable changes to this project will be documented in this file.
4
+
5
+ The format is based on [Keep a Changelog](https://keepachangelog.com/en/1.0.0/),
6
+ and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0.html).
7
+
8
+ ## [Unreleased]
9
+
10
+ ## [1.0.0] - 2025-11-29
11
+
12
+ ### 🚨 BREAKING CHANGES
13
+
14
+ This is a major rewrite of PicoFlow's API. The library now uses an explicit tracking context instead of getter/watcher functions. **This release is not backward compatible with v0.x.**
15
+
16
+ **Migration required:** Please see [UPGRADING.md](UPGRADING.md) for detailed migration instructions. Most projects can be migrated in 15-30 minutes.
17
+
18
+ ### Changed
19
+
20
+ - **Complete API overhaul:** Effects and derivations now receive a `TrackingContext` parameter (`t`) instead of separate `get` and `watch` functions
21
+ - **New method-based API:** Observables use `.get(t)` for reactive reads instead of `get(observable)`
22
+ - **Signals use `.watch(t)`:** Signal tracking now uses `$signal.watch(t)` instead of `watch($signal)`
23
+ - **Chained syntax:** Enable natural chaining like `$parent.get(t).child.get(t)` instead of nested `get(get($parent).child)`
24
+ - **Simpler architecture:** Removed internal methods (`_watch`, `_watchFrom`, `_getFrom`) in favor of direct method overrides
25
+
26
+ ### Added
27
+
28
+ - **`TrackingContext` class:** New explicit tracking context for reactive computations
29
+ - **`pick()` method:** Read observable values without creating dependencies - `$state.pick()` is equivalent to `$state.get(null)`
30
+ - **Explicit control:** Granular control over what is tracked vs. untracked in the same reactive scope
31
+ - **Mixed reactive/non-reactive reads:** Use `.get(t)` for reactive dependencies and `.pick()` for snapshot reads in the same effect
32
+
33
+ ### Removed
34
+
35
+ - **`FlowGetter` type:** Replaced by `TrackingContext` parameter
36
+ - **`FlowWatcher` type:** Replaced by `TrackingContext` parameter
37
+ - **Implicit getter/watcher functions:** No longer passed to effects and derivations
38
+
39
+ ### Benefits
40
+
41
+ - **More readable:** Code is more explicit about what creates dependencies
42
+ - **Better chaining:** Natural fluent API for nested observables
43
+ - **Simpler codebase:** Cleaner internal architecture with fewer abstractions
44
+ - **More flexible:** Fine-grained control over reactive tracking per read operation
45
+
46
+ ---
47
+
48
+ ## [0.2.4] - Previous Release
49
+
50
+ (Version 0.x releases used the getter/watcher API)
51
+