knode (com.nexustools.knode) is a pure Kotlin Multiplatform Node.js v20+ runtime, standard module suite, and systems framework spanning JVM, Android, iOS/iPadOS, macOS, Windows, Linux, Browser (JS/Wasm), and Node.js (JS/Wasm).
See ARCHITECTURE.md for the architectural specification and AGENTS.md for engineering rules.
| Layer | KMP Targets | Role |
|---|---|---|
:common |
jvm, android, ios*, macos*, mingwX64, linux*, js, wasmJs |
KNode entry point, KNodePromise<T>, 6-phase KNodeEventLoop, KNodeBuffer, KNodeEventEmitter, KNodeProcess, KNodeException, module APIs, KNodeModuleRegistry, KNodeDynamicLibraryLoader |
:system |
jvm, android, ios*, macos*, mingwX64, linux* |
Shared OS runtime, KNodeIoDispatcher, pure-Kotlin zlib, HTTP/1.1 + HTTP/2 + HPACK, RFC 1035 DNS |
:jvm |
jvm, android |
Plain headless JVM runtime (jvmOnlyMain JDK 11+, jvmSharedMain API 24+), NIO2/JCA, Class.forName loader (zero java.awt/javax.swing) |
:apple |
macosArm64, macosX64, iosArm64, iosSimulatorArm64 |
Darwin Foundation/GCD timers, dlopen/dlsym loader, shared Apple OS hooks |
:desktop |
jvm, mingwX64, linuxX64, linuxArm64, macosArm64, macosX64 |
Win32 IOCP/LoadLibraryW, Linux epoll/dlopen, macOS desktop runtime |
:mobile |
android, iosArm64, iosSimulatorArm64 |
Android Context/SAF/FileObserver/DnsResolver, iOS sandbox & NWPathMonitor |
:web |
js { browser() }, wasmJs { browser() } |
1:1 Web APIs (fetch, URL, WebStreams, crypto.subtle, OPFS/FSA, WebSocket, CompressionStream) |
:nodejs |
js { nodejs() }, wasmJs { nodejs() } |
1:1 lazy process.getBuiltinModule("node:*") / require("node:*") delegation (@JsFun WasmJs-safe) |
- 35 Built-In
:modules:*Subprojects:fs,path,os,stream,net,tls,dgram,dns,http,https,http2,crypto,zlib,url,querystring,punycode,util,string-decoder,assert,timers,console,tty,child-process,worker-threads,cluster,readline,perf-hooks,async-hooks,diagnostics-channel,vm,v8,inspector,module,fetch,webstreams.- Consumer apps opt in only to required modules and load them immediately (
lazyLoadModules = falsedefault). - NJS's NodeJS mode enables
all()withlazyLoadModules = truesoknode-mod-<mod>.dll/.so/.dylibload dynamically onrequire("node:*")/require("fs"). - Blocking TCP accept/read/write loops in
:modules:netrun onnetBlockingDispatcher(Dispatchers.IOon JVM/Android/Native,Dispatchers.Defaulton JS/Wasm) to avoid starvingDispatchers.Default.
- Consumer apps opt in only to required modules and load them immediately (
- 8 First-Party
:extensions:*Families::extensions:binarycodecs—ByteBuffer,@BinarySerializable,BinaryJson,BinaryPlist:extensions:ipc— Named Pipes w/ DACL,AF_UNIXw/SO_PEERCRED, macOS XPC, JDK FFM, Android Binder,:nodejspipes, FD passing, lock-free SPSC SHM rings:extensions:htmlparser—htmlparser2-compatible streaming HTML5/XML parser:extensions:websockets:{common,client,server}— RFC 6455 / RFC 7692 WebSockets:extensions:socket.io:{common,client,server}— Engine.IO v4 + Socket.IO v4:extensions:ftp:{common,client,server}— FTP / FTPS client and server:extensions:mail:{common,smtp,imap,pop3}— SMTP, IMAP4, and POP3 clients/servers:extensions:mysql— Async MySQL 8 / MariaDB wire client and pool
Apply the Gradle plugin (com.nexustools.knode) in a consumer project and opt in to only the backends, built-in Node.js modules, and extensions your app requires:
plugins {
kotlin("multiplatform")
id("com.nexustools.knode")
}
knode {
app {
appId = "com.example.service"
baseName = "exampleService"
}
backends {
jvm()
windows()
linux()
macos()
}
modules {
fs()
path()
http()
https()
crypto()
// lazyLoadModules = false (default: immediate load & link of opted-in modules)
}
extensions {
binaryCodecs()
ipc()
websockets(includeServer = true)
}
}Run all multiplatform tests via root :jest (zero JUnit):
./gradlew kjestTestRun upstream Node.js conformance suites against NJS + knode:
./gradlew :conformance:nodejs-suite:runNodejsTier1Conformance- Core Modules & Event Loop — 35 built-in Node.js modules,
KNodePromise<T>, 6-phaseKNodeEventLoop,:web&:nodejs1:1 mappings, andnetBlockingDispatcher. - Lazy Shared Libraries —
knode.*,knode-mod-<mod>.*,knode-ext-<ext>.*,knode-jest.*, consumer immediate loading vs. NJSlazyLoadModules = true. - IPC Extension — Cross-platform IPC transports, FD passing, lock-free SHM rings, and migration from GenericUI's old
:extensions:ipc. - Extensions — Detailed guide to all 8
:extensions:*families (binarycodecs,ipc,htmlparser,websockets,socket.io,ftp,mail,mysql). - Jest Testing Framework —
:jest:core,:jest:cli,:jest:gradle-plugin, matchers, async.resolves/.rejects, mocks, fake timers, snapshots, and reporters (zero JUnit). - Node.js Conformance Suite —
:conformance:nodejs-suiterunning upstreamextern/node/testsuites against NJS +knode. - Gradle Plugin & SPI —
KNodeGradlePlugin,KNodeSettingsPlugin,KNodeNativeSharedLibraryCatalog,KNodeExtensionContributor, and DSL reference. - IntelliJ IDEA Plugin — Open
:idea-pluginproject wizard, target/module manager, and extension hooks used by GenericUI.