mirror of
https://github.com/danielsogl/awesome-cordova-plugins.git
synced 2026-02-04 00:06:19 +08:00
Compare commits
12 Commits
| Author | SHA1 | Date | |
|---|---|---|---|
|
|
4aec187e8c | ||
|
|
d9188446a0 | ||
|
|
7ae6e10375 | ||
|
|
ea53a1923a | ||
|
|
f45f34442a | ||
|
|
49de11e761 | ||
|
|
c29aaca857 | ||
|
|
9241339b2c | ||
|
|
9c8b0ceda6 | ||
|
|
78c226e83d | ||
|
|
ef148d2a68 | ||
|
|
7fa2f7f364 |
@@ -1,6 +1,6 @@
|
||||
{
|
||||
"name": "ionic-native",
|
||||
"version": "2.2.10",
|
||||
"version": "2.2.11",
|
||||
"description": "Native plugin wrappers for Cordova and Ionic with TypeScript, ES6+, Promise and Observable support",
|
||||
"main": "dist/es5/index.js",
|
||||
"module": "dist/esm/index.js",
|
||||
|
||||
@@ -24,7 +24,8 @@ function run {
|
||||
cd $SITE_DIR
|
||||
|
||||
# if no changes, don't commit
|
||||
if [[ `git status --porcelain` ]]; then
|
||||
if ! git diff-index --quiet HEAD --
|
||||
then
|
||||
echo "-- No changes detected for the following commit, docs not updated."
|
||||
echo "https://github.com/driftyco/$CIRCLE_PROJECT_REPONAME/commit/$CIRCLE_SHA1"
|
||||
else
|
||||
@@ -37,7 +38,7 @@ function run {
|
||||
git fetch
|
||||
git rebase
|
||||
|
||||
git push origin master
|
||||
git push origin master || :
|
||||
|
||||
echo "-- Updated docs for $VERSION_NAME succesfully!"
|
||||
fi
|
||||
|
||||
@@ -1,33 +1,7 @@
|
||||
import { CordovaProperty, Plugin } from './plugin';
|
||||
|
||||
|
||||
declare var window: any;
|
||||
|
||||
/**
|
||||
* @private
|
||||
*/
|
||||
export interface IDevice {
|
||||
/** Get the version of Cordova running on the device. */
|
||||
cordova: string;
|
||||
/**
|
||||
* The device.model returns the name of the device's model or product. The value is set
|
||||
* by the device manufacturer and may be different across versions of the same product.
|
||||
*/
|
||||
model: string;
|
||||
/** Get the device's operating system name. */
|
||||
platform: string;
|
||||
/** Get the device's Universally Unique Identifier (UUID). */
|
||||
uuid: string;
|
||||
/** Get the operating system version. */
|
||||
version: string;
|
||||
/** Get the device's manufacturer. */
|
||||
manufacturer: string;
|
||||
/** Whether the device is running on a simulator. */
|
||||
isVirtual: boolean;
|
||||
/** Get the device hardware serial number. */
|
||||
serial: string;
|
||||
}
|
||||
|
||||
/**
|
||||
* @name Device
|
||||
* @description
|
||||
@@ -38,7 +12,7 @@ export interface IDevice {
|
||||
* import { Device } from 'ionic-native';
|
||||
*
|
||||
*
|
||||
* console.log('Device UUID is: ' + Device.device.uuid);
|
||||
* console.log('Device UUID is: ' + Device.uuid);
|
||||
* ```
|
||||
*/
|
||||
@Plugin({
|
||||
@@ -49,12 +23,39 @@ export interface IDevice {
|
||||
})
|
||||
export class Device {
|
||||
|
||||
/** Get the version of Cordova running on the device. */
|
||||
@CordovaProperty
|
||||
static cordova: string;
|
||||
|
||||
/**
|
||||
* Returns the whole device object.
|
||||
*
|
||||
* @returns {Device} The device object.
|
||||
* The device.model returns the name of the device's model or product. The value is set
|
||||
* by the device manufacturer and may be different across versions of the same product.
|
||||
*/
|
||||
@CordovaProperty
|
||||
static device: IDevice;
|
||||
static model: string;
|
||||
|
||||
/** Get the device's operating system name. */
|
||||
@CordovaProperty
|
||||
static platform: string;
|
||||
|
||||
/** Get the device's Universally Unique Identifier (UUID). */
|
||||
@CordovaProperty
|
||||
static uuid: string;
|
||||
|
||||
/** Get the operating system version. */
|
||||
@CordovaProperty
|
||||
static version: string;
|
||||
|
||||
/** Get the device's manufacturer. */
|
||||
@CordovaProperty
|
||||
static manufacturer: string;
|
||||
|
||||
/** Whether the device is running on a simulator. */
|
||||
@CordovaProperty
|
||||
static isVirtual: boolean;
|
||||
|
||||
/** Get the device hardware serial number. */
|
||||
@CordovaProperty
|
||||
static serial: string;
|
||||
|
||||
}
|
||||
|
||||
@@ -407,31 +407,27 @@ export function CordovaInstance(opts: any = {}) {
|
||||
*
|
||||
* Before calling the original method, ensure Cordova and the plugin are installed.
|
||||
*/
|
||||
export function CordovaProperty(target: Function, key: string) {
|
||||
let exists: Function = function(): boolean {
|
||||
if (!window.cordova) {
|
||||
cordovaWarn(this.name, null);
|
||||
return false;
|
||||
}
|
||||
let pluginInstance = getPlugin(this.pluginRef);
|
||||
export function CordovaProperty(target: any, key: string) {
|
||||
const exists = () => {
|
||||
let pluginInstance = getPlugin(target.pluginRef);
|
||||
if (!pluginInstance) {
|
||||
pluginWarn(this, key);
|
||||
pluginWarn(target, key);
|
||||
return false;
|
||||
}
|
||||
return true;
|
||||
};
|
||||
|
||||
Object.defineProperty(target, key, {
|
||||
get: function() {
|
||||
if (exists) {
|
||||
return this.pluginRef[key];
|
||||
get: () => {
|
||||
if (exists()) {
|
||||
return getPlugin(target.pluginRef)[key];
|
||||
} else {
|
||||
return {};
|
||||
}
|
||||
},
|
||||
set: function(value) {
|
||||
if (exists) {
|
||||
this.pluginRef[key] = value;
|
||||
set: (value) => {
|
||||
if (exists()) {
|
||||
getPlugin(target.pluginRef)[key] = value;
|
||||
}
|
||||
}
|
||||
});
|
||||
|
||||
Reference in New Issue
Block a user