@blac/core 2.1.0 → 2.1.2

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 (391) hide show
  1. package/README.md +19 -29
  2. package/dist/StateContainer-BUyuxKb3.cjs +667 -0
  3. package/dist/StateContainer-BUyuxKb3.cjs.map +1 -0
  4. package/dist/StateContainer-B_7UHc3I.js +632 -0
  5. package/dist/StateContainer-B_7UHc3I.js.map +1 -0
  6. package/dist/StateContainer-Bh2ipNYj.js +632 -0
  7. package/dist/StateContainer-Bh2ipNYj.js.map +1 -0
  8. package/dist/StateContainer-ClzwKnQZ.cjs +667 -0
  9. package/dist/StateContainer-ClzwKnQZ.cjs.map +1 -0
  10. package/dist/StateContainer-CwByTd5L.js +656 -0
  11. package/dist/StateContainer-CwByTd5L.js.map +1 -0
  12. package/dist/StateContainer-D2b10eR4.cjs +691 -0
  13. package/dist/StateContainer-D2b10eR4.cjs.map +1 -0
  14. package/dist/StateContainer-DiQATvZh.js +632 -0
  15. package/dist/StateContainer-DiQATvZh.js.map +1 -0
  16. package/dist/StateContainer-j16zciex.cjs +667 -0
  17. package/dist/StateContainer-j16zciex.cjs.map +1 -0
  18. package/dist/{StateContainerRegistry-CSNm2Ws5.cjs → StateContainerRegistry-141uHhtF.cjs} +300 -397
  19. package/dist/StateContainerRegistry-141uHhtF.cjs.map +1 -0
  20. package/dist/StateContainerRegistry-B6O6cfJd.cjs +903 -0
  21. package/dist/StateContainerRegistry-B6O6cfJd.cjs.map +1 -0
  22. package/dist/{StateContainerRegistry-DVIBTxGZ.js → StateContainerRegistry-BH7aOMWV.js} +299 -406
  23. package/dist/StateContainerRegistry-BH7aOMWV.js.map +1 -0
  24. package/dist/StateContainerRegistry-BX-DlHXO.js +747 -0
  25. package/dist/StateContainerRegistry-BX-DlHXO.js.map +1 -0
  26. package/dist/StateContainerRegistry-Bf5VuVjm.js +747 -0
  27. package/dist/StateContainerRegistry-Bf5VuVjm.js.map +1 -0
  28. package/dist/{StateContainerRegistry-Dj77cok9.js → StateContainerRegistry-BsH_s0pJ.js} +303 -413
  29. package/dist/StateContainerRegistry-BsH_s0pJ.js.map +1 -0
  30. package/dist/StateContainerRegistry-BvSRfhKv.cjs +866 -0
  31. package/dist/StateContainerRegistry-BvSRfhKv.cjs.map +1 -0
  32. package/dist/StateContainerRegistry-C8jxrcqk.cjs +866 -0
  33. package/dist/StateContainerRegistry-C8jxrcqk.cjs.map +1 -0
  34. package/dist/{StateContainerRegistry-lIwo-0m3.cjs → StateContainerRegistry-CBLeHObO.cjs} +326 -418
  35. package/dist/StateContainerRegistry-CBLeHObO.cjs.map +1 -0
  36. package/dist/StateContainerRegistry-CrTtRX5V.js +772 -0
  37. package/dist/StateContainerRegistry-CrTtRX5V.js.map +1 -0
  38. package/dist/StateContainerRegistry-DjQQtlCW.cjs +870 -0
  39. package/dist/StateContainerRegistry-DjQQtlCW.cjs.map +1 -0
  40. package/dist/{StateContainerRegistry-D9BIRjwv.cjs → StateContainerRegistry-MkT0W4C2.cjs} +322 -411
  41. package/dist/StateContainerRegistry-MkT0W4C2.cjs.map +1 -0
  42. package/dist/StateContainerRegistry-gQbEutkN.js +751 -0
  43. package/dist/StateContainerRegistry-gQbEutkN.js.map +1 -0
  44. package/dist/{StateContainerRegistry-CvBOhAT2.js → StateContainerRegistry-vWgsD-RP.js} +277 -392
  45. package/dist/StateContainerRegistry-vWgsD-RP.js.map +1 -0
  46. package/dist/config.d.cts +8 -8
  47. package/dist/config.d.ts +8 -8
  48. package/dist/constants.d.cts +20 -28
  49. package/dist/constants.d.ts +20 -28
  50. package/dist/core/Cubit.d.ts +14 -10
  51. package/dist/core/StateContainer.d.ts +89 -62
  52. package/dist/core/StateContainerRegistry.d.ts +89 -166
  53. package/dist/core/meta.d.ts +37 -47
  54. package/dist/core/onActivated.d.ts +10 -0
  55. package/dist/core/symbols.d.ts +26 -1
  56. package/dist/decorators/blac.d.ts +38 -28
  57. package/dist/{acquire-B1LYXSGj.js → ensure-Bi_yXk6f.js} +16 -5
  58. package/dist/ensure-Bi_yXk6f.js.map +1 -0
  59. package/dist/{ensure-r1C_7K6_.cjs → ensure-BjhbDW8Z.cjs} +203 -160
  60. package/dist/ensure-BjhbDW8Z.cjs.map +1 -0
  61. package/dist/{ensure-BSJHkUNX.js → ensure-BnVyd6s4.js} +297 -122
  62. package/dist/ensure-BnVyd6s4.js.map +1 -0
  63. package/dist/{acquire-BZIs6tpN.cjs → ensure-Bx41d-il.cjs} +23 -6
  64. package/dist/ensure-Bx41d-il.cjs.map +1 -0
  65. package/dist/{acquire-BRIJVJaA.js → ensure-C7UQ_mKM.js} +16 -5
  66. package/dist/ensure-C7UQ_mKM.js.map +1 -0
  67. package/dist/{ensure-B59ri8oo.js → ensure-CneMkpbI.js} +298 -122
  68. package/dist/ensure-CneMkpbI.js.map +1 -0
  69. package/dist/{acquire-BdsVZBSe.js → ensure-CwtQVTam.js} +16 -5
  70. package/dist/ensure-CwtQVTam.js.map +1 -0
  71. package/dist/{ensure-B2DYCbbI.cjs → ensure-D15vGnk5.cjs} +328 -123
  72. package/dist/ensure-D15vGnk5.cjs.map +1 -0
  73. package/dist/{acquire-B1Wuqla6.cjs → ensure-D1D4WjYf.cjs} +23 -6
  74. package/dist/ensure-D1D4WjYf.cjs.map +1 -0
  75. package/dist/{ensure-BKdq5xsY.cjs → ensure-D3w6YGp9.cjs} +329 -123
  76. package/dist/ensure-D3w6YGp9.cjs.map +1 -0
  77. package/dist/{acquire-BJ3xUEmh.cjs → ensure-DBnuRJ0R.cjs} +23 -6
  78. package/dist/ensure-DBnuRJ0R.cjs.map +1 -0
  79. package/dist/{acquire-B_p1fNEh.cjs → ensure-DShrbIYY.cjs} +23 -6
  80. package/dist/ensure-DShrbIYY.cjs.map +1 -0
  81. package/dist/{acquire-BP-ZfUH2.js → ensure-NTB9nnnj.js} +16 -5
  82. package/dist/ensure-NTB9nnnj.js.map +1 -0
  83. package/dist/{ensure-D3WWWwMo.cjs → ensure-ORVw-WRE.cjs} +194 -155
  84. package/dist/ensure-ORVw-WRE.cjs.map +1 -0
  85. package/dist/{ensure-BEeY5Ab7.js → ensure-dsqWhIuO.js} +182 -147
  86. package/dist/ensure-dsqWhIuO.js.map +1 -0
  87. package/dist/{ensure-11-asM1e.js → ensure-k-6q7O25.js} +173 -150
  88. package/dist/ensure-k-6q7O25.js.map +1 -0
  89. package/dist/index.cjs +257 -86
  90. package/dist/index.cjs.map +1 -1
  91. package/dist/index.d.cts +6 -13
  92. package/dist/index.d.ts +6 -13
  93. package/dist/index.js +232 -52
  94. package/dist/index.js.map +1 -1
  95. package/dist/internal.cjs +10 -0
  96. package/dist/internal.d.cts +8 -0
  97. package/dist/internal.d.ts +8 -0
  98. package/dist/internal.js +3 -0
  99. package/dist/plugin/BlacPlugin.d.ts +25 -25
  100. package/dist/plugin/PluginManager.d.ts +46 -59
  101. package/dist/plugins.cjs +383 -3
  102. package/dist/plugins.cjs.map +1 -0
  103. package/dist/plugins.d.cts +10 -5
  104. package/dist/plugins.d.ts +10 -5
  105. package/dist/plugins.js +381 -1
  106. package/dist/plugins.js.map +1 -0
  107. package/dist/registry/acquire.d.ts +2 -2
  108. package/dist/registry/config.d.ts +12 -0
  109. package/dist/registry/index.d.ts +2 -2
  110. package/dist/registry/management.d.ts +5 -0
  111. package/dist/registry/queries.d.ts +15 -0
  112. package/dist/registry/release.d.ts +4 -20
  113. package/dist/testing.cjs +63 -38
  114. package/dist/testing.cjs.map +1 -1
  115. package/dist/testing.d.cts +14 -12
  116. package/dist/testing.d.ts +14 -12
  117. package/dist/testing.js +53 -29
  118. package/dist/testing.js.map +1 -1
  119. package/dist/types/branded.d.ts +6 -13
  120. package/dist/types/utilities.d.ts +40 -31
  121. package/dist/utils/idGenerator.d.ts +6 -13
  122. package/dist/utils/static-props.d.ts +28 -29
  123. package/dist/utils/structural-key.d.ts +0 -22
  124. package/dist/watch/index.d.ts +1 -2
  125. package/dist/watch/watch.d.ts +23 -3
  126. package/package.json +28 -54
  127. package/dist/StateContainerRegistry-4Ljd9EJx.js +0 -1018
  128. package/dist/StateContainerRegistry-4Ljd9EJx.js.map +0 -1
  129. package/dist/StateContainerRegistry-8zNFMAf7.js +0 -1067
  130. package/dist/StateContainerRegistry-8zNFMAf7.js.map +0 -1
  131. package/dist/StateContainerRegistry-B1GYx9Xo.js +0 -975
  132. package/dist/StateContainerRegistry-B1GYx9Xo.js.map +0 -1
  133. package/dist/StateContainerRegistry-B_ViBLvJ.js +0 -975
  134. package/dist/StateContainerRegistry-B_ViBLvJ.js.map +0 -1
  135. package/dist/StateContainerRegistry-Bx2ly-ba.cjs +0 -1162
  136. package/dist/StateContainerRegistry-Bx2ly-ba.cjs.map +0 -1
  137. package/dist/StateContainerRegistry-C0dCNlTF.js +0 -1005
  138. package/dist/StateContainerRegistry-C0dCNlTF.js.map +0 -1
  139. package/dist/StateContainerRegistry-C75QpeaO.cjs +0 -1260
  140. package/dist/StateContainerRegistry-C75QpeaO.cjs.map +0 -1
  141. package/dist/StateContainerRegistry-CEWpc1bj.cjs +0 -1113
  142. package/dist/StateContainerRegistry-CEWpc1bj.cjs.map +0 -1
  143. package/dist/StateContainerRegistry-CS18y4au.cjs +0 -1163
  144. package/dist/StateContainerRegistry-CS18y4au.cjs.map +0 -1
  145. package/dist/StateContainerRegistry-CSNm2Ws5.cjs.map +0 -1
  146. package/dist/StateContainerRegistry-CchRjnjX.cjs +0 -1094
  147. package/dist/StateContainerRegistry-CchRjnjX.cjs.map +0 -1
  148. package/dist/StateContainerRegistry-CvBOhAT2.js.map +0 -1
  149. package/dist/StateContainerRegistry-D8nu7Z0T.js +0 -1068
  150. package/dist/StateContainerRegistry-D8nu7Z0T.js.map +0 -1
  151. package/dist/StateContainerRegistry-D9BIRjwv.cjs.map +0 -1
  152. package/dist/StateContainerRegistry-DJQqLrli.cjs +0 -1046
  153. package/dist/StateContainerRegistry-DJQqLrli.cjs.map +0 -1
  154. package/dist/StateContainerRegistry-DL5Ai7wh.js +0 -1153
  155. package/dist/StateContainerRegistry-DL5Ai7wh.js.map +0 -1
  156. package/dist/StateContainerRegistry-DVIBTxGZ.js.map +0 -1
  157. package/dist/StateContainerRegistry-DWOzx7Gd.js +0 -1154
  158. package/dist/StateContainerRegistry-DWOzx7Gd.js.map +0 -1
  159. package/dist/StateContainerRegistry-Dj77cok9.js.map +0 -1
  160. package/dist/StateContainerRegistry-FWKzPfS-.cjs +0 -1046
  161. package/dist/StateContainerRegistry-FWKzPfS-.cjs.map +0 -1
  162. package/dist/StateContainerRegistry-G81GcCRm.cjs +0 -1261
  163. package/dist/StateContainerRegistry-G81GcCRm.cjs.map +0 -1
  164. package/dist/StateContainerRegistry-lIwo-0m3.cjs.map +0 -1
  165. package/dist/acquire-B1LYXSGj.js.map +0 -1
  166. package/dist/acquire-B1Wuqla6.cjs.map +0 -1
  167. package/dist/acquire-BJ3xUEmh.cjs.map +0 -1
  168. package/dist/acquire-BP-ZfUH2.js.map +0 -1
  169. package/dist/acquire-BRIJVJaA.js.map +0 -1
  170. package/dist/acquire-BZIs6tpN.cjs.map +0 -1
  171. package/dist/acquire-B_p1fNEh.cjs.map +0 -1
  172. package/dist/acquire-BdsVZBSe.js.map +0 -1
  173. package/dist/acquire-C3nOb3XR.cjs +0 -46
  174. package/dist/acquire-C3nOb3XR.cjs.map +0 -1
  175. package/dist/acquire-C4WAS13G.cjs +0 -46
  176. package/dist/acquire-C4WAS13G.cjs.map +0 -1
  177. package/dist/acquire-C7beGI55.cjs +0 -46
  178. package/dist/acquire-C7beGI55.cjs.map +0 -1
  179. package/dist/acquire-CE0uq0Dx.cjs +0 -46
  180. package/dist/acquire-CE0uq0Dx.cjs.map +0 -1
  181. package/dist/acquire-CU0u8BMn.js +0 -35
  182. package/dist/acquire-CU0u8BMn.js.map +0 -1
  183. package/dist/acquire-CbMz7gWs.cjs +0 -46
  184. package/dist/acquire-CbMz7gWs.cjs.map +0 -1
  185. package/dist/acquire-CkgLJ8WL.cjs +0 -46
  186. package/dist/acquire-CkgLJ8WL.cjs.map +0 -1
  187. package/dist/acquire-CwB083au.js +0 -35
  188. package/dist/acquire-CwB083au.js.map +0 -1
  189. package/dist/acquire-DHEOEVcj.cjs +0 -46
  190. package/dist/acquire-DHEOEVcj.cjs.map +0 -1
  191. package/dist/acquire-DTvfYJ0y.js +0 -35
  192. package/dist/acquire-DTvfYJ0y.js.map +0 -1
  193. package/dist/acquire-DXEQDZGr.js +0 -35
  194. package/dist/acquire-DXEQDZGr.js.map +0 -1
  195. package/dist/acquire-Dg-uXwjF.js +0 -35
  196. package/dist/acquire-Dg-uXwjF.js.map +0 -1
  197. package/dist/acquire-Don7499S.js +0 -35
  198. package/dist/acquire-Don7499S.js.map +0 -1
  199. package/dist/acquire-G8aB3GAx.js +0 -35
  200. package/dist/acquire-G8aB3GAx.js.map +0 -1
  201. package/dist/branded-BybA0_xw.cjs +0 -18
  202. package/dist/branded-BybA0_xw.cjs.map +0 -1
  203. package/dist/branded-DkbUzncc.js +0 -13
  204. package/dist/branded-DkbUzncc.js.map +0 -1
  205. package/dist/config-8pyOC5gv.js +0 -16
  206. package/dist/config-8pyOC5gv.js.map +0 -1
  207. package/dist/config-B1l8ZGlU.cjs +0 -32
  208. package/dist/config-B1l8ZGlU.cjs.map +0 -1
  209. package/dist/config-C1T6Jw7n.cjs +0 -32
  210. package/dist/config-C1T6Jw7n.cjs.map +0 -1
  211. package/dist/config-C7Ktkjh2.cjs +0 -32
  212. package/dist/config-C7Ktkjh2.cjs.map +0 -1
  213. package/dist/config-COT4Xkbc.js +0 -16
  214. package/dist/config-COT4Xkbc.js.map +0 -1
  215. package/dist/config-CzcoAvBo.js +0 -16
  216. package/dist/config-CzcoAvBo.js.map +0 -1
  217. package/dist/config-D2A8ZYRM.js +0 -16
  218. package/dist/config-D2A8ZYRM.js.map +0 -1
  219. package/dist/config-D34BkraU.cjs +0 -32
  220. package/dist/config-D34BkraU.cjs.map +0 -1
  221. package/dist/config-D6BoWWPv.js +0 -16
  222. package/dist/config-D6BoWWPv.js.map +0 -1
  223. package/dist/config-DOO82lbZ.js +0 -16
  224. package/dist/config-DOO82lbZ.js.map +0 -1
  225. package/dist/config-DVM_ESQt.js +0 -16
  226. package/dist/config-DVM_ESQt.js.map +0 -1
  227. package/dist/config-DVMnlHLv.cjs +0 -32
  228. package/dist/config-DVMnlHLv.cjs.map +0 -1
  229. package/dist/config-DWUq7zEQ.cjs +0 -32
  230. package/dist/config-DWUq7zEQ.cjs.map +0 -1
  231. package/dist/config-DXI3kzmA.js +0 -16
  232. package/dist/config-DXI3kzmA.js.map +0 -1
  233. package/dist/config-Dk1FxfXj.js +0 -16
  234. package/dist/config-Dk1FxfXj.js.map +0 -1
  235. package/dist/config-ZVy_yFZ3.js +0 -16
  236. package/dist/config-ZVy_yFZ3.js.map +0 -1
  237. package/dist/config-b2z51Y_C.cjs +0 -32
  238. package/dist/config-b2z51Y_C.cjs.map +0 -1
  239. package/dist/config-buwpT7l3.js +0 -16
  240. package/dist/config-buwpT7l3.js.map +0 -1
  241. package/dist/config-cwaTn5oy.cjs +0 -32
  242. package/dist/config-cwaTn5oy.cjs.map +0 -1
  243. package/dist/config-d9_U58ef.cjs +0 -32
  244. package/dist/config-d9_U58ef.cjs.map +0 -1
  245. package/dist/config-hWTayX76.cjs +0 -32
  246. package/dist/config-hWTayX76.cjs.map +0 -1
  247. package/dist/config-sCPKPYxZ.cjs +0 -32
  248. package/dist/config-sCPKPYxZ.cjs.map +0 -1
  249. package/dist/debug.cjs +0 -14
  250. package/dist/debug.d.cts +0 -34
  251. package/dist/debug.d.ts +0 -34
  252. package/dist/debug.js +0 -4
  253. package/dist/ensure-11-asM1e.js.map +0 -1
  254. package/dist/ensure-B1dEDsZV.cjs +0 -559
  255. package/dist/ensure-B1dEDsZV.cjs.map +0 -1
  256. package/dist/ensure-B2DYCbbI.cjs.map +0 -1
  257. package/dist/ensure-B59ri8oo.js.map +0 -1
  258. package/dist/ensure-B9oOqpOB.cjs +0 -558
  259. package/dist/ensure-B9oOqpOB.cjs.map +0 -1
  260. package/dist/ensure-BEeY5Ab7.js.map +0 -1
  261. package/dist/ensure-BKdq5xsY.cjs.map +0 -1
  262. package/dist/ensure-BSJHkUNX.js.map +0 -1
  263. package/dist/ensure-BfYnvAsI.js +0 -709
  264. package/dist/ensure-BfYnvAsI.js.map +0 -1
  265. package/dist/ensure-Bm91o37h.js +0 -536
  266. package/dist/ensure-Bm91o37h.js.map +0 -1
  267. package/dist/ensure-C1a8IFWy.js +0 -535
  268. package/dist/ensure-C1a8IFWy.js.map +0 -1
  269. package/dist/ensure-CLQEx0Nn.cjs +0 -528
  270. package/dist/ensure-CLQEx0Nn.cjs.map +0 -1
  271. package/dist/ensure-CPMiGvov.js +0 -493
  272. package/dist/ensure-CPMiGvov.js.map +0 -1
  273. package/dist/ensure-CQimeD0I.cjs +0 -559
  274. package/dist/ensure-CQimeD0I.cjs.map +0 -1
  275. package/dist/ensure-D3WWWwMo.cjs.map +0 -1
  276. package/dist/ensure-DEXSmA-N.js +0 -526
  277. package/dist/ensure-DEXSmA-N.js.map +0 -1
  278. package/dist/ensure-DTTTd2h8.js +0 -536
  279. package/dist/ensure-DTTTd2h8.js.map +0 -1
  280. package/dist/ensure-Dx86f80B.cjs +0 -567
  281. package/dist/ensure-Dx86f80B.cjs.map +0 -1
  282. package/dist/ensure-DzqGej43.js +0 -526
  283. package/dist/ensure-DzqGej43.js.map +0 -1
  284. package/dist/ensure-VuiNPccZ.cjs +0 -559
  285. package/dist/ensure-VuiNPccZ.cjs.map +0 -1
  286. package/dist/ensure-_Oh8XPm4.cjs +0 -732
  287. package/dist/ensure-_Oh8XPm4.cjs.map +0 -1
  288. package/dist/ensure-fsQMjaQL.cjs +0 -567
  289. package/dist/ensure-fsQMjaQL.cjs.map +0 -1
  290. package/dist/ensure-r1C_7K6_.cjs.map +0 -1
  291. package/dist/ensure-vxAGa2v3.js +0 -536
  292. package/dist/ensure-vxAGa2v3.js.map +0 -1
  293. package/dist/events.d.cts +0 -42
  294. package/dist/events.d.ts +0 -42
  295. package/dist/management-14vsHr4t.cjs +0 -85
  296. package/dist/management-14vsHr4t.cjs.map +0 -1
  297. package/dist/management-444tdCBG.js +0 -38
  298. package/dist/management-444tdCBG.js.map +0 -1
  299. package/dist/management-7jLjVHJd.js +0 -38
  300. package/dist/management-7jLjVHJd.js.map +0 -1
  301. package/dist/management-8x1OVMi6.js +0 -38
  302. package/dist/management-8x1OVMi6.js.map +0 -1
  303. package/dist/management-AFuqQEwz.js +0 -38
  304. package/dist/management-AFuqQEwz.js.map +0 -1
  305. package/dist/management-BZgsi29F.js +0 -38
  306. package/dist/management-BZgsi29F.js.map +0 -1
  307. package/dist/management-BodVLAfJ.cjs +0 -85
  308. package/dist/management-BodVLAfJ.cjs.map +0 -1
  309. package/dist/management-BqGBdL01.js +0 -38
  310. package/dist/management-BqGBdL01.js.map +0 -1
  311. package/dist/management-BvUAjril.js +0 -38
  312. package/dist/management-BvUAjril.js.map +0 -1
  313. package/dist/management-C-WGcwPD.js +0 -38
  314. package/dist/management-C-WGcwPD.js.map +0 -1
  315. package/dist/management-C2wv4vGS.cjs +0 -85
  316. package/dist/management-C2wv4vGS.cjs.map +0 -1
  317. package/dist/management-D2pjr38g.js +0 -38
  318. package/dist/management-D2pjr38g.js.map +0 -1
  319. package/dist/management-D5WsZoTV.js +0 -38
  320. package/dist/management-D5WsZoTV.js.map +0 -1
  321. package/dist/management-DAV9sN-k.cjs +0 -85
  322. package/dist/management-DAV9sN-k.cjs.map +0 -1
  323. package/dist/management-Df7Y2sF1.cjs +0 -85
  324. package/dist/management-Df7Y2sF1.cjs.map +0 -1
  325. package/dist/management-Dg2SxUb6.cjs +0 -85
  326. package/dist/management-Dg2SxUb6.cjs.map +0 -1
  327. package/dist/management-DwO0nBzL.cjs +0 -85
  328. package/dist/management-DwO0nBzL.cjs.map +0 -1
  329. package/dist/management-GcnNJjnm.cjs +0 -85
  330. package/dist/management-GcnNJjnm.cjs.map +0 -1
  331. package/dist/management-P_Vi_cvw.js +0 -38
  332. package/dist/management-P_Vi_cvw.js.map +0 -1
  333. package/dist/management-QWLpbXlW.cjs +0 -85
  334. package/dist/management-QWLpbXlW.cjs.map +0 -1
  335. package/dist/management-hkY13log.cjs +0 -85
  336. package/dist/management-hkY13log.cjs.map +0 -1
  337. package/dist/management-iE4x6IQY.cjs +0 -85
  338. package/dist/management-iE4x6IQY.cjs.map +0 -1
  339. package/dist/types.cjs +0 -3
  340. package/dist/types.d.cts +0 -8
  341. package/dist/types.d.ts +0 -8
  342. package/dist/types.js +0 -2
  343. package/dist/watch/observe.d.ts +0 -13
  344. package/dist/watch-B0pUfh-v.cjs +0 -119
  345. package/dist/watch-B0pUfh-v.cjs.map +0 -1
  346. package/dist/watch-B91opmva.cjs +0 -70
  347. package/dist/watch-B91opmva.cjs.map +0 -1
  348. package/dist/watch-BDiwCPmb.js +0 -108
  349. package/dist/watch-BDiwCPmb.js.map +0 -1
  350. package/dist/watch-BHfCtbn1.cjs +0 -119
  351. package/dist/watch-BHfCtbn1.cjs.map +0 -1
  352. package/dist/watch-BW7gYiDf.js +0 -108
  353. package/dist/watch-BW7gYiDf.js.map +0 -1
  354. package/dist/watch-BmC-Tyqg.js +0 -59
  355. package/dist/watch-BmC-Tyqg.js.map +0 -1
  356. package/dist/watch-Bx0y-Kcc.js +0 -108
  357. package/dist/watch-Bx0y-Kcc.js.map +0 -1
  358. package/dist/watch-CKWt788i.cjs +0 -70
  359. package/dist/watch-CKWt788i.cjs.map +0 -1
  360. package/dist/watch-CfrSSrRY.js +0 -59
  361. package/dist/watch-CfrSSrRY.js.map +0 -1
  362. package/dist/watch-Cnh3PtQA.cjs +0 -70
  363. package/dist/watch-Cnh3PtQA.cjs.map +0 -1
  364. package/dist/watch-D01MdwKy.js +0 -108
  365. package/dist/watch-D01MdwKy.js.map +0 -1
  366. package/dist/watch-D8hwbFU1.js +0 -59
  367. package/dist/watch-D8hwbFU1.js.map +0 -1
  368. package/dist/watch-DPVUwPUY.js +0 -59
  369. package/dist/watch-DPVUwPUY.js.map +0 -1
  370. package/dist/watch-DVmvZBMD.cjs +0 -70
  371. package/dist/watch-DVmvZBMD.cjs.map +0 -1
  372. package/dist/watch-DkDGmGAx.cjs +0 -119
  373. package/dist/watch-DkDGmGAx.cjs.map +0 -1
  374. package/dist/watch-DttHqefn.js +0 -108
  375. package/dist/watch-DttHqefn.js.map +0 -1
  376. package/dist/watch-DxdIZjpt.cjs +0 -119
  377. package/dist/watch-DxdIZjpt.cjs.map +0 -1
  378. package/dist/watch-DztcJuUy.cjs +0 -119
  379. package/dist/watch-DztcJuUy.cjs.map +0 -1
  380. package/dist/watch-IrR8G28N.js +0 -108
  381. package/dist/watch-IrR8G28N.js.map +0 -1
  382. package/dist/watch-aoNLQAXp.cjs +0 -119
  383. package/dist/watch-aoNLQAXp.cjs.map +0 -1
  384. package/dist/watch-entry.cjs +0 -4
  385. package/dist/watch-entry.d.cts +0 -24
  386. package/dist/watch-entry.d.ts +0 -24
  387. package/dist/watch-entry.js +0 -2
  388. package/dist/watch-hx0r92Zc.js +0 -108
  389. package/dist/watch-hx0r92Zc.js.map +0 -1
  390. package/dist/watch-lEco5Tbl.cjs +0 -119
  391. package/dist/watch-lEco5Tbl.cjs.map +0 -1
