@blac/core
Advanced tools
| /** | ||
| * Framework Adapter - Reusable logic for integrating BlaC with any reactive framework | ||
| * | ||
| * This module provides framework-agnostic utilities for: | ||
| * - Subscription management (auto-tracking, manual deps, no-tracking modes) | ||
| * - Snapshot generation (state proxies with tracking) | ||
| * - External dependency management (cross-bloc subscriptions) | ||
| * - Change detection (state and getter tracking) | ||
| * | ||
| * Can be used to integrate BlaC with React, Vue, Solid, Svelte, Angular, etc. | ||
| */ | ||
| import type { StateContainer } from '../core/StateContainer'; | ||
| import type { TrackerState, GetterTrackerState } from '../tracking'; | ||
| import type { ExtractState } from '../types/utilities'; | ||
| /** | ||
| * Framework-agnostic adapter state | ||
| * Frameworks should store this in their component state mechanism | ||
| */ | ||
| export interface AdapterState<TBloc extends StateContainer<any>> { | ||
| /** State property tracker */ | ||
| tracker: TrackerState<ExtractState<TBloc>> | null; | ||
| /** Manual dependencies cache */ | ||
| manualDepsCache: unknown[] | null; | ||
| /** Getter tracking state */ | ||
| getterTracker: GetterTrackerState | null; | ||
| /** Cached proxied bloc instance */ | ||
| proxiedBloc: TBloc | null; | ||
| } | ||
| /** | ||
| * Configuration for manual dependencies mode | ||
| */ | ||
| export interface ManualDepsConfig<TBloc extends StateContainer<any>> { | ||
| dependencies: (state: any, bloc: TBloc) => unknown[]; | ||
| } | ||
| /** | ||
| * Subscription callback type | ||
| * Called when the framework should re-render | ||
| */ | ||
| export type SubscriptionCallback = () => void; | ||
| /** | ||
| * Subscription function type | ||
| * Returns an unsubscribe function | ||
| */ | ||
| export type SubscribeFunction = (callback: SubscriptionCallback) => () => void; | ||
| /** | ||
| * Snapshot function type | ||
| * Returns the current state (possibly proxied) | ||
| */ | ||
| export type SnapshotFunction<TState> = () => TState; | ||
| /** | ||
| * External dependency manager | ||
| * Handles subscriptions to external blocs accessed in getters | ||
| */ | ||
| export declare class ExternalDependencyManager { | ||
| private subscriptions; | ||
| private previousDeps; | ||
| /** | ||
| * Check if dependencies have changed | ||
| */ | ||
| private areDependenciesEqual; | ||
| /** | ||
| * Update external subscriptions | ||
| * @param getterTracker - The getter tracker state | ||
| * @param rawInstance - The raw bloc instance (exclude from subscriptions) | ||
| * @param onGetterChange - Callback when external getter changes | ||
| * @returns Whether subscriptions were updated | ||
| */ | ||
| updateSubscriptions(getterTracker: GetterTrackerState | null, rawInstance: StateContainer<any>, onGetterChange: () => void): boolean; | ||
| /** | ||
| * Cleanup all subscriptions | ||
| */ | ||
| cleanup(): void; | ||
| } | ||
| /** | ||
| * Create a subscription function for auto-tracking mode | ||
| */ | ||
| export declare function createAutoTrackSubscribe<TBloc extends StateContainer<any>>(instance: TBloc, adapterState: AdapterState<TBloc>): SubscribeFunction; | ||
| /** | ||
| * Create a subscription function for manual dependencies mode | ||
| */ | ||
| export declare function createManualDepsSubscribe<TBloc extends StateContainer<any>>(instance: TBloc, adapterState: AdapterState<TBloc>, config: ManualDepsConfig<TBloc>): SubscribeFunction; | ||
| /** | ||
| * Create a subscription function for no-tracking mode | ||
| */ | ||
| export declare function createNoTrackSubscribe<TBloc extends StateContainer<any>>(instance: TBloc): SubscribeFunction; | ||
| /** | ||
| * Create a snapshot function for auto-tracking mode | ||
| */ | ||
| export declare function createAutoTrackSnapshot<TBloc extends StateContainer<any>>(instance: TBloc, adapterState: AdapterState<TBloc>): SnapshotFunction<ExtractState<TBloc>>; | ||
| /** | ||
| * Create a snapshot function for manual dependencies mode | ||
| */ | ||
| export declare function createManualDepsSnapshot<TBloc extends StateContainer<any>>(instance: TBloc, adapterState: AdapterState<TBloc>, config: ManualDepsConfig<TBloc>): SnapshotFunction<ExtractState<TBloc>>; | ||
| /** | ||
| * Create a snapshot function for no-tracking mode | ||
| */ | ||
| export declare function createNoTrackSnapshot<TBloc extends StateContainer<any>>(instance: TBloc): SnapshotFunction<ExtractState<TBloc>>; | ||
| /** | ||
| * Initialize adapter state for auto-tracking mode | ||
| */ | ||
| export declare function initAutoTrackState<TBloc extends StateContainer<any>>(instance: TBloc): AdapterState<TBloc>; | ||
| /** | ||
| * Initialize adapter state for manual dependencies mode | ||
| */ | ||
| export declare function initManualDepsState<TBloc extends StateContainer<any>>(instance: TBloc): AdapterState<TBloc>; | ||
| /** | ||
| * Initialize adapter state for no-tracking mode | ||
| */ | ||
| export declare function initNoTrackState<TBloc extends StateContainer<any>>(instance: TBloc): AdapterState<TBloc>; | ||
| /** | ||
| * Disable getter tracking (call after render completes) | ||
| */ | ||
| export declare function disableGetterTracking<TBloc extends StateContainer<any>>(adapterState: AdapterState<TBloc>, rawInstance: TBloc): void; | ||
| //# sourceMappingURL=framework-adapter.d.ts.map |
| {"version":3,"file":"framework-adapter.d.ts","sourceRoot":"","sources":["../../src/adapter/framework-adapter.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;GAUG;AAEH,OAAO,KAAK,EAAE,cAAc,EAAE,MAAM,wBAAwB,CAAC;AAC7D,OAAO,KAAK,EAAE,YAAY,EAAE,kBAAkB,EAAE,MAAM,aAAa,CAAC;AACpE,OAAO,KAAK,EAAE,YAAY,EAAE,MAAM,oBAAoB,CAAC;AAmBvD;;;GAGG;AACH,MAAM,WAAW,YAAY,CAAC,KAAK,SAAS,cAAc,CAAC,GAAG,CAAC;IAC7D,6BAA6B;IAC7B,OAAO,EAAE,YAAY,CAAC,YAAY,CAAC,KAAK,CAAC,CAAC,GAAG,IAAI,CAAC;IAClD,gCAAgC;IAChC,eAAe,EAAE,OAAO,EAAE,GAAG,IAAI,CAAC;IAClC,4BAA4B;IAC5B,aAAa,EAAE,kBAAkB,GAAG,IAAI,CAAC;IACzC,mCAAmC;IACnC,WAAW,EAAE,KAAK,GAAG,IAAI,CAAC;CAC3B;AAED;;GAEG;AACH,MAAM,WAAW,gBAAgB,CAAC,KAAK,SAAS,cAAc,CAAC,GAAG,CAAC;IACjE,YAAY,EAAE,CAAC,KAAK,EAAE,GAAG,EAAE,IAAI,EAAE,KAAK,KAAK,OAAO,EAAE,CAAC;CACtD;AAED;;;GAGG;AACH,MAAM,MAAM,oBAAoB,GAAG,M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;GAEG;AACH,wBAAgB,wBAAwB,CAAC,KAAK,SAAS,cAAc,CAAC,GAAG,CAAC,EACxE,QAAQ,EAAE,KAAK,EACf,YAAY,EAAE,YAAY,CAAC,KAAK,CAAC,EACjC,MAAM,EAAE,gBAAgB,CAAC,KAAK,CAAC,GAC9B,gBAAgB,CAAC,YAAY,CAAC,KAAK,CAAC,CAAC,CAQvC;AAED;;GAEG;AACH,wBAAgB,qBAAqB,CAAC,KAAK,SAAS,cAAc,CAAC,GAAG,CAAC,EACrE,QAAQ,EAAE,KAAK,GACd,gBAAgB,CAAC,YAAY,CAAC,KAAK,CAAC,CAAC,CAEvC;AAED;;GAEG;AACH,wBAAgB,kBAAkB,CAAC,KAAK,SAAS,cAAc,CAAC,GAAG,CAAC,EAClE,QAAQ,EAAE,KAAK,GACd,YAAY,CAAC,KAAK,CAAC,CAOrB;AAED;;GAEG;AACH,wBAAgB,mBAAmB,CAAC,KAAK,SAAS,cAAc,CAAC,GAAG,CAAC,EACnE,QAAQ,EAAE,KAAK,GACd,YAAY,CAAC,KAAK,CAAC,CAOrB;AAED;;GAEG;AACH,wBAAgB,gBAAgB,CAAC,KAAK,SAAS,cAAc,CAAC,GAAG,CAAC,EAChE,QAAQ,EAAE,KAAK,GACd,YAAY,CAAC,KAAK,CAAC,CAOrB;AAED;;GAEG;AACH,wBAAgB,qBAAqB,CAAC,KAAK,SAAS,cAAc,CAAC,GAAG,CAAC,EACrE,YAAY,EAAE,YAAY,CAAC,KAAK,CAAC,EACjC,WAAW,EAAE,KAAK,GACjB,IAAI,CAKN"} |
| /** | ||
| * Framework Adapter | ||
| * | ||
| * Reusable utilities for integrating BlaC with any reactive framework. | ||
| * Use these to build integrations for React, Vue, Solid, Svelte, Angular, etc. | ||
| */ | ||
| export { type AdapterState, type ManualDepsConfig, type SubscriptionCallback, type SubscribeFunction, type SnapshotFunction, ExternalDependencyManager, createAutoTrackSubscribe, createManualDepsSubscribe, createNoTrackSubscribe, createAutoTrackSnapshot, createManualDepsSnapshot, createNoTrackSnapshot, initAutoTrackState, initManualDepsState, initNoTrackState, disableGetterTracking, } from './framework-adapter'; | ||
| //# sourceMappingURL=index.d.ts.map |
| {"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../src/adapter/index.ts"],"names":[],"mappings":"AAAA;;;;;GAKG;AAEH,OAAO,EACL,KAAK,YAAY,EACjB,KAAK,gBAAgB,EACrB,KAAK,oBAAoB,EACzB,KAAK,iBAAiB,EACtB,KAAK,gBAAgB,EACrB,yBAAyB,EACzB,wBAAwB,EACxB,yBAAyB,EACzB,sBAAsB,EACtB,uBAAuB,EACvB,wBAAwB,EACxB,qBAAqB,EACrB,kBAAkB,EAClB,mBAAmB,EACnB,gBAAgB,EAChB,qBAAqB,GACtB,MAAM,qBAAqB,CAAC"} |
| /** | ||
| * Default configuration constants for BlaC | ||
| * | ||
| * Centralized location for all magic numbers and default values. | ||
| */ | ||
| /** | ||
| * Default configuration constants for BlaC | ||
| */ | ||
| export declare const BLAC_DEFAULTS: { | ||
| /** | ||
| * Default instance key for shared instances | ||
| */ | ||
| readonly DEFAULT_INSTANCE_KEY: "default"; | ||
| /** | ||
| * Maximum getter nesting depth (prevents infinite recursion) | ||
| */ | ||
| readonly MAX_GETTER_DEPTH: 10; | ||
| /** | ||
| * Default cleanup interval for subscriptions (30 seconds) | ||
| */ | ||
| readonly CLEANUP_INTERVAL_MS: 30000; | ||
| /** | ||
| * Cleanup interval for weak reference stage (10 seconds) | ||
| */ | ||
| readonly WEAKREF_CLEANUP_INTERVAL_MS: 10000; | ||
| /** | ||
| * Default maximum subscriptions per container | ||
| */ | ||
| readonly MAX_SUBSCRIPTIONS: 1000; | ||
| /** | ||
| * Maximum subscriptions for high-performance mode | ||
| */ | ||
| readonly MAX_SUBSCRIPTIONS_HIGH_PERF: 10000; | ||
| /** | ||
| * Default timeout for pipeline execution (5 seconds) | ||
| */ | ||
| readonly PIPELINE_TIMEOUT_MS: 5000; | ||
| /** | ||
| * Cleanup interval for high-performance mode (5 seconds) | ||
| */ | ||
| readonly CLEANUP_INTERVAL_HIGH_PERF_MS: 5000; | ||
| /** | ||
| * Maximum number of stages in a pipeline | ||
| */ | ||
| readonly MAX_PIPELINE_STAGES: 30; | ||
| }; | ||
| /** | ||
| * Static property names for StateContainer classes | ||
| * Used for feature flags and configuration on bloc classes | ||
| */ | ||
| export declare const BLAC_STATIC_PROPS: { | ||
| /** | ||
| * Mark a bloc as isolated (each component gets its own instance) | ||
| */ | ||
| readonly ISOLATED: "isolated"; | ||
| /** | ||
| * Mark a bloc to never be auto-disposed (kept alive permanently) | ||
| */ | ||
| readonly KEEP_ALIVE: "keepAlive"; | ||
| /** | ||
| * Exclude a bloc from DevTools reporting (prevents infinite loops) | ||
| */ | ||
| readonly EXCLUDE_FROM_DEVTOOLS: "__excludeFromDevTools"; | ||
| }; | ||
| /** | ||
| * ID generation patterns and constants | ||
| */ | ||
| export declare const BLAC_ID_PATTERNS: { | ||
| /** | ||
| * Prefix for isolated instance keys | ||
| */ | ||
| readonly ISOLATED_PREFIX: "isolated-"; | ||
| /** | ||
| * Length of generated ID portion (9 characters from base36) | ||
| */ | ||
| readonly ID_LENGTH: 9; | ||
| }; | ||
| /** | ||
| * Standard error message prefix | ||
| */ | ||
| export declare const BLAC_ERROR_PREFIX: "[BlaC]"; | ||
| //# sourceMappingURL=constants.d.ts.map |
| {"version":3,"file":"constants.d.ts","sourceRoot":"","sources":["../src/constants.ts"],"names":[],"mappings":"AAAA;;;;GAIG;AAEH;;GAEG;AACH,eAAO,MAAM,aAAa;IACxB;;OAEG;;IAGH;;OAEG;;IAGH;;OAEG;;IAGH;;OAEG;;IAGH;;OAEG;;IAGH;;OAEG;;IAGH;;OAEG;;IAGH;;OAEG;;IAGH;;OAEG;;CAEK,CAAC;AAEX;;;GAGG;AACH,eAAO,MAAM,iBAAiB;IAC5B;;OAEG;;IAGH;;OAEG;;IAGH;;OAEG;;CAEK,CAAC;AAEX;;GAEG;AACH,eAAO,MAAM,gBAAgB;IAC3B;;OAEG;;IAGH;;OAEG;;CAEK,CAAC;AAEX;;GAEG;AACH,eAAO,MAAM,iBAAiB,EAAG,QAAiB,CAAC"} |
| /** | ||
| * Cubit - Simple state container with direct state emission | ||
| * | ||
| * This validates that our StateContainer design can support | ||
| * the simple Cubit pattern from the original BlaC. | ||
| */ | ||
| import { StateContainer } from './StateContainer'; | ||
| /** | ||
| * Cubit is a simple state container that allows direct state emission | ||
| * | ||
| * Unlike StateContainer (where emit is protected), Cubit exposes emit and update | ||
| * as public methods to allow direct state management. | ||
| */ | ||
| export declare abstract class Cubit<S> extends StateContainer<S> { | ||
| /** | ||
| * Create a new Cubit | ||
| * @param initialState Initial state value | ||
| */ | ||
| constructor(initialState: S); | ||
| /** | ||
| * Emit a new state (public override of protected parent method) | ||
| */ | ||
| emit(newState: S): void; | ||
| /** | ||
| * Update state using a function (public override of protected parent method) | ||
| */ | ||
| update(updater: (current: S) => S): void; | ||
| /** | ||
| * Patch state with partial updates (shallow merge) | ||
| * Only available when state is an object type | ||
| * Arrow function to maintain correct 'this' binding in React | ||
| * | ||
| * @example | ||
| * ```typescript | ||
| * // Update single field | ||
| * this.patch({ count: 5 }); | ||
| * | ||
| * // Update multiple fields | ||
| * this.patch({ count: 5, name: 'Updated' }); | ||
| * ``` | ||
| */ | ||
| patch: S extends object ? (partial: Partial<S>) => void : never; | ||
| } | ||
| /** | ||
| * Example: Counter Cubit | ||
| */ | ||
| export declare class CounterCubit extends Cubit<number> { | ||
| constructor(); | ||
| increment: () => void; | ||
| decrement: () => void; | ||
| reset: () => void; | ||
| addAmount: (amount: number) => void; | ||
| } | ||
| /** | ||
| * Example: Complex State Cubit | ||
| */ | ||
| export interface TodoState { | ||
| todos: Array<{ | ||
| id: string; | ||
| text: string; | ||
| done: boolean; | ||
| }>; | ||
| filter: 'all' | 'active' | 'completed'; | ||
| isLoading: boolean; | ||
| } | ||
| export declare class TodoCubit extends Cubit<TodoState> { | ||
| static keepAlive: boolean; | ||
| private nextId; | ||
| constructor(); | ||
| addTodo: (text: string) => void; | ||
| toggleTodo: (id: string) => void; | ||
| removeTodo: (id: string) => void; | ||
| setFilter: (filter: TodoState["filter"]) => void; | ||
| setLoading: (isLoading: boolean) => void; | ||
| get visibleTodos(): { | ||
| id: string; | ||
| text: string; | ||
| done: boolean; | ||
| }[]; | ||
| get activeTodoCount(): number; | ||
| } | ||
| //# sourceMappingURL=Cubit.d.ts.map |
| {"version":3,"file":"Cubit.d.ts","sourceRoot":"","sources":["../../src/core/Cubit.ts"],"names":[],"mappings":"AAAA;;;;;GAKG;AAEH,OAAO,EAAE,cAAc,EAAE,MAAM,kBAAkB,CAAC;AAElD;;;;;GAKG;AACH,8BAAsB,KAAK,CAAC,CAAC,CAAE,SAAQ,cAAc,CAAC,CAAC,CAAC;IACtD;;;OAGG;gBACS,YAAY,EAAE,CAAC;IAI3B;;OAEG;IACI,IAAI,CAAC,QAAQ,EAAE,CAAC,GAAG,IAAI;IAI9B;;OAEG;IACI,MAAM,CAAC,OAAO,EAAE,CAAC,OAAO,EAAE,CAAC,KAAK,CAAC,GAAG,IAAI;IAI/C;;;;;;;;;;;;;OAaG;IACI,KAAK,EAKN,CAAC,SAAS,MAAM,GAAG,CAAC,OAAO,EAAE,OAAO,CAAC,CAAC,CAAC,KAAK,IAAI,GAAG,KAAK,CAAC;CAChE;AAED;;GAEG;AACH,qBAAa,YAAa,SAAQ,KAAK,CAAC,MAAM,CAAC;;IAK7C,SAAS,QAAO,IAAI,CAElB;IAEF,SAAS,QAAO,IAAI,CAElB;IAEF,KAAK,QAAO,IAAI,CAEd;IAEF,SAAS,GAAI,QAAQ,MAAM,KAAG,IAAI,CAEhC;CACH;AAED;;GAEG;AACH,MAAM,WAAW,SAAS;IACxB,KAAK,EAAE,KAAK,CAAC;QAAE,EAAE,EAAE,MAAM,CAAC;QAAC,IAAI,EAAE,MAAM,CAAC;QAAC,IAAI,EAAE,OAAO,CAAA;KAAE,CAAC,CAAC;IAC1D,MAAM,EAAE,KAAK,GAAG,QAAQ,GAAG,WAAW,CAAC;IACvC,SAAS,EAAE,OAAO,CAAC;CACpB;AAED,qBAAa,SAAU,SAAQ,KAAK,CAAC,SAAS,CAAC;IAC7C,MAAM,CAAC,SAAS,UAAQ;IACxB,OAAO,CAAC,MAAM,CAAK;;IAUnB,OAAO,GAAI,MAAM,MAAM,KAAG,IAAI,CAQ5B;IAEF,UAAU,GAAI,IAAI,MAAM,KAAG,IAAI,CAO7B;IAEF,UAAU,GAAI,IAAI,MAAM,KAAG,IAAI,CAK7B;IAEF,SAAS,GAAI,QAAQ,SAAS,CAAC,QAAQ,CAAC,KAAG,IAAI,CAE7C;IAEF,UAAU,GAAI,WAAW,OAAO,KAAG,IAAI,CAErC;IAEF,IAAI,YAAY;YAnDG,MAAM;cAAQ,MAAM;cAAQ,OAAO;QAgErD;IAED,IAAI,eAAe,WAElB;CACF"} |
| /** | ||
| * StateContainer - Clean, minimal state management container | ||
| * | ||
| * Responsibilities: | ||
| * - State storage and updates | ||
| * - Change notifications to subscribers | ||
| * - Lifecycle management | ||
| */ | ||
| import { StateContainerRegistry } from './StateContainerRegistry'; | ||
| /** | ||
| * Configuration options for StateContainer | ||
| */ | ||
| export interface StateContainerConfig { | ||
| /** Container name for debugging */ | ||
| name?: string; | ||
| /** Enable debug logging */ | ||
| debug?: boolean; | ||
| /** Custom instance identifier */ | ||
| instanceId?: string; | ||
| } | ||
| /** | ||
| * Listener function for state changes | ||
| */ | ||
| type StateListener<S> = (state: S) => void; | ||
| /** | ||
| * Base abstract class for all state containers | ||
| */ | ||
| export declare abstract class StateContainer<S> { | ||
| /** | ||
| * Exclude this class from DevTools reporting | ||
| * Set to true for internal/DevTools-related Blocs to prevent infinite loops | ||
| */ | ||
| static __excludeFromDevTools: boolean; | ||
| /** | ||
| * Global registry for lifecycle events and instance management | ||
| */ | ||
| protected static _registry: StateContainerRegistry; | ||
| /** | ||
| * Get the global registry (mainly for testing) | ||
| */ | ||
| static getRegistry(): StateContainerRegistry; | ||
| /** | ||
| * Set a custom registry (mainly for testing) | ||
| * | ||
| * Clears all instances before switching to ensure clean test isolation. | ||
| */ | ||
| static setRegistry(registry: StateContainerRegistry): void; | ||
| /** | ||
| * Register a type as isolated or shared | ||
| */ | ||
| static register<T extends StateContainer<any>>(this: new (...args: any[]) => T, isolated?: boolean): void; | ||
| /** | ||
| * Resolve an instance with ref counting (ownership semantics) | ||
| * | ||
| * Delegates to the global registry for instance management. | ||
| * | ||
| * @param instanceKey - Optional instance key for shared instances | ||
| * @param constructorArgs - Constructor arguments | ||
| * @returns Instance with incremented ref count | ||
| */ | ||
| static resolve<T extends StateContainer<any>>(this: new (...args: any[]) => T, instanceKey?: string, constructorArgs?: any): T; | ||
| /** | ||
| * Get an existing instance without ref counting (borrowing semantics) | ||
| * Delegates to the global registry. | ||
| */ | ||
| static get<T extends StateContainer<any>>(this: new (...args: any[]) => T, instanceKey?: string): T; | ||
| /** | ||
| * Safely get an existing instance (borrowing semantics with error handling) | ||
| * Delegates to the global registry. | ||
| */ | ||
| static getSafe<T extends StateContainer<any>>(this: new (...args: any[]) => T, instanceKey?: string): { | ||
| error: Error; | ||
| instance: null; | ||
| } | { | ||
| error: null; | ||
| instance: T; | ||
| }; | ||
| /** | ||
| * Connect to an instance with borrowing semantics (for B2B communication) | ||
| * Gets existing instance OR creates it if it doesn't exist, without incrementing ref count. | ||
| * Tracks cross-bloc dependency for reactive updates. | ||
| * | ||
| * Use this in bloc-to-bloc communication when you need to ensure an instance exists | ||
| * but don't want to claim ownership (no ref count increment). | ||
| * | ||
| * Delegates to the global registry. | ||
| * | ||
| * @param instanceKey - Optional instance key (defaults to 'default') | ||
| * @param constructorArgs - Constructor arguments (only used if creating new instance) | ||
| * @returns The bloc instance | ||
| */ | ||
| static connect<T extends StateContainer<any>>(this: new (...args: any[]) => T, instanceKey?: string, constructorArgs?: any): T; | ||
| /** | ||
| * Release a reference to an instance | ||
| * Delegates to the global registry. | ||
| */ | ||
| static release<T extends StateContainer<any>>(this: new (...args: any[]) => T, instanceKey?: string, forceDispose?: boolean): void; | ||
| /** | ||
| * Get all instances of this type | ||
| * Delegates to the global registry. | ||
| */ | ||
| static getAll<T extends StateContainer<any>>(this: new (...args: any[]) => T): T[]; | ||
| /** | ||
| * Safely iterate over all instances of this type | ||
| * Delegates to the global registry. | ||
| */ | ||
| static forEach<T extends StateContainer<any>>(this: new (...args: any[]) => T, callback: (instance: T) => void): void; | ||
| /** | ||
| * Clear all instances of this type | ||
| * Delegates to the global registry. | ||
| */ | ||
| static clear<T extends StateContainer<any>>(this: new (...args: any[]) => T): void; | ||
| /** | ||
| * Clear all instances from all types (for testing) | ||
| * Delegates to the global registry. | ||
| */ | ||
| static clearAllInstances(): void; | ||
| /** | ||
| * Get registry statistics (for debugging) | ||
| * Delegates to the global registry. | ||
| */ | ||
| static getStats(): { | ||
| registeredTypes: number; | ||
| totalInstances: number; | ||
| typeBreakdown: Record<string, number>; | ||
| }; | ||
| /** | ||
| * Get reference count for an instance | ||
| * Delegates to the global registry. | ||
| */ | ||
| static getRefCount<T extends StateContainer<any>>(this: new (...args: any[]) => T, instanceKey?: string): number; | ||
| /** | ||
| * Check if an instance exists | ||
| * Delegates to the global registry. | ||
| */ | ||
| static hasInstance<T extends StateContainer<any>>(this: new (...args: any[]) => T, instanceKey?: string): boolean; | ||
| private _state; | ||
| private readonly listeners; | ||
| private _disposed; | ||
| private config; | ||
| name: string; | ||
| debug: boolean; | ||
| instanceId: string; | ||
| createdAt: number; | ||
| /** | ||
| * Create a new StateContainer | ||
| */ | ||
| constructor(initialState: S); | ||
| initiConfig(config: StateContainerConfig): void; | ||
| /** | ||
| * Get the current state | ||
| */ | ||
| get state(): S; | ||
| /** | ||
| * Check if disposed | ||
| */ | ||
| get isDisposed(): boolean; | ||
| /** | ||
| * Subscribe to state changes | ||
| * @returns Unsubscribe function | ||
| */ | ||
| subscribe(listener: StateListener<S>): () => void; | ||
| /** | ||
| * Dispose the container | ||
| */ | ||
| dispose(): void; | ||
| /** | ||
| * Emit a new state (with change detection) | ||
| */ | ||
| protected emit(newState: S): void; | ||
| /** | ||
| * Capture stack trace for debugging | ||
| * Can be overridden to disable in production | ||
| */ | ||
| private captureStackTrace; | ||
| /** | ||
| * Format a single stack trace line for better readability | ||
| * Removes URL prefixes, query params, and cleans up the output | ||
| */ | ||
| private formatStackLine; | ||
| /** | ||
| * Clean up file path by removing URL prefixes and query params | ||
| */ | ||
| private cleanFilePath; | ||
| lastUpdateTimestamp: number; | ||
| /** | ||
| * Update state using a function | ||
| */ | ||
| protected update(updater: (current: S) => S): void; | ||
| /** | ||
| * Optional disposal hook for subclasses | ||
| */ | ||
| protected onDispose?(): void; | ||
| /** | ||
| * Optional state change hook for subclasses | ||
| */ | ||
| protected onStateChange?(newState: S, previousState: S): void; | ||
| } | ||
| export {}; | ||
| //# sourceMappingURL=StateContainer.d.ts.map |
| {"version":3,"file":"StateContainer.d.ts","sourceRoot":"","sources":["../../src/core/StateContainer.ts"],"names":[],"mappings":"AAAA;;;;;;;GAOG;AAGH,OAAO,EACL,sBAAsB,EAEvB,MAAM,0BAA0B,CAAC;AAElC;;GAEG;AACH,MAAM,WAAW,oBAAoB;IACnC,mCAAmC;IACnC,IAAI,CAAC,EAAE,MAAM,CAAC;IACd,2BAA2B;IAC3B,KAAK,CAAC,EAAE,OAAO,CAAC;IAChB,iCAAiC;IACjC,UAAU,CAAC,EAAE,MAAM,CAAC;CACrB;AAED;;GAEG;AACH,KAAK,aAAa,CAAC,CAAC,IAAI,CAAC,KAAK,EAAE,CAAC,KAAK,IAAI,CAAC;AAE3C;;GAEG;AACH,8BAAsB,cAAc,CAAC,CAAC;IACpC;;;OAGG;IACH,MAAM,CAAC,qBAAqB,UAAS;IAErC;;OAEG;IACH,SAAS,CAAC,MAAM,CAAC,SAAS,yBAAkB;IAE5C;;OAEG;IACH,MAAM,CAAC,WAAW,IAAI,sBAAsB;IAI5C;;;;OAIG;IACH,MAAM,CAAC,WAAW,CAAC,QAA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AI,EAAE,GAAG,EAAE,KAAK,CAAC,EAC/B,WAAW,CAAC,EAAE,MAAM,GACnB,OAAO;IAIV,OAAO,CAAC,MAAM,CAAI;IAClB,OAAO,CAAC,QAAQ,CAAC,SAAS,CAA+B;IACzD,OAAO,CAAC,SAAS,CAAS;IAC1B,OAAO,CAAC,MAAM,CAA4B;IAE1C,IAAI,EAAE,MAAM,CAAyB;IACrC,KAAK,EAAE,OAAO,CAAS;IACvB,UAAU,EAAE,MAAM,CAAmD;IACrE,SAAS,EAAE,MAAM,CAAc;IAE/B;;OAEG;gBACS,YAAY,EAAE,CAAC;IAI3B,WAAW,CAAC,MAAM,EAAE,oBAAoB,GAAG,IAAI;IAa/C;;OAEG;IACH,IAAI,KAAK,IAAI,CAAC,CAEb;IAED;;OAEG;IACH,IAAI,UAAU,IAAI,OAAO,CAExB;IAED;;;OAGG;IACH,SAAS,CAAC,QAAQ,EAAE,aAAa,CAAC,CAAC,CAAC,GAAG,MAAM,IAAI;IASjD;;OAEG;IACH,OAAO,IAAI,IAAI;IAsBf;;OAEG;IACH,SAAS,CAAC,IAAI,CAAC,QAAQ,EAAE,CAAC,GAAG,IAAI;IAqCjC;;;OAGG;IACH,OAAO,CAAC,iBAAiB;IAiEzB;;;OAGG;IACH,OAAO,CAAC,eAAe;IAoBvB;;OAEG;IACH,OAAO,CAAC,aAAa;IAuBrB,mBAAmB,EAAE,MAAM,CAAc;IAEzC;;OAEG;IACH,SAAS,CAAC,MAAM,CAAC,OAAO,EAAE,CAAC,OAAO,EAAE,CAAC,KAAK,CAAC,GAAG,IAAI;IASlD;;OAEG;IACH,SAAS,CAAC,SAAS,CAAC,IAAI,IAAI;IAE5B;;OAEG;IACH,SAAS,CAAC,aAAa,CAAC,CAAC,QAAQ,EAAE,CAAC,EAAE,aAAa,EAAE,CAAC,GAAG,IAAI;CAC9D"} |
| /** | ||
| * StateContainerRegistry - Centralized instance and lifecycle management | ||
| * | ||
| * Responsibilities: | ||
| * - Instance storage and management (WeakMap per constructor) | ||
| * - Type registration and tracking | ||
| * - Lifecycle event notifications (plugin system) | ||
| * - Global operations (clearAllInstances) | ||
| */ | ||
| import type { StateContainer } from './StateContainer'; | ||
| import type { Vertex } from './Vertex'; | ||
| /** | ||
| * Internal entry for instance storage | ||
| * Each entry tracks an instance and its reference count | ||
| */ | ||
| export interface InstanceEntry<T = any> { | ||
| instance: T; | ||
| refCount: number; | ||
| } | ||
| /** | ||
| * Lifecycle events that can be observed | ||
| */ | ||
| export type LifecycleEvent = 'created' | 'stateChanged' | 'eventAdded' | 'disposed'; | ||
| /** | ||
| * Listener function types for each lifecycle event | ||
| */ | ||
| export type LifecycleListener<E extends LifecycleEvent> = E extends 'created' ? (container: StateContainer<any>) => void : E extends 'stateChanged' ? (container: StateContainer<any>, previousState: any, currentState: any, callstack?: string) => void : E extends 'eventAdded' ? (container: Vertex<any, any>, event: any) => void : E extends 'disposed' ? (container: StateContainer<any>) => void : never; | ||
| /** | ||
| * Registry for coordinating StateContainer lifecycle and managing instances | ||
| * | ||
| * Centralizes all instance management using WeakMap to ensure proper isolation. | ||
| */ | ||
| export declare class StateContainerRegistry { | ||
| /** | ||
| * Global storage for all instance Maps, keyed by constructor | ||
| * | ||
| * IMPORTANT: JavaScript/TypeScript static properties are inherited by reference, | ||
| * meaning all subclasses would share the same Map. To ensure each subclass has | ||
| * its own instance storage, we use a WeakMap keyed by the constructor function. | ||
| * | ||
| * This approach guarantees: | ||
| * - CounterBloc instances are separate from UserBloc instances | ||
| * - Each class owns and manages its own instances | ||
| * - Automatic garbage collection when classes are no longer referenced | ||
| */ | ||
| private readonly instancesByConstructor; | ||
| /** | ||
| * Strong Set for tracking all registered types | ||
| * Used for clearAllInstances() and getStats() | ||
| */ | ||
| private readonly types; | ||
| /** | ||
| * Type configurations (isolated flag) | ||
| */ | ||
| private readonly typeConfigs; | ||
| /** | ||
| * Lifecycle event listeners | ||
| */ | ||
| private readonly listeners; | ||
| /** | ||
| * Register a type for tracking | ||
| * Called automatically on first instance creation | ||
| */ | ||
| registerType<T extends StateContainer<any>>(constructor: new (...args: any[]) => T): void; | ||
| /** | ||
| * Register a type with isolation mode (explicit registration) | ||
| */ | ||
| register<T extends StateContainer<any>>(constructor: new (...args: any[]) => T, isolated?: boolean): void; | ||
| /** | ||
| * Get the instances Map for a specific class | ||
| * Creates a new Map on first access. | ||
| */ | ||
| private ensureInstancesMap; | ||
| /** | ||
| * Get the instances Map for a specific class (public API for stats/debugging) | ||
| */ | ||
| getInstancesMap<T extends StateContainer<any>>(Type: new (...args: any[]) => T): Map<string, InstanceEntry>; | ||
| /** | ||
| * Resolve an instance with ref counting (ownership semantics) | ||
| */ | ||
| resolve<T extends StateContainer<any>>(Type: new (...args: any[]) => T, instanceKey?: string, constructorArgs?: any): T; | ||
| /** | ||
| * Get an existing instance without ref counting (borrowing semantics) | ||
| * @throws Error if instance doesn't exist | ||
| */ | ||
| get<T extends StateContainer<any>>(Type: new (...args: any[]) => T, instanceKey?: string): T; | ||
| /** | ||
| * Safely get an existing instance (borrowing semantics with error handling) | ||
| * Returns discriminated union for type-safe conditional access | ||
| */ | ||
| getSafe<T extends StateContainer<any>>(Type: new (...args: any[]) => T, instanceKey?: string): { | ||
| error: Error; | ||
| instance: null; | ||
| } | { | ||
| error: null; | ||
| instance: T; | ||
| }; | ||
| /** | ||
| * Connect to an instance with borrowing semantics (for B2B communication) | ||
| * Gets existing instance OR creates it if it doesn't exist, without incrementing ref count. | ||
| * Tracks cross-bloc dependency for reactive updates. | ||
| * | ||
| * Use this in bloc-to-bloc communication when you need to ensure an instance exists | ||
| * but don't want to claim ownership (no ref count increment). | ||
| * | ||
| * @param Type - The bloc class constructor | ||
| * @param instanceKey - Optional instance key (defaults to 'default') | ||
| * @param constructorArgs - Constructor arguments (only used if creating new instance) | ||
| * @returns The bloc instance | ||
| */ | ||
| connect<T extends StateContainer<any>>(Type: new (...args: any[]) => T, instanceKey?: string, constructorArgs?: any): T; | ||
| /** | ||
| * Release a reference to an instance | ||
| */ | ||
| release<T extends StateContainer<any>>(Type: new (...args: any[]) => T, instanceKey?: string, forceDispose?: boolean): void; | ||
| /** | ||
| * Get all instances of a specific type | ||
| */ | ||
| getAll<T extends StateContainer<any>>(Type: new (...args: any[]) => T): T[]; | ||
| /** | ||
| * Safely iterate over all instances of a type | ||
| */ | ||
| forEach<T extends StateContainer<any>>(Type: new (...args: any[]) => T, callback: (instance: T) => void): void; | ||
| /** | ||
| * Clear all instances of a specific type | ||
| */ | ||
| clear<T extends StateContainer<any>>(Type: new (...args: any[]) => T): void; | ||
| /** | ||
| * Get reference count for an instance | ||
| */ | ||
| getRefCount<T extends StateContainer<any>>(Type: new (...args: any[]) => T, instanceKey?: string): number; | ||
| /** | ||
| * Check if an instance exists | ||
| */ | ||
| hasInstance<T extends StateContainer<any>>(Type: new (...args: any[]) => T, instanceKey?: string): boolean; | ||
| /** | ||
| * Clear all instances from all types (for testing) | ||
| * | ||
| * Iterates all registered types and clears their instances. | ||
| * Also clears type tracking to reset the registry state. | ||
| */ | ||
| clearAll(): void; | ||
| /** | ||
| * Get registry statistics (for debugging) | ||
| */ | ||
| getStats(): { | ||
| registeredTypes: number; | ||
| totalInstances: number; | ||
| typeBreakdown: Record<string, number>; | ||
| }; | ||
| /** | ||
| * Get all registered types (for plugin system) | ||
| */ | ||
| getTypes(): Array<new (...args: any[]) => StateContainer<any>>; | ||
| /** | ||
| * Subscribe to lifecycle events | ||
| * @param event - The lifecycle event to listen for | ||
| * @param listener - The listener function to call when the event occurs | ||
| * @returns Unsubscribe function | ||
| */ | ||
| on<E extends LifecycleEvent>(event: E, listener: LifecycleListener<E>): () => void; | ||
| /** | ||
| * Emit lifecycle event to all listeners | ||
| * @internal - Called by StateContainer/Vertex lifecycle methods | ||
| */ | ||
| emit(event: LifecycleEvent, ...args: any[]): void; | ||
| } | ||
| /** | ||
| * Global default registry instance | ||
| */ | ||
| export declare const globalRegistry: StateContainerRegistry; | ||
| /** | ||
| * Get the global plugin manager | ||
| */ | ||
| export declare function getPluginManager(): any; | ||
| //# sourceMappingURL=StateContainerRegistry.d.ts.map |
| {"version":3,"file":"StateContainerRegistry.d.ts","sourceRoot":"","sources":["../../src/core/StateContainerRegistry.ts"],"names":[],"mappings":"AAAA;;;;;;;;GAQG;AAEH,OAAO,KAAK,EAAE,cAAc,EAAwB,MAAM,kBAAkB,CAAC;AAC7E,OAAO,KAAK,EAAE,MAAM,EAAE,MAAM,UAAU,CAAC;AAUvC;;;GAGG;AACH,MAAM,WAAW,aAAa,CAAC,CAAC,GAAG,GAAG;IACpC,QAAQ,EAAE,CAAC,CAAC;IACZ,QAAQ,EAAE,MAAM,CAAC;CAClB;AAED;;GAEG;AACH,MAAM,MAAM,cAAc,GACtB,SAAS,GACT,cAAc,GACd,YAAY,GACZ,UAAU,CAAC;AAEf;;GAEG;AACH,MAAM,MAAM,iBAAiB,CAAC,CAAC,SAAS,cAAc,IAAI,CAAC,SAAS,SAAS,GACzE,CAAC,SAAS,EAAE,cAAc,CAAC,GAAG,CAAC,KAAK,IAAI,GACxC,CAAC,SAAS,cAAc,GACtB,CACE,SAAS,EAAE,cAAc,CAAC,GAAG,CAAC,EAC9B,aAAa,EAAE,GAAG,EAClB,YAAY,EAAE,GAAG,EACjB,SAAS,CAAC,EAAE,MAAM,KACf,IAAI,GACT,CAAC,SAAS,YAAY,GACpB,CAAC,SAAS,EAAE,MAAM,CAAC,GAAG,EAAE,GAAG,CAAC,EAAE,KAAK,EAAE,GAAG,KAAK,IAAI,GACjD,CAAC,SAAS,UAAU,GAClB,CAAC,SAAS,EAAE,cAAc,CAAC,GAAG,CAAC,KAAK,IAAI,GACxC,KAAK,CAAC;AAEhB;;;;GAIG;AACH,qBAAa,sBAAsB;IACjC;;;;;;;;;;;OAWG;IACH,OAAO,CAAC,QAAQ,CAAC,sBAAsB,CAGnC;IAEJ;;;OAGG;IACH,OAAO,CAAC,QAAQ,CAAC,KAAK,CAElB;IAEJ;;OAEG;IACH,OAAO,CAAC,QAAQ,CA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GAAG,IAAI,EAAE,GAAG,EAAE,KAAK,CAAC,EAC/B,WAAW,GAAE,MAA2C,GACvD,OAAO;IAKV;;;;;OAKG;IACH,QAAQ,IAAI,IAAI;IAUhB;;OAEG;IACH,QAAQ,IAAI;QACV,eAAe,EAAE,MAAM,CAAC;QACxB,cAAc,EAAE,MAAM,CAAC;QACvB,aAAa,EAAE,MAAM,CAAC,MAAM,EAAE,MAAM,CAAC,CAAC;KACvC;IAqBD;;OAEG;IACH,QAAQ,IAAI,KAAK,CAAC,KAAK,GAAG,IAAI,EAAE,GAAG,EAAE,KAAK,cAAc,CAAC,GAAG,CAAC,CAAC;IAI9D;;;;;OAKG;IACH,EAAE,CAAC,CAAC,SAAS,cAAc,EACzB,KAAK,EAAE,CAAC,EACR,QAAQ,EAAE,iBAAiB,CAAC,CAAC,CAAC,GAC7B,MAAM,IAAI;IAYb;;;OAGG;IACH,IAAI,CAAC,KAAK,EAAE,cAAc,EAAE,GAAG,IAAI,EAAE,GAAG,EAAE,GAAG,IAAI;CAelD;AAED;;GAEG;AACH,eAAO,MAAM,cAAc,wBAA+B,CAAC;AAO3D;;GAEG;AACH,wBAAgB,gBAAgB,IAAI,GAAG,CAKtC"} |
| /** | ||
| * Vertex - Event-driven state container (Bloc pattern) | ||
| * | ||
| * Simplified version that includes its own event handling, | ||
| * since events are only needed for the Vertex pattern. | ||
| */ | ||
| import { StateContainer } from './StateContainer'; | ||
| import { BaseEvent } from '../types/events'; | ||
| /** | ||
| * Event handler signature (synchronous only) | ||
| */ | ||
| export type EventHandler<E extends BaseEvent, S> = (event: E, emit: (state: S) => void) => void; | ||
| /** | ||
| * Type-safe event constructor | ||
| */ | ||
| export type EventConstructor<T extends BaseEvent = BaseEvent> = new (...args: never[]) => T; | ||
| /** | ||
| * Vertex is an event-driven state container (Bloc pattern) | ||
| * | ||
| * Includes its own simple event system since events are only needed | ||
| * for the Vertex pattern, not for the base StateContainer. | ||
| */ | ||
| export declare abstract class Vertex<S, E extends BaseEvent = BaseEvent> extends StateContainer<S> { | ||
| private eventHandlers; | ||
| private isProcessing; | ||
| private eventQueue; | ||
| /** | ||
| * Create a new Vertex | ||
| * @param initialState Initial state value | ||
| */ | ||
| constructor(initialState: S); | ||
| /** | ||
| * Register an event handler | ||
| * Arrow function to maintain correct 'this' binding | ||
| */ | ||
| protected on: <T extends E>(EventClass: EventConstructor<T>, handler: EventHandler<T, S>) => void; | ||
| /** | ||
| * Add an event to be processed | ||
| * Arrow function to maintain correct 'this' binding in React | ||
| */ | ||
| add: (event: E) => void; | ||
| /** | ||
| * Process an event (synchronously) | ||
| */ | ||
| private processEvent; | ||
| /** | ||
| * Handle a single event (synchronously) | ||
| */ | ||
| private handleEvent; | ||
| /** | ||
| * Hook for handling event processing errors | ||
| */ | ||
| protected onEventError(_event: E, _error: Error): void; | ||
| } | ||
| /** | ||
| * Example: Counter Events | ||
| */ | ||
| export declare class IncrementEvent implements BaseEvent { | ||
| readonly amount: number; | ||
| readonly type = "increment"; | ||
| readonly timestamp: number; | ||
| constructor(amount?: number); | ||
| } | ||
| export declare class DecrementEvent implements BaseEvent { | ||
| readonly amount: number; | ||
| readonly type = "decrement"; | ||
| readonly timestamp: number; | ||
| constructor(amount?: number); | ||
| } | ||
| export declare class ResetEvent implements BaseEvent { | ||
| readonly type = "reset"; | ||
| readonly timestamp: number; | ||
| } | ||
| /** | ||
| * Example: Counter Vertex | ||
| * Demonstrates proper typing and event handling | ||
| */ | ||
| export declare class CounterVertex extends Vertex<number> { | ||
| constructor(); | ||
| increment: (amount?: number) => void; | ||
| decrement: (amount?: number) => void; | ||
| reset: () => void; | ||
| } | ||
| /** | ||
| * Auth State and Events for testing async handlers | ||
| */ | ||
| export interface AuthState { | ||
| isAuthenticated: boolean; | ||
| isLoading: boolean; | ||
| user: { | ||
| id: string; | ||
| name: string; | ||
| email: string; | ||
| } | null; | ||
| error: string | null; | ||
| } | ||
| export declare class LoginEvent implements BaseEvent { | ||
| readonly email: string; | ||
| readonly password: string; | ||
| readonly type = "login"; | ||
| readonly timestamp: number; | ||
| constructor(email: string, password: string); | ||
| } | ||
| export declare class LogoutEvent implements BaseEvent { | ||
| readonly type = "logout"; | ||
| readonly timestamp: number; | ||
| } | ||
| export declare class AuthVertex extends Vertex<AuthState> { | ||
| constructor(); | ||
| login: (email: string, password: string) => void; | ||
| logout: () => void; | ||
| } | ||
| //# sourceMappingURL=Vertex.d.ts.map |
| {"version":3,"file":"Vertex.d.ts","sourceRoot":"","sources":["../../src/core/Vertex.ts"],"names":[],"mappings":"AAAA;;;;;GAKG;AAEH,OAAO,EAAE,cAAc,EAAE,MAAM,kBAAkB,CAAC;AAClD,OAAO,EAAE,SAAS,EAAE,MAAM,iBAAiB,CAAC;AAE5C;;GAEG;AACH,MAAM,MAAM,YAAY,CAAC,CAAC,SAAS,SAAS,EAAE,CAAC,IAAI,CACjD,KAAK,EAAE,CAAC,EACR,IAAI,EAAE,CAAC,KAAK,EAAE,CAAC,KAAK,IAAI,KACrB,IAAI,CAAC;AAEV;;GAEG;AACH,MAAM,MAAM,gBAAgB,CAAC,CAAC,SAAS,SAAS,GAAG,SAAS,IAAI,KAC9D,GAAG,IAAI,EAAE,KAAK,EAAE,KACb,CAAC,CAAC;AAUP;;;;;GAKG;AACH,8BAAsB,MAAM,CAC1B,CAAC,EACD,CAAC,SAAS,SAAS,GAAG,SAAS,CAC/B,SAAQ,cAAc,CAAC,CAAC,CAAC;IACzB,OAAO,CAAC,aAAa,CAAuD;IAC5E,OAAO,CAAC,YAAY,CAAS;IAC7B,OAAO,CAAC,UAAU,CAAW;IAE7B;;;OAGG;gBACS,YAAY,EAAE,CAAC;IAI3B;;;OAGG;IACH,SAAS,CAAC,EAAE,GAAI,CAAC,SAAS,CAAC,EACzB,YAAY,gBAAgB,CAAC,CAAC,CAAC,EAC/B,SAAS,YAAY,CAAC,CAAC,EAAE,CAAC,CAAC,KAC1B,IAAI,CAQL;IAEF;;;OAGG;IACI,GAAG,GAAI,OAAO,CAAC,KAAG,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AO,EACL,UAAU,EACV,gBAAgB,EAChB,iBAAiB,EACjB,iBAAiB,EACjB,mBAAmB,EACnB,aAAa,GACd,MAAM,qBAAqB,CAAC;AAE7B,OAAO,EACL,aAAa,EACb,eAAe,EACf,gBAAgB,EAChB,sBAAsB,GACvB,MAAM,sBAAsB,CAAC"} |
| export declare enum LogLevel { | ||
| ERROR = 0, | ||
| WARN = 1, | ||
| INFO = 2, | ||
| DEBUG = 3 | ||
| } | ||
| export interface LogEntry { | ||
| level: string; | ||
| context: string; | ||
| message: string; | ||
| data?: any; | ||
| timestamp: number; | ||
| } | ||
| export interface LogConfig { | ||
| enabled: boolean; | ||
| level: LogLevel; | ||
| output: (entry: LogEntry) => void; | ||
| } | ||
| /** | ||
| * Creates a logger instance with given configuration | ||
| * | ||
| * @param config - Logger configuration | ||
| * @returns Logger instance with debug, info, warn, error, and configure methods | ||
| * | ||
| * @example | ||
| * ```ts | ||
| * const logger = createLogger({ | ||
| * enabled: true, | ||
| * level: LogLevel.DEBUG, | ||
| * output: (entry) => console.log(JSON.stringify(entry)) | ||
| * }); | ||
| * logger.debug('MyComponent', 'Rendering', { props: { foo: 'bar' } }); | ||
| * ``` | ||
| */ | ||
| export declare function createLogger(config: LogConfig): { | ||
| debug: (context: string, message: string, data?: any) => void; | ||
| info: (context: string, message: string, data?: any) => void; | ||
| warn: (context: string, message: string, data?: any) => void; | ||
| error: (context: string, message: string, data?: any) => void; | ||
| configure: (opts: Partial<LogConfig>) => void; | ||
| }; | ||
| export declare const debug: (context: string, message: string, data?: any) => void; | ||
| export declare const info: (context: string, message: string, data?: any) => void; | ||
| export declare const warn: (context: string, message: string, data?: any) => void; | ||
| export declare const error: (context: string, message: string, data?: any) => void; | ||
| /** | ||
| * Configuration function that recreates the default logger | ||
| * | ||
| * @param opts - Partial logger configuration | ||
| * | ||
| * @example | ||
| * ```ts | ||
| * configureLogger({ enabled: true, level: LogLevel.DEBUG }); | ||
| * ``` | ||
| */ | ||
| export declare function configureLogger(opts: Partial<LogConfig>): void; | ||
| //# sourceMappingURL=Logger.d.ts.map |
| {"version":3,"file":"Logger.d.ts","sourceRoot":"","sources":["../../src/logging/Logger.ts"],"names":[],"mappings":"AAAA,oBAAY,QAAQ;IAClB,KAAK,IAAI;IACT,IAAI,IAAI;IACR,IAAI,IAAI;IACR,KAAK,IAAI;CACV;AAED,MAAM,WAAW,QAAQ;IACvB,KAAK,EAAE,MAAM,CAAC;IACd,OAAO,EAAE,MAAM,CAAC;IAChB,OAAO,EAAE,MAAM,CAAC;IAChB,IAAI,CAAC,EAAE,GAAG,CAAC;IACX,SAAS,EAAE,MAAM,CAAC;CACnB;AAED,MAAM,WAAW,SAAS;IACxB,OAAO,EAAE,OAAO,CAAC;IACjB,KAAK,EAAE,QAAQ,CAAC;IAChB,MAAM,EAAE,CAAC,KAAK,EAAE,QAAQ,KAAK,IAAI,CAAC;CACnC;AAED;;;;;;;;;;;;;;;GAeG;AACH,wBAAgB,YAAY,CAAC,MAAM,EAAE,SAAS;qBAkCzB,MAAM,WAAW,MAAM,SAAS,GAAG;oBAKpC,MAAM,WAAW,MAAM,SAAS,GAAG;oBAKnC,MAAM,WAAW,MAAM,SAAS,GAAG;qBAKlC,MAAM,WAAW,MAAM,SAAS,GAAG;sBAKlC,OAAO,CAAC,SAAS,CAAC;EAIvC;AAaD,eAAO,MAAM,KAAK,GAAI,SAAS,MAAM,EAAE,SAAS,MAAM,EAAE,OAAO,GAAG,SACrB,CAAC;AAC9C,eAAO,MAAM,IAAI,GAAI,SAAS,MAAM,EAAE,SAAS,MAAM,EAAE,OAAO,GAAG,SACrB,CAAC;AAC7C,eAAO,MAAM,IAAI,GAAI,SAAS,MAAM,EAAE,SAAS,MAAM,EAAE,OAAO,GAAG,SACrB,CAAC;AAC7C,eAAO,MAAM,KAAK,GAAI,SAAS,MAAM,EAAE,SAAS,MAAM,EAAE,OAAO,GAAG,SACrB,CAAC;AAE9C;;;;;;;;;GASG;AACH,wBAAgB,eAAe,CAAC,IAAI,EAAE,OAAO,CAAC,SAAS,CAAC,GAAG,IAAI,CAO9D"} |
| /** | ||
| * BlacPlugin - Plugin system for BlaC state management | ||
| * | ||
| * Provides a safe and powerful API for plugins to observe and interact with | ||
| * StateContainer instances without coupling to the core. | ||
| */ | ||
| import type { StateContainer } from '../core/StateContainer'; | ||
| import type { Vertex } from '../core/Vertex'; | ||
| import type { BaseEvent } from '../types/events'; | ||
| /** | ||
| * Instance metadata exposed to plugins | ||
| */ | ||
| export interface InstanceMetadata { | ||
| /** Unique instance ID */ | ||
| id: string; | ||
| /** Class name (e.g., 'CounterCubit') */ | ||
| className: string; | ||
| isDisposed: boolean; | ||
| /** Custom name if provided */ | ||
| name: string; | ||
| lastStateChangeTimestamp: number; | ||
| state: any; | ||
| createdAt: number; | ||
| /** Whether this is an isolated instance */ | ||
| isIsolated: boolean; | ||
| /** Call stack for state update (optional, for DevTools) */ | ||
| callstack?: string; | ||
| /** Previous state (optional, for state change events) */ | ||
| previousState?: any; | ||
| /** Current state (optional, for state change events) */ | ||
| currentState?: any; | ||
| } | ||
| /** | ||
| * Plugin context - provides safe access to BlaC internals | ||
| */ | ||
| export interface PluginContext { | ||
| /** | ||
| * Get metadata for an instance | ||
| */ | ||
| getInstanceMetadata(instance: StateContainer<any>): InstanceMetadata; | ||
| /** | ||
| * Get current state of an instance | ||
| */ | ||
| getState<S>(instance: StateContainer<S>): S; | ||
| /** | ||
| * Query all instances of a specific type | ||
| */ | ||
| queryInstances<T extends StateContainer<any>>(typeClass: new (...args: any[]) => T): T[]; | ||
| /** | ||
| * Query all registered types | ||
| */ | ||
| getAllTypes(): Array<new (...args: any[]) => StateContainer<any>>; | ||
| /** | ||
| * Get registry statistics | ||
| */ | ||
| getStats(): { | ||
| registeredTypes: number; | ||
| totalInstances: number; | ||
| typeBreakdown: Record<string, number>; | ||
| }; | ||
| } | ||
| /** | ||
| * Base plugin interface | ||
| */ | ||
| export interface BlacPlugin { | ||
| /** Plugin name for identification */ | ||
| readonly name: string; | ||
| /** Plugin version */ | ||
| readonly version: string; | ||
| /** | ||
| * Called when plugin is installed | ||
| * @param context - Plugin context for safe access to BlaC internals | ||
| */ | ||
| onInstall?(context: PluginContext): void; | ||
| /** | ||
| * Called when plugin is uninstalled | ||
| */ | ||
| onUninstall?(): void; | ||
| /** | ||
| * Called when a StateContainer instance is created | ||
| */ | ||
| onInstanceCreated?(instance: StateContainer<any>, context: PluginContext): void; | ||
| /** | ||
| * Called when state changes | ||
| */ | ||
| onStateChanged?<S>(instance: StateContainer<S>, previousState: S, currentState: S, callstack: string | undefined, context: PluginContext): void; | ||
| /** | ||
| * Called when an event is added (Vertex only) | ||
| */ | ||
| onEventAdded?<E extends BaseEvent>(vertex: Vertex<any, E>, event: E, context: PluginContext): void; | ||
| /** | ||
| * Called when an instance is disposed | ||
| */ | ||
| onInstanceDisposed?(instance: StateContainer<any>, context: PluginContext): void; | ||
| } | ||
| /** | ||
| * Plugin with initialization hook | ||
| */ | ||
| export interface BlacPluginWithInit extends BlacPlugin { | ||
| onInstall(context: PluginContext): void; | ||
| } | ||
| /** | ||
| * Plugin configuration options | ||
| */ | ||
| export interface PluginConfig { | ||
| /** Whether plugin is enabled */ | ||
| enabled?: boolean; | ||
| /** Environment filter (e.g., only run in development) */ | ||
| environment?: 'development' | 'production' | 'test' | 'all'; | ||
| } | ||
| /** | ||
| * Type guard for plugins with init | ||
| */ | ||
| export declare function hasInitHook(plugin: BlacPlugin): plugin is BlacPluginWithInit; | ||
| //# sourceMappingURL=BlacPlugin.d.ts.map |
| {"version":3,"file":"BlacPlugin.d.ts","sourceRoot":"","sources":["../../src/plugin/BlacPlugin.ts"],"names":[],"mappings":"AAAA;;;;;GAKG;AAEH,OAAO,KAAK,EAAE,cAAc,EAAE,MAAM,wBAAwB,CAAC;AAC7D,OAAO,KAAK,EAAE,MAAM,EAAE,MAAM,gBAAgB,CAAC;AAC7C,OAAO,KAAK,EAAE,SAAS,EAAE,MAAM,iBAAiB,CAAC;AAEjD;;GA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manages plugins and provides plugin context | ||
| * TESTS ARE FOR AN OLDER VERSION AND NEED TO BE REWRITTEN | ||
| */ | ||
| import type { StateContainerRegistry } from '../core/StateContainerRegistry'; | ||
| import type { BlacPlugin, PluginConfig } from './BlacPlugin'; | ||
| /** | ||
| * Plugin manager for registering and coordinating plugins | ||
| */ | ||
| export declare class PluginManager { | ||
| private plugins; | ||
| private registry; | ||
| constructor(registry: StateContainerRegistry); | ||
| /** | ||
| * Install a plugin | ||
| */ | ||
| install(plugin: BlacPlugin, config?: PluginConfig): void; | ||
| /** | ||
| * Uninstall a plugin | ||
| */ | ||
| uninstall(pluginName: string): void; | ||
| /** | ||
| * Get installed plugin | ||
| */ | ||
| getPlugin(pluginName: string): BlacPlugin | undefined; | ||
| /** | ||
| * Get all installed plugins | ||
| */ | ||
| getAllPlugins(): BlacPlugin[]; | ||
| /** | ||
| * Check if plugin is installed | ||
| */ | ||
| hasPlugin(pluginName: string): boolean; | ||
| /** | ||
| * Clear all plugins (for testing) | ||
| */ | ||
| clear(): void; | ||
| /** | ||
| * Setup lifecycle hooks to notify plugins | ||
| */ | ||
| private setupLifecycleHooks; | ||
| /** | ||
| * Notify all plugins of a lifecycle event | ||
| */ | ||
| private notifyPlugins; | ||
| /** | ||
| * Create plugin context with safe API access | ||
| */ | ||
| private createPluginContext; | ||
| /** | ||
| * Check if plugin should be enabled based on environment | ||
| */ | ||
| private shouldEnablePlugin; | ||
| /** | ||
| * Get current environment | ||
| */ | ||
| private getCurrentEnvironment; | ||
| } | ||
| /** | ||
| * Create a plugin manager instance | ||
| */ | ||
| export declare function createPluginManager(registry: StateContainerRegistry): PluginManager; | ||
| //# sourceMappingURL=PluginManager.d.ts.map |
| {"version":3,"file":"PluginManager.d.ts","sourceRoot":"","sources":["../../src/plugin/PluginManager.ts"],"names":[],"mappings":"AAAA;;;GAGG;AAGH,OAAO,KAAK,EAAE,sBAAsB,EAAE,MAAM,gCAAgC,CAAC;AAC7E,OAAO,KAAK,EACV,UAAU,EAEV,YAAY,EAEb,MAAM,cAAc,CAAC;AAQtB;;GAEG;AACH,qBAAa,aAAa;IACxB,OAAO,CAAC,OAAO,CAAsC;IACrD,OAAO,CAAC,QAAQ,CAAyB;gBAE7B,QAAQ,EAAE,sBAAsB;IAK5C;;OAEG;IACH,OAAO,CAAC,MAAM,EAAE,UAAU,EAAE,MAAM,GAAE,YAAiB,GAAG,IAAI;IA8C5D;;OAEG;IACH,SAAS,CAAC,UAAU,EAAE,MAAM,GAAG,IAAI;IAsBnC;;OAEG;IACH,SAAS,CAAC,UAAU,EAAE,MAAM,GAAG,UAAU,GAAG,SAAS;IAIrD;;OAEG;IACH,aAAa,IAAI,UAAU,EAAE;IAI7B;;OAEG;IACH,SAAS,CAAC,UAAU,EAAE,MAAM,GAAG,OAAO;IAItC;;OAEG;IACH,KAAK,IAAI,IAAI;IAMb;;OAEG;IACH,OAAO,CAAC,mBAAmB;IA+B3B;;OAEG;IACH,OAAO,CAAC,aAAa;IAkBrB;;OAEG;IACH,OAAO,CAAC,mBAAmB;IA+C3B;;OAEG;IACH,OAAO,CAAC,kBAAkB;IAQ1B;;OAEG;IACH,OAAO,CAAC,qBAAqB;CAQ9B;AAED;;GAEG;AACH,wBAAgB,mBAAmB,CACjC,QAAQ,EAAE,sBAAsB,GAC/B,aAAa,CAEf"} |
| /** | ||
| * ProxyTracker - Automatic dependency tracking through Proxies | ||
| * | ||
| * Tracks property access on state objects to automatically determine | ||
| * which parts of the state a component depends on. | ||
| */ | ||
| /** | ||
| * Tracks property access on state objects | ||
| */ | ||
| export declare class ProxyTracker<T> { | ||
| private trackedPaths; | ||
| private isTracking; | ||
| private proxyCache; | ||
| private maxDepth; | ||
| /** | ||
| * Create a proxy that tracks property access | ||
| */ | ||
| createProxy(target: T, path?: string, depth?: number): T; | ||
| /** | ||
| * Create a proxy for arrays with special handling | ||
| */ | ||
| private createArrayProxy; | ||
| /** | ||
| * Start tracking property access | ||
| */ | ||
| startTracking(): void; | ||
| /** | ||
| * Stop tracking and return tracked paths | ||
| */ | ||
| stopTracking(): Set<string>; | ||
| /** | ||
| * Get currently tracked paths | ||
| */ | ||
| getTrackedPaths(): ReadonlySet<string>; | ||
| /** | ||
| * Check if currently tracking | ||
| */ | ||
| isCurrentlyTracking(): boolean; | ||
| /** | ||
| * Clear proxy cache (useful for memory management) | ||
| */ | ||
| clearCache(): void; | ||
| /** | ||
| * Set maximum tracking depth | ||
| */ | ||
| setMaxDepth(depth: number): void; | ||
| /** | ||
| * Add a path manually (useful for forcing dependencies) | ||
| */ | ||
| addPath(path: string): void; | ||
| /** | ||
| * Remove a path manually | ||
| */ | ||
| removePath(path: string): void; | ||
| /** | ||
| * Clear all tracked paths | ||
| */ | ||
| clearPaths(): void; | ||
| } | ||
| /** | ||
| * Global proxy tracker instance for convenience | ||
| */ | ||
| export declare const globalProxyTracker: ProxyTracker<unknown>; | ||
| /** | ||
| * Utility function to track property access in a callback | ||
| */ | ||
| export declare function trackAccess<T, R>(state: T, callback: (proxiedState: T) => R): { | ||
| result: R; | ||
| trackedPaths: Set<string>; | ||
| }; | ||
| //# sourceMappingURL=ProxyTracker.d.ts.map |
| {"version":3,"file":"ProxyTracker.d.ts","sourceRoot":"","sources":["../../src/proxy/ProxyTracker.ts"],"names":[],"mappings":"AAAA;;;;;GAKG;AAqBH;;GAEG;AACH,qBAAa,YAAY,CAAC,CAAC;IACzB,OAAO,CAAC,YAAY,CAAqB;IACzC,OAAO,CAAC,UAAU,CAAS;IAC3B,OAAO,CAAC,UAAU,CAA8B;IAChD,OAAO,CAAC,QAAQ,CAAM;IAEtB;;OAEG;IACH,WAAW,CAAC,MAAM,EAAE,CAAC,EAAE,IAAI,GAAE,MAAW,EAAE,KAAK,GAAE,MAAU,GAAG,CAAC;IA6F/D;;OAEG;IACH,OAAO,CAAC,gBAAgB;IA8DxB;;OAEG;IACH,aAAa,IAAI,IAAI;IAMrB;;OAEG;IACH,YAAY,IAAI,GAAG,CAAC,MAAM,CAAC;IAS3B;;OAEG;IACH,eAAe,IAAI,WAAW,CAAC,MAAM,CAAC;IAItC;;OAEG;IACH,mBAAmB,IAAI,OAAO;IAI9B;;OAEG;IACH,UAAU,IAAI,IAAI;IAIlB;;OAEG;IACH,WAAW,CAAC,KAAK,EAAE,MAAM,GAAG,IAAI;IAIhC;;OAEG;IACH,OAAO,CAAC,IAAI,EAAE,MAAM,GAAG,IAAI;IAI3B;;OAEG;IACH,UAAU,CAAC,IAAI,EAAE,MAAM,GAAG,IAAI;IAI9B;;OAEG;IACH,UAAU,IAAI,IAAI;CAGnB;AAED;;GAEG;AACH,eAAO,MAAM,kBAAkB,uBAAqB,CAAC;AAErD;;GAEG;AACH,wBAAgB,WAAW,CAAC,CAAC,EAAE,CAAC,EAC9B,KAAK,EAAE,CAAC,EACR,QAAQ,EAAE,CAAC,YAAY,EAAE,CAAC,KAAK,CAAC,GAC/B;IAAE,MAAM,EAAE,CAAC,CAAC;IAAC,YAAY,EAAE,GAAG,CAAC,MAAM,CAAC,CAAA;CAAE,CAS1C"} |
| /** | ||
| * Registry module (deprecated) | ||
| * | ||
| * Registry functionality has been consolidated into StateContainer. | ||
| * Use StateContainer static methods instead: | ||
| * | ||
| * - StateContainer.register() - Register a type | ||
| * - StateContainer.getOrCreate() - Get or create instance | ||
| * - StateContainer.isRegistered() - Check if type is registered | ||
| * - StateContainer.hasInstance() - Check if instance exists | ||
| * - StateContainer.removeInstance() - Remove instance | ||
| * - StateContainer.getAll() - Get all instances of a type | ||
| * - StateContainer.clear() - Clear all instances of a type | ||
| * - StateContainer.clearAllInstances() - Clear all instances | ||
| * - StateContainer.unregister() - Unregister a type | ||
| * - StateContainer.getStats() - Get statistics | ||
| */ | ||
| export { type BlocConstructor } from '../types/utilities'; | ||
| export { type InstanceId, instanceId as createInstanceId, } from '../types/branded'; | ||
| //# sourceMappingURL=index.d.ts.map |
| {"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../src/registry/index.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;;;;;;GAgBG;AAGH,OAAO,EAAE,KAAK,eAAe,EAAE,MAAM,oBAAoB,CAAC;AAC1D,OAAO,EACL,KAAK,UAAU,EACf,UAAU,IAAI,gBAAgB,GAC/B,MAAM,kBAAkB,CAAC"} |
| /** | ||
| * Test utilities and fixtures | ||
| */ | ||
| /** | ||
| * Create a test state object | ||
| */ | ||
| export declare function createTestState<T extends Record<string, unknown>>(overrides?: Partial<T>): T; | ||
| /** | ||
| * Wait for a condition to be true | ||
| */ | ||
| export declare function waitFor(condition: () => boolean, timeout?: number, interval?: number): Promise<void>; | ||
| /** | ||
| * Create a mock subscription notify function | ||
| */ | ||
| export declare function createMockNotify<T = unknown>(): { | ||
| fn: import("vitest").Mock<(state: T) => void>; | ||
| calls: T[]; | ||
| callCount: () => number; | ||
| lastCall: () => T; | ||
| reset: () => void; | ||
| }; | ||
| /** | ||
| * Memory usage tracker for tests | ||
| */ | ||
| export declare class MemoryTracker { | ||
| private baseline; | ||
| start(): void; | ||
| getUsage(): number; | ||
| getMB(): number; | ||
| } | ||
| /** | ||
| * Performance timer for benchmarking | ||
| */ | ||
| export declare class PerfTimer { | ||
| private start; | ||
| private marks; | ||
| begin(): void; | ||
| mark(label: string): void; | ||
| end(): number; | ||
| getMark(label: string): number | undefined; | ||
| getAllMarks(): Record<string, number>; | ||
| } | ||
| //# sourceMappingURL=index.d.ts.map |
| {"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../src/test-utils/index.ts"],"names":[],"mappings":"AAAA;;GAEG;AAIH;;GAEG;AACH,wBAAgB,eAAe,CAAC,CAAC,SAAS,MAAM,CAAC,MAAM,EAAE,OAAO,CAAC,EAC/D,SAAS,CAAC,EAAE,OAAO,CAAC,CAAC,CAAC,GACrB,CAAC,CAUH;AAED;;GAEG;AACH,wBAAsB,OAAO,CAC3B,SAAS,EAAE,MAAM,OAAO,EACxB,OAAO,SAAO,EACd,QAAQ,SAAK,GACZ,OAAO,CAAC,IAAI,CAAC,CAQf;AAED;;GAEG;AACH,wBAAgB,gBAAgB,CAAC,CAAC,GAAG,OAAO;sCAEjB,CAAC;;;;;EAa3B;AAED;;GAEG;AACH,qBAAa,aAAa;IACxB,OAAO,CAAC,QAAQ,CAAa;IAE7B,KAAK,IAAI,IAAI;IAOb,QAAQ,IAAI,MAAM;IAOlB,KAAK,IAAI,MAAM;CAGhB;AAED;;GAEG;AACH,qBAAa,SAAS;IACpB,OAAO,CAAC,KAAK,CAAa;IAC1B,OAAO,CAAC,KAAK,CAAkC;IAE/C,KAAK,IAAI,IAAI;IAIb,IAAI,CAAC,KAAK,EAAE,MAAM,GAAG,IAAI;IAIzB,GAAG,IAAI,MAAM;IAIb,OAAO,CAAC,KAAK,EAAE,MAAM,GAAG,MAAM,GAAG,SAAS;IAK1C,WAAW,IAAI,MAAM,CAAC,MAAM,EAAE,MAAM,CAAC;CAOtC"} |
| import { type ProxyTrackerState } from './proxy-tracker'; | ||
| export interface PathInfo { | ||
| segments: string[]; | ||
| value: any; | ||
| } | ||
| export interface TrackerState<T> { | ||
| proxyTrackerState: ProxyTrackerState<T>; | ||
| previousRenderPaths: Set<string>; | ||
| currentRenderPaths: Set<string>; | ||
| pathCache: Map<string, PathInfo>; | ||
| lastCheckedState: T | null; | ||
| lastCheckedValues: Map<string, any>; | ||
| } | ||
| export declare function optimizeTrackedPaths(paths: Set<string>): Set<string>; | ||
| export declare function createTrackerState<T>(): TrackerState<T>; | ||
| export declare function startTracking<T>(tracker: TrackerState<T>): void; | ||
| export declare function createProxy<T>(tracker: TrackerState<T>, state: T): T; | ||
| export declare function captureTrackedPaths<T>(tracker: TrackerState<T>, state: T): void; | ||
| export declare function hasChanges<T>(tracker: TrackerState<T>, state: T): boolean; | ||
| export declare function hasTrackedData<T>(tracker: TrackerState<T>): boolean; | ||
| //# sourceMappingURL=dependency-tracker.d.ts.map |
| {"version":3,"file":"dependency-tracker.d.ts","sourceRoot":"","sources":["../../src/tracking/dependency-tracker.ts"],"names":[],"mappings":"AAAA,OAAO,EACL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Container } from '../core/StateContainer'; | ||
| export interface GetterTrackerState { | ||
| trackedValues: Map<string | symbol, unknown>; | ||
| currentlyAccessing: Set<string | symbol>; | ||
| trackedGetters: Set<string | symbol>; | ||
| isTracking: boolean; | ||
| renderCache: Map<string | symbol, unknown>; | ||
| cacheValid: boolean; | ||
| externalDependencies: Set<StateContainer<any>>; | ||
| } | ||
| interface GetterExecutionContext { | ||
| tracker: GetterTrackerState | null; | ||
| currentBloc: StateContainer<any> | null; | ||
| depth: number; | ||
| visitedBlocs: Set<StateContainer<any>>; | ||
| } | ||
| export declare function getGetterExecutionContext(): GetterExecutionContext; | ||
| export declare function getDescriptor(obj: any, prop: string | symbol): PropertyDescriptor | undefined; | ||
| export declare function isGetter(obj: any, prop: string | symbol): boolean; | ||
| export declare function createGetterTracker(): GetterTrackerState; | ||
| export declare function setActiveTracker<TBloc extends StateContainer<any>>(bloc: TBloc, tracker: GetterTrackerState): void; | ||
| export declare function clearActiveTracker<TBloc extends StateContainer<any>>(bloc: TBloc): void; | ||
| export declare function getActiveTracker<TBloc extends StateContainer<any>>(bloc: TBloc): GetterTrackerState | undefined; | ||
| export declare function commitTrackedGetters(tracker: GetterTrackerState): void; | ||
| export declare function createBlocProxy<TBloc extends StateContainer<any>>(bloc: TBloc): TBloc; | ||
| export declare function hasGetterChanges<TBloc extends StateContainer<any>>(bloc: TBloc, tracker: GetterTrackerState | null): boolean; | ||
| export declare function invalidateRenderCache(tracker: GetterTrackerState): void; | ||
| export declare function clearExternalDependencies(tracker: GetterTrackerState): void; | ||
| export declare function resetGetterTracker(tracker: GetterTrackerState): void; | ||
| export {}; | ||
| //# sourceMappingURL=getter-tracker.d.ts.map |
| {"version":3,"file":"getter-tracker.d.ts","sourceRoot":"","sources":["../../src/tracking/getter-tracker.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,cAAc,EAAE,MAAM,wBAAwB,CAAC;AAG7D,MAAM,WAAW,kBAAkB;IACjC,aAAa,EAAE,GAAG,CAAC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,kBAAkB,GAAG,SAAS,CAEhC;AAED,wBAAgB,oBAAoB,CAAC,OAAO,EAAE,kBAAkB,GAAG,IAAI,CAKtE;AAED,wBAAgB,eAAe,CAAC,KAAK,SAAS,cAAc,CAAC,GAAG,CAAC,EAC/D,IAAI,EAAE,KAAK,GACV,KAAK,CA+EP;AAED,wBAAgB,gBAAgB,CAAC,KAAK,SAAS,cAAc,CAAC,GAAG,CAAC,EAChE,IAAI,EAAE,KAAK,EACX,OAAO,EAAE,kBAAkB,GAAG,IAAI,GACjC,OAAO,CAwDT;AAED,wBAAgB,qBAAqB,CAAC,OAAO,EAAE,kBAAkB,GAAG,IAAI,CAEvE;AAED,wBAAgB,yBAAyB,CAAC,OAAO,EAAE,kBAAkB,GAAG,IAAI,CAE3E;AAED,wBAAgB,kBAAkB,CAAC,OAAO,EAAE,kBAAkB,GAAG,IAAI,CAQpE"} |
| /** | ||
| * Dependency Tracking | ||
| * | ||
| * Framework-agnostic dependency tracking utilities for automatic reactivity. | ||
| * These utilities can be used by any framework integration (React, Vue, Angular, etc.) | ||
| * to track property accesses and detect changes. | ||
| * | ||
| * ## Usage | ||
| * | ||
| * ```typescript | ||
| * import { | ||
| * createTrackerState, | ||
| * startTracking, | ||
| * createProxy, | ||
| * captureTrackedPaths, | ||
| * hasChanges | ||
| * } from '@blac/core'; | ||
| * | ||
| * // Create tracker state | ||
| * const tracker = createTrackerState<MyState>(); | ||
| * | ||
| * // During render: | ||
| * startTracking(tracker); | ||
| * const proxy = createProxy(tracker, state); | ||
| * // ... render with proxy ... | ||
| * captureTrackedPaths(tracker, state); | ||
| * | ||
| * // On state change: | ||
| * if (hasChanges(tracker, newState)) { | ||
| * // Trigger re-render | ||
| * } | ||
| * ``` | ||
| */ | ||
| export { type TrackerState, type PathInfo, createTrackerState, startTracking, createProxy, captureTrackedPaths, hasChanges, hasTrackedData, } from './dependency-tracker'; | ||
| export { type ProxyTrackerState, createProxyTrackerState, startProxyTracking, stopProxyTracking, createProxyInternal, createArrayProxy, createProxyForTarget, isProxyable, } from './proxy-tracker'; | ||
| export { parsePath, getValueAtPath, shallowEqual } from './path-utils'; | ||
| export { type GetterTrackerState, createGetterTracker, createBlocProxy, hasGetterChanges, isGetter, getDescriptor, setActiveTracker, clearActiveTracker, getActiveTracker, commitTrackedGetters, invalidateRenderCache, resetGetterTracker, clearExternalDependencies, getGetterExecutionContext, } from './getter-tracker'; | ||
| //# sourceMappingURL=index.d.ts.map |
| {"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../src/tracking/index.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;GAgCG;AAGH,OAAO,EACL,KAAK,YAAY,EACjB,KAAK,QAAQ,EACb,kBAAkB,EAClB,aAAa,EACb,WAAW,EACX,mBAAmB,EACnB,UAAU,EACV,cAAc,GACf,MAAM,sBAAsB,CAAC;AAG9B,OAAO,EACL,KAAK,iBAAiB,EACtB,uBAAuB,EACvB,kBAAkB,EAClB,iBAAiB,EACjB,mBAAmB,EACnB,gBAAgB,EAChB,oBAAoB,EACpB,WAAW,GACZ,MAAM,iBAAiB,CAAC;AAGzB,OAAO,EAAE,SAAS,EAAE,cAAc,EAAE,YAAY,EAAE,MAAM,cAAc,CAAC;AAGvE,OAAO,EACL,KAAK,kBAAkB,EACvB,mBAAmB,EACnB,eAAe,EACf,gBAAgB,EAChB,QAAQ,EACR,aAAa,EACb,gBAAgB,EAChB,kBAAkB,EAClB,gBAAgB,EAChB,oBAAoB,EACpB,qBAAqB,EACrB,kBAAkB,EAClB,yBAAyB,EACzB,yBAAyB,GAC1B,MAAM,kBAAkB,CAAC"} |
| /** | ||
| * Path utilities for dependency tracking | ||
| * | ||
| * Provides utilities for parsing property paths and extracting values | ||
| * from nested objects using path strings. | ||
| */ | ||
| /** | ||
| * Parse a property path string into an array of segments | ||
| * | ||
| * Handles both dot notation (a.b.c) and bracket notation (a[0].b) | ||
| * | ||
| * @example | ||
| * parsePath('user.name') // ['user', 'name'] | ||
| * parsePath('items[0].name') // ['items', '0', 'name'] | ||
| * parsePath('data.users[2].address.city') // ['data', 'users', '2', 'address', 'city'] | ||
| */ | ||
| export declare function parsePath(path: string): string[]; | ||
| /** | ||
| * Get a value from an object using a path of segments | ||
| * | ||
| * @example | ||
| * const obj = { user: { name: 'Alice', age: 30 } } | ||
| * getValueAtPath(obj, ['user', 'name']) // 'Alice' | ||
| * getValueAtPath(obj, ['user', 'age']) // 30 | ||
| * getValueAtPath(obj, ['user', 'missing']) // undefined | ||
| */ | ||
| export declare function getValueAtPath(obj: any, segments: string[]): any; | ||
| /** | ||
| * Shallow equality comparison for arrays | ||
| * | ||
| * Compares two arrays element-by-element using Object.is | ||
| * | ||
| * @example | ||
| * shallowEqual([1, 2, 3], [1, 2, 3]) // true | ||
| * shallowEqual([1, 2, 3], [1, 2, 4]) // false | ||
| * shallowEqual([1, 2], [1, 2, 3]) // false | ||
| */ | ||
| export declare function shallowEqual(arr1: unknown[], arr2: unknown[]): boolean; | ||
| //# sourceMappingURL=path-utils.d.ts.map |
| {"version":3,"file":"path-utils.d.ts","sourceRoot":"","sources":["../../src/tracking/path-utils.ts"],"names":[],"mappings":"AAAA;;;;;GAKG;AAEH;;;;;;;;;GASG;AACH,wBAAgB,SAAS,CAAC,IAAI,EAAE,MAAM,GAAG,MAAM,EAAE,CA6BhD;AAED;;;;;;;;GAQG;AACH,wBAAgB,cAAc,CAAC,GAAG,EAAE,GAAG,EAAE,QAAQ,EAAE,MAAM,EAAE,GAAG,GAAG,CAShE;AAED;;;;;;;;;GASG;AACH,wBAAgB,YAAY,CAAC,IAAI,EAAE,OAAO,EAAE,EAAE,IAAI,EAAE,OAAO,EAAE,GAAG,OAAO,CAMtE"} |
| /** | ||
| * Functional proxy tracker for automatic dependency tracking | ||
| * | ||
| * This module provides a functional approach to proxy-based dependency tracking. | ||
| * Unlike the class-based ProxyTracker, this uses a state object pattern that's | ||
| * easier to integrate with functional programming patterns and framework hooks. | ||
| */ | ||
| /** | ||
| * Check if a value can be proxied | ||
| * | ||
| * Returns true for plain objects and arrays only. | ||
| * Excludes built-in objects like Date, Map, Set, etc. | ||
| */ | ||
| export declare function isProxyable(value: unknown): value is object; | ||
| /** | ||
| * State container for proxy tracking | ||
| */ | ||
| export interface ProxyTrackerState<T> { | ||
| /** Set of all tracked property paths */ | ||
| trackedPaths: Set<string>; | ||
| /** Whether tracking is currently active */ | ||
| isTracking: boolean; | ||
| /** Cache of created proxies to avoid duplicates */ | ||
| proxyCache: WeakMap<object, any>; | ||
| /** Cache of bound functions to maintain referential equality */ | ||
| boundFunctionsCache: WeakMap<Function, Function> | null; | ||
| /** Last state object that was proxied (for cache invalidation) */ | ||
| lastProxiedState: T | null; | ||
| /** Last proxy created (for cache reuse) */ | ||
| lastProxy: T | null; | ||
| /** Maximum depth for nested proxy creation */ | ||
| maxDepth: number; | ||
| } | ||
| /** | ||
| * Create a new proxy tracker state | ||
| * | ||
| * @example | ||
| * const state = createProxyTrackerState<MyState>(); | ||
| * startProxyTracking(state); | ||
| * const proxy = createProxyForTarget(state, myObject); | ||
| * // ... use proxy ... | ||
| * const paths = stopProxyTracking(state); | ||
| */ | ||
| export declare function createProxyTrackerState<T>(): ProxyTrackerState<T>; | ||
| /** | ||
| * Start tracking property accesses | ||
| * | ||
| * Clears previous tracked paths and enables tracking mode. | ||
| */ | ||
| export declare function startProxyTracking<T>(state: ProxyTrackerState<T>): void; | ||
| /** | ||
| * Stop tracking and return the tracked paths | ||
| * | ||
| * Returns a new Set containing all tracked paths. | ||
| */ | ||
| export declare function stopProxyTracking<T>(state: ProxyTrackerState<T>): Set<string>; | ||
| /** | ||
| * Create a proxy for an array with property access tracking | ||
| * | ||
| * Tracks: | ||
| * - Array element access (arr[0]) | ||
| * - Length access (arr.length) | ||
| * - Array method calls (arr.map, arr.filter, etc.) | ||
| */ | ||
| export declare function createArrayProxy<T, U>(state: ProxyTrackerState<T>, target: U[], path: string, depth?: number): U[]; | ||
| /** | ||
| * Create a proxy for an object with property access tracking | ||
| * | ||
| * This is the core proxy creation function that recursively creates proxies | ||
| * for nested objects and arrays. | ||
| * | ||
| * Tracks: | ||
| * - Property access (obj.prop) | ||
| * - Nested property access (obj.nested.prop) | ||
| * - 'in' operator usage ('prop' in obj) | ||
| * - Object.keys, Object.entries, etc. | ||
| */ | ||
| export declare function createProxyInternal<T>(state: ProxyTrackerState<T>, target: T, path?: string, depth?: number): T; | ||
| /** | ||
| * Create a proxy for a target with caching | ||
| * | ||
| * If the target hasn't changed since the last call, returns the cached proxy. | ||
| * Otherwise, creates a new proxy and caches it. | ||
| * | ||
| * This is the main entry point for creating tracked proxies. | ||
| */ | ||
| export declare function createProxyForTarget<T>(state: ProxyTrackerState<T>, target: T): T; | ||
| //# sourceMappingURL=proxy-tracker.d.ts.map |
| {"version":3,"file":"proxy-tracker.d.ts","sourceRoot":"","sources":["../../src/tracking/proxy-tracker.ts"],"names":[],"mappings":"AAAA;;;;;;GAMG;AAeH;;;;;GAKG;AACH,wBAAgB,WAAW,CAAC,KAAK,EAAE,OAAO,GAAG,KAAK,IAAI,MAAM,CAI3D;AAED;;GAEG;AACH,MAAM,WAAW,iBAAiB,CAAC,CAAC;IAClC,wCAAwC;IACxC,YAAY,EAAE,GAAG,CAAC,MAAM,CAAC,CAAC;IAC1B,2CAA2C;IAC3C,UAAU,EAAE,OAAO,CAAC;IACpB,mDAAmD;IACnD,UAAU,EAAE,OAAO,CAAC,MAAM,EAAE,GAAG,CAAC,CAAC;IACjC,gEAAgE;IAEhE,mBAAmB,EAAE,OAAO,CAAC,QAAQ,EAAE,QAAQ,CAAC,GAAG,IAAI,CAAC;IACxD,kEAAkE;IAClE,gBAAgB,EAAE,CAAC,GAAG,IAAI,CAAC;IAC3B,2CAA2C;IAC3C,SAAS,EAAE,CAAC,GAAG,IAAI,CAAC;IACpB,8CAA8C;IAC9C,QAAQ,EAAE,MAAM,CAAC;CAClB;AAED;;;;;;;;;GASG;AACH,wBAAgB,uBAAuB,CAAC,CAAC,KAAK,iBAAiB,CAAC,CAAC,CAAC,CAUjE;AAED;;;;GAIG;AACH,wBAAgB,kBAAkB,CAAC,CAAC,EAAE,KAAK,EAAE,iBAAiB,CAAC,CAAC,CAAC,GAAG,IAAI,CAGvE;AAED;;;;GAIG;AACH,wBAAgB,iBAAiB,CAAC,CAAC,EAAE,KAAK,EAAE,iBAAiB,CAAC,CAAC,CAAC,GAAG,GAAG,CAAC,MAAM,CAAC,CAG7E;AAED;;;;;;;GAOG;AACH,wBAAgB,gBAAgB,CAAC,CAAC,EAAE,CAAC,EACnC,KAAK,EAAE,iBAAiB,CAAC,CAAC,CAAC,EAC3B,MAAM,EAAE,CAAC,EAAE,EACX,IAAI,EAAE,MAAM,EACZ,KAAK,GAAE,MAAU,GAChB,CAAC,EAAE,CA4DL;AAED;;;;;;;;;;;GAWG;AACH,wBAAgB,mBAAmB,CAAC,CAAC,EACnC,KAAK,EAAE,iBAAiB,CAAC,CAAC,CAAC,EAC3B,MAAM,EAAE,CAAC,EACT,IAAI,GAAE,MAAW,EACjB,KAAK,GAAE,MAAU,GAChB,CAAC,CAsFH;AAED;;;;;;;GAOG;AACH,wBAAgB,oBAAoB,CAAC,CAAC,EACpC,KAAK,EAAE,iBAAiB,CAAC,CAAC,CAAC,EAC3B,MAAM,EAAE,CAAC,GACR,CAAC,CAcH"} |
| declare const brand: unique symbol; | ||
| export type Brand<T, B> = T & { | ||
| [brand]: B; | ||
| }; | ||
| export type BrandedId<B> = Brand<string, B>; | ||
| export type InstanceId = Brand<string, 'InstanceId'>; | ||
| export declare function instanceId(id: string): InstanceId; | ||
| export {}; | ||
| //# sourceMappingURL=branded.d.ts.map |
| {"version":3,"file":"branded.d.ts","sourceRoot":"","sources":["../../src/types/branded.ts"],"names":[],"mappings":"AAAA,OAAO,CAAC,MAAM,KAAK,EAAE,OAAO,MAAM,CAAC;AAEnC,MAAM,MAAM,KAAK,CAAC,CAAC,EAAE,CAAC,IAAI,CAAC,GAAG;IAAE,CAAC,KAAK,CAAC,EAAE,CAAC,CAAA;CAAE,CAAC;AAC7C,MAAM,MAAM,SAAS,CAAC,CAAC,IAAI,KAAK,CAAC,MAAM,EAAE,CAAC,CAAC,CAAC;AAC5C,MAAM,MAAM,UAAU,GAAG,KAAK,CAAC,MAAM,EAAE,YAAY,CAAC,CAAC;AAErD,wBAAgB,UAAU,CAAC,EAAE,EAAE,MAAM,GAAG,UAAU,CAEjD"} |
| /** | ||
| * Base event interface for type-safe event system | ||
| */ | ||
| /** | ||
| * Base event interface | ||
| * Used by Vertex for event-driven state management | ||
| */ | ||
| export interface BaseEvent { | ||
| readonly type: string; | ||
| readonly timestamp: number; | ||
| readonly source?: string; | ||
| } | ||
| //# sourceMappingURL=events.d.ts.map |
| {"version":3,"file":"events.d.ts","sourceRoot":"","sources":["../../src/types/events.ts"],"names":[],"mappings":"AAAA;;GAEG;AAEH;;;GAGG;AACH,MAAM,WAAW,SAAS;IACxB,QAAQ,CAAC,IAAI,EAAE,MAAM,CAAC;IACtB,QAAQ,CAAC,SAAS,EAAE,MAAM,CAAC;IAC3B,QAAQ,CAAC,MAAM,CAAC,EAAE,MAAM,CAAC;CAC1B"} |
| import type { StateContainer } from '../core/StateContainer'; | ||
| export type ExtractState<T> = T extends StateContainer<infer S> ? S : never; | ||
| export type ExtractConstructorArgs<T> = T extends new (...args: infer P) => any ? P : never[]; | ||
| export type BlocConstructor<TBloc extends StateContainer<any>> = (new (...args: any[]) => TBloc) & { | ||
| resolve(instanceKey?: string, ...args: any[]): TBloc; | ||
| get(instanceKey?: string): TBloc; | ||
| getSafe(instanceKey?: string): { | ||
| error: Error; | ||
| instance: null; | ||
| } | { | ||
| error: null; | ||
| instance: TBloc; | ||
| }; | ||
| release(instanceKey?: string): void; | ||
| isolated?: boolean; | ||
| keepAlive?: boolean; | ||
| }; | ||
| //# sourceMappingURL=utilities.d.ts.map |
| {"version":3,"file":"utilities.d.ts","sourceRoot":"","sources":["../../src/types/utilities.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,cAAc,EAAE,MAAM,wBAAwB,CAAC;AAE7D,MAAM,MAAM,YAAY,CAAC,CAAC,IAAI,CAAC,SAAS,cAAc,CAAC,MAAM,CAAC,CAAC,GAAG,CAAC,GAAG,KAAK,CAAC;AAE5E,MAAM,MAAM,sBAAsB,CAAC,CAAC,IAAI,CAAC,SAAS,KAAK,GAAG,IAAI,EAAE,MAAM,CAAC,KAAK,GAAG,GAC3E,CAAC,GACD,KAAK,EAAE,CAAC;AAEZ,MAAM,MAAM,eAAe,CAAC,KAAK,SAAS,cAAc,CAAC,GAAG,CAAC,IAAI,CAAC,KAChE,GAAG,IAAI,EAAE,GAAG,EAAE,KACX,KAAK,CAAC,GAAG;IACZ,OAAO,CAAC,WAAW,CAAC,EAAE,MAAM,EAAE,GAAG,IAAI,EAAE,GAAG,EAAE,GAAG,KAAK,CAAC;IACrD,GAAG,CAAC,WAAW,CAAC,EAAE,MAAM,GAAG,KAAK,CAAC;IACjC,OAAO,CACL,WAAW,CAAC,EAAE,MAAM,GACnB;QAAE,KAAK,EAAE,KAAK,CAAC;QAAC,QAAQ,EAAE,IAAI,CAAA;KAAE,GAAG;QAAE,KAAK,EAAE,IAAI,CAAC;QAAC,QAAQ,EAAE,KAAK,CAAA;KAAE,CAAC;IACvE,OAAO,CAAC,WAAW,CAAC,EAAE,MAAM,GAAG,IAAI,CAAC;IACpC,QAAQ,CAAC,EAAE,OAAO,CAAC;IACnB,SAAS,CAAC,EAAE,OAAO,CAAC;CACrB,CAAC"} |
| /** | ||
| * Deep equality check with circular reference handling | ||
| */ | ||
| export declare function deepEqual<T>(a: T, b: T, seen?: WeakMap<WeakKey, any>): boolean; | ||
| /** | ||
| * Shallow equality check (more performant for simple cases) | ||
| */ | ||
| export declare function shallowEqual<T>(a: T, b: T): boolean; | ||
| //# sourceMappingURL=equality.d.ts.map |
| {"version":3,"file":"equality.d.ts","sourceRoot":"","sources":["../../src/utils/equality.ts"],"names":[],"mappings":"AAEA;;GAEG;AACH,wBAAgB,SAAS,CAAC,CAAC,EAAE,CAAC,EAAE,CAAC,EAAE,CAAC,EAAE,CAAC,EAAE,IAAI,wBAAgB,GAAG,OAAO,CA4DtE;AAED;;GAEG;AACH,wBAAgB,YAAY,CAAC,CAAC,EAAE,CAAC,EAAE,CAAC,EAAE,CAAC,EAAE,CAAC,GAAG,OAAO,CAWnD"} |
| /** | ||
| * Centralized ID Generation | ||
| * | ||
| * Provides consistent, collision-resistant ID generation for all BlaC subsystems. | ||
| * Uses timestamp + counter + random suffix for uniqueness. | ||
| */ | ||
| /** | ||
| * Creates an ID generator with isolated counter state | ||
| * | ||
| * @param prefix - Prefix for generated IDs | ||
| * @returns Object with next(), nextSimple(), and reset() methods | ||
| * | ||
| * @example | ||
| * ```ts | ||
| * const generator = createIdGenerator('sub'); | ||
| * const id1 = generator.next(); // "sub:1698765432100_1_a3k9d7f2q" | ||
| * const id2 = generator.next(); // "sub:1698765432101_2_b4n8e9g3r" | ||
| * ``` | ||
| */ | ||
| export declare function createIdGenerator(prefix: string): { | ||
| next: () => string; | ||
| nextSimple: () => string; | ||
| reset: () => void; | ||
| }; | ||
| /** | ||
| * Generate ID with timestamp, counter, and random suffix (tree-shakeable) | ||
| * | ||
| * Format: `${prefix}:${timestamp}_${counter}_${random}` | ||
| * | ||
| * @param prefix - Prefix for the ID (e.g., 'sub', 'consumer', 'stage') | ||
| * @returns Branded ID string | ||
| * | ||
| * @example | ||
| * ```ts | ||
| * const id = generateId('sub'); | ||
| * // Returns: "sub:1698765432100_1_a3k9d7f2q" | ||
| * ``` | ||
| */ | ||
| export declare function generateId(prefix: string): string; | ||
| /** | ||
| * Generate simple ID with timestamp and random (no counter tracking) | ||
| * | ||
| * Format: `${prefix}:${timestamp}_${random}` | ||
| * | ||
| * @param prefix - Prefix for the ID | ||
| * @returns Branded ID string | ||
| * | ||
| * @example | ||
| * ```ts | ||
| * const id = generateSimpleId('CounterBloc'); | ||
| * // Returns: "CounterBloc:1698765432100_a3k9d7f2q" | ||
| * ``` | ||
| */ | ||
| export declare function generateSimpleId(prefix: string, affix?: string): string; | ||
| /** | ||
| * Reset all counters for testing purposes | ||
| * @internal | ||
| */ | ||
| export declare function __resetIdCounters(): void; | ||
| /** | ||
| * Generate a unique isolated instance key | ||
| * Uses base36 encoding for compact, URL-safe identifiers | ||
| * | ||
| * Format: "isolated-{9-char-random-string}" | ||
| * Example: "isolated-k7x2m9p4q" | ||
| * | ||
| * @returns A unique isolated instance key | ||
| */ | ||
| export declare function generateIsolatedKey(): string; | ||
| /** | ||
| * Check if a key is an isolated instance key | ||
| * @param key - The instance key to check | ||
| * @returns true if the key is an isolated instance key | ||
| */ | ||
| export declare function isIsolatedKey(key: string): boolean; | ||
| //# sourceMappingURL=idGenerator.d.ts.map |
| {"version":3,"file":"idGenerator.d.ts","sourceRoot":"","sources":["../../src/utils/idGenerator.ts"],"names":[],"mappings":"AAAA;;;;;GAKG;AAKH;;;;;;;;;;;;GAYG;AACH,wBAAgB,iBAAiB,CAAC,MAAM,EAAE,MAAM;;;;EAU/C;AAED;;;;;;;;;;;;;GAaG;AACH,wBAAgB,UAAU,CAAC,MAAM,EAAE,MAAM,GAAG,MAAM,CAMjD;AAED;;;;;;;;;;;;;GAaG;AACH,wBAAgB,gBAAgB,CAAC,MAAM,EAAE,MAAM,EAAE,KAAK,CAAC,EAAE,MAAM,GAAG,MAAM,CAOvE;AAED;;;GAGG;AACH,wBAAgB,iBAAiB,IAAI,IAAI,CAExC;AAED;;;;;;;;GAQG;AACH,wBAAgB,mBAAmB,IAAI,MAAM,CAG5C;AAED;;;;GAIG;AACH,wBAAgB,aAAa,CAAC,GAAG,EAAE,MAAM,GAAG,OAAO,CAElD"} |
| /** | ||
| * Deep clone with circular reference handling | ||
| */ | ||
| export declare function cloneDeep<T>(obj: T, cloned?: WeakMap<WeakKey, any>): T; | ||
| /** | ||
| * Deep freeze with circular reference handling | ||
| * | ||
| * Note: Currently disabled by default for proxy tracking compatibility. | ||
| * Proxies cannot intercept property access on frozen objects due to proxy invariants. | ||
| * | ||
| * @param obj - Object to freeze | ||
| * @param frozen - WeakSet for tracking circular references | ||
| * @param enabled - Whether to actually freeze (default: false for proxy compatibility) | ||
| */ | ||
| export declare function deepFreeze<T>(obj: T, frozen?: WeakSet<WeakKey>, enabled?: boolean): T; | ||
| //# sourceMappingURL=immutable.d.ts.map |
| {"version":3,"file":"immutable.d.ts","sourceRoot":"","sources":["../../src/utils/immutable.ts"],"names":[],"mappings":"AAEA;;GAEG;AACH,wBAAgB,SAAS,CAAC,CAAC,EAAE,GAAG,EAAE,CAAC,EAAE,MAAM,wBAAgB,GAAG,CAAC,CAyC9D;AAED;;;;;;;;;GASG;AACH,wBAAgB,UAAU,CAAC,CAAC,EAC1B,GAAG,EAAE,CAAC,EACN,MAAM,mBAAgB,EACtB,OAAO,UAAQ,GACd,CAAC,CAoBH"} |
| /** | ||
| * Stack trace utilities for DevTools | ||
| */ | ||
| /** | ||
| * Capture and parse the current call stack | ||
| * Filters out internal BlaC framework calls to show only user code | ||
| */ | ||
| export declare function captureStackTrace(): string; | ||
| /** | ||
| * Parse a stack trace string into structured data | ||
| */ | ||
| export interface StackFrame { | ||
| functionName: string; | ||
| fileName: string; | ||
| lineNumber: number | null; | ||
| columnNumber: number | null; | ||
| } | ||
| export declare function parseStackTrace(stack: string): StackFrame[]; | ||
| //# sourceMappingURL=stack-trace.d.ts.map |
| {"version":3,"file":"stack-trace.d.ts","sourceRoot":"","sources":["../../src/utils/stack-trace.ts"],"names":[],"mappings":"AAAA;;GAEG;AAEH;;;GAGG;AACH,wBAAgB,iBAAiB,IAAI,MAAM,CA+B1C;AAED;;GAEG;AACH,MAAM,WAAW,UAAU;IACzB,YAAY,EAAE,MAAM,CAAC;IACrB,QAAQ,EAAE,MAAM,CAAC;IACjB,UAAU,EAAE,MAAM,GAAG,IAAI,CAAC;IAC1B,YAAY,EAAE,MAAM,GAAG,IAAI,CAAC;CAC7B;AAED,wBAAgB,eAAe,CAAC,KAAK,EAAE,MAAM,GAAG,UAAU,EAAE,CAiC3D"} |
| /** | ||
| * Utility functions for accessing static properties on StateContainer classes | ||
| */ | ||
| /** | ||
| * Get a static property from a class constructor | ||
| * Type-safe helper that avoids (Type as any) casts | ||
| * | ||
| * @param Type - The class constructor | ||
| * @param propName - The property name to access | ||
| * @param defaultValue - Optional default value if property is undefined | ||
| * @returns The property value or default | ||
| */ | ||
| export declare function getStaticProp<T>(Type: new (...args: any[]) => any, propName: string, defaultValue?: T): T | undefined; | ||
| /** | ||
| * Check if a class is marked as isolated | ||
| * Isolated classes create separate instances per component | ||
| */ | ||
| export declare function isIsolatedClass(Type: new (...args: any[]) => any): boolean; | ||
| /** | ||
| * Check if a class is marked as keepAlive | ||
| * KeepAlive classes are never auto-disposed when ref count reaches 0 | ||
| */ | ||
| export declare function isKeepAliveClass(Type: new (...args: any[]) => any): boolean; | ||
| /** | ||
| * Check if a class should be excluded from DevTools | ||
| * Used to prevent infinite loops when DevTools tracks itself | ||
| */ | ||
| export declare function isExcludedFromDevTools(Type: new (...args: any[]) => any): boolean; | ||
| //# sourceMappingURL=static-props.d.ts.map |
| {"version":3,"file":"static-props.d.ts","sourceRoot":"","sources":["../../src/utils/static-props.ts"],"names":[],"mappings":"AAAA;;GAEG;AAIH;;;;;;;;GAQG;AACH,wBAAgB,aAAa,CAAC,CAAC,EAC7B,IAAI,EAAE,KAAK,GAAG,IAAI,EAAE,GAAG,EAAE,KAAK,GAAG,EACjC,QAAQ,EAAE,MAAM,EAChB,YAAY,CAAC,EAAE,CAAC,GACf,CAAC,GAAG,SAAS,CAEf;AAED;;;GAGG;AACH,wBAAgB,eAAe,CAAC,IAAI,EAAE,KAAK,GAAG,IAAI,EAAE,GAAG,EAAE,KAAK,GAAG,GAAG,OAAO,CAE1E;AAED;;;GAGG;AACH,wBAAgB,gBAAgB,CAAC,IAAI,EAAE,KAAK,GAAG,IAAI,EAAE,GAAG,EAAE,KAAK,GAAG,GAAG,OAAO,CAE3E;AAED;;;GAGG;AACH,wBAAgB,sBAAsB,CACpC,IAAI,EAAE,KAAK,GAAG,IAAI,EAAE,GAAG,EAAE,KAAK,GAAG,GAChC,OAAO,CAKT"} |
+20
-885
@@ -1,885 +0,20 @@ | ||
| //#region src/types/events.d.ts | ||
| /** | ||
| * Base event interface for type-safe event system | ||
| */ | ||
| /** | ||
| * Base event interface | ||
| * Used by Vertex for event-driven state management | ||
| */ | ||
| interface BaseEvent { | ||
| readonly type: string; | ||
| readonly timestamp: number; | ||
| readonly source?: string; | ||
| } | ||
| //#endregion | ||
| //#region src/core/Vertex.d.ts | ||
| /** | ||
| * Event handler signature (synchronous only) | ||
| */ | ||
| type EventHandler<E$1 extends BaseEvent, S$1> = (event: E$1, emit: (state: S$1) => void) => void; | ||
| /** | ||
| * Type-safe event constructor | ||
| */ | ||
| type EventConstructor<T$1 extends BaseEvent = BaseEvent> = new (...args: never[]) => T$1; | ||
| /** | ||
| * Vertex is an event-driven state container (Bloc pattern) | ||
| * | ||
| * Includes its own simple event system since events are only needed | ||
| * for the Vertex pattern, not for the base StateContainer. | ||
| */ | ||
| declare abstract class Vertex<S$1, E$1 extends BaseEvent = BaseEvent> extends StateContainer<S$1> { | ||
| private eventHandlers; | ||
| private isProcessing; | ||
| private eventQueue; | ||
| /** | ||
| * Create a new Vertex | ||
| * @param initialState Initial state value | ||
| * @param config Configuration options | ||
| */ | ||
| constructor(initialState: S$1, config?: StateContainerConfig); | ||
| /** | ||
| * Register an event handler | ||
| * Arrow function to maintain correct 'this' binding | ||
| */ | ||
| protected on: <T extends E$1>(EventClass: EventConstructor<T>, handler: EventHandler<T, S$1>) => void; | ||
| /** | ||
| * Add an event to be processed | ||
| * Arrow function to maintain correct 'this' binding in React | ||
| */ | ||
| add: (event: E$1) => void; | ||
| /** | ||
| * Process an event (synchronously) | ||
| */ | ||
| private processEvent; | ||
| /** | ||
| * Handle a single event (synchronously) | ||
| */ | ||
| private handleEvent; | ||
| /** | ||
| * Hook for handling event processing errors | ||
| */ | ||
| protected onEventError(event: E$1, error: Error): void; | ||
| } | ||
| /** | ||
| * Example: Counter Events | ||
| */ | ||
| declare class IncrementEvent implements BaseEvent { | ||
| readonly amount: number; | ||
| readonly type = "increment"; | ||
| readonly timestamp: number; | ||
| constructor(amount?: number); | ||
| } | ||
| declare class DecrementEvent implements BaseEvent { | ||
| readonly amount: number; | ||
| readonly type = "decrement"; | ||
| readonly timestamp: number; | ||
| constructor(amount?: number); | ||
| } | ||
| declare class ResetEvent implements BaseEvent { | ||
| readonly type = "reset"; | ||
| readonly timestamp: number; | ||
| } | ||
| /** | ||
| * Example: Counter Vertex | ||
| * Demonstrates proper typing and event handling | ||
| */ | ||
| declare class CounterVertex extends Vertex<number> { | ||
| constructor(); | ||
| increment: (amount?: number) => void; | ||
| decrement: (amount?: number) => void; | ||
| reset: () => void; | ||
| } | ||
| /** | ||
| * Auth State and Events for testing async handlers | ||
| */ | ||
| interface AuthState { | ||
| isAuthenticated: boolean; | ||
| isLoading: boolean; | ||
| user: { | ||
| id: string; | ||
| name: string; | ||
| email: string; | ||
| } | null; | ||
| error: string | null; | ||
| } | ||
| declare class LoginEvent implements BaseEvent { | ||
| readonly email: string; | ||
| readonly password: string; | ||
| readonly type = "login"; | ||
| readonly timestamp: number; | ||
| constructor(email: string, password: string); | ||
| } | ||
| declare class LogoutEvent implements BaseEvent { | ||
| readonly type = "logout"; | ||
| readonly timestamp: number; | ||
| } | ||
| declare class AuthVertex extends Vertex<AuthState> { | ||
| constructor(); | ||
| login: (email: string, password: string) => void; | ||
| logout: () => void; | ||
| } | ||
| //#endregion | ||
| //#region src/core/StateContainerRegistry.d.ts | ||
| /** | ||
| * Lifecycle events that can be observed | ||
| */ | ||
| type LifecycleEvent = 'created' | 'stateChanged' | 'eventAdded' | 'disposed'; | ||
| /** | ||
| * Listener function types for each lifecycle event | ||
| */ | ||
| type LifecycleListener<E$1 extends LifecycleEvent> = E$1 extends 'created' ? (container: StateContainer<any>) => void : E$1 extends 'stateChanged' ? (container: StateContainer<any>, previousState: any, currentState: any) => void : E$1 extends 'eventAdded' ? (container: Vertex<any, any>, event: any) => void : E$1 extends 'disposed' ? (container: StateContainer<any>) => void : never; | ||
| /** | ||
| * Registry for managing StateContainer instances | ||
| */ | ||
| declare class StateContainerRegistry { | ||
| private readonly instances; | ||
| private readonly types; | ||
| private readonly listeners; | ||
| /** | ||
| * Register a type with isolation mode | ||
| */ | ||
| register<T extends StateContainer<any>>(constructor: new (...args: any[]) => T, isolated?: boolean): void; | ||
| /** | ||
| * Get or create a StateContainer instance | ||
| * For isolated: always creates new | ||
| * For shared: singleton per key | ||
| */ | ||
| getOrCreate<T extends StateContainer<any>>(constructor: new (...args: any[]) => T, key?: string, ...args: any[]): T; | ||
| /** | ||
| * Release a reference to an instance | ||
| * Disposes when ref count reaches zero (unless static keepAlive is true) | ||
| */ | ||
| release<T extends StateContainer<any>>(constructor: new (...args: any[]) => T, key?: string, forceDispose?: boolean): void; | ||
| /** | ||
| * Get all instances of a type (shared only, isolated aren't tracked) | ||
| */ | ||
| getAll<T extends StateContainer<any>>(constructor: new (...args: any[]) => T): T[]; | ||
| /** | ||
| * Clear all instances of a type | ||
| */ | ||
| clear<T extends StateContainer<any>>(constructor: new (...args: any[]) => T): void; | ||
| /** | ||
| * Clear all instances from all types (for testing) | ||
| */ | ||
| clearAll(): void; | ||
| /** | ||
| * Get registry statistics (for debugging) | ||
| */ | ||
| getStats(): { | ||
| registeredTypes: number; | ||
| totalInstances: number; | ||
| typeBreakdown: Record<string, number>; | ||
| }; | ||
| /** | ||
| * Get reference count for an instance | ||
| */ | ||
| getRefCount<T extends StateContainer<any>>(constructor: new (...args: any[]) => T, key?: string): number; | ||
| /** | ||
| * Check if an instance exists | ||
| */ | ||
| hasInstance<T extends StateContainer<any>>(constructor: new (...args: any[]) => T, key?: string): boolean; | ||
| /** | ||
| * Subscribe to lifecycle events | ||
| * @param event - The lifecycle event to listen for | ||
| * @param listener - The listener function to call when the event occurs | ||
| * @returns Unsubscribe function | ||
| */ | ||
| on<E extends LifecycleEvent>(event: E, listener: LifecycleListener<E>): () => void; | ||
| /** | ||
| * Emit lifecycle event to all listeners | ||
| * @internal - Called by StateContainer/Vertex lifecycle methods | ||
| */ | ||
| emit(event: LifecycleEvent, ...args: any[]): void; | ||
| } | ||
| /** | ||
| * Global default registry instance | ||
| */ | ||
| declare const globalRegistry: StateContainerRegistry; | ||
| //#endregion | ||
| //#region src/core/StateContainer.d.ts | ||
| /** | ||
| * Configuration options for StateContainer | ||
| */ | ||
| interface StateContainerConfig { | ||
| /** Container name for debugging */ | ||
| name?: string; | ||
| /** Enable debug logging */ | ||
| debug?: boolean; | ||
| /** Custom instance identifier */ | ||
| instanceId?: string; | ||
| } | ||
| /** | ||
| * Listener function for state changes | ||
| */ | ||
| type StateListener<S$1> = (state: S$1) => void; | ||
| /** | ||
| * Base abstract class for all state containers | ||
| */ | ||
| declare abstract class StateContainer<S$1> { | ||
| protected static _registry: StateContainerRegistry; | ||
| /** | ||
| * Set a custom registry (mainly for testing) | ||
| */ | ||
| static setRegistry(registry: StateContainerRegistry): void; | ||
| /** | ||
| * Register a type as isolated or shared | ||
| */ | ||
| static register<T extends StateContainer<any>>(this: new (...args: any[]) => T, isolated?: boolean): void; | ||
| /** | ||
| * Get or create an instance | ||
| * @param key - Optional instance key for shared instances | ||
| * @param args - Constructor arguments | ||
| */ | ||
| static getOrCreate<T extends StateContainer<any>>(this: new (...args: any[]) => T, key?: string, ...args: any[]): T; | ||
| /** | ||
| * Release a reference to an instance | ||
| * @param key - Optional instance key | ||
| * @param forceDispose - Force dispose regardless of ref count or keepAlive | ||
| */ | ||
| static release<T extends StateContainer<any>>(this: new (...args: any[]) => T, key?: string, forceDispose?: boolean): void; | ||
| /** | ||
| * Get all instances of this type | ||
| */ | ||
| static getAll<T extends StateContainer<any>>(this: new (...args: any[]) => T): T[]; | ||
| /** | ||
| * Clear all instances of this type | ||
| */ | ||
| static clear<T extends StateContainer<any>>(this: new (...args: any[]) => T): void; | ||
| /** | ||
| * Clear all instances from all types (for testing) | ||
| */ | ||
| static clearAllInstances(): void; | ||
| /** | ||
| * Get registry statistics (for debugging) | ||
| */ | ||
| static getStats(): { | ||
| registeredTypes: number; | ||
| totalInstances: number; | ||
| typeBreakdown: Record<string, number>; | ||
| }; | ||
| /** | ||
| * Get reference count for an instance | ||
| * @param key - Optional instance key | ||
| */ | ||
| static getRefCount<T extends StateContainer<any>>(this: new (...args: any[]) => T, key?: string): number; | ||
| /** | ||
| * Check if an instance exists | ||
| * @param key - Optional instance key | ||
| */ | ||
| static hasInstance<T extends StateContainer<any>>(this: new (...args: any[]) => T, key?: string): boolean; | ||
| private _state; | ||
| private readonly listeners; | ||
| private _disposed; | ||
| private readonly config; | ||
| readonly name: string; | ||
| readonly debug: boolean; | ||
| readonly instanceId: string; | ||
| /** | ||
| * Create a new StateContainer | ||
| */ | ||
| constructor(initialState: S$1, config?: StateContainerConfig); | ||
| /** | ||
| * Get the current state | ||
| */ | ||
| get state(): S$1; | ||
| /** | ||
| * Check if disposed | ||
| */ | ||
| get isDisposed(): boolean; | ||
| /** | ||
| * Subscribe to state changes | ||
| * @returns Unsubscribe function | ||
| */ | ||
| subscribe(listener: StateListener<S$1>): () => void; | ||
| /** | ||
| * Dispose the container | ||
| */ | ||
| dispose(): void; | ||
| /** | ||
| * Emit a new state (with change detection) | ||
| */ | ||
| protected emit(newState: S$1): void; | ||
| /** | ||
| * Update state using a function | ||
| */ | ||
| protected update(updater: (current: S$1) => S$1): void; | ||
| /** | ||
| * Optional disposal hook for subclasses | ||
| */ | ||
| protected onDispose?(): void; | ||
| /** | ||
| * Optional state change hook for subclasses | ||
| */ | ||
| protected onStateChange?(newState: S$1, previousState: S$1): void; | ||
| } | ||
| //#endregion | ||
| //#region src/core/Cubit.d.ts | ||
| /** | ||
| * Cubit is a simple state container that allows direct state emission | ||
| * | ||
| * Unlike StateContainer (where emit is protected), Cubit exposes emit and update | ||
| * as public methods to allow direct state management. | ||
| */ | ||
| declare abstract class Cubit<S$1> extends StateContainer<S$1> { | ||
| /** | ||
| * Create a new Cubit | ||
| * @param initialState Initial state value | ||
| * @param config Configuration options | ||
| */ | ||
| constructor(initialState: S$1, config?: StateContainerConfig); | ||
| /** | ||
| * Emit a new state (public override of protected parent method) | ||
| */ | ||
| emit(newState: S$1): void; | ||
| /** | ||
| * Update state using a function (public override of protected parent method) | ||
| */ | ||
| update(updater: (current: S$1) => S$1): void; | ||
| /** | ||
| * Patch state with partial updates (shallow merge) | ||
| * Only available when state is an object type | ||
| * Arrow function to maintain correct 'this' binding in React | ||
| * | ||
| * @example | ||
| * ```typescript | ||
| * // Update single field | ||
| * this.patch({ count: 5 }); | ||
| * | ||
| * // Update multiple fields | ||
| * this.patch({ count: 5, name: 'Updated' }); | ||
| * ``` | ||
| */ | ||
| patch: S$1 extends object ? (partial: Partial<S$1>) => void : never; | ||
| } | ||
| /** | ||
| * Example: Counter Cubit | ||
| */ | ||
| declare class CounterCubit extends Cubit<number> { | ||
| constructor(); | ||
| increment: () => void; | ||
| decrement: () => void; | ||
| reset: () => void; | ||
| addAmount: (amount: number) => void; | ||
| } | ||
| /** | ||
| * Example: Complex State Cubit | ||
| */ | ||
| interface TodoState { | ||
| todos: Array<{ | ||
| id: string; | ||
| text: string; | ||
| done: boolean; | ||
| }>; | ||
| filter: 'all' | 'active' | 'completed'; | ||
| isLoading: boolean; | ||
| } | ||
| declare class TodoCubit extends Cubit<TodoState> { | ||
| static keepAlive: boolean; | ||
| private nextId; | ||
| constructor(); | ||
| addTodo: (text: string) => void; | ||
| toggleTodo: (id: string) => void; | ||
| removeTodo: (id: string) => void; | ||
| setFilter: (filter: TodoState["filter"]) => void; | ||
| setLoading: (isLoading: boolean) => void; | ||
| get visibleTodos(): { | ||
| id: string; | ||
| text: string; | ||
| done: boolean; | ||
| }[]; | ||
| get activeTodoCount(): number; | ||
| } | ||
| //#endregion | ||
| //#region src/types/branded.d.ts | ||
| /** | ||
| * Branded types for type-safe IDs | ||
| * These types ensure that IDs can't be accidentally mixed up | ||
| */ | ||
| /** | ||
| * Helper type for cases where any object type is acceptable | ||
| * Used sparingly only where type cannot be more specific | ||
| * eslint-disable-next-line @typescript-eslint/no-explicit-any | ||
| */ | ||
| type AnyObject = any; | ||
| /** Unique symbol for branding */ | ||
| declare const brand: unique symbol; | ||
| /** Type branding utility */ | ||
| type Brand<T$1, B> = T$1 & { | ||
| [brand]: B; | ||
| }; | ||
| /** Generic branded ID type */ | ||
| type BrandedId<B> = Brand<string, B>; | ||
| /** Branded instance ID type */ | ||
| type InstanceId = Brand<string, 'InstanceId'>; | ||
| //#endregion | ||
| //#region src/tracking/proxy-tracker.d.ts | ||
| /** | ||
| * Functional proxy tracker for automatic dependency tracking | ||
| * | ||
| * This module provides a functional approach to proxy-based dependency tracking. | ||
| * Unlike the class-based ProxyTracker, this uses a state object pattern that's | ||
| * easier to integrate with functional programming patterns and framework hooks. | ||
| */ | ||
| /** | ||
| * Check if a value can be proxied | ||
| * | ||
| * Returns true for plain objects and arrays only. | ||
| * Excludes built-in objects like Date, Map, Set, etc. | ||
| */ | ||
| declare function isProxyable(value: unknown): value is object; | ||
| /** | ||
| * State container for proxy tracking | ||
| */ | ||
| interface ProxyTrackerState<T$1> { | ||
| /** Set of all tracked property paths */ | ||
| trackedPaths: Set<string>; | ||
| /** Whether tracking is currently active */ | ||
| isTracking: boolean; | ||
| /** Cache of created proxies to avoid duplicates */ | ||
| proxyCache: WeakMap<object, any>; | ||
| /** Cache of bound functions to maintain referential equality */ | ||
| boundFunctionsCache: WeakMap<Function, Function> | null; | ||
| /** Last state object that was proxied (for cache invalidation) */ | ||
| lastProxiedState: T$1 | null; | ||
| /** Last proxy created (for cache reuse) */ | ||
| lastProxy: T$1 | null; | ||
| /** Maximum depth for nested proxy creation */ | ||
| maxDepth: number; | ||
| } | ||
| /** | ||
| * Create a new proxy tracker state | ||
| * | ||
| * @example | ||
| * const state = createProxyTrackerState<MyState>(); | ||
| * startProxyTracking(state); | ||
| * const proxy = createProxyForTarget(state, myObject); | ||
| * // ... use proxy ... | ||
| * const paths = stopProxyTracking(state); | ||
| */ | ||
| declare function createProxyTrackerState<T$1>(): ProxyTrackerState<T$1>; | ||
| /** | ||
| * Start tracking property accesses | ||
| * | ||
| * Clears previous tracked paths and enables tracking mode. | ||
| */ | ||
| declare function startProxyTracking<T$1>(state: ProxyTrackerState<T$1>): void; | ||
| /** | ||
| * Stop tracking and return the tracked paths | ||
| * | ||
| * Returns a new Set containing all tracked paths. | ||
| */ | ||
| declare function stopProxyTracking<T$1>(state: ProxyTrackerState<T$1>): Set<string>; | ||
| /** | ||
| * Create a proxy for an array with property access tracking | ||
| * | ||
| * Tracks: | ||
| * - Array element access (arr[0]) | ||
| * - Length access (arr.length) | ||
| * - Array method calls (arr.map, arr.filter, etc.) | ||
| */ | ||
| declare function createArrayProxy<T$1, U>(state: ProxyTrackerState<T$1>, target: U[], path: string, depth?: number): U[]; | ||
| /** | ||
| * Create a proxy for an object with property access tracking | ||
| * | ||
| * This is the core proxy creation function that recursively creates proxies | ||
| * for nested objects and arrays. | ||
| * | ||
| * Tracks: | ||
| * - Property access (obj.prop) | ||
| * - Nested property access (obj.nested.prop) | ||
| * - 'in' operator usage ('prop' in obj) | ||
| * - Object.keys, Object.entries, etc. | ||
| */ | ||
| declare function createProxyInternal<T$1>(state: ProxyTrackerState<T$1>, target: T$1, path?: string, depth?: number): T$1; | ||
| /** | ||
| * Create a proxy for a target with caching | ||
| * | ||
| * If the target hasn't changed since the last call, returns the cached proxy. | ||
| * Otherwise, creates a new proxy and caches it. | ||
| * | ||
| * This is the main entry point for creating tracked proxies. | ||
| */ | ||
| declare function createProxyForTarget<T$1>(state: ProxyTrackerState<T$1>, target: T$1): T$1; | ||
| //#endregion | ||
| //#region src/tracking/dependency-tracker.d.ts | ||
| /** | ||
| * Information about a tracked path | ||
| */ | ||
| interface PathInfo { | ||
| /** Parsed path segments */ | ||
| segments: string[]; | ||
| /** Last known value at this path */ | ||
| value: any; | ||
| } | ||
| /** | ||
| * State for dependency tracking | ||
| */ | ||
| interface TrackerState<T$1 extends AnyObject> { | ||
| /** Internal proxy tracker state */ | ||
| proxyTrackerState: ProxyTrackerState<T$1>; | ||
| /** Paths tracked in the previous render */ | ||
| previousRenderPaths: Set<string>; | ||
| /** Paths tracked in the current render */ | ||
| currentRenderPaths: Set<string>; | ||
| /** Cache of parsed paths and their values */ | ||
| pathCache: Map<string, PathInfo>; | ||
| /** Last state object that was checked for changes */ | ||
| lastCheckedState: T$1 | null; | ||
| /** Values from the last change check (optimization) */ | ||
| lastCheckedValues: Map<string, any>; | ||
| /** Counter for periodic cleanup of unused paths */ | ||
| cleanupCounter: number; | ||
| } | ||
| /** | ||
| * Create a new tracker state | ||
| */ | ||
| declare function createTrackerState<T$1 extends AnyObject>(): TrackerState<T$1>; | ||
| /** | ||
| * Start tracking property accesses | ||
| */ | ||
| declare function startTracking<T$1 extends AnyObject>(tracker: TrackerState<T$1>): void; | ||
| /** | ||
| * Create a proxy for the given state | ||
| */ | ||
| declare function createProxy<T$1 extends AnyObject>(tracker: TrackerState<T$1>, state: T$1): T$1; | ||
| /** | ||
| * Capture the paths that were tracked during a render | ||
| * | ||
| * This should be called after each render to record which paths were accessed. | ||
| * It also performs periodic cleanup of unused paths to prevent memory leaks. | ||
| */ | ||
| declare function captureTrackedPaths<T$1 extends AnyObject>(tracker: TrackerState<T$1>, state: T$1): void; | ||
| /** | ||
| * Check if any tracked paths have changed | ||
| * | ||
| * This is called when state changes to determine if a re-render is needed. | ||
| * Returns true if any tracked path has a different value than before. | ||
| */ | ||
| declare function hasChanges<T$1 extends AnyObject>(tracker: TrackerState<T$1>, state: T$1): boolean; | ||
| /** | ||
| * Check if tracker has any tracked data | ||
| * | ||
| * Returns true if there are any tracked paths or cached paths. | ||
| */ | ||
| declare function hasTrackedData<T$1 extends AnyObject>(tracker: TrackerState<T$1>): boolean; | ||
| //#endregion | ||
| //#region src/tracking/path-utils.d.ts | ||
| /** | ||
| * Path utilities for dependency tracking | ||
| * | ||
| * Provides utilities for parsing property paths and extracting values | ||
| * from nested objects using path strings. | ||
| */ | ||
| /** | ||
| * Parse a property path string into an array of segments | ||
| * | ||
| * Handles both dot notation (a.b.c) and bracket notation (a[0].b) | ||
| * | ||
| * @example | ||
| * parsePath('user.name') // ['user', 'name'] | ||
| * parsePath('items[0].name') // ['items', '0', 'name'] | ||
| * parsePath('data.users[2].address.city') // ['data', 'users', '2', 'address', 'city'] | ||
| */ | ||
| declare function parsePath(path: string): string[]; | ||
| /** | ||
| * Get a value from an object using a path of segments | ||
| * | ||
| * @example | ||
| * const obj = { user: { name: 'Alice', age: 30 } } | ||
| * getValueAtPath(obj, ['user', 'name']) // 'Alice' | ||
| * getValueAtPath(obj, ['user', 'age']) // 30 | ||
| * getValueAtPath(obj, ['user', 'missing']) // undefined | ||
| */ | ||
| declare function getValueAtPath(obj: any, segments: string[]): any; | ||
| /** | ||
| * Shallow equality comparison for arrays | ||
| * | ||
| * Compares two arrays element-by-element using Object.is | ||
| * | ||
| * @example | ||
| * shallowEqual([1, 2, 3], [1, 2, 3]) // true | ||
| * shallowEqual([1, 2, 3], [1, 2, 4]) // false | ||
| * shallowEqual([1, 2], [1, 2, 3]) // false | ||
| */ | ||
| declare function shallowEqual(arr1: unknown[], arr2: unknown[]): boolean; | ||
| //#endregion | ||
| //#region src/proxy/ProxyTracker.d.ts | ||
| /** | ||
| * ProxyTracker - Automatic dependency tracking through Proxies | ||
| * | ||
| * Tracks property access on state objects to automatically determine | ||
| * which parts of the state a component depends on. | ||
| */ | ||
| /** | ||
| * Tracks property access on state objects | ||
| */ | ||
| declare class ProxyTracker<T$1> { | ||
| private trackedPaths; | ||
| private isTracking; | ||
| private proxyCache; | ||
| private maxDepth; | ||
| /** | ||
| * Create a proxy that tracks property access | ||
| */ | ||
| createProxy(target: T$1, path?: string, depth?: number): T$1; | ||
| /** | ||
| * Create a proxy for arrays with special handling | ||
| */ | ||
| private createArrayProxy; | ||
| /** | ||
| * Start tracking property access | ||
| */ | ||
| startTracking(): void; | ||
| /** | ||
| * Stop tracking and return tracked paths | ||
| */ | ||
| stopTracking(): Set<string>; | ||
| /** | ||
| * Get currently tracked paths | ||
| */ | ||
| getTrackedPaths(): ReadonlySet<string>; | ||
| /** | ||
| * Check if currently tracking | ||
| */ | ||
| isCurrentlyTracking(): boolean; | ||
| /** | ||
| * Clear proxy cache (useful for memory management) | ||
| */ | ||
| clearCache(): void; | ||
| /** | ||
| * Set maximum tracking depth | ||
| */ | ||
| setMaxDepth(depth: number): void; | ||
| /** | ||
| * Add a path manually (useful for forcing dependencies) | ||
| */ | ||
| addPath(path: string): void; | ||
| /** | ||
| * Remove a path manually | ||
| */ | ||
| removePath(path: string): void; | ||
| /** | ||
| * Clear all tracked paths | ||
| */ | ||
| clearPaths(): void; | ||
| } | ||
| /** | ||
| * Global proxy tracker instance for convenience | ||
| */ | ||
| declare const globalProxyTracker: ProxyTracker<unknown>; | ||
| /** | ||
| * Utility function to track property access in a callback | ||
| */ | ||
| declare function trackAccess<T$1, R>(state: T$1, callback: (proxiedState: T$1) => R): { | ||
| result: R; | ||
| trackedPaths: Set<string>; | ||
| }; | ||
| //#endregion | ||
| //#region src/types/utilities.d.ts | ||
| /** | ||
| * Extract state type from StateContainer | ||
| * | ||
| * @example | ||
| * ```ts | ||
| * class CounterBloc extends Cubit<number> { ... } | ||
| * type State = ExtractState<CounterBloc>; // number | ||
| * ``` | ||
| */ | ||
| type ExtractState<T$1> = T$1 extends StateContainer<infer S> ? S : never; | ||
| /** | ||
| * Extract constructor parameter types from a Bloc class | ||
| * | ||
| * @example | ||
| * ```ts | ||
| * class UserBloc extends Cubit<UserState> { | ||
| * constructor(userId: string, config: Config) { ... } | ||
| * } | ||
| * type Args = ExtractConstructorArgs<typeof UserBloc>; // [string, Config] | ||
| * ``` | ||
| */ | ||
| type ExtractConstructorArgs<T$1> = T$1 extends (new (...args: infer P) => AnyObject) ? P : never[]; | ||
| /** | ||
| * Bloc constructor type - represents a class constructor for StateContainer subclasses | ||
| * Includes static methods from StateContainer for instance management | ||
| * | ||
| * Note: Uses `any` for state type to support variance - the actual Bloc instance | ||
| * will have the correct specific types inferred at usage sites. | ||
| * | ||
| * @example | ||
| * ```ts | ||
| * function createBloc<TBloc extends StateContainer<any>>( | ||
| * BlocClass: BlocConstructor<TBloc> | ||
| * ): TBloc { | ||
| * return BlocClass.getOrCreate(); | ||
| * } | ||
| * ``` | ||
| */ | ||
| type BlocConstructor<TBloc extends StateContainer<any>> = (new (...args: any[]) => TBloc) & { | ||
| getOrCreate?(instanceKey?: string, ...args: any[]): TBloc; | ||
| release?(instanceKey?: string): void; | ||
| isolated?: boolean; | ||
| keepAlive?: boolean; | ||
| }; | ||
| //#endregion | ||
| //#region src/logging/Logger.d.ts | ||
| declare enum LogLevel { | ||
| ERROR = 0, | ||
| WARN = 1, | ||
| INFO = 2, | ||
| DEBUG = 3, | ||
| } | ||
| interface LogEntry { | ||
| level: string; | ||
| context: string; | ||
| message: string; | ||
| data?: any; | ||
| timestamp: number; | ||
| } | ||
| interface LogConfig { | ||
| enabled: boolean; | ||
| level: LogLevel; | ||
| output: (entry: LogEntry) => void; | ||
| } | ||
| /** | ||
| * Creates a logger instance with given configuration | ||
| * | ||
| * @param config - Logger configuration | ||
| * @returns Logger instance with debug, info, warn, error, and configure methods | ||
| * | ||
| * @example | ||
| * ```ts | ||
| * const logger = createLogger({ | ||
| * enabled: true, | ||
| * level: LogLevel.DEBUG, | ||
| * output: (entry) => console.log(JSON.stringify(entry)) | ||
| * }); | ||
| * logger.debug('MyComponent', 'Rendering', { props: { foo: 'bar' } }); | ||
| * ``` | ||
| */ | ||
| declare function createLogger(config: LogConfig): { | ||
| debug: (context: string, message: string, data?: any) => void; | ||
| info: (context: string, message: string, data?: any) => void; | ||
| warn: (context: string, message: string, data?: any) => void; | ||
| error: (context: string, message: string, data?: any) => void; | ||
| configure: (opts: Partial<LogConfig>) => void; | ||
| }; | ||
| declare const debug: (context: string, message: string, data?: any) => void; | ||
| declare const info: (context: string, message: string, data?: any) => void; | ||
| declare const warn: (context: string, message: string, data?: any) => void; | ||
| declare const error: (context: string, message: string, data?: any) => void; | ||
| /** | ||
| * Configuration function that recreates the default logger | ||
| * | ||
| * @param opts - Partial logger configuration | ||
| * | ||
| * @example | ||
| * ```ts | ||
| * configureLogger({ enabled: true, level: LogLevel.DEBUG }); | ||
| * ``` | ||
| */ | ||
| declare function configureLogger(opts: Partial<LogConfig>): void; | ||
| //#endregion | ||
| //#region src/constants.d.ts | ||
| /** | ||
| * Default configuration constants for BlaC | ||
| * | ||
| * Centralized location for all magic numbers and default values. | ||
| */ | ||
| /** | ||
| * Default configuration constants for BlaC | ||
| */ | ||
| declare const BLAC_DEFAULTS: { | ||
| /** | ||
| * Default cleanup interval for subscriptions (30 seconds) | ||
| */ | ||
| readonly CLEANUP_INTERVAL_MS: 30000; | ||
| /** | ||
| * Cleanup interval for weak reference stage (10 seconds) | ||
| */ | ||
| readonly WEAKREF_CLEANUP_INTERVAL_MS: 10000; | ||
| /** | ||
| * Default maximum subscriptions per container | ||
| */ | ||
| readonly MAX_SUBSCRIPTIONS: 1000; | ||
| /** | ||
| * Maximum subscriptions for high-performance mode | ||
| */ | ||
| readonly MAX_SUBSCRIPTIONS_HIGH_PERF: 10000; | ||
| /** | ||
| * Default timeout for pipeline execution (5 seconds) | ||
| */ | ||
| readonly PIPELINE_TIMEOUT_MS: 5000; | ||
| /** | ||
| * Cleanup interval for high-performance mode (5 seconds) | ||
| */ | ||
| readonly CLEANUP_INTERVAL_HIGH_PERF_MS: 5000; | ||
| /** | ||
| * Maximum number of stages in a pipeline | ||
| */ | ||
| readonly MAX_PIPELINE_STAGES: 30; | ||
| }; | ||
| //#endregion | ||
| //#region src/utils/idGenerator.d.ts | ||
| /** | ||
| * Centralized ID Generation | ||
| * | ||
| * Provides consistent, collision-resistant ID generation for all BlaC subsystems. | ||
| * Uses timestamp + counter + random suffix for uniqueness. | ||
| */ | ||
| /** | ||
| * Creates an ID generator with isolated counter state | ||
| * | ||
| * @param prefix - Prefix for generated IDs | ||
| * @returns Object with next(), nextSimple(), and reset() methods | ||
| * | ||
| * @example | ||
| * ```ts | ||
| * const generator = createIdGenerator('sub'); | ||
| * const id1 = generator.next(); // "sub_1698765432100_1_a3k9d7f2q" | ||
| * const id2 = generator.next(); // "sub_1698765432101_2_b4n8e9g3r" | ||
| * ``` | ||
| */ | ||
| declare function createIdGenerator(prefix: string): { | ||
| next: () => string; | ||
| nextSimple: () => string; | ||
| reset: () => void; | ||
| }; | ||
| /** | ||
| * Generate ID with timestamp, counter, and random suffix (tree-shakeable) | ||
| * | ||
| * Format: `${prefix}_${timestamp}_${counter}_${random}` | ||
| * | ||
| * @param prefix - Prefix for the ID (e.g., 'sub', 'consumer', 'stage') | ||
| * @returns Branded ID string | ||
| * | ||
| * @example | ||
| * ```ts | ||
| * const id = generateId('sub'); | ||
| * // Returns: "sub_1698765432100_1_a3k9d7f2q" | ||
| * ``` | ||
| */ | ||
| declare function generateId(prefix: string): string; | ||
| /** | ||
| * Generate simple ID with timestamp and random (no counter tracking) | ||
| * | ||
| * Format: `${prefix}_${timestamp}_${random}` | ||
| * | ||
| * @param prefix - Prefix for the ID | ||
| * @returns Branded ID string | ||
| * | ||
| * @example | ||
| * ```ts | ||
| * const id = generateSimpleId('CounterBloc'); | ||
| * // Returns: "CounterBloc_1698765432100_a3k9d7f2q" | ||
| * ``` | ||
| */ | ||
| declare function generateSimpleId(prefix: string): string; | ||
| /** | ||
| * Reset all counters for testing purposes | ||
| * @internal | ||
| */ | ||
| declare function __resetIdCounters(): void; | ||
| //#endregion | ||
| export { type AnyObject, AuthState, AuthVertex, BLAC_DEFAULTS, type BaseEvent, BlocConstructor, type Brand, type BrandedId, CounterCubit, CounterVertex, Cubit, DecrementEvent, EventConstructor, EventHandler, ExtractConstructorArgs, ExtractState, IncrementEvent, type InstanceId, type LifecycleEvent, type LifecycleListener, type LogConfig, type LogEntry, LogLevel, LoginEvent, LogoutEvent, PathInfo, ProxyTracker, ProxyTrackerState, ResetEvent, StateContainer, StateContainerConfig, StateContainerRegistry, TodoCubit, TodoState, TrackerState, Vertex, __resetIdCounters, captureTrackedPaths, configureLogger, createArrayProxy, createIdGenerator, createLogger, createProxy, createProxyForTarget, createProxyInternal, createProxyTrackerState, createTrackerState, debug, error, generateId, generateSimpleId, getValueAtPath, globalProxyTracker, globalRegistry, hasChanges, hasTrackedData, info, isProxyable, parsePath, shallowEqual, startProxyTracking, startTracking, stopProxyTracking, trackAccess, warn }; | ||
| //# sourceMappingURL=index.d.cts.map | ||
| export * from './core/StateContainer'; | ||
| export * from './core/StateContainerRegistry'; | ||
| export * from './core/Cubit'; | ||
| export * from './core/Vertex'; | ||
| export { globalRegistry, getPluginManager, } from './core/StateContainerRegistry'; | ||
| export type { LifecycleEvent, LifecycleListener, } from './core/StateContainerRegistry'; | ||
| export type { BlacPlugin, BlacPluginWithInit, PluginContext, PluginConfig, InstanceMetadata, } from './plugin/BlacPlugin'; | ||
| export { PluginManager, createPluginManager } from './plugin/PluginManager'; | ||
| export { hasInitHook } from './plugin/BlacPlugin'; | ||
| export * from './tracking'; | ||
| export * from './proxy/ProxyTracker'; | ||
| export * from './adapter'; | ||
| export type { Brand, BrandedId, InstanceId } from './types/branded'; | ||
| export type { BaseEvent } from './types/events'; | ||
| export * from './types/utilities'; | ||
| export { createLogger, configureLogger, debug, info, warn, error, LogLevel, type LogConfig, type LogEntry, } from './logging/Logger'; | ||
| export { BLAC_DEFAULTS, BLAC_STATIC_PROPS, BLAC_ID_PATTERNS, BLAC_ERROR_PREFIX, } from './constants'; | ||
| export { generateId, generateSimpleId, createIdGenerator, __resetIdCounters, generateIsolatedKey, isIsolatedKey, } from './utils/idGenerator'; | ||
| export { getStaticProp, isIsolatedClass, isKeepAliveClass, isExcludedFromDevTools, } from './utils/static-props'; | ||
| //# sourceMappingURL=index.d.ts.map |
+19
-884
@@ -1,885 +0,20 @@ | ||
| //#region src/types/events.d.ts | ||
| /** | ||
| * Base event interface for type-safe event system | ||
| */ | ||
| /** | ||
| * Base event interface | ||
| * Used by Vertex for event-driven state management | ||
| */ | ||
| interface BaseEvent { | ||
| readonly type: string; | ||
| readonly timestamp: number; | ||
| readonly source?: string; | ||
| } | ||
| //#endregion | ||
| //#region src/core/Vertex.d.ts | ||
| /** | ||
| * Event handler signature (synchronous only) | ||
| */ | ||
| type EventHandler<E$1 extends BaseEvent, S$1> = (event: E$1, emit: (state: S$1) => void) => void; | ||
| /** | ||
| * Type-safe event constructor | ||
| */ | ||
| type EventConstructor<T$1 extends BaseEvent = BaseEvent> = new (...args: never[]) => T$1; | ||
| /** | ||
| * Vertex is an event-driven state container (Bloc pattern) | ||
| * | ||
| * Includes its own simple event system since events are only needed | ||
| * for the Vertex pattern, not for the base StateContainer. | ||
| */ | ||
| declare abstract class Vertex<S$1, E$1 extends BaseEvent = BaseEvent> extends StateContainer<S$1> { | ||
| private eventHandlers; | ||
| private isProcessing; | ||
| private eventQueue; | ||
| /** | ||
| * Create a new Vertex | ||
| * @param initialState Initial state value | ||
| * @param config Configuration options | ||
| */ | ||
| constructor(initialState: S$1, config?: StateContainerConfig); | ||
| /** | ||
| * Register an event handler | ||
| * Arrow function to maintain correct 'this' binding | ||
| */ | ||
| protected on: <T extends E$1>(EventClass: EventConstructor<T>, handler: EventHandler<T, S$1>) => void; | ||
| /** | ||
| * Add an event to be processed | ||
| * Arrow function to maintain correct 'this' binding in React | ||
| */ | ||
| add: (event: E$1) => void; | ||
| /** | ||
| * Process an event (synchronously) | ||
| */ | ||
| private processEvent; | ||
| /** | ||
| * Handle a single event (synchronously) | ||
| */ | ||
| private handleEvent; | ||
| /** | ||
| * Hook for handling event processing errors | ||
| */ | ||
| protected onEventError(event: E$1, error: Error): void; | ||
| } | ||
| /** | ||
| * Example: Counter Events | ||
| */ | ||
| declare class IncrementEvent implements BaseEvent { | ||
| readonly amount: number; | ||
| readonly type = "increment"; | ||
| readonly timestamp: number; | ||
| constructor(amount?: number); | ||
| } | ||
| declare class DecrementEvent implements BaseEvent { | ||
| readonly amount: number; | ||
| readonly type = "decrement"; | ||
| readonly timestamp: number; | ||
| constructor(amount?: number); | ||
| } | ||
| declare class ResetEvent implements BaseEvent { | ||
| readonly type = "reset"; | ||
| readonly timestamp: number; | ||
| } | ||
| /** | ||
| * Example: Counter Vertex | ||
| * Demonstrates proper typing and event handling | ||
| */ | ||
| declare class CounterVertex extends Vertex<number> { | ||
| constructor(); | ||
| increment: (amount?: number) => void; | ||
| decrement: (amount?: number) => void; | ||
| reset: () => void; | ||
| } | ||
| /** | ||
| * Auth State and Events for testing async handlers | ||
| */ | ||
| interface AuthState { | ||
| isAuthenticated: boolean; | ||
| isLoading: boolean; | ||
| user: { | ||
| id: string; | ||
| name: string; | ||
| email: string; | ||
| } | null; | ||
| error: string | null; | ||
| } | ||
| declare class LoginEvent implements BaseEvent { | ||
| readonly email: string; | ||
| readonly password: string; | ||
| readonly type = "login"; | ||
| readonly timestamp: number; | ||
| constructor(email: string, password: string); | ||
| } | ||
| declare class LogoutEvent implements BaseEvent { | ||
| readonly type = "logout"; | ||
| readonly timestamp: number; | ||
| } | ||
| declare class AuthVertex extends Vertex<AuthState> { | ||
| constructor(); | ||
| login: (email: string, password: string) => void; | ||
| logout: () => void; | ||
| } | ||
| //#endregion | ||
| //#region src/core/StateContainerRegistry.d.ts | ||
| /** | ||
| * Lifecycle events that can be observed | ||
| */ | ||
| type LifecycleEvent = 'created' | 'stateChanged' | 'eventAdded' | 'disposed'; | ||
| /** | ||
| * Listener function types for each lifecycle event | ||
| */ | ||
| type LifecycleListener<E$1 extends LifecycleEvent> = E$1 extends 'created' ? (container: StateContainer<any>) => void : E$1 extends 'stateChanged' ? (container: StateContainer<any>, previousState: any, currentState: any) => void : E$1 extends 'eventAdded' ? (container: Vertex<any, any>, event: any) => void : E$1 extends 'disposed' ? (container: StateContainer<any>) => void : never; | ||
| /** | ||
| * Registry for managing StateContainer instances | ||
| */ | ||
| declare class StateContainerRegistry { | ||
| private readonly instances; | ||
| private readonly types; | ||
| private readonly listeners; | ||
| /** | ||
| * Register a type with isolation mode | ||
| */ | ||
| register<T extends StateContainer<any>>(constructor: new (...args: any[]) => T, isolated?: boolean): void; | ||
| /** | ||
| * Get or create a StateContainer instance | ||
| * For isolated: always creates new | ||
| * For shared: singleton per key | ||
| */ | ||
| getOrCreate<T extends StateContainer<any>>(constructor: new (...args: any[]) => T, key?: string, ...args: any[]): T; | ||
| /** | ||
| * Release a reference to an instance | ||
| * Disposes when ref count reaches zero (unless static keepAlive is true) | ||
| */ | ||
| release<T extends StateContainer<any>>(constructor: new (...args: any[]) => T, key?: string, forceDispose?: boolean): void; | ||
| /** | ||
| * Get all instances of a type (shared only, isolated aren't tracked) | ||
| */ | ||
| getAll<T extends StateContainer<any>>(constructor: new (...args: any[]) => T): T[]; | ||
| /** | ||
| * Clear all instances of a type | ||
| */ | ||
| clear<T extends StateContainer<any>>(constructor: new (...args: any[]) => T): void; | ||
| /** | ||
| * Clear all instances from all types (for testing) | ||
| */ | ||
| clearAll(): void; | ||
| /** | ||
| * Get registry statistics (for debugging) | ||
| */ | ||
| getStats(): { | ||
| registeredTypes: number; | ||
| totalInstances: number; | ||
| typeBreakdown: Record<string, number>; | ||
| }; | ||
| /** | ||
| * Get reference count for an instance | ||
| */ | ||
| getRefCount<T extends StateContainer<any>>(constructor: new (...args: any[]) => T, key?: string): number; | ||
| /** | ||
| * Check if an instance exists | ||
| */ | ||
| hasInstance<T extends StateContainer<any>>(constructor: new (...args: any[]) => T, key?: string): boolean; | ||
| /** | ||
| * Subscribe to lifecycle events | ||
| * @param event - The lifecycle event to listen for | ||
| * @param listener - The listener function to call when the event occurs | ||
| * @returns Unsubscribe function | ||
| */ | ||
| on<E extends LifecycleEvent>(event: E, listener: LifecycleListener<E>): () => void; | ||
| /** | ||
| * Emit lifecycle event to all listeners | ||
| * @internal - Called by StateContainer/Vertex lifecycle methods | ||
| */ | ||
| emit(event: LifecycleEvent, ...args: any[]): void; | ||
| } | ||
| /** | ||
| * Global default registry instance | ||
| */ | ||
| declare const globalRegistry: StateContainerRegistry; | ||
| //#endregion | ||
| //#region src/core/StateContainer.d.ts | ||
| /** | ||
| * Configuration options for StateContainer | ||
| */ | ||
| interface StateContainerConfig { | ||
| /** Container name for debugging */ | ||
| name?: string; | ||
| /** Enable debug logging */ | ||
| debug?: boolean; | ||
| /** Custom instance identifier */ | ||
| instanceId?: string; | ||
| } | ||
| /** | ||
| * Listener function for state changes | ||
| */ | ||
| type StateListener<S$1> = (state: S$1) => void; | ||
| /** | ||
| * Base abstract class for all state containers | ||
| */ | ||
| declare abstract class StateContainer<S$1> { | ||
| protected static _registry: StateContainerRegistry; | ||
| /** | ||
| * Set a custom registry (mainly for testing) | ||
| */ | ||
| static setRegistry(registry: StateContainerRegistry): void; | ||
| /** | ||
| * Register a type as isolated or shared | ||
| */ | ||
| static register<T extends StateContainer<any>>(this: new (...args: any[]) => T, isolated?: boolean): void; | ||
| /** | ||
| * Get or create an instance | ||
| * @param key - Optional instance key for shared instances | ||
| * @param args - Constructor arguments | ||
| */ | ||
| static getOrCreate<T extends StateContainer<any>>(this: new (...args: any[]) => T, key?: string, ...args: any[]): T; | ||
| /** | ||
| * Release a reference to an instance | ||
| * @param key - Optional instance key | ||
| * @param forceDispose - Force dispose regardless of ref count or keepAlive | ||
| */ | ||
| static release<T extends StateContainer<any>>(this: new (...args: any[]) => T, key?: string, forceDispose?: boolean): void; | ||
| /** | ||
| * Get all instances of this type | ||
| */ | ||
| static getAll<T extends StateContainer<any>>(this: new (...args: any[]) => T): T[]; | ||
| /** | ||
| * Clear all instances of this type | ||
| */ | ||
| static clear<T extends StateContainer<any>>(this: new (...args: any[]) => T): void; | ||
| /** | ||
| * Clear all instances from all types (for testing) | ||
| */ | ||
| static clearAllInstances(): void; | ||
| /** | ||
| * Get registry statistics (for debugging) | ||
| */ | ||
| static getStats(): { | ||
| registeredTypes: number; | ||
| totalInstances: number; | ||
| typeBreakdown: Record<string, number>; | ||
| }; | ||
| /** | ||
| * Get reference count for an instance | ||
| * @param key - Optional instance key | ||
| */ | ||
| static getRefCount<T extends StateContainer<any>>(this: new (...args: any[]) => T, key?: string): number; | ||
| /** | ||
| * Check if an instance exists | ||
| * @param key - Optional instance key | ||
| */ | ||
| static hasInstance<T extends StateContainer<any>>(this: new (...args: any[]) => T, key?: string): boolean; | ||
| private _state; | ||
| private readonly listeners; | ||
| private _disposed; | ||
| private readonly config; | ||
| readonly name: string; | ||
| readonly debug: boolean; | ||
| readonly instanceId: string; | ||
| /** | ||
| * Create a new StateContainer | ||
| */ | ||
| constructor(initialState: S$1, config?: StateContainerConfig); | ||
| /** | ||
| * Get the current state | ||
| */ | ||
| get state(): S$1; | ||
| /** | ||
| * Check if disposed | ||
| */ | ||
| get isDisposed(): boolean; | ||
| /** | ||
| * Subscribe to state changes | ||
| * @returns Unsubscribe function | ||
| */ | ||
| subscribe(listener: StateListener<S$1>): () => void; | ||
| /** | ||
| * Dispose the container | ||
| */ | ||
| dispose(): void; | ||
| /** | ||
| * Emit a new state (with change detection) | ||
| */ | ||
| protected emit(newState: S$1): void; | ||
| /** | ||
| * Update state using a function | ||
| */ | ||
| protected update(updater: (current: S$1) => S$1): void; | ||
| /** | ||
| * Optional disposal hook for subclasses | ||
| */ | ||
| protected onDispose?(): void; | ||
| /** | ||
| * Optional state change hook for subclasses | ||
| */ | ||
| protected onStateChange?(newState: S$1, previousState: S$1): void; | ||
| } | ||
| //#endregion | ||
| //#region src/core/Cubit.d.ts | ||
| /** | ||
| * Cubit is a simple state container that allows direct state emission | ||
| * | ||
| * Unlike StateContainer (where emit is protected), Cubit exposes emit and update | ||
| * as public methods to allow direct state management. | ||
| */ | ||
| declare abstract class Cubit<S$1> extends StateContainer<S$1> { | ||
| /** | ||
| * Create a new Cubit | ||
| * @param initialState Initial state value | ||
| * @param config Configuration options | ||
| */ | ||
| constructor(initialState: S$1, config?: StateContainerConfig); | ||
| /** | ||
| * Emit a new state (public override of protected parent method) | ||
| */ | ||
| emit(newState: S$1): void; | ||
| /** | ||
| * Update state using a function (public override of protected parent method) | ||
| */ | ||
| update(updater: (current: S$1) => S$1): void; | ||
| /** | ||
| * Patch state with partial updates (shallow merge) | ||
| * Only available when state is an object type | ||
| * Arrow function to maintain correct 'this' binding in React | ||
| * | ||
| * @example | ||
| * ```typescript | ||
| * // Update single field | ||
| * this.patch({ count: 5 }); | ||
| * | ||
| * // Update multiple fields | ||
| * this.patch({ count: 5, name: 'Updated' }); | ||
| * ``` | ||
| */ | ||
| patch: S$1 extends object ? (partial: Partial<S$1>) => void : never; | ||
| } | ||
| /** | ||
| * Example: Counter Cubit | ||
| */ | ||
| declare class CounterCubit extends Cubit<number> { | ||
| constructor(); | ||
| increment: () => void; | ||
| decrement: () => void; | ||
| reset: () => void; | ||
| addAmount: (amount: number) => void; | ||
| } | ||
| /** | ||
| * Example: Complex State Cubit | ||
| */ | ||
| interface TodoState { | ||
| todos: Array<{ | ||
| id: string; | ||
| text: string; | ||
| done: boolean; | ||
| }>; | ||
| filter: 'all' | 'active' | 'completed'; | ||
| isLoading: boolean; | ||
| } | ||
| declare class TodoCubit extends Cubit<TodoState> { | ||
| static keepAlive: boolean; | ||
| private nextId; | ||
| constructor(); | ||
| addTodo: (text: string) => void; | ||
| toggleTodo: (id: string) => void; | ||
| removeTodo: (id: string) => void; | ||
| setFilter: (filter: TodoState["filter"]) => void; | ||
| setLoading: (isLoading: boolean) => void; | ||
| get visibleTodos(): { | ||
| id: string; | ||
| text: string; | ||
| done: boolean; | ||
| }[]; | ||
| get activeTodoCount(): number; | ||
| } | ||
| //#endregion | ||
| //#region src/types/branded.d.ts | ||
| /** | ||
| * Branded types for type-safe IDs | ||
| * These types ensure that IDs can't be accidentally mixed up | ||
| */ | ||
| /** | ||
| * Helper type for cases where any object type is acceptable | ||
| * Used sparingly only where type cannot be more specific | ||
| * eslint-disable-next-line @typescript-eslint/no-explicit-any | ||
| */ | ||
| type AnyObject = any; | ||
| /** Unique symbol for branding */ | ||
| declare const brand: unique symbol; | ||
| /** Type branding utility */ | ||
| type Brand<T$1, B> = T$1 & { | ||
| [brand]: B; | ||
| }; | ||
| /** Generic branded ID type */ | ||
| type BrandedId<B> = Brand<string, B>; | ||
| /** Branded instance ID type */ | ||
| type InstanceId = Brand<string, 'InstanceId'>; | ||
| //#endregion | ||
| //#region src/tracking/proxy-tracker.d.ts | ||
| /** | ||
| * Functional proxy tracker for automatic dependency tracking | ||
| * | ||
| * This module provides a functional approach to proxy-based dependency tracking. | ||
| * Unlike the class-based ProxyTracker, this uses a state object pattern that's | ||
| * easier to integrate with functional programming patterns and framework hooks. | ||
| */ | ||
| /** | ||
| * Check if a value can be proxied | ||
| * | ||
| * Returns true for plain objects and arrays only. | ||
| * Excludes built-in objects like Date, Map, Set, etc. | ||
| */ | ||
| declare function isProxyable(value: unknown): value is object; | ||
| /** | ||
| * State container for proxy tracking | ||
| */ | ||
| interface ProxyTrackerState<T$1> { | ||
| /** Set of all tracked property paths */ | ||
| trackedPaths: Set<string>; | ||
| /** Whether tracking is currently active */ | ||
| isTracking: boolean; | ||
| /** Cache of created proxies to avoid duplicates */ | ||
| proxyCache: WeakMap<object, any>; | ||
| /** Cache of bound functions to maintain referential equality */ | ||
| boundFunctionsCache: WeakMap<Function, Function> | null; | ||
| /** Last state object that was proxied (for cache invalidation) */ | ||
| lastProxiedState: T$1 | null; | ||
| /** Last proxy created (for cache reuse) */ | ||
| lastProxy: T$1 | null; | ||
| /** Maximum depth for nested proxy creation */ | ||
| maxDepth: number; | ||
| } | ||
| /** | ||
| * Create a new proxy tracker state | ||
| * | ||
| * @example | ||
| * const state = createProxyTrackerState<MyState>(); | ||
| * startProxyTracking(state); | ||
| * const proxy = createProxyForTarget(state, myObject); | ||
| * // ... use proxy ... | ||
| * const paths = stopProxyTracking(state); | ||
| */ | ||
| declare function createProxyTrackerState<T$1>(): ProxyTrackerState<T$1>; | ||
| /** | ||
| * Start tracking property accesses | ||
| * | ||
| * Clears previous tracked paths and enables tracking mode. | ||
| */ | ||
| declare function startProxyTracking<T$1>(state: ProxyTrackerState<T$1>): void; | ||
| /** | ||
| * Stop tracking and return the tracked paths | ||
| * | ||
| * Returns a new Set containing all tracked paths. | ||
| */ | ||
| declare function stopProxyTracking<T$1>(state: ProxyTrackerState<T$1>): Set<string>; | ||
| /** | ||
| * Create a proxy for an array with property access tracking | ||
| * | ||
| * Tracks: | ||
| * - Array element access (arr[0]) | ||
| * - Length access (arr.length) | ||
| * - Array method calls (arr.map, arr.filter, etc.) | ||
| */ | ||
| declare function createArrayProxy<T$1, U>(state: ProxyTrackerState<T$1>, target: U[], path: string, depth?: number): U[]; | ||
| /** | ||
| * Create a proxy for an object with property access tracking | ||
| * | ||
| * This is the core proxy creation function that recursively creates proxies | ||
| * for nested objects and arrays. | ||
| * | ||
| * Tracks: | ||
| * - Property access (obj.prop) | ||
| * - Nested property access (obj.nested.prop) | ||
| * - 'in' operator usage ('prop' in obj) | ||
| * - Object.keys, Object.entries, etc. | ||
| */ | ||
| declare function createProxyInternal<T$1>(state: ProxyTrackerState<T$1>, target: T$1, path?: string, depth?: number): T$1; | ||
| /** | ||
| * Create a proxy for a target with caching | ||
| * | ||
| * If the target hasn't changed since the last call, returns the cached proxy. | ||
| * Otherwise, creates a new proxy and caches it. | ||
| * | ||
| * This is the main entry point for creating tracked proxies. | ||
| */ | ||
| declare function createProxyForTarget<T$1>(state: ProxyTrackerState<T$1>, target: T$1): T$1; | ||
| //#endregion | ||
| //#region src/tracking/dependency-tracker.d.ts | ||
| /** | ||
| * Information about a tracked path | ||
| */ | ||
| interface PathInfo { | ||
| /** Parsed path segments */ | ||
| segments: string[]; | ||
| /** Last known value at this path */ | ||
| value: any; | ||
| } | ||
| /** | ||
| * State for dependency tracking | ||
| */ | ||
| interface TrackerState<T$1 extends AnyObject> { | ||
| /** Internal proxy tracker state */ | ||
| proxyTrackerState: ProxyTrackerState<T$1>; | ||
| /** Paths tracked in the previous render */ | ||
| previousRenderPaths: Set<string>; | ||
| /** Paths tracked in the current render */ | ||
| currentRenderPaths: Set<string>; | ||
| /** Cache of parsed paths and their values */ | ||
| pathCache: Map<string, PathInfo>; | ||
| /** Last state object that was checked for changes */ | ||
| lastCheckedState: T$1 | null; | ||
| /** Values from the last change check (optimization) */ | ||
| lastCheckedValues: Map<string, any>; | ||
| /** Counter for periodic cleanup of unused paths */ | ||
| cleanupCounter: number; | ||
| } | ||
| /** | ||
| * Create a new tracker state | ||
| */ | ||
| declare function createTrackerState<T$1 extends AnyObject>(): TrackerState<T$1>; | ||
| /** | ||
| * Start tracking property accesses | ||
| */ | ||
| declare function startTracking<T$1 extends AnyObject>(tracker: TrackerState<T$1>): void; | ||
| /** | ||
| * Create a proxy for the given state | ||
| */ | ||
| declare function createProxy<T$1 extends AnyObject>(tracker: TrackerState<T$1>, state: T$1): T$1; | ||
| /** | ||
| * Capture the paths that were tracked during a render | ||
| * | ||
| * This should be called after each render to record which paths were accessed. | ||
| * It also performs periodic cleanup of unused paths to prevent memory leaks. | ||
| */ | ||
| declare function captureTrackedPaths<T$1 extends AnyObject>(tracker: TrackerState<T$1>, state: T$1): void; | ||
| /** | ||
| * Check if any tracked paths have changed | ||
| * | ||
| * This is called when state changes to determine if a re-render is needed. | ||
| * Returns true if any tracked path has a different value than before. | ||
| */ | ||
| declare function hasChanges<T$1 extends AnyObject>(tracker: TrackerState<T$1>, state: T$1): boolean; | ||
| /** | ||
| * Check if tracker has any tracked data | ||
| * | ||
| * Returns true if there are any tracked paths or cached paths. | ||
| */ | ||
| declare function hasTrackedData<T$1 extends AnyObject>(tracker: TrackerState<T$1>): boolean; | ||
| //#endregion | ||
| //#region src/tracking/path-utils.d.ts | ||
| /** | ||
| * Path utilities for dependency tracking | ||
| * | ||
| * Provides utilities for parsing property paths and extracting values | ||
| * from nested objects using path strings. | ||
| */ | ||
| /** | ||
| * Parse a property path string into an array of segments | ||
| * | ||
| * Handles both dot notation (a.b.c) and bracket notation (a[0].b) | ||
| * | ||
| * @example | ||
| * parsePath('user.name') // ['user', 'name'] | ||
| * parsePath('items[0].name') // ['items', '0', 'name'] | ||
| * parsePath('data.users[2].address.city') // ['data', 'users', '2', 'address', 'city'] | ||
| */ | ||
| declare function parsePath(path: string): string[]; | ||
| /** | ||
| * Get a value from an object using a path of segments | ||
| * | ||
| * @example | ||
| * const obj = { user: { name: 'Alice', age: 30 } } | ||
| * getValueAtPath(obj, ['user', 'name']) // 'Alice' | ||
| * getValueAtPath(obj, ['user', 'age']) // 30 | ||
| * getValueAtPath(obj, ['user', 'missing']) // undefined | ||
| */ | ||
| declare function getValueAtPath(obj: any, segments: string[]): any; | ||
| /** | ||
| * Shallow equality comparison for arrays | ||
| * | ||
| * Compares two arrays element-by-element using Object.is | ||
| * | ||
| * @example | ||
| * shallowEqual([1, 2, 3], [1, 2, 3]) // true | ||
| * shallowEqual([1, 2, 3], [1, 2, 4]) // false | ||
| * shallowEqual([1, 2], [1, 2, 3]) // false | ||
| */ | ||
| declare function shallowEqual(arr1: unknown[], arr2: unknown[]): boolean; | ||
| //#endregion | ||
| //#region src/proxy/ProxyTracker.d.ts | ||
| /** | ||
| * ProxyTracker - Automatic dependency tracking through Proxies | ||
| * | ||
| * Tracks property access on state objects to automatically determine | ||
| * which parts of the state a component depends on. | ||
| */ | ||
| /** | ||
| * Tracks property access on state objects | ||
| */ | ||
| declare class ProxyTracker<T$1> { | ||
| private trackedPaths; | ||
| private isTracking; | ||
| private proxyCache; | ||
| private maxDepth; | ||
| /** | ||
| * Create a proxy that tracks property access | ||
| */ | ||
| createProxy(target: T$1, path?: string, depth?: number): T$1; | ||
| /** | ||
| * Create a proxy for arrays with special handling | ||
| */ | ||
| private createArrayProxy; | ||
| /** | ||
| * Start tracking property access | ||
| */ | ||
| startTracking(): void; | ||
| /** | ||
| * Stop tracking and return tracked paths | ||
| */ | ||
| stopTracking(): Set<string>; | ||
| /** | ||
| * Get currently tracked paths | ||
| */ | ||
| getTrackedPaths(): ReadonlySet<string>; | ||
| /** | ||
| * Check if currently tracking | ||
| */ | ||
| isCurrentlyTracking(): boolean; | ||
| /** | ||
| * Clear proxy cache (useful for memory management) | ||
| */ | ||
| clearCache(): void; | ||
| /** | ||
| * Set maximum tracking depth | ||
| */ | ||
| setMaxDepth(depth: number): void; | ||
| /** | ||
| * Add a path manually (useful for forcing dependencies) | ||
| */ | ||
| addPath(path: string): void; | ||
| /** | ||
| * Remove a path manually | ||
| */ | ||
| removePath(path: string): void; | ||
| /** | ||
| * Clear all tracked paths | ||
| */ | ||
| clearPaths(): void; | ||
| } | ||
| /** | ||
| * Global proxy tracker instance for convenience | ||
| */ | ||
| declare const globalProxyTracker: ProxyTracker<unknown>; | ||
| /** | ||
| * Utility function to track property access in a callback | ||
| */ | ||
| declare function trackAccess<T$1, R>(state: T$1, callback: (proxiedState: T$1) => R): { | ||
| result: R; | ||
| trackedPaths: Set<string>; | ||
| }; | ||
| //#endregion | ||
| //#region src/types/utilities.d.ts | ||
| /** | ||
| * Extract state type from StateContainer | ||
| * | ||
| * @example | ||
| * ```ts | ||
| * class CounterBloc extends Cubit<number> { ... } | ||
| * type State = ExtractState<CounterBloc>; // number | ||
| * ``` | ||
| */ | ||
| type ExtractState<T$1> = T$1 extends StateContainer<infer S> ? S : never; | ||
| /** | ||
| * Extract constructor parameter types from a Bloc class | ||
| * | ||
| * @example | ||
| * ```ts | ||
| * class UserBloc extends Cubit<UserState> { | ||
| * constructor(userId: string, config: Config) { ... } | ||
| * } | ||
| * type Args = ExtractConstructorArgs<typeof UserBloc>; // [string, Config] | ||
| * ``` | ||
| */ | ||
| type ExtractConstructorArgs<T$1> = T$1 extends (new (...args: infer P) => AnyObject) ? P : never[]; | ||
| /** | ||
| * Bloc constructor type - represents a class constructor for StateContainer subclasses | ||
| * Includes static methods from StateContainer for instance management | ||
| * | ||
| * Note: Uses `any` for state type to support variance - the actual Bloc instance | ||
| * will have the correct specific types inferred at usage sites. | ||
| * | ||
| * @example | ||
| * ```ts | ||
| * function createBloc<TBloc extends StateContainer<any>>( | ||
| * BlocClass: BlocConstructor<TBloc> | ||
| * ): TBloc { | ||
| * return BlocClass.getOrCreate(); | ||
| * } | ||
| * ``` | ||
| */ | ||
| type BlocConstructor<TBloc extends StateContainer<any>> = (new (...args: any[]) => TBloc) & { | ||
| getOrCreate?(instanceKey?: string, ...args: any[]): TBloc; | ||
| release?(instanceKey?: string): void; | ||
| isolated?: boolean; | ||
| keepAlive?: boolean; | ||
| }; | ||
| //#endregion | ||
| //#region src/logging/Logger.d.ts | ||
| declare enum LogLevel { | ||
| ERROR = 0, | ||
| WARN = 1, | ||
| INFO = 2, | ||
| DEBUG = 3, | ||
| } | ||
| interface LogEntry { | ||
| level: string; | ||
| context: string; | ||
| message: string; | ||
| data?: any; | ||
| timestamp: number; | ||
| } | ||
| interface LogConfig { | ||
| enabled: boolean; | ||
| level: LogLevel; | ||
| output: (entry: LogEntry) => void; | ||
| } | ||
| /** | ||
| * Creates a logger instance with given configuration | ||
| * | ||
| * @param config - Logger configuration | ||
| * @returns Logger instance with debug, info, warn, error, and configure methods | ||
| * | ||
| * @example | ||
| * ```ts | ||
| * const logger = createLogger({ | ||
| * enabled: true, | ||
| * level: LogLevel.DEBUG, | ||
| * output: (entry) => console.log(JSON.stringify(entry)) | ||
| * }); | ||
| * logger.debug('MyComponent', 'Rendering', { props: { foo: 'bar' } }); | ||
| * ``` | ||
| */ | ||
| declare function createLogger(config: LogConfig): { | ||
| debug: (context: string, message: string, data?: any) => void; | ||
| info: (context: string, message: string, data?: any) => void; | ||
| warn: (context: string, message: string, data?: any) => void; | ||
| error: (context: string, message: string, data?: any) => void; | ||
| configure: (opts: Partial<LogConfig>) => void; | ||
| }; | ||
| declare const debug: (context: string, message: string, data?: any) => void; | ||
| declare const info: (context: string, message: string, data?: any) => void; | ||
| declare const warn: (context: string, message: string, data?: any) => void; | ||
| declare const error: (context: string, message: string, data?: any) => void; | ||
| /** | ||
| * Configuration function that recreates the default logger | ||
| * | ||
| * @param opts - Partial logger configuration | ||
| * | ||
| * @example | ||
| * ```ts | ||
| * configureLogger({ enabled: true, level: LogLevel.DEBUG }); | ||
| * ``` | ||
| */ | ||
| declare function configureLogger(opts: Partial<LogConfig>): void; | ||
| //#endregion | ||
| //#region src/constants.d.ts | ||
| /** | ||
| * Default configuration constants for BlaC | ||
| * | ||
| * Centralized location for all magic numbers and default values. | ||
| */ | ||
| /** | ||
| * Default configuration constants for BlaC | ||
| */ | ||
| declare const BLAC_DEFAULTS: { | ||
| /** | ||
| * Default cleanup interval for subscriptions (30 seconds) | ||
| */ | ||
| readonly CLEANUP_INTERVAL_MS: 30000; | ||
| /** | ||
| * Cleanup interval for weak reference stage (10 seconds) | ||
| */ | ||
| readonly WEAKREF_CLEANUP_INTERVAL_MS: 10000; | ||
| /** | ||
| * Default maximum subscriptions per container | ||
| */ | ||
| readonly MAX_SUBSCRIPTIONS: 1000; | ||
| /** | ||
| * Maximum subscriptions for high-performance mode | ||
| */ | ||
| readonly MAX_SUBSCRIPTIONS_HIGH_PERF: 10000; | ||
| /** | ||
| * Default timeout for pipeline execution (5 seconds) | ||
| */ | ||
| readonly PIPELINE_TIMEOUT_MS: 5000; | ||
| /** | ||
| * Cleanup interval for high-performance mode (5 seconds) | ||
| */ | ||
| readonly CLEANUP_INTERVAL_HIGH_PERF_MS: 5000; | ||
| /** | ||
| * Maximum number of stages in a pipeline | ||
| */ | ||
| readonly MAX_PIPELINE_STAGES: 30; | ||
| }; | ||
| //#endregion | ||
| //#region src/utils/idGenerator.d.ts | ||
| /** | ||
| * Centralized ID Generation | ||
| * | ||
| * Provides consistent, collision-resistant ID generation for all BlaC subsystems. | ||
| * Uses timestamp + counter + random suffix for uniqueness. | ||
| */ | ||
| /** | ||
| * Creates an ID generator with isolated counter state | ||
| * | ||
| * @param prefix - Prefix for generated IDs | ||
| * @returns Object with next(), nextSimple(), and reset() methods | ||
| * | ||
| * @example | ||
| * ```ts | ||
| * const generator = createIdGenerator('sub'); | ||
| * const id1 = generator.next(); // "sub_1698765432100_1_a3k9d7f2q" | ||
| * const id2 = generator.next(); // "sub_1698765432101_2_b4n8e9g3r" | ||
| * ``` | ||
| */ | ||
| declare function createIdGenerator(prefix: string): { | ||
| next: () => string; | ||
| nextSimple: () => string; | ||
| reset: () => void; | ||
| }; | ||
| /** | ||
| * Generate ID with timestamp, counter, and random suffix (tree-shakeable) | ||
| * | ||
| * Format: `${prefix}_${timestamp}_${counter}_${random}` | ||
| * | ||
| * @param prefix - Prefix for the ID (e.g., 'sub', 'consumer', 'stage') | ||
| * @returns Branded ID string | ||
| * | ||
| * @example | ||
| * ```ts | ||
| * const id = generateId('sub'); | ||
| * // Returns: "sub_1698765432100_1_a3k9d7f2q" | ||
| * ``` | ||
| */ | ||
| declare function generateId(prefix: string): string; | ||
| /** | ||
| * Generate simple ID with timestamp and random (no counter tracking) | ||
| * | ||
| * Format: `${prefix}_${timestamp}_${random}` | ||
| * | ||
| * @param prefix - Prefix for the ID | ||
| * @returns Branded ID string | ||
| * | ||
| * @example | ||
| * ```ts | ||
| * const id = generateSimpleId('CounterBloc'); | ||
| * // Returns: "CounterBloc_1698765432100_a3k9d7f2q" | ||
| * ``` | ||
| */ | ||
| declare function generateSimpleId(prefix: string): string; | ||
| /** | ||
| * Reset all counters for testing purposes | ||
| * @internal | ||
| */ | ||
| declare function __resetIdCounters(): void; | ||
| //#endregion | ||
| export { type AnyObject, AuthState, AuthVertex, BLAC_DEFAULTS, type BaseEvent, BlocConstructor, type Brand, type BrandedId, CounterCubit, CounterVertex, Cubit, DecrementEvent, EventConstructor, EventHandler, ExtractConstructorArgs, ExtractState, IncrementEvent, type InstanceId, type LifecycleEvent, type LifecycleListener, type LogConfig, type LogEntry, LogLevel, LoginEvent, LogoutEvent, PathInfo, ProxyTracker, ProxyTrackerState, ResetEvent, StateContainer, StateContainerConfig, StateContainerRegistry, TodoCubit, TodoState, TrackerState, Vertex, __resetIdCounters, captureTrackedPaths, configureLogger, createArrayProxy, createIdGenerator, createLogger, createProxy, createProxyForTarget, createProxyInternal, createProxyTrackerState, createTrackerState, debug, error, generateId, generateSimpleId, getValueAtPath, globalProxyTracker, globalRegistry, hasChanges, hasTrackedData, info, isProxyable, parsePath, shallowEqual, startProxyTracking, startTracking, stopProxyTracking, trackAccess, warn }; | ||
| export * from './core/StateContainer'; | ||
| export * from './core/StateContainerRegistry'; | ||
| export * from './core/Cubit'; | ||
| export * from './core/Vertex'; | ||
| export { globalRegistry, getPluginManager, } from './core/StateContainerRegistry'; | ||
| export type { LifecycleEvent, LifecycleListener, } from './core/StateContainerRegistry'; | ||
| export type { BlacPlugin, BlacPluginWithInit, PluginContext, PluginConfig, InstanceMetadata, } from './plugin/BlacPlugin'; | ||
| export { PluginManager, createPluginManager } from './plugin/PluginManager'; | ||
| export { hasInitHook } from './plugin/BlacPlugin'; | ||
| export * from './tracking'; | ||
| export * from './proxy/ProxyTracker'; | ||
| export * from './adapter'; | ||
| export type { Brand, BrandedId, InstanceId } from './types/branded'; | ||
| export type { BaseEvent } from './types/events'; | ||
| export * from './types/utilities'; | ||
| export { createLogger, configureLogger, debug, info, warn, error, LogLevel, type LogConfig, type LogEntry, } from './logging/Logger'; | ||
| export { BLAC_DEFAULTS, BLAC_STATIC_PROPS, BLAC_ID_PATTERNS, BLAC_ERROR_PREFIX, } from './constants'; | ||
| export { generateId, generateSimpleId, createIdGenerator, __resetIdCounters, generateIsolatedKey, isIsolatedKey, } from './utils/idGenerator'; | ||
| export { getStaticProp, isIsolatedClass, isKeepAliveClass, isExcludedFromDevTools, } from './utils/static-props'; | ||
| //# sourceMappingURL=index.d.ts.map |
+17
-4
| { | ||
| "name": "@blac/core", | ||
| "version": "2.0.0-rc.6", | ||
| "version": "2.0.0-rc.8", | ||
| "license": "MIT", | ||
| "author": "Brendan Mullins <jsnanigans@gmail.com>", | ||
| "main": "./dist/index.js", | ||
| "repository": { | ||
| "type": "git", | ||
| "url": "git+https://github.com/jsnanigans/blac.git", | ||
| "directory": "packages/blac" | ||
| }, | ||
| "homepage": "https://github.com/jsnanigans/blac#readme", | ||
| "bugs": { | ||
| "url": "https://github.com/jsnanigans/blac/issues" | ||
| }, | ||
| "main": "./dist/index.cjs", | ||
| "module": "./dist/index.js", | ||
@@ -22,3 +31,7 @@ "types": "./dist/index.d.ts", | ||
| "files": [ | ||
| "dist", | ||
| "dist/**/*.js", | ||
| "dist/**/*.cjs", | ||
| "dist/**/*.d.ts", | ||
| "dist/**/*.d.cts", | ||
| "dist/**/*.map", | ||
| "README.md", | ||
@@ -51,3 +64,3 @@ "LICENSE" | ||
| "dev": "tsdown --watch", | ||
| "build": "tsdown", | ||
| "build": "tsdown && tsc -p tsconfig.build.json && cp dist/index.d.ts dist/index.d.cts", | ||
| "clean": "rm -rf dist", | ||
@@ -54,0 +67,0 @@ "format": "prettier --write \".\"", |
Sorry, the diff of this file is too big to display
Sorry, the diff of this file is too big to display
Sorry, the diff of this file is too big to display
Sorry, the diff of this file is too big to display
Environment variable access
Supply chain riskPackage accesses environment variables, which may be a sign of credential stuffing or data theft.
Found 2 instances in 1 package
Long strings
Supply chain riskContains long string literals, which may be a sign of obfuscated or packed code.
Found 1 instance in 1 package
Long strings
Supply chain riskContains long string literals, which may be a sign of obfuscated or packed code.
Found 1 instance in 1 package
No bug tracker
MaintenancePackage does not have a linked bug tracker in package.json.
Found 1 instance in 1 package
No repository
Supply chain riskPackage does not have a linked source code repository. Without this field, a package will have no reference to the location of the source code use to generate the package.
Found 1 instance in 1 package
No website
QualityPackage does not have a website.
Found 1 instance in 1 package
499162
75.82%61
662.5%5878
63.41%0
-100%1
-50%18
12.5%