CB-12369: Add plugin typings from DefinitelyTyped

This closes #53
This commit is contained in:
Nikita Matrosov 2017-01-19 16:10:44 +03:00 committed by Vladimir Kotikov
parent 30e219aa95
commit d8c1b0b503
2 changed files with 63 additions and 0 deletions

View File

@ -2,6 +2,7 @@
"name": "cordova-plugin-network-information",
"version": "1.3.2-dev",
"description": "Cordova Network Information Plugin",
"types": "./types/index.d.ts",
"cordova": {
"id": "cordova-plugin-network-information",
"platforms": [

62
types/index.d.ts vendored Normal file
View File

@ -0,0 +1,62 @@
// Type definitions for Apache Cordova Network Information plugin
// Project: https://github.com/apache/cordova-plugin-network-information
// Definitions by: Microsoft Open Technologies Inc <http://msopentech.com>
// Definitions: https://github.com/DefinitelyTyped/DefinitelyTyped
//
// Copyright (c) Microsoft Open Technologies Inc
// Licensed under the MIT license
interface Navigator {
/**
* This plugin provides an implementation of an old version of the Network Information API.
* It provides information about the device's cellular and wifi connection, and whether the device has an internet connection.
*/
connection: Connection;
// see https://github.com/apache/cordova-plugin-network-information/blob/dev/doc/index.md#api-change
// for
network: {
/**
* This plugin provides an implementation of an old version of the Network Information API.
* It provides information about the device's cellular and wifi connection, and whether the device has an internet connection.
*/
connection: Connection
}
}
interface Document {
addEventListener(type: "online", connectionStateCallback: () => any, useCapture?: boolean): void;
addEventListener(type: "offline", connectionStateCallback: () => any, useCapture?: boolean): void;
}
/**
* The connection object, exposed via navigator.connection, provides information
* about the device's cellular and wifi connection.
*/
interface Connection {
/**
* This property offers a fast way to determine the device's network connection state, and type of connection.
* One of:
* Connection.UNKNOWN
* Connection.ETHERNET
* Connection.WIFI
* Connection.CELL_2G
* Connection.CELL_3G
* Connection.CELL_4G
* Connection.CELL
* Connection.NONE
*/
type: string;
addEventListener(type: string, listener: EventListenerOrEventListenerObject, useCapture?: boolean): void;
removeEventListener(type: string, listener: EventListenerOrEventListenerObject, useCapture?: boolean): void;
}
declare var Connection: {
UNKNOWN: string;
ETHERNET: string;
WIFI: string;
CELL_2G: string;
CELL_3G: string;
CELL_4G: string;
CELL: string;
NONE: string;
}