import { ServiceIdentifier, LazyServiceIdentifier, Container, Newable } from 'inversify'; export { bindingTypeValues as BindingType, Container, ContainerModule, inject as Inject, injectable as Injectable, LazyServiceIdentifier, multiInject as MultiInject, named as Named, optional as Optional, postConstruct as PostConstruct, preDestroy as PreDestroy, bindingScopeValues as ScopeBindingType, ServiceIdentifier, tagged as Tagged } from 'inversify'; import { I as IInjectableDescriptor, T as TAnyObject, M as MaybePromise, O as Optional } from './lib.js'; import * as react from 'react'; import { ReactNode, ReactElement, Dispatch, SetStateAction, PropsWithChildren } from 'react'; declare function forwardRef(forward: () => ServiceIdentifier): LazyServiceIdentifier; interface IBindServiceOptions { isWithIgnoreLifecycle?: boolean; } /** * Registers a service class in the container with activation/deactivation logic. * Ensures container references, event subscriptions, command and query handlers are managed correctly. * * @param container - target Inversify container * @param entry - service constructor * @param options - options object to control binding flow */ declare function bindService(container: Container, entry: Newable, options?: IBindServiceOptions): void; /** * Options for {@link bindEntry}. */ interface IBindEntryOptions extends IBindServiceOptions { isWithIgnoreLifecycle?: boolean; } /** * Binds a single service entry to the container, dispatching to the * correct binding strategy based on the descriptor's `type` field. * * Supports: * - Service classes (function entries) - bound as singleton * - Constant values - bound via `bindConstant` * - Dynamic values - bound via `toDynamicValue` with optional scope * - Instance bindings - bound as generic singleton service * * @param container - target IOC container to bind into * @param entry - entry descriptor to bind * @param options - optional binding configuration * @returns void */ declare function bindEntry(container: Container, entry: Newable | IInjectableDescriptor, options?: IBindEntryOptions): void; /** * Binds a constant value to a token in the container. * * @param container - target Inversify container * @param entry - entry descriptor to bind */ declare function bindConstant(container: Container, entry: IInjectableDescriptor): void; interface ICreateIocContainerOptions { /** * Parent container for inheritance. */ readonly parent?: Container; /** * Optional default seed value. */ readonly seed?: TAnyObject; } /** * Creates an IoC container with framework essentials. * * @param options - container configuration * @returns new IoC container */ declare function createIocContainer(options?: ICreateIocContainerOptions): Container; /** * Command identifier. Use symbols for private commands. */ type TCommandType = string | symbol; /** * Command handler signature. */ type TCommandHandler = (data: D) => MaybePromise; /** * Command calling function signature. */ type TCommandCaller = (type: T, data?: D) => ICommandDescriptor; /** * Removes a command handler. */ type TCommandUnregister = () => void; /** * Command execution status. */ declare enum ECommandStatus { PENDING = "pending", SETTLED = "settled", ERROR = "error" } /** * Descriptor returned by command execution. * Contains the task promise, current status, and responder with result/error. */ interface ICommandDescriptor { readonly task: Promise; readonly status: ECommandStatus; } /** * Dispatches a command on the provided container. * * @param container - inversify container * @param type - command type * @param data - command data * @returns command descriptor */ declare function command(container: Container, type: T, data?: D): ICommandDescriptor; /** * Dispatches a command on the provided container, returning null if no handler is registered. * * @param container - inversify container * @param type - command type * @param data - command data * @returns command descriptor or null */ declare function commandOptional(container: Container, type: T, data?: D): Optional>; /** * Event identifier. */ type TEventType = string | symbol; /** * Event object. */ interface IEvent

{ readonly type: T; readonly payload?: P; readonly from?: F; } /** * Event handler signature. */ type TEventHandler = (event: E) => void; /** * Unsubscribes from events, part of events subscription lifecycle. */ type TEventUnsubscriber = () => void; /** * Event emitter signature. */ type TEventEmitter

