Files
WAFER/crates/web/www/style.css
ok2 246e21fb0f Runtime abstraction + browser REPL
Decouple ForthVM from wasmtime via a Runtime trait so the same outer
interpreter, compiler, and 200+ word definitions work on both native
(wasmtime) and browser (js-sys WebAssembly API) backends.

Runtime trait (runtime.rs):
- HostAccess trait for memory/global ops inside host function closures
- HostFn type: Box<dyn Fn(&mut dyn HostAccess) -> Result<()>>
- Runtime trait: memory, globals, table, instantiate, call, register

NativeRuntime (runtime_native.rs):
- Wraps wasmtime Engine/Store/Memory/Table/Global/Func
- CallerHostAccess bridges HostAccess to wasmtime Caller API
- Feature-gated behind "native" (default)

outer.rs refactor:
- ForthVM<R: Runtime> — generic over execution backend
- All 87 host functions converted from Func::new closures to HostFn
- All memory access via rt.mem_read/write_*, global access via rt.get/set_*
- Zero logic changes — pure API conversion

wafer-core feature gates:
- default = ["native"] includes wasmtime + all native modules
- Without "native": pure Rust only (outer, codegen, optimizer, dictionary)

Browser REPL (crates/web):
- WebRuntime: js-sys WebAssembly.Memory/Table/Global/Module/Instance
- WaferRepl: wasm-bindgen entry point (evaluate, data_stack, reset)
- WebAssembly.Function with Safari fallback (wrapper module)
- Frontend: dark terminal UI, word panel, init code editor, history
- Build: wasm-pack build --target web

All 452 tests pass (431 unit + 1 benchmark + 9 comparison + 11 compliance).
2026-04-13 10:06:37 +02:00

382 lines
6.5 KiB
CSS

