@logixjs/core 0.0.1 → 1.0.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 (398) hide show
  1. package/LICENSE +201 -0
  2. package/dist/{Action-mqVvtEHt.d.ts → Action-DYl88bwj.d.ts} +1 -1
  3. package/dist/{Action-BkRHy2vg.d.cts → Action-DkxsI_DK.d.cts} +1 -1
  4. package/dist/Action.cjs.map +1 -1
  5. package/dist/Action.d.cts +1 -1
  6. package/dist/Action.d.ts +1 -1
  7. package/dist/Action.js +2 -2
  8. package/dist/{Actions-AsQ07yTP.d.cts → Actions-Dicm7jdc.d.cts} +2 -2
  9. package/dist/{Actions-AsQ07yTP.d.ts → Actions-Dicm7jdc.d.ts} +2 -2
  10. package/dist/Actions.cjs.map +1 -1
  11. package/dist/Actions.d.cts +1 -1
  12. package/dist/Actions.d.ts +1 -1
  13. package/dist/Actions.js +1 -1
  14. package/dist/{Bound-BN1DQ_lM.d.ts → Bound-1OJLzVIS.d.ts} +2 -2
  15. package/dist/{Bound-BPIfH9SS.d.cts → Bound-BMLrtQ1V.d.cts} +2 -2
  16. package/dist/Bound.cjs +1737 -399
  17. package/dist/Bound.cjs.map +1 -1
  18. package/dist/Bound.d.cts +5 -5
  19. package/dist/Bound.d.ts +5 -5
  20. package/dist/Bound.js +19 -17
  21. package/dist/{Debug-B5q5Bkzx.d.ts → Debug-DKrWP5H1.d.ts} +40 -22
  22. package/dist/{Debug-Bq8Sqjcr.d.cts → Debug-hIT44XsY.d.cts} +40 -22
  23. package/dist/Debug.cjs +1348 -318
  24. package/dist/Debug.cjs.map +1 -1
  25. package/dist/Debug.d.cts +12 -11
  26. package/dist/Debug.d.ts +12 -11
  27. package/dist/Debug.js +20 -11
  28. package/dist/EffectOp.cjs +15 -6
  29. package/dist/EffectOp.cjs.map +1 -1
  30. package/dist/EffectOp.js +3 -3
  31. package/dist/Env.cjs +772 -6
  32. package/dist/Env.cjs.map +1 -1
  33. package/dist/Env.js +5 -2
  34. package/dist/ExternalStore-DqJKKRJ4.d.ts +61 -0
  35. package/dist/ExternalStore-JC-gAgEI.d.cts +61 -0
  36. package/dist/ExternalStore.cjs +774 -0
  37. package/dist/ExternalStore.cjs.map +1 -0
  38. package/dist/ExternalStore.d.cts +8 -0
  39. package/dist/ExternalStore.d.ts +8 -0
  40. package/dist/ExternalStore.js +19 -0
  41. package/dist/ExternalStore.js.map +1 -0
  42. package/dist/{Flow-BhpjE22E.d.ts → Flow-CZmXRDqp.d.cts} +13 -4
  43. package/dist/{Flow-1fZT8MpX.d.cts → Flow-DIVDxz7R.d.ts} +13 -4
  44. package/dist/Flow.cjs +765 -148
  45. package/dist/Flow.cjs.map +1 -1
  46. package/dist/Flow.d.cts +6 -6
  47. package/dist/Flow.d.ts +6 -6
  48. package/dist/Flow.js +9 -8
  49. package/dist/{Handle-D_cLW1Z3.d.ts → Handle-Bo6cAFut.d.ts} +1 -1
  50. package/dist/{Handle-D8D1zPb_.d.cts → Handle-CfDvSqN7.d.cts} +1 -1
  51. package/dist/Handle.d.cts +5 -5
  52. package/dist/Handle.d.ts +5 -5
  53. package/dist/{Kernel-8kC-jOda.d.cts → Kernel-CuXBF9S_.d.cts} +16 -7
  54. package/dist/{Kernel-CnGE1Fyk.d.ts → Kernel-D9guNwRL.d.ts} +16 -7
  55. package/dist/Kernel.cjs +814 -26
  56. package/dist/Kernel.cjs.map +1 -1
  57. package/dist/Kernel.d.cts +13 -12
  58. package/dist/Kernel.d.ts +13 -12
  59. package/dist/Kernel.js +7 -4
  60. package/dist/{Link-Db7975nU.d.ts → Link-CUM0yUCH.d.ts} +10 -3
  61. package/dist/{Link-fX8x1eCK.d.cts → Link-NAfR6uGD.d.cts} +10 -3
  62. package/dist/Link.cjs +1294 -121
  63. package/dist/Link.cjs.map +1 -1
  64. package/dist/Link.d.cts +5 -5
  65. package/dist/Link.d.ts +5 -5
  66. package/dist/Link.js +37 -29
  67. package/dist/{Logic-DRh4sDZj.d.cts → Logic-09VQpIj3.d.cts} +7 -4
  68. package/dist/{Logic-BRjEMr-W.d.ts → Logic-DKg7ghGy.d.ts} +7 -4
  69. package/dist/Logic.cjs +2 -1
  70. package/dist/Logic.cjs.map +1 -1
  71. package/dist/Logic.d.cts +5 -5
  72. package/dist/Logic.d.ts +5 -5
  73. package/dist/Logic.js +1 -1
  74. package/dist/{MatchBuilder-CJk5oCkR.d.cts → MatchBuilder-CsW5jgrL.d.ts} +1 -1
  75. package/dist/{MatchBuilder-0QOc-nlU.d.ts → MatchBuilder-Dksk07F4.d.cts} +1 -1
  76. package/dist/MatchBuilder.cjs +2 -2
  77. package/dist/MatchBuilder.cjs.map +1 -1
  78. package/dist/MatchBuilder.d.cts +6 -6
  79. package/dist/MatchBuilder.d.ts +6 -6
  80. package/dist/MatchBuilder.js +2 -2
  81. package/dist/Middleware-D8tUDLv_.d.cts +100 -0
  82. package/dist/Middleware-DS7CbTTN.d.ts +100 -0
  83. package/dist/Middleware.cjs +678 -58
  84. package/dist/Middleware.cjs.map +1 -1
  85. package/dist/Middleware.d.cts +2 -86
  86. package/dist/Middleware.d.ts +2 -86
  87. package/dist/Middleware.js +15 -12
  88. package/dist/{Module-DnzluX2J.d.ts → Module-B_Cntyms.d.ts} +54 -25
  89. package/dist/{Module-B_0xRDMR.d.cts → Module-CmNOVXzf.d.cts} +54 -25
  90. package/dist/Module.cjs +9331 -3317
  91. package/dist/Module.cjs.map +1 -1
  92. package/dist/Module.d.cts +7 -6
  93. package/dist/Module.d.ts +7 -6
  94. package/dist/Module.js +39 -31
  95. package/dist/ModuleTag-CGho_InD.d.ts +113 -0
  96. package/dist/ModuleTag-CITb8L_G.d.cts +113 -0
  97. package/dist/ModuleTag.cjs +7248 -2847
  98. package/dist/ModuleTag.cjs.map +1 -1
  99. package/dist/ModuleTag.d.cts +6 -6
  100. package/dist/ModuleTag.d.ts +6 -6
  101. package/dist/ModuleTag.js +35 -29
  102. package/dist/Observability-Bdhnx2Dv.d.ts +385 -0
  103. package/dist/Observability-DXGAFBIT.d.cts +385 -0
  104. package/dist/Observability.cjs +5093 -1556
  105. package/dist/Observability.cjs.map +1 -1
  106. package/dist/Observability.d.cts +6 -7
  107. package/dist/Observability.d.ts +6 -7
  108. package/dist/Observability.js +28 -23
  109. package/dist/{Platform-CHX8o-U4.d.ts → Platform-B4s8tg6C.d.cts} +4 -5
  110. package/dist/{Platform-C49Pv956.d.cts → Platform-BV_0MW7g.d.cts} +5 -2
  111. package/dist/{Platform-C49Pv956.d.ts → Platform-BV_0MW7g.d.ts} +5 -2
  112. package/dist/{Platform-CVlv0xLQ.d.cts → Platform-W0Mefy_e.d.ts} +4 -5
  113. package/dist/Platform.cjs +2 -1
  114. package/dist/Platform.cjs.map +1 -1
  115. package/dist/Platform.d.cts +2 -3
  116. package/dist/Platform.d.ts +2 -3
  117. package/dist/Platform.js +2 -2
  118. package/dist/{Process-CM9xbMdP.d.ts → Process-CO8G7HO9.d.cts} +30 -5
  119. package/dist/{Process-mL8fHDSB.d.cts → Process-Cyf6VNDR.d.ts} +30 -5
  120. package/dist/Process.cjs +1288 -120
  121. package/dist/Process.cjs.map +1 -1
  122. package/dist/Process.d.cts +6 -6
  123. package/dist/Process.d.ts +6 -6
  124. package/dist/Process.js +34 -26
  125. package/dist/ReadQuery-C_or5nLC.d.ts +128 -0
  126. package/dist/ReadQuery-DXLzCE0E.d.cts +614 -0
  127. package/dist/ReadQuery-DXLzCE0E.d.ts +614 -0
  128. package/dist/ReadQuery-Yve1lmUo.d.cts +128 -0
  129. package/dist/ReadQuery.cjs +290 -5
  130. package/dist/ReadQuery.cjs.map +1 -1
  131. package/dist/ReadQuery.d.cts +3 -2
  132. package/dist/ReadQuery.d.ts +3 -2
  133. package/dist/ReadQuery.js +23 -5
  134. package/dist/{Reflection-CQnKwPXj.d.ts → Reflection-B2Xi1e4Q.d.ts} +89 -7
  135. package/dist/{Reflection-Kabo1mlU.d.cts → Reflection-DNB4V4_e.d.cts} +89 -7
  136. package/dist/Reflection.cjs +3227 -1617
  137. package/dist/Reflection.cjs.map +1 -1
  138. package/dist/Reflection.d.cts +17 -15
  139. package/dist/Reflection.d.ts +17 -15
  140. package/dist/Reflection.js +33 -25
  141. package/dist/{Resource-Dy1xD_DG.d.cts → Resource-pKvQQ4x5.d.cts} +3 -3
  142. package/dist/{Resource-Dy1xD_DG.d.ts → Resource-pKvQQ4x5.d.ts} +3 -3
  143. package/dist/Resource.cjs +781 -15
  144. package/dist/Resource.cjs.map +1 -1
  145. package/dist/Resource.d.cts +1 -1
  146. package/dist/Resource.d.ts +1 -1
  147. package/dist/Resource.js +6 -3
  148. package/dist/{Root-7ADUMk4t.d.cts → Root-CCVuFHB6.d.cts} +3 -3
  149. package/dist/{Root-7ADUMk4t.d.ts → Root-CCVuFHB6.d.ts} +3 -3
  150. package/dist/Root.cjs +786 -20
  151. package/dist/Root.cjs.map +1 -1
  152. package/dist/Root.d.cts +2 -2
  153. package/dist/Root.d.ts +2 -2
  154. package/dist/Root.js +7 -3
  155. package/dist/{Runtime-CtyzZG4i.d.ts → Runtime-CRmvwK4I.d.ts} +70 -14
  156. package/dist/{Runtime-B-aL-f29.d.cts → Runtime-C_wJM9mN.d.cts} +70 -14
  157. package/dist/Runtime.cjs +4942 -1601
  158. package/dist/Runtime.cjs.map +1 -1
  159. package/dist/Runtime.d.cts +17 -15
  160. package/dist/Runtime.d.ts +17 -15
  161. package/dist/Runtime.js +44 -32
  162. package/dist/{ScopeRegistry-D1owDNSm.d.cts → ScopeRegistry-BhYzqWri.d.cts} +6 -6
  163. package/dist/{ScopeRegistry-D1owDNSm.d.ts → ScopeRegistry-BhYzqWri.d.ts} +6 -6
  164. package/dist/ScopeRegistry.cjs +776 -10
  165. package/dist/ScopeRegistry.cjs.map +1 -1
  166. package/dist/ScopeRegistry.d.cts +1 -1
  167. package/dist/ScopeRegistry.d.ts +1 -1
  168. package/dist/ScopeRegistry.js +6 -3
  169. package/dist/{State-CU50R26M.d.cts → State-rNFsFPTl.d.cts} +2 -2
  170. package/dist/{State-CU50R26M.d.ts → State-rNFsFPTl.d.ts} +2 -2
  171. package/dist/State.cjs.map +1 -1
  172. package/dist/State.d.cts +1 -1
  173. package/dist/State.d.ts +1 -1
  174. package/dist/State.js +1 -1
  175. package/dist/{StateTrait-BGsZghTz.d.ts → StateTrait-CijdwNb6.d.ts} +25 -8
  176. package/dist/{StateTrait-OWhbj12c.d.cts → StateTrait-Dltto6PU.d.cts} +25 -8
  177. package/dist/StateTrait.cjs +1890 -528
  178. package/dist/StateTrait.cjs.map +1 -1
  179. package/dist/StateTrait.d.cts +9 -7
  180. package/dist/StateTrait.d.ts +9 -7
  181. package/dist/StateTrait.js +18 -14
  182. package/dist/{TraitLifecycle-CwV5WPFX.d.cts → TraitLifecycle-BKzDqzLu.d.cts} +2 -2
  183. package/dist/{TraitLifecycle-LdIWmKlg.d.ts → TraitLifecycle-Cvo94uDB.d.ts} +2 -2
  184. package/dist/TraitLifecycle.cjs +630 -67
  185. package/dist/TraitLifecycle.cjs.map +1 -1
  186. package/dist/TraitLifecycle.d.cts +6 -6
  187. package/dist/TraitLifecycle.d.ts +6 -6
  188. package/dist/TraitLifecycle.js +8 -7
  189. package/dist/Workflow-C_OWr4dV.d.ts +415 -0
  190. package/dist/Workflow-DmydkHO8.d.cts +415 -0
  191. package/dist/Workflow.cjs +3150 -0
  192. package/dist/Workflow.cjs.map +1 -0
  193. package/dist/Workflow.d.cts +7 -0
  194. package/dist/Workflow.d.ts +7 -0
  195. package/dist/Workflow.js +58 -0
  196. package/dist/Workflow.js.map +1 -0
  197. package/dist/{action-DiMDD_0v.d.cts → action-BQxjPFEw.d.cts} +5 -5
  198. package/dist/{action-DiMDD_0v.d.ts → action-BQxjPFEw.d.ts} +5 -5
  199. package/dist/chunk-2XRLXDWR.js +276 -0
  200. package/dist/chunk-2XRLXDWR.js.map +1 -0
  201. package/dist/chunk-3L6QGFMM.js +701 -0
  202. package/dist/chunk-3L6QGFMM.js.map +1 -0
  203. package/dist/{chunk-GMPEOUP2.js → chunk-4MZ7BT3R.js} +2 -2
  204. package/dist/chunk-4MZ7BT3R.js.map +1 -0
  205. package/dist/{chunk-3IYZ5IGG.js → chunk-5WKUGEBY.js} +2 -2
  206. package/dist/{chunk-3RMKLXHX.js → chunk-63ZQ5RIN.js} +2 -2
  207. package/dist/{chunk-M3WTHJHJ.js → chunk-67DIEA53.js} +385 -148
  208. package/dist/chunk-67DIEA53.js.map +1 -0
  209. package/dist/{chunk-YS3AZQ2G.js → chunk-6HFAW2MH.js} +1 -1
  210. package/dist/chunk-6HFAW2MH.js.map +1 -0
  211. package/dist/{chunk-EY4NZKDR.js → chunk-6Y2TKCNY.js} +2 -2
  212. package/dist/{chunk-76WT3HOR.js → chunk-6YZOXFPQ.js} +25 -24
  213. package/dist/chunk-6YZOXFPQ.js.map +1 -0
  214. package/dist/{chunk-G5ZBFPNU.js → chunk-A2RQOJC7.js} +2 -2
  215. package/dist/{chunk-AUIR5O6W.js → chunk-AFSB6NKM.js} +13 -19
  216. package/dist/chunk-AFSB6NKM.js.map +1 -0
  217. package/dist/{chunk-JCXGZRMU.js → chunk-AO4JEOKD.js} +22 -23
  218. package/dist/chunk-AO4JEOKD.js.map +1 -0
  219. package/dist/{chunk-TAAPQVZN.js → chunk-AYELIQXR.js} +2 -2
  220. package/dist/{chunk-QMM6O4CD.js → chunk-BLHZW7DG.js} +15 -3
  221. package/dist/{chunk-QMM6O4CD.js.map → chunk-BLHZW7DG.js.map} +1 -1
  222. package/dist/{chunk-TQOBJYDP.js → chunk-CD4N74YC.js} +1 -1
  223. package/dist/chunk-CD4N74YC.js.map +1 -0
  224. package/dist/{chunk-ANLBCBDC.js → chunk-CGE2HBTH.js} +11 -11
  225. package/dist/chunk-CGE2HBTH.js.map +1 -0
  226. package/dist/{chunk-OFADUJWJ.js → chunk-CYYSQMLO.js} +5 -5
  227. package/dist/chunk-CYYSQMLO.js.map +1 -0
  228. package/dist/{chunk-66ALHVEX.js → chunk-EB46EYI7.js} +3 -3
  229. package/dist/{chunk-NZJKFF45.js → chunk-EKCDHWRK.js} +4 -4
  230. package/dist/chunk-EKCDHWRK.js.map +1 -0
  231. package/dist/{chunk-BABLDP24.js → chunk-EPQFNJU3.js} +152 -7
  232. package/dist/chunk-EPQFNJU3.js.map +1 -0
  233. package/dist/{chunk-OGWBVHB3.js → chunk-ESR6HGOY.js} +73 -14
  234. package/dist/chunk-ESR6HGOY.js.map +1 -0
  235. package/dist/{chunk-NBD3KUOZ.js → chunk-F6RP62H3.js} +150 -98
  236. package/dist/chunk-F6RP62H3.js.map +1 -0
  237. package/dist/chunk-FBYW3QDI.js +252 -0
  238. package/dist/chunk-FBYW3QDI.js.map +1 -0
  239. package/dist/{chunk-IPF7E66P.js → chunk-FYAODKVP.js} +2 -2
  240. package/dist/chunk-GNEN7NKO.js +908 -0
  241. package/dist/chunk-GNEN7NKO.js.map +1 -0
  242. package/dist/chunk-GWSM4KLB.js +763 -0
  243. package/dist/chunk-GWSM4KLB.js.map +1 -0
  244. package/dist/{chunk-4SO6JMZL.js → chunk-HDMXCUZL.js} +1 -1
  245. package/dist/chunk-HDMXCUZL.js.map +1 -0
  246. package/dist/{chunk-ZFY7U2FR.js → chunk-HJM5Y5NU.js} +43 -3
  247. package/dist/chunk-HJM5Y5NU.js.map +1 -0
  248. package/dist/{chunk-ZGDVUPTM.js → chunk-IOZ3VKPK.js} +129 -68
  249. package/dist/chunk-IOZ3VKPK.js.map +1 -0
  250. package/dist/{chunk-PYOE4VSI.js → chunk-IVXSVHO4.js} +303 -247
  251. package/dist/chunk-IVXSVHO4.js.map +1 -0
  252. package/dist/chunk-J3CWXIPV.js +242 -0
  253. package/dist/chunk-J3CWXIPV.js.map +1 -0
  254. package/dist/chunk-K6JQW266.js +42 -0
  255. package/dist/chunk-K6JQW266.js.map +1 -0
  256. package/dist/chunk-KMZYQF6Q.js +202 -0
  257. package/dist/chunk-KMZYQF6Q.js.map +1 -0
  258. package/dist/{chunk-JWOYLO27.js → chunk-LPPZDFTD.js} +22 -12
  259. package/dist/chunk-LPPZDFTD.js.map +1 -0
  260. package/dist/{chunk-PAYXCY6A.js → chunk-MYB2B5WX.js} +997 -576
  261. package/dist/chunk-MYB2B5WX.js.map +1 -0
  262. package/dist/chunk-MYKNINNN.js +228 -0
  263. package/dist/chunk-MYKNINNN.js.map +1 -0
  264. package/dist/chunk-NSQIRMVF.js +27 -0
  265. package/dist/{chunk-QCHIQWAJ.js.map → chunk-NSQIRMVF.js.map} +1 -1
  266. package/dist/chunk-NUDBM4MM.js +30 -0
  267. package/dist/chunk-NUDBM4MM.js.map +1 -0
  268. package/dist/chunk-NZMWWDAY.js +23 -0
  269. package/dist/chunk-NZMWWDAY.js.map +1 -0
  270. package/dist/{chunk-RNFE3ML2.js → chunk-OCUV2Y25.js} +4 -3
  271. package/dist/chunk-OCUV2Y25.js.map +1 -0
  272. package/dist/chunk-P4ZJOQA7.js +271 -0
  273. package/dist/chunk-P4ZJOQA7.js.map +1 -0
  274. package/dist/chunk-P6C5EZ3D.js +342 -0
  275. package/dist/chunk-P6C5EZ3D.js.map +1 -0
  276. package/dist/{chunk-CW6T36TN.js → chunk-PBD7BJUN.js} +62 -4
  277. package/dist/chunk-PBD7BJUN.js.map +1 -0
  278. package/dist/chunk-PBIUCQY3.js +696 -0
  279. package/dist/chunk-PBIUCQY3.js.map +1 -0
  280. package/dist/chunk-PD6YECQH.js +845 -0
  281. package/dist/chunk-PD6YECQH.js.map +1 -0
  282. package/dist/{chunk-M7IYCTJV.js → chunk-R4LFQGP3.js} +2 -2
  283. package/dist/chunk-RHJIGDUE.js +21 -0
  284. package/dist/chunk-RHJIGDUE.js.map +1 -0
  285. package/dist/{chunk-KP7MUZNX.js → chunk-RLXO27MW.js} +30 -8
  286. package/dist/chunk-RLXO27MW.js.map +1 -0
  287. package/dist/{chunk-DFNM3WX2.js → chunk-S44BEV4B.js} +168 -45
  288. package/dist/chunk-S44BEV4B.js.map +1 -0
  289. package/dist/chunk-S4S5N4BJ.js +1461 -0
  290. package/dist/chunk-S4S5N4BJ.js.map +1 -0
  291. package/dist/{chunk-BZ2SHDN2.js → chunk-SGTRAXXX.js} +3 -3
  292. package/dist/chunk-SGTRAXXX.js.map +1 -0
  293. package/dist/{chunk-M2RGJPXX.js → chunk-SJAE5PB5.js} +3 -3
  294. package/dist/{chunk-JGIWG6SR.js → chunk-SNPNHU3H.js} +3937 -1776
  295. package/dist/chunk-SNPNHU3H.js.map +1 -0
  296. package/dist/{chunk-IHVBV5C2.js → chunk-SOOBFXRR.js} +94 -71
  297. package/dist/chunk-SOOBFXRR.js.map +1 -0
  298. package/dist/{chunk-ZDTRWK5F.js → chunk-TAHFWKS6.js} +2 -2
  299. package/dist/chunk-UEFFTVPY.js +9 -0
  300. package/dist/chunk-UEFFTVPY.js.map +1 -0
  301. package/dist/{chunk-24VULZ7A.js → chunk-UR5BXLBP.js} +3 -3
  302. package/dist/chunk-UR5BXLBP.js.map +1 -0
  303. package/dist/{chunk-DMBALCE2.js → chunk-V2SBGVDO.js} +471 -186
  304. package/dist/chunk-V2SBGVDO.js.map +1 -0
  305. package/dist/chunk-VJLWD47W.js +23 -0
  306. package/dist/chunk-VJLWD47W.js.map +1 -0
  307. package/dist/{chunk-4CQAV7YB.js → chunk-W647DX5Z.js} +2 -2
  308. package/dist/{chunk-THATMZXD.js → chunk-WFIIU3YZ.js} +2 -2
  309. package/dist/{chunk-THATMZXD.js.map → chunk-WFIIU3YZ.js.map} +1 -1
  310. package/dist/chunk-YZDJMAKL.js +82 -0
  311. package/dist/chunk-YZDJMAKL.js.map +1 -0
  312. package/dist/{chunk-3TMODYZV.js → chunk-Z5XH6VHY.js} +5 -5
  313. package/dist/chunk-Z5XH6VHY.js.map +1 -0
  314. package/dist/{chunk-BE3HW4FY.js → chunk-ZBBMZMA6.js} +377 -170
  315. package/dist/chunk-ZBBMZMA6.js.map +1 -0
  316. package/dist/index.cjs +21224 -11714
  317. package/dist/index.cjs.map +1 -1
  318. package/dist/index.d.cts +195 -49
  319. package/dist/index.d.ts +195 -49
  320. package/dist/index.js +150 -74
  321. package/dist/index.js.map +1 -1
  322. package/dist/{ir-BMP7yxJJ.d.cts → ir-BSosEwc8.d.cts} +1 -1
  323. package/dist/{ir-DUOz6H-5.d.ts → ir-D-uqwL_4.d.ts} +1 -1
  324. package/dist/{module-B8CBqIZ_.d.cts → module-Ds4tarcI.d.cts} +230 -140
  325. package/dist/{module-k7m3txak.d.ts → module-Zd1Gn-Nj.d.ts} +230 -140
  326. package/package.json +20 -4
  327. package/dist/ModuleTag-C8FHY_sY.d.ts +0 -93
  328. package/dist/ModuleTag-EGbgBMpZ.d.cts +0 -93
  329. package/dist/Observability-COqEvp2C.d.cts +0 -713
  330. package/dist/Observability-cY4kLn0S.d.ts +0 -713
  331. package/dist/ReadQuery-BlMwhe-F.d.ts +0 -30
  332. package/dist/ReadQuery-CL5XlXts.d.cts +0 -30
  333. package/dist/ReadQuery-SinbStGF.d.cts +0 -38
  334. package/dist/ReadQuery-SinbStGF.d.ts +0 -38
  335. package/dist/chunk-24VULZ7A.js.map +0 -1
  336. package/dist/chunk-3QMIVH35.js +0 -43
  337. package/dist/chunk-3QMIVH35.js.map +0 -1
  338. package/dist/chunk-3TMODYZV.js.map +0 -1
  339. package/dist/chunk-4SO6JMZL.js.map +0 -1
  340. package/dist/chunk-76WT3HOR.js.map +0 -1
  341. package/dist/chunk-ANLBCBDC.js.map +0 -1
  342. package/dist/chunk-AUIR5O6W.js.map +0 -1
  343. package/dist/chunk-BABLDP24.js.map +0 -1
  344. package/dist/chunk-BE3HW4FY.js.map +0 -1
  345. package/dist/chunk-BZ2SHDN2.js.map +0 -1
  346. package/dist/chunk-CW6T36TN.js.map +0 -1
  347. package/dist/chunk-DFNM3WX2.js.map +0 -1
  348. package/dist/chunk-DMBALCE2.js.map +0 -1
  349. package/dist/chunk-EGK3KN7B.js +0 -406
  350. package/dist/chunk-EGK3KN7B.js.map +0 -1
  351. package/dist/chunk-GMPEOUP2.js.map +0 -1
  352. package/dist/chunk-IHVBV5C2.js.map +0 -1
  353. package/dist/chunk-JCXGZRMU.js.map +0 -1
  354. package/dist/chunk-JGIWG6SR.js.map +0 -1
  355. package/dist/chunk-JWOYLO27.js.map +0 -1
  356. package/dist/chunk-KIXAU3GM.js +0 -137
  357. package/dist/chunk-KIXAU3GM.js.map +0 -1
  358. package/dist/chunk-KL5ACTCT.js +0 -8
  359. package/dist/chunk-KL5ACTCT.js.map +0 -1
  360. package/dist/chunk-KP7MUZNX.js.map +0 -1
  361. package/dist/chunk-M3BFQ7HK.js +0 -13
  362. package/dist/chunk-M3BFQ7HK.js.map +0 -1
  363. package/dist/chunk-M3WTHJHJ.js.map +0 -1
  364. package/dist/chunk-NBD3KUOZ.js.map +0 -1
  365. package/dist/chunk-NQZ2OSGR.js +0 -151
  366. package/dist/chunk-NQZ2OSGR.js.map +0 -1
  367. package/dist/chunk-NZJKFF45.js.map +0 -1
  368. package/dist/chunk-OFADUJWJ.js.map +0 -1
  369. package/dist/chunk-OGWBVHB3.js.map +0 -1
  370. package/dist/chunk-PAYXCY6A.js.map +0 -1
  371. package/dist/chunk-PYOE4VSI.js.map +0 -1
  372. package/dist/chunk-QCHIQWAJ.js +0 -21
  373. package/dist/chunk-RNFE3ML2.js.map +0 -1
  374. package/dist/chunk-TKZ7MEIA.js +0 -27
  375. package/dist/chunk-TKZ7MEIA.js.map +0 -1
  376. package/dist/chunk-TQOBJYDP.js.map +0 -1
  377. package/dist/chunk-VZB726PE.js +0 -93
  378. package/dist/chunk-VZB726PE.js.map +0 -1
  379. package/dist/chunk-W3TEWHLO.js +0 -568
  380. package/dist/chunk-W3TEWHLO.js.map +0 -1
  381. package/dist/chunk-YS3AZQ2G.js.map +0 -1
  382. package/dist/chunk-ZFLHVFUC.js +0 -192
  383. package/dist/chunk-ZFLHVFUC.js.map +0 -1
  384. package/dist/chunk-ZFY7U2FR.js.map +0 -1
  385. package/dist/chunk-ZGDVUPTM.js.map +0 -1
  386. package/dist/protocol-g_1897M2.d.cts +0 -127
  387. package/dist/protocol-g_1897M2.d.ts +0 -127
  388. /package/dist/{chunk-3IYZ5IGG.js.map → chunk-5WKUGEBY.js.map} +0 -0
  389. /package/dist/{chunk-3RMKLXHX.js.map → chunk-63ZQ5RIN.js.map} +0 -0
  390. /package/dist/{chunk-EY4NZKDR.js.map → chunk-6Y2TKCNY.js.map} +0 -0
  391. /package/dist/{chunk-G5ZBFPNU.js.map → chunk-A2RQOJC7.js.map} +0 -0
  392. /package/dist/{chunk-TAAPQVZN.js.map → chunk-AYELIQXR.js.map} +0 -0
  393. /package/dist/{chunk-66ALHVEX.js.map → chunk-EB46EYI7.js.map} +0 -0
  394. /package/dist/{chunk-IPF7E66P.js.map → chunk-FYAODKVP.js.map} +0 -0
  395. /package/dist/{chunk-M7IYCTJV.js.map → chunk-R4LFQGP3.js.map} +0 -0
  396. /package/dist/{chunk-M2RGJPXX.js.map → chunk-SJAE5PB5.js.map} +0 -0
  397. /package/dist/{chunk-ZDTRWK5F.js.map → chunk-TAHFWKS6.js.map} +0 -0
  398. /package/dist/{chunk-4CQAV7YB.js.map → chunk-W647DX5Z.js.map} +0 -0
