@demlik/tea 0.13.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 (372) hide show
  1. package/README.md +11 -9
  2. package/dist/agent/index.d.ts +637 -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-RH5EFRVJ.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-O4MVQTEJ.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-DMYGQB4O.js → chunk-HYDWG35Q.js} +23 -6
  19. package/dist/chunk-HYDWG35Q.js.map +1 -0
  20. package/dist/{chunk-YUXP55T2.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-Co0LWkIA.d.ts → core-CTzMJ82M.d.ts} +72 -23
  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 +42 -29
  43. package/dist/do/index.js +36 -25
  44. package/dist/do/index.js.map +1 -1
  45. package/dist/{durable-effects-C6uwzjb5.d.ts → durable-effects-B0-qGQDy.d.ts} +2 -2
  46. package/dist/extension/index.d.ts +300 -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 -12
  55. package/dist/{fan-out/index.d.ts → index-6A7dB8f6.d.ts} +7 -9
  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 -78
  61. package/dist/{monitored-run/index.d.ts → index-NjrT3fL2.d.ts} +37 -13
  62. package/dist/{recorder/index.d.ts → index-TvRb1KVf.d.ts} +4 -7
  63. package/dist/{deadline/index.d.ts → index-q0hXFeZ0.d.ts} +155 -9
  64. package/dist/index.d.ts +711 -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 +1 -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 +18 -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 +104 -6
  77. package/dist/node/index.js +132 -9
  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 +4 -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 +247 -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 -5
  88. package/dist/persistence/index.js +6 -0
  89. package/dist/react/index.d.ts +2 -2
  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 +2 -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 +143 -12
  102. package/dist/{throttled-input → timing}/index.js +57 -12
  103. package/dist/timing/index.js.map +1 -0
  104. package/dist/{types-XS_miRnB.d.ts → types-DP3f5NIl.d.ts} +1 -1
  105. package/dist/work-queue/index.d.ts +130 -54
  106. package/dist/work-queue/index.js +3 -2
  107. package/dist/work-queue/index.js.map +1 -1
  108. package/package.json +45 -218
  109. package/dist/authed-call/index.d.ts +0 -120
  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 -101
  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 -152
  117. package/dist/cache/index.js +0 -8
  118. package/dist/chart/index.d.ts +0 -218
  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 -86
  122. package/dist/chart/inspect/index.js +0 -5
  123. package/dist/chart/inspect/react.d.ts +0 -113
  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 -362
  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 -84
  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 -117
  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-3I52QZZ5.js +0 -519
  193. package/dist/chunk-3I52QZZ5.js.map +0 -1
  194. package/dist/chunk-3ZAFFRRB.js +0 -457
  195. package/dist/chunk-3ZAFFRRB.js.map +0 -1
  196. package/dist/chunk-4EQZ76JC.js +0 -33
  197. package/dist/chunk-4EQZ76JC.js.map +0 -1
  198. package/dist/chunk-4KLG43GY.js +0 -223
  199. package/dist/chunk-4KLG43GY.js.map +0 -1
  200. package/dist/chunk-7FRZ2CT2.js +0 -424
  201. package/dist/chunk-7FRZ2CT2.js.map +0 -1
  202. package/dist/chunk-AZZLE7XR.js +0 -62
  203. package/dist/chunk-AZZLE7XR.js.map +0 -1
  204. package/dist/chunk-BYQUGDD3.js +0 -16
  205. package/dist/chunk-BYQUGDD3.js.map +0 -1
  206. package/dist/chunk-CIQG5L42.js +0 -685
  207. package/dist/chunk-CIQG5L42.js.map +0 -1
  208. package/dist/chunk-CLM6ERNO.js +0 -61
  209. package/dist/chunk-CLM6ERNO.js.map +0 -1
  210. package/dist/chunk-COS5MSTO.js +0 -88
  211. package/dist/chunk-COS5MSTO.js.map +0 -1
  212. package/dist/chunk-CRPZJVD2.js +0 -71
  213. package/dist/chunk-CRPZJVD2.js.map +0 -1
  214. package/dist/chunk-D62FDQKE.js +0 -53
  215. package/dist/chunk-D62FDQKE.js.map +0 -1
  216. package/dist/chunk-D736QUGF.js.map +0 -1
  217. package/dist/chunk-DGE4PV4A.js +0 -26
  218. package/dist/chunk-DGE4PV4A.js.map +0 -1
  219. package/dist/chunk-DMYGQB4O.js.map +0 -1
  220. package/dist/chunk-EWJP3YYP.js.map +0 -1
  221. package/dist/chunk-FV3Z5MBE.js.map +0 -1
  222. package/dist/chunk-HCEVHFJ7.js +0 -54
  223. package/dist/chunk-HCEVHFJ7.js.map +0 -1
  224. package/dist/chunk-J6527VRQ.js.map +0 -1
  225. package/dist/chunk-JELSZN25.js +0 -47
  226. package/dist/chunk-JELSZN25.js.map +0 -1
  227. package/dist/chunk-K575PT4S.js.map +0 -1
  228. package/dist/chunk-L57ZOT5K.js +0 -184
  229. package/dist/chunk-L57ZOT5K.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-NR7BU22N.js +0 -758
  234. package/dist/chunk-NR7BU22N.js.map +0 -1
  235. package/dist/chunk-O4MVQTEJ.js.map +0 -1
  236. package/dist/chunk-OOYD44JI.js +0 -317
  237. package/dist/chunk-OOYD44JI.js.map +0 -1
  238. package/dist/chunk-Q2UM7BXU.js.map +0 -1
  239. package/dist/chunk-RH5EFRVJ.js.map +0 -1
  240. package/dist/chunk-S2EGRPCM.js +0 -47
  241. package/dist/chunk-S2EGRPCM.js.map +0 -1
  242. package/dist/chunk-SINXE47Y.js +0 -55
  243. package/dist/chunk-SINXE47Y.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-VYFAZN3F.js +0 -372
  249. package/dist/chunk-VYFAZN3F.js.map +0 -1
  250. package/dist/chunk-WRAA7GVZ.js +0 -209
  251. package/dist/chunk-WRAA7GVZ.js.map +0 -1
  252. package/dist/chunk-XGELA764.js +0 -163
  253. package/dist/chunk-XGELA764.js.map +0 -1
  254. package/dist/chunk-YUXP55T2.js.map +0 -1
  255. package/dist/chunk-YWIKDKHY.js +0 -307
  256. package/dist/chunk-YWIKDKHY.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-ZSUUOEPL.js +0 -731
  260. package/dist/chunk-ZSUUOEPL.js.map +0 -1
  261. package/dist/chunk-ZVJZ72HY.js.map +0 -1
  262. package/dist/circuit-breaker/index.d.ts +0 -197
  263. package/dist/circuit-breaker/index.js +0 -3
  264. package/dist/circuit-breaker/index.js.map +0 -1
  265. package/dist/deadline/index.js +0 -6
  266. package/dist/deadline/index.js.map +0 -1
  267. package/dist/debounce/index.js +0 -3
  268. package/dist/debounce/index.js.map +0 -1
  269. package/dist/extension/react.d.ts +0 -121
  270. package/dist/extension/react.js +0 -75
  271. package/dist/extension/react.js.map +0 -1
  272. package/dist/extension/subs/index.d.ts +0 -45
  273. package/dist/extension/subs/index.js +0 -80
  274. package/dist/extension/subs/index.js.map +0 -1
  275. package/dist/extension/test-utils.d.ts +0 -128
  276. package/dist/extension/test-utils.js +0 -277
  277. package/dist/extension/test-utils.js.map +0 -1
  278. package/dist/fan-out/index.js +0 -5
  279. package/dist/fan-out/index.js.map +0 -1
  280. package/dist/fold-BJPdjc9w.d.ts +0 -435
  281. package/dist/graph-B3L5e0N1.d.ts +0 -923
  282. package/dist/idempotency/adapter.d.ts +0 -62
  283. package/dist/idempotency/adapter.js +0 -4
  284. package/dist/idempotency/adapter.js.map +0 -1
  285. package/dist/idempotent-intake/index.d.ts +0 -188
  286. package/dist/idempotent-intake/index.js +0 -7
  287. package/dist/idempotent-intake/index.js.map +0 -1
  288. package/dist/journal/index.d.ts +0 -373
  289. package/dist/journal/index.js +0 -3
  290. package/dist/journal/index.js.map +0 -1
  291. package/dist/llm-call/index.d.ts +0 -311
  292. package/dist/llm-call/index.js +0 -16
  293. package/dist/llm-call/index.js.map +0 -1
  294. package/dist/machine-BtFWQmmq.d.ts +0 -804
  295. package/dist/monitored-run/index.js +0 -10
  296. package/dist/monitored-run/index.js.map +0 -1
  297. package/dist/paginated-walk/index.d.ts +0 -235
  298. package/dist/paginated-walk/index.js +0 -16
  299. package/dist/paginated-walk/index.js.map +0 -1
  300. package/dist/paginator/index.js +0 -3
  301. package/dist/paginator/index.js.map +0 -1
  302. package/dist/pbt/arbitraries/index.d.ts +0 -136
  303. package/dist/pbt/arbitraries/index.js +0 -3
  304. package/dist/pbt/arbitraries/index.js.map +0 -1
  305. package/dist/pbt/runners/index.d.ts +0 -118
  306. package/dist/pbt/runners/index.js +0 -5
  307. package/dist/pbt/runners/index.js.map +0 -1
  308. package/dist/poller/index.d.ts +0 -352
  309. package/dist/poller/index.js +0 -115
  310. package/dist/poller/index.js.map +0 -1
  311. package/dist/prediction/index.d.ts +0 -131
  312. package/dist/prediction/index.js +0 -4
  313. package/dist/prediction/index.js.map +0 -1
  314. package/dist/protocol-B5YmJr0d.d.ts +0 -45
  315. package/dist/pure/index.d.ts +0 -3
  316. package/dist/pure/index.js +0 -4
  317. package/dist/pure/index.js.map +0 -1
  318. package/dist/rate-limit/index.d.ts +0 -115
  319. package/dist/rate-limit/index.js +0 -3
  320. package/dist/rate-limit/index.js.map +0 -1
  321. package/dist/reconciler/index.d.ts +0 -193
  322. package/dist/reconciler/index.js +0 -164
  323. package/dist/reconciler/index.js.map +0 -1
  324. package/dist/recorder/index.js +0 -3
  325. package/dist/recorder/index.js.map +0 -1
  326. package/dist/reducer-4GNR6b8B.d.ts +0 -447
  327. package/dist/resilient-call/index.d.ts +0 -320
  328. package/dist/resilient-call/index.js +0 -14
  329. package/dist/resilient-call/index.js.map +0 -1
  330. package/dist/retry-to-success/index.d.ts +0 -109
  331. package/dist/retry-to-success/index.js +0 -37
  332. package/dist/retry-to-success/index.js.map +0 -1
  333. package/dist/run-pAcmBpah.d.ts +0 -713
  334. package/dist/runtime-types-CNLmhWif.d.ts +0 -517
  335. package/dist/saga/index.d.ts +0 -241
  336. package/dist/saga/index.js +0 -150
  337. package/dist/saga/index.js.map +0 -1
  338. package/dist/samples-B3My5oh2.d.ts +0 -59
  339. package/dist/snapshot/index.js +0 -5
  340. package/dist/snapshot/index.js.map +0 -1
  341. package/dist/subs/index.d.ts +0 -472
  342. package/dist/subs/index.js +0 -7
  343. package/dist/subs/index.js.map +0 -1
  344. package/dist/throttle/index.d.ts +0 -134
  345. package/dist/throttle/index.js +0 -3
  346. package/dist/throttle/index.js.map +0 -1
  347. package/dist/throttled-input/index.js.map +0 -1
  348. package/dist/token-refresh/index.d.ts +0 -216
  349. package/dist/token-refresh/index.js +0 -6
  350. package/dist/token-refresh/index.js.map +0 -1
  351. package/dist/trace-replay/index.js +0 -6
  352. package/dist/trace-replay/index.js.map +0 -1
  353. package/dist/with-deadline/index.d.ts +0 -197
  354. package/dist/with-deadline/index.js +0 -111
  355. package/dist/with-deadline/index.js.map +0 -1
  356. package/dist/with-resilience/index.d.ts +0 -225
  357. package/dist/with-resilience/index.js +0 -240
  358. package/dist/with-resilience/index.js.map +0 -1
  359. package/dist/with-telemetry/index.d.ts +0 -150
  360. package/dist/with-telemetry/index.js +0 -70
  361. package/dist/with-telemetry/index.js.map +0 -1
  362. package/dist/work-queue/adapter.d.ts +0 -84
  363. package/dist/work-queue/adapter.js +0 -4
  364. package/dist/work-queue/adapter.js.map +0 -1
  365. package/dist/work-queue/ops.d.ts +0 -71
  366. package/dist/work-queue/ops.js +0 -3
  367. package/dist/work-queue/ops.js.map +0 -1
  368. package/dist/workflow/index.d.ts +0 -485
  369. package/dist/workflow/index.js +0 -244
  370. package/dist/workflow/index.js.map +0 -1
  371. /package/dist/{cache → paginate}/index.js.map +0 -0
  372. /package/dist/{chart/inspect → persistence}/index.js.map +0 -0
