about summary refs log tree commit diff
path: root/web/tvixbolt/src
diff options
context:
space:
mode:
authorIlan Joselevich <personal@ilanjoselevich.com>2024-07-04T18·05+0300
committerIlan Joselevich <personal@ilanjoselevich.com>2024-07-05T20·19+0000
commit7ca32d9f0baf2548ec32d75d2872e8b82d4d8921 (patch)
tree791a20db7c7c1c3cc7da36088ac3b4f11af4f0c0 /web/tvixbolt/src
parent6a7069904e9d29f05638c37a52b640bc9eb43a63 (diff)
refactor(web/tvixbolt): buildRustPackage -> crate2nix r/8349
With the recent changes to crate2nix and buildRustCrate in nixpkgs it is
now possible to build tvixbolt via crate2nix like we do for other tvix
crates. We can reuse a lot of the customizations done in //tvix in
tvixbolt to avoid repeating ourselves.

A script for serving tvixbolt locally for testing purposes is also
available now through the .serve attribute of tvixbolt.

This change supersedes https://cl.tvl.fyi/c/depot/+/11821.

Change-Id: I4864df8b75aec73cf5fee2428924ed4cfbb32902
Reviewed-on: https://cl.tvl.fyi/c/depot/+/11952
Tested-by: BuildkiteCI
Autosubmit: Ilan Joselevich <personal@ilanjoselevich.com>
Reviewed-by: flokli <flokli@flokli.de>
Diffstat (limited to 'web/tvixbolt/src')
-rw-r--r--web/tvixbolt/src/index.css7
-rw-r--r--web/tvixbolt/src/index.html21
-rw-r--r--web/tvixbolt/src/lib.rs (renamed from web/tvixbolt/src/main.rs)4
3 files changed, 31 insertions, 1 deletions
diff --git a/web/tvixbolt/src/index.css b/web/tvixbolt/src/index.css
new file mode 100644
index 000000000000..95bd7d098362
--- /dev/null
+++ b/web/tvixbolt/src/index.css
@@ -0,0 +1,7 @@
+.footer {
+    text-align: right;
+}
+
+.lod {
+    text-align: center;
+}
diff --git a/web/tvixbolt/src/index.html b/web/tvixbolt/src/index.html
new file mode 100644
index 000000000000..a938c4f4ea5e
--- /dev/null
+++ b/web/tvixbolt/src/index.html
@@ -0,0 +1,21 @@
+<!DOCTYPE html>
+<html>
+  <head>
+    <meta content="text/html;charset=utf-8" http-equiv="Content-Type">
+    <meta name="viewport" content="width=device-width, initial-scale=1">
+    <link rel="stylesheet" href="https://static.tvl.su/latest/terminal.min.css">
+    <link rel="stylesheet" href="index.css">
+    <title>Tvixbolt</title>
+  </head>
+  <body>
+    <script type="module">
+      import init, { main } from './tvixbolt.js';
+
+      async function run() {
+        await init();
+	main();
+      }
+
+      run();
+    </script>
+  </body>
diff --git a/web/tvixbolt/src/main.rs b/web/tvixbolt/src/lib.rs
index 2e68e03fb0ba..1f47b0eaf59d 100644
--- a/web/tvixbolt/src/main.rs
+++ b/web/tvixbolt/src/lib.rs
@@ -7,6 +7,7 @@ use std::fmt::Write;
 
 use serde::{Deserialize, Serialize};
 use tvix_eval::observer::{DisassemblingObserver, TracingObserver};
+use wasm_bindgen::prelude::wasm_bindgen;
 use web_sys::HtmlDetailsElement;
 use web_sys::HtmlTextAreaElement;
 use yew::prelude::*;
@@ -310,6 +311,7 @@ fn eval(model: &Model) -> Output {
     out
 }
 
-fn main() {
+#[wasm_bindgen]
+pub fn main() {
     yew::start_app::<Model>();
 }