@blac/core 2.0.20 → 2.0.22

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 (295) hide show
  1. package/README.md +19 -29
  2. package/dist/{StateContainerRegistry-CSNm2Ws5.cjs → StateContainerRegistry-141uHhtF.cjs} +300 -397
  3. package/dist/StateContainerRegistry-141uHhtF.cjs.map +1 -0
  4. package/dist/{StateContainerRegistry-DVIBTxGZ.js → StateContainerRegistry-BH7aOMWV.js} +299 -406
  5. package/dist/StateContainerRegistry-BH7aOMWV.js.map +1 -0
  6. package/dist/{StateContainerRegistry-Dj77cok9.js → StateContainerRegistry-BsH_s0pJ.js} +303 -413
  7. package/dist/StateContainerRegistry-BsH_s0pJ.js.map +1 -0
  8. package/dist/{StateContainerRegistry-lIwo-0m3.cjs → StateContainerRegistry-CBLeHObO.cjs} +326 -418
  9. package/dist/StateContainerRegistry-CBLeHObO.cjs.map +1 -0
  10. package/dist/{StateContainerRegistry-D9BIRjwv.cjs → StateContainerRegistry-MkT0W4C2.cjs} +322 -411
  11. package/dist/StateContainerRegistry-MkT0W4C2.cjs.map +1 -0
  12. package/dist/{StateContainerRegistry-CvBOhAT2.js → StateContainerRegistry-vWgsD-RP.js} +277 -392
  13. package/dist/StateContainerRegistry-vWgsD-RP.js.map +1 -0
  14. package/dist/config.d.cts +2 -2
  15. package/dist/config.d.ts +2 -2
  16. package/dist/constants.d.cts +4 -20
  17. package/dist/constants.d.ts +4 -20
  18. package/dist/core/Cubit.d.ts +14 -10
  19. package/dist/core/StateContainer.d.ts +68 -8
  20. package/dist/core/StateContainerRegistry.d.ts +100 -19
  21. package/dist/core/meta.d.ts +34 -47
  22. package/dist/core/symbols.d.ts +18 -1
  23. package/dist/decorators/blac.d.ts +28 -26
  24. package/dist/{ensure-BKdq5xsY.cjs → ensure-BjhbDW8Z.cjs} +223 -40
  25. package/dist/ensure-BjhbDW8Z.cjs.map +1 -0
  26. package/dist/ensure-BnVyd6s4.js +730 -0
  27. package/dist/ensure-BnVyd6s4.js.map +1 -0
  28. package/dist/ensure-CneMkpbI.js +731 -0
  29. package/dist/ensure-CneMkpbI.js.map +1 -0
  30. package/dist/{ensure-CQimeD0I.cjs → ensure-D15vGnk5.cjs} +348 -124
  31. package/dist/ensure-D15vGnk5.cjs.map +1 -0
  32. package/dist/{ensure-B1dEDsZV.cjs → ensure-D3w6YGp9.cjs} +349 -124
  33. package/dist/ensure-D3w6YGp9.cjs.map +1 -0
  34. package/dist/{ensure-B2DYCbbI.cjs → ensure-ORVw-WRE.cjs} +214 -39
  35. package/dist/ensure-ORVw-WRE.cjs.map +1 -0
  36. package/dist/{ensure-B59ri8oo.js → ensure-dsqWhIuO.js} +192 -39
  37. package/dist/ensure-dsqWhIuO.js.map +1 -0
  38. package/dist/{ensure-BSJHkUNX.js → ensure-k-6q7O25.js} +183 -38
  39. package/dist/ensure-k-6q7O25.js.map +1 -0
  40. package/dist/index.cjs +212 -32
  41. package/dist/index.cjs.map +1 -1
  42. package/dist/index.d.cts +4 -6
  43. package/dist/index.d.ts +4 -6
  44. package/dist/index.js +192 -12
  45. package/dist/index.js.map +1 -1
  46. package/dist/plugin/BlacPlugin.d.ts +14 -0
  47. package/dist/plugin/PluginManager.d.ts +21 -11
  48. package/dist/plugins.cjs +403 -3
  49. package/dist/plugins.cjs.map +1 -0
  50. package/dist/plugins.d.cts +6 -2
  51. package/dist/plugins.d.ts +6 -2
  52. package/dist/plugins.js +401 -1
  53. package/dist/plugins.js.map +1 -0
  54. package/dist/registry/acquire.d.ts +2 -2
  55. package/dist/registry/config.d.ts +9 -0
  56. package/dist/registry/management.d.ts +3 -0
  57. package/dist/registry/queries.d.ts +15 -0
  58. package/dist/registry/release.d.ts +3 -3
  59. package/dist/testing.cjs +13 -15
  60. package/dist/testing.cjs.map +1 -1
  61. package/dist/testing.d.cts +1 -1
  62. package/dist/testing.d.ts +1 -1
  63. package/dist/testing.js +2 -4
  64. package/dist/testing.js.map +1 -1
  65. package/dist/types/branded.d.ts +3 -3
  66. package/dist/types/utilities.d.ts +45 -18
  67. package/dist/utils/static-props.d.ts +25 -1
  68. package/dist/utils/structural-key.d.ts +0 -7
  69. package/dist/watch/index.d.ts +1 -1
  70. package/dist/watch/watch.d.ts +22 -3
  71. package/package.json +16 -55
  72. package/dist/StateContainerRegistry-4Ljd9EJx.js +0 -1018
  73. package/dist/StateContainerRegistry-4Ljd9EJx.js.map +0 -1
  74. package/dist/StateContainerRegistry-8zNFMAf7.js +0 -1067
  75. package/dist/StateContainerRegistry-8zNFMAf7.js.map +0 -1
  76. package/dist/StateContainerRegistry-B1GYx9Xo.js +0 -975
  77. package/dist/StateContainerRegistry-B1GYx9Xo.js.map +0 -1
  78. package/dist/StateContainerRegistry-B_ViBLvJ.js +0 -975
  79. package/dist/StateContainerRegistry-B_ViBLvJ.js.map +0 -1
  80. package/dist/StateContainerRegistry-Bx2ly-ba.cjs +0 -1162
  81. package/dist/StateContainerRegistry-Bx2ly-ba.cjs.map +0 -1
  82. package/dist/StateContainerRegistry-C0dCNlTF.js +0 -1005
  83. package/dist/StateContainerRegistry-C0dCNlTF.js.map +0 -1
  84. package/dist/StateContainerRegistry-CEWpc1bj.cjs +0 -1113
  85. package/dist/StateContainerRegistry-CEWpc1bj.cjs.map +0 -1
  86. package/dist/StateContainerRegistry-CS18y4au.cjs +0 -1163
  87. package/dist/StateContainerRegistry-CS18y4au.cjs.map +0 -1
  88. package/dist/StateContainerRegistry-CSNm2Ws5.cjs.map +0 -1
  89. package/dist/StateContainerRegistry-CchRjnjX.cjs +0 -1094
  90. package/dist/StateContainerRegistry-CchRjnjX.cjs.map +0 -1
  91. package/dist/StateContainerRegistry-CvBOhAT2.js.map +0 -1
  92. package/dist/StateContainerRegistry-D8nu7Z0T.js +0 -1068
  93. package/dist/StateContainerRegistry-D8nu7Z0T.js.map +0 -1
  94. package/dist/StateContainerRegistry-D9BIRjwv.cjs.map +0 -1
  95. package/dist/StateContainerRegistry-DJQqLrli.cjs +0 -1046
  96. package/dist/StateContainerRegistry-DJQqLrli.cjs.map +0 -1
  97. package/dist/StateContainerRegistry-DVIBTxGZ.js.map +0 -1
  98. package/dist/StateContainerRegistry-Dj77cok9.js.map +0 -1
  99. package/dist/StateContainerRegistry-FWKzPfS-.cjs +0 -1046
  100. package/dist/StateContainerRegistry-FWKzPfS-.cjs.map +0 -1
  101. package/dist/StateContainerRegistry-lIwo-0m3.cjs.map +0 -1
  102. package/dist/acquire-B1LYXSGj.js +0 -35
  103. package/dist/acquire-B1LYXSGj.js.map +0 -1
  104. package/dist/acquire-B1Wuqla6.cjs +0 -46
  105. package/dist/acquire-B1Wuqla6.cjs.map +0 -1
  106. package/dist/acquire-BJ3xUEmh.cjs +0 -46
  107. package/dist/acquire-BJ3xUEmh.cjs.map +0 -1
  108. package/dist/acquire-BP-ZfUH2.js +0 -35
  109. package/dist/acquire-BP-ZfUH2.js.map +0 -1
  110. package/dist/acquire-BRIJVJaA.js +0 -35
  111. package/dist/acquire-BRIJVJaA.js.map +0 -1
  112. package/dist/acquire-BZIs6tpN.cjs +0 -46
  113. package/dist/acquire-BZIs6tpN.cjs.map +0 -1
  114. package/dist/acquire-B_p1fNEh.cjs +0 -46
  115. package/dist/acquire-B_p1fNEh.cjs.map +0 -1
  116. package/dist/acquire-BdsVZBSe.js +0 -35
  117. package/dist/acquire-BdsVZBSe.js.map +0 -1
  118. package/dist/acquire-C3nOb3XR.cjs +0 -46
  119. package/dist/acquire-C3nOb3XR.cjs.map +0 -1
  120. package/dist/acquire-C4WAS13G.cjs +0 -46
  121. package/dist/acquire-C4WAS13G.cjs.map +0 -1
  122. package/dist/acquire-C7beGI55.cjs +0 -46
  123. package/dist/acquire-C7beGI55.cjs.map +0 -1
  124. package/dist/acquire-CbMz7gWs.cjs +0 -46
  125. package/dist/acquire-CbMz7gWs.cjs.map +0 -1
  126. package/dist/acquire-CwB083au.js +0 -35
  127. package/dist/acquire-CwB083au.js.map +0 -1
  128. package/dist/acquire-DHEOEVcj.cjs +0 -46
  129. package/dist/acquire-DHEOEVcj.cjs.map +0 -1
  130. package/dist/acquire-DXEQDZGr.js +0 -35
  131. package/dist/acquire-DXEQDZGr.js.map +0 -1
  132. package/dist/acquire-Dg-uXwjF.js +0 -35
  133. package/dist/acquire-Dg-uXwjF.js.map +0 -1
  134. package/dist/acquire-Don7499S.js +0 -35
  135. package/dist/acquire-Don7499S.js.map +0 -1
  136. package/dist/acquire-G8aB3GAx.js +0 -35
  137. package/dist/acquire-G8aB3GAx.js.map +0 -1
  138. package/dist/branded-BybA0_xw.cjs +0 -18
  139. package/dist/branded-BybA0_xw.cjs.map +0 -1
  140. package/dist/branded-DkbUzncc.js +0 -13
  141. package/dist/branded-DkbUzncc.js.map +0 -1
  142. package/dist/config-8pyOC5gv.js +0 -16
  143. package/dist/config-8pyOC5gv.js.map +0 -1
  144. package/dist/config-B1l8ZGlU.cjs +0 -32
  145. package/dist/config-B1l8ZGlU.cjs.map +0 -1
  146. package/dist/config-C7Ktkjh2.cjs +0 -32
  147. package/dist/config-C7Ktkjh2.cjs.map +0 -1
  148. package/dist/config-COT4Xkbc.js +0 -16
  149. package/dist/config-COT4Xkbc.js.map +0 -1
  150. package/dist/config-CzcoAvBo.js +0 -16
  151. package/dist/config-CzcoAvBo.js.map +0 -1
  152. package/dist/config-D6BoWWPv.js +0 -16
  153. package/dist/config-D6BoWWPv.js.map +0 -1
  154. package/dist/config-DOO82lbZ.js +0 -16
  155. package/dist/config-DOO82lbZ.js.map +0 -1
  156. package/dist/config-DVM_ESQt.js +0 -16
  157. package/dist/config-DVM_ESQt.js.map +0 -1
  158. package/dist/config-DVMnlHLv.cjs +0 -32
  159. package/dist/config-DVMnlHLv.cjs.map +0 -1
  160. package/dist/config-DWUq7zEQ.cjs +0 -32
  161. package/dist/config-DWUq7zEQ.cjs.map +0 -1
  162. package/dist/config-DXI3kzmA.js +0 -16
  163. package/dist/config-DXI3kzmA.js.map +0 -1
  164. package/dist/config-Dk1FxfXj.js +0 -16
  165. package/dist/config-Dk1FxfXj.js.map +0 -1
  166. package/dist/config-b2z51Y_C.cjs +0 -32
  167. package/dist/config-b2z51Y_C.cjs.map +0 -1
  168. package/dist/config-buwpT7l3.js +0 -16
  169. package/dist/config-buwpT7l3.js.map +0 -1
  170. package/dist/config-cwaTn5oy.cjs +0 -32
  171. package/dist/config-cwaTn5oy.cjs.map +0 -1
  172. package/dist/config-d9_U58ef.cjs +0 -32
  173. package/dist/config-d9_U58ef.cjs.map +0 -1
  174. package/dist/config-hWTayX76.cjs +0 -32
  175. package/dist/config-hWTayX76.cjs.map +0 -1
  176. package/dist/config-sCPKPYxZ.cjs +0 -32
  177. package/dist/config-sCPKPYxZ.cjs.map +0 -1
  178. package/dist/debug.cjs +0 -14
  179. package/dist/debug.d.cts +0 -34
  180. package/dist/debug.d.ts +0 -34
  181. package/dist/debug.js +0 -4
  182. package/dist/ensure-B1dEDsZV.cjs.map +0 -1
  183. package/dist/ensure-B2DYCbbI.cjs.map +0 -1
  184. package/dist/ensure-B59ri8oo.js.map +0 -1
  185. package/dist/ensure-B9oOqpOB.cjs +0 -558
  186. package/dist/ensure-B9oOqpOB.cjs.map +0 -1
  187. package/dist/ensure-BKdq5xsY.cjs.map +0 -1
  188. package/dist/ensure-BSJHkUNX.js.map +0 -1
  189. package/dist/ensure-BfYnvAsI.js +0 -709
  190. package/dist/ensure-BfYnvAsI.js.map +0 -1
  191. package/dist/ensure-Bm91o37h.js +0 -536
  192. package/dist/ensure-Bm91o37h.js.map +0 -1
  193. package/dist/ensure-C1a8IFWy.js +0 -535
  194. package/dist/ensure-C1a8IFWy.js.map +0 -1
  195. package/dist/ensure-CLQEx0Nn.cjs +0 -528
  196. package/dist/ensure-CLQEx0Nn.cjs.map +0 -1
  197. package/dist/ensure-CPMiGvov.js +0 -493
  198. package/dist/ensure-CPMiGvov.js.map +0 -1
  199. package/dist/ensure-CQimeD0I.cjs.map +0 -1
  200. package/dist/ensure-DEXSmA-N.js +0 -526
  201. package/dist/ensure-DEXSmA-N.js.map +0 -1
  202. package/dist/ensure-DTTTd2h8.js +0 -536
  203. package/dist/ensure-DTTTd2h8.js.map +0 -1
  204. package/dist/ensure-Dx86f80B.cjs +0 -567
  205. package/dist/ensure-Dx86f80B.cjs.map +0 -1
  206. package/dist/ensure-DzqGej43.js +0 -526
  207. package/dist/ensure-DzqGej43.js.map +0 -1
  208. package/dist/ensure-VuiNPccZ.cjs +0 -559
  209. package/dist/ensure-VuiNPccZ.cjs.map +0 -1
  210. package/dist/ensure-_Oh8XPm4.cjs +0 -732
  211. package/dist/ensure-_Oh8XPm4.cjs.map +0 -1
  212. package/dist/ensure-fsQMjaQL.cjs +0 -567
  213. package/dist/ensure-fsQMjaQL.cjs.map +0 -1
  214. package/dist/ensure-vxAGa2v3.js +0 -536
  215. package/dist/ensure-vxAGa2v3.js.map +0 -1
  216. package/dist/management-14vsHr4t.cjs +0 -85
  217. package/dist/management-14vsHr4t.cjs.map +0 -1
  218. package/dist/management-444tdCBG.js +0 -38
  219. package/dist/management-444tdCBG.js.map +0 -1
  220. package/dist/management-7jLjVHJd.js +0 -38
  221. package/dist/management-7jLjVHJd.js.map +0 -1
  222. package/dist/management-AFuqQEwz.js +0 -38
  223. package/dist/management-AFuqQEwz.js.map +0 -1
  224. package/dist/management-BodVLAfJ.cjs +0 -85
  225. package/dist/management-BodVLAfJ.cjs.map +0 -1
  226. package/dist/management-BqGBdL01.js +0 -38
  227. package/dist/management-BqGBdL01.js.map +0 -1
  228. package/dist/management-BvUAjril.js +0 -38
  229. package/dist/management-BvUAjril.js.map +0 -1
  230. package/dist/management-C-WGcwPD.js +0 -38
  231. package/dist/management-C-WGcwPD.js.map +0 -1
  232. package/dist/management-C2wv4vGS.cjs +0 -85
  233. package/dist/management-C2wv4vGS.cjs.map +0 -1
  234. package/dist/management-D2pjr38g.js +0 -38
  235. package/dist/management-D2pjr38g.js.map +0 -1
  236. package/dist/management-D5WsZoTV.js +0 -38
  237. package/dist/management-D5WsZoTV.js.map +0 -1
  238. package/dist/management-DAV9sN-k.cjs +0 -85
  239. package/dist/management-DAV9sN-k.cjs.map +0 -1
  240. package/dist/management-Df7Y2sF1.cjs +0 -85
  241. package/dist/management-Df7Y2sF1.cjs.map +0 -1
  242. package/dist/management-DwO0nBzL.cjs +0 -85
  243. package/dist/management-DwO0nBzL.cjs.map +0 -1
  244. package/dist/management-GcnNJjnm.cjs +0 -85
  245. package/dist/management-GcnNJjnm.cjs.map +0 -1
  246. package/dist/management-P_Vi_cvw.js +0 -38
  247. package/dist/management-P_Vi_cvw.js.map +0 -1
  248. package/dist/management-QWLpbXlW.cjs +0 -85
  249. package/dist/management-QWLpbXlW.cjs.map +0 -1
  250. package/dist/management-iE4x6IQY.cjs +0 -85
  251. package/dist/management-iE4x6IQY.cjs.map +0 -1
  252. package/dist/types.cjs +0 -3
  253. package/dist/types.d.cts +0 -8
  254. package/dist/types.d.ts +0 -8
  255. package/dist/types.js +0 -2
  256. package/dist/watch-B0pUfh-v.cjs +0 -119
  257. package/dist/watch-B0pUfh-v.cjs.map +0 -1
  258. package/dist/watch-B91opmva.cjs +0 -70
  259. package/dist/watch-B91opmva.cjs.map +0 -1
  260. package/dist/watch-BHfCtbn1.cjs +0 -119
  261. package/dist/watch-BHfCtbn1.cjs.map +0 -1
  262. package/dist/watch-BmC-Tyqg.js +0 -59
  263. package/dist/watch-BmC-Tyqg.js.map +0 -1
  264. package/dist/watch-Bx0y-Kcc.js +0 -108
  265. package/dist/watch-Bx0y-Kcc.js.map +0 -1
  266. package/dist/watch-CKWt788i.cjs +0 -70
  267. package/dist/watch-CKWt788i.cjs.map +0 -1
  268. package/dist/watch-CfrSSrRY.js +0 -59
  269. package/dist/watch-CfrSSrRY.js.map +0 -1
  270. package/dist/watch-Cnh3PtQA.cjs +0 -70
  271. package/dist/watch-Cnh3PtQA.cjs.map +0 -1
  272. package/dist/watch-D01MdwKy.js +0 -108
  273. package/dist/watch-D01MdwKy.js.map +0 -1
  274. package/dist/watch-D8hwbFU1.js +0 -59
  275. package/dist/watch-D8hwbFU1.js.map +0 -1
  276. package/dist/watch-DPVUwPUY.js +0 -59
  277. package/dist/watch-DPVUwPUY.js.map +0 -1
  278. package/dist/watch-DVmvZBMD.cjs +0 -70
  279. package/dist/watch-DVmvZBMD.cjs.map +0 -1
  280. package/dist/watch-DkDGmGAx.cjs +0 -119
  281. package/dist/watch-DkDGmGAx.cjs.map +0 -1
  282. package/dist/watch-DttHqefn.js +0 -108
  283. package/dist/watch-DttHqefn.js.map +0 -1
  284. package/dist/watch-DxdIZjpt.cjs +0 -119
  285. package/dist/watch-DxdIZjpt.cjs.map +0 -1
  286. package/dist/watch-DztcJuUy.cjs +0 -119
  287. package/dist/watch-DztcJuUy.cjs.map +0 -1
  288. package/dist/watch-IrR8G28N.js +0 -108
  289. package/dist/watch-IrR8G28N.js.map +0 -1
  290. package/dist/watch-entry.cjs +0 -4
  291. package/dist/watch-entry.d.cts +0 -24
  292. package/dist/watch-entry.d.ts +0 -24
  293. package/dist/watch-entry.js +0 -2
  294. package/dist/watch-hx0r92Zc.js +0 -108
  295. package/dist/watch-hx0r92Zc.js.map +0 -1
