@blac/core 2.0.13 → 2.0.14
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 +85 -3
- package/dist/Cubit-9jal5zdZ.cjs +1 -1
- package/dist/Cubit-BAUPiUF7.cjs +359 -286
- package/dist/Cubit-BBKF3PIg.js +269 -230
- package/dist/Cubit-BC70gaiA.js +453 -0
- package/dist/Cubit-BC70gaiA.js.map +1 -0
- package/dist/Cubit-BOgUZva7.js +342 -266
- package/dist/Cubit-BOxMvpfc.js +273 -232
- package/dist/Cubit-BTznt8zg.js +1 -1
- package/dist/Cubit-BogJXkLm.js +260 -225
- package/dist/Cubit-C-8R_8db.cjs +475 -0
- package/dist/Cubit-C-8R_8db.cjs.map +1 -0
- package/dist/Cubit-C3Mw3EoO.cjs +401 -0
- package/dist/Cubit-C3Mw3EoO.cjs.map +1 -0
- package/dist/Cubit-CO8Fr72L.cjs +447 -0
- package/dist/Cubit-CO8Fr72L.cjs.map +1 -0
- package/dist/Cubit-COfHT1Bm.cjs +300 -259
- package/dist/Cubit-CROWjjs9.js +481 -0
- package/dist/Cubit-CROWjjs9.js.map +1 -0
- package/dist/Cubit-CWP8Ddzx.cjs +510 -0
- package/dist/Cubit-CWP8Ddzx.cjs.map +1 -0
- package/dist/Cubit-CXxh9iol.js +284 -242
- package/dist/Cubit-CYOWfzQt.cjs +297 -254
- package/dist/Cubit-CZaf_fp4.cjs +1 -1
- package/dist/Cubit-C_dUEUdd.cjs +359 -286
- package/dist/Cubit-C_rxRCTN.cjs +523 -0
- package/dist/Cubit-C_rxRCTN.cjs.map +1 -0
- package/dist/Cubit-CcKgMEBO.js +281 -239
- package/dist/Cubit-CfT6Y1jl.js +328 -280
- package/dist/Cubit-CynJruuO.js +369 -0
- package/dist/Cubit-CynJruuO.js.map +1 -0
- package/dist/Cubit-D2vQ6nMb.js +342 -266
- package/dist/Cubit-D7jOZCoZ.js +342 -266
- package/dist/Cubit-D9j3IGPc.cjs +523 -0
- package/dist/Cubit-D9j3IGPc.cjs.map +1 -0
- package/dist/Cubit-DKEY9WYq.cjs +276 -240
- package/dist/Cubit-DMV_0TCp.js +481 -0
- package/dist/Cubit-DMV_0TCp.js.map +1 -0
- package/dist/Cubit-DP5DXPUK.js +342 -266
- package/dist/Cubit-DRFkzD2h.js +426 -0
- package/dist/Cubit-DRFkzD2h.js.map +1 -0
- package/dist/Cubit-DbnhTUaZ.cjs +359 -286
- package/dist/Cubit-DrqG3SP3.cjs +349 -300
- package/dist/Cubit-DsDkCo42.cjs +292 -250
- package/dist/Cubit-DwRw1E9D.cjs +289 -247
- package/dist/Cubit-Dw_kFBgc.js +1 -1
- package/dist/Cubit-KiXZCubP.cjs +1 -1
- package/dist/Cubit-Ksj7G4uR.js +342 -266
- package/dist/Cubit-MkjbpcPf.cjs +359 -286
- package/dist/Cubit-NRhvdDQ6.js +279 -239
- package/dist/Cubit-PMTXxI_u.js +1 -1
- package/dist/Cubit-VJuu2tt9.js +481 -0
- package/dist/Cubit-VJuu2tt9.js.map +1 -0
- package/dist/Cubit-jz922NKf.cjs +300 -257
- package/dist/Cubit-kU5_4jgC.cjs +359 -286
- package/dist/StateContainerRegistry-B4yVMYbx.cjs +1057 -0
- package/dist/StateContainerRegistry-B4yVMYbx.cjs.map +1 -0
- package/dist/StateContainerRegistry-BAcxouCu.js +683 -615
- package/dist/StateContainerRegistry-BK57H92E.js +701 -630
- package/dist/StateContainerRegistry-BRBATSrx.cjs +1030 -0
- package/dist/StateContainerRegistry-BRBATSrx.cjs.map +1 -0
- package/dist/StateContainerRegistry-BgBIKcQF.js +956 -0
- package/dist/StateContainerRegistry-BgBIKcQF.js.map +1 -0
- package/dist/StateContainerRegistry-BglEhqdA.js +669 -606
- package/dist/StateContainerRegistry-BhcnG0DF.js +625 -562
- package/dist/StateContainerRegistry-BpO5t-0i.js +642 -580
- package/dist/StateContainerRegistry-BqS-wpb_.js +957 -0
- package/dist/StateContainerRegistry-BqS-wpb_.js.map +1 -0
- package/dist/StateContainerRegistry-BrEGYPZT.cjs +1029 -0
- package/dist/StateContainerRegistry-BrEGYPZT.cjs.map +1 -0
- package/dist/StateContainerRegistry-Bxfne4A7.cjs +908 -0
- package/dist/StateContainerRegistry-Bxfne4A7.cjs.map +1 -0
- package/dist/StateContainerRegistry-C0E7vsgy.js +758 -0
- package/dist/StateContainerRegistry-C0E7vsgy.js.map +1 -0
- package/dist/StateContainerRegistry-C0I77Ndz.cjs +920 -0
- package/dist/StateContainerRegistry-C0I77Ndz.cjs.map +1 -0
- package/dist/StateContainerRegistry-CDH9mnQS.cjs +668 -614
- package/dist/StateContainerRegistry-CTOXUf75.cjs +695 -640
- package/dist/StateContainerRegistry-CX2CBOmv.cjs +739 -679
- package/dist/StateContainerRegistry-CXnnf2-l.js +867 -0
- package/dist/StateContainerRegistry-CXnnf2-l.js.map +1 -0
- package/dist/StateContainerRegistry-CehuIpK_.cjs +811 -0
- package/dist/StateContainerRegistry-CehuIpK_.cjs.map +1 -0
- package/dist/StateContainerRegistry-Ci0ajc5g.js +680 -612
- package/dist/StateContainerRegistry-Ck2-XmT_.js +587 -527
- package/dist/StateContainerRegistry-D1lVJFGL.cjs +706 -646
- package/dist/StateContainerRegistry-DC4N73O6.js +632 -569
- package/dist/StateContainerRegistry-DOuGI-l5.js +645 -582
- package/dist/StateContainerRegistry-DT66lr3I.cjs +651 -596
- package/dist/StateContainerRegistry-DmmzYa7S.js +974 -0
- package/dist/StateContainerRegistry-DmmzYa7S.js.map +1 -0
- package/dist/StateContainerRegistry-Upsrlg9G.cjs +709 -649
- package/dist/StateContainerRegistry-WznfcA-Q.js +855 -0
- package/dist/StateContainerRegistry-WznfcA-Q.js.map +1 -0
- package/dist/StateContainerRegistry-Yph6UCA_.js +637 -569
- package/dist/StateContainerRegistry-mseeTqSA.cjs +671 -616
- package/dist/StateContainerRegistry-pRNxHNFD.cjs +658 -603
- package/dist/StateContainerRegistry-vXMWtG7J.cjs +613 -561
- package/dist/StateContainerRegistry-v_prqMcI.cjs +663 -603
- package/dist/branded-BSeA_mZO.cjs.map +1 -1
- package/dist/branded-DCqi3De1.cjs +11 -11
- package/dist/branded-DwtzSsg0.js.map +1 -1
- package/dist/branded-Max3xOTA.js +6 -6
- package/dist/config-0ZD9i3wy.js +16 -0
- package/dist/config-0ZD9i3wy.js.map +1 -0
- package/dist/config-B3NIwDQv.cjs +20 -20
- package/dist/config-BKGHop0V.js +5 -5
- package/dist/config-BKoaAlmb.js +5 -5
- package/dist/config-BPj08-8h.cjs +32 -0
- package/dist/config-BPj08-8h.cjs.map +1 -0
- package/dist/config-BR0Xy-Tn.cjs +20 -20
- package/dist/config-B_4xXpvK.cjs +32 -0
- package/dist/config-B_4xXpvK.cjs.map +1 -0
- package/dist/config-BflrQM4_.cjs +32 -0
- package/dist/config-BflrQM4_.cjs.map +1 -0
- package/dist/config-BzObBsk2.cjs +32 -0
- package/dist/config-BzObBsk2.cjs.map +1 -0
- package/dist/config-C0yumL1H.cjs +32 -0
- package/dist/config-C0yumL1H.cjs.map +1 -0
- package/dist/config-C8xqVHTf.js +16 -0
- package/dist/config-C8xqVHTf.js.map +1 -0
- package/dist/config-CCUhIYIF.js +5 -5
- package/dist/config-CGo__MAt.js +16 -0
- package/dist/config-CGo__MAt.js.map +1 -0
- package/dist/config-CQH9fTY-.cjs +20 -20
- package/dist/config-CR_Bz7RD.js +5 -5
- package/dist/config-CTOa-yPN.cjs +20 -20
- package/dist/config-Cd7Q-B4g.js +16 -0
- package/dist/config-Cd7Q-B4g.js.map +1 -0
- package/dist/config-CmDEX-1o.js +16 -0
- package/dist/config-CmDEX-1o.js.map +1 -0
- package/dist/config-CoNMTnMA.cjs +32 -0
- package/dist/config-CoNMTnMA.cjs.map +1 -0
- package/dist/config-Cwj8-C1J.js +5 -5
- package/dist/config-D3jisfdj.cjs +20 -20
- package/dist/config-D4GifZQ4.js +5 -5
- package/dist/config-DDrSQGpQ.cjs +20 -20
- package/dist/config-DEcslxan.cjs +20 -20
- package/dist/config-DMNZ2YLV.cjs +20 -20
- package/dist/config-De9oQ6Ki.js +5 -5
- package/dist/config-DoHx0Xsl.js +16 -0
- package/dist/config-DoHx0Xsl.js.map +1 -0
- package/dist/config-DokTzpr8.cjs +20 -20
- package/dist/config-DslYBm4Z.js +5 -5
- package/dist/config-H6FAqbW4.cjs +20 -20
- package/dist/config-Yp645dGK.js +5 -5
- package/dist/config-ispAzOZV.js +5 -5
- package/dist/config.d.cts +72 -0
- package/dist/config.d.ts +72 -0
- package/dist/constants.d.cts +13 -0
- package/dist/constants.d.ts +13 -0
- package/dist/core/Cubit.d.ts +14 -4
- package/dist/core/StateContainer.d.ts +111 -11
- package/dist/core/StateContainerRegistry.d.ts +55 -11
- package/dist/core/symbols.d.ts +26 -0
- package/dist/debug.cjs +3 -3
- package/dist/debug.js +3 -3
- package/dist/decorators/blac.d.ts +17 -0
- package/dist/ensure-9VEq5H0L.js +3 -3
- package/dist/ensure-BB6xHQAF.cjs +14 -0
- package/dist/ensure-BB6xHQAF.cjs.map +1 -0
- package/dist/ensure-BNDfTzqg.cjs +8 -8
- package/dist/ensure-BVCnjU7r.js +343 -267
- package/dist/ensure-BbzGXjep.cjs +8 -8
- package/dist/ensure-BlIaQai6.js +9 -0
- package/dist/ensure-BlIaQai6.js.map +1 -0
- package/dist/ensure-Bm3oHxga.js +9 -0
- package/dist/ensure-Bm3oHxga.js.map +1 -0
- package/dist/ensure-C3eIRs6e.cjs +8 -8
- package/dist/ensure-CJZL7bcA.cjs +365 -292
- package/dist/ensure-CN6unBOe.cjs +8 -8
- package/dist/ensure-CU-B1ywv.js +3 -3
- package/dist/ensure-CWKzeno7.js +3 -3
- package/dist/ensure-CkENsuQ9.js +9 -0
- package/dist/ensure-CkENsuQ9.js.map +1 -0
- package/dist/ensure-Cm-4_LSh.cjs +14 -0
- package/dist/ensure-Cm-4_LSh.cjs.map +1 -0
- package/dist/ensure-Cqex5r1P.cjs +14 -0
- package/dist/ensure-Cqex5r1P.cjs.map +1 -0
- package/dist/ensure-Cv5AbNGZ.js +9 -0
- package/dist/ensure-Cv5AbNGZ.js.map +1 -0
- package/dist/ensure-D63lEMUK.cjs +8 -8
- package/dist/ensure-DGEtPU9A.cjs +8 -8
- package/dist/ensure-DM3qb336.cjs +14 -0
- package/dist/ensure-DM3qb336.cjs.map +1 -0
- package/dist/ensure-DME-_T0j.cjs +8 -8
- package/dist/ensure-DWd0GCYB.js +3 -3
- package/dist/ensure-DamKOP6q.cjs +8 -8
- package/dist/ensure-Dcfptl-A.js +9 -0
- package/dist/ensure-Dcfptl-A.js.map +1 -0
- package/dist/ensure-Def-EBWG.js +3 -3
- package/dist/ensure-DnHL5QiQ.cjs +14 -0
- package/dist/ensure-DnHL5QiQ.cjs.map +1 -0
- package/dist/ensure-Dr7I78Ku.cjs +8 -8
- package/dist/ensure-SLVdGd5b.js +3 -3
- package/dist/ensure-Sb92MCXu.js +3 -3
- package/dist/ensure-gFlvevGm.cjs +14 -0
- package/dist/ensure-gFlvevGm.cjs.map +1 -0
- package/dist/ensure-l2-H7S5W.js +3 -3
- package/dist/ensure-mkL-3qh8.js +9 -0
- package/dist/ensure-mkL-3qh8.js.map +1 -0
- package/dist/ensure-n80crSlX.js +3 -3
- package/dist/ensure-nCxg7MCN.js +3 -3
- package/dist/ensure-vS71MV4q.cjs +8 -8
- package/dist/index.cjs +37 -14
- package/dist/index.cjs.map +1 -1
- package/dist/index.d.cts +14 -4
- package/dist/index.d.ts +14 -4
- package/dist/index.js +23 -10
- package/dist/index.js.map +1 -1
- package/dist/management-6oQbmf0z.js +41 -0
- package/dist/management-6oQbmf0z.js.map +1 -0
- package/dist/management-B46QwA9Y.js +20 -11
- package/dist/management-B9yrRpeg.js +41 -0
- package/dist/management-B9yrRpeg.js.map +1 -0
- package/dist/management-BCKTEZ8Q.js +20 -11
- package/dist/management-BbMzdXbT.js +41 -0
- package/dist/management-BbMzdXbT.js.map +1 -0
- package/dist/management-Bg652agq.js +20 -11
- package/dist/management-BnedF5ZD.cjs +50 -50
- package/dist/management-BoUa99eB.cjs +79 -0
- package/dist/management-BoUa99eB.cjs.map +1 -0
- package/dist/management-C4SHcrJm.cjs +79 -0
- package/dist/management-C4SHcrJm.cjs.map +1 -0
- package/dist/management-CK-GL3wY.js +20 -11
- package/dist/management-CPhgY8OE.js +41 -0
- package/dist/management-CPhgY8OE.js.map +1 -0
- package/dist/management-CU_V3LIP.js +20 -11
- package/dist/management-CUwXDSi9.cjs +79 -0
- package/dist/management-CUwXDSi9.cjs.map +1 -0
- package/dist/management-CaqiyNzB.js +20 -11
- package/dist/management-Cin-JvYe.js +20 -11
- package/dist/management-ClaXym0F.cjs +50 -50
- package/dist/management-DL0Uzsoz.js +20 -11
- package/dist/management-DLdAQfqk.cjs +79 -0
- package/dist/management-DLdAQfqk.cjs.map +1 -0
- package/dist/management-DMZ8qpwr.cjs +50 -50
- package/dist/management-DTzcC6aD.cjs +79 -0
- package/dist/management-DTzcC6aD.cjs.map +1 -0
- package/dist/management-DYLNyj9p.cjs +50 -50
- package/dist/management-Dag9u4t6.cjs +50 -50
- package/dist/management-DbMRdDBo.cjs +50 -50
- package/dist/management-DfnDAKmP.js +41 -0
- package/dist/management-DfnDAKmP.js.map +1 -0
- package/dist/management-DjBU1gtb.cjs +50 -50
- package/dist/management-DwCozsY8.js +20 -11
- package/dist/management-H4m3ciJO.js +32 -0
- package/dist/management-H4m3ciJO.js.map +1 -0
- package/dist/management-Xo3A6Za3.cjs +79 -0
- package/dist/management-Xo3A6Za3.cjs.map +1 -0
- package/dist/management-ZU2YzOkr.js +18 -10
- package/dist/management-baPDwA9n.cjs +50 -50
- package/dist/management-jQGCvZNN.cjs +44 -44
- package/dist/management-ry_KteFK.cjs +50 -50
- package/dist/plugin/BlacPlugin.d.ts +89 -15
- package/dist/plugin/PluginManager.d.ts +65 -5
- package/dist/plugins.cjs +1 -1
- package/dist/plugins.d.cts +2 -2
- package/dist/plugins.d.ts +2 -2
- package/dist/plugins.js +1 -1
- package/dist/registry/acquire.d.ts +9 -2
- package/dist/registry/ensure.d.ts +2 -2
- package/dist/registry/index.d.ts +1 -1
- package/dist/resolve-dependencies-B2QggQAi.js +641 -558
- package/dist/resolve-dependencies-B6JDXvpr.js +651 -566
- package/dist/resolve-dependencies-BAKAoD0U.js +878 -0
- package/dist/resolve-dependencies-BAKAoD0U.js.map +1 -0
- package/dist/resolve-dependencies-BFZQq60Y.cjs +724 -666
- package/dist/resolve-dependencies-BGafS3Ww.js +643 -561
- package/dist/resolve-dependencies-BHd34gS3.cjs +724 -666
- package/dist/resolve-dependencies-BNeayhbQ.cjs +732 -671
- package/dist/resolve-dependencies-BWEMpuDy.js +641 -558
- package/dist/resolve-dependencies-BiWkW2eS.js +643 -561
- package/dist/resolve-dependencies-BjxCztYD.js +739 -0
- package/dist/resolve-dependencies-BjxCztYD.js.map +1 -0
- package/dist/resolve-dependencies-BlyBV0hB.cjs +969 -0
- package/dist/resolve-dependencies-BlyBV0hB.cjs.map +1 -0
- package/dist/resolve-dependencies-By26rT_i.js +651 -566
- package/dist/resolve-dependencies-C9Kf7AzY.cjs +724 -666
- package/dist/resolve-dependencies-CTzV1txG.js +643 -561
- package/dist/resolve-dependencies-CWjuGHiF.cjs +969 -0
- package/dist/resolve-dependencies-CWjuGHiF.cjs.map +1 -0
- package/dist/resolve-dependencies-ClSsP0DJ.cjs +722 -663
- package/dist/resolve-dependencies-D0vTzZgs.js +643 -561
- package/dist/resolve-dependencies-D2WnZMF-.cjs +724 -666
- package/dist/resolve-dependencies-DCBLTeza.cjs +969 -0
- package/dist/resolve-dependencies-DCBLTeza.cjs.map +1 -0
- package/dist/resolve-dependencies-DMlqYJR2.js +643 -561
- package/dist/resolve-dependencies-DP6U1EYB.cjs +840 -0
- package/dist/resolve-dependencies-DP6U1EYB.cjs.map +1 -0
- package/dist/resolve-dependencies-DSQNXvnV.cjs +724 -666
- package/dist/resolve-dependencies-DV3HO_uH.js +878 -0
- package/dist/resolve-dependencies-DV3HO_uH.js.map +1 -0
- package/dist/resolve-dependencies-DXwMhP0Y.js +878 -0
- package/dist/resolve-dependencies-DXwMhP0Y.js.map +1 -0
- package/dist/resolve-dependencies-DbRWlt9u.js +878 -0
- package/dist/resolve-dependencies-DbRWlt9u.js.map +1 -0
- package/dist/resolve-dependencies-DcUUva2P.cjs +724 -666
- package/dist/resolve-dependencies-Dd8T6TLt.cjs +724 -666
- package/dist/resolve-dependencies-Dfdp_DZd.cjs +732 -671
- package/dist/resolve-dependencies-GJ8PNyNB.cjs +969 -0
- package/dist/resolve-dependencies-GJ8PNyNB.cjs.map +1 -0
- package/dist/resolve-dependencies-KSpTt4jy.cjs +722 -663
- package/dist/resolve-dependencies-Nvjp4CwS.js +643 -561
- package/dist/resolve-dependencies-f-QUqYiL.js +643 -561
- package/dist/testing.cjs +27 -20
- package/dist/testing.cjs.map +1 -1
- package/dist/testing.d.cts +22 -1
- package/dist/testing.d.ts +22 -1
- package/dist/testing.js +27 -21
- package/dist/testing.js.map +1 -1
- package/dist/tracked-B77j2g9M.js +171 -151
- package/dist/tracked-BDVi2LKM.cjs +196 -175
- package/dist/tracked-BFdJCzL0.cjs +242 -0
- package/dist/tracked-BFdJCzL0.cjs.map +1 -0
- package/dist/tracked-BH-gX4T1.cjs +196 -175
- package/dist/tracked-BTHok3Dl.cjs +196 -175
- package/dist/tracked-BTbFkFeM.js +186 -166
- package/dist/tracked-BU_OBWqM.cjs +242 -0
- package/dist/tracked-BU_OBWqM.cjs.map +1 -0
- package/dist/tracked-BfctH2es.cjs +242 -0
- package/dist/tracked-BfctH2es.cjs.map +1 -0
- package/dist/tracked-BhQtzUhZ.js +186 -166
- package/dist/tracked-BnqrYXiO.js +212 -0
- package/dist/tracked-BnqrYXiO.js.map +1 -0
- package/dist/tracked-BtgFOGup.js +212 -0
- package/dist/tracked-BtgFOGup.js.map +1 -0
- package/dist/tracked-C3nIS4J7.cjs +242 -0
- package/dist/tracked-C3nIS4J7.cjs.map +1 -0
- package/dist/tracked-C52awNV9.js +171 -151
- package/dist/tracked-CGzduF2m.js +186 -166
- package/dist/tracked-CK_-ixtX.cjs +196 -175
- package/dist/tracked-CLlvURln.js +186 -166
- package/dist/tracked-CgHWmuGC.cjs +211 -190
- package/dist/tracked-CoAlC8fs.js +171 -151
- package/dist/tracked-D3Xjm1H1.cjs +211 -190
- package/dist/tracked-DB6yMV5F.js +212 -0
- package/dist/tracked-DB6yMV5F.js.map +1 -0
- package/dist/tracked-DBn-bs_G.js +171 -151
- package/dist/tracked-DMBTDF0P.js +171 -151
- package/dist/tracked-DN3h3Rp1.js +171 -151
- package/dist/tracked-DOGh1Q5Z.cjs +242 -0
- package/dist/tracked-DOGh1Q5Z.cjs.map +1 -0
- package/dist/tracked-DUkp4zve.cjs +196 -175
- package/dist/tracked-D_ou7mYG.js +212 -0
- package/dist/tracked-D_ou7mYG.js.map +1 -0
- package/dist/tracked-Dcu6EATB.js +171 -151
- package/dist/tracked-GvAJQVAI.cjs +227 -196
- package/dist/tracked-O2lv-kJV.cjs +211 -190
- package/dist/tracked-WF6aXuAo.js +186 -162
- package/dist/tracked-d_sQWU3c.cjs +196 -175
- package/dist/tracked-n9TMK-30.cjs +196 -175
- package/dist/tracked-njU-_pVa.cjs +211 -190
- package/dist/tracked-zAgmKIlC.js +212 -0
- package/dist/tracked-zAgmKIlC.js.map +1 -0
- package/dist/tracking/dependency-manager.d.ts +33 -29
- package/dist/tracking/index.d.ts +16 -1
- package/dist/tracking/iteration-perf.bench.d.ts +1 -0
- package/dist/tracking/path-utils.d.ts +18 -1
- package/dist/tracking/resolve-dependencies.d.ts +3 -1
- package/dist/tracking/tracked.d.ts +37 -34
- package/dist/tracking/tracking-proxy.d.ts +94 -47
- package/dist/tracking.cjs +12 -9
- package/dist/tracking.js +32 -2
- package/dist/types/utilities.d.ts +15 -3
- package/dist/types.cjs +1 -1
- package/dist/types.js +1 -1
- package/dist/utils/static-props.d.ts +14 -0
- package/dist/utils/structural-key.d.ts +14 -0
- package/dist/watch/watch.d.ts +1 -1
- package/dist/watch-BpwaUL8r.cjs +68 -0
- package/dist/watch-BpwaUL8r.cjs.map +1 -0
- package/dist/watch-DWCqXllW.js +57 -0
- package/dist/watch-DWCqXllW.js.map +1 -0
- package/dist/watch-entry.cjs +3 -6
- package/dist/watch-entry.d.cts +1 -3
- package/dist/watch-entry.d.ts +1 -3
- package/dist/watch-entry.js +2 -2
- package/package.json +4 -14
|
@@ -1,663 +1,718 @@
|
|
|
1
1
|
//#region src/constants.ts
|
|
2
2
|
/**
|
|
3
|
-
* Default configuration constants for BlaC
|
|
4
|
-
*
|
|
5
|
-
* Centralized location for all magic numbers and default values.
|
|
6
|
-
*/
|
|
3
|
+
* Default configuration constants for BlaC
|
|
4
|
+
*
|
|
5
|
+
* Centralized location for all magic numbers and default values.
|
|
6
|
+
*/
|
|
7
7
|
/**
|
|
8
|
-
* Default configuration constants for BlaC
|
|
9
|
-
*/
|
|
8
|
+
* Default configuration constants for BlaC
|
|
9
|
+
*/
|
|
10
10
|
const BLAC_DEFAULTS = {
|
|
11
|
-
|
|
12
|
-
|
|
13
|
-
|
|
14
|
-
|
|
15
|
-
|
|
16
|
-
|
|
17
|
-
|
|
18
|
-
|
|
19
|
-
|
|
11
|
+
DEFAULT_INSTANCE_KEY: 'default',
|
|
12
|
+
MAX_GETTER_DEPTH: 10,
|
|
13
|
+
CLEANUP_INTERVAL_MS: 3e4,
|
|
14
|
+
WEAKREF_CLEANUP_INTERVAL_MS: 1e4,
|
|
15
|
+
MAX_SUBSCRIPTIONS: 1e3,
|
|
16
|
+
MAX_SUBSCRIPTIONS_HIGH_PERF: 1e4,
|
|
17
|
+
PIPELINE_TIMEOUT_MS: 5e3,
|
|
18
|
+
CLEANUP_INTERVAL_HIGH_PERF_MS: 5e3,
|
|
19
|
+
MAX_PIPELINE_STAGES: 30,
|
|
20
20
|
};
|
|
21
21
|
/**
|
|
22
|
-
* Static property names for StateContainer classes
|
|
23
|
-
* Used for feature flags and configuration on bloc classes
|
|
24
|
-
*/
|
|
22
|
+
* Static property names for StateContainer classes
|
|
23
|
+
* Used for feature flags and configuration on bloc classes
|
|
24
|
+
*/
|
|
25
25
|
const BLAC_STATIC_PROPS = {
|
|
26
|
-
|
|
27
|
-
|
|
26
|
+
KEEP_ALIVE: 'keepAlive',
|
|
27
|
+
EXCLUDE_FROM_DEVTOOLS: '__excludeFromDevTools',
|
|
28
28
|
};
|
|
29
29
|
/**
|
|
30
|
-
* Standard error message prefix
|
|
31
|
-
*/
|
|
32
|
-
const BLAC_ERROR_PREFIX =
|
|
30
|
+
* Standard error message prefix
|
|
31
|
+
*/
|
|
32
|
+
const BLAC_ERROR_PREFIX = '[BlaC]';
|
|
33
33
|
//#endregion
|
|
34
34
|
//#region src/plugin/PluginManager.ts
|
|
35
35
|
/**
|
|
36
|
-
* Manages plugin lifecycle for the BlaC state management system.
|
|
37
|
-
* Plugins receive notifications about state container lifecycle events.
|
|
38
|
-
*
|
|
39
|
-
* @example
|
|
40
|
-
* ```ts
|
|
41
|
-
* const manager = createPluginManager(registry);
|
|
42
|
-
* manager.install(myPlugin, { environment: 'development' });
|
|
43
|
-
* ```
|
|
44
|
-
*/
|
|
36
|
+
* Manages plugin lifecycle for the BlaC state management system.
|
|
37
|
+
* Plugins receive notifications about state container lifecycle events.
|
|
38
|
+
*
|
|
39
|
+
* @example
|
|
40
|
+
* ```ts
|
|
41
|
+
* const manager = createPluginManager(registry);
|
|
42
|
+
* manager.install(myPlugin, { environment: 'development' });
|
|
43
|
+
* ```
|
|
44
|
+
*/
|
|
45
45
|
var PluginManager = class {
|
|
46
|
-
|
|
47
|
-
|
|
48
|
-
|
|
49
|
-
|
|
50
|
-
|
|
51
|
-
|
|
52
|
-
|
|
53
|
-
|
|
54
|
-
|
|
55
|
-
|
|
56
|
-
|
|
57
|
-
|
|
58
|
-
|
|
59
|
-
|
|
60
|
-
|
|
61
|
-
|
|
62
|
-
|
|
63
|
-
|
|
64
|
-
|
|
65
|
-
|
|
66
|
-
|
|
67
|
-
|
|
68
|
-
|
|
69
|
-
|
|
70
|
-
|
|
71
|
-
|
|
72
|
-
|
|
73
|
-
|
|
74
|
-
|
|
75
|
-
|
|
76
|
-
|
|
77
|
-
|
|
78
|
-
|
|
79
|
-
|
|
80
|
-
|
|
81
|
-
|
|
82
|
-
|
|
83
|
-
|
|
84
|
-
|
|
85
|
-
|
|
86
|
-
|
|
87
|
-
|
|
88
|
-
|
|
89
|
-
|
|
90
|
-
|
|
91
|
-
|
|
92
|
-
|
|
93
|
-
|
|
94
|
-
|
|
95
|
-
|
|
96
|
-
|
|
97
|
-
|
|
98
|
-
|
|
99
|
-
|
|
100
|
-
|
|
101
|
-
|
|
102
|
-
|
|
103
|
-
|
|
104
|
-
|
|
105
|
-
|
|
106
|
-
|
|
107
|
-
|
|
108
|
-
|
|
109
|
-
|
|
110
|
-
|
|
111
|
-
|
|
112
|
-
|
|
113
|
-
|
|
114
|
-
|
|
115
|
-
|
|
116
|
-
|
|
117
|
-
|
|
118
|
-
|
|
119
|
-
|
|
120
|
-
|
|
121
|
-
|
|
122
|
-
|
|
123
|
-
|
|
124
|
-
|
|
125
|
-
|
|
126
|
-
|
|
127
|
-
|
|
128
|
-
|
|
129
|
-
|
|
130
|
-
|
|
131
|
-
|
|
132
|
-
|
|
133
|
-
|
|
134
|
-
|
|
135
|
-
|
|
136
|
-
|
|
137
|
-
|
|
138
|
-
|
|
139
|
-
|
|
140
|
-
|
|
141
|
-
|
|
142
|
-
|
|
143
|
-
|
|
144
|
-
|
|
145
|
-
|
|
146
|
-
|
|
147
|
-
|
|
148
|
-
|
|
149
|
-
|
|
150
|
-
|
|
151
|
-
|
|
152
|
-
|
|
153
|
-
|
|
154
|
-
|
|
155
|
-
|
|
156
|
-
|
|
157
|
-
|
|
158
|
-
|
|
159
|
-
|
|
160
|
-
|
|
161
|
-
|
|
162
|
-
|
|
163
|
-
|
|
164
|
-
|
|
165
|
-
|
|
166
|
-
|
|
167
|
-
|
|
168
|
-
|
|
169
|
-
|
|
170
|
-
|
|
171
|
-
|
|
172
|
-
|
|
173
|
-
|
|
174
|
-
|
|
175
|
-
|
|
176
|
-
|
|
177
|
-
|
|
178
|
-
|
|
179
|
-
|
|
180
|
-
|
|
181
|
-
|
|
182
|
-
|
|
183
|
-
|
|
184
|
-
|
|
185
|
-
|
|
186
|
-
|
|
187
|
-
|
|
188
|
-
|
|
189
|
-
|
|
190
|
-
|
|
191
|
-
|
|
192
|
-
|
|
193
|
-
|
|
194
|
-
|
|
195
|
-
|
|
196
|
-
|
|
197
|
-
|
|
198
|
-
|
|
199
|
-
|
|
200
|
-
|
|
201
|
-
|
|
202
|
-
|
|
203
|
-
|
|
204
|
-
|
|
205
|
-
|
|
206
|
-
|
|
207
|
-
|
|
208
|
-
|
|
209
|
-
|
|
210
|
-
|
|
211
|
-
|
|
212
|
-
|
|
213
|
-
|
|
214
|
-
|
|
215
|
-
|
|
216
|
-
|
|
217
|
-
|
|
218
|
-
|
|
219
|
-
|
|
220
|
-
|
|
221
|
-
|
|
222
|
-
|
|
223
|
-
|
|
224
|
-
|
|
225
|
-
|
|
226
|
-
|
|
227
|
-
|
|
228
|
-
|
|
229
|
-
|
|
230
|
-
|
|
231
|
-
|
|
232
|
-
|
|
233
|
-
|
|
234
|
-
|
|
235
|
-
|
|
236
|
-
|
|
237
|
-
|
|
238
|
-
|
|
239
|
-
|
|
240
|
-
|
|
241
|
-
|
|
242
|
-
|
|
243
|
-
|
|
244
|
-
|
|
46
|
+
/**
|
|
47
|
+
* Create a new PluginManager
|
|
48
|
+
* @param registry - The StateContainerRegistry to monitor for lifecycle events
|
|
49
|
+
*/
|
|
50
|
+
constructor(registry) {
|
|
51
|
+
this.plugins = /* @__PURE__ */ new Map();
|
|
52
|
+
this.registry = registry;
|
|
53
|
+
this.setupLifecycleHooks();
|
|
54
|
+
}
|
|
55
|
+
/**
|
|
56
|
+
* Install a plugin with optional configuration
|
|
57
|
+
* @param plugin - The plugin to install
|
|
58
|
+
* @param config - Optional plugin configuration
|
|
59
|
+
* @throws Error if plugin is already installed
|
|
60
|
+
*/
|
|
61
|
+
install(plugin, config = {}) {
|
|
62
|
+
const effectiveConfig = {
|
|
63
|
+
enabled: true,
|
|
64
|
+
environment: 'all',
|
|
65
|
+
...config,
|
|
66
|
+
};
|
|
67
|
+
if (!this.shouldEnablePlugin(effectiveConfig)) {
|
|
68
|
+
console.log(
|
|
69
|
+
`[BlaC] Plugin "${plugin.name}" skipped (environment mismatch)`,
|
|
70
|
+
);
|
|
71
|
+
return;
|
|
72
|
+
}
|
|
73
|
+
if (this.plugins.has(plugin.name))
|
|
74
|
+
throw new Error(`Plugin "${plugin.name}" is already installed`);
|
|
75
|
+
const context = this.createPluginContext();
|
|
76
|
+
this.plugins.set(plugin.name, {
|
|
77
|
+
plugin,
|
|
78
|
+
config: effectiveConfig,
|
|
79
|
+
context,
|
|
80
|
+
});
|
|
81
|
+
if (plugin.onInstall)
|
|
82
|
+
try {
|
|
83
|
+
plugin.onInstall(context);
|
|
84
|
+
} catch (error) {
|
|
85
|
+
console.error(
|
|
86
|
+
`[BlaC] Error installing plugin "${plugin.name}":`,
|
|
87
|
+
error,
|
|
88
|
+
);
|
|
89
|
+
this.plugins.delete(plugin.name);
|
|
90
|
+
throw error;
|
|
91
|
+
}
|
|
92
|
+
console.log(`[BlaC] Plugin "${plugin.name}" v${plugin.version} installed`);
|
|
93
|
+
}
|
|
94
|
+
/**
|
|
95
|
+
* Uninstall a plugin by name
|
|
96
|
+
* @param pluginName - The name of the plugin to uninstall
|
|
97
|
+
* @throws Error if plugin is not installed
|
|
98
|
+
*/
|
|
99
|
+
uninstall(pluginName) {
|
|
100
|
+
const installed = this.plugins.get(pluginName);
|
|
101
|
+
if (!installed) throw new Error(`Plugin "${pluginName}" is not installed`);
|
|
102
|
+
if (installed.plugin.onUninstall)
|
|
103
|
+
try {
|
|
104
|
+
installed.plugin.onUninstall();
|
|
105
|
+
} catch (error) {
|
|
106
|
+
console.error(
|
|
107
|
+
`[BlaC] Error uninstalling plugin "${pluginName}":`,
|
|
108
|
+
error,
|
|
109
|
+
);
|
|
110
|
+
}
|
|
111
|
+
this.plugins.delete(pluginName);
|
|
112
|
+
console.log(`[BlaC] Plugin "${pluginName}" uninstalled`);
|
|
113
|
+
}
|
|
114
|
+
/**
|
|
115
|
+
* Get an installed plugin by name
|
|
116
|
+
* @param pluginName - The name of the plugin to retrieve
|
|
117
|
+
* @returns The plugin instance or undefined if not found
|
|
118
|
+
*/
|
|
119
|
+
getPlugin(pluginName) {
|
|
120
|
+
return this.plugins.get(pluginName)?.plugin;
|
|
121
|
+
}
|
|
122
|
+
/**
|
|
123
|
+
* Get all installed plugins
|
|
124
|
+
* @returns Array of all installed plugins
|
|
125
|
+
*/
|
|
126
|
+
getAllPlugins() {
|
|
127
|
+
return Array.from(this.plugins.values()).map((p) => p.plugin);
|
|
128
|
+
}
|
|
129
|
+
/**
|
|
130
|
+
* Check if a plugin is installed
|
|
131
|
+
* @param pluginName - The name of the plugin to check
|
|
132
|
+
* @returns true if the plugin is installed
|
|
133
|
+
*/
|
|
134
|
+
hasPlugin(pluginName) {
|
|
135
|
+
return this.plugins.has(pluginName);
|
|
136
|
+
}
|
|
137
|
+
/**
|
|
138
|
+
* Uninstall all plugins
|
|
139
|
+
*/
|
|
140
|
+
clear() {
|
|
141
|
+
for (const name of this.plugins.keys()) this.uninstall(name);
|
|
142
|
+
}
|
|
143
|
+
/**
|
|
144
|
+
* Setup lifecycle hooks to notify plugins
|
|
145
|
+
*/
|
|
146
|
+
setupLifecycleHooks() {
|
|
147
|
+
this.registry.on('created', (instance) => {
|
|
148
|
+
this.notifyPlugins('onInstanceCreated', instance);
|
|
149
|
+
});
|
|
150
|
+
this.registry.on(
|
|
151
|
+
'stateChanged',
|
|
152
|
+
(instance, previousState, currentState, callstack) => {
|
|
153
|
+
this.notifyPlugins(
|
|
154
|
+
'onStateChanged',
|
|
155
|
+
instance,
|
|
156
|
+
previousState,
|
|
157
|
+
currentState,
|
|
158
|
+
callstack,
|
|
159
|
+
);
|
|
160
|
+
},
|
|
161
|
+
);
|
|
162
|
+
this.registry.on('disposed', (instance) => {
|
|
163
|
+
this.notifyPlugins('onInstanceDisposed', instance);
|
|
164
|
+
});
|
|
165
|
+
this.registry.on('refAcquired', (instance, refId) => {
|
|
166
|
+
this.notifyPlugins('onRefAcquired', instance, refId);
|
|
167
|
+
});
|
|
168
|
+
this.registry.on('refReleased', (instance, refId) => {
|
|
169
|
+
this.notifyPlugins('onRefReleased', instance, refId);
|
|
170
|
+
});
|
|
171
|
+
}
|
|
172
|
+
/**
|
|
173
|
+
* Notify all plugins of a lifecycle event
|
|
174
|
+
*/
|
|
175
|
+
notifyPlugins(hookName, ...args) {
|
|
176
|
+
for (const { plugin, config, context } of this.plugins.values()) {
|
|
177
|
+
if (!config.enabled) continue;
|
|
178
|
+
const hook = plugin[hookName];
|
|
179
|
+
if (typeof hook === 'function')
|
|
180
|
+
try {
|
|
181
|
+
hook.apply(plugin, [...args, context]);
|
|
182
|
+
} catch (error) {
|
|
183
|
+
console.error(
|
|
184
|
+
`[BlaC] Error in plugin "${plugin.name}" ${hookName}:`,
|
|
185
|
+
error,
|
|
186
|
+
);
|
|
187
|
+
}
|
|
188
|
+
}
|
|
189
|
+
}
|
|
190
|
+
/**
|
|
191
|
+
* Create plugin context with safe API access
|
|
192
|
+
*/
|
|
193
|
+
createPluginContext() {
|
|
194
|
+
return {
|
|
195
|
+
getInstanceMetadata: (instance) => {
|
|
196
|
+
return {
|
|
197
|
+
id: instance.instanceId,
|
|
198
|
+
className: instance.constructor.name,
|
|
199
|
+
isDisposed: instance.isDisposed,
|
|
200
|
+
name: instance.name,
|
|
201
|
+
lastStateChangeTimestamp: instance.lastUpdateTimestamp,
|
|
202
|
+
createdAt: instance.createdAt,
|
|
203
|
+
state: instance.state,
|
|
204
|
+
hydrationStatus: instance.hydrationStatus,
|
|
205
|
+
isHydrated: instance.isHydrated,
|
|
206
|
+
hydrationError: instance.hydrationError,
|
|
207
|
+
changedWhileHydrating: instance.changedWhileHydrating,
|
|
208
|
+
createdFrom: instance.createdFrom || void 0,
|
|
209
|
+
};
|
|
210
|
+
},
|
|
211
|
+
getState: (instance) => {
|
|
212
|
+
return instance.state;
|
|
213
|
+
},
|
|
214
|
+
getHydrationStatus: (instance) => {
|
|
215
|
+
return instance.hydrationStatus;
|
|
216
|
+
},
|
|
217
|
+
startHydration: (instance) => {
|
|
218
|
+
instance.beginHydration();
|
|
219
|
+
},
|
|
220
|
+
applyHydratedState: (instance, state) => {
|
|
221
|
+
return instance.applyHydratedState(state);
|
|
222
|
+
},
|
|
223
|
+
finishHydration: (instance) => {
|
|
224
|
+
instance.finishHydration();
|
|
225
|
+
},
|
|
226
|
+
failHydration: (instance, error) => {
|
|
227
|
+
instance.failHydration(error);
|
|
228
|
+
},
|
|
229
|
+
waitForHydration: (instance) => {
|
|
230
|
+
return instance.waitForHydration();
|
|
231
|
+
},
|
|
232
|
+
queryInstances: (typeClass) => {
|
|
233
|
+
return this.registry.getAll(typeClass);
|
|
234
|
+
},
|
|
235
|
+
getAllTypes: () => {
|
|
236
|
+
return this.registry.getTypes();
|
|
237
|
+
},
|
|
238
|
+
getStats: () => {
|
|
239
|
+
return this.registry.getStats();
|
|
240
|
+
},
|
|
241
|
+
getRefIds: (instanceId) => {
|
|
242
|
+
for (const Type of this.registry.getTypes()) {
|
|
243
|
+
const map = this.registry.getInstancesMap(Type);
|
|
244
|
+
for (const [, entry] of map)
|
|
245
|
+
if (entry.instance.instanceId === instanceId)
|
|
246
|
+
return Array.from(entry.refs.keys());
|
|
247
|
+
}
|
|
248
|
+
return [];
|
|
249
|
+
},
|
|
250
|
+
};
|
|
251
|
+
}
|
|
252
|
+
/**
|
|
253
|
+
* Check if plugin should be enabled based on environment
|
|
254
|
+
*/
|
|
255
|
+
shouldEnablePlugin(config) {
|
|
256
|
+
if (!config.enabled) return false;
|
|
257
|
+
if (config.environment === 'all') return true;
|
|
258
|
+
return this.getCurrentEnvironment() === config.environment;
|
|
259
|
+
}
|
|
260
|
+
/**
|
|
261
|
+
* Get current environment
|
|
262
|
+
*/
|
|
263
|
+
getCurrentEnvironment() {
|
|
264
|
+
if (typeof process !== 'undefined') {
|
|
265
|
+
if (process.env.NODE_ENV === 'test') return 'test';
|
|
266
|
+
if (process.env.NODE_ENV === 'production') return 'production';
|
|
267
|
+
return 'development';
|
|
268
|
+
}
|
|
269
|
+
return 'development';
|
|
270
|
+
}
|
|
245
271
|
};
|
|
246
272
|
/**
|
|
247
|
-
* Create a plugin manager instance
|
|
248
|
-
* @param registry - The StateContainerRegistry to monitor for lifecycle events
|
|
249
|
-
* @returns A new PluginManager instance
|
|
250
|
-
*/
|
|
273
|
+
* Create a plugin manager instance
|
|
274
|
+
* @param registry - The StateContainerRegistry to monitor for lifecycle events
|
|
275
|
+
* @returns A new PluginManager instance
|
|
276
|
+
*/
|
|
251
277
|
function createPluginManager(registry) {
|
|
252
|
-
|
|
278
|
+
return new PluginManager(registry);
|
|
253
279
|
}
|
|
254
280
|
//#endregion
|
|
255
281
|
//#region src/utils/static-props.ts
|
|
256
282
|
/**
|
|
257
|
-
* Utility functions for accessing static properties on StateContainer classes
|
|
258
|
-
*/
|
|
283
|
+
* Utility functions for accessing static properties on StateContainer classes
|
|
284
|
+
*/
|
|
259
285
|
/**
|
|
260
|
-
* Get a static property from a class constructor
|
|
261
|
-
* Type-safe helper that avoids (Type as any) casts
|
|
262
|
-
*
|
|
263
|
-
* @param Type - The class constructor
|
|
264
|
-
* @param propName - The property name to access
|
|
265
|
-
* @param defaultValue - Optional default value if property is undefined
|
|
266
|
-
* @returns The property value or default
|
|
267
|
-
*/
|
|
286
|
+
* Get a static property from a class constructor
|
|
287
|
+
* Type-safe helper that avoids (Type as any) casts
|
|
288
|
+
*
|
|
289
|
+
* @param Type - The class constructor
|
|
290
|
+
* @param propName - The property name to access
|
|
291
|
+
* @param defaultValue - Optional default value if property is undefined
|
|
292
|
+
* @returns The property value or default
|
|
293
|
+
*/
|
|
268
294
|
function getStaticProp(Type, propName, defaultValue) {
|
|
269
|
-
|
|
295
|
+
return Type[propName] ?? defaultValue;
|
|
270
296
|
}
|
|
271
297
|
/**
|
|
272
|
-
* Check if a class is marked as keepAlive.
|
|
273
|
-
* KeepAlive classes are never auto-disposed when ref count reaches 0.
|
|
274
|
-
* @param Type - The class constructor to check
|
|
275
|
-
* @returns true if the class has `static keepAlive = true`
|
|
276
|
-
*/
|
|
298
|
+
* Check if a class is marked as keepAlive.
|
|
299
|
+
* KeepAlive classes are never auto-disposed when ref count reaches 0.
|
|
300
|
+
* @param Type - The class constructor to check
|
|
301
|
+
* @returns true if the class has `static keepAlive = true`
|
|
302
|
+
*/
|
|
277
303
|
function isKeepAliveClass(Type) {
|
|
278
|
-
|
|
304
|
+
return getStaticProp(Type, BLAC_STATIC_PROPS.KEEP_ALIVE) === true;
|
|
279
305
|
}
|
|
280
306
|
//#endregion
|
|
281
307
|
//#region src/core/StateContainerRegistry.ts
|
|
282
308
|
/**
|
|
283
|
-
* Central registry for managing StateContainer instances.
|
|
284
|
-
* Handles instance lifecycle, named ref tracking, and lifecycle event emission.
|
|
285
|
-
*
|
|
286
|
-
* @example
|
|
287
|
-
* ```ts
|
|
288
|
-
* const registry = new StateContainerRegistry();
|
|
289
|
-
* const instance = registry.acquire(MyBloc); // ownership, must release
|
|
290
|
-
* const other = registry.ensure(OtherBloc); // no ownership, bloc-to-bloc
|
|
291
|
-
* registry.on('stateChanged', (container, prev, next) => {
|
|
292
|
-
* console.log('State changed:', prev, '->', next);
|
|
293
|
-
* });
|
|
294
|
-
* ```
|
|
295
|
-
*/
|
|
309
|
+
* Central registry for managing StateContainer instances.
|
|
310
|
+
* Handles instance lifecycle, named ref tracking, and lifecycle event emission.
|
|
311
|
+
*
|
|
312
|
+
* @example
|
|
313
|
+
* ```ts
|
|
314
|
+
* const registry = new StateContainerRegistry();
|
|
315
|
+
* const instance = registry.acquire(MyBloc); // ownership, must release
|
|
316
|
+
* const other = registry.ensure(OtherBloc); // no ownership, bloc-to-bloc
|
|
317
|
+
* registry.on('stateChanged', (container, prev, next) => {
|
|
318
|
+
* console.log('State changed:', prev, '->', next);
|
|
319
|
+
* });
|
|
320
|
+
* ```
|
|
321
|
+
*/
|
|
296
322
|
var StateContainerRegistry = class {
|
|
297
|
-
|
|
298
|
-
|
|
299
|
-
|
|
300
|
-
|
|
301
|
-
|
|
302
|
-
|
|
303
|
-
|
|
304
|
-
|
|
305
|
-
|
|
306
|
-
|
|
307
|
-
|
|
308
|
-
|
|
309
|
-
|
|
310
|
-
|
|
311
|
-
|
|
312
|
-
|
|
313
|
-
|
|
314
|
-
|
|
315
|
-
|
|
316
|
-
|
|
317
|
-
|
|
318
|
-
|
|
319
|
-
|
|
320
|
-
|
|
321
|
-
|
|
322
|
-
|
|
323
|
-
|
|
324
|
-
|
|
325
|
-
|
|
326
|
-
|
|
327
|
-
|
|
328
|
-
|
|
329
|
-
|
|
330
|
-
|
|
331
|
-
|
|
332
|
-
|
|
333
|
-
|
|
334
|
-
|
|
335
|
-
|
|
336
|
-
|
|
337
|
-
|
|
338
|
-
|
|
339
|
-
|
|
340
|
-
|
|
341
|
-
|
|
342
|
-
|
|
343
|
-
|
|
344
|
-
|
|
345
|
-
|
|
346
|
-
|
|
347
|
-
|
|
348
|
-
|
|
349
|
-
|
|
350
|
-
|
|
351
|
-
|
|
352
|
-
|
|
353
|
-
|
|
354
|
-
|
|
355
|
-
|
|
356
|
-
|
|
357
|
-
|
|
358
|
-
|
|
359
|
-
|
|
360
|
-
|
|
361
|
-
|
|
362
|
-
|
|
363
|
-
|
|
364
|
-
|
|
365
|
-
|
|
366
|
-
|
|
367
|
-
|
|
368
|
-
|
|
369
|
-
|
|
370
|
-
|
|
371
|
-
|
|
372
|
-
|
|
373
|
-
|
|
374
|
-
|
|
375
|
-
|
|
376
|
-
|
|
377
|
-
|
|
378
|
-
|
|
379
|
-
|
|
380
|
-
|
|
381
|
-
|
|
382
|
-
|
|
383
|
-
|
|
384
|
-
|
|
385
|
-
|
|
386
|
-
|
|
387
|
-
|
|
388
|
-
|
|
389
|
-
|
|
390
|
-
|
|
391
|
-
|
|
392
|
-
|
|
393
|
-
|
|
394
|
-
|
|
395
|
-
|
|
396
|
-
|
|
397
|
-
|
|
398
|
-
|
|
399
|
-
|
|
400
|
-
|
|
401
|
-
|
|
402
|
-
|
|
403
|
-
|
|
404
|
-
|
|
405
|
-
|
|
406
|
-
|
|
407
|
-
|
|
408
|
-
|
|
409
|
-
|
|
410
|
-
|
|
411
|
-
|
|
412
|
-
|
|
413
|
-
|
|
414
|
-
|
|
415
|
-
|
|
416
|
-
|
|
417
|
-
|
|
418
|
-
|
|
419
|
-
|
|
420
|
-
|
|
421
|
-
|
|
422
|
-
|
|
423
|
-
|
|
424
|
-
|
|
425
|
-
|
|
426
|
-
|
|
427
|
-
|
|
428
|
-
|
|
429
|
-
|
|
430
|
-
|
|
431
|
-
|
|
432
|
-
|
|
433
|
-
|
|
434
|
-
|
|
435
|
-
|
|
436
|
-
|
|
437
|
-
|
|
438
|
-
|
|
439
|
-
|
|
440
|
-
|
|
441
|
-
|
|
442
|
-
|
|
443
|
-
|
|
444
|
-
|
|
445
|
-
|
|
446
|
-
|
|
447
|
-
|
|
448
|
-
|
|
449
|
-
|
|
450
|
-
|
|
451
|
-
|
|
452
|
-
|
|
453
|
-
|
|
454
|
-
|
|
455
|
-
|
|
456
|
-
|
|
457
|
-
|
|
458
|
-
|
|
459
|
-
|
|
460
|
-
|
|
461
|
-
|
|
462
|
-
|
|
463
|
-
|
|
464
|
-
|
|
465
|
-
|
|
466
|
-
|
|
467
|
-
|
|
468
|
-
|
|
469
|
-
|
|
470
|
-
|
|
471
|
-
|
|
472
|
-
|
|
473
|
-
|
|
474
|
-
|
|
475
|
-
|
|
476
|
-
|
|
477
|
-
|
|
478
|
-
|
|
479
|
-
|
|
480
|
-
|
|
481
|
-
|
|
482
|
-
|
|
483
|
-
|
|
484
|
-
|
|
485
|
-
|
|
486
|
-
|
|
487
|
-
|
|
488
|
-
|
|
489
|
-
|
|
490
|
-
|
|
491
|
-
|
|
492
|
-
|
|
493
|
-
|
|
494
|
-
|
|
495
|
-
|
|
496
|
-
|
|
497
|
-
|
|
498
|
-
|
|
499
|
-
|
|
500
|
-
|
|
501
|
-
|
|
502
|
-
|
|
503
|
-
|
|
504
|
-
|
|
505
|
-
|
|
506
|
-
|
|
507
|
-
|
|
508
|
-
|
|
509
|
-
|
|
510
|
-
|
|
511
|
-
|
|
512
|
-
|
|
513
|
-
|
|
514
|
-
|
|
515
|
-
|
|
516
|
-
|
|
517
|
-
|
|
518
|
-
|
|
519
|
-
|
|
520
|
-
|
|
521
|
-
|
|
522
|
-
|
|
523
|
-
|
|
524
|
-
|
|
525
|
-
|
|
526
|
-
|
|
527
|
-
|
|
528
|
-
|
|
529
|
-
|
|
530
|
-
|
|
531
|
-
|
|
532
|
-
|
|
533
|
-
|
|
534
|
-
|
|
535
|
-
|
|
536
|
-
|
|
537
|
-
|
|
538
|
-
|
|
539
|
-
|
|
540
|
-
|
|
541
|
-
|
|
542
|
-
|
|
543
|
-
|
|
544
|
-
|
|
545
|
-
|
|
546
|
-
|
|
547
|
-
|
|
548
|
-
|
|
549
|
-
|
|
550
|
-
|
|
551
|
-
|
|
552
|
-
|
|
553
|
-
|
|
554
|
-
|
|
555
|
-
|
|
556
|
-
|
|
557
|
-
|
|
558
|
-
|
|
559
|
-
|
|
560
|
-
|
|
561
|
-
|
|
562
|
-
|
|
563
|
-
|
|
564
|
-
|
|
565
|
-
|
|
566
|
-
|
|
567
|
-
|
|
568
|
-
|
|
569
|
-
|
|
570
|
-
|
|
571
|
-
|
|
572
|
-
|
|
573
|
-
|
|
574
|
-
|
|
575
|
-
|
|
576
|
-
|
|
577
|
-
|
|
578
|
-
|
|
579
|
-
|
|
580
|
-
|
|
581
|
-
|
|
582
|
-
|
|
583
|
-
|
|
584
|
-
|
|
585
|
-
|
|
586
|
-
|
|
587
|
-
|
|
588
|
-
|
|
589
|
-
|
|
590
|
-
|
|
591
|
-
|
|
592
|
-
|
|
593
|
-
|
|
594
|
-
|
|
595
|
-
|
|
596
|
-
|
|
597
|
-
|
|
598
|
-
|
|
599
|
-
|
|
600
|
-
|
|
601
|
-
|
|
602
|
-
|
|
323
|
+
constructor() {
|
|
324
|
+
this.instancesByConstructor = /* @__PURE__ */ new WeakMap();
|
|
325
|
+
this.types = /* @__PURE__ */ new Set();
|
|
326
|
+
this.registeredTypeNames = /* @__PURE__ */ new Set();
|
|
327
|
+
this.listeners = /* @__PURE__ */ new Map();
|
|
328
|
+
this._autoRefIdCounter = 0;
|
|
329
|
+
}
|
|
330
|
+
/**
|
|
331
|
+
* Register a type for lifecycle event tracking
|
|
332
|
+
* @param constructor - The StateContainer class constructor
|
|
333
|
+
*/
|
|
334
|
+
registerType(constructor) {
|
|
335
|
+
this.types.add(constructor);
|
|
336
|
+
}
|
|
337
|
+
/**
|
|
338
|
+
* Register a StateContainer class with configuration
|
|
339
|
+
* @param constructor - The StateContainer class constructor
|
|
340
|
+
* @throws Error if type is already registered
|
|
341
|
+
*/
|
|
342
|
+
register(constructor) {
|
|
343
|
+
const className = constructor.name;
|
|
344
|
+
if (this.registeredTypeNames.has(className))
|
|
345
|
+
throw new Error(
|
|
346
|
+
`${BLAC_ERROR_PREFIX} Type "${className}" is already registered`,
|
|
347
|
+
);
|
|
348
|
+
this.registeredTypeNames.add(className);
|
|
349
|
+
this.registerType(constructor);
|
|
350
|
+
}
|
|
351
|
+
ensureInstancesMap(Type) {
|
|
352
|
+
let instances = this.instancesByConstructor.get(Type);
|
|
353
|
+
if (!instances) {
|
|
354
|
+
instances = /* @__PURE__ */ new Map();
|
|
355
|
+
this.instancesByConstructor.set(Type, instances);
|
|
356
|
+
}
|
|
357
|
+
return instances;
|
|
358
|
+
}
|
|
359
|
+
/**
|
|
360
|
+
* Get the instances Map for a specific class (public API for stats/debugging)
|
|
361
|
+
*/
|
|
362
|
+
getInstancesMap(Type) {
|
|
363
|
+
return this.instancesByConstructor.get(Type) || /* @__PURE__ */ new Map();
|
|
364
|
+
}
|
|
365
|
+
/**
|
|
366
|
+
* Acquire an instance with ref tracking (ownership semantics).
|
|
367
|
+
* Creates a new instance if one doesn't exist, or returns existing and adds a ref.
|
|
368
|
+
* You must call `release()` with the same refId when done.
|
|
369
|
+
* @param Type - The StateContainer class constructor
|
|
370
|
+
* @param instanceKey - Instance key (defaults to 'default')
|
|
371
|
+
* @param options - Acquisition options
|
|
372
|
+
* @param options.canCreate - Whether to create new instance if not found (default: true)
|
|
373
|
+
* @param options.countRef - Whether to add a reference (default: true)
|
|
374
|
+
* @param options.refId - Named reference ID for debugging; auto-generated if omitted
|
|
375
|
+
* @returns The state container instance
|
|
376
|
+
*/
|
|
377
|
+
acquire(
|
|
378
|
+
Type,
|
|
379
|
+
instanceKey = BLAC_DEFAULTS.DEFAULT_INSTANCE_KEY,
|
|
380
|
+
options = {},
|
|
381
|
+
) {
|
|
382
|
+
const { canCreate = true, countRef = true } = options;
|
|
383
|
+
const config = { instanceId: instanceKey };
|
|
384
|
+
const instances = this.ensureInstancesMap(Type);
|
|
385
|
+
let entry = instances.get(instanceKey);
|
|
386
|
+
if (entry?.instance.isDisposed) {
|
|
387
|
+
instances.delete(instanceKey);
|
|
388
|
+
entry = void 0;
|
|
389
|
+
}
|
|
390
|
+
if (entry && countRef) {
|
|
391
|
+
const refId = options.refId ?? `_auto_${this._autoRefIdCounter++}`;
|
|
392
|
+
entry.refs.set(refId, (entry.refs.get(refId) ?? 0) + 1);
|
|
393
|
+
this.emit('refAcquired', entry.instance, refId);
|
|
394
|
+
}
|
|
395
|
+
if (entry) return entry.instance;
|
|
396
|
+
if (!canCreate)
|
|
397
|
+
throw new Error(
|
|
398
|
+
`${BLAC_ERROR_PREFIX} ${Type.name} instance "${instanceKey}" not found and creation is disabled.`,
|
|
399
|
+
);
|
|
400
|
+
const instance = new Type();
|
|
401
|
+
instance.initConfig(config);
|
|
402
|
+
const initialRefs = /* @__PURE__ */ new Map();
|
|
403
|
+
let initialRefId;
|
|
404
|
+
if (countRef) {
|
|
405
|
+
initialRefId = options.refId ?? `_auto_${this._autoRefIdCounter++}`;
|
|
406
|
+
initialRefs.set(initialRefId, 1);
|
|
407
|
+
}
|
|
408
|
+
instances.set(instanceKey, {
|
|
409
|
+
instance,
|
|
410
|
+
refs: initialRefs,
|
|
411
|
+
});
|
|
412
|
+
this.registerType(Type);
|
|
413
|
+
if (initialRefId) this.emit('refAcquired', instance, initialRefId);
|
|
414
|
+
return instance;
|
|
415
|
+
}
|
|
416
|
+
/**
|
|
417
|
+
* Borrow an existing instance without adding a ref (borrowing semantics).
|
|
418
|
+
* Tracks cross-bloc dependency for reactive updates.
|
|
419
|
+
* @param Type - The StateContainer class constructor
|
|
420
|
+
* @param instanceKey - Instance key (defaults to 'default')
|
|
421
|
+
* @returns The state container instance
|
|
422
|
+
* @throws Error if instance doesn't exist
|
|
423
|
+
*/
|
|
424
|
+
borrow(Type, instanceKey = BLAC_DEFAULTS.DEFAULT_INSTANCE_KEY) {
|
|
425
|
+
return this.acquire(Type, instanceKey, {
|
|
426
|
+
canCreate: false,
|
|
427
|
+
countRef: false,
|
|
428
|
+
});
|
|
429
|
+
}
|
|
430
|
+
/**
|
|
431
|
+
* Safely borrow an existing instance (borrowing semantics with error handling).
|
|
432
|
+
* Returns discriminated union for type-safe conditional access.
|
|
433
|
+
* @param Type - The StateContainer class constructor
|
|
434
|
+
* @param instanceKey - Instance key (defaults to 'default')
|
|
435
|
+
* @returns Discriminated union with either the instance or an error
|
|
436
|
+
*/
|
|
437
|
+
borrowSafe(Type, instanceKey = BLAC_DEFAULTS.DEFAULT_INSTANCE_KEY) {
|
|
438
|
+
try {
|
|
439
|
+
return {
|
|
440
|
+
error: null,
|
|
441
|
+
instance: this.borrow(Type, instanceKey),
|
|
442
|
+
};
|
|
443
|
+
} catch (error) {
|
|
444
|
+
return {
|
|
445
|
+
error,
|
|
446
|
+
instance: null,
|
|
447
|
+
};
|
|
448
|
+
}
|
|
449
|
+
}
|
|
450
|
+
/**
|
|
451
|
+
* Ensure an instance exists without taking ownership (for bloc-to-bloc communication).
|
|
452
|
+
* Gets existing instance OR creates it if it doesn't exist, without adding a ref.
|
|
453
|
+
* Tracks cross-bloc dependency for reactive updates.
|
|
454
|
+
*
|
|
455
|
+
* Use this in bloc-to-bloc communication when you need to ensure an instance exists
|
|
456
|
+
* but don't want to claim ownership (no ref added).
|
|
457
|
+
* @param Type - The StateContainer class constructor
|
|
458
|
+
* @param instanceKey - Instance key (defaults to 'default')
|
|
459
|
+
* @returns The state container instance
|
|
460
|
+
*/
|
|
461
|
+
ensure(Type, instanceKey = BLAC_DEFAULTS.DEFAULT_INSTANCE_KEY) {
|
|
462
|
+
return this.acquire(Type, instanceKey, {
|
|
463
|
+
canCreate: true,
|
|
464
|
+
countRef: false,
|
|
465
|
+
});
|
|
466
|
+
}
|
|
467
|
+
/**
|
|
468
|
+
* Release a reference to an instance.
|
|
469
|
+
* Removes the ref and disposes when refs is empty (unless keepAlive).
|
|
470
|
+
* Releasing an already-removed refId is a no-op (idempotent).
|
|
471
|
+
* @param Type - The StateContainer class constructor
|
|
472
|
+
* @param instanceKey - Instance key (defaults to 'default')
|
|
473
|
+
* @param forceDispose - Force immediate disposal regardless of refs
|
|
474
|
+
* @param refId - The specific ref to remove; removes one arbitrary ref if omitted
|
|
475
|
+
*/
|
|
476
|
+
release(
|
|
477
|
+
Type,
|
|
478
|
+
instanceKey = BLAC_DEFAULTS.DEFAULT_INSTANCE_KEY,
|
|
479
|
+
forceDispose = false,
|
|
480
|
+
refId,
|
|
481
|
+
) {
|
|
482
|
+
const instances = this.ensureInstancesMap(Type);
|
|
483
|
+
const entry = instances.get(instanceKey);
|
|
484
|
+
if (!entry) return;
|
|
485
|
+
if (forceDispose) {
|
|
486
|
+
if (!entry.instance.isDisposed) entry.instance.dispose();
|
|
487
|
+
instances.delete(instanceKey);
|
|
488
|
+
return;
|
|
489
|
+
}
|
|
490
|
+
let releasedRefId;
|
|
491
|
+
if (refId !== void 0) {
|
|
492
|
+
const count = entry.refs.get(refId) ?? 0;
|
|
493
|
+
if (count <= 1) entry.refs.delete(refId);
|
|
494
|
+
else entry.refs.set(refId, count - 1);
|
|
495
|
+
releasedRefId = refId;
|
|
496
|
+
} else {
|
|
497
|
+
const firstKey = entry.refs.keys().next().value;
|
|
498
|
+
if (firstKey !== void 0) {
|
|
499
|
+
const count = entry.refs.get(firstKey);
|
|
500
|
+
if (count <= 1) entry.refs.delete(firstKey);
|
|
501
|
+
else entry.refs.set(firstKey, count - 1);
|
|
502
|
+
releasedRefId = firstKey;
|
|
503
|
+
}
|
|
504
|
+
}
|
|
505
|
+
if (releasedRefId) this.emit('refReleased', entry.instance, releasedRefId);
|
|
506
|
+
const keepAlive = isKeepAliveClass(Type);
|
|
507
|
+
if (entry.refs.size === 0 && !keepAlive) {
|
|
508
|
+
if (!entry.instance.isDisposed) entry.instance.dispose();
|
|
509
|
+
instances.delete(instanceKey);
|
|
510
|
+
}
|
|
511
|
+
}
|
|
512
|
+
/**
|
|
513
|
+
* Get all instances of a specific type.
|
|
514
|
+
* @param Type - The StateContainer class constructor
|
|
515
|
+
* @returns Array of all instances
|
|
516
|
+
*/
|
|
517
|
+
getAll(Type) {
|
|
518
|
+
const instances = this.ensureInstancesMap(Type);
|
|
519
|
+
const result = [];
|
|
520
|
+
for (const entry of instances.values()) result.push(entry.instance);
|
|
521
|
+
return result;
|
|
522
|
+
}
|
|
523
|
+
/**
|
|
524
|
+
* Safely iterate over all instances of a type.
|
|
525
|
+
* Skips disposed instances and catches callback errors.
|
|
526
|
+
* @param Type - The StateContainer class constructor
|
|
527
|
+
* @param callback - Function to call for each instance
|
|
528
|
+
*/
|
|
529
|
+
forEach(Type, callback) {
|
|
530
|
+
const instances = this.ensureInstancesMap(Type);
|
|
531
|
+
for (const entry of instances.values()) {
|
|
532
|
+
const instance = entry.instance;
|
|
533
|
+
if (!instance.isDisposed)
|
|
534
|
+
try {
|
|
535
|
+
callback(instance);
|
|
536
|
+
} catch (error) {
|
|
537
|
+
console.error(
|
|
538
|
+
`${BLAC_ERROR_PREFIX} forEach callback error for ${Type.name}:`,
|
|
539
|
+
error,
|
|
540
|
+
);
|
|
541
|
+
}
|
|
542
|
+
}
|
|
543
|
+
}
|
|
544
|
+
/**
|
|
545
|
+
* Clear all instances of a specific type (disposes them).
|
|
546
|
+
* @param Type - The StateContainer class constructor
|
|
547
|
+
*/
|
|
548
|
+
clear(Type) {
|
|
549
|
+
const instances = this.ensureInstancesMap(Type);
|
|
550
|
+
for (const entry of instances.values())
|
|
551
|
+
if (!entry.instance.isDisposed) entry.instance.dispose();
|
|
552
|
+
instances.clear();
|
|
553
|
+
}
|
|
554
|
+
/**
|
|
555
|
+
* Get reference count for an instance (number of active refs).
|
|
556
|
+
* @param Type - The StateContainer class constructor
|
|
557
|
+
* @param instanceKey - Instance key (defaults to 'default')
|
|
558
|
+
* @returns Current ref count (0 if instance doesn't exist)
|
|
559
|
+
*/
|
|
560
|
+
getRefCount(Type, instanceKey = BLAC_DEFAULTS.DEFAULT_INSTANCE_KEY) {
|
|
561
|
+
return this.ensureInstancesMap(Type).get(instanceKey)?.refs.size ?? 0;
|
|
562
|
+
}
|
|
563
|
+
/**
|
|
564
|
+
* Get all active reference IDs for an instance.
|
|
565
|
+
* @param Type - The StateContainer class constructor
|
|
566
|
+
* @param instanceKey - Instance key (defaults to 'default')
|
|
567
|
+
* @returns Array of ref ID strings (empty if instance doesn't exist)
|
|
568
|
+
*/
|
|
569
|
+
getRefIds(Type, instanceKey = BLAC_DEFAULTS.DEFAULT_INSTANCE_KEY) {
|
|
570
|
+
const instances = this.instancesByConstructor.get(Type);
|
|
571
|
+
if (!instances) return [];
|
|
572
|
+
const entry = instances.get(instanceKey);
|
|
573
|
+
return entry ? Array.from(entry.refs.keys()) : [];
|
|
574
|
+
}
|
|
575
|
+
/**
|
|
576
|
+
* Check if an instance exists.
|
|
577
|
+
* @param Type - The StateContainer class constructor
|
|
578
|
+
* @param instanceKey - Instance key (defaults to 'default')
|
|
579
|
+
* @returns true if instance exists
|
|
580
|
+
*/
|
|
581
|
+
hasInstance(Type, instanceKey = BLAC_DEFAULTS.DEFAULT_INSTANCE_KEY) {
|
|
582
|
+
return this.ensureInstancesMap(Type).has(instanceKey);
|
|
583
|
+
}
|
|
584
|
+
/**
|
|
585
|
+
* Clear all instances from all types (for testing)
|
|
586
|
+
*
|
|
587
|
+
* Iterates all registered types and clears their instances.
|
|
588
|
+
* Also clears type tracking to reset the registry state.
|
|
589
|
+
*/
|
|
590
|
+
clearAll() {
|
|
591
|
+
for (const Type of this.types) this.clear(Type);
|
|
592
|
+
this.types.clear();
|
|
593
|
+
this.registeredTypeNames.clear();
|
|
594
|
+
}
|
|
595
|
+
/**
|
|
596
|
+
* Get registry statistics for debugging.
|
|
597
|
+
* @returns Object with registeredTypes, totalInstances, and typeBreakdown
|
|
598
|
+
*/
|
|
599
|
+
getStats() {
|
|
600
|
+
const typeBreakdown = {};
|
|
601
|
+
let totalInstances = 0;
|
|
602
|
+
for (const Type of this.types) {
|
|
603
|
+
const typeName = Type.name;
|
|
604
|
+
const count = this.getInstancesMap(Type).size;
|
|
605
|
+
typeBreakdown[typeName] = count;
|
|
606
|
+
totalInstances += count;
|
|
607
|
+
}
|
|
608
|
+
return {
|
|
609
|
+
registeredTypes: this.types.size,
|
|
610
|
+
totalInstances,
|
|
611
|
+
typeBreakdown,
|
|
612
|
+
};
|
|
613
|
+
}
|
|
614
|
+
/**
|
|
615
|
+
* Get all registered types (for plugin system).
|
|
616
|
+
* @returns Array of all registered StateContainer class constructors
|
|
617
|
+
*/
|
|
618
|
+
getTypes() {
|
|
619
|
+
return Array.from(this.types);
|
|
620
|
+
}
|
|
621
|
+
/**
|
|
622
|
+
* Subscribe to lifecycle events
|
|
623
|
+
* @param event - The lifecycle event to listen for
|
|
624
|
+
* @param listener - The listener function to call when the event occurs
|
|
625
|
+
* @returns Unsubscribe function
|
|
626
|
+
*/
|
|
627
|
+
on(event, listener) {
|
|
628
|
+
if (!this.listeners.has(event))
|
|
629
|
+
this.listeners.set(event, /* @__PURE__ */ new Set());
|
|
630
|
+
const instance = this.listeners.get(event);
|
|
631
|
+
if (!instance)
|
|
632
|
+
throw new Error(
|
|
633
|
+
`${BLAC_ERROR_PREFIX} Failed to register listener for event '${event}'`,
|
|
634
|
+
);
|
|
635
|
+
instance.add(listener);
|
|
636
|
+
return () => {
|
|
637
|
+
this.listeners.get(event)?.delete(listener);
|
|
638
|
+
};
|
|
639
|
+
}
|
|
640
|
+
/**
|
|
641
|
+
* Emit lifecycle event to all listeners
|
|
642
|
+
* @internal - Called by StateContainer lifecycle methods
|
|
643
|
+
*/
|
|
644
|
+
emit(event, ...args) {
|
|
645
|
+
const listeners = this.listeners.get(event);
|
|
646
|
+
if (!listeners || listeners.size === 0) return;
|
|
647
|
+
for (const listener of listeners)
|
|
648
|
+
try {
|
|
649
|
+
listener(...args);
|
|
650
|
+
} catch (error) {
|
|
651
|
+
console.error(
|
|
652
|
+
`${BLAC_ERROR_PREFIX} Listener error for '${event}':`,
|
|
653
|
+
error,
|
|
654
|
+
);
|
|
655
|
+
}
|
|
656
|
+
}
|
|
603
657
|
};
|
|
604
658
|
/**
|
|
605
|
-
* Global default registry instance
|
|
606
|
-
*/
|
|
659
|
+
* Global default registry instance
|
|
660
|
+
*/
|
|
607
661
|
const globalRegistry = new StateContainerRegistry();
|
|
608
662
|
/**
|
|
609
|
-
* Global plugin manager (initialized lazily)
|
|
610
|
-
*/
|
|
663
|
+
* Global plugin manager (initialized lazily)
|
|
664
|
+
*/
|
|
611
665
|
let _globalPluginManager = null;
|
|
612
666
|
/**
|
|
613
|
-
* Get the global plugin manager
|
|
614
|
-
*/
|
|
667
|
+
* Get the global plugin manager
|
|
668
|
+
*/
|
|
615
669
|
function getPluginManager() {
|
|
616
|
-
|
|
617
|
-
|
|
670
|
+
if (!_globalPluginManager)
|
|
671
|
+
_globalPluginManager = createPluginManager(globalRegistry);
|
|
672
|
+
return _globalPluginManager;
|
|
618
673
|
}
|
|
619
674
|
//#endregion
|
|
620
|
-
Object.defineProperty(exports,
|
|
621
|
-
|
|
622
|
-
|
|
623
|
-
|
|
624
|
-
|
|
675
|
+
Object.defineProperty(exports, 'BLAC_DEFAULTS', {
|
|
676
|
+
enumerable: true,
|
|
677
|
+
get: function () {
|
|
678
|
+
return BLAC_DEFAULTS;
|
|
679
|
+
},
|
|
625
680
|
});
|
|
626
|
-
Object.defineProperty(exports,
|
|
627
|
-
|
|
628
|
-
|
|
629
|
-
|
|
630
|
-
|
|
681
|
+
Object.defineProperty(exports, 'BLAC_ERROR_PREFIX', {
|
|
682
|
+
enumerable: true,
|
|
683
|
+
get: function () {
|
|
684
|
+
return BLAC_ERROR_PREFIX;
|
|
685
|
+
},
|
|
631
686
|
});
|
|
632
|
-
Object.defineProperty(exports,
|
|
633
|
-
|
|
634
|
-
|
|
635
|
-
|
|
636
|
-
|
|
687
|
+
Object.defineProperty(exports, 'BLAC_STATIC_PROPS', {
|
|
688
|
+
enumerable: true,
|
|
689
|
+
get: function () {
|
|
690
|
+
return BLAC_STATIC_PROPS;
|
|
691
|
+
},
|
|
637
692
|
});
|
|
638
|
-
Object.defineProperty(exports,
|
|
639
|
-
|
|
640
|
-
|
|
641
|
-
|
|
642
|
-
|
|
693
|
+
Object.defineProperty(exports, 'PluginManager', {
|
|
694
|
+
enumerable: true,
|
|
695
|
+
get: function () {
|
|
696
|
+
return PluginManager;
|
|
697
|
+
},
|
|
643
698
|
});
|
|
644
|
-
Object.defineProperty(exports,
|
|
645
|
-
|
|
646
|
-
|
|
647
|
-
|
|
648
|
-
|
|
699
|
+
Object.defineProperty(exports, 'StateContainerRegistry', {
|
|
700
|
+
enumerable: true,
|
|
701
|
+
get: function () {
|
|
702
|
+
return StateContainerRegistry;
|
|
703
|
+
},
|
|
649
704
|
});
|
|
650
|
-
Object.defineProperty(exports,
|
|
651
|
-
|
|
652
|
-
|
|
653
|
-
|
|
654
|
-
|
|
705
|
+
Object.defineProperty(exports, 'getPluginManager', {
|
|
706
|
+
enumerable: true,
|
|
707
|
+
get: function () {
|
|
708
|
+
return getPluginManager;
|
|
709
|
+
},
|
|
655
710
|
});
|
|
656
|
-
Object.defineProperty(exports,
|
|
657
|
-
|
|
658
|
-
|
|
659
|
-
|
|
660
|
-
|
|
711
|
+
Object.defineProperty(exports, 'globalRegistry', {
|
|
712
|
+
enumerable: true,
|
|
713
|
+
get: function () {
|
|
714
|
+
return globalRegistry;
|
|
715
|
+
},
|
|
661
716
|
});
|
|
662
717
|
|
|
663
|
-
//# sourceMappingURL=StateContainerRegistry-mseeTqSA.cjs.map
|
|
718
|
+
//# sourceMappingURL=StateContainerRegistry-mseeTqSA.cjs.map
|