@blac/core 2.0.0-rc-10 → 2.0.0-rc-13
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 +27 -0
- package/dist/index.cjs.js +2 -2
- package/dist/index.cjs.js.map +1 -1
- package/dist/index.d.ts +294 -11
- package/dist/index.es.js +869 -397
- package/dist/index.es.js.map +1 -1
- package/package.json +1 -1
- package/src/Blac.ts +94 -9
- package/src/BlacObserver.ts +3 -0
- package/src/Bloc.ts +43 -49
- package/src/BlocBase.ts +107 -4
- package/src/Cubit.ts +14 -0
- package/src/__tests__/Blac.config.test.ts +86 -0
- package/src/__tests__/plugins.test.ts +454 -0
- package/src/__tests__/props.test.ts +256 -0
- package/src/adapter/BlacAdapter.ts +73 -8
- package/src/events.ts +3 -0
- package/src/index.ts +5 -0
- package/src/plugins/BlocPluginRegistry.ts +220 -0
- package/src/plugins/SystemPluginRegistry.ts +192 -0
- package/src/plugins/index.ts +8 -0
- package/src/plugins/types.ts +100 -0
- package/src/types.ts +1 -10
- package/src/utils/shallowEqual.ts +40 -0
package/src/types.ts
CHANGED
|
@@ -56,19 +56,10 @@ export type InferPropsFromGeneric<T> =
|
|
|
56
56
|
export type BlocConstructorParameters<B extends BlocBase<any>> =
|
|
57
57
|
BlocConstructor<B> extends new (...args: infer P) => B ? P : never;
|
|
58
58
|
|
|
59
|
-
/**
|
|
60
|
-
* Base interface for all Bloc events
|
|
61
|
-
* Events must be objects with a constructor to enable proper type matching
|
|
62
|
-
*/
|
|
63
|
-
export interface BlocEvent {
|
|
64
|
-
readonly type?: string;
|
|
65
|
-
readonly timestamp?: number;
|
|
66
|
-
}
|
|
67
|
-
|
|
68
59
|
/**
|
|
69
60
|
* Enhanced constraint for Bloc events - must be objects with proper constructor
|
|
70
61
|
*/
|
|
71
|
-
export type BlocEventConstraint =
|
|
62
|
+
export type BlocEventConstraint = object;
|
|
72
63
|
|
|
73
64
|
/**
|
|
74
65
|
* Error boundary interface for Bloc error handling
|
|
@@ -0,0 +1,40 @@
|
|
|
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 function shallowEqual(a: any, b: any): boolean {
|
|
9
|
+
if (Object.is(a, b)) {
|
|
10
|
+
return true;
|
|
11
|
+
}
|
|
12
|
+
|
|
13
|
+
if (
|
|
14
|
+
typeof a !== 'object' ||
|
|
15
|
+
a === null ||
|
|
16
|
+
typeof b !== 'object' ||
|
|
17
|
+
b === null
|
|
18
|
+
) {
|
|
19
|
+
return false;
|
|
20
|
+
}
|
|
21
|
+
|
|
22
|
+
const keysA = Object.keys(a);
|
|
23
|
+
const keysB = Object.keys(b);
|
|
24
|
+
|
|
25
|
+
if (keysA.length !== keysB.length) {
|
|
26
|
+
return false;
|
|
27
|
+
}
|
|
28
|
+
|
|
29
|
+
for (let i = 0; i < keysA.length; i++) {
|
|
30
|
+
const key = keysA[i];
|
|
31
|
+
if (
|
|
32
|
+
!Object.prototype.hasOwnProperty.call(b, key) ||
|
|
33
|
+
!Object.is(a[key], b[key])
|
|
34
|
+
) {
|
|
35
|
+
return false;
|
|
36
|
+
}
|
|
37
|
+
}
|
|
38
|
+
|
|
39
|
+
return true;
|
|
40
|
+
}
|