UNPKG

1.8 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 retainedEventArguments: {
15 [eventName: string]: any[];
16 };
17 protected windowListeners: {
18 [eventName: string]: WindowListenerHandle;
19 };
20 constructor(config?: WebPluginConfig);
21 addListener(eventName: string, listenerFunc: ListenerCallback): Promise<PluginListenerHandle>;
22 removeAllListeners(): Promise<void>;
23 protected notifyListeners(eventName: string, data: any, retainUntilConsumed?: boolean): void;
24 protected hasListeners(eventName: string): boolean;
25 protected registerWindowListener(windowEventName: string, pluginEventName: string): void;
26 protected unimplemented(msg?: string): CapacitorException;
27 protected unavailable(msg?: string): CapacitorException;
28 private removeListener;
29 private addWindowListener;
30 private removeWindowListener;
31 private sendRetainedArgumentsForEvent;
32}
33export type ListenerCallback = (err: any, ...args: any[]) => void;
34export interface WindowListenerHandle {
35 registered: boolean;
36 windowEventName: string;
37 pluginEventName: string;
38 handler: (event: any) => void;
39}
40/**
41 * @deprecated Deprecated in v3, removing in v4.
42 */
43export interface WebPluginConfig {
44 /**
45 * @deprecated Deprecated in v3, removing in v4.
46 */
47 readonly name: string;
48 /**
49 * @deprecated Deprecated in v3, removing in v4.
50 */
51 platforms?: string[];
52}