Web playground
対象実装: このドキュメントは現行 Web Playground(Bootstrap 実装)について記述する。NEPLg3 の正の仕様は
doc/neplg3/spec/を参照。
The web playground lives under web/ and is built by Trunk (Trunk.toml targetsweb/index.html).
Local development
- Run
trunk serveand openhttp://127.0.0.1:8080/. - GitHub Pages builds pass
--public-url /NEPL-g2/so the published site resolves assets under that prefix. - If you set
--public-urlto a subpath (e.g./web/dist/),trunk servewill also expect that base path. Openhttp://127.0.0.1:8080/web/dist/or pass--serve-base / --ws-base /to serve from root while keeping asset URLs under the subpath.
Panel workspace
The playground now uses a split-tree workspace instead of the old fixed three-pane layout.
- The root layout starts with
Explorer | (Editor / Terminal). - Each leaf panel owns its own shell, focus state, and, for editor panels, its own tab state.
- Split ratios and focused panel state are saved in localStorage and restored on the next launch.
- Toolbar actions such as
Run,Compile,Help, andSavetarget the focused editor panel. - File open requests from the explorer also target the focused editor panel, creating or reusing editor state through the workspace manager.
- Drag-and-drop supports moving panel shells across
left,right,top, andbottomdrop zones. - Editor tabs can be dragged onto another editor panel to merge there, or dropped on a panel edge to create a new split and move the tab into it.
- Explorer files can be dragged onto an editor panel to open there, or dropped on a panel edge to create a new editor split and open the file there.
- Dragging onto an editor panel's tab bar is treated as tab attachment, not as split creation.
- Center-drop merges for editor panels preserve tab snapshots instead of re-reading from VFS.
- Tab switching is treated as a full-document replace, so syntax highlighting does not reuse incremental payloads across unrelated files.
- Each editor panel owns its own language provider instance; analysis state is not shared across panels.
- Explorer duplication is intentionally blocked, and the last explorer or last editor panel cannot be closed.
- Editor panels keep zoom per active tab, and terminal panels keep zoom per panel.
- Zoom controls are
Ctrl+Wheel,Ctrl++,Ctrl+-,Ctrl+0, and two-finger pinch on touch devices. The current zoom is shown as a temporary badge overlay in the panel.
Terminal features
The embedded terminal can:
run: compile the current editor source to WASM and execute it in the browser.test: compile and execute stdlib tests (fromstdlib/tests).clear: clear terminal output.
WAT generation is provided by the "WATを生成" button in the editor panel.
Standard input is provided via the terminal stdin textarea. Output is captured
from WASI fd_write and rendered in the terminal pane.
neplg2 build/neplg2 runandwasmiexecution now run in a dedicated web worker, so compile and execution no longer block the workspace UI.- The worker owns long-running WASI execution and streams stdout/stderr back to the terminal while stdin continues to be accepted from the focused terminal panel.
Notes
- The compiler runs in WebAssembly and uses an in-memory stdlib source map.
- Diagnostics are rendered as text with line/column information.
- The terminal is a browser-only convenience; it does not execute
cargocommands. - Only stdlib imports are available in the browser; local file imports are not supported yet.
Editor redevelopment test path
The playground editor redesign is expected to stay testable without a browser.
- The app entrypoint now creates the editor through the new
editor-corebrowser adapter instead of calling the old global factory directly. - Build the web TypeScript side first with
npm --prefix web run build:ts. - When the Rust / WASM side changes, run
trunk buildbefore CLI verification. - The formal CLI check is
node nodesrc/cli.js -i tests/playground_editor --playground-editor-tests -o json=/tmp/playground-editor-tests.json. - Inspect the generated JSON summary to confirm case counts, failures, and per-case snapshots.
- The CLI suite now covers keyboard/state fixtures, pure text editing, left-right and vertical cursor movement, Home/End, PageUp/PageDown, and pure analysis fixtures for highlight payloads, problems, hover, definition, and occurrences.
- Workspace-specific headless checks include
node nodesrc/playground_workspace_test_runner.jsandnode nodesrc/playground_tab_transfer_test_runner.js. - Drag/drop intent checks include
node nodesrc/playground_drag_drop_test_runner.js. - Terminal worker protocol checks include
node nodesrc/playground_shell_worker_test_runner.js. trunk buildis still a hard requirement before commit, but it depends on thetrunkbinary being available in the environment.