@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/dist/index.cjs +435 -197
- package/dist/index.cjs.map +1 -0
- package/dist/index.d.cts +1325 -21
- package/dist/index.d.ts +1325 -21
- package/dist/index.js +436 -189
- package/dist/index.js.map +1 -0
- package/package.json +10 -6
- package/dist/adapter/framework-adapter.d.ts +0 -33
- package/dist/adapter/index.d.ts +0 -8
- package/dist/constants.d.ts +0 -82
- package/dist/core/Cubit.d.ts +0 -40
- package/dist/core/StateContainer.d.ts +0 -78
- package/dist/core/StateContainerRegistry.d.ts +0 -119
- package/dist/core/Vertex.d.ts +0 -74
- package/dist/decorators/blac.d.ts +0 -31
- package/dist/decorators/index.d.ts +0 -2
- package/dist/logging/Logger.d.ts +0 -57
- package/dist/plugin/BlacPlugin.d.ts +0 -46
- package/dist/plugin/PluginManager.d.ts +0 -38
- package/dist/registry/index.d.ts +0 -20
- package/dist/test-utils/index.d.ts +0 -43
- package/dist/tracking/dependency-tracker.d.ts +0 -21
- package/dist/tracking/getter-tracker.d.ts +0 -31
- package/dist/tracking/index.d.ts +0 -38
- package/dist/tracking/path-utils.d.ts +0 -39
- package/dist/tracking/proxy-tracker.d.ts +0 -88
- package/dist/types/branded.d.ts +0 -9
- package/dist/types/events.d.ts +0 -13
- package/dist/types/utilities.d.ts +0 -19
- package/dist/utils/equality.d.ts +0 -9
- package/dist/utils/idGenerator.d.ts +0 -76
- package/dist/utils/immutable.d.ts +0 -16
- package/dist/utils/stack-trace.d.ts +0 -19
- package/dist/utils/static-props.d.ts +0 -29
|
@@ -1,119 +0,0 @@
|
|
|
1
|
-
import type { StateContainer } from './StateContainer';
|
|
2
|
-
import type { Vertex } from './Vertex';
|
|
3
|
-
export interface InstanceEntry<T = any> {
|
|
4
|
-
instance: T;
|
|
5
|
-
refCount: number;
|
|
6
|
-
}
|
|
7
|
-
export type LifecycleEvent = 'created' | 'stateChanged' | 'eventAdded' | 'disposed';
|
|
8
|
-
export type LifecycleListener<E extends LifecycleEvent> = E extends 'created' ? (container: StateContainer<any>) => void : E extends 'stateChanged' ? (container: StateContainer<any>, previousState: any, currentState: any, callstack?: string) => void : E extends 'eventAdded' ? (container: Vertex<any, any>, event: any) => void : E extends 'disposed' ? (container: StateContainer<any>) => void : never;
|
|
9
|
-
export declare class StateContainerRegistry {
|
|
10
|
-
private readonly instancesByConstructor;
|
|
11
|
-
private readonly types;
|
|
12
|
-
private readonly typeConfigs;
|
|
13
|
-
private readonly listeners;
|
|
14
|
-
registerType<T extends StateContainer<any>>(constructor: new (...args: any[]) => T): void;
|
|
15
|
-
register<T extends StateContainer<any>>(constructor: new (...args: any[]) => T, isolated?: boolean): void;
|
|
16
|
-
private ensureInstancesMap;
|
|
17
|
-
/**
|
|
18
|
-
* Get the instances Map for a specific class (public API for stats/debugging)
|
|
19
|
-
*/
|
|
20
|
-
getInstancesMap<T extends StateContainer<any>>(Type: new (...args: any[]) => T): Map<string, InstanceEntry>;
|
|
21
|
-
/**
|
|
22
|
-
* Resolve an instance with ref counting (ownership semantics)
|
|
23
|
-
*/
|
|
24
|
-
resolve<T extends StateContainer<any>>(Type: new (...args: any[]) => T, instanceKey?: string, constructorArgs?: any): T;
|
|
25
|
-
/**
|
|
26
|
-
* Get an existing instance without ref counting (borrowing semantics)
|
|
27
|
-
* @throws Error if instance doesn't exist
|
|
28
|
-
*/
|
|
29
|
-
get<T extends StateContainer<any>>(Type: new (...args: any[]) => T, instanceKey?: string): T;
|
|
30
|
-
/**
|
|
31
|
-
* Safely get an existing instance (borrowing semantics with error handling)
|
|
32
|
-
* Returns discriminated union for type-safe conditional access
|
|
33
|
-
*/
|
|
34
|
-
getSafe<T extends StateContainer<any>>(Type: new (...args: any[]) => T, instanceKey?: string): {
|
|
35
|
-
error: Error;
|
|
36
|
-
instance: null;
|
|
37
|
-
} | {
|
|
38
|
-
error: null;
|
|
39
|
-
instance: T;
|
|
40
|
-
};
|
|
41
|
-
/**
|
|
42
|
-
* Connect to an instance with borrowing semantics (for B2B communication)
|
|
43
|
-
* Gets existing instance OR creates it if it doesn't exist, without incrementing ref count.
|
|
44
|
-
* Tracks cross-bloc dependency for reactive updates.
|
|
45
|
-
*
|
|
46
|
-
* Use this in bloc-to-bloc communication when you need to ensure an instance exists
|
|
47
|
-
* but don't want to claim ownership (no ref count increment).
|
|
48
|
-
*
|
|
49
|
-
* @param Type - The bloc class constructor
|
|
50
|
-
* @param instanceKey - Optional instance key (defaults to 'default')
|
|
51
|
-
* @param constructorArgs - Constructor arguments (only used if creating new instance)
|
|
52
|
-
* @returns The bloc instance
|
|
53
|
-
*/
|
|
54
|
-
connect<T extends StateContainer<any>>(Type: new (...args: any[]) => T, instanceKey?: string, constructorArgs?: any): T;
|
|
55
|
-
/**
|
|
56
|
-
* Release a reference to an instance
|
|
57
|
-
*/
|
|
58
|
-
release<T extends StateContainer<any>>(Type: new (...args: any[]) => T, instanceKey?: string, forceDispose?: boolean): void;
|
|
59
|
-
/**
|
|
60
|
-
* Get all instances of a specific type
|
|
61
|
-
*/
|
|
62
|
-
getAll<T extends StateContainer<any>>(Type: new (...args: any[]) => T): T[];
|
|
63
|
-
/**
|
|
64
|
-
* Safely iterate over all instances of a type
|
|
65
|
-
*/
|
|
66
|
-
forEach<T extends StateContainer<any>>(Type: new (...args: any[]) => T, callback: (instance: T) => void): void;
|
|
67
|
-
/**
|
|
68
|
-
* Clear all instances of a specific type
|
|
69
|
-
*/
|
|
70
|
-
clear<T extends StateContainer<any>>(Type: new (...args: any[]) => T): void;
|
|
71
|
-
/**
|
|
72
|
-
* Get reference count for an instance
|
|
73
|
-
*/
|
|
74
|
-
getRefCount<T extends StateContainer<any>>(Type: new (...args: any[]) => T, instanceKey?: string): number;
|
|
75
|
-
/**
|
|
76
|
-
* Check if an instance exists
|
|
77
|
-
*/
|
|
78
|
-
hasInstance<T extends StateContainer<any>>(Type: new (...args: any[]) => T, instanceKey?: string): boolean;
|
|
79
|
-
/**
|
|
80
|
-
* Clear all instances from all types (for testing)
|
|
81
|
-
*
|
|
82
|
-
* Iterates all registered types and clears their instances.
|
|
83
|
-
* Also clears type tracking to reset the registry state.
|
|
84
|
-
*/
|
|
85
|
-
clearAll(): void;
|
|
86
|
-
/**
|
|
87
|
-
* Get registry statistics (for debugging)
|
|
88
|
-
*/
|
|
89
|
-
getStats(): {
|
|
90
|
-
registeredTypes: number;
|
|
91
|
-
totalInstances: number;
|
|
92
|
-
typeBreakdown: Record<string, number>;
|
|
93
|
-
};
|
|
94
|
-
/**
|
|
95
|
-
* Get all registered types (for plugin system)
|
|
96
|
-
*/
|
|
97
|
-
getTypes(): Array<new (...args: any[]) => StateContainer<any>>;
|
|
98
|
-
/**
|
|
99
|
-
* Subscribe to lifecycle events
|
|
100
|
-
* @param event - The lifecycle event to listen for
|
|
101
|
-
* @param listener - The listener function to call when the event occurs
|
|
102
|
-
* @returns Unsubscribe function
|
|
103
|
-
*/
|
|
104
|
-
on<E extends LifecycleEvent>(event: E, listener: LifecycleListener<E>): () => void;
|
|
105
|
-
/**
|
|
106
|
-
* Emit lifecycle event to all listeners
|
|
107
|
-
* @internal - Called by StateContainer/Vertex lifecycle methods
|
|
108
|
-
*/
|
|
109
|
-
emit(event: LifecycleEvent, ...args: any[]): void;
|
|
110
|
-
}
|
|
111
|
-
/**
|
|
112
|
-
* Global default registry instance
|
|
113
|
-
*/
|
|
114
|
-
export declare const globalRegistry: StateContainerRegistry;
|
|
115
|
-
/**
|
|
116
|
-
* Get the global plugin manager
|
|
117
|
-
*/
|
|
118
|
-
export declare function getPluginManager(): any;
|
|
119
|
-
//# sourceMappingURL=StateContainerRegistry.d.ts.map
|
package/dist/core/Vertex.d.ts
DELETED
|
@@ -1,74 +0,0 @@
|
|
|
1
|
-
import { StateContainer } from './StateContainer';
|
|
2
|
-
import { BaseEvent } from '../types/events';
|
|
3
|
-
export type EventHandler<E extends BaseEvent, S> = (event: E, emit: (state: S) => void) => void;
|
|
4
|
-
export type EventConstructor<T extends BaseEvent = BaseEvent> = new (...args: never[]) => T;
|
|
5
|
-
export declare abstract class Vertex<S, E extends BaseEvent = BaseEvent, P = undefined> extends StateContainer<S, P> {
|
|
6
|
-
private eventHandlers;
|
|
7
|
-
private isProcessing;
|
|
8
|
-
private eventQueue;
|
|
9
|
-
constructor(initialState: S);
|
|
10
|
-
protected on: <T extends E>(EventClass: EventConstructor<T>, handler: EventHandler<T, S>) => void;
|
|
11
|
-
add: (event: E) => void;
|
|
12
|
-
private processEvent;
|
|
13
|
-
private handleEvent;
|
|
14
|
-
protected onEventError(_event: E, _error: Error): void;
|
|
15
|
-
}
|
|
16
|
-
/**
|
|
17
|
-
* Example: Counter Events
|
|
18
|
-
*/
|
|
19
|
-
export declare class IncrementEvent implements BaseEvent {
|
|
20
|
-
readonly amount: number;
|
|
21
|
-
readonly type = "increment";
|
|
22
|
-
readonly timestamp: number;
|
|
23
|
-
constructor(amount?: number);
|
|
24
|
-
}
|
|
25
|
-
export declare class DecrementEvent implements BaseEvent {
|
|
26
|
-
readonly amount: number;
|
|
27
|
-
readonly type = "decrement";
|
|
28
|
-
readonly timestamp: number;
|
|
29
|
-
constructor(amount?: number);
|
|
30
|
-
}
|
|
31
|
-
export declare class ResetEvent implements BaseEvent {
|
|
32
|
-
readonly type = "reset";
|
|
33
|
-
readonly timestamp: number;
|
|
34
|
-
}
|
|
35
|
-
/**
|
|
36
|
-
* Example: Counter Vertex
|
|
37
|
-
* Demonstrates proper typing and event handling
|
|
38
|
-
*/
|
|
39
|
-
export declare class CounterVertex extends Vertex<number> {
|
|
40
|
-
constructor();
|
|
41
|
-
increment: (amount?: number) => void;
|
|
42
|
-
decrement: (amount?: number) => void;
|
|
43
|
-
reset: () => void;
|
|
44
|
-
}
|
|
45
|
-
/**
|
|
46
|
-
* Auth State and Events for testing async handlers
|
|
47
|
-
*/
|
|
48
|
-
export interface AuthState {
|
|
49
|
-
isAuthenticated: boolean;
|
|
50
|
-
isLoading: boolean;
|
|
51
|
-
user: {
|
|
52
|
-
id: string;
|
|
53
|
-
name: string;
|
|
54
|
-
email: string;
|
|
55
|
-
} | null;
|
|
56
|
-
error: string | null;
|
|
57
|
-
}
|
|
58
|
-
export declare class LoginEvent implements BaseEvent {
|
|
59
|
-
readonly email: string;
|
|
60
|
-
readonly password: string;
|
|
61
|
-
readonly type = "login";
|
|
62
|
-
readonly timestamp: number;
|
|
63
|
-
constructor(email: string, password: string);
|
|
64
|
-
}
|
|
65
|
-
export declare class LogoutEvent implements BaseEvent {
|
|
66
|
-
readonly type = "logout";
|
|
67
|
-
readonly timestamp: number;
|
|
68
|
-
}
|
|
69
|
-
export declare class AuthVertex extends Vertex<AuthState> {
|
|
70
|
-
constructor();
|
|
71
|
-
login: (email: string, password: string) => void;
|
|
72
|
-
logout: () => void;
|
|
73
|
-
}
|
|
74
|
-
//# sourceMappingURL=Vertex.d.ts.map
|
|
@@ -1,31 +0,0 @@
|
|
|
1
|
-
export type BlacOptions = {
|
|
2
|
-
isolated: true;
|
|
3
|
-
} | {
|
|
4
|
-
keepAlive: true;
|
|
5
|
-
} | {
|
|
6
|
-
excludeFromDevTools: true;
|
|
7
|
-
};
|
|
8
|
-
/**
|
|
9
|
-
* Decorator to configure StateContainer classes.
|
|
10
|
-
*
|
|
11
|
-
* @example Decorator syntax (requires experimentalDecorators or TC39 decorators)
|
|
12
|
-
* ```typescript
|
|
13
|
-
* @blac({ isolated: true })
|
|
14
|
-
* class FormBloc extends Cubit<FormState> {}
|
|
15
|
-
*
|
|
16
|
-
* @blac({ keepAlive: true })
|
|
17
|
-
* class AuthBloc extends Cubit<AuthState> {}
|
|
18
|
-
*
|
|
19
|
-
* @blac({ excludeFromDevTools: true })
|
|
20
|
-
* class InternalBloc extends Cubit<InternalState> {}
|
|
21
|
-
* ```
|
|
22
|
-
*
|
|
23
|
-
* @example Function syntax (no decorator support needed)
|
|
24
|
-
* ```typescript
|
|
25
|
-
* const FormBloc = blac({ isolated: true })(
|
|
26
|
-
* class extends Cubit<FormState> {}
|
|
27
|
-
* );
|
|
28
|
-
* ```
|
|
29
|
-
*/
|
|
30
|
-
export declare function blac(options: BlacOptions): <T extends new (...args: any[]) => any>(target: T, _context?: ClassDecoratorContext) => T;
|
|
31
|
-
//# sourceMappingURL=blac.d.ts.map
|
package/dist/logging/Logger.d.ts
DELETED
|
@@ -1,57 +0,0 @@
|
|
|
1
|
-
export declare enum LogLevel {
|
|
2
|
-
ERROR = 0,
|
|
3
|
-
WARN = 1,
|
|
4
|
-
INFO = 2,
|
|
5
|
-
DEBUG = 3
|
|
6
|
-
}
|
|
7
|
-
export interface LogEntry {
|
|
8
|
-
level: string;
|
|
9
|
-
context: string;
|
|
10
|
-
message: string;
|
|
11
|
-
data?: any;
|
|
12
|
-
timestamp: number;
|
|
13
|
-
}
|
|
14
|
-
export interface LogConfig {
|
|
15
|
-
enabled: boolean;
|
|
16
|
-
level: LogLevel;
|
|
17
|
-
output: (entry: LogEntry) => void;
|
|
18
|
-
}
|
|
19
|
-
/**
|
|
20
|
-
* Creates a logger instance with given configuration
|
|
21
|
-
*
|
|
22
|
-
* @param config - Logger configuration
|
|
23
|
-
* @returns Logger instance with debug, info, warn, error, and configure methods
|
|
24
|
-
*
|
|
25
|
-
* @example
|
|
26
|
-
* ```ts
|
|
27
|
-
* const logger = createLogger({
|
|
28
|
-
* enabled: true,
|
|
29
|
-
* level: LogLevel.DEBUG,
|
|
30
|
-
* output: (entry) => console.log(JSON.stringify(entry))
|
|
31
|
-
* });
|
|
32
|
-
* logger.debug('MyComponent', 'Rendering', { props: { foo: 'bar' } });
|
|
33
|
-
* ```
|
|
34
|
-
*/
|
|
35
|
-
export declare function createLogger(config: LogConfig): {
|
|
36
|
-
debug: (context: string, message: string, data?: any) => void;
|
|
37
|
-
info: (context: string, message: string, data?: any) => void;
|
|
38
|
-
warn: (context: string, message: string, data?: any) => void;
|
|
39
|
-
error: (context: string, message: string, data?: any) => void;
|
|
40
|
-
configure: (opts: Partial<LogConfig>) => void;
|
|
41
|
-
};
|
|
42
|
-
export declare const debug: (context: string, message: string, data?: any) => void;
|
|
43
|
-
export declare const info: (context: string, message: string, data?: any) => void;
|
|
44
|
-
export declare const warn: (context: string, message: string, data?: any) => void;
|
|
45
|
-
export declare const error: (context: string, message: string, data?: any) => void;
|
|
46
|
-
/**
|
|
47
|
-
* Configuration function that recreates the default logger
|
|
48
|
-
*
|
|
49
|
-
* @param opts - Partial logger configuration
|
|
50
|
-
*
|
|
51
|
-
* @example
|
|
52
|
-
* ```ts
|
|
53
|
-
* configureLogger({ enabled: true, level: LogLevel.DEBUG });
|
|
54
|
-
* ```
|
|
55
|
-
*/
|
|
56
|
-
export declare function configureLogger(opts: Partial<LogConfig>): void;
|
|
57
|
-
//# sourceMappingURL=Logger.d.ts.map
|
|
@@ -1,46 +0,0 @@
|
|
|
1
|
-
import type { StateContainer } from '../core/StateContainer';
|
|
2
|
-
import type { Vertex } from '../core/Vertex';
|
|
3
|
-
import type { BaseEvent } from '../types/events';
|
|
4
|
-
export interface InstanceMetadata {
|
|
5
|
-
id: string;
|
|
6
|
-
className: string;
|
|
7
|
-
isDisposed: boolean;
|
|
8
|
-
name: string;
|
|
9
|
-
lastStateChangeTimestamp: number;
|
|
10
|
-
state: any;
|
|
11
|
-
createdAt: number;
|
|
12
|
-
isIsolated: boolean;
|
|
13
|
-
callstack?: string;
|
|
14
|
-
previousState?: any;
|
|
15
|
-
currentState?: any;
|
|
16
|
-
}
|
|
17
|
-
export interface PluginContext {
|
|
18
|
-
getInstanceMetadata(instance: StateContainer<any>): InstanceMetadata;
|
|
19
|
-
getState<S>(instance: StateContainer<S>): S;
|
|
20
|
-
queryInstances<T extends StateContainer<any>>(typeClass: new (...args: any[]) => T): T[];
|
|
21
|
-
getAllTypes(): Array<new (...args: any[]) => StateContainer<any>>;
|
|
22
|
-
getStats(): {
|
|
23
|
-
registeredTypes: number;
|
|
24
|
-
totalInstances: number;
|
|
25
|
-
typeBreakdown: Record<string, number>;
|
|
26
|
-
};
|
|
27
|
-
}
|
|
28
|
-
export interface BlacPlugin {
|
|
29
|
-
readonly name: string;
|
|
30
|
-
readonly version: string;
|
|
31
|
-
onInstall?(context: PluginContext): void;
|
|
32
|
-
onUninstall?(): void;
|
|
33
|
-
onInstanceCreated?(instance: StateContainer<any>, context: PluginContext): void;
|
|
34
|
-
onStateChanged?<S>(instance: StateContainer<S>, previousState: S, currentState: S, callstack: string | undefined, context: PluginContext): void;
|
|
35
|
-
onEventAdded?<E extends BaseEvent>(vertex: Vertex<any, E>, event: E, context: PluginContext): void;
|
|
36
|
-
onInstanceDisposed?(instance: StateContainer<any>, context: PluginContext): void;
|
|
37
|
-
}
|
|
38
|
-
export interface BlacPluginWithInit extends BlacPlugin {
|
|
39
|
-
onInstall(context: PluginContext): void;
|
|
40
|
-
}
|
|
41
|
-
export interface PluginConfig {
|
|
42
|
-
enabled?: boolean;
|
|
43
|
-
environment?: 'development' | 'production' | 'test' | 'all';
|
|
44
|
-
}
|
|
45
|
-
export declare function hasInitHook(plugin: BlacPlugin): plugin is BlacPluginWithInit;
|
|
46
|
-
//# sourceMappingURL=BlacPlugin.d.ts.map
|
|
@@ -1,38 +0,0 @@
|
|
|
1
|
-
import type { StateContainerRegistry } from '../core/StateContainerRegistry';
|
|
2
|
-
import type { BlacPlugin, PluginConfig } from './BlacPlugin';
|
|
3
|
-
export declare class PluginManager {
|
|
4
|
-
private plugins;
|
|
5
|
-
private registry;
|
|
6
|
-
constructor(registry: StateContainerRegistry);
|
|
7
|
-
install(plugin: BlacPlugin, config?: PluginConfig): void;
|
|
8
|
-
uninstall(pluginName: string): void;
|
|
9
|
-
getPlugin(pluginName: string): BlacPlugin | undefined;
|
|
10
|
-
getAllPlugins(): BlacPlugin[];
|
|
11
|
-
hasPlugin(pluginName: string): boolean;
|
|
12
|
-
clear(): void;
|
|
13
|
-
/**
|
|
14
|
-
* Setup lifecycle hooks to notify plugins
|
|
15
|
-
*/
|
|
16
|
-
private setupLifecycleHooks;
|
|
17
|
-
/**
|
|
18
|
-
* Notify all plugins of a lifecycle event
|
|
19
|
-
*/
|
|
20
|
-
private notifyPlugins;
|
|
21
|
-
/**
|
|
22
|
-
* Create plugin context with safe API access
|
|
23
|
-
*/
|
|
24
|
-
private createPluginContext;
|
|
25
|
-
/**
|
|
26
|
-
* Check if plugin should be enabled based on environment
|
|
27
|
-
*/
|
|
28
|
-
private shouldEnablePlugin;
|
|
29
|
-
/**
|
|
30
|
-
* Get current environment
|
|
31
|
-
*/
|
|
32
|
-
private getCurrentEnvironment;
|
|
33
|
-
}
|
|
34
|
-
/**
|
|
35
|
-
* Create a plugin manager instance
|
|
36
|
-
*/
|
|
37
|
-
export declare function createPluginManager(registry: StateContainerRegistry): PluginManager;
|
|
38
|
-
//# sourceMappingURL=PluginManager.d.ts.map
|
package/dist/registry/index.d.ts
DELETED
|
@@ -1,20 +0,0 @@
|
|
|
1
|
-
/**
|
|
2
|
-
* Registry module (deprecated)
|
|
3
|
-
*
|
|
4
|
-
* Registry functionality has been consolidated into StateContainer.
|
|
5
|
-
* Use StateContainer static methods instead:
|
|
6
|
-
*
|
|
7
|
-
* - StateContainer.register() - Register a type
|
|
8
|
-
* - StateContainer.getOrCreate() - Get or create instance
|
|
9
|
-
* - StateContainer.isRegistered() - Check if type is registered
|
|
10
|
-
* - StateContainer.hasInstance() - Check if instance exists
|
|
11
|
-
* - StateContainer.removeInstance() - Remove instance
|
|
12
|
-
* - StateContainer.getAll() - Get all instances of a type
|
|
13
|
-
* - StateContainer.clear() - Clear all instances of a type
|
|
14
|
-
* - StateContainer.clearAllInstances() - Clear all instances
|
|
15
|
-
* - StateContainer.unregister() - Unregister a type
|
|
16
|
-
* - StateContainer.getStats() - Get statistics
|
|
17
|
-
*/
|
|
18
|
-
export { type BlocConstructor } from '../types/utilities';
|
|
19
|
-
export { type InstanceId, instanceId as createInstanceId, } from '../types/branded';
|
|
20
|
-
//# sourceMappingURL=index.d.ts.map
|
|
@@ -1,43 +0,0 @@
|
|
|
1
|
-
/**
|
|
2
|
-
* Test utilities and fixtures
|
|
3
|
-
*/
|
|
4
|
-
/**
|
|
5
|
-
* Create a test state object
|
|
6
|
-
*/
|
|
7
|
-
export declare function createTestState<T extends Record<string, unknown>>(overrides?: Partial<T>): T;
|
|
8
|
-
/**
|
|
9
|
-
* Wait for a condition to be true
|
|
10
|
-
*/
|
|
11
|
-
export declare function waitFor(condition: () => boolean, timeout?: number, interval?: number): Promise<void>;
|
|
12
|
-
/**
|
|
13
|
-
* Create a mock subscription notify function
|
|
14
|
-
*/
|
|
15
|
-
export declare function createMockNotify<T = unknown>(): {
|
|
16
|
-
fn: import("vitest").Mock<(state: T) => void>;
|
|
17
|
-
calls: T[];
|
|
18
|
-
callCount: () => number;
|
|
19
|
-
lastCall: () => T;
|
|
20
|
-
reset: () => void;
|
|
21
|
-
};
|
|
22
|
-
/**
|
|
23
|
-
* Memory usage tracker for tests
|
|
24
|
-
*/
|
|
25
|
-
export declare class MemoryTracker {
|
|
26
|
-
private baseline;
|
|
27
|
-
start(): void;
|
|
28
|
-
getUsage(): number;
|
|
29
|
-
getMB(): number;
|
|
30
|
-
}
|
|
31
|
-
/**
|
|
32
|
-
* Performance timer for benchmarking
|
|
33
|
-
*/
|
|
34
|
-
export declare class PerfTimer {
|
|
35
|
-
private start;
|
|
36
|
-
private marks;
|
|
37
|
-
begin(): void;
|
|
38
|
-
mark(label: string): void;
|
|
39
|
-
end(): number;
|
|
40
|
-
getMark(label: string): number | undefined;
|
|
41
|
-
getAllMarks(): Record<string, number>;
|
|
42
|
-
}
|
|
43
|
-
//# sourceMappingURL=index.d.ts.map
|
|
@@ -1,21 +0,0 @@
|
|
|
1
|
-
import { type ProxyTrackerState } from './proxy-tracker';
|
|
2
|
-
export interface PathInfo {
|
|
3
|
-
segments: string[];
|
|
4
|
-
value: any;
|
|
5
|
-
}
|
|
6
|
-
export interface TrackerState<T> {
|
|
7
|
-
proxyTrackerState: ProxyTrackerState<T>;
|
|
8
|
-
previousRenderPaths: Set<string>;
|
|
9
|
-
currentRenderPaths: Set<string>;
|
|
10
|
-
pathCache: Map<string, PathInfo>;
|
|
11
|
-
lastCheckedState: T | null;
|
|
12
|
-
lastCheckedValues: Map<string, any>;
|
|
13
|
-
}
|
|
14
|
-
export declare function optimizeTrackedPaths(paths: Set<string>): Set<string>;
|
|
15
|
-
export declare function createTrackerState<T>(): TrackerState<T>;
|
|
16
|
-
export declare function startTracking<T>(tracker: TrackerState<T>): void;
|
|
17
|
-
export declare function createProxy<T>(tracker: TrackerState<T>, state: T): T;
|
|
18
|
-
export declare function captureTrackedPaths<T>(tracker: TrackerState<T>, state: T): void;
|
|
19
|
-
export declare function hasChanges<T>(tracker: TrackerState<T>, state: T): boolean;
|
|
20
|
-
export declare function hasTrackedData<T>(tracker: TrackerState<T>): boolean;
|
|
21
|
-
//# sourceMappingURL=dependency-tracker.d.ts.map
|
|
@@ -1,31 +0,0 @@
|
|
|
1
|
-
import type { StateContainer } from '../core/StateContainer';
|
|
2
|
-
export interface GetterTrackerState {
|
|
3
|
-
trackedValues: Map<string | symbol, unknown>;
|
|
4
|
-
currentlyAccessing: Set<string | symbol>;
|
|
5
|
-
trackedGetters: Set<string | symbol>;
|
|
6
|
-
isTracking: boolean;
|
|
7
|
-
renderCache: Map<string | symbol, unknown>;
|
|
8
|
-
cacheValid: boolean;
|
|
9
|
-
externalDependencies: Set<StateContainer<any>>;
|
|
10
|
-
}
|
|
11
|
-
interface GetterExecutionContext {
|
|
12
|
-
tracker: GetterTrackerState | null;
|
|
13
|
-
currentBloc: StateContainer<any> | null;
|
|
14
|
-
depth: number;
|
|
15
|
-
visitedBlocs: Set<StateContainer<any>>;
|
|
16
|
-
}
|
|
17
|
-
export declare function getGetterExecutionContext(): GetterExecutionContext;
|
|
18
|
-
export declare function getDescriptor(obj: any, prop: string | symbol): PropertyDescriptor | undefined;
|
|
19
|
-
export declare function isGetter(obj: any, prop: string | symbol): boolean;
|
|
20
|
-
export declare function createGetterTracker(): GetterTrackerState;
|
|
21
|
-
export declare function setActiveTracker<TBloc extends StateContainer<any>>(bloc: TBloc, tracker: GetterTrackerState): void;
|
|
22
|
-
export declare function clearActiveTracker<TBloc extends StateContainer<any>>(bloc: TBloc): void;
|
|
23
|
-
export declare function getActiveTracker<TBloc extends StateContainer<any>>(bloc: TBloc): GetterTrackerState | undefined;
|
|
24
|
-
export declare function commitTrackedGetters(tracker: GetterTrackerState): void;
|
|
25
|
-
export declare function createBlocProxy<TBloc extends StateContainer<any>>(bloc: TBloc): TBloc;
|
|
26
|
-
export declare function hasGetterChanges<TBloc extends StateContainer<any>>(bloc: TBloc, tracker: GetterTrackerState | null): boolean;
|
|
27
|
-
export declare function invalidateRenderCache(tracker: GetterTrackerState): void;
|
|
28
|
-
export declare function clearExternalDependencies(tracker: GetterTrackerState): void;
|
|
29
|
-
export declare function resetGetterTracker(tracker: GetterTrackerState): void;
|
|
30
|
-
export {};
|
|
31
|
-
//# sourceMappingURL=getter-tracker.d.ts.map
|
package/dist/tracking/index.d.ts
DELETED
|
@@ -1,38 +0,0 @@
|
|
|
1
|
-
/**
|
|
2
|
-
* Dependency Tracking
|
|
3
|
-
*
|
|
4
|
-
* Framework-agnostic dependency tracking utilities for automatic reactivity.
|
|
5
|
-
* These utilities can be used by any framework integration (React, Vue, Angular, etc.)
|
|
6
|
-
* to track property accesses and detect changes.
|
|
7
|
-
*
|
|
8
|
-
* ## Usage
|
|
9
|
-
*
|
|
10
|
-
* ```typescript
|
|
11
|
-
* import {
|
|
12
|
-
* createTrackerState,
|
|
13
|
-
* startTracking,
|
|
14
|
-
* createProxy,
|
|
15
|
-
* captureTrackedPaths,
|
|
16
|
-
* hasChanges
|
|
17
|
-
* } from '@blac/core';
|
|
18
|
-
*
|
|
19
|
-
* // Create tracker state
|
|
20
|
-
* const tracker = createTrackerState<MyState>();
|
|
21
|
-
*
|
|
22
|
-
* // During render:
|
|
23
|
-
* startTracking(tracker);
|
|
24
|
-
* const proxy = createProxy(tracker, state);
|
|
25
|
-
* // ... render with proxy ...
|
|
26
|
-
* captureTrackedPaths(tracker, state);
|
|
27
|
-
*
|
|
28
|
-
* // On state change:
|
|
29
|
-
* if (hasChanges(tracker, newState)) {
|
|
30
|
-
* // Trigger re-render
|
|
31
|
-
* }
|
|
32
|
-
* ```
|
|
33
|
-
*/
|
|
34
|
-
export { type TrackerState, type PathInfo, createTrackerState, startTracking, createProxy, captureTrackedPaths, hasChanges, hasTrackedData, } from './dependency-tracker';
|
|
35
|
-
export { type ProxyTrackerState, createProxyTrackerState, startProxyTracking, stopProxyTracking, createProxyInternal, createArrayProxy, createProxyForTarget, isProxyable, } from './proxy-tracker';
|
|
36
|
-
export { parsePath, getValueAtPath, shallowEqual } from './path-utils';
|
|
37
|
-
export { type GetterTrackerState, createGetterTracker, createBlocProxy, hasGetterChanges, isGetter, getDescriptor, setActiveTracker, clearActiveTracker, getActiveTracker, commitTrackedGetters, invalidateRenderCache, resetGetterTracker, clearExternalDependencies, getGetterExecutionContext, } from './getter-tracker';
|
|
38
|
-
//# sourceMappingURL=index.d.ts.map
|
|
@@ -1,39 +0,0 @@
|
|
|
1
|
-
/**
|
|
2
|
-
* Path utilities for dependency tracking
|
|
3
|
-
*
|
|
4
|
-
* Provides utilities for parsing property paths and extracting values
|
|
5
|
-
* from nested objects using path strings.
|
|
6
|
-
*/
|
|
7
|
-
/**
|
|
8
|
-
* Parse a property path string into an array of segments
|
|
9
|
-
*
|
|
10
|
-
* Handles both dot notation (a.b.c) and bracket notation (a[0].b)
|
|
11
|
-
*
|
|
12
|
-
* @example
|
|
13
|
-
* parsePath('user.name') // ['user', 'name']
|
|
14
|
-
* parsePath('items[0].name') // ['items', '0', 'name']
|
|
15
|
-
* parsePath('data.users[2].address.city') // ['data', 'users', '2', 'address', 'city']
|
|
16
|
-
*/
|
|
17
|
-
export declare function parsePath(path: string): string[];
|
|
18
|
-
/**
|
|
19
|
-
* Get a value from an object using a path of segments
|
|
20
|
-
*
|
|
21
|
-
* @example
|
|
22
|
-
* const obj = { user: { name: 'Alice', age: 30 } }
|
|
23
|
-
* getValueAtPath(obj, ['user', 'name']) // 'Alice'
|
|
24
|
-
* getValueAtPath(obj, ['user', 'age']) // 30
|
|
25
|
-
* getValueAtPath(obj, ['user', 'missing']) // undefined
|
|
26
|
-
*/
|
|
27
|
-
export declare function getValueAtPath(obj: any, segments: string[]): any;
|
|
28
|
-
/**
|
|
29
|
-
* Shallow equality comparison for arrays
|
|
30
|
-
*
|
|
31
|
-
* Compares two arrays element-by-element using Object.is
|
|
32
|
-
*
|
|
33
|
-
* @example
|
|
34
|
-
* shallowEqual([1, 2, 3], [1, 2, 3]) // true
|
|
35
|
-
* shallowEqual([1, 2, 3], [1, 2, 4]) // false
|
|
36
|
-
* shallowEqual([1, 2], [1, 2, 3]) // false
|
|
37
|
-
*/
|
|
38
|
-
export declare function shallowEqual(arr1: unknown[], arr2: unknown[]): boolean;
|
|
39
|
-
//# sourceMappingURL=path-utils.d.ts.map
|
|
@@ -1,88 +0,0 @@
|
|
|
1
|
-
/**
|
|
2
|
-
* Functional proxy tracker for automatic dependency tracking
|
|
3
|
-
*
|
|
4
|
-
* This module provides a functional approach to proxy-based dependency tracking.
|
|
5
|
-
* Unlike the class-based ProxyTracker, this uses a state object pattern that's
|
|
6
|
-
* easier to integrate with functional programming patterns and framework hooks.
|
|
7
|
-
*/
|
|
8
|
-
/**
|
|
9
|
-
* Check if a value can be proxied
|
|
10
|
-
*
|
|
11
|
-
* Returns true for plain objects and arrays only.
|
|
12
|
-
* Excludes built-in objects like Date, Map, Set, etc.
|
|
13
|
-
*/
|
|
14
|
-
export declare function isProxyable(value: unknown): value is object;
|
|
15
|
-
/**
|
|
16
|
-
* State container for proxy tracking
|
|
17
|
-
*/
|
|
18
|
-
export interface ProxyTrackerState<T> {
|
|
19
|
-
/** Set of all tracked property paths */
|
|
20
|
-
trackedPaths: Set<string>;
|
|
21
|
-
/** Whether tracking is currently active */
|
|
22
|
-
isTracking: boolean;
|
|
23
|
-
/** Cache of created proxies to avoid duplicates */
|
|
24
|
-
proxyCache: WeakMap<object, any>;
|
|
25
|
-
/** Cache of bound functions to maintain referential equality */
|
|
26
|
-
boundFunctionsCache: WeakMap<Function, Function> | null;
|
|
27
|
-
/** Last state object that was proxied (for cache invalidation) */
|
|
28
|
-
lastProxiedState: T | null;
|
|
29
|
-
/** Last proxy created (for cache reuse) */
|
|
30
|
-
lastProxy: T | null;
|
|
31
|
-
/** Maximum depth for nested proxy creation */
|
|
32
|
-
maxDepth: number;
|
|
33
|
-
}
|
|
34
|
-
/**
|
|
35
|
-
* Create a new proxy tracker state
|
|
36
|
-
*
|
|
37
|
-
* @example
|
|
38
|
-
* const state = createProxyTrackerState<MyState>();
|
|
39
|
-
* startProxyTracking(state);
|
|
40
|
-
* const proxy = createProxyForTarget(state, myObject);
|
|
41
|
-
* // ... use proxy ...
|
|
42
|
-
* const paths = stopProxyTracking(state);
|
|
43
|
-
*/
|
|
44
|
-
export declare function createProxyTrackerState<T>(): ProxyTrackerState<T>;
|
|
45
|
-
/**
|
|
46
|
-
* Start tracking property accesses
|
|
47
|
-
*
|
|
48
|
-
* Clears previous tracked paths and enables tracking mode.
|
|
49
|
-
*/
|
|
50
|
-
export declare function startProxyTracking<T>(state: ProxyTrackerState<T>): void;
|
|
51
|
-
/**
|
|
52
|
-
* Stop tracking and return the tracked paths
|
|
53
|
-
*
|
|
54
|
-
* Returns a new Set containing all tracked paths.
|
|
55
|
-
*/
|
|
56
|
-
export declare function stopProxyTracking<T>(state: ProxyTrackerState<T>): Set<string>;
|
|
57
|
-
/**
|
|
58
|
-
* Create a proxy for an array with property access tracking
|
|
59
|
-
*
|
|
60
|
-
* Tracks:
|
|
61
|
-
* - Array element access (arr[0])
|
|
62
|
-
* - Length access (arr.length)
|
|
63
|
-
* - Array method calls (arr.map, arr.filter, etc.)
|
|
64
|
-
*/
|
|
65
|
-
export declare function createArrayProxy<T, U>(state: ProxyTrackerState<T>, target: U[], path: string, depth?: number): U[];
|
|
66
|
-
/**
|
|
67
|
-
* Create a proxy for an object with property access tracking
|
|
68
|
-
*
|
|
69
|
-
* This is the core proxy creation function that recursively creates proxies
|
|
70
|
-
* for nested objects and arrays.
|
|
71
|
-
*
|
|
72
|
-
* Tracks:
|
|
73
|
-
* - Property access (obj.prop)
|
|
74
|
-
* - Nested property access (obj.nested.prop)
|
|
75
|
-
* - 'in' operator usage ('prop' in obj)
|
|
76
|
-
* - Object.keys, Object.entries, etc.
|
|
77
|
-
*/
|
|
78
|
-
export declare function createProxyInternal<T>(state: ProxyTrackerState<T>, target: T, path?: string, depth?: number): T;
|
|
79
|
-
/**
|
|
80
|
-
* Create a proxy for a target with caching
|
|
81
|
-
*
|
|
82
|
-
* If the target hasn't changed since the last call, returns the cached proxy.
|
|
83
|
-
* Otherwise, creates a new proxy and caches it.
|
|
84
|
-
*
|
|
85
|
-
* This is the main entry point for creating tracked proxies.
|
|
86
|
-
*/
|
|
87
|
-
export declare function createProxyForTarget<T>(state: ProxyTrackerState<T>, target: T): T;
|
|
88
|
-
//# sourceMappingURL=proxy-tracker.d.ts.map
|
package/dist/types/branded.d.ts
DELETED
|
@@ -1,9 +0,0 @@
|
|
|
1
|
-
declare const brand: unique symbol;
|
|
2
|
-
export type Brand<T, B> = T & {
|
|
3
|
-
[brand]: B;
|
|
4
|
-
};
|
|
5
|
-
export type BrandedId<B> = Brand<string, B>;
|
|
6
|
-
export type InstanceId = Brand<string, 'InstanceId'>;
|
|
7
|
-
export declare function instanceId(id: string): InstanceId;
|
|
8
|
-
export {};
|
|
9
|
-
//# sourceMappingURL=branded.d.ts.map
|