@blac/core
Advanced tools
+42
-15
@@ -203,5 +203,5 @@ /* Excluded from this release type: __resetIdCounters */ | ||
| export declare type BlocConstructor<TBloc extends StateContainer<any, any>> = (new (...args: any[]) => TBloc) & { | ||
| resolve(instanceKey?: string, ...args: any[]): TBloc; | ||
| get(instanceKey?: string): TBloc; | ||
| getSafe(instanceKey?: string): { | ||
| resolve<S = never>(instanceKey?: string, ...args: any[]): StateOverride<TBloc, S>; | ||
| get<S = never>(instanceKey?: string): StateOverride<TBloc, S>; | ||
| getSafe<S = never>(instanceKey?: string): { | ||
| error: Error; | ||
@@ -211,3 +211,3 @@ instance: null; | ||
| error: null; | ||
| instance: TBloc; | ||
| instance: StateOverride<TBloc, S>; | ||
| }; | ||
@@ -928,2 +928,4 @@ release(instanceKey?: string): void; | ||
| * Creates a new instance if one doesn't exist, or returns existing and increments ref count. | ||
| * @template S - Optional state type override for generic StateContainers | ||
| * @template T - The StateContainer type (inferred from class) | ||
| * @param instanceKey - Optional instance key (defaults to 'default') | ||
@@ -933,5 +935,7 @@ * @param constructorArgs - Arguments to pass to constructor if creating new instance | ||
| */ | ||
| static resolve<T extends StateContainer<any>>(this: new (...args: any[]) => T, instanceKey?: string, constructorArgs?: any): T; | ||
| static resolve<S = never, T extends StateContainer<any> = StateContainer<any>>(this: new (...args: any[]) => T, instanceKey?: string, constructorArgs?: any): StateOverride<T, S>; | ||
| /** | ||
| * Get an existing instance without incrementing ref count (borrowing semantics). | ||
| * @template S - Optional state type override for generic StateContainers | ||
| * @template T - The StateContainer type (inferred from class) | ||
| * @param instanceKey - Optional instance key (defaults to 'default') | ||
@@ -941,9 +945,11 @@ * @returns The state container instance | ||
| */ | ||
| static get<T extends StateContainer<any>>(this: new (...args: any[]) => T, instanceKey?: string): T; | ||
| static get<S = never, T extends StateContainer<any> = StateContainer<any>>(this: new (...args: any[]) => T, instanceKey?: string): StateOverride<T, S>; | ||
| /** | ||
| * Safely get an existing instance with error handling. | ||
| * @template S - Optional state type override for generic StateContainers | ||
| * @template T - The StateContainer type (inferred from class) | ||
| * @param instanceKey - Optional instance key (defaults to 'default') | ||
| * @returns Discriminated union with either the instance or an error | ||
| */ | ||
| static getSafe<T extends StateContainer<any>>(this: new (...args: any[]) => T, instanceKey?: string): { | ||
| static getSafe<S = never, T extends StateContainer<any> = StateContainer<any>>(this: new (...args: any[]) => T, instanceKey?: string): { | ||
| error: Error; | ||
@@ -953,3 +959,3 @@ instance: null; | ||
| error: null; | ||
| instance: T; | ||
| instance: StateOverride<T, S>; | ||
| }; | ||
@@ -959,2 +965,4 @@ /** | ||
| * Gets or creates instance without incrementing ref count. | ||
| * @template S - Optional state type override for generic StateContainers | ||
| * @template T - The StateContainer type (inferred from class) | ||
| * @param instanceKey - Optional instance key (defaults to 'default') | ||
@@ -964,3 +972,3 @@ * @param constructorArgs - Arguments to pass to constructor if creating new instance | ||
| */ | ||
| static connect<T extends StateContainer<any>>(this: new (...args: any[]) => T, instanceKey?: string, constructorArgs?: any): T; | ||
| static connect<S = never, T extends StateContainer<any> = StateContainer<any>>(this: new (...args: any[]) => T, instanceKey?: string, constructorArgs?: any): StateOverride<T, S>; | ||
| /** | ||
@@ -972,3 +980,3 @@ * Release a reference to an instance. | ||
| */ | ||
| static release<T extends StateContainer<any>>(this: new (...args: any[]) => T, instanceKey?: string, forceDispose?: boolean): void; | ||
| static release<T extends StateContainer<any> = StateContainer<any>>(this: new (...args: any[]) => T, instanceKey?: string, forceDispose?: boolean): void; | ||
| /** | ||
@@ -978,3 +986,3 @@ * Get all instances of this class | ||
| */ | ||
| static getAll<T extends StateContainer<any>>(this: new (...args: any[]) => T): T[]; | ||
| static getAll<T extends StateContainer<any> = StateContainer<any>>(this: new (...args: any[]) => T): T[]; | ||
| /** | ||
@@ -984,7 +992,7 @@ * Iterate over all instances of this class | ||
| */ | ||
| static forEach<T extends StateContainer<any>>(this: new (...args: any[]) => T, callback: (instance: T) => void): void; | ||
| static forEach<T extends StateContainer<any> = StateContainer<any>>(this: new (...args: any[]) => T, callback: (instance: T) => void): void; | ||
| /** | ||
| * Clear all instances of this class (disposes them) | ||
| */ | ||
| static clear<T extends StateContainer<any>>(this: new (...args: any[]) => T): void; | ||
| static clear<T extends StateContainer<any> = StateContainer<any>>(this: new (...args: any[]) => T): void; | ||
| /** | ||
@@ -1008,3 +1016,3 @@ * Clear all instances from all registered types | ||
| */ | ||
| static getRefCount<T extends StateContainer<any>>(this: new (...args: any[]) => T, instanceKey?: string): number; | ||
| static getRefCount<T extends StateContainer<any> = StateContainer<any>>(this: new (...args: any[]) => T, instanceKey?: string): number; | ||
| /** | ||
@@ -1015,3 +1023,3 @@ * Check if an instance exists | ||
| */ | ||
| static hasInstance<T extends StateContainer<any>>(this: new (...args: any[]) => T, instanceKey?: string): boolean; | ||
| static hasInstance<T extends StateContainer<any> = StateContainer<any>>(this: new (...args: any[]) => T, instanceKey?: string): boolean; | ||
| private _state; | ||
@@ -1227,2 +1235,21 @@ private readonly listeners; | ||
| /** | ||
| * Conditionally override the state type of a StateContainer. | ||
| * When S is `never`, returns T unchanged (inferred state type). | ||
| * When S is provided, replaces the state type while preserving all other properties. | ||
| * | ||
| * @template T - The StateContainer type | ||
| * @template S - The state type override (defaults to never) | ||
| * | ||
| * @example | ||
| * // Without override - returns original type | ||
| * type Result1 = StateOverride<MyBloc>; // MyBloc | ||
| * | ||
| * // With override - replaces state type | ||
| * type Result2 = StateOverride<MyBloc, CustomState>; // Omit<MyBloc, 'state'> & { readonly state: CustomState } | ||
| */ | ||
| export declare type StateOverride<T extends StateContainer<any, any>, S = never> = [S] extends [never] ? T : Omit<T, 'state'> & { | ||
| readonly state: S; | ||
| }; | ||
| /* Excluded from this release type: stopProxyTracking */ | ||
@@ -1229,0 +1256,0 @@ |
+42
-15
@@ -203,5 +203,5 @@ /* Excluded from this release type: __resetIdCounters */ | ||
| export declare type BlocConstructor<TBloc extends StateContainer<any, any>> = (new (...args: any[]) => TBloc) & { | ||
| resolve(instanceKey?: string, ...args: any[]): TBloc; | ||
| get(instanceKey?: string): TBloc; | ||
| getSafe(instanceKey?: string): { | ||
| resolve<S = never>(instanceKey?: string, ...args: any[]): StateOverride<TBloc, S>; | ||
| get<S = never>(instanceKey?: string): StateOverride<TBloc, S>; | ||
| getSafe<S = never>(instanceKey?: string): { | ||
| error: Error; | ||
@@ -211,3 +211,3 @@ instance: null; | ||
| error: null; | ||
| instance: TBloc; | ||
| instance: StateOverride<TBloc, S>; | ||
| }; | ||
@@ -928,2 +928,4 @@ release(instanceKey?: string): void; | ||
| * Creates a new instance if one doesn't exist, or returns existing and increments ref count. | ||
| * @template S - Optional state type override for generic StateContainers | ||
| * @template T - The StateContainer type (inferred from class) | ||
| * @param instanceKey - Optional instance key (defaults to 'default') | ||
@@ -933,5 +935,7 @@ * @param constructorArgs - Arguments to pass to constructor if creating new instance | ||
| */ | ||
| static resolve<T extends StateContainer<any>>(this: new (...args: any[]) => T, instanceKey?: string, constructorArgs?: any): T; | ||
| static resolve<S = never, T extends StateContainer<any> = StateContainer<any>>(this: new (...args: any[]) => T, instanceKey?: string, constructorArgs?: any): StateOverride<T, S>; | ||
| /** | ||
| * Get an existing instance without incrementing ref count (borrowing semantics). | ||
| * @template S - Optional state type override for generic StateContainers | ||
| * @template T - The StateContainer type (inferred from class) | ||
| * @param instanceKey - Optional instance key (defaults to 'default') | ||
@@ -941,9 +945,11 @@ * @returns The state container instance | ||
| */ | ||
| static get<T extends StateContainer<any>>(this: new (...args: any[]) => T, instanceKey?: string): T; | ||
| static get<S = never, T extends StateContainer<any> = StateContainer<any>>(this: new (...args: any[]) => T, instanceKey?: string): StateOverride<T, S>; | ||
| /** | ||
| * Safely get an existing instance with error handling. | ||
| * @template S - Optional state type override for generic StateContainers | ||
| * @template T - The StateContainer type (inferred from class) | ||
| * @param instanceKey - Optional instance key (defaults to 'default') | ||
| * @returns Discriminated union with either the instance or an error | ||
| */ | ||
| static getSafe<T extends StateContainer<any>>(this: new (...args: any[]) => T, instanceKey?: string): { | ||
| static getSafe<S = never, T extends StateContainer<any> = StateContainer<any>>(this: new (...args: any[]) => T, instanceKey?: string): { | ||
| error: Error; | ||
@@ -953,3 +959,3 @@ instance: null; | ||
| error: null; | ||
| instance: T; | ||
| instance: StateOverride<T, S>; | ||
| }; | ||
@@ -959,2 +965,4 @@ /** | ||
| * Gets or creates instance without incrementing ref count. | ||
| * @template S - Optional state type override for generic StateContainers | ||
| * @template T - The StateContainer type (inferred from class) | ||
| * @param instanceKey - Optional instance key (defaults to 'default') | ||
@@ -964,3 +972,3 @@ * @param constructorArgs - Arguments to pass to constructor if creating new instance | ||
| */ | ||
| static connect<T extends StateContainer<any>>(this: new (...args: any[]) => T, instanceKey?: string, constructorArgs?: any): T; | ||
| static connect<S = never, T extends StateContainer<any> = StateContainer<any>>(this: new (...args: any[]) => T, instanceKey?: string, constructorArgs?: any): StateOverride<T, S>; | ||
| /** | ||
@@ -972,3 +980,3 @@ * Release a reference to an instance. | ||
| */ | ||
| static release<T extends StateContainer<any>>(this: new (...args: any[]) => T, instanceKey?: string, forceDispose?: boolean): void; | ||
| static release<T extends StateContainer<any> = StateContainer<any>>(this: new (...args: any[]) => T, instanceKey?: string, forceDispose?: boolean): void; | ||
| /** | ||
@@ -978,3 +986,3 @@ * Get all instances of this class | ||
| */ | ||
| static getAll<T extends StateContainer<any>>(this: new (...args: any[]) => T): T[]; | ||
| static getAll<T extends StateContainer<any> = StateContainer<any>>(this: new (...args: any[]) => T): T[]; | ||
| /** | ||
@@ -984,7 +992,7 @@ * Iterate over all instances of this class | ||
| */ | ||
| static forEach<T extends StateContainer<any>>(this: new (...args: any[]) => T, callback: (instance: T) => void): void; | ||
| static forEach<T extends StateContainer<any> = StateContainer<any>>(this: new (...args: any[]) => T, callback: (instance: T) => void): void; | ||
| /** | ||
| * Clear all instances of this class (disposes them) | ||
| */ | ||
| static clear<T extends StateContainer<any>>(this: new (...args: any[]) => T): void; | ||
| static clear<T extends StateContainer<any> = StateContainer<any>>(this: new (...args: any[]) => T): void; | ||
| /** | ||
@@ -1008,3 +1016,3 @@ * Clear all instances from all registered types | ||
| */ | ||
| static getRefCount<T extends StateContainer<any>>(this: new (...args: any[]) => T, instanceKey?: string): number; | ||
| static getRefCount<T extends StateContainer<any> = StateContainer<any>>(this: new (...args: any[]) => T, instanceKey?: string): number; | ||
| /** | ||
@@ -1015,3 +1023,3 @@ * Check if an instance exists | ||
| */ | ||
| static hasInstance<T extends StateContainer<any>>(this: new (...args: any[]) => T, instanceKey?: string): boolean; | ||
| static hasInstance<T extends StateContainer<any> = StateContainer<any>>(this: new (...args: any[]) => T, instanceKey?: string): boolean; | ||
| private _state; | ||
@@ -1227,2 +1235,21 @@ private readonly listeners; | ||
| /** | ||
| * Conditionally override the state type of a StateContainer. | ||
| * When S is `never`, returns T unchanged (inferred state type). | ||
| * When S is provided, replaces the state type while preserving all other properties. | ||
| * | ||
| * @template T - The StateContainer type | ||
| * @template S - The state type override (defaults to never) | ||
| * | ||
| * @example | ||
| * // Without override - returns original type | ||
| * type Result1 = StateOverride<MyBloc>; // MyBloc | ||
| * | ||
| * // With override - replaces state type | ||
| * type Result2 = StateOverride<MyBloc, CustomState>; // Omit<MyBloc, 'state'> & { readonly state: CustomState } | ||
| */ | ||
| export declare type StateOverride<T extends StateContainer<any, any>, S = never> = [S] extends [never] ? T : Omit<T, 'state'> & { | ||
| readonly state: S; | ||
| }; | ||
| /* Excluded from this release type: stopProxyTracking */ | ||
@@ -1229,0 +1256,0 @@ |
+1
-1
| { | ||
| "name": "@blac/core", | ||
| "version": "2.0.0-rc.11", | ||
| "version": "2.0.0-rc.13", | ||
| "license": "MIT", | ||
@@ -5,0 +5,0 @@ "author": "Brendan Mullins <jsnanigans@gmail.com>", |
Sorry, the diff of this file is too big to display
Sorry, the diff of this file is too big to display
Sorry, the diff of this file is too big to display
Sorry, the diff of this file is too big to display
Environment variable access
Supply chain riskPackage accesses environment variables, which may be a sign of credential stuffing or data theft.
Found 2 instances in 1 package
Long strings
Supply chain riskContains long string literals, which may be a sign of obfuscated or packed code.
Found 1 instance in 1 package
Environment variable access
Supply chain riskPackage accesses environment variables, which may be a sign of credential stuffing or data theft.
Found 2 instances in 1 package
Long strings
Supply chain riskContains long string literals, which may be a sign of obfuscated or packed code.
Found 1 instance in 1 package
488187
1.48%5333
0.79%