package/dist/index.d.cts CHANGED
@@ -1,26 +1,19 @@
1
1
  export { configureBlac, getBlacConfig, resetBlacConfig, shallowEqualState, type BlacConfig, type EqualityFn, } from './config';
2
- export { StateContainer, DEP_BRAND } from './core/StateContainer';
2
+ export { StateContainer } from './core/StateContainer';
3
+ export { onActivated } from './core/onActivated';
3
4
  export type { HydrationStatus, StateContainerConfig, SystemEvent, SystemEventPayloads, DepHandle, } from './core/StateContainer';
4
5
  export { Cubit } from './core/Cubit';
5
- /**
6
- * @internal symbols — read by `@blac/react` (APPLY_DEPS / REMOVE_DEPS_OWNER),
7
- * in-package tests (INIT_CONFIG), and `watch()` (ON_DISPOSE).
8
- */
9
- export { APPLY_DEPS, REMOVE_DEPS_OWNER, INIT_CONFIG, ON_DISPOSE, } from './core/symbols';
10
6
  export type { BlacMeta, BlacHydration } from './core/meta';
11
7
  export { ALL_PATHS } from '@dirtytalk/structural';
12
8
  export type { PathSet } from '@dirtytalk/structural';
13
- export { acquire, resolveInstanceKey, borrow, borrowSafe, ensure, release, releaseInstance, clear, clearAll, register, hasInstance, getRefCount, getRefIds, getAll, forEach, getRegistry, setRegistry, getStats, } from './registry';
9
+ export { acquire, resolveInstanceKey, borrow, borrowSafe, ensure, release, clear, clearAll, clearWhere, register, hasInstance, getRefCount, getRefIds, getAll, forEach, getRegistry, setRegistry, getStats, } from './registry';
14
10
  export type { BorrowTarget } from './registry';
