How dustinlacewell/steamworks-ts works
Project type and purpose
• This is a language‐binding library: a NodeJS package (“steamworks-ts”) that provides TypeScript‐typed bindings to Valve’s Steamworks SDK.
• It’s built in Rust (via the steamworks-rs crate) and exposed to NodeJS through the N-API using napi-rs. Consumers call into the native addon from JavaScript/TypeScript.
File structure
Top-level:
• Cargo.toml, build.rs, src/… → Rust code defining the Steamworks wrapper
• index.js, index.d.ts → JS/TS entry points to the compiled native addon
• npm/… → folder of prebuilt binaries per platform (darwin, linux, win32)
• bin/build.ts → custom build script to orchestrate the Rust → .node build and packaging
• app/… and examples/… → sample TypeScript apps showing how to use the module
• .github/workflows → CI pipelines for build & docs
README for additional insights
• Confirms that you need Rust+NodeJS toolchains
• Describes build command producing steamworks-ts.<platform>-<arch>.node
• Mentions Steam’s steam_appid.txt mechanism, external dependency to the Steam client
Main components & interactions
a. Rust Library Layer
• src/lib.rs plus submodules (friends.rs, ugc/...)
• Depends on steamworks-rs (external crate binding to Steamworks SDK)
b. Build & N-API Layer
• build.rs and napi-rs code glue that compiles Rust to a .node addon
• bin/build.ts orchestrates cross-platform builds and packaging into npm/… directories
c. NodeJS Module Interface
• index.js (CommonJS wrapper)
• index.d.ts (TypeScript definitions)
d. Distribution Artifacts
• Prebuilt binaries under npm/darwin-x64, linux-x64-gnu, win32-x64-msvc
• Published to NPM as @ldlework/steamworks-ts
e. Consumer Code
• Example apps under app/ and examples/
• They import SteamClient from the package and invoke Steamworks API methods
f. External Dependencies
• Steamworks SDK dynamic libs (.dll, .dylib) loaded at runtime
• The Steam client (via steam_appid.txt)
Architectural patterns & design principles
• Layered architecture:
1. Native Rust layer (interfaces Steamworks SDK)
2. N-API binding layer (napi-rs)
3. JavaScript API surface (index.js + .d.ts)
4. Consumer layer (TS/JS apps)
• Packaging/multi-target distribution: precompilation per platform
• Separation of concerns: Rust modules for feature areas (friends, ugc, errors)
Detail
• CI workflows (build.yml, docs.yml) optionally as external automation
• steam_appid.txt file creation and warning path in examples