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

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
package/dist/index.d.ts CHANGED
@@ -1,21 +1,1325 @@
1
- export * from './core/StateContainer';
2
- export type { SystemEvent, SystemEventPayloads } from './core/StateContainer';
3
- export * from './core/StateContainerRegistry';
4
- export * from './core/Cubit';
5
- export * from './core/Vertex';
6
- export { globalRegistry, getPluginManager, } from './core/StateContainerRegistry';
7
- export type { LifecycleEvent, LifecycleListener, } from './core/StateContainerRegistry';
8
- export type { BlacPlugin, BlacPluginWithInit, PluginContext, PluginConfig, InstanceMetadata, } from './plugin/BlacPlugin';
9
- export { PluginManager, createPluginManager } from './plugin/PluginManager';
10
- export { hasInitHook } from './plugin/BlacPlugin';
11
- export * from './tracking';
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
- export { blac, type BlacOptions } from './decorators';
21
- //# sourceMappingURL=index.d.ts.map
1
+ /* Excluded from this release type: __resetIdCounters */
2
+
3
+ /**
4
+ * Internal state for framework adapters, holding tracking and caching data.
5
+ * @template TBloc - The state container type
6
+ */
7
+ export declare interface AdapterState<TBloc extends StateContainer<any, any>> {
8
+ /** Proxy tracker for state property access tracking */
9
+ tracker: TrackerState<ExtractState<TBloc>> | null;
10
+ /** Cached manual dependencies for comparison */
11
+ manualDepsCache: unknown[] | null;
12
+ /** Getter tracker for computed property tracking */
13
+ getterTracker: GetterTrackerState | null;
14
+ /** Proxied bloc instance for auto-tracking */
15
+ proxiedBloc: TBloc | null;
16
+ }
17
+
18
+ /**
19
+ * Base event interface
20
+ * Used by Vertex for event-driven state management
21
+ */
22
+ export declare interface BaseEvent {
23
+ /** Event type identifier (typically the class name) */
24
+ readonly type: string;
25
+ /** Unix timestamp when the event was created */
26
+ readonly timestamp: number;
27
+ /** Optional source identifier for debugging */
28
+ readonly source?: string;
29
+ }
30
+
31
+ /**
32
+ * Decorator to configure StateContainer classes.
33
+ *
34
+ * @example Decorator syntax (requires experimentalDecorators or TC39 decorators)
35
+ * ```ts
36
+ * @blac({ isolated: true })
37
+ * class FormBloc extends Cubit<FormState> {}
38
+ *
39
+ * @blac({ keepAlive: true })
40
+ * class AuthBloc extends Cubit<AuthState> {}
41
+ *
42
+ * @blac({ excludeFromDevTools: true })
43
+ * class InternalBloc extends Cubit<InternalState> {}
44
+ * ```
45
+ *
46
+ * @example Function syntax (no decorator support needed)
47
+ * ```ts
48
+ * const FormBloc = blac({ isolated: true })(
49
+ * class extends Cubit<FormState> {}
50
+ * );
51
+ * ```
52
+ */
53
+ export declare function blac(options: BlacOptions): <T extends new (...args: any[]) => any>(target: T, _context?: ClassDecoratorContext) => T;
54
+
55
+ /**
56
+ * Default configuration constants for BlaC
57
+ */
58
+ export declare const BLAC_DEFAULTS: {
59
+ /**
60
+ * Default instance key for shared instances
61
+ */
62
+ readonly DEFAULT_INSTANCE_KEY: "default";
63
+ /**
64
+ * Maximum getter nesting depth (prevents infinite recursion)
65
+ */
66
+ readonly MAX_GETTER_DEPTH: 10;
67
+ /**
68
+ * Default cleanup interval for subscriptions (30 seconds)
69
+ */
70
+ readonly CLEANUP_INTERVAL_MS: 30000;
71
+ /**
72
+ * Cleanup interval for weak reference stage (10 seconds)
73
+ */
74
+ readonly WEAKREF_CLEANUP_INTERVAL_MS: 10000;
75
+ /**
76
+ * Default maximum subscriptions per container
77
+ */
78
+ readonly MAX_SUBSCRIPTIONS: 1000;
79
+ /**
80
+ * Maximum subscriptions for high-performance mode
81
+ */
82
+ readonly MAX_SUBSCRIPTIONS_HIGH_PERF: 10000;
83
+ /**
84
+ * Default timeout for pipeline execution (5 seconds)
85
+ */
86
+ readonly PIPELINE_TIMEOUT_MS: 5000;
87
+ /**
88
+ * Cleanup interval for high-performance mode (5 seconds)
89
+ */
90
+ readonly CLEANUP_INTERVAL_HIGH_PERF_MS: 5000;
91
+ /**
92
+ * Maximum number of stages in a pipeline
93
+ */
94
+ readonly MAX_PIPELINE_STAGES: 30;
95
+ };
96
+
97
+ /**
98
+ * Standard error message prefix
99
+ */
100
+ export declare const BLAC_ERROR_PREFIX: "[BlaC]";
101
+
102
+ /**
103
+ * ID generation patterns and constants
104
+ */
105
+ export declare const BLAC_ID_PATTERNS: {
106
+ /**
107
+ * Prefix for isolated instance keys
108
+ */
109
+ readonly ISOLATED_PREFIX: "isolated-";
110
+ /**
111
+ * Length of generated ID portion (9 characters from base36)
112
+ */
113
+ readonly ID_LENGTH: 9;
114
+ };
115
+
116
+ /**
117
+ * Static property names for StateContainer classes
118
+ * Used for feature flags and configuration on bloc classes
119
+ */
120
+ export declare const BLAC_STATIC_PROPS: {
121
+ /**
122
+ * Mark a bloc as isolated (each component gets its own instance)
123
+ */
124
+ readonly ISOLATED: "isolated";
125
+ /**
126
+ * Mark a bloc to never be auto-disposed (kept alive permanently)
127
+ */
128
+ readonly KEEP_ALIVE: "keepAlive";
129
+ /**
130
+ * Exclude a bloc from DevTools reporting (prevents infinite loops)
131
+ */
132
+ readonly EXCLUDE_FROM_DEVTOOLS: "__excludeFromDevTools";
133
+ };
134
+
135
+ /**
136
+ * Configuration options for the @blac decorator.
137
+ * Only one option can be specified at a time (union type).
138
+ */
139
+ export declare type BlacOptions =
140
+ /** Mark bloc as isolated (each component gets its own instance) */
141
+ {
142
+ isolated: true;
143
+ }
144
+ /** Mark bloc to never be auto-disposed when ref count reaches 0 */
145
+ | {
146
+ keepAlive: true;
147
+ }
148
+ /** Exclude bloc from DevTools tracking (prevents infinite loops) */
149
+ | {
150
+ excludeFromDevTools: true;
151
+ };
152
+
153
+ /**
154
+ * Interface for plugins that extend BlaC functionality
155
+ */
156
+ export declare interface BlacPlugin {
157
+ /** Unique plugin identifier */
158
+ readonly name: string;
159
+ /** Plugin version identifier */
160
+ readonly version: string;
161
+ /**
162
+ * Called when the plugin is installed (optional)
163
+ */
164
+ onInstall?(context: PluginContext): void;
165
+ /**
166
+ * Called when the plugin is uninstalled
167
+ */
168
+ onUninstall?(): void;
169
+ /**
170
+ * Called when a state container instance is created
171
+ */
172
+ onInstanceCreated?(instance: StateContainer<any>, context: PluginContext): void;
173
+ /**
174
+ * Called when state changes in a container instance
175
+ */
176
+ onStateChanged?<S>(instance: StateContainer<S>, previousState: S, currentState: S, callstack: string | undefined, context: PluginContext): void;
177
+ /**
178
+ * Called when an event is added to a Vertex instance
179
+ */
180
+ onEventAdded?<E extends BaseEvent>(vertex: Vertex<any, E>, event: E, context: PluginContext): void;
181
+ /**
182
+ * Called when a state container instance is disposed
183
+ */
184
+ onInstanceDisposed?(instance: StateContainer<any>, context: PluginContext): void;
185
+ }
186
+
187
+ /**
188
+ * Plugin interface variant that requires mandatory onInstall hook
189
+ */
190
+ export declare interface BlacPluginWithInit extends BlacPlugin {
191
+ /**
192
+ * Required initialization hook called when plugin is installed
193
+ */
194
+ onInstall(context: PluginContext): void;
195
+ }
196
+
197
+ /**
198
+ * Constructor type for StateContainer classes with static registry methods.
199
+ * Used for type-safe hook parameters.
200
+ * @template TBloc - The StateContainer instance type
201
+ */
202
+ export declare type BlocConstructor<TBloc extends StateContainer<any, any>> = (new (...args: any[]) => TBloc) & {
203
+ resolve<S = never>(instanceKey?: string, ...args: any[]): StateOverride<TBloc, S>;
204
+ get<S = never>(instanceKey?: string): StateOverride<TBloc, S>;
205
+ getSafe<S = never>(instanceKey?: string): {
206
+ error: Error;
207
+ instance: null;
208
+ } | {
209
+ error: null;
210
+ instance: StateOverride<TBloc, S>;
211
+ };
212
+ release(instanceKey?: string): void;
213
+ isolated?: boolean;
214
+ keepAlive?: boolean;
215
+ };
216
+
217
+ /**
218
+ * Utility type for creating branded/nominal types.
219
+ * Prevents accidental type confusion between similar primitive types.
220
+ * @template T - The base type
221
+ * @template B - The brand identifier
222
+ */
223
+ export declare type Brand<T, B> = T & {
224
+ [brand]: B;
225
+ };
226
+
227
+ declare const brand: unique symbol;
228
+
229
+ /**
230
+ * Branded string type for type-safe IDs.
231
+ * @template B - The brand identifier
232
+ */
233
+ export declare type BrandedId<B> = Brand<string, B>;
234
+
235
+ /* Excluded from this release type: captureTrackedPaths */
236
+
237
+ /* Excluded from this release type: clearActiveTracker */
238
+
239
+ /* Excluded from this release type: clearExternalDependencies */
240
+
241
+ /* Excluded from this release type: commitTrackedGetters */
242
+
243
+ /**
244
+ * Configuration function that recreates the default logger
245
+ *
246
+ * @param opts - Partial logger configuration
247
+ *
248
+ * @example
249
+ * ```ts
250
+ * configureLogger({ enabled: true, level: LogLevel.DEBUG });
251
+ * ```
252
+ */
253
+ export declare function configureLogger(opts: Partial<LogConfig>): void;
254
+
255
+ /* Excluded from this release type: createArrayProxy */
256
+
257
+ /**
258
+ * Create a snapshot function for auto-tracking mode.
259
+ * Returns a proxied state that tracks property access.
260
+ * @param instance - The state container instance
261
+ * @param adapterState - The adapter state for tracking
262
+ * @returns Snapshot function for use with useSyncExternalStore
263
+ */
264
+ export declare function createAutoTrackSnapshot<TBloc extends StateContainer<any, any>>(instance: TBloc, adapterState: AdapterState<TBloc>): SnapshotFunction<ExtractState<TBloc>>;
265
+
266
+ /**
267
+ * Create a subscribe function for auto-tracking mode.
268
+ * Only triggers callback when tracked properties change.
269
+ * @param instance - The state container instance
270
+ * @param adapterState - The adapter state for tracking
271
+ * @returns Subscribe function for use with useSyncExternalStore
272
+ */
273
+ export declare function createAutoTrackSubscribe<TBloc extends StateContainer<any, any>>(instance: TBloc, adapterState: AdapterState<TBloc>): SubscribeFunction;
274
+
275
+ /* Excluded from this release type: createBlocProxy */
276
+
277
+ /* Excluded from this release type: createGetterTracker */
278
+
279
+ /**
280
+ * Centralized ID Generation
281
+ *
282
+ * Provides consistent, collision-resistant ID generation for all BlaC subsystems.
283
+ * Uses timestamp + counter + random suffix for uniqueness.
284
+ */
285
+ /**
286
+ * Creates an ID generator with isolated counter state
287
+ *
288
+ * @param prefix - Prefix for generated IDs
289
+ * @returns Object with next(), nextSimple(), and reset() methods
290
+ *
291
+ * @example
292
+ * ```ts
293
+ * const generator = createIdGenerator('sub');
294
+ * const id1 = generator.next(); // "sub:1698765432100_1_a3k9d7f2q"
295
+ * const id2 = generator.next(); // "sub:1698765432101_2_b4n8e9g3r"
296
+ * ```
297
+ */
298
+ export declare function createIdGenerator(prefix: string): {
299
+ next: () => string;
300
+ nextSimple: () => string;
301
+ reset: () => void;
302
+ };
303
+
304
+ /**
305
+ * Creates a logger instance with given configuration
306
+ *
307
+ * @param config - Logger configuration
308
+ * @returns Logger instance with debug, info, warn, error, and configure methods
309
+ *
310
+ * @example
311
+ * ```ts
312
+ * const logger = createLogger({
313
+ * enabled: true,
314
+ * level: LogLevel.DEBUG,
315
+ * output: (entry) => console.log(JSON.stringify(entry))
316
+ * });
317
+ * logger.debug('MyComponent', 'Rendering', { props: { foo: 'bar' } });
318
+ * ```
319
+ */
320
+ export declare function createLogger(config: LogConfig): {
321
+ debug: (context: string, message: string, data?: any) => void;
322
+ info: (context: string, message: string, data?: any) => void;
323
+ warn: (context: string, message: string, data?: any) => void;
324
+ error: (context: string, message: string, data?: any) => void;
325
+ configure: (opts: Partial<LogConfig>) => void;
326
+ };
327
+
328
+ /**
329
+ * Create a snapshot function for manual dependency tracking mode.
330
+ * Caches dependencies for comparison on next render.
331
+ * @param instance - The state container instance
332
+ * @param adapterState - The adapter state for caching
333
+ * @param config - Configuration with dependencies function
334
+ * @returns Snapshot function for use with useSyncExternalStore
335
+ */
336
+ export declare function createManualDepsSnapshot<TBloc extends StateContainer<any, any>>(instance: TBloc, adapterState: AdapterState<TBloc>, config: ManualDepsConfig<TBloc>): SnapshotFunction<ExtractState<TBloc>>;
337
+
338
+ /**
339
+ * Create a subscribe function for manual dependency tracking mode.
340
+ * Only triggers callback when dependencies array changes.
341
+ * @param instance - The state container instance
342
+ * @param adapterState - The adapter state for caching
343
+ * @param config - Configuration with dependencies function
344
+ * @returns Subscribe function for use with useSyncExternalStore
345
+ */
346
+ export declare function createManualDepsSubscribe<TBloc extends StateContainer<any, any>>(instance: TBloc, adapterState: AdapterState<TBloc>, config: ManualDepsConfig<TBloc>): SubscribeFunction;
347
+
348
+ /**
349
+ * Create a snapshot function for no-tracking mode.
350
+ * Returns the raw state directly.
351
+ * @param instance - The state container instance
352
+ * @returns Snapshot function for use with useSyncExternalStore
353
+ */
354
+ export declare function createNoTrackSnapshot<TBloc extends StateContainer<any, any>>(instance: TBloc): SnapshotFunction<ExtractState<TBloc>>;
355
+
356
+ /**
357
+ * Create a subscribe function for no-tracking mode.
358
+ * Triggers callback on every state change.
359
+ * @param instance - The state container instance
360
+ * @returns Subscribe function for use with useSyncExternalStore
361
+ */
362
+ export declare function createNoTrackSubscribe<TBloc extends StateContainer<any, any>>(instance: TBloc): SubscribeFunction;
363
+
364
+ /**
365
+ * Create a plugin manager instance
366
+ */
367
+ export declare function createPluginManager(registry: StateContainerRegistry): PluginManager;
368
+
369
+ /* Excluded from this release type: createProxy */
370
+
371
+ /* Excluded from this release type: createProxyForTarget */
372
+
373
+ /* Excluded from this release type: createProxyInternal */
374
+
375
+ /* Excluded from this release type: createProxyTrackerState */
376
+
377
+ /* Excluded from this release type: createTrackerState */
378
+
379
+ /**
380
+ * Simple state container with direct state emission.
381
+ * Extends StateContainer with public methods for emitting and updating state.
382
+ *
383
+ * @template S - State type
384
+ * @template P - Props type (optional)
385
+ */
386
+ export declare abstract class Cubit<S, P = undefined> extends StateContainer<S, P> {
387
+ constructor(initialState: S);
388
+ /**
389
+ * Replace state with a new value and notify all listeners
390
+ * @param newState - The new state value
391
+ */
392
+ emit(newState: S): void;
393
+ /**
394
+ * Transform current state using an updater function and emit the new state
395
+ * @param updater - Function that receives current state and returns new state
396
+ */
397
+ update(updater: (current: S) => S): void;
398
+ /**
399
+ * Merge partial state changes into current state (only for object states)
400
+ */
401
+ patch: S extends object ? (partial: Partial<S>) => void : never;
402
+ }
403
+
404
+ /**
405
+ * Log a debug message (tree-shakeable export)
406
+ * @param context - Context identifier (module or component name)
407
+ * @param message - Log message
408
+ * @param data - Optional structured data
409
+ */
410
+ export declare const debug: (context: string, message: string, data?: any) => void;
411
+
412
+ /**
413
+ * Disable getter tracking after render phase completes.
414
+ * Clears the active tracker to prevent tracking outside of render.
415
+ * @param adapterState - The adapter state
416
+ * @param rawInstance - The raw bloc instance
417
+ */
418
+ export declare function disableGetterTracking<TBloc extends StateContainer<any, any>>(adapterState: AdapterState<TBloc>, rawInstance: TBloc): void;
419
+
420
+ /**
421
+ * Log an error message (tree-shakeable export)
422
+ * @param context - Context identifier (module or component name)
423
+ * @param message - Log message
424
+ * @param data - Optional structured data
425
+ */
426
+ export declare const error: (context: string, message: string, data?: any) => void;
427
+
428
+ /**
429
+ * Constructor type for event classes
430
+ * @template T - Event type
431
+ */
432
+ export declare type EventConstructor<T extends BaseEvent = BaseEvent> = new (...args: never[]) => T;
433
+
434
+ /**
435
+ * Handler function for processing events in Vertex
436
+ * @template E - Event type
437
+ * @template S - State type
438
+ * @param event - The event being handled
439
+ * @param emit - Function to emit new state
440
+ */
441
+ export declare type EventHandler<E extends BaseEvent, S> = (event: E, emit: (state: S) => void) => void;
442
+
443
+ /**
444
+ * Manages subscriptions to external bloc dependencies for getter tracking.
445
+ * When a getter accesses another bloc's state, this manager ensures
446
+ * re-renders occur when those external dependencies change.
447
+ */
448
+ export declare class ExternalDependencyManager {
449
+ private subscriptions;
450
+ private previousDeps;
451
+ private areDependenciesEqual;
452
+ /**
453
+ * Update subscriptions to external bloc dependencies.
454
+ * Creates subscriptions to blocs accessed via getters.
455
+ * @param getterTracker - The getter tracker state with external dependencies
456
+ * @param rawInstance - The primary bloc instance (excluded from subscriptions)
457
+ * @param onGetterChange - Callback to invoke when external dependency changes
458
+ * @returns true if subscriptions were updated, false if unchanged
459
+ */
460
+ updateSubscriptions(getterTracker: GetterTrackerState | null, rawInstance: StateContainer<any, any>, onGetterChange: () => void): boolean;
461
+ /**
462
+ * Clean up all active subscriptions
463
+ */
464
+ cleanup(): void;
465
+ }
466
+
467
+ /**
468
+ * Extract constructor argument types from a class
469
+ * @template T - The class type
470
+ */
471
+ export declare type ExtractConstructorArgs<T> = T extends new (...args: infer P) => any ? P : never[];
472
+
473
+ /**
474
+ * Extract the props type from a StateContainer
475
+ * @template T - The StateContainer type
476
+ */
477
+ export declare type ExtractProps<T> = T extends StateContainer<any, infer P> ? P : undefined;
478
+
479
+ /**
480
+ * Extract the state type from a StateContainer
481
+ * @template T - The StateContainer type
482
+ */
483
+ export declare type ExtractState<T> = T extends StateContainer<infer S, any> ? S : never;
484
+
485
+ /**
486
+ * Generate ID with timestamp, counter, and random suffix (tree-shakeable)
487
+ *
488
+ * Format: `${prefix}:${timestamp}_${counter}_${random}`
489
+ *
490
+ * @param prefix - Prefix for the ID (e.g., 'sub', 'consumer', 'stage')
491
+ * @returns Branded ID string
492
+ *
493
+ * @example
494
+ * const id = generateId('sub');
495
+ * // Returns: "sub:1698765432100_1_a3k9d7f2q"
496
+ */
497
+ export declare function generateId(prefix: string): string;
498
+
499
+ /**
500
+ * Generate a unique isolated instance key
501
+ * Uses base36 encoding for compact, URL-safe identifiers
502
+ *
503
+ * Format: "isolated-{9-char-random-string}"
504
+ * Example: "isolated-k7x2m9p4q"
505
+ *
506
+ * @returns A unique isolated instance key
507
+ */
508
+ export declare function generateIsolatedKey(): string;
509
+
510
+ /**
511
+ * Generate simple ID with timestamp and random (no counter tracking)
512
+ *
513
+ * Format: `${prefix}:${timestamp}_${random}`
514
+ *
515
+ * @param prefix - Prefix for the ID
516
+ * @returns Branded ID string
517
+ *
518
+ * @example
519
+ * ```ts
520
+ * const id = generateSimpleId('CounterBloc');
521
+ * // Returns: "CounterBloc:1698765432100_a3k9d7f2q"
522
+ * ```
523
+ */
524
+ export declare function generateSimpleId(prefix: string, affix?: string): string;
525
+
526
+ /* Excluded from this release type: getActiveTracker */
527
+
528
+ /* Excluded from this release type: getDescriptor */
529
+
530
+ /* Excluded from this release type: getGetterExecutionContext */
531
+
532
+ /**
533
+ * Get the global plugin manager
534
+ */
535
+ export declare function getPluginManager(): any;
536
+
537
+ /**
538
+ * Utility functions for accessing static properties on StateContainer classes
539
+ */
540
+ /**
541
+ * Get a static property from a class constructor
542
+ * Type-safe helper that avoids (Type as any) casts
543
+ *
544
+ * @param Type - The class constructor
545
+ * @param propName - The property name to access
546
+ * @param defaultValue - Optional default value if property is undefined
547
+ * @returns The property value or default
548
+ */
549
+ export declare function getStaticProp<T>(Type: new (...args: any[]) => any, propName: string, defaultValue?: T): T | undefined;
550
+
551
+ declare interface GetterExecutionContext {
552
+ tracker: GetterTrackerState | null;
553
+ currentBloc: StateContainer<any> | null;
554
+ depth: number;
555
+ visitedBlocs: Set<StateContainer<any>>;
556
+ }
557
+
558
+ /* Excluded from this release type: GetterTrackerState */
559
+
560
+ /* Excluded from this release type: getValueAtPath */
561
+
562
+ /**
563
+ * Global default registry instance
564
+ */
565
+ export declare const globalRegistry: StateContainerRegistry;
566
+
567
+ /* Excluded from this release type: hasChanges */
568
+
569
+ /* Excluded from this release type: hasGetterChanges */
570
+
571
+ /**
572
+ * Type guard to check if a plugin has a required onInstall hook
573
+ * @param plugin - The plugin to check
574
+ * @returns true if the plugin implements BlacPluginWithInit
575
+ */
576
+ export declare function hasInitHook(plugin: BlacPlugin): plugin is BlacPluginWithInit;
577
+
578
+ /* Excluded from this release type: hasTrackedData */
579
+
580
+ /**
581
+ * Log an info message (tree-shakeable export)
582
+ * @param context - Context identifier (module or component name)
583
+ * @param message - Log message
584
+ * @param data - Optional structured data
585
+ */
586
+ export declare const info: (context: string, message: string, data?: any) => void;
587
+
588
+ /**
589
+ * Initialize adapter state for auto-tracking mode.
590
+ * Creates getter tracker and proxied bloc instance.
591
+ * @param instance - The state container instance
592
+ * @returns Initialized adapter state
593
+ */
594
+ export declare function initAutoTrackState<TBloc extends StateContainer<any, any>>(instance: TBloc): AdapterState<TBloc>;
595
+
596
+ /**
597
+ * Initialize adapter state for manual dependency tracking mode.
598
+ * No proxy is created; bloc is used directly.
599
+ * @param instance - The state container instance
600
+ * @returns Initialized adapter state
601
+ */
602
+ export declare function initManualDepsState<TBloc extends StateContainer<any, any>>(instance: TBloc): AdapterState<TBloc>;
603
+
604
+ /**
605
+ * Initialize adapter state for no-tracking mode.
606
+ * No tracking or proxy is created.
607
+ * @param instance - The state container instance
608
+ * @returns Initialized adapter state
609
+ */
610
+ export declare function initNoTrackState<TBloc extends StateContainer<any, any>>(instance: TBloc): AdapterState<TBloc>;
611
+
612
+ /**
613
+ * Entry in the instance registry, tracking the instance and its reference count
614
+ * @template T - Instance type
615
+ */
616
+ export declare interface InstanceEntry<T = any> {
617
+ /** The state container instance */
618
+ instance: T;
619
+ /** Number of active references to this instance */
620
+ refCount: number;
621
+ }
622
+
623
+ /**
624
+ * Branded string type for state container instance IDs
625
+ */
626
+ export declare type InstanceId = Brand<string, 'InstanceId'>;
627
+
628
+ /**
629
+ * Metadata information about a state container instance for debugging and inspection
630
+ */
631
+ export declare interface InstanceMetadata {
632
+ /** Unique instance identifier */
633
+ id: string;
634
+ /** Name of the state container class */
635
+ className: string;
636
+ /** Whether the instance has been disposed */
637
+ isDisposed: boolean;
638
+ /** Display name for the instance */
639
+ name: string;
640
+ /** When state last changed (milliseconds) */
641
+ lastStateChangeTimestamp: number;
642
+ /** Current state value */
643
+ state: any;
644
+ /** Timestamp when instance was created (milliseconds) */
645
+ createdAt: number;
646
+ /** Whether this is an isolated (component-scoped) instance */
647
+ isIsolated: boolean;
648
+ /** Stack trace from when instance was created (for debugging) */
649
+ callstack?: string;
650
+ /** Previous state value */
651
+ previousState?: any;
652
+ /** Current state value */
653
+ currentState?: any;
654
+ }
655
+
656
+ /* Excluded from this release type: invalidateRenderCache */
657
+
658
+ /**
659
+ * Check if a class should be excluded from DevTools
660
+ * Used to prevent infinite loops when DevTools tracks itself
661
+ */
662
+ export declare function isExcludedFromDevTools(Type: new (...args: any[]) => any): boolean;
663
+
664
+ /* Excluded from this release type: isGetter */
665
+
666
+ /**
667
+ * Check if a class is marked as isolated
668
+ * Isolated classes create separate instances per component
669
+ */
670
+ export declare function isIsolatedClass(Type: new (...args: any[]) => any): boolean;
671
+
672
+ /**
673
+ * Check if a key is an isolated instance key
674
+ * @param key - The instance key to check
675
+ * @returns true if the key is an isolated instance key
676
+ */
677
+ export declare function isIsolatedKey(key: string): boolean;
678
+
679
+ /**
680
+ * Check if a class is marked as keepAlive
681
+ * KeepAlive classes are never auto-disposed when ref count reaches 0
682
+ */
683
+ export declare function isKeepAliveClass(Type: new (...args: any[]) => any): boolean;
684
+
685
+ /* Excluded from this release type: isProxyable */
686
+
687
+ /**
688
+ * Lifecycle events emitted by the registry
689
+ */
690
+ export declare type LifecycleEvent = 'created' | 'stateChanged' | 'eventAdded' | 'disposed';
691
+
692
+ /**
693
+ * Listener function type for each lifecycle event
694
+ * @template E - The lifecycle event type
695
+ */
696
+ export declare type LifecycleListener<E extends LifecycleEvent> = E extends 'created' ? (container: StateContainer<any>) => void : E extends 'stateChanged' ? (container: StateContainer<any>, previousState: any, currentState: any, callstack?: string) => void : E extends 'eventAdded' ? (container: Vertex<any, any>, event: any) => void : E extends 'disposed' ? (container: StateContainer<any>) => void : never;
697
+
698
+ /**
699
+ * Configuration for the logger
700
+ */
701
+ export declare interface LogConfig {
702
+ /** Whether logging is enabled */
703
+ enabled: boolean;
704
+ /** Minimum log level to output */
705
+ level: LogLevel;
706
+ /** Function called to output log entries */
707
+ output: (entry: LogEntry) => void;
708
+ }
709
+
710
+ /**
711
+ * Structure of a log entry passed to output handlers
712
+ */
713
+ export declare interface LogEntry {
714
+ /** Log level as string (DEBUG, INFO, WARN, ERROR) */
715
+ level: string;
716
+ /** Context identifier (typically component or module name) */
717
+ context: string;
718
+ /** Log message */
719
+ message: string;
720
+ /** Optional structured data */
721
+ data?: any;
722
+ /** Unix timestamp in milliseconds */
723
+ timestamp: number;
724
+ }
725
+
726
+ /**
727
+ * Log severity levels (lower number = higher severity)
728
+ */
729
+ export declare enum LogLevel {
730
+ /** Critical errors that may cause application failure */
731
+ ERROR = 0,
732
+ /** Warning conditions that should be addressed */
733
+ WARN = 1,
734
+ /** Informational messages about application state */
735
+ INFO = 2,
736
+ /** Detailed debugging information */
737
+ DEBUG = 3
738
+ }
739
+
740
+ /**
741
+ * Configuration for manual dependency tracking mode
742
+ * @template TBloc - The state container type
743
+ */
744
+ export declare interface ManualDepsConfig<TBloc extends StateContainer<any, any>> {
745
+ /** Function that returns dependency array from state and bloc */
746
+ dependencies: (state: any, bloc: TBloc) => unknown[];
747
+ }
748
+
749
+ /* Excluded from this release type: parsePath */
750
+
751
+ /* Excluded from this release type: PathInfo */
752
+
753
+ /**
754
+ * Configuration options for plugin installation
755
+ */
756
+ export declare interface PluginConfig {
757
+ /** Enable or disable the plugin */
758
+ enabled?: boolean;
759
+ /** Environments where plugin runs */
760
+ environment?: 'development' | 'production' | 'test' | 'all';
761
+ }
762
+
763
+ /**
764
+ * Safe context API provided to plugins for accessing registry data
765
+ */
766
+ export declare interface PluginContext {
767
+ /**
768
+ * Get metadata for a specific instance
769
+ */
770
+ getInstanceMetadata(instance: StateContainer<any>): InstanceMetadata;
771
+ /**
772
+ * Get current state from a container
773
+ */
774
+ getState<S>(instance: StateContainer<S>): S;
775
+ /**
776
+ * Get all instances of a specific type
777
+ */
778
+ queryInstances<T extends StateContainer<any>>(typeClass: new (...args: any[]) => T): T[];
779
+ /**
780
+ * Get all registered state container types
781
+ */
782
+ getAllTypes(): Array<new (...args: any[]) => StateContainer<any>>;
783
+ /**
784
+ * Get registry statistics
785
+ */
786
+ getStats(): {
787
+ registeredTypes: number;
788
+ totalInstances: number;
789
+ typeBreakdown: Record<string, number>;
790
+ };
791
+ }
792
+
793
+ /**
794
+ * Manages plugin lifecycle for the BlaC state management system.
795
+ * Plugins receive notifications about state container lifecycle events.
796
+ *
797
+ * @example
798
+ * ```ts
799
+ * const manager = createPluginManager(registry);
800
+ * manager.install(myPlugin, { environment: 'development' });
801
+ * ```
802
+ */
803
+ export declare class PluginManager {
804
+ private plugins;
805
+ private registry;
806
+ /**
807
+ * Create a new PluginManager
808
+ * @param registry - The StateContainerRegistry to monitor for lifecycle events
809
+ */
810
+ constructor(registry: StateContainerRegistry);
811
+ /**
812
+ * Install a plugin with optional configuration
813
+ * @param plugin - The plugin to install
814
+ * @param config - Optional plugin configuration
815
+ * @throws Error if plugin is already installed
816
+ */
817
+ install(plugin: BlacPlugin, config?: PluginConfig): void;
818
+ /**
819
+ * Uninstall a plugin by name
820
+ * @param pluginName - The name of the plugin to uninstall
821
+ * @throws Error if plugin is not installed
822
+ */
823
+ uninstall(pluginName: string): void;
824
+ /**
825
+ * Get an installed plugin by name
826
+ * @param pluginName - The name of the plugin to retrieve
827
+ * @returns The plugin instance or undefined if not found
828
+ */
829
+ getPlugin(pluginName: string): BlacPlugin | undefined;
830
+ /**
831
+ * Get all installed plugins
832
+ * @returns Array of all installed plugins
833
+ */
834
+ getAllPlugins(): BlacPlugin[];
835
+ /**
836
+ * Check if a plugin is installed
837
+ * @param pluginName - The name of the plugin to check
838
+ * @returns true if the plugin is installed
839
+ */
840
+ hasPlugin(pluginName: string): boolean;
841
+ /**
842
+ * Uninstall all plugins
843
+ */
844
+ clear(): void;
845
+ /**
846
+ * Setup lifecycle hooks to notify plugins
847
+ */
848
+ private setupLifecycleHooks;
849
+ /**
850
+ * Notify all plugins of a lifecycle event
851
+ */
852
+ private notifyPlugins;
853
+ /**
854
+ * Create plugin context with safe API access
855
+ */
856
+ private createPluginContext;
857
+ /**
858
+ * Check if plugin should be enabled based on environment
859
+ */
860
+ private shouldEnablePlugin;
861
+ /**
862
+ * Get current environment
863
+ */
864
+ private getCurrentEnvironment;
865
+ }
866
+
867
+ /* Excluded from this release type: ProxyTrackerState */
868
+
869
+ /* Excluded from this release type: resetGetterTracker */
870
+
871
+ /* Excluded from this release type: setActiveTracker */
872
+
873
+ /* Excluded from this release type: shallowEqual */
874
+
875
+ /**
876
+ * Function that returns a snapshot of the current state
877
+ * @template TState - The state type
878
+ */
879
+ export declare type SnapshotFunction<TState> = () => TState;
880
+
881
+ /* Excluded from this release type: startProxyTracking */
882
+
883
+ /* Excluded from this release type: startTracking */
884
+
885
+ /**
886
+ * Abstract base class for all state containers in BlaC.
887
+ * Provides lifecycle management, subscription handling, ref counting,
888
+ * and integration with the global registry.
889
+ *
890
+ * @template S - State type managed by this container
891
+ * @template P - Props type passed to the container (optional)
892
+ *
893
+ * @example
894
+ * ```ts
895
+ * class CounterBloc extends StateContainer<number> {
896
+ * constructor() {
897
+ * super(0);
898
+ * }
899
+ * increment() {
900
+ * this.emit(this.state + 1);
901
+ * }
902
+ * }
903
+ * ```
904
+ */
905
+ export declare abstract class StateContainer<S, P = undefined> {
906
+ /* Excluded from this release type: __excludeFromDevTools */
907
+ /* Excluded from this release type: _registry */
908
+ /**
909
+ * Get the global StateContainerRegistry
910
+ * @returns The registry managing all state container instances
911
+ */
912
+ static getRegistry(): StateContainerRegistry;
913
+ /**
914
+ * Replace the global registry (clears existing instances)
915
+ * @param registry - The new registry to use
916
+ */
917
+ static setRegistry(registry: StateContainerRegistry): void;
918
+ /**
919
+ * Register this class with the global registry
920
+ * @param isolated - Whether instances should be isolated (component-scoped)
921
+ */
922
+ static register<T extends StateContainer<any>>(this: new (...args: any[]) => T, isolated?: boolean): void;
923
+ /**
924
+ * Resolve an instance with ref counting (ownership semantics).
925
+ * Creates a new instance if one doesn't exist, or returns existing and increments ref count.
926
+ * @template S - Optional state type override for generic StateContainers
927
+ * @template T - The StateContainer type (inferred from class)
928
+ * @param instanceKey - Optional instance key (defaults to 'default')
929
+ * @param constructorArgs - Arguments to pass to constructor if creating new instance
930
+ * @returns The state container instance
931
+ */
932
+ static resolve<S = never, T extends StateContainer<any> = StateContainer<any>>(this: new (...args: any[]) => T, instanceKey?: string, constructorArgs?: any): StateOverride<T, S>;
933
+ /**
934
+ * Get an existing instance without incrementing ref count (borrowing semantics).
935
+ * @template S - Optional state type override for generic StateContainers
936
+ * @template T - The StateContainer type (inferred from class)
937
+ * @param instanceKey - Optional instance key (defaults to 'default')
938
+ * @returns The state container instance
939
+ * @throws Error if instance doesn't exist
940
+ */
941
+ static get<S = never, T extends StateContainer<any> = StateContainer<any>>(this: new (...args: any[]) => T, instanceKey?: string): StateOverride<T, S>;
942
+ /**
943
+ * Safely get an existing instance with error handling.
944
+ * @template S - Optional state type override for generic StateContainers
945
+ * @template T - The StateContainer type (inferred from class)
946
+ * @param instanceKey - Optional instance key (defaults to 'default')
947
+ * @returns Discriminated union with either the instance or an error
948
+ */
949
+ static getSafe<S = never, T extends StateContainer<any> = StateContainer<any>>(this: new (...args: any[]) => T, instanceKey?: string): {
950
+ error: Error;
951
+ instance: null;
952
+ } | {
953
+ error: null;
954
+ instance: StateOverride<T, S>;
955
+ };
956
+ /**
957
+ * Connect to an instance for bloc-to-bloc communication (borrowing semantics).
958
+ * Gets or creates instance without incrementing ref count.
959
+ * @template S - Optional state type override for generic StateContainers
960
+ * @template T - The StateContainer type (inferred from class)
961
+ * @param instanceKey - Optional instance key (defaults to 'default')
962
+ * @param constructorArgs - Arguments to pass to constructor if creating new instance
963
+ * @returns The state container instance
964
+ */
965
+ static connect<S = never, T extends StateContainer<any> = StateContainer<any>>(this: new (...args: any[]) => T, instanceKey?: string, constructorArgs?: any): StateOverride<T, S>;
966
+ /**
967
+ * Release a reference to an instance.
968
+ * Decrements ref count and disposes when it reaches 0 (unless keepAlive).
969
+ * @param instanceKey - Optional instance key (defaults to 'default')
970
+ * @param forceDispose - Force immediate disposal regardless of ref count
971
+ */
972
+ static release<T extends StateContainer<any> = StateContainer<any>>(this: new (...args: any[]) => T, instanceKey?: string, forceDispose?: boolean): void;
973
+ /**
974
+ * Get all instances of this class
975
+ * @returns Array of all instances
976
+ */
977
+ static getAll<T extends StateContainer<any> = StateContainer<any>>(this: new (...args: any[]) => T): T[];
978
+ /**
979
+ * Iterate over all instances of this class
980
+ * @param callback - Function to call for each instance
981
+ */
982
+ static forEach<T extends StateContainer<any> = StateContainer<any>>(this: new (...args: any[]) => T, callback: (instance: T) => void): void;
983
+ /**
984
+ * Clear all instances of this class (disposes them)
985
+ */
986
+ static clear<T extends StateContainer<any> = StateContainer<any>>(this: new (...args: any[]) => T): void;
987
+ /**
988
+ * Clear all instances from all registered types
989
+ */
990
+ static clearAllInstances(): void;
991
+ /**
992
+ * Get registry statistics for debugging
993
+ * @returns Object with registeredTypes, totalInstances, and typeBreakdown
994
+ */
995
+ static getStats(): {
996
+ registeredTypes: number;
997
+ totalInstances: number;
998
+ typeBreakdown: Record<string, number>;
999
+ };
1000
+ /**
1001
+ * Get reference count for an instance
1002
+ * @param instanceKey - Optional instance key (defaults to 'default')
1003
+ * @returns Current ref count (0 if instance doesn't exist)
1004
+ */
1005
+ static getRefCount<T extends StateContainer<any> = StateContainer<any>>(this: new (...args: any[]) => T, instanceKey?: string): number;
1006
+ /**
1007
+ * Check if an instance exists
1008
+ * @param instanceKey - Optional instance key (defaults to 'default')
1009
+ * @returns true if instance exists
1010
+ */
1011
+ static hasInstance<T extends StateContainer<any> = StateContainer<any>>(this: new (...args: any[]) => T, instanceKey?: string): boolean;
1012
+ private _state;
1013
+ private readonly listeners;
1014
+ private _disposed;
1015
+ private config;
1016
+ private _props;
1017
+ private readonly systemEventHandlers;
1018
+ /** Display name for this instance */
1019
+ name: string;
1020
+ /** Whether debug logging is enabled */
1021
+ debug: boolean;
1022
+ /** Unique identifier for this instance */
1023
+ instanceId: string;
1024
+ /** Timestamp when this instance was created */
1025
+ createdAt: number;
1026
+ /** Current props value passed to this container */
1027
+ get props(): P | undefined;
1028
+ constructor(initialState: S);
1029
+ /**
1030
+ * Initialize configuration for this instance.
1031
+ * Called by the registry after construction.
1032
+ * @param config - Configuration options
1033
+ */
1034
+ initConfig(config: StateContainerConfig): void;
1035
+ /** Current state value */
1036
+ get state(): S;
1037
+ /** Whether this instance has been disposed */
1038
+ get isDisposed(): boolean;
1039
+ /**
1040
+ * Subscribe to state changes
1041
+ * @param listener - Function called when state changes
1042
+ * @returns Unsubscribe function
1043
+ */
1044
+ subscribe(listener: StateListener<S>): () => void;
1045
+ /**
1046
+ * Dispose this instance and clean up resources.
1047
+ * Clears all listeners and emits the 'dispose' system event.
1048
+ */
1049
+ dispose(): void;
1050
+ /**
1051
+ * Emit a new state value and notify all listeners.
1052
+ * @param newState - The new state value
1053
+ * @protected
1054
+ */
1055
+ protected emit(newState: S): void;
1056
+ /** Whether to capture stack traces on state changes (disabled in production) */
1057
+ static enableStackTrace: boolean;
1058
+ private captureStackTrace;
1059
+ private formatStackLine;
1060
+ private cleanFilePath;
1061
+ /** Timestamp of the last state update */
1062
+ lastUpdateTimestamp: number;
1063
+ /**
1064
+ * Update state using a transform function.
1065
+ * @param updater - Function that receives current state and returns new state
1066
+ * @protected
1067
+ */
1068
+ protected update(updater: (current: S) => S): void;
1069
+ /**
1070
+ * Subscribe to system lifecycle events.
1071
+ * @param event - The event type to listen for
1072
+ * @param handler - Handler function called when event occurs
1073
+ * @returns Unsubscribe function
1074
+ * @protected
1075
+ */
1076
+ protected onSystemEvent: <E extends SystemEvent>(event: E, handler: SystemEventHandler<S, P, E>) => (() => void);
1077
+ private emitSystemEvent;
1078
+ /**
1079
+ * Update the props for this container.
1080
+ * Emits the 'propsUpdated' system event.
1081
+ * @param newProps - The new props value
1082
+ */
1083
+ updateProps(newProps: P): void;
1084
+ }
1085
+
1086
+ /**
1087
+ * Configuration options for initializing a StateContainer instance
1088
+ */
1089
+ export declare interface StateContainerConfig {
1090
+ /** Display name for the instance (defaults to class name) */
1091
+ name?: string;
1092
+ /** Enable debug logging for this instance */
1093
+ debug?: boolean;
1094
+ /** Custom instance identifier */
1095
+ instanceId?: string;
1096
+ }
1097
+
1098
+ /**
1099
+ * Central registry for managing StateContainer instances.
1100
+ * Handles instance lifecycle, ref counting, and lifecycle event emission.
1101
+ *
1102
+ * @example
1103
+ * ```ts
1104
+ * const registry = new StateContainerRegistry();
1105
+ * const instance = registry.resolve(MyBloc);
1106
+ * registry.on('stateChanged', (container, prev, next) => {
1107
+ * console.log('State changed:', prev, '->', next);
1108
+ * });
1109
+ * ```
1110
+ */
1111
+ export declare class StateContainerRegistry {
1112
+ private readonly instancesByConstructor;
1113
+ private readonly types;
1114
+ private readonly typeConfigs;
1115
+ private readonly listeners;
1116
+ /**
1117
+ * Register a type for lifecycle event tracking
1118
+ * @param constructor - The StateContainer class constructor
1119
+ */
1120
+ registerType<T extends StateContainer<any>>(constructor: new (...args: any[]) => T): void;
1121
+ /**
1122
+ * Register a StateContainer class with configuration
1123
+ * @param constructor - The StateContainer class constructor
1124
+ * @param isolated - Whether instances should be isolated (component-scoped)
1125
+ * @throws Error if type is already registered
1126
+ */
1127
+ register<T extends StateContainer<any>>(constructor: new (...args: any[]) => T, isolated?: boolean): void;
1128
+ private ensureInstancesMap;
1129
+ /**
1130
+ * Get the instances Map for a specific class (public API for stats/debugging)
1131
+ */
1132
+ getInstancesMap<T extends StateContainer<any>>(Type: new (...args: any[]) => T): Map<string, InstanceEntry>;
1133
+ /**
1134
+ * Resolve an instance with ref counting (ownership semantics)
1135
+ */
1136
+ resolve<T extends StateContainer<any>>(Type: new (...args: any[]) => T, instanceKey?: string, constructorArgs?: any): T;
1137
+ /**
1138
+ * Get an existing instance without ref counting (borrowing semantics)
1139
+ * @throws Error if instance doesn't exist
1140
+ */
1141
+ get<T extends StateContainer<any>>(Type: new (...args: any[]) => T, instanceKey?: string): T;
1142
+ /**
1143
+ * Safely get an existing instance (borrowing semantics with error handling)
1144
+ * Returns discriminated union for type-safe conditional access
1145
+ */
1146
+ getSafe<T extends StateContainer<any>>(Type: new (...args: any[]) => T, instanceKey?: string): {
1147
+ error: Error;
1148
+ instance: null;
1149
+ } | {
1150
+ error: null;
1151
+ instance: T;
1152
+ };
1153
+ /**
1154
+ * Connect to an instance with borrowing semantics (for B2B communication)
1155
+ * Gets existing instance OR creates it if it doesn't exist, without incrementing ref count.
1156
+ * Tracks cross-bloc dependency for reactive updates.
1157
+ *
1158
+ * Use this in bloc-to-bloc communication when you need to ensure an instance exists
1159
+ * but don't want to claim ownership (no ref count increment).
1160
+ *
1161
+ * @param Type - The bloc class constructor
1162
+ * @param instanceKey - Optional instance key (defaults to 'default')
1163
+ * @param constructorArgs - Constructor arguments (only used if creating new instance)
1164
+ * @returns The bloc instance
1165
+ */
1166
+ connect<T extends StateContainer<any>>(Type: new (...args: any[]) => T, instanceKey?: string, constructorArgs?: any): T;
1167
+ /**
1168
+ * Release a reference to an instance
1169
+ */
1170
+ release<T extends StateContainer<any>>(Type: new (...args: any[]) => T, instanceKey?: string, forceDispose?: boolean): void;
1171
+ /**
1172
+ * Get all instances of a specific type
1173
+ */
1174
+ getAll<T extends StateContainer<any>>(Type: new (...args: any[]) => T): T[];
1175
+ /**
1176
+ * Safely iterate over all instances of a type
1177
+ */
1178
+ forEach<T extends StateContainer<any>>(Type: new (...args: any[]) => T, callback: (instance: T) => void): void;
1179
+ /**
1180
+ * Clear all instances of a specific type
1181
+ */
1182
+ clear<T extends StateContainer<any>>(Type: new (...args: any[]) => T): void;
1183
+ /**
1184
+ * Get reference count for an instance
1185
+ */
1186
+ getRefCount<T extends StateContainer<any>>(Type: new (...args: any[]) => T, instanceKey?: string): number;
1187
+ /**
1188
+ * Check if an instance exists
1189
+ */
1190
+ hasInstance<T extends StateContainer<any>>(Type: new (...args: any[]) => T, instanceKey?: string): boolean;
1191
+ /**
1192
+ * Clear all instances from all types (for testing)
1193
+ *
1194
+ * Iterates all registered types and clears their instances.
1195
+ * Also clears type tracking to reset the registry state.
1196
+ */
1197
+ clearAll(): void;
1198
+ /**
1199
+ * Get registry statistics (for debugging)
1200
+ */
1201
+ getStats(): {
1202
+ registeredTypes: number;
1203
+ totalInstances: number;
1204
+ typeBreakdown: Record<string, number>;
1205
+ };
1206
+ /**
1207
+ * Get all registered types (for plugin system)
1208
+ */
1209
+ getTypes(): Array<new (...args: any[]) => StateContainer<any>>;
1210
+ /**
1211
+ * Subscribe to lifecycle events
1212
+ * @param event - The lifecycle event to listen for
1213
+ * @param listener - The listener function to call when the event occurs
1214
+ * @returns Unsubscribe function
1215
+ */
1216
+ on<E extends LifecycleEvent>(event: E, listener: LifecycleListener<E>): () => void;
1217
+ /* Excluded from this release type: emit */
1218
+ }
1219
+
1220
+ /* Excluded from this release type: StateListener */
1221
+
1222
+ /**
1223
+ * Conditionally override the state type of a StateContainer.
1224
+ * When S is `never`, returns T unchanged (inferred state type).
1225
+ * When S is provided, replaces the state type while preserving all other properties.
1226
+ *
1227
+ * @template T - The StateContainer type
1228
+ * @template S - The state type override (defaults to never)
1229
+ *
1230
+ * @example
1231
+ * // Without override - returns original type
1232
+ * type Result1 = StateOverride<MyBloc>; // MyBloc
1233
+ *
1234
+ * // With override - replaces state type
1235
+ * type Result2 = StateOverride<MyBloc, CustomState>; // Omit<MyBloc, 'state'> & { readonly state: CustomState }
1236
+ */
1237
+ export declare type StateOverride<T extends StateContainer<any, any>, S = never> = [S] extends [never] ? T : Omit<T, 'state'> & {
1238
+ readonly state: S;
1239
+ };
1240
+
1241
+ /* Excluded from this release type: stopProxyTracking */
1242
+
1243
+ /**
1244
+ * Function that subscribes to state changes and returns an unsubscribe function
1245
+ */
1246
+ export declare type SubscribeFunction = (callback: SubscriptionCallback) => () => void;
1247
+
1248
+ /**
1249
+ * Callback function invoked when subscribed state changes
1250
+ */
1251
+ export declare type SubscriptionCallback = () => void;
1252
+
1253
+ /**
1254
+ * System events emitted by StateContainer lifecycle
1255
+ */
1256
+ export declare type SystemEvent = 'propsUpdated' | 'stateChanged' | 'dispose';
1257
+
1258
+ /* Excluded from this release type: SystemEventHandler */
1259
+
1260
+ /**
1261
+ * Payload types for each system event
1262
+ * @template S - State type
1263
+ * @template P - Props type
1264
+ */
1265
+ export declare interface SystemEventPayloads<S, P> {
1266
+ /** Emitted when props are updated via updateProps() */
1267
+ propsUpdated: {
1268
+ props: P;
1269
+ previousProps: P | undefined;
1270
+ };
1271
+ /** Emitted when state changes via emit() or update() */
1272
+ stateChanged: {
1273
+ state: S;
1274
+ previousState: S;
1275
+ };
1276
+ /** Emitted when the instance is disposed */
1277
+ dispose: void;
1278
+ }
1279
+
1280
+ /* Excluded from this release type: TrackerState */
1281
+
1282
+ /**
1283
+ * Event-driven state container that processes events to update state.
1284
+ * Use with event handlers registered via the on() method.
1285
+ *
1286
+ * @template S - State type
1287
+ * @template E - Event type (extends BaseEvent)
1288
+ * @template P - Props type (optional)
1289
+ */
1290
+ export declare abstract class Vertex<S, E extends BaseEvent = BaseEvent, P = undefined> extends StateContainer<S, P> {
1291
+ private eventHandlers;
1292
+ private isProcessing;
1293
+ private eventQueue;
1294
+ constructor(initialState: S);
1295
+ /**
1296
+ * Register a handler for a specific event type
1297
+ * @param EventClass - The event class constructor
1298
+ * @param handler - Function to handle events of this type
1299
+ */
1300
+ protected on: <T extends E>(EventClass: EventConstructor<T>, handler: EventHandler<T, S>) => void;
1301
+ /**
1302
+ * Add an event to the event stream for processing
1303
+ * @param event - The event to process
1304
+ */
1305
+ add: (event: E) => void;
1306
+ private processEvent;
1307
+ private handleEvent;
1308
+ /**
1309
+ * Handle errors that occur during event processing.
1310
+ * Override this method to implement custom error handling.
1311
+ * @param _event - The event that caused the error
1312
+ * @param _error - The error that occurred
1313
+ */
1314
+ protected onEventError(_event: E, _error: Error): void;
1315
+ }
1316
+
1317
+ /**
1318
+ * Log a warning message (tree-shakeable export)
1319
+ * @param context - Context identifier (module or component name)
1320
+ * @param message - Log message
1321
+ * @param data - Optional structured data
1322
+ */
1323
+ export declare const warn: (context: string, message: string, data?: any) => void;
1324
+
1325
+ export { }