main-c55d8855.d.ts 1.5 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950
  1. interface Config {
  2. page: 'manager' | 'preview';
  3. }
  4. type ChannelHandler = (event: ChannelEvent) => void;
  5. interface ChannelTransport {
  6. send(event: ChannelEvent, options?: any): void;
  7. setHandler(handler: ChannelHandler): void;
  8. }
  9. interface ChannelEvent {
  10. type: string;
  11. from: string;
  12. args: any[];
  13. }
  14. interface Listener {
  15. (...args: any[]): void;
  16. }
  17. interface ChannelArgsSingle {
  18. transport?: ChannelTransport;
  19. async?: boolean;
  20. }
  21. interface ChannelArgsMulti {
  22. transports: ChannelTransport[];
  23. async?: boolean;
  24. }
  25. declare class Channel {
  26. readonly isAsync: boolean;
  27. private sender;
  28. private events;
  29. private data;
  30. private readonly transports;
  31. constructor(input: ChannelArgsMulti);
  32. constructor(input: ChannelArgsSingle);
  33. get hasTransport(): boolean;
  34. addListener(eventName: string, listener: Listener): void;
  35. emit(eventName: string, ...args: any): void;
  36. last(eventName: string): any;
  37. eventNames(): string[];
  38. listenerCount(eventName: string): number;
  39. listeners(eventName: string): Listener[] | undefined;
  40. once(eventName: string, listener: Listener): void;
  41. removeAllListeners(eventName?: string): void;
  42. removeListener(eventName: string, listener: Listener): void;
  43. on(eventName: string, listener: Listener): void;
  44. off(eventName: string, listener: Listener): void;
  45. private handleEvent;
  46. private onceListener;
  47. }
  48. export { Channel as C, Listener as L, Config as a, ChannelTransport as b, ChannelEvent as c, ChannelHandler as d };