@blac/core 2.0.0-rc.0 → 2.0.0-rc.10

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.
Files changed (146) hide show
  1. package/dist/adapter/framework-adapter.d.ts +33 -0
  2. package/dist/adapter/index.d.ts +7 -2
  3. package/dist/constants.d.ts +82 -0
  4. package/dist/core/Cubit.d.ts +40 -0
  5. package/dist/core/StateContainer.d.ts +78 -0
  6. package/dist/core/StateContainerRegistry.d.ts +119 -0
  7. package/dist/core/Vertex.d.ts +74 -0
  8. package/dist/decorators/blac.d.ts +31 -0
  9. package/dist/decorators/index.d.ts +2 -0
  10. package/dist/index.cjs +1870 -38
  11. package/dist/index.d.cts +21 -0
  12. package/dist/index.d.ts +19 -15
  13. package/dist/index.js +1789 -37
  14. package/dist/logging/Logger.d.ts +57 -0
  15. package/dist/plugin/BlacPlugin.d.ts +46 -0
  16. package/dist/plugin/PluginManager.d.ts +38 -0
  17. package/dist/registry/index.d.ts +20 -0
  18. package/dist/test-utils/index.d.ts +43 -0
  19. package/dist/tracking/dependency-tracker.d.ts +21 -0
  20. package/dist/tracking/getter-tracker.d.ts +31 -0
  21. package/dist/tracking/index.d.ts +38 -0
  22. package/dist/tracking/path-utils.d.ts +39 -0
  23. package/dist/tracking/proxy-tracker.d.ts +88 -0
  24. package/dist/types/branded.d.ts +9 -0
  25. package/dist/types/events.d.ts +13 -0
  26. package/dist/types/utilities.d.ts +19 -0
  27. package/dist/utils/equality.d.ts +9 -0
  28. package/dist/utils/idGenerator.d.ts +76 -0
  29. package/dist/utils/immutable.d.ts +16 -0
  30. package/dist/utils/stack-trace.d.ts +19 -0
  31. package/dist/utils/static-props.d.ts +29 -0
  32. package/package.json +33 -13
  33. package/dist/.tsbuildinfo +0 -1
  34. package/dist/Blac.d.ts +0 -246
  35. package/dist/Blac.d.ts.map +0 -1
  36. package/dist/Blac.js +0 -625
  37. package/dist/Blac.js.map +0 -1
  38. package/dist/Bloc.d.ts +0 -41
  39. package/dist/Bloc.d.ts.map +0 -1
  40. package/dist/Bloc.js +0 -140
  41. package/dist/Bloc.js.map +0 -1
  42. package/dist/BlocBase.d.ts +0 -110
  43. package/dist/BlocBase.d.ts.map +0 -1
  44. package/dist/BlocBase.js +0 -287
  45. package/dist/BlocBase.js.map +0 -1
  46. package/dist/Cubit.d.ts +0 -25
  47. package/dist/Cubit.d.ts.map +0 -1
  48. package/dist/Cubit.js +0 -64
  49. package/dist/Cubit.js.map +0 -1
  50. package/dist/adapter/BlacAdapter.d.ts +0 -71
  51. package/dist/adapter/BlacAdapter.d.ts.map +0 -1
  52. package/dist/adapter/BlacAdapter.js +0 -373
  53. package/dist/adapter/BlacAdapter.js.map +0 -1
  54. package/dist/adapter/ProxyFactory.d.ts +0 -50
  55. package/dist/adapter/ProxyFactory.d.ts.map +0 -1
  56. package/dist/adapter/ProxyFactory.js +0 -150
  57. package/dist/adapter/ProxyFactory.js.map +0 -1
  58. package/dist/adapter/index.d.ts.map +0 -1
  59. package/dist/adapter/index.js +0 -19
  60. package/dist/adapter/index.js.map +0 -1
  61. package/dist/errors/BlacError.d.ts +0 -38
  62. package/dist/errors/BlacError.d.ts.map +0 -1
  63. package/dist/errors/BlacError.js +0 -55
  64. package/dist/errors/BlacError.js.map +0 -1
  65. package/dist/errors/ErrorManager.d.ts +0 -39
  66. package/dist/errors/ErrorManager.d.ts.map +0 -1
  67. package/dist/errors/ErrorManager.js +0 -91
  68. package/dist/errors/ErrorManager.js.map +0 -1
  69. package/dist/errors/handleError.d.ts +0 -24
  70. package/dist/errors/handleError.d.ts.map +0 -1
  71. package/dist/errors/handleError.js +0 -62
  72. package/dist/errors/handleError.js.map +0 -1
  73. package/dist/errors/index.d.ts +0 -5
  74. package/dist/errors/index.d.ts.map +0 -1
  75. package/dist/errors/index.js +0 -13
  76. package/dist/errors/index.js.map +0 -1
  77. package/dist/events.d.ts +0 -11
  78. package/dist/events.d.ts.map +0 -1
  79. package/dist/events.js +0 -17
  80. package/dist/events.js.map +0 -1
  81. package/dist/index.d.ts.map +0 -1
  82. package/dist/index.js.map +0 -1
  83. package/dist/lifecycle/BlocLifecycle.d.ts +0 -51
  84. package/dist/lifecycle/BlocLifecycle.d.ts.map +0 -1
  85. package/dist/lifecycle/BlocLifecycle.js +0 -123
  86. package/dist/lifecycle/BlocLifecycle.js.map +0 -1
  87. package/dist/lifecycle/index.d.ts +0 -2
  88. package/dist/lifecycle/index.d.ts.map +0 -1
  89. package/dist/lifecycle/index.js +0 -18
  90. package/dist/lifecycle/index.js.map +0 -1
  91. package/dist/plugins/BlocPluginRegistry.d.ts +0 -58
  92. package/dist/plugins/BlocPluginRegistry.d.ts.map +0 -1
  93. package/dist/plugins/BlocPluginRegistry.js +0 -201
  94. package/dist/plugins/BlocPluginRegistry.js.map +0 -1
  95. package/dist/plugins/SystemPluginRegistry.d.ts +0 -79
  96. package/dist/plugins/SystemPluginRegistry.d.ts.map +0 -1
  97. package/dist/plugins/SystemPluginRegistry.js +0 -184
  98. package/dist/plugins/SystemPluginRegistry.js.map +0 -1
  99. package/dist/plugins/index.d.ts +0 -4
  100. package/dist/plugins/index.d.ts.map +0 -1
  101. package/dist/plugins/index.js +0 -26
  102. package/dist/plugins/index.js.map +0 -1
  103. package/dist/plugins/types.d.ts +0 -103
  104. package/dist/plugins/types.d.ts.map +0 -1
  105. package/dist/plugins/types.js +0 -3
  106. package/dist/plugins/types.js.map +0 -1
  107. package/dist/subscription/SubscriptionManager.d.ts +0 -67
  108. package/dist/subscription/SubscriptionManager.d.ts.map +0 -1
  109. package/dist/subscription/SubscriptionManager.js +0 -317
  110. package/dist/subscription/SubscriptionManager.js.map +0 -1
  111. package/dist/subscription/index.d.ts +0 -3
  112. package/dist/subscription/index.d.ts.map +0 -1
  113. package/dist/subscription/index.js +0 -19
  114. package/dist/subscription/index.js.map +0 -1
  115. package/dist/subscription/types.d.ts +0 -65
  116. package/dist/subscription/types.d.ts.map +0 -1
  117. package/dist/subscription/types.js +0 -3
  118. package/dist/subscription/types.js.map +0 -1
  119. package/dist/testing.d.ts +0 -85
  120. package/dist/testing.d.ts.map +0 -1
  121. package/dist/testing.js +0 -186
  122. package/dist/testing.js.map +0 -1
  123. package/dist/types.d.ts +0 -57
  124. package/dist/types.d.ts.map +0 -1
  125. package/dist/types.js +0 -3
  126. package/dist/types.js.map +0 -1
  127. package/dist/utils/BatchingManager.d.ts +0 -28
  128. package/dist/utils/BatchingManager.d.ts.map +0 -1
  129. package/dist/utils/BatchingManager.js +0 -48
  130. package/dist/utils/BatchingManager.js.map +0 -1
  131. package/dist/utils/RerenderLogger.d.ts +0 -60
  132. package/dist/utils/RerenderLogger.d.ts.map +0 -1
  133. package/dist/utils/RerenderLogger.js +0 -205
  134. package/dist/utils/RerenderLogger.js.map +0 -1
  135. package/dist/utils/generateInstanceId.d.ts +0 -11
  136. package/dist/utils/generateInstanceId.d.ts.map +0 -1
  137. package/dist/utils/generateInstanceId.js +0 -50
  138. package/dist/utils/generateInstanceId.js.map +0 -1
  139. package/dist/utils/shallowEqual.d.ts +0 -9
  140. package/dist/utils/shallowEqual.d.ts.map +0 -1
  141. package/dist/utils/shallowEqual.js +0 -35
  142. package/dist/utils/shallowEqual.js.map +0 -1
  143. package/dist/utils/uuid.d.ts +0 -10
  144. package/dist/utils/uuid.d.ts.map +0 -1
  145. package/dist/utils/uuid.js +0 -24
  146. package/dist/utils/uuid.js.map +0 -1
