@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,35 @@
|
|
|
1
|
+
import { t as getRegistry } from "./config-DVM_ESQt.js";
|
|
2
|
+
//#region src/registry/acquire.ts
|
|
3
|
+
/**
|
|
4
|
+
* Acquire an instance with ref tracking (ownership semantics). Instance
|
|
5
|
+
* identity is derived purely from `args` (via the class's `static key(args)`,
|
|
6
|
+
* a structural hash of `args`, or the default sentinel when there are none).
|
|
7
|
+
*
|
|
8
|
+
* @param BlocClass - The StateContainer class constructor
|
|
9
|
+
* @param opts.args - Construction/identity args; derives the instance key
|
|
10
|
+
* @param opts.refId - Named reference ID for debugging; auto-generated if omitted
|
|
11
|
+
*/
|
|
12
|
+
function acquire(BlocClass, opts) {
|
|
13
|
+
const registry = getRegistry();
|
|
14
|
+
const key = registry.resolveKey(BlocClass, void 0, opts?.args);
|
|
15
|
+
return registry.acquire(BlocClass, key, {
|
|
16
|
+
canCreate: true,
|
|
17
|
+
countRef: true,
|
|
18
|
+
refId: opts?.refId,
|
|
19
|
+
args: opts?.args
|
|
20
|
+
});
|
|
21
|
+
}
|
|
22
|
+
/**
|
|
23
|
+
* Resolve the storage key an instance would be acquired under, given its
|
|
24
|
+
* construction `args`. This is the canonical key-computation path. Callers that
|
|
25
|
+
* both acquire and release against the `@internal` registry tier (e.g.
|
|
26
|
+
* `@blac/react` `useBloc`) must use this once and pass the same resolved key to
|
|
27
|
+
* both, so the ref is dropped under the key it was taken.
|
|
28
|
+
*/
|
|
29
|
+
function resolveInstanceKey(BlocClass, args) {
|
|
30
|
+
return getRegistry().resolveKey(BlocClass, void 0, args);
|
|
31
|
+
}
|
|
32
|
+
//#endregion
|
|
33
|
+
export { resolveInstanceKey as n, acquire as t };
|
|
34
|
+
|
|
35
|
+
//# sourceMappingURL=acquire-Dg-uXwjF.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"acquire-Dg-uXwjF.js","names":[],"sources":["../src/registry/acquire.ts"],"sourcesContent":["import { getRegistry } from './config';\nimport type {\n ExtractArgs,\n StateContainerConstructor,\n} from '../types/utilities';\n\n/**\n * Acquire an instance with ref tracking (ownership semantics). Instance\n * identity is derived purely from `args` (via the class's `static key(args)`,\n * a structural hash of `args`, or the default sentinel when there are none).\n *\n * @param BlocClass - The StateContainer class constructor\n * @param opts.args - Construction/identity args; derives the instance key\n * @param opts.refId - Named reference ID for debugging; auto-generated if omitted\n */\nexport function acquire<T extends StateContainerConstructor>(\n BlocClass: T,\n opts?: { args?: ExtractArgs<T>; refId?: string },\n): InstanceType<T> {\n const registry = getRegistry();\n const key = registry.resolveKey(BlocClass, undefined, opts?.args);\n return registry.acquire(BlocClass, key, {\n canCreate: true,\n countRef: true,\n refId: opts?.refId,\n args: opts?.args,\n });\n}\n\n/**\n * Resolve the storage key an instance would be acquired under, given its\n * construction `args`. This is the canonical key-computation path. Callers that\n * both acquire and release against the `@internal` registry tier (e.g.\n * `@blac/react` `useBloc`) must use this once and pass the same resolved key to\n * both, so the ref is dropped under the key it was taken.\n */\nexport function resolveInstanceKey<T extends StateContainerConstructor>(\n BlocClass: T,\n args?: ExtractArgs<T>,\n): string {\n return getRegistry().resolveKey(BlocClass, undefined, args);\n}\n"],"mappings":";;;;;;;;;;;AAeA,SAAgB,QACd,WACA,MACiB;CACjB,MAAM,WAAW,YAAY;CAC7B,MAAM,MAAM,SAAS,WAAW,WAAW,KAAA,GAAW,MAAM,IAAI;CAChE,OAAO,SAAS,QAAQ,WAAW,KAAK;EACtC,WAAW;EACX,UAAU;EACV,OAAO,MAAM;EACb,MAAM,MAAM;CACd,CAAC;AACH;;;;;;;;AASA,SAAgB,mBACd,WACA,MACQ;CACR,OAAO,YAAY,EAAE,WAAW,WAAW,KAAA,GAAW,IAAI;AAC5D"}
|
|
@@ -0,0 +1,32 @@
|
|
|
1
|
+
//#region src/registry/config.ts
|
|
2
|
+
let _registry = require("./StateContainerRegistry-lIwo-0m3.cjs").globalRegistry;
|
|
3
|
+
function getRegistry() {
|
|
4
|
+
return _registry;
|
|
5
|
+
}
|
|
6
|
+
function setRegistry(registry) {
|
|
7
|
+
_registry = registry;
|
|
8
|
+
}
|
|
9
|
+
function getStats() {
|
|
10
|
+
return _registry.getStats();
|
|
11
|
+
}
|
|
12
|
+
//#endregion
|
|
13
|
+
Object.defineProperty(exports, "getRegistry", {
|
|
14
|
+
enumerable: true,
|
|
15
|
+
get: function() {
|
|
16
|
+
return getRegistry;
|
|
17
|
+
}
|
|
18
|
+
});
|
|
19
|
+
Object.defineProperty(exports, "getStats", {
|
|
20
|
+
enumerable: true,
|
|
21
|
+
get: function() {
|
|
22
|
+
return getStats;
|
|
23
|
+
}
|
|
24
|
+
});
|
|
25
|
+
Object.defineProperty(exports, "setRegistry", {
|
|
26
|
+
enumerable: true,
|
|
27
|
+
get: function() {
|
|
28
|
+
return setRegistry;
|
|
29
|
+
}
|
|
30
|
+
});
|
|
31
|
+
|
|
32
|
+
//# sourceMappingURL=config-B1l8ZGlU.cjs.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"config-B1l8ZGlU.cjs","names":["globalRegistry"],"sources":["../src/registry/config.ts"],"sourcesContent":["import {\n globalRegistry,\n StateContainerRegistry,\n} from '../core/StateContainerRegistry';\n\nlet _registry = globalRegistry;\n\nexport function getRegistry(): StateContainerRegistry {\n return _registry;\n}\n\nexport function setRegistry(registry: StateContainerRegistry): void {\n _registry = registry;\n}\n\nexport function getStats(): {\n registeredTypes: number;\n totalInstances: number;\n typeBreakdown: Record<string, number>;\n} {\n return _registry.getStats();\n}\n"],"mappings":";AAKA,IAAI,2DAAYA,EAAAA;AAEhB,SAAgB,cAAsC;CACpD,OAAO;AACT;AAEA,SAAgB,YAAY,UAAwC;CAClE,YAAY;AACd;AAEA,SAAgB,WAId;CACA,OAAO,UAAU,SAAS;AAC5B"}
|
|
@@ -0,0 +1,32 @@
|
|
|
1
|
+
//#region src/registry/config.ts
|
|
2
|
+
let _registry = require("./StateContainerRegistry-CSNm2Ws5.cjs").globalRegistry;
|
|
3
|
+
function getRegistry() {
|
|
4
|
+
return _registry;
|
|
5
|
+
}
|
|
6
|
+
function setRegistry(registry) {
|
|
7
|
+
_registry = registry;
|
|
8
|
+
}
|
|
9
|
+
function getStats() {
|
|
10
|
+
return _registry.getStats();
|
|
11
|
+
}
|
|
12
|
+
//#endregion
|
|
13
|
+
Object.defineProperty(exports, "getRegistry", {
|
|
14
|
+
enumerable: true,
|
|
15
|
+
get: function() {
|
|
16
|
+
return getRegistry;
|
|
17
|
+
}
|
|
18
|
+
});
|
|
19
|
+
Object.defineProperty(exports, "getStats", {
|
|
20
|
+
enumerable: true,
|
|
21
|
+
get: function() {
|
|
22
|
+
return getStats;
|
|
23
|
+
}
|
|
24
|
+
});
|
|
25
|
+
Object.defineProperty(exports, "setRegistry", {
|
|
26
|
+
enumerable: true,
|
|
27
|
+
get: function() {
|
|
28
|
+
return setRegistry;
|
|
29
|
+
}
|
|
30
|
+
});
|
|
31
|
+
|
|
32
|
+
//# sourceMappingURL=config-C7Ktkjh2.cjs.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"config-C7Ktkjh2.cjs","names":["globalRegistry"],"sources":["../src/registry/config.ts"],"sourcesContent":["import {\n globalRegistry,\n StateContainerRegistry,\n} from '../core/StateContainerRegistry';\n\nlet _registry = globalRegistry;\n\nexport function getRegistry(): StateContainerRegistry {\n return _registry;\n}\n\nexport function setRegistry(registry: StateContainerRegistry): void {\n _registry = registry;\n}\n\nexport function getStats(): {\n registeredTypes: number;\n totalInstances: number;\n typeBreakdown: Record<string, number>;\n} {\n return _registry.getStats();\n}\n"],"mappings":";AAKA,IAAI,2DAAYA,EAAAA;AAEhB,SAAgB,cAAsC;CACpD,OAAO;AACT;AAEA,SAAgB,YAAY,UAAwC;CAClE,YAAY;AACd;AAEA,SAAgB,WAId;CACA,OAAO,UAAU,SAAS;AAC5B"}
|
|
@@ -0,0 +1,16 @@
|
|
|
1
|
+
import { r as globalRegistry } from "./StateContainerRegistry-4Ljd9EJx.js";
|
|
2
|
+
//#region src/registry/config.ts
|
|
3
|
+
let _registry = globalRegistry;
|
|
4
|
+
function getRegistry() {
|
|
5
|
+
return _registry;
|
|
6
|
+
}
|
|
7
|
+
function setRegistry(registry) {
|
|
8
|
+
_registry = registry;
|
|
9
|
+
}
|
|
10
|
+
function getStats() {
|
|
11
|
+
return _registry.getStats();
|
|
12
|
+
}
|
|
13
|
+
//#endregion
|
|
14
|
+
export { getStats as n, setRegistry as r, getRegistry as t };
|
|
15
|
+
|
|
16
|
+
//# sourceMappingURL=config-COT4Xkbc.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"config-COT4Xkbc.js","names":[],"sources":["../src/registry/config.ts"],"sourcesContent":["import {\n globalRegistry,\n StateContainerRegistry,\n} from '../core/StateContainerRegistry';\n\nlet _registry = globalRegistry;\n\nexport function getRegistry(): StateContainerRegistry {\n return _registry;\n}\n\nexport function setRegistry(registry: StateContainerRegistry): void {\n _registry = registry;\n}\n\nexport function getStats(): {\n registeredTypes: number;\n totalInstances: number;\n typeBreakdown: Record<string, number>;\n} {\n return _registry.getStats();\n}\n"],"mappings":";;AAKA,IAAI,YAAY;AAEhB,SAAgB,cAAsC;CACpD,OAAO;AACT;AAEA,SAAgB,YAAY,UAAwC;CAClE,YAAY;AACd;AAEA,SAAgB,WAId;CACA,OAAO,UAAU,SAAS;AAC5B"}
|
|
@@ -0,0 +1,16 @@
|
|
|
1
|
+
import { r as globalRegistry } from "./StateContainerRegistry-Dj77cok9.js";
|
|
2
|
+
//#region src/registry/config.ts
|
|
3
|
+
let _registry = globalRegistry;
|
|
4
|
+
function getRegistry() {
|
|
5
|
+
return _registry;
|
|
6
|
+
}
|
|
7
|
+
function setRegistry(registry) {
|
|
8
|
+
_registry = registry;
|
|
9
|
+
}
|
|
10
|
+
function getStats() {
|
|
11
|
+
return _registry.getStats();
|
|
12
|
+
}
|
|
13
|
+
//#endregion
|
|
14
|
+
export { getStats as n, setRegistry as r, getRegistry as t };
|
|
15
|
+
|
|
16
|
+
//# sourceMappingURL=config-CzcoAvBo.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"config-CzcoAvBo.js","names":[],"sources":["../src/registry/config.ts"],"sourcesContent":["import {\n globalRegistry,\n StateContainerRegistry,\n} from '../core/StateContainerRegistry';\n\nlet _registry = globalRegistry;\n\nexport function getRegistry(): StateContainerRegistry {\n return _registry;\n}\n\nexport function setRegistry(registry: StateContainerRegistry): void {\n _registry = registry;\n}\n\nexport function getStats(): {\n registeredTypes: number;\n totalInstances: number;\n typeBreakdown: Record<string, number>;\n} {\n return _registry.getStats();\n}\n"],"mappings":";;AAKA,IAAI,YAAY;AAEhB,SAAgB,cAAsC;CACpD,OAAO;AACT;AAEA,SAAgB,YAAY,UAAwC;CAClE,YAAY;AACd;AAEA,SAAgB,WAId;CACA,OAAO,UAAU,SAAS;AAC5B"}
|
|
@@ -0,0 +1,16 @@
|
|
|
1
|
+
import { r as globalRegistry } from "./StateContainerRegistry-C0dCNlTF.js";
|
|
2
|
+
//#region src/registry/config.ts
|
|
3
|
+
let _registry = globalRegistry;
|
|
4
|
+
function getRegistry() {
|
|
5
|
+
return _registry;
|
|
6
|
+
}
|
|
7
|
+
function setRegistry(registry) {
|
|
8
|
+
_registry = registry;
|
|
9
|
+
}
|
|
10
|
+
function getStats() {
|
|
11
|
+
return _registry.getStats();
|
|
12
|
+
}
|
|
13
|
+
//#endregion
|
|
14
|
+
export { getStats as n, setRegistry as r, getRegistry as t };
|
|
15
|
+
|
|
16
|
+
//# sourceMappingURL=config-D6BoWWPv.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"config-D6BoWWPv.js","names":[],"sources":["../src/registry/config.ts"],"sourcesContent":["import {\n globalRegistry,\n StateContainerRegistry,\n} from '../core/StateContainerRegistry';\n\nlet _registry = globalRegistry;\n\nexport function getRegistry(): StateContainerRegistry {\n return _registry;\n}\n\nexport function setRegistry(registry: StateContainerRegistry): void {\n _registry = registry;\n}\n\nexport function getStats(): {\n registeredTypes: number;\n totalInstances: number;\n typeBreakdown: Record<string, number>;\n} {\n return _registry.getStats();\n}\n"],"mappings":";;AAKA,IAAI,YAAY;AAEhB,SAAgB,cAAsC;CACpD,OAAO;AACT;AAEA,SAAgB,YAAY,UAAwC;CAClE,YAAY;AACd;AAEA,SAAgB,WAId;CACA,OAAO,UAAU,SAAS;AAC5B"}
|
|
@@ -0,0 +1,16 @@
|
|
|
1
|
+
import { r as globalRegistry } from "./StateContainerRegistry-DVIBTxGZ.js";
|
|
2
|
+
//#region src/registry/config.ts
|
|
3
|
+
let _registry = globalRegistry;
|
|
4
|
+
function getRegistry() {
|
|
5
|
+
return _registry;
|
|
6
|
+
}
|
|
7
|
+
function setRegistry(registry) {
|
|
8
|
+
_registry = registry;
|
|
9
|
+
}
|
|
10
|
+
function getStats() {
|
|
11
|
+
return _registry.getStats();
|
|
12
|
+
}
|
|
13
|
+
//#endregion
|
|
14
|
+
export { getStats as n, setRegistry as r, getRegistry as t };
|
|
15
|
+
|
|
16
|
+
//# sourceMappingURL=config-DVM_ESQt.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"config-DVM_ESQt.js","names":[],"sources":["../src/registry/config.ts"],"sourcesContent":["import {\n globalRegistry,\n StateContainerRegistry,\n} from '../core/StateContainerRegistry';\n\nlet _registry = globalRegistry;\n\nexport function getRegistry(): StateContainerRegistry {\n return _registry;\n}\n\nexport function setRegistry(registry: StateContainerRegistry): void {\n _registry = registry;\n}\n\nexport function getStats(): {\n registeredTypes: number;\n totalInstances: number;\n typeBreakdown: Record<string, number>;\n} {\n return _registry.getStats();\n}\n"],"mappings":";;AAKA,IAAI,YAAY;AAEhB,SAAgB,cAAsC;CACpD,OAAO;AACT;AAEA,SAAgB,YAAY,UAAwC;CAClE,YAAY;AACd;AAEA,SAAgB,WAId;CACA,OAAO,UAAU,SAAS;AAC5B"}
|
|
@@ -0,0 +1,32 @@
|
|
|
1
|
+
//#region src/registry/config.ts
|
|
2
|
+
let _registry = require("./StateContainerRegistry-CEWpc1bj.cjs").globalRegistry;
|
|
3
|
+
function getRegistry() {
|
|
4
|
+
return _registry;
|
|
5
|
+
}
|
|
6
|
+
function setRegistry(registry) {
|
|
7
|
+
_registry = registry;
|
|
8
|
+
}
|
|
9
|
+
function getStats() {
|
|
10
|
+
return _registry.getStats();
|
|
11
|
+
}
|
|
12
|
+
//#endregion
|
|
13
|
+
Object.defineProperty(exports, "getRegistry", {
|
|
14
|
+
enumerable: true,
|
|
15
|
+
get: function() {
|
|
16
|
+
return getRegistry;
|
|
17
|
+
}
|
|
18
|
+
});
|
|
19
|
+
Object.defineProperty(exports, "getStats", {
|
|
20
|
+
enumerable: true,
|
|
21
|
+
get: function() {
|
|
22
|
+
return getStats;
|
|
23
|
+
}
|
|
24
|
+
});
|
|
25
|
+
Object.defineProperty(exports, "setRegistry", {
|
|
26
|
+
enumerable: true,
|
|
27
|
+
get: function() {
|
|
28
|
+
return setRegistry;
|
|
29
|
+
}
|
|
30
|
+
});
|
|
31
|
+
|
|
32
|
+
//# sourceMappingURL=config-b2z51Y_C.cjs.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"config-b2z51Y_C.cjs","names":["globalRegistry"],"sources":["../src/registry/config.ts"],"sourcesContent":["import {\n globalRegistry,\n StateContainerRegistry,\n} from '../core/StateContainerRegistry';\n\nlet _registry = globalRegistry;\n\nexport function getRegistry(): StateContainerRegistry {\n return _registry;\n}\n\nexport function setRegistry(registry: StateContainerRegistry): void {\n _registry = registry;\n}\n\nexport function getStats(): {\n registeredTypes: number;\n totalInstances: number;\n typeBreakdown: Record<string, number>;\n} {\n return _registry.getStats();\n}\n"],"mappings":";AAKA,IAAI,2DAAYA,EAAAA;AAEhB,SAAgB,cAAsC;CACpD,OAAO;AACT;AAEA,SAAgB,YAAY,UAAwC;CAClE,YAAY;AACd;AAEA,SAAgB,WAId;CACA,OAAO,UAAU,SAAS;AAC5B"}
|
|
@@ -0,0 +1,16 @@
|
|
|
1
|
+
import { r as globalRegistry } from "./StateContainerRegistry-CvBOhAT2.js";
|
|
2
|
+
//#region src/registry/config.ts
|
|
3
|
+
let _registry = globalRegistry;
|
|
4
|
+
function getRegistry() {
|
|
5
|
+
return _registry;
|
|
6
|
+
}
|
|
7
|
+
function setRegistry(registry) {
|
|
8
|
+
_registry = registry;
|
|
9
|
+
}
|
|
10
|
+
function getStats() {
|
|
11
|
+
return _registry.getStats();
|
|
12
|
+
}
|
|
13
|
+
//#endregion
|
|
14
|
+
export { getStats as n, setRegistry as r, getRegistry as t };
|
|
15
|
+
|
|
16
|
+
//# sourceMappingURL=config-buwpT7l3.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"config-buwpT7l3.js","names":[],"sources":["../src/registry/config.ts"],"sourcesContent":["import {\n globalRegistry,\n StateContainerRegistry,\n} from '../core/StateContainerRegistry';\n\nlet _registry = globalRegistry;\n\nexport function getRegistry(): StateContainerRegistry {\n return _registry;\n}\n\nexport function setRegistry(registry: StateContainerRegistry): void {\n _registry = registry;\n}\n\nexport function getStats(): {\n registeredTypes: number;\n totalInstances: number;\n typeBreakdown: Record<string, number>;\n} {\n return _registry.getStats();\n}\n"],"mappings":";;AAKA,IAAI,YAAY;AAEhB,SAAgB,cAAsC;CACpD,OAAO;AACT;AAEA,SAAgB,YAAY,UAAwC;CAClE,YAAY;AACd;AAEA,SAAgB,WAId;CACA,OAAO,UAAU,SAAS;AAC5B"}
|
|
@@ -0,0 +1,32 @@
|
|
|
1
|
+
//#region src/registry/config.ts
|
|
2
|
+
let _registry = require("./StateContainerRegistry-CchRjnjX.cjs").globalRegistry;
|
|
3
|
+
function getRegistry() {
|
|
4
|
+
return _registry;
|
|
5
|
+
}
|
|
6
|
+
function setRegistry(registry) {
|
|
7
|
+
_registry = registry;
|
|
8
|
+
}
|
|
9
|
+
function getStats() {
|
|
10
|
+
return _registry.getStats();
|
|
11
|
+
}
|
|
12
|
+
//#endregion
|
|
13
|
+
Object.defineProperty(exports, "getRegistry", {
|
|
14
|
+
enumerable: true,
|
|
15
|
+
get: function() {
|
|
16
|
+
return getRegistry;
|
|
17
|
+
}
|
|
18
|
+
});
|
|
19
|
+
Object.defineProperty(exports, "getStats", {
|
|
20
|
+
enumerable: true,
|
|
21
|
+
get: function() {
|
|
22
|
+
return getStats;
|
|
23
|
+
}
|
|
24
|
+
});
|
|
25
|
+
Object.defineProperty(exports, "setRegistry", {
|
|
26
|
+
enumerable: true,
|
|
27
|
+
get: function() {
|
|
28
|
+
return setRegistry;
|
|
29
|
+
}
|
|
30
|
+
});
|
|
31
|
+
|
|
32
|
+
//# sourceMappingURL=config-d9_U58ef.cjs.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"config-d9_U58ef.cjs","names":["globalRegistry"],"sources":["../src/registry/config.ts"],"sourcesContent":["import {\n globalRegistry,\n StateContainerRegistry,\n} from '../core/StateContainerRegistry';\n\nlet _registry = globalRegistry;\n\nexport function getRegistry(): StateContainerRegistry {\n return _registry;\n}\n\nexport function setRegistry(registry: StateContainerRegistry): void {\n _registry = registry;\n}\n\nexport function getStats(): {\n registeredTypes: number;\n totalInstances: number;\n typeBreakdown: Record<string, number>;\n} {\n return _registry.getStats();\n}\n"],"mappings":";AAKA,IAAI,2DAAYA,EAAAA;AAEhB,SAAgB,cAAsC;CACpD,OAAO;AACT;AAEA,SAAgB,YAAY,UAAwC;CAClE,YAAY;AACd;AAEA,SAAgB,WAId;CACA,OAAO,UAAU,SAAS;AAC5B"}
|
|
@@ -0,0 +1,32 @@
|
|
|
1
|
+
//#region src/registry/config.ts
|
|
2
|
+
let _registry = require("./StateContainerRegistry-D9BIRjwv.cjs").globalRegistry;
|
|
3
|
+
function getRegistry() {
|
|
4
|
+
return _registry;
|
|
5
|
+
}
|
|
6
|
+
function setRegistry(registry) {
|
|
7
|
+
_registry = registry;
|
|
8
|
+
}
|
|
9
|
+
function getStats() {
|
|
10
|
+
return _registry.getStats();
|
|
11
|
+
}
|
|
12
|
+
//#endregion
|
|
13
|
+
Object.defineProperty(exports, "getRegistry", {
|
|
14
|
+
enumerable: true,
|
|
15
|
+
get: function() {
|
|
16
|
+
return getRegistry;
|
|
17
|
+
}
|
|
18
|
+
});
|
|
19
|
+
Object.defineProperty(exports, "getStats", {
|
|
20
|
+
enumerable: true,
|
|
21
|
+
get: function() {
|
|
22
|
+
return getStats;
|
|
23
|
+
}
|
|
24
|
+
});
|
|
25
|
+
Object.defineProperty(exports, "setRegistry", {
|
|
26
|
+
enumerable: true,
|
|
27
|
+
get: function() {
|
|
28
|
+
return setRegistry;
|
|
29
|
+
}
|
|
30
|
+
});
|
|
31
|
+
|
|
32
|
+
//# sourceMappingURL=config-hWTayX76.cjs.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"config-hWTayX76.cjs","names":["globalRegistry"],"sources":["../src/registry/config.ts"],"sourcesContent":["import {\n globalRegistry,\n StateContainerRegistry,\n} from '../core/StateContainerRegistry';\n\nlet _registry = globalRegistry;\n\nexport function getRegistry(): StateContainerRegistry {\n return _registry;\n}\n\nexport function setRegistry(registry: StateContainerRegistry): void {\n _registry = registry;\n}\n\nexport function getStats(): {\n registeredTypes: number;\n totalInstances: number;\n typeBreakdown: Record<string, number>;\n} {\n return _registry.getStats();\n}\n"],"mappings":";AAKA,IAAI,2DAAYA,EAAAA;AAEhB,SAAgB,cAAsC;CACpD,OAAO;AACT;AAEA,SAAgB,YAAY,UAAwC;CAClE,YAAY;AACd;AAEA,SAAgB,WAId;CACA,OAAO,UAAU,SAAS;AAC5B"}
|
package/dist/core/Cubit.d.ts
CHANGED
|
@@ -4,13 +4,13 @@ import { StateContainer } from './StateContainer';
|
|
|
4
4
|
* public mutation surface. Today it adds nothing structurally beyond
|
|
5
5
|
* `StateContainer` — both are inherited from the underlying
|
|
6
6
|
* `StructuralContainer<S>`. Kept as a real class (not a type alias) because
|
|
7
|
-
* downstream code does `instance instanceof Cubit` checks
|
|
7
|
+
* downstream code does `instance instanceof Cubit` checks.
|
|
8
8
|
*
|
|
9
9
|
* The class body is intentionally empty: a no-op `emit` override would
|
|
10
10
|
* still go through `applyState`, and `patch` is inherited from
|
|
11
|
-
* `StructuralContainer` (path-diffed, microtask-flushed).
|
|
12
|
-
*
|
|
13
|
-
*
|
|
11
|
+
* `StructuralContainer` (path-diffed, microtask-flushed). A caller that
|
|
12
|
+
* wants "skip if no real change" patch semantics can wrap `patch`
|
|
13
|
+
* themselves or call `emit` after a manual equality check.
|
|
14
14
|
*/
|
|
15
15
|
export declare abstract class Cubit<S extends object = any, Args = void, Deps extends object = Record<string, never>> extends StateContainer<S, Args, Deps> {
|
|
16
16
|
}
|
|
@@ -1,6 +1,7 @@
|
|
|
1
1
|
import { StructuralContainer, type DeepPartial, type StructuralContainerOptions } from '@dirtytalk/structural';
|
|
2
2
|
import type { ExtractArgs, ExtractState, StateContainerConstructor } from '../types/utilities';
|
|
3
|
-
import { APPLY_DEPS,
|
|
3
|
+
import { APPLY_DEPS, INIT_CONFIG, REMOVE_DEPS_OWNER } from './symbols';
|
|
4
|
+
import { type BlacMeta } from './meta';
|
|
4
5
|
/**
|
|
5
6
|
* Brand symbol carried (non-enumerable) on every handle returned by
|
|
6
7
|
* `depend()`. Framework adapters (`@blac/react`) use this to detect handles
|
|
@@ -45,7 +46,6 @@ export interface StateContainerConfig {
|
|
|
45
46
|
args?: unknown;
|
|
46
47
|
}
|
|
47
48
|
export type HydrationStatus = 'idle' | 'hydrating' | 'hydrated' | 'error';
|
|
48
|
-
type StateListener<S> = (state: S) => void;
|
|
49
49
|
export type SystemEvent = 'stateChanged' | 'dispose' | 'hydrationChanged';
|
|
50
50
|
export interface SystemEventPayloads<S> {
|
|
51
51
|
stateChanged: {
|
|
@@ -72,19 +72,15 @@ type SystemEventHandler<S, E extends SystemEvent> = (payload: SystemEventPayload
|
|
|
72
72
|
* - per-class `PathInterner`
|
|
73
73
|
*
|
|
74
74
|
* StateContainer layers on:
|
|
75
|
-
* - identity (
|
|
76
|
-
* -
|
|
77
|
-
* - hydration (`beginHydration` / `applyHydratedState` / `finishHydration` / `failHydration` / `waitForHydration`)
|
|
78
|
-
* - cross-bloc deps (`depend()`, `dependencies` getter)
|
|
75
|
+
* - identity / lifecycle / hydration (exposed via `$blac: BlacMeta`)
|
|
76
|
+
* - cross-bloc deps (`depend()`, `$blac.dependencies`)
|
|
79
77
|
* - per-consumer deps slices (`APPLY_DEPS` / `REMOVE_DEPS_OWNER` / `onDepsChanged`)
|
|
80
78
|
* - registry integration (config-driven equality, emit-rate circuit breaker)
|
|
81
79
|
*
|
|
82
80
|
* Subscribers can attach via:
|
|
83
|
-
* - `subscribe(listener)` — legacy state listener (back-compat); fires on
|
|
84
|
-
* every flush with the latest state.
|
|
85
81
|
* - `onSystemEvent('stateChanged' | 'dispose' | 'hydrationChanged', cb)` —
|
|
86
82
|
* coarse lifecycle events.
|
|
87
|
-
* - `this.channel.subscribe(interest, cb)` — path-scoped
|
|
83
|
+
* - `this.channel.subscribe(interest, cb)` — path-scoped.
|
|
88
84
|
*/
|
|
89
85
|
export declare abstract class StateContainer<S extends object = any, Args = void, Deps extends object = Record<string, never>> extends StructuralContainer<S> {
|
|
90
86
|
static __excludeFromDevTools: boolean;
|
|
@@ -123,18 +119,24 @@ export declare abstract class StateContainer<S extends object = any, Args = void
|
|
|
123
119
|
private _emitWindowStart;
|
|
124
120
|
private _emitCount;
|
|
125
121
|
private _emitRateWarned;
|
|
126
|
-
private readonly _listeners;
|
|
127
122
|
private readonly _systemEventHandlers;
|
|
128
123
|
private _dependencies;
|
|
129
124
|
private _pendingChange;
|
|
130
125
|
private _bridgeUnsub;
|
|
131
126
|
private _registry;
|
|
132
127
|
private _equalityFn;
|
|
133
|
-
|
|
134
|
-
|
|
135
|
-
|
|
136
|
-
|
|
137
|
-
|
|
128
|
+
private _name;
|
|
129
|
+
private _debug;
|
|
130
|
+
private _instanceId;
|
|
131
|
+
private _createdAt;
|
|
132
|
+
/**
|
|
133
|
+
* Reserved meta namespace: identity (`name`/`id`/`debug`/`createdAt`),
|
|
134
|
+
* lifecycle (`disposed`/`dependencies`), and the `hydration` sub-surface.
|
|
135
|
+
* Own, frozen, branded data property — `buildTrackedProxy` only intercepts
|
|
136
|
+
* prototype getters, so this own property and its closure-based getters are
|
|
137
|
+
* proxy-safe. See {@link createMeta}.
|
|
138
|
+
*/
|
|
139
|
+
readonly $blac: BlacMeta<S>;
|
|
138
140
|
get args(): Args | undefined;
|
|
139
141
|
/**
|
|
140
142
|
* Declare a cross-bloc dependency. Returns a branded handle with two
|
|
@@ -160,43 +162,37 @@ export declare abstract class StateContainer<S extends object = any, Args = void
|
|
|
160
162
|
* this.emit(...)) or kick off loads.
|
|
161
163
|
*/
|
|
162
164
|
protected init(_args: Args): void;
|
|
163
|
-
|
|
164
|
-
|
|
165
|
-
|
|
166
|
-
|
|
167
|
-
|
|
168
|
-
|
|
169
|
-
|
|
165
|
+
/**
|
|
166
|
+
* @internal Framework-only configuration entry point (registry + testing
|
|
167
|
+
* helpers). Writes the `_`-private identity fields directly, resolves
|
|
168
|
+
* per-class equality, emits the registry `created` event, and runs `init()`
|
|
169
|
+
* once. See {@link INIT_CONFIG}.
|
|
170
|
+
*/
|
|
171
|
+
[INIT_CONFIG](config: StateContainerConfig): void;
|
|
170
172
|
dispose(): void;
|
|
171
173
|
emit(next: S): void;
|
|
172
174
|
/**
|
|
173
175
|
* Override of `StructuralContainer.patch` that routes through the
|
|
174
176
|
* StateContainer concerns: disposed guard, dev-only emit-rate check,
|
|
175
|
-
* `_changedWhileHydrating` flag, pending-change capture (so
|
|
176
|
-
*
|
|
177
|
-
*
|
|
177
|
+
* `_changedWhileHydrating` flag, pending-change capture (so `stateChanged`
|
|
178
|
+
* system events see the merged prev/next), and the registry-level
|
|
179
|
+
* `stateChanged` notification. We still call
|
|
178
180
|
* `super.patch` so path-marking semantics (the whole point of patch) are
|
|
179
181
|
* preserved.
|
|
180
182
|
*/
|
|
181
183
|
patch(partial: DeepPartial<S>): void;
|
|
182
|
-
/**
|
|
183
|
-
* @internal @deprecated Symbol-keyed alias for `emit`. Kept only so legacy
|
|
184
|
-
* in-package tests that index with `[EMIT]` typecheck/run unchanged. C5
|
|
185
|
-
* removes this along with the `EMIT` symbol.
|
|
186
|
-
*/
|
|
187
|
-
protected [EMIT](next: S): void;
|
|
188
184
|
private applyState;
|
|
189
185
|
/**
|
|
190
186
|
* Called by the channel-bridge subscriber on each flush. Drains the
|
|
191
|
-
* pending change (if any) into
|
|
192
|
-
*
|
|
187
|
+
* pending change (if any) into the 'stateChanged' system event.
|
|
188
|
+
* No pending change == flush from a no-op patch == skip.
|
|
193
189
|
*/
|
|
194
190
|
private _drainPending;
|
|
195
|
-
|
|
196
|
-
|
|
197
|
-
|
|
198
|
-
|
|
199
|
-
|
|
191
|
+
private _beginHydration;
|
|
192
|
+
private _applyHydratedState;
|
|
193
|
+
private _finishHydration;
|
|
194
|
+
private _failHydration;
|
|
195
|
+
private _waitForHydration;
|
|
200
196
|
private setHydrationStatus;
|
|
201
197
|
private ensureHydrationPromise;
|
|
202
198
|
private resolveHydration;
|
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import type { StateContainer } from './StateContainer';
|
|
1
|
+
import type { HydrationStatus, StateContainer } from './StateContainer';
|
|
2
2
|
import { type PluginManager } from '../plugin/PluginManager';
|
|
3
3
|
import { InstanceReadonlyState, StateContainerConstructor } from '../types/utilities';
|
|
4
4
|
/**
|
|
@@ -16,12 +16,12 @@ export interface InstanceEntry<T = any> {
|
|
|
16
16
|
/**
|
|
17
17
|
* Lifecycle events emitted by the registry
|
|
18
18
|
*/
|
|
19
|
-
export type LifecycleEvent = 'created' | 'stateChanged' | 'disposed' | 'refAcquired' | 'refReleased' | 'depsChanged';
|
|
19
|
+
export type LifecycleEvent = 'created' | 'stateChanged' | 'disposed' | 'refAcquired' | 'refReleased' | 'depsChanged' | 'hydrationChanged';
|
|
20
20
|
/**
|
|
21
21
|
* Listener function type for each lifecycle event
|
|
22
22
|
* @template E - The lifecycle event type
|
|
23
23
|
*/
|
|
24
|
-
export type LifecycleListener<E extends LifecycleEvent> = E extends 'created' ? (container: StateContainer<any, any, any>) => void : E extends 'stateChanged' ? (container: StateContainer<any, any, any>, previousState: any, currentState: any) => void : E extends 'disposed' ? (container: StateContainer<any, any, any>) => void : E extends 'refAcquired' ? (container: StateContainer<any, any, any>, refId: string) => void : E extends 'refReleased' ? (container: StateContainer<any, any, any>, refId: string) => void : E extends 'depsChanged' ? (container: StateContainer<any, any, any>, previousDeps: Readonly<Record<string, unknown>>, currentDeps: Readonly<Record<string, unknown>>) => void : never;
|
|
24
|
+
export type LifecycleListener<E extends LifecycleEvent> = E extends 'created' ? (container: StateContainer<any, any, any>) => void : E extends 'stateChanged' ? (container: StateContainer<any, any, any>, previousState: any, currentState: any) => void : E extends 'disposed' ? (container: StateContainer<any, any, any>) => void : E extends 'refAcquired' ? (container: StateContainer<any, any, any>, refId: string) => void : E extends 'refReleased' ? (container: StateContainer<any, any, any>, refId: string) => void : E extends 'depsChanged' ? (container: StateContainer<any, any, any>, previousDeps: Readonly<Record<string, unknown>>, currentDeps: Readonly<Record<string, unknown>>) => void : E extends 'hydrationChanged' ? (container: StateContainer<any, any, any>, status: HydrationStatus, previousStatus: HydrationStatus) => void : never;
|
|
25
25
|
/**
|
|
26
26
|
* Central registry for managing StateContainer instances.
|
|
27
27
|
* Handles instance lifecycle, named ref tracking, and lifecycle event emission.
|
|
@@ -105,7 +105,7 @@ export declare class StateContainerRegistry {
|
|
|
105
105
|
* You must call `release()` with the same refId when done.
|
|
106
106
|
*
|
|
107
107
|
* @internal Internal key tier. Public callers use the args-based `acquire`
|
|
108
|
-
* wrapper; `useBloc
|
|
108
|
+
* wrapper; `useBloc` and `watch` address a pre-resolved key here.
|
|
109
109
|
* @param Type - The StateContainer class constructor
|
|
110
110
|
* @param instanceKey - Pre-resolved instance key (defaults to 'default')
|
|
111
111
|
* @param options - Acquisition options
|
|
@@ -258,6 +258,7 @@ export declare class StateContainerRegistry {
|
|
|
258
258
|
emit(event: 'refAcquired', container: StateContainer<any, any, any>, refId: string): void;
|
|
259
259
|
emit(event: 'refReleased', container: StateContainer<any, any, any>, refId: string): void;
|
|
260
260
|
emit(event: 'depsChanged', container: StateContainer<any, any, any>, previousDeps: Readonly<Record<string, unknown>>, currentDeps: Readonly<Record<string, unknown>>): void;
|
|
261
|
+
emit(event: 'hydrationChanged', container: StateContainer<any, any, any>, status: HydrationStatus, previousStatus: HydrationStatus): void;
|
|
261
262
|
/**
|
|
262
263
|
* Schedule a deferred stateChanged notification via microtask.
|
|
263
264
|
* Skips entirely when no stateChanged listeners are registered.
|
|
@@ -0,0 +1,73 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* `$blac` meta namespace for `StateContainer`.
|
|
3
|
+
*
|
|
4
|
+
* ──────────────────────────────────────────────────────────────────────────
|
|
5
|
+
* CONSTRAINT — NO ES `#private` FIELDS, ANYWHERE IN THIS FILE.
|
|
6
|
+
*
|
|
7
|
+
* `@blac/react`'s `buildTrackedProxy` invokes prototype getters with a
|
|
8
|
+
* `Proxy(instance)` as the `this`-receiver. Accessing an ES `#private` field
|
|
9
|
+
* through a proxy receiver throws (`#x` brand checks fail on the proxy). The
|
|
10
|
+
* whole point of this meta object is to be proxy-safe: every getter/method
|
|
11
|
+
* here closes over the *real* container instance captured at `createMeta`
|
|
12
|
+
* time, NEVER over a `this`-receiver. Do not "modernize" the `_`-prefixed
|
|
13
|
+
* TS-private reads below into `#private` access.
|
|
14
|
+
* ──────────────────────────────────────────────────────────────────────────
|
|
15
|
+
*/
|
|
16
|
+
import type { HydrationStatus } from './StateContainer';
|
|
17
|
+
import type { StateContainerConstructor } from '../types/utilities';
|
|
18
|
+
/**
|
|
19
|
+
* Hydration sub-surface of {@link BlacMeta}. Exposes the container's
|
|
20
|
+
* hydration state machine — the `begin`/`apply`/`finish`/`fail`/`wait`
|
|
21
|
+
* methods and the `status`/`error`/`isHydrated`/`changedWhileHydrating`
|
|
22
|
+
* getters — namespaced under `$blac`.
|
|
23
|
+
*/
|
|
24
|
+
export interface BlacHydration<S extends object> {
|
|
25
|
+
readonly status: HydrationStatus;
|
|
26
|
+
readonly error: Error | undefined;
|
|
27
|
+
readonly isHydrated: boolean;
|
|
28
|
+
readonly changedWhileHydrating: boolean;
|
|
29
|
+
begin(): void;
|
|
30
|
+
apply(next: S): boolean;
|
|
31
|
+
finish(): void;
|
|
32
|
+
fail(error: Error): void;
|
|
33
|
+
wait(): Promise<void>;
|
|
34
|
+
}
|
|
35
|
+
/**
|
|
36
|
+
* The reserved `$blac` instance member on every `StateContainer`. Gathers the
|
|
37
|
+
* container's identity/lifecycle/hydration surface (`name`, `id`, `debug`,
|
|
38
|
+
* `createdAt`, `disposed`, `dependencies`, and the hydration methods) under one
|
|
39
|
+
* namespace, keeping the generic names free for userland blocs.
|
|
40
|
+
*
|
|
41
|
+
* The object is allocated once per container, frozen, branded, and exposes
|
|
42
|
+
* live getters that read the container's current `_`-private fields — values
|
|
43
|
+
* are never snapshotted.
|
|
44
|
+
*/
|
|
45
|
+
export interface BlacMeta<S extends object = any> {
|
|
46
|
+
readonly name: string;
|
|
47
|
+
readonly id: string;
|
|
48
|
+
readonly debug: boolean;
|
|
49
|
+
readonly createdAt: number;
|
|
50
|
+
readonly disposed: boolean;
|
|
51
|
+
readonly dependencies: ReadonlyMap<StateContainerConstructor, string>;
|
|
52
|
+
readonly hydration: BlacHydration<S>;
|
|
53
|
+
}
|
|
54
|
+
/**
|
|
55
|
+
* Non-enumerable brand carried on every `$blac` object produced by
|
|
56
|
+
* {@link createMeta}. Used by the clobber guard in `StateContainer` to detect
|
|
57
|
+
* a subclass class-field shadowing the base's own `$blac` property, and by the
|
|
58
|
+
* meta tests. Intentionally NOT re-exported from the package barrel.
|
|
59
|
+
*/
|
|
60
|
+
export declare const META_BRAND: unique symbol;
|
|
61
|
+
/**
|
|
62
|
+
* Build the frozen, branded `$blac` meta object for a container.
|
|
63
|
+
*
|
|
64
|
+
* Called from a `StateContainer` field initializer (`$blac = createMeta(this)`).
|
|
65
|
+
* Only the back-reference is captured at this point; every getter/method reads
|
|
66
|
+
* the container's `_`-private fields lazily on access, so field-initializer
|
|
67
|
+
* ordering relative to those private fields is irrelevant.
|
|
68
|
+
*
|
|
69
|
+
* The getters close over `container` (the real instance), never over a
|
|
70
|
+
* `this`-receiver — this is what keeps `$blac` reads safe through
|
|
71
|
+
* `buildTrackedProxy`.
|
|
72
|
+
*/
|
|
73
|
+
export declare function createMeta<S extends object>(container: object): BlacMeta<S>;
|
package/dist/core/symbols.d.ts
CHANGED
|
@@ -1,27 +1,20 @@
|
|
|
1
|
-
/**
|
|
2
|
-
* @internal @deprecated Symbol-keyed mutation entry point on `StateContainer`.
|
|
3
|
-
*
|
|
4
|
-
* Per A2 audit (`plans/blac-core-migration/_audit.md`), this symbol has zero
|
|
5
|
-
* external consumers — only in-package tests still reference it. C0 keeps it
|
|
6
|
-
* as a thin alias for `emit()` so the existing test files typecheck and run
|
|
7
|
-
* unchanged; C5 will port those tests to use `emit()` directly and delete
|
|
8
|
-
* this symbol along with its `[EMIT]` method on `StateContainer`.
|
|
9
|
-
*
|
|
10
|
-
* Do not add new uses of this symbol.
|
|
11
|
-
*/
|
|
12
|
-
export declare const EMIT: unique symbol;
|
|
13
1
|
/**
|
|
14
2
|
* @internal Apply one owner's (consumer's) deps slice to an instance.
|
|
15
3
|
* Called by framework adapters (e.g. @blac/react useBloc) — not public API.
|
|
16
|
-
*
|
|
17
|
-
* Kept until D0 ports `useBloc` off the legacy adapter surface. See A2 audit
|
|
18
|
-
* (`plans/blac-core-migration/_audit.md`) for the consumer list.
|
|
19
4
|
*/
|
|
20
5
|
export declare const APPLY_DEPS: unique symbol;
|
|
21
6
|
/**
|
|
22
7
|
* @internal Withdraw one owner's entire deps slice (consumer unmounted).
|
|
23
8
|
* Called by framework adapters — not public API.
|
|
24
|
-
*
|
|
25
|
-
* Kept until D0 ports `useBloc`. See A2 audit for the consumer list.
|
|
26
9
|
*/
|
|
27
10
|
export declare const REMOVE_DEPS_OWNER: unique symbol;
|
|
11
|
+
/**
|
|
12
|
+
* @internal Symbol-keyed configuration entry point on `StateContainer`.
|
|
13
|
+
* Writes the instance's identity fields (`_name`/`_debug`/`_instanceId`),
|
|
14
|
+
* resolves per-class equality, emits the registry `created` event, and runs
|
|
15
|
+
* `init()` once.
|
|
16
|
+
*
|
|
17
|
+
* Framework-only — the registry (`StateContainerRegistry.ensure`) and testing
|
|
18
|
+
* helpers are the sole callers, mirroring the `APPLY_DEPS` precedent.
|
|
19
|
+
*/
|
|
20
|
+
export declare const INIT_CONFIG: unique symbol;
|