@blac/core 2.0.5 → 2.0.7

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (55) hide show
  1. package/README.md +98 -129
  2. package/dist/StateContainerRegistry-COxgpYAw.cjs +601 -0
  3. package/dist/StateContainerRegistry-COxgpYAw.cjs.map +1 -0
  4. package/dist/StateContainerRegistry-DS_wyKck.js +566 -0
  5. package/dist/StateContainerRegistry-DS_wyKck.js.map +1 -0
  6. package/dist/branded-DndTHjv2.cjs +18 -0
  7. package/dist/branded-DndTHjv2.cjs.map +1 -0
  8. package/dist/branded-mwGzzPF1.js +13 -0
  9. package/dist/branded-mwGzzPF1.js.map +1 -0
  10. package/dist/config-BD9MkJ0k.js +42 -0
  11. package/dist/config-BD9MkJ0k.js.map +1 -0
  12. package/dist/config-DTuCbHcJ.cjs +101 -0
  13. package/dist/config-DTuCbHcJ.cjs.map +1 -0
  14. package/dist/constants.d.cts +73 -0
  15. package/dist/constants.d.ts +0 -8
  16. package/dist/core/Cubit.d.ts +0 -17
  17. package/dist/core/StateContainer.d.ts +37 -88
  18. package/dist/core/StateContainerRegistry.d.ts +2 -3
  19. package/dist/core/symbols.d.ts +2 -0
  20. package/dist/debug.cjs +12 -0
  21. package/dist/debug.d.cts +35 -0
  22. package/dist/debug.js +3 -0
  23. package/dist/decorators/blac.d.ts +3 -10
  24. package/dist/index.cjs +175 -1613
  25. package/dist/index.cjs.map +1 -1
  26. package/dist/index.d.cts +2 -4
  27. package/dist/index.d.ts +2 -4
  28. package/dist/index.js +142 -1564
  29. package/dist/index.js.map +1 -1
  30. package/dist/plugin/BlacPlugin.d.ts +34 -3
  31. package/dist/plugins.cjs +4 -0
  32. package/dist/plugins.d.cts +25 -0
  33. package/dist/plugins.js +2 -0
  34. package/dist/registry/management.d.ts +1 -1
  35. package/dist/resolve-dependencies-8xtWXd53.js +648 -0
  36. package/dist/resolve-dependencies-8xtWXd53.js.map +1 -0
  37. package/dist/resolve-dependencies-DJ2UBTq1.cjs +773 -0
  38. package/dist/resolve-dependencies-DJ2UBTq1.cjs.map +1 -0
  39. package/dist/tracked-12W-U7tq.js +181 -0
  40. package/dist/tracked-12W-U7tq.js.map +1 -0
  41. package/dist/tracked-DLnq137F.cjs +216 -0
  42. package/dist/tracked-DLnq137F.cjs.map +1 -0
  43. package/dist/tracking.cjs +18 -0
  44. package/dist/tracking.d.cts +9 -0
  45. package/dist/tracking.js +2 -0
  46. package/dist/types/utilities.d.ts +0 -1
  47. package/dist/types.cjs +3 -0
  48. package/dist/types.d.cts +8 -0
  49. package/dist/types.js +2 -0
  50. package/dist/utils/idGenerator.d.ts +0 -16
  51. package/dist/utils/static-props.d.ts +0 -7
  52. package/dist/watch-entry.cjs +7 -0
  53. package/dist/watch-entry.d.cts +26 -0
  54. package/dist/watch-entry.js +2 -0
  55. package/package.json +58 -3
