@blac/core 2.0.12 → 2.0.14

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 (457) hide show
  1. package/README.md +85 -3
  2. package/dist/Cubit-9jal5zdZ.cjs +1 -1
  3. package/dist/Cubit-BAUPiUF7.cjs +359 -286
  4. package/dist/Cubit-BBKF3PIg.js +287 -0
  5. package/dist/Cubit-BBKF3PIg.js.map +1 -0
  6. package/dist/Cubit-BC70gaiA.js +453 -0
  7. package/dist/Cubit-BC70gaiA.js.map +1 -0
  8. package/dist/Cubit-BOgUZva7.js +342 -266
  9. package/dist/Cubit-BOxMvpfc.js +291 -0
  10. package/dist/Cubit-BOxMvpfc.js.map +1 -0
  11. package/dist/Cubit-BTznt8zg.js +1 -1
  12. package/dist/Cubit-BogJXkLm.js +278 -0
  13. package/dist/Cubit-BogJXkLm.js.map +1 -0
  14. package/dist/Cubit-C-8R_8db.cjs +475 -0
  15. package/dist/Cubit-C-8R_8db.cjs.map +1 -0
  16. package/dist/Cubit-C3Mw3EoO.cjs +401 -0
  17. package/dist/Cubit-C3Mw3EoO.cjs.map +1 -0
  18. package/dist/Cubit-CO8Fr72L.cjs +447 -0
  19. package/dist/Cubit-CO8Fr72L.cjs.map +1 -0
  20. package/dist/Cubit-COfHT1Bm.cjs +321 -0
  21. package/dist/Cubit-COfHT1Bm.cjs.map +1 -0
  22. package/dist/Cubit-CROWjjs9.js +481 -0
  23. package/dist/Cubit-CROWjjs9.js.map +1 -0
  24. package/dist/Cubit-CWP8Ddzx.cjs +510 -0
  25. package/dist/Cubit-CWP8Ddzx.cjs.map +1 -0
  26. package/dist/Cubit-CXxh9iol.js +302 -0
  27. package/dist/Cubit-CXxh9iol.js.map +1 -0
  28. package/dist/Cubit-CYOWfzQt.cjs +317 -0
  29. package/dist/Cubit-CYOWfzQt.cjs.map +1 -0
  30. package/dist/Cubit-CZaf_fp4.cjs +1 -1
  31. package/dist/Cubit-C_dUEUdd.cjs +359 -286
  32. package/dist/Cubit-C_rxRCTN.cjs +523 -0
  33. package/dist/Cubit-C_rxRCTN.cjs.map +1 -0
  34. package/dist/Cubit-CcKgMEBO.js +299 -0
  35. package/dist/Cubit-CcKgMEBO.js.map +1 -0
  36. package/dist/Cubit-CfT6Y1jl.js +346 -0
  37. package/dist/Cubit-CfT6Y1jl.js.map +1 -0
  38. package/dist/Cubit-CynJruuO.js +369 -0
  39. package/dist/Cubit-CynJruuO.js.map +1 -0
  40. package/dist/Cubit-D2vQ6nMb.js +342 -266
  41. package/dist/Cubit-D7jOZCoZ.js +342 -266
  42. package/dist/Cubit-D9j3IGPc.cjs +523 -0
  43. package/dist/Cubit-D9j3IGPc.cjs.map +1 -0
  44. package/dist/Cubit-DKEY9WYq.cjs +296 -0
  45. package/dist/Cubit-DKEY9WYq.cjs.map +1 -0
  46. package/dist/Cubit-DMV_0TCp.js +481 -0
  47. package/dist/Cubit-DMV_0TCp.js.map +1 -0
  48. package/dist/Cubit-DP5DXPUK.js +342 -266
  49. package/dist/Cubit-DRFkzD2h.js +426 -0
  50. package/dist/Cubit-DRFkzD2h.js.map +1 -0
  51. package/dist/Cubit-DbnhTUaZ.cjs +359 -286
  52. package/dist/Cubit-DrqG3SP3.cjs +370 -0
  53. package/dist/Cubit-DrqG3SP3.cjs.map +1 -0
  54. package/dist/Cubit-DsDkCo42.cjs +313 -0
  55. package/dist/Cubit-DsDkCo42.cjs.map +1 -0
  56. package/dist/Cubit-DwRw1E9D.cjs +309 -0
  57. package/dist/Cubit-DwRw1E9D.cjs.map +1 -0
  58. package/dist/Cubit-Dw_kFBgc.js +1 -1
  59. package/dist/Cubit-KiXZCubP.cjs +1 -1
  60. package/dist/Cubit-Ksj7G4uR.js +342 -266
  61. package/dist/Cubit-MkjbpcPf.cjs +359 -286
  62. package/dist/Cubit-NRhvdDQ6.js +297 -0
  63. package/dist/Cubit-NRhvdDQ6.js.map +1 -0
  64. package/dist/Cubit-PMTXxI_u.js +1 -1
  65. package/dist/Cubit-VJuu2tt9.js +481 -0
  66. package/dist/Cubit-VJuu2tt9.js.map +1 -0
  67. package/dist/Cubit-jz922NKf.cjs +320 -0
  68. package/dist/Cubit-jz922NKf.cjs.map +1 -0
  69. package/dist/Cubit-kU5_4jgC.cjs +359 -286
  70. package/dist/StateContainerRegistry-B4yVMYbx.cjs +1057 -0
  71. package/dist/StateContainerRegistry-B4yVMYbx.cjs.map +1 -0
  72. package/dist/StateContainerRegistry-BAcxouCu.js +723 -0
  73. package/dist/StateContainerRegistry-BAcxouCu.js.map +1 -0
  74. package/dist/StateContainerRegistry-BK57H92E.js +747 -0
  75. package/dist/StateContainerRegistry-BK57H92E.js.map +1 -0
  76. package/dist/StateContainerRegistry-BRBATSrx.cjs +1030 -0
  77. package/dist/StateContainerRegistry-BRBATSrx.cjs.map +1 -0
  78. package/dist/StateContainerRegistry-BgBIKcQF.js +956 -0
  79. package/dist/StateContainerRegistry-BgBIKcQF.js.map +1 -0
  80. package/dist/StateContainerRegistry-BglEhqdA.js +709 -0
  81. package/dist/StateContainerRegistry-BglEhqdA.js.map +1 -0
  82. package/dist/StateContainerRegistry-BhcnG0DF.js +625 -562
  83. package/dist/StateContainerRegistry-BpO5t-0i.js +682 -0
  84. package/dist/StateContainerRegistry-BpO5t-0i.js.map +1 -0
  85. package/dist/StateContainerRegistry-BqS-wpb_.js +957 -0
  86. package/dist/StateContainerRegistry-BqS-wpb_.js.map +1 -0
  87. package/dist/StateContainerRegistry-BrEGYPZT.cjs +1029 -0
  88. package/dist/StateContainerRegistry-BrEGYPZT.cjs.map +1 -0
  89. package/dist/StateContainerRegistry-Bxfne4A7.cjs +908 -0
  90. package/dist/StateContainerRegistry-Bxfne4A7.cjs.map +1 -0
  91. package/dist/StateContainerRegistry-C0E7vsgy.js +758 -0
  92. package/dist/StateContainerRegistry-C0E7vsgy.js.map +1 -0
  93. package/dist/StateContainerRegistry-C0I77Ndz.cjs +920 -0
  94. package/dist/StateContainerRegistry-C0I77Ndz.cjs.map +1 -0
  95. package/dist/StateContainerRegistry-CDH9mnQS.cjs +715 -0
  96. package/dist/StateContainerRegistry-CDH9mnQS.cjs.map +1 -0
  97. package/dist/StateContainerRegistry-CTOXUf75.cjs +742 -0
  98. package/dist/StateContainerRegistry-CTOXUf75.cjs.map +1 -0
  99. package/dist/StateContainerRegistry-CX2CBOmv.cjs +795 -0
  100. package/dist/StateContainerRegistry-CX2CBOmv.cjs.map +1 -0
  101. package/dist/StateContainerRegistry-CXnnf2-l.js +867 -0
  102. package/dist/StateContainerRegistry-CXnnf2-l.js.map +1 -0
  103. package/dist/StateContainerRegistry-CehuIpK_.cjs +811 -0
  104. package/dist/StateContainerRegistry-CehuIpK_.cjs.map +1 -0
  105. package/dist/StateContainerRegistry-Ci0ajc5g.js +720 -0
  106. package/dist/StateContainerRegistry-Ci0ajc5g.js.map +1 -0
  107. package/dist/StateContainerRegistry-Ck2-XmT_.js +587 -527
  108. package/dist/StateContainerRegistry-D1lVJFGL.cjs +753 -0
  109. package/dist/StateContainerRegistry-D1lVJFGL.cjs.map +1 -0
  110. package/dist/StateContainerRegistry-DC4N73O6.js +632 -569
  111. package/dist/StateContainerRegistry-DOuGI-l5.js +645 -582
  112. package/dist/StateContainerRegistry-DT66lr3I.cjs +651 -596
  113. package/dist/StateContainerRegistry-DmmzYa7S.js +974 -0
  114. package/dist/StateContainerRegistry-DmmzYa7S.js.map +1 -0
  115. package/dist/StateContainerRegistry-Upsrlg9G.cjs +756 -0
  116. package/dist/StateContainerRegistry-Upsrlg9G.cjs.map +1 -0
  117. package/dist/StateContainerRegistry-WznfcA-Q.js +855 -0
  118. package/dist/StateContainerRegistry-WznfcA-Q.js.map +1 -0
  119. package/dist/StateContainerRegistry-Yph6UCA_.js +637 -569
  120. package/dist/StateContainerRegistry-mseeTqSA.cjs +671 -616
  121. package/dist/StateContainerRegistry-pRNxHNFD.cjs +658 -603
  122. package/dist/StateContainerRegistry-vXMWtG7J.cjs +613 -561
  123. package/dist/StateContainerRegistry-v_prqMcI.cjs +663 -603
  124. package/dist/branded-BSeA_mZO.cjs.map +1 -1
  125. package/dist/branded-DCqi3De1.cjs +11 -11
  126. package/dist/branded-DwtzSsg0.js.map +1 -1
  127. package/dist/branded-Max3xOTA.js +6 -6
  128. package/dist/config-0ZD9i3wy.js +16 -0
  129. package/dist/config-0ZD9i3wy.js.map +1 -0
  130. package/dist/config-B3NIwDQv.cjs +32 -0
  131. package/dist/config-B3NIwDQv.cjs.map +1 -0
  132. package/dist/config-BKGHop0V.js +16 -0
  133. package/dist/config-BKGHop0V.js.map +1 -0
  134. package/dist/config-BKoaAlmb.js +5 -5
  135. package/dist/config-BPj08-8h.cjs +32 -0
  136. package/dist/config-BPj08-8h.cjs.map +1 -0
  137. package/dist/config-BR0Xy-Tn.cjs +32 -0
  138. package/dist/config-BR0Xy-Tn.cjs.map +1 -0
  139. package/dist/config-B_4xXpvK.cjs +32 -0
  140. package/dist/config-B_4xXpvK.cjs.map +1 -0
  141. package/dist/config-BflrQM4_.cjs +32 -0
  142. package/dist/config-BflrQM4_.cjs.map +1 -0
  143. package/dist/config-BzObBsk2.cjs +32 -0
  144. package/dist/config-BzObBsk2.cjs.map +1 -0
  145. package/dist/config-C0yumL1H.cjs +32 -0
  146. package/dist/config-C0yumL1H.cjs.map +1 -0
  147. package/dist/config-C8xqVHTf.js +16 -0
  148. package/dist/config-C8xqVHTf.js.map +1 -0
  149. package/dist/config-CCUhIYIF.js +5 -5
  150. package/dist/config-CGo__MAt.js +16 -0
  151. package/dist/config-CGo__MAt.js.map +1 -0
  152. package/dist/config-CQH9fTY-.cjs +32 -0
  153. package/dist/config-CQH9fTY-.cjs.map +1 -0
  154. package/dist/config-CR_Bz7RD.js +5 -5
  155. package/dist/config-CTOa-yPN.cjs +20 -20
  156. package/dist/config-Cd7Q-B4g.js +16 -0
  157. package/dist/config-Cd7Q-B4g.js.map +1 -0
  158. package/dist/config-CmDEX-1o.js +16 -0
  159. package/dist/config-CmDEX-1o.js.map +1 -0
  160. package/dist/config-CoNMTnMA.cjs +32 -0
  161. package/dist/config-CoNMTnMA.cjs.map +1 -0
  162. package/dist/config-Cwj8-C1J.js +16 -0
  163. package/dist/config-Cwj8-C1J.js.map +1 -0
  164. package/dist/config-D3jisfdj.cjs +20 -20
  165. package/dist/config-D4GifZQ4.js +5 -5
  166. package/dist/config-DDrSQGpQ.cjs +20 -20
  167. package/dist/config-DEcslxan.cjs +32 -0
  168. package/dist/config-DEcslxan.cjs.map +1 -0
  169. package/dist/config-DMNZ2YLV.cjs +20 -20
  170. package/dist/config-De9oQ6Ki.js +16 -0
  171. package/dist/config-De9oQ6Ki.js.map +1 -0
  172. package/dist/config-DoHx0Xsl.js +16 -0
  173. package/dist/config-DoHx0Xsl.js.map +1 -0
  174. package/dist/config-DokTzpr8.cjs +20 -20
  175. package/dist/config-DslYBm4Z.js +5 -5
  176. package/dist/config-H6FAqbW4.cjs +32 -0
  177. package/dist/config-H6FAqbW4.cjs.map +1 -0
  178. package/dist/config-Yp645dGK.js +16 -0
  179. package/dist/config-Yp645dGK.js.map +1 -0
  180. package/dist/config-ispAzOZV.js +16 -0
  181. package/dist/config-ispAzOZV.js.map +1 -0
  182. package/dist/config.d.cts +72 -0
  183. package/dist/config.d.ts +72 -0
  184. package/dist/constants.d.cts +18 -28
  185. package/dist/constants.d.ts +18 -28
  186. package/dist/core/Cubit.d.ts +14 -5
  187. package/dist/core/StateContainer.d.ts +112 -15
  188. package/dist/core/StateContainerRegistry.d.ts +66 -7
  189. package/dist/core/symbols.d.ts +26 -1
  190. package/dist/debug.cjs +3 -3
  191. package/dist/debug.js +3 -3
  192. package/dist/decorators/blac.d.ts +17 -0
  193. package/dist/ensure-9VEq5H0L.js +3 -3
  194. package/dist/ensure-BB6xHQAF.cjs +14 -0
  195. package/dist/ensure-BB6xHQAF.cjs.map +1 -0
  196. package/dist/ensure-BNDfTzqg.cjs +8 -8
  197. package/dist/ensure-BVCnjU7r.js +343 -267
  198. package/dist/ensure-BbzGXjep.cjs +8 -8
  199. package/dist/ensure-BlIaQai6.js +9 -0
  200. package/dist/ensure-BlIaQai6.js.map +1 -0
  201. package/dist/ensure-Bm3oHxga.js +9 -0
  202. package/dist/ensure-Bm3oHxga.js.map +1 -0
  203. package/dist/ensure-C3eIRs6e.cjs +14 -0
  204. package/dist/ensure-C3eIRs6e.cjs.map +1 -0
  205. package/dist/ensure-CJZL7bcA.cjs +365 -292
  206. package/dist/ensure-CN6unBOe.cjs +14 -0
  207. package/dist/ensure-CN6unBOe.cjs.map +1 -0
  208. package/dist/ensure-CU-B1ywv.js +3 -3
  209. package/dist/ensure-CWKzeno7.js +9 -0
  210. package/dist/ensure-CWKzeno7.js.map +1 -0
  211. package/dist/ensure-CkENsuQ9.js +9 -0
  212. package/dist/ensure-CkENsuQ9.js.map +1 -0
  213. package/dist/ensure-Cm-4_LSh.cjs +14 -0
  214. package/dist/ensure-Cm-4_LSh.cjs.map +1 -0
  215. package/dist/ensure-Cqex5r1P.cjs +14 -0
  216. package/dist/ensure-Cqex5r1P.cjs.map +1 -0
  217. package/dist/ensure-Cv5AbNGZ.js +9 -0
  218. package/dist/ensure-Cv5AbNGZ.js.map +1 -0
  219. package/dist/ensure-D63lEMUK.cjs +8 -8
  220. package/dist/ensure-DGEtPU9A.cjs +14 -0
  221. package/dist/ensure-DGEtPU9A.cjs.map +1 -0
  222. package/dist/ensure-DM3qb336.cjs +14 -0
  223. package/dist/ensure-DM3qb336.cjs.map +1 -0
  224. package/dist/ensure-DME-_T0j.cjs +14 -0
  225. package/dist/ensure-DME-_T0j.cjs.map +1 -0
  226. package/dist/ensure-DWd0GCYB.js +9 -0
  227. package/dist/ensure-DWd0GCYB.js.map +1 -0
  228. package/dist/ensure-DamKOP6q.cjs +8 -8
  229. package/dist/ensure-Dcfptl-A.js +9 -0
  230. package/dist/ensure-Dcfptl-A.js.map +1 -0
  231. package/dist/ensure-Def-EBWG.js +3 -3
  232. package/dist/ensure-DnHL5QiQ.cjs +14 -0
  233. package/dist/ensure-DnHL5QiQ.cjs.map +1 -0
  234. package/dist/ensure-Dr7I78Ku.cjs +14 -0
  235. package/dist/ensure-Dr7I78Ku.cjs.map +1 -0
  236. package/dist/ensure-SLVdGd5b.js +9 -0
  237. package/dist/ensure-SLVdGd5b.js.map +1 -0
  238. package/dist/ensure-Sb92MCXu.js +3 -3
  239. package/dist/ensure-gFlvevGm.cjs +14 -0
  240. package/dist/ensure-gFlvevGm.cjs.map +1 -0
  241. package/dist/ensure-l2-H7S5W.js +9 -0
  242. package/dist/ensure-l2-H7S5W.js.map +1 -0
  243. package/dist/ensure-mkL-3qh8.js +9 -0
  244. package/dist/ensure-mkL-3qh8.js.map +1 -0
  245. package/dist/ensure-n80crSlX.js +3 -3
  246. package/dist/ensure-nCxg7MCN.js +9 -0
  247. package/dist/ensure-nCxg7MCN.js.map +1 -0
  248. package/dist/ensure-vS71MV4q.cjs +8 -8
  249. package/dist/index.cjs +40 -15
  250. package/dist/index.cjs.map +1 -1
  251. package/dist/index.d.cts +15 -4
  252. package/dist/index.d.ts +15 -4
  253. package/dist/index.js +23 -10
  254. package/dist/index.js.map +1 -1
  255. package/dist/management-6oQbmf0z.js +41 -0
  256. package/dist/management-6oQbmf0z.js.map +1 -0
  257. package/dist/management-B46QwA9Y.js +41 -0
  258. package/dist/management-B46QwA9Y.js.map +1 -0
  259. package/dist/management-B9yrRpeg.js +41 -0
  260. package/dist/management-B9yrRpeg.js.map +1 -0
  261. package/dist/management-BCKTEZ8Q.js +41 -0
  262. package/dist/management-BCKTEZ8Q.js.map +1 -0
  263. package/dist/management-BbMzdXbT.js +41 -0
  264. package/dist/management-BbMzdXbT.js.map +1 -0
  265. package/dist/management-Bg652agq.js +20 -11
  266. package/dist/management-BnedF5ZD.cjs +79 -0
  267. package/dist/management-BnedF5ZD.cjs.map +1 -0
  268. package/dist/management-BoUa99eB.cjs +79 -0
  269. package/dist/management-BoUa99eB.cjs.map +1 -0
  270. package/dist/management-C4SHcrJm.cjs +79 -0
  271. package/dist/management-C4SHcrJm.cjs.map +1 -0
  272. package/dist/management-CK-GL3wY.js +41 -0
  273. package/dist/management-CK-GL3wY.js.map +1 -0
  274. package/dist/management-CPhgY8OE.js +41 -0
  275. package/dist/management-CPhgY8OE.js.map +1 -0
  276. package/dist/management-CU_V3LIP.js +20 -11
  277. package/dist/management-CUwXDSi9.cjs +79 -0
  278. package/dist/management-CUwXDSi9.cjs.map +1 -0
  279. package/dist/management-CaqiyNzB.js +20 -11
  280. package/dist/management-Cin-JvYe.js +20 -11
  281. package/dist/management-ClaXym0F.cjs +50 -50
  282. package/dist/management-DL0Uzsoz.js +41 -0
  283. package/dist/management-DL0Uzsoz.js.map +1 -0
  284. package/dist/management-DLdAQfqk.cjs +79 -0
  285. package/dist/management-DLdAQfqk.cjs.map +1 -0
  286. package/dist/management-DMZ8qpwr.cjs +79 -0
  287. package/dist/management-DMZ8qpwr.cjs.map +1 -0
  288. package/dist/management-DTzcC6aD.cjs +79 -0
  289. package/dist/management-DTzcC6aD.cjs.map +1 -0
  290. package/dist/management-DYLNyj9p.cjs +79 -0
  291. package/dist/management-DYLNyj9p.cjs.map +1 -0
  292. package/dist/management-Dag9u4t6.cjs +50 -50
  293. package/dist/management-DbMRdDBo.cjs +50 -50
  294. package/dist/management-DfnDAKmP.js +41 -0
  295. package/dist/management-DfnDAKmP.js.map +1 -0
  296. package/dist/management-DjBU1gtb.cjs +79 -0
  297. package/dist/management-DjBU1gtb.cjs.map +1 -0
  298. package/dist/management-DwCozsY8.js +41 -0
  299. package/dist/management-DwCozsY8.js.map +1 -0
  300. package/dist/management-H4m3ciJO.js +32 -0
  301. package/dist/management-H4m3ciJO.js.map +1 -0
  302. package/dist/management-Xo3A6Za3.cjs +79 -0
  303. package/dist/management-Xo3A6Za3.cjs.map +1 -0
  304. package/dist/management-ZU2YzOkr.js +18 -10
  305. package/dist/management-baPDwA9n.cjs +50 -50
  306. package/dist/management-jQGCvZNN.cjs +44 -44
  307. package/dist/management-ry_KteFK.cjs +79 -0
  308. package/dist/management-ry_KteFK.cjs.map +1 -0
  309. package/dist/plugin/BlacPlugin.d.ts +70 -100
  310. package/dist/plugin/PluginManager.d.ts +67 -5
  311. package/dist/plugins.cjs +1 -1
  312. package/dist/plugins.d.cts +2 -2
  313. package/dist/plugins.d.ts +2 -2
  314. package/dist/plugins.js +1 -1
  315. package/dist/registry/acquire.d.ts +9 -2
  316. package/dist/registry/ensure.d.ts +2 -2
  317. package/dist/registry/index.d.ts +1 -1
  318. package/dist/resolve-dependencies-B2QggQAi.js +729 -0
  319. package/dist/resolve-dependencies-B2QggQAi.js.map +1 -0
  320. package/dist/resolve-dependencies-B6JDXvpr.js +739 -0
  321. package/dist/resolve-dependencies-B6JDXvpr.js.map +1 -0
  322. package/dist/resolve-dependencies-BAKAoD0U.js +878 -0
  323. package/dist/resolve-dependencies-BAKAoD0U.js.map +1 -0
  324. package/dist/resolve-dependencies-BFZQq60Y.cjs +724 -666
  325. package/dist/resolve-dependencies-BGafS3Ww.js +643 -561
  326. package/dist/resolve-dependencies-BHd34gS3.cjs +724 -666
  327. package/dist/resolve-dependencies-BNeayhbQ.cjs +840 -0
  328. package/dist/resolve-dependencies-BNeayhbQ.cjs.map +1 -0
  329. package/dist/resolve-dependencies-BWEMpuDy.js +729 -0
  330. package/dist/resolve-dependencies-BWEMpuDy.js.map +1 -0
  331. package/dist/resolve-dependencies-BiWkW2eS.js +643 -561
  332. package/dist/resolve-dependencies-BjxCztYD.js +739 -0
  333. package/dist/resolve-dependencies-BjxCztYD.js.map +1 -0
  334. package/dist/resolve-dependencies-BlyBV0hB.cjs +969 -0
  335. package/dist/resolve-dependencies-BlyBV0hB.cjs.map +1 -0
  336. package/dist/resolve-dependencies-By26rT_i.js +739 -0
  337. package/dist/resolve-dependencies-By26rT_i.js.map +1 -0
  338. package/dist/resolve-dependencies-C9Kf7AzY.cjs +832 -0
  339. package/dist/resolve-dependencies-C9Kf7AzY.cjs.map +1 -0
  340. package/dist/resolve-dependencies-CTzV1txG.js +643 -561
  341. package/dist/resolve-dependencies-CWjuGHiF.cjs +969 -0
  342. package/dist/resolve-dependencies-CWjuGHiF.cjs.map +1 -0
  343. package/dist/resolve-dependencies-ClSsP0DJ.cjs +830 -0
  344. package/dist/resolve-dependencies-ClSsP0DJ.cjs.map +1 -0
  345. package/dist/resolve-dependencies-D0vTzZgs.js +643 -561
  346. package/dist/resolve-dependencies-D2WnZMF-.cjs +724 -666
  347. package/dist/resolve-dependencies-DCBLTeza.cjs +969 -0
  348. package/dist/resolve-dependencies-DCBLTeza.cjs.map +1 -0
  349. package/dist/resolve-dependencies-DMlqYJR2.js +731 -0
  350. package/dist/resolve-dependencies-DMlqYJR2.js.map +1 -0
  351. package/dist/resolve-dependencies-DP6U1EYB.cjs +840 -0
  352. package/dist/resolve-dependencies-DP6U1EYB.cjs.map +1 -0
  353. package/dist/resolve-dependencies-DSQNXvnV.cjs +724 -666
  354. package/dist/resolve-dependencies-DV3HO_uH.js +878 -0
  355. package/dist/resolve-dependencies-DV3HO_uH.js.map +1 -0
  356. package/dist/resolve-dependencies-DXwMhP0Y.js +878 -0
  357. package/dist/resolve-dependencies-DXwMhP0Y.js.map +1 -0
  358. package/dist/resolve-dependencies-DbRWlt9u.js +878 -0
  359. package/dist/resolve-dependencies-DbRWlt9u.js.map +1 -0
  360. package/dist/resolve-dependencies-DcUUva2P.cjs +724 -666
  361. package/dist/resolve-dependencies-Dd8T6TLt.cjs +832 -0
  362. package/dist/resolve-dependencies-Dd8T6TLt.cjs.map +1 -0
  363. package/dist/resolve-dependencies-Dfdp_DZd.cjs +840 -0
  364. package/dist/resolve-dependencies-Dfdp_DZd.cjs.map +1 -0
  365. package/dist/resolve-dependencies-GJ8PNyNB.cjs +969 -0
  366. package/dist/resolve-dependencies-GJ8PNyNB.cjs.map +1 -0
  367. package/dist/resolve-dependencies-KSpTt4jy.cjs +830 -0
  368. package/dist/resolve-dependencies-KSpTt4jy.cjs.map +1 -0
  369. package/dist/resolve-dependencies-Nvjp4CwS.js +731 -0
  370. package/dist/resolve-dependencies-Nvjp4CwS.js.map +1 -0
  371. package/dist/resolve-dependencies-f-QUqYiL.js +643 -561
  372. package/dist/testing.cjs +27 -20
  373. package/dist/testing.cjs.map +1 -1
  374. package/dist/testing.d.cts +22 -1
  375. package/dist/testing.d.ts +22 -1
  376. package/dist/testing.js +27 -21
  377. package/dist/testing.js.map +1 -1
  378. package/dist/tracked-B77j2g9M.js +171 -151
  379. package/dist/tracked-BDVi2LKM.cjs +196 -175
  380. package/dist/tracked-BFdJCzL0.cjs +242 -0
  381. package/dist/tracked-BFdJCzL0.cjs.map +1 -0
  382. package/dist/tracked-BH-gX4T1.cjs +196 -175
  383. package/dist/tracked-BTHok3Dl.cjs +196 -175
  384. package/dist/tracked-BTbFkFeM.js +212 -0
  385. package/dist/tracked-BTbFkFeM.js.map +1 -0
  386. package/dist/tracked-BU_OBWqM.cjs +242 -0
  387. package/dist/tracked-BU_OBWqM.cjs.map +1 -0
  388. package/dist/tracked-BfctH2es.cjs +242 -0
  389. package/dist/tracked-BfctH2es.cjs.map +1 -0
  390. package/dist/tracked-BhQtzUhZ.js +212 -0
  391. package/dist/tracked-BhQtzUhZ.js.map +1 -0
  392. package/dist/tracked-BnqrYXiO.js +212 -0
  393. package/dist/tracked-BnqrYXiO.js.map +1 -0
  394. package/dist/tracked-BtgFOGup.js +212 -0
  395. package/dist/tracked-BtgFOGup.js.map +1 -0
  396. package/dist/tracked-C3nIS4J7.cjs +242 -0
  397. package/dist/tracked-C3nIS4J7.cjs.map +1 -0
  398. package/dist/tracked-C52awNV9.js +197 -0
  399. package/dist/tracked-C52awNV9.js.map +1 -0
  400. package/dist/tracked-CGzduF2m.js +212 -0
  401. package/dist/tracked-CGzduF2m.js.map +1 -0
  402. package/dist/tracked-CK_-ixtX.cjs +227 -0
  403. package/dist/tracked-CK_-ixtX.cjs.map +1 -0
  404. package/dist/tracked-CLlvURln.js +212 -0
  405. package/dist/tracked-CLlvURln.js.map +1 -0
  406. package/dist/tracked-CgHWmuGC.cjs +242 -0
  407. package/dist/tracked-CgHWmuGC.cjs.map +1 -0
  408. package/dist/tracked-CoAlC8fs.js +171 -151
  409. package/dist/tracked-D3Xjm1H1.cjs +242 -0
  410. package/dist/tracked-D3Xjm1H1.cjs.map +1 -0
  411. package/dist/tracked-DB6yMV5F.js +212 -0
  412. package/dist/tracked-DB6yMV5F.js.map +1 -0
  413. package/dist/tracked-DBn-bs_G.js +171 -151
  414. package/dist/tracked-DMBTDF0P.js +171 -151
  415. package/dist/tracked-DN3h3Rp1.js +197 -0
  416. package/dist/tracked-DN3h3Rp1.js.map +1 -0
  417. package/dist/tracked-DOGh1Q5Z.cjs +242 -0
  418. package/dist/tracked-DOGh1Q5Z.cjs.map +1 -0
  419. package/dist/tracked-DUkp4zve.cjs +227 -0
  420. package/dist/tracked-DUkp4zve.cjs.map +1 -0
  421. package/dist/tracked-D_ou7mYG.js +212 -0
  422. package/dist/tracked-D_ou7mYG.js.map +1 -0
  423. package/dist/tracked-Dcu6EATB.js +171 -151
  424. package/dist/tracked-GvAJQVAI.cjs +227 -196
  425. package/dist/tracked-O2lv-kJV.cjs +242 -0
  426. package/dist/tracked-O2lv-kJV.cjs.map +1 -0
  427. package/dist/tracked-WF6aXuAo.js +186 -162
  428. package/dist/tracked-d_sQWU3c.cjs +196 -175
  429. package/dist/tracked-n9TMK-30.cjs +196 -175
  430. package/dist/tracked-njU-_pVa.cjs +242 -0
  431. package/dist/tracked-njU-_pVa.cjs.map +1 -0
  432. package/dist/tracked-zAgmKIlC.js +212 -0
  433. package/dist/tracked-zAgmKIlC.js.map +1 -0
  434. package/dist/tracking/dependency-manager.d.ts +33 -29
  435. package/dist/tracking/index.d.ts +16 -1
  436. package/dist/tracking/iteration-perf.bench.d.ts +1 -0
  437. package/dist/tracking/path-utils.d.ts +18 -1
  438. package/dist/tracking/resolve-dependencies.d.ts +3 -1
  439. package/dist/tracking/tracked.d.ts +37 -34
  440. package/dist/tracking/tracking-proxy.d.ts +94 -47
  441. package/dist/tracking.cjs +12 -9
  442. package/dist/tracking.js +32 -2
  443. package/dist/types/utilities.d.ts +15 -3
  444. package/dist/types.cjs +1 -1
  445. package/dist/types.js +1 -1
  446. package/dist/utils/static-props.d.ts +23 -0
  447. package/dist/utils/structural-key.d.ts +14 -0
  448. package/dist/watch/watch.d.ts +1 -1
  449. package/dist/watch-BpwaUL8r.cjs +68 -0
  450. package/dist/watch-BpwaUL8r.cjs.map +1 -0
  451. package/dist/watch-DWCqXllW.js +57 -0
  452. package/dist/watch-DWCqXllW.js.map +1 -0
  453. package/dist/watch-entry.cjs +3 -6
  454. package/dist/watch-entry.d.cts +1 -3
  455. package/dist/watch-entry.d.ts +1 -3
  456. package/dist/watch-entry.js +2 -2
  457. package/package.json +4 -14
@@ -1,622 +1,685 @@
1
1
  //#region src/constants.ts
2
2
  /**
3
- * Default configuration constants for BlaC
4
- *
5
- * Centralized location for all magic numbers and default values.
6
- */
3
+ * Default configuration constants for BlaC
4
+ *
5
+ * Centralized location for all magic numbers and default values.
6
+ */
7
7
  /**
8
- * Default configuration constants for BlaC
9
- */
8
+ * Default configuration constants for BlaC
9
+ */
10
10
  const BLAC_DEFAULTS = {
11
- DEFAULT_INSTANCE_KEY: "default",
12
- MAX_GETTER_DEPTH: 10,
13
- CLEANUP_INTERVAL_MS: 3e4,
14
- WEAKREF_CLEANUP_INTERVAL_MS: 1e4,
15
- MAX_SUBSCRIPTIONS: 1e3,
16
- MAX_SUBSCRIPTIONS_HIGH_PERF: 1e4,
17
- PIPELINE_TIMEOUT_MS: 5e3,
18
- CLEANUP_INTERVAL_HIGH_PERF_MS: 5e3,
19
- MAX_PIPELINE_STAGES: 30
11
+ DEFAULT_INSTANCE_KEY: 'default',
12
+ MAX_GETTER_DEPTH: 10,
13
+ CLEANUP_INTERVAL_MS: 3e4,
14
+ WEAKREF_CLEANUP_INTERVAL_MS: 1e4,
15
+ MAX_SUBSCRIPTIONS: 1e3,
16
+ MAX_SUBSCRIPTIONS_HIGH_PERF: 1e4,
17
+ PIPELINE_TIMEOUT_MS: 5e3,
18
+ CLEANUP_INTERVAL_HIGH_PERF_MS: 5e3,
19
+ MAX_PIPELINE_STAGES: 30,
20
20
  };
