@blac/core 2.0.13 → 2.0.15

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 (379) 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 +269 -230
  5. package/dist/Cubit-BC70gaiA.js +453 -0
  6. package/dist/Cubit-BC70gaiA.js.map +1 -0
  7. package/dist/Cubit-BOgUZva7.js +342 -266
  8. package/dist/Cubit-BOxMvpfc.js +273 -232
  9. package/dist/Cubit-BTznt8zg.js +1 -1
  10. package/dist/Cubit-BogJXkLm.js +260 -225
  11. package/dist/Cubit-C-8R_8db.cjs +475 -0
  12. package/dist/Cubit-C-8R_8db.cjs.map +1 -0
  13. package/dist/Cubit-C3Mw3EoO.cjs +401 -0
  14. package/dist/Cubit-C3Mw3EoO.cjs.map +1 -0
  15. package/dist/Cubit-CO8Fr72L.cjs +447 -0
  16. package/dist/Cubit-CO8Fr72L.cjs.map +1 -0
  17. package/dist/Cubit-COfHT1Bm.cjs +300 -259
  18. package/dist/Cubit-CROWjjs9.js +481 -0
  19. package/dist/Cubit-CROWjjs9.js.map +1 -0
  20. package/dist/Cubit-CWP8Ddzx.cjs +510 -0
  21. package/dist/Cubit-CWP8Ddzx.cjs.map +1 -0
  22. package/dist/Cubit-CXxh9iol.js +284 -242
  23. package/dist/Cubit-CYOWfzQt.cjs +297 -254
  24. package/dist/Cubit-CZaf_fp4.cjs +1 -1
  25. package/dist/Cubit-C_dUEUdd.cjs +359 -286
  26. package/dist/Cubit-C_rxRCTN.cjs +523 -0
  27. package/dist/Cubit-C_rxRCTN.cjs.map +1 -0
  28. package/dist/Cubit-CcKgMEBO.js +281 -239
  29. package/dist/Cubit-CfT6Y1jl.js +328 -280
  30. package/dist/Cubit-CynJruuO.js +369 -0
  31. package/dist/Cubit-CynJruuO.js.map +1 -0
  32. package/dist/Cubit-D2vQ6nMb.js +342 -266
  33. package/dist/Cubit-D7jOZCoZ.js +342 -266
  34. package/dist/Cubit-D9j3IGPc.cjs +523 -0
  35. package/dist/Cubit-D9j3IGPc.cjs.map +1 -0
  36. package/dist/Cubit-DKEY9WYq.cjs +276 -240
  37. package/dist/Cubit-DMV_0TCp.js +481 -0
  38. package/dist/Cubit-DMV_0TCp.js.map +1 -0
  39. package/dist/Cubit-DP5DXPUK.js +342 -266
  40. package/dist/Cubit-DRFkzD2h.js +426 -0
  41. package/dist/Cubit-DRFkzD2h.js.map +1 -0
  42. package/dist/Cubit-DbnhTUaZ.cjs +359 -286
  43. package/dist/Cubit-DrqG3SP3.cjs +349 -300
  44. package/dist/Cubit-DsDkCo42.cjs +292 -250
  45. package/dist/Cubit-DwRw1E9D.cjs +289 -247
  46. package/dist/Cubit-Dw_kFBgc.js +1 -1
  47. package/dist/Cubit-KiXZCubP.cjs +1 -1
  48. package/dist/Cubit-Ksj7G4uR.js +342 -266
  49. package/dist/Cubit-MkjbpcPf.cjs +359 -286
  50. package/dist/Cubit-NRhvdDQ6.js +279 -239
  51. package/dist/Cubit-PMTXxI_u.js +1 -1
  52. package/dist/Cubit-VJuu2tt9.js +481 -0
  53. package/dist/Cubit-VJuu2tt9.js.map +1 -0
  54. package/dist/Cubit-jz922NKf.cjs +300 -257
  55. package/dist/Cubit-kU5_4jgC.cjs +359 -286
  56. package/dist/StateContainerRegistry-B4yVMYbx.cjs +1057 -0
  57. package/dist/StateContainerRegistry-B4yVMYbx.cjs.map +1 -0
  58. package/dist/StateContainerRegistry-BAcxouCu.js +683 -615
  59. package/dist/StateContainerRegistry-BK57H92E.js +701 -630
  60. package/dist/StateContainerRegistry-BRBATSrx.cjs +1030 -0
  61. package/dist/StateContainerRegistry-BRBATSrx.cjs.map +1 -0
  62. package/dist/StateContainerRegistry-BgBIKcQF.js +956 -0
  63. package/dist/StateContainerRegistry-BgBIKcQF.js.map +1 -0
  64. package/dist/StateContainerRegistry-BglEhqdA.js +669 -606
  65. package/dist/StateContainerRegistry-BhcnG0DF.js +625 -562
  66. package/dist/StateContainerRegistry-BpO5t-0i.js +642 -580
  67. package/dist/StateContainerRegistry-BqS-wpb_.js +957 -0
  68. package/dist/StateContainerRegistry-BqS-wpb_.js.map +1 -0
  69. package/dist/StateContainerRegistry-BrEGYPZT.cjs +1029 -0
  70. package/dist/StateContainerRegistry-BrEGYPZT.cjs.map +1 -0
  71. package/dist/StateContainerRegistry-Bxfne4A7.cjs +908 -0
  72. package/dist/StateContainerRegistry-Bxfne4A7.cjs.map +1 -0
  73. package/dist/StateContainerRegistry-C0E7vsgy.js +758 -0
  74. package/dist/StateContainerRegistry-C0E7vsgy.js.map +1 -0
  75. package/dist/StateContainerRegistry-C0I77Ndz.cjs +920 -0
  76. package/dist/StateContainerRegistry-C0I77Ndz.cjs.map +1 -0
  77. package/dist/StateContainerRegistry-CDH9mnQS.cjs +668 -614
  78. package/dist/StateContainerRegistry-CTOXUf75.cjs +695 -640
  79. package/dist/StateContainerRegistry-CX2CBOmv.cjs +739 -679
  80. package/dist/StateContainerRegistry-CXnnf2-l.js +867 -0
  81. package/dist/StateContainerRegistry-CXnnf2-l.js.map +1 -0
  82. package/dist/StateContainerRegistry-CehuIpK_.cjs +811 -0
  83. package/dist/StateContainerRegistry-CehuIpK_.cjs.map +1 -0
  84. package/dist/StateContainerRegistry-Ci0ajc5g.js +680 -612
  85. package/dist/StateContainerRegistry-Ck2-XmT_.js +587 -527
  86. package/dist/StateContainerRegistry-D1lVJFGL.cjs +706 -646
  87. package/dist/StateContainerRegistry-DC4N73O6.js +632 -569
  88. package/dist/StateContainerRegistry-DOuGI-l5.js +645 -582
  89. package/dist/StateContainerRegistry-DT66lr3I.cjs +651 -596
  90. package/dist/StateContainerRegistry-DmmzYa7S.js +974 -0
  91. package/dist/StateContainerRegistry-DmmzYa7S.js.map +1 -0
  92. package/dist/StateContainerRegistry-Upsrlg9G.cjs +709 -649
  93. package/dist/StateContainerRegistry-WznfcA-Q.js +855 -0
  94. package/dist/StateContainerRegistry-WznfcA-Q.js.map +1 -0
  95. package/dist/StateContainerRegistry-Yph6UCA_.js +637 -569
  96. package/dist/StateContainerRegistry-mseeTqSA.cjs +671 -616
  97. package/dist/StateContainerRegistry-pRNxHNFD.cjs +658 -603
  98. package/dist/StateContainerRegistry-vXMWtG7J.cjs +613 -561
  99. package/dist/StateContainerRegistry-v_prqMcI.cjs +663 -603
  100. package/dist/branded-BSeA_mZO.cjs.map +1 -1
  101. package/dist/branded-DCqi3De1.cjs +11 -11
  102. package/dist/branded-DwtzSsg0.js.map +1 -1
  103. package/dist/branded-Max3xOTA.js +6 -6
  104. package/dist/config-0ZD9i3wy.js +16 -0
  105. package/dist/config-0ZD9i3wy.js.map +1 -0
  106. package/dist/config-B3NIwDQv.cjs +20 -20
  107. package/dist/config-BKGHop0V.js +5 -5
  108. package/dist/config-BKoaAlmb.js +5 -5
  109. package/dist/config-BPj08-8h.cjs +32 -0
  110. package/dist/config-BPj08-8h.cjs.map +1 -0
  111. package/dist/config-BR0Xy-Tn.cjs +20 -20
  112. package/dist/config-B_4xXpvK.cjs +32 -0
  113. package/dist/config-B_4xXpvK.cjs.map +1 -0
  114. package/dist/config-BflrQM4_.cjs +32 -0
  115. package/dist/config-BflrQM4_.cjs.map +1 -0
  116. package/dist/config-BzObBsk2.cjs +32 -0
  117. package/dist/config-BzObBsk2.cjs.map +1 -0
  118. package/dist/config-C0yumL1H.cjs +32 -0
  119. package/dist/config-C0yumL1H.cjs.map +1 -0
  120. package/dist/config-C8xqVHTf.js +16 -0
  121. package/dist/config-C8xqVHTf.js.map +1 -0
  122. package/dist/config-CCUhIYIF.js +5 -5
  123. package/dist/config-CGo__MAt.js +16 -0
  124. package/dist/config-CGo__MAt.js.map +1 -0
  125. package/dist/config-CQH9fTY-.cjs +20 -20
  126. package/dist/config-CR_Bz7RD.js +5 -5
  127. package/dist/config-CTOa-yPN.cjs +20 -20
  128. package/dist/config-Cd7Q-B4g.js +16 -0
  129. package/dist/config-Cd7Q-B4g.js.map +1 -0
  130. package/dist/config-CmDEX-1o.js +16 -0
  131. package/dist/config-CmDEX-1o.js.map +1 -0
  132. package/dist/config-CoNMTnMA.cjs +32 -0
  133. package/dist/config-CoNMTnMA.cjs.map +1 -0
  134. package/dist/config-Cwj8-C1J.js +5 -5
  135. package/dist/config-D3jisfdj.cjs +20 -20
  136. package/dist/config-D4GifZQ4.js +5 -5
  137. package/dist/config-DDrSQGpQ.cjs +20 -20
  138. package/dist/config-DEcslxan.cjs +20 -20
  139. package/dist/config-DMNZ2YLV.cjs +20 -20
  140. package/dist/config-De9oQ6Ki.js +5 -5
  141. package/dist/config-DoHx0Xsl.js +16 -0
  142. package/dist/config-DoHx0Xsl.js.map +1 -0
  143. package/dist/config-DokTzpr8.cjs +20 -20
  144. package/dist/config-DslYBm4Z.js +5 -5
  145. package/dist/config-H6FAqbW4.cjs +20 -20
  146. package/dist/config-Yp645dGK.js +5 -5
  147. package/dist/config-ispAzOZV.js +5 -5
  148. package/dist/config.d.cts +72 -0
  149. package/dist/config.d.ts +72 -0
  150. package/dist/constants.d.cts +13 -0
  151. package/dist/constants.d.ts +13 -0
  152. package/dist/core/Cubit.d.ts +14 -4
  153. package/dist/core/StateContainer.d.ts +111 -11
  154. package/dist/core/StateContainerRegistry.d.ts +55 -11
  155. package/dist/core/symbols.d.ts +26 -0
  156. package/dist/debug.cjs +3 -3
  157. package/dist/debug.js +3 -3
  158. package/dist/decorators/blac.d.ts +17 -0
  159. package/dist/ensure-9VEq5H0L.js +3 -3
  160. package/dist/ensure-BB6xHQAF.cjs +14 -0
  161. package/dist/ensure-BB6xHQAF.cjs.map +1 -0
  162. package/dist/ensure-BNDfTzqg.cjs +8 -8
  163. package/dist/ensure-BVCnjU7r.js +343 -267
  164. package/dist/ensure-BbzGXjep.cjs +8 -8
  165. package/dist/ensure-BlIaQai6.js +9 -0
  166. package/dist/ensure-BlIaQai6.js.map +1 -0
  167. package/dist/ensure-Bm3oHxga.js +9 -0
  168. package/dist/ensure-Bm3oHxga.js.map +1 -0
  169. package/dist/ensure-C3eIRs6e.cjs +8 -8
  170. package/dist/ensure-CJZL7bcA.cjs +365 -292
  171. package/dist/ensure-CN6unBOe.cjs +8 -8
  172. package/dist/ensure-CU-B1ywv.js +3 -3
  173. package/dist/ensure-CWKzeno7.js +3 -3
  174. package/dist/ensure-CkENsuQ9.js +9 -0
  175. package/dist/ensure-CkENsuQ9.js.map +1 -0
  176. package/dist/ensure-Cm-4_LSh.cjs +14 -0
  177. package/dist/ensure-Cm-4_LSh.cjs.map +1 -0
  178. package/dist/ensure-Cqex5r1P.cjs +14 -0
  179. package/dist/ensure-Cqex5r1P.cjs.map +1 -0
  180. package/dist/ensure-Cv5AbNGZ.js +9 -0
  181. package/dist/ensure-Cv5AbNGZ.js.map +1 -0
  182. package/dist/ensure-D63lEMUK.cjs +8 -8
  183. package/dist/ensure-DGEtPU9A.cjs +8 -8
  184. package/dist/ensure-DM3qb336.cjs +14 -0
  185. package/dist/ensure-DM3qb336.cjs.map +1 -0
  186. package/dist/ensure-DME-_T0j.cjs +8 -8
  187. package/dist/ensure-DWd0GCYB.js +3 -3
  188. package/dist/ensure-DamKOP6q.cjs +8 -8
  189. package/dist/ensure-Dcfptl-A.js +9 -0
  190. package/dist/ensure-Dcfptl-A.js.map +1 -0
  191. package/dist/ensure-Def-EBWG.js +3 -3
  192. package/dist/ensure-DnHL5QiQ.cjs +14 -0
  193. package/dist/ensure-DnHL5QiQ.cjs.map +1 -0
  194. package/dist/ensure-Dr7I78Ku.cjs +8 -8
  195. package/dist/ensure-SLVdGd5b.js +3 -3
  196. package/dist/ensure-Sb92MCXu.js +3 -3
  197. package/dist/ensure-gFlvevGm.cjs +14 -0
  198. package/dist/ensure-gFlvevGm.cjs.map +1 -0
  199. package/dist/ensure-l2-H7S5W.js +3 -3
  200. package/dist/ensure-mkL-3qh8.js +9 -0
  201. package/dist/ensure-mkL-3qh8.js.map +1 -0
  202. package/dist/ensure-n80crSlX.js +3 -3
  203. package/dist/ensure-nCxg7MCN.js +3 -3
  204. package/dist/ensure-vS71MV4q.cjs +8 -8
  205. package/dist/index.cjs +37 -14
  206. package/dist/index.cjs.map +1 -1
  207. package/dist/index.d.cts +14 -4
  208. package/dist/index.d.ts +14 -4
  209. package/dist/index.js +23 -10
  210. package/dist/index.js.map +1 -1
  211. package/dist/management-6oQbmf0z.js +41 -0
  212. package/dist/management-6oQbmf0z.js.map +1 -0
  213. package/dist/management-B46QwA9Y.js +20 -11
  214. package/dist/management-B9yrRpeg.js +41 -0
  215. package/dist/management-B9yrRpeg.js.map +1 -0
  216. package/dist/management-BCKTEZ8Q.js +20 -11
  217. package/dist/management-BbMzdXbT.js +41 -0
  218. package/dist/management-BbMzdXbT.js.map +1 -0
  219. package/dist/management-Bg652agq.js +20 -11
  220. package/dist/management-BnedF5ZD.cjs +50 -50
  221. package/dist/management-BoUa99eB.cjs +79 -0
  222. package/dist/management-BoUa99eB.cjs.map +1 -0
  223. package/dist/management-C4SHcrJm.cjs +79 -0
  224. package/dist/management-C4SHcrJm.cjs.map +1 -0
  225. package/dist/management-CK-GL3wY.js +20 -11
  226. package/dist/management-CPhgY8OE.js +41 -0
  227. package/dist/management-CPhgY8OE.js.map +1 -0
  228. package/dist/management-CU_V3LIP.js +20 -11
  229. package/dist/management-CUwXDSi9.cjs +79 -0
  230. package/dist/management-CUwXDSi9.cjs.map +1 -0
  231. package/dist/management-CaqiyNzB.js +20 -11
  232. package/dist/management-Cin-JvYe.js +20 -11
  233. package/dist/management-ClaXym0F.cjs +50 -50
  234. package/dist/management-DL0Uzsoz.js +20 -11
  235. package/dist/management-DLdAQfqk.cjs +79 -0
  236. package/dist/management-DLdAQfqk.cjs.map +1 -0
  237. package/dist/management-DMZ8qpwr.cjs +50 -50
  238. package/dist/management-DTzcC6aD.cjs +79 -0
  239. package/dist/management-DTzcC6aD.cjs.map +1 -0
  240. package/dist/management-DYLNyj9p.cjs +50 -50
  241. package/dist/management-Dag9u4t6.cjs +50 -50
  242. package/dist/management-DbMRdDBo.cjs +50 -50
  243. package/dist/management-DfnDAKmP.js +41 -0
  244. package/dist/management-DfnDAKmP.js.map +1 -0
  245. package/dist/management-DjBU1gtb.cjs +50 -50
  246. package/dist/management-DwCozsY8.js +20 -11
  247. package/dist/management-H4m3ciJO.js +32 -0
  248. package/dist/management-H4m3ciJO.js.map +1 -0
  249. package/dist/management-Xo3A6Za3.cjs +79 -0
  250. package/dist/management-Xo3A6Za3.cjs.map +1 -0
  251. package/dist/management-ZU2YzOkr.js +18 -10
  252. package/dist/management-baPDwA9n.cjs +50 -50
  253. package/dist/management-jQGCvZNN.cjs +44 -44
  254. package/dist/management-ry_KteFK.cjs +50 -50
  255. package/dist/plugin/BlacPlugin.d.ts +89 -15
  256. package/dist/plugin/PluginManager.d.ts +65 -5
  257. package/dist/plugins.cjs +1 -1
  258. package/dist/plugins.d.cts +2 -2
  259. package/dist/plugins.d.ts +2 -2
  260. package/dist/plugins.js +1 -1
  261. package/dist/registry/acquire.d.ts +9 -2
  262. package/dist/registry/ensure.d.ts +2 -2
  263. package/dist/registry/index.d.ts +1 -1
  264. package/dist/resolve-dependencies-B2QggQAi.js +641 -558
  265. package/dist/resolve-dependencies-B6JDXvpr.js +651 -566
  266. package/dist/resolve-dependencies-BAKAoD0U.js +878 -0
  267. package/dist/resolve-dependencies-BAKAoD0U.js.map +1 -0
  268. package/dist/resolve-dependencies-BFZQq60Y.cjs +724 -666
  269. package/dist/resolve-dependencies-BGafS3Ww.js +643 -561
  270. package/dist/resolve-dependencies-BHd34gS3.cjs +724 -666
  271. package/dist/resolve-dependencies-BNeayhbQ.cjs +732 -671
  272. package/dist/resolve-dependencies-BWEMpuDy.js +641 -558
  273. package/dist/resolve-dependencies-BiWkW2eS.js +643 -561
  274. package/dist/resolve-dependencies-BjxCztYD.js +739 -0
  275. package/dist/resolve-dependencies-BjxCztYD.js.map +1 -0
  276. package/dist/resolve-dependencies-BlyBV0hB.cjs +969 -0
  277. package/dist/resolve-dependencies-BlyBV0hB.cjs.map +1 -0
  278. package/dist/resolve-dependencies-By26rT_i.js +651 -566
  279. package/dist/resolve-dependencies-C9Kf7AzY.cjs +724 -666
  280. package/dist/resolve-dependencies-CTzV1txG.js +643 -561
  281. package/dist/resolve-dependencies-CWjuGHiF.cjs +969 -0
  282. package/dist/resolve-dependencies-CWjuGHiF.cjs.map +1 -0
  283. package/dist/resolve-dependencies-ClSsP0DJ.cjs +722 -663
  284. package/dist/resolve-dependencies-D0vTzZgs.js +643 -561
  285. package/dist/resolve-dependencies-D2WnZMF-.cjs +724 -666
  286. package/dist/resolve-dependencies-DCBLTeza.cjs +969 -0
  287. package/dist/resolve-dependencies-DCBLTeza.cjs.map +1 -0
  288. package/dist/resolve-dependencies-DMlqYJR2.js +643 -561
  289. package/dist/resolve-dependencies-DP6U1EYB.cjs +840 -0
  290. package/dist/resolve-dependencies-DP6U1EYB.cjs.map +1 -0
  291. package/dist/resolve-dependencies-DSQNXvnV.cjs +724 -666
  292. package/dist/resolve-dependencies-DV3HO_uH.js +878 -0
  293. package/dist/resolve-dependencies-DV3HO_uH.js.map +1 -0
  294. package/dist/resolve-dependencies-DXwMhP0Y.js +878 -0
  295. package/dist/resolve-dependencies-DXwMhP0Y.js.map +1 -0
  296. package/dist/resolve-dependencies-DbRWlt9u.js +878 -0
  297. package/dist/resolve-dependencies-DbRWlt9u.js.map +1 -0
  298. package/dist/resolve-dependencies-DcUUva2P.cjs +724 -666
  299. package/dist/resolve-dependencies-Dd8T6TLt.cjs +724 -666
  300. package/dist/resolve-dependencies-Dfdp_DZd.cjs +732 -671
  301. package/dist/resolve-dependencies-GJ8PNyNB.cjs +969 -0
  302. package/dist/resolve-dependencies-GJ8PNyNB.cjs.map +1 -0
  303. package/dist/resolve-dependencies-KSpTt4jy.cjs +722 -663
  304. package/dist/resolve-dependencies-Nvjp4CwS.js +643 -561
  305. package/dist/resolve-dependencies-f-QUqYiL.js +643 -561
  306. package/dist/testing.cjs +27 -20
  307. package/dist/testing.cjs.map +1 -1
  308. package/dist/testing.d.cts +22 -1
  309. package/dist/testing.d.ts +22 -1
  310. package/dist/testing.js +27 -21
  311. package/dist/testing.js.map +1 -1
  312. package/dist/tracked-B77j2g9M.js +171 -151
  313. package/dist/tracked-BDVi2LKM.cjs +196 -175
  314. package/dist/tracked-BFdJCzL0.cjs +242 -0
  315. package/dist/tracked-BFdJCzL0.cjs.map +1 -0
  316. package/dist/tracked-BH-gX4T1.cjs +196 -175
  317. package/dist/tracked-BTHok3Dl.cjs +196 -175
  318. package/dist/tracked-BTbFkFeM.js +186 -166
  319. package/dist/tracked-BU_OBWqM.cjs +242 -0
  320. package/dist/tracked-BU_OBWqM.cjs.map +1 -0
  321. package/dist/tracked-BfctH2es.cjs +242 -0
  322. package/dist/tracked-BfctH2es.cjs.map +1 -0
  323. package/dist/tracked-BhQtzUhZ.js +186 -166
  324. package/dist/tracked-BnqrYXiO.js +212 -0
  325. package/dist/tracked-BnqrYXiO.js.map +1 -0
  326. package/dist/tracked-BtgFOGup.js +212 -0
  327. package/dist/tracked-BtgFOGup.js.map +1 -0
  328. package/dist/tracked-C3nIS4J7.cjs +242 -0
  329. package/dist/tracked-C3nIS4J7.cjs.map +1 -0
  330. package/dist/tracked-C52awNV9.js +171 -151
  331. package/dist/tracked-CGzduF2m.js +186 -166
  332. package/dist/tracked-CK_-ixtX.cjs +196 -175
  333. package/dist/tracked-CLlvURln.js +186 -166
  334. package/dist/tracked-CgHWmuGC.cjs +211 -190
  335. package/dist/tracked-CoAlC8fs.js +171 -151
  336. package/dist/tracked-D3Xjm1H1.cjs +211 -190
  337. package/dist/tracked-DB6yMV5F.js +212 -0
  338. package/dist/tracked-DB6yMV5F.js.map +1 -0
  339. package/dist/tracked-DBn-bs_G.js +171 -151
  340. package/dist/tracked-DMBTDF0P.js +171 -151
  341. package/dist/tracked-DN3h3Rp1.js +171 -151
  342. package/dist/tracked-DOGh1Q5Z.cjs +242 -0
  343. package/dist/tracked-DOGh1Q5Z.cjs.map +1 -0
  344. package/dist/tracked-DUkp4zve.cjs +196 -175
  345. package/dist/tracked-D_ou7mYG.js +212 -0
  346. package/dist/tracked-D_ou7mYG.js.map +1 -0
  347. package/dist/tracked-Dcu6EATB.js +171 -151
  348. package/dist/tracked-GvAJQVAI.cjs +227 -196
  349. package/dist/tracked-O2lv-kJV.cjs +211 -190
  350. package/dist/tracked-WF6aXuAo.js +186 -162
  351. package/dist/tracked-d_sQWU3c.cjs +196 -175
  352. package/dist/tracked-n9TMK-30.cjs +196 -175
  353. package/dist/tracked-njU-_pVa.cjs +211 -190
  354. package/dist/tracked-zAgmKIlC.js +212 -0
  355. package/dist/tracked-zAgmKIlC.js.map +1 -0
  356. package/dist/tracking/dependency-manager.d.ts +33 -29
  357. package/dist/tracking/index.d.ts +16 -1
  358. package/dist/tracking/iteration-perf.bench.d.ts +1 -0
  359. package/dist/tracking/path-utils.d.ts +18 -1
  360. package/dist/tracking/resolve-dependencies.d.ts +3 -1
  361. package/dist/tracking/tracked.d.ts +37 -34
  362. package/dist/tracking/tracking-proxy.d.ts +94 -47
  363. package/dist/tracking.cjs +12 -9
  364. package/dist/tracking.js +32 -2
  365. package/dist/types/utilities.d.ts +15 -3
  366. package/dist/types.cjs +1 -1
  367. package/dist/types.js +1 -1
  368. package/dist/utils/static-props.d.ts +14 -0
  369. package/dist/utils/structural-key.d.ts +14 -0
  370. package/dist/watch/watch.d.ts +1 -1
  371. package/dist/watch-BpwaUL8r.cjs +68 -0
  372. package/dist/watch-BpwaUL8r.cjs.map +1 -0
  373. package/dist/watch-DWCqXllW.js +57 -0
  374. package/dist/watch-DWCqXllW.js.map +1 -0
  375. package/dist/watch-entry.cjs +3 -6
  376. package/dist/watch-entry.d.cts +1 -3
  377. package/dist/watch-entry.d.ts +1 -3
  378. package/dist/watch-entry.js +2 -2
  379. package/package.json +4 -14
