@blac/core 2.0.6 → 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 (46) hide show
  1. package/README.md +2 -5
  2. package/dist/{StateContainerRegistry-CVPTMaHn.cjs → StateContainerRegistry-COxgpYAw.cjs} +6 -34
  3. package/dist/StateContainerRegistry-COxgpYAw.cjs.map +1 -0
  4. package/dist/{StateContainerRegistry-Brmferpf.js → StateContainerRegistry-DS_wyKck.js} +7 -29
  5. package/dist/StateContainerRegistry-DS_wyKck.js.map +1 -0
  6. package/dist/{config-BmFnPVM0.js → config-BD9MkJ0k.js} +4 -4
  7. package/dist/{config-BmFnPVM0.js.map → config-BD9MkJ0k.js.map} +1 -1
  8. package/dist/{config-BInS_9WT.cjs → config-DTuCbHcJ.cjs} +4 -4
  9. package/dist/{config-BInS_9WT.cjs.map → config-DTuCbHcJ.cjs.map} +1 -1
  10. package/dist/constants.d.cts +0 -8
  11. package/dist/constants.d.ts +0 -8
  12. package/dist/core/Cubit.d.ts +0 -17
  13. package/dist/core/StateContainer.d.ts +12 -113
  14. package/dist/core/StateContainerRegistry.d.ts +2 -3
  15. package/dist/core/symbols.d.ts +2 -0
  16. package/dist/debug.cjs +2 -2
  17. package/dist/debug.js +2 -2
  18. package/dist/decorators/blac.d.ts +3 -10
  19. package/dist/index.cjs +54 -146
  20. package/dist/index.cjs.map +1 -1
  21. package/dist/index.d.cts +1 -2
  22. package/dist/index.d.ts +1 -2
  23. package/dist/index.js +53 -145
  24. package/dist/index.js.map +1 -1
  25. package/dist/plugin/BlacPlugin.d.ts +0 -2
  26. package/dist/plugins.cjs +1 -1
  27. package/dist/plugins.js +1 -1
  28. package/dist/registry/management.d.ts +1 -1
  29. package/dist/{resolve-dependencies-Cvq0glJF.js → resolve-dependencies-8xtWXd53.js} +2 -2
  30. package/dist/{resolve-dependencies-Cvq0glJF.js.map → resolve-dependencies-8xtWXd53.js.map} +1 -1
  31. package/dist/{resolve-dependencies-B22YjFGk.cjs → resolve-dependencies-DJ2UBTq1.cjs} +2 -2
  32. package/dist/{resolve-dependencies-B22YjFGk.cjs.map → resolve-dependencies-DJ2UBTq1.cjs.map} +1 -1
  33. package/dist/{tracked-I_q9buYg.js → tracked-12W-U7tq.js} +3 -3
  34. package/dist/{tracked-I_q9buYg.js.map → tracked-12W-U7tq.js.map} +1 -1
  35. package/dist/{tracked-B_MUXIpe.cjs → tracked-DLnq137F.cjs} +3 -3
  36. package/dist/{tracked-B_MUXIpe.cjs.map → tracked-DLnq137F.cjs.map} +1 -1
  37. package/dist/tracking.cjs +1 -1
  38. package/dist/tracking.js +1 -1
  39. package/dist/types/utilities.d.ts +0 -1
  40. package/dist/utils/idGenerator.d.ts +0 -16
  41. package/dist/utils/static-props.d.ts +0 -7
  42. package/dist/watch-entry.cjs +1 -1
  43. package/dist/watch-entry.js +1 -1
  44. package/package.json +2 -1
  45. package/dist/StateContainerRegistry-Brmferpf.js.map +0 -1
  46. package/dist/StateContainerRegistry-CVPTMaHn.cjs.map +0 -1
package/README.md CHANGED
@@ -1,9 +1,9 @@
1
1
  # @blac/core
2
2
 
3
- > ⚠️ **Warning:** This project is currently under active development. The API may change in future releases. Use with caution in production environments.
4
-
5
3
  Core state management primitives for BlaC: state containers, registry, plugins, and tracking utilities.
6
4
 
