@logixjs/core 0.0.1

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 (345) hide show
  1. package/dist/Action-BkRHy2vg.d.cts +10 -0
  2. package/dist/Action-mqVvtEHt.d.ts +10 -0
  3. package/dist/Action.cjs +57 -0
  4. package/dist/Action.cjs.map +1 -0
  5. package/dist/Action.d.cts +2 -0
  6. package/dist/Action.d.ts +2 -0
  7. package/dist/Action.js +9 -0
  8. package/dist/Action.js.map +1 -0
  9. package/dist/Actions-AsQ07yTP.d.cts +22 -0
  10. package/dist/Actions-AsQ07yTP.d.ts +22 -0
  11. package/dist/Actions.cjs +19 -0
  12. package/dist/Actions.cjs.map +1 -0
  13. package/dist/Actions.d.cts +2 -0
  14. package/dist/Actions.d.ts +2 -0
  15. package/dist/Actions.js +2 -0
  16. package/dist/Actions.js.map +1 -0
  17. package/dist/Bound-BN1DQ_lM.d.ts +23 -0
  18. package/dist/Bound-BPIfH9SS.d.cts +23 -0
  19. package/dist/Bound.cjs +1532 -0
  20. package/dist/Bound.cjs.map +1 -0
  21. package/dist/Bound.d.cts +7 -0
  22. package/dist/Bound.d.ts +7 -0
  23. package/dist/Bound.js +25 -0
  24. package/dist/Bound.js.map +1 -0
  25. package/dist/Debug-B5q5Bkzx.d.ts +320 -0
  26. package/dist/Debug-Bq8Sqjcr.d.cts +320 -0
  27. package/dist/Debug.cjs +1821 -0
  28. package/dist/Debug.cjs.map +1 -0
  29. package/dist/Debug.d.cts +13 -0
  30. package/dist/Debug.d.ts +13 -0
  31. package/dist/Debug.js +76 -0
  32. package/dist/Debug.js.map +1 -0
  33. package/dist/EffectOp.cjs +169 -0
  34. package/dist/EffectOp.cjs.map +1 -0
  35. package/dist/EffectOp.d.cts +118 -0
  36. package/dist/EffectOp.d.ts +118 -0
  37. package/dist/EffectOp.js +28 -0
  38. package/dist/EffectOp.js.map +1 -0
  39. package/dist/Env-DuJ6JrU2.d.cts +10 -0
  40. package/dist/Env-DuJ6JrU2.d.ts +10 -0
  41. package/dist/Env.cjs +60 -0
  42. package/dist/Env.cjs.map +1 -0
  43. package/dist/Env.d.cts +1 -0
  44. package/dist/Env.d.ts +1 -0
  45. package/dist/Env.js +11 -0
  46. package/dist/Env.js.map +1 -0
  47. package/dist/Flow-1fZT8MpX.d.cts +152 -0
  48. package/dist/Flow-BhpjE22E.d.ts +152 -0
  49. package/dist/Flow.cjs +504 -0
  50. package/dist/Flow.cjs.map +1 -0
  51. package/dist/Flow.d.cts +8 -0
  52. package/dist/Flow.d.ts +8 -0
  53. package/dist/Flow.js +15 -0
  54. package/dist/Flow.js.map +1 -0
  55. package/dist/Handle-D8D1zPb_.d.cts +30 -0
  56. package/dist/Handle-D_cLW1Z3.d.ts +30 -0
  57. package/dist/Handle.cjs +42 -0
  58. package/dist/Handle.cjs.map +1 -0
  59. package/dist/Handle.d.cts +7 -0
  60. package/dist/Handle.d.ts +7 -0
  61. package/dist/Handle.js +10 -0
  62. package/dist/Handle.js.map +1 -0
  63. package/dist/Kernel-8kC-jOda.d.cts +171 -0
  64. package/dist/Kernel-CnGE1Fyk.d.ts +171 -0
  65. package/dist/Kernel.cjs +284 -0
  66. package/dist/Kernel.cjs.map +1 -0
  67. package/dist/Kernel.d.cts +14 -0
  68. package/dist/Kernel.d.ts +14 -0
  69. package/dist/Kernel.js +36 -0
  70. package/dist/Kernel.js.map +1 -0
  71. package/dist/Link-Db7975nU.d.ts +45 -0
  72. package/dist/Link-fX8x1eCK.d.cts +45 -0
  73. package/dist/Link.cjs +542 -0
  74. package/dist/Link.cjs.map +1 -0
  75. package/dist/Link.d.cts +7 -0
  76. package/dist/Link.d.ts +7 -0
  77. package/dist/Link.js +35 -0
  78. package/dist/Link.js.map +1 -0
  79. package/dist/Logic-BRjEMr-W.d.ts +38 -0
  80. package/dist/Logic-DRh4sDZj.d.cts +38 -0
  81. package/dist/Logic.cjs +37 -0
  82. package/dist/Logic.cjs.map +1 -0
  83. package/dist/Logic.d.cts +7 -0
  84. package/dist/Logic.d.ts +7 -0
  85. package/dist/Logic.js +10 -0
  86. package/dist/Logic.js.map +1 -0
  87. package/dist/MatchBuilder-0QOc-nlU.d.ts +14 -0
  88. package/dist/MatchBuilder-CJk5oCkR.d.cts +14 -0
  89. package/dist/MatchBuilder.cjs +85 -0
  90. package/dist/MatchBuilder.cjs.map +1 -0
  91. package/dist/MatchBuilder.d.cts +8 -0
  92. package/dist/MatchBuilder.d.ts +8 -0
  93. package/dist/MatchBuilder.js +11 -0
  94. package/dist/MatchBuilder.js.map +1 -0
  95. package/dist/Middleware.cjs +411 -0
  96. package/dist/Middleware.cjs.map +1 -0
  97. package/dist/Middleware.d.cts +88 -0
  98. package/dist/Middleware.d.ts +88 -0
  99. package/dist/Middleware.js +27 -0
  100. package/dist/Middleware.js.map +1 -0
  101. package/dist/Module-B_0xRDMR.d.cts +203 -0
  102. package/dist/Module-DnzluX2J.d.ts +203 -0
  103. package/dist/Module.cjs +13512 -0
  104. package/dist/Module.cjs.map +1 -0
  105. package/dist/Module.d.cts +8 -0
  106. package/dist/Module.d.ts +8 -0
  107. package/dist/Module.js +53 -0
  108. package/dist/Module.js.map +1 -0
  109. package/dist/ModuleTag-C8FHY_sY.d.ts +93 -0
  110. package/dist/ModuleTag-EGbgBMpZ.d.cts +93 -0
  111. package/dist/ModuleTag.cjs +12231 -0
  112. package/dist/ModuleTag.cjs.map +1 -0
  113. package/dist/ModuleTag.d.cts +8 -0
  114. package/dist/ModuleTag.d.ts +8 -0
  115. package/dist/ModuleTag.js +39 -0
  116. package/dist/ModuleTag.js.map +1 -0
  117. package/dist/Observability-COqEvp2C.d.cts +713 -0
  118. package/dist/Observability-cY4kLn0S.d.ts +713 -0
  119. package/dist/Observability.cjs +5865 -0
  120. package/dist/Observability.cjs.map +1 -0
  121. package/dist/Observability.d.cts +9 -0
  122. package/dist/Observability.d.ts +9 -0
  123. package/dist/Observability.js +41 -0
  124. package/dist/Observability.js.map +1 -0
  125. package/dist/Platform-C49Pv956.d.cts +21 -0
  126. package/dist/Platform-C49Pv956.d.ts +21 -0
  127. package/dist/Platform-CHX8o-U4.d.ts +51 -0
  128. package/dist/Platform-CVlv0xLQ.d.cts +51 -0
  129. package/dist/Platform.cjs +58 -0
  130. package/dist/Platform.cjs.map +1 -0
  131. package/dist/Platform.d.cts +4 -0
  132. package/dist/Platform.d.ts +4 -0
  133. package/dist/Platform.js +15 -0
  134. package/dist/Platform.js.map +1 -0
  135. package/dist/Process-CM9xbMdP.d.ts +92 -0
  136. package/dist/Process-mL8fHDSB.d.cts +92 -0
  137. package/dist/Process.cjs +575 -0
  138. package/dist/Process.cjs.map +1 -0
  139. package/dist/Process.d.cts +8 -0
  140. package/dist/Process.d.ts +8 -0
  141. package/dist/Process.js +42 -0
  142. package/dist/Process.js.map +1 -0
  143. package/dist/ReadQuery-BlMwhe-F.d.ts +30 -0
  144. package/dist/ReadQuery-CL5XlXts.d.cts +30 -0
  145. package/dist/ReadQuery-SinbStGF.d.cts +38 -0
  146. package/dist/ReadQuery-SinbStGF.d.ts +38 -0
  147. package/dist/ReadQuery.cjs +377 -0
  148. package/dist/ReadQuery.cjs.map +1 -0
  149. package/dist/ReadQuery.d.cts +2 -0
  150. package/dist/ReadQuery.d.ts +2 -0
  151. package/dist/ReadQuery.js +14 -0
  152. package/dist/ReadQuery.js.map +1 -0
  153. package/dist/Reflection-CQnKwPXj.d.ts +182 -0
  154. package/dist/Reflection-Kabo1mlU.d.cts +182 -0
  155. package/dist/Reflection.cjs +2954 -0
  156. package/dist/Reflection.cjs.map +1 -0
  157. package/dist/Reflection.d.cts +17 -0
  158. package/dist/Reflection.d.ts +17 -0
  159. package/dist/Reflection.js +40 -0
  160. package/dist/Reflection.js.map +1 -0
  161. package/dist/Resource-Dy1xD_DG.d.cts +75 -0
  162. package/dist/Resource-Dy1xD_DG.d.ts +75 -0
  163. package/dist/Resource.cjs +166 -0
  164. package/dist/Resource.cjs.map +1 -0
  165. package/dist/Resource.d.cts +3 -0
  166. package/dist/Resource.d.ts +3 -0
  167. package/dist/Resource.js +21 -0
  168. package/dist/Resource.js.map +1 -0
  169. package/dist/Root-7ADUMk4t.d.cts +29 -0
  170. package/dist/Root-7ADUMk4t.d.ts +29 -0
  171. package/dist/Root.cjs +125 -0
  172. package/dist/Root.cjs.map +1 -0
  173. package/dist/Root.d.cts +4 -0
  174. package/dist/Root.d.ts +4 -0
  175. package/dist/Root.js +12 -0
  176. package/dist/Root.js.map +1 -0
  177. package/dist/Runtime-B-aL-f29.d.cts +274 -0
  178. package/dist/Runtime-CtyzZG4i.d.ts +274 -0
  179. package/dist/Runtime.cjs +5740 -0
  180. package/dist/Runtime.cjs.map +1 -0
  181. package/dist/Runtime.d.cts +19 -0
  182. package/dist/Runtime.d.ts +19 -0
  183. package/dist/Runtime.js +62 -0
  184. package/dist/Runtime.js.map +1 -0
  185. package/dist/ScopeRegistry-D1owDNSm.d.cts +61 -0
  186. package/dist/ScopeRegistry-D1owDNSm.d.ts +61 -0
  187. package/dist/ScopeRegistry.cjs +152 -0
  188. package/dist/ScopeRegistry.cjs.map +1 -0
  189. package/dist/ScopeRegistry.d.cts +2 -0
  190. package/dist/ScopeRegistry.d.ts +2 -0
  191. package/dist/ScopeRegistry.js +16 -0
  192. package/dist/ScopeRegistry.js.map +1 -0
  193. package/dist/State-CU50R26M.d.cts +19 -0
  194. package/dist/State-CU50R26M.d.ts +19 -0
  195. package/dist/State.cjs +19 -0
  196. package/dist/State.cjs.map +1 -0
  197. package/dist/State.d.cts +2 -0
  198. package/dist/State.d.ts +2 -0
  199. package/dist/State.js +2 -0
  200. package/dist/State.js.map +1 -0
  201. package/dist/StateTrait-BGsZghTz.d.ts +122 -0
  202. package/dist/StateTrait-OWhbj12c.d.cts +122 -0
  203. package/dist/StateTrait.cjs +2737 -0
  204. package/dist/StateTrait.cjs.map +1 -0
  205. package/dist/StateTrait.d.cts +9 -0
  206. package/dist/StateTrait.d.ts +9 -0
  207. package/dist/StateTrait.js +39 -0
  208. package/dist/StateTrait.js.map +1 -0
  209. package/dist/TraitLifecycle-CwV5WPFX.d.cts +88 -0
  210. package/dist/TraitLifecycle-LdIWmKlg.d.ts +88 -0
  211. package/dist/TraitLifecycle.cjs +581 -0
  212. package/dist/TraitLifecycle.cjs.map +1 -0
  213. package/dist/TraitLifecycle.d.cts +8 -0
  214. package/dist/TraitLifecycle.d.ts +8 -0
  215. package/dist/TraitLifecycle.js +24 -0
  216. package/dist/TraitLifecycle.js.map +1 -0
  217. package/dist/action-DiMDD_0v.d.cts +35 -0
  218. package/dist/action-DiMDD_0v.d.ts +35 -0
  219. package/dist/chunk-24VULZ7A.js +76 -0
  220. package/dist/chunk-24VULZ7A.js.map +1 -0
  221. package/dist/chunk-3IYZ5IGG.js +17 -0
  222. package/dist/chunk-3IYZ5IGG.js.map +1 -0
  223. package/dist/chunk-3QMIVH35.js +43 -0
  224. package/dist/chunk-3QMIVH35.js.map +1 -0
  225. package/dist/chunk-3RMKLXHX.js +83 -0
  226. package/dist/chunk-3RMKLXHX.js.map +1 -0
  227. package/dist/chunk-3TMODYZV.js +111 -0
  228. package/dist/chunk-3TMODYZV.js.map +1 -0
  229. package/dist/chunk-3VG5TWQR.js +27 -0
  230. package/dist/chunk-3VG5TWQR.js.map +1 -0
  231. package/dist/chunk-4CQAV7YB.js +37 -0
  232. package/dist/chunk-4CQAV7YB.js.map +1 -0
  233. package/dist/chunk-4SO6JMZL.js +7 -0
  234. package/dist/chunk-4SO6JMZL.js.map +1 -0
  235. package/dist/chunk-66ALHVEX.js +40 -0
  236. package/dist/chunk-66ALHVEX.js.map +1 -0
  237. package/dist/chunk-76WT3HOR.js +397 -0
  238. package/dist/chunk-76WT3HOR.js.map +1 -0
  239. package/dist/chunk-ANLBCBDC.js +285 -0
  240. package/dist/chunk-ANLBCBDC.js.map +1 -0
  241. package/dist/chunk-AUIR5O6W.js +75 -0
  242. package/dist/chunk-AUIR5O6W.js.map +1 -0
  243. package/dist/chunk-BABLDP24.js +445 -0
  244. package/dist/chunk-BABLDP24.js.map +1 -0
  245. package/dist/chunk-BE3HW4FY.js +1099 -0
  246. package/dist/chunk-BE3HW4FY.js.map +1 -0
  247. package/dist/chunk-BZ2SHDN2.js +54 -0
  248. package/dist/chunk-BZ2SHDN2.js.map +1 -0
  249. package/dist/chunk-CW6T36TN.js +393 -0
  250. package/dist/chunk-CW6T36TN.js.map +1 -0
  251. package/dist/chunk-DFNM3WX2.js +632 -0
  252. package/dist/chunk-DFNM3WX2.js.map +1 -0
  253. package/dist/chunk-DMBALCE2.js +1034 -0
  254. package/dist/chunk-DMBALCE2.js.map +1 -0
  255. package/dist/chunk-EGK3KN7B.js +406 -0
  256. package/dist/chunk-EGK3KN7B.js.map +1 -0
  257. package/dist/chunk-EY4NZKDR.js +19 -0
  258. package/dist/chunk-EY4NZKDR.js.map +1 -0
  259. package/dist/chunk-G5ZBFPNU.js +23 -0
  260. package/dist/chunk-G5ZBFPNU.js.map +1 -0
  261. package/dist/chunk-GMPEOUP2.js +31 -0
  262. package/dist/chunk-GMPEOUP2.js.map +1 -0
  263. package/dist/chunk-IHVBV5C2.js +279 -0
  264. package/dist/chunk-IHVBV5C2.js.map +1 -0
  265. package/dist/chunk-IPF7E66P.js +23 -0
  266. package/dist/chunk-IPF7E66P.js.map +1 -0
  267. package/dist/chunk-JCXGZRMU.js +204 -0
  268. package/dist/chunk-JCXGZRMU.js.map +1 -0
  269. package/dist/chunk-JGIWG6SR.js +6359 -0
  270. package/dist/chunk-JGIWG6SR.js.map +1 -0
  271. package/dist/chunk-JWOYLO27.js +241 -0
  272. package/dist/chunk-JWOYLO27.js.map +1 -0
  273. package/dist/chunk-KIXAU3GM.js +137 -0
  274. package/dist/chunk-KIXAU3GM.js.map +1 -0
  275. package/dist/chunk-KL5ACTCT.js +8 -0
  276. package/dist/chunk-KL5ACTCT.js.map +1 -0
  277. package/dist/chunk-KP7MUZNX.js +83 -0
  278. package/dist/chunk-KP7MUZNX.js.map +1 -0
  279. package/dist/chunk-LEU6UA5J.js +1 -0
  280. package/dist/chunk-LEU6UA5J.js.map +1 -0
  281. package/dist/chunk-M2RGJPXX.js +35 -0
  282. package/dist/chunk-M2RGJPXX.js.map +1 -0
  283. package/dist/chunk-M3BFQ7HK.js +13 -0
  284. package/dist/chunk-M3BFQ7HK.js.map +1 -0
  285. package/dist/chunk-M3WTHJHJ.js +1051 -0
  286. package/dist/chunk-M3WTHJHJ.js.map +1 -0
  287. package/dist/chunk-M7IYCTJV.js +79 -0
  288. package/dist/chunk-M7IYCTJV.js.map +1 -0
  289. package/dist/chunk-NBD3KUOZ.js +838 -0
  290. package/dist/chunk-NBD3KUOZ.js.map +1 -0
  291. package/dist/chunk-NQZ2OSGR.js +151 -0
  292. package/dist/chunk-NQZ2OSGR.js.map +1 -0
  293. package/dist/chunk-NZJKFF45.js +106 -0
  294. package/dist/chunk-NZJKFF45.js.map +1 -0
  295. package/dist/chunk-OFADUJWJ.js +175 -0
  296. package/dist/chunk-OFADUJWJ.js.map +1 -0
  297. package/dist/chunk-OGWBVHB3.js +461 -0
  298. package/dist/chunk-OGWBVHB3.js.map +1 -0
  299. package/dist/chunk-PAYXCY6A.js +1696 -0
  300. package/dist/chunk-PAYXCY6A.js.map +1 -0
  301. package/dist/chunk-PYOE4VSI.js +1924 -0
  302. package/dist/chunk-PYOE4VSI.js.map +1 -0
  303. package/dist/chunk-PZ5AY32C.js +10 -0
  304. package/dist/chunk-PZ5AY32C.js.map +1 -0
  305. package/dist/chunk-QCHIQWAJ.js +21 -0
  306. package/dist/chunk-QCHIQWAJ.js.map +1 -0
  307. package/dist/chunk-QMM6O4CD.js +71 -0
  308. package/dist/chunk-QMM6O4CD.js.map +1 -0
  309. package/dist/chunk-RNFE3ML2.js +22 -0
  310. package/dist/chunk-RNFE3ML2.js.map +1 -0
  311. package/dist/chunk-TAAPQVZN.js +23 -0
  312. package/dist/chunk-TAAPQVZN.js.map +1 -0
  313. package/dist/chunk-THATMZXD.js +21 -0
  314. package/dist/chunk-THATMZXD.js.map +1 -0
  315. package/dist/chunk-TKZ7MEIA.js +27 -0
  316. package/dist/chunk-TKZ7MEIA.js.map +1 -0
  317. package/dist/chunk-TQOBJYDP.js +7 -0
  318. package/dist/chunk-TQOBJYDP.js.map +1 -0
  319. package/dist/chunk-VZB726PE.js +93 -0
  320. package/dist/chunk-VZB726PE.js.map +1 -0
  321. package/dist/chunk-W3TEWHLO.js +568 -0
  322. package/dist/chunk-W3TEWHLO.js.map +1 -0
  323. package/dist/chunk-YS3AZQ2G.js +52 -0
  324. package/dist/chunk-YS3AZQ2G.js.map +1 -0
  325. package/dist/chunk-ZDTRWK5F.js +40 -0
  326. package/dist/chunk-ZDTRWK5F.js.map +1 -0
  327. package/dist/chunk-ZFLHVFUC.js +192 -0
  328. package/dist/chunk-ZFLHVFUC.js.map +1 -0
  329. package/dist/chunk-ZFY7U2FR.js +133 -0
  330. package/dist/chunk-ZFY7U2FR.js.map +1 -0
  331. package/dist/chunk-ZGDVUPTM.js +270 -0
  332. package/dist/chunk-ZGDVUPTM.js.map +1 -0
  333. package/dist/index.cjs +19700 -0
  334. package/dist/index.cjs.map +1 -0
  335. package/dist/index.d.cts +195 -0
  336. package/dist/index.d.ts +195 -0
  337. package/dist/index.js +286 -0
  338. package/dist/index.js.map +1 -0
  339. package/dist/ir-BMP7yxJJ.d.cts +39 -0
  340. package/dist/ir-DUOz6H-5.d.ts +39 -0
  341. package/dist/module-B8CBqIZ_.d.cts +1191 -0
  342. package/dist/module-k7m3txak.d.ts +1191 -0
  343. package/dist/protocol-g_1897M2.d.cts +127 -0
  344. package/dist/protocol-g_1897M2.d.ts +127 -0
  345. package/package.json +162 -0
