@stringke/game-framework-core
Web 优先、可扩展桌面(kxed-tauri)与移动端(Capacitor / Tauri 2 Mobile)的通用前端游戏框架核心库。基于 solid-js 纯响应式内核构建,零 DOM 硬依赖,零具体游戏玩法耦合,原生适配 60 / 90 / 120 fps。
安装#
配置 GitHub Packages scope(.npmrc):
@stringke:registry=https://npm.pkg.github.com安装依赖:
npm install @stringke/game-framework-core solid-js核心模块#
| 模块 | 主要导出 | 说明 |
|---|---|---|
| 主时钟 | MasterClock, createMasterClock, QualityTier | 单一主时钟,按秒数 dt 驱动 60/90/120fps 一致流速;内置 FPS 采样与画质档位自适应降级、切后台自动挂起及 dt 钳位 |
| 高精度金额 | Money, RoundingMode, CurrencyFormatOptions | 基于 bigint 最小单位整数运算,零浮点误差,支持 toWireString() / fromWire() / fromMajor() 与多币种本地化格式化 |
| 分轨音控 | AudioController, createAudioController, AudioBackendAdapter | bgm / sfx / voice 三轨音量与静音 Solid Store、可插拔播放后端、首次手势解锁状态机、切后台自动静音恢复 |
| 国际化 | createI18n, I18nInstance, TextDirection | 响应式多语言词典、占位符插值、语言动态切换与 isRtl / direction 方向信号 |
| 状态机 | createStateMachine, StateMachine | 轻量前端有限状态机,支持同步/异步守卫、防重入保护、Solid Signal 状态与生命周期钩子 |
| 平台适配 | detectPlatform, createPlatformAdapter, PlatformAdapter | 统一探测 Web / iframe / kxed-tauri / Capacitor 运行环境,抽象安全区与可见性监听 |
| 连接与时钟 | GameConnection, createGameConnection, RpcTransport | 对接 kxed-rpc.ts 的传输抽象,维护连接态 Signal、服务端时钟偏移 serverNow() 与断线重连恢复钩子 |
开发命令#
npm install
npm run typecheck
npm run test
npm run build