cordova.d.ts 4.1 KB

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