smoltcpjs
v0.2.1
Published
Userland IPv6 network stack in WebAssembly via smoltcp.
Downloads
131
Maintainers
Readme
smoltcpjs
A wasm-bindgen build of the smoltcp 0.13 IP stack, targeting WebAssembly. It exposes a Stack API over IPv6: raw L3 frame I/O, TCP, UDP, ICMPv6 echo, raw IPv6 sockets, and topic multicast (see COVERAGE.md for the full matrix).
Installers get prebuilt .js and .wasm; no Rust toolchain is required at runtime.
Use from npm
npm install smoltcpjsimport init, { Stack } from 'smoltcpjs'
await init() // or init({ module_or_path: new URL('smoltcpjs_bg.wasm', import.meta.url) }) in some bundlers
const stack = new Stack('2001:db8::1')
// … see COVERAGE.md and the published TypeScript typesinit()loads the WebAssembly (wasm-bindgen default). Your bundler may need an explicitmodule_or_pathto thesmoltcpjs_bg.wasmfile next to the JS; check your bundler’s WASM docs.- The package is ESM (
"type": "module"). Useimport, notrequire(or usecreateRequirein Node if you must). - Invalid IPv6 in
new Stack(…)throws; catch or validate the string first.
Developing this package
To change Rust code or wasm-pack output you need the Rust wasm target, wasm-pack, and dependencies as resolved by cargo (see Cargo.toml):
rustup target add wasm32-unknown-unknownnpm install(forwasm-packas a dev dependency) or a globalwasm-packinstall
npm run buildThe web build is written to pkg/. A Node-target build can be produced with npm run build:node (outputs to pkg-node/, not published in the main npm files set).
npm testRebuilds wasm and runs the tests in test/.
Release checklist (npm)
- Bump version in package.json and Cargo.toml together.
npm test(rebuilds wasm and runs test/smoltcpjs.test.mjs).- Dry-run the published tarball:
npm pack --dry-runand confirmpkg/*.wasmandpkg/*.jsare listed. npm login(once) thennpm publish(use--access publiconly if the package name were scoped and needed).
prepack runs npm run build, so npm pack and npm publish both build wasm first even if pkg/ is not committed (it is usually gitignored).
License
0BSD (see the license field in package.json).