15
11
  export { globalRegistry, StateContainerRegistry, } from './core/StateContainerRegistry';
16
12
  export type { LifecycleEvent, LifecycleListener, InstanceEntry, } from './core/StateContainerRegistry';
17
13
  export { blac, type BlacOptions } from './decorators';
18
- export { isKeepAliveClass, isExcludedFromDevTools, isIsolatedClass, } from './utils/static-props';
19
- export { getPluginManager } from './core/StateContainerRegistry';
14
+ export { isKeepAliveClass, isIsolatedClass, isExcludedFromDevTools, getBlacName, } from './utils/static-props';
20
15
  export type { BlacPlugin, BlacPluginWithInit, PluginContext, PluginConfig, InstanceMetadata, } from './plugin/BlacPlugin';
21
- export { PluginManager } from './plugin/PluginManager';
22
- export { watch, instance, observe, type WatchFn, type BlocRef } from './watch';
23
- export { defineEvent, emitEvent, onEvent, type EventToken } from './events';
24
- export type { StateContainerConstructor, ExtractState, ExtractStateMutable, ExtractConstructorArgs, ExtractArgs, ExtractDeps, BlocInstanceType, BlocConstructor, InstanceReadonlyState, InstanceState, StateContainerInstance, } from './types/utilities';
16
+ export { watch, instance, type WatchFn, type WatchOptions, type BlocRef, } from './watch';
17
+ export type { StateContainerConstructor, DeepReadonly, ExtractState, ExtractStateMutable, ExtractArgs, ExtractDeps, InstanceReadonlyState, WithState, InstanceState, StateContainerInstance, } from './types/utilities';
25
18
  export type { Brand, BrandedId, InstanceId } from './types/branded';
26
19
  export { instanceId } from './types/branded';
package/dist/index.d.ts CHANGED
@@ -1,26 +1,19 @@
1
1
  export { configureBlac, getBlacConfig, resetBlacConfig, shallowEqualState, type BlacConfig, type EqualityFn, } from './config';
2
- export { StateContainer, DEP_BRAND } from './core/StateContainer';
2
+ export { StateContainer } from './core/StateContainer';
3
+ export { onActivated } from './core/onActivated';
3
4
  export type { HydrationStatus, StateContainerConfig, SystemEvent, SystemEventPayloads, DepHandle, } from './core/StateContainer';
4
5
  export { Cubit } from './core/Cubit';
5
- /**
6
- * @internal symbols — read by `@blac/react` (APPLY_DEPS / REMOVE_DEPS_OWNER),
7
- * in-package tests (INIT_CONFIG), and `watch()` (ON_DISPOSE).
8
- */
9
- export { APPLY_DEPS, REMOVE_DEPS_OWNER, INIT_CONFIG, ON_DISPOSE, } from './core/symbols';
10
6
  export type { BlacMeta, BlacHydration } from './core/meta';
11
7
  export { ALL_PATHS } from '@dirtytalk/structural';
12
8
  export type { PathSet } from '@dirtytalk/structural';
13
- export { acquire, resolveInstanceKey, borrow, borrowSafe, ensure, release, releaseInstance, clear, clearAll, register, hasInstance, getRefCount, getRefIds, getAll, forEach, getRegistry, setRegistry, getStats, } from './registry';
9
+ export { acquire, resolveInstanceKey, borrow, borrowSafe, ensure, release, clear, clearAll, clearWhere, register, hasInstance, getRefCount, getRefIds, getAll, forEach, getRegistry, setRegistry, getStats, } from './registry';
14
10
  export type { BorrowTarget } from './registry';
15
11
  export { globalRegistry, StateContainerRegistry, } from './core/StateContainerRegistry';
16
12
  export type { LifecycleEvent, LifecycleListener, InstanceEntry, } from './core/StateContainerRegistry';
17
13
  export { blac, type BlacOptions } from './decorators';
