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

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 (60) hide show
  1. package/dist/adapter/framework-adapter.d.ts +114 -0
  2. package/dist/adapter/framework-adapter.d.ts.map +1 -0
  3. package/dist/adapter/index.d.ts +8 -0
  4. package/dist/adapter/index.d.ts.map +1 -0
  5. package/dist/constants.d.ts +82 -0
  6. package/dist/constants.d.ts.map +1 -0
  7. package/dist/core/Cubit.d.ts +82 -0
  8. package/dist/core/Cubit.d.ts.map +1 -0
  9. package/dist/core/StateContainer.d.ts +200 -0
  10. package/dist/core/StateContainer.d.ts.map +1 -0
  11. package/dist/core/StateContainerRegistry.d.ts +176 -0
  12. package/dist/core/StateContainerRegistry.d.ts.map +1 -0
  13. package/dist/core/Vertex.d.ts +113 -0
  14. package/dist/core/Vertex.d.ts.map +1 -0
  15. package/dist/index.cjs +1158 -326
  16. package/dist/index.cjs.map +1 -1
  17. package/dist/index.d.cts +20 -885
  18. package/dist/index.d.ts +19 -884
  19. package/dist/index.d.ts.map +1 -0
  20. package/dist/index.js +1122 -327
  21. package/dist/index.js.map +1 -1
  22. package/dist/logging/Logger.d.ts +57 -0
  23. package/dist/logging/Logger.d.ts.map +1 -0
  24. package/dist/plugin/BlacPlugin.d.ts +115 -0
  25. package/dist/plugin/BlacPlugin.d.ts.map +1 -0
  26. package/dist/plugin/PluginManager.d.ts +63 -0
  27. package/dist/plugin/PluginManager.d.ts.map +1 -0
  28. package/dist/proxy/ProxyTracker.d.ts +71 -0
  29. package/dist/proxy/ProxyTracker.d.ts.map +1 -0
  30. package/dist/registry/index.d.ts +20 -0
  31. package/dist/registry/index.d.ts.map +1 -0
  32. package/dist/test-utils/index.d.ts +43 -0
  33. package/dist/test-utils/index.d.ts.map +1 -0
  34. package/dist/tracking/dependency-tracker.d.ts +21 -0
  35. package/dist/tracking/dependency-tracker.d.ts.map +1 -0
  36. package/dist/tracking/getter-tracker.d.ts +31 -0
  37. package/dist/tracking/getter-tracker.d.ts.map +1 -0
  38. package/dist/tracking/index.d.ts +38 -0
  39. package/dist/tracking/index.d.ts.map +1 -0
  40. package/dist/tracking/path-utils.d.ts +39 -0
  41. package/dist/tracking/path-utils.d.ts.map +1 -0
  42. package/dist/tracking/proxy-tracker.d.ts +88 -0
  43. package/dist/tracking/proxy-tracker.d.ts.map +1 -0
  44. package/dist/types/branded.d.ts +9 -0
  45. package/dist/types/branded.d.ts.map +1 -0
  46. package/dist/types/events.d.ts +13 -0
  47. package/dist/types/events.d.ts.map +1 -0
  48. package/dist/types/utilities.d.ts +18 -0
  49. package/dist/types/utilities.d.ts.map +1 -0
  50. package/dist/utils/equality.d.ts +9 -0
  51. package/dist/utils/equality.d.ts.map +1 -0
  52. package/dist/utils/idGenerator.d.ts +76 -0
  53. package/dist/utils/idGenerator.d.ts.map +1 -0
  54. package/dist/utils/immutable.d.ts +16 -0
  55. package/dist/utils/immutable.d.ts.map +1 -0
  56. package/dist/utils/stack-trace.d.ts +19 -0
  57. package/dist/utils/stack-trace.d.ts.map +1 -0
  58. package/dist/utils/static-props.d.ts +29 -0
  59. package/dist/utils/static-props.d.ts.map +1 -0
  60. package/package.json +17 -4
