2015-11-25 08:37:29 +08:00
|
|
|
interface Window { Native: any }
|
|
|
|
|
2015-11-25 04:04:16 +08:00
|
|
|
import {PluginConfig} from './plugin-config'
|
|
|
|
import {promisifyCordova} from './cordova';
|
|
|
|
|
2015-11-25 05:00:16 +08:00
|
|
|
import {get} from './util';
|
|
|
|
|
2015-11-26 01:44:58 +08:00
|
|
|
export * from './plugins/camera';
|
|
|
|
|
|
|
|
/*
|
2015-11-25 04:37:34 +08:00
|
|
|
let wrappedPlugins = {}
|
2015-11-25 04:04:16 +08:00
|
|
|
|
2015-11-25 04:25:43 +08:00
|
|
|
let promised;
|
2015-11-25 04:37:34 +08:00
|
|
|
|
2015-11-25 04:44:30 +08:00
|
|
|
function newPluginClass(config) {
|
|
|
|
let obj = {
|
|
|
|
installed: () => {
|
2015-11-25 06:55:09 +08:00
|
|
|
return !!obj.plugin();
|
2015-11-25 04:51:47 +08:00
|
|
|
},
|
2015-11-25 04:44:30 +08:00
|
|
|
|
2015-11-25 06:55:09 +08:00
|
|
|
// Get the plugin by checking the plugin ref path on window
|
|
|
|
plugin: () => {
|
|
|
|
return get(window, config.pluginRef)
|
|
|
|
},
|
|
|
|
|
|
|
|
pluginName: config.plugin
|
2015-11-25 04:51:47 +08:00
|
|
|
};
|
2015-11-25 04:44:30 +08:00
|
|
|
|
|
|
|
return obj;
|
|
|
|
}
|
|
|
|
|
2015-11-25 04:37:34 +08:00
|
|
|
// Go through each registered plugin
|
2015-11-25 06:55:09 +08:00
|
|
|
for(let i = 0; i < PluginConfig.length; i++) {
|
|
|
|
let plugin = PluginConfig[i];
|
2015-11-25 04:04:16 +08:00
|
|
|
|
2015-11-25 04:37:34 +08:00
|
|
|
// Create the wrapped class
|
|
|
|
let cls = newPluginClass(plugin);
|
2015-11-25 04:04:16 +08:00
|
|
|
|
2015-11-25 04:37:34 +08:00
|
|
|
promised = plugin.promise || [];
|
2015-11-25 04:04:16 +08:00
|
|
|
|
2015-11-25 06:55:09 +08:00
|
|
|
for(let j = 0; j < promised.length; j++) {
|
|
|
|
let method = promised[j];
|
2015-11-25 04:51:47 +08:00
|
|
|
let p = promisifyCordova(cls, plugin.id, method)
|
2015-11-25 04:37:34 +08:00
|
|
|
cls[method] = p;
|
2015-11-25 04:04:16 +08:00
|
|
|
}
|
|
|
|
|
2015-11-25 04:37:34 +08:00
|
|
|
// Save the plugin object
|
|
|
|
wrappedPlugins[plugin.className] = cls;
|
|
|
|
}
|
|
|
|
|
2015-11-25 08:10:34 +08:00
|
|
|
export default wrappedPlugins;
|
2015-11-26 01:44:58 +08:00
|
|
|
*/
|
2015-11-25 04:04:16 +08:00
|
|
|
|
2015-11-26 01:44:58 +08:00
|
|
|
//window['Native'] = wrappedPlugins;
|