= (type: T, payload?: P, from?: F) => void; /** * Emits events for container from outside scope. * * @param container - inversify container * @param type - event type ot emit * @param payload - event payload * @param from - optional indicator of the event source */ declare function emitEvent(container: Container, type: T, payload?: P, from?: unknown): void; /** * Query identifier. Use symbols for private queries. */ type TQueryType = string | symbol; /** * Query handler signature. */ type TQueryHandler = (data: D) => MaybePromise; /** * Removes a query handler. */ type TQueryUnregister = () => void; /** * Public query responder signature. */ type TQueryResponder = (data?: D) => MaybePromise; /** * Dispatches queries and returns their result as a value or promise. */ type TQueryCaller = (type: T, data?: D) => MaybePromise; /** * Dispatches synchronous queries and returns their result directly. */ type TSyncQueryCaller = (type: T, data?: D) => R; /** * Dispatches optional queries. Returns null when no handler is registered. */ type TOptionalQueryCaller = (type: T, data?: D) => Optional>; /** * Dispatches optional synchronous queries. Returns null when no handler is registered. */ type TOptionalSyncQueryCaller = (type: T, data?: D) => Optional; /** * Dispatches a query on the provided container. * * @param container - inversify container * @param type - query type * @param data - query data * @returns query result */ declare function query(container: Container, type: TQueryType, data?: D): MaybePromise; /** * Dispatches a query on the provided container, returning null if no handler is registered. * * @param container - inversify container * @param type - query type * @param data - query data * @returns query result or null */ declare function queryOptional(container: Container, type: TQueryType, data?: D): Optional>; /** * A custom error class that contains generic error information for Wirestate-related issues. * * This class extends the native `Error` class and is used to represent errors specific * to the Wirestate library, providing more structured error handling. */ declare class WirestateError extends Error { /** * Name or error class to help differentiate error class in minified environments. */ readonly name: string; /** * Error code describing the issue. */ readonly code: number; /** * Error message describing the issue. */ readonly message: string; constructor(code?: number, detail?: string); } /** * Decorator for service methods that handle a command. * * @param type - command type identifier * @returns decorator function */ declare function OnCommand(type: TCommandType): MethodDecorator; /** * Returns a function to dispatch commands on the active container. * * @returns command dispatcher */ declare function useCommandCaller(): (type: T, data?: D) => ICommandDescriptor; /** * Returns a function to dispatch optional commands on the active container. * Returns null instead of throwing when no handler is registered. * * @returns optional command dispatcher */ declare function useOptionalCommandCaller(): (type: T, data?: D) => Optional>; /** * Registers a command handler for the component's lifetime. * The handler is stored in a ref to avoid manual memoization. * Only one handler is active per type; newer registrations shadow older ones. * * @param type - command type * @param handler - command handler function */ declare function useCommandHandler(type: TCommandType, handler: TCommandHandler): void; /** * Decorator for service methods that respond to a query. * * @param type - query type identifier * @returns decorator function */ declare function OnQuery(type: TQueryType): MethodDecorator; /** * Returns a function to dispatch queries on the active container. * * @returns query dispatcher */ declare function useQueryCaller(): TQueryCaller; /** * Returns a function to dispatch optional queries on the active container. * Returns null instead of throwing when no handler is registered. * * @returns optional query dispatcher */ declare function useOptionalQueryCaller(): TOptionalQueryCaller; /** * Registers a query handler for the component's lifetime. * The handler is stored in a ref to avoid manual memoization. * Only one handler is active per type; newer registrations shadow older ones. * * @param type - query type * @param handler - query handler function */ declare function useQueryHandler(type: T, handler: TQueryHandler): void; /** * Returns a stable function to dispatch synchronous queries. * Returns the value directly from the handler. * * @returns sync query dispatcher */ declare function useSyncQueryCaller(): TSyncQueryCaller; /** * Returns a stable function to dispatch synchronous optional queries. * Returns null instead of throwing when no handler is registered. * * @returns optional sync query dispatcher */ declare function useOptionalSyncQueryCaller(): TOptionalSyncQueryCaller; /** * Lookup key for service seeds. */ type TSeedKey = Newable | string | symbol; /** * Service-to-seed mapping entry. */ type TSeedEntry = readonly [TSeedKey, T]; /** * Collection of seed entries. */ type TSeedEntries = ReadonlyArray; /** * Injectable scope providing access to wirestate buses and seeds. * Each injecting service receives its own instance (transient scope). * The scope is activated and deactivated automatically alongside its owner service. */ declare class WireScope { private readonly container; /** * Whether the scope was deactivated and disposed from the container. */ readonly isDisposed: boolean; constructor(container: Optional); /** * Access the IoC container. * Available only for activated instances of scope. * * @returns active container * * @throws WirestateError if scope is not activated or already disposed */ getContainer(): Container; /** * Resolves a sibling service or injected value. * Use for lazy resolution or circular dependency breaking. * Available only for activated containers. * * @param injectionId - injection identifier * @returns resolved injection, service instance, or generic value * * @throws WirestateError if scope is not activated */ resolve(injectionId: ServiceIdentifier): T; /** * Resolves a sibling service or injected value. * Use for lazy resolution or circular dependency breaking. * Available only for activated containers. * * @param injectionId - injection identifier * @returns resolved injection, service instance, generic value, or null if it is not bound * * @throws WirestateError if scope is not activated */ resolveOptional(injectionId: ServiceIdentifier): Optional; /** * Broadcasts an event. * Available only for activated containers. * * @param type - type of event to emit * @param payload - optional payload to send with the event * @param from - optional sender of the event * * @throws WirestateError if scope is not activated */ emitEvent(type: T, payload?: P, from?: unknown): void; /** * Dispatches a query and returns the result. * Available only for activated containers. * * @param type - query type * @param data - query data * @returns query result * * @throws WirestateError if scope is not activated */ queryData(type: T, data?: D): MaybePromise; /** * Dispatches a query and returns the result. * Available only for activated containers. * * @param type - query type * @param data - query data * @returns query result or null if handler is not registered */ queryOptionalData(type: T, data?: D): Optional>; /** * Dispatches a command and returns the descriptor. * Available only for activated containers. * * @param type - command type * @param data - command data * @returns command descriptor * * @throws WirestateError if scope is not activated */ executeCommand(type: T, data?: D): ICommandDescriptor; /** * Dispatches a command and returns the descriptor. * Available only for activated containers. * * @param type - command type * @param data - command data * @returns command descriptor or null if handler is not registered */ executeOptionalCommand(type: T, data?: D): Optional>; getSeed(): T; getSeed(seed?: TSeedKey): Optional; } /** * Token for the container-scoped shared seed object. */ declare const SEED_TOKEN: unique symbol; /** * Decorator for service methods that run after activation. * * @returns decorator function */ declare function OnActivated(): MethodDecorator; /** * Decorator for service methods that run before deactivation. * * @returns decorator function */ declare function OnDeactivation(): MethodDecorator; /** * Resolves a value from the container - constant or service. * Automatically re-resolves if the container is reset or services are rebound. * * @param injectionId - injection identifier * @returns resolved value */ declare function useInjection(injectionId: ServiceIdentifier): T; /** * Resolves a value from the container if bound, returning null otherwise. * Unlike {@link useInjection}, this hook does not throw when the token is not bound. * * @param injectionId - injection identifier * @param onFallback - optional callback to handle cases when dependency was not resolved * @returns resolved value, result of optional fallback handler or null */ declare function useOptionalInjection(injectionId: ServiceIdentifier, onFallback?: (container: Container) => T): Optional; /** * Props for the component returned by {@link createInjectablesProvider}. */ interface IInjectablesProviderProps { /** * Targeted seeds bound to specific injectables or tokens. * Subsequent prop changes are ignored. Use a React `key` to re-seed the tree. */ readonly seeds?: TSeedEntries; /** * Subtree that consumes the bound services. */ readonly children?: ReactNode; } /** * Component returned by {@link createInjectablesProvider}. */ type InjectablesProvider = ReturnType; /** * Configuration for {@link createInjectablesProvider}. */ interface ICreateInjectablesProviderOptions { /** * Services to resolve immediately on mount. */ readonly activate?: ReadonlyArray; } /** * Creates a component that manages injectable lifetimes for its subtree. * * @param entries - service classes or injectable descriptors to bind * @param options - provider configuration * @returns injectables provider component */ declare function createInjectablesProvider(entries: ReadonlyArray | IInjectableDescriptor>, options?: ICreateInjectablesProviderOptions): { (props: IInjectablesProviderProps): ReactElement; displayName: string; }; /** * React context value. */ interface IIocContext { /** * Inversify container. */ readonly container: Container; /** * Revision counter for cache invalidation. */ readonly revision: number; /** * Forces a revision update. */ readonly setRevision: Dispatch>; } /** * Props for {@link IocProvider}. */ interface IIocProviderProps extends PropsWithChildren { /** * External container instance. If omitted, a new container is created. */ readonly container?: Container; /** * Shared seed for the container. */ readonly seed?: TAnyObject; } /** * Provides an IoC container to the component tree. * * @param props - component props * @param props.container - external container instance * @param props.seed - shared seed across the container * @param props.children - components to wrap * @returns provider element */ declare function IocProvider({ container: externalContainer, seed, children }: IIocProviderProps): react.FunctionComponentElement>>; /** * Returns the active IoC container. * * @returns active Inversify container */ declare function useContainer(): Container; /** * Returns the current container revision. * * @returns revision number */ declare function useContainerRevision(): number; /** * Decorator for service methods that respond to events. * * @param types - event type(s) to handle. If omitted, handles all events * @returns decorator function */ declare function OnEvent(types?: TEventType | ReadonlyArray): MethodDecorator; /** * Subscribes a component to events. * * @param type - event type to listen to * @param handler - event handler to invoke when event is emitted */ declare function useEvent(type: TEventType, handler: TEventHandler): void; /** * Subscribes a component to multiple event types. * * @param types - event types to filter by * @param handler - events handler */ declare function useEvents(types: ReadonlyArray, handler: TEventHandler): void; /** * Subscribes a component to all events without type filtering. * * @param handler - event handler invoked for every emitted event */ declare function useEventsHandler(handler: TEventHandler): void; /** * Returns a stable function to emit events. * * @returns event emitter */ declare function useEventEmitter

