@blac/core 2.0.0-rc-10 → 2.0.0-rn-12
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 +40 -11
- package/dist/index.es.js +432 -364
- package/dist/index.es.js.map +1 -1
- package/package.json +1 -1
- package/src/Blac.ts +46 -7
- package/src/Bloc.ts +0 -49
- package/src/Cubit.ts +14 -0
- package/src/__tests__/Blac.config.test.ts +86 -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 +2 -0
- package/src/types.ts +1 -10
- package/src/utils/shallowEqual.ts +40 -0
package/dist/index.d.ts
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
export declare interface AdapterOptions<B extends BlocBase<any>> {
|
|
2
2
|
id?: string;
|
|
3
3
|
dependencies?: (bloc: B) => unknown[];
|
|
4
|
-
props?:
|
|
4
|
+
props?: any;
|
|
5
5
|
onMount?: (bloc: B) => void;
|
|
6
6
|
onUnmount?: (bloc: B) => void;
|
|
7
7
|
}
|
|
@@ -23,6 +23,16 @@ export declare class Blac {
|
|
|
23
23
|
static get getAllBlocs(): <B extends BlocConstructor<any>>(blocClass: B, options?: {
|
|
24
24
|
searchIsolated?: boolean;
|
|
25
25
|
}) => InstanceType<B>[];
|
|
26
|
+
/** Private static configuration */
|
|
27
|
+
private static _config;
|
|
28
|
+
/** Get current configuration */
|
|
29
|
+
static get config(): Readonly<BlacConfig>;
|
|
30
|
+
/**
|
|
31
|
+
* Set or update Blac configuration
|
|
32
|
+
* @param config - Partial configuration to merge with existing config
|
|
33
|
+
* @throws Error if configuration is invalid
|
|
34
|
+
*/
|
|
35
|
+
static setConfig(config: Partial<BlacConfig>): void;
|
|
26
36
|
/** Map storing all registered bloc instances by their class name and ID */
|
|
27
37
|
blocInstanceMap: Map<string, BlocBase<unknown>>;
|
|
28
38
|
/** Map storing isolated bloc instances grouped by their constructor */
|
|
@@ -225,6 +235,8 @@ export declare class BlacAdapter<B extends BlocConstructor<BlocBase<any>>> {
|
|
|
225
235
|
};
|
|
226
236
|
blocInstance: InstanceType<B>;
|
|
227
237
|
private consumerTracker;
|
|
238
|
+
private static propsOwners;
|
|
239
|
+
private lastProps?;
|
|
228
240
|
unmountTime: number;
|
|
229
241
|
mountTime: number;
|
|
230
242
|
private dependencyValues?;
|
|
@@ -258,6 +270,7 @@ export declare class BlacAdapter<B extends BlocConstructor<BlocBase<any>>> {
|
|
|
258
270
|
getProxyState: (state: BlocState<InstanceType<B>>) => BlocState<InstanceType<B>>;
|
|
259
271
|
getProxyBlocInstance: () => InstanceType<B>;
|
|
260
272
|
get calledOnMount(): boolean;
|
|
273
|
+
updateProps(props: any): void;
|
|
261
274
|
private hasDependencyValuesChanged;
|
|
262
275
|
}
|
|
263
276
|
|
|
@@ -267,6 +280,12 @@ export declare class BlacAdapter<B extends BlocConstructor<BlocBase<any>>> {
|
|
|
267
280
|
export declare interface BlacConfig {
|
|
268
281
|
/** Whether to expose the Blac instance globally */
|
|
269
282
|
exposeBlacInstance?: boolean;
|
|
283
|
+
/**
|
|
284
|
+
* Whether to enable proxy dependency tracking for automatic re-render optimization.
|
|
285
|
+
* When false, state changes always cause re-renders unless dependencies are manually specified.
|
|
286
|
+
* Default: true
|
|
287
|
+
*/
|
|
288
|
+
proxyDependencyTracking?: boolean;
|
|
270
289
|
}
|
|
271
290
|
|
|
272
291
|
/**
|
|
@@ -498,19 +517,10 @@ export declare interface BlocErrorBoundary<S, A extends BlocEventConstraint> {
|
|
|
498
517
|
shouldRethrow?: (error: Error, event: A) => boolean;
|
|
499
518
|
}
|
|
500
519
|
|
|
501
|
-
/**
|
|
502
|
-
* Base interface for all Bloc events
|
|
503
|
-
* Events must be objects with a constructor to enable proper type matching
|
|
504
|
-
*/
|
|
505
|
-
export declare interface BlocEvent {
|
|
506
|
-
readonly type?: string;
|
|
507
|
-
readonly timestamp?: number;
|
|
508
|
-
}
|
|
509
|
-
|
|
510
520
|
/**
|
|
511
521
|
* Enhanced constraint for Bloc events - must be objects with proper constructor
|
|
512
522
|
*/
|
|
513
|
-
export declare type BlocEventConstraint =
|
|
523
|
+
export declare type BlocEventConstraint = object;
|
|
514
524
|
|
|
515
525
|
/**
|
|
516
526
|
* Function type for determining dependencies that trigger re-renders
|
|
@@ -620,6 +630,11 @@ declare interface ConsumerTracker_2 {
|
|
|
620
630
|
* @template P - The type of parameters (optional, defaults to null)
|
|
621
631
|
*/
|
|
622
632
|
export declare abstract class Cubit<S, P = null> extends BlocBase<S, P> {
|
|
633
|
+
/* Excluded from this release type: _updateProps */
|
|
634
|
+
/**
|
|
635
|
+
* Optional override for props handling
|
|
636
|
+
*/
|
|
637
|
+
protected onPropsChanged?(oldProps: P | undefined, newProps: P): void;
|
|
623
638
|
/**
|
|
624
639
|
* Updates the current state and notifies all observers of the change.
|
|
625
640
|
* If the new state is identical to the current state (using Object.is),
|
|
@@ -728,6 +743,11 @@ export declare class MockCubit<S> extends Cubit<S> {
|
|
|
728
743
|
clearStateHistory(): void;
|
|
729
744
|
}
|
|
730
745
|
|
|
746
|
+
export declare class PropsUpdated<P = any> {
|
|
747
|
+
readonly props: P;
|
|
748
|
+
constructor(props: P);
|
|
749
|
+
}
|
|
750
|
+
|
|
731
751
|
export declare class ProxyFactory {
|
|
732
752
|
static createStateProxy<T extends object>(options: {
|
|
733
753
|
target: T;
|
|
@@ -772,6 +792,15 @@ export declare class ProxyFactory {
|
|
|
772
792
|
*/
|
|
773
793
|
export declare function setBlacInstanceManager(manager: BlacInstanceManager): void;
|
|
774
794
|
|
|
795
|
+
/**
|
|
796
|
+
* Performs a shallow equality comparison between two values.
|
|
797
|
+
* For objects, it checks if all top-level properties are equal using Object.is.
|
|
798
|
+
* @param a First value to compare
|
|
799
|
+
* @param b Second value to compare
|
|
800
|
+
* @returns true if values are shallowly equal, false otherwise
|
|
801
|
+
*/
|
|
802
|
+
export declare function shallowEqual(a: any, b: any): boolean;
|
|
803
|
+
|
|
775
804
|
/**
|
|
776
805
|
* Result of an atomic state transition operation
|
|
777
806
|
*/
|