Overview
@rezi-ui/native is the native addon layer that provides Rust-based rendering engine bindings for Rezi. It uses:
- napi-rs for Node.js N-API bindings
- Zireael engine for high-performance terminal rendering
- Pre-built binaries for major platforms
Installation
- Linux: x64, arm64, armv7
- macOS: x64 (Intel), arm64 (Apple Silicon)
- Windows: x64
What It Provides
The native addon exposes low-level engine functions:Engine Initialization
- Terminal capability detection
- Raw mode entry/exit
- Viewport size queries
Frame Rendering
- ZRDL (Zireael Drawlist) binary protocol parsing
- SGR sequence generation
- Cursor positioning
- Synchronized output (DEC SM 2026)
Event Handling
- Key event parsing (ANSI escape sequences)
- Mouse event parsing (SGR 1006 protocol)
- ZREV (Zireael Event) binary batch encoding
Platform I/O
- Non-blocking terminal reads
- Signal handling (SIGWINCH for resize)
- Output backpressure management
Architecture
The native addon is used by@rezi-ui/node in a worker thread architecture:
Building from Source
Only needed if pre-built binaries aren’t available for your platform.
Prerequisites
- Rust: 1.70 or higher
- Node.js: 18 or higher
- Build tools:
- Linux:
gcc,make - macOS: Xcode Command Line Tools
- Windows: Visual Studio Build Tools
- Linux:
Build Steps
cargo build --releasefor the Rust addonnapi-rsto generate Node.js bindings- Copies
.nodebinary to package root
Platform Support
Tier 1 (Pre-built + Tested)
- Linux x64
- macOS x64 (Intel)
- macOS arm64 (Apple Silicon)
Tier 2 (Pre-built)
- Linux arm64
- Linux armv7
- Windows x64
Tier 3 (Build from Source)
- FreeBSD
- Other Unix-like systems
Version Compatibility
The native addon exposes an ABI (Application Binary Interface) version:- Major version mismatch: Fatal error, cannot run
- Minor version mismatch: Warning, may have missing features
- Patch version mismatch: No warning, fully compatible
Debugging
Enable Native Logs
Check Binary Loading
Smoke Test
Engine Capabilities
The Zireael engine provides:ZRDL Protocol
- v1: Legacy protocol (deprecated)
- v3: Stable protocol with shadow and scrollbar support
- v5: Latest protocol with additional optimizations
Terminal Features
- Color modes: 16-color, 256-color, 24-bit RGB
- Mouse protocols: SGR 1006, UTF-8 extended
- Cursor shapes: Block, underline, bar
- Synchronized output: DEC SM 2026 for flicker-free rendering
- Hyperlinks: OSC 8 terminal hyperlinks
- Clipboard: OSC 52 clipboard access
Performance
- Zero-copy frame submission via SharedArrayBuffer (optional)
- Vectorized text measurement
- Incremental damage tracking
- Backpressure-aware output
Security
The native addon is sandboxed by Node.js N-API:- No direct file system access (except stdin/stdout/stderr)
- No network access
- No arbitrary code execution
- Memory-safe Rust implementation
Troubleshooting
”Cannot find module ‘@rezi-ui/native’”
Cause: Pre-built binary not available for your platform. Solution: Build from source:“Engine ABI version mismatch”
Cause:@rezi-ui/core and @rezi-ui/native versions don’t match.
Solution: Ensure all @rezi-ui/* packages have the same version:
“Symbol not found” on macOS
Cause: Binary built for wrong architecture. Solution: Rebuild for your architecture:Related Documentation
@rezi-ui/node
Node.js backend using native addon
Custom Backends
Implementing custom backends
Architecture
Worker thread architecture
ZRDL Protocol
Drawlist binary format