Skip to content

Conversation

@sinelaw
Copy link
Owner

@sinelaw sinelaw commented Dec 31, 2025

Comprehensive design for running Fresh editor in browsers via WebAssembly:

  • Custom HtmlBackend implementing ratatui's Backend trait
  • Browser event adapter converting KeyboardEvent/MouseEvent to crossterm format
  • WASM entry point with wasm-bindgen exports
  • JavaScript/HTML host with event handling and resize support
  • WasmFsBackend for in-memory/IndexedDB filesystem
  • Phased implementation plan with deliverables
  • Alternative approaches analysis (Ratzilla, egui_ratatui, Canvas)

@sinelaw sinelaw force-pushed the claude/wasm-browser-editor-0swAA branch from 5734197 to 0be2c53 Compare January 4, 2026 23:22
claude added 2 commits January 5, 2026 17:19
Code reorganization to improve modularity:

- Extract Action and KeyContext types from keybindings.rs to action.rs
- Move CursorId from event.rs to cursor.rs
- Add FileSystem trait for abstracting file I/O operations
- Refactor Buffer to use FileSystem trait for portability
- Add GrammarStore injection to GrammarRegistry for flexibility
- Refactor HighlightEngine for better separation of concerns
- Extract shared Language enum from highlighter.rs
- Extend FsBackend trait with additional operations
- Improve theme portability
Add WebAssembly support for running Fresh in browsers:

- Add WASM feature flag and dependencies (ratzilla, syntect, wasm-bindgen)
- Add syntect-based syntax highlighter for WASM builds
- Add TextContentProvider trait for shared rendering
- Add WASM module with browser integration via Ratzilla
- Add virtual filesystem backend for browser environment
- Add event adapter for browser keyboard/mouse events
- Add web assets (styles.css) for browser UI
- Add build scripts (wasm-build.sh, wasm-setup.sh)
- Configure module gating for WASM-compatible vs runtime-only code
- Add comprehensive design documentation

Modules ungated for WASM:
- input: action, command_registry, commands, fuzzy, input_history, position_history
- view: margin, overlay, virtual_text, scroll_sync, text_content, theme, markdown
- primitives: highlight_engine, line_iterator, snippet, text_property, word_navigation
- model: buffer, cursor, event, marker, marker_tree, overlay, piece_tree, filesystem
@sinelaw sinelaw force-pushed the claude/wasm-browser-editor-0swAA branch from 9639234 to e1bd765 Compare January 5, 2026 17:20
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants