On Wed, Nov 5, 2014 at 10:57 AM, Michal Mocny <[email protected]> wrote:
> Hi All,
>
> So there's this new cordova-browser platform thing, which is awesome. I
> wanted to get the ball rolling on full plugin support for browser platform
> (thanks to Suraj Pindoria + other Adobe folk for the great work so far).
>
> I know a bunch of people/teams have independently solved a lot of the
> problems with cordova plugins not running in a browser. E.g. Some teams
> have built client libraries that do feature detection and fallback. I know
> there are some frameworks like angular that have libs for polyfilling
> cordova plugins (I think Ionic may do this by default?). And we saw
> Telerik demo cordova plugin polyfills in something that already looked like
> cordova-browser at PGDay.
>
> Instead of re-inventing the wheel, please help point out such existing
> solutions, and/or reach out to those devs and get them involved in
> upstreaming.
>
> Core plugins that still need implementations are:
>
> cordova-plugin-battery-status
> cordova-plugin-console
> cordova-plugin-contacts
> cordova-plugin-dialogs
> cordova-plugin-file-transfer
> cordova-plugin-file
> cordova-plugin-geolocation
> cordova-plugin-globalization
> cordova-plugin-inappbrowser
> cordova-plugin-media
> cordova-plugin-media-capture
> cordova-plugin-splashscreen
> cordova-plugin-vibration
> cordova-plugin-statusbar
> cordova-plugin-test-framework
>
> cordova-plugins/android-legacy-websql/
> cordova-plugins/file-system-roots/
> cordova-plugins/keyboard/
> cordova-plugins/websql/
>
Just deleted all but keyboard here (within cordova-plugins) as they are
obsolete.
>
> The process for implementing a browser polyfill (I'm new to this, may be
> missing steps), appears to be just like any other platform whose
> implementations are in js (like firefoxos, windows). Here is the
> implementation for device plugin for example:
>
> In plugin.xml:
>
> <!-- browser -->
> <platform name="browser">
> <config-file target="config.xml" parent="/*">
> <feature name="Device">
> <param name="browser-package" value="Device" />
> </feature>
> </config-file>
>
> <js-module src="src/browser/DeviceProxy.js" name="DeviceProxy">
> <runs />
> </js-module>
> </platform>
>
> The critical bits of src/browser/DeviceProxy.js:
>
> module.exports = {
> getDeviceInfo: function (success, error) {
> setTimeout(function () {
> success({
> cordova: browser.cordovaVersion,
> platform: getPlatform(),
> model: getModel(),
> version: getVersion(),
> uuid: null
> });
> }, 0);
> }
> };
>
> require("cordova/exec/proxy").add("Device", module.exports);
>
> That last line is the critical bit, which signals to the bridge to forward
> exec calls to these js functions for the "Device" feature. Proxy handler
> is called with (success, fail, args).
>
> -Michal
>