Skip to content

Commit

Permalink
save
Browse files Browse the repository at this point in the history
  • Loading branch information
kent-3 committed Oct 17, 2024
1 parent 2d2f9ff commit bee69d1
Show file tree
Hide file tree
Showing 9 changed files with 972 additions and 683 deletions.
1 change: 0 additions & 1 deletion Cargo.lock

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

1 change: 0 additions & 1 deletion Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -69,7 +69,6 @@ base64 = "0.22.1"
futures = "0.3.20"
async-trait = "0.1.81"
thiserror = "1.0.63"
once_cell = "1.20.2"

# Logging
tracing = "0.1.40"
Expand Down
141 changes: 135 additions & 6 deletions dist/index.html
Original file line number Diff line number Diff line change
Expand Up @@ -9,9 +9,9 @@



<script type="module" nonce="ErjneCZ2DGOyT5CINoeJyA==">
import init, * as bindings from '/trader-leptos-3f3a7ff0257f5c7a.js';
const wasm = await init('/trader-leptos-3f3a7ff0257f5c7a_bg.wasm');
<script type="module" nonce="Pqrf1q8e1VYGtPgDQypKUQ==">
import init, * as bindings from '/trader-leptos-86732d6f79cf68b5.js';
const wasm = await init('/trader-leptos-86732d6f79cf68b5_bg.wasm');


window.wasmBindings = bindings;
Expand Down Expand Up @@ -44,8 +44,8 @@
});
</script>

<link rel="modulepreload" href="/trader-leptos-3f3a7ff0257f5c7a.js" crossorigin=anonymous integrity="sha384-JL0GzV0jEYM6QQxNQxMIHoQvThC4KEZVLherkW7wAVh2o/55Mi1FbZjZDaGoiVOf">
<link rel="preload" href="/trader-leptos-3f3a7ff0257f5c7a_bg.wasm" crossorigin=anonymous integrity="sha384-12+5rWR9lvID8jwKk7f4LFBeV9mskkCHj5JOO7OjpltbrfFzW89znJe/KHmxNFp0" as="fetch" type="application/wasm"></head>
<link rel="modulepreload" href="/trader-leptos-86732d6f79cf68b5.js" crossorigin=anonymous integrity="sha384-kIsbID1iuJLTspXk4nghNvugmBc0JG0lPva1uo4+d4tsfzeFD7ab29IslDsPvJ6A">
<link rel="preload" href="/trader-leptos-86732d6f79cf68b5_bg.wasm" crossorigin=anonymous integrity="sha384-MxX45PAh0FC/NKUzBmOwCxfCHQK8ZaTSw5D8tn7VndcGPhDPrErsuBL+LJn6hCtE" as="fetch" type="application/wasm"></head>

<style>
.spinner {
Expand Down Expand Up @@ -119,6 +119,135 @@
<code
class="unstyled rocker flex items-center whitespace-nowrap rounded bg-surface-50 px-2 py-0.5 font-mono text-lg font-bold dark:bg-neutral-800">Loading...</code>
</div>
</body>
<script>"use strict";

(function () {

const address = '{{__TRUNK_ADDRESS__}}';
const base = '{{__TRUNK_WS_BASE__}}';
let protocol = '';
protocol =
protocol
? protocol
: window.location.protocol === 'https:'
? 'wss'
: 'ws';
const url = protocol + '://' + address + base + '.well-known/trunk/ws';

class Overlay {
constructor() {
// create an overlay
this._overlay = document.createElement("div");
const style = this._overlay.style;
style.height = "100vh";
style.width = "100vw";
style.position = "fixed";
style.top = "0";
style.left = "0";
style.backgroundColor = "rgba(222, 222, 222, 0.5)";
style.fontFamily = "sans-serif";
// not sure that's the right approach
style.zIndex = "1000000";
style.backdropFilter = "blur(1rem)";

const container = document.createElement("div");
// center it
container.style.position = "absolute";
container.style.top = "30%";
container.style.left = "15%";
container.style.maxWidth = "85%";

this._title = document.createElement("div");
this._title.innerText = "Build failure";
this._title.style.paddingBottom = "2rem";
this._title.style.fontSize = "2.5rem";

this._message = document.createElement("div");
this._message.style.whiteSpace = "pre-wrap";

const icon= document.createElement("div");
icon.innerHTML = '<svg xmlns="http://www.w3.org/2000/svg" width="64" height="64" fill="#dc3545" viewBox="0 0 16 16"><path d="M8.982 1.566a1.13 1.13 0 0 0-1.96 0L.165 13.233c-.457.778.091 1.767.98 1.767h13.713c.889 0 1.438-.99.98-1.767L8.982 1.566zM8 5c.535 0 .954.462.9.995l-.35 3.507a.552.552 0 0 1-1.1 0L7.1 5.995A.905.905 0 0 1 8 5zm.002 6a1 1 0 1 1 0 2 1 1 0 0 1 0-2z"/></svg>';
this._title.prepend(icon);

container.append(this._title, this._message);
this._overlay.append(container);

this._inject();
window.setInterval(() => {
this._inject();
}, 250);
}

set reason(reason) {
this._message.textContent = reason;
}

_inject() {
if (!this._overlay.isConnected) {
// prepend it
document.body?.prepend(this._overlay);
}
}

}

class Client {
constructor(url) {
this.url = url;
this.poll_interval = 5000;
this._overlay = null;
}

start() {
const ws = new WebSocket(this.url);
ws.onmessage = (ev) => {
const msg = JSON.parse(ev.data);
switch (msg.type) {
case "reload":
this.reload();
break;
case "buildFailure":
this.buildFailure(msg.data)
break;
}
};
ws.onclose = this.onclose;
}

onclose() {
window.setTimeout(
() => {
// when we successfully reconnect, we'll force a
// reload (since we presumably lost connection to
// trunk due to it being killed, so it will have
// rebuilt on restart)
const ws = new WebSocket(this.url);
ws.onopen = () => window.location.reload();
ws.onclose = this.onclose;
},
this.poll_interval);
}

reload() {
window.location.reload();
}

buildFailure({reason}) {
// also log the console
console.error("Build failed:", reason);

console.debug("Overlay", this._overlay);

if (!this._overlay) {
this._overlay = new Overlay();
}
this._overlay.reason = reason;
}
}

new Client(url).start();

})()
</script></body>

</html>
Binary file removed dist/trader-leptos-3f3a7ff0257f5c7a_bg.wasm
Binary file not shown.
Loading

0 comments on commit bee69d1

Please sign in to comment.