on master help sign in
078ba3fiko
flake.lock+15−15
@@ -6,11 +6,11 @@
6 "rust-analyzer-src": "rust-analyzer-src"
6 "rust-analyzer-src": "rust-analyzer-src"
7 },
7 },
8 "locked": {
8 "locked": {
9− "lastModified": 1724221791,
9+ "lastModified": 1730010749,
10− "narHash": "sha256-mKX67QPnUybOopVph/LhOV1G/H4EvPxDIfSmbufrVdA=",
10+ "narHash": "sha256-UBckyKItSD0z50+3YQOqfOuyvUI7UjPHiLbOPFUolqo=",
11 "owner": "nix-community",
11 "owner": "nix-community",
12 "repo": "fenix",
12 "repo": "fenix",
13− "rev": "e88b38a5a3834e039d413a88f8150a75ef6453ef",
13+ "rev": "5fa09829e74070c1e83b2aaa50b71bbc6da3f37c",
14 "type": "github"
14 "type": "github"
15 },
15 },
16 "original": {
16 "original": {
@@ -24,11 +24,11 @@
24 "systems": "systems"
24 "systems": "systems"
25 },
25 },
26 "locked": {
26 "locked": {
27− "lastModified": 1710146030,
27+ "lastModified": 1726560853,
28− "narHash": "sha256-SZ5L6eA7HJ/nmkzGG7/ISclqe6oZdOZTNoesiInkXPQ=",
28+ "narHash": "sha256-X6rJYSESBVr3hBoH0WbKE5KvhPU5bloyZ2L4K60/fPQ=",
29 "owner": "numtide",
29 "owner": "numtide",
30 "repo": "flake-utils",
30 "repo": "flake-utils",
31− "rev": "b1d9ab70662946ef0850d488da1c9019f3a9752a",
31+ "rev": "c1dfcf08411b08f6b8615f7d8971a2bfa81d5e8a",
32 "type": "github"
32 "type": "github"
33 },
33 },
34 "original": {
34 "original": {
@@ -38,11 +38,11 @@
38 },
38 },
39 "nixpkgs": {
39 "nixpkgs": {
40 "locked": {
40 "locked": {
41− "lastModified": 1723991338,
41+ "lastModified": 1729880355,
42− "narHash": "sha256-Grh5PF0+gootJfOJFenTTxDTYPidA3V28dqJ/WV7iis=",
42+ "narHash": "sha256-RP+OQ6koQQLX5nw0NmcDrzvGL8HDLnyXt/jHhL1jwjM=",
43 "owner": "nixos",
43 "owner": "nixos",
44 "repo": "nixpkgs",
44 "repo": "nixpkgs",
45− "rev": "8a3354191c0d7144db9756a74755672387b702ba",
45+ "rev": "18536bf04cd71abd345f9579158841376fdd0c5a",
46 "type": "github"
46 "type": "github"
47 },
47 },
48 "original": {
48 "original": {
@@ -54,11 +54,11 @@
54 },
54 },
55 "nixpkgs_2": {
55 "nixpkgs_2": {
56 "locked": {
56 "locked": {
57− "lastModified": 1723637854,
57+ "lastModified": 1729880355,
58− "narHash": "sha256-med8+5DSWa2UnOqtdICndjDAEjxr5D7zaIiK4pn0Q7c=",
58+ "narHash": "sha256-RP+OQ6koQQLX5nw0NmcDrzvGL8HDLnyXt/jHhL1jwjM=",
59 "owner": "NixOS",
59 "owner": "NixOS",
60 "repo": "nixpkgs",
60 "repo": "nixpkgs",
61− "rev": "c3aa7b8938b17aebd2deecf7be0636000d62a2b9",
61+ "rev": "18536bf04cd71abd345f9579158841376fdd0c5a",
62 "type": "github"
62 "type": "github"
63 },
63 },
64 "original": {
64 "original": {
@@ -77,11 +77,11 @@
77 "rust-analyzer-src": {
77 "rust-analyzer-src": {
78 "flake": false,
78 "flake": false,
79 "locked": {
79 "locked": {
80− "lastModified": 1724153119,
80+ "lastModified": 1729923686,
81− "narHash": "sha256-WxpvDJDttkINkXmUA/W5o11lwLPYhATAgu0QUAacZ2g=",
81+ "narHash": "sha256-Tc+5E/UmjpXlYGQQ6X2nGDv6J6VQgZ+pVOJLcNCIVQc=",
82 "owner": "rust-lang",
82 "owner": "rust-lang",
83 "repo": "rust-analyzer",
83 "repo": "rust-analyzer",
84− "rev": "3723e5910c14f0ffbd13de474b8a8fcc74db04ce",
84+ "rev": "26d2fbaef2d68a2fccf55d725915188c2634439a",
85 "type": "github"
85 "type": "github"
86 },
86 },
87 "original": {
87 "original": {
hello.nock

Binary file not shown.

index.htmldeleted−12
@@ -1,12 +0,0 @@
1−<!DOCTYPE html>
2−
3−<html>
4−<head>
5− <meta charset="UTF-8" />
6− <meta name="viewport" content="width=device-width, initial-scale=1, minimum-scale=1" />
7−</head>
8−<body>
9− <script type="text/javascript" src="/result/nock.js"></script>
10− <script type="text/javascript" src="/script.js"></script>
11−</body>
12−</html>
nock/hello.hoon+5−1
@@ -1 +1,5 @@
1+|= name=@t
1−|=(x=@t (crip (weld "Hello, " (trip x))))
2+?+ name (crip (weld "Hello, " (trip name)))
3+ 'Curtis' 'Hello, daddy...'
4+ '' 'Hello, world!'
5+==
nock/hello.nock

Binary file not shown.

wock-web/Cargo.toml+8−2
@@ -21,11 +21,14 @@ nock = { path = "../nock" }
21console_error_panic_hook = { version = "0.1.7", optional = true }
21console_error_panic_hook = { version = "0.1.7", optional = true }
22wasm-bindgen-futures = "0.4.45"
22wasm-bindgen-futures = "0.4.45"
23js-sys = "0.3.72"
23js-sys = "0.3.72"
24−gloo = "0.11.0"
25
24
26[dependencies.web-sys]
25[dependencies.web-sys]
27version = "0.3.72"
26version = "0.3.72"
28−features = ['Headers', 'Request', 'RequestInit', 'RequestMode', 'Response', 'Window', 'Blob']
27+features = ['Headers', 'Request', 'RequestInit', 'RequestMode', 'Response', 'Window', 'Blob', 'Document', 'Element']
28+
29+[dependencies.gloo]
30+version = "0.11.0"
31+features = ['utils']
29
32
30[dev-dependencies]
33[dev-dependencies]
31wasm-bindgen-test = "0.3.34"
34wasm-bindgen-test = "0.3.34"
@@ -33,3 +36,6 @@ wasm-bindgen-test = "0.3.34"
33[profile.release]
36[profile.release]
34# Tell `rustc` to optimize for small code size.
37# Tell `rustc` to optimize for small code size.
35opt-level = "s"
38opt-level = "s"
39+
40+[package.metadata.wasm-pack.profile.dev]
41+wasm-opt = ["-O", "--enable-bulk-memory"]
wock-web/build.sh+1−1
@@ -1,3 +1,3 @@
1#!/bin/sh
1#!/bin/sh
2
2
3−wasm-pack build --no-typescript --no-pack --target=web
3+wasm-pack build --no-typescript --no-pack --target=web --dev
wock-web/hello.nocknew file

Binary file not shown.

wock-web/index.html+1
@@ -4,6 +4,7 @@
4 </head>
4 </head>
5 <body>
5 <body>
6 <input id="input"></input>
6 <input id="input"></input>
7+ <div id="output"></div>
7 <script type="module" src="script.mjs?src=/hello.nock"></script>
8 <script type="module" src="script.mjs?src=/hello.nock"></script>
8 </body>
9 </body>
9</html>
10</html>
wock-web/src/lib.rs+29−4
@@ -2,6 +2,7 @@ mod utils;
2
2
3use std::rc::Rc;
3use std::rc::Rc;
4
4
5+use gloo::events::EventListener;
5use nock::{
6use nock::{
6 cue::cue_bytes,
7 cue::cue_bytes,
7 interpreter::{generate_interpreter_context, slam},
8 interpreter::{generate_interpreter_context, slam},
@@ -9,6 +10,7 @@ use nock::{
9};
10};
10use wasm_bindgen::prelude::*;
11use wasm_bindgen::prelude::*;
11use wasm_bindgen_futures::JsFuture;
12use wasm_bindgen_futures::JsFuture;
13+use web_sys::{Element, HtmlInputElement};
12
14
13#[wasm_bindgen]
15#[wasm_bindgen]
14extern "C" {
16extern "C" {
@@ -23,17 +25,40 @@ pub fn greet() {
23 alert("Hello, wock-web!");
25 alert("Hello, wock-web!");
24}
26}
25
27
28+static mut LISTENER: Option<EventListener> = None;
29+
26#[wasm_bindgen]
30#[wasm_bindgen]
27pub async fn main(path: &str) {
31pub async fn main(path: &str) {
28 let nock = load_nock(path).await;
32 let nock = load_nock(path).await;
29
33
30 let mut ctx = generate_interpreter_context();
34 let mut ctx = generate_interpreter_context();
31− let bar = slam(&mut ctx, &nock, &Rc::new(Noun::from_bytes(b"Curtis"))).unwrap();
32
35
36+ let document = gloo::utils::document();
37+ let input_element: web_sys::HtmlInputElement = document
38+ .get_element_by_id("input")
39+ .unwrap()
40+ .dyn_into()
41+ .unwrap();
42+ let output_el: Element = document.get_element_by_id("output").unwrap();
43+ unsafe {
44+ LISTENER = Some(EventListener::new(&input_element, "input", move |ev| {
45+ let el: HtmlInputElement = ev.target().unwrap().dyn_into().unwrap();
46+
47+ let bar = slam(
48+ &mut ctx,
49+ &nock,
50+ &Rc::new(Noun::from_bytes(el.value().as_bytes())),
51+ )
52+ .unwrap();
53+
33− let foo = bar.as_bytes().unwrap();
54+ let foo = bar.as_bytes().unwrap();
34− let qux = String::from_utf8(foo).unwrap();
55+ let qux = String::from_utf8(foo).unwrap();
56+
57+ output_el.set_inner_html(&*qux);
58+ }));
59+ }
35
60
36− log(&*qux);
61+ // window.get_eleme
37}
62}
38
63
39pub async fn load_nock(path: &str) -> Rc<Noun> {
64pub async fn load_nock(path: &str) -> Rc<Noun> {