@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,197 +0,0 @@
1
- /**
2
- * @packageDocumentation
3
- * @demlik/tea/circuit-breaker — per-target failure tracking as pure state + ops.
4
- *
5
- * Same shape as `@demlik/tea/work-queue`'s `ops.ts`, `@demlik/tea/rate-limit`,
6
- * and `@demlik/tea/idempotency`: a state type plus pure transition functions.
7
- * Host-agnostic by construction — no `Date.now()`, no timers, no I/O. The
8
- * caller injects the clock (`nowMs`) and wires the result into its own reducer
9
- * / interpret. This keeps the breaker inside TEA's invariant 2 (transitions are
10
- * pure: same inputs → same outputs, no `Date.now`) so a consumer can fold it
11
- * through `update` and exercise it with `replay` / the pbt fold without a fake
12
- * clock.
13
- *
14
- * Every op returns a NEW state value and never mutates its input (invariant 1 —
15
- * state is a value, not a place). `canPass` returns a `[next, allowed]` tuple so
16
- * the caller branches on the decision while threading the advanced state forward
17
- * — same convention as `rate-limit`'s `tryConsume` / `record`. `onSuccess` /
18
- * `onFailure` are the outcome-recording transitions the caller folds in once the
19
- * guarded call resolves.
20
- *
21
- * ## The phase machine
22
- *
23
- * A circuit breaker guards a fallible downstream target (an HTTP backend, a DB,
24
- * a flaky tool call). Instead of hammering a target that is already failing, it
25
- * trips OPEN after enough failures and fast-fails subsequent calls for a
26
- * cooldown, then probes with a few trial calls before fully closing again.
27
- * Three phases, each carrying ONLY its own data so impossible states are
28
- * unrepresentable (pattern 11):
29
- *
30
- * - **closed** — the healthy steady state. Calls pass through. Carries
31
- * `failures`: the count of *consecutive* failures since the last success.
32
- * A success resets it to 0; the `failureThreshold`-th failure trips the
33
- * breaker OPEN. Only `closed` has a failure counter — `open` and
34
- * `half_open` don't, because in those phases the count is irrelevant
35
- * (the breaker has already tripped / is already probing).
36
- *
37
- * - **open** — the tripped state. All calls fast-fail (no downstream load).
38
- * Carries `openedAtMs`: the clock reading at which the breaker tripped.
39
- * `canPass` compares `nowMs - openedAtMs` against `cooldownMs` to decide
40
- * when to start probing. Only `open` carries a timestamp — neither other
41
- * phase is timing anything.
42
- *
43
- * - **half_open** — the probing state. A limited number of trial calls are
44
- * allowed through to test whether the target has recovered. Carries
45
- * `probes`: the count of probes admitted so far this probing round.
46
- * `canPass` admits while `probes < halfOpenMaxProbes`, then fast-fails the
47
- * rest (so a slow target can't be flooded by every queued caller at once).
48
- * A probe success closes the breaker; a probe failure re-opens it (and
49
- * resets the cooldown clock). Only `half_open` counts in-flight probes.
50
- *
51
- * ### Transition table
52
- *
53
- * Rows are the current phase; columns are the event. `→` denotes the next
54
- * phase; `self` means unchanged. `nowMs` is the injected clock.
55
- *
56
- * | from \ event | onSuccess | onFailure | canPass (→ allowed?) |
57
- * | ------------ | -------------- | -------------------------------------- | ------------------------------------------------------------------------------------ |
58
- * | closed | closed(0) | failures+1; trip → open(nowMs) at thr. | self → true (always) |
59
- * | open | self *(¹)* | self | elapsed ≥ cooldown → half_open(1), true; else self → false |
60
- * | half_open | → closed(0) | → open(nowMs) (probe failed) | probes < max → half_open(probes+1), true; else self → false |
61
- *
62
- * *(¹)* `onSuccess` on `open` "shouldn't happen": no call was admitted while
63
- * open, so no success can be reported for one. We leave the state unchanged
64
- * rather than throw — the breaker is a coordination aid, not a correctness
65
- * gate, and a spurious success report (e.g. a late-arriving result from before
66
- * the trip) must not silently un-trip the breaker. `onFailure` on `open` is
67
- * likewise a no-op: the breaker is already tripped; the `open` clock is anchored
68
- * at the trip, not bumped by late failures.
69
- *
70
- * ### The probe-admission asymmetry
71
- *
72
- * Entering `half_open` happens inside `canPass`, not `onSuccess` / `onFailure`,
73
- * because the cooldown is a *time* condition and only `canPass` reads the clock
74
- * against `openedAtMs`. The first `canPass` after the cooldown elapses both
75
- * transitions the phase AND admits the probe (`[half_open(1), true]`) — one
76
- * caller drives the recovery attempt. Subsequent `canPass` calls in the same
77
- * round admit up to `halfOpenMaxProbes` total, then fast-fail until a probe
78
- * resolves and `onSuccess` / `onFailure` moves the phase out of `half_open`.
79
- *
80
- * This module is a textbook three-state machine — a clean `/machine-viz` demo.
81
- *
82
- * NOT exported from the package root — reached via the
83
- * `@demlik/tea/circuit-breaker` subpath, same one-shape-per-package rule as
84
- * `work-queue`, `rate-limit`, and `idempotency`.
85
- */
86
- /**
87
- * Circuit-breaker policy — pure configuration, no mutable state. One policy is
88
- * shared across all the calls guarded by one logical breaker (often a
89
- * module-scope const). `CircuitState` carries the mutable counts; this carries
90
- * the thresholds those counts are compared against.
91
- */
92
- interface CircuitPolicy {
93
- /**
94
- * Consecutive failures in `closed` that trip the breaker `open`. The
95
- * `failureThreshold`-th failure is the one that trips — with a threshold of
96
- * 5, the breaker survives 4 failures and opens on the 5th.
97
- */
98
- readonly failureThreshold: number;
99
- /**
100
- * How long the breaker stays `open` before `canPass` starts admitting
101
- * probes, in milliseconds. Measured from `openedAtMs`; the cutoff is
102
- * half-open (`elapsed >= cooldownMs` admits), matching `rate-limit` /
103
- * `idempotency` window edges — a breaker opened at `t` first probes at
104
- * `t + cooldownMs`.
105
- */
106
- readonly cooldownMs: number;
107
- /**
108
- * How many probe calls `half_open` admits before fast-failing the rest of
109
- * the round. Caps the load on a recovering target — a single slow probe
110
- * can't be joined by every queued caller. The round ends when a probe
111
- * resolves: success closes the breaker, failure re-opens it.
112
- */
113
- readonly halfOpenMaxProbes: number;
114
- }
115
- /**
116
- * Sensible defaults: trip after 5 consecutive failures, cool down for 30s,
117
- * admit a single probe before deciding. Tuned for guarding a network backend;
118
- * override per call site rather than mutating this shared const.
119
- */
120
- declare const defaultCircuitPolicy: CircuitPolicy;
121
- /**
122
- * The breaker's phase. A discriminated union on `phase` so each phase carries
123
- * ONLY its own data and impossible combinations are unrepresentable (pattern
124
- * 11): there is no state with both a failure count AND an open timestamp,
125
- * because such a state is meaningless. `phase` is the discriminant; every field
126
- * is `readonly` so the whole value is trivially JSON-serializable into a
127
- * consumer's `Store<S>` and safe to thread through a pure reducer.
128
- *
129
- * - `closed` carries `failures` — consecutive failures since last success.
130
- * - `open` carries `openedAtMs` — clock reading when it tripped.
131
- * - `half_open` carries `probes` — probes admitted this round.
132
- */
133
- type CircuitState = {
134
- readonly phase: "closed";
135
- readonly failures: number;
136
- } | {
137
- readonly phase: "open";
138
- readonly openedAtMs: number;
139
- } | {
140
- readonly phase: "half_open";
141
- readonly probes: number;
142
- };
143
- /** The starting state: closed with zero recorded failures. */
144
- declare function initCircuit(): CircuitState;
145
- /**
146
- * Record a successful guarded call. PURE — returns a new state; the input is
147
- * never mutated.
148
- *
149
- * - `closed` → reset `failures` to 0 (a success breaks the consecutive run).
150
- * - `half_open` → the probe succeeded; the target has recovered → `closed`.
151
- * - `open` → unchanged. A success "shouldn't happen" while open (no call
152
- * was admitted to produce one); a late/spurious success must
153
- * not silently un-trip the breaker. See module header note ¹.
154
- */
155
- declare function onSuccess(state: CircuitState, _policy: CircuitPolicy): CircuitState;
156
- /**
157
- * Record a failed guarded call. PURE — returns a new state; the input is never
158
- * mutated. `nowMs` is the injected clock, stamped onto the `open` phase when the
159
- * breaker trips so `canPass` can measure the cooldown later.
160
- *
161
- * - `closed` → `failures + 1`; if that reaches `failureThreshold`, trip to
162
- * `open(nowMs)`. The threshold-th failure is the one that trips.
163
- * - `half_open` → the probe failed; the target is still unhealthy →
164
- * `open(nowMs)`, restarting the cooldown clock so a fresh
165
- * cooldown elapses before the next probe round.
166
- * - `open` → unchanged. The breaker is already tripped; the `open` clock
167
- * is anchored at the original trip, not bumped by late
168
- * failures. See module header note ¹.
169
- */
170
- declare function onFailure(state: CircuitState, policy: CircuitPolicy, nowMs: number): CircuitState;
171
- /**
172
- * Decide whether a call may pass, advancing the phase as a side effect of the
173
- * decision. PURE — returns `[next, allowed]`; the input is never mutated.
174
- * Branch on the boolean, thread the state forward regardless:
175
- *
176
- * const [c1, allowed] = canPass(state.circuit, policy, nowMs);
177
- * if (!allowed) return [{ ...state, circuit: c1 }, [fastFailCmd]];
178
- * return [{ ...state, circuit: c1 }, [doGuardedCallCmd]];
179
- *
180
- * - `closed` → `[state, true]` — always passes; failures are recorded by
181
- * `onFailure` once the call resolves, not gated here.
182
- * - `open` → if `nowMs - openedAtMs >= cooldownMs` the cooldown has
183
- * elapsed → enter `half_open` and admit this caller as the
184
- * first probe: `[half_open(1), true]`. Otherwise still cooling
185
- * down → `[state, false]` (fast-fail, no downstream load).
186
- * - `half_open` → admit while `probes < halfOpenMaxProbes`, incrementing the
187
- * count: `[half_open(probes+1), true]`. Once the cap is hit →
188
- * `[state, false]` until a probe resolves and `onSuccess` /
189
- * `onFailure` moves the phase out of `half_open`.
190
- *
191
- * Entering `half_open` lives here (not in `onSuccess` / `onFailure`) because the
192
- * cooldown is a time condition and only `canPass` reads `nowMs` against
193
- * `openedAtMs`. See the module header's probe-admission note.
194
- */
195
- declare function canPass(state: CircuitState, policy: CircuitPolicy, nowMs: number): readonly [CircuitState, boolean];
196
-
197
- export { type CircuitPolicy, type CircuitState, canPass, defaultCircuitPolicy, initCircuit, onFailure, onSuccess };
@@ -1,3 +0,0 @@
1
- export { canPass, defaultCircuitPolicy, initCircuit, onFailure, onSuccess } from '../chunk-UF4MZSLT.js';
2
- //# sourceMappingURL=index.js.map
3
- //# sourceMappingURL=index.js.map
@@ -1 +0,0 @@
1
- {"version":3,"sources":[],"names":[],"mappings":"","file":"index.js"}
@@ -1,326 +0,0 @@
1
- type SyncReturn<S, C extends Cmd> = readonly [S, readonly C[]] & {
2
- readonly then?: never;
3
- };
4
- type UpdateForm = "reducer" | "transitions";
5
- declare function detectUpdateForm(update: object): UpdateForm;
6
- declare function formOf(machine: {
7
- update: object;
8
- __form?: UpdateForm;
9
- }): UpdateForm;
10
- declare class NoCellError extends Error {
11
- readonly msgType: string;
12
- readonly stateName: string;
13
- readonly name = "NoCellError";
14
- readonly _tag: "NoCellError";
15
- constructor(msgType: string, stateName: string);
16
- }
17
- declare function applyCell<S, M extends {
18
- type: string;
19
- }, C extends Cmd>(machine: {
20
- update: object;
21
- __form?: UpdateForm;
22
- }, state: S, msg: M): readonly [S, readonly C[]];
23
- declare function applyCellChecked<S, M extends {
24
- type: string;
25
- }, C extends Cmd>(machine: {
26
- update: object;
27
- __form?: UpdateForm;
28
- }, state: S, msg: M): readonly [S, readonly C[]];
29
- declare function msgKeysOf(machine: {
30
- update: object;
31
- __form?: UpdateForm;
32
- }): readonly string[];
33
- type MachineShape = {
34
- readonly form: "reducer";
35
- /** Every `Msg.type` the flat reducer has a cell for. */
36
- readonly msgs: readonly string[];
37
- } | {
38
- readonly form: "transitions";
39
- /** The union of every row's `Msg.type` keys (see `msgKeysOf`). */
40
- readonly msgs: readonly string[];
41
- /** Every `state.type` the table has a row for, in table order. */
42
- readonly states: readonly string[];
43
- /** `state.type` → the `Msg.type`s that state has a cell for. */
44
- readonly accepts: Readonly<Record<string, readonly string[]>>;
45
- };
46
- declare function describeMachine(machine: {
47
- update: object;
48
- __form?: UpdateForm;
49
- }): MachineShape;
50
- declare function acceptsOf(machine: {
51
- update: object;
52
- __form?: UpdateForm;
53
- }, stateType: string): readonly string[];
54
- type Reducer<S, M extends {
55
- type: string;
56
- }, C extends Cmd> = {
57
- [K in M["type"]]: (state: S, msg: Extract<M, {
58
- type: K;
59
- }>) => SyncReturn<S, C>;
60
- };
61
- type Transitions<S extends {
62
- type: string;
63
- }, M extends {
64
- type: string;
65
- }, C extends Cmd> = {
66
- [P in S["type"]]: {
67
- [K in M["type"]]: (state: Extract<S, {
68
- type: P;
69
- }>, msg: Extract<M, {
70
- type: K;
71
- }>) => SyncReturn<S, C>;
72
- };
73
- };
74
- type Cmd<T extends string = string> = {
75
- readonly type: T;
76
- };
77
- declare const Cmd: {
78
- /**
79
- * The empty Cmd array. Typed `readonly never[]` so it's assignable to any
80
- * `readonly C[]` for any `C extends Cmd`. Use in `init` returns and
81
- * Transitions cells that emit zero effects:
82
- *
83
- * init: (loaded) => [loaded ?? initial, Cmd.none],
84
- * tick: (state) => [state, Cmd.none],
85
- *
86
- * Elm's `Cmd.none` analogue. Cultural signal alongside the runtime help:
87
- * `[state, Cmd.none]` reads as intent ("this transition emits nothing"),
88
- * `[state, []]` reads as "empty array of what".
89
- *
90
- * Frozen at runtime so a downstream consumer can't `.push()` into the
91
- * shared reference.
92
- */
93
- readonly none: readonly never[];
94
- /**
95
- * Flat concat of cmd arrays. Use when a cell composes effects from
96
- * multiple conditional sources:
97
- *
98
- * return [next, Cmd.batch(
99
- * Cmd.whenDefined(state.queueItemId, (id) => ({ type: "complete", id })),
100
- * Cmd.when(state.windowId !== undefined, { type: "close_window", windowId }),
101
- * [{ type: "detach_debugger", tabId: state.tabId }],
102
- * )];
103
- *
104
- * `<const C>` keeps inline cmd literals' discriminants narrow (same
105
- * rationale as `when` / `whenDefined` above).
106
- */
107
- readonly batch: <const C extends Cmd>(...arrs: readonly (readonly C[])[]) => readonly C[];
108
- /**
109
- * Emit `cmd` wrapped in a single-element array iff `cond` is true.
110
- * Otherwise return the empty array. Spreads cleanly into the cmds array
111
- * returned by a Transitions cell.
112
- *
113
- * `const C` (TypeScript 5.0+) keeps the inferred `type:` discriminator
114
- * literal narrow when called with an object literal — so `Cmd.when(b,
115
- * { type: "x", ... })` infers as `{ type: "x", ... }`, not `{ type:
116
- * string, ... }`, and stays assignable to a discriminated-union arm
117
- * without `as const` at the call site.
118
- */
119
- readonly when: <const C extends Cmd>(cond: boolean, cmd: C) => readonly C[];
120
- /**
121
- * If `value` is defined, call `build(value)` and emit the resulting cmd
122
- * wrapped in a single-element array. If `value` is `undefined`, return
123
- * the empty array. `value` is narrowed to `T` inside `build`.
124
- *
125
- * `const C` on the return type keeps the callback's object-literal
126
- * `type:` field narrow (see `when` above for the full rationale).
127
- */
128
- readonly whenDefined: <T, const C extends Cmd>(value: T | undefined, build: (value: T) => C) => readonly C[];
129
- };
130
- type SubId = string & {
131
- readonly __brand: "SubId";
132
- };
133
- /**
134
- * Construct a `SubId` from a string. Use this everywhere a Sub literal is
135
- * built — including ids derived from runtime data (`subId(\`ws:${auditId}\`)`).
136
- * The brand is structural, not nominal, so dynamic ids are permitted; the
137
- * constructor's job is to make the identity decision explicit at every call
138
- * site so the type system can catch accidental raw-string drift.
139
- *
140
- * Strengthens invariant 7 (identity is explicit).
141
- */
142
- declare function subId(s: string): SubId;
143
- type Sub<T extends string = string> = {
144
- readonly id: SubId;
145
- readonly type: T;
146
- };
147
- type Dispose = () => void | Promise<void>;
148
- declare function structuralHash(deps: unknown): string;
149
- interface DepKeyedSub<S, M, Ctx = unknown> {
150
- /**
151
- * The slice of state this Sub depends on. `null` OR `undefined` ⇒ the Sub is
152
- * inactive in this state (the substrate disposes it if it was running) — see
153
- * `depsInactive`, so `(s) => s.optionalRunId` gates correctly. Otherwise the
154
- * Sub is active, keyed on `structuralHash(deps)`.
155
- *
156
- * Pure (invariant 2). Plain JSON-compatible data only (invariant 1) — the
157
- * structural hash walks it deterministically and THROWS on a `Date`, `Map`,
158
- * `Set`, `Error` or class instance rather than collapsing them all onto one
159
- * id. Project such a value first (`startedAt.toISOString()`).
160
- */
161
- readonly deps: (state: S) => unknown;
162
- /**
163
- * Open the resource for the current `state` (whose `deps` the kernel just
164
- * found non-null). Receives `dispatch` to fire follow-up Msgs (a timer's
165
- * fire, an inbound frame) and the machine's `ctx` (the host's transport
166
- * factory, storage handles). Returns the `Dispose` the substrate runs on
167
- * teardown / re-arm. Same role as a `subscribe[type]` handler's returned
168
- * cleanup.
169
- *
170
- * `source` takes `state` (not the deps slice) so the slice type `D` never
171
- * escapes the entry — each battery's `.depKeyed` closes over its own typed
172
- * deps internally (cast-free existential: the entry that produced the deps
173
- * is the entry that consumes them).
174
- */
175
- readonly source: (state: S, dispatch: (msg: M) => void, ctx: Ctx) => Dispose;
176
- }
177
- interface Identity<S, M> {
178
- /** The identity THIS instance owns. Pure (invariant 2); plain value. */
179
- readonly ofState: (state: S) => unknown;
180
- /**
181
- * The identity a message is addressed to, or `undefined` when the message
182
- * carries no identity (lifecycle / pre-identity messages — never dropped).
183
- * Pure (invariant 2); plain value when defined.
184
- */
185
- readonly ofMsg: (msg: M) => unknown;
186
- }
187
- interface Port<T> {
188
- readonly __brand: "port";
189
- readonly name: string;
190
- readonly __t?: T;
191
- }
192
- /**
193
- * Augmentation injected onto `ctx` inside Cmd handlers. Handlers receive
194
- * `ctx & PortEmitter` so they can call `ctx.emit(port, value)` synchronously.
195
- * Subscribers registered via `runtime.subscribePort(port, listener)` receive
196
- * the value immediately.
197
- *
198
- * Emitting to a port with no subscribers is a no-op (does not throw).
199
- */
200
- interface PortEmitter {
201
- emit<T>(port: Port<T>, value: T): void;
202
- }
203
- type NoCtx = Readonly<Record<never, never>>;
204
- /**
205
- * Spelled-out alias for `NoCtx`.
206
- *
207
- * @deprecated Use {@link NoCtx}. One Way to Do Each Thing — `NoCtx` is the
208
- * single non-deprecated name for the context-free-ctx marker (this alias has
209
- * no in-tree uses). Kept as a re-export for one minor per the deprecate-don't-
210
- * delete policy in `MAINTAINING.md`, then removed.
211
- */
212
- type ContextFree = NoCtx;
213
- type Interpret<M extends {
214
- type: string;
215
- }, C extends Cmd, Ctx> = {
216
- [K in C["type"]]: (cmd: Extract<C, {
217
- type: K;
218
- }>, ctx: Ctx & PortEmitter, dispatch?: (msg: M) => void) => Promise<M | void>;
219
- };
220
- type InterpretDetached<C extends Cmd, Allowed extends {
221
- type: string;
222
- }, Ctx> = (cmd: C, ctx: Ctx & PortEmitter, dispatch: (msg: Allowed) => void) => Promise<void>;
223
- type Subscribe<M extends {
224
- type: string;
225
- }, U extends Sub, Ctx> = {
226
- [K in U["type"]]: (sub: Extract<U, {
227
- type: K;
228
- }>, ctx: Ctx, dispatch: (msg: M) => void) => Dispose;
229
- };
230
- type Machine<S, M extends {
231
- type: string;
232
- }, C extends Cmd, U extends Sub, Ctx> = {
233
- /**
234
- * Boot the runtime. Called once by `run(...)` with whatever `Store.load()`
235
- * returned: `null` on fresh boot, the persisted state on rehydrate.
236
- *
237
- * **Contract:** when `loaded !== null`, init MUST return `[loaded, []]` —
238
- * no Cmds. Init's rehydrate branch is the migration / parse boundary, not
239
- * the boot-effect hook. See Invariant 2 in `.patterns/tea/tea-invariants.md`.
240
- *
241
- * Boot effects routes:
242
- * - Stateless infrastructure → host module top, outside TEA.
243
- * - State-conditional resume → a `boot` Msg the host dispatches once
244
- * after `run(...)` returns.
245
- *
246
- * Violations are caught at runtime by `replay` (which throws with a
247
- * pointer to the alternatives).
248
- */
249
- init: (loaded: S | null, ctx: Ctx) => readonly [S, readonly C[]];
250
- update: Reducer<S, M, C> | ([S] extends [{
251
- type: string;
252
- }] ? Transitions<S, M, C> : never);
253
- /**
254
- * Dep-keyed Subs. Each declares the state slice it depends on; the substrate
255
- * derives the id (`structuralHash(deps)`) and the gate (`deps` non-null) and
256
- * folds them into the SAME reconcile loop `subscriptions` feeds. The author
257
- * never writes `subId(...)` and never lists Subs in a central
258
- * `subscriptions(state)` aggregate — a per-Sub gate travels with the Sub, so
259
- * a new phase can't silently forget to arm it.
260
- *
261
- * The deps slice type is erased to `unknown` per entry — each Sub's slice
262
- * differs, but the slice type never crosses this field (the kernel only needs
263
- * to hash it and pass `state` back to that same entry's `source`).
264
- *
265
- * Optional and independent of `subscriptions` / `subscribe`: a machine that
266
- * omits `subs` reconciles exactly as before.
267
- *
268
- * Strengthens invariant 4 (lifecycle owned by the substrate) and invariant 7
269
- * (identity derived, not hand-authored).
270
- */
271
- subs?: ReadonlyArray<DepKeyedSub<S, M, Ctx>>;
272
- /**
273
- * Instance-identity filter. Declares THIS instance's identity once; the
274
- * substrate drops any message addressed to a DIFFERENT identity before it
275
- * reaches `update`. Replaces the per-cell `if (msg.runId !== state.runId)`
276
- * guard entirely — the reducer never sees a foreign-instance message, so no
277
- * cell needs to check.
278
- *
279
- * Opt-in: a machine that omits `identity` skips the filter (every message
280
- * reaches `update`, exactly as before). A message whose `ofMsg` returns
281
- * `undefined` is identity-agnostic and always reaches `update` (lifecycle /
282
- * pre-identity messages).
283
- *
284
- * Strengthens invariant 7 (identity is explicit — declared once, enforced by
285
- * the substrate) and invariant 6 (mis-addressed messages dropped at one
286
- * observable point, not per cell).
287
- */
288
- identity?: Identity<S, M>;
289
- /**
290
- * Manual Sub aggregate — the documented escape hatch, KEPT alongside `subs`.
291
- * The machine that needs cross-Sub logic the per-Sub `deps` fold can't
292
- * express lists Subs here; the substrate reconciles them via `subscribe`.
293
- * Both paths feed ONE reconcile pass.
294
- */
295
- subscriptions?: (state: S) => readonly U[];
296
- subscribe?: Subscribe<M, U, Ctx>;
297
- /**
298
- * The update form ("reducer" | "transitions"), stamped non-enumerably by
299
- * `defineMachine` at construction (see `UpdateForm` / `formOf`). Optional in
300
- * the type so the structural `Machine` annotation form keeps accepting plain
301
- * object literals; readers go through `formOf`, which falls back to
302
- * `detectUpdateForm` when the tag is absent. Never written by hand.
303
- */
304
- readonly __form?: UpdateForm;
305
- } & ([C] extends [Cmd<never>] ? {
306
- interpret?: Interpret<M, C, Ctx>;
307
- } : {
308
- interpret: Interpret<M, C, Ctx>;
309
- }) & ([U] extends [Sub<never>] ? unknown : {
310
- subscriptions: (state: S) => readonly U[];
311
- subscribe: Subscribe<M, U, Ctx>;
312
- });
313
- declare function foldUpdates<S, M extends {
314
- type: string;
315
- }, C extends Cmd>(machine: {
316
- update: object;
317
- __form?: UpdateForm;
318
- }, initialState: S, msgs: readonly M[]): {
319
- state: S;
320
- cmds: C[];
321
- };
322
- declare function foldMsgs<S, M extends {
323
- type: string;
324
- }, C extends Cmd, U extends Sub, Ctx>(machine: Machine<S, M, C, U, Ctx>, base: S, msgs: readonly M[]): S;
325
-
326
- export { Cmd as C, type DepKeyedSub as D, type Interpret as I, type Machine as M, NoCellError as N, type PortEmitter as P, type Reducer as R, type Sub as S, type Transitions as T, type UpdateForm as U, type Port as a, type SubId as b, type InterpretDetached as c, type ContextFree as d, type Dispose as e, type Identity as f, type MachineShape as g, type NoCtx as h, type Subscribe as i, type SyncReturn as j, acceptsOf as k, applyCell as l, applyCellChecked as m, describeMachine as n, detectUpdateForm as o, foldMsgs as p, foldUpdates as q, formOf as r, msgKeysOf as s, structuralHash as t, subId as u };
@@ -1,6 +0,0 @@
1
- export { deadlineExceeded, deadlineSub, setTimeoutArmTimer, subscribeDeadline, subscribeWith } from '../chunk-JGVL3WPL.js';
2
- import '../chunk-2YFLOCWX.js';
3
- import '../chunk-5EHLEUTL.js';
4
- import '../chunk-B5VXOFMZ.js';
5
- //# sourceMappingURL=index.js.map
6
- //# sourceMappingURL=index.js.map
@@ -1 +0,0 @@
1
- {"version":3,"sources":[],"names":[],"mappings":"","file":"index.js"}
@@ -1,3 +0,0 @@
1
- export { debounce } from '../chunk-J6527VRQ.js';
2
- //# sourceMappingURL=index.js.map
3
- //# sourceMappingURL=index.js.map
@@ -1 +0,0 @@
1
- {"version":3,"sources":[],"names":[],"mappings":"","file":"index.js"}
@@ -1,121 +0,0 @@
1
- import { ReactNode } from 'react';
2
-
3
- /**
4
- * React adapters for the background TEA runtime.
5
- *
6
- * Two layers, both built on the same `bridgeClient`:
7
- *
8
- * 1. `useBackgroundRuntime(opts)` — direct hook. One bridge client per
9
- * call. Surfaces that only have a single consumer mount it inline.
10
- *
11
- * 2. `createBackgroundRuntimeContext<S, M>()` → `{ Provider, useDispatch,
12
- * useState, useRuntime }` — factory-style React context. Mounts the
13
- * bridge client ONCE inside the Provider; child hooks read `state` /
14
- * `dispatch` from context. Surfaces that drill `dispatch` through
15
- * multiple component layers, or mount `useBackgroundRuntime` more
16
- * than once for the same channel, should use this instead.
17
- *
18
- * Why a factory (not a single global context):
19
- * - Type safety: each app types it against its own `S` / `M`.
20
- * - Tests can mount fresh contexts per test (no module-level state to
21
- * reset).
22
- * - Multiple-runtimes case: an app COULD theoretically have two
23
- * background-shaped runtimes (e.g. one per channel); the factory
24
- * pattern doesn't preclude it.
25
- *
26
- * Hook lifecycle (`useBackgroundRuntime`) — preserved from the prior
27
- * single-export module:
28
- * 1. `useSyncExternalStore` subscribes to broadcasts via
29
- * `bridgeClient.subscribe`, reading the latest state via
30
- * `bridgeClient.getSnapshot`. Reference stability is owned by the
31
- * bridge — `getSnapshot` returns the SAME `S` until a new broadcast
32
- * overwrites it, so React doesn't loop.
33
- * 2. A one-shot `hydrate()` call seeds `latestState` before the first
34
- * broadcast arrives. The hydrate side-effect runs in an effect so the
35
- * first render shows `null` and the subsequent render flips to the
36
- * hydrated snapshot (or stays null if the host is still booting).
37
- * 3. `dispatch(msg)` sends `:dispatch` envelopes.
38
- *
39
- * On unmount: `useSyncExternalStore` removes the listener; the host's
40
- * bridge stays installed.
41
- *
42
- * Canon §3.1: React adapters use `useSyncExternalStore`, not
43
- * `useState + useEffect`. `useMachine` and `useRuntime` already follow this
44
- * — `useBackgroundRuntime` (and by extension the Provider) does too. One
45
- * Way to Do Each Thing.
46
- *
47
- * NOTE: This is a separate entry from the main `index.ts` so apps that
48
- * never need React don't drag react into their type graph. The React
49
- * adapter peer-depends on react (you must have it installed in the app).
50
- */
51
-
52
- interface UseBackgroundRuntimeOpts<S> {
53
- channel: string;
54
- /**
55
- * REQUIRED parse for inbound `state` payloads. Forwarded to
56
- * `bridgeClient` — see `BridgeClientOpts.parseState`. Surfaces own this
57
- * because the chrome.runtime boundary is `unknown` (Inv 8). Returning
58
- * `null` drops the payload silently.
59
- */
60
- parseState: (raw: unknown) => S | null;
61
- }
62
- interface UseBackgroundRuntimeResult<S, M> {
63
- /** Latest snapshot from the host. `null` until the first hydrate response
64
- * or the first broadcast arrives. Surfaces SHOULD render a placeholder
65
- * for the null window. */
66
- state: S | null;
67
- /** Send a msg to the host runtime. Resolves once the host's dispatch
68
- * settles. */
69
- dispatch(msg: M): Promise<void>;
70
- }
71
- declare function useBackgroundRuntime<S, M extends {
72
- type: string;
73
- }>({ channel, parseState, }: UseBackgroundRuntimeOpts<S>): UseBackgroundRuntimeResult<S, M>;
74
- interface BackgroundRuntimeContext<S, M> {
75
- /**
76
- * Wrap a subtree to share a single background-runtime bridge client.
77
- * `opts` is forwarded verbatim to `useBackgroundRuntime` — same channel,
78
- * same parse contract.
79
- */
80
- Provider: (props: {
81
- opts: UseBackgroundRuntimeOpts<S>;
82
- children: ReactNode;
83
- }) => ReactNode;
84
- /**
85
- * Returns the dispatch function bound to this Provider's bridge client.
86
- * Reference is stable across renders (per `useBackgroundRuntime`'s
87
- * `useCallback`), so passing it to memoized children won't churn them.
88
- */
89
- useDispatch: () => (msg: M) => Promise<void>;
90
- /**
91
- * Returns a slice of the latest state. `selector` defaults to identity
92
- * (returns the whole `S | null` snapshot). Selectors run on every state
93
- * change — surfaces with expensive transforms should memoize the
94
- * selector at call site.
95
- *
96
- * Returns `null` until the first hydrate / broadcast lands when the
97
- * selector is identity; for non-identity selectors the return type is
98
- * `T` and the caller's selector decides how to handle the pre-hydrate
99
- * `null` snapshot.
100
- */
101
- useState: {
102
- (): S | null;
103
- <T>(selector: (state: S | null) => T): T;
104
- };
105
- /**
106
- * Escape hatch — returns the full `{ state, dispatch }` pair as-is.
107
- * Useful for consumers that want both the snapshot and the dispatch
108
- * fn in a single hook call (e.g. effects that read state THEN
109
- * dispatch in response).
110
- *
111
- * Not a `@demlik/tea` `Runtime<S, M>` — the bridge surface is a thinner
112
- * client. This hook returns the same shape as `useBackgroundRuntime`,
113
- * just sourced from context instead of mounting a fresh client.
114
- */
115
- useRuntime: () => UseBackgroundRuntimeResult<S, M>;
116
- }
117
- declare function createBackgroundRuntimeContext<S, M extends {
118
- type: string;
119
- }>(): BackgroundRuntimeContext<S, M>;
120
-
121
- export { type BackgroundRuntimeContext, type UseBackgroundRuntimeOpts, type UseBackgroundRuntimeResult, createBackgroundRuntimeContext, useBackgroundRuntime };