18
- export { isKeepAliveClass, isExcludedFromDevTools, isIsolatedClass, } from './utils/static-props';
19
- export { getPluginManager } from './core/StateContainerRegistry';
14
+ export { isKeepAliveClass, isIsolatedClass, isExcludedFromDevTools, getBlacName, } from './utils/static-props';
20
15
  export type { BlacPlugin, BlacPluginWithInit, PluginContext, PluginConfig, InstanceMetadata, } from './plugin/BlacPlugin';
21
- export { PluginManager } from './plugin/PluginManager';
22
- export { watch, instance, observe, type WatchFn, type BlocRef } from './watch';
23
- export { defineEvent, emitEvent, onEvent, type EventToken } from './events';
24
- export type { StateContainerConstructor, ExtractState, ExtractStateMutable, ExtractConstructorArgs, ExtractArgs, ExtractDeps, BlocInstanceType, BlocConstructor, InstanceReadonlyState, InstanceState, StateContainerInstance, } from './types/utilities';
16
+ export { watch, instance, type WatchFn, type WatchOptions, type BlocRef, } from './watch';
17
+ export type { StateContainerConstructor, DeepReadonly, ExtractState, ExtractStateMutable, ExtractArgs, ExtractDeps, InstanceReadonlyState, WithState, InstanceState, StateContainerInstance, } from './types/utilities';
25
18
  export type { Brand, BrandedId, InstanceId } from './types/branded';
26
19
  export { instanceId } from './types/branded';
package/dist/index.js CHANGED
@@ -1,11 +1,46 @@
1
- import { _ as resetBlacConfig, a as INIT_CONFIG, d as isKeepAliveClass, g as getBlacConfig, h as configureBlac, i as APPLY_DEPS, l as isExcludedFromDevTools, m as PluginManager, n as getPluginManager, o as ON_DISPOSE, p as BLAC_STATIC_PROPS, r as globalRegistry, s as REMOVE_DEPS_OWNER, t as StateContainerRegistry, u as isIsolatedClass, v as shallowEqualState } from "./StateContainerRegistry-DWOzx7Gd.js";
2
- import { a as defineEvent, i as StateContainer, n as Cubit, o as emitEvent, r as DEP_BRAND, s as onEvent, t as ensure } from "./ensure-11-asM1e.js";
3
- import { n as getStats, r as setRegistry, t as getRegistry } from "./config-D2A8ZYRM.js";
4
- import { n as resolveInstanceKey, t as acquire } from "./acquire-CU0u8BMn.js";
5
- import { a as getAll, c as hasInstance, i as forEach, n as clearAll, o as getRefCount, r as register, s as getRefIds, t as clear } from "./management-8x1OVMi6.js";
6
- import { n as watch, t as instance } from "./watch-BDiwCPmb.js";
7
- import { t as instanceId } from "./branded-DkbUzncc.js";
1
+ import { S as shallowEqualState, b as getBlacConfig, d as getBlacName, g as BLAC_STATIC_PROPS, h as isKeepAliveClass, m as isIsolatedClass, n as globalRegistry, o as ON_ACTIVATED, p as isExcludedFromDevTools, s as ON_DISPOSE, t as StateContainerRegistry, x as resetBlacConfig, y as configureBlac } from "./StateContainerRegistry-CrTtRX5V.js";
2
+ import { a as getStats, i as getRegistry, n as StateContainer, o as setRegistry } from "./StateContainer-CwByTd5L.js";
3
+ import { n as acquire, r as resolveInstanceKey, t as ensure } from "./ensure-CwtQVTam.js";
8
4
  import { ALL_PATHS, ALL_PATHS as ALL_PATHS$1 } from "@dirtytalk/structural";
5
+ //#region src/core/onActivated.ts
6
+ /**
7
+ * Run `handler` each time `container` goes from unowned to owned, and now if it
8
+ * is already owned. `signal` aborts on the matching deactivation and on
9
+ * dispose. Returns an unsubscribe function.
10
+ *
11
+ * Unlike the protected `onActivate`, this can be called from a field
12
+ * initializer or a helper that receives the container.
13
+ */
14
+ function onActivated(container, handler) {
15
+ return container[ON_ACTIVATED](handler);
16
+ }
17
+ //#endregion
18
+ //#region src/core/Cubit.ts
19
+ /**
20
+ * `Cubit<S>` is a `StateContainer<S>` that exposes mutation publicly.
21
+ *
22
+ * That is the whole difference, and it is a real one: on `StateContainer`
23
+ * `emit` / `patch` / `update` are `protected`, so a container mutates itself
24
+ * from its own methods and callers go through the API it chooses to publish.
25
+ * `Cubit` re-declares the three as `public` for the cases where a caller
26
+ * legitimately drives state from outside — test helpers, devtools
27
+ * time-travel, benchmarks.
28
+ *
29
+ * Reach for `StateContainer` when business logic should live in the class,
30
+ * and `Cubit` when the caller owns the transitions.
31
+ */
32
+ var Cubit = class extends StateContainer {
33
+ emit(next) {
34
+ super.emit(next);
35
+ }
36
+ patch(partial) {
37
+ super.patch(partial);
38
+ }
39
+ update(fn) {
40
+ super.update(fn);
41
+ }
42
+ };
43
+ //#endregion
9
44
  //#region src/registry/borrow.ts
