mirror of
https://github.com/danielsogl/awesome-cordova-plugins.git
synced 2025-03-17 00:51:07 +08:00
parent
3b440c6df8
commit
86b637e85a
@ -1,5 +1,3 @@
|
|||||||
import * as _ from 'lodash';
|
|
||||||
|
|
||||||
export function checkReady() {
|
export function checkReady() {
|
||||||
const DEVICE_READY_TIMEOUT = 5000;
|
const DEVICE_READY_TIMEOUT = 5000;
|
||||||
|
|
||||||
@ -18,7 +16,7 @@ export function checkReady() {
|
|||||||
});
|
});
|
||||||
|
|
||||||
setTimeout(() => {
|
setTimeout(() => {
|
||||||
if (!didFireReady && !_.isUndefined(window.cordova)) {
|
if (!didFireReady && window.cordova) {
|
||||||
console.warn(
|
console.warn(
|
||||||
`Ionic Native: deviceready did not fire within ${DEVICE_READY_TIMEOUT}ms. This can happen when plugins are in an inconsistent state. Try removing plugins from plugins/ and reinstalling them.`
|
`Ionic Native: deviceready did not fire within ${DEVICE_READY_TIMEOUT}ms. This can happen when plugins are in an inconsistent state. Try removing plugins from plugins/ and reinstalling them.`
|
||||||
);
|
);
|
||||||
|
@ -1,4 +1,3 @@
|
|||||||
import { isUndefined } from 'lodash';
|
|
||||||
import { Observable, fromEvent } from 'rxjs';
|
import { Observable, fromEvent } from 'rxjs';
|
||||||
|
|
||||||
import { CordovaOptions } from './interfaces';
|
import { CordovaOptions } from './interfaces';
|
||||||
@ -375,12 +374,12 @@ export function pluginWarn(
|
|||||||
if (method) {
|
if (method) {
|
||||||
console.warn(
|
console.warn(
|
||||||
'Native: tried calling ' +
|
'Native: tried calling ' +
|
||||||
pluginName +
|
pluginName +
|
||||||
'.' +
|
'.' +
|
||||||
method +
|
method +
|
||||||
', but the ' +
|
', but the ' +
|
||||||
pluginName +
|
pluginName +
|
||||||
' plugin is not installed.'
|
' plugin is not installed.'
|
||||||
);
|
);
|
||||||
} else {
|
} else {
|
||||||
console.warn(
|
console.warn(
|
||||||
@ -403,16 +402,16 @@ export function cordovaWarn(pluginName: string, method?: string): void {
|
|||||||
if (method) {
|
if (method) {
|
||||||
console.warn(
|
console.warn(
|
||||||
'Native: tried calling ' +
|
'Native: tried calling ' +
|
||||||
pluginName +
|
pluginName +
|
||||||
'.' +
|
'.' +
|
||||||
method +
|
method +
|
||||||
', but Cordova is not available. Make sure to include cordova.js or run in a device/simulator'
|
', but Cordova is not available. Make sure to include cordova.js or run in a device/simulator'
|
||||||
);
|
);
|
||||||
} else {
|
} else {
|
||||||
console.warn(
|
console.warn(
|
||||||
'Native: tried accessing the ' +
|
'Native: tried accessing the ' +
|
||||||
pluginName +
|
pluginName +
|
||||||
' plugin but Cordova is not available. Make sure to include cordova.js or run in a device/simulator'
|
' plugin but Cordova is not available. Make sure to include cordova.js or run in a device/simulator'
|
||||||
);
|
);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@ -420,7 +419,7 @@ export function cordovaWarn(pluginName: string, method?: string): void {
|
|||||||
/**
|
/**
|
||||||
* @private
|
* @private
|
||||||
*/
|
*/
|
||||||
export const wrap = function (
|
export const wrap = function(
|
||||||
pluginObj: any,
|
pluginObj: any,
|
||||||
methodName: string,
|
methodName: string,
|
||||||
opts: CordovaOptions = {}
|
opts: CordovaOptions = {}
|
||||||
@ -525,7 +524,7 @@ export function wrapInstance(
|
|||||||
reject
|
reject
|
||||||
);
|
);
|
||||||
}
|
}
|
||||||
if (result && !isUndefined(result.then)) {
|
if (result && result.then) {
|
||||||
result.then(resolve, reject);
|
result.then(resolve, reject);
|
||||||
} else {
|
} else {
|
||||||
reject();
|
reject();
|
||||||
|
@ -1,14 +1,12 @@
|
|||||||
import * as _ from 'lodash';
|
|
||||||
|
|
||||||
export function instancePropertyGet(pluginObj: any, key: string) {
|
export function instancePropertyGet(pluginObj: any, key: string) {
|
||||||
if (!_.isUndefined(pluginObj._objectInstance) && !_.isUndefined(pluginObj._objectInstance[key])) {
|
if (pluginObj._objectInstance && pluginObj._objectInstance[key]) {
|
||||||
return pluginObj._objectInstance[key];
|
return pluginObj._objectInstance[key];
|
||||||
}
|
}
|
||||||
return null;
|
return null;
|
||||||
}
|
}
|
||||||
|
|
||||||
export function instancePropertySet(pluginObj: any, key: string, value: any) {
|
export function instancePropertySet(pluginObj: any, key: string, value: any) {
|
||||||
if (!_.isUndefined(pluginObj._objectInstance) && !_.isUndefined(pluginObj._objectInstance[key])) {
|
if (pluginObj._objectInstance && pluginObj._objectInstance[key]) {
|
||||||
pluginObj._objectInstance[key] = value;
|
pluginObj._objectInstance[key] = value;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
Loading…
x
Reference in New Issue
Block a user