@@ -1,13 +1,15 @@
1
1
  import type { HydrationStatus, StateContainer } from './StateContainer';
2
- import { type PluginManager } from '../plugin/PluginManager';
3
2
  import { InstanceReadonlyState, StateContainerConstructor } from '../types/utilities';
4
3
  /**
5
4
  * Entry in the instance registry, tracking the instance and its named references
6
- * @template T - Instance type
5
+ * @typeParam T - Instance type
6
+ * @internal
7
7
  */
8
8
  export interface InstanceEntry<T = any> {
9
9
  /** The state container instance */
10
10
  instance: T;
11
+ /** The key this entry is stored under in its constructor's instances Map. */
12
+ key: string;
11
13
  /** Map of active reference IDs to their acquire count (supports paired acquire/release) */
12
14
  refs: Map<string, number>;
13
15
  /** The args used when this entry was first created; used for dev-warn on arg mismatch. */
@@ -19,13 +21,15 @@ export interface InstanceEntry<T = any> {
19
21
  }
20
22
  /**
21
23
  * Lifecycle events emitted by the registry
24
+ * @public
22
25
  */
23
- export type LifecycleEvent = 'created' | 'stateChanged' | 'disposed' | 'refAcquired' | 'refReleased' | 'depsChanged' | 'hydrationChanged';
26
+ export type LifecycleEvent = 'created' | 'stateChanged' | 'disposed' | 'refAcquired' | 'refReleased' | 'depsChanged' | 'hydrationChanged' | 'activated' | 'deactivated';
24
27
  /**
25
28
  * Listener function type for each lifecycle event
26
- * @template E - The lifecycle event type
29
+ * @typeParam E - The lifecycle event type
30
+ * @public
27
31
  */
28
- export type LifecycleListener<E extends LifecycleEvent> = E extends 'created' ? (container: StateContainer<any, any, any>) => void : E extends 'stateChanged' ? (container: StateContainer<any, any, any>, previousState: any, currentState: any) => void : E extends 'disposed' ? (container: StateContainer<any, any, any>) => void : E extends 'refAcquired' ? (container: StateContainer<any, any, any>, refId: string) => void : E extends 'refReleased' ? (container: StateContainer<any, any, any>, refId: string) => void : E extends 'depsChanged' ? (container: StateContainer<any, any, any>, previousDeps: Readonly<Record<string, unknown>>, currentDeps: Readonly<Record<string, unknown>>) => void : E extends 'hydrationChanged' ? (container: StateContainer<any, any, any>, status: HydrationStatus, previousStatus: HydrationStatus) => void : never;
32
+ export type LifecycleListener<E extends LifecycleEvent> = E extends 'created' ? (container: StateContainer<any, any, any>) => void : E extends 'stateChanged' ? (container: StateContainer<any, any, any>, previousState: Readonly<Record<string, unknown>>, currentState: Readonly<Record<string, unknown>>) => void : E extends 'disposed' ? (container: StateContainer<any, any, any>) => void : E extends 'refAcquired' ? (container: StateContainer<any, any, any>, refId: string) => void : E extends 'refReleased' ? (container: StateContainer<any, any, any>, refId: string) => void : E extends 'depsChanged' ? (container: StateContainer<any, any, any>, previousDeps: Readonly<Record<string, unknown>>, currentDeps: Readonly<Record<string, unknown>>) => void : E extends 'hydrationChanged' ? (container: StateContainer<any, any, any>, status: HydrationStatus, previousStatus: HydrationStatus) => void : E extends 'activated' ? (container: StateContainer<any, any, any>, signal: AbortSignal) => void : E extends 'deactivated' ? (container: StateContainer<any, any, any>) => void : never;
29
33
  /**
30
34
  * Central registry for managing StateContainer instances.
31
35
  * Handles instance lifecycle, named ref tracking, and lifecycle event emission.
@@ -39,13 +43,33 @@ export type LifecycleListener<E extends LifecycleEvent> = E extends 'created' ?
39
43
  * console.log('State changed:', prev, '->', next);
40
44
  * });
41
45
  * ```
46
+ *
47
+ * `stateChanged` fires once per emit (microtask-deferred but uncoalesced), so
48
+ * listeners see every intermediate transition. Plugins' `onStateChange` fires
49
+ * once per channel flush with coalesced `prev`/`next` and a `PathSet`. Pick
50
+ * the transition log for devtools/time-travel, the plugin hook for
51
+ * change-driven work.
42
52
  */
43
53
  export declare class StateContainerRegistry {
44
54
  private readonly instancesByConstructor;
45
55
  private readonly types;
46
- private readonly registeredTypeNames;
56
+ /**
57
+ * `depend()`-owner to the (Type, key) entries it has resolved. Keyed per
58
+ * resolved key because one handle resolves a different key per `args`.
59
+ * Weak so a bare `new`'d owner that is never disposed cannot pin the map.
60
+ */
61
+ private readonly _dependentEdges;
62
+ /**
63
+ * Reverse lookup from `$blac.id` to its entry, for `PluginContext.getRefIds`
64
+ * and the O(1) prune on dispose. Ids are `<name>:<key>`, so an entry is
65
+ * matched by instance identity as well.
66
+ */
67
+ private readonly _entryById;
47
68
  private readonly listeners;
48
- private _stateChangedListenerCount;
69
+ /**
70
+ * Derived from the listener Set, never a parallel counter: `on()` with the
71
+ * same function twice adds once, so a counter cannot stay in step.
72
+ */
49
73
  get hasStateChangedListeners(): boolean;
50
74
  private _pendingStateChanges;
51
75
  private _autoRefIdCounter;
@@ -57,6 +81,35 @@ export declare class StateContainerRegistry {
57
81
  * release its dependent edges on whatever it `depend()`'d on.
58
82
  */
59
83
  private _handleDisposed;
84
+ /**
85
+ * An entry may be disposed only when nothing owns it: no public refs, no
86
+ * `depend()` dependents, and not keepAlive. Every dispose decision goes
87
+ * through here so `release()` and `_releaseDependent` cannot disagree.
88
+ */
89
+ private _isUnowned;
90
+ /**
91
+ * Pure ownership: refs plus `depend()` dependents, with no keepAlive term.
92
+ * `_isUnowned` is "may be disposed"; this is "nothing is using it", which is
93
+ * what the activation lifecycle keys off — a keepAlive instance still
94
+ * deactivates when its last owner goes.
95
+ */
96
+ private _hasNoOwners;
97
+ /**
98
+ * Single funnel for the 0↔1 ownership transition. `SET_ACTIVE` is idempotent,
99
+ * so every acquire/release path can call this unconditionally rather than
100
+ * each computing the edge itself. Emits `activated`/`deactivated` for
101
+ * plugins to observe the same transition `onActivate`/`onDeactivate` expose
102
+ * to bloc authors — after `SET_ACTIVE` has already run the instance's own
103
+ * hook, so plugins always see a container that has finished reacting.
104
+ */
105
+ private _syncActivation;
106
+ /**
107
+ * Record that `dependent` resolved `Type` at `key`, so the edge can be
108
+ * released on the owner's disposal. Keyed per resolved key, not per type:
109
+ * one `depend()` handle resolves a distinct key for every `args` it is
110
+ * called with, and all of them must be swept.
111
+ */
112
+ private _recordDependentEdge;
60
113
  /**
61
114
  * Remove the Map entry for `container`, if this registry is tracking it.
62
115
  * @returns true if an entry was found and removed
@@ -84,7 +137,7 @@ export declare class StateContainerRegistry {
84
137
  /**
85
138
  * Get the instances Map for a specific class (public API for stats/debugging)
86
139
  */
87
- getInstancesMap<T extends StateContainerConstructor>(Type: T): Map<string, InstanceEntry>;
140
+ getInstancesMap<T extends StateContainerConstructor>(Type: T): ReadonlyMap<string, InstanceEntry>;
88
141
  /**
89
142
  * Directly insert an instance entry into the registry without going through
90
143
  * acquire/release. Creates the internal WeakMap bucket for the constructor if
@@ -103,7 +156,7 @@ export declare class StateContainerRegistry {
103
156
  * an args-derived key is never dropped (instance leaks).
104
157
  *
105
158
  * Resolution order (explicit beats derived):
106
- * explicit key > `static key(args)` > structural hash of args > default sentinel.
159
+ * explicit key \> `static key(args)` \> structural hash of args \> default sentinel.
107
160
  *
108
161
  * @param Type - The StateContainer class constructor
109
162
  * @param instanceKey - Explicit key, or undefined to derive from args
@@ -132,12 +185,13 @@ export declare class StateContainerRegistry {
132
185
  * wrapper; `useBloc` and `watch` address a pre-resolved key here.
133
186
  * @param Type - The StateContainer class constructor
134
187
  * @param instanceKey - Pre-resolved instance key (defaults to 'default')
135
- * @param options - Acquisition options
136
- * @param options.canCreate - Whether to create new instance if not found (default: true)
137
- * @param options.countRef - Whether to add a reference (default: true)
138
- * @param options.refId - Named reference ID for debugging; auto-generated if omitted
139
- * @param options.dependent - The `depend()`-owner resolving this instance, if any;
140
- * recorded so its dependent edge can be released on the owner's disposal.
188
+ * @param options - Acquisition options: `canCreate` (create when absent,
189
+ * default true), `countRef` (add a reference, default true), `refId`
190
+ * (named reference for debugging, auto-generated when omitted),
191
+ * `dependent` — the `depend()`-owner resolving this instance, recorded so
192
+ * its dependent edge is released on the owner's disposal — and
193
+ * `sweepIfUnowned`, for callers that create speculatively and claim
194
+ * ownership later (see {@link _scheduleSweep}).
141
195
  * @returns The state container instance
142
196
  */
143
197
  acquire<T extends StateContainerConstructor = StateContainerConstructor>(Type: T, instanceKey?: string, options?: {
@@ -146,7 +200,19 @@ export declare class StateContainerRegistry {
146
200
  refId?: string;
147
201
  args?: unknown;
148
202
  dependent?: StateContainer<any, any, any>;
203
+ sweepIfUnowned?: boolean;
149
204
  }): InstanceType<T>;
205
+ /**
206
+ * Speculative creates (`useBloc`'s render-time create) leak forever when the
207
+ * render is discarded or never commits — SSR has no commit at all, so nothing
208
+ * ever claims ownership. Sweep at the end of the microtask unless the entry
209
+ * gained an owner or is keepAlive.
210
+ *
211
+ * Opt-in, not automatic: a bare `ensure()` hands the instance to a caller
212
+ * that legitimately holds it without a ref, and sweeping those would make
213
+ * `ensure` unusable across an `await`.
214
+ */
215
+ private _scheduleSweep;
150
216
  /**
151
217
  * Borrow an existing instance without adding a ref (borrowing semantics).
152
218
  * Tracks cross-bloc dependency for reactive updates.
@@ -238,6 +304,13 @@ export declare class StateContainerRegistry {
238
304
  * @returns Array of ref ID strings (empty if instance doesn't exist)
239
305
  */
240
306
  getRefIds<T extends StateContainerConstructor>(Type: T, instanceKey?: string): string[];
307
+ /**
308
+ * Get all active reference IDs for an instance by its `$blac.id`, without
309
+ * needing the owning Type. Used by `PluginContext.getRefIds`.
310
+ * @param instanceId - The instance's `$blac.id`
311
+ * @returns Array of ref ID strings (empty if instance doesn't exist)
312
+ */
313
+ getRefIdsById(instanceId: string): string[];
241
314
  /**
242
315
  * Check if an instance exists.
243
316
  *
@@ -286,19 +359,27 @@ export declare class StateContainerRegistry {
286
359
  emit(event: 'refReleased', container: StateContainer<any, any, any>, refId: string): void;
287
360
  emit(event: 'depsChanged', container: StateContainer<any, any, any>, previousDeps: Readonly<Record<string, unknown>>, currentDeps: Readonly<Record<string, unknown>>): void;
288
361
  emit(event: 'hydrationChanged', container: StateContainer<any, any, any>, status: HydrationStatus, previousStatus: HydrationStatus): void;
362
+ emit(event: 'activated', container: StateContainer<any, any, any>, signal: AbortSignal): void;
363
+ emit(event: 'deactivated', container: StateContainer<any, any, any>): void;
289
364
  /**
290
365
  * Schedule a deferred stateChanged notification via microtask.
291
366
  * Skips entirely when no stateChanged listeners are registered.
292
367
  * @internal - Called by StateContainer.applyState
293
368
  */
294
369
  notifyStateChanged(container: StateContainer<any, any, any>, previousState: any, newState: any): void;
370
+ /**
371
+ * Deliver one event per emit, in order — deliberately NOT coalesced.
372
+ *
373
+ * This is a transition log: devtools, time-travel debugging and perf
374
+ * monitoring need every intermediate `prev`/`next`, which coalescing would
375
+ * destroy. The plugin `onStateChange` bridge is the coalesced, `PathSet`-
376
+ * carrying lane (see `PluginManager.setupLifecycleHooks`); the two differ on
377
+ * purpose, so a listener picks the lane that matches what it needs.
378
+ */
295
379
  private flushStateChanged;
296
380
  }
297
381
  /**
298
382
  * Global default registry instance
383
+ * @public
299
384
  */
300
385
  export declare const globalRegistry: StateContainerRegistry;
301
- /**
302
- * Get the global plugin manager
303
- */
304
- export declare function getPluginManager(): PluginManager;
@@ -1,31 +1,35 @@
1
1
  /**
2
2
  * `$blac` meta namespace for `StateContainer`.
3
3
  *
4
- * ──────────────────────────────────────────────────────────────────────────
5
- * CONSTRAINT — NO ES `#private` FIELDS, ANYWHERE IN THIS FILE.
6
- *
7
- * `@blac/react`'s `buildTrackedProxy` invokes prototype getters with a
8
- * `Proxy(instance)` as the `this`-receiver. Accessing an ES `#private` field
9
- * through a proxy receiver throws (`#x` brand checks fail on the proxy). The
10
- * whole point of this meta object is to be proxy-safe: every getter/method
11
- * here closes over the *real* container instance captured at `createMeta`
12
- * time, NEVER over a `this`-receiver. Do not "modernize" the `_`-prefixed
13
- * TS-private reads below into `#private` access.
14
- * ──────────────────────────────────────────────────────────────────────────
4
+ * `BlacMeta` and `BlacHydration` are classes whose accessors live on the
5
+ * prototype and read the container through one `#private` back-reference, so
6
+ * a container allocates a single small object here instead of a literal with
7
+ * seven closures. Members are therefore not own-enumerable: `Object.keys` and
8
+ * `JSON.stringify` see an empty object. Read the fields by name.
15
9
  */
16
10
  import type { HydrationStatus } from './StateContainer';
17
11
  import type { StateContainerConstructor } from '../types/utilities';
12
+ /**
13
+ * Non-enumerable brand carried on every `$blac` object. Used by the clobber
14
+ * guard in `StateContainer` to detect a subclass class-field shadowing the
15
+ * base's own `$blac` property, and by the meta tests. Intentionally NOT
16
+ * re-exported from the package barrel.
17
+ */
18
+ export declare const META_BRAND: unique symbol;
18
19
  /**
19
20
  * Hydration sub-surface of {@link BlacMeta}. Exposes the container's
20
21
  * hydration state machine — the `begin`/`apply`/`finish`/`fail`/`wait`
21
22
  * methods and the `status`/`error`/`isHydrated`/`changedWhileHydrating`
22
23
  * getters — namespaced under `$blac`.
23
24
  */
24
- export interface BlacHydration<S extends object> {
25
- readonly status: HydrationStatus;
26
- readonly error: Error | undefined;
27
- readonly isHydrated: boolean;
28
- readonly changedWhileHydrating: boolean;
25
+ export declare class BlacHydration<S extends object> {
26
+ #private;
27
+ /** @internal */
28
+ constructor(container: object);
29
+ get status(): HydrationStatus;
30
+ get error(): Error | undefined;
31
+ get isHydrated(): boolean;
32
+ get changedWhileHydrating(): boolean;
29
33
  begin(): void;
30
34
  apply(next: S): boolean;
31
35
  finish(): void;
@@ -38,36 +42,19 @@ export interface BlacHydration<S extends object> {
38
42
  * `createdAt`, `disposed`, `dependencies`, and the hydration methods) under one
39
43
  * namespace, keeping the generic names free for userland blocs.
40
44
  *
41
- * The object is allocated once per container, frozen, branded, and exposes
42
- * live getters that read the container's current `_`-private fields — values
43
- * are never snapshotted.
45
+ * Allocated once per container and frozen. Every accessor reads the
46
+ * container's current `_`-private fields live — values are never snapshotted.
44
47
  */
45
- export interface BlacMeta<S extends object = any> {
46
- readonly name: string;
47
- readonly id: string;
48
- readonly debug: boolean;
49
- readonly createdAt: number;
50
- readonly disposed: boolean;
51
- readonly dependencies: ReadonlyMap<StateContainerConstructor, string>;
52
- readonly hydration: BlacHydration<S>;
48
+ export declare class BlacMeta<S extends object = any> {
49
+ #private;
50
+ /** @internal Called from the `StateContainer` field initializer. */
51
+ constructor(container: object);
52
+ get name(): string;
53
+ get id(): string;
54
+ get debug(): boolean;
55
+ get createdAt(): number;
56
+ get disposed(): boolean;
57
+ get dependencies(): ReadonlyMap<StateContainerConstructor, string>;
58
+ /** Built on first access; identity-stable afterwards. */
59
+ get hydration(): BlacHydration<S>;
53
60
  }
54
- /**
55
- * Non-enumerable brand carried on every `$blac` object produced by
56
- * {@link createMeta}. Used by the clobber guard in `StateContainer` to detect
57
- * a subclass class-field shadowing the base's own `$blac` property, and by the
58
- * meta tests. Intentionally NOT re-exported from the package barrel.
59
- */
60
- export declare const META_BRAND: unique symbol;
61
- /**
62
- * Build the frozen, branded `$blac` meta object for a container.
63
- *
64
- * Called from a `StateContainer` field initializer (`$blac = createMeta(this)`).
65
- * Only the back-reference is captured at this point; every getter/method reads
66
- * the container's `_`-private fields lazily on access, so field-initializer
67
- * ordering relative to those private fields is irrelevant.
68
- *
69
- * The getters close over `container` (the real instance), never over a
70
- * `this`-receiver — this is what keeps `$blac` reads safe through
71
- * `buildTrackedProxy`.
72
- */
73
- export declare function createMeta<S extends object>(container: object): BlacMeta<S>;
@@ -1,6 +1,6 @@
1
1
  /**
2
2
  * @internal Apply one owner's (consumer's) deps slice to an instance.
3
- * Called by framework adapters (e.g. @blac/react useBloc) — not public API.
3
+ * Called by framework adapters (e.g. `@blac/react` useBloc) — not public API.
4
4
  */
5
5
  export declare const APPLY_DEPS: unique symbol;
6
6
  /**
@@ -24,3 +24,20 @@ export declare const ON_DISPOSE: unique symbol;
24
24
  * helpers are the sole callers, mirroring the `APPLY_DEPS` precedent.
25
25
  */
26
26
  export declare const INIT_CONFIG: unique symbol;
27
+ /**
28
+ * @internal Run `fn` with `state` temporarily reporting a render's tracking
29
+ * proxy, so getters record the paths they read. Called by `@blac/react`'s
30
+ * `buildTrackedProxy` — not public API.
31
+ *
32
+ * Replaces the old `this`-Proxy receiver: getters now run with `this` bound to
33
+ * the real instance, so ES `#private` works in user blocs.
34
+ */
35
+ export declare const WITH_TRACKED_STATE: unique symbol;
36
+ /**
37
+ * @internal Drive the activation lifecycle from the registry's 0↔1 ownership
38
+ * transition. Owns the per-instance AbortController so `onActivate`'s signal
39
+ * aborts on the matching deactivation and on dispose.
40
+ *
41
+ * Framework-only — `StateContainerRegistry` is the sole caller.
42
+ */
43
+ export declare const SET_ACTIVE: unique symbol;
@@ -1,33 +1,32 @@
1
1
  import type { EqualityFn } from '../config';
2
2
  /**
3
- * Configuration options for the @blac decorator.
4
- * Only one option can be specified at a time (union type).
3
+ * Configuration options for the `@blac` decorator. Any combination may be
4
+ * given at once.
5
5
  */
6
- export type BlacOptions =
7
- /** Mark bloc to never be auto-disposed when ref count reaches 0 */
8
- {
9
- keepAlive: true;
10
- }
11
- /** Exclude bloc from DevTools tracking (prevents infinite loops) */
12
- | {
13
- excludeFromDevTools: true;
14
- }
15
- /**
16
- * Override the global equality check for this bloc.
17
- * Return `true` to skip the emit (states considered equal).
18
- */
19
- | {
20
- equality: EqualityFn;
6
+ export interface BlacOptions {
7
+ /** Mark bloc to never be auto-disposed when ref count reaches 0 */
8
+ keepAlive?: true;
9
+ /** Exclude bloc from DevTools tracking (prevents infinite loops) */
10
+ excludeFromDevTools?: true;
11
+ /**
12
+ * Override the global equality check for this bloc.
13
+ * Return `true` to skip the emit (states considered equal).
14
+ */
15
+ equality?: EqualityFn;
16
+ /**
17
+ * Override the default structural-hash identity key.
18
+ * The function receives `args` and returns the instance key string.
19
+ * Distinct return values → distinct instances; identical values → shared instance.
20
+ * Non-identity fields can be excluded so they don't fork new instances.
21
+ */
22
+ key?: (args: any) => string;
23
+ /**
24
+ * Explicit, minification-safe identity for this bloc class. Falls back to
25
+ * `constructor.name` when unset, which collides across classes once a
26
+ * minifier shortens class names.
27
+ */
28
+ name?: string;
21
29
  }
22
- /**
23
- * Override the default structural-hash identity key.
24
- * The function receives `args` and returns the instance key string.
25
- * Distinct return values → distinct instances; identical values → shared instance.
26
- * Non-identity fields can be excluded so they don't fork new instances.
27
- */
28
- | {
29
- key: (args: any) => string;
30
- };
31
30
  /**
32
31
  * Decorator to configure StateContainer classes.
33
32
  *
@@ -38,6 +37,9 @@ export type BlacOptions =
38
37
  *
39
38
  * @blac({ excludeFromDevTools: true })
40
39
  * class InternalBloc extends Cubit<InternalState> {}
40
+ *
41
+ * @blac({ keepAlive: true, key: (args) => args.userId })
42
+ * class UserBloc extends Cubit<UserState> {}
41
43
  * ```
42
44
  *
43
45
  * @example Function syntax (no decorator support needed)