awesome-cordova-plugins/src/index.ts

90 lines
2.4 KiB
TypeScript
Raw Normal View History

2015-12-02 03:33:08 +08:00
import {initAngular1} from './ng1';
initAngular1();
2015-11-30 06:30:15 +08:00
const DEVICE_READY_TIMEOUT = 2000;
2015-12-02 03:33:08 +08:00
declare var window;
import {ActionSheet} from './plugins/actionsheet';
2016-03-05 05:42:21 +08:00
import {AppRate} from './plugins/apprate';
import {AppVersion} from './plugins/appversion';
2016-02-02 22:35:45 +08:00
import {BarcodeScanner} from './plugins/barcodescanner';
2016-03-05 05:42:21 +08:00
import {Badge} from './plugins/badge';
2015-12-02 03:33:08 +08:00
import {BLE} from './plugins/ble';
import {Camera} from './plugins/camera';
import {Calendar} from './plugins/calendar';
2016-03-05 00:33:36 +08:00
import {Clipboard} from './plugins/clipboard';
2015-12-02 08:47:24 +08:00
import {Contacts} from './plugins/contacts';
2016-03-05 05:42:21 +08:00
import {DatePicker} from './plugins/datepicker';
2015-12-02 03:33:08 +08:00
import {Device} from './plugins/device';
import {Facebook} from './plugins/facebook';
import {Geolocation} from './plugins/geolocation';
2015-12-02 08:47:24 +08:00
import {Push} from './plugins/push';
2015-12-02 03:33:08 +08:00
import {StatusBar} from './plugins/statusbar';
import {Toast} from './plugins/toast';
2015-12-02 09:06:38 +08:00
import {TouchID} from './plugins/touchid';
2015-12-02 03:33:08 +08:00
2015-12-02 08:47:24 +08:00
export {
ActionSheet,
2016-03-05 05:42:21 +08:00
AppRate,
AppVersion,
2016-02-02 22:35:45 +08:00
BarcodeScanner,
2016-03-05 05:42:21 +08:00
Badge,
2015-12-02 08:47:24 +08:00
BLE,
Camera,
Calendar,
2016-03-05 00:33:36 +08:00
Clipboard,
2015-12-02 08:47:24 +08:00
Contacts,
2016-03-05 05:42:21 +08:00
DatePicker,
2015-12-02 08:47:24 +08:00
Device,
Facebook,
Geolocation,
Push,
StatusBar,
2015-12-02 09:06:38 +08:00
Toast,
2016-03-05 05:42:21 +08:00
TouchID
2015-12-02 08:47:24 +08:00
}
export * from './plugins/plugin';
2015-12-02 03:33:08 +08:00
// Window export to use outside of a module loading system
window['IonicNative'] = {
ActionSheet: ActionSheet,
2016-03-05 05:42:21 +08:00
AppRate: AppRate,
AppVersion: AppVersion,
BarcodeScanner: BarcodeScanner,
Badge: Badge,
2015-12-02 03:33:08 +08:00
BLE: BLE,
Camera: Camera,
Calendar: Calendar,
2016-03-05 05:42:21 +08:00
Clipboard: Clipboard,
2015-12-02 08:47:24 +08:00
Contacts: Contacts,
2016-03-05 05:42:21 +08:00
DatePicker: DatePicker,
2015-12-02 03:33:08 +08:00
Device: Device,
Facebook: Facebook,
Geolocation: Geolocation,
2015-12-02 08:47:24 +08:00
Push: Push,
2015-12-02 03:33:08 +08:00
StatusBar: StatusBar,
2015-12-02 09:06:38 +08:00
Toast: Toast,
2016-03-05 05:42:21 +08:00
TouchID: TouchID
2016-03-07 04:27:26 +08:00
};
2015-12-02 03:33:08 +08:00
2015-11-30 07:20:11 +08:00
// To help developers using cordova, we listen for the device ready event and
// log an error if it didn't fire in a reasonable amount of time. Generally,
// when this happens, developers should remove and reinstall plugins, since
// an inconsistent plugin is often the culprit.
2015-12-01 03:27:25 +08:00
let before = +new Date;
2015-11-30 06:30:15 +08:00
let didFireReady = false;
2015-12-01 03:27:25 +08:00
document.addEventListener('deviceready', function() {
2016-03-07 04:27:26 +08:00
console.log('DEVICE READY FIRED AFTER', (+new Date - before), 'ms');
2015-11-30 06:30:15 +08:00
didFireReady = true;
2016-03-07 04:27:26 +08:00
});
2015-11-30 06:30:15 +08:00
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);