import { Subscribable, ISubscriber } from './subscribable'; export declare type EventOptions = boolean | (AddEventListenerOptions & EventListenerOptions & { mode?: 'onlyOne' | 'onlyParent' | 'onlyChild'; }); export declare type EventContainer = Window | HTMLElement | HTMLDocument; export declare type EventDriverContainer = HTMLElement | HTMLDocument; export interface IEventEffect { (engine: T): void; } export interface IEventDriver { container: EventDriverContainer; contentWindow: Window; attach(container: EventDriverContainer): void; detach(container: EventDriverContainer): void; dispatch = any>(event: T): void | boolean; subscribe = any>(subscriber: ISubscriber): void; addEventListener(type: K, listener: (this: HTMLElement, ev: HTMLElementEventMap[K]) => any, options?: boolean | EventOptions): void; addEventListener(type: string, listener: EventListenerOrEventListenerObject, options?: boolean | EventOptions): void; addEventListener(type: any, listener: any, options: any): void; removeEventListener(type: K, listener: (this: HTMLElement, ev: HTMLElementEventMap[K]) => any, options?: boolean | EventOptions): void; removeEventListener(type: string, listener: EventListenerOrEventListenerObject, options?: boolean | EventOptions): void; removeEventListener(type: any, listener: any, options?: any): void; batchAddEventListener(type: K, listener: (this: HTMLElement, ev: HTMLElementEventMap[K]) => any, options?: boolean | EventOptions): void; batchAddEventListener(type: string, listener: EventListenerOrEventListenerObject, options?: boolean | EventOptions): void; batchAddEventListener(type: any, listener: any, options?: any): void; batchRemoveEventListener(type: K, listener: (this: HTMLElement, ev: HTMLElementEventMap[K]) => any, options?: boolean | EventOptions): void; batchRemoveEventListener(type: string, listener: EventListenerOrEventListenerObject, options?: boolean | EventOptions): void; batchRemoveEventListener(type: any, listener: any, options: any): void; } export interface IEventDriverClass { new (engine: T, context?: any): IEventDriver; } export interface ICustomEvent { type: string; data?: EventData; context?: EventContext; } export interface CustomEventClass { new (...args: any[]): any; } export interface IEventProps { drivers?: IEventDriverClass[]; effects?: IEventEffect[]; } /** * 事件驱动器基类 */ export declare class EventDriver implements IEventDriver { engine: Engine; container: EventDriverContainer; contentWindow: Window; context: Context; constructor(engine: Engine, context?: Context); dispatch = any>(event: T): boolean; subscribe = any>(subscriber: ISubscriber): () => void; subscribeTo(type: T, subscriber: ISubscriber>): () => void; subscribeWith(type: string | string[], subscriber: ISubscriber): () => void; attach(container: EventDriverContainer): void; detach(container: EventDriverContainer): void; eventTarget(type: string): EventContainer; addEventListener(type: K, listener: (this: HTMLElement, ev: HTMLElementEventMap[K]) => any, options?: boolean | EventOptions): void; addEventListener(type: string, listener: EventListenerOrEventListenerObject, options?: boolean | EventOptions): void; removeEventListener(type: K, listener: (this: HTMLElement, ev: HTMLElementEventMap[K]) => any, options?: boolean | EventOptions): void; removeEventListener(type: string, listener: EventListenerOrEventListenerObject, options?: boolean | EventOptions): void; batchAddEventListener(type: K, listener: (this: HTMLElement, ev: HTMLElementEventMap[K]) => any, options?: boolean | EventOptions): void; batchAddEventListener(type: string, listener: EventListenerOrEventListenerObject, options?: boolean | EventOptions): void; batchRemoveEventListener(type: K, listener: (this: HTMLElement, ev: HTMLElementEventMap[K]) => any, options?: boolean | EventOptions): void; batchRemoveEventListener(type: string, listener: EventListenerOrEventListenerObject, options?: boolean | EventOptions): void; } /** * 事件引擎 */ export declare class Event extends Subscribable> { private drivers; private containers; constructor(props?: IEventProps); subscribeTo(type: T, subscriber: ISubscriber>): () => void; subscribeWith(type: string | string[], subscriber: ISubscriber): () => void; attachEvents(container: EventContainer, contentWindow?: Window, context?: any): any; detachEvents(container?: EventContainer): any; }