@blac/core 2.0.0-rc.11 → 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 +113 -69
- package/dist/index.cjs.map +1 -1
- package/dist/index.d.cts +141 -72
- package/dist/index.d.ts +141 -72
- package/dist/index.js +113 -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(instanceKey?: string, ...args: any[]):
|
|
204
|
-
get(instanceKey?: string):
|
|
205
|
-
getSafe(instanceKey?: string): {
|
|
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,63 +930,76 @@ 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.
|
|
937
|
+
* @template S - Optional state type override for generic StateContainers
|
|
938
|
+
* @template T - The StateContainer type (inferred from class)
|
|
926
939
|
* @param instanceKey - Optional instance key (defaults to 'default')
|
|
927
|
-
* @param
|
|
940
|
+
* @param options - Resolution options (canCreate, countRef, props, trackExecutionContext)
|
|
928
941
|
* @returns The state container instance
|
|
929
942
|
*/
|
|
930
|
-
static resolve<T extends
|
|
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>;
|
|
931
949
|
/**
|
|
932
950
|
* Get an existing instance without incrementing ref count (borrowing semantics).
|
|
951
|
+
* @template S - Optional state type override for generic StateContainers
|
|
952
|
+
* @template T - The StateContainer type (inferred from class)
|
|
933
953
|
* @param instanceKey - Optional instance key (defaults to 'default')
|
|
934
954
|
* @returns The state container instance
|
|
935
955
|
* @throws Error if instance doesn't exist
|
|
936
956
|
*/
|
|
937
|
-
static get<T extends
|
|
957
|
+
static get<T extends StateContainerConstructor<any> = StateContainerConstructor<any>>(this: T, instanceKey?: string): InstanceType<T>;
|
|
938
958
|
/**
|
|
939
959
|
* Safely get an existing instance with error handling.
|
|
960
|
+
* @template S - Optional state type override for generic StateContainers
|
|
961
|
+
* @template T - The StateContainer type (inferred from class)
|
|
940
962
|
* @param instanceKey - Optional instance key (defaults to 'default')
|
|
941
963
|
* @returns Discriminated union with either the instance or an error
|
|
942
964
|
*/
|
|
943
|
-
static getSafe<T extends
|
|
965
|
+
static getSafe<T extends StateContainerConstructor<any> = StateContainerConstructor<any>>(this: T, instanceKey?: string): {
|
|
944
966
|
error: Error;
|
|
945
967
|
instance: null;
|
|
946
968
|
} | {
|
|
947
969
|
error: null;
|
|
948
|
-
instance: T
|
|
970
|
+
instance: InstanceType<T>;
|
|
949
971
|
};
|
|
950
972
|
/**
|
|
951
973
|
* Connect to an instance for bloc-to-bloc communication (borrowing semantics).
|
|
952
974
|
* Gets or creates instance without incrementing ref count.
|
|
975
|
+
* Tracks cross-bloc dependency for reactive updates.
|
|
976
|
+
* @template S - Optional state type override for generic StateContainers
|
|
977
|
+
* @template T - The StateContainer type (inferred from class)
|
|
953
978
|
* @param instanceKey - Optional instance key (defaults to 'default')
|
|
954
|
-
* @param constructorArgs - Arguments to pass to constructor if creating new instance
|
|
955
979
|
* @returns The state container instance
|
|
956
980
|
*/
|
|
957
|
-
static connect<T extends
|
|
981
|
+
static connect<T extends StateContainerConstructor<any> = StateContainerConstructor<any>>(this: T, instanceKey?: string): InstanceType<T>;
|
|
958
982
|
/**
|
|
959
983
|
* Release a reference to an instance.
|
|
960
984
|
* Decrements ref count and disposes when it reaches 0 (unless keepAlive).
|
|
961
985
|
* @param instanceKey - Optional instance key (defaults to 'default')
|
|
962
986
|
* @param forceDispose - Force immediate disposal regardless of ref count
|
|
963
987
|
*/
|
|
964
|
-
static release<T extends
|
|
988
|
+
static release<T extends StateContainerConstructor = StateContainerConstructor>(this: T, instanceKey?: string, forceDispose?: boolean): void;
|
|
965
989
|
/**
|
|
966
990
|
* Get all instances of this class
|
|
967
991
|
* @returns Array of all instances
|
|
968
992
|
*/
|
|
969
|
-
static getAll<T extends
|
|
993
|
+
static getAll<T extends StateContainerConstructor = StateContainerConstructor>(this: T): InstanceType<T>[];
|
|
970
994
|
/**
|
|
971
995
|
* Iterate over all instances of this class
|
|
972
996
|
* @param callback - Function to call for each instance
|
|
973
997
|
*/
|
|
974
|
-
static forEach<T extends
|
|
998
|
+
static forEach<T extends StateContainerConstructor = StateContainerConstructor>(this: T, callback: (instance: InstanceType<T>) => void): void;
|
|
975
999
|
/**
|
|
976
1000
|
* Clear all instances of this class (disposes them)
|
|
977
1001
|
*/
|
|
978
|
-
static clear<T extends
|
|
1002
|
+
static clear<T extends StateContainerConstructor = StateContainerConstructor>(this: T): void;
|
|
979
1003
|
/**
|
|
980
1004
|
* Clear all instances from all registered types
|
|
981
1005
|
*/
|
|
@@ -994,13 +1018,13 @@ export declare abstract class StateContainer<S, P = undefined> {
|
|
|
994
1018
|
* @param instanceKey - Optional instance key (defaults to 'default')
|
|
995
1019
|
* @returns Current ref count (0 if instance doesn't exist)
|
|
996
1020
|
*/
|
|
997
|
-
static getRefCount<T extends
|
|
1021
|
+
static getRefCount<T extends StateContainerConstructor = StateContainerConstructor>(this: T, instanceKey?: string): number;
|
|
998
1022
|
/**
|
|
999
1023
|
* Check if an instance exists
|
|
1000
1024
|
* @param instanceKey - Optional instance key (defaults to 'default')
|
|
1001
1025
|
* @returns true if instance exists
|
|
1002
1026
|
*/
|
|
1003
|
-
static hasInstance<T extends
|
|
1027
|
+
static hasInstance<T extends StateContainerConstructor = StateContainerConstructor>(this: T, instanceKey?: string): boolean;
|
|
1004
1028
|
private _state;
|
|
1005
1029
|
private readonly listeners;
|
|
1006
1030
|
private _disposed;
|
|
@@ -1087,6 +1111,13 @@ export declare interface StateContainerConfig {
|
|
|
1087
1111
|
instanceId?: string;
|
|
1088
1112
|
}
|
|
1089
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
|
+
|
|
1090
1121
|
/**
|
|
1091
1122
|
* Central registry for managing StateContainer instances.
|
|
1092
1123
|
* Handles instance lifecycle, ref counting, and lifecycle event emission.
|
|
@@ -1109,77 +1140,113 @@ export declare class StateContainerRegistry {
|
|
|
1109
1140
|
* Register a type for lifecycle event tracking
|
|
1110
1141
|
* @param constructor - The StateContainer class constructor
|
|
1111
1142
|
*/
|
|
1112
|
-
registerType<T extends
|
|
1143
|
+
registerType<T extends StateContainerConstructor>(constructor: T): void;
|
|
1113
1144
|
/**
|
|
1114
1145
|
* Register a StateContainer class with configuration
|
|
1115
1146
|
* @param constructor - The StateContainer class constructor
|
|
1116
1147
|
* @param isolated - Whether instances should be isolated (component-scoped)
|
|
1117
1148
|
* @throws Error if type is already registered
|
|
1118
1149
|
*/
|
|
1119
|
-
register<T extends
|
|
1150
|
+
register<T extends StateContainerConstructor>(constructor: T, isolated?: boolean): void;
|
|
1120
1151
|
private ensureInstancesMap;
|
|
1121
1152
|
/**
|
|
1122
1153
|
* Get the instances Map for a specific class (public API for stats/debugging)
|
|
1123
1154
|
*/
|
|
1124
|
-
getInstancesMap<T extends
|
|
1155
|
+
getInstancesMap<T extends StateContainerConstructor>(Type: T): Map<string, InstanceEntry>;
|
|
1156
|
+
private trackExecutionContext;
|
|
1125
1157
|
/**
|
|
1126
|
-
* 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
|
|
1127
1168
|
*/
|
|
1128
|
-
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>;
|
|
1129
1175
|
/**
|
|
1130
|
-
* 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
|
|
1131
1181
|
* @throws Error if instance doesn't exist
|
|
1132
1182
|
*/
|
|
1133
|
-
get<T extends
|
|
1183
|
+
get<T extends StateContainerConstructor = StateContainerConstructor>(Type: T, instanceKey?: string): InstanceType<T>;
|
|
1134
1184
|
/**
|
|
1135
|
-
* Safely get an existing instance (borrowing semantics with error handling)
|
|
1136
|
-
* 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
|
|
1137
1190
|
*/
|
|
1138
|
-
getSafe<T extends
|
|
1191
|
+
getSafe<T extends StateContainerConstructor = StateContainerConstructor>(Type: T, instanceKey?: string): {
|
|
1139
1192
|
error: Error;
|
|
1140
1193
|
instance: null;
|
|
1141
1194
|
} | {
|
|
1142
1195
|
error: null;
|
|
1143
|
-
instance: T
|
|
1196
|
+
instance: InstanceType<T>;
|
|
1144
1197
|
};
|
|
1145
1198
|
/**
|
|
1146
|
-
* Connect to an instance with borrowing semantics (for B2B communication)
|
|
1199
|
+
* Connect to an instance with borrowing semantics (for B2B communication).
|
|
1147
1200
|
* Gets existing instance OR creates it if it doesn't exist, without incrementing ref count.
|
|
1148
1201
|
* Tracks cross-bloc dependency for reactive updates.
|
|
1149
1202
|
*
|
|
1150
1203
|
* Use this in bloc-to-bloc communication when you need to ensure an instance exists
|
|
1151
1204
|
* but don't want to claim ownership (no ref count increment).
|
|
1152
|
-
*
|
|
1153
|
-
* @param
|
|
1154
|
-
* @
|
|
1155
|
-
* @param constructorArgs - Constructor arguments (only used if creating new instance)
|
|
1156
|
-
* @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
|
|
1157
1208
|
*/
|
|
1158
|
-
connect<T extends
|
|
1209
|
+
connect<T extends StateContainerConstructor = StateContainerConstructor>(Type: T, instanceKey?: string): InstanceType<T>;
|
|
1159
1210
|
/**
|
|
1160
|
-
* 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
|
|
1161
1216
|
*/
|
|
1162
|
-
release<T extends
|
|
1217
|
+
release<T extends StateContainerConstructor>(Type: T, instanceKey?: string, forceDispose?: boolean): void;
|
|
1163
1218
|
/**
|
|
1164
|
-
* 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
|
|
1165
1222
|
*/
|
|
1166
|
-
getAll<T extends
|
|
1223
|
+
getAll<T extends StateContainerConstructor>(Type: T): InstanceType<T>[];
|
|
1167
1224
|
/**
|
|
1168
|
-
* 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
|
|
1169
1229
|
*/
|
|
1170
|
-
forEach<T extends
|
|
1230
|
+
forEach<T extends StateContainerConstructor>(Type: T, callback: (instance: InstanceType<T>) => void): void;
|
|
1171
1231
|
/**
|
|
1172
|
-
* Clear all instances of a specific type
|
|
1232
|
+
* Clear all instances of a specific type (disposes them).
|
|
1233
|
+
* @param Type - The StateContainer class constructor
|
|
1173
1234
|
*/
|
|
1174
|
-
clear<T extends
|
|
1235
|
+
clear<T extends StateContainerConstructor>(Type: T): void;
|
|
1175
1236
|
/**
|
|
1176
|
-
* 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)
|
|
1177
1241
|
*/
|
|
1178
|
-
getRefCount<T extends
|
|
1242
|
+
getRefCount<T extends StateContainerConstructor>(Type: T, instanceKey?: string): number;
|
|
1179
1243
|
/**
|
|
1180
|
-
* 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
|
|
1181
1248
|
*/
|
|
1182
|
-
hasInstance<T extends
|
|
1249
|
+
hasInstance<T extends StateContainerConstructor>(Type: T, instanceKey?: string): boolean;
|
|
1183
1250
|
/**
|
|
1184
1251
|
* Clear all instances from all types (for testing)
|
|
1185
1252
|
*
|
|
@@ -1188,7 +1255,8 @@ export declare class StateContainerRegistry {
|
|
|
1188
1255
|
*/
|
|
1189
1256
|
clearAll(): void;
|
|
1190
1257
|
/**
|
|
1191
|
-
* Get registry statistics
|
|
1258
|
+
* Get registry statistics for debugging.
|
|
1259
|
+
* @returns Object with registeredTypes, totalInstances, and typeBreakdown
|
|
1192
1260
|
*/
|
|
1193
1261
|
getStats(): {
|
|
1194
1262
|
registeredTypes: number;
|
|
@@ -1196,9 +1264,10 @@ export declare class StateContainerRegistry {
|
|
|
1196
1264
|
typeBreakdown: Record<string, number>;
|
|
1197
1265
|
};
|
|
1198
1266
|
/**
|
|
1199
|
-
* Get all registered types (for plugin system)
|
|
1267
|
+
* Get all registered types (for plugin system).
|
|
1268
|
+
* @returns Array of all registered StateContainer class constructors
|
|
1200
1269
|
*/
|
|
1201
|
-
getTypes():
|
|
1270
|
+
getTypes(): StateContainerConstructor[];
|
|
1202
1271
|
/**
|
|
1203
1272
|
* Subscribe to lifecycle events
|
|
1204
1273
|
* @param event - The lifecycle event to listen for
|