@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,1057 @@
1
+ let _dirtytalk_structural = require("@dirtytalk/structural");
2
+ //#region src/config.ts
3
+ /**
4
+ * Default equality: shallow per-key `Object.is` comparison.
5
+ * Falls through to `false` for primitives/null so reference-only state still
6
+ * behaves correctly.
7
+ */
8
+ const shallowEqualState = (prev, next) => {
9
+ if (Object.is(prev, next)) return true;
10
+ if (typeof prev !== "object" || prev === null) return false;
11
+ if (typeof next !== "object" || next === null) return false;
12
+ const prevKeys = Object.keys(prev);
13
+ if (prevKeys.length !== Object.keys(next).length) return false;
14
+ for (let i = 0; i < prevKeys.length; i++) {
15
+ const key = prevKeys[i];
16
+ if (!Object.is(prev[key], next[key])) return false;
17
+ }
18
+ return true;
19
+ };
20
+ const defaultConfig = {
21
+ equality: shallowEqualState,
22
+ maxInstancesPerType: 1e3,
23
+ maxRefsPerInstance: 1e3,
24
+ maxEmitsPerSecond: 100
25
+ };
26
+ let globalConfig = { ...defaultConfig };
27
+ /**
28
+ * Configure global defaults for @blac/core.
29
+ *
30
+ * @example
31
+ * ```ts
32
+ * import { configureBlac, shallowEqualState } from '@blac/core';
33
+ *
34
+ * // Swap in a deep-equality check for all blocs
35
+ * configureBlac({ equality: myDeepEqual });
36
+ * ```
37
+ */
38
+ function configureBlac(config) {
39
+ globalConfig = {
40
+ ...globalConfig,
41
+ ...config
42
+ };
43
+ }
44
+ /**
45
+ * Get the current global configuration.
46
+ * @internal
47
+ */
48
+ function getBlacConfig() {
49
+ return globalConfig;
50
+ }
51
+ /**
52
+ * Reset configuration to defaults (useful for testing).
53
+ * @internal
54
+ */
55
+ function resetBlacConfig() {
56
+ globalConfig = { ...defaultConfig };
57
+ }
58
+ //#endregion
59
+ //#region src/constants.ts
60
+ /**
61
+ * Default configuration constants for BlaC
62
+ *
63
+ * Centralized location for all magic numbers and default values.
64
+ */
65
+ /**
66
+ * Default configuration constants for BlaC
67
+ */
68
+ const BLAC_DEFAULTS = {
69
+ /**
70
+ * Default instance key for shared instances
71
+ */
72
+ DEFAULT_INSTANCE_KEY: "default",
73
+ /**
74
+ * Maximum getter nesting depth (prevents infinite recursion)
75
+ */
76
+ MAX_GETTER_DEPTH: 10
77
+ };
78
+ /**
79
+ * Static property names for StateContainer classes
80
+ * Used for feature flags and configuration on bloc classes
81
+ */
82
+ const BLAC_STATIC_PROPS = {
83
+ /**
84
+ * Mark a bloc to never be auto-disposed (kept alive permanently)
85
+ */
86
+ KEEP_ALIVE: "keepAlive",
87
+ /**
88
+ * Exclude a bloc from DevTools reporting (prevents infinite loops)
89
+ */
90
+ EXCLUDE_FROM_DEVTOOLS: "__excludeFromDevTools",
91
+ /**
92
+ * Mark a bloc so each `useBloc` call site gets its own per-mount instance.
93
+ * The React adapter auto-keys via `useId()` when this is set.
94
+ */
95
+ ISOLATED: "isolated",
96
+ /**
97
+ * Per-class equality function used to short-circuit `emit`/`patch` when the
98
+ * new state is structurally equal to the previous state. Falls back to the
99
+ * global `configureBlac({ equality })` value when unset.
100
+ */
101
+ EQUALITY: "__equality",
102
+ /**
103
+ * Per-class key function: `static key = (args) => string`.
104
+ * When set, the registry calls `Type.key(args)` to derive the instance key
105
+ * instead of using a structural hash of `args`. Allows blocs to ignore
106
+ * non-identity fields (e.g., `readonly` flags) while still keying by id.
107
+ */
108
+ KEY: "key"
109
+ };
110
+ /**
111
+ * Standard error message prefix
112
+ */
113
+ const BLAC_ERROR_PREFIX = "[BlaC]";
114
+ //#endregion
115
+ //#region src/plugin/PluginManager.ts
116
+ /**
117
+ * Manages plugin lifecycle for the BlaC state management system.
118
+ *
119
+ * The manager hooks into two surfaces:
120
+ *
121
+ * 1. **Registry lifecycle events** (`created`, `disposed`, `refAcquired`,
122
+ * `refReleased`, `depsChanged`) — synchronous, fired by the registry.
123
+ *
124
+ * 2. **Per-container channel flushes** — microtask-coalesced. For each
125
+ * container, the manager subscribes once at create-time with
126
+ * `ALL_PATHS` interest and stashes `prevState`. On every flush it
127
+ * captures the new state + the changed `PathSet` and dispatches
128
+ * `onStateChange(ctx, prev, next, paths)` to every enabled plugin.
129
+ *
130
+ * The `ALL_PATHS` subscription cost: plugins counted as a consumer with
131
+ * `ALL_PATHS` interest will defeat the single-consumer-skip optimization
132
+ * in `StructuralContainer`. This is the intended trade-off — devtools /
133
+ * persist plugins genuinely want every change, and stateful plugins
134
+ * (logging) can decode `paths` via `container.interner.lookup(id)` to log
135
+ * only relevant fields. Plugins that want low overhead should remain
136
+ * uninstalled or environment-gated.
137
+ *
138
+ * @example
139
+ * ```ts
140
+ * const manager = createPluginManager(registry);
141
+ * manager.install(myPlugin, { environment: 'development' });
142
+ * ```
143
+ */
144
+ var PluginManager = class {
145
+ /**
146
+ * Create a new PluginManager
147
+ * @param registry - The StateContainerRegistry to monitor for lifecycle events
148
+ */
149
+ constructor(registry) {
150
+ this.plugins = /* @__PURE__ */ new Map();
151
+ this.lifecycleUnsubscribers = [];
152
+ this.containerBridges = /* @__PURE__ */ new WeakMap();
153
+ this.registry = registry;
154
+ this.setupLifecycleHooks();
155
+ }
156
+ /**
157
+ * Install a plugin with optional configuration
158
+ * @param plugin - The plugin to install
159
+ * @param config - Optional plugin configuration
160
+ * @throws Error if plugin is already installed
161
+ */
162
+ install(plugin, config = {}) {
163
+ const effectiveConfig = {
164
+ enabled: true,
165
+ environment: "all",
166
+ ...config
167
+ };
168
+ if (!this.shouldEnablePlugin(effectiveConfig)) {
169
+ console.log(`[BlaC] Plugin "${plugin.name}" skipped (environment mismatch)`);
170
+ return;
171
+ }
172
+ if (this.plugins.has(plugin.name)) throw new Error(`Plugin "${plugin.name}" is already installed`);
173
+ const installContext = this.buildContext(void 0);
174
+ this.plugins.set(plugin.name, {
175
+ plugin,
176
+ config: effectiveConfig,
177
+ installContext
178
+ });
179
+ if (plugin.onInstall) try {
180
+ plugin.onInstall(installContext);
181
+ } catch (error) {
182
+ console.error(`[BlaC] Error installing plugin "${plugin.name}":`, error);
183
+ this.plugins.delete(plugin.name);
184
+ throw error;
185
+ }
186
+ console.log(`[BlaC] Plugin "${plugin.name}" v${plugin.version} installed`);
187
+ }
188
+ /**
189
+ * Uninstall a plugin by name
190
+ * @param pluginName - The name of the plugin to uninstall
191
+ * @throws Error if plugin is not installed
192
+ */
193
+ uninstall(pluginName) {
194
+ const installed = this.plugins.get(pluginName);
195
+ if (!installed) throw new Error(`Plugin "${pluginName}" is not installed`);
196
+ if (installed.plugin.onUninstall) try {
197
+ installed.plugin.onUninstall();
198
+ } catch (error) {
199
+ console.error(`[BlaC] Error uninstalling plugin "${pluginName}":`, error);
200
+ }
201
+ this.plugins.delete(pluginName);
202
+ console.log(`[BlaC] Plugin "${pluginName}" uninstalled`);
203
+ }
204
+ /**
205
+ * Get an installed plugin by name
206
+ * @param pluginName - The name of the plugin to retrieve
207
+ * @returns The plugin instance or undefined if not found
208
+ */
209
+ getPlugin(pluginName) {
210
+ return this.plugins.get(pluginName)?.plugin;
211
+ }
212
+ /**
213
+ * Get all installed plugins
214
+ * @returns Array of all installed plugins
215
+ */
216
+ getAllPlugins() {
217
+ return Array.from(this.plugins.values()).map((p) => p.plugin);
218
+ }
219
+ /**
220
+ * Check if a plugin is installed
221
+ * @param pluginName - The name of the plugin to check
222
+ * @returns true if the plugin is installed
223
+ */
224
+ hasPlugin(pluginName) {
225
+ return this.plugins.has(pluginName);
226
+ }
227
+ /**
228
+ * Uninstall all plugins
229
+ */
230
+ clear() {
231
+ for (const name of this.plugins.keys()) this.uninstall(name);
232
+ }
233
+ destroy() {
234
+ this.clear();
235
+ for (const unsub of this.lifecycleUnsubscribers) unsub();
236
+ this.lifecycleUnsubscribers = [];
237
+ }
238
+ /**
239
+ * Wire registry lifecycle events into plugin dispatch.
240
+ *
241
+ * `onStateChange` is NOT wired through `registry.on('stateChanged', …)` —
242
+ * that event lacks the `PathSet` payload. Instead, on each `created` we
243
+ * subscribe to the container's channel directly so we get
244
+ * `(paths)` and capture `(prev, next)` via the per-container snapshot.
245
+ */
246
+ setupLifecycleHooks() {
247
+ this.lifecycleUnsubscribers = [
248
+ this.registry.on("created", (instance) => {
249
+ this.attachStateBridge(instance);
250
+ this.notifyPlugins("onCreated", instance);
251
+ }),
252
+ this.registry.on("disposed", (instance) => {
253
+ this.notifyPlugins("onDestroyed", instance);
254
+ this.detachStateBridge(instance);
255
+ }),
256
+ this.registry.on("refAcquired", (instance, refId) => {
257
+ this.notifyPlugins("onRefAcquired", instance, refId);
258
+ }),
259
+ this.registry.on("refReleased", (instance, refId) => {
260
+ this.notifyPlugins("onRefReleased", instance, refId);
261
+ }),
262
+ this.registry.on("depsChanged", (instance, previousDeps, currentDeps) => {
263
+ this.notifyPlugins("onDepsChanged", instance, previousDeps, currentDeps);
264
+ })
265
+ ];
266
+ }
267
+ /**
268
+ * Subscribe to the container's channel with `ALL_PATHS` interest, so we
269
+ * fire on every flush. Capture `prev` from the snapshot taken on the
270
+ * previous flush (or at create-time for the first flush) and pass the
271
+ * channel's `paths` argument straight through to plugins.
272
+ *
273
+ * Per-container bookkeeping is stored in a `WeakMap` keyed by the
274
+ * container itself, so a disposed/GC'd container drops cleanly.
275
+ */
276
+ attachStateBridge(container) {
277
+ if (this.containerBridges.has(container)) return;
278
+ const bridge = {
279
+ unsub: () => {},
280
+ prevState: container.state
281
+ };
282
+ this.containerBridges.set(container, bridge);
283
+ bridge.unsub = container.channel.subscribe(() => _dirtytalk_structural.ALL_PATHS, (paths) => this.dispatchStateChange(container, paths));
284
+ }
285
+ detachStateBridge(container) {
286
+ const bridge = this.containerBridges.get(container);
287
+ if (!bridge) return;
288
+ bridge.unsub();
289
+ this.containerBridges.delete(container);
290
+ }
291
+ /**
292
+ * Channel-flush callback. Snapshots `next`, hands `(prev, next, paths)`
293
+ * to every enabled plugin's `onStateChange`, then updates `prevState`
294
+ * for the next flush.
295
+ *
296
+ * Note: `prev` is captured once and reused across plugins — every
297
+ * plugin sees the same `prev`/`next`/`paths` regardless of dispatch
298
+ * order, matching the "snapshot prev once per flush" invariant called
299
+ * out in the C2 spec pitfalls.
300
+ */
301
+ dispatchStateChange(container, paths) {
302
+ const bridge = this.containerBridges.get(container);
303
+ if (!bridge) return;
304
+ const prev = bridge.prevState;
305
+ const next = container.state;
306
+ bridge.prevState = next;
307
+ for (const { plugin, config } of this.plugins.values()) {
308
+ if (!config.enabled) continue;
309
+ const hook = plugin.onStateChange;
310
+ if (typeof hook !== "function") continue;
311
+ try {
312
+ hook.call(plugin, this.buildContext(container), prev, next, paths);
313
+ } catch (error) {
314
+ console.error(`[BlaC] Error in plugin "${plugin.name}" onStateChange:`, error);
315
+ }
316
+ }
317
+ }
318
+ /**
319
+ * Notify all plugins of a lifecycle event.
320
+ *
321
+ * Builds a fresh `PluginContext` per dispatch (instance becomes
322
+ * `ctx.container`), so plugins can reach the focal bloc through
323
+ * `ctx.container` per Decision 6.
324
+ */
325
+ notifyPlugins(hookName, instance, ...extraArgs) {
326
+ for (const { plugin, config } of this.plugins.values()) {
327
+ if (!config.enabled) continue;
328
+ const hook = plugin[hookName];
329
+ if (typeof hook !== "function") continue;
330
+ try {
331
+ hook.call(plugin, this.buildContext(instance), ...extraArgs);
332
+ } catch (error) {
333
+ console.error(`[BlaC] Error in plugin "${plugin.name}" ${hookName}:`, error);
334
+ }
335
+ }
336
+ }
337
+ /**
338
+ * Build a `PluginContext` for a given focal container. The context is
339
+ * cheap to build — its methods close over `this.registry` directly —
340
+ * so we create one per dispatch rather than caching per container.
341
+ * This sidesteps the lifetime question of "when do we evict a cached
342
+ * context?" and keeps `paths`-vs-`container` lifetimes cleanly
343
+ * separated per the C2 spec.
344
+ */
345
+ buildContext(container) {
346
+ const registry = this.registry;
347
+ return {
348
+ container,
349
+ getInstanceMetadata: (instance) => {
350
+ return {
351
+ id: instance.instanceId,
352
+ className: instance.constructor.name,
353
+ isDisposed: instance.isDisposed,
354
+ name: instance.name,
355
+ createdAt: instance.createdAt,
356
+ state: instance.state,
357
+ hydrationStatus: instance.hydrationStatus,
358
+ isHydrated: instance.isHydrated,
359
+ hydrationError: instance.hydrationError,
360
+ changedWhileHydrating: instance.changedWhileHydrating,
361
+ args: instance.args
362
+ };
363
+ },
364
+ getState: (instance) => {
365
+ return instance.state;
366
+ },
367
+ getHydrationStatus: (instance) => {
368
+ return instance.hydrationStatus;
369
+ },
370
+ startHydration: (instance) => {
371
+ instance.beginHydration();
372
+ },
373
+ applyHydratedState: (instance, state) => {
374
+ return instance.applyHydratedState(state);
375
+ },
376
+ finishHydration: (instance) => {
377
+ instance.finishHydration();
378
+ },
379
+ failHydration: (instance, error) => {
380
+ instance.failHydration(error);
381
+ },
382
+ waitForHydration: (instance) => {
383
+ return instance.waitForHydration();
384
+ },
385
+ queryInstances: (typeClass) => {
386
+ return registry.getAll(typeClass);
387
+ },
388
+ getAllTypes: () => {
389
+ return registry.getTypes();
390
+ },
391
+ getStats: () => {
392
+ return registry.getStats();
393
+ },
394
+ getRefIds: (instanceId) => {
395
+ for (const Type of registry.getTypes()) {
396
+ const map = registry.getInstancesMap(Type);
397
+ for (const [, entry] of map) if (entry.instance.instanceId === instanceId) return Array.from(entry.refs.keys());
398
+ }
399
+ return [];
400
+ }
401
+ };
402
+ }
403
+ /**
404
+ * Check if plugin should be enabled based on environment
405
+ */
406
+ shouldEnablePlugin(config) {
407
+ if (!config.enabled) return false;
408
+ if (config.environment === "all") return true;
409
+ return this.getCurrentEnvironment() === config.environment;
410
+ }
411
+ /**
412
+ * Get current environment
413
+ */
414
+ getCurrentEnvironment() {
415
+ if (typeof process !== "undefined") {
416
+ if (process.env.NODE_ENV === "test") return "test";
417
+ if (process.env.NODE_ENV === "production") return "production";
418
+ return "development";
419
+ }
420
+ return "development";
421
+ }
422
+ };
423
+ /**
424
+ * Create a plugin manager instance
425
+ * @param registry - The StateContainerRegistry to monitor for lifecycle events
426
+ * @returns A new PluginManager instance
427
+ */
428
+ function createPluginManager(registry) {
429
+ return new PluginManager(registry);
430
+ }
431
+ //#endregion
432
+ //#region src/utils/static-props.ts
433
+ /**
434
+ * Utility functions for accessing static properties on StateContainer classes
435
+ */
436
+ /**
437
+ * Get a static property from a class constructor
438
+ * Type-safe helper that avoids (Type as any) casts
439
+ *
440
+ * @param Type - The class constructor
441
+ * @param propName - The property name to access
442
+ * @param defaultValue - Optional default value if property is undefined
443
+ * @returns The property value or default
444
+ */
445
+ function getStaticProp(Type, propName, defaultValue) {
446
+ return Type[propName] ?? defaultValue;
447
+ }
448
+ /**
449
+ * Check if a class is marked as keepAlive.
450
+ * KeepAlive classes are never auto-disposed when ref count reaches 0.
451
+ * @param Type - The class constructor to check
452
+ * @returns true if the class has `static keepAlive = true`
453
+ */
454
+ function isKeepAliveClass(Type) {
455
+ return getStaticProp(Type, BLAC_STATIC_PROPS.KEEP_ALIVE) === true;
456
+ }
457
+ /**
458
+ * Check if a class should be excluded from DevTools.
459
+ * Used to prevent infinite loops when DevTools tracks itself.
460
+ * @param Type - The class constructor to check
461
+ * @returns true if the class has `static __excludeFromDevTools = true`
462
+ */
463
+ function isExcludedFromDevTools(Type) {
464
+ return getStaticProp(Type, BLAC_STATIC_PROPS.EXCLUDE_FROM_DEVTOOLS) === true;
465
+ }
466
+ /**
467
+ * Check if a class is marked as isolated.
468
+ * Isolated classes get a fresh, per-mount instance from `useBloc`
469
+ * (auto-keyed via React's `useId()`), instead of sharing the default
470
+ * instance with sibling call sites.
471
+ * @param Type - The class constructor to check
472
+ * @returns true if the class has `static isolated = true`
473
+ */
474
+ function isIsolatedClass(Type) {
475
+ return getStaticProp(Type, BLAC_STATIC_PROPS.ISOLATED) === true;
476
+ }
477
+ /**
478
+ * Get the per-class equality function set via `@blac({ equality })`, if any.
479
+ * @param Type - The class constructor to check
480
+ * @returns the equality function or `undefined`
481
+ */
482
+ function getClassEquality(Type) {
483
+ const fn = getStaticProp(Type, BLAC_STATIC_PROPS.EQUALITY);
484
+ return typeof fn === "function" ? fn : void 0;
485
+ }
486
+ /**
487
+ * Get the per-class key function set via `@blac({ key })` or `static key = …`, if any.
488
+ * Used by the registry to derive a stable instance key from `args`.
489
+ * @param Type - The class constructor to check
490
+ * @returns the key function or `undefined`
491
+ */
492
+ function getClassKey(Type) {
493
+ const fn = getStaticProp(Type, BLAC_STATIC_PROPS.KEY, void 0);
494
+ return typeof fn === "function" ? fn : void 0;
495
+ }
496
+ //#endregion
497
+ //#region src/utils/structural-key.ts
498
+ /**
499
+ * Deterministic, order-independent hash of serializable args.
500
+ * Sorts object keys so {a,b} === {b,a}.
501
+ * Throws (dev) if it encounters a function or non-plain object — those belong in `deps`.
502
+ */
503
+ const DEFAULT_STRUCTURAL_KEY = "default";
504
+ /**
505
+ * Produce a stable string key for serializable args.
506
+ * - `undefined` / `void` args → `'default'` sentinel (no-args blocs stay on the default key).
507
+ * - Object keys are sorted for order-independence.
508
+ * - Arrays keep their insertion order.
509
+ * - Functions throw — they must be passed via `deps`, not `args`.
510
+ */
511
+ function structuralKey(args) {
512
+ if (args === void 0 || args === null) return DEFAULT_STRUCTURAL_KEY;
513
+ return JSON.stringify(args, function(_k, v) {
514
+ if (typeof v === "function") throw new Error("[blac] args must be serializable; put refs/callbacks in `deps`");
515
+ if (v && typeof v === "object" && !Array.isArray(v)) return Object.keys(v).sort().reduce((o, k) => {
516
+ o[k] = v[k];
517
+ return o;
518
+ }, {});
519
+ return v;
520
+ });
521
+ }
522
+ //#endregion
523
+ //#region src/core/StateContainerRegistry.ts
524
+ /**
525
+ * Central registry for managing StateContainer instances.
526
+ * Handles instance lifecycle, named ref tracking, and lifecycle event emission.
527
+ *
528
+ * @example
529
+ * ```ts
530
+ * const registry = new StateContainerRegistry();
531
+ * const instance = registry.acquire(MyBloc); // ownership, must release
532
+ * const other = registry.ensure(OtherBloc); // no ownership, bloc-to-bloc
533
+ * registry.on('stateChanged', (container, prev, next) => {
534
+ * console.log('State changed:', prev, '->', next);
535
+ * });
536
+ * ```
537
+ */
538
+ var StateContainerRegistry = class {
539
+ constructor() {
540
+ this.instancesByConstructor = /* @__PURE__ */ new WeakMap();
541
+ this.types = /* @__PURE__ */ new Set();
542
+ this.registeredTypeNames = /* @__PURE__ */ new Set();
543
+ this.listeners = /* @__PURE__ */ new Map();
544
+ this._stateChangedListenerCount = 0;
545
+ this._pendingStateChanges = null;
546
+ this._autoRefIdCounter = 0;
547
+ }
548
+ get hasStateChangedListeners() {
549
+ return this._stateChangedListenerCount > 0;
550
+ }
551
+ /**
552
+ * Register a type for lifecycle event tracking
553
+ * @param constructor - The StateContainer class constructor
554
+ */
555
+ registerType(constructor) {
556
+ this.types.add(constructor);
557
+ }
558
+ /**
559
+ * Register a StateContainer class with configuration
560
+ * @param constructor - The StateContainer class constructor
561
+ * @throws Error if type is already registered
562
+ */
563
+ register(constructor) {
564
+ const className = constructor.name;
565
+ if (this.registeredTypeNames.has(className)) throw new Error(`${BLAC_ERROR_PREFIX} Type "${className}" is already registered`);
566
+ this.registeredTypeNames.add(className);
567
+ this.registerType(constructor);
568
+ }
569
+ ensureInstancesMap(Type) {
570
+ let instances = this.instancesByConstructor.get(Type);
571
+ if (!instances) {
572
+ instances = /* @__PURE__ */ new Map();
573
+ this.instancesByConstructor.set(Type, instances);
574
+ }
575
+ return instances;
576
+ }
577
+ /**
578
+ * Get the instances Map for a specific class (public API for stats/debugging)
579
+ */
580
+ getInstancesMap(Type) {
581
+ return this.instancesByConstructor.get(Type) || /* @__PURE__ */ new Map();
582
+ }
583
+ /**
584
+ * Directly insert an instance entry into the registry without going through
585
+ * acquire/release. Creates the internal WeakMap bucket for the constructor if
586
+ * it does not exist yet. Replaces any existing entry for the same key.
587
+ *
588
+ * The provided instance is NOT configured or disposed here — callers are
589
+ * responsible for any initConfig / dispose calls. Intended for testing
590
+ * helpers that create stubs outside the normal acquisition path.
591
+ *
592
+ * @internal Used by testing helpers only.
593
+ */
594
+ insertInstance(Type, instanceKey, instance, refs = /* @__PURE__ */ new Map()) {
595
+ const instances = this.ensureInstancesMap(Type);
596
+ const existingEntry = instances.get(instanceKey);
597
+ if (existingEntry && existingEntry.instance !== instance && !existingEntry.instance.isDisposed) existingEntry.instance.dispose();
598
+ instances.set(instanceKey, {
599
+ instance,
600
+ refs
601
+ });
602
+ }
603
+ /**
604
+ * Resolve the storage key for an instance. This is the single source of truth
605
+ * for keying — `acquire` and `release` MUST agree, otherwise a ref taken under
606
+ * an args-derived key is never dropped (instance leaks).
607
+ *
608
+ * Resolution order (explicit beats derived):
609
+ * explicit key > `static key(args)` > structural hash of args > default sentinel.
610
+ *
611
+ * @param Type - The StateContainer class constructor
612
+ * @param instanceKey - Explicit key, or undefined to derive from args
613
+ * @param args - Construction args used for structural/`static key` derivation
614
+ */
615
+ resolveKey(Type, instanceKey, args) {
616
+ if (instanceKey !== void 0) return instanceKey;
617
+ const keyFn = getClassKey(Type);
618
+ if (keyFn) return keyFn(args);
619
+ if (args !== void 0) return structuralKey(args);
620
+ return DEFAULT_STRUCTURAL_KEY;
621
+ }
622
+ /**
623
+ * Circuit breaker for runaway instance creation. Throws when a single
624
+ * constructor would exceed `maxInstancesPerType` live instances — almost
625
+ * always an unstable instance key (e.g. a new object/array passed as `args`
626
+ * every render, or a missing `static key`) leaking an instance per render.
627
+ */
628
+ assertInstanceLimit(Type, currentCount) {
629
+ const limit = getBlacConfig().maxInstancesPerType;
630
+ if (limit > 0 && currentCount >= limit) throw new Error(`${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 })\`.`);
631
+ }
632
+ /**
633
+ * Circuit breaker for runaway reference growth. Throws when one instance
634
+ * accumulates more than `maxRefsPerInstance` distinct live refs — almost
635
+ * always consumer cleanup (e.g. `useBloc`'s unmount `release`) never firing.
636
+ */
637
+ assertRefLimit(Type, resolvedKey, refCount) {
638
+ const limit = getBlacConfig().maxRefsPerInstance;
639
+ if (limit > 0 && refCount > limit) throw new Error(`${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 })\`.`);
640
+ }
641
+ /**
642
+ * Acquire an instance with ref tracking (ownership semantics).
643
+ * Creates a new instance if one doesn't exist, or returns existing and adds a ref.
644
+ * You must call `release()` with the same refId when done.
645
+ * @param Type - The StateContainer class constructor
646
+ * @param instanceKey - Instance key (defaults to 'default')
647
+ * @param options - Acquisition options
648
+ * @param options.canCreate - Whether to create new instance if not found (default: true)
649
+ * @param options.countRef - Whether to add a reference (default: true)
650
+ * @param options.refId - Named reference ID for debugging; auto-generated if omitted
651
+ * @returns The state container instance
652
+ */
653
+ acquire(Type, instanceKey = void 0, options = {}) {
654
+ const { canCreate = true, countRef = true } = options;
655
+ const args = options.args;
656
+ const resolvedKey = this.resolveKey(Type, instanceKey, args);
657
+ const config = {
658
+ instanceId: resolvedKey,
659
+ args
660
+ };
661
+ const instances = this.ensureInstancesMap(Type);
662
+ let entry = instances.get(resolvedKey);
663
+ if (entry?.instance.isDisposed) {
664
+ instances.delete(resolvedKey);
665
+ entry = void 0;
666
+ }
667
+ if (entry) {
668
+ if (process.env.NODE_ENV !== "production" && args !== void 0 && entry.args !== void 0) {
669
+ const incomingKey = structuralKey(args);
670
+ const storedKey = structuralKey(entry.args);
671
+ if (incomingKey !== storedKey) console.warn(`${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.`);
672
+ }
673
+ if (countRef) {
674
+ const refId = options.refId ?? `_auto_${this._autoRefIdCounter++}`;
675
+ entry.refs.set(refId, (entry.refs.get(refId) ?? 0) + 1);
676
+ this.assertRefLimit(Type, resolvedKey, entry.refs.size);
677
+ this.emit("refAcquired", entry.instance, refId);
678
+ }
679
+ return entry.instance;
680
+ }
681
+ if (!canCreate) throw new Error(`${BLAC_ERROR_PREFIX} ${Type.name} instance "${resolvedKey}" not found and creation is disabled.`);
682
+ this.assertInstanceLimit(Type, instances.size);
683
+ const instance = new Type();
684
+ instance.initConfig(config);
685
+ const initialRefs = /* @__PURE__ */ new Map();
686
+ let initialRefId;
687
+ if (countRef) {
688
+ initialRefId = options.refId ?? `_auto_${this._autoRefIdCounter++}`;
689
+ initialRefs.set(initialRefId, 1);
690
+ }
691
+ instances.set(resolvedKey, {
692
+ instance,
693
+ refs: initialRefs,
694
+ args
695
+ });
696
+ this.registerType(Type);
697
+ if (initialRefId) this.emit("refAcquired", instance, initialRefId);
698
+ return instance;
699
+ }
700
+ /**
701
+ * Borrow an existing instance without adding a ref (borrowing semantics).
702
+ * Tracks cross-bloc dependency for reactive updates.
703
+ * @param Type - The StateContainer class constructor
704
+ * @param instanceKey - Instance key (defaults to 'default')
705
+ * @returns The state container instance
706
+ * @throws Error if instance doesn't exist
707
+ */
708
+ borrow(Type, instanceKey = BLAC_DEFAULTS.DEFAULT_INSTANCE_KEY) {
709
+ return this.acquire(Type, instanceKey, {
710
+ canCreate: false,
711
+ countRef: false
712
+ });
713
+ }
714
+ /**
715
+ * Safely borrow an existing instance (borrowing semantics with error handling).
716
+ * Returns discriminated union for type-safe conditional access.
717
+ * @param Type - The StateContainer class constructor
718
+ * @param instanceKey - Instance key (defaults to 'default')
719
+ * @returns Discriminated union with either the instance or an error
720
+ */
721
+ borrowSafe(Type, instanceKey = BLAC_DEFAULTS.DEFAULT_INSTANCE_KEY) {
722
+ try {
723
+ return {
724
+ error: null,
725
+ instance: this.borrow(Type, instanceKey)
726
+ };
727
+ } catch (error) {
728
+ return {
729
+ error,
730
+ instance: null
731
+ };
732
+ }
733
+ }
734
+ /**
735
+ * Ensure an instance exists without taking ownership (for bloc-to-bloc communication).
736
+ * Gets existing instance OR creates it if it doesn't exist, without adding a ref.
737
+ * Tracks cross-bloc dependency for reactive updates.
738
+ *
739
+ * Use this in bloc-to-bloc communication when you need to ensure an instance exists
740
+ * but don't want to claim ownership (no ref added).
741
+ * @param Type - The StateContainer class constructor
742
+ * @param instanceKey - Explicit instance key, or undefined to derive from `args`
743
+ * (`static key(args)` / structural hash), matching `acquire`.
744
+ * @param args - Construction args; used for keying when no explicit key is given
745
+ * @returns The state container instance
746
+ */
747
+ ensure(Type, instanceKey = void 0, args) {
748
+ return this.acquire(Type, instanceKey, {
749
+ canCreate: true,
750
+ countRef: false,
751
+ args
752
+ });
753
+ }
754
+ /**
755
+ * Release a reference to an instance.
756
+ * Removes the ref and disposes when refs is empty (unless keepAlive).
757
+ * Releasing an already-removed refId is a no-op (idempotent).
758
+ * @param Type - The StateContainer class constructor
759
+ * @param instanceKey - Instance key (defaults to 'default')
760
+ * @param forceDispose - Force immediate disposal regardless of refs
761
+ * @param refId - The specific ref to remove; removes one arbitrary ref if omitted
762
+ */
763
+ release(Type, instanceKey = BLAC_DEFAULTS.DEFAULT_INSTANCE_KEY, forceDispose = false, refId) {
764
+ const instances = this.ensureInstancesMap(Type);
765
+ const entry = instances.get(instanceKey);
766
+ if (!entry) return;
767
+ if (forceDispose) {
768
+ if (!entry.instance.isDisposed) entry.instance.dispose();
769
+ instances.delete(instanceKey);
770
+ return;
771
+ }
772
+ let releasedRefId;
773
+ if (refId !== void 0) {
774
+ const count = entry.refs.get(refId) ?? 0;
775
+ if (count <= 1) entry.refs.delete(refId);
776
+ else entry.refs.set(refId, count - 1);
777
+ releasedRefId = refId;
778
+ } else {
779
+ const firstKey = entry.refs.keys().next().value;
780
+ if (firstKey !== void 0) {
781
+ const count = entry.refs.get(firstKey) ?? 0;
782
+ if (count <= 1) entry.refs.delete(firstKey);
783
+ else entry.refs.set(firstKey, count - 1);
784
+ releasedRefId = firstKey;
785
+ }
786
+ }
787
+ if (releasedRefId) this.emit("refReleased", entry.instance, releasedRefId);
788
+ const keepAlive = isKeepAliveClass(Type);
789
+ if (entry.refs.size === 0 && !keepAlive) {
790
+ const deps = entry.instance.dependencies;
791
+ if (!entry.instance.isDisposed) entry.instance.dispose();
792
+ instances.delete(instanceKey);
793
+ for (const [DepType, depKey] of deps) {
794
+ const depInstances = this.ensureInstancesMap(DepType);
795
+ const depEntry = depInstances.get(depKey);
796
+ if (depEntry && depEntry.refs.size === 0 && !isKeepAliveClass(DepType) && !depEntry.instance.isDisposed) {
797
+ depEntry.instance.dispose();
798
+ depInstances.delete(depKey);
799
+ }
800
+ }
801
+ }
802
+ }
803
+ /**
804
+ * Get all instances of a specific type.
805
+ * @param Type - The StateContainer class constructor
806
+ * @returns Array of all instances
807
+ */
808
+ getAll(Type) {
809
+ const instances = this.ensureInstancesMap(Type);
810
+ const result = [];
811
+ for (const entry of instances.values()) result.push(entry.instance);
812
+ return result;
813
+ }
814
+ /**
815
+ * Safely iterate over all instances of a type.
816
+ * Skips disposed instances and catches callback errors.
817
+ * @param Type - The StateContainer class constructor
818
+ * @param callback - Function to call for each instance
819
+ */
820
+ forEach(Type, callback) {
821
+ const instances = this.ensureInstancesMap(Type);
822
+ for (const entry of instances.values()) {
823
+ const instance = entry.instance;
824
+ if (!instance.isDisposed) try {
825
+ callback(instance);
826
+ } catch (error) {
827
+ console.error(`${BLAC_ERROR_PREFIX} forEach callback error for ${Type.name}:`, error);
828
+ }
829
+ }
830
+ }
831
+ /**
832
+ * Clear all instances of a specific type (disposes them).
833
+ * @param Type - The StateContainer class constructor
834
+ */
835
+ clear(Type) {
836
+ const instances = this.ensureInstancesMap(Type);
837
+ for (const entry of instances.values()) if (!entry.instance.isDisposed) entry.instance.dispose();
838
+ instances.clear();
839
+ }
840
+ /**
841
+ * Get reference count for an instance (number of active refs).
842
+ * @param Type - The StateContainer class constructor
843
+ * @param instanceKey - Instance key (defaults to 'default')
844
+ * @returns Current ref count (0 if instance doesn't exist)
845
+ */
846
+ getRefCount(Type, instanceKey = BLAC_DEFAULTS.DEFAULT_INSTANCE_KEY) {
847
+ return this.ensureInstancesMap(Type).get(instanceKey)?.refs.size ?? 0;
848
+ }
849
+ /**
850
+ * Get all active reference IDs for an instance.
851
+ * @param Type - The StateContainer class constructor
852
+ * @param instanceKey - Instance key (defaults to 'default')
853
+ * @returns Array of ref ID strings (empty if instance doesn't exist)
854
+ */
855
+ getRefIds(Type, instanceKey = BLAC_DEFAULTS.DEFAULT_INSTANCE_KEY) {
856
+ const instances = this.instancesByConstructor.get(Type);
857
+ if (!instances) return [];
858
+ const entry = instances.get(instanceKey);
859
+ return entry ? Array.from(entry.refs.keys()) : [];
860
+ }
861
+ /**
862
+ * Check if an instance exists.
863
+ * @param Type - The StateContainer class constructor
864
+ * @param instanceKey - Instance key (defaults to 'default')
865
+ * @returns true if instance exists
866
+ */
867
+ hasInstance(Type, instanceKey = BLAC_DEFAULTS.DEFAULT_INSTANCE_KEY) {
868
+ return this.ensureInstancesMap(Type).has(instanceKey);
869
+ }
870
+ /**
871
+ * Clear all instances from all types (for testing)
872
+ *
873
+ * Iterates all registered types and clears their instances.
874
+ * Also clears type tracking to reset the registry state.
875
+ */
876
+ clearAll() {
877
+ for (const Type of this.types) this.clear(Type);
878
+ this.types.clear();
879
+ this.registeredTypeNames.clear();
880
+ }
881
+ /**
882
+ * Get registry statistics for debugging.
883
+ * @returns Object with registeredTypes, totalInstances, and typeBreakdown
884
+ */
885
+ getStats() {
886
+ const typeBreakdown = {};
887
+ let totalInstances = 0;
888
+ for (const Type of this.types) {
889
+ const typeName = Type.name;
890
+ const count = this.getInstancesMap(Type).size;
891
+ typeBreakdown[typeName] = count;
892
+ totalInstances += count;
893
+ }
894
+ return {
895
+ registeredTypes: this.types.size,
896
+ totalInstances,
897
+ typeBreakdown
898
+ };
899
+ }
900
+ /**
901
+ * Get all registered types (for plugin system).
902
+ * @returns Array of all registered StateContainer class constructors
903
+ */
904
+ getTypes() {
905
+ return Array.from(this.types);
906
+ }
907
+ /**
908
+ * Subscribe to lifecycle events
909
+ * @param event - The lifecycle event to listen for
910
+ * @param listener - The listener function to call when the event occurs
911
+ * @returns Unsubscribe function
912
+ */
913
+ on(event, listener) {
914
+ if (!this.listeners.has(event)) this.listeners.set(event, /* @__PURE__ */ new Set());
915
+ const instance = this.listeners.get(event);
916
+ if (!instance) throw new Error(`${BLAC_ERROR_PREFIX} Failed to register listener for event '${event}'`);
917
+ instance.add(listener);
918
+ if (event === "stateChanged") this._stateChangedListenerCount++;
919
+ return () => {
920
+ if (this.listeners.get(event)?.delete(listener) && event === "stateChanged") this._stateChangedListenerCount--;
921
+ };
922
+ }
923
+ emit(event, ...args) {
924
+ const listeners = this.listeners.get(event);
925
+ if (!listeners || listeners.size === 0) return;
926
+ for (const listener of listeners) try {
927
+ listener(...args);
928
+ } catch (error) {
929
+ console.error(`${BLAC_ERROR_PREFIX} Listener error for '${event}':`, error);
930
+ }
931
+ }
932
+ /**
933
+ * Schedule a deferred stateChanged notification via microtask.
934
+ * Skips entirely when no stateChanged listeners are registered.
935
+ * @internal - Called by StateContainer.applyState
936
+ */
937
+ notifyStateChanged(container, previousState, newState) {
938
+ if (this._stateChangedListenerCount === 0) return;
939
+ if (!this._pendingStateChanges) {
940
+ this._pendingStateChanges = [];
941
+ queueMicrotask(() => this.flushStateChanged());
942
+ }
943
+ this._pendingStateChanges.push([
944
+ container,
945
+ previousState,
946
+ newState
947
+ ]);
948
+ }
949
+ flushStateChanged() {
950
+ const pending = this._pendingStateChanges;
951
+ this._pendingStateChanges = null;
952
+ if (!pending) return;
953
+ for (const [container, prev, next] of pending) this.emit("stateChanged", container, prev, next);
954
+ }
955
+ };
956
+ /**
957
+ * Global default registry instance
958
+ */
959
+ const globalRegistry = new StateContainerRegistry();
960
+ /**
961
+ * Global plugin manager (initialized lazily)
962
+ */
963
+ let _globalPluginManager = null;
964
+ /**
965
+ * Get the global plugin manager
966
+ */
967
+ function getPluginManager() {
968
+ if (!_globalPluginManager) _globalPluginManager = createPluginManager(globalRegistry);
969
+ return _globalPluginManager;
970
+ }
971
+ //#endregion
972
+ Object.defineProperty(exports, "BLAC_DEFAULTS", {
973
+ enumerable: true,
974
+ get: function() {
975
+ return BLAC_DEFAULTS;
976
+ }
977
+ });
978
+ Object.defineProperty(exports, "BLAC_STATIC_PROPS", {
979
+ enumerable: true,
980
+ get: function() {
981
+ return BLAC_STATIC_PROPS;
982
+ }
983
+ });
984
+ Object.defineProperty(exports, "PluginManager", {
985
+ enumerable: true,
986
+ get: function() {
987
+ return PluginManager;
988
+ }
989
+ });
990
+ Object.defineProperty(exports, "StateContainerRegistry", {
991
+ enumerable: true,
992
+ get: function() {
993
+ return StateContainerRegistry;
994
+ }
995
+ });
996
+ Object.defineProperty(exports, "configureBlac", {
997
+ enumerable: true,
998
+ get: function() {
999
+ return configureBlac;
1000
+ }
1001
+ });
1002
+ Object.defineProperty(exports, "getBlacConfig", {
1003
+ enumerable: true,
1004
+ get: function() {
1005
+ return getBlacConfig;
1006
+ }
1007
+ });
1008
+ Object.defineProperty(exports, "getClassEquality", {
1009
+ enumerable: true,
1010
+ get: function() {
1011
+ return getClassEquality;
1012
+ }
1013
+ });
1014
+ Object.defineProperty(exports, "getPluginManager", {
1015
+ enumerable: true,
1016
+ get: function() {
1017
+ return getPluginManager;
1018
+ }
1019
+ });
1020
+ Object.defineProperty(exports, "globalRegistry", {
1021
+ enumerable: true,
1022
+ get: function() {
1023
+ return globalRegistry;
1024
+ }
1025
+ });
1026
+ Object.defineProperty(exports, "isExcludedFromDevTools", {
1027
+ enumerable: true,
1028
+ get: function() {
1029
+ return isExcludedFromDevTools;
1030
+ }
1031
+ });
1032
+ Object.defineProperty(exports, "isIsolatedClass", {
1033
+ enumerable: true,
1034
+ get: function() {
1035
+ return isIsolatedClass;
1036
+ }
1037
+ });
1038
+ Object.defineProperty(exports, "isKeepAliveClass", {
1039
+ enumerable: true,
1040
+ get: function() {
1041
+ return isKeepAliveClass;
1042
+ }
1043
+ });
1044
+ Object.defineProperty(exports, "resetBlacConfig", {
1045
+ enumerable: true,
1046
+ get: function() {
1047
+ return resetBlacConfig;
1048
+ }
1049
+ });
1050
+ Object.defineProperty(exports, "shallowEqualState", {
1051
+ enumerable: true,
1052
+ get: function() {
1053
+ return shallowEqualState;
1054
+ }
1055
+ });
1056
+
1057
+ //# sourceMappingURL=StateContainerRegistry-B4yVMYbx.cjs.map