@@ -0,0 +1,42 @@
1
+ import { n as globalRegistry } from "./StateContainerRegistry-DS_wyKck.js";
2
+ //#region src/registry/queries.ts
3
+ function hasInstance(BlocClass, instanceKey) {
4
+ return globalRegistry.hasInstance(BlocClass, instanceKey);
5
+ }
6
+ function getRefCount(BlocClass, instanceKey) {
7
+ return globalRegistry.getRefCount(BlocClass, instanceKey);
8
+ }
9
+ function getAll(BlocClass) {
10
+ return globalRegistry.getAll(BlocClass);
11
+ }
12
+ function forEach(BlocClass, callback) {
13
+ globalRegistry.forEach(BlocClass, callback);
14
+ }
15
+ //#endregion
16
+ //#region src/registry/management.ts
17
+ function clear(BlocClass) {
18
+ globalRegistry.clear(BlocClass);
19
+ }
20
+ function clearAll() {
21
+ globalRegistry.clearAll();
22
+ }
23
+ function register(BlocClass) {
24
+ globalRegistry.register(BlocClass);
25
+ }
26
+ //#endregion
27
+ //#region src/registry/config.ts
28
+ let _registry = globalRegistry;
29
+ function getRegistry() {
30
+ return _registry;
31
+ }
32
+ function setRegistry(registry) {
33
+ _registry.clearAll();
34
+ _registry = registry;
35
+ }
36
+ function getStats() {
37
+ return _registry.getStats();
38
+ }
39
+ //#endregion
40
+ export { clearAll as a, getAll as c, clear as i, getRefCount as l, getStats as n, register as o, setRegistry as r, forEach as s, getRegistry as t, hasInstance as u };
41
+
42
+ //# sourceMappingURL=config-BD9MkJ0k.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"config-BD9MkJ0k.js","names":[],"sources":["../src/registry/queries.ts","../src/registry/management.ts","../src/registry/config.ts"],"sourcesContent":["import { globalRegistry } from '../core/StateContainerRegistry';\nimport type {\n StateContainerConstructor,\n InstanceReadonlyState,\n} from '../types/utilities';\n\nexport function hasInstance<T extends StateContainerConstructor>(\n BlocClass: T,\n instanceKey?: string,\n): boolean {\n return globalRegistry.hasInstance(BlocClass, instanceKey);\n}\n\nexport function getRefCount<T extends StateContainerConstructor>(\n BlocClass: T,\n instanceKey?: string,\n): number {\n return globalRegistry.getRefCount(BlocClass, instanceKey);\n}\n\nexport function getAll<T extends StateContainerConstructor>(\n BlocClass: T,\n): InstanceReadonlyState<T>[] {\n return globalRegistry.getAll(BlocClass);\n}\n\nexport function forEach<T extends StateContainerConstructor>(\n BlocClass: T,\n callback: (instance: InstanceReadonlyState<T>) => void,\n): void {\n globalRegistry.forEach(BlocClass, callback);\n}\n","import { globalRegistry } from '../core/StateContainerRegistry';\nimport type { StateContainerConstructor } from '../types/utilities';\n\nexport function clear<T extends StateContainerConstructor>(BlocClass: T): void {\n globalRegistry.clear(BlocClass);\n}\n\nexport function clearAll(): void {\n globalRegistry.clearAll();\n}\n\nexport function register<T extends StateContainerConstructor>(\n BlocClass: T,\n): void {\n globalRegistry.register(BlocClass);\n}\n","import {\n globalRegistry,\n StateContainerRegistry,\n} from '../core/StateContainerRegistry';\n\nlet _registry = globalRegistry;\n\nexport function getRegistry(): StateContainerRegistry {\n return _registry;\n}\n\nexport function setRegistry(registry: StateContainerRegistry): void {\n _registry.clearAll();\n _registry = registry;\n}\n\nexport function getStats(): {\n registeredTypes: number;\n totalInstances: number;\n typeBreakdown: Record<string, number>;\n} {\n return _registry.getStats();\n}\n"],"mappings":";;AAMA,SAAgB,YACd,WACA,aACS;AACT,QAAO,eAAe,YAAY,WAAW,YAAY;;AAG3D,SAAgB,YACd,WACA,aACQ;AACR,QAAO,eAAe,YAAY,WAAW,YAAY;;AAG3D,SAAgB,OACd,WAC4B;AAC5B,QAAO,eAAe,OAAO,UAAU;;AAGzC,SAAgB,QACd,WACA,UACM;AACN,gBAAe,QAAQ,WAAW,SAAS;;;;AC3B7C,SAAgB,MAA2C,WAAoB;AAC7E,gBAAe,MAAM,UAAU;;AAGjC,SAAgB,WAAiB;AAC/B,gBAAe,UAAU;;AAG3B,SAAgB,SACd,WACM;AACN,gBAAe,SAAS,UAAU;;;;ACTpC,IAAI,YAAY;AAEhB,SAAgB,cAAsC;AACpD,QAAO;;AAGT,SAAgB,YAAY,UAAwC;AAClE,WAAU,UAAU;AACpB,aAAY;;AAGd,SAAgB,WAId;AACA,QAAO,UAAU,UAAU"}
@@ -0,0 +1,101 @@
1
+ const require_StateContainerRegistry = require("./StateContainerRegistry-COxgpYAw.cjs");
2
+ //#region src/registry/queries.ts
3
+ function hasInstance(BlocClass, instanceKey) {
4
+ return require_StateContainerRegistry.globalRegistry.hasInstance(BlocClass, instanceKey);
5
+ }
6
+ function getRefCount(BlocClass, instanceKey) {
7
+ return require_StateContainerRegistry.globalRegistry.getRefCount(BlocClass, instanceKey);
8
+ }
9
+ function getAll(BlocClass) {
10
+ return require_StateContainerRegistry.globalRegistry.getAll(BlocClass);
11
+ }
12
+ function forEach(BlocClass, callback) {
13
+ require_StateContainerRegistry.globalRegistry.forEach(BlocClass, callback);
14
+ }
15
+ //#endregion
16
+ //#region src/registry/management.ts
17
+ function clear(BlocClass) {
18
+ require_StateContainerRegistry.globalRegistry.clear(BlocClass);
19
+ }
20
+ function clearAll() {
21
+ require_StateContainerRegistry.globalRegistry.clearAll();
22
+ }
23
+ function register(BlocClass) {
24
+ require_StateContainerRegistry.globalRegistry.register(BlocClass);
25
+ }
26
+ //#endregion
27
+ //#region src/registry/config.ts
28
+ let _registry = require_StateContainerRegistry.globalRegistry;
29
+ function getRegistry() {
30
+ return _registry;
31
+ }
32
+ function setRegistry(registry) {
33
+ _registry.clearAll();
34
+ _registry = registry;
35
+ }
36
+ function getStats() {
37
+ return _registry.getStats();
38
+ }
39
+ //#endregion
40
+ Object.defineProperty(exports, "clear", {
41
+ enumerable: true,
42
+ get: function() {
43
+ return clear;
44
+ }
45
+ });
46
+ Object.defineProperty(exports, "clearAll", {
47
+ enumerable: true,
48
+ get: function() {
49
+ return clearAll;
50
+ }
51
+ });
52
+ Object.defineProperty(exports, "forEach", {
53
+ enumerable: true,
54
+ get: function() {
55
+ return forEach;
56
+ }
57
+ });
58
+ Object.defineProperty(exports, "getAll", {
59
+ enumerable: true,
60
+ get: function() {
61
+ return getAll;
62
+ }
63
+ });
64
+ Object.defineProperty(exports, "getRefCount", {
65
+ enumerable: true,
66
+ get: function() {
67
+ return getRefCount;
68
+ }
69
+ });
70
+ Object.defineProperty(exports, "getRegistry", {
71
+ enumerable: true,
72
+ get: function() {
73
+ return getRegistry;
74
+ }
75
+ });
76
+ Object.defineProperty(exports, "getStats", {
77
+ enumerable: true,
78
+ get: function() {
79
+ return getStats;
80
+ }
81
+ });
82
+ Object.defineProperty(exports, "hasInstance", {
83
+ enumerable: true,
84
+ get: function() {
85
+ return hasInstance;
86
+ }
87
+ });
88
+ Object.defineProperty(exports, "register", {
89
+ enumerable: true,
90
+ get: function() {
91
+ return register;
92
+ }
93
+ });
94
+ Object.defineProperty(exports, "setRegistry", {
95
+ enumerable: true,
96
+ get: function() {
97
+ return setRegistry;
98
+ }
99
+ });
100
+
101
+ //# sourceMappingURL=config-DTuCbHcJ.cjs.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"config-DTuCbHcJ.cjs","names":["globalRegistry","globalRegistry"],"sources":["../src/registry/queries.ts","../src/registry/management.ts","../src/registry/config.ts"],"sourcesContent":["import { globalRegistry } from '../core/StateContainerRegistry';\nimport type {\n StateContainerConstructor,\n InstanceReadonlyState,\n} from '../types/utilities';\n\nexport function hasInstance<T extends StateContainerConstructor>(\n BlocClass: T,\n instanceKey?: string,\n): boolean {\n return globalRegistry.hasInstance(BlocClass, instanceKey);\n}\n\nexport function getRefCount<T extends StateContainerConstructor>(\n BlocClass: T,\n instanceKey?: string,\n): number {\n return globalRegistry.getRefCount(BlocClass, instanceKey);\n}\n\nexport function getAll<T extends StateContainerConstructor>(\n BlocClass: T,\n): InstanceReadonlyState<T>[] {\n return globalRegistry.getAll(BlocClass);\n}\n\nexport function forEach<T extends StateContainerConstructor>(\n BlocClass: T,\n callback: (instance: InstanceReadonlyState<T>) => void,\n): void {\n globalRegistry.forEach(BlocClass, callback);\n}\n","import { globalRegistry } from '../core/StateContainerRegistry';\nimport type { StateContainerConstructor } from '../types/utilities';\n\nexport function clear<T extends StateContainerConstructor>(BlocClass: T): void {\n globalRegistry.clear(BlocClass);\n}\n\nexport function clearAll(): void {\n globalRegistry.clearAll();\n}\n\nexport function register<T extends StateContainerConstructor>(\n BlocClass: T,\n): void {\n globalRegistry.register(BlocClass);\n}\n","import {\n globalRegistry,\n StateContainerRegistry,\n} from '../core/StateContainerRegistry';\n\nlet _registry = globalRegistry;\n\nexport function getRegistry(): StateContainerRegistry {\n return _registry;\n}\n\nexport function setRegistry(registry: StateContainerRegistry): void {\n _registry.clearAll();\n _registry = registry;\n}\n\nexport function getStats(): {\n registeredTypes: number;\n totalInstances: number;\n typeBreakdown: Record<string, number>;\n} {\n return _registry.getStats();\n}\n"],"mappings":";;AAMA,SAAgB,YACd,WACA,aACS;AACT,QAAOA,+BAAAA,eAAe,YAAY,WAAW,YAAY;;AAG3D,SAAgB,YACd,WACA,aACQ;AACR,QAAOA,+BAAAA,eAAe,YAAY,WAAW,YAAY;;AAG3D,SAAgB,OACd,WAC4B;AAC5B,QAAOA,+BAAAA,eAAe,OAAO,UAAU;;AAGzC,SAAgB,QACd,WACA,UACM;AACN,gCAAA,eAAe,QAAQ,WAAW,SAAS;;;;AC3B7C,SAAgB,MAA2C,WAAoB;AAC7E,gCAAA,eAAe,MAAM,UAAU;;AAGjC,SAAgB,WAAiB;AAC/B,gCAAA,eAAe,UAAU;;AAG3B,SAAgB,SACd,WACM;AACN,gCAAA,eAAe,SAAS,UAAU;;;;ACTpC,IAAI,YAAYC,+BAAAA;AAEhB,SAAgB,cAAsC;AACpD,QAAO;;AAGT,SAAgB,YAAY,UAAwC;AAClE,WAAU,UAAU;AACpB,aAAY;;AAGd,SAAgB,WAId;AACA,QAAO,UAAU,UAAU"}
@@ -0,0 +1,73 @@
1
+ /**
2
+ * Default configuration constants for BlaC
3
+ *
4
+ * Centralized location for all magic numbers and default values.
5
+ */
6
+ /**
7
+ * Default configuration constants for BlaC
8
+ */
9
+ export declare const BLAC_DEFAULTS: {
10
+ /**
11
+ * Default instance key for shared instances
12
+ */
13
+ readonly DEFAULT_INSTANCE_KEY: "default";
14
+ /**
15
+ * Maximum getter nesting depth (prevents infinite recursion)
16
+ */
17
+ readonly MAX_GETTER_DEPTH: 10;
18
+ /**
19
+ * Default cleanup interval for subscriptions (30 seconds)
20
+ */
21
+ readonly CLEANUP_INTERVAL_MS: 30000;
22
+ /**
23
+ * Cleanup interval for weak reference stage (10 seconds)
24
+ */
25
+ readonly WEAKREF_CLEANUP_INTERVAL_MS: 10000;
26
+ /**
27
+ * Default maximum subscriptions per container
28
+ */
29
+ readonly MAX_SUBSCRIPTIONS: 1000;
30
+ /**
31
+ * Maximum subscriptions for high-performance mode
32
+ */
33
+ readonly MAX_SUBSCRIPTIONS_HIGH_PERF: 10000;
34
+ /**
35
+ * Default timeout for pipeline execution (5 seconds)
36
+ */
37
+ readonly PIPELINE_TIMEOUT_MS: 5000;
38
+ /**
39
+ * Cleanup interval for high-performance mode (5 seconds)
40
+ */
41
+ readonly CLEANUP_INTERVAL_HIGH_PERF_MS: 5000;
42
+ /**
43
+ * Maximum number of stages in a pipeline
44
+ */
45
+ readonly MAX_PIPELINE_STAGES: 30;
46
+ };
47
+ /**
48
+ * Static property names for StateContainer classes
49
+ * Used for feature flags and configuration on bloc classes
50
+ */
51
+ export declare const BLAC_STATIC_PROPS: {
52
+ /**
53
+ * Mark a bloc to never be auto-disposed (kept alive permanently)
54
+ */
55
+ readonly KEEP_ALIVE: "keepAlive";
56
+ /**
57
+ * Exclude a bloc from DevTools reporting (prevents infinite loops)
58
+ */
59
+ readonly EXCLUDE_FROM_DEVTOOLS: "__excludeFromDevTools";
60
+ };
61
+ /**
62
+ * ID generation patterns and constants
63
+ */
64
+ export declare const BLAC_ID_PATTERNS: {
65
+ /**
66
+ * Length of generated ID portion (9 characters from base36)
67
+ */
68
+ readonly ID_LENGTH: 9;
69
+ };
70
+ /**
71
+ * Standard error message prefix
72
+ */
73
+ export declare const BLAC_ERROR_PREFIX: "[BlaC]";
@@ -49,10 +49,6 @@ export declare const BLAC_DEFAULTS: {
49
49
  * Used for feature flags and configuration on bloc classes
50
50
  */
51
51
  export declare const BLAC_STATIC_PROPS: {
52
- /**
53
- * Mark a bloc as isolated (each component gets its own instance)
54
- */
55
- readonly ISOLATED: "isolated";
56
52
  /**
57
53
  * Mark a bloc to never be auto-disposed (kept alive permanently)
58
54
  */
@@ -66,10 +62,6 @@ export declare const BLAC_STATIC_PROPS: {
66
62
  * ID generation patterns and constants
67
63
  */
68
64
  export declare const BLAC_ID_PATTERNS: {
69
- /**
70
- * Prefix for isolated instance keys
71
- */
72
- readonly ISOLATED_PREFIX: "isolated-";
73
65
  /**
74
66
  * Length of generated ID portion (9 characters from base36)
75
67
  */
@@ -1,24 +1,7 @@
1
1
  import { StateContainer } from './StateContainer';
2
- /**
3
- * Simple state container with direct state emission.
4
- * Extends StateContainer with public methods for emitting and updating state.
5
- *
6
- * @template S - State type
7
- */
8
2
  export declare abstract class Cubit<S extends object = any> extends StateContainer<S> {
9
3
  constructor(initialState: S);
10
- /**
11
- * Replace state with a new value and notify all listeners
12
- * @param newState - The new state value
13
- */
14
4
  emit(newState: S): void;
15
- /**
16
- * Transform current state using an updater function and emit the new state
17
- * @param updater - Function that receives current state and returns new state
18
- */
19
5
  update(updater: (current: S) => S): void;
20
- /**
21
- * Merge partial state changes into current state (only for object states)
22
- */
23
6
  patch: S extends object ? (partial: Partial<S>) => void : never;
24
7
  }
@@ -1,126 +1,75 @@
1
1
  import type { StateContainerConstructor } from '../types/utilities';
2
- /**
3
- * Configuration options for initializing a StateContainer instance
4
- */
2
+ import { EMIT, UPDATE } from './symbols';
5
3
  export interface StateContainerConfig {
6
- /** Display name for the instance (defaults to class name) */
7
4
  name?: string;
8
- /** Enable debug logging for this instance */
9
5
  debug?: boolean;
10
- /** Custom instance identifier */
11
6
  instanceId?: string;
12
7
  }
13
- /**
14
- * Listener function for state changes
15
- * @internal
16
- */
8
+ export type HydrationStatus = 'idle' | 'hydrating' | 'hydrated' | 'error';
17
9
  type StateListener<S> = (state: S) => void;
18
- /**
19
- * System events emitted by StateContainer lifecycle
20
- */
21
- export type SystemEvent = 'stateChanged' | 'dispose';
22
- /**
23
- * Payload types for each system event
24
- * @template S - State type
25
- */
10
+ export type SystemEvent = 'stateChanged' | 'dispose' | 'hydrationChanged';
26
11
  export interface SystemEventPayloads<S> {
27
- /** Emitted when state changes via emit() or update() */
28
12
  stateChanged: {
29
13
  state: S;
30
14
  previousState: S;
31
15
  };
32
- /** Emitted when the instance is disposed */
33
16
  dispose: void;
17
+ hydrationChanged: {
18
+ status: HydrationStatus;
19
+ previousStatus: HydrationStatus;
20
+ error?: Error;
21
+ changedWhileHydrating: boolean;
22
+ };
34
23
  }
35
- /**
36
- * Handler function for system events
37
- * @internal
38
- */
39
24
  type SystemEventHandler<S, E extends SystemEvent> = (payload: SystemEventPayloads<S>[E]) => void;
40
- /**
41
- * Abstract base class for all state containers in BlaC.
42
- * Provides lifecycle management, subscription handling, ref counting,
43
- * and integration with the global registry.
44
- *
45
- * @template S - State type managed by this container
46
- *
47
- * @example
48
- * ```ts
49
- * class CounterBloc extends StateContainer<{ count: number }> {
50
- * constructor() {
51
- * super({ count: 0 });
52
- * }
53
- * increment() {
54
- * this.emit({ count: this.state.count + 1 });
55
- * }
56
- * }
57
- * ```
58
- */
59
25
  export declare abstract class StateContainer<S extends object = any> {
60
26
  static __excludeFromDevTools: boolean;
61
27
  static enableStackTrace: boolean;
62
28
  private _state;
63
- private readonly listeners;
29
+ private readonly _listeners;
64
30
  private _disposed;
65
- private config;
66
- private readonly systemEventHandlers;
67
- /** Display name for this instance */
31
+ private _hydrationStatus;
32
+ private _hydrationError?;
33
+ private _changedWhileHydrating;
34
+ private _hydrationPromise;
35
+ private _resolveHydrationPromise?;
36
+ private _rejectHydrationPromise?;
37
+ private _hydrationPromiseSettled;
38
+ private _config;
39
+ private readonly _systemEventHandlers;
40
+ private _dependencies;
68
41
  name: string;
69
- /** Whether debug logging is enabled */
70
42
  debug: boolean;
71
- /** Unique identifier for this instance */
72
43
  instanceId: string;
73
- /** Timestamp when this instance was created */
74
44
  createdAt: number;
75
- private _dependencies;
45
+ lastUpdateTimestamp: number;
76
46
  get dependencies(): ReadonlyMap<StateContainerConstructor, string>;
77
47
  protected depend<T extends StateContainerConstructor>(Type: T, instanceKey?: string): () => InstanceType<T>;
78
48
  constructor(initialState: S);
79
- /**
80
- * Initialize configuration for this instance.
81
- * Called by the registry after construction.
82
- * @param config - Configuration options
83
- */
84
49
  initConfig(config: StateContainerConfig): void;
85
- /** Current state value */
86
50
  get state(): Readonly<S>;
87
- /** Whether this instance has been disposed */
88
51
  get isDisposed(): boolean;
89
- /**
90
- * Subscribe to state changes
91
- * @param listener - Function called when state changes
92
- * @returns Unsubscribe function
93
- */
52
+ get hydrationStatus(): HydrationStatus;
53
+ get hydrationError(): Error | undefined;
54
+ get isHydrated(): boolean;
55
+ get changedWhileHydrating(): boolean;
94
56
  subscribe(listener: StateListener<S>): () => void;
95
- /**
96
- * Dispose this instance and clean up resources.
97
- * Clears all listeners and emits the 'dispose' system event.
98
- */
99
57
  dispose(): void;
100
- /**
101
- * Emit a new state value and notify all listeners.
102
- * @param newState - The new state value
103
- * @protected
104
- */
105
- protected emit(newState: S): void;
58
+ protected [EMIT](newState: S): void;
59
+ protected [UPDATE](updater: (current: S) => S): void;
60
+ beginHydration(): void;
61
+ applyHydratedState(newState: S): boolean;
62
+ finishHydration(): void;
63
+ failHydration(error: Error): void;
64
+ waitForHydration(): Promise<void>;
106
65
  private captureStackTrace;
107
66
  private formatStackLine;
108
67
  private cleanFilePath;
109
- /** Timestamp of the last state update */
110
- lastUpdateTimestamp: number;
111
- /**
112
- * Update state using a transform function.
113
- * @param updater - Function that receives current state and returns new state
114
- * @protected
115
- */
116
- protected update(updater: (current: S) => S): void;
117
- /**
118
- * Subscribe to system lifecycle events.
119
- * @param event - The event type to listen for
120
- * @param handler - Handler function called when event occurs
121
- * @returns Unsubscribe function
122
- * @protected
123
- */
68
+ private applyState;
69
+ private setHydrationStatus;
70
+ private ensureHydrationPromise;
71
+ private resolveHydration;
72
+ private rejectHydration;
124
73
  protected onSystemEvent: <E extends SystemEvent>(event: E, handler: SystemEventHandler<S, E>) => (() => void);
125
74
  private emitSystemEvent;
126
75
  }
@@ -36,7 +36,7 @@ export type LifecycleListener<E extends LifecycleEvent> = E extends 'created' ?
36
36
  export declare class StateContainerRegistry {
37
37
  private readonly instancesByConstructor;
38
38
  private readonly types;
39
- private readonly typeConfigs;
39
+ private readonly registeredTypeNames;
40
40
  private readonly listeners;
41
41
  /**
42
42
  * Register a type for lifecycle event tracking
@@ -46,10 +46,9 @@ export declare class StateContainerRegistry {
46
46
  /**
47
47
  * Register a StateContainer class with configuration
48
48
  * @param constructor - The StateContainer class constructor
49
- * @param isolated - Whether instances should be isolated (component-scoped)
50
49
  * @throws Error if type is already registered
51
50
  */
52
- register<T extends StateContainerConstructor>(constructor: T, isolated?: boolean): void;
51
+ register<T extends StateContainerConstructor>(constructor: T): void;
53
52
  private ensureInstancesMap;
54
53
  /**
55
54
  * Get the instances Map for a specific class (public API for stats/debugging)
@@ -0,0 +1,2 @@
1
+ export declare const EMIT: unique symbol;
2
+ export declare const UPDATE: unique symbol;
package/dist/debug.cjs ADDED
@@ -0,0 +1,12 @@
1
+ Object.defineProperty(exports, Symbol.toStringTag, { value: "Module" });
2
+ const require_StateContainerRegistry = require("./StateContainerRegistry-COxgpYAw.cjs");
3
+ const require_config = require("./config-DTuCbHcJ.cjs");
4
+ exports.forEach = require_config.forEach;
5
+ exports.getAll = require_config.getAll;
6
+ exports.getRefCount = require_config.getRefCount;
7
+ exports.getRegistry = require_config.getRegistry;
8
+ exports.getStats = require_config.getStats;
9
+ exports.globalRegistry = require_StateContainerRegistry.globalRegistry;
10
+ exports.hasInstance = require_config.hasInstance;
11
+ exports.register = require_config.register;
12
+ exports.setRegistry = require_config.setRegistry;
@@ -0,0 +1,35 @@
1
+ /**
2
+ * Debug/Advanced Subpath Export
3
+ *
4
+ * Advanced registry introspection and debugging utilities.
5
+ * Import from '@blac/core/debug'
6
+ *
7
+ * These utilities are intended for debugging, testing, and advanced use cases.
8
+ * Most applications don't need these - use the main '@blac/core' exports instead.
9
+ *
10
+ * @example
11
+ * ```typescript
12
+ * import { getStats, globalRegistry, hasInstance } from '@blac/core/debug';
13
+ *
14
+ * // Get registry statistics
15
+ * const stats = getStats();
16
+ * console.log(`Total instances: ${stats.totalInstances}`);
17
+ *
18
+ * // Check if an instance exists
19
+ * if (hasInstance(UserBloc)) {
20
+ * console.log('UserBloc is registered');
21
+ * }
22
+ *
23
+ * // Iterate over all instances of a type
24
+ * forEach(UserBloc, (instance) => {
25
+ * console.log(instance.state);
26
+ * });
27
+ * ```
28
+ *
29
+ * @packageDocumentation
30
+ */
31
+ export { hasInstance, getRefCount, getAll, forEach } from './registry/queries';
32
+ export { register } from './registry/management';
33
+ export { getRegistry, setRegistry, getStats } from './registry/config';
34
+ export { globalRegistry } from './core/StateContainerRegistry';
35
+ export type { LifecycleEvent, LifecycleListener, InstanceEntry, } from './core/StateContainerRegistry';
package/dist/debug.js ADDED
@@ -0,0 +1,3 @@
1
+ import { n as globalRegistry } from "./StateContainerRegistry-DS_wyKck.js";
2
+ import { c as getAll, l as getRefCount, n as getStats, o as register, r as setRegistry, s as forEach, t as getRegistry, u as hasInstance } from "./config-BD9MkJ0k.js";
3
+ export { forEach, getAll, getRefCount, getRegistry, getStats, globalRegistry, hasInstance, register, setRegistry };
@@ -3,12 +3,8 @@
3
3
  * Only one option can be specified at a time (union type).
4
4
  */
5
5
  export type BlacOptions =
6
- /** Mark bloc as isolated (each component gets its own instance) */
7
- {
8
- isolated: true;
9
- }
10
6
  /** Mark bloc to never be auto-disposed when ref count reaches 0 */
11
- | {
7
+ {
12
8
  keepAlive: true;
13
9
  }
14
10
  /** Exclude bloc from DevTools tracking (prevents infinite loops) */
@@ -20,9 +16,6 @@ export type BlacOptions =
20
16
  *
21
17
  * @example Decorator syntax (requires experimentalDecorators or TC39 decorators)
22
18
  * ```ts
23
- * @blac({ isolated: true })
24
- * class FormBloc extends Cubit<FormState> {}
25
- *
26
19
  * @blac({ keepAlive: true })
27
20
  * class AuthBloc extends Cubit<AuthState> {}
28
21
  *
@@ -32,8 +25,8 @@ export type BlacOptions =
32
25
  *
33
26
  * @example Function syntax (no decorator support needed)
34
27
  * ```ts
35
- * const FormBloc = blac({ isolated: true })(
36
- * class extends Cubit<FormState> {}
28
+ * const AuthBloc = blac({ keepAlive: true })(
29
+ * class extends Cubit<AuthState> {}
37
30
  * );
38
31
  * ```
39
32
  */