@tty-pt/xylem
Universal Node.js and Browser bindings forlibxylem, the extensible C module bus and dynamic hook dispatch runtime. Canonical C headers:<ttypt/xy.h>and<ttypt/xy-mod.h>.
๐ Full C & Module Bus Documentation: See the main libxylem GitHub README for XY_DECL / XY_IMPL cross-.so symbol contracts, xy_load() DAG resolution, and hook dispatch.
1. Quickstart & Installation
npm config set @tty-pt:registry https://tty.pt/npm/
npm install @tty-pt/xylem
Native OS & Mobile Packages (tty.pt): Prebuilt native C packages (libxylem) for Linux (apt, apk, pacman, dnf), macOS (brew), Windows (winget, MSYS2), OpenBSD (pkg_add), plus static mobile sysroots for Android (https://tty.pt/android/) and iOS (https://tty.pt/ios/ โ libxylem.xcframework, supporting XY_STATIC_MOD and xy_load_mem()) are available via the tty.pt package repositories.
import { XylemBus, areg, call } from "@tty-pt/xylem";
// 1. Register a dynamic hook listener
const unregister = areg("on_event", (payload) => {
console.log("Received event payload:", payload);
return { status: "processed" };
});
// 2. Dispatch event across registered listeners
const results = call("on_event", { userId: 101, action: "login" });
console.log("Hook return values:", results);
unregister();
2. JavaScript / TypeScript API Reference
XylemBus
Dynamic module hook and lifecycle event bus.
constructor(): Initializes an isolated event bus..register(name: string, listener: Function): () => boolean: Registers hook and returns unsubscribe function. Automatically registers into compiledxylem.wasmviaxy_areg()..call(name: string, ...args: any[]): any[]: Dispatches hook sequentially, collecting return values..has(name: string): boolean: Checks if any listeners are registered for hook..unregister(name: string, listener: Function): boolean: Unregisters specific listener..list(): string[]: Lists all registered hook names.
Standalone Functions & Capability Bridge
areg(name: string, listener: Function): () => boolean: Registers listener on the global default bus.call(name: string, ...args: any[]): any[]: Dispatches hook on the global default bus.createXylemBridge(options?)(@tty-pt/xylem/bridge): Registers Web HALxy_*hook dispatch imports on a SteleCapabilityRegistryor WASM environment.getXylemWasm(): WebAssembly.Instance: Returns the WebAssembly instance loaded on the Stele shared-memory substrate.version(): string: Returns the library semantic version string.
3. C Development Headers & Native Integration
CFLAGS += -I./node_modules/@tty-pt/xylem/include
LDLIBS += -lxylem
License
BSD-2-Clause โ Copyright (c) 2026, Paulo Quirino <quirinpa@gmail.com>. See LICENSE.