@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/Flow.cjs CHANGED
@@ -20,30 +20,39 @@ var __toCommonJS = (mod) => __copyProps(__defProp({}, "__esModule", { value: tru
20
20
  // src/Flow.ts
21
21
  var Flow_exports = {};
22
22
  __export(Flow_exports, {
23
- make: () => make3
23
+ make: () => make4
24
24
  });
25
25
  module.exports = __toCommonJS(Flow_exports);
26
26
 
27
27
  // src/internal/runtime/core/FlowRuntime.ts
28
- var import_effect6 = require("effect");
28
+ var import_effect8 = require("effect");
29
29
 
30
30
  // src/internal/effect-op.ts
31
31
  var import_effect3 = require("effect");
32
32
 
33
33
  // src/internal/runtime/core/EffectOpCore.ts
34
34
  var import_effect = require("effect");
35
- var currentLinkId = import_effect.FiberRef.unsafeMake(void 0);
36
- var EffectOpMiddlewareTag = class extends import_effect.Context.Tag("Logix/EffectOpMiddleware")() {
35
+ var currentLinkId = import_effect.ServiceMap.Reference("@logixjs/core/CurrentLinkId", {
36
+ defaultValue: () => void 0
37
+ });
38
+ var composeMiddlewareCache = /* @__PURE__ */ new WeakMap();
39
+ var EffectOpMiddlewareTag = class extends import_effect.ServiceMap.Service()("Logix/EffectOpMiddleware") {
37
40
  };
38
41
  var composeMiddleware = (stack) => {
39
- return (op) => stack.reduceRight(
42
+ const cached = composeMiddlewareCache.get(stack);
43
+ if (cached) {
44
+ return cached;
45
+ }
46
+ const composed = (op) => stack.reduceRight(
40
47
  (eff, mw) => mw({ ...op, effect: eff }),
41
48
  op.effect
42
49
  );
50
+ composeMiddlewareCache.set(stack, composed);
51
+ return composed;
43
52
  };
44
53
  var runWithMiddleware = (op, stack) => {
45
54
  return import_effect.Effect.gen(function* () {
46
- const existing = yield* import_effect.FiberRef.get(currentLinkId);
55
+ const existing = yield* import_effect.Effect.service(currentLinkId);
47
56
  const metaLinkId = op.meta?.linkId;
48
57
  const linkId = typeof metaLinkId === "string" && metaLinkId.length > 0 ? metaLinkId : existing ?? op.id;
49
58
  const nextOp = {
@@ -54,7 +63,7 @@ var runWithMiddleware = (op, stack) => {
54
63
  }
55
64
  };
56
65
  const program = stack.length ? composeMiddleware(stack)(nextOp) : nextOp.effect;
57
- return yield* import_effect.Effect.locally(currentLinkId, linkId)(program);
66
+ return yield* import_effect.Effect.provideService(program, currentLinkId, linkId);
58
67
  });
59
68
  };
60
69
 
@@ -72,7 +81,7 @@ var defaultOptions = {
72
81
  };
73
82
 
74
83
  // src/internal/observability/runSession.ts
75
- var RunSessionTagImpl = class extends import_effect2.Context.Tag("@logixjs/core/RunSession")() {
84
+ var RunSessionTagImpl = class extends import_effect2.ServiceMap.Service()("@logixjs/core/RunSession") {
76
85
  };
77
86
  var RunSessionTag = RunSessionTagImpl;
78
87
 
@@ -100,31 +109,53 @@ var make = (params) => ({
100
109
  });
101
110
  var run = (op, stack) => runWithMiddleware(op, stack);
102
111
 
103
- // src/internal/runtime/core/DebugSink.ts
112
+ // src/internal/runtime/core/DebugSink.record.ts
104
113
  var import_effect5 = require("effect");
105
114
 
106
115
  // src/internal/runtime/core/errorSummary.ts
107
116
  var import_effect4 = require("effect");
108
117
 
109
- // src/internal/runtime/core/DebugSink.ts
110
- var currentDebugSinks = import_effect5.FiberRef.unsafeMake([]);
111
- var currentRuntimeLabel = import_effect5.FiberRef.unsafeMake(void 0);
112
- var currentTxnId = import_effect5.FiberRef.unsafeMake(void 0);
113
- var currentOpSeq = import_effect5.FiberRef.unsafeMake(void 0);
114
- var currentDiagnosticsLevel = import_effect5.FiberRef.unsafeMake("off");
115
- var currentTraitConvergeDiagnosticsSampling = import_effect5.FiberRef.unsafeMake({
116
- sampleEveryN: 32,
117
- topK: 3
118
+ // src/internal/runtime/core/DebugSink.record.ts
119
+ var currentDebugSinks = import_effect5.ServiceMap.Reference("@logixjs/core/Debug.currentDebugSinks", {
120
+ defaultValue: () => []
121
+ });
122
+ var currentRuntimeLabel = import_effect5.ServiceMap.Reference("@logixjs/core/Debug.currentRuntimeLabel", {
123
+ defaultValue: () => void 0
124
+ });
125
+ var currentTxnId = import_effect5.ServiceMap.Reference("@logixjs/core/Debug.currentTxnId", {
126
+ defaultValue: () => void 0
127
+ });
128
+ var currentOpSeq = import_effect5.ServiceMap.Reference("@logixjs/core/Debug.currentOpSeq", {
129
+ defaultValue: () => void 0
118
130
  });
131
+ var currentDiagnosticsLevel = import_effect5.ServiceMap.Reference("@logixjs/core/Debug.currentDiagnosticsLevel", {
132
+ defaultValue: () => "off"
133
+ });
134
+ var currentDiagnosticsMaterialization = import_effect5.ServiceMap.Reference(
135
+ "@logixjs/core/Debug.currentDiagnosticsMaterialization",
136
+ {
137
+ defaultValue: () => "eager"
138
+ }
139
+ );
140
+ var currentTraceMode = import_effect5.ServiceMap.Reference("@logixjs/core/Debug.currentTraceMode", {
141
+ defaultValue: () => "on"
142
+ });
143
+ var currentTraitConvergeDiagnosticsSampling = import_effect5.ServiceMap.Reference(
144
+ "@logixjs/core/Debug.currentTraitConvergeDiagnosticsSampling",
145
+ {
146
+ defaultValue: () => ({
147
+ sampleEveryN: 32,
148
+ topK: 3
149
+ })
150
+ }
151
+ );
119
152
  var browserLifecycleSeen = /* @__PURE__ */ new Set();
120
153
  var browserDiagnosticSeen = /* @__PURE__ */ new Set();
121
154
  var lifecycleErrorLog = (event) => {
122
155
  const moduleId = event.moduleId ?? "unknown";
123
156
  const causePretty = (() => {
124
157
  try {
125
- return import_effect5.Cause.pretty(event.cause, {
126
- renderErrorCause: true
127
- });
158
+ return import_effect5.Cause.pretty(event.cause);
128
159
  } catch {
129
160
  try {
130
161
  return JSON.stringify(event.cause, null, 2);
@@ -165,16 +196,16 @@ ${detail}`;
165
196
  }
166
197
  return base.pipe(import_effect5.Effect.annotateLogs(annotations));
167
198
  };
168
- var noopLayer = import_effect5.Layer.locallyScoped(currentDebugSinks, []);
199
+ var noopLayer = import_effect5.Layer.succeed(currentDebugSinks, []);
169
200
  var errorOnlySink = {
170
201
  record: (event) => event.type === "lifecycle:error" ? lifecycleErrorLog(event) : event.type === "diagnostic" && event.severity !== "info" ? diagnosticLog(event) : import_effect5.Effect.void
171
202
  };
172
- var errorOnlyLayer = import_effect5.Layer.locallyScoped(currentDebugSinks, [errorOnlySink]);
203
+ var errorOnlyLayer = import_effect5.Layer.succeed(currentDebugSinks, [errorOnlySink]);
173
204
  var isErrorOnlyOnlySinks = (sinks) => sinks.length === 1 && sinks[0] === errorOnlySink;
174
205
  var consoleSink = {
175
206
  record: (event) => event.type === "lifecycle:error" ? lifecycleErrorLog(event) : event.type === "diagnostic" ? diagnosticLog(event) : import_effect5.Effect.logDebug({ debugEvent: event })
176
207
  };
177
- var consoleLayer = import_effect5.Layer.locallyScoped(currentDebugSinks, [consoleSink]);
208
+ var consoleLayer = import_effect5.Layer.succeed(currentDebugSinks, [consoleSink]);
178
209
  var isBrowser = typeof window !== "undefined" && typeof document !== "undefined";
179
210
  var renderBrowserConsoleEvent = (event) => {
180
211
  if (typeof event.type === "string" && event.type.startsWith("trace:")) {
@@ -200,7 +231,7 @@ var renderBrowserConsoleEvent = (event) => {
200
231
  const moduleId = event.moduleId ?? "unknown";
201
232
  const causePretty = (() => {
202
233
  try {
203
- return import_effect5.Cause.pretty(event.cause, { renderErrorCause: true });
234
+ return import_effect5.Cause.pretty(event.cause);
204
235
  } catch {
205
236
  try {
206
237
  return JSON.stringify(event.cause, null, 2);
@@ -266,7 +297,7 @@ var browserConsoleSink = {
266
297
  return renderBrowserConsoleEvent(event);
267
298
  }
268
299
  };
269
- var browserConsoleLayer = import_effect5.Layer.locallyScoped(currentDebugSinks, [browserConsoleSink]);
300
+ var browserConsoleLayer = import_effect5.Layer.succeed(currentDebugSinks, [browserConsoleSink]);
270
301
  var browserDiagnosticConsoleSink = {
271
302
  record: (event) => {
272
303
  if (!isBrowser) {
@@ -275,36 +306,33 @@ var browserDiagnosticConsoleSink = {
275
306
  return event.type === "lifecycle:error" || event.type === "diagnostic" && event.severity !== "info" ? renderBrowserConsoleEvent(event) : import_effect5.Effect.void;
276
307
  }
277
308
  };
278
- var browserDiagnosticConsoleLayer = import_effect5.Layer.locallyScoped(currentDebugSinks, [browserDiagnosticConsoleSink]);
279
- var browserPrettyLoggerLayer = import_effect5.Logger.replace(
280
- import_effect5.Logger.defaultLogger,
281
- import_effect5.Logger.prettyLogger({ mode: "browser", colors: true })
309
+ var browserDiagnosticConsoleLayer = import_effect5.Layer.succeed(currentDebugSinks, [browserDiagnosticConsoleSink]);
310
+ var browserPrettyLoggerLayer = import_effect5.Layer.effect(
311
+ import_effect5.Logger.CurrentLoggers,
312
+ import_effect5.Effect.gen(function* () {
313
+ const current = yield* import_effect5.Effect.service(import_effect5.Logger.CurrentLoggers);
314
+ return new Set(
315
+ [...current].filter((logger) => logger !== import_effect5.Logger.defaultLogger).concat(import_effect5.Logger.consolePretty({ mode: "browser", colors: true }))
316
+ );
317
+ })
282
318
  );
283
319
  var record = (event) => import_effect5.Effect.gen(function* () {
284
- const sinks = yield* import_effect5.FiberRef.get(currentDebugSinks);
320
+ const sinks = yield* import_effect5.Effect.service(currentDebugSinks);
285
321
  if (isErrorOnlyOnlySinks(sinks)) {
286
322
  if (event.type === "lifecycle:error") {
287
323
  yield* lifecycleErrorLog(event);
288
324
  return;
289
325
  }
290
- if (event.type === "diagnostic") {
291
- if (event.severity !== "info") {
292
- yield* diagnosticLog(event);
293
- } else {
294
- yield* import_effect5.Effect.void;
295
- }
296
- return;
326
+ if (event.type === "diagnostic" && event.severity !== "info") {
327
+ yield* diagnosticLog(event);
297
328
  }
298
- yield* import_effect5.Effect.void;
299
329
  return;
300
330
  }
301
331
  if (sinks.length === 0) {
302
332
  if (isBrowser) {
303
333
  if (event.type === "lifecycle:error" || event.type === "diagnostic") {
304
334
  yield* renderBrowserConsoleEvent(event);
305
- return;
306
335
  }
307
- yield* import_effect5.Effect.void;
308
336
  return;
309
337
  }
310
338
  if (event.type === "lifecycle:error") {
@@ -313,13 +341,15 @@ var record = (event) => import_effect5.Effect.gen(function* () {
313
341
  }
314
342
  if (event.type === "diagnostic") {
315
343
  yield* diagnosticLog(event);
316
- return;
317
344
  }
318
- yield* import_effect5.Effect.void;
319
345
  return;
320
346
  }
347
+ if (typeof event.type === "string" && event.type.startsWith("trace:")) {
348
+ const mode = yield* import_effect5.Effect.service(currentTraceMode);
349
+ if (mode === "off") return;
350
+ }
321
351
  const enriched = event;
322
- const diagnosticsLevel = yield* import_effect5.FiberRef.get(currentDiagnosticsLevel);
352
+ const diagnosticsLevel = yield* import_effect5.Effect.service(currentDiagnosticsLevel);
323
353
  let now;
324
354
  const getNow = () => {
325
355
  if (now === void 0) now = Date.now();
@@ -330,24 +360,24 @@ var record = (event) => import_effect5.Effect.gen(function* () {
330
360
  enriched.timestamp = getNow();
331
361
  }
332
362
  if (diagnosticsLevel !== "off" && enriched.runtimeLabel === void 0) {
333
- const runtimeLabel = yield* import_effect5.FiberRef.get(currentRuntimeLabel);
363
+ const runtimeLabel = yield* import_effect5.Effect.service(currentRuntimeLabel);
334
364
  if (runtimeLabel) {
335
365
  ;
336
366
  enriched.runtimeLabel = runtimeLabel;
337
367
  }
338
368
  }
339
369
  if (enriched.type === "diagnostic" && enriched.txnId === void 0) {
340
- const txnId = yield* import_effect5.FiberRef.get(currentTxnId);
370
+ const txnId = yield* import_effect5.Effect.service(currentTxnId);
341
371
  if (txnId) {
342
372
  ;
343
373
  enriched.txnId = txnId;
344
374
  }
345
375
  }
346
376
  if (diagnosticsLevel !== "off" && enriched.type === "trace:effectop" && enriched.linkId === void 0) {
347
- const linkId = yield* import_effect5.FiberRef.get(currentLinkId);
348
- if (linkId) {
377
+ const maybeLinkId = yield* import_effect5.Effect.serviceOption(currentLinkId);
378
+ if (import_effect5.Option.isSome(maybeLinkId) && maybeLinkId.value) {
349
379
  ;
350
- enriched.linkId = linkId;
380
+ enriched.linkId = maybeLinkId.value;
351
381
  }
352
382
  }
353
383
  if (sinks.length === 1) {
@@ -357,16 +387,508 @@ var record = (event) => import_effect5.Effect.gen(function* () {
357
387
  yield* import_effect5.Effect.forEach(sinks, (sink) => sink.record(enriched), { discard: true });
358
388
  });
359
389
 
390
+ // src/internal/digest.ts
391
+ var stableStringify = (value) => {
392
+ if (value === null) return "null";
393
+ const t = typeof value;
394
+ if (t === "string") return JSON.stringify(value);
395
+ if (t === "number") return Number.isFinite(value) ? String(value) : "null";
396
+ if (t === "boolean") return value ? "true" : "false";
397
+ if (Array.isArray(value)) {
398
+ return `[${value.map(stableStringify).join(",")}]`;
399
+ }
400
+ if (t === "object") {
401
+ const record2 = value;
402
+ const keys = Object.keys(record2).sort();
403
+ return `{${keys.map((k) => `${JSON.stringify(k)}:${stableStringify(record2[k])}`).join(",")}}`;
404
+ }
405
+ return "null";
406
+ };
407
+ var fnv1a32 = (input) => {
408
+ let hash = 2166136261;
409
+ for (let i = 0; i < input.length; i++) {
410
+ hash ^= input.charCodeAt(i);
411
+ hash = hash * 16777619 >>> 0;
412
+ }
413
+ return hash.toString(16).padStart(8, "0");
414
+ };
415
+
360
416
  // src/internal/runtime/core/ReadQuery.ts
361
417
  function isReadQuery(input) {
362
418
  if (!input || typeof input !== "object" && typeof input !== "function") return false;
363
419
  const maybe = input;
364
420
  return typeof maybe.selectorId === "string" && typeof maybe.select === "function" && Array.isArray(maybe.reads);
365
421
  }
422
+ var normalizeReads = (reads) => {
423
+ const unique = [];
424
+ const seen = /* @__PURE__ */ new Set();
425
+ for (const r of reads) {
426
+ const key = typeof r === "number" ? `n:${r}` : `s:${r}`;
427
+ if (seen.has(key)) continue;
428
+ seen.add(key);
429
+ unique.push(r);
430
+ }
431
+ return unique.slice().sort();
432
+ };
433
+ var toHash32Number = (hex) => Number.parseInt(hex, 16);
434
+ var makeReadsDigest = (reads) => {
435
+ const normalized = normalizeReads(reads);
436
+ return {
437
+ count: normalized.length,
438
+ hash: toHash32Number(fnv1a32(stableStringify(normalized)))
439
+ };
440
+ };
441
+ var computeSelectorId = (value) => `rq_${fnv1a32(stableStringify(value))}`;
442
+ var nextUnstableSelectorSeq = 0;
443
+ var unstableSelectorIdByFn = /* @__PURE__ */ new WeakMap();
444
+ var computeUnstableSelectorId = (selector) => {
445
+ const existing = unstableSelectorIdByFn.get(selector);
446
+ if (existing) return existing;
447
+ nextUnstableSelectorSeq += 1;
448
+ const selectorId = `rq_u${nextUnstableSelectorSeq}`;
449
+ unstableSelectorIdByFn.set(selector, selectorId);
450
+ return selectorId;
451
+ };
452
+ var unwrapParens = (input) => {
453
+ const trimmed = input.trim();
454
+ if (trimmed.startsWith("(") && trimmed.endsWith(")")) {
455
+ const inner = trimmed.slice(1, -1).trim();
456
+ if (!inner.startsWith("(") || !inner.endsWith(")")) {
457
+ return inner;
458
+ }
459
+ }
460
+ return trimmed;
461
+ };
462
+ var extractArrow = (source) => {
463
+ const idx = source.indexOf("=>");
464
+ if (idx < 0) return void 0;
465
+ const left = source.slice(0, idx).trim();
466
+ const right = source.slice(idx + 2).trim();
467
+ const paramRaw = unwrapParens(left);
468
+ if (!/^[A-Za-z_$][A-Za-z0-9_$]*$/.test(paramRaw)) return void 0;
469
+ if (right.startsWith("{")) {
470
+ const m = right.match(/^\{\s*return\s+(.+?);?\s*\}\s*$/s);
471
+ if (!m) return void 0;
472
+ return { param: paramRaw, body: m[1]?.trim() ?? "" };
473
+ }
474
+ return { param: paramRaw, body: right };
475
+ };
476
+ var extractFunctionReturn = (source) => {
477
+ const trimmed = source.trim();
478
+ const m = trimmed.match(
479
+ /^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
480
+ );
481
+ if (!m) return void 0;
482
+ const param = m[1]?.trim() ?? "";
483
+ if (!/^[A-Za-z_$][A-Za-z0-9_$]*$/.test(param)) return void 0;
484
+ const body = m[2]?.trim() ?? "";
485
+ if (body.length === 0) return void 0;
486
+ return { param, body };
487
+ };
488
+ var tryParseSelectorSource = (source) => {
489
+ const arrowOrFn = extractArrow(source) ?? extractFunctionReturn(source);
490
+ if (!arrowOrFn) return void 0;
491
+ const expr = unwrapParens(arrowOrFn.body).trim().replace(/;$/, "").trim();
492
+ {
493
+ const re = new RegExp(`^${arrowOrFn.param}\\.([A-Za-z0-9_$]+(?:\\.[A-Za-z0-9_$]+)*)$`);
494
+ const m = expr.match(re);
495
+ if (m) {
496
+ return { kind: "path", path: m[1] };
497
+ }
498
+ }
499
+ if (expr.startsWith("{") && expr.endsWith("}")) {
500
+ const inner = expr.slice(1, -1).trim();
501
+ if (inner.length === 0) return { kind: "struct", entries: [] };
502
+ const parts = inner.split(",").map((p) => p.trim()).filter((p) => p.length > 0);
503
+ const entries = [];
504
+ for (const part of parts) {
505
+ const idx = part.indexOf(":");
506
+ if (idx < 0) return void 0;
507
+ const key = part.slice(0, idx).trim();
508
+ const value = part.slice(idx + 1).trim();
509
+ if (!/^[A-Za-z_$][A-Za-z0-9_$]*$/.test(key)) return void 0;
510
+ const re = new RegExp(`^${arrowOrFn.param}\\.([A-Za-z0-9_$]+(?:\\.[A-Za-z0-9_$]+)*)$`);
511
+ const m = value.match(re);
512
+ if (!m) return void 0;
513
+ entries.push([key, m[1]]);
514
+ }
515
+ entries.sort((a, b) => a[0] < b[0] ? -1 : a[0] > b[0] ? 1 : 0);
516
+ return { kind: "struct", entries };
517
+ }
518
+ return void 0;
519
+ };
520
+ var READ_QUERY_TEMPLATE_CACHE_MAX = 2048;
521
+ var readQueryTemplateByFn = /* @__PURE__ */ new WeakMap();
522
+ var readQueryTemplateBySource = /* @__PURE__ */ new Map();
523
+ var lruGet = (map, key) => {
524
+ const value = map.get(key);
525
+ if (value === void 0) return void 0;
526
+ map.delete(key);
527
+ map.set(key, value);
528
+ return value;
529
+ };
530
+ var lruSet = (map, key, value, maxSize) => {
531
+ if (map.has(key)) map.delete(key);
532
+ map.set(key, value);
533
+ if (map.size <= maxSize) return;
534
+ const oldestKey = map.keys().next().value;
535
+ if (oldestKey !== void 0) {
536
+ map.delete(oldestKey);
537
+ }
538
+ };
539
+ var safeToString = (fn) => {
540
+ try {
541
+ return fn.toString();
542
+ } catch {
543
+ return "";
544
+ }
545
+ };
546
+ var compile = (input) => {
547
+ if (isReadQuery(input)) {
548
+ const reads = normalizeReads(input.reads);
549
+ const readsDigest = reads.length > 0 ? makeReadsDigest(reads) : void 0;
550
+ const equalsKind = input.equalsKind;
551
+ const staticIr2 = {
552
+ selectorId: input.selectorId,
553
+ debugKey: input.debugKey,
554
+ lane: "static",
555
+ producer: "manual",
556
+ reads,
557
+ readsDigest,
558
+ equalsKind
559
+ };
560
+ return {
561
+ ...input,
562
+ reads,
563
+ lane: "static",
564
+ producer: "manual",
565
+ readsDigest,
566
+ staticIr: staticIr2
567
+ };
568
+ }
569
+ const selector = input;
570
+ 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);
571
+ const declaredReads = Array.isArray(selector?.fieldPaths) ? selector.fieldPaths.filter((x) => typeof x === "string") : void 0;
572
+ if (declaredReads && declaredReads.length > 0) {
573
+ const reads = normalizeReads(declaredReads);
574
+ const readsDigest = makeReadsDigest(reads);
575
+ const selectorId2 = computeSelectorId({ kind: "reads", reads });
576
+ const staticIr2 = {
577
+ selectorId: selectorId2,
578
+ debugKey,
579
+ lane: "static",
580
+ producer: "jit",
581
+ reads,
582
+ readsDigest,
583
+ equalsKind: "objectIs"
584
+ };
585
+ return {
586
+ selectorId: selectorId2,
587
+ debugKey,
588
+ reads,
589
+ select: selector,
590
+ equalsKind: "objectIs",
591
+ lane: "static",
592
+ producer: "jit",
593
+ readsDigest,
594
+ staticIr: staticIr2
595
+ };
596
+ }
597
+ const cachedByFn = readQueryTemplateByFn.get(selector);
598
+ if (cachedByFn) {
599
+ const staticIr2 = {
600
+ selectorId: cachedByFn.selectorId,
601
+ debugKey,
602
+ lane: "static",
603
+ producer: "jit",
604
+ reads: cachedByFn.reads,
605
+ readsDigest: cachedByFn.readsDigest,
606
+ equalsKind: cachedByFn.equalsKind
607
+ };
608
+ return {
609
+ selectorId: cachedByFn.selectorId,
610
+ debugKey,
611
+ reads: cachedByFn.reads,
612
+ select: selector,
613
+ equalsKind: cachedByFn.equalsKind,
614
+ lane: "static",
615
+ producer: "jit",
616
+ readsDigest: cachedByFn.readsDigest,
617
+ staticIr: staticIr2
618
+ };
619
+ }
620
+ const srcTrimmed = safeToString(selector).trim();
621
+ const cachedBySource = srcTrimmed.length > 0 ? lruGet(readQueryTemplateBySource, srcTrimmed) : void 0;
622
+ if (cachedBySource) {
623
+ readQueryTemplateByFn.set(selector, cachedBySource);
624
+ const staticIr2 = {
625
+ selectorId: cachedBySource.selectorId,
626
+ debugKey,
627
+ lane: "static",
628
+ producer: "jit",
629
+ reads: cachedBySource.reads,
630
+ readsDigest: cachedBySource.readsDigest,
631
+ equalsKind: cachedBySource.equalsKind
632
+ };
633
+ return {
634
+ selectorId: cachedBySource.selectorId,
635
+ debugKey,
636
+ reads: cachedBySource.reads,
637
+ select: selector,
638
+ equalsKind: cachedBySource.equalsKind,
639
+ lane: "static",
640
+ producer: "jit",
641
+ readsDigest: cachedBySource.readsDigest,
642
+ staticIr: staticIr2
643
+ };
644
+ }
645
+ const parsed = srcTrimmed.length > 0 ? tryParseSelectorSource(srcTrimmed) : void 0;
646
+ if (parsed?.kind === "path") {
647
+ const reads = [parsed.path];
648
+ const readsDigest = makeReadsDigest(reads);
649
+ const selectorId2 = computeSelectorId({ kind: "path", path: parsed.path });
650
+ const template = { selectorId: selectorId2, reads, readsDigest, equalsKind: "objectIs" };
651
+ readQueryTemplateByFn.set(selector, template);
652
+ lruSet(readQueryTemplateBySource, srcTrimmed, template, READ_QUERY_TEMPLATE_CACHE_MAX);
653
+ const staticIr2 = {
654
+ selectorId: selectorId2,
655
+ debugKey,
656
+ lane: "static",
657
+ producer: "jit",
658
+ reads,
659
+ readsDigest,
660
+ equalsKind: "objectIs"
661
+ };
662
+ return {
663
+ selectorId: selectorId2,
664
+ debugKey,
665
+ reads,
666
+ select: selector,
667
+ equalsKind: "objectIs",
668
+ lane: "static",
669
+ producer: "jit",
670
+ readsDigest,
671
+ staticIr: staticIr2
672
+ };
673
+ }
674
+ if (parsed?.kind === "struct") {
675
+ const reads = normalizeReads(parsed.entries.map(([, path]) => path));
676
+ const readsDigest = makeReadsDigest(reads);
677
+ const selectorId2 = computeSelectorId({ kind: "struct", entries: parsed.entries });
678
+ const template = { selectorId: selectorId2, reads, readsDigest, equalsKind: "shallowStruct" };
679
+ readQueryTemplateByFn.set(selector, template);
680
+ lruSet(readQueryTemplateBySource, srcTrimmed, template, READ_QUERY_TEMPLATE_CACHE_MAX);
681
+ const staticIr2 = {
682
+ selectorId: selectorId2,
683
+ debugKey,
684
+ lane: "static",
685
+ producer: "jit",
686
+ reads,
687
+ readsDigest,
688
+ equalsKind: "shallowStruct"
689
+ };
690
+ return {
691
+ selectorId: selectorId2,
692
+ debugKey,
693
+ reads,
694
+ select: selector,
695
+ equalsKind: "shallowStruct",
696
+ lane: "static",
697
+ producer: "jit",
698
+ readsDigest,
699
+ staticIr: staticIr2
700
+ };
701
+ }
702
+ const baseFallbackReason = srcTrimmed.includes("=>") || srcTrimmed.startsWith("function") ? "unsupportedSyntax" : "missingDeps";
703
+ const lowDiscriminabilitySource = srcTrimmed.length === 0 || srcTrimmed.includes("[native code]");
704
+ const fallbackReason = !debugKey || lowDiscriminabilitySource ? "unstableSelectorId" : baseFallbackReason;
705
+ const selectorId = fallbackReason === "unstableSelectorId" ? computeUnstableSelectorId(selector) : computeSelectorId({ kind: "dynamic", debugKey, src: srcTrimmed });
706
+ const staticIr = {
707
+ selectorId,
708
+ debugKey,
709
+ lane: "dynamic",
710
+ producer: "dynamic",
711
+ fallbackReason,
712
+ equalsKind: "objectIs"
713
+ };
714
+ return {
715
+ selectorId,
716
+ debugKey,
717
+ reads: [],
718
+ select: selector,
719
+ equalsKind: "objectIs",
720
+ lane: "dynamic",
721
+ producer: "dynamic",
722
+ fallbackReason,
723
+ staticIr
724
+ };
725
+ };
726
+
727
+ // src/internal/runtime/core/diagnosticsBudget.ts
728
+ var DIAGNOSTICS_BUDGET_CONTRACT_V1 = "diagnostics_budget.v1";
729
+ var normalizePositiveInteger = (value) => {
730
+ if (typeof value !== "number" || !Number.isFinite(value) || value < 0) return void 0;
731
+ return Math.floor(value);
732
+ };
733
+ var makeRunBudgetEnvelopeV1 = (args) => {
734
+ const maxEvents = normalizePositiveInteger(args.limits?.maxEvents);
735
+ const maxBytes = normalizePositiveInteger(args.limits?.maxBytes);
736
+ const emitted = normalizePositiveInteger(args.usage?.emitted);
737
+ const dropped = normalizePositiveInteger(args.usage?.dropped);
738
+ const downgraded = normalizePositiveInteger(args.usage?.downgraded);
739
+ return {
740
+ contract: DIAGNOSTICS_BUDGET_CONTRACT_V1,
741
+ domain: args.domain,
742
+ runId: args.runId,
743
+ ...maxEvents !== void 0 || maxBytes !== void 0 ? {
744
+ limits: {
745
+ ...maxEvents !== void 0 ? { maxEvents } : null,
746
+ ...maxBytes !== void 0 ? { maxBytes } : null
747
+ }
748
+ } : null,
749
+ ...emitted !== void 0 || dropped !== void 0 || downgraded !== void 0 ? {
750
+ usage: {
751
+ ...emitted !== void 0 ? { emitted } : null,
752
+ ...dropped !== void 0 ? { dropped } : null,
753
+ ...downgraded !== void 0 ? { downgraded } : null
754
+ }
755
+ } : null
756
+ };
757
+ };
758
+ var makeRunDegradeMarkerV1 = (degraded, reason) => ({
759
+ contract: DIAGNOSTICS_BUDGET_CONTRACT_V1,
760
+ degraded,
761
+ ...degraded && reason ? { reason } : null
762
+ });
763
+
764
+ // src/internal/runtime/core/ModeRunner.ts
765
+ var import_effect7 = require("effect");
766
+
767
+ // src/internal/runtime/core/LatestFiberSlot.ts
768
+ var import_effect6 = require("effect");
769
+ var make2 = () => import_effect6.Ref.make({
770
+ fiber: void 0,
771
+ runningId: 0,
772
+ nextId: 0
773
+ });
774
+ var beginRun = (slotRef) => import_effect6.Ref.modify(slotRef, (state) => {
775
+ const runId = state.nextId + 1;
776
+ const prevFiber = state.fiber;
777
+ const prevRunningId = state.runningId;
778
+ state.nextId = runId;
779
+ state.runningId = runId;
780
+ return [[prevFiber, prevRunningId, runId], state];
781
+ });
782
+ var setFiberIfCurrent = (slotRef, runId, fiber) => import_effect6.Ref.update(slotRef, (state) => {
783
+ if (state.runningId === runId) {
784
+ state.fiber = fiber;
785
+ }
786
+ return state;
787
+ });
788
+ var clearIfCurrent = (slotRef, runId) => import_effect6.Ref.update(slotRef, (state) => {
789
+ if (state.runningId === runId) {
790
+ state.runningId = 0;
791
+ state.fiber = void 0;
792
+ }
793
+ return state;
794
+ });
795
+
796
+ // src/internal/runtime/core/ModeRunner.ts
797
+ var EXHAUST_ACQUIRE_BUSY = [true, true];
798
+ var EXHAUST_REJECT_BUSY = [false, true];
799
+ var beginSwitchLatestRun = (stateRef) => import_effect7.Ref.modify(stateRef, (state) => {
800
+ const runId = state.nextId + 1;
801
+ state.nextId = runId;
802
+ state.runningId = runId;
803
+ return [runId, state];
804
+ });
805
+ var clearSwitchLatestIfCurrent = (stateRef, runId) => import_effect7.Ref.update(stateRef, (state) => {
806
+ if (state.runningId === runId) {
807
+ state.runningId = 0;
808
+ }
809
+ return state;
810
+ });
811
+ var runLatestSwitch = (stream, runLatest) => import_effect7.Effect.gen(function* () {
812
+ const stateRef = yield* import_effect7.Ref.make({
813
+ runningId: 0,
814
+ nextId: 0
815
+ });
816
+ const makeEffect = (payload) => import_effect7.Effect.gen(function* () {
817
+ const runId = yield* beginSwitchLatestRun(stateRef);
818
+ const isCurrent = import_effect7.Ref.get(stateRef).pipe(import_effect7.Effect.map((state) => state.runningId === runId));
819
+ yield* runLatest(payload, { runId, isCurrent }).pipe(import_effect7.Effect.ensuring(clearSwitchLatestIfCurrent(stateRef, runId)));
820
+ });
821
+ return yield* import_effect7.Stream.runDrain(
822
+ import_effect7.Stream.map(stream, makeEffect).pipe(import_effect7.Stream.switchMap((effect) => import_effect7.Stream.fromEffect(effect)))
823
+ );
824
+ });
825
+ var runLatestFiberSlot = (stream, runLatest, awaitLatestOnEnd) => import_effect7.Effect.gen(function* () {
826
+ const stateRef = yield* make2();
827
+ const start = (payload) => import_effect7.Effect.gen(function* () {
828
+ const [prevFiber, prevRunningId, runId] = yield* beginRun(stateRef);
829
+ if (prevFiber && prevRunningId !== 0) {
830
+ yield* import_effect7.Fiber.interrupt(prevFiber);
831
+ }
832
+ const isCurrent = import_effect7.Ref.get(stateRef).pipe(import_effect7.Effect.map((state) => state.runningId === runId));
833
+ const fiber = yield* import_effect7.Effect.forkChild(
834
+ runLatest(payload, { runId, isCurrent }).pipe(import_effect7.Effect.ensuring(clearIfCurrent(stateRef, runId)))
835
+ );
836
+ yield* setFiberIfCurrent(stateRef, runId, fiber);
837
+ });
838
+ yield* import_effect7.Stream.runForEach(stream, start);
839
+ if (!awaitLatestOnEnd) {
840
+ return;
841
+ }
842
+ const finalState = yield* import_effect7.Ref.get(stateRef);
843
+ const finalFiber = finalState.runningId !== 0 ? finalState.fiber : void 0;
844
+ if (finalFiber) {
845
+ yield* import_effect7.Fiber.join(finalFiber);
846
+ }
847
+ });
848
+ var runExhaust = (stream, run2, resolveConcurrencyLimit) => import_effect7.Effect.gen(function* () {
849
+ const concurrency = yield* resolveConcurrencyLimit;
850
+ const busyRef = yield* import_effect7.Ref.make(false);
851
+ const mapper = (payload) => import_effect7.Effect.gen(function* () {
852
+ const acquired = yield* import_effect7.Ref.modify(
853
+ busyRef,
854
+ (busy) => busy ? EXHAUST_REJECT_BUSY : EXHAUST_ACQUIRE_BUSY
855
+ );
856
+ if (!acquired) {
857
+ return;
858
+ }
859
+ try {
860
+ yield* run2(payload);
861
+ } finally {
862
+ yield* import_effect7.Ref.set(busyRef, false);
863
+ }
864
+ });
865
+ return yield* import_effect7.Stream.runDrain(stream.pipe(import_effect7.Stream.mapEffect(mapper, { concurrency })));
866
+ });
867
+ var runParallel = (stream, run2, resolveConcurrencyLimit) => import_effect7.Effect.gen(function* () {
868
+ const concurrency = yield* resolveConcurrencyLimit;
869
+ return yield* import_effect7.Stream.runDrain(stream.pipe(import_effect7.Stream.mapEffect(run2, { concurrency })));
870
+ });
871
+ var runByMode = (config) => {
872
+ const runLatest = config.runLatest ?? ((payload) => config.run(payload));
873
+ if (config.mode === "latest") {
874
+ const strategy = config.latest?.strategy ?? "switch";
875
+ if (strategy === "fiber-slot") {
876
+ return runLatestFiberSlot(config.stream, runLatest, config.latest?.awaitLatestOnEnd ?? false);
877
+ }
878
+ return runLatestSwitch(config.stream, runLatest);
879
+ }
880
+ if (config.mode === "exhaust") {
881
+ return runExhaust(config.stream, config.run, config.resolveConcurrencyLimit);
882
+ }
883
+ if (config.mode === "parallel") {
884
+ return runParallel(config.stream, config.run, config.resolveConcurrencyLimit);
885
+ }
886
+ return import_effect7.Stream.runForEach(config.stream, config.run);
887
+ };
366
888
 
367
889
  // src/internal/runtime/core/FlowRuntime.ts
368
- var getMiddlewareStack = () => import_effect6.Effect.serviceOption(EffectOpMiddlewareTag).pipe(
369
- import_effect6.Effect.map((maybe) => import_effect6.Option.isSome(maybe) ? maybe.value.stack : [])
890
+ var getMiddlewareStack = () => import_effect8.Effect.serviceOption(EffectOpMiddlewareTag).pipe(
891
+ import_effect8.Effect.map((maybe) => import_effect8.Option.isSome(maybe) ? maybe.value.stack : [])
370
892
  );
371
893
  var getRuntimeScope = (runtime) => {
372
894
  if (!runtime) return {};
@@ -377,13 +899,74 @@ var getRuntimeScope = (runtime) => {
377
899
  instanceId: typeof scope.instanceId === "string" ? scope.instanceId : void 0
378
900
  };
379
901
  };
380
- var resolveEffect = (eff, payload) => typeof eff === "function" ? eff(payload) : eff;
381
- var make2 = (runtime, runtimeInternals) => {
902
+ var hasChangesReadQueryWithMeta = (candidate) => {
903
+ if (candidate == null) return false;
904
+ if (typeof candidate !== "object" && typeof candidate !== "function") return false;
905
+ return typeof candidate.changesReadQueryWithMeta === "function";
906
+ };
907
+ var preResolveEffectResolver = (eff) => {
908
+ if (typeof eff === "function") {
909
+ return eff;
910
+ }
911
+ return () => eff;
912
+ };
913
+ var resolveFlowRunId = (name, meta, fallbackRunSeq) => {
914
+ const explicitRunId = meta.runId;
915
+ if (typeof explicitRunId === "string" && explicitRunId.length > 0) {
916
+ return explicitRunId;
917
+ }
918
+ const instanceId = typeof meta.instanceId === "string" && meta.instanceId.length > 0 ? meta.instanceId : "global";
919
+ const opSeq = meta.opSeq;
920
+ if (typeof opSeq === "number" && Number.isFinite(opSeq) && opSeq >= 1) {
921
+ return `${instanceId}::${name}::r${Math.floor(opSeq)}`;
922
+ }
923
+ if (typeof fallbackRunSeq === "number" && Number.isFinite(fallbackRunSeq) && fallbackRunSeq >= 1) {
924
+ return `${instanceId}::${name}::r${Math.floor(fallbackRunSeq)}`;
925
+ }
926
+ return `${instanceId}::${name}`;
927
+ };
928
+ var withFlowRunBudgetMeta = (name, meta, fallbackRunSeq) => {
929
+ const disableObservers = typeof meta.policy === "object" && meta.policy !== null && meta.policy.disableObservers === true;
930
+ return {
931
+ ...meta,
932
+ budgetEnvelope: makeRunBudgetEnvelopeV1({
933
+ domain: "flow",
934
+ runId: resolveFlowRunId(name, meta, fallbackRunSeq)
935
+ }),
936
+ degrade: makeRunDegradeMarkerV1(disableObservers, disableObservers ? "observer_disabled" : void 0)
937
+ };
938
+ };
939
+ var isRunConfig = (input) => {
940
+ if (!input || typeof input !== "object") {
941
+ return false;
942
+ }
943
+ const candidate = input;
944
+ if (!("effect" in candidate)) {
945
+ return false;
946
+ }
947
+ const mode = candidate.mode;
948
+ if (mode === void 0) {
949
+ return true;
950
+ }
951
+ return mode === "task" || mode === "parallel" || mode === "latest" || mode === "exhaust";
952
+ };
953
+ var make3 = (runtime, runtimeInternals) => {
954
+ let flowBudgetRunSeq = 0;
382
955
  const scope = getRuntimeScope(runtime);
383
- const resolveConcurrencyLimit = () => runtimeInternals ? runtimeInternals.concurrency.resolveConcurrencyPolicy().pipe(import_effect6.Effect.map((p) => p.concurrencyLimit)) : import_effect6.Effect.succeed(16);
384
- const runAsFlowOp = (name, payload, eff, options) => import_effect6.Effect.gen(function* () {
956
+ const resolveConcurrencyLimit = () => runtimeInternals ? runtimeInternals.concurrency.resolveConcurrencyPolicy().pipe(import_effect8.Effect.map((p) => p.concurrencyLimit)) : import_effect8.Effect.succeed(16);
957
+ const makeFlowOpRunContext = (options) => import_effect8.Effect.gen(function* () {
385
958
  const stack = yield* getMiddlewareStack();
386
- const meta = {
959
+ if (stack.length === 0) {
960
+ return {
961
+ stack,
962
+ hasMiddleware: false,
963
+ metaTemplate: {},
964
+ hasFiniteTemplateOpSeq: false,
965
+ allocateOpSeq: void 0
966
+ };
967
+ }
968
+ const sessionOpt = yield* import_effect8.Effect.serviceOption(RunSessionTag);
969
+ const metaTemplate = {
387
970
  ...options?.meta ?? {},
388
971
  policy: options?.policy,
389
972
  tags: options?.tags,
@@ -391,112 +974,146 @@ var make2 = (runtime, runtimeInternals) => {
391
974
  moduleId: scope.moduleId,
392
975
  instanceId: scope.instanceId
393
976
  };
394
- if (!(typeof meta.opSeq === "number" && Number.isFinite(meta.opSeq))) {
395
- const sessionOpt = yield* import_effect6.Effect.serviceOption(RunSessionTag);
396
- if (import_effect6.Option.isSome(sessionOpt)) {
397
- const key = meta.instanceId ?? "global";
398
- meta.opSeq = sessionOpt.value.local.nextSeq("opSeq", key);
399
- }
977
+ const hasFiniteTemplateOpSeq = typeof metaTemplate.opSeq === "number" && Number.isFinite(metaTemplate.opSeq);
978
+ const runSessionLocal = import_effect8.Option.isSome(sessionOpt) ? sessionOpt.value.local : void 0;
979
+ const opSeqKey = metaTemplate.instanceId ?? "global";
980
+ const allocateOpSeq = runSessionLocal ? () => runSessionLocal.nextSeq("opSeq", opSeqKey) : void 0;
981
+ return {
982
+ stack,
983
+ hasMiddleware: true,
984
+ metaTemplate,
985
+ hasFiniteTemplateOpSeq,
986
+ allocateOpSeq
987
+ };
988
+ });
989
+ const buildFlowOpMeta = (context) => {
990
+ if (context.hasFiniteTemplateOpSeq) {
991
+ return { ...context.metaTemplate };
992
+ }
993
+ if (context.allocateOpSeq) {
994
+ return {
995
+ ...context.metaTemplate,
996
+ opSeq: context.allocateOpSeq()
997
+ };
998
+ }
999
+ return context.metaTemplate;
1000
+ };
1001
+ const runAsFlowOp = (context, name, payload, eff) => {
1002
+ if (!context.hasMiddleware) {
1003
+ return eff;
400
1004
  }
401
- const op = make({
402
- kind: "flow",
403
- name,
404
- payload,
405
- effect: eff,
406
- meta
1005
+ return import_effect8.Effect.gen(function* () {
1006
+ flowBudgetRunSeq += 1;
1007
+ const meta = withFlowRunBudgetMeta(name, buildFlowOpMeta(context), flowBudgetRunSeq);
1008
+ const op = make({
1009
+ kind: "flow",
1010
+ name,
1011
+ payload,
1012
+ effect: eff,
1013
+ meta
1014
+ });
1015
+ return yield* run(op, context.stack);
1016
+ });
1017
+ };
1018
+ const makeFlowOpMapper = (context, name, resolver) => {
1019
+ if (!context.hasMiddleware) {
1020
+ return resolver;
1021
+ }
1022
+ return (payload) => runAsFlowOp(context, name, payload, resolver(payload));
1023
+ };
1024
+ const runStreamWithMode = (mode, name, resolver, options) => (stream) => import_effect8.Effect.gen(function* () {
1025
+ const context = yield* makeFlowOpRunContext(options);
1026
+ const mapper = makeFlowOpMapper(context, name, resolver);
1027
+ return yield* runByMode({
1028
+ stream,
1029
+ mode,
1030
+ run: mapper,
1031
+ resolveConcurrencyLimit: resolveConcurrencyLimit(),
1032
+ latest: {
1033
+ strategy: "switch"
1034
+ }
407
1035
  });
408
- return yield* run(op, stack);
409
1036
  });
410
- const runEffect = (eff) => (payload) => resolveEffect(eff, payload);
411
- const runStreamSequential = (eff, options) => (stream) => import_effect6.Stream.runForEach(
412
- stream,
413
- (payload) => runAsFlowOp("flow.run", payload, runEffect(eff)(payload), options)
1037
+ const runStreamParallelWithDiagnostics = (resolver, options) => (stream) => runStreamWithMode("parallel", "flow.runParallel", resolver, options)(stream).pipe(
1038
+ import_effect8.Effect.catchCause((cause) => record({
1039
+ type: "diagnostic",
1040
+ moduleId: scope.moduleId,
1041
+ instanceId: scope.instanceId,
1042
+ code: "flow::unhandled_failure",
1043
+ severity: "error",
1044
+ message: "Flow watcher (runParallel) failed with an unhandled error.",
1045
+ hint: "Handle errors explicitly inside the watcher (catch/catchAll) or write back via TaskRunner failure; avoid silent failures.",
1046
+ kind: "flow_unhandled_failure",
1047
+ trigger: {
1048
+ kind: "flow",
1049
+ name: "runParallel"
1050
+ }
1051
+ }).pipe(import_effect8.Effect.flatMap(() => import_effect8.Effect.failCause(cause))))
414
1052
  );
415
- const runStreamParallel = (eff, options) => (stream) => import_effect6.Effect.gen(function* () {
416
- const concurrency = yield* resolveConcurrencyLimit();
417
- return yield* import_effect6.Stream.runDrain(
418
- stream.pipe(
419
- import_effect6.Stream.mapEffect(
420
- (payload) => runAsFlowOp("flow.runParallel", payload, runEffect(eff)(payload), options),
421
- { concurrency }
422
- )
423
- )
424
- ).pipe(
425
- import_effect6.Effect.catchAllCause(
426
- (cause) => record({
427
- type: "diagnostic",
428
- moduleId: scope.moduleId,
429
- instanceId: scope.instanceId,
430
- code: "flow::unhandled_failure",
431
- severity: "error",
432
- message: "Flow watcher (runParallel) failed with an unhandled error.",
433
- hint: "Handle errors explicitly inside the watcher (catch/catchAll) or write back via TaskRunner failure; avoid silent failures.",
434
- kind: "flow_unhandled_failure",
435
- trigger: {
436
- kind: "flow",
437
- name: "runParallel"
438
- }
439
- }).pipe(import_effect6.Effect.zipRight(import_effect6.Effect.failCause(cause)))
440
- )
441
- );
442
- });
1053
+ const fromState = (selectorOrQuery) => {
1054
+ const runtimeWithReadQueryMeta = hasChangesReadQueryWithMeta(runtime) ? runtime : void 0;
1055
+ if (isReadQuery(selectorOrQuery)) {
1056
+ if (runtimeWithReadQueryMeta) {
1057
+ return runtimeWithReadQueryMeta.changesReadQueryWithMeta(selectorOrQuery).pipe(import_effect8.Stream.map((evt) => evt.value));
1058
+ }
1059
+ return runtime.changes(selectorOrQuery.select);
1060
+ }
1061
+ if (!runtimeWithReadQueryMeta) {
1062
+ return runtime.changes(selectorOrQuery);
1063
+ }
1064
+ const compiled = compile(selectorOrQuery);
1065
+ if (compiled.lane === "static") {
1066
+ return runtimeWithReadQueryMeta.changesReadQueryWithMeta(compiled).pipe(import_effect8.Stream.map((evt) => evt.value));
1067
+ }
1068
+ return runtime.changes(selectorOrQuery);
1069
+ };
443
1070
  return {
444
- fromAction: (predicate) => runtime.actions$.pipe(import_effect6.Stream.filter(predicate)),
445
- fromState: (selectorOrQuery) => runtime.changes(isReadQuery(selectorOrQuery) ? selectorOrQuery.select : selectorOrQuery),
446
- debounce: (ms) => (stream) => import_effect6.Stream.debounce(stream, ms),
447
- throttle: (ms) => (stream) => import_effect6.Stream.throttle(stream, {
1071
+ fromAction: (predicate) => runtime.actions$.pipe(import_effect8.Stream.filter(predicate)),
1072
+ fromState,
1073
+ debounce: (ms) => (stream) => import_effect8.Stream.debounce(stream, ms),
1074
+ throttle: (ms) => (stream) => import_effect8.Stream.throttle(stream, {
448
1075
  cost: () => 1,
449
1076
  units: 1,
450
1077
  duration: ms,
451
1078
  strategy: "enforce"
452
1079
  }),
453
- filter: (predicate) => (stream) => import_effect6.Stream.filter(stream, predicate),
454
- run: (eff, options) => (stream) => runStreamSequential(eff, options)(stream),
455
- runParallel: (eff, options) => (stream) => runStreamParallel(eff, options)(stream),
456
- runLatest: (eff, options) => (stream) => import_effect6.Stream.runDrain(
457
- import_effect6.Stream.map(
458
- stream,
459
- (payload) => runAsFlowOp(
460
- "flow.runLatest",
461
- payload,
462
- runEffect(eff)(payload),
463
- options
464
- )
465
- ).pipe(
466
- import_effect6.Stream.flatMap((effect) => import_effect6.Stream.fromEffect(effect), {
467
- switch: true
468
- })
469
- )
470
- ),
471
- runExhaust: (eff, options) => (stream) => import_effect6.Effect.gen(function* () {
472
- const concurrency = yield* resolveConcurrencyLimit();
473
- const busyRef = yield* import_effect6.Ref.make(false);
474
- const mapper = (payload) => import_effect6.Effect.gen(function* () {
475
- const acquired = yield* import_effect6.Ref.modify(
476
- busyRef,
477
- (busy) => busy ? [false, busy] : [true, true]
478
- );
479
- if (!acquired) {
480
- return;
481
- }
482
- try {
483
- yield* runAsFlowOp(
484
- "flow.runExhaust",
485
- payload,
486
- runEffect(eff)(payload),
487
- options
488
- );
489
- } finally {
490
- yield* import_effect6.Ref.set(busyRef, false);
491
- }
492
- });
493
- return yield* import_effect6.Stream.runDrain(stream.pipe(import_effect6.Stream.mapEffect(mapper, { concurrency })));
494
- })
1080
+ filter: (predicate) => (stream) => import_effect8.Stream.filter(stream, predicate),
1081
+ run: (effOrConfig, options) => (stream) => {
1082
+ const mode = isRunConfig(effOrConfig) ? effOrConfig.mode ?? "task" : "task";
1083
+ const resolvedOptions = isRunConfig(effOrConfig) ? effOrConfig.options : options;
1084
+ const effect = isRunConfig(effOrConfig) ? effOrConfig.effect : effOrConfig;
1085
+ const resolver = preResolveEffectResolver(effect);
1086
+ if (mode === "parallel") {
1087
+ return runStreamParallelWithDiagnostics(resolver, resolvedOptions)(stream);
1088
+ }
1089
+ return runStreamWithMode(
1090
+ mode,
1091
+ mode === "latest" ? "flow.runLatest" : mode === "exhaust" ? "flow.runExhaust" : "flow.run",
1092
+ resolver,
1093
+ resolvedOptions
1094
+ )(stream);
1095
+ },
1096
+ runParallel: (eff, options) => (stream) => runStreamParallelWithDiagnostics(
1097
+ preResolveEffectResolver(eff),
1098
+ options
1099
+ )(stream),
1100
+ runLatest: (eff, options) => (stream) => runStreamWithMode(
1101
+ "latest",
1102
+ "flow.runLatest",
1103
+ preResolveEffectResolver(eff),
1104
+ options
1105
+ )(stream),
1106
+ runExhaust: (eff, options) => (stream) => runStreamWithMode(
1107
+ "exhaust",
1108
+ "flow.runExhaust",
1109
+ preResolveEffectResolver(eff),
1110
+ options
1111
+ )(stream)
495
1112
  };
496
1113
  };
497
1114
 
498
1115
  // src/Flow.ts
499
- var make3 = make2;
1116
+ var make4 = make3;
500
1117
  // Annotate the CommonJS export names for ESM import in node:
501
1118
  0 && (module.exports = {
502
1119
  make