npm package discovery and stats viewer.

Discover Tips

  • General search

    [free text search, go nuts!]

  • Package details

    pkg:[package-name]

  • User packages

    @[username]

Sponsor

Optimize Toolset

I’ve always been into building performant and accessible sites, but lately I’ve been taking it extremely seriously. So much so that I’ve been building a tool to help me optimize and monitor the sites that I build to make sure that I’m making an attempt to offer the best experience to those who visit them. If you’re into performant, accessible and SEO friendly sites, you might like it too! You can check it out at Optimize Toolset.

About

Hi, 👋, I’m Ryan Hefner  and I built this site for me, and you! The goal of this site was to provide an easy way for me to check the stats on my npm packages, both for prioritizing issues and updates, and to give me a little kick in the pants to keep up on stuff.

As I was building it, I realized that I was actually using the tool to build the tool, and figured I might as well put this out there and hopefully others will find it to be a fast and useful way to search and browse npm packages as I have.

If you’re interested in other things I’m working on, follow me on Twitter or check out the open source projects I’ve been publishing on GitHub.

I am also working on a Twitter bot for this site to tweet the most popular, newest, random packages from npm. Please follow that account now and it will start sending out packages soon–ish.

Open Software & Tools

This site wouldn’t be possible without the immense generosity and tireless efforts from the people who make contributions to the world and share their work via open source initiatives. Thank you 🙏

© 2026 – Pkg Stats / Ryan Hefner

@skyatnpm/steamworks-js

v0.1.0

Published

Modern Steamworks SDK for Node.js and Electron

Readme

steamworks-js

现代化的 Steamworks SDK for Node.js 和 Electron。

npm version License: MIT

✨ 特性

  • 🎮 完整的 Steamworks API - 覆盖 Steam SDK 所有 21 个模块,327 个方法
  • 📦 预编译二进制 - 无需编译环境,开箱即用
  • 💡 TypeScript 支持 - 完整的类型定义
  • 🖥️ 跨平台 - 支持 Windows、Linux、macOS
  • 多运行环境 - 支持 Node.js 18+ 和 Electron
  • 🔌 模块化架构 - 按需使用各个模块

📦 安装

npm install steamworks-js

🚀 快速开始

import { SteamClient } from 'steamworks-js';

const steam = new SteamClient();

// 初始化 Steam API (480 是 Spacewar 测试 AppID)
const success = await steam.init(480);

if (success) {
    console.log('Steam ID:', steam.user.getSteamId());
    console.log('用户名:', steam.friends.getPersonaName());
    console.log('等级:', steam.user.getPlayerSteamLevel());
}

// 退出时关闭
process.on('exit', () => steam.shutdown());

📚 模块列表

核心模块

| 模块 | 说明 | 示例 | |------|------|------| | client | Steam API 初始化/关闭 | steam.init() | | user | 用户信息 | steam.user.getSteamId() | | friends | 好友系统 | steam.friends.getPersonaName() | | userStats | 成就/统计/排行榜 | steam.userStats.setAchievement() | | utils | 工具函数 | steam.utils.getAppId() | | apps | 应用/DLC 信息 | steam.apps.isDlcInstalled() | | remoteStorage | 云存储 | steam.remoteStorage.fileWrite() |

扩展模块

| 模块 | 说明 | 示例 | |------|------|------| | input | 手柄/控制器 | steam.input.getConnectedControllers() | | matchmaking | 大厅/匹配 | steam.matchmaking.createLobby() | | ugc | 创意工坊 | steam.ugc.getSubscribedItems() | | screenshots | 截图管理 | steam.screenshots.triggerScreenshot() | | inventory | 物品系统 | steam.inventory.getAllItems() | | music | Steam 音乐 | steam.music.play() | | video | 视频/直播 | steam.video.isBroadcasting() | | remotePlay | 远程同乐 | steam.remotePlay.sendInvite() | | parentalSettings | 家长控制 | steam.parentalSettings.isAppBlocked() | | http | HTTP 请求 | steam.http.createHTTPRequest() | | timeline | 时间线 | steam.timeline.addEvent() | | networking | P2P 网络 | steam.networking.sendP2PPacket() | | gameServer | 游戏服务器 | steam.gameServer.logOnAnonymous() | | htmlSurface | HTML 渲染 | steam.htmlSurface.loadURL() |

📖 使用示例

成就系统

// 请求当前用户的统计数据
steam.userStats.requestCurrentStats();

// 解锁成就
steam.userStats.setAchievement('ACH_WIN_100_GAMES');

// 更新成就进度
steam.userStats.indicateAchievementProgress('ACH_TRAVEL', 50, 100);

// 保存到 Steam 服务器
steam.userStats.storeStats();

云存储

// 写入文件
steam.remoteStorage.fileWrite('save.dat', Buffer.from('game data'));

// 读取文件
const data = steam.remoteStorage.fileRead('save.dat');

// 检查云存储配额
const quota = steam.remoteStorage.getQuota();
console.log(`已用: ${quota.used} / ${quota.total}`);

创意工坊

// 获取已订阅的 Mod
const items = steam.ugc.getSubscribedItems();

for (const itemId of items) {
    const info = steam.ugc.getItemInstallInfo(itemId);
    if (info) {
        console.log(`Mod 路径: ${info.folder}`);
    }
}

游戏大厅

import { LobbyType } from 'steamworks-js';

// 创建大厅
const callHandle = steam.matchmaking.createLobby(LobbyType.Public, 8);

// 加入大厅
steam.matchmaking.joinLobby(lobbyId);

// 设置大厅数据
steam.matchmaking.setLobbyData(lobbyId, 'gameMode', 'deathmatch');

// 邀请好友
steam.matchmaking.inviteUserToLobby(lobbyId, friendSteamId);

好友系统

// 获取好友列表
const friendCount = steam.friends.getFriendCount();
for (let i = 0; i < friendCount; i++) {
    const friendId = steam.friends.getFriendByIndex(i);
    const name = steam.friends.getFriendPersonaName(friendId);
    console.log(`好友: ${name}`);
}

// 设置富存在
steam.friends.setRichPresence('status', '在主菜单');
steam.friends.setRichPresence('steam_player_group', lobbyId.toString());

// 打开 Steam 覆盖层
steam.friends.activateGameOverlay('friends');

⚙️ 配置

steam_appid.txt

在项目根目录创建 steam_appid.txt 文件,写入你的 App ID:

480

480 是 Spacewar 测试游戏的 App ID,开发时可以使用。

Electron 配置

// main.js
const { app } = require('electron');
const { SteamClient } = require('steamworks-js');

const steam = new SteamClient();

app.on('ready', async () => {
    await steam.init();
    // ...
});

app.on('quit', () => {
    steam.shutdown();
});

🔧 开发

从源码构建

# 克隆仓库
git clone https://github.com/skyatgit/steamworks-js.git
cd steamworks-js

# 安装依赖
npm install

# 构建原生模块
npm run build:native

# 构建 TypeScript
npm run build

运行测试

npm test

📄 许可证

MIT License

注意: sdk/ 目录包含 Valve 的 Steamworks SDK 文件,其使用受 Steamworks SDK 许可协议 约束。

🔗 相关链接