apache / cordova

Apache Cordova
https://cordova.apache.org/
584 stars 61 forks source link

Add Tauri platform #392

Closed Risto-Stevcev closed 1 year ago

Risto-Stevcev commented 1 year ago

Feature Request

Add a new platform for Tauri apps

Motivation Behind Feature

Why should this feature be implemented? What problem does it solve?

Tauri solves a different use case than Electron. Tauri uses Rust as the backend, making it much more compatible with existing desktop applications that often rely on shared libraries.

For example, a lot of open source desktop projects, especially for Linux, are written in either Qt or Gtk. They've been often criticized for being aesthetically unpleasing, and often lagging behind commercial software. If these projects decide to switch to Tauri in the future, they could reduce the barrier to entry for open source contributions, because frontend engineers could contribute without having to learn Qt or Gtk and how to compile a C/C++ application. Tauri apps are relatively smaller in size and memory footprint than Electron apps.

Electron and Neutralino are more directly comparable than Electron and Tauri, because the backend for Neutralino is nodejs. I think that Neutralino's main tradeoff is that it has a smaller size and memory footprint than Electron, but has a downsize of using TCP sockets to do the IPC between processes instead of unix sockets like Electron does.

Feature Description

N/A

Alternatives or Workarounds

Using the browser platform for Tauri with changes to manifest.json

You can supply a custom manifest.json for the browser platform. Existing Cordova apps that want to use Tauri instead of Electron could use the browser platform with changes to manifest.json that indicate that it's a Tauri app, since Tauri runs in a webview.

The idea is that both the Cordova browser platform and Tauri would likely reuse Web APIs for common tasks like notifications. For example, Tauri Interfaces and Cordova Dialogs use the Notifiations API. Since it's using the same Web API, all that needs to be done is to add the API to your Tauri app and then you could just reuse the Cordova plugin with Tauri.

If Tauri needs a different entry point, such as for a shim/polyfill, or to provide a separate compilation step, a solution could be to provide a different start_url in manifest.json, such as an index.tauri.html. Another possibility is to add another field to manifest.json indicating that it's a Tauri app, and then to create a custom version of the Device plugin that can detect Tauri from the manifest file. Then, when building plugin versions adapted to Tauri, it can check device.platform on the custom Device plugin.

breautek commented 1 year ago

If there is serious support/desire for the Tauri platform, I'd recommend creating a PoC. We don't really have documentation on how to create a platform, but the electron platform is our newest platform and can probably be used as samples to extrapolate from.

While the Tauri platform is Apache/MIT licensed... I do have concerns how flexible it can be when integrating/depending on Qt or GTK libraries as they are all generally GPL (or some variation of) licensed software. Apache products can optionally depend on GPL software but Apache cannot require GPL code and/or libraries and we have take extreme care not to ship/distribute anything that is GPL licensed. (See Policy) So this pretty much makes libraries like libgtk / webkit2gtk a no-go. (webkit2gtk is BSD, but contains GPL code, see http://changelogs.ubuntu.com/changelogs/pool/main/w/webkit2gtk/webkit2gtk_2.32.4-0ubuntu0.18.04.1/copyright).

The licensing concerns will likely be extremely hard to navigate, so for that reason, I have a hard time seeing if it would be incubated as an Apache project.

Risto-Stevcev commented 1 year ago

Ah good point, I didn't think about this. It would prove to be problematic to reuse Cordova plugins in any case, even if it wasn't officially supported by Apache. I guess a Tauri + Cordova app could share it's framework-agnostic code, but provide separate entry points into either framework.

breautek commented 1 year ago

Custom platforms are possible, and as far as my non-lawyer understanding of licensing goes, Apache is compatible with GPL so you can mix the two software together (so you can use the Apache Cordova libraries and mix it with other GPL libraries) but the resulting software must be GPL (which is why Apache can't mix GPL itself).

So a Cordova Tauri platform is possible, but it will have to be completely community driven, and probably licensed under GPL. I do wonder how Tauri navigates this themselves. But that's a question for an actual lawyer.

Risto-Stevcev commented 1 year ago

Ah yeah, it's free as in freedom so you can still probably publish to Play/App Store and sell it as long as you provide the source code, which could be in webassembly.

Risto-Stevcev commented 1 year ago

Actually, I guess not.