From 2e0c6dfdb0c06282b91588391e828f57914abd74 Mon Sep 17 00:00:00 2001 From: Niko PLP Date: Sun, 6 Aug 2023 14:41:50 +0300 Subject: [PATCH] fix android tauri window doesnt have js injected --- ng-app/package.json | 7 +-- ng-app/src-tauri/Cargo.toml | 2 +- ng-app/src-tauri/src/lib.rs | 4 +- ng-app/src/App.svelte | 2 +- ng-app/src/api.ts | 4 +- ng-app/src/lib/Login.svelte | 4 +- ng-app/src/routes/WalletCreate.svelte | 61 ++++++++++++++++---------- ngaccount/src/main.rs | 2 +- ngaccount/web/package.json | 2 +- ngaccount/web/pnpm-lock.yaml | 9 +++- ngaccount/web/src/routes/Create.svelte | 2 +- ngaccount/web/src/routes/Delete.svelte | 2 +- ngaccount/web/src/routes/Home.svelte | 10 ++--- ngone/src/store/dynpeer.rs | 2 +- ngone/src/store/wallet_record.rs | 2 +- p2p-broker/src/broker_store/wallet.rs | 2 +- pnpm-lock.yaml | 9 +++- 17 files changed, 77 insertions(+), 49 deletions(-) diff --git a/ng-app/package.json b/ng-app/package.json index 61a2d7b..7b1b8eb 100644 --- a/ng-app/package.json +++ b/ng-app/package.json @@ -6,17 +6,18 @@ "scripts": { "dev": "vite", "webdev": "cross-env NG_APP_WEB=1 TAURI_DEBUG=1 vite", - "webbuild": "cross-env NG_APP_WEB=1 vite build", + "webbuild": "cross-env NG_APP_WEB=1 vite build && rm ./dist/assets/*.svg", "filebuild": "cross-env NG_APP_WEB=1 NG_APP_FILE=1 vite build && node prepare-app-file.cjs", "filebuilddebug": "cross-env NG_APP_WEB=1 NG_APP_FILE=1 TAURI_DEBUG=1 vite build -m debug", - "build": "vite build", + "build": "vite build && rm ./dist/assets/*.svg", + "buildfile": "cross-env NG_APP_FILE=1 vite build && rm -r ./dist/assets", "preview": "vite preview", "check": "svelte-check --tsconfig ./tsconfig.json", "tauri": "tauri" }, "dependencies": { "@popperjs/core": "^2.11.8", - "@tauri-apps/api": "2.0.0-alpha.4", + "@tauri-apps/api": "2.0.0-alpha.5", "@tauri-apps/plugin-window": "2.0.0-alpha.0", "async-proxy": "^0.4.1", "classnames": "^2.3.2", diff --git a/ng-app/src-tauri/Cargo.toml b/ng-app/src-tauri/Cargo.toml index b2f7c6a..9d75607 100644 --- a/ng-app/src-tauri/Cargo.toml +++ b/ng-app/src-tauri/Cargo.toml @@ -17,7 +17,7 @@ crate-type = ["staticlib", "cdylib", "rlib"] tauri-build = { version = "2.0.0-alpha.5", features = [] } [dependencies] -tauri = { version = "2.0.0-alpha.9", features = [] } +tauri = { version = "2.0.0-alpha.10", features = [] } serde = { version = "1.0", features = ["derive"] } serde_json = "1.0" p2p-repo = { path = "../../p2p-repo" } diff --git a/ng-app/src-tauri/src/lib.rs b/ng-app/src-tauri/src/lib.rs index d2b33dc..f5f277b 100644 --- a/ng-app/src-tauri/src/lib.rs +++ b/ng-app/src-tauri/src/lib.rs @@ -208,7 +208,8 @@ async fn open_window( ) -> Result<(), ()> { log_debug!("open window url {:?}", url); let already_exists = app.get_window(&label); - if (already_exists.is_some()) { + #[cfg(desktop)] + if already_exists.is_some() { let _ = already_exists.unwrap().close(); std::thread::sleep(std::time::Duration::from_secs(1)); } @@ -332,6 +333,7 @@ impl AppBuilder { app.ipc_scope().configure_remote_access( RemoteDomainAccessScope::new(domain) .add_window("registration") + .add_window("main") .add_plugins(["window", "event"]), ); } diff --git a/ng-app/src/App.svelte b/ng-app/src/App.svelte index ebd63c6..56ae93b 100644 --- a/ng-app/src/App.svelte +++ b/ng-app/src/App.svelte @@ -11,7 +11,7 @@
diff --git a/ngone/src/store/dynpeer.rs b/ngone/src/store/dynpeer.rs index 1b7dc4b..3991455 100644 --- a/ngone/src/store/dynpeer.rs +++ b/ngone/src/store/dynpeer.rs @@ -55,7 +55,7 @@ impl<'a> DynPeer<'a> { if acc.exists() { return Err(StorageError::BackendError); } - store.write_transaction(&|tx| { + store.write_transaction(&mut |tx| { tx.put( Self::PREFIX, &to_vec(&id)?, diff --git a/ngone/src/store/wallet_record.rs b/ngone/src/store/wallet_record.rs index 905e0e7..38425a2 100644 --- a/ngone/src/store/wallet_record.rs +++ b/ngone/src/store/wallet_record.rs @@ -55,7 +55,7 @@ impl<'a> WalletRecord<'a> { if wallet.exists() { return Err(StorageError::BackendError); } - store.write_transaction(&|tx| { + store.write_transaction(&mut |tx| { tx.put( Self::PREFIX, &to_vec(&id)?, diff --git a/p2p-broker/src/broker_store/wallet.rs b/p2p-broker/src/broker_store/wallet.rs index fc12933..170ea41 100644 --- a/p2p-broker/src/broker_store/wallet.rs +++ b/p2p-broker/src/broker_store/wallet.rs @@ -76,7 +76,7 @@ impl<'a> Wallet<'a> { } pub fn get_or_create_overlay_key(&self, overlay: &OverlayId) -> Result { - self.get_or_create_single_key(Self::PREFIX_USER, &to_vec(overlay)?) + self.get_or_create_single_key(Self::PREFIX_OVERLAY, &to_vec(overlay)?) } pub fn create_single_key( diff --git a/pnpm-lock.yaml b/pnpm-lock.yaml index 439d64b..21a6b48 100644 --- a/pnpm-lock.yaml +++ b/pnpm-lock.yaml @@ -9,7 +9,7 @@ importers: specifiers: '@popperjs/core': ^2.11.8 '@sveltejs/vite-plugin-svelte': ^2.0.0 - '@tauri-apps/api': 2.0.0-alpha.4 + '@tauri-apps/api': 2.0.0-alpha.5 '@tauri-apps/cli': 2.0.0-alpha.9 '@tauri-apps/plugin-window': 2.0.0-alpha.0 '@tsconfig/svelte': ^3.0.0 @@ -39,7 +39,7 @@ importers: vite-plugin-wasm: ^3.2.2 dependencies: '@popperjs/core': 2.11.8 - '@tauri-apps/api': 2.0.0-alpha.4 + '@tauri-apps/api': 2.0.0-alpha.5 '@tauri-apps/plugin-window': 2.0.0-alpha.0 async-proxy: 0.4.1 classnames: 2.3.2 @@ -507,6 +507,11 @@ packages: engines: {node: '>= 14.6.0', npm: '>= 6.6.0', yarn: '>= 1.19.1'} dev: false + /@tauri-apps/api/2.0.0-alpha.5: + resolution: {integrity: sha512-OqysC4c819itGxic50RoDMrmd+ofX+MMNkXKeRS0BV2rkKqrnuV17o3TrQXFI1xs/kXRmmPC+3Y42P9Y5uNvRg==} + engines: {node: '>= 14.6.0', npm: '>= 6.6.0', yarn: '>= 1.19.1'} + dev: false + /@tauri-apps/cli-darwin-arm64/2.0.0-alpha.9: resolution: {integrity: sha512-h7AQY4MbHyy7CLANfoegJyaypKQ3fYPlBA3mnhtF+zntrMxVTv+HO9sgn98jGnwlOak8y0NPPKJ6gZFu5GYiNg==} engines: {node: '>= 10'}