diff --git a/circle.yml b/circle.yml index 861353cb3..d007caa6a 100644 --- a/circle.yml +++ b/circle.yml @@ -9,19 +9,19 @@ general: only: - master # ignore PRs and branches -dependencies: - pre: - - ./scripts/docs/prepare.sh - cache_directories: - - "~/ionic-site" # cache ionic-site +#dependencies: +# pre: +# - ./scripts/docs/prepare.sh +# cache_directories: +# - "~/ionic-site" # cache ionic-site test: override: - echo "No tests are written at the moment. But we will attempt to build the library with the latest changes." - npm run build_bundle -deployment: - staging: - branch: master - commands: - - ./scripts/docs/update_docs.sh +#deployment: +# staging: +# branch: master +# commands: +# - ./scripts/docs/update_docs.sh diff --git a/gulpfile.js b/gulpfile.js index 55d9f4af3..c81505f58 100644 --- a/gulpfile.js +++ b/gulpfile.js @@ -1,5 +1,7 @@ var gulp = require('gulp'); var minimist = require('minimist'); +var uglify = require('gulp-uglify'); +var rename = require("gulp-rename"); var flagConfig = { string: ['port', 'version', 'ngVersion', 'animations'], @@ -11,3 +13,13 @@ var flags = minimist(process.argv.slice(2), flagConfig); /* Docs tasks */ require('./scripts/docs/gulp-tasks')(gulp, flags); + + +gulp.task("minify:dist", function(){ + gulp.src('./dist/ionic.native.js') + .pipe(uglify()) + .pipe(rename({ + suffix: '.min' + })) + .pipe(gulp.dest('./dist')); +}); diff --git a/package.json b/package.json index 97a8d7004..207322064 100644 --- a/package.json +++ b/package.json @@ -22,6 +22,8 @@ "dgeni-packages": "^0.10.18", "glob": "^6.0.4", "gulp": "~3.9.0", + "gulp-rename": "^1.2.2", + "gulp-uglify": "^1.5.3", "lodash": "3.10.1", "minimist": "^1.1.3", "mkdirp": "^0.5.1", @@ -33,7 +35,7 @@ "scripts": { "test": "echo \"Error: no test specified\" && exit 1", "build": "tsc --module commonjs --sourcemap --outDir dist/ --experimentalDecorators -d typings/es6-shim/es6-shim.d.ts src/index.ts --target ES5", - "build_bundle": "npm run-script build && browserify dist/index.js > dist/ionic.native.js" + "build_bundle": "npm run-script build && browserify dist/index.js > dist/ionic.native.js && gulp minify:dist" }, "repository": { "type": "git", diff --git a/src/index.ts b/src/index.ts index 5ff171b35..04c653e26 100644 --- a/src/index.ts +++ b/src/index.ts @@ -6,6 +6,7 @@ const DEVICE_READY_TIMEOUT = 2000; declare var window; import {ActionSheet} from './plugins/actionsheet'; +import {AdMob} from './plugins/admob'; import {AppAvailability} from './plugins/appavailability'; import {AppRate} from './plugins/apprate'; import {AppVersion} from './plugins/appversion'; @@ -14,6 +15,7 @@ import {BarcodeScanner} from './plugins/barcodescanner'; import {Base64ToGallery} from './plugins/base64togallery'; import {BatteryStatus} from './plugins/batterystatus'; import {BLE} from './plugins/ble'; +import {BluetoothSerial} from './plugins/bluetoothserial'; import {Calendar} from './plugins/calendar'; import {Camera} from './plugins/camera'; import {Clipboard} from './plugins/clipboard'; @@ -21,6 +23,7 @@ import {Contacts} from './plugins/contacts'; import {DatePicker} from './plugins/datepicker'; import {DBMeter} from './plugins/dbmeter'; import {Device} from './plugins/device'; +import {DeviceAccounts} from './plugins/deviceaccounts'; import {DeviceMotion} from './plugins/devicemotion'; import {DeviceOrientation} from './plugins/deviceorientation'; import {Diagnostic} from './plugins/diagnostic'; @@ -42,6 +45,7 @@ import {LocalNotifications} from './plugins/localnotifications'; import {MediaPlugin} from './plugins/media'; import {Network, Connection} from './plugins/network'; import {Push} from './plugins/push'; +import {Screenshot} from './plugins/screenshot'; import {SMS} from './plugins/sms'; import {SocialSharing} from './plugins/socialsharing'; import {SpinnerDialog} from './plugins/spinnerdialog'; @@ -55,6 +59,7 @@ import {WebIntent} from './plugins/webintent'; export { ActionSheet, + AdMob, AppAvailability, AppRate, AppVersion, @@ -63,6 +68,7 @@ export { Base64ToGallery, BatteryStatus, BLE, + BluetoothSerial, Calendar, Camera, Clipboard, @@ -71,6 +77,7 @@ export { DatePicker, DBMeter, Device, + DeviceAccounts, DeviceMotion, DeviceOrientation, Dialogs, @@ -92,6 +99,7 @@ export { MediaPlugin, Network, Push, + Screenshot, SMS, SocialSharing, SpinnerDialog, @@ -109,6 +117,7 @@ export * from './plugins/plugin'; // Window export to use outside of a module loading system window['IonicNative'] = { ActionSheet: ActionSheet, + AdMob: AdMob, AppAvailability: AppAvailability, AppRate: AppRate, AppVersion: AppVersion, @@ -117,6 +126,7 @@ window['IonicNative'] = { Base64ToGallery: Base64ToGallery, BatteryStatus: BatteryStatus, BLE: BLE, + BluetoothSerial: BluetoothSerial, Calendar: Calendar, Camera: Camera, Clipboard: Clipboard, @@ -125,6 +135,7 @@ window['IonicNative'] = { DatePicker: DatePicker, DBMeter: DBMeter, Device: Device, + DeviceAccounts: DeviceAccounts, DeviceMotion: DeviceMotion, DeviceOrientation: DeviceOrientation, Dialogs: Dialogs, @@ -146,6 +157,7 @@ window['IonicNative'] = { MediaPlugin: MediaPlugin, Network: Network, Push: Push, + Screenshot: Screenshot, SMS: SMS, SocialSharing: SocialSharing, SpinnerDialog: SpinnerDialog, diff --git a/src/plugins/admob.ts b/src/plugins/admob.ts new file mode 100644 index 000000000..da7f28042 --- /dev/null +++ b/src/plugins/admob.ts @@ -0,0 +1,177 @@ +import {Plugin, Cordova} from './plugin'; +import {Observable} from "rxjs/Observable"; + +/** + * @name AdMob + * @description + * @usage + */ +@Plugin({ + plugin: 'cordova-plugin-admobpro', + pluginRef: 'AdMob', + repo: 'https://github.com/floatinghotspot/cordova-admob-pro' +}) +export class AdMob { + + // Static Methods + + /** + * + * @param adIdOrOptions + */ + @Cordova() + static createBanner(adIdOrOptions : any) : Promise {return} + + /** + * + */ + @Cordova({ + sync: true + }) + static removeBanner() : void {} + + /** + * + * @param position + */ + @Cordova({ + sync: true + }) + static showBanner(position : any) : void {} + + /** + * + * @param x + * @param y + */ + @Cordova({ + sync: true + }) + static showBannerAtXY(x : number, y : number) : void {} + + /** + * + */ + @Cordova({ + sync: true + }) + static hideBanner() : void {} + + /** + * + * @param adIdOrOptions + */ + @Cordova() + static prepareInterstitial(adIdOrOptions : any) : Promise {return} + + /** + * Show interstitial + */ + @Cordova({ + sync: true + }) + static showInterstitial() : void {} + + /** + * + */ + @Cordova() + static isInterstitialReady () : Promise {return} + + /** + * Prepare a reward video ad + * @param adIdOrOptions + */ + @Cordova() + static prepareRewardVideoAd(adIdOrOptions : any) : Promise {return} + + /** + * Show a reward video ad + */ + @Cordova({ + sync : true + }) + static showRewardVideoAd() : void {} + + /** + * Sets the values for configuration and targeting + * @param options Returns a promise that resolves if the options are set successfully + */ + @Cordova() + static setOptions(options:any) : Promise {return} + + /** + * Get user ad settings + * @returns {Promise} Returns a promise that resolves with the ad settings + */ + @Cordova() + static getAdSettings() : Promise {return} + + // Events + + @Cordova({ + eventObservable: true, + event: 'onBannerFailedToReceive' + }) + static onBannerFailedToReceive () : Observable {return} + + @Cordova({ + eventObservable: true, + event: 'onBannerReceive' + }) + static onBannerReceive () : Observable {return} + + @Cordova({ + eventObservable: true, + event: 'onBannerPresent' + }) + static onBannerPresent () : Observable {return} + + @Cordova({ + eventObservable: true, + event: 'onBannerLeaveApp' + }) + static onBannerLeaveApp () : Observable {return} + + @Cordova({ + eventObservable: true, + event: 'onBannerDismiss' + }) + static onBannerDismiss () : Observable {return} + + + @Cordova({ + eventObservable: true, + event: 'onInterstitialFailedToReceive' + }) + static onInterstitialFailedToReceive () : Observable {return} + + + @Cordova({ + eventObservable: true, + event: 'onInterstitialReceive' + }) + static onInterstitialReceive () : Observable {return} + + + @Cordova({ + eventObservable: true, + event: 'onInterstitialPresent' + }) + static onInterstitialPresent () : Observable {return} + + + @Cordova({ + eventObservable: true, + event: 'onInterstitialLeaveApp' + }) + static onInterstitialLeaveApp () : Observable {return} + + + @Cordova({ + eventObservable: true, + event: 'onInterstitialDismiss' + }) + static onInterstitialDismiss () : Observable {return} + +} \ No newline at end of file diff --git a/src/plugins/bluetoothserial.ts b/src/plugins/bluetoothserial.ts new file mode 100644 index 000000000..ad0f20143 --- /dev/null +++ b/src/plugins/bluetoothserial.ts @@ -0,0 +1,226 @@ +import {Plugin, Cordova} from './plugin'; +import {Observable} from "rxjs/Observable"; + +/** + * @name Bluetooth Serial + * @description This plugin enables serial communication over Bluetooth. It was written for communicating between Android or iOS and an Arduino. + * @usage + */ +@Plugin({ + repo: 'https://github.com/don/BluetoothSerial', + plugin: 'cordova-plugin-bluetooth-serial', + pluginRef: 'bluetoothSerial', + platforms: ['Android','iOS','Windows Phone','Browser'] +}) +export class BluetoothSerial { + + /** + * Connect to a Bluetooth device + * @param macAddress_or_uuid Identifier of the remote device + */ + @Cordova({ + platforms: ['Android','iOS','Windows Phone'] + }) + static connect (macAddress_or_uuid : string) : Promise {return} + + /** + * Connect insecurely to a Bluetooth device + * @param macAddress Identifier of the remote device + */ + @Cordova({ + platforms: ['Android'] + }) + static connectInsecure (macAddress : string) : Promise {return} + + /** + * Disconnect + */ + @Cordova({ + platforms: ['Android','iOS','Windows Phone'] + }) + static disconnect () : Promise {return} + + /** + * Writes data to the serial port + * @param data ArrayBuffer of data + * @usage + * ```ts + * // Write a string + * Bluetooth.write("hello world").then(success, failure); + * + * // Array of int or bytes + * Bluetooth.write([186, 220, 222]).then(success, failure); + * + * // Typed Array + * var data = new Uint8Array(4); + * data[0] = 0x41; + * data[1] = 0x42; + * data[2] = 0x43; + * data[3] = 0x44; + * Bluetooth.write(data).then(success, failure); + * + * // Array Buffer + * Bluetooth.write(data.buffer).then(success, failure); + * ``` + */ + @Cordova({ + platforms: ['Android', 'iOS','Windows Phone'] + }) + static write (data : any) : Promise {return} + + /** + * Gets the number of bytes of data available + */ + @Cordova({ + platforms: ['Android', 'iOS','Windows Phone'] + }) static available () : Promise {return} + + /** + * Reads data from the buffer + */ + @Cordova({ + platforms: ['Android', 'iOS','Windows Phone'] + }) + static read () : Promise {return} + + /** + * Reads data from the buffer until it reaches a delimiter + * @param delimiter + */ + @Cordova({ + platforms: ['Android', 'iOS','Windows Phone'] + }) + static readUntil (delimiter : string) : Promise {return} + + /** + * Subscribe to be notified when data is received + * @param delimiter + */ + @Cordova({ + platforms: ['Android', 'iOS','Windows Phone'], + observable: true, + clearFunction: 'unsubscribe' + }) + static subscribe (delimiter : string) : Observable {return} + + /** + * Subscribe to be notified when data is received + */ + @Cordova({ + platforms: ['Android', 'iOS','Windows Phone'], + observable: true, + clearFunction: 'unsubscribeRawData' + }) + static subscribeRawData () : Observable {return} + + /** + * Clears data in buffer + */ + @Cordova({ + platforms: ['Android', 'iOS','Windows Phone'] + }) + static clear () : Promise {return} + + /** + * Lists bonded devices + */ + @Cordova({ + platforms: ['Android', 'iOS','Windows Phone'] + }) + static list () : Promise {return} + + /** + * Reports if bluetooth is enabled + */ + @Cordova({ + platforms: ['Android', 'iOS','Windows Phone'] + }) + static isEnabled () : Promise {return} + + /** + * Reports the connection status + */ + @Cordova({ + platforms: ['Android', 'iOS','Windows Phone'] + }) + static isConnected () : Promise {return} + + /** + * Reads the RSSI from the connected peripheral + */ + @Cordova({ + platforms: ['Android', 'iOS','Windows Phone'] + }) + static readRSSI () : Promise {return} + + /** + * Show the Bluetooth settings on the device + */ + @Cordova({ + platforms: ['Android', 'iOS','Windows Phone'] + }) + static showBluetoothSettings () : Promise {return} + + /** + * Enable Bluetooth on the device + */ + @Cordova({ + platforms: ['Android', 'iOS','Windows Phone'] + }) + static enable () : Promise {return} + + /** + * Discover unpaired devices + * @usage + * ```ts + * [{ + * "class": 276, + * "id": "10:BF:48:CB:00:00", + * "address": "10:BF:48:CB:00:00", + * "name": "Nexus 7" + * }, { + * "class": 7936, + * "id": "00:06:66:4D:00:00", + * "address": "00:06:66:4D:00:00", + * "name": "RN42" + * }] + * ``` + */ + @Cordova({ + platforms: ['Android', 'iOS','Windows Phone'] + }) + static discoverUnpaired () : Promise {return} + + /** + * Subscribe to be notified on Bluetooth device discovery. Discovery process must be initiated with the `discoverUnpaired` function. + */ + @Cordova({ + platforms: ['Android', 'iOS','Windows Phone'], + observable: true, + clearFunction: 'clearDeviceDiscoveredListener' + }) + static setDeviceDiscoveredListener () : Observable {return} + + /** + * Sets the human readable device name that is broadcasted to other devices + * @param newName Desired name of device + */ + @Cordova({ + platforms: ['Android'], + sync: true + }) + static setName (newName : string) : void {} + + /** + * Makes the device discoverable by other devices + * @param discoverableDuration Desired number of seconds device should be discoverable for + */ + @Cordova({ + platforms: ['Android'], + sync: true + }) + static setDiscoverable (discoverableDuration : number) : void {} + + + +} \ No newline at end of file diff --git a/src/plugins/deviceaccounts.ts b/src/plugins/deviceaccounts.ts new file mode 100644 index 000000000..c3bc0c65b --- /dev/null +++ b/src/plugins/deviceaccounts.ts @@ -0,0 +1,33 @@ +import {Cordova, Plugin} from './plugin'; +@Plugin({ + plugin: 'https://github.com/loicknuchel/cordova-device-accounts.git', + pluginRef: 'plugins.DeviceAccounts', + repo: 'https://github.com/loicknuchel/cordova-device-accounts', + platforms: ['Android'] +}) +export class DeviceAccounts { + + /** + * Gets all accounts registered on the Android Device + */ + @Cordova() + static get() : Promise {return} + + /** + * Get all accounts registered on Android device for requested type + */ + @Cordova() + static getByType(type: string) : Promise {return} + + /** + * Get all emails registered on Android device (accounts with 'com.google' type) + */ + @Cordova() + static getEmails() : Promise {return} + + /** + * Get the first email registered on Android device + */ + @Cordova() + static getEmail() : Promise {return} +} \ No newline at end of file diff --git a/src/plugins/plugin.ts b/src/plugins/plugin.ts index fed7554d1..a853cb30c 100644 --- a/src/plugins/plugin.ts +++ b/src/plugins/plugin.ts @@ -126,14 +126,27 @@ function getPromise(cb) { } function wrapPromise(pluginObj:any, methodName:string, args:any[], opts:any={}) { - return getPromise((resolve, reject) => { - callCordovaPlugin(pluginObj, methodName, args, opts, resolve, reject); - }) + let pluginResult, rej; + const p = getPromise((resolve, reject) => { + pluginResult = callCordovaPlugin(pluginObj, methodName, args, opts, resolve, reject); + rej = reject; + }); + // Angular throws an error on unhandled rejection, but in this case we have already printed + // a warning that Cordova is undefined or the plugin is uninstalled, so there is no reason + // to error + if (pluginResult && pluginResult.error) { + p.catch(() => {}); + rej(pluginResult.error); + } + return p; } function wrapObservable(pluginObj:any, methodName:string, args:any[], opts:any = {}) { return new Observable(observer => { let pluginResult = callCordovaPlugin(pluginObj, methodName, args, opts, observer.next.bind(observer), observer.error.bind(observer)); + if (pluginResult && pluginResult.error) { + observer.error(pluginResult.error); + } return () => { try { diff --git a/src/plugins/screenshot.ts b/src/plugins/screenshot.ts new file mode 100644 index 000000000..6c34543d4 --- /dev/null +++ b/src/plugins/screenshot.ts @@ -0,0 +1,36 @@ +import {Cordova, Plugin} from './plugin'; +@Plugin({ + plugin: 'https://github.com/gitawego/cordova-screenshot.git', + pluginRef: 'navigator.screenshot', + repo: 'https://github.com/gitawego/cordova-screenshot.git' +}) +export class Screenshot { + +/** + * Takes screenshot and saves the image + * + * @param {string} format. Format can take the value of either 'jpg' or 'png' + * On ios, only 'jpg' format is supported + * @param {number} quality. Determines the quality of the screenshot. + * Default quality is set to 100. + * @param {string} filename. Name of the file as stored on the storage + */ + @Cordova({ + successIndex: 1, + errorIndex: 0 + }) + static save (format?: string, quality?: number, filename?: string) : Promise {return} + +/** + * Takes screenshot and returns the image as an URI + * + * @param {number} quality. Determines the quality of the screenshot. + * Default quality is set to 100. + */ + + @Cordova({ + successIndex: 1, + errorIndex: 0 + }) + static URI (quality?: number) : Promise {return} +} \ No newline at end of file