@@ -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,46 @@
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
@@ -0,0 +1,38 @@
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
@@ -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,19 @@
1
+ import type { StateContainer } from '../core/StateContainer';
2
+ export type ExtractState<T> = T extends StateContainer<infer S, any> ? S : never;
3
+ export type ExtractProps<T> = T extends StateContainer<any, infer P> ? P : undefined;
4
+ export type ExtractConstructorArgs<T> = T extends new (...args: infer P) => any ? P : never[];
5
+ export type BlocConstructor<TBloc extends StateContainer<any, any>> = (new (...args: any[]) => TBloc) & {
6
+ resolve(instanceKey?: string, ...args: any[]): TBloc;
7
+ get(instanceKey?: string): TBloc;
8
+ getSafe(instanceKey?: string): {
9
+ error: Error;
10
+ instance: null;
11
+ } | {
12
+ error: null;
13
+ instance: TBloc;
14
+ };
15
+ release(instanceKey?: string): void;
16
+ isolated?: boolean;
17
+ keepAlive?: boolean;
18
+ };
19
+ //# 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
@@ -0,0 +1,19 @@
1
+ /**
2
+ * Stack trace utilities for DevTools
3
+ */
4
+ /**
5
+ * Capture and parse the current call stack
6
+ * Filters out internal BlaC framework calls to show only user code
7
+ */
8
+ export declare function captureStackTrace(): string;
9
+ /**
10
+ * Parse a stack trace string into structured data
11
+ */
12
+ export interface StackFrame {
13
+ functionName: string;
14
+ fileName: string;
15
+ lineNumber: number | null;
16
+ columnNumber: number | null;
17
+ }
18
+ export declare function parseStackTrace(stack: string): StackFrame[];
19
+ //# sourceMappingURL=stack-trace.d.ts.map
@@ -0,0 +1,29 @@
1
+ /**
2
+ * Utility functions for accessing static properties on StateContainer classes
3
+ */
4
+ /**
5
+ * Get a static property from a class constructor
6
+ * Type-safe helper that avoids (Type as any) casts
7
+ *
8
+ * @param Type - The class constructor
9
+ * @param propName - The property name to access
10
+ * @param defaultValue - Optional default value if property is undefined
11
+ * @returns The property value or default
12
+ */
13
+ export declare function getStaticProp<T>(Type: new (...args: any[]) => any, propName: string, defaultValue?: T): T | undefined;
14
+ /**
15
+ * Check if a class is marked as isolated
16
+ * Isolated classes create separate instances per component
17
+ */
18
+ export declare function isIsolatedClass(Type: new (...args: any[]) => any): boolean;
19
+ /**
20
+ * Check if a class is marked as keepAlive
21
+ * KeepAlive classes are never auto-disposed when ref count reaches 0
22
+ */
23
+ export declare function isKeepAliveClass(Type: new (...args: any[]) => any): boolean;
24
+ /**
25
+ * Check if a class should be excluded from DevTools
26
+ * Used to prevent infinite loops when DevTools tracks itself
27
+ */
28
+ export declare function isExcludedFromDevTools(Type: new (...args: any[]) => any): boolean;
29
+ //# sourceMappingURL=static-props.d.ts.map