@seriousgaming/sdk

中文文档
1.6.0发布于 2026/11/02Apache-2.0TypeScriptES Module零依赖

SDK for building Serious Gaming games

原始使用文档

@seriousgaming/sdk

The library a Serious Gaming game imports: the types and helpers for engines, hooks, validators, endpoints and tick controllers, and the React wrappers and hooks for every kind of user interface.

You build, test and run a game with the CLI in @seriousgaming/sdk-tools. Its documentation starts at docs/index.md in that package.

The package is ES modules only: import it. Its exports carry no require condition, so CommonJS tooling that resolves with require.resolve does not find it.

Stability

A version with a prerelease suffix, such as 1.0.0-alpha.1, carries none of these guarantees: it can change in any way before the release it leads to.

From 1.0.0, these subpaths follow semantic versioning. A breaking change to anything they export waits for a major release:

SubpathWhat it holds
.Logic signatures, bundle types, uses callbacks, scheduling builders, seeded randomness, UTF-8 helpers, UndeclaredApiUseError
./uiThe user interface wrappers, their hooks, and the types a surface reads
./ui/testingRender helpers and mocks for testing a surface, including mergingSetData and createMockBrand
./testinglogicArgs, the offline stub callbacks, and createMockTeam, createMockParticipant and their plurals, for calling a logic function directly in a unit test
./projectionThe observable session state the dev server and the CLI report, and PROJECTION_VERSION
./commandsThe command set a client sends the dev server, and what each query answers with

Two things in them are outside that guarantee:

  • Members tagged @internal in their TSDoc, such as the dev server's fault injection (FaultKind, ArmedFault, the armFault and disarmFault commands and the projection's faults). They ship in the declarations, but may change in a minor release
  • The React context objects ./ui exports (UserInterfaceDataContext and the rest of the *Context names). The hooks that read them are covered; providing one directly is not, because a minor release may add a required field to a context's value. Test a surface with the render* helpers in ./ui/testing, which supply every context for you

Adding a field to the projection or to a query's answer is not a breaking change, so a reader should ignore what it does not know. PROJECTION_VERSION changes only with a major release.

./e2e carries no such guarantee. It holds the Playwright helpers for testing a game against the dev server, which track the dev console and so move with sdk-tools.

The host half of the iframe protocol (@seriousgaming/sdk-tools/host) and the runtime helpers (@seriousgaming/sdk-tools/runtime) are not part of this package. They exist for the Serious Gaming platform and the SDK's own tooling, not for games.

Licence

Apache License, Version 2.0. See LICENSE and NOTICE.

版本与发布记录

@seriousgaming/sdk 共发布 12 个版本,首次发布于 2026/10/18;过去 12 个月发布了 12 个版本。

版本发布日期距今
1.6.0latest2026/11/021 天前
1.5.02026/10/295 天前
1.4.02026/10/277 天前
1.3.02026/10/268 天前
1.2.02026/10/268 天前
1.1.02026/10/259 天前

其他发布通道:next → 1.0.0-alpha.4。

关于 @seriousgaming/sdk 的常见问题

@seriousgaming/sdk 是什么?

用于构建严肃游戏的SDK

如何安装 @seriousgaming/sdk?

在项目目录运行 npm install @seriousgaming/sdk,或使用 pnpm add / yarn add / bun add。

@seriousgaming/sdk 支持 TypeScript 吗?

支持。包内自带 TypeScript 类型声明(package.json 声明了 types 入口),安装后即可获得类型提示,无需再安装 @types 包。

@seriousgaming/sdk 支持 ESM 还是 CommonJS?

以 ES Module 形式发布,推荐使用 import 引入。在 CommonJS 项目中,Node.js 20.19+ / 22.12+ 可以直接 require() 不含顶层 await 的 ES Module,更早的版本需要改用动态 import()。

@seriousgaming/sdk 需要什么版本的 Node.js?

package.json 的 engines 字段要求 Node.js >=24。版本不符时 npm 默认只给出警告,开启 engine-strict 后会拒绝安装。

@seriousgaming/sdk 可以商用吗?

@seriousgaming/sdk 使用 Apache-2.0 许可。宽松许可:允许商业使用、修改和再分发,并附带明确的专利授权;分发时需保留许可与 NOTICE 文件,修改过的文件要注明改动。以上为概括,不构成法律意见,请以许可原文为准。

@seriousgaming/sdk 还在维护吗?

最新版本 1.6.0 发布于 2026/11/02(1 天前);至今共发布 12 个版本,其中过去 12 个月发布了 12 个;首次发布于 2026/10/18。发布频率只是参考信号:功能稳定的工具可能很少需要更新,建议结合源码仓库的 issue 和提交记录判断。