@demlik/tea 0.12.0 → 0.14.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 (368) hide show
  1. package/README.md +11 -9
  2. package/dist/agent/index.d.ts +638 -45
  3. package/dist/agent/index.js +9 -19
  4. package/dist/{chunk-25LBDCBC.js → chunk-6IQPODUF.js} +2 -2
  5. package/dist/{chunk-25LBDCBC.js.map → chunk-6IQPODUF.js.map} +1 -1
  6. package/dist/chunk-AQ6ZIMEA.js +421 -0
  7. package/dist/chunk-AQ6ZIMEA.js.map +1 -0
  8. package/dist/{chunk-MUUROGIH.js → chunk-BLJ2JQSH.js} +62 -12
  9. package/dist/chunk-BLJ2JQSH.js.map +1 -0
  10. package/dist/{chunk-7SVIRMC6.js → chunk-F2US5BW6.js} +25 -5
  11. package/dist/chunk-F2US5BW6.js.map +1 -0
  12. package/dist/{batch-window/index.js → chunk-F7FMAWLA.js} +4 -8
  13. package/dist/chunk-F7FMAWLA.js.map +1 -0
  14. package/dist/{chunk-7V4EVLZA.js → chunk-HUKZQX6U.js} +20 -16
  15. package/dist/chunk-HUKZQX6U.js.map +1 -0
  16. package/dist/{chunk-EWJP3YYP.js → chunk-HWVW4AXC.js} +3 -3
  17. package/dist/chunk-HWVW4AXC.js.map +1 -0
  18. package/dist/{chunk-WLGO64WC.js → chunk-HYDWG35Q.js} +23 -6
  19. package/dist/chunk-HYDWG35Q.js.map +1 -0
  20. package/dist/{chunk-I5OV65MS.js → chunk-I5MQMJDW.js} +57 -7
  21. package/dist/chunk-I5MQMJDW.js.map +1 -0
  22. package/dist/{chunk-J6527VRQ.js → chunk-LFZUK6J2.js} +3 -3
  23. package/dist/chunk-LFZUK6J2.js.map +1 -0
  24. package/dist/{chunk-ZVJZ72HY.js → chunk-LYLTKJWM.js} +25 -11
  25. package/dist/chunk-LYLTKJWM.js.map +1 -0
  26. package/dist/{chunk-D736QUGF.js → chunk-MYXFNWAJ.js} +4 -5
  27. package/dist/chunk-MYXFNWAJ.js.map +1 -0
  28. package/dist/{chunk-K575PT4S.js → chunk-PR6TB3BL.js} +15 -4
  29. package/dist/chunk-PR6TB3BL.js.map +1 -0
  30. package/dist/chunk-RQULHGYH.js +1804 -0
  31. package/dist/chunk-RQULHGYH.js.map +1 -0
  32. package/dist/{chunk-FV3Z5MBE.js → chunk-TXN2KFHF.js} +14 -4
  33. package/dist/chunk-TXN2KFHF.js.map +1 -0
  34. package/dist/{chunk-Q2UM7BXU.js → chunk-VBDU4JL6.js} +2 -2
  35. package/dist/chunk-VBDU4JL6.js.map +1 -0
  36. package/dist/chunk-Z2L3LSNV.js +1470 -0
  37. package/dist/chunk-Z2L3LSNV.js.map +1 -0
  38. package/dist/core-CTzMJ82M.d.ts +562 -0
  39. package/dist/devtools/index.d.ts +2 -2
  40. package/dist/devtools/index.js +207 -2
  41. package/dist/devtools/index.js.map +1 -1
  42. package/dist/do/index.d.ts +48 -31
  43. package/dist/do/index.js +36 -25
  44. package/dist/do/index.js.map +1 -1
  45. package/dist/{durable-effects-D8SqU_if.d.ts → durable-effects-B0-qGQDy.d.ts} +2 -2
  46. package/dist/extension/index.d.ts +301 -3
  47. package/dist/extension/index.js +596 -5
  48. package/dist/extension/index.js.map +1 -1
  49. package/dist/flow/index.d.ts +1295 -0
  50. package/dist/flow/index.js +732 -0
  51. package/dist/flow/index.js.map +1 -0
  52. package/dist/idempotency/index.d.ts +90 -116
  53. package/dist/idempotency/index.js +4 -1
  54. package/dist/{batch-window/index.d.ts → index-4vZzljCD.d.ts} +7 -11
  55. package/dist/{fan-out/index.d.ts → index-6A7dB8f6.d.ts} +7 -8
  56. package/dist/index-B5BZ-_cT.d.ts +616 -0
  57. package/dist/index-Bc40JWVl.d.ts +131 -0
  58. package/dist/{debounce/index.d.ts → index-DHSUmQTR.d.ts} +7 -7
  59. package/dist/index-DJWIER_3.d.ts +69 -0
  60. package/dist/{snapshot/index.d.ts → index-DMCeMPMJ.d.ts} +15 -77
  61. package/dist/{monitored-run/index.d.ts → index-NjrT3fL2.d.ts} +37 -12
  62. package/dist/{recorder/index.d.ts → index-TvRb1KVf.d.ts} +4 -6
  63. package/dist/{deadline/index.d.ts → index-q0hXFeZ0.d.ts} +155 -8
  64. package/dist/index.d.ts +719 -6
  65. package/dist/index.js +1 -2
  66. package/dist/jev/index.d.ts +634 -0
  67. package/dist/jev/index.js +433 -0
  68. package/dist/jev/index.js.map +1 -0
  69. package/dist/machine-CdIcN2Xm.d.ts +1773 -0
  70. package/dist/machine-viz/index.d.ts +2 -1
  71. package/dist/machine-viz/index.js +12 -5
  72. package/dist/machine-viz/index.js.map +1 -1
  73. package/dist/mem/index.d.ts +19 -3
  74. package/dist/mem/index.js +22 -2
  75. package/dist/mem/index.js.map +1 -1
  76. package/dist/node/index.d.ts +130 -4
  77. package/dist/node/index.js +222 -10
  78. package/dist/node/index.js.map +1 -1
  79. package/dist/{paginator → paginate}/index.d.ts +151 -6
  80. package/dist/paginate/index.js +7 -0
  81. package/dist/parity/index.d.ts +5 -10
  82. package/dist/parity/index.js +4 -7
  83. package/dist/parity/index.js.map +1 -1
  84. package/dist/pbt/index.d.ts +248 -5
  85. package/dist/pbt/index.js +124 -5
  86. package/dist/pbt/index.js.map +1 -1
  87. package/dist/{trace-replay → persistence}/index.d.ts +7 -4
  88. package/dist/persistence/index.js +6 -0
  89. package/dist/react/index.d.ts +4 -3
  90. package/dist/react/index.js +1 -2
  91. package/dist/react/index.js.map +1 -1
  92. package/dist/resilience/index.d.ts +743 -0
  93. package/dist/resilience/index.js +657 -0
  94. package/dist/resilience/index.js.map +1 -0
  95. package/dist/retry-backoff/index.d.ts +3 -2
  96. package/dist/retry-backoff/index.js +1 -1
  97. package/dist/runtime-types-LWDoi943.d.ts +998 -0
  98. package/dist/testing/index.d.ts +3 -2
  99. package/dist/testing/index.js +1 -2
  100. package/dist/testing/index.js.map +1 -1
  101. package/dist/{throttled-input → timing}/index.d.ts +144 -12
  102. package/dist/{throttled-input → timing}/index.js +57 -12
  103. package/dist/timing/index.js.map +1 -0
  104. package/dist/{types-D7u9DkH7.d.ts → types-DP3f5NIl.d.ts} +1 -1
  105. package/dist/work-queue/index.d.ts +131 -54
  106. package/dist/work-queue/index.js +3 -2
  107. package/dist/work-queue/index.js.map +1 -1
  108. package/package.json +50 -216
  109. package/dist/authed-call/index.d.ts +0 -119
  110. package/dist/authed-call/index.js +0 -134
  111. package/dist/authed-call/index.js.map +0 -1
  112. package/dist/await-terminal/index.d.ts +0 -100
  113. package/dist/await-terminal/index.js +0 -76
  114. package/dist/await-terminal/index.js.map +0 -1
  115. package/dist/batch-window/index.js.map +0 -1
  116. package/dist/cache/index.d.ts +0 -151
  117. package/dist/cache/index.js +0 -8
  118. package/dist/chart/index.d.ts +0 -217
  119. package/dist/chart/index.js +0 -16
  120. package/dist/chart/index.js.map +0 -1
  121. package/dist/chart/inspect/index.d.ts +0 -85
  122. package/dist/chart/inspect/index.js +0 -5
  123. package/dist/chart/inspect/react.d.ts +0 -112
  124. package/dist/chart/inspect/react.js +0 -11
  125. package/dist/chart/inspect/react.js.map +0 -1
  126. package/dist/chart/inspect/styles.css +0 -286
  127. package/dist/chart/lane/index.d.ts +0 -361
  128. package/dist/chart/lane/index.js +0 -9
  129. package/dist/chart/lane/index.js.map +0 -1
  130. package/dist/chart/lane/react.d.ts +0 -83
  131. package/dist/chart/lane/react.js +0 -559
  132. package/dist/chart/lane/react.js.map +0 -1
  133. package/dist/chart/lane/server.d.ts +0 -148
  134. package/dist/chart/lane/server.js +0 -209
  135. package/dist/chart/lane/server.js.map +0 -1
  136. package/dist/chart/lane/styles.css +0 -498
  137. package/dist/chart/lane/viewer/assets/abnfDiagram-N423BO3Z-C729LI31.js +0 -1
  138. package/dist/chart/lane/viewer/assets/architectureDiagram-T3A2C74G-C729LI31.js +0 -1
  139. package/dist/chart/lane/viewer/assets/blockDiagram-VBNYF7ZC-C729LI31.js +0 -1
  140. package/dist/chart/lane/viewer/assets/c4Diagram-5PPSVZJV-C729LI31.js +0 -1
  141. package/dist/chart/lane/viewer/assets/chunk-2GRJ4B5K-HdDf8SI3.js +0 -1
  142. package/dist/chart/lane/viewer/assets/chunk-5RXB4S5H-CcNtpUd7.js +0 -231
  143. package/dist/chart/lane/viewer/assets/chunk-5VM5RSS4-BP4fRS_5.js +0 -15
  144. package/dist/chart/lane/viewer/assets/chunk-KBJHAD2P-DZOw7xU6.js +0 -1
  145. package/dist/chart/lane/viewer/assets/chunk-NSK5VX7P-CBCyTZMs.js +0 -128
  146. package/dist/chart/lane/viewer/assets/classDiagram-JCYQIIEL-C729LI31.js +0 -1
  147. package/dist/chart/lane/viewer/assets/classDiagram-v2-OCEON4UE-D4uAiFr8.js +0 -206
  148. package/dist/chart/lane/viewer/assets/cose-bilkent-JH36ORCC-DOwCrGXH.js +0 -1
  149. package/dist/chart/lane/viewer/assets/cynefinDiagram-MW4NZA55-C729LI31.js +0 -1
  150. package/dist/chart/lane/viewer/assets/dagre-K_PewWfS.js +0 -1
  151. package/dist/chart/lane/viewer/assets/dagre-VZM6K2ZE-831qZcA8.js +0 -4
  152. package/dist/chart/lane/viewer/assets/diagram-7IWD3JNH-C729LI31.js +0 -1
  153. package/dist/chart/lane/viewer/assets/diagram-B4RE2ZJO-C729LI31.js +0 -1
  154. package/dist/chart/lane/viewer/assets/diagram-LBJQPF4R-C729LI31.js +0 -1
  155. package/dist/chart/lane/viewer/assets/diagram-Q27KOJAE-C729LI31.js +0 -1
  156. package/dist/chart/lane/viewer/assets/diagram-UB23O5K3-C729LI31.js +0 -1
  157. package/dist/chart/lane/viewer/assets/ebnfDiagram-BXEA7PRR-C729LI31.js +0 -1
  158. package/dist/chart/lane/viewer/assets/erDiagram-JOGREHBK-C729LI31.js +0 -1
  159. package/dist/chart/lane/viewer/assets/flowDiagram-UKHOOZJN-C729LI31.js +0 -1
  160. package/dist/chart/lane/viewer/assets/ganttDiagram-PKOTCBZU-C729LI31.js +0 -1
  161. package/dist/chart/lane/viewer/assets/gitGraphDiagram-DS77QQ5N-C729LI31.js +0 -1
  162. package/dist/chart/lane/viewer/assets/index-9SkH5NA3.css +0 -1
  163. package/dist/chart/lane/viewer/assets/index-Bgt4sXpW.js +0 -195
  164. package/dist/chart/lane/viewer/assets/infoDiagram-6WML65LV-C729LI31.js +0 -1
  165. package/dist/chart/lane/viewer/assets/ishikawaDiagram-WSZJBQD7-C729LI31.js +0 -1
  166. package/dist/chart/lane/viewer/assets/journeyDiagram-NVQOT4AX-C729LI31.js +0 -1
  167. package/dist/chart/lane/viewer/assets/kanban-definition-27J2QSJJ-G7PaPzy-.js +0 -89
  168. package/dist/chart/lane/viewer/assets/katex-DOwCrGXH.js +0 -1
  169. package/dist/chart/lane/viewer/assets/mindmap-definition-FAOFIHXS-CGj9nrVk.js +0 -96
  170. package/dist/chart/lane/viewer/assets/path-fybaL0A-.js +0 -1
  171. package/dist/chart/lane/viewer/assets/pegDiagram-VL7TDLO6-C729LI31.js +0 -1
  172. package/dist/chart/lane/viewer/assets/pieDiagram-7S7Q4E2Y-C729LI31.js +0 -1
  173. package/dist/chart/lane/viewer/assets/quadrantDiagram-CIZ2JOQS-C729LI31.js +0 -1
  174. package/dist/chart/lane/viewer/assets/railroadDiagram-AXF67PYL-C729LI31.js +0 -1
  175. package/dist/chart/lane/viewer/assets/requirementDiagram-LRYGKXZP-C729LI31.js +0 -1
  176. package/dist/chart/lane/viewer/assets/sankeyDiagram-W5VNT64P-C729LI31.js +0 -1
  177. package/dist/chart/lane/viewer/assets/sequenceDiagram-SI44F4Z6-C729LI31.js +0 -1
  178. package/dist/chart/lane/viewer/assets/stateDiagram-OKZ733FA-B_88AzBS.js +0 -1
  179. package/dist/chart/lane/viewer/assets/stateDiagram-v2-UEYNNEHI-CR5gcgq6.js +0 -1
  180. package/dist/chart/lane/viewer/assets/swimlanes-SLNWSIFB-B4xK-rwg.js +0 -1
  181. package/dist/chart/lane/viewer/assets/swimlanesDiagram-ULZ7WXOC-C729LI31.js +0 -1
  182. package/dist/chart/lane/viewer/assets/timeline-definition-Z64GVDOM-CCv52MfY.js +0 -120
  183. package/dist/chart/lane/viewer/assets/vennDiagram-T6HMQDX7-C729LI31.js +0 -1
  184. package/dist/chart/lane/viewer/assets/wardleyDiagram-T6FBY63Y-C729LI31.js +0 -1
  185. package/dist/chart/lane/viewer/assets/xychartDiagram-ELKLHX3M-C729LI31.js +0 -1
  186. package/dist/chart/lane/viewer/index.html +0 -15
  187. package/dist/chart/report/index.d.ts +0 -116
  188. package/dist/chart/report/index.js +0 -32
  189. package/dist/chart/report/index.js.map +0 -1
  190. package/dist/chunk-2YFLOCWX.js +0 -15
  191. package/dist/chunk-2YFLOCWX.js.map +0 -1
  192. package/dist/chunk-3JU6657S.js +0 -372
  193. package/dist/chunk-3JU6657S.js.map +0 -1
  194. package/dist/chunk-4KTWLPL5.js +0 -33
  195. package/dist/chunk-4KTWLPL5.js.map +0 -1
  196. package/dist/chunk-5EHLEUTL.js +0 -686
  197. package/dist/chunk-5EHLEUTL.js.map +0 -1
  198. package/dist/chunk-5KJKJOFC.js +0 -758
  199. package/dist/chunk-5KJKJOFC.js.map +0 -1
  200. package/dist/chunk-7SVIRMC6.js.map +0 -1
  201. package/dist/chunk-7V4EVLZA.js.map +0 -1
  202. package/dist/chunk-A56OR5RF.js +0 -184
  203. package/dist/chunk-A56OR5RF.js.map +0 -1
  204. package/dist/chunk-AZZLE7XR.js +0 -62
  205. package/dist/chunk-AZZLE7XR.js.map +0 -1
  206. package/dist/chunk-B5VXOFMZ.js +0 -266
  207. package/dist/chunk-B5VXOFMZ.js.map +0 -1
  208. package/dist/chunk-BYQUGDD3.js +0 -16
  209. package/dist/chunk-BYQUGDD3.js.map +0 -1
  210. package/dist/chunk-D736QUGF.js.map +0 -1
  211. package/dist/chunk-E6GEDSF4.js +0 -307
  212. package/dist/chunk-E6GEDSF4.js.map +0 -1
  213. package/dist/chunk-EUF7XOEE.js +0 -223
  214. package/dist/chunk-EUF7XOEE.js.map +0 -1
  215. package/dist/chunk-EWJP3YYP.js.map +0 -1
  216. package/dist/chunk-FV3Z5MBE.js.map +0 -1
  217. package/dist/chunk-HCEVHFJ7.js +0 -54
  218. package/dist/chunk-HCEVHFJ7.js.map +0 -1
  219. package/dist/chunk-I5OV65MS.js.map +0 -1
  220. package/dist/chunk-J6527VRQ.js.map +0 -1
  221. package/dist/chunk-JELSZN25.js +0 -47
  222. package/dist/chunk-JELSZN25.js.map +0 -1
  223. package/dist/chunk-JER5O7PQ.js +0 -416
  224. package/dist/chunk-JER5O7PQ.js.map +0 -1
  225. package/dist/chunk-JGVL3WPL.js +0 -26
  226. package/dist/chunk-JGVL3WPL.js.map +0 -1
  227. package/dist/chunk-JP5D6GSL.js +0 -71
  228. package/dist/chunk-JP5D6GSL.js.map +0 -1
  229. package/dist/chunk-K575PT4S.js.map +0 -1
  230. package/dist/chunk-MU6MCIAC.js +0 -15
  231. package/dist/chunk-MU6MCIAC.js.map +0 -1
  232. package/dist/chunk-MUUROGIH.js.map +0 -1
  233. package/dist/chunk-ND3DH6KM.js +0 -88
  234. package/dist/chunk-ND3DH6KM.js.map +0 -1
  235. package/dist/chunk-Q2UM7BXU.js.map +0 -1
  236. package/dist/chunk-S2EGRPCM.js +0 -47
  237. package/dist/chunk-S2EGRPCM.js.map +0 -1
  238. package/dist/chunk-SINXE47Y.js +0 -55
  239. package/dist/chunk-SINXE47Y.js.map +0 -1
  240. package/dist/chunk-SUST46KO.js +0 -53
  241. package/dist/chunk-SUST46KO.js.map +0 -1
  242. package/dist/chunk-TP5UPGLY.js +0 -61
  243. package/dist/chunk-TP5UPGLY.js.map +0 -1
  244. package/dist/chunk-UF4MZSLT.js +0 -53
  245. package/dist/chunk-UF4MZSLT.js.map +0 -1
  246. package/dist/chunk-UOC2PL46.js +0 -13
  247. package/dist/chunk-UOC2PL46.js.map +0 -1
  248. package/dist/chunk-WLGO64WC.js.map +0 -1
  249. package/dist/chunk-WRAA7GVZ.js +0 -209
  250. package/dist/chunk-WRAA7GVZ.js.map +0 -1
  251. package/dist/chunk-ZCL7SCBK.js +0 -685
  252. package/dist/chunk-ZCL7SCBK.js.map +0 -1
  253. package/dist/chunk-ZD6PNZBK.js +0 -457
  254. package/dist/chunk-ZD6PNZBK.js.map +0 -1
  255. package/dist/chunk-ZF6WDK2D.js +0 -519
  256. package/dist/chunk-ZF6WDK2D.js.map +0 -1
  257. package/dist/chunk-ZJ5AOYBH.js +0 -8
  258. package/dist/chunk-ZJ5AOYBH.js.map +0 -1
  259. package/dist/chunk-ZVJZ72HY.js.map +0 -1
  260. package/dist/circuit-breaker/index.d.ts +0 -197
  261. package/dist/circuit-breaker/index.js +0 -3
  262. package/dist/circuit-breaker/index.js.map +0 -1
  263. package/dist/core-Bjc0bS8j.d.ts +0 -326
  264. package/dist/deadline/index.js +0 -6
  265. package/dist/deadline/index.js.map +0 -1
  266. package/dist/debounce/index.js +0 -3
  267. package/dist/debounce/index.js.map +0 -1
  268. package/dist/extension/react.d.ts +0 -121
  269. package/dist/extension/react.js +0 -75
  270. package/dist/extension/react.js.map +0 -1
  271. package/dist/extension/subs/index.d.ts +0 -44
  272. package/dist/extension/subs/index.js +0 -80
  273. package/dist/extension/subs/index.js.map +0 -1
  274. package/dist/extension/test-utils.d.ts +0 -128
  275. package/dist/extension/test-utils.js +0 -277
  276. package/dist/extension/test-utils.js.map +0 -1
  277. package/dist/fan-out/index.js +0 -5
  278. package/dist/fan-out/index.js.map +0 -1
  279. package/dist/fold-Blbhru48.d.ts +0 -435
  280. package/dist/graph-CcjWZVrd.d.ts +0 -923
  281. package/dist/idempotency/adapter.d.ts +0 -62
  282. package/dist/idempotency/adapter.js +0 -4
  283. package/dist/idempotency/adapter.js.map +0 -1
  284. package/dist/idempotent-intake/index.d.ts +0 -187
  285. package/dist/idempotent-intake/index.js +0 -7
  286. package/dist/idempotent-intake/index.js.map +0 -1
  287. package/dist/llm-call/index.d.ts +0 -310
  288. package/dist/llm-call/index.js +0 -16
  289. package/dist/llm-call/index.js.map +0 -1
  290. package/dist/machine-0OmPvsy_.d.ts +0 -804
  291. package/dist/monitored-run/index.js +0 -10
  292. package/dist/monitored-run/index.js.map +0 -1
  293. package/dist/paginated-walk/index.d.ts +0 -234
  294. package/dist/paginated-walk/index.js +0 -16
  295. package/dist/paginated-walk/index.js.map +0 -1
  296. package/dist/paginator/index.js +0 -3
  297. package/dist/paginator/index.js.map +0 -1
  298. package/dist/pbt/arbitraries/index.d.ts +0 -135
  299. package/dist/pbt/arbitraries/index.js +0 -3
  300. package/dist/pbt/arbitraries/index.js.map +0 -1
  301. package/dist/pbt/runners/index.d.ts +0 -117
  302. package/dist/pbt/runners/index.js +0 -5
  303. package/dist/pbt/runners/index.js.map +0 -1
  304. package/dist/poller/index.d.ts +0 -351
  305. package/dist/poller/index.js +0 -115
  306. package/dist/poller/index.js.map +0 -1
  307. package/dist/prediction/index.d.ts +0 -130
  308. package/dist/prediction/index.js +0 -4
  309. package/dist/prediction/index.js.map +0 -1
  310. package/dist/protocol-B5YmJr0d.d.ts +0 -45
  311. package/dist/pure/index.d.ts +0 -2
  312. package/dist/pure/index.js +0 -4
  313. package/dist/pure/index.js.map +0 -1
  314. package/dist/rate-limit/index.d.ts +0 -115
  315. package/dist/rate-limit/index.js +0 -3
  316. package/dist/rate-limit/index.js.map +0 -1
  317. package/dist/reconciler/index.d.ts +0 -192
  318. package/dist/reconciler/index.js +0 -164
  319. package/dist/reconciler/index.js.map +0 -1
  320. package/dist/recorder/index.js +0 -3
  321. package/dist/recorder/index.js.map +0 -1
  322. package/dist/reducer-BqyoVyBG.d.ts +0 -447
  323. package/dist/resilient-call/index.d.ts +0 -319
  324. package/dist/resilient-call/index.js +0 -14
  325. package/dist/resilient-call/index.js.map +0 -1
  326. package/dist/retry-to-success/index.d.ts +0 -109
  327. package/dist/retry-to-success/index.js +0 -37
  328. package/dist/retry-to-success/index.js.map +0 -1
  329. package/dist/run-BVeqJDBF.d.ts +0 -713
  330. package/dist/runtime-types-Bxc637bp.d.ts +0 -502
  331. package/dist/saga/index.d.ts +0 -240
  332. package/dist/saga/index.js +0 -150
  333. package/dist/saga/index.js.map +0 -1
  334. package/dist/samples-DCt6nF8H.d.ts +0 -59
  335. package/dist/snapshot/index.js +0 -5
  336. package/dist/snapshot/index.js.map +0 -1
  337. package/dist/subs/index.d.ts +0 -471
  338. package/dist/subs/index.js +0 -7
  339. package/dist/subs/index.js.map +0 -1
  340. package/dist/throttle/index.d.ts +0 -134
  341. package/dist/throttle/index.js +0 -3
  342. package/dist/throttle/index.js.map +0 -1
  343. package/dist/throttled-input/index.js.map +0 -1
  344. package/dist/token-refresh/index.d.ts +0 -215
  345. package/dist/token-refresh/index.js +0 -6
  346. package/dist/token-refresh/index.js.map +0 -1
  347. package/dist/trace-replay/index.js +0 -6
  348. package/dist/trace-replay/index.js.map +0 -1
  349. package/dist/with-deadline/index.d.ts +0 -196
  350. package/dist/with-deadline/index.js +0 -111
  351. package/dist/with-deadline/index.js.map +0 -1
  352. package/dist/with-resilience/index.d.ts +0 -224
  353. package/dist/with-resilience/index.js +0 -240
  354. package/dist/with-resilience/index.js.map +0 -1
  355. package/dist/with-telemetry/index.d.ts +0 -149
  356. package/dist/with-telemetry/index.js +0 -70
  357. package/dist/with-telemetry/index.js.map +0 -1
  358. package/dist/work-queue/adapter.d.ts +0 -83
  359. package/dist/work-queue/adapter.js +0 -4
  360. package/dist/work-queue/adapter.js.map +0 -1
  361. package/dist/work-queue/ops.d.ts +0 -70
  362. package/dist/work-queue/ops.js +0 -3
  363. package/dist/work-queue/ops.js.map +0 -1
  364. package/dist/workflow/index.d.ts +0 -484
  365. package/dist/workflow/index.js +0 -244
  366. package/dist/workflow/index.js.map +0 -1
  367. /package/dist/{cache → paginate}/index.js.map +0 -0
  368. /package/dist/{chart/inspect → persistence}/index.js.map +0 -0