:root {
--bg: #0d1117;
--bg-panel: #161b22;
--bg-input: #0d1117;
--border: #30363d;
--text: #e6edf3;
--text-dim: #8b949e;
--accent: #58a6ff;
--accent-dim: #1f6feb;
--ok: #3fb950;
--error: #f85149;
--prompt: #d2a8ff;
--output: #79c0ff;
--font-mono: 'JetBrains Mono', 'Fira Code', 'Cascadia Code', 'Consolas', monospace;
}
* { margin: 0; padding: 0; box-sizing: border-box; }
body {
font-family: var(--font-mono);
font-size: 14px;
background: var(--bg);
color: var(--text);
height: 100vh;
overflow: hidden;
}
#app {
display: flex;
flex-direction: column;
height: 100vh;
}
/* Header */
header {
display: flex;
justify-content: space-between;
align-items: center;
padding: 8px 16px;
background: var(--bg-panel);
border-bottom: 1px solid var(--border);
}
header h1 {
font-size: 16px;
font-weight: 600;
color: var(--accent);
}
header .subtitle {
font-size: 11px;
color: var(--text-dim);
font-weight: 400;
margin-left: 8px;
}
.header-actions { display: flex; gap: 8px; }
.header-actions button, .init-actions button, #btn-toggle-words {
background: var(--bg);
border: 1px solid var(--border);
color: var(--text-dim);
padding: 4px 12px;
border-radius: 6px;
cursor: pointer;
font-family: var(--font-mono);
font-size: 12px;
transition: all 0.15s;
}
.header-actions button:hover, .init-actions button:hover, #btn-toggle-words:hover {
color: var(--text);
border-color: var(--accent-dim);
background: var(--bg-panel);
}
/* Main layout */
.main-layout {
display: flex;
flex: 1;
overflow: hidden;
}
/* Word panel */
#word-panel {
width: 260px;
background: var(--bg-panel);
border-right: 1px solid var(--border);
display: flex;
flex-direction: column;
transition: width 0.2s;
overflow: hidden;
}
#word-panel.collapsed {
width: 42px;
}
#word-panel.collapsed .word-content {
display: none;
}
#btn-toggle-words {
writing-mode: vertical-rl;
text-orientation: mixed;
padding: 12px 6px;
border: none;
border-radius: 0;
background: transparent;
width: 100%;
}
#word-panel:not(.collapsed) #btn-toggle-words {
writing-mode: horizontal-tb;
padding: 8px 12px;
border-bottom: 1px solid var(--border);
text-align: left;
}
.word-content {
flex: 1;
overflow-y: auto;
padding: 8px;
}
#word-filter {
width: 100%;
background: var(--bg);
border: 1px solid var(--border);
color: var(--text);
padding: 6px 8px;
border-radius: 4px;
font-family: var(--font-mono);
font-size: 12px;
margin-bottom: 8px;
}
.word-category h4 {
color: var(--accent);
font-size: 11px;
text-transform: uppercase;
letter-spacing: 0.5px;
margin: 12px 0 4px;
cursor: pointer;
user-select: none;
}
.word-category h4::before {
content: '\25BE ';
font-size: 10px;
}
.word-category.collapsed h4::before {
content: '\25B8 ';
}
.word-category.collapsed .word-list {
display: none;
}
.word-list {
display: flex;
flex-wrap: wrap;
gap: 3px;
}
.word-chip {
background: var(--bg);
border: 1px solid var(--border);
color: var(--text-dim);
padding: 2px 6px;
border-radius: 3px;
font-size: 11px;
cursor: pointer;
transition: all 0.1s;
}
.word-chip:hover {
color: var(--text);
border-color: var(--accent-dim);
background: rgba(88, 166, 255, 0.1);
}
.word-chip.user-word {
border-color: var(--ok);
color: var(--ok);
}
/* Terminal */
#terminal-area {
flex: 1;
display: flex;
flex-direction: column;
overflow: hidden;
}
#output {
flex: 1;
overflow-y: auto;
padding: 12px 16px;
white-space: pre-wrap;
word-break: break-all;
line-height: 1.6;
font-size: 14px;
}
.line { margin: 0; }
.line-input { color: var(--text); }
.line-output { color: var(--output); }
.line-ok { color: var(--ok); }
.line-error { color: var(--error); }
#input-line {
display: flex;
align-items: center;
padding: 8px 16px;
background: var(--bg-panel);
border-top: 1px solid var(--border);
}
#prompt {
color: var(--prompt);
font-weight: 600;
margin-right: 4px;
user-select: none;
}
#input {
flex: 1;
background: transparent;
border: none;
color: var(--text);
font-family: var(--font-mono);
font-size: 14px;
outline: none;
caret-color: var(--accent);
}
#stack-bar {
padding: 4px 16px;
font-size: 11px;
color: var(--text-dim);
background: var(--bg-panel);
border-top: 1px solid var(--border);
min-height: 24px;
}
/* Init panel */
#init-panel {
border-top: 1px solid var(--border);
background: var(--bg-panel);
}
.init-header {
display: flex;
justify-content: space-between;
align-items: center;
padding: 4px 16px;
cursor: pointer;
font-size: 12px;
color: var(--text-dim);
}
.init-body {
overflow: hidden;
transition: max-height 0.2s;
max-height: 200px;
}
.init-body.collapsed {
max-height: 0;
}
#init-code {
width: 100%;
height: 120px;
background: var(--bg);
border: none;
border-top: 1px solid var(--border);
color: var(--text);
font-family: var(--font-mono);
font-size: 13px;
padding: 8px 16px;
resize: vertical;
outline: none;
}
/* Help overlay */
#help-overlay {
position: fixed;
inset: 0;
background: rgba(0, 0, 0, 0.7);
display: flex;
align-items: center;
justify-content: center;
z-index: 100;
}
#help-overlay.hidden { display: none; }
.help-content {
background: var(--bg-panel);
border: 1px solid var(--border);
border-radius: 12px;
padding: 24px;
max-width: 640px;
max-height: 80vh;
overflow-y: auto;
position: relative;
}
.help-content h2 {
color: var(--accent);
font-size: 18px;
margin-bottom: 16px;
}
.help-content h3 {
color: var(--text-dim);
font-size: 12px;
text-transform: uppercase;
margin: 12px 0 4px;
}
.help-content code {
display: block;
color: var(--text);
font-size: 12px;
line-height: 1.8;
word-spacing: 8px;
}
.help-columns {
display: grid;
grid-template-columns: 1fr 1fr;
gap: 16px;
}
.help-footer {
margin-top: 16px;
font-size: 12px;
color: var(--text-dim);
}
.close-help {
position: absolute;
top: 12px;
right: 16px;
background: none;
border: none;
color: var(--text-dim);
font-size: 24px;
cursor: pointer;
}
.close-help:hover { color: var(--text); }
/* Loading state */
.loading {
display: flex;
align-items: center;
justify-content: center;
height: 100%;
color: var(--text-dim);
font-size: 16px;
}
@keyframes pulse {
0%, 100% { opacity: 0.4; }
50% { opacity: 1; }
}
.loading span {
animation: pulse 1.5s ease-in-out infinite;
}
/* Responsive */
@media (max-width: 768px) {
#word-panel { display: none; }
.help-columns { grid-template-columns: 1fr; }
}