package/dist/Debug.cjs ADDED
@@ -0,0 +1,1821 @@
1
+ "use strict";
2
+ var __defProp = Object.defineProperty;
3
+ var __getOwnPropDesc = Object.getOwnPropertyDescriptor;
4
+ var __getOwnPropNames = Object.getOwnPropertyNames;
5
+ var __hasOwnProp = Object.prototype.hasOwnProperty;
6
+ var __export = (target, all) => {
7
+ for (var name in all)
8
+ __defProp(target, name, { get: all[name], enumerable: true });
9
+ };
10
+ var __copyProps = (to, from, except, desc) => {
11
+ if (from && typeof from === "object" || typeof from === "function") {
12
+ for (let key of __getOwnPropNames(from))
13
+ if (!__hasOwnProp.call(to, key) && key !== except)
14
+ __defProp(to, key, { get: () => from[key], enumerable: !(desc = __getOwnPropDesc(from, key)) || desc.enumerable });
15
+ }
16
+ return to;
17
+ };
18
+ var __toCommonJS = (mod) => __copyProps(__defProp({}, "__esModule", { value: true }), mod);
19
+
20
+ // src/Debug.ts
21
+ var Debug_exports = {};
22
+ __export(Debug_exports, {
23
+ appendSinks: () => appendSinks,
24
+ clearDevtoolsEvents: () => clearDevtoolsEvents2,
25
+ devtoolsHubLayer: () => devtoolsHubLayer,
26
+ diagnosticsLevel: () => diagnosticsLevel,
27
+ exportEvidencePackage: () => exportEvidencePackage2,
28
+ getDevtoolsRunId: () => getDevtoolsRunId2,
29
+ getDevtoolsSnapshot: () => getDevtoolsSnapshot2,
30
+ getDevtoolsSnapshotToken: () => getDevtoolsSnapshotToken2,
31
+ getInstanceLabel: () => getInstanceLabel2,
32
+ getModuleFinalTraits: () => getModuleFinalTraits,
33
+ getModuleTraits: () => getModuleTraits,
34
+ getModuleTraitsById: () => getModuleTraitsById,
35
+ getModuleTraitsSnapshot: () => getModuleTraitsSnapshot,
36
+ internal: () => internal,
37
+ isDevtoolsEnabled: () => isDevtoolsEnabled2,
38
+ layer: () => layer,
39
+ makeModuleRuntimeCounterSink: () => makeModuleRuntimeCounterSink,
40
+ makeRingBufferSink: () => makeRingBufferSink,
41
+ noopLayer: () => noopLayer2,
42
+ record: () => record2,
43
+ replace: () => replace,
44
+ runtimeLabel: () => runtimeLabel,
45
+ setDevtoolsRunId: () => setDevtoolsRunId2,
46
+ setInstanceLabel: () => setInstanceLabel2,
47
+ startDevtoolsRun: () => startDevtoolsRun2,
48
+ subscribeDevtoolsSnapshot: () => subscribeDevtoolsSnapshot2,
49
+ toRuntimeDebugEventRef: () => toRuntimeDebugEventRef2,
50
+ traceLayer: () => traceLayer,
51
+ traitConvergeDiagnosticsSampling: () => traitConvergeDiagnosticsSampling2,
52
+ withPrettyLogger: () => withPrettyLogger
53
+ });
54
+ module.exports = __toCommonJS(Debug_exports);
55
+ var import_effect7 = require("effect");
56
+
57
+ // src/internal/runtime/core/DebugSink.ts
58
+ var import_effect3 = require("effect");
59
+
60
+ // src/internal/observability/jsonValue.ts
61
+ var defaultOptions = {
62
+ maxDepth: 6,
63
+ maxObjectKeys: 32,
64
+ maxArrayLength: 32,
65
+ maxStringLength: 256,
66
+ maxJsonBytes: 4 * 1024,
67
+ oversizedPreviewBytes: 256
68
+ };
69
+ var truncateString = (value, maxLen, stats) => {
70
+ if (value.length <= maxLen) return value;
71
+ stats.oversized += 1;
72
+ return value.slice(0, maxLen);
73
+ };
74
+ var mergeDowngrade = (current, next) => {
75
+ if (!current) return next;
76
+ if (current === "non_serializable" || next === "non_serializable") return "non_serializable";
77
+ if (current === "oversized" || next === "oversized") return "oversized";
78
+ return "unknown";
79
+ };
80
+ function isPlainRecord(value) {
81
+ if (typeof value !== "object" || value === null) return false;
82
+ const proto = Object.getPrototypeOf(value);
83
+ return proto === Object.prototype || proto === null;
84
+ }
85
+ var asNumber = (value, stats) => {
86
+ if (Number.isFinite(value)) return value;
87
+ stats.nonSerializable += 1;
88
+ return String(value);
89
+ };
90
+ var toJsonValueInternal = (input, options, stats, seen, depth) => {
91
+ if (input === null) return null;
92
+ switch (typeof input) {
93
+ case "string":
94
+ return truncateString(input, options.maxStringLength, stats);
95
+ case "number":
96
+ return asNumber(input, stats);
97
+ case "boolean":
98
+ return input;
99
+ case "bigint":
100
+ stats.nonSerializable += 1;
101
+ return truncateString(input.toString(), options.maxStringLength, stats);
102
+ case "symbol":
103
+ stats.nonSerializable += 1;
104
+ return truncateString(input.toString(), options.maxStringLength, stats);
105
+ case "function":
106
+ stats.nonSerializable += 1;
107
+ return "[Function]";
108
+ case "undefined":
109
+ stats.dropped += 1;
110
+ return null;
111
+ }
112
+ if (depth >= options.maxDepth) {
113
+ stats.oversized += 1;
114
+ return "[Truncated]";
115
+ }
116
+ if (input instanceof Date) {
117
+ return input.toISOString();
118
+ }
119
+ if (input instanceof Error) {
120
+ stats.nonSerializable += 1;
121
+ return {
122
+ name: truncateString(input.name, options.maxStringLength, stats),
123
+ message: truncateString(input.message, options.maxStringLength, stats)
124
+ };
125
+ }
126
+ if (typeof input === "object") {
127
+ if (seen.has(input)) {
128
+ stats.nonSerializable += 1;
129
+ return "[Circular]";
130
+ }
131
+ seen.add(input);
132
+ }
133
+ if (Array.isArray(input)) {
134
+ const out2 = [];
135
+ const limit2 = Math.min(input.length, options.maxArrayLength);
136
+ for (let i = 0; i < limit2; i++) {
137
+ out2.push(toJsonValueInternal(input[i], options, stats, seen, depth + 1));
138
+ }
139
+ if (input.length > limit2) {
140
+ stats.oversized += 1;
141
+ out2.push(`[...${input.length - limit2} more]`);
142
+ }
143
+ return out2;
144
+ }
145
+ if (!isPlainRecord(input)) {
146
+ stats.nonSerializable += 1;
147
+ return truncateString(String(input), options.maxStringLength, stats);
148
+ }
149
+ const entries = Object.entries(input);
150
+ const limit = Math.min(entries.length, options.maxObjectKeys);
151
+ const out = {};
152
+ for (let i = 0; i < limit; i++) {
153
+ const [rawKey, rawValue] = entries[i];
154
+ const key = truncateString(rawKey, options.maxStringLength, stats);
155
+ if (rawValue === void 0) {
156
+ stats.dropped += 1;
157
+ continue;
158
+ }
159
+ out[key] = toJsonValueInternal(rawValue, options, stats, seen, depth + 1);
160
+ }
161
+ if (entries.length > limit) {
162
+ stats.oversized += 1;
163
+ out.__truncatedKeys = entries.length - limit;
164
+ }
165
+ return out;
166
+ };
167
+ var projectJsonValue = (input, options) => {
168
+ const resolved = { ...defaultOptions, ...options ?? {} };
169
+ const stats = { dropped: 0, oversized: 0, nonSerializable: 0 };
170
+ const seen = /* @__PURE__ */ new WeakSet();
171
+ let downgrade;
172
+ const value = toJsonValueInternal(input, resolved, stats, seen, 0);
173
+ if (stats.nonSerializable > 0) {
174
+ downgrade = mergeDowngrade(downgrade, "non_serializable");
175
+ }
176
+ if (stats.oversized > 0) {
177
+ downgrade = mergeDowngrade(downgrade, "oversized");
178
+ }
179
+ try {
180
+ const json = JSON.stringify(value);
181
+ if (json.length > resolved.maxJsonBytes) {
182
+ downgrade = mergeDowngrade(downgrade, "oversized");
183
+ const preview = json.slice(0, Math.min(resolved.oversizedPreviewBytes, resolved.maxJsonBytes));
184
+ return {
185
+ value: {
186
+ _tag: "oversized",
187
+ bytes: json.length,
188
+ preview
189
+ },
190
+ stats: {
191
+ dropped: stats.dropped,
192
+ oversized: stats.oversized + 1,
193
+ nonSerializable: stats.nonSerializable
194
+ },
195
+ downgrade
196
+ };
197
+ }
198
+ } catch {
199
+ downgrade = mergeDowngrade(downgrade, "non_serializable");
200
+ return {
201
+ value: "[Unserializable]",
202
+ stats: {
203
+ dropped: stats.dropped,
204
+ oversized: stats.oversized,
205
+ nonSerializable: stats.nonSerializable + 1
206
+ },
207
+ downgrade
208
+ };
209
+ }
210
+ return {
211
+ value,
212
+ stats: {
213
+ dropped: stats.dropped,
214
+ oversized: stats.oversized,
215
+ nonSerializable: stats.nonSerializable
216
+ },
217
+ downgrade
218
+ };
219
+ };
220
+
221
+ // src/internal/runtime/core/errorSummary.ts
222
+ var import_effect = require("effect");
223
+ var truncate = (value, maxLen) => {
224
+ if (value.length <= maxLen) return { value, truncated: false };
225
+ return { value: value.slice(0, maxLen), truncated: true };
226
+ };
227
+ var safeStringify = (value) => {
228
+ try {
229
+ return { ok: true, json: JSON.stringify(value) };
230
+ } catch {
231
+ return { ok: false };
232
+ }
233
+ };
234
+ var getMessageFromUnknown = (cause) => {
235
+ if (typeof cause === "string") return cause;
236
+ if (typeof cause === "number" || typeof cause === "boolean" || typeof cause === "bigint") return String(cause);
237
+ if (cause instanceof Error) return cause.message || cause.name || "Error";
238
+ if (cause && typeof cause === "object" && "message" in cause && typeof cause.message === "string") {
239
+ return cause.message;
240
+ }
241
+ try {
242
+ const pretty = import_effect.Cause.pretty(cause, { renderErrorCause: true });
243
+ if (typeof pretty === "string" && pretty.length > 0) return pretty;
244
+ } catch {
245
+ }
246
+ return "Unknown error";
247
+ };
248
+ var toSerializableErrorSummary = (cause, options) => {
249
+ const maxMessageLength = options?.maxMessageLength ?? 256;
250
+ const messageRaw = getMessageFromUnknown(cause);
251
+ const { value: message, truncated } = truncate(messageRaw, maxMessageLength);
252
+ const summary = {
253
+ message
254
+ };
255
+ if (cause instanceof Error) {
256
+ if (cause.name && cause.name !== "Error") summary.name = cause.name;
257
+ const anyCause = cause;
258
+ if (typeof anyCause.code === "string" && anyCause.code.length > 0) summary.code = anyCause.code;
259
+ else if (typeof anyCause.code === "number" && Number.isFinite(anyCause.code)) summary.code = String(anyCause.code);
260
+ if (typeof anyCause.hint === "string" && anyCause.hint.length > 0) summary.hint = anyCause.hint;
261
+ return {
262
+ errorSummary: summary,
263
+ downgrade: truncated ? "oversized" : void 0
264
+ };
265
+ }
266
+ if (cause && typeof cause === "object") {
267
+ const anyCause = cause;
268
+ if (typeof anyCause.name === "string" && anyCause.name.length > 0) summary.name = anyCause.name;
269
+ if (typeof anyCause.code === "string" && anyCause.code.length > 0) summary.code = anyCause.code;
270
+ if (typeof anyCause.hint === "string" && anyCause.hint.length > 0) summary.hint = anyCause.hint;
271
+ }
272
+ const stringifyResult = safeStringify(cause);
273
+ if (!stringifyResult.ok) {
274
+ return {
275
+ errorSummary: summary,
276
+ downgrade: "non_serializable"
277
+ };
278
+ }
279
+ if (truncated) {
280
+ return {
281
+ errorSummary: summary,
282
+ downgrade: "oversized"
283
+ };
284
+ }
285
+ if (message === "Unknown error") {
286
+ return {
287
+ errorSummary: summary,
288
+ downgrade: "unknown"
289
+ };
290
+ }
291
+ return { errorSummary: summary };
292
+ };
293
+
294
+ // src/internal/runtime/core/EffectOpCore.ts
295
+ var import_effect2 = require("effect");
296
+ var currentLinkId = import_effect2.FiberRef.unsafeMake(void 0);
297
+ var EffectOpMiddlewareTag = class extends import_effect2.Context.Tag("Logix/EffectOpMiddleware")() {
298
+ };
299
+
300
+ // src/internal/runtime/core/DebugSink.ts
301
+ var currentDebugSinks = import_effect3.FiberRef.unsafeMake([]);
302
+ var currentRuntimeLabel = import_effect3.FiberRef.unsafeMake(void 0);
303
+ var currentTxnId = import_effect3.FiberRef.unsafeMake(void 0);
304
+ var currentOpSeq = import_effect3.FiberRef.unsafeMake(void 0);
305
+ var currentDiagnosticsLevel = import_effect3.FiberRef.unsafeMake("off");
306
+ var currentTraitConvergeDiagnosticsSampling = import_effect3.FiberRef.unsafeMake({
307
+ sampleEveryN: 32,
308
+ topK: 3
309
+ });
310
+ var traitConvergeDiagnosticsSampling = (config) => import_effect3.Layer.fiberRefLocallyScopedWith(currentTraitConvergeDiagnosticsSampling, () => config);
311
+ var nextGlobalEventSeq = 0;
312
+ var clearRuntimeDebugEventSeq = () => {
313
+ nextGlobalEventSeq = 0;
314
+ };
315
+ var nextEventSeq = () => {
316
+ nextGlobalEventSeq += 1;
317
+ return nextGlobalEventSeq;
318
+ };
319
+ var makeEventId = (instanceId, eventSeq) => `${instanceId}::e${eventSeq}`;
320
+ var mergeDowngrade2 = (current, next) => {
321
+ if (!current) return next;
322
+ if (!next) return current;
323
+ if (current === "non_serializable" || next === "non_serializable") return "non_serializable";
324
+ if (current === "oversized" || next === "oversized") return "oversized";
325
+ return "unknown";
326
+ };
327
+ var browserLifecycleSeen = /* @__PURE__ */ new Set();
328
+ var browserDiagnosticSeen = /* @__PURE__ */ new Set();
329
+ var lastTxnByInstance = /* @__PURE__ */ new Map();
330
+ var pendingTxnAlignmentByInstance = /* @__PURE__ */ new Map();
331
+ var enqueuePendingTxnAlignment = (instanceId, ref) => {
332
+ const list = pendingTxnAlignmentByInstance.get(instanceId);
333
+ if (!list) {
334
+ pendingTxnAlignmentByInstance.set(instanceId, [ref]);
335
+ return;
336
+ }
337
+ list.push(ref);
338
+ if (list.length > 64) {
339
+ list.shift();
340
+ }
341
+ };
342
+ var backfillPendingTxnAlignment = (instanceId, txn) => {
343
+ const pending = pendingTxnAlignmentByInstance.get(instanceId);
344
+ if (!pending || pending.length === 0) {
345
+ pendingTxnAlignmentByInstance.delete(instanceId);
346
+ return;
347
+ }
348
+ for (const ref of pending) {
349
+ const anyRef = ref;
350
+ if (anyRef.txnId == null) {
351
+ anyRef.txnId = txn.txnId;
352
+ }
353
+ if (typeof anyRef.txnSeq !== "number" || anyRef.txnSeq <= 0) {
354
+ anyRef.txnSeq = txn.txnSeq;
355
+ }
356
+ }
357
+ pendingTxnAlignmentByInstance.delete(instanceId);
358
+ };
359
+ var lifecycleErrorLog = (event) => {
360
+ const moduleId = event.moduleId ?? "unknown";
361
+ const causePretty = (() => {
362
+ try {
363
+ return import_effect3.Cause.pretty(event.cause, {
364
+ renderErrorCause: true
365
+ });
366
+ } catch {
367
+ try {
368
+ return JSON.stringify(event.cause, null, 2);
369
+ } catch {
370
+ return String(event.cause);
371
+ }
372
+ }
373
+ })();
374
+ const message = `[Logix][module=${moduleId}] lifecycle:error
375
+ ${causePretty}`;
376
+ return import_effect3.Effect.logError(message).pipe(
377
+ import_effect3.Effect.annotateLogs({
378
+ "logix.moduleId": moduleId,
379
+ "logix.event": "lifecycle:error",
380
+ "logix.cause": causePretty
381
+ })
382
+ );
383
+ };
384
+ var diagnosticLog = (event) => {
385
+ const moduleId = event.moduleId ?? "unknown";
386
+ const header = `[Logix][module=${moduleId}] diagnostic(${event.severity})`;
387
+ const detail = `code=${event.code} message=${event.message}${event.actionTag ? ` action=${event.actionTag}` : ""}${event.hint ? `
388
+ hint: ${event.hint}` : ""}`;
389
+ const msg = `${header}
390
+ ${detail}`;
391
+ const base = event.severity === "warning" ? import_effect3.Effect.logWarning(msg) : event.severity === "info" ? import_effect3.Effect.logInfo(msg) : import_effect3.Effect.logError(msg);
392
+ const annotations = {
393
+ "logix.moduleId": moduleId,
394
+ "logix.event": `diagnostic(${event.severity})`,
395
+ "logix.diagnostic.code": event.code,
396
+ "logix.diagnostic.message": event.message
397
+ };
398
+ if (event.hint) {
399
+ annotations["logix.diagnostic.hint"] = event.hint;
400
+ }
401
+ if (event.actionTag) {
402
+ annotations["logix.diagnostic.actionTag"] = event.actionTag;
403
+ }
404
+ return base.pipe(import_effect3.Effect.annotateLogs(annotations));
405
+ };
406
+ var noopLayer = import_effect3.Layer.locallyScoped(currentDebugSinks, []);
407
+ var errorOnlySink = {
408
+ record: (event) => event.type === "lifecycle:error" ? lifecycleErrorLog(event) : event.type === "diagnostic" && event.severity !== "info" ? diagnosticLog(event) : import_effect3.Effect.void
409
+ };
410
+ var errorOnlyLayer = import_effect3.Layer.locallyScoped(currentDebugSinks, [errorOnlySink]);
411
+ var isErrorOnlyOnlySinks = (sinks) => sinks.length === 1 && sinks[0] === errorOnlySink;
412
+ var consoleSink = {
413
+ record: (event) => event.type === "lifecycle:error" ? lifecycleErrorLog(event) : event.type === "diagnostic" ? diagnosticLog(event) : import_effect3.Effect.logDebug({ debugEvent: event })
414
+ };
415
+ var consoleLayer = import_effect3.Layer.locallyScoped(currentDebugSinks, [consoleSink]);
416
+ var isBrowser = typeof window !== "undefined" && typeof document !== "undefined";
417
+ var renderBrowserConsoleEvent = (event) => {
418
+ if (typeof event.type === "string" && event.type.startsWith("trace:")) {
419
+ const moduleId = event.moduleId ?? "unknown";
420
+ const type = event.type;
421
+ return import_effect3.Effect.sync(() => {
422
+ console.groupCollapsed(
423
+ "%c[Logix]%c trace %c" + moduleId + "%c " + String(type),
424
+ "color:#6b7280;font-weight:bold",
425
+ // tag
426
+ "color:#3b82f6",
427
+ // label
428
+ "color:#9ca3af",
429
+ // module id
430
+ "color:#6b7280"
431
+ // type
432
+ );
433
+ console.log(event);
434
+ console.groupEnd();
435
+ });
436
+ }
437
+ if (event.type === "lifecycle:error") {
438
+ const moduleId = event.moduleId ?? "unknown";
439
+ const causePretty = (() => {
440
+ try {
441
+ return import_effect3.Cause.pretty(event.cause, { renderErrorCause: true });
442
+ } catch {
443
+ try {
444
+ return JSON.stringify(event.cause, null, 2);
445
+ } catch {
446
+ return String(event.cause);
447
+ }
448
+ }
449
+ })();
450
+ const key = `${moduleId}|${causePretty}`;
451
+ if (browserLifecycleSeen.has(key)) {
452
+ return import_effect3.Effect.void;
453
+ }
454
+ browserLifecycleSeen.add(key);
455
+ return import_effect3.Effect.sync(() => {
456
+ console.groupCollapsed(
457
+ "%c[Logix]%c lifecycle:error %c" + moduleId,
458
+ "color:#ef4444;font-weight:bold",
459
+ // tag
460
+ "color:#ef4444",
461
+ // label
462
+ "color:#9ca3af"
463
+ // module id
464
+ );
465
+ console.error(causePretty);
466
+ console.groupEnd();
467
+ });
468
+ }
469
+ if (event.type === "diagnostic") {
470
+ const moduleId = event.moduleId ?? "unknown";
471
+ const detail = `code=${event.code} message=${event.message}${event.actionTag ? ` action=${event.actionTag}` : ""}${event.hint ? `
472
+ hint: ${event.hint}` : ""}`;
473
+ const color = event.severity === "warning" ? "color:#d97706" : event.severity === "info" ? "color:#3b82f6" : "color:#ef4444";
474
+ const label = event.severity === "warning" ? "diagnostic(warning)" : event.severity === "info" ? "diagnostic(info)" : "diagnostic(error)";
475
+ const key = `${moduleId}|${event.code}|${event.message}`;
476
+ if (browserDiagnosticSeen.has(key)) {
477
+ return import_effect3.Effect.void;
478
+ }
479
+ browserDiagnosticSeen.add(key);
480
+ return import_effect3.Effect.sync(() => {
481
+ console.groupCollapsed(
482
+ "%c[Logix]%c " + label + "%c module=" + moduleId,
483
+ "color:#6b7280;font-weight:bold",
484
+ color,
485
+ "color:#9ca3af"
486
+ );
487
+ if (event.severity === "warning") {
488
+ console.warn(detail);
489
+ } else if (event.severity === "info") {
490
+ console.info(detail);
491
+ } else {
492
+ console.error(detail);
493
+ }
494
+ console.groupEnd();
495
+ });
496
+ }
497
+ return import_effect3.Effect.void;
498
+ };
499
+ var browserConsoleSink = {
500
+ record: (event) => {
501
+ if (!isBrowser) {
502
+ return event.type === "lifecycle:error" ? lifecycleErrorLog(event) : event.type === "diagnostic" ? diagnosticLog(event) : import_effect3.Effect.logDebug({ debugEvent: event });
503
+ }
504
+ return renderBrowserConsoleEvent(event);
505
+ }
506
+ };
507
+ var browserConsoleLayer = import_effect3.Layer.locallyScoped(currentDebugSinks, [browserConsoleSink]);
508
+ var browserDiagnosticConsoleSink = {
509
+ record: (event) => {
510
+ if (!isBrowser) {
511
+ return event.type === "lifecycle:error" ? lifecycleErrorLog(event) : event.type === "diagnostic" && event.severity !== "info" ? diagnosticLog(event) : import_effect3.Effect.void;
512
+ }
513
+ return event.type === "lifecycle:error" || event.type === "diagnostic" && event.severity !== "info" ? renderBrowserConsoleEvent(event) : import_effect3.Effect.void;
514
+ }
515
+ };
516
+ var browserDiagnosticConsoleLayer = import_effect3.Layer.locallyScoped(currentDebugSinks, [browserDiagnosticConsoleSink]);
517
+ var browserPrettyLoggerLayer = import_effect3.Logger.replace(
518
+ import_effect3.Logger.defaultLogger,
519
+ import_effect3.Logger.prettyLogger({ mode: "browser", colors: true })
520
+ );
521
+ var record = (event) => import_effect3.Effect.gen(function* () {
522
+ const sinks = yield* import_effect3.FiberRef.get(currentDebugSinks);
523
+ if (isErrorOnlyOnlySinks(sinks)) {
524
+ if (event.type === "lifecycle:error") {
525
+ yield* lifecycleErrorLog(event);
526
+ return;
527
+ }
528
+ if (event.type === "diagnostic") {
529
+ if (event.severity !== "info") {
530
+ yield* diagnosticLog(event);
531
+ } else {
532
+ yield* import_effect3.Effect.void;
533
+ }
534
+ return;
535
+ }
536
+ yield* import_effect3.Effect.void;
537
+ return;
538
+ }
539
+ if (sinks.length === 0) {
540
+ if (isBrowser) {
541
+ if (event.type === "lifecycle:error" || event.type === "diagnostic") {
542
+ yield* renderBrowserConsoleEvent(event);
543
+ return;
544
+ }
545
+ yield* import_effect3.Effect.void;
546
+ return;
547
+ }
548
+ if (event.type === "lifecycle:error") {
549
+ yield* lifecycleErrorLog(event);
550
+ return;
551
+ }
552
+ if (event.type === "diagnostic") {
553
+ yield* diagnosticLog(event);
554
+ return;
555
+ }
556
+ yield* import_effect3.Effect.void;
557
+ return;
558
+ }
559
+ const enriched = event;
560
+ const diagnosticsLevel2 = yield* import_effect3.FiberRef.get(currentDiagnosticsLevel);
561
+ let now;
562
+ const getNow = () => {
563
+ if (now === void 0) now = Date.now();
564
+ return now;
565
+ };
566
+ if (enriched.timestamp === void 0 && (diagnosticsLevel2 !== "off" || enriched.type === "lifecycle:error" || enriched.type === "diagnostic")) {
567
+ ;
568
+ enriched.timestamp = getNow();
569
+ }
570
+ if (diagnosticsLevel2 !== "off" && enriched.runtimeLabel === void 0) {
571
+ const runtimeLabel2 = yield* import_effect3.FiberRef.get(currentRuntimeLabel);
572
+ if (runtimeLabel2) {
573
+ ;
574
+ enriched.runtimeLabel = runtimeLabel2;
575
+ }
576
+ }
577
+ if (enriched.type === "diagnostic" && enriched.txnId === void 0) {
578
+ const txnId = yield* import_effect3.FiberRef.get(currentTxnId);
579
+ if (txnId) {
580
+ ;
581
+ enriched.txnId = txnId;
582
+ }
583
+ }
584
+ if (diagnosticsLevel2 !== "off" && enriched.type === "trace:effectop" && enriched.linkId === void 0) {
585
+ const linkId = yield* import_effect3.FiberRef.get(currentLinkId);
586
+ if (linkId) {
587
+ ;
588
+ enriched.linkId = linkId;
589
+ }
590
+ }
591
+ if (sinks.length === 1) {
592
+ yield* sinks[0].record(enriched);
593
+ return;
594
+ }
595
+ yield* import_effect3.Effect.forEach(sinks, (sink) => sink.record(enriched), { discard: true });
596
+ });
597
+ var toRuntimeDebugEventRef = (event, options) => {
598
+ const diagnosticsLevel2 = options?.diagnosticsLevel ?? "full";
599
+ if (diagnosticsLevel2 === "off") {
600
+ return void 0;
601
+ }
602
+ const isLightLike = diagnosticsLevel2 === "light" || diagnosticsLevel2 === "sampled";
603
+ const timestamp = typeof event.timestamp === "number" && Number.isFinite(event.timestamp) ? event.timestamp : Date.now();
604
+ const moduleIdRaw = event.moduleId;
605
+ const moduleId = typeof moduleIdRaw === "string" && moduleIdRaw.length > 0 ? moduleIdRaw : "unknown";
606
+ const instanceIdRaw = event.instanceId;
607
+ const instanceId = typeof instanceIdRaw === "string" && instanceIdRaw.length > 0 ? instanceIdRaw : "unknown";
608
+ const runtimeLabelRaw = event.runtimeLabel;
609
+ const runtimeLabel2 = typeof runtimeLabelRaw === "string" && runtimeLabelRaw.length > 0 ? runtimeLabelRaw : void 0;
610
+ const txnSeqRaw = event.txnSeq;
611
+ const txnSeq = typeof txnSeqRaw === "number" && Number.isFinite(txnSeqRaw) && txnSeqRaw >= 0 ? Math.floor(txnSeqRaw) : 0;
612
+ const txnIdRaw = event.txnId;
613
+ const txnId = typeof txnIdRaw === "string" && txnIdRaw.length > 0 ? txnIdRaw : txnSeq > 0 ? `${instanceId}::t${txnSeq}` : void 0;
614
+ const linkId = (() => {
615
+ const linkIdRaw = event.linkId;
616
+ if (typeof linkIdRaw === "string" && linkIdRaw.length > 0) return linkIdRaw;
617
+ if (typeof event.type !== "string" || !event.type.startsWith("trace:")) {
618
+ return void 0;
619
+ }
620
+ const data = event.data;
621
+ const meta = data?.meta;
622
+ const linkIdFromMeta = meta?.linkId;
623
+ if (typeof linkIdFromMeta === "string" && linkIdFromMeta.length > 0) return linkIdFromMeta;
624
+ return void 0;
625
+ })();
626
+ const eventSeqRaw = options?.eventSeq;
627
+ const eventSeq = typeof eventSeqRaw === "number" && Number.isFinite(eventSeqRaw) && eventSeqRaw > 0 ? Math.floor(eventSeqRaw) : nextEventSeq();
628
+ const eventId = makeEventId(instanceId, eventSeq);
629
+ const base = {
630
+ eventId,
631
+ eventSeq,
632
+ moduleId,
633
+ instanceId,
634
+ runtimeLabel: runtimeLabel2,
635
+ txnSeq,
636
+ txnId,
637
+ linkId,
638
+ timestamp
639
+ };
640
+ let downgrade;
641
+ const withDowngrade = (ref) => {
642
+ if (!downgrade) return ref;
643
+ return { ...ref, downgrade: { reason: downgrade } };
644
+ };
645
+ switch (event.type) {
646
+ case "module:init":
647
+ return withDowngrade({
648
+ ...base,
649
+ kind: "lifecycle",
650
+ label: "module:init"
651
+ });
652
+ case "module:destroy":
653
+ return withDowngrade({
654
+ ...base,
655
+ kind: "lifecycle",
656
+ label: "module:destroy"
657
+ });
658
+ case "lifecycle:phase": {
659
+ const e = event;
660
+ const metaInput = isLightLike ? { type: "lifecycle:phase", phase: e.phase, name: e.name } : { type: "lifecycle:phase", phase: e.phase, name: e.name, payload: e.payload };
661
+ const metaProjection = projectJsonValue(metaInput);
662
+ options?.onMetaProjection?.({
663
+ stats: metaProjection.stats,
664
+ downgrade: metaProjection.downgrade
665
+ });
666
+ downgrade = mergeDowngrade2(downgrade, metaProjection.downgrade);
667
+ return withDowngrade({
668
+ ...base,
669
+ kind: "lifecycle",
670
+ label: e.name,
671
+ meta: metaProjection.value
672
+ });
673
+ }
674
+ case "action:dispatch": {
675
+ const action = event.action;
676
+ const actionTagRaw = event.actionTag;
677
+ const tag = typeof actionTagRaw === "string" && actionTagRaw.length > 0 ? actionTagRaw : action?._tag ?? action?.type;
678
+ const label = String(tag ?? "action:dispatch");
679
+ const labelNormalized = label.length > 0 ? label : "unknown";
680
+ const unknownAction = event.unknownAction === true ? true : void 0;
681
+ const metaInput = isLightLike ? { actionTag: labelNormalized, ...unknownAction ? { unknownAction: true } : {} } : { action, ...unknownAction ? { unknownAction: true } : {} };
682
+ const metaProjection = projectJsonValue(metaInput);
683
+ options?.onMetaProjection?.({
684
+ stats: metaProjection.stats,
685
+ downgrade: metaProjection.downgrade
686
+ });
687
+ downgrade = mergeDowngrade2(downgrade, metaProjection.downgrade);
688
+ if (unknownAction) {
689
+ downgrade = mergeDowngrade2(downgrade, "unknown");
690
+ }
691
+ return withDowngrade({
692
+ ...base,
693
+ kind: "action",
694
+ label: labelNormalized,
695
+ meta: metaProjection.value
696
+ });
697
+ }
698
+ case "state:update": {
699
+ const e = event;
700
+ const resolveDirtySetRootPaths = () => {
701
+ const resolve = options?.resolveConvergeStaticIr;
702
+ if (!resolve) return void 0;
703
+ const digest = e.staticIrDigest;
704
+ if (typeof digest !== "string" || digest.length === 0) return void 0;
705
+ const dirtySet = e.dirtySet;
706
+ if (!dirtySet || typeof dirtySet !== "object" || Array.isArray(dirtySet)) return void 0;
707
+ const rootIds = dirtySet.rootIds;
708
+ if (!Array.isArray(rootIds) || rootIds.length === 0) return void 0;
709
+ const ir = resolve(digest);
710
+ const fieldPaths = ir?.fieldPaths;
711
+ if (!Array.isArray(fieldPaths) || fieldPaths.length === 0) return void 0;
712
+ const out = [];
713
+ for (const rawId of rootIds) {
714
+ if (typeof rawId !== "number" || !Number.isFinite(rawId)) continue;
715
+ const id = Math.floor(rawId);
716
+ if (id < 0) continue;
717
+ const path = fieldPaths[id];
718
+ if (!Array.isArray(path) || path.length === 0) continue;
719
+ if (!path.every((seg) => typeof seg === "string" && seg.length > 0)) continue;
720
+ out.push(path);
721
+ }
722
+ return out.length > 0 ? out : void 0;
723
+ };
724
+ const dirtySetWithRootPaths = (() => {
725
+ const rootPaths = resolveDirtySetRootPaths();
726
+ if (!rootPaths) return e.dirtySet;
727
+ const dirtySet = e.dirtySet;
728
+ if (!dirtySet || typeof dirtySet !== "object" || Array.isArray(dirtySet)) return e.dirtySet;
729
+ return { ...dirtySet, rootPaths };
730
+ })();
731
+ const metaInput = isLightLike ? {
732
+ state: e.state,
733
+ dirtySet: dirtySetWithRootPaths,
734
+ patchCount: e.patchCount,
735
+ patchesTruncated: e.patchesTruncated,
736
+ patchesTruncatedReason: e.patchesTruncatedReason,
737
+ staticIrDigest: e.staticIrDigest,
738
+ commitMode: e.commitMode,
739
+ priority: e.priority,
740
+ originKind: e.originKind,
741
+ originName: e.originName
742
+ } : {
743
+ state: e.state,
744
+ dirtySet: dirtySetWithRootPaths,
745
+ patchCount: e.patchCount,
746
+ patchesTruncated: e.patchesTruncated,
747
+ patchesTruncatedReason: e.patchesTruncatedReason,
748
+ staticIrDigest: e.staticIrDigest,
749
+ commitMode: e.commitMode,
750
+ priority: e.priority,
751
+ originKind: e.originKind,
752
+ originName: e.originName,
753
+ traitSummary: e.traitSummary,
754
+ replayEvent: e.replayEvent
755
+ };
756
+ const metaProjection = projectJsonValue(metaInput);
757
+ options?.onMetaProjection?.({
758
+ stats: metaProjection.stats,
759
+ downgrade: metaProjection.downgrade
760
+ });
761
+ downgrade = mergeDowngrade2(downgrade, metaProjection.downgrade);
762
+ if (txnId) {
763
+ lastTxnByInstance.set(instanceId, { txnId, txnSeq });
764
+ backfillPendingTxnAlignment(instanceId, { txnId, txnSeq });
765
+ }
766
+ return withDowngrade({
767
+ ...base,
768
+ kind: "state",
769
+ label: "state:update",
770
+ meta: metaProjection.value
771
+ });
772
+ }
773
+ case "process:start":
774
+ case "process:stop":
775
+ case "process:restart":
776
+ case "process:trigger":
777
+ case "process:dispatch":
778
+ case "process:error": {
779
+ const e = event;
780
+ const ts2 = typeof e.timestampMs === "number" && Number.isFinite(e.timestampMs) ? e.timestampMs : timestamp;
781
+ const metaInput = {
782
+ identity: e.identity,
783
+ severity: e.severity,
784
+ eventSeq: e.eventSeq,
785
+ timestampMs: e.timestampMs,
786
+ trigger: e.trigger,
787
+ dispatch: e.dispatch,
788
+ error: e.error
789
+ };
790
+ const metaProjection = projectJsonValue(metaInput);
791
+ options?.onMetaProjection?.({
792
+ stats: metaProjection.stats,
793
+ downgrade: metaProjection.downgrade
794
+ });
795
+ downgrade = mergeDowngrade2(downgrade, metaProjection.downgrade);
796
+ const errorSummary = e.type === "process:error" || e.type === "process:restart" ? e.error : void 0;
797
+ return withDowngrade({
798
+ ...base,
799
+ timestamp: ts2,
800
+ kind: "process",
801
+ label: e.type,
802
+ meta: metaProjection.value,
803
+ errorSummary
804
+ });
805
+ }
806
+ case "lifecycle:error": {
807
+ const e = event;
808
+ const summary = toSerializableErrorSummary(e.cause);
809
+ downgrade = mergeDowngrade2(downgrade, summary.downgrade);
810
+ const metaInput = isLightLike ? { type: "lifecycle:error", phase: e.phase, name: e.hook } : {
811
+ type: "lifecycle:error",
812
+ phase: e.phase,
813
+ name: e.hook,
814
+ hook: e.hook,
815
+ taskId: e.taskId,
816
+ origin: e.origin,
817
+ txnSeq: e.txnSeq,
818
+ opSeq: e.opSeq
819
+ };
820
+ const metaProjection = projectJsonValue(metaInput);
821
+ options?.onMetaProjection?.({
822
+ stats: metaProjection.stats,
823
+ downgrade: metaProjection.downgrade
824
+ });
825
+ downgrade = mergeDowngrade2(downgrade, metaProjection.downgrade);
826
+ return withDowngrade({
827
+ ...base,
828
+ kind: "lifecycle",
829
+ label: "lifecycle:error",
830
+ meta: metaProjection.value,
831
+ errorSummary: summary.errorSummary
832
+ });
833
+ }
834
+ case "diagnostic": {
835
+ const e = event;
836
+ const metaInput = {
837
+ code: e.code,
838
+ severity: e.severity,
839
+ message: e.message,
840
+ hint: e.hint,
841
+ actionTag: e.actionTag,
842
+ kind: e.kind,
843
+ trigger: e.trigger
844
+ };
845
+ const metaProjection = projectJsonValue(metaInput);
846
+ options?.onMetaProjection?.({
847
+ stats: metaProjection.stats,
848
+ downgrade: metaProjection.downgrade
849
+ });
850
+ downgrade = mergeDowngrade2(downgrade, metaProjection.downgrade);
851
+ return withDowngrade({
852
+ ...base,
853
+ kind: "diagnostic",
854
+ label: e.code,
855
+ meta: metaProjection.value
856
+ });
857
+ }
858
+ default: {
859
+ if (typeof event.type !== "string" || !event.type.startsWith("trace:")) {
860
+ return void 0;
861
+ }
862
+ if (event.type === "trace:txn-lane") {
863
+ const data = event.data;
864
+ const evidence = data?.evidence ?? data;
865
+ const metaProjection2 = projectJsonValue(evidence);
866
+ options?.onMetaProjection?.({
867
+ stats: metaProjection2.stats,
868
+ downgrade: metaProjection2.downgrade
869
+ });
870
+ downgrade = mergeDowngrade2(downgrade, metaProjection2.downgrade);
871
+ const label = typeof evidence?.kind === "string" && evidence.kind.length > 0 ? String(evidence.kind) : "txn-lane";
872
+ return withDowngrade({
873
+ ...base,
874
+ kind: "txn-lane",
875
+ label,
876
+ meta: metaProjection2.value
877
+ });
878
+ }
879
+ if (event.type === "trace:react-render" || event.type === "trace:react-selector") {
880
+ const data = event.data;
881
+ const metaProjection2 = projectJsonValue(
882
+ isLightLike ? {
883
+ componentLabel: data?.componentLabel,
884
+ selectorKey: data?.selectorKey,
885
+ fieldPaths: data?.fieldPaths,
886
+ selectorId: data?.selectorId,
887
+ lane: data?.lane,
888
+ producer: data?.producer,
889
+ fallbackReason: data?.fallbackReason,
890
+ readsDigest: data?.readsDigest,
891
+ equalsKind: data?.equalsKind,
892
+ strictModePhase: data?.strictModePhase
893
+ } : {
894
+ componentLabel: data?.componentLabel,
895
+ selectorKey: data?.selectorKey,
896
+ fieldPaths: data?.fieldPaths,
897
+ selectorId: data?.selectorId,
898
+ lane: data?.lane,
899
+ producer: data?.producer,
900
+ fallbackReason: data?.fallbackReason,
901
+ readsDigest: data?.readsDigest,
902
+ equalsKind: data?.equalsKind,
903
+ strictModePhase: data?.strictModePhase,
904
+ meta: data?.meta
905
+ }
906
+ );
907
+ options?.onMetaProjection?.({
908
+ stats: metaProjection2.stats,
909
+ downgrade: metaProjection2.downgrade
910
+ });
911
+ downgrade = mergeDowngrade2(downgrade, metaProjection2.downgrade);
912
+ const label = typeof data?.componentLabel === "string" && data.componentLabel.length > 0 ? data.componentLabel : event.type === "trace:react-selector" ? "react-selector" : "react-render";
913
+ const last = lastTxnByInstance.get(instanceId);
914
+ const txnSeqFromMeta = typeof data?.meta?.txnSeq === "number" && Number.isFinite(data.meta.txnSeq) && data.meta.txnSeq >= 0 ? Math.floor(data.meta.txnSeq) : void 0;
915
+ const txnIdFromMeta = typeof data?.meta?.txnId === "string" && data.meta.txnId.length > 0 ? data.meta.txnId : void 0;
916
+ const txnIdAligned = txnIdFromMeta ?? base.txnId ?? last?.txnId;
917
+ const txnSeqAligned = txnSeqFromMeta ?? (base.txnSeq > 0 ? base.txnSeq : last?.txnSeq ?? base.txnSeq);
918
+ const ref = withDowngrade({
919
+ ...base,
920
+ txnId: txnIdAligned,
921
+ txnSeq: txnSeqAligned,
922
+ kind: event.type === "trace:react-selector" ? "react-selector" : "react-render",
923
+ label,
924
+ meta: metaProjection2.value
925
+ });
926
+ if (instanceId !== "unknown" && (ref.txnId == null || ref.txnSeq <= 0)) {
927
+ enqueuePendingTxnAlignment(instanceId, ref);
928
+ }
929
+ return ref;
930
+ }
931
+ if (event.type === "trace:selector:eval") {
932
+ const data = event.data;
933
+ const metaInput = {
934
+ selectorId: data?.selectorId,
935
+ lane: data?.lane,
936
+ producer: data?.producer,
937
+ fallbackReason: data?.fallbackReason,
938
+ readsDigest: data?.readsDigest,
939
+ equalsKind: data?.equalsKind,
940
+ changed: data?.changed,
941
+ evalMs: data?.evalMs
942
+ };
943
+ const metaProjection2 = projectJsonValue(metaInput);
944
+ options?.onMetaProjection?.({
945
+ stats: metaProjection2.stats,
946
+ downgrade: metaProjection2.downgrade
947
+ });
948
+ downgrade = mergeDowngrade2(downgrade, metaProjection2.downgrade);
949
+ return withDowngrade({
950
+ ...base,
951
+ kind: "devtools",
952
+ label: event.type,
953
+ meta: metaProjection2.value
954
+ });
955
+ }
956
+ if (event.type === "trace:exec-vm") {
957
+ const data = event.data;
958
+ const metaInput = {
959
+ version: data?.version,
960
+ stage: data?.stage,
961
+ hit: data?.hit,
962
+ reasonCode: data?.reasonCode ?? data?.reason,
963
+ reasonDetail: data?.reasonDetail,
964
+ execIrVersion: data?.execIrVersion,
965
+ execIrHash: data?.execIrHash,
966
+ serviceId: data?.serviceId,
967
+ implId: data?.implId
968
+ };
969
+ const metaProjection2 = projectJsonValue(metaInput);
970
+ options?.onMetaProjection?.({
971
+ stats: metaProjection2.stats,
972
+ downgrade: metaProjection2.downgrade
973
+ });
974
+ downgrade = mergeDowngrade2(downgrade, metaProjection2.downgrade);
975
+ return withDowngrade({
976
+ ...base,
977
+ kind: "devtools",
978
+ label: event.type,
979
+ meta: metaProjection2.value
980
+ });
981
+ }
982
+ if (event.type === "trace:trait:converge") {
983
+ const resolveDirtyRootPaths = (args) => {
984
+ const resolve = options?.resolveConvergeStaticIr;
985
+ if (!resolve) return void 0;
986
+ const digest = args.staticIrDigest;
987
+ if (typeof digest !== "string" || digest.length === 0) return void 0;
988
+ const rootIds = args.rootIds;
989
+ if (!Array.isArray(rootIds) || rootIds.length === 0) return void 0;
990
+ const ir = resolve(digest);
991
+ const fieldPaths = ir?.fieldPaths;
992
+ if (!Array.isArray(fieldPaths) || fieldPaths.length === 0) return void 0;
993
+ const out = [];
994
+ for (const id of rootIds) {
995
+ if (typeof id !== "number" || !Number.isFinite(id)) continue;
996
+ const idx = Math.floor(id);
997
+ if (idx < 0 || idx >= fieldPaths.length) continue;
998
+ const path = fieldPaths[idx];
999
+ if (Array.isArray(path)) {
1000
+ out.push(path);
1001
+ }
1002
+ }
1003
+ return out.length > 0 ? out : void 0;
1004
+ };
1005
+ const enrichDirtyRootPaths = (value) => {
1006
+ if (!value || typeof value !== "object" || Array.isArray(value)) return value;
1007
+ const anyValue = value;
1008
+ const dirty = anyValue.dirty;
1009
+ if (!dirty || typeof dirty !== "object" || Array.isArray(dirty)) return value;
1010
+ const dirtyRootPaths = resolveDirtyRootPaths({
1011
+ staticIrDigest: anyValue.staticIrDigest,
1012
+ rootIds: dirty?.rootIds
1013
+ });
1014
+ if (!dirtyRootPaths) return value;
1015
+ return {
1016
+ ...anyValue,
1017
+ dirty: {
1018
+ ...dirty,
1019
+ rootPaths: dirtyRootPaths
1020
+ }
1021
+ };
1022
+ };
1023
+ const stripHeavyLight = (value) => {
1024
+ if (!value || typeof value !== "object" || Array.isArray(value)) return value;
1025
+ const anyValue = value;
1026
+ const dirty = anyValue.dirty;
1027
+ const dirtyRootPaths = resolveDirtyRootPaths({
1028
+ staticIrDigest: anyValue.staticIrDigest,
1029
+ rootIds: dirty?.rootIds
1030
+ });
1031
+ const dirtySlim = dirty && typeof dirty === "object" && !Array.isArray(dirty) ? {
1032
+ dirtyAll: dirty.dirtyAll,
1033
+ ...typeof dirty.reason === "string" ? { reason: dirty.reason } : null,
1034
+ ...Array.isArray(dirty.rootIds) ? { rootIds: dirty.rootIds } : null,
1035
+ ...typeof dirty.rootIdsTruncated === "boolean" ? { rootIdsTruncated: dirty.rootIdsTruncated } : null,
1036
+ ...dirtyRootPaths ? { rootPaths: dirtyRootPaths } : null
1037
+ } : void 0;
1038
+ const { top3, dirtyRoots, ...rest } = anyValue;
1039
+ return dirtySlim ? { ...rest, dirty: dirtySlim } : rest;
1040
+ };
1041
+ const stripHeavySampled = (value) => {
1042
+ if (!value || typeof value !== "object" || Array.isArray(value)) return value;
1043
+ const anyValue = value;
1044
+ const dirty = anyValue.dirty;
1045
+ const dirtySlim = dirty && typeof dirty === "object" && !Array.isArray(dirty) ? {
1046
+ dirtyAll: dirty.dirtyAll,
1047
+ ...typeof dirty.reason === "string" ? { reason: dirty.reason } : null
1048
+ } : void 0;
1049
+ const { dirtyRoots, ...rest } = anyValue;
1050
+ return dirtySlim ? { ...rest, dirty: dirtySlim } : rest;
1051
+ };
1052
+ const data = event.data;
1053
+ const metaInput = diagnosticsLevel2 === "light" ? stripHeavyLight(data) : diagnosticsLevel2 === "sampled" ? stripHeavySampled(data) : enrichDirtyRootPaths(data);
1054
+ const metaProjection2 = projectJsonValue(metaInput);
1055
+ options?.onMetaProjection?.({
1056
+ stats: metaProjection2.stats,
1057
+ downgrade: metaProjection2.downgrade
1058
+ });
1059
+ downgrade = mergeDowngrade2(downgrade, metaProjection2.downgrade);
1060
+ return withDowngrade({
1061
+ ...base,
1062
+ kind: "trait:converge",
1063
+ label: "trait:converge",
1064
+ meta: metaProjection2.value
1065
+ });
1066
+ }
1067
+ if (event.type === "trace:trait:check") {
1068
+ const stripHeavy = (value) => {
1069
+ if (!value || typeof value !== "object" || Array.isArray(value)) return value;
1070
+ const anyValue = value;
1071
+ const degraded = anyValue.degraded;
1072
+ const degradedSlim = degraded && typeof degraded === "object" && !Array.isArray(degraded) ? { kind: degraded.kind } : void 0;
1073
+ const { degraded: _degraded, ...rest } = anyValue;
1074
+ return degradedSlim ? { ...rest, degraded: degradedSlim } : rest;
1075
+ };
1076
+ const data = event.data;
1077
+ const metaInput = isLightLike ? stripHeavy(data) : data;
1078
+ const metaProjection2 = projectJsonValue(metaInput);
1079
+ options?.onMetaProjection?.({
1080
+ stats: metaProjection2.stats,
1081
+ downgrade: metaProjection2.downgrade
1082
+ });
1083
+ downgrade = mergeDowngrade2(downgrade, metaProjection2.downgrade);
1084
+ return withDowngrade({
1085
+ ...base,
1086
+ kind: "trait:check",
1087
+ label: "trait:check",
1088
+ meta: metaProjection2.value
1089
+ });
1090
+ }
1091
+ if (event.type === "trace:trait:validate") {
1092
+ const data = event.data;
1093
+ const metaProjection2 = projectJsonValue(data);
1094
+ options?.onMetaProjection?.({
1095
+ stats: metaProjection2.stats,
1096
+ downgrade: metaProjection2.downgrade
1097
+ });
1098
+ downgrade = mergeDowngrade2(downgrade, metaProjection2.downgrade);
1099
+ return withDowngrade({
1100
+ ...base,
1101
+ kind: "trait:validate",
1102
+ label: "trait:validate",
1103
+ meta: metaProjection2.value
1104
+ });
1105
+ }
1106
+ if (event.type === "trace:module:traits") {
1107
+ const data = event.data;
1108
+ const metaInput = isLightLike ? {
1109
+ digest: data?.digest,
1110
+ count: data?.count
1111
+ } : {
1112
+ digest: data?.digest,
1113
+ count: data?.count,
1114
+ traits: data?.traits,
1115
+ provenanceIndex: data?.provenanceIndex
1116
+ };
1117
+ const metaProjection2 = projectJsonValue(metaInput);
1118
+ options?.onMetaProjection?.({
1119
+ stats: metaProjection2.stats,
1120
+ downgrade: metaProjection2.downgrade
1121
+ });
1122
+ downgrade = mergeDowngrade2(downgrade, metaProjection2.downgrade);
1123
+ return withDowngrade({
1124
+ ...base,
1125
+ kind: "devtools",
1126
+ label: event.type,
1127
+ meta: metaProjection2.value
1128
+ });
1129
+ }
1130
+ if (event.type === "trace:module:traits:conflict") {
1131
+ const data = event.data;
1132
+ const metaInput = isLightLike ? {
1133
+ conflictCount: data?.conflictCount,
1134
+ traitIds: data?.traitIds
1135
+ } : {
1136
+ conflictCount: data?.conflictCount,
1137
+ conflicts: data?.conflicts
1138
+ };
1139
+ const metaProjection2 = projectJsonValue(metaInput);
1140
+ options?.onMetaProjection?.({
1141
+ stats: metaProjection2.stats,
1142
+ downgrade: metaProjection2.downgrade
1143
+ });
1144
+ downgrade = mergeDowngrade2(downgrade, metaProjection2.downgrade);
1145
+ return withDowngrade({
1146
+ ...base,
1147
+ kind: "devtools",
1148
+ label: event.type,
1149
+ meta: metaProjection2.value
1150
+ });
1151
+ }
1152
+ if (event.type === "trace:module:descriptor") {
1153
+ const data = event.data;
1154
+ const metaInput = isLightLike ? {
1155
+ id: data?.id,
1156
+ traits: data?.traits,
1157
+ source: data?.source
1158
+ } : { data };
1159
+ const metaProjection2 = projectJsonValue(metaInput);
1160
+ options?.onMetaProjection?.({
1161
+ stats: metaProjection2.stats,
1162
+ downgrade: metaProjection2.downgrade
1163
+ });
1164
+ downgrade = mergeDowngrade2(downgrade, metaProjection2.downgrade);
1165
+ return withDowngrade({
1166
+ ...base,
1167
+ kind: "devtools",
1168
+ label: event.type,
1169
+ meta: metaProjection2.value
1170
+ });
1171
+ }
1172
+ if (event.type === "trace:effectop") {
1173
+ const data = event.data;
1174
+ const opMeta = data?.meta;
1175
+ const opKind = data?.kind ?? "service";
1176
+ const label = typeof data?.name === "string" ? data.name : "effectop";
1177
+ const moduleId2 = typeof opMeta?.moduleId === "string" ? opMeta.moduleId : moduleId;
1178
+ const txnId2 = typeof opMeta?.txnId === "string" && opMeta.txnId.length > 0 ? opMeta.txnId : base.txnId;
1179
+ const txnSeq2 = typeof opMeta?.txnSeq === "number" && Number.isFinite(opMeta.txnSeq) && opMeta.txnSeq >= 0 ? Math.floor(opMeta.txnSeq) : base.txnSeq;
1180
+ const metaInput = isLightLike ? {
1181
+ id: data?.id,
1182
+ kind: data?.kind,
1183
+ name: data?.name,
1184
+ meta: opMeta
1185
+ } : {
1186
+ id: data?.id,
1187
+ kind: data?.kind,
1188
+ name: data?.name,
1189
+ payload: data?.payload,
1190
+ meta: opMeta
1191
+ };
1192
+ const metaProjection2 = projectJsonValue(metaInput);
1193
+ options?.onMetaProjection?.({
1194
+ stats: metaProjection2.stats,
1195
+ downgrade: metaProjection2.downgrade
1196
+ });
1197
+ downgrade = mergeDowngrade2(downgrade, metaProjection2.downgrade);
1198
+ return withDowngrade({
1199
+ ...base,
1200
+ moduleId: moduleId2,
1201
+ txnId: txnId2,
1202
+ txnSeq: txnSeq2,
1203
+ kind: opKind,
1204
+ label,
1205
+ meta: metaProjection2.value
1206
+ });
1207
+ }
1208
+ const metaProjection = projectJsonValue(
1209
+ isLightLike ? {
1210
+ data: void 0
1211
+ } : {
1212
+ data: event.data
1213
+ }
1214
+ );
1215
+ options?.onMetaProjection?.({
1216
+ stats: metaProjection.stats,
1217
+ downgrade: metaProjection.downgrade
1218
+ });
1219
+ downgrade = mergeDowngrade2(downgrade, metaProjection.downgrade);
1220
+ return withDowngrade({
1221
+ ...base,
1222
+ kind: "devtools",
1223
+ label: event.type,
1224
+ meta: metaProjection.value
1225
+ });
1226
+ }
1227
+ }
1228
+ };
1229
+
1230
+ // src/internal/runtime/core/DevtoolsHub.ts
1231
+ var import_effect4 = require("effect");
1232
+
1233
+ // src/internal/observability/evidence.ts
1234
+ var OBSERVABILITY_PROTOCOL_VERSION = "v1";
1235
+ var exportEvidencePackage = (options) => {
1236
+ const protocolVersion = options.protocolVersion ?? OBSERVABILITY_PROTOCOL_VERSION;
1237
+ return {
1238
+ protocolVersion,
1239
+ runId: options.runId,
1240
+ createdAt: options.createdAt ?? Date.now(),
1241
+ source: options.source,
1242
+ events: options.events.slice().sort((a, b) => a.seq - b.seq),
1243
+ summary: options.summary
1244
+ };
1245
+ };
1246
+
1247
+ // src/internal/runtime/core/DevtoolsHub.ts
1248
+ var instances = /* @__PURE__ */ new Map();
1249
+ var latestStates = /* @__PURE__ */ new Map();
1250
+ var latestTraitSummaries = /* @__PURE__ */ new Map();
1251
+ var instanceLabels = /* @__PURE__ */ new Map();
1252
+ var convergeStaticIrByDigest = /* @__PURE__ */ new Map();
1253
+ var liveInstanceKeys = /* @__PURE__ */ new Set();
1254
+ var exportBudget = {
1255
+ dropped: 0,
1256
+ oversized: 0
1257
+ };
1258
+ var lastRunTs = 0;
1259
+ var lastRunTsSeq = 0;
1260
+ var nextRunId = () => {
1261
+ const ts = Date.now();
1262
+ if (ts === lastRunTs) {
1263
+ lastRunTsSeq += 1;
1264
+ } else {
1265
+ lastRunTs = ts;
1266
+ lastRunTsSeq = 0;
1267
+ }
1268
+ return lastRunTsSeq === 0 ? `run-${ts}` : `run-${ts}.${lastRunTsSeq}`;
1269
+ };
1270
+ var currentRunId = nextRunId();
1271
+ var nextSeq = 1;
1272
+ var bufferSize = 500;
1273
+ var ringBuffer = [];
1274
+ var ringBufferSeq = [];
1275
+ var snapshotToken = 0;
1276
+ var ensureRingBufferSize = () => {
1277
+ if (bufferSize <= 0) {
1278
+ ringBuffer.length = 0;
1279
+ ringBufferSeq.length = 0;
1280
+ return;
1281
+ }
1282
+ if (ringBuffer.length <= bufferSize) return;
1283
+ const excess = ringBuffer.length - bufferSize;
1284
+ ringBuffer.splice(0, excess);
1285
+ ringBufferSeq.splice(0, excess);
1286
+ };
1287
+ var trimRingBufferIfNeeded = () => {
1288
+ if (bufferSize <= 0) {
1289
+ ringBuffer.length = 0;
1290
+ ringBufferSeq.length = 0;
1291
+ return;
1292
+ }
1293
+ if (bufferSize <= 64) {
1294
+ ensureRingBufferSize();
1295
+ return;
1296
+ }
1297
+ const slack = Math.min(1024, Math.floor(bufferSize / 2));
1298
+ const threshold = bufferSize + Math.max(1, slack);
1299
+ if (ringBuffer.length <= threshold) return;
1300
+ const excess = ringBuffer.length - bufferSize;
1301
+ ringBuffer.splice(0, excess);
1302
+ ringBufferSeq.splice(0, excess);
1303
+ };
1304
+ var currentSnapshot = {
1305
+ snapshotToken,
1306
+ instances,
1307
+ events: ringBuffer,
1308
+ latestStates,
1309
+ latestTraitSummaries,
1310
+ exportBudget
1311
+ };
1312
+ var listeners = /* @__PURE__ */ new Set();
1313
+ var notifyScheduled = false;
1314
+ var scheduleNotify = () => {
1315
+ if (notifyScheduled) return;
1316
+ notifyScheduled = true;
1317
+ queueMicrotask(() => {
1318
+ notifyScheduled = false;
1319
+ for (const listener of listeners) {
1320
+ listener();
1321
+ }
1322
+ });
1323
+ };
1324
+ var devtoolsEnabled = false;
1325
+ var bumpSnapshotToken = () => {
1326
+ snapshotToken += 1;
1327
+ currentSnapshot.snapshotToken = snapshotToken;
1328
+ };
1329
+ var markSnapshotChanged = () => {
1330
+ bumpSnapshotToken();
1331
+ scheduleNotify();
1332
+ };
1333
+ var configureDevtoolsHub = (options) => {
1334
+ devtoolsEnabled = true;
1335
+ if (typeof options?.bufferSize === "number" && Number.isFinite(options.bufferSize)) {
1336
+ const next = Math.floor(options.bufferSize);
1337
+ const nextBufferSize = next >= 0 ? next : 0;
1338
+ if (nextBufferSize !== bufferSize) {
1339
+ bufferSize = nextBufferSize;
1340
+ ensureRingBufferSize();
1341
+ markSnapshotChanged();
1342
+ }
1343
+ }
1344
+ };
1345
+ var isDevtoolsEnabled = () => devtoolsEnabled;
1346
+ var getDevtoolsSnapshot = () => currentSnapshot;
1347
+ var getDevtoolsSnapshotToken = () => snapshotToken;
1348
+ var subscribeDevtoolsSnapshot = (listener) => {
1349
+ listeners.add(listener);
1350
+ return () => {
1351
+ listeners.delete(listener);
1352
+ };
1353
+ };
1354
+ var getDevtoolsRunId = () => currentRunId;
1355
+ var setDevtoolsRunId = (runId) => {
1356
+ if (typeof runId !== "string" || runId.length === 0) return;
1357
+ if (runId !== currentRunId) {
1358
+ currentRunId = runId;
1359
+ markSnapshotChanged();
1360
+ }
1361
+ };
1362
+ var startDevtoolsRun = (runId) => {
1363
+ currentRunId = typeof runId === "string" && runId.length > 0 ? runId : nextRunId();
1364
+ nextSeq = 1;
1365
+ clearRuntimeDebugEventSeq();
1366
+ clearDevtoolsEvents();
1367
+ return currentRunId;
1368
+ };
1369
+ var clearDevtoolsEvents = () => {
1370
+ ringBuffer.length = 0;
1371
+ ringBufferSeq.length = 0;
1372
+ exportBudget.dropped = 0;
1373
+ exportBudget.oversized = 0;
1374
+ markSnapshotChanged();
1375
+ };
1376
+ var setInstanceLabel = (instanceId, label) => {
1377
+ instanceLabels.set(instanceId, label);
1378
+ markSnapshotChanged();
1379
+ };
1380
+ var getInstanceLabel = (instanceId) => instanceLabels.get(instanceId);
1381
+ var registerConvergeStaticIr = (ir) => {
1382
+ convergeStaticIrByDigest.set(ir.staticIrDigest, ir);
1383
+ };
1384
+ var devtoolsHubConvergeStaticIrCollector = {
1385
+ register: registerConvergeStaticIr
1386
+ };
1387
+ var exportDevtoolsEvidencePackage = (options) => {
1388
+ const protocolVersion = options?.protocolVersion ?? OBSERVABILITY_PROTOCOL_VERSION;
1389
+ const runId = options?.runId ?? currentRunId;
1390
+ const source = options?.source ?? { host: "unknown" };
1391
+ const events = ringBuffer.map((payload, i) => ({
1392
+ protocolVersion,
1393
+ runId,
1394
+ seq: ringBufferSeq[i] ?? i + 1,
1395
+ timestamp: payload.timestamp,
1396
+ type: "debug:event",
1397
+ payload
1398
+ }));
1399
+ const isRecord = (value) => typeof value === "object" && value !== null && !Array.isArray(value);
1400
+ const convergeDigests = /* @__PURE__ */ new Set();
1401
+ let sawFullConverge = false;
1402
+ for (const ref of ringBuffer) {
1403
+ if (ref.kind !== "trait:converge") continue;
1404
+ const meta = ref.meta;
1405
+ if (!isRecord(meta)) continue;
1406
+ const digest = meta.staticIrDigest;
1407
+ if (typeof digest === "string" && digest.length > 0) {
1408
+ convergeDigests.add(digest);
1409
+ }
1410
+ const dirty = meta.dirty;
1411
+ if (isRecord(dirty) && typeof dirty.rootCount === "number") {
1412
+ sawFullConverge = true;
1413
+ }
1414
+ }
1415
+ let summary;
1416
+ if (sawFullConverge && convergeDigests.size > 0) {
1417
+ const staticIrByDigest = {};
1418
+ for (const digest of convergeDigests) {
1419
+ const ir = convergeStaticIrByDigest.get(digest);
1420
+ if (ir) {
1421
+ staticIrByDigest[digest] = ir;
1422
+ }
1423
+ }
1424
+ if (Object.keys(staticIrByDigest).length > 0) {
1425
+ summary = { converge: { staticIrByDigest } };
1426
+ }
1427
+ }
1428
+ return exportEvidencePackage({
1429
+ protocolVersion,
1430
+ runId,
1431
+ source,
1432
+ events,
1433
+ summary
1434
+ });
1435
+ };
1436
+ var devtoolsHubSink = {
1437
+ record: (event) => import_effect4.Effect.gen(function* () {
1438
+ const level = yield* import_effect4.FiberRef.get(currentDiagnosticsLevel);
1439
+ let changed = false;
1440
+ if (event.type === "trace:instanceLabel") {
1441
+ const instanceId = event.instanceId;
1442
+ const data = event.data;
1443
+ const label = data && typeof data === "object" && "label" in data ? String(data.label) : void 0;
1444
+ if (instanceId && label) {
1445
+ instanceLabels.set(instanceId, label);
1446
+ changed = true;
1447
+ }
1448
+ }
1449
+ if (event.type === "module:init" || event.type === "module:destroy") {
1450
+ const moduleId = event.moduleId ?? "unknown";
1451
+ const runtimeLabel2 = event.runtimeLabel ?? "unknown";
1452
+ const instanceId = event.instanceId;
1453
+ const key = `${runtimeLabel2}::${moduleId}`;
1454
+ const prev = instances.get(key) ?? 0;
1455
+ if (event.type === "module:init") {
1456
+ instances.set(key, prev + 1);
1457
+ changed = true;
1458
+ if (instanceId) {
1459
+ const instanceKey = `${runtimeLabel2}::${moduleId}::${instanceId}`;
1460
+ liveInstanceKeys.add(instanceKey);
1461
+ if (latestStates.delete(instanceKey)) changed = true;
1462
+ if (latestTraitSummaries.delete(instanceKey)) changed = true;
1463
+ }
1464
+ } else {
1465
+ const next = prev - 1;
1466
+ if (next <= 0) {
1467
+ if (instances.delete(key)) changed = true;
1468
+ } else {
1469
+ instances.set(key, next);
1470
+ changed = true;
1471
+ }
1472
+ if (instanceId) {
1473
+ const instanceKey = `${runtimeLabel2}::${moduleId}::${instanceId}`;
1474
+ liveInstanceKeys.delete(instanceKey);
1475
+ if (latestStates.delete(instanceKey)) changed = true;
1476
+ if (latestTraitSummaries.delete(instanceKey)) changed = true;
1477
+ if (instanceLabels.delete(instanceId)) changed = true;
1478
+ changed = true;
1479
+ }
1480
+ }
1481
+ }
1482
+ let exportBudgetChanged = false;
1483
+ const ref = toRuntimeDebugEventRef(event, {
1484
+ diagnosticsLevel: level,
1485
+ resolveConvergeStaticIr: (staticIrDigest) => convergeStaticIrByDigest.get(staticIrDigest),
1486
+ onMetaProjection: ({ stats }) => {
1487
+ if (stats.dropped !== 0 || stats.oversized !== 0) {
1488
+ exportBudgetChanged = true;
1489
+ }
1490
+ exportBudget.dropped += stats.dropped;
1491
+ exportBudget.oversized += stats.oversized;
1492
+ }
1493
+ });
1494
+ if (exportBudgetChanged) {
1495
+ changed = true;
1496
+ }
1497
+ if (!ref) {
1498
+ if (changed) {
1499
+ markSnapshotChanged();
1500
+ }
1501
+ return;
1502
+ }
1503
+ if (ref.kind === "state" && ref.label === "state:update") {
1504
+ const runtimeLabel2 = ref.runtimeLabel ?? "unknown";
1505
+ const key = `${runtimeLabel2}::${ref.moduleId}::${ref.instanceId}`;
1506
+ if (liveInstanceKeys.has(key)) {
1507
+ if (ref.meta && typeof ref.meta === "object" && !Array.isArray(ref.meta)) {
1508
+ const anyMeta = ref.meta;
1509
+ if ("state" in anyMeta) {
1510
+ latestStates.set(key, anyMeta.state);
1511
+ changed = true;
1512
+ }
1513
+ if ("traitSummary" in anyMeta && anyMeta.traitSummary !== void 0) {
1514
+ latestTraitSummaries.set(key, anyMeta.traitSummary);
1515
+ changed = true;
1516
+ }
1517
+ }
1518
+ }
1519
+ }
1520
+ if (bufferSize > 0) {
1521
+ const seq = nextSeq++;
1522
+ ringBuffer.push(ref);
1523
+ ringBufferSeq.push(seq);
1524
+ trimRingBufferIfNeeded();
1525
+ changed = true;
1526
+ }
1527
+ if (changed) {
1528
+ markSnapshotChanged();
1529
+ }
1530
+ })
1531
+ };
1532
+
1533
+ // src/internal/runtime/core/ConvergeStaticIrCollector.ts
1534
+ var import_effect5 = require("effect");
1535
+ var currentConvergeStaticIrCollectors = import_effect5.FiberRef.unsafeMake([]);
1536
+ var appendConvergeStaticIrCollectors = (collectors) => import_effect5.Layer.fiberRefLocallyScopedWith(currentConvergeStaticIrCollectors, (current) => [
1537
+ ...current,
1538
+ ...collectors
1539
+ ]);
1540
+
1541
+ // src/internal/runtime/core/env.ts
1542
+ var import_effect6 = require("effect");
1543
+ var getNodeEnv = () => {
1544
+ try {
1545
+ const env = globalThis?.process?.env;
1546
+ return typeof env?.NODE_ENV === "string" ? env.NODE_ENV : void 0;
1547
+ } catch {
1548
+ return void 0;
1549
+ }
1550
+ };
1551
+ var isDevEnv = () => getNodeEnv() !== "production";
1552
+ var StateTransactionConfigTagImpl = class extends import_effect6.Context.Tag("@logixjs/core/StateTransactionRuntimeConfig")() {
1553
+ };
1554
+ var ReadQueryStrictGateConfigTagImpl = class extends import_effect6.Context.Tag("@logixjs/core/ReadQueryStrictGateRuntimeConfig")() {
1555
+ };
1556
+ var ReplayModeConfigTagImpl = class extends import_effect6.Context.Tag("@logixjs/core/ReplayModeConfig")() {
1557
+ };
1558
+ var StateTransactionOverridesTagImpl = class extends import_effect6.Context.Tag("@logixjs/core/StateTransactionOverrides")() {
1559
+ };
1560
+ var ConcurrencyPolicyTagImpl = class extends import_effect6.Context.Tag("@logixjs/core/ConcurrencyPolicy")() {
1561
+ };
1562
+ var ConcurrencyPolicyOverridesTagImpl = class extends import_effect6.Context.Tag("@logixjs/core/ConcurrencyPolicyOverrides")() {
1563
+ };
1564
+
1565
+ // src/internal/debug/ModuleTraitsRegistry.ts
1566
+ var programsByIdAndDigest = /* @__PURE__ */ new Map();
1567
+ var latestDigestById = /* @__PURE__ */ new Map();
1568
+ var getModuleProgramById = (moduleId) => {
1569
+ const latestDigest = latestDigestById.get(moduleId);
1570
+ if (!latestDigest) return void 0;
1571
+ return programsByIdAndDigest.get(moduleId)?.get(latestDigest);
1572
+ };
1573
+
1574
+ // src/internal/runtime/core/runtimeInternalsAccessor.ts
1575
+ var RUNTIME_INTERNALS = /* @__PURE__ */ Symbol.for("@logixjs/core/runtimeInternals");
1576
+ var MODULE_TRAITS_PROGRAM = /* @__PURE__ */ Symbol.for("@logixjs/core/moduleTraitsProgram");
1577
+ var getModuleTraitsProgram = (module2) => {
1578
+ if (!module2) return void 0;
1579
+ if (typeof module2 !== "object" && typeof module2 !== "function") return void 0;
1580
+ return module2[MODULE_TRAITS_PROGRAM];
1581
+ };
1582
+ var formatScope = (moduleId, instanceId) => {
1583
+ const m = typeof moduleId === "string" && moduleId.length > 0 ? moduleId : "unknown";
1584
+ const i = typeof instanceId === "string" && instanceId.length > 0 ? instanceId : "unknown";
1585
+ return `moduleId=${m}, instanceId=${i}`;
1586
+ };
1587
+ var getRuntimeInternals = (runtime) => {
1588
+ const scope = runtime;
1589
+ const internals = runtime[RUNTIME_INTERNALS];
1590
+ if (!internals) {
1591
+ const msg = isDevEnv() ? [
1592
+ "[MissingRuntimeInternals] Runtime internals not installed on ModuleRuntime instance.",
1593
+ `scope: ${formatScope(scope.moduleId, scope.instanceId)}`,
1594
+ "fix:",
1595
+ "- Ensure ModuleRuntime.make calls internalHooks.installInternalHooks (020 foundation).",
1596
+ "- If you created a mock runtime for tests, attach internals or avoid calling internal-only APIs."
1597
+ ].join("\n") : "Runtime internals not installed";
1598
+ throw new Error(msg);
1599
+ }
1600
+ const runtimeInstanceId = scope.instanceId;
1601
+ if (typeof runtimeInstanceId === "string" && runtimeInstanceId.length > 0 && runtimeInstanceId !== internals.instanceId) {
1602
+ throw new Error(
1603
+ isDevEnv() ? [
1604
+ "[InconsistentRuntimeInternals] Runtime internals instanceId mismatch.",
1605
+ `runtime: ${formatScope(scope.moduleId, runtimeInstanceId)}`,
1606
+ `internals: ${formatScope(internals.moduleId, internals.instanceId)}`
1607
+ ].join("\n") : "Runtime internals mismatch"
1608
+ );
1609
+ }
1610
+ return internals;
1611
+ };
1612
+
1613
+ // src/Debug.ts
1614
+ var toRuntimeDebugEventRef2 = toRuntimeDebugEventRef;
1615
+ var internal = {
1616
+ currentDebugSinks,
1617
+ currentRuntimeLabel,
1618
+ currentDiagnosticsLevel,
1619
+ currentTraitConvergeDiagnosticsSampling,
1620
+ toRuntimeDebugEventRef
1621
+ };
1622
+ var getDevtoolsSnapshot2 = getDevtoolsSnapshot;
1623
+ var getDevtoolsSnapshotToken2 = getDevtoolsSnapshotToken;
1624
+ var subscribeDevtoolsSnapshot2 = subscribeDevtoolsSnapshot;
1625
+ var clearDevtoolsEvents2 = clearDevtoolsEvents;
1626
+ var getDevtoolsRunId2 = getDevtoolsRunId;
1627
+ var setDevtoolsRunId2 = setDevtoolsRunId;
1628
+ var startDevtoolsRun2 = startDevtoolsRun;
1629
+ var setInstanceLabel2 = setInstanceLabel;
1630
+ var getInstanceLabel2 = getInstanceLabel;
1631
+ var exportEvidencePackage2 = (options) => exportDevtoolsEvidencePackage(options);
1632
+ var diagnosticsLevel = (level) => import_effect7.Layer.fiberRefLocallyScopedWith(currentDiagnosticsLevel, () => level);
1633
+ var traitConvergeDiagnosticsSampling2 = (config) => traitConvergeDiagnosticsSampling(config);
1634
+ var isDevtoolsEnabled2 = isDevtoolsEnabled;
1635
+ var makeModuleRuntimeCounterSink = () => {
1636
+ const counts = /* @__PURE__ */ new Map();
1637
+ const sink = {
1638
+ record: (event) => import_effect7.Effect.sync(() => {
1639
+ if (event.type === "module:init") {
1640
+ const moduleId = event.moduleId ?? "unknown";
1641
+ const runtimeLabel2 = "runtimeLabel" in event && event.runtimeLabel ? event.runtimeLabel : "unknown";
1642
+ const key = `${runtimeLabel2}::${moduleId}`;
1643
+ const prev = counts.get(key) ?? 0;
1644
+ counts.set(key, prev + 1);
1645
+ return;
1646
+ }
1647
+ if (event.type === "module:destroy") {
1648
+ const moduleId = event.moduleId ?? "unknown";
1649
+ const runtimeLabel2 = "runtimeLabel" in event && event.runtimeLabel ? event.runtimeLabel : "unknown";
1650
+ const key = `${runtimeLabel2}::${moduleId}`;
1651
+ const prev = counts.get(key) ?? 0;
1652
+ const next = prev - 1;
1653
+ if (next <= 0) {
1654
+ counts.delete(key);
1655
+ } else {
1656
+ counts.set(key, next);
1657
+ }
1658
+ }
1659
+ })
1660
+ };
1661
+ const getSnapshot = () => new Map(counts);
1662
+ return { sink, getSnapshot };
1663
+ };
1664
+ var makeRingBufferSink = (capacity = 1e3) => {
1665
+ const buffer = [];
1666
+ const sink = {
1667
+ record: (event) => import_effect7.Effect.sync(() => {
1668
+ if (capacity <= 0) {
1669
+ return;
1670
+ }
1671
+ if (buffer.length >= capacity) {
1672
+ buffer.shift();
1673
+ }
1674
+ buffer.push(event);
1675
+ })
1676
+ };
1677
+ const getSnapshot = () => buffer.slice();
1678
+ const clear = () => {
1679
+ buffer.length = 0;
1680
+ };
1681
+ return { sink, getSnapshot, clear };
1682
+ };
1683
+ var record2 = record;
1684
+ var noopLayer2 = noopLayer;
1685
+ var resolveMode = (mode) => {
1686
+ if (mode && mode !== "auto") {
1687
+ return mode;
1688
+ }
1689
+ const env = getNodeEnv();
1690
+ return env === "production" ? "prod" : "dev";
1691
+ };
1692
+ var layer = (options) => {
1693
+ const mode = resolveMode(options?.mode);
1694
+ const diagnostics = options?.diagnosticsLevel;
1695
+ const sinks = (() => {
1696
+ switch (mode) {
1697
+ case "off":
1698
+ return noopLayer;
1699
+ case "prod":
1700
+ return errorOnlyLayer;
1701
+ case "dev":
1702
+ case "auto": {
1703
+ return options?.devConsole === "diagnostic" ? browserDiagnosticConsoleLayer : browserConsoleLayer;
1704
+ }
1705
+ }
1706
+ })();
1707
+ return diagnostics ? import_effect7.Layer.mergeAll(sinks, diagnosticsLevel(diagnostics)) : sinks;
1708
+ };
1709
+ var withPrettyLogger = (base, options) => import_effect7.Layer.merge(
1710
+ base,
1711
+ import_effect7.Logger.replace(import_effect7.Logger.defaultLogger, import_effect7.Logger.prettyLogger(options))
1712
+ );
1713
+ var replace = (sinks) => import_effect7.Layer.locallyScoped(internal.currentDebugSinks, sinks);
1714
+ var appendSinks = (sinks) => import_effect7.Layer.fiberRefLocallyScopedWith(currentDebugSinks, (current) => [
1715
+ ...current,
1716
+ ...sinks
1717
+ ]);
1718
+ function devtoolsHubLayer(baseOrOptions, maybeOptions) {
1719
+ const isLayerValue = (value) => typeof value === "object" && value !== null && "_op_layer" in value;
1720
+ const hasBase = isLayerValue(baseOrOptions);
1721
+ const base = hasBase ? baseOrOptions : import_effect7.Layer.empty;
1722
+ const options = hasBase ? maybeOptions : baseOrOptions;
1723
+ configureDevtoolsHub(options);
1724
+ const append = appendSinks([devtoolsHubSink]);
1725
+ const appendConvergeStaticIr = appendConvergeStaticIrCollectors([
1726
+ devtoolsHubConvergeStaticIrCollector
1727
+ ]);
1728
+ const enableExportableDiagnostics = diagnosticsLevel(options?.diagnosticsLevel ?? "light");
1729
+ const convergeSamplingLayer = options?.traitConvergeDiagnosticsSampling ? traitConvergeDiagnosticsSampling2(options.traitConvergeDiagnosticsSampling) : import_effect7.Layer.empty;
1730
+ return import_effect7.Layer.provideMerge(
1731
+ import_effect7.Layer.mergeAll(append, enableExportableDiagnostics, convergeSamplingLayer, appendConvergeStaticIr),
1732
+ base
1733
+ );
1734
+ }
1735
+ var runtimeLabel = (label) => import_effect7.Layer.fiberRefLocallyScopedWith(internal.currentRuntimeLabel, () => label);
1736
+ var getModuleTraits = (module2) => {
1737
+ const moduleTag = module2.tag ? module2.tag : module2;
1738
+ const program = getModuleTraitsProgram(moduleTag);
1739
+ if (!program) {
1740
+ return {};
1741
+ }
1742
+ return {
1743
+ program,
1744
+ graph: program.graph,
1745
+ plan: program.plan
1746
+ };
1747
+ };
1748
+ var getModuleTraitsById = (moduleId) => {
1749
+ const program = getModuleProgramById(moduleId);
1750
+ if (!program) {
1751
+ return void 0;
1752
+ }
1753
+ return {
1754
+ program,
1755
+ graph: program.graph,
1756
+ plan: program.plan
1757
+ };
1758
+ };
1759
+ var getModuleTraitsSnapshot = (runtime) => {
1760
+ try {
1761
+ const internals = getRuntimeInternals(runtime);
1762
+ return internals.traits.getModuleTraitsSnapshot();
1763
+ } catch {
1764
+ return void 0;
1765
+ }
1766
+ };
1767
+ var getModuleFinalTraits = (runtime) => {
1768
+ const snapshot = getModuleTraitsSnapshot(runtime);
1769
+ if (!snapshot) return [];
1770
+ return snapshot.traits.map((t) => ({
1771
+ traitId: t.traitId,
1772
+ name: t.name,
1773
+ description: t.description,
1774
+ provenance: snapshot.provenanceIndex[t.traitId]
1775
+ }));
1776
+ };
1777
+ var isLayer = (value) => typeof value === "object" && value !== null && "_op_layer" in value;
1778
+ function traceLayer(baseOrHandler, maybeOnTrace) {
1779
+ const hasBase = isLayer(baseOrHandler);
1780
+ const base = hasBase ? baseOrHandler : import_effect7.Layer.empty;
1781
+ const onTrace = hasBase ? maybeOnTrace : baseOrHandler;
1782
+ const traceSink = {
1783
+ record: (event) => typeof event.type === "string" && event.type.startsWith("trace:") ? onTrace ? onTrace(event) : import_effect7.Effect.logDebug({ traceEvent: event }) : import_effect7.Effect.void
1784
+ };
1785
+ const appendTrace = import_effect7.Layer.fiberRefLocallyScopedWith(currentDebugSinks, (sinks) => [...sinks, traceSink]);
1786
+ return import_effect7.Layer.provideMerge(appendTrace, base);
1787
+ }
1788
+ // Annotate the CommonJS export names for ESM import in node:
1789
+ 0 && (module.exports = {
1790
+ appendSinks,
1791
+ clearDevtoolsEvents,
1792
+ devtoolsHubLayer,
1793
+ diagnosticsLevel,
1794
+ exportEvidencePackage,
1795
+ getDevtoolsRunId,
1796
+ getDevtoolsSnapshot,
1797
+ getDevtoolsSnapshotToken,
1798
+ getInstanceLabel,
1799
+ getModuleFinalTraits,
1800
+ getModuleTraits,
1801
+ getModuleTraitsById,
1802
+ getModuleTraitsSnapshot,
1803
+ internal,
1804
+ isDevtoolsEnabled,
1805
+ layer,
1806
+ makeModuleRuntimeCounterSink,
1807
+ makeRingBufferSink,
1808
+ noopLayer,
1809
+ record,
1810
+ replace,
1811
+ runtimeLabel,
1812
+ setDevtoolsRunId,
1813
+ setInstanceLabel,
1814
+ startDevtoolsRun,
1815
+ subscribeDevtoolsSnapshot,
1816
+ toRuntimeDebugEventRef,
1817
+ traceLayer,
1818
+ traitConvergeDiagnosticsSampling,
1819
+ withPrettyLogger
1820
+ });
1821
+ //# sourceMappingURL=Debug.cjs.map