feat: JavaScript engine with DOM manipulation (oasis-js) - #35
Conversation
…scripts) Add oasis-js crate wrapping QuickJS-NG (rquickjs 0.11) with console API (log/warn/error/info), alert/setTimeout/setInterval stubs, and inline <script> execution in the browser. Feature-gated behind `javascript` in oasis-browser, propagated through oasis-core to SDL and WASM backends. Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
Add document global with getElementById, createElement, createTextNode, body, and title. Element proxies support tagName, id, textContent, children, parentElement, getAttribute, setAttribute, removeAttribute, and appendChild. DOM mutations from JS persist into the CSS cascade. Architecture: Rust-side __oasis_* functions return only primitives to avoid rquickjs lifetime invariance issues; a JS bootstrap IIFE defines the Element prototype and document global bridging the helpers. Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
OASIS_APP=Browser OASIS_URL=vfs://sites/home/js-test.html opens the browser directly on startup with the JS DOM test page. Also enables the javascript feature by default in oasis-app and adds a link to the JS test page from the browser home page. Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
Update README, CLAUDE.md, design.md, and GitHub Pages site to cover: - oasis-js crate (QuickJS-NG runtime, console API, DOM bindings) - JavaScript DOM manipulation in the browser engine - OASIS_APP/OASIS_URL environment variables for auto-launch - Crate count 17 → 18 across all docs and architecture diagrams Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
Codex AI Code ReviewIssues (if any)
Previous Issues (for incremental reviews)(none) Suggestions (if any)
Notes
Generated by Codex AI (gpt-5.3-codex). Supplementary to human reviews. |
Automated fix by Claude in response to Gemini/Codex review. Iteration: 1/5 Co-Authored-By: AI Review Agent <noreply@anthropic.com>
Review Response Agent (Iteration 1)Status: Changes committed, pushing... Commit: Fixed Issues
Ignored Issues
Deferred to Human
Notes
Automated summary of agent fixes. |
Review Response Agent (Iteration 2)Status: No changes needed Fixed Issues
Ignored Issues
Deferred to Human
Notes
The agent reviewed feedback but determined no code changes were required. |
Review Response Agent (Iteration 3)Status: No changes needed Fixed Issues
Ignored Issues
Deferred to Human
Notes
The agent reviewed feedback but determined no code changes were required. |
Codex AI Incremental ReviewThis is an incremental review focusing on changes since the last review. Issues (if any)
Previous Issues (for incremental reviews)
Suggestions (if any)
Notes
Generated by Codex AI (gpt-5.3-codex). Supplementary to human reviews. |
Review Response Agent (Iteration 4)Status: No changes needed Fixed Issues
Ignored Issues
Deferred to Human
Notes
The agent reviewed feedback but determined no code changes were required. |
Summary
oasis-jscrate wrapping QuickJS-NG via rquickjs withconsoleAPI (log/warn/error/info),alert(), andsetTimeout/setIntervalstubsdocument.getElementById,createElement,createTextNode,document.title,document.body, element proxies withtagName,id,textContent,children,parentElement,getAttribute,setAttribute,removeAttribute,appendChildOASIS_APPandOASIS_URLenvironment variables for auto-launching apps on startup (useful for testing and kiosk mode)vfs://sites/home/js-test.htmlwith 12 automated testsjavascript) -- enabled by default on desktop, not available on PSP (MIPS target)Architecture
The DOM binding uses a two-layer design to work around rquickjs lifetime constraints:
__oasis_*functions returning only primitives (String, i32, bool)Elementprototype anddocumentglobalDuring
load_html(), theDocumentis wrapped inRc<RefCell<>>, shared with JS closures, then recovered viaRc::try_unwrap()after the engine is dropped. All DOM mutations from JS persist into the CSS cascade phase.Commits
oasis-jscrate with QuickJS-NG runtime, console API, inline<script>execution (18 tests)oasis-browser/src/js_dom.rs, DOM mutation methods indom.rs, wiring inload_html()(14 tests)OASIS_APP/OASIS_URLenv vars, JS test page in VFSTest plan
cargo test -p oasis-js-- 18 engine/console tests passcargo test -p oasis-browser --features javascript-- 14 JS DOM tests pass (11 unit + 3 integration)cargo test --workspace-- all 3,049 tests passcargo clippy --workspace -- -D warnings-- cleancargo fmt --all -- --check-- cleanOASIS_APP=Browser OASIS_URL="vfs://sites/home/js-test.html"-- JS test page renders with 12/12 tests passingGenerated with Claude Code