package/dist/index.d.cts CHANGED
@@ -1,885 +1,20 @@
1
- //#region src/types/events.d.ts
2
- /**
3
- * Base event interface for type-safe event system
4
- */
5
- /**
6
- * Base event interface
7
- * Used by Vertex for event-driven state management
8
- */
9
- interface BaseEvent {
10
- readonly type: string;
11
- readonly timestamp: number;
12
- readonly source?: string;
13
- }
14
- //#endregion
15
- //#region src/core/Vertex.d.ts
16
-
17
- /**
18
- * Event handler signature (synchronous only)
19
- */
20
- type EventHandler<E$1 extends BaseEvent, S$1> = (event: E$1, emit: (state: S$1) => void) => void;
21
- /**
22
- * Type-safe event constructor
23
- */
24
- type EventConstructor<T$1 extends BaseEvent = BaseEvent> = new (...args: never[]) => T$1;
25
- /**
26
- * Vertex is an event-driven state container (Bloc pattern)
27
- *
28
- * Includes its own simple event system since events are only needed
29
- * for the Vertex pattern, not for the base StateContainer.
30
- */
31
- declare abstract class Vertex<S$1, E$1 extends BaseEvent = BaseEvent> extends StateContainer<S$1> {
32
- private eventHandlers;
33
- private isProcessing;
34
- private eventQueue;
35
- /**
36
- * Create a new Vertex
37
- * @param initialState Initial state value
38
- * @param config Configuration options
39
- */
40
- constructor(initialState: S$1, config?: StateContainerConfig);
41
- /**
42
- * Register an event handler
43
- * Arrow function to maintain correct 'this' binding
44
- */
45
- protected on: <T extends E$1>(EventClass: EventConstructor<T>, handler: EventHandler<T, S$1>) => void;
46
- /**
47
- * Add an event to be processed
48
- * Arrow function to maintain correct 'this' binding in React
49
- */
50
- add: (event: E$1) => void;
51
- /**
52
- * Process an event (synchronously)
53
- */
54
- private processEvent;
55
- /**
56
- * Handle a single event (synchronously)
57
- */
58
- private handleEvent;
59
- /**
60
- * Hook for handling event processing errors
61
- */
62
- protected onEventError(event: E$1, error: Error): void;
63
- }
64
- /**
65
- * Example: Counter Events
66
- */
67
- declare class IncrementEvent implements BaseEvent {
68
- readonly amount: number;
69
- readonly type = "increment";
70
- readonly timestamp: number;
71
- constructor(amount?: number);
72
- }
73
- declare class DecrementEvent implements BaseEvent {
74
- readonly amount: number;
75
- readonly type = "decrement";
76
- readonly timestamp: number;
77
- constructor(amount?: number);
78
- }
79
- declare class ResetEvent implements BaseEvent {
80
- readonly type = "reset";
81
- readonly timestamp: number;
82
- }
83
- /**
84
- * Example: Counter Vertex
85
- * Demonstrates proper typing and event handling
86
- */
87
- declare class CounterVertex extends Vertex<number> {
88
- constructor();
89
- increment: (amount?: number) => void;
90
- decrement: (amount?: number) => void;
91
- reset: () => void;
92
- }
93
- /**
94
- * Auth State and Events for testing async handlers
95
- */
96
- interface AuthState {
97
- isAuthenticated: boolean;
98
- isLoading: boolean;
99
- user: {
100
- id: string;
101
- name: string;
102
- email: string;
103
- } | null;
104
- error: string | null;
105
- }
106
- declare class LoginEvent implements BaseEvent {
107
- readonly email: string;
108
- readonly password: string;
109
- readonly type = "login";
110
- readonly timestamp: number;
111
- constructor(email: string, password: string);
112
- }
113
- declare class LogoutEvent implements BaseEvent {
114
- readonly type = "logout";
115
- readonly timestamp: number;
116
- }
117
- declare class AuthVertex extends Vertex<AuthState> {
118
- constructor();
119
- login: (email: string, password: string) => void;
120
- logout: () => void;
121
- }
122
- //#endregion
123
- //#region src/core/StateContainerRegistry.d.ts
124
- /**
125
- * Lifecycle events that can be observed
126
- */
127
- type LifecycleEvent = 'created' | 'stateChanged' | 'eventAdded' | 'disposed';
128
- /**
129
- * Listener function types for each lifecycle event
130
- */
131
- type LifecycleListener<E$1 extends LifecycleEvent> = E$1 extends 'created' ? (container: StateContainer<any>) => void : E$1 extends 'stateChanged' ? (container: StateContainer<any>, previousState: any, currentState: any) => void : E$1 extends 'eventAdded' ? (container: Vertex<any, any>, event: any) => void : E$1 extends 'disposed' ? (container: StateContainer<any>) => void : never;
132
- /**
133
- * Registry for managing StateContainer instances
134
- */
135
- declare class StateContainerRegistry {
136
- private readonly instances;
137
- private readonly types;
138
- private readonly listeners;
139
- /**
140
- * Register a type with isolation mode
141
- */
142
- register<T extends StateContainer<any>>(constructor: new (...args: any[]) => T, isolated?: boolean): void;
143
- /**
144
- * Get or create a StateContainer instance
145
- * For isolated: always creates new
146
- * For shared: singleton per key
147
- */
148
- getOrCreate<T extends StateContainer<any>>(constructor: new (...args: any[]) => T, key?: string, ...args: any[]): T;
149
- /**
150
- * Release a reference to an instance
151
- * Disposes when ref count reaches zero (unless static keepAlive is true)
152
- */
153
- release<T extends StateContainer<any>>(constructor: new (...args: any[]) => T, key?: string, forceDispose?: boolean): void;
154
- /**
155
- * Get all instances of a type (shared only, isolated aren't tracked)
156
- */
157
- getAll<T extends StateContainer<any>>(constructor: new (...args: any[]) => T): T[];
158
- /**
159
- * Clear all instances of a type
160
- */
161
- clear<T extends StateContainer<any>>(constructor: new (...args: any[]) => T): void;
162
- /**
163
- * Clear all instances from all types (for testing)
164
- */
165
- clearAll(): void;
166
- /**
167
- * Get registry statistics (for debugging)
168
- */
169
- getStats(): {
170
- registeredTypes: number;
171
- totalInstances: number;
172
- typeBreakdown: Record<string, number>;
173
- };
174
- /**
175
- * Get reference count for an instance
176
- */
177
- getRefCount<T extends StateContainer<any>>(constructor: new (...args: any[]) => T, key?: string): number;
178
- /**
179
- * Check if an instance exists
180
- */
181
- hasInstance<T extends StateContainer<any>>(constructor: new (...args: any[]) => T, key?: string): boolean;
182
- /**
183
- * Subscribe to lifecycle events
184
- * @param event - The lifecycle event to listen for
185
- * @param listener - The listener function to call when the event occurs
186
- * @returns Unsubscribe function
187
- */
188
- on<E extends LifecycleEvent>(event: E, listener: LifecycleListener<E>): () => void;
189
- /**
190
- * Emit lifecycle event to all listeners
191
- * @internal - Called by StateContainer/Vertex lifecycle methods
192
- */
193
- emit(event: LifecycleEvent, ...args: any[]): void;
194
- }
195
- /**
196
- * Global default registry instance
197
- */
198
- declare const globalRegistry: StateContainerRegistry;
199
- //#endregion
200
- //#region src/core/StateContainer.d.ts
201
- /**
202
- * Configuration options for StateContainer
203
- */
204
- interface StateContainerConfig {
205
- /** Container name for debugging */
206
- name?: string;
207
- /** Enable debug logging */
208
- debug?: boolean;
209
- /** Custom instance identifier */
210
- instanceId?: string;
211
- }
212
- /**
213
- * Listener function for state changes
214
- */
215
- type StateListener<S$1> = (state: S$1) => void;
216
- /**
217
- * Base abstract class for all state containers
218
- */
219
- declare abstract class StateContainer<S$1> {
220
- protected static _registry: StateContainerRegistry;
221
- /**
222
- * Set a custom registry (mainly for testing)
223
- */
224
- static setRegistry(registry: StateContainerRegistry): void;
225
- /**
226
- * Register a type as isolated or shared
227
- */
228
- static register<T extends StateContainer<any>>(this: new (...args: any[]) => T, isolated?: boolean): void;
229
- /**
230
- * Get or create an instance
231
- * @param key - Optional instance key for shared instances
232
- * @param args - Constructor arguments
233
- */
234
- static getOrCreate<T extends StateContainer<any>>(this: new (...args: any[]) => T, key?: string, ...args: any[]): T;
235
- /**
236
- * Release a reference to an instance
237
- * @param key - Optional instance key
238
- * @param forceDispose - Force dispose regardless of ref count or keepAlive
239
- */
240
- static release<T extends StateContainer<any>>(this: new (...args: any[]) => T, key?: string, forceDispose?: boolean): void;
241
- /**
242
- * Get all instances of this type
243
- */
244
- static getAll<T extends StateContainer<any>>(this: new (...args: any[]) => T): T[];
245
- /**
246
- * Clear all instances of this type
247
- */
248
- static clear<T extends StateContainer<any>>(this: new (...args: any[]) => T): void;
249
- /**
250
- * Clear all instances from all types (for testing)
251
- */
252
- static clearAllInstances(): void;
253
- /**
254
- * Get registry statistics (for debugging)
255
- */
256
- static getStats(): {
257
- registeredTypes: number;
258
- totalInstances: number;
259
- typeBreakdown: Record<string, number>;
260
- };
261
- /**
262
- * Get reference count for an instance
263
- * @param key - Optional instance key
264
- */
265
- static getRefCount<T extends StateContainer<any>>(this: new (...args: any[]) => T, key?: string): number;
266
- /**
267
- * Check if an instance exists
268
- * @param key - Optional instance key
269
- */
270
- static hasInstance<T extends StateContainer<any>>(this: new (...args: any[]) => T, key?: string): boolean;
271
- private _state;
272
- private readonly listeners;
273
- private _disposed;
274
- private readonly config;
275
- readonly name: string;
276
- readonly debug: boolean;
277
- readonly instanceId: string;
278
- /**
279
- * Create a new StateContainer
280
- */
281
- constructor(initialState: S$1, config?: StateContainerConfig);
282
- /**
283
- * Get the current state
284
- */
285
- get state(): S$1;
286
- /**
287
- * Check if disposed
288
- */
289
- get isDisposed(): boolean;
290
- /**
291
- * Subscribe to state changes
292
- * @returns Unsubscribe function
293
- */
294
- subscribe(listener: StateListener<S$1>): () => void;
295
- /**
296
- * Dispose the container
297
- */
298
- dispose(): void;
299
- /**
300
- * Emit a new state (with change detection)
301
- */
302
- protected emit(newState: S$1): void;
303
- /**
304
- * Update state using a function
305
- */
306
- protected update(updater: (current: S$1) => S$1): void;
307
- /**
308
- * Optional disposal hook for subclasses
309
- */
310
- protected onDispose?(): void;
311
- /**
312
- * Optional state change hook for subclasses
313
- */
314
- protected onStateChange?(newState: S$1, previousState: S$1): void;
315
- }
316
- //#endregion
317
- //#region src/core/Cubit.d.ts
318
- /**
319
- * Cubit is a simple state container that allows direct state emission
320
- *
321
- * Unlike StateContainer (where emit is protected), Cubit exposes emit and update
322
- * as public methods to allow direct state management.
323
- */
324
- declare abstract class Cubit<S$1> extends StateContainer<S$1> {
325
- /**
326
- * Create a new Cubit
327
- * @param initialState Initial state value
328
- * @param config Configuration options
329
- */
330
- constructor(initialState: S$1, config?: StateContainerConfig);
331
- /**
332
- * Emit a new state (public override of protected parent method)
333
- */
334
- emit(newState: S$1): void;
335
- /**
336
- * Update state using a function (public override of protected parent method)
337
- */
338
- update(updater: (current: S$1) => S$1): void;
339
- /**
340
- * Patch state with partial updates (shallow merge)
341
- * Only available when state is an object type
342
- * Arrow function to maintain correct 'this' binding in React
343
- *
344
- * @example
345
- * ```typescript
346
- * // Update single field
347
- * this.patch({ count: 5 });
348
- *
349
- * // Update multiple fields
350
- * this.patch({ count: 5, name: 'Updated' });
351
- * ```
352
- */
353
- patch: S$1 extends object ? (partial: Partial<S$1>) => void : never;
354
- }
355
- /**
356
- * Example: Counter Cubit
357
- */
358
- declare class CounterCubit extends Cubit<number> {
359
- constructor();
360
- increment: () => void;
361
- decrement: () => void;
362
- reset: () => void;
363
- addAmount: (amount: number) => void;
364
- }
365
- /**
366
- * Example: Complex State Cubit
367
- */
368
- interface TodoState {
369
- todos: Array<{
370
- id: string;
371
- text: string;
372
- done: boolean;
373
- }>;
374
- filter: 'all' | 'active' | 'completed';
375
- isLoading: boolean;
376
- }
377
- declare class TodoCubit extends Cubit<TodoState> {
378
- static keepAlive: boolean;
379
- private nextId;
380
- constructor();
381
- addTodo: (text: string) => void;
382
- toggleTodo: (id: string) => void;
383
- removeTodo: (id: string) => void;
384
- setFilter: (filter: TodoState["filter"]) => void;
385
- setLoading: (isLoading: boolean) => void;
386
- get visibleTodos(): {
387
- id: string;
388
- text: string;
389
- done: boolean;
390
- }[];
391
- get activeTodoCount(): number;
392
- }
393
- //#endregion
394
- //#region src/types/branded.d.ts
395
- /**
396
- * Branded types for type-safe IDs
397
- * These types ensure that IDs can't be accidentally mixed up
398
- */
399
- /**
400
- * Helper type for cases where any object type is acceptable
401
- * Used sparingly only where type cannot be more specific
402
- * eslint-disable-next-line @typescript-eslint/no-explicit-any
403
- */
404
- type AnyObject = any;
405
- /** Unique symbol for branding */
406
- declare const brand: unique symbol;
407
- /** Type branding utility */
408
- type Brand<T$1, B> = T$1 & {
409
- [brand]: B;
410
- };
411
- /** Generic branded ID type */
412
- type BrandedId<B> = Brand<string, B>;
413
- /** Branded instance ID type */
414
- type InstanceId = Brand<string, 'InstanceId'>;
415
- //#endregion
416
- //#region src/tracking/proxy-tracker.d.ts
417
- /**
418
- * Functional proxy tracker for automatic dependency tracking
419
- *
420
- * This module provides a functional approach to proxy-based dependency tracking.
421
- * Unlike the class-based ProxyTracker, this uses a state object pattern that's
422
- * easier to integrate with functional programming patterns and framework hooks.
423
- */
424
- /**
425
- * Check if a value can be proxied
426
- *
427
- * Returns true for plain objects and arrays only.
428
- * Excludes built-in objects like Date, Map, Set, etc.
429
- */
430
- declare function isProxyable(value: unknown): value is object;
431
- /**
432
- * State container for proxy tracking
433
- */
434
- interface ProxyTrackerState<T$1> {
435
- /** Set of all tracked property paths */
436
- trackedPaths: Set<string>;
437
- /** Whether tracking is currently active */
438
- isTracking: boolean;
439
- /** Cache of created proxies to avoid duplicates */
440
- proxyCache: WeakMap<object, any>;
441
- /** Cache of bound functions to maintain referential equality */
442
- boundFunctionsCache: WeakMap<Function, Function> | null;
443
- /** Last state object that was proxied (for cache invalidation) */
444
- lastProxiedState: T$1 | null;
445
- /** Last proxy created (for cache reuse) */
446
- lastProxy: T$1 | null;
447
- /** Maximum depth for nested proxy creation */
448
- maxDepth: number;
449
- }
450
- /**
451
- * Create a new proxy tracker state
452
- *
453
- * @example
454
- * const state = createProxyTrackerState<MyState>();
455
- * startProxyTracking(state);
456
- * const proxy = createProxyForTarget(state, myObject);
457
- * // ... use proxy ...
458
- * const paths = stopProxyTracking(state);
459
- */
460
- declare function createProxyTrackerState<T$1>(): ProxyTrackerState<T$1>;
461
- /**
462
- * Start tracking property accesses
463
- *
464
- * Clears previous tracked paths and enables tracking mode.
465
- */
466
- declare function startProxyTracking<T$1>(state: ProxyTrackerState<T$1>): void;
467
- /**
468
- * Stop tracking and return the tracked paths
469
- *
470
- * Returns a new Set containing all tracked paths.
471
- */
472
- declare function stopProxyTracking<T$1>(state: ProxyTrackerState<T$1>): Set<string>;
473
- /**
474
- * Create a proxy for an array with property access tracking
475
- *
476
- * Tracks:
477
- * - Array element access (arr[0])
478
- * - Length access (arr.length)
479
- * - Array method calls (arr.map, arr.filter, etc.)
480
- */
481
- declare function createArrayProxy<T$1, U>(state: ProxyTrackerState<T$1>, target: U[], path: string, depth?: number): U[];
482
- /**
483
- * Create a proxy for an object with property access tracking
484
- *
485
- * This is the core proxy creation function that recursively creates proxies
486
- * for nested objects and arrays.
487
- *
488
- * Tracks:
489
- * - Property access (obj.prop)
490
- * - Nested property access (obj.nested.prop)
491
- * - 'in' operator usage ('prop' in obj)
492
- * - Object.keys, Object.entries, etc.
493
- */
494
- declare function createProxyInternal<T$1>(state: ProxyTrackerState<T$1>, target: T$1, path?: string, depth?: number): T$1;
495
- /**
496
- * Create a proxy for a target with caching
497
- *
498
- * If the target hasn't changed since the last call, returns the cached proxy.
499
- * Otherwise, creates a new proxy and caches it.
500
- *
501
- * This is the main entry point for creating tracked proxies.
502
- */
503
- declare function createProxyForTarget<T$1>(state: ProxyTrackerState<T$1>, target: T$1): T$1;
504
- //#endregion
505
- //#region src/tracking/dependency-tracker.d.ts
506
- /**
507
- * Information about a tracked path
508
- */
509
- interface PathInfo {
510
- /** Parsed path segments */
511
- segments: string[];
512
- /** Last known value at this path */
513
- value: any;
514
- }
515
- /**
516
- * State for dependency tracking
517
- */
518
- interface TrackerState<T$1 extends AnyObject> {
519
- /** Internal proxy tracker state */
520
- proxyTrackerState: ProxyTrackerState<T$1>;
521
- /** Paths tracked in the previous render */
522
- previousRenderPaths: Set<string>;
523
- /** Paths tracked in the current render */
524
- currentRenderPaths: Set<string>;
525
- /** Cache of parsed paths and their values */
526
- pathCache: Map<string, PathInfo>;
527
- /** Last state object that was checked for changes */
528
- lastCheckedState: T$1 | null;
529
- /** Values from the last change check (optimization) */
530
- lastCheckedValues: Map<string, any>;
531
- /** Counter for periodic cleanup of unused paths */
532
- cleanupCounter: number;
533
- }
534
- /**
535
- * Create a new tracker state
536
- */
537
- declare function createTrackerState<T$1 extends AnyObject>(): TrackerState<T$1>;
538
- /**
539
- * Start tracking property accesses
540
- */
541
- declare function startTracking<T$1 extends AnyObject>(tracker: TrackerState<T$1>): void;
542
- /**
543
- * Create a proxy for the given state
544
- */
545
- declare function createProxy<T$1 extends AnyObject>(tracker: TrackerState<T$1>, state: T$1): T$1;
546
- /**
547
- * Capture the paths that were tracked during a render
548
- *
549
- * This should be called after each render to record which paths were accessed.
550
- * It also performs periodic cleanup of unused paths to prevent memory leaks.
551
- */
552
- declare function captureTrackedPaths<T$1 extends AnyObject>(tracker: TrackerState<T$1>, state: T$1): void;
553
- /**
554
- * Check if any tracked paths have changed
555
- *
556
- * This is called when state changes to determine if a re-render is needed.
557
- * Returns true if any tracked path has a different value than before.
558
- */
559
- declare function hasChanges<T$1 extends AnyObject>(tracker: TrackerState<T$1>, state: T$1): boolean;
560
- /**
561
- * Check if tracker has any tracked data
562
- *
563
- * Returns true if there are any tracked paths or cached paths.
564
- */
565
- declare function hasTrackedData<T$1 extends AnyObject>(tracker: TrackerState<T$1>): boolean;
566
- //#endregion
567
- //#region src/tracking/path-utils.d.ts
568
- /**
569
- * Path utilities for dependency tracking
570
- *
571
- * Provides utilities for parsing property paths and extracting values
572
- * from nested objects using path strings.
573
- */
574
- /**
575
- * Parse a property path string into an array of segments
576
- *
577
- * Handles both dot notation (a.b.c) and bracket notation (a[0].b)
578
- *
579
- * @example
580
- * parsePath('user.name') // ['user', 'name']
581
- * parsePath('items[0].name') // ['items', '0', 'name']
582
- * parsePath('data.users[2].address.city') // ['data', 'users', '2', 'address', 'city']
583
- */
584
- declare function parsePath(path: string): string[];
585
- /**
586
- * Get a value from an object using a path of segments
587
- *
588
- * @example
589
- * const obj = { user: { name: 'Alice', age: 30 } }
590
- * getValueAtPath(obj, ['user', 'name']) // 'Alice'
591
- * getValueAtPath(obj, ['user', 'age']) // 30
592
- * getValueAtPath(obj, ['user', 'missing']) // undefined
593
- */
594
- declare function getValueAtPath(obj: any, segments: string[]): any;
595
- /**
596
- * Shallow equality comparison for arrays
597
- *
598
- * Compares two arrays element-by-element using Object.is
599
- *
600
- * @example
601
- * shallowEqual([1, 2, 3], [1, 2, 3]) // true
602
- * shallowEqual([1, 2, 3], [1, 2, 4]) // false
603
- * shallowEqual([1, 2], [1, 2, 3]) // false
604
- */
605
- declare function shallowEqual(arr1: unknown[], arr2: unknown[]): boolean;
606
- //#endregion
607
- //#region src/proxy/ProxyTracker.d.ts
608
- /**
609
- * ProxyTracker - Automatic dependency tracking through Proxies
610
- *
611
- * Tracks property access on state objects to automatically determine
612
- * which parts of the state a component depends on.
613
- */
614
- /**
615
- * Tracks property access on state objects
616
- */
617
- declare class ProxyTracker<T$1> {
618
- private trackedPaths;
619
- private isTracking;
620
- private proxyCache;
621
- private maxDepth;
622
- /**
623
- * Create a proxy that tracks property access
624
- */
625
- createProxy(target: T$1, path?: string, depth?: number): T$1;
626
- /**
627
- * Create a proxy for arrays with special handling
628
- */
629
- private createArrayProxy;
630
- /**
631
- * Start tracking property access
632
- */
633
- startTracking(): void;
634
- /**
635
- * Stop tracking and return tracked paths
636
- */
637
- stopTracking(): Set<string>;
638
- /**
639
- * Get currently tracked paths
640
- */
641
- getTrackedPaths(): ReadonlySet<string>;
642
- /**
643
- * Check if currently tracking
644
- */
645
- isCurrentlyTracking(): boolean;
646
- /**
647
- * Clear proxy cache (useful for memory management)
648
- */
649
- clearCache(): void;
650
- /**
651
- * Set maximum tracking depth
652
- */
653
- setMaxDepth(depth: number): void;
654
- /**
655
- * Add a path manually (useful for forcing dependencies)
656
- */
657
- addPath(path: string): void;
658
- /**
659
- * Remove a path manually
660
- */
661
- removePath(path: string): void;
662
- /**
663
- * Clear all tracked paths
664
- */
665
- clearPaths(): void;
666
- }
667
- /**
668
- * Global proxy tracker instance for convenience
669
- */
670
- declare const globalProxyTracker: ProxyTracker<unknown>;
671
- /**
672
- * Utility function to track property access in a callback
673
- */
674
- declare function trackAccess<T$1, R>(state: T$1, callback: (proxiedState: T$1) => R): {
675
- result: R;
676
- trackedPaths: Set<string>;
677
- };
678
- //#endregion
679
- //#region src/types/utilities.d.ts
680
- /**
681
- * Extract state type from StateContainer
682
- *
683
- * @example
684
- * ```ts
685
- * class CounterBloc extends Cubit<number> { ... }
686
- * type State = ExtractState<CounterBloc>; // number
687
- * ```
688
- */
689
- type ExtractState<T$1> = T$1 extends StateContainer<infer S> ? S : never;
690
- /**
691
- * Extract constructor parameter types from a Bloc class
692
- *
693
- * @example
694
- * ```ts
695
- * class UserBloc extends Cubit<UserState> {
696
- * constructor(userId: string, config: Config) { ... }
697
- * }
698
- * type Args = ExtractConstructorArgs<typeof UserBloc>; // [string, Config]
699
- * ```
700
- */
701
- type ExtractConstructorArgs<T$1> = T$1 extends (new (...args: infer P) => AnyObject) ? P : never[];
702
- /**
703
- * Bloc constructor type - represents a class constructor for StateContainer subclasses
704
- * Includes static methods from StateContainer for instance management
705
- *
706
- * Note: Uses `any` for state type to support variance - the actual Bloc instance
707
- * will have the correct specific types inferred at usage sites.
708
- *
709
- * @example
710
- * ```ts
711
- * function createBloc<TBloc extends StateContainer<any>>(
712
- * BlocClass: BlocConstructor<TBloc>
713
- * ): TBloc {
714
- * return BlocClass.getOrCreate();
715
- * }
716
- * ```
717
- */
718
- type BlocConstructor<TBloc extends StateContainer<any>> = (new (...args: any[]) => TBloc) & {
719
- getOrCreate?(instanceKey?: string, ...args: any[]): TBloc;
720
- release?(instanceKey?: string): void;
721
- isolated?: boolean;
722
- keepAlive?: boolean;
723
- };
724
- //#endregion
725
- //#region src/logging/Logger.d.ts
726
- declare enum LogLevel {
727
- ERROR = 0,
728
- WARN = 1,
729
- INFO = 2,
730
- DEBUG = 3,
731
- }
732
- interface LogEntry {
733
- level: string;
734
- context: string;
735
- message: string;
736
- data?: any;
737
- timestamp: number;
738
- }
739
- interface LogConfig {
740
- enabled: boolean;
741
- level: LogLevel;
742
- output: (entry: LogEntry) => void;
743
- }
744
- /**
745
- * Creates a logger instance with given configuration
746
- *
747
- * @param config - Logger configuration
748
- * @returns Logger instance with debug, info, warn, error, and configure methods
749
- *
750
- * @example
751
- * ```ts
752
- * const logger = createLogger({
753
- * enabled: true,
754
- * level: LogLevel.DEBUG,
755
- * output: (entry) => console.log(JSON.stringify(entry))
756
- * });
757
- * logger.debug('MyComponent', 'Rendering', { props: { foo: 'bar' } });
758
- * ```
759
- */
760
- declare function createLogger(config: LogConfig): {
761
- debug: (context: string, message: string, data?: any) => void;
762
- info: (context: string, message: string, data?: any) => void;
763
- warn: (context: string, message: string, data?: any) => void;
764
- error: (context: string, message: string, data?: any) => void;
765
- configure: (opts: Partial<LogConfig>) => void;
766
- };
767
- declare const debug: (context: string, message: string, data?: any) => void;
768
- declare const info: (context: string, message: string, data?: any) => void;
769
- declare const warn: (context: string, message: string, data?: any) => void;
770
- declare const error: (context: string, message: string, data?: any) => void;
771
- /**
772
- * Configuration function that recreates the default logger
773
- *
774
- * @param opts - Partial logger configuration
775
- *
776
- * @example
777
- * ```ts
778
- * configureLogger({ enabled: true, level: LogLevel.DEBUG });
779
- * ```
780
- */
781
- declare function configureLogger(opts: Partial<LogConfig>): void;
782
- //#endregion
783
- //#region src/constants.d.ts
784
- /**
785
- * Default configuration constants for BlaC
786
- *
787
- * Centralized location for all magic numbers and default values.
788
- */
789
- /**
790
- * Default configuration constants for BlaC
791
- */
792
- declare const BLAC_DEFAULTS: {
793
- /**
794
- * Default cleanup interval for subscriptions (30 seconds)
795
- */
796
- readonly CLEANUP_INTERVAL_MS: 30000;
797
- /**
798
- * Cleanup interval for weak reference stage (10 seconds)
799
- */
800
- readonly WEAKREF_CLEANUP_INTERVAL_MS: 10000;
801
- /**
802
- * Default maximum subscriptions per container
803
- */
804
- readonly MAX_SUBSCRIPTIONS: 1000;
805
- /**
806
- * Maximum subscriptions for high-performance mode
807
- */
808
- readonly MAX_SUBSCRIPTIONS_HIGH_PERF: 10000;
809
- /**
810
- * Default timeout for pipeline execution (5 seconds)
811
- */
812
- readonly PIPELINE_TIMEOUT_MS: 5000;
813
- /**
814
- * Cleanup interval for high-performance mode (5 seconds)
815
- */
816
- readonly CLEANUP_INTERVAL_HIGH_PERF_MS: 5000;
817
- /**
818
- * Maximum number of stages in a pipeline
819
- */
820
- readonly MAX_PIPELINE_STAGES: 30;
821
- };
822
- //#endregion
823
- //#region src/utils/idGenerator.d.ts
824
- /**
825
- * Centralized ID Generation
826
- *
827
- * Provides consistent, collision-resistant ID generation for all BlaC subsystems.
828
- * Uses timestamp + counter + random suffix for uniqueness.
829
- */
830
- /**
831
- * Creates an ID generator with isolated counter state
832
- *
833
- * @param prefix - Prefix for generated IDs
834
- * @returns Object with next(), nextSimple(), and reset() methods
835
- *
836
- * @example
837
- * ```ts
838
- * const generator = createIdGenerator('sub');
839
- * const id1 = generator.next(); // "sub_1698765432100_1_a3k9d7f2q"
840
- * const id2 = generator.next(); // "sub_1698765432101_2_b4n8e9g3r"
841
- * ```
842
- */
843
- declare function createIdGenerator(prefix: string): {
844
- next: () => string;
845
- nextSimple: () => string;
846
- reset: () => void;
847
- };
848
- /**
849
- * Generate ID with timestamp, counter, and random suffix (tree-shakeable)
850
- *
851
- * Format: `${prefix}_${timestamp}_${counter}_${random}`
852
- *
853
- * @param prefix - Prefix for the ID (e.g., 'sub', 'consumer', 'stage')
854
- * @returns Branded ID string
855
- *
856
- * @example
857
- * ```ts
858
- * const id = generateId('sub');
859
- * // Returns: "sub_1698765432100_1_a3k9d7f2q"
860
- * ```
861
- */
862
- declare function generateId(prefix: string): string;
863
- /**
864
- * Generate simple ID with timestamp and random (no counter tracking)
865
- *
866
- * Format: `${prefix}_${timestamp}_${random}`
867
- *
868
- * @param prefix - Prefix for the ID
869
- * @returns Branded ID string
870
- *
871
- * @example
872
- * ```ts
873
- * const id = generateSimpleId('CounterBloc');
874
- * // Returns: "CounterBloc_1698765432100_a3k9d7f2q"
875
- * ```
876
- */
877
- declare function generateSimpleId(prefix: string): string;
878
- /**
879
- * Reset all counters for testing purposes
880
- * @internal
881
- */
882
- declare function __resetIdCounters(): void;
883
- //#endregion
884
- export { type AnyObject, AuthState, AuthVertex, BLAC_DEFAULTS, type BaseEvent, BlocConstructor, type Brand, type BrandedId, CounterCubit, CounterVertex, Cubit, DecrementEvent, EventConstructor, EventHandler, ExtractConstructorArgs, ExtractState, IncrementEvent, type InstanceId, type LifecycleEvent, type LifecycleListener, type LogConfig, type LogEntry, LogLevel, LoginEvent, LogoutEvent, PathInfo, ProxyTracker, ProxyTrackerState, ResetEvent, StateContainer, StateContainerConfig, StateContainerRegistry, TodoCubit, TodoState, TrackerState, Vertex, __resetIdCounters, captureTrackedPaths, configureLogger, createArrayProxy, createIdGenerator, createLogger, createProxy, createProxyForTarget, createProxyInternal, createProxyTrackerState, createTrackerState, debug, error, generateId, generateSimpleId, getValueAtPath, globalProxyTracker, globalRegistry, hasChanges, hasTrackedData, info, isProxyable, parsePath, shallowEqual, startProxyTracking, startTracking, stopProxyTracking, trackAccess, warn };
885
- //# sourceMappingURL=index.d.cts.map
1
+ export * from './core/StateContainer';
2
+ export * from './core/StateContainerRegistry';
3
+ export * from './core/Cubit';
4
+ export * from './core/Vertex';
5
+ export { globalRegistry, getPluginManager, } from './core/StateContainerRegistry';
6
+ export type { LifecycleEvent, LifecycleListener, } from './core/StateContainerRegistry';
7
+ export type { BlacPlugin, BlacPluginWithInit, PluginContext, PluginConfig, InstanceMetadata, } from './plugin/BlacPlugin';
8
+ export { PluginManager, createPluginManager } from './plugin/PluginManager';
9
+ export { hasInitHook } from './plugin/BlacPlugin';
10
+ export * from './tracking';
11
+ export * from './proxy/ProxyTracker';
12
+ export * from './adapter';
13
+ export type { Brand, BrandedId, InstanceId } from './types/branded';
14
+ export type { BaseEvent } from './types/events';
15
+ export * from './types/utilities';
16
+ export { createLogger, configureLogger, debug, info, warn, error, LogLevel, type LogConfig, type LogEntry, } from './logging/Logger';
17
+ export { BLAC_DEFAULTS, BLAC_STATIC_PROPS, BLAC_ID_PATTERNS, BLAC_ERROR_PREFIX, } from './constants';
18
+ export { generateId, generateSimpleId, createIdGenerator, __resetIdCounters, generateIsolatedKey, isIsolatedKey, } from './utils/idGenerator';
19
+ export { getStaticProp, isIsolatedClass, isKeepAliveClass, isExcludedFromDevTools, } from './utils/static-props';
20
+ //# sourceMappingURL=index.d.ts.map