Skip to content

Commit

Permalink
feat: MacOS and Linux compatibility (#108)
Browse files Browse the repository at this point in the history
  • Loading branch information
lars-berger authored Sep 24, 2024
1 parent 3aad0e3 commit ff0b5fc
Show file tree
Hide file tree
Showing 12 changed files with 761 additions and 552 deletions.
1,084 changes: 643 additions & 441 deletions Cargo.lock

Large diffs are not rendered by default.

6 changes: 3 additions & 3 deletions examples/boilerplates/react-buildless/index.html
Original file line number Diff line number Diff line change
Expand Up @@ -11,9 +11,9 @@
<script type="importmap">
{
"imports": {
"react": "https://esm.sh/react?dev",
"react-dom/client": "https://esm.sh/react-dom/client?dev",
"zebar": "https://esm.sh/zebar"
"react": "https://esm.sh/react@18?dev",
"react-dom/client": "https://esm.sh/react-dom@18/client?dev",
"zebar": "https://esm.sh/zebar@2"
}
}
</script>
Expand Down
6 changes: 3 additions & 3 deletions examples/starter/vanilla.html
Original file line number Diff line number Diff line change
Expand Up @@ -11,9 +11,9 @@
<script type="importmap">
{
"imports": {
"react": "https://esm.sh/react?dev",
"react-dom/client": "https://esm.sh/react-dom/client?dev",
"zebar": "https://esm.sh/zebar"
"react": "https://esm.sh/react@18?dev",
"react-dom/client": "https://esm.sh/react-dom@18/client?dev",
"zebar": "https://esm.sh/zebar@2"
}
}
</script>
Expand Down
6 changes: 3 additions & 3 deletions examples/starter/with-glazewm.html
Original file line number Diff line number Diff line change
Expand Up @@ -11,9 +11,9 @@
<script type="importmap">
{
"imports": {
"react": "https://esm.sh/react?dev",
"react-dom/client": "https://esm.sh/react-dom/client?dev",
"zebar": "https://esm.sh/zebar"
"react": "https://esm.sh/react@18?dev",
"react-dom/client": "https://esm.sh/react-dom@18/client?dev",
"zebar": "https://esm.sh/zebar@2"
}
}
</script>
Expand Down
6 changes: 3 additions & 3 deletions examples/starter/with-komorebi.html
Original file line number Diff line number Diff line change
Expand Up @@ -11,9 +11,9 @@
<script type="importmap">
{
"imports": {
"react": "https://esm.sh/react?dev",
"react-dom/client": "https://esm.sh/react-dom/client?dev",
"zebar": "https://esm.sh/zebar"
"react": "https://esm.sh/react@18?dev",
"react-dom/client": "https://esm.sh/react-dom@18/client?dev",
"zebar": "https://esm.sh/zebar@2"
}
}
</script>
Expand Down
6 changes: 3 additions & 3 deletions packages/client-api/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -25,9 +25,9 @@
"prepublishOnly": "npm run build"
},
"dependencies": {
"@tauri-apps/api": "2.0.0-beta.15",
"@tauri-apps/plugin-dialog": "2.0.0-beta.7",
"@tauri-apps/plugin-shell": "2.0.0-beta.8",
"@tauri-apps/api": "2.0.0-rc.5",
"@tauri-apps/plugin-dialog": "2.0.0-rc.1",
"@tauri-apps/plugin-shell": "2.0.0-rc.1",
"glazewm": "1.4.3",
"luxon": "3.4.4",
"zod": "3.22.4"
Expand Down
16 changes: 9 additions & 7 deletions packages/desktop/Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -10,23 +10,23 @@ edition = "2021"
# See more keys and their definitions at https://doc.rust-lang.org/cargo/reference/manifest.html

[build-dependencies]
tauri-build = { version = "2.0.0-beta", features = [] }
tauri-build = { version = "2.0.0-rc", features = [] }

[dependencies]
anyhow = "1"
async-trait = "0.1"
clap = { version = "4", features = ["derive"] }
reqwest = { version = "0.11", features = ["json"] }
tauri = { version = "2.0.0-beta", features = [
tauri = { version = "2.0.0-rc", features = [
"devtools",
"macos-private-api",
"protocol-asset",
"tray-icon",
] }
tauri-plugin-dialog = "2.0.0-beta"
tauri-plugin-http = "2.0.0-beta"
tauri-plugin-shell = "2.0.0-beta"
tauri-plugin-single-instance = "2.0.0-beta"
tauri-plugin-dialog = "2.0.0-rc"
tauri-plugin-http = "2.0.0-rc"
tauri-plugin-shell = "2.0.0-rc"
tauri-plugin-single-instance = "2.0.0-rc"
serde = { version = "1", features = ["derive"] }
serde_json = "1"
starship-battery = "0.8"
Expand All @@ -39,12 +39,14 @@ regex = "1"

[target.'cfg(target_os = "windows")'.dependencies]
komorebi-client = { git = "https://github.com/LGUG2Z/komorebi", tag = "v0.1.28" }
windows = { version = "0.57", features = [
windows = { version = "0.58", features = [
"Win32_Globalization",
"Win32_System_Console",
"Win32_System_SystemServices",
"Win32_System_Threading",
"Win32_UI_WindowsAndMessaging",
"Win32_UI_Input_KeyboardAndMouse",
"Win32_UI_TextServices",
] }

[target.'cfg(target_os = "macos")'.dependencies]
Expand Down
36 changes: 18 additions & 18 deletions packages/desktop/capabilities/main.json
Original file line number Diff line number Diff line change
Expand Up @@ -4,26 +4,26 @@
"description": "Default capabilities",
"windows": ["*"],
"remote": {
"urls": ["http://asset.localhost"]
"urls": ["http://asset.localhost", "asset://localhost"]
},
"permissions": [
"app:default",
"core:app:default",
"dialog:allow-message",
"event:default",
"path:allow-resolve-directory",
"path:default",
"window:default",
"window:allow-center",
"window:allow-close",
"window:allow-hide",
"window:allow-show",
"window:allow-maximize",
"window:allow-minimize",
"window:allow-set-skip-taskbar",
"window:allow-set-always-on-bottom",
"window:allow-set-always-on-top",
"window:allow-set-resizable",
"window:allow-set-position",
"window:allow-set-size"
"core:event:default",
"core:path:allow-resolve-directory",
"core:path:default",
"core:window:default",
"core:window:allow-center",
"core:window:allow-close",
"core:window:allow-hide",
"core:window:allow-show",
"core:window:allow-maximize",
"core:window:allow-minimize",
"core:window:allow-set-skip-taskbar",
"core:window:allow-set-always-on-bottom",
"core:window:allow-set-always-on-top",
"core:window:allow-set-resizable",
"core:window:allow-set-position",
"core:window:allow-set-size"
]
}
2 changes: 1 addition & 1 deletion packages/desktop/installer.wxs
Original file line number Diff line number Diff line change
Expand Up @@ -153,7 +153,7 @@
</Component>

<Component Id="Path" Guid="{{path_component_guid}}" Win64="$(var.Win64)">
<File Id="Path" Source="{{app_exe_source}}" KeyPath="yes" Checksum="yes" />
<File Id="Path" Source="{{main_binary_path}}" KeyPath="yes" Checksum="yes" />

{{#each file_associations as |association| ~}}
{{#each association.ext as |ext| ~}}
Expand Down
2 changes: 1 addition & 1 deletion packages/desktop/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,7 @@
},
"dependencies": {},
"devDependencies": {
"@tauri-apps/cli": "2.0.0-beta.22",
"@tauri-apps/cli": "2.0.0-rc.16",
"typescript": "5.3.3"
}
}
18 changes: 12 additions & 6 deletions packages/desktop/src/window_factory.rs
Original file line number Diff line number Diff line change
Expand Up @@ -127,13 +127,8 @@ impl WindowFactory {
config_path.display()
);

// TODO: Url-encode the HTML path to get this working on MacOS/Linux.
let webview_url = WebviewUrl::App(
format!(
"http://asset.localhost/{}",
html_path.to_unicode_string()
)
.into(),
Self::to_asset_url(&html_path.to_unicode_string()).into(),
);

// Note that window label needs to be globally unique.
Expand Down Expand Up @@ -193,6 +188,17 @@ impl WindowFactory {
Ok(())
}

/// Converts a file path to a Tauri asset URL.
///
/// Returns a string that can be used as a webview URL.
pub fn to_asset_url(file_path: &str) -> String {
if cfg!(target_os = "windows") {
format!("http://asset.localhost/{}", file_path)
} else {
format!("asset://localhost/{}", file_path)
}
}

/// Registers window events for a given window.
fn register_window_events(
&self,
Expand Down
Loading

0 comments on commit ff0b5fc

Please sign in to comment.