diffuse
diffuse copied to clipboard
Tauri integration
Tauri integration somewhat works now, but there are issues (and I've only tested on MacOS).
- [x] ~~Dialogs don't work (eg. for importing data)~~ Fixed
- [ ] Downloading files doesn't work (eg. export button)
- [ ] Opening links in new tabs doesn't work either (eg. Link to help page)
- [x] Errors regarding the Tauri window in console:
TypeError: window['5ae98b93-333b-439e-a895-08f45041b522'] is not a function. (In 'window['5ae98b93-333b-439e-a895-08f45041b522']({event: "tauri://resize", payload: {"height":1690,"width":2336}})', 'window['5ae98b93-333b-439e-a895-08f45041b522']' is undefined)
- [ ] Waiting for zoom in/out menu items: https://github.com/tauri-apps/tauri/issues/2802
- [x] Different menus for other operating systems (current one is MacOS specific): https://github.com/tauri-apps/tauri/issues/2398
- [ ] Dark mode doesn't work
To dos:
- [ ] Make a universal Mac app with
yarn tauri build --target universal-apple-darwin
- [ ] Transparent window bar: https://github.com/tauri-apps/tauri/issues/2663#issuecomment-1123696703
Hey there. Thanks @schickling for the heads up.
I think that all of these issues have been resolved by the RC, which is now available at crates.io / npm respectively (and is recommended for stability going forward).
Although I am not sure what you mean with Opening links in new tabs (in the browser???) WRT to "different menus": You have full control over this, so I see it as more of a documentation issue, and macOS needed to be overridden because its default is senseless (IMHO).
This too has been fixed:
Errors regarding the Tauri window in console:
Thanks @nothingismagick !
That is not a function
error has indeed been fixed 👍
Not sure what else is supposed to be fixed, so let me clarify the points layed out above:
- Dialogs don't work → Meaning
alert()
,confirm()
andprompt()
. As I understand it, this isn't really an issue, but more a feature that's missing? Any thoughts on how to approach this? - Downloading files → Downloading a generated file using the
download
attribute on<a>
elements. Don't know what to do this one, related to the next point. Should this work in Tauri? - Open link in a new tab →
<a href="..." target="_blank" />
, not entirely sure how this should behave in a Tauri app, I guess opening in the browser makes the most sense? Can I configure Tauri so that this is done automatically?
(5) & (6) regarding the menus are indeed not issues with Tauri but things I have yet to address.
Clarifying the "import dialog", how this works is:
- User clicks
<button>
- Elm injects a
<input type="file" />
- Elm clicks
<input />
This means I can't replace it with https://tauri.studio/docs/api/js/modules/dialog/
<a href="..." target="_blank" />
links should be able to be opened. The default config only allows links matching the regex ^https?://
. I've tried to set it to allow everything using { allowlist: { shell: { open: ".*" }}}
, but that doesn't seem to work.
With regard to <a href>
do you mean opened in the webview? Should it spawn a new webview? Or should it open a browser tab?
<input file>
if elm is trying to be helpful, but isn't, then you should probably construct your own click handler.
Alert -> https://tauri.studio/docs/api/js/modules/dialog#message
Downloading files? I would need to know more about what you mean. From a remote webserver? From the core app? You want it to go to the Downloads folder? I am not trying to be obtuse here, just getting a feeling for what you need.
@nothingismagick <a href="..." target="_blank" />
should open in a new web view, or the default browser. Don't have a strong preference. I found out that this should already work in Tauri, but, I'm using relative urls which don't work with the default configuration. I tried adjusting the regex for the allowList
, but I couldn't get that to work yet (see comment above for more details).
Downloading files is done using <a download href="blob:uri">
(ie. with a https://developer.mozilla.org/en-US/docs/Web/API/URL/createObjectURL uri from the core app), which does indeed go to the downloads folder.
I did already know about the dialog module, but wanted to stick with alert
so it works in the browser as well. Or do you mean Tauri will trigger the dialog module automatically like it does with the <a>
elements?
On the Tauri Discord it was suggested to me I could write plugins for <a download>
and <input type="file" />
, so I might look into that at some point.
Import dialog works now, still having trouble opening links in default browser and downloading files with <a href="blob:..." download />
Download link isn't supported yet: https://github.com/tauri-apps/wry/issues/349 Might be possible to "polyfill" this using https://tauri.app/v1/api/js/modules/dialog
Incoming: https://github.com/tauri-apps/wry/pull/530
Thanks @nothingismagick !
Discussed the "new tab" links on Discord. Notes:
- Relative links can't be opened in the browser because of the custom
tauri
protocol - I'm using https://github.com/tauri-apps/tauri-plugin-localhost, so I can somewhat bypass that. But, I'd still need to prefix all my links with the full hostname (eg.
http://localhost:44999/about/#UI
) - Ideally I'd be able to open my relative links in a new window in my app, but no such (HTML) API is available yet (ie. there's no
<a href target="_newWindow" />
or something similar) - Was told that I could use
WebviewWindow
(write plugin?)
Setting dark mode explicitly changes the CSS successfully. It doesn't however detect dark mode automatically when not setting a preferred theme.
By looking at this code, it should do that: https://github.com/tauri-apps/tao/blob/93c256f9835b2da853129f2a1d77287aa714934e/src/platform_impl/windows/dark_mode.rs#L155-L181 But it doesn't work.
(tauri v1.0.3)
Dark mode is fixed, may have been a plugin that interfered with the theme detection.