@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
@@ -0,0 +1,1034 @@
1
+ import {
2
+ currentLinkId,
3
+ projectJsonValue
4
+ } from "./chunk-JWOYLO27.js";
5
+
6
+ // src/internal/runtime/core/DebugSink.ts
7
+ import { Cause as Cause2, Effect, FiberRef, Layer, Logger } from "effect";
8
+
9
+ // src/internal/runtime/core/errorSummary.ts
10
+ import { Cause } from "effect";
11
+ var truncate = (value, maxLen) => {
12
+ if (value.length <= maxLen) return { value, truncated: false };
13
+ return { value: value.slice(0, maxLen), truncated: true };
14
+ };
15
+ var safeStringify = (value) => {
16
+ try {
17
+ return { ok: true, json: JSON.stringify(value) };
18
+ } catch {
19
+ return { ok: false };
20
+ }
21
+ };
22
+ var getMessageFromUnknown = (cause) => {
23
+ if (typeof cause === "string") return cause;
24
+ if (typeof cause === "number" || typeof cause === "boolean" || typeof cause === "bigint") return String(cause);
25
+ if (cause instanceof Error) return cause.message || cause.name || "Error";
26
+ if (cause && typeof cause === "object" && "message" in cause && typeof cause.message === "string") {
27
+ return cause.message;
28
+ }
29
+ try {
30
+ const pretty = Cause.pretty(cause, { renderErrorCause: true });
31
+ if (typeof pretty === "string" && pretty.length > 0) return pretty;
32
+ } catch {
33
+ }
34
+ return "Unknown error";
35
+ };
36
+ var toSerializableErrorSummary = (cause, options) => {
37
+ const maxMessageLength = options?.maxMessageLength ?? 256;
38
+ const messageRaw = getMessageFromUnknown(cause);
39
+ const { value: message, truncated } = truncate(messageRaw, maxMessageLength);
40
+ const summary = {
41
+ message
42
+ };
43
+ if (cause instanceof Error) {
44
+ if (cause.name && cause.name !== "Error") summary.name = cause.name;
45
+ const anyCause = cause;
46
+ if (typeof anyCause.code === "string" && anyCause.code.length > 0) summary.code = anyCause.code;
47
+ else if (typeof anyCause.code === "number" && Number.isFinite(anyCause.code)) summary.code = String(anyCause.code);
48
+ if (typeof anyCause.hint === "string" && anyCause.hint.length > 0) summary.hint = anyCause.hint;
49
+ return {
50
+ errorSummary: summary,
51
+ downgrade: truncated ? "oversized" : void 0
52
+ };
53
+ }
54
+ if (cause && typeof cause === "object") {
55
+ const anyCause = cause;
56
+ if (typeof anyCause.name === "string" && anyCause.name.length > 0) summary.name = anyCause.name;
57
+ if (typeof anyCause.code === "string" && anyCause.code.length > 0) summary.code = anyCause.code;
58
+ if (typeof anyCause.hint === "string" && anyCause.hint.length > 0) summary.hint = anyCause.hint;
59
+ }
60
+ const stringifyResult = safeStringify(cause);
61
+ if (!stringifyResult.ok) {
62
+ return {
63
+ errorSummary: summary,
64
+ downgrade: "non_serializable"
65
+ };
66
+ }
67
+ if (truncated) {
68
+ return {
69
+ errorSummary: summary,
70
+ downgrade: "oversized"
71
+ };
72
+ }
73
+ if (message === "Unknown error") {
74
+ return {
75
+ errorSummary: summary,
76
+ downgrade: "unknown"
77
+ };
78
+ }
79
+ return { errorSummary: summary };
80
+ };
81
+
82
+ // src/internal/runtime/core/DebugSink.ts
83
+ var currentDebugSinks = FiberRef.unsafeMake([]);
84
+ var currentRuntimeLabel = FiberRef.unsafeMake(void 0);
85
+ var currentTxnId = FiberRef.unsafeMake(void 0);
86
+ var currentOpSeq = FiberRef.unsafeMake(void 0);
87
+ var currentDiagnosticsLevel = FiberRef.unsafeMake("off");
88
+ var diagnosticsLevel = (level) => Layer.fiberRefLocallyScopedWith(currentDiagnosticsLevel, () => level);
89
+ var currentTraitConvergeDiagnosticsSampling = FiberRef.unsafeMake({
90
+ sampleEveryN: 32,
91
+ topK: 3
92
+ });
93
+ var traitConvergeDiagnosticsSampling = (config) => Layer.fiberRefLocallyScopedWith(currentTraitConvergeDiagnosticsSampling, () => config);
94
+ var appendSinks = (sinks) => Layer.fiberRefLocallyScopedWith(currentDebugSinks, (current) => [...current, ...sinks]);
95
+ var nextGlobalEventSeq = 0;
96
+ var clearRuntimeDebugEventSeq = () => {
97
+ nextGlobalEventSeq = 0;
98
+ };
99
+ var nextEventSeq = () => {
100
+ nextGlobalEventSeq += 1;
101
+ return nextGlobalEventSeq;
102
+ };
103
+ var makeEventId = (instanceId, eventSeq) => `${instanceId}::e${eventSeq}`;
104
+ var mergeDowngrade = (current, next) => {
105
+ if (!current) return next;
106
+ if (!next) return current;
107
+ if (current === "non_serializable" || next === "non_serializable") return "non_serializable";
108
+ if (current === "oversized" || next === "oversized") return "oversized";
109
+ return "unknown";
110
+ };
111
+ var browserLifecycleSeen = /* @__PURE__ */ new Set();
112
+ var browserDiagnosticSeen = /* @__PURE__ */ new Set();
113
+ var lastTxnByInstance = /* @__PURE__ */ new Map();
114
+ var pendingTxnAlignmentByInstance = /* @__PURE__ */ new Map();
115
+ var enqueuePendingTxnAlignment = (instanceId, ref) => {
116
+ const list = pendingTxnAlignmentByInstance.get(instanceId);
117
+ if (!list) {
118
+ pendingTxnAlignmentByInstance.set(instanceId, [ref]);
119
+ return;
120
+ }
121
+ list.push(ref);
122
+ if (list.length > 64) {
123
+ list.shift();
124
+ }
125
+ };
126
+ var backfillPendingTxnAlignment = (instanceId, txn) => {
127
+ const pending = pendingTxnAlignmentByInstance.get(instanceId);
128
+ if (!pending || pending.length === 0) {
129
+ pendingTxnAlignmentByInstance.delete(instanceId);
130
+ return;
131
+ }
132
+ for (const ref of pending) {
133
+ const anyRef = ref;
134
+ if (anyRef.txnId == null) {
135
+ anyRef.txnId = txn.txnId;
136
+ }
137
+ if (typeof anyRef.txnSeq !== "number" || anyRef.txnSeq <= 0) {
138
+ anyRef.txnSeq = txn.txnSeq;
139
+ }
140
+ }
141
+ pendingTxnAlignmentByInstance.delete(instanceId);
142
+ };
143
+ var lifecycleErrorLog = (event) => {
144
+ const moduleId = event.moduleId ?? "unknown";
145
+ const causePretty = (() => {
146
+ try {
147
+ return Cause2.pretty(event.cause, {
148
+ renderErrorCause: true
149
+ });
150
+ } catch {
151
+ try {
152
+ return JSON.stringify(event.cause, null, 2);
153
+ } catch {
154
+ return String(event.cause);
155
+ }
156
+ }
157
+ })();
158
+ const message = `[Logix][module=${moduleId}] lifecycle:error
159
+ ${causePretty}`;
160
+ return Effect.logError(message).pipe(
161
+ Effect.annotateLogs({
162
+ "logix.moduleId": moduleId,
163
+ "logix.event": "lifecycle:error",
164
+ "logix.cause": causePretty
165
+ })
166
+ );
167
+ };
168
+ var diagnosticLog = (event) => {
169
+ const moduleId = event.moduleId ?? "unknown";
170
+ const header = `[Logix][module=${moduleId}] diagnostic(${event.severity})`;
171
+ const detail = `code=${event.code} message=${event.message}${event.actionTag ? ` action=${event.actionTag}` : ""}${event.hint ? `
172
+ hint: ${event.hint}` : ""}`;
173
+ const msg = `${header}
174
+ ${detail}`;
175
+ const base = event.severity === "warning" ? Effect.logWarning(msg) : event.severity === "info" ? Effect.logInfo(msg) : Effect.logError(msg);
176
+ const annotations = {
177
+ "logix.moduleId": moduleId,
178
+ "logix.event": `diagnostic(${event.severity})`,
179
+ "logix.diagnostic.code": event.code,
180
+ "logix.diagnostic.message": event.message
181
+ };
182
+ if (event.hint) {
183
+ annotations["logix.diagnostic.hint"] = event.hint;
184
+ }
185
+ if (event.actionTag) {
186
+ annotations["logix.diagnostic.actionTag"] = event.actionTag;
187
+ }
188
+ return base.pipe(Effect.annotateLogs(annotations));
189
+ };
190
+ var noopLayer = Layer.locallyScoped(currentDebugSinks, []);
191
+ var errorOnlySink = {
192
+ record: (event) => event.type === "lifecycle:error" ? lifecycleErrorLog(event) : event.type === "diagnostic" && event.severity !== "info" ? diagnosticLog(event) : Effect.void
193
+ };
194
+ var errorOnlyLayer = Layer.locallyScoped(currentDebugSinks, [errorOnlySink]);
195
+ var isErrorOnlyOnlySinks = (sinks) => sinks.length === 1 && sinks[0] === errorOnlySink;
196
+ var consoleSink = {
197
+ record: (event) => event.type === "lifecycle:error" ? lifecycleErrorLog(event) : event.type === "diagnostic" ? diagnosticLog(event) : Effect.logDebug({ debugEvent: event })
198
+ };
199
+ var consoleLayer = Layer.locallyScoped(currentDebugSinks, [consoleSink]);
200
+ var isBrowser = typeof window !== "undefined" && typeof document !== "undefined";
201
+ var renderBrowserConsoleEvent = (event) => {
202
+ if (typeof event.type === "string" && event.type.startsWith("trace:")) {
203
+ const moduleId = event.moduleId ?? "unknown";
204
+ const type = event.type;
205
+ return Effect.sync(() => {
206
+ console.groupCollapsed(
207
+ "%c[Logix]%c trace %c" + moduleId + "%c " + String(type),
208
+ "color:#6b7280;font-weight:bold",
209
+ // tag
210
+ "color:#3b82f6",
211
+ // label
212
+ "color:#9ca3af",
213
+ // module id
214
+ "color:#6b7280"
215
+ // type
216
+ );
217
+ console.log(event);
218
+ console.groupEnd();
219
+ });
220
+ }
221
+ if (event.type === "lifecycle:error") {
222
+ const moduleId = event.moduleId ?? "unknown";
223
+ const causePretty = (() => {
224
+ try {
225
+ return Cause2.pretty(event.cause, { renderErrorCause: true });
226
+ } catch {
227
+ try {
228
+ return JSON.stringify(event.cause, null, 2);
229
+ } catch {
230
+ return String(event.cause);
231
+ }
232
+ }
233
+ })();
234
+ const key = `${moduleId}|${causePretty}`;
235
+ if (browserLifecycleSeen.has(key)) {
236
+ return Effect.void;
237
+ }
238
+ browserLifecycleSeen.add(key);
239
+ return Effect.sync(() => {
240
+ console.groupCollapsed(
241
+ "%c[Logix]%c lifecycle:error %c" + moduleId,
242
+ "color:#ef4444;font-weight:bold",
243
+ // tag
244
+ "color:#ef4444",
245
+ // label
246
+ "color:#9ca3af"
247
+ // module id
248
+ );
249
+ console.error(causePretty);
250
+ console.groupEnd();
251
+ });
252
+ }
253
+ if (event.type === "diagnostic") {
254
+ const moduleId = event.moduleId ?? "unknown";
255
+ const detail = `code=${event.code} message=${event.message}${event.actionTag ? ` action=${event.actionTag}` : ""}${event.hint ? `
256
+ hint: ${event.hint}` : ""}`;
257
+ const color = event.severity === "warning" ? "color:#d97706" : event.severity === "info" ? "color:#3b82f6" : "color:#ef4444";
258
+ const label = event.severity === "warning" ? "diagnostic(warning)" : event.severity === "info" ? "diagnostic(info)" : "diagnostic(error)";
259
+ const key = `${moduleId}|${event.code}|${event.message}`;
260
+ if (browserDiagnosticSeen.has(key)) {
261
+ return Effect.void;
262
+ }
263
+ browserDiagnosticSeen.add(key);
264
+ return Effect.sync(() => {
265
+ console.groupCollapsed(
266
+ "%c[Logix]%c " + label + "%c module=" + moduleId,
267
+ "color:#6b7280;font-weight:bold",
268
+ color,
269
+ "color:#9ca3af"
270
+ );
271
+ if (event.severity === "warning") {
272
+ console.warn(detail);
273
+ } else if (event.severity === "info") {
274
+ console.info(detail);
275
+ } else {
276
+ console.error(detail);
277
+ }
278
+ console.groupEnd();
279
+ });
280
+ }
281
+ return Effect.void;
282
+ };
283
+ var browserConsoleSink = {
284
+ record: (event) => {
285
+ if (!isBrowser) {
286
+ return event.type === "lifecycle:error" ? lifecycleErrorLog(event) : event.type === "diagnostic" ? diagnosticLog(event) : Effect.logDebug({ debugEvent: event });
287
+ }
288
+ return renderBrowserConsoleEvent(event);
289
+ }
290
+ };
291
+ var browserConsoleLayer = Layer.locallyScoped(currentDebugSinks, [browserConsoleSink]);
292
+ var browserDiagnosticConsoleSink = {
293
+ record: (event) => {
294
+ if (!isBrowser) {
295
+ return event.type === "lifecycle:error" ? lifecycleErrorLog(event) : event.type === "diagnostic" && event.severity !== "info" ? diagnosticLog(event) : Effect.void;
296
+ }
297
+ return event.type === "lifecycle:error" || event.type === "diagnostic" && event.severity !== "info" ? renderBrowserConsoleEvent(event) : Effect.void;
298
+ }
299
+ };
300
+ var browserDiagnosticConsoleLayer = Layer.locallyScoped(currentDebugSinks, [browserDiagnosticConsoleSink]);
301
+ var browserPrettyLoggerLayer = Logger.replace(
302
+ Logger.defaultLogger,
303
+ Logger.prettyLogger({ mode: "browser", colors: true })
304
+ );
305
+ var record = (event) => Effect.gen(function* () {
306
+ const sinks = yield* FiberRef.get(currentDebugSinks);
307
+ if (isErrorOnlyOnlySinks(sinks)) {
308
+ if (event.type === "lifecycle:error") {
309
+ yield* lifecycleErrorLog(event);
310
+ return;
311
+ }
312
+ if (event.type === "diagnostic") {
313
+ if (event.severity !== "info") {
314
+ yield* diagnosticLog(event);
315
+ } else {
316
+ yield* Effect.void;
317
+ }
318
+ return;
319
+ }
320
+ yield* Effect.void;
321
+ return;
322
+ }
323
+ if (sinks.length === 0) {
324
+ if (isBrowser) {
325
+ if (event.type === "lifecycle:error" || event.type === "diagnostic") {
326
+ yield* renderBrowserConsoleEvent(event);
327
+ return;
328
+ }
329
+ yield* Effect.void;
330
+ return;
331
+ }
332
+ if (event.type === "lifecycle:error") {
333
+ yield* lifecycleErrorLog(event);
334
+ return;
335
+ }
336
+ if (event.type === "diagnostic") {
337
+ yield* diagnosticLog(event);
338
+ return;
339
+ }
340
+ yield* Effect.void;
341
+ return;
342
+ }
343
+ const enriched = event;
344
+ const diagnosticsLevel2 = yield* FiberRef.get(currentDiagnosticsLevel);
345
+ let now;
346
+ const getNow = () => {
347
+ if (now === void 0) now = Date.now();
348
+ return now;
349
+ };
350
+ if (enriched.timestamp === void 0 && (diagnosticsLevel2 !== "off" || enriched.type === "lifecycle:error" || enriched.type === "diagnostic")) {
351
+ ;
352
+ enriched.timestamp = getNow();
353
+ }
354
+ if (diagnosticsLevel2 !== "off" && enriched.runtimeLabel === void 0) {
355
+ const runtimeLabel = yield* FiberRef.get(currentRuntimeLabel);
356
+ if (runtimeLabel) {
357
+ ;
358
+ enriched.runtimeLabel = runtimeLabel;
359
+ }
360
+ }
361
+ if (enriched.type === "diagnostic" && enriched.txnId === void 0) {
362
+ const txnId = yield* FiberRef.get(currentTxnId);
363
+ if (txnId) {
364
+ ;
365
+ enriched.txnId = txnId;
366
+ }
367
+ }
368
+ if (diagnosticsLevel2 !== "off" && enriched.type === "trace:effectop" && enriched.linkId === void 0) {
369
+ const linkId = yield* FiberRef.get(currentLinkId);
370
+ if (linkId) {
371
+ ;
372
+ enriched.linkId = linkId;
373
+ }
374
+ }
375
+ if (sinks.length === 1) {
376
+ yield* sinks[0].record(enriched);
377
+ return;
378
+ }
379
+ yield* Effect.forEach(sinks, (sink) => sink.record(enriched), { discard: true });
380
+ });
381
+ var toRuntimeDebugEventRef = (event, options) => {
382
+ const diagnosticsLevel2 = options?.diagnosticsLevel ?? "full";
383
+ if (diagnosticsLevel2 === "off") {
384
+ return void 0;
385
+ }
386
+ const isLightLike = diagnosticsLevel2 === "light" || diagnosticsLevel2 === "sampled";
387
+ const timestamp = typeof event.timestamp === "number" && Number.isFinite(event.timestamp) ? event.timestamp : Date.now();
388
+ const moduleIdRaw = event.moduleId;
389
+ const moduleId = typeof moduleIdRaw === "string" && moduleIdRaw.length > 0 ? moduleIdRaw : "unknown";
390
+ const instanceIdRaw = event.instanceId;
391
+ const instanceId = typeof instanceIdRaw === "string" && instanceIdRaw.length > 0 ? instanceIdRaw : "unknown";
392
+ const runtimeLabelRaw = event.runtimeLabel;
393
+ const runtimeLabel = typeof runtimeLabelRaw === "string" && runtimeLabelRaw.length > 0 ? runtimeLabelRaw : void 0;
394
+ const txnSeqRaw = event.txnSeq;
395
+ const txnSeq = typeof txnSeqRaw === "number" && Number.isFinite(txnSeqRaw) && txnSeqRaw >= 0 ? Math.floor(txnSeqRaw) : 0;
396
+ const txnIdRaw = event.txnId;
397
+ const txnId = typeof txnIdRaw === "string" && txnIdRaw.length > 0 ? txnIdRaw : txnSeq > 0 ? `${instanceId}::t${txnSeq}` : void 0;
398
+ const linkId = (() => {
399
+ const linkIdRaw = event.linkId;
400
+ if (typeof linkIdRaw === "string" && linkIdRaw.length > 0) return linkIdRaw;
401
+ if (typeof event.type !== "string" || !event.type.startsWith("trace:")) {
402
+ return void 0;
403
+ }
404
+ const data = event.data;
405
+ const meta = data?.meta;
406
+ const linkIdFromMeta = meta?.linkId;
407
+ if (typeof linkIdFromMeta === "string" && linkIdFromMeta.length > 0) return linkIdFromMeta;
408
+ return void 0;
409
+ })();
410
+ const eventSeqRaw = options?.eventSeq;
411
+ const eventSeq = typeof eventSeqRaw === "number" && Number.isFinite(eventSeqRaw) && eventSeqRaw > 0 ? Math.floor(eventSeqRaw) : nextEventSeq();
412
+ const eventId = makeEventId(instanceId, eventSeq);
413
+ const base = {
414
+ eventId,
415
+ eventSeq,
416
+ moduleId,
417
+ instanceId,
418
+ runtimeLabel,
419
+ txnSeq,
420
+ txnId,
421
+ linkId,
422
+ timestamp
423
+ };
424
+ let downgrade;
425
+ const withDowngrade = (ref) => {
426
+ if (!downgrade) return ref;
427
+ return { ...ref, downgrade: { reason: downgrade } };
428
+ };
429
+ switch (event.type) {
430
+ case "module:init":
431
+ return withDowngrade({
432
+ ...base,
433
+ kind: "lifecycle",
434
+ label: "module:init"
435
+ });
436
+ case "module:destroy":
437
+ return withDowngrade({
438
+ ...base,
439
+ kind: "lifecycle",
440
+ label: "module:destroy"
441
+ });
442
+ case "lifecycle:phase": {
443
+ const e = event;
444
+ const metaInput = isLightLike ? { type: "lifecycle:phase", phase: e.phase, name: e.name } : { type: "lifecycle:phase", phase: e.phase, name: e.name, payload: e.payload };
445
+ const metaProjection = projectJsonValue(metaInput);
446
+ options?.onMetaProjection?.({
447
+ stats: metaProjection.stats,
448
+ downgrade: metaProjection.downgrade
449
+ });
450
+ downgrade = mergeDowngrade(downgrade, metaProjection.downgrade);
451
+ return withDowngrade({
452
+ ...base,
453
+ kind: "lifecycle",
454
+ label: e.name,
455
+ meta: metaProjection.value
456
+ });
457
+ }
458
+ case "action:dispatch": {
459
+ const action = event.action;
460
+ const actionTagRaw = event.actionTag;
461
+ const tag = typeof actionTagRaw === "string" && actionTagRaw.length > 0 ? actionTagRaw : action?._tag ?? action?.type;
462
+ const label = String(tag ?? "action:dispatch");
463
+ const labelNormalized = label.length > 0 ? label : "unknown";
464
+ const unknownAction = event.unknownAction === true ? true : void 0;
465
+ const metaInput = isLightLike ? { actionTag: labelNormalized, ...unknownAction ? { unknownAction: true } : {} } : { action, ...unknownAction ? { unknownAction: true } : {} };
466
+ const metaProjection = projectJsonValue(metaInput);
467
+ options?.onMetaProjection?.({
468
+ stats: metaProjection.stats,
469
+ downgrade: metaProjection.downgrade
470
+ });
471
+ downgrade = mergeDowngrade(downgrade, metaProjection.downgrade);
472
+ if (unknownAction) {
473
+ downgrade = mergeDowngrade(downgrade, "unknown");
474
+ }
475
+ return withDowngrade({
476
+ ...base,
477
+ kind: "action",
478
+ label: labelNormalized,
479
+ meta: metaProjection.value
480
+ });
481
+ }
482
+ case "state:update": {
483
+ const e = event;
484
+ const resolveDirtySetRootPaths = () => {
485
+ const resolve = options?.resolveConvergeStaticIr;
486
+ if (!resolve) return void 0;
487
+ const digest = e.staticIrDigest;
488
+ if (typeof digest !== "string" || digest.length === 0) return void 0;
489
+ const dirtySet = e.dirtySet;
490
+ if (!dirtySet || typeof dirtySet !== "object" || Array.isArray(dirtySet)) return void 0;
491
+ const rootIds = dirtySet.rootIds;
492
+ if (!Array.isArray(rootIds) || rootIds.length === 0) return void 0;
493
+ const ir = resolve(digest);
494
+ const fieldPaths = ir?.fieldPaths;
495
+ if (!Array.isArray(fieldPaths) || fieldPaths.length === 0) return void 0;
496
+ const out = [];
497
+ for (const rawId of rootIds) {
498
+ if (typeof rawId !== "number" || !Number.isFinite(rawId)) continue;
499
+ const id = Math.floor(rawId);
500
+ if (id < 0) continue;
501
+ const path = fieldPaths[id];
502
+ if (!Array.isArray(path) || path.length === 0) continue;
503
+ if (!path.every((seg) => typeof seg === "string" && seg.length > 0)) continue;
504
+ out.push(path);
505
+ }
506
+ return out.length > 0 ? out : void 0;
507
+ };
508
+ const dirtySetWithRootPaths = (() => {
509
+ const rootPaths = resolveDirtySetRootPaths();
510
+ if (!rootPaths) return e.dirtySet;
511
+ const dirtySet = e.dirtySet;
512
+ if (!dirtySet || typeof dirtySet !== "object" || Array.isArray(dirtySet)) return e.dirtySet;
513
+ return { ...dirtySet, rootPaths };
514
+ })();
515
+ const metaInput = isLightLike ? {
516
+ state: e.state,
517
+ dirtySet: dirtySetWithRootPaths,
518
+ patchCount: e.patchCount,
519
+ patchesTruncated: e.patchesTruncated,
520
+ patchesTruncatedReason: e.patchesTruncatedReason,
521
+ staticIrDigest: e.staticIrDigest,
522
+ commitMode: e.commitMode,
523
+ priority: e.priority,
524
+ originKind: e.originKind,
525
+ originName: e.originName
526
+ } : {
527
+ state: e.state,
528
+ dirtySet: dirtySetWithRootPaths,
529
+ patchCount: e.patchCount,
530
+ patchesTruncated: e.patchesTruncated,
531
+ patchesTruncatedReason: e.patchesTruncatedReason,
532
+ staticIrDigest: e.staticIrDigest,
533
+ commitMode: e.commitMode,
534
+ priority: e.priority,
535
+ originKind: e.originKind,
536
+ originName: e.originName,
537
+ traitSummary: e.traitSummary,
538
+ replayEvent: e.replayEvent
539
+ };
540
+ const metaProjection = projectJsonValue(metaInput);
541
+ options?.onMetaProjection?.({
542
+ stats: metaProjection.stats,
543
+ downgrade: metaProjection.downgrade
544
+ });
545
+ downgrade = mergeDowngrade(downgrade, metaProjection.downgrade);
546
+ if (txnId) {
547
+ lastTxnByInstance.set(instanceId, { txnId, txnSeq });
548
+ backfillPendingTxnAlignment(instanceId, { txnId, txnSeq });
549
+ }
550
+ return withDowngrade({
551
+ ...base,
552
+ kind: "state",
553
+ label: "state:update",
554
+ meta: metaProjection.value
555
+ });
556
+ }
557
+ case "process:start":
558
+ case "process:stop":
559
+ case "process:restart":
560
+ case "process:trigger":
561
+ case "process:dispatch":
562
+ case "process:error": {
563
+ const e = event;
564
+ const ts2 = typeof e.timestampMs === "number" && Number.isFinite(e.timestampMs) ? e.timestampMs : timestamp;
565
+ const metaInput = {
566
+ identity: e.identity,
567
+ severity: e.severity,
568
+ eventSeq: e.eventSeq,
569
+ timestampMs: e.timestampMs,
570
+ trigger: e.trigger,
571
+ dispatch: e.dispatch,
572
+ error: e.error
573
+ };
574
+ const metaProjection = projectJsonValue(metaInput);
575
+ options?.onMetaProjection?.({
576
+ stats: metaProjection.stats,
577
+ downgrade: metaProjection.downgrade
578
+ });
579
+ downgrade = mergeDowngrade(downgrade, metaProjection.downgrade);
580
+ const errorSummary = e.type === "process:error" || e.type === "process:restart" ? e.error : void 0;
581
+ return withDowngrade({
582
+ ...base,
583
+ timestamp: ts2,
584
+ kind: "process",
585
+ label: e.type,
586
+ meta: metaProjection.value,
587
+ errorSummary
588
+ });
589
+ }
590
+ case "lifecycle:error": {
591
+ const e = event;
592
+ const summary = toSerializableErrorSummary(e.cause);
593
+ downgrade = mergeDowngrade(downgrade, summary.downgrade);
594
+ const metaInput = isLightLike ? { type: "lifecycle:error", phase: e.phase, name: e.hook } : {
595
+ type: "lifecycle:error",
596
+ phase: e.phase,
597
+ name: e.hook,
598
+ hook: e.hook,
599
+ taskId: e.taskId,
600
+ origin: e.origin,
601
+ txnSeq: e.txnSeq,
602
+ opSeq: e.opSeq
603
+ };
604
+ const metaProjection = projectJsonValue(metaInput);
605
+ options?.onMetaProjection?.({
606
+ stats: metaProjection.stats,
607
+ downgrade: metaProjection.downgrade
608
+ });
609
+ downgrade = mergeDowngrade(downgrade, metaProjection.downgrade);
610
+ return withDowngrade({
611
+ ...base,
612
+ kind: "lifecycle",
613
+ label: "lifecycle:error",
614
+ meta: metaProjection.value,
615
+ errorSummary: summary.errorSummary
616
+ });
617
+ }
618
+ case "diagnostic": {
619
+ const e = event;
620
+ const metaInput = {
621
+ code: e.code,
622
+ severity: e.severity,
623
+ message: e.message,
624
+ hint: e.hint,
625
+ actionTag: e.actionTag,
626
+ kind: e.kind,
627
+ trigger: e.trigger
628
+ };
629
+ const metaProjection = projectJsonValue(metaInput);
630
+ options?.onMetaProjection?.({
631
+ stats: metaProjection.stats,
632
+ downgrade: metaProjection.downgrade
633
+ });
634
+ downgrade = mergeDowngrade(downgrade, metaProjection.downgrade);
635
+ return withDowngrade({
636
+ ...base,
637
+ kind: "diagnostic",
638
+ label: e.code,
639
+ meta: metaProjection.value
640
+ });
641
+ }
642
+ default: {
643
+ if (typeof event.type !== "string" || !event.type.startsWith("trace:")) {
644
+ return void 0;
645
+ }
646
+ if (event.type === "trace:txn-lane") {
647
+ const data = event.data;
648
+ const evidence = data?.evidence ?? data;
649
+ const metaProjection2 = projectJsonValue(evidence);
650
+ options?.onMetaProjection?.({
651
+ stats: metaProjection2.stats,
652
+ downgrade: metaProjection2.downgrade
653
+ });
654
+ downgrade = mergeDowngrade(downgrade, metaProjection2.downgrade);
655
+ const label = typeof evidence?.kind === "string" && evidence.kind.length > 0 ? String(evidence.kind) : "txn-lane";
656
+ return withDowngrade({
657
+ ...base,
658
+ kind: "txn-lane",
659
+ label,
660
+ meta: metaProjection2.value
661
+ });
662
+ }
663
+ if (event.type === "trace:react-render" || event.type === "trace:react-selector") {
664
+ const data = event.data;
665
+ const metaProjection2 = projectJsonValue(
666
+ isLightLike ? {
667
+ componentLabel: data?.componentLabel,
668
+ selectorKey: data?.selectorKey,
669
+ fieldPaths: data?.fieldPaths,
670
+ selectorId: data?.selectorId,
671
+ lane: data?.lane,
672
+ producer: data?.producer,
673
+ fallbackReason: data?.fallbackReason,
674
+ readsDigest: data?.readsDigest,
675
+ equalsKind: data?.equalsKind,
676
+ strictModePhase: data?.strictModePhase
677
+ } : {
678
+ componentLabel: data?.componentLabel,
679
+ selectorKey: data?.selectorKey,
680
+ fieldPaths: data?.fieldPaths,
681
+ selectorId: data?.selectorId,
682
+ lane: data?.lane,
683
+ producer: data?.producer,
684
+ fallbackReason: data?.fallbackReason,
685
+ readsDigest: data?.readsDigest,
686
+ equalsKind: data?.equalsKind,
687
+ strictModePhase: data?.strictModePhase,
688
+ meta: data?.meta
689
+ }
690
+ );
691
+ options?.onMetaProjection?.({
692
+ stats: metaProjection2.stats,
693
+ downgrade: metaProjection2.downgrade
694
+ });
695
+ downgrade = mergeDowngrade(downgrade, metaProjection2.downgrade);
696
+ const label = typeof data?.componentLabel === "string" && data.componentLabel.length > 0 ? data.componentLabel : event.type === "trace:react-selector" ? "react-selector" : "react-render";
697
+ const last = lastTxnByInstance.get(instanceId);
698
+ const txnSeqFromMeta = typeof data?.meta?.txnSeq === "number" && Number.isFinite(data.meta.txnSeq) && data.meta.txnSeq >= 0 ? Math.floor(data.meta.txnSeq) : void 0;
699
+ const txnIdFromMeta = typeof data?.meta?.txnId === "string" && data.meta.txnId.length > 0 ? data.meta.txnId : void 0;
700
+ const txnIdAligned = txnIdFromMeta ?? base.txnId ?? last?.txnId;
701
+ const txnSeqAligned = txnSeqFromMeta ?? (base.txnSeq > 0 ? base.txnSeq : last?.txnSeq ?? base.txnSeq);
702
+ const ref = withDowngrade({
703
+ ...base,
704
+ txnId: txnIdAligned,
705
+ txnSeq: txnSeqAligned,
706
+ kind: event.type === "trace:react-selector" ? "react-selector" : "react-render",
707
+ label,
708
+ meta: metaProjection2.value
709
+ });
710
+ if (instanceId !== "unknown" && (ref.txnId == null || ref.txnSeq <= 0)) {
711
+ enqueuePendingTxnAlignment(instanceId, ref);
712
+ }
713
+ return ref;
714
+ }
715
+ if (event.type === "trace:selector:eval") {
716
+ const data = event.data;
717
+ const metaInput = {
718
+ selectorId: data?.selectorId,
719
+ lane: data?.lane,
720
+ producer: data?.producer,
721
+ fallbackReason: data?.fallbackReason,
722
+ readsDigest: data?.readsDigest,
723
+ equalsKind: data?.equalsKind,
724
+ changed: data?.changed,
725
+ evalMs: data?.evalMs
726
+ };
727
+ const metaProjection2 = projectJsonValue(metaInput);
728
+ options?.onMetaProjection?.({
729
+ stats: metaProjection2.stats,
730
+ downgrade: metaProjection2.downgrade
731
+ });
732
+ downgrade = mergeDowngrade(downgrade, metaProjection2.downgrade);
733
+ return withDowngrade({
734
+ ...base,
735
+ kind: "devtools",
736
+ label: event.type,
737
+ meta: metaProjection2.value
738
+ });
739
+ }
740
+ if (event.type === "trace:exec-vm") {
741
+ const data = event.data;
742
+ const metaInput = {
743
+ version: data?.version,
744
+ stage: data?.stage,
745
+ hit: data?.hit,
746
+ reasonCode: data?.reasonCode ?? data?.reason,
747
+ reasonDetail: data?.reasonDetail,
748
+ execIrVersion: data?.execIrVersion,
749
+ execIrHash: data?.execIrHash,
750
+ serviceId: data?.serviceId,
751
+ implId: data?.implId
752
+ };
753
+ const metaProjection2 = projectJsonValue(metaInput);
754
+ options?.onMetaProjection?.({
755
+ stats: metaProjection2.stats,
756
+ downgrade: metaProjection2.downgrade
757
+ });
758
+ downgrade = mergeDowngrade(downgrade, metaProjection2.downgrade);
759
+ return withDowngrade({
760
+ ...base,
761
+ kind: "devtools",
762
+ label: event.type,
763
+ meta: metaProjection2.value
764
+ });
765
+ }
766
+ if (event.type === "trace:trait:converge") {
767
+ const resolveDirtyRootPaths = (args) => {
768
+ const resolve = options?.resolveConvergeStaticIr;
769
+ if (!resolve) return void 0;
770
+ const digest = args.staticIrDigest;
771
+ if (typeof digest !== "string" || digest.length === 0) return void 0;
772
+ const rootIds = args.rootIds;
773
+ if (!Array.isArray(rootIds) || rootIds.length === 0) return void 0;
774
+ const ir = resolve(digest);
775
+ const fieldPaths = ir?.fieldPaths;
776
+ if (!Array.isArray(fieldPaths) || fieldPaths.length === 0) return void 0;
777
+ const out = [];
778
+ for (const id of rootIds) {
779
+ if (typeof id !== "number" || !Number.isFinite(id)) continue;
780
+ const idx = Math.floor(id);
781
+ if (idx < 0 || idx >= fieldPaths.length) continue;
782
+ const path = fieldPaths[idx];
783
+ if (Array.isArray(path)) {
784
+ out.push(path);
785
+ }
786
+ }
787
+ return out.length > 0 ? out : void 0;
788
+ };
789
+ const enrichDirtyRootPaths = (value) => {
790
+ if (!value || typeof value !== "object" || Array.isArray(value)) return value;
791
+ const anyValue = value;
792
+ const dirty = anyValue.dirty;
793
+ if (!dirty || typeof dirty !== "object" || Array.isArray(dirty)) return value;
794
+ const dirtyRootPaths = resolveDirtyRootPaths({
795
+ staticIrDigest: anyValue.staticIrDigest,
796
+ rootIds: dirty?.rootIds
797
+ });
798
+ if (!dirtyRootPaths) return value;
799
+ return {
800
+ ...anyValue,
801
+ dirty: {
802
+ ...dirty,
803
+ rootPaths: dirtyRootPaths
804
+ }
805
+ };
806
+ };
807
+ const stripHeavyLight = (value) => {
808
+ if (!value || typeof value !== "object" || Array.isArray(value)) return value;
809
+ const anyValue = value;
810
+ const dirty = anyValue.dirty;
811
+ const dirtyRootPaths = resolveDirtyRootPaths({
812
+ staticIrDigest: anyValue.staticIrDigest,
813
+ rootIds: dirty?.rootIds
814
+ });
815
+ const dirtySlim = dirty && typeof dirty === "object" && !Array.isArray(dirty) ? {
816
+ dirtyAll: dirty.dirtyAll,
817
+ ...typeof dirty.reason === "string" ? { reason: dirty.reason } : null,
818
+ ...Array.isArray(dirty.rootIds) ? { rootIds: dirty.rootIds } : null,
819
+ ...typeof dirty.rootIdsTruncated === "boolean" ? { rootIdsTruncated: dirty.rootIdsTruncated } : null,
820
+ ...dirtyRootPaths ? { rootPaths: dirtyRootPaths } : null
821
+ } : void 0;
822
+ const { top3, dirtyRoots, ...rest } = anyValue;
823
+ return dirtySlim ? { ...rest, dirty: dirtySlim } : rest;
824
+ };
825
+ const stripHeavySampled = (value) => {
826
+ if (!value || typeof value !== "object" || Array.isArray(value)) return value;
827
+ const anyValue = value;
828
+ const dirty = anyValue.dirty;
829
+ const dirtySlim = dirty && typeof dirty === "object" && !Array.isArray(dirty) ? {
830
+ dirtyAll: dirty.dirtyAll,
831
+ ...typeof dirty.reason === "string" ? { reason: dirty.reason } : null
832
+ } : void 0;
833
+ const { dirtyRoots, ...rest } = anyValue;
834
+ return dirtySlim ? { ...rest, dirty: dirtySlim } : rest;
835
+ };
836
+ const data = event.data;
837
+ const metaInput = diagnosticsLevel2 === "light" ? stripHeavyLight(data) : diagnosticsLevel2 === "sampled" ? stripHeavySampled(data) : enrichDirtyRootPaths(data);
838
+ const metaProjection2 = projectJsonValue(metaInput);
839
+ options?.onMetaProjection?.({
840
+ stats: metaProjection2.stats,
841
+ downgrade: metaProjection2.downgrade
842
+ });
843
+ downgrade = mergeDowngrade(downgrade, metaProjection2.downgrade);
844
+ return withDowngrade({
845
+ ...base,
846
+ kind: "trait:converge",
847
+ label: "trait:converge",
848
+ meta: metaProjection2.value
849
+ });
850
+ }
851
+ if (event.type === "trace:trait:check") {
852
+ const stripHeavy = (value) => {
853
+ if (!value || typeof value !== "object" || Array.isArray(value)) return value;
854
+ const anyValue = value;
855
+ const degraded = anyValue.degraded;
856
+ const degradedSlim = degraded && typeof degraded === "object" && !Array.isArray(degraded) ? { kind: degraded.kind } : void 0;
857
+ const { degraded: _degraded, ...rest } = anyValue;
858
+ return degradedSlim ? { ...rest, degraded: degradedSlim } : rest;
859
+ };
860
+ const data = event.data;
861
+ const metaInput = isLightLike ? stripHeavy(data) : data;
862
+ const metaProjection2 = projectJsonValue(metaInput);
863
+ options?.onMetaProjection?.({
864
+ stats: metaProjection2.stats,
865
+ downgrade: metaProjection2.downgrade
866
+ });
867
+ downgrade = mergeDowngrade(downgrade, metaProjection2.downgrade);
868
+ return withDowngrade({
869
+ ...base,
870
+ kind: "trait:check",
871
+ label: "trait:check",
872
+ meta: metaProjection2.value
873
+ });
874
+ }
875
+ if (event.type === "trace:trait:validate") {
876
+ const data = event.data;
877
+ const metaProjection2 = projectJsonValue(data);
878
+ options?.onMetaProjection?.({
879
+ stats: metaProjection2.stats,
880
+ downgrade: metaProjection2.downgrade
881
+ });
882
+ downgrade = mergeDowngrade(downgrade, metaProjection2.downgrade);
883
+ return withDowngrade({
884
+ ...base,
885
+ kind: "trait:validate",
886
+ label: "trait:validate",
887
+ meta: metaProjection2.value
888
+ });
889
+ }
890
+ if (event.type === "trace:module:traits") {
891
+ const data = event.data;
892
+ const metaInput = isLightLike ? {
893
+ digest: data?.digest,
894
+ count: data?.count
895
+ } : {
896
+ digest: data?.digest,
897
+ count: data?.count,
898
+ traits: data?.traits,
899
+ provenanceIndex: data?.provenanceIndex
900
+ };
901
+ const metaProjection2 = projectJsonValue(metaInput);
902
+ options?.onMetaProjection?.({
903
+ stats: metaProjection2.stats,
904
+ downgrade: metaProjection2.downgrade
905
+ });
906
+ downgrade = mergeDowngrade(downgrade, metaProjection2.downgrade);
907
+ return withDowngrade({
908
+ ...base,
909
+ kind: "devtools",
910
+ label: event.type,
911
+ meta: metaProjection2.value
912
+ });
913
+ }
914
+ if (event.type === "trace:module:traits:conflict") {
915
+ const data = event.data;
916
+ const metaInput = isLightLike ? {
917
+ conflictCount: data?.conflictCount,
918
+ traitIds: data?.traitIds
919
+ } : {
920
+ conflictCount: data?.conflictCount,
921
+ conflicts: data?.conflicts
922
+ };
923
+ const metaProjection2 = projectJsonValue(metaInput);
924
+ options?.onMetaProjection?.({
925
+ stats: metaProjection2.stats,
926
+ downgrade: metaProjection2.downgrade
927
+ });
928
+ downgrade = mergeDowngrade(downgrade, metaProjection2.downgrade);
929
+ return withDowngrade({
930
+ ...base,
931
+ kind: "devtools",
932
+ label: event.type,
933
+ meta: metaProjection2.value
934
+ });
935
+ }
936
+ if (event.type === "trace:module:descriptor") {
937
+ const data = event.data;
938
+ const metaInput = isLightLike ? {
939
+ id: data?.id,
940
+ traits: data?.traits,
941
+ source: data?.source
942
+ } : { data };
943
+ const metaProjection2 = projectJsonValue(metaInput);
944
+ options?.onMetaProjection?.({
945
+ stats: metaProjection2.stats,
946
+ downgrade: metaProjection2.downgrade
947
+ });
948
+ downgrade = mergeDowngrade(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:effectop") {
957
+ const data = event.data;
958
+ const opMeta = data?.meta;
959
+ const opKind = data?.kind ?? "service";
960
+ const label = typeof data?.name === "string" ? data.name : "effectop";
961
+ const moduleId2 = typeof opMeta?.moduleId === "string" ? opMeta.moduleId : moduleId;
962
+ const txnId2 = typeof opMeta?.txnId === "string" && opMeta.txnId.length > 0 ? opMeta.txnId : base.txnId;
963
+ const txnSeq2 = typeof opMeta?.txnSeq === "number" && Number.isFinite(opMeta.txnSeq) && opMeta.txnSeq >= 0 ? Math.floor(opMeta.txnSeq) : base.txnSeq;
964
+ const metaInput = isLightLike ? {
965
+ id: data?.id,
966
+ kind: data?.kind,
967
+ name: data?.name,
968
+ meta: opMeta
969
+ } : {
970
+ id: data?.id,
971
+ kind: data?.kind,
972
+ name: data?.name,
973
+ payload: data?.payload,
974
+ meta: opMeta
975
+ };
976
+ const metaProjection2 = projectJsonValue(metaInput);
977
+ options?.onMetaProjection?.({
978
+ stats: metaProjection2.stats,
979
+ downgrade: metaProjection2.downgrade
980
+ });
981
+ downgrade = mergeDowngrade(downgrade, metaProjection2.downgrade);
982
+ return withDowngrade({
983
+ ...base,
984
+ moduleId: moduleId2,
985
+ txnId: txnId2,
986
+ txnSeq: txnSeq2,
987
+ kind: opKind,
988
+ label,
989
+ meta: metaProjection2.value
990
+ });
991
+ }
992
+ const metaProjection = projectJsonValue(
993
+ isLightLike ? {
994
+ data: void 0
995
+ } : {
996
+ data: event.data
997
+ }
998
+ );
999
+ options?.onMetaProjection?.({
1000
+ stats: metaProjection.stats,
1001
+ downgrade: metaProjection.downgrade
1002
+ });
1003
+ downgrade = mergeDowngrade(downgrade, metaProjection.downgrade);
1004
+ return withDowngrade({
1005
+ ...base,
1006
+ kind: "devtools",
1007
+ label: event.type,
1008
+ meta: metaProjection.value
1009
+ });
1010
+ }
1011
+ }
1012
+ };
1013
+
1014
+ export {
1015
+ toSerializableErrorSummary,
1016
+ currentDebugSinks,
1017
+ currentRuntimeLabel,
1018
+ currentTxnId,
1019
+ currentOpSeq,
1020
+ currentDiagnosticsLevel,
1021
+ diagnosticsLevel,
1022
+ currentTraitConvergeDiagnosticsSampling,
1023
+ traitConvergeDiagnosticsSampling,
1024
+ appendSinks,
1025
+ clearRuntimeDebugEventSeq,
1026
+ noopLayer,
1027
+ errorOnlyLayer,
1028
+ isErrorOnlyOnlySinks,
1029
+ browserConsoleLayer,
1030
+ browserDiagnosticConsoleLayer,
1031
+ record,
1032
+ toRuntimeDebugEventRef
1033
+ };
1034
+ //# sourceMappingURL=chunk-DMBALCE2.js.map