<div align="center"> @tty-pt/stele logo </div>

@tty-pt/stele

npm version License: BSD-2-Clause Standards: WebAssembly Reactor

Universal Node.js and Browser bindings for libstele, the zero-dependency system substrate for plain C and isomorphic WebAssembly. Provides high-resolution monotonic clocks, memory diagnostics, the decoupled CapabilityRegistry plug-and-play contract, and the bundled portable mk/ build system. Canonical C headers: <ttypt/stele.h>, <ttypt/iso.h>, <ttypt/iso_json.h>, <ttypt/stl_json.h>, <ttypt/wq.h>, <ttypt/stl_job.h>, and <ttypt/stele_wasm.h>.

๐Ÿ“– Full C & Substrate Documentation: See the main libstele GitHub README for single-allocator shared WASM memory, POSIX/Win32 socket shims, and STL_WASM_MODULE slot lifecycle.


1. Quickstart & Installation

# Primary tty.pt registry (recommended; also mirrored to npmjs.org)
npm config set @tty-pt:registry https://tty.pt/npm/
npm install @tty-pt/stele

Native & Mobile OS Packages (tty.pt): Prebuilt native C packages (libstele) for Linux (apt, apk, pacman, dnf), macOS (brew), Windows (winget, MSYS2), OpenBSD (pkg_add), Android (https://tty.pt/android/), and iOS XCFramework (https://tty.pt/ios/) are available via the tty.pt package repositories.

Usage in modern JavaScript / TypeScript:

import {
  nowMs,
  selfRssBytes,
  CapabilityRegistry,
  WasmSubstrate,
  getSubstrate,
  getSharedWasm
} from "@tty-pt/stele";

// 1. High-Resolution Metrics
console.log(`Current process monotonic time: ${nowMs()} ms`);
console.log(`Resident Set Size (RSS): ${selfRssBytes()} bytes`);

// 2. Capability Registry
const caps = new CapabilityRegistry();
caps.register("audio", (root, wasm) => ({
  play: (url) => console.log("Playing audio:", url)
}));

// 3. WebAssembly Substrate
const substrate = getSubstrate();
console.log("Single-memory substrate initialized:", substrate.memory.buffer.byteLength);

2. JavaScript / TypeScript API Reference

nowMs(): number

Returns a high-resolution monotonic timestamp in milliseconds using the fastest available native clock.

selfRssBytes(): number

Returns the process Resident Set Size (RSS) in bytes.

CapabilityRegistry

Decoupled plug-and-play capability registry mapping feature slots to runtime providers.

WasmSubstrate

Universal single-memory WebAssembly runtime substrate.

getSubstrate(): WasmSubstrate / getSubstrateAsync(): Promise<WasmSubstrate>

Returns the globally shared WasmSubstrate instance, guaranteed to instantiate stele.wasm strictly once per lifecycle with dynamic WebAssembly linear memory growth up to 4 GB.

loadWasmModule(wasmUrl, customImports?) / loadWasmModuleAsync(wasmUrl, customImports?)

Instantiates a downstream WebAssembly module onto the shared WasmSubstrate linear memory with automatic malloc/free and env.memory wiring.

Native Addon & Prebuild Loader (@tty-pt/stele)

Cross-Platform Advisory File Locks (Node-API)

Browser Client Runtime (@tty-pt/stele/client)

SteleWasmClient (dist/client.js / htdocs/stele-client.js) provides the browser-side multi-slot hydration runtime:


3. Isomorphic C Headers & Portable mk/ Build System

@tty-pt/stele ships the canonical C substrate headers (include/ttypt/), stele.pc, and the integrated portable mk/ build system (mk/include.mk, mk/portable.mk, mk/portable-gnu.mk, mk/portable-bsd.mk, mk/service.mk, mk/cx.mk, mk/iso.mk, mk/glfw.mk, mk/ttypt/{include,portable}.mk, mk/wasm_alloc_shim.c, mk/Doxyfile*, mk/scripts/wasm-audit.sh):

When building native Node addons, C libraries, or WebAssembly reactors:

CFLAGS += -I./node_modules/@tty-pt/stele/include
LDLIBS += -lstele
include ./node_modules/@tty-pt/stele/mk/include.mk

System installs (make install on libstele) also install these helpers to share/ttypt/mk/, install Make search-path shims (ttypt/include.mk, ttypt/portable.mk), expose datadir, mk_dir, include_mk, portable_mk, and wasm_includedir in stele.pc, and provide a backward-compatible ttypt-mk.pc.


License

BSD-2-Clause โ€” Copyright (c) 2026, Paulo Quirino <quirinpa@gmail.com>. See LICENSE.

Documentation