@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/testing.cjs
CHANGED
|
@@ -1,8 +1,7 @@
|
|
|
1
1
|
Object.defineProperty(exports, Symbol.toStringTag, { value: "Module" });
|
|
2
|
-
const require_StateContainerRegistry = require("./StateContainerRegistry-
|
|
3
|
-
const
|
|
4
|
-
const
|
|
5
|
-
const require_acquire = require("./acquire-CkgLJ8WL.cjs");
|
|
2
|
+
const require_StateContainerRegistry = require("./StateContainerRegistry-DjQQtlCW.cjs");
|
|
3
|
+
const require_StateContainer = require("./StateContainer-BUyuxKb3.cjs");
|
|
4
|
+
const require_ensure = require("./ensure-DBnuRJ0R.cjs");
|
|
6
5
|
//#region src/testing.ts
|
|
7
6
|
/** Synthetic owner id used by test helpers for pre-wired deps. */
|
|
8
7
|
const TESTING_DEPS_OWNER = "testing-deps";
|
|
@@ -10,39 +9,42 @@ function createTestRegistry() {
|
|
|
10
9
|
return new require_StateContainerRegistry.StateContainerRegistry();
|
|
11
10
|
}
|
|
12
11
|
function withTestRegistry(fn) {
|
|
13
|
-
const previous =
|
|
12
|
+
const previous = require_StateContainer.getRegistry();
|
|
14
13
|
const testRegistry = createTestRegistry();
|
|
15
|
-
|
|
14
|
+
require_StateContainer.setRegistry(testRegistry);
|
|
16
15
|
try {
|
|
17
16
|
const result = fn(testRegistry);
|
|
18
17
|
if (result instanceof Promise) return result.then((value) => {
|
|
19
|
-
|
|
18
|
+
require_StateContainer.setRegistry(previous);
|
|
20
19
|
return value;
|
|
21
20
|
}, (error) => {
|
|
22
|
-
|
|
21
|
+
require_StateContainer.setRegistry(previous);
|
|
23
22
|
throw error;
|
|
24
23
|
});
|
|
25
|
-
|
|
24
|
+
require_StateContainer.setRegistry(previous);
|
|
26
25
|
return result;
|
|
27
26
|
} catch (error) {
|
|
28
|
-
|
|
27
|
+
require_StateContainer.setRegistry(previous);
|
|
29
28
|
throw error;
|
|
30
29
|
}
|
|
31
30
|
}
|
|
32
31
|
function blacTestSetup() {
|
|
33
32
|
let savedRegistry;
|
|
33
|
+
let testRegistry;
|
|
34
34
|
beforeEach(() => {
|
|
35
|
-
savedRegistry =
|
|
36
|
-
|
|
35
|
+
savedRegistry = require_StateContainer.getRegistry();
|
|
36
|
+
testRegistry = createTestRegistry();
|
|
37
|
+
require_StateContainer.setRegistry(testRegistry);
|
|
37
38
|
});
|
|
38
39
|
afterEach(() => {
|
|
39
|
-
|
|
40
|
+
testRegistry.clearAll();
|
|
41
|
+
require_StateContainer.setRegistry(savedRegistry);
|
|
40
42
|
});
|
|
41
43
|
}
|
|
42
44
|
function registerOverride(BlocClass, instance, args) {
|
|
43
|
-
const registry =
|
|
44
|
-
const key =
|
|
45
|
-
registry.
|
|
45
|
+
const registry = require_StateContainer.getRegistry();
|
|
46
|
+
const key = require_ensure.resolveInstanceKey(BlocClass, args);
|
|
47
|
+
registry[require_StateContainerRegistry.INSERT_INSTANCE](BlocClass, key, instance, new Map([["testing-override", 1]]));
|
|
46
48
|
}
|
|
47
49
|
function overrideEnsure(BlocClass, instance, fn, args) {
|
|
48
50
|
return withTestRegistry(() => {
|
|
@@ -52,14 +54,8 @@ function overrideEnsure(BlocClass, instance, fn, args) {
|
|
|
52
54
|
}
|
|
53
55
|
function createCubitStub(BlocClass, options) {
|
|
54
56
|
const instance = new BlocClass();
|
|
55
|
-
|
|
56
|
-
if (options?.state != null)
|
|
57
|
-
if (instance instanceof require_ensure.Cubit) {
|
|
58
|
-
const currentState = instance.state;
|
|
59
|
-
if (typeof currentState === "object" && currentState !== null && typeof options.state === "object" && options.state !== null) instance.patch(options.state);
|
|
60
|
-
else instance.emit(options.state);
|
|
61
|
-
}
|
|
62
|
-
}
|
|
57
|
+
instance[require_StateContainerRegistry.INIT_CONFIG]({ args: options?.args });
|
|
58
|
+
if (options?.state != null) applyState(instance, options.state);
|
|
63
59
|
if (options?.methods) {
|
|
64
60
|
for (const [key, impl] of Object.entries(options.methods)) if (typeof impl === "function") instance[key] = impl;
|
|
65
61
|
}
|
|
@@ -68,31 +64,35 @@ function createCubitStub(BlocClass, options) {
|
|
|
68
64
|
}
|
|
69
65
|
function withBlocState(BlocClass, state, args) {
|
|
70
66
|
const instance = require_ensure.ensure(BlocClass, { args });
|
|
71
|
-
|
|
72
|
-
const currentState = instance.state;
|
|
73
|
-
if (typeof currentState === "object" && currentState !== null && typeof state === "object" && state !== null) instance.patch(state);
|
|
74
|
-
else instance.emit(state);
|
|
75
|
-
}
|
|
67
|
+
applyState(instance, state);
|
|
76
68
|
return instance;
|
|
77
69
|
}
|
|
70
|
+
function applyState(instance, state) {
|
|
71
|
+
const target = instance;
|
|
72
|
+
if (typeof target.state === "object" && target.state !== null && typeof state === "object" && state !== null) target.patch(state);
|
|
73
|
+
else target.emit(state);
|
|
74
|
+
}
|
|
78
75
|
function withBlocMethod(BlocClass, methodName, impl, args) {
|
|
79
76
|
const instance = require_ensure.ensure(BlocClass, { args });
|
|
80
77
|
instance[methodName] = impl;
|
|
81
78
|
return instance;
|
|
82
79
|
}
|
|
83
80
|
/**
|
|
84
|
-
* Drain pending microtasks so
|
|
85
|
-
*
|
|
86
|
-
*
|
|
87
|
-
*
|
|
88
|
-
* The default `MicrotaskScheduler` coalesces emits within a tick; tests
|
|
89
|
-
* that emit and then assert on subscriber side-effects need `await flush()`
|
|
90
|
-
* between the two.
|
|
81
|
+
* Drain pending microtasks so channel-flushed effects (subscribers,
|
|
82
|
+
* `onSystemEvent('stateChanged')` handlers, plugin hooks) run before the
|
|
83
|
+
* next assertion. A subscriber can emit again, so this keeps draining until
|
|
84
|
+
* a round passes with no new state change.
|
|
91
85
|
*/
|
|
92
86
|
async function flush() {
|
|
93
|
-
|
|
94
|
-
|
|
87
|
+
for (let i = 0; i < MAX_FLUSH_ROUNDS; i++) {
|
|
88
|
+
const before = require_StateContainer.getStateChangeCount();
|
|
89
|
+
await Promise.resolve();
|
|
90
|
+
await Promise.resolve();
|
|
91
|
+
if (require_StateContainer.getStateChangeCount() === before) return;
|
|
92
|
+
}
|
|
93
|
+
throw new Error(`[blac] flush(): state was still changing after ${MAX_FLUSH_ROUNDS} rounds`);
|
|
95
94
|
}
|
|
95
|
+
const MAX_FLUSH_ROUNDS = 100;
|
|
96
96
|
//#endregion
|
|
97
97
|
exports.blacTestSetup = blacTestSetup;
|
|
98
98
|
exports.createCubitStub = createCubitStub;
|
package/dist/testing.cjs.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"testing.cjs","names":["StateContainerRegistry","getRegistry","resolveInstanceKey","
|
|
1
|
+
{"version":3,"file":"testing.cjs","names":["StateContainerRegistry","getRegistry","resolveInstanceKey","INSERT_INSTANCE","INIT_CONFIG","APPLY_DEPS","ensure","getStateChangeCount"],"sources":["../src/testing.ts"],"sourcesContent":["import type { Cubit } from './core/Cubit';\nimport { getStateChangeCount } from './core/StateContainer';\nimport { StateContainerRegistry } from './core/StateContainerRegistry';\nimport { APPLY_DEPS, INIT_CONFIG, INSERT_INSTANCE } from './core/symbols';\nimport { ensure, getRegistry, setRegistry } from './registry';\nimport { resolveInstanceKey } from './registry/acquire';\nimport type {\n ExtractArgs,\n ExtractDeps,\n ExtractState,\n StateContainerConstructor,\n} from './types/utilities';\n\n/** Synthetic owner id used by test helpers for pre-wired deps. */\nconst TESTING_DEPS_OWNER = 'testing-deps';\n\ndeclare const beforeEach: (fn: () => void) => void;\ndeclare const afterEach: (fn: () => void) => void;\n\nexport function createTestRegistry(): StateContainerRegistry {\n return new StateContainerRegistry();\n}\n\nexport function withTestRegistry<T>(\n fn: (registry: StateContainerRegistry) => T,\n): T {\n const previous = getRegistry();\n const testRegistry = createTestRegistry();\n setRegistry(testRegistry);\n try {\n const result = fn(testRegistry);\n if (result instanceof Promise) {\n return result.then(\n (value) => {\n setRegistry(previous);\n return value;\n },\n (error) => {\n setRegistry(previous);\n throw error;\n },\n ) as T;\n }\n setRegistry(previous);\n return result;\n } catch (error) {\n setRegistry(previous);\n throw error;\n }\n}\n\nexport function blacTestSetup(): void {\n let savedRegistry: StateContainerRegistry;\n let testRegistry: StateContainerRegistry;\n beforeEach(() => {\n savedRegistry = getRegistry();\n testRegistry = createTestRegistry();\n setRegistry(testRegistry);\n });\n afterEach(() => {\n testRegistry.clearAll();\n setRegistry(savedRegistry);\n });\n}\n\nexport function registerOverride<T extends StateContainerConstructor>(\n BlocClass: T,\n instance: InstanceType<T>,\n args?: ExtractArgs<T>,\n): void {\n const registry = getRegistry();\n const key = resolveInstanceKey(BlocClass, args);\n registry[INSERT_INSTANCE](\n BlocClass,\n key,\n instance,\n new Map([['testing-override', 1]]),\n );\n}\n\nexport function overrideEnsure<T extends StateContainerConstructor, R>(\n BlocClass: T,\n instance: InstanceType<T>,\n fn: () => R,\n args?: ExtractArgs<T>,\n): R {\n return withTestRegistry(() => {\n registerOverride(BlocClass, instance, args);\n return fn();\n });\n}\n\ntype MethodKeys<T> = {\n [K in keyof T]: T[K] extends (...args: any[]) => any ? K : never;\n}[keyof T];\n\nexport interface CubitStubOptions<T extends StateContainerConstructor> {\n state?: ExtractState<T> extends Record<string, any>\n ? Partial<ExtractState<T>>\n : ExtractState<T>;\n methods?: Partial<\n Record<MethodKeys<InstanceType<T>>, (...args: any[]) => any>\n >;\n /** Args passed to init(). */\n args?: ExtractArgs<T> extends void ? never : ExtractArgs<T>;\n /**\n * Deps slice to pre-wire via the core [APPLY_DEPS] path (synthetic owner\n * \"testing-deps\"), so onDepsChanged fires during tests.\n */\n deps?: Partial<ExtractDeps<T>>;\n}\n\nexport function createCubitStub<T extends StateContainerConstructor>(\n BlocClass: T,\n options?: CubitStubOptions<T>,\n): InstanceType<T> {\n const instance = new BlocClass() as InstanceType<T>;\n instance[INIT_CONFIG]({ args: options?.args });\n\n if (options?.state != null) {\n applyState(instance, options.state);\n }\n if (options?.methods) {\n for (const [key, impl] of Object.entries(options.methods)) {\n if (typeof impl === 'function') {\n (instance as any)[key] = impl;\n }\n }\n }\n\n // Pre-wire deps via the core merge path so onDepsChanged fires in tests.\n if (options?.deps != null) {\n (instance as any)[APPLY_DEPS](TESTING_DEPS_OWNER, options.deps);\n }\n\n return instance;\n}\n\nexport function withBlocState<T extends StateContainerConstructor>(\n BlocClass: T,\n state: ExtractState<T> extends Record<string, any>\n ? Partial<ExtractState<T>>\n : ExtractState<T>,\n args?: ExtractArgs<T>,\n): InstanceType<T> {\n const instance = ensure(BlocClass, { args });\n applyState(instance, state);\n return instance;\n}\n\n// emit/patch are protected on StateContainer; Cubit only makes them public.\nfunction applyState(instance: object, state: unknown): void {\n const target = instance as Cubit<any>;\n if (\n typeof target.state === 'object' &&\n target.state !== null &&\n typeof state === 'object' &&\n state !== null\n ) {\n target.patch(state);\n } else {\n target.emit(state as any);\n }\n}\n\nexport function withBlocMethod<T extends StateContainerConstructor>(\n BlocClass: T,\n methodName: keyof InstanceType<T>,\n impl: (...args: any[]) => any,\n args?: ExtractArgs<T>,\n): InstanceType<T> {\n const instance = ensure(BlocClass, { args });\n (instance as any)[methodName] = impl;\n return instance;\n}\n\n/**\n * Drain pending microtasks so channel-flushed effects (subscribers,\n * `onSystemEvent('stateChanged')` handlers, plugin hooks) run before the\n * next assertion. A subscriber can emit again, so this keeps draining until\n * a round passes with no new state change.\n */\nexport async function flush(): Promise<void> {\n for (let i = 0; i < MAX_FLUSH_ROUNDS; i++) {\n const before = getStateChangeCount();\n // The second tick lets microtasks queued by the drain itself (registry\n // `stateChanged` delivery) run too.\n await Promise.resolve();\n await Promise.resolve();\n if (getStateChangeCount() === before) return;\n }\n throw new Error(\n `[blac] flush(): state was still changing after ${MAX_FLUSH_ROUNDS} rounds`,\n );\n}\n\nconst MAX_FLUSH_ROUNDS = 100;\n"],"mappings":";;;;;;AAcA,MAAM,qBAAqB;AAK3B,SAAgB,qBAA6C;CAC3D,OAAO,IAAIA,+BAAAA,uBAAuB;AACpC;AAEA,SAAgB,iBACd,IACG;CACH,MAAM,WAAWC,uBAAAA,YAAY;CAC7B,MAAM,eAAe,mBAAmB;CACxC,uBAAA,YAAY,YAAY;CACxB,IAAI;EACF,MAAM,SAAS,GAAG,YAAY;EAC9B,IAAI,kBAAkB,SACpB,OAAO,OAAO,MACX,UAAU;GACT,uBAAA,YAAY,QAAQ;GACpB,OAAO;EACT,IACC,UAAU;GACT,uBAAA,YAAY,QAAQ;GACpB,MAAM;EACR,CACF;EAEF,uBAAA,YAAY,QAAQ;EACpB,OAAO;CACT,SAAS,OAAO;EACd,uBAAA,YAAY,QAAQ;EACpB,MAAM;CACR;AACF;AAEA,SAAgB,gBAAsB;CACpC,IAAI;CACJ,IAAI;CACJ,iBAAiB;EACf,gBAAgBA,uBAAAA,YAAY;EAC5B,eAAe,mBAAmB;EAClC,uBAAA,YAAY,YAAY;CAC1B,CAAC;CACD,gBAAgB;EACd,aAAa,SAAS;EACtB,uBAAA,YAAY,aAAa;CAC3B,CAAC;AACH;AAEA,SAAgB,iBACd,WACA,UACA,MACM;CACN,MAAM,WAAWA,uBAAAA,YAAY;CAC7B,MAAM,MAAMC,eAAAA,mBAAmB,WAAW,IAAI;CAC9C,SAASC,+BAAAA,iBACP,WACA,KACA,UACA,IAAI,IAAI,CAAC,CAAC,oBAAoB,CAAC,CAAC,CAAC,CACnC;AACF;AAEA,SAAgB,eACd,WACA,UACA,IACA,MACG;CACH,OAAO,uBAAuB;EAC5B,iBAAiB,WAAW,UAAU,IAAI;EAC1C,OAAO,GAAG;CACZ,CAAC;AACH;AAsBA,SAAgB,gBACd,WACA,SACiB;CACjB,MAAM,WAAW,IAAI,UAAU;CAC/B,SAASC,+BAAAA,aAAa,EAAE,MAAM,SAAS,KAAK,CAAC;CAE7C,IAAI,SAAS,SAAS,MACpB,WAAW,UAAU,QAAQ,KAAK;CAEpC,IAAI,SAAS;OACN,MAAM,CAAC,KAAK,SAAS,OAAO,QAAQ,QAAQ,OAAO,GACtD,IAAI,OAAO,SAAS,YAClB,SAAkB,OAAO;CAAA;CAM/B,IAAI,SAAS,QAAQ,MACnB,SAAkBC,+BAAAA,YAAY,oBAAoB,QAAQ,IAAI;CAGhE,OAAO;AACT;AAEA,SAAgB,cACd,WACA,OAGA,MACiB;CACjB,MAAM,WAAWC,eAAAA,OAAO,WAAW,EAAE,KAAK,CAAC;CAC3C,WAAW,UAAU,KAAK;CAC1B,OAAO;AACT;AAGA,SAAS,WAAW,UAAkB,OAAsB;CAC1D,MAAM,SAAS;CACf,IACE,OAAO,OAAO,UAAU,YACxB,OAAO,UAAU,QACjB,OAAO,UAAU,YACjB,UAAU,MAEV,OAAO,MAAM,KAAK;MAElB,OAAO,KAAK,KAAY;AAE5B;AAEA,SAAgB,eACd,WACA,YACA,MACA,MACiB;CACjB,MAAM,WAAWA,eAAAA,OAAO,WAAW,EAAE,KAAK,CAAC;CAC3C,SAAkB,cAAc;CAChC,OAAO;AACT;;;;;;;AAQA,eAAsB,QAAuB;CAC3C,KAAK,IAAI,IAAI,GAAG,IAAI,kBAAkB,KAAK;EACzC,MAAM,SAASC,uBAAAA,oBAAoB;EAGnC,MAAM,QAAQ,QAAQ;EACtB,MAAM,QAAQ,QAAQ;EACtB,IAAIA,uBAAAA,oBAAoB,MAAM,QAAQ;CACxC;CACA,MAAM,IAAI,MACR,kDAAkD,iBAAiB,QACrE;AACF;AAEA,MAAM,mBAAmB"}
|
package/dist/testing.d.cts
CHANGED
|
@@ -11,10 +11,7 @@ type MethodKeys<T> = {
|
|
|
11
11
|
export interface CubitStubOptions<T extends StateContainerConstructor> {
|
|
12
12
|
state?: ExtractState<T> extends Record<string, any> ? Partial<ExtractState<T>> : ExtractState<T>;
|
|
13
13
|
methods?: Partial<Record<MethodKeys<InstanceType<T>>, (...args: any[]) => any>>;
|
|
14
|
-
/**
|
|
15
|
-
* Args to pass to init(). If the bloc's Args type is not void, supplying
|
|
16
|
-
* args here causes initConfig({ args }) to be called so init() runs.
|
|
17
|
-
*/
|
|
14
|
+
/** Args passed to init(). */
|
|
18
15
|
args?: ExtractArgs<T> extends void ? never : ExtractArgs<T>;
|
|
19
16
|
/**
|
|
20
17
|
* Deps slice to pre-wire via the core [APPLY_DEPS] path (synthetic owner
|
|
@@ -26,13 +23,10 @@ export declare function createCubitStub<T extends StateContainerConstructor>(Blo
|
|
|
26
23
|
export declare function withBlocState<T extends StateContainerConstructor>(BlocClass: T, state: ExtractState<T> extends Record<string, any> ? Partial<ExtractState<T>> : ExtractState<T>, args?: ExtractArgs<T>): InstanceType<T>;
|
|
27
24
|
export declare function withBlocMethod<T extends StateContainerConstructor>(BlocClass: T, methodName: keyof InstanceType<T>, impl: (...args: any[]) => any, args?: ExtractArgs<T>): InstanceType<T>;
|
|
28
25
|
/**
|
|
29
|
-
* Drain pending microtasks so
|
|
30
|
-
*
|
|
31
|
-
*
|
|
32
|
-
*
|
|
33
|
-
* The default `MicrotaskScheduler` coalesces emits within a tick; tests
|
|
34
|
-
* that emit and then assert on subscriber side-effects need `await flush()`
|
|
35
|
-
* between the two.
|
|
26
|
+
* Drain pending microtasks so channel-flushed effects (subscribers,
|
|
27
|
+
* `onSystemEvent('stateChanged')` handlers, plugin hooks) run before the
|
|
28
|
+
* next assertion. A subscriber can emit again, so this keeps draining until
|
|
29
|
+
* a round passes with no new state change.
|
|
36
30
|
*/
|
|
37
31
|
export declare function flush(): Promise<void>;
|
|
38
32
|
export {};
|
package/dist/testing.d.ts
CHANGED
|
@@ -11,10 +11,7 @@ type MethodKeys<T> = {
|
|
|
11
11
|
export interface CubitStubOptions<T extends StateContainerConstructor> {
|
|
12
12
|
state?: ExtractState<T> extends Record<string, any> ? Partial<ExtractState<T>> : ExtractState<T>;
|
|
13
13
|
methods?: Partial<Record<MethodKeys<InstanceType<T>>, (...args: any[]) => any>>;
|
|
14
|
-
/**
|
|
15
|
-
* Args to pass to init(). If the bloc's Args type is not void, supplying
|
|
16
|
-
* args here causes initConfig({ args }) to be called so init() runs.
|
|
17
|
-
*/
|
|
14
|
+
/** Args passed to init(). */
|
|
18
15
|
args?: ExtractArgs<T> extends void ? never : ExtractArgs<T>;
|
|
19
16
|
/**
|
|
20
17
|
* Deps slice to pre-wire via the core [APPLY_DEPS] path (synthetic owner
|
|
@@ -26,13 +23,10 @@ export declare function createCubitStub<T extends StateContainerConstructor>(Blo
|
|
|
26
23
|
export declare function withBlocState<T extends StateContainerConstructor>(BlocClass: T, state: ExtractState<T> extends Record<string, any> ? Partial<ExtractState<T>> : ExtractState<T>, args?: ExtractArgs<T>): InstanceType<T>;
|
|
27
24
|
export declare function withBlocMethod<T extends StateContainerConstructor>(BlocClass: T, methodName: keyof InstanceType<T>, impl: (...args: any[]) => any, args?: ExtractArgs<T>): InstanceType<T>;
|
|
28
25
|
/**
|
|
29
|
-
* Drain pending microtasks so
|
|
30
|
-
*
|
|
31
|
-
*
|
|
32
|
-
*
|
|
33
|
-
* The default `MicrotaskScheduler` coalesces emits within a tick; tests
|
|
34
|
-
* that emit and then assert on subscriber side-effects need `await flush()`
|
|
35
|
-
* between the two.
|
|
26
|
+
* Drain pending microtasks so channel-flushed effects (subscribers,
|
|
27
|
+
* `onSystemEvent('stateChanged')` handlers, plugin hooks) run before the
|
|
28
|
+
* next assertion. A subscriber can emit again, so this keeps draining until
|
|
29
|
+
* a round passes with no new state change.
|
|
36
30
|
*/
|
|
37
31
|
export declare function flush(): Promise<void>;
|
|
38
32
|
export {};
|
package/dist/testing.js
CHANGED
|
@@ -1,7 +1,6 @@
|
|
|
1
|
-
import { a as
|
|
2
|
-
import {
|
|
3
|
-
import { r as
|
|
4
|
-
import { n as resolveInstanceKey } from "./acquire-CU0u8BMn.js";
|
|
1
|
+
import { a as INSERT_INSTANCE, i as INIT_CONFIG, r as APPLY_DEPS, t as StateContainerRegistry } from "./StateContainerRegistry-gQbEutkN.js";
|
|
2
|
+
import { i as getRegistry, o as setRegistry, r as getStateChangeCount } from "./StateContainer-Bh2ipNYj.js";
|
|
3
|
+
import { r as resolveInstanceKey, t as ensure } from "./ensure-Bi_yXk6f.js";
|
|
5
4
|
//#region src/testing.ts
|
|
6
5
|
/** Synthetic owner id used by test helpers for pre-wired deps. */
|
|
7
6
|
const TESTING_DEPS_OWNER = "testing-deps";
|
|
@@ -30,18 +29,21 @@ function withTestRegistry(fn) {
|
|
|
30
29
|
}
|
|
31
30
|
function blacTestSetup() {
|
|
32
31
|
let savedRegistry;
|
|
32
|
+
let testRegistry;
|
|
33
33
|
beforeEach(() => {
|
|
34
34
|
savedRegistry = getRegistry();
|
|
35
|
-
|
|
35
|
+
testRegistry = createTestRegistry();
|
|
36
|
+
setRegistry(testRegistry);
|
|
36
37
|
});
|
|
37
38
|
afterEach(() => {
|
|
39
|
+
testRegistry.clearAll();
|
|
38
40
|
setRegistry(savedRegistry);
|
|
39
41
|
});
|
|
40
42
|
}
|
|
41
43
|
function registerOverride(BlocClass, instance, args) {
|
|
42
44
|
const registry = getRegistry();
|
|
43
45
|
const key = resolveInstanceKey(BlocClass, args);
|
|
44
|
-
registry
|
|
46
|
+
registry[INSERT_INSTANCE](BlocClass, key, instance, new Map([["testing-override", 1]]));
|
|
45
47
|
}
|
|
46
48
|
function overrideEnsure(BlocClass, instance, fn, args) {
|
|
47
49
|
return withTestRegistry(() => {
|
|
@@ -51,14 +53,8 @@ function overrideEnsure(BlocClass, instance, fn, args) {
|
|
|
51
53
|
}
|
|
52
54
|
function createCubitStub(BlocClass, options) {
|
|
53
55
|
const instance = new BlocClass();
|
|
54
|
-
|
|
55
|
-
if (options?.state != null)
|
|
56
|
-
if (instance instanceof Cubit) {
|
|
57
|
-
const currentState = instance.state;
|
|
58
|
-
if (typeof currentState === "object" && currentState !== null && typeof options.state === "object" && options.state !== null) instance.patch(options.state);
|
|
59
|
-
else instance.emit(options.state);
|
|
60
|
-
}
|
|
61
|
-
}
|
|
56
|
+
instance[INIT_CONFIG]({ args: options?.args });
|
|
57
|
+
if (options?.state != null) applyState(instance, options.state);
|
|
62
58
|
if (options?.methods) {
|
|
63
59
|
for (const [key, impl] of Object.entries(options.methods)) if (typeof impl === "function") instance[key] = impl;
|
|
64
60
|
}
|
|
@@ -67,31 +63,35 @@ function createCubitStub(BlocClass, options) {
|
|
|
67
63
|
}
|
|
68
64
|
function withBlocState(BlocClass, state, args) {
|
|
69
65
|
const instance = ensure(BlocClass, { args });
|
|
70
|
-
|
|
71
|
-
const currentState = instance.state;
|
|
72
|
-
if (typeof currentState === "object" && currentState !== null && typeof state === "object" && state !== null) instance.patch(state);
|
|
73
|
-
else instance.emit(state);
|
|
74
|
-
}
|
|
66
|
+
applyState(instance, state);
|
|
75
67
|
return instance;
|
|
76
68
|
}
|
|
69
|
+
function applyState(instance, state) {
|
|
70
|
+
const target = instance;
|
|
71
|
+
if (typeof target.state === "object" && target.state !== null && typeof state === "object" && state !== null) target.patch(state);
|
|
72
|
+
else target.emit(state);
|
|
73
|
+
}
|
|
77
74
|
function withBlocMethod(BlocClass, methodName, impl, args) {
|
|
78
75
|
const instance = ensure(BlocClass, { args });
|
|
79
76
|
instance[methodName] = impl;
|
|
80
77
|
return instance;
|
|
81
78
|
}
|
|
82
79
|
/**
|
|
83
|
-
* Drain pending microtasks so
|
|
84
|
-
*
|
|
85
|
-
*
|
|
86
|
-
*
|
|
87
|
-
* The default `MicrotaskScheduler` coalesces emits within a tick; tests
|
|
88
|
-
* that emit and then assert on subscriber side-effects need `await flush()`
|
|
89
|
-
* between the two.
|
|
80
|
+
* Drain pending microtasks so channel-flushed effects (subscribers,
|
|
81
|
+
* `onSystemEvent('stateChanged')` handlers, plugin hooks) run before the
|
|
82
|
+
* next assertion. A subscriber can emit again, so this keeps draining until
|
|
83
|
+
* a round passes with no new state change.
|
|
90
84
|
*/
|
|
91
85
|
async function flush() {
|
|
92
|
-
|
|
93
|
-
|
|
86
|
+
for (let i = 0; i < MAX_FLUSH_ROUNDS; i++) {
|
|
87
|
+
const before = getStateChangeCount();
|
|
88
|
+
await Promise.resolve();
|
|
89
|
+
await Promise.resolve();
|
|
90
|
+
if (getStateChangeCount() === before) return;
|
|
91
|
+
}
|
|
92
|
+
throw new Error(`[blac] flush(): state was still changing after ${MAX_FLUSH_ROUNDS} rounds`);
|
|
94
93
|
}
|
|
94
|
+
const MAX_FLUSH_ROUNDS = 100;
|
|
95
95
|
//#endregion
|
|
96
96
|
export { blacTestSetup, createCubitStub, createTestRegistry, flush, overrideEnsure, registerOverride, withBlocMethod, withBlocState, withTestRegistry };
|
|
97
97
|
|
package/dist/testing.js.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"testing.js","names":[],"sources":["../src/testing.ts"],"sourcesContent":["import { Cubit } from './core/Cubit';\nimport { StateContainerRegistry } from './core/StateContainerRegistry';\nimport { APPLY_DEPS, INIT_CONFIG } from './core/symbols';\nimport { ensure, getRegistry, setRegistry } from './registry';\nimport { resolveInstanceKey } from './registry/acquire';\nimport type {\n ExtractArgs,\n ExtractDeps,\n ExtractState,\n StateContainerConstructor,\n} from './types/utilities';\n\n/** Synthetic owner id used by test helpers for pre-wired deps. */\nconst TESTING_DEPS_OWNER = 'testing-deps';\n\ndeclare const beforeEach: (fn: () => void) => void;\ndeclare const afterEach: (fn: () => void) => void;\n\
|
|
1
|
+
{"version":3,"file":"testing.js","names":[],"sources":["../src/testing.ts"],"sourcesContent":["import type { Cubit } from './core/Cubit';\nimport { getStateChangeCount } from './core/StateContainer';\nimport { StateContainerRegistry } from './core/StateContainerRegistry';\nimport { APPLY_DEPS, INIT_CONFIG, INSERT_INSTANCE } from './core/symbols';\nimport { ensure, getRegistry, setRegistry } from './registry';\nimport { resolveInstanceKey } from './registry/acquire';\nimport type {\n ExtractArgs,\n ExtractDeps,\n ExtractState,\n StateContainerConstructor,\n} from './types/utilities';\n\n/** Synthetic owner id used by test helpers for pre-wired deps. */\nconst TESTING_DEPS_OWNER = 'testing-deps';\n\ndeclare const beforeEach: (fn: () => void) => void;\ndeclare const afterEach: (fn: () => void) => void;\n\nexport function createTestRegistry(): StateContainerRegistry {\n return new StateContainerRegistry();\n}\n\nexport function withTestRegistry<T>(\n fn: (registry: StateContainerRegistry) => T,\n): T {\n const previous = getRegistry();\n const testRegistry = createTestRegistry();\n setRegistry(testRegistry);\n try {\n const result = fn(testRegistry);\n if (result instanceof Promise) {\n return result.then(\n (value) => {\n setRegistry(previous);\n return value;\n },\n (error) => {\n setRegistry(previous);\n throw error;\n },\n ) as T;\n }\n setRegistry(previous);\n return result;\n } catch (error) {\n setRegistry(previous);\n throw error;\n }\n}\n\nexport function blacTestSetup(): void {\n let savedRegistry: StateContainerRegistry;\n let testRegistry: StateContainerRegistry;\n beforeEach(() => {\n savedRegistry = getRegistry();\n testRegistry = createTestRegistry();\n setRegistry(testRegistry);\n });\n afterEach(() => {\n testRegistry.clearAll();\n setRegistry(savedRegistry);\n });\n}\n\nexport function registerOverride<T extends StateContainerConstructor>(\n BlocClass: T,\n instance: InstanceType<T>,\n args?: ExtractArgs<T>,\n): void {\n const registry = getRegistry();\n const key = resolveInstanceKey(BlocClass, args);\n registry[INSERT_INSTANCE](\n BlocClass,\n key,\n instance,\n new Map([['testing-override', 1]]),\n );\n}\n\nexport function overrideEnsure<T extends StateContainerConstructor, R>(\n BlocClass: T,\n instance: InstanceType<T>,\n fn: () => R,\n args?: ExtractArgs<T>,\n): R {\n return withTestRegistry(() => {\n registerOverride(BlocClass, instance, args);\n return fn();\n });\n}\n\ntype MethodKeys<T> = {\n [K in keyof T]: T[K] extends (...args: any[]) => any ? K : never;\n}[keyof T];\n\nexport interface CubitStubOptions<T extends StateContainerConstructor> {\n state?: ExtractState<T> extends Record<string, any>\n ? Partial<ExtractState<T>>\n : ExtractState<T>;\n methods?: Partial<\n Record<MethodKeys<InstanceType<T>>, (...args: any[]) => any>\n >;\n /** Args passed to init(). */\n args?: ExtractArgs<T> extends void ? never : ExtractArgs<T>;\n /**\n * Deps slice to pre-wire via the core [APPLY_DEPS] path (synthetic owner\n * \"testing-deps\"), so onDepsChanged fires during tests.\n */\n deps?: Partial<ExtractDeps<T>>;\n}\n\nexport function createCubitStub<T extends StateContainerConstructor>(\n BlocClass: T,\n options?: CubitStubOptions<T>,\n): InstanceType<T> {\n const instance = new BlocClass() as InstanceType<T>;\n instance[INIT_CONFIG]({ args: options?.args });\n\n if (options?.state != null) {\n applyState(instance, options.state);\n }\n if (options?.methods) {\n for (const [key, impl] of Object.entries(options.methods)) {\n if (typeof impl === 'function') {\n (instance as any)[key] = impl;\n }\n }\n }\n\n // Pre-wire deps via the core merge path so onDepsChanged fires in tests.\n if (options?.deps != null) {\n (instance as any)[APPLY_DEPS](TESTING_DEPS_OWNER, options.deps);\n }\n\n return instance;\n}\n\nexport function withBlocState<T extends StateContainerConstructor>(\n BlocClass: T,\n state: ExtractState<T> extends Record<string, any>\n ? Partial<ExtractState<T>>\n : ExtractState<T>,\n args?: ExtractArgs<T>,\n): InstanceType<T> {\n const instance = ensure(BlocClass, { args });\n applyState(instance, state);\n return instance;\n}\n\n// emit/patch are protected on StateContainer; Cubit only makes them public.\nfunction applyState(instance: object, state: unknown): void {\n const target = instance as Cubit<any>;\n if (\n typeof target.state === 'object' &&\n target.state !== null &&\n typeof state === 'object' &&\n state !== null\n ) {\n target.patch(state);\n } else {\n target.emit(state as any);\n }\n}\n\nexport function withBlocMethod<T extends StateContainerConstructor>(\n BlocClass: T,\n methodName: keyof InstanceType<T>,\n impl: (...args: any[]) => any,\n args?: ExtractArgs<T>,\n): InstanceType<T> {\n const instance = ensure(BlocClass, { args });\n (instance as any)[methodName] = impl;\n return instance;\n}\n\n/**\n * Drain pending microtasks so channel-flushed effects (subscribers,\n * `onSystemEvent('stateChanged')` handlers, plugin hooks) run before the\n * next assertion. A subscriber can emit again, so this keeps draining until\n * a round passes with no new state change.\n */\nexport async function flush(): Promise<void> {\n for (let i = 0; i < MAX_FLUSH_ROUNDS; i++) {\n const before = getStateChangeCount();\n // The second tick lets microtasks queued by the drain itself (registry\n // `stateChanged` delivery) run too.\n await Promise.resolve();\n await Promise.resolve();\n if (getStateChangeCount() === before) return;\n }\n throw new Error(\n `[blac] flush(): state was still changing after ${MAX_FLUSH_ROUNDS} rounds`,\n );\n}\n\nconst MAX_FLUSH_ROUNDS = 100;\n"],"mappings":";;;;;AAcA,MAAM,qBAAqB;AAK3B,SAAgB,qBAA6C;CAC3D,OAAO,IAAI,uBAAuB;AACpC;AAEA,SAAgB,iBACd,IACG;CACH,MAAM,WAAW,YAAY;CAC7B,MAAM,eAAe,mBAAmB;CACxC,YAAY,YAAY;CACxB,IAAI;EACF,MAAM,SAAS,GAAG,YAAY;EAC9B,IAAI,kBAAkB,SACpB,OAAO,OAAO,MACX,UAAU;GACT,YAAY,QAAQ;GACpB,OAAO;EACT,IACC,UAAU;GACT,YAAY,QAAQ;GACpB,MAAM;EACR,CACF;EAEF,YAAY,QAAQ;EACpB,OAAO;CACT,SAAS,OAAO;EACd,YAAY,QAAQ;EACpB,MAAM;CACR;AACF;AAEA,SAAgB,gBAAsB;CACpC,IAAI;CACJ,IAAI;CACJ,iBAAiB;EACf,gBAAgB,YAAY;EAC5B,eAAe,mBAAmB;EAClC,YAAY,YAAY;CAC1B,CAAC;CACD,gBAAgB;EACd,aAAa,SAAS;EACtB,YAAY,aAAa;CAC3B,CAAC;AACH;AAEA,SAAgB,iBACd,WACA,UACA,MACM;CACN,MAAM,WAAW,YAAY;CAC7B,MAAM,MAAM,mBAAmB,WAAW,IAAI;CAC9C,SAAS,iBACP,WACA,KACA,UACA,IAAI,IAAI,CAAC,CAAC,oBAAoB,CAAC,CAAC,CAAC,CACnC;AACF;AAEA,SAAgB,eACd,WACA,UACA,IACA,MACG;CACH,OAAO,uBAAuB;EAC5B,iBAAiB,WAAW,UAAU,IAAI;EAC1C,OAAO,GAAG;CACZ,CAAC;AACH;AAsBA,SAAgB,gBACd,WACA,SACiB;CACjB,MAAM,WAAW,IAAI,UAAU;CAC/B,SAAS,aAAa,EAAE,MAAM,SAAS,KAAK,CAAC;CAE7C,IAAI,SAAS,SAAS,MACpB,WAAW,UAAU,QAAQ,KAAK;CAEpC,IAAI,SAAS;OACN,MAAM,CAAC,KAAK,SAAS,OAAO,QAAQ,QAAQ,OAAO,GACtD,IAAI,OAAO,SAAS,YAClB,SAAkB,OAAO;CAAA;CAM/B,IAAI,SAAS,QAAQ,MACnB,SAAkB,YAAY,oBAAoB,QAAQ,IAAI;CAGhE,OAAO;AACT;AAEA,SAAgB,cACd,WACA,OAGA,MACiB;CACjB,MAAM,WAAW,OAAO,WAAW,EAAE,KAAK,CAAC;CAC3C,WAAW,UAAU,KAAK;CAC1B,OAAO;AACT;AAGA,SAAS,WAAW,UAAkB,OAAsB;CAC1D,MAAM,SAAS;CACf,IACE,OAAO,OAAO,UAAU,YACxB,OAAO,UAAU,QACjB,OAAO,UAAU,YACjB,UAAU,MAEV,OAAO,MAAM,KAAK;MAElB,OAAO,KAAK,KAAY;AAE5B;AAEA,SAAgB,eACd,WACA,YACA,MACA,MACiB;CACjB,MAAM,WAAW,OAAO,WAAW,EAAE,KAAK,CAAC;CAC3C,SAAkB,cAAc;CAChC,OAAO;AACT;;;;;;;AAQA,eAAsB,QAAuB;CAC3C,KAAK,IAAI,IAAI,GAAG,IAAI,kBAAkB,KAAK;EACzC,MAAM,SAAS,oBAAoB;EAGnC,MAAM,QAAQ,QAAQ;EACtB,MAAM,QAAQ,QAAQ;EACtB,IAAI,oBAAoB,MAAM,QAAQ;CACxC;CACA,MAAM,IAAI,MACR,kDAAkD,iBAAiB,QACrE;AACF;AAEA,MAAM,mBAAmB"}
|
package/dist/types/branded.d.ts
CHANGED
|
@@ -1,26 +1,19 @@
|
|
|
1
1
|
declare const brand: unique symbol;
|
|
2
2
|
/**
|
|
3
|
-
*
|
|
4
|
-
*
|
|
5
|
-
* @
|
|
6
|
-
* @
|
|
3
|
+
* Nominal type helper, preventing accidental confusion between similar
|
|
4
|
+
* primitive types.
|
|
5
|
+
* @typeParam T - The base type
|
|
6
|
+
* @typeParam B - The brand identifier
|
|
7
7
|
*/
|
|
8
8
|
export type Brand<T, B> = T & {
|
|
9
9
|
[brand]: B;
|
|
10
10
|
};
|
|
11
11
|
/**
|
|
12
12
|
* Branded string type for type-safe IDs.
|
|
13
|
-
* @
|
|
13
|
+
* @typeParam B - The brand identifier
|
|
14
14
|
*/
|
|
15
15
|
export type BrandedId<B> = Brand<string, B>;
|
|
16
|
-
/**
|
|
17
|
-
* Branded string type for state container instance IDs
|
|
18
|
-
*/
|
|
16
|
+
/** Branded string type for state container instance IDs. */
|
|
19
17
|
export type InstanceId = Brand<string, 'InstanceId'>;
|
|
20
|
-
/**
|
|
21
|
-
* Create a branded InstanceId from a string
|
|
22
|
-
* @param id - The string ID to brand
|
|
23
|
-
* @returns Branded InstanceId
|
|
24
|
-
*/
|
|
25
18
|
export declare function instanceId(id: string): InstanceId;
|
|
26
19
|
export {};
|
|
@@ -1,51 +1,60 @@
|
|
|
1
1
|
import type { StateContainer } from '../core/StateContainer';
|
|
2
2
|
/**
|
|
3
|
-
*
|
|
4
|
-
*
|
|
3
|
+
* Recursively mark all properties readonly. The mirror of
|
|
4
|
+
* `DeepPartial` in `@dirtytalk/structural`, and carves out the same
|
|
5
|
+
* built-ins for the same reason.
|
|
6
|
+
*
|
|
7
|
+
* - Arrays become `ReadonlyArray`, recursing into the element type.
|
|
8
|
+
* - `Map`/`Set` become their `Readonly` counterparts so their contents are
|
|
9
|
+
* frozen too, rather than only the binding.
|
|
10
|
+
* - `Date | RegExp` are kept as-is; mapping over them would freeze their
|
|
11
|
+
* prototype methods instead of their (inaccessible) internal state.
|
|
12
|
+
* - Primitives and functions pass through unchanged.
|
|
13
|
+
*
|
|
14
|
+
* @typeParam T - The type to deeply freeze
|
|
15
|
+
* @public
|
|
5
16
|
*/
|
|
6
|
-
export type
|
|
17
|
+
export type DeepReadonly<T> = T extends (...args: any[]) => any ? T : T extends ReadonlyArray<infer U> ? ReadonlyArray<DeepReadonly<U>> : T extends ReadonlyMap<infer K, infer V> ? ReadonlyMap<DeepReadonly<K>, DeepReadonly<V>> : T extends ReadonlySet<infer U> ? ReadonlySet<DeepReadonly<U>> : T extends Date | RegExp ? T : T extends object ? {
|
|
18
|
+
readonly [K in keyof T]: DeepReadonly<T[K]>;
|
|
19
|
+
} : T;
|
|
20
|
+
/**
|
|
21
|
+
* Extract the state type from a StateContainer, deeply readonly.
|
|
22
|
+
*
|
|
23
|
+
* State is owned by the container: consumers read it and mutate only through
|
|
24
|
+
* `emit`/`patch`, so nested writes are a compile error rather than a silent
|
|
25
|
+
* desync from the change-tracking channel.
|
|
26
|
+
*
|
|
27
|
+
* @typeParam T - The StateContainer type
|
|
28
|
+
*/
|
|
29
|
+
export type ExtractState<T> = T extends StateContainerConstructor<infer S> ? DeepReadonly<S> : never;
|
|
7
30
|
export type ExtractStateMutable<T> = T extends StateContainerConstructor<infer S> ? S : never;
|
|
8
31
|
/**
|
|
9
32
|
* Constructor type for StateContainer classes
|
|
10
|
-
* @
|
|
33
|
+
* @typeParam S - State type managed by the container
|
|
11
34
|
*/
|
|
12
|
-
export type StateContainerConstructor<S extends object = any> = new (
|
|
35
|
+
export type StateContainerConstructor<S extends object = any> = new () => StateContainer<S, any, any>;
|
|
13
36
|
/**
|
|
14
37
|
* Extract the args type (serializable construction/identity data) from a
|
|
15
38
|
* StateContainer subclass.
|
|
16
|
-
* @
|
|
39
|
+
* @typeParam T - The StateContainer constructor type
|
|
17
40
|
*/
|
|
18
41
|
export type ExtractArgs<T> = T extends new () => StateContainer<any, infer A, any> ? A : void;
|
|
19
42
|
/**
|
|
20
43
|
* Extract the deps type (injected non-serializable handles) from a
|
|
21
44
|
* StateContainer subclass.
|
|
22
|
-
* @
|
|
45
|
+
* @typeParam T - The StateContainer constructor type
|
|
23
46
|
*/
|
|
24
47
|
export type ExtractDeps<T> = T extends new () => StateContainer<any, any, infer D> ? D : Record<string, never>;
|
|
25
|
-
export type InstanceReadonlyState<T extends StateContainerConstructor = any> = Omit<InstanceType<T>, 'state'> & {
|
|
26
|
-
state: ExtractState<T>;
|
|
27
|
-
};
|
|
28
|
-
export type InstanceState<T extends StateContainerConstructor = any> = Omit<InstanceType<T>, 'state'> & {
|
|
29
|
-
state: ExtractStateMutable<T>;
|
|
30
|
-
};
|
|
31
|
-
export type StateContainerInstance<S extends object = any> = Omit<StateContainer<S, any, any>, 'state'> & {
|
|
32
|
-
state: Readonly<S>;
|
|
33
|
-
};
|
|
34
|
-
/**
|
|
35
|
-
* Extract constructor argument types from a class
|
|
36
|
-
* @template T - The class type
|
|
37
|
-
*/
|
|
38
|
-
export type ExtractConstructorArgs<T> = T extends new (...args: infer P) => any ? P : never[];
|
|
39
|
-
/**
|
|
40
|
-
* Extract instance type from an abstract class constructor
|
|
41
|
-
* @template T - The abstract class constructor type
|
|
42
|
-
*/
|
|
43
|
-
export type BlocInstanceType<T extends abstract new (...args: any) => any> = T extends abstract new (...args: any) => infer R ? R : any;
|
|
44
48
|
/**
|
|
45
|
-
*
|
|
46
|
-
*
|
|
47
|
-
*
|
|
49
|
+
* Narrow a container instance's `state` without erasing the class. A plain
|
|
50
|
+
* intersection keeps private members, `this` types and symbol keys, so the
|
|
51
|
+
* result stays assignable to `StateContainer`; `state` is getter-only at the
|
|
52
|
+
* source, so no `readonly` modifier is needed here.
|
|
53
|
+
* @public
|
|
48
54
|
*/
|
|
49
|
-
export type
|
|
50
|
-
|
|
55
|
+
export type WithState<I, S> = I & {
|
|
56
|
+
state: S;
|
|
51
57
|
};
|
|
58
|
+
export type InstanceReadonlyState<T extends StateContainerConstructor = StateContainerConstructor> = WithState<InstanceType<T>, ExtractState<T>>;
|
|
59
|
+
export type InstanceState<T extends StateContainerConstructor = StateContainerConstructor> = WithState<InstanceType<T>, ExtractStateMutable<T>>;
|
|
60
|
+
export type StateContainerInstance<S extends object = any> = WithState<StateContainer<S, any, any>, Readonly<S>>;
|
|
@@ -1,21 +1,14 @@
|
|
|
1
1
|
/**
|
|
2
|
-
*
|
|
2
|
+
* Build an instance id: `${prefix}:${affix}` when an affix is given (the
|
|
3
|
+
* registry passes the instance key), otherwise `${prefix}:${timestamp}_${random}`.
|
|
3
4
|
*
|
|
4
|
-
*
|
|
5
|
-
*
|
|
6
|
-
*/
|
|
7
|
-
/**
|
|
8
|
-
* Generate simple ID with timestamp and random (no counter tracking)
|
|
9
|
-
*
|
|
10
|
-
* Format: `${prefix}:${timestamp}_${random}`
|
|
11
|
-
*
|
|
12
|
-
* @param prefix - Prefix for the ID
|
|
13
|
-
* @returns Branded ID string
|
|
5
|
+
* Ids are not unique: same-named classes share an id for the same affix, and
|
|
6
|
+
* the lazy `$blac.id` of an unregistered instance is always `${prefix}:main`.
|
|
14
7
|
*
|
|
15
8
|
* @example
|
|
16
9
|
* ```ts
|
|
17
|
-
*
|
|
18
|
-
* //
|
|
10
|
+
* generateSimpleId('CounterBloc', 'default'); // "CounterBloc:default"
|
|
11
|
+
* generateSimpleId('CounterBloc'); // "CounterBloc:1698765432100_a3k9d7f2q"
|
|
19
12
|
* ```
|
|
20
13
|
*/
|
|
21
14
|
export declare function generateSimpleId(prefix: string, affix?: string): string;
|
|
@@ -1,47 +1,40 @@
|
|
|
1
|
-
/**
|
|
2
|
-
* Utility functions for accessing static properties on StateContainer classes
|
|
3
|
-
*/
|
|
4
1
|
import type { EqualityFn } from '../config';
|
|
5
2
|
import { StateContainerConstructor } from '../types/utilities';
|
|
6
3
|
/**
|
|
7
|
-
* Get a static property from a class constructor
|
|
8
|
-
*
|
|
9
|
-
|
|
10
|
-
|
|
11
|
-
|
|
12
|
-
*
|
|
13
|
-
*
|
|
4
|
+
* Get a static property from a class constructor, walking the prototype
|
|
5
|
+
* chain so subclasses inherit the value unless they define their own.
|
|
6
|
+
*/
|
|
7
|
+
export declare function getStaticProp<V, T extends StateContainerConstructor = StateContainerConstructor>(Type: T, propName: string): V | undefined;
|
|
8
|
+
/**
|
|
9
|
+
* Get a static property declared directly on `Type`, ignoring the prototype
|
|
10
|
+
* chain, so subclasses never inherit a base class's value.
|
|
14
11
|
*/
|
|
15
|
-
export declare function
|
|
12
|
+
export declare function getOwnStaticProp<V, T extends StateContainerConstructor = StateContainerConstructor>(Type: T, propName: string): V | undefined;
|
|
16
13
|
/**
|
|
17
|
-
*
|
|
18
|
-
*
|
|
19
|
-
* @param Type - The class constructor to check
|
|
20
|
-
* @returns true if the class has `static keepAlive = true`
|
|
14
|
+
* Whether a class is marked `keepAlive` (never auto-disposed at ref count 0).
|
|
15
|
+
* Inherited: a subclass keeps a base class's `keepAlive` unless overridden.
|
|
21
16
|
*/
|
|
22
17
|
export declare function isKeepAliveClass<T extends StateContainerConstructor>(Type: T): boolean;
|
|
23
18
|
/**
|
|
24
|
-
*
|
|
25
|
-
*
|
|
26
|
-
* @param Type - The class constructor to check
|
|
27
|
-
* @returns true if the class has `static __excludeFromDevTools = true`
|
|
19
|
+
* Whether a class is excluded from DevTools (avoids DevTools tracking itself
|
|
20
|
+
* into an infinite loop). Inherited unless overridden by a subclass.
|
|
28
21
|
*/
|
|
29
22
|
export declare function isExcludedFromDevTools<T extends StateContainerConstructor>(Type: T): boolean;
|
|
30
23
|
/**
|
|
31
24
|
* Get the per-class equality function set via `@blac({ equality })`, if any.
|
|
32
|
-
*
|
|
33
|
-
* @returns the equality function or `undefined`
|
|
25
|
+
* Inherited: a subclass keeps a base class's equality fn unless overridden.
|
|
34
26
|
*/
|
|
35
27
|
export declare function getClassEquality<T extends StateContainerConstructor>(Type: T): EqualityFn | undefined;
|
|
36
28
|
/**
|
|
37
|
-
* Get
|
|
38
|
-
*
|
|
39
|
-
*
|
|
40
|
-
*
|
|
29
|
+
* Get a class's minification-safe identity name (`static blacName`), falling
|
|
30
|
+
* back to `Type.name`. Own only: a subclass never inherits a base class's
|
|
31
|
+
* explicit `blacName`, since that would collapse two distinct blocs onto one
|
|
32
|
+
* identity.
|
|
41
33
|
*/
|
|
42
|
-
export declare function
|
|
34
|
+
export declare function getBlacName<T extends StateContainerConstructor>(Type: T): string;
|
|
43
35
|
/**
|
|
44
|
-
*
|
|
45
|
-
*
|
|
36
|
+
* Get the per-class key function set via `@blac({ key })` or `static key = …`.
|
|
37
|
+
* Own only: a subclass never inherits a base class's `key`, since a
|
|
38
|
+
* different `Args` shape would derive the wrong instance key.
|
|
46
39
|
*/
|
|
47
|
-
export declare function
|
|
40
|
+
export declare function getClassKey(Type: unknown): ((args: any) => string) | undefined;
|