@blac/core 2.0.0-rc.13 → 2.0.0-rc.14
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/index.cjs +105 -69
- package/dist/index.cjs.map +1 -1
- package/dist/index.d.cts +133 -91
- package/dist/index.d.ts +133 -91
- package/dist/index.js +105 -69
- package/dist/index.js.map +1 -1
- package/package.json +1 -1
package/dist/index.d.cts
CHANGED
|
@@ -4,7 +4,7 @@
|
|
|
4
4
|
* Internal state for framework adapters, holding tracking and caching data.
|
|
5
5
|
* @template TBloc - The state container type
|
|
6
6
|
*/
|
|
7
|
-
export declare interface AdapterState<TBloc extends StateContainer<any
|
|
7
|
+
export declare interface AdapterState<TBloc extends StateContainer<any>> {
|
|
8
8
|
/** Proxy tracker for state property access tracking */
|
|
9
9
|
tracker: TrackerState<ExtractState<TBloc>> | null;
|
|
10
10
|
/** Cached manual dependencies for comparison */
|
|
@@ -199,21 +199,27 @@ export declare interface BlacPluginWithInit extends BlacPlugin {
|
|
|
199
199
|
* Used for type-safe hook parameters.
|
|
200
200
|
* @template TBloc - The StateContainer instance type
|
|
201
201
|
*/
|
|
202
|
-
export declare type BlocConstructor<
|
|
203
|
-
resolve
|
|
204
|
-
get
|
|
205
|
-
getSafe
|
|
202
|
+
export declare type BlocConstructor<S = any, T extends new (...args: any[]) => StateContainer<S, any> = new (...args: any[]) => StateContainer<S, any>> = (new (...args: any[]) => InstanceType<T>) & {
|
|
203
|
+
resolve(instanceKey?: string, ...args: any[]): InstanceType<T>;
|
|
204
|
+
get(instanceKey?: string, ...args: any[]): InstanceType<T> | null;
|
|
205
|
+
getSafe(instanceKey?: string, ...args: any[]): {
|
|
206
206
|
error: Error;
|
|
207
207
|
instance: null;
|
|
208
208
|
} | {
|
|
209
209
|
error: null;
|
|
210
|
-
instance:
|
|
210
|
+
instance: InstanceType<T>;
|
|
211
211
|
};
|
|
212
212
|
release(instanceKey?: string): void;
|
|
213
213
|
isolated?: boolean;
|
|
214
214
|
keepAlive?: boolean;
|
|
215
215
|
};
|
|
216
216
|
|
|
217
|
+
/**
|
|
218
|
+
* Extract instance type from an abstract class constructor
|
|
219
|
+
* @template T - The abstract class constructor type
|
|
220
|
+
*/
|
|
221
|
+
export declare type BlocInstanceType<T extends abstract new (...args: any) => any> = T extends abstract new (...args: any) => infer R ? R : any;
|
|
222
|
+
|
|
217
223
|
/**
|
|
218
224
|
* Utility type for creating branded/nominal types.
|
|
219
225
|
* Prevents accidental type confusion between similar primitive types.
|
|
@@ -333,7 +339,7 @@ export declare function createLogger(config: LogConfig): {
|
|
|
333
339
|
* @param config - Configuration with dependencies function
|
|
334
340
|
* @returns Snapshot function for use with useSyncExternalStore
|
|
335
341
|
*/
|
|
336
|
-
export declare function createManualDepsSnapshot<TBloc extends StateContainer<any, any>>(instance: TBloc, adapterState: AdapterState<TBloc>, config: ManualDepsConfig<TBloc>): SnapshotFunction<ExtractState<
|
|
342
|
+
export declare function createManualDepsSnapshot<TBloc extends StateContainer<any, any>>(instance: TBloc, adapterState: AdapterState<TBloc>, config: ManualDepsConfig<TBloc>): SnapshotFunction<ExtractState<StateContainerConstructor>>;
|
|
337
343
|
|
|
338
344
|
/**
|
|
339
345
|
* Create a subscribe function for manual dependency tracking mode.
|
|
@@ -363,6 +369,8 @@ export declare function createNoTrackSubscribe<TBloc extends StateContainer<any,
|
|
|
363
369
|
|
|
364
370
|
/**
|
|
365
371
|
* Create a plugin manager instance
|
|
372
|
+
* @param registry - The StateContainerRegistry to monitor for lifecycle events
|
|
373
|
+
* @returns A new PluginManager instance
|
|
366
374
|
*/
|
|
367
375
|
export declare function createPluginManager(registry: StateContainerRegistry): PluginManager;
|
|
368
376
|
|
|
@@ -474,13 +482,13 @@ export declare type ExtractConstructorArgs<T> = T extends new (...args: infer P)
|
|
|
474
482
|
* Extract the props type from a StateContainer
|
|
475
483
|
* @template T - The StateContainer type
|
|
476
484
|
*/
|
|
477
|
-
export declare type ExtractProps<T> = T extends
|
|
485
|
+
export declare type ExtractProps<T> = T extends StateContainerConstructor<any, infer P> ? P : undefined;
|
|
478
486
|
|
|
479
487
|
/**
|
|
480
488
|
* Extract the state type from a StateContainer
|
|
481
489
|
* @template T - The StateContainer type
|
|
482
490
|
*/
|
|
483
|
-
export declare type ExtractState<T> = T extends
|
|
491
|
+
export declare type ExtractState<T> = T extends StateContainerConstructor<infer S, any> ? S : never;
|
|
484
492
|
|
|
485
493
|
/**
|
|
486
494
|
* Generate ID with timestamp, counter, and random suffix (tree-shakeable)
|
|
@@ -534,9 +542,6 @@ export declare function generateSimpleId(prefix: string, affix?: string): string
|
|
|
534
542
|
*/
|
|
535
543
|
export declare function getPluginManager(): any;
|
|
536
544
|
|
|
537
|
-
/**
|
|
538
|
-
* Utility functions for accessing static properties on StateContainer classes
|
|
539
|
-
*/
|
|
540
545
|
/**
|
|
541
546
|
* Get a static property from a class constructor
|
|
542
547
|
* Type-safe helper that avoids (Type as any) casts
|
|
@@ -546,7 +551,7 @@ export declare function getPluginManager(): any;
|
|
|
546
551
|
* @param defaultValue - Optional default value if property is undefined
|
|
547
552
|
* @returns The property value or default
|
|
548
553
|
*/
|
|
549
|
-
export declare function getStaticProp<T>(Type:
|
|
554
|
+
export declare function getStaticProp<V, T extends StateContainerConstructor = StateContainerConstructor>(Type: T, propName: string, defaultValue?: V): V | undefined;
|
|
550
555
|
|
|
551
556
|
declare interface GetterExecutionContext {
|
|
552
557
|
tracker: GetterTrackerState | null;
|
|
@@ -656,18 +661,22 @@ export declare interface InstanceMetadata {
|
|
|
656
661
|
/* Excluded from this release type: invalidateRenderCache */
|
|
657
662
|
|
|
658
663
|
/**
|
|
659
|
-
* Check if a class should be excluded from DevTools
|
|
660
|
-
* Used to prevent infinite loops when DevTools tracks itself
|
|
664
|
+
* Check if a class should be excluded from DevTools.
|
|
665
|
+
* Used to prevent infinite loops when DevTools tracks itself.
|
|
666
|
+
* @param Type - The class constructor to check
|
|
667
|
+
* @returns true if the class has `static __excludeFromDevTools = true`
|
|
661
668
|
*/
|
|
662
|
-
export declare function isExcludedFromDevTools
|
|
669
|
+
export declare function isExcludedFromDevTools<T extends StateContainerConstructor>(Type: T): boolean;
|
|
663
670
|
|
|
664
671
|
/* Excluded from this release type: isGetter */
|
|
665
672
|
|
|
666
673
|
/**
|
|
667
|
-
* Check if a class is marked as isolated
|
|
668
|
-
* Isolated classes create separate instances per component
|
|
674
|
+
* Check if a class is marked as isolated.
|
|
675
|
+
* Isolated classes create separate instances per component.
|
|
676
|
+
* @param Type - The class constructor to check
|
|
677
|
+
* @returns true if the class has `static isolated = true`
|
|
669
678
|
*/
|
|
670
|
-
export declare function isIsolatedClass
|
|
679
|
+
export declare function isIsolatedClass<T extends StateContainerConstructor>(Type: T): boolean;
|
|
671
680
|
|
|
672
681
|
/**
|
|
673
682
|
* Check if a key is an isolated instance key
|
|
@@ -677,10 +686,12 @@ export declare function isIsolatedClass(Type: new (...args: any[]) => any): bool
|
|
|
677
686
|
export declare function isIsolatedKey(key: string): boolean;
|
|
678
687
|
|
|
679
688
|
/**
|
|
680
|
-
* Check if a class is marked as keepAlive
|
|
681
|
-
* KeepAlive classes are never auto-disposed when ref count reaches 0
|
|
689
|
+
* Check if a class is marked as keepAlive.
|
|
690
|
+
* KeepAlive classes are never auto-disposed when ref count reaches 0.
|
|
691
|
+
* @param Type - The class constructor to check
|
|
692
|
+
* @returns true if the class has `static keepAlive = true`
|
|
682
693
|
*/
|
|
683
|
-
export declare function isKeepAliveClass
|
|
694
|
+
export declare function isKeepAliveClass<T extends StateContainerConstructor>(Type: T): boolean;
|
|
684
695
|
|
|
685
696
|
/* Excluded from this release type: isProxyable */
|
|
686
697
|
|
|
@@ -741,9 +752,9 @@ export declare enum LogLevel {
|
|
|
741
752
|
* Configuration for manual dependency tracking mode
|
|
742
753
|
* @template TBloc - The state container type
|
|
743
754
|
*/
|
|
744
|
-
export declare interface ManualDepsConfig<TBloc extends StateContainer<any
|
|
755
|
+
export declare interface ManualDepsConfig<TBloc extends StateContainer<any>> {
|
|
745
756
|
/** Function that returns dependency array from state and bloc */
|
|
746
|
-
dependencies: (state: any, bloc: TBloc) =>
|
|
757
|
+
dependencies: (state: any, bloc: TBloc) => any[];
|
|
747
758
|
}
|
|
748
759
|
|
|
749
760
|
/* Excluded from this release type: parsePath */
|
|
@@ -902,7 +913,7 @@ export declare type SnapshotFunction<TState> = () => TState;
|
|
|
902
913
|
* }
|
|
903
914
|
* ```
|
|
904
915
|
*/
|
|
905
|
-
export declare abstract class StateContainer<S, P =
|
|
916
|
+
export declare abstract class StateContainer<S = any, P = any> {
|
|
906
917
|
/* Excluded from this release type: __excludeFromDevTools */
|
|
907
918
|
/* Excluded from this release type: _registry */
|
|
908
919
|
/**
|
|
@@ -919,17 +930,22 @@ export declare abstract class StateContainer<S, P = undefined> {
|
|
|
919
930
|
* Register this class with the global registry
|
|
920
931
|
* @param isolated - Whether instances should be isolated (component-scoped)
|
|
921
932
|
*/
|
|
922
|
-
static register<T extends
|
|
933
|
+
static register<T extends StateContainerConstructor>(this: T, isolated?: boolean): void;
|
|
923
934
|
/**
|
|
924
935
|
* Resolve an instance with ref counting (ownership semantics).
|
|
925
936
|
* Creates a new instance if one doesn't exist, or returns existing and increments ref count.
|
|
926
937
|
* @template S - Optional state type override for generic StateContainers
|
|
927
938
|
* @template T - The StateContainer type (inferred from class)
|
|
928
939
|
* @param instanceKey - Optional instance key (defaults to 'default')
|
|
929
|
-
* @param
|
|
940
|
+
* @param options - Resolution options (canCreate, countRef, props, trackExecutionContext)
|
|
930
941
|
* @returns The state container instance
|
|
931
942
|
*/
|
|
932
|
-
static resolve<
|
|
943
|
+
static resolve<T extends StateContainerConstructor = StateContainerConstructor>(this: T, instanceKey?: string, options?: {
|
|
944
|
+
canCreate?: boolean;
|
|
945
|
+
countRef?: boolean;
|
|
946
|
+
props?: ExtractProps<T>;
|
|
947
|
+
trackExecutionContext?: boolean;
|
|
948
|
+
}): InstanceType<T>;
|
|
933
949
|
/**
|
|
934
950
|
* Get an existing instance without incrementing ref count (borrowing semantics).
|
|
935
951
|
* @template S - Optional state type override for generic StateContainers
|
|
@@ -938,7 +954,7 @@ export declare abstract class StateContainer<S, P = undefined> {
|
|
|
938
954
|
* @returns The state container instance
|
|
939
955
|
* @throws Error if instance doesn't exist
|
|
940
956
|
*/
|
|
941
|
-
static get<
|
|
957
|
+
static get<T extends StateContainerConstructor<any> = StateContainerConstructor<any>>(this: T, instanceKey?: string): InstanceType<T>;
|
|
942
958
|
/**
|
|
943
959
|
* Safely get an existing instance with error handling.
|
|
944
960
|
* @template S - Optional state type override for generic StateContainers
|
|
@@ -946,44 +962,44 @@ export declare abstract class StateContainer<S, P = undefined> {
|
|
|
946
962
|
* @param instanceKey - Optional instance key (defaults to 'default')
|
|
947
963
|
* @returns Discriminated union with either the instance or an error
|
|
948
964
|
*/
|
|
949
|
-
static getSafe<
|
|
965
|
+
static getSafe<T extends StateContainerConstructor<any> = StateContainerConstructor<any>>(this: T, instanceKey?: string): {
|
|
950
966
|
error: Error;
|
|
951
967
|
instance: null;
|
|
952
968
|
} | {
|
|
953
969
|
error: null;
|
|
954
|
-
instance:
|
|
970
|
+
instance: InstanceType<T>;
|
|
955
971
|
};
|
|
956
972
|
/**
|
|
957
973
|
* Connect to an instance for bloc-to-bloc communication (borrowing semantics).
|
|
958
974
|
* Gets or creates instance without incrementing ref count.
|
|
975
|
+
* Tracks cross-bloc dependency for reactive updates.
|
|
959
976
|
* @template S - Optional state type override for generic StateContainers
|
|
960
977
|
* @template T - The StateContainer type (inferred from class)
|
|
961
978
|
* @param instanceKey - Optional instance key (defaults to 'default')
|
|
962
|
-
* @param constructorArgs - Arguments to pass to constructor if creating new instance
|
|
963
979
|
* @returns The state container instance
|
|
964
980
|
*/
|
|
965
|
-
static connect<
|
|
981
|
+
static connect<T extends StateContainerConstructor<any> = StateContainerConstructor<any>>(this: T, instanceKey?: string): InstanceType<T>;
|
|
966
982
|
/**
|
|
967
983
|
* Release a reference to an instance.
|
|
968
984
|
* Decrements ref count and disposes when it reaches 0 (unless keepAlive).
|
|
969
985
|
* @param instanceKey - Optional instance key (defaults to 'default')
|
|
970
986
|
* @param forceDispose - Force immediate disposal regardless of ref count
|
|
971
987
|
*/
|
|
972
|
-
static release<T extends
|
|
988
|
+
static release<T extends StateContainerConstructor = StateContainerConstructor>(this: T, instanceKey?: string, forceDispose?: boolean): void;
|
|
973
989
|
/**
|
|
974
990
|
* Get all instances of this class
|
|
975
991
|
* @returns Array of all instances
|
|
976
992
|
*/
|
|
977
|
-
static getAll<T extends
|
|
993
|
+
static getAll<T extends StateContainerConstructor = StateContainerConstructor>(this: T): InstanceType<T>[];
|
|
978
994
|
/**
|
|
979
995
|
* Iterate over all instances of this class
|
|
980
996
|
* @param callback - Function to call for each instance
|
|
981
997
|
*/
|
|
982
|
-
static forEach<T extends
|
|
998
|
+
static forEach<T extends StateContainerConstructor = StateContainerConstructor>(this: T, callback: (instance: InstanceType<T>) => void): void;
|
|
983
999
|
/**
|
|
984
1000
|
* Clear all instances of this class (disposes them)
|
|
985
1001
|
*/
|
|
986
|
-
static clear<T extends
|
|
1002
|
+
static clear<T extends StateContainerConstructor = StateContainerConstructor>(this: T): void;
|
|
987
1003
|
/**
|
|
988
1004
|
* Clear all instances from all registered types
|
|
989
1005
|
*/
|
|
@@ -1002,13 +1018,13 @@ export declare abstract class StateContainer<S, P = undefined> {
|
|
|
1002
1018
|
* @param instanceKey - Optional instance key (defaults to 'default')
|
|
1003
1019
|
* @returns Current ref count (0 if instance doesn't exist)
|
|
1004
1020
|
*/
|
|
1005
|
-
static getRefCount<T extends
|
|
1021
|
+
static getRefCount<T extends StateContainerConstructor = StateContainerConstructor>(this: T, instanceKey?: string): number;
|
|
1006
1022
|
/**
|
|
1007
1023
|
* Check if an instance exists
|
|
1008
1024
|
* @param instanceKey - Optional instance key (defaults to 'default')
|
|
1009
1025
|
* @returns true if instance exists
|
|
1010
1026
|
*/
|
|
1011
|
-
static hasInstance<T extends
|
|
1027
|
+
static hasInstance<T extends StateContainerConstructor = StateContainerConstructor>(this: T, instanceKey?: string): boolean;
|
|
1012
1028
|
private _state;
|
|
1013
1029
|
private readonly listeners;
|
|
1014
1030
|
private _disposed;
|
|
@@ -1095,6 +1111,13 @@ export declare interface StateContainerConfig {
|
|
|
1095
1111
|
instanceId?: string;
|
|
1096
1112
|
}
|
|
1097
1113
|
|
|
1114
|
+
/**
|
|
1115
|
+
* Constructor type for StateContainer classes
|
|
1116
|
+
* @template S - State type managed by the container
|
|
1117
|
+
* @template P - Props type passed to the container
|
|
1118
|
+
*/
|
|
1119
|
+
export declare type StateContainerConstructor<S = any, P = any> = new (...args: any[]) => StateContainer<S, P>;
|
|
1120
|
+
|
|
1098
1121
|
/**
|
|
1099
1122
|
* Central registry for managing StateContainer instances.
|
|
1100
1123
|
* Handles instance lifecycle, ref counting, and lifecycle event emission.
|
|
@@ -1117,77 +1140,113 @@ export declare class StateContainerRegistry {
|
|
|
1117
1140
|
* Register a type for lifecycle event tracking
|
|
1118
1141
|
* @param constructor - The StateContainer class constructor
|
|
1119
1142
|
*/
|
|
1120
|
-
registerType<T extends
|
|
1143
|
+
registerType<T extends StateContainerConstructor>(constructor: T): void;
|
|
1121
1144
|
/**
|
|
1122
1145
|
* Register a StateContainer class with configuration
|
|
1123
1146
|
* @param constructor - The StateContainer class constructor
|
|
1124
1147
|
* @param isolated - Whether instances should be isolated (component-scoped)
|
|
1125
1148
|
* @throws Error if type is already registered
|
|
1126
1149
|
*/
|
|
1127
|
-
register<T extends
|
|
1150
|
+
register<T extends StateContainerConstructor>(constructor: T, isolated?: boolean): void;
|
|
1128
1151
|
private ensureInstancesMap;
|
|
1129
1152
|
/**
|
|
1130
1153
|
* Get the instances Map for a specific class (public API for stats/debugging)
|
|
1131
1154
|
*/
|
|
1132
|
-
getInstancesMap<T extends
|
|
1155
|
+
getInstancesMap<T extends StateContainerConstructor>(Type: T): Map<string, InstanceEntry>;
|
|
1156
|
+
private trackExecutionContext;
|
|
1133
1157
|
/**
|
|
1134
|
-
* Resolve an instance with ref counting (ownership semantics)
|
|
1158
|
+
* Resolve an instance with ref counting (ownership semantics).
|
|
1159
|
+
* Creates a new instance if one doesn't exist, or returns existing and increments ref count.
|
|
1160
|
+
* @param Type - The StateContainer class constructor
|
|
1161
|
+
* @param instanceKey - Instance key (defaults to 'default')
|
|
1162
|
+
* @param options - Resolution options
|
|
1163
|
+
* @param options.canCreate - Whether to create new instance if not found (default: true)
|
|
1164
|
+
* @param options.countRef - Whether to increment ref count (default: true)
|
|
1165
|
+
* @param options.props - Props to pass to constructor if creating new instance
|
|
1166
|
+
* @param options.trackExecutionContext - Whether to track cross-bloc dependency (default: false)
|
|
1167
|
+
* @returns The state container instance
|
|
1135
1168
|
*/
|
|
1136
|
-
resolve<T extends
|
|
1169
|
+
resolve<T extends StateContainerConstructor = StateContainerConstructor>(Type: T, instanceKey?: string, options?: {
|
|
1170
|
+
canCreate?: boolean;
|
|
1171
|
+
countRef?: boolean;
|
|
1172
|
+
props?: ExtractProps<T>;
|
|
1173
|
+
trackExecutionContext?: boolean;
|
|
1174
|
+
}): InstanceType<T>;
|
|
1137
1175
|
/**
|
|
1138
|
-
* Get an existing instance without ref
|
|
1176
|
+
* Get an existing instance without incrementing ref count (borrowing semantics).
|
|
1177
|
+
* Tracks cross-bloc dependency for reactive updates.
|
|
1178
|
+
* @param Type - The StateContainer class constructor
|
|
1179
|
+
* @param instanceKey - Instance key (defaults to 'default')
|
|
1180
|
+
* @returns The state container instance
|
|
1139
1181
|
* @throws Error if instance doesn't exist
|
|
1140
1182
|
*/
|
|
1141
|
-
get<T extends
|
|
1183
|
+
get<T extends StateContainerConstructor = StateContainerConstructor>(Type: T, instanceKey?: string): InstanceType<T>;
|
|
1142
1184
|
/**
|
|
1143
|
-
* Safely get an existing instance (borrowing semantics with error handling)
|
|
1144
|
-
* Returns discriminated union for type-safe conditional access
|
|
1185
|
+
* Safely get an existing instance (borrowing semantics with error handling).
|
|
1186
|
+
* Returns discriminated union for type-safe conditional access.
|
|
1187
|
+
* @param Type - The StateContainer class constructor
|
|
1188
|
+
* @param instanceKey - Instance key (defaults to 'default')
|
|
1189
|
+
* @returns Discriminated union with either the instance or an error
|
|
1145
1190
|
*/
|
|
1146
|
-
getSafe<T extends
|
|
1191
|
+
getSafe<T extends StateContainerConstructor = StateContainerConstructor>(Type: T, instanceKey?: string): {
|
|
1147
1192
|
error: Error;
|
|
1148
1193
|
instance: null;
|
|
1149
1194
|
} | {
|
|
1150
1195
|
error: null;
|
|
1151
|
-
instance: T
|
|
1196
|
+
instance: InstanceType<T>;
|
|
1152
1197
|
};
|
|
1153
1198
|
/**
|
|
1154
|
-
* Connect to an instance with borrowing semantics (for B2B communication)
|
|
1199
|
+
* Connect to an instance with borrowing semantics (for B2B communication).
|
|
1155
1200
|
* Gets existing instance OR creates it if it doesn't exist, without incrementing ref count.
|
|
1156
1201
|
* Tracks cross-bloc dependency for reactive updates.
|
|
1157
1202
|
*
|
|
1158
1203
|
* Use this in bloc-to-bloc communication when you need to ensure an instance exists
|
|
1159
1204
|
* but don't want to claim ownership (no ref count increment).
|
|
1160
|
-
*
|
|
1161
|
-
* @param
|
|
1162
|
-
* @
|
|
1163
|
-
* @param constructorArgs - Constructor arguments (only used if creating new instance)
|
|
1164
|
-
* @returns The bloc instance
|
|
1205
|
+
* @param Type - The StateContainer class constructor
|
|
1206
|
+
* @param instanceKey - Instance key (defaults to 'default')
|
|
1207
|
+
* @returns The state container instance
|
|
1165
1208
|
*/
|
|
1166
|
-
connect<T extends
|
|
1209
|
+
connect<T extends StateContainerConstructor = StateContainerConstructor>(Type: T, instanceKey?: string): InstanceType<T>;
|
|
1167
1210
|
/**
|
|
1168
|
-
* Release a reference to an instance
|
|
1211
|
+
* Release a reference to an instance.
|
|
1212
|
+
* Decrements ref count and disposes when it reaches 0 (unless keepAlive).
|
|
1213
|
+
* @param Type - The StateContainer class constructor
|
|
1214
|
+
* @param instanceKey - Instance key (defaults to 'default')
|
|
1215
|
+
* @param forceDispose - Force immediate disposal regardless of ref count
|
|
1169
1216
|
*/
|
|
1170
|
-
release<T extends
|
|
1217
|
+
release<T extends StateContainerConstructor>(Type: T, instanceKey?: string, forceDispose?: boolean): void;
|
|
1171
1218
|
/**
|
|
1172
|
-
* Get all instances of a specific type
|
|
1219
|
+
* Get all instances of a specific type.
|
|
1220
|
+
* @param Type - The StateContainer class constructor
|
|
1221
|
+
* @returns Array of all instances
|
|
1173
1222
|
*/
|
|
1174
|
-
getAll<T extends
|
|
1223
|
+
getAll<T extends StateContainerConstructor>(Type: T): InstanceType<T>[];
|
|
1175
1224
|
/**
|
|
1176
|
-
* Safely iterate over all instances of a type
|
|
1225
|
+
* Safely iterate over all instances of a type.
|
|
1226
|
+
* Skips disposed instances and catches callback errors.
|
|
1227
|
+
* @param Type - The StateContainer class constructor
|
|
1228
|
+
* @param callback - Function to call for each instance
|
|
1177
1229
|
*/
|
|
1178
|
-
forEach<T extends
|
|
1230
|
+
forEach<T extends StateContainerConstructor>(Type: T, callback: (instance: InstanceType<T>) => void): void;
|
|
1179
1231
|
/**
|
|
1180
|
-
* Clear all instances of a specific type
|
|
1232
|
+
* Clear all instances of a specific type (disposes them).
|
|
1233
|
+
* @param Type - The StateContainer class constructor
|
|
1181
1234
|
*/
|
|
1182
|
-
clear<T extends
|
|
1235
|
+
clear<T extends StateContainerConstructor>(Type: T): void;
|
|
1183
1236
|
/**
|
|
1184
|
-
* Get reference count for an instance
|
|
1237
|
+
* Get reference count for an instance.
|
|
1238
|
+
* @param Type - The StateContainer class constructor
|
|
1239
|
+
* @param instanceKey - Instance key (defaults to 'default')
|
|
1240
|
+
* @returns Current ref count (0 if instance doesn't exist)
|
|
1185
1241
|
*/
|
|
1186
|
-
getRefCount<T extends
|
|
1242
|
+
getRefCount<T extends StateContainerConstructor>(Type: T, instanceKey?: string): number;
|
|
1187
1243
|
/**
|
|
1188
|
-
* Check if an instance exists
|
|
1244
|
+
* Check if an instance exists.
|
|
1245
|
+
* @param Type - The StateContainer class constructor
|
|
1246
|
+
* @param instanceKey - Instance key (defaults to 'default')
|
|
1247
|
+
* @returns true if instance exists
|
|
1189
1248
|
*/
|
|
1190
|
-
hasInstance<T extends
|
|
1249
|
+
hasInstance<T extends StateContainerConstructor>(Type: T, instanceKey?: string): boolean;
|
|
1191
1250
|
/**
|
|
1192
1251
|
* Clear all instances from all types (for testing)
|
|
1193
1252
|
*
|
|
@@ -1196,7 +1255,8 @@ export declare class StateContainerRegistry {
|
|
|
1196
1255
|
*/
|
|
1197
1256
|
clearAll(): void;
|
|
1198
1257
|
/**
|
|
1199
|
-
* Get registry statistics
|
|
1258
|
+
* Get registry statistics for debugging.
|
|
1259
|
+
* @returns Object with registeredTypes, totalInstances, and typeBreakdown
|
|
1200
1260
|
*/
|
|
1201
1261
|
getStats(): {
|
|
1202
1262
|
registeredTypes: number;
|
|
@@ -1204,9 +1264,10 @@ export declare class StateContainerRegistry {
|
|
|
1204
1264
|
typeBreakdown: Record<string, number>;
|
|
1205
1265
|
};
|
|
1206
1266
|
/**
|
|
1207
|
-
* Get all registered types (for plugin system)
|
|
1267
|
+
* Get all registered types (for plugin system).
|
|
1268
|
+
* @returns Array of all registered StateContainer class constructors
|
|
1208
1269
|
*/
|
|
1209
|
-
getTypes():
|
|
1270
|
+
getTypes(): StateContainerConstructor[];
|
|
1210
1271
|
/**
|
|
1211
1272
|
* Subscribe to lifecycle events
|
|
1212
1273
|
* @param event - The lifecycle event to listen for
|
|
@@ -1219,25 +1280,6 @@ export declare class StateContainerRegistry {
|
|
|
1219
1280
|
|
|
1220
1281
|
/* Excluded from this release type: StateListener */
|
|
1221
1282
|
|
|
1222
|
-
/**
|
|
1223
|
-
* Conditionally override the state type of a StateContainer.
|
|
1224
|
-
* When S is `never`, returns T unchanged (inferred state type).
|
|
1225
|
-
* When S is provided, replaces the state type while preserving all other properties.
|
|
1226
|
-
*
|
|
1227
|
-
* @template T - The StateContainer type
|
|
1228
|
-
* @template S - The state type override (defaults to never)
|
|
1229
|
-
*
|
|
1230
|
-
* @example
|
|
1231
|
-
* // Without override - returns original type
|
|
1232
|
-
* type Result1 = StateOverride<MyBloc>; // MyBloc
|
|
1233
|
-
*
|
|
1234
|
-
* // With override - replaces state type
|
|
1235
|
-
* type Result2 = StateOverride<MyBloc, CustomState>; // Omit<MyBloc, 'state'> & { readonly state: CustomState }
|
|
1236
|
-
*/
|
|
1237
|
-
export declare type StateOverride<T extends StateContainer<any, any>, S = never> = [S] extends [never] ? T : Omit<T, 'state'> & {
|
|
1238
|
-
readonly state: S;
|
|
1239
|
-
};
|
|
1240
|
-
|
|
1241
1283
|
/* Excluded from this release type: stopProxyTracking */
|
|
1242
1284
|
|
|
1243
1285
|
/**
|