chore: implement xtermjs API#54
Merged
Merged
Conversation
- Make terminal.options public and mutable with Proxy interception - Make open() synchronous (WASM pre-loads in constructor) - Add windowsMode and allowProposedApi options for xterm.js compatibility - Add unicode.activeVersion property - Add onReady event that fires immediately for late subscribers - Implement event-based FitAddon auto-retry (no timers) - Add write queueing for data sent before WASM loads - Support runtime option changes (disableStdin, windowsMode, etc) - Fix: setupTerminal uses this.cols/rows instead of options.cols/rows Breaking changes: - open() is now synchronous (remove await keyword) - options is now public (was private) - WASM loading starts in constructor (slight startup cost) This enables true zero-friction migration from xterm.js - just change the import statement and all existing code works unchanged. Includes comprehensive test suite (18 xterm.js compatibility tests). Fixes resize issue where PTY was created before FitAddon could update terminal dimensions. Now term.cols/rows are used when creating WASM terminal, ensuring correct initial size.
- Add 15 new tests in lib/new-features.test.ts - Tests cover: onReady event, write queueing, FitAddon auto-retry, runtime option propagation, WASM pre-loading, initial sizing - Add FEATURES_TESTING_GUIDE.md documenting all 11 features and their tests - Total test coverage: 33 tests for all new functionality
- Add public options, unicode, onReady, write queueing tests to lib/terminal.test.ts - Add FitAddon onReady auto-retry tests to lib/addons/fit.test.ts - Remove standalone test files (xterm-compat.test.ts, new-features.test.ts) - All new features now have unit test coverage in appropriate files
Add comprehensive functional tests that verify actual behavior: Terminal tests (21 new tests): - disableStdin: Verifies paste/input are blocked when enabled, can toggle at runtime - onReady event: Fires after WASM loads, late subscribers fire immediately, multiple subscribers all receive event, wasmTerm is available - Write queueing: Writes before ready are queued and processed, callbacks work - Synchronous open(): Returns immediately, element/cols/rows available, FitAddon can update dimensions before ready FitAddon tests (6 new tests): - onReady subscription: Subscribes during activation, calls fit() when ready - Resource cleanup: Disposes subscription on dispose - Dimension calculation: Correct cols/rows including scrollbar space These tests verify functionality rather than just checking property values.
The synchronous open() API change requires tests to explicitly wait for WASM to be ready before accessing wasmTerm or WASM-dependent features. Changes: - Add openAndWaitForReady() helper to terminal.test.ts, buffer.test.ts, and scrolling.test.ts - Update 68 tests in terminal.test.ts to use the helper - Update 4 tests in scrolling.test.ts to use the helper - Update 1 test in buffer.test.ts to use the helper - Fix 'cannot open twice' and 'cannot open after disposal' tests to use synchronous throw assertions (open() now throws synchronously) All 268 tests now pass.
Remove non-functional xterm.js compatibility options: - Remove allowProposedApi (was no-op, no APIs to gate) - Remove windowsMode (affects buffer reflow, not implementable without WASM changes) Add functional tests for Options Proxy handleOptionChange: - Test cursorStyle change updates renderer.cursorStyle - Test cursorBlink change starts/stops blink timer - Test cols/rows change triggers resize event - Test options can be changed before terminal is open Add functional tests for disableStdin with real keyboard events: - Test blocks real KeyboardEvent when disableStdin is true - Test allows real KeyboardEvent when disableStdin is false - Test keyboard blocked after runtime toggle to disableStdin=true All 273 tests pass.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
No description provided.