21
21
  /**
22
- * Static property names for StateContainer classes
23
- * Used for feature flags and configuration on bloc classes
24
- */
22
+ * Static property names for StateContainer classes
23
+ * Used for feature flags and configuration on bloc classes
24
+ */
25
25
  const BLAC_STATIC_PROPS = {
26
- KEEP_ALIVE: "keepAlive",
27
- EXCLUDE_FROM_DEVTOOLS: "__excludeFromDevTools"
26
+ KEEP_ALIVE: 'keepAlive',
27
+ EXCLUDE_FROM_DEVTOOLS: '__excludeFromDevTools',
28
28
  };
29
29
  /**
30
- * Standard error message prefix
31
- */
32
- const BLAC_ERROR_PREFIX = "[BlaC]";
30
+ * Standard error message prefix
31
+ */
32
+ const BLAC_ERROR_PREFIX = '[BlaC]';
33
33
  //#endregion
34
34
  //#region src/plugin/PluginManager.ts
35
35
  /**
36
- * Manages plugin lifecycle for the BlaC state management system.
37
- * Plugins receive notifications about state container lifecycle events.
38
- *
39
- * @example
40
- * ```ts
41
- * const manager = createPluginManager(registry);
42
- * manager.install(myPlugin, { environment: 'development' });
43
- * ```
44
- */
36
+ * Manages plugin lifecycle for the BlaC state management system.
37
+ * Plugins receive notifications about state container lifecycle events.
38
+ *
39
+ * @example
40
+ * ```ts
41
+ * const manager = createPluginManager(registry);
42
+ * manager.install(myPlugin, { environment: 'development' });
43
+ * ```
44
+ */
45
45
  var PluginManager = class {
46
- /**
47
- * Create a new PluginManager
48
- * @param registry - The StateContainerRegistry to monitor for lifecycle events
49
- */
50
- constructor(registry) {
51
- this.plugins = /* @__PURE__ */ new Map();
52
- this.registry = registry;
53
- this.setupLifecycleHooks();
54
- }
55
- /**
56
- * Install a plugin with optional configuration
57
- * @param plugin - The plugin to install
58
- * @param config - Optional plugin configuration
59
- * @throws Error if plugin is already installed
60
- */
61
- install(plugin, config = {}) {
62
- const effectiveConfig = {
63
- enabled: true,
64
- environment: "all",
65
- ...config
66
- };
67
- if (!this.shouldEnablePlugin(effectiveConfig)) {
68
- console.log(`[BlaC] Plugin "${plugin.name}" skipped (environment mismatch)`);
69
- return;
70
- }
71
- if (this.plugins.has(plugin.name)) throw new Error(`Plugin "${plugin.name}" is already installed`);
72
- const context = this.createPluginContext();
73
- this.plugins.set(plugin.name, {
74
- plugin,
75
- config: effectiveConfig,
76
- context
77
- });
78
- if (plugin.onInstall) try {
79
- plugin.onInstall(context);
80
- } catch (error) {
81
- console.error(`[BlaC] Error installing plugin "${plugin.name}":`, error);
82
- this.plugins.delete(plugin.name);
83
- throw error;
84
- }
85
- console.log(`[BlaC] Plugin "${plugin.name}" v${plugin.version} installed`);
86
- }
87
- /**
88
- * Uninstall a plugin by name
89
- * @param pluginName - The name of the plugin to uninstall
90
- * @throws Error if plugin is not installed
91
- */
92
- uninstall(pluginName) {
93
- const installed = this.plugins.get(pluginName);
94
- if (!installed) throw new Error(`Plugin "${pluginName}" is not installed`);
95
- if (installed.plugin.onUninstall) try {
96
- installed.plugin.onUninstall();
97
- } catch (error) {
98
- console.error(`[BlaC] Error uninstalling plugin "${pluginName}":`, error);
99
- }
100
- this.plugins.delete(pluginName);
101
- console.log(`[BlaC] Plugin "${pluginName}" uninstalled`);
102
- }
103
- /**
104
- * Get an installed plugin by name
105
- * @param pluginName - The name of the plugin to retrieve
106
- * @returns The plugin instance or undefined if not found
107
- */
108
- getPlugin(pluginName) {
109
- return this.plugins.get(pluginName)?.plugin;
110
- }
111
- /**
112
- * Get all installed plugins
113
- * @returns Array of all installed plugins
114
- */
115
- getAllPlugins() {
116
- return Array.from(this.plugins.values()).map((p) => p.plugin);
117
- }
118
- /**
119
- * Check if a plugin is installed
120
- * @param pluginName - The name of the plugin to check
121
- * @returns true if the plugin is installed
122
- */
123
- hasPlugin(pluginName) {
124
- return this.plugins.has(pluginName);
125
- }
126
- /**
127
- * Uninstall all plugins
128
- */
129
- clear() {
130
- for (const name of this.plugins.keys()) this.uninstall(name);
131
- }
132
- /**
133
- * Setup lifecycle hooks to notify plugins
134
- */
135
- setupLifecycleHooks() {
136
- this.registry.on("created", (instance) => {
137
- this.notifyPlugins("onInstanceCreated", instance);
138
- });
139
- this.registry.on("stateChanged", (instance, previousState, currentState, callstack) => {
140
- this.notifyPlugins("onStateChanged", instance, previousState, currentState, callstack);
141
- });
142
- this.registry.on("disposed", (instance) => {
143
- this.notifyPlugins("onInstanceDisposed", instance);
144
- });
145
- this.registry.on("refAcquired", (instance, refId) => {
146
- this.notifyPlugins("onRefAcquired", instance, refId);
147
- });
148
- this.registry.on("refReleased", (instance, refId) => {
149
- this.notifyPlugins("onRefReleased", instance, refId);
150
- });
151
- }
152
- /**
153
- * Notify all plugins of a lifecycle event
154
- */
155
- notifyPlugins(hookName, ...args) {
156
- for (const { plugin, config, context } of this.plugins.values()) {
157
- if (!config.enabled) continue;
158
- const hook = plugin[hookName];
159
- if (typeof hook === "function") try {
160
- hook.apply(plugin, [...args, context]);
161
- } catch (error) {
162
- console.error(`[BlaC] Error in plugin "${plugin.name}" ${hookName}:`, error);
163
- }
164
- }
165
- }
166
- /**
167
- * Create plugin context with safe API access
168
- */
169
- createPluginContext() {
170
- return {
171
- getInstanceMetadata: (instance) => {
172
- return {
173
- id: instance.instanceId,
174
- className: instance.constructor.name,
175
- isDisposed: instance.isDisposed,
176
- name: instance.name,
177
- lastStateChangeTimestamp: instance.lastUpdateTimestamp,
178
- createdAt: instance.createdAt,
179
- state: instance.state,
180
- hydrationStatus: instance.hydrationStatus,
181
- isHydrated: instance.isHydrated,
182
- hydrationError: instance.hydrationError,
183
- changedWhileHydrating: instance.changedWhileHydrating,
184
- createdFrom: instance.createdFrom || void 0
185
- };
186
- },
187
- getState: (instance) => {
188
- return instance.state;
189
- },
190
- getHydrationStatus: (instance) => {
191
- return instance.hydrationStatus;
192
- },
193
- startHydration: (instance) => {
194
- instance.beginHydration();
195
- },
196
- applyHydratedState: (instance, state) => {
197
- return instance.applyHydratedState(state);
198
- },
199
- finishHydration: (instance) => {
200
- instance.finishHydration();
201
- },
202
- failHydration: (instance, error) => {
203
- instance.failHydration(error);
204
- },
205
- waitForHydration: (instance) => {
206
- return instance.waitForHydration();
207
- },
208
- queryInstances: (typeClass) => {
209
- return this.registry.getAll(typeClass);
210
- },
211
- getAllTypes: () => {
212
- return this.registry.getTypes();
213
- },
214
- getStats: () => {
215
- return this.registry.getStats();
216
- },
217
- getRefIds: (instanceId) => {
218
- for (const Type of this.registry.getTypes()) {
219
- const map = this.registry.getInstancesMap(Type);
220
- for (const [, entry] of map) if (entry.instance.instanceId === instanceId) return Array.from(entry.refs.keys());
221
- }
222
- return [];
223
- }
224
- };
225
- }
226
- /**
227
- * Check if plugin should be enabled based on environment
228
- */
229
- shouldEnablePlugin(config) {
230
- if (!config.enabled) return false;
231
- if (config.environment === "all") return true;
232
- return this.getCurrentEnvironment() === config.environment;
233
- }
234
- /**
235
- * Get current environment
236
- */
237
- getCurrentEnvironment() {
238
- if (typeof process !== "undefined") {
239
- if (process.env.NODE_ENV === "test") return "test";
240
- if (process.env.NODE_ENV === "production") return "production";
241
- return "development";
242
- }
243
- return "development";
244
- }
46
+ /**
47
+ * Create a new PluginManager
48
+ * @param registry - The StateContainerRegistry to monitor for lifecycle events
49
+ */
50
+ constructor(registry) {
51
+ this.plugins = /* @__PURE__ */ new Map();
52
+ this.registry = registry;
53
+ this.setupLifecycleHooks();
54
+ }
55
+ /**
56
+ * Install a plugin with optional configuration
57
+ * @param plugin - The plugin to install
58
+ * @param config - Optional plugin configuration
59
+ * @throws Error if plugin is already installed
60
+ */
61
+ install(plugin, config = {}) {
62
+ const effectiveConfig = {
63
+ enabled: true,
64
+ environment: 'all',
65
+ ...config,
66
+ };
67
+ if (!this.shouldEnablePlugin(effectiveConfig)) {
68
+ console.log(
69
+ `[BlaC] Plugin "${plugin.name}" skipped (environment mismatch)`,
70
+ );
71
+ return;
72
+ }
73
+ if (this.plugins.has(plugin.name))
74
+ throw new Error(`Plugin "${plugin.name}" is already installed`);
75
+ const context = this.createPluginContext();
76
+ this.plugins.set(plugin.name, {
77
+ plugin,
78
+ config: effectiveConfig,
79
+ context,
80
+ });
81
+ if (plugin.onInstall)
82
+ try {
83
+ plugin.onInstall(context);
84
+ } catch (error) {
85
+ console.error(
86
+ `[BlaC] Error installing plugin "${plugin.name}":`,
87
+ error,
88
+ );
89
+ this.plugins.delete(plugin.name);
90
+ throw error;
91
+ }
92
+ console.log(`[BlaC] Plugin "${plugin.name}" v${plugin.version} installed`);
93
+ }
94
+ /**
95
+ * Uninstall a plugin by name
96
+ * @param pluginName - The name of the plugin to uninstall
97
+ * @throws Error if plugin is not installed
98
+ */
99
+ uninstall(pluginName) {
100
+ const installed = this.plugins.get(pluginName);
101
+ if (!installed) throw new Error(`Plugin "${pluginName}" is not installed`);
102
+ if (installed.plugin.onUninstall)
103
+ try {
104
+ installed.plugin.onUninstall();
105
+ } catch (error) {
106
+ console.error(
107
+ `[BlaC] Error uninstalling plugin "${pluginName}":`,
108
+ error,
109
+ );
110
+ }
111
+ this.plugins.delete(pluginName);
112
+ console.log(`[BlaC] Plugin "${pluginName}" uninstalled`);
113
+ }
114
+ /**
115
+ * Get an installed plugin by name
116
+ * @param pluginName - The name of the plugin to retrieve
117
+ * @returns The plugin instance or undefined if not found
118
+ */
119
+ getPlugin(pluginName) {
120
+ return this.plugins.get(pluginName)?.plugin;
121
+ }
122
+ /**
123
+ * Get all installed plugins
124
+ * @returns Array of all installed plugins
125
+ */
126
+ getAllPlugins() {
127
+ return Array.from(this.plugins.values()).map((p) => p.plugin);
128
+ }
129
+ /**
130
+ * Check if a plugin is installed
131
+ * @param pluginName - The name of the plugin to check
132
+ * @returns true if the plugin is installed
133
+ */
134
+ hasPlugin(pluginName) {
135
+ return this.plugins.has(pluginName);
136
+ }
137
+ /**
138
+ * Uninstall all plugins
139
+ */
140
+ clear() {
141
+ for (const name of this.plugins.keys()) this.uninstall(name);
142
+ }
143
+ /**
144
+ * Setup lifecycle hooks to notify plugins
145
+ */
146
+ setupLifecycleHooks() {
147
+ this.registry.on('created', (instance) => {
148
+ this.notifyPlugins('onInstanceCreated', instance);
149
+ });
150
+ this.registry.on(
151
+ 'stateChanged',
152
+ (instance, previousState, currentState, callstack) => {
153
+ this.notifyPlugins(
154
+ 'onStateChanged',
155
+ instance,
156
+ previousState,
157
+ currentState,
158
+ callstack,
159
+ );
160
+ },
161
+ );
162
+ this.registry.on('disposed', (instance) => {
163
+ this.notifyPlugins('onInstanceDisposed', instance);
164
+ });
165
+ this.registry.on('refAcquired', (instance, refId) => {
166
+ this.notifyPlugins('onRefAcquired', instance, refId);
167
+ });
168
+ this.registry.on('refReleased', (instance, refId) => {
169
+ this.notifyPlugins('onRefReleased', instance, refId);
170
+ });
171
+ }
172
+ /**
173
+ * Notify all plugins of a lifecycle event
174
+ */
175
+ notifyPlugins(hookName, ...args) {
176
+ for (const { plugin, config, context } of this.plugins.values()) {
177
+ if (!config.enabled) continue;
178
+ const hook = plugin[hookName];
179
+ if (typeof hook === 'function')
180
+ try {
181
+ hook.apply(plugin, [...args, context]);
182
+ } catch (error) {
183
+ console.error(
184
+ `[BlaC] Error in plugin "${plugin.name}" ${hookName}:`,
185
+ error,
186
+ );
187
+ }
188
+ }
189
+ }
190
+ /**
191
+ * Create plugin context with safe API access
192
+ */
193
+ createPluginContext() {
194
+ return {
195
+ getInstanceMetadata: (instance) => {
196
+ return {
197
+ id: instance.instanceId,
198
+ className: instance.constructor.name,
199
+ isDisposed: instance.isDisposed,
200
+ name: instance.name,
201
+ lastStateChangeTimestamp: instance.lastUpdateTimestamp,
202
+ createdAt: instance.createdAt,
203
+ state: instance.state,
204
+ hydrationStatus: instance.hydrationStatus,
205
+ isHydrated: instance.isHydrated,
206
+ hydrationError: instance.hydrationError,
207
+ changedWhileHydrating: instance.changedWhileHydrating,
208
+ createdFrom: instance.createdFrom || void 0,
209
+ };
210
+ },
211
+ getState: (instance) => {
212
+ return instance.state;
213
+ },
214
+ getHydrationStatus: (instance) => {
215
+ return instance.hydrationStatus;
216
+ },
217
+ startHydration: (instance) => {
218
+ instance.beginHydration();
219
+ },
220
+ applyHydratedState: (instance, state) => {
221
+ return instance.applyHydratedState(state);
222
+ },
223
+ finishHydration: (instance) => {
224
+ instance.finishHydration();
225
+ },
226
+ failHydration: (instance, error) => {
227
+ instance.failHydration(error);
228
+ },
229
+ waitForHydration: (instance) => {
230
+ return instance.waitForHydration();
231
+ },
232
+ queryInstances: (typeClass) => {
233
+ return this.registry.getAll(typeClass);
234
+ },
235
+ getAllTypes: () => {
236
+ return this.registry.getTypes();
237
+ },
238
+ getStats: () => {
239
+ return this.registry.getStats();
240
+ },
241
+ getRefIds: (instanceId) => {
242
+ for (const Type of this.registry.getTypes()) {
243
+ const map = this.registry.getInstancesMap(Type);
244
+ for (const [, entry] of map)
245
+ if (entry.instance.instanceId === instanceId)
246
+ return Array.from(entry.refs.keys());
247
+ }
248
+ return [];
249
+ },
250
+ };
251
+ }
252
+ /**
253
+ * Check if plugin should be enabled based on environment
254
+ */
255
+ shouldEnablePlugin(config) {
256
+ if (!config.enabled) return false;
257
+ if (config.environment === 'all') return true;
258
+ return this.getCurrentEnvironment() === config.environment;
259
+ }
260
+ /**
261
+ * Get current environment
262
+ */
263
+ getCurrentEnvironment() {
264
+ if (typeof process !== 'undefined') {
265
+ if (process.env.NODE_ENV === 'test') return 'test';
266
+ if (process.env.NODE_ENV === 'production') return 'production';
267
+ return 'development';
268
+ }
269
+ return 'development';
270
+ }
245
271
  };
