UNPKG

1.68 kBTypeScriptView Raw
1import type { PluginListenerHandle, Plugin } from './definitions';
2import type { CapacitorException } from './util';
3/**
4 * Base class web plugins should extend.
5 */
6export declare class WebPlugin implements Plugin {
7 /**
8 * @deprecated WebPluginConfig deprecated in v3 and will be removed in v4.
9 */
10 config?: WebPluginConfig;
11 protected listeners: {
12 [eventName: string]: ListenerCallback[];
13 };
14 protected windowListeners: {
15 [eventName: string]: WindowListenerHandle;
16 };
17 constructor(config?: WebPluginConfig);
18 addListener(eventName: string, listenerFunc: ListenerCallback): Promise<PluginListenerHandle> & PluginListenerHandle;
19 removeAllListeners(): Promise<void>;
20 protected notifyListeners(eventName: string, data: any): void;
21 protected hasListeners(eventName: string): boolean;
22 protected registerWindowListener(windowEventName: string, pluginEventName: string): void;
23 protected unimplemented(msg?: string): CapacitorException;
24 protected unavailable(msg?: string): CapacitorException;
25 private removeListener;
26 private addWindowListener;
27 private removeWindowListener;
28}
29export declare type ListenerCallback = (err: any, ...args: any[]) => void;
30export interface WindowListenerHandle {
31 registered: boolean;
32 windowEventName: string;
33 pluginEventName: string;
34 handler: (event: any) => void;
35}
36/**
37 * @deprecated Deprecated in v3, removing in v4.
38 */
39export interface WebPluginConfig {
40 /**
41 * @deprecated Deprecated in v3, removing in v4.
42 */
43 readonly name: string;
44 /**
45 * @deprecated Deprecated in v3, removing in v4.
46 */
47 platforms?: string[];
48}