Skip to content

Commit

Permalink
Upgrade to Tauri 2.0.0 rc (#262)
Browse files Browse the repository at this point in the history
  • Loading branch information
stephlow authored Sep 17, 2024
1 parent 7158ef9 commit 80e587b
Show file tree
Hide file tree
Showing 59 changed files with 1,307 additions and 855 deletions.
1,952 changes: 1,216 additions & 736 deletions Cargo.lock

Large diffs are not rendered by default.

13 changes: 4 additions & 9 deletions fpx-app/Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -6,20 +6,15 @@ edition = "2021"
# See more keys and their definitions at https://doc.rust-lang.org/cargo/reference/manifest.html

[build-dependencies]
tauri-build = { version = "1.5.5", features = [] }
tauri-build = { version = "2.0.0-rc.11", features = [] }

[dependencies]
schemars.workspace = true
serde = { workspace = true }
serde_json = { workspace = true }
tauri = { version = "1.8.0", features = [
"dialog-open",
"path-all",
"shell-all",
"http-all",
"config-toml",
] }
tauri-plugin-store = { git = "https://github.com/tauri-apps/plugins-workspace", branch = "v1" }
tauri = { version = "2.0.0-rc.14", features = ["config-toml"] }
tauri-plugin-dialog = "2.0.0-rc"
tauri-plugin-store = { version = "2.0.0-rc" }
toml = "0.8.19"

[features]
Expand Down
13 changes: 13 additions & 0 deletions fpx-app/Tauri.toml
Original file line number Diff line number Diff line change
@@ -0,0 +1,13 @@
identifier = "com.fiberplane.fpx"

[build]
devUrl = "http://localhost:5173"
beforeBuildCommand = "pnpm build:fpx-studio"
beforeDevCommand = "pnpm dev:api & pnpm dev:frontend"

[bundle]
active = true
icon = ["../fpx.svg"]

[app.security]
capabilities = ["workspace-capability"]
11 changes: 11 additions & 0 deletions fpx-app/capabilities/workspace.toml
Original file line number Diff line number Diff line change
@@ -0,0 +1,11 @@
identifier = "workspace-capability"
description = "Workspace capabilities for the main window"
windows = ["main-window"]
permissions = [
"core:app:default",
"core:event:allow-listen",
"core:webview:allow-internal-toggle-devtools",
"core:path:allow-resolve-directory",
"dialog:default",
"store:default",
]
Binary file modified fpx-app/icons/128x128.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file modified fpx-app/icons/[email protected]
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file modified fpx-app/icons/32x32.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file modified fpx-app/icons/Square107x107Logo.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file modified fpx-app/icons/Square142x142Logo.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file modified fpx-app/icons/Square150x150Logo.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file modified fpx-app/icons/Square284x284Logo.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file modified fpx-app/icons/Square30x30Logo.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file modified fpx-app/icons/Square310x310Logo.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file modified fpx-app/icons/Square44x44Logo.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file modified fpx-app/icons/Square71x71Logo.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file modified fpx-app/icons/Square89x89Logo.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file modified fpx-app/icons/StoreLogo.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file added fpx-app/icons/android/mipmap-hdpi/ic_launcher.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file added fpx-app/icons/android/mipmap-mdpi/ic_launcher.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file modified fpx-app/icons/icon.icns
Binary file not shown.
Binary file modified fpx-app/icons/icon.ico
Binary file not shown.
Binary file modified fpx-app/icons/icon.png
Binary file added fpx-app/icons/ios/[email protected]
Binary file added fpx-app/icons/ios/[email protected]
Binary file added fpx-app/icons/ios/[email protected]
Binary file added fpx-app/icons/ios/[email protected]
Binary file added fpx-app/icons/ios/[email protected]
Binary file added fpx-app/icons/ios/[email protected]
Binary file added fpx-app/icons/ios/[email protected]
Binary file added fpx-app/icons/ios/[email protected]
Binary file added fpx-app/icons/ios/[email protected]
Binary file added fpx-app/icons/ios/[email protected]
Binary file added fpx-app/icons/ios/[email protected]
Binary file added fpx-app/icons/ios/[email protected]
Binary file added fpx-app/icons/ios/[email protected]
Binary file added fpx-app/icons/ios/[email protected]
Binary file added fpx-app/icons/ios/[email protected]
Binary file added fpx-app/icons/ios/[email protected]
Binary file added fpx-app/icons/ios/[email protected]
Binary file added fpx-app/icons/ios/[email protected]
66 changes: 43 additions & 23 deletions fpx-app/src/main.rs
Original file line number Diff line number Diff line change
Expand Up @@ -2,47 +2,67 @@
#![cfg_attr(not(debug_assertions), windows_subsystem = "windows")]

use state::AppState;
use tauri::{CustomMenuItem, Menu, MenuItem, Submenu, WindowBuilder};
use tauri_plugin_store::StoreBuilder;
use tauri::menu::{MenuBuilder, MenuId, MenuItemBuilder, SubmenuBuilder};
use tauri::{Emitter, WebviewWindowBuilder};
use tauri::{Manager, Wry};
use tauri_plugin_store::StoreCollection;

mod commands;
mod models;
mod state;

const MAIN_WINDOW_ID: &str = "main-window";
const STORE_PATH: &str = "fpx.bin";

fn main() {
let quit = CustomMenuItem::new("quit".to_string(), "Quit");
let open = CustomMenuItem::new("open".to_string(), "Open");
let submenu = Submenu::new("File", Menu::new().add_item(quit).add_item(open));
let menu = Menu::new()
.add_native_item(MenuItem::Copy)
.add_item(CustomMenuItem::new("hide", "Hide"))
.add_submenu(submenu);

tauri::Builder::default()
.plugin(tauri_plugin_store::Builder::default().build())
.plugin(tauri_plugin_store::Builder::new().build())
.plugin(tauri_plugin_dialog::init())
.manage(AppState::default())
.setup(|app| {
StoreBuilder::new(app.handle(), STORE_PATH.parse()?).build();
app.handle()
.try_state::<StoreCollection<Wry>>()
.ok_or("Store not found")
.unwrap();

let quit = MenuItemBuilder::new("Quit").id("quit").build(app).unwrap();
let open = MenuItemBuilder::new("Open workspace")
.id("open")
.build(app)
.unwrap();

let app_menu = SubmenuBuilder::new(app, "App")
.item(&open)
.separator()
.item(&quit)
.build()
.unwrap();

let menu = MenuBuilder::new(app).items(&[&app_menu]).build().unwrap();

let window = WindowBuilder::new(
app.set_menu(menu).unwrap();

let window = WebviewWindowBuilder::new(
app,
"main-window".to_string(),
tauri::WindowUrl::App("index.html".into()),
MAIN_WINDOW_ID.to_string(),
tauri::WebviewUrl::App("index.html".into()),
)
.menu(menu)
.title("fpx")
.build()?;

let window_ = window.clone();
window.on_menu_event(move |event| match event.menu_item_id() {
"quit" => {
std::process::exit(0);
}
"open" => {
window_.emit("request-open-dialog", "").unwrap();
window.on_menu_event(move |_app, event| {
let MenuId(id) = event.id();

match id.as_str() {
"quit" => {
std::process::exit(0);
}
"open" => {
window_.emit("request-open-dialog", "").unwrap();
}
_ => {}
}
_ => {}
});

Ok(())
Expand Down
77 changes: 0 additions & 77 deletions fpx-app/tauri.conf.json

This file was deleted.

21 changes: 15 additions & 6 deletions pnpm-lock.yaml

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

3 changes: 2 additions & 1 deletion studio/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -42,7 +42,8 @@
"@scalar/openapi-parser": "^0.7.2",
"@tanstack/react-query": "^5.51.1",
"@tanstack/react-table": "^8.17.3",
"@tauri-apps/api": "1.6.0",
"@tauri-apps/api": "2.0.0-rc.4",
"@tauri-apps/plugin-dialog": "2.0.0-rc.1",
"@types/highlight-words-core": "^1.2.3",
"@uiw/codemirror-theme-duotone": "^4.22.2",
"@uiw/react-codemirror": "^4.22.2",
Expand Down
2 changes: 1 addition & 1 deletion studio/src/constants.ts
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
export type Runtime = "tauri" | "browser";

const isTauri = "__TAURI__" in window;
const isTauri = "__TAURI_INTERNALS__" in window;
export const RUNTIME: Runtime = isTauri ? "tauri" : "browser";

/**
Expand Down
4 changes: 2 additions & 2 deletions studio/src/tauri/utils.ts
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
import type { Workspace } from "@fiberplane/fpx-types";
import { invoke } from "@tauri-apps/api";
import { open } from "@tauri-apps/api/dialog";
import { invoke } from "@tauri-apps/api/core";
import { open } from "@tauri-apps/plugin-dialog";
import { appDataDir } from "@tauri-apps/api/path";

export async function listRecentWorkspaces() {
Expand Down

0 comments on commit 80e587b

Please sign in to comment.