1 | import type { CapacitorGlobal, PluginCallback, PluginResultData, PluginResultError } from './definitions';
|
2 | import type { CapacitorPlatformsInstance } from './platforms';
|
3 | export interface PluginHeaderMethod {
|
4 | readonly name: string;
|
5 | readonly rtype?: 'promise' | 'callback';
|
6 | }
|
7 | export interface PluginHeader {
|
8 | readonly name: string;
|
9 | readonly methods: readonly PluginHeaderMethod[];
|
10 | }
|
11 |
|
12 |
|
13 |
|
14 |
|
15 |
|
16 | export interface CapacitorInstance extends CapacitorGlobal {
|
17 | |
18 |
|
19 |
|
20 |
|
21 |
|
22 |
|
23 | Plugins: {
|
24 | [pluginName: string]: {
|
25 | [prop: string]: any;
|
26 | };
|
27 | };
|
28 | PluginHeaders?: readonly PluginHeader[];
|
29 | |
30 |
|
31 |
|
32 |
|
33 | getServerUrl: () => string;
|
34 | |
35 |
|
36 |
|
37 |
|
38 |
|
39 | toNative?: (pluginName: string, methodName: string, options: any, storedCallback?: StoredCallback) => string;
|
40 | |
41 |
|
42 |
|
43 |
|
44 | nativeCallback: <O>(pluginName: string, methodName: string, options?: O, callback?: PluginCallback) => string;
|
45 | |
46 |
|
47 |
|
48 |
|
49 |
|
50 | nativePromise: <O, R>(pluginName: string, methodName: string, options?: O) => Promise<R>;
|
51 | |
52 |
|
53 |
|
54 |
|
55 | fromNative?: (result: PluginResult) => void;
|
56 | |
57 |
|
58 |
|
59 | createEvent?: (eventName: string, eventData?: any) => Event;
|
60 | |
61 |
|
62 |
|
63 | triggerEvent?: (eventName: string, target: string, eventData?: any) => boolean;
|
64 | handleError: (err: Error) => void;
|
65 | handleWindowError: (msg: string | Event, url: string, lineNo: number, columnNo: number, err: Error) => void;
|
66 | |
67 |
|
68 |
|
69 | logJs: (message: string, level: 'error' | 'warn' | 'info' | 'log') => void;
|
70 | logToNative: (data: MessageCallData) => void;
|
71 | logFromNative: (results: PluginResult) => void;
|
72 | |
73 |
|
74 |
|
75 | withPlugin?: (pluginName: string, fn: (...args: any[]) => any) => void;
|
76 | }
|
77 | export interface MessageCallData {
|
78 | type?: 'message';
|
79 | callbackId: string;
|
80 | pluginId: string;
|
81 | methodName: string;
|
82 | options: any;
|
83 | }
|
84 | export interface ErrorCallData {
|
85 | type: 'js.error';
|
86 | error: {
|
87 | message: string;
|
88 | url: string;
|
89 | line: number;
|
90 | col: number;
|
91 | errorObject: string;
|
92 | };
|
93 | }
|
94 | export declare type CallData = MessageCallData | ErrorCallData;
|
95 |
|
96 |
|
97 |
|
98 | export interface PluginResult {
|
99 | callbackId?: string;
|
100 | methodName?: string;
|
101 | data: PluginResultData;
|
102 | success: boolean;
|
103 | error?: PluginResultError;
|
104 | pluginId?: string;
|
105 | save?: boolean;
|
106 | }
|
107 |
|
108 |
|
109 |
|
110 |
|
111 | export interface StoredCallback {
|
112 | callback?: PluginCallback;
|
113 | resolve?: (...args: any[]) => any;
|
114 | reject?: (...args: any[]) => any;
|
115 | }
|
116 | export interface CapacitorCustomPlatformInstance {
|
117 | name: string;
|
118 | plugins: {
|
119 | [pluginName: string]: any;
|
120 | };
|
121 | }
|
122 | export interface WindowCapacitor {
|
123 | Capacitor?: CapacitorInstance;
|
124 | |
125 |
|
126 |
|
127 | CapacitorPlatforms?: CapacitorPlatformsInstance;
|
128 | CapacitorCustomPlatform?: CapacitorCustomPlatformInstance;
|
129 | Ionic?: {
|
130 | WebView?: {
|
131 | getServerBasePath?: any;
|
132 | setServerBasePath?: any;
|
133 | persistServerBasePath?: any;
|
134 | convertFileSrc?: any;
|
135 | };
|
136 | };
|
137 | WEBVIEW_SERVER_URL?: string;
|
138 | androidBridge?: {
|
139 | postMessage(data: string): void;
|
140 | };
|
141 | webkit?: {
|
142 | messageHandlers?: {
|
143 | bridge: {
|
144 | postMessage(data: any): void;
|
145 | };
|
146 | };
|
147 | };
|
148 | console?: Console;
|
149 | cordova?: {
|
150 | fireDocumentEvent?: (eventName: string, eventData: any) => void;
|
151 | };
|
152 | dispatchEvent?: any;
|
153 | document?: any;
|
154 | navigator?: {
|
155 | app?: {
|
156 | exitApp?: () => void;
|
157 | };
|
158 | };
|
159 | }
|