@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,686 +0,0 @@
1
- import { detectUpdateForm, foldUpdates, depsInactive, structuralHash, lookupCell, NoCellError, __DEV__, deepFreeze, assertPureResult, applyCellChecked } from './chunk-B5VXOFMZ.js';
2
- import { Result } from 'better-result';
3
-
4
- // src/observability.ts
5
- function historyTracker(runtime, size) {
6
- const buffer = [];
7
- let stopped = false;
8
- const push = (entry) => {
9
- buffer.push(entry);
10
- if (buffer.length > size) buffer.shift();
11
- };
12
- const unobserve = size <= 0 ? () => {
13
- } : runtime.observe((msg, state) => {
14
- push({ msg, state });
15
- });
16
- const unboot = size <= 0 ? () => {
17
- } : runtime.onBoot((state) => {
18
- push({ msg: null, state });
19
- });
20
- return {
21
- snapshot() {
22
- return buffer.slice();
23
- },
24
- stop() {
25
- if (stopped) return;
26
- stopped = true;
27
- unobserve();
28
- unboot();
29
- }
30
- };
31
- }
32
- function absurd(x) {
33
- throw new Error(`unreachable: ${JSON.stringify(x)}`);
34
- }
35
- var noop = (state, _msg) => [state, []];
36
- var definedPortNames = /* @__PURE__ */ new Set();
37
- var PortNameCollisionError = class extends Error {
38
- name = "PortNameCollisionError";
39
- _tag = "PortNameCollisionError";
40
- constructor(portName) {
41
- super(
42
- `definePort: a port named "${portName}" was already defined. Each definePort call must use a unique name. If two modules need the same port, export it from one module and import it.`
43
- );
44
- }
45
- };
46
- var SubIdCollisionError = class extends Error {
47
- name = "SubIdCollisionError";
48
- _tag = "SubIdCollisionError";
49
- constructor(id, declaredType, conflictingType) {
50
- super(
51
- `@demlik/tea: Sub.id collision: id="${id}" declared as type="${declaredType}" and type="${conflictingType}"`
52
- );
53
- }
54
- };
55
- function __resetPortRegistry() {
56
- definedPortNames.clear();
57
- }
58
- var QuiescenceTimeoutError = class extends Error {
59
- constructor(iterations) {
60
- super(
61
- `@demlik/tea: idle() did not reach quiescence after ${iterations} iterations \u2014 the dispatch tail kept advancing. The machine is likely livelocking (an interpret handler enqueues a follow-up Msg that enqueues another, without end). Bound the follow-up chain in the reducer, or stop the runtime.`
62
- );
63
- this.iterations = iterations;
64
- }
65
- iterations;
66
- name = "QuiescenceTimeoutError";
67
- _tag = "QuiescenceTimeoutError";
68
- };
69
- var RuntimeDiscardNotice = class extends Error {
70
- };
71
- var RuntimeDiscardedError = class extends RuntimeDiscardNotice {
72
- constructor(pendingCmds) {
73
- super(
74
- `@demlik/tea: runtime stopped with ${pendingCmds} Cmd(s) in flight \u2014 their results will reach no listener. In React this is usually a ctx-identity change rebuilding useMachine's runtime mid-flight: stabilize the ctx (useMemo / useState) so the runtime outlives the Cmds it started. An intentional teardown (unmount, navigation) can silence this with a run({ onError }) sink that ignores phase: "discard".`
75
- );
76
- this.pendingCmds = pendingCmds;
77
- }
78
- pendingCmds;
79
- name = "RuntimeDiscardedError";
80
- _tag = "RuntimeDiscardedError";
81
- };
82
- var IdentityDropNotice = class extends RuntimeDiscardNotice {
83
- constructor(msgType) {
84
- super(
85
- `@demlik/tea: Msg "${msgType}" was addressed to a different instance than this state owns and was dropped before \`update\` ran \u2014 the machine's \`identity\` filter working as declared. If this Msg was meant for THIS instance, its \`ofMsg\` projection disagrees with \`ofState\`; if the instance is being reused across runs, route the message to the run that owns it.`
86
- );
87
- this.msgType = msgType;
88
- }
89
- msgType;
90
- name = "IdentityDropNotice";
91
- _tag = "IdentityDropNotice";
92
- };
93
- var DisposeTimeoutNotice = class extends RuntimeDiscardNotice {
94
- constructor(pendingDisposals, timeoutMs) {
95
- super(
96
- `@demlik/tea: stop() gave up waiting for ${pendingDisposals} async teardown(s) after ${timeoutMs}ms \u2014 the resources they release may still be open. Make \`release\` / the Sub cleanup settle (bound its own IO), or raise run({ disposeTimeoutMs }).`
97
- );
98
- this.pendingDisposals = pendingDisposals;
99
- this.timeoutMs = timeoutMs;
100
- }
101
- pendingDisposals;
102
- timeoutMs;
103
- name = "DisposeTimeoutNotice";
104
- _tag = "DisposeTimeoutNotice";
105
- };
106
- var DispatchDiscardedError = class extends RuntimeDiscardNotice {
107
- constructor(msgType) {
108
- super(
109
- `@demlik/tea: Msg "${msgType}" arrived while the runtime was stopping and was discarded \u2014 stop() refuses new work so the drain terminates. It is the result of a Cmd that outlived its runtime; keep the runtime alive until the Cmd settles (in React: stabilize useMachine's ctx) if the transition matters.`
110
- );
111
- this.msgType = msgType;
112
- }
113
- msgType;
114
- name = "DispatchDiscardedError";
115
- _tag = "DispatchDiscardedError";
116
- };
117
- function definePort(name) {
118
- let isHmr = false;
119
- try {
120
- const meta = import.meta;
121
- isHmr = meta?.hot !== void 0 && meta?.hot !== null;
122
- } catch {
123
- isHmr = false;
124
- }
125
- if (!isHmr && definedPortNames.has(name)) {
126
- throw new PortNameCollisionError(name);
127
- }
128
- definedPortNames.add(name);
129
- return { __brand: "port", name };
130
- }
131
- function schemaMigrate(schema, upcast = (raw) => raw) {
132
- return (raw) => {
133
- let migrated;
134
- try {
135
- migrated = upcast(raw);
136
- } catch {
137
- return null;
138
- }
139
- const parsed = schema.safeParse(migrated);
140
- return parsed.success ? parsed.data : null;
141
- };
142
- }
143
- function defineMachine(m) {
144
- if (m.__form === void 0) {
145
- Object.defineProperty(m, "__form", {
146
- value: detectUpdateForm(m.update),
147
- enumerable: false,
148
- writable: false,
149
- configurable: true
150
- });
151
- }
152
- return m;
153
- }
154
- function asReducer(reducer) {
155
- return reducer;
156
- }
157
- function replay(machine, opts) {
158
- const loaded = opts.loaded ?? null;
159
- const [initialState, initCmds] = machine.init(loaded, opts.ctx);
160
- if (loaded !== null && initCmds.length > 0) {
161
- throw new Error(
162
- "TEA contract violation: machine.init must return [state, []] (no Cmds) when `loaded` is non-null. Init's rehydrate branch is a pure state passthrough \u2014 the migration/parse boundary, not the boot-effect hook.\n\nRoutes for boot effects:\n - Stateless infrastructure (e.g. chrome.alarms ensure) \u2192 host module top level, outside TEA.\n - State-conditional resume (e.g. re-attach a session) \u2192 a `boot` Msg dispatched once from the host after `run(...)` returns, handled in update.\n\nSee .patterns/tea/tea-invariants.md (Invariant 2)."
163
- );
164
- }
165
- const { state, cmds: foldedCmds } = foldUpdates(
166
- machine,
167
- initialState,
168
- opts.msgs
169
- );
170
- const cmds = [...initCmds, ...foldedCmds];
171
- const subs = machine.subscriptions ? [...machine.subscriptions(state)] : [];
172
- const depSubs = [];
173
- if (machine.subs) {
174
- for (const [index, entry] of machine.subs.entries()) {
175
- const deps = entry.deps(state);
176
- if (!depsInactive(deps))
177
- depSubs.push({ index, id: structuralHash(deps) });
178
- }
179
- }
180
- return { state, cmds, subs, depSubs };
181
- }
182
- function wrapDetached(handler) {
183
- return (cmd, ctx, dispatch) => {
184
- if (dispatch === void 0) {
185
- throw new Error(
186
- "@demlik/tea: a wrapDetached handler was invoked without the injected dispatch. The kernel always supplies it; call the handler through the runtime, not directly."
187
- );
188
- }
189
- return handler(cmd, ctx, dispatch);
190
- };
191
- }
192
- function tryApplyCell(machine, state, msg) {
193
- const { cell, stateName } = lookupCell(machine, state, msg);
194
- if (cell === void 0) {
195
- return Result.err(new NoCellError(msg.type, stateName));
196
- }
197
- return Result.ok(cell(state, msg));
198
- }
199
- function tryFoldMsgs(machine, base, msgs) {
200
- let state = base;
201
- for (const [index, msg] of msgs.entries()) {
202
- if (__DEV__) deepFreeze(state);
203
- const stepped = tryApplyCell(machine, state, msg);
204
- if (Result.isError(stepped)) {
205
- return Result.err({ index, msg, error: stepped.error });
206
- }
207
- if (__DEV__) assertPureResult(stepped.value, msg.type);
208
- state = stepped.value[0];
209
- }
210
- return Result.ok(state);
211
- }
212
- function tryInterpret(work, onOk, onErr) {
213
- return async (cmd, ctx) => {
214
- const result = await Result.tryPromise({
215
- try: () => work(cmd, ctx),
216
- catch: (error) => error
217
- });
218
- return result.match({
219
- ok: (value) => onOk(value, cmd),
220
- err: (error) => onErr(error, cmd)
221
- });
222
- };
223
- }
224
-
225
- // src/run.ts
226
- function defaultOnError(error, _context) {
227
- if (error instanceof RuntimeDiscardNotice) {
228
- console.warn(error);
229
- return;
230
- }
231
- setTimeout(() => {
232
- throw error;
233
- }, 0);
234
- }
235
- function normalizeSupervision(supervision) {
236
- if (supervision === void 0) return { strategy: "stop" };
237
- if (typeof supervision === "string") return { strategy: supervision };
238
- return supervision;
239
- }
240
- function run(machine, opts) {
241
- const { store } = opts;
242
- const ctx = opts.ctx ?? {};
243
- const idleCap = opts.__idleCap ?? 1e5;
244
- const disposeTimeoutMs = opts.disposeTimeoutMs ?? 5e3;
245
- const projectEvents = opts.events ?? (() => []);
246
- const isTerminal = opts.terminal ?? (() => false);
247
- const onError = opts.onError ?? defaultOnError;
248
- const reportError = (error, context) => {
249
- try {
250
- onError(error, context);
251
- } catch (sinkError) {
252
- defaultOnError(sinkError);
253
- }
254
- };
255
- function fanout(items, phase, fn) {
256
- for (const item of items) {
257
- try {
258
- fn(item);
259
- } catch (err) {
260
- reportError(err, { phase });
261
- }
262
- }
263
- }
264
- const supervision = normalizeSupervision(opts.supervision);
265
- let state;
266
- let bootError = null;
267
- let gate = "open";
268
- let inFlightCmds = 0;
269
- const subRegistry = /* @__PURE__ */ new Map();
270
- const depSubRegistry = /* @__PURE__ */ new Map();
271
- const listeners = /* @__PURE__ */ new Set();
272
- const observers = /* @__PURE__ */ new Set();
273
- const bootHandlers = /* @__PURE__ */ new Set();
274
- let booted = false;
275
- const eventHandlers = /* @__PURE__ */ new Map();
276
- const doneWaiters = /* @__PURE__ */ new Set();
277
- const portRegistry = /* @__PURE__ */ new Map();
278
- function portEmit(port, value) {
279
- const subscribers = portRegistry.get(port);
280
- if (!subscribers || subscribers.size === 0) return;
281
- fanout(subscribers, "port-emit", (listener) => listener(value));
282
- }
283
- const augmentedCtx = { ...ctx, emit: portEmit };
284
- let tail = Promise.resolve();
285
- function stopSubs(ids) {
286
- for (const id of ids) {
287
- const cleanup = subRegistry.get(id);
288
- if (cleanup === void 0) continue;
289
- try {
290
- trackDisposal(cleanup());
291
- } catch (err) {
292
- reportError(err, { phase: "sub-cleanup" });
293
- }
294
- subRegistry.delete(id);
295
- }
296
- }
297
- const pendingDisposals = /* @__PURE__ */ new Set();
298
- function trackDisposal(result) {
299
- if (!(result instanceof Promise)) return;
300
- const settling = result.catch((err) => {
301
- reportError(err, { phase: "sub-cleanup" });
302
- }).finally(() => {
303
- pendingDisposals.delete(settling);
304
- });
305
- pendingDisposals.add(settling);
306
- }
307
- async function drainDisposals() {
308
- if (pendingDisposals.size === 0) return;
309
- const outstanding = [...pendingDisposals];
310
- let timer;
311
- try {
312
- const outcome = await Promise.race([
313
- Promise.all(outstanding).then(() => "settled"),
314
- new Promise((resolve) => {
315
- timer = setTimeout(() => resolve("timeout"), disposeTimeoutMs);
316
- })
317
- ]);
318
- if (outcome === "timeout") {
319
- reportError(
320
- new DisposeTimeoutNotice(outstanding.length, disposeTimeoutMs),
321
- { phase: "discard" }
322
- );
323
- }
324
- } finally {
325
- if (timer !== void 0) clearTimeout(timer);
326
- }
327
- }
328
- function disposeDepSubs(indices) {
329
- for (const index of indices) {
330
- const running = depSubRegistry.get(index);
331
- if (running === void 0) continue;
332
- try {
333
- trackDisposal(running.dispose());
334
- } catch (err) {
335
- reportError(err, { phase: "sub-cleanup" });
336
- }
337
- depSubRegistry.delete(index);
338
- }
339
- }
340
- function reconcileDepSubs() {
341
- let firstError = null;
342
- const subs = machine.subs;
343
- if (!subs) return firstError;
344
- for (const [i, entry] of subs.entries()) {
345
- let deps;
346
- let id;
347
- try {
348
- deps = entry.deps(state);
349
- if (depsInactive(deps)) {
350
- disposeDepSubs([i]);
351
- continue;
352
- }
353
- id = structuralHash(deps);
354
- } catch (err) {
355
- if (firstError === null) firstError = err;
356
- continue;
357
- }
358
- const running = depSubRegistry.get(i);
359
- if (running !== void 0 && running.runningId === id) {
360
- continue;
361
- }
362
- disposeDepSubs([i]);
363
- try {
364
- const dispose = entry.source(state, dispatchUnawaited, ctx);
365
- depSubRegistry.set(i, { runningId: id, dispose });
366
- } catch (err) {
367
- if (firstError === null) firstError = err;
368
- }
369
- }
370
- return firstError;
371
- }
372
- function reconcileSubs() {
373
- const depError = reconcileDepSubs();
374
- if (!machine.subscriptions) {
375
- if (depError !== null) throw depError;
376
- return;
377
- }
378
- const desired = machine.subscriptions(state);
379
- const desiredIds = /* @__PURE__ */ new Set();
380
- const desiredTypeById = /* @__PURE__ */ new Map();
381
- for (const sub of desired) {
382
- const existing = desiredTypeById.get(sub.id);
383
- if (existing !== void 0 && existing !== sub.type) {
384
- throw new SubIdCollisionError(sub.id, existing, sub.type);
385
- }
386
- desiredTypeById.set(sub.id, sub.type);
387
- }
388
- for (const sub of desired) desiredIds.add(sub.id);
389
- stopSubs([...subRegistry.keys()].filter((id) => !desiredIds.has(id)));
390
- let firstStartError = depError;
391
- for (const sub of desired) {
392
- if (subRegistry.has(sub.id)) continue;
393
- const handler = machine.subscribe?.[sub.type];
394
- if (!handler) {
395
- continue;
396
- }
397
- try {
398
- const cleanup = handler(
399
- sub,
400
- ctx,
401
- dispatchUnawaited
402
- );
403
- subRegistry.set(sub.id, cleanup);
404
- } catch (err) {
405
- if (firstStartError === null) firstStartError = err;
406
- }
407
- }
408
- if (firstStartError !== null) throw firstStartError;
409
- }
410
- const interpretMap = machine.interpret ?? {};
411
- const dispatchUnawaited = (msg) => {
412
- enqueueDispatch(msg).catch(reportUndelivered);
413
- };
414
- function reportUndelivered(error) {
415
- reportError(error, {
416
- phase: error instanceof DispatchDiscardedError ? "discard" : "follow-up"
417
- });
418
- }
419
- function trackInFlight(work) {
420
- inFlightCmds++;
421
- return Promise.resolve(work).finally(() => {
422
- inFlightCmds--;
423
- });
424
- }
425
- async function runInterpret(cmds) {
426
- for (const cmd of cmds) {
427
- const handler = interpretMap[cmd.type];
428
- if (!handler) continue;
429
- const follow = await trackInFlight(
430
- handler(
431
- cmd,
432
- augmentedCtx,
433
- dispatchUnawaited
434
- )
435
- );
436
- if (follow !== void 0 && follow !== null) {
437
- enqueueDispatch(follow).catch(reportUndelivered);
438
- }
439
- }
440
- }
441
- function fireListeners() {
442
- fanout(listeners, "listener", (listener) => listener());
443
- }
444
- function fireObservers(msg) {
445
- if (observers.size === 0 || state === void 0) return;
446
- const snapshot = state;
447
- fanout(observers, "observer", (observer) => observer(msg, snapshot));
448
- }
449
- function fireEvents(msg) {
450
- if (eventHandlers.size === 0 || state === void 0) return;
451
- let events;
452
- try {
453
- events = projectEvents(msg, state);
454
- } catch (err) {
455
- reportError(err, { phase: "event" });
456
- return;
457
- }
458
- for (const event of events) {
459
- const bucket = eventHandlers.get(event.type);
460
- if (bucket === void 0) continue;
461
- fanout(bucket, "event", (handler) => handler(event));
462
- }
463
- }
464
- function fireBoot() {
465
- booted = true;
466
- if (bootHandlers.size === 0 || state === void 0) return;
467
- const snapshot = state;
468
- fanout(bootHandlers, "boot", (handler) => handler(snapshot));
469
- }
470
- function settleDoneWaiters() {
471
- if (doneWaiters.size === 0 || state === void 0) return;
472
- if (!isTerminal(state)) return;
473
- const snapshot = state;
474
- const parked = [...doneWaiters];
475
- doneWaiters.clear();
476
- for (const resolve of parked) resolve(snapshot);
477
- }
478
- async function commit(next, msg, cmds) {
479
- state = next;
480
- if (store) await store.save(next);
481
- reconcileSubs();
482
- await runInterpret(cmds);
483
- fireListeners();
484
- fireObservers(msg);
485
- fireEvents(msg);
486
- settleDoneWaiters();
487
- }
488
- function isMisaddressed(msg, current) {
489
- if (machine.identity === void 0) return false;
490
- const addressed = machine.identity.ofMsg(msg);
491
- if (addressed === void 0) return false;
492
- const own = machine.identity.ofState(current);
493
- if (own === void 0) return false;
494
- return structuralHash(addressed) !== structuralHash(own);
495
- }
496
- async function stepDispatch(msg) {
497
- if (state === void 0) {
498
- throw new Error("@demlik/tea: runtime not booted");
499
- }
500
- let next;
501
- let cmds;
502
- try {
503
- if (isMisaddressed(msg, state)) {
504
- reportError(new IdentityDropNotice(msg.type), {
505
- phase: "identity-drop"
506
- });
507
- return;
508
- }
509
- [next, cmds] = applyCellChecked(machine, state, msg);
510
- } catch (reduceError) {
511
- reportError(reduceError, { phase: "reduce" });
512
- switch (supervision.strategy) {
513
- case "restart": {
514
- await commit(supervision.rehydrate(state, msg, reduceError), msg, []);
515
- return;
516
- }
517
- case "escalate":
518
- throw reduceError;
519
- default:
520
- gate = "closed";
521
- throw reduceError;
522
- }
523
- }
524
- await commit(next, msg, cmds);
525
- }
526
- let pendingInitCmds = [];
527
- if (!store) {
528
- const [initialState, initCmds] = machine.init(null, ctx);
529
- state = initialState;
530
- pendingInitCmds = initCmds;
531
- }
532
- async function stepBootEffects() {
533
- if (store) {
534
- const raw = await store.load();
535
- const parsed = store.migrate(raw);
536
- const [initialState, initCmds] = machine.init(parsed, ctx);
537
- state = initialState;
538
- pendingInitCmds = initCmds;
539
- await store.save(state);
540
- }
541
- reconcileSubs();
542
- await runInterpret(pendingInitCmds);
543
- fireListeners();
544
- fireBoot();
545
- settleDoneWaiters();
546
- }
547
- function enqueueDispatch(msg) {
548
- if (gate !== "open") {
549
- return Promise.reject(
550
- gate === "draining" ? new DispatchDiscardedError(msg.type) : new Error("@demlik/tea: runtime stopped")
551
- );
552
- }
553
- const next = tail.then(() => {
554
- if (bootError !== null) throw bootError;
555
- return stepDispatch(msg);
556
- });
557
- tail = next.catch(() => {
558
- });
559
- return next;
560
- }
561
- async function drainToQuiescence() {
562
- for (let i = 0; i < idleCap; i++) {
563
- const observed = tail;
564
- await observed;
565
- if (tail === observed) return;
566
- }
567
- throw new QuiescenceTimeoutError(idleCap);
568
- }
569
- async function dispatchToQuiescence(msg, opts2) {
570
- await enqueueDispatch(msg);
571
- if (opts2?.settle === "once") return;
572
- await drainToQuiescence();
573
- }
574
- const bootPromise = stepBootEffects();
575
- tail = bootPromise.catch((err) => {
576
- bootError = err;
577
- });
578
- const readyPromise = bootPromise.then(
579
- () => runtime
580
- );
581
- const runtime = {
582
- dispatch: dispatchToQuiescence,
583
- dispatchOnce: enqueueDispatch,
584
- getState() {
585
- return state;
586
- },
587
- subscribe(listener) {
588
- listeners.add(listener);
589
- return () => {
590
- listeners.delete(listener);
591
- };
592
- },
593
- observe(observer) {
594
- observers.add(observer);
595
- return () => {
596
- observers.delete(observer);
597
- };
598
- },
599
- onBoot(handler) {
600
- if (booted && state !== void 0) {
601
- const snapshot = state;
602
- fanout([handler], "boot", (h) => h(snapshot));
603
- return () => {
604
- };
605
- }
606
- bootHandlers.add(handler);
607
- return () => {
608
- bootHandlers.delete(handler);
609
- };
610
- },
611
- on(type, handler) {
612
- let bucket = eventHandlers.get(type);
613
- if (bucket === void 0) {
614
- bucket = /* @__PURE__ */ new Set();
615
- eventHandlers.set(type, bucket);
616
- }
617
- const erased = handler;
618
- bucket.add(erased);
619
- return () => {
620
- const set = eventHandlers.get(type);
621
- if (set === void 0) return;
622
- set.delete(erased);
623
- if (set.size === 0) eventHandlers.delete(type);
624
- };
625
- },
626
- subscribePort(port, listener) {
627
- const key = port;
628
- let bucket = portRegistry.get(key);
629
- if (!bucket) {
630
- bucket = /* @__PURE__ */ new Set();
631
- portRegistry.set(key, bucket);
632
- }
633
- const erased = listener;
634
- bucket.add(erased);
635
- return () => {
636
- const set = portRegistry.get(key);
637
- if (!set) return;
638
- set.delete(erased);
639
- if (set.size === 0) portRegistry.delete(key);
640
- };
641
- },
642
- emitPort(port, value) {
643
- portEmit(port, value);
644
- },
645
- ready: readyPromise,
646
- idle() {
647
- return drainToQuiescence();
648
- },
649
- result() {
650
- const current = state;
651
- return isTerminal(current) ? current : void 0;
652
- },
653
- done() {
654
- const current = state;
655
- if (isTerminal(current)) return Promise.resolve(current);
656
- return new Promise((resolve) => {
657
- doneWaiters.add(resolve);
658
- });
659
- },
660
- async stop() {
661
- if (gate === "open") gate = "draining";
662
- if (inFlightCmds > 0) {
663
- reportError(new RuntimeDiscardedError(inFlightCmds), {
664
- phase: "discard"
665
- });
666
- }
667
- await tail;
668
- gate = "closed";
669
- stopSubs([...subRegistry.keys()]);
670
- disposeDepSubs([...depSubRegistry.keys()]);
671
- await drainDisposals();
672
- if (store && state !== void 0 && bootError === null) {
673
- try {
674
- await store.save(state);
675
- } catch (error) {
676
- reportError(error, { phase: "stop-save" });
677
- }
678
- }
679
- }
680
- };
681
- return runtime;
682
- }
683
-
684
- export { DispatchDiscardedError, DisposeTimeoutNotice, IdentityDropNotice, PortNameCollisionError, QuiescenceTimeoutError, RuntimeDiscardNotice, RuntimeDiscardedError, SubIdCollisionError, __resetPortRegistry, absurd, asReducer, defineMachine, definePort, historyTracker, noop, replay, run, schemaMigrate, tryApplyCell, tryFoldMsgs, tryInterpret, wrapDetached };
685
- //# sourceMappingURL=chunk-5EHLEUTL.js.map
686
- //# sourceMappingURL=chunk-5EHLEUTL.js.map