diff --git a/demo/ionic.project b/demo/ionic.project new file mode 100644 index 000000000..2b6ef930c --- /dev/null +++ b/demo/ionic.project @@ -0,0 +1,4 @@ +{ + "name": "demo", + "app_id": "" +} \ No newline at end of file diff --git a/demo/www/app/home/home.html b/demo/www/app/home/home.html index ac43d100c..3bb18bc31 100644 --- a/demo/www/app/home/home.html +++ b/demo/www/app/home/home.html @@ -6,8 +6,8 @@ - + diff --git a/demo/www/app/home/home.js b/demo/www/app/home/home.js index e53e5b1ae..363edb787 100644 --- a/demo/www/app/home/home.js +++ b/demo/www/app/home/home.js @@ -2,7 +2,9 @@ import {Page, NavController} from 'ionic/ionic' import { ActionSheet, + BLE, Camera, + Contacts, Device, StatusBar, Toast @@ -19,7 +21,9 @@ export class HomePage { this.plugins = [ ActionSheet, + BLE, Camera, + Contacts, Device, StatusBar, Toast diff --git a/dist/index.d.ts b/dist/index.d.ts index 087d76f2a..ad2aa9c34 100644 --- a/dist/index.d.ts +++ b/dist/index.d.ts @@ -1,5 +1,7 @@ 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/index.js b/dist/index.js index 955757b45..a8576d2cc 100644 --- a/dist/index.js +++ b/dist/index.js @@ -3,7 +3,9 @@ function __export(m) { } 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')); diff --git a/dist/plugins/ble.d.ts b/dist/plugins/ble.d.ts index 9a0884050..8357b9b1e 100644 --- a/dist/plugins/ble.d.ts +++ b/dist/plugins/ble.d.ts @@ -1,7 +1,10 @@ export declare class BLE { static scan(services: any[], seconds: number): void; - static startScan: any; - static stopScan: any; - static connect: any; - static disconnect: any; + 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/plugins/ble.js b/dist/plugins/ble.js index 3d6b411ee..8aa42a4bb 100644 --- a/dist/plugins/ble.js +++ b/dist/plugins/ble.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); @@ -11,37 +11,52 @@ 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({ - successIndex: 2, - errIndex: 3 - }) + plugin_1.Cordova() ], BLE, "scan", Object.getOwnPropertyDescriptor(BLE, "scan"))); - __decorate([ - plugin_1.Cordova({ - successIndex: 1, - errIndex: 2 - }) - ], BLE, "startScan"); - __decorate([ - plugin_1.Cordova({ - successIndex: 0, - errIndex: 1 - }) - ], BLE, "stopScan"); - __decorate([ - plugin_1.Cordova({ - successIndex: 1, - errIndex: 2 - }) - ], BLE, "connect"); - __decorate([ - plugin_1.Cordova({ - successIndex: 1, - errIndex: 2 - }) - ], BLE, "disconnect"); + 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', diff --git a/dist/plugins/contacts.d.ts b/dist/plugins/contacts.d.ts new file mode 100644 index 000000000..9ae332ce1 --- /dev/null +++ b/dist/plugins/contacts.d.ts @@ -0,0 +1,5 @@ +export declare class Contacts { + static create(fields: string[], options: any): void; + static find(fields: string[], options: any): void; + static pickContact(): void; +} diff --git a/dist/plugins/contacts.js b/dist/plugins/contacts.js new file mode 100644 index 000000000..0687cc934 --- /dev/null +++ b/dist/plugins/contacts.js @@ -0,0 +1,47 @@ +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; diff --git a/dist/plugins/plugin.js b/dist/plugins/plugin.js index 706a07ba3..a982cf46e 100644 --- a/dist/plugins/plugin.js +++ b/dist/plugins/plugin.js @@ -49,8 +49,8 @@ exports.wrap = function (pluginObj, methodName, opts) { } else if (typeof opts.successIndex !== 'undefined' || typeof opts.errorIndex !== 'undefined') { // If we've specified a success/error index - args[opts.successIndex] = resolve; - args[opts.errorIndex] = reject; + args.splice(opts.successIndex, resolve); + args.splice(opts.errorIndex, reject); } else { // Otherwise, let's tack them on to the end of the argument list diff --git a/dist/src/index.d.ts b/dist/src/index.d.ts index 68333def4..a7d77f922 100644 --- a/dist/src/index.d.ts +++ b/dist/src/index.d.ts @@ -1,5 +1,7 @@ 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/index.js b/dist/src/index.js index 0244dd084..5e6a7537c 100644 --- a/dist/src/index.js +++ b/dist/src/index.js @@ -3,7 +3,9 @@ function __export(m) { } 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')); diff --git a/dist/src/plugins/plugin.js b/dist/src/plugins/plugin.js index 6a7fab129..92663d1c7 100644 --- a/dist/src/plugins/plugin.js +++ b/dist/src/plugins/plugin.js @@ -45,8 +45,8 @@ exports.wrap = function (pluginObj, methodName, opts) { args[1] = reject; } else if (typeof opts.successIndex !== 'undefined' || typeof opts.errorIndex !== 'undefined') { - args[opts.successIndex] = resolve; - args[opts.errorIndex] = reject; + args.splice(opts.successIndex, resolve); + args.splice(opts.errorIndex, reject); } else { args.push(resolve); diff --git a/package.json b/package.json index b4c26d4ec..fb547cba1 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 --experimentalDecorators" }, "repository": { "type": "git", diff --git a/src/index.ts b/src/index.ts index 38cee2294..5cd4973e9 100644 --- a/src/index.ts +++ b/src/index.ts @@ -1,7 +1,9 @@ const DEVICE_READY_TIMEOUT = 2000; 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/src/plugins/contacts.ts b/src/plugins/contacts.ts new file mode 100644 index 000000000..1393716fe --- /dev/null +++ b/src/plugins/contacts.ts @@ -0,0 +1,25 @@ +import {Plugin, Cordova} from './plugin'; + +@Plugin({ + name: 'Contacts', + plugin: 'cordova-plugin-contacts', + pluginRef: 'navigator.contacts', + repo: 'https://github.com/apache/cordova-plugin-contacts' +}) +export class Contacts { + @Cordova({ + successIndex: 1, + errorIndex: 2 + }) + // This method is create(fields, success, error, options) :/ + static create(fields:string[], options:any){}; + + @Cordova({ + successIndex: 1, + errorIndex: 2 + }) + static find(fields:string[], options:any){}; + + @Cordova() + static pickContact(){}; +} diff --git a/src/plugins/plugin.ts b/src/plugins/plugin.ts index 551764620..aa16d2cea 100644 --- a/src/plugins/plugin.ts +++ b/src/plugins/plugin.ts @@ -50,8 +50,8 @@ export const wrap = function(pluginObj, methodName, opts: any = {}) { args[1] = reject; } else if(typeof opts.successIndex !== 'undefined' || typeof opts.errorIndex !== 'undefined') { // If we've specified a success/error index - args[opts.successIndex] = resolve; - args[opts.errorIndex] = reject; + 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