The bridge between Cordova phonegap and Electron
Look ma, same codebase!
Electrolyte's focus is to bridge the gap between Cordova and Electron. Plugin shims allow developers to continue to share a single codebase for not only mobile platforms, but now desktop platforms too. Each shim is modeled as close as possible to its cordova plugin interface.
Here's what is coming up
- Continue adding more plugins
- Minification/Complex plugins
- Create-your-own-bundle tool
- Clone or
npm install --save-dev electrolyte-plugins
so you can access the shims. - Follow the installation instructions for each supported plugin. Some plugins require additional node modules to be installed or require additional configuration steps.
- Install electrolyte globally
npm install -g electrolyte-plugins
- Make sure you are in the root of your Polyonic project. Initialize Electrolyte with
electrolyte init
- Update your index.html so that Electrolyte can automatically include the scripts for you:
On Load
Update the cordova.js script tag to look like this:
<script src="cordova.js" onload="javascript:window.isCordovaApp = true;"></script>
Script Comments
Add these comments after so that Electrolyte knows where to put the scripts, like so:
<script src="cordova.js" onload="javascript:window.isCordovaApp = true;"></script>
<!--electrolyte:begin-->
<!--electrolyte:end-->
- Install plugins with
electrolyte install cordova-plugin-device
, if Electrolyte has a shim, it will install it.
Device (cordova-plugin-device)
App Version (cordova-plugin-app-version)
Clipboard (com.verso.cordova.clipboard)
This will install all the plugins listed in the electrolyte.json
. Great for restoring the shims after a fresh clone or copy.
This will install a plugin and update your electrolyte.json
. If a plugin doesn't have a shim yet the call will fail with the information. Note: github urls are not yet supported.
This will give you a list of available plugin shims to install.
The end goal with these shims is to allow any ionic app to be easily ported over for desktop use with minimal code changes. Obviously not all plugins can be ported but the hope is things like notifications, device info, geolocation, etc, can be used without any code modification on the desktop side.
PRs are welcome! If you are contributing please keep in mind the following:
If you are creating a shim for a plugin be sure to follow the correct readme format and include full installation instructions. Shims must line up with the cordova interface. If the cordova plugin is using window.device
, your shim must also bind to window.device
.
If creating additional functionality consider creating an entirely new plugin to keep the mobile-compatible shims more aligned with their cordova plugin methods.