UNPKG

4.31 kBTypeScriptView Raw
1// Type definitions for Apache Cordova
2// Project: http://cordova.apache.org
3// Definitions by: Microsoft Open Technologies Inc <http://msopentech.com>
4// Definitions: https://github.com/DefinitelyTyped/DefinitelyTyped
5//
6// Copyright (c) Microsoft Open Technologies Inc
7// Licensed under the MIT license.
8
9
10
11interface Cordova {
12 /** Invokes native functionality by specifying corresponding service name, action and optional parameters.
13 * @param success A success callback function.
14 * @param fail An error callback function.
15 * @param service The service name to call on the native side (corresponds to a native class).
16 * @param action The action name to call on the native side (generally corresponds to the native class method).
17 * @param args An array of arguments to pass into the native environment.
18 */
19 exec(success: (data: any) => any, fail: (err: any) => any, service: string, action: string, args?: any[]): void;
20 /** Gets the operating system name. */
21 platformId: string;
22 /** Gets Cordova framework version */
23 version: string;
24 /** Defines custom logic as a Cordova module. Other modules can later access it using module name provided. */
25 define(moduleName: string, factory: (require: any, exports: any, module: any) => any): void;
26 /** Access a Cordova module by name. */
27 require(moduleName: string): any;
28 /** Namespace for Cordova plugin functionality */
29 plugins:CordovaPlugins;
30}
31
32interface CordovaPlugins {}
33
34interface Document {
35 addEventListener(type: "deviceready", listener: (ev: Event) => any, useCapture?: boolean): void;
36 addEventListener(type: "pause", listener: (ev: Event) => any, useCapture?: boolean): void;
37 addEventListener(type: "resume", listener: (ev: Event) => any, useCapture?: boolean): void;
38 addEventListener(type: "backbutton", listener: (ev: Event) => any, useCapture?: boolean): void;
39 addEventListener(type: "menubutton", listener: (ev: Event) => any, useCapture?: boolean): void;
40 addEventListener(type: "searchbutton", listener: (ev: Event) => any, useCapture?: boolean): void;
41 addEventListener(type: "startcallbutton", listener: (ev: Event) => any, useCapture?: boolean): void;
42 addEventListener(type: "endcallbutton", listener: (ev: Event) => any, useCapture?: boolean): void;
43 addEventListener(type: "volumedownbutton", listener: (ev: Event) => any, useCapture?: boolean): void;
44 addEventListener(type: "volumeupbutton", listener: (ev: Event) => any, useCapture?: boolean): void;
45
46 removeEventListener(type: "deviceready", listener: (ev: Event) => any, useCapture?: boolean): void;
47 removeEventListener(type: "pause", listener: (ev: Event) => any, useCapture?: boolean): void;
48 removeEventListener(type: "resume", listener: (ev: Event) => any, useCapture?: boolean): void;
49 removeEventListener(type: "backbutton", listener: (ev: Event) => any, useCapture?: boolean): void;
50 removeEventListener(type: "menubutton", listener: (ev: Event) => any, useCapture?: boolean): void;
51 removeEventListener(type: "searchbutton", listener: (ev: Event) => any, useCapture?: boolean): void;
52 removeEventListener(type: "startcallbutton", listener: (ev: Event) => any, useCapture?: boolean): void;
53 removeEventListener(type: "endcallbutton", listener: (ev: Event) => any, useCapture?: boolean): void;
54 removeEventListener(type: "volumedownbutton", listener: (ev: Event) => any, useCapture?: boolean): void;
55 removeEventListener(type: "volumeupbutton", listener: (ev: Event) => any, useCapture?: boolean): void;
56
57 addEventListener(type: string, listener: (ev: Event) => any, useCapture?: boolean): void;
58 removeEventListener(type: string, listener: (ev: Event) => any, useCapture?: boolean): void;
59}
60
61interface Window {
62 cordova:Cordova;
63}
64
65// cordova/argscheck module
66interface ArgsCheck {
67 checkArgs(argsSpec: string, functionName: string, args: any[], callee?: any): void;
68 getValue(value?: any, defaultValue?: any): any;
69 enableChecks: boolean;
70}
71
72// cordova/urlutil module
73interface UrlUtil {
74 makeAbsolute(url: string): string
75}
76
77/** Apache Cordova instance */
78declare var cordova: Cordova;
79
80declare module 'cordova' {
81 export = cordova;
82}