add url bar and fix corium invocation for single-file mode

This commit is contained in:
CoolElectronics 2023-08-12 18:01:09 -04:00
parent a5840d54dc
commit 099b191981
No known key found for this signature in database
GPG key ID: F63593D168636C50
3 changed files with 54 additions and 21 deletions

View file

@ -1,14 +1,19 @@
<!DOCTYPE html> <!DOCTYPE html>
<html lang="en"> <html lang="en">
<head> <head>
<title></title> <title></title>
<meta charset="UTF-8" /> <meta charset="UTF-8" />
<meta name="viewport" content="width=device-width, initial-scale=1" /> <meta name="viewport" content="width=device-width, initial-scale=1" />
<script type="module" src="src/entry.ts"></script> <script type="module" src="src/entry.ts"></script>
<script src="uv/uv.bundle.js"></script>
<script src="uv.config.js"></script>
</head> </head>
<body> <body>
<div id="app"></div> <div id="app"></div>
</body> </body>
</html> </html>

View file

@ -16,7 +16,7 @@
import { getDatabase, onValue, ref, set } from "firebase/database"; import { getDatabase, onValue, ref, set } from "firebase/database";
import type { Transport } from "protocol"; import type { Transport } from "protocol";
import { openWindow } from "../../corium"; import { Win, openWindow } from "../../corium";
let transport: Transport; let transport: Transport;
@ -124,17 +124,32 @@
); );
} }
function visitURL() { function visitURL(url: string) {
if (!import.meta.env.VITE_ADRIFT_SINGLEFILE) { if (!import.meta.env.VITE_ADRIFT_SINGLEFILE) {
alert("TODO"); let path = `${__uv$config.prefix}${__uv$config.encodeUrl(url)}`;
proxyIframe.src = path;
} else { } else {
let bare = new BareClient(); let bare = new BareClient();
openWindow(new Request(url), "_self", bare, "replace"); openWindow(
new Request(url),
"_self",
proxyIframe.contentWindow! as unknown as Win,
bare,
"replace"
);
} }
} }
</script> </script>
{#if !import.meta.env.VITE_ADRIFT_DEV} {#if ready}
<div class="container h-full w-full">
<div class="container">
<input bind:value={url} type="text" />
<button on:click={() => visitURL(url)}>Go!</button>
</div>
<iframe class="h-full w-full" bind:this={proxyIframe} />
</div>
{:else if !import.meta.env.VITE_ADRIFT_DEV}
<div class="container"> <div class="container">
<label for="email">email</label> <label for="email">email</label>
<input name="email" type="text" bind:value={email} /> <input name="email" type="text" bind:value={email} />
@ -149,16 +164,26 @@
<button on:click={connectDevWS}>Connect with dev websocket</button> <button on:click={connectDevWS}>Connect with dev websocket</button>
{/if} {/if}
{#if ready}
<input bind:value={url} type="text" />
<button on:click={visitURL}>Go!</button>
<iframe bind:this={proxyIframe} />
{/if}
<style> <style>
:global(body, html, #app) {
width: 100vw;
height: 100vh;
padding: 0;
margin: 0;
}
iframe {
outline: none;
border: none;
}
.container { .container {
display: flex; display: flex;
flex-direction: column; flex-direction: column;
width: max-content; width: max-content;
} }
.h-full {
height: 100%;
}
.w-full {
width: 100%;
}
</style> </style>

View file

@ -7,3 +7,6 @@ interface ImportMetaEnv {
interface ImportMeta { interface ImportMeta {
readonly env: ImportMetaEnv; readonly env: ImportMetaEnv;
} }
declare const Ultraviolet: any;
declare const __uv$config: any;