UNPKG

3.3 kBTypeScriptView Raw
1export interface PluginConfig {
2 /**
3 * Plugin name, this should match the class name
4 */
5 pluginName: string;
6 /**
7 * Plugin NPM package name
8 */
9 plugin: string;
10 /**
11 * Plugin object reference
12 */
13 pluginRef?: string;
14 /**
15 * Github repository URL
16 */
17 repo?: string;
18 /**
19 * Custom install command
20 */
21 install?: string;
22 /**
23 * Available installation variables
24 */
25 installVariables?: string[];
26 /**
27 * Supported platforms
28 */
29 platforms?: string[];
30 [key: string]: any;
31}
32export interface CordovaOptions {
33 destruct?: boolean;
34 /**
35 * If the method-name of the cordova plugin is different from the wrappers one, it can be defined here
36 */
37 methodName?: string;
38 /**
39 * Set to true if the wrapped method is a sync function
40 */
41 sync?: boolean;
42 /**
43 * Callback order. Set to reverse if the success/error callbacks are the first 2 arguments that the wrapped method
44 * takes.
45 */
46 callbackOrder?: 'reverse';
47 /**
48 * Callback style
49 */
50 callbackStyle?: 'node' | 'object';
51 /**
52 * Set a custom index for the success callback function. This doesn't work if callbackOrder or callbackStyle are set.
53 */
54 successIndex?: number;
55 /**
56 * Set a custom index for the error callback function. This doesn't work if callbackOrder or callbackStyle are set.
57 */
58 errorIndex?: number;
59 /**
60 * Success function property name. This must be set if callbackStyle is set to object.
61 */
62 successName?: string;
63 /**
64 * Error function property name. This must be set if callbackStyle is set to object.
65 */
66 errorName?: string;
67 /**
68 * Set to true to return an observable
69 */
70 observable?: boolean;
71 /**
72 * If observable is set to true, this can be set to a different function name that will cancel the observable.
73 */
74 clearFunction?: string;
75 /**
76 * This can be used if clearFunction is set. Set this to true to call the clearFunction with the same arguments used
77 * in the initial function.
78 */
79 clearWithArgs?: boolean;
80 /**
81 * Creates an observable that wraps a global event. Replaces document.addEventListener
82 */
83 eventObservable?: boolean;
84 /**
85 * Event name, this must be set if eventObservable is set to true
86 */
87 event?: string;
88 /**
89 * Element to attach the event listener to, this is optional, defaults to `window`
90 */
91 element?: any;
92 /**
93 * Set to true if the wrapped method returns a promise
94 */
95 otherPromise?: boolean;
96 /**
97 * Supported platforms
98 */
99 platforms?: string[];
100}
101export declare const Plugin: (config: PluginConfig) => ClassDecorator;
102export declare const Cordova: (config?: CordovaOptions) => MethodDecorator;
103export declare const CordovaProperty: () => PropertyDecorator;
104export declare const CordovaInstance: (config?: CordovaOptions) => MethodDecorator;
105export declare const InstanceProperty: () => PropertyDecorator;
106export declare const CordovaCheck: (config?: CordovaOptions) => MethodDecorator;
107export declare const InstanceCheck: (config?: CordovaOptions) => MethodDecorator;
108export declare const CordovaFunctionOverride: () => MethodDecorator;