@callable-recharge/callbag-recharge 0.1.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 (452) hide show
  1. package/README.md +259 -0
  2. package/dist/backoff-BXsH2Ago.d.cts +25 -0
  3. package/dist/backoff-BXsH2Ago.d.ts +25 -0
  4. package/dist/chunk-2BINVZ33.js +2 -0
  5. package/dist/chunk-2BINVZ33.js.map +1 -0
  6. package/dist/chunk-2E3ALULW.js +2 -0
  7. package/dist/chunk-2E3ALULW.js.map +1 -0
  8. package/dist/chunk-2IM76CX3.js +2 -0
  9. package/dist/chunk-2IM76CX3.js.map +1 -0
  10. package/dist/chunk-2KKEBHMR.js +2 -0
  11. package/dist/chunk-2KKEBHMR.js.map +1 -0
  12. package/dist/chunk-2P6G236K.js +2 -0
  13. package/dist/chunk-2P6G236K.js.map +1 -0
  14. package/dist/chunk-4AANJADQ.js +2 -0
  15. package/dist/chunk-4AANJADQ.js.map +1 -0
  16. package/dist/chunk-4WFD6EA7.js +2 -0
  17. package/dist/chunk-4WFD6EA7.js.map +1 -0
  18. package/dist/chunk-52WEI2L4.js +2 -0
  19. package/dist/chunk-52WEI2L4.js.map +1 -0
  20. package/dist/chunk-52YSBIVX.js +2 -0
  21. package/dist/chunk-52YSBIVX.js.map +1 -0
  22. package/dist/chunk-5PJCNPKY.js +2 -0
  23. package/dist/chunk-5PJCNPKY.js.map +1 -0
  24. package/dist/chunk-6YHJJXF4.js +2 -0
  25. package/dist/chunk-6YHJJXF4.js.map +1 -0
  26. package/dist/chunk-7CQ6XF2G.js +2 -0
  27. package/dist/chunk-7CQ6XF2G.js.map +1 -0
  28. package/dist/chunk-7WTS4C5R.js +3 -0
  29. package/dist/chunk-7WTS4C5R.js.map +1 -0
  30. package/dist/chunk-A6BNAR7H.js +2 -0
  31. package/dist/chunk-A6BNAR7H.js.map +1 -0
  32. package/dist/chunk-BNY43SC2.js +2 -0
  33. package/dist/chunk-BNY43SC2.js.map +1 -0
  34. package/dist/chunk-C2BNB3CS.js +2 -0
  35. package/dist/chunk-C2BNB3CS.js.map +1 -0
  36. package/dist/chunk-COAIGQ25.js +2 -0
  37. package/dist/chunk-COAIGQ25.js.map +1 -0
  38. package/dist/chunk-DBAHFYN4.js +2 -0
  39. package/dist/chunk-DBAHFYN4.js.map +1 -0
  40. package/dist/chunk-E63D25PW.js +1 -0
  41. package/dist/chunk-E63D25PW.js.map +1 -0
  42. package/dist/chunk-E6EZEFS5.js +2 -0
  43. package/dist/chunk-E6EZEFS5.js.map +1 -0
  44. package/dist/chunk-EMNGVHNM.js +2 -0
  45. package/dist/chunk-EMNGVHNM.js.map +1 -0
  46. package/dist/chunk-F356J323.js +2 -0
  47. package/dist/chunk-F356J323.js.map +1 -0
  48. package/dist/chunk-HKDBOVSA.js +2 -0
  49. package/dist/chunk-HKDBOVSA.js.map +1 -0
  50. package/dist/chunk-IJNZ5GDS.js +2 -0
  51. package/dist/chunk-IJNZ5GDS.js.map +1 -0
  52. package/dist/chunk-IQUXZNBK.js +2 -0
  53. package/dist/chunk-IQUXZNBK.js.map +1 -0
  54. package/dist/chunk-IUHESEXZ.js +2 -0
  55. package/dist/chunk-IUHESEXZ.js.map +1 -0
  56. package/dist/chunk-IZ5GFMMK.js +2 -0
  57. package/dist/chunk-IZ5GFMMK.js.map +1 -0
  58. package/dist/chunk-JCITTHWJ.js +2 -0
  59. package/dist/chunk-JCITTHWJ.js.map +1 -0
  60. package/dist/chunk-JS2FB4B3.js +2 -0
  61. package/dist/chunk-JS2FB4B3.js.map +1 -0
  62. package/dist/chunk-K7VPCAZD.js +2 -0
  63. package/dist/chunk-K7VPCAZD.js.map +1 -0
  64. package/dist/chunk-KDB2NMLA.js +2 -0
  65. package/dist/chunk-KDB2NMLA.js.map +1 -0
  66. package/dist/chunk-LHEWNZ3X.js +2 -0
  67. package/dist/chunk-LHEWNZ3X.js.map +1 -0
  68. package/dist/chunk-LM26JNAK.js +2 -0
  69. package/dist/chunk-LM26JNAK.js.map +1 -0
  70. package/dist/chunk-M6ZEDHQT.js +2 -0
  71. package/dist/chunk-M6ZEDHQT.js.map +1 -0
  72. package/dist/chunk-MJB2RHP4.js +2 -0
  73. package/dist/chunk-MJB2RHP4.js.map +1 -0
  74. package/dist/chunk-MKQEMUUJ.js +2 -0
  75. package/dist/chunk-MKQEMUUJ.js.map +1 -0
  76. package/dist/chunk-MVAQ5TH7.js +2 -0
  77. package/dist/chunk-MVAQ5TH7.js.map +1 -0
  78. package/dist/chunk-NEUWMVR4.js +2 -0
  79. package/dist/chunk-NEUWMVR4.js.map +1 -0
  80. package/dist/chunk-NSJJXMWD.js +2 -0
  81. package/dist/chunk-NSJJXMWD.js.map +1 -0
  82. package/dist/chunk-NUVYBG4B.js +2 -0
  83. package/dist/chunk-NUVYBG4B.js.map +1 -0
  84. package/dist/chunk-O5WOX6C7.js +2 -0
  85. package/dist/chunk-O5WOX6C7.js.map +1 -0
  86. package/dist/chunk-O7ITRRPK.js +2 -0
  87. package/dist/chunk-O7ITRRPK.js.map +1 -0
  88. package/dist/chunk-OHGZIPRU.js +2 -0
  89. package/dist/chunk-OHGZIPRU.js.map +1 -0
  90. package/dist/chunk-PXF7567W.js +2 -0
  91. package/dist/chunk-PXF7567W.js.map +1 -0
  92. package/dist/chunk-PYRVYHZG.js +2 -0
  93. package/dist/chunk-PYRVYHZG.js.map +1 -0
  94. package/dist/chunk-QECUTAQY.js +2 -0
  95. package/dist/chunk-QECUTAQY.js.map +1 -0
  96. package/dist/chunk-QPY7RRUK.js +2 -0
  97. package/dist/chunk-QPY7RRUK.js.map +1 -0
  98. package/dist/chunk-QYUTDL4D.js +2 -0
  99. package/dist/chunk-QYUTDL4D.js.map +1 -0
  100. package/dist/chunk-UEA4RIP5.js +2 -0
  101. package/dist/chunk-UEA4RIP5.js.map +1 -0
  102. package/dist/chunk-UHUNMZJO.js +2 -0
  103. package/dist/chunk-UHUNMZJO.js.map +1 -0
  104. package/dist/chunk-W5MQVYXW.js +2 -0
  105. package/dist/chunk-W5MQVYXW.js.map +1 -0
  106. package/dist/chunk-WHAGQ74D.js +2 -0
  107. package/dist/chunk-WHAGQ74D.js.map +1 -0
  108. package/dist/chunk-WRNNR3U5.js +2 -0
  109. package/dist/chunk-WRNNR3U5.js.map +1 -0
  110. package/dist/chunk-X6UCLV7L.js +2 -0
  111. package/dist/chunk-X6UCLV7L.js.map +1 -0
  112. package/dist/chunk-XHUZ4TRE.js +2 -0
  113. package/dist/chunk-XHUZ4TRE.js.map +1 -0
  114. package/dist/chunk-XISWBEKL.js +2 -0
  115. package/dist/chunk-XISWBEKL.js.map +1 -0
  116. package/dist/chunk-YCL7NHHW.js +2 -0
  117. package/dist/chunk-YCL7NHHW.js.map +1 -0
  118. package/dist/chunk-YMOLNCDC.js +2 -0
  119. package/dist/chunk-YMOLNCDC.js.map +1 -0
  120. package/dist/chunk-ZRKP6HCI.js +2 -0
  121. package/dist/chunk-ZRKP6HCI.js.map +1 -0
  122. package/dist/data/index.cjs +3 -0
  123. package/dist/data/index.cjs.map +1 -0
  124. package/dist/data/index.d.cts +32 -0
  125. package/dist/data/index.d.ts +32 -0
  126. package/dist/data/index.js +2 -0
  127. package/dist/data/index.js.map +1 -0
  128. package/dist/eviction-DGPP1vHP.d.cts +21 -0
  129. package/dist/eviction-DGPP1vHP.d.ts +21 -0
  130. package/dist/extra/buffer.cjs +3 -0
  131. package/dist/extra/buffer.cjs.map +1 -0
  132. package/dist/extra/buffer.d.cts +21 -0
  133. package/dist/extra/buffer.d.ts +21 -0
  134. package/dist/extra/buffer.js +2 -0
  135. package/dist/extra/buffer.js.map +1 -0
  136. package/dist/extra/bufferTime.cjs +3 -0
  137. package/dist/extra/bufferTime.cjs.map +1 -0
  138. package/dist/extra/bufferTime.d.cts +15 -0
  139. package/dist/extra/bufferTime.d.ts +15 -0
  140. package/dist/extra/bufferTime.js +2 -0
  141. package/dist/extra/bufferTime.js.map +1 -0
  142. package/dist/extra/combine.cjs +3 -0
  143. package/dist/extra/combine.cjs.map +1 -0
  144. package/dist/extra/combine.d.cts +19 -0
  145. package/dist/extra/combine.d.ts +19 -0
  146. package/dist/extra/combine.js +2 -0
  147. package/dist/extra/combine.js.map +1 -0
  148. package/dist/extra/concat.cjs +3 -0
  149. package/dist/extra/concat.cjs.map +1 -0
  150. package/dist/extra/concat.d.cts +18 -0
  151. package/dist/extra/concat.d.ts +18 -0
  152. package/dist/extra/concat.js +2 -0
  153. package/dist/extra/concat.js.map +1 -0
  154. package/dist/extra/concatMap.cjs +3 -0
  155. package/dist/extra/concatMap.cjs.map +1 -0
  156. package/dist/extra/concatMap.d.cts +25 -0
  157. package/dist/extra/concatMap.d.ts +25 -0
  158. package/dist/extra/concatMap.js +2 -0
  159. package/dist/extra/concatMap.js.map +1 -0
  160. package/dist/extra/debounce.cjs +3 -0
  161. package/dist/extra/debounce.cjs.map +1 -0
  162. package/dist/extra/debounce.d.cts +17 -0
  163. package/dist/extra/debounce.d.ts +17 -0
  164. package/dist/extra/debounce.js +2 -0
  165. package/dist/extra/debounce.js.map +1 -0
  166. package/dist/extra/delay.cjs +3 -0
  167. package/dist/extra/delay.cjs.map +1 -0
  168. package/dist/extra/delay.d.cts +15 -0
  169. package/dist/extra/delay.d.ts +15 -0
  170. package/dist/extra/delay.js +2 -0
  171. package/dist/extra/delay.js.map +1 -0
  172. package/dist/extra/distinctUntilChanged.cjs +3 -0
  173. package/dist/extra/distinctUntilChanged.cjs.map +1 -0
  174. package/dist/extra/distinctUntilChanged.d.cts +16 -0
  175. package/dist/extra/distinctUntilChanged.d.ts +16 -0
  176. package/dist/extra/distinctUntilChanged.js +2 -0
  177. package/dist/extra/distinctUntilChanged.js.map +1 -0
  178. package/dist/extra/elementAt.cjs +3 -0
  179. package/dist/extra/elementAt.cjs.map +1 -0
  180. package/dist/extra/elementAt.d.cts +17 -0
  181. package/dist/extra/elementAt.d.ts +17 -0
  182. package/dist/extra/elementAt.js +2 -0
  183. package/dist/extra/elementAt.js.map +1 -0
  184. package/dist/extra/empty.cjs +3 -0
  185. package/dist/extra/empty.cjs.map +1 -0
  186. package/dist/extra/empty.d.cts +13 -0
  187. package/dist/extra/empty.d.ts +13 -0
  188. package/dist/extra/empty.js +2 -0
  189. package/dist/extra/empty.js.map +1 -0
  190. package/dist/extra/exhaustMap.cjs +3 -0
  191. package/dist/extra/exhaustMap.cjs.map +1 -0
  192. package/dist/extra/exhaustMap.d.cts +21 -0
  193. package/dist/extra/exhaustMap.d.ts +21 -0
  194. package/dist/extra/exhaustMap.js +2 -0
  195. package/dist/extra/exhaustMap.js.map +1 -0
  196. package/dist/extra/filter.cjs +3 -0
  197. package/dist/extra/filter.cjs.map +1 -0
  198. package/dist/extra/filter.d.cts +16 -0
  199. package/dist/extra/filter.d.ts +16 -0
  200. package/dist/extra/filter.js +2 -0
  201. package/dist/extra/filter.js.map +1 -0
  202. package/dist/extra/find.cjs +3 -0
  203. package/dist/extra/find.cjs.map +1 -0
  204. package/dist/extra/find.d.cts +17 -0
  205. package/dist/extra/find.d.ts +17 -0
  206. package/dist/extra/find.js +2 -0
  207. package/dist/extra/find.js.map +1 -0
  208. package/dist/extra/first.cjs +3 -0
  209. package/dist/extra/first.cjs.map +1 -0
  210. package/dist/extra/first.d.cts +15 -0
  211. package/dist/extra/first.d.ts +15 -0
  212. package/dist/extra/first.js +2 -0
  213. package/dist/extra/first.js.map +1 -0
  214. package/dist/extra/flat.cjs +3 -0
  215. package/dist/extra/flat.cjs.map +1 -0
  216. package/dist/extra/flat.d.cts +21 -0
  217. package/dist/extra/flat.d.ts +21 -0
  218. package/dist/extra/flat.js +2 -0
  219. package/dist/extra/flat.js.map +1 -0
  220. package/dist/extra/forEach.cjs +2 -0
  221. package/dist/extra/forEach.cjs.map +1 -0
  222. package/dist/extra/forEach.d.cts +13 -0
  223. package/dist/extra/forEach.d.ts +13 -0
  224. package/dist/extra/forEach.js +2 -0
  225. package/dist/extra/forEach.js.map +1 -0
  226. package/dist/extra/fromEvent.cjs +3 -0
  227. package/dist/extra/fromEvent.cjs.map +1 -0
  228. package/dist/extra/fromEvent.d.cts +14 -0
  229. package/dist/extra/fromEvent.d.ts +14 -0
  230. package/dist/extra/fromEvent.js +2 -0
  231. package/dist/extra/fromEvent.js.map +1 -0
  232. package/dist/extra/fromIter.cjs +3 -0
  233. package/dist/extra/fromIter.cjs.map +1 -0
  234. package/dist/extra/fromIter.d.cts +15 -0
  235. package/dist/extra/fromIter.d.ts +15 -0
  236. package/dist/extra/fromIter.js +2 -0
  237. package/dist/extra/fromIter.js.map +1 -0
  238. package/dist/extra/fromObs.cjs +3 -0
  239. package/dist/extra/fromObs.cjs.map +1 -0
  240. package/dist/extra/fromObs.d.cts +25 -0
  241. package/dist/extra/fromObs.d.ts +25 -0
  242. package/dist/extra/fromObs.js +2 -0
  243. package/dist/extra/fromObs.js.map +1 -0
  244. package/dist/extra/fromPromise.cjs +3 -0
  245. package/dist/extra/fromPromise.cjs.map +1 -0
  246. package/dist/extra/fromPromise.d.cts +16 -0
  247. package/dist/extra/fromPromise.d.ts +16 -0
  248. package/dist/extra/fromPromise.js +2 -0
  249. package/dist/extra/fromPromise.js.map +1 -0
  250. package/dist/extra/index.cjs +3 -0
  251. package/dist/extra/index.cjs.map +1 -0
  252. package/dist/extra/index.d.cts +220 -0
  253. package/dist/extra/index.d.ts +220 -0
  254. package/dist/extra/index.js +2 -0
  255. package/dist/extra/index.js.map +1 -0
  256. package/dist/extra/interval.cjs +3 -0
  257. package/dist/extra/interval.cjs.map +1 -0
  258. package/dist/extra/interval.d.cts +15 -0
  259. package/dist/extra/interval.d.ts +15 -0
  260. package/dist/extra/interval.js +2 -0
  261. package/dist/extra/interval.js.map +1 -0
  262. package/dist/extra/last.cjs +3 -0
  263. package/dist/extra/last.cjs.map +1 -0
  264. package/dist/extra/last.d.cts +16 -0
  265. package/dist/extra/last.d.ts +16 -0
  266. package/dist/extra/last.js +2 -0
  267. package/dist/extra/last.js.map +1 -0
  268. package/dist/extra/map.cjs +3 -0
  269. package/dist/extra/map.cjs.map +1 -0
  270. package/dist/extra/map.d.cts +15 -0
  271. package/dist/extra/map.d.ts +15 -0
  272. package/dist/extra/map.js +2 -0
  273. package/dist/extra/map.js.map +1 -0
  274. package/dist/extra/merge.cjs +3 -0
  275. package/dist/extra/merge.cjs.map +1 -0
  276. package/dist/extra/merge.d.cts +21 -0
  277. package/dist/extra/merge.d.ts +21 -0
  278. package/dist/extra/merge.js +2 -0
  279. package/dist/extra/merge.js.map +1 -0
  280. package/dist/extra/never.cjs +3 -0
  281. package/dist/extra/never.cjs.map +1 -0
  282. package/dist/extra/never.d.cts +13 -0
  283. package/dist/extra/never.d.ts +13 -0
  284. package/dist/extra/never.js +2 -0
  285. package/dist/extra/never.js.map +1 -0
  286. package/dist/extra/of.cjs +3 -0
  287. package/dist/extra/of.cjs.map +1 -0
  288. package/dist/extra/of.d.cts +14 -0
  289. package/dist/extra/of.d.ts +14 -0
  290. package/dist/extra/of.js +2 -0
  291. package/dist/extra/of.js.map +1 -0
  292. package/dist/extra/pairwise.cjs +3 -0
  293. package/dist/extra/pairwise.cjs.map +1 -0
  294. package/dist/extra/pairwise.d.cts +16 -0
  295. package/dist/extra/pairwise.d.ts +16 -0
  296. package/dist/extra/pairwise.js +2 -0
  297. package/dist/extra/pairwise.js.map +1 -0
  298. package/dist/extra/partition.cjs +3 -0
  299. package/dist/extra/partition.cjs.map +1 -0
  300. package/dist/extra/partition.d.cts +24 -0
  301. package/dist/extra/partition.d.ts +24 -0
  302. package/dist/extra/partition.js +2 -0
  303. package/dist/extra/partition.js.map +1 -0
  304. package/dist/extra/pipeRaw.cjs +3 -0
  305. package/dist/extra/pipeRaw.cjs.map +1 -0
  306. package/dist/extra/pipeRaw.d.cts +22 -0
  307. package/dist/extra/pipeRaw.d.ts +22 -0
  308. package/dist/extra/pipeRaw.js +2 -0
  309. package/dist/extra/pipeRaw.js.map +1 -0
  310. package/dist/extra/remember.cjs +3 -0
  311. package/dist/extra/remember.cjs.map +1 -0
  312. package/dist/extra/remember.d.cts +17 -0
  313. package/dist/extra/remember.d.ts +17 -0
  314. package/dist/extra/remember.js +2 -0
  315. package/dist/extra/remember.js.map +1 -0
  316. package/dist/extra/repeat.cjs +3 -0
  317. package/dist/extra/repeat.cjs.map +1 -0
  318. package/dist/extra/repeat.d.cts +29 -0
  319. package/dist/extra/repeat.d.ts +29 -0
  320. package/dist/extra/repeat.js +2 -0
  321. package/dist/extra/repeat.js.map +1 -0
  322. package/dist/extra/rescue.cjs +3 -0
  323. package/dist/extra/rescue.cjs.map +1 -0
  324. package/dist/extra/rescue.d.cts +16 -0
  325. package/dist/extra/rescue.d.ts +16 -0
  326. package/dist/extra/rescue.js +2 -0
  327. package/dist/extra/rescue.js.map +1 -0
  328. package/dist/extra/retry.cjs +3 -0
  329. package/dist/extra/retry.cjs.map +1 -0
  330. package/dist/extra/retry.d.cts +29 -0
  331. package/dist/extra/retry.d.ts +29 -0
  332. package/dist/extra/retry.js +2 -0
  333. package/dist/extra/retry.js.map +1 -0
  334. package/dist/extra/sample.cjs +3 -0
  335. package/dist/extra/sample.cjs.map +1 -0
  336. package/dist/extra/sample.d.cts +15 -0
  337. package/dist/extra/sample.d.ts +15 -0
  338. package/dist/extra/sample.js +2 -0
  339. package/dist/extra/sample.js.map +1 -0
  340. package/dist/extra/scan.cjs +3 -0
  341. package/dist/extra/scan.cjs.map +1 -0
  342. package/dist/extra/scan.d.cts +16 -0
  343. package/dist/extra/scan.d.ts +16 -0
  344. package/dist/extra/scan.js +2 -0
  345. package/dist/extra/scan.js.map +1 -0
  346. package/dist/extra/share.cjs +2 -0
  347. package/dist/extra/share.cjs.map +1 -0
  348. package/dist/extra/share.d.cts +12 -0
  349. package/dist/extra/share.d.ts +12 -0
  350. package/dist/extra/share.js +2 -0
  351. package/dist/extra/share.js.map +1 -0
  352. package/dist/extra/skip.cjs +3 -0
  353. package/dist/extra/skip.cjs.map +1 -0
  354. package/dist/extra/skip.d.cts +16 -0
  355. package/dist/extra/skip.d.ts +16 -0
  356. package/dist/extra/skip.js +2 -0
  357. package/dist/extra/skip.js.map +1 -0
  358. package/dist/extra/startWith.cjs +3 -0
  359. package/dist/extra/startWith.cjs.map +1 -0
  360. package/dist/extra/startWith.d.cts +15 -0
  361. package/dist/extra/startWith.d.ts +15 -0
  362. package/dist/extra/startWith.js +2 -0
  363. package/dist/extra/startWith.js.map +1 -0
  364. package/dist/extra/subject.cjs +3 -0
  365. package/dist/extra/subject.cjs.map +1 -0
  366. package/dist/extra/subject.d.cts +27 -0
  367. package/dist/extra/subject.d.ts +27 -0
  368. package/dist/extra/subject.js +2 -0
  369. package/dist/extra/subject.js.map +1 -0
  370. package/dist/extra/subscribe.cjs +2 -0
  371. package/dist/extra/subscribe.cjs.map +1 -0
  372. package/dist/extra/subscribe.d.cts +19 -0
  373. package/dist/extra/subscribe.d.ts +19 -0
  374. package/dist/extra/subscribe.js +2 -0
  375. package/dist/extra/subscribe.js.map +1 -0
  376. package/dist/extra/switchMap.cjs +3 -0
  377. package/dist/extra/switchMap.cjs.map +1 -0
  378. package/dist/extra/switchMap.d.cts +21 -0
  379. package/dist/extra/switchMap.d.ts +21 -0
  380. package/dist/extra/switchMap.js +2 -0
  381. package/dist/extra/switchMap.js.map +1 -0
  382. package/dist/extra/take.cjs +3 -0
  383. package/dist/extra/take.cjs.map +1 -0
  384. package/dist/extra/take.d.cts +15 -0
  385. package/dist/extra/take.d.ts +15 -0
  386. package/dist/extra/take.js +2 -0
  387. package/dist/extra/take.js.map +1 -0
  388. package/dist/extra/takeUntil.cjs +3 -0
  389. package/dist/extra/takeUntil.cjs.map +1 -0
  390. package/dist/extra/takeUntil.d.cts +20 -0
  391. package/dist/extra/takeUntil.d.ts +20 -0
  392. package/dist/extra/takeUntil.js +2 -0
  393. package/dist/extra/takeUntil.js.map +1 -0
  394. package/dist/extra/tap.cjs +3 -0
  395. package/dist/extra/tap.cjs.map +1 -0
  396. package/dist/extra/tap.d.cts +15 -0
  397. package/dist/extra/tap.d.ts +15 -0
  398. package/dist/extra/tap.js +2 -0
  399. package/dist/extra/tap.js.map +1 -0
  400. package/dist/extra/throttle.cjs +3 -0
  401. package/dist/extra/throttle.cjs.map +1 -0
  402. package/dist/extra/throttle.d.cts +16 -0
  403. package/dist/extra/throttle.d.ts +16 -0
  404. package/dist/extra/throttle.js +2 -0
  405. package/dist/extra/throttle.js.map +1 -0
  406. package/dist/extra/throwError.cjs +3 -0
  407. package/dist/extra/throwError.cjs.map +1 -0
  408. package/dist/extra/throwError.d.cts +13 -0
  409. package/dist/extra/throwError.d.ts +13 -0
  410. package/dist/extra/throwError.js +2 -0
  411. package/dist/extra/throwError.js.map +1 -0
  412. package/dist/extra/timeout.cjs +3 -0
  413. package/dist/extra/timeout.cjs.map +1 -0
  414. package/dist/extra/timeout.d.cts +19 -0
  415. package/dist/extra/timeout.d.ts +19 -0
  416. package/dist/extra/timeout.js +2 -0
  417. package/dist/extra/timeout.js.map +1 -0
  418. package/dist/index.cjs +3 -0
  419. package/dist/index.cjs.map +1 -0
  420. package/dist/index.d.cts +197 -0
  421. package/dist/index.d.ts +197 -0
  422. package/dist/index.js +2 -0
  423. package/dist/index.js.map +1 -0
  424. package/dist/memory/index.cjs +3 -0
  425. package/dist/memory/index.cjs.map +1 -0
  426. package/dist/memory/index.d.cts +113 -0
  427. package/dist/memory/index.d.ts +113 -0
  428. package/dist/memory/index.js +2 -0
  429. package/dist/memory/index.js.map +1 -0
  430. package/dist/orchestrate/index.cjs +3 -0
  431. package/dist/orchestrate/index.cjs.map +1 -0
  432. package/dist/orchestrate/index.d.cts +101 -0
  433. package/dist/orchestrate/index.d.ts +101 -0
  434. package/dist/orchestrate/index.js +2 -0
  435. package/dist/orchestrate/index.js.map +1 -0
  436. package/dist/patterns/createStore/index.cjs +3 -0
  437. package/dist/patterns/createStore/index.cjs.map +1 -0
  438. package/dist/patterns/createStore/index.d.cts +55 -0
  439. package/dist/patterns/createStore/index.d.ts +55 -0
  440. package/dist/patterns/createStore/index.js +2 -0
  441. package/dist/patterns/createStore/index.js.map +1 -0
  442. package/dist/types-BiLijSKv.d.cts +192 -0
  443. package/dist/types-CIITLkgL.d.ts +192 -0
  444. package/dist/types-DsAN6Hga.d.cts +86 -0
  445. package/dist/types-DsAN6Hga.d.ts +86 -0
  446. package/dist/utils/index.cjs +3 -0
  447. package/dist/utils/index.cjs.map +1 -0
  448. package/dist/utils/index.d.cts +8 -0
  449. package/dist/utils/index.d.ts +8 -0
  450. package/dist/utils/index.js +2 -0
  451. package/dist/utils/index.js.map +1 -0
  452. package/package.json +141 -0