@@ -1,472 +0,0 @@
1
- import { S as Sub, a as Port, l as Dispose, D as DepKeyedSub, b as SubId } from '../core-Co0LWkIA.js';
2
- import { S as SubscribeHandler } from '../types-XS_miRnB.js';
3
- import { R as Runtime } from '../runtime-types-CNLmhWif.js';
4
- import 'zod';
5
- import 'better-result';
6
-
7
- /**
8
- * The imperative listener target, expressed as the `add`/`remove` pair the
9
- * substrate pairs into a reconciled resource. Both halves receive the SAME
10
- * `listener` reference — the substrate builds it once — so `remove` can never
11
- * be handed a different function than `add` saw.
12
- *
13
- * `add`/`remove` also receive `(sub, ctx)` so the target may be resolved from
14
- * `ctx` (a runtime, a port, a DOM node looked up lazily) or keyed on the Sub
15
- * (an alarm name, a channel name). Resolving the target inside `add` and
16
- * closing over nothing but the listener keeps a target swap from leaking the
17
- * old target's listener — same rationale as `fromEventTarget`'s captured
18
- * target.
19
- *
20
- * `Args` is the tuple the platform invokes the listener with — `[Alarm]` for
21
- * `chrome.alarms.onAlarm`, `[message, sender, sendResponse]` for
22
- * `chrome.runtime.onMessage`, `[changes, areaName]` for
23
- * `chrome.storage.onChanged`. The substrate builds ONE function of this exact
24
- * shape and threads the IDENTICAL reference to both `add` and `remove` — so a
25
- * platform that matches `removeListener` by reference (every chrome surface)
26
- * removes exactly what it added. A consumer that wrapped the listener inside
27
- * `add` would break reference identity (leak #2 above); carrying the native
28
- * `Args` on the listener itself removes the need for any wrapper.
29
- */
30
- interface ListenerTarget<Args extends readonly unknown[], S extends Sub, Ctx> {
31
- add: (listener: (...args: Args) => void, sub: S, ctx: Ctx) => void;
32
- remove: (listener: (...args: Args) => void, sub: S, ctx: Ctx) => void;
33
- }
34
- /**
35
- * Build a listener-backed Sub factory whose cleanup is mandatory and derived.
36
- *
37
- * `Args`, `S`, `Ctx` are fixed when the target is defined — they describe the
38
- * one listener topology this factory owns (the platform arg tuple, which Sub
39
- * shape it filters on, what context resolves it). `M` is supplied at the
40
- * subscribe cell because the same listener feeds different Msgs in different
41
- * machines. Pinning `S` here (rather than at the `msgFn` step) lets
42
- * `add`/`remove` read the concrete Sub's fields — `sub.alarmName`,
43
- * `sub.channel` — with NO cast at the substrate edge: the narrowing happens in
44
- * author-land where the Sub shape is in scope.
45
- *
46
- * The returned function is a `SubscribeHandler` factory in the exact shape of
47
- * every other `@demlik/tea/subs` battery: supply the `msgFn` projection, get a
48
- * `(sub, ctx, dispatch) => cleanup` handler assignable to `machine.subscribe`.
49
- * The cleanup the author NEVER writes is `() => remove(listener, sub, ctx)`,
50
- * with `listener` the identical reference passed to `add`.
51
- */
52
- declare function defineListener<Args extends readonly unknown[], S extends Sub = Sub, Ctx = unknown>(target: ListenerTarget<Args, S, Ctx>): <M>(msgFn: (sub: S, ...args: Args) => M | null) => SubscribeHandler<S, M, Ctx>;
53
-
54
- interface MinimalEvent {
55
- readonly type: string;
56
- }
57
- interface MinimalMessageEvent extends MinimalEvent {
58
- readonly data: unknown;
59
- }
60
- interface MinimalEventTarget {
61
- addEventListener(type: string, listener: (event: MinimalEvent) => void): void;
62
- removeEventListener(type: string, listener: (event: MinimalEvent) => void): void;
63
- }
64
- interface MinimalCloseEvent extends MinimalEvent {
65
- readonly code: number;
66
- readonly reason: string;
67
- }
68
- interface MinimalWebSocket {
69
- close(code?: number, reason?: string): void;
70
- onopen: ((event: MinimalEvent) => void) | null;
71
- onmessage: ((event: MinimalMessageEvent) => void) | null;
72
- onerror: ((event: MinimalEvent) => void) | null;
73
- onclose: ((event: MinimalCloseEvent) => void) | null;
74
- }
75
-
76
- type BroadcastSubData = {
77
- channelName: string;
78
- };
79
- declare function fromBroadcastChannel<S extends Sub & BroadcastSubData, M>(msgFn: (event: MinimalMessageEvent, sub: S) => M | null): SubscribeHandler<S, M, unknown>;
80
-
81
- type EventSourceSubData = {
82
- url: string;
83
- };
84
- interface EventSourceFactoryOpts<S, M> {
85
- onMessage: (data: string, sub: S) => M | null;
86
- onError?: (event: MinimalEvent, sub: S) => M | null;
87
- onOpen?: (sub: S) => M | null;
88
- }
89
- declare function fromEventSource<S extends Sub & EventSourceSubData, M>(opts: EventSourceFactoryOpts<S, M>): SubscribeHandler<S, M, unknown>;
90
-
91
- declare function fromEventTarget<S extends Sub, M>(getTarget: () => MinimalEventTarget, eventName: string, msgFn: (event: MinimalEvent, sub: S) => M | null): SubscribeHandler<S, M, unknown>;
92
-
93
- type IntervalSubData = {
94
- intervalMs: number;
95
- };
96
- declare function fromInterval<S extends Sub & IntervalSubData, M>(msgFn: (sub: S) => M): SubscribeHandler<S, M, unknown>;
97
-
98
- declare function fromPort<S extends Sub, M, Ctx, T, RS = unknown, RM extends {
99
- type: string;
100
- } = {
101
- type: string;
102
- }>(selectRuntime: (ctx: Ctx) => Runtime<RS, RM>, port: Port<T>, msgFn: (value: T, sub: S) => M | null): SubscribeHandler<S, M, Ctx>;
103
-
104
- type WebSocketSubData = {
105
- wsUrl: string;
106
- };
107
- interface WebSocketFactoryOpts<S, M> {
108
- onMessage: (data: unknown, sub: S) => M | null;
109
- onOpen?: (sub: S) => M | null;
110
- onError?: (event: MinimalEvent, sub: S) => M | null;
111
- onClose?: (code: number, reason: string, sub: S) => M | null;
112
- }
113
- declare function fromWebSocket<S extends Sub & WebSocketSubData, M>(opts: WebSocketFactoryOpts<S, M>): SubscribeHandler<S, M, unknown>;
114
-
115
- /** Cancels a scheduled reconnect timer (the inverse of `schedule`). */
116
- type CancelTimer = () => void;
117
- interface ReconnectingWebSocketFactoryOpts<S, M> {
118
- onMessage: (data: unknown, sub: S) => M | null;
119
- onOpen?: (sub: S) => M | null;
120
- onError?: (event: MinimalEvent, sub: S) => M | null;
121
- onClose?: (code: number, reason: string, sub: S) => M | null;
122
- /**
123
- * Fires when a reconnection (any open after the first) succeeds, carrying the
124
- * 1-based reconnect count — the resync hook. Omitting drops reconnect events
125
- * silently.
126
- */
127
- onReconnect?: (attempt: number, sub: S) => M | null;
128
- /** First backoff delay in ms (doubles each failed attempt). Default 250. */
129
- backoffBaseMs?: number;
130
- /** Backoff ceiling in ms. Default 5000. */
131
- backoffMaxMs?: number;
132
- /** Inject the socket constructor (defaults to the global `WebSocket`); the test seam. */
133
- connect?: (url: string) => MinimalWebSocket;
134
- /** Inject the timer (defaults to `setTimeout`/`clearTimeout`); the test seam. */
135
- schedule?: (fn: () => void, ms: number) => CancelTimer;
136
- }
137
- declare function fromReconnectingWebSocket<S extends Sub & WebSocketSubData, M>(opts: ReconnectingWebSocketFactoryOpts<S, M>): SubscribeHandler<S, M, unknown>;
138
-
139
- type TimeoutSubData = {
140
- delayMs: number;
141
- };
142
- declare function fromTimeout<S extends Sub & TimeoutSubData, M>(msgFn: (sub: S) => M): SubscribeHandler<S, M, unknown>;
143
-
144
- /**
145
- * The Sub the battery builds. The consumer's `Sub` union includes
146
- * `ManagedResourceSub<TKey>` directly — the substrate reconciles by `id` and
147
- * `type` like any other Sub.
148
- */
149
- interface ManagedResourceSub<TKey> extends Sub<"managed_resource"> {
150
- /** The lifetime key. Stable while the resource should be held; a change
151
- * retires the old resource (release) and acquires a fresh one. */
152
- readonly key: TKey;
153
- }
154
- /**
155
- * A battery paired with a state-gate. Self-contained: it knows its `name`
156
- * (for the unique-name assert), how to derive its live Sub from a state
157
- * (`subFor`), how to handle its own `subscribe`, and whether it `owns` a given
158
- * Sub id.
159
- *
160
- * Generic in the consumer state `S`, the shared lifetime key `TKey`, and the
161
- * shared `Ctx`. `Handle` is the ONLY thing erased — each battery's handle type
162
- * differs (a checkpoint saver vs. a tool-call bridge) but never crosses this
163
- * interface, so a `combineManagedResources` array holds entries of
164
- * heterogeneous handle types with no cast. The sub type stays
165
- * `ManagedResourceSub<TKey>` end to end, so the substrate's narrowed Sub flows
166
- * straight in.
167
- */
168
- interface GatedManagedResource<S, TKey, Ctx> {
169
- /** The owning battery's `name`. The combinator asserts these are unique. */
170
- readonly name: string;
171
- /**
172
- * Derive this resource's live Sub for a given state: the battery's
173
- * `.sub(key)` when `when(state)` returns a key, or `null` when it returns
174
- * `null` (the resource should be torn down in that state).
175
- */
176
- readonly subFor: (state: S) => ManagedResourceSub<TKey> | null;
177
- /**
178
- * This battery's own `.subscribe`. The combinator routes an incoming
179
- * `managed_resource` Sub to the entry whose `owns(sub)` is true, then calls
180
- * this.
181
- */
182
- readonly subscribe: (sub: ManagedResourceSub<TKey>, ctx: Ctx, dispatch: (msg: never) => void) => Dispose;
183
- /**
184
- * Does this entry own the given Sub? `sub.id === subIdFor(sub.key)` encodes
185
- * the battery `name`, so a match is unambiguous.
186
- */
187
- readonly owns: (sub: ManagedResourceSub<TKey>) => boolean;
188
- }
189
- /**
190
- * What `combineManagedResources` returns: the single managed-resource
191
- * `subscribe` cell for the machine's `subscribe` record, and a `subs(state)`
192
- * builder for `subscriptions(state)`.
193
- */
194
- interface CombinedManagedResources<S, TKey, Ctx> {
195
- /**
196
- * Map every entry through its `when(state)`, drop the `null`s, and build the
197
- * live Subs. Spread into `subscriptions(state)`. The derived list and the
198
- * `subscribe` routing share one source — the entries — so they never drift.
199
- */
200
- readonly subs: (state: S) => ManagedResourceSub<TKey>[];
201
- /**
202
- * The SINGLE `subscribe.managed_resource` handler. Routes an incoming Sub to
203
- * the owning battery by matching `sub.id === battery.subIdFor(sub.key)` (the
204
- * id encodes the battery `name`). Throws loudly on an unrouted id — a wiring
205
- * bug, never a silent no-op resource.
206
- */
207
- readonly subscribe: (sub: ManagedResourceSub<TKey>, ctx: Ctx, dispatch: (msg: never) => void) => Dispose;
208
- }
209
- interface DefineManagedResourceOpts<TKey, Handle, Ctx> {
210
- /**
211
- * A short, stable name. The Sub id is `managed:${name}:${stringify(key)}`,
212
- * so two managed resources in one machine never collide and neither
213
- * collides with a `fromTransport` Sub keyed on the same identity.
214
- */
215
- readonly name: string;
216
- /**
217
- * Build the resource. Runs when the Sub appears in `subscriptions(state)`.
218
- * The returned Handle is the ONLY thing `release` receives — capture
219
- * everything teardown needs into it. If `acquire` throws, the substrate's
220
- * reconcile does NOT register the Sub and `release` is never called (no
221
- * dangling half-built resource).
222
- */
223
- readonly acquire: (key: TKey, ctx: Ctx) => Handle;
224
- /**
225
- * Tear the resource down. Runs when the Sub leaves the desired set (phase
226
- * exited) or when its key changes. MANDATORY — the guaranteed teardown is
227
- * the reason this battery exists.
228
- *
229
- * May be sync or async, and an async one is really awaited: the promise is
230
- * returned to the substrate, which tracks it and drains it inside `stop()`
231
- * (bounded by `run({ disposeTimeoutMs })`). So `await runtime.stop()` means
232
- * the release finished — the reading a host evicting an isolate acts on.
233
- * MID-RUN teardown (a phase exit, a key change) is still fire-and-forget
234
- * (Rule 2): the reconcile pass is synchronous by construction, so it starts
235
- * the release and moves on. A rejection is never a Msg — it reaches the
236
- * runtime's `onError` sink under `phase: "sub-cleanup"`.
237
- */
238
- readonly release: (handle: Handle) => void | Promise<void>;
239
- }
240
- /**
241
- * What the battery returns: a `.sub(key)` builder for `subscriptions`, the
242
- * `.subscribe` handler for the machine's `subscribe` record, a `.get(key)`
243
- * accessor so Cmd handlers can reach the live Handle while the resource is
244
- * held, and a `.subIdFor(key)` for tests.
245
- */
246
- interface ManagedResourceBattery<TKey, Handle, Ctx> {
247
- /**
248
- * Build the Sub for `subscriptions(state)`. The consumer calls this from
249
- * inside their `subscriptions` cell for the phases where the resource
250
- * should be live.
251
- */
252
- readonly sub: (key: TKey) => ManagedResourceSub<TKey>;
253
- /**
254
- * Pair this battery with a state-gate, producing a self-contained entry for
255
- * `combineManagedResources`. `when(state)` returns the resource's KEY when
256
- * it should be live in that state, or `null` when it should be torn down.
257
- *
258
- * Folding "is it active?" and "what key?" into ONE declaration at the
259
- * battery's own definition site is the point: a central `subscriptions(state)`
260
- * list can silently forget to gate a new phase, but a per-resource gate
261
- * travels with the resource. The combinator derives BOTH the active-sub list
262
- * and the subscribe routing from these entries, so the two can never disagree.
263
- *
264
- * Generic in the consumer's state `S` (each `.gated` call binds its own `S`).
265
- * The returned entry erases this battery's `Handle` — `combineManagedResources`
266
- * holds entries of heterogeneous handle types with no cast — while keeping
267
- * `TKey` and `Ctx` so the substrate's narrowed `ManagedResourceSub<TKey>`
268
- * flows straight into the entry's `subscribe`.
269
- */
270
- readonly gated: <S>(when: (state: S) => TKey | null) => GatedManagedResource<S, TKey, Ctx>;
271
- /**
272
- * Dep-keyed entry for the machine's `subs` array. `when(state)` returns the
273
- * resource's KEY when it should be held, or `null` when it should be torn
274
- * down — the exact gate `.gated` takes, now producing a `DepKeyedSub` the
275
- * kernel folds directly instead of an entry the `combineManagedResources`
276
- * router multiplexes.
277
- *
278
- * This is the simplification the dep-keyed kernel unlocks: two managed
279
- * resources used to COLLIDE on the single `subscribe.managed_resource` key
280
- * (both subs share `type: "managed_resource"`), forcing
281
- * `combineManagedResources` to route by SubId. A dep-keyed Sub has its OWN
282
- * reconcile slot (its array position), so there is no shared `type` to route
283
- * — each resource is one `subs` entry, no combinator, no router. `acquire` /
284
- * `release` still ride the kernel's dispose-on-change / dispose-on-null
285
- * reconcile, now via the dep-keyed source's `Dispose` instead of the
286
- * `subscribe` cell's cleanup.
287
- */
288
- readonly depKeyed: <S>(when: (state: S) => TKey | null) => DepKeyedSub<S, never, Ctx>;
289
- /**
290
- * The `subscribe.managed_resource` handler. Drop straight into the
291
- * machine's `subscribe` record. Runs `acquire` on install, holds the
292
- * Handle in the battery's handle table, and returns a cleanup that runs
293
- * `release` (and forgets the Handle) on reconcile-out.
294
- */
295
- readonly subscribe: (sub: ManagedResourceSub<TKey>, ctx: Ctx, dispatch: (msg: never) => void) => Dispose;
296
- /**
297
- * Accessor for the live Handle, keyed on `key`. Returns `undefined` when
298
- * the resource is not currently held (no active sub for that key) — the
299
- * caller decides whether that is an error. A Cmd handler wires its
300
- * `ctx.getX(key)` through this, so the handler reads the SAME owner the
301
- * reconciler holds, never a hand-built duplicate.
302
- */
303
- readonly get: (key: TKey) => Handle | undefined;
304
- /** Pre-derived subId for `(key)` — handy for tests. */
305
- readonly subIdFor: (key: TKey) => SubId;
306
- }
307
- /**
308
- * Build the battery. One call per managed resource at the machine's host
309
- * file.
310
- *
311
- * @example
312
- * const checkpointStore = defineManagedResource<RunId, CheckpointSaver, Ctx>({
313
- * name: "checkpoint",
314
- * acquire: (runId, ctx) =>
315
- * new CheckpointSaver({ storage: ctx.storage, bucket: ctx.bucket, runId }),
316
- * release: (saver) => saver.clear(),
317
- * });
318
- *
319
- * // In the machine:
320
- * subscriptions: (state) =>
321
- * state.type === "running" ? [checkpointStore.sub(state.runId)] : [],
322
- * subscribe: { managed_resource: checkpointStore.subscribe },
323
- *
324
- * // In interpret (read the live handle the reconciler holds):
325
- * start_graph: async (cmd, ctx) => {
326
- * const saver = checkpointStore.get(cmd.runId); // same owner, no rebuild
327
- * ...
328
- * }
329
- */
330
- declare function defineManagedResource<TKey, Handle, Ctx>(opts: DefineManagedResourceOpts<TKey, Handle, Ctx>): ManagedResourceBattery<TKey, Handle, Ctx>;
331
- declare function combineManagedResources<S, TKey, Ctx>(entries: readonly GatedManagedResource<S, TKey, Ctx>[]): CombinedManagedResources<S, TKey, Ctx>;
332
-
333
- /**
334
- * Duplex transport. The host (DO, worker thread, in-process bus) constructs
335
- * one from whatever the platform offers. `fromTransport` does not know what
336
- * a WebSocket is — it knows `send`, `onMessage`, `onClose`.
337
- */
338
- interface Transport {
339
- /** Send a string frame. Best-effort; failures are logged at the boundary. */
340
- send(data: string): void;
341
- /**
342
- * Subscribe to inbound frames. Returns a cleanup that removes the listener.
343
- * The battery wires this in its Sub's subscribe handler; cleanup runs when
344
- * the phase exits (the substrate's reconcileSubs).
345
- */
346
- onMessage(listener: (data: string) => void): () => void;
347
- /**
348
- * Subscribe to a one-shot close. Returns a cleanup that removes the
349
- * listener. The battery dispatches `lostMsg` on close.
350
- */
351
- onClose(listener: () => void): () => void;
352
- /** Close the underlying channel cleanly. Called by the Sub cleanup. */
353
- close(): void;
354
- }
355
- /**
356
- * Factory the consumer wires to a platform-specific transport. The battery
357
- * passes the runtime-derived key (`runId`, or whatever identity is on the
358
- * phase) so per-run transports can be addressed.
359
- */
360
- type TransportFactory<K> = (key: K) => Transport;
361
- /**
362
- * The Sub the battery builds. The consumer's `Sub` union includes
363
- * `TransportSub<TKey>` directly — no wrapping needed, the substrate
364
- * reconciles by `id` and `type` like any other Sub.
365
- */
366
- interface TransportSub<TKey> extends Sub<"transport"> {
367
- /** The phase / run identity. Stable for the lifetime of the seam. */
368
- readonly key: TKey;
369
- }
370
- interface FromTransportOpts<TKey, Inbound, Outbound, M, Ctx> {
371
- /**
372
- * A short, stable name for this seam. The Sub id is derived from
373
- * `${name}:${stringify(key)}` so two seams in the same machine (e.g.
374
- * `hands` + `worker`) never collide.
375
- */
376
- readonly name: string;
377
- /**
378
- * Build the transport. The battery owns the lifetime; the factory is the
379
- * platform-specific constructor (`new WebSocket(...)` adapter on a DO,
380
- * `MessagePort` adapter in a worker, in-memory stub in tests).
381
- */
382
- readonly openTransport: (key: TKey, ctx: Ctx) => Transport;
383
- /**
384
- * Parse one inbound frame. The battery hands `unknown` through (boundary
385
- * parse is the consumer's responsibility per invariant 8). Returning
386
- * `null` drops the frame silently — useful for frames the seam doesn't
387
- * recognize at this layer (e.g. transport-level keepalive).
388
- */
389
- readonly parseInbound: (raw: string, key: TKey) => Inbound | null;
390
- /**
391
- * Map a parsed inbound to a domain Msg. Returning `null` drops the
392
- * dispatch (e.g. a transport-level pong that doesn't change domain state).
393
- */
394
- readonly onInbound: (inbound: Inbound, key: TKey) => M | null;
395
- /**
396
- * The Msg dispatched when the transport closes (peer gone, network
397
- * dropped, normal close). ONE Msg arm, not a Sub, not a heartbeat-derived
398
- * deadline — the transport's own close signal is the truth.
399
- */
400
- readonly lostMsg: (key: TKey) => M;
401
- /**
402
- * Serialize an outbound. Called by the Cmd handler the battery wires.
403
- * Pure data → string at the seam boundary.
404
- */
405
- readonly serializeOutbound: (outbound: Outbound) => string;
406
- }
407
- /**
408
- * What the battery returns: a Sub builder (for `subscriptions`), the Sub's
409
- * `subscribe` handler (for `subscribe.transport`), and a `send(key, outbound)`
410
- * helper the consumer's Cmd handler calls. Plus a `subIdFor` factory the
411
- * consumer can use when keying related Subs (e.g. a deadline) to the same seam
412
- * identity.
413
- */
414
- interface TransportBattery<TKey, Outbound, M, Ctx> {
415
- /**
416
- * Build the Sub for `subscriptions(state)`. The consumer calls this from
417
- * inside their `subscriptions` cell when the seam should be open.
418
- */
419
- readonly sub: (key: TKey) => TransportSub<TKey>;
420
- /**
421
- * The `subscribe.transport` handler. Drop straight into the machine's
422
- * `subscribe` record — the battery wires inbound + close in one shot.
423
- */
424
- readonly subscribe: (sub: TransportSub<TKey>, ctx: Ctx, dispatch: (msg: M) => void) => () => void;
425
- /**
426
- * Outbound send. The Cmd handler calls this; the battery's handle table
427
- * (built when subscribe ran) routes to the live transport. If the seam
428
- * is closed (no active sub), the send is dropped honestly (logged, not
429
- * thrown — the reducer already moved past caring, same shape as Rule 2
430
- * fire-and-forget Cmds).
431
- */
432
- readonly send: (key: TKey, outbound: Outbound) => void;
433
- /** Pre-derived subId for `(key)` — handy for deadline Subs keyed to the same seam. */
434
- readonly subIdFor: (key: TKey) => SubId;
435
- /**
436
- * Pair this seam with a state-gate, producing a dep-keyed Sub for the
437
- * machine's `subs` array. `when(state)` returns the seam's KEY when it
438
- * should be open, or `null` when it should be torn down. The kernel derives
439
- * the id from `structuralHash(key)` and reconciles the seam's lifetime — so
440
- * the author neither lists this Sub in a central `subscriptions(state)` nor
441
- * writes its id. Replaces `subscriptions: (s) => active(s) ? [hands.sub(...)] : []`
442
- * + `subscribe: { transport: hands.subscribe }` with one `subs` entry.
443
- *
444
- * The `source` closes over the battery's own `subscribe` (open inbound +
445
- * close, wire the handle table) using the same `ctx` the kernel passes every
446
- * Sub source.
447
- */
448
- readonly depKeyed: <S>(when: (state: S) => TKey | null) => DepKeyedSub<S, M, Ctx>;
449
- }
450
- /**
451
- * Build the battery. One call per seam at the machine's host file.
452
- *
453
- * @example
454
- * const handsSeam = fromTransport<RunId, HandsInbound, HandsOutbound, Msg, Ctx>({
455
- * name: "hands",
456
- * openTransport: (runId, ctx) => ctx.openHandsWs(runId),
457
- * parseInbound: (raw) => parseHandsInbound(JSON.parse(raw)),
458
- * onInbound: (inbound, runId) => ({ type: "hands_said", runId, inbound }),
459
- * lostMsg: (runId) => ({ type: "hands_lost", runId }),
460
- * serializeOutbound: (out) => JSON.stringify(out),
461
- * });
462
- *
463
- * // In the machine:
464
- * subscriptions: (state) => state.type === "auditing" ? [handsSeam.sub(state.runId)] : [],
465
- * subscribe: { transport: handsSeam.subscribe },
466
- *
467
- * // In interpret:
468
- * send_hands: async (cmd) => { handsSeam.send(cmd.runId, cmd.outbound); },
469
- */
470
- declare function fromTransport<TKey, Inbound, Outbound, M, Ctx>(opts: FromTransportOpts<TKey, Inbound, Outbound, M, Ctx>): TransportBattery<TKey, Outbound, M, Ctx>;
471
-
472
- export { type CancelTimer, type CombinedManagedResources, type DefineManagedResourceOpts, type EventSourceFactoryOpts, type FromTransportOpts, type GatedManagedResource, type ListenerTarget, type ManagedResourceBattery, type ManagedResourceSub, type ReconnectingWebSocketFactoryOpts, SubscribeHandler, type Transport, type TransportBattery, type TransportFactory, type TransportSub, type WebSocketFactoryOpts, type WebSocketSubData, combineManagedResources, defineListener, defineManagedResource, fromBroadcastChannel, fromEventSource, fromEventTarget, fromInterval, fromPort, fromReconnectingWebSocket, fromTimeout, fromTransport, fromWebSocket };
@@ -1,7 +0,0 @@
1
- export { combineManagedResources, defineListener, defineManagedResource, fromBroadcastChannel, fromEventSource, fromEventTarget, fromInterval, fromPort, fromReconnectingWebSocket, fromTransport, fromWebSocket } from '../chunk-VYFAZN3F.js';
2
- export { fromTimeout } from '../chunk-2YFLOCWX.js';
3
- import '../chunk-ZJ5AOYBH.js';
4
- import '../chunk-ZSUUOEPL.js';
5
- import '../chunk-OOYD44JI.js';
6
- //# sourceMappingURL=index.js.map
7
- //# sourceMappingURL=index.js.map
@@ -1 +0,0 @@
1
- {"version":3,"sources":[],"names":[],"mappings":"","file":"index.js"}
@@ -1,134 +0,0 @@
1
- /**
2
- * @demlik/tea/throttle — a timer-based call transformer that caps invocation
3
- * to at most once per `ms` window.
4
- *
5
- * Sibling of `@demlik/tea/debounce` — the two share a SYMMETRIC surface
6
- * (`Throttled<A>` / `Debounced<A>`, both callable + `.cancel()` + `.flush()`,
7
- * both `{ leading?, trailing? }`) so they read as a pair. They are kept in
8
- * separate files with NO cross-import: each is a self-contained timer, and the
9
- * coalesce-vs-drop policies differ enough that sharing code would hide the
10
- * distinction. The contrast IS the lesson:
11
- *
12
- * - **debounce** waits for quiet — fires once AFTER a burst settles.
13
- * - **throttle** enforces a rate — fires AT MOST once per `ms` while the
14
- * burst is ongoing, dropping the calls in between.
15
- *
16
- * Layering with `@demlik/tea/throttled-input`: `throttle` and `debounce` are
17
- * the two host-boundary PRIMITIVES — two distinct algorithms
18
- * (at-most-once-per-window vs collapse-a-burst) behind one signature shape.
19
- * `throttled-input` is NOT a third primitive: it is a TEA machine composed
20
- * OVER them (the same semantics, reimplemented as pure, durable Model state)
21
- * that re-exports both. Wrapping a raw host event → these primitives; durable, replayable
22
- * gating inside a machine → `throttled-input` (see its module doc for the full
23
- * layering map).
24
- *
25
- * WHAT THIS IS NOT — and why it lives outside `update`:
26
- *
27
- * - NOT a reducer / Transitions cell. Reducers are PURE (invariant 2 — same
28
- * inputs → same outputs, no `Date.now`, no timers). A throttle holds a live
29
- * `setTimeout` handle and a window cursor; folding it into `update` would
30
- * smuggle a timer into the pure core.
31
- * - NOT a Sub. A Sub is a continuous SOURCE of Msgs the substrate reconciles
32
- * by id every transition (invariant 4). A throttle is a SINK transformer:
33
- * it wraps a `void`-returning handler (the canonical one is
34
- * `Runtime.dispatch`) so a high-frequency HOST event is rate-limited BEFORE
35
- * it ever becomes a Msg.
36
- *
37
- * It is a higher-order function at the host boundary (pattern 14 — TEA owns
38
- * state, JS owns timing). The host attaches the wrapped function to a
39
- * high-frequency event source (`mousemove`, `scroll`, `pointermove`, a game
40
- * loop) and the substrate downstream only ever sees the rate-limited Msg:
41
- *
42
- * const onMoved = throttle(
43
- * (e: PointerEvent) =>
44
- * runtime.dispatch({ type: "UserMovedCursor", x: e.clientX, y: e.clientY }),
45
- * 16, // ~60fps cap
46
- * );
47
- * window.addEventListener("pointermove", onMoved);
48
- * // cleanup: onMoved.cancel(); window.removeEventListener("pointermove", onMoved);
49
- *
50
- * NOT exported from the package root — reached via the `@demlik/tea/throttle`
51
- * subpath, same one-shape-per-package rule as `rate-limit`, `deadline`, and
52
- * `work-queue`.
53
- *
54
- * Uses the universal `setTimeout` / `clearTimeout` timer idiom (same discipline
55
- * as `subs/from-timeout.ts`): exactly one live handle at a time, the window
56
- * timer clears itself on expiry, `cancel` / `flush` clear and null it so a
57
- * stale callback can never run.
58
- */
59
- /**
60
- * A throttled wrapper around `fn`. Callable with the SAME argument tuple as
61
- * `fn` — `(...args: A) => void` — plus two control methods that share names and
62
- * shapes with `Debounced<A>` so the two modules read as a symmetric pair.
63
- */
64
- interface Throttled<A extends readonly unknown[]> {
65
- /** Invoke `fn` if the window is open, else record args for the trailing fire. */
66
- (...args: A): void;
67
- /**
68
- * Drop any pending trailing fire WITHOUT invoking `fn`, and close the active
69
- * window. Clears the timer, forgets the captured trailing args, and resets
70
- * the cursor so the next call fires immediately on the leading edge (if
71
- * `leading` is enabled). Idempotent.
72
- *
73
- * The host-cleanup partner of `removeEventListener`: cancel the pending fire
74
- * when the component unmounts / the listener detaches, so a queued
75
- * `dispatch` can't land after teardown.
76
- */
77
- cancel(): void;
78
- /**
79
- * Fire any pending trailing call IMMEDIATELY with its latest captured args,
80
- * then close the window. No-op when nothing is pending. Use to force the last
81
- * dropped call out early — e.g. flush the final cursor position when a drag
82
- * ends, so the rest state isn't a stale mid-drag sample.
83
- */
84
- flush(): void;
85
- }
86
- /**
87
- * Wrap `fn` so it runs AT MOST once per `ms` window, no matter how often it is
88
- * called.
89
- *
90
- * Leading + trailing (the default): the first call fires `fn` IMMEDIATELY (the
91
- * leading edge) and opens a `ms` window. Calls during the window are dropped
92
- * from immediate firing but their args are remembered; when the window closes,
93
- * `fn` fires ONCE more with the LATEST dropped args (the trailing edge) and a
94
- * new window opens. A call after the window has already closed leads a fresh
95
- * window immediately. Spacing every call at least `ms` apart therefore fires
96
- * each one on its own leading edge.
97
- *
98
- * @param fn The handler to rate-limit. Typically `(...) => runtime.dispatch(...)`,
99
- * but any `(...args: A) => void` works. The return value is
100
- * ignored — throttle is a fire transformer, not a value pipe.
101
- * @param ms Window length in milliseconds. `fn` fires at most once per `ms`.
102
- * @param opts.leading Fire on the FIRST call of a window (the leading edge),
103
- * immediately. Default `true`.
104
- * @param opts.trailing Fire once at window END with the latest args dropped
105
- * during the window. Default `true`.
106
- *
107
- * Edge combinations (matching lodash's settled semantics, the de-facto
108
- * standard the ecosystem rediscovered):
109
- *
110
- * - `{ leading: true, trailing: true }` (default): immediate fire + a
111
- * trailing fire per window while calls keep arriving. The trailing fire is
112
- * SUPPRESSED when no extra call arrived during the window (a lone call
113
- * already fired on the leading edge — no stale trailing double-fire).
114
- * - `{ leading: true, trailing: false }`: only the immediate fire; everything
115
- * in the window is dropped with no catch-up at the end.
116
- * - `{ leading: false, trailing: true }`: no immediate fire; the FIRST call
117
- * opens a window and `fn` fires at the window's end with the latest args.
118
- * Steady "sample every `ms`" behavior with no instant response.
119
- * - `{ leading: false, trailing: false }`: never fires. Degenerate but legal;
120
- * we don't throw — the caller asked for a no-op transformer.
121
- *
122
- * WHY a default of leading + trailing both `true`: a throttle's job is "respond
123
- * now, then keep responding at a steady rate." Leading gives the instant
124
- * response (the first `mousemove` updates immediately); trailing guarantees the
125
- * FINAL sample of a window isn't lost (the cursor ends where the user actually
126
- * left it, not one window-width behind). Dropping either loses one of those two
127
- * guarantees, so both default on.
128
- */
129
- declare function throttle<A extends readonly unknown[]>(fn: (...args: A) => void, ms: number, opts?: {
130
- leading?: boolean;
131
- trailing?: boolean;
132
- }): Throttled<A>;
133
-
134
- export { type Throttled, throttle };
@@ -1,3 +0,0 @@
1
- export { throttle } from '../chunk-HCEVHFJ7.js';
2
- //# sourceMappingURL=index.js.map
3
- //# sourceMappingURL=index.js.map
@@ -1 +0,0 @@
1
- {"version":3,"sources":[],"names":[],"mappings":"","file":"index.js"}