diff --git a/src/app/App.svelte b/src/app/App.svelte index 47d4f995..1c6e2973 100644 --- a/src/app/App.svelte +++ b/src/app/App.svelte @@ -3,70 +3,80 @@ import logo from "./img/logo.svg?raw"; const baseUrl = "https://github.com/quoid/userscripts"; + const webkit = window.webkit.messageHandlers.controller; - let version = "v0.0.0"; - let build = "(0)"; let directory = "init"; - window.APP = { - show: () => {}, - printVersion: (v, b) => { - version = v; - build = b; - }, - printDirectory: (d) => { - directory = d; - }, + window.webapp = { + updateDirectory: (newDir) => (directory = newDir), }; + async function initialize() { + const app = await webkit.postMessage("INIT"); + directory = app.directory; + return app; + } + function changeDirectory() { - window.webkit?.messageHandlers.controller.postMessage("CHANGE_DIRECTORY"); + webkit.postMessage("CHANGE_DIRECTORY"); } function openDirectory() { - window.webkit?.messageHandlers.controller.postMessage("OPEN_DIRECTORY"); + webkit.postMessage("OPEN_DIRECTORY"); }
-
- Userscripts App Icon - - -
- {#if import.meta.env.GIT_TAG && import.meta.env.GIT_COMMIT} - - {import.meta.env.GIT_TAG} - - ( - {import.meta.env.GIT_COMMIT.slice(0, 7)} - ) - {:else} - {version} - {build} - {/if} + {#await initialize() then app} +
+ Userscripts App Icon + + +
+ {#if import.meta.env.GIT_TAG && import.meta.env.GIT_COMMIT} + + {import.meta.env.GIT_TAG} + + ( + {import.meta.env.GIT_COMMIT.slice(0, 7)} + ) + {:else} + v{app.version} + ({app.build}) + {/if} +
-
-
-

- You can turn on the Userscripts iOS Safari extension in Settings or - Safari, then use the extension in Safari. Please refer to the "Usage" - section in the - README of this version. -

-
-
- -
CURRENT DIRECTORY:
- -
+
+

+ You can turn on the Userscripts iOS Safari extension in Settings or + Safari, then use the extension in Safari. Please refer to the "Usage" + section in the + README of this version. +

+
+
+ +
CURRENT DIRECTORY:
+ +
+ {:catch error} +
+ {error} +
+ {/await} +