10
45
  function resolveBorrowKey(BlocClass, target) {
11
46
  return getRegistry().resolveKey(BlocClass, void 0, target?.args);
@@ -22,33 +57,69 @@ function borrowSafe(BlocClass, target) {
22
57
  * Release a reference to an instance. Instance identity is derived purely from
23
58
  * `args` (must match the `args` it was acquired with).
24
59
  *
25
- * @param opts.args - Construction/identity args; derives the instance key
26
- * @param opts.refId - The specific ref to drop; drops one arbitrary ref if omitted
27
- * @param opts.forceDispose - Force immediate disposal regardless of refs
60
+ * @param opts - `args` derives the instance key (must match acquire);
61
+ * `refId` picks the ref to drop, otherwise one arbitrary ref goes;
62
+ * `forceDispose` disposes immediately regardless of remaining refs.
28
63
  */
29
64
  function release(BlocClass, opts) {
30
65
  const registry = getRegistry();
31
66
  const key = registry.resolveKey(BlocClass, void 0, opts?.args);
32
67
  registry.release(BlocClass, key, opts?.forceDispose ?? false, opts?.refId);
33
68
  }
69
+ //#endregion
70
+ //#region src/registry/queries.ts
34
71
  /**
35
- * Release a reference using the INSTANCE as the identity, for callers that
36
- * hold a container but not the `args` it was acquired with (teardown loops).
37
- *
38
- * Never throws — safe on an unknown, transient, already-disposed, or
39
- * non-registry instance, and idempotent. Teardown loops depend on this.
40
- *
41
- * Idempotence is structural, not guarded here: once the instance is gone from
42
- * the registry `registry.release` returns early on its own missing-entry check
43
- * (`StateContainerRegistry.ts:636`), so a second call is a no-op. Do not add a
44
- * redundant guard.
72
+ * @public
45
73
  */
46
- function releaseInstance(instance, opts) {
47
- if (!instance) return;
74
+ function hasInstance(BlocClass, opts) {
48
75
  const registry = getRegistry();
49
- const key = registry.keyOf(instance);
50
- if (key === void 0) return;
51
- registry.release(instance.constructor, key, opts?.forceDispose ?? false, opts?.refId);
76
+ const key = registry.resolveKey(BlocClass, void 0, opts?.args);
77
+ return registry.hasInstance(BlocClass, key);
78
+ }
79
+ /**
80
+ * @public
81
+ */
82
+ function getRefCount(BlocClass, opts) {
83
+ const registry = getRegistry();
84
+ const key = registry.resolveKey(BlocClass, void 0, opts?.args);
85
+ return registry.getRefCount(BlocClass, key);
86
+ }
87
+ /**
88
+ * @public
89
+ */
90
+ function getRefIds(BlocClass, opts) {
91
+ const registry = getRegistry();
92
+ const key = registry.resolveKey(BlocClass, void 0, opts?.args);
93
+ return registry.getRefIds(BlocClass, key);
94
+ }
95
+ /**
96
+ * @public
97
+ */
98
+ function getAll(BlocClass) {
99
+ return getRegistry().getAll(BlocClass);
100
+ }
101
+ /**
102
+ * @public
103
+ */
104
+ function forEach(BlocClass, callback) {
105
+ getRegistry().forEach(BlocClass, callback);
106
+ }
107
+ //#endregion
108
+ //#region src/registry/management.ts
109
+ function clear(BlocClass) {
110
+ getRegistry().clear(BlocClass);
111
+ }
112
+ function clearAll() {
113
+ getRegistry().clearAll();
114
+ }
115
+ function clearWhere(predicate) {
116
+ getRegistry().clearWhere(predicate);
117
+ }
118
+ /**
119
+ * @public
120
+ */
121
+ function register(BlocClass) {
122
+ getRegistry().register(BlocClass);
52
123
  }
53
124
  //#endregion
54
125
  //#region src/decorators/blac.ts
@@ -62,6 +133,9 @@ function releaseInstance(instance, opts) {
62
133
  *
63
134
  * @blac({ excludeFromDevTools: true })
64
135
  * class InternalBloc extends Cubit<InternalState> {}
136
+ *
137
+ * @blac({ keepAlive: true, key: (args) => args.userId })
138
+ * class UserBloc extends Cubit<UserState> {}
65
139
  * ```
66
140
  *
67
141
  * @example Function syntax (no decorator support needed)
@@ -73,43 +147,149 @@ function releaseInstance(instance, opts) {
73
147
  */
74
148
  function blac(options) {
75
149
  return function(target, _context) {
76
- if ("keepAlive" in options && options.keepAlive) target[BLAC_STATIC_PROPS.KEEP_ALIVE] = true;
77
- if ("excludeFromDevTools" in options && options.excludeFromDevTools) target[BLAC_STATIC_PROPS.EXCLUDE_FROM_DEVTOOLS] = true;
78
- if ("equality" in options && typeof options.equality === "function") target[BLAC_STATIC_PROPS.EQUALITY] = options.equality;
79
- if ("key" in options && typeof options.key === "function") target[BLAC_STATIC_PROPS.KEY] = options.key;
150
+ if (options.keepAlive !== void 0) target[BLAC_STATIC_PROPS.KEEP_ALIVE] = options.keepAlive;
151
+ if (options.isolated !== void 0) target[BLAC_STATIC_PROPS.ISOLATED] = options.isolated;
152
+ if (options.excludeFromDevTools) target[BLAC_STATIC_PROPS.EXCLUDE_FROM_DEVTOOLS] = true;
153
+ if (typeof options.equality === "function") target[BLAC_STATIC_PROPS.EQUALITY] = options.equality;
154
+ if (typeof options.key === "function") target[BLAC_STATIC_PROPS.KEY] = options.key;
155
+ if (typeof options.name === "string") target[BLAC_STATIC_PROPS.BLAC_NAME] = options.name;
80
156
  return target;
81
157
  };
82
158
  }
83
159
  //#endregion
84
- //#region src/watch/observe.ts
160
+ //#region src/watch/watch.ts
161
+ const STOP = Symbol("watch.STOP");
162
+ const BLOC_REF_MARKER = Symbol("BlocRef");
85
163
  /**
86
- * Subscribe to every state change of a LIVE container instance, without the
87
- * immediate first call and without taking a registry ref.
88
- *
89
- * Contrast with `watch`: `watch` fires once on subscribe AND holds a ref that
90
- * keeps the instance alive. `observe` does neither — it is for hand-managed
91
- * subscriptions against an instance you already hold.
164
+ * Create a reference to a specific bloc instance, identified by its `args`.
165
+ * The key is derived the same way `useBloc`/`acquire` derive it.
92
166
  *
93
- * Delivery is microtask-coalesced by the container's channel scheduler: several
94
- * `emit`s in one tick deliver ONE call carrying the latest state.
167
+ * @example
168
+ * ```ts
169
+ * watch(instance(UserBloc, { userId: 'user-123' }), (userBloc) => {
170
+ * console.log(userBloc.state.name);
171
+ * });
172
+ * ```
95
173
  */
96
- function observe(instance, listener) {
97
- if (!instance || instance.$blac.disposed) return () => {};
98
- let stopped = false;
99
- const unsub = instance.subscribe(() => ALL_PATHS$1, () => {
100
- if (stopped) return;
101
- listener(instance.state);
174
+ function instance(BlocClass, args) {
175
+ return {
176
+ [BLOC_REF_MARKER]: true,
177
+ blocClass: BlocClass,
178
+ instanceId: resolveInstanceKey(BlocClass, args),
179
+ args
180
+ };
181
+ }
182
+ function isBlocRef(input) {
183
+ return typeof input === "object" && input !== null && BLOC_REF_MARKER in input;
184
+ }
185
+ function toWatchTarget(registry, input) {
186
+ if (isBlocRef(input)) return {
187
+ blocClass: input.blocClass,
188
+ key: input.instanceId,
189
+ args: input.args
190
+ };
191
+ return {
192
+ blocClass: input,
193
+ key: registry.resolveKey(input, void 0, void 0),
194
+ args: void 0
195
+ };
196
+ }
197
+ let watchRefSeq = 0;
198
+ /**
199
+ * Acquire a real ref (countRef: true) for the target, carrying its `args`
200
+ * through so a not-yet-created instance is initialized correctly. The
201
+ * caller is responsible for releasing `refId` in cleanup.
202
+ */
203
+ function resolveBloc(registry, target, refId) {
204
+ return registry.acquire(target.blocClass, target.key, {
205
+ countRef: true,
206
+ refId,
207
+ args: target.args
102
208
  });
103
- function stop() {
104
- if (stopped) return;
105
- stopped = true;
106
- unsub();
107
- offDispose();
209
+ }
210
+ /**
211
+ * Passive lookup for `{ create: false }`: never creates the instance and
212
+ * never takes a ref. Returns `undefined` when no instance currently exists.
213
+ */
214
+ function resolveBlocPassive(registry, target) {
215
+ try {
216
+ return registry.acquire(target.blocClass, target.key, {
217
+ canCreate: false,
218
+ countRef: false,
219
+ args: target.args
220
+ });
221
+ } catch {
222
+ return;
223
+ }
224
+ }
225
+ function isArray(input) {
226
+ return Array.isArray(input);
227
+ }
228
+ function watchImpl(blocsOrBloc, callback, options) {
229
+ const isSingle = !isArray(blocsOrBloc);
230
+ const inputs = isSingle ? [blocsOrBloc] : blocsOrBloc;
231
+ const registry = getRegistry();
232
+ const create = options?.create ?? true;
233
+ const signal = options?.signal;
234
+ if (signal?.aborted) return () => {};
235
+ const targets = inputs.map((input) => toWatchTarget(registry, input));
236
+ const refIds = targets.map(() => `_watch_${watchRefSeq++}`);
237
+ const resolveAt = (index) => create ? resolveBloc(registry, targets[index], refIds[index]) : resolveBlocPassive(registry, targets[index]);
238
+ let disposed = false;
239
+ const instances = [];
240
+ const channelUnsubs = [];
241
+ const disposedUnsubs = [];
242
+ const cleanup = () => {
243
+ if (disposed) return;
244
+ disposed = true;
245
+ signal?.removeEventListener("abort", cleanup);
246
+ for (const unsub of channelUnsubs) unsub?.();
247
+ for (const unsub of disposedUnsubs) unsub?.();
248
+ channelUnsubs.length = 0;
249
+ disposedUnsubs.length = 0;
250
+ if (create) for (let i = 0; i < instances.length; i++) registry.release(targets[i].blocClass, targets[i].key, false, refIds[i]);
251
+ };
252
+ const runCallback = () => {
253
+ if (disposed) return;
254
+ if (instances.some((i) => i === void 0)) return;
255
+ if (callback(isSingle ? instances[0] : instances) === STOP) cleanup();
256
+ };
257
+ const subscribeAt = (index) => {
258
+ channelUnsubs[index] = instances[index]?.channel.subscribe(() => ALL_PATHS$1, runCallback);
259
+ };
260
+ const resubscribeAt = (index) => {
261
+ if (disposed) return;
262
+ instances[index] = resolveAt(index);
263
+ subscribeAt(index);
264
+ subscribeDisposeAt(index);
265
+ runCallback();
266
+ };
267
+ const subscribeDisposeAt = (index) => {
268
+ disposedUnsubs[index] = instances[index]?.[ON_DISPOSE](() => {
269
+ channelUnsubs[index]?.();
270
+ channelUnsubs[index] = void 0;
271
+ queueMicrotask(() => resubscribeAt(index));
272
+ });
273
+ };
274
+ signal?.addEventListener("abort", cleanup, { once: true });
275
+ try {
276
+ for (let i = 0; i < targets.length; i++) instances.push(resolveAt(i));
277
+ for (let i = 0; i < instances.length; i++) subscribeAt(i);
278
+ for (let i = 0; i < instances.length; i++) subscribeDisposeAt(i);
279
+ runCallback();
280
+ } catch (error) {
281
+ cleanup();
282
+ throw error;
108
283
  }
109
- const offDispose = instance[ON_DISPOSE](stop);
110
- return stop;
284
+ return cleanup;
285
+ }
286
+ const watch = Object.assign(watchImpl, { STOP });
287
+ //#endregion
288
+ //#region src/types/branded.ts
289
+ function instanceId(id) {
290
+ return id;
111
291
  }
112
292
  //#endregion
113
- export { ALL_PATHS, APPLY_DEPS, Cubit, DEP_BRAND, INIT_CONFIG, ON_DISPOSE, PluginManager, REMOVE_DEPS_OWNER, StateContainer, StateContainerRegistry, acquire, blac, borrow, borrowSafe, clear, clearAll, configureBlac, defineEvent, emitEvent, ensure, forEach, getAll, getBlacConfig, getPluginManager, getRefCount, getRefIds, getRegistry, getStats, globalRegistry, hasInstance, instance, instanceId, isExcludedFromDevTools, isIsolatedClass, isKeepAliveClass, observe, onEvent, register, release, releaseInstance, resetBlacConfig, resolveInstanceKey, setRegistry, shallowEqualState, watch };
293
+ export { ALL_PATHS, Cubit, StateContainer, StateContainerRegistry, acquire, blac, borrow, borrowSafe, clear, clearAll, clearWhere, configureBlac, ensure, forEach, getAll, getBlacConfig, getBlacName, getRefCount, getRefIds, getRegistry, getStats, globalRegistry, hasInstance, instance, instanceId, isExcludedFromDevTools, isIsolatedClass, isKeepAliveClass, onActivated, register, release, resetBlacConfig, resolveInstanceKey, setRegistry, shallowEqualState, watch };
114
294
 
115
295
  //# sourceMappingURL=index.js.map
package/dist/index.js.map CHANGED
@@ -1 +1 @@
1
- {"version":3,"file":"index.js","names":["ALL_PATHS"],"sources":["../src/registry/borrow.ts","../src/registry/release.ts","../src/decorators/blac.ts","../src/watch/observe.ts"],"sourcesContent":["import { getRegistry } from './config';\nimport type {\n ExtractArgs,\n StateContainerConstructor,\n} from '../types/utilities';\n\n/**\n * How to identify the instance to borrow: the same `args` shape `useBloc`\n * accepts, resolved through the class's `static key(args)` so call sites use\n * the *same* shape they pass to `useBloc` instead of hand-deriving the key.\n *\n * `borrowSafe(ChannelBloc, { args: { channelId } })` and\n * `useBloc(ChannelBloc, { args: { channelId } })` therefore always agree.\n */\nexport type BorrowTarget<T extends StateContainerConstructor> = {\n args?: ExtractArgs<T>;\n};\n\nfunction resolveBorrowKey<T extends StateContainerConstructor>(\n BlocClass: T,\n target: BorrowTarget<T> | undefined,\n): string {\n return getRegistry().resolveKey(BlocClass, undefined, target?.args);\n}\n\nexport function borrow<T extends StateContainerConstructor>(\n BlocClass: T,\n target?: BorrowTarget<T>,\n): InstanceType<T> {\n return getRegistry().borrow(BlocClass, resolveBorrowKey(BlocClass, target));\n}\n\nexport function borrowSafe<T extends StateContainerConstructor>(\n BlocClass: T,\n target?: BorrowTarget<T>,\n):\n | { error: Error; instance: null }\n | { error: null; instance: InstanceType<T> } {\n return getRegistry().borrowSafe(\n BlocClass,\n resolveBorrowKey(BlocClass, target),\n );\n}\n","import { getRegistry } from './config';\nimport type {\n ExtractArgs,\n StateContainerConstructor,\n StateContainerInstance,\n} from '../types/utilities';\n\n/**\n * Release a reference to an instance. Instance identity is derived purely from\n * `args` (must match the `args` it was acquired with).\n *\n * @param opts.args - Construction/identity args; derives the instance key\n * @param opts.refId - The specific ref to drop; drops one arbitrary ref if omitted\n * @param opts.forceDispose - Force immediate disposal regardless of refs\n */\nexport function release<T extends StateContainerConstructor>(\n BlocClass: T,\n opts?: { args?: ExtractArgs<T>; refId?: string; forceDispose?: boolean },\n): void {\n const registry = getRegistry();\n const key = registry.resolveKey(BlocClass, undefined, opts?.args);\n registry.release(BlocClass, key, opts?.forceDispose ?? false, opts?.refId);\n}\n\n/**\n * Release a reference using the INSTANCE as the identity, for callers that\n * hold a container but not the `args` it was acquired with (teardown loops).\n *\n * Never throws — safe on an unknown, transient, already-disposed, or\n * non-registry instance, and idempotent. Teardown loops depend on this.\n *\n * Idempotence is structural, not guarded here: once the instance is gone from\n * the registry `registry.release` returns early on its own missing-entry check\n * (`StateContainerRegistry.ts:636`), so a second call is a no-op. Do not add a\n * redundant guard.\n */\nexport function releaseInstance(\n instance: StateContainerInstance,\n opts?: { forceDispose?: boolean; refId?: string },\n): void {\n if (!instance) return;\n const registry = getRegistry();\n const key = registry.keyOf(instance);\n if (key === undefined) return;\n registry.release(\n instance.constructor as StateContainerConstructor,\n key,\n opts?.forceDispose ?? false,\n opts?.refId,\n );\n}\n","import { BLAC_STATIC_PROPS } from '../constants';\nimport type { EqualityFn } from '../config';\n\n/**\n * Configuration options for the @blac decorator.\n * Only one option can be specified at a time (union type).\n */\nexport type BlacOptions =\n /** Mark bloc to never be auto-disposed when ref count reaches 0 */\n | { keepAlive: true }\n /** Exclude bloc from DevTools tracking (prevents infinite loops) */\n | { excludeFromDevTools: true }\n /**\n * Override the global equality check for this bloc.\n * Return `true` to skip the emit (states considered equal).\n * Applies to `emit`/`update` only — `patch` does not consult this fn; it\n * still skips structural no-ops on its own.\n */\n | { equality: EqualityFn }\n /**\n * Override the default structural-hash identity key.\n * The function receives `args` and returns the instance key string.\n * Distinct return values → distinct instances; identical values → shared instance.\n * Non-identity fields can be excluded so they don't fork new instances.\n */\n | { key: (args: any) => string };\n\n/**\n * Decorator to configure StateContainer classes.\n *\n * @example Decorator syntax (requires experimentalDecorators or TC39 decorators)\n * ```ts\n * @blac({ keepAlive: true })\n * class AuthBloc extends Cubit<AuthState> {}\n *\n * @blac({ excludeFromDevTools: true })\n * class InternalBloc extends Cubit<InternalState> {}\n * ```\n *\n * @example Function syntax (no decorator support needed)\n * ```ts\n * const AuthBloc = blac({ keepAlive: true })(\n * class extends Cubit<AuthState> {}\n * );\n * ```\n */\nexport function blac(options: BlacOptions) {\n return function <T extends new (...args: any[]) => any>(\n target: T,\n _context?: ClassDecoratorContext,\n ): T {\n if ('keepAlive' in options && options.keepAlive) {\n (target as any)[BLAC_STATIC_PROPS.KEEP_ALIVE] = true;\n }\n if ('excludeFromDevTools' in options && options.excludeFromDevTools) {\n (target as any)[BLAC_STATIC_PROPS.EXCLUDE_FROM_DEVTOOLS] = true;\n }\n if ('equality' in options && typeof options.equality === 'function') {\n (target as any)[BLAC_STATIC_PROPS.EQUALITY] = options.equality;\n }\n if ('key' in options && typeof options.key === 'function') {\n (target as any)[BLAC_STATIC_PROPS.KEY] = options.key;\n }\n return target;\n };\n}\n","import { ALL_PATHS } from '@dirtytalk/structural';\nimport { ON_DISPOSE } from '../core/symbols';\nimport type { StateContainer } from '../core/StateContainer';\n\n/**\n * Subscribe to every state change of a LIVE container instance, without the\n * immediate first call and without taking a registry ref.\n *\n * Contrast with `watch`: `watch` fires once on subscribe AND holds a ref that\n * keeps the instance alive. `observe` does neither — it is for hand-managed\n * subscriptions against an instance you already hold.\n *\n * Delivery is microtask-coalesced by the container's channel scheduler: several\n * `emit`s in one tick deliver ONE call carrying the latest state.\n */\nexport function observe<S extends object>(\n instance: StateContainer<S, any, any>,\n listener: (state: Readonly<S>) => void,\n): () => void {\n if (!instance || instance.$blac.disposed) return () => {};\n let stopped = false;\n const unsub = instance.subscribe(\n () => ALL_PATHS,\n () => {\n if (stopped) return;\n listener(instance.state as Readonly<S>);\n },\n );\n // A hoisted function declaration, so it can be handed to `[ON_DISPOSE]`\n // below while still referencing the `offDispose` const that call returns.\n // `[ON_DISPOSE]` only registers the handler (it never invokes it inline), so\n // by the time `stop` can actually run, `offDispose` is initialized.\n function stop(): void {\n if (stopped) return;\n stopped = true;\n unsub();\n offDispose();\n }\n // Same closure on both teardown paths (caller-invoked and dispose-driven), so\n // the `stopped` flag guarantees teardown runs exactly once.\n const offDispose = instance[ON_DISPOSE](stop);\n return stop;\n}\n"],"mappings":";;;;;;;;;AAkBA,SAAS,iBACP,WACA,QACQ;CACR,OAAO,YAAY,EAAE,WAAW,WAAW,KAAA,GAAW,QAAQ,IAAI;AACpE;AAEA,SAAgB,OACd,WACA,QACiB;CACjB,OAAO,YAAY,EAAE,OAAO,WAAW,iBAAiB,WAAW,MAAM,CAAC;AAC5E;AAEA,SAAgB,WACd,WACA,QAG6C;CAC7C,OAAO,YAAY,EAAE,WACnB,WACA,iBAAiB,WAAW,MAAM,CACpC;AACF;;;;;;;;;;;AC3BA,SAAgB,QACd,WACA,MACM;CACN,MAAM,WAAW,YAAY;CAC7B,MAAM,MAAM,SAAS,WAAW,WAAW,KAAA,GAAW,MAAM,IAAI;CAChE,SAAS,QAAQ,WAAW,KAAK,MAAM,gBAAgB,OAAO,MAAM,KAAK;AAC3E;;;;;;;;;;;;;AAcA,SAAgB,gBACd,UACA,MACM;CACN,IAAI,CAAC,UAAU;CACf,MAAM,WAAW,YAAY;CAC7B,MAAM,MAAM,SAAS,MAAM,QAAQ;CACnC,IAAI,QAAQ,KAAA,GAAW;CACvB,SAAS,QACP,SAAS,aACT,KACA,MAAM,gBAAgB,OACtB,MAAM,KACR;AACF;;;;;;;;;;;;;;;;;;;;;;ACJA,SAAgB,KAAK,SAAsB;CACzC,OAAO,SACL,QACA,UACG;EACH,IAAI,eAAe,WAAW,QAAQ,WACpC,OAAgB,kBAAkB,cAAc;EAElD,IAAI,yBAAyB,WAAW,QAAQ,qBAC9C,OAAgB,kBAAkB,yBAAyB;EAE7D,IAAI,cAAc,WAAW,OAAO,QAAQ,aAAa,YACvD,OAAgB,kBAAkB,YAAY,QAAQ;EAExD,IAAI,SAAS,WAAW,OAAO,QAAQ,QAAQ,YAC7C,OAAgB,kBAAkB,OAAO,QAAQ;EAEnD,OAAO;CACT;AACF;;;;;;;;;;;;;;AClDA,SAAgB,QACd,UACA,UACY;CACZ,IAAI,CAAC,YAAY,SAAS,MAAM,UAAU,aAAa,CAAC;CACxD,IAAI,UAAU;CACd,MAAM,QAAQ,SAAS,gBACfA,mBACA;EACJ,IAAI,SAAS;EACb,SAAS,SAAS,KAAoB;CACxC,CACF;CAKA,SAAS,OAAa;EACpB,IAAI,SAAS;EACb,UAAU;EACV,MAAM;EACN,WAAW;CACb;CAGA,MAAM,aAAa,SAAS,YAAY,IAAI;CAC5C,OAAO;AACT"}
1
+ {"version":3,"file":"index.js","names":["ALL_PATHS"],"sources":["../src/core/onActivated.ts","../src/core/Cubit.ts","../src/registry/borrow.ts","../src/registry/release.ts","../src/registry/queries.ts","../src/registry/management.ts","../src/decorators/blac.ts","../src/watch/watch.ts","../src/types/branded.ts"],"sourcesContent":["import { ON_ACTIVATED } from './symbols';\nimport type { StateContainer } from './StateContainer';\n\n/**\n * Run `handler` each time `container` goes from unowned to owned, and now if it\n * is already owned. `signal` aborts on the matching deactivation and on\n * dispose. Returns an unsubscribe function.\n *\n * Unlike the protected `onActivate`, this can be called from a field\n * initializer or a helper that receives the container.\n */\nexport function onActivated(\n container: StateContainer<any, any, any>,\n handler: (signal: AbortSignal) => void,\n): () => void {\n return container[ON_ACTIVATED](handler);\n}\n","import { StateContainer } from './StateContainer';\nimport type { DeepPartial } from '@dirtytalk/structural';\n\n/**\n * `Cubit<S>` is a `StateContainer<S>` that exposes mutation publicly.\n *\n * That is the whole difference, and it is a real one: on `StateContainer`\n * `emit` / `patch` / `update` are `protected`, so a container mutates itself\n * from its own methods and callers go through the API it chooses to publish.\n * `Cubit` re-declares the three as `public` for the cases where a caller\n * legitimately drives state from outside — test helpers, devtools\n * time-travel, benchmarks.\n *\n * Reach for `StateContainer` when business logic should live in the class,\n * and `Cubit` when the caller owns the transitions.\n */\nexport abstract class Cubit<\n S extends object = any,\n Args = void,\n Deps extends object = Record<string, never>,\n> extends StateContainer<S, Args, Deps> {\n override emit(next: S): void {\n super.emit(next);\n }\n\n override patch(partial: DeepPartial<S>): void {\n super.patch(partial);\n }\n\n override update(fn: (state: S) => S): void {\n super.update(fn);\n }\n}\n","import { getRegistry } from './config';\nimport type {\n ExtractArgs,\n StateContainerConstructor,\n} from '../types/utilities';\n\n/**\n * How to identify the instance to borrow: the same `args` shape `useBloc`\n * accepts, resolved through the class's `static key(args)` so call sites use\n * the *same* shape they pass to `useBloc` instead of hand-deriving the key.\n *\n * `borrowSafe(ChannelBloc, { args: { channelId } })` and\n * `useBloc(ChannelBloc, { args: { channelId } })` therefore always agree.\n */\nexport type BorrowTarget<T extends StateContainerConstructor> = {\n args?: ExtractArgs<T>;\n};\n\nfunction resolveBorrowKey<T extends StateContainerConstructor>(\n BlocClass: T,\n target: BorrowTarget<T> | undefined,\n): string {\n return getRegistry().resolveKey(BlocClass, undefined, target?.args);\n}\n\nexport function borrow<T extends StateContainerConstructor>(\n BlocClass: T,\n target?: BorrowTarget<T>,\n): InstanceType<T> {\n return getRegistry().borrow(BlocClass, resolveBorrowKey(BlocClass, target));\n}\n\nexport function borrowSafe<T extends StateContainerConstructor>(\n BlocClass: T,\n target?: BorrowTarget<T>,\n):\n | { error: Error; instance: null }\n | { error: null; instance: InstanceType<T> } {\n return getRegistry().borrowSafe(\n BlocClass,\n resolveBorrowKey(BlocClass, target),\n );\n}\n","import { getRegistry } from './config';\nimport type {\n ExtractArgs,\n StateContainerConstructor,\n} from '../types/utilities';\n\n/**\n * Release a reference to an instance. Instance identity is derived purely from\n * `args` (must match the `args` it was acquired with).\n *\n * @param opts - `args` derives the instance key (must match acquire);\n * `refId` picks the ref to drop, otherwise one arbitrary ref goes;\n * `forceDispose` disposes immediately regardless of remaining refs.\n */\nexport function release<T extends StateContainerConstructor>(\n BlocClass: T,\n opts?: { args?: ExtractArgs<T>; refId?: string; forceDispose?: boolean },\n): void {\n const registry = getRegistry();\n const key = registry.resolveKey(BlocClass, undefined, opts?.args);\n registry.release(BlocClass, key, opts?.forceDispose ?? false, opts?.refId);\n}\n","import { getRegistry } from './config';\nimport type {\n ExtractArgs,\n StateContainerConstructor,\n InstanceReadonlyState,\n} from '../types/utilities';\n\n/**\n * @public\n */\nexport function hasInstance<T extends StateContainerConstructor>(\n BlocClass: T,\n opts?: { args?: ExtractArgs<T> },\n): boolean {\n const registry = getRegistry();\n const key = registry.resolveKey(BlocClass, undefined, opts?.args);\n return registry.hasInstance(BlocClass, key);\n}\n\n/**\n * @public\n */\nexport function getRefCount<T extends StateContainerConstructor>(\n BlocClass: T,\n opts?: { args?: ExtractArgs<T> },\n): number {\n const registry = getRegistry();\n const key = registry.resolveKey(BlocClass, undefined, opts?.args);\n return registry.getRefCount(BlocClass, key);\n}\n\n/**\n * @public\n */\nexport function getRefIds<T extends StateContainerConstructor>(\n BlocClass: T,\n opts?: { args?: ExtractArgs<T> },\n): string[] {\n const registry = getRegistry();\n const key = registry.resolveKey(BlocClass, undefined, opts?.args);\n return registry.getRefIds(BlocClass, key);\n}\n\n/**\n * @public\n */\nexport function getAll<T extends StateContainerConstructor>(\n BlocClass: T,\n): InstanceReadonlyState<T>[] {\n return getRegistry().getAll(BlocClass);\n}\n\n/**\n * @public\n */\nexport function forEach<T extends StateContainerConstructor>(\n BlocClass: T,\n callback: (instance: InstanceReadonlyState<T>) => void,\n): void {\n getRegistry().forEach(BlocClass, callback);\n}\n","import { getRegistry } from './config';\nimport type { StateContainer } from '../core/StateContainer';\nimport type { StateContainerConstructor } from '../types/utilities';\n\nexport function clear<T extends StateContainerConstructor>(BlocClass: T): void {\n getRegistry().clear(BlocClass);\n}\n\nexport function clearAll(): void {\n getRegistry().clearAll();\n}\n\nexport function clearWhere(\n predicate: (instance: StateContainer<any, any, any>) => boolean,\n): void {\n getRegistry().clearWhere(predicate);\n}\n\n/**\n * @public\n */\nexport function register<T extends StateContainerConstructor>(\n BlocClass: T,\n): void {\n getRegistry().register(BlocClass);\n}\n","import { BLAC_STATIC_PROPS } from '../constants';\nimport type { EqualityFn } from '../config';\n\n/**\n * Configuration options for the `@blac` decorator. Any combination may be\n * given at once.\n */\nexport interface BlacOptions {\n /**\n * Keep the bloc alive when its ref count reaches 0. `false` turns off a\n * `keepAlive` inherited from a base class.\n */\n keepAlive?: boolean;\n /**\n * Give each `useBloc` mount its own private instance, disposed when that\n * component unmounts. Applies to `useBloc` only; `ensure`/`acquire` still\n * resolve the shared instance. `false` turns off an `isolated` inherited\n * from a base class.\n */\n isolated?: boolean;\n /** Exclude bloc from DevTools tracking (prevents infinite loops) */\n excludeFromDevTools?: true;\n /**\n * Override the global equality check for this bloc.\n * Return `true` to skip the emit (states considered equal).\n */\n equality?: EqualityFn;\n /**\n * Override the default structural-hash identity key.\n * The function receives `args` and returns the instance key string.\n * Distinct return values → distinct instances; identical values → shared instance.\n * Non-identity fields can be excluded so they don't fork new instances.\n */\n key?: (args: any) => string;\n /**\n * Explicit, minification-safe identity for this bloc class. Falls back to\n * `constructor.name` when unset, which collides across classes once a\n * minifier shortens class names.\n */\n name?: string;\n}\n\n/**\n * Decorator to configure StateContainer classes.\n *\n * @example Decorator syntax (requires experimentalDecorators or TC39 decorators)\n * ```ts\n * @blac({ keepAlive: true })\n * class AuthBloc extends Cubit<AuthState> {}\n *\n * @blac({ excludeFromDevTools: true })\n * class InternalBloc extends Cubit<InternalState> {}\n *\n * @blac({ keepAlive: true, key: (args) => args.userId })\n * class UserBloc extends Cubit<UserState> {}\n * ```\n *\n * @example Function syntax (no decorator support needed)\n * ```ts\n * const AuthBloc = blac({ keepAlive: true })(\n * class extends Cubit<AuthState> {}\n * );\n * ```\n */\nexport function blac(options: BlacOptions) {\n return function <T extends new (...args: any[]) => any>(\n target: T,\n _context?: ClassDecoratorContext,\n ): T {\n if (options.keepAlive !== undefined) {\n (target as any)[BLAC_STATIC_PROPS.KEEP_ALIVE] = options.keepAlive;\n }\n if (options.isolated !== undefined) {\n (target as any)[BLAC_STATIC_PROPS.ISOLATED] = options.isolated;\n }\n if (options.excludeFromDevTools) {\n (target as any)[BLAC_STATIC_PROPS.EXCLUDE_FROM_DEVTOOLS] = true;\n }\n if (typeof options.equality === 'function') {\n (target as any)[BLAC_STATIC_PROPS.EQUALITY] = options.equality;\n }\n if (typeof options.key === 'function') {\n (target as any)[BLAC_STATIC_PROPS.KEY] = options.key;\n }\n if (typeof options.name === 'string') {\n (target as any)[BLAC_STATIC_PROPS.BLAC_NAME] = options.name;\n }\n return target;\n };\n}\n","import { ALL_PATHS } from '@dirtytalk/structural';\nimport { ON_DISPOSE } from '../core/symbols';\nimport { getRegistry } from '../registry';\nimport { resolveInstanceKey } from '../registry/acquire';\nimport type { StateContainerRegistry } from '../core/StateContainerRegistry';\nimport type {\n ExtractArgs,\n StateContainerConstructor,\n StateContainerInstance,\n} from '../types/utilities';\n\nconst STOP: unique symbol = Symbol('watch.STOP');\ntype StopSymbol = typeof STOP;\n\nconst BLOC_REF_MARKER = Symbol('BlocRef');\n\n/**\n * Reference to a specific bloc instance, identified by class + the resolved\n * key derived from its `args`.\n */\nexport interface BlocRef<T extends StateContainerConstructor> {\n [BLOC_REF_MARKER]: true;\n blocClass: T;\n /** @internal The resolved instance key (derived from `args`). */\n instanceId: string;\n /**\n * @internal The `args` used to derive `instanceId`. Forwarded to\n * `registry.acquire` so a not-yet-created instance is initialized with\n * these args instead of `undefined`.\n */\n args?: unknown;\n}\n\n/**\n * Create a reference to a specific bloc instance, identified by its `args`.\n * The key is derived the same way `useBloc`/`acquire` derive it.\n *\n * @example\n * ```ts\n * watch(instance(UserBloc, { userId: 'user-123' }), (userBloc) => {\n * console.log(userBloc.state.name);\n * });\n * ```\n */\nexport function instance<T extends StateContainerConstructor>(\n BlocClass: T,\n args?: ExtractArgs<T>,\n): BlocRef<T> {\n return {\n [BLOC_REF_MARKER]: true,\n blocClass: BlocClass,\n instanceId: resolveInstanceKey(BlocClass, args),\n args,\n };\n}\n\nfunction isBlocRef(\n input: unknown,\n): input is BlocRef<StateContainerConstructor> {\n return (\n typeof input === 'object' && input !== null && BLOC_REF_MARKER in input\n );\n}\n\ntype BlocInput = StateContainerConstructor | BlocRef<StateContainerConstructor>;\n\n/**\n * Options for `watch`.\n */\nexport interface WatchOptions {\n /**\n * When `false`, `watch` observes passively: it neither creates a missing\n * instance nor takes a real ownership ref on an existing one. If the\n * instance does not exist yet, the callback simply never fires — `watch`\n * does not poll; call it again once the instance exists.\n *\n * Defaults to `true`.\n */\n create?: boolean;\n /**\n * Stops the watch when aborted, equivalent to calling the returned stop\n * function. An already-aborted signal returns a no-op stop without\n * creating or acquiring anything.\n */\n signal?: AbortSignal;\n}\n\ntype ExtractInstance<T> =\n T extends BlocRef<infer C>\n ? InstanceType<C>\n : T extends StateContainerConstructor\n ? InstanceType<T>\n : never;\n\ntype ExtractInstances<T extends readonly BlocInput[]> = {\n [K in keyof T]: ExtractInstance<T[K]>;\n};\n\n/**\n * Watch function signature for single bloc.\n */\nexport interface WatchSingleFn {\n <T extends StateContainerConstructor>(\n bloc: T | BlocRef<T>,\n callback: (bloc: InstanceType<T>) => void | StopSymbol,\n options?: WatchOptions,\n ): () => void;\n\n STOP: StopSymbol;\n}\n\n/**\n * Watch function signature for multiple blocs.\n */\nexport interface WatchMultipleFn {\n <T extends readonly BlocInput[]>(\n blocs: T,\n callback: (blocs: ExtractInstances<T>) => void | StopSymbol,\n options?: WatchOptions,\n ): () => void;\n\n STOP: StopSymbol;\n}\n\n/**\n * Combined watch function type.\n */\nexport interface WatchFn extends WatchSingleFn {\n <T extends readonly BlocInput[]>(\n blocs: T,\n callback: (blocs: ExtractInstances<T>) => void | StopSymbol,\n options?: WatchOptions,\n ): () => void;\n}\n\n/**\n * Class + resolved key + args needed to (re-)acquire a specific instance.\n * `watch` keeps this around per input so it can re-acquire the same logical\n * instance if the underlying container is disposed elsewhere.\n */\ninterface WatchTarget {\n blocClass: StateContainerConstructor;\n key: string;\n args: unknown;\n}\n\nfunction toWatchTarget(\n registry: StateContainerRegistry,\n input: BlocInput,\n): WatchTarget {\n if (isBlocRef(input)) {\n return {\n blocClass: input.blocClass,\n key: input.instanceId,\n args: input.args,\n };\n }\n return {\n blocClass: input,\n key: registry.resolveKey(input, undefined, undefined),\n args: undefined,\n };\n}\n\nlet watchRefSeq = 0;\n\n/**\n * Acquire a real ref (countRef: true) for the target, carrying its `args`\n * through so a not-yet-created instance is initialized correctly. The\n * caller is responsible for releasing `refId` in cleanup.\n */\nfunction resolveBloc(\n registry: StateContainerRegistry,\n target: WatchTarget,\n refId: string,\n): StateContainerInstance {\n return registry.acquire(target.blocClass, target.key, {\n countRef: true,\n refId,\n args: target.args,\n });\n}\n\n/**\n * Passive lookup for `{ create: false }`: never creates the instance and\n * never takes a ref. Returns `undefined` when no instance currently exists.\n */\nfunction resolveBlocPassive(\n registry: StateContainerRegistry,\n target: WatchTarget,\n): StateContainerInstance | undefined {\n try {\n return registry.acquire(target.blocClass, target.key, {\n canCreate: false,\n countRef: false,\n args: target.args,\n });\n } catch {\n return undefined;\n }\n}\n\nfunction isArray(input: unknown): input is readonly BlocInput[] {\n return Array.isArray(input);\n}\n\n/**\n * Watch one or more blocs for state changes.\n *\n * Thin wrapper around `container.channel.subscribe(() => ALL_PATHS, ...)`. The\n * callback fires once immediately, then on every state change of any of the\n * passed blocs. Returning `watch.STOP` from the callback tears down all\n * subscriptions. Subscriptions are microtask-deferred, so callbacks land\n * asynchronously after `emit()`.\n *\n * By default `watch` creates the instance if it does not exist and holds a\n * real ownership ref until `unwatch`, matching `acquire`. Pass\n * `{ create: false }` to observe passively instead — see `WatchOptions`.\n *\n * @example Single bloc\n * ```ts\n * const unwatch = watch(UserBloc, (userBloc) => {\n * console.log(userBloc.state.name);\n * });\n * ```\n *\n * @example Multiple blocs\n * ```ts\n * const unwatch = watch(\n * [UserBloc, SettingsBloc] as const,\n * ([userBloc, settingsBloc]) => {\n * console.log(userBloc.state.name, settingsBloc.state.theme);\n * }\n * );\n * ```\n *\n * @example With specific instance\n * ```ts\n * const unwatch = watch(\n * instance(UserBloc, { userId: 'user-123' }),\n * (userBloc) => {\n * console.log(userBloc.state.name);\n * }\n * );\n * ```\n *\n * @example Stop watching from callback\n * ```ts\n * const unwatch = watch(UserBloc, (userBloc) => {\n * if (userBloc.state.done) {\n * return watch.STOP;\n * }\n * });\n * ```\n */\nfunction watchImpl<T extends StateContainerConstructor>(\n bloc: T | BlocRef<T>,\n callback: (bloc: InstanceType<T>) => void | StopSymbol,\n options?: WatchOptions,\n): () => void;\n\nfunction watchImpl<T extends readonly BlocInput[]>(\n blocs: T,\n callback: (blocs: ExtractInstances<T>) => void | StopSymbol,\n options?: WatchOptions,\n): () => void;\n\nfunction watchImpl(\n blocsOrBloc: BlocInput | readonly BlocInput[],\n callback: (blocsOrBloc: any) => void | StopSymbol,\n options?: WatchOptions,\n): () => void {\n const isSingle = !isArray(blocsOrBloc);\n const inputs = isSingle ? [blocsOrBloc] : blocsOrBloc;\n const registry = getRegistry();\n const create = options?.create ?? true;\n const signal = options?.signal;\n if (signal?.aborted) return () => {};\n\n const targets = inputs.map((input) => toWatchTarget(registry, input));\n const refIds = targets.map(() => `_watch_${watchRefSeq++}`);\n const resolveAt = (index: number) =>\n create\n ? resolveBloc(registry, targets[index], refIds[index])\n : resolveBlocPassive(registry, targets[index]);\n\n let disposed = false;\n const instances: Array<StateContainerInstance | undefined> = [];\n const channelUnsubs: Array<(() => void) | undefined> = [];\n const disposedUnsubs: Array<(() => void) | undefined> = [];\n\n const cleanup = () => {\n if (disposed) return;\n disposed = true;\n signal?.removeEventListener('abort', cleanup);\n for (const unsub of channelUnsubs) unsub?.();\n for (const unsub of disposedUnsubs) unsub?.();\n channelUnsubs.length = 0;\n disposedUnsubs.length = 0;\n if (create) {\n for (let i = 0; i < instances.length; i++) {\n registry.release(\n targets[i].blocClass,\n targets[i].key,\n false,\n refIds[i],\n );\n }\n }\n };\n\n const runCallback = () => {\n if (disposed) return;\n if (instances.some((i) => i === undefined)) return;\n const arg = isSingle ? instances[0] : instances;\n const result = callback(arg);\n if (result === STOP) cleanup();\n };\n\n const subscribeAt = (index: number) => {\n channelUnsubs[index] = instances[index]?.channel.subscribe(\n () => ALL_PATHS,\n runCallback,\n );\n };\n\n // On external dispose, tear down the stale subscription and re-acquire +\n // resubscribe (microtask-deferred, so it never runs mid-mutation of the\n // registry that triggered the dispose, e.g. `clearAll()`), then notify.\n const resubscribeAt = (index: number) => {\n if (disposed) return;\n instances[index] = resolveAt(index);\n subscribeAt(index);\n subscribeDisposeAt(index);\n runCallback();\n };\n\n const subscribeDisposeAt = (index: number) => {\n disposedUnsubs[index] = instances[index]?.[ON_DISPOSE](() => {\n channelUnsubs[index]?.();\n channelUnsubs[index] = undefined;\n queueMicrotask(() => resubscribeAt(index));\n });\n };\n\n signal?.addEventListener('abort', cleanup, { once: true });\n\n try {\n for (let i = 0; i < targets.length; i++) instances.push(resolveAt(i));\n for (let i = 0; i < instances.length; i++) subscribeAt(i);\n for (let i = 0; i < instances.length; i++) subscribeDisposeAt(i);\n // Fire once immediately so the consumer sees the current state.\n runCallback();\n } catch (error) {\n cleanup();\n throw error;\n }\n\n return cleanup;\n}\n\nexport const watch: WatchFn = Object.assign(watchImpl, { STOP }) as WatchFn;\n","declare const brand: unique symbol;\n\n/**\n * Nominal type helper, preventing accidental confusion between similar\n * primitive types.\n * @typeParam T - The base type\n * @typeParam B - The brand identifier\n */\nexport type Brand<T, B> = T & { [brand]: B };\n\n/**\n * Branded string type for type-safe IDs.\n * @typeParam B - The brand identifier\n */\nexport type BrandedId<B> = Brand<string, B>;\n\n/** Branded string type for state container instance IDs. */\nexport type InstanceId = Brand<string, 'InstanceId'>;\n\nexport function instanceId(id: string): InstanceId {\n return id as InstanceId;\n}\n"],"mappings":"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"}
@@ -0,0 +1,10 @@
1
+ Object.defineProperty(exports, Symbol.toStringTag, { value: "Module" });
2
+ const require_StateContainerRegistry = require("./StateContainerRegistry-B6O6cfJd.cjs");
3
+ const require_StateContainer = require("./StateContainer-D2b10eR4.cjs");
4
+ exports.APPLY_DEPS = require_StateContainerRegistry.APPLY_DEPS;
5
+ exports.DEP_BRAND = require_StateContainer.DEP_BRAND;
6
+ exports.INIT_CONFIG = require_StateContainerRegistry.INIT_CONFIG;
7
+ exports.INSERT_INSTANCE = require_StateContainerRegistry.INSERT_INSTANCE;
8
+ exports.ON_DISPOSE = require_StateContainerRegistry.ON_DISPOSE;
9
+ exports.REMOVE_DEPS_OWNER = require_StateContainerRegistry.REMOVE_DEPS_OWNER;
10
+ exports.WITH_TRACKED_STATE = require_StateContainerRegistry.WITH_TRACKED_STATE;
@@ -0,0 +1,8 @@
1
+ /**
2
+ * Framework hooks used by `@blac/react` and the testing helpers. Not public
3
+ * API; may change in any release.
4
+ *
5
+ * @packageDocumentation
6
+ */
7
+ export { DEP_BRAND } from './core/StateContainer';
8
+ export { APPLY_DEPS, REMOVE_DEPS_OWNER, INIT_CONFIG, INSERT_INSTANCE, ON_DISPOSE, WITH_TRACKED_STATE, } from './core/symbols';
@@ -0,0 +1,8 @@
1
+ /**
2
+ * Framework hooks used by `@blac/react` and the testing helpers. Not public
3
+ * API; may change in any release.
4
+ *
5
+ * @packageDocumentation
6
+ */
7
+ export { DEP_BRAND } from './core/StateContainer';
8
+ export { APPLY_DEPS, REMOVE_DEPS_OWNER, INIT_CONFIG, INSERT_INSTANCE, ON_DISPOSE, WITH_TRACKED_STATE, } from './core/symbols';
@@ -0,0 +1,3 @@
1
+ import { a as INSERT_INSTANCE, c as REMOVE_DEPS_OWNER, i as INIT_CONFIG, r as APPLY_DEPS, s as ON_DISPOSE, u as WITH_TRACKED_STATE } from "./StateContainerRegistry-CrTtRX5V.js";
2
+ import { t as DEP_BRAND } from "./StateContainer-CwByTd5L.js";
3
+ export { APPLY_DEPS, DEP_BRAND, INIT_CONFIG, INSERT_INSTANCE, ON_DISPOSE, REMOVE_DEPS_OWNER, WITH_TRACKED_STATE };
@@ -17,15 +17,10 @@ export interface InstanceMetadata {
17
17
  args?: unknown;
18
18
  }
19
19
  /**
20
- * Per-event context delivered to plugin hooks.
21
- *
22
- * `PluginContext` is per-container — it identifies the bloc, not the event.
23
- * Per-event data (e.g. the changed `PathSet`) is passed via dedicated method
24
- * arguments, never via the context object.
25
- *
26
- * The `container` field is the focal bloc for the event. For `onInstall`
27
- * (which fires once at install time, not bound to any container) the
28
- * `container` field is `undefined`.
20
+ * Per-event context delivered to plugin hooks. Identifies the focal
21
+ * container for the event (`undefined` only for `onInstall`, which fires
22
+ * once at install time before any container is known); per-event data (e.g.
23
+ * the changed `PathSet`) is passed via method arguments, not this object.
29
24
  */
30
25
  export interface PluginContext {
31
26
  /**
@@ -53,21 +48,10 @@ export interface PluginContext {
53
48
  /**
54
49
  * BlaC plugin hook surface.
55
50
  *
56
- * State-change events carry the `PathSet` of paths that changed in the flush.
57
- * Lifecycle events (`onCreated`, `onDestroyed`) are not tied to a state change
58
- * and so do not carry `paths`.
59
- *
60
- * Hook firing model:
61
- * - `onCreated` fires synchronously when a container is first acquired.
62
- * - `onStateChange` fires once per channel flush (microtask-coalesced).
63
- * `prev` is the state before the first emit of the flush; `next` is the
64
- * state at flush time; `paths` is the set of paths marked during the flush.
65
- * - `onDestroyed` fires synchronously when a container is disposed (after
66
- * its system 'dispose' event).
67
- *
68
- * The ref/deps hooks (`onRefAcquired`, `onRefReleased`, `onDepsChanged`) are
69
- * devtools-only — they drive devtools-connect and are orthogonal to the
70
- * state-change event payload.
51
+ * `onStateChange` fires once per channel flush (microtask-coalesced) with
52
+ * the changed `PathSet`; lifecycle hooks (`onCreated`, `onDestroyed`) fire
53
+ * synchronously and carry no `paths`. The ref/deps hooks (`onRefAcquired`,
54
+ * `onRefReleased`, `onDepsChanged`) are devtools-only.
71
55
  */
72
56
  export interface BlacPlugin {
73
57
  readonly name: string;
@@ -85,7 +69,9 @@ export interface BlacPlugin {
85
69
  onCreated?(ctx: PluginContext): void;
86
70
  /**
87
71
  * Fires once per channel flush with the changed `PathSet`.
88
- * `paths` may be `ALL_PATHS` when the change spans every path.
72
+ * `paths` may be `ALL_PATHS` when the change spans every path, and may
73
+ * include the container's reserved root id (`container.interner.rootId()`),
74
+ * which decodes to the empty path `''`.
89
75
  * `prev`/`next` are the coalesced before/after states for the flush.
90
76
  */
91
77
  onStateChange?<S extends object = any>(ctx: PluginContext, prev: S, next: S, paths: PathSet): void;
@@ -99,6 +85,20 @@ export interface BlacPlugin {
99
85
  * Fires when a container's hydration status transitions.
100
86
  */
101
87
  onHydrationChange?(ctx: PluginContext, status: HydrationStatus, previousStatus: HydrationStatus): void;
88
+ /**
89
+ * Fires on the same 0↔1 ownership transition that drives the container's
90
+ * own `onActivate`, after that hook has already run. `signal` aborts on the
91
+ * matching `onDeactivate` and on dispose — dispose does NOT fire
92
+ * `onDeactivate` (or this hook), matching `StateContainer`'s single
93
+ * teardown path.
94
+ */
95
+ onActivate?(ctx: PluginContext, signal: AbortSignal): void;
96
+ /**
97
+ * Fires when an active container goes back to unowned while surviving in
98
+ * the registry (i.e. `keepAlive`), after the container's own `onDeactivate`
99
+ * has already run. Not fired on dispose.
100
+ */
101
+ onDeactivate?(ctx: PluginContext): void;
102
102
  /**
103
103
  * @internal Devtools-only — fires when a named ref is acquired.
104
104
  * Not part of the state-change event payload.