@@ -0,0 +1,1461 @@
1
+ import {
2
+ getGlobalHostScheduler
3
+ } from "./chunk-MYKNINNN.js";
4
+ import {
5
+ currentDiagnosticsLevel,
6
+ currentTraceMode,
7
+ record,
8
+ runByMode
9
+ } from "./chunk-V2SBGVDO.js";
10
+
11
+ // src/internal/runtime/core/TickScheduler.ts
12
+ import { Effect as Effect4 } from "effect";
13
+
14
+ // src/internal/runtime/core/JobQueue.ts
15
+ var maxPriority = (a, b) => a === "normal" || b === "normal" ? "normal" : "low";
16
+ var makeJobQueue = () => {
17
+ let pendingModules = /* @__PURE__ */ new Map();
18
+ let pendingDirtyTopics = /* @__PURE__ */ new Map();
19
+ const hasPending = () => pendingModules.size > 0 || pendingDirtyTopics.size > 0;
20
+ const enqueueModuleCommit = (commit) => {
21
+ const prev = pendingModules.get(commit.moduleInstanceKey);
22
+ if (!prev) {
23
+ pendingModules.set(commit.moduleInstanceKey, commit);
24
+ return false;
25
+ }
26
+ pendingModules.set(commit.moduleInstanceKey, {
27
+ ...commit,
28
+ meta: {
29
+ ...commit.meta,
30
+ priority: maxPriority(prev.meta.priority, commit.meta.priority)
31
+ }
32
+ });
33
+ return true;
34
+ };
35
+ const markTopicDirty = (topicKey, priority) => {
36
+ const prev = pendingDirtyTopics.get(topicKey);
37
+ pendingDirtyTopics.set(topicKey, prev ? maxPriority(prev, priority) : priority);
38
+ return prev != null;
39
+ };
40
+ const drain = () => {
41
+ if (!hasPending()) return void 0;
42
+ const drained = {
43
+ modules: pendingModules,
44
+ dirtyTopics: pendingDirtyTopics
45
+ };
46
+ pendingModules = /* @__PURE__ */ new Map();
47
+ pendingDirtyTopics = /* @__PURE__ */ new Map();
48
+ return drained;
49
+ };
50
+ const requeue = (drain2) => {
51
+ for (const [, commit] of drain2.modules) {
52
+ enqueueModuleCommit(commit);
53
+ }
54
+ for (const [k, p] of drain2.dirtyTopics) {
55
+ markTopicDirty(k, p);
56
+ }
57
+ };
58
+ return {
59
+ hasPending,
60
+ enqueueModuleCommit,
61
+ markTopicDirty,
62
+ drain,
63
+ requeue
64
+ };
65
+ };
66
+
67
+ // src/internal/runtime/core/TaskRunner.ts
68
+ import { Cause, Effect as Effect3, ServiceMap as ServiceMap2 } from "effect";
69
+
70
+ // src/internal/runtime/core/env.ts
71
+ import { Effect as Effect2, Layer, ServiceMap } from "effect";
72
+
73
+ // src/internal/runtime/core/RuntimeStore.ts
74
+ var makeModuleInstanceKey = (moduleId, instanceId) => `${moduleId}::${instanceId}`;
75
+ var makeReadQueryTopicKey = (moduleInstanceKey, selectorId) => `${moduleInstanceKey}::rq:${selectorId}`;
76
+ var parseTopicKey = (topicKey) => {
77
+ const idx = topicKey.indexOf("::");
78
+ if (idx <= 0) return void 0;
79
+ const moduleId = topicKey.slice(0, idx);
80
+ const rest = topicKey.slice(idx + 2);
81
+ if (rest.length === 0) return void 0;
82
+ const idx2 = rest.indexOf("::");
83
+ if (idx2 < 0) {
84
+ return { kind: "module", moduleInstanceKey: `${moduleId}::${rest}` };
85
+ }
86
+ const instanceId = rest.slice(0, idx2);
87
+ const suffix = rest.slice(idx2 + 2);
88
+ if (suffix.startsWith("rq:")) {
89
+ const selectorId = suffix.slice("rq:".length);
90
+ if (selectorId.length === 0) return void 0;
91
+ return {
92
+ kind: "readQuery",
93
+ moduleInstanceKey: `${moduleId}::${instanceId}`,
94
+ selectorId
95
+ };
96
+ }
97
+ return { kind: "module", moduleInstanceKey: `${moduleId}::${instanceId}` };
98
+ };
99
+ var EMPTY_LISTENER_SNAPSHOT = [];
100
+ var NO_CHANGED_TOPIC_LISTENERS = [];
101
+ var makeRuntimeStore = () => {
102
+ let tickSeq = 0;
103
+ const moduleStates = /* @__PURE__ */ new Map();
104
+ const topicVersions = /* @__PURE__ */ new Map();
105
+ const topicPriorities = /* @__PURE__ */ new Map();
106
+ const listenersByTopic = /* @__PURE__ */ new Map();
107
+ const subscriberCountByModule = /* @__PURE__ */ new Map();
108
+ const getTopicVersion = (topicKey) => topicVersions.get(topicKey) ?? 0;
109
+ const getTopicPriority = (topicKey) => topicPriorities.get(topicKey) ?? "normal";
110
+ const commitTopicBump = (topicKey, priority) => {
111
+ const prev = topicVersions.get(topicKey) ?? 0;
112
+ topicVersions.set(topicKey, prev + 1);
113
+ topicPriorities.set(topicKey, priority);
114
+ };
115
+ const refreshTopicSnapshot = (state) => {
116
+ state.snapshot = Array.from(state.listeners);
117
+ };
118
+ const subscribeTopic = (topicKey, listener) => {
119
+ const info = parseTopicKey(topicKey);
120
+ const existing = listenersByTopic.get(topicKey);
121
+ const state = existing ?? { listeners: /* @__PURE__ */ new Set(), snapshot: EMPTY_LISTENER_SNAPSHOT };
122
+ const alreadyHas = state.listeners.has(listener);
123
+ if (!alreadyHas) {
124
+ state.listeners.add(listener);
125
+ refreshTopicSnapshot(state);
126
+ }
127
+ if (!existing) {
128
+ listenersByTopic.set(topicKey, state);
129
+ }
130
+ if (!alreadyHas && info) {
131
+ const prev = subscriberCountByModule.get(info.moduleInstanceKey) ?? 0;
132
+ subscriberCountByModule.set(info.moduleInstanceKey, prev + 1);
133
+ }
134
+ return () => {
135
+ const currentState = listenersByTopic.get(topicKey);
136
+ if (!currentState) return;
137
+ const deleted = currentState.listeners.delete(listener);
138
+ if (deleted && info) {
139
+ const prev = subscriberCountByModule.get(info.moduleInstanceKey) ?? 0;
140
+ const next = prev - 1;
141
+ if (next <= 0) {
142
+ subscriberCountByModule.delete(info.moduleInstanceKey);
143
+ } else {
144
+ subscriberCountByModule.set(info.moduleInstanceKey, next);
145
+ }
146
+ }
147
+ if (currentState.listeners.size === 0) {
148
+ listenersByTopic.delete(topicKey);
149
+ } else if (deleted) {
150
+ refreshTopicSnapshot(currentState);
151
+ }
152
+ };
153
+ };
154
+ const getTopicSubscriberCount = (topicKey) => listenersByTopic.get(topicKey)?.listeners.size ?? 0;
155
+ const getModuleSubscriberCount = (moduleInstanceKey) => subscriberCountByModule.get(moduleInstanceKey) ?? 0;
156
+ const registerModuleInstance = (args) => {
157
+ moduleStates.set(args.moduleInstanceKey, args.initialState);
158
+ if (!topicVersions.has(args.moduleInstanceKey)) {
159
+ topicVersions.set(args.moduleInstanceKey, 0);
160
+ topicPriorities.set(args.moduleInstanceKey, "normal");
161
+ }
162
+ };
163
+ const unregisterModuleInstance = (moduleInstanceKey) => {
164
+ moduleStates.delete(moduleInstanceKey);
165
+ };
166
+ const commitTick = (args) => {
167
+ tickSeq = args.tickSeq;
168
+ for (const [key, commit] of args.accepted.modules) {
169
+ moduleStates.set(key, commit.state);
170
+ }
171
+ if (args.accepted.dirtyTopics.size === 0) {
172
+ return {
173
+ changedTopicListeners: NO_CHANGED_TOPIC_LISTENERS
174
+ };
175
+ }
176
+ if (args.onListener) {
177
+ let firstTopicListeners;
178
+ let secondTopicListeners;
179
+ let restTopicListeners;
180
+ for (const [topicKey, priority] of args.accepted.dirtyTopics) {
181
+ commitTopicBump(topicKey, priority);
182
+ const listeners = listenersByTopic.get(topicKey)?.snapshot ?? EMPTY_LISTENER_SNAPSHOT;
183
+ if (listeners.length === 0) {
184
+ continue;
185
+ }
186
+ if (!firstTopicListeners) {
187
+ firstTopicListeners = listeners;
188
+ continue;
189
+ }
190
+ if (!secondTopicListeners) {
191
+ secondTopicListeners = listeners;
192
+ continue;
193
+ }
194
+ if (!restTopicListeners) {
195
+ restTopicListeners = [];
196
+ }
197
+ restTopicListeners.push(listeners);
198
+ }
199
+ if (firstTopicListeners) {
200
+ for (const listener of firstTopicListeners) {
201
+ try {
202
+ args.onListener(listener);
203
+ } catch {
204
+ }
205
+ }
206
+ }
207
+ if (secondTopicListeners) {
208
+ for (const listener of secondTopicListeners) {
209
+ try {
210
+ args.onListener(listener);
211
+ } catch {
212
+ }
213
+ }
214
+ }
215
+ if (restTopicListeners) {
216
+ for (const listeners of restTopicListeners) {
217
+ for (const listener of listeners) {
218
+ try {
219
+ args.onListener(listener);
220
+ } catch {
221
+ }
222
+ }
223
+ }
224
+ }
225
+ return {
226
+ changedTopicListeners: NO_CHANGED_TOPIC_LISTENERS
227
+ };
228
+ }
229
+ let singleTopicListeners;
230
+ let flattenedTopicListeners;
231
+ for (const [topicKey, priority] of args.accepted.dirtyTopics) {
232
+ commitTopicBump(topicKey, priority);
233
+ const listeners = listenersByTopic.get(topicKey)?.snapshot ?? EMPTY_LISTENER_SNAPSHOT;
234
+ if (listeners.length === 0) {
235
+ continue;
236
+ }
237
+ if (flattenedTopicListeners) {
238
+ for (const listener of listeners) {
239
+ flattenedTopicListeners.push(listener);
240
+ }
241
+ continue;
242
+ }
243
+ if (!singleTopicListeners) {
244
+ singleTopicListeners = listeners;
245
+ continue;
246
+ }
247
+ flattenedTopicListeners = Array.from(singleTopicListeners);
248
+ for (const listener of listeners) {
249
+ flattenedTopicListeners.push(listener);
250
+ }
251
+ }
252
+ return {
253
+ changedTopicListeners: flattenedTopicListeners ?? singleTopicListeners ?? NO_CHANGED_TOPIC_LISTENERS
254
+ };
255
+ };
256
+ const getModuleState = (moduleInstanceKey) => moduleStates.get(moduleInstanceKey);
257
+ const dispose = () => {
258
+ moduleStates.clear();
259
+ topicVersions.clear();
260
+ topicPriorities.clear();
261
+ listenersByTopic.clear();
262
+ subscriberCountByModule.clear();
263
+ };
264
+ return {
265
+ getTickSeq: () => tickSeq,
266
+ getModuleState,
267
+ getTopicVersion,
268
+ getTopicPriority,
269
+ subscribeTopic,
270
+ getTopicSubscriberCount,
271
+ getModuleSubscriberCount,
272
+ registerModuleInstance,
273
+ unregisterModuleInstance,
274
+ commitTick,
275
+ dispose
276
+ };
277
+ };
278
+
279
+ // src/internal/runtime/core/DeclarativeLinkRuntime.ts
280
+ import { Effect } from "effect";
281
+ var makeDeclarativeLinkRuntime = () => {
282
+ const moduleAsSourceById = /* @__PURE__ */ new Map();
283
+ const moduleAsSourceIdsBySource = /* @__PURE__ */ new Map();
284
+ const declarativeById = /* @__PURE__ */ new Map();
285
+ const declarativeReadNodesBySource = /* @__PURE__ */ new Map();
286
+ const registerModuleAsSourceLink = (link) => {
287
+ const stored = {
288
+ ...link,
289
+ hasValue: false,
290
+ lastValue: void 0
291
+ };
292
+ moduleAsSourceById.set(link.id, stored);
293
+ const set = moduleAsSourceIdsBySource.get(link.sourceModuleInstanceKey) ?? /* @__PURE__ */ new Set();
294
+ set.add(link.id);
295
+ moduleAsSourceIdsBySource.set(link.sourceModuleInstanceKey, set);
296
+ return () => {
297
+ moduleAsSourceById.delete(link.id);
298
+ const current = moduleAsSourceIdsBySource.get(link.sourceModuleInstanceKey);
299
+ if (!current) return;
300
+ current.delete(link.id);
301
+ if (current.size === 0) {
302
+ moduleAsSourceIdsBySource.delete(link.sourceModuleInstanceKey);
303
+ }
304
+ };
305
+ };
306
+ const registerDeclarativeLink = (link) => {
307
+ const readNodeById = /* @__PURE__ */ new Map();
308
+ for (const n of link.readNodes) {
309
+ readNodeById.set(n.nodeId, n);
310
+ }
311
+ const dispatchNodeById = /* @__PURE__ */ new Map();
312
+ for (const n of link.dispatchNodes) {
313
+ dispatchNodeById.set(n.nodeId, n);
314
+ }
315
+ const incomingByDispatch = /* @__PURE__ */ new Map();
316
+ for (const e of link.ir.edges) {
317
+ const to = e.to;
318
+ const isDispatch = dispatchNodeById.has(to);
319
+ if (!isDispatch) continue;
320
+ incomingByDispatch.set(to, (incomingByDispatch.get(to) ?? 0) + 1);
321
+ const count = incomingByDispatch.get(to) ?? 0;
322
+ if (count > 1) {
323
+ throw new Error(
324
+ `[DeclarativeLinkRuntime] Invalid DeclarativeLinkIR: dispatch node has multiple incoming edges (linkId=${link.linkId}, nodeId=${to}).`
325
+ );
326
+ }
327
+ }
328
+ const dispatchTargetsByReadNode = /* @__PURE__ */ new Map();
329
+ for (const e of link.ir.edges) {
330
+ const from = e.from;
331
+ const to = e.to;
332
+ if (!readNodeById.has(from)) continue;
333
+ if (!dispatchNodeById.has(to)) continue;
334
+ const list = dispatchTargetsByReadNode.get(from) ?? [];
335
+ list.push(to);
336
+ dispatchTargetsByReadNode.set(from, list);
337
+ }
338
+ const stored = {
339
+ ...link,
340
+ readNodeById,
341
+ dispatchNodeById,
342
+ dispatchTargetsByReadNode,
343
+ readNodeState: /* @__PURE__ */ new Map()
344
+ };
345
+ declarativeById.set(link.linkId, stored);
346
+ for (const n of link.readNodes) {
347
+ const list = declarativeReadNodesBySource.get(n.moduleInstanceKey) ?? [];
348
+ list.push({ linkId: link.linkId, nodeId: n.nodeId });
349
+ declarativeReadNodesBySource.set(n.moduleInstanceKey, list);
350
+ }
351
+ return () => {
352
+ declarativeById.delete(link.linkId);
353
+ for (const n of link.readNodes) {
354
+ const list = declarativeReadNodesBySource.get(n.moduleInstanceKey);
355
+ if (!list) continue;
356
+ const next = list.filter((x) => !(x.linkId === link.linkId && x.nodeId === n.nodeId));
357
+ if (next.length === 0) {
358
+ declarativeReadNodesBySource.delete(n.moduleInstanceKey);
359
+ } else {
360
+ declarativeReadNodesBySource.set(n.moduleInstanceKey, next);
361
+ }
362
+ }
363
+ };
364
+ };
365
+ const applyForSources = (args) => Effect.gen(function* () {
366
+ let scheduled = false;
367
+ for (const sourceKey of args.changedModuleInstanceKeys) {
368
+ const ids = moduleAsSourceIdsBySource.get(sourceKey);
369
+ if (!ids || ids.size === 0) continue;
370
+ const commit = args.acceptedModules.get(sourceKey);
371
+ if (!commit) continue;
372
+ for (const id of ids) {
373
+ const link = moduleAsSourceById.get(id);
374
+ if (!link) continue;
375
+ let selected;
376
+ try {
377
+ selected = link.readQuery.select(commit.state);
378
+ } catch {
379
+ continue;
380
+ }
381
+ const nextValue = link.computeValue(selected);
382
+ if (link.hasValue && link.equalsValue(link.lastValue, nextValue)) {
383
+ continue;
384
+ }
385
+ link.hasValue = true;
386
+ link.lastValue = nextValue;
387
+ scheduled = true;
388
+ yield* link.applyValue(nextValue);
389
+ }
390
+ }
391
+ for (const sourceKey of args.changedModuleInstanceKeys) {
392
+ const refs = declarativeReadNodesBySource.get(sourceKey);
393
+ if (!refs || refs.length === 0) continue;
394
+ const commit = args.acceptedModules.get(sourceKey);
395
+ if (!commit) continue;
396
+ for (const ref of refs) {
397
+ const link = declarativeById.get(ref.linkId);
398
+ if (!link) continue;
399
+ const readNode = link.readNodeById.get(ref.nodeId);
400
+ if (!readNode) continue;
401
+ let value;
402
+ try {
403
+ value = readNode.readQuery.select(commit.state);
404
+ } catch {
405
+ continue;
406
+ }
407
+ const state = link.readNodeState.get(ref.nodeId) ?? { hasValue: false, lastValue: void 0 };
408
+ const changed = !state.hasValue || !Object.is(state.lastValue, value);
409
+ if (!changed) continue;
410
+ state.hasValue = true;
411
+ state.lastValue = value;
412
+ link.readNodeState.set(ref.nodeId, state);
413
+ const targets = link.dispatchTargetsByReadNode.get(ref.nodeId) ?? [];
414
+ for (const dispatchNodeId of targets) {
415
+ const node = link.dispatchNodeById.get(dispatchNodeId);
416
+ if (!node) continue;
417
+ scheduled = true;
418
+ yield* node.dispatch(value);
419
+ }
420
+ }
421
+ }
422
+ return { scheduled };
423
+ });
424
+ return {
425
+ registerModuleAsSourceLink,
426
+ registerDeclarativeLink,
427
+ applyForSources
428
+ };
429
+ };
430
+
431
+ // src/internal/runtime/core/env.ts
432
+ var getNodeEnv = () => {
433
+ try {
434
+ const env = globalThis?.process?.env;
435
+ return typeof env?.NODE_ENV === "string" ? env.NODE_ENV : void 0;
436
+ } catch {
437
+ return void 0;
438
+ }
439
+ };
440
+ var isDevEnv = () => getNodeEnv() !== "production";
441
+ var getDefaultStateTxnInstrumentation = () => isDevEnv() ? "full" : "light";
442
+ var StateTransactionConfigTagImpl = class extends ServiceMap.Service()("@logixjs/core/StateTransactionRuntimeConfig") {
443
+ };
444
+ var StateTransactionConfigTag = StateTransactionConfigTagImpl;
445
+ var ReadQueryStrictGateConfigTagImpl = class extends ServiceMap.Service()("@logixjs/core/ReadQueryStrictGateRuntimeConfig") {
446
+ };
447
+ var ReadQueryStrictGateConfigTag = ReadQueryStrictGateConfigTagImpl;
448
+ var ReplayModeConfigTagImpl = class extends ServiceMap.Service()("@logixjs/core/ReplayModeConfig") {
449
+ };
450
+ var ReplayModeConfigTag = ReplayModeConfigTagImpl;
451
+ var StateTransactionOverridesTagImpl = class extends ServiceMap.Service()("@logixjs/core/StateTransactionOverrides") {
452
+ };
453
+ var StateTransactionOverridesTag = StateTransactionOverridesTagImpl;
454
+ var SchedulingPolicySurfaceTagImpl = class extends ServiceMap.Service()("@logixjs/core/SchedulingPolicySurface") {
455
+ };
456
+ var SchedulingPolicySurfaceTag = SchedulingPolicySurfaceTagImpl;
457
+ var SchedulingPolicySurfaceOverridesTagImpl = class extends ServiceMap.Service()("@logixjs/core/SchedulingPolicySurfaceOverrides") {
458
+ };
459
+ var SchedulingPolicySurfaceOverridesTag = SchedulingPolicySurfaceOverridesTagImpl;
460
+ var ConcurrencyPolicyTag = SchedulingPolicySurfaceTag;
461
+ var RuntimeStoreTag = class extends ServiceMap.Service()("@logixjs/core/RuntimeStore") {
462
+ };
463
+ var runtimeStoreLayer = Layer.effect(
464
+ RuntimeStoreTag,
465
+ Effect2.acquireRelease(
466
+ Effect2.sync(() => makeRuntimeStore()),
467
+ (store) => Effect2.sync(() => store.dispose())
468
+ )
469
+ );
470
+ var HostSchedulerTag = class extends ServiceMap.Service()("@logixjs/core/HostScheduler") {
471
+ };
472
+ var hostSchedulerLayer = Layer.succeed(
473
+ HostSchedulerTag,
474
+ getGlobalHostScheduler()
475
+ );
476
+ var hostSchedulerTestStubLayer = (scheduler) => Layer.succeed(HostSchedulerTag, scheduler);
477
+ var DeclarativeLinkRuntimeTag = class extends ServiceMap.Service()("@logixjs/core/DeclarativeLinkRuntime") {
478
+ };
479
+ var declarativeLinkRuntimeLayer = Layer.succeed(
480
+ DeclarativeLinkRuntimeTag,
481
+ makeDeclarativeLinkRuntime()
482
+ );
483
+ var TickSchedulerTag = class extends ServiceMap.Service()("@logixjs/core/TickScheduler") {
484
+ };
485
+ var tickSchedulerLayer = (config) => Layer.effect(
486
+ TickSchedulerTag,
487
+ Effect2.gen(function* () {
488
+ const store = yield* Effect2.service(RuntimeStoreTag).pipe(Effect2.orDie);
489
+ const declarativeLinkRuntime = yield* Effect2.service(DeclarativeLinkRuntimeTag).pipe(Effect2.orDie);
490
+ const hostScheduler = yield* Effect2.service(HostSchedulerTag).pipe(Effect2.orDie);
491
+ return makeTickScheduler({ runtimeStore: store, declarativeLinkRuntime, hostScheduler, config });
492
+ })
493
+ );
494
+
495
+ // src/internal/runtime/core/TaskRunner.ts
496
+ var inSyncTransactionFiber = ServiceMap2.Reference("@logixjs/core/TaskRunner.inSyncTransactionFiber", {
497
+ defaultValue: () => false
498
+ });
499
+ var forceSourceRefresh = ServiceMap2.Reference("@logixjs/core/TaskRunner.forceSourceRefresh", {
500
+ defaultValue: () => false
501
+ });
502
+ var inSyncTransactionShadowDepth = 0;
503
+ var enterSyncTransactionShadow = () => {
504
+ inSyncTransactionShadowDepth += 1;
505
+ };
506
+ var exitSyncTransactionShadow = () => {
507
+ inSyncTransactionShadowDepth = Math.max(0, inSyncTransactionShadowDepth - 1);
508
+ };
509
+ var isInSyncTransactionShadow = () => inSyncTransactionShadowDepth > 0;
510
+ var resolve = (eff, payload) => typeof eff === "function" ? eff(payload) : eff;
511
+ var defaultOrigins = (triggerName) => ({
512
+ pending: {
513
+ kind: "task:pending",
514
+ name: triggerName
515
+ },
516
+ success: {
517
+ kind: "service-callback",
518
+ name: "task:success"
519
+ },
520
+ failure: {
521
+ kind: "service-callback",
522
+ name: "task:failure"
523
+ }
524
+ });
525
+ var shouldNoopInSyncTransactionFiber = (options) => Effect3.gen(function* () {
526
+ const inTxn = yield* Effect3.service(inSyncTransactionFiber);
527
+ if (!inTxn) {
528
+ return false;
529
+ }
530
+ if (isDevEnv()) {
531
+ yield* record({
532
+ type: "diagnostic",
533
+ moduleId: options.moduleId,
534
+ instanceId: options.instanceId,
535
+ code: options.code,
536
+ severity: options.severity,
537
+ message: options.message,
538
+ hint: options.hint,
539
+ actionTag: options.actionTag,
540
+ kind: options.kind
541
+ });
542
+ }
543
+ return true;
544
+ });
545
+ var resolveConcurrencyLimit = (runtime) => runtime.resolveConcurrencyPolicy ? runtime.resolveConcurrencyPolicy().pipe(Effect3.map((p) => p.concurrencyLimit)) : Effect3.succeed(16);
546
+ var runTaskLifecycle = (payload, runtime, config, getCanWriteBack) => Effect3.gen(function* () {
547
+ const noop = yield* shouldNoopInSyncTransactionFiber({
548
+ moduleId: runtime.moduleId,
549
+ instanceId: runtime.instanceId,
550
+ code: "logic::invalid_usage",
551
+ severity: "error",
552
+ message: "run*Task is not allowed inside a synchronous StateTransaction body (it may deadlock the txnQueue).",
553
+ hint: "Call run*Task from the run section of a watcher (e.g. $.onAction/$.onState/$.on); do not call it directly inside a reducer / trait.run / synchronous transaction body. For long-lived flows, use a multi-entry pattern (pending \u2192 IO \u2192 writeback).",
554
+ kind: "run_task_in_transaction"
555
+ });
556
+ if (noop) {
557
+ return;
558
+ }
559
+ const defaults = defaultOrigins(config.triggerName);
560
+ const origins = {
561
+ pending: config.origin?.pending ?? defaults.pending,
562
+ success: config.origin?.success ?? defaults.success,
563
+ failure: config.origin?.failure ?? defaults.failure
564
+ };
565
+ const pending = config.pending;
566
+ if (pending) {
567
+ yield* Effect3.uninterruptible(
568
+ runtime.runWithStateTransaction(origins.pending, () => Effect3.asVoid(resolve(pending, payload)))
569
+ );
570
+ }
571
+ const io = resolve(config.effect, payload);
572
+ const exit = yield* Effect3.exit(io);
573
+ if (getCanWriteBack) {
574
+ const ok = yield* getCanWriteBack;
575
+ if (!ok) {
576
+ return;
577
+ }
578
+ }
579
+ if (exit._tag === "Success") {
580
+ const success = config.success;
581
+ if (success) {
582
+ yield* runtime.runWithStateTransaction(origins.success, () => Effect3.asVoid(success(exit.value, payload)));
583
+ }
584
+ return;
585
+ }
586
+ const cause = exit.cause;
587
+ if (Cause.hasInterruptsOnly(cause)) {
588
+ return;
589
+ }
590
+ const failure = config.failure;
591
+ if (failure) {
592
+ yield* runtime.runWithStateTransaction(origins.failure, () => Effect3.asVoid(failure(cause, payload)));
593
+ }
594
+ }).pipe(
595
+ // Watchers must not crash as a whole due to a single task failure: swallow errors, but keep them diagnosable.
596
+ Effect3.catchCause((cause) => record({
597
+ type: "diagnostic",
598
+ moduleId: runtime.moduleId,
599
+ instanceId: runtime.instanceId,
600
+ code: "task_runner::unhandled_failure",
601
+ severity: "error",
602
+ message: "TaskRunner encountered an unhandled failure (pending/IO/writeback).",
603
+ hint: "Add a failure writeback for this task or handle errors explicitly upstream; avoid fire-and-forget swallowing errors.",
604
+ actionTag: config.triggerName,
605
+ kind: "task_runner_unhandled_failure",
606
+ trigger: {
607
+ kind: "task",
608
+ name: config.triggerName
609
+ }
610
+ }).pipe(Effect3.flatMap(() => Effect3.logError("TaskRunner error", cause))))
611
+ );
612
+ var runTask = (args) => {
613
+ const mode = args.mode ?? "task";
614
+ const runtime = args.runtime;
615
+ const config = args.config;
616
+ return runByMode({
617
+ stream: args.stream,
618
+ mode,
619
+ run: (payload) => runTaskLifecycle(payload, runtime, config),
620
+ runLatest: (payload, context) => runTaskLifecycle(payload, runtime, config, context.isCurrent),
621
+ resolveConcurrencyLimit: resolveConcurrencyLimit(runtime),
622
+ latest: {
623
+ strategy: "fiber-slot",
624
+ // Keep TaskRunner behavior: triggers are acknowledged once started; no need to await final IO on stream completion.
625
+ awaitLatestOnEnd: false
626
+ }
627
+ });
628
+ };
629
+ var makeTaskRunner = (stream, mode, runtime, config) => runTask({
630
+ stream,
631
+ mode,
632
+ runtime,
633
+ config
634
+ });
635
+
636
+ // src/internal/runtime/core/TickScheduler.ts
637
+ var batchDepth = 0;
638
+ var batchWaiters = /* @__PURE__ */ new Set();
639
+ var enterRuntimeBatch = () => {
640
+ batchDepth += 1;
641
+ };
642
+ var exitRuntimeBatch = () => {
643
+ batchDepth = Math.max(0, batchDepth - 1);
644
+ if (batchDepth !== 0) return;
645
+ const waiters = Array.from(batchWaiters);
646
+ batchWaiters.clear();
647
+ for (const w of waiters) {
648
+ try {
649
+ w.resolve();
650
+ } catch {
651
+ }
652
+ }
653
+ };
654
+ var waitForBatchEndIfNeeded = () => batchDepth === 0 ? Effect4.void : Effect4.promise(
655
+ (signal) => new Promise((resolve2) => {
656
+ let done = false;
657
+ const cleanup = () => {
658
+ if (done) return;
659
+ done = true;
660
+ batchWaiters.delete(waiter);
661
+ try {
662
+ signal.removeEventListener("abort", onAbort);
663
+ } catch {
664
+ }
665
+ };
666
+ const onAbort = () => {
667
+ cleanup();
668
+ };
669
+ const waiter = {
670
+ resolve: () => {
671
+ cleanup();
672
+ resolve2();
673
+ }
674
+ };
675
+ batchWaiters.add(waiter);
676
+ try {
677
+ signal.addEventListener("abort", onAbort, { once: true });
678
+ } catch {
679
+ }
680
+ })
681
+ );
682
+ var toSchedulingAnchor = (commit) => {
683
+ if (!commit) return void 0;
684
+ if (typeof commit.opSeq !== "number") return void 0;
685
+ return {
686
+ moduleId: commit.moduleId,
687
+ instanceId: commit.instanceId,
688
+ txnSeq: commit.meta.txnSeq,
689
+ txnId: commit.meta.txnId,
690
+ opSeq: commit.opSeq
691
+ };
692
+ };
693
+ var toSchedulingResolvedTxnSeq = (commit) => commit.schedulingPolicy?.resolvedAtTxnSeq ?? commit.meta.txnSeq;
694
+ var toSchedulingResolvedOpSeq = (commit) => typeof commit.opSeq === "number" && Number.isFinite(commit.opSeq) ? commit.opSeq : -1;
695
+ var pickNewerSchedulingCommit = (current, candidate) => {
696
+ if (!current) return candidate;
697
+ const currentTxnSeq = toSchedulingResolvedTxnSeq(current);
698
+ const candidateTxnSeq = toSchedulingResolvedTxnSeq(candidate);
699
+ if (candidateTxnSeq > currentTxnSeq) return candidate;
700
+ if (candidateTxnSeq < currentTxnSeq) return current;
701
+ return toSchedulingResolvedOpSeq(candidate) > toSchedulingResolvedOpSeq(current) ? candidate : current;
702
+ };
703
+ var clampSampleRate = (sampleRate) => {
704
+ if (typeof sampleRate !== "number" || !Number.isFinite(sampleRate)) return 0;
705
+ if (sampleRate <= 0) return 0;
706
+ if (sampleRate >= 1) return 1;
707
+ return sampleRate;
708
+ };
709
+ var shouldSampleTick = (tickSeq, sampleRate) => {
710
+ if (sampleRate <= 0) return false;
711
+ if (sampleRate >= 1) return true;
712
+ const x = tickSeq >>> 0;
713
+ const h = Math.imul(x ^ 2654435769, 2246822507) >>> 0;
714
+ return h / 4294967295 < sampleRate;
715
+ };
716
+ var topicKeyResolutionCacheLimit = 1024;
717
+ var toTriggerKind = (originKind) => {
718
+ if (originKind === "action") return "dispatch";
719
+ if (originKind === "trait-external-store") return "externalStore";
720
+ if (originKind?.includes("timer")) return "timer";
721
+ return "unknown";
722
+ };
723
+ var toLane = (priority) => priority === "low" ? "nonUrgent" : "urgent";
724
+ var maxPriority2 = (a, b) => a === "normal" || b === "normal" ? "normal" : "low";
725
+ var mergeDrainInPlace = (base, next) => {
726
+ for (const [k, commit] of next.modules) {
727
+ const prev = base.modules.get(k);
728
+ if (!prev) {
729
+ base.modules.set(k, commit);
730
+ } else {
731
+ const mergedPriority = maxPriority2(prev.meta.priority, commit.meta.priority);
732
+ if (mergedPriority === commit.meta.priority) {
733
+ base.modules.set(k, commit);
734
+ } else {
735
+ base.modules.set(k, {
736
+ ...commit,
737
+ meta: {
738
+ ...commit.meta,
739
+ priority: mergedPriority
740
+ }
741
+ });
742
+ }
743
+ }
744
+ }
745
+ for (const [k, p] of next.dirtyTopics) {
746
+ const prev = base.dirtyTopics.get(k);
747
+ if (!prev) {
748
+ base.dirtyTopics.set(k, p);
749
+ continue;
750
+ }
751
+ const mergedPriority = maxPriority2(prev, p);
752
+ if (mergedPriority !== prev) {
753
+ base.dirtyTopics.set(k, mergedPriority);
754
+ }
755
+ }
756
+ };
757
+ var emptyDrain = () => ({ modules: /* @__PURE__ */ new Map(), dirtyTopics: /* @__PURE__ */ new Map() });
758
+ var partitionModulesForBudget = (args) => {
759
+ let urgentCount = 0;
760
+ for (const commit of args.modules.values()) {
761
+ if (toLane(commit.meta.priority) === "urgent") {
762
+ urgentCount += 1;
763
+ }
764
+ }
765
+ const urgentCap = Math.max(0, args.urgentStepCap);
766
+ const urgentCapExceeded = urgentCount > urgentCap;
767
+ const nonUrgentBudget = Math.max(0, args.maxSteps);
768
+ let acceptedUrgentCount = 0;
769
+ let deferredNonUrgentCount = 0;
770
+ const acceptedModules = /* @__PURE__ */ new Map();
771
+ const deferredModules = /* @__PURE__ */ new Map();
772
+ for (const commit of args.modules.values()) {
773
+ if (toLane(commit.meta.priority) !== "urgent") continue;
774
+ if (urgentCapExceeded && acceptedUrgentCount >= urgentCap) {
775
+ deferredModules.set(commit.moduleInstanceKey, commit);
776
+ continue;
777
+ }
778
+ acceptedModules.set(commit.moduleInstanceKey, commit);
779
+ acceptedUrgentCount += 1;
780
+ }
781
+ if (urgentCapExceeded) {
782
+ for (const commit of args.modules.values()) {
783
+ if (toLane(commit.meta.priority) === "urgent") continue;
784
+ deferredModules.set(commit.moduleInstanceKey, commit);
785
+ deferredNonUrgentCount += 1;
786
+ }
787
+ return {
788
+ acceptedModules,
789
+ deferredModules,
790
+ urgentCapExceeded,
791
+ deferredNonUrgentCount
792
+ };
793
+ }
794
+ let acceptedNonUrgentCount = 0;
795
+ for (const commit of args.modules.values()) {
796
+ if (toLane(commit.meta.priority) === "urgent") continue;
797
+ if (acceptedNonUrgentCount >= nonUrgentBudget) {
798
+ deferredModules.set(commit.moduleInstanceKey, commit);
799
+ deferredNonUrgentCount += 1;
800
+ continue;
801
+ }
802
+ acceptedModules.set(commit.moduleInstanceKey, commit);
803
+ acceptedNonUrgentCount += 1;
804
+ }
805
+ return {
806
+ acceptedModules,
807
+ deferredModules,
808
+ urgentCapExceeded,
809
+ deferredNonUrgentCount
810
+ };
811
+ };
812
+ var makeTickScheduler = (args) => {
813
+ const store = args.runtimeStore;
814
+ const hostScheduler = args.hostScheduler;
815
+ const declarativeLinks = args.declarativeLinkRuntime;
816
+ const queue = args.queue ?? makeJobQueue();
817
+ const config = {
818
+ maxSteps: args.config?.maxSteps ?? 64,
819
+ urgentStepCap: args.config?.urgentStepCap ?? 512,
820
+ maxDrainRounds: args.config?.maxDrainRounds ?? 8,
821
+ microtaskChainDepthLimit: args.config?.microtaskChainDepthLimit ?? 32
822
+ };
823
+ const telemetry = args.config?.telemetry;
824
+ const telemetrySampleRate = clampSampleRate(telemetry?.sampleRate);
825
+ let tickSeq = 0;
826
+ let scheduled = false;
827
+ let microtaskChainDepth = 0;
828
+ let nextForcedReason;
829
+ let lastSchedulingDegrade;
830
+ let coalescedModules = 0;
831
+ let coalescedTopics = 0;
832
+ const topicKeyToModuleInstanceKeyCache = /* @__PURE__ */ new Map();
833
+ const rememberTopicKeyResolution = (topicKey, moduleInstanceKey) => {
834
+ if (topicKeyToModuleInstanceKeyCache.has(topicKey)) {
835
+ topicKeyToModuleInstanceKeyCache.delete(topicKey);
836
+ } else if (topicKeyToModuleInstanceKeyCache.size >= topicKeyResolutionCacheLimit) {
837
+ const oldestKey = topicKeyToModuleInstanceKeyCache.keys().next().value;
838
+ if (oldestKey !== void 0) {
839
+ topicKeyToModuleInstanceKeyCache.delete(oldestKey);
840
+ }
841
+ }
842
+ topicKeyToModuleInstanceKeyCache.set(topicKey, moduleInstanceKey ?? null);
843
+ return moduleInstanceKey;
844
+ };
845
+ const yieldMicrotask = Effect4.promise(
846
+ () => new Promise((resolve2) => {
847
+ hostScheduler.scheduleMicrotask(resolve2);
848
+ })
849
+ );
850
+ const yieldMacrotask = Effect4.promise(
851
+ (signal) => new Promise((resolve2) => {
852
+ const cancel = hostScheduler.scheduleMacrotask(resolve2);
853
+ try {
854
+ signal.addEventListener(
855
+ "abort",
856
+ () => {
857
+ cancel();
858
+ },
859
+ { once: true }
860
+ );
861
+ } catch {
862
+ }
863
+ })
864
+ );
865
+ const scheduleTick = () => Effect4.gen(function* () {
866
+ if (scheduled) return;
867
+ scheduled = true;
868
+ const waitedForBatch = batchDepth > 0;
869
+ const forcedReason = nextForcedReason;
870
+ nextForcedReason = void 0;
871
+ const shouldYieldForStarvation = forcedReason == null && microtaskChainDepth >= Math.max(1, config.microtaskChainDepthLimit);
872
+ const reason = forcedReason ?? (shouldYieldForStarvation ? "microtask_starvation" : void 0);
873
+ const boundary = reason ? "macrotask" : "microtask";
874
+ const startedAs = waitedForBatch ? "batch" : boundary;
875
+ const depthAtSchedule = microtaskChainDepth;
876
+ yield* Effect4.provideService(Effect4.gen(function* () {
877
+ try {
878
+ yield* waitForBatchEndIfNeeded();
879
+ if (boundary === "microtask") {
880
+ if (waitedForBatch) {
881
+ microtaskChainDepth = 0;
882
+ }
883
+ yield* yieldMicrotask;
884
+ if (!waitedForBatch) {
885
+ microtaskChainDepth += 1;
886
+ }
887
+ } else {
888
+ yield* yieldMacrotask;
889
+ microtaskChainDepth = 0;
890
+ }
891
+ const schedule = {
892
+ startedAs,
893
+ microtaskChainDepth: boundary === "macrotask" ? depthAtSchedule : microtaskChainDepth,
894
+ ...boundary === "macrotask" ? { forcedMacrotask: true, reason: reason ?? "unknown" } : {}
895
+ };
896
+ const outcome = yield* flushTick(schedule);
897
+ if (!outcome.stable) {
898
+ nextForcedReason = outcome.degradeReason === "budget_steps" ? "budget" : outcome.degradeReason === "cycle_detected" ? "cycle_detected" : "unknown";
899
+ }
900
+ } finally {
901
+ scheduled = false;
902
+ if (queue.hasPending()) {
903
+ yield* scheduleTick();
904
+ } else {
905
+ microtaskChainDepth = 0;
906
+ }
907
+ }
908
+ }), inSyncTransactionFiber, false).pipe(Effect4.forkDetach({ startImmediately: true }));
909
+ });
910
+ const flushTick = (schedule) => Effect4.gen(function* () {
911
+ if (!queue.hasPending()) {
912
+ return { stable: true };
913
+ }
914
+ tickSeq += 1;
915
+ const currentTickSeq = tickSeq;
916
+ const diagnosticsLevel = yield* Effect4.service(currentDiagnosticsLevel).pipe(Effect4.orDie);
917
+ const traceMode = yield* Effect4.service(currentTraceMode).pipe(Effect4.orDie);
918
+ const shouldEmitTrace = traceMode === "on" && diagnosticsLevel !== "off";
919
+ const shouldEmitSchedulingDiagnostics = diagnosticsLevel !== "off";
920
+ const captured = {
921
+ drainRounds: 0,
922
+ stable: true,
923
+ accepted: emptyDrain()
924
+ };
925
+ while (captured.drainRounds < config.maxDrainRounds) {
926
+ const drained = queue.drain();
927
+ if (!drained) break;
928
+ captured.drainRounds += 1;
929
+ mergeDrainInPlace(captured.accepted, drained);
930
+ if (declarativeLinks && drained.modules.size > 0) {
931
+ const changedModuleInstanceKeys = Array.from(drained.modules.keys());
932
+ yield* declarativeLinks.applyForSources({
933
+ tickSeq: currentTickSeq,
934
+ acceptedModules: captured.accepted.modules,
935
+ changedModuleInstanceKeys
936
+ });
937
+ }
938
+ }
939
+ if (queue.hasPending()) {
940
+ captured.stable = false;
941
+ captured.degradeReason = "cycle_detected";
942
+ }
943
+ let acceptedModules = captured.accepted.modules;
944
+ let deferredModules = void 0;
945
+ let urgentCapExceeded = false;
946
+ let deferredNonUrgentCount = 0;
947
+ if (!(captured.accepted.modules.size <= config.maxSteps && captured.accepted.modules.size <= config.urgentStepCap)) {
948
+ const partitioned = partitionModulesForBudget({
949
+ modules: captured.accepted.modules,
950
+ maxSteps: config.maxSteps,
951
+ urgentStepCap: config.urgentStepCap
952
+ });
953
+ acceptedModules = partitioned.acceptedModules;
954
+ deferredModules = partitioned.deferredModules;
955
+ urgentCapExceeded = partitioned.urgentCapExceeded;
956
+ deferredNonUrgentCount = partitioned.deferredNonUrgentCount;
957
+ }
958
+ if (urgentCapExceeded) {
959
+ captured.stable = false;
960
+ captured.degradeReason = "cycle_detected";
961
+ } else if (deferredNonUrgentCount > 0) {
962
+ captured.stable = false;
963
+ captured.degradeReason = captured.degradeReason ?? "budget_steps";
964
+ }
965
+ const canAcceptAllTopics = deferredModules == null || deferredModules.size === 0;
966
+ const acceptedDrain = (() => {
967
+ if (canAcceptAllTopics) {
968
+ if (captured.accepted.dirtyTopics.size === 0) {
969
+ return captured.accepted;
970
+ }
971
+ let hasNonParsable = false;
972
+ for (const topicKey of captured.accepted.dirtyTopics.keys()) {
973
+ if (!storeTopicToModuleInstanceKey(topicKey)) {
974
+ hasNonParsable = true;
975
+ break;
976
+ }
977
+ }
978
+ if (!hasNonParsable) {
979
+ return captured.accepted;
980
+ }
981
+ const acceptedTopics2 = /* @__PURE__ */ new Map();
982
+ for (const [topicKey, priority] of captured.accepted.dirtyTopics) {
983
+ const moduleInstanceKey = storeTopicToModuleInstanceKey(topicKey);
984
+ if (!moduleInstanceKey) continue;
985
+ acceptedTopics2.set(topicKey, priority);
986
+ }
987
+ return {
988
+ modules: acceptedModules,
989
+ dirtyTopics: acceptedTopics2
990
+ };
991
+ }
992
+ const acceptedTopics = /* @__PURE__ */ new Map();
993
+ const deferredTopics = /* @__PURE__ */ new Map();
994
+ for (const [topicKey, priority] of captured.accepted.dirtyTopics) {
995
+ const moduleInstanceKey = storeTopicToModuleInstanceKey(topicKey);
996
+ if (!moduleInstanceKey) continue;
997
+ if (acceptedModules.has(moduleInstanceKey)) {
998
+ acceptedTopics.set(topicKey, priority);
999
+ } else if (deferredModules && deferredModules.has(moduleInstanceKey)) {
1000
+ deferredTopics.set(topicKey, priority);
1001
+ } else {
1002
+ acceptedTopics.set(topicKey, priority);
1003
+ }
1004
+ }
1005
+ return {
1006
+ modules: acceptedModules,
1007
+ dirtyTopics: acceptedTopics
1008
+ };
1009
+ })();
1010
+ const deferredDrain = canAcceptAllTopics || !deferredModules ? void 0 : deferredModules.size > 0 ? {
1011
+ modules: deferredModules,
1012
+ dirtyTopics: (() => {
1013
+ const deferredTopics = /* @__PURE__ */ new Map();
1014
+ for (const [topicKey, priority] of captured.accepted.dirtyTopics) {
1015
+ const moduleInstanceKey = storeTopicToModuleInstanceKey(topicKey);
1016
+ if (!moduleInstanceKey) continue;
1017
+ if (deferredModules.has(moduleInstanceKey)) {
1018
+ deferredTopics.set(topicKey, priority);
1019
+ }
1020
+ }
1021
+ return deferredTopics;
1022
+ })()
1023
+ } : void 0;
1024
+ captured.deferred = deferredDrain;
1025
+ const anchorCommitForScheduling = (() => {
1026
+ let selected;
1027
+ for (const commit of acceptedModules.values()) {
1028
+ selected = pickNewerSchedulingCommit(selected, commit);
1029
+ }
1030
+ if (deferredDrain) {
1031
+ for (const commit of deferredDrain.modules.values()) {
1032
+ selected = pickNewerSchedulingCommit(selected, commit);
1033
+ }
1034
+ }
1035
+ return selected;
1036
+ })();
1037
+ const schedulingAnchor = toSchedulingAnchor(anchorCommitForScheduling);
1038
+ const schedulingPolicy = anchorCommitForScheduling?.schedulingPolicy;
1039
+ const schedulingConfigScope = schedulingPolicy?.configScope ?? "builtin";
1040
+ const schedulingLimit = schedulingPolicy?.concurrencyLimit ?? 16;
1041
+ const schedulingThreshold = schedulingPolicy?.pressureWarningThreshold ?? {
1042
+ backlogCount: 1e3,
1043
+ backlogDurationMs: 5e3
1044
+ };
1045
+ const schedulingCooldownMs = schedulingPolicy?.warningCooldownMs ?? 3e4;
1046
+ const backlogCount = deferredDrain ? deferredDrain.modules.size + deferredDrain.dirtyTopics.size : 0;
1047
+ if (!captured.stable && shouldEmitSchedulingDiagnostics && schedulingAnchor && !lastSchedulingDegrade) {
1048
+ const reason = captured.degradeReason ?? "unknown";
1049
+ yield* record({
1050
+ type: "diagnostic",
1051
+ moduleId: schedulingAnchor.moduleId,
1052
+ instanceId: schedulingAnchor.instanceId,
1053
+ txnSeq: schedulingAnchor.txnSeq,
1054
+ txnId: schedulingAnchor.txnId,
1055
+ opSeq: schedulingAnchor.opSeq,
1056
+ code: "scheduling::degrade",
1057
+ severity: "warning",
1058
+ message: "Scheduling degraded: tick execution deferred part of the backlog.",
1059
+ hint: "Inspect reason/backlog and align queue/tick/concurrency knobs through the same scheduling policy surface.",
1060
+ kind: "scheduling:degrade",
1061
+ trigger: {
1062
+ kind: "tickScheduler",
1063
+ name: "flushTick",
1064
+ details: {
1065
+ eventKind: "degrade",
1066
+ reason,
1067
+ tickSeq: currentTickSeq,
1068
+ backlogCount,
1069
+ configScope: schedulingConfigScope,
1070
+ limit: schedulingLimit,
1071
+ threshold: schedulingThreshold,
1072
+ cooldownMs: schedulingCooldownMs,
1073
+ schedule: {
1074
+ startedAs: schedule.startedAs ?? "unknown",
1075
+ forcedMacrotask: schedule.forcedMacrotask === true,
1076
+ reason: schedule.reason ?? "unknown",
1077
+ microtaskChainDepth: schedule.microtaskChainDepth ?? 0
1078
+ }
1079
+ }
1080
+ }
1081
+ });
1082
+ lastSchedulingDegrade = {
1083
+ tickSeq: currentTickSeq,
1084
+ reason,
1085
+ moduleId: schedulingAnchor.moduleId,
1086
+ instanceId: schedulingAnchor.instanceId,
1087
+ txnSeq: schedulingAnchor.txnSeq,
1088
+ txnId: schedulingAnchor.txnId,
1089
+ opSeq: schedulingAnchor.opSeq,
1090
+ configScope: schedulingConfigScope,
1091
+ limit: schedulingLimit,
1092
+ backlogCount
1093
+ };
1094
+ } else if (captured.stable && lastSchedulingDegrade) {
1095
+ const previous = lastSchedulingDegrade;
1096
+ if (shouldEmitSchedulingDiagnostics) {
1097
+ const recoverAnchor = schedulingAnchor ?? previous;
1098
+ yield* record({
1099
+ type: "diagnostic",
1100
+ moduleId: recoverAnchor.moduleId,
1101
+ instanceId: recoverAnchor.instanceId,
1102
+ txnSeq: recoverAnchor.txnSeq,
1103
+ txnId: recoverAnchor.txnId,
1104
+ opSeq: recoverAnchor.opSeq,
1105
+ code: "scheduling::recover",
1106
+ severity: "info",
1107
+ message: "Scheduling recovered: backlog/degrade condition cleared.",
1108
+ hint: "No immediate action needed unless degrade/recover oscillates frequently.",
1109
+ kind: "scheduling:recover",
1110
+ trigger: {
1111
+ kind: "tickScheduler",
1112
+ name: "flushTick",
1113
+ details: {
1114
+ eventKind: "recover",
1115
+ tickSeq: currentTickSeq,
1116
+ fromTickSeq: previous.tickSeq,
1117
+ fromReason: previous.reason,
1118
+ previousBacklogCount: previous.backlogCount,
1119
+ configScope: previous.configScope,
1120
+ limit: previous.limit,
1121
+ schedule: {
1122
+ startedAs: schedule.startedAs ?? "unknown",
1123
+ forcedMacrotask: schedule.forcedMacrotask === true,
1124
+ reason: schedule.reason ?? "unknown",
1125
+ microtaskChainDepth: schedule.microtaskChainDepth ?? 0
1126
+ }
1127
+ }
1128
+ }
1129
+ });
1130
+ }
1131
+ lastSchedulingDegrade = void 0;
1132
+ }
1133
+ let startedAtMs;
1134
+ let triggerSummary;
1135
+ let anchor;
1136
+ let backlog;
1137
+ let result;
1138
+ if (shouldEmitTrace) {
1139
+ startedAtMs = Date.now();
1140
+ let triggerTotal = 0;
1141
+ let triggerPrimary = void 0;
1142
+ let triggerAnchor;
1143
+ const triggerKindsOrder = [];
1144
+ let externalStoreCount = 0;
1145
+ let dispatchCount = 0;
1146
+ let timerCount = 0;
1147
+ let unknownCount = 0;
1148
+ for (const commit of captured.accepted.modules.values()) {
1149
+ if (!triggerAnchor) {
1150
+ triggerAnchor = commit;
1151
+ }
1152
+ triggerTotal += 1;
1153
+ const kind = toTriggerKind(commit.meta.originKind);
1154
+ if (!triggerPrimary) {
1155
+ triggerPrimary = {
1156
+ kind,
1157
+ moduleId: commit.moduleId,
1158
+ instanceId: commit.instanceId,
1159
+ fieldPath: kind === "externalStore" ? commit.meta.originName : void 0,
1160
+ actionTag: kind === "dispatch" ? commit.meta.originName : void 0
1161
+ };
1162
+ }
1163
+ switch (kind) {
1164
+ case "externalStore": {
1165
+ if (externalStoreCount === 0) triggerKindsOrder.push(kind);
1166
+ externalStoreCount += 1;
1167
+ break;
1168
+ }
1169
+ case "dispatch": {
1170
+ if (dispatchCount === 0) triggerKindsOrder.push(kind);
1171
+ dispatchCount += 1;
1172
+ break;
1173
+ }
1174
+ case "timer": {
1175
+ if (timerCount === 0) triggerKindsOrder.push(kind);
1176
+ timerCount += 1;
1177
+ break;
1178
+ }
1179
+ default: {
1180
+ if (unknownCount === 0) triggerKindsOrder.push(kind);
1181
+ unknownCount += 1;
1182
+ break;
1183
+ }
1184
+ }
1185
+ }
1186
+ const kinds = [];
1187
+ for (const kind of triggerKindsOrder) {
1188
+ switch (kind) {
1189
+ case "externalStore":
1190
+ kinds.push({ kind, count: externalStoreCount });
1191
+ break;
1192
+ case "dispatch":
1193
+ kinds.push({ kind, count: dispatchCount });
1194
+ break;
1195
+ case "timer":
1196
+ kinds.push({ kind, count: timerCount });
1197
+ break;
1198
+ default:
1199
+ kinds.push({ kind, count: unknownCount });
1200
+ break;
1201
+ }
1202
+ }
1203
+ triggerSummary = {
1204
+ total: triggerTotal,
1205
+ kinds,
1206
+ primary: triggerPrimary,
1207
+ coalescedCount: {
1208
+ modules: coalescedModules,
1209
+ topics: coalescedTopics
1210
+ }
1211
+ };
1212
+ if (triggerAnchor) {
1213
+ anchor = {
1214
+ moduleId: triggerAnchor.moduleId,
1215
+ instanceId: triggerAnchor.instanceId,
1216
+ txnSeq: triggerAnchor.meta.txnSeq,
1217
+ txnId: triggerAnchor.meta.txnId,
1218
+ ...typeof triggerAnchor.opSeq === "number" ? { opSeq: triggerAnchor.opSeq } : null
1219
+ };
1220
+ }
1221
+ const deferredWork = captured.deferred;
1222
+ if (deferredWork) {
1223
+ const pendingDeferredWork = deferredWork.modules.size + deferredWork.dirtyTopics.size;
1224
+ let pendingExternalInputs = 0;
1225
+ let firstDeferred;
1226
+ let firstExternalStoreDeferred;
1227
+ for (const deferred of deferredWork.modules.values()) {
1228
+ if (!firstDeferred) {
1229
+ firstDeferred = deferred;
1230
+ }
1231
+ const kind = toTriggerKind(deferred.meta.originKind);
1232
+ if (kind === "externalStore") {
1233
+ pendingExternalInputs += 1;
1234
+ if (!firstExternalStoreDeferred) {
1235
+ firstExternalStoreDeferred = deferred;
1236
+ }
1237
+ }
1238
+ }
1239
+ const primaryDeferred = firstExternalStoreDeferred ?? firstDeferred;
1240
+ let deferredPrimary = void 0;
1241
+ if (primaryDeferred) {
1242
+ const kind = toTriggerKind(primaryDeferred.meta.originKind);
1243
+ const isExternalStore = kind === "externalStore";
1244
+ deferredPrimary = {
1245
+ kind: isExternalStore ? "externalStore" : "unknown",
1246
+ moduleId: primaryDeferred.moduleId,
1247
+ instanceId: primaryDeferred.instanceId,
1248
+ fieldPath: isExternalStore ? primaryDeferred.meta.originName : void 0,
1249
+ storeId: void 0
1250
+ };
1251
+ }
1252
+ backlog = {
1253
+ pendingExternalInputs,
1254
+ pendingDeferredWork,
1255
+ deferredPrimary
1256
+ };
1257
+ }
1258
+ result = {
1259
+ stable: captured.stable,
1260
+ ...captured.stable ? null : { degradeReason: captured.degradeReason ?? "unknown" }
1261
+ };
1262
+ }
1263
+ if (shouldEmitTrace && schedule.forcedMacrotask && schedule.reason === "microtask_starvation") {
1264
+ yield* record({
1265
+ type: "warn:microtask-starvation",
1266
+ moduleId: anchor?.moduleId,
1267
+ instanceId: anchor?.instanceId,
1268
+ tickSeq: currentTickSeq,
1269
+ microtaskChainDepth: schedule.microtaskChainDepth
1270
+ });
1271
+ }
1272
+ if (shouldEmitTrace) {
1273
+ yield* record({
1274
+ type: "trace:tick",
1275
+ moduleId: anchor?.moduleId,
1276
+ instanceId: anchor?.instanceId,
1277
+ data: {
1278
+ tickSeq: currentTickSeq,
1279
+ phase: "start",
1280
+ timestampMs: startedAtMs,
1281
+ schedule,
1282
+ triggerSummary,
1283
+ anchors: anchor,
1284
+ budget: {
1285
+ maxSteps: config.maxSteps,
1286
+ elapsedMs: 0,
1287
+ steps: 0,
1288
+ txnCount: acceptedModules.size
1289
+ }
1290
+ }
1291
+ });
1292
+ }
1293
+ if (!captured.stable && shouldEmitTrace) {
1294
+ yield* record({
1295
+ type: "trace:tick",
1296
+ moduleId: anchor?.moduleId,
1297
+ instanceId: anchor?.instanceId,
1298
+ data: {
1299
+ tickSeq: currentTickSeq,
1300
+ phase: "budgetExceeded",
1301
+ timestampMs: Date.now(),
1302
+ schedule,
1303
+ triggerSummary,
1304
+ anchors: anchor,
1305
+ budget: {
1306
+ maxSteps: config.maxSteps,
1307
+ elapsedMs: Math.max(0, Date.now() - startedAtMs),
1308
+ steps: config.maxSteps,
1309
+ txnCount: acceptedModules.size
1310
+ },
1311
+ backlog,
1312
+ result
1313
+ }
1314
+ });
1315
+ }
1316
+ if (deferredDrain) {
1317
+ queue.requeue(deferredDrain);
1318
+ }
1319
+ store.commitTick({
1320
+ tickSeq: currentTickSeq,
1321
+ accepted: acceptedDrain,
1322
+ onListener: (listener) => listener()
1323
+ });
1324
+ if (!captured.stable && shouldEmitTrace && backlog?.deferredPrimary) {
1325
+ const primary = backlog.deferredPrimary;
1326
+ if (primary.kind === "externalStore") {
1327
+ const moduleInstanceKey = primary.moduleId && primary.instanceId ? `${primary.moduleId}::${primary.instanceId}` : void 0;
1328
+ if (moduleInstanceKey && store.getModuleSubscriberCount(moduleInstanceKey) > 0) {
1329
+ yield* record({
1330
+ type: "warn:priority-inversion",
1331
+ moduleId: primary.moduleId,
1332
+ instanceId: primary.instanceId,
1333
+ tickSeq: currentTickSeq,
1334
+ reason: "deferredBacklog"
1335
+ });
1336
+ }
1337
+ }
1338
+ }
1339
+ if (shouldEmitTrace) {
1340
+ yield* record({
1341
+ type: "trace:tick",
1342
+ moduleId: anchor?.moduleId,
1343
+ instanceId: anchor?.instanceId,
1344
+ data: {
1345
+ tickSeq: currentTickSeq,
1346
+ phase: "settled",
1347
+ timestampMs: Date.now(),
1348
+ schedule,
1349
+ triggerSummary,
1350
+ anchors: anchor,
1351
+ budget: {
1352
+ maxSteps: config.maxSteps,
1353
+ elapsedMs: Math.max(0, Date.now() - startedAtMs),
1354
+ steps: acceptedModules.size,
1355
+ txnCount: acceptedModules.size
1356
+ },
1357
+ backlog,
1358
+ result
1359
+ }
1360
+ });
1361
+ }
1362
+ if (telemetry?.onTickDegraded && (schedule.forcedMacrotask || !captured.stable) && shouldSampleTick(currentTickSeq, telemetrySampleRate)) {
1363
+ try {
1364
+ telemetry.onTickDegraded({
1365
+ tickSeq: currentTickSeq,
1366
+ stable: captured.stable,
1367
+ degradeReason: captured.stable ? void 0 : captured.degradeReason ?? "unknown",
1368
+ forcedMacrotask: schedule.forcedMacrotask,
1369
+ scheduleReason: schedule.reason,
1370
+ microtaskChainDepth: schedule.microtaskChainDepth,
1371
+ deferredWorkCount: deferredDrain ? deferredDrain.modules.size + deferredDrain.dirtyTopics.size : 0
1372
+ });
1373
+ } catch {
1374
+ }
1375
+ }
1376
+ coalescedModules = 0;
1377
+ coalescedTopics = 0;
1378
+ return { stable: captured.stable, degradeReason: captured.degradeReason };
1379
+ });
1380
+ const flushNow = Effect4.gen(function* () {
1381
+ const beforeTickSeq = tickSeq;
1382
+ yield* flushTick({ startedAs: "unknown" });
1383
+ if (tickSeq > beforeTickSeq) {
1384
+ return;
1385
+ }
1386
+ if (!queue.hasPending() && !scheduled) {
1387
+ return;
1388
+ }
1389
+ yield* Effect4.yieldNow;
1390
+ if (tickSeq > beforeTickSeq) {
1391
+ return;
1392
+ }
1393
+ if (queue.hasPending()) {
1394
+ yield* flushTick({ startedAs: "unknown" });
1395
+ }
1396
+ }).pipe(Effect4.asVoid);
1397
+ const storeTopicToModuleInstanceKey = (topicKey) => {
1398
+ const cached = topicKeyToModuleInstanceKeyCache.get(topicKey);
1399
+ if (cached !== void 0) {
1400
+ return cached === null ? void 0 : cached;
1401
+ }
1402
+ const idx = topicKey.indexOf("::rq:");
1403
+ if (idx > 0) {
1404
+ return rememberTopicKeyResolution(topicKey, topicKey.slice(0, idx));
1405
+ }
1406
+ if (topicKey.includes("::")) {
1407
+ return rememberTopicKeyResolution(topicKey, topicKey);
1408
+ }
1409
+ return rememberTopicKeyResolution(topicKey, void 0);
1410
+ };
1411
+ const onSelectorChanged = ({ moduleInstanceKey, selectorId, priority }) => {
1412
+ const coalesced = queue.markTopicDirty(makeReadQueryTopicKey(moduleInstanceKey, selectorId), priority);
1413
+ if (coalesced) coalescedTopics += 1;
1414
+ };
1415
+ const onModuleCommit = (commit) => Effect4.gen(function* () {
1416
+ const coalescedCommit = queue.enqueueModuleCommit(commit);
1417
+ if (coalescedCommit) coalescedModules += 1;
1418
+ const coalescedTopic = queue.markTopicDirty(commit.moduleInstanceKey, commit.meta.priority);
1419
+ if (coalescedTopic) coalescedTopics += 1;
1420
+ yield* scheduleTick();
1421
+ });
1422
+ return {
1423
+ getTickSeq: () => tickSeq,
1424
+ onModuleCommit,
1425
+ onSelectorChanged,
1426
+ flushNow
1427
+ };
1428
+ };
1429
+
1430
+ export {
1431
+ makeModuleInstanceKey,
1432
+ enterRuntimeBatch,
1433
+ exitRuntimeBatch,
1434
+ getNodeEnv,
1435
+ isDevEnv,
1436
+ getDefaultStateTxnInstrumentation,
1437
+ StateTransactionConfigTag,
1438
+ ReadQueryStrictGateConfigTag,
1439
+ ReplayModeConfigTag,
1440
+ StateTransactionOverridesTag,
1441
+ SchedulingPolicySurfaceTag,
1442
+ SchedulingPolicySurfaceOverridesTag,
1443
+ ConcurrencyPolicyTag,
1444
+ RuntimeStoreTag,
1445
+ runtimeStoreLayer,
1446
+ HostSchedulerTag,
1447
+ hostSchedulerLayer,
1448
+ hostSchedulerTestStubLayer,
1449
+ DeclarativeLinkRuntimeTag,
1450
+ declarativeLinkRuntimeLayer,
1451
+ TickSchedulerTag,
1452
+ tickSchedulerLayer,
1453
+ inSyncTransactionFiber,
1454
+ forceSourceRefresh,
1455
+ enterSyncTransactionShadow,
1456
+ exitSyncTransactionShadow,
1457
+ isInSyncTransactionShadow,
1458
+ shouldNoopInSyncTransactionFiber,
1459
+ makeTaskRunner
1460
+ };
1461
+ //# sourceMappingURL=chunk-S4S5N4BJ.js.map