@ersbeth/picoflow 1.1.2 → 2.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 (383) hide show
  1. package/.vscode/settings.json +3 -3
  2. package/CHANGELOG.md +43 -0
  3. package/README.md +2 -18
  4. package/biome.json +45 -35
  5. package/dist/picoflow.js +856 -1530
  6. package/dist/types/api/base/flowDisposable.d.ts +41 -0
  7. package/dist/types/api/base/flowDisposable.d.ts.map +1 -0
  8. package/dist/types/api/base/flowObservable.d.ts +27 -0
  9. package/dist/types/api/base/flowObservable.d.ts.map +1 -0
  10. package/dist/types/api/base/flowSubscribable.d.ts +79 -0
  11. package/dist/types/api/base/flowSubscribable.d.ts.map +1 -0
  12. package/dist/types/api/base/flowTracker.d.ts +8 -0
  13. package/dist/types/api/base/flowTracker.d.ts.map +1 -0
  14. package/dist/types/api/base/index.d.ts +5 -0
  15. package/dist/types/api/base/index.d.ts.map +1 -0
  16. package/dist/types/api/index.d.ts +3 -0
  17. package/dist/types/api/index.d.ts.map +1 -0
  18. package/dist/types/api/nodes/async/flowConstantAsync.d.ts +31 -0
  19. package/dist/types/api/nodes/async/flowConstantAsync.d.ts.map +1 -0
  20. package/dist/types/api/nodes/async/flowDerivationAsync.d.ts +37 -0
  21. package/dist/types/api/nodes/async/flowDerivationAsync.d.ts.map +1 -0
  22. package/dist/types/api/nodes/async/flowStateAsync.d.ts +41 -0
  23. package/dist/types/api/nodes/async/flowStateAsync.d.ts.map +1 -0
  24. package/dist/types/api/nodes/async/flowWritableDerivationAsync.d.ts +30 -0
  25. package/dist/types/api/nodes/async/flowWritableDerivationAsync.d.ts.map +1 -0
  26. package/dist/types/{flow → api}/nodes/async/index.d.ts +1 -2
  27. package/dist/types/api/nodes/async/index.d.ts.map +1 -0
  28. package/dist/types/api/nodes/collections/flowArray.d.ts +134 -0
  29. package/dist/types/api/nodes/collections/flowArray.d.ts.map +1 -0
  30. package/dist/types/api/nodes/collections/flowMap.d.ts +98 -0
  31. package/dist/types/api/nodes/collections/flowMap.d.ts.map +1 -0
  32. package/dist/types/api/nodes/collections/index.d.ts.map +1 -0
  33. package/dist/types/api/nodes/flowEffect.d.ts +28 -0
  34. package/dist/types/api/nodes/flowEffect.d.ts.map +1 -0
  35. package/dist/types/api/nodes/flowSignal.d.ts +25 -0
  36. package/dist/types/api/nodes/flowSignal.d.ts.map +1 -0
  37. package/dist/types/api/nodes/flowValue.d.ts +35 -0
  38. package/dist/types/api/nodes/flowValue.d.ts.map +1 -0
  39. package/dist/types/api/nodes/index.d.ts +8 -0
  40. package/dist/types/api/nodes/index.d.ts.map +1 -0
  41. package/dist/types/api/nodes/sync/flowConstant.d.ts +29 -0
  42. package/dist/types/api/nodes/sync/flowConstant.d.ts.map +1 -0
  43. package/dist/types/api/nodes/sync/flowDerivation.d.ts +36 -0
  44. package/dist/types/api/nodes/sync/flowDerivation.d.ts.map +1 -0
  45. package/dist/types/api/nodes/sync/flowState.d.ts +39 -0
  46. package/dist/types/api/nodes/sync/flowState.d.ts.map +1 -0
  47. package/dist/types/api/nodes/sync/flowWritableDerivation.d.ts +28 -0
  48. package/dist/types/api/nodes/sync/flowWritableDerivation.d.ts.map +1 -0
  49. package/dist/types/{flow → api}/nodes/sync/index.d.ts +1 -2
  50. package/dist/types/api/nodes/sync/index.d.ts.map +1 -0
  51. package/dist/types/api/nodes/utils.d.ts +22 -0
  52. package/dist/types/api/nodes/utils.d.ts.map +1 -0
  53. package/dist/types/base/disposable.d.ts +11 -0
  54. package/dist/types/base/disposable.d.ts.map +1 -0
  55. package/dist/types/base/executionStack.d.ts +14 -0
  56. package/dist/types/base/executionStack.d.ts.map +1 -0
  57. package/dist/types/base/index.d.ts +6 -0
  58. package/dist/types/base/index.d.ts.map +1 -0
  59. package/dist/types/base/node.d.ts +27 -0
  60. package/dist/types/base/node.d.ts.map +1 -0
  61. package/dist/types/base/observable.d.ts +37 -0
  62. package/dist/types/base/observable.d.ts.map +1 -0
  63. package/dist/types/base/observer.d.ts +25 -0
  64. package/dist/types/base/observer.d.ts.map +1 -0
  65. package/dist/types/converters/index.d.ts +2 -0
  66. package/dist/types/converters/index.d.ts.map +1 -0
  67. package/dist/types/converters/solid.d.ts +46 -0
  68. package/dist/types/converters/solid.d.ts.map +1 -0
  69. package/dist/types/index.d.ts +2 -63
  70. package/dist/types/index.d.ts.map +1 -1
  71. package/dist/types/nodes/arrayNode.d.ts +2 -0
  72. package/dist/types/nodes/arrayNode.d.ts.map +1 -0
  73. package/dist/types/nodes/effectNode.d.ts +2 -0
  74. package/dist/types/nodes/effectNode.d.ts.map +1 -0
  75. package/dist/types/nodes/index.d.ts +9 -0
  76. package/dist/types/nodes/index.d.ts.map +1 -0
  77. package/dist/types/nodes/mapNode.d.ts +2 -0
  78. package/dist/types/nodes/mapNode.d.ts.map +1 -0
  79. package/dist/types/nodes/signalNode.d.ts +2 -0
  80. package/dist/types/nodes/signalNode.d.ts.map +1 -0
  81. package/dist/types/nodes/valueAsyncNode.d.ts +2 -0
  82. package/dist/types/nodes/valueAsyncNode.d.ts.map +1 -0
  83. package/dist/types/nodes/valueNode.d.ts +2 -0
  84. package/dist/types/nodes/valueNode.d.ts.map +1 -0
  85. package/dist/types/nodes/valueSyncNode.d.ts +2 -0
  86. package/dist/types/nodes/valueSyncNode.d.ts.map +1 -0
  87. package/dist/types/schedulers/asyncResolver.d.ts +2 -0
  88. package/dist/types/schedulers/asyncResolver.d.ts.map +1 -0
  89. package/dist/types/schedulers/asyncScheduler.d.ts +2 -0
  90. package/dist/types/schedulers/asyncScheduler.d.ts.map +1 -0
  91. package/dist/types/schedulers/index.d.ts +5 -0
  92. package/dist/types/schedulers/index.d.ts.map +1 -0
  93. package/dist/types/schedulers/pendingError.d.ts +2 -0
  94. package/dist/types/schedulers/pendingError.d.ts.map +1 -0
  95. package/dist/types/schedulers/scheduler.d.ts +2 -0
  96. package/dist/types/schedulers/scheduler.d.ts.map +1 -0
  97. package/dist/types/schedulers/syncResolver.d.ts +2 -0
  98. package/dist/types/schedulers/syncResolver.d.ts.map +1 -0
  99. package/dist/types/schedulers/syncScheduler.d.ts +2 -0
  100. package/dist/types/schedulers/syncScheduler.d.ts.map +1 -0
  101. package/docs/.vitepress/config.mts +128 -93
  102. package/docs/api/functions/array.md +14 -37
  103. package/docs/api/functions/constant.md +13 -25
  104. package/docs/api/functions/constantAsync.md +69 -0
  105. package/docs/api/functions/derivation.md +14 -33
  106. package/docs/api/functions/derivationAsync.md +34 -0
  107. package/docs/api/functions/from.md +62 -153
  108. package/docs/api/functions/isDisposable.md +8 -30
  109. package/docs/api/functions/map.md +15 -36
  110. package/docs/api/functions/signal.md +8 -23
  111. package/docs/api/functions/state.md +43 -23
  112. package/docs/api/functions/stateAsync.md +69 -0
  113. package/docs/api/functions/subscribe.md +40 -0
  114. package/docs/api/functions/writableDerivation.md +33 -0
  115. package/docs/api/functions/writableDerivationAsync.md +34 -0
  116. package/docs/api/index.md +45 -102
  117. package/docs/api/interfaces/FlowArray.md +439 -0
  118. package/docs/api/interfaces/FlowConstant.md +220 -0
  119. package/docs/api/interfaces/FlowConstantAsync.md +221 -0
  120. package/docs/api/interfaces/FlowDerivation.md +241 -0
  121. package/docs/api/interfaces/FlowDerivationAsync.md +242 -0
  122. package/docs/api/interfaces/FlowDisposable.md +32 -38
  123. package/docs/api/interfaces/FlowEffect.md +64 -0
  124. package/docs/api/interfaces/FlowMap.md +374 -0
  125. package/docs/api/interfaces/FlowObservable.md +155 -0
  126. package/docs/api/interfaces/FlowSignal.md +156 -0
  127. package/docs/api/interfaces/FlowState.md +269 -0
  128. package/docs/api/interfaces/FlowStateAsync.md +268 -0
  129. package/docs/api/interfaces/FlowSubscribable.md +55 -0
  130. package/docs/api/interfaces/FlowTracker.md +61 -0
  131. package/docs/api/interfaces/FlowValue.md +222 -0
  132. package/docs/api/interfaces/FlowWritableDerivation.md +292 -0
  133. package/docs/api/interfaces/FlowWritableDerivationAsync.md +293 -0
  134. package/docs/api/type-aliases/DerivationFunction.md +28 -0
  135. package/docs/api/type-aliases/DerivationFunctionAsync.md +28 -0
  136. package/docs/api/type-aliases/FlowArrayAction.md +19 -8
  137. package/docs/api/type-aliases/FlowDataTracker.md +33 -0
  138. package/docs/api/type-aliases/FlowMapAction.md +48 -0
  139. package/docs/api/type-aliases/FlowOnDataListener.md +33 -0
  140. package/docs/api/type-aliases/FlowOnErrorListener.md +27 -0
  141. package/docs/api/type-aliases/FlowOnPendingListener.md +21 -0
  142. package/docs/api/type-aliases/FlowReadonly.md +22 -0
  143. package/docs/api/type-aliases/InitFunction.md +21 -0
  144. package/docs/api/type-aliases/InitFunctionAsync.md +21 -0
  145. package/docs/api/type-aliases/NotPromise.md +6 -3
  146. package/docs/api/type-aliases/UpdateFunction.md +27 -0
  147. package/docs/api/type-aliases/UpdateFunctionAsync.md +27 -0
  148. package/docs/api/typedoc-sidebar.json +1 -81
  149. package/docs/examples/examples.md +0 -2
  150. package/docs/guide/advanced/architecture.md +1234 -0
  151. package/docs/guide/advanced/migration-v2.md +204 -0
  152. package/docs/guide/advanced/solidjs.md +2 -88
  153. package/docs/guide/introduction/concepts.md +4 -3
  154. package/docs/guide/introduction/conventions.md +2 -33
  155. package/docs/guide/introduction/getting-started.md +28 -23
  156. package/docs/guide/introduction/lifecycle.md +16 -19
  157. package/docs/guide/primitives/array.md +102 -216
  158. package/docs/guide/primitives/constant.md +39 -212
  159. package/docs/guide/primitives/derivations.md +55 -122
  160. package/docs/guide/primitives/effects.md +155 -241
  161. package/docs/guide/primitives/map.md +64 -186
  162. package/docs/guide/primitives/overview.md +45 -128
  163. package/docs/guide/primitives/signal.md +51 -88
  164. package/docs/guide/primitives/state.md +34 -130
  165. package/package.json +56 -60
  166. package/src/api/base/flowDisposable.ts +44 -0
  167. package/src/api/base/flowObservable.ts +28 -0
  168. package/src/api/base/flowSubscribable.ts +87 -0
  169. package/src/api/base/flowTracker.ts +7 -0
  170. package/src/api/base/index.ts +4 -0
  171. package/src/{flow → api}/index.ts +0 -1
  172. package/src/api/nodes/async/flowConstantAsync.ts +36 -0
  173. package/src/api/nodes/async/flowDerivationAsync.ts +42 -0
  174. package/src/api/nodes/async/flowStateAsync.ts +47 -0
  175. package/src/api/nodes/async/flowWritableDerivationAsync.ts +33 -0
  176. package/src/{flow → api}/nodes/async/index.ts +1 -2
  177. package/src/api/nodes/collections/flowArray.ts +155 -0
  178. package/src/api/nodes/collections/flowMap.ts +115 -0
  179. package/src/api/nodes/flowEffect.ts +42 -0
  180. package/src/api/nodes/flowSignal.ts +28 -0
  181. package/src/api/nodes/flowValue.ts +36 -0
  182. package/src/api/nodes/index.ts +7 -0
  183. package/src/api/nodes/sync/flowConstant.ts +33 -0
  184. package/src/api/nodes/sync/flowDerivation.ts +41 -0
  185. package/src/api/nodes/sync/flowState.ts +45 -0
  186. package/src/api/nodes/sync/flowWritableDerivation.ts +31 -0
  187. package/src/{flow → api}/nodes/sync/index.ts +1 -2
  188. package/src/api/nodes/utils.ts +22 -0
  189. package/src/base/disposable.ts +18 -0
  190. package/src/base/executionStack.ts +42 -0
  191. package/src/base/index.ts +5 -0
  192. package/src/base/node.ts +98 -0
  193. package/src/base/observable.ts +87 -0
  194. package/src/base/observer.ts +51 -0
  195. package/src/converters/index.ts +1 -0
  196. package/src/converters/solid.ts +109 -0
  197. package/src/index.ts +2 -64
  198. package/src/nodes/arrayNode.ts +172 -0
  199. package/src/nodes/effectNode.ts +59 -0
  200. package/src/nodes/index.ts +8 -0
  201. package/src/nodes/mapNode.ts +127 -0
  202. package/src/nodes/signalNode.ts +21 -0
  203. package/src/nodes/valueAsyncNode.ts +88 -0
  204. package/src/nodes/valueNode.ts +144 -0
  205. package/src/nodes/valueSyncNode.ts +128 -0
  206. package/src/schedulers/asyncResolver.ts +78 -0
  207. package/src/schedulers/asyncScheduler.ts +66 -0
  208. package/src/schedulers/index.ts +4 -0
  209. package/src/schedulers/pendingError.ts +13 -0
  210. package/src/schedulers/scheduler.ts +9 -0
  211. package/src/schedulers/syncResolver.ts +69 -0
  212. package/src/schedulers/syncScheduler.ts +55 -0
  213. package/test/base/pendingError.test.ts +67 -0
  214. package/test/converters/solid.derivation.browser.test.tsx +69 -0
  215. package/test/converters/solid.node.test.ts +654 -0
  216. package/test/converters/solid.state.browser.test.tsx +1592 -0
  217. package/test/reactivity/flowSignal.test.ts +226 -0
  218. package/test/reactivity/nodes/async/asyncScheduler/asyncResolver.test.ts +593 -0
  219. package/test/reactivity/nodes/async/asyncScheduler/asyncScheduler.test.ts +317 -0
  220. package/test/reactivity/nodes/async/flowConstantAsync.test.ts +652 -0
  221. package/test/reactivity/nodes/async/flowDerivation.test.ts +898 -0
  222. package/test/reactivity/nodes/async/flowDerivationAsync.test.ts +1716 -0
  223. package/test/reactivity/nodes/async/flowStateAsync.test.ts +708 -0
  224. package/test/reactivity/nodes/async/flowWritableDerivationAsync.test.ts +614 -0
  225. package/test/reactivity/nodes/collections/flowArray.asyncStates.test.ts +1289 -0
  226. package/test/reactivity/nodes/collections/flowArray.scalars.test.ts +961 -0
  227. package/test/reactivity/nodes/collections/flowArray.states.test.ts +1035 -0
  228. package/test/reactivity/nodes/collections/flowMap.asyncStates.test.ts +960 -0
  229. package/test/reactivity/nodes/collections/flowMap.scalars.test.ts +775 -0
  230. package/test/reactivity/nodes/collections/flowMap.states.test.ts +958 -0
  231. package/test/reactivity/nodes/sync/flowConstant.test.ts +377 -0
  232. package/test/reactivity/nodes/sync/flowDerivation.test.ts +896 -0
  233. package/test/reactivity/nodes/sync/flowState.test.ts +341 -0
  234. package/test/reactivity/nodes/sync/flowWritableDerivation.test.ts +603 -0
  235. package/test/vitest.d.ts +10 -0
  236. package/tsconfig.json +31 -20
  237. package/typedoc.json +35 -35
  238. package/vite.config.ts +25 -23
  239. package/vitest.browser.config.ts +21 -0
  240. package/vitest.config.ts +12 -12
  241. package/.cursor/plans/unifier-flowresource-avec-flowderivation-c9506e24.plan.md +0 -372
  242. package/.cursor/plans/update-js-e795d61b.plan.md +0 -567
  243. package/dist/types/flow/base/flowDisposable.d.ts +0 -67
  244. package/dist/types/flow/base/flowDisposable.d.ts.map +0 -1
  245. package/dist/types/flow/base/flowEffect.d.ts +0 -127
  246. package/dist/types/flow/base/flowEffect.d.ts.map +0 -1
  247. package/dist/types/flow/base/flowGraph.d.ts +0 -97
  248. package/dist/types/flow/base/flowGraph.d.ts.map +0 -1
  249. package/dist/types/flow/base/flowSignal.d.ts +0 -134
  250. package/dist/types/flow/base/flowSignal.d.ts.map +0 -1
  251. package/dist/types/flow/base/flowTracker.d.ts +0 -15
  252. package/dist/types/flow/base/flowTracker.d.ts.map +0 -1
  253. package/dist/types/flow/base/index.d.ts +0 -7
  254. package/dist/types/flow/base/index.d.ts.map +0 -1
  255. package/dist/types/flow/base/utils.d.ts +0 -20
  256. package/dist/types/flow/base/utils.d.ts.map +0 -1
  257. package/dist/types/flow/collections/flowArray.d.ts +0 -148
  258. package/dist/types/flow/collections/flowArray.d.ts.map +0 -1
  259. package/dist/types/flow/collections/flowMap.d.ts +0 -224
  260. package/dist/types/flow/collections/flowMap.d.ts.map +0 -1
  261. package/dist/types/flow/collections/index.d.ts.map +0 -1
  262. package/dist/types/flow/index.d.ts +0 -4
  263. package/dist/types/flow/index.d.ts.map +0 -1
  264. package/dist/types/flow/nodes/async/flowConstantAsync.d.ts +0 -137
  265. package/dist/types/flow/nodes/async/flowConstantAsync.d.ts.map +0 -1
  266. package/dist/types/flow/nodes/async/flowDerivationAsync.d.ts +0 -137
  267. package/dist/types/flow/nodes/async/flowDerivationAsync.d.ts.map +0 -1
  268. package/dist/types/flow/nodes/async/flowNodeAsync.d.ts +0 -343
  269. package/dist/types/flow/nodes/async/flowNodeAsync.d.ts.map +0 -1
  270. package/dist/types/flow/nodes/async/flowReadonlyAsync.d.ts +0 -81
  271. package/dist/types/flow/nodes/async/flowReadonlyAsync.d.ts.map +0 -1
  272. package/dist/types/flow/nodes/async/flowStateAsync.d.ts +0 -111
  273. package/dist/types/flow/nodes/async/flowStateAsync.d.ts.map +0 -1
  274. package/dist/types/flow/nodes/async/index.d.ts.map +0 -1
  275. package/dist/types/flow/nodes/index.d.ts +0 -3
  276. package/dist/types/flow/nodes/index.d.ts.map +0 -1
  277. package/dist/types/flow/nodes/sync/flowConstant.d.ts +0 -108
  278. package/dist/types/flow/nodes/sync/flowConstant.d.ts.map +0 -1
  279. package/dist/types/flow/nodes/sync/flowDerivation.d.ts +0 -100
  280. package/dist/types/flow/nodes/sync/flowDerivation.d.ts.map +0 -1
  281. package/dist/types/flow/nodes/sync/flowNode.d.ts +0 -314
  282. package/dist/types/flow/nodes/sync/flowNode.d.ts.map +0 -1
  283. package/dist/types/flow/nodes/sync/flowReadonly.d.ts +0 -57
  284. package/dist/types/flow/nodes/sync/flowReadonly.d.ts.map +0 -1
  285. package/dist/types/flow/nodes/sync/flowState.d.ts +0 -96
  286. package/dist/types/flow/nodes/sync/flowState.d.ts.map +0 -1
  287. package/dist/types/flow/nodes/sync/index.d.ts.map +0 -1
  288. package/dist/types/solid/converters.d.ts +0 -57
  289. package/dist/types/solid/converters.d.ts.map +0 -1
  290. package/dist/types/solid/index.d.ts +0 -3
  291. package/dist/types/solid/index.d.ts.map +0 -1
  292. package/dist/types/solid/primitives.d.ts +0 -181
  293. package/dist/types/solid/primitives.d.ts.map +0 -1
  294. package/docs/api/classes/FlowArray.md +0 -489
  295. package/docs/api/classes/FlowConstant.md +0 -350
  296. package/docs/api/classes/FlowDerivation.md +0 -334
  297. package/docs/api/classes/FlowEffect.md +0 -100
  298. package/docs/api/classes/FlowMap.md +0 -512
  299. package/docs/api/classes/FlowObservable.md +0 -306
  300. package/docs/api/classes/FlowResource.md +0 -380
  301. package/docs/api/classes/FlowResourceAsync.md +0 -362
  302. package/docs/api/classes/FlowSignal.md +0 -160
  303. package/docs/api/classes/FlowState.md +0 -368
  304. package/docs/api/classes/FlowStream.md +0 -367
  305. package/docs/api/classes/FlowStreamAsync.md +0 -364
  306. package/docs/api/classes/SolidDerivation.md +0 -75
  307. package/docs/api/classes/SolidResource.md +0 -91
  308. package/docs/api/classes/SolidState.md +0 -71
  309. package/docs/api/classes/TrackingContext.md +0 -33
  310. package/docs/api/functions/effect.md +0 -49
  311. package/docs/api/functions/resource.md +0 -52
  312. package/docs/api/functions/resourceAsync.md +0 -50
  313. package/docs/api/functions/stream.md +0 -53
  314. package/docs/api/functions/streamAsync.md +0 -50
  315. package/docs/api/interfaces/SolidObservable.md +0 -19
  316. package/docs/api/type-aliases/FlowStreamDisposer.md +0 -15
  317. package/docs/api/type-aliases/FlowStreamSetter.md +0 -27
  318. package/docs/api/type-aliases/FlowStreamUpdater.md +0 -32
  319. package/docs/api/type-aliases/SolidGetter.md +0 -17
  320. package/docs/guide/primitives/resources.md +0 -858
  321. package/docs/guide/primitives/streams.md +0 -931
  322. package/src/flow/base/flowDisposable.ts +0 -71
  323. package/src/flow/base/flowEffect.ts +0 -171
  324. package/src/flow/base/flowGraph.ts +0 -288
  325. package/src/flow/base/flowSignal.ts +0 -207
  326. package/src/flow/base/flowTracker.ts +0 -17
  327. package/src/flow/base/index.ts +0 -6
  328. package/src/flow/base/utils.ts +0 -19
  329. package/src/flow/collections/flowArray.ts +0 -409
  330. package/src/flow/collections/flowMap.ts +0 -398
  331. package/src/flow/nodes/async/flowConstantAsync.ts +0 -142
  332. package/src/flow/nodes/async/flowDerivationAsync.ts +0 -143
  333. package/src/flow/nodes/async/flowNodeAsync.ts +0 -474
  334. package/src/flow/nodes/async/flowReadonlyAsync.ts +0 -81
  335. package/src/flow/nodes/async/flowStateAsync.ts +0 -116
  336. package/src/flow/nodes/await/advanced/index.ts +0 -5
  337. package/src/flow/nodes/await/advanced/resource.ts +0 -134
  338. package/src/flow/nodes/await/advanced/resourceAsync.ts +0 -109
  339. package/src/flow/nodes/await/advanced/stream.ts +0 -188
  340. package/src/flow/nodes/await/advanced/streamAsync.ts +0 -176
  341. package/src/flow/nodes/await/flowConstantAwait.ts +0 -154
  342. package/src/flow/nodes/await/flowDerivationAwait.ts +0 -154
  343. package/src/flow/nodes/await/flowNodeAwait.ts +0 -508
  344. package/src/flow/nodes/await/flowReadonlyAwait.ts +0 -89
  345. package/src/flow/nodes/await/flowStateAwait.ts +0 -130
  346. package/src/flow/nodes/await/index.ts +0 -5
  347. package/src/flow/nodes/index.ts +0 -3
  348. package/src/flow/nodes/sync/flowConstant.ts +0 -111
  349. package/src/flow/nodes/sync/flowDerivation.ts +0 -105
  350. package/src/flow/nodes/sync/flowNode.ts +0 -439
  351. package/src/flow/nodes/sync/flowReadonly.ts +0 -57
  352. package/src/flow/nodes/sync/flowState.ts +0 -101
  353. package/src/solid/converters.ts +0 -148
  354. package/src/solid/index.ts +0 -2
  355. package/src/solid/primitives.ts +0 -215
  356. package/test/base/flowEffect.test.ts +0 -108
  357. package/test/base/flowGraph.test.ts +0 -485
  358. package/test/base/flowSignal.test.ts +0 -372
  359. package/test/collections/flowArray.asyncStates.test.ts +0 -1553
  360. package/test/collections/flowArray.scalars.test.ts +0 -1129
  361. package/test/collections/flowArray.states.test.ts +0 -1365
  362. package/test/collections/flowMap.asyncStates.test.ts +0 -1105
  363. package/test/collections/flowMap.scalars.test.ts +0 -877
  364. package/test/collections/flowMap.states.test.ts +0 -1097
  365. package/test/nodes/async/flowConstantAsync.test.ts +0 -860
  366. package/test/nodes/async/flowDerivationAsync.test.ts +0 -1517
  367. package/test/nodes/async/flowStateAsync.test.ts +0 -1387
  368. package/test/nodes/await/advanced/resource.test.ts +0 -129
  369. package/test/nodes/await/advanced/resourceAsync.test.ts +0 -108
  370. package/test/nodes/await/advanced/stream.test.ts +0 -198
  371. package/test/nodes/await/advanced/streamAsync.test.ts +0 -196
  372. package/test/nodes/await/flowConstantAwait.test.ts +0 -643
  373. package/test/nodes/await/flowDerivationAwait.test.ts +0 -1583
  374. package/test/nodes/await/flowStateAwait.test.ts +0 -999
  375. package/test/nodes/mixed/derivation.test.ts +0 -1527
  376. package/test/nodes/sync/flowConstant.test.ts +0 -620
  377. package/test/nodes/sync/flowDerivation.test.ts +0 -1373
  378. package/test/nodes/sync/flowState.test.ts +0 -945
  379. package/test/solid/converters.test.ts +0 -721
  380. package/test/solid/primitives.test.ts +0 -1031
  381. /package/dist/types/{flow → api/nodes}/collections/index.d.ts +0 -0
  382. /package/docs/guide/advanced/{upgrading.md → migration-v1.md} +0 -0
  383. /package/src/{flow → api/nodes}/collections/index.ts +0 -0
