@blac/core 2.0.17 → 2.0.19
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 +7 -1
- package/dist/StateContainerRegistry-4Ljd9EJx.js +1018 -0
- package/dist/StateContainerRegistry-4Ljd9EJx.js.map +1 -0
- package/dist/StateContainerRegistry-C0dCNlTF.js +1005 -0
- package/dist/StateContainerRegistry-C0dCNlTF.js.map +1 -0
- package/dist/StateContainerRegistry-CEWpc1bj.cjs +1113 -0
- package/dist/StateContainerRegistry-CEWpc1bj.cjs.map +1 -0
- package/dist/StateContainerRegistry-CSNm2Ws5.cjs +1085 -0
- package/dist/StateContainerRegistry-CSNm2Ws5.cjs.map +1 -0
- package/dist/StateContainerRegistry-CchRjnjX.cjs +1094 -0
- package/dist/StateContainerRegistry-CchRjnjX.cjs.map +1 -0
- package/dist/StateContainerRegistry-CvBOhAT2.js +996 -0
- package/dist/StateContainerRegistry-CvBOhAT2.js.map +1 -0
- package/dist/StateContainerRegistry-D9BIRjwv.cjs +1088 -0
- package/dist/StateContainerRegistry-D9BIRjwv.cjs.map +1 -0
- package/dist/StateContainerRegistry-DVIBTxGZ.js +999 -0
- package/dist/StateContainerRegistry-DVIBTxGZ.js.map +1 -0
- package/dist/StateContainerRegistry-Dj77cok9.js +1005 -0
- package/dist/StateContainerRegistry-Dj77cok9.js.map +1 -0
- package/dist/StateContainerRegistry-lIwo-0m3.cjs +1094 -0
- package/dist/StateContainerRegistry-lIwo-0m3.cjs.map +1 -0
- package/dist/acquire-B1Wuqla6.cjs +46 -0
- package/dist/acquire-B1Wuqla6.cjs.map +1 -0
- package/dist/acquire-BP-ZfUH2.js +35 -0
- package/dist/acquire-BP-ZfUH2.js.map +1 -0
- package/dist/acquire-BRIJVJaA.js +35 -0
- package/dist/acquire-BRIJVJaA.js.map +1 -0
- package/dist/acquire-BZIs6tpN.cjs +46 -0
- package/dist/acquire-BZIs6tpN.cjs.map +1 -0
- package/dist/acquire-C3nOb3XR.cjs +46 -0
- package/dist/acquire-C3nOb3XR.cjs.map +1 -0
- package/dist/acquire-C4WAS13G.cjs +46 -0
- package/dist/acquire-C4WAS13G.cjs.map +1 -0
- package/dist/acquire-C7beGI55.cjs +46 -0
- package/dist/acquire-C7beGI55.cjs.map +1 -0
- package/dist/acquire-CwB083au.js +35 -0
- package/dist/acquire-CwB083au.js.map +1 -0
- package/dist/acquire-DXEQDZGr.js +35 -0
- package/dist/acquire-DXEQDZGr.js.map +1 -0
- package/dist/acquire-Dg-uXwjF.js +35 -0
- package/dist/acquire-Dg-uXwjF.js.map +1 -0
- package/dist/config-B1l8ZGlU.cjs +32 -0
- package/dist/config-B1l8ZGlU.cjs.map +1 -0
- package/dist/config-C7Ktkjh2.cjs +32 -0
- package/dist/config-C7Ktkjh2.cjs.map +1 -0
- package/dist/config-COT4Xkbc.js +16 -0
- package/dist/config-COT4Xkbc.js.map +1 -0
- package/dist/config-CzcoAvBo.js +16 -0
- package/dist/config-CzcoAvBo.js.map +1 -0
- package/dist/config-D6BoWWPv.js +16 -0
- package/dist/config-D6BoWWPv.js.map +1 -0
- package/dist/config-DVM_ESQt.js +16 -0
- package/dist/config-DVM_ESQt.js.map +1 -0
- package/dist/config-b2z51Y_C.cjs +32 -0
- package/dist/config-b2z51Y_C.cjs.map +1 -0
- package/dist/config-buwpT7l3.js +16 -0
- package/dist/config-buwpT7l3.js.map +1 -0
- package/dist/config-d9_U58ef.cjs +32 -0
- package/dist/config-d9_U58ef.cjs.map +1 -0
- package/dist/config-hWTayX76.cjs +32 -0
- package/dist/config-hWTayX76.cjs.map +1 -0
- package/dist/core/Cubit.d.ts +4 -4
- package/dist/core/StateContainer.d.ts +34 -38
- package/dist/core/StateContainerRegistry.d.ts +5 -4
- package/dist/core/meta.d.ts +73 -0
- package/dist/core/symbols.d.ts +10 -17
- package/dist/debug.cjs +3 -3
- package/dist/debug.js +3 -3
- package/dist/ensure-B1dEDsZV.cjs +559 -0
- package/dist/ensure-B1dEDsZV.cjs.map +1 -0
- package/dist/ensure-B9oOqpOB.cjs +558 -0
- package/dist/ensure-B9oOqpOB.cjs.map +1 -0
- package/dist/ensure-BfYnvAsI.js +709 -0
- package/dist/ensure-BfYnvAsI.js.map +1 -0
- package/dist/ensure-Bm91o37h.js +536 -0
- package/dist/ensure-Bm91o37h.js.map +1 -0
- package/dist/ensure-C1a8IFWy.js +535 -0
- package/dist/ensure-C1a8IFWy.js.map +1 -0
- package/dist/ensure-CQimeD0I.cjs +559 -0
- package/dist/ensure-CQimeD0I.cjs.map +1 -0
- package/dist/ensure-DTTTd2h8.js +536 -0
- package/dist/ensure-DTTTd2h8.js.map +1 -0
- package/dist/ensure-VuiNPccZ.cjs +559 -0
- package/dist/ensure-VuiNPccZ.cjs.map +1 -0
- package/dist/ensure-_Oh8XPm4.cjs +732 -0
- package/dist/ensure-_Oh8XPm4.cjs.map +1 -0
- package/dist/ensure-vxAGa2v3.js +536 -0
- package/dist/ensure-vxAGa2v3.js.map +1 -0
- package/dist/index.cjs +9 -9
- package/dist/index.d.cts +4 -7
- package/dist/index.d.ts +4 -7
- package/dist/index.js +7 -7
- package/dist/management-14vsHr4t.cjs +85 -0
- package/dist/management-14vsHr4t.cjs.map +1 -0
- package/dist/management-AFuqQEwz.js +38 -0
- package/dist/management-AFuqQEwz.js.map +1 -0
- package/dist/management-BodVLAfJ.cjs +85 -0
- package/dist/management-BodVLAfJ.cjs.map +1 -0
- package/dist/management-BqGBdL01.js +38 -0
- package/dist/management-BqGBdL01.js.map +1 -0
- package/dist/management-BvUAjril.js +38 -0
- package/dist/management-BvUAjril.js.map +1 -0
- package/dist/management-C2wv4vGS.cjs +85 -0
- package/dist/management-C2wv4vGS.cjs.map +1 -0
- package/dist/management-D2pjr38g.js +38 -0
- package/dist/management-D2pjr38g.js.map +1 -0
- package/dist/management-D5WsZoTV.js +38 -0
- package/dist/management-D5WsZoTV.js.map +1 -0
- package/dist/management-Df7Y2sF1.cjs +85 -0
- package/dist/management-Df7Y2sF1.cjs.map +1 -0
- package/dist/management-DwO0nBzL.cjs +85 -0
- package/dist/management-DwO0nBzL.cjs.map +1 -0
- package/dist/plugin/BlacPlugin.d.ts +11 -12
- package/dist/plugin/PluginManager.d.ts +5 -4
- package/dist/plugins.cjs +1 -1
- package/dist/plugins.js +1 -1
- package/dist/testing.cjs +10 -15
- package/dist/testing.cjs.map +1 -1
- package/dist/testing.d.cts +4 -6
- package/dist/testing.d.ts +4 -6
- package/dist/testing.js +10 -14
- package/dist/testing.js.map +1 -1
- package/dist/watch/watch.d.ts +6 -0
- package/dist/watch-BHfCtbn1.cjs +119 -0
- package/dist/watch-BHfCtbn1.cjs.map +1 -0
- package/dist/watch-CfrSSrRY.js +59 -0
- package/dist/watch-CfrSSrRY.js.map +1 -0
- package/dist/watch-Cnh3PtQA.cjs +70 -0
- package/dist/watch-Cnh3PtQA.cjs.map +1 -0
- package/dist/watch-D01MdwKy.js +108 -0
- package/dist/watch-D01MdwKy.js.map +1 -0
- package/dist/watch-D8hwbFU1.js +59 -0
- package/dist/watch-D8hwbFU1.js.map +1 -0
- package/dist/watch-DVmvZBMD.cjs +70 -0
- package/dist/watch-DVmvZBMD.cjs.map +1 -0
- package/dist/watch-DkDGmGAx.cjs +119 -0
- package/dist/watch-DkDGmGAx.cjs.map +1 -0
- package/dist/watch-DztcJuUy.cjs +119 -0
- package/dist/watch-DztcJuUy.cjs.map +1 -0
- package/dist/watch-IrR8G28N.js +108 -0
- package/dist/watch-IrR8G28N.js.map +1 -0
- package/dist/watch-entry.cjs +1 -1
- package/dist/watch-entry.js +1 -1
- package/dist/watch-hx0r92Zc.js +108 -0
- package/dist/watch-hx0r92Zc.js.map +1 -0
- package/package.json +3 -3
|
@@ -0,0 +1,38 @@
|
|
|
1
|
+
import { t as getRegistry } from "./config-DVM_ESQt.js";
|
|
2
|
+
//#region src/registry/queries.ts
|
|
3
|
+
function hasInstance(BlocClass, opts) {
|
|
4
|
+
const registry = getRegistry();
|
|
5
|
+
const key = registry.resolveKey(BlocClass, void 0, opts?.args);
|
|
6
|
+
return registry.hasInstance(BlocClass, key);
|
|
7
|
+
}
|
|
8
|
+
function getRefCount(BlocClass, opts) {
|
|
9
|
+
const registry = getRegistry();
|
|
10
|
+
const key = registry.resolveKey(BlocClass, void 0, opts?.args);
|
|
11
|
+
return registry.getRefCount(BlocClass, key);
|
|
12
|
+
}
|
|
13
|
+
function getRefIds(BlocClass, opts) {
|
|
14
|
+
const registry = getRegistry();
|
|
15
|
+
const key = registry.resolveKey(BlocClass, void 0, opts?.args);
|
|
16
|
+
return registry.getRefIds(BlocClass, key);
|
|
17
|
+
}
|
|
18
|
+
function getAll(BlocClass) {
|
|
19
|
+
return getRegistry().getAll(BlocClass);
|
|
20
|
+
}
|
|
21
|
+
function forEach(BlocClass, callback) {
|
|
22
|
+
getRegistry().forEach(BlocClass, callback);
|
|
23
|
+
}
|
|
24
|
+
//#endregion
|
|
25
|
+
//#region src/registry/management.ts
|
|
26
|
+
function clear(BlocClass) {
|
|
27
|
+
getRegistry().clear(BlocClass);
|
|
28
|
+
}
|
|
29
|
+
function clearAll() {
|
|
30
|
+
getRegistry().clearAll();
|
|
31
|
+
}
|
|
32
|
+
function register(BlocClass) {
|
|
33
|
+
getRegistry().register(BlocClass);
|
|
34
|
+
}
|
|
35
|
+
//#endregion
|
|
36
|
+
export { getAll as a, hasInstance as c, forEach as i, clearAll as n, getRefCount as o, register as r, getRefIds as s, clear as t };
|
|
37
|
+
|
|
38
|
+
//# sourceMappingURL=management-D2pjr38g.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"management-D2pjr38g.js","names":[],"sources":["../src/registry/queries.ts","../src/registry/management.ts"],"sourcesContent":["import { getRegistry } from './config';\nimport type {\n ExtractArgs,\n StateContainerConstructor,\n InstanceReadonlyState,\n} from '../types/utilities';\n\nexport function hasInstance<T extends StateContainerConstructor>(\n BlocClass: T,\n opts?: { args?: ExtractArgs<T> },\n): boolean {\n const registry = getRegistry();\n const key = registry.resolveKey(BlocClass, undefined, opts?.args);\n return registry.hasInstance(BlocClass, key);\n}\n\nexport function getRefCount<T extends StateContainerConstructor>(\n BlocClass: T,\n opts?: { args?: ExtractArgs<T> },\n): number {\n const registry = getRegistry();\n const key = registry.resolveKey(BlocClass, undefined, opts?.args);\n return registry.getRefCount(BlocClass, key);\n}\n\nexport function getRefIds<T extends StateContainerConstructor>(\n BlocClass: T,\n opts?: { args?: ExtractArgs<T> },\n): string[] {\n const registry = getRegistry();\n const key = registry.resolveKey(BlocClass, undefined, opts?.args);\n return registry.getRefIds(BlocClass, key);\n}\n\nexport function getAll<T extends StateContainerConstructor>(\n BlocClass: T,\n): InstanceReadonlyState<T>[] {\n return getRegistry().getAll(BlocClass);\n}\n\nexport function forEach<T extends StateContainerConstructor>(\n BlocClass: T,\n callback: (instance: InstanceReadonlyState<T>) => void,\n): void {\n getRegistry().forEach(BlocClass, callback);\n}\n","import { getRegistry } from './config';\nimport type { StateContainerConstructor } from '../types/utilities';\n\nexport function clear<T extends StateContainerConstructor>(BlocClass: T): void {\n getRegistry().clear(BlocClass);\n}\n\nexport function clearAll(): void {\n getRegistry().clearAll();\n}\n\nexport function register<T extends StateContainerConstructor>(\n BlocClass: T,\n): void {\n getRegistry().register(BlocClass);\n}\n"],"mappings":";;AAOA,SAAgB,YACd,WACA,MACS;CACT,MAAM,WAAW,YAAY;CAC7B,MAAM,MAAM,SAAS,WAAW,WAAW,KAAA,GAAW,MAAM,IAAI;CAChE,OAAO,SAAS,YAAY,WAAW,GAAG;AAC5C;AAEA,SAAgB,YACd,WACA,MACQ;CACR,MAAM,WAAW,YAAY;CAC7B,MAAM,MAAM,SAAS,WAAW,WAAW,KAAA,GAAW,MAAM,IAAI;CAChE,OAAO,SAAS,YAAY,WAAW,GAAG;AAC5C;AAEA,SAAgB,UACd,WACA,MACU;CACV,MAAM,WAAW,YAAY;CAC7B,MAAM,MAAM,SAAS,WAAW,WAAW,KAAA,GAAW,MAAM,IAAI;CAChE,OAAO,SAAS,UAAU,WAAW,GAAG;AAC1C;AAEA,SAAgB,OACd,WAC4B;CAC5B,OAAO,YAAY,EAAE,OAAO,SAAS;AACvC;AAEA,SAAgB,QACd,WACA,UACM;CACN,YAAY,EAAE,QAAQ,WAAW,QAAQ;AAC3C;;;AC1CA,SAAgB,MAA2C,WAAoB;CAC7E,YAAY,EAAE,MAAM,SAAS;AAC/B;AAEA,SAAgB,WAAiB;CAC/B,YAAY,EAAE,SAAS;AACzB;AAEA,SAAgB,SACd,WACM;CACN,YAAY,EAAE,SAAS,SAAS;AAClC"}
|
|
@@ -0,0 +1,38 @@
|
|
|
1
|
+
import { t as getRegistry } from "./config-D6BoWWPv.js";
|
|
2
|
+
//#region src/registry/queries.ts
|
|
3
|
+
function hasInstance(BlocClass, opts) {
|
|
4
|
+
const registry = getRegistry();
|
|
5
|
+
const key = registry.resolveKey(BlocClass, void 0, opts?.args);
|
|
6
|
+
return registry.hasInstance(BlocClass, key);
|
|
7
|
+
}
|
|
8
|
+
function getRefCount(BlocClass, opts) {
|
|
9
|
+
const registry = getRegistry();
|
|
10
|
+
const key = registry.resolveKey(BlocClass, void 0, opts?.args);
|
|
11
|
+
return registry.getRefCount(BlocClass, key);
|
|
12
|
+
}
|
|
13
|
+
function getRefIds(BlocClass, opts) {
|
|
14
|
+
const registry = getRegistry();
|
|
15
|
+
const key = registry.resolveKey(BlocClass, void 0, opts?.args);
|
|
16
|
+
return registry.getRefIds(BlocClass, key);
|
|
17
|
+
}
|
|
18
|
+
function getAll(BlocClass) {
|
|
19
|
+
return getRegistry().getAll(BlocClass);
|
|
20
|
+
}
|
|
21
|
+
function forEach(BlocClass, callback) {
|
|
22
|
+
getRegistry().forEach(BlocClass, callback);
|
|
23
|
+
}
|
|
24
|
+
//#endregion
|
|
25
|
+
//#region src/registry/management.ts
|
|
26
|
+
function clear(BlocClass) {
|
|
27
|
+
getRegistry().clear(BlocClass);
|
|
28
|
+
}
|
|
29
|
+
function clearAll() {
|
|
30
|
+
getRegistry().clearAll();
|
|
31
|
+
}
|
|
32
|
+
function register(BlocClass) {
|
|
33
|
+
getRegistry().register(BlocClass);
|
|
34
|
+
}
|
|
35
|
+
//#endregion
|
|
36
|
+
export { getAll as a, hasInstance as c, forEach as i, clearAll as n, getRefCount as o, register as r, getRefIds as s, clear as t };
|
|
37
|
+
|
|
38
|
+
//# sourceMappingURL=management-D5WsZoTV.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"management-D5WsZoTV.js","names":[],"sources":["../src/registry/queries.ts","../src/registry/management.ts"],"sourcesContent":["import { getRegistry } from './config';\nimport type {\n ExtractArgs,\n StateContainerConstructor,\n InstanceReadonlyState,\n} from '../types/utilities';\n\nexport function hasInstance<T extends StateContainerConstructor>(\n BlocClass: T,\n opts?: { args?: ExtractArgs<T> },\n): boolean {\n const registry = getRegistry();\n const key = registry.resolveKey(BlocClass, undefined, opts?.args);\n return registry.hasInstance(BlocClass, key);\n}\n\nexport function getRefCount<T extends StateContainerConstructor>(\n BlocClass: T,\n opts?: { args?: ExtractArgs<T> },\n): number {\n const registry = getRegistry();\n const key = registry.resolveKey(BlocClass, undefined, opts?.args);\n return registry.getRefCount(BlocClass, key);\n}\n\nexport function getRefIds<T extends StateContainerConstructor>(\n BlocClass: T,\n opts?: { args?: ExtractArgs<T> },\n): string[] {\n const registry = getRegistry();\n const key = registry.resolveKey(BlocClass, undefined, opts?.args);\n return registry.getRefIds(BlocClass, key);\n}\n\nexport function getAll<T extends StateContainerConstructor>(\n BlocClass: T,\n): InstanceReadonlyState<T>[] {\n return getRegistry().getAll(BlocClass);\n}\n\nexport function forEach<T extends StateContainerConstructor>(\n BlocClass: T,\n callback: (instance: InstanceReadonlyState<T>) => void,\n): void {\n getRegistry().forEach(BlocClass, callback);\n}\n","import { getRegistry } from './config';\nimport type { StateContainerConstructor } from '../types/utilities';\n\nexport function clear<T extends StateContainerConstructor>(BlocClass: T): void {\n getRegistry().clear(BlocClass);\n}\n\nexport function clearAll(): void {\n getRegistry().clearAll();\n}\n\nexport function register<T extends StateContainerConstructor>(\n BlocClass: T,\n): void {\n getRegistry().register(BlocClass);\n}\n"],"mappings":";;AAOA,SAAgB,YACd,WACA,MACS;CACT,MAAM,WAAW,YAAY;CAC7B,MAAM,MAAM,SAAS,WAAW,WAAW,KAAA,GAAW,MAAM,IAAI;CAChE,OAAO,SAAS,YAAY,WAAW,GAAG;AAC5C;AAEA,SAAgB,YACd,WACA,MACQ;CACR,MAAM,WAAW,YAAY;CAC7B,MAAM,MAAM,SAAS,WAAW,WAAW,KAAA,GAAW,MAAM,IAAI;CAChE,OAAO,SAAS,YAAY,WAAW,GAAG;AAC5C;AAEA,SAAgB,UACd,WACA,MACU;CACV,MAAM,WAAW,YAAY;CAC7B,MAAM,MAAM,SAAS,WAAW,WAAW,KAAA,GAAW,MAAM,IAAI;CAChE,OAAO,SAAS,UAAU,WAAW,GAAG;AAC1C;AAEA,SAAgB,OACd,WAC4B;CAC5B,OAAO,YAAY,EAAE,OAAO,SAAS;AACvC;AAEA,SAAgB,QACd,WACA,UACM;CACN,YAAY,EAAE,QAAQ,WAAW,QAAQ;AAC3C;;;AC1CA,SAAgB,MAA2C,WAAoB;CAC7E,YAAY,EAAE,MAAM,SAAS;AAC/B;AAEA,SAAgB,WAAiB;CAC/B,YAAY,EAAE,SAAS;AACzB;AAEA,SAAgB,SACd,WACM;CACN,YAAY,EAAE,SAAS,SAAS;AAClC"}
|
|
@@ -0,0 +1,85 @@
|
|
|
1
|
+
const require_config = require("./config-b2z51Y_C.cjs");
|
|
2
|
+
//#region src/registry/queries.ts
|
|
3
|
+
function hasInstance(BlocClass, opts) {
|
|
4
|
+
const registry = require_config.getRegistry();
|
|
5
|
+
const key = registry.resolveKey(BlocClass, void 0, opts?.args);
|
|
6
|
+
return registry.hasInstance(BlocClass, key);
|
|
7
|
+
}
|
|
8
|
+
function getRefCount(BlocClass, opts) {
|
|
9
|
+
const registry = require_config.getRegistry();
|
|
10
|
+
const key = registry.resolveKey(BlocClass, void 0, opts?.args);
|
|
11
|
+
return registry.getRefCount(BlocClass, key);
|
|
12
|
+
}
|
|
13
|
+
function getRefIds(BlocClass, opts) {
|
|
14
|
+
const registry = require_config.getRegistry();
|
|
15
|
+
const key = registry.resolveKey(BlocClass, void 0, opts?.args);
|
|
16
|
+
return registry.getRefIds(BlocClass, key);
|
|
17
|
+
}
|
|
18
|
+
function getAll(BlocClass) {
|
|
19
|
+
return require_config.getRegistry().getAll(BlocClass);
|
|
20
|
+
}
|
|
21
|
+
function forEach(BlocClass, callback) {
|
|
22
|
+
require_config.getRegistry().forEach(BlocClass, callback);
|
|
23
|
+
}
|
|
24
|
+
//#endregion
|
|
25
|
+
//#region src/registry/management.ts
|
|
26
|
+
function clear(BlocClass) {
|
|
27
|
+
require_config.getRegistry().clear(BlocClass);
|
|
28
|
+
}
|
|
29
|
+
function clearAll() {
|
|
30
|
+
require_config.getRegistry().clearAll();
|
|
31
|
+
}
|
|
32
|
+
function register(BlocClass) {
|
|
33
|
+
require_config.getRegistry().register(BlocClass);
|
|
34
|
+
}
|
|
35
|
+
//#endregion
|
|
36
|
+
Object.defineProperty(exports, "clear", {
|
|
37
|
+
enumerable: true,
|
|
38
|
+
get: function() {
|
|
39
|
+
return clear;
|
|
40
|
+
}
|
|
41
|
+
});
|
|
42
|
+
Object.defineProperty(exports, "clearAll", {
|
|
43
|
+
enumerable: true,
|
|
44
|
+
get: function() {
|
|
45
|
+
return clearAll;
|
|
46
|
+
}
|
|
47
|
+
});
|
|
48
|
+
Object.defineProperty(exports, "forEach", {
|
|
49
|
+
enumerable: true,
|
|
50
|
+
get: function() {
|
|
51
|
+
return forEach;
|
|
52
|
+
}
|
|
53
|
+
});
|
|
54
|
+
Object.defineProperty(exports, "getAll", {
|
|
55
|
+
enumerable: true,
|
|
56
|
+
get: function() {
|
|
57
|
+
return getAll;
|
|
58
|
+
}
|
|
59
|
+
});
|
|
60
|
+
Object.defineProperty(exports, "getRefCount", {
|
|
61
|
+
enumerable: true,
|
|
62
|
+
get: function() {
|
|
63
|
+
return getRefCount;
|
|
64
|
+
}
|
|
65
|
+
});
|
|
66
|
+
Object.defineProperty(exports, "getRefIds", {
|
|
67
|
+
enumerable: true,
|
|
68
|
+
get: function() {
|
|
69
|
+
return getRefIds;
|
|
70
|
+
}
|
|
71
|
+
});
|
|
72
|
+
Object.defineProperty(exports, "hasInstance", {
|
|
73
|
+
enumerable: true,
|
|
74
|
+
get: function() {
|
|
75
|
+
return hasInstance;
|
|
76
|
+
}
|
|
77
|
+
});
|
|
78
|
+
Object.defineProperty(exports, "register", {
|
|
79
|
+
enumerable: true,
|
|
80
|
+
get: function() {
|
|
81
|
+
return register;
|
|
82
|
+
}
|
|
83
|
+
});
|
|
84
|
+
|
|
85
|
+
//# sourceMappingURL=management-Df7Y2sF1.cjs.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"management-Df7Y2sF1.cjs","names":["getRegistry"],"sources":["../src/registry/queries.ts","../src/registry/management.ts"],"sourcesContent":["import { getRegistry } from './config';\nimport type {\n ExtractArgs,\n StateContainerConstructor,\n InstanceReadonlyState,\n} from '../types/utilities';\n\nexport function hasInstance<T extends StateContainerConstructor>(\n BlocClass: T,\n opts?: { args?: ExtractArgs<T> },\n): boolean {\n const registry = getRegistry();\n const key = registry.resolveKey(BlocClass, undefined, opts?.args);\n return registry.hasInstance(BlocClass, key);\n}\n\nexport function getRefCount<T extends StateContainerConstructor>(\n BlocClass: T,\n opts?: { args?: ExtractArgs<T> },\n): number {\n const registry = getRegistry();\n const key = registry.resolveKey(BlocClass, undefined, opts?.args);\n return registry.getRefCount(BlocClass, key);\n}\n\nexport function getRefIds<T extends StateContainerConstructor>(\n BlocClass: T,\n opts?: { args?: ExtractArgs<T> },\n): string[] {\n const registry = getRegistry();\n const key = registry.resolveKey(BlocClass, undefined, opts?.args);\n return registry.getRefIds(BlocClass, key);\n}\n\nexport function getAll<T extends StateContainerConstructor>(\n BlocClass: T,\n): InstanceReadonlyState<T>[] {\n return getRegistry().getAll(BlocClass);\n}\n\nexport function forEach<T extends StateContainerConstructor>(\n BlocClass: T,\n callback: (instance: InstanceReadonlyState<T>) => void,\n): void {\n getRegistry().forEach(BlocClass, callback);\n}\n","import { getRegistry } from './config';\nimport type { StateContainerConstructor } from '../types/utilities';\n\nexport function clear<T extends StateContainerConstructor>(BlocClass: T): void {\n getRegistry().clear(BlocClass);\n}\n\nexport function clearAll(): void {\n getRegistry().clearAll();\n}\n\nexport function register<T extends StateContainerConstructor>(\n BlocClass: T,\n): void {\n getRegistry().register(BlocClass);\n}\n"],"mappings":";;AAOA,SAAgB,YACd,WACA,MACS;CACT,MAAM,WAAWA,eAAAA,YAAY;CAC7B,MAAM,MAAM,SAAS,WAAW,WAAW,KAAA,GAAW,MAAM,IAAI;CAChE,OAAO,SAAS,YAAY,WAAW,GAAG;AAC5C;AAEA,SAAgB,YACd,WACA,MACQ;CACR,MAAM,WAAWA,eAAAA,YAAY;CAC7B,MAAM,MAAM,SAAS,WAAW,WAAW,KAAA,GAAW,MAAM,IAAI;CAChE,OAAO,SAAS,YAAY,WAAW,GAAG;AAC5C;AAEA,SAAgB,UACd,WACA,MACU;CACV,MAAM,WAAWA,eAAAA,YAAY;CAC7B,MAAM,MAAM,SAAS,WAAW,WAAW,KAAA,GAAW,MAAM,IAAI;CAChE,OAAO,SAAS,UAAU,WAAW,GAAG;AAC1C;AAEA,SAAgB,OACd,WAC4B;CAC5B,OAAOA,eAAAA,YAAY,EAAE,OAAO,SAAS;AACvC;AAEA,SAAgB,QACd,WACA,UACM;CACN,eAAA,YAAY,EAAE,QAAQ,WAAW,QAAQ;AAC3C;;;AC1CA,SAAgB,MAA2C,WAAoB;CAC7E,eAAA,YAAY,EAAE,MAAM,SAAS;AAC/B;AAEA,SAAgB,WAAiB;CAC/B,eAAA,YAAY,EAAE,SAAS;AACzB;AAEA,SAAgB,SACd,WACM;CACN,eAAA,YAAY,EAAE,SAAS,SAAS;AAClC"}
|
|
@@ -0,0 +1,85 @@
|
|
|
1
|
+
const require_config = require("./config-B1l8ZGlU.cjs");
|
|
2
|
+
//#region src/registry/queries.ts
|
|
3
|
+
function hasInstance(BlocClass, opts) {
|
|
4
|
+
const registry = require_config.getRegistry();
|
|
5
|
+
const key = registry.resolveKey(BlocClass, void 0, opts?.args);
|
|
6
|
+
return registry.hasInstance(BlocClass, key);
|
|
7
|
+
}
|
|
8
|
+
function getRefCount(BlocClass, opts) {
|
|
9
|
+
const registry = require_config.getRegistry();
|
|
10
|
+
const key = registry.resolveKey(BlocClass, void 0, opts?.args);
|
|
11
|
+
return registry.getRefCount(BlocClass, key);
|
|
12
|
+
}
|
|
13
|
+
function getRefIds(BlocClass, opts) {
|
|
14
|
+
const registry = require_config.getRegistry();
|
|
15
|
+
const key = registry.resolveKey(BlocClass, void 0, opts?.args);
|
|
16
|
+
return registry.getRefIds(BlocClass, key);
|
|
17
|
+
}
|
|
18
|
+
function getAll(BlocClass) {
|
|
19
|
+
return require_config.getRegistry().getAll(BlocClass);
|
|
20
|
+
}
|
|
21
|
+
function forEach(BlocClass, callback) {
|
|
22
|
+
require_config.getRegistry().forEach(BlocClass, callback);
|
|
23
|
+
}
|
|
24
|
+
//#endregion
|
|
25
|
+
//#region src/registry/management.ts
|
|
26
|
+
function clear(BlocClass) {
|
|
27
|
+
require_config.getRegistry().clear(BlocClass);
|
|
28
|
+
}
|
|
29
|
+
function clearAll() {
|
|
30
|
+
require_config.getRegistry().clearAll();
|
|
31
|
+
}
|
|
32
|
+
function register(BlocClass) {
|
|
33
|
+
require_config.getRegistry().register(BlocClass);
|
|
34
|
+
}
|
|
35
|
+
//#endregion
|
|
36
|
+
Object.defineProperty(exports, "clear", {
|
|
37
|
+
enumerable: true,
|
|
38
|
+
get: function() {
|
|
39
|
+
return clear;
|
|
40
|
+
}
|
|
41
|
+
});
|
|
42
|
+
Object.defineProperty(exports, "clearAll", {
|
|
43
|
+
enumerable: true,
|
|
44
|
+
get: function() {
|
|
45
|
+
return clearAll;
|
|
46
|
+
}
|
|
47
|
+
});
|
|
48
|
+
Object.defineProperty(exports, "forEach", {
|
|
49
|
+
enumerable: true,
|
|
50
|
+
get: function() {
|
|
51
|
+
return forEach;
|
|
52
|
+
}
|
|
53
|
+
});
|
|
54
|
+
Object.defineProperty(exports, "getAll", {
|
|
55
|
+
enumerable: true,
|
|
56
|
+
get: function() {
|
|
57
|
+
return getAll;
|
|
58
|
+
}
|
|
59
|
+
});
|
|
60
|
+
Object.defineProperty(exports, "getRefCount", {
|
|
61
|
+
enumerable: true,
|
|
62
|
+
get: function() {
|
|
63
|
+
return getRefCount;
|
|
64
|
+
}
|
|
65
|
+
});
|
|
66
|
+
Object.defineProperty(exports, "getRefIds", {
|
|
67
|
+
enumerable: true,
|
|
68
|
+
get: function() {
|
|
69
|
+
return getRefIds;
|
|
70
|
+
}
|
|
71
|
+
});
|
|
72
|
+
Object.defineProperty(exports, "hasInstance", {
|
|
73
|
+
enumerable: true,
|
|
74
|
+
get: function() {
|
|
75
|
+
return hasInstance;
|
|
76
|
+
}
|
|
77
|
+
});
|
|
78
|
+
Object.defineProperty(exports, "register", {
|
|
79
|
+
enumerable: true,
|
|
80
|
+
get: function() {
|
|
81
|
+
return register;
|
|
82
|
+
}
|
|
83
|
+
});
|
|
84
|
+
|
|
85
|
+
//# sourceMappingURL=management-DwO0nBzL.cjs.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"management-DwO0nBzL.cjs","names":["getRegistry"],"sources":["../src/registry/queries.ts","../src/registry/management.ts"],"sourcesContent":["import { getRegistry } from './config';\nimport type {\n ExtractArgs,\n StateContainerConstructor,\n InstanceReadonlyState,\n} from '../types/utilities';\n\nexport function hasInstance<T extends StateContainerConstructor>(\n BlocClass: T,\n opts?: { args?: ExtractArgs<T> },\n): boolean {\n const registry = getRegistry();\n const key = registry.resolveKey(BlocClass, undefined, opts?.args);\n return registry.hasInstance(BlocClass, key);\n}\n\nexport function getRefCount<T extends StateContainerConstructor>(\n BlocClass: T,\n opts?: { args?: ExtractArgs<T> },\n): number {\n const registry = getRegistry();\n const key = registry.resolveKey(BlocClass, undefined, opts?.args);\n return registry.getRefCount(BlocClass, key);\n}\n\nexport function getRefIds<T extends StateContainerConstructor>(\n BlocClass: T,\n opts?: { args?: ExtractArgs<T> },\n): string[] {\n const registry = getRegistry();\n const key = registry.resolveKey(BlocClass, undefined, opts?.args);\n return registry.getRefIds(BlocClass, key);\n}\n\nexport function getAll<T extends StateContainerConstructor>(\n BlocClass: T,\n): InstanceReadonlyState<T>[] {\n return getRegistry().getAll(BlocClass);\n}\n\nexport function forEach<T extends StateContainerConstructor>(\n BlocClass: T,\n callback: (instance: InstanceReadonlyState<T>) => void,\n): void {\n getRegistry().forEach(BlocClass, callback);\n}\n","import { getRegistry } from './config';\nimport type { StateContainerConstructor } from '../types/utilities';\n\nexport function clear<T extends StateContainerConstructor>(BlocClass: T): void {\n getRegistry().clear(BlocClass);\n}\n\nexport function clearAll(): void {\n getRegistry().clearAll();\n}\n\nexport function register<T extends StateContainerConstructor>(\n BlocClass: T,\n): void {\n getRegistry().register(BlocClass);\n}\n"],"mappings":";;AAOA,SAAgB,YACd,WACA,MACS;CACT,MAAM,WAAWA,eAAAA,YAAY;CAC7B,MAAM,MAAM,SAAS,WAAW,WAAW,KAAA,GAAW,MAAM,IAAI;CAChE,OAAO,SAAS,YAAY,WAAW,GAAG;AAC5C;AAEA,SAAgB,YACd,WACA,MACQ;CACR,MAAM,WAAWA,eAAAA,YAAY;CAC7B,MAAM,MAAM,SAAS,WAAW,WAAW,KAAA,GAAW,MAAM,IAAI;CAChE,OAAO,SAAS,YAAY,WAAW,GAAG;AAC5C;AAEA,SAAgB,UACd,WACA,MACU;CACV,MAAM,WAAWA,eAAAA,YAAY;CAC7B,MAAM,MAAM,SAAS,WAAW,WAAW,KAAA,GAAW,MAAM,IAAI;CAChE,OAAO,SAAS,UAAU,WAAW,GAAG;AAC1C;AAEA,SAAgB,OACd,WAC4B;CAC5B,OAAOA,eAAAA,YAAY,EAAE,OAAO,SAAS;AACvC;AAEA,SAAgB,QACd,WACA,UACM;CACN,eAAA,YAAY,EAAE,QAAQ,WAAW,QAAQ;AAC3C;;;AC1CA,SAAgB,MAA2C,WAAoB;CAC7E,eAAA,YAAY,EAAE,MAAM,SAAS;AAC/B;AAEA,SAAgB,WAAiB;CAC/B,eAAA,YAAY,EAAE,SAAS;AACzB;AAEA,SAAgB,SACd,WACM;CACN,eAAA,YAAY,EAAE,SAAS,SAAS;AAClC"}
|
|
@@ -19,10 +19,9 @@ export interface InstanceMetadata {
|
|
|
19
19
|
/**
|
|
20
20
|
* Per-event context delivered to plugin hooks.
|
|
21
21
|
*
|
|
22
|
-
*
|
|
23
|
-
*
|
|
24
|
-
*
|
|
25
|
-
* context object.
|
|
22
|
+
* `PluginContext` is per-container — it identifies the bloc, not the event.
|
|
23
|
+
* Per-event data (e.g. the changed `PathSet`) is passed via dedicated method
|
|
24
|
+
* arguments, never via the context object.
|
|
26
25
|
*
|
|
27
26
|
* The `container` field is the focal bloc for the event. For `onInstall`
|
|
28
27
|
* (which fires once at install time, not bound to any container) the
|
|
@@ -54,9 +53,9 @@ export interface PluginContext {
|
|
|
54
53
|
/**
|
|
55
54
|
* BlaC plugin hook surface.
|
|
56
55
|
*
|
|
57
|
-
*
|
|
58
|
-
*
|
|
59
|
-
*
|
|
56
|
+
* State-change events carry the `PathSet` of paths that changed in the flush.
|
|
57
|
+
* Lifecycle events (`onCreated`, `onDestroyed`) are not tied to a state change
|
|
58
|
+
* and so do not carry `paths`.
|
|
60
59
|
*
|
|
61
60
|
* Hook firing model:
|
|
62
61
|
* - `onCreated` fires synchronously when a container is first acquired.
|
|
@@ -66,9 +65,9 @@ export interface PluginContext {
|
|
|
66
65
|
* - `onDestroyed` fires synchronously when a container is disposed (after
|
|
67
66
|
* its system 'dispose' event).
|
|
68
67
|
*
|
|
69
|
-
*
|
|
70
|
-
*
|
|
71
|
-
*
|
|
68
|
+
* The ref/deps hooks (`onRefAcquired`, `onRefReleased`, `onDepsChanged`) are
|
|
69
|
+
* devtools-only — they drive devtools-connect and are orthogonal to the
|
|
70
|
+
* state-change event payload.
|
|
72
71
|
*/
|
|
73
72
|
export interface BlacPlugin {
|
|
74
73
|
readonly name: string;
|
|
@@ -102,12 +101,12 @@ export interface BlacPlugin {
|
|
|
102
101
|
onHydrationChange?(ctx: PluginContext, status: HydrationStatus, previousStatus: HydrationStatus): void;
|
|
103
102
|
/**
|
|
104
103
|
* @internal Devtools-only — fires when a named ref is acquired.
|
|
105
|
-
* Not part of the
|
|
104
|
+
* Not part of the state-change event payload.
|
|
106
105
|
*/
|
|
107
106
|
onRefAcquired?(ctx: PluginContext, refId: string): void;
|
|
108
107
|
/**
|
|
109
108
|
* @internal Devtools-only — fires when a named ref is released.
|
|
110
|
-
* Not part of the
|
|
109
|
+
* Not part of the state-change event payload.
|
|
111
110
|
*/
|
|
112
111
|
onRefReleased?(ctx: PluginContext, refId: string): void;
|
|
113
112
|
/**
|
|
@@ -105,8 +105,7 @@ export declare class PluginManager {
|
|
|
105
105
|
*
|
|
106
106
|
* Note: `prev` is captured once and reused across plugins — every
|
|
107
107
|
* plugin sees the same `prev`/`next`/`paths` regardless of dispatch
|
|
108
|
-
* order, matching the "snapshot prev once per flush" invariant
|
|
109
|
-
* out in the C2 spec pitfalls.
|
|
108
|
+
* order, matching the "snapshot prev once per flush" invariant.
|
|
110
109
|
*/
|
|
111
110
|
private dispatchStateChange;
|
|
112
111
|
/**
|
|
@@ -114,7 +113,9 @@ export declare class PluginManager {
|
|
|
114
113
|
*
|
|
115
114
|
* Builds a fresh `PluginContext` per dispatch (instance becomes
|
|
116
115
|
* `ctx.container`), so plugins can reach the focal bloc through
|
|
117
|
-
* `ctx.container
|
|
116
|
+
* `ctx.container`. The context is built lazily on the first matching
|
|
117
|
+
* hook and reused for every other plugin in this dispatch — zero
|
|
118
|
+
* builds if no enabled plugin implements `hookName`.
|
|
118
119
|
*/
|
|
119
120
|
private notifyPlugins;
|
|
120
121
|
/**
|
|
@@ -123,7 +124,7 @@ export declare class PluginManager {
|
|
|
123
124
|
* so we create one per dispatch rather than caching per container.
|
|
124
125
|
* This sidesteps the lifetime question of "when do we evict a cached
|
|
125
126
|
* context?" and keeps `paths`-vs-`container` lifetimes cleanly
|
|
126
|
-
* separated
|
|
127
|
+
* separated.
|
|
127
128
|
*/
|
|
128
129
|
private buildContext;
|
|
129
130
|
/**
|
package/dist/plugins.cjs
CHANGED
|
@@ -1,4 +1,4 @@
|
|
|
1
1
|
Object.defineProperty(exports, Symbol.toStringTag, { value: "Module" });
|
|
2
|
-
const require_StateContainerRegistry = require("./StateContainerRegistry-
|
|
2
|
+
const require_StateContainerRegistry = require("./StateContainerRegistry-lIwo-0m3.cjs");
|
|
3
3
|
exports.PluginManager = require_StateContainerRegistry.PluginManager;
|
|
4
4
|
exports.getPluginManager = require_StateContainerRegistry.getPluginManager;
|
package/dist/plugins.js
CHANGED
|
@@ -1,2 +1,2 @@
|
|
|
1
|
-
import {
|
|
1
|
+
import { d as PluginManager, n as getPluginManager } from "./StateContainerRegistry-Dj77cok9.js";
|
|
2
2
|
export { PluginManager, getPluginManager };
|
package/dist/testing.cjs
CHANGED
|
@@ -1,8 +1,8 @@
|
|
|
1
1
|
Object.defineProperty(exports, Symbol.toStringTag, { value: "Module" });
|
|
2
|
-
const require_StateContainerRegistry = require("./StateContainerRegistry-
|
|
3
|
-
const require_ensure = require("./ensure-
|
|
4
|
-
const require_config = require("./config-
|
|
5
|
-
const require_acquire = require("./acquire-
|
|
2
|
+
const require_StateContainerRegistry = require("./StateContainerRegistry-lIwo-0m3.cjs");
|
|
3
|
+
const require_ensure = require("./ensure-VuiNPccZ.cjs");
|
|
4
|
+
const require_config = require("./config-B1l8ZGlU.cjs");
|
|
5
|
+
const require_acquire = require("./acquire-C4WAS13G.cjs");
|
|
6
6
|
//#region src/testing.ts
|
|
7
7
|
/** Synthetic owner id used by test helpers for pre-wired deps. */
|
|
8
8
|
const TESTING_DEPS_OWNER = "testing-deps";
|
|
@@ -52,7 +52,7 @@ function overrideEnsure(BlocClass, instance, fn, args) {
|
|
|
52
52
|
}
|
|
53
53
|
function createCubitStub(BlocClass, options) {
|
|
54
54
|
const instance = new BlocClass();
|
|
55
|
-
if (options?.args != null) instance.
|
|
55
|
+
if (options?.args != null) instance[require_StateContainerRegistry.INIT_CONFIG]({ args: options.args });
|
|
56
56
|
if (options?.state != null) {
|
|
57
57
|
if (instance instanceof require_ensure.Cubit) {
|
|
58
58
|
const currentState = instance.state;
|
|
@@ -63,7 +63,7 @@ function createCubitStub(BlocClass, options) {
|
|
|
63
63
|
if (options?.methods) {
|
|
64
64
|
for (const [key, impl] of Object.entries(options.methods)) if (typeof impl === "function") instance[key] = impl;
|
|
65
65
|
}
|
|
66
|
-
if (options?.deps != null) instance[
|
|
66
|
+
if (options?.deps != null) instance[require_StateContainerRegistry.APPLY_DEPS](TESTING_DEPS_OWNER, options.deps);
|
|
67
67
|
return instance;
|
|
68
68
|
}
|
|
69
69
|
function withBlocState(BlocClass, state, args) {
|
|
@@ -81,28 +81,23 @@ function withBlocMethod(BlocClass, methodName, impl, args) {
|
|
|
81
81
|
return instance;
|
|
82
82
|
}
|
|
83
83
|
/**
|
|
84
|
-
* Drain pending microtasks so any channel-flushed effects (
|
|
85
|
-
*
|
|
84
|
+
* Drain pending microtasks so any channel-flushed effects (channel
|
|
85
|
+
* subscribers, `onSystemEvent('stateChanged')` handlers, plugin hooks) run
|
|
86
86
|
* before the next assertion.
|
|
87
87
|
*
|
|
88
88
|
* The default `MicrotaskScheduler` coalesces emits within a tick; tests
|
|
89
|
-
* that emit and then assert on
|
|
90
|
-
*
|
|
89
|
+
* that emit and then assert on subscriber side-effects need `await flush()`
|
|
90
|
+
* between the two.
|
|
91
91
|
*/
|
|
92
92
|
async function flush() {
|
|
93
93
|
await Promise.resolve();
|
|
94
94
|
await Promise.resolve();
|
|
95
95
|
}
|
|
96
|
-
/** @deprecated Alias for `flush()`. */
|
|
97
|
-
async function flushBlocUpdates() {
|
|
98
|
-
await flush();
|
|
99
|
-
}
|
|
100
96
|
//#endregion
|
|
101
97
|
exports.blacTestSetup = blacTestSetup;
|
|
102
98
|
exports.createCubitStub = createCubitStub;
|
|
103
99
|
exports.createTestRegistry = createTestRegistry;
|
|
104
100
|
exports.flush = flush;
|
|
105
|
-
exports.flushBlocUpdates = flushBlocUpdates;
|
|
106
101
|
exports.overrideEnsure = overrideEnsure;
|
|
107
102
|
exports.registerOverride = registerOverride;
|
|
108
103
|
exports.withBlocMethod = withBlocMethod;
|
package/dist/testing.cjs.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"testing.cjs","names":["StateContainerRegistry","getRegistry","resolveInstanceKey","Cubit","APPLY_DEPS","ensure"],"sources":["../src/testing.ts"],"sourcesContent":["import { Cubit } from './core/Cubit';\nimport { StateContainerRegistry } from './core/StateContainerRegistry';\nimport { APPLY_DEPS } 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\n// --- createTestRegistry + withTestRegistry ---\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\n// --- blacTestSetup ---\n\nexport function blacTestSetup(): void {\n let savedRegistry: StateContainerRegistry;\n beforeEach(() => {\n savedRegistry = getRegistry();\n setRegistry(new StateContainerRegistry());\n });\n afterEach(() => {\n setRegistry(savedRegistry);\n });\n}\n\n// --- registerOverride + overrideEnsure ---\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.insertInstance(\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\n// --- createCubitStub ---\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 /**\n * Args to pass to init(). If the bloc's Args type is not void, supplying\n * args here causes initConfig({ args }) to be called so init() runs.\n */\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\n // Run init() if args are supplied — goes through the same initConfig path\n // that the registry uses, so lifecycle hooks fire correctly.\n if (options?.args != null) {\n instance
|
|
1
|
+
{"version":3,"file":"testing.cjs","names":["StateContainerRegistry","getRegistry","resolveInstanceKey","INIT_CONFIG","Cubit","APPLY_DEPS","ensure"],"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\n// --- createTestRegistry + withTestRegistry ---\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\n// --- blacTestSetup ---\n\nexport function blacTestSetup(): void {\n let savedRegistry: StateContainerRegistry;\n beforeEach(() => {\n savedRegistry = getRegistry();\n setRegistry(new StateContainerRegistry());\n });\n afterEach(() => {\n setRegistry(savedRegistry);\n });\n}\n\n// --- registerOverride + overrideEnsure ---\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.insertInstance(\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\n// --- createCubitStub ---\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 /**\n * Args to pass to init(). If the bloc's Args type is not void, supplying\n * args here causes initConfig({ args }) to be called so init() runs.\n */\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\n // Run init() if args are supplied — goes through the same initConfig path\n // that the registry uses, so lifecycle hooks fire correctly.\n if (options?.args != null) {\n instance[INIT_CONFIG]({ args: options.args });\n }\n\n if (options?.state != null) {\n if (instance instanceof Cubit) {\n const currentState = instance.state;\n if (\n typeof currentState === 'object' &&\n currentState !== null &&\n typeof options.state === 'object' &&\n options.state !== null\n ) {\n instance.patch(options.state as any);\n } else {\n instance.emit(options.state as any);\n }\n }\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\n// --- withBlocState ---\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 if (instance instanceof Cubit) {\n const currentState = instance.state;\n if (\n typeof currentState === 'object' &&\n currentState !== null &&\n typeof state === 'object' &&\n state !== null\n ) {\n instance.patch(state as any);\n } else {\n instance.emit(state as any);\n }\n }\n return instance;\n}\n\n// --- withBlocMethod ---\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// --- flush ---\n\n/**\n * Drain pending microtasks so any channel-flushed effects (channel\n * subscribers, `onSystemEvent('stateChanged')` handlers, plugin hooks) run\n * before the next assertion.\n *\n * The default `MicrotaskScheduler` coalesces emits within a tick; tests\n * that emit and then assert on subscriber side-effects need `await flush()`\n * between the two.\n */\nexport async function flush(): Promise<void> {\n // queueMicrotask wins the race against the channel's own queued flush —\n // we resolve after the channel has drained its current pending flush.\n await Promise.resolve();\n await Promise.resolve();\n}\n"],"mappings":";;;;;;;AAaA,MAAM,qBAAqB;AAO3B,SAAgB,qBAA6C;CAC3D,OAAO,IAAIA,+BAAAA,uBAAuB;AACpC;AAEA,SAAgB,iBACd,IACG;CACH,MAAM,WAAWC,eAAAA,YAAY;CAC7B,MAAM,eAAe,mBAAmB;CACxC,eAAA,YAAY,YAAY;CACxB,IAAI;EACF,MAAM,SAAS,GAAG,YAAY;EAC9B,IAAI,kBAAkB,SACpB,OAAO,OAAO,MACX,UAAU;GACT,eAAA,YAAY,QAAQ;GACpB,OAAO;EACT,IACC,UAAU;GACT,eAAA,YAAY,QAAQ;GACpB,MAAM;EACR,CACF;EAEF,eAAA,YAAY,QAAQ;EACpB,OAAO;CACT,SAAS,OAAO;EACd,eAAA,YAAY,QAAQ;EACpB,MAAM;CACR;AACF;AAIA,SAAgB,gBAAsB;CACpC,IAAI;CACJ,iBAAiB;EACf,gBAAgBA,eAAAA,YAAY;EAC5B,eAAA,YAAY,IAAID,+BAAAA,uBAAuB,CAAC;CAC1C,CAAC;CACD,gBAAgB;EACd,eAAA,YAAY,aAAa;CAC3B,CAAC;AACH;AAIA,SAAgB,iBACd,WACA,UACA,MACM;CACN,MAAM,WAAWC,eAAAA,YAAY;CAC7B,MAAM,MAAMC,gBAAAA,mBAAmB,WAAW,IAAI;CAC9C,SAAS,eACP,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;AA2BA,SAAgB,gBACd,WACA,SACiB;CACjB,MAAM,WAAW,IAAI,UAAU;CAI/B,IAAI,SAAS,QAAQ,MACnB,SAASC,+BAAAA,aAAa,EAAE,MAAM,QAAQ,KAAK,CAAC;CAG9C,IAAI,SAAS,SAAS;MAChB,oBAAoBC,eAAAA,OAAO;GAC7B,MAAM,eAAe,SAAS;GAC9B,IACE,OAAO,iBAAiB,YACxB,iBAAiB,QACjB,OAAO,QAAQ,UAAU,YACzB,QAAQ,UAAU,MAElB,SAAS,MAAM,QAAQ,KAAY;QAEnC,SAAS,KAAK,QAAQ,KAAY;EAEtC;;CAEF,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;AAIA,SAAgB,cACd,WACA,OAGA,MACiB;CACjB,MAAM,WAAWC,eAAAA,OAAO,WAAW,EAAE,KAAK,CAAC;CAC3C,IAAI,oBAAoBF,eAAAA,OAAO;EAC7B,MAAM,eAAe,SAAS;EAC9B,IACE,OAAO,iBAAiB,YACxB,iBAAiB,QACjB,OAAO,UAAU,YACjB,UAAU,MAEV,SAAS,MAAM,KAAY;OAE3B,SAAS,KAAK,KAAY;CAE9B;CACA,OAAO;AACT;AAIA,SAAgB,eACd,WACA,YACA,MACA,MACiB;CACjB,MAAM,WAAWE,eAAAA,OAAO,WAAW,EAAE,KAAK,CAAC;CAC3C,SAAkB,cAAc;CAChC,OAAO;AACT;;;;;;;;;;AAaA,eAAsB,QAAuB;CAG3C,MAAM,QAAQ,QAAQ;CACtB,MAAM,QAAQ,QAAQ;AACxB"}
|
package/dist/testing.d.cts
CHANGED
|
@@ -26,15 +26,13 @@ export declare function createCubitStub<T extends StateContainerConstructor>(Blo
|
|
|
26
26
|
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
27
|
export declare function withBlocMethod<T extends StateContainerConstructor>(BlocClass: T, methodName: keyof InstanceType<T>, impl: (...args: any[]) => any, args?: ExtractArgs<T>): InstanceType<T>;
|
|
28
28
|
/**
|
|
29
|
-
* Drain pending microtasks so any channel-flushed effects (
|
|
30
|
-
*
|
|
29
|
+
* Drain pending microtasks so any channel-flushed effects (channel
|
|
30
|
+
* subscribers, `onSystemEvent('stateChanged')` handlers, plugin hooks) run
|
|
31
31
|
* before the next assertion.
|
|
32
32
|
*
|
|
33
33
|
* The default `MicrotaskScheduler` coalesces emits within a tick; tests
|
|
34
|
-
* that emit and then assert on
|
|
35
|
-
*
|
|
34
|
+
* that emit and then assert on subscriber side-effects need `await flush()`
|
|
35
|
+
* between the two.
|
|
36
36
|
*/
|
|
37
37
|
export declare function flush(): Promise<void>;
|
|
38
|
-
/** @deprecated Alias for `flush()`. */
|
|
39
|
-
export declare function flushBlocUpdates(): Promise<void>;
|
|
40
38
|
export {};
|
package/dist/testing.d.ts
CHANGED
|
@@ -26,15 +26,13 @@ export declare function createCubitStub<T extends StateContainerConstructor>(Blo
|
|
|
26
26
|
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
27
|
export declare function withBlocMethod<T extends StateContainerConstructor>(BlocClass: T, methodName: keyof InstanceType<T>, impl: (...args: any[]) => any, args?: ExtractArgs<T>): InstanceType<T>;
|
|
28
28
|
/**
|
|
29
|
-
* Drain pending microtasks so any channel-flushed effects (
|
|
30
|
-
*
|
|
29
|
+
* Drain pending microtasks so any channel-flushed effects (channel
|
|
30
|
+
* subscribers, `onSystemEvent('stateChanged')` handlers, plugin hooks) run
|
|
31
31
|
* before the next assertion.
|
|
32
32
|
*
|
|
33
33
|
* The default `MicrotaskScheduler` coalesces emits within a tick; tests
|
|
34
|
-
* that emit and then assert on
|
|
35
|
-
*
|
|
34
|
+
* that emit and then assert on subscriber side-effects need `await flush()`
|
|
35
|
+
* between the two.
|
|
36
36
|
*/
|
|
37
37
|
export declare function flush(): Promise<void>;
|
|
38
|
-
/** @deprecated Alias for `flush()`. */
|
|
39
|
-
export declare function flushBlocUpdates(): Promise<void>;
|
|
40
38
|
export {};
|
package/dist/testing.js
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
|
-
import { t as StateContainerRegistry } from "./StateContainerRegistry-
|
|
2
|
-
import {
|
|
3
|
-
import { r as setRegistry, t as getRegistry } from "./config-
|
|
4
|
-
import { n as resolveInstanceKey } from "./acquire-
|
|
1
|
+
import { a as INIT_CONFIG, i as APPLY_DEPS, t as StateContainerRegistry } from "./StateContainerRegistry-Dj77cok9.js";
|
|
2
|
+
import { n as Cubit, t as ensure } from "./ensure-Bm91o37h.js";
|
|
3
|
+
import { r as setRegistry, t as getRegistry } from "./config-CzcoAvBo.js";
|
|
4
|
+
import { n as resolveInstanceKey } from "./acquire-BRIJVJaA.js";
|
|
5
5
|
//#region src/testing.ts
|
|
6
6
|
/** Synthetic owner id used by test helpers for pre-wired deps. */
|
|
7
7
|
const TESTING_DEPS_OWNER = "testing-deps";
|
|
@@ -51,7 +51,7 @@ function overrideEnsure(BlocClass, instance, fn, args) {
|
|
|
51
51
|
}
|
|
52
52
|
function createCubitStub(BlocClass, options) {
|
|
53
53
|
const instance = new BlocClass();
|
|
54
|
-
if (options?.args != null) instance
|
|
54
|
+
if (options?.args != null) instance[INIT_CONFIG]({ args: options.args });
|
|
55
55
|
if (options?.state != null) {
|
|
56
56
|
if (instance instanceof Cubit) {
|
|
57
57
|
const currentState = instance.state;
|
|
@@ -80,23 +80,19 @@ function withBlocMethod(BlocClass, methodName, impl, args) {
|
|
|
80
80
|
return instance;
|
|
81
81
|
}
|
|
82
82
|
/**
|
|
83
|
-
* Drain pending microtasks so any channel-flushed effects (
|
|
84
|
-
*
|
|
83
|
+
* Drain pending microtasks so any channel-flushed effects (channel
|
|
84
|
+
* subscribers, `onSystemEvent('stateChanged')` handlers, plugin hooks) run
|
|
85
85
|
* before the next assertion.
|
|
86
86
|
*
|
|
87
87
|
* The default `MicrotaskScheduler` coalesces emits within a tick; tests
|
|
88
|
-
* that emit and then assert on
|
|
89
|
-
*
|
|
88
|
+
* that emit and then assert on subscriber side-effects need `await flush()`
|
|
89
|
+
* between the two.
|
|
90
90
|
*/
|
|
91
91
|
async function flush() {
|
|
92
92
|
await Promise.resolve();
|
|
93
93
|
await Promise.resolve();
|
|
94
94
|
}
|
|
95
|
-
/** @deprecated Alias for `flush()`. */
|
|
96
|
-
async function flushBlocUpdates() {
|
|
97
|
-
await flush();
|
|
98
|
-
}
|
|
99
95
|
//#endregion
|
|
100
|
-
export { blacTestSetup, createCubitStub, createTestRegistry, flush,
|
|
96
|
+
export { blacTestSetup, createCubitStub, createTestRegistry, flush, overrideEnsure, registerOverride, withBlocMethod, withBlocState, withTestRegistry };
|
|
101
97
|
|
|
102
98
|
//# sourceMappingURL=testing.js.map
|
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 } 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\n// --- createTestRegistry + withTestRegistry ---\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\n// --- blacTestSetup ---\n\nexport function blacTestSetup(): void {\n let savedRegistry: StateContainerRegistry;\n beforeEach(() => {\n savedRegistry = getRegistry();\n setRegistry(new StateContainerRegistry());\n });\n afterEach(() => {\n setRegistry(savedRegistry);\n });\n}\n\n// --- registerOverride + overrideEnsure ---\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.insertInstance(\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\n// --- createCubitStub ---\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 /**\n * Args to pass to init(). If the bloc's Args type is not void, supplying\n * args here causes initConfig({ args }) to be called so init() runs.\n */\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\n // Run init() if args are supplied — goes through the same initConfig path\n // that the registry uses, so lifecycle hooks fire correctly.\n if (options?.args != null) {\n instance
|
|
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\n// --- createTestRegistry + withTestRegistry ---\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\n// --- blacTestSetup ---\n\nexport function blacTestSetup(): void {\n let savedRegistry: StateContainerRegistry;\n beforeEach(() => {\n savedRegistry = getRegistry();\n setRegistry(new StateContainerRegistry());\n });\n afterEach(() => {\n setRegistry(savedRegistry);\n });\n}\n\n// --- registerOverride + overrideEnsure ---\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.insertInstance(\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\n// --- createCubitStub ---\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 /**\n * Args to pass to init(). If the bloc's Args type is not void, supplying\n * args here causes initConfig({ args }) to be called so init() runs.\n */\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\n // Run init() if args are supplied — goes through the same initConfig path\n // that the registry uses, so lifecycle hooks fire correctly.\n if (options?.args != null) {\n instance[INIT_CONFIG]({ args: options.args });\n }\n\n if (options?.state != null) {\n if (instance instanceof Cubit) {\n const currentState = instance.state;\n if (\n typeof currentState === 'object' &&\n currentState !== null &&\n typeof options.state === 'object' &&\n options.state !== null\n ) {\n instance.patch(options.state as any);\n } else {\n instance.emit(options.state as any);\n }\n }\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\n// --- withBlocState ---\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 if (instance instanceof Cubit) {\n const currentState = instance.state;\n if (\n typeof currentState === 'object' &&\n currentState !== null &&\n typeof state === 'object' &&\n state !== null\n ) {\n instance.patch(state as any);\n } else {\n instance.emit(state as any);\n }\n }\n return instance;\n}\n\n// --- withBlocMethod ---\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// --- flush ---\n\n/**\n * Drain pending microtasks so any channel-flushed effects (channel\n * subscribers, `onSystemEvent('stateChanged')` handlers, plugin hooks) run\n * before the next assertion.\n *\n * The default `MicrotaskScheduler` coalesces emits within a tick; tests\n * that emit and then assert on subscriber side-effects need `await flush()`\n * between the two.\n */\nexport async function flush(): Promise<void> {\n // queueMicrotask wins the race against the channel's own queued flush —\n // we resolve after the channel has drained its current pending flush.\n await Promise.resolve();\n await Promise.resolve();\n}\n"],"mappings":";;;;;;AAaA,MAAM,qBAAqB;AAO3B,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;AAIA,SAAgB,gBAAsB;CACpC,IAAI;CACJ,iBAAiB;EACf,gBAAgB,YAAY;EAC5B,YAAY,IAAI,uBAAuB,CAAC;CAC1C,CAAC;CACD,gBAAgB;EACd,YAAY,aAAa;CAC3B,CAAC;AACH;AAIA,SAAgB,iBACd,WACA,UACA,MACM;CACN,MAAM,WAAW,YAAY;CAC7B,MAAM,MAAM,mBAAmB,WAAW,IAAI;CAC9C,SAAS,eACP,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;AA2BA,SAAgB,gBACd,WACA,SACiB;CACjB,MAAM,WAAW,IAAI,UAAU;CAI/B,IAAI,SAAS,QAAQ,MACnB,SAAS,aAAa,EAAE,MAAM,QAAQ,KAAK,CAAC;CAG9C,IAAI,SAAS,SAAS;MAChB,oBAAoB,OAAO;GAC7B,MAAM,eAAe,SAAS;GAC9B,IACE,OAAO,iBAAiB,YACxB,iBAAiB,QACjB,OAAO,QAAQ,UAAU,YACzB,QAAQ,UAAU,MAElB,SAAS,MAAM,QAAQ,KAAY;QAEnC,SAAS,KAAK,QAAQ,KAAY;EAEtC;;CAEF,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;AAIA,SAAgB,cACd,WACA,OAGA,MACiB;CACjB,MAAM,WAAW,OAAO,WAAW,EAAE,KAAK,CAAC;CAC3C,IAAI,oBAAoB,OAAO;EAC7B,MAAM,eAAe,SAAS;EAC9B,IACE,OAAO,iBAAiB,YACxB,iBAAiB,QACjB,OAAO,UAAU,YACjB,UAAU,MAEV,SAAS,MAAM,KAAY;OAE3B,SAAS,KAAK,KAAY;CAE9B;CACA,OAAO;AACT;AAIA,SAAgB,eACd,WACA,YACA,MACA,MACiB;CACjB,MAAM,WAAW,OAAO,WAAW,EAAE,KAAK,CAAC;CAC3C,SAAkB,cAAc;CAChC,OAAO;AACT;;;;;;;;;;AAaA,eAAsB,QAAuB;CAG3C,MAAM,QAAQ,QAAQ;CACtB,MAAM,QAAQ,QAAQ;AACxB"}
|
package/dist/watch/watch.d.ts
CHANGED
|
@@ -11,6 +11,12 @@ export interface BlocRef<T extends StateContainerConstructor> {
|
|
|
11
11
|
blocClass: T;
|
|
12
12
|
/** @internal The resolved instance key (derived from `args`). */
|
|
13
13
|
instanceId: string;
|
|
14
|
+
/**
|
|
15
|
+
* @internal The `args` used to derive `instanceId`. Forwarded to
|
|
16
|
+
* `registry.acquire` so a not-yet-created instance is initialized with
|
|
17
|
+
* these args instead of `undefined`.
|
|
18
|
+
*/
|
|
19
|
+
args?: unknown;
|
|
14
20
|
}
|
|
15
21
|
/**
|
|
16
22
|
* Create a reference to a specific bloc instance, identified by its `args`.
|