feat: updates frontend release

This commit is contained in:
itsscb 2024-08-22 16:18:09 +02:00
parent 8fb11f9bca
commit bf0a66d40f
3 changed files with 19 additions and 178 deletions

46
flake.lock generated
View File

@ -1,30 +1,12 @@
{ {
"nodes": { "nodes": {
"flake-utils": {
"inputs": {
"systems": "systems"
},
"locked": {
"lastModified": 1705309234,
"narHash": "sha256-uNRRNRKmJyCRC/8y1RqBkqWBLM034y4qN7EprSdmgyA=",
"owner": "numtide",
"repo": "flake-utils",
"rev": "1ef2e671c3b0c19053962c07dbda38332dcebf26",
"type": "github"
},
"original": {
"owner": "numtide",
"repo": "flake-utils",
"type": "github"
}
},
"nixpkgs": { "nixpkgs": {
"locked": { "locked": {
"lastModified": 1706487304, "lastModified": 1718428119,
"narHash": "sha256-LE8lVX28MV2jWJsidW13D2qrHU/RUUONendL2Q/WlJg=", "narHash": "sha256-WdWDpNaq6u1IPtxtYHHWpl5BmabtpmLnMAx0RdJ/vo8=",
"owner": "NixOS", "owner": "NixOS",
"repo": "nixpkgs", "repo": "nixpkgs",
"rev": "90f456026d284c22b3e3497be980b2e47d0b28ac", "rev": "e6cea36f83499eb4e9cd184c8a8e823296b50ad5",
"type": "github" "type": "github"
}, },
"original": { "original": {
@ -45,15 +27,14 @@
}, },
"rust-overlay": { "rust-overlay": {
"inputs": { "inputs": {
"flake-utils": "flake-utils",
"nixpkgs": "nixpkgs" "nixpkgs": "nixpkgs"
}, },
"locked": { "locked": {
"lastModified": 1717294752, "lastModified": 1724293269,
"narHash": "sha256-QhlS52cEQyx+iVcgrEoCnEEpWUA6uLdmeLRxk935inI=", "narHash": "sha256-x/XhOAszT/ejditCHUtGOjQcVg2AQhrC/QVew3i7kTI=",
"owner": "oxalica", "owner": "oxalica",
"repo": "rust-overlay", "repo": "rust-overlay",
"rev": "b46857a406d207a1de74e792ef3b83e800c30e08", "rev": "6dc6d34a3a217457d7044dcce32b6d537480a6a1",
"type": "github" "type": "github"
}, },
"original": { "original": {
@ -61,21 +42,6 @@
"repo": "rust-overlay", "repo": "rust-overlay",
"type": "github" "type": "github"
} }
},
"systems": {
"locked": {
"lastModified": 1681028828,
"narHash": "sha256-Vy1rq5AaRuLzOxct8nz4T6wlgyUR7zLU309k9mBC768=",
"owner": "nix-systems",
"repo": "default",
"rev": "da67096a3b9bf56a91d16901293e51ba5b49a27e",
"type": "github"
},
"original": {
"owner": "nix-systems",
"repo": "default",
"type": "github"
}
} }
}, },
"root": "root", "root": "root",

View File

@ -6,15 +6,19 @@ edition = "2021"
# See more keys and their definitions at https://doc.rust-lang.org/cargo/reference/manifest.html # See more keys and their definitions at https://doc.rust-lang.org/cargo/reference/manifest.html
[dependencies] [dependencies]
web-sys = { version = "0.3.69", features = ["HtmlElement", "HtmlInputElement", "KeyboardEvent"] } web-sys = { version = "0.3.69", features = [
"HtmlElement",
"HtmlInputElement",
"KeyboardEvent",
] }
yew = { version = "0.21.0", features = ["csr"] } yew = { version = "0.21.0", features = ["csr"] }
yew-router = { version = "0.18.0"} yew-router = { version = "0.18.0" }
gloo-console = "0.3.0" gloo-console = "0.3.0"
wasm-bindgen-futures = "0.4.43" wasm-bindgen-futures = "0.4.43"
wasm-bindgen = "0.2.93"
yewdux = "0.10.0" yewdux = "0.10.0"
surrealdb = "1.5.4" surrealdb = "1.5.4"
gloo-net = "0.6.0" gloo-net = "0.6.0"
serde = {version = "1.0.198", features = ["derive"]} serde = { version = "1.0.198", features = ["derive"] }
serde_json = "1.0.116" serde_json = "1.0.116"
regex = "1.10.4" regex = "1.10.4"

View File

@ -9,13 +9,13 @@
<link rel="manifest" href="public/manifest.json" /> <link rel="manifest" href="public/manifest.json" />
<link rel="modulepreload" href="/wordl-frontend-b775e5ac46c429c2.js" crossorigin=anonymous integrity="sha384-d9YxtVTJZK55F/tw4RJfGfKHiNOpv6M7cWFUlG56t7ji+lbNzt/d2srIXLbGnbJw"> <link rel="modulepreload" href="/wordl-frontend-fc53a686d7997e96.js" crossorigin=anonymous integrity="sha384-mYYngEqwNe/MByGAOghKzFvwKtcFKa49nvztLGp2bWtEr122LZIy90IwuEsz1d3/">
<link rel="preload" href="/wordl-frontend-b775e5ac46c429c2_bg.wasm" crossorigin=anonymous integrity="sha384-OeuJrCitX0Yk7zu7SEZ0vUlWgR9nwWRfBOEOGtT78f3NzadCDbBZwMxWmg+6xIvI" as="fetch" type="application/wasm"></head> <link rel="preload" href="/wordl-frontend-fc53a686d7997e96_bg.wasm" crossorigin=anonymous integrity="sha384-91qkiGfY7l6p7THqCtyecHAhThTZ71cH0SN3l03GQI8qH7nFwZxck5c25JS+LlCd" as="fetch" type="application/wasm"></head>
<body class="bg-black text-white"> <body class="bg-black text-white">
<script type="module" nonce="bkDD0eidqI71oXS/PsNg0A=="> <script type="module" nonce="z1ycfrQCqxwlbyPwNQ2Ltg==">
import init, * as bindings from '/wordl-frontend-b775e5ac46c429c2.js'; import init, * as bindings from '/wordl-frontend-fc53a686d7997e96.js';
const wasm = await init('/wordl-frontend-b775e5ac46c429c2_bg.wasm'); const wasm = await init('/wordl-frontend-fc53a686d7997e96_bg.wasm');
window.wasmBindings = bindings; window.wasmBindings = bindings;
@ -23,134 +23,5 @@ window.wasmBindings = bindings;
dispatchEvent(new CustomEvent("TrunkApplicationStarted", {detail: {wasm}})); dispatchEvent(new CustomEvent("TrunkApplicationStarted", {detail: {wasm}}));
</script><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> </script></body>
</html> </html>