This commit is contained in:
Ibrahim Hadeed 2016-04-29 20:07:59 -04:00
commit 0b15a2f037
9 changed files with 525 additions and 14 deletions

View File

@ -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

View File

@ -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'));
});

View File

@ -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",

View File

@ -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,

177
src/plugins/admob.ts Normal file
View File

@ -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<any> {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<any> {return}
/**
* Show interstitial
*/
@Cordova({
sync: true
})
static showInterstitial() : void {}
/**
*
*/
@Cordova()
static isInterstitialReady () : Promise<boolean> {return}
/**
* Prepare a reward video ad
* @param adIdOrOptions
*/
@Cordova()
static prepareRewardVideoAd(adIdOrOptions : any) : Promise<any> {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<any> {return}
/**
* Get user ad settings
* @returns {Promise<any>} Returns a promise that resolves with the ad settings
*/
@Cordova()
static getAdSettings() : Promise<any> {return}
// Events
@Cordova({
eventObservable: true,
event: 'onBannerFailedToReceive'
})
static onBannerFailedToReceive () : Observable<any> {return}
@Cordova({
eventObservable: true,
event: 'onBannerReceive'
})
static onBannerReceive () : Observable<any> {return}
@Cordova({
eventObservable: true,
event: 'onBannerPresent'
})
static onBannerPresent () : Observable<any> {return}
@Cordova({
eventObservable: true,
event: 'onBannerLeaveApp'
})
static onBannerLeaveApp () : Observable<any> {return}
@Cordova({
eventObservable: true,
event: 'onBannerDismiss'
})
static onBannerDismiss () : Observable<any> {return}
@Cordova({
eventObservable: true,
event: 'onInterstitialFailedToReceive'
})
static onInterstitialFailedToReceive () : Observable<any> {return}
@Cordova({
eventObservable: true,
event: 'onInterstitialReceive'
})
static onInterstitialReceive () : Observable<any> {return}
@Cordova({
eventObservable: true,
event: 'onInterstitialPresent'
})
static onInterstitialPresent () : Observable<any> {return}
@Cordova({
eventObservable: true,
event: 'onInterstitialLeaveApp'
})
static onInterstitialLeaveApp () : Observable<any> {return}
@Cordova({
eventObservable: true,
event: 'onInterstitialDismiss'
})
static onInterstitialDismiss () : Observable<any> {return}
}

View File

@ -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<any> {return}
/**
* Connect insecurely to a Bluetooth device
* @param macAddress Identifier of the remote device
*/
@Cordova({
platforms: ['Android']
})
static connectInsecure (macAddress : string) : Promise<any> {return}
/**
* Disconnect
*/
@Cordova({
platforms: ['Android','iOS','Windows Phone']
})
static disconnect () : Promise<any> {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<any> {return}
/**
* Gets the number of bytes of data available
*/
@Cordova({
platforms: ['Android', 'iOS','Windows Phone']
}) static available () : Promise<any> {return}
/**
* Reads data from the buffer
*/
@Cordova({
platforms: ['Android', 'iOS','Windows Phone']
})
static read () : Promise<any> {return}
/**
* Reads data from the buffer until it reaches a delimiter
* @param delimiter
*/
@Cordova({
platforms: ['Android', 'iOS','Windows Phone']
})
static readUntil (delimiter : string) : Promise<any> {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<any> {return}
/**
* Subscribe to be notified when data is received
*/
@Cordova({
platforms: ['Android', 'iOS','Windows Phone'],
observable: true,
clearFunction: 'unsubscribeRawData'
})
static subscribeRawData () : Observable<any> {return}
/**
* Clears data in buffer
*/
@Cordova({
platforms: ['Android', 'iOS','Windows Phone']
})
static clear () : Promise<any> {return}
/**
* Lists bonded devices
*/
@Cordova({
platforms: ['Android', 'iOS','Windows Phone']
})
static list () : Promise<any> {return}
/**
* Reports if bluetooth is enabled
*/
@Cordova({
platforms: ['Android', 'iOS','Windows Phone']
})
static isEnabled () : Promise<any> {return}
/**
* Reports the connection status
*/
@Cordova({
platforms: ['Android', 'iOS','Windows Phone']
})
static isConnected () : Promise<any> {return}
/**
* Reads the RSSI from the connected peripheral
*/
@Cordova({
platforms: ['Android', 'iOS','Windows Phone']
})
static readRSSI () : Promise<any> {return}
/**
* Show the Bluetooth settings on the device
*/
@Cordova({
platforms: ['Android', 'iOS','Windows Phone']
})
static showBluetoothSettings () : Promise<any> {return}
/**
* Enable Bluetooth on the device
*/
@Cordova({
platforms: ['Android', 'iOS','Windows Phone']
})
static enable () : Promise<any> {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<any> {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<any> {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 {}
}

View File

@ -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<any> {return}
/**
* Get all accounts registered on Android device for requested type
*/
@Cordova()
static getByType(type: string) : Promise<any> {return}
/**
* Get all emails registered on Android device (accounts with 'com.google' type)
*/
@Cordova()
static getEmails() : Promise<any> {return}
/**
* Get the first email registered on Android device
*/
@Cordova()
static getEmail() : Promise<any> {return}
}

View File

@ -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 {

36
src/plugins/screenshot.ts Normal file
View File

@ -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<any> {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<any> {return}
}