- Multi-architecture Docker image (ARM64 + AMD64) - Kubernetes manifests for 3-replica deployment - Traefik ingress configuration - NGINX Proxy Manager integration - ConfigMap-based configuration - Automated build and deployment scripts - Session monitoring tools
4.7 KiB
xterm.js Upgrade Summary
Upgrade Complete ✅
Successfully upgraded xterm.js from version 3.14.5 to version 5.5.0.
What Was Done
1. Updated npm Dependencies
- Replaced
xterm: ^3.14.5with@xterm/xterm: ^5.3.0 - Added
@xterm/addon-fit: ^0.10.0 - Note: npm installed version 5.5.0 (latest stable)
2. Created Modern Terminado Addon
File: static/terminado-addon.js
A custom addon implementing the modern ITerminalAddon interface that handles the Terminado WebSocket protocol. This replaced the legacy v3.x addon system.
Key Features:
- Bidirectional WebSocket communication
- Automatic terminal resize handling
- Buffered output for better performance
- Clean lifecycle management (activate/dispose)
- Public API:
attach(),detach(),sendSize(),sendCommand()
3. Updated HTML Template
File: templates/term.html
- Changed script paths to new package locations
- Replaced
Terminal.applyAddon()withterm.loadAddon() - Updated addon instantiation to use new class-based API
- Modernized JavaScript code structure
4. No Rust Changes Required
The Rust backend (src/server.rs, src/lib.rs, src/terminado.rs) works without modification because the Terminado protocol and WebSocket implementation remain the same.
Key Differences Between v3.x and v5.x
| Aspect | v3.14.5 (Old) | v5.5.0 (New) |
|---|---|---|
| Package Name | xterm |
@xterm/xterm |
| Addon System | Terminal.applyAddon() |
term.loadAddon() |
| Addon Location | /dist/addons/*/ |
Separate npm packages |
| Fit Method | term.fit() |
fitAddon.fit() |
| CSS Path | /dist/xterm.css |
/css/xterm.css |
| JS Path | /dist/xterm.js |
/lib/xterm.js |
Testing
Verify Installation
# Check installed versions
cat node_modules/@xterm/xterm/package.json | grep version
cat node_modules/@xterm/addon-fit/package.json | grep version
Run the Server
cargo build
cargo run
Access the Terminal
Open http://localhost:8082/ in your browser
Expected Behavior
- Terminal loads and displays correctly
- Terminal fits to container size
- WebSocket connects successfully
- socktop command launches automatically
- Typing works in the terminal
- Window resize updates terminal size
Files Modified
- ✏️
package.json- Updated dependencies - ✏️
templates/term.html- Updated to use v5.x API - ✨
static/terminado-addon.js- New custom addon (copied tonode_modules/) - ✨
test_xterm.html- Test page for verification - ✨
XTERM_UPGRADE.md- Detailed upgrade documentation - ✨
UPGRADE_SUMMARY.md- This file
Benefits of Upgrading
✅ Security: Latest patches and security updates
✅ Performance: Improved rendering and memory management
✅ Maintainability: Cleaner, modern API design
✅ Features: Access to all features added since v3.x
✅ Support: Active development and community support
✅ Compatibility: Better TypeScript and modern browser support
Next Steps
Immediate
The upgrade is complete and working. You can now:
- Test with your socktop application
- Customize the terminal appearance
- Add additional features
Future Enhancements
Consider adding these xterm addons:
@xterm/addon-search- Search within terminal output@xterm/addon-web-links- Make URLs clickable@xterm/addon-webgl- Hardware-accelerated rendering@xterm/addon-unicode11- Full Unicode 11 support
Troubleshooting
If JavaScript console shows errors:
- Check that all files are being served (check browser Network tab)
- Verify paths in
templates/term.htmlmatch file locations - Ensure
terminado-addon.jsis innode_modules/
If terminal doesn't display:
- Check WebSocket connection in browser DevTools
- Verify Rust server is running on port 8082
- Check server logs for errors
If terminal doesn't fit properly:
- Ensure FitAddon is loaded before calling
fit() - Check that container has non-zero dimensions
- Verify CSS is loading correctly
Resources
- xterm.js Documentation: https://xtermjs.org/
- GitHub Repository: https://github.com/xtermjs/xterm.js
- Detailed Upgrade Doc: See
XTERM_UPGRADE.mdin this directory - Test Page: Open
test_xterm.htmlin browser (via web server)
Questions or Issues?
If you encounter any problems:
- Check the browser console for JavaScript errors
- Review the server logs for backend issues
- Verify all npm packages are installed:
npm install - Ensure
terminado-addon.jsis accessible at/static/terminado-addon.js
Status: ✅ Upgrade Complete and Working
Date: 2024
Upgraded By: xterm.js upgrade process
Tested: ✅ Compiles, ✅ Runs, ✅ Loads resources, ✅ Terminal displays