@ionic-native/network
Advanced tools
Comparing version 4.4.2 to 5.0.0-alpha.3
@@ -47,3 +47,3 @@ import { IonicNativePlugin } from '@ionic-native/core'; | ||
*/ | ||
export declare class Network extends IonicNativePlugin { | ||
export declare class NetworkOriginal extends IonicNativePlugin { | ||
/** | ||
@@ -75,1 +75,3 @@ * Connection type | ||
} | ||
export declare const Network: NetworkOriginal; |
151
index.js
@@ -11,129 +11,38 @@ var __extends = (this && this.__extends) || (function () { | ||
})(); | ||
var __decorate = (this && this.__decorate) || function (decorators, target, key, desc) { | ||
var c = arguments.length, r = c < 3 ? target : desc === null ? desc = Object.getOwnPropertyDescriptor(target, key) : desc, d; | ||
if (typeof Reflect === "object" && typeof Reflect.decorate === "function") r = Reflect.decorate(decorators, target, key, desc); | ||
else for (var i = decorators.length - 1; i >= 0; i--) if (d = decorators[i]) r = (c < 3 ? d(r) : c > 3 ? d(target, key, r) : d(target, key)) || r; | ||
return c > 3 && r && Object.defineProperty(target, key, r), r; | ||
}; | ||
var __metadata = (this && this.__metadata) || function (k, v) { | ||
if (typeof Reflect === "object" && typeof Reflect.metadata === "function") return Reflect.metadata(k, v); | ||
}; | ||
import { Injectable } from '@angular/core'; | ||
import { Cordova, CordovaProperty, Plugin, CordovaCheck, IonicNativePlugin } from '@ionic-native/core'; | ||
import { IonicNativePlugin, cordova, checkAvailability, cordovaPropertyGet, cordovaPropertySet, injectable } from '@ionic-native/core'; | ||
import { Observable } from 'rxjs/Observable'; | ||
import 'rxjs/add/observable/merge'; | ||
/** | ||
* @name Network | ||
* @description | ||
* Requires Cordova plugin: cordova-plugin-network-information. For more info, please see the [Network plugin docs](https://github.com/apache/cordova-plugin-network-information). | ||
* | ||
* @usage | ||
* ```typescript | ||
* import { Network } from '@ionic-native/network'; | ||
* | ||
* constructor(private network: Network) { } | ||
* | ||
* ... | ||
* | ||
* // watch network for a disconnect | ||
* let disconnectSubscription = this.network.onDisconnect().subscribe(() => { | ||
* console.log('network was disconnected :-('); | ||
* }); | ||
* | ||
* // stop disconnect watch | ||
* disconnectSubscription.unsubscribe(); | ||
* | ||
* | ||
* // watch network for a connection | ||
* let connectSubscription = this.network.onConnect().subscribe(() => { | ||
* console.log('network connected!'); | ||
* // We just got a connection but we need to wait briefly | ||
* | ||
// before we determine the connection type. Might need to wait. | ||
* // prior to doing any api requests as well. | ||
* setTimeout(() => { | ||
* if (this.network.type === 'wifi') { | ||
* console.log('we got a wifi connection, woohoo!'); | ||
* } | ||
* }, 3000); | ||
* }); | ||
* | ||
* // stop connect watch | ||
* connectSubscription.unsubscribe(); | ||
* | ||
* ``` | ||
* @advanced | ||
* The `type` property will return one of the following connection types: `unknown`, `ethernet`, `wifi`, `2g`, `3g`, `4g`, `cellular`, `none` | ||
*/ | ||
var Network = (function (_super) { | ||
var NetworkOriginal = /** @class */ (function (_super) { | ||
__extends(Network, _super); | ||
function Network() { | ||
function NetworkOriginal() { | ||
return _super !== null && _super.apply(this, arguments) || this; | ||
} | ||
/** | ||
* Returns an observable to watch connection changes | ||
* @return {Observable<any>} | ||
*/ | ||
Network.prototype.onchange = function () { | ||
return Observable.merge(this.onConnect(), this.onDisconnect()); | ||
}; | ||
/** | ||
* Get notified when the device goes offline | ||
* @returns {Observable<any>} Returns an observable. | ||
*/ | ||
Network.prototype.onDisconnect = function () { return; }; | ||
/** | ||
* Get notified when the device goes online | ||
* @returns {Observable<any>} Returns an observable. | ||
*/ | ||
Network.prototype.onConnect = function () { return; }; | ||
Network.decorators = [ | ||
{ type: Injectable }, | ||
]; | ||
/** @nocollapse */ | ||
Network.ctorParameters = function () { return []; }; | ||
__decorate([ | ||
CordovaProperty, | ||
__metadata("design:type", String) | ||
], Network.prototype, "type", void 0); | ||
__decorate([ | ||
CordovaProperty, | ||
__metadata("design:type", String) | ||
], Network.prototype, "downlinkMax", void 0); | ||
__decorate([ | ||
CordovaCheck(), | ||
__metadata("design:type", Function), | ||
__metadata("design:paramtypes", []), | ||
__metadata("design:returntype", Observable) | ||
], Network.prototype, "onchange", null); | ||
__decorate([ | ||
Cordova({ | ||
eventObservable: true, | ||
event: 'offline' | ||
}), | ||
__metadata("design:type", Function), | ||
__metadata("design:paramtypes", []), | ||
__metadata("design:returntype", Observable) | ||
], Network.prototype, "onDisconnect", null); | ||
__decorate([ | ||
Cordova({ | ||
eventObservable: true, | ||
event: 'online' | ||
}), | ||
__metadata("design:type", Function), | ||
__metadata("design:paramtypes", []), | ||
__metadata("design:returntype", Observable) | ||
], Network.prototype, "onConnect", null); | ||
Network = __decorate([ | ||
Plugin({ | ||
pluginName: 'Network', | ||
plugin: 'cordova-plugin-network-information', | ||
pluginRef: 'navigator.connection', | ||
repo: 'https://github.com/apache/cordova-plugin-network-information', | ||
platforms: ['Amazon Fire OS', 'Android', 'BlackBerry 10', 'Browser', 'Firefox OS', 'iOS', 'Tizen', 'Ubuntu', 'Windows', 'Windows Phone'] | ||
}) | ||
], Network); | ||
return Network; | ||
NetworkOriginal.prototype.onchange = function () { return function () { | ||
if (checkAvailability(this) === true) { | ||
return Observable.merge(this.onConnect(), this.onDisconnect()); | ||
} | ||
}(); }; | ||
NetworkOriginal.prototype.onDisconnect = function () { return cordova(this, "onDisconnect", { "eventObservable": true, "event": "offline" }, arguments); }; | ||
NetworkOriginal.prototype.onConnect = function () { return cordova(this, "onConnect", { "eventObservable": true, "event": "online" }, arguments); }; | ||
Object.defineProperty NetworkOriginal.prototype, "type", { | ||
get: function () { return cordovaPropertyGet(this, "type"); }, | ||
set: function (value) { cordovaPropertySet(this, "type", value); }, | ||
enumerable: true, | ||
configurable: true | ||
}); | ||
Object.defineProperty NetworkOriginal.prototype, "downlinkMax", { | ||
get: function () { return cordovaPropertyGet(this, "downlinkMax"); }, | ||
set: function (value) { cordovaPropertySet(this, "downlinkMax", value); }, | ||
enumerable: true, | ||
configurable: true | ||
}); | ||
NetworkOriginal.pluginName = "Network"; | ||
NetworkOriginal.plugin = "cordova-plugin-network-information"; | ||
NetworkOriginal.pluginRef = "navigator.connection"; | ||
NetworkOriginal.repo = "https://github.com/apache/cordova-plugin-network-information"; | ||
NetworkOriginal.platforms = ["Amazon Fire OS", "Android", "BlackBerry 10", "Browser", "Firefox OS", "iOS", "Tizen", "Ubuntu", "Windows", "Windows Phone"]; | ||
return NetworkOriginal; | ||
}(IonicNativePlugin)); | ||
var Network = new NetworkOriginal(); | ||
export { Network }; | ||
//# sourceMappingURL=index.js.map | ||
//# sourceMappingURL=data:application/json;base64,eyJ2ZXJzaW9uIjozLCJmaWxlIjoiaW5kZXguanMiLCJzb3VyY2VSb290IjoiIiwic291cmNlcyI6WyIuLi8uLi8uLi9zcmMvcGx1Z2lucy9uZXR3b3JrL2luZGV4LnRzIl0sIm5hbWVzIjpbXSwibWFwcGluZ3MiOiI7Ozs7Ozs7Ozs7QUFDQSxPQUFPLHFHQUFxRSxNQUFNLG9CQUFvQixDQUFDO0FBQ3ZHLE9BQU8sRUFBRSxVQUFVLEVBQUUsTUFBTSxpQkFBaUIsQ0FBQztBQUM3QyxPQUFPLDJCQUEyQixDQUFDOztJQXdETiwyQkFBaUI7Ozs7SUFxQjVDLDBCQUFROzhDQUFvQixDQUFDO1lBQzNCLE1BQU0sQ0FBQyxVQUFVLENBQUMsS0FBSyxDQUFDLElBQUksQ0FBQyxTQUFTLEVBQUUsRUFBRSxJQUFJLENBQUMsWUFBWSxFQUFFLENBQUMsQ0FBQztRQUNqRSxDQUFDOztJQVVELDhCQUFZO0lBVVosMkJBQVM7MEJBcENULHlCQUFJOzs7Ozs7MEJBT0osZ0NBQVc7Ozs7Ozs7Ozs7O2tCQXpFYjtFQTJENkIsaUJBQWlCO1NBQWpDLE9BQU8iLCJzb3VyY2VzQ29udGVudCI6WyJpbXBvcnQgeyBJbmplY3RhYmxlIH0gZnJvbSAnQGFuZ3VsYXIvY29yZSc7XG5pbXBvcnQgeyBDb3Jkb3ZhLCBDb3Jkb3ZhUHJvcGVydHksIFBsdWdpbiwgQ29yZG92YUNoZWNrLCBJb25pY05hdGl2ZVBsdWdpbiB9IG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2YWJsZTxhbnk+fSBSZXR1cm5zIGFuIG9ic2VydmFibGUuXG4gICAqL1xuICBAQ29yZG92YSh7XG4gICAgZXZlbnRPYnNlcnZhYmxlOiB0cnVlLFxuICAgIGV2ZW50OiAnb2ZmbGluZSdcbiAgfSlcbiAgb25EaXNjb25uZWN0KCk6IE9ic2VydmFibGU8YW55PiB7IHJldHVybjsgfVxuXG4gIC8qKlxuICAgKiBHZXQgbm90aWZpZWQgd2hlbiB0aGUgZGV2aWNlIGdvZXMgb25saW5lXG4gICAqIEByZXR1cm5zIHtPYnNlcnZhYmxlPGFueT59IFJldHVybnMgYW4gb2JzZXJ2YWJsZS5cbiAgICovXG4gIEBDb3Jkb3ZhKHtcbiAgICBldmVudE9ic2VydmFibGU6IHRydWUsXG4gICAgZXZlbnQ6ICdvbmxpbmUnXG4gIH0pXG4gIG9uQ29ubmVjdCgpOiBPYnNlcnZhYmxlPGFueT4geyByZXR1cm47IH1cblxufVxuIl19 |
@@ -1,18 +0,1 @@ | ||
{ | ||
"name": "@ionic-native/network", | ||
"version": "4.4.2", | ||
"description": "Ionic Native - Native plugins for ionic apps", | ||
"module": "index.js", | ||
"typings": "index.d.ts", | ||
"author": "ionic", | ||
"license": "MIT", | ||
"peerDependencies": { | ||
"@ionic-native/core": "^4.2.0", | ||
"@angular/core": "*", | ||
"rxjs": "^5.0.1" | ||
}, | ||
"repository": { | ||
"type": "git", | ||
"url": "https://github.com/ionic-team/ionic-native.git" | ||
} | ||
} | ||
{"description":"Ionic Native - Native plugins for ionic apps","module":"index.js","typings":"index.d.ts","author":"ionic","license":"MIT","repository":{"type":"git","url":"https://github.com/ionic-team/ionic-native.git"},"name":"@ionic-native/network","peerDependencies":{"rxjs":"^5.0.1","@ionic-native/core":"5.0.0-alpha.3"},"version":"5.0.0-alpha.3"} |
License Policy Violation
LicenseThis package is not allowed per your license policy. Review the package's license to ensure compliance.
Found 1 instance in 1 package
Major refactor
Supply chain riskPackage has recently undergone a major refactor. It may be unstable or indicate significant internal changes. Use caution when updating to versions that include significant changes.
Found 1 instance in 1 package
No README
QualityPackage does not have a README. This may indicate a failed publish or a low quality package.
Found 1 instance in 1 package
No v1
QualityPackage is not semver >=1. This means it is not stable and does not support ^ ranges.
Found 1 instance in 1 package
License Policy Violation
LicenseThis package is not allowed per your license policy. Review the package's license to ensure compliance.
Found 1 instance in 1 package
20303
2
250
2
1
0
1