forked from danielsogl/awesome-cordova-plugins
-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
Showing
35 changed files
with
653 additions
and
356 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1 @@ | ||
export declare function Plugin(config: any): (cls: any) => any; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,18 @@ | ||
var PluginDecotor = (function () { | ||
function PluginDecotor(cls, config) { | ||
this.cls = cls; | ||
this.config = config; | ||
} | ||
return PluginDecotor; | ||
})(); | ||
function Plugin(config) { | ||
return function (cls) { | ||
for (var _i = 0; _i < config.length; _i++) { | ||
var k = config[_i]; | ||
cls[k] = config[k]; | ||
} | ||
console.log('Decorated', cls, config); | ||
return cls; | ||
}; | ||
} | ||
exports.Plugin = Plugin; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,6 +1,4 @@ | ||
export declare var Camera: { | ||
name: string; | ||
plugin: string; | ||
getPicture: (...args: any[]) => any; | ||
cleanup: (...args: any[]) => any; | ||
}; | ||
export declare class Camera { | ||
static getPicture: any; | ||
static cleanup: any; | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,10 +1,35 @@ | ||
var util_1 = require('../util'); | ||
var PLUGIN_REF = 'navigator.camera'; | ||
exports.Camera = { | ||
// Metadata | ||
name: 'Camera', | ||
plugin: 'cordova-plugin-camera', | ||
// Methods | ||
getPicture: util_1.promisify(PLUGIN_REF, 'getPicture', 0, 1), | ||
cleanup: util_1.promisify(PLUGIN_REF, 'cleanup', 0, 1) | ||
if (typeof __decorate !== "function") __decorate = function (decorators, target, key, desc) { | ||
if (typeof Reflect === "object" && typeof Reflect.decorate === "function") return Reflect.decorate(decorators, target, key, desc); | ||
switch (arguments.length) { | ||
case 2: return decorators.reduceRight(function(o, d) { return (d && d(o)) || o; }, target); | ||
case 3: return decorators.reduceRight(function(o, d) { return (d && d(target, key)), void 0; }, void 0); | ||
case 4: return decorators.reduceRight(function(o, d) { return (d && d(target, key, o)) || o; }, desc); | ||
} | ||
}; | ||
var plugin_1 = require('./plugin'); | ||
var PLUGIN_REF = 'navigator.camera'; | ||
var Camera = (function () { | ||
function Camera() { | ||
} | ||
__decorate([ | ||
plugin_1.Cordova({ | ||
successIndex: 0, | ||
errIndex: 1 | ||
}) | ||
], Camera, "getPicture"); | ||
__decorate([ | ||
plugin_1.Cordova({ | ||
successIndex: 0, | ||
errIndex: 1 | ||
}) | ||
], Camera, "cleanup"); | ||
Camera = __decorate([ | ||
plugin_1.Plugin({ | ||
name: 'Camera', | ||
plugin: 'cordova-plugin-camera', | ||
pluginRef: 'navigator.camera' | ||
}) | ||
], Camera); | ||
return Camera; | ||
})(); | ||
exports.Camera = Camera; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,3 @@ | ||
export declare const wrap: (pluginObj: any, methodName: any, opts?: any) => (...args: any[]) => any; | ||
export declare function Plugin(config: any): (cls: any) => any; | ||
export declare function Cordova(opts?: any): (obj: any, methodName: any) => void; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,55 @@ | ||
var util_1 = require('../util'); | ||
exports.wrap = function (pluginObj, methodName, opts) { | ||
if (opts === void 0) { opts = {}; } | ||
return function () { | ||
var args = []; | ||
for (var _i = 0; _i < arguments.length; _i++) { | ||
args[_i - 0] = arguments[_i]; | ||
} | ||
console.log('Trying', pluginObj.name, methodName, args); | ||
return new Promise(function (resolve, reject) { | ||
if (typeof opts.successIndex !== 'undefined') { | ||
args[opts.successIndex] = resolve; | ||
} | ||
if (typeof opts.errorIndex !== 'undefined') { | ||
args[opts.errorIndex] = reject; | ||
} | ||
var pluginInstance = util_1.get(window, pluginObj.pluginRef); | ||
if (!pluginInstance) { | ||
console.warn('Native: tried calling ' + pluginObj.name + '.' + methodName + ', but the ' + pluginObj.name + ' plugin is not installed. Install the ' + pluginObj.plugin + ' plugin'); | ||
reject({ | ||
error: 'plugin_not_installed' | ||
}); | ||
return; | ||
} | ||
util_1.get(window, pluginObj.pluginRef)[methodName].apply(pluginObj, args); | ||
}); | ||
}; | ||
}; | ||
var PluginDecotor = (function () { | ||
function PluginDecotor(cls, config) { | ||
this.cls = cls; | ||
this.config = config; | ||
} | ||
return PluginDecotor; | ||
})(); | ||
function Plugin(config) { | ||
return function (cls) { | ||
// Add these fields to the class | ||
for (var k in config) { | ||
cls[k] = config[k]; | ||
} | ||
return cls; | ||
}; | ||
} | ||
exports.Plugin = Plugin; | ||
function Cordova(opts) { | ||
if (opts === void 0) { opts = {}; } | ||
return function (obj, methodName) { | ||
if (opts.promise) { | ||
console.log('TODO: Promise'); | ||
} | ||
obj[methodName] = exports.wrap(obj, methodName, opts); | ||
}; | ||
} | ||
exports.Cordova = Cordova; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,13 +1,11 @@ | ||
export declare var StatusBar: { | ||
name: string; | ||
plugin: string; | ||
overlaysWebView: (...args: any[]) => any; | ||
styleDefault: (...args: any[]) => any; | ||
styleLightContent: (...args: any[]) => any; | ||
styleBlackTranslucent: (...args: any[]) => any; | ||
styleBlackOpaque: (...args: any[]) => any; | ||
backgroundColorByName: (...args: any[]) => any; | ||
backgroundColorByHexString: (...args: any[]) => any; | ||
hide: (...args: any[]) => any; | ||
show: (...args: any[]) => any; | ||
}; | ||
export declare class StatusBar { | ||
static overlaysWebView: any; | ||
static styleDefault: any; | ||
static styleLightContent: any; | ||
static styleBlackTranslucent: any; | ||
static styleBlackOpaque: any; | ||
static backgroundColorByName: any; | ||
static backgroundColorByHexString: any; | ||
static hide: any; | ||
static show: any; | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,17 +1,49 @@ | ||
var util_1 = require('../util'); | ||
var PLUGIN_REF = 'StatusBar'; | ||
exports.StatusBar = { | ||
// Metadata | ||
name: 'StatusBar', | ||
plugin: 'cordova-plugin-statusbar', | ||
// Methods | ||
overlaysWebView: util_1.wrap(PLUGIN_REF, 'overlaysWebView'), | ||
styleDefault: util_1.wrap(PLUGIN_REF, 'styleDefault'), | ||
styleLightContent: util_1.wrap(PLUGIN_REF, 'styleLightContent'), | ||
styleBlackTranslucent: util_1.wrap(PLUGIN_REF, 'styleBlackTranslucent'), | ||
styleBlackOpaque: util_1.wrap(PLUGIN_REF, 'styleBlackOpaque'), | ||
backgroundColorByName: util_1.wrap(PLUGIN_REF, 'backgroundColorByName'), | ||
backgroundColorByHexString: util_1.wrap(PLUGIN_REF, 'backgroundColorByHexString'), | ||
hide: util_1.wrap(PLUGIN_REF, 'hide'), | ||
show: util_1.wrap(PLUGIN_REF, 'show') | ||
if (typeof __decorate !== "function") __decorate = function (decorators, target, key, desc) { | ||
if (typeof Reflect === "object" && typeof Reflect.decorate === "function") return Reflect.decorate(decorators, target, key, desc); | ||
switch (arguments.length) { | ||
case 2: return decorators.reduceRight(function(o, d) { return (d && d(o)) || o; }, target); | ||
case 3: return decorators.reduceRight(function(o, d) { return (d && d(target, key)), void 0; }, void 0); | ||
case 4: return decorators.reduceRight(function(o, d) { return (d && d(target, key, o)) || o; }, desc); | ||
} | ||
}; | ||
var plugin_1 = require('./plugin'); | ||
var StatusBar = (function () { | ||
function StatusBar() { | ||
} | ||
__decorate([ | ||
plugin_1.Cordova() | ||
], StatusBar, "overlaysWebView"); | ||
__decorate([ | ||
plugin_1.Cordova() | ||
], StatusBar, "styleDefault"); | ||
__decorate([ | ||
plugin_1.Cordova() | ||
], StatusBar, "styleLightContent"); | ||
__decorate([ | ||
plugin_1.Cordova() | ||
], StatusBar, "styleBlackTranslucent"); | ||
__decorate([ | ||
plugin_1.Cordova() | ||
], StatusBar, "styleBlackOpaque"); | ||
__decorate([ | ||
plugin_1.Cordova() | ||
], StatusBar, "backgroundColorByName"); | ||
__decorate([ | ||
plugin_1.Cordova() | ||
], StatusBar, "backgroundColorByHexString"); | ||
__decorate([ | ||
plugin_1.Cordova() | ||
], StatusBar, "hide"); | ||
__decorate([ | ||
plugin_1.Cordova() | ||
], StatusBar, "show"); | ||
StatusBar = __decorate([ | ||
plugin_1.Plugin({ | ||
name: 'StatusBar', | ||
plugin: 'cordova-plugin-statusbar', | ||
pluginRef: 'StatusBar' | ||
}) | ||
], StatusBar); | ||
return StatusBar; | ||
})(); | ||
exports.StatusBar = StatusBar; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,6 +1,4 @@ | ||
export declare var Toast: { | ||
name: string; | ||
plugin: string; | ||
showWithOptions: (...args: any[]) => any; | ||
hide: (...args: any[]) => any; | ||
}; | ||
export declare class Toast { | ||
static hide: any; | ||
static showWithOptions: any; | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,10 +1,34 @@ | ||
var util_1 = require('../util'); | ||
var PLUGIN_REF = 'plugins.toast'; | ||
exports.Toast = { | ||
// Metadata | ||
name: 'Toast', | ||
plugin: 'cordova-plugin-x-toast', | ||
// Methods | ||
showWithOptions: util_1.wrap(PLUGIN_REF, 'showWithOptions', 1, 2), | ||
hide: util_1.promisify(PLUGIN_REF, 'hide', 0, 1), | ||
if (typeof __decorate !== "function") __decorate = function (decorators, target, key, desc) { | ||
if (typeof Reflect === "object" && typeof Reflect.decorate === "function") return Reflect.decorate(decorators, target, key, desc); | ||
switch (arguments.length) { | ||
case 2: return decorators.reduceRight(function(o, d) { return (d && d(o)) || o; }, target); | ||
case 3: return decorators.reduceRight(function(o, d) { return (d && d(target, key)), void 0; }, void 0); | ||
case 4: return decorators.reduceRight(function(o, d) { return (d && d(target, key, o)) || o; }, desc); | ||
} | ||
}; | ||
var plugin_1 = require('./plugin'); | ||
var Toast = (function () { | ||
function Toast() { | ||
} | ||
__decorate([ | ||
plugin_1.Cordova({ | ||
successIndex: 0, | ||
errIndex: 1 | ||
}) | ||
], Toast, "hide"); | ||
__decorate([ | ||
plugin_1.Cordova({ | ||
successIndex: 0, | ||
errIndex: 1 | ||
}) | ||
], Toast, "showWithOptions"); | ||
Toast = __decorate([ | ||
plugin_1.Plugin({ | ||
name: 'Toast', | ||
plugin: 'cordova-plugin-x-toast', | ||
pluginRef: 'plugins.toast' | ||
}) | ||
], Toast); | ||
return Toast; | ||
})(); | ||
exports.Toast = Toast; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,5 +1,5 @@ | ||
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; | ||
} | ||
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; | ||
} |
Oops, something went wrong.