@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,923 +0,0 @@
1
- import { C as Cmd } from './core-Bjc0bS8j.js';
2
-
3
- /**
4
- * A type smuggled through a value position. `ty<{ at: number }>()` is an empty
5
- * object at runtime whose TYPE remembers `{ at: number }` — which is what lets
6
- * an event declare its payload IN the chart instead of in a parallel type map
7
- * the author has to keep in step.
8
- */
9
- interface Ty<T> {
10
- readonly __ty: T;
11
- }
12
- declare const ty: <T>() => Ty<T>;
13
- /** `Ty<T>` → `T`; anything else (an absent `data`) → the neutral `unknown`. */
14
- type Payload<X> = X extends Ty<infer T> ? T : unknown;
15
- type EvMap<C> = C extends {
16
- readonly events: infer E;
17
- } ? E : never;
18
- type CmdMap<C> = C extends {
19
- readonly cmds: infer M;
20
- } ? M : Record<never, never>;
21
- type Groups<C> = C extends {
22
- readonly states: infer G;
23
- } ? G : never;
24
- type CtxOf<C> = C extends {
25
- readonly ctx: infer T;
26
- } ? Payload<T> : unknown;
27
- type EventName<C> = Extract<keyof EvMap<C>, string>;
28
- type CmdName<C> = Extract<keyof CmdMap<C>, string>;
29
- /** The named phases — `keyof states`. A group name is declared by BEING a key. */
30
- type GroupName<C> = Extract<keyof Groups<C>, string>;
31
- type StateName<C> = Extract<{
32
- [G in keyof Groups<C>]: keyof Groups<C>[G];
33
- }[keyof Groups<C>], string>;
34
- /** The node for state `S`, found by scanning the groups. Groups partition. */
35
- type NodeAt<C, S> = {
36
- [G in keyof Groups<C>]: S extends keyof Groups<C>[G] ? Groups<C>[G][S] : never;
37
- }[keyof Groups<C>];
38
- /** The phase `S` lives in. A union here means `S` was declared twice. */
39
- type GroupOf<C, S> = Extract<{
40
- [G in keyof Groups<C>]: S extends keyof Groups<C>[G] ? G : never;
41
- }[keyof Groups<C>], string>;
42
- type OnOf<X> = X extends {
43
- readonly on: infer O;
44
- } ? O : Record<never, never>;
45
- type IgnoreOf<X> = X extends {
46
- readonly ignore: readonly (infer I)[];
47
- } ? Extract<I, string> : never;
48
- type DataOf<X> = X extends {
49
- readonly data: infer D;
50
- } ? Payload<D> : unknown;
51
- type IsEndOf<X> = X extends {
52
- readonly end: true | "error";
53
- } ? true : false;
54
- type IsInitialOf<X> = X extends {
55
- readonly initial: true;
56
- } ? true : false;
57
- type IsForeignOf<X> = X extends {
58
- readonly foreign: true;
59
- } ? true : false;
60
- type ScopeOf<X> = X extends {
61
- readonly scope: infer S;
62
- } ? S extends readonly string[] ? S[number] : S : never;
63
- type On<C, S> = OnOf<NodeAt<C, S>>;
64
- type IgnoredAt<C, S> = IgnoreOf<NodeAt<C, S>>;
65
- /** A cmd reference on an edge: one declared name, or an ORDERED list of them. */
66
- type CmdRef<N extends string> = N | readonly N[];
67
- type EdgeSpec<SN extends string, CN extends string> = SN | {
68
- readonly to: readonly SN[];
69
- readonly cell: string;
70
- } | {
71
- readonly target: SN;
72
- readonly cmd?: CmdRef<CN>;
73
- } | {
74
- readonly target: SN;
75
- readonly when: string;
76
- readonly otherwise: SN;
77
- /** Fires only when the guard HOLDS. */
78
- readonly cmd?: CmdRef<CN>;
79
- /** Fires only when the guard FAILS — `Cmd.when` lifted onto the edge. */
80
- readonly otherwiseCmd?: CmdRef<CN>;
81
- } | {
82
- readonly resume: {
83
- readonly fallback: SN;
84
- };
85
- readonly cmd?: CmdRef<CN>;
86
- };
87
- /**
88
- * Where an event's Msg comes from. TEA's own taxonomy, and no wider:
89
- *
90
- * `"cmd"` — a Cmd's result.
91
- * `"sub"` — a Sub firing.
92
- * `{ world: <role> }` — the outside world, through the role the CONSUMER
93
- * names. `{ world: "the operator" }`, `{ world: "a
94
- * human" }` — this file knows no role names.
95
- *
96
- * Written as one exported alias and used at the declaration site too, unlike
97
- * `scope` (which is spelled out inline so tsc prints the chart's own phase
98
- * names and offers "Did you mean …?" against them). There is nothing chart-
99
- * specific to print here — the alphabet is closed, universal and three members
100
- * long — so the alias name in the diagnostic costs nothing and the one-site
101
- * rule wins.
102
- */
103
- type EventOrigin = "cmd" | "sub" | {
104
- readonly world: string;
105
- };
106
- /** The `from` field AS DECLARED — before the authored/fallback test. */
107
- type FromOf<X> = X extends {
108
- readonly from: infer F;
109
- } ? F : never;
110
- type WorldRoleOf<F> = F extends {
111
- readonly world: infer R;
112
- } ? R : never;
113
- /**
114
- * Is this event's `from` something the AUTHOR wrote, or is it tsc's fallback?
115
- *
116
- * `IsAuthoredScope`'s test, applied to this field's shape. When some OTHER
117
- * error in the literal defeats inference of `C`, tsc falls back to the
118
- * `Chart<C>` constraint, where `from` is the whole `EventOrigin` union — a
119
- * union MIXING a word with an object, which no literal can produce. An author's
120
- * `from` is either a word (`"cmd"`) or a `{ world }` with a LITERAL role; a
121
- * bare `string` role is not authorable as a declaration either, so it keeps the
122
- * same reading of "no declaration".
123
- */
124
- type IsAuthoredFrom<X, F = FromOf<X>> = [F] extends [string] ? [string] extends [F] ? false : true : [F] extends [{
125
- readonly world: string;
126
- }] ? [string] extends [WorldRoleOf<F>] ? false : true : false;
127
- /** Event `E`'s declared origin, once it is established that it IS a declaration. */
128
- type OriginAt<C, E extends keyof EvMap<C>> = [
129
- IsAuthoredFrom<EvMap<C>[E]>
130
- ] extends [true] ? FromOf<EvMap<C>[E]> : never;
131
- /**
132
- * The events whose declared origin is exactly `O`.
133
- *
134
- * The `[never] extends [O]` arm comes FIRST and is not optional: an event with
135
- * no `from` has `OriginAt` `never`, and `[never] extends ["cmd"]` is TRUE — so
136
- * without it an undeclared event would be classified as every origin at once,
137
- * which is the loudest possible way to turn "the chart does not say" into a
138
- * confident wrong answer.
139
- */
140
- type EventsFrom<C, O> = Extract<{
141
- [E in EventName<C>]: [OriginAt<C, E>] extends [never] ? never : [OriginAt<C, E>] extends [O] ? E : never;
142
- }[EventName<C>], string>;
143
- /** The events the chart says are a Cmd's result. */
144
- type CmdEvent<C> = EventsFrom<C, "cmd">;
145
- /** The events the chart says a Sub fires. */
146
- type SubEvent<C> = EventsFrom<C, "sub">;
147
- /** The events the chart attributes to a named outside-world role. */
148
- type WorldEvent<C> = Extract<{
149
- [E in EventName<C>]: [WorldRoleOf<OriginAt<C, E>>] extends [never] ? never : E;
150
- }[EventName<C>], string>;
151
- /** The role `E` is attributed to — `never` for a `cmd`/`sub`/undeclared event. */
152
- type WorldRole<C, E extends keyof EvMap<C>> = Extract<WorldRoleOf<OriginAt<C, E>>, string>;
153
- /** The `scope` field AS DECLARED — before the list is flattened to its members. */
154
- type ScopeDeclOf<X> = X extends {
155
- readonly scope: infer S;
156
- } ? S : never;
157
- type ScopeElems<S> = S extends readonly (infer T)[] ? T : S;
158
- /**
159
- * Is this event's `scope` something the AUTHOR wrote, or is it tsc's fallback?
160
- *
161
- * When some OTHER error in the chart literal (a typo'd target, say) defeats
162
- * inference of `C`, tsc falls back to the `Chart<C>` constraint, where `scope`
163
- * is the whole `"edges" | "all" | GroupName<C> | readonly (…)[]` universe. Left
164
- * alone that makes every event look live in every phase and buries the one real
165
- * diagnostic under a wall of spurious unhandled-pair demands.
166
- *
167
- * The fallback is recognised BY ITS SHAPE, not by what it happens to cover: it
168
- * is the one form that is a union MIXING a string with a list, which no literal
169
- * can produce. An author's scope is either a word (`"all"`) or a list
170
- * (`["edges", "p"]`) — never both at once.
171
- *
172
- * The older test — "a scope that spans the entire universe is no scope" — was a
173
- * proxy for this, and it misfired on the genuinely authored `["edges","all","p"]`:
174
- * the type layer read it as NO scope (so `MissingPairs<C>` was `never` and the
175
- * chart looked total) while `compile`'s `scopeList(…).includes("all")` read it as
176
- * live everywhere and threw `NoCellError` on the first msg. Testing the shape
177
- * instead makes the two layers agree by construction.
178
- *
179
- * A `string`-typed (non-literal) scope is also not authorable as a decision, so
180
- * it keeps the old reading of "no scope".
181
- */
182
- type IsAuthoredScope<X, S = ScopeDeclOf<X>> = [S] extends [string] ? [string] extends [S] ? false : true : [S] extends [readonly string[]] ? [string] extends [ScopeElems<S>] ? false : true : false;
183
- /** The event's declared scope, once it is established that it IS a declaration. */
184
- type ScopeAt<C, E extends keyof EvMap<C>> = [
185
- IsAuthoredScope<EvMap<C>[E]>
186
- ] extends [true] ? ScopeOf<EvMap<C>[E]> : never;
187
- /** The events that are LIVE at `S` — i.e. that `S` owes a decision about. */
188
- type LiveAt<C, S> = {
189
- [E in EventName<C>]: "all" extends ScopeAt<C, E> ? E : [GroupOf<C, S>] extends [ScopeAt<C, E>] ? E : never;
190
- }[EventName<C>];
191
- /** Pairs at `S` that are live, unhandled and unrefused. Empty = total. */
192
- type MissingAt<C, S> = [IsEndOf<NodeAt<C, S>>] extends [true] ? never : Exclude<LiveAt<C, S>, Extract<keyof On<C, S>, string> | IgnoredAt<C, S>>;
193
- /** Every unhandled pair in the whole chart — `never` when the chart is total. */
194
- type MissingPairs<C> = {
195
- [S in StateName<C>]: `${S}.${Extract<MissingAt<C, S>, string>}`;
196
- }[StateName<C>];
197
- type Chart<C> = {
198
- /** Data EVERY state carries. Declared once; intersected into all of them. */
199
- readonly ctx?: Ty<object>;
200
- readonly events: {
201
- readonly [E in keyof EvMap<C>]: {
202
- readonly data?: Ty<object>;
203
- /**
204
- * "This name is not mine." The Msg is minted by SOMEONE ELSE — a library
205
- * Sub (`@demlik/tea/deadline` dispatching `deadline_exceeded`), a host
206
- * bridge, another machine — so the author cannot rename it and the
207
- * compiler must not decorate it. A foreign event keeps its BARE name in
208
- * the emitted table under every namespace, which is what makes it the
209
- * same event across all N instances. Everything else — payload, `scope`,
210
- * totality, edges — is unchanged: it is a normal event that happens to
211
- * belong to someone else.
212
- */
213
- readonly foreign?: true;
214
- /**
215
- * WHERE THIS MSG COMES FROM — see {@link EventOrigin} and §3a.
216
- *
217
- * Optional, and its absence means exactly "the chart does not say",
218
- * never a default: a chart that declares no `from` behaves as it always
219
- * did, and a reader that wants the answer must degrade honestly rather
220
- * than guess. It composes with everything else on the event — `scope`
221
- * answers WHERE the event is live, `data` WHAT it carries, `foreign`
222
- * WHOSE NAME it is, and this WHO SENT IT — and none of the four is
223
- * derivable from another.
224
- */
225
- readonly from?: EventOrigin;
226
- readonly scope: "edges" | "all" | GroupName<C> | readonly ("edges" | "all" | GroupName<C>)[];
227
- };
228
- };
229
- readonly cmds?: {
230
- readonly [N in keyof CmdMap<C>]: Ty<object>;
231
- };
232
- readonly states: {
233
- readonly [G in keyof Groups<C>]: {
234
- readonly [S in keyof Groups<C>[G]]: {
235
- /** Exactly one state in a machine-bearing chart marks itself the entry. */
236
- readonly initial?: true;
237
- /** Extra data only THIS state carries, on top of `ctx`. */
238
- readonly data?: Ty<object>;
239
- readonly on?: {
240
- readonly [E in EventName<C>]?: EdgeSpec<StateName<C>, CmdName<C>>;
241
- };
242
- /** Per-state exception: refuse a live event by name. */
243
- readonly ignore?: readonly EventName<C>[];
244
- /**
245
- * Terminal, and WITH WHICH POLARITY.
246
- *
247
- * `true` is the success final — the meaning it has always had, so every
248
- * chart written before this field widened is unchanged. `"error"` is
249
- * the failure final: the state a guarded edge falls through to when its
250
- * guard is spent (`frozen`, `tripped`), which a driver reads to trip the
251
- * whole run rather than to call it done.
252
- *
253
- * Both are finals in every structural sense — no obligations, no edges.
254
- * The difference is not "is this the end" but "which end", and it is
255
- * declared here because it is a fact ABOUT THE STATE, not a fact about
256
- * the one edge that happens to reach it.
257
- */
258
- readonly end?: true | "error";
259
- };
260
- };
261
- };
262
- };
263
- type KnownEdgeField = "target" | "cmd" | "otherwiseCmd" | "when" | "otherwise" | "resume" | "to" | "cell";
264
- /**
265
- * A cell edge OWNS its transition end to end — it picks the target and returns
266
- * its own cmds. So every declarative field that would also decide one of those
267
- * is illegal ALONGSIDE it, rather than silently ignored by the walk:
268
- *
269
- * `cmd`/`otherwiseCmd` — the cell already returns the cmd list (req. 4)
270
- * `when`/`otherwise` — the cell already chose (a guard would choose twice)
271
- * `target`/`resume` — same fact as `to`, said a second way
272
- *
273
- * The `assign` bypass (req. 6) is caught one level up: `Assigns` is keyed by
274
- * `EdgeKey` MINUS the cell edges, so writing `"polling.poll_failed"` in the
275
- * assign bag of a cell edge is an excess property, named by tsc.
276
- */
277
- type CellFieldConflict = "target" | "cmd" | "otherwiseCmd" | "when" | "otherwise" | "resume";
278
- /**
279
- * A resume edge OWNS its transition the same way a cell edge does: the target
280
- * is `st.was ?? fallback`, which is neither declared nor chosen by a guard. So
281
- * every field that would ALSO decide the target is illegal alongside it, rather
282
- * than accepted and then skipped by the walk — `buildCell` tests `edge.resume`
283
- * first, so a `when` beside it is a guard the author writes, maintains and
284
- * reads as load-bearing, and which is never once called.
285
- *
286
- * `cmd` is absent from this list deliberately: `EdgeSpec` admits `{ resume, cmd }`
287
- * and the walk fires it, so it is a real, working field on a resume edge.
288
- * `to`/`cell` are absent because `CellCheck` already names that conflict.
289
- */
290
- type ResumeFieldConflict = "target" | "when" | "otherwise" | "otherwiseCmd";
291
- type ResumeCheck<X> = X extends {
292
- readonly resume: unknown;
293
- } ? [Extract<keyof X, ResumeFieldConflict>] extends [never] ? unknown : {
294
- readonly __resumeEdgeCannotAlsoDeclare: Extract<keyof X, ResumeFieldConflict>;
295
- } : unknown;
296
- /**
297
- * `when` and `otherwise` are ONE fact — "this edge branches" — written in two
298
- * halves, and half of it is not a decision, it is a hole.
299
- *
300
- * The two layers used to key the `{ then, else }` assign shape off different
301
- * halves: `Cell<C, X, …>` off `X extends { target; otherwise }`, `buildCell`
302
- * off `edge.when !== undefined`. Omit either field and they picked opposite
303
- * shapes — the chart compiled and then died with `payloadFn is not a function`
304
- * on the first message. Both layers now read `when`, and this makes the two
305
- * halves inseparable, so there is no shape left on which they could disagree.
306
- */
307
- type GuardPairCheck<X> = X extends {
308
- readonly when: string;
309
- } ? X extends {
310
- readonly otherwise: unknown;
311
- } ? unknown : {
312
- readonly __whenNeedsAnOtherwiseTarget: true;
313
- } : X extends {
314
- readonly otherwise: unknown;
315
- } ? {
316
- readonly __otherwiseNeedsAWhenGuard: true;
317
- } : unknown;
318
- type CellCheck<X> = X extends {
319
- readonly cell: string;
320
- } ? X extends {
321
- readonly to: readonly unknown[];
322
- } ? [Extract<keyof X, CellFieldConflict>] extends [never] ? unknown : {
323
- readonly __cellEdgeCannotAlsoDeclare: Extract<keyof X, CellFieldConflict>;
324
- } : {
325
- readonly __cellEdgeMustDeclareItsTargetsInTo: true;
326
- } : X extends {
327
- readonly to: readonly unknown[];
328
- } ? {
329
- readonly __toWithoutACellToPickFromIt: true;
330
- } : unknown;
331
- type EdgeCheck<X> = X extends string ? unknown : [Exclude<keyof X, KnownEdgeField>] extends [never] ? CellCheck<X> & ResumeCheck<X> & GuardPairCheck<X> & (X extends {
332
- readonly otherwiseCmd: unknown;
333
- } ? X extends {
334
- readonly when: string;
335
- } ? unknown : {
336
- readonly __otherwiseCmdWithoutAGuard: true;
337
- } : unknown) : {
338
- readonly __edgeHasUnknownField: Exclude<keyof X, KnownEdgeField>;
339
- };
340
- type KnownChartField = "ctx" | "events" | "cmds" | "states";
341
- type KnownEventField = "data" | "foreign" | "scope" | "from";
342
- type KnownNodeField = "initial" | "data" | "on" | "ignore" | "end";
343
- type UnknownKeys<X, Known extends string> = Exclude<keyof X, Known>;
344
- /**
345
- * The `{ world }` form's own unknown-key rule — the same hole one level down.
346
- *
347
- * `EventCheck` names a typo'd key ON the event (`frm`), but the world origin is
348
- * an object of its own and constraint checking runs no excess-property check
349
- * inside it either: `{ world: "a human", role: "reviewer" }` structurally
350
- * satisfies `{ world: string }`, so a second field would be accepted and then
351
- * silently dropped by every reader. A role is ONE fact and it is `world`.
352
- */
353
- type FromCheck<X> = X extends {
354
- readonly from: infer F;
355
- } ? [F] extends [string] ? unknown : [Exclude<keyof F, "world">] extends [never] ? unknown : {
356
- readonly __fromWorldCannotAlsoDeclare: Exclude<keyof F, "world">;
357
- } : unknown;
358
- type EventCheck<X> = ([UnknownKeys<X, KnownEventField>] extends [never] ? unknown : {
359
- readonly __eventHasUnknownField: UnknownKeys<X, KnownEventField>;
360
- }) & FromCheck<X>;
361
- type NodeCheck<N> = [UnknownKeys<N, KnownNodeField>] extends [never] ? unknown : {
362
- readonly __stateNodeHasUnknownField: UnknownKeys<N, KnownNodeField>;
363
- };
364
- type StrictNode<C, N> = NodeCheck<N> & {
365
- readonly on?: {
366
- readonly [E in keyof OnOf<N>]: E extends EventName<C> ? EdgeCheck<OnOf<N>[E]> : {
367
- readonly __onDeclaresAnUndeclaredEvent: E;
368
- };
369
- };
370
- };
371
- type IsDegenerate<N> = [string] extends [N] ? true : false;
372
- type LiteralAlphabets<C> = ([IsDegenerate<StateName<C>>] extends [true] ? {
373
- readonly __stateNamesMustBeLiteralsNotAComputedStringKey: true;
374
- } : unknown) & ([IsDegenerate<EventName<C>>] extends [true] ? {
375
- readonly __eventNamesMustBeLiteralsNotAComputedStringKey: true;
376
- } : unknown) & ([IsDegenerate<CmdName<C>>] extends [true] ? {
377
- readonly __cmdNamesMustBeLiteralsNotAComputedStringKey: true;
378
- } : unknown) & ([IsDegenerate<GroupName<C>>] extends [true] ? {
379
- readonly __phaseNamesMustBeLiteralsNotAComputedStringKey: true;
380
- } : unknown);
381
- type Strict<C> = LiteralAlphabets<C> & ([UnknownKeys<C, KnownChartField>] extends [never] ? unknown : {
382
- readonly __chartHasUnknownField: UnknownKeys<C, KnownChartField>;
383
- }) & {
384
- readonly events: {
385
- readonly [E in keyof EvMap<C>]: EventCheck<EvMap<C>[E]>;
386
- };
387
- readonly states: {
388
- readonly [G in keyof Groups<C>]: {
389
- readonly [S in keyof Groups<C>[G]]: StrictNode<C, Groups<C>[G][S]>;
390
- };
391
- };
392
- };
393
- type Demand<S extends string, E extends string> = E extends string ? `unhandled pair "${S}.${E}" — declare it in \`on\`, or list "${E}" in this state's \`ignore\`, or narrow the \`scope\` of event "${E}"` : never;
394
- type IsUnion<T, U = T> = T extends unknown ? [U] extends [T] ? false : true : never;
395
- type Total<C> = {
396
- readonly events: {
397
- readonly [E in keyof EvMap<C>]: [IsForeignOf<EvMap<C>[E]>] extends [true] ? E extends `${string}.${string}` ? {
398
- readonly __foreignEventNameCannotContainADot: E;
399
- } : unknown : unknown;
400
- };
401
- readonly states: {
402
- readonly [G in keyof Groups<C>]: {
403
- readonly [S in keyof Groups<C>[G]]: ([MissingAt<C, S>] extends [never] ? unknown : {
404
- readonly [K in Demand<Extract<S, string>, Extract<MissingAt<C, S>, string>>]: never;
405
- }) & (Extract<S, string> extends `${string}.${string}` ? {
406
- readonly __stateNameCannotContainADot: S;
407
- } : unknown) & ([Extract<keyof On<C, S>, string>] extends [never] ? unknown : [IsEndOf<Groups<C>[G][S]>] extends [true] ? {
408
- readonly __endStateCannotDeclareEdges: keyof On<C, S>;
409
- } : unknown) & ([IsUnion<GroupOf<C, S>>] extends [true] ? {
410
- readonly __stateDeclaredInTwoPhases: GroupOf<C, S>;
411
- } : unknown) & ([Exclude<IgnoredAt<C, S>, LiveAt<C, S>>] extends [never] ? unknown : {
412
- readonly __refusalRefusesNothing: Exclude<IgnoredAt<C, S>, LiveAt<C, S>>;
413
- });
414
- };
415
- };
416
- };
417
- /**
418
- * `const C` preserves the nested literals with no `as const` at the call site
419
- * (without it every edge value widens to `string` and every derivation below
420
- * collapses). `Strict` and `Total` sit on the PARAMETER, not on the constraint:
421
- * intersecting them into the constraint makes the typo'd-target diagnostic
422
- * collapse to an index-signature complaint about `string` and lose tsc's
423
- * "Did you mean '"review"'?" suggestion.
424
- */
425
- declare function defineChart<const C extends Chart<C>>(c: C & Strict<C> & Total<C>): C;
426
- type EdgeAt<C, S, E> = E extends keyof On<C, S> ? On<C, S>[E] : never;
427
- /** The `State.Event` pairs that are ACTUALLY declared — not the cross product. */
428
- type EdgeKey<C> = {
429
- [S in StateName<C>]: `${S}.${Extract<keyof On<C, S>, string>}`;
430
- }[StateName<C>];
431
- /** The subset of `EdgeKey` whose transition is delegated to a cell. */
432
- type CellEdgeKey<C> = Extract<{
433
- [S in StateName<C>]: {
434
- [E in keyof On<C, S>]: On<C, S>[E] extends {
435
- readonly cell: string;
436
- } ? `${S}.${Extract<E, string>}` : never;
437
- }[keyof On<C, S>];
438
- }[StateName<C>], string>;
439
- /** The state marked `initial: true` — the chart's entry, as data. */
440
- type InitialState<C> = Extract<{
441
- [S in StateName<C>]: [IsInitialOf<NodeAt<C, S>>] extends [true] ? S : never;
442
- }[StateName<C>], string>;
443
- /**
444
- * `S`'s terminal polarity, as data: `true` (success final), `"error"` (failure
445
- * final) or `false` (not a final at all).
446
- *
447
- * Read off the ONE site the polarity is declared at, so a drawing, a driver and
448
- * a status derivation cannot disagree about which finals mean "done" and which
449
- * mean "tripped".
450
- */
451
- type EndPolarity<C, S> = [IsEndOf<NodeAt<C, S>>] extends [true] ? NodeAt<C, S> extends {
452
- readonly end: "error";
453
- } ? "error" : true : false;
454
- /** Every state the chart declares a SUCCESS final. */
455
- type SuccessFinal<C> = Extract<{
456
- [S in StateName<C>]: [EndPolarity<C, S>] extends [true] ? S : never;
457
- }[StateName<C>], string>;
458
- /** Every state the chart declares an ERROR final — the tripped terminals. */
459
- type ErrorFinal<C> = Extract<{
460
- [S in StateName<C>]: [EndPolarity<C, S>] extends ["error"] ? S : never;
461
- }[StateName<C>], string>;
462
- /** States that carry a `resume` edge out of them — the parking states. */
463
- type ParkingState<C> = Extract<{
464
- [S in StateName<C>]: {
465
- [E in keyof On<C, S>]: On<C, S>[E] extends {
466
- readonly resume: unknown;
467
- } ? S : never;
468
- }[keyof On<C, S>];
469
- }[StateName<C>], string>;
470
- /** The targets a CELL edge declares — the union its cell is clamped to. */
471
- type ToOf<X> = X extends {
472
- readonly to: readonly (infer T)[];
473
- } ? T : never;
474
- /**
475
- * Every state an edge can land on. A guarded edge contributes both arms; a
476
- * cell edge contributes its whole declared `to` fan-out — which is precisely
477
- * why the escape hatch does not blind the derivations (`ResumeTargets`,
478
- * `chartMermaid`) that read the graph's shape.
479
- */
480
- type TargetOf<X> = X extends string ? X : X extends {
481
- readonly to: readonly unknown[];
482
- } ? ToOf<X> : X extends {
483
- readonly target: infer T;
484
- } ? T | (X extends {
485
- readonly otherwise: infer O;
486
- } ? O : never) : never;
487
- /** States with an edge INTO `P` — i.e. the states you could be parked from. */
488
- type ResumeSource<C, P> = {
489
- [S in StateName<C>]: {
490
- [E in keyof On<C, S>]: P extends TargetOf<On<C, S>[E]> ? S : never;
491
- }[keyof On<C, S>];
492
- }[StateName<C>];
493
- /** The `fallback` declared on `P`'s resume edge — Umut's `?? initial`. */
494
- type FallbackOf<C, P> = {
495
- [E in keyof On<C, P>]: On<C, P>[E] extends {
496
- readonly resume: {
497
- readonly fallback: infer F;
498
- };
499
- } ? F : never;
500
- }[keyof On<C, P>];
501
- /**
502
- * Where a resume edge out of parking state `P` can land: any state with an edge
503
- * into `P`, plus the declared fallback. `was ?? initial` lifted to a type — and
504
- * DERIVED, so adding a `BLOCKED` edge from a new state widens the legal `was`.
505
- */
506
- type ResumeTargets<C, P> = Extract<ResumeSource<C, P> | FallbackOf<C, P>, string>;
507
- /**
508
- * `was` is INJECTED here, not authored: a parking state is one with a `resume`
509
- * edge, which the chart already says. Writing `blocked: Ctx & { was: … }` by
510
- * hand would be that same fact a second time.
511
- */
512
- type StateOf<C> = {
513
- [S in StateName<C>]: {
514
- readonly type: S;
515
- } & CtxOf<C> & DataOf<NodeAt<C, S>> & (S extends ParkingState<C> ? {
516
- readonly was: ResumeTargets<C, S>;
517
- } : unknown);
518
- }[StateName<C>];
519
- type MsgOf<C> = {
520
- [E in EventName<C>]: {
521
- readonly type: E;
522
- } & DataOf<EvMap<C>[E]>;
523
- }[EventName<C>];
524
- type CmdOf<C> = [CmdName<C>] extends [never] ? Cmd<never> : {
525
- [N in CmdName<C>]: {
526
- readonly type: N;
527
- } & Payload<CmdMap<C>[N]>;
528
- }[CmdName<C>];
529
- /** The events the chart declares FOREIGN — the names that are not ours to decorate. */
530
- type ForeignEvent<C> = Extract<{
531
- [E in EventName<C>]: [IsForeignOf<EvMap<C>[E]>] extends [true] ? E : never;
532
- }[EventName<C>], string>;
533
- /**
534
- * How the compiled table keys event `E`. Namespacing is PER-EVENT, not
535
- * per-machine: `NS` omitted (`undefined`) namespaces nothing, and a foreign
536
- * event keeps its bare name even under a namespace. Everything stays a literal.
537
- */
538
- type KeyOf<C, NS extends string | undefined, E extends string> = E extends ForeignEvent<C> ? E : NS extends string ? `${NS}.${E}` : E;
539
- /**
540
- * The Msg union AS THE COMPILED TABLE CONSUMES IT — the same derivation as
541
- * `MsgOf`, with the keys the namespace produces. Two namespaces give genuinely
542
- * disjoint literal unions for the author's OWN events, while the foreign events
543
- * are literally shared, because they are the same event.
544
- */
545
- type MsgIn<C, NS extends string | undefined = undefined> = {
546
- [E in EventName<C>]: {
547
- readonly type: KeyOf<C, NS, E>;
548
- } & DataOf<EvMap<C>[E]>;
549
- }[EventName<C>];
550
- type Narrow<U, K> = Extract<U, {
551
- type: K;
552
- }>;
553
- type Data<S, K> = K extends string ? Omit<Narrow<S, K>, "type"> : never;
554
- type UnionToIntersection<U> = (U extends unknown ? (x: U) => void : never) extends (x: infer I) => void ? I : never;
555
- /**
556
- * What an `assign` must return for a given target. `was` is stripped when the
557
- * target is a parking state: the compiler injects it from `state.type`, so the
558
- * author can neither forget it nor type it wrong.
559
- */
560
- type Assigned<C, S, T> = T extends string ? T extends ParkingState<C> ? Omit<Data<S, T>, "was"> : Data<S, T> : never;
561
- /**
562
- * What `boot()` must return: the initial state's payload, minus the `type` the
563
- * compiler stamps on. The two degenerate charts get a NAMED marker type rather
564
- * than a silent `never`, so the diagnostic says which rule was broken.
565
- */
566
- type InitialData<C, S extends {
567
- type: string;
568
- }> = [
569
- InitialState<C>
570
- ] extends [never] ? {
571
- readonly __chartDeclaresNoInitialState: true;
572
- } : [IsUnion<InitialState<C>>] extends [true] ? {
573
- readonly __chartDeclaresManyInitialStates: InitialState<C>;
574
- } : Data<S, InitialState<C>>;
575
- type Fn<S, M, From, Ev, R> = (state: Narrow<S, From>, msg: Narrow<M, Ev>) => R;
576
- type Cell<C, X, S, M, From, Ev> = X extends {
577
- readonly resume: unknown;
578
- } ? Fn<S, M, From, Ev, UnionToIntersection<Assigned<C, S, ResumeTargets<C, From>>>> : X extends {
579
- readonly when: string;
580
- } ? {
581
- readonly then: Fn<S, M, From, Ev, Assigned<C, S, X extends {
582
- readonly target: infer T;
583
- } ? T : never>>;
584
- readonly else: Fn<S, M, From, Ev, Assigned<C, S, X extends {
585
- readonly otherwise: infer O;
586
- } ? O : never>>;
587
- } : X extends {
588
- readonly target: infer T;
589
- } ? Fn<S, M, From, Ev, Assigned<C, S, T>> : X extends string ? Fn<S, M, From, Ev, Assigned<C, S, X>> : never;
590
- /**
591
- * The payload builders — one per DECLARATIVE edge. Cell edges are excluded:
592
- * a cell returns the whole next state itself, so an `assign` entry for one
593
- * would be dead code the walk never calls. Because this is a mapped type over
594
- * a closed key union, writing that entry anyway is an excess property and tsc
595
- * names it (req. 6 — the bypass is a compile error, not a surprise).
596
- */
597
- type Assigns<C, S extends {
598
- type: string;
599
- }, M extends {
600
- type: string;
601
- }> = {
602
- [K in Exclude<EdgeKey<C>, CellEdgeKey<C>>]: K extends `${infer From}.${infer Ev}` ? Cell<C, EdgeAt<C, From, Ev>, S, M, From, Ev> : never;
603
- };
604
- type GuardName<C> = Extract<{
605
- [S in StateName<C>]: {
606
- [E in keyof On<C, S>]: On<C, S>[E] extends {
607
- readonly when: infer W;
608
- } ? W : never;
609
- }[keyof On<C, S>];
610
- }[StateName<C>], string>;
611
- /** Every cell named by a `{ to, cell }` edge — the escape hatch's alphabet. */
612
- type CellName<C> = Extract<{
613
- [S in StateName<C>]: {
614
- [E in keyof On<C, S>]: On<C, S>[E] extends {
615
- readonly cell: infer W;
616
- } ? W : never;
617
- }[keyof On<C, S>];
618
- }[StateName<C>], string>;
619
- /** Flatten a `CmdRef` — one name, or every name in an ordered list. */
620
- type Flatten<X> = X extends readonly string[] ? X[number] : X;
621
- /** Every cmd an edge can fire, across BOTH guard arms. */
622
- type EdgeCmds<X> = (X extends {
623
- readonly cmd: infer Q;
624
- } ? Flatten<Q> : never) | (X extends {
625
- readonly otherwiseCmd: infer Q;
626
- } ? Flatten<Q> : never);
627
- /** Every cmd name any edge in the chart actually FIRES declaratively. */
628
- type UsedCmdName<C> = Extract<{
629
- [S in StateName<C>]: {
630
- [E in keyof On<C, S>]: EdgeCmds<On<C, S>[E]>;
631
- }[keyof On<C, S>];
632
- }[StateName<C>], string>;
633
- /** What field `F` on an edge REFERENCES — a guard/cell name, or its cmd names. */
634
- type Referenced<X, F extends "when" | "cmd" | "cell"> = F extends "when" ? X extends {
635
- readonly when: infer W;
636
- } ? W : never : F extends "cell" ? X extends {
637
- readonly cell: infer W;
638
- } ? W : never : EdgeCmds<X>;
639
- /**
640
- * Scan the chart for every edge that references `Name` through field `F`.
641
- * `[Name] extends [Referenced<…>]` rather than an equality check, because an
642
- * edge's cmd list references SEVERAL names at once.
643
- */
644
- type SitesWhere<C, F extends "when" | "cmd" | "cell", Name> = {
645
- [S in StateName<C>]: {
646
- [E in keyof On<C, S>]: [Name] extends [Referenced<On<C, S>[E], F>] ? `${S}.${Extract<E, string>}` : never;
647
- }[keyof On<C, S>];
648
- }[StateName<C>];
649
- /**
650
- * `"review.FAIL"` → `[state: ReviewState, msg: FailMsg, at: "review.FAIL"]`.
651
- * Distributes over N sites, so a multi-site name yields a UNION OF TUPLES.
652
- *
653
- * The third element is the correlator. A union of tuples does not, on its own,
654
- * keep `state` and `msg` in step: narrowing `state.type` is a NESTED
655
- * discriminant, and TypeScript's dependent-parameter control-flow analysis
656
- * (TS 4.6, microsoft/TypeScript#47109) only re-narrows sibling parameters from
657
- * a discriminant that is a DIRECT, literal-typed element of the union. `at` is
658
- * exactly that: one `switch (at)` collapses the tuple union to a single member,
659
- * and `state` AND `msg` both narrow with it.
660
- *
661
- * For a single-site name `K` is not a union, so this is a lone tuple and the
662
- * author may keep writing `(s, m) => …`.
663
- */
664
- type SiteArgs<K, S, M> = K extends `${infer From}.${infer Ev}` ? [state: Narrow<S, From>, msg: Narrow<M, Ev>, at: K] : never;
665
- /**
666
- * THE POINT. A guard's parameters come from the edges that REFERENCE it, not
667
- * from a standalone registry declaration — so `retriesRemaining`, used only at
668
- * `review.FAIL`, receives exactly `review`'s state and `FAIL`'s msg.
669
- */
670
- type Guards<C, S extends {
671
- type: string;
672
- }, M extends {
673
- type: string;
674
- }> = {
675
- [N in GuardName<C>]: (...args: SiteArgs<SitesWhere<C, "when", N>, S, M>) => boolean;
676
- };
677
- /**
678
- * Same technique: a cmd's parameters come from the edges that REFERENCE it, and
679
- * the payload it owes is the one DECLARED in the chart's `cmds` section — the
680
- * single site where the effect alphabet lives. A cmd fired from two edges gets
681
- * the union of both sites' `[state, msg]` tuples.
682
- */
683
- type Cmds<C, S extends {
684
- type: string;
685
- }, M extends {
686
- type: string;
687
- }> = {
688
- [N in UsedCmdName<C>]: (...args: SiteArgs<SitesWhere<C, "cmd", N>, S, M>) => Payload<CmdMap<C>[N]>;
689
- };
690
- /**
691
- * THE ESCAPE HATCH's parts bag. Same shape and the same `SitesWhere`/`SiteArgs`
692
- * narrowing as `guards` and `cmds` — a cell used at one site gets exactly that
693
- * site's state and msg, a cell used at N sites gets the union of N tuples plus
694
- * the `at` correlator to discriminate on.
695
- *
696
- * What is different is the RETURN: a cell returns the transition itself,
697
- * `[nextState, cmds]`, clamped to the states the edge DECLARED in `to`. That
698
- * clamp is the whole bargain — code may decide, but only among the targets the
699
- * chart admits, so the chart stays a truthful drawing of the machine.
700
- */
701
- type Cells<C, S extends {
702
- type: string;
703
- }, M extends {
704
- type: string;
705
- }> = {
706
- [N in CellName<C>]: CellForm<C, SitesWhere<C, "cell", N>, S, M>;
707
- };
708
- /** The `to` union of every site `N` is used at, resolved to real State members. */
709
- type CellTarget<C, Sites, S> = Sites extends `${infer From}.${infer Ev}` ? Narrow<S, ToOf<EdgeAt<C, From, Ev>>> : never;
710
- type CellReturn<C, Sites, S> = readonly [
711
- CellTarget<C, Sites, S>,
712
- readonly CmdOf<C>[]
713
- ];
714
- /**
715
- * THE MULTI-SITE RETURN, EXACTLY. One entry per use site, each a lone tuple of
716
- * parameters and each clamped to THAT site's `to` — so `a.X` returning a `c` is
717
- * rejected at `a.X` rather than waved through because some OTHER site admits a
718
- * `c`. The `at` element is still passed (the walk hands it over uniformly), and
719
- * is simply redundant here: the key already says which site this is.
720
- */
721
- type CellBySite<C, Sites, S, M> = {
722
- readonly [K in Extract<Sites, string>]: (...args: SiteArgs<K, S, M>) => CellReturn<C, K, S>;
723
- };
724
- /**
725
- * A cell is written in ONE of two forms, and the choice is the precision dial.
726
- *
727
- * the FUNCTION form — one body, `switch (at)` inside. Parameters narrow per
728
- * site (the `SiteArgs` correlator); the RETURN does not, because the whole
729
- * thing is one rest signature over a union of tuples and TypeScript has no
730
- * dependent return type over that (5.7: a union of function types is
731
- * reduced back to exactly this shape, an intersection loses the parameter
732
- * correlation, and a generic on the site key correlates nothing and merely
733
- * rejects every body — all three measured, none of them work). The clamp is
734
- * therefore the union of every site's `to`.
735
- *
736
- * the PER-SITE form — one entry per site, each exact in both directions.
737
- *
738
- * The second is offered ONLY when the cell is genuinely multi-site: with one
739
- * site the function form is already exact in both directions, so its type stays
740
- * byte-for-byte what it was and the common case cannot regress.
741
- *
742
- * The looseness the function form keeps is closed at RUNTIME instead: the walk
743
- * checks the returned `type` against the edge's declared `to` and throws
744
- * `CellTargetError`. Worth less than a compile error, worth more than nothing —
745
- * and `to` is right there, so it costs one `includes`.
746
- */
747
- type CellForm<C, Sites, S, M> = ((...args: SiteArgs<Sites, S, M>) => CellReturn<C, Sites, S>) | ([IsUnion<Sites>] extends [true] ? CellBySite<C, Sites, S, M> : never);
748
- /** The declared state names — a flat tuple, not a grouped record of nodes. */
749
- type RStateName<C> = C extends {
750
- readonly states: readonly (infer S)[];
751
- } ? Extract<S, string> : never;
752
- /** The top-level edge bag. One edge per event; that IS the totality obligation. */
753
- type ROn<C> = C extends {
754
- readonly on: infer O;
755
- } ? O : never;
756
- type REdgeAt<C, E> = E extends keyof ROn<C> ? ROn<C>[E] : never;
757
- type ReducerChart<C> = {
758
- /** Data EVERY state carries — and, here, the ONLY data any state carries. */
759
- readonly ctx?: Ty<object>;
760
- readonly states: readonly RStateName<C>[];
761
- /** The entry state, by name. One word where the grid form marks a node. */
762
- readonly initial: RStateName<C>;
763
- readonly events: {
764
- readonly [E in keyof EvMap<C>]: {
765
- readonly data?: Ty<object>;
766
- /** Same meaning as the grid form's: this name is not ours to decorate. */
767
- readonly foreign?: true;
768
- /**
769
- * KEPT, where `scope` is dropped. `scope` answers "at which STATES does
770
- * this event mean anything", and with no state dimension the question
771
- * has no content. "Who sent this" has exactly as much content here as it
772
- * does in the grid form — it is a fact about the event, and this form
773
- * still has events.
774
- */
775
- readonly from?: EventOrigin;
776
- };
777
- };
778
- readonly cmds?: {
779
- readonly [N in keyof CmdMap<C>]: Ty<object>;
780
- };
781
- /**
782
- * TOTAL, not partial. Every declared event owes an edge — the `?` the grid
783
- * form's per-state `on` carries is exactly what `Total<C>` had to police
784
- * there, and here the mapped type does it for free.
785
- */
786
- readonly on: {
787
- readonly [E in EventName<C>]: EdgeSpec<RStateName<C>, CmdName<C>>;
788
- };
789
- };
790
- /**
791
- * `resume` needs a phase dimension: `was` is derived from "the states with an
792
- * edge INTO the parking state", and here every edge is reachable from every
793
- * state, so the derivation degenerates to "all of them" and says nothing. It
794
- * is rejected by name rather than silently accepted and ignored by the walk.
795
- */
796
- type RStrictEdge<X> = X extends {
797
- readonly resume: unknown;
798
- } ? {
799
- readonly __resumeNeedsAPhaseDimension: true;
800
- } : EdgeCheck<X>;
801
- /** The reducer form's key alphabet — `scope` has no meaning without phases. */
802
- type KnownReducerChartField = "ctx" | "states" | "initial" | "events" | "cmds" | "on";
803
- type KnownReducerEventField = "data" | "foreign" | "from";
804
- type REventCheck<X> = ([UnknownKeys<X, KnownReducerEventField>] extends [never] ? unknown : {
805
- readonly __eventHasUnknownField: UnknownKeys<X, KnownReducerEventField>;
806
- }) & FromCheck<X>;
807
- type StrictR<C> = ([IsDegenerate<RStateName<C>>] extends [true] ? {
808
- readonly __stateNamesMustBeLiteralsNotAComputedStringKey: true;
809
- } : unknown) & ([IsDegenerate<EventName<C>>] extends [true] ? {
810
- readonly __eventNamesMustBeLiteralsNotAComputedStringKey: true;
811
- } : unknown) & ([IsDegenerate<CmdName<C>>] extends [true] ? {
812
- readonly __cmdNamesMustBeLiteralsNotAComputedStringKey: true;
813
- } : unknown) & ([UnknownKeys<C, KnownReducerChartField>] extends [never] ? unknown : {
814
- readonly __chartHasUnknownField: UnknownKeys<C, KnownReducerChartField>;
815
- }) & {
816
- readonly on: {
817
- readonly [E in keyof ROn<C>]: E extends EventName<C> ? RStrictEdge<ROn<C>[E]> : {
818
- readonly __onDeclaresAnUndeclaredEvent: E;
819
- };
820
- };
821
- readonly events: {
822
- readonly [E in keyof EvMap<C>]: REventCheck<EvMap<C>[E]> & ([IsForeignOf<EvMap<C>[E]>] extends [true] ? E extends `${string}.${string}` ? {
823
- readonly __foreignEventNameCannotContainADot: E;
824
- } : unknown : unknown);
825
- };
826
- };
827
- /** Same contract as `defineChart`, one dimension smaller. */
828
- declare function defineReducerChart<const C extends ReducerChart<C>>(c: C & StrictR<C>): C;
829
- /**
830
- * ONE object, not a union: every state carries `ctx` and nothing else, so the
831
- * only thing that varies is the tag. This is the original's
832
- * `interface State { phase: Phase; … }` with `phase` named `type`.
833
- */
834
- type RStateOf<C> = {
835
- readonly type: RStateName<C>;
836
- } & CtxOf<C>;
837
- /** The events whose transition is delegated to a cell. */
838
- type RCellEvent<C> = Extract<{
839
- [E in EventName<C>]: ROn<C>[E & keyof ROn<C>] extends {
840
- readonly cell: string;
841
- } ? E : never;
842
- }[EventName<C>], string>;
843
- type RNames<C, F extends "when" | "cmd" | "cell"> = Extract<{
844
- [E in keyof ROn<C>]: Referenced<ROn<C>[E], F>;
845
- }[keyof ROn<C>], string>;
846
- type RGuardName<C> = RNames<C, "when">;
847
- type RCellName<C> = RNames<C, "cell">;
848
- type RUsedCmdName<C> = RNames<C, "cmd">;
849
- /**
850
- * A site is an EVENT. The grid form's `SitesWhere` scans `state × event`; with
851
- * one dimension the scan is the same shape with the outer loop removed.
852
- */
853
- type RSitesWhere<C, F extends "when" | "cmd" | "cell", Name> = Extract<{
854
- [E in keyof ROn<C>]: [Name] extends [Referenced<ROn<C>[E], F>] ? E : never;
855
- }[keyof ROn<C>], string>;
856
- /**
857
- * The state is NOT narrowed — there is nothing to narrow it to. Everything
858
- * else is `SiteArgs` verbatim, including the `at` correlator that lets a
859
- * multi-site helper discriminate its msg with one `switch`.
860
- */
861
- type RSiteArgs<K, S, M> = K extends string ? [state: S, msg: Narrow<M, K>, at: K] : never;
862
- type RGuards<C, S, M extends {
863
- type: string;
864
- }> = {
865
- [N in RGuardName<C>]: (...args: RSiteArgs<RSitesWhere<C, "when", N>, S, M>) => boolean;
866
- };
867
- type RCmds<C, S, M extends {
868
- type: string;
869
- }> = {
870
- [N in RUsedCmdName<C>]: (...args: RSiteArgs<RSitesWhere<C, "cmd", N>, S, M>) => Payload<CmdMap<C>[N & keyof CmdMap<C>]>;
871
- };
872
- type RCells<C, S extends {
873
- type: string;
874
- }, M extends {
875
- type: string;
876
- }> = {
877
- [N in RCellName<C>]: RCellForm<C, RSitesWhere<C, "cell", N>, S, M>;
878
- };
879
- /** The `to` clamp, unchanged in spirit: the tag is restricted, `ctx` is not. */
880
- type RCellTarget<C, Sites> = Sites extends string ? {
881
- readonly type: Extract<ToOf<REdgeAt<C, Sites>>, string>;
882
- } & CtxOf<C> : never;
883
- type RCellReturn<C, Sites> = readonly [
884
- RCellTarget<C, Sites>,
885
- readonly CmdOf<C>[]
886
- ];
887
- /**
888
- * `CellForm`, with the phase dimension removed — the same two forms, offered on
889
- * the same condition, for the same reason. A site here is an EVENT, so the
890
- * per-site bag is keyed `"X" | "Y"` rather than `"a.X" | "b.Y"`; everything
891
- * else, including the runtime `CellTargetError` under the function form, is the
892
- * grid form's machinery reused verbatim (`buildCell` serves both).
893
- */
894
- type RCellForm<C, Sites, S, M extends {
895
- type: string;
896
- }> = ((...args: RSiteArgs<Sites, S, M>) => RCellReturn<C, Sites>) | ([IsUnion<Sites>] extends [true] ? {
897
- readonly [K in Extract<Sites, string>]: (...args: RSiteArgs<K, S, M>) => RCellReturn<C, K>;
898
- } : never);
899
- /**
900
- * What an `assign` returns: `ctx`, for every target. The compiler stamps
901
- * `type` from the edge, so — as in the grid form — the author cannot forget it
902
- * and cannot get it wrong.
903
- */
904
- type RAssigned<C> = CtxOf<C>;
905
- type RFn<S, M extends {
906
- type: string;
907
- }, E, R> = (state: S, msg: Narrow<M, E>) => R;
908
- type RCell<C, X, S, M extends {
909
- type: string;
910
- }, E> = X extends {
911
- readonly when: string;
912
- } ? {
913
- readonly then: RFn<S, M, E, RAssigned<C>>;
914
- readonly else: RFn<S, M, E, RAssigned<C>>;
915
- } : RFn<S, M, E, RAssigned<C>>;
916
- /** One builder per DECLARATIVE event. Cell events own their whole transition. */
917
- type RAssigns<C, S, M extends {
918
- type: string;
919
- }> = {
920
- [E in Exclude<EventName<C>, RCellEvent<C>>]: RCell<C, REdgeAt<C, E>, S, M, E>;
921
- };
922
-
923
- export { type Assigns as A, type EndPolarity as B, type Chart as C, type GroupName as D, type EventName as E, type ForeignEvent as F, type GuardName as G, type GroupOf as H, type InitialData as I, type MissingPairs as J, type RStateName as K, type SubEvent as L, type MsgOf as M, type WorldRole as N, type OriginAt as O, type ParkingState as P, defineChart as Q, type ReducerChart as R, type StateOf as S, type Total as T, type UsedCmdName as U, defineReducerChart as V, type WorldEvent as W, ty as X, type CmdOf as a, type RStateOf as b, type StateName as c, type Strict as d, type CellEdgeKey as e, type InitialState as f, type Ty as g, type SuccessFinal as h, type ErrorFinal as i, type MsgIn as j, type EventOrigin as k, type Guards as l, type Cmds as m, type CellName as n, type Cells as o, type RAssigns as p, type RGuardName as q, type RGuards as r, type RUsedCmdName as s, type RCmds as t, type RCellName as u, type RCells as v, type CmdEvent as w, type CmdName as x, type EdgeKey as y, type EdgeSpec as z };