@blac/core 2.0.0-rc-14 → 2.0.0-rc.0
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/dist/.tsbuildinfo +1 -0
- package/dist/Blac.d.ts +246 -0
- package/dist/Blac.d.ts.map +1 -0
- package/dist/Blac.js +625 -0
- package/dist/Blac.js.map +1 -0
- package/dist/Bloc.d.ts +41 -0
- package/dist/Bloc.d.ts.map +1 -0
- package/dist/Bloc.js +140 -0
- package/dist/Bloc.js.map +1 -0
- package/dist/BlocBase.d.ts +110 -0
- package/dist/BlocBase.d.ts.map +1 -0
- package/dist/BlocBase.js +287 -0
- package/dist/BlocBase.js.map +1 -0
- package/dist/Cubit.d.ts +25 -0
- package/dist/Cubit.d.ts.map +1 -0
- package/dist/Cubit.js +64 -0
- package/dist/Cubit.js.map +1 -0
- package/dist/adapter/BlacAdapter.d.ts +71 -0
- package/dist/adapter/BlacAdapter.d.ts.map +1 -0
- package/dist/adapter/BlacAdapter.js +373 -0
- package/dist/adapter/BlacAdapter.js.map +1 -0
- package/dist/adapter/ProxyFactory.d.ts +50 -0
- package/dist/adapter/ProxyFactory.d.ts.map +1 -0
- package/dist/adapter/ProxyFactory.js +150 -0
- package/dist/adapter/ProxyFactory.js.map +1 -0
- package/{src/adapter/index.ts → dist/adapter/index.d.ts} +1 -0
- package/dist/adapter/index.d.ts.map +1 -0
- package/dist/adapter/index.js +19 -0
- package/dist/adapter/index.js.map +1 -0
- package/dist/errors/BlacError.d.ts +38 -0
- package/dist/errors/BlacError.d.ts.map +1 -0
- package/dist/errors/BlacError.js +55 -0
- package/dist/errors/BlacError.js.map +1 -0
- package/dist/errors/ErrorManager.d.ts +39 -0
- package/dist/errors/ErrorManager.d.ts.map +1 -0
- package/dist/errors/ErrorManager.js +91 -0
- package/dist/errors/ErrorManager.js.map +1 -0
- package/dist/errors/handleError.d.ts +24 -0
- package/dist/errors/handleError.d.ts.map +1 -0
- package/dist/errors/handleError.js +62 -0
- package/dist/errors/handleError.js.map +1 -0
- package/dist/errors/index.d.ts +5 -0
- package/dist/errors/index.d.ts.map +1 -0
- package/dist/errors/index.js +13 -0
- package/dist/errors/index.js.map +1 -0
- package/{src/events.ts → dist/events.d.ts} +4 -2
- package/dist/events.d.ts.map +1 -0
- package/dist/events.js +17 -0
- package/dist/events.js.map +1 -0
- package/dist/index.cjs +38 -0
- package/dist/index.d.ts +17 -1303
- package/dist/index.d.ts.map +1 -0
- package/dist/index.js +38 -0
- package/dist/index.js.map +1 -0
- package/dist/lifecycle/BlocLifecycle.d.ts +51 -0
- package/dist/lifecycle/BlocLifecycle.d.ts.map +1 -0
- package/dist/lifecycle/BlocLifecycle.js +123 -0
- package/dist/lifecycle/BlocLifecycle.js.map +1 -0
- package/dist/lifecycle/index.d.ts +2 -0
- package/dist/lifecycle/index.d.ts.map +1 -0
- package/dist/lifecycle/index.js +18 -0
- package/dist/lifecycle/index.js.map +1 -0
- package/dist/plugins/BlocPluginRegistry.d.ts +58 -0
- package/dist/plugins/BlocPluginRegistry.d.ts.map +1 -0
- package/dist/plugins/BlocPluginRegistry.js +201 -0
- package/dist/plugins/BlocPluginRegistry.js.map +1 -0
- package/dist/plugins/SystemPluginRegistry.d.ts +79 -0
- package/dist/plugins/SystemPluginRegistry.d.ts.map +1 -0
- package/dist/plugins/SystemPluginRegistry.js +184 -0
- package/dist/plugins/SystemPluginRegistry.js.map +1 -0
- package/{src/plugins/index.ts → dist/plugins/index.d.ts} +1 -5
- package/dist/plugins/index.d.ts.map +1 -0
- package/dist/plugins/index.js +26 -0
- package/dist/plugins/index.js.map +1 -0
- package/dist/plugins/types.d.ts +103 -0
- package/dist/plugins/types.d.ts.map +1 -0
- package/dist/plugins/types.js +3 -0
- package/dist/plugins/types.js.map +1 -0
- package/dist/subscription/SubscriptionManager.d.ts +67 -0
- package/dist/subscription/SubscriptionManager.d.ts.map +1 -0
- package/dist/subscription/SubscriptionManager.js +317 -0
- package/dist/subscription/SubscriptionManager.js.map +1 -0
- package/{src/subscription/index.ts → dist/subscription/index.d.ts} +1 -0
- package/dist/subscription/index.d.ts.map +1 -0
- package/dist/subscription/index.js +19 -0
- package/dist/subscription/index.js.map +1 -0
- package/dist/subscription/types.d.ts +65 -0
- package/dist/subscription/types.d.ts.map +1 -0
- package/dist/subscription/types.js +3 -0
- package/dist/subscription/types.js.map +1 -0
- package/dist/testing.d.ts +85 -0
- package/dist/testing.d.ts.map +1 -0
- package/dist/testing.js +186 -0
- package/dist/testing.js.map +1 -0
- package/{src/types.ts → dist/types.d.ts} +11 -28
- package/dist/types.d.ts.map +1 -0
- package/dist/types.js +3 -0
- package/dist/types.js.map +1 -0
- package/dist/utils/BatchingManager.d.ts +28 -0
- package/dist/utils/BatchingManager.d.ts.map +1 -0
- package/dist/utils/BatchingManager.js +48 -0
- package/dist/utils/BatchingManager.js.map +1 -0
- package/dist/utils/RerenderLogger.d.ts +60 -0
- package/dist/utils/RerenderLogger.d.ts.map +1 -0
- package/dist/utils/RerenderLogger.js +205 -0
- package/dist/utils/RerenderLogger.js.map +1 -0
- package/dist/utils/generateInstanceId.d.ts +11 -0
- package/dist/utils/generateInstanceId.d.ts.map +1 -0
- package/dist/utils/generateInstanceId.js +50 -0
- package/dist/utils/generateInstanceId.js.map +1 -0
- package/dist/utils/shallowEqual.d.ts +9 -0
- package/dist/utils/shallowEqual.d.ts.map +1 -0
- package/dist/utils/shallowEqual.js +35 -0
- package/dist/utils/shallowEqual.js.map +1 -0
- package/dist/utils/uuid.d.ts +10 -0
- package/dist/utils/uuid.d.ts.map +1 -0
- package/dist/utils/uuid.js +24 -0
- package/dist/utils/uuid.js.map +1 -0
- package/package.json +17 -10
- package/dist/index.cjs.js +0 -11
- package/dist/index.cjs.js.map +0 -1
- package/dist/index.es.js +0 -2275
- package/dist/index.es.js.map +0 -1
- package/src/Blac.ts +0 -802
- package/src/Bloc.ts +0 -180
- package/src/BlocBase.ts +0 -398
- package/src/Cubit.ts +0 -68
- package/src/__tests__/Blac.config.test.ts +0 -79
- package/src/__tests__/Bloc.event.test.ts +0 -394
- package/src/__tests__/BlocBase.subscription.test.ts +0 -349
- package/src/__tests__/Cubit.test.ts +0 -462
- package/src/__tests__/memory-leaks.test.ts +0 -383
- package/src/__tests__/plugins.test.ts +0 -464
- package/src/adapter/BlacAdapter.ts +0 -467
- package/src/adapter/ProxyFactory.ts +0 -249
- package/src/adapter/__tests__/BlacAdapter.test.ts +0 -555
- package/src/adapter/__tests__/ProxyFactory.test.ts +0 -655
- package/src/errors/BlacError.ts +0 -69
- package/src/errors/ErrorManager.ts +0 -101
- package/src/errors/handleError.ts +0 -114
- package/src/errors/index.ts +0 -13
- package/src/index.ts +0 -26
- package/src/lifecycle/BlocLifecycle.ts +0 -156
- package/src/lifecycle/index.ts +0 -1
- package/src/plugins/BlocPluginRegistry.ts +0 -240
- package/src/plugins/SystemPluginRegistry.ts +0 -242
- package/src/plugins/__tests__/BlocPluginRegistry.test.ts +0 -450
- package/src/plugins/__tests__/SystemPluginRegistry.test.ts +0 -404
- package/src/plugins/types.ts +0 -129
- package/src/subscription/README.md +0 -132
- package/src/subscription/SubscriptionManager.ts +0 -395
- package/src/subscription/__tests__/SubscriptionManager.test.ts +0 -355
- package/src/subscription/types.ts +0 -90
- package/src/testing.ts +0 -246
- package/src/utils/BatchingManager.ts +0 -59
- package/src/utils/RerenderLogger.ts +0 -265
- package/src/utils/__tests__/generateInstanceId.test.ts +0 -104
- package/src/utils/__tests__/shallowEqual.test.ts +0 -171
- package/src/utils/__tests__/uuid.test.ts +0 -144
- package/src/utils/generateInstanceId.ts +0 -54
- package/src/utils/shallowEqual.ts +0 -40
- package/src/utils/uuid.ts +0 -22
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"generateInstanceId.d.ts","sourceRoot":"","sources":["../../src/utils/generateInstanceId.ts"],"names":[],"mappings":"AAAA;;;;;;;;GAQG;AACH,wBAAgB,2BAA2B,CACzC,KAAK,EAAE,OAAO,GACb,MAAM,GAAG,SAAS,CA0CpB"}
|
|
@@ -0,0 +1,50 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
+
exports.generateInstanceIdFromProps = generateInstanceIdFromProps;
|
|
4
|
+
/**
|
|
5
|
+
* Generates a deterministic instance ID from static props by extracting primitive values
|
|
6
|
+
*
|
|
7
|
+
* Rules:
|
|
8
|
+
* 1. Only considers primitive types: string, number, boolean, null, undefined
|
|
9
|
+
* 2. Ignores complex types: objects, arrays, functions, symbols
|
|
10
|
+
* 3. Sorts keys alphabetically for deterministic output
|
|
11
|
+
* 4. Returns undefined if no primitives found (caller should use default ID)
|
|
12
|
+
*/
|
|
13
|
+
function generateInstanceIdFromProps(props) {
|
|
14
|
+
if (!props || typeof props !== 'object') {
|
|
15
|
+
return undefined;
|
|
16
|
+
}
|
|
17
|
+
const primitives = [];
|
|
18
|
+
// Extract primitive values
|
|
19
|
+
for (const [key, value] of Object.entries(props)) {
|
|
20
|
+
const type = typeof value;
|
|
21
|
+
if (type === 'string' ||
|
|
22
|
+
type === 'number' ||
|
|
23
|
+
type === 'boolean' ||
|
|
24
|
+
value === null ||
|
|
25
|
+
value === undefined) {
|
|
26
|
+
primitives.push([key, value]);
|
|
27
|
+
}
|
|
28
|
+
}
|
|
29
|
+
// No primitives found
|
|
30
|
+
if (primitives.length === 0) {
|
|
31
|
+
return undefined;
|
|
32
|
+
}
|
|
33
|
+
// Sort by key for deterministic output
|
|
34
|
+
primitives.sort(([a], [b]) => a.localeCompare(b));
|
|
35
|
+
// Create instance ID
|
|
36
|
+
const parts = [];
|
|
37
|
+
for (const [key, value] of primitives) {
|
|
38
|
+
if (value === null) {
|
|
39
|
+
parts.push(`${key}:null`);
|
|
40
|
+
}
|
|
41
|
+
else if (value === undefined) {
|
|
42
|
+
parts.push(`${key}:undefined`);
|
|
43
|
+
}
|
|
44
|
+
else {
|
|
45
|
+
parts.push(`${key}:${String(value)}`);
|
|
46
|
+
}
|
|
47
|
+
}
|
|
48
|
+
return parts.join('|');
|
|
49
|
+
}
|
|
50
|
+
//# sourceMappingURL=generateInstanceId.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"generateInstanceId.js","sourceRoot":"","sources":["../../src/utils/generateInstanceId.ts"],"names":[],"mappings":";;AASA,kEA4CC;AArDD;;;;;;;;GAQG;AACH,SAAgB,2BAA2B,CACzC,KAAc;IAEd,IAAI,CAAC,KAAK,IAAI,OAAO,KAAK,KAAK,QAAQ,EAAE,CAAC;QACxC,OAAO,SAAS,CAAC;IACnB,CAAC;IAED,MAAM,UAAU,GAA6B,EAAE,CAAC;IAEhD,2BAA2B;IAC3B,KAAK,MAAM,CAAC,GAAG,EAAE,KAAK,CAAC,IAAI,MAAM,CAAC,OAAO,CAAC,KAAK,CAAC,EAAE,CAAC;QACjD,MAAM,IAAI,GAAG,OAAO,KAAK,CAAC;QAC1B,IACE,IAAI,KAAK,QAAQ;YACjB,IAAI,KAAK,QAAQ;YACjB,IAAI,KAAK,SAAS;YAClB,KAAK,KAAK,IAAI;YACd,KAAK,KAAK,SAAS,EACnB,CAAC;YACD,UAAU,CAAC,IAAI,CAAC,CAAC,GAAG,EAAE,KAAK,CAAC,CAAC,CAAC;QAChC,CAAC;IACH,CAAC;IAED,sBAAsB;IACtB,IAAI,UAAU,CAAC,MAAM,KAAK,CAAC,EAAE,CAAC;QAC5B,OAAO,SAAS,CAAC;IACnB,CAAC;IAED,uCAAuC;IACvC,UAAU,CAAC,IAAI,CAAC,CAAC,CAAC,CAAC,CAAC,EAAE,CAAC,CAAC,CAAC,EAAE,EAAE,CAAC,CAAC,CAAC,aAAa,CAAC,CAAC,CAAC,CAAC,CAAC;IAElD,qBAAqB;IACrB,MAAM,KAAK,GAAa,EAAE,CAAC;IAC3B,KAAK,MAAM,CAAC,GAAG,EAAE,KAAK,CAAC,IAAI,UAAU,EAAE,CAAC;QACtC,IAAI,KAAK,KAAK,IAAI,EAAE,CAAC;YACnB,KAAK,CAAC,IAAI,CAAC,GAAG,GAAG,OAAO,CAAC,CAAC;QAC5B,CAAC;aAAM,IAAI,KAAK,KAAK,SAAS,EAAE,CAAC;YAC/B,KAAK,CAAC,IAAI,CAAC,GAAG,GAAG,YAAY,CAAC,CAAC;QACjC,CAAC;aAAM,CAAC;YACN,KAAK,CAAC,IAAI,CAAC,GAAG,GAAG,IAAI,MAAM,CAAC,KAAK,CAAC,EAAE,CAAC,CAAC;QACxC,CAAC;IACH,CAAC;IAED,OAAO,KAAK,CAAC,IAAI,CAAC,GAAG,CAAC,CAAC;AACzB,CAAC"}
|
|
@@ -0,0 +1,9 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Performs a shallow equality comparison between two values.
|
|
3
|
+
* For objects, it checks if all top-level properties are equal using Object.is.
|
|
4
|
+
* @param a First value to compare
|
|
5
|
+
* @param b Second value to compare
|
|
6
|
+
* @returns true if values are shallowly equal, false otherwise
|
|
7
|
+
*/
|
|
8
|
+
export declare function shallowEqual(a: any, b: any): boolean;
|
|
9
|
+
//# sourceMappingURL=shallowEqual.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"shallowEqual.d.ts","sourceRoot":"","sources":["../../src/utils/shallowEqual.ts"],"names":[],"mappings":"AAAA;;;;;;GAMG;AACH,wBAAgB,YAAY,CAAC,CAAC,EAAE,GAAG,EAAE,CAAC,EAAE,GAAG,GAAG,OAAO,CAgCpD"}
|
|
@@ -0,0 +1,35 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
+
exports.shallowEqual = shallowEqual;
|
|
4
|
+
/**
|
|
5
|
+
* Performs a shallow equality comparison between two values.
|
|
6
|
+
* For objects, it checks if all top-level properties are equal using Object.is.
|
|
7
|
+
* @param a First value to compare
|
|
8
|
+
* @param b Second value to compare
|
|
9
|
+
* @returns true if values are shallowly equal, false otherwise
|
|
10
|
+
*/
|
|
11
|
+
function shallowEqual(a, b) {
|
|
12
|
+
if (Object.is(a, b)) {
|
|
13
|
+
return true;
|
|
14
|
+
}
|
|
15
|
+
if (typeof a !== 'object' ||
|
|
16
|
+
a === null ||
|
|
17
|
+
typeof b !== 'object' ||
|
|
18
|
+
b === null) {
|
|
19
|
+
return false;
|
|
20
|
+
}
|
|
21
|
+
const keysA = Object.keys(a);
|
|
22
|
+
const keysB = Object.keys(b);
|
|
23
|
+
if (keysA.length !== keysB.length) {
|
|
24
|
+
return false;
|
|
25
|
+
}
|
|
26
|
+
for (let i = 0; i < keysA.length; i++) {
|
|
27
|
+
const key = keysA[i];
|
|
28
|
+
if (!Object.prototype.hasOwnProperty.call(b, key) ||
|
|
29
|
+
!Object.is(a[key], b[key])) {
|
|
30
|
+
return false;
|
|
31
|
+
}
|
|
32
|
+
}
|
|
33
|
+
return true;
|
|
34
|
+
}
|
|
35
|
+
//# sourceMappingURL=shallowEqual.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"shallowEqual.js","sourceRoot":"","sources":["../../src/utils/shallowEqual.ts"],"names":[],"mappings":";;AAOA,oCAgCC;AAvCD;;;;;;GAMG;AACH,SAAgB,YAAY,CAAC,CAAM,EAAE,CAAM;IACzC,IAAI,MAAM,CAAC,EAAE,CAAC,CAAC,EAAE,CAAC,CAAC,EAAE,CAAC;QACpB,OAAO,IAAI,CAAC;IACd,CAAC;IAED,IACE,OAAO,CAAC,KAAK,QAAQ;QACrB,CAAC,KAAK,IAAI;QACV,OAAO,CAAC,KAAK,QAAQ;QACrB,CAAC,KAAK,IAAI,EACV,CAAC;QACD,OAAO,KAAK,CAAC;IACf,CAAC;IAED,MAAM,KAAK,GAAG,MAAM,CAAC,IAAI,CAAC,CAAC,CAAC,CAAC;IAC7B,MAAM,KAAK,GAAG,MAAM,CAAC,IAAI,CAAC,CAAC,CAAC,CAAC;IAE7B,IAAI,KAAK,CAAC,MAAM,KAAK,KAAK,CAAC,MAAM,EAAE,CAAC;QAClC,OAAO,KAAK,CAAC;IACf,CAAC;IAED,KAAK,IAAI,CAAC,GAAG,CAAC,EAAE,CAAC,GAAG,KAAK,CAAC,MAAM,EAAE,CAAC,EAAE,EAAE,CAAC;QACtC,MAAM,GAAG,GAAG,KAAK,CAAC,CAAC,CAAC,CAAC;QACrB,IACE,CAAC,MAAM,CAAC,SAAS,CAAC,cAAc,CAAC,IAAI,CAAC,CAAC,EAAE,GAAG,CAAC;YAC7C,CAAC,MAAM,CAAC,EAAE,CAAC,CAAC,CAAC,GAAG,CAAC,EAAE,CAAC,CAAC,GAAG,CAAC,CAAC,EAC1B,CAAC;YACD,OAAO,KAAK,CAAC;QACf,CAAC;IACH,CAAC;IAED,OAAO,IAAI,CAAC;AACd,CAAC"}
|
|
@@ -0,0 +1,10 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Cross-platform UUID v4 generator that works in all environments including React Native/Hermes
|
|
3
|
+
* Falls back to crypto.randomUUID() when available, otherwise uses Math.random()
|
|
4
|
+
*/
|
|
5
|
+
/**
|
|
6
|
+
* Generates a UUID v4 string compatible with all JavaScript environments
|
|
7
|
+
* @returns A UUID v4 string in the format xxxxxxxx-xxxx-4xxx-yxxx-xxxxxxxxxxxx
|
|
8
|
+
*/
|
|
9
|
+
export declare function generateUUID(): string;
|
|
10
|
+
//# sourceMappingURL=uuid.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"uuid.d.ts","sourceRoot":"","sources":["../../src/utils/uuid.ts"],"names":[],"mappings":"AAAA;;;GAGG;AAEH;;;GAGG;AACH,wBAAgB,YAAY,IAAI,MAAM,CAYrC"}
|
|
@@ -0,0 +1,24 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
/**
|
|
3
|
+
* Cross-platform UUID v4 generator that works in all environments including React Native/Hermes
|
|
4
|
+
* Falls back to crypto.randomUUID() when available, otherwise uses Math.random()
|
|
5
|
+
*/
|
|
6
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
7
|
+
exports.generateUUID = generateUUID;
|
|
8
|
+
/**
|
|
9
|
+
* Generates a UUID v4 string compatible with all JavaScript environments
|
|
10
|
+
* @returns A UUID v4 string in the format xxxxxxxx-xxxx-4xxx-yxxx-xxxxxxxxxxxx
|
|
11
|
+
*/
|
|
12
|
+
function generateUUID() {
|
|
13
|
+
// Try to use crypto.randomUUID() if available (Node.js 16+, modern browsers)
|
|
14
|
+
if (typeof crypto !== 'undefined' && crypto.randomUUID) {
|
|
15
|
+
return crypto.randomUUID();
|
|
16
|
+
}
|
|
17
|
+
// Fallback implementation for React Native/Hermes and older environments
|
|
18
|
+
return 'xxxxxxxx-xxxx-4xxx-yxxx-xxxxxxxxxxxx'.replace(/[xy]/g, function (c) {
|
|
19
|
+
const r = (Math.random() * 16) | 0;
|
|
20
|
+
const v = c === 'x' ? r : (r & 0x3) | 0x8;
|
|
21
|
+
return v.toString(16);
|
|
22
|
+
});
|
|
23
|
+
}
|
|
24
|
+
//# sourceMappingURL=uuid.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"uuid.js","sourceRoot":"","sources":["../../src/utils/uuid.ts"],"names":[],"mappings":";AAAA;;;GAGG;;AAMH,oCAYC;AAhBD;;;GAGG;AACH,SAAgB,YAAY;IAC1B,6EAA6E;IAC7E,IAAI,OAAO,MAAM,KAAK,WAAW,IAAI,MAAM,CAAC,UAAU,EAAE,CAAC;QACvD,OAAO,MAAM,CAAC,UAAU,EAAE,CAAC;IAC7B,CAAC;IAED,yEAAyE;IACzE,OAAO,sCAAsC,CAAC,OAAO,CAAC,OAAO,EAAE,UAAU,CAAC;QACxE,MAAM,CAAC,GAAG,CAAC,IAAI,CAAC,MAAM,EAAE,GAAG,EAAE,CAAC,GAAG,CAAC,CAAC;QACnC,MAAM,CAAC,GAAG,CAAC,KAAK,GAAG,CAAC,CAAC,CAAC,CAAC,CAAC,CAAC,CAAC,CAAC,CAAC,GAAG,GAAG,CAAC,GAAG,GAAG,CAAC;QAC1C,OAAO,CAAC,CAAC,QAAQ,CAAC,EAAE,CAAC,CAAC;IACxB,CAAC,CAAC,CAAC;AACL,CAAC"}
|
package/package.json
CHANGED
|
@@ -1,15 +1,20 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@blac/core",
|
|
3
|
-
"version": "2.0.0-rc
|
|
3
|
+
"version": "2.0.0-rc.0",
|
|
4
4
|
"license": "MIT",
|
|
5
5
|
"author": "Brendan Mullins <jsnanigans@gmail.com>",
|
|
6
|
-
"main": "dist/index.
|
|
7
|
-
"module": "dist/index.
|
|
8
|
-
"
|
|
9
|
-
"
|
|
6
|
+
"main": "./dist/index.js",
|
|
7
|
+
"module": "./dist/index.js",
|
|
8
|
+
"types": "./dist/index.d.ts",
|
|
9
|
+
"exports": {
|
|
10
|
+
".": {
|
|
11
|
+
"types": "./dist/index.d.ts",
|
|
12
|
+
"import": "./dist/index.js",
|
|
13
|
+
"require": "./dist/index.cjs"
|
|
14
|
+
}
|
|
15
|
+
},
|
|
10
16
|
"files": [
|
|
11
17
|
"dist",
|
|
12
|
-
"src",
|
|
13
18
|
"README.md",
|
|
14
19
|
"LICENSE"
|
|
15
20
|
],
|
|
@@ -30,17 +35,19 @@
|
|
|
30
35
|
"jsdom": "^26.1.0",
|
|
31
36
|
"prettier": "^3.6.2",
|
|
32
37
|
"typescript": "^5.9.2",
|
|
33
|
-
"vite": "^7.0.6",
|
|
34
|
-
"vite-plugin-dts": "^4.5.4",
|
|
35
38
|
"vitest": "^3.2.4"
|
|
36
39
|
},
|
|
37
40
|
"scripts": {
|
|
41
|
+
"dev": "tsc --watch --project tsconfig.build.json",
|
|
42
|
+
"build": "pnpm run clean && pnpm run build:esm && pnpm run build:cjs",
|
|
43
|
+
"build:esm": "tsc --project tsconfig.build.json",
|
|
44
|
+
"build:cjs": "tsc --project tsconfig.build.json --module commonjs --outDir dist --declaration false --declarationMap false && cp dist/index.js dist/index.cjs",
|
|
45
|
+
"clean": "rm -rf dist",
|
|
38
46
|
"format": "prettier --write \".\"",
|
|
39
47
|
"test": "vitest run",
|
|
40
48
|
"test:watch": "vitest --watch",
|
|
41
49
|
"coverage": "vitest run --coverage",
|
|
42
50
|
"typecheck": "tsc --noEmit",
|
|
43
|
-
"
|
|
44
|
-
"deploy": "pnpm run build && pnpm publish --access public"
|
|
51
|
+
"deploy": "pnpm publish --access public"
|
|
45
52
|
}
|
|
46
53
|
}
|
package/dist/index.cjs.js
DELETED
|
@@ -1,11 +0,0 @@
|
|
|
1
|
-
"use strict";Object.defineProperty(exports,Symbol.toStringTag,{value:"Module"});var u=(r=>(r.ACTIVE="active",r.DISPOSAL_REQUESTED="disposal_requested",r.DISPOSING="disposing",r.DISPOSED="disposed",r))(u||{});class C{disposalState="active";disposalLock=!1;disposalTimer;disposalHandler;get currentState(){return this.disposalState}get isDisposed(){return this.disposalState==="disposed"}atomicStateTransition(e,t){if(this.disposalLock)return{success:!1,currentState:this.disposalState,previousState:this.disposalState};this.disposalLock=!0;try{if(this.disposalState!==e)return{success:!1,currentState:this.disposalState,previousState:this.disposalState};const s=this.disposalState;return this.disposalState=t,{success:!0,currentState:t,previousState:s}}finally{this.disposalLock=!1}}scheduleDisposal(e,t,s){this.disposalTimer&&(clearTimeout(this.disposalTimer),this.disposalTimer=void 0),this.atomicStateTransition("active","disposal_requested").success&&(this.disposalTimer=setTimeout(()=>{t()&&this.disposalState==="disposal_requested"?s():this.atomicStateTransition("disposal_requested","active")},e))}cancelDisposal(){return this.disposalState==="disposal_requested"?(this.disposalTimer&&(clearTimeout(this.disposalTimer),this.disposalTimer=void 0),this.atomicStateTransition("disposal_requested","active").success):!1}setDisposalHandler(e){this.disposalHandler=e}getDisposalHandler(){return this.disposalHandler}clearDisposalTimer(){this.disposalTimer&&(clearTimeout(this.disposalTimer),this.disposalTimer=void 0)}}class E{plugins=new Map;metrics=new Map;executionOrder=[];add(e){if(this.plugins.has(e.name))throw new Error(`Plugin '${e.name}' is already registered`);this.plugins.set(e.name,e),this.executionOrder.push(e.name),this.initializeMetrics(e.name)}remove(e){return this.plugins.get(e)?(this.plugins.delete(e),this.metrics.delete(e),this.executionOrder=this.executionOrder.filter(s=>s!==e),!0):!1}get(e){return this.plugins.get(e)}getAll(){return this.executionOrder.map(e=>this.plugins.get(e))}clear(){this.plugins.clear(),this.metrics.clear(),this.executionOrder=[]}executeHook(e,t,s){for(const i of this.executionOrder){const n=this.plugins.get(i),a=n[e];if(typeof a!="function")continue;const c=performance.now();try{a.apply(n,t),this.recordSuccess(i,e,c)}catch(l){this.recordError(i,e,l),s?s(l,n):console.error(`Plugin '${i}' error in hook '${e}':`,l)}}}bootstrap(){this.executeHook("beforeBootstrap",[]),this.executeHook("afterBootstrap",[])}shutdown(){this.executeHook("beforeShutdown",[]),this.executeHook("afterShutdown",[])}notifyBlocCreated(e){this.executeHook("onBlocCreated",[e])}notifyBlocDisposed(e){this.executeHook("onBlocDisposed",[e])}notifyStateChanged(e,t,s){this.executeHook("onStateChanged",[e,t,s])}notifyEventAdded(e,t){this.executeHook("onEventAdded",[e,t])}notifyError(e,t,s){this.executeHook("onError",[e,t,s],(i,n)=>{console.error(`Plugin '${n.name}' error handler failed:`,i)})}notifyAdapterCreated(e,t){this.executeHook("onAdapterCreated",[e,t])}notifyAdapterMount(e,t){this.executeHook("onAdapterMount",[e,t])}notifyAdapterUnmount(e,t){this.executeHook("onAdapterUnmount",[e,t])}notifyAdapterRender(e,t){this.executeHook("onAdapterRender",[e,t])}notifyAdapterDisposed(e,t){this.executeHook("onAdapterDisposed",[e,t])}getMetrics(e){return this.metrics.get(e)}initializeMetrics(e){this.metrics.set(e,new Map)}recordSuccess(e,t,s){const i=this.metrics.get(e),n=i.get(t)||{executionTime:0,executionCount:0,errorCount:0},a=performance.now()-s;i.set(t,{...n,executionTime:n.executionTime+a,executionCount:n.executionCount+1,lastExecutionTime:a})}recordError(e,t,s){const i=this.metrics.get(e),n=i.get(t)||{executionTime:0,executionCount:0,errorCount:0};i.set(t,{...n,errorCount:n.errorCount+1,lastError:s})}}var S=(r=>(r.LIFECYCLE="LIFECYCLE",r.STATE="STATE",r.PLUGIN="PLUGIN",r.VALIDATION="VALIDATION",r.DISPOSAL="DISPOSAL",r.CONSUMER="CONSUMER",r))(S||{}),m=(r=>(r.FATAL="FATAL",r.ERROR="ERROR",r.WARNING="WARNING",r.INFO="INFO",r))(m||{});class y extends Error{constructor(e,t,s,i,n){super(e),this.category=t,this.severity=s,this.context=i,this.cause=n,this.name="BlacError",Object.setPrototypeOf(this,y.prototype)}toString(){const e=this.context?` [${Object.entries(this.context).filter(([t,s])=>s!==void 0).map(([t,s])=>`${t}: ${s}`).join(", ")}]`:"";return`${this.name} [${this.severity}/${this.category}]: ${this.message}${e}`}}const w={shouldPropagate:r=>r.severity==="FATAL",shouldLog:r=>r.severity!=="INFO",handle:r=>{w.shouldLog(r)&&console.error(r.toString(),r.cause)}};class g{static instance;handlers=new Set;strategy=w;static getInstance(){return g.instance||(g.instance=new g),g.instance}setStrategy(e){this.strategy=e}addHandler(e){this.handlers.add(e)}removeHandler(e){this.handlers.delete(e)}handle(e){if(this.handlers.forEach(t=>{try{t(e)}catch(s){console.error("Error in error handler:",s)}}),this.strategy.handle(e),this.strategy.shouldPropagate(e))throw e}wrap(e,t){try{return e()}catch(s){const i=t(s);this.handle(i);return}}async wrapAsync(e,t){try{return await e()}catch(s){const i=t(s);this.handle(i);return}}}class f{static _instance;getInstance(){return f._instance||(f._instance=new o({__unsafe_ignore_singleton:!0})),f._instance}setInstance(e){f._instance=e}resetInstance(){const e=f._instance;if(f._instance=new o({__unsafe_ignore_singleton:!0}),e)for(const t of e.keepAliveBlocs)f._instance.keepAliveBlocs.add(t),f._instance.uidRegistry.set(t.uid,t)}}let b=new f;function N(r){b=r}class o{static get instance(){return b.getInstance()}createdAt=Date.now();errorManager=g.getInstance();static get getAllBlocs(){return o.instance.getAllBlocs}static _config={proxyDependencyTracking:!0};static get config(){return{...this._config}}static setConfig(e){if(e.proxyDependencyTracking!==void 0&&typeof e.proxyDependencyTracking!="boolean"){const t=new y("BlacConfig.proxyDependencyTracking must be a boolean",S.VALIDATION,m.FATAL);this.instance.errorManager.handle(t)}this._config={...this._config,...e},this.enableLog&&this.instance.log("Blac config updated:",this._config)}blocInstanceMap=new Map;isolatedBlocMap=new Map;isolatedBlocIndex=new Map;uidRegistry=new Map;keepAliveBlocs=new Set;postChangesToDocument=!1;plugins=new E;constructor(e={}){const{__unsafe_ignore_singleton:t=!1}=e;if(!t)return o.instance;b.setInstance(this),this.plugins.bootstrap()}static enableLog=!1;static logLevel="warn";static logSpy=null;log=(...e)=>{o.logSpy&&o.logSpy(e),o.enableLog&&o.logLevel,o.enableLog&&o.logLevel};static get log(){return o.instance.log}static getInstance(){return b.getInstance()}warn=(e,...t)=>{console.warn(e,...t)};static get warn(){return o.instance.warn}error=(e,...t)=>{o.enableLog&&console.error(e,...t)};static get error(){return o.instance.error}resetInstance=()=>{this.log("Reset Blac instance");const e=new Map(this.blocInstanceMap),t=new Map(this.isolatedBlocMap);e.forEach(s=>{!s._keepAlive&&s._disposalState===u.ACTIVE&&this.disposeBloc(s)}),t.forEach(s=>{s.forEach(i=>{!i._keepAlive&&i._disposalState===u.ACTIVE&&this.disposeBloc(i)})}),this.blocInstanceMap.clear(),this.isolatedBlocMap.clear(),this.isolatedBlocIndex.clear(),b.resetInstance()};static resetInstance=()=>{b.resetInstance()};disposeBloc=e=>{const t=e._disposalState;if(![u.ACTIVE,u.DISPOSAL_REQUESTED].includes(t)){this.log(`[${e._name}:${String(e._id)}] disposeBloc called on bloc in invalid state: ${t}`);return}const i=e.constructor,n=this.createBlocInstanceMapKey(e._name,e._id);this.log(`[${e._name}:${String(e._id)}] disposeBloc called. Isolated: ${String(i.isolated)}`),e.dispose(),this.plugins.notifyBlocDisposed(e),i.isolated?(this.unregisterIsolatedBlocInstance(e),this.blocInstanceMap.delete(n)):this.unregisterBlocInstance(e),this.log("dispatched bloc",e)};static get disposeBloc(){return o.instance.disposeBloc}createBlocInstanceMapKey(e,t){return`${e}:${String(t)}`}unregisterBlocInstance(e){const t=this.createBlocInstanceMapKey(e._name,e._id);this.blocInstanceMap.delete(t),this.uidRegistry.delete(e.uid),this.keepAliveBlocs.delete(e)}registerBlocInstance(e){const t=this.createBlocInstanceMapKey(e._name,e._id);this.blocInstanceMap.set(t,e),this.uidRegistry.set(e.uid,e),e._keepAlive&&this.keepAliveBlocs.add(e)}findRegisteredBlocInstance(e,t){if(e.isolated)return;const i=this.createBlocInstanceMapKey(e.name,t),n=this.blocInstanceMap.get(i);if(!(n&&n.isDisposed))return n}registerIsolatedBlocInstance(e){const t=e.constructor,s=this.isolatedBlocMap.get(t);s?s.push(e):this.isolatedBlocMap.set(t,[e]),this.isolatedBlocIndex.set(e.uid,e),this.uidRegistry.set(e.uid,e),e._keepAlive&&this.keepAliveBlocs.add(e)}unregisterIsolatedBlocInstance(e){const t=e.constructor,s=this.isolatedBlocMap.get(t);let i=!1;if(s){const a=s.findIndex(c=>c.uid===e.uid);a!==-1&&(s.splice(a,1),i=!0),s.length===0&&this.isolatedBlocMap.delete(t)}const n=this.isolatedBlocIndex.delete(e.uid);this.uidRegistry.delete(e.uid),this.keepAliveBlocs.delete(e),i!==n&&this.warn(`[Blac] Inconsistent state detected during isolated bloc cleanup for ${e._name}:${e.uid}. Map removal: ${i}, Index removal: ${n}`)}findIsolatedBlocInstance(e,t){if(!e.isolated)return;const i=this.isolatedBlocMap.get(e);return i?i.find(a=>a._id===t&&!a.isDisposed):void 0}findIsolatedBlocInstanceByUid(e){return this.isolatedBlocIndex.get(e)}createNewBlocInstance(e,t,s={}){const{constructorParams:i,instanceRef:n}=s,a=new e(i);return a.blacInstance=this,a._instanceRef=n,a._id=t,a.setDisposalHandler(c=>this.disposeBloc(c)),a.isIsolated?this.registerIsolatedBlocInstance(a):this.registerBlocInstance(a),this.plugins.notifyBlocCreated(a),a}activateBloc=e=>{if(e._disposalState!==u.ACTIVE){this.log(`[${e._name}:${String(e._id)}] activateBloc called on disposed bloc. Ignoring.`);return}const t=e.constructor;(e.isIsolated?this.findIsolatedBlocInstance(t,e._id):this.findRegisteredBlocInstance(t,e._id))||(this.log(`[${e._name}:${String(e._id)}] activateBloc called. Isolated: ${String(e.isIsolated)}`),e.isIsolated?this.registerIsolatedBlocInstance(e):this.registerBlocInstance(e))};static get activateBloc(){return o.instance.activateBloc}getBloc=(e,t={})=>{const{id:s,forceNewInstance:i}=t,n=e,a=s??e.name;if(this.log(`[${e.name}:${String(a)}] (getBloc) Called:`,{options:t,base:n}),!i)if(n.isolated){const l=this.findIsolatedBlocInstance(e,t.instanceRef??a);if(l)return l;if(t.throwIfNotFound)throw new Error(`Isolated bloc ${e.name} not found`)}else{const l=this.findRegisteredBlocInstance(e,a);if(l)return l;if(t.throwIfNotFound)throw new Error(`Registered bloc ${e.name} not found`)}const c=this.createNewBlocInstance(e,a,t);if(this.log(`[${e.name}:${String(a)}] (getBloc) No existing instance found. Creating new one.`,t,c),!c)throw new Error(`[getBloc] Failed to create bloc instance for ${e.name}. This should never happen.`);return c};static get getBloc(){return o.instance.getBloc}getAllBlocs=(e,t={})=>{const s=[];if(this.blocInstanceMap.forEach(i=>{i.constructor===e&&s.push(i)}),t.searchIsolated!==!1){const i=this.isolatedBlocMap.get(e);i&&s.push(...i.map(n=>n))}return s};disposeKeepAliveBlocs=e=>{const t=[];for(const s of this.keepAliveBlocs)(!e||s.constructor===e)&&t.push(s);t.forEach(s=>s.dispose())};static get disposeKeepAliveBlocs(){return o.instance.disposeKeepAliveBlocs}disposeBlocs=e=>{const t=[];for(const s of this.blocInstanceMap.values())e(s)&&t.push(s);for(const s of this.isolatedBlocMap.values())for(const i of s)e(i)&&t.push(i);t.forEach(s=>s.dispose())};static get disposeBlocs(){return o.instance.disposeBlocs}getMemoryStats=()=>({totalBlocs:this.uidRegistry.size,registeredBlocs:this.blocInstanceMap.size,isolatedBlocs:Array.from(this.isolatedBlocMap.values()).reduce((e,t)=>e+t.length,0),keepAliveBlocs:this.keepAliveBlocs.size,isolatedBlocTypes:this.isolatedBlocMap.size});static get getMemoryStats(){return o.instance.getMemoryStats}validateConsumers=()=>{for(const e of this.uidRegistry.values())e.subscriptionCount===0&&!e._keepAlive&&e._disposalState===u.ACTIVE&&setTimeout(()=>{e.subscriptionCount===0&&!e._keepAlive&&e._disposalState===u.ACTIVE&&this.disposeBloc(e)},1e3)};static get validateConsumers(){return o.instance.validateConsumers}bootstrap(){this.plugins.bootstrap()}shutdown(){this.plugins.shutdown();for(const e of this.blocInstanceMap.values())e._keepAlive||this.disposeBloc(e);for(const e of this.isolatedBlocMap.values())for(const t of e)t._keepAlive||this.disposeBloc(t)}}function A(){return typeof crypto<"u"&&crypto.randomUUID?crypto.randomUUID():"xxxxxxxx-xxxx-4xxx-yxxx-xxxxxxxxxxxx".replace(/[xy]/g,function(r){const e=Math.random()*16|0;return(r==="x"?e:e&3|8).toString(16)})}const k={fatal:(r,e,t,s)=>{const i=new y(r,e,m.FATAL,t,s);throw g.getInstance().handle(i),i},error:(r,e,t,s)=>{const i=new y(r,e,m.ERROR,t,s);g.getInstance().handle(i)},warn:(r,e,t,s)=>{const i=new y(r,e,m.WARNING,t,s);g.getInstance().handle(i)},info:(r,e,t)=>{const s=new y(r,e,m.INFO,t);g.getInstance().handle(s)},wrap:(r,e,t,s=m.ERROR)=>{try{return r()}catch(i){const n=i instanceof Error?i.message:String(i),a=new y(n,e,s,t,i);g.getInstance().handle(a);return}},wrapAsync:async(r,e,t,s=m.ERROR)=>{try{return await r()}catch(i){const n=i instanceof Error?i.message:String(i),a=new y(n,e,s,t,i);g.getInstance().handle(a);return}}};class x{plugins=new Map;executionOrder=[];attached=!1;add(e){if(this.plugins.has(e.name))throw new Error(`Plugin '${e.name}' is already registered`);e.capabilities&&this.validateCapabilities(e),this.plugins.set(e.name,e),this.executionOrder.push(e.name)}remove(e){const t=this.plugins.get(e);return t?(this.attached&&t.onDetach&&k.wrap(()=>t.onDetach(),S.PLUGIN,{pluginName:e,operation:"onDetach"}),this.plugins.delete(e),this.executionOrder=this.executionOrder.filter(s=>s!==e),!0):!1}get(e){return this.plugins.get(e)}getAll(){return this.executionOrder.map(e=>this.plugins.get(e))}clear(){if(this.attached)for(const e of this.getAll())e.onDetach&&k.wrap(()=>e.onDetach(),S.PLUGIN,{pluginName:e.name,operation:"onDetach"});this.plugins.clear(),this.executionOrder=[],this.attached=!1}attach(e){if(this.attached)throw new Error("Plugins are already attached");for(const t of this.getAll())if(t.onAttach)try{t.onAttach(e)}catch(s){console.error(`Plugin '${t.name}' error in onAttach:`,s),this.remove(t.name)}this.attached=!0}transformState(e,t){let s=t;for(const i of this.getAll())if(i.transformState&&this.canTransformState(i))try{s=i.transformState(e,s)}catch(n){console.error(`Plugin '${i.name}' error in transformState:`,n)}return s}transformEvent(e){let t=e;for(const s of this.getAll()){if(t===null)break;if(s.transformEvent&&this.canInterceptEvents(s))try{t=s.transformEvent(t)}catch(i){console.error(`Plugin '${s.name}' error in transformEvent:`,i)}}return t}notifyStateChange(e,t){for(const s of this.getAll())if(s.onStateChange&&this.canReadState(s))try{s.onStateChange(e,t)}catch(i){console.error(`Plugin '${s.name}' error in onStateChange:`,i)}}notifyEvent(e){for(const t of this.getAll())if(t.onEvent&&this.canReadState(t))try{t.onEvent(e)}catch(s){console.error(`Plugin '${t.name}' error in onEvent:`,s)}}notifyError(e,t){for(const s of this.getAll())if(s.onError)try{s.onError(e,t)}catch(i){console.error(`Plugin '${s.name}' error in onError:`,i)}}validateCapabilities(e){const t=e.capabilities;if(t.transformState&&!t.readState)throw new Error(`Plugin '${e.name}': transformState requires readState capability`);if(t.interceptEvents&&!t.readState)throw new Error(`Plugin '${e.name}': interceptEvents requires readState capability`)}canReadState(e){return!e.capabilities||e.capabilities.readState!==!1}canTransformState(e){return!e.capabilities||e.capabilities.transformState===!0}canInterceptEvents(e){return!e.capabilities||e.capabilities.interceptEvents===!0}}class T{constructor(e){this.bloc=e}subscriptions=new Map;pathToSubscriptions=new Map;weakRefCleanupScheduled=!1;totalNotifications=0;subscribe(e){const t=`${e.type}-${A()}`,s={id:t,type:e.type,selector:e.selector,equalityFn:e.equalityFn||Object.is,notify:e.notify,priority:e.priority??0,weakRef:e.weakRef,dependencies:new Set,metadata:{lastNotified:Date.now(),hasRendered:!1,accessCount:0,firstAccessTime:Date.now()}};if(s.selector)try{s.lastValue=s.selector(this.bloc.state,this.bloc)}catch(i){o.error(`SubscriptionManager: Error in selector for ${t}:`,i)}return this.subscriptions.set(t,s),o.log(`[${this.bloc._name}:${this.bloc._id}] Subscription added: ${t}. Total: ${this.subscriptions.size}`),this.bloc._cancelDisposalIfRequested(),()=>this.unsubscribe(t)}unsubscribe(e){const t=this.subscriptions.get(e);if(t){if(t.dependencies)for(const s of t.dependencies){const i=this.pathToSubscriptions.get(s);i&&(i.delete(e),i.size===0&&this.pathToSubscriptions.delete(s))}this.subscriptions.delete(e),o.log(`[${this.bloc._name}:${this.bloc._id}] Subscription removed: ${e}. Remaining: ${this.subscriptions.size}`),this.bloc.checkDisposal()}}notify(e,t,s){this.cleanupDeadReferences();const i=Array.from(this.subscriptions.values()).sort((n,a)=>(a.priority??0)-(n.priority??0));for(const n of i){if(n.weakRef&&!n.weakRef.deref()){this.scheduleWeakRefCleanup();continue}let a=!1,c,l;if(n.selector)try{c=n.selector(e,this.bloc),l=n.lastValue,a=!(n.equalityFn||Object.is)(l,c),a&&(n.lastValue=c)}catch(h){o.error(`SubscriptionManager: Error in selector for ${n.id}:`,h);continue}else{if(n.dependencies&&n.dependencies.size>0){const h=this.getChangedPaths(t,e);a=this.shouldNotifyForPaths(n.id,h),o.config.logLevel==="debug"&&(o.log(`[SubscriptionManager] Subscription ${n.id} dependencies:`,Array.from(n.dependencies)),o.log("[SubscriptionManager] Changed paths:",Array.from(h)),o.log("[SubscriptionManager] Should notify:",a))}else a=!0;c=e,l=t}if(a)try{n.notify(c,l,s),this.totalNotifications++,n.metadata&&(n.metadata.lastNotified=Date.now(),n.metadata.hasRendered=!0)}catch(h){o.error(`SubscriptionManager: Error in notify for ${n.id}:`,h)}}}trackAccess(e,t,s){const i=this.subscriptions.get(e);if(!i)return;i.dependencies||(i.dependencies=new Set),i.dependencies.add(t);let n=this.pathToSubscriptions.get(t);n||(n=new Set,this.pathToSubscriptions.set(t,n)),n.add(e),i.metadata&&(i.metadata.accessCount=(i.metadata.accessCount||0)+1,i.metadata.lastAccessTime=Date.now())}getChangedPaths(e,t,s=""){const i=new Set;if(e===t)return i;if(typeof e!="object"||typeof t!="object"||e===null||t===null)return s&&i.add(s),i;const n=new Set([...Object.keys(e),...Object.keys(t)]);for(const a of n){const c=s?`${s}.${a}`:a,l=e[a],h=t[a];l!==h&&(i.add(c),typeof l=="object"&&typeof h=="object"&&l!==null&&h!==null&&this.getChangedPaths(l,h,c).forEach(v=>i.add(v)))}return i}shouldNotifyForPaths(e,t){const s=this.subscriptions.get(e);if(!s||!s.dependencies)return!0;for(const i of s.dependencies){if(i.startsWith("_class.")){if(t.size>0)return!0;continue}if(t.has(i))return!0;for(const n of t)if(n.startsWith(i+".")||i.startsWith(n+"."))return!0}return!1}getStats(){let e=0,t=0;for(const s of this.subscriptions.values())s.type==="consumer"?e++:t++;return{activeSubscriptions:this.subscriptions.size,consumerCount:e,observerCount:t,totalNotifications:this.totalNotifications,trackedDependencies:this.pathToSubscriptions.size}}clear(){this.subscriptions.clear(),this.pathToSubscriptions.clear()}getSubscription(e){return this.subscriptions.get(e)}get hasSubscriptions(){return this.subscriptions.size>0}get size(){return this.subscriptions.size}cleanupDeadReferences(){if(!this.weakRefCleanupScheduled)return;const e=[];for(const[t,s]of this.subscriptions)s.weakRef&&!s.weakRef.deref()&&e.push(t);for(const t of e)this.unsubscribe(t);this.weakRefCleanupScheduled=!1}scheduleWeakRefCleanup(){this.weakRefCleanupScheduled||(this.weakRefCleanupScheduled=!0,queueMicrotask(()=>this.cleanupDeadReferences()))}}class L{pendingUpdates=[];isBatching=!1;batchUpdates(e,t){if(this.isBatching){e();return}this.isBatching=!0,this.pendingUpdates=[];try{if(e(),this.pendingUpdates.length>0){const s=this.pendingUpdates[this.pendingUpdates.length-1];t(s)}}finally{this.isBatching=!1,this.pendingUpdates=[]}}addUpdate(e){this.isBatching&&this.pendingUpdates.push(e)}get isCurrentlyBatching(){return this.isBatching}}class B{uid=A();blacInstance;static isolated=!1;get isIsolated(){return this._isolated}static keepAlive=!1;get isKeepAlive(){return this._keepAlive}_isolated=!1;_id;_instanceRef;_name;_subscriptionManager;_state;_lifecycleManager=new C;_batchingManager=new L;_keepAlive=!1;lastUpdate;_plugins=new x;onDispose;constructor(e){this._state=e,this._id=this.constructor.name,this._name=this.constructor.name,this._subscriptionManager=new T(this);const t=this.constructor;if(this._keepAlive=typeof t.keepAlive=="boolean"?t.keepAlive:!1,this._isolated=typeof t.isolated=="boolean"?t.isolated:!1,this._plugins=new x,t.plugins&&Array.isArray(t.plugins))for(const s of t.plugins)this._plugins.add(s);this._plugins.attach(this)}get state(){return this._lifecycleManager.isDisposed?this._state:this._state}subscribe(e){return this._subscriptionManager.subscribe({type:"observer",notify:t=>e(t)})}subscribeWithSelector(e,t,s){return this._subscriptionManager.subscribe({type:"consumer",selector:e,equalityFn:s,notify:i=>t(i)})}subscribeComponent(e,t){return this._subscriptionManager.subscribe({type:"consumer",weakRef:e,notify:t})}get subscriptionCount(){return this._subscriptionManager.size}trackAccess(e,t,s){this._subscriptionManager.trackAccess(e,t,s)}emit(e,t){this._pushState(e,this._state,t)}_pushState(e,t,s){if(this._lifecycleManager.currentState!==u.ACTIVE){this.blacInstance?.error(`[${this._name}:${this._id}] Attempted state update on ${this._lifecycleManager.currentState} bloc. Update ignored.`);return}if(e===void 0)return;this._state=e;const i=this._plugins.transformState(t,e);if(this._state=i,this._plugins.notifyStateChange(t,i),this.blacInstance?.plugins.notifyStateChanged(this,t,i),this._batchingManager.isCurrentlyBatching){this._batchingManager.addUpdate({newState:i,oldState:t,action:s});return}this._subscriptionManager.notify(i,t,s),this.lastUpdate=Date.now()}_batchUpdates(e){this._batchingManager.batchUpdates(e,t=>{this._subscriptionManager.notify(t.newState,t.oldState,t.action)})}addPlugin(e){if(this._plugins.add(e),this._plugins.attached&&e.onAttach)try{e.onAttach(this)}catch(t){console.error(`Plugin '${e.name}' error in onAttach:`,t)}}removePlugin(e){this._plugins.remove(e.name)}get plugins(){return this._plugins.getAll()}get isDisposed(){return this._lifecycleManager.isDisposed}_atomicStateTransition(e,t){return this._lifecycleManager.atomicStateTransition(e,t)}async dispose(){if(!this._lifecycleManager.atomicStateTransition(u.ACTIVE,u.DISPOSING).success)if(this._lifecycleManager.currentState===u.DISPOSAL_REQUESTED)this._lifecycleManager.atomicStateTransition(u.DISPOSAL_REQUESTED,u.DISPOSING);else return;try{this._subscriptionManager.clear(),this.onDispose&&this.onDispose();for(const s of this._plugins.getAll())try{"onDispose"in s&&typeof s.onDispose=="function"&&s.onDispose(this)}catch(i){console.error("Plugin disposal error:",i)}const t=this._lifecycleManager.getDisposalHandler();t&&t(this)}finally{this._lifecycleManager.atomicStateTransition(u.DISPOSING,u.DISPOSED)}}_scheduleDisposal(){this._subscriptionManager.size===0&&!this._keepAlive&&this._lifecycleManager.scheduleDisposal(16,()=>this._subscriptionManager.size===0&&!this._keepAlive,()=>this.dispose())}setDisposalHandler(e){this._lifecycleManager.setDisposalHandler(e)}checkDisposal(){this._subscriptionManager.size===0&&!this._keepAlive&&this._lifecycleManager.currentState===u.ACTIVE&&this._scheduleDisposal()}_cancelDisposalIfRequested(){this.blacInstance?.log(`[${this._name}:${this._id}] _cancelDisposalIfRequested called. Current state: ${this._lifecycleManager.currentState}`),this._lifecycleManager.cancelDisposal()?this.blacInstance?.log(`[${this._name}:${this._id}] Disposal cancelled - new subscription added`):this._lifecycleManager.currentState===u.DISPOSAL_REQUESTED?this.blacInstance?.warn(`[${this._name}:${this._id}] Failed to cancel disposal. Current state: ${this._lifecycleManager.currentState}`):this._lifecycleManager.isDisposed&&this.blacInstance?.error(`[${this._name}:${this._id}] Cannot cancel disposal - bloc is already disposed`)}}class D extends B{eventHandlers=new Map;_eventQueue=[];_isProcessingEvent=!1;on(e,t){this.eventHandlers.has(e)&&o.warn(`[Bloc ${this._name}:${String(this._id)}] Handler for event '${e.name}' already registered. It will be overwritten.`),this.eventHandlers.set(e,t)}add=async e=>{let t=e;try{t=this._plugins.transformEvent(e)}catch(s){console.error("Error transforming event:",s)}if(t!==null){try{this._plugins.notifyEvent(t)}catch(s){console.error("Error notifying plugins of event:",s)}o.instance.plugins.notifyEventAdded(this,t),this._eventQueue.push(t),this._isProcessingEvent||await this._processEventQueue()}};async _processEventQueue(){if(!this._isProcessingEvent){this._isProcessingEvent=!0;try{for(;this._eventQueue.length>0;){const e=this._eventQueue.shift();await this._processEvent(e)}}finally{this._isProcessingEvent=!1}}}async _processEvent(e){const t=e.constructor,s=this.eventHandlers.get(t);if(s){const i=n=>{const a=this.state;this._pushState(n,a,e)};try{await s(e,i)}catch(n){const a=e.constructor.name||"UnnamedConstructor",c={blocName:this._name,blocId:String(this._id),eventType:a,currentState:this.state,action:e,timestamp:new Date().toISOString()};if(o.error(`[Bloc ${this._name}:${String(this._id)}] Error in event handler for '${a}':`,n,"Context:",c),n instanceof Error)try{this._plugins.notifyError(n,{phase:"event-processing",operation:"handler",metadata:{event:e}}),o.instance.plugins.notifyError(n,this,{phase:"event-processing",operation:"handler",metadata:{event:e}})}catch(l){console.error("Error notifying plugins:",l)}if(n instanceof Error&&n.name==="CriticalError")throw n}}else{const i=e.constructor.name||"UnnamedConstructor";o.warn(`[Bloc ${this._name}:${String(this._id)}] No handler registered for action type: '${i}'.`,"Registered handlers:",Array.from(this.eventHandlers.keys()).map(n=>n.name),"Action was:",e)}}}class R extends B{emit(e){if(Object.is(e,this.state))return;const t=this.state,s=e;this._pushState(s,t)}patch(e,t=!1){if(typeof this.state!="object"||this.state===null){o.warn("Cubit.patch: was called on a cubit where the state is not an object. This is a no-op.");return}let s=!1;if(t)s=!0;else for(const i in e)if(Object.prototype.hasOwnProperty.call(e,i)){const a=this.state[i];if(!Object.is(e[i],a)){s=!0;break}}s&&this.emit({...this.state,...e})}}class U{constructor(e){this.props=e}}function H(r,e){if(Object.is(r,e))return!0;if(typeof r!="object"||r===null||typeof e!="object"||e===null)return!1;const t=Object.keys(r),s=Object.keys(e);if(t.length!==s.length)return!1;for(let i=0;i<t.length;i++){const n=t[i];if(!Object.prototype.hasOwnProperty.call(e,n)||!Object.is(r[n],e[n]))return!1}return!0}function O(r){if(!r||typeof r!="object")return;const e=[];for(const[s,i]of Object.entries(r)){const n=typeof i;(n==="string"||n==="number"||n==="boolean"||i===null||i===void 0)&&e.push([s,i])}if(e.length===0)return;e.sort(([s],[i])=>s.localeCompare(i));const t=[];for(const[s,i]of e)i===null?t.push(`${s}:null`):i===void 0?t.push(`${s}:undefined`):t.push(`${s}:${String(i)}`);return t.join("|")}class V{static componentRenderCounts=new Map;static lastRenderTimestamps=new Map;static groupedLogs=new Map;static groupTimeouts=new Map;static logRerender(e){const t=o._config?.rerenderLogging;if(!t)return;const s=this.parseConfig(t);if(!s.enabled||s.filter&&!s.filter({componentName:e.componentName,blocName:e.blocName}))return;const i=`${e.componentName}-${e.blocId}`,n=this.componentRenderCounts.get(i)||0;this.componentRenderCounts.set(i,n+1),e.renderCount=n+1;const a=this.lastRenderTimestamps.get(i);a&&(e.duration=e.timestamp-a),this.lastRenderTimestamps.set(i,e.timestamp),s.includeStackTrace&&s.level==="detailed"&&(e.stackTrace=new Error().stack),s.groupRerenders?this.logGrouped(e,s):this.logImmediate(e,s)}static parseConfig(e){return e===!0?{enabled:!0,level:"normal"}:typeof e=="string"?{enabled:!0,level:e==="minimal"?"minimal":"detailed"}:{enabled:e.enabled,level:e.level||"normal",filter:e.filter,includeStackTrace:e.includeStackTrace,groupRerenders:e.groupRerenders}}static logImmediate(e,t){const s=this.formatMessage(e,t.level);t.level==="detailed"?(console.group(s.header),s.details&&console.log(s.details),s.values&&console.table(s.values),e.stackTrace&&console.log("Stack trace:",e.stackTrace),console.groupEnd()):console.log(s.header,s.details||"")}static logGrouped(e,t){const s=`${e.componentName}-${e.blocId}`,i=this.groupTimeouts.get(s);i&&clearTimeout(i);const n=this.groupedLogs.get(s)||[];n.push(e),this.groupedLogs.set(s,n);const a=setTimeout(()=>{const c=this.groupedLogs.get(s)||[];this.groupedLogs.delete(s),this.groupTimeouts.delete(s),c.length===1?this.logImmediate(c[0],t):(console.group(`🔄 ${e.componentName} rendered ${c.length} times (${e.blocName})`),c.forEach((l,h)=>{const p=this.formatMessage(l,t.level);console.log(` ${h+1}. ${p.details||p.header}`)}),console.groupEnd())},50);this.groupTimeouts.set(s,a)}static formatMessage(e,t){const s=this.getReasonEmoji(e.reason.type);if(t==="minimal")return{header:`${s} ${e.componentName} #${e.renderCount}`,details:null,values:null};const i=`${s} ${e.componentName} rerender #${e.renderCount} (${e.blocName})`;let n=`Reason: ${e.reason.description||e.reason.type}`;e.duration!==void 0&&(n+=` | Time since last: ${e.duration}ms`),t==="normal"&&e.reason.changedPaths&&e.reason.changedPaths.length>0&&(n+=` | Changed: ${e.reason.changedPaths.join(", ")}`);let a=null;return t==="detailed"&&e.reason.changedPaths&&e.reason.changedPaths.length>0&&(a={},e.reason.changedPaths.forEach(c=>{a[c]={old:e.reason.oldValues?.[c],new:e.reason.newValues?.[c]}}),Object.keys(a).length===0&&(a=null)),{header:i,details:n,values:a}}static getReasonEmoji(e){switch(e){case"state-change":return"📊";case"dependency-change":return"🔗";case"mount":return"🚀";case"props-change":return"📦";default:return"🔄"}}static clear(){this.componentRenderCounts.clear(),this.lastRenderTimestamps.clear(),this.groupedLogs.clear(),this.groupTimeouts.forEach(e=>clearTimeout(e)),this.groupTimeouts.clear()}static getRenderCount(e,t){return this.componentRenderCounts.get(`${e}-${t}`)||0}}class F{static originalInstance;static setUp(){this.originalInstance=o.instance,o.resetInstance(),o.enableLog=!1}static tearDown(){o.resetInstance()}static createBloc(e,...t){const s=new e(...t);return o.activateBloc(s),s}static async waitForState(e,t,s=5e3){return new Promise((i,n)=>{const a=setTimeout(()=>{n(new Error(`Timeout waiting for state matching predicate after ${s}ms`))},s),c=e.subscribe(l=>{t(l)&&(clearTimeout(a),c(),i(l))});t(e.state)&&(clearTimeout(a),c(),i(e.state))})}static async expectStates(e,t,s=5e3){const i=[];return new Promise((n,a)=>{const c=setTimeout(()=>{a(new Error(`Timeout waiting for states. Expected: ${JSON.stringify(t)}, Received: ${JSON.stringify(i)}`))},s),l=e.subscribe(h=>{if(i.push(h),i.length===t.length){clearTimeout(c),l();for(let p=0;p<t.length;p++){const v=t[p],$=i[p];if(JSON.stringify(v)!==JSON.stringify($)){a(new Error(`State mismatch at index ${p}. Expected: ${JSON.stringify(v)}, Received: ${JSON.stringify($)}`));return}}n()}})})}}class j extends D{mockHandlers=new Map;constructor(e){super(e)}mockEventHandler(e,t){this.on(e,t)}getHandlerCount(){return this.eventHandlers.size}hasHandler(e){return this.eventHandlers.has(e)}}class z extends R{stateHistory=[];constructor(e){super(e),this.stateHistory.push(e)}emit(e){this.stateHistory.push(e),super.emit(e)}getStateHistory(){return[...this.stateHistory]}clearStateHistory(){this.stateHistory=[this.state]}}class q{initialStats;constructor(){this.initialStats=o.getMemoryStats()}checkForLeaks(){const e=o.getMemoryStats(),t=e.registeredBlocs>this.initialStats.registeredBlocs||e.isolatedBlocs>this.initialStats.isolatedBlocs||e.keepAliveBlocs>this.initialStats.keepAliveBlocs,s=`
|
|
2
|
-
Memory Leak Detection Report:
|
|
3
|
-
- Initial registered blocs: ${this.initialStats.registeredBlocs}
|
|
4
|
-
- Current registered blocs: ${e.registeredBlocs}
|
|
5
|
-
- Initial isolated blocs: ${this.initialStats.isolatedBlocs}
|
|
6
|
-
- Current isolated blocs: ${e.isolatedBlocs}
|
|
7
|
-
- Initial keep-alive blocs: ${this.initialStats.keepAliveBlocs}
|
|
8
|
-
- Current keep-alive blocs: ${e.keepAliveBlocs}
|
|
9
|
-
- Potential leaks detected: ${t?"YES":"NO"}
|
|
10
|
-
`.trim();return{hasLeaks:t,report:s,stats:e}}}const I=new WeakMap,d={stateProxiesCreated:0,classProxiesCreated:0,cacheHits:0,cacheMisses:0,totalProxiesCreated:0},_=(r,e,t,s="")=>{if(!e||!t||typeof r!="object"||r===null)return r;if(!s){let n=I.get(r);n||(n=new WeakMap,I.set(r,n));const a=n.get(e);if(a)return d.cacheHits++,a;d.cacheMisses++}const i=new Proxy(r,{get(n,a){if(typeof a=="symbol"||a==="constructor")return Reflect.get(n,a);const c=s?`${s}.${a}`:a,l=Reflect.get(n,a),h=l&&typeof l=="object";return t.trackAccess(e,"state",c,h?void 0:l),h&&(Array.isArray(l)||Object.getPrototypeOf(l)===Object.prototype)?_(l,e,t,c):l},set:()=>!1,deleteProperty:()=>!1});return s||(I.get(r).set(e,i),d.stateProxiesCreated++,d.totalProxiesCreated++),i},M=(r,e,t)=>{if(!e||!t)return r;let s=I.get(r);s||(s=new WeakMap,I.set(r,s));const i=s.get(e);if(i)return d.cacheHits++,i;d.cacheMisses++;const n=new Proxy(r,{get(a,c){const l=Reflect.get(a,c);if(W(a,c)?.get){const p=l!==null&&typeof l!="object";t.trackAccess(e,"class",String(c),p?l:void 0)}return l}});return s.set(e,n),d.classProxiesCreated++,d.totalProxiesCreated++,n},W=(r,e,t=10)=>{let s=r,i=0;for(;s&&i<t;){const n=Object.getOwnPropertyDescriptor(s,e);if(n)return n;s=Object.getPrototypeOf(s),i++}},P={createStateProxy:r=>_(r.target,r.consumerRef,r.consumerTracker,r.path),createClassProxy:r=>M(r.target,r.consumerRef,r.consumerTracker),getProxyState:r=>_(r.state,r.consumerRef,r.consumerTracker),getProxyBlocInstance:r=>M(r.blocInstance,r.consumerRef,r.consumerTracker),getStats:()=>({...d,propertyAccesses:0,nestedProxiesCreated:0,cacheEfficiency:d.cacheHits+d.cacheMisses>0?`${(d.cacheHits/(d.cacheHits+d.cacheMisses)*100).toFixed(1)}%`:"N/A",lifetime:"0ms",proxiesPerSecond:"N/A"}),resetStats:()=>{d.stateProxiesCreated=0,d.classProxiesCreated=0,d.cacheHits=0,d.cacheMisses=0,d.totalProxiesCreated=0}};class G{id=`adapter-${A()}`;blocConstructor;componentRef={current:{}};blocInstance;unmountTime=0;mountTime=0;subscriptionId;unsubscribe;dependencyValues;isUsingDependencies=!1;trackedPaths=new Set;pendingTrackedPaths=new Set;cachedStateProxy;cachedBlocProxy;lastProxiedState;hasMounted=!1;mountCount=0;lastState;lastDependencyValues;componentName;renderCount=0;lastDependenciesFn;options;constructor(e,t){this.options=t,this.blocConstructor=e.blocConstructor,this.componentRef=e.componentRef,this.isUsingDependencies=!!t?.dependencies,this.updateBlocInstance(),this.isUsingDependencies&&t?.dependencies&&(this.dependencyValues=t.dependencies(this.blocInstance));const s=this.getAdapterMetadata();o.getInstance().plugins.notifyAdapterCreated(this,s)}trackAccess(e,t,s,i){const n=t==="class"?`_class.${s}`:s;this.trackedPaths.add(n),this.subscriptionId?this.blocInstance.trackAccess(this.subscriptionId,n,i):(this.pendingTrackedPaths.add(n),o.config.logLevel==="debug"&&o.log(`[BlacAdapter] trackAccess storing pending path: ${s}`))}updateBlocInstance(){let e=this.options?.instanceId;if(!e&&this.options?.staticProps){const t=O(this.options.staticProps);t&&(e=t)}return this.blocInstance=o.instance.getBloc(this.blocConstructor,{constructorParams:this.options?.staticProps,id:e,instanceRef:this.id}),this.blocInstance}createSubscription=e=>{if(this.isUsingDependencies&&this.options?.dependencies)this.unsubscribe=this.blocInstance.subscribeWithSelector(t=>this.options.dependencies(this.blocInstance),t=>{this.hasDependencyValuesChanged(this.dependencyValues,t)&&(this.dependencyValues=t,e.onChange())});else{const t=new WeakRef(this.componentRef.current);this.unsubscribe=this.blocInstance.subscribeComponent(t,e.onChange);const s=this.blocInstance._subscriptionManager.subscriptions;if(this.subscriptionId=Array.from(s.keys()).pop(),this.subscriptionId&&this.pendingTrackedPaths.size>0){for(const i of this.pendingTrackedPaths)this.blocInstance.trackAccess(this.subscriptionId,i);this.pendingTrackedPaths.clear()}}return()=>{this.unsubscribe&&(this.unsubscribe(),this.unsubscribe=void 0,this.subscriptionId=void 0)}};hasDependencyValuesChanged=(e,t)=>{if(!e||e.length!==t.length)return!0;for(let s=0;s<e.length;s++)if(!Object.is(e[s],t[s]))return!0;return!1};getStateProxy=()=>{if(this.isUsingDependencies||!o.config.proxyDependencyTracking)return this.blocInstance.state;const e=this.blocInstance.state;return this.cachedStateProxy&&this.lastProxiedState===e?this.cachedStateProxy:(this.lastProxiedState=e,this.cachedStateProxy=this.createStateProxy({target:e}),this.cachedStateProxy)};getBlocProxy=()=>this.isUsingDependencies||!o.config.proxyDependencyTracking?this.blocInstance:this.cachedBlocProxy?this.cachedBlocProxy:(this.cachedBlocProxy=this.createClassProxy({target:this.blocInstance}),this.cachedBlocProxy);createStateProxy=e=>P.createStateProxy({target:e.target,consumerRef:this.componentRef.current,consumerTracker:this});createClassProxy=e=>P.createClassProxy({target:e.target,consumerRef:this.componentRef.current,consumerTracker:this});mount=()=>{this.hasMounted=!0,this.mountCount++,this.mountTime=Date.now(),this.options?.onMount&&this.options.onMount(this.blocInstance),this.isUsingDependencies&&this.options?.dependencies&&(this.dependencyValues=this.options.dependencies(this.blocInstance));const e=this.getAdapterMetadata();o.getInstance().plugins.notifyAdapterMount(this,e)};unmount=()=>{if(this.unmountTime=Date.now(),this.unsubscribe&&(this.unsubscribe(),this.unsubscribe=void 0,this.subscriptionId=void 0),this.options?.onUnmount)try{this.options.onUnmount(this.blocInstance)}catch(t){console.error("Error in onUnmount hook:",t)}const e=this.getAdapterMetadata();o.getInstance().plugins.notifyAdapterUnmount(this,e)};resetTracking(){if(this.trackedPaths.clear(),this.pendingTrackedPaths.clear(),this.subscriptionId){const e=this.blocInstance._subscriptionManager.subscriptions.get(this.subscriptionId);e&&e.dependencies&&e.dependencies.clear()}}setComponentName(e){this.componentName=e}notifyRender(){this.renderCount++,this.isUsingDependencies&&this.options?.dependencies&&(this.lastDependencyValues=this.dependencyValues,this.dependencyValues=this.options.dependencies(this.blocInstance));const e=this.getAdapterMetadata();o.getInstance().plugins.notifyAdapterRender(this,e)}getAdapterMetadata(){return{componentName:this.componentName,blocInstance:this.blocInstance,renderCount:this.renderCount,trackedPaths:Array.from(this.trackedPaths),isUsingDependencies:this.isUsingDependencies,lastState:this.lastState,lastDependencyValues:this.lastDependencyValues,currentDependencyValues:this.dependencyValues}}getValueAtPath(e,t){const s=t.split(".");let i=e;for(const n of s){if(i==null)return;i=i[n]}return i}getStateChangedPaths(e,t){const s=[];if(this.trackedPaths.size>0)for(const i of this.trackedPaths){if(i.startsWith("_class."))continue;const n=this.getValueAtPath(e,i),a=this.getValueAtPath(t,i);Object.is(n,a)||s.push(i)}else if(e!==t){const i=this.getDeepChangedPaths(e,t);if(i.length>0)return i;s.push("(entire state)")}return s}getDeepChangedPaths(e,t,s=""){const i=[];if(e===t)return i;if(e==null||t==null)return i.push(s||"(root)"),i;if(typeof e!="object"||typeof t!="object")return e!==t&&i.push(s||"(root)"),i;if(Array.isArray(e)||Array.isArray(t)){if(!Array.isArray(e)||!Array.isArray(t)||e.length!==t.length)return i.push(s||"(root)"),i;for(let a=0;a<e.length;a++){const c=s?`${s}[${a}]`:`[${a}]`;i.push(...this.getDeepChangedPaths(e[a],t[a],c))}return i}const n=new Set([...Object.keys(e),...Object.keys(t)]);for(const a of n){const c=s?`${s}.${a}`:a;if(!(a in e))i.push(`${c} (added)`);else if(!(a in t))i.push(`${c} (removed)`);else{const l=e[a],h=t[a];if(!Object.is(l,h))if(typeof l!="object"||typeof h!="object"||l===null||h===null)i.push(c);else{const p=this.getDeepChangedPaths(l,h,c);p.length>0?i.push(...p):i.push(c)}}}return i}getLastRerenderReason(){}}exports.Blac=o;exports.BlacAdapter=G;exports.BlacError=y;exports.Bloc=D;exports.BlocBase=B;exports.BlocLifecycleManager=C;exports.BlocLifecycleState=u;exports.BlocPluginRegistry=x;exports.BlocTest=F;exports.Cubit=R;exports.DefaultErrorStrategy=w;exports.ErrorCategory=S;exports.ErrorManager=g;exports.ErrorSeverity=m;exports.MemoryLeakDetector=q;exports.MockBloc=j;exports.MockCubit=z;exports.PropsUpdated=U;exports.ProxyFactory=P;exports.RerenderLogger=V;exports.SubscriptionManager=T;exports.SystemPluginRegistry=E;exports.createBlocProxy=M;exports.createStateProxy=_;exports.generateInstanceIdFromProps=O;exports.generateUUID=A;exports.handleError=k;exports.setBlacInstanceManager=N;exports.shallowEqual=H;
|
|
11
|
-
//# sourceMappingURL=index.cjs.js.map
|