5
+ **[Full documentation](https://jsnanigans.github.io/blac/guide/introduction)**
6
+
7
7
  ## Installation
8
8
 
9
9
  ```bash
@@ -111,9 +111,6 @@ Configure container behavior with `@blac`.
111
111
  ```ts
112
112
  import { Cubit, blac } from '@blac/core';
113
113
 
114
- @blac({ isolated: true })
115
- class FormCubit extends Cubit<FormState> {}
116
-
117
114
  @blac({ keepAlive: true })
118
115
  class AuthCubit extends Cubit<AuthState> {}
119
116
 
@@ -23,7 +23,6 @@ const BLAC_DEFAULTS = {
23
23
  * Used for feature flags and configuration on bloc classes
24
24
  */
25
25
  const BLAC_STATIC_PROPS = {
26
- ISOLATED: "isolated",
27
26
  KEEP_ALIVE: "keepAlive",
28
27
  EXCLUDE_FROM_DEVTOOLS: "__excludeFromDevTools"
29
28
  };
@@ -172,7 +171,6 @@ var PluginManager = class {
172
171
  lastStateChangeTimestamp: instance.lastUpdateTimestamp,
173
172
  createdAt: instance.createdAt,
174
173
  state: instance.state,
175
- isIsolated: instance.instanceId.startsWith("isolated-"),
176
174
  hydrationStatus: instance.hydrationStatus,
177
175
  isHydrated: instance.isHydrated,
178
176
  hydrationError: instance.hydrationError,
@@ -257,15 +255,6 @@ function getStaticProp(Type, propName, defaultValue) {
257
255
  return Type[propName] ?? defaultValue;
258
256
  }
259
257
  /**
260
- * Check if a class is marked as isolated.
261
- * Isolated classes create separate instances per component.
262
- * @param Type - The class constructor to check
263
- * @returns true if the class has `static isolated = true`
264
- */
265
- function isIsolatedClass(Type) {
266
- return getStaticProp(Type, BLAC_STATIC_PROPS.ISOLATED) === true;
267
- }
268
- /**
269
258
  * Check if a class is marked as keepAlive.
270
259
  * KeepAlive classes are never auto-disposed when ref count reaches 0.
271
260
  * @param Type - The class constructor to check
@@ -294,7 +283,7 @@ var StateContainerRegistry = class {
294
283
  constructor() {
295
284
  this.instancesByConstructor = /* @__PURE__ */ new WeakMap();
296
285
  this.types = /* @__PURE__ */ new Set();
297
- this.typeConfigs = /* @__PURE__ */ new Map();
286
+ this.registeredTypeNames = /* @__PURE__ */ new Set();
298
287
  this.listeners = /* @__PURE__ */ new Map();
299
288
  }
300
289
  /**
@@ -307,14 +296,12 @@ var StateContainerRegistry = class {
307
296
  /**
308
297
  * Register a StateContainer class with configuration
309
298
  * @param constructor - The StateContainer class constructor
310
- * @param isolated - Whether instances should be isolated (component-scoped)
311
299
  * @throws Error if type is already registered
312
300
  */
313
- register(constructor, isolated = false) {
301
+ register(constructor) {
314
302
  const className = constructor.name;
315
- if (!isolated && isIsolatedClass(constructor)) isolated = true;
316
- if (this.typeConfigs.has(className)) throw new Error(`${BLAC_ERROR_PREFIX} Type "${className}" is already registered`);
317
- this.typeConfigs.set(className, { isolated });
303
+ if (this.registeredTypeNames.has(className)) throw new Error(`${BLAC_ERROR_PREFIX} Type "${className}" is already registered`);
304
+ this.registeredTypeNames.add(className);
318
305
  this.registerType(constructor);
319
306
  }
320
307
  ensureInstancesMap(Type) {
@@ -344,16 +331,7 @@ var StateContainerRegistry = class {
344
331
  */
345
332
  acquire(Type, instanceKey = BLAC_DEFAULTS.DEFAULT_INSTANCE_KEY, options = {}) {
346
333
  const { canCreate = true, countRef = true } = options;
347
- const registryConfig = this.typeConfigs.get(Type.name);
348
- const isolated = isIsolatedClass(Type) || registryConfig?.isolated === true;
349
334
  const config = { instanceId: instanceKey };
350
- if (isolated && !canCreate) throw new Error(`${BLAC_ERROR_PREFIX} Cannot get isolated instance "${instanceKey}" of ${Type.name} when creation is disabled.`);
351
- if (isolated) {
352
- const instance = new Type();
353
- instance.initConfig(config);
354
- this.registerType(Type);
355
- return instance;
356
- }
357
335
  const instances = this.ensureInstancesMap(Type);
358
336
  let entry = instances.get(instanceKey);
359
337
  if (entry?.instance.isDisposed) {
@@ -510,7 +488,7 @@ var StateContainerRegistry = class {
510
488
  clearAll() {
511
489
  for (const Type of this.types) this.clear(Type);
512
490
  this.types.clear();
513
- this.typeConfigs.clear();
491
+ this.registeredTypeNames.clear();
514
492
  }
515
493
  /**
516
494
  * Get registry statistics for debugging.
@@ -619,11 +597,5 @@ Object.defineProperty(exports, "globalRegistry", {
619
597
  return globalRegistry;
620
598
  }
621
599
  });
622
- Object.defineProperty(exports, "isIsolatedClass", {
623
- enumerable: true,
624
- get: function() {
625
- return isIsolatedClass;
626
- }
627
- });
628
600
 
629
- //# sourceMappingURL=StateContainerRegistry-CVPTMaHn.cjs.map
601
+ //# sourceMappingURL=StateContainerRegistry-COxgpYAw.cjs.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"StateContainerRegistry-COxgpYAw.cjs","names":[],"sources":["../src/constants.ts","../src/plugin/PluginManager.ts","../src/utils/static-props.ts","../src/core/StateContainerRegistry.ts"],"sourcesContent":["/**\n * Default configuration constants for BlaC\n *\n * Centralized location for all magic numbers and default values.\n */\n\n/**\n * Default configuration constants for BlaC\n */\nexport const BLAC_DEFAULTS = {\n /**\n * Default instance key for shared instances\n */\n DEFAULT_INSTANCE_KEY: 'default',\n\n /**\n * Maximum getter nesting depth (prevents infinite recursion)\n */\n MAX_GETTER_DEPTH: 10,\n\n /**\n * Default cleanup interval for subscriptions (30 seconds)\n */\n CLEANUP_INTERVAL_MS: 30_000,\n\n /**\n * Cleanup interval for weak reference stage (10 seconds)\n */\n WEAKREF_CLEANUP_INTERVAL_MS: 10_000,\n\n /**\n * Default maximum subscriptions per container\n */\n MAX_SUBSCRIPTIONS: 1_000,\n\n /**\n * Maximum subscriptions for high-performance mode\n */\n MAX_SUBSCRIPTIONS_HIGH_PERF: 10_000,\n\n /**\n * Default timeout for pipeline execution (5 seconds)\n */\n PIPELINE_TIMEOUT_MS: 5_000,\n\n /**\n * Cleanup interval for high-performance mode (5 seconds)\n */\n CLEANUP_INTERVAL_HIGH_PERF_MS: 5_000,\n\n /**\n * Maximum number of stages in a pipeline\n */\n MAX_PIPELINE_STAGES: 30,\n} as const;\n\n/**\n * Static property names for StateContainer classes\n * Used for feature flags and configuration on bloc classes\n */\nexport const BLAC_STATIC_PROPS = {\n /**\n * Mark a bloc to never be auto-disposed (kept alive permanently)\n */\n KEEP_ALIVE: 'keepAlive',\n\n /**\n * Exclude a bloc from DevTools reporting (prevents infinite loops)\n */\n EXCLUDE_FROM_DEVTOOLS: '__excludeFromDevTools',\n} as const;\n\n/**\n * ID generation patterns and constants\n */\nexport const BLAC_ID_PATTERNS = {\n /**\n * Length of generated ID portion (9 characters from base36)\n */\n ID_LENGTH: 9,\n} as const;\n\n/**\n * Standard error message prefix\n */\nexport const BLAC_ERROR_PREFIX = '[BlaC]' as const;\n","import type { StateContainer } from '../core/StateContainer';\nimport type { StateContainerRegistry } from '../core/StateContainerRegistry';\nimport type {\n BlacPlugin,\n PluginContext,\n PluginConfig,\n InstanceMetadata,\n} from './BlacPlugin';\n\n/**\n * Internal structure for tracking installed plugins\n * @internal\n */\ninterface InstalledPlugin {\n plugin: BlacPlugin;\n config: PluginConfig;\n context: PluginContext;\n}\n\n/**\n * Manages plugin lifecycle for the BlaC state management system.\n * Plugins receive notifications about state container lifecycle events.\n *\n * @example\n * ```ts\n * const manager = createPluginManager(registry);\n * manager.install(myPlugin, { environment: 'development' });\n * ```\n */\nexport class PluginManager {\n private plugins = new Map<string, InstalledPlugin>();\n private registry: StateContainerRegistry;\n\n /**\n * Create a new PluginManager\n * @param registry - The StateContainerRegistry to monitor for lifecycle events\n */\n constructor(registry: StateContainerRegistry) {\n this.registry = registry;\n this.setupLifecycleHooks();\n }\n\n /**\n * Install a plugin with optional configuration\n * @param plugin - The plugin to install\n * @param config - Optional plugin configuration\n * @throws Error if plugin is already installed\n */\n install(plugin: BlacPlugin, config: PluginConfig = {}): void {\n const effectiveConfig: PluginConfig = {\n enabled: true,\n environment: 'all',\n ...config,\n };\n\n if (!this.shouldEnablePlugin(effectiveConfig)) {\n console.log(\n `[BlaC] Plugin \"${plugin.name}\" skipped (environment mismatch)`,\n );\n return;\n }\n\n if (this.plugins.has(plugin.name)) {\n throw new Error(`Plugin \"${plugin.name}\" is already installed`);\n }\n\n const context = this.createPluginContext();\n\n this.plugins.set(plugin.name, {\n plugin,\n config: effectiveConfig,\n context,\n });\n\n if (plugin.onInstall) {\n try {\n plugin.onInstall(context);\n } catch (error) {\n console.error(\n `[BlaC] Error installing plugin \"${plugin.name}\":`,\n error,\n );\n this.plugins.delete(plugin.name);\n throw error;\n }\n }\n\n console.log(`[BlaC] Plugin \"${plugin.name}\" v${plugin.version} installed`);\n }\n\n /**\n * Uninstall a plugin by name\n * @param pluginName - The name of the plugin to uninstall\n * @throws Error if plugin is not installed\n */\n uninstall(pluginName: string): void {\n const installed = this.plugins.get(pluginName);\n if (!installed) {\n throw new Error(`Plugin \"${pluginName}\" is not installed`);\n }\n\n if (installed.plugin.onUninstall) {\n try {\n installed.plugin.onUninstall();\n } catch (error) {\n console.error(\n `[BlaC] Error uninstalling plugin \"${pluginName}\":`,\n error,\n );\n }\n }\n\n this.plugins.delete(pluginName);\n console.log(`[BlaC] Plugin \"${pluginName}\" uninstalled`);\n }\n\n /**\n * Get an installed plugin by name\n * @param pluginName - The name of the plugin to retrieve\n * @returns The plugin instance or undefined if not found\n */\n getPlugin(pluginName: string): BlacPlugin | undefined {\n return this.plugins.get(pluginName)?.plugin;\n }\n\n /**\n * Get all installed plugins\n * @returns Array of all installed plugins\n */\n getAllPlugins(): BlacPlugin[] {\n return Array.from(this.plugins.values()).map((p) => p.plugin);\n }\n\n /**\n * Check if a plugin is installed\n * @param pluginName - The name of the plugin to check\n * @returns true if the plugin is installed\n */\n hasPlugin(pluginName: string): boolean {\n return this.plugins.has(pluginName);\n }\n\n /**\n * Uninstall all plugins\n */\n clear(): void {\n for (const name of this.plugins.keys()) {\n this.uninstall(name);\n }\n }\n\n /**\n * Setup lifecycle hooks to notify plugins\n */\n private setupLifecycleHooks(): void {\n // Instance created\n this.registry.on('created', (instance) => {\n this.notifyPlugins('onInstanceCreated', instance);\n });\n\n // State changed\n this.registry.on(\n 'stateChanged',\n (instance, previousState, currentState, callstack) => {\n this.notifyPlugins(\n 'onStateChanged',\n instance,\n previousState,\n currentState,\n callstack,\n );\n },\n );\n\n // Instance disposed\n this.registry.on('disposed', (instance) => {\n this.notifyPlugins('onInstanceDisposed', instance);\n });\n }\n\n /**\n * Notify all plugins of a lifecycle event\n */\n private notifyPlugins(hookName: keyof BlacPlugin, ...args: any[]): void {\n for (const { plugin, config, context } of this.plugins.values()) {\n if (!config.enabled) continue;\n\n const hook = plugin[hookName];\n if (typeof hook === 'function') {\n try {\n (hook as any).apply(plugin, [...args, context]);\n } catch (error) {\n console.error(\n `[BlaC] Error in plugin \"${plugin.name}\" ${hookName}:`,\n error,\n );\n }\n }\n }\n }\n\n /**\n * Create plugin context with safe API access\n */\n private createPluginContext(): PluginContext {\n return {\n getInstanceMetadata: (\n instance: StateContainer<any>,\n ): InstanceMetadata => {\n return {\n id: instance.instanceId,\n className: instance.constructor.name,\n isDisposed: instance.isDisposed,\n name: instance.name,\n lastStateChangeTimestamp: instance.lastUpdateTimestamp,\n createdAt: instance.createdAt,\n state: instance.state,\n hydrationStatus: instance.hydrationStatus,\n isHydrated: instance.isHydrated,\n hydrationError: instance.hydrationError,\n changedWhileHydrating: instance.changedWhileHydrating,\n };\n },\n\n getState: <S extends object = any>(instance: StateContainer<S>): S => {\n return instance.state;\n },\n\n getHydrationStatus: (instance: StateContainer<any>) => {\n return instance.hydrationStatus;\n },\n\n startHydration: (instance: StateContainer<any>) => {\n instance.beginHydration();\n },\n\n applyHydratedState: <S extends object = any>(\n instance: StateContainer<S>,\n state: S,\n ): boolean => {\n return instance.applyHydratedState(state);\n },\n\n finishHydration: (instance: StateContainer<any>) => {\n instance.finishHydration();\n },\n\n failHydration: (instance: StateContainer<any>, error: Error) => {\n instance.failHydration(error);\n },\n\n waitForHydration: (instance: StateContainer<any>) => {\n return instance.waitForHydration();\n },\n\n queryInstances: <T extends StateContainer<any>>(\n typeClass: new (...args: any[]) => T,\n ): T[] => {\n return this.registry.getAll(typeClass as any);\n },\n\n getAllTypes: () => {\n return this.registry.getTypes();\n },\n\n getStats: () => {\n return this.registry.getStats();\n },\n };\n }\n\n /**\n * Check if plugin should be enabled based on environment\n */\n private shouldEnablePlugin(config: PluginConfig): boolean {\n if (!config.enabled) return false;\n if (config.environment === 'all') return true;\n\n const currentEnv = this.getCurrentEnvironment();\n return currentEnv === config.environment;\n }\n\n /**\n * Get current environment\n */\n private getCurrentEnvironment(): 'development' | 'production' | 'test' {\n if (typeof process !== 'undefined') {\n if (process.env.NODE_ENV === 'test') return 'test';\n if (process.env.NODE_ENV === 'production') return 'production';\n return 'development';\n }\n return 'development';\n }\n}\n\n/**\n * Create a plugin manager instance\n * @param registry - The StateContainerRegistry to monitor for lifecycle events\n * @returns A new PluginManager instance\n */\nexport function createPluginManager(\n registry: StateContainerRegistry,\n): PluginManager {\n return new PluginManager(registry);\n}\n","/**\n * Utility functions for accessing static properties on StateContainer classes\n */\n\nimport { BLAC_STATIC_PROPS } from '../constants';\nimport { StateContainerConstructor } from '../types/utilities';\n\n/**\n * Get a static property from a class constructor\n * Type-safe helper that avoids (Type as any) casts\n *\n * @param Type - The class constructor\n * @param propName - The property name to access\n * @param defaultValue - Optional default value if property is undefined\n * @returns The property value or default\n */\nexport function getStaticProp<\n V,\n T extends StateContainerConstructor = StateContainerConstructor,\n>(Type: T, propName: string, defaultValue?: V): V | undefined {\n return (Type as any)[propName] ?? defaultValue;\n}\n\n/**\n * Check if a class is marked as keepAlive.\n * KeepAlive classes are never auto-disposed when ref count reaches 0.\n * @param Type - The class constructor to check\n * @returns true if the class has `static keepAlive = true`\n */\nexport function isKeepAliveClass<T extends StateContainerConstructor>(\n Type: T,\n): boolean {\n return getStaticProp<boolean>(Type, BLAC_STATIC_PROPS.KEEP_ALIVE) === true;\n}\n\n/**\n * Check if a class should be excluded from DevTools.\n * Used to prevent infinite loops when DevTools tracks itself.\n * @param Type - The class constructor to check\n * @returns true if the class has `static __excludeFromDevTools = true`\n */\nexport function isExcludedFromDevTools<T extends StateContainerConstructor>(\n Type: T,\n): boolean {\n return (\n getStaticProp<boolean>(Type, BLAC_STATIC_PROPS.EXCLUDE_FROM_DEVTOOLS) ===\n true\n );\n}\n","import type { StateContainer, StateContainerConfig } from './StateContainer';\nimport { createPluginManager } from '../plugin/PluginManager';\nimport { BLAC_DEFAULTS, BLAC_ERROR_PREFIX } from '../constants';\nimport { isKeepAliveClass } from '../utils/static-props';\nimport {\n InstanceReadonlyState,\n StateContainerConstructor,\n} from '../types/utilities';\n\n/**\n * Entry in the instance registry, tracking the instance and its reference count\n * @template T - Instance type\n */\nexport interface InstanceEntry<T = any> {\n /** The state container instance */\n instance: T;\n /** Number of active references to this instance */\n refCount: number;\n}\n\n/**\n * Lifecycle events emitted by the registry\n */\nexport type LifecycleEvent = 'created' | 'stateChanged' | 'disposed';\n\n/**\n * Listener function type for each lifecycle event\n * @template E - The lifecycle event type\n */\nexport type LifecycleListener<E extends LifecycleEvent> = E extends 'created'\n ? (container: StateContainer<any>) => void\n : E extends 'stateChanged'\n ? (\n container: StateContainer<any>,\n previousState: any,\n currentState: any,\n callstack?: string,\n ) => void\n : E extends 'disposed'\n ? (container: StateContainer<any>) => void\n : never;\n\n/**\n * Central registry for managing StateContainer instances.\n * Handles instance lifecycle, ref counting, and lifecycle event emission.\n *\n * @example\n * ```ts\n * const registry = new StateContainerRegistry();\n * const instance = registry.acquire(MyBloc); // ownership, must release\n * const other = registry.ensure(OtherBloc); // no ownership, bloc-to-bloc\n * registry.on('stateChanged', (container, prev, next) => {\n * console.log('State changed:', prev, '->', next);\n * });\n * ```\n */\nexport class StateContainerRegistry {\n private readonly instancesByConstructor = new WeakMap<\n StateContainerConstructor,\n Map<string, InstanceEntry>\n >();\n\n private readonly types = new Set<StateContainerConstructor>();\n\n private readonly registeredTypeNames = new Set<string>();\n\n private readonly listeners = new Map<\n LifecycleEvent,\n Set<(...args: any[]) => void>\n >();\n\n /**\n * Register a type for lifecycle event tracking\n * @param constructor - The StateContainer class constructor\n */\n registerType<T extends StateContainerConstructor>(constructor: T): void {\n this.types.add(constructor);\n }\n\n /**\n * Register a StateContainer class with configuration\n * @param constructor - The StateContainer class constructor\n * @throws Error if type is already registered\n */\n register<T extends StateContainerConstructor>(constructor: T): void {\n const className = constructor.name;\n\n if (this.registeredTypeNames.has(className)) {\n throw new Error(\n `${BLAC_ERROR_PREFIX} Type \"${className}\" is already registered`,\n );\n }\n\n this.registeredTypeNames.add(className);\n this.registerType(constructor);\n }\n\n private ensureInstancesMap<T extends StateContainerConstructor>(\n Type: T,\n ): Map<string, InstanceEntry> {\n let instances = this.instancesByConstructor.get(Type);\n if (!instances) {\n instances = new Map<string, InstanceEntry>();\n this.instancesByConstructor.set(Type, instances);\n }\n return instances;\n }\n\n /**\n * Get the instances Map for a specific class (public API for stats/debugging)\n */\n getInstancesMap<T extends StateContainerConstructor>(\n Type: T,\n ): Map<string, InstanceEntry> {\n return this.instancesByConstructor.get(Type) || new Map();\n }\n\n /**\n * Acquire an instance with ref counting (ownership semantics).\n * Creates a new instance if one doesn't exist, or returns existing and increments ref count.\n * You must call `release()` when done to decrement the ref count.\n * @param Type - The StateContainer class constructor\n * @param instanceKey - Instance key (defaults to 'default')\n * @param options - Acquisition options\n * @param options.canCreate - Whether to create new instance if not found (default: true)\n * @param options.countRef - Whether to increment ref count (default: true)\n * @returns The state container instance\n */\n acquire<T extends StateContainerConstructor = StateContainerConstructor>(\n Type: T,\n instanceKey: string = BLAC_DEFAULTS.DEFAULT_INSTANCE_KEY,\n options: {\n canCreate?: boolean;\n countRef?: boolean;\n } = {},\n ): InstanceType<T> {\n const { canCreate = true, countRef = true } = options;\n\n const config: StateContainerConfig = {\n instanceId: instanceKey,\n };\n\n const instances = this.ensureInstancesMap(Type);\n let entry = instances.get(instanceKey);\n\n // Detect stale disposed entries (disposed directly, not through release)\n if (entry?.instance.isDisposed) {\n instances.delete(instanceKey);\n entry = undefined;\n }\n\n if (entry && countRef) {\n entry.refCount++;\n }\n\n if (entry) {\n return entry.instance;\n }\n\n if (!canCreate) {\n throw new Error(\n `${BLAC_ERROR_PREFIX} ${Type.name} instance \"${instanceKey}\" not found and creation is disabled.`,\n );\n }\n\n // Create new shared instance\n const instance = new Type() as InstanceType<T>;\n instance.initConfig(config);\n instances.set(instanceKey, { instance, refCount: 1 });\n\n // Register type for lifecycle coordination\n this.registerType(Type);\n\n return instance;\n }\n\n /**\n * Borrow an existing instance without incrementing ref count (borrowing semantics).\n * Tracks cross-bloc dependency for reactive updates.\n * @param Type - The StateContainer class constructor\n * @param instanceKey - Instance key (defaults to 'default')\n * @returns The state container instance\n * @throws Error if instance doesn't exist\n */\n borrow<T extends StateContainerConstructor = StateContainerConstructor>(\n Type: T,\n instanceKey: string = BLAC_DEFAULTS.DEFAULT_INSTANCE_KEY,\n ): InstanceType<T> {\n return this.acquire(Type, instanceKey, {\n canCreate: false,\n countRef: false,\n });\n }\n\n /**\n * Safely borrow an existing instance (borrowing semantics with error handling).\n * Returns discriminated union for type-safe conditional access.\n * @param Type - The StateContainer class constructor\n * @param instanceKey - Instance key (defaults to 'default')\n * @returns Discriminated union with either the instance or an error\n */\n borrowSafe<T extends StateContainerConstructor = StateContainerConstructor>(\n Type: T,\n instanceKey: string = BLAC_DEFAULTS.DEFAULT_INSTANCE_KEY,\n ):\n | { error: Error; instance: null }\n | { error: null; instance: InstanceType<T> } {\n try {\n const instance = this.borrow(Type, instanceKey);\n return { error: null, instance };\n } catch (error: any) {\n return { error, instance: null };\n }\n }\n\n /**\n * Ensure an instance exists without taking ownership (for bloc-to-bloc communication).\n * Gets existing instance OR creates it if it doesn't exist, without incrementing ref count.\n * Tracks cross-bloc dependency for reactive updates.\n *\n * Use this in bloc-to-bloc communication when you need to ensure an instance exists\n * but don't want to claim ownership (no ref count increment).\n * @param Type - The StateContainer class constructor\n * @param instanceKey - Instance key (defaults to 'default')\n * @returns The state container instance\n */\n ensure<T extends StateContainerConstructor = StateContainerConstructor>(\n Type: T,\n instanceKey: string = BLAC_DEFAULTS.DEFAULT_INSTANCE_KEY,\n ): InstanceType<T> {\n return this.acquire(Type, instanceKey, {\n canCreate: true,\n countRef: false,\n });\n }\n\n /**\n * Release a reference to an instance.\n * Decrements ref count and disposes when it reaches 0 (unless keepAlive).\n * @param Type - The StateContainer class constructor\n * @param instanceKey - Instance key (defaults to 'default')\n * @param forceDispose - Force immediate disposal regardless of ref count\n */\n release<T extends StateContainerConstructor>(\n Type: T,\n instanceKey: string = BLAC_DEFAULTS.DEFAULT_INSTANCE_KEY,\n forceDispose = false,\n ): void {\n const instances = this.ensureInstancesMap(Type);\n const entry = instances.get(instanceKey);\n\n if (!entry) return;\n\n // Force dispose immediately\n if (forceDispose) {\n if (!entry.instance.isDisposed) {\n entry.instance.dispose();\n }\n instances.delete(instanceKey);\n return;\n }\n\n // Decrement ref count\n entry.refCount--;\n\n // Check static keepAlive property\n const keepAlive = isKeepAliveClass(Type);\n\n // Auto-dispose when ref count reaches 0 (unless keepAlive)\n if (entry.refCount <= 0 && !keepAlive) {\n if (!entry.instance.isDisposed) {\n entry.instance.dispose();\n }\n instances.delete(instanceKey);\n }\n }\n\n /**\n * Get all instances of a specific type.\n * @param Type - The StateContainer class constructor\n * @returns Array of all instances\n */\n getAll<T extends StateContainerConstructor>(\n Type: T,\n ): InstanceReadonlyState<T>[] {\n const instances = this.ensureInstancesMap(Type);\n const result: InstanceReadonlyState<T>[] = [];\n for (const entry of instances.values()) {\n result.push(entry.instance);\n }\n return result;\n }\n\n /**\n * Safely iterate over all instances of a type.\n * Skips disposed instances and catches callback errors.\n * @param Type - The StateContainer class constructor\n * @param callback - Function to call for each instance\n */\n forEach<T extends StateContainerConstructor>(\n Type: T,\n callback: (instance: InstanceReadonlyState<T>) => void,\n ): void {\n const instances = this.ensureInstancesMap(Type);\n for (const entry of instances.values()) {\n const instance = entry.instance;\n if (!instance.isDisposed) {\n try {\n callback(instance);\n } catch (error) {\n console.error(\n `${BLAC_ERROR_PREFIX} forEach callback error for ${Type.name}:`,\n error,\n );\n }\n }\n }\n }\n\n /**\n * Clear all instances of a specific type (disposes them).\n * @param Type - The StateContainer class constructor\n */\n clear<T extends StateContainerConstructor>(Type: T): void {\n const instances = this.ensureInstancesMap(Type);\n // Dispose all instances\n for (const entry of instances.values()) {\n if (!entry.instance.isDisposed) {\n entry.instance.dispose();\n }\n }\n // Clear the Map\n instances.clear();\n }\n\n /**\n * Get reference count for an instance.\n * @param Type - The StateContainer class constructor\n * @param instanceKey - Instance key (defaults to 'default')\n * @returns Current ref count (0 if instance doesn't exist)\n */\n getRefCount<T extends StateContainerConstructor>(\n Type: T,\n instanceKey: string = BLAC_DEFAULTS.DEFAULT_INSTANCE_KEY,\n ): number {\n const instances = this.ensureInstancesMap(Type);\n const entry = instances.get(instanceKey);\n return entry?.refCount ?? 0;\n }\n\n /**\n * Check if an instance exists.\n * @param Type - The StateContainer class constructor\n * @param instanceKey - Instance key (defaults to 'default')\n * @returns true if instance exists\n */\n hasInstance<T extends StateContainerConstructor>(\n Type: T,\n instanceKey: string = BLAC_DEFAULTS.DEFAULT_INSTANCE_KEY,\n ): boolean {\n const instances = this.ensureInstancesMap(Type);\n return instances.has(instanceKey);\n }\n\n /**\n * Clear all instances from all types (for testing)\n *\n * Iterates all registered types and clears their instances.\n * Also clears type tracking to reset the registry state.\n */\n clearAll(): void {\n // Step 1: Clear instances from each type (while we still have the types list)\n for (const Type of this.types) {\n this.clear(Type);\n }\n // Step 2: Now clear type tracking (resets registry state for tests)\n this.types.clear();\n this.registeredTypeNames.clear();\n }\n\n /**\n * Get registry statistics for debugging.\n * @returns Object with registeredTypes, totalInstances, and typeBreakdown\n */\n getStats(): {\n registeredTypes: number;\n totalInstances: number;\n typeBreakdown: Record<string, number>;\n } {\n const typeBreakdown: Record<string, number> = {};\n let totalInstances = 0;\n\n // Collect stats from each registered type\n for (const Type of this.types) {\n const typeName = Type.name;\n const instances = this.getInstancesMap(Type);\n const count = instances.size;\n\n typeBreakdown[typeName] = count;\n totalInstances += count;\n }\n\n return {\n registeredTypes: this.types.size,\n totalInstances,\n typeBreakdown,\n };\n }\n\n /**\n * Get all registered types (for plugin system).\n * @returns Array of all registered StateContainer class constructors\n */\n getTypes(): StateContainerConstructor[] {\n return Array.from(this.types);\n }\n\n /**\n * Subscribe to lifecycle events\n * @param event - The lifecycle event to listen for\n * @param listener - The listener function to call when the event occurs\n * @returns Unsubscribe function\n */\n on<E extends LifecycleEvent>(\n event: E,\n listener: LifecycleListener<E>,\n ): () => void {\n if (!this.listeners.has(event)) {\n this.listeners.set(event, new Set());\n }\n const instance = this.listeners.get(event);\n if (!instance) {\n throw new Error(\n `${BLAC_ERROR_PREFIX} Failed to register listener for event '${event}'`,\n );\n }\n\n instance.add(listener as (...args: any[]) => void);\n\n // Return unsubscribe function\n return () => {\n this.listeners.get(event)?.delete(listener as (...args: any[]) => void);\n };\n }\n\n /**\n * Emit lifecycle event to all listeners\n * @internal - Called by StateContainer lifecycle methods\n */\n emit(event: LifecycleEvent, ...args: any[]): void {\n const listeners = this.listeners.get(event);\n if (!listeners || listeners.size === 0) return; // Zero overhead when no listeners\n\n for (const listener of listeners) {\n try {\n listener(...args);\n } catch (error) {\n console.error(\n `${BLAC_ERROR_PREFIX} Listener error for '${event}':`,\n error,\n );\n }\n }\n }\n}\n\n/**\n * Global default registry instance\n */\nexport const globalRegistry = new StateContainerRegistry();\n\n/**\n * Global plugin manager (initialized lazily)\n */\nlet _globalPluginManager: any = null;\n\n/**\n * Get the global plugin manager\n */\nexport function getPluginManager(): any {\n if (!_globalPluginManager) {\n _globalPluginManager = createPluginManager(globalRegistry);\n }\n return _globalPluginManager;\n}\n"],"mappings":";;;;;;;;;AASA,MAAa,gBAAgB;CAI3B,sBAAsB;CAKtB,kBAAkB;CAKlB,qBAAqB;CAKrB,6BAA6B;CAK7B,mBAAmB;CAKnB,6BAA6B;CAK7B,qBAAqB;CAKrB,+BAA+B;CAK/B,qBAAqB;CACtB;;;;;AAMD,MAAa,oBAAoB;CAI/B,YAAY;CAKZ,uBAAuB;CACxB;;;;AAeD,MAAa,oBAAoB;;;;;;;;;;;;;ACxDjC,IAAa,gBAAb,MAA2B;;;;;CAQzB,YAAY,UAAkC;iCAP5B,IAAI,KAA8B;AAQlD,OAAK,WAAW;AAChB,OAAK,qBAAqB;;;;;;;;CAS5B,QAAQ,QAAoB,SAAuB,EAAE,EAAQ;EAC3D,MAAM,kBAAgC;GACpC,SAAS;GACT,aAAa;GACb,GAAG;GACJ;AAED,MAAI,CAAC,KAAK,mBAAmB,gBAAgB,EAAE;AAC7C,WAAQ,IACN,kBAAkB,OAAO,KAAK,kCAC/B;AACD;;AAGF,MAAI,KAAK,QAAQ,IAAI,OAAO,KAAK,CAC/B,OAAM,IAAI,MAAM,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1B,qBAAkB;;AAGpB,SAAO;GACL,iBAAiB,KAAK,MAAM;GAC5B;GACA;GACD;;;;;;CAOH,WAAwC;AACtC,SAAO,MAAM,KAAK,KAAK,MAAM;;;;;;;;CAS/B,GACE,OACA,UACY;AACZ,MAAI,CAAC,KAAK,UAAU,IAAI,MAAM,CAC5B,MAAK,UAAU,IAAI,uBAAO,IAAI,KAAK,CAAC;EAEtC,MAAM,WAAW,KAAK,UAAU,IAAI,MAAM;AAC1C,MAAI,CAAC,SACH,OAAM,IAAI,MACR,GAAG,kBAAkB,0CAA0C,MAAM,GACtE;AAGH,WAAS,IAAI,SAAqC;AAGlD,eAAa;AACX,QAAK,UAAU,IAAI,MAAM,EAAE,OAAO,SAAqC;;;;;;;CAQ3E,KAAK,OAAuB,GAAG,MAAmB;EAChD,MAAM,YAAY,KAAK,UAAU,IAAI,MAAM;AAC3C,MAAI,CAAC,aAAa,UAAU,SAAS,EAAG;AAExC,OAAK,MAAM,YAAY,UACrB,KAAI;AACF,YAAS,GAAG,KAAK;WACV,OAAO;AACd,WAAQ,MACN,GAAG,kBAAkB,uBAAuB,MAAM,KAClD,MACD;;;;;;;AAST,MAAa,iBAAiB,IAAI,wBAAwB;;;;AAK1D,IAAI,uBAA4B;;;;AAKhC,SAAgB,mBAAwB;AACtC,KAAI,CAAC,qBACH,wBAAuB,oBAAoB,eAAe;AAE5D,QAAO"}
@@ -23,7 +23,6 @@ const BLAC_DEFAULTS = {
23
23
  * Used for feature flags and configuration on bloc classes
24
24
  */
25
25
  const BLAC_STATIC_PROPS = {
26
- ISOLATED: "isolated",
27
26
  KEEP_ALIVE: "keepAlive",
28
27
  EXCLUDE_FROM_DEVTOOLS: "__excludeFromDevTools"
29
28
  };
@@ -172,7 +171,6 @@ var PluginManager = class {
172
171
  lastStateChangeTimestamp: instance.lastUpdateTimestamp,
173
172
  createdAt: instance.createdAt,
174
173
  state: instance.state,
175
- isIsolated: instance.instanceId.startsWith("isolated-"),
176
174
  hydrationStatus: instance.hydrationStatus,
177
175
  isHydrated: instance.isHydrated,
178
176
  hydrationError: instance.hydrationError,
@@ -257,15 +255,6 @@ function getStaticProp(Type, propName, defaultValue) {
257
255
  return Type[propName] ?? defaultValue;
258
256
  }
259
257
  /**
260
- * Check if a class is marked as isolated.
261
- * Isolated classes create separate instances per component.
262
- * @param Type - The class constructor to check
263
- * @returns true if the class has `static isolated = true`
264
- */
265
- function isIsolatedClass(Type) {
266
- return getStaticProp(Type, BLAC_STATIC_PROPS.ISOLATED) === true;
267
- }
268
- /**
269
258
  * Check if a class is marked as keepAlive.
270
259
  * KeepAlive classes are never auto-disposed when ref count reaches 0.
271
260
  * @param Type - The class constructor to check
@@ -294,7 +283,7 @@ var StateContainerRegistry = class {
294
283
  constructor() {
295
284
  this.instancesByConstructor = /* @__PURE__ */ new WeakMap();
296
285
  this.types = /* @__PURE__ */ new Set();
297
- this.typeConfigs = /* @__PURE__ */ new Map();
286
+ this.registeredTypeNames = /* @__PURE__ */ new Set();
298
287
  this.listeners = /* @__PURE__ */ new Map();
299
288
  }
300
289
  /**
@@ -307,14 +296,12 @@ var StateContainerRegistry = class {
307
296
  /**
308
297
  * Register a StateContainer class with configuration
309
298
  * @param constructor - The StateContainer class constructor
310
- * @param isolated - Whether instances should be isolated (component-scoped)
311
299
  * @throws Error if type is already registered
312
300
  */
313
- register(constructor, isolated = false) {
301
+ register(constructor) {
314
302
  const className = constructor.name;
315
- if (!isolated && isIsolatedClass(constructor)) isolated = true;
316
- if (this.typeConfigs.has(className)) throw new Error(`${BLAC_ERROR_PREFIX} Type "${className}" is already registered`);
317
- this.typeConfigs.set(className, { isolated });
303
+ if (this.registeredTypeNames.has(className)) throw new Error(`${BLAC_ERROR_PREFIX} Type "${className}" is already registered`);
304
+ this.registeredTypeNames.add(className);
318
305
  this.registerType(constructor);
319
306
  }
320
307
  ensureInstancesMap(Type) {
@@ -344,16 +331,7 @@ var StateContainerRegistry = class {
344
331
  */
345
332
  acquire(Type, instanceKey = BLAC_DEFAULTS.DEFAULT_INSTANCE_KEY, options = {}) {
346
333
  const { canCreate = true, countRef = true } = options;
347
- const registryConfig = this.typeConfigs.get(Type.name);
348
- const isolated = isIsolatedClass(Type) || registryConfig?.isolated === true;
349
334
  const config = { instanceId: instanceKey };
350
- if (isolated && !canCreate) throw new Error(`${BLAC_ERROR_PREFIX} Cannot get isolated instance "${instanceKey}" of ${Type.name} when creation is disabled.`);
351
- if (isolated) {
352
- const instance = new Type();
353
- instance.initConfig(config);
354
- this.registerType(Type);
355
- return instance;
356
- }
357
335
  const instances = this.ensureInstancesMap(Type);
358
336
  let entry = instances.get(instanceKey);
359
337
  if (entry?.instance.isDisposed) {
@@ -510,7 +488,7 @@ var StateContainerRegistry = class {
510
488
  clearAll() {
511
489
  for (const Type of this.types) this.clear(Type);
512
490
  this.types.clear();
513
- this.typeConfigs.clear();
491
+ this.registeredTypeNames.clear();
514
492
  }
515
493
  /**
516
494
  * Get registry statistics for debugging.
@@ -583,6 +561,6 @@ function getPluginManager() {
583
561
  return _globalPluginManager;
584
562
  }
585
563
  //#endregion
586
- export { BLAC_DEFAULTS as a, PluginManager as i, globalRegistry as n, BLAC_ERROR_PREFIX as o, isIsolatedClass as r, BLAC_STATIC_PROPS as s, getPluginManager as t };
564
+ export { BLAC_ERROR_PREFIX as a, BLAC_DEFAULTS as i, globalRegistry as n, BLAC_STATIC_PROPS as o, PluginManager as r, getPluginManager as t };
587
565
 
588
- //# sourceMappingURL=StateContainerRegistry-Brmferpf.js.map
566
+ //# sourceMappingURL=StateContainerRegistry-DS_wyKck.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"StateContainerRegistry-DS_wyKck.js","names":[],"sources":["../src/constants.ts","../src/plugin/PluginManager.ts","../src/utils/static-props.ts","../src/core/StateContainerRegistry.ts"],"sourcesContent":["/**\n * Default configuration constants for BlaC\n *\n * Centralized location for all magic numbers and default values.\n */\n\n/**\n * Default configuration constants for BlaC\n */\nexport const BLAC_DEFAULTS = {\n /**\n * Default instance key for shared instances\n */\n DEFAULT_INSTANCE_KEY: 'default',\n\n /**\n * Maximum getter nesting depth (prevents infinite recursion)\n */\n MAX_GETTER_DEPTH: 10,\n\n /**\n * Default cleanup interval for subscriptions (30 seconds)\n */\n CLEANUP_INTERVAL_MS: 30_000,\n\n /**\n * Cleanup interval for weak reference stage (10 seconds)\n */\n WEAKREF_CLEANUP_INTERVAL_MS: 10_000,\n\n /**\n * Default maximum subscriptions per container\n */\n MAX_SUBSCRIPTIONS: 1_000,\n\n /**\n * Maximum subscriptions for high-performance mode\n */\n MAX_SUBSCRIPTIONS_HIGH_PERF: 10_000,\n\n /**\n * Default timeout for pipeline execution (5 seconds)\n */\n PIPELINE_TIMEOUT_MS: 5_000,\n\n /**\n * Cleanup interval for high-performance mode (5 seconds)\n */\n CLEANUP_INTERVAL_HIGH_PERF_MS: 5_000,\n\n /**\n * Maximum number of stages in a pipeline\n */\n MAX_PIPELINE_STAGES: 30,\n} as const;\n\n/**\n * Static property names for StateContainer classes\n * Used for feature flags and configuration on bloc classes\n */\nexport const BLAC_STATIC_PROPS = {\n /**\n * Mark a bloc to never be auto-disposed (kept alive permanently)\n */\n KEEP_ALIVE: 'keepAlive',\n\n /**\n * Exclude a bloc from DevTools reporting (prevents infinite loops)\n */\n EXCLUDE_FROM_DEVTOOLS: '__excludeFromDevTools',\n} as const;\n\n/**\n * ID generation patterns and constants\n */\nexport const BLAC_ID_PATTERNS = {\n /**\n * Length of generated ID portion (9 characters from base36)\n */\n ID_LENGTH: 9,\n} as const;\n\n/**\n * Standard error message prefix\n */\nexport const BLAC_ERROR_PREFIX = '[BlaC]' as const;\n","import type { StateContainer } from '../core/StateContainer';\nimport type { StateContainerRegistry } from '../core/StateContainerRegistry';\nimport type {\n BlacPlugin,\n PluginContext,\n PluginConfig,\n InstanceMetadata,\n} from './BlacPlugin';\n\n/**\n * Internal structure for tracking installed plugins\n * @internal\n */\ninterface InstalledPlugin {\n plugin: BlacPlugin;\n config: PluginConfig;\n context: PluginContext;\n}\n\n/**\n * Manages plugin lifecycle for the BlaC state management system.\n * Plugins receive notifications about state container lifecycle events.\n *\n * @example\n * ```ts\n * const manager = createPluginManager(registry);\n * manager.install(myPlugin, { environment: 'development' });\n * ```\n */\nexport class PluginManager {\n private plugins = new Map<string, InstalledPlugin>();\n private registry: StateContainerRegistry;\n\n /**\n * Create a new PluginManager\n * @param registry - The StateContainerRegistry to monitor for lifecycle events\n */\n constructor(registry: StateContainerRegistry) {\n this.registry = registry;\n this.setupLifecycleHooks();\n }\n\n /**\n * Install a plugin with optional configuration\n * @param plugin - The plugin to install\n * @param config - Optional plugin configuration\n * @throws Error if plugin is already installed\n */\n install(plugin: BlacPlugin, config: PluginConfig = {}): void {\n const effectiveConfig: PluginConfig = {\n enabled: true,\n environment: 'all',\n ...config,\n };\n\n if (!this.shouldEnablePlugin(effectiveConfig)) {\n console.log(\n `[BlaC] Plugin \"${plugin.name}\" skipped (environment mismatch)`,\n );\n return;\n }\n\n if (this.plugins.has(plugin.name)) {\n throw new Error(`Plugin \"${plugin.name}\" is already installed`);\n }\n\n const context = this.createPluginContext();\n\n this.plugins.set(plugin.name, {\n plugin,\n config: effectiveConfig,\n context,\n });\n\n if (plugin.onInstall) {\n try {\n plugin.onInstall(context);\n } catch (error) {\n console.error(\n `[BlaC] Error installing plugin \"${plugin.name}\":`,\n error,\n );\n this.plugins.delete(plugin.name);\n throw error;\n }\n }\n\n console.log(`[BlaC] Plugin \"${plugin.name}\" v${plugin.version} installed`);\n }\n\n /**\n * Uninstall a plugin by name\n * @param pluginName - The name of the plugin to uninstall\n * @throws Error if plugin is not installed\n */\n uninstall(pluginName: string): void {\n const installed = this.plugins.get(pluginName);\n if (!installed) {\n throw new Error(`Plugin \"${pluginName}\" is not installed`);\n }\n\n if (installed.plugin.onUninstall) {\n try {\n installed.plugin.onUninstall();\n } catch (error) {\n console.error(\n `[BlaC] Error uninstalling plugin \"${pluginName}\":`,\n error,\n );\n }\n }\n\n this.plugins.delete(pluginName);\n console.log(`[BlaC] Plugin \"${pluginName}\" uninstalled`);\n }\n\n /**\n * Get an installed plugin by name\n * @param pluginName - The name of the plugin to retrieve\n * @returns The plugin instance or undefined if not found\n */\n getPlugin(pluginName: string): BlacPlugin | undefined {\n return this.plugins.get(pluginName)?.plugin;\n }\n\n /**\n * Get all installed plugins\n * @returns Array of all installed plugins\n */\n getAllPlugins(): BlacPlugin[] {\n return Array.from(this.plugins.values()).map((p) => p.plugin);\n }\n\n /**\n * Check if a plugin is installed\n * @param pluginName - The name of the plugin to check\n * @returns true if the plugin is installed\n */\n hasPlugin(pluginName: string): boolean {\n return this.plugins.has(pluginName);\n }\n\n /**\n * Uninstall all plugins\n */\n clear(): void {\n for (const name of this.plugins.keys()) {\n this.uninstall(name);\n }\n }\n\n /**\n * Setup lifecycle hooks to notify plugins\n */\n private setupLifecycleHooks(): void {\n // Instance created\n this.registry.on('created', (instance) => {\n this.notifyPlugins('onInstanceCreated', instance);\n });\n\n // State changed\n this.registry.on(\n 'stateChanged',\n (instance, previousState, currentState, callstack) => {\n this.notifyPlugins(\n 'onStateChanged',\n instance,\n previousState,\n currentState,\n callstack,\n );\n },\n );\n\n // Instance disposed\n this.registry.on('disposed', (instance) => {\n this.notifyPlugins('onInstanceDisposed', instance);\n });\n }\n\n /**\n * Notify all plugins of a lifecycle event\n */\n private notifyPlugins(hookName: keyof BlacPlugin, ...args: any[]): void {\n for (const { plugin, config, context } of this.plugins.values()) {\n if (!config.enabled) continue;\n\n const hook = plugin[hookName];\n if (typeof hook === 'function') {\n try {\n (hook as any).apply(plugin, [...args, context]);\n } catch (error) {\n console.error(\n `[BlaC] Error in plugin \"${plugin.name}\" ${hookName}:`,\n error,\n );\n }\n }\n }\n }\n\n /**\n * Create plugin context with safe API access\n */\n private createPluginContext(): PluginContext {\n return {\n getInstanceMetadata: (\n instance: StateContainer<any>,\n ): InstanceMetadata => {\n return {\n id: instance.instanceId,\n className: instance.constructor.name,\n isDisposed: instance.isDisposed,\n name: instance.name,\n lastStateChangeTimestamp: instance.lastUpdateTimestamp,\n createdAt: instance.createdAt,\n state: instance.state,\n hydrationStatus: instance.hydrationStatus,\n isHydrated: instance.isHydrated,\n hydrationError: instance.hydrationError,\n changedWhileHydrating: instance.changedWhileHydrating,\n };\n },\n\n getState: <S extends object = any>(instance: StateContainer<S>): S => {\n return instance.state;\n },\n\n getHydrationStatus: (instance: StateContainer<any>) => {\n return instance.hydrationStatus;\n },\n\n startHydration: (instance: StateContainer<any>) => {\n instance.beginHydration();\n },\n\n applyHydratedState: <S extends object = any>(\n instance: StateContainer<S>,\n state: S,\n ): boolean => {\n return instance.applyHydratedState(state);\n },\n\n finishHydration: (instance: StateContainer<any>) => {\n instance.finishHydration();\n },\n\n failHydration: (instance: StateContainer<any>, error: Error) => {\n instance.failHydration(error);\n },\n\n waitForHydration: (instance: StateContainer<any>) => {\n return instance.waitForHydration();\n },\n\n queryInstances: <T extends StateContainer<any>>(\n typeClass: new (...args: any[]) => T,\n ): T[] => {\n return this.registry.getAll(typeClass as any);\n },\n\n getAllTypes: () => {\n return this.registry.getTypes();\n },\n\n getStats: () => {\n return this.registry.getStats();\n },\n };\n }\n\n /**\n * Check if plugin should be enabled based on environment\n */\n private shouldEnablePlugin(config: PluginConfig): boolean {\n if (!config.enabled) return false;\n if (config.environment === 'all') return true;\n\n const currentEnv = this.getCurrentEnvironment();\n return currentEnv === config.environment;\n }\n\n /**\n * Get current environment\n */\n private getCurrentEnvironment(): 'development' | 'production' | 'test' {\n if (typeof process !== 'undefined') {\n if (process.env.NODE_ENV === 'test') return 'test';\n if (process.env.NODE_ENV === 'production') return 'production';\n return 'development';\n }\n return 'development';\n }\n}\n\n/**\n * Create a plugin manager instance\n * @param registry - The StateContainerRegistry to monitor for lifecycle events\n * @returns A new PluginManager instance\n */\nexport function createPluginManager(\n registry: StateContainerRegistry,\n): PluginManager {\n return new PluginManager(registry);\n}\n","/**\n * Utility functions for accessing static properties on StateContainer classes\n */\n\nimport { BLAC_STATIC_PROPS } from '../constants';\nimport { StateContainerConstructor } from '../types/utilities';\n\n/**\n * Get a static property from a class constructor\n * Type-safe helper that avoids (Type as any) casts\n *\n * @param Type - The class constructor\n * @param propName - The property name to access\n * @param defaultValue - Optional default value if property is undefined\n * @returns The property value or default\n */\nexport function getStaticProp<\n V,\n T extends StateContainerConstructor = StateContainerConstructor,\n>(Type: T, propName: string, defaultValue?: V): V | undefined {\n return (Type as any)[propName] ?? defaultValue;\n}\n\n/**\n * Check if a class is marked as keepAlive.\n * KeepAlive classes are never auto-disposed when ref count reaches 0.\n * @param Type - The class constructor to check\n * @returns true if the class has `static keepAlive = true`\n */\nexport function isKeepAliveClass<T extends StateContainerConstructor>(\n Type: T,\n): boolean {\n return getStaticProp<boolean>(Type, BLAC_STATIC_PROPS.KEEP_ALIVE) === true;\n}\n\n/**\n * Check if a class should be excluded from DevTools.\n * Used to prevent infinite loops when DevTools tracks itself.\n * @param Type - The class constructor to check\n * @returns true if the class has `static __excludeFromDevTools = true`\n */\nexport function isExcludedFromDevTools<T extends StateContainerConstructor>(\n Type: T,\n): boolean {\n return (\n getStaticProp<boolean>(Type, BLAC_STATIC_PROPS.EXCLUDE_FROM_DEVTOOLS) ===\n true\n );\n}\n","import type { StateContainer, StateContainerConfig } from './StateContainer';\nimport { createPluginManager } from '../plugin/PluginManager';\nimport { BLAC_DEFAULTS, BLAC_ERROR_PREFIX } from '../constants';\nimport { isKeepAliveClass } from '../utils/static-props';\nimport {\n InstanceReadonlyState,\n StateContainerConstructor,\n} from '../types/utilities';\n\n/**\n * Entry in the instance registry, tracking the instance and its reference count\n * @template T - Instance type\n */\nexport interface InstanceEntry<T = any> {\n /** The state container instance */\n instance: T;\n /** Number of active references to this instance */\n refCount: number;\n}\n\n/**\n * Lifecycle events emitted by the registry\n */\nexport type LifecycleEvent = 'created' | 'stateChanged' | 'disposed';\n\n/**\n * Listener function type for each lifecycle event\n * @template E - The lifecycle event type\n */\nexport type LifecycleListener<E extends LifecycleEvent> = E extends 'created'\n ? (container: StateContainer<any>) => void\n : E extends 'stateChanged'\n ? (\n container: StateContainer<any>,\n previousState: any,\n currentState: any,\n callstack?: string,\n ) => void\n : E extends 'disposed'\n ? (container: StateContainer<any>) => void\n : never;\n\n/**\n * Central registry for managing StateContainer instances.\n * Handles instance lifecycle, ref counting, and lifecycle event emission.\n *\n * @example\n * ```ts\n * const registry = new StateContainerRegistry();\n * const instance = registry.acquire(MyBloc); // ownership, must release\n * const other = registry.ensure(OtherBloc); // no ownership, bloc-to-bloc\n * registry.on('stateChanged', (container, prev, next) => {\n * console.log('State changed:', prev, '->', next);\n * });\n * ```\n */\nexport class StateContainerRegistry {\n private readonly instancesByConstructor = new WeakMap<\n StateContainerConstructor,\n Map<string, InstanceEntry>\n >();\n\n private readonly types = new Set<StateContainerConstructor>();\n\n private readonly registeredTypeNames = new Set<string>();\n\n private readonly listeners = new Map<\n LifecycleEvent,\n Set<(...args: any[]) => void>\n >();\n\n /**\n * Register a type for lifecycle event tracking\n * @param constructor - The StateContainer class constructor\n */\n registerType<T extends StateContainerConstructor>(constructor: T): void {\n this.types.add(constructor);\n }\n\n /**\n * Register a StateContainer class with configuration\n * @param constructor - The StateContainer class constructor\n * @throws Error if type is already registered\n */\n register<T extends StateContainerConstructor>(constructor: T): void {\n const className = constructor.name;\n\n if (this.registeredTypeNames.has(className)) {\n throw new Error(\n `${BLAC_ERROR_PREFIX} Type \"${className}\" is already registered`,\n );\n }\n\n this.registeredTypeNames.add(className);\n this.registerType(constructor);\n }\n\n private ensureInstancesMap<T extends StateContainerConstructor>(\n Type: T,\n ): Map<string, InstanceEntry> {\n let instances = this.instancesByConstructor.get(Type);\n if (!instances) {\n instances = new Map<string, InstanceEntry>();\n this.instancesByConstructor.set(Type, instances);\n }\n return instances;\n }\n\n /**\n * Get the instances Map for a specific class (public API for stats/debugging)\n */\n getInstancesMap<T extends StateContainerConstructor>(\n Type: T,\n ): Map<string, InstanceEntry> {\n return this.instancesByConstructor.get(Type) || new Map();\n }\n\n /**\n * Acquire an instance with ref counting (ownership semantics).\n * Creates a new instance if one doesn't exist, or returns existing and increments ref count.\n * You must call `release()` when done to decrement the ref count.\n * @param Type - The StateContainer class constructor\n * @param instanceKey - Instance key (defaults to 'default')\n * @param options - Acquisition options\n * @param options.canCreate - Whether to create new instance if not found (default: true)\n * @param options.countRef - Whether to increment ref count (default: true)\n * @returns The state container instance\n */\n acquire<T extends StateContainerConstructor = StateContainerConstructor>(\n Type: T,\n instanceKey: string = BLAC_DEFAULTS.DEFAULT_INSTANCE_KEY,\n options: {\n canCreate?: boolean;\n countRef?: boolean;\n } = {},\n ): InstanceType<T> {\n const { canCreate = true, countRef = true } = options;\n\n const config: StateContainerConfig = {\n instanceId: instanceKey,\n };\n\n const instances = this.ensureInstancesMap(Type);\n let entry = instances.get(instanceKey);\n\n // Detect stale disposed entries (disposed directly, not through release)\n if (entry?.instance.isDisposed) {\n instances.delete(instanceKey);\n entry = undefined;\n }\n\n if (entry && countRef) {\n entry.refCount++;\n }\n\n if (entry) {\n return entry.instance;\n }\n\n if (!canCreate) {\n throw new Error(\n `${BLAC_ERROR_PREFIX} ${Type.name} instance \"${instanceKey}\" not found and creation is disabled.`,\n );\n }\n\n // Create new shared instance\n const instance = new Type() as InstanceType<T>;\n instance.initConfig(config);\n instances.set(instanceKey, { instance, refCount: 1 });\n\n // Register type for lifecycle coordination\n this.registerType(Type);\n\n return instance;\n }\n\n /**\n * Borrow an existing instance without incrementing ref count (borrowing semantics).\n * Tracks cross-bloc dependency for reactive updates.\n * @param Type - The StateContainer class constructor\n * @param instanceKey - Instance key (defaults to 'default')\n * @returns The state container instance\n * @throws Error if instance doesn't exist\n */\n borrow<T extends StateContainerConstructor = StateContainerConstructor>(\n Type: T,\n instanceKey: string = BLAC_DEFAULTS.DEFAULT_INSTANCE_KEY,\n ): InstanceType<T> {\n return this.acquire(Type, instanceKey, {\n canCreate: false,\n countRef: false,\n });\n }\n\n /**\n * Safely borrow an existing instance (borrowing semantics with error handling).\n * Returns discriminated union for type-safe conditional access.\n * @param Type - The StateContainer class constructor\n * @param instanceKey - Instance key (defaults to 'default')\n * @returns Discriminated union with either the instance or an error\n */\n borrowSafe<T extends StateContainerConstructor = StateContainerConstructor>(\n Type: T,\n instanceKey: string = BLAC_DEFAULTS.DEFAULT_INSTANCE_KEY,\n ):\n | { error: Error; instance: null }\n | { error: null; instance: InstanceType<T> } {\n try {\n const instance = this.borrow(Type, instanceKey);\n return { error: null, instance };\n } catch (error: any) {\n return { error, instance: null };\n }\n }\n\n /**\n * Ensure an instance exists without taking ownership (for bloc-to-bloc communication).\n * Gets existing instance OR creates it if it doesn't exist, without incrementing ref count.\n * Tracks cross-bloc dependency for reactive updates.\n *\n * Use this in bloc-to-bloc communication when you need to ensure an instance exists\n * but don't want to claim ownership (no ref count increment).\n * @param Type - The StateContainer class constructor\n * @param instanceKey - Instance key (defaults to 'default')\n * @returns The state container instance\n */\n ensure<T extends StateContainerConstructor = StateContainerConstructor>(\n Type: T,\n instanceKey: string = BLAC_DEFAULTS.DEFAULT_INSTANCE_KEY,\n ): InstanceType<T> {\n return this.acquire(Type, instanceKey, {\n canCreate: true,\n countRef: false,\n });\n }\n\n /**\n * Release a reference to an instance.\n * Decrements ref count and disposes when it reaches 0 (unless keepAlive).\n * @param Type - The StateContainer class constructor\n * @param instanceKey - Instance key (defaults to 'default')\n * @param forceDispose - Force immediate disposal regardless of ref count\n */\n release<T extends StateContainerConstructor>(\n Type: T,\n instanceKey: string = BLAC_DEFAULTS.DEFAULT_INSTANCE_KEY,\n forceDispose = false,\n ): void {\n const instances = this.ensureInstancesMap(Type);\n const entry = instances.get(instanceKey);\n\n if (!entry) return;\n\n // Force dispose immediately\n if (forceDispose) {\n if (!entry.instance.isDisposed) {\n entry.instance.dispose();\n }\n instances.delete(instanceKey);\n return;\n }\n\n // Decrement ref count\n entry.refCount--;\n\n // Check static keepAlive property\n const keepAlive = isKeepAliveClass(Type);\n\n // Auto-dispose when ref count reaches 0 (unless keepAlive)\n if (entry.refCount <= 0 && !keepAlive) {\n if (!entry.instance.isDisposed) {\n entry.instance.dispose();\n }\n instances.delete(instanceKey);\n }\n }\n\n /**\n * Get all instances of a specific type.\n * @param Type - The StateContainer class constructor\n * @returns Array of all instances\n */\n getAll<T extends StateContainerConstructor>(\n Type: T,\n ): InstanceReadonlyState<T>[] {\n const instances = this.ensureInstancesMap(Type);\n const result: InstanceReadonlyState<T>[] = [];\n for (const entry of instances.values()) {\n result.push(entry.instance);\n }\n return result;\n }\n\n /**\n * Safely iterate over all instances of a type.\n * Skips disposed instances and catches callback errors.\n * @param Type - The StateContainer class constructor\n * @param callback - Function to call for each instance\n */\n forEach<T extends StateContainerConstructor>(\n Type: T,\n callback: (instance: InstanceReadonlyState<T>) => void,\n ): void {\n const instances = this.ensureInstancesMap(Type);\n for (const entry of instances.values()) {\n const instance = entry.instance;\n if (!instance.isDisposed) {\n try {\n callback(instance);\n } catch (error) {\n console.error(\n `${BLAC_ERROR_PREFIX} forEach callback error for ${Type.name}:`,\n error,\n );\n }\n }\n }\n }\n\n /**\n * Clear all instances of a specific type (disposes them).\n * @param Type - The StateContainer class constructor\n */\n clear<T extends StateContainerConstructor>(Type: T): void {\n const instances = this.ensureInstancesMap(Type);\n // Dispose all instances\n for (const entry of instances.values()) {\n if (!entry.instance.isDisposed) {\n entry.instance.dispose();\n }\n }\n // Clear the Map\n instances.clear();\n }\n\n /**\n * Get reference count for an instance.\n * @param Type - The StateContainer class constructor\n * @param instanceKey - Instance key (defaults to 'default')\n * @returns Current ref count (0 if instance doesn't exist)\n */\n getRefCount<T extends StateContainerConstructor>(\n Type: T,\n instanceKey: string = BLAC_DEFAULTS.DEFAULT_INSTANCE_KEY,\n ): number {\n const instances = this.ensureInstancesMap(Type);\n const entry = instances.get(instanceKey);\n return entry?.refCount ?? 0;\n }\n\n /**\n * Check if an instance exists.\n * @param Type - The StateContainer class constructor\n * @param instanceKey - Instance key (defaults to 'default')\n * @returns true if instance exists\n */\n hasInstance<T extends StateContainerConstructor>(\n Type: T,\n instanceKey: string = BLAC_DEFAULTS.DEFAULT_INSTANCE_KEY,\n ): boolean {\n const instances = this.ensureInstancesMap(Type);\n return instances.has(instanceKey);\n }\n\n /**\n * Clear all instances from all types (for testing)\n *\n * Iterates all registered types and clears their instances.\n * Also clears type tracking to reset the registry state.\n */\n clearAll(): void {\n // Step 1: Clear instances from each type (while we still have the types list)\n for (const Type of this.types) {\n this.clear(Type);\n }\n // Step 2: Now clear type tracking (resets registry state for tests)\n this.types.clear();\n this.registeredTypeNames.clear();\n }\n\n /**\n * Get registry statistics for debugging.\n * @returns Object with registeredTypes, totalInstances, and typeBreakdown\n */\n getStats(): {\n registeredTypes: number;\n totalInstances: number;\n typeBreakdown: Record<string, number>;\n } {\n const typeBreakdown: Record<string, number> = {};\n let totalInstances = 0;\n\n // Collect stats from each registered type\n for (const Type of this.types) {\n const typeName = Type.name;\n const instances = this.getInstancesMap(Type);\n const count = instances.size;\n\n typeBreakdown[typeName] = count;\n totalInstances += count;\n }\n\n return {\n registeredTypes: this.types.size,\n totalInstances,\n typeBreakdown,\n };\n }\n\n /**\n * Get all registered types (for plugin system).\n * @returns Array of all registered StateContainer class constructors\n */\n getTypes(): StateContainerConstructor[] {\n return Array.from(this.types);\n }\n\n /**\n * Subscribe to lifecycle events\n * @param event - The lifecycle event to listen for\n * @param listener - The listener function to call when the event occurs\n * @returns Unsubscribe function\n */\n on<E extends LifecycleEvent>(\n event: E,\n listener: LifecycleListener<E>,\n ): () => void {\n if (!this.listeners.has(event)) {\n this.listeners.set(event, new Set());\n }\n const instance = this.listeners.get(event);\n if (!instance) {\n throw new Error(\n `${BLAC_ERROR_PREFIX} Failed to register listener for event '${event}'`,\n );\n }\n\n instance.add(listener as (...args: any[]) => void);\n\n // Return unsubscribe function\n return () => {\n this.listeners.get(event)?.delete(listener as (...args: any[]) => void);\n };\n }\n\n /**\n * Emit lifecycle event to all listeners\n * @internal - Called by StateContainer lifecycle methods\n */\n emit(event: LifecycleEvent, ...args: any[]): void {\n const listeners = this.listeners.get(event);\n if (!listeners || listeners.size === 0) return; // Zero overhead when no listeners\n\n for (const listener of listeners) {\n try {\n listener(...args);\n } catch (error) {\n console.error(\n `${BLAC_ERROR_PREFIX} Listener error for '${event}':`,\n error,\n );\n }\n }\n }\n}\n\n/**\n * Global default registry instance\n */\nexport const globalRegistry = new StateContainerRegistry();\n\n/**\n * Global plugin manager (initialized lazily)\n */\nlet _globalPluginManager: any = null;\n\n/**\n * Get the global plugin manager\n */\nexport function getPluginManager(): any {\n if (!_globalPluginManager) {\n _globalPluginManager = createPluginManager(globalRegistry);\n }\n return _globalPluginManager;\n}\n"],"mappings":";;;;;;;;;AASA,MAAa,gBAAgB;CAI3B,sBAAsB;CAKtB,kBAAkB;CAKlB,qBAAqB;CAKrB,6BAA6B;CAK7B,mBAAmB;CAKnB,6BAA6B;CAK7B,qBAAqB;CAKrB,+BAA+B;CAK/B,qBAAqB;CACtB;;;;;AAMD,MAAa,oBAAoB;CAI/B,YAAY;CAKZ,uBAAuB;CACxB;;;;AAeD,MAAa,oBAAoB;;;;;;;;;;;;;ACxDjC,IAAa,gBAAb,MAA2B;;;;;CAQzB,YAAY,UAAkC;iCAP5B,IAAI,KAA8B;AAQlD,OAAK,WAAW;AAChB,OAAK,qBAAqB;;;;;;;;CAS5B,QAAQ,QAAoB,SAAuB,EAAE,EAAQ;EAC3D,MAAM,kBAAgC;GACpC,SAAS;GACT,aAAa;GACb,GAAG;GACJ;AAED,MAAI,CAAC,KAAK,mBAAmB,gBAAgB,EAAE;AAC7C,WAAQ,IACN,kBAAkB,OAAO,KAAK,kCAC/B;AACD;;AAGF,MAAI,KAAK,QAAQ,IAAI,OAAO,KAAK,CAC/B,OAAM,IAAI,MAAM,WAAW,OAAO,KAAK,wBAAwB;EAGjE,MAAM,UAAU,KAAK,qBAAqB;AAE1C,OAAK,QAAQ,IAAI,OAAO,MAAM;GAC5B;GACA,QAAQ;GACR;GACD,CAA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;CAS/B,GACE,OACA,UACY;AACZ,MAAI,CAAC,KAAK,UAAU,IAAI,MAAM,CAC5B,MAAK,UAAU,IAAI,uBAAO,IAAI,KAAK,CAAC;EAEtC,MAAM,WAAW,KAAK,UAAU,IAAI,MAAM;AAC1C,MAAI,CAAC,SACH,OAAM,IAAI,MACR,GAAG,kBAAkB,0CAA0C,MAAM,GACtE;AAGH,WAAS,IAAI,SAAqC;AAGlD,eAAa;AACX,QAAK,UAAU,IAAI,MAAM,EAAE,OAAO,SAAqC;;;;;;;CAQ3E,KAAK,OAAuB,GAAG,MAAmB;EAChD,MAAM,YAAY,KAAK,UAAU,IAAI,MAAM;AAC3C,MAAI,CAAC,aAAa,UAAU,SAAS,EAAG;AAExC,OAAK,MAAM,YAAY,UACrB,KAAI;AACF,YAAS,GAAG,KAAK;WACV,OAAO;AACd,WAAQ,MACN,GAAG,kBAAkB,uBAAuB,MAAM,KAClD,MACD;;;;;;;AAST,MAAa,iBAAiB,IAAI,wBAAwB;;;;AAK1D,IAAI,uBAA4B;;;;AAKhC,SAAgB,mBAAwB;AACtC,KAAI,CAAC,qBACH,wBAAuB,oBAAoB,eAAe;AAE5D,QAAO"}
@@ -1,4 +1,4 @@
1
- import { n as globalRegistry } from "./StateContainerRegistry-Brmferpf.js";
1
+ import { n as globalRegistry } from "./StateContainerRegistry-DS_wyKck.js";
2
2
  //#region src/registry/queries.ts
3
3
  function hasInstance(BlocClass, instanceKey) {
4
4
  return globalRegistry.hasInstance(BlocClass, instanceKey);
@@ -20,8 +20,8 @@ function clear(BlocClass) {
20
20
  function clearAll() {
21
21
  globalRegistry.clearAll();
22
22
  }
23
- function register(BlocClass, isolated = false) {
24
- globalRegistry.register(BlocClass, isolated);
23
+ function register(BlocClass) {
24
+ globalRegistry.register(BlocClass);
25
25
  }
26
26
  //#endregion
27
27
  //#region src/registry/config.ts
@@ -39,4 +39,4 @@ function getStats() {
39
39
  //#endregion
40
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
41
 
42
- //# sourceMappingURL=config-BmFnPVM0.js.map
42
+ //# sourceMappingURL=config-BD9MkJ0k.js.map
@@ -1 +1 @@
1
- {"version":3,"file":"config-BmFnPVM0.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 isolated = false,\n): void {\n globalRegistry.register(BlocClass, isolated);\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,WACA,WAAW,OACL;AACN,gBAAe,SAAS,WAAW,SAAS;;;;ACV9C,IAAI,YAAY;AAEhB,SAAgB,cAAsC;AACpD,QAAO;;AAGT,SAAgB,YAAY,UAAwC;AAClE,WAAU,UAAU;AACpB,aAAY;;AAGd,SAAgB,WAId;AACA,QAAO,UAAU,UAAU"}
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"}
@@ -1,4 +1,4 @@
1
- const require_StateContainerRegistry = require("./StateContainerRegistry-CVPTMaHn.cjs");
1
+ const require_StateContainerRegistry = require("./StateContainerRegistry-COxgpYAw.cjs");
2
2
  //#region src/registry/queries.ts
3
3
  function hasInstance(BlocClass, instanceKey) {
4
4
  return require_StateContainerRegistry.globalRegistry.hasInstance(BlocClass, instanceKey);
@@ -20,8 +20,8 @@ function clear(BlocClass) {
20
20
  function clearAll() {
21
21
  require_StateContainerRegistry.globalRegistry.clearAll();
22
22
  }
23
- function register(BlocClass, isolated = false) {
24
- require_StateContainerRegistry.globalRegistry.register(BlocClass, isolated);
23
+ function register(BlocClass) {
24
+ require_StateContainerRegistry.globalRegistry.register(BlocClass);
25
25
  }
26
26
  //#endregion
27
27
  //#region src/registry/config.ts
@@ -98,4 +98,4 @@ Object.defineProperty(exports, "setRegistry", {
98
98
  }
99
99
  });
100
100
 
101
- //# sourceMappingURL=config-BInS_9WT.cjs.map
101
+ //# sourceMappingURL=config-DTuCbHcJ.cjs.map
@@ -1 +1 @@
1
- {"version":3,"file":"config-BInS_9WT.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 isolated = false,\n): void {\n globalRegistry.register(BlocClass, isolated);\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,WACA,WAAW,OACL;AACN,gCAAA,eAAe,SAAS,WAAW,SAAS;;;;ACV9C,IAAI,YAAYC,+BAAAA;AAEhB,SAAgB,cAAsC;AACpD,QAAO;;AAGT,SAAgB,YAAY,UAAwC;AAClE,WAAU,UAAU;AACpB,aAAY;;AAGd,SAAgB,WAId;AACA,QAAO,UAAU,UAAU"}
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"}
@@ -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
  */
@@ -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
  }