abxbus 2.5.1 → 2.5.3

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
@@ -0,0 +1,30 @@
1
+ import { BaseEvent } from './base_event.js';
2
+ import type { EventClass, EventHandlerCallable, UntypedEventHandlerFunction } from './types.js';
3
+ export declare class SQLiteEventBridge {
4
+ readonly path: string;
5
+ readonly table: string;
6
+ readonly poll_interval: number;
7
+ readonly name: string;
8
+ private readonly inbound_bus;
9
+ private running;
10
+ private last_seen_event_created_at;
11
+ private last_seen_event_id;
12
+ private listener_task;
13
+ private start_task;
14
+ private db;
15
+ private table_columns;
16
+ constructor(path: string, table?: string, poll_interval?: number, name?: string);
17
+ on<T extends BaseEvent>(event_pattern: EventClass<T>, handler: EventHandlerCallable<T>): void;
18
+ on<T extends BaseEvent>(event_pattern: string | '*', handler: UntypedEventHandlerFunction<T>): void;
19
+ emit<T extends BaseEvent>(event: T): Promise<void>;
20
+ dispatch<T extends BaseEvent>(event: T): Promise<void>;
21
+ start(): Promise<void>;
22
+ close(): Promise<void>;
23
+ private ensureStarted;
24
+ private listenLoop;
25
+ private dispatchInboundPayload;
26
+ private refreshColumnCache;
27
+ private ensureColumns;
28
+ private ensureBaseIndexes;
29
+ private setCursorToLatestRow;
30
+ }
@@ -0,0 +1,125 @@
1
+ import { BaseEvent, type BaseEventJSON } from './base_event.js';
2
+ import { EventHistory } from './event_history.js';
3
+ import { EventResult } from './event_result.js';
4
+ import { AsyncLock, type EventConcurrencyMode, type EventHandlerConcurrencyMode, type EventHandlerCompletionMode, LockManager } from './lock_manager.js';
5
+ import { EventHandler, type EphemeralFindEventHandler, type EventHandlerJSON } from './event_handler.js';
6
+ import type { EventBusMiddleware, EventBusMiddlewareInput } from './middlewares.js';
7
+ import type { EventClass, EventHandlerCallable, EventPattern, FindOptions, UntypedEventHandlerFunction } from './types.js';
8
+ export type EventBusOptions = {
9
+ id?: string;
10
+ max_history_size?: number | null;
11
+ max_history_drop?: boolean;
12
+ event_concurrency?: EventConcurrencyMode | null;
13
+ event_timeout?: number | null;
14
+ event_slow_timeout?: number | null;
15
+ event_handler_concurrency?: EventHandlerConcurrencyMode | null;
16
+ event_handler_completion?: EventHandlerCompletionMode;
17
+ event_handler_slow_timeout?: number | null;
18
+ event_handler_detect_file_paths?: boolean;
19
+ middlewares?: EventBusMiddlewareInput[];
20
+ };
21
+ export type EventBusJSON = {
22
+ id: string;
23
+ name: string;
24
+ max_history_size: number | null;
25
+ max_history_drop: boolean;
26
+ event_concurrency: EventConcurrencyMode;
27
+ event_timeout: number | null;
28
+ event_slow_timeout: number | null;
29
+ event_handler_concurrency: EventHandlerConcurrencyMode;
30
+ event_handler_completion: EventHandlerCompletionMode;
31
+ event_handler_slow_timeout: number | null;
32
+ event_handler_detect_file_paths: boolean;
33
+ handlers: Record<string, EventHandlerJSON>;
34
+ handlers_by_key: Record<string, string[]>;
35
+ event_history: Record<string, BaseEventJSON>;
36
+ pending_event_queue: string[];
37
+ };
38
+ export declare class GlobalEventBusRegistry {
39
+ private _bus_refs;
40
+ add(bus: EventBus): void;
41
+ discard(bus: EventBus): void;
42
+ has(bus: EventBus): boolean;
43
+ get size(): number;
44
+ [Symbol.iterator](): IterableIterator<EventBus>;
45
+ findBusById(bus_id: string): EventBus | undefined;
46
+ findEventById(event_id: string): BaseEvent | null;
47
+ }
48
+ export declare class EventBus {
49
+ private static _registry_by_constructor;
50
+ private static _global_event_lock_by_constructor;
51
+ private static getRegistryForConstructor;
52
+ private static getGlobalEventLockForConstructor;
53
+ static get all_instances(): GlobalEventBusRegistry;
54
+ get all_instances(): GlobalEventBusRegistry;
55
+ get _lock_for_event_global_serial(): AsyncLock;
56
+ id: string;
57
+ name: string;
58
+ event_timeout: number | null;
59
+ event_concurrency: EventConcurrencyMode;
60
+ event_handler_concurrency: EventHandlerConcurrencyMode;
61
+ event_handler_completion: EventHandlerCompletionMode;
62
+ event_handler_detect_file_paths: boolean;
63
+ event_handler_slow_timeout: number | null;
64
+ event_slow_timeout: number | null;
65
+ handlers: Map<string, EventHandler>;
66
+ handlers_by_key: Map<string, string[]>;
67
+ event_history: EventHistory<BaseEvent>;
68
+ pending_event_queue: BaseEvent[];
69
+ in_flight_event_ids: Set<string>;
70
+ runloop_running: boolean;
71
+ locks: LockManager;
72
+ find_waiters: Set<EphemeralFindEventHandler>;
73
+ middlewares: EventBusMiddleware[];
74
+ private static normalizeMiddlewares;
75
+ constructor(name?: string, options?: EventBusOptions);
76
+ toString(): string;
77
+ scheduleMicrotask(fn: () => void): void;
78
+ private _runMiddlewareHook;
79
+ onEventChange(event: BaseEvent, status: 'pending' | 'started' | 'completed'): Promise<void>;
80
+ onEventResultChange(event: BaseEvent, result: EventResult, status: 'pending' | 'started' | 'completed'): Promise<void>;
81
+ private _onEventChange;
82
+ private _onEventResultChange;
83
+ private _onBusHandlersChange;
84
+ private _finalizeEventTimeout;
85
+ private _createEventTimeoutError;
86
+ private _runHandlersWithTimeout;
87
+ private _markEventCompletedIfNeeded;
88
+ toJSON(): EventBusJSON;
89
+ private static _stubHandlerFn;
90
+ private static _upsertHandlerIndex;
91
+ private static _linkEventResultHandlers;
92
+ static fromJSON(data: unknown): EventBus;
93
+ get label(): string;
94
+ removeEventFromPendingQueue(event: BaseEvent): number;
95
+ isEventInFlightOrQueued(event_id: string): boolean;
96
+ removeEventFromHistory(event_id: string): boolean;
97
+ destroy(): void;
98
+ on<T extends BaseEvent>(event_pattern: EventClass<T>, handler: EventHandlerCallable<T>, options?: Partial<EventHandler>): EventHandler;
99
+ on<T extends BaseEvent>(event_pattern: string | '*', handler: UntypedEventHandlerFunction<T>, options?: Partial<EventHandler>): EventHandler;
100
+ off<T extends BaseEvent>(event_pattern: EventPattern<T> | '*', handler?: EventHandlerCallable<T> | string | EventHandler): void;
101
+ emit<T extends BaseEvent>(event: T): T;
102
+ dispatch<T extends BaseEvent>(event: T): T;
103
+ find(event_pattern: '*', options?: FindOptions<BaseEvent>): Promise<BaseEvent | null>;
104
+ find(event_pattern: '*', where: (event: BaseEvent) => boolean, options?: FindOptions<BaseEvent>): Promise<BaseEvent | null>;
105
+ find<T extends BaseEvent>(event_pattern: EventPattern<T>, options?: FindOptions<T>): Promise<T | null>;
106
+ find<T extends BaseEvent>(event_pattern: EventPattern<T>, where: (event: T) => boolean, options?: FindOptions<T>): Promise<T | null>;
107
+ private _waitForFutureMatch;
108
+ waitUntilIdle(timeout?: number | null): Promise<boolean>;
109
+ isIdle(): boolean;
110
+ isIdleAndQueueEmpty(): boolean;
111
+ eventIsChildOf(child_event: BaseEvent, parent_event: BaseEvent): boolean;
112
+ eventIsParentOf(parent_event: BaseEvent, child_event: BaseEvent): boolean;
113
+ logTree(): string;
114
+ findEventById(event_id: string): BaseEvent | null;
115
+ private _startRunloop;
116
+ private _processEvent;
117
+ _processEventImmediately<T extends BaseEvent>(event: T, handler_result?: EventResult): Promise<T>;
118
+ private _processEventImmediatelyAcrossBuses;
119
+ private _runloop;
120
+ _hasProcessedEvent(event: BaseEvent): boolean;
121
+ _getEventProxyScopedToThisBus<T extends BaseEvent>(event: T, handler_result?: EventResult): T;
122
+ private _resolveFindWaiters;
123
+ _getHandlersForEvent(event: BaseEvent): EventHandler[];
124
+ private _removeIndexedHandler;
125
+ }
@@ -0,0 +1,139 @@
1
+ import { z } from 'zod';
2
+ import { type EventHandlerCallable, type EventPattern } from './types.js';
3
+ import { BaseEvent } from './base_event.js';
4
+ import type { EventResult } from './event_result.js';
5
+ export type EphemeralFindEventHandler = {
6
+ event_pattern: string | '*';
7
+ matches: (event: BaseEvent) => boolean;
8
+ resolve: (event: BaseEvent) => void;
9
+ timeout_id?: ReturnType<typeof setTimeout>;
10
+ };
11
+ export declare const FindWaiterJSONSchema: z.ZodObject<{
12
+ event_pattern: z.ZodUnion<readonly [z.ZodString, z.ZodLiteral<"*">]>;
13
+ has_timeout: z.ZodBoolean;
14
+ }, z.core.$strict>;
15
+ export type FindWaiterJSON = z.infer<typeof FindWaiterJSONSchema>;
16
+ export declare class FindWaiter {
17
+ static toJSON(waiter: EphemeralFindEventHandler): FindWaiterJSON;
18
+ static fromJSON(data: unknown, overrides?: {
19
+ matches?: (event: BaseEvent) => boolean;
20
+ resolve?: (event: BaseEvent) => void;
21
+ }): EphemeralFindEventHandler;
22
+ static toJSONArray(waiters: Iterable<EphemeralFindEventHandler>): FindWaiterJSON[];
23
+ static fromJSONArray(data: unknown, overrides?: {
24
+ matches?: (event: BaseEvent) => boolean;
25
+ resolve?: (event: BaseEvent) => void;
26
+ }): EphemeralFindEventHandler[];
27
+ }
28
+ export declare const EventHandlerJSONSchema: z.ZodObject<{
29
+ id: z.ZodString;
30
+ eventbus_name: z.ZodString;
31
+ eventbus_id: z.ZodString;
32
+ event_pattern: z.ZodUnion<readonly [z.ZodString, z.ZodLiteral<"*">]>;
33
+ handler_name: z.ZodString;
34
+ handler_file_path: z.ZodOptional<z.ZodNullable<z.ZodString>>;
35
+ handler_timeout: z.ZodOptional<z.ZodNullable<z.ZodNumber>>;
36
+ handler_slow_timeout: z.ZodOptional<z.ZodNullable<z.ZodNumber>>;
37
+ handler_registered_at: z.ZodString;
38
+ }, z.core.$strict>;
39
+ export type EventHandlerJSON = z.infer<typeof EventHandlerJSONSchema>;
40
+ export declare class EventHandler {
41
+ id: string;
42
+ handler: EventHandlerCallable;
43
+ handler_name: string;
44
+ handler_file_path: string | null;
45
+ handler_timeout?: number | null;
46
+ handler_slow_timeout?: number | null;
47
+ handler_registered_at: string;
48
+ event_pattern: string | '*';
49
+ eventbus_name: string;
50
+ eventbus_id: string;
51
+ constructor(params: {
52
+ id?: string;
53
+ handler: EventHandlerCallable;
54
+ handler_name: string;
55
+ handler_file_path?: string | null;
56
+ handler_timeout?: number | null;
57
+ handler_slow_timeout?: number | null;
58
+ handler_registered_at: string;
59
+ event_pattern: string | '*';
60
+ eventbus_name: string;
61
+ eventbus_id: string;
62
+ });
63
+ get _handler_async(): EventHandlerCallable;
64
+ static computeHandlerId(params: {
65
+ eventbus_id: string;
66
+ handler_name: string;
67
+ handler_file_path?: string | null;
68
+ handler_registered_at: string;
69
+ event_pattern: string | '*';
70
+ }): string;
71
+ static fromCallable<TEvent extends BaseEvent = BaseEvent>(params: {
72
+ handler: EventHandlerCallable<TEvent>;
73
+ event_pattern: EventPattern | '*';
74
+ eventbus_name: string;
75
+ eventbus_id: string;
76
+ detect_handler_file_path?: boolean;
77
+ id?: string;
78
+ handler_file_path?: string | null;
79
+ handler_timeout?: number | null;
80
+ handler_slow_timeout?: number | null;
81
+ handler_registered_at?: string;
82
+ }): EventHandler;
83
+ toString(): string;
84
+ _detectHandlerFilePath(): void;
85
+ toJSON(): EventHandlerJSON;
86
+ static fromJSON(data: unknown, handler?: EventHandlerCallable): EventHandler;
87
+ static toJSONArray(handlers: Iterable<EventHandler>): EventHandlerJSON[];
88
+ static fromJSONArray(data: unknown, handler?: EventHandlerCallable): EventHandler[];
89
+ get eventbus_label(): string;
90
+ }
91
+ export declare class TimeoutError extends Error {
92
+ constructor(message: string);
93
+ }
94
+ export declare class EventHandlerError extends Error {
95
+ event_result: EventResult;
96
+ timeout_seconds: number | null;
97
+ cause: Error;
98
+ constructor(message: string, params: {
99
+ event_result: EventResult;
100
+ timeout_seconds?: number | null;
101
+ cause: Error;
102
+ });
103
+ get event(): BaseEvent;
104
+ get event_type(): string;
105
+ get handler_name(): string;
106
+ get handler_id(): string;
107
+ get event_timeout(): number | null;
108
+ }
109
+ export declare class EventHandlerTimeoutError extends EventHandlerError {
110
+ constructor(message: string, params: {
111
+ event_result: EventResult;
112
+ timeout_seconds?: number | null;
113
+ cause?: Error;
114
+ });
115
+ }
116
+ export declare class EventHandlerCancelledError extends EventHandlerError {
117
+ constructor(message: string, params: {
118
+ event_result: EventResult;
119
+ timeout_seconds?: number | null;
120
+ cause: Error;
121
+ });
122
+ }
123
+ export declare class EventHandlerAbortedError extends EventHandlerError {
124
+ constructor(message: string, params: {
125
+ event_result: EventResult;
126
+ timeout_seconds?: number | null;
127
+ cause: Error;
128
+ });
129
+ }
130
+ export declare class EventHandlerResultSchemaError extends EventHandlerError {
131
+ raw_value: unknown;
132
+ constructor(message: string, params: {
133
+ event_result: EventResult;
134
+ timeout_seconds?: number | null;
135
+ cause: Error;
136
+ raw_value: unknown;
137
+ });
138
+ get expected_schema(): any;
139
+ }
@@ -0,0 +1,45 @@
1
+ import { BaseEvent } from './base_event.js';
2
+ import type { EventPattern, FindWindow } from './types.js';
3
+ export type EventHistoryFindOptions = {
4
+ past?: FindWindow;
5
+ future?: FindWindow;
6
+ child_of?: BaseEvent | null;
7
+ event_is_child_of?: (event: BaseEvent, ancestor: BaseEvent) => boolean;
8
+ wait_for_future_match?: (event_pattern: string | '*', matches: (event: BaseEvent) => boolean, future: FindWindow) => Promise<BaseEvent | null>;
9
+ } & Record<string, unknown>;
10
+ export type EventHistoryTrimOptions<TEvent extends BaseEvent = BaseEvent> = {
11
+ is_event_complete?: (event: TEvent) => boolean;
12
+ on_remove?: (event: TEvent) => void;
13
+ owner_label?: string;
14
+ max_history_size?: number | null;
15
+ max_history_drop?: boolean;
16
+ };
17
+ export declare class EventHistory<TEvent extends BaseEvent = BaseEvent> implements Iterable<[string, TEvent]> {
18
+ max_history_size: number | null;
19
+ max_history_drop: boolean;
20
+ private _events;
21
+ private _warned_about_dropping_uncompleted_events;
22
+ constructor(options?: {
23
+ max_history_size?: number | null;
24
+ max_history_drop?: boolean;
25
+ });
26
+ get size(): number;
27
+ [Symbol.iterator](): Iterator<[string, TEvent]>;
28
+ entries(): IterableIterator<[string, TEvent]>;
29
+ keys(): IterableIterator<string>;
30
+ values(): IterableIterator<TEvent>;
31
+ clear(): void;
32
+ get(event_id: string): TEvent | undefined;
33
+ set(event_id: string, event: TEvent): this;
34
+ has(event_id: string): boolean;
35
+ delete(event_id: string): boolean;
36
+ addEvent(event: TEvent): void;
37
+ getEvent(event_id: string): TEvent | undefined;
38
+ removeEvent(event_id: string): boolean;
39
+ hasEvent(event_id: string): boolean;
40
+ static normalizeEventPattern(event_pattern: EventPattern | '*'): string | '*';
41
+ find(event_pattern: '*', where?: (event: TEvent) => boolean, options?: EventHistoryFindOptions): Promise<TEvent | null>;
42
+ find<TMatch extends TEvent>(event_pattern: EventPattern<TMatch>, where?: (event: TMatch) => boolean, options?: EventHistoryFindOptions): Promise<TMatch | null>;
43
+ trimEventHistory(options?: EventHistoryTrimOptions<TEvent>): number;
44
+ private eventIsChildOf;
45
+ }
@@ -0,0 +1,86 @@
1
+ import { z } from 'zod';
2
+ import { BaseEvent } from './base_event.js';
3
+ import type { EventBus } from './event_bus.js';
4
+ import { EventHandler } from './event_handler.js';
5
+ import { type HandlerLock } from './lock_manager.js';
6
+ import type { Deferred } from './lock_manager.js';
7
+ import type { EventResultType } from './types.js';
8
+ export type EventResultStatus = 'pending' | 'started' | 'completed' | 'error';
9
+ export declare const EventResultJSONSchema: z.ZodObject<{
10
+ id: z.ZodString;
11
+ status: z.ZodEnum<{
12
+ pending: "pending";
13
+ started: "started";
14
+ completed: "completed";
15
+ error: "error";
16
+ }>;
17
+ event_id: z.ZodString;
18
+ handler_id: z.ZodString;
19
+ handler_name: z.ZodString;
20
+ handler_file_path: z.ZodOptional<z.ZodNullable<z.ZodString>>;
21
+ handler_timeout: z.ZodOptional<z.ZodNullable<z.ZodNumber>>;
22
+ handler_slow_timeout: z.ZodOptional<z.ZodNullable<z.ZodNumber>>;
23
+ handler_registered_at: z.ZodOptional<z.ZodString>;
24
+ handler_event_pattern: z.ZodOptional<z.ZodUnion<readonly [z.ZodString, z.ZodLiteral<"*">]>>;
25
+ eventbus_name: z.ZodString;
26
+ eventbus_id: z.ZodString;
27
+ started_at: z.ZodOptional<z.ZodNullable<z.ZodString>>;
28
+ completed_at: z.ZodOptional<z.ZodNullable<z.ZodString>>;
29
+ result: z.ZodOptional<z.ZodUnknown>;
30
+ error: z.ZodOptional<z.ZodUnknown>;
31
+ event_children: z.ZodArray<z.ZodString>;
32
+ }, z.core.$strict>;
33
+ export type EventResultJSON = z.infer<typeof EventResultJSONSchema>;
34
+ export declare class EventResult<TEvent extends BaseEvent = BaseEvent> {
35
+ id: string;
36
+ status: EventResultStatus;
37
+ event: TEvent;
38
+ handler: EventHandler;
39
+ started_at: string | null;
40
+ completed_at: string | null;
41
+ result?: EventResultType<TEvent>;
42
+ error?: unknown;
43
+ event_children: BaseEvent[];
44
+ _abort: Deferred<never> | null;
45
+ _lock: HandlerLock | null;
46
+ _queue_jump_pause_releases: Map<EventBus, () => void> | null;
47
+ constructor(params: {
48
+ event: TEvent;
49
+ handler: EventHandler;
50
+ });
51
+ toString(): string;
52
+ get event_id(): string;
53
+ get bus(): EventBus;
54
+ get handler_id(): string;
55
+ get handler_name(): string;
56
+ get handler_file_path(): string | null;
57
+ get eventbus_name(): string;
58
+ get eventbus_id(): string;
59
+ get eventbus_label(): string;
60
+ private getHookBus;
61
+ private _notifyStatusHook;
62
+ get value(): EventResultType<TEvent> | undefined;
63
+ get result_type(): TEvent['event_result_type'];
64
+ _linkEmittedChildEvent(child_event: BaseEvent): void;
65
+ get raw_value(): EventResultType<TEvent> | undefined;
66
+ get handler_timeout(): number | null;
67
+ get handler_slow_timeout(): number | null;
68
+ _createSlowHandlerWarningTimer(effective_timeout: number | null): ReturnType<typeof setTimeout> | null;
69
+ _ensureQueueJumpPause(bus: EventBus): void;
70
+ _releaseQueueJumpPauses(): void;
71
+ update(params: {
72
+ status?: EventResultStatus;
73
+ result?: EventResultType<TEvent> | BaseEvent | undefined;
74
+ error?: unknown;
75
+ }): this;
76
+ private _createHandlerTimeoutError;
77
+ private _handleHandlerError;
78
+ private _onHandlerExit;
79
+ runHandler(handler_lock: HandlerLock | null): Promise<void>;
80
+ _signalAbort(error: Error): void;
81
+ _markStarted(notify_hook?: boolean): Promise<never>;
82
+ _markCompleted(result: EventResultType<TEvent> | BaseEvent | undefined, notify_hook?: boolean): void;
83
+ _markError(error: unknown, notify_hook?: boolean): void;
84
+ toJSON(): EventResultJSON;
85
+ static fromJSON<TEvent extends BaseEvent>(event: TEvent, data: unknown): EventResult<TEvent>;
86
+ }
@@ -0,0 +1,70 @@
1
+ import type { BaseEvent } from './base_event.js';
2
+ import type { EventResult } from './event_result.js';
3
+ export type Deferred<T> = {
4
+ promise: Promise<T>;
5
+ resolve: (value: T | PromiseLike<T>) => void;
6
+ reject: (reason?: unknown) => void;
7
+ };
8
+ export declare const withResolvers: <T>() => Deferred<T>;
9
+ export declare const EVENT_CONCURRENCY_MODES: readonly ["global-serial", "bus-serial", "parallel"];
10
+ export type EventConcurrencyMode = (typeof EVENT_CONCURRENCY_MODES)[number];
11
+ export declare const EVENT_HANDLER_CONCURRENCY_MODES: readonly ["serial", "parallel"];
12
+ export type EventHandlerConcurrencyMode = (typeof EVENT_HANDLER_CONCURRENCY_MODES)[number];
13
+ export declare const EVENT_HANDLER_COMPLETION_MODES: readonly ["all", "first"];
14
+ export type EventHandlerCompletionMode = (typeof EVENT_HANDLER_COMPLETION_MODES)[number];
15
+ export declare class AsyncLock {
16
+ size: number;
17
+ in_use: number;
18
+ waiters: Array<() => void>;
19
+ constructor(size: number);
20
+ acquire(): Promise<void>;
21
+ release(): void;
22
+ }
23
+ export declare const runWithLock: <T>(lock: AsyncLock | null, fn: () => Promise<T>) => Promise<T>;
24
+ export type HandlerExecutionState = 'held' | 'yielded' | 'closed';
25
+ export declare class HandlerLock {
26
+ private lock;
27
+ private state;
28
+ constructor(lock: AsyncLock | null);
29
+ yieldHandlerLockForChildRun(): boolean;
30
+ reclaimHandlerLockIfRunning(): Promise<boolean>;
31
+ exitHandlerRun(): void;
32
+ runQueueJump<T>(fn: () => Promise<T>): Promise<T>;
33
+ }
34
+ export type EventBusInterfaceForLockManager = {
35
+ isIdleAndQueueEmpty: () => boolean;
36
+ event_concurrency: EventConcurrencyMode;
37
+ _lock_for_event_global_serial: AsyncLock;
38
+ };
39
+ export type LockManagerOptions = {
40
+ auto_schedule_idle_checks?: boolean;
41
+ };
42
+ export declare class LockManager {
43
+ private bus;
44
+ private auto_schedule_idle_checks;
45
+ readonly bus_event_lock: AsyncLock;
46
+ private pause_depth;
47
+ private pause_waiters;
48
+ private active_handler_results;
49
+ private idle_waiters;
50
+ private idle_check_pending;
51
+ private idle_check_streak;
52
+ constructor(bus: EventBusInterfaceForLockManager, options?: LockManagerOptions);
53
+ _requestRunloopPause(): () => void;
54
+ _waitUntilRunloopResumed(): Promise<void>;
55
+ _isPaused(): boolean;
56
+ _runWithHandlerDispatchContext<T>(result: EventResult, fn: () => Promise<T>): Promise<T>;
57
+ _getActiveHandlerResultForCurrentAsyncContext(): EventResult | undefined;
58
+ _getActiveHandlerResults(): EventResult[];
59
+ _isAnyHandlerActive(): boolean;
60
+ waitForIdle(timeout_seconds?: number | null): Promise<boolean>;
61
+ _notifyIdleListeners(): void;
62
+ getLockForEvent(event: BaseEvent): AsyncLock | null;
63
+ _runWithEventLock<T>(event: BaseEvent, fn: () => Promise<T>, options?: {
64
+ bypass_event_locks?: boolean;
65
+ pre_acquired_lock?: AsyncLock | null;
66
+ }): Promise<T>;
67
+ _runWithHandlerLock<T>(event: BaseEvent, default_handler_concurrency: EventHandlerConcurrencyMode | undefined, fn: (lock: HandlerLock | null) => Promise<T>): Promise<T>;
68
+ private scheduleIdleCheck;
69
+ clear(): void;
70
+ }
@@ -1,4 +1,11 @@
1
1
  type SemaphoreScope = 'multiprocess' | 'global' | 'class' | 'instance';
