@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
package/dist/Link.cjs CHANGED
@@ -30,15 +30,19 @@ var __toCommonJS = (mod) => __copyProps(__defProp({}, "__esModule", { value: tru
30
30
  // src/Link.ts
31
31
  var Link_exports = {};
32
32
  __export(Link_exports, {
33
- make: () => make7
33
+ make: () => make9,
34
+ makeDeclarative: () => makeDeclarative
34
35
  });
35
36
  module.exports = __toCommonJS(Link_exports);
36
37
 
38
+ // src/Process.ts
39
+ var import_effect56 = require("effect");
40
+
37
41
  // src/internal/runtime/ModuleFactory.ts
38
- var import_effect48 = require("effect");
42
+ var import_effect55 = require("effect");
39
43
 
40
- // src/internal/runtime/core/ModuleRuntime.ts
41
- var import_effect42 = require("effect");
44
+ // src/internal/runtime/core/ModuleRuntime.impl.ts
45
+ var import_effect49 = require("effect");
42
46
 
43
47
  // src/internal/runtime/core/Lifecycle.ts
44
48
  var import_effect4 = require("effect");
@@ -46,7 +50,7 @@ var import_effect4 = require("effect");
46
50
  // src/internal/runtime/core/errorSummary.ts
47
51
  var import_effect = require("effect");
48
52
 
49
- // src/internal/runtime/core/DebugSink.ts
53
+ // src/internal/runtime/core/DebugSink.record.ts
50
54
  var import_effect3 = require("effect");
51
55
 
52
56
  // src/internal/observability/jsonValue.ts
@@ -61,29 +65,53 @@ var defaultOptions = {
61
65
 
62
66
  // src/internal/runtime/core/EffectOpCore.ts
63
67
  var import_effect2 = require("effect");
64
- var currentLinkId = import_effect2.FiberRef.unsafeMake(void 0);
65
- var EffectOpMiddlewareTag = class extends import_effect2.Context.Tag("Logix/EffectOpMiddleware")() {
66
- };
67
-
68
- // src/internal/runtime/core/DebugSink.ts
69
- var currentDebugSinks = import_effect3.FiberRef.unsafeMake([]);
70
- var currentRuntimeLabel = import_effect3.FiberRef.unsafeMake(void 0);
71
- var currentTxnId = import_effect3.FiberRef.unsafeMake(void 0);
72
- var currentOpSeq = import_effect3.FiberRef.unsafeMake(void 0);
73
- var currentDiagnosticsLevel = import_effect3.FiberRef.unsafeMake("off");
74
- var currentTraitConvergeDiagnosticsSampling = import_effect3.FiberRef.unsafeMake({
75
- sampleEveryN: 32,
76
- topK: 3
68
+ var currentLinkId = import_effect2.ServiceMap.Reference("@logixjs/core/CurrentLinkId", {
69
+ defaultValue: () => void 0
70
+ });
71
+ var EffectOpMiddlewareTag = class extends import_effect2.ServiceMap.Service()("Logix/EffectOpMiddleware") {
72
+ };
73
+
74
+ // src/internal/runtime/core/DebugSink.record.ts
75
+ var currentDebugSinks = import_effect3.ServiceMap.Reference("@logixjs/core/Debug.currentDebugSinks", {
76
+ defaultValue: () => []
77
+ });
78
+ var currentRuntimeLabel = import_effect3.ServiceMap.Reference("@logixjs/core/Debug.currentRuntimeLabel", {
79
+ defaultValue: () => void 0
80
+ });
81
+ var currentTxnId = import_effect3.ServiceMap.Reference("@logixjs/core/Debug.currentTxnId", {
82
+ defaultValue: () => void 0
83
+ });
84
+ var currentOpSeq = import_effect3.ServiceMap.Reference("@logixjs/core/Debug.currentOpSeq", {
85
+ defaultValue: () => void 0
86
+ });
87
+ var currentDiagnosticsLevel = import_effect3.ServiceMap.Reference("@logixjs/core/Debug.currentDiagnosticsLevel", {
88
+ defaultValue: () => "off"
89
+ });
90
+ var currentDiagnosticsMaterialization = import_effect3.ServiceMap.Reference(
91
+ "@logixjs/core/Debug.currentDiagnosticsMaterialization",
92
+ {
93
+ defaultValue: () => "eager"
94
+ }
95
+ );
96
+ var currentTraceMode = import_effect3.ServiceMap.Reference("@logixjs/core/Debug.currentTraceMode", {
97
+ defaultValue: () => "on"
77
98
  });
99
+ var currentTraitConvergeDiagnosticsSampling = import_effect3.ServiceMap.Reference(
100
+ "@logixjs/core/Debug.currentTraitConvergeDiagnosticsSampling",
101
+ {
102
+ defaultValue: () => ({
103
+ sampleEveryN: 32,
104
+ topK: 3
105
+ })
106
+ }
107
+ );
78
108
  var browserLifecycleSeen = /* @__PURE__ */ new Set();
79
109
  var browserDiagnosticSeen = /* @__PURE__ */ new Set();
80
110
  var lifecycleErrorLog = (event) => {
81
111
  const moduleId = event.moduleId ?? "unknown";
82
112
  const causePretty = (() => {
83
113
  try {
84
- return import_effect3.Cause.pretty(event.cause, {
85
- renderErrorCause: true
86
- });
114
+ return import_effect3.Cause.pretty(event.cause);
87
115
  } catch {
88
116
  try {
89
117
  return JSON.stringify(event.cause, null, 2);
@@ -124,15 +152,16 @@ ${detail}`;
124
152
  }
125
153
  return base.pipe(import_effect3.Effect.annotateLogs(annotations));
126
154
  };
127
- var noopLayer = import_effect3.Layer.locallyScoped(currentDebugSinks, []);
155
+ var noopLayer = import_effect3.Layer.succeed(currentDebugSinks, []);
128
156
  var errorOnlySink = {
129
157
  record: (event) => event.type === "lifecycle:error" ? lifecycleErrorLog(event) : event.type === "diagnostic" && event.severity !== "info" ? diagnosticLog(event) : import_effect3.Effect.void
130
158
  };
131
- var errorOnlyLayer = import_effect3.Layer.locallyScoped(currentDebugSinks, [errorOnlySink]);
159
+ var errorOnlyLayer = import_effect3.Layer.succeed(currentDebugSinks, [errorOnlySink]);
160
+ var isErrorOnlyOnlySinks = (sinks) => sinks.length === 1 && sinks[0] === errorOnlySink;
132
161
  var consoleSink = {
133
162
  record: (event) => event.type === "lifecycle:error" ? lifecycleErrorLog(event) : event.type === "diagnostic" ? diagnosticLog(event) : import_effect3.Effect.logDebug({ debugEvent: event })
134
163
  };
135
- var consoleLayer = import_effect3.Layer.locallyScoped(currentDebugSinks, [consoleSink]);
164
+ var consoleLayer = import_effect3.Layer.succeed(currentDebugSinks, [consoleSink]);
136
165
  var isBrowser = typeof window !== "undefined" && typeof document !== "undefined";
137
166
  var renderBrowserConsoleEvent = (event) => {
138
167
  if (typeof event.type === "string" && event.type.startsWith("trace:")) {
@@ -158,7 +187,7 @@ var renderBrowserConsoleEvent = (event) => {
158
187
  const moduleId = event.moduleId ?? "unknown";
159
188
  const causePretty = (() => {
160
189
  try {
161
- return import_effect3.Cause.pretty(event.cause, { renderErrorCause: true });
190
+ return import_effect3.Cause.pretty(event.cause);
162
191
  } catch {
163
192
  try {
164
193
  return JSON.stringify(event.cause, null, 2);
@@ -224,7 +253,7 @@ var browserConsoleSink = {
224
253
  return renderBrowserConsoleEvent(event);
225
254
  }
226
255
  };
227
- var browserConsoleLayer = import_effect3.Layer.locallyScoped(currentDebugSinks, [browserConsoleSink]);
256
+ var browserConsoleLayer = import_effect3.Layer.succeed(currentDebugSinks, [browserConsoleSink]);
228
257
  var browserDiagnosticConsoleSink = {
229
258
  record: (event) => {
230
259
  if (!isBrowser) {
@@ -233,114 +262,765 @@ var browserDiagnosticConsoleSink = {
233
262
  return event.type === "lifecycle:error" || event.type === "diagnostic" && event.severity !== "info" ? renderBrowserConsoleEvent(event) : import_effect3.Effect.void;
234
263
  }
235
264
  };
236
- var browserDiagnosticConsoleLayer = import_effect3.Layer.locallyScoped(currentDebugSinks, [browserDiagnosticConsoleSink]);
237
- var browserPrettyLoggerLayer = import_effect3.Logger.replace(
238
- import_effect3.Logger.defaultLogger,
239
- import_effect3.Logger.prettyLogger({ mode: "browser", colors: true })
265
+ var browserDiagnosticConsoleLayer = import_effect3.Layer.succeed(currentDebugSinks, [browserDiagnosticConsoleSink]);
266
+ var browserPrettyLoggerLayer = import_effect3.Layer.effect(
267
+ import_effect3.Logger.CurrentLoggers,
268
+ import_effect3.Effect.gen(function* () {
269
+ const current = yield* import_effect3.Effect.service(import_effect3.Logger.CurrentLoggers);
270
+ return new Set(
271
+ [...current].filter((logger) => logger !== import_effect3.Logger.defaultLogger).concat(import_effect3.Logger.consolePretty({ mode: "browser", colors: true }))
272
+ );
273
+ })
240
274
  );
275
+ var record = (event) => import_effect3.Effect.gen(function* () {
276
+ const sinks = yield* import_effect3.Effect.service(currentDebugSinks);
277
+ if (isErrorOnlyOnlySinks(sinks)) {
278
+ if (event.type === "lifecycle:error") {
279
+ yield* lifecycleErrorLog(event);
280
+ return;
281
+ }
282
+ if (event.type === "diagnostic" && event.severity !== "info") {
283
+ yield* diagnosticLog(event);
284
+ }
285
+ return;
286
+ }
287
+ if (sinks.length === 0) {
288
+ if (isBrowser) {
289
+ if (event.type === "lifecycle:error" || event.type === "diagnostic") {
290
+ yield* renderBrowserConsoleEvent(event);
291
+ }
292
+ return;
293
+ }
294
+ if (event.type === "lifecycle:error") {
295
+ yield* lifecycleErrorLog(event);
296
+ return;
297
+ }
298
+ if (event.type === "diagnostic") {
299
+ yield* diagnosticLog(event);
300
+ }
301
+ return;
302
+ }
303
+ if (typeof event.type === "string" && event.type.startsWith("trace:")) {
304
+ const mode = yield* import_effect3.Effect.service(currentTraceMode);
305
+ if (mode === "off") return;
306
+ }
307
+ const enriched = event;
308
+ const diagnosticsLevel = yield* import_effect3.Effect.service(currentDiagnosticsLevel);
309
+ let now;
310
+ const getNow = () => {
311
+ if (now === void 0) now = Date.now();
312
+ return now;
313
+ };
314
+ if (enriched.timestamp === void 0 && (diagnosticsLevel !== "off" || enriched.type === "lifecycle:error" || enriched.type === "diagnostic")) {
315
+ ;
316
+ enriched.timestamp = getNow();
317
+ }
318
+ if (diagnosticsLevel !== "off" && enriched.runtimeLabel === void 0) {
319
+ const runtimeLabel = yield* import_effect3.Effect.service(currentRuntimeLabel);
320
+ if (runtimeLabel) {
321
+ ;
322
+ enriched.runtimeLabel = runtimeLabel;
323
+ }
324
+ }
325
+ if (enriched.type === "diagnostic" && enriched.txnId === void 0) {
326
+ const txnId = yield* import_effect3.Effect.service(currentTxnId);
327
+ if (txnId) {
328
+ ;
329
+ enriched.txnId = txnId;
330
+ }
331
+ }
332
+ if (diagnosticsLevel !== "off" && enriched.type === "trace:effectop" && enriched.linkId === void 0) {
333
+ const maybeLinkId = yield* import_effect3.Effect.serviceOption(currentLinkId);
334
+ if (import_effect3.Option.isSome(maybeLinkId) && maybeLinkId.value) {
335
+ ;
336
+ enriched.linkId = maybeLinkId.value;
337
+ }
338
+ }
339
+ if (sinks.length === 1) {
340
+ yield* sinks[0].record(enriched);
341
+ return;
342
+ }
343
+ yield* import_effect3.Effect.forEach(sinks, (sink) => sink.record(enriched), { discard: true });
344
+ });
241
345
 
242
346
  // src/internal/runtime/core/Lifecycle.ts
243
- var LifecycleContext = import_effect4.Context.GenericTag("@logixjs/LifecycleManager");
347
+ var LifecycleContext = class extends import_effect4.ServiceMap.Service()("@logixjs/LifecycleManager") {
348
+ };
244
349
 
245
350
  // src/internal/runtime/core/ConvergeStaticIrCollector.ts
246
351
  var import_effect5 = require("effect");
247
- var currentConvergeStaticIrCollectors = import_effect5.FiberRef.unsafeMake([]);
352
+ var currentConvergeStaticIrCollectors = import_effect5.ServiceMap.Reference(
353
+ "@logixjs/core/ConvergeStaticIrCollectors",
354
+ {
355
+ defaultValue: () => []
356
+ }
357
+ );
248
358
 
249
359
  // src/internal/runtime/core/StateTransaction.ts
250
360
  var import_effect6 = require("effect");
251
361
 
252
362
  // src/internal/runtime/core/RuntimeKernel.ts
253
- var import_effect8 = require("effect");
363
+ var import_effect13 = require("effect");
254
364
 
255
365
  // src/internal/runtime/core/env.ts
366
+ var import_effect12 = require("effect");
367
+
368
+ // src/internal/runtime/core/HostScheduler.ts
369
+ var noopCancel = () => {
370
+ };
371
+ var safeNowMs = () => {
372
+ const perf = globalThis.performance;
373
+ if (perf && typeof perf.now === "function") {
374
+ try {
375
+ const v = perf.now();
376
+ if (typeof v === "number" && Number.isFinite(v)) return v;
377
+ } catch {
378
+ }
379
+ }
380
+ return Date.now();
381
+ };
382
+ var safeQueueMicrotask = (cb) => {
383
+ const qm = globalThis.queueMicrotask;
384
+ if (typeof qm === "function") {
385
+ try {
386
+ qm(cb);
387
+ return;
388
+ } catch {
389
+ }
390
+ }
391
+ try {
392
+ Promise.resolve().then(cb);
393
+ } catch {
394
+ setTimeout(cb, 0);
395
+ }
396
+ };
397
+ var safeSetTimeout = (ms, cb) => {
398
+ const id = setTimeout(cb, ms);
399
+ return () => {
400
+ try {
401
+ clearTimeout(id);
402
+ } catch {
403
+ }
404
+ };
405
+ };
406
+ var makeMessageChannelMacrotask = () => {
407
+ const MC = globalThis.MessageChannel;
408
+ if (typeof MC !== "function") return void 0;
409
+ let channel;
410
+ try {
411
+ channel = new MC();
412
+ } catch {
413
+ return void 0;
414
+ }
415
+ const queue = [];
416
+ let scheduled = false;
417
+ const flush = () => {
418
+ scheduled = false;
419
+ const tasks = queue.splice(0, queue.length);
420
+ for (const t of tasks) {
421
+ if (t.canceled) continue;
422
+ try {
423
+ t.cb();
424
+ } catch {
425
+ }
426
+ }
427
+ };
428
+ try {
429
+ channel.port1.onmessage = flush;
430
+ } catch {
431
+ return void 0;
432
+ }
433
+ const schedule = (cb) => {
434
+ const task = { canceled: false, cb };
435
+ queue.push(task);
436
+ if (!scheduled) {
437
+ scheduled = true;
438
+ try {
439
+ channel.port2.postMessage(void 0);
440
+ } catch {
441
+ scheduled = false;
442
+ return safeSetTimeout(0, cb);
443
+ }
444
+ }
445
+ return () => {
446
+ task.canceled = true;
447
+ };
448
+ };
449
+ return schedule;
450
+ };
451
+ var makeSetImmediateMacrotask = () => {
452
+ const si = globalThis.setImmediate;
453
+ const ci = globalThis.clearImmediate;
454
+ if (typeof si !== "function") return void 0;
455
+ return (cb) => {
456
+ let id;
457
+ try {
458
+ id = si(cb);
459
+ } catch {
460
+ return safeSetTimeout(0, cb);
461
+ }
462
+ return () => {
463
+ if (typeof ci !== "function") return;
464
+ try {
465
+ ci(id);
466
+ } catch {
467
+ }
468
+ };
469
+ };
470
+ };
471
+ var makeRaf = () => {
472
+ const raf = globalThis.requestAnimationFrame;
473
+ const cancel = globalThis.cancelAnimationFrame;
474
+ if (typeof raf !== "function") return void 0;
475
+ return (cb) => {
476
+ let id;
477
+ try {
478
+ id = raf(cb);
479
+ } catch {
480
+ return noopCancel;
481
+ }
482
+ return () => {
483
+ if (typeof cancel !== "function") return;
484
+ try {
485
+ cancel(id);
486
+ } catch {
487
+ }
488
+ };
489
+ };
490
+ };
491
+ var makeDefaultHostScheduler = () => {
492
+ const macrotask = makeSetImmediateMacrotask() ?? makeMessageChannelMacrotask() ?? ((cb) => safeSetTimeout(0, cb));
493
+ const raf = makeRaf();
494
+ return {
495
+ nowMs: safeNowMs,
496
+ scheduleMicrotask: safeQueueMicrotask,
497
+ scheduleMacrotask: macrotask,
498
+ scheduleAnimationFrame: (cb) => raf?.(cb) ?? macrotask(cb),
499
+ scheduleTimeout: safeSetTimeout
500
+ };
501
+ };
502
+ var globalHostScheduler;
503
+ var getGlobalHostScheduler = () => {
504
+ globalHostScheduler ?? (globalHostScheduler = makeDefaultHostScheduler());
505
+ return globalHostScheduler;
506
+ };
507
+
508
+ // src/internal/runtime/core/RuntimeStore.ts
509
+ var parseTopicKey = (topicKey) => {
510
+ const idx = topicKey.indexOf("::");
511
+ if (idx <= 0) return void 0;
512
+ const moduleId = topicKey.slice(0, idx);
513
+ const rest = topicKey.slice(idx + 2);
514
+ if (rest.length === 0) return void 0;
515
+ const idx2 = rest.indexOf("::");
516
+ if (idx2 < 0) {
517
+ return { kind: "module", moduleInstanceKey: `${moduleId}::${rest}` };
518
+ }
519
+ const instanceId = rest.slice(0, idx2);
520
+ const suffix = rest.slice(idx2 + 2);
521
+ if (suffix.startsWith("rq:")) {
522
+ const selectorId = suffix.slice("rq:".length);
523
+ if (selectorId.length === 0) return void 0;
524
+ return {
525
+ kind: "readQuery",
526
+ moduleInstanceKey: `${moduleId}::${instanceId}`,
527
+ selectorId
528
+ };
529
+ }
530
+ return { kind: "module", moduleInstanceKey: `${moduleId}::${instanceId}` };
531
+ };
532
+ var EMPTY_LISTENER_SNAPSHOT = [];
533
+ var NO_CHANGED_TOPIC_LISTENERS = [];
534
+ var makeRuntimeStore = () => {
535
+ let tickSeq = 0;
536
+ const moduleStates = /* @__PURE__ */ new Map();
537
+ const topicVersions = /* @__PURE__ */ new Map();
538
+ const topicPriorities = /* @__PURE__ */ new Map();
539
+ const listenersByTopic = /* @__PURE__ */ new Map();
540
+ const subscriberCountByModule = /* @__PURE__ */ new Map();
541
+ const getTopicVersion = (topicKey) => topicVersions.get(topicKey) ?? 0;
542
+ const getTopicPriority = (topicKey) => topicPriorities.get(topicKey) ?? "normal";
543
+ const commitTopicBump = (topicKey, priority) => {
544
+ const prev = topicVersions.get(topicKey) ?? 0;
545
+ topicVersions.set(topicKey, prev + 1);
546
+ topicPriorities.set(topicKey, priority);
547
+ };
548
+ const refreshTopicSnapshot = (state) => {
549
+ state.snapshot = Array.from(state.listeners);
550
+ };
551
+ const subscribeTopic = (topicKey, listener) => {
552
+ const info = parseTopicKey(topicKey);
553
+ const existing = listenersByTopic.get(topicKey);
554
+ const state = existing ?? { listeners: /* @__PURE__ */ new Set(), snapshot: EMPTY_LISTENER_SNAPSHOT };
555
+ const alreadyHas = state.listeners.has(listener);
556
+ if (!alreadyHas) {
557
+ state.listeners.add(listener);
558
+ refreshTopicSnapshot(state);
559
+ }
560
+ if (!existing) {
561
+ listenersByTopic.set(topicKey, state);
562
+ }
563
+ if (!alreadyHas && info) {
564
+ const prev = subscriberCountByModule.get(info.moduleInstanceKey) ?? 0;
565
+ subscriberCountByModule.set(info.moduleInstanceKey, prev + 1);
566
+ }
567
+ return () => {
568
+ const currentState = listenersByTopic.get(topicKey);
569
+ if (!currentState) return;
570
+ const deleted = currentState.listeners.delete(listener);
571
+ if (deleted && info) {
572
+ const prev = subscriberCountByModule.get(info.moduleInstanceKey) ?? 0;
573
+ const next = prev - 1;
574
+ if (next <= 0) {
575
+ subscriberCountByModule.delete(info.moduleInstanceKey);
576
+ } else {
577
+ subscriberCountByModule.set(info.moduleInstanceKey, next);
578
+ }
579
+ }
580
+ if (currentState.listeners.size === 0) {
581
+ listenersByTopic.delete(topicKey);
582
+ } else if (deleted) {
583
+ refreshTopicSnapshot(currentState);
584
+ }
585
+ };
586
+ };
587
+ const getTopicSubscriberCount = (topicKey) => listenersByTopic.get(topicKey)?.listeners.size ?? 0;
588
+ const getModuleSubscriberCount = (moduleInstanceKey) => subscriberCountByModule.get(moduleInstanceKey) ?? 0;
589
+ const registerModuleInstance = (args) => {
590
+ moduleStates.set(args.moduleInstanceKey, args.initialState);
591
+ if (!topicVersions.has(args.moduleInstanceKey)) {
592
+ topicVersions.set(args.moduleInstanceKey, 0);
593
+ topicPriorities.set(args.moduleInstanceKey, "normal");
594
+ }
595
+ };
596
+ const unregisterModuleInstance = (moduleInstanceKey) => {
597
+ moduleStates.delete(moduleInstanceKey);
598
+ };
599
+ const commitTick = (args) => {
600
+ tickSeq = args.tickSeq;
601
+ for (const [key, commit] of args.accepted.modules) {
602
+ moduleStates.set(key, commit.state);
603
+ }
604
+ if (args.accepted.dirtyTopics.size === 0) {
605
+ return {
606
+ changedTopicListeners: NO_CHANGED_TOPIC_LISTENERS
607
+ };
608
+ }
609
+ if (args.onListener) {
610
+ let firstTopicListeners;
611
+ let secondTopicListeners;
612
+ let restTopicListeners;
613
+ for (const [topicKey, priority] of args.accepted.dirtyTopics) {
614
+ commitTopicBump(topicKey, priority);
615
+ const listeners = listenersByTopic.get(topicKey)?.snapshot ?? EMPTY_LISTENER_SNAPSHOT;
616
+ if (listeners.length === 0) {
617
+ continue;
618
+ }
619
+ if (!firstTopicListeners) {
620
+ firstTopicListeners = listeners;
621
+ continue;
622
+ }
623
+ if (!secondTopicListeners) {
624
+ secondTopicListeners = listeners;
625
+ continue;
626
+ }
627
+ if (!restTopicListeners) {
628
+ restTopicListeners = [];
629
+ }
630
+ restTopicListeners.push(listeners);
631
+ }
632
+ if (firstTopicListeners) {
633
+ for (const listener of firstTopicListeners) {
634
+ try {
635
+ args.onListener(listener);
636
+ } catch {
637
+ }
638
+ }
639
+ }
640
+ if (secondTopicListeners) {
641
+ for (const listener of secondTopicListeners) {
642
+ try {
643
+ args.onListener(listener);
644
+ } catch {
645
+ }
646
+ }
647
+ }
648
+ if (restTopicListeners) {
649
+ for (const listeners of restTopicListeners) {
650
+ for (const listener of listeners) {
651
+ try {
652
+ args.onListener(listener);
653
+ } catch {
654
+ }
655
+ }
656
+ }
657
+ }
658
+ return {
659
+ changedTopicListeners: NO_CHANGED_TOPIC_LISTENERS
660
+ };
661
+ }
662
+ let singleTopicListeners;
663
+ let flattenedTopicListeners;
664
+ for (const [topicKey, priority] of args.accepted.dirtyTopics) {
665
+ commitTopicBump(topicKey, priority);
666
+ const listeners = listenersByTopic.get(topicKey)?.snapshot ?? EMPTY_LISTENER_SNAPSHOT;
667
+ if (listeners.length === 0) {
668
+ continue;
669
+ }
670
+ if (flattenedTopicListeners) {
671
+ for (const listener of listeners) {
672
+ flattenedTopicListeners.push(listener);
673
+ }
674
+ continue;
675
+ }
676
+ if (!singleTopicListeners) {
677
+ singleTopicListeners = listeners;
678
+ continue;
679
+ }
680
+ flattenedTopicListeners = Array.from(singleTopicListeners);
681
+ for (const listener of listeners) {
682
+ flattenedTopicListeners.push(listener);
683
+ }
684
+ }
685
+ return {
686
+ changedTopicListeners: flattenedTopicListeners ?? singleTopicListeners ?? NO_CHANGED_TOPIC_LISTENERS
687
+ };
688
+ };
689
+ const getModuleState = (moduleInstanceKey) => moduleStates.get(moduleInstanceKey);
690
+ const dispose = () => {
691
+ moduleStates.clear();
692
+ topicVersions.clear();
693
+ topicPriorities.clear();
694
+ listenersByTopic.clear();
695
+ subscriberCountByModule.clear();
696
+ };
697
+ return {
698
+ getTickSeq: () => tickSeq,
699
+ getModuleState,
700
+ getTopicVersion,
701
+ getTopicPriority,
702
+ subscribeTopic,
703
+ getTopicSubscriberCount,
704
+ getModuleSubscriberCount,
705
+ registerModuleInstance,
706
+ unregisterModuleInstance,
707
+ commitTick,
708
+ dispose
709
+ };
710
+ };
711
+
712
+ // src/internal/runtime/core/TickScheduler.ts
713
+ var import_effect10 = require("effect");
714
+
715
+ // src/internal/runtime/core/TaskRunner.ts
716
+ var import_effect9 = require("effect");
717
+
718
+ // src/internal/runtime/core/ModeRunner.ts
719
+ var import_effect8 = require("effect");
720
+
721
+ // src/internal/runtime/core/LatestFiberSlot.ts
256
722
  var import_effect7 = require("effect");
257
- var StateTransactionConfigTagImpl = class extends import_effect7.Context.Tag("@logixjs/core/StateTransactionRuntimeConfig")() {
723
+
724
+ // src/internal/runtime/core/TaskRunner.ts
725
+ var inSyncTransactionFiber = import_effect9.ServiceMap.Reference("@logixjs/core/TaskRunner.inSyncTransactionFiber", {
726
+ defaultValue: () => false
727
+ });
728
+ var forceSourceRefresh = import_effect9.ServiceMap.Reference("@logixjs/core/TaskRunner.forceSourceRefresh", {
729
+ defaultValue: () => false
730
+ });
731
+
732
+ // src/internal/runtime/core/DeclarativeLinkRuntime.ts
733
+ var import_effect11 = require("effect");
734
+ var makeDeclarativeLinkRuntime = () => {
735
+ const moduleAsSourceById = /* @__PURE__ */ new Map();
736
+ const moduleAsSourceIdsBySource = /* @__PURE__ */ new Map();
737
+ const declarativeById = /* @__PURE__ */ new Map();
738
+ const declarativeReadNodesBySource = /* @__PURE__ */ new Map();
739
+ const registerModuleAsSourceLink = (link2) => {
740
+ const stored = {
741
+ ...link2,
742
+ hasValue: false,
743
+ lastValue: void 0
744
+ };
745
+ moduleAsSourceById.set(link2.id, stored);
746
+ const set = moduleAsSourceIdsBySource.get(link2.sourceModuleInstanceKey) ?? /* @__PURE__ */ new Set();
747
+ set.add(link2.id);
748
+ moduleAsSourceIdsBySource.set(link2.sourceModuleInstanceKey, set);
749
+ return () => {
750
+ moduleAsSourceById.delete(link2.id);
751
+ const current = moduleAsSourceIdsBySource.get(link2.sourceModuleInstanceKey);
752
+ if (!current) return;
753
+ current.delete(link2.id);
754
+ if (current.size === 0) {
755
+ moduleAsSourceIdsBySource.delete(link2.sourceModuleInstanceKey);
756
+ }
757
+ };
758
+ };
759
+ const registerDeclarativeLink = (link2) => {
760
+ const readNodeById = /* @__PURE__ */ new Map();
761
+ for (const n of link2.readNodes) {
762
+ readNodeById.set(n.nodeId, n);
763
+ }
764
+ const dispatchNodeById = /* @__PURE__ */ new Map();
765
+ for (const n of link2.dispatchNodes) {
766
+ dispatchNodeById.set(n.nodeId, n);
767
+ }
768
+ const incomingByDispatch = /* @__PURE__ */ new Map();
769
+ for (const e of link2.ir.edges) {
770
+ const to = e.to;
771
+ const isDispatch = dispatchNodeById.has(to);
772
+ if (!isDispatch) continue;
773
+ incomingByDispatch.set(to, (incomingByDispatch.get(to) ?? 0) + 1);
774
+ const count = incomingByDispatch.get(to) ?? 0;
775
+ if (count > 1) {
776
+ throw new Error(
777
+ `[DeclarativeLinkRuntime] Invalid DeclarativeLinkIR: dispatch node has multiple incoming edges (linkId=${link2.linkId}, nodeId=${to}).`
778
+ );
779
+ }
780
+ }
781
+ const dispatchTargetsByReadNode = /* @__PURE__ */ new Map();
782
+ for (const e of link2.ir.edges) {
783
+ const from = e.from;
784
+ const to = e.to;
785
+ if (!readNodeById.has(from)) continue;
786
+ if (!dispatchNodeById.has(to)) continue;
787
+ const list = dispatchTargetsByReadNode.get(from) ?? [];
788
+ list.push(to);
789
+ dispatchTargetsByReadNode.set(from, list);
790
+ }
791
+ const stored = {
792
+ ...link2,
793
+ readNodeById,
794
+ dispatchNodeById,
795
+ dispatchTargetsByReadNode,
796
+ readNodeState: /* @__PURE__ */ new Map()
797
+ };
798
+ declarativeById.set(link2.linkId, stored);
799
+ for (const n of link2.readNodes) {
800
+ const list = declarativeReadNodesBySource.get(n.moduleInstanceKey) ?? [];
801
+ list.push({ linkId: link2.linkId, nodeId: n.nodeId });
802
+ declarativeReadNodesBySource.set(n.moduleInstanceKey, list);
803
+ }
804
+ return () => {
805
+ declarativeById.delete(link2.linkId);
806
+ for (const n of link2.readNodes) {
807
+ const list = declarativeReadNodesBySource.get(n.moduleInstanceKey);
808
+ if (!list) continue;
809
+ const next = list.filter((x) => !(x.linkId === link2.linkId && x.nodeId === n.nodeId));
810
+ if (next.length === 0) {
811
+ declarativeReadNodesBySource.delete(n.moduleInstanceKey);
812
+ } else {
813
+ declarativeReadNodesBySource.set(n.moduleInstanceKey, next);
814
+ }
815
+ }
816
+ };
817
+ };
818
+ const applyForSources = (args) => import_effect11.Effect.gen(function* () {
819
+ let scheduled = false;
820
+ for (const sourceKey of args.changedModuleInstanceKeys) {
821
+ const ids = moduleAsSourceIdsBySource.get(sourceKey);
822
+ if (!ids || ids.size === 0) continue;
823
+ const commit = args.acceptedModules.get(sourceKey);
824
+ if (!commit) continue;
825
+ for (const id of ids) {
826
+ const link2 = moduleAsSourceById.get(id);
827
+ if (!link2) continue;
828
+ let selected;
829
+ try {
830
+ selected = link2.readQuery.select(commit.state);
831
+ } catch {
832
+ continue;
833
+ }
834
+ const nextValue = link2.computeValue(selected);
835
+ if (link2.hasValue && link2.equalsValue(link2.lastValue, nextValue)) {
836
+ continue;
837
+ }
838
+ link2.hasValue = true;
839
+ link2.lastValue = nextValue;
840
+ scheduled = true;
841
+ yield* link2.applyValue(nextValue);
842
+ }
843
+ }
844
+ for (const sourceKey of args.changedModuleInstanceKeys) {
845
+ const refs = declarativeReadNodesBySource.get(sourceKey);
846
+ if (!refs || refs.length === 0) continue;
847
+ const commit = args.acceptedModules.get(sourceKey);
848
+ if (!commit) continue;
849
+ for (const ref of refs) {
850
+ const link2 = declarativeById.get(ref.linkId);
851
+ if (!link2) continue;
852
+ const readNode = link2.readNodeById.get(ref.nodeId);
853
+ if (!readNode) continue;
854
+ let value;
855
+ try {
856
+ value = readNode.readQuery.select(commit.state);
857
+ } catch {
858
+ continue;
859
+ }
860
+ const state = link2.readNodeState.get(ref.nodeId) ?? { hasValue: false, lastValue: void 0 };
861
+ const changed = !state.hasValue || !Object.is(state.lastValue, value);
862
+ if (!changed) continue;
863
+ state.hasValue = true;
864
+ state.lastValue = value;
865
+ link2.readNodeState.set(ref.nodeId, state);
866
+ const targets = link2.dispatchTargetsByReadNode.get(ref.nodeId) ?? [];
867
+ for (const dispatchNodeId of targets) {
868
+ const node = link2.dispatchNodeById.get(dispatchNodeId);
869
+ if (!node) continue;
870
+ scheduled = true;
871
+ yield* node.dispatch(value);
872
+ }
873
+ }
874
+ }
875
+ return { scheduled };
876
+ });
877
+ return {
878
+ registerModuleAsSourceLink,
879
+ registerDeclarativeLink,
880
+ applyForSources
881
+ };
882
+ };
883
+
884
+ // src/internal/runtime/core/env.ts
885
+ var StateTransactionConfigTagImpl = class extends import_effect12.ServiceMap.Service()("@logixjs/core/StateTransactionRuntimeConfig") {
886
+ };
887
+ var ReadQueryStrictGateConfigTagImpl = class extends import_effect12.ServiceMap.Service()("@logixjs/core/ReadQueryStrictGateRuntimeConfig") {
258
888
  };
259
- var ReadQueryStrictGateConfigTagImpl = class extends import_effect7.Context.Tag("@logixjs/core/ReadQueryStrictGateRuntimeConfig")() {
889
+ var ReplayModeConfigTagImpl = class extends import_effect12.ServiceMap.Service()("@logixjs/core/ReplayModeConfig") {
260
890
  };
261
- var ReplayModeConfigTagImpl = class extends import_effect7.Context.Tag("@logixjs/core/ReplayModeConfig")() {
891
+ var StateTransactionOverridesTagImpl = class extends import_effect12.ServiceMap.Service()("@logixjs/core/StateTransactionOverrides") {
262
892
  };
263
- var StateTransactionOverridesTagImpl = class extends import_effect7.Context.Tag("@logixjs/core/StateTransactionOverrides")() {
893
+ var SchedulingPolicySurfaceTagImpl = class extends import_effect12.ServiceMap.Service()("@logixjs/core/SchedulingPolicySurface") {
264
894
  };
265
- var ConcurrencyPolicyTagImpl = class extends import_effect7.Context.Tag("@logixjs/core/ConcurrencyPolicy")() {
895
+ var SchedulingPolicySurfaceOverridesTagImpl = class extends import_effect12.ServiceMap.Service()("@logixjs/core/SchedulingPolicySurfaceOverrides") {
266
896
  };
267
- var ConcurrencyPolicyOverridesTagImpl = class extends import_effect7.Context.Tag("@logixjs/core/ConcurrencyPolicyOverrides")() {
897
+ var RuntimeStoreTag = class extends import_effect12.ServiceMap.Service()("@logixjs/core/RuntimeStore") {
898
+ };
899
+ var runtimeStoreLayer = import_effect12.Layer.effect(
900
+ RuntimeStoreTag,
901
+ import_effect12.Effect.acquireRelease(
902
+ import_effect12.Effect.sync(() => makeRuntimeStore()),
903
+ (store) => import_effect12.Effect.sync(() => store.dispose())
904
+ )
905
+ );
906
+ var HostSchedulerTag = class extends import_effect12.ServiceMap.Service()("@logixjs/core/HostScheduler") {
907
+ };
908
+ var hostSchedulerLayer = import_effect12.Layer.succeed(
909
+ HostSchedulerTag,
910
+ getGlobalHostScheduler()
911
+ );
912
+ var DeclarativeLinkRuntimeTag = class extends import_effect12.ServiceMap.Service()("@logixjs/core/DeclarativeLinkRuntime") {
913
+ };
914
+ var declarativeLinkRuntimeLayer = import_effect12.Layer.succeed(
915
+ DeclarativeLinkRuntimeTag,
916
+ makeDeclarativeLinkRuntime()
917
+ );
918
+ var TickSchedulerTag = class extends import_effect12.ServiceMap.Service()("@logixjs/core/TickScheduler") {
268
919
  };
269
920
 
270
921
  // src/internal/runtime/core/RuntimeKernel.ts
271
- var RuntimeServicesRuntimeConfigTagImpl = class extends import_effect8.Context.Tag("@logixjs/core/RuntimeServicesRuntimeConfig")() {
922
+ var RuntimeServicesRuntimeConfigTagImpl = class extends import_effect13.ServiceMap.Service()("@logixjs/core/RuntimeServicesRuntimeConfig") {
272
923
  };
273
- var RuntimeServicesProviderOverridesTagImpl = class extends import_effect8.Context.Tag("@logixjs/core/RuntimeServicesProviderOverrides")() {
924
+ var RuntimeServicesProviderOverridesTagImpl = class extends import_effect13.ServiceMap.Service()("@logixjs/core/RuntimeServicesProviderOverrides") {
274
925
  };
275
- var RuntimeServicesInstanceOverridesTagImpl = class extends import_effect8.Context.Tag("@logixjs/core/RuntimeServicesInstanceOverrides")() {
926
+ var RuntimeServicesInstanceOverridesTagImpl = class extends import_effect13.ServiceMap.Service()("@logixjs/core/RuntimeServicesInstanceOverrides") {
276
927
  };
277
- var FullCutoverGateModeTagImpl = class extends import_effect8.Context.Tag("@logixjs/core/FullCutoverGateMode")() {
928
+ var FullCutoverGateModeTagImpl = class extends import_effect13.ServiceMap.Service()("@logixjs/core/FullCutoverGateMode") {
278
929
  };
279
- var RuntimeServicesRegistryTagImpl = class extends import_effect8.Context.Tag("@logixjs/core/RuntimeServicesRegistry")() {
930
+ var RuntimeServicesRegistryTagImpl = class extends import_effect13.ServiceMap.Service()("@logixjs/core/RuntimeServicesRegistry") {
280
931
  };
281
932
 
282
933
  // src/internal/runtime/core/KernelRef.ts
283
- var import_effect9 = require("effect");
284
- var KernelImplementationRefTagImpl = class extends import_effect9.Context.Tag("@logixjs/core/KernelImplementationRef")() {
934
+ var import_effect14 = require("effect");
935
+ var KernelImplementationRefTagImpl = class extends import_effect14.ServiceMap.Service()("@logixjs/core/KernelImplementationRef") {
285
936
  };
286
937
 
287
938
  // src/internal/runtime/core/RuntimeServiceBuiltins.ts
288
- var import_effect10 = require("effect");
289
- var RuntimeServiceBuiltinsTag = class extends import_effect10.Context.Tag("@logixjs/core/RuntimeServiceBuiltins")() {
939
+ var import_effect15 = require("effect");
940
+ var RuntimeServiceBuiltinsTag = class extends import_effect15.ServiceMap.Service()("@logixjs/core/RuntimeServiceBuiltins") {
290
941
  };
291
942
 
292
943
  // src/internal/observability/evidenceCollector.ts
293
- var import_effect12 = require("effect");
944
+ var import_effect17 = require("effect");
294
945
 
295
946
  // src/internal/observability/runSession.ts
296
- var import_effect11 = require("effect");
297
- var RunSessionTagImpl = class extends import_effect11.Context.Tag("@logixjs/core/RunSession")() {
947
+ var import_effect16 = require("effect");
948
+ var RunSessionTagImpl = class extends import_effect16.ServiceMap.Service()("@logixjs/core/RunSession") {
298
949
  };
299
950
 
300
951
  // src/internal/observability/evidenceCollector.ts
301
- var EvidenceCollectorTagImpl = class extends import_effect12.Context.Tag("@logixjs/core/EvidenceCollector")() {
952
+ var EvidenceCollectorTagImpl = class extends import_effect17.ServiceMap.Service()("@logixjs/core/EvidenceCollector") {
302
953
  };
303
954
 
304
955
  // src/internal/runtime/core/ModuleRuntime.operation.ts
305
- var import_effect14 = require("effect");
956
+ var import_effect19 = require("effect");
306
957
 
307
958
  // src/internal/effect-op.ts
308
- var import_effect13 = require("effect");
959
+ var import_effect18 = require("effect");
309
960
 
310
961
  // src/internal/runtime/core/ModuleRuntime.dispatch.ts
311
- var import_effect16 = require("effect");
962
+ var import_effect21 = require("effect");
312
963
 
313
964
  // src/internal/runtime/core/ReducerDiagnostics.ts
314
- var import_effect15 = require("effect");
965
+ var import_effect20 = require("effect");
966
+
967
+ // src/internal/runtime/core/mutativePatches.ts
968
+ var import_mutative = require("mutative");
315
969
 
316
970
  // src/internal/runtime/core/ModuleRuntime.effects.ts
317
- var import_effect17 = require("effect");
971
+ var import_effect22 = require("effect");
318
972
 
319
973
  // src/internal/runtime/core/ModuleRuntime.transaction.ts
320
- var import_effect27 = require("effect");
974
+ var import_effect33 = require("effect");
321
975
 
322
- // src/internal/runtime/core/TaskRunner.ts
323
- var import_effect18 = require("effect");
324
- var inSyncTransactionFiber = import_effect18.FiberRef.unsafeMake(false);
325
- var forceSourceRefresh = import_effect18.FiberRef.unsafeMake(false);
976
+ // src/internal/state-trait/converge-in-transaction.impl.ts
977
+ var import_effect26 = require("effect");
326
978
 
327
- // src/internal/state-trait/converge-in-transaction.ts
328
- var import_effect22 = require("effect");
979
+ // src/internal/digest.ts
980
+ var stableStringify = (value) => {
981
+ if (value === null) return "null";
982
+ const t = typeof value;
983
+ if (t === "string") return JSON.stringify(value);
984
+ if (t === "number") return Number.isFinite(value) ? String(value) : "null";
985
+ if (t === "boolean") return value ? "true" : "false";
986
+ if (Array.isArray(value)) {
987
+ return `[${value.map(stableStringify).join(",")}]`;
988
+ }
989
+ if (t === "object") {
990
+ const record2 = value;
991
+ const keys = Object.keys(record2).sort();
992
+ return `{${keys.map((k) => `${JSON.stringify(k)}:${stableStringify(record2[k])}`).join(",")}}`;
993
+ }
994
+ return "null";
995
+ };
996
+ var fnv1a32 = (input) => {
997
+ let hash = 2166136261;
998
+ for (let i = 0; i < input.length; i++) {
999
+ hash ^= input.charCodeAt(i);
1000
+ hash = hash * 16777619 >>> 0;
1001
+ }
1002
+ return hash.toString(16).padStart(8, "0");
1003
+ };
329
1004
 
330
1005
  // src/internal/state-trait/converge-diagnostics.ts
331
- var import_effect19 = require("effect");
1006
+ var import_effect23 = require("effect");
332
1007
  var SchemaAST = __toESM(require("effect/SchemaAST"), 1);
333
1008
 
334
1009
  // src/internal/state-trait/exec-vm-mode.ts
335
- var import_effect20 = require("effect");
336
- var currentExecVmMode = import_effect20.FiberRef.unsafeMake(false);
1010
+ var import_effect24 = require("effect");
1011
+ var currentExecVmMode = import_effect24.ServiceMap.Reference("@logixjs/core/ExecVmMode", {
1012
+ defaultValue: () => false
1013
+ });
337
1014
 
338
1015
  // src/internal/state-trait/converge-step.ts
339
- var import_effect21 = require("effect");
1016
+ var import_effect25 = require("effect");
340
1017
 
341
- // src/internal/state-trait/validate.ts
342
- var import_effect23 = require("effect");
343
- var import_mutative = require("mutative");
1018
+ // src/internal/state-trait/converge-in-transaction.impl.ts
1019
+ var EMPTY_INT32 = new Int32Array(0);
1020
+
1021
+ // src/internal/state-trait/validate.impl.ts
1022
+ var import_effect27 = require("effect");
1023
+ var import_mutative2 = require("mutative");
344
1024
  var nowMs = (() => {
345
1025
  const perf = globalThis.performance;
346
1026
  if (perf && typeof perf.now === "function") {
@@ -349,53 +1029,65 @@ var nowMs = (() => {
349
1029
  return () => Date.now();
350
1030
  })();
351
1031
 
352
- // src/internal/state-trait/source.ts
353
- var import_effect26 = require("effect");
354
- var import_mutative2 = require("mutative");
1032
+ // src/internal/state-trait/source.impl.ts
1033
+ var import_effect30 = require("effect");
1034
+ var import_mutative3 = require("mutative");
355
1035
 
356
1036
  // src/internal/resource.ts
357
- var import_effect24 = require("effect");
358
- var ResourceRegistryTag = class extends import_effect24.Context.Tag("@logixjs/core/ResourceRegistry")() {
1037
+ var import_effect28 = require("effect");
1038
+ var ResourceRegistryTag = class extends import_effect28.ServiceMap.Service()("@logixjs/core/ResourceRegistry") {
359
1039
  };
360
1040
 
361
1041
  // src/internal/runtime/core/ReplayLog.ts
362
- var import_effect25 = require("effect");
363
- var ReplayLog = class extends import_effect25.Context.Tag("@logixjs/core/ReplayLog")() {
1042
+ var import_effect29 = require("effect");
1043
+ var ReplayLog = class extends import_effect29.ServiceMap.Service()("@logixjs/core/ReplayLog") {
364
1044
  };
365
- var snapshot = import_effect25.Effect.gen(function* () {
1045
+ var snapshot = import_effect29.Effect.gen(function* () {
366
1046
  const log = yield* ReplayLog;
367
1047
  return yield* log.snapshot;
368
1048
  });
369
- var resetCursor = import_effect25.Effect.gen(function* () {
1049
+ var resetCursor = import_effect29.Effect.gen(function* () {
370
1050
  const log = yield* ReplayLog;
371
1051
  yield* log.resetCursor;
372
1052
  });
373
1053
 
1054
+ // src/internal/runtime/core/ModuleRuntime.txnQueue.ts
1055
+ var import_effect31 = require("effect");
1056
+ var currentTxnQueuePhaseTiming = import_effect31.ServiceMap.Reference(
1057
+ "@logixjs/core/TxnQueue.currentTxnQueuePhaseTiming",
1058
+ {
1059
+ defaultValue: () => void 0
1060
+ }
1061
+ );
1062
+
1063
+ // src/internal/runtime/core/runner/SyncEffectRunner.ts
1064
+ var import_effect32 = require("effect");
1065
+
374
1066
  // src/internal/runtime/core/ModuleRuntime.concurrencyPolicy.ts
375
- var import_effect28 = require("effect");
1067
+ var import_effect34 = require("effect");
376
1068
 
377
1069
  // src/internal/runtime/core/ModuleRuntime.txnLanePolicy.ts
378
- var import_effect29 = require("effect");
1070
+ var import_effect35 = require("effect");
379
1071
 
380
1072
  // src/internal/runtime/core/ModuleRuntime.traitConvergeConfig.ts
381
- var import_effect30 = require("effect");
1073
+ var import_effect36 = require("effect");
382
1074
 
383
1075
  // src/internal/state-trait/build.ts
384
1076
  var SchemaAST2 = __toESM(require("effect/SchemaAST"), 1);
385
1077
 
386
1078
  // src/internal/runtime/core/ModuleRuntime.internalHooks.ts
387
- var import_effect31 = require("effect");
1079
+ var import_effect37 = require("effect");
388
1080
 
389
1081
  // src/internal/runtime/core/RootContext.ts
390
- var import_effect32 = require("effect");
391
- var RootContextTagImpl = class extends import_effect32.Context.Tag("@logixjs/core/RootContext")() {
1082
+ var import_effect38 = require("effect");
1083
+ var RootContextTagImpl = class extends import_effect38.ServiceMap.Service()("@logixjs/core/RootContext") {
392
1084
  };
393
1085
 
394
- // src/internal/runtime/core/process/ProcessRuntime.ts
395
- var import_effect34 = require("effect");
1086
+ // src/internal/runtime/core/process/ProcessRuntime.make.ts
1087
+ var import_effect42 = require("effect");
396
1088
 
397
1089
  // src/internal/runtime/core/process/concurrency.ts
398
- var import_effect33 = require("effect");
1090
+ var import_effect39 = require("effect");
399
1091
 
400
1092
  // src/internal/runtime/core/process/events.ts
401
1093
  var PROCESS_EVENT_MAX_BYTES = 4 * 1024;
@@ -418,66 +1110,384 @@ var attachMeta = (effect, meta) => {
418
1110
  // src/internal/runtime/core/process/selectorSchema.ts
419
1111
  var SchemaAST3 = __toESM(require("effect/SchemaAST"), 1);
420
1112
 
421
- // src/internal/runtime/core/process/ProcessRuntime.ts
422
- var ProcessRuntimeTag = class extends import_effect34.Context.Tag("@logixjs/core/ProcessRuntime")() {
1113
+ // src/internal/runtime/core/process/triggerStreams.ts
1114
+ var import_effect40 = require("effect");
1115
+
1116
+ // src/internal/runtime/core/ReadQuery.ts
1117
+ function isReadQuery(input) {
1118
+ if (!input || typeof input !== "object" && typeof input !== "function") return false;
1119
+ const maybe = input;
1120
+ return typeof maybe.selectorId === "string" && typeof maybe.select === "function" && Array.isArray(maybe.reads);
1121
+ }
1122
+ var normalizeReads = (reads) => {
1123
+ const unique = [];
1124
+ const seen = /* @__PURE__ */ new Set();
1125
+ for (const r of reads) {
1126
+ const key = typeof r === "number" ? `n:${r}` : `s:${r}`;
1127
+ if (seen.has(key)) continue;
1128
+ seen.add(key);
1129
+ unique.push(r);
1130
+ }
1131
+ return unique.slice().sort();
1132
+ };
1133
+ var toHash32Number = (hex) => Number.parseInt(hex, 16);
1134
+ var makeReadsDigest = (reads) => {
1135
+ const normalized = normalizeReads(reads);
1136
+ return {
1137
+ count: normalized.length,
1138
+ hash: toHash32Number(fnv1a32(stableStringify(normalized)))
1139
+ };
1140
+ };
1141
+ var computeSelectorId = (value) => `rq_${fnv1a32(stableStringify(value))}`;
1142
+ var nextUnstableSelectorSeq = 0;
1143
+ var unstableSelectorIdByFn = /* @__PURE__ */ new WeakMap();
1144
+ var computeUnstableSelectorId = (selector) => {
1145
+ const existing = unstableSelectorIdByFn.get(selector);
1146
+ if (existing) return existing;
1147
+ nextUnstableSelectorSeq += 1;
1148
+ const selectorId = `rq_u${nextUnstableSelectorSeq}`;
1149
+ unstableSelectorIdByFn.set(selector, selectorId);
1150
+ return selectorId;
1151
+ };
1152
+ var unwrapParens = (input) => {
1153
+ const trimmed = input.trim();
1154
+ if (trimmed.startsWith("(") && trimmed.endsWith(")")) {
1155
+ const inner = trimmed.slice(1, -1).trim();
1156
+ if (!inner.startsWith("(") || !inner.endsWith(")")) {
1157
+ return inner;
1158
+ }
1159
+ }
1160
+ return trimmed;
1161
+ };
1162
+ var extractArrow = (source) => {
1163
+ const idx = source.indexOf("=>");
1164
+ if (idx < 0) return void 0;
1165
+ const left = source.slice(0, idx).trim();
1166
+ const right = source.slice(idx + 2).trim();
1167
+ const paramRaw = unwrapParens(left);
1168
+ if (!/^[A-Za-z_$][A-Za-z0-9_$]*$/.test(paramRaw)) return void 0;
1169
+ if (right.startsWith("{")) {
1170
+ const m = right.match(/^\{\s*return\s+(.+?);?\s*\}\s*$/s);
1171
+ if (!m) return void 0;
1172
+ return { param: paramRaw, body: m[1]?.trim() ?? "" };
1173
+ }
1174
+ return { param: paramRaw, body: right };
1175
+ };
1176
+ var extractFunctionReturn = (source) => {
1177
+ const trimmed = source.trim();
1178
+ const m = trimmed.match(
1179
+ /^function\s*(?:[A-Za-z_$][A-Za-z0-9_$]*\s*)?\(\s*([A-Za-z_$][A-Za-z0-9_$]*)\s*\)\s*\{\s*return\s+(.+?);?\s*\}\s*$/s
1180
+ );
1181
+ if (!m) return void 0;
1182
+ const param = m[1]?.trim() ?? "";
1183
+ if (!/^[A-Za-z_$][A-Za-z0-9_$]*$/.test(param)) return void 0;
1184
+ const body = m[2]?.trim() ?? "";
1185
+ if (body.length === 0) return void 0;
1186
+ return { param, body };
423
1187
  };
424
- var currentProcessTrigger = import_effect34.FiberRef.unsafeMake(void 0);
425
- var currentProcessEventBudget = import_effect34.FiberRef.unsafeMake(
426
- void 0
1188
+ var tryParseSelectorSource = (source) => {
1189
+ const arrowOrFn = extractArrow(source) ?? extractFunctionReturn(source);
1190
+ if (!arrowOrFn) return void 0;
1191
+ const expr = unwrapParens(arrowOrFn.body).trim().replace(/;$/, "").trim();
1192
+ {
1193
+ const re = new RegExp(`^${arrowOrFn.param}\\.([A-Za-z0-9_$]+(?:\\.[A-Za-z0-9_$]+)*)$`);
1194
+ const m = expr.match(re);
1195
+ if (m) {
1196
+ return { kind: "path", path: m[1] };
1197
+ }
1198
+ }
1199
+ if (expr.startsWith("{") && expr.endsWith("}")) {
1200
+ const inner = expr.slice(1, -1).trim();
1201
+ if (inner.length === 0) return { kind: "struct", entries: [] };
1202
+ const parts = inner.split(",").map((p) => p.trim()).filter((p) => p.length > 0);
1203
+ const entries = [];
1204
+ for (const part of parts) {
1205
+ const idx = part.indexOf(":");
1206
+ if (idx < 0) return void 0;
1207
+ const key = part.slice(0, idx).trim();
1208
+ const value = part.slice(idx + 1).trim();
1209
+ if (!/^[A-Za-z_$][A-Za-z0-9_$]*$/.test(key)) return void 0;
1210
+ const re = new RegExp(`^${arrowOrFn.param}\\.([A-Za-z0-9_$]+(?:\\.[A-Za-z0-9_$]+)*)$`);
1211
+ const m = value.match(re);
1212
+ if (!m) return void 0;
1213
+ entries.push([key, m[1]]);
1214
+ }
1215
+ entries.sort((a, b) => a[0] < b[0] ? -1 : a[0] > b[0] ? 1 : 0);
1216
+ return { kind: "struct", entries };
1217
+ }
1218
+ return void 0;
1219
+ };
1220
+ var READ_QUERY_TEMPLATE_CACHE_MAX = 2048;
1221
+ var readQueryTemplateByFn = /* @__PURE__ */ new WeakMap();
1222
+ var readQueryTemplateBySource = /* @__PURE__ */ new Map();
1223
+ var lruGet = (map, key) => {
1224
+ const value = map.get(key);
1225
+ if (value === void 0) return void 0;
1226
+ map.delete(key);
1227
+ map.set(key, value);
1228
+ return value;
1229
+ };
1230
+ var lruSet = (map, key, value, maxSize) => {
1231
+ if (map.has(key)) map.delete(key);
1232
+ map.set(key, value);
1233
+ if (map.size <= maxSize) return;
1234
+ const oldestKey = map.keys().next().value;
1235
+ if (oldestKey !== void 0) {
1236
+ map.delete(oldestKey);
1237
+ }
1238
+ };
1239
+ var safeToString = (fn) => {
1240
+ try {
1241
+ return fn.toString();
1242
+ } catch {
1243
+ return "";
1244
+ }
1245
+ };
1246
+ var compile = (input) => {
1247
+ if (isReadQuery(input)) {
1248
+ const reads = normalizeReads(input.reads);
1249
+ const readsDigest = reads.length > 0 ? makeReadsDigest(reads) : void 0;
1250
+ const equalsKind = input.equalsKind;
1251
+ const staticIr2 = {
1252
+ selectorId: input.selectorId,
1253
+ debugKey: input.debugKey,
1254
+ lane: "static",
1255
+ producer: "manual",
1256
+ reads,
1257
+ readsDigest,
1258
+ equalsKind
1259
+ };
1260
+ return {
1261
+ ...input,
1262
+ reads,
1263
+ lane: "static",
1264
+ producer: "manual",
1265
+ readsDigest,
1266
+ staticIr: staticIr2
1267
+ };
1268
+ }
1269
+ const selector = input;
1270
+ const debugKey = (typeof selector?.debugKey === "string" && selector.debugKey.length > 0 ? selector.debugKey : void 0) ?? (typeof selector.name === "string" && selector.name.length > 0 ? selector.name : void 0);
1271
+ const declaredReads = Array.isArray(selector?.fieldPaths) ? selector.fieldPaths.filter((x) => typeof x === "string") : void 0;
1272
+ if (declaredReads && declaredReads.length > 0) {
1273
+ const reads = normalizeReads(declaredReads);
1274
+ const readsDigest = makeReadsDigest(reads);
1275
+ const selectorId2 = computeSelectorId({ kind: "reads", reads });
1276
+ const staticIr2 = {
1277
+ selectorId: selectorId2,
1278
+ debugKey,
1279
+ lane: "static",
1280
+ producer: "jit",
1281
+ reads,
1282
+ readsDigest,
1283
+ equalsKind: "objectIs"
1284
+ };
1285
+ return {
1286
+ selectorId: selectorId2,
1287
+ debugKey,
1288
+ reads,
1289
+ select: selector,
1290
+ equalsKind: "objectIs",
1291
+ lane: "static",
1292
+ producer: "jit",
1293
+ readsDigest,
1294
+ staticIr: staticIr2
1295
+ };
1296
+ }
1297
+ const cachedByFn = readQueryTemplateByFn.get(selector);
1298
+ if (cachedByFn) {
1299
+ const staticIr2 = {
1300
+ selectorId: cachedByFn.selectorId,
1301
+ debugKey,
1302
+ lane: "static",
1303
+ producer: "jit",
1304
+ reads: cachedByFn.reads,
1305
+ readsDigest: cachedByFn.readsDigest,
1306
+ equalsKind: cachedByFn.equalsKind
1307
+ };
1308
+ return {
1309
+ selectorId: cachedByFn.selectorId,
1310
+ debugKey,
1311
+ reads: cachedByFn.reads,
1312
+ select: selector,
1313
+ equalsKind: cachedByFn.equalsKind,
1314
+ lane: "static",
1315
+ producer: "jit",
1316
+ readsDigest: cachedByFn.readsDigest,
1317
+ staticIr: staticIr2
1318
+ };
1319
+ }
1320
+ const srcTrimmed = safeToString(selector).trim();
1321
+ const cachedBySource = srcTrimmed.length > 0 ? lruGet(readQueryTemplateBySource, srcTrimmed) : void 0;
1322
+ if (cachedBySource) {
1323
+ readQueryTemplateByFn.set(selector, cachedBySource);
1324
+ const staticIr2 = {
1325
+ selectorId: cachedBySource.selectorId,
1326
+ debugKey,
1327
+ lane: "static",
1328
+ producer: "jit",
1329
+ reads: cachedBySource.reads,
1330
+ readsDigest: cachedBySource.readsDigest,
1331
+ equalsKind: cachedBySource.equalsKind
1332
+ };
1333
+ return {
1334
+ selectorId: cachedBySource.selectorId,
1335
+ debugKey,
1336
+ reads: cachedBySource.reads,
1337
+ select: selector,
1338
+ equalsKind: cachedBySource.equalsKind,
1339
+ lane: "static",
1340
+ producer: "jit",
1341
+ readsDigest: cachedBySource.readsDigest,
1342
+ staticIr: staticIr2
1343
+ };
1344
+ }
1345
+ const parsed = srcTrimmed.length > 0 ? tryParseSelectorSource(srcTrimmed) : void 0;
1346
+ if (parsed?.kind === "path") {
1347
+ const reads = [parsed.path];
1348
+ const readsDigest = makeReadsDigest(reads);
1349
+ const selectorId2 = computeSelectorId({ kind: "path", path: parsed.path });
1350
+ const template = { selectorId: selectorId2, reads, readsDigest, equalsKind: "objectIs" };
1351
+ readQueryTemplateByFn.set(selector, template);
1352
+ lruSet(readQueryTemplateBySource, srcTrimmed, template, READ_QUERY_TEMPLATE_CACHE_MAX);
1353
+ const staticIr2 = {
1354
+ selectorId: selectorId2,
1355
+ debugKey,
1356
+ lane: "static",
1357
+ producer: "jit",
1358
+ reads,
1359
+ readsDigest,
1360
+ equalsKind: "objectIs"
1361
+ };
1362
+ return {
1363
+ selectorId: selectorId2,
1364
+ debugKey,
1365
+ reads,
1366
+ select: selector,
1367
+ equalsKind: "objectIs",
1368
+ lane: "static",
1369
+ producer: "jit",
1370
+ readsDigest,
1371
+ staticIr: staticIr2
1372
+ };
1373
+ }
1374
+ if (parsed?.kind === "struct") {
1375
+ const reads = normalizeReads(parsed.entries.map(([, path]) => path));
1376
+ const readsDigest = makeReadsDigest(reads);
1377
+ const selectorId2 = computeSelectorId({ kind: "struct", entries: parsed.entries });
1378
+ const template = { selectorId: selectorId2, reads, readsDigest, equalsKind: "shallowStruct" };
1379
+ readQueryTemplateByFn.set(selector, template);
1380
+ lruSet(readQueryTemplateBySource, srcTrimmed, template, READ_QUERY_TEMPLATE_CACHE_MAX);
1381
+ const staticIr2 = {
1382
+ selectorId: selectorId2,
1383
+ debugKey,
1384
+ lane: "static",
1385
+ producer: "jit",
1386
+ reads,
1387
+ readsDigest,
1388
+ equalsKind: "shallowStruct"
1389
+ };
1390
+ return {
1391
+ selectorId: selectorId2,
1392
+ debugKey,
1393
+ reads,
1394
+ select: selector,
1395
+ equalsKind: "shallowStruct",
1396
+ lane: "static",
1397
+ producer: "jit",
1398
+ readsDigest,
1399
+ staticIr: staticIr2
1400
+ };
1401
+ }
1402
+ const baseFallbackReason = srcTrimmed.includes("=>") || srcTrimmed.startsWith("function") ? "unsupportedSyntax" : "missingDeps";
1403
+ const lowDiscriminabilitySource = srcTrimmed.length === 0 || srcTrimmed.includes("[native code]");
1404
+ const fallbackReason = !debugKey || lowDiscriminabilitySource ? "unstableSelectorId" : baseFallbackReason;
1405
+ const selectorId = fallbackReason === "unstableSelectorId" ? computeUnstableSelectorId(selector) : computeSelectorId({ kind: "dynamic", debugKey, src: srcTrimmed });
1406
+ const staticIr = {
1407
+ selectorId,
1408
+ debugKey,
1409
+ lane: "dynamic",
1410
+ producer: "dynamic",
1411
+ fallbackReason,
1412
+ equalsKind: "objectIs"
1413
+ };
1414
+ return {
1415
+ selectorId,
1416
+ debugKey,
1417
+ reads: [],
1418
+ select: selector,
1419
+ equalsKind: "objectIs",
1420
+ lane: "dynamic",
1421
+ producer: "dynamic",
1422
+ fallbackReason,
1423
+ staticIr
1424
+ };
1425
+ };
1426
+
1427
+ // src/internal/serviceId.ts
1428
+ var import_effect41 = require("effect");
1429
+
1430
+ // src/internal/runtime/core/process/ProcessRuntime.make.ts
1431
+ var ProcessRuntimeTag = class extends import_effect42.ServiceMap.Service()("@logixjs/core/ProcessRuntime") {
1432
+ };
1433
+ var currentProcessTrigger = import_effect42.ServiceMap.Reference("@logixjs/core/ProcessRuntime.currentTrigger", {
1434
+ defaultValue: () => void 0
1435
+ });
1436
+ var currentProcessEventBudget = import_effect42.ServiceMap.Reference(
1437
+ "@logixjs/core/ProcessRuntime.currentEventBudget",
1438
+ {
1439
+ defaultValue: () => void 0
1440
+ }
427
1441
  );
428
1442
 
429
1443
  // src/internal/runtime/core/SelectorGraph.ts
430
- var import_effect35 = require("effect");
431
-
432
- // src/internal/runtime/core/ModuleRuntime.txnQueue.ts
433
- var import_effect36 = require("effect");
1444
+ var import_effect43 = require("effect");
434
1445
 
435
1446
  // src/internal/runtime/core/ModuleRuntime.logics.ts
436
- var import_effect40 = require("effect");
1447
+ var import_effect47 = require("effect");
437
1448
 
438
1449
  // src/internal/runtime/core/LifecycleDiagnostics.ts
439
- var import_effect37 = require("effect");
1450
+ var import_effect44 = require("effect");
440
1451
 
441
1452
  // src/internal/runtime/core/LogicDiagnostics.ts
442
- var import_effect38 = require("effect");
443
- var LogicPhaseServiceTag = import_effect38.Context.GenericTag("@logixjs/LogicPhaseService");
444
- var LogicUnitServiceTag = class extends import_effect38.Context.Tag("@logixjs/LogicUnitService")() {
1453
+ var import_effect45 = require("effect");
1454
+ var LogicPhaseServiceTag = class extends import_effect45.ServiceMap.Service()("@logixjs/LogicPhaseService") {
1455
+ };
1456
+ var LogicUnitServiceTag = class extends import_effect45.ServiceMap.Service()("@logixjs/LogicUnitService") {
445
1457
  };
446
1458
 
447
1459
  // src/internal/runtime/core/Platform.ts
448
- var import_effect39 = require("effect");
449
- var Tag = import_effect39.Context.GenericTag("@logixjs/Platform");
1460
+ var import_effect46 = require("effect");
1461
+ var Tag = class extends import_effect46.ServiceMap.Service()("@logixjs/Platform") {
1462
+ };
450
1463
 
451
1464
  // src/internal/runtime/core/ConcurrencyDiagnostics.ts
452
- var import_effect41 = require("effect");
453
- var nowMs2 = import_effect41.Effect.clockWith((clock) => clock.currentTimeMillis);
1465
+ var import_effect48 = require("effect");
1466
+ var nowMs2 = import_effect48.Effect.clockWith((clock) => clock.currentTimeMillis);
454
1467
 
455
1468
  // src/internal/runtime/core/BoundApiRuntime.ts
456
- var import_effect47 = require("effect");
1469
+ var import_effect54 = require("effect");
457
1470
 
458
1471
  // src/internal/action.ts
459
- var import_effect43 = require("effect");
460
-
461
- // src/internal/runtime/core/mutativePatches.ts
462
- var import_mutative3 = require("mutative");
1472
+ var import_effect50 = require("effect");
463
1473
 
464
1474
  // src/internal/runtime/core/FlowRuntime.ts
465
- var import_effect44 = require("effect");
1475
+ var import_effect51 = require("effect");
466
1476
 
467
1477
  // src/internal/runtime/core/MatchBuilder.ts
468
- var import_effect45 = require("effect");
1478
+ var import_effect52 = require("effect");
469
1479
 
470
1480
  // src/internal/root.ts
471
- var import_effect46 = require("effect");
1481
+ var import_effect53 = require("effect");
472
1482
 
473
1483
  // src/internal/runtime/ModuleFactory.ts
474
1484
  function Link(modules, logic) {
475
- return import_effect48.Effect.gen(function* () {
1485
+ return import_effect55.Effect.gen(function* () {
476
1486
  const handles = {};
477
1487
  for (const [key, module2] of Object.entries(modules)) {
478
- const runtime = yield* module2;
1488
+ const runtime = yield* import_effect55.Effect.service(module2).pipe(import_effect55.Effect.orDie);
479
1489
  handles[key] = {
480
- read: (selector) => import_effect48.Effect.map(runtime.getState, selector),
1490
+ read: (selector) => import_effect55.Effect.map(runtime.getState, selector),
481
1491
  changes: runtime.changes,
482
1492
  dispatch: runtime.dispatch,
483
1493
  actions$: runtime.actions$,
@@ -495,6 +1505,19 @@ function Link(modules, logic) {
495
1505
  });
496
1506
  }
497
1507
 
1508
+ // src/internal/runtime/core/DeclarativeLinkIR.ts
1509
+ var getDeclarativeLinkIrDigest = (ir) => `dlink_ir_v1:${fnv1a32(stableStringify(ir))}`;
1510
+ var exportDeclarativeLinkIr = (args) => ({
1511
+ staticIrDigest: getDeclarativeLinkIrDigest(args.ir),
1512
+ moduleId: `link:${args.linkId}`,
1513
+ instanceId: "runtime",
1514
+ kind: "declarativeLinkIr",
1515
+ ir: args.ir
1516
+ });
1517
+
1518
+ // src/ReadQuery.ts
1519
+ var compile2 = compile;
1520
+
498
1521
  // src/Process.ts
499
1522
  var DEFAULT_TRIGGERS = [{ kind: "platformEvent", platformEvent: "runtime:boot" }];
500
1523
  var isModuleLike = (value) => Boolean(value) && typeof value === "object" && (value._kind === "ModuleDef" || value._kind === "Module") && "tag" in value;
@@ -517,6 +1540,21 @@ function link(config, logic) {
517
1540
  modulesRecord,
518
1541
  logic
519
1542
  );
1543
+ const wrapped = import_effect56.Effect.gen(function* () {
1544
+ const level = yield* import_effect56.Effect.service(currentDiagnosticsLevel).pipe(import_effect56.Effect.orDie);
1545
+ if (level !== "off") {
1546
+ yield* record({
1547
+ type: "diagnostic",
1548
+ moduleId: `link:${linkId}`,
1549
+ code: "process_link::blackbox_best_effort",
1550
+ severity: "info",
1551
+ message: "[Process.link] Blackbox link is best-effort and is NOT stabilized within the same tick. Strong consistency applies only to declarative IR.",
1552
+ hint: "If you need same-tick strong consistency, migrate to Process.linkDeclarative(...) (073).",
1553
+ kind: "blackbox_link_boundary"
1554
+ });
1555
+ }
1556
+ return yield* effect;
1557
+ });
520
1558
  const definition = {
521
1559
  processId: linkId,
522
1560
  requires: Array.from(requires),
@@ -525,18 +1563,153 @@ function link(config, logic) {
525
1563
  errorPolicy: { mode: "failStop" },
526
1564
  diagnosticsLevel: "off"
527
1565
  };
528
- return attachMeta(effect, {
1566
+ return attachMeta(wrapped, {
529
1567
  definition,
530
1568
  kind: "link"
531
1569
  });
532
1570
  }
1571
+ function linkDeclarative(config, build2) {
1572
+ const linkId = config.id ?? [...config.modules].map((m) => m.id).sort().join("~");
1573
+ const modulesRecord = /* @__PURE__ */ Object.create(null);
1574
+ const requires = /* @__PURE__ */ new Set();
1575
+ for (const module2 of config.modules) {
1576
+ const tag = unwrapModuleTag(module2);
1577
+ requires.add(String(tag.id));
1578
+ modulesRecord[tag.id] = tag;
1579
+ }
1580
+ const handles = /* @__PURE__ */ Object.create(null);
1581
+ for (const id of Object.keys(modulesRecord)) {
1582
+ const tag = modulesRecord[id];
1583
+ handles[id] = {
1584
+ read: (selector) => {
1585
+ const compiled = compile2(selector);
1586
+ const staticIr = compiled.staticIr;
1587
+ const ok = staticIr.lane === "static" && staticIr.readsDigest != null && staticIr.fallbackReason == null;
1588
+ if (!ok) {
1589
+ throw new Error(
1590
+ `[Process.linkDeclarative] ReadQuery must be static with readsDigest (moduleId=${id}, selectorId=${staticIr.selectorId}, lane=${staticIr.lane}, fallbackReason=${staticIr.fallbackReason}). Fix: use ReadQuery.make(...) or annotate selector.fieldPaths.`
1591
+ );
1592
+ }
1593
+ return { _tag: "readNode", moduleId: id, tag, readQuery: compiled };
1594
+ },
1595
+ dispatch: (actionTag) => {
1596
+ if (typeof actionTag !== "string" || actionTag.length === 0) {
1597
+ throw new Error("[Process.linkDeclarative] actionTag must be a non-empty string");
1598
+ }
1599
+ return { _tag: "dispatchNode", moduleId: id, tag, actionTag };
1600
+ }
1601
+ };
1602
+ }
1603
+ const edges = build2(handles);
1604
+ if (!Array.isArray(edges)) {
1605
+ throw new Error("[Process.linkDeclarative] build(...) must return an array of edges");
1606
+ }
1607
+ const normalized = edges.filter((e) => Boolean(e && e.from && e.to)).map((e) => {
1608
+ if (e.from._tag !== "readNode" || e.to._tag !== "dispatchNode") {
1609
+ throw new Error("[Process.linkDeclarative] Invalid edge spec returned from build(...)");
1610
+ }
1611
+ return e;
1612
+ }).slice().sort((a, b) => {
1613
+ const ak = `${a.from.moduleId}:${a.from.readQuery.staticIr.selectorId}->${a.to.moduleId}:${a.to.actionTag}`;
1614
+ const bk = `${b.from.moduleId}:${b.from.readQuery.staticIr.selectorId}->${b.to.moduleId}:${b.to.actionTag}`;
1615
+ return ak < bk ? -1 : ak > bk ? 1 : 0;
1616
+ });
1617
+ const program = import_effect56.Effect.gen(function* () {
1618
+ const runtime = yield* import_effect56.Effect.service(DeclarativeLinkRuntimeTag).pipe(import_effect56.Effect.orDie);
1619
+ const collectors = yield* import_effect56.Effect.service(currentConvergeStaticIrCollectors).pipe(import_effect56.Effect.orDie);
1620
+ const runtimeByTag = /* @__PURE__ */ new Map();
1621
+ const resolveRuntime = (tag) => import_effect56.Effect.suspend(() => {
1622
+ const cached = runtimeByTag.get(tag);
1623
+ if (cached) return import_effect56.Effect.succeed(cached);
1624
+ return import_effect56.Effect.service(tag).pipe(
1625
+ import_effect56.Effect.tap(
1626
+ (rt) => import_effect56.Effect.sync(() => {
1627
+ runtimeByTag.set(tag, rt);
1628
+ })
1629
+ )
1630
+ );
1631
+ });
1632
+ const nodes = [];
1633
+ const irEdges = [];
1634
+ const readNodes = [];
1635
+ const dispatchNodes = [];
1636
+ for (let i = 0; i < normalized.length; i += 1) {
1637
+ const edge = normalized[i];
1638
+ const fromRuntime = yield* resolveRuntime(edge.from.tag);
1639
+ const toRuntime = yield* resolveRuntime(edge.to.tag);
1640
+ const fromKey = `${fromRuntime.moduleId}::${fromRuntime.instanceId}`;
1641
+ const readNodeId = `r${i}`;
1642
+ const dispatchNodeId = `d${i}`;
1643
+ nodes.push({
1644
+ id: readNodeId,
1645
+ kind: "readQuery",
1646
+ moduleId: fromRuntime.moduleId,
1647
+ instanceKey: fromRuntime.instanceId,
1648
+ readQuery: edge.from.readQuery.staticIr
1649
+ });
1650
+ nodes.push({
1651
+ id: dispatchNodeId,
1652
+ kind: "dispatch",
1653
+ moduleId: toRuntime.moduleId,
1654
+ instanceKey: toRuntime.instanceId,
1655
+ actionTag: edge.to.actionTag
1656
+ });
1657
+ irEdges.push({ from: readNodeId, to: dispatchNodeId });
1658
+ readNodes.push({ nodeId: readNodeId, moduleInstanceKey: fromKey, readQuery: edge.from.readQuery });
1659
+ dispatchNodes.push({
1660
+ nodeId: dispatchNodeId,
1661
+ dispatch: (payload) => toRuntime.dispatch({ _tag: edge.to.actionTag, payload }).pipe(import_effect56.Effect.asVoid)
1662
+ });
1663
+ }
1664
+ const ir = {
1665
+ version: 1,
1666
+ nodes,
1667
+ edges: irEdges
1668
+ };
1669
+ const registration = {
1670
+ linkId,
1671
+ ir,
1672
+ readNodes,
1673
+ dispatchNodes
1674
+ };
1675
+ const unregister = runtime.registerDeclarativeLink(registration);
1676
+ if (collectors.length > 0) {
1677
+ const exported = exportDeclarativeLinkIr({ linkId, ir });
1678
+ for (const collector of collectors) {
1679
+ collector.register(exported);
1680
+ }
1681
+ }
1682
+ yield* import_effect56.Effect.addFinalizer(
1683
+ () => import_effect56.Effect.sync(() => {
1684
+ unregister();
1685
+ })
1686
+ );
1687
+ yield* import_effect56.Effect.never;
1688
+ });
1689
+ const definition = {
1690
+ processId: `dlink:${linkId}`,
1691
+ requires: Array.from(requires),
1692
+ triggers: DEFAULT_TRIGGERS,
1693
+ concurrency: { mode: "latest" },
1694
+ errorPolicy: { mode: "failStop" },
1695
+ diagnosticsLevel: "off"
1696
+ };
1697
+ return attachMeta(program, {
1698
+ definition,
1699
+ kind: "declarativeLink"
1700
+ });
1701
+ }
533
1702
 
534
1703
  // src/Link.ts
535
- function make7(config, logic) {
1704
+ function make9(config, logic) {
536
1705
  return link(config, logic);
537
1706
  }
1707
+ function makeDeclarative(config, build2) {
1708
+ return linkDeclarative(config, build2);
1709
+ }
538
1710
  // Annotate the CommonJS export names for ESM import in node:
539
1711
  0 && (module.exports = {
540
- make
1712
+ make,
1713
+ makeDeclarative
541
1714
  });
542
1715
  //# sourceMappingURL=Link.cjs.map