diff --git a/demo/www/app/home/home.js b/demo/www/app/home/home.js index 363edb78..89d69645 100644 --- a/demo/www/app/home/home.js +++ b/demo/www/app/home/home.js @@ -6,6 +6,7 @@ import { Camera, Contacts, Device, + Geolocation, StatusBar, Toast } from 'ionic-native'; @@ -25,6 +26,7 @@ export class HomePage { Camera, Contacts, Device, + Geolocation, StatusBar, Toast ]; diff --git a/demo/www/app/plugin/plugin.html b/demo/www/app/plugin/plugin.html index ec75da56..0fd2f99b 100644 --- a/demo/www/app/plugin/plugin.html +++ b/demo/www/app/plugin/plugin.html @@ -6,8 +6,8 @@ - + diff --git a/dist/.index.js.swp b/dist/.index.js.swp new file mode 100644 index 00000000..46c5161e Binary files /dev/null and b/dist/.index.js.swp differ diff --git a/dist/cordova.d.ts b/dist/cordova.d.ts deleted file mode 100644 index bc833b0f..00000000 --- a/dist/cordova.d.ts +++ /dev/null @@ -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; -} diff --git a/dist/cordova.js b/dist/cordova.js deleted file mode 100644 index 822d01b2..00000000 --- a/dist/cordova.js +++ /dev/null @@ -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; diff --git a/dist/index.d.ts b/dist/index.d.ts index ad2aa9c3..09957f39 100644 --- a/dist/index.d.ts +++ b/dist/index.d.ts @@ -3,5 +3,6 @@ export * from './plugins/ble'; export * from './plugins/camera'; export * from './plugins/contacts'; export * from './plugins/device'; +export * from './plugins/geolocation'; export * from './plugins/statusbar'; export * from './plugins/toast'; diff --git a/dist/index.js b/dist/index.js index a8576d2c..222b9b39 100644 --- a/dist/index.js +++ b/dist/index.js @@ -7,6 +7,7 @@ __export(require('./plugins/ble')); __export(require('./plugins/camera')); __export(require('./plugins/contacts')); __export(require('./plugins/device')); +__export(require('./plugins/geolocation')); __export(require('./plugins/statusbar')); __export(require('./plugins/toast')); var didFireReady = false; @@ -18,3 +19,4 @@ setTimeout(function () { console.warn('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.'); } }, DEVICE_READY_TIMEOUT); +//# sourceMappingURL=index.js.map \ No newline at end of file diff --git a/dist/index.js.map b/dist/index.js.map new file mode 100644 index 00000000..56a89c89 --- /dev/null +++ b/dist/index.js.map @@ -0,0 +1 @@ +{"version":3,"file":"index.js","sourceRoot":"","sources":["../src/index.ts"],"names":[],"mappings":";;;AAAA,IAAM,oBAAoB,GAAG,IAAI,CAAC;AAElC,iBAAc,uBAAuB,CAAC,EAAA;AACtC,iBAAc,eAAe,CAAC,EAAA;AAC9B,iBAAc,kBAAkB,CAAC,EAAA;AACjC,iBAAc,oBAAoB,CAAC,EAAA;AACnC,iBAAc,kBAAkB,CAAC,EAAA;AACjC,iBAAc,uBAAuB,CAAC,EAAA;AACtC,iBAAc,qBAAqB,CAAC,EAAA;AACpC,iBAAc,iBAAiB,CAAC,EAAA;AAShC,IAAI,YAAY,GAAG,KAAK,CAAC;AACzB,MAAM,CAAC,gBAAgB,CAAC,aAAa,EAAE;IACrC,YAAY,GAAG,IAAI,CAAC;AACtB,CAAC,CAAC,CAAA;AAEF,UAAU,CAAC;IACT,EAAE,CAAA,CAAC,CAAC,YAAY,IAAI,MAAM,CAAC,OAAO,CAAC,CAAC,CAAC;QACnC,OAAO,CAAC,IAAI,CAAC,0CAA0C,GAAG,oBAAoB,GAAG,0HAA0H,CAAC,CAAC;IAC/M,CAAC;AACH,CAAC,EAAE,oBAAoB,CAAC,CAAC"} \ No newline at end of file diff --git a/dist/plugin-config.d.ts b/dist/plugin-config.d.ts deleted file mode 100644 index 0975baa7..00000000 --- a/dist/plugin-config.d.ts +++ /dev/null @@ -1,8 +0,0 @@ -export interface CordovaPlugin { - id: string; - className: string; - plugin: string; - pluginRef: string; - promise?: any; -} -export declare var PluginConfig: CordovaPlugin[]; diff --git a/dist/plugin-config.js b/dist/plugin-config.js deleted file mode 100644 index e3bee0f3..00000000 --- a/dist/plugin-config.js +++ /dev/null @@ -1,49 +0,0 @@ -exports.PluginConfig = [ - { - id: 'device', - className: 'Device', - plugin: 'cordova-plugin-device', - pluginRef: 'device' - }, - { - id: 'camera', - className: 'Camera', - plugin: 'cordova-plugin-camera', - promise: ['takePicture'], - pluginRef: 'navigator.camera' - }, - { - id: 'statusbar', - className: 'StatusBar', - plugin: 'cordova-plugin-statusbar', - pluginRef: 'StatusBar', - promise: ['show', 'hide', 'styleDefault', 'styleLightContent', 'styleBlackTranslucent', 'styleBlackOpaque'] - }, - { - id: 'applinks', - className: 'AppLinks', - plugin: 'com.lampa.startapp', - pluginRef: 'navigator.startApp', - promise: ['start', 'check'] - }, - { - id: 'barcode', - className: 'Barcode', - plugin: 'phonegap-plugin-barcodescanner', - pluginRef: 'cordova.plugins.barcodeScanner', - promise: ['scan', 'encode'] - }, - { - id: 'camera-roll', - className: 'CameraRoll', - plugin: 'cordova-plugin-camera-roll', - pluginRef: 'CameraRoll', - promise: ['saveToCameraRoll', 'getPhotos'] - }, - { - id: 'contacts', - className: 'Contacts', - plugin: 'cordova-plugin-contacts', - pluginRef: 'navigator.contacts', - }, -]; diff --git a/dist/plugin.d.ts b/dist/plugin.d.ts deleted file mode 100644 index f4278943..00000000 --- a/dist/plugin.d.ts +++ /dev/null @@ -1 +0,0 @@ -export declare function Plugin(config: any): (cls: any) => any; diff --git a/dist/plugin.js b/dist/plugin.js deleted file mode 100644 index d134c020..00000000 --- a/dist/plugin.js +++ /dev/null @@ -1,18 +0,0 @@ -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; diff --git a/dist/plugins/actionsheet.js b/dist/plugins/actionsheet.js index 475627b5..c43da84a 100644 --- a/dist/plugins/actionsheet.js +++ b/dist/plugins/actionsheet.js @@ -33,3 +33,4 @@ var ActionSheet = (function () { return ActionSheet; })(); exports.ActionSheet = ActionSheet; +//# sourceMappingURL=actionsheet.js.map \ No newline at end of file diff --git a/dist/plugins/actionsheet.js.map b/dist/plugins/actionsheet.js.map new file mode 100644 index 00000000..4b611720 --- /dev/null +++ b/dist/plugins/actionsheet.js.map @@ -0,0 +1 @@ +{"version":3,"file":"actionsheet.js","sourceRoot":"","sources":["../../src/plugins/actionsheet.ts"],"names":["ActionSheet","ActionSheet.constructor","ActionSheet.show","ActionSheet.hide"],"mappings":";;;;;;;;AAAA,uBAA8B,UAAU,CAAC,CAAA;AAEzC;IAAAA;IAYAC,CAACA;IAJQD,gBAAIA,GADXA,UACYA,OAAWA,IAAEE,CAACA;;IAGnBF,gBAAIA,GADXA,UACYA,OAAWA,IAAEG,CAACA;;IAJ1BH,sBACOA,mBAAIA;;YADVA,gBAAOA,EAAEA;WACHA,mBAAIA,kCAAJA,mBAAIA,IAAeA;IAE1BA,sBACOA,mBAAIA;;YADVA,gBAAOA,EAAEA;WACHA,mBAAIA,kCAAJA,mBAAIA,IAAeA;IAX5BA;QAACA,eAAMA,CAACA;YACNA,IAAIA,EAAEA,aAAaA;YACnBA,MAAMA,EAAEA,4BAA4BA;YACpCA,SAASA,EAAEA,qBAAqBA;YAChCA,IAAIA,EAAEA,8DAA8DA;SACrEA,CAACA;oBAODA;IAADA,kBAACA;AAADA,CAACA,AAZD,IAYC;AANY,mBAAW,cAMvB,CAAA"} \ No newline at end of file diff --git a/dist/plugins/ble.js b/dist/plugins/ble.js index 8aa42a4b..4c04d745 100644 --- a/dist/plugins/ble.js +++ b/dist/plugins/ble.js @@ -68,3 +68,4 @@ var BLE = (function () { return BLE; })(); exports.BLE = BLE; +//# sourceMappingURL=ble.js.map \ No newline at end of file diff --git a/dist/plugins/ble.js.map b/dist/plugins/ble.js.map new file mode 100644 index 00000000..ed0cebce --- /dev/null +++ b/dist/plugins/ble.js.map @@ -0,0 +1 @@ +{"version":3,"file":"ble.js","sourceRoot":"","sources":["../../src/plugins/ble.ts"],"names":["BLE","BLE.constructor","BLE.scan","BLE.startScan","BLE.stopScan","BLE.connect","BLE.disconnect","BLE.read","BLE.write","BLE.writeWithoutResponse"],"mappings":";;;;;;;;AAAA,uBAA8B,UAAU,CAAC,CAAA;AAEzC;IAAAA;IA8BAC,CAACA;IAtBQD,QAAIA,GADXA,UACYA,QAAcA,EAAEA,OAAcA,IAAGE,CAACA;IAGvCF,aAASA,GADhBA,UACiBA,QAAcA,IAAEG,CAACA;;IAG3BH,YAAQA,GADfA,cACkBI,CAACA;;IAGZJ,WAAOA,GADdA,UACeA,QAAeA,IAAEK,CAACA;;IAG1BL,cAAUA,GADjBA,UACkBA,QAAeA,IAAEM,CAACA;;IAG7BN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era.js index 9fc8b905..b4122a98 100644 --- a/dist/plugins/camera.js +++ b/dist/plugins/camera.js @@ -35,3 +35,4 @@ var Camera = (function () { return Camera; })(); exports.Camera = Camera; +//# sourceMappingURL=camera.js.map \ No newline at end of file diff --git a/dist/plugins/camera.js.map b/dist/plugins/camera.js.map new file mode 100644 index 00000000..703fe4cf --- /dev/null +++ b/dist/plugins/camera.js.map @@ -0,0 +1 @@ +{"version":3,"file":"camera.js","sourceRoot":"","sources":["../../src/plugins/camera.ts"],"names":["Camera","Camera.constructor","Camera.getPicture","Camera.cleanup"],"mappings":";;;;;;;;AAAA,uBAA8B,UAAU,CAAC,CAAA;AAEzC;IAAAA;IAcAC,CAACA;IAJQD,iBAAUA,GAJjBA,UAIkBA,OAAWA,IAAEE,CAACA;;IAGzBF,cAAOA,GADdA,cACiBG,CAACA;;IAPlBH,sBAIOA,oBAAUA;;YAJhBA,gBAAOA,CAACA;gBACPA,6DAA6DA;gBAC7DA,aAAaA,EAAEA,SAASA;aACzBA,CAACA;WACKA,oBAAUA,kCAAVA,oBAAUA,IAAeA;IAEhCA,sBACOA,iBAAOA;;YADbA,gBAAOA,EAAEA;WACHA,iBAAOA,kCAAPA,iBAAOA,IAAIA;IAbpBA;QAACA,eAAMA,CAACA;YACNA,IAAIA,EAAEA,QAAQA;YACdA,MAAMA,EAAEA,uBAAuBA;YAC/BA,SAASA,EAAEA,kBAAkBA;SAC9BA,CAACA;eAUDA;IAADA,aAACA;AAADA,CAACA,AAdD,IAcC;AATY,cAAM,SASlB,CAAA"} \ No newline at end of file diff --git a/dist/plugins/contacts.js b/dist/plugins/contacts.js index 0687cc93..00342bdf 100644 --- a/dist/plugins/contacts.js +++ b/dist/plugins/contacts.js @@ -45,3 +45,4 @@ var Contacts = (function () { return Contacts; })(); exports.Contacts = Contacts; +//# sourceMappingURL=contacts.js.map \ No newline at end of file diff --git a/dist/plugins/contacts.js.map b/dist/plugins/contacts.js.map new file mode 100644 index 00000000..4173212f --- /dev/null +++ b/dist/plugins/contacts.js.map @@ -0,0 +1 @@ +{"version":3,"file":"contacts.js","sourceRoot":"","sources":["../../src/plugins/contacts.ts"],"names":["Contacts","Contacts.constructor","Contacts.create","Contacts.find","Contacts.pickContact"],"mappings":";;;;;;;;AAAA,uBAA8B,UAAU,CAAC,CAAA;AAEzC;IAAAA;IAsBAC,CAACA;IAVQD,eAAMA,GALbA,UAKcA,MAAeA,EAAEA,OAAWA,IAAEE,CAACA;;IAMtCF,aAAIA,GAJXA,UAIYA,MAAeA,EAAEA,OAAWA,IAAEG,CAACA;;IAGpCH,oBAAWA,GADlBA,cACqBI,CAACA;;IAdtBJ,sBAKOA,kBAAMA;;YALZA,gBAAOA,CAACA;gBACPA,YAAYA,EAAEA,CAACA;gBACfA,UAAUA,EAAEA,CAACA;aACdA,CAACA;WAEKA,kBAAMA,kCAANA,kBAAMA,IAAgCA;IAE7CA,sBAIOA,gBAAIA;;YAJVA,gBAAOA,CAACA;gBACPA,YAAYA,EAAEA,CAACA;gBACfA,UAAUA,EAAEA,CAACA;aACdA,CAACA;WACKA,gBAAIA,kCAAJA,gBAAIA,IAAgCA;IAE3CA,sBACOA,uBAAWA;;YADjBA,gBAAOA,EAAEA;WACHA,uBAAWA,kCAAXA,uBAAWA,IAAIA;IArBxBA;QAACA,eAAMA,CAACA;YACNA,IAAIA,EAAEA,UAAUA;YAChBA,MAAMA,EAAEA,yBAAyBA;YACjCA,SAASA,EAAEA,oBAAoBA;YAC/BA,IAAIA,EAAEA,mDAAmDA;SAC1DA,CAACA;iBAiBDA;IAADA,eAACA;AAADA,CAACA,AAtBD,IAsBC;AAhBY,gBAAQ,WAgBpB,CAAA"} \ No newline at end of file diff --git a/dist/plugins/device.js b/dist/plugins/device.js index 6737ae54..0fd6d634 100644 --- a/dist/plugins/device.js +++ b/dist/plugins/device.js @@ -27,3 +27,4 @@ var Device = (function () { return Device; })(); exports.Device = Device; +//# sourceMappingURL=device.js.map \ No newline at end of file diff --git a/dist/plugins/device.js.map b/dist/plugins/device.js.map new file mode 100644 index 00000000..366b2c96 --- /dev/null +++ b/dist/plugins/device.js.map @@ -0,0 +1 @@ +{"version":3,"file":"device.js","sourceRoot":"","sources":["../../src/plugins/device.ts"],"names":["Device","Device.constructor","Device.getDevice"],"mappings":";;;;;;;;AAAA,uBAAqC,UAAU,CAAC,CAAA;AAIhD;IAAAA;IAWAC,CAACA;IAHQD,gBAASA,GADhBA;QAEEE,MAAMA,CAACA,MAAMA,CAACA,MAAMA,CAACA;IACvBA,CAACA;IAHDF,sBACOA,mBAASA;;YADfA,uBAAcA;WACRA,mBAASA,kCAATA,mBAASA,IAEfA;IAVHA;QAACA,eAAMA,CAACA;YACNA,IAAIA,EAAEA,QAAQA;YACdA,MAAMA,EAAEA,uBAAuBA;YAC/BA,SAASA,EAAEA,QAAQA;SACpBA,CAACA;eAODA;IAADA,aAACA;AAADA,CAACA,AAXD,IAWC;AANY,cAAM,SAMlB,CAAA"} \ No newline at end of file diff --git a/dist/plugins/file.d.ts b/dist/plugins/file.d.ts deleted file mode 100644 index 91f33a7f..00000000 --- a/dist/plugins/file.d.ts +++ /dev/null @@ -1,2 +0,0 @@ -export declare class File { -} diff --git a/dist/plugins/geolocation.d.ts b/dist/plugins/geolocation.d.ts index 46bb0efb..771a23a6 100644 --- a/dist/plugins/geolocation.d.ts +++ b/dist/plugins/geolocation.d.ts @@ -1,3 +1,4 @@ export declare class Device { - static getCurrentPosition: any; + static getCurrentPosition(options: any): void; + static watchPosition(options: any): void; } diff --git a/dist/plugins/geolocation.js b/dist/plugins/geolocation.js index 481cb943..edaeedfc 100644 --- a/dist/plugins/geolocation.js +++ b/dist/plugins/geolocation.js @@ -1,4 +1,4 @@ -if (typeof __decorate !== "function") __decorate = function (decorators, target, key, desc) { +var __decorate = (this && this.__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); @@ -10,9 +10,21 @@ var plugin_1 = require('./plugin'); var Device = (function () { function Device() { } - __decorate([ - plugin_1.Cordova() - ], Device, "getCurrentPosition"); + Device.getCurrentPosition = function (options) { }; + ; + Device.watchPosition = function (options) { }; + ; + Object.defineProperty(Device, "getCurrentPosition", + __decorate([ + plugin_1.Cordova() + ], Device, "getCurrentPosition", Object.getOwnPropertyDescriptor(Device, "getCurrentPosition"))); + Object.defineProperty(Device, "watchPosition", + __decorate([ + plugin_1.Cordova({ + observable: true, + clearFunction: 'clearWatch()' + }) + ], Device, "watchPosition", Object.getOwnPropertyDescriptor(Device, "watchPosition"))); Device = __decorate([ plugin_1.Plugin({ name: 'Geolocation', @@ -23,3 +35,4 @@ var Device = (function () { return Device; })(); exports.Device = Device; +//# sourceMappingURL=geolocation.js.map \ No newline at end of file diff --git a/dist/plugins/geolocation.js.map b/dist/plugins/geolocation.js.map new file mode 100644 index 00000000..6678d1a7 --- /dev/null +++ b/dist/plugins/geolocation.js.map @@ -0,0 +1 @@ +{"version":3,"file":"geolocation.js","sourceRoot":"","sources":["../../src/plugins/geolocation.ts"],"names":["Device","Device.constructor","Device.getCurrentPosition","Device.watchPosition"],"mappings":";;;;;;;;AAAA,uBAA8B,UAAU,CAAC,CAAA;AAMzC;IAAAA;IAeAC,CAACA;IARQD,yBAAkBA,GADzBA,UAC0BA,OAAWA,IAAEE,CAACA;;IAOjCF,oBAAaA,GAJpBA,UAIqBA,OAAWA,IAAEG,CAACA;;IARnCH,sBACOA,4BAAkBA;;YADxBA,gBAAOA,EAAEA;WACHA,4BAAkBA,kCAAlBA,4BAAkBA,IAAeA;IAGxCA,sBAIOA,uBAAaA;;YAJnBA,gBAAOA,CAACA;gBACPA,UAAUA,EAAEA,IAAIA;gBAChBA,aAAaA,EAAEA,cAAcA;aAC9BA,CAACA;WACKA,uBAAaA,kCAAbA,uBAAaA,IAAeA;IAdrCA;QAACA,eAAMA,CAACA;YACNA,IAAIA,EAAEA,aAAaA;YACnBA,MAAMA,EAAEA,4BAA4BA;YACpCA,SAASA,EAAEA,uBAAuBA;SACnCA,CAACA;eAWDA;IAADA,aAACA;AAADA,CAACA,AAfD,IAeC;AAVY,cAAM,SAUlB,CAAA"} \ No newline at end of file diff --git a/dist/plugins/plugin.d.ts b/dist/plugins/plugin.d.ts index 2327bbbf..a2a2045f 100644 --- a/dist/plugins/plugin.d.ts +++ b/dist/plugins/plugin.d.ts @@ -2,7 +2,7 @@ export declare const getPlugin: (pluginRef: string) => any; export declare const isInstalled: (pluginRef: string) => boolean; export declare const pluginWarn: (pluginName: string, method: string, plugin: string) => void; export declare const cordovaWarn: (pluginName: string, method: string) => void; -export declare const wrap: (pluginObj: any, methodName: any, opts?: any) => (...args: any[]) => any; +export declare const wrap: (pluginObj: any, methodName: string, opts?: any) => (...args: any[]) => any; /** * Class decorator specifying Plugin metadata. Required for all plugins. */ diff --git a/dist/plugins/plugin.js b/dist/plugins/plugin.js index a982cf46..4983804f 100644 --- a/dist/plugins/plugin.js +++ b/dist/plugins/plugin.js @@ -1,4 +1,5 @@ var util_1 = require('../util'); +var Rx_1 = require('@reactivex/rxjs/dist/cjs/Rx'); exports.getPlugin = function (pluginRef) { return util_1.get(window, pluginRef); }; @@ -23,52 +24,73 @@ exports.cordovaWarn = function (pluginName, method) { console.warn('Native: tried accessing the ' + pluginName + ' plugin but Cordova is not available. Make sure to include cordova.js or run in a device/simulator'); } }; +function callCordovaPlugin(pluginObj, methodName, args, opts, resolve, reject) { + if (opts === void 0) { opts = {}; } + if (!window.cordova) { + exports.cordovaWarn(pluginObj.name, methodName); + reject({ + error: 'cordova_not_available' + }); + return; + } + // Try to figure out where the success/error callbacks need to be bound + // to our promise resolve/reject handlers. + // If the plugin method expects myMethod(success, err, options) + if (opts.callbackOrder == 'reverse') { + args[0] = resolve; + args[1] = reject; + } + else if (typeof opts.successIndex !== 'undefined' || typeof opts.errorIndex !== 'undefined') { + // If we've specified a success/error index + args.splice(opts.successIndex, 0, resolve); + args.splice(opts.errorIndex, 0, reject); + } + else { + // Otherwise, let's tack them on to the end of the argument list + // which is 90% of cases + args.push(resolve); + args.push(reject); + } + var pluginInstance = exports.getPlugin(pluginObj.pluginRef); + if (!pluginInstance) { + exports.pluginWarn(pluginObj.name, methodName, pluginObj.name); + reject({ + error: 'plugin_not_installed' + }); + return; + } + console.log('Cordova calling', pluginObj.name, methodName, args); + return util_1.get(window, pluginObj.pluginRef)[methodName].apply(pluginObj, args); +} +function wrapPromise(pluginObj, methodName, args, opts) { + if (opts === void 0) { opts = {}; } + return new Promise(function (resolve, reject) { + callCordovaPlugin(pluginObj, methodName, args, opts, resolve, reject); + }); +} +function wrapObservable(pluginObj, methodName, args, opts) { + if (opts === void 0) { opts = {}; } + return Rx_1.Observable.create(function (observer) { + var pluginResult = callCordovaPlugin(pluginObj, methodName, args, opts, observer.onNext, observer.onError); + return function () { + return util_1.get(window, pluginObj.pluginRef)[opts.clearFunction].apply(pluginObj, pluginResult); + }; + }); +} exports.wrap = function (pluginObj, methodName, opts) { if (opts === void 0) { opts = {}; } - console.log('Wrap', pluginObj.name, methodName); return function () { var args = []; for (var _i = 0; _i < arguments.length; _i++) { args[_i - 0] = arguments[_i]; } - console.log('Wrap CALLED', pluginObj.name, methodName, args); - return new Promise(function (resolve, reject) { - if (!window.cordova) { - exports.cordovaWarn(pluginObj.name, methodName); - reject({ - error: 'cordova_not_available' - }); - return; - } - // Try to figure out where the success/error callbacks need to be bound - // to our promise resolve/reject handlers. - // If the plugin method expects myMethod(success, err, options) - if (opts.callbackOrder == 'reverse') { - args[0] = resolve; - args[1] = reject; - } - else if (typeof opts.successIndex !== 'undefined' || typeof opts.errorIndex !== 'undefined') { - // If we've specified a success/error index - args.splice(opts.successIndex, resolve); - args.splice(opts.errorIndex, reject); - } - else { - // Otherwise, let's tack them on to the end of the argument list - // which is 90% of cases - args.push(resolve); - args.push(reject); - } - var pluginInstance = exports.getPlugin(pluginObj.pluginRef); - if (!pluginInstance) { - exports.pluginWarn(pluginObj.name, methodName, pluginObj.name); - reject({ - error: 'plugin_not_installed' - }); - return; - } - console.log('Cordova calling', pluginObj.name, methodName, args); - util_1.get(window, pluginObj.pluginRef)[methodName].apply(pluginObj, args); - }); + if (opts.observable) { + console.log("Wrapping observable"); + return wrapObservable(pluginObj, methodName, args, opts); + } + else { + return wrapPromise(pluginObj, methodName, args, opts); + } }; }; /** @@ -129,3 +151,4 @@ function RequiresPlugin(target, key, descriptor) { return descriptor; } exports.RequiresPlugin = RequiresPlugin; +//# sourceMappingURL=plugin.js.map \ No newline at end of file diff --git a/dist/plugins/plugin.js.map b/dist/plugins/plugin.js.map new file mode 100644 index 00000000..88c9679c --- /dev/null +++ b/dist/plugins/plugin.js.map @@ -0,0 +1 @@ +{"version":3,"file":"plugin.js","sourceRoot":"","sources":["../../src/plugins/plugin.ts"],"names":["callCordovaPlugin","wrapPromise","wrapObservable","Plugin","Cordova","RequiresPlugin"],"mappings":"AAAA,qBAAkB,SAAS,CAAC,CAAA;AAK5B,mBAAyB,6BAA6B,CAAC,CAAA;AAG1C,iBAAS,GAAG,UAAS,SAAiB;IACjD,MAAM,CAAC,UAAG,CAAC,MAAM,EAAE,SAAS,CAAC,CAAC;AAChC,CAAC,CAAA;AACY,mBAAW,GAAG,UAAS,SAAiB;IACnD,MAAM,CAAC,CAAC,CAAC,iBAAS,CAAC,SAAS,CAAC,CAAC;AAChC,CAAC,CAAA;AACY,kBAAU,GAAG,UAAS,UAAkB,EAAE,MAAc,EAAE,MAAc;IACnF,EAAE,CAAA,CAAC,MAAM,CAAC,CAAC,CAAC;QACV,OAAO,CAAC,IAAI,CAAC,wBAAwB,GAAG,UAAU,GAAG,GAAG,GAAG,MAAM;YAC/D,YAAY,GAAG,UAAU,GAAG,wCAAwC;YACpE,MAAM,GAAG,SAAS,CAAC,CAAC;IACxB,CAAC;IAAC,IAAI,CAAC,CAAC;QACN,OAAO,CAAC,IAAI,CAAC,8BAA8B,GAAG,UAAU,GAAG,+CAA+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E,IAAI,EAAE,IAAI,CAAC,IAAI,CAAC,CAAC;YACvC,MAAM,CAAC;QACT,CAAC;QACD,cAAc,CAAC,KAAK,CAAC,IAAI,EAAE,IAAI,CAAC,CAAC;IACnC,CAAC,CAAAA;IAEDA,MAAMA,CAACA,UAAUA,CAACA;AACpBA,CAACA;AAnBe,sBAAc,iBAmB7B,CAAA"} \ No newline at end of file diff --git a/dist/plugins/statusbar.js b/dist/plugins/statusbar.js index fbbc2905..dcf7cac1 100644 --- a/dist/plugins/statusbar.js +++ b/dist/plugins/statusbar.js @@ -74,3 +74,4 @@ var StatusBar = (function () { return StatusBar; })(); exports.StatusBar = StatusBar; +//# sourceMappingURL=statusbar.js.map \ No newline at end of file diff --git a/dist/plugins/statusbar.js.map b/dist/plugins/statusbar.js.map new file mode 100644 index 00000000..e65c83ac --- /dev/null +++ b/dist/plugins/statusbar.js.map @@ -0,0 +1 @@ +{"version":3,"file":"statusbar.js","sourceRoot":"","sources":["../../src/plugins/statusbar.ts"],"names":["StatusBar","StatusBar.constructor","StatusBar.overlaysWebView","StatusBar.styleDefault","StatusBar.styleLightContent","StatusBar.styleBlackTranslucent","StatusBar.styleBlackOpaque","StatusBar.backgroundColorByName","StatusBar.backgroundColorByHexString","StatusBar.hide","StatusBar.show"],"mappings":";;;;;;;;AAAA,uBAA8B,UAAU,CAAC,CAAA;AAEzC;IAAAA;IAwBAC,CAACA;IAjBQD,yBAAeA,GADtBA,UACuBA,SAAiBA,IAAEE,CAACA;;IAEpCF,sBAAYA,GADnBA,cACsBG,CAACA;;IAEhBH,2BAAiBA,GADxBA,cAC2BI,CAACA;;IAErBJ,+BAAqBA,GAD5BA,cAC+BK,CAACA;;IAEzBL,0BAAgBA,GADvBA,cAC0BM,CAACA;;IAEpBN,+BAAqBA,GAD5BA,UAC6BA,SAAgBA,IAAEO,CAACA;;IAEzCP,oCAA0BA,GADjCA,UACkCA,SAAgBA,IAAEQ,CAACA;;IAE9CR,cAAIA,GADXA,cACcS,CAACA;;IAERT,cAAIA,GADXA,cACcU,CAACA;;IAjBfV,sBACOA,4BAAeA;;YADrBA,gBAAOA,EAAEA;WACHA,4BAAeA,kCAAfA,4BAAeA,IAAqBA;IAC3CA,sBACOA,yBAAYA;;YADlBA,gBAAOA,EAAEA;WACHA,yBAAYA,kCAAZA,yBAAYA,IAAIA;IACvBA,sBACOA,8BAAiBA;;YADvBA,gBAAOA,EAAEA;WACHA,8BAAiBA,kCAAjBA,8BAAiBA,IAAIA;IAC5BA,sBACOA,kCAAqBA;;YAD3BA,gBAAOA,EAAEA;WACHA,kCAAqBA,kCAArBA,kCAAqBA,IAAIA;IAChCA,sBACOA,6BAAgBA;;YADtBA,gBAAOA,EAAEA;WACHA,6BAAgBA,kCAAhBA,6BAAgBA,IAAIA;IAC3BA,sBACOA,kCAAqBA;;YAD3BA,gBAAOA,EAAEA;WACHA,kCAAqBA,kCAArBA,kCAAqBA,IAAoBA;IAChDA,sBACOA,uCAA0BA;;YADhCA,gBAAOA,EAAEA;WACHA,uCAA0BA,kCAA1BA,uCAA0BA,IAAoBA;IACrDA,sBACOA,iBAAIA;;YADVA,gBAAOA,EAAEA;WACHA,iBAAIA,kCAAJA,iBAAIA,IAAIA;IACfA,sBACOA,iBAAIA;;YADVA,gBAAOA,EAAEA;WACHA,iBAAIA,kCAAJA,iBAAIA,IAAIA;IAvBjBA;QAACA,eAAMA,CAACA;YACNA,IAAIA,EAAEA,WAAWA;YACjBA,MAAMA,EAAEA,0BAA0BA;YAClCA,SAASA,EAAEA,WAAWA;SACvBA,CAACA;kBAoBDA;IAADA,gBAACA;AAADA,CAACA,AAxBD,IAwBC;AAnBY,iBAAS,YAmBrB,CAAA"} \ No newline at end of file diff --git a/dist/plugins/toast.js b/dist/plugins/toast.js index 1d750fde..ec55d3a7 100644 --- a/dist/plugins/toast.js +++ b/dist/plugins/toast.js @@ -33,3 +33,4 @@ var Toast = (function () { return Toast; })(); exports.Toast = Toast; +//# sourceMappingURL=toast.js.map \ No newline at end of file diff --git a/dist/plugins/toast.js.map b/dist/plugins/toast.js.map new file mode 100644 index 00000000..00b5a992 --- /dev/null +++ b/dist/plugins/toast.js.map @@ -0,0 +1 @@ +{"version":3,"file":"toast.js","sourceRoot":"","sources":["../../src/plugins/toast.ts"],"names":["Toast","Toast.constructor","Toast.hide","Toast.showWithOptions"],"mappings":";;;;;;;;AAAA,uBAA8B,UAAU,CAAC,CAAA;AAEzC;IAAAA;IAYAC,CAACA;IAJQD,UAAIA,GADXA,cACcE,CAACA;;IAGRF,qBAAeA,GADtBA,UACuBA,OAAWA,IAAEG,CAACA;;IAJrCH,sBACOA,aAAIA;;YADVA,gBAAOA,EAAEA;WACHA,aAAIA,kCAAJA,aAAIA,IAAIA;IAEfA,sBACOA,wBAAeA;;YADrBA,gBAAOA,EAAEA;WACHA,wBAAeA,kCAAfA,wBAAeA,IAAeA;IAXvCA;QAACA,eAAMA,CAACA;YACNA,IAAIA,EAAEA,OAAOA;YACbA,MAAMA,EAAEA,wBAAwBA;YAChCA,SAASA,EAAEA,eAAeA;YAC1BA,IAAIA,EAAEA,yDAAyDA;SAChEA,CAACA;cAODA;IAADA,YAACA;AAADA,CAACA,AAZD,IAYC;AANY,aAAK,QAMjB,CAAA"} \ No newline at end of file diff --git a/dist/src/cordova.d.ts b/dist/src/cordova.d.ts deleted file mode 100644 index e69de29b..00000000 diff --git a/dist/src/cordova.js b/dist/src/cordova.js deleted file mode 100644 index e69de29b..00000000 diff --git a/dist/src/index.d.ts b/dist/src/index.d.ts deleted file mode 100644 index a7d77f92..00000000 --- a/dist/src/index.d.ts +++ /dev/null @@ -1,7 +0,0 @@ -export * from './plugins/actionsheet'; -export * from './plugins/ble'; -export * from './plugins/camera'; -export * from './plugins/contacts'; -export * from './plugins/device'; -export * from './plugins/statusbar'; -export * from './plugins/toast'; diff --git a/dist/src/plugin-config.d.ts b/dist/src/plugin-config.d.ts deleted file mode 100644 index 0975baa7..00000000 --- a/dist/src/plugin-config.d.ts +++ /dev/null @@ -1,8 +0,0 @@ -export interface CordovaPlugin { - id: string; - className: string; - plugin: string; - pluginRef: string; - promise?: any; -} -export declare var PluginConfig: CordovaPlugin[]; diff --git a/dist/src/plugin-config.js b/dist/src/plugin-config.js deleted file mode 100644 index e3bee0f3..00000000 --- a/dist/src/plugin-config.js +++ /dev/null @@ -1,49 +0,0 @@ -exports.PluginConfig = [ - { - id: 'device', - className: 'Device', - plugin: 'cordova-plugin-device', - pluginRef: 'device' - }, - { - id: 'camera', - className: 'Camera', - plugin: 'cordova-plugin-camera', - promise: ['takePicture'], - pluginRef: 'navigator.camera' - }, - { - id: 'statusbar', - className: 'StatusBar', - plugin: 'cordova-plugin-statusbar', - pluginRef: 'StatusBar', - promise: ['show', 'hide', 'styleDefault', 'styleLightContent', 'styleBlackTranslucent', 'styleBlackOpaque'] - }, - { - id: 'applinks', - className: 'AppLinks', - plugin: 'com.lampa.startapp', - pluginRef: 'navigator.startApp', - promise: ['start', 'check'] - }, - { - id: 'barcode', - className: 'Barcode', - plugin: 'phonegap-plugin-barcodescanner', - pluginRef: 'cordova.plugins.barcodeScanner', - promise: ['scan', 'encode'] - }, - { - id: 'camera-roll', - className: 'CameraRoll', - plugin: 'cordova-plugin-camera-roll', - pluginRef: 'CameraRoll', - promise: ['saveToCameraRoll', 'getPhotos'] - }, - { - id: 'contacts', - className: 'Contacts', - plugin: 'cordova-plugin-contacts', - pluginRef: 'navigator.contacts', - }, -]; diff --git a/dist/src/plugins/actionsheet.d.ts b/dist/src/plugins/actionsheet.d.ts deleted file mode 100644 index 67513518..00000000 --- a/dist/src/plugins/actionsheet.d.ts +++ /dev/null @@ -1,4 +0,0 @@ -export declare class ActionSheet { - static show(options: any): void; - static hide(options: any): void; -} diff --git a/dist/src/plugins/actionsheet.js b/dist/src/plugins/actionsheet.js deleted file mode 100644 index eedd4ac9..00000000 --- a/dist/src/plugins/actionsheet.js +++ /dev/null @@ -1,41 +0,0 @@ -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); -}; -var plugin_1 = require('./plugin'); -var ActionSheet = (function () { - function ActionSheet() { - } - ActionSheet.show = function (options) { }; - ; - ActionSheet.hide = function (options) { }; - ; - __decorate([ - plugin_1.Cordova(), - __metadata('design:type', Function), - __metadata('design:paramtypes', [Object]), - __metadata('design:returntype', void 0) - ], ActionSheet, "show", null); - __decorate([ - plugin_1.Cordova(), - __metadata('design:type', Function), - __metadata('design:paramtypes', [Object]), - __metadata('design:returntype', void 0) - ], ActionSheet, "hide", null); - ActionSheet = __decorate([ - plugin_1.Plugin({ - name: 'ActionSheet', - plugin: 'cordova-plugin-actionsheet', - pluginRef: 'plugins.actionsheet', - repo: 'https://github.com/EddyVerbruggen/cordova-plugin-actionsheet' - }), - __metadata('design:paramtypes', []) - ], ActionSheet); - return ActionSheet; -})(); -exports.ActionSheet = ActionSheet; diff --git a/dist/src/plugins/ble.d.ts b/dist/src/plugins/ble.d.ts deleted file mode 100644 index b9f10cee..00000000 --- a/dist/src/plugins/ble.d.ts +++ /dev/null @@ -1,10 +0,0 @@ -export declare class BLE { - static scan(services: any[], seconds: number): void; - static startScan(services: any[]): void; - static stopScan(): void; - static connect(deviceId: string): void; - static disconnect(deviceId: string): void; - static read(deviceId: string, serviceUUID: string, characteristicUUID: string): void; - static write(deviceId: string, serviceUUID: string, characteristicUUID: string, value: ArrayBuffer): void; - static writeWithoutResponse(deviceId: string, serviceUUID: string, characteristicUUID: string, value: ArrayBuffer): void; -} diff --git a/dist/src/plugins/ble.js b/dist/src/plugins/ble.js deleted file mode 100644 index bb540223..00000000 --- a/dist/src/plugins/ble.js +++ /dev/null @@ -1,91 +0,0 @@ -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); -}; -var plugin_1 = require('./plugin'); -var BLE = (function () { - function BLE() { - } - BLE.scan = function (services, seconds) { }; - BLE.startScan = function (services) { }; - ; - BLE.stopScan = function () { }; - ; - BLE.connect = function (deviceId) { }; - ; - BLE.disconnect = function (deviceId) { }; - ; - BLE.read = function (deviceId, serviceUUID, characteristicUUID) { }; - ; - BLE.write = function (deviceId, serviceUUID, characteristicUUID, value) { }; - ; - BLE.writeWithoutResponse = function (deviceId, serviceUUID, characteristicUUID, value) { }; - ; - __decorate([ - plugin_1.Cordova({ - successIndex: 2, - errIndex: 3 - }), - __metadata('design:type', Function), - __metadata('design:paramtypes', [Array, Number]), - __metadata('design:returntype', void 0) - ], BLE, "scan", null); - __decorate([ - plugin_1.Cordova(), - __metadata('design:type', Function), - __metadata('design:paramtypes', [Array]), - __metadata('design:returntype', void 0) - ], BLE, "startScan", null); - __decorate([ - plugin_1.Cordova(), - __metadata('design:type', Function), - __metadata('design:paramtypes', []), - __metadata('design:returntype', void 0) - ], BLE, "stopScan", null); - __decorate([ - plugin_1.Cordova(), - __metadata('design:type', Function), - __metadata('design:paramtypes', [String]), - __metadata('design:returntype', void 0) - ], BLE, "connect", null); - __decorate([ - plugin_1.Cordova(), - __metadata('design:type', Function), - __metadata('design:paramtypes', [String]), - __metadata('design:returntype', void 0) - ], BLE, "disconnect", null); - __decorate([ - plugin_1.Cordova(), - __metadata('design:type', Function), - __metadata('design:paramtypes', [String, String, String]), - __metadata('design:returntype', void 0) - ], BLE, "read", null); - __decorate([ - plugin_1.Cordova(), - __metadata('design:type', Function), - __metadata('design:paramtypes', [String, String, String, ArrayBuffer]), - __metadata('design:returntype', void 0) - ], BLE, "write", null); - __decorate([ - plugin_1.Cordova(), - __metadata('design:type', Function), - __metadata('design:paramtypes', [String, String, String, ArrayBuffer]), - __metadata('design:returntype', void 0) - ], BLE, "writeWithoutResponse", null); - BLE = __decorate([ - plugin_1.Plugin({ - name: 'BluetoothLowEnergy', - plugin: 'cordova-plugin-ble-central', - pluginRef: 'ble', - pluginRepo: 'https://github.com/don/cordova-plugin-ble-central' - }), - __metadata('design:paramtypes', []) - ], BLE); - return BLE; -})(); -exports.BLE = BLE; diff --git a/dist/src/plugins/camera.d.ts b/dist/src/plugins/camera.d.ts deleted file mode 100644 index ca6de50e..00000000 --- a/dist/src/plugins/camera.d.ts +++ /dev/null @@ -1,4 +0,0 @@ -export declare class Camera { - static getPicture(options: any): void; - static cleanup(): void; -} diff --git a/dist/src/plugins/camera.js b/dist/src/plugins/camera.js deleted file mode 100644 index 6b844902..00000000 --- a/dist/src/plugins/camera.js +++ /dev/null @@ -1,42 +0,0 @@ -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); -}; -var plugin_1 = require('./plugin'); -var Camera = (function () { - function Camera() { - } - Camera.getPicture = function (options) { }; - ; - Camera.cleanup = function () { }; - ; - __decorate([ - plugin_1.Cordova({ - callbackOrder: 'reverse' - }), - __metadata('design:type', Function), - __metadata('design:paramtypes', [Object]), - __metadata('design:returntype', void 0) - ], Camera, "getPicture", null); - __decorate([ - plugin_1.Cordova(), - __metadata('design:type', Function), - __metadata('design:paramtypes', []), - __metadata('design:returntype', void 0) - ], Camera, "cleanup", null); - Camera = __decorate([ - plugin_1.Plugin({ - name: 'Camera', - plugin: 'cordova-plugin-camera', - pluginRef: 'navigator.camera' - }), - __metadata('design:paramtypes', []) - ], Camera); - return Camera; -})(); -exports.Camera = Camera; diff --git a/dist/src/plugins/device.d.ts b/dist/src/plugins/device.d.ts deleted file mode 100644 index b477e0aa..00000000 --- a/dist/src/plugins/device.d.ts +++ /dev/null @@ -1,3 +0,0 @@ -export declare class Device { - static getDevice(): any; -} diff --git a/dist/src/plugins/device.js b/dist/src/plugins/device.js deleted file mode 100644 index 7c306693..00000000 --- a/dist/src/plugins/device.js +++ /dev/null @@ -1,33 +0,0 @@ -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); -}; -var plugin_1 = require('./plugin'); -var Device = (function () { - function Device() { - } - Device.getDevice = function () { - return window.device; - }; - __decorate([ - plugin_1.RequiresPlugin, - __metadata('design:type', Function), - __metadata('design:paramtypes', []), - __metadata('design:returntype', void 0) - ], Device, "getDevice", null); - Device = __decorate([ - plugin_1.Plugin({ - name: 'Device', - plugin: 'cordova-plugin-device', - pluginRef: 'device' - }), - __metadata('design:paramtypes', []) - ], Device); - return Device; -})(); -exports.Device = Device; diff --git a/dist/src/plugins/file.d.ts b/dist/src/plugins/file.d.ts deleted file mode 100644 index b92f0bb1..00000000 --- a/dist/src/plugins/file.d.ts +++ /dev/null @@ -1,2 +0,0 @@ -export declare class File { -} diff --git a/dist/src/plugins/file.js b/dist/src/plugins/file.js deleted file mode 100644 index a15049cf..00000000 --- a/dist/src/plugins/file.js +++ /dev/null @@ -1,24 +0,0 @@ -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); -}; -var plugin_1 = require('./plugin'); -var File = (function () { - function File() { - } - File = __decorate([ - plugin_1.Plugin({ - name: 'File', - plugin: 'cordova-plugin-file', - pluginRef: 'cordova.file' - }), - __metadata('design:paramtypes', []) - ], File); - return File; -})(); -exports.File = File; diff --git a/dist/src/plugins/geolocation.d.ts b/dist/src/plugins/geolocation.d.ts deleted file mode 100644 index 528e36a8..00000000 --- a/dist/src/plugins/geolocation.d.ts +++ /dev/null @@ -1,3 +0,0 @@ -export declare class Device { - static getCurrentPosition(options: any): void; -} diff --git a/dist/src/plugins/geolocation.js b/dist/src/plugins/geolocation.js deleted file mode 100644 index 5ac28695..00000000 --- a/dist/src/plugins/geolocation.js +++ /dev/null @@ -1,32 +0,0 @@ -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); -}; -var plugin_1 = require('./plugin'); -var Device = (function () { - function Device() { - } - Device.getCurrentPosition = function (options) { }; - ; - __decorate([ - plugin_1.Cordova(), - __metadata('design:type', Function), - __metadata('design:paramtypes', [Object]), - __metadata('design:returntype', void 0) - ], Device, "getCurrentPosition", null); - Device = __decorate([ - plugin_1.Plugin({ - name: 'Geolocation', - plugin: 'cordova-plugin-geolocation', - pluginRef: 'navigator.geolocation' - }), - __metadata('design:paramtypes', []) - ], Device); - return Device; -})(); -exports.Device = Device; diff --git a/dist/src/plugins/plugin.d.ts b/dist/src/plugins/plugin.d.ts deleted file mode 100644 index 567a89ff..00000000 --- a/dist/src/plugins/plugin.d.ts +++ /dev/null @@ -1,10 +0,0 @@ -export declare const getPlugin: (pluginRef: string) => any; -export declare const isInstalled: (pluginRef: string) => boolean; -export declare const pluginWarn: (pluginName: string, method: string, plugin: string) => void; -export declare const cordovaWarn: (pluginName: string, method: string) => void; -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): (target: Object, methodName: string, descriptor: TypedPropertyDescriptor) => { - value: (...args: any[]) => any; -}; -export declare function RequiresPlugin(target: Function, key: string, descriptor: TypedPropertyDescriptor): TypedPropertyDescriptor; diff --git a/dist/src/plugins/statusbar.d.ts b/dist/src/plugins/statusbar.d.ts deleted file mode 100644 index 2f16d987..00000000 --- a/dist/src/plugins/statusbar.d.ts +++ /dev/null @@ -1,11 +0,0 @@ -export declare class StatusBar { - static overlaysWebView(doOverlay: boolean): void; - static styleDefault(): void; - static styleLightContent(): void; - static styleBlackTranslucent(): void; - static styleBlackOpaque(): void; - static backgroundColorByName(colorName: string): void; - static backgroundColorByHexString(hexString: string): void; - static hide(): void; - static show(): void; -} diff --git a/dist/src/plugins/statusbar.js b/dist/src/plugins/statusbar.js deleted file mode 100644 index 28b95380..00000000 --- a/dist/src/plugins/statusbar.js +++ /dev/null @@ -1,96 +0,0 @@ -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); -}; -var plugin_1 = require('./plugin'); -var StatusBar = (function () { - function StatusBar() { - } - StatusBar.overlaysWebView = function (doOverlay) { }; - ; - StatusBar.styleDefault = function () { }; - ; - StatusBar.styleLightContent = function () { }; - ; - StatusBar.styleBlackTranslucent = function () { }; - ; - StatusBar.styleBlackOpaque = function () { }; - ; - StatusBar.backgroundColorByName = function (colorName) { }; - ; - StatusBar.backgroundColorByHexString = function (hexString) { }; - ; - StatusBar.hide = function () { }; - ; - StatusBar.show = function () { }; - ; - __decorate([ - plugin_1.Cordova(), - __metadata('design:type', Function), - __metadata('design:paramtypes', [Boolean]), - __metadata('design:returntype', void 0) - ], StatusBar, "overlaysWebView", null); - __decorate([ - plugin_1.Cordova(), - __metadata('design:type', Function), - __metadata('design:paramtypes', []), - __metadata('design:returntype', void 0) - ], StatusBar, "styleDefault", null); - __decorate([ - plugin_1.Cordova(), - __metadata('design:type', Function), - __metadata('design:paramtypes', []), - __metadata('design:returntype', void 0) - ], StatusBar, "styleLightContent", null); - __decorate([ - plugin_1.Cordova(), - __metadata('design:type', Function), - __metadata('design:paramtypes', []), - __metadata('design:returntype', void 0) - ], StatusBar, "styleBlackTranslucent", null); - __decorate([ - plugin_1.Cordova(), - __metadata('design:type', Function), - __metadata('design:paramtypes', []), - __metadata('design:returntype', void 0) - ], StatusBar, "styleBlackOpaque", null); - __decorate([ - plugin_1.Cordova(), - __metadata('design:type', Function), - __metadata('design:paramtypes', [String]), - __metadata('design:returntype', void 0) - ], StatusBar, "backgroundColorByName", null); - __decorate([ - plugin_1.Cordova(), - __metadata('design:type', Function), - __metadata('design:paramtypes', [String]), - __metadata('design:returntype', void 0) - ], StatusBar, "backgroundColorByHexString", null); - __decorate([ - plugin_1.Cordova(), - __metadata('design:type', Function), - __metadata('design:paramtypes', []), - __metadata('design:returntype', void 0) - ], StatusBar, "hide", null); - __decorate([ - plugin_1.Cordova(), - __metadata('design:type', Function), - __metadata('design:paramtypes', []), - __metadata('design:returntype', void 0) - ], StatusBar, "show", null); - StatusBar = __decorate([ - plugin_1.Plugin({ - name: 'StatusBar', - plugin: 'cordova-plugin-statusbar', - pluginRef: 'StatusBar' - }), - __metadata('design:paramtypes', []) - ], StatusBar); - return StatusBar; -})(); -exports.StatusBar = StatusBar; diff --git a/dist/src/plugins/toast.d.ts b/dist/src/plugins/toast.d.ts deleted file mode 100644 index fe6ffc54..00000000 --- a/dist/src/plugins/toast.d.ts +++ /dev/null @@ -1,4 +0,0 @@ -export declare class Toast { - static hide(): void; - static showWithOptions(options: any): void; -} diff --git a/dist/src/plugins/toast.js b/dist/src/plugins/toast.js deleted file mode 100644 index e1924f4b..00000000 --- a/dist/src/plugins/toast.js +++ /dev/null @@ -1,41 +0,0 @@ -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); -}; -var plugin_1 = require('./plugin'); -var Toast = (function () { - function Toast() { - } - Toast.hide = function () { }; - ; - Toast.showWithOptions = function (options) { }; - ; - __decorate([ - plugin_1.Cordova(), - __metadata('design:type', Function), - __metadata('design:paramtypes', []), - __metadata('design:returntype', void 0) - ], Toast, "hide", null); - __decorate([ - plugin_1.Cordova(), - __metadata('design:type', Function), - __metadata('design:paramtypes', [Object]), - __metadata('design:returntype', void 0) - ], Toast, "showWithOptions", null); - Toast = __decorate([ - plugin_1.Plugin({ - name: 'Toast', - plugin: 'cordova-plugin-x-toast', - pluginRef: 'plugins.toast', - repo: 'https://github.com/EddyVerbruggen/Toast-PhoneGap-Plugin' - }), - __metadata('design:paramtypes', []) - ], Toast); - return Toast; -})(); -exports.Toast = Toast; diff --git a/dist/src/util.d.ts b/dist/src/util.d.ts deleted file mode 100644 index f9cb3d63..00000000 --- a/dist/src/util.d.ts +++ /dev/null @@ -1 +0,0 @@ -export declare function get(obj: any, path: any): any; diff --git a/dist/util.js b/dist/util.js index 86fe4a2c..19dd6ac9 100644 --- a/dist/util.js +++ b/dist/util.js @@ -9,3 +9,4 @@ function get(obj, path) { } exports.get = get; ; +//# sourceMappingURL=util.js.map \ No newline at end of file diff --git a/dist/util.js.map b/dist/util.js.map new file mode 100644 index 00000000..33a54c14 --- /dev/null +++ b/dist/util.js.map @@ -0,0 +1 @@ +{"version":3,"file":"util.js","sourceRoot":"","sources":["../src/util.ts"],"names":["get"],"mappings":"AAAA,aAAoB,GAAG,EAAE,IAAI;IAC3BA,GAAGA,CAAAA,CAACA,GAAGA,CAACA,CAACA,GAAGA,CAACA,EAAEA,IAAIA,GAAGA,IAAIA,CAACA,KAAKA,CAACA,GAAGA,CAACA,EAAEA,GAAGA,GAAGA,IAAIA,CAACA,MAAMA,EAAEA,CAACA,GAAGA,GAAGA,EAAEA,CAACA,EAAEA,EAAEA,CAACA;QACvEA,EAAEA,CAAAA,CAACA,CAACA,GAAGA,CAACA,CAACA,CAACA;YAACA,MAAMA,CAACA,IAAIA,CAACA;QAACA,CAACA;QACzBA,GAAGA,GAAGA,GAAGA,CAACA,IAAIA,CAACA,CAACA,CAACA,CAACA,CAACA;IACrBA,CAACA;IACDA,MAAMA,CAACA,GAAGA,CAACA;AACbA,CAACA;AANe,WAAG,MAMlB,CAAA;AAAA,CAAC"} \ No newline at end of file diff --git a/package.json b/package.json index fb547cba..aa04c6ce 100644 --- a/package.json +++ b/package.json @@ -11,7 +11,7 @@ }, "scripts": { "test": "echo \"Error: no test specified\" && exit 1", - "build": "tsc --experimentalDecorators" + "build": "tsc -w --module commonjs --sourcemap --outDir dist/ --experimentalDecorators -d node_modules/@reactivex/rxjs/typings/es6-shim/es6-shim.d.ts src/index.ts --target ES5" }, "repository": { "type": "git", diff --git a/dist/src/index.js b/src/index.js similarity index 91% rename from dist/src/index.js rename to src/index.js index 5e6a7537..222b9b39 100644 --- a/dist/src/index.js +++ b/src/index.js @@ -1,20 +1,22 @@ -function __export(m) { - for (var p in m) if (!exports.hasOwnProperty(p)) exports[p] = m[p]; -} -var DEVICE_READY_TIMEOUT = 2000; -__export(require('./plugins/actionsheet')); -__export(require('./plugins/ble')); -__export(require('./plugins/camera')); -__export(require('./plugins/contacts')); -__export(require('./plugins/device')); -__export(require('./plugins/statusbar')); -__export(require('./plugins/toast')); -var didFireReady = false; -window.addEventListener('deviceready', function () { - didFireReady = true; -}); -setTimeout(function () { - if (!didFireReady && window.cordova) { - console.warn('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.'); - } -}, DEVICE_READY_TIMEOUT); +function __export(m) { + for (var p in m) if (!exports.hasOwnProperty(p)) exports[p] = m[p]; +} +var DEVICE_READY_TIMEOUT = 2000; +__export(require('./plugins/actionsheet')); +__export(require('./plugins/ble')); +__export(require('./plugins/camera')); +__export(require('./plugins/contacts')); +__export(require('./plugins/device')); +__export(require('./plugins/geolocation')); +__export(require('./plugins/statusbar')); +__export(require('./plugins/toast')); +var didFireReady = false; +window.addEventListener('deviceready', function () { + didFireReady = true; +}); +setTimeout(function () { + if (!didFireReady && window.cordova) { + console.warn('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.'); + } +}, DEVICE_READY_TIMEOUT); +//# sourceMappingURL=index.js.map \ No newline at end of file diff --git a/src/index.js.map b/src/index.js.map new file mode 100644 index 00000000..9df8eedd --- /dev/null +++ b/src/index.js.map @@ -0,0 +1 @@ +{"version":3,"file":"index.js","sourceRoot":"","sources":["index.ts"],"names":[],"mappings":";;;AAAA,IAAM,oBAAoB,GAAG,IAAI,CAAC;AAElC,iBAAc,uBAAuB,CAAC,EAAA;AACtC,iBAAc,eAAe,CAAC,EAAA;AAC9B,iBAAc,kBAAkB,CAAC,EAAA;AACjC,iBAAc,oBAAoB,CAAC,EAAA;AACnC,iBAAc,kBAAkB,CAAC,EAAA;AACjC,iBAAc,uBAAuB,CAAC,EAAA;AACtC,iBAAc,qBAAqB,CAAC,EAAA;AACpC,iBAAc,iBAAiB,CAAC,EAAA;AAShC,IAAI,YAAY,GAAG,KAAK,CAAC;AACzB,MAAM,CAAC,gBAAgB,CAAC,aAAa,EAAE;IACrC,YAAY,GAAG,IAAI,CAAC;AACtB,CAAC,CAAC,CAAA;AAEF,UAAU,CAAC;IACT,EAAE,CAAA,CAAC,CAAC,YAAY,IAAI,MAAM,CAAC,OAAO,CAAC,CAAC,CAAC;QACnC,OAAO,CAAC,IAAI,CAAC,0CAA0C,GAAG,oBAAoB,GAAG,0HAA0H,CAAC,CAAC;IAC/M,CAAC;AACH,CAAC,EAAE,oBAAoB,CAAC,CAAC"} \ No newline at end of file diff --git a/src/index.ts b/src/index.ts index 5cd4973e..9c099186 100644 --- a/src/index.ts +++ b/src/index.ts @@ -5,6 +5,7 @@ export * from './plugins/ble'; export * from './plugins/camera'; export * from './plugins/contacts'; export * from './plugins/device'; +export * from './plugins/geolocation'; export * from './plugins/statusbar'; export * from './plugins/toast'; diff --git a/src/plugins/actionsheet.js b/src/plugins/actionsheet.js new file mode 100644 index 00000000..c43da84a --- /dev/null +++ b/src/plugins/actionsheet.js @@ -0,0 +1,36 @@ +var __decorate = (this && this.__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 ActionSheet = (function () { + function ActionSheet() { + } + ActionSheet.show = function (options) { }; + ; + ActionSheet.hide = function (options) { }; + ; + Object.defineProperty(ActionSheet, "show", + __decorate([ + plugin_1.Cordova() + ], ActionSheet, "show", Object.getOwnPropertyDescriptor(ActionSheet, "show"))); + Object.defineProperty(ActionSheet, "hide", + __decorate([ + plugin_1.Cordova() + ], ActionSheet, "hide", Object.getOwnPropertyDescriptor(ActionSheet, "hide"))); + ActionSheet = __decorate([ + plugin_1.Plugin({ + name: 'ActionSheet', + plugin: 'cordova-plugin-actionsheet', + pluginRef: 'plugins.actionsheet', + repo: 'https://github.com/EddyVerbruggen/cordova-plugin-actionsheet' + }) + ], ActionSheet); + return ActionSheet; +})(); +exports.ActionSheet = ActionSheet; +//# sourceMappingURL=actionsheet.js.map \ No newline at end of file diff --git a/src/plugins/actionsheet.js.map b/src/plugins/actionsheet.js.map new file mode 100644 index 00000000..361fdeb8 --- /dev/null +++ b/src/plugins/actionsheet.js.map @@ -0,0 +1 @@ +{"version":3,"file":"actionsheet.js","sourceRoot":"","sources":["actionsheet.ts"],"names":["ActionSheet","ActionSheet.constructor","ActionSheet.show","ActionSheet.hide"],"mappings":";;;;;;;;AAAA,uBAA8B,UAAU,CAAC,CAAA;AAEzC;IAAAA;IAYAC,CAACA;IAJQD,gBAAIA,GADXA,UACYA,OAAWA,IAAEE,CAACA;;IAGnBF,gBAAIA,GADXA,UACYA,OAAWA,IAAEG,CAACA;;IAJ1BH,sBACOA,mBAAIA;;YADVA,gBAAOA,EAAEA;WACHA,mBAAIA,kCAAJA,mBAAIA,IAAeA;IAE1BA,sBACOA,mBAAIA;;YADVA,gBAAOA,EAAEA;WACHA,mBAAIA,kCAAJA,mBAAIA,IAAeA;IAX5BA;QAACA,eAAMA,CAACA;YACNA,IAAIA,EAAEA,aAAaA;YACnBA,MAAMA,EAAEA,4BAA4BA;YACpCA,SAASA,EAAEA,qBAAqBA;YAChCA,IAAIA,EAAEA,8DAA8DA;SACrEA,CAACA;oBAODA;IAADA,kBAACA;AAADA,CAACA,AAZD,IAYC;AANY,mBAAW,cAMvB,CAAA"} \ No newline at end of file diff --git a/src/plugins/ble.js b/src/plugins/ble.js new file mode 100644 index 00000000..4c04d745 --- /dev/null +++ b/src/plugins/ble.js @@ -0,0 +1,71 @@ +var __decorate = (this && this.__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 BLE = (function () { + function BLE() { + } + BLE.scan = function (services, seconds) { }; + BLE.startScan = function (services) { }; + ; + BLE.stopScan = function () { }; + ; + BLE.connect = function (deviceId) { }; + ; + BLE.disconnect = function (deviceId) { }; + ; + BLE.read = function (deviceId, serviceUUID, characteristicUUID) { }; + ; + BLE.write = function (deviceId, serviceUUID, characteristicUUID, value) { }; + ; + BLE.writeWithoutResponse = function (deviceId, serviceUUID, characteristicUUID, value) { }; + ; + Object.defineProperty(BLE, "scan", + __decorate([ + plugin_1.Cordova() + ], BLE, "scan", Object.getOwnPropertyDescriptor(BLE, "scan"))); + Object.defineProperty(BLE, "startScan", + __decorate([ + plugin_1.Cordova() + ], BLE, "startScan", Object.getOwnPropertyDescriptor(BLE, "startScan"))); + Object.defineProperty(BLE, "stopScan", + __decorate([ + plugin_1.Cordova() + ], BLE, "stopScan", Object.getOwnPropertyDescriptor(BLE, "stopScan"))); + Object.defineProperty(BLE, "connect", + __decorate([ + plugin_1.Cordova() + ], BLE, "connect", Object.getOwnPropertyDescriptor(BLE, "connect"))); + Object.defineProperty(BLE, "disconnect", + __decorate([ + plugin_1.Cordova() + ], BLE, "disconnect", Object.getOwnPropertyDescriptor(BLE, "disconnect"))); + Object.defineProperty(BLE, "read", + __decorate([ + plugin_1.Cordova() + ], BLE, "read", Object.getOwnPropertyDescriptor(BLE, "read"))); + Object.defineProperty(BLE, "write", + __decorate([ + plugin_1.Cordova() + ], BLE, "write", Object.getOwnPropertyDescriptor(BLE, "write"))); + Object.defineProperty(BLE, "writeWithoutResponse", + __decorate([ + plugin_1.Cordova() + ], BLE, "writeWithoutResponse", Object.getOwnPropertyDescriptor(BLE, "writeWithoutResponse"))); + BLE = __decorate([ + plugin_1.Plugin({ + name: 'BluetoothLowEnergy', + plugin: 'cordova-plugin-ble-central', + pluginRef: 'ble', + pluginRepo: 'https://github.com/don/cordova-plugin-ble-central' + }) + ], BLE); + return BLE; +})(); +exports.BLE = BLE; +//# sourceMappingURL=ble.js.map \ No newline at end of file diff --git a/src/plugins/ble.js.map b/src/plugins/ble.js.map new file mode 100644 index 00000000..44723ab4 --- /dev/null +++ b/src/plugins/ble.js.map @@ -0,0 +1 @@ +{"version":3,"file":"ble.js","sourceRoot":"","sources":["ble.ts"],"names":["BLE","BLE.constructor","BLE.scan","BLE.startScan","BLE.stopScan","BLE.connect","BLE.disconnect","BLE.read","BLE.write","BLE.writeWithoutResponse"],"mappings":";;;;;;;;AAAA,uBAA8B,UAAU,CAAC,CAAA;AAEzC;IAAAA;IA8BAC,CAACA;IAtBQD,QAAIA,GADXA,UACYA,QAAcA,EAAEA,OAAcA,IAAGE,CAACA;IAGvCF,aAASA,GADhBA,UACiBA,QAAcA,IAAEG,CAACA;;IAG3BH,YAAQA,GADfA,cACkBI,CAACA;;IAGZJ,WAAOA,GADdA,UACeA,QAAeA,IAAEK,CAACA;;IAG1BL,cAAUA,GADjBA,UACkBA,QAAeA,IAAEM,CAACA;;IAG7BN,QAAIA,GADXA,UACYA,QAAeA,EAAEA,WAAkBA,EAAEA,kBAAyBA,IAAEO,CAACA;;IAGtEP,SAAKA,GADZA,UACaA,QAAeA,EAAEA,WAAkBA,EAAEA,kBAAyBA,EAAEA,KAAiBA,IAAEQ,CAACA;;IAG1FR,wBAAoBA,GAD3BA,UAC4BA,QAAeA,EAAEA,WAAkBA,EAAEA,kBAAyBA,EAAEA,KAAiBA,IAAES,CAACA;;IAtBhHT,sBACOA,WAAIA;;YADVA,gBAAOA,EAAEA;WACHA,WAAIA,kCAAJA,WAAIA,IAAmCA;IAE9CA,sBACOA,gBAASA;;YADfA,gBAAOA,EAAEA;WACHA,gBAASA,kCAATA,gBAASA,IAAkBA;IAElCA,sBACOA,eAAQA;;YADdA,gBAAOA,EAAEA;WACHA,eAAQA,kCAARA,eAAQA,IAAIA;IAEnBA,sBACOA,cAAOA;;YADbA,gBAAOA,EAAEA;WACHA,cAAOA,kCAAPA,cAAOA,IAAmBA;IAEjCA,sBACOA,iBAAUA;;YADhBA,gBAAOA,EAAEA;WACHA,iBAAUA,kCAAVA,iBAAUA,IAAmBA;IAEpCA,sBACOA,WAAIA;;YADVA,gBAAOA,EAAEA;WACHA,WAAIA,kCAAJA,WAAIA,IAAkEA;IAE7EA,sBACOA,YAAKA;;YADXA,gBAAOA,EAAEA;WACHA,YAAKA,kCAALA,YAAKA,IAAqFA;IAEjGA,sBACOA,2BAAoBA;;YAD1BA,gBAAOA,EAAEA;WACHA,2BAAoBA,kCAApBA,2BAAoBA,IAAqFA;IA7BlHA;QAACA,eAAMA,CAACA;YACNA,IAAIA,EAAEA,oBAAoBA;YAC1BA,MAAMA,EAAEA,4BAA4BA;YACpCA,SAASA,EAAEA,KAAKA;YAChBA,UAAUA,EAAEA,mDAAmDA;SAChEA,CAACA;YAyBDA;IAADA,UAACA;AAADA,CAACA,AA9BD,IA8BC;AAxBY,WAAG,MAwBf,CAAA"} \ No newline at end of file diff --git a/src/plugins/camera.js b/src/plugins/camera.js new file mode 100644 index 00000000..b4122a98 --- /dev/null +++ b/src/plugins/camera.js @@ -0,0 +1,38 @@ +var __decorate = (this && this.__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 Camera = (function () { + function Camera() { + } + Camera.getPicture = function (options) { }; + ; + Camera.cleanup = function () { }; + ; + Object.defineProperty(Camera, "getPicture", + __decorate([ + plugin_1.Cordova({ + // Not sure why this plugin has the success/err come first... + callbackOrder: 'reverse' + }) + ], Camera, "getPicture", Object.getOwnPropertyDescriptor(Camera, "getPicture"))); + Object.defineProperty(Camera, "cleanup", + __decorate([ + plugin_1.Cordova() + ], Camera, "cleanup", Object.getOwnPropertyDescriptor(Camera, "cleanup"))); + Camera = __decorate([ + plugin_1.Plugin({ + name: 'Camera', + plugin: 'cordova-plugin-camera', + pluginRef: 'navigator.camera' + }) + ], Camera); + return Camera; +})(); +exports.Camera = Camera; +//# sourceMappingURL=camera.js.map \ No newline at end of file diff --git a/src/plugins/camera.js.map b/src/plugins/camera.js.map new file mode 100644 index 00000000..b4d05500 --- /dev/null +++ b/src/plugins/camera.js.map @@ -0,0 +1 @@ +{"version":3,"file":"camera.js","sourceRoot":"","sources":["camera.ts"],"names":["Camera","Camera.constructor","Camera.getPicture","Camera.cleanup"],"mappings":";;;;;;;;AAAA,uBAA8B,UAAU,CAAC,CAAA;AAEzC;IAAAA;IAcAC,CAACA;IAJQD,iBAAUA,GAJjBA,UAIkBA,OAAWA,IAAEE,CAACA;;IAGzBF,cAAOA,GADdA,cACiBG,CAACA;;IAPlBH,sBAIOA,oBAAUA;;YAJhBA,gBAAOA,CAACA;gBACPA,6DAA6DA;gBAC7DA,aAAaA,EAAEA,SAASA;aACzBA,CAACA;WACKA,oBAAUA,kCAAVA,oBAAUA,IAAeA;IAEhCA,sBACOA,iBAAOA;;YADbA,gBAAOA,EAAEA;WACHA,iBAAOA,kCAAPA,iBAAOA,IAAIA;IAbpBA;QAACA,eAAMA,CAACA;YACNA,IAAIA,EAAEA,QAAQA;YACdA,MAAMA,EAAEA,uBAAuBA;YAC/BA,SAASA,EAAEA,kBAAkBA;SAC9BA,CAACA;eAUDA;IAADA,aAACA;AAADA,CAACA,AAdD,IAcC;AATY,cAAM,SASlB,CAAA"} \ No newline at end of file diff --git a/src/plugins/contacts.js b/src/plugins/contacts.js new file mode 100644 index 00000000..00342bdf --- /dev/null +++ b/src/plugins/contacts.js @@ -0,0 +1,48 @@ +var __decorate = (this && this.__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 Contacts = (function () { + function Contacts() { + } + Contacts.create = function (fields, options) { }; + ; + Contacts.find = function (fields, options) { }; + ; + Contacts.pickContact = function () { }; + ; + Object.defineProperty(Contacts, "create", + __decorate([ + plugin_1.Cordova({ + successIndex: 1, + errorIndex: 2 + }) + ], Contacts, "create", Object.getOwnPropertyDescriptor(Contacts, "create"))); + Object.defineProperty(Contacts, "find", + __decorate([ + plugin_1.Cordova({ + successIndex: 1, + errorIndex: 2 + }) + ], Contacts, "find", Object.getOwnPropertyDescriptor(Contacts, "find"))); + Object.defineProperty(Contacts, "pickContact", + __decorate([ + plugin_1.Cordova() + ], Contacts, "pickContact", Object.getOwnPropertyDescriptor(Contacts, "pickContact"))); + Contacts = __decorate([ + plugin_1.Plugin({ + name: 'Contacts', + plugin: 'cordova-plugin-contacts', + pluginRef: 'navigator.contacts', + repo: 'https://github.com/apache/cordova-plugin-contacts' + }) + ], Contacts); + return Contacts; +})(); +exports.Contacts = Contacts; +//# sourceMappingURL=contacts.js.map \ No newline at end of file diff --git a/src/plugins/contacts.js.map b/src/plugins/contacts.js.map new file mode 100644 index 00000000..e414eaf2 --- /dev/null +++ b/src/plugins/contacts.js.map @@ -0,0 +1 @@ +{"version":3,"file":"contacts.js","sourceRoot":"","sources":["contacts.ts"],"names":["Contacts","Contacts.constructor","Contacts.create","Contacts.find","Contacts.pickContact"],"mappings":";;;;;;;;AAAA,uBAA8B,UAAU,CAAC,CAAA;AAEzC;IAAAA;IAsBAC,CAACA;IAVQD,eAAMA,GALbA,UAKcA,MAAeA,EAAEA,OAAWA,IAAEE,CAACA;;IAMtCF,aAAIA,GAJXA,UAIYA,MAAeA,EAAEA,OAAWA,IAAEG,CAACA;;IAGpCH,oBAAWA,GADlBA,cACqBI,CAACA;;IAdtBJ,sBAKOA,kBAAMA;;YALZA,gBAAOA,CAACA;gBACPA,YAAYA,EAAEA,CAACA;gBACfA,UAAUA,EAAEA,CAACA;aACdA,CAACA;WAEKA,kBAAMA,kCAANA,kBAAMA,IAAgCA;IAE7CA,sBAIOA,gBAAIA;;YAJVA,gBAAOA,CAACA;gBACPA,YAAYA,EAAEA,CAACA;gBACfA,UAAUA,EAAEA,CAACA;aACdA,CAACA;WACKA,gBAAIA,kCAAJA,gBAAIA,IAAgCA;IAE3CA,sBACOA,uBAAWA;;YADjBA,gBAAOA,EAAEA;WACHA,uBAAWA,kCAAXA,uBAAWA,IAAIA;IArBxBA;QAACA,eAAMA,CAACA;YACNA,IAAIA,EAAEA,UAAUA;YAChBA,MAAMA,EAAEA,yBAAyBA;YACjCA,SAASA,EAAEA,oBAAoBA;YAC/BA,IAAIA,EAAEA,mDAAmDA;SAC1DA,CAACA;iBAiBDA;IAADA,eAACA;AAADA,CAACA,AAtBD,IAsBC;AAhBY,gBAAQ,WAgBpB,CAAA"} \ No newline at end of file diff --git a/src/plugins/device.js b/src/plugins/device.js new file mode 100644 index 00000000..0fd6d634 --- /dev/null +++ b/src/plugins/device.js @@ -0,0 +1,30 @@ +var __decorate = (this && this.__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 Device = (function () { + function Device() { + } + Device.getDevice = function () { + return window.device; + }; + Object.defineProperty(Device, "getDevice", + __decorate([ + plugin_1.RequiresPlugin + ], Device, "getDevice", Object.getOwnPropertyDescriptor(Device, "getDevice"))); + Device = __decorate([ + plugin_1.Plugin({ + name: 'Device', + plugin: 'cordova-plugin-device', + pluginRef: 'device' + }) + ], Device); + return Device; +})(); +exports.Device = Device; +//# sourceMappingURL=device.js.map \ No newline at end of file diff --git a/src/plugins/device.js.map b/src/plugins/device.js.map new file mode 100644 index 00000000..321e6006 --- /dev/null +++ b/src/plugins/device.js.map @@ -0,0 +1 @@ +{"version":3,"file":"device.js","sourceRoot":"","sources":["device.ts"],"names":["Device","Device.constructor","Device.getDevice"],"mappings":";;;;;;;;AAAA,uBAAqC,UAAU,CAAC,CAAA;AAIhD;IAAAA;IAWAC,CAACA;IAHQD,gBAASA,GADhBA;QAEEE,MAAMA,CAACA,MAAMA,CAACA,MAAMA,CAACA;IACvBA,CAACA;IAHDF,sBACOA,mBAASA;;YADfA,uBAAcA;WACRA,mBAASA,kCAATA,mBAASA,IAEfA;IAVHA;QAACA,eAAMA,CAACA;YACNA,IAAIA,EAAEA,QAAQA;YACdA,MAAMA,EAAEA,uBAAuBA;YAC/BA,SAASA,EAAEA,QAAQA;SACpBA,CAACA;eAODA;IAADA,aAACA;AAADA,CAACA,AAXD,IAWC;AANY,cAAM,SAMlB,CAAA"} \ No newline at end of file diff --git a/dist/plugins/file.js b/src/plugins/file.js similarity index 87% rename from dist/plugins/file.js rename to src/plugins/file.js index 92e62656..cae20034 100644 --- a/dist/plugins/file.js +++ b/src/plugins/file.js @@ -1,4 +1,4 @@ -if (typeof __decorate !== "function") __decorate = function (decorators, target, key, desc) { +var __decorate = (this && this.__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); @@ -20,3 +20,4 @@ var File = (function () { return File; })(); exports.File = File; +//# sourceMappingURL=file.js.map \ No newline at end of file diff --git a/src/plugins/file.js.map b/src/plugins/file.js.map new file mode 100644 index 00000000..d1887339 --- /dev/null +++ b/src/plugins/file.js.map @@ -0,0 +1 @@ +{"version":3,"file":"file.js","sourceRoot":"","sources":["file.ts"],"names":["File","File.constructor"],"mappings":";;;;;;;;AAAA,uBAA8B,UAAU,CAAC,CAAA;AAIzC;IAAAA;IAMAC,CAACA;IANDD;QAACA,eAAMA,CAACA;YACNA,IAAIA,EAAEA,MAAMA;YACZA,MAAMA,EAAEA,qBAAqBA;YAC7BA,SAASA,EAAEA,cAAcA;SAC1BA,CAACA;aAEDA;IAADA,WAACA;AAADA,CAACA,AAND,IAMC;AADY,YAAI,OAChB,CAAA"} \ No newline at end of file diff --git a/src/plugins/geolocation.js b/src/plugins/geolocation.js new file mode 100644 index 00000000..edaeedfc --- /dev/null +++ b/src/plugins/geolocation.js @@ -0,0 +1,38 @@ +var __decorate = (this && this.__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 Device = (function () { + function Device() { + } + Device.getCurrentPosition = function (options) { }; + ; + Device.watchPosition = function (options) { }; + ; + Object.defineProperty(Device, "getCurrentPosition", + __decorate([ + plugin_1.Cordova() + ], Device, "getCurrentPosition", Object.getOwnPropertyDescriptor(Device, "getCurrentPosition"))); + Object.defineProperty(Device, "watchPosition", + __decorate([ + plugin_1.Cordova({ + observable: true, + clearFunction: 'clearWatch()' + }) + ], Device, "watchPosition", Object.getOwnPropertyDescriptor(Device, "watchPosition"))); + Device = __decorate([ + plugin_1.Plugin({ + name: 'Geolocation', + plugin: 'cordova-plugin-geolocation', + pluginRef: 'navigator.geolocation' + }) + ], Device); + return Device; +})(); +exports.Device = Device; +//# sourceMappingURL=geolocation.js.map \ No newline at end of file diff --git a/src/plugins/geolocation.js.map b/src/plugins/geolocation.js.map new file mode 100644 index 00000000..77517f7b --- /dev/null +++ b/src/plugins/geolocation.js.map @@ -0,0 +1 @@ +{"version":3,"file":"geolocation.js","sourceRoot":"","sources":["geolocation.ts"],"names":["Device","Device.constructor","Device.getCurrentPosition","Device.watchPosition"],"mappings":";;;;;;;;AAAA,uBAA8B,UAAU,CAAC,CAAA;AAMzC;IAAAA;IAeAC,CAACA;IARQD,yBAAkBA,GADzBA,UAC0BA,OAAWA,IAAEE,CAACA;;IAOjCF,oBAAaA,GAJpBA,UAIqBA,OAAWA,IAAEG,CAACA;;IARnCH,sBACOA,4BAAkBA;;YADxBA,gBAAOA,EAAEA;WACHA,4BAAkBA,kCAAlBA,4BAAkBA,IAAeA;IAGxCA,sBAIOA,uBAAaA;;YAJnBA,gBAAOA,CAACA;gBACPA,UAAUA,EAAEA,IAAIA;gBAChBA,aAAaA,EAAEA,cAAcA;aAC9BA,CAACA;WACKA,uBAAaA,kCAAbA,uBAAaA,IAAeA;IAdrCA;QAACA,eAAMA,CAACA;YACNA,IAAIA,EAAEA,aAAaA;YACnBA,MAAMA,EAAEA,4BAA4BA;YACpCA,SAASA,EAAEA,uBAAuBA;SACnCA,CAACA;eAWDA;IAADA,aAACA;AAADA,CAACA,AAfD,IAeC;AAVY,cAAM,SAUlB,CAAA"} \ No newline at end of file diff --git a/src/plugins/geolocation.ts b/src/plugins/geolocation.ts index d5474996..df677229 100644 --- a/src/plugins/geolocation.ts +++ b/src/plugins/geolocation.ts @@ -1,5 +1,7 @@ import {Plugin, Cordova} from './plugin'; +declare var Promise; + declare var window; @Plugin({ @@ -12,7 +14,9 @@ export class Device { static getCurrentPosition(options:any){}; - // Do this with observables - // @Cordova() - // static watchPosition; + @Cordova({ + observable: true, + clearFunction: 'clearWatch()' + }) + static watchPosition(options:any){}; } diff --git a/dist/src/plugins/plugin.js b/src/plugins/plugin.js similarity index 50% rename from dist/src/plugins/plugin.js rename to src/plugins/plugin.js index 92663d1c..4983804f 100644 --- a/dist/src/plugins/plugin.js +++ b/src/plugins/plugin.js @@ -1,114 +1,154 @@ -var util_1 = require('../util'); -exports.getPlugin = function (pluginRef) { - return util_1.get(window, pluginRef); -}; -exports.isInstalled = function (pluginRef) { - return !!exports.getPlugin(pluginRef); -}; -exports.pluginWarn = function (pluginName, method, plugin) { - if (method) { - console.warn('Native: tried calling ' + pluginName + '.' + method + - ', but the ' + pluginName + ' plugin is not installed. Install the ' + - plugin + ' plugin'); - } - else { - console.warn('Native: tried accessing the ' + pluginName + ' plugin but it\'s not installed. Install the ' + plugin + ' plugin'); - } -}; -exports.cordovaWarn = function (pluginName, method) { - if (method) { - console.warn('Native: tried calling ' + pluginName + '.' + method + ', but Cordova is not available. Make sure to include cordova.js or run in a device/simulator'); - } - else { - console.warn('Native: tried accessing the ' + pluginName + ' plugin but Cordova is not available. Make sure to include cordova.js or run in a device/simulator'); - } -}; -exports.wrap = function (pluginObj, methodName, opts) { - if (opts === void 0) { opts = {}; } - console.log('Wrap', pluginObj.name, methodName); - return function () { - var args = []; - for (var _i = 0; _i < arguments.length; _i++) { - args[_i - 0] = arguments[_i]; - } - console.log('Wrap CALLED', pluginObj.name, methodName, args); - return new Promise(function (resolve, reject) { - if (!window.cordova) { - exports.cordovaWarn(pluginObj.name, methodName); - reject({ - error: 'cordova_not_available' - }); - return; - } - if (opts.callbackOrder == 'reverse') { - args[0] = resolve; - args[1] = reject; - } - else if (typeof opts.successIndex !== 'undefined' || typeof opts.errorIndex !== 'undefined') { - args.splice(opts.successIndex, resolve); - args.splice(opts.errorIndex, reject); - } - else { - args.push(resolve); - args.push(reject); - } - var pluginInstance = exports.getPlugin(pluginObj.pluginRef); - if (!pluginInstance) { - exports.pluginWarn(pluginObj.name, methodName, pluginObj.name); - reject({ - error: 'plugin_not_installed' - }); - return; - } - console.log('Cordova calling', pluginObj.name, methodName, args); - util_1.get(window, pluginObj.pluginRef)[methodName].apply(pluginObj, args); - }); - }; -}; -function Plugin(config) { - return function (cls) { - for (var k in config) { - cls[k] = config[k]; - } - return cls; - }; -} -exports.Plugin = Plugin; -function Cordova(opts) { - if (opts === void 0) { opts = {}; } - return function (target, methodName, descriptor) { - var originalMethod = descriptor.value; - return { - value: function () { - var args = []; - for (var _i = 0; _i < arguments.length; _i++) { - args[_i - 0] = arguments[_i]; - } - return exports.wrap(this, methodName, opts).apply(this, args); - } - }; - }; -} -exports.Cordova = Cordova; -function RequiresPlugin(target, key, descriptor) { - var originalMethod = descriptor.value; - descriptor.value = function () { - var args = []; - for (var _i = 0; _i < arguments.length; _i++) { - args[_i - 0] = arguments[_i]; - } - console.log('Calling', this); - if (!window.cordova) { - exports.cordovaWarn(this.name, null); - return; - } - var pluginInstance = exports.getPlugin(this.pluginRef); - if (!pluginInstance) { - exports.pluginWarn(this.name, null, this.name); - return; - } - originalMethod.apply(this, args); - }; - return descriptor; -} -exports.RequiresPlugin = RequiresPlugin; +var util_1 = require('../util'); +var Rx_1 = require('@reactivex/rxjs/dist/cjs/Rx'); +exports.getPlugin = function (pluginRef) { + return util_1.get(window, pluginRef); +}; +exports.isInstalled = function (pluginRef) { + return !!exports.getPlugin(pluginRef); +}; +exports.pluginWarn = function (pluginName, method, plugin) { + if (method) { + console.warn('Native: tried calling ' + pluginName + '.' + method + + ', but the ' + pluginName + ' plugin is not installed. Install the ' + + plugin + ' plugin'); + } + else { + console.warn('Native: tried accessing the ' + pluginName + ' plugin but it\'s not installed. Install the ' + plugin + ' plugin'); + } +}; +exports.cordovaWarn = function (pluginName, method) { + if (method) { + console.warn('Native: tried calling ' + pluginName + '.' + method + ', but Cordova is not available. Make sure to include cordova.js or run in a device/simulator'); + } + else { + console.warn('Native: tried accessing the ' + pluginName + ' plugin but Cordova is not available. Make sure to include cordova.js or run in a device/simulator'); + } +}; +function callCordovaPlugin(pluginObj, methodName, args, opts, resolve, reject) { + if (opts === void 0) { opts = {}; } + if (!window.cordova) { + exports.cordovaWarn(pluginObj.name, methodName); + reject({ + error: 'cordova_not_available' + }); + return; + } + // Try to figure out where the success/error callbacks need to be bound + // to our promise resolve/reject handlers. + // If the plugin method expects myMethod(success, err, options) + if (opts.callbackOrder == 'reverse') { + args[0] = resolve; + args[1] = reject; + } + else if (typeof opts.successIndex !== 'undefined' || typeof opts.errorIndex !== 'undefined') { + // If we've specified a success/error index + args.splice(opts.successIndex, 0, resolve); + args.splice(opts.errorIndex, 0, reject); + } + else { + // Otherwise, let's tack them on to the end of the argument list + // which is 90% of cases + args.push(resolve); + args.push(reject); + } + var pluginInstance = exports.getPlugin(pluginObj.pluginRef); + if (!pluginInstance) { + exports.pluginWarn(pluginObj.name, methodName, pluginObj.name); + reject({ + error: 'plugin_not_installed' + }); + return; + } + console.log('Cordova calling', pluginObj.name, methodName, args); + return util_1.get(window, pluginObj.pluginRef)[methodName].apply(pluginObj, args); +} +function wrapPromise(pluginObj, methodName, args, opts) { + if (opts === void 0) { opts = {}; } + return new Promise(function (resolve, reject) { + callCordovaPlugin(pluginObj, methodName, args, opts, resolve, reject); + }); +} +function wrapObservable(pluginObj, methodName, args, opts) { + if (opts === void 0) { opts = {}; } + return Rx_1.Observable.create(function (observer) { + var pluginResult = callCordovaPlugin(pluginObj, methodName, args, opts, observer.onNext, observer.onError); + return function () { + return util_1.get(window, pluginObj.pluginRef)[opts.clearFunction].apply(pluginObj, pluginResult); + }; + }); +} +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]; + } + if (opts.observable) { + console.log("Wrapping observable"); + return wrapObservable(pluginObj, methodName, args, opts); + } + else { + return wrapPromise(pluginObj, methodName, args, opts); + } + }; +}; +/** + * Class decorator specifying Plugin metadata. Required for all plugins. + */ +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; +/** + * Wrap a stub function in a call to a Cordova plugin, checking if both Cordova + * and the required plugin are installed. + */ +function Cordova(opts) { + if (opts === void 0) { opts = {}; } + return function (target, methodName, descriptor) { + var originalMethod = descriptor.value; + return { + value: function () { + var args = []; + for (var _i = 0; _i < arguments.length; _i++) { + args[_i - 0] = arguments[_i]; + } + return exports.wrap(this, methodName, opts).apply(this, args); + } + }; + }; +} +exports.Cordova = Cordova; +/** + * Before calling the original method, ensure Cordova and the plugin are installed. + */ +function RequiresPlugin(target, key, descriptor) { + var originalMethod = descriptor.value; + descriptor.value = function () { + var args = []; + for (var _i = 0; _i < arguments.length; _i++) { + args[_i - 0] = arguments[_i]; + } + console.log('Calling', this); + if (!window.cordova) { + exports.cordovaWarn(this.name, null); + return; + } + var pluginInstance = exports.getPlugin(this.pluginRef); + if (!pluginInstance) { + exports.pluginWarn(this.name, null, this.name); + return; + } + originalMethod.apply(this, args); + }; + return descriptor; +} +exports.RequiresPlugin = RequiresPlugin; +//# sourceMappingURL=plugin.js.map \ No newline at end of file diff --git a/src/plugins/plugin.js.map b/src/plugins/plugin.js.map new file mode 100644 index 00000000..2be95fe7 --- /dev/null +++ b/src/plugins/plugin.js.map @@ -0,0 +1 @@ +{"version":3,"file":"plugin.js","sourceRoot":"","sources":["plugin.ts"],"names":["callCordovaPlugin","wrapPromise","wrapObservable","Plugin","Cordova","RequiresPlugin"],"mappings":"AAAA,qBAAkB,SAAS,CAAC,CAAA;AAK5B,mBAAyB,6BAA6B,CAAC,CAAA;AAG1C,iBAAS,GAAG,UAAS,SAAiB;IACjD,MAAM,CAAC,UAAG,CAAC,MAAM,EAAE,SAAS,CAAC,CAAC;AAChC,CAAC,CAAA;AACY,mBAAW,GAAG,UAAS,SAAiB;IACnD,MAAM,CAAC,CAAC,CAAC,iBAAS,CAAC,SAAS,CAAC,CAAC;AAChC,CAAC,CAAA;AACY,kBAAU,GAAG,UAAS,UAAkB,EAAE,MAAc,EAAE,M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AC,CAAC,MAAM,CAAC,OAAO,CAAC,CAAC,CAAC;YACnB,mBAAW,CAAC,IAAI,CAAC,IAAI,EAAE,IAAI,CAAC,CAAC;YAC7B,MAAM,CAAC;QACT,CAAC;QAED,IAAI,cAAc,GAAG,iBAAS,CAAC,IAAI,CAAC,SAAS,CAAC,CAAC;QAC/C,EAAE,CAAA,CAAC,CAAC,cAAc,CAAC,CAAC,CAAC;YACnB,kBAAU,CAAC,IAAI,CAAC,IAAI,EAAE,IAAI,EAAE,IAAI,CAAC,IAAI,CAAC,CAAC;YACvC,MAAM,CAAC;QACT,CAAC;QACD,cAAc,CAAC,KAAK,CAAC,IAAI,EAAE,IAAI,CAAC,CAAC;IACnC,CAAC,CAAAA;IAEDA,MAAMA,CAACA,UAAUA,CAACA;AACpBA,CAACA;AAnBe,sBAAc,iBAmB7B,CAAA"} \ No newline at end of file diff --git a/src/plugins/plugin.ts b/src/plugins/plugin.ts index aa16d2ce..ec8de10e 100644 --- a/src/plugins/plugin.ts +++ b/src/plugins/plugin.ts @@ -3,6 +3,8 @@ import {get} from '../util'; declare var window; declare var Promise; +import {Observable} from '@reactivex/rxjs/dist/cjs/Rx'; + export const getPlugin = function(pluginRef: string): any { return get(window, pluginRef); @@ -27,52 +29,73 @@ export const cordovaWarn = function(pluginName: string, method: string) { } } -export const wrap = function(pluginObj, methodName, opts: any = {}) { - console.log('Wrap', pluginObj.name, methodName); - return (...args) => { - console.log('Wrap CALLED', pluginObj.name, methodName, args); - return new Promise((resolve, reject) => { - - if(!window.cordova) { - cordovaWarn(pluginObj.name, methodName); - reject({ - error: 'cordova_not_available' - }) - return; - } - - // Try to figure out where the success/error callbacks need to be bound - // to our promise resolve/reject handlers. - - // If the plugin method expects myMethod(success, err, options) - if(opts.callbackOrder == 'reverse') { - args[0] = resolve; - args[1] = reject; - } else if(typeof opts.successIndex !== 'undefined' || typeof opts.errorIndex !== 'undefined') { - // If we've specified a success/error index - args.splice(opts.successIndex, resolve); - args.splice(opts.errorIndex, reject); - } else { - // Otherwise, let's tack them on to the end of the argument list - // which is 90% of cases - args.push(resolve); - args.push(reject); - } - - let pluginInstance = getPlugin(pluginObj.pluginRef); - - if(!pluginInstance) { - pluginWarn(pluginObj.name, methodName, pluginObj.name); - reject({ - error: 'plugin_not_installed' - }); - return; - } - - console.log('Cordova calling', pluginObj.name, methodName, args); - - get(window, pluginObj.pluginRef)[methodName].apply(pluginObj, args); +function callCordovaPlugin(pluginObj:any, methodName:string, args:any[], opts:any={}, resolve:any, reject:any) { + if(!window.cordova) { + cordovaWarn(pluginObj.name, methodName); + reject({ + error: 'cordova_not_available' }) + return; + } + + // Try to figure out where the success/error callbacks need to be bound + // to our promise resolve/reject handlers. + + // If the plugin method expects myMethod(success, err, options) + if(opts.callbackOrder == 'reverse') { + args[0] = resolve; + args[1] = reject; + } else if(typeof opts.successIndex !== 'undefined' || typeof opts.errorIndex !== 'undefined') { + // If we've specified a success/error index + args.splice(opts.successIndex, 0, resolve); + args.splice(opts.errorIndex, 0, reject); + } else { + // Otherwise, let's tack them on to the end of the argument list + // which is 90% of cases + args.push(resolve); + args.push(reject); + } + + let pluginInstance = getPlugin(pluginObj.pluginRef); + + if(!pluginInstance) { + pluginWarn(pluginObj.name, methodName, pluginObj.name); + reject({ + error: 'plugin_not_installed' + }); + return; + } + + console.log('Cordova calling', pluginObj.name, methodName, args); + + return get(window, pluginObj.pluginRef)[methodName].apply(pluginObj, args); +} + +function wrapPromise(pluginObj:any, methodName:string, args:any[], opts:any={}) { + return new Promise((resolve, reject) => { + callCordovaPlugin(pluginObj, methodName, args, opts, resolve, reject); + }) +} + +function wrapObservable(pluginObj:any, methodName:string, args:any[], opts:any = {}) { + return Observable.create((observer) => { + let pluginResult = callCordovaPlugin(pluginObj, methodName, args, opts, observer.onNext, observer.onError); + + return () => { + return get(window, pluginObj.pluginRef)[opts.clearFunction].apply(pluginObj, pluginResult); + } + }); +} + +export const wrap = function(pluginObj:any, methodName:string, opts:any = {}) { + return (...args) => { + + if(opts.observable) { + console.log("Wrapping observable"); + return wrapObservable(pluginObj, methodName, args, opts); + } else { + return wrapPromise(pluginObj, methodName, args, opts); + } } } diff --git a/src/plugins/statusbar.js b/src/plugins/statusbar.js new file mode 100644 index 00000000..dcf7cac1 --- /dev/null +++ b/src/plugins/statusbar.js @@ -0,0 +1,77 @@ +var __decorate = (this && this.__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() { + } + StatusBar.overlaysWebView = function (doOverlay) { }; + ; + StatusBar.styleDefault = function () { }; + ; + StatusBar.styleLightContent = function () { }; + ; + StatusBar.styleBlackTranslucent = function () { }; + ; + StatusBar.styleBlackOpaque = function () { }; + ; + StatusBar.backgroundColorByName = function (colorName) { }; + ; + StatusBar.backgroundColorByHexString = function (hexString) { }; + ; + StatusBar.hide = function () { }; + ; + StatusBar.show = function () { }; + ; + Object.defineProperty(StatusBar, "overlaysWebView", + __decorate([ + plugin_1.Cordova() + ], StatusBar, "overlaysWebView", Object.getOwnPropertyDescriptor(StatusBar, "overlaysWebView"))); + Object.defineProperty(StatusBar, "styleDefault", + __decorate([ + plugin_1.Cordova() + ], StatusBar, "styleDefault", Object.getOwnPropertyDescriptor(StatusBar, "styleDefault"))); + Object.defineProperty(StatusBar, "styleLightContent", + __decorate([ + plugin_1.Cordova() + ], StatusBar, "styleLightContent", Object.getOwnPropertyDescriptor(StatusBar, "styleLightContent"))); + Object.defineProperty(StatusBar, "styleBlackTranslucent", + __decorate([ + plugin_1.Cordova() + ], StatusBar, "styleBlackTranslucent", Object.getOwnPropertyDescriptor(StatusBar, "styleBlackTranslucent"))); + Object.defineProperty(StatusBar, "styleBlackOpaque", + __decorate([ + plugin_1.Cordova() + ], StatusBar, "styleBlackOpaque", Object.getOwnPropertyDescriptor(StatusBar, "styleBlackOpaque"))); + Object.defineProperty(StatusBar, "backgroundColorByName", + __decorate([ + plugin_1.Cordova() + ], StatusBar, "backgroundColorByName", Object.getOwnPropertyDescriptor(StatusBar, "backgroundColorByName"))); + Object.defineProperty(StatusBar, "backgroundColorByHexString", + __decorate([ + plugin_1.Cordova() + ], StatusBar, "backgroundColorByHexString", Object.getOwnPropertyDescriptor(StatusBar, "backgroundColorByHexString"))); + Object.defineProperty(StatusBar, "hide", + __decorate([ + plugin_1.Cordova() + ], StatusBar, "hide", Object.getOwnPropertyDescriptor(StatusBar, "hide"))); + Object.defineProperty(StatusBar, "show", + __decorate([ + plugin_1.Cordova() + ], StatusBar, "show", Object.getOwnPropertyDescriptor(StatusBar, "show"))); + StatusBar = __decorate([ + plugin_1.Plugin({ + name: 'StatusBar', + plugin: 'cordova-plugin-statusbar', + pluginRef: 'StatusBar' + }) + ], StatusBar); + return StatusBar; +})(); +exports.StatusBar = StatusBar; +//# sourceMappingURL=statusbar.js.map \ No newline at end of file diff --git a/src/plugins/statusbar.js.map b/src/plugins/statusbar.js.map new file mode 100644 index 00000000..4a4cd032 --- /dev/null +++ b/src/plugins/statusbar.js.map @@ -0,0 +1 @@ +{"version":3,"file":"statusbar.js","sourceRoot":"","sources":["statusbar.ts"],"names":["StatusBar","StatusBar.constructor","StatusBar.overlaysWebView","StatusBar.styleDefault","StatusBar.styleLightContent","StatusBar.styleBlackTranslucent","StatusBar.styleBlackOpaque","StatusBar.backgroundColorByName","StatusBar.backgroundColorByHexString","StatusBar.hide","StatusBar.show"],"mappings":";;;;;;;;AAAA,uBAA8B,UAAU,CAAC,CAAA;AAEzC;IAAAA;IAwBAC,CAACA;IAjBQD,yBAAeA,GADtBA,UACuBA,SAAiBA,IAAEE,CAACA;;IAEpCF,sBAAYA,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,WAAWA;SACvBA,CAACA;kBAoBDA;IAADA,gBAACA;AAADA,CAACA,AAxBD,IAwBC;AAnBY,iBAAS,YAmBrB,CAAA"} \ No newline at end of file diff --git a/src/plugins/toast.js b/src/plugins/toast.js new file mode 100644 index 00000000..ec55d3a7 --- /dev/null +++ b/src/plugins/toast.js @@ -0,0 +1,36 @@ +var __decorate = (this && this.__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() { + } + Toast.hide = function () { }; + ; + Toast.showWithOptions = function (options) { }; + ; + Object.defineProperty(Toast, "hide", + __decorate([ + plugin_1.Cordova() + ], Toast, "hide", Object.getOwnPropertyDescriptor(Toast, "hide"))); + Object.defineProperty(Toast, "showWithOptions", + __decorate([ + plugin_1.Cordova() + ], Toast, "showWithOptions", Object.getOwnPropertyDescriptor(Toast, "showWithOptions"))); + Toast = __decorate([ + plugin_1.Plugin({ + name: 'Toast', + plugin: 'cordova-plugin-x-toast', + pluginRef: 'plugins.toast', + repo: 'https://github.com/EddyVerbruggen/Toast-PhoneGap-Plugin' + }) + ], Toast); + return Toast; +})(); +exports.Toast = Toast; +//# sourceMappingURL=toast.js.map \ No newline at end of file diff --git a/src/plugins/toast.js.map b/src/plugins/toast.js.map new file mode 100644 index 00000000..118137ac --- /dev/null +++ b/src/plugins/toast.js.map @@ -0,0 +1 @@ +{"version":3,"file":"toast.js","sourceRoot":"","sources":["toast.ts"],"names":["Toast","Toast.constructor","Toast.hide","Toast.showWithOptions"],"mappings":";;;;;;;;AAAA,uBAA8B,UAAU,CAAC,CAAA;AAEzC;IAAAA;IAYAC,CAACA;IAJQD,UAAIA,GADXA,cACcE,CAACA;;IAGRF,qBAAeA,GADtBA,UACuBA,OAAWA,IAAEG,CAACA;;IAJrCH,sBACOA,aAAIA;;YADVA,gBAAOA,EAAEA;WACHA,aAAIA,kCAAJA,aAAIA,IAAIA;IAEfA,sBACOA,wBAAeA;;YADrBA,gBAAOA,EAAEA;WACHA,wBAAeA,kCAAfA,wBAAeA,IAAeA;IAXvCA;QAACA,eAAMA,CAACA;YACNA,IAAIA,EAAEA,OAAOA;YACbA,MAAMA,EAAEA,wBAAwBA;YAChCA,SAASA,EAAEA,eAAeA;YAC1BA,IAAIA,EAAEA,yDAAyDA;SAChEA,CAACA;cAODA;IAADA,YAACA;AAADA,CAACA,AAZD,IAYC;AANY,aAAK,QAMjB,CAAA"} \ No newline at end of file diff --git a/dist/src/util.js b/src/util.js similarity index 87% rename from dist/src/util.js rename to src/util.js index 92409556..19dd6ac9 100644 --- a/dist/src/util.js +++ b/src/util.js @@ -1,11 +1,12 @@ -function get(obj, path) { - for (var i = 0, path = path.split('.'), len = path.length; i < len; i++) { - if (!obj) { - return null; - } - obj = obj[path[i]]; - } - return obj; -} -exports.get = get; -; +function get(obj, path) { + for (var i = 0, path = path.split('.'), len = path.length; i < len; i++) { + if (!obj) { + return null; + } + obj = obj[path[i]]; + } + return obj; +} +exports.get = get; +; +//# sourceMappingURL=util.js.map \ No newline at end of file diff --git a/src/util.js.map b/src/util.js.map new file mode 100644 index 00000000..28c70d6e --- /dev/null +++ b/src/util.js.map @@ -0,0 +1 @@ +{"version":3,"file":"util.js","sourceRoot":"","sources":["util.ts"],"names":["get"],"mappings":"AAAA,aAAoB,GAAG,EAAE,IAAI;IAC3BA,GAAGA,CAAAA,CAACA,GAAGA,CAACA,CAACA,GAAGA,CAACA,EAAEA,IAAIA,GAAGA,IAAIA,CAACA,KAAKA,CAACA,GAAGA,CAACA,EAAEA,GAAGA,GAAGA,IAAIA,CAACA,MAAMA,EAAEA,CAACA,GAAGA,GAAGA,EAAEA,CAACA,EAAEA,EAAEA,CAACA;QACvEA,EAAEA,CAAAA,CAACA,CAACA,GAAGA,CAACA,CAACA,CAACA;YAACA,MAAMA,CAACA,IAAIA,CAACA;QAACA,CAACA;QACzBA,GAAGA,GAAGA,GAAGA,CAACA,IAAIA,CAACA,CAACA,CAACA,CAACA,CAACA;IACrBA,CAACA;IACDA,MAAMA,CAACA,GAAGA,CAACA;AACbA,CAACA;AANe,WAAG,MAMlB,CAAA;AAAA,CAAC"} \ No newline at end of file diff --git a/tsconfig.json b/tsconfig.json index 7dc9584f..2799cf98 100644 --- a/tsconfig.json +++ b/tsconfig.json @@ -5,15 +5,26 @@ "noImplicitAny": false, "outDir": "dist", "rootDir": ".", - "sourceMap": false, + "sourceMap": true, "declaration": true }, "exclude": [ "node_modules" ], + "filesGlob": [ + "src/**/*.ts" + ], "files": [ "src/index.ts", - "src/plugin-config.ts", + "src/plugins/actionsheet.ts", + "src/plugins/ble.ts", + "src/plugins/camera.ts", + "src/plugins/contacts.ts", + "src/plugins/device.ts", + "src/plugins/file.ts", + "src/plugins/geolocation.ts", + "src/plugins/plugin.ts", + "src/plugins/statusbar.ts", "src/plugins/toast.ts", "src/util.ts" ],