mirror of
https://github.com/danielsogl/awesome-cordova-plugins.git
synced 2026-05-20 00:06:24 +08:00
Aww yis
This commit is contained in:
Vendored
-5
@@ -1,5 +0,0 @@
|
||||
export declare class Cordova {
|
||||
static hasPlugin(pluginRef: string): boolean;
|
||||
static plugin(pluginRef: string): any;
|
||||
static promisify(pluginRef: any, pluginName: any, methodName: any, successIndex: any, errorIndex: any): (...args: any[]) => any;
|
||||
}
|
||||
|
||||
Vendored
-42
@@ -1,42 +0,0 @@
|
||||
var util_1 = require('./util');
|
||||
var Cordova = (function () {
|
||||
function Cordova() {
|
||||
}
|
||||
Cordova.hasPlugin = function (pluginRef) {
|
||||
return !!this.plugin(pluginRef);
|
||||
};
|
||||
Cordova.plugin = function (pluginRef) {
|
||||
return util_1.get(window, pluginRef);
|
||||
};
|
||||
Cordova.promisify = function (pluginRef, pluginName, methodName, successIndex, errorIndex) {
|
||||
var _this = this;
|
||||
return function () {
|
||||
var args = [];
|
||||
for (var _i = 0; _i < arguments.length; _i++) {
|
||||
args[_i - 0] = arguments[_i];
|
||||
}
|
||||
return new Promise(function (resolve, reject) {
|
||||
if (!window.cordova) {
|
||||
console.warn('Cordova: tried calling', '"' + pluginName + '.' + methodName + '"', 'but Cordova is not defined. Please make sure you have cordova.js included in your index.html file and you are running in a proper cordova environment');
|
||||
reject({
|
||||
error: 'cordova_not_available'
|
||||
});
|
||||
return;
|
||||
}
|
||||
if (!_this.hasPlugin(pluginRef)) {
|
||||
console.warn('Cordova: tried calling', '"' + pluginName + '.' + methodName + '"', 'but the ' + pluginName + ' plugin is not installed.');
|
||||
reject({
|
||||
error: 'plugin_not_installed'
|
||||
});
|
||||
return;
|
||||
}
|
||||
console.log('Cordova: exec(' + pluginName + ', ' + methodName + ')');
|
||||
args[successIndex] = resolve;
|
||||
args[errorIndex] = reject;
|
||||
util_1.get(window, pluginRef)[methodName].apply(_this, args);
|
||||
});
|
||||
};
|
||||
};
|
||||
return Cordova;
|
||||
})();
|
||||
exports.Cordova = Cordova;
|
||||
|
||||
Vendored
+1
-1
@@ -48,7 +48,7 @@ function Cordova(opts) {
|
||||
if (opts.promise) {
|
||||
console.log('TODO: Promise');
|
||||
}
|
||||
obj[methodName] = exports.wrap(obj, methodName, opts);
|
||||
obj[methodName] = exports.wrap(obj, methodName, opts).bind(obj);
|
||||
};
|
||||
}
|
||||
exports.Cordova = Cordova;
|
||||
|
||||
Vendored
+2
-2
@@ -20,8 +20,8 @@ var Toast = (function () {
|
||||
], Toast, "hide", void 0);
|
||||
__decorate([
|
||||
plugin_1.Cordova({
|
||||
successIndex: 0,
|
||||
errIndex: 1
|
||||
successIndex: 1,
|
||||
errIndex: 2
|
||||
}),
|
||||
__metadata('design:type', Object)
|
||||
], Toast, "showWithOptions", void 0);
|
||||
|
||||
Reference in New Issue
Block a user