@blac/core 2.0.0-rc.6 → 2.0.0-rc.9

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.
@@ -0,0 +1,57 @@
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
@@ -0,0 +1,115 @@
1
+ /**
2
+ * BlacPlugin - Plugin system for BlaC state management
3
+ *
4
+ * Provides a safe and powerful API for plugins to observe and interact with
5
+ * StateContainer instances without coupling to the core.
6
+ */
7
+ import type { StateContainer } from '../core/StateContainer';
8
+ import type { Vertex } from '../core/Vertex';
9
+ import type { BaseEvent } from '../types/events';
10
+ /**
11
+ * Instance metadata exposed to plugins
12
+ */
13
+ export interface InstanceMetadata {
14
+ /** Unique instance ID */
15
+ id: string;
16
+ /** Class name (e.g., 'CounterCubit') */
17
+ className: string;
18
+ isDisposed: boolean;
19
+ /** Custom name if provided */
20
+ name: string;
21
+ lastStateChangeTimestamp: number;
22
+ state: any;
23
+ createdAt: number;
24
+ /** Whether this is an isolated instance */
25
+ isIsolated: boolean;
26
+ /** Call stack for state update (optional, for DevTools) */
27
+ callstack?: string;
28
+ /** Previous state (optional, for state change events) */
29
+ previousState?: any;
30
+ /** Current state (optional, for state change events) */
31
+ currentState?: any;
32
+ }
33
+ /**
34
+ * Plugin context - provides safe access to BlaC internals
35
+ */
36
+ export interface PluginContext {
37
+ /**
38
+ * Get metadata for an instance
39
+ */
40
+ getInstanceMetadata(instance: StateContainer<any>): InstanceMetadata;
41
+ /**
42
+ * Get current state of an instance
43
+ */
44
+ getState<S>(instance: StateContainer<S>): S;
45
+ /**
46
+ * Query all instances of a specific type
47
+ */
48
+ queryInstances<T extends StateContainer<any>>(typeClass: new (...args: any[]) => T): T[];
49
+ /**
50
+ * Query all registered types
51
+ */
52
+ getAllTypes(): Array<new (...args: any[]) => StateContainer<any>>;
53
+ /**
54
+ * Get registry statistics
55
+ */
56
+ getStats(): {
57
+ registeredTypes: number;
58
+ totalInstances: number;
59
+ typeBreakdown: Record<string, number>;
60
+ };
61
+ }
62
+ /**
63
+ * Base plugin interface
64
+ */
65
+ export interface BlacPlugin {
66
+ /** Plugin name for identification */
67
+ readonly name: string;
68
+ /** Plugin version */
69
+ readonly version: string;
70
+ /**
71
+ * Called when plugin is installed
72
+ * @param context - Plugin context for safe access to BlaC internals
73
+ */
74
+ onInstall?(context: PluginContext): void;
75
+ /**
76
+ * Called when plugin is uninstalled
77
+ */
78
+ onUninstall?(): void;
79
+ /**
80
+ * Called when a StateContainer instance is created
81
+ */
82
+ onInstanceCreated?(instance: StateContainer<any>, context: PluginContext): void;
83
+ /**
84
+ * Called when state changes
85
+ */
86
+ onStateChanged?<S>(instance: StateContainer<S>, previousState: S, currentState: S, callstack: string | undefined, context: PluginContext): void;
87
+ /**
88
+ * Called when an event is added (Vertex only)
89
+ */
90
+ onEventAdded?<E extends BaseEvent>(vertex: Vertex<any, E>, event: E, context: PluginContext): void;
91
+ /**
92
+ * Called when an instance is disposed
93
+ */
94
+ onInstanceDisposed?(instance: StateContainer<any>, context: PluginContext): void;
95
+ }
96
+ /**
97
+ * Plugin with initialization hook
98
+ */
99
+ export interface BlacPluginWithInit extends BlacPlugin {
100
+ onInstall(context: PluginContext): void;
101
+ }
102
+ /**
103
+ * Plugin configuration options
104
+ */
105
+ export interface PluginConfig {
106
+ /** Whether plugin is enabled */
107
+ enabled?: boolean;
108
+ /** Environment filter (e.g., only run in development) */
109
+ environment?: 'development' | 'production' | 'test' | 'all';
110
+ }
111
+ /**
112
+ * Type guard for plugins with init
113
+ */
114
+ export declare function hasInitHook(plugin: BlacPlugin): plugin is BlacPluginWithInit;
115
+ //# sourceMappingURL=BlacPlugin.d.ts.map
@@ -0,0 +1,63 @@
1
+ /**
2
+ * PluginManager - Manages plugins and provides plugin context
3
+ * TESTS ARE FOR AN OLDER VERSION AND NEED TO BE REWRITTEN
4
+ */
5
+ import type { StateContainerRegistry } from '../core/StateContainerRegistry';
6
+ import type { BlacPlugin, PluginConfig } from './BlacPlugin';
7
+ /**
8
+ * Plugin manager for registering and coordinating plugins
9
+ */
10
+ export declare class PluginManager {
11
+ private plugins;
12
+ private registry;
13
+ constructor(registry: StateContainerRegistry);
14
+ /**
15
+ * Install a plugin
16
+ */
17
+ install(plugin: BlacPlugin, config?: PluginConfig): void;
18
+ /**
19
+ * Uninstall a plugin
20
+ */
21
+ uninstall(pluginName: string): void;
22
+ /**
23
+ * Get installed plugin
24
+ */
25
+ getPlugin(pluginName: string): BlacPlugin | undefined;
26
+ /**
27
+ * Get all installed plugins
28
+ */
29
+ getAllPlugins(): BlacPlugin[];
30
+ /**
31
+ * Check if plugin is installed
32
+ */
33
+ hasPlugin(pluginName: string): boolean;
34
+ /**
35
+ * Clear all plugins (for testing)
36
+ */
37
+ clear(): void;
38
+ /**
39
+ * Setup lifecycle hooks to notify plugins
40
+ */
41
+ private setupLifecycleHooks;
42
+ /**
43
+ * Notify all plugins of a lifecycle event
44
+ */
45
+ private notifyPlugins;
46
+ /**
47
+ * Create plugin context with safe API access
48
+ */
49
+ private createPluginContext;
50
+ /**
51
+ * Check if plugin should be enabled based on environment
52
+ */
53
+ private shouldEnablePlugin;
54
+ /**
55
+ * Get current environment
56
+ */
57
+ private getCurrentEnvironment;
58
+ }
59
+ /**
60
+ * Create a plugin manager instance
61
+ */
62
+ export declare function createPluginManager(registry: StateContainerRegistry): PluginManager;
63
+ //# sourceMappingURL=PluginManager.d.ts.map
@@ -0,0 +1,20 @@
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
@@ -0,0 +1,43 @@
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
@@ -0,0 +1,21 @@
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
@@ -0,0 +1,31 @@
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
@@ -0,0 +1,38 @@
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
@@ -0,0 +1,39 @@
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
@@ -0,0 +1,88 @@
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
@@ -0,0 +1,9 @@
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
@@ -0,0 +1,13 @@
1
+ /**
2
+ * Base event interface for type-safe event system
3
+ */
4
+ /**
5
+ * Base event interface
6
+ * Used by Vertex for event-driven state management
7
+ */
8
+ export interface BaseEvent {
9
+ readonly type: string;
10
+ readonly timestamp: number;
11
+ readonly source?: string;
12
+ }
13
+ //# sourceMappingURL=events.d.ts.map
@@ -0,0 +1,18 @@
1
+ import type { StateContainer } from '../core/StateContainer';
2
+ export type ExtractState<T> = T extends StateContainer<infer S> ? S : never;
3
+ export type ExtractConstructorArgs<T> = T extends new (...args: infer P) => any ? P : never[];
4
+ export type BlocConstructor<TBloc extends StateContainer<any>> = (new (...args: any[]) => TBloc) & {
5
+ resolve(instanceKey?: string, ...args: any[]): TBloc;
6
+ get(instanceKey?: string): TBloc;
7
+ getSafe(instanceKey?: string): {
8
+ error: Error;
9
+ instance: null;
10
+ } | {
11
+ error: null;
12
+ instance: TBloc;
13
+ };
14
+ release(instanceKey?: string): void;
15
+ isolated?: boolean;
16
+ keepAlive?: boolean;
17
+ };
18
+ //# sourceMappingURL=utilities.d.ts.map
@@ -0,0 +1,9 @@
1
+ /**
2
+ * Deep equality check with circular reference handling
3
+ */
4
+ export declare function deepEqual<T>(a: T, b: T, seen?: WeakMap<WeakKey, any>): boolean;
5
+ /**
6
+ * Shallow equality check (more performant for simple cases)
7
+ */
8
+ export declare function shallowEqual<T>(a: T, b: T): boolean;
9
+ //# sourceMappingURL=equality.d.ts.map
@@ -0,0 +1,76 @@
1
+ /**
2
+ * Centralized ID Generation
3
+ *
4
+ * Provides consistent, collision-resistant ID generation for all BlaC subsystems.
5
+ * Uses timestamp + counter + random suffix for uniqueness.
6
+ */
7
+ /**
8
+ * Creates an ID generator with isolated counter state
9
+ *
10
+ * @param prefix - Prefix for generated IDs
11
+ * @returns Object with next(), nextSimple(), and reset() methods
12
+ *
13
+ * @example
14
+ * ```ts
15
+ * const generator = createIdGenerator('sub');
16
+ * const id1 = generator.next(); // "sub:1698765432100_1_a3k9d7f2q"
17
+ * const id2 = generator.next(); // "sub:1698765432101_2_b4n8e9g3r"
18
+ * ```
19
+ */
20
+ export declare function createIdGenerator(prefix: string): {
21
+ next: () => string;
22
+ nextSimple: () => string;
23
+ reset: () => void;
24
+ };
25
+ /**
26
+ * Generate ID with timestamp, counter, and random suffix (tree-shakeable)
27
+ *
28
+ * Format: `${prefix}:${timestamp}_${counter}_${random}`
29
+ *
30
+ * @param prefix - Prefix for the ID (e.g., 'sub', 'consumer', 'stage')
31
+ * @returns Branded ID string
32
+ *
33
+ * @example
34
+ * ```ts
35
+ * const id = generateId('sub');
36
+ * // Returns: "sub:1698765432100_1_a3k9d7f2q"
37
+ * ```
38
+ */
39
+ export declare function generateId(prefix: string): string;
40
+ /**
41
+ * Generate simple ID with timestamp and random (no counter tracking)
42
+ *
43
+ * Format: `${prefix}:${timestamp}_${random}`
44
+ *
45
+ * @param prefix - Prefix for the ID
46
+ * @returns Branded ID string
47
+ *
48
+ * @example
49
+ * ```ts
50
+ * const id = generateSimpleId('CounterBloc');
51
+ * // Returns: "CounterBloc:1698765432100_a3k9d7f2q"
52
+ * ```
53
+ */
54
+ export declare function generateSimpleId(prefix: string, affix?: string): string;
55
+ /**
56
+ * Reset all counters for testing purposes
57
+ * @internal
58
+ */
59
+ export declare function __resetIdCounters(): void;
60
+ /**
61
+ * Generate a unique isolated instance key
62
+ * Uses base36 encoding for compact, URL-safe identifiers
63
+ *
64
+ * Format: "isolated-{9-char-random-string}"
65
+ * Example: "isolated-k7x2m9p4q"
66
+ *
67
+ * @returns A unique isolated instance key
68
+ */
69
+ export declare function generateIsolatedKey(): string;
70
+ /**
71
+ * Check if a key is an isolated instance key
72
+ * @param key - The instance key to check
73
+ * @returns true if the key is an isolated instance key
74
+ */
75
+ export declare function isIsolatedKey(key: string): boolean;
76
+ //# sourceMappingURL=idGenerator.d.ts.map
@@ -0,0 +1,16 @@
1
+ /**
2
+ * Deep clone with circular reference handling
3
+ */
4
+ export declare function cloneDeep<T>(obj: T, cloned?: WeakMap<WeakKey, any>): T;
5
+ /**
6
+ * Deep freeze with circular reference handling
7
+ *
8
+ * Note: Currently disabled by default for proxy tracking compatibility.
9
+ * Proxies cannot intercept property access on frozen objects due to proxy invariants.
10
+ *
11
+ * @param obj - Object to freeze
12
+ * @param frozen - WeakSet for tracking circular references
13
+ * @param enabled - Whether to actually freeze (default: false for proxy compatibility)
14
+ */
15
+ export declare function deepFreeze<T>(obj: T, frozen?: WeakSet<WeakKey>, enabled?: boolean): T;
16
+ //# sourceMappingURL=immutable.d.ts.map