Standardize settings file naming and relocate documentation files Fix code quality violations from rsx:check Reorganize user_management directory into logical subdirectories Move Quill Bundle to core and align with Tom Select pattern Simplify Site Settings page to focus on core site information Complete Phase 5: Multi-tenant authentication with login flow and site selection Add route query parameter rule and synchronize filename validation logic Fix critical bug in UpdateNpmCommand causing missing JavaScript stubs Implement filename convention rule and resolve VS Code auto-rename conflict Implement js-sanitizer RPC server to eliminate 900+ Node.js process spawns Implement RPC server architecture for JavaScript parsing WIP: Add RPC server infrastructure for JS parsing (partial implementation) Update jqhtml terminology from destroy to stop, fix datagrid DOM preservation Add JQHTML-CLASS-01 rule and fix redundant class names Improve code quality rules and resolve violations Remove legacy fatal error format in favor of unified 'fatal' error type Filter internal keys from window.rsxapp output Update button styling and comprehensive form/modal documentation Add conditional fly-in animation for modals Fix non-deterministic bundle compilation 🤖 Generated with [Claude Code](https://claude.com/claude-code) Co-Authored-By: Claude <noreply@anthropic.com>
3.7 KiB
Executable File
3.7 KiB
Executable File
JavaScript Core Systems - RPC Server Architecture
Overview
JavaScript parsing and transformation use long-running Node.js RPC servers via Unix sockets to avoid spawning 1000+ Node processes during builds.
JS Parser - RPC Server
Components
Js_Parser.php- PHP client, manages parser server lifecyclejs-parser-server.js- Node.js RPC server, processes batch parse requestsjs-parser.js- Legacy single-file parser (kept for compatibility)
Server Lifecycle
- Lazy start: Server spawns on first JS file parse during manifest build
- Startup: Checks for stale socket, force-kills if found, starts fresh server
- Wait: Polls socket with ping (50ms intervals, 10s max), fatal error if timeout
- Usage: All JS parsing during build goes through RPC (batched when possible)
- Shutdown: Graceful shutdown on manifest build completion (registered shutdown handler)
Socket
- Path:
storage/rsx-tmp/js-parser-server.sock - Protocol: Line-delimited JSON over Unix domain socket
RPC Methods
ping→"pong"- Health checkparse→{file: result, ...}- Batch parse multiple filesshutdown→ Graceful server termination
PHP API
Js_Parser::start_rpc_server(); // Lazy init, auto-called
Js_Parser::stop_rpc_server($force); // Clean shutdown
Js_Parser::parse_via_rpc($files); // Batch parse (future)
JS Transformer (Babel) - RPC Server
Components
Js_Transformer.php- PHP client, manages transformer server lifecyclejs-transformer-server.js- Node.js RPC server, processes batch Babel transformationsjs-transformer.js- Legacy single-file transformer (kept for compatibility)
Server Lifecycle
- Lazy start: Server spawns on first JS transformation during bundle compilation
- Startup: Checks for stale socket, force-kills if found, starts fresh server
- Wait: Polls socket with ping (50ms intervals, 10s max), fatal error if timeout
- Usage: All JS transformations during bundle builds go through RPC
- Shutdown: Graceful shutdown when bundle compilation completes (registered shutdown handler)
Socket
- Path:
storage/rsx-tmp/js-transformer-server.sock - Protocol: Line-delimited JSON over Unix domain socket
RPC Methods
ping→"pong"- Health checktransform→{file: {status, result, hash}, ...}- Batch transform multiple filesshutdown→ Graceful server termination
PHP API
Js_Transformer::start_rpc_server(); // Lazy init, auto-called
Js_Transformer::stop_rpc_server($force); // Clean shutdown
Js_Transformer::_transform_via_rpc(...); // Internal RPC transformation
Transformation Details
- Preprocesses
@decoratoron standalone functions - Applies Babel transformations: decorators, class properties, optional chaining, nullish coalescing
- Prefixes generated helper functions with file hash to prevent namespace collisions
- Uses target presets:
modern,es6,es5 - Generates inline source maps for debugging
Common RPC Pattern
Force Parameter
stop_rpc_server($force = false):
false(default): Send shutdown command, return immediatelytrue: Send shutdown + wait + SIGTERM if needed (used for stale server cleanup)
Cache Integration
Cache checked before RPC call - only uncached files sent to server for processing.
Error Handling
Server failure → fatal error (no fallback). Server must start or build/compilation fails.
Performance Impact
Before RPC: N Node.js process spawns (where N = number of files needing processing) After RPC: Single persistent Node.js process per server type (~1-2s startup overhead)
Future: Other RPC Servers
This pattern is reusable for other expensive Node operations. See implementation guide in project summary.