@@ -0,0 +1,1030 @@
1
+ //#region src/config.ts
2
+ /**
3
+ * Default equality: shallow per-key `Object.is` comparison.
4
+ * Falls through to `false` for primitives/null so reference-only state still
5
+ * behaves correctly.
6
+ */
7
+ const shallowEqualState = (prev, next) => {
8
+ if (Object.is(prev, next)) return true;
9
+ if (typeof prev !== 'object' || prev === null) return false;
10
+ if (typeof next !== 'object' || next === null) return false;
11
+ const prevKeys = Object.keys(prev);
12
+ if (prevKeys.length !== Object.keys(next).length) return false;
13
+ for (let i = 0; i < prevKeys.length; i++) {
14
+ const key = prevKeys[i];
15
+ if (!Object.is(prev[key], next[key])) return false;
16
+ }
17
+ return true;
18
+ };
19
+ const defaultConfig = {
20
+ equality: shallowEqualState,
21
+ maxInstancesPerType: 1e3,
22
+ maxRefsPerInstance: 1e3,
23
+ maxEmitsPerSecond: 100,
24
+ };
25
+ let globalConfig = { ...defaultConfig };
26
+ /**
27
+ * Configure global defaults for @blac/core.
28
+ *
29
+ * @example
30
+ * ```ts
31
+ * import { configureBlac, shallowEqualState } from '@blac/core';
32
+ *
33
+ * // Swap in a deep-equality check for all blocs
34
+ * configureBlac({ equality: myDeepEqual });
35
+ * ```
36
+ */
37
+ function configureBlac(config) {
38
+ globalConfig = {
39
+ ...globalConfig,
40
+ ...config,
41
+ };
42
+ }
43
+ /**
44
+ * Get the current global configuration.
45
+ * @internal
46
+ */
47
+ function getBlacConfig() {
48
+ return globalConfig;
49
+ }
50
+ /**
51
+ * Reset configuration to defaults (useful for testing).
52
+ * @internal
53
+ */
54
+ function resetBlacConfig() {
55
+ globalConfig = { ...defaultConfig };
56
+ }
57
+ //#endregion
58
+ //#region src/constants.ts
59
+ /**
60
+ * Default configuration constants for BlaC
61
+ *
62
+ * Centralized location for all magic numbers and default values.
63
+ */
64
+ /**
65
+ * Default configuration constants for BlaC
66
+ */
67
+ const BLAC_DEFAULTS = {
68
+ DEFAULT_INSTANCE_KEY: 'default',
69
+ MAX_GETTER_DEPTH: 10,
70
+ };
71
+ /**
72
+ * Static property names for StateContainer classes
73
+ * Used for feature flags and configuration on bloc classes
74
+ */
75
+ const BLAC_STATIC_PROPS = {
76
+ KEEP_ALIVE: 'keepAlive',
77
+ EXCLUDE_FROM_DEVTOOLS: '__excludeFromDevTools',
78
+ ISOLATED: 'isolated',
79
+ EQUALITY: '__equality',
80
+ KEY: 'key',
81
+ };
82
+ /**
83
+ * Standard error message prefix
84
+ */
85
+ const BLAC_ERROR_PREFIX = '[BlaC]';
86
+ //#endregion
87
+ //#region src/plugin/PluginManager.ts
88
+ /**
89
+ * Manages plugin lifecycle for the BlaC state management system.
90
+ * Plugins receive notifications about state container lifecycle events.
91
+ *
92
+ * @example
93
+ * ```ts
94
+ * const manager = createPluginManager(registry);
95
+ * manager.install(myPlugin, { environment: 'development' });
96
+ * ```
97
+ */
98
+ var PluginManager = class {
99
+ /**
100
+ * Create a new PluginManager
101
+ * @param registry - The StateContainerRegistry to monitor for lifecycle events
102
+ */
103
+ constructor(registry) {
104
+ this.plugins = /* @__PURE__ */ new Map();
105
+ this.lifecycleUnsubscribers = [];
106
+ this.registry = registry;
107
+ this.setupLifecycleHooks();
108
+ }
109
+ /**
110
+ * Install a plugin with optional configuration
111
+ * @param plugin - The plugin to install
112
+ * @param config - Optional plugin configuration
113
+ * @throws Error if plugin is already installed
114
+ */
115
+ install(plugin, config = {}) {
116
+ const effectiveConfig = {
117
+ enabled: true,
118
+ environment: 'all',
119
+ ...config,
120
+ };
121
+ if (!this.shouldEnablePlugin(effectiveConfig)) {
122
+ console.log(
123
+ `[BlaC] Plugin "${plugin.name}" skipped (environment mismatch)`,
124
+ );
125
+ return;
126
+ }
127
+ if (this.plugins.has(plugin.name))
128
+ throw new Error(`Plugin "${plugin.name}" is already installed`);
129
+ const context = this.createPluginContext();
130
+ this.plugins.set(plugin.name, {
131
+ plugin,
132
+ config: effectiveConfig,
133
+ context,
134
+ });
135
+ if (plugin.onInstall)
136
+ try {
137
+ plugin.onInstall(context);
138
+ } catch (error) {
139
+ console.error(
140
+ `[BlaC] Error installing plugin "${plugin.name}":`,
141
+ error,
142
+ );
143
+ this.plugins.delete(plugin.name);
144
+ throw error;
145
+ }
146
+ console.log(`[BlaC] Plugin "${plugin.name}" v${plugin.version} installed`);
147
+ }
148
+ /**
149
+ * Uninstall a plugin by name
150
+ * @param pluginName - The name of the plugin to uninstall
151
+ * @throws Error if plugin is not installed
152
+ */
153
+ uninstall(pluginName) {
154
+ const installed = this.plugins.get(pluginName);
155
+ if (!installed) throw new Error(`Plugin "${pluginName}" is not installed`);
156
+ if (installed.plugin.onUninstall)
157
+ try {
158
+ installed.plugin.onUninstall();
159
+ } catch (error) {
160
+ console.error(
161
+ `[BlaC] Error uninstalling plugin "${pluginName}":`,
162
+ error,
163
+ );
164
+ }
165
+ this.plugins.delete(pluginName);
166
+ console.log(`[BlaC] Plugin "${pluginName}" uninstalled`);
167
+ }
168
+ /**
169
+ * Get an installed plugin by name
170
+ * @param pluginName - The name of the plugin to retrieve
171
+ * @returns The plugin instance or undefined if not found
172
+ */
173
+ getPlugin(pluginName) {
174
+ return this.plugins.get(pluginName)?.plugin;
175
+ }
176
+ /**
177
+ * Get all installed plugins
178
+ * @returns Array of all installed plugins
179
+ */
180
+ getAllPlugins() {
181
+ return Array.from(this.plugins.values()).map((p) => p.plugin);
182
+ }
183
+ /**
184
+ * Check if a plugin is installed
185
+ * @param pluginName - The name of the plugin to check
186
+ * @returns true if the plugin is installed
187
+ */
188
+ hasPlugin(pluginName) {
189
+ return this.plugins.has(pluginName);
190
+ }
191
+ /**
192
+ * Uninstall all plugins
193
+ */
194
+ clear() {
195
+ for (const name of this.plugins.keys()) this.uninstall(name);
196
+ }
197
+ destroy() {
198
+ this.clear();
199
+ for (const unsub of this.lifecycleUnsubscribers) unsub();
200
+ this.lifecycleUnsubscribers = [];
201
+ }
202
+ /**
203
+ * Setup lifecycle hooks to notify plugins
204
+ */
205
+ setupLifecycleHooks() {
206
+ this.lifecycleUnsubscribers = [
207
+ this.registry.on('created', (instance) => {
208
+ this.notifyPlugins('onInstanceCreated', instance);
209
+ }),
210
+ this.registry.on(
211
+ 'stateChanged',
212
+ (instance, previousState, currentState) => {
213
+ this.notifyPlugins(
214
+ 'onStateChanged',
215
+ instance,
216
+ previousState,
217
+ currentState,
218
+ );
219
+ },
220
+ ),
221
+ this.registry.on('disposed', (instance) => {
222
+ this.notifyPlugins('onInstanceDisposed', instance);
223
+ }),
224
+ this.registry.on('refAcquired', (instance, refId) => {
225
+ this.notifyPlugins('onRefAcquired', instance, refId);
226
+ }),
227
+ this.registry.on('refReleased', (instance, refId) => {
228
+ this.notifyPlugins('onRefReleased', instance, refId);
229
+ }),
230
+ ];
231
+ }
232
+ /**
233
+ * Notify all plugins of a lifecycle event
234
+ */
235
+ notifyPlugins(hookName, ...args) {
236
+ for (const { plugin, config, context } of this.plugins.values()) {
237
+ if (!config.enabled) continue;
238
+ const hook = plugin[hookName];
239
+ if (typeof hook === 'function')
240
+ try {
241
+ hook.apply(plugin, [...args, context]);
242
+ } catch (error) {
243
+ console.error(
244
+ `[BlaC] Error in plugin "${plugin.name}" ${hookName}:`,
245
+ error,
246
+ );
247
+ }
248
+ }
249
+ }
250
+ /**
251
+ * Create plugin context with safe API access
252
+ */
253
+ createPluginContext() {
254
+ return {
255
+ getInstanceMetadata: (instance) => {
256
+ return {
257
+ id: instance.instanceId,
258
+ className: instance.constructor.name,
259
+ isDisposed: instance.isDisposed,
260
+ name: instance.name,
261
+ createdAt: instance.createdAt,
262
+ state: instance.state,
263
+ hydrationStatus: instance.hydrationStatus,
264
+ isHydrated: instance.isHydrated,
265
+ hydrationError: instance.hydrationError,
266
+ changedWhileHydrating: instance.changedWhileHydrating,
267
+ };
268
+ },
269
+ getState: (instance) => {
270
+ return instance.state;
271
+ },
272
+ getHydrationStatus: (instance) => {
273
+ return instance.hydrationStatus;
274
+ },
275
+ startHydration: (instance) => {
276
+ instance.beginHydration();
277
+ },
278
+ applyHydratedState: (instance, state) => {
279
+ return instance.applyHydratedState(state);
280
+ },
281
+ finishHydration: (instance) => {
282
+ instance.finishHydration();
283
+ },
284
+ failHydration: (instance, error) => {
285
+ instance.failHydration(error);
286
+ },
287
+ waitForHydration: (instance) => {
288
+ return instance.waitForHydration();
289
+ },
290
+ queryInstances: (typeClass) => {
291
+ return this.registry.getAll(typeClass);
292
+ },
293
+ getAllTypes: () => {
294
+ return this.registry.getTypes();
295
+ },
296
+ getStats: () => {
297
+ return this.registry.getStats();
298
+ },
299
+ getRefIds: (instanceId) => {
300
+ for (const Type of this.registry.getTypes()) {
301
+ const map = this.registry.getInstancesMap(Type);
302
+ for (const [, entry] of map)
303
+ if (entry.instance.instanceId === instanceId)
304
+ return Array.from(entry.refs.keys());
305
+ }
306
+ return [];
307
+ },
308
+ };
309
+ }
310
+ /**
311
+ * Check if plugin should be enabled based on environment
312
+ */
313
+ shouldEnablePlugin(config) {
314
+ if (!config.enabled) return false;
315
+ if (config.environment === 'all') return true;
316
+ return this.getCurrentEnvironment() === config.environment;
317
+ }
318
+ /**
319
+ * Get current environment
320
+ */
321
+ getCurrentEnvironment() {
322
+ if (typeof process !== 'undefined') {
323
+ if (process.env.NODE_ENV === 'test') return 'test';
324
+ if (process.env.NODE_ENV === 'production') return 'production';
325
+ return 'development';
326
+ }
327
+ return 'development';
328
+ }
329
+ };
330
+ /**
331
+ * Create a plugin manager instance
332
+ * @param registry - The StateContainerRegistry to monitor for lifecycle events
333
+ * @returns A new PluginManager instance
334
+ */
335
+ function createPluginManager(registry) {
336
+ return new PluginManager(registry);
337
+ }
338
+ //#endregion
339
+ //#region src/utils/static-props.ts
340
+ /**
341
+ * Utility functions for accessing static properties on StateContainer classes
342
+ */
343
+ /**
344
+ * Get a static property from a class constructor
345
+ * Type-safe helper that avoids (Type as any) casts
346
+ *
347
+ * @param Type - The class constructor
348
+ * @param propName - The property name to access
349
+ * @param defaultValue - Optional default value if property is undefined
350
+ * @returns The property value or default
351
+ */
352
+ function getStaticProp(Type, propName, defaultValue) {
353
+ return Type[propName] ?? defaultValue;
354
+ }
355
+ /**
356
+ * Check if a class is marked as keepAlive.
357
+ * KeepAlive classes are never auto-disposed when ref count reaches 0.
358
+ * @param Type - The class constructor to check
359
+ * @returns true if the class has `static keepAlive = true`
360
+ */
361
+ function isKeepAliveClass(Type) {
362
+ return getStaticProp(Type, BLAC_STATIC_PROPS.KEEP_ALIVE) === true;
363
+ }
364
+ /**
365
+ * Check if a class should be excluded from DevTools.
366
+ * Used to prevent infinite loops when DevTools tracks itself.
367
+ * @param Type - The class constructor to check
368
+ * @returns true if the class has `static __excludeFromDevTools = true`
369
+ */
370
+ function isExcludedFromDevTools(Type) {
371
+ return getStaticProp(Type, BLAC_STATIC_PROPS.EXCLUDE_FROM_DEVTOOLS) === true;
372
+ }
373
+ /**
374
+ * Check if a class is marked as isolated.
375
+ * Isolated classes get a fresh, per-mount instance from `useBloc`
376
+ * (auto-keyed via React's `useId()`), instead of sharing the default
377
+ * instance with sibling call sites.
378
+ * @param Type - The class constructor to check
379
+ * @returns true if the class has `static isolated = true`
380
+ */
381
+ function isIsolatedClass(Type) {
382
+ return getStaticProp(Type, BLAC_STATIC_PROPS.ISOLATED) === true;
383
+ }
384
+ /**
385
+ * Get the per-class equality function set via `@blac({ equality })`, if any.
386
+ * @param Type - The class constructor to check
387
+ * @returns the equality function or `undefined`
388
+ */
389
+ function getClassEquality(Type) {
390
+ const fn = getStaticProp(Type, BLAC_STATIC_PROPS.EQUALITY);
391
+ return typeof fn === 'function' ? fn : void 0;
392
+ }
393
+ /**
394
+ * Get the per-class key function set via `@blac({ key })` or `static key = …`, if any.
395
+ * Used by the registry to derive a stable instance key from `args`.
396
+ * @param Type - The class constructor to check
397
+ * @returns the key function or `undefined`
398
+ */
399
+ function getClassKey(Type) {
400
+ const fn = getStaticProp(Type, BLAC_STATIC_PROPS.KEY, void 0);
401
+ return typeof fn === 'function' ? fn : void 0;
402
+ }
403
+ //#endregion
404
+ //#region src/utils/structural-key.ts
405
+ /**
406
+ * Deterministic, order-independent hash of serializable args.
407
+ * Sorts object keys so {a,b} === {b,a}.
408
+ * Throws (dev) if it encounters a function or non-plain object — those belong in `deps`.
409
+ */
410
+ const DEFAULT_STRUCTURAL_KEY = 'default';
411
+ /**
412
+ * Produce a stable string key for serializable args.
413
+ * - `undefined` / `void` args → `'default'` sentinel (no-args blocs stay on the default key).
414
+ * - Object keys are sorted for order-independence.
415
+ * - Arrays keep their insertion order.
416
+ * - Functions throw — they must be passed via `deps`, not `args`.
417
+ */
418
+ function structuralKey(args) {
419
+ if (args === void 0 || args === null) return DEFAULT_STRUCTURAL_KEY;
420
+ return JSON.stringify(args, function (_k, v) {
421
+ if (typeof v === 'function')
422
+ throw new Error(
423
+ '[blac] args must be serializable; put refs/callbacks in `deps`',
424
+ );
425
+ if (v && typeof v === 'object' && !Array.isArray(v))
426
+ return Object.keys(v)
427
+ .sort()
428
+ .reduce((o, k) => {
429
+ o[k] = v[k];
430
+ return o;
431
+ }, {});
432
+ return v;
433
+ });
434
+ }
435
+ //#endregion
436
+ //#region src/core/StateContainerRegistry.ts
437
+ /**
438
+ * Central registry for managing StateContainer instances.
439
+ * Handles instance lifecycle, named ref tracking, and lifecycle event emission.
440
+ *
441
+ * @example
442
+ * ```ts
443
+ * const registry = new StateContainerRegistry();
444
+ * const instance = registry.acquire(MyBloc); // ownership, must release
445
+ * const other = registry.ensure(OtherBloc); // no ownership, bloc-to-bloc
446
+ * registry.on('stateChanged', (container, prev, next) => {
447
+ * console.log('State changed:', prev, '->', next);
448
+ * });
449
+ * ```
450
+ */
451
+ var StateContainerRegistry = class {
452
+ constructor() {
453
+ this.instancesByConstructor = /* @__PURE__ */ new WeakMap();
454
+ this.types = /* @__PURE__ */ new Set();
455
+ this.registeredTypeNames = /* @__PURE__ */ new Set();
456
+ this.listeners = /* @__PURE__ */ new Map();
457
+ this._stateChangedListenerCount = 0;
458
+ this._pendingStateChanges = null;
459
+ this._autoRefIdCounter = 0;
460
+ }
461
+ get hasStateChangedListeners() {
462
+ return this._stateChangedListenerCount > 0;
463
+ }
464
+ /**
465
+ * Register a type for lifecycle event tracking
466
+ * @param constructor - The StateContainer class constructor
467
+ */
468
+ registerType(constructor) {
469
+ this.types.add(constructor);
470
+ }
471
+ /**
472
+ * Register a StateContainer class with configuration
473
+ * @param constructor - The StateContainer class constructor
474
+ * @throws Error if type is already registered
475
+ */
476
+ register(constructor) {
477
+ const className = constructor.name;
478
+ if (this.registeredTypeNames.has(className))
479
+ throw new Error(
480
+ `${BLAC_ERROR_PREFIX} Type "${className}" is already registered`,
481
+ );
482
+ this.registeredTypeNames.add(className);
483
+ this.registerType(constructor);
484
+ }
485
+ ensureInstancesMap(Type) {
486
+ let instances = this.instancesByConstructor.get(Type);
487
+ if (!instances) {
488
+ instances = /* @__PURE__ */ new Map();
489
+ this.instancesByConstructor.set(Type, instances);
490
+ }
491
+ return instances;
492
+ }
493
+ /**
494
+ * Get the instances Map for a specific class (public API for stats/debugging)
495
+ */
496
+ getInstancesMap(Type) {
497
+ return this.instancesByConstructor.get(Type) || /* @__PURE__ */ new Map();
498
+ }
499
+ /**
500
+ * Directly insert an instance entry into the registry without going through
501
+ * acquire/release. Creates the internal WeakMap bucket for the constructor if
502
+ * it does not exist yet. Replaces any existing entry for the same key.
503
+ *
504
+ * The provided instance is NOT configured or disposed here — callers are
505
+ * responsible for any initConfig / dispose calls. Intended for testing
506
+ * helpers that create stubs outside the normal acquisition path.
507
+ *
508
+ * @internal Used by testing helpers only.
509
+ */
510
+ insertInstance(
511
+ Type,
512
+ instanceKey,
513
+ instance,
514
+ refs = /* @__PURE__ */ new Map(),
515
+ ) {
516
+ const instances = this.ensureInstancesMap(Type);
517
+ const existingEntry = instances.get(instanceKey);
518
+ if (
519
+ existingEntry &&
520
+ existingEntry.instance !== instance &&
521
+ !existingEntry.instance.isDisposed
522
+ )
523
+ existingEntry.instance.dispose();
524
+ instances.set(instanceKey, {
525
+ instance,
526
+ refs,
527
+ });
528
+ }
529
+ /**
530
+ * Resolve the storage key for an instance. This is the single source of truth
531
+ * for keying — `acquire` and `release` MUST agree, otherwise a ref taken under
532
+ * an args-derived key is never dropped (instance leaks).
533
+ *
534
+ * Resolution order (explicit beats derived):
535
+ * explicit key > `static key(args)` > structural hash of args > default sentinel.
536
+ *
537
+ * @param Type - The StateContainer class constructor
538
+ * @param instanceKey - Explicit key, or undefined to derive from args
539
+ * @param args - Construction args used for structural/`static key` derivation
540
+ */
541
+ resolveKey(Type, instanceKey, args) {
542
+ if (instanceKey !== void 0) return instanceKey;
543
+ const keyFn = getClassKey(Type);
544
+ if (keyFn) return keyFn(args);
545
+ if (args !== void 0) return structuralKey(args);
546
+ return DEFAULT_STRUCTURAL_KEY;
547
+ }
548
+ /**
549
+ * Circuit breaker for runaway instance creation. Throws when a single
550
+ * constructor would exceed `maxInstancesPerType` live instances — almost
551
+ * always an unstable instance key (e.g. a new object/array passed as `args`
552
+ * every render, or a missing `static key`) leaking an instance per render.
553
+ */
554
+ assertInstanceLimit(Type, currentCount) {
555
+ const limit = getBlacConfig().maxInstancesPerType;
556
+ if (limit > 0 && currentCount >= limit)
557
+ throw new Error(
558
+ `${BLAC_ERROR_PREFIX} ${Type.name} exceeded the maximum of ${limit} live instances. This usually means the instance key is unstable — e.g. \`args\` that change identity every render, or a missing \`static key\` — so a new instance is created and never disposed (memory leak). Stabilize the key, add a \`static key(args)\`, or raise \`configureBlac({ maxInstancesPerType })\`.`,
559
+ );
560
+ }
561
+ /**
562
+ * Circuit breaker for runaway reference growth. Throws when one instance
563
+ * accumulates more than `maxRefsPerInstance` distinct live refs — almost
564
+ * always consumer cleanup (e.g. `useBloc`'s unmount `release`) never firing.
565
+ */
566
+ assertRefLimit(Type, resolvedKey, refCount) {
567
+ const limit = getBlacConfig().maxRefsPerInstance;
568
+ if (limit > 0 && refCount > limit)
569
+ throw new Error(
570
+ `${BLAC_ERROR_PREFIX} ${Type.name} instance "${resolvedKey}" exceeded the maximum of ${limit} live references. This usually means references are acquired without a matching release (e.g. a consumer that never unmounts/cleans up), leaking refs that keep the instance alive forever. Ensure every acquire is paired with a release, or raise \`configureBlac({ maxRefsPerInstance })\`.`,
571
+ );
572
+ }
573
+ /**
574
+ * Acquire an instance with ref tracking (ownership semantics).
575
+ * Creates a new instance if one doesn't exist, or returns existing and adds a ref.
576
+ * You must call `release()` with the same refId when done.
577
+ * @param Type - The StateContainer class constructor
578
+ * @param instanceKey - Instance key (defaults to 'default')
579
+ * @param options - Acquisition options
580
+ * @param options.canCreate - Whether to create new instance if not found (default: true)
581
+ * @param options.countRef - Whether to add a reference (default: true)
582
+ * @param options.refId - Named reference ID for debugging; auto-generated if omitted
583
+ * @returns The state container instance
584
+ */
585
+ acquire(Type, instanceKey = void 0, options = {}) {
586
+ const { canCreate = true, countRef = true } = options;
587
+ const args = options.args;
588
+ const resolvedKey = this.resolveKey(Type, instanceKey, args);
589
+ const config = {
590
+ instanceId: resolvedKey,
591
+ args,
592
+ };
593
+ const instances = this.ensureInstancesMap(Type);
594
+ let entry = instances.get(resolvedKey);
595
+ if (entry?.instance.isDisposed) {
596
+ instances.delete(resolvedKey);
597
+ entry = void 0;
598
+ }
599
+ if (entry) {
600
+ if (
601
+ process.env.NODE_ENV !== 'production' &&
602
+ args !== void 0 &&
603
+ entry.args !== void 0
604
+ ) {
605
+ const incomingKey = structuralKey(args);
606
+ const storedKey = structuralKey(entry.args);
607
+ if (incomingKey !== storedKey)
608
+ console.warn(
609
+ `${BLAC_ERROR_PREFIX} ${Type.name} instance key "${resolvedKey}" was acquired with different args. Existing args: ${storedKey}, new args: ${incomingKey}. The existing instance will be reused. If distinct args should produce distinct instances, either remove the explicit instanceKey or provide a \`static key\` function that reflects the difference.`,
610
+ );
611
+ }
612
+ if (countRef) {
613
+ const refId = options.refId ?? `_auto_${this._autoRefIdCounter++}`;
614
+ entry.refs.set(refId, (entry.refs.get(refId) ?? 0) + 1);
615
+ this.assertRefLimit(Type, resolvedKey, entry.refs.size);
616
+ this.emit('refAcquired', entry.instance, refId);
617
+ }
618
+ return entry.instance;
619
+ }
620
+ if (!canCreate)
621
+ throw new Error(
622
+ `${BLAC_ERROR_PREFIX} ${Type.name} instance "${resolvedKey}" not found and creation is disabled.`,
623
+ );
624
+ this.assertInstanceLimit(Type, instances.size);
625
+ const instance = new Type();
626
+ instance.initConfig(config);
627
+ const initialRefs = /* @__PURE__ */ new Map();
628
+ let initialRefId;
629
+ if (countRef) {
630
+ initialRefId = options.refId ?? `_auto_${this._autoRefIdCounter++}`;
631
+ initialRefs.set(initialRefId, 1);
632
+ }
633
+ instances.set(resolvedKey, {
634
+ instance,
635
+ refs: initialRefs,
636
+ args,
637
+ });
638
+ this.registerType(Type);
639
+ if (initialRefId) this.emit('refAcquired', instance, initialRefId);
640
+ return instance;
641
+ }
642
+ /**
643
+ * Borrow an existing instance without adding a ref (borrowing semantics).
644
+ * Tracks cross-bloc dependency for reactive updates.
645
+ * @param Type - The StateContainer class constructor
646
+ * @param instanceKey - Instance key (defaults to 'default')
647
+ * @returns The state container instance
648
+ * @throws Error if instance doesn't exist
649
+ */
650
+ borrow(Type, instanceKey = BLAC_DEFAULTS.DEFAULT_INSTANCE_KEY) {
651
+ return this.acquire(Type, instanceKey, {
652
+ canCreate: false,
653
+ countRef: false,
654
+ });
655
+ }
656
+ /**
657
+ * Safely borrow an existing instance (borrowing semantics with error handling).
658
+ * Returns discriminated union for type-safe conditional access.
659
+ * @param Type - The StateContainer class constructor
660
+ * @param instanceKey - Instance key (defaults to 'default')
661
+ * @returns Discriminated union with either the instance or an error
662
+ */
663
+ borrowSafe(Type, instanceKey = BLAC_DEFAULTS.DEFAULT_INSTANCE_KEY) {
664
+ try {
665
+ return {
666
+ error: null,
667
+ instance: this.borrow(Type, instanceKey),
668
+ };
669
+ } catch (error) {
670
+ return {
671
+ error,
672
+ instance: null,
673
+ };
674
+ }
675
+ }
676
+ /**
677
+ * Ensure an instance exists without taking ownership (for bloc-to-bloc communication).
678
+ * Gets existing instance OR creates it if it doesn't exist, without adding a ref.
679
+ * Tracks cross-bloc dependency for reactive updates.
680
+ *
681
+ * Use this in bloc-to-bloc communication when you need to ensure an instance exists
682
+ * but don't want to claim ownership (no ref added).
683
+ * @param Type - The StateContainer class constructor
684
+ * @param instanceKey - Explicit instance key, or undefined to derive from `args`
685
+ * (`static key(args)` / structural hash), matching `acquire`.
686
+ * @param args - Construction args; used for keying when no explicit key is given
687
+ * @returns The state container instance
688
+ */
689
+ ensure(Type, instanceKey = void 0, args) {
690
+ return this.acquire(Type, instanceKey, {
691
+ canCreate: true,
692
+ countRef: false,
693
+ args,
694
+ });
695
+ }
696
+ /**
697
+ * Release a reference to an instance.
698
+ * Removes the ref and disposes when refs is empty (unless keepAlive).
699
+ * Releasing an already-removed refId is a no-op (idempotent).
700
+ * @param Type - The StateContainer class constructor
701
+ * @param instanceKey - Instance key (defaults to 'default')
702
+ * @param forceDispose - Force immediate disposal regardless of refs
703
+ * @param refId - The specific ref to remove; removes one arbitrary ref if omitted
704
+ */
705
+ release(
706
+ Type,
707
+ instanceKey = BLAC_DEFAULTS.DEFAULT_INSTANCE_KEY,
708
+ forceDispose = false,
709
+ refId,
710
+ ) {
711
+ const instances = this.ensureInstancesMap(Type);
712
+ const entry = instances.get(instanceKey);
713
+ if (!entry) return;
714
+ if (forceDispose) {
715
+ if (!entry.instance.isDisposed) entry.instance.dispose();
716
+ instances.delete(instanceKey);
717
+ return;
718
+ }
719
+ let releasedRefId;
720
+ if (refId !== void 0) {
721
+ const count = entry.refs.get(refId) ?? 0;
722
+ if (count <= 1) entry.refs.delete(refId);
723
+ else entry.refs.set(refId, count - 1);
724
+ releasedRefId = refId;
725
+ } else {
726
+ const firstKey = entry.refs.keys().next().value;
727
+ if (firstKey !== void 0) {
728
+ const count = entry.refs.get(firstKey) ?? 0;
729
+ if (count <= 1) entry.refs.delete(firstKey);
730
+ else entry.refs.set(firstKey, count - 1);
731
+ releasedRefId = firstKey;
732
+ }
733
+ }
734
+ if (releasedRefId) this.emit('refReleased', entry.instance, releasedRefId);
735
+ const keepAlive = isKeepAliveClass(Type);
736
+ if (entry.refs.size === 0 && !keepAlive) {
737
+ const deps = entry.instance.dependencies;
738
+ if (!entry.instance.isDisposed) entry.instance.dispose();
739
+ instances.delete(instanceKey);
740
+ for (const [DepType, depKey] of deps) {
741
+ const depInstances = this.ensureInstancesMap(DepType);
742
+ const depEntry = depInstances.get(depKey);
743
+ if (
744
+ depEntry &&
745
+ depEntry.refs.size === 0 &&
746
+ !isKeepAliveClass(DepType) &&
747
+ !depEntry.instance.isDisposed
748
+ ) {
749
+ depEntry.instance.dispose();
750
+ depInstances.delete(depKey);
751
+ }
752
+ }
753
+ }
754
+ }
755
+ /**
756
+ * Get all instances of a specific type.
757
+ * @param Type - The StateContainer class constructor
758
+ * @returns Array of all instances
759
+ */
760
+ getAll(Type) {
761
+ const instances = this.ensureInstancesMap(Type);
762
+ const result = [];
763
+ for (const entry of instances.values()) result.push(entry.instance);
764
+ return result;
765
+ }
766
+ /**
767
+ * Safely iterate over all instances of a type.
768
+ * Skips disposed instances and catches callback errors.
769
+ * @param Type - The StateContainer class constructor
770
+ * @param callback - Function to call for each instance
771
+ */
772
+ forEach(Type, callback) {
773
+ const instances = this.ensureInstancesMap(Type);
774
+ for (const entry of instances.values()) {
775
+ const instance = entry.instance;
776
+ if (!instance.isDisposed)
777
+ try {
778
+ callback(instance);
779
+ } catch (error) {
780
+ console.error(
781
+ `${BLAC_ERROR_PREFIX} forEach callback error for ${Type.name}:`,
782
+ error,
783
+ );
784
+ }
785
+ }
786
+ }
787
+ /**
788
+ * Clear all instances of a specific type (disposes them).
789
+ * @param Type - The StateContainer class constructor
790
+ */
791
+ clear(Type) {
792
+ const instances = this.ensureInstancesMap(Type);
793
+ for (const entry of instances.values())
794
+ if (!entry.instance.isDisposed) entry.instance.dispose();
795
+ instances.clear();
796
+ }
797
+ /**
798
+ * Get reference count for an instance (number of active refs).
799
+ * @param Type - The StateContainer class constructor
800
+ * @param instanceKey - Instance key (defaults to 'default')
801
+ * @returns Current ref count (0 if instance doesn't exist)
802
+ */
803
+ getRefCount(Type, instanceKey = BLAC_DEFAULTS.DEFAULT_INSTANCE_KEY) {
804
+ return this.ensureInstancesMap(Type).get(instanceKey)?.refs.size ?? 0;
805
+ }
806
+ /**
807
+ * Get all active reference IDs for an instance.
808
+ * @param Type - The StateContainer class constructor
809
+ * @param instanceKey - Instance key (defaults to 'default')
810
+ * @returns Array of ref ID strings (empty if instance doesn't exist)
811
+ */
812
+ getRefIds(Type, instanceKey = BLAC_DEFAULTS.DEFAULT_INSTANCE_KEY) {
813
+ const instances = this.instancesByConstructor.get(Type);
814
+ if (!instances) return [];
815
+ const entry = instances.get(instanceKey);
816
+ return entry ? Array.from(entry.refs.keys()) : [];
817
+ }
818
+ /**
819
+ * Check if an instance exists.
820
+ * @param Type - The StateContainer class constructor
821
+ * @param instanceKey - Instance key (defaults to 'default')
822
+ * @returns true if instance exists
823
+ */
824
+ hasInstance(Type, instanceKey = BLAC_DEFAULTS.DEFAULT_INSTANCE_KEY) {
825
+ return this.ensureInstancesMap(Type).has(instanceKey);
826
+ }
827
+ /**
828
+ * Clear all instances from all types (for testing)
829
+ *
830
+ * Iterates all registered types and clears their instances.
831
+ * Also clears type tracking to reset the registry state.
832
+ */
833
+ clearAll() {
834
+ for (const Type of this.types) this.clear(Type);
835
+ this.types.clear();
836
+ this.registeredTypeNames.clear();
837
+ }
838
+ /**
839
+ * Get registry statistics for debugging.
840
+ * @returns Object with registeredTypes, totalInstances, and typeBreakdown
841
+ */
842
+ getStats() {
843
+ const typeBreakdown = {};
844
+ let totalInstances = 0;
845
+ for (const Type of this.types) {
846
+ const typeName = Type.name;
847
+ const count = this.getInstancesMap(Type).size;
848
+ typeBreakdown[typeName] = count;
849
+ totalInstances += count;
850
+ }
851
+ return {
852
+ registeredTypes: this.types.size,
853
+ totalInstances,
854
+ typeBreakdown,
855
+ };
856
+ }
857
+ /**
858
+ * Get all registered types (for plugin system).
859
+ * @returns Array of all registered StateContainer class constructors
860
+ */
861
+ getTypes() {
862
+ return Array.from(this.types);
863
+ }
864
+ /**
865
+ * Subscribe to lifecycle events
866
+ * @param event - The lifecycle event to listen for
867
+ * @param listener - The listener function to call when the event occurs
868
+ * @returns Unsubscribe function
869
+ */
870
+ on(event, listener) {
871
+ if (!this.listeners.has(event))
872
+ this.listeners.set(event, /* @__PURE__ */ new Set());
873
+ const instance = this.listeners.get(event);
874
+ if (!instance)
875
+ throw new Error(
876
+ `${BLAC_ERROR_PREFIX} Failed to register listener for event '${event}'`,
877
+ );
878
+ instance.add(listener);
879
+ if (event === 'stateChanged') this._stateChangedListenerCount++;
880
+ return () => {
881
+ if (
882
+ this.listeners.get(event)?.delete(listener) &&
883
+ event === 'stateChanged'
884
+ )
885
+ this._stateChangedListenerCount--;
886
+ };
887
+ }
888
+ emit(event, ...args) {
889
+ const listeners = this.listeners.get(event);
890
+ if (!listeners || listeners.size === 0) return;
891
+ for (const listener of listeners)
892
+ try {
893
+ listener(...args);
894
+ } catch (error) {
895
+ console.error(
896
+ `${BLAC_ERROR_PREFIX} Listener error for '${event}':`,
897
+ error,
898
+ );
899
+ }
900
+ }
901
+ /**
902
+ * Schedule a deferred stateChanged notification via microtask.
903
+ * Skips entirely when no stateChanged listeners are registered.
904
+ * @internal - Called by StateContainer.applyState
905
+ */
906
+ notifyStateChanged(container, previousState, newState) {
907
+ if (this._stateChangedListenerCount === 0) return;
908
+ if (!this._pendingStateChanges) {
909
+ this._pendingStateChanges = [];
910
+ queueMicrotask(() => this.flushStateChanged());
911
+ }
912
+ this._pendingStateChanges.push([container, previousState, newState]);
913
+ }
914
+ flushStateChanged() {
915
+ const pending = this._pendingStateChanges;
916
+ this._pendingStateChanges = null;
917
+ if (!pending) return;
918
+ for (const [container, prev, next] of pending)
919
+ this.emit('stateChanged', container, prev, next);
920
+ }
921
+ };
922
+ /**
923
+ * Global default registry instance
924
+ */
925
+ const globalRegistry = new StateContainerRegistry();
926
+ /**
927
+ * Global plugin manager (initialized lazily)
928
+ */
929
+ let _globalPluginManager = null;
930
+ /**
931
+ * Get the global plugin manager
932
+ */
933
+ function getPluginManager() {
934
+ if (!_globalPluginManager)
935
+ _globalPluginManager = createPluginManager(globalRegistry);
936
+ return _globalPluginManager;
937
+ }
938
+ //#endregion
939
+ Object.defineProperty(exports, 'BLAC_DEFAULTS', {
940
+ enumerable: true,
941
+ get: function () {
942
+ return BLAC_DEFAULTS;
943
+ },
944
+ });
945
+ Object.defineProperty(exports, 'BLAC_ERROR_PREFIX', {
946
+ enumerable: true,
947
+ get: function () {
948
+ return BLAC_ERROR_PREFIX;
949
+ },
950
+ });
951
+ Object.defineProperty(exports, 'BLAC_STATIC_PROPS', {
952
+ enumerable: true,
953
+ get: function () {
954
+ return BLAC_STATIC_PROPS;
955
+ },
956
+ });
957
+ Object.defineProperty(exports, 'PluginManager', {
958
+ enumerable: true,
959
+ get: function () {
960
+ return PluginManager;
961
+ },
962
+ });
963
+ Object.defineProperty(exports, 'StateContainerRegistry', {
964
+ enumerable: true,
965
+ get: function () {
966
+ return StateContainerRegistry;
967
+ },
968
+ });
969
+ Object.defineProperty(exports, 'configureBlac', {
970
+ enumerable: true,
971
+ get: function () {
972
+ return configureBlac;
973
+ },
974
+ });
975
+ Object.defineProperty(exports, 'getBlacConfig', {
976
+ enumerable: true,
977
+ get: function () {
978
+ return getBlacConfig;
979
+ },
980
+ });
981
+ Object.defineProperty(exports, 'getClassEquality', {
982
+ enumerable: true,
983
+ get: function () {
984
+ return getClassEquality;
985
+ },
986
+ });
987
+ Object.defineProperty(exports, 'getPluginManager', {
988
+ enumerable: true,
989
+ get: function () {
990
+ return getPluginManager;
991
+ },
992
+ });
993
+ Object.defineProperty(exports, 'globalRegistry', {
994
+ enumerable: true,
995
+ get: function () {
996
+ return globalRegistry;
997
+ },
998
+ });
999
+ Object.defineProperty(exports, 'isExcludedFromDevTools', {
1000
+ enumerable: true,
1001
+ get: function () {
1002
+ return isExcludedFromDevTools;
1003
+ },
1004
+ });
1005
+ Object.defineProperty(exports, 'isIsolatedClass', {
1006
+ enumerable: true,
1007
+ get: function () {
1008
+ return isIsolatedClass;
1009
+ },
1010
+ });
1011
+ Object.defineProperty(exports, 'isKeepAliveClass', {
1012
+ enumerable: true,
1013
+ get: function () {
1014
+ return isKeepAliveClass;
1015
+ },
1016
+ });
1017
+ Object.defineProperty(exports, 'resetBlacConfig', {
1018
+ enumerable: true,
1019
+ get: function () {
1020
+ return resetBlacConfig;
1021
+ },
1022
+ });
1023
+ Object.defineProperty(exports, 'shallowEqualState', {
1024
+ enumerable: true,
1025
+ get: function () {
1026
+ return shallowEqualState;
1027
+ },
1028
+ });
1029
+
1030
+ //# sourceMappingURL=StateContainerRegistry-BRBATSrx.cjs.map