Report on Tauri
I’d like to report on my experience so far with Tauri. As noted above, the setup process for development went well, and I was able to run the app in development mode with little trouble. There was one non-blocking glitch which turned out to be a bug, but the (very responsive) Tauri core team has already fixed it.
Bundling the app
Bundling the app turned out to be quite simple. I copied the Main.js
and index.html
files into ./dist
as well as the directory ./assets
; the latter has one css file and some Javascript files that work with ports and which define some custom elements that talk to a large JS library (MathJax.js
). I then ran npx tauri bundle
. After a lot of compilation (mostly Rust files, I think), the results were deposited as listed below: an app (which I renamed) and a dmg
installer.
$ tree -L 2 src-tauri/target/release/bundle/
src-tauri/target/release/bundle/
├── dmg
│ ├── app.dmg
│ ├── bundle_dmg.sh
│ └── support
└── osx
└── muEdit.app
If you say “show package contents” for the app, you find the file Contents/MacOs/app
which weighs 4.9 MB. This is the executable. Does anyone know how this compares with Electron?
Note added. There are tools to reduce the size. Maybe able to get to about 1 MB.
Running the app
With two exceptions having to do with JS interop, the app responded normally, and was able to talk to both the localhost server I have been using for data persistence and a remote server. The custom element code worked fine, as did MathJax.js
, which is used to render math formulas. The app was very snappy/responsive.
I did get one crash, but have not been able to duplicate it.
((Turns out that using a localhost server for persistence as I have done is a well-known bad which was pointed out to me by @miniBill and @wolfadex and also referenced in something I read about Tauri.))
What did not work
The two things that did not work had to do with copy-paste between the external world and the app. This uses ports and some JS code which is not part of the Tauri JS API — one gets undefined
in the console. Here is some of the code:
function updateClipboard(newClip) {
console.log("updateClipboard")
navigator.clipboard.writeText(newClip).then(function() {
}, function() {
console.log ("!JS! Clipboard write failed");
});
}
It is navigator
that gave the undefined
message.
Next steps
The next step is to implement file system access and use it to persist the documents that the app works on. For that I will need to figure out how to use the Tauri JS API. This will be slightly tricky since I will have to use require
and hence rely on browserify
— unless someone has a better suggestion.
(@AlienKevin, if you are around, could you ping me? Tauri also has Rust bindings – and is written in Rust. I’d like to see if the file persistence stuff and maybe some other things can be done using Rust. Tauri does have a Rust API. I can be reached here, as jxxcarlson on Slack, and as jxxcarlson on gmail. Thanks!)
Conclusion
Tauri looks very promising. Still very young (one year and one month): version 0.6.3 (four days ago)