@blac/core 2.1.0 → 2.1.1
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.
- package/README.md +19 -29
- package/dist/StateContainer-BUyuxKb3.cjs +667 -0
- package/dist/StateContainer-BUyuxKb3.cjs.map +1 -0
- package/dist/StateContainer-B_7UHc3I.js +632 -0
- package/dist/StateContainer-B_7UHc3I.js.map +1 -0
- package/dist/StateContainer-Bh2ipNYj.js +632 -0
- package/dist/StateContainer-Bh2ipNYj.js.map +1 -0
- package/dist/StateContainer-ClzwKnQZ.cjs +667 -0
- package/dist/StateContainer-ClzwKnQZ.cjs.map +1 -0
- package/dist/StateContainer-DiQATvZh.js +632 -0
- package/dist/StateContainer-DiQATvZh.js.map +1 -0
- package/dist/StateContainer-j16zciex.cjs +667 -0
- package/dist/StateContainer-j16zciex.cjs.map +1 -0
- package/dist/{StateContainerRegistry-CSNm2Ws5.cjs → StateContainerRegistry-141uHhtF.cjs} +300 -397
- package/dist/StateContainerRegistry-141uHhtF.cjs.map +1 -0
- package/dist/{StateContainerRegistry-DVIBTxGZ.js → StateContainerRegistry-BH7aOMWV.js} +299 -406
- package/dist/StateContainerRegistry-BH7aOMWV.js.map +1 -0
- package/dist/StateContainerRegistry-BX-DlHXO.js +747 -0
- package/dist/StateContainerRegistry-BX-DlHXO.js.map +1 -0
- package/dist/StateContainerRegistry-Bf5VuVjm.js +747 -0
- package/dist/StateContainerRegistry-Bf5VuVjm.js.map +1 -0
- package/dist/{StateContainerRegistry-Dj77cok9.js → StateContainerRegistry-BsH_s0pJ.js} +303 -413
- package/dist/StateContainerRegistry-BsH_s0pJ.js.map +1 -0
- package/dist/StateContainerRegistry-BvSRfhKv.cjs +866 -0
- package/dist/StateContainerRegistry-BvSRfhKv.cjs.map +1 -0
- package/dist/StateContainerRegistry-C8jxrcqk.cjs +866 -0
- package/dist/StateContainerRegistry-C8jxrcqk.cjs.map +1 -0
- package/dist/{StateContainerRegistry-lIwo-0m3.cjs → StateContainerRegistry-CBLeHObO.cjs} +326 -418
- package/dist/StateContainerRegistry-CBLeHObO.cjs.map +1 -0
- package/dist/StateContainerRegistry-DjQQtlCW.cjs +870 -0
- package/dist/StateContainerRegistry-DjQQtlCW.cjs.map +1 -0
- package/dist/{StateContainerRegistry-D9BIRjwv.cjs → StateContainerRegistry-MkT0W4C2.cjs} +322 -411
- package/dist/StateContainerRegistry-MkT0W4C2.cjs.map +1 -0
- package/dist/StateContainerRegistry-gQbEutkN.js +751 -0
- package/dist/StateContainerRegistry-gQbEutkN.js.map +1 -0
- package/dist/{StateContainerRegistry-CvBOhAT2.js → StateContainerRegistry-vWgsD-RP.js} +277 -392
- package/dist/StateContainerRegistry-vWgsD-RP.js.map +1 -0
- package/dist/config.d.cts +8 -8
- package/dist/config.d.ts +8 -8
- package/dist/constants.d.cts +18 -28
- package/dist/constants.d.ts +18 -28
- package/dist/core/Cubit.d.ts +14 -10
- package/dist/core/StateContainer.d.ts +83 -62
- package/dist/core/StateContainerRegistry.d.ts +87 -166
- package/dist/core/meta.d.ts +34 -47
- package/dist/core/symbols.d.ts +21 -1
- package/dist/decorators/blac.d.ts +31 -28
- package/dist/{acquire-B1LYXSGj.js → ensure-Bi_yXk6f.js} +16 -5
- package/dist/ensure-Bi_yXk6f.js.map +1 -0
- package/dist/{ensure-r1C_7K6_.cjs → ensure-BjhbDW8Z.cjs} +203 -160
- package/dist/ensure-BjhbDW8Z.cjs.map +1 -0
- package/dist/{ensure-BSJHkUNX.js → ensure-BnVyd6s4.js} +297 -122
- package/dist/ensure-BnVyd6s4.js.map +1 -0
- package/dist/{acquire-BZIs6tpN.cjs → ensure-Bx41d-il.cjs} +23 -6
- package/dist/ensure-Bx41d-il.cjs.map +1 -0
- package/dist/{acquire-BRIJVJaA.js → ensure-C7UQ_mKM.js} +16 -5
- package/dist/ensure-C7UQ_mKM.js.map +1 -0
- package/dist/{ensure-B59ri8oo.js → ensure-CneMkpbI.js} +298 -122
- package/dist/ensure-CneMkpbI.js.map +1 -0
- package/dist/{ensure-B2DYCbbI.cjs → ensure-D15vGnk5.cjs} +328 -123
- package/dist/ensure-D15vGnk5.cjs.map +1 -0
- package/dist/{acquire-B1Wuqla6.cjs → ensure-D1D4WjYf.cjs} +23 -6
- package/dist/ensure-D1D4WjYf.cjs.map +1 -0
- package/dist/{ensure-BKdq5xsY.cjs → ensure-D3w6YGp9.cjs} +329 -123
- package/dist/ensure-D3w6YGp9.cjs.map +1 -0
- package/dist/{acquire-BJ3xUEmh.cjs → ensure-DBnuRJ0R.cjs} +23 -6
- package/dist/ensure-DBnuRJ0R.cjs.map +1 -0
- package/dist/{acquire-BdsVZBSe.js → ensure-NTB9nnnj.js} +16 -5
- package/dist/ensure-NTB9nnnj.js.map +1 -0
- package/dist/{ensure-D3WWWwMo.cjs → ensure-ORVw-WRE.cjs} +194 -155
- package/dist/ensure-ORVw-WRE.cjs.map +1 -0
- package/dist/{ensure-BEeY5Ab7.js → ensure-dsqWhIuO.js} +182 -147
- package/dist/ensure-dsqWhIuO.js.map +1 -0
- package/dist/{ensure-11-asM1e.js → ensure-k-6q7O25.js} +173 -150
- package/dist/ensure-k-6q7O25.js.map +1 -0
- package/dist/index.cjs +234 -87
- package/dist/index.cjs.map +1 -1
- package/dist/index.d.cts +5 -13
- package/dist/index.d.ts +5 -13
- package/dist/index.js +211 -52
- package/dist/index.js.map +1 -1
- package/dist/internal.cjs +10 -0
- package/dist/internal.d.cts +8 -0
- package/dist/internal.d.ts +8 -0
- package/dist/internal.js +3 -0
- package/dist/plugin/BlacPlugin.d.ts +22 -24
- package/dist/plugin/PluginManager.d.ts +47 -60
- package/dist/plugins.cjs +383 -3
- package/dist/plugins.cjs.map +1 -0
- package/dist/plugins.d.cts +10 -5
- package/dist/plugins.d.ts +10 -5
- package/dist/plugins.js +381 -1
- package/dist/plugins.js.map +1 -0
- package/dist/registry/acquire.d.ts +2 -2
- package/dist/registry/config.d.ts +12 -0
- package/dist/registry/index.d.ts +1 -1
- package/dist/registry/management.d.ts +3 -0
- package/dist/registry/queries.d.ts +15 -0
- package/dist/registry/release.d.ts +4 -20
- package/dist/testing.cjs +38 -38
- package/dist/testing.cjs.map +1 -1
- package/dist/testing.d.cts +5 -11
- package/dist/testing.d.ts +5 -11
- package/dist/testing.js +28 -28
- package/dist/testing.js.map +1 -1
- package/dist/types/branded.d.ts +6 -13
- package/dist/types/utilities.d.ts +40 -31
- package/dist/utils/idGenerator.d.ts +6 -13
- package/dist/utils/static-props.d.ts +22 -29
- package/dist/utils/structural-key.d.ts +0 -22
- package/dist/watch/index.d.ts +1 -2
- package/dist/watch/watch.d.ts +17 -3
- package/package.json +28 -54
- package/dist/StateContainerRegistry-4Ljd9EJx.js +0 -1018
- package/dist/StateContainerRegistry-4Ljd9EJx.js.map +0 -1
- package/dist/StateContainerRegistry-8zNFMAf7.js +0 -1067
- package/dist/StateContainerRegistry-8zNFMAf7.js.map +0 -1
- package/dist/StateContainerRegistry-B1GYx9Xo.js +0 -975
- package/dist/StateContainerRegistry-B1GYx9Xo.js.map +0 -1
- package/dist/StateContainerRegistry-B_ViBLvJ.js +0 -975
- package/dist/StateContainerRegistry-B_ViBLvJ.js.map +0 -1
- package/dist/StateContainerRegistry-Bx2ly-ba.cjs +0 -1162
- package/dist/StateContainerRegistry-Bx2ly-ba.cjs.map +0 -1
- package/dist/StateContainerRegistry-C0dCNlTF.js +0 -1005
- package/dist/StateContainerRegistry-C0dCNlTF.js.map +0 -1
- package/dist/StateContainerRegistry-C75QpeaO.cjs +0 -1260
- package/dist/StateContainerRegistry-C75QpeaO.cjs.map +0 -1
- package/dist/StateContainerRegistry-CEWpc1bj.cjs +0 -1113
- package/dist/StateContainerRegistry-CEWpc1bj.cjs.map +0 -1
- package/dist/StateContainerRegistry-CS18y4au.cjs +0 -1163
- package/dist/StateContainerRegistry-CS18y4au.cjs.map +0 -1
- package/dist/StateContainerRegistry-CSNm2Ws5.cjs.map +0 -1
- package/dist/StateContainerRegistry-CchRjnjX.cjs +0 -1094
- package/dist/StateContainerRegistry-CchRjnjX.cjs.map +0 -1
- package/dist/StateContainerRegistry-CvBOhAT2.js.map +0 -1
- package/dist/StateContainerRegistry-D8nu7Z0T.js +0 -1068
- package/dist/StateContainerRegistry-D8nu7Z0T.js.map +0 -1
- package/dist/StateContainerRegistry-D9BIRjwv.cjs.map +0 -1
- package/dist/StateContainerRegistry-DJQqLrli.cjs +0 -1046
- package/dist/StateContainerRegistry-DJQqLrli.cjs.map +0 -1
- package/dist/StateContainerRegistry-DL5Ai7wh.js +0 -1153
- package/dist/StateContainerRegistry-DL5Ai7wh.js.map +0 -1
- package/dist/StateContainerRegistry-DVIBTxGZ.js.map +0 -1
- package/dist/StateContainerRegistry-DWOzx7Gd.js +0 -1154
- package/dist/StateContainerRegistry-DWOzx7Gd.js.map +0 -1
- package/dist/StateContainerRegistry-Dj77cok9.js.map +0 -1
- package/dist/StateContainerRegistry-FWKzPfS-.cjs +0 -1046
- package/dist/StateContainerRegistry-FWKzPfS-.cjs.map +0 -1
- package/dist/StateContainerRegistry-G81GcCRm.cjs +0 -1261
- package/dist/StateContainerRegistry-G81GcCRm.cjs.map +0 -1
- package/dist/StateContainerRegistry-lIwo-0m3.cjs.map +0 -1
- package/dist/acquire-B1LYXSGj.js.map +0 -1
- package/dist/acquire-B1Wuqla6.cjs.map +0 -1
- package/dist/acquire-BJ3xUEmh.cjs.map +0 -1
- package/dist/acquire-BP-ZfUH2.js +0 -35
- package/dist/acquire-BP-ZfUH2.js.map +0 -1
- package/dist/acquire-BRIJVJaA.js.map +0 -1
- package/dist/acquire-BZIs6tpN.cjs.map +0 -1
- package/dist/acquire-B_p1fNEh.cjs +0 -46
- package/dist/acquire-B_p1fNEh.cjs.map +0 -1
- package/dist/acquire-BdsVZBSe.js.map +0 -1
- package/dist/acquire-C3nOb3XR.cjs +0 -46
- package/dist/acquire-C3nOb3XR.cjs.map +0 -1
- package/dist/acquire-C4WAS13G.cjs +0 -46
- package/dist/acquire-C4WAS13G.cjs.map +0 -1
- package/dist/acquire-C7beGI55.cjs +0 -46
- package/dist/acquire-C7beGI55.cjs.map +0 -1
- package/dist/acquire-CE0uq0Dx.cjs +0 -46
- package/dist/acquire-CE0uq0Dx.cjs.map +0 -1
- package/dist/acquire-CU0u8BMn.js +0 -35
- package/dist/acquire-CU0u8BMn.js.map +0 -1
- package/dist/acquire-CbMz7gWs.cjs +0 -46
- package/dist/acquire-CbMz7gWs.cjs.map +0 -1
- package/dist/acquire-CkgLJ8WL.cjs +0 -46
- package/dist/acquire-CkgLJ8WL.cjs.map +0 -1
- package/dist/acquire-CwB083au.js +0 -35
- package/dist/acquire-CwB083au.js.map +0 -1
- package/dist/acquire-DHEOEVcj.cjs +0 -46
- package/dist/acquire-DHEOEVcj.cjs.map +0 -1
- package/dist/acquire-DTvfYJ0y.js +0 -35
- package/dist/acquire-DTvfYJ0y.js.map +0 -1
- package/dist/acquire-DXEQDZGr.js +0 -35
- package/dist/acquire-DXEQDZGr.js.map +0 -1
- package/dist/acquire-Dg-uXwjF.js +0 -35
- package/dist/acquire-Dg-uXwjF.js.map +0 -1
- package/dist/acquire-Don7499S.js +0 -35
- package/dist/acquire-Don7499S.js.map +0 -1
- package/dist/acquire-G8aB3GAx.js +0 -35
- package/dist/acquire-G8aB3GAx.js.map +0 -1
- package/dist/branded-BybA0_xw.cjs +0 -18
- package/dist/branded-BybA0_xw.cjs.map +0 -1
- package/dist/branded-DkbUzncc.js +0 -13
- package/dist/branded-DkbUzncc.js.map +0 -1
- package/dist/config-8pyOC5gv.js +0 -16
- package/dist/config-8pyOC5gv.js.map +0 -1
- package/dist/config-B1l8ZGlU.cjs +0 -32
- package/dist/config-B1l8ZGlU.cjs.map +0 -1
- package/dist/config-C1T6Jw7n.cjs +0 -32
- package/dist/config-C1T6Jw7n.cjs.map +0 -1
- package/dist/config-C7Ktkjh2.cjs +0 -32
- package/dist/config-C7Ktkjh2.cjs.map +0 -1
- package/dist/config-COT4Xkbc.js +0 -16
- package/dist/config-COT4Xkbc.js.map +0 -1
- package/dist/config-CzcoAvBo.js +0 -16
- package/dist/config-CzcoAvBo.js.map +0 -1
- package/dist/config-D2A8ZYRM.js +0 -16
- package/dist/config-D2A8ZYRM.js.map +0 -1
- package/dist/config-D34BkraU.cjs +0 -32
- package/dist/config-D34BkraU.cjs.map +0 -1
- package/dist/config-D6BoWWPv.js +0 -16
- package/dist/config-D6BoWWPv.js.map +0 -1
- package/dist/config-DOO82lbZ.js +0 -16
- package/dist/config-DOO82lbZ.js.map +0 -1
- package/dist/config-DVM_ESQt.js +0 -16
- package/dist/config-DVM_ESQt.js.map +0 -1
- package/dist/config-DVMnlHLv.cjs +0 -32
- package/dist/config-DVMnlHLv.cjs.map +0 -1
- package/dist/config-DWUq7zEQ.cjs +0 -32
- package/dist/config-DWUq7zEQ.cjs.map +0 -1
- package/dist/config-DXI3kzmA.js +0 -16
- package/dist/config-DXI3kzmA.js.map +0 -1
- package/dist/config-Dk1FxfXj.js +0 -16
- package/dist/config-Dk1FxfXj.js.map +0 -1
- package/dist/config-ZVy_yFZ3.js +0 -16
- package/dist/config-ZVy_yFZ3.js.map +0 -1
- package/dist/config-b2z51Y_C.cjs +0 -32
- package/dist/config-b2z51Y_C.cjs.map +0 -1
- package/dist/config-buwpT7l3.js +0 -16
- package/dist/config-buwpT7l3.js.map +0 -1
- package/dist/config-cwaTn5oy.cjs +0 -32
- package/dist/config-cwaTn5oy.cjs.map +0 -1
- package/dist/config-d9_U58ef.cjs +0 -32
- package/dist/config-d9_U58ef.cjs.map +0 -1
- package/dist/config-hWTayX76.cjs +0 -32
- package/dist/config-hWTayX76.cjs.map +0 -1
- package/dist/config-sCPKPYxZ.cjs +0 -32
- package/dist/config-sCPKPYxZ.cjs.map +0 -1
- package/dist/debug.cjs +0 -14
- package/dist/debug.d.cts +0 -34
- package/dist/debug.d.ts +0 -34
- package/dist/debug.js +0 -4
- package/dist/ensure-11-asM1e.js.map +0 -1
- package/dist/ensure-B1dEDsZV.cjs +0 -559
- package/dist/ensure-B1dEDsZV.cjs.map +0 -1
- package/dist/ensure-B2DYCbbI.cjs.map +0 -1
- package/dist/ensure-B59ri8oo.js.map +0 -1
- package/dist/ensure-B9oOqpOB.cjs +0 -558
- package/dist/ensure-B9oOqpOB.cjs.map +0 -1
- package/dist/ensure-BEeY5Ab7.js.map +0 -1
- package/dist/ensure-BKdq5xsY.cjs.map +0 -1
- package/dist/ensure-BSJHkUNX.js.map +0 -1
- package/dist/ensure-BfYnvAsI.js +0 -709
- package/dist/ensure-BfYnvAsI.js.map +0 -1
- package/dist/ensure-Bm91o37h.js +0 -536
- package/dist/ensure-Bm91o37h.js.map +0 -1
- package/dist/ensure-C1a8IFWy.js +0 -535
- package/dist/ensure-C1a8IFWy.js.map +0 -1
- package/dist/ensure-CLQEx0Nn.cjs +0 -528
- package/dist/ensure-CLQEx0Nn.cjs.map +0 -1
- package/dist/ensure-CPMiGvov.js +0 -493
- package/dist/ensure-CPMiGvov.js.map +0 -1
- package/dist/ensure-CQimeD0I.cjs +0 -559
- package/dist/ensure-CQimeD0I.cjs.map +0 -1
- package/dist/ensure-D3WWWwMo.cjs.map +0 -1
- package/dist/ensure-DEXSmA-N.js +0 -526
- package/dist/ensure-DEXSmA-N.js.map +0 -1
- package/dist/ensure-DTTTd2h8.js +0 -536
- package/dist/ensure-DTTTd2h8.js.map +0 -1
- package/dist/ensure-Dx86f80B.cjs +0 -567
- package/dist/ensure-Dx86f80B.cjs.map +0 -1
- package/dist/ensure-DzqGej43.js +0 -526
- package/dist/ensure-DzqGej43.js.map +0 -1
- package/dist/ensure-VuiNPccZ.cjs +0 -559
- package/dist/ensure-VuiNPccZ.cjs.map +0 -1
- package/dist/ensure-_Oh8XPm4.cjs +0 -732
- package/dist/ensure-_Oh8XPm4.cjs.map +0 -1
- package/dist/ensure-fsQMjaQL.cjs +0 -567
- package/dist/ensure-fsQMjaQL.cjs.map +0 -1
- package/dist/ensure-r1C_7K6_.cjs.map +0 -1
- package/dist/ensure-vxAGa2v3.js +0 -536
- package/dist/ensure-vxAGa2v3.js.map +0 -1
- package/dist/events.d.cts +0 -42
- package/dist/events.d.ts +0 -42
- package/dist/management-14vsHr4t.cjs +0 -85
- package/dist/management-14vsHr4t.cjs.map +0 -1
- package/dist/management-444tdCBG.js +0 -38
- package/dist/management-444tdCBG.js.map +0 -1
- package/dist/management-7jLjVHJd.js +0 -38
- package/dist/management-7jLjVHJd.js.map +0 -1
- package/dist/management-8x1OVMi6.js +0 -38
- package/dist/management-8x1OVMi6.js.map +0 -1
- package/dist/management-AFuqQEwz.js +0 -38
- package/dist/management-AFuqQEwz.js.map +0 -1
- package/dist/management-BZgsi29F.js +0 -38
- package/dist/management-BZgsi29F.js.map +0 -1
- package/dist/management-BodVLAfJ.cjs +0 -85
- package/dist/management-BodVLAfJ.cjs.map +0 -1
- package/dist/management-BqGBdL01.js +0 -38
- package/dist/management-BqGBdL01.js.map +0 -1
- package/dist/management-BvUAjril.js +0 -38
- package/dist/management-BvUAjril.js.map +0 -1
- package/dist/management-C-WGcwPD.js +0 -38
- package/dist/management-C-WGcwPD.js.map +0 -1
- package/dist/management-C2wv4vGS.cjs +0 -85
- package/dist/management-C2wv4vGS.cjs.map +0 -1
- package/dist/management-D2pjr38g.js +0 -38
- package/dist/management-D2pjr38g.js.map +0 -1
- package/dist/management-D5WsZoTV.js +0 -38
- package/dist/management-D5WsZoTV.js.map +0 -1
- package/dist/management-DAV9sN-k.cjs +0 -85
- package/dist/management-DAV9sN-k.cjs.map +0 -1
- package/dist/management-Df7Y2sF1.cjs +0 -85
- package/dist/management-Df7Y2sF1.cjs.map +0 -1
- package/dist/management-Dg2SxUb6.cjs +0 -85
- package/dist/management-Dg2SxUb6.cjs.map +0 -1
- package/dist/management-DwO0nBzL.cjs +0 -85
- package/dist/management-DwO0nBzL.cjs.map +0 -1
- package/dist/management-GcnNJjnm.cjs +0 -85
- package/dist/management-GcnNJjnm.cjs.map +0 -1
- package/dist/management-P_Vi_cvw.js +0 -38
- package/dist/management-P_Vi_cvw.js.map +0 -1
- package/dist/management-QWLpbXlW.cjs +0 -85
- package/dist/management-QWLpbXlW.cjs.map +0 -1
- package/dist/management-hkY13log.cjs +0 -85
- package/dist/management-hkY13log.cjs.map +0 -1
- package/dist/management-iE4x6IQY.cjs +0 -85
- package/dist/management-iE4x6IQY.cjs.map +0 -1
- package/dist/types.cjs +0 -3
- package/dist/types.d.cts +0 -8
- package/dist/types.d.ts +0 -8
- package/dist/types.js +0 -2
- package/dist/watch/observe.d.ts +0 -13
- package/dist/watch-B0pUfh-v.cjs +0 -119
- package/dist/watch-B0pUfh-v.cjs.map +0 -1
- package/dist/watch-B91opmva.cjs +0 -70
- package/dist/watch-B91opmva.cjs.map +0 -1
- package/dist/watch-BDiwCPmb.js +0 -108
- package/dist/watch-BDiwCPmb.js.map +0 -1
- package/dist/watch-BHfCtbn1.cjs +0 -119
- package/dist/watch-BHfCtbn1.cjs.map +0 -1
- package/dist/watch-BW7gYiDf.js +0 -108
- package/dist/watch-BW7gYiDf.js.map +0 -1
- package/dist/watch-BmC-Tyqg.js +0 -59
- package/dist/watch-BmC-Tyqg.js.map +0 -1
- package/dist/watch-Bx0y-Kcc.js +0 -108
- package/dist/watch-Bx0y-Kcc.js.map +0 -1
- package/dist/watch-CKWt788i.cjs +0 -70
- package/dist/watch-CKWt788i.cjs.map +0 -1
- package/dist/watch-CfrSSrRY.js +0 -59
- package/dist/watch-CfrSSrRY.js.map +0 -1
- package/dist/watch-Cnh3PtQA.cjs +0 -70
- package/dist/watch-Cnh3PtQA.cjs.map +0 -1
- package/dist/watch-D01MdwKy.js +0 -108
- package/dist/watch-D01MdwKy.js.map +0 -1
- package/dist/watch-D8hwbFU1.js +0 -59
- package/dist/watch-D8hwbFU1.js.map +0 -1
- package/dist/watch-DPVUwPUY.js +0 -59
- package/dist/watch-DPVUwPUY.js.map +0 -1
- package/dist/watch-DVmvZBMD.cjs +0 -70
- package/dist/watch-DVmvZBMD.cjs.map +0 -1
- package/dist/watch-DkDGmGAx.cjs +0 -119
- package/dist/watch-DkDGmGAx.cjs.map +0 -1
- package/dist/watch-DttHqefn.js +0 -108
- package/dist/watch-DttHqefn.js.map +0 -1
- package/dist/watch-DxdIZjpt.cjs +0 -119
- package/dist/watch-DxdIZjpt.cjs.map +0 -1
- package/dist/watch-DztcJuUy.cjs +0 -119
- package/dist/watch-DztcJuUy.cjs.map +0 -1
- package/dist/watch-IrR8G28N.js +0 -108
- package/dist/watch-IrR8G28N.js.map +0 -1
- package/dist/watch-aoNLQAXp.cjs +0 -119
- package/dist/watch-aoNLQAXp.cjs.map +0 -1
- package/dist/watch-entry.cjs +0 -4
- package/dist/watch-entry.d.cts +0 -24
- package/dist/watch-entry.d.ts +0 -24
- package/dist/watch-entry.js +0 -2
- package/dist/watch-hx0r92Zc.js +0 -108
- package/dist/watch-hx0r92Zc.js.map +0 -1
- package/dist/watch-lEco5Tbl.cjs +0 -119
- package/dist/watch-lEco5Tbl.cjs.map +0 -1
package/dist/index.d.ts
CHANGED
|
@@ -1,26 +1,18 @@
|
|
|
1
1
|
export { configureBlac, getBlacConfig, resetBlacConfig, shallowEqualState, type BlacConfig, type EqualityFn, } from './config';
|
|
2
|
-
export { StateContainer
|
|
2
|
+
export { StateContainer } from './core/StateContainer';
|
|
3
3
|
export type { HydrationStatus, StateContainerConfig, SystemEvent, SystemEventPayloads, DepHandle, } from './core/StateContainer';
|
|
4
4
|
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
5
|
export type { BlacMeta, BlacHydration } from './core/meta';
|
|
11
6
|
export { ALL_PATHS } from '@dirtytalk/structural';
|
|
12
7
|
export type { PathSet } from '@dirtytalk/structural';
|
|
13
|
-
export { acquire, resolveInstanceKey, borrow, borrowSafe, ensure, release,
|
|
8
|
+
export { acquire, resolveInstanceKey, borrow, borrowSafe, ensure, release, clear, clearAll, register, hasInstance, getRefCount, getRefIds, getAll, forEach, getRegistry, setRegistry, getStats, } from './registry';
|
|
14
9
|
export type { BorrowTarget } from './registry';
|
|
15
10
|
export { globalRegistry, StateContainerRegistry, } from './core/StateContainerRegistry';
|
|
16
11
|
export type { LifecycleEvent, LifecycleListener, InstanceEntry, } from './core/StateContainerRegistry';
|
|
17
12
|
export { blac, type BlacOptions } from './decorators';
|
|
18
|
-
export { isKeepAliveClass, isExcludedFromDevTools,
|
|
19
|
-
export { getPluginManager } from './core/StateContainerRegistry';
|
|
13
|
+
export { isKeepAliveClass, isExcludedFromDevTools, getBlacName, } from './utils/static-props';
|
|
20
14
|
export type { BlacPlugin, BlacPluginWithInit, PluginContext, PluginConfig, InstanceMetadata, } from './plugin/BlacPlugin';
|
|
21
|
-
export {
|
|
22
|
-
export {
|
|
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';
|
|
15
|
+
export { watch, instance, type WatchFn, type WatchOptions, type BlocRef, } from './watch';
|
|
16
|
+
export type { StateContainerConstructor, DeepReadonly, ExtractState, ExtractStateMutable, ExtractArgs, ExtractDeps, InstanceReadonlyState, WithState, InstanceState, StateContainerInstance, } from './types/utilities';
|
|
25
17
|
export type { Brand, BrandedId, InstanceId } from './types/branded';
|
|
26
18
|
export { instanceId } from './types/branded';
|
package/dist/index.js
CHANGED
|
@@ -1,11 +1,33 @@
|
|
|
1
|
-
import { _ as
|
|
2
|
-
import { a as
|
|
3
|
-
import { n as
|
|
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 { _ as configureBlac, b as shallowEqualState, f as isExcludedFromDevTools, m as BLAC_STATIC_PROPS, n as globalRegistry, o as ON_DISPOSE, p as isKeepAliveClass, t as StateContainerRegistry, u as getBlacName, v as getBlacConfig, y as resetBlacConfig } from "./StateContainerRegistry-gQbEutkN.js";
|
|
2
|
+
import { a as getStats, i as getRegistry, n as StateContainer, o as setRegistry } from "./StateContainer-Bh2ipNYj.js";
|
|
3
|
+
import { n as acquire, r as resolveInstanceKey, t as ensure } from "./ensure-Bi_yXk6f.js";
|
|
8
4
|
import { ALL_PATHS, ALL_PATHS as ALL_PATHS$1 } from "@dirtytalk/structural";
|
|
5
|
+
//#region src/core/Cubit.ts
|
|
6
|
+
/**
|
|
7
|
+
* `Cubit<S>` is a `StateContainer<S>` that exposes mutation publicly.
|
|
8
|
+
*
|
|
9
|
+
* That is the whole difference, and it is a real one: on `StateContainer`
|
|
10
|
+
* `emit` / `patch` / `update` are `protected`, so a container mutates itself
|
|
11
|
+
* from its own methods and callers go through the API it chooses to publish.
|
|
12
|
+
* `Cubit` re-declares the three as `public` for the cases where a caller
|
|
13
|
+
* legitimately drives state from outside — test helpers, devtools
|
|
14
|
+
* time-travel, benchmarks.
|
|
15
|
+
*
|
|
16
|
+
* Reach for `StateContainer` when business logic should live in the class,
|
|
17
|
+
* and `Cubit` when the caller owns the transitions.
|
|
18
|
+
*/
|
|
19
|
+
var Cubit = class extends StateContainer {
|
|
20
|
+
emit(next) {
|
|
21
|
+
super.emit(next);
|
|
22
|
+
}
|
|
23
|
+
patch(partial) {
|
|
24
|
+
super.patch(partial);
|
|
25
|
+
}
|
|
26
|
+
update(fn) {
|
|
27
|
+
super.update(fn);
|
|
28
|
+
}
|
|
29
|
+
};
|
|
30
|
+
//#endregion
|
|
9
31
|
//#region src/registry/borrow.ts
|
|
10
32
|
function resolveBorrowKey(BlocClass, target) {
|
|
11
33
|
return getRegistry().resolveKey(BlocClass, void 0, target?.args);
|
|
@@ -22,33 +44,66 @@ function borrowSafe(BlocClass, target) {
|
|
|
22
44
|
* Release a reference to an instance. Instance identity is derived purely from
|
|
23
45
|
* `args` (must match the `args` it was acquired with).
|
|
24
46
|
*
|
|
25
|
-
* @param opts
|
|
26
|
-
*
|
|
27
|
-
*
|
|
47
|
+
* @param opts - `args` derives the instance key (must match acquire);
|
|
48
|
+
* `refId` picks the ref to drop, otherwise one arbitrary ref goes;
|
|
49
|
+
* `forceDispose` disposes immediately regardless of remaining refs.
|
|
28
50
|
*/
|
|
29
51
|
function release(BlocClass, opts) {
|
|
30
52
|
const registry = getRegistry();
|
|
31
53
|
const key = registry.resolveKey(BlocClass, void 0, opts?.args);
|
|
32
54
|
registry.release(BlocClass, key, opts?.forceDispose ?? false, opts?.refId);
|
|
33
55
|
}
|
|
56
|
+
//#endregion
|
|
57
|
+
//#region src/registry/queries.ts
|
|
34
58
|
/**
|
|
35
|
-
*
|
|
36
|
-
|
|
37
|
-
|
|
38
|
-
|
|
39
|
-
|
|
40
|
-
|
|
41
|
-
|
|
42
|
-
|
|
43
|
-
*
|
|
44
|
-
|
|
59
|
+
* @public
|
|
60
|
+
*/
|
|
61
|
+
function hasInstance(BlocClass, opts) {
|
|
62
|
+
const registry = getRegistry();
|
|
63
|
+
const key = registry.resolveKey(BlocClass, void 0, opts?.args);
|
|
64
|
+
return registry.hasInstance(BlocClass, key);
|
|
65
|
+
}
|
|
66
|
+
/**
|
|
67
|
+
* @public
|
|
68
|
+
*/
|
|
69
|
+
function getRefCount(BlocClass, opts) {
|
|
70
|
+
const registry = getRegistry();
|
|
71
|
+
const key = registry.resolveKey(BlocClass, void 0, opts?.args);
|
|
72
|
+
return registry.getRefCount(BlocClass, key);
|
|
73
|
+
}
|
|
74
|
+
/**
|
|
75
|
+
* @public
|
|
45
76
|
*/
|
|
46
|
-
function
|
|
47
|
-
if (!instance) return;
|
|
77
|
+
function getRefIds(BlocClass, opts) {
|
|
48
78
|
const registry = getRegistry();
|
|
49
|
-
const key = registry.
|
|
50
|
-
|
|
51
|
-
|
|
79
|
+
const key = registry.resolveKey(BlocClass, void 0, opts?.args);
|
|
80
|
+
return registry.getRefIds(BlocClass, key);
|
|
81
|
+
}
|
|
82
|
+
/**
|
|
83
|
+
* @public
|
|
84
|
+
*/
|
|
85
|
+
function getAll(BlocClass) {
|
|
86
|
+
return getRegistry().getAll(BlocClass);
|
|
87
|
+
}
|
|
88
|
+
/**
|
|
89
|
+
* @public
|
|
90
|
+
*/
|
|
91
|
+
function forEach(BlocClass, callback) {
|
|
92
|
+
getRegistry().forEach(BlocClass, callback);
|
|
93
|
+
}
|
|
94
|
+
//#endregion
|
|
95
|
+
//#region src/registry/management.ts
|
|
96
|
+
function clear(BlocClass) {
|
|
97
|
+
getRegistry().clear(BlocClass);
|
|
98
|
+
}
|
|
99
|
+
function clearAll() {
|
|
100
|
+
getRegistry().clearAll();
|
|
101
|
+
}
|
|
102
|
+
/**
|
|
103
|
+
* @public
|
|
104
|
+
*/
|
|
105
|
+
function register(BlocClass) {
|
|
106
|
+
getRegistry().register(BlocClass);
|
|
52
107
|
}
|
|
53
108
|
//#endregion
|
|
54
109
|
//#region src/decorators/blac.ts
|
|
@@ -62,6 +117,9 @@ function releaseInstance(instance, opts) {
|
|
|
62
117
|
*
|
|
63
118
|
* @blac({ excludeFromDevTools: true })
|
|
64
119
|
* class InternalBloc extends Cubit<InternalState> {}
|
|
120
|
+
*
|
|
121
|
+
* @blac({ keepAlive: true, key: (args) => args.userId })
|
|
122
|
+
* class UserBloc extends Cubit<UserState> {}
|
|
65
123
|
* ```
|
|
66
124
|
*
|
|
67
125
|
* @example Function syntax (no decorator support needed)
|
|
@@ -73,43 +131,144 @@ function releaseInstance(instance, opts) {
|
|
|
73
131
|
*/
|
|
74
132
|
function blac(options) {
|
|
75
133
|
return function(target, _context) {
|
|
76
|
-
if (
|
|
77
|
-
if (
|
|
78
|
-
if (
|
|
79
|
-
if (
|
|
134
|
+
if (options.keepAlive !== void 0) target[BLAC_STATIC_PROPS.KEEP_ALIVE] = options.keepAlive;
|
|
135
|
+
if (options.excludeFromDevTools) target[BLAC_STATIC_PROPS.EXCLUDE_FROM_DEVTOOLS] = true;
|
|
136
|
+
if (typeof options.equality === "function") target[BLAC_STATIC_PROPS.EQUALITY] = options.equality;
|
|
137
|
+
if (typeof options.key === "function") target[BLAC_STATIC_PROPS.KEY] = options.key;
|
|
138
|
+
if (typeof options.name === "string") target[BLAC_STATIC_PROPS.BLAC_NAME] = options.name;
|
|
80
139
|
return target;
|
|
81
140
|
};
|
|
82
141
|
}
|
|
83
142
|
//#endregion
|
|
84
|
-
//#region src/watch/
|
|
143
|
+
//#region src/watch/watch.ts
|
|
144
|
+
const STOP = Symbol("watch.STOP");
|
|
145
|
+
const BLOC_REF_MARKER = Symbol("BlocRef");
|
|
85
146
|
/**
|
|
86
|
-
*
|
|
87
|
-
*
|
|
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.
|
|
147
|
+
* Create a reference to a specific bloc instance, identified by its `args`.
|
|
148
|
+
* The key is derived the same way `useBloc`/`acquire` derive it.
|
|
92
149
|
*
|
|
93
|
-
*
|
|
94
|
-
*
|
|
150
|
+
* @example
|
|
151
|
+
* ```ts
|
|
152
|
+
* watch(instance(UserBloc, { userId: 'user-123' }), (userBloc) => {
|
|
153
|
+
* console.log(userBloc.state.name);
|
|
154
|
+
* });
|
|
155
|
+
* ```
|
|
156
|
+
*/
|
|
157
|
+
function instance(BlocClass, args) {
|
|
158
|
+
return {
|
|
159
|
+
[BLOC_REF_MARKER]: true,
|
|
160
|
+
blocClass: BlocClass,
|
|
161
|
+
instanceId: resolveInstanceKey(BlocClass, args),
|
|
162
|
+
args
|
|
163
|
+
};
|
|
164
|
+
}
|
|
165
|
+
function isBlocRef(input) {
|
|
166
|
+
return typeof input === "object" && input !== null && BLOC_REF_MARKER in input;
|
|
167
|
+
}
|
|
168
|
+
function toWatchTarget(registry, input) {
|
|
169
|
+
if (isBlocRef(input)) return {
|
|
170
|
+
blocClass: input.blocClass,
|
|
171
|
+
key: input.instanceId,
|
|
172
|
+
args: input.args
|
|
173
|
+
};
|
|
174
|
+
return {
|
|
175
|
+
blocClass: input,
|
|
176
|
+
key: registry.resolveKey(input, void 0, void 0),
|
|
177
|
+
args: void 0
|
|
178
|
+
};
|
|
179
|
+
}
|
|
180
|
+
let watchRefSeq = 0;
|
|
181
|
+
/**
|
|
182
|
+
* Acquire a real ref (countRef: true) for the target, carrying its `args`
|
|
183
|
+
* through so a not-yet-created instance is initialized correctly. The
|
|
184
|
+
* caller is responsible for releasing `refId` in cleanup.
|
|
95
185
|
*/
|
|
96
|
-
function
|
|
97
|
-
|
|
98
|
-
|
|
99
|
-
|
|
100
|
-
|
|
101
|
-
listener(instance.state);
|
|
186
|
+
function resolveBloc(registry, target, refId) {
|
|
187
|
+
return registry.acquire(target.blocClass, target.key, {
|
|
188
|
+
countRef: true,
|
|
189
|
+
refId,
|
|
190
|
+
args: target.args
|
|
102
191
|
});
|
|
103
|
-
|
|
104
|
-
|
|
105
|
-
|
|
106
|
-
|
|
107
|
-
|
|
192
|
+
}
|
|
193
|
+
/**
|
|
194
|
+
* Passive lookup for `{ create: false }`: never creates the instance and
|
|
195
|
+
* never takes a ref. Returns `undefined` when no instance currently exists.
|
|
196
|
+
*/
|
|
197
|
+
function resolveBlocPassive(registry, target) {
|
|
198
|
+
try {
|
|
199
|
+
return registry.acquire(target.blocClass, target.key, {
|
|
200
|
+
canCreate: false,
|
|
201
|
+
countRef: false,
|
|
202
|
+
args: target.args
|
|
203
|
+
});
|
|
204
|
+
} catch {
|
|
205
|
+
return;
|
|
108
206
|
}
|
|
109
|
-
|
|
110
|
-
|
|
207
|
+
}
|
|
208
|
+
function isArray(input) {
|
|
209
|
+
return Array.isArray(input);
|
|
210
|
+
}
|
|
211
|
+
function watchImpl(blocsOrBloc, callback, options) {
|
|
212
|
+
const isSingle = !isArray(blocsOrBloc);
|
|
213
|
+
const inputs = isSingle ? [blocsOrBloc] : blocsOrBloc;
|
|
214
|
+
const registry = getRegistry();
|
|
215
|
+
const create = options?.create ?? true;
|
|
216
|
+
const targets = inputs.map((input) => toWatchTarget(registry, input));
|
|
217
|
+
const refIds = targets.map(() => `_watch_${watchRefSeq++}`);
|
|
218
|
+
const resolveAt = (index) => create ? resolveBloc(registry, targets[index], refIds[index]) : resolveBlocPassive(registry, targets[index]);
|
|
219
|
+
let disposed = false;
|
|
220
|
+
const instances = [];
|
|
221
|
+
const channelUnsubs = [];
|
|
222
|
+
const disposedUnsubs = [];
|
|
223
|
+
const cleanup = () => {
|
|
224
|
+
if (disposed) return;
|
|
225
|
+
disposed = true;
|
|
226
|
+
for (const unsub of channelUnsubs) unsub?.();
|
|
227
|
+
for (const unsub of disposedUnsubs) unsub?.();
|
|
228
|
+
channelUnsubs.length = 0;
|
|
229
|
+
disposedUnsubs.length = 0;
|
|
230
|
+
if (create) for (let i = 0; i < instances.length; i++) registry.release(targets[i].blocClass, targets[i].key, false, refIds[i]);
|
|
231
|
+
};
|
|
232
|
+
const runCallback = () => {
|
|
233
|
+
if (disposed) return;
|
|
234
|
+
if (instances.some((i) => i === void 0)) return;
|
|
235
|
+
if (callback(isSingle ? instances[0] : instances) === STOP) cleanup();
|
|
236
|
+
};
|
|
237
|
+
const subscribeAt = (index) => {
|
|
238
|
+
channelUnsubs[index] = instances[index]?.channel.subscribe(() => ALL_PATHS$1, runCallback);
|
|
239
|
+
};
|
|
240
|
+
const resubscribeAt = (index) => {
|
|
241
|
+
if (disposed) return;
|
|
242
|
+
instances[index] = resolveAt(index);
|
|
243
|
+
subscribeAt(index);
|
|
244
|
+
subscribeDisposeAt(index);
|
|
245
|
+
runCallback();
|
|
246
|
+
};
|
|
247
|
+
const subscribeDisposeAt = (index) => {
|
|
248
|
+
disposedUnsubs[index] = instances[index]?.[ON_DISPOSE](() => {
|
|
249
|
+
channelUnsubs[index]?.();
|
|
250
|
+
channelUnsubs[index] = void 0;
|
|
251
|
+
queueMicrotask(() => resubscribeAt(index));
|
|
252
|
+
});
|
|
253
|
+
};
|
|
254
|
+
try {
|
|
255
|
+
for (let i = 0; i < targets.length; i++) instances.push(resolveAt(i));
|
|
256
|
+
for (let i = 0; i < instances.length; i++) subscribeAt(i);
|
|
257
|
+
for (let i = 0; i < instances.length; i++) subscribeDisposeAt(i);
|
|
258
|
+
runCallback();
|
|
259
|
+
} catch (error) {
|
|
260
|
+
cleanup();
|
|
261
|
+
throw error;
|
|
262
|
+
}
|
|
263
|
+
return cleanup;
|
|
264
|
+
}
|
|
265
|
+
const watch = Object.assign(watchImpl, { STOP });
|
|
266
|
+
//#endregion
|
|
267
|
+
//#region src/types/branded.ts
|
|
268
|
+
function instanceId(id) {
|
|
269
|
+
return id;
|
|
111
270
|
}
|
|
112
271
|
//#endregion
|
|
113
|
-
export { ALL_PATHS,
|
|
272
|
+
export { ALL_PATHS, Cubit, StateContainer, StateContainerRegistry, acquire, blac, borrow, borrowSafe, clear, clearAll, configureBlac, ensure, forEach, getAll, getBlacConfig, getBlacName, getRefCount, getRefIds, getRegistry, getStats, globalRegistry, hasInstance, instance, instanceId, isExcludedFromDevTools, isKeepAliveClass, register, release, resetBlacConfig, resolveInstanceKey, setRegistry, shallowEqualState, watch };
|
|
114
273
|
|
|
115
274
|
//# 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/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 { 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 { 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\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 /** 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.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\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\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 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 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-DjQQtlCW.cjs");
|
|
3
|
+
const require_StateContainer = require("./StateContainer-BUyuxKb3.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';
|
package/dist/internal.js
ADDED
|
@@ -0,0 +1,3 @@
|
|
|
1
|
+
import { a as INSERT_INSTANCE, i as INIT_CONFIG, l as WITH_TRACKED_STATE, o as ON_DISPOSE, r as APPLY_DEPS, s as REMOVE_DEPS_OWNER } from "./StateContainerRegistry-gQbEutkN.js";
|
|
2
|
+
import { t as DEP_BRAND } from "./StateContainer-Bh2ipNYj.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
|
-
*
|
|
23
|
-
*
|
|
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
|
-
*
|
|
57
|
-
*
|
|
58
|
-
* and
|
|
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;
|
|
@@ -99,6 +83,20 @@ export interface BlacPlugin {
|
|
|
99
83
|
* Fires when a container's hydration status transitions.
|
|
100
84
|
*/
|
|
101
85
|
onHydrationChange?(ctx: PluginContext, status: HydrationStatus, previousStatus: HydrationStatus): void;
|
|
86
|
+
/**
|
|
87
|
+
* Fires on the same 0↔1 ownership transition that drives the container's
|
|
88
|
+
* own `onActivate`, after that hook has already run. `signal` aborts on the
|
|
89
|
+
* matching `onDeactivate` and on dispose — dispose does NOT fire
|
|
90
|
+
* `onDeactivate` (or this hook), matching `StateContainer`'s single
|
|
91
|
+
* teardown path.
|
|
92
|
+
*/
|
|
93
|
+
onActivate?(ctx: PluginContext, signal: AbortSignal): void;
|
|
94
|
+
/**
|
|
95
|
+
* Fires when an active container goes back to unowned while surviving in
|
|
96
|
+
* the registry (i.e. `keepAlive`), after the container's own `onDeactivate`
|
|
97
|
+
* has already run. Not fired on dispose.
|
|
98
|
+
*/
|
|
99
|
+
onDeactivate?(ctx: PluginContext): void;
|
|
102
100
|
/**
|
|
103
101
|
* @internal Devtools-only — fires when a named ref is acquired.
|
|
104
102
|
* Not part of the state-change event payload.
|