@blac/core 2.0.1 → 2.0.4
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/README.md +6 -55
- package/dist/StateContainerRegistry.cjs.map +1 -0
- package/dist/StateContainerRegistry.js.map +1 -0
- package/dist/debug.cjs +27 -0
- package/dist/debug.cjs.map +1 -0
- package/dist/debug.js +19 -0
- package/dist/debug.js.map +1 -0
- package/dist/index.cjs +236 -2874
- package/dist/index.cjs.map +1 -1
- package/dist/index.d.cts +18 -1119
- package/dist/index.d.ts +18 -1119
- package/dist/index.js +203 -2768
- package/dist/index.js.map +1 -1
- package/dist/management.cjs.map +1 -0
- package/dist/management.js.map +1 -0
- package/dist/plugins.cjs +4 -0
- package/dist/plugins.js +3 -0
- package/dist/resolve-dependencies.cjs.map +1 -0
- package/dist/resolve-dependencies.js.map +1 -0
- package/dist/tracking/dependency-manager.d.ts +37 -0
- package/dist/tracking/index.d.ts +13 -0
- package/dist/tracking/path-utils.d.ts +52 -0
- package/dist/tracking/resolve-dependencies.d.ts +7 -0
- package/dist/tracking/tracked.d.ts +70 -0
- package/dist/tracking/tracking-proxy.d.ts +183 -0
- package/dist/tracking.cjs +18 -0
- package/dist/tracking.d.cts +9 -0
- package/dist/tracking.d.ts +9 -0
- package/dist/tracking.js +3 -0
- package/dist/types.cjs +14 -0
- package/dist/types.cjs.map +1 -0
- package/dist/types.d.cts +8 -0
- package/dist/types.d.ts +8 -0
- package/dist/types.js +13 -0
- package/dist/types.js.map +1 -0
- package/dist/watch-entry.cjs +109 -0
- package/dist/watch-entry.cjs.map +1 -0
- package/dist/watch-entry.js +105 -0
- package/dist/watch-entry.js.map +1 -0
- package/dist/watch.cjs.map +1 -0
- package/dist/watch.js.map +1 -0
- package/package.json +74 -3
package/dist/index.d.cts
CHANGED
|
@@ -1,51 +1,4 @@
|
|
|
1
|
-
|
|
2
|
-
|
|
3
|
-
export declare function acquire<T extends StateContainerConstructor>(BlocClass: T, instanceKey?: string, options?: AcquireOptions<T>): InstanceType<T>;
|
|
4
|
-
|
|
5
|
-
export declare interface AcquireOptions<T extends StateContainerConstructor> {
|
|
6
|
-
props?: ExtractProps<T>;
|
|
7
|
-
}
|
|
8
|
-
|
|
9
|
-
/**
|
|
10
|
-
* Internal state for framework adapters, holding tracking and caching data.
|
|
11
|
-
* @template TBloc - The state container type
|
|
12
|
-
*/
|
|
13
|
-
export declare interface AdapterState<TBloc extends StateContainerConstructor> {
|
|
14
|
-
/** Dependency tracker for state property access tracking */
|
|
15
|
-
dependencyState: DependencyState<ExtractState<TBloc>> | null;
|
|
16
|
-
/** Cached manual dependencies for comparison */
|
|
17
|
-
manualDepsCache: unknown[] | null;
|
|
18
|
-
/** Getter state for computed property tracking */
|
|
19
|
-
getterState: GetterState | null;
|
|
20
|
-
/** Proxied bloc instance for auto-tracking */
|
|
21
|
-
proxiedBloc: InstanceState<TBloc> | null;
|
|
22
|
-
}
|
|
23
|
-
|
|
24
|
-
/**
|
|
25
|
-
* Initialize adapter state for auto-tracking mode.
|
|
26
|
-
* Creates getter tracker and proxied bloc instance.
|
|
27
|
-
* @param instance - The state container instance
|
|
28
|
-
* @returns Initialized adapter state
|
|
29
|
-
*/
|
|
30
|
-
export declare function autoTrackInit<TBloc extends StateContainerConstructor>(instance: InstanceState<TBloc>): AdapterState<TBloc>;
|
|
31
|
-
|
|
32
|
-
/**
|
|
33
|
-
* Create a snapshot function for auto-tracking mode.
|
|
34
|
-
* Returns a proxied state that tracks property access.
|
|
35
|
-
* @param instance - The state container instance
|
|
36
|
-
* @param adapterState - The adapter state for tracking
|
|
37
|
-
* @returns Snapshot function for use with useSyncExternalStore
|
|
38
|
-
*/
|
|
39
|
-
export declare function autoTrackSnapshot<TBloc extends StateContainerConstructor>(instance: InstanceReadonlyState<TBloc>, adapterState: AdapterState<TBloc>): SnapshotFunction<ExtractState<TBloc>>;
|
|
40
|
-
|
|
41
|
-
/**
|
|
42
|
-
* Create a subscribe function for auto-tracking mode.
|
|
43
|
-
* Only triggers callback when tracked properties change.
|
|
44
|
-
* @param instance - The state container instance
|
|
45
|
-
* @param adapterState - The adapter state for tracking
|
|
46
|
-
* @returns Subscribe function for use with useSyncExternalStore
|
|
47
|
-
*/
|
|
48
|
-
export declare function autoTrackSubscribe<TBloc extends StateContainerConstructor>(instance: InstanceReadonlyState<TBloc>, adapterState: AdapterState<TBloc>): SubscribeFunction;
|
|
1
|
+
export declare function acquire<T extends StateContainerConstructor>(BlocClass: T, instanceKey?: string): InstanceType<T>;
|
|
49
2
|
|
|
50
3
|
/**
|
|
51
4
|
* Decorator to configure StateContainer classes.
|
|
@@ -71,96 +24,6 @@ export declare function autoTrackSubscribe<TBloc extends StateContainerConstruct
|
|
|
71
24
|
*/
|
|
72
25
|
export declare function blac(options: BlacOptions): <T extends new (...args: any[]) => any>(target: T, _context?: ClassDecoratorContext) => T;
|
|
73
26
|
|
|
74
|
-
/**
|
|
75
|
-
* Default configuration constants for BlaC
|
|
76
|
-
*/
|
|
77
|
-
export declare const BLAC_DEFAULTS: {
|
|
78
|
-
/**
|
|
79
|
-
* Default instance key for shared instances
|
|
80
|
-
*/
|
|
81
|
-
readonly DEFAULT_INSTANCE_KEY: "default";
|
|
82
|
-
/**
|
|
83
|
-
* Maximum getter nesting depth (prevents infinite recursion)
|
|
84
|
-
*/
|
|
85
|
-
readonly MAX_GETTER_DEPTH: 10;
|
|
86
|
-
/**
|
|
87
|
-
* Default cleanup interval for subscriptions (30 seconds)
|
|
88
|
-
*/
|
|
89
|
-
readonly CLEANUP_INTERVAL_MS: 30000;
|
|
90
|
-
/**
|
|
91
|
-
* Cleanup interval for weak reference stage (10 seconds)
|
|
92
|
-
*/
|
|
93
|
-
readonly WEAKREF_CLEANUP_INTERVAL_MS: 10000;
|
|
94
|
-
/**
|
|
95
|
-
* Default maximum subscriptions per container
|
|
96
|
-
*/
|
|
97
|
-
readonly MAX_SUBSCRIPTIONS: 1000;
|
|
98
|
-
/**
|
|
99
|
-
* Maximum subscriptions for high-performance mode
|
|
100
|
-
*/
|
|
101
|
-
readonly MAX_SUBSCRIPTIONS_HIGH_PERF: 10000;
|
|
102
|
-
/**
|
|
103
|
-
* Default timeout for pipeline execution (5 seconds)
|
|
104
|
-
*/
|
|
105
|
-
readonly PIPELINE_TIMEOUT_MS: 5000;
|
|
106
|
-
/**
|
|
107
|
-
* Cleanup interval for high-performance mode (5 seconds)
|
|
108
|
-
*/
|
|
109
|
-
readonly CLEANUP_INTERVAL_HIGH_PERF_MS: 5000;
|
|
110
|
-
/**
|
|
111
|
-
* Maximum number of stages in a pipeline
|
|
112
|
-
*/
|
|
113
|
-
readonly MAX_PIPELINE_STAGES: 30;
|
|
114
|
-
};
|
|
115
|
-
|
|
116
|
-
/**
|
|
117
|
-
* Standard error message prefix
|
|
118
|
-
*/
|
|
119
|
-
export declare const BLAC_ERROR_PREFIX: "[BlaC]";
|
|
120
|
-
|
|
121
|
-
/**
|
|
122
|
-
* ID generation patterns and constants
|
|
123
|
-
*/
|
|
124
|
-
export declare const BLAC_ID_PATTERNS: {
|
|
125
|
-
/**
|
|
126
|
-
* Prefix for isolated instance keys
|
|
127
|
-
*/
|
|
128
|
-
readonly ISOLATED_PREFIX: "isolated-";
|
|
129
|
-
/**
|
|
130
|
-
* Length of generated ID portion (9 characters from base36)
|
|
131
|
-
*/
|
|
132
|
-
readonly ID_LENGTH: 9;
|
|
133
|
-
};
|
|
134
|
-
|
|
135
|
-
/**
|
|
136
|
-
* Static property names for StateContainer classes
|
|
137
|
-
* Used for feature flags and configuration on bloc classes
|
|
138
|
-
*/
|
|
139
|
-
export declare const BLAC_STATIC_PROPS: {
|
|
140
|
-
/**
|
|
141
|
-
* Mark a bloc as isolated (each component gets its own instance)
|
|
142
|
-
*/
|
|
143
|
-
readonly ISOLATED: "isolated";
|
|
144
|
-
/**
|
|
145
|
-
* Mark a bloc to never be auto-disposed (kept alive permanently)
|
|
146
|
-
*/
|
|
147
|
-
readonly KEEP_ALIVE: "keepAlive";
|
|
148
|
-
/**
|
|
149
|
-
* Exclude a bloc from DevTools reporting (prevents infinite loops)
|
|
150
|
-
*/
|
|
151
|
-
readonly EXCLUDE_FROM_DEVTOOLS: "__excludeFromDevTools";
|
|
152
|
-
};
|
|
153
|
-
|
|
154
|
-
/**
|
|
155
|
-
* Global configuration for @blac/core
|
|
156
|
-
*/
|
|
157
|
-
export declare interface BlacConfig {
|
|
158
|
-
/** Enable development mode (enables additional warnings and checks) */
|
|
159
|
-
devMode: boolean;
|
|
160
|
-
/** Logger configuration */
|
|
161
|
-
logger: Partial<LogConfig>;
|
|
162
|
-
}
|
|
163
|
-
|
|
164
27
|
/**
|
|
165
28
|
* Configuration options for the @blac decorator.
|
|
166
29
|
* Only one option can be specified at a time (union type).
|
|
@@ -203,10 +66,6 @@ export declare interface BlacPlugin {
|
|
|
203
66
|
* Called when state changes in a container instance
|
|
204
67
|
*/
|
|
205
68
|
onStateChanged?<S extends object = any>(instance: StateContainer<S>, previousState: S, currentState: S, callstack: string | undefined, context: PluginContext): void;
|
|
206
|
-
/**
|
|
207
|
-
* Called when an event is added to a Vertex instance
|
|
208
|
-
*/
|
|
209
|
-
onEventAdded?<E extends DiscriminatedEvent>(vertex: Vertex<any, E>, event: EventWithMetadata<E>, context: PluginContext): void;
|
|
210
69
|
/**
|
|
211
70
|
* Called when a state container instance is disposed
|
|
212
71
|
*/
|
|
@@ -230,7 +89,7 @@ declare const BLOC_REF_MARKER: unique symbol;
|
|
|
230
89
|
* Used for type-safe hook parameters.
|
|
231
90
|
* @template TBloc - The StateContainer instance type
|
|
232
91
|
*/
|
|
233
|
-
export declare type BlocConstructor<S extends object = any, T extends new (...args: any[]) => StateContainer<S
|
|
92
|
+
export declare type BlocConstructor<S extends object = any, T extends new (...args: any[]) => StateContainer<S> = new (...args: any[]) => StateContainer<S>> = (new (...args: any[]) => InstanceType<T>) & {
|
|
234
93
|
acquire(instanceKey?: string, ...args: any[]): InstanceType<T>;
|
|
235
94
|
borrow(instanceKey?: string, ...args: any[]): InstanceType<T> | null;
|
|
236
95
|
borrowSafe(instanceKey?: string, ...args: any[]): {
|
|
@@ -273,24 +132,6 @@ export declare function borrowSafe<T extends StateContainerConstructor>(BlocClas
|
|
|
273
132
|
instance: InstanceType<T>;
|
|
274
133
|
};
|
|
275
134
|
|
|
276
|
-
/**
|
|
277
|
-
* Utility type for creating branded/nominal types.
|
|
278
|
-
* Prevents accidental type confusion between similar primitive types.
|
|
279
|
-
* @template T - The base type
|
|
280
|
-
* @template B - The brand identifier
|
|
281
|
-
*/
|
|
282
|
-
export declare type Brand<T, B> = T & {
|
|
283
|
-
[brand]: B;
|
|
284
|
-
};
|
|
285
|
-
|
|
286
|
-
declare const brand: unique symbol;
|
|
287
|
-
|
|
288
|
-
/**
|
|
289
|
-
* Branded string type for type-safe IDs.
|
|
290
|
-
* @template B - The brand identifier
|
|
291
|
-
*/
|
|
292
|
-
export declare type BrandedId<B> = Brand<string, B>;
|
|
293
|
-
|
|
294
135
|
/* Excluded from this release type: capturePaths */
|
|
295
136
|
|
|
296
137
|
export declare function clear<T extends StateContainerConstructor>(BlocClass: T): void;
|
|
@@ -299,138 +140,23 @@ export declare function clear<T extends StateContainerConstructor>(BlocClass: T)
|
|
|
299
140
|
|
|
300
141
|
export declare function clearAll(): void;
|
|
301
142
|
|
|
302
|
-
/* Excluded from this release type: clearExternalDependencies */
|
|
303
|
-
|
|
304
143
|
/* Excluded from this release type: commitTrackedGetters */
|
|
305
144
|
|
|
306
|
-
/**
|
|
307
|
-
* Configure global defaults for @blac/core.
|
|
308
|
-
*
|
|
309
|
-
* @example
|
|
310
|
-
* ```ts
|
|
311
|
-
* import { configureBlac, LogLevel } from '@blac/core';
|
|
312
|
-
*
|
|
313
|
-
* configureBlac({
|
|
314
|
-
* devMode: true,
|
|
315
|
-
* logger: {
|
|
316
|
-
* enabled: true,
|
|
317
|
-
* level: LogLevel.DEBUG
|
|
318
|
-
* }
|
|
319
|
-
* });
|
|
320
|
-
* ```
|
|
321
|
-
*
|
|
322
|
-
* @param config - Partial configuration to merge with defaults
|
|
323
|
-
*/
|
|
324
|
-
export declare function configureBlac(config: Partial<BlacConfig>): void;
|
|
325
|
-
|
|
326
|
-
/**
|
|
327
|
-
* Configuration function that recreates the default logger
|
|
328
|
-
*
|
|
329
|
-
* @param opts - Partial logger configuration
|
|
330
|
-
*
|
|
331
|
-
* @example
|
|
332
|
-
* ```ts
|
|
333
|
-
* configureLogger({ enabled: true, level: LogLevel.DEBUG });
|
|
334
|
-
* ```
|
|
335
|
-
*/
|
|
336
|
-
export declare function configureLogger(opts: Partial<LogConfig>): void;
|
|
337
|
-
|
|
338
|
-
/* Excluded from this release type: createArrayProxy */
|
|
339
|
-
|
|
340
145
|
/* Excluded from this release type: createBlocProxy */
|
|
341
146
|
|
|
342
147
|
/* Excluded from this release type: createDependencyProxy */
|
|
343
148
|
|
|
344
149
|
/* Excluded from this release type: createDependencyState */
|
|
345
150
|
|
|
346
|
-
/* Excluded from this release type: createForTarget */
|
|
347
|
-
|
|
348
151
|
/* Excluded from this release type: createGetterState */
|
|
349
152
|
|
|
350
|
-
/**
|
|
351
|
-
* Centralized ID Generation
|
|
352
|
-
*
|
|
353
|
-
* Provides consistent, collision-resistant ID generation for all BlaC subsystems.
|
|
354
|
-
* Uses timestamp + counter + random suffix for uniqueness.
|
|
355
|
-
*/
|
|
356
|
-
/**
|
|
357
|
-
* Creates an ID generator with isolated counter state
|
|
358
|
-
*
|
|
359
|
-
* @param prefix - Prefix for generated IDs
|
|
360
|
-
* @returns Object with next(), nextSimple(), and reset() methods
|
|
361
|
-
*
|
|
362
|
-
* @example
|
|
363
|
-
* ```ts
|
|
364
|
-
* const generator = createIdGenerator('sub');
|
|
365
|
-
* const id1 = generator.next(); // "sub:1698765432100_1_a3k9d7f2q"
|
|
366
|
-
* const id2 = generator.next(); // "sub:1698765432101_2_b4n8e9g3r"
|
|
367
|
-
* ```
|
|
368
|
-
*/
|
|
369
|
-
export declare function createIdGenerator(prefix: string): {
|
|
370
|
-
next: () => string;
|
|
371
|
-
nextSimple: () => string;
|
|
372
|
-
reset: () => void;
|
|
373
|
-
};
|
|
374
|
-
|
|
375
|
-
/* Excluded from this release type: createInternal */
|
|
376
|
-
|
|
377
|
-
/**
|
|
378
|
-
* Creates a logger instance with given configuration
|
|
379
|
-
*
|
|
380
|
-
* @param config - Logger configuration
|
|
381
|
-
* @returns Logger instance with debug, info, warn, error, and configure methods
|
|
382
|
-
*
|
|
383
|
-
* @example
|
|
384
|
-
* ```ts
|
|
385
|
-
* const logger = createLogger({
|
|
386
|
-
* enabled: true,
|
|
387
|
-
* level: LogLevel.DEBUG,
|
|
388
|
-
* output: (entry) => console.log(JSON.stringify(entry))
|
|
389
|
-
* });
|
|
390
|
-
* logger.debug('MyComponent', 'Rendering', { props: { foo: 'bar' } });
|
|
391
|
-
* ```
|
|
392
|
-
*/
|
|
393
|
-
export declare function createLogger(config: LogConfig): {
|
|
394
|
-
debug: (context: string, message: string, data?: any) => void;
|
|
395
|
-
info: (context: string, message: string, data?: any) => void;
|
|
396
|
-
warn: (context: string, message: string, data?: any) => void;
|
|
397
|
-
error: (context: string, message: string, data?: any) => void;
|
|
398
|
-
configure: (opts: Partial<LogConfig>) => void;
|
|
399
|
-
};
|
|
400
|
-
|
|
401
|
-
/**
|
|
402
|
-
* Create a plugin manager instance
|
|
403
|
-
* @param registry - The StateContainerRegistry to monitor for lifecycle events
|
|
404
|
-
* @returns A new PluginManager instance
|
|
405
|
-
*/
|
|
406
|
-
export declare function createPluginManager(registry: StateContainerRegistry): PluginManager;
|
|
407
|
-
|
|
408
|
-
/* Excluded from this release type: createProxyState */
|
|
409
|
-
|
|
410
|
-
/**
|
|
411
|
-
* Create a new tracked context for manual control over tracking.
|
|
412
|
-
*/
|
|
413
|
-
export declare function createTrackedContext(): TrackedContext;
|
|
414
|
-
|
|
415
|
-
/**
|
|
416
|
-
* Create a tracking proxy for a bloc instance.
|
|
417
|
-
* Tracks both state property access and getter access.
|
|
418
|
-
*/
|
|
419
|
-
export declare function createTrackingProxy<T extends StateContainerInstance>(bloc: T, tracker: TrackingProxyState): T;
|
|
420
|
-
|
|
421
|
-
/**
|
|
422
|
-
* Create a new tracking proxy state.
|
|
423
|
-
*/
|
|
424
|
-
export declare function createTrackingProxyState(): TrackingProxyState;
|
|
425
|
-
|
|
426
153
|
/**
|
|
427
154
|
* Simple state container with direct state emission.
|
|
428
155
|
* Extends StateContainer with public methods for emitting and updating state.
|
|
429
156
|
*
|
|
430
157
|
* @template S - State type
|
|
431
|
-
* @template P - Props type (optional)
|
|
432
158
|
*/
|
|
433
|
-
export declare abstract class Cubit<S extends object = any
|
|
159
|
+
export declare abstract class Cubit<S extends object = any> extends StateContainer<S> {
|
|
434
160
|
constructor(initialState: S);
|
|
435
161
|
/**
|
|
436
162
|
* Replace state with a new value and notify all listeners
|
|
@@ -448,14 +174,6 @@ export declare abstract class Cubit<S extends object = any, P = undefined> exten
|
|
|
448
174
|
patch: S extends object ? (partial: Partial<S>) => void : never;
|
|
449
175
|
}
|
|
450
176
|
|
|
451
|
-
/**
|
|
452
|
-
* Log a debug message (tree-shakeable export)
|
|
453
|
-
* @param context - Context identifier (module or component name)
|
|
454
|
-
* @param message - Log message
|
|
455
|
-
* @param data - Optional structured data
|
|
456
|
-
*/
|
|
457
|
-
export declare const debug: (context: string, message: string, data?: any) => void;
|
|
458
|
-
|
|
459
177
|
/**
|
|
460
178
|
* Manages subscriptions to state container dependencies.
|
|
461
179
|
* Provides efficient sync mechanism to add/remove subscriptions
|
|
@@ -495,173 +213,30 @@ export declare class DependencyManager {
|
|
|
495
213
|
|
|
496
214
|
/* Excluded from this release type: DependencyState */
|
|
497
215
|
|
|
498
|
-
/**
|
|
499
|
-
* Disable getter tracking after render phase completes.
|
|
500
|
-
* Clears the active tracker to prevent tracking outside of render.
|
|
501
|
-
* @param adapterState - The adapter state
|
|
502
|
-
* @param rawInstance - The raw bloc instance
|
|
503
|
-
*/
|
|
504
|
-
export declare function disableGetterTracking<TBloc extends StateContainerConstructor>(adapterState: AdapterState<TBloc>, rawInstance: InstanceState<TBloc>): void;
|
|
505
|
-
|
|
506
|
-
/**
|
|
507
|
-
* Base type for discriminated union events.
|
|
508
|
-
* All events must have a `type` property as the discriminator.
|
|
509
|
-
*
|
|
510
|
-
* @example
|
|
511
|
-
* ```typescript
|
|
512
|
-
* type MyEvent =
|
|
513
|
-
* | { type: 'increment'; amount: number }
|
|
514
|
-
* | { type: 'decrement' };
|
|
515
|
-
* ```
|
|
516
|
-
*/
|
|
517
|
-
export declare interface DiscriminatedEvent {
|
|
518
|
-
readonly type: string;
|
|
519
|
-
}
|
|
520
|
-
|
|
521
|
-
/* Excluded from this release type: EmptyState */
|
|
522
|
-
|
|
523
|
-
/* Excluded from this release type: EmptyState_2 */
|
|
524
|
-
|
|
525
216
|
export declare function ensure<T extends StateContainerConstructor>(BlocClass: T, instanceKey?: string): InstanceType<T>;
|
|
526
217
|
|
|
527
|
-
/**
|
|
528
|
-
* Log an error message (tree-shakeable export)
|
|
529
|
-
* @param context - Context identifier (module or component name)
|
|
530
|
-
* @param message - Log message
|
|
531
|
-
* @param data - Optional structured data
|
|
532
|
-
*/
|
|
533
|
-
export declare const error: (context: string, message: string, data?: any) => void;
|
|
534
|
-
|
|
535
|
-
/**
|
|
536
|
-
* Map of event handlers requiring exhaustive coverage.
|
|
537
|
-
* TypeScript enforces that every event type in the union has a handler.
|
|
538
|
-
*
|
|
539
|
-
* @template E - The discriminated event union type
|
|
540
|
-
* @template S - The state type
|
|
541
|
-
*
|
|
542
|
-
* @example
|
|
543
|
-
* ```typescript
|
|
544
|
-
* type CounterEvent =
|
|
545
|
-
* | { type: 'increment'; amount: number }
|
|
546
|
-
* | { type: 'reset' };
|
|
547
|
-
*
|
|
548
|
-
* // All event types must be handled:
|
|
549
|
-
* const handlers: EventHandlerMap<CounterEvent, { count: number }> = {
|
|
550
|
-
* increment: (event, emit) => emit({ count: event.amount }),
|
|
551
|
-
* reset: (_, emit) => emit({ count: 0 }),
|
|
552
|
-
* };
|
|
553
|
-
* ```
|
|
554
|
-
*/
|
|
555
|
-
export declare type EventHandlerMap<E extends DiscriminatedEvent, S extends object> = {
|
|
556
|
-
[K in EventType<E>]: VertexEventHandler<ExtractEvent<E, K>, S>;
|
|
557
|
-
};
|
|
558
|
-
|
|
559
|
-
/* Excluded from this release type: EventMetadata */
|
|
560
|
-
|
|
561
|
-
/**
|
|
562
|
-
* Extract the `type` literal union from a discriminated event union.
|
|
563
|
-
*
|
|
564
|
-
* @template E - The discriminated event union type
|
|
565
|
-
*
|
|
566
|
-
* @example
|
|
567
|
-
* ```typescript
|
|
568
|
-
* type MyEvent = { type: 'a' } | { type: 'b' };
|
|
569
|
-
* type Types = EventType<MyEvent>; // 'a' | 'b'
|
|
570
|
-
* ```
|
|
571
|
-
*/
|
|
572
|
-
export declare type EventType<E extends DiscriminatedEvent> = E['type'];
|
|
573
|
-
|
|
574
|
-
/* Excluded from this release type: EventWithMetadata */
|
|
575
|
-
|
|
576
|
-
/**
|
|
577
|
-
* Manages subscriptions to external bloc dependencies for getter tracking.
|
|
578
|
-
* When a getter accesses another bloc's state, this manager ensures
|
|
579
|
-
* re-renders occur when those external dependencies change.
|
|
580
|
-
*
|
|
581
|
-
* @deprecated Use DependencyManager from tracking module instead.
|
|
582
|
-
* This class is kept for backward compatibility.
|
|
583
|
-
*/
|
|
584
|
-
export declare class ExternalDepsManager {
|
|
585
|
-
private manager;
|
|
586
|
-
/**
|
|
587
|
-
* Update subscriptions to external bloc dependencies.
|
|
588
|
-
* Creates subscriptions to blocs accessed via getters.
|
|
589
|
-
* @param getterTracker - The getter tracker state with external dependencies
|
|
590
|
-
* @param rawInstance - The primary bloc instance (excluded from subscriptions)
|
|
591
|
-
* @param onGetterChange - Callback to invoke when external dependency changes
|
|
592
|
-
* @returns true if subscriptions were updated, false if unchanged
|
|
593
|
-
*/
|
|
594
|
-
updateSubscriptions(getterState: GetterState | null, rawInstance: StateContainerInstance, onGetterChange: () => void): boolean;
|
|
595
|
-
/**
|
|
596
|
-
* Clean up all active subscriptions
|
|
597
|
-
*/
|
|
598
|
-
cleanup(): void;
|
|
599
|
-
}
|
|
600
|
-
|
|
601
218
|
/**
|
|
602
219
|
* Extract constructor argument types from a class
|
|
603
220
|
* @template T - The class type
|
|
604
221
|
*/
|
|
605
222
|
export declare type ExtractConstructorArgs<T> = T extends new (...args: infer P) => any ? P : never[];
|
|
606
223
|
|
|
607
|
-
/**
|
|
608
|
-
* Extract a specific event variant from a union by its type.
|
|
609
|
-
*
|
|
610
|
-
* @template E - The discriminated event union type
|
|
611
|
-
* @template T - The type literal to extract
|
|
612
|
-
*
|
|
613
|
-
* @example
|
|
614
|
-
* ```typescript
|
|
615
|
-
* type MyEvent = { type: 'a'; value: number } | { type: 'b' };
|
|
616
|
-
* type EventA = ExtractEvent<MyEvent, 'a'>; // { type: 'a'; value: number }
|
|
617
|
-
* ```
|
|
618
|
-
*/
|
|
619
|
-
export declare type ExtractEvent<E extends DiscriminatedEvent, T extends EventType<E>> = Extract<E, {
|
|
620
|
-
type: T;
|
|
621
|
-
}>;
|
|
622
|
-
|
|
623
224
|
declare type ExtractInstance<T> = T extends BlocRef<infer C> ? InstanceType<C> : T extends StateContainerConstructor ? InstanceType<T> : never;
|
|
624
225
|
|
|
625
226
|
declare type ExtractInstances<T extends readonly BlocInput[]> = {
|
|
626
227
|
[K in keyof T]: ExtractInstance<T[K]>;
|
|
627
228
|
};
|
|
628
229
|
|
|
629
|
-
/**
|
|
630
|
-
* Extract the props type from a StateContainer
|
|
631
|
-
* @template T - The StateContainer type
|
|
632
|
-
*/
|
|
633
|
-
export declare type ExtractProps<T> = T extends StateContainerConstructor<any, infer P> ? P : undefined;
|
|
634
|
-
|
|
635
230
|
/**
|
|
636
231
|
* Extract the state type from a StateContainer
|
|
637
232
|
* @template T - The StateContainer type
|
|
638
233
|
*/
|
|
639
|
-
export declare type ExtractState<T> = T extends StateContainerConstructor<infer S
|
|
234
|
+
export declare type ExtractState<T> = T extends StateContainerConstructor<infer S> ? Readonly<S> : never;
|
|
640
235
|
|
|
641
|
-
|
|
642
|
-
* Constrain a type to extract state only from stateful containers.
|
|
643
|
-
* Returns `never` for stateless containers.
|
|
644
|
-
*/
|
|
645
|
-
export declare type ExtractStatefulState<T extends StateContainerConstructor> = IsStatelessContainer<T> extends true ? never : ExtractState<T>;
|
|
646
|
-
|
|
647
|
-
export declare type ExtractStateMutable<T> = T extends StateContainerConstructor<infer S, any> ? S : never;
|
|
236
|
+
export declare type ExtractStateMutable<T> = T extends StateContainerConstructor<infer S> ? S : never;
|
|
648
237
|
|
|
649
238
|
export declare function forEach<T extends StateContainerConstructor>(BlocClass: T, callback: (instance: InstanceReadonlyState<T>) => void): void;
|
|
650
239
|
|
|
651
|
-
/**
|
|
652
|
-
* Generate ID with timestamp, counter, and random suffix (tree-shakeable)
|
|
653
|
-
*
|
|
654
|
-
* Format: `${prefix}:${timestamp}_${counter}_${random}`
|
|
655
|
-
*
|
|
656
|
-
* @param prefix - Prefix for the ID (e.g., 'sub', 'consumer', 'stage')
|
|
657
|
-
* @returns Branded ID string
|
|
658
|
-
*
|
|
659
|
-
* @example
|
|
660
|
-
* const id = generateId('sub');
|
|
661
|
-
* // Returns: "sub:1698765432100_1_a3k9d7f2q"
|
|
662
|
-
*/
|
|
663
|
-
export declare function generateId(prefix: string): string;
|
|
664
|
-
|
|
665
240
|
/**
|
|
666
241
|
* Generate a unique isolated instance key
|
|
667
242
|
* Uses base36 encoding for compact, URL-safe identifiers
|
|
@@ -673,32 +248,8 @@ export declare function generateId(prefix: string): string;
|
|
|
673
248
|
*/
|
|
674
249
|
export declare function generateIsolatedKey(): string;
|
|
675
250
|
|
|
676
|
-
/**
|
|
677
|
-
* Generate simple ID with timestamp and random (no counter tracking)
|
|
678
|
-
*
|
|
679
|
-
* Format: `${prefix}:${timestamp}_${random}`
|
|
680
|
-
*
|
|
681
|
-
* @param prefix - Prefix for the ID
|
|
682
|
-
* @returns Branded ID string
|
|
683
|
-
*
|
|
684
|
-
* @example
|
|
685
|
-
* ```ts
|
|
686
|
-
* const id = generateSimpleId('CounterBloc');
|
|
687
|
-
* // Returns: "CounterBloc:1698765432100_a3k9d7f2q"
|
|
688
|
-
* ```
|
|
689
|
-
*/
|
|
690
|
-
export declare function generateSimpleId(prefix: string, affix?: string): string;
|
|
691
|
-
|
|
692
|
-
/* Excluded from this release type: getActiveTracker */
|
|
693
|
-
|
|
694
251
|
export declare function getAll<T extends StateContainerConstructor>(BlocClass: T): InstanceReadonlyState<T>[];
|
|
695
252
|
|
|
696
|
-
/* Excluded from this release type: getBlacConfig */
|
|
697
|
-
|
|
698
|
-
/* Excluded from this release type: getDescriptor */
|
|
699
|
-
|
|
700
|
-
/* Excluded from this release type: getGetterExecutionContext */
|
|
701
|
-
|
|
702
253
|
/**
|
|
703
254
|
* Get the global plugin manager
|
|
704
255
|
*/
|
|
@@ -706,36 +257,8 @@ export declare function getPluginManager(): any;
|
|
|
706
257
|
|
|
707
258
|
export declare function getRefCount<T extends StateContainerConstructor>(BlocClass: T, instanceKey?: string): number;
|
|
708
259
|
|
|
709
|
-
export declare function getRegistry(): StateContainerRegistry;
|
|
710
|
-
|
|
711
|
-
/**
|
|
712
|
-
* Get a static property from a class constructor
|
|
713
|
-
* Type-safe helper that avoids (Type as any) casts
|
|
714
|
-
*
|
|
715
|
-
* @param Type - The class constructor
|
|
716
|
-
* @param propName - The property name to access
|
|
717
|
-
* @param defaultValue - Optional default value if property is undefined
|
|
718
|
-
* @returns The property value or default
|
|
719
|
-
*/
|
|
720
|
-
export declare function getStaticProp<V, T extends StateContainerConstructor = StateContainerConstructor>(Type: T, propName: string, defaultValue?: V): V | undefined;
|
|
721
|
-
|
|
722
|
-
export declare function getStats(): {
|
|
723
|
-
registeredTypes: number;
|
|
724
|
-
totalInstances: number;
|
|
725
|
-
typeBreakdown: Record<string, number>;
|
|
726
|
-
};
|
|
727
|
-
|
|
728
|
-
declare interface GetterExecutionContext {
|
|
729
|
-
tracker: GetterState | null;
|
|
730
|
-
currentBloc: StateContainerInstance | null;
|
|
731
|
-
depth: number;
|
|
732
|
-
visitedBlocs: Set<StateContainerInstance>;
|
|
733
|
-
}
|
|
734
|
-
|
|
735
260
|
/* Excluded from this release type: GetterState */
|
|
736
261
|
|
|
737
|
-
/* Excluded from this release type: getValueAtPath */
|
|
738
|
-
|
|
739
262
|
/**
|
|
740
263
|
* Global default registry instance
|
|
741
264
|
*/
|
|
@@ -745,30 +268,10 @@ export declare const globalRegistry: StateContainerRegistry;
|
|
|
745
268
|
|
|
746
269
|
/* Excluded from this release type: hasGetterChanges */
|
|
747
270
|
|
|
748
|
-
/**
|
|
749
|
-
* Type guard to check if a plugin has a required onInstall hook
|
|
750
|
-
* @param plugin - The plugin to check
|
|
751
|
-
* @returns true if the plugin implements BlacPluginWithInit
|
|
752
|
-
*/
|
|
753
|
-
export declare function hasInitHook(plugin: BlacPlugin): plugin is BlacPluginWithInit;
|
|
754
|
-
|
|
755
271
|
export declare function hasInstance<T extends StateContainerConstructor>(BlocClass: T, instanceKey?: string): boolean;
|
|
756
272
|
|
|
757
273
|
/* Excluded from this release type: hasTrackedData */
|
|
758
274
|
|
|
759
|
-
/**
|
|
760
|
-
* Check if tracked state or getters have changed.
|
|
761
|
-
*/
|
|
762
|
-
export declare function hasTrackingProxyChanges(tracker: TrackingProxyState, bloc: StateContainerInstance): boolean;
|
|
763
|
-
|
|
764
|
-
/**
|
|
765
|
-
* Log an info message (tree-shakeable export)
|
|
766
|
-
* @param context - Context identifier (module or component name)
|
|
767
|
-
* @param message - Log message
|
|
768
|
-
* @param data - Optional structured data
|
|
769
|
-
*/
|
|
770
|
-
export declare const info: (context: string, message: string, data?: any) => void;
|
|
771
|
-
|
|
772
275
|
/**
|
|
773
276
|
* Create a reference to a specific bloc instance.
|
|
774
277
|
*
|
|
@@ -792,11 +295,6 @@ export declare interface InstanceEntry<T = any> {
|
|
|
792
295
|
refCount: number;
|
|
793
296
|
}
|
|
794
297
|
|
|
795
|
-
/**
|
|
796
|
-
* Branded string type for state container instance IDs
|
|
797
|
-
*/
|
|
798
|
-
export declare type InstanceId = Brand<string, 'InstanceId'>;
|
|
799
|
-
|
|
800
298
|
/**
|
|
801
299
|
* Metadata information about a state container instance for debugging and inspection
|
|
802
300
|
*/
|
|
@@ -835,21 +333,6 @@ export declare type InstanceState<T extends StateContainerConstructor = any> = O
|
|
|
835
333
|
|
|
836
334
|
/* Excluded from this release type: invalidateRenderCache */
|
|
837
335
|
|
|
838
|
-
/**
|
|
839
|
-
* Check if development mode is enabled.
|
|
840
|
-
*/
|
|
841
|
-
export declare function isDevMode(): boolean;
|
|
842
|
-
|
|
843
|
-
/**
|
|
844
|
-
* Check if a class should be excluded from DevTools.
|
|
845
|
-
* Used to prevent infinite loops when DevTools tracks itself.
|
|
846
|
-
* @param Type - The class constructor to check
|
|
847
|
-
* @returns true if the class has `static __excludeFromDevTools = true`
|
|
848
|
-
*/
|
|
849
|
-
export declare function isExcludedFromDevTools<T extends StateContainerConstructor>(Type: T): boolean;
|
|
850
|
-
|
|
851
|
-
/* Excluded from this release type: isGetter */
|
|
852
|
-
|
|
853
336
|
/**
|
|
854
337
|
* Check if a class is marked as isolated.
|
|
855
338
|
* Isolated classes create separate instances per component.
|
|
@@ -858,154 +341,16 @@ export declare function isExcludedFromDevTools<T extends StateContainerConstruct
|
|
|
858
341
|
*/
|
|
859
342
|
export declare function isIsolatedClass<T extends StateContainerConstructor>(Type: T): boolean;
|
|
860
343
|
|
|
861
|
-
/**
|
|
862
|
-
* Check if a key is an isolated instance key
|
|
863
|
-
* @param key - The instance key to check
|
|
864
|
-
* @returns true if the key is an isolated instance key
|
|
865
|
-
*/
|
|
866
|
-
export declare function isIsolatedKey(key: string): boolean;
|
|
867
|
-
|
|
868
|
-
/**
|
|
869
|
-
* Check if a class is marked as keepAlive.
|
|
870
|
-
* KeepAlive classes are never auto-disposed when ref count reaches 0.
|
|
871
|
-
* @param Type - The class constructor to check
|
|
872
|
-
* @returns true if the class has `static keepAlive = true`
|
|
873
|
-
*/
|
|
874
|
-
export declare function isKeepAliveClass<T extends StateContainerConstructor>(Type: T): boolean;
|
|
875
|
-
|
|
876
|
-
/* Excluded from this release type: isProxyable */
|
|
877
|
-
|
|
878
|
-
/**
|
|
879
|
-
* Check if a class is a stateless container (StatelessCubit or StatelessVertex).
|
|
880
|
-
* Stateless containers don't have state, emit, update, or subscribe methods.
|
|
881
|
-
* @param Type - The class constructor to check
|
|
882
|
-
* @returns true if the class is a stateless container
|
|
883
|
-
*/
|
|
884
|
-
export declare function isStatelessClass<T extends StateContainerConstructor>(Type: T): boolean;
|
|
885
|
-
|
|
886
|
-
/**
|
|
887
|
-
* Check if a StateContainer constructor is a stateless container.
|
|
888
|
-
* Returns true for StatelessCubit and StatelessVertex classes.
|
|
889
|
-
*/
|
|
890
|
-
export declare type IsStatelessContainer<T> = T extends {
|
|
891
|
-
readonly [STATELESS_MARKER]: true;
|
|
892
|
-
} ? true : false;
|
|
893
|
-
|
|
894
344
|
/**
|
|
895
345
|
* Lifecycle events emitted by the registry
|
|
896
346
|
*/
|
|
897
|
-
export declare type LifecycleEvent = 'created' | 'stateChanged' | '
|
|
347
|
+
export declare type LifecycleEvent = 'created' | 'stateChanged' | 'disposed';
|
|
898
348
|
|
|
899
349
|
/**
|
|
900
350
|
* Listener function type for each lifecycle event
|
|
901
351
|
* @template E - The lifecycle event type
|
|
902
352
|
*/
|
|
903
|
-
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 '
|
|
904
|
-
|
|
905
|
-
/**
|
|
906
|
-
* Configuration for the logger
|
|
907
|
-
*/
|
|
908
|
-
export declare interface LogConfig {
|
|
909
|
-
/** Whether logging is enabled */
|
|
910
|
-
enabled: boolean;
|
|
911
|
-
/** Minimum log level to output */
|
|
912
|
-
level: LogLevel;
|
|
913
|
-
/** Function called to output log entries */
|
|
914
|
-
output: (entry: LogEntry) => void;
|
|
915
|
-
}
|
|
916
|
-
|
|
917
|
-
/**
|
|
918
|
-
* Structure of a log entry passed to output handlers
|
|
919
|
-
*/
|
|
920
|
-
export declare interface LogEntry {
|
|
921
|
-
/** Log level as string (DEBUG, INFO, WARN, ERROR) */
|
|
922
|
-
level: string;
|
|
923
|
-
/** Context identifier (typically component or module name) */
|
|
924
|
-
context: string;
|
|
925
|
-
/** Log message */
|
|
926
|
-
message: string;
|
|
927
|
-
/** Optional structured data */
|
|
928
|
-
data?: any;
|
|
929
|
-
/** Unix timestamp in milliseconds */
|
|
930
|
-
timestamp: number;
|
|
931
|
-
}
|
|
932
|
-
|
|
933
|
-
/**
|
|
934
|
-
* Log severity levels (lower number = higher severity)
|
|
935
|
-
*/
|
|
936
|
-
export declare enum LogLevel {
|
|
937
|
-
/** Critical errors that may cause application failure */
|
|
938
|
-
ERROR = 0,
|
|
939
|
-
/** Warning conditions that should be addressed */
|
|
940
|
-
WARN = 1,
|
|
941
|
-
/** Informational messages about application state */
|
|
942
|
-
INFO = 2,
|
|
943
|
-
/** Detailed debugging information */
|
|
944
|
-
DEBUG = 3
|
|
945
|
-
}
|
|
946
|
-
|
|
947
|
-
/**
|
|
948
|
-
* Configuration for manual dependency tracking mode
|
|
949
|
-
* @template TBloc - The state container type
|
|
950
|
-
*/
|
|
951
|
-
export declare interface ManualDepsConfig<TBloc extends StateContainerConstructor> {
|
|
952
|
-
/** Function that returns dependency array from state and bloc */
|
|
953
|
-
dependencies: (state: ExtractState<TBloc>, bloc: InstanceState<TBloc>) => any[];
|
|
954
|
-
}
|
|
955
|
-
|
|
956
|
-
/**
|
|
957
|
-
* Initialize adapter state for manual dependency tracking mode.
|
|
958
|
-
* No proxy is created; bloc is used directly.
|
|
959
|
-
* @param instance - The state container instance
|
|
960
|
-
* @returns Initialized adapter state
|
|
961
|
-
*/
|
|
962
|
-
export declare function manualDepsInit<TBloc extends StateContainerConstructor>(instance: InstanceState<TBloc>): AdapterState<TBloc>;
|
|
963
|
-
|
|
964
|
-
/**
|
|
965
|
-
* Create a snapshot function for manual dependency tracking mode.
|
|
966
|
-
* Caches dependencies for comparison on next render.
|
|
967
|
-
* @param instance - The state container instance
|
|
968
|
-
* @param adapterState - The adapter state for caching
|
|
969
|
-
* @param config - Configuration with dependencies function
|
|
970
|
-
* @returns Snapshot function for use with useSyncExternalStore
|
|
971
|
-
*/
|
|
972
|
-
export declare function manualDepsSnapshot<TBloc extends StateContainerConstructor>(instance: InstanceState<TBloc>, adapterState: AdapterState<TBloc>, config: ManualDepsConfig<TBloc>): SnapshotFunction<ExtractState<TBloc>>;
|
|
973
|
-
|
|
974
|
-
/**
|
|
975
|
-
* Create a subscribe function for manual dependency tracking mode.
|
|
976
|
-
* Only triggers callback when dependencies array changes.
|
|
977
|
-
* @param instance - The state container instance
|
|
978
|
-
* @param adapterState - The adapter state for caching
|
|
979
|
-
* @param config - Configuration with dependencies function
|
|
980
|
-
* @returns Subscribe function for use with useSyncExternalStore
|
|
981
|
-
*/
|
|
982
|
-
export declare function manualDepsSubscribe<TBloc extends StateContainerConstructor>(instance: InstanceState<TBloc>, adapterState: AdapterState<TBloc>, config: ManualDepsConfig<TBloc>): SubscribeFunction;
|
|
983
|
-
|
|
984
|
-
/**
|
|
985
|
-
* Initialize adapter state for no-tracking mode.
|
|
986
|
-
* No tracking or proxy is created.
|
|
987
|
-
* @param instance - The state container instance
|
|
988
|
-
* @returns Initialized adapter state
|
|
989
|
-
*/
|
|
990
|
-
export declare function noTrackInit<TBloc extends StateContainerConstructor>(instance: InstanceState<TBloc>): AdapterState<TBloc>;
|
|
991
|
-
|
|
992
|
-
/**
|
|
993
|
-
* Create a snapshot function for no-tracking mode.
|
|
994
|
-
* Returns the raw state directly.
|
|
995
|
-
* @param instance - The state container instance
|
|
996
|
-
* @returns Snapshot function for use with useSyncExternalStore
|
|
997
|
-
*/
|
|
998
|
-
export declare function noTrackSnapshot<TBloc extends StateContainerConstructor>(instance: InstanceReadonlyState<TBloc>): SnapshotFunction<ExtractState<TBloc>>;
|
|
999
|
-
|
|
1000
|
-
/**
|
|
1001
|
-
* Create a subscribe function for no-tracking mode.
|
|
1002
|
-
* Triggers callback on every state change.
|
|
1003
|
-
* @param instance - The state container instance
|
|
1004
|
-
* @returns Subscribe function for use with useSyncExternalStore
|
|
1005
|
-
*/
|
|
1006
|
-
export declare function noTrackSubscribe<TBloc extends StateContainerInstance>(instance: TBloc): SubscribeFunction;
|
|
1007
|
-
|
|
1008
|
-
/* Excluded from this release type: parsePath */
|
|
353
|
+
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 'disposed' ? (container: StateContainer<any>) => void : never;
|
|
1009
354
|
|
|
1010
355
|
/* Excluded from this release type: PathInfo */
|
|
1011
356
|
|
|
@@ -1125,42 +470,22 @@ export declare class PluginManager {
|
|
|
1125
470
|
|
|
1126
471
|
/* Excluded from this release type: ProxyState */
|
|
1127
472
|
|
|
1128
|
-
export declare function register<T extends StateContainerConstructor>(BlocClass: T, isolated?: boolean): void;
|
|
1129
|
-
|
|
1130
473
|
export declare function release<T extends StateContainerConstructor>(BlocClass: T, instanceKey?: string, forceDispose?: boolean): void;
|
|
1131
474
|
|
|
1132
|
-
/* Excluded from this release type:
|
|
1133
|
-
|
|
1134
|
-
/* Excluded from this release type: resetGetterState */
|
|
475
|
+
/* Excluded from this release type: resolveDependencies */
|
|
1135
476
|
|
|
1136
477
|
/* Excluded from this release type: setActiveTracker */
|
|
1137
478
|
|
|
1138
|
-
export declare function setRegistry(registry: StateContainerRegistry): void;
|
|
1139
|
-
|
|
1140
479
|
/* Excluded from this release type: shallowEqual */
|
|
1141
480
|
|
|
1142
|
-
/**
|
|
1143
|
-
* Function that returns a snapshot of the current state
|
|
1144
|
-
* @template TState - The state type
|
|
1145
|
-
*/
|
|
1146
|
-
export declare type SnapshotFunction<TState> = () => TState;
|
|
1147
|
-
|
|
1148
481
|
/* Excluded from this release type: startDependency */
|
|
1149
482
|
|
|
1150
|
-
/* Excluded from this release type: startProxy */
|
|
1151
|
-
|
|
1152
|
-
/**
|
|
1153
|
-
* Start tracking on a tracking proxy.
|
|
1154
|
-
*/
|
|
1155
|
-
export declare function startTrackingProxy(tracker: TrackingProxyState): void;
|
|
1156
|
-
|
|
1157
483
|
/**
|
|
1158
484
|
* Abstract base class for all state containers in BlaC.
|
|
1159
485
|
* Provides lifecycle management, subscription handling, ref counting,
|
|
1160
486
|
* and integration with the global registry.
|
|
1161
487
|
*
|
|
1162
488
|
* @template S - State type managed by this container
|
|
1163
|
-
* @template P - Props type passed to the container (optional)
|
|
1164
489
|
*
|
|
1165
490
|
* @example
|
|
1166
491
|
* ```ts
|
|
@@ -1174,14 +499,13 @@ export declare function startTrackingProxy(tracker: TrackingProxyState): void;
|
|
|
1174
499
|
* }
|
|
1175
500
|
* ```
|
|
1176
501
|
*/
|
|
1177
|
-
export declare abstract class StateContainer<S extends object = any
|
|
502
|
+
export declare abstract class StateContainer<S extends object = any> {
|
|
1178
503
|
static __excludeFromDevTools: boolean;
|
|
1179
504
|
static enableStackTrace: boolean;
|
|
1180
505
|
private _state;
|
|
1181
506
|
private readonly listeners;
|
|
1182
507
|
private _disposed;
|
|
1183
508
|
private config;
|
|
1184
|
-
private _props;
|
|
1185
509
|
private readonly systemEventHandlers;
|
|
1186
510
|
/** Display name for this instance */
|
|
1187
511
|
name: string;
|
|
@@ -1191,8 +515,9 @@ export declare abstract class StateContainer<S extends object = any, P = any> {
|
|
|
1191
515
|
instanceId: string;
|
|
1192
516
|
/** Timestamp when this instance was created */
|
|
1193
517
|
createdAt: number;
|
|
1194
|
-
|
|
1195
|
-
get
|
|
518
|
+
private _dependencies;
|
|
519
|
+
get dependencies(): ReadonlyMap<StateContainerConstructor, string>;
|
|
520
|
+
protected depend<T extends StateContainerConstructor>(Type: T, instanceKey?: string): () => InstanceType<T>;
|
|
1196
521
|
constructor(initialState: S);
|
|
1197
522
|
/**
|
|
1198
523
|
* Initialize configuration for this instance.
|
|
@@ -1239,14 +564,8 @@ export declare abstract class StateContainer<S extends object = any, P = any> {
|
|
|
1239
564
|
* @returns Unsubscribe function
|
|
1240
565
|
* @protected
|
|
1241
566
|
*/
|
|
1242
|
-
protected onSystemEvent: <E extends SystemEvent>(event: E, handler: SystemEventHandler<S,
|
|
567
|
+
protected onSystemEvent: <E extends SystemEvent>(event: E, handler: SystemEventHandler<S, E>) => (() => void);
|
|
1243
568
|
private emitSystemEvent;
|
|
1244
|
-
/**
|
|
1245
|
-
* Update the props for this container.
|
|
1246
|
-
* Emits the 'propsUpdated' system event.
|
|
1247
|
-
* @param newProps - The new props value
|
|
1248
|
-
*/
|
|
1249
|
-
updateProps(newProps: P): void;
|
|
1250
569
|
}
|
|
1251
570
|
|
|
1252
571
|
/**
|
|
@@ -1264,11 +583,10 @@ export declare interface StateContainerConfig {
|
|
|
1264
583
|
/**
|
|
1265
584
|
* Constructor type for StateContainer classes
|
|
1266
585
|
* @template S - State type managed by the container
|
|
1267
|
-
* @template P - Props type passed to the container
|
|
1268
586
|
*/
|
|
1269
|
-
export declare type StateContainerConstructor<S extends object = any
|
|
587
|
+
export declare type StateContainerConstructor<S extends object = any> = new (...args: any[]) => StateContainer<S>;
|
|
1270
588
|
|
|
1271
|
-
export declare type StateContainerInstance<S extends object = any
|
|
589
|
+
export declare type StateContainerInstance<S extends object = any> = Omit<StateContainer<S>, 'state'> & {
|
|
1272
590
|
state: Readonly<S>;
|
|
1273
591
|
};
|
|
1274
592
|
|
|
@@ -1286,7 +604,7 @@ export declare type StateContainerInstance<S extends object = any, P = any> = Om
|
|
|
1286
604
|
* });
|
|
1287
605
|
* ```
|
|
1288
606
|
*/
|
|
1289
|
-
|
|
607
|
+
declare class StateContainerRegistry {
|
|
1290
608
|
private readonly instancesByConstructor;
|
|
1291
609
|
private readonly types;
|
|
1292
610
|
private readonly typeConfigs;
|
|
@@ -1308,7 +626,6 @@ export declare class StateContainerRegistry {
|
|
|
1308
626
|
* Get the instances Map for a specific class (public API for stats/debugging)
|
|
1309
627
|
*/
|
|
1310
628
|
getInstancesMap<T extends StateContainerConstructor>(Type: T): Map<string, InstanceEntry>;
|
|
1311
|
-
private trackExecutionContext;
|
|
1312
629
|
/**
|
|
1313
630
|
* Acquire an instance with ref counting (ownership semantics).
|
|
1314
631
|
* Creates a new instance if one doesn't exist, or returns existing and increments ref count.
|
|
@@ -1318,15 +635,11 @@ export declare class StateContainerRegistry {
|
|
|
1318
635
|
* @param options - Acquisition options
|
|
1319
636
|
* @param options.canCreate - Whether to create new instance if not found (default: true)
|
|
1320
637
|
* @param options.countRef - Whether to increment ref count (default: true)
|
|
1321
|
-
* @param options.props - Props to pass to constructor if creating new instance
|
|
1322
|
-
* @param options.trackExecutionContext - Whether to track cross-bloc dependency (default: false)
|
|
1323
638
|
* @returns The state container instance
|
|
1324
639
|
*/
|
|
1325
640
|
acquire<T extends StateContainerConstructor = StateContainerConstructor>(Type: T, instanceKey?: string, options?: {
|
|
1326
641
|
canCreate?: boolean;
|
|
1327
642
|
countRef?: boolean;
|
|
1328
|
-
props?: ExtractProps<T>;
|
|
1329
|
-
trackExecutionContext?: boolean;
|
|
1330
643
|
}): InstanceType<T>;
|
|
1331
644
|
/**
|
|
1332
645
|
* Borrow an existing instance without incrementing ref count (borrowing semantics).
|
|
@@ -1434,224 +747,24 @@ export declare class StateContainerRegistry {
|
|
|
1434
747
|
/* Excluded from this release type: emit */
|
|
1435
748
|
}
|
|
1436
749
|
|
|
1437
|
-
/**
|
|
1438
|
-
* Constrain a type to only accept stateful containers (not StatelessCubit/StatelessVertex).
|
|
1439
|
-
* Use this to reject stateless containers at the type level.
|
|
1440
|
-
*/
|
|
1441
|
-
export declare type StatefulContainerOnly<T extends StateContainerConstructor> = IsStatelessContainer<T> extends true ? never : T;
|
|
1442
|
-
|
|
1443
|
-
/**
|
|
1444
|
-
* Marker symbol to identify stateless containers at the type level.
|
|
1445
|
-
* Used by React hooks to prevent `useBloc` from accepting stateless containers.
|
|
1446
|
-
*/
|
|
1447
|
-
export declare const STATELESS_MARKER: unique symbol;
|
|
1448
|
-
|
|
1449
|
-
/**
|
|
1450
|
-
* A Cubit without state management capabilities.
|
|
1451
|
-
* Use this for action-only containers that don't need to manage or emit state.
|
|
1452
|
-
*
|
|
1453
|
-
* StatelessCubit:
|
|
1454
|
-
* - Has no `emit()`, `update()`, or `patch()` methods
|
|
1455
|
-
* - Has no accessible `state` property
|
|
1456
|
-
* - Cannot be subscribed to (throws error)
|
|
1457
|
-
* - Is rejected by `useBloc` hook (use `useBlocActions` instead)
|
|
1458
|
-
*
|
|
1459
|
-
* @template P - Props type (optional)
|
|
1460
|
-
*
|
|
1461
|
-
* @example
|
|
1462
|
-
* ```typescript
|
|
1463
|
-
* class AnalyticsService extends StatelessCubit {
|
|
1464
|
-
* trackPageView(page: string) {
|
|
1465
|
-
* analytics.track('page_view', { page });
|
|
1466
|
-
* }
|
|
1467
|
-
*
|
|
1468
|
-
* trackClick(element: string) {
|
|
1469
|
-
* analytics.track('click', { element });
|
|
1470
|
-
* }
|
|
1471
|
-
* }
|
|
1472
|
-
*
|
|
1473
|
-
* // In React component:
|
|
1474
|
-
* const analytics = useBlocActions(AnalyticsService);
|
|
1475
|
-
* analytics.trackPageView('/home');
|
|
1476
|
-
* ```
|
|
1477
|
-
*/
|
|
1478
|
-
export declare abstract class StatelessCubit<P = undefined> extends Cubit<EmptyState, P> {
|
|
1479
|
-
/* Excluded from this release type: [STATELESS_MARKER] */
|
|
1480
|
-
constructor();
|
|
1481
|
-
/**
|
|
1482
|
-
* State is not available on StatelessCubit.
|
|
1483
|
-
* @throws Always throws an error when accessed.
|
|
1484
|
-
*/
|
|
1485
|
-
get state(): never;
|
|
1486
|
-
/**
|
|
1487
|
-
* Subscriptions are not available on StatelessCubit.
|
|
1488
|
-
* @throws Always throws an error when called.
|
|
1489
|
-
*/
|
|
1490
|
-
subscribe(_listener: (state: EmptyState) => void): never;
|
|
1491
|
-
/**
|
|
1492
|
-
* emit() is not available on StatelessCubit.
|
|
1493
|
-
* TypeScript will show an error if you try to call this method.
|
|
1494
|
-
*/
|
|
1495
|
-
emit(_newState: never): never;
|
|
1496
|
-
/**
|
|
1497
|
-
* update() is not available on StatelessCubit.
|
|
1498
|
-
* TypeScript will show an error if you try to call this method.
|
|
1499
|
-
*/
|
|
1500
|
-
update(_updater: never): never;
|
|
1501
|
-
/**
|
|
1502
|
-
* patch() is not available on StatelessCubit.
|
|
1503
|
-
* @throws Error always - StatelessCubit does not support state changes
|
|
1504
|
-
*/
|
|
1505
|
-
patch: (_partial: Partial<EmptyState>) => void;
|
|
1506
|
-
}
|
|
1507
|
-
|
|
1508
|
-
/**
|
|
1509
|
-
* Event handler for StatelessVertex that receives only the event (no emit function).
|
|
1510
|
-
* Use for side-effect-only event processing.
|
|
1511
|
-
*/
|
|
1512
|
-
export declare type StatelessEventHandler<E extends DiscriminatedEvent> = (event: EventWithMetadata<E>) => void;
|
|
1513
|
-
|
|
1514
|
-
/**
|
|
1515
|
-
* Map of event types to their handlers for StatelessVertex.
|
|
1516
|
-
* Enforces exhaustive handling of all event types in the union.
|
|
1517
|
-
*/
|
|
1518
|
-
export declare type StatelessEventHandlerMap<E extends DiscriminatedEvent> = {
|
|
1519
|
-
[K in E['type']]: StatelessEventHandler<Extract<E, {
|
|
1520
|
-
type: K;
|
|
1521
|
-
}>>;
|
|
1522
|
-
};
|
|
1523
|
-
|
|
1524
|
-
/**
|
|
1525
|
-
* An event-driven container without state management capabilities.
|
|
1526
|
-
* Use this for event processing that only produces side effects (logging, analytics, etc).
|
|
1527
|
-
*
|
|
1528
|
-
* StatelessVertex:
|
|
1529
|
-
* - Processes events via `add()` method
|
|
1530
|
-
* - Handlers receive only the event (no `emit` function)
|
|
1531
|
-
* - Has no accessible `state` property
|
|
1532
|
-
* - Cannot be subscribed to (throws error)
|
|
1533
|
-
* - Is rejected by `useBloc` hook (use `useBlocActions` instead)
|
|
1534
|
-
*
|
|
1535
|
-
* @template E - Event union type (discriminated by 'type' property)
|
|
1536
|
-
* @template P - Props type (optional)
|
|
1537
|
-
*
|
|
1538
|
-
* @example
|
|
1539
|
-
* ```typescript
|
|
1540
|
-
* type LogEvent =
|
|
1541
|
-
* | { type: 'info'; message: string }
|
|
1542
|
-
* | { type: 'error'; message: string; error: Error }
|
|
1543
|
-
* | { type: 'warn'; message: string };
|
|
1544
|
-
*
|
|
1545
|
-
* class LoggingVertex extends StatelessVertex<LogEvent> {
|
|
1546
|
-
* constructor() {
|
|
1547
|
-
* super();
|
|
1548
|
-
* this.createHandlers({
|
|
1549
|
-
* info: (event) => console.log('[INFO]', event.message),
|
|
1550
|
-
* error: (event) => console.error('[ERROR]', event.message, event.error),
|
|
1551
|
-
* warn: (event) => console.warn('[WARN]', event.message),
|
|
1552
|
-
* });
|
|
1553
|
-
* }
|
|
1554
|
-
*
|
|
1555
|
-
* info = (message: string) => this.add({ type: 'info', message });
|
|
1556
|
-
* error = (message: string, error: Error) => this.add({ type: 'error', message, error });
|
|
1557
|
-
* warn = (message: string) => this.add({ type: 'warn', message });
|
|
1558
|
-
* }
|
|
1559
|
-
*
|
|
1560
|
-
* // In React component:
|
|
1561
|
-
* const logger = useBlocActions(LoggingVertex);
|
|
1562
|
-
* logger.info('Page loaded');
|
|
1563
|
-
* ```
|
|
1564
|
-
*/
|
|
1565
|
-
export declare abstract class StatelessVertex<E extends DiscriminatedEvent = DiscriminatedEvent, P = undefined> extends StateContainer<EmptyState_2, P> {
|
|
1566
|
-
/* Excluded from this release type: [STATELESS_MARKER] */
|
|
1567
|
-
/* Excluded from this release type: handlers */
|
|
1568
|
-
/* Excluded from this release type: isProcessing */
|
|
1569
|
-
/* Excluded from this release type: eventQueue */
|
|
1570
|
-
constructor();
|
|
1571
|
-
/**
|
|
1572
|
-
* State is not available on StatelessVertex.
|
|
1573
|
-
* @throws Always throws an error when accessed.
|
|
1574
|
-
*/
|
|
1575
|
-
get state(): never;
|
|
1576
|
-
/**
|
|
1577
|
-
* Subscriptions are not available on StatelessVertex.
|
|
1578
|
-
* @throws Always throws an error when called.
|
|
1579
|
-
*/
|
|
1580
|
-
subscribe(_listener: (state: EmptyState_2) => void): never;
|
|
1581
|
-
/**
|
|
1582
|
-
* Register all event handlers with exhaustive type checking.
|
|
1583
|
-
* TypeScript will error if any event type from the union is missing.
|
|
1584
|
-
*
|
|
1585
|
-
* Unlike regular Vertex, handlers do NOT receive an emit function
|
|
1586
|
-
* since StatelessVertex cannot emit state.
|
|
1587
|
-
*
|
|
1588
|
-
* @param handlers - Map of event type to handler function
|
|
1589
|
-
*/
|
|
1590
|
-
protected createHandlers(handlers: StatelessEventHandlerMap<E>): void;
|
|
1591
|
-
/**
|
|
1592
|
-
* Dispatch an event for processing.
|
|
1593
|
-
* Events are processed synchronously; if called during processing,
|
|
1594
|
-
* the event is queued and processed after the current event completes.
|
|
1595
|
-
*
|
|
1596
|
-
* @param event - The event to process (must match the event union type)
|
|
1597
|
-
*/
|
|
1598
|
-
add: (event: E) => void;
|
|
1599
|
-
/* Excluded from this release type: enrichEvent */
|
|
1600
|
-
/* Excluded from this release type: processEvent */
|
|
1601
|
-
/* Excluded from this release type: handleEvent */
|
|
1602
|
-
/**
|
|
1603
|
-
* Called when an error occurs during event processing.
|
|
1604
|
-
* Override to implement custom error handling.
|
|
1605
|
-
*
|
|
1606
|
-
* @param _event - The event that caused the error
|
|
1607
|
-
* @param _error - The error that occurred
|
|
1608
|
-
*/
|
|
1609
|
-
protected onEventError(_event: EventWithMetadata<E>, _error: Error): void;
|
|
1610
|
-
/* Excluded from this release type: emit */
|
|
1611
|
-
/* Excluded from this release type: update */
|
|
1612
|
-
}
|
|
1613
|
-
|
|
1614
750
|
/* Excluded from this release type: StateListener */
|
|
1615
751
|
|
|
1616
752
|
declare const STOP: unique symbol;
|
|
1617
753
|
|
|
1618
|
-
/* Excluded from this release type: stopProxy */
|
|
1619
|
-
|
|
1620
754
|
declare type StopSymbol = typeof STOP;
|
|
1621
755
|
|
|
1622
|
-
/**
|
|
1623
|
-
* Stop tracking and collect all dependencies.
|
|
1624
|
-
*/
|
|
1625
|
-
export declare function stopTrackingProxy(tracker: TrackingProxyState, bloc: StateContainerInstance): Set<StateContainerInstance>;
|
|
1626
|
-
|
|
1627
|
-
/**
|
|
1628
|
-
* Function that subscribes to state changes and returns an unsubscribe function
|
|
1629
|
-
*/
|
|
1630
|
-
export declare type SubscribeFunction = (callback: SubscriptionCallback) => () => void;
|
|
1631
|
-
|
|
1632
|
-
/**
|
|
1633
|
-
* Callback function invoked when subscribed state changes
|
|
1634
|
-
*/
|
|
1635
|
-
export declare type SubscriptionCallback = () => void;
|
|
1636
|
-
|
|
1637
756
|
/**
|
|
1638
757
|
* System events emitted by StateContainer lifecycle
|
|
1639
758
|
*/
|
|
1640
|
-
export declare type SystemEvent = '
|
|
759
|
+
export declare type SystemEvent = 'stateChanged' | 'dispose';
|
|
1641
760
|
|
|
1642
761
|
/* Excluded from this release type: SystemEventHandler */
|
|
1643
762
|
|
|
1644
763
|
/**
|
|
1645
764
|
* Payload types for each system event
|
|
1646
765
|
* @template S - State type
|
|
1647
|
-
* @template P - Props type
|
|
1648
766
|
*/
|
|
1649
|
-
export declare interface SystemEventPayloads<S
|
|
1650
|
-
/** Emitted when props are updated via updateProps() */
|
|
1651
|
-
propsUpdated: {
|
|
1652
|
-
props: P;
|
|
1653
|
-
previousProps: P | undefined;
|
|
1654
|
-
};
|
|
767
|
+
export declare interface SystemEventPayloads<S> {
|
|
1655
768
|
/** Emitted when state changes via emit() or update() */
|
|
1656
769
|
stateChanged: {
|
|
1657
770
|
state: S;
|
|
@@ -1661,220 +774,6 @@ export declare interface SystemEventPayloads<S, P> {
|
|
|
1661
774
|
dispose: void;
|
|
1662
775
|
}
|
|
1663
776
|
|
|
1664
|
-
/**
|
|
1665
|
-
* Run a callback while tracking all bloc dependencies accessed.
|
|
1666
|
-
* Returns both the result and the set of discovered dependencies.
|
|
1667
|
-
*
|
|
1668
|
-
* @example
|
|
1669
|
-
* ```ts
|
|
1670
|
-
* const { result, dependencies } = tracked(() => {
|
|
1671
|
-
* const user = ensure(UserBloc);
|
|
1672
|
-
* return user.fullName; // getter that may access other blocs
|
|
1673
|
-
* });
|
|
1674
|
-
* // dependencies contains UserBloc + any blocs accessed in fullName getter
|
|
1675
|
-
* ```
|
|
1676
|
-
*/
|
|
1677
|
-
export declare function tracked<T>(callback: () => T, options?: TrackedOptions): TrackedResult<T>;
|
|
1678
|
-
|
|
1679
|
-
/**
|
|
1680
|
-
* Context for running tracked callbacks with bloc proxies.
|
|
1681
|
-
* Provides methods to create proxies and check for changes.
|
|
1682
|
-
*/
|
|
1683
|
-
export declare class TrackedContext {
|
|
1684
|
-
private tracker;
|
|
1685
|
-
private proxiedBlocs;
|
|
1686
|
-
private primaryBlocs;
|
|
1687
|
-
constructor();
|
|
1688
|
-
/**
|
|
1689
|
-
* Get a tracking proxy for a bloc instance.
|
|
1690
|
-
* The proxy will track state and getter accesses.
|
|
1691
|
-
*/
|
|
1692
|
-
proxy<T extends StateContainerInstance>(bloc: T): T;
|
|
1693
|
-
/**
|
|
1694
|
-
* Start tracking for a new callback execution.
|
|
1695
|
-
*/
|
|
1696
|
-
start(): void;
|
|
1697
|
-
/**
|
|
1698
|
-
* Stop tracking and get discovered dependencies.
|
|
1699
|
-
* Excludes primary blocs (those explicitly proxied via proxy()).
|
|
1700
|
-
*/
|
|
1701
|
-
stop(): Set<StateContainerInstance>;
|
|
1702
|
-
/**
|
|
1703
|
-
* Check if any tracked state or getters have changed.
|
|
1704
|
-
*/
|
|
1705
|
-
changed(): boolean;
|
|
1706
|
-
/**
|
|
1707
|
-
* Get all primary blocs (those explicitly proxied).
|
|
1708
|
-
*/
|
|
1709
|
-
getPrimaryBlocs(): Set<StateContainerInstance>;
|
|
1710
|
-
/**
|
|
1711
|
-
* Reset the context for reuse.
|
|
1712
|
-
*/
|
|
1713
|
-
reset(): void;
|
|
1714
|
-
}
|
|
1715
|
-
|
|
1716
|
-
/**
|
|
1717
|
-
* Options for the tracked() function.
|
|
1718
|
-
*/
|
|
1719
|
-
export declare interface TrackedOptions {
|
|
1720
|
-
exclude?: StateContainerInstance;
|
|
1721
|
-
}
|
|
1722
|
-
|
|
1723
|
-
/**
|
|
1724
|
-
* Result of running a tracked callback.
|
|
1725
|
-
*/
|
|
1726
|
-
export declare interface TrackedResult<T> {
|
|
1727
|
-
result: T;
|
|
1728
|
-
dependencies: Set<StateContainerInstance>;
|
|
1729
|
-
}
|
|
1730
|
-
|
|
1731
|
-
/**
|
|
1732
|
-
* State for tracking both state property access and getter access.
|
|
1733
|
-
*/
|
|
1734
|
-
export declare interface TrackingProxyState {
|
|
1735
|
-
dependencyState: DependencyState<any>;
|
|
1736
|
-
getterState: GetterState;
|
|
1737
|
-
dependencies: Set<StateContainerInstance>;
|
|
1738
|
-
isTracking: boolean;
|
|
1739
|
-
}
|
|
1740
|
-
|
|
1741
|
-
/**
|
|
1742
|
-
* Event-driven state container using discriminated union events.
|
|
1743
|
-
* Extends StateContainer with event-based state transitions and
|
|
1744
|
-
* compile-time exhaustive checking for event handlers.
|
|
1745
|
-
*
|
|
1746
|
-
* @template S - State type (must be an object)
|
|
1747
|
-
* @template E - Event union type (discriminated by 'type' property)
|
|
1748
|
-
* @template P - Props type (optional)
|
|
1749
|
-
*
|
|
1750
|
-
* @example
|
|
1751
|
-
* ```typescript
|
|
1752
|
-
* type CounterEvent =
|
|
1753
|
-
* | { type: 'increment'; amount: number }
|
|
1754
|
-
* | { type: 'decrement' }
|
|
1755
|
-
* | { type: 'reset' };
|
|
1756
|
-
*
|
|
1757
|
-
* class CounterVertex extends Vertex<{ count: number }, CounterEvent> {
|
|
1758
|
-
* constructor() {
|
|
1759
|
-
* super({ count: 0 });
|
|
1760
|
-
* this.createHandlers({
|
|
1761
|
-
* increment: (event, emit) => {
|
|
1762
|
-
* emit({ count: this.state.count + event.amount });
|
|
1763
|
-
* },
|
|
1764
|
-
* decrement: (_, emit) => {
|
|
1765
|
-
* emit({ count: this.state.count - 1 });
|
|
1766
|
-
* },
|
|
1767
|
-
* reset: (_, emit) => {
|
|
1768
|
-
* emit({ count: 0 });
|
|
1769
|
-
* },
|
|
1770
|
-
* });
|
|
1771
|
-
* }
|
|
1772
|
-
*
|
|
1773
|
-
* increment = (amount = 1) => this.add({ type: 'increment', amount });
|
|
1774
|
-
* }
|
|
1775
|
-
* ```
|
|
1776
|
-
*/
|
|
1777
|
-
export declare abstract class Vertex<S extends object = object, E extends DiscriminatedEvent = DiscriminatedEvent, P = undefined> extends StateContainer<S, P> {
|
|
1778
|
-
/* Excluded from this release type: handlers */
|
|
1779
|
-
/* Excluded from this release type: isProcessing */
|
|
1780
|
-
/* Excluded from this release type: eventQueue */
|
|
1781
|
-
constructor(initialState: S);
|
|
1782
|
-
/**
|
|
1783
|
-
* Register all event handlers with exhaustive type checking.
|
|
1784
|
-
* TypeScript will error if any event type from the union is missing.
|
|
1785
|
-
*
|
|
1786
|
-
* @param handlers - Map of event type to handler function
|
|
1787
|
-
*/
|
|
1788
|
-
protected createHandlers(handlers: EventHandlerMap<E, S>): void;
|
|
1789
|
-
/**
|
|
1790
|
-
* Dispatch an event for processing.
|
|
1791
|
-
* Events are processed synchronously; if called during processing,
|
|
1792
|
-
* the event is queued and processed after the current event completes.
|
|
1793
|
-
*
|
|
1794
|
-
* @param event - The event to process (must match the event union type)
|
|
1795
|
-
*/
|
|
1796
|
-
add: (event: E) => void;
|
|
1797
|
-
/* Excluded from this release type: enrichEvent */
|
|
1798
|
-
/* Excluded from this release type: processEvent */
|
|
1799
|
-
/* Excluded from this release type: handleEvent */
|
|
1800
|
-
/**
|
|
1801
|
-
* Called when an error occurs during event processing.
|
|
1802
|
-
* Override to implement custom error handling.
|
|
1803
|
-
*
|
|
1804
|
-
* @param _event - The event that caused the error
|
|
1805
|
-
* @param _error - The error that occurred
|
|
1806
|
-
*/
|
|
1807
|
-
protected onEventError(_event: EventWithMetadata<E>, _error: Error): void;
|
|
1808
|
-
}
|
|
1809
|
-
|
|
1810
|
-
/* Excluded from this release type: VertexEventHandler */
|
|
1811
|
-
|
|
1812
|
-
/**
|
|
1813
|
-
* Wait until a condition is met on a bloc instance.
|
|
1814
|
-
* Returns the bloc instance when the predicate returns true.
|
|
1815
|
-
* Automatically tracks dependencies accessed in the predicate.
|
|
1816
|
-
*
|
|
1817
|
-
* @example
|
|
1818
|
-
* ```ts
|
|
1819
|
-
* // Wait for bloc state to be ready
|
|
1820
|
-
* const userBloc = await waitUntil(UserBloc, (bloc) => bloc.state.isAuthenticated);
|
|
1821
|
-
*
|
|
1822
|
-
* // Wait using a getter
|
|
1823
|
-
* const userBloc = await waitUntil(UserBloc, (bloc) => bloc.isReady);
|
|
1824
|
-
* ```
|
|
1825
|
-
*/
|
|
1826
|
-
export declare function waitUntil<T extends StateContainerConstructor>(BlocClass: T, predicate: (bloc: InstanceType<T>) => boolean, options?: WaitUntilOptions): Promise<InstanceType<T>>;
|
|
1827
|
-
|
|
1828
|
-
/**
|
|
1829
|
-
* Wait until a condition is met on a selected value from a bloc.
|
|
1830
|
-
* Returns the selected value when the predicate returns true.
|
|
1831
|
-
* Automatically tracks dependencies accessed in selector and predicate.
|
|
1832
|
-
*
|
|
1833
|
-
* @example
|
|
1834
|
-
* ```ts
|
|
1835
|
-
* // Wait for layout to be set and get it directly
|
|
1836
|
-
* const layout = await waitUntil(
|
|
1837
|
-
* LayoutBloc,
|
|
1838
|
-
* (bloc) => bloc.state.currentLayout,
|
|
1839
|
-
* (layout) => layout !== null
|
|
1840
|
-
* );
|
|
1841
|
-
*
|
|
1842
|
-
* // Using a getter as selector
|
|
1843
|
-
* const user = await waitUntil(
|
|
1844
|
-
* UserBloc,
|
|
1845
|
-
* (bloc) => bloc.currentUser,
|
|
1846
|
-
* (user) => user !== null
|
|
1847
|
-
* );
|
|
1848
|
-
* ```
|
|
1849
|
-
*/
|
|
1850
|
-
export declare function waitUntil<T extends StateContainerConstructor, TSelected>(BlocClass: T, selector: (bloc: InstanceType<T>) => TSelected, predicate: (selected: TSelected) => boolean, options?: WaitUntilOptions): Promise<TSelected>;
|
|
1851
|
-
|
|
1852
|
-
export declare class WaitUntilAbortedError extends Error {
|
|
1853
|
-
constructor();
|
|
1854
|
-
}
|
|
1855
|
-
|
|
1856
|
-
export declare class WaitUntilDisposedError extends Error {
|
|
1857
|
-
constructor(blocName: string);
|
|
1858
|
-
}
|
|
1859
|
-
|
|
1860
|
-
export declare interface WaitUntilOptions {
|
|
1861
|
-
instanceId?: string;
|
|
1862
|
-
timeout?: number;
|
|
1863
|
-
signal?: AbortSignal;
|
|
1864
|
-
}
|
|
1865
|
-
|
|
1866
|
-
export declare class WaitUntilTimeoutError extends Error {
|
|
1867
|
-
constructor(timeout: number);
|
|
1868
|
-
}
|
|
1869
|
-
|
|
1870
|
-
/**
|
|
1871
|
-
* Log a warning message (tree-shakeable export)
|
|
1872
|
-
* @param context - Context identifier (module or component name)
|
|
1873
|
-
* @param message - Log message
|
|
1874
|
-
* @param data - Optional structured data
|
|
1875
|
-
*/
|
|
1876
|
-
export declare const warn: (context: string, message: string, data?: any) => void;
|
|
1877
|
-
|
|
1878
777
|
export declare const watch: WatchFn;
|
|
1879
778
|
|
|
1880
779
|
/**
|