diff --git a/ng-app/dist-file.tar.gz b/ng-app/dist-file.tar.gz index d466dcb..fc0e232 100644 Binary files a/ng-app/dist-file.tar.gz and b/ng-app/dist-file.tar.gz differ diff --git a/ng-app/src/lib/Login.svelte b/ng-app/src/lib/Login.svelte index 1d2296c..88e1a2a 100644 --- a/ng-app/src/lib/Login.svelte +++ b/ng-app/src/lib/Login.svelte @@ -118,16 +118,38 @@ // open the wallet try { - let secret_wallet = await ng.wallet_open_wallet_with_pazzle( - wallet, - pazzle, - pin_code - ); - step = "end"; - dispatch("opened", { - wallet: secret_wallet, - id: secret_wallet.V0.wallet_id, - }); + if (tauri_platform) { + let secret_wallet = await ng.wallet_open_wallet_with_pazzle( + wallet, + pazzle, + pin_code + ); + step = "end"; + dispatch("opened", { + wallet: secret_wallet, + id: secret_wallet.V0.wallet_id, + }); + } else { + let worker_file = await import("../worker.js?worker"); + const myWorker = new worker_file.default(); + myWorker.postMessage({ wallet, pazzle, pin_code }); + + myWorker.onmessage = (msg) => { + //console.log("Message received from worker", msg.data); + if (msg.data.success) { + step = "end"; + dispatch("opened", { + wallet: msg.data.success, + id: msg.data.success.V0.wallet_id, + }); + } else { + console.error(msg.data.error); + error = msg.data.error; + step = "end"; + dispatch("error", { error: msg.data.error }); + } + }; + } } catch (e) { console.error(e); error = e; diff --git a/ng-app/src/worker.js b/ng-app/src/worker.js new file mode 100644 index 0000000..4b4609f --- /dev/null +++ b/ng-app/src/worker.js @@ -0,0 +1,21 @@ +import { + default as ng, + } from "./api"; + + onmessage = (e) => { + //console.log("Message received by worker", e.data); + (async function() { + try { + let secret_wallet = await ng.wallet_open_wallet_with_pazzle( + e.data.wallet, + e.data.pazzle, + e.data.pin_code + ); + postMessage({success:secret_wallet}); + } catch (e) { + postMessage({error:e}); + } + })(); + }; + + \ No newline at end of file diff --git a/ng-app/vite.config.ts b/ng-app/vite.config.ts index 8f48633..6c3d75b 100644 --- a/ng-app/vite.config.ts +++ b/ng-app/vite.config.ts @@ -11,6 +11,13 @@ import topLevelAwait from "vite-plugin-top-level-await"; export default defineConfig(async () => { const host = await internalIpV4() const config = { + worker: { + format: 'es', + plugins : [ + wasm(), + topLevelAwait(), + ] + }, plugins: [ wasm(), topLevelAwait(), @@ -71,6 +78,9 @@ export default defineConfig(async () => { sourcemap: !!process.env.TAURI_DEBUG, } } -if (process.env.NG_APP_FILE) config.plugins.push(viteSingleFile()); +if (process.env.NG_APP_FILE) { + config.plugins.push(viteSingleFile()); + config.worker.plugins.push(viteSingleFile()); +} return config }) diff --git a/ngaccount/web/src/routes/Create.svelte b/ngaccount/web/src/routes/Create.svelte index 46e36e9..5a870d5 100644 --- a/ngaccount/web/src/routes/Create.svelte +++ b/ngaccount/web/src/routes/Create.svelte @@ -180,8 +180,8 @@
You would like to choose {domain} as your Broker Service
- Provider.
Please read carefully the Terms of Service here
- below, before accepting them.
+ Provider.
Please read carefully the Terms of Service below,
+ before accepting them.