@@ -0,0 +1 @@
1
+ {"version":3,"sources":["../../../src/patterns/createStore/index.ts","../../../src/core/bitmask.ts","../../../src/core/protocol.ts","../../../src/core/inspector.ts","../../../src/core/derived.ts","../../../src/core/producer.ts","../../../src/core/state.ts","../../../src/core/subscribe.ts"],"sourcesContent":["/**\n * createStore — single-store pattern for Zustand/Redux users.\n *\n * Provides a familiar `create((set, get) => ({ ...state, ...actions }))` API\n * backed by callbag-recharge primitives. Key advantage over Zustand:\n * diamond-safe `select()` returns a `Store<U>` with automatic memoization\n * and dependency tracking — no reselect, no useShallow.\n *\n * Zustand StoreApi compatibility: matches `getState`, `setState`, `subscribe`,\n * `getInitialState` — Zustand middleware (persist, devtools, immer) can wrap\n * this store directly.\n */\n\nimport { derived } from \"../../core/derived\";\nimport { batch, teardown } from \"../../core/protocol\";\nimport { state } from \"../../core/state\";\nimport { subscribe as coreSubscribe } from \"../../core/subscribe\";\nimport type { Store, WritableStore } from \"../../core/types\";\n\n// ---------------------------------------------------------------------------\n// Types\n// ---------------------------------------------------------------------------\n\ntype SetStateAction<T> = T | Partial<T> | ((state: T) => T | Partial<T>);\n\ntype Get<T> = () => T;\ntype Set<T> = (partial: SetStateAction<T>, replace?: boolean) => void;\n\ntype StateCreator<T> = (set: Set<T>, get: Get<T>) => T;\n\n/**\n * Zustand-compatible StoreApi — middleware works if you match this contract.\n */\ninterface StoreApi<T> {\n\tsetState: (partial: SetStateAction<T>, replace?: boolean) => void;\n\tgetState: () => T;\n\tgetInitialState: () => T;\n\tsubscribe: (listener: (state: T, prevState: T) => void) => () => void;\n}\n\ninterface CreateStoreResult<T> extends StoreApi<T> {\n\t/**\n\t * Create a diamond-safe derived store from a selector function.\n\t * Returns a `Store<U>` that only recomputes when the selected value\n\t * actually changes (push-phase memoization via `equals`).\n\t *\n\t * This is the killer feature over Zustand — selectors are reactive stores\n\t * with automatic memoization, not just functions re-evaluated on every render.\n\t */\n\tselect<U>(selector: (state: T) => U, equals?: (a: U, b: U) => boolean): Store<U>;\n\n\t/**\n\t * The underlying callbag-recharge WritableStore.\n\t * Use this to compose with other callbag-recharge primitives\n\t * (derived, effect, pipe, operators).\n\t */\n\tstore: WritableStore<T>;\n\n\t/**\n\t * Destroy the store — sends END to all downstream subscribers and derived\n\t * stores, cascading through the entire subgraph. After destroy, the store\n\t * is in COMPLETED state and won't accept new values or subscriptions.\n\t */\n\tdestroy: () => void;\n}\n\n// ---------------------------------------------------------------------------\n// createStore\n// ---------------------------------------------------------------------------\n\nexport function createStore<T extends object>(initializer: StateCreator<T>): CreateStoreResult<T> {\n\t// --- Phase 1: initialization ---\n\t// `source` doesn't exist yet. get()/set() use `initialState` directly.\n\t// source is `let` so set() during the initializer doesn't throw.\n\tlet source: WritableStore<T> | null = null;\n\tlet initialState: T = undefined as unknown as T;\n\n\t// Action keys cached once after init (not recomputed per set()).\n\t// Starts empty — set() during init skips action preservation (no actions yet).\n\tlet actionKeys: string[] = [];\n\n\tconst get: Get<T> = () => (source ? (source.get() as T) : initialState);\n\n\tconst set: Set<T> = (partial, replace) => {\n\t\tconst prev = get();\n\t\tconst nextPartial =\n\t\t\ttypeof partial === \"function\" ? (partial as (s: T) => T | Partial<T>)(prev) : partial;\n\n\t\t// No-op early return — avoids unnecessary allocation\n\t\tif (nextPartial === prev && !replace) return;\n\n\t\t// replace=true replaces the entire state, no action preservation.\n\t\tif (replace) {\n\t\t\tif (source) source.set(nextPartial as T);\n\t\t\telse initialState = nextPartial as T;\n\t\t\treturn;\n\t\t}\n\n\t\tconst nextState = Object.assign({}, prev, nextPartial) as T;\n\n\t\t// Preserve action references not explicitly overwritten.\n\t\tfor (const key of actionKeys) {\n\t\t\tif (!Object.hasOwn(nextPartial as object, key)) {\n\t\t\t\t(nextState as any)[key] = (prev as any)[key];\n\t\t\t}\n\t\t}\n\n\t\tif (source) source.set(nextState);\n\t\telse initialState = nextState;\n\t};\n\n\t// Run initializer — may call set()/get() during execution.\n\t// get() returns `initialState` (starts as undefined, updated by any\n\t// set() calls during init). This matches Zustand's behavior.\n\tinitialState = initializer(set, get);\n\n\t// Cache action keys once after init\n\tactionKeys = Object.keys(initialState).filter(\n\t\t(k) => typeof (initialState as any)[k] === \"function\",\n\t);\n\n\t// Snapshot for getInitialState() — frozen reference to the original state\n\tconst frozenInitial = initialState;\n\n\t// --- Phase 2: reactive backing store ---\n\t// After this point, `source` is set and get()/set() delegate to it.\n\tsource = state<T>(initialState, { name: \"createStore\" });\n\n\t// -- StoreApi methods --\n\t// coreSubscribe is a lightweight sink (no graph node allocation, no\n\t// Inspector registration). effect() would work but creates an unnecessary\n\t// store node — we just need \"call me when values change\".\n\n\tconst setState: StoreApi<T>[\"setState\"] = (partial, replace) => {\n\t\tset(partial, replace);\n\t};\n\n\tconst getState: StoreApi<T>[\"getState\"] = () => source!.get() as T;\n\n\tconst getInitialState: StoreApi<T>[\"getInitialState\"] = () => frozenInitial;\n\n\tconst storeSubscribe: StoreApi<T>[\"subscribe\"] = (listener) => {\n\t\treturn coreSubscribe(source as Store<T>, (value, prev) => {\n\t\t\tlistener(value, prev as T);\n\t\t});\n\t};\n\n\t// -- Select: the killer feature --\n\n\tconst select = <U>(selector: (state: T) => U, equals?: (a: U, b: U) => boolean): Store<U> => {\n\t\treturn derived([source as Store<T>], () => selector(source!.get() as T), {\n\t\t\tequals: equals ?? (Object.is as (a: U, b: U) => boolean),\n\t\t});\n\t};\n\n\t// destroy() uses protocol-level teardown — sends END to all downstream\n\t// sinks (subscribers, select()-derived stores), cascading through the\n\t// entire subgraph.\n\tconst destroy = () => {\n\t\tteardown(source!);\n\t};\n\n\treturn {\n\t\tsetState,\n\t\tgetState,\n\t\tgetInitialState,\n\t\tsubscribe: storeSubscribe,\n\t\tselect,\n\t\tstore: source,\n\t\tdestroy,\n\t};\n}\n\nexport { batch, teardown };\nexport type { StoreApi, CreateStoreResult, StateCreator, SetStateAction };\n","/**\n * Dirty-dep bitmask — safe for any number of deps.\n *\n * ≤32 deps: stores bitmask as a plain number in `_v` (zero overhead).\n * >32 deps: stores bits in a Uint32Array `_w`, with `_v` tracking the\n * count of set bits for O(1) emptiness checks.\n *\n * In both cases, `empty()` is a single `_v === 0` comparison — no typeof\n * dispatch, no array scan. Method calls on the class prototype are\n * monomorphic (one hidden class for all instances).\n *\n * Used by derived, effect, merge, combine — anywhere dirty-dep tracking\n * needs per-dep bit flags.\n */\n\nexport class Bitmask {\n\t/** Narrow (≤32): bitmask value. Wide (>32): count of set bits. */\n\t_v: number;\n\t/** Uint32Array for >32 deps, null otherwise. */\n\t_w: Uint32Array | null;\n\n\tconstructor(size: number) {\n\t\tthis._v = 0;\n\t\tthis._w = size > 32 ? new Uint32Array(((size - 1) >>> 5) + 1) : null;\n\t}\n\n\tset(i: number): void {\n\t\tconst w = this._w;\n\t\tif (w === null) {\n\t\t\tthis._v |= 1 << i;\n\t\t} else {\n\t\t\tconst idx = i >>> 5;\n\t\t\tconst bit = 1 << (i & 31);\n\t\t\tif (!(w[idx] & bit)) {\n\t\t\t\tw[idx] |= bit;\n\t\t\t\tthis._v++;\n\t\t\t}\n\t\t}\n\t}\n\n\tclear(i: number): void {\n\t\tconst w = this._w;\n\t\tif (w === null) {\n\t\t\tthis._v &= ~(1 << i);\n\t\t} else {\n\t\t\tconst idx = i >>> 5;\n\t\t\tconst bit = 1 << (i & 31);\n\t\t\tif (w[idx] & bit) {\n\t\t\t\tw[idx] &= ~bit;\n\t\t\t\tthis._v--;\n\t\t\t}\n\t\t}\n\t}\n\n\ttest(i: number): boolean {\n\t\tconst w = this._w;\n\t\tif (w === null) return (this._v & (1 << i)) !== 0;\n\t\treturn (w[i >>> 5] & (1 << (i & 31))) !== 0;\n\t}\n\n\t/** O(1) in both narrow and wide paths. */\n\tempty(): boolean {\n\t\treturn this._v === 0;\n\t}\n\n\treset(): void {\n\t\tthis._v = 0;\n\t\tthis._w?.fill(0);\n\t}\n}\n","// ---------------------------------------------------------------------------\n// Protocol — v3 type 3 control channel\n// ---------------------------------------------------------------------------\n// Type 3 (STATE) carries control signals: DIRTY, RESOLVED\n// Type 1 (DATA) carries only real values — never sentinels\n// ---------------------------------------------------------------------------\n\n/** Control signal: \"my value is about to change\" */\nexport const DIRTY = Symbol(\"DIRTY\");\n\n/** Control signal: \"I was dirty but my value didn't change\" */\nexport const RESOLVED = Symbol(\"RESOLVED\");\n\nexport type Signal = typeof DIRTY | typeof RESOLVED;\n\n/** Node status — tracks current lifecycle state (v4) */\nexport type NodeStatus =\n\t| \"DISCONNECTED\"\n\t| \"DIRTY\"\n\t| \"SETTLED\"\n\t| \"RESOLVED\"\n\t| \"COMPLETED\"\n\t| \"ERRORED\";\n\n// ---------------------------------------------------------------------------\n// Integer status constants — pack into _flags for hot-path performance.\n// 3 bits (7-9) encode 6 statuses. Use STATUS_MASK to read/write.\n// ---------------------------------------------------------------------------\nexport const S_DISCONNECTED = 0;\nexport const S_DIRTY = 1;\nexport const S_SETTLED = 2;\nexport const S_RESOLVED = 3;\nexport const S_COMPLETED = 4;\nexport const S_ERRORED = 5;\nexport const STATUS_SHIFT = 7;\nexport const STATUS_MASK = 0b111 << STATUS_SHIFT; // bits 7-9\n\nconst STATUS_STRINGS: NodeStatus[] = [\n\t\"DISCONNECTED\",\n\t\"DIRTY\",\n\t\"SETTLED\",\n\t\"RESOLVED\",\n\t\"COMPLETED\",\n\t\"ERRORED\",\n];\n\n/** Decode integer status bits back to string (for Inspector / tests) */\nexport function decodeStatus(flags: number): NodeStatus {\n\treturn STATUS_STRINGS[(flags & STATUS_MASK) >>> STATUS_SHIFT];\n}\n\n/** Callbag signal types */\nexport const START = 0;\nexport const DATA = 1;\nexport const END = 2;\nexport const STATE = 3;\n\n// ---------------------------------------------------------------------------\n// Batch — defers type 1 value emissions; type 3 DIRTY propagates immediately\n// ---------------------------------------------------------------------------\n\nlet batchDepth = 0;\nconst deferredEmissions: Array<() => void> = [];\n\n// `draining` prevents re-entrant drain when a nested batch() call ends while\n// the outer drain loop is already running. Without it, the inner batch's\n// finally block would see batchDepth===0 and start a second drain, racing the\n// outer loop — potentially double-processing items or clearing the array mid-\n// iteration. With draining=true, the inner batch skips its drain; any items it\n// pushes are picked up by the outer loop (the `for` condition re-evaluates\n// `deferredEmissions.length` on every iteration, so appends during drain are\n// naturally included in the same pass).\nlet draining = false;\n\nexport function batch<T>(fn: () => T): T {\n\tbatchDepth++;\n\ttry {\n\t\treturn fn();\n\t} finally {\n\t\tbatchDepth--;\n\t\tif (batchDepth === 0 && !draining) {\n\t\t\tdraining = true;\n\t\t\tfor (let i = 0; i < deferredEmissions.length; i++) {\n\t\t\t\tdeferredEmissions[i]();\n\t\t\t}\n\t\t\tdeferredEmissions.length = 0;\n\t\t\tdraining = false;\n\t\t}\n\t}\n}\n\nexport function isBatching(): boolean {\n\treturn batchDepth > 0;\n}\n\nexport function deferEmission(fn: () => void): void {\n\tdeferredEmissions.push(fn);\n}\n\n// ---------------------------------------------------------------------------\n// Connection batching (producer start deferral) — unchanged from v2\n// ---------------------------------------------------------------------------\n\nlet connectDepth = 0;\nconst pendingStarts: Array<() => void> = [];\n\nexport function beginDeferredStart(): void {\n\tconnectDepth++;\n}\n\nexport function endDeferredStart(): void {\n\tconnectDepth--;\n\tif (connectDepth === 0) {\n\t\tfor (let i = 0; i < pendingStarts.length; i++) {\n\t\t\tpendingStarts[i]();\n\t\t}\n\t\tpendingStarts.length = 0;\n\t}\n}\n\nexport function deferStart(start: () => void): void {\n\tif (connectDepth > 0) {\n\t\tpendingStarts.push(start);\n\t} else {\n\t\tstart();\n\t}\n}\n\n// ---------------------------------------------------------------------------\n// teardown — protocol-level graph destruction\n// ---------------------------------------------------------------------------\n// Sends END to all downstream sinks of a store node, cascading through the\n// entire subgraph. After teardown, the node is in COMPLETED state and won't\n// accept new values or subscriptions.\n//\n// Works with any node that uses the output slot model:\n// - ProducerImpl / StateImpl / OperatorImpl → calls .complete()\n// - DerivedImpl → calls ._handleEnd() (no public complete() on derived)\n// ---------------------------------------------------------------------------\n\nexport function teardown(store: { source: (type: number, payload?: any) => void }): void {\n\tconst node = store as any;\n\tif (typeof node.complete === \"function\") {\n\t\tnode.complete();\n\t} else if (typeof node._handleEnd === \"function\") {\n\t\tnode._handleEnd(undefined);\n\t}\n}\n","// ---------------------------------------------------------------------------\n// Inspector — static class for observability\n// ---------------------------------------------------------------------------\n// All debug metadata lives here in WeakMaps, not on the store objects.\n// Stores stay lean. Inspector is opt-in overhead.\n//\n// v5: Zero intrusion into primitives. No hooks in hot paths. All methods\n// are static — call directly as Inspector.observe(), Inspector.tap(), etc.\n// - register/registerEdge: metadata collection (called from constructors)\n// - inspect/graph/dumpGraph/snapshot: read-only graph queries\n// - observe/spy/trace: callbag sinks for debugging (subscribe externally)\n// - tap: transparent passthrough wrapper for graph visualization\n// ---------------------------------------------------------------------------\n\nimport type { NodeStatus, Signal } from \"./protocol\";\nimport { DATA, DIRTY, END, RESOLVED, START, STATE } from \"./protocol\";\nimport type { Store } from \"./types\";\n\nexport interface StoreInfo<T = unknown> {\n\tname: string | undefined;\n\tkind: string;\n\tvalue: T;\n\t/** v4: node lifecycle status */\n\tstatus: NodeStatus | undefined;\n}\n\nexport interface ObserveResult<T> {\n\t/** All DATA (type 1) values received, in order */\n\tvalues: T[];\n\t/** All STATE (type 3) payloads received (DIRTY, RESOLVED, or unknown) */\n\tsignals: Signal[];\n\t/** All events in protocol order: { type, data } */\n\tevents: Array<{ type: \"data\" | \"signal\" | \"end\"; data: unknown }>;\n\t/** Whether END (type 2) has been received */\n\tended: boolean;\n\t/** Error payload from END, if any */\n\tendError: unknown;\n\t/** Count of DIRTY signals received */\n\tdirtyCount: number;\n\t/** Count of RESOLVED signals received */\n\tresolvedCount: number;\n\t/** Store name (from Inspector, if registered) */\n\tname: string | undefined;\n\t/** Disconnect the observer */\n\tdispose: () => void;\n}\n\n// Static-only class is intentional API for Inspector namespace\n// biome-ignore lint/complexity/noStaticOnlyClass: public API surface\nexport class Inspector {\n\t// WeakMaps for metadata — keyed by any graph node (stores, effects, etc.)\n\tprivate static _names = new WeakMap<object, string>();\n\tprivate static _kinds = new WeakMap<object, string>();\n\tprivate static _keys = new WeakMap<object, string>();\n\n\t// WeakRef set for graph() — allows GC of unused nodes\n\tprivate static _stores = new Set<WeakRef<object>>();\n\n\t// Dependency edges: parent key → child keys\n\tprivate static _edges = new Map<string, string[]>();\n\n\t// Unique key generation\n\tprivate static _nextId = 0;\n\tprivate static _usedKeys = new Set<string>();\n\n\t// Enabled flag — when false, register/getName are no-ops\n\tprivate static _explicitEnabled: boolean | null = null;\n\tprivate static _cachedDefault: boolean | null = null;\n\n\tstatic get enabled(): boolean {\n\t\tif (Inspector._explicitEnabled !== null) return Inspector._explicitEnabled;\n\t\tif (Inspector._cachedDefault !== null) return Inspector._cachedDefault;\n\t\ttry {\n\t\t\tInspector._cachedDefault = (globalThis as any).process?.env?.NODE_ENV !== \"production\";\n\t\t} catch {\n\t\t\tInspector._cachedDefault = true;\n\t\t}\n\t\treturn Inspector._cachedDefault;\n\t}\n\n\tstatic set enabled(value: boolean) {\n\t\tInspector._explicitEnabled = value;\n\t}\n\n\t/** Compute a dep-name-based suffix for unique key generation */\n\tprivate static _depSuffix(deps?: object[]): string | undefined {\n\t\tif (!deps?.length) return undefined;\n\t\tconst names = deps.map((d) => Inspector._names.get(d) ?? \"?\");\n\t\tconst joined = names.join(\",\");\n\t\treturn joined.length > 40 ? `${joined.slice(0, 37)}...` : joined;\n\t}\n\n\t/** Resolve a node to its unique graph key */\n\tprivate static _resolveKey(node: object): string {\n\t\treturn Inspector._keys.get(node) ?? Inspector._names.get(node) ?? \"anonymous\";\n\t}\n\n\t/** Register a graph node (store, effect, etc.) with the inspector */\n\tstatic register(node: object, opts?: { name?: string; kind?: string; deps?: object[] }): void {\n\t\tif (!Inspector.enabled) return;\n\t\tif (opts?.name) Inspector._names.set(node, opts.name);\n\t\tif (opts?.kind) Inspector._kinds.set(node, opts.kind);\n\n\t\t// Compute unique key\n\t\tconst id = Inspector._nextId++;\n\t\tlet key = opts?.name;\n\t\tif (key && !Inspector._usedKeys.has(key)) {\n\t\t\t// Unique name — use as-is\n\t\t} else if (key) {\n\t\t\t// Name collision — differentiate with dep names or ID\n\t\t\tconst depSuffix = Inspector._depSuffix(opts?.deps);\n\t\t\tkey = depSuffix ? `${key}(${depSuffix})` : `${key}_${id}`;\n\t\t\tif (Inspector._usedKeys.has(key)) key = `${key}_${id}`;\n\t\t} else {\n\t\t\t// Unnamed — use kind + dep names or ID\n\t\t\tconst kind = opts?.kind ?? \"store\";\n\t\t\tconst depSuffix = Inspector._depSuffix(opts?.deps);\n\t\t\tkey = depSuffix ? `${kind}(${depSuffix})` : `${kind}_${id}`;\n\t\t\tif (Inspector._usedKeys.has(key)) key = `${key}_${id}`;\n\t\t}\n\n\t\tInspector._usedKeys.add(key);\n\t\tInspector._keys.set(node, key);\n\t\tInspector._stores.add(new WeakRef(node));\n\t}\n\n\t/** Register a dependency edge between parent and child nodes */\n\tstatic registerEdge(parent: object, child: object): void {\n\t\tif (!Inspector.enabled) return;\n\t\tconst parentKey = Inspector._resolveKey(parent);\n\t\tconst childKey = Inspector._resolveKey(child);\n\t\tconst children = Inspector._edges.get(parentKey);\n\t\tif (children) {\n\t\t\tif (!children.includes(childKey)) children.push(childKey);\n\t\t} else {\n\t\t\tInspector._edges.set(parentKey, [childKey]);\n\t\t}\n\t}\n\n\t/** Get dependency edges: parent → children */\n\tstatic getEdges(): Map<string, string[]> {\n\t\treturn new Map(Inspector._edges);\n\t}\n\n\t/** Get the name of a node */\n\tstatic getName(node: object): string | undefined {\n\t\tif (!Inspector.enabled) return undefined;\n\t\treturn Inspector._names.get(node);\n\t}\n\n\t/** Get the kind of a node */\n\tstatic getKind(node: object): string | undefined {\n\t\treturn Inspector._kinds.get(node);\n\t}\n\n\t/** Inspect a single graph node — includes status and value (if available) */\n\tstatic inspect<T = unknown>(node: object): StoreInfo<T> {\n\t\treturn {\n\t\t\tname: Inspector._names.get(node),\n\t\t\tkind: Inspector._kinds.get(node) ?? \"unknown\",\n\t\t\tvalue: (typeof (node as any).get === \"function\" ? (node as any).get() : undefined) as T,\n\t\t\tstatus: (node as any)._status,\n\t\t};\n\t}\n\n\t/** Get all living nodes as a Map. Also prunes dead edges from GC'd nodes. */\n\tstatic graph(): Map<string, StoreInfo> {\n\t\tconst result = new Map<string, StoreInfo>();\n\t\tconst livingKeys = new Set<string>();\n\t\tfor (const ref of Inspector._stores) {\n\t\t\tconst node = ref.deref();\n\t\t\tif (!node) {\n\t\t\t\tInspector._stores.delete(ref); // cleanup GC'd refs\n\t\t\t\tcontinue;\n\t\t\t}\n\t\t\tconst key = Inspector._resolveKey(node);\n\t\t\tlivingKeys.add(key);\n\t\t\tresult.set(key, Inspector.inspect(node));\n\t\t}\n\t\t// Prune edges referencing GC'd stores\n\t\tfor (const [key, children] of Inspector._edges) {\n\t\t\tif (!livingKeys.has(key)) {\n\t\t\t\tInspector._edges.delete(key);\n\t\t\t\tInspector._usedKeys.delete(key);\n\t\t\t\tcontinue;\n\t\t\t}\n\t\t\tconst alive = children.filter((c) => livingKeys.has(c));\n\t\t\tif (alive.length === 0) {\n\t\t\t\tInspector._edges.delete(key);\n\t\t\t} else if (alive.length !== children.length) {\n\t\t\t\tInspector._edges.set(key, alive);\n\t\t\t}\n\t\t}\n\t\treturn result;\n\t}\n\n\t/** Trace a specific store's value changes (raw callbag — no extra/ dependency) */\n\tstatic trace<T>(store: Store<T>, cb: (value: T, prev: T | undefined) => void): () => void {\n\t\tlet talkback: ((type: number) => void) | null = null;\n\t\tlet prev: T | undefined = store.get();\n\t\tstore.source(START, (type: number, data: any) => {\n\t\t\tif (type === START) talkback = data;\n\t\t\tif (type === END) {\n\t\t\t\ttalkback = null;\n\t\t\t\treturn;\n\t\t\t}\n\t\t\tif (type === 1) {\n\t\t\t\tconst next = data as T;\n\t\t\t\tif (!Object.is(next, prev)) {\n\t\t\t\t\tconst p = prev;\n\t\t\t\t\tprev = next;\n\t\t\t\t\tcb(next, p);\n\t\t\t\t}\n\t\t\t}\n\t\t});\n\t\treturn () => talkback?.(END);\n\t}\n\n\t/** Pretty-print the entire store graph for console/CLI debugging */\n\tstatic dumpGraph(): string {\n\t\tconst g = Inspector.graph();\n\t\tconst edges = Inspector.getEdges();\n\n\t\t// Build reverse map: child key → parent keys (deps)\n\t\tconst depsMap = new Map<string, string[]>();\n\t\tfor (const [parent, children] of edges) {\n\t\t\tfor (const child of children) {\n\t\t\t\tconst deps = depsMap.get(child);\n\t\t\t\tif (deps) {\n\t\t\t\t\tif (!deps.includes(parent)) deps.push(parent);\n\t\t\t\t} else {\n\t\t\t\t\tdepsMap.set(child, [parent]);\n\t\t\t\t}\n\t\t\t}\n\t\t}\n\n\t\tconst lines: string[] = [];\n\t\tfor (const [key, info] of g) {\n\t\t\tconst deps = depsMap.get(key);\n\t\t\tconst children = edges.get(key);\n\t\t\tconst depsStr = deps?.length ? ` ← [${deps.join(\", \")}]` : \"\";\n\t\t\tconst childStr = children?.length ? ` → [${children.join(\", \")}]` : \"\";\n\t\t\tlines.push(\n\t\t\t\t` ${key} (${info.kind}) = ${JSON.stringify(info.value)} [${info.status ?? \"?\"}]${depsStr}${childStr}`,\n\t\t\t);\n\t\t}\n\t\tconst header = `Store Graph (${g.size} nodes):`;\n\t\treturn [header, ...lines].join(\"\\n\");\n\t}\n\n\t/**\n\t * Internal observe implementation shared by observe() and spy().\n\t */\n\tprivate static _observe<T>(\n\t\tstore: Store<T>,\n\t\tlabel?: string,\n\t\tlog?: (...args: any[]) => void,\n\t): ObserveResult<T> {\n\t\tlet talkback: ((type: number) => void) | null = null;\n\t\tconst name = label ?? Inspector.getName(store);\n\t\tconst result: ObserveResult<T> = {\n\t\t\tvalues: [],\n\t\t\tsignals: [],\n\t\t\tevents: [],\n\t\t\tended: false,\n\t\t\tendError: undefined,\n\t\t\tdirtyCount: 0,\n\t\t\tresolvedCount: 0,\n\t\t\tname,\n\t\t\tdispose: () => talkback?.(END),\n\t\t};\n\n\t\tstore.source(START, (type: number, data: any) => {\n\t\t\tif (type === START) {\n\t\t\t\ttalkback = data;\n\t\t\t\treturn;\n\t\t\t}\n\t\t\tif (type === DATA) {\n\t\t\t\tresult.values.push(data);\n\t\t\t\tresult.events.push({ type: \"data\", data });\n\t\t\t\tif (log) log(`[${name}] DATA:`, data);\n\t\t\t} else if (type === STATE) {\n\t\t\t\tresult.signals.push(data);\n\t\t\t\tresult.events.push({ type: \"signal\", data });\n\t\t\t\tif (data === DIRTY) result.dirtyCount++;\n\t\t\t\telse if (data === RESOLVED) result.resolvedCount++;\n\t\t\t\tif (log) log(`[${name}] STATE:`, data);\n\t\t\t} else if (type === END) {\n\t\t\t\tresult.ended = true;\n\t\t\t\tresult.endError = data;\n\t\t\t\tresult.events.push({ type: \"end\", data });\n\t\t\t\tif (log) log(`[${name}] END`, data !== undefined ? data : \"\");\n\t\t\t\ttalkback = null;\n\t\t\t}\n\t\t});\n\n\t\treturn result;\n\t}\n\n\t/**\n\t * Observe a store's full callbag protocol — the test-friendly alternative\n\t * to hooks. Captures DATA values, STATE signals, END, and provides\n\t * convenience accessors.\n\t *\n\t * Returns a live observation object — arrays grow as the store emits.\n\t *\n\t * ```ts\n\t * const obs = Inspector.observe(myStore);\n\t * myState.set(5);\n\t * obs.values // [5]\n\t * obs.signals // [DIRTY]\n\t * obs.ended // false\n\t * obs.dirtyCount // 1\n\t * obs.dispose() // stop observing\n\t * ```\n\t */\n\tstatic observe<T>(store: Store<T>): ObserveResult<T> {\n\t\treturn Inspector._observe(store);\n\t}\n\n\t/**\n\t * Create a transparent passthrough wrapper for graph visualization.\n\t * The wrapper delegates `get()` and `source()` to the original store,\n\t * appearing as a distinct node in the Inspector graph. Zero overhead —\n\t * subscribers connect directly to the original store's source.\n\t */\n\tstatic tap<T>(store: Store<T>, name?: string): Store<T> {\n\t\tconst tapName = name ?? `tap(${Inspector.getName(store) ?? \"anon\"})`;\n\t\tconst wrapper: Store<T> = {\n\t\t\tget: () => store.get(),\n\t\t\tsource: store.source,\n\t\t};\n\t\tInspector.register(wrapper, { name: tapName, kind: \"tap\" });\n\t\tInspector.registerEdge(store, wrapper);\n\t\treturn wrapper;\n\t}\n\n\t/**\n\t * Enhanced observe() with logging — for interactive debugging.\n\t * Returns the same observation object as observe(), but also logs each\n\t * event as it happens. Pass a custom logger or defaults to console.log.\n\t */\n\tstatic spy<T>(\n\t\tstore: Store<T>,\n\t\topts?: { name?: string; log?: (...args: any[]) => void },\n\t): ObserveResult<T> {\n\t\tconst label = opts?.name ?? Inspector.getName(store) ?? \"spy\";\n\t\tconst log = opts?.log ?? console.log;\n\t\treturn Inspector._observe(store, label, log);\n\t}\n\n\t/**\n\t * JSON-serializable snapshot of the entire graph — nodes + edges.\n\t * Designed for AI consumption during debugging sessions.\n\t */\n\tstatic snapshot(): {\n\t\tnodes: Array<{ name: string; kind: string; value: unknown; status: string | undefined }>;\n\t\tedges: Array<{ from: string; to: string }>;\n\t} {\n\t\tconst g = Inspector.graph();\n\t\tconst edgeMap = Inspector.getEdges();\n\t\tconst nodes: Array<{ name: string; kind: string; value: unknown; status: string | undefined }> =\n\t\t\t[];\n\t\tfor (const [key, info] of g) {\n\t\t\tnodes.push({ name: key, kind: info.kind, value: info.value, status: info.status });\n\t\t}\n\t\tconst edges: Array<{ from: string; to: string }> = [];\n\t\tfor (const [parent, children] of edgeMap) {\n\t\t\tfor (const child of children) {\n\t\t\t\tedges.push({ from: parent, to: child });\n\t\t\t}\n\t\t}\n\t\treturn { nodes, edges };\n\t}\n\n\t/** Reset all state (for testing) */\n\tstatic _reset(): void {\n\t\tInspector._names = new WeakMap<object, string>();\n\t\tInspector._kinds = new WeakMap<object, string>();\n\t\tInspector._keys = new WeakMap<object, string>();\n\t\tInspector._stores = new Set<WeakRef<object>>();\n\t\tInspector._edges = new Map();\n\t\tInspector._usedKeys = new Set();\n\t\tInspector._nextId = 0;\n\t\tInspector._explicitEnabled = null;\n\t\tInspector._cachedDefault = null;\n\t}\n}\n","/**\n * Computed store with dirty tracking and caching. Recomputes fn() when\n * all dirty deps have resolved, emitting the new value on type 1 DATA.\n *\n * v6 (Option D3): Disconnect on last subscriber leaving. get() pull-computes\n * from deps when disconnected (always fresh). source() subscription triggers\n * connection; last unsubscribe triggers disconnect.\n *\n * _status packed into _flags bits 7-9 for hot-path performance.\n * String status exposed via getter for Inspector/test backward compat.\n *\n * Class-based for V8 hidden class optimization and prototype method sharing.\n * Boolean fields packed into _flags bitmask to reduce hidden class size.\n */\n\nimport { Bitmask } from \"./bitmask\";\nimport { Inspector } from \"./inspector\";\nimport {\n\tbeginDeferredStart,\n\tDATA,\n\tDIRTY,\n\tdecodeStatus,\n\tEND,\n\tendDeferredStart,\n\tRESOLVED,\n\tS_COMPLETED,\n\tS_DIRTY,\n\tS_DISCONNECTED,\n\tS_ERRORED,\n\tS_RESOLVED,\n\tS_SETTLED,\n\tSTART,\n\tSTATE,\n\tSTATUS_MASK,\n\tSTATUS_SHIFT,\n} from \"./protocol\";\nimport type { Store, StoreOptions } from \"./types\";\n\n// Flag bits for _flags bitmask (bits 0-6)\nconst D_HAS_CACHED = 1;\nconst D_CONNECTED = 2;\nconst D_ANY_DATA = 4;\nconst D_COMPLETED = 8;\n// bit 4 unused (was D_STANDALONE, then D_RESET — removed: derived get() always pull-computes)\nconst D_MULTI = 32;\nconst D_IDENTITY = 64;\n\n// Pre-shifted status constants for hot-path writes\nconst _S_DISCONNECTED = S_DISCONNECTED << STATUS_SHIFT;\nconst _S_DIRTY = S_DIRTY << STATUS_SHIFT;\nconst _S_SETTLED = S_SETTLED << STATUS_SHIFT;\nconst _S_RESOLVED = S_RESOLVED << STATUS_SHIFT;\nconst _S_COMPLETED = S_COMPLETED << STATUS_SHIFT;\nconst _S_ERRORED = S_ERRORED << STATUS_SHIFT;\nconst _STATUS_MASK = STATUS_MASK;\n\nexport class DerivedImpl<T> {\n\t_output: ((type: number, data?: any) => void) | Set<any> | null = null;\n\t_upstreamTalkbacks: Array<(type: number) => void> = [];\n\t_cachedValue: T | undefined;\n\t_flags: number;\n\t_dirtyDeps!: Bitmask;\n\t_eqFn: ((a: T, b: T) => boolean) | undefined;\n\t_deps: Store<unknown>[];\n\t_fn: () => T;\n\n\tget _status() {\n\t\treturn decodeStatus(this._flags);\n\t}\n\n\tconstructor(deps: Store<unknown>[], fn: () => T, opts?: StoreOptions<T>, identity?: boolean) {\n\t\tthis._deps = deps;\n\t\tthis._fn = fn;\n\t\tthis._eqFn = opts?.equals;\n\t\tthis._flags = identity ? D_IDENTITY : 0;\n\t\t// S_DISCONNECTED = 0, so no need to set status bits\n\t\tthis._dirtyDeps = new Bitmask(deps.length);\n\n\t\tthis.source = this.source.bind(this);\n\n\t\tInspector.register(this as any, { kind: \"derived\", ...opts, deps });\n\t\tfor (const dep of deps) Inspector.registerEdge(dep, this as any);\n\n\t\t// v4.1: Fully lazy — no computation or connection at construction.\n\t}\n\n\t_dispatch(type: number, data?: any): void {\n\t\tconst output = this._output;\n\t\tif (!output) return;\n\t\tif (this._flags & D_MULTI) {\n\t\t\tfor (const sink of output as Set<any>) sink(type, data);\n\t\t} else {\n\t\t\t(output as (type: number, data?: any) => void)(type, data);\n\t\t}\n\t}\n\n\t_recompute(): void {\n\t\tconst result = this._fn();\n\t\tif (this._eqFn && this._flags & D_HAS_CACHED && this._eqFn(this._cachedValue as T, result)) {\n\t\t\tthis._flags = (this._flags & ~_STATUS_MASK) | _S_RESOLVED;\n\t\t\tthis._dispatch(STATE, RESOLVED);\n\t\t\treturn;\n\t\t}\n\t\tthis._cachedValue = result;\n\t\tthis._flags = ((this._flags | D_HAS_CACHED) & ~_STATUS_MASK) | _S_SETTLED;\n\t\tthis._dispatch(DATA, this._cachedValue);\n\t}\n\n\t_recomputeIdentity(data: T): void {\n\t\tif (this._eqFn && this._flags & D_HAS_CACHED && this._eqFn(this._cachedValue as T, data)) {\n\t\t\tthis._flags = (this._flags & ~_STATUS_MASK) | _S_RESOLVED;\n\t\t\tthis._dispatch(STATE, RESOLVED);\n\t\t\treturn;\n\t\t}\n\t\tthis._cachedValue = data;\n\t\tthis._flags = ((this._flags | D_HAS_CACHED) & ~_STATUS_MASK) | _S_SETTLED;\n\t\tthis._dispatch(DATA, data);\n\t}\n\n\t_lazyConnect(): void {\n\t\tif (this._flags & (D_CONNECTED | D_COMPLETED)) return;\n\t\tthis._cachedValue = this._fn();\n\t\tthis._flags = ((this._flags | D_HAS_CACHED) & ~_STATUS_MASK) | _S_SETTLED;\n\t\tbeginDeferredStart();\n\t\tthis._connectUpstream();\n\t\tif (!(this._flags & D_COMPLETED)) {\n\t\t\tthis._flags |= D_CONNECTED;\n\t\t}\n\t\tendDeferredStart();\n\t}\n\n\t_connectUpstream(): void {\n\t\tthis._upstreamTalkbacks = [];\n\t\tif (this._deps.length === 1) {\n\t\t\tif (this._flags & D_IDENTITY) {\n\t\t\t\tthis._connectSingleDepIdentity();\n\t\t\t} else {\n\t\t\t\tthis._connectSingleDep();\n\t\t\t}\n\t\t} else {\n\t\t\tthis._connectMultiDep();\n\t\t}\n\t}\n\n\t/** Single-dep: no bitmask, direct forward (P0 optimization) */\n\t_connectSingleDep(): void {\n\t\tlet dirty = false;\n\t\tthis._deps[0].source(START, (type: number, data: any) => {\n\t\t\tif (type === START) {\n\t\t\t\tthis._upstreamTalkbacks.push(data);\n\t\t\t\treturn;\n\t\t\t}\n\t\t\tif (this._flags & D_COMPLETED) return;\n\n\t\t\tif (type === STATE) {\n\t\t\t\tif (data === DIRTY) {\n\t\t\t\t\tdirty = true;\n\t\t\t\t\tthis._flags = (this._flags & ~_STATUS_MASK) | _S_DIRTY;\n\t\t\t\t\tthis._dispatch(STATE, DIRTY);\n\t\t\t\t} else if (data === RESOLVED) {\n\t\t\t\t\tif (dirty) {\n\t\t\t\t\t\tdirty = false;\n\t\t\t\t\t\tthis._flags = (this._flags & ~_STATUS_MASK) | _S_RESOLVED;\n\t\t\t\t\t\tthis._dispatch(STATE, RESOLVED);\n\t\t\t\t\t}\n\t\t\t\t} else {\n\t\t\t\t\tthis._dispatch(STATE, data);\n\t\t\t\t}\n\t\t\t} else if (type === DATA) {\n\t\t\t\tif (dirty) {\n\t\t\t\t\tdirty = false;\n\t\t\t\t\tthis._recompute();\n\t\t\t\t} else {\n\t\t\t\t\tthis._flags = (this._flags & ~_STATUS_MASK) | _S_DIRTY;\n\t\t\t\t\tthis._dispatch(STATE, DIRTY);\n\t\t\t\t\tthis._recompute();\n\t\t\t\t}\n\t\t\t} else if (type === END) {\n\t\t\t\tthis._handleEnd(data);\n\t\t\t}\n\t\t});\n\t}\n\n\t_connectSingleDepIdentity(): void {\n\t\tlet dirty = false;\n\t\tthis._deps[0].source(START, (type: number, data: any) => {\n\t\t\tif (type === START) {\n\t\t\t\tthis._upstreamTalkbacks.push(data);\n\t\t\t\treturn;\n\t\t\t}\n\t\t\tif (this._flags & D_COMPLETED) return;\n\n\t\t\tif (type === STATE) {\n\t\t\t\tif (data === DIRTY) {\n\t\t\t\t\tdirty = true;\n\t\t\t\t\tthis._flags = (this._flags & ~_STATUS_MASK) | _S_DIRTY;\n\t\t\t\t\tthis._dispatch(STATE, DIRTY);\n\t\t\t\t} else if (data === RESOLVED) {\n\t\t\t\t\tif (dirty) {\n\t\t\t\t\t\tdirty = false;\n\t\t\t\t\t\tthis._flags = (this._flags & ~_STATUS_MASK) | _S_RESOLVED;\n\t\t\t\t\t\tthis._dispatch(STATE, RESOLVED);\n\t\t\t\t\t}\n\t\t\t\t} else {\n\t\t\t\t\tthis._dispatch(STATE, data);\n\t\t\t\t}\n\t\t\t} else if (type === DATA) {\n\t\t\t\tif (dirty) {\n\t\t\t\t\tdirty = false;\n\t\t\t\t\tthis._recomputeIdentity(data);\n\t\t\t\t} else {\n\t\t\t\t\tthis._flags = (this._flags & ~_STATUS_MASK) | _S_DIRTY;\n\t\t\t\t\tthis._dispatch(STATE, DIRTY);\n\t\t\t\t\tthis._recomputeIdentity(data);\n\t\t\t\t}\n\t\t\t} else if (type === END) {\n\t\t\t\tthis._handleEnd(data);\n\t\t\t}\n\t\t});\n\t}\n\n\t/** Multi-dep: bitmask-based diamond resolution */\n\t_connectMultiDep(): void {\n\t\tfor (let i = 0; i < this._deps.length; i++) {\n\t\t\tif (this._flags & D_COMPLETED) break;\n\t\t\tconst depIndex = i;\n\t\t\tthis._deps[depIndex].source(START, (type: number, data: any) => {\n\t\t\t\tif (type === START) {\n\t\t\t\t\tthis._upstreamTalkbacks.push(data);\n\t\t\t\t\treturn;\n\t\t\t\t}\n\t\t\t\tif (this._flags & D_COMPLETED) return;\n\n\t\t\t\tif (type === STATE) {\n\t\t\t\t\tif (data === DIRTY) {\n\t\t\t\t\t\tconst wasEmpty = this._dirtyDeps.empty();\n\t\t\t\t\t\tthis._dirtyDeps.set(depIndex);\n\t\t\t\t\t\tif (wasEmpty) {\n\t\t\t\t\t\t\tthis._flags &= ~D_ANY_DATA;\n\t\t\t\t\t\t\tthis._flags = (this._flags & ~_STATUS_MASK) | _S_DIRTY;\n\t\t\t\t\t\t\tthis._dispatch(STATE, DIRTY);\n\t\t\t\t\t\t}\n\t\t\t\t\t} else if (data === RESOLVED) {\n\t\t\t\t\t\tif (this._dirtyDeps.test(depIndex)) {\n\t\t\t\t\t\t\tthis._dirtyDeps.clear(depIndex);\n\t\t\t\t\t\t\tif (this._dirtyDeps.empty()) {\n\t\t\t\t\t\t\t\tif (this._flags & D_ANY_DATA) {\n\t\t\t\t\t\t\t\t\tthis._recompute();\n\t\t\t\t\t\t\t\t} else {\n\t\t\t\t\t\t\t\t\tthis._flags = (this._flags & ~_STATUS_MASK) | _S_RESOLVED;\n\t\t\t\t\t\t\t\t\tthis._dispatch(STATE, RESOLVED);\n\t\t\t\t\t\t\t\t}\n\t\t\t\t\t\t\t}\n\t\t\t\t\t\t}\n\t\t\t\t\t} else {\n\t\t\t\t\t\tthis._dispatch(STATE, data);\n\t\t\t\t\t}\n\t\t\t\t} else if (type === DATA) {\n\t\t\t\t\tif (this._dirtyDeps.test(depIndex)) {\n\t\t\t\t\t\tthis._dirtyDeps.clear(depIndex);\n\t\t\t\t\t\tthis._flags |= D_ANY_DATA;\n\t\t\t\t\t\tif (this._dirtyDeps.empty()) {\n\t\t\t\t\t\t\tthis._recompute();\n\t\t\t\t\t\t}\n\t\t\t\t\t} else {\n\t\t\t\t\t\tif (this._dirtyDeps.empty()) {\n\t\t\t\t\t\t\tthis._flags = (this._flags & ~_STATUS_MASK) | _S_DIRTY;\n\t\t\t\t\t\t\tthis._dispatch(STATE, DIRTY);\n\t\t\t\t\t\t\tthis._recompute();\n\t\t\t\t\t\t} else {\n\t\t\t\t\t\t\tthis._flags |= D_ANY_DATA;\n\t\t\t\t\t\t}\n\t\t\t\t\t}\n\t\t\t\t} else if (type === END) {\n\t\t\t\t\tthis._handleEnd(data);\n\t\t\t\t}\n\t\t\t});\n\t\t}\n\t}\n\n\t_handleEnd(errorData: any): void {\n\t\tthis._flags |= D_COMPLETED;\n\t\tthis._flags =\n\t\t\t(this._flags & ~_STATUS_MASK) | (errorData !== undefined ? _S_ERRORED : _S_COMPLETED);\n\t\tfor (const tb of this._upstreamTalkbacks) tb(END);\n\t\tthis._upstreamTalkbacks = [];\n\t\tthis._flags &= ~D_CONNECTED;\n\t\tthis._dirtyDeps.reset();\n\t\tconst output = this._output;\n\t\tconst wasMulti = this._flags & D_MULTI;\n\t\tthis._output = null;\n\t\tthis._flags &= ~D_MULTI;\n\t\tif (output) {\n\t\t\tif (wasMulti) {\n\t\t\t\tfor (const sink of output as Set<any>) {\n\t\t\t\t\terrorData !== undefined ? sink(END, errorData) : sink(END);\n\t\t\t\t}\n\t\t\t} else {\n\t\t\t\terrorData !== undefined\n\t\t\t\t\t? (output as (type: number, data?: any) => void)(END, errorData)\n\t\t\t\t\t: (output as (type: number, data?: any) => void)(END);\n\t\t\t}\n\t\t}\n\t}\n\n\t_disconnectUpstream(): void {\n\t\tfor (const tb of this._upstreamTalkbacks) tb(END);\n\t\tthis._upstreamTalkbacks = [];\n\t\tthis._flags &= ~(D_CONNECTED | D_ANY_DATA);\n\t\tthis._flags = (this._flags & ~_STATUS_MASK) | _S_DISCONNECTED;\n\t\tthis._dirtyDeps.reset();\n\t}\n\n\t/**\n\t * v6: Pull-compute when disconnected (always fresh). When connected,\n\t * returns push-updated cache (fast path).\n\t */\n\tget(): T {\n\t\tif (this._flags & D_CONNECTED) {\n\t\t\treturn this._cachedValue as T;\n\t\t}\n\t\tif (this._flags & D_COMPLETED) {\n\t\t\treturn this._cachedValue as T;\n\t\t}\n\t\t// Disconnected: pull-compute from deps\n\t\tconst result = this._fn();\n\t\tthis._cachedValue = result;\n\t\tthis._flags |= D_HAS_CACHED;\n\t\treturn result;\n\t}\n\n\tsource(type: number, payload?: any): void {\n\t\tif (type === START) {\n\t\t\tconst sink = payload;\n\t\t\tif (this._flags & D_COMPLETED) {\n\t\t\t\tsink(START, (_t: number) => {});\n\t\t\t\tsink(END);\n\t\t\t\treturn;\n\t\t\t}\n\n\t\t\tif (!(this._flags & D_CONNECTED)) {\n\t\t\t\tthis._lazyConnect();\n\t\t\t\tif (this._flags & D_COMPLETED) {\n\t\t\t\t\tsink(START, (_t: number) => {});\n\t\t\t\t\tsink(END);\n\t\t\t\t\treturn;\n\t\t\t\t}\n\t\t\t}\n\n\t\t\tif (this._output === null) {\n\t\t\t\tthis._output = sink;\n\t\t\t} else if (!(this._flags & D_MULTI)) {\n\t\t\t\tconst set = new Set<any>();\n\t\t\t\tset.add(this._output);\n\t\t\t\tset.add(sink);\n\t\t\t\tthis._output = set;\n\t\t\t\tthis._flags |= D_MULTI;\n\t\t\t} else {\n\t\t\t\t(this._output as Set<any>).add(sink);\n\t\t\t}\n\n\t\t\tsink(START, (t: number) => {\n\t\t\t\tif (t === DATA) sink(DATA, this._cachedValue);\n\t\t\t\tif (t === END) {\n\t\t\t\t\tif (this._output === null) return;\n\t\t\t\t\tif (this._flags & D_MULTI) {\n\t\t\t\t\t\tconst set = this._output as Set<any>;\n\t\t\t\t\t\tset.delete(sink);\n\t\t\t\t\t\tif (set.size === 1) {\n\t\t\t\t\t\t\tthis._output = set.values().next().value;\n\t\t\t\t\t\t\tthis._flags &= ~D_MULTI;\n\t\t\t\t\t\t} else if (set.size === 0) {\n\t\t\t\t\t\t\tthis._output = null;\n\t\t\t\t\t\t\tthis._flags &= ~D_MULTI;\n\t\t\t\t\t\t\tthis._disconnectUpstream();\n\t\t\t\t\t\t}\n\t\t\t\t\t} else if (this._output === sink) {\n\t\t\t\t\t\tthis._output = null;\n\t\t\t\t\t\tthis._disconnectUpstream();\n\t\t\t\t\t}\n\t\t\t\t}\n\t\t\t});\n\t\t}\n\t}\n}\n\nexport function derived<T>(deps: Store<unknown>[], fn: () => T, opts?: StoreOptions<T>): Store<T> {\n\treturn new DerivedImpl<T>(deps, fn, opts) as any;\n}\n\nexport namespace derived {\n\texport function from<T>(dep: Store<T>, opts?: StoreOptions<T>): Store<T> {\n\t\treturn new DerivedImpl<T>([dep as Store<unknown>], () => dep.get() as any, opts, true) as any;\n\t}\n}\n","/**\n * General-purpose source primitive. Can emit values, send control signals,\n * complete, and error. Lazy start on first sink, auto-cleanup on last\n * sink disconnect.\n *\n * Stateful: maintains currentValue. get() returns currentValue (or\n * getter(currentValue) when getter option is provided).\n *\n * v4: Output slot model replaces _sinks Set. _output is null (no sinks),\n * a function (single sink — P0 optimization), or a Set (multi sink).\n * _status tracks node lifecycle. autoDirty (default true) sends DIRTY on\n * type 3 before each type 1 DATA. equals option guards emit();\n * resetOnTeardown resets value on stop.\n *\n * v5: _status packed into _flags bits 7-9 for hot-path performance.\n * String status exposed via getter for Inspector/test backward compat.\n *\n * Class-based for V8 hidden class optimization and prototype method sharing.\n * Boolean fields packed into _flags bitmask to reduce hidden class size.\n */\n\nimport { Inspector } from \"./inspector\";\nimport type { Signal } from \"./protocol\";\nimport {\n\tDATA,\n\tDIRTY,\n\tdecodeStatus,\n\tdeferEmission,\n\tdeferStart,\n\tEND,\n\tisBatching,\n\tRESOLVED,\n\tS_COMPLETED,\n\tS_DIRTY,\n\tS_DISCONNECTED,\n\tS_ERRORED,\n\tS_RESOLVED,\n\tS_SETTLED,\n\tSTART,\n\tSTATE,\n\tSTATUS_MASK,\n\tSTATUS_SHIFT,\n} from \"./protocol\";\nimport type { ProducerStore, SourceOptions, Store } from \"./types\";\n\nexport type ProducerFn<T> = (actions: {\n\temit: (value: T) => void;\n\tsignal: (s: Signal) => void;\n\tcomplete: () => void;\n\terror: (e: unknown) => void;\n}) => (() => void) | undefined;\n\nexport type ProducerOpts<T> = SourceOptions<T> & {\n\tautoDirty?: boolean;\n\t_skipInspect?: boolean;\n};\n\n// Flag bits for _flags bitmask (bits 0-6)\nconst P_STARTED = 1;\nconst P_MULTI = 64;\n\n// Exported for subclass fast paths (StateImpl)\nexport const P_COMPLETED = 2;\nexport const P_AUTO_DIRTY = 4;\nconst P_RESET = 8;\nconst P_RESUB = 16;\nexport const P_PENDING = 32;\n\n// Status bits (bits 7-9) — exported for StateImpl fast path\nexport const _STATUS_MASK = STATUS_MASK;\nexport const _S_DIRTY = S_DIRTY << STATUS_SHIFT;\nexport const _S_SETTLED = S_SETTLED << STATUS_SHIFT;\nexport const _S_DISCONNECTED = S_DISCONNECTED << STATUS_SHIFT;\nexport const _S_COMPLETED = S_COMPLETED << STATUS_SHIFT;\nexport const _S_ERRORED = S_ERRORED << STATUS_SHIFT;\nexport const _S_RESOLVED = S_RESOLVED << STATUS_SHIFT;\n\nexport class ProducerImpl<T> {\n\t_value: T | undefined;\n\t_output: ((type: number, data?: any) => void) | Set<any> | null = null;\n\t_flags: number;\n\n\tget _status() {\n\t\treturn decodeStatus(this._flags);\n\t}\n\t_cleanup: (() => void) | undefined;\n\t_fn: ProducerFn<T> | undefined;\n\t_eqFn: ((a: T, b: T) => boolean) | undefined;\n\t_getterFn: ((cached: T | undefined) => T) | undefined;\n\t_initial: T | undefined;\n\n\tconstructor(fn?: ProducerFn<T>, opts?: ProducerOpts<T>) {\n\t\tthis._value = opts?.initial;\n\t\tthis._fn = fn;\n\t\tthis._eqFn = opts?.equals;\n\t\tthis._getterFn = opts?.getter;\n\t\tthis._initial = opts?.initial;\n\n\t\tlet flags = 0;\n\t\tif (opts?.autoDirty !== false) flags |= P_AUTO_DIRTY;\n\t\tif (opts?.resetOnTeardown) flags |= P_RESET;\n\t\tif (opts?.resubscribable) flags |= P_RESUB;\n\t\t// S_DISCONNECTED = 0, so no need to set status bits\n\t\tthis._flags = flags;\n\n\t\t// Bind public API methods so they work when detached (callbag interop,\n\t\t// destructuring, etc.). Replaces per-instance closure functions.\n\t\tthis.source = this.source.bind(this);\n\t\tthis.emit = this.emit.bind(this);\n\t\tthis.signal = this.signal.bind(this);\n\t\tthis.complete = this.complete.bind(this);\n\t\tthis.error = this.error.bind(this);\n\n\t\tif (!opts?._skipInspect) Inspector.register(this as any, { kind: \"producer\", ...opts });\n\t}\n\n\tget(): T | undefined {\n\t\treturn this._getterFn ? this._getterFn(this._value) : this._value;\n\t}\n\n\t/**\n\t * Dispatch a signal to all current subscribers via the output slot.\n\t *\n\t * Safety: P_MULTI flag and _output type are always updated together.\n\t * No reentrancy can occur between the two assignments (source() doesn't\n\t * trigger dispatch, and dispatch doesn't trigger source()). The null-check\n\t * provides an additional guard for the MULTI→null transition path.\n\t */\n\t_dispatch(type: number, data?: any): void {\n\t\tconst output = this._output;\n\t\tif (!output) return;\n\t\tif (this._flags & P_MULTI) {\n\t\t\tfor (const sink of output as Set<any>) sink(type, data);\n\t\t} else {\n\t\t\t(output as (type: number, data?: any) => void)(type, data);\n\t\t}\n\t}\n\n\temit(value: T): void {\n\t\tif (this._flags & P_COMPLETED) return;\n\t\tif (this._eqFn && this._value !== undefined && this._eqFn(this._value as T, value)) return;\n\t\tthis._value = value;\n\t\tif (!this._output) return;\n\t\tif (isBatching()) {\n\t\t\tif (!(this._flags & P_PENDING)) {\n\t\t\t\tthis._flags |= P_PENDING;\n\t\t\t\tif (this._flags & P_AUTO_DIRTY) {\n\t\t\t\t\tthis._flags = (this._flags & ~_STATUS_MASK) | _S_DIRTY;\n\t\t\t\t\tthis._dispatch(STATE, DIRTY);\n\t\t\t\t}\n\t\t\t\tdeferEmission(() => {\n\t\t\t\t\tthis._flags &= ~P_PENDING;\n\t\t\t\t\tthis._flags = (this._flags & ~_STATUS_MASK) | _S_SETTLED;\n\t\t\t\t\tthis._dispatch(DATA, this._value);\n\t\t\t\t});\n\t\t\t}\n\t\t} else {\n\t\t\tif (this._flags & P_AUTO_DIRTY) {\n\t\t\t\tthis._flags = (this._flags & ~_STATUS_MASK) | _S_DIRTY;\n\t\t\t\tthis._dispatch(STATE, DIRTY);\n\t\t\t}\n\t\t\tthis._flags = (this._flags & ~_STATUS_MASK) | _S_SETTLED;\n\t\t\tthis._dispatch(DATA, this._value);\n\t\t}\n\t}\n\n\tsignal(s: Signal): void {\n\t\tif (this._flags & P_COMPLETED || !this._output) return;\n\t\tif (s === DIRTY) this._flags = (this._flags & ~_STATUS_MASK) | _S_DIRTY;\n\t\telse if (s === RESOLVED) this._flags = (this._flags & ~_STATUS_MASK) | _S_RESOLVED;\n\t\t// Unknown signals: dispatch without _status change (v4 forward-compat)\n\t\tthis._dispatch(STATE, s);\n\t}\n\n\tcomplete(): void {\n\t\tif (this._flags & P_COMPLETED) return;\n\t\tthis._flags = ((this._flags | P_COMPLETED) & ~_STATUS_MASK) | _S_COMPLETED;\n\t\tconst output = this._output;\n\t\tconst wasMulti = this._flags & P_MULTI;\n\t\tthis._output = null;\n\t\tthis._flags &= ~P_MULTI;\n\t\tthis._stop();\n\t\tif (output) {\n\t\t\tif (wasMulti) {\n\t\t\t\tfor (const sink of output as Set<any>) sink(END);\n\t\t\t} else {\n\t\t\t\t(output as (type: number, data?: any) => void)(END);\n\t\t\t}\n\t\t}\n\t}\n\n\terror(e: unknown): void {\n\t\tif (this._flags & P_COMPLETED) return;\n\t\tthis._flags = ((this._flags | P_COMPLETED) & ~_STATUS_MASK) | _S_ERRORED;\n\t\tconst output = this._output;\n\t\tconst wasMulti = this._flags & P_MULTI;\n\t\tthis._output = null;\n\t\tthis._flags &= ~P_MULTI;\n\t\tthis._stop();\n\t\tif (output) {\n\t\t\tif (wasMulti) {\n\t\t\t\tfor (const sink of output as Set<any>) sink(END, e);\n\t\t\t} else {\n\t\t\t\t(output as (type: number, data?: any) => void)(END, e);\n\t\t\t}\n\t\t}\n\t}\n\n\t_start(): void {\n\t\tif (this._flags & P_STARTED || !this._fn) return;\n\t\tthis._flags |= P_STARTED;\n\t\tconst result = this._fn(this as any);\n\t\tthis._cleanup = typeof result === \"function\" ? result : undefined;\n\t}\n\n\t_stop(): void {\n\t\tif (!(this._flags & P_STARTED)) return;\n\t\tthis._flags &= ~P_STARTED;\n\t\tif (this._cleanup) this._cleanup();\n\t\tthis._cleanup = undefined;\n\t\tif (this._flags & P_RESET) this._value = this._initial;\n\t\tif (!(this._flags & P_COMPLETED)) this._flags = (this._flags & ~_STATUS_MASK) | _S_DISCONNECTED;\n\t}\n\n\tsource(type: number, payload?: any): void {\n\t\tif (type === START) {\n\t\t\tconst sink = payload;\n\t\t\tif (this._flags & P_COMPLETED) {\n\t\t\t\tif (this._flags & P_RESUB && this._output === null) {\n\t\t\t\t\tthis._flags = (this._flags & ~(P_COMPLETED | _STATUS_MASK)) | _S_DISCONNECTED;\n\t\t\t\t} else {\n\t\t\t\t\tsink(START, (_t: number) => {});\n\t\t\t\t\tsink(END);\n\t\t\t\t\treturn;\n\t\t\t\t}\n\t\t\t}\n\t\t\tif (this._output === null) {\n\t\t\t\tthis._output = sink;\n\t\t\t} else if (!(this._flags & P_MULTI)) {\n\t\t\t\tconst set = new Set<any>();\n\t\t\t\tset.add(this._output);\n\t\t\t\tset.add(sink);\n\t\t\t\tthis._output = set;\n\t\t\t\tthis._flags |= P_MULTI;\n\t\t\t} else {\n\t\t\t\t(this._output as Set<any>).add(sink);\n\t\t\t}\n\t\t\tsink(START, (t: number) => {\n\t\t\t\tif (t === DATA) sink(DATA, this._value);\n\t\t\t\tif (t === END) {\n\t\t\t\t\tif (this._output === null) return;\n\t\t\t\t\tif (this._flags & P_MULTI) {\n\t\t\t\t\t\tconst set = this._output as Set<any>;\n\t\t\t\t\t\tset.delete(sink);\n\t\t\t\t\t\tif (set.size === 1) {\n\t\t\t\t\t\t\tthis._output = set.values().next().value;\n\t\t\t\t\t\t\tthis._flags &= ~P_MULTI;\n\t\t\t\t\t\t} else if (set.size === 0) {\n\t\t\t\t\t\t\tthis._output = null;\n\t\t\t\t\t\t\tthis._flags &= ~P_MULTI;\n\t\t\t\t\t\t\tthis._flags = (this._flags & ~_STATUS_MASK) | _S_DISCONNECTED;\n\t\t\t\t\t\t\tthis._stop();\n\t\t\t\t\t\t}\n\t\t\t\t\t} else if (this._output === sink) {\n\t\t\t\t\t\tthis._output = null;\n\t\t\t\t\t\tthis._flags = (this._flags & ~_STATUS_MASK) | _S_DISCONNECTED;\n\t\t\t\t\t\tthis._stop();\n\t\t\t\t\t}\n\t\t\t\t}\n\t\t\t});\n\t\t\tdeferStart(() => this._start());\n\t\t}\n\t}\n}\n\nexport function producer<T>(\n\tfn: ProducerFn<T> | undefined,\n\topts: ProducerOpts<T> & { initial: T },\n): ProducerStore<T> & Store<T>;\nexport function producer<T>(fn?: ProducerFn<T>, opts?: ProducerOpts<T>): ProducerStore<T>;\nexport function producer<T>(fn?: ProducerFn<T>, opts?: ProducerOpts<T>): ProducerStore<T> {\n\treturn new ProducerImpl<T>(fn, opts) as any;\n}\n","/**\n * A writable store, subclass of ProducerImpl.\n * Adds set()/update() API and defaults equals to Object.is.\n *\n * v5: _status packed into _flags bits 7-9 (inherited from ProducerImpl).\n * set() fast path uses pre-shifted status constants for zero-overhead writes.\n */\n\nimport { Inspector } from \"./inspector\";\nimport {\n\t_S_DIRTY,\n\t_S_SETTLED,\n\t_STATUS_MASK,\n\tP_AUTO_DIRTY,\n\tP_COMPLETED,\n\tP_PENDING,\n\tProducerImpl,\n} from \"./producer\";\nimport { DATA, DIRTY, deferEmission, isBatching, STATE } from \"./protocol\";\nimport type { StoreOptions, WritableStore } from \"./types\";\n\nexport class StateImpl<T> extends ProducerImpl<T> {\n\tconstructor(initial: T, opts?: StoreOptions<T>) {\n\t\tsuper(undefined, {\n\t\t\tinitial,\n\t\t\tautoDirty: true,\n\t\t\tequals: opts?.equals ?? Object.is,\n\t\t\t_skipInspect: true,\n\t\t});\n\t\tthis.set = this.set.bind(this);\n\t\tInspector.register(this as any, { kind: \"state\", ...opts });\n\t}\n\n\toverride get(): T {\n\t\treturn this._value as T;\n\t}\n\n\t/**\n\t * Fast path: inlines ProducerImpl.emit() to skip the bound method call.\n\t * For no-subscriber writes, this is just an equals check + value assign.\n\t * Status writes use pre-shifted integer constants (bits 7-9 of _flags).\n\t */\n\tset(value: T): void {\n\t\tif (this._flags & P_COMPLETED) return;\n\t\tif (this._value !== undefined && this._eqFn!(this._value as T, value)) return;\n\t\tthis._value = value;\n\t\tif (!this._output) return;\n\t\tif (isBatching()) {\n\t\t\tif (!(this._flags & P_PENDING)) {\n\t\t\t\tthis._flags |= P_PENDING;\n\t\t\t\tif (this._flags & P_AUTO_DIRTY) {\n\t\t\t\t\tthis._flags = (this._flags & ~_STATUS_MASK) | _S_DIRTY;\n\t\t\t\t\tthis._dispatch(STATE, DIRTY);\n\t\t\t\t}\n\t\t\t\tdeferEmission(() => {\n\t\t\t\t\tthis._flags &= ~P_PENDING;\n\t\t\t\t\tthis._flags = (this._flags & ~_STATUS_MASK) | _S_SETTLED;\n\t\t\t\t\tthis._dispatch(DATA, this._value);\n\t\t\t\t});\n\t\t\t}\n\t\t} else {\n\t\t\tif (this._flags & P_AUTO_DIRTY) {\n\t\t\t\tthis._flags = (this._flags & ~_STATUS_MASK) | _S_DIRTY;\n\t\t\t\tthis._dispatch(STATE, DIRTY);\n\t\t\t}\n\t\t\tthis._flags = (this._flags & ~_STATUS_MASK) | _S_SETTLED;\n\t\t\tthis._dispatch(DATA, this._value);\n\t\t}\n\t}\n\n\tupdate(fn: (current: T) => T): void {\n\t\tthis.set(fn(this._value as T));\n\t}\n}\n\nexport function state<T>(initial: T, opts?: StoreOptions<T>): WritableStore<T> {\n\treturn new StateImpl<T>(initial, opts) as any;\n}\n","/**\n * Core subscribe — reusable callbag sink connector.\n *\n * Used as the base for:\n * - External subscribe (extra/subscribe re-exports this)\n * - Derived's dep connections (STANDALONE mode)\n * - Effect's dep connections\n *\n * v4: Handles callbag START handshake, filters STATE for user callbacks,\n * provides prev-value tracking. Returns unsub function.\n */\n\nimport { beginDeferredStart, END, endDeferredStart, START } from \"./protocol\";\nimport type { Store } from \"./types\";\n\nexport function subscribe<T>(\n\tstore: Store<T>,\n\tcb: (value: T, prev: T | undefined) => void,\n\topts?: { onEnd?: (error?: unknown) => void },\n): () => void {\n\tlet talkback: ((type: number) => void) | null = null;\n\n\tbeginDeferredStart();\n\n\t// `prev` is declared after store.source() but the closure only reads it\n\t// after endDeferredStart() triggers producers. By that point prev is already\n\t// set to store.get(). Order: register sink → read baseline → start producers.\n\tstore.source(START, (type: number, data: any) => {\n\t\tif (type === START) talkback = data;\n\t\tif (type === END) {\n\t\t\ttalkback = null;\n\t\t\topts?.onEnd?.(data);\n\t\t\treturn;\n\t\t}\n\t\t// Transparent sink — forwards every DATA to the callback.\n\t\t// Dedup (if desired) belongs in the source (state's equals) or in\n\t\t// an explicit operator (distinctUntilChanged), not here.\n\t\tif (type === 1 /* DATA */) {\n\t\t\tconst next = data as T;\n\t\t\tconst p = prev;\n\t\t\tprev = next;\n\t\t\tcb(next, p);\n\t\t}\n\t});\n\n\t// Baseline: captures current value before producers start. Aligns with\n\t// RxJS Observable semantics — no initial-value callback on subscribe.\n\tlet prev: T | undefined = store.get();\n\n\tendDeferredStart();\n\n\treturn () => talkback?.(END);\n}\n"],"mappings":"ubAAA,IAAAA,GAAA,GAAAC,GAAAD,GAAA,WAAAE,GAAA,gBAAAC,GAAA,aAAAC,KAAA,eAAAC,GAAAL,ICeO,IAAMM,EAAN,KAAc,CAEpB,GAEA,GAEA,YAAYC,EAAc,CACzB,KAAK,GAAK,EACV,KAAK,GAAKA,EAAO,GAAK,IAAI,aAAcA,EAAO,IAAO,GAAK,CAAC,EAAI,IACjE,CAEA,IAAIC,EAAiB,CACpB,IAAMC,EAAI,KAAK,GACf,GAAIA,IAAM,KACT,KAAK,IAAM,GAAKD,MACV,CACN,IAAME,EAAMF,IAAM,EACZG,EAAM,IAAMH,EAAI,IAChBC,EAAEC,CAAG,EAAIC,IACdF,EAAEC,CAAG,GAAKC,EACV,KAAK,KAEP,CACD,CAEA,MAAMH,EAAiB,CACtB,IAAMC,EAAI,KAAK,GACf,GAAIA,IAAM,KACT,KAAK,IAAM,EAAE,GAAKD,OACZ,CACN,IAAME,EAAMF,IAAM,EACZG,EAAM,IAAMH,EAAI,IAClBC,EAAEC,CAAG,EAAIC,IACZF,EAAEC,CAAG,GAAK,CAACC,EACX,KAAK,KAEP,CACD,CAEA,KAAKH,EAAoB,CACxB,IAAMC,EAAI,KAAK,GACf,OAAIA,IAAM,MAAc,KAAK,GAAM,GAAKD,KAAQ,GACxCC,EAAED,IAAM,CAAC,EAAK,IAAMA,EAAI,OAAU,CAC3C,CAGA,OAAiB,CAChB,OAAO,KAAK,KAAO,CACpB,CAEA,OAAc,CACb,KAAK,GAAK,EACV,KAAK,IAAI,KAAK,CAAC,CAChB,CACD,EC7DO,IAAMI,EAAQ,OAAO,OAAO,EAGtBC,EAAW,OAAO,UAAU,EAiB5BC,EAAiB,EACjBC,EAAU,EACVC,EAAY,EACZC,EAAa,EAC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,SA9ByC,CAACI,EAASC,IAAY,CAC/DF,EAAIC,EAASC,CAAO,CACrB,EA6BC,SA3ByC,IAAMN,EAAQ,IAAI,EA4B3D,gBA1BuD,IAAMY,EA2B7D,UAzBiDE,GAC1CC,GAAcf,EAAoB,CAACgB,EAAOT,IAAS,CACzDO,EAASE,EAAOT,CAAS,CAC1B,CAAC,EAuBD,OAlBc,CAAIU,EAA2BC,IACtCC,GAAQ,CAACnB,CAAkB,EAAG,IAAMiB,EAASjB,EAAQ,IAAI,CAAM,EAAG,CACxE,OAAQkB,GAAW,OAAO,EAC3B,CAAC,EAgBD,MAAOlB,EACP,QAXe,IAAM,CACrBoB,GAASpB,CAAO,CACjB,CAUA,CACD","names":["createStore_exports","__export","batch","createStore","teardown","__toCommonJS","Bitmask","size","i","w","idx","bit","DIRTY","RESOLVED","S_DISCONNECTED","S_DIRTY","S_SETTLED","S_RESOLVED","S_COMPLETED","S_ERRORED","STATUS_SHIFT","STATUS_MASK","STATUS_STRINGS","decodeStatus","flags","START","DATA","END","STATE","batchDepth","deferredEmissions","draining","batch","fn","i","isBatching","deferEmission","connectDepth","pendingStarts","beginDeferredStart","endDeferredStart","deferStart","start","teardown","store","node","Inspector","_Inspector","value","deps","joined","d","node","opts","id","key","depSuffix","kind","parent","child","parentKey","childKey","children","result","livingKeys","ref","alive","c","store","cb","talkback","prev","START","type","data","END","next","p","g","edges","depsMap","lines","info","depsStr","childStr","label","log","name","DATA","STATE","DIRTY","RESOLVED","tapName","wrapper","edgeMap","nodes","D_HAS_CACHED","D_CONNECTED","D_ANY_DATA","D_COMPLETED","D_MULTI","D_IDENTITY","_S_DISCONNECTED","S_DISCONNECTED","STATUS_SHIFT","_S_DIRTY","S_DIRTY","_S_SETTLED","S_SETTLED","_S_RESOLVED","S_RESOLVED","_S_COMPLETED","S_COMPLETED","_S_ERRORED","S_ERRORED","_STATUS_MASK","STATUS_MASK","DerivedImpl","decodeStatus","deps","fn","opts","identity","Bitmask","Inspector","dep","type","data","output","sink","result","STATE","RESOLVED","DATA","beginDeferredStart","endDeferredStart","dirty","START","DIRTY","END","i","depIndex","wasEmpty","errorData","tb","wasMulti","payload","_t","set","t","derived","from","P_STARTED","P_MULTI","P_COMPLETED","P_AUTO_DIRTY","P_RESET","P_RESUB","P_PENDING","_STATUS_MASK","STATUS_MASK","_S_DIRTY","S_DIRTY","STATUS_SHIFT","_S_SETTLED","S_SETTLED","_S_DISCONNECTED","S_DISCONNECTED","_S_COMPLETED","S_COMPLETED","_S_ERRORED","S_ERRORED","_S_RESOLVED","S_RESOLVED","ProducerImpl","decodeStatus","fn","opts","flags","Inspector","type","data","output","sink","value","isBatching","STATE","DIRTY","deferEmission","DATA","s","RESOLVED","wasMulti","END","e","result","payload","START","_t","set","t","deferStart","StateImpl","ProducerImpl","initial","opts","Inspector","value","P_COMPLETED","isBatching","P_PENDING","P_AUTO_DIRTY","_STATUS_MASK","_S_DIRTY","STATE","DIRTY","deferEmission","_S_SETTLED","DATA","fn","state","subscribe","store","cb","opts","talkback","beginDeferredStart","START","type","data","END","next","p","prev","endDeferredStart","createStore","initializer","source","initialState","actionKeys","get","set","partial","replace","prev","nextPartial","nextState","key","k","frozenInitial","state","listener","subscribe","value","selector","equals","derived","teardown"]}
@@ -0,0 +1,55 @@
1
+ import { S as Store, W as WritableStore } from '../../types-DsAN6Hga.cjs';
2
+ export { c as batch, t as teardown } from '../../types-DsAN6Hga.cjs';
3
+
4
+ /**
5
+ * createStore — single-store pattern for Zustand/Redux users.
6
+ *
7
+ * Provides a familiar `create((set, get) => ({ ...state, ...actions }))` API
8
+ * backed by callbag-recharge primitives. Key advantage over Zustand:
9
+ * diamond-safe `select()` returns a `Store<U>` with automatic memoization
10
+ * and dependency tracking — no reselect, no useShallow.
11
+ *
12
+ * Zustand StoreApi compatibility: matches `getState`, `setState`, `subscribe`,
13
+ * `getInitialState` — Zustand middleware (persist, devtools, immer) can wrap
14
+ * this store directly.
15
+ */
16
+
17
+ type SetStateAction<T> = T | Partial<T> | ((state: T) => T | Partial<T>);
18
+ type Get<T> = () => T;
19
+ type Set<T> = (partial: SetStateAction<T>, replace?: boolean) => void;
20
+ type StateCreator<T> = (set: Set<T>, get: Get<T>) => T;
21
+ /**
22
+ * Zustand-compatible StoreApi — middleware works if you match this contract.
23
+ */
24
+ interface StoreApi<T> {
25
+ setState: (partial: SetStateAction<T>, replace?: boolean) => void;
26
+ getState: () => T;
27
+ getInitialState: () => T;
28
+ subscribe: (listener: (state: T, prevState: T) => void) => () => void;
29
+ }
30
+ interface CreateStoreResult<T> extends StoreApi<T> {
31
+ /**
32
+ * Create a diamond-safe derived store from a selector function.
33
+ * Returns a `Store<U>` that only recomputes when the selected value
34
+ * actually changes (push-phase memoization via `equals`).
35
+ *
36
+ * This is the killer feature over Zustand — selectors are reactive stores
37
+ * with automatic memoization, not just functions re-evaluated on every render.
38
+ */
39
+ select<U>(selector: (state: T) => U, equals?: (a: U, b: U) => boolean): Store<U>;
40
+ /**
41
+ * The underlying callbag-recharge WritableStore.
42
+ * Use this to compose with other callbag-recharge primitives
43
+ * (derived, effect, pipe, operators).
44
+ */
45
+ store: WritableStore<T>;
46
+ /**
47
+ * Destroy the store — sends END to all downstream subscribers and derived
48
+ * stores, cascading through the entire subgraph. After destroy, the store
49
+ * is in COMPLETED state and won't accept new values or subscriptions.
50
+ */
51
+ destroy: () => void;
52
+ }
53
+ declare function createStore<T extends object>(initializer: StateCreator<T>): CreateStoreResult<T>;
54
+
55
+ export { type CreateStoreResult, type SetStateAction, type StateCreator, type StoreApi, createStore };
@@ -0,0 +1,55 @@
1
+ import { S as Store, W as WritableStore } from '../../types-DsAN6Hga.js';
2
+ export { c as batch, t as teardown } from '../../types-DsAN6Hga.js';
3
+
4
+ /**
5
+ * createStore — single-store pattern for Zustand/Redux users.
6
+ *
7
+ * Provides a familiar `create((set, get) => ({ ...state, ...actions }))` API
8
+ * backed by callbag-recharge primitives. Key advantage over Zustand:
9
+ * diamond-safe `select()` returns a `Store<U>` with automatic memoization
10
+ * and dependency tracking — no reselect, no useShallow.
11
+ *
12
+ * Zustand StoreApi compatibility: matches `getState`, `setState`, `subscribe`,
13
+ * `getInitialState` — Zustand middleware (persist, devtools, immer) can wrap
14
+ * this store directly.
15
+ */
16
+
17
+ type SetStateAction<T> = T | Partial<T> | ((state: T) => T | Partial<T>);
18
+ type Get<T> = () => T;
19
+ type Set<T> = (partial: SetStateAction<T>, replace?: boolean) => void;
20
+ type StateCreator<T> = (set: Set<T>, get: Get<T>) => T;
21
+ /**
22
+ * Zustand-compatible StoreApi — middleware works if you match this contract.
23
+ */
24
+ interface StoreApi<T> {
25
+ setState: (partial: SetStateAction<T>, replace?: boolean) => void;
26
+ getState: () => T;
27
+ getInitialState: () => T;
28
+ subscribe: (listener: (state: T, prevState: T) => void) => () => void;
29
+ }
30
+ interface CreateStoreResult<T> extends StoreApi<T> {
31
+ /**
32
+ * Create a diamond-safe derived store from a selector function.
33
+ * Returns a `Store<U>` that only recomputes when the selected value
34
+ * actually changes (push-phase memoization via `equals`).
35
+ *
36
+ * This is the killer feature over Zustand — selectors are reactive stores
37
+ * with automatic memoization, not just functions re-evaluated on every render.
38
+ */
39
+ select<U>(selector: (state: T) => U, equals?: (a: U, b: U) => boolean): Store<U>;
40
+ /**
41
+ * The underlying callbag-recharge WritableStore.
42
+ * Use this to compose with other callbag-recharge primitives
43
+ * (derived, effect, pipe, operators).
44
+ */
45
+ store: WritableStore<T>;
46
+ /**
47
+ * Destroy the store — sends END to all downstream subscribers and derived
48
+ * stores, cascading through the entire subgraph. After destroy, the store
49
+ * is in COMPLETED state and won't accept new values or subscriptions.
50
+ */
51
+ destroy: () => void;
52
+ }
53
+ declare function createStore<T extends object>(initializer: StateCreator<T>): CreateStoreResult<T>;
54
+
55
+ export { type CreateStoreResult, type SetStateAction, type StateCreator, type StoreApi, createStore };
@@ -0,0 +1,2 @@
1
+ import{a as b}from"../../chunk-IZ5GFMMK.js";import{a as p}from"../../chunk-K7VPCAZD.js";import"../../chunk-PYRVYHZG.js";import{a as u}from"../../chunk-OHGZIPRU.js";import"../../chunk-LM26JNAK.js";import"../../chunk-7WTS4C5R.js";import{p as d,v as l}from"../../chunk-QYUTDL4D.js";function P(f){let t=null,a,S=[],T=()=>t?t.get():a,c=(e,o)=>{let r=T(),s=typeof e=="function"?e(r):e;if(s===r&&!o)return;if(o){t?t.set(s):a=s;return}let i=Object.assign({},r,s);for(let n of S)Object.hasOwn(s,n)||(i[n]=r[n]);t?t.set(i):a=i};a=f(c,T),S=Object.keys(a).filter(e=>typeof a[e]=="function");let y=a;return t=p(a,{name:"createStore"}),{setState:(e,o)=>{c(e,o)},getState:()=>t.get(),getInitialState:()=>y,subscribe:e=>u(t,(o,r)=>{e(o,r)}),select:(e,o)=>b([t],()=>e(t.get()),{equals:o??Object.is}),store:t,destroy:()=>{l(t)}}}export{d as batch,P as createStore,l as teardown};
2
+ //# sourceMappingURL=index.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"sources":["../../../src/patterns/createStore/index.ts"],"sourcesContent":["/**\n * createStore — single-store pattern for Zustand/Redux users.\n *\n * Provides a familiar `create((set, get) => ({ ...state, ...actions }))` API\n * backed by callbag-recharge primitives. Key advantage over Zustand:\n * diamond-safe `select()` returns a `Store<U>` with automatic memoization\n * and dependency tracking — no reselect, no useShallow.\n *\n * Zustand StoreApi compatibility: matches `getState`, `setState`, `subscribe`,\n * `getInitialState` — Zustand middleware (persist, devtools, immer) can wrap\n * this store directly.\n */\n\nimport { derived } from \"../../core/derived\";\nimport { batch, teardown } from \"../../core/protocol\";\nimport { state } from \"../../core/state\";\nimport { subscribe as coreSubscribe } from \"../../core/subscribe\";\nimport type { Store, WritableStore } from \"../../core/types\";\n\n// ---------------------------------------------------------------------------\n// Types\n// ---------------------------------------------------------------------------\n\ntype SetStateAction<T> = T | Partial<T> | ((state: T) => T | Partial<T>);\n\ntype Get<T> = () => T;\ntype Set<T> = (partial: SetStateAction<T>, replace?: boolean) => void;\n\ntype StateCreator<T> = (set: Set<T>, get: Get<T>) => T;\n\n/**\n * Zustand-compatible StoreApi — middleware works if you match this contract.\n */\ninterface StoreApi<T> {\n\tsetState: (partial: SetStateAction<T>, replace?: boolean) => void;\n\tgetState: () => T;\n\tgetInitialState: () => T;\n\tsubscribe: (listener: (state: T, prevState: T) => void) => () => void;\n}\n\ninterface CreateStoreResult<T> extends StoreApi<T> {\n\t/**\n\t * Create a diamond-safe derived store from a selector function.\n\t * Returns a `Store<U>` that only recomputes when the selected value\n\t * actually changes (push-phase memoization via `equals`).\n\t *\n\t * This is the killer feature over Zustand — selectors are reactive stores\n\t * with automatic memoization, not just functions re-evaluated on every render.\n\t */\n\tselect<U>(selector: (state: T) => U, equals?: (a: U, b: U) => boolean): Store<U>;\n\n\t/**\n\t * The underlying callbag-recharge WritableStore.\n\t * Use this to compose with other callbag-recharge primitives\n\t * (derived, effect, pipe, operators).\n\t */\n\tstore: WritableStore<T>;\n\n\t/**\n\t * Destroy the store — sends END to all downstream subscribers and derived\n\t * stores, cascading through the entire subgraph. After destroy, the store\n\t * is in COMPLETED state and won't accept new values or subscriptions.\n\t */\n\tdestroy: () => void;\n}\n\n// ---------------------------------------------------------------------------\n// createStore\n// ---------------------------------------------------------------------------\n\nexport function createStore<T extends object>(initializer: StateCreator<T>): CreateStoreResult<T> {\n\t// --- Phase 1: initialization ---\n\t// `source` doesn't exist yet. get()/set() use `initialState` directly.\n\t// source is `let` so set() during the initializer doesn't throw.\n\tlet source: WritableStore<T> | null = null;\n\tlet initialState: T = undefined as unknown as T;\n\n\t// Action keys cached once after init (not recomputed per set()).\n\t// Starts empty — set() during init skips action preservation (no actions yet).\n\tlet actionKeys: string[] = [];\n\n\tconst get: Get<T> = () => (source ? (source.get() as T) : initialState);\n\n\tconst set: Set<T> = (partial, replace) => {\n\t\tconst prev = get();\n\t\tconst nextPartial =\n\t\t\ttypeof partial === \"function\" ? (partial as (s: T) => T | Partial<T>)(prev) : partial;\n\n\t\t// No-op early return — avoids unnecessary allocation\n\t\tif (nextPartial === prev && !replace) return;\n\n\t\t// replace=true replaces the entire state, no action preservation.\n\t\tif (replace) {\n\t\t\tif (source) source.set(nextPartial as T);\n\t\t\telse initialState = nextPartial as T;\n\t\t\treturn;\n\t\t}\n\n\t\tconst nextState = Object.assign({}, prev, nextPartial) as T;\n\n\t\t// Preserve action references not explicitly overwritten.\n\t\tfor (const key of actionKeys) {\n\t\t\tif (!Object.hasOwn(nextPartial as object, key)) {\n\t\t\t\t(nextState as any)[key] = (prev as any)[key];\n\t\t\t}\n\t\t}\n\n\t\tif (source) source.set(nextState);\n\t\telse initialState = nextState;\n\t};\n\n\t// Run initializer — may call set()/get() during execution.\n\t// get() returns `initialState` (starts as undefined, updated by any\n\t// set() calls during init). This matches Zustand's behavior.\n\tinitialState = initializer(set, get);\n\n\t// Cache action keys once after init\n\tactionKeys = Object.keys(initialState).filter(\n\t\t(k) => typeof (initialState as any)[k] === \"function\",\n\t);\n\n\t// Snapshot for getInitialState() — frozen reference to the original state\n\tconst frozenInitial = initialState;\n\n\t// --- Phase 2: reactive backing store ---\n\t// After this point, `source` is set and get()/set() delegate to it.\n\tsource = state<T>(initialState, { name: \"createStore\" });\n\n\t// -- StoreApi methods --\n\t// coreSubscribe is a lightweight sink (no graph node allocation, no\n\t// Inspector registration). effect() would work but creates an unnecessary\n\t// store node — we just need \"call me when values change\".\n\n\tconst setState: StoreApi<T>[\"setState\"] = (partial, replace) => {\n\t\tset(partial, replace);\n\t};\n\n\tconst getState: StoreApi<T>[\"getState\"] = () => source!.get() as T;\n\n\tconst getInitialState: StoreApi<T>[\"getInitialState\"] = () => frozenInitial;\n\n\tconst storeSubscribe: StoreApi<T>[\"subscribe\"] = (listener) => {\n\t\treturn coreSubscribe(source as Store<T>, (value, prev) => {\n\t\t\tlistener(value, prev as T);\n\t\t});\n\t};\n\n\t// -- Select: the killer feature --\n\n\tconst select = <U>(selector: (state: T) => U, equals?: (a: U, b: U) => boolean): Store<U> => {\n\t\treturn derived([source as Store<T>], () => selector(source!.get() as T), {\n\t\t\tequals: equals ?? (Object.is as (a: U, b: U) => boolean),\n\t\t});\n\t};\n\n\t// destroy() uses protocol-level teardown — sends END to all downstream\n\t// sinks (subscribers, select()-derived stores), cascading through the\n\t// entire subgraph.\n\tconst destroy = () => {\n\t\tteardown(source!);\n\t};\n\n\treturn {\n\t\tsetState,\n\t\tgetState,\n\t\tgetInitialState,\n\t\tsubscribe: storeSubscribe,\n\t\tselect,\n\t\tstore: source,\n\t\tdestroy,\n\t};\n}\n\nexport { batch, teardown };\nexport type { StoreApi, CreateStoreResult, StateCreator, SetStateAction };\n"],"mappings":"uRAsEO,SAASA,EAA8BC,EAAoD,CAIjG,IAAIC,EAAkC,KAClCC,EAIAC,EAAuB,CAAC,EAEtBC,EAAc,IAAOH,EAAUA,EAAO,IAAI,EAAUC,EAEpDG,EAAc,CAACC,EAASC,IAAY,CACzC,IAAMC,EAAOJ,EAAI,EACXK,EACL,OAAOH,GAAY,WAAcA,EAAqCE,CAAI,EAAIF,EAG/E,GAAIG,IAAgBD,GAAQ,CAACD,EAAS,OAGtC,GAAIA,EAAS,CACRN,EAAQA,EAAO,IAAIQ,CAAgB,EAClCP,EAAeO,EACpB,MACD,CAEA,IAAMC,EAAY,OAAO,OAAO,CAAC,EAAGF,EAAMC,CAAW,EAGrD,QAAWE,KAAOR,EACZ,OAAO,OAAOM,EAAuBE,CAAG,IAC3CD,EAAkBC,CAAG,EAAKH,EAAaG,CAAG,GAIzCV,EAAQA,EAAO,IAAIS,CAAS,EAC3BR,EAAeQ,CACrB,EAKAR,EAAeF,EAAYK,EAAKD,CAAG,EAGnCD,EAAa,OAAO,KAAKD,CAAY,EAAE,OACrCU,GAAM,OAAQV,EAAqBU,CAAC,GAAM,UAC5C,EAGA,IAAMC,EAAgBX,EAItB,OAAAD,EAASa,EAASZ,EAAc,CAAE,KAAM,aAAc,CAAC,EAoChD,CACN,SA9ByC,CAACI,EAASC,IAAY,CAC/DF,EAAIC,EAASC,CAAO,CACrB,EA6BC,SA3ByC,IAAMN,EAAQ,IAAI,EA4B3D,gBA1BuD,IAAMY,EA2B7D,UAzBiDE,GAC1CC,EAAcf,EAAoB,CAACgB,EAAOT,IAAS,CACzDO,EAASE,EAAOT,CAAS,CAC1B,CAAC,EAuBD,OAlBc,CAAIU,EAA2BC,IACtCC,EAAQ,CAACnB,CAAkB,EAAG,IAAMiB,EAASjB,EAAQ,IAAI,CAAM,EAAG,CACxE,OAAQkB,GAAW,OAAO,EAC3B,CAAC,EAgBD,MAAOlB,EACP,QAXe,IAAM,CACrBoB,EAASpB,CAAO,CACjB,CAUA,CACD","names":["createStore","initializer","source","initialState","actionKeys","get","set","partial","replace","prev","nextPartial","nextState","key","k","frozenInitial","state","listener","subscribe","value","selector","equals","derived","teardown"]}
@@ -0,0 +1,192 @@
1
+ import { S as Store } from './types-DsAN6Hga.cjs';
2
+ import { E as EvictionPolicy } from './eviction-DGPP1vHP.cjs';
3
+
4
+ type KVEventType = "set" | "delete" | "clear";
5
+ interface KVEvent<V> {
6
+ type: KVEventType;
7
+ key?: string;
8
+ value?: V;
9
+ }
10
+ interface ReactiveMap<V> extends NodeV0 {
11
+ /** Point read — O(1), ~10ns */
12
+ get(key: string): V | undefined;
13
+ /** Point write — O(1), ~50ns */
14
+ set(key: string, value: V): void;
15
+ /** Delete a key. Returns true if the key existed. */
16
+ delete(key: string): boolean;
17
+ /** Check if a key exists. */
18
+ has(key: string): boolean;
19
+ /** Atomic read-modify-write. */
20
+ update(key: string, fn: (current: V | undefined) => V): void;
21
+ /** Get existing value or create with factory. */
22
+ getOrSet(key: string, factory: () => V): V;
23
+ /** Get all keys (snapshot). */
24
+ keys(): string[];
25
+ /** Get all values (snapshot). */
26
+ values(): V[];
27
+ /** Get all entries (snapshot). */
28
+ entries(): [string, V][];
29
+ /** Current number of keys. */
30
+ size(): number;
31
+ /** Clear all keys. */
32
+ clear(): void;
33
+ /** Set multiple keys atomically (single DIRTY cycle). */
34
+ setMany(entries: Record<string, V> | [string, V][]): void;
35
+ /** Cached read-only reactive view of a key. Auto-cleaned on delete. */
36
+ select(key: string): Store<V | undefined>;
37
+ /** Reactive store of all current keys. Version-gated, lazy materialization. */
38
+ keysStore: Store<string[]>;
39
+ /** Reactive store of current size. */
40
+ sizeStore: Store<number>;
41
+ /** Reactive filtered view. */
42
+ where(pred: (value: V, key: string) => boolean): Store<[string, V][]>;
43
+ /** Set a key with a time-to-live in milliseconds. */
44
+ setWithTTL(key: string, value: V, ttlMs: number): void;
45
+ /** Get remaining TTL in ms. undefined if no TTL. */
46
+ ttl(key: string): number | undefined;
47
+ /** Remove TTL from a key, keeping the key alive. */
48
+ persist(key: string): void;
49
+ /** Keyspace notification store. Zero cost if unsubscribed. */
50
+ events: Store<KVEvent<V> | undefined>;
51
+ /** Virtual partitioning via key prefix. */
52
+ namespace(prefix: string): ReactiveMap<V>;
53
+ /** Return a JSON-serializable snapshot of the map. */
54
+ snapshot(): MapSnapshot<V>;
55
+ /** Tear down all stores and timers. */
56
+ destroy(): void;
57
+ }
58
+ interface ReactiveMapOptions<V> {
59
+ /** User-specified ID. Auto-generated if omitted. */
60
+ id?: string;
61
+ /** Default TTL in milliseconds for all keys. 0 = no expiry (default). */
62
+ defaultTTL?: number;
63
+ /** Custom equality function for value deduplication. Default: Object.is */
64
+ equals?: (a: V, b: V) => boolean;
65
+ /** Maximum number of keys. When exceeded, oldest keys are evicted (FIFO). */
66
+ maxSize?: number;
67
+ /** Eviction policy. Default: fifo(). Only used when maxSize > 0. */
68
+ eviction?: EvictionPolicy<string>;
69
+ }
70
+ interface LogEntry<V> {
71
+ /** Monotonically increasing sequence number (1-based). */
72
+ seq: number;
73
+ value: V;
74
+ }
75
+ type LogEventType = "append" | "clear";
76
+ interface LogEvent<V> {
77
+ type: LogEventType;
78
+ seq?: number;
79
+ value?: V;
80
+ }
81
+ interface ReactiveLog<V> extends NodeV0 {
82
+ /** Append a value. Returns the assigned sequence number. */
83
+ append(value: V): number;
84
+ /** Batch append. Returns sequence numbers. */
85
+ appendMany(values: V[]): number[];
86
+ /** Point read by sequence number — O(1). */
87
+ get(seq: number): LogEntry<V> | undefined;
88
+ /** Range read by sequence number (inclusive). */
89
+ slice(from?: number, to?: number): LogEntry<V>[];
90
+ /** Snapshot of all entries. */
91
+ toArray(): LogEntry<V>[];
92
+ /** Current number of entries. */
93
+ readonly length: number;
94
+ /** Sequence number of the oldest entry still in the log. 0 if empty. */
95
+ readonly headSeq: number;
96
+ /** Sequence number of the newest entry. 0 if empty. */
97
+ readonly tailSeq: number;
98
+ /** Reactive count of entries. */
99
+ lengthStore: Store<number>;
100
+ /** Reactive store of the most recent entry. */
101
+ latest: Store<LogEntry<V> | undefined>;
102
+ /** Reactive store of the last N entries (default: all). */
103
+ tail(n?: number): Store<LogEntry<V>[]>;
104
+ /** Event notification store. Zero cost if unsubscribed. */
105
+ events: Store<LogEvent<V> | undefined>;
106
+ /** Return a JSON-serializable snapshot of the log. */
107
+ snapshot(): LogSnapshot<V>;
108
+ /** Remove all entries. */
109
+ clear(): void;
110
+ /** Tear down all stores. */
111
+ destroy(): void;
112
+ }
113
+ interface ReactiveLogOptions {
114
+ /** User-specified ID. Auto-generated if omitted. */
115
+ id?: string;
116
+ /** Maximum number of entries. 0 = unlimited (default). Oldest trimmed on overflow. */
117
+ maxSize?: number;
118
+ }
119
+ /** An index entry mapping an index key to a set of primary keys. */
120
+ interface ReactiveIndex extends NodeV0 {
121
+ /** Get all primary keys matching an index key. */
122
+ get(indexKey: string): Set<string>;
123
+ /** Check if an index key has any entries. */
124
+ has(indexKey: string): boolean;
125
+ /** Get all index keys. */
126
+ keys(): string[];
127
+ /** Current number of distinct index keys. */
128
+ readonly size: number;
129
+ /** Reactive store of primary keys for a given index key. Cached per key. */
130
+ select(indexKey: string): Store<Set<string>>;
131
+ /** Reactive store of all index keys. */
132
+ keysStore: Store<string[]>;
133
+ /** Reactive store of the number of distinct index keys. */
134
+ sizeStore: Store<number>;
135
+ /** Add a primary key under one or more index keys. */
136
+ add(primaryKey: string, indexKeys: string[]): void;
137
+ /** Remove a primary key from all index keys. */
138
+ remove(primaryKey: string): void;
139
+ /** Update a primary key's index keys (remove old, add new). */
140
+ update(primaryKey: string, indexKeys: string[]): void;
141
+ /** Clear all entries. */
142
+ clear(): void;
143
+ /** Return a JSON-serializable snapshot of the index. */
144
+ snapshot(): IndexSnapshot;
145
+ /** Tear down all stores. */
146
+ destroy(): void;
147
+ }
148
+ interface ReactiveIndexOptions<V> {
149
+ /** Function that extracts index keys from a value. */
150
+ keyFn: (value: V, primaryKey: string) => string[];
151
+ }
152
+ interface NodeV0 {
153
+ /** User-specified or auto-generated unique identifier. */
154
+ readonly id: string;
155
+ /** Monotonically increasing version number (bumped on structural changes). */
156
+ readonly version: number;
157
+ }
158
+ interface MapSnapshot<V> extends NodeV0 {
159
+ type: "reactiveMap";
160
+ entries: [string, V][];
161
+ }
162
+ interface LogSnapshot<V> extends NodeV0 {
163
+ type: "reactiveLog";
164
+ entries: Array<{
165
+ seq: number;
166
+ value: V;
167
+ }>;
168
+ headSeq: number;
169
+ tailSeq: number;
170
+ }
171
+ interface IndexSnapshot extends NodeV0 {
172
+ type: "reactiveIndex";
173
+ index: Record<string, string[]>;
174
+ }
175
+ interface PubSub<T = unknown> extends NodeV0 {
176
+ /** Publish a message to a topic. */
177
+ publish(topic: string, message: T): void;
178
+ /** Subscribe to a topic. Returns a read-only reactive store of the latest message. */
179
+ subscribe(topic: string): Store<T | undefined>;
180
+ /** Get all topics that have been created. */
181
+ topics(): string[];
182
+ /** Return a JSON-serializable snapshot. */
183
+ snapshot(): PubSubSnapshot<T>;
184
+ /** Tear down all channel stores. */
185
+ destroy(): void;
186
+ }
187
+ interface PubSubSnapshot<T> extends NodeV0 {
188
+ type: "pubsub";
189
+ channels: Record<string, T | undefined>;
190
+ }
191
+
192
+ export type { IndexSnapshot as I, KVEvent as K, LogSnapshot as L, MapSnapshot as M, NodeV0 as N, PubSub as P, ReactiveIndex as R, PubSubSnapshot as a, ReactiveLogOptions as b, ReactiveLog as c, ReactiveMapOptions as d, ReactiveMap as e, KVEventType as f, LogEntry as g, LogEvent as h, LogEventType as i, ReactiveIndexOptions as j };