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