@@ -1,343 +0,0 @@
1
- import { FlowSignal, FlowTracker } from '../../base';
2
- /**
3
- * A versatile reactive node that can operate as mutable state or computed derivation, with asynchronous values.
4
- *
5
- * @typeParam T - The type of the value held by this node (not the Promise itself).
6
- *
7
- * @remarks
8
- * FlowNodeAsync is a flexible reactive primitive that adapts its behavior based on how it's initialized.
9
- * It extends {@link FlowSignal} and provides reactive value access with automatic dependency tracking.
10
- * Unlike its synchronous counterpart {@link FlowNode}, FlowNodeAsync always works with `Promise<T>` values,
11
- * making it suitable for asynchronous computations and data fetching.
12
- *
13
- * **Operating Modes:**
14
- *
15
- * - **Mutable State Mode**: When constructed with a constant Promise, FlowNodeAsync acts as a mutable
16
- * reactive state. You can update its value using `set()`, and all dependents are automatically
17
- * notified when the value changes. The value is always a Promise that resolves to type T.
18
- *
19
- * - **Computed Derivation Mode**: When constructed with a compute function, FlowNodeAsync acts as a
20
- * computed value that automatically tracks its dependencies. The compute function runs lazily
21
- * (only when the value is first accessed) and recomputes when any tracked dependency changes.
22
- * The compute function must return a `Promise<T>`. The computed value can be temporarily overridden
23
- * using `set()`, but the override is cleared on the next recomputation (triggered by dependency changes).
24
- *
25
- * **Asynchronous Nature:**
26
- * All values in FlowNodeAsync are Promises. When you call `get()` or `pick()`, you receive a `Promise<T>`
27
- * that you must await to get the actual value. This allows for seamless integration with async/await
28
- * patterns and asynchronous data sources.
29
- *
30
- * **Lazy Computation:**
31
- * When using a compute function, the computation doesn't run immediately upon construction. It
32
- * executes only when:
33
- * - The value is first read via `get()` or `pick()`
34
- * - The node is watched via `watch()`
35
- *
36
- * **Dirty Tracking:**
37
- * When a tracked dependency changes, the node is marked as "dirty" but doesn't recompute
38
- * immediately. Recomputation happens lazily on the next value access, preventing unnecessary
39
- * computations when multiple dependencies change in quick succession. The Promise is cached until
40
- * dependencies change, ensuring efficient access patterns.
41
- *
42
- * **Dynamic Dependencies:**
43
- * Dependencies are tracked dynamically during each computation. If the compute function
44
- * conditionally tracks different observables, the dependency graph updates automatically.
45
- *
46
- * @example
47
- * ```typescript
48
- * // Mutable state mode
49
- * const $count = new FlowNodeAsync(Promise.resolve(0));
50
- * await $count.set(Promise.resolve(1)); // Updates the value
51
- *
52
- * // Computed derivation mode
53
- * const $firstName = new FlowNodeAsync(Promise.resolve('John'));
54
- * const $lastName = new FlowNodeAsync(Promise.resolve('Doe'));
55
- * const $fullName = new FlowNodeAsync(async (t) => {
56
- * const first = await $firstName.get(t);
57
- * const last = await $lastName.get(t);
58
- * return `${first} ${last}`;
59
- * });
60
- *
61
- * // Compute function hasn't run yet (lazy)
62
- * const name = await $fullName.pick(); // Now it computes: "John Doe"
63
- *
64
- * // Temporarily override computed value
65
- * await $fullName.set(Promise.resolve('Override'));
66
- * console.log(await $fullName.pick()); // "Override"
67
- *
68
- * // Trigger recomputation (clears override)
69
- * await $firstName.set(Promise.resolve('Jane'));
70
- * console.log(await $fullName.pick()); // "Jane Doe" (override cleared)
71
- * ```
72
- *
73
- * @public
74
- */
75
- export declare class FlowNodeAsync<T> extends FlowSignal {
76
- protected _promise?: Promise<T>;
77
- private _dirty;
78
- private _compute?;
79
- /**
80
- * Creates a new FlowNodeAsync.
81
- *
82
- * @param compute - Either a constant Promise or a compute function that derives the value.
83
- *
84
- * @remarks
85
- * The constructor accepts two different initialization modes:
86
- *
87
- * - **Constant Promise**: Creates a mutable reactive node that can be updated via `set()`.
88
- * The Promise is stored immediately and can be changed at any time. The Promise resolves
89
- * to the value of type T.
90
- *
91
- * - **Compute function**: Creates a computed reactive node that automatically tracks dependencies
92
- * and recomputes when they change. The compute function receives a tracking context (`t`)
93
- * that should be used to access dependencies via `.get(t)`. The function must return a
94
- * `Promise<T>`. The function is not executed immediately; it runs lazily on first access.
95
- * The computed value can be temporarily overridden using `set()`, but the override is cleared
96
- * on the next recomputation (triggered by dependency changes).
97
- *
98
- * @example
99
- * ```typescript
100
- * // Mutable state with constant Promise
101
- * const $count = new FlowNodeAsync(Promise.resolve(0));
102
- * await $count.set(Promise.resolve(5));
103
- *
104
- * // Computed derivation with async function
105
- * const $a = new FlowNodeAsync(Promise.resolve(10));
106
- * const $b = new FlowNodeAsync(Promise.resolve(20));
107
- * const $sum = new FlowNodeAsync(async (t) => {
108
- * const a = await $a.get(t);
109
- * const b = await $b.get(t);
110
- * return a + b;
111
- * });
112
- *
113
- * // Lazy evaluation - compute function hasn't run yet
114
- * console.log(await $sum.pick()); // Now it computes: 30
115
- * ```
116
- *
117
- * @public
118
- */
119
- constructor(compute: Promise<T> | ((t: FlowTracker) => Promise<T>));
120
- get settled(): Promise<T> | undefined;
121
- watch(tracker: FlowTracker): Promise<void>;
122
- /**
123
- * Gets the current value with dependency tracking.
124
- *
125
- * @param tracker - The tracking context for reactive tracking. This observable is registered
126
- * as a dependency when accessed through this method.
127
- *
128
- * @returns A Promise that resolves to the current value of type T.
129
- *
130
- * @remarks
131
- * Use `get(t)` within effects and derivations to create reactive dependencies. The tracker
132
- * parameter must be provided from the reactive context (typically the `t` parameter in effect
133
- * or derivation callbacks).
134
- *
135
- * **Important:** This method returns a `Promise<T>`, not `T`. You must await the Promise to
136
- * get the actual value. The Promise is cached until dependencies change, ensuring efficient
137
- * access patterns.
138
- *
139
- * To read a value without creating a dependency, use `pick()` instead.
140
- *
141
- * @example
142
- * ```typescript
143
- * effect(async (t) => {
144
- * const tracked = await $state.get(t); // Dependency registered, await the Promise
145
- * const untracked = await $other.pick(); // No dependency
146
- * });
147
- * ```
148
- *
149
- * @throws Error if the node has been disposed.
150
- *
151
- * @public
152
- */
153
- get(tracker: FlowTracker | null): Promise<T>;
154
- /**
155
- * Updates the node with a new value.
156
- *
157
- * @param value - A new Promise or a callback function that computes a new Promise based on the current value.
158
- *
159
- * @returns A promise that resolves after the update is processed and all dependent effects have been notified.
160
- *
161
- * @remarks
162
- * This method can be used in two ways:
163
- *
164
- * **For mutable state nodes** (constructed with a constant Promise):
165
- * - Updates the stored Promise directly
166
- * - All dependents are notified of the change
167
- *
168
- * **For computed nodes** (constructed with a compute function):
169
- * - Temporarily overrides the computed value
170
- * - The override persists until the next recomputation, which occurs when:
171
- * - A tracked dependency changes, or
172
- * - The node is refreshed
173
- * - This allows temporarily overriding computed values for testing or manual control
174
- *
175
- * **Value Comparison:**
176
- * The Promises are resolved and their values are compared. If the resolved new value is strictly
177
- * equal (`===`) to the current resolved value, no update occurs and subscribers are not notified.
178
- * This prevents unnecessary re-renders and effect executions.
179
- *
180
- * **Asynchronous Processing:**
181
- * The update is processed asynchronously through the reactive graph, ensuring proper
182
- * ordering of updates and effect execution. The method returns a Promise that resolves
183
- * after the update is complete.
184
- *
185
- * @throws Error if the node has been disposed.
186
- *
187
- * @example
188
- * ```typescript
189
- * // Mutable state usage
190
- * const $count = new FlowNodeAsync(Promise.resolve(0));
191
- * await $count.set(Promise.resolve(5));
192
- * await $count.set(async (current) => Promise.resolve(current + 1)); // 6
193
- *
194
- * // Temporary override of computed value
195
- * const $source = new FlowNodeAsync(Promise.resolve(10));
196
- * const $doubled = new FlowNodeAsync(async (t) => {
197
- * const val = await $source.get(t);
198
- * return val * 2;
199
- * });
200
- *
201
- * console.log(await $doubled.pick()); // 20
202
- *
203
- * // Temporarily override
204
- * await $doubled.set(Promise.resolve(50));
205
- * console.log(await $doubled.pick()); // 50 (override active)
206
- *
207
- * // Dependency change clears override
208
- * await $source.set(Promise.resolve(15));
209
- * console.log(await $doubled.pick()); // 30 (recomputed, override cleared)
210
- * ```
211
- *
212
- * @public
213
- */
214
- set(value: Promise<T> | ((current: T) => Promise<T>)): Promise<void>;
215
- /**
216
- * Forces recomputation of the value, even if it's not marked as dirty.
217
- *
218
- * @returns A promise that resolves after the recomputation is complete and all
219
- * dependent effects have been notified.
220
- *
221
- * @remarks
222
- * This method is useful when you need to force a recomputation of a computed value,
223
- * for example when the computation depends on external data that has changed outside
224
- * the reactive system.
225
- *
226
- * **Behavior:**
227
- * - For nodes with a compute function: Forces the compute function to run again,
228
- * even if no dependencies have changed. This effectively clears any temporary
229
- * override that was set using `set()`.
230
- * - For nodes without a compute function (mutable state): Recomputes the current
231
- * value (which is just the stored value), useful for consistency but typically
232
- * not necessary.
233
- *
234
- * The recomputation happens asynchronously through the reactive graph, ensuring
235
- * proper ordering of updates and effect execution.
236
- *
237
- * @throws Error if the node has been disposed.
238
- *
239
- * @example
240
- * ```typescript
241
- * const $externalData = new FlowNode(() => fetchExternalData());
242
- *
243
- * // Some external event occurs that changes the data source
244
- * externalDataChanged();
245
- *
246
- * // Force recomputation to get the new value
247
- * await $externalData.refresh();
248
- *
249
- * // For computed nodes with temporary overrides
250
- * const $computed = new FlowNode((t) => $source.get(t) * 2);
251
- * $computed.set(100); // Temporary override
252
- * await $computed.refresh(); // Clears override, recomputes from source
253
- * ```
254
- *
255
- * @public
256
- */
257
- refresh(): Promise<void>;
258
- /**
259
- * Gets the current value without any dependency tracking.
260
- *
261
- * @returns A promise that resolves with the current value of type T.
262
- *
263
- * @remarks
264
- * This method reads the value asynchronously through the reactive graph, ensuring proper ordering of
265
- * read operations. Unlike `get(t)`, this method does not create a reactive dependency.
266
- *
267
- * **Important:** This is an async method that returns `Promise<T>`. Always use `await` when calling it.
268
- *
269
- * Use `pick()` when you want to read a snapshot of the current value without creating a reactive
270
- * dependency. This is useful for:
271
- * - Reading initial values outside reactive contexts
272
- * - Accessing configuration that shouldn't trigger updates
273
- * - Mixing tracked and untracked reads in the same effect
274
- *
275
- * @example
276
- * ```typescript
277
- * // Read a snapshot outside reactive context
278
- * const currentValue = await $state.pick();
279
- *
280
- * // Mix tracked and untracked reads
281
- * effect(async (t) => {
282
- * const tracked = await $reactive.get(t); // Triggers re-runs
283
- * const snapshot = await $config.pick(); // Doesn't trigger re-runs
284
- * processData(tracked, snapshot);
285
- * });
286
- * ```
287
- *
288
- * @throws Error if the node has been disposed.
289
- *
290
- * @public
291
- */
292
- pick(): Promise<T>;
293
- /**
294
- * Subscribes a listener function to changes of this node.
295
- *
296
- * @param listener - A callback function that receives the new value whenever it changes.
297
- *
298
- * @returns A disposer function that cancels the subscription when called.
299
- *
300
- * @remarks
301
- * This method creates a reactive subscription that automatically tracks this node as a dependency.
302
- * The listener is executed:
303
- * - Immediately with the current value when the subscription is created
304
- * - Automatically whenever the value changes
305
- *
306
- * **Important:** The listener receives a `Promise<T>`, not `T`. You must await the Promise
307
- * within the listener to access the actual value. The Promise is the same one returned by `get()`,
308
- * so it's cached until dependencies change.
309
- *
310
- * The subscription uses a {@link FlowEffect} internally to manage the reactive tracking and
311
- * automatic re-execution. When the value changes, the listener is called with the new Promise
312
- * after the update is processed through the reactive graph.
313
- *
314
- * **Cleanup:**
315
- * Always call the returned disposer function when you no longer need the subscription to
316
- * prevent memory leaks and unnecessary computations.
317
- *
318
- * @example
319
- * ```typescript
320
- * const $count = new FlowNodeAsync(Promise.resolve(0));
321
- *
322
- * // Subscribe to changes
323
- * const unsubscribe = $count.subscribe(async (valuePromise) => {
324
- * const value = await valuePromise;
325
- * console.log(`Count is now: ${value}`);
326
- * });
327
- * // Logs immediately: "Count is now: 0"
328
- *
329
- * await $count.set(Promise.resolve(5));
330
- * // Logs: "Count is now: 5"
331
- *
332
- * // Clean up when done
333
- * unsubscribe();
334
- * ```
335
- *
336
- * @throws Error if the node has been disposed.
337
- *
338
- * @public
339
- */
340
- subscribe(listener: (value: Promise<T>) => void): () => void;
341
- private _computeValue;
342
- }
343
- //# sourceMappingURL=flowNodeAsync.d.ts.map
@@ -1 +0,0 @@
1
- {"version":3,"file":"flowNodeAsync.d.ts","sourceRoot":"","sources":["../../../../../src/flow/nodes/async/flowNodeAsync.ts"],"names":[],"mappings":"AAAA,OAAO,EAGN,UAAU,EACV,KAAK,WAAW,EAChB,MAAM,YAAY,CAAC;AAEpB;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;GAwEG;AACH,qBAAa,aAAa,CAAC,CAAC,CAAE,SAAQ,UAAU;IAC/C,SAAS,CAAC,QAAQ,CAAC,EAAE,OAAO,CAAC,CAAC,CAAC,CAAC;IAChC,OAAO,CAAC,MAAM,CAAQ;IACtB,OAAO,CAAC,QAAQ,CAAC,CAAiC;IAElD;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;OAuCG;gBACS,OAAO,EAAE,OAAO,CAAC,CAAC,CAAC,GAAG,CAAC,CAAC,CAAC,EAAE,WAAW,KAAK,OAAO,CAAC,CAAC,CAAC,CAAC;IAUlE,IAAI,OAAO,2BAEV;IAEc,KAAK,CAAC,OAAO,EAAE,WAAW,GAAG,OAAO,CAAC,IAAI,CAAC;IAOzD;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;OA8BG;IACG,GAAG,CAAC,OAAO,EAAE,WAAW,GAAG,IAAI,GAAG,OAAO,CAAC,CAAC,CAAC;IAOlD;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;OA2DG;IACG,GAAG,CAAC,KAAK,EAAE,OAAO,CAAC,CAAC,CAAC,GAAG,CAAC,CAAC,OAAO,EAAE,CAAC,KAAK,OAAO,CAAC,CAAC,CAAC,CAAC,GAAG,OAAO,CAAC,IAAI,CAAC;IA4B1E;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;OAyCG;IACG,OAAO,IAAI,OAAO,CAAC,IAAI,CAAC;IAwB9B;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;OAiCG;IACG,IAAI,IAAI,OAAO,CAAC,CAAC,CAAC;IAMxB;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;OA8CG;IACH,SAAS,CAAC,QAAQ,EAAE,CAAC,KAAK,EAAE,OAAO,CAAC,CAAC,CAAC,KAAK,IAAI,GAAG,MAAM,IAAI;YAkB9C,aAAa;CA8B3B"}
@@ -1,81 +0,0 @@
1
- import { FlowNodeAsync } from './flowNodeAsync';
2
- /**
3
- * A generic utility type for creating read-only views of reactive nodes, with asynchronous values.
4
- *
5
- * @typeParam T - The type of the value held by the reactive node (not the Promise itself).
6
- *
7
- * @remarks
8
- * `FlowReadonlyAsync` is a type alias based on {@link FlowNodeAsync} with the `set()` and `refresh()`
9
- * methods removed, making it a read-only view. It provides all the reactive capabilities of `FlowNodeAsync`
10
- * (dependency tracking, lazy computation, caching, reading values) but prevents mutation.
11
- *
12
- * **Asynchronous Nature:**
13
- * All values in FlowReadonlyAsync are Promises. When you call `get()` or `pick()`, you receive a
14
- * `Promise<T>` that you must await to get the actual value. This allows for seamless integration
15
- * with async/await patterns and asynchronous data sources.
16
- *
17
- * **Difference from FlowConstantAsync and FlowDerivationAsync:**
18
- * - {@link FlowConstantAsync}: Specialized type for immutable constants that compute once and never change
19
- * - {@link FlowDerivationAsync}: Specialized type for computed values that automatically recompute when dependencies change
20
- * - `FlowReadonlyAsync`: Generic utility type that can be used with any `FlowNodeAsync` to create a read-only view
21
- *
22
- * **Use Cases:**
23
- * - **Type Safety**: Ensure functions don't accidentally mutate state by accepting `FlowReadonlyAsync` instead of `FlowStateAsync`
24
- * - **API Design**: Expose read-only views of internal state to prevent external mutation
25
- * - **Function Parameters**: Accept any reactive node (state, derivation, constant) but prevent mutation
26
- * - **Composition**: Create read-only wrappers around mutable states for safer sharing
27
- *
28
- * @example
29
- * ```typescript
30
- * // Type safety: Function that only reads state
31
- * function displayCount(count: FlowReadonlyAsync<number>) {
32
- * // count.set(Promise.resolve(100)); // TypeScript error: Property 'set' does not exist
33
- * effect(async (t) => {
34
- * const value = await count.get(t); // OK: Reading is allowed
35
- * console.log(value);
36
- * });
37
- * }
38
- *
39
- * const $count = stateAsync(Promise.resolve(0));
40
- * displayCount($count); // OK: FlowStateAsync is assignable to FlowReadonlyAsync
41
- *
42
- * // API design: Expose read-only view
43
- * class Counter {
44
- * private _count = stateAsync(Promise.resolve(0));
45
- *
46
- * get count(): FlowReadonlyAsync<number> {
47
- * return this._count; // FlowStateAsync is assignable to FlowReadonlyAsync
48
- * }
49
- *
50
- * async increment() {
51
- * await this._count.set(async (current) => Promise.resolve(current + 1)); // Internal mutation allowed
52
- * }
53
- * }
54
- *
55
- * const counter = new Counter();
56
- * // counter.count.set(Promise.resolve(100)); // TypeScript error: Cannot mutate read-only view
57
- * const current = await counter.count.pick(); // OK: Reading is allowed
58
- *
59
- * // Works with derivations too
60
- * const $firstName = stateAsync(Promise.resolve('John'));
61
- * const $lastName = stateAsync(Promise.resolve('Doe'));
62
- * const $fullName = derivationAsync(async (t) => {
63
- * const first = await $firstName.get(t);
64
- * const last = await $lastName.get(t);
65
- * return `${first} ${last}`;
66
- * });
67
- *
68
- * function displayName(name: FlowReadonlyAsync<string>) {
69
- * effect(async (t) => {
70
- * const fullName = await name.get(t);
71
- * console.log(fullName);
72
- * });
73
- * }
74
- *
75
- * displayName($fullName); // OK: FlowDerivationAsync is assignable to FlowReadonlyAsync
76
- * ```
77
- *
78
- * @public
79
- */
80
- export type FlowReadonlyAsync<T> = Omit<FlowNodeAsync<T>, "set" | "refresh">;
81
- //# sourceMappingURL=flowReadonlyAsync.d.ts.map
@@ -1 +0,0 @@
1
- {"version":3,"file":"flowReadonlyAsync.d.ts","sourceRoot":"","sources":["../../../../../src/flow/nodes/async/flowReadonlyAsync.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,aAAa,EAAE,MAAM,iBAAiB,CAAC;AAErD;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;GA6EG;AACH,MAAM,MAAM,iBAAiB,CAAC,CAAC,IAAI,IAAI,CAAC,aAAa,CAAC,CAAC,CAAC,EAAE,KAAK,GAAG,SAAS,CAAC,CAAC"}
@@ -1,111 +0,0 @@
1
- import { FlowNodeAsync } from './flowNodeAsync';
2
- /**
3
- * Represents a reactive state that holds a mutable value, with asynchronous values.
4
- *
5
- * @typeParam T - The type of the state value (not the Promise itself).
6
- *
7
- * @remarks
8
- * `FlowStateAsync` is a type alias of {@link FlowNodeAsync}, providing a mutable reactive state that can be
9
- * updated using the `set()` method. It provides all the reactive capabilities of `FlowNodeAsync`
10
- * (lazy computation, caching) with the ability to mutate the value.
11
- *
12
- * Unlike {@link FlowConstantAsync}, which is immutable and computes once, states can be updated at any
13
- * time. Unlike {@link FlowDerivationAsync}, which recomputes when dependencies change, states are
14
- * updated explicitly via `set()`.
15
- *
16
- * **Asynchronous Nature:**
17
- * All values in FlowStateAsync are Promises. When you call `get()` or `pick()`, you receive a
18
- * `Promise<T>` that you must await to get the actual value. The `set()` method returns `Promise<void>`
19
- * and must be awaited. This allows for seamless integration with async/await patterns and asynchronous
20
- * data sources.
21
- *
22
- * **Reading Values:**
23
- * You can read the state value using `get(t)` for tracked access (creates reactive dependency)
24
- * or `pick()` for untracked access (reads without creating dependency). Both methods return `Promise<T>`
25
- * that must be awaited.
26
- *
27
- * **Updating Values:**
28
- * When the state is updated with a new value that differs from the current value (strict equality),
29
- * all dependent effects and derivations are automatically notified and re-executed. If the new value
30
- * is strictly equal to the current value, no notification occurs. The `set()` method accepts either
31
- * a `Promise<T>` or a function `(current: T) => Promise<T>` and returns `Promise<void>`.
32
- *
33
- * @example
34
- * ```typescript
35
- * const $count = stateAsync(Promise.resolve(0));
36
- *
37
- * // Read with tracking
38
- * effect(async (t) => {
39
- * const value = await $count.get(t); // Effect re-runs when $count changes
40
- * console.log(value);
41
- * });
42
- *
43
- * // Read without tracking
44
- * const snapshot = await $count.pick();
45
- *
46
- * // Update the value
47
- * await $count.set(Promise.resolve(1));
48
- * await $count.set(async (current) => Promise.resolve(current + 1));
49
- * ```
50
- *
51
- * @public
52
- */
53
- export type FlowStateAsync<T> = Omit<FlowNodeAsync<T>, "refresh">;
54
- /**
55
- * Creates a new reactive state holding a mutable value.
56
- *
57
- * @typeParam T - The type of the state value (not the Promise itself).
58
- *
59
- * @param value - The initial value for the state, or a function that returns the initial value.
60
- * If a function is provided, it is called lazily only when the value is first accessed via
61
- * `get()` or `pick()`. If a direct Promise is provided, it is stored immediately.
62
- *
63
- * @returns A new instance of {@link FlowStateAsync} that provides reactive access to the mutable value.
64
- *
65
- * @remarks
66
- * State is the most common reactive primitive - a mutable container that notifies dependents
67
- * when its value changes. Use `set()` to update the value (returns `Promise<void>`) and `get(t)`
68
- * or `pick()` to read it (both return `Promise<T>`).
69
- *
70
- * **Asynchronous Nature:**
71
- * All values are Promises. When you access the state via `get(t)` or `pick()`, you receive a
72
- * `Promise<T>` that you must await to get the actual value. The `set()` method also returns
73
- * `Promise<void>` and must be awaited. This allows for seamless integration with async/await
74
- * patterns and asynchronous data sources.
75
- *
76
- * **Lazy Initialization:**
77
- * When a function is provided, the initialization is lazy - the function is not called immediately
78
- * upon creation. It executes only when:
79
- * - The value is first read via `get(t)` or `pick()`
80
- * - The state is watched via `watch()`
81
- *
82
- * This is useful for expensive async initializations that may not be needed immediately.
83
- *
84
- * **When to Use States:**
85
- * - Use `stateAsync()` for mutable values that can be updated directly
86
- * - Use `constantAsync()` for values that compute once and never change
87
- * - Use `derivationAsync()` for values that recompute when dependencies change
88
- *
89
- * @example
90
- * ```typescript
91
- * // Direct Promise - initialized immediately
92
- * const $count = stateAsync(Promise.resolve(0));
93
- *
94
- * // Lazy initialization - computed on first access
95
- * const $config = stateAsync(async () => {
96
- * return await loadConfiguration();
97
- * });
98
- *
99
- * effect(async (t) => {
100
- * const value = await $count.get(t);
101
- * console.log(value);
102
- * });
103
- *
104
- * await $count.set(Promise.resolve(1)); // Logs: 1
105
- * await $count.set(async (current) => Promise.resolve(current + 1)); // Logs: 2
106
- * ```
107
- *
108
- * @public
109
- */
110
- export declare function stateAsync<T>(value: Promise<T> | (() => Promise<T>)): FlowStateAsync<T>;
111
- //# sourceMappingURL=flowStateAsync.d.ts.map
@@ -1 +0,0 @@
1
- {"version":3,"file":"flowStateAsync.d.ts","sourceRoot":"","sources":["../../../../../src/flow/nodes/async/flowStateAsync.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,aAAa,EAAE,MAAM,iBAAiB,CAAC;AAEhD;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;GAkDG;AACH,MAAM,MAAM,cAAc,CAAC,CAAC,IAAI,IAAI,CAAC,aAAa,CAAC,CAAC,CAAC,EAAE,SAAS,CAAC,CAAC;AAElE;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;GAuDG;AACH,wBAAgB,UAAU,CAAC,CAAC,EAC3B,KAAK,EAAE,OAAO,CAAC,CAAC,CAAC,GAAG,CAAC,MAAM,OAAO,CAAC,CAAC,CAAC,CAAC,GACpC,cAAc,CAAC,CAAC,CAAC,CAEnB"}
@@ -1 +0,0 @@
1
- {"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../../../../src/flow/nodes/async/index.ts"],"names":[],"mappings":"AAAA,cAAc,qBAAqB,CAAC;AACpC,cAAc,uBAAuB,CAAC;AACtC,cAAc,iBAAiB,CAAC;AAChC,cAAc,qBAAqB,CAAC;AACpC,cAAc,kBAAkB,CAAC"}
@@ -1,3 +0,0 @@
1
- export * from './async';
2
- export * from './sync';
3
- //# sourceMappingURL=index.d.ts.map
@@ -1 +0,0 @@
1
- {"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../../../src/flow/nodes/index.ts"],"names":[],"mappings":"AAAA,cAAc,SAAS,CAAC;AACxB,cAAc,QAAQ,CAAC"}
@@ -1,108 +0,0 @@
1
- import { NotPromise } from '../../base';
2
- import { FlowNode } from './flowNode';
3
- /**
4
- * Represents a constant value that can be computed lazily upon first access.
5
- *
6
- * @typeParam T - The type of the constant value.
7
- *
8
- * @remarks
9
- * `FlowConstant` is a type alias based on {@link FlowNode} with the `set()` method removed,
10
- * making it immutable. It provides all the reactive capabilities of `FlowNode` (
11
- * lazy computation, caching) but prevents value mutation after initialization.
12
- *
13
- * Unlike {@link FlowState}, which is mutable via the `set()` method, a constant's value never
14
- * changes after it's computed. This makes it ideal for values that should remain stable throughout
15
- * the application lifecycle.
16
- *
17
- * **Lazy Computation:**
18
- * Constants are created using the `constant()` factory function, which accepts a compute function.
19
- * The computation doesn't run immediately upon creation. It executes only when:
20
- * - The value is first read via `get()` or `pick()`
21
- * - The constant is watched via `watch()`
22
- * This allows you to defer expensive computations until they're actually needed.
23
- *
24
- * **Caching:**
25
- * Once computed, the value is cached permanently. All subsequent accesses return the cached value
26
- * without re-computation, ensuring the value remains constant and the computation runs only once.
27
- *
28
- * **Use Cases:**
29
- * - Configuration values that don't change
30
- * - Expensive computations that should only run once
31
- * - Initialization values for other reactive primitives
32
- * - Values derived from external sources that shouldn't be modified
33
- *
34
- * @example
35
- * ```typescript
36
- * // Lazy initialization - computed on first access
37
- * const $expensiveValue = constant(() => {
38
- * return performExpensiveCalculation();
39
- * });
40
- *
41
- * // First access triggers computation
42
- * const value1 = await $expensiveValue.pick();
43
- *
44
- * // Subsequent accesses return cached value
45
- * const value2 = await $expensiveValue.pick();
46
- *
47
- * // Value cannot be changed (set() method is not available)
48
- * // $expensiveValue.set(100); // TypeScript error: Property 'set' does not exist
49
- * ```
50
- *
51
- * @public
52
- */
53
- export type FlowConstant<T> = Omit<FlowNode<T>, "set" | "refresh">;
54
- /**
55
- * Creates a new reactive constant with lazy initialization.
56
- *
57
- * @typeParam T - The type of the constant value.
58
- *
59
- * @param value - A function that computes the constant value. This function is called lazily
60
- * only when the value is first accessed via `get()` or `pick()`.
61
- *
62
- * @returns A new instance of {@link FlowConstant} that provides reactive access to the computed value.
63
- *
64
- * @remarks
65
- * Constants are immutable reactive values that are computed once and cached permanently. Unlike
66
- * states (created with `state()`), constants cannot be modified after initialization - they don't
67
- * have a `set()` method.
68
- *
69
- * **Lazy Computation:**
70
- * The compute function is not executed immediately upon creation. It runs only when:
71
- * - The value is first read via `get(t)` or `pick()`
72
- * - The constant is watched via `watch()`
73
- *
74
- * This lazy computation is useful for:
75
- * - Expensive computations that may not be needed immediately
76
- * - Values that depend on resources not available at construction time
77
- * - Deferring computation until the value is actually needed
78
- *
79
- * **When to Use Constants:**
80
- * - Use `constant()` for values that should never change after initialization
81
- * - Use `state()` for mutable values that can be updated
82
- * - Use `derivation()` for values that recompute when dependencies change
83
- *
84
- * @example
85
- * ```typescript
86
- * // Expensive computation that runs only once
87
- * const $config = constant(() => {
88
- * return loadConfigurationFromFile();
89
- * });
90
- *
91
- * // Computation hasn't run yet
92
- * // First access triggers it
93
- * const config = await $config.pick();
94
- *
95
- * // Subsequent accesses return cached value
96
- * const config2 = await $config.pick();
97
- *
98
- * // Use in reactive context
99
- * effect((t) => {
100
- * const cfg = $config.get(t);
101
- * console.log(`API URL: ${cfg.apiUrl}`);
102
- * });
103
- * ```
104
- *
105
- * @public
106
- */
107
- export declare function constant<T>(value: () => NotPromise<T>): FlowConstant<T>;
108
- //# sourceMappingURL=flowConstant.d.ts.map
@@ -1 +0,0 @@
1
- {"version":3,"file":"flowConstant.d.ts","sourceRoot":"","sources":["../../../../../src/flow/nodes/sync/flowConstant.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,UAAU,EAAE,MAAM,YAAY,CAAC;AAC7C,OAAO,EAAE,QAAQ,EAAE,MAAM,YAAY,CAAC;AAEtC;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;GAiDG;AACH,MAAM,MAAM,YAAY,CAAC,CAAC,IAAI,IAAI,CAAC,QAAQ,CAAC,CAAC,CAAC,EAAE,KAAK,GAAG,SAAS,CAAC,CAAC;AAEnE;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;GAoDG;AACH,wBAAgB,QAAQ,CAAC,CAAC,EAAE,KAAK,EAAE,MAAM,UAAU,CAAC,CAAC,CAAC,GAAG,YAAY,CAAC,CAAC,CAAC,CAEvE"}