feat: WASM web app (browser LesS/KEY) backed by the hel core

Run the real hel core in the browser via WebAssembly, replacing the plain-JS
ooke.github.io/sk reimplementation so the web and the CLI share one generator.

- hel core: new storage module (native fs / wasm localStorage) backs
  init/source/dump/correct; the pipe and pb branches are gated out of wasm;
  the wasm editor is completed (EditorRef) and its password prompt no longer
  blocks the single JS thread (synchronous hel_get_password instead of a
  thread::sleep poll).
- helwasm: hel_load_script for bulk import, a panic hook in hel_init, dropped
  the ok_add / web-sys leftovers; build.sh runs wasm-bindgen into a committed
  pkg/ so GitHub Pages can serve the static dir with no CI.
- UI: rewritten index.html + style.css in the kaizenkodo.org style — responsive,
  masked-but-copyable passwords with click-to-reveal, a quick-generate card plus
  a full command console, localStorage persistence, and paste import/export.
This commit is contained in:
Oleksandr Kozachuk
2026-06-08 18:43:19 +02:00
parent 74d3296882
commit 03c5dadccb
15 changed files with 1018 additions and 271 deletions
+15 -14
View File
@@ -150,25 +150,32 @@ pub mod editor {
#[cfg(target_arch = "wasm32")]
pub mod editor {
use crate::structs::LKErr;
use parking_lot::Mutex;
use std::sync::Arc;
use wasm_bindgen::prelude::*;
// Mirror the unix editor's contract so repl.rs (which holds an `EditorRef`
// and calls `.lock()`) compiles unchanged under wasm.
pub type EditorRef = Arc<Mutex<Editor>>;
#[wasm_bindgen]
extern "C" {
#[wasm_bindgen(js_name = hel_read_password)]
fn extern_read_password(prompt: &str);
#[wasm_bindgen(js_name = hel_current_password)]
fn extern_current_password() -> Option<String>;
// Synchronous: the host page returns the current master-password value.
// (The old read/poll pair used thread::sleep, which deadlocks the single
// browser thread — never use blocking polling under wasm.)
#[wasm_bindgen(js_name = hel_get_password)]
fn extern_get_password(prompt: &str) -> String;
}
#[derive(Debug)]
pub struct Editor {
#[allow(dead_code)]
history: Vec<String>,
}
impl Editor {
pub fn new() -> Self {
Self { history: vec![] }
pub fn new() -> EditorRef {
Arc::new(Mutex::new(Self { history: vec![] }))
}
pub fn clear_history(&mut self) {
@@ -193,13 +200,7 @@ pub mod editor {
}
pub fn password(prompt: String) -> std::io::Result<String> {
extern_read_password(&prompt);
loop {
match extern_current_password() {
Some(p) => return Ok(p),
None => std::thread::sleep(std::time::Duration::from_millis(100)),
}
}
Ok(extern_get_password(&prompt))
}
}