This replaces the simple string-based let/const->var transform with
Bun's full transpiler in replMode, enabling:
- Proper hoisting of let/const/var/function/class declarations
- Top-level await support via async IIFE wrapping
- Result capture in { value: expr } wrapper
- Object literal disambiguation (wrapping { } in parens)
- Class and function declarations that persist across lines
The REPL now properly awaits promises by running the event loop
until they resolve, allowing `await Promise.resolve(42)` to work.
Co-Authored-By: Claude Opus 4.5 <noreply@anthropic.com>
Add a simple string-based transform that converts top-level `let` and
`const` declarations to `var`, which allows variables to persist across
REPL lines since `var` declarations become properties of the global
object in sloppy mode.
This is a temporary solution until we can properly integrate the
AST-based repl_transforms.zig module with the transpiler pipeline.
Co-Authored-By: Claude Opus 4.5 <noreply@anthropic.com>
This implements a new REPL in Zig that replaces the previous bunx-based
REPL. The new REPL provides:
- Interactive line editing with cursor movement and history navigation
- Syntax highlighting using QuickAndDirtyJavaScriptSyntaxHighlighter
- Multi-line input with bracket matching detection
- REPL commands (.help, .exit, .clear, .load, .save, .editor, .timing)
- JavaScript evaluation using the global eval() function
- Pretty-printed output for evaluated expressions
- Support for both TTY (interactive) and non-TTY (piped) input
The REPL properly initializes the JSC VirtualMachine with the API lock
held, enabling safe JavaScript execution. It uses Bun's transpiler
infrastructure and output formatting.
TODO:
- Implement REPL transforms for variable persistence across lines
- Integrate package installation
- Add shell mode integration
- Implement JSC-based autocomplete
Co-Authored-By: Claude Opus 4.5 <noreply@anthropic.com>