(): TEventEmitter; export { ECommandStatus as CommandStatus, IInjectableDescriptor as InjectableDescriptor, IocProvider, OnActivated, OnCommand, OnDeactivation, OnEvent, OnQuery, SEED_TOKEN as SEED, WireScope, WirestateError, bindConstant, bindEntry, bindService, command, commandOptional, createInjectablesProvider, createIocContainer, emitEvent, forwardRef, query, queryOptional, useCommandCaller, useCommandHandler, useContainer, useContainerRevision, useEvent, useEventEmitter, useEvents, useEventsHandler, useInjection, useOptionalCommandCaller, useOptionalInjection, useOptionalQueryCaller, useOptionalSyncQueryCaller, useQueryCaller, useQueryHandler, useSyncQueryCaller }; export type { TCommandCaller as CommandCaller, ICommandDescriptor as CommandDescriptor, TCommandHandler as CommandHandler, TCommandType as CommandType, TCommandUnregister as CommandUnregister, IEvent as Event, TEventEmitter as EventEmitter, TEventHandler as EventHandler, TEventType as EventType, TEventUnsubscriber as EventUnsubscriber, InjectablesProvider, IInjectablesProviderProps as InjectablesProviderProps, TOptionalQueryCaller as OptionalQueryCaller, TOptionalSyncQueryCaller as OptionalSyncQueryCaller, TQueryCaller as QueryCaller, TQueryHandler as QueryHandler, TQueryResponder as QueryResponder, TQueryType as QueryType, TQueryUnregister as QueryUnregister, TSeedEntries as SeedEntries, TSeedEntry as SeedEntry, TSeedKey as SeedKey, TSyncQueryCaller as SyncQueryCaller };