2
+ type AnyFunction = (this: any, ...args: any[]) => any;
3
+ type LegacyMethodDescriptor = TypedPropertyDescriptor<AnyFunction>;
4
+ type RetryDecorator = {
5
+ <T extends AnyFunction>(target: T): T;
6
+ <T extends AnyFunction>(target: T, context: ClassMethodDecoratorContext): T;
7
+ (target: object, property_key: string | symbol, descriptor: LegacyMethodDescriptor): LegacyMethodDescriptor;
8
+ };
2
9
  export interface RetryOptions {
3
10
  /** Total number of attempts including the initial call (1 = no retry, 3 = up to 2 retries). Default: 1 */
4
11
  max_attempts?: number;
@@ -51,5 +58,5 @@ export declare class SemaphoreTimeoutError extends Error {
51
58
  }
52
59
  /** Reset the global semaphore registry. Useful in tests. */
53
60
  export declare function clearSemaphoreRegistry(): void;
54
- export declare function retry(options?: RetryOptions): <T extends (...args: any[]) => any>(target: T, _context?: ClassMethodDecoratorContext) => T;
61
+ export declare function retry(options?: RetryOptions): RetryDecorator;
55
62
  export {};
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "abxbus",
3
- "version": "2.5.1",
3
+ "version": "2.5.3",
4
4
  "description": "Event bus library for browsers and ESM Node.js",
5
5
  "type": "module",
6
6
  "sideEffects": false,