246
272
  /**
247
- * Create a plugin manager instance
248
- * @param registry - The StateContainerRegistry to monitor for lifecycle events
249
- * @returns A new PluginManager instance
250
- */
273
+ * Create a plugin manager instance
274
+ * @param registry - The StateContainerRegistry to monitor for lifecycle events
275
+ * @returns A new PluginManager instance
276
+ */
251
277
  function createPluginManager(registry) {
252
- return new PluginManager(registry);
278
+ return new PluginManager(registry);
253
279
  }
254
280
  //#endregion
255
281
  //#region src/utils/static-props.ts
256
282
  /**
257
- * Utility functions for accessing static properties on StateContainer classes
258
- */
283
+ * Utility functions for accessing static properties on StateContainer classes
284
+ */
259
285
  /**
260
- * Get a static property from a class constructor
261
- * Type-safe helper that avoids (Type as any) casts
262
- *
263
- * @param Type - The class constructor
264
- * @param propName - The property name to access
265
- * @param defaultValue - Optional default value if property is undefined
266
- * @returns The property value or default
267
- */
286
+ * Get a static property from a class constructor
287
+ * Type-safe helper that avoids (Type as any) casts
288
+ *
289
+ * @param Type - The class constructor
290
+ * @param propName - The property name to access
291
+ * @param defaultValue - Optional default value if property is undefined
292
+ * @returns The property value or default
293
+ */
268
294
  function getStaticProp(Type, propName, defaultValue) {
269
- return Type[propName] ?? defaultValue;
295
+ return Type[propName] ?? defaultValue;
270
296
  }
