Reputation: 10384
I have a hybrid app that I'm trying to convert into a desktop app, adding the electron platform along with android and ios.
Cordova seems to support the electron platform, and just executing cordova platform add electron
it was able to create a window containing the webapp, but with no hook for the plugins.
Since the plugins were firstly written for iOS and Android, I would like to rewrite them in NodeJS, but I'm having a hard time finding any documentation about that. In the cordova documentation I can read:
When adding a plugin, if the plugin supports both the electron and browser platform, the electron portion will be used. If the plugin misses electron but contains the browser implementation, it will fall back on the browser implementation.
But how can I know if a plugin supports the electron platform? And how can other developers know how to make a plugin compatible with electron if it's not mentioned anywhere but the "platform" section of documentation?
So, shortly, how do I setup an electron plugin for cordova?
Upvotes: 3
Views: 1267
Reputation: 182
I disagree with others that say that cordova-electron is only a browser. What the documentation says is that if there is no provided electron-specific plugin, a fallback to the browser implementation will take place.
Here is how to link native c++ to a pure electron app. https://gauriatiq.medium.com/electron-app-with-c-back-end-as-native-addon-napi-c67867f4058
With this in mind, we only need to find a way to make a plugin work with this.
While this would only run on machines able to run native c++, you can imagine there could be a way to make platform specific plugins work under the electron umbrella.
Upvotes: 2
Reputation: 10626
Electron plugins for Cordova are in fact "browser" platform plugins
All browser-based plugins are usable with the Electron platform.
When adding a plugin, if the plugin supports both the electron and browser platform, the electron portion will be used. If the plugin misses electron but contains the browser implementation, it will fall back on the browser implementation.
https://www.electronjs.org/docs/faq#i-can-not-use-jqueryrequirejsmeteorangularjs-in-electron
Read about browser platform here
https://cordova.apache.org/docs/en/latest/plugin_ref/spec.html#platform
Upvotes: 0