Dev Build / cleanup (push) Canceled after 0s
Dev Build / typecheck (push) Canceled after 0s
Dev Build / build (linux-arm64, ubuntu-24.04-arm, linux-arm64) (push) Canceled after 0s
Dev Build / build (linux-x64, ubuntu-latest, linux-x64) (push) Canceled after 0s
Dev Build / build (win-x64, windows-latest, win32-x64) (push) Canceled after 0s
Dev Build / dispatch-dev-docker (push) Canceled after 0s
48 lines
2.3 KiB
Plaintext
48 lines
2.3 KiB
Plaintext
/**
|
|
* Protocol-independent DOM-style event fan-out.
|
|
*
|
|
* Owners perform event-specific state updates before calling
|
|
* {@link dispatch}. Dispatch then invokes the singular handler followed by a
|
|
* snapshot of listeners in insertion order.
|
|
*
|
|
* @typeParam EventMap - Maps event names to their listener parameter types.
|
|
*/
|
|
export declare class EventDispatcher<EventMap extends Record<string, unknown>> {
|
|
private readonly _eventSlots;
|
|
/** Set, replace, or clear the singular handler for an event. */
|
|
setHandler<K extends keyof EventMap>(event: K, handler: ((params: EventMap[K]) => void) | undefined): void;
|
|
/** Get the singular handler for an event, if one is set. */
|
|
getHandler<K extends keyof EventMap>(event: K): ((params: EventMap[K]) => void) | undefined;
|
|
/** Add a listener. Listeners run in insertion order after the handler. */
|
|
addEventListener<K extends keyof EventMap>(event: K, handler: (params: EventMap[K]) => void): void;
|
|
/** Remove the first matching listener, if present. */
|
|
removeEventListener<K extends keyof EventMap>(event: K, handler: (params: EventMap[K]) => void): void;
|
|
/**
|
|
* Dispatch an event to its singular handler and a listener snapshot.
|
|
* Listener mutations during dispatch take effect on the next dispatch.
|
|
*/
|
|
dispatch<K extends keyof EventMap>(event: K, params: EventMap[K]): void;
|
|
private _ensureEventSlot;
|
|
}
|
|
/**
|
|
* Tracks which JSON-RPC methods already have a handler registered through the
|
|
* owning `App` / `AppBridge`, so a second direct `setRequestHandler` /
|
|
* `setNotificationHandler` call for the same method throws instead of
|
|
* silently replacing the first handler (the base SDK `Protocol` replaces).
|
|
*
|
|
* The `on*` setters use {@link replace} for DOM-style replace semantics, and
|
|
* `removeRequestHandler` / `removeNotificationHandler` use {@link release}.
|
|
*
|
|
* @internal
|
|
*/
|
|
export declare class MethodRegistry {
|
|
private readonly _methods;
|
|
/** Claim `method`. Throws if a handler is already registered for it. */
|
|
claim(method: string, via: string): void;
|
|
/** Claim `method` with replace semantics (never throws). */
|
|
replace(method: string): void;
|
|
/** Release `method` so it can be claimed again. */
|
|
release(method: string): void;
|
|
has(method: string): boolean;
|
|
}
|