@@ -1,116 +0,0 @@
1
- import { WalkCounts } from '../index.js';
2
- export { edgeKey } from '../index.js';
3
- import { a as ImportedChart, L as LogEntry, b as LaneStatus, I as ImportedLane, W as WorkflowImportOptions } from '../../fold-Blbhru48.js';
4
- export { c as ImportedEdge, d as ImportedNode, e as ImportedPhase, f as LeafStates, g as PhaseStand, P as PhaseStanding, T as TaskState, h as TimelineStep, U as UnreplayableLogError, i as WorkflowImportError, j as bareEvent, k as chartFromWorkflow, l as chartFromWorkflowText, m as deriveLaneStatus, n as endPolarityOf, o as eventAlphabet, p as foldLane, q as initialOf, r as initialStates, s as laneTerminalReached, t as originOf, u as parseEventsJsonl, v as parseHistoryJson, w as parseStatusJson, x as phaseStandings, y as statesOf, z as stepTask, A as timeline, B as trippedTasks, C as walkedEdgeKey } from '../../fold-Blbhru48.js';
5
- import '../../core-Bjc0bS8j.js';
6
- import '../../graph-CcjWZVrd.js';
7
-
8
- interface DrawOptions {
9
- /** The state the task is in right now — lit. */
10
- readonly current?: string;
11
- /** Edges the log actually walked, keyed `${from}|${event}|${to}`. */
12
- readonly walked?: WalkCounts;
13
- }
14
- /**
15
- * One task's region as a mermaid `stateDiagram-v2` block, with the current node
16
- * lit, the walked edges marked and the two endings drawn apart.
17
- *
18
- * `polarity` is always on: a lane's whole point is that `shipped` and `frozen`
19
- * are not the same ending, and a report that painted them alike would be lying
20
- * in the place a reader looks first. It is an OPTION on the renderer rather
21
- * than a default because a chart drawing is something a reviewer approves —
22
- * see `ChartMermaidOptions.polarity`.
23
- */
24
- declare function drawTask(chart: ImportedChart, opts?: DrawOptions): string;
25
- /**
26
- * The edges a log walked, counted — the input `drawTask` marks from.
27
- *
28
- * Reads each step's DECLARED `edge` rather than recomputing one from
29
- * `from`/`event`/`to`: a resume edge is drawn to its fallback and walked to
30
- * wherever `was` pointed, so the observed target names an edge the drawing does
31
- * not have. `TimelineStep.edge` is the edge that actually fired.
32
- */
33
- declare function walkedEdges(steps: readonly {
34
- readonly edge: string;
35
- }[]): WalkCounts;
36
-
37
- /** The lane the report is about. `workflow` is the PARSED document, or an import. */
38
- interface LaneReportInput {
39
- /** `workflow.json`, parsed — or an already-imported lane, reused as is. */
40
- readonly workflow: unknown;
41
- readonly entries: readonly LogEntry[];
42
- /**
43
- * `lane status`'s answer.
44
- *
45
- * OPTIONAL, and that is the whole shape of the two input paths: a caller
46
- * shelling out to `fabrika` hands over the CLI's own derivation and the
47
- * report never second-guesses it; a caller holding only the two files omits
48
- * it and the same derivation runs here.
49
- */
50
- readonly status?: LaneStatus;
51
- /** Heading for the block. Defaults to the document's `id`. */
52
- readonly title?: string;
53
- }
54
- interface LaneReport {
55
- readonly markdown: string;
56
- }
57
- /**
58
- * What this task is waiting on — or `null` at a final.
59
- *
60
- * DERIVED, entirely: the events this state routes, grouped by the origin each
61
- * one DECLARES, in declaration order. Nothing here knows a state name, an event
62
- * name or a job title, so a consumer that renames half its states changes this
63
- * output correctly and a consumer with a completely different cast is served by
64
- * the same function.
65
- *
66
- * The degradation is the point of the second half. Provenance is not in
67
- * `workflow.json` — it is stated at the import boundary or not at all — so a
68
- * chart imported without it must say what it actually knows, which is WHICH
69
- * EVENTS the state accepts. It never says who sends them.
70
- */
71
- declare function waitingOn(chart: ImportedChart, state: string): string | null;
72
- /**
73
- * A lane, as one markdown block.
74
- *
75
- * The diagram half is behind {@link drawTask}, which is a translation onto
76
- * `chartMermaid` — the package's one chart renderer.
77
- */
78
- declare function laneReport(input: LaneReportInput): LaneReport;
79
-
80
- /** Everything a report needs, however it was obtained. */
81
- interface LaneSource {
82
- readonly workflow: ImportedLane;
83
- readonly entries: readonly LogEntry[];
84
- /** Present only on the CLI path — the driver's own answer, not ours. */
85
- readonly status?: LaneStatus;
86
- }
87
- /**
88
- * PATH 1 — the two files.
89
- *
90
- * @param workflowJson the bytes of `<lane>/workflow.json`
91
- * @param eventsJsonl the bytes of `<lane>/events.jsonl` (`""` for a fresh lane)
92
- * @param options {@link WorkflowImportOptions} — carried straight through
93
- * to the importer, which is the one place it is read.
94
- */
95
- declare function laneFromFiles(workflowJson: string, eventsJsonl: string, options?: WorkflowImportOptions): LaneSource;
96
- /**
97
- * PATH 2 — the CLI's stdout.
98
- *
99
- * const dir = ".fabrika/lanes/5842";
100
- * const src = laneFromCli(
101
- * readFileSync(`${dir}/workflow.json`, "utf8"),
102
- * execFileSync("fabrika", ["lane", "status", "--lane", "5842"], { encoding: "utf8" }),
103
- * execFileSync("fabrika", ["lane", "history", "--lane", "5842"], { encoding: "utf8" }),
104
- * );
105
- * console.log(laneReport(reportInput(src)).markdown);
106
- *
107
- * @param workflowJson the bytes of `<lane>/workflow.json`
108
- * @param statusStdout `fabrika lane status`'s stdout — `JSON.stringify(status, null, 2)`
109
- * @param historyStdout `fabrika lane history`'s stdout — the log as a JSON array
110
- * @param options {@link WorkflowImportOptions} — the same seam as path 1's.
111
- */
112
- declare function laneFromCli(workflowJson: string, statusStdout: string, historyStdout: string, options?: WorkflowImportOptions): LaneSource;
113
- /** A `LaneSource` as the report's input. One line, so neither path spells it. */
114
- declare function reportInput(source: LaneSource, title?: string): LaneReportInput;
115
-
116
- export { type DrawOptions, ImportedChart, ImportedLane, type LaneReport, type LaneReportInput, type LaneSource, LaneStatus, LogEntry, WalkCounts, WorkflowImportOptions, drawTask, laneFromCli, laneFromFiles, laneReport, reportInput, waitingOn, walkedEdges };
@@ -1,32 +0,0 @@
1
- import { parseEventsJsonl, chartFromWorkflowText, parseStatusJson, parseHistoryJson } from '../../chunk-5KJKJOFC.js';
2
- export { UnreplayableLogError, WorkflowImportError, bareEvent, chartFromWorkflow, chartFromWorkflowText, deriveLaneStatus, drawTask, endPolarityOf, eventAlphabet, foldLane, initialOf, initialStates, laneReport, laneTerminalReached, originOf, parseEventsJsonl, parseHistoryJson, parseStatusJson, phaseStandings, statesOf, stepTask, timeline, trippedTasks, waitingOn, walkedEdgeKey, walkedEdges } from '../../chunk-5KJKJOFC.js';
3
- export { edgeKey } from '../../chunk-E6GEDSF4.js';
4
- import '../../chunk-UOC2PL46.js';
5
- import '../../chunk-B5VXOFMZ.js';
6
-
7
- // src/chart/report/sources.ts
8
- function laneFromFiles(workflowJson, eventsJsonl, options = {}) {
9
- return {
10
- workflow: chartFromWorkflowText(workflowJson, options),
11
- entries: parseEventsJsonl(eventsJsonl)
12
- };
13
- }
14
- function laneFromCli(workflowJson, statusStdout, historyStdout, options = {}) {
15
- return {
16
- workflow: chartFromWorkflowText(workflowJson, options),
17
- entries: parseHistoryJson(historyStdout),
18
- status: parseStatusJson(statusStdout)
19
- };
20
- }
21
- function reportInput(source, title) {
22
- return {
23
- workflow: source.workflow,
24
- entries: source.entries,
25
- ...source.status === void 0 ? {} : { status: source.status },
26
- ...title === void 0 ? {} : { title }
27
- };
28
- }
29
-
30
- export { laneFromCli, laneFromFiles, reportInput };
31
- //# sourceMappingURL=index.js.map
32
- //# sourceMappingURL=index.js.map
@@ -1 +0,0 @@
1
- {"version":3,"sources":["../../../src/chart/report/sources.ts"],"names":[],"mappings":";;;;;;;AAsDO,SAAS,aAAA,CACd,YAAA,EACA,WAAA,EACA,OAAA,GAAiC,EAAC,EACtB;AACZ,EAAA,OAAO;AAAA,IACL,QAAA,EAAU,qBAAA,CAAsB,YAAA,EAAc,OAAO,CAAA;AAAA,IACrD,OAAA,EAAS,iBAAiB,WAAW;AAAA,GACvC;AACF;AAkBO,SAAS,YACd,YAAA,EACA,YAAA,EACA,aAAA,EACA,OAAA,GAAiC,EAAC,EACtB;AACZ,EAAA,OAAO;AAAA,IACL,QAAA,EAAU,qBAAA,CAAsB,YAAA,EAAc,OAAO,CAAA;AAAA,IACrD,OAAA,EAAS,iBAAiB,aAAa,CAAA;AAAA,IACvC,MAAA,EAAQ,gBAAgB,YAAY;AAAA,GACtC;AACF;AAGO,SAAS,WAAA,CACd,QACA,KAAA,EACiB;AACjB,EAAA,OAAO;AAAA,IACL,UAAU,MAAA,CAAO,QAAA;AAAA,IACjB,SAAS,MAAA,CAAO,OAAA;AAAA,IAChB,GAAI,OAAO,MAAA,KAAW,MAAA,GAAY,EAAC,GAAI,EAAE,MAAA,EAAQ,MAAA,CAAO,MAAA,EAAO;AAAA,IAC/D,GAAI,KAAA,KAAU,MAAA,GAAY,EAAC,GAAI,EAAE,KAAA;AAAM,GACzC;AACF","file":"index.js","sourcesContent":["// ═══════════════════════════════════════════════════════════════════════════\n// THE TWO INPUT PATHS.\n//\n// Both produce the same `LaneReportInput`, and both take TEXT rather than doing\n// their own I/O — so this module has no `node:fs` in it, runs in a worker or a\n// Durable Object, and the caller keeps the one decision that is genuinely\n// theirs (which bytes, from where).\n//\n// THE FILE PATH — `workflow.json` + `events.jsonl` off disk. What a tool\n// running inside the repo already has: the lane directory is right there.\n// Status is DERIVED, because there is nothing to be handed.\n//\n// THE CLI PATH — `fabrika lane status` + `fabrika lane history` stdout, plus\n// the `workflow.json` bytes. This is the one that matters: it means a\n// standalone inspector can shell out to `fabrika` and need ZERO phoenix\n// changes, because both verbs already print JSON on stdout and have done\n// since they were written. Status here is the CLI's OWN derivation, carried\n// verbatim — the report reads, it does not re-decide.\n//\n// `workflow.json` is read as a file on BOTH paths, deliberately. `lane print`\n// looks like the CLI answer for topology and is not: it emits, per state, the\n// event NAMES a cell exists for and never the targets, so no edge can be drawn\n// from it. The document is local, gitignored and sitting next to the log.\n// ═══════════════════════════════════════════════════════════════════════════\nimport {\n type LaneStatus,\n type LogEntry,\n parseEventsJsonl,\n parseHistoryJson,\n parseStatusJson,\n} from \"./fold\";\nimport type { LaneReportInput } from \"./report\";\nimport {\n chartFromWorkflowText,\n type ImportedLane,\n type WorkflowImportOptions,\n} from \"./workflow\";\n\n/** Everything a report needs, however it was obtained. */\nexport interface LaneSource {\n readonly workflow: ImportedLane;\n readonly entries: readonly LogEntry[];\n /** Present only on the CLI path — the driver's own answer, not ours. */\n readonly status?: LaneStatus;\n}\n\n/**\n * PATH 1 — the two files.\n *\n * @param workflowJson the bytes of `<lane>/workflow.json`\n * @param eventsJsonl the bytes of `<lane>/events.jsonl` (`\"\"` for a fresh lane)\n * @param options {@link WorkflowImportOptions} — carried straight through\n * to the importer, which is the one place it is read.\n */\nexport function laneFromFiles(\n workflowJson: string,\n eventsJsonl: string,\n options: WorkflowImportOptions = {},\n): LaneSource {\n return {\n workflow: chartFromWorkflowText(workflowJson, options),\n entries: parseEventsJsonl(eventsJsonl),\n };\n}\n\n/**\n * PATH 2 — the CLI's stdout.\n *\n * const dir = \".fabrika/lanes/5842\";\n * const src = laneFromCli(\n * readFileSync(`${dir}/workflow.json`, \"utf8\"),\n * execFileSync(\"fabrika\", [\"lane\", \"status\", \"--lane\", \"5842\"], { encoding: \"utf8\" }),\n * execFileSync(\"fabrika\", [\"lane\", \"history\", \"--lane\", \"5842\"], { encoding: \"utf8\" }),\n * );\n * console.log(laneReport(reportInput(src)).markdown);\n *\n * @param workflowJson the bytes of `<lane>/workflow.json`\n * @param statusStdout `fabrika lane status`'s stdout — `JSON.stringify(status, null, 2)`\n * @param historyStdout `fabrika lane history`'s stdout — the log as a JSON array\n * @param options {@link WorkflowImportOptions} — the same seam as path 1's.\n */\nexport function laneFromCli(\n workflowJson: string,\n statusStdout: string,\n historyStdout: string,\n options: WorkflowImportOptions = {},\n): LaneSource {\n return {\n workflow: chartFromWorkflowText(workflowJson, options),\n entries: parseHistoryJson(historyStdout),\n status: parseStatusJson(statusStdout),\n };\n}\n\n/** A `LaneSource` as the report's input. One line, so neither path spells it. */\nexport function reportInput(\n source: LaneSource,\n title?: string,\n): LaneReportInput {\n return {\n workflow: source.workflow,\n entries: source.entries,\n ...(source.status === undefined ? {} : { status: source.status }),\n ...(title === undefined ? {} : { title }),\n };\n}\n"]}
@@ -1,15 +0,0 @@
1
- // src/subs/from-timeout.ts
2
- function fromTimeout(msgFn) {
3
- return (sub, _ctx, dispatch) => {
4
- const handle = setTimeout(() => {
5
- dispatch(msgFn(sub));
6
- }, sub.delayMs);
7
- return () => {
8
- clearTimeout(handle);
9
- };
10
- };
11
- }
12
-
13
- export { fromTimeout };
14
- //# sourceMappingURL=chunk-2YFLOCWX.js.map
15
- //# sourceMappingURL=chunk-2YFLOCWX.js.map
@@ -1 +0,0 @@
1
- {"version":3,"sources":["../src/subs/from-timeout.ts"],"names":[],"mappings":";AAgCO,SAAS,YACd,KAAA,EACiC;AACjC,EAAA,OAAO,CAAC,GAAA,EAAK,IAAA,EAAM,QAAA,KAAa;AAC9B,IAAA,MAAM,MAAA,GAAS,WAAW,MAAM;AAC9B,MAAA,QAAA,CAAS,KAAA,CAAM,GAAG,CAAC,CAAA;AAAA,IACrB,CAAA,EAAG,IAAI,OAAO,CAAA;AACd,IAAA,OAAO,MAAM;AACX,MAAA,YAAA,CAAa,MAAM,CAAA;AAAA,IACrB,CAAA;AAAA,EACF,CAAA;AACF","file":"chunk-2YFLOCWX.js","sourcesContent":["// ---------------------------------------------------------------------------\n// fromTimeout — universal `setTimeout`-shaped Sub factory.\n//\n// Same lifecycle shape as `fromInterval` minus the recurrence: the\n// scheduled callback fires once, the cleanup is `clearTimeout`. Two\n// observable consequences worth pinning explicitly:\n//\n// 1. The Sub stays in the desired set until the caller removes it from\n// `subscriptions(state)`. The substrate's reconcile pass does NOT\n// auto-remove a Sub on cleanup — the timer fires, the callback\n// dispatches its Msg, and if the Sub is still present on the next\n// transition's desired set, the factory will... NOT re-fire. The\n// timer handle is captured per-subscribe call; after it fires, the\n// handle is exhausted. Adding the same Sub a second time (via a new\n// id) is the only way to re-arm.\n//\n// 2. Cleanup before the timer fires cancels the pending dispatch. This\n// is the \"cancel on state exit\" pattern: model the timeout as a Sub\n// whose `subscriptions(state)` returns it only in the state where the\n// timeout should be armed. When the state changes, the substrate's\n// reconcile drops the Sub and the factory's cleanup fires before the\n// timer does.\n//\n// Like `fromInterval`, the delay lives on the Sub (`delayMs`) — same id\n// means same scheduled timeout; changing the delay requires a new id.\n// ---------------------------------------------------------------------------\n\nimport type { Sub } from \"../index\";\nimport type { SubscribeHandler } from \"./types\";\n\ntype TimeoutSubData = { delayMs: number };\n\nexport function fromTimeout<S extends Sub & TimeoutSubData, M>(\n msgFn: (sub: S) => M,\n): SubscribeHandler<S, M, unknown> {\n return (sub, _ctx, dispatch) => {\n const handle = setTimeout(() => {\n dispatch(msgFn(sub));\n }, sub.delayMs);\n return () => {\n clearTimeout(handle);\n };\n };\n}\n"]}
@@ -1,372 +0,0 @@
1
- import { dispatchIfPresent } from './chunk-ZJ5AOYBH.js';
2
- import { structuralHash, subId } from './chunk-B5VXOFMZ.js';
3
-
4
- // src/subs/define-listener.ts
5
- function defineListener(target) {
6
- return (msgFn) => {
7
- return (sub, ctx, dispatch) => {
8
- const listener = (...args) => {
9
- dispatchIfPresent(dispatch, msgFn(sub, ...args));
10
- };
11
- target.add(listener, sub, ctx);
12
- return () => {
13
- target.remove(listener, sub, ctx);
14
- };
15
- };
16
- };
17
- }
18
-
19
- // src/subs/from-broadcast-channel.ts
20
- function fromBroadcastChannel(msgFn) {
21
- return (sub, _ctx, dispatch) => {
22
- const channel = new BroadcastChannel(sub.channelName);
23
- const listener = (event) => {
24
- dispatchIfPresent(dispatch, msgFn(event, sub));
25
- };
26
- channel.addEventListener("message", listener);
27
- return () => {
28
- channel.removeEventListener("message", listener);
29
- channel.close();
30
- };
31
- };
32
- }
33
-
34
- // src/subs/from-event-source.ts
35
- function fromEventSource(opts) {
36
- return (sub, _ctx, dispatch) => {
37
- const source = new EventSource(sub.url);
38
- const messageListener = (event) => {
39
- dispatchIfPresent(dispatch, opts.onMessage(event.data, sub));
40
- };
41
- source.addEventListener("message", messageListener);
42
- const onError = opts.onError;
43
- const errorListener = onError ? (event) => {
44
- dispatchIfPresent(dispatch, onError(event, sub));
45
- } : void 0;
46
- if (errorListener) source.addEventListener("error", errorListener);
47
- const onOpen = opts.onOpen;
48
- const openListener = onOpen ? () => {
49
- dispatchIfPresent(dispatch, onOpen(sub));
50
- } : void 0;
51
- if (openListener) source.addEventListener("open", openListener);
52
- return () => {
53
- source.removeEventListener("message", messageListener);
54
- if (errorListener) source.removeEventListener("error", errorListener);
55
- if (openListener) source.removeEventListener("open", openListener);
56
- source.close();
57
- };
58
- };
59
- }
60
-
61
- // src/subs/from-event-target.ts
62
- function fromEventTarget(getTarget, eventName, msgFn) {
63
- return (sub, _ctx, dispatch) => {
64
- const target = getTarget();
65
- const listener = (event) => {
66
- dispatchIfPresent(dispatch, msgFn(event, sub));
67
- };
68
- target.addEventListener(eventName, listener);
69
- return () => {
70
- target.removeEventListener(eventName, listener);
71
- };
72
- };
73
- }
74
-
75
- // src/subs/from-interval.ts
76
- function fromInterval(msgFn) {
77
- return (sub, _ctx, dispatch) => {
78
- const handle = setInterval(() => {
79
- dispatch(msgFn(sub));
80
- }, sub.intervalMs);
81
- return () => {
82
- clearInterval(handle);
83
- };
84
- };
85
- }
86
-
87
- // src/subs/from-port.ts
88
- function fromPort(selectRuntime, port, msgFn) {
89
- return (sub, ctx, dispatch) => {
90
- const runtime = selectRuntime(ctx);
91
- return runtime.subscribePort(port, (value) => {
92
- dispatchIfPresent(dispatch, msgFn(value, sub));
93
- });
94
- };
95
- }
96
-
97
- // src/subs/from-reconnecting-web-socket.ts
98
- var defaultConnect = (url) => new WebSocket(url);
99
- var defaultSchedule = (fn, ms) => {
100
- const handle = setTimeout(fn, ms);
101
- return () => clearTimeout(handle);
102
- };
103
- function fromReconnectingWebSocket(opts) {
104
- const backoffBaseMs = opts.backoffBaseMs ?? 250;
105
- const backoffMaxMs = opts.backoffMaxMs ?? 5e3;
106
- const connect = opts.connect ?? defaultConnect;
107
- const schedule = opts.schedule ?? defaultSchedule;
108
- const { onMessage, onOpen, onError, onClose, onReconnect } = opts;
109
- return (sub, _ctx, dispatch) => {
110
- let ws = null;
111
- let attempt = 0;
112
- let opened = false;
113
- let closedByCaller = false;
114
- let cancelReconnect = null;
115
- const emit = (msg) => dispatchIfPresent(dispatch, msg);
116
- const handleClose = (code, reason) => {
117
- ws = null;
118
- if (onClose) emit(onClose(code, reason, sub));
119
- if (closedByCaller) return;
120
- const delay = Math.min(backoffBaseMs * 2 ** attempt, backoffMaxMs);
121
- attempt += 1;
122
- cancelReconnect = schedule(() => {
123
- cancelReconnect = null;
124
- if (!closedByCaller) open();
125
- }, delay);
126
- };
127
- function open() {
128
- const socket = connect(sub.wsUrl);
129
- ws = socket;
130
- socket.onopen = () => {
131
- const reconnected = opened;
132
- const reconnectCount = attempt;
133
- attempt = 0;
134
- opened = true;
135
- if (onOpen) emit(onOpen(sub));
136
- if (reconnected && onReconnect) emit(onReconnect(reconnectCount, sub));
137
- };
138
- socket.onmessage = (event) => {
139
- emit(onMessage(event.data, sub));
140
- };
141
- socket.onerror = onError ? (event) => emit(onError(event, sub)) : () => {
142
- };
143
- socket.onclose = (event) => {
144
- handleClose(event.code, event.reason);
145
- };
146
- }
147
- open();
148
- return () => {
149
- closedByCaller = true;
150
- if (cancelReconnect !== null) {
151
- cancelReconnect();
152
- cancelReconnect = null;
153
- }
154
- const socket = ws;
155
- ws = null;
156
- if (socket !== null) {
157
- socket.onopen = null;
158
- socket.onmessage = null;
159
- socket.onerror = null;
160
- socket.onclose = null;
161
- socket.close(1e3);
162
- }
163
- };
164
- };
165
- }
166
-
167
- // src/subs/from-web-socket.ts
168
- function fromWebSocket(opts) {
169
- return (sub, _ctx, dispatch) => {
170
- const ws = new WebSocket(sub.wsUrl);
171
- ws.onmessage = (event) => {
172
- dispatchIfPresent(dispatch, opts.onMessage(event.data, sub));
173
- };
174
- const onOpen = opts.onOpen;
175
- if (onOpen) {
176
- ws.onopen = () => {
177
- dispatchIfPresent(dispatch, onOpen(sub));
178
- };
179
- }
180
- const onError = opts.onError;
181
- if (onError) {
182
- ws.onerror = (event) => {
183
- dispatchIfPresent(dispatch, onError(event, sub));
184
- };
185
- }
186
- const onClose = opts.onClose;
187
- if (onClose) {
188
- ws.onclose = (event) => {
189
- dispatchIfPresent(dispatch, onClose(event.code, event.reason, sub));
190
- };
191
- }
192
- return () => {
193
- ws.onmessage = null;
194
- ws.onopen = null;
195
- ws.onerror = null;
196
- ws.onclose = null;
197
- ws.close(1e3);
198
- };
199
- };
200
- }
201
-
202
- // src/subs/managed-resource.ts
203
- function defineManagedResource(opts) {
204
- const held = /* @__PURE__ */ new Map();
205
- const keyString = (k) => structuralHash(k);
206
- const subIdFor = (key) => subId(`managed:${opts.name}:${keyString(key)}`);
207
- const subBuilder = (key) => ({
208
- id: subIdFor(key),
209
- type: "managed_resource",
210
- key
211
- });
212
- const subscribeHandler = (sub, ctx, _dispatch) => {
213
- const handle = opts.acquire(sub.key, ctx);
214
- const k = keyString(sub.key);
215
- held.set(k, handle);
216
- return () => {
217
- held.delete(k);
218
- return opts.release(handle);
219
- };
220
- };
221
- return {
222
- sub: subBuilder,
223
- // Pair the battery with a state-gate. `TKey` / `Handle` / `Ctx` are in
224
- // scope here, so `subFor` builds the fully-typed sub and `subscribe`
225
- // forwards straight to the battery's own typed `subscribe`. The entry
226
- // erases ONLY `Handle` for the combinator (`TKey` and `Ctx` stay), so the
227
- // substrate's narrowed `ManagedResourceSub<TKey>` flows in with no cast.
228
- gated: (when) => ({
229
- name: opts.name,
230
- owns: (sub) => sub.id === subIdFor(sub.key),
231
- subFor: (state) => {
232
- const key = when(state);
233
- return key === null ? null : subBuilder(key);
234
- },
235
- subscribe: subscribeHandler
236
- }),
237
- // Dep-keyed entry. `when` is the gate (the deps = the KEY); the source runs
238
- // the SAME `acquire` → hold → `release`-on-dispose lifecycle the `subscribe`
239
- // cell does, now driven by the kernel's dep-keyed reconcile. The Msg type is
240
- // `never` (a managed resource dispatches nothing); the ignored `_dispatch`
241
- // matches the source signature.
242
- depKeyed: (when) => ({
243
- deps: when,
244
- source: (state, _dispatch, ctx) => {
245
- const key = when(state);
246
- if (key === null) return () => {
247
- };
248
- return subscribeHandler(subBuilder(key), ctx);
249
- }
250
- }),
251
- subscribe: subscribeHandler,
252
- get: (key) => held.get(keyString(key)),
253
- subIdFor
254
- };
255
- }
256
- function combineManagedResources(entries) {
257
- const seen = /* @__PURE__ */ new Set();
258
- for (const entry of entries) {
259
- if (seen.has(entry.name)) {
260
- throw new Error(
261
- `[combineManagedResources] duplicate managed-resource name "${entry.name}" \u2014 names must be unique (the Sub id encodes the name; two batteries sharing it collide)`
262
- );
263
- }
264
- seen.add(entry.name);
265
- }
266
- return {
267
- subs: (state) => {
268
- const live = [];
269
- for (const entry of entries) {
270
- const sub = entry.subFor(state);
271
- if (sub !== null) live.push(sub);
272
- }
273
- return live;
274
- },
275
- subscribe: (sub, ctx, dispatch) => {
276
- const owner = entries.find((entry) => entry.owns(sub));
277
- if (owner === void 0) {
278
- throw new Error(
279
- `[combineManagedResources] no battery for sub id ${sub.id}`
280
- );
281
- }
282
- return owner.subscribe(sub, ctx, dispatch);
283
- }
284
- };
285
- }
286
-
287
- // src/subs/transport.ts
288
- function fromTransport(opts) {
289
- const live = /* @__PURE__ */ new Map();
290
- const keyString = (k) => structuralHash(k);
291
- const subIdFor = (key) => subId(`${opts.name}:${keyString(key)}`);
292
- const sub = (key) => ({
293
- id: subIdFor(key),
294
- type: "transport",
295
- key
296
- });
297
- const subscribe = (s, ctx, dispatch) => {
298
- const t = opts.openTransport(s.key, ctx);
299
- const k = keyString(s.key);
300
- let offMessage;
301
- let offClose;
302
- try {
303
- offMessage = t.onMessage((raw) => {
304
- const parsed = opts.parseInbound(raw, s.key);
305
- if (parsed === null) return;
306
- const msg = opts.onInbound(parsed, s.key);
307
- if (msg === null) return;
308
- dispatch(msg);
309
- });
310
- offClose = t.onClose(() => {
311
- dispatch(opts.lostMsg(s.key));
312
- });
313
- } catch (err) {
314
- offMessage?.();
315
- offClose?.();
316
- try {
317
- t.close();
318
- } catch (closeErr) {
319
- console.warn(
320
- `[fromTransport:${opts.name}] close during failed wiring failed`,
321
- closeErr
322
- );
323
- }
324
- throw err;
325
- }
326
- live.set(k, t);
327
- return () => {
328
- offMessage?.();
329
- offClose?.();
330
- live.delete(k);
331
- try {
332
- t.close();
333
- } catch (err) {
334
- console.warn(`[fromTransport:${opts.name}] close failed`, err);
335
- }
336
- };
337
- };
338
- return {
339
- sub,
340
- subscribe,
341
- send: (key, outbound) => {
342
- const t = live.get(keyString(key));
343
- if (t === void 0) {
344
- console.warn(
345
- `[fromTransport:${opts.name}] send dropped \u2014 no live transport for key`,
346
- keyString(key)
347
- );
348
- return;
349
- }
350
- t.send(opts.serializeOutbound(outbound));
351
- },
352
- subIdFor,
353
- // Dep-keyed entry: `when` is the gate (the deps slice → the seam key);
354
- // `source` re-runs `when(state)` to recover the typed key and opens the seam
355
- // via the battery's own `subscribe`. The kernel only calls `source` when
356
- // `deps(state)` was non-null, so `when` is non-null here; the key type never
357
- // escapes the entry (cast-free existential).
358
- depKeyed: (when) => ({
359
- deps: when,
360
- source: (state, dispatch, ctx) => {
361
- const key = when(state);
362
- if (key === null) return () => {
363
- };
364
- return subscribe(sub(key), ctx, dispatch);
365
- }
366
- })
367
- };
368
- }
369
-
370
- export { combineManagedResources, defineListener, defineManagedResource, fromBroadcastChannel, fromEventSource, fromEventTarget, fromInterval, fromPort, fromReconnectingWebSocket, fromTransport, fromWebSocket };
371
- //# sourceMappingURL=chunk-3JU6657S.js.map
372
- //# sourceMappingURL=chunk-3JU6657S.js.map