271
297
  /**
272
- * Check if a class is marked as keepAlive.
273
- * KeepAlive classes are never auto-disposed when ref count reaches 0.
274
- * @param Type - The class constructor to check
275
- * @returns true if the class has `static keepAlive = true`
276
- */
298
+ * Check if a class is marked as keepAlive.
299
+ * KeepAlive classes are never auto-disposed when ref count reaches 0.
300
+ * @param Type - The class constructor to check
301
+ * @returns true if the class has `static keepAlive = true`
302
+ */
277
303
  function isKeepAliveClass(Type) {
278
- return getStaticProp(Type, BLAC_STATIC_PROPS.KEEP_ALIVE) === true;
304
+ return getStaticProp(Type, BLAC_STATIC_PROPS.KEEP_ALIVE) === true;
279
305
  }
280
306
  //#endregion
281
307
  //#region src/core/StateContainerRegistry.ts
282
308
  /**
283
- * Central registry for managing StateContainer instances.
284
- * Handles instance lifecycle, named ref tracking, and lifecycle event emission.
285
- *
286
- * @example
287
- * ```ts
288
- * const registry = new StateContainerRegistry();
289
- * const instance = registry.acquire(MyBloc); // ownership, must release
290
- * const other = registry.ensure(OtherBloc); // no ownership, bloc-to-bloc
291
- * registry.on('stateChanged', (container, prev, next) => {
292
- * console.log('State changed:', prev, '->', next);
293
- * });
294
- * ```
295
- */
309
+ * Central registry for managing StateContainer instances.
310
+ * Handles instance lifecycle, named ref tracking, and lifecycle event emission.
311
+ *
312
+ * @example
313
+ * ```ts
314
+ * const registry = new StateContainerRegistry();
315
+ * const instance = registry.acquire(MyBloc); // ownership, must release
316
+ * const other = registry.ensure(OtherBloc); // no ownership, bloc-to-bloc
317
+ * registry.on('stateChanged', (container, prev, next) => {
318
+ * console.log('State changed:', prev, '->', next);
319
+ * });
320
+ * ```
321
+ */
296
322
  var StateContainerRegistry = class {
297
- constructor() {
298
- this.instancesByConstructor = /* @__PURE__ */ new WeakMap();
299
- this.types = /* @__PURE__ */ new Set();
300
- this.registeredTypeNames = /* @__PURE__ */ new Set();
301
- this.listeners = /* @__PURE__ */ new Map();
302
- this._autoRefIdCounter = 0;
303
- }
304
- /**
305
- * Register a type for lifecycle event tracking
306
- * @param constructor - The StateContainer class constructor
307
- */
308
- registerType(constructor) {
309
- this.types.add(constructor);
310
- }
311
- /**
312
- * Register a StateContainer class with configuration
313
- * @param constructor - The StateContainer class constructor
314
- * @throws Error if type is already registered
315
- */
316
- register(constructor) {
317
- const className = constructor.name;
318
- if (this.registeredTypeNames.has(className)) throw new Error(`${BLAC_ERROR_PREFIX} Type "${className}" is already registered`);
319
- this.registeredTypeNames.add(className);
320
- this.registerType(constructor);
321
- }
322
- ensureInstancesMap(Type) {
323
- let instances = this.instancesByConstructor.get(Type);
324
- if (!instances) {
325
- instances = /* @__PURE__ */ new Map();
326
- this.instancesByConstructor.set(Type, instances);
327
- }
328
- return instances;
329
- }
330
- /**
331
- * Get the instances Map for a specific class (public API for stats/debugging)
332
- */
333
- getInstancesMap(Type) {
334
- return this.instancesByConstructor.get(Type) || /* @__PURE__ */ new Map();
335
- }
336
- /**
337
- * Acquire an instance with ref tracking (ownership semantics).
338
- * Creates a new instance if one doesn't exist, or returns existing and adds a ref.
339
- * You must call `release()` with the same refId when done.
340
- * @param Type - The StateContainer class constructor
341
- * @param instanceKey - Instance key (defaults to 'default')
342
- * @param options - Acquisition options
343
- * @param options.canCreate - Whether to create new instance if not found (default: true)
344
- * @param options.countRef - Whether to add a reference (default: true)
345
- * @param options.refId - Named reference ID for debugging; auto-generated if omitted
346
- * @returns The state container instance
347
- */
348
- acquire(Type, instanceKey = BLAC_DEFAULTS.DEFAULT_INSTANCE_KEY, options = {}) {
349
- const { canCreate = true, countRef = true } = options;
350
- const config = { instanceId: instanceKey };
351
- const instances = this.ensureInstancesMap(Type);
352
- let entry = instances.get(instanceKey);
353
- if (entry?.instance.isDisposed) {
354
- instances.delete(instanceKey);
355
- entry = void 0;
356
- }
357
- if (entry && countRef) {
358
- const refId = options.refId ?? `_auto_${this._autoRefIdCounter++}`;
359
- entry.refs.set(refId, (entry.refs.get(refId) ?? 0) + 1);
360
- this.emit("refAcquired", entry.instance, refId);
361
- }
362
- if (entry) return entry.instance;
363
- if (!canCreate) throw new Error(`${BLAC_ERROR_PREFIX} ${Type.name} instance "${instanceKey}" not found and creation is disabled.`);
364
- const instance = new Type();
365
- instance.initConfig(config);
366
- const initialRefs = /* @__PURE__ */ new Map();
367
- let initialRefId;
368
- if (countRef) {
369
- initialRefId = options.refId ?? `_auto_${this._autoRefIdCounter++}`;
370
- initialRefs.set(initialRefId, 1);
371
- }
372
- instances.set(instanceKey, {
373
- instance,
374
- refs: initialRefs
375
- });
376
- this.registerType(Type);
377
- if (initialRefId) this.emit("refAcquired", instance, initialRefId);
378
- return instance;
379
- }
380
- /**
381
- * Borrow an existing instance without adding a ref (borrowing semantics).
382
- * Tracks cross-bloc dependency for reactive updates.
383
- * @param Type - The StateContainer class constructor
384
- * @param instanceKey - Instance key (defaults to 'default')
385
- * @returns The state container instance
386
- * @throws Error if instance doesn't exist
387
- */
388
- borrow(Type, instanceKey = BLAC_DEFAULTS.DEFAULT_INSTANCE_KEY) {
389
- return this.acquire(Type, instanceKey, {
390
- canCreate: false,
391
- countRef: false
392
- });
393
- }
394
- /**
395
- * Safely borrow an existing instance (borrowing semantics with error handling).
396
- * Returns discriminated union for type-safe conditional access.
397
- * @param Type - The StateContainer class constructor
398
- * @param instanceKey - Instance key (defaults to 'default')
399
- * @returns Discriminated union with either the instance or an error
400
- */
401
- borrowSafe(Type, instanceKey = BLAC_DEFAULTS.DEFAULT_INSTANCE_KEY) {
402
- try {
403
- return {
404
- error: null,
405
- instance: this.borrow(Type, instanceKey)
406
- };
407
- } catch (error) {
408
- return {
409
- error,
410
- instance: null
411
- };
412
- }
413
- }
414
- /**
415
- * Ensure an instance exists without taking ownership (for bloc-to-bloc communication).
416
- * Gets existing instance OR creates it if it doesn't exist, without adding a ref.
417
- * Tracks cross-bloc dependency for reactive updates.
418
- *
419
- * Use this in bloc-to-bloc communication when you need to ensure an instance exists
420
- * but don't want to claim ownership (no ref added).
421
- * @param Type - The StateContainer class constructor
422
- * @param instanceKey - Instance key (defaults to 'default')
423
- * @returns The state container instance
424
- */
425
- ensure(Type, instanceKey = BLAC_DEFAULTS.DEFAULT_INSTANCE_KEY) {
426
- return this.acquire(Type, instanceKey, {
427
- canCreate: true,
428
- countRef: false
429
- });
430
- }
431
- /**
432
- * Release a reference to an instance.
433
- * Removes the ref and disposes when refs is empty (unless keepAlive).
434
- * Releasing an already-removed refId is a no-op (idempotent).
435
- * @param Type - The StateContainer class constructor
436
- * @param instanceKey - Instance key (defaults to 'default')
437
- * @param forceDispose - Force immediate disposal regardless of refs
438
- * @param refId - The specific ref to remove; removes one arbitrary ref if omitted
439
- */
440
- release(Type, instanceKey = BLAC_DEFAULTS.DEFAULT_INSTANCE_KEY, forceDispose = false, refId) {
441
- const instances = this.ensureInstancesMap(Type);
442
- const entry = instances.get(instanceKey);
443
- if (!entry) return;
444
- if (forceDispose) {
445
- if (!entry.instance.isDisposed) entry.instance.dispose();
446
- instances.delete(instanceKey);
447
- return;
448
- }
449
- let releasedRefId;
450
- if (refId !== void 0) {
451
- const count = entry.refs.get(refId) ?? 0;
452
- if (count <= 1) entry.refs.delete(refId);
453
- else entry.refs.set(refId, count - 1);
454
- releasedRefId = refId;
455
- } else {
456
- const firstKey = entry.refs.keys().next().value;
457
- if (firstKey !== void 0) {
458
- const count = entry.refs.get(firstKey);
459
- if (count <= 1) entry.refs.delete(firstKey);
460
- else entry.refs.set(firstKey, count - 1);
461
- releasedRefId = firstKey;
462
- }
463
- }
464
- if (releasedRefId) this.emit("refReleased", entry.instance, releasedRefId);
465
- const keepAlive = isKeepAliveClass(Type);
466
- if (entry.refs.size === 0 && !keepAlive) {
467
- if (!entry.instance.isDisposed) entry.instance.dispose();
468
- instances.delete(instanceKey);
469
- }
470
- }
471
- /**
472
- * Get all instances of a specific type.
473
- * @param Type - The StateContainer class constructor
474
- * @returns Array of all instances
475
- */
476
- getAll(Type) {
477
- const instances = this.ensureInstancesMap(Type);
478
- const result = [];
479
- for (const entry of instances.values()) result.push(entry.instance);
480
- return result;
481
- }
482
- /**
483
- * Safely iterate over all instances of a type.
484
- * Skips disposed instances and catches callback errors.
485
- * @param Type - The StateContainer class constructor
486
- * @param callback - Function to call for each instance
487
- */
488
- forEach(Type, callback) {
489
- const instances = this.ensureInstancesMap(Type);
490
- for (const entry of instances.values()) {
491
- const instance = entry.instance;
492
- if (!instance.isDisposed) try {
493
- callback(instance);
494
- } catch (error) {
495
- console.error(`${BLAC_ERROR_PREFIX} forEach callback error for ${Type.name}:`, error);
496
- }
497
- }
498
- }
499
- /**
500
- * Clear all instances of a specific type (disposes them).
501
- * @param Type - The StateContainer class constructor
502
- */
503
- clear(Type) {
504
- const instances = this.ensureInstancesMap(Type);
505
- for (const entry of instances.values()) if (!entry.instance.isDisposed) entry.instance.dispose();
506
- instances.clear();
507
- }
508
- /**
509
- * Get reference count for an instance (number of active refs).
510
- * @param Type - The StateContainer class constructor
511
- * @param instanceKey - Instance key (defaults to 'default')
512
- * @returns Current ref count (0 if instance doesn't exist)
513
- */
514
- getRefCount(Type, instanceKey = BLAC_DEFAULTS.DEFAULT_INSTANCE_KEY) {
515
- return this.ensureInstancesMap(Type).get(instanceKey)?.refs.size ?? 0;
516
- }
517
- /**
518
- * Get all active reference IDs for an instance.
519
- * @param Type - The StateContainer class constructor
520
- * @param instanceKey - Instance key (defaults to 'default')
521
- * @returns Array of ref ID strings (empty if instance doesn't exist)
522
- */
523
- getRefIds(Type, instanceKey = BLAC_DEFAULTS.DEFAULT_INSTANCE_KEY) {
524
- const instances = this.instancesByConstructor.get(Type);
525
- if (!instances) return [];
526
- const entry = instances.get(instanceKey);
527
- return entry ? Array.from(entry.refs.keys()) : [];
528
- }
529
- /**
530
- * Check if an instance exists.
531
- * @param Type - The StateContainer class constructor
532
- * @param instanceKey - Instance key (defaults to 'default')
533
- * @returns true if instance exists
534
- */
535
- hasInstance(Type, instanceKey = BLAC_DEFAULTS.DEFAULT_INSTANCE_KEY) {
536
- return this.ensureInstancesMap(Type).has(instanceKey);
537
- }
538
- /**
539
- * Clear all instances from all types (for testing)
540
- *
541
- * Iterates all registered types and clears their instances.
542
- * Also clears type tracking to reset the registry state.
543
- */
544
- clearAll() {
545
- for (const Type of this.types) this.clear(Type);
546
- this.types.clear();
547
- this.registeredTypeNames.clear();
548
- }
549
- /**
550
- * Get registry statistics for debugging.
551
- * @returns Object with registeredTypes, totalInstances, and typeBreakdown
552
- */
553
- getStats() {
554
- const typeBreakdown = {};
555
- let totalInstances = 0;
556
- for (const Type of this.types) {
557
- const typeName = Type.name;
558
- const count = this.getInstancesMap(Type).size;
559
- typeBreakdown[typeName] = count;
560
- totalInstances += count;
561
- }
562
- return {
563
- registeredTypes: this.types.size,
564
- totalInstances,
565
- typeBreakdown
566
- };
567
- }
568
- /**
569
- * Get all registered types (for plugin system).
570
- * @returns Array of all registered StateContainer class constructors
571
- */
572
- getTypes() {
573
- return Array.from(this.types);
574
- }
575
- /**
576
- * Subscribe to lifecycle events
577
- * @param event - The lifecycle event to listen for
578
- * @param listener - The listener function to call when the event occurs
579
- * @returns Unsubscribe function
580
- */
581
- on(event, listener) {
582
- if (!this.listeners.has(event)) this.listeners.set(event, /* @__PURE__ */ new Set());
583
- const instance = this.listeners.get(event);
584
- if (!instance) throw new Error(`${BLAC_ERROR_PREFIX} Failed to register listener for event '${event}'`);
585
- instance.add(listener);
586
- return () => {
587
- this.listeners.get(event)?.delete(listener);
588
- };
589
- }
590
- /**
591
- * Emit lifecycle event to all listeners
592
- * @internal - Called by StateContainer lifecycle methods
593
- */
594
- emit(event, ...args) {
595
- const listeners = this.listeners.get(event);
596
- if (!listeners || listeners.size === 0) return;
597
- for (const listener of listeners) try {
598
- listener(...args);
599
- } catch (error) {
600
- console.error(`${BLAC_ERROR_PREFIX} Listener error for '${event}':`, error);
601
- }
602
- }
323
+ constructor() {
324
+ this.instancesByConstructor = /* @__PURE__ */ new WeakMap();
325
+ this.types = /* @__PURE__ */ new Set();
326
+ this.registeredTypeNames = /* @__PURE__ */ new Set();
327
+ this.listeners = /* @__PURE__ */ new Map();
328
+ this._autoRefIdCounter = 0;
329
+ }
330
+ /**
331
+ * Register a type for lifecycle event tracking
332
+ * @param constructor - The StateContainer class constructor
333
+ */
334
+ registerType(constructor) {
335
+ this.types.add(constructor);
336
+ }
337
+ /**
338
+ * Register a StateContainer class with configuration
339
+ * @param constructor - The StateContainer class constructor
340
+ * @throws Error if type is already registered
341
+ */
342
+ register(constructor) {
343
+ const className = constructor.name;
344
+ if (this.registeredTypeNames.has(className))
345
+ throw new Error(
346
+ `${BLAC_ERROR_PREFIX} Type "${className}" is already registered`,
347
+ );
348
+ this.registeredTypeNames.add(className);
349
+ this.registerType(constructor);
350
+ }
351
+ ensureInstancesMap(Type) {
352
+ let instances = this.instancesByConstructor.get(Type);
353
+ if (!instances) {
354
+ instances = /* @__PURE__ */ new Map();
355
+ this.instancesByConstructor.set(Type, instances);
356
+ }
357
+ return instances;
358
+ }
359
+ /**
360
+ * Get the instances Map for a specific class (public API for stats/debugging)
361
+ */
362
+ getInstancesMap(Type) {
363
+ return this.instancesByConstructor.get(Type) || /* @__PURE__ */ new Map();
364
+ }
365
+ /**
366
+ * Acquire an instance with ref tracking (ownership semantics).
367
+ * Creates a new instance if one doesn't exist, or returns existing and adds a ref.
368
+ * You must call `release()` with the same refId when done.
369
+ * @param Type - The StateContainer class constructor
370
+ * @param instanceKey - Instance key (defaults to 'default')
371
+ * @param options - Acquisition options
372
+ * @param options.canCreate - Whether to create new instance if not found (default: true)
373
+ * @param options.countRef - Whether to add a reference (default: true)
374
+ * @param options.refId - Named reference ID for debugging; auto-generated if omitted
375
+ * @returns The state container instance
376
+ */
377
+ acquire(
378
+ Type,
379
+ instanceKey = BLAC_DEFAULTS.DEFAULT_INSTANCE_KEY,
380
+ options = {},
381
+ ) {
382
+ const { canCreate = true, countRef = true } = options;
383
+ const config = { instanceId: instanceKey };
384
+ const instances = this.ensureInstancesMap(Type);
385
+ let entry = instances.get(instanceKey);
386
+ if (entry?.instance.isDisposed) {
387
+ instances.delete(instanceKey);
388
+ entry = void 0;
389
+ }
390
+ if (entry && countRef) {
391
+ const refId = options.refId ?? `_auto_${this._autoRefIdCounter++}`;
392
+ entry.refs.set(refId, (entry.refs.get(refId) ?? 0) + 1);
393
+ this.emit('refAcquired', entry.instance, refId);
394
+ }
395
+ if (entry) return entry.instance;
396
+ if (!canCreate)
397
+ throw new Error(
398
+ `${BLAC_ERROR_PREFIX} ${Type.name} instance "${instanceKey}" not found and creation is disabled.`,
399
+ );
400
+ const instance = new Type();
401
+ instance.initConfig(config);
402
+ const initialRefs = /* @__PURE__ */ new Map();
403
+ let initialRefId;
404
+ if (countRef) {
405
+ initialRefId = options.refId ?? `_auto_${this._autoRefIdCounter++}`;
406
+ initialRefs.set(initialRefId, 1);
407
+ }
408
+ instances.set(instanceKey, {
409
+ instance,
410
+ refs: initialRefs,
411
+ });
412
+ this.registerType(Type);
413
+ if (initialRefId) this.emit('refAcquired', instance, initialRefId);
414
+ return instance;
415
+ }
416
+ /**
417
+ * Borrow an existing instance without adding a ref (borrowing semantics).
418
+ * Tracks cross-bloc dependency for reactive updates.
419
+ * @param Type - The StateContainer class constructor
420
+ * @param instanceKey - Instance key (defaults to 'default')
421
+ * @returns The state container instance
422
+ * @throws Error if instance doesn't exist
423
+ */
424
+ borrow(Type, instanceKey = BLAC_DEFAULTS.DEFAULT_INSTANCE_KEY) {
425
+ return this.acquire(Type, instanceKey, {
426
+ canCreate: false,
427
+ countRef: false,
428
+ });
429
+ }
430
+ /**
431
+ * Safely borrow an existing instance (borrowing semantics with error handling).
432
+ * Returns discriminated union for type-safe conditional access.
433
+ * @param Type - The StateContainer class constructor
434
+ * @param instanceKey - Instance key (defaults to 'default')
435
+ * @returns Discriminated union with either the instance or an error
436
+ */
437
+ borrowSafe(Type, instanceKey = BLAC_DEFAULTS.DEFAULT_INSTANCE_KEY) {
438
+ try {
439
+ return {
440
+ error: null,
441
+ instance: this.borrow(Type, instanceKey),
442
+ };
443
+ } catch (error) {
444
+ return {
445
+ error,
446
+ instance: null,
447
+ };
448
+ }
449
+ }
450
+ /**
451
+ * Ensure an instance exists without taking ownership (for bloc-to-bloc communication).
452
+ * Gets existing instance OR creates it if it doesn't exist, without adding a ref.
453
+ * Tracks cross-bloc dependency for reactive updates.
454
+ *
455
+ * Use this in bloc-to-bloc communication when you need to ensure an instance exists
456
+ * but don't want to claim ownership (no ref added).
457
+ * @param Type - The StateContainer class constructor
458
+ * @param instanceKey - Instance key (defaults to 'default')
459
+ * @returns The state container instance
460
+ */
461
+ ensure(Type, instanceKey = BLAC_DEFAULTS.DEFAULT_INSTANCE_KEY) {
462
+ return this.acquire(Type, instanceKey, {
463
+ canCreate: true,
464
+ countRef: false,
465
+ });
466
+ }
467
+ /**
468
+ * Release a reference to an instance.
469
+ * Removes the ref and disposes when refs is empty (unless keepAlive).
470
+ * Releasing an already-removed refId is a no-op (idempotent).
471
+ * @param Type - The StateContainer class constructor
472
+ * @param instanceKey - Instance key (defaults to 'default')
473
+ * @param forceDispose - Force immediate disposal regardless of refs
474
+ * @param refId - The specific ref to remove; removes one arbitrary ref if omitted
475
+ */
476
+ release(
477
+ Type,
478
+ instanceKey = BLAC_DEFAULTS.DEFAULT_INSTANCE_KEY,
479
+ forceDispose = false,
480
+ refId,
481
+ ) {
482
+ const instances = this.ensureInstancesMap(Type);
483
+ const entry = instances.get(instanceKey);
484
+ if (!entry) return;
485
+ if (forceDispose) {
486
+ if (!entry.instance.isDisposed) entry.instance.dispose();
487
+ instances.delete(instanceKey);
488
+ return;
489
+ }
490
+ let releasedRefId;
491
+ if (refId !== void 0) {
492
+ const count = entry.refs.get(refId) ?? 0;
493
+ if (count <= 1) entry.refs.delete(refId);
494
+ else entry.refs.set(refId, count - 1);
495
+ releasedRefId = refId;
496
+ } else {
497
+ const firstKey = entry.refs.keys().next().value;
498
+ if (firstKey !== void 0) {
499
+ const count = entry.refs.get(firstKey);
500
+ if (count <= 1) entry.refs.delete(firstKey);
501
+ else entry.refs.set(firstKey, count - 1);
502
+ releasedRefId = firstKey;
503
+ }
504
+ }
505
+ if (releasedRefId) this.emit('refReleased', entry.instance, releasedRefId);
506
+ const keepAlive = isKeepAliveClass(Type);
507
+ if (entry.refs.size === 0 && !keepAlive) {
508
+ if (!entry.instance.isDisposed) entry.instance.dispose();
509
+ instances.delete(instanceKey);
510
+ }
511
+ }
512
+ /**
513
+ * Get all instances of a specific type.
514
+ * @param Type - The StateContainer class constructor
515
+ * @returns Array of all instances
516
+ */
517
+ getAll(Type) {
518
+ const instances = this.ensureInstancesMap(Type);
519
+ const result = [];
520
+ for (const entry of instances.values()) result.push(entry.instance);
521
+ return result;
522
+ }
523
+ /**
524
+ * Safely iterate over all instances of a type.
525
+ * Skips disposed instances and catches callback errors.
526
+ * @param Type - The StateContainer class constructor
527
+ * @param callback - Function to call for each instance
528
+ */
529
+ forEach(Type, callback) {
530
+ const instances = this.ensureInstancesMap(Type);
531
+ for (const entry of instances.values()) {
532
+ const instance = entry.instance;
533
+ if (!instance.isDisposed)
534
+ try {
535
+ callback(instance);
536
+ } catch (error) {
537
+ console.error(
538
+ `${BLAC_ERROR_PREFIX} forEach callback error for ${Type.name}:`,
539
+ error,
540
+ );
541
+ }
542
+ }
543
+ }
544
+ /**
545
+ * Clear all instances of a specific type (disposes them).
546
+ * @param Type - The StateContainer class constructor
547
+ */
548
+ clear(Type) {
549
+ const instances = this.ensureInstancesMap(Type);
550
+ for (const entry of instances.values())
551
+ if (!entry.instance.isDisposed) entry.instance.dispose();
552
+ instances.clear();
553
+ }
554
+ /**
555
+ * Get reference count for an instance (number of active refs).
556
+ * @param Type - The StateContainer class constructor
557
+ * @param instanceKey - Instance key (defaults to 'default')
558
+ * @returns Current ref count (0 if instance doesn't exist)
559
+ */
560
+ getRefCount(Type, instanceKey = BLAC_DEFAULTS.DEFAULT_INSTANCE_KEY) {
561
+ return this.ensureInstancesMap(Type).get(instanceKey)?.refs.size ?? 0;
562
+ }
563
+ /**
564
+ * Get all active reference IDs for an instance.
565
+ * @param Type - The StateContainer class constructor
566
+ * @param instanceKey - Instance key (defaults to 'default')
567
+ * @returns Array of ref ID strings (empty if instance doesn't exist)
568
+ */
569
+ getRefIds(Type, instanceKey = BLAC_DEFAULTS.DEFAULT_INSTANCE_KEY) {
570
+ const instances = this.instancesByConstructor.get(Type);
571
+ if (!instances) return [];
572
+ const entry = instances.get(instanceKey);
573
+ return entry ? Array.from(entry.refs.keys()) : [];
574
+ }
575
+ /**
576
+ * Check if an instance exists.
577
+ * @param Type - The StateContainer class constructor
578
+ * @param instanceKey - Instance key (defaults to 'default')
579
+ * @returns true if instance exists
580
+ */
581
+ hasInstance(Type, instanceKey = BLAC_DEFAULTS.DEFAULT_INSTANCE_KEY) {
582
+ return this.ensureInstancesMap(Type).has(instanceKey);
583
+ }
584
+ /**
585
+ * Clear all instances from all types (for testing)
586
+ *
587
+ * Iterates all registered types and clears their instances.
588
+ * Also clears type tracking to reset the registry state.
589
+ */
590
+ clearAll() {
591
+ for (const Type of this.types) this.clear(Type);
592
+ this.types.clear();
593
+ this.registeredTypeNames.clear();
594
+ }
595
+ /**
596
+ * Get registry statistics for debugging.
597
+ * @returns Object with registeredTypes, totalInstances, and typeBreakdown
598
+ */
599
+ getStats() {
600
+ const typeBreakdown = {};
601
+ let totalInstances = 0;
602
+ for (const Type of this.types) {
603
+ const typeName = Type.name;
604
+ const count = this.getInstancesMap(Type).size;
605
+ typeBreakdown[typeName] = count;
606
+ totalInstances += count;
607
+ }
608
+ return {
609
+ registeredTypes: this.types.size,
610
+ totalInstances,
611
+ typeBreakdown,
612
+ };
613
+ }
614
+ /**
615
+ * Get all registered types (for plugin system).
616
+ * @returns Array of all registered StateContainer class constructors
617
+ */
618
+ getTypes() {
619
+ return Array.from(this.types);
620
+ }
621
+ /**
622
+ * Subscribe to lifecycle events
623
+ * @param event - The lifecycle event to listen for
624
+ * @param listener - The listener function to call when the event occurs
625
+ * @returns Unsubscribe function
626
+ */
627
+ on(event, listener) {
628
+ if (!this.listeners.has(event))
629
+ this.listeners.set(event, /* @__PURE__ */ new Set());
630
+ const instance = this.listeners.get(event);
631
+ if (!instance)
632
+ throw new Error(
633
+ `${BLAC_ERROR_PREFIX} Failed to register listener for event '${event}'`,
634
+ );
635
+ instance.add(listener);
636
+ return () => {
637
+ this.listeners.get(event)?.delete(listener);
638
+ };
639
+ }
640
+ /**
641
+ * Emit lifecycle event to all listeners
642
+ * @internal - Called by StateContainer lifecycle methods
643
+ */
644
+ emit(event, ...args) {
645
+ const listeners = this.listeners.get(event);
646
+ if (!listeners || listeners.size === 0) return;
647
+ for (const listener of listeners)
648
+ try {
649
+ listener(...args);
650
+ } catch (error) {
651
+ console.error(
652
+ `${BLAC_ERROR_PREFIX} Listener error for '${event}':`,
653
+ error,
654
+ );
655
+ }
656
+ }
603
657
  };
604
658
  /**
605
- * Global default registry instance
606
- */
659
+ * Global default registry instance
660
+ */
607
661
  const globalRegistry = new StateContainerRegistry();
608
662
  /**
609
- * Global plugin manager (initialized lazily)
610
- */
663
+ * Global plugin manager (initialized lazily)
664
+ */
611
665
  let _globalPluginManager = null;
612
666
  /**
613
- * Get the global plugin manager
614
- */
667
+ * Get the global plugin manager
668
+ */
615
669
  function getPluginManager() {
616
- if (!_globalPluginManager) _globalPluginManager = createPluginManager(globalRegistry);
617
- return _globalPluginManager;
670
+ if (!_globalPluginManager)
671
+ _globalPluginManager = createPluginManager(globalRegistry);
672
+ return _globalPluginManager;
618
673
  }
619
674
  //#endregion
620
- export { BLAC_DEFAULTS as a, PluginManager as i, getPluginManager as n, BLAC_ERROR_PREFIX as o, globalRegistry as r, BLAC_STATIC_PROPS as s, StateContainerRegistry as t };
675
+ export {
676
+ BLAC_DEFAULTS as a,
677
+ PluginManager as i,
678
+ getPluginManager as n,
679
+ BLAC_ERROR_PREFIX as o,
680
+ globalRegistry as r,
681
+ BLAC_STATIC_PROPS as s,
682
+ StateContainerRegistry as t,
683
+ };
621
684
 
622
- //# sourceMappingURL=StateContainerRegistry-DOuGI-l5.js.map
685
+ //# sourceMappingURL=StateContainerRegistry-DOuGI-l5.js.map