add chir-rs frontend code
This commit is contained in:
parent
40eb10bdeb
commit
e95e109ab2
10 changed files with 4411 additions and 243 deletions
2
.cargo/config.toml
Normal file
2
.cargo/config.toml
Normal file
|
@ -0,0 +1,2 @@
|
||||||
|
[unstable]
|
||||||
|
bindeps = true
|
6
.gitignore
vendored
6
.gitignore
vendored
|
@ -1,7 +1,7 @@
|
||||||
/target
|
/target
|
||||||
.env
|
.env
|
||||||
config.toml
|
/config.toml
|
||||||
.direnv
|
.direnv
|
||||||
target/
|
/target
|
||||||
target-bin/
|
/target-bin
|
||||||
secrets/
|
secrets/
|
1227
Cargo.lock
generated
1227
Cargo.lock
generated
File diff suppressed because it is too large
Load diff
|
@ -3,7 +3,7 @@ members = [
|
||||||
"chir-rs-castore",
|
"chir-rs-castore",
|
||||||
"chir-rs-client",
|
"chir-rs-client",
|
||||||
"chir-rs-config",
|
"chir-rs-config",
|
||||||
"chir-rs-db",
|
"chir-rs-db", "chir-rs-fe",
|
||||||
"chir-rs-gemini",
|
"chir-rs-gemini",
|
||||||
"chir-rs-http",
|
"chir-rs-http",
|
||||||
"chir-rs-http-api",
|
"chir-rs-http-api",
|
||||||
|
|
63
chir-rs-fe/Cargo.toml
Normal file
63
chir-rs-fe/Cargo.toml
Normal file
|
@ -0,0 +1,63 @@
|
||||||
|
[package]
|
||||||
|
name = "chir-rs-fe"
|
||||||
|
version = "0.1.0"
|
||||||
|
edition = "2021"
|
||||||
|
|
||||||
|
[lib]
|
||||||
|
crate-type = ["cdylib"]
|
||||||
|
|
||||||
|
[dependencies]
|
||||||
|
wasm-bindgen = "=0.2.99"
|
||||||
|
yew = { version = "0.21.0", features = ["csr"] }
|
||||||
|
|
||||||
|
[build-dependencies]
|
||||||
|
wasm-bindgen-cli = { version = "=0.2.99", artifact = "bin" }
|
||||||
|
|
||||||
|
[lints.rust]
|
||||||
|
deprecated-safe = "forbid"
|
||||||
|
elided_lifetimes_in_paths = "warn"
|
||||||
|
explicit_outlives_requirements = "warn"
|
||||||
|
impl-trait-overcaptures = "warn"
|
||||||
|
keyword-idents-2024 = "forbid"
|
||||||
|
let-underscore-drop = "warn"
|
||||||
|
macro-use-extern-crate = "deny"
|
||||||
|
meta-variable-misuse = "deny"
|
||||||
|
missing-abi = "forbid"
|
||||||
|
missing-copy-implementations = "warn"
|
||||||
|
missing-debug-implementations = "deny"
|
||||||
|
missing-docs = "warn"
|
||||||
|
missing-unsafe-on-extern = "deny"
|
||||||
|
non-local-definitions = "warn"
|
||||||
|
redundant-lifetimes = "warn"
|
||||||
|
single-use-lifetimes = "warn"
|
||||||
|
trivial-casts = "warn"
|
||||||
|
trivial-numeric-casts = "warn"
|
||||||
|
unit-bindings = "deny"
|
||||||
|
unnameable-types = "warn"
|
||||||
|
unreachable-pub = "warn"
|
||||||
|
unsafe-code = "forbid"
|
||||||
|
unused-crate-dependencies = "warn"
|
||||||
|
unused-extern-crates = "warn"
|
||||||
|
unused-import-braces = "warn"
|
||||||
|
unused-lifetimes = "warn"
|
||||||
|
unused-macro-rules = "warn"
|
||||||
|
unused-qualifications = "warn"
|
||||||
|
variant-size-differences = "warn"
|
||||||
|
|
||||||
|
[lints.clippy]
|
||||||
|
nursery = { level = "warn", priority = -1 }
|
||||||
|
pedantic = { level = "warn", priority = -1 }
|
||||||
|
module-name-repetitions = "allow"
|
||||||
|
alloc-instead-of-core = "warn"
|
||||||
|
allow-attributes-without-reason = "deny"
|
||||||
|
assertions-on-result-states = "forbid"
|
||||||
|
clone-on-ref-ptr = "warn"
|
||||||
|
empty-drop = "warn"
|
||||||
|
expect-used = "deny"
|
||||||
|
inline-asm-x86-att-syntax = "forbid"
|
||||||
|
missing-docs-in-private-items = "warn"
|
||||||
|
panic = "deny"
|
||||||
|
panic-in-result-fn = "forbid"
|
||||||
|
rc-buffer = "warn"
|
||||||
|
rc-mutex = "deny"
|
||||||
|
unwrap-used = "forbid"
|
16
chir-rs-fe/index.html
Normal file
16
chir-rs-fe/index.html
Normal file
|
@ -0,0 +1,16 @@
|
||||||
|
<!doctype html>
|
||||||
|
<html lang="en">
|
||||||
|
|
||||||
|
<head>
|
||||||
|
<script type="module">
|
||||||
|
import init from './chir_rs_fe.js';
|
||||||
|
async function run() {
|
||||||
|
await init();
|
||||||
|
}
|
||||||
|
run();
|
||||||
|
</script>
|
||||||
|
</head>
|
||||||
|
|
||||||
|
<body></body>
|
||||||
|
|
||||||
|
</html>
|
16
chir-rs-fe/src/lib.rs
Normal file
16
chir-rs-fe/src/lib.rs
Normal file
|
@ -0,0 +1,16 @@
|
||||||
|
//! Management frontend for chir.rs
|
||||||
|
|
||||||
|
use wasm_bindgen::prelude::*;
|
||||||
|
use yew::prelude::*;
|
||||||
|
|
||||||
|
#[function_component(App)]
|
||||||
|
fn app() -> Html {
|
||||||
|
html! {
|
||||||
|
<h1>{ "Hello World" }</h1>
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
#[wasm_bindgen(start)]
|
||||||
|
fn main() {
|
||||||
|
yew::Renderer::<App>::new().render();
|
||||||
|
}
|
|
@ -14,11 +14,11 @@
|
||||||
]
|
]
|
||||||
},
|
},
|
||||||
"locked": {
|
"locked": {
|
||||||
"lastModified": 1726552619,
|
"lastModified": 1733731208,
|
||||||
"narHash": "sha256-ytTBILVMnRZYvjiLYz+J6IFf/TOXdGuP6RDesMx9qgA=",
|
"narHash": "sha256-s9O/KIBhKOS49VmYJIBEiCrLK5hocJLKuvAkwAoELLQ=",
|
||||||
"owner": "DarkKirb",
|
"owner": "DarkKirb",
|
||||||
"repo": "cargo2nix",
|
"repo": "cargo2nix",
|
||||||
"rev": "baa12124e2de09e1cbbdac320f14809fa55af1a2",
|
"rev": "37f356e1ba56e591550647c86039ffb0ca0c2201",
|
||||||
"type": "github"
|
"type": "github"
|
||||||
},
|
},
|
||||||
"original": {
|
"original": {
|
||||||
|
|
68
flake.nix
68
flake.nix
|
@ -59,11 +59,38 @@
|
||||||
pkgs = import nixpkgs {
|
pkgs = import nixpkgs {
|
||||||
inherit system overlays;
|
inherit system overlays;
|
||||||
};
|
};
|
||||||
|
pkgs-wasm32 = import nixpkgs {
|
||||||
|
inherit system overlays;
|
||||||
|
crossSystem = {
|
||||||
|
system = "wasm32-wasi";
|
||||||
|
useLLVM = true;
|
||||||
|
};
|
||||||
|
};
|
||||||
rustPkgs = pkgs.rustBuilder.makePackageSet {
|
rustPkgs = pkgs.rustBuilder.makePackageSet {
|
||||||
packageFun = import ./Cargo.nix;
|
packageFun = import ./Cargo.nix;
|
||||||
rustChannel = "stable";
|
rustChannel = "nightly";
|
||||||
rustVersion = "latest";
|
rustVersion = "latest";
|
||||||
packageOverrides = pkgs: pkgs.rustBuilder.overrides.all;
|
packageOverrides = pkgs: pkgs.rustBuilder.overrides.all;
|
||||||
|
extraConfigToml = ''
|
||||||
|
[unstable]
|
||||||
|
bindeps = true
|
||||||
|
'';
|
||||||
|
};
|
||||||
|
rustPkgs-wasm32 = pkgs-wasm32.rustBuilder.makePackageSet {
|
||||||
|
packageFun = import ./Cargo.nix;
|
||||||
|
rustChannel = "nightly";
|
||||||
|
rustVersion = "latest";
|
||||||
|
packageOverrides = pkgs: pkgs.rustBuilder.overrides.all;
|
||||||
|
target = "wasm32-unknown-unknown";
|
||||||
|
hostPlatform = pkgs-wasm32.stdenv.hostPlatform // {
|
||||||
|
parsed = pkgs-wasm32.stdenv.hostPlatform.parsed // {
|
||||||
|
kernel.name = "unknown";
|
||||||
|
};
|
||||||
|
};
|
||||||
|
extraConfigToml = ''
|
||||||
|
[unstable]
|
||||||
|
bindeps = true
|
||||||
|
'';
|
||||||
};
|
};
|
||||||
in
|
in
|
||||||
rec {
|
rec {
|
||||||
|
@ -71,6 +98,13 @@
|
||||||
with pkgs;
|
with pkgs;
|
||||||
mkShell {
|
mkShell {
|
||||||
buildInputs = [
|
buildInputs = [
|
||||||
|
(rust-bin.selectLatestNightlyWith (
|
||||||
|
toolchain:
|
||||||
|
toolchain.default.override {
|
||||||
|
extensions = [ "rust-src" ];
|
||||||
|
targets = [ "wasm32-unknown-unknown" ];
|
||||||
|
}
|
||||||
|
))
|
||||||
cargo2nix.packages.${system}.cargo2nix
|
cargo2nix.packages.${system}.cargo2nix
|
||||||
rustfilt
|
rustfilt
|
||||||
gdb
|
gdb
|
||||||
|
@ -79,9 +113,39 @@
|
||||||
sqlite
|
sqlite
|
||||||
treefmt
|
treefmt
|
||||||
nixfmt-rfc-style
|
nixfmt-rfc-style
|
||||||
|
wabt
|
||||||
|
trunk
|
||||||
|
(rustPkgs."registry+https://github.com/rust-lang/crates.io-index".wasm-bindgen-cli."0.2.99" { })
|
||||||
|
binaryen
|
||||||
];
|
];
|
||||||
};
|
};
|
||||||
packages = pkgs.lib.mapAttrs (_: v: (v { }).overrideAttrs { dontStrip = true; }) rustPkgs.workspace;
|
packages =
|
||||||
|
(pkgs.lib.mapAttrs (_: v: (v { }).overrideAttrs { dontStrip = true; }) rustPkgs.workspace)
|
||||||
|
// {
|
||||||
|
chir-rs-fe =
|
||||||
|
let
|
||||||
|
chir-rs-fe = rustPkgs-wasm32.workspace.chir-rs-fe { };
|
||||||
|
wasm-bindgen-cli =
|
||||||
|
rustPkgs."registry+https://github.com/rust-lang/crates.io-index".wasm-bindgen-cli."0.2.99"
|
||||||
|
{ };
|
||||||
|
in
|
||||||
|
pkgs.stdenvNoCC.mkDerivation {
|
||||||
|
inherit (chir-rs-fe) name version;
|
||||||
|
src = chir-rs-fe.out;
|
||||||
|
dontUnpack = true;
|
||||||
|
dontBuild = true;
|
||||||
|
nativeBuildInputs = [
|
||||||
|
wasm-bindgen-cli
|
||||||
|
pkgs.binaryen
|
||||||
|
];
|
||||||
|
installPhase = ''
|
||||||
|
mkdir $out
|
||||||
|
wasm-opt $src/lib/chir_rs_fe.wasm -o chir_rs_fe.wasm
|
||||||
|
wasm-bindgen chir_rs_fe.wasm --out-dir $out --target web
|
||||||
|
cp ${./chir-rs-fe/index.html} $out/index.html
|
||||||
|
'';
|
||||||
|
};
|
||||||
|
};
|
||||||
nixosModules.default = import ./nixos {
|
nixosModules.default = import ./nixos {
|
||||||
inherit inputs system;
|
inherit inputs system;
|
||||||
};
|
};
|
||||||
|
|
Loading…
Reference in a new issue