WIP fix iced wasm foo
This commit is contained in:
parent
47525c3682
commit
11ab07a34f
12 changed files with 3789 additions and 4742 deletions
5713
Cargo.lock
generated
5713
Cargo.lock
generated
File diff suppressed because it is too large
Load diff
15
Cargo.toml
15
Cargo.toml
|
@ -6,10 +6,6 @@ lto = "thin"
|
||||||
opt-level = 3
|
opt-level = 3
|
||||||
[profile.dev.package.frozen_llama]
|
[profile.dev.package.frozen_llama]
|
||||||
opt-level = 1
|
opt-level = 1
|
||||||
[profile.dev.package.llama_forge_rs]
|
|
||||||
opt-level = 1
|
|
||||||
[profile.dev.package.leptos_stub]
|
|
||||||
opt-level = 1
|
|
||||||
|
|
||||||
|
|
||||||
[profile.release]
|
[profile.release]
|
||||||
|
@ -27,7 +23,7 @@ lto = "fat"
|
||||||
panic = "abort"
|
panic = "abort"
|
||||||
|
|
||||||
[workspace]
|
[workspace]
|
||||||
members = ["llama_forge_rs", "frozen_llama", "llama_proxy_man", "redvault_el_rs", "garnix"]
|
members = ["frozen_llama", "llama_proxy_man", "redvault_el_rs", "garnix"]
|
||||||
resolver = "2"
|
resolver = "2"
|
||||||
|
|
||||||
[workspace.package]
|
[workspace.package]
|
||||||
|
@ -42,15 +38,6 @@ edition = "2021"
|
||||||
|
|
||||||
[workspace.dependencies]
|
[workspace.dependencies]
|
||||||
# iced = { git = "https://github.com/iced-rs/iced.git", branch = "master" }
|
# iced = { git = "https://github.com/iced-rs/iced.git", branch = "master" }
|
||||||
iced = { version = "0.13" }
|
|
||||||
leptos = { version = "0.6", features = ["serde"] }
|
|
||||||
leptos_axum = { version = "0.6" }
|
|
||||||
leptos_meta = { version = "0.6" }
|
|
||||||
leptos_router = { version = "0.6" }
|
|
||||||
server_fn = { version = "0.6" }
|
|
||||||
axum = { version = "0.7", features = ["macros"] }
|
|
||||||
http = "1.1"
|
|
||||||
wasm-bindgen = "=0.2.93"
|
|
||||||
|
|
||||||
[workspace.metadata.cargo-all-features]
|
[workspace.metadata.cargo-all-features]
|
||||||
skip_feature_sets = [["csr", "ssr"], ["csr", "hydrate"], ["ssr", "hydrate"]]
|
skip_feature_sets = [["csr", "ssr"], ["csr", "hydrate"], ["ssr", "hydrate"]]
|
||||||
|
|
6
flake.lock
generated
6
flake.lock
generated
|
@ -108,11 +108,11 @@
|
||||||
},
|
},
|
||||||
"nixpkgs_2": {
|
"nixpkgs_2": {
|
||||||
"locked": {
|
"locked": {
|
||||||
"lastModified": 1736077418,
|
"lastModified": 1738758495,
|
||||||
"narHash": "sha256-2LwAcQXlLkqWyibkYGiS1SfXsewxRuhpYtzrMQSYElc=",
|
"narHash": "sha256-CZ8T4vP3ag2hwkpSZjatxJb55ouszvmnWw09qxGW9TU=",
|
||||||
"owner": "NixOS",
|
"owner": "NixOS",
|
||||||
"repo": "nixpkgs",
|
"repo": "nixpkgs",
|
||||||
"rev": "e554bf17658bd1bfe393dcaca8b8eee6014ddfa1",
|
"rev": "ceaea203f3ae1787b1bd13f021f686391696fc5b",
|
||||||
"type": "github"
|
"type": "github"
|
||||||
},
|
},
|
||||||
"original": {
|
"original": {
|
||||||
|
|
21
flake.nix
21
flake.nix
|
@ -142,9 +142,10 @@
|
||||||
devShells.default = pkgs.mkShell {
|
devShells.default = pkgs.mkShell {
|
||||||
packages = with pkgs;
|
packages = with pkgs;
|
||||||
[
|
[
|
||||||
customNodeModules
|
# customNodeModules
|
||||||
customRustToolchain
|
# customRustToolchain
|
||||||
self.packages.${system}.myllamacpp
|
# self.packages.${system}.myllamacpp
|
||||||
|
rustup
|
||||||
bacon
|
bacon
|
||||||
binaryen
|
binaryen
|
||||||
cacert
|
cacert
|
||||||
|
@ -158,17 +159,19 @@
|
||||||
cargo-make
|
cargo-make
|
||||||
cargo-generate
|
cargo-generate
|
||||||
cargo-udeps
|
cargo-udeps
|
||||||
self.packages.${system}.cargo-leptos
|
# self.packages.${system}.cargo-leptos
|
||||||
(wasm-bindgen-cli.override {
|
wasm-bindgen-cli
|
||||||
version = "0.2.93";
|
# (wasm-bindgen-cli.override {
|
||||||
hash = "sha256-DDdu5mM3gneraM85pAepBXWn3TMofarVR4NbjMdz3r0=";
|
# version = "0.2.93";
|
||||||
cargoHash = "sha256-birrg+XABBHHKJxfTKAMSlmTVYLmnmqMDfRnmG6g/YQ=";
|
# hash = "sha256-DDdu5mM3gneraM85pAepBXWn3TMofarVR4NbjMdz3r0=";
|
||||||
})
|
# cargoHash = "sha256-birrg+XABBHHKJxfTKAMSlmTVYLmnmqMDfRnmG6g/YQ=";
|
||||||
|
# })
|
||||||
cargo-outdated
|
cargo-outdated
|
||||||
cargo-release
|
cargo-release
|
||||||
calc
|
calc
|
||||||
# jre8 # needed for xmlls
|
# jre8 # needed for xmlls
|
||||||
dart-sass
|
dart-sass
|
||||||
|
# trunk
|
||||||
fish
|
fish
|
||||||
inotify-tools
|
inotify-tools
|
||||||
leptosfmt
|
leptosfmt
|
||||||
|
|
|
@ -6,8 +6,7 @@ edition.workspace=true
|
||||||
publish.workspace=true
|
publish.workspace=true
|
||||||
|
|
||||||
[dependencies]
|
[dependencies]
|
||||||
iced.workspace = true
|
iced = { version = "0.13", features = [ "markdown", "highlighter" ]}
|
||||||
|
|
||||||
[target.'cfg(target_arch = "wasm32")'.dependencies]
|
[target.'cfg(target_arch = "wasm32")'.dependencies]
|
||||||
iced.workspace = true
|
iced = { version = "0.13", features = [ "markdown", "highlighter", "webgl" ]}
|
||||||
iced.features = ["webgl"]
|
|
||||||
|
|
2553
frozen_llama/dist/frozen_llama-1ff1acb919012211.js
vendored
Normal file
2553
frozen_llama/dist/frozen_llama-1ff1acb919012211.js
vendored
Normal file
File diff suppressed because it is too large
Load diff
BIN
frozen_llama/dist/frozen_llama-1ff1acb919012211_bg.wasm
vendored
Normal file
BIN
frozen_llama/dist/frozen_llama-1ff1acb919012211_bg.wasm
vendored
Normal file
Binary file not shown.
152
frozen_llama/dist/index.html
vendored
Normal file
152
frozen_llama/dist/index.html
vendored
Normal file
|
@ -0,0 +1,152 @@
|
||||||
|
<!DOCTYPE html>
|
||||||
|
<html lang="en">
|
||||||
|
<head>
|
||||||
|
<meta charset="utf-8" content="text/html; charset=utf-8" />
|
||||||
|
<meta name="viewport" content="width=device-width, initial-scale=1" />
|
||||||
|
<title>Counter - Iced</title>
|
||||||
|
<base href="/" />
|
||||||
|
<link rel="modulepreload" href="/frozen_llama-1ff1acb919012211.js" crossorigin="anonymous" integrity="sha384-6fkB5rhoXDzndAModjY/US8Sbhsgg7eKrlHxsUu07CyZoHCfoFiqx4WWM2g1nevu"><link rel="preload" href="/frozen_llama-1ff1acb919012211_bg.wasm" crossorigin="anonymous" integrity="sha384-C/ioVDilaldzaeO82+Y01hAiO7i09AW9dahsLXhuxqaVBCbxcQVGqS9NNwniSjC0" as="fetch" type="application/wasm"></head>
|
||||||
|
<body>
|
||||||
|
|
||||||
|
<script type="module">
|
||||||
|
import init, * as bindings from '/frozen_llama-1ff1acb919012211.js';
|
||||||
|
const wasm = await init({ module_or_path: '/frozen_llama-1ff1acb919012211_bg.wasm' });
|
||||||
|
|
||||||
|
|
||||||
|
window.wasmBindings = bindings;
|
||||||
|
|
||||||
|
|
||||||
|
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>
|
||||||
|
</html>
|
|
@ -7,6 +7,6 @@
|
||||||
<base data-trunk-public-url />
|
<base data-trunk-public-url />
|
||||||
</head>
|
</head>
|
||||||
<body>
|
<body>
|
||||||
<link data-trunk rel="rust" href="Cargo.toml" data-wasm-opt="z" data-bin="counter" />
|
<link data-trunk rel="rust" href="Cargo.toml" data-wasm-opt="z" data-bin="frozen_llama" />
|
||||||
</body>
|
</body>
|
||||||
</html>
|
</html>
|
||||||
|
|
16
frozen_llama/src/audit.json
Normal file
16
frozen_llama/src/audit.json
Normal file
|
@ -0,0 +1,16 @@
|
||||||
|
{
|
||||||
|
"keepSettings": {
|
||||||
|
"type": 1,
|
||||||
|
"amount": 30
|
||||||
|
},
|
||||||
|
"auditFilename": "audit.json",
|
||||||
|
"hashType": "md5",
|
||||||
|
"extension": ".log",
|
||||||
|
"files": [
|
||||||
|
{
|
||||||
|
"date": 1738759849257,
|
||||||
|
"name": "/home/tristand/.tabby-client/agent/logs/20250205.0.log",
|
||||||
|
"hash": "8691f49ab8bcffd129bab5bb3343c351"
|
||||||
|
}
|
||||||
|
]
|
||||||
|
}
|
|
@ -1,8 +1,13 @@
|
||||||
use iced::widget::{button, column, text, Column};
|
use iced::widget::{button, column, text, Column};
|
||||||
use iced::Center;
|
use iced::Center;
|
||||||
|
|
||||||
|
mod markdown;
|
||||||
|
use markdown::*;
|
||||||
|
|
||||||
pub fn main() -> iced::Result {
|
pub fn main() -> iced::Result {
|
||||||
iced::run("A cool counter", Counter::update, Counter::view)
|
let md = markdown::Markdown::new();
|
||||||
|
// iced::run("A cool counter", Counter::update, Counter::view)
|
||||||
|
iced::run("", markdown::Markdown::update, markdown::Markdown::view)
|
||||||
}
|
}
|
||||||
|
|
||||||
#[derive(Default)]
|
#[derive(Default)]
|
||||||
|
@ -32,7 +37,7 @@ impl Counter {
|
||||||
column![
|
column![
|
||||||
button("Increment").on_press(Message::Increment),
|
button("Increment").on_press(Message::Increment),
|
||||||
text(self.value).size(50),
|
text(self.value).size(50),
|
||||||
button("Decrement").on_press(Message::Decrement)
|
button("Decrement").on_press(Message::Decrement),
|
||||||
]
|
]
|
||||||
.padding(20)
|
.padding(20)
|
||||||
.align_x(Center)
|
.align_x(Center)
|
||||||
|
|
39
frozen_llama/src/markdown.rs
Normal file
39
frozen_llama/src/markdown.rs
Normal file
|
@ -0,0 +1,39 @@
|
||||||
|
use iced::widget::markdown;
|
||||||
|
use iced::Element;
|
||||||
|
use iced::Theme;
|
||||||
|
|
||||||
|
#[derive(Debug, Clone, Default)]
|
||||||
|
pub struct Markdown {
|
||||||
|
markdown: Vec<markdown::Item>,
|
||||||
|
}
|
||||||
|
|
||||||
|
#[derive(Debug)]
|
||||||
|
pub enum Message {
|
||||||
|
LinkClicked(markdown::Url),
|
||||||
|
}
|
||||||
|
|
||||||
|
impl Markdown {
|
||||||
|
pub fn new() -> Self {
|
||||||
|
Self {
|
||||||
|
markdown: markdown::parse("This is some **Markdown**!").collect(),
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
pub fn view(&self) -> Element<'_, Message> {
|
||||||
|
markdown::view(
|
||||||
|
&self.markdown,
|
||||||
|
markdown::Settings::default(),
|
||||||
|
markdown::Style::from_palette(Theme::TokyoNightStorm.palette()),
|
||||||
|
)
|
||||||
|
.map(Message::LinkClicked)
|
||||||
|
.into()
|
||||||
|
}
|
||||||
|
|
||||||
|
pub fn update(_state: &mut Self, message: Message) {
|
||||||
|
match message {
|
||||||
|
Message::LinkClicked(url) => {
|
||||||
|
println!("The following url was clicked: {url}");
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
Loading…
Add table
Reference in a new issue