fix android tauri window doesnt have js injected

master
Niko PLP 10 months ago
parent 949d3ba519
commit 2e0c6dfdb0
  1. 7
      ng-app/package.json
  2. 2
      ng-app/src-tauri/Cargo.toml
  3. 4
      ng-app/src-tauri/src/lib.rs
  4. 2
      ng-app/src/App.svelte
  5. 4
      ng-app/src/api.ts
  6. 4
      ng-app/src/lib/Login.svelte
  7. 61
      ng-app/src/routes/WalletCreate.svelte
  8. 2
      ngaccount/src/main.rs
  9. 2
      ngaccount/web/package.json
  10. 9
      ngaccount/web/pnpm-lock.yaml
  11. 2
      ngaccount/web/src/routes/Create.svelte
  12. 2
      ngaccount/web/src/routes/Delete.svelte
  13. 10
      ngaccount/web/src/routes/Home.svelte
  14. 2
      ngone/src/store/dynpeer.rs
  15. 2
      ngone/src/store/wallet_record.rs
  16. 2
      p2p-broker/src/broker_store/wallet.rs
  17. 9
      pnpm-lock.yaml

@ -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",

@ -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" }

@ -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"]),
);
}

@ -11,7 +11,7 @@
<script lang="ts">
// this line is needed to have the SDK working when compiling for a single file bundle (pnpm filebuild)
import * as api from "ng-sdk-js";
//import * as api from "ng-sdk-js";
import { push, default as Router } from "svelte-spa-router";
import { onMount, tick, onDestroy } from "svelte";
import {

@ -112,10 +112,10 @@ const handler = {
return res;
} else if (path[0] === "get_wallets_from_localstorage") {
let res = await tauri.invoke(path[0],{});
for (let e of Object.entries(res)) {
if (res) for (let e of Object.entries(res)) {
e[1].wallet.V0.content.security_img = Uint8Array.from(e[1].wallet.V0.content.security_img);
}
return res;
return res || {};
} else if (path[0] === "wallet_create_wallet") {
let params = args[0];

@ -191,7 +191,7 @@
</svg>
</div>
{:else if step == "pazzle"}
<div class="h-screen aspect-[3/5] pazzleline max-w-[600px] min-w-[500px]">
<div class="h-screen aspect-[3/5] pazzleline max-w-[600px] min-w-[350px]">
{#each [0, 1, 2, 3, 4] as row}
<div class="columns-3 gap-0">
{#each emojis2[display]?.slice(0 + row * 3, 3 + row * 3) || [] as emoji, i}
@ -210,7 +210,7 @@
</div>
{:else if step == "order"}
<!-- console.log(cat_idx, emoji_cat[cat_idx], idx, cat[idx].code); -->
<div class="h-screen aspect-[3/3] pazzleline max-w-[600px] min-w-[500px]">
<div class="h-screen aspect-[3/3] pazzleline max-w-[600px] min-w-[350px]">
{#each [0, 1, 2] as row}
<div class="columns-3 gap-0">
{#each selection.slice(0 + row * 3, 3 + row * 3) || [] as emoji, i}

@ -125,10 +125,14 @@
}
}
function confirm_pin(val) {
async function confirm_pin(val) {
if (pin_confirm.length < 4) {
pin_confirm.push(val);
pin_confirm = pin_confirm;
if (pin_confirm.length == 4) {
await tick();
scrollToTop();
}
}
}
@ -138,7 +142,7 @@
async function bootstrap() {
//console.log(await ng.client_info());
if (!tauri_platform) {
if (!tauri_platform || tauri_platform == "android") {
if (param.get("skipintro") || param.get("rs")) {
intro = false;
}
@ -148,21 +152,22 @@
if (param.get("rs")) {
registration_success = param.get("rs");
invitation = await ng.decode_invitation(param.get("i"));
} else {
window.location.replace(window.location.href.split("?")[0]);
} else if (param.get("i")) {
invitation = await ng.get_local_bootstrap_with_public(
location.href,
param.get("i")
);
}
console.log(invitation);
if (!invitation && param.get("i")) {
let redirect = await ng.get_ngone_url_of_invitation(param.get("i"));
if (redirect) {
console.error("got an invitation for another broker. redirecting");
window.location.href = redirect;
} else {
//let i = await ng.decode_invitation(param.get("i"));
console.error("invalid invitation. ignoring it");
console.log(invitation);
if (!invitation) {
let redirect = await ng.get_ngone_url_of_invitation(param.get("i"));
if (redirect) {
console.error("got an invitation for another broker. redirecting");
window.location.href = redirect;
} else {
//let i = await ng.decode_invitation(param.get("i"));
console.error("invalid invitation. ignoring it");
}
}
}
}
@ -277,14 +282,23 @@
});
const select_bsp = async (bsp_url, bsp_name) => {
if (!tauri_platform) {
let local_url = await ng.get_local_url(location.href);
if (!import.meta.env.PROD) {
local_url = "http://localhost:1421";
if (!tauri_platform || tauri_platform == "android") {
let redirect_url;
if (tauri_platform) {
redirect_url = window.location.href;
} else {
let local_url;
if (!import.meta.env.PROD) {
local_url = "http://localhost:1421";
} else {
local_url = await ng.get_local_url(location.href);
}
redirect_url = local_url + APP_WALLET_CREATE_SUFFIX;
}
let create = {
V0: {
redirect_url: local_url + APP_WALLET_CREATE_SUFFIX,
redirect_url,
},
};
let ca = await ng.encode_create_account(create);
@ -338,14 +352,14 @@
const enterINVITE = (event) => {};
const enterQRcode = (event) => {};
const displayNGbox = async (event) => {
if (!tauri_platform) {
if (!tauri_platform || tauri_platform == "android") {
window.open(LINK_NG_BOX, "_blank").focus();
} else {
await ng.open_window(LINK_NG_BOX, "viewer", "Own your NG-Box");
}
};
const displaySelfHost = async (event) => {
if (!tauri_platform) {
if (!tauri_platform || tauri_platform == "android") {
window.open(LINK_SELF_HOST, "_blank").focus();
} else {
await ng.open_window(LINK_SELF_HOST, "viewer", "Self-host a broker");
@ -1030,7 +1044,8 @@
{:else if pin_confirm.length < 4}
<div class=" max-w-6xl lg:px-8 mx-auto px-4">
<p class="max-w-xl md:mx-auto lg:max-w-2xl">
<span class="text-xl">Please confirm your PIN code.</span>
<span class="animate-bounce text-xl">Please confirm your PIN code.</span
>
Enter the same PIN again
</p>
<Alert color="blue" class="mt-5">
@ -1045,7 +1060,7 @@
<button
tabindex="0"
class="m-1 select-none align-bottom text-7xl w-[100px] h-[100px] p-0"
on:click={async () => confirm_pin(num + row * 3)}
on:click={async () => await confirm_pin(num + row * 3)}
>
<span>{num + row * 3}</span>
</button>
@ -1055,7 +1070,7 @@
<button
tabindex="0"
class="m-1 select-none mx-auto align-bottom text-7xl w-[100px] h-[100px] p-0"
on:click={async () => confirm_pin(0)}
on:click={async () => await confirm_pin(0)}
>
<span>0</span>
</button>

@ -272,7 +272,7 @@ async fn main() -> anyhow::Result<()> {
}
log::info!("Starting server on http://localhost:3031");
warp::serve(api_v1.or(static_files).with(cors))
.run(([127, 0, 0, 1], 3031))
.run(([192, 168, 192, 2], 3031))
.await;
Ok(())

@ -10,7 +10,7 @@
"preview": "vite preview"
},
"dependencies": {
"@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",
"flowbite": "^1.6.5",
"flowbite-svelte": "^0.37.1",

@ -2,7 +2,7 @@ lockfileVersion: 5.4
specifiers:
'@sveltejs/vite-plugin-svelte': ^2.0.4
'@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
autoprefixer: ^10.4.14
cross-env: ^7.0.3
@ -18,7 +18,7 @@ specifiers:
vite-plugin-svelte-svg: ^2.2.1
dependencies:
'@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
flowbite: 1.6.6
flowbite-svelte: 0.37.5_svelte@3.59.1
@ -341,6 +341,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/plugin-window/2.0.0-alpha.0:
resolution: {integrity: sha512-ZXFXOu9m8QiDB8d8LFFgwcfxIAbr0bhzj06YvmZDB3isuVtlFP9EyU4D+zmumWEWvNN2XP7xgpn68ivOVhmNNQ==}
dependencies:

@ -27,7 +27,7 @@
let top;
const api_url = import.meta.env.PROD
? "api/v1/"
: "http://localhost:3031/api/v1/";
: "http://192.168.192.2:3031/api/v1/";
async function register() {
const opts = {

@ -27,7 +27,7 @@
let top;
const api_url = import.meta.env.PROD
? "api/v1/"
: "http://localhost:3031/api/v1/";
: "http://192.168.192.2:3031/api/v1/";
async function bootstrap() {}
let error;

@ -15,13 +15,13 @@
import { onMount } from "svelte";
const api_url = import.meta.env.PROD
? "api/v1/"
: "http://localhost:3031/api/v1/";
// const api_url = import.meta.env.PROD
// ? "api/v1/"
// : "http://localhost:3031/api/v1/";
async function bootstrap() {}
// async function bootstrap() {}
onMount(() => bootstrap());
// onMount(() => bootstrap());
</script>
<div />

@ -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)?,

@ -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)?,

@ -76,7 +76,7 @@ impl<'a> Wallet<'a> {
}
pub fn get_or_create_overlay_key(&self, overlay: &OverlayId) -> Result<SymKey, StorageError> {
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(

@ -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'}

Loading…
Cancel
Save