Files
esengine/.changeset/rpc-network-migration.md
YHH 7940f581a6 feat(rpc,network): 新增 RPC 库并迁移网络模块 (#364)
* feat(rpc,network): 新增 RPC 库并迁移网络模块

## @esengine/rpc (新增)
- 新增类型安全的 RPC 库,支持 WebSocket 通信
- 新增 RpcClient 类:connect/disconnect, call/send/on/off/once 方法
- 新增 RpcServer 类:Node.js WebSocket 服务端
- 新增编解码系统:支持 JSON 和 MessagePack
- 新增 TextEncoder/TextDecoder polyfill,兼容微信小游戏平台
- 新增 WebSocketAdapter 接口,支持跨平台 WebSocket 抽象

## @esengine/network (重构)
- 重构 NetworkService:拆分为 RpcService 基类和 GameNetworkService
- 新增 gameProtocol:类型安全的 API 和消息定义
- 新增类型安全便捷方法:sendInput(), onSync(), onSpawn(), onDespawn()
- 更新 NetworkPlugin 使用新的服务架构
- 移除 TSRPC 依赖,改用 @esengine/rpc

## 文档
- 新增 RPC 模块文档(中英文)
- 更新 Network 模块文档(中英文)
- 更新侧边栏导航

* fix(network,cli): 修复 CI 构建和更新 CLI 适配器

## 修复
- 在 tsconfig.build.json 添加 rpc 引用,修复类型声明生成

## CLI 更新
- 更新 nodejs 适配器使用新的 @esengine/rpc
- 生成的服务器代码使用 RpcServer 替代旧的 GameServer
- 添加 ws 和 @types/ws 依赖
- 更新 README 模板中的客户端连接示例

* chore: 添加 CLI changeset

* fix(ci): add @esengine/rpc to build and check scripts

- Add rpc package to CI build step (must build before network)
- Add rpc to type-check:framework, lint:framework, test:ci:framework

* fix(rpc,network): fix tsconfig for declaration generation

- Remove composite mode from rpc (not needed, causes CI issues)
- Remove rpc from network project references (resolves via node_modules)
- Remove unused references from network tsconfig.build.json
2025-12-28 10:54:51 +08:00

60 lines
2.1 KiB
Markdown
Raw Blame History

This file contains ambiguous Unicode characters
This file contains Unicode characters that might be confused with other characters. If you think that this is intentional, you can safely ignore this warning. Use the Escape button to reveal them.
---
"@esengine/rpc": minor
"@esengine/network": minor
"@esengine/cli": minor
---
## @esengine/rpc
### 新增 | Added
- 新增类型安全的 RPC 库,支持 WebSocket 通信
- 新增 `RpcClient`connect/disconnect, call/send/on/off/once 方法
- 新增 `RpcServer`Node.js WebSocket 服务端
- 新增编解码系统:支持 JSON 和 MessagePack
- 新增 TextEncoder/TextDecoder polyfill兼容微信小游戏平台
- 新增 WebSocketAdapter 接口,支持跨平台 WebSocket 抽象
---
- Add type-safe RPC library with WebSocket support
- Add `RpcClient` class with connect/disconnect, call/send/on/off/once methods
- Add `RpcServer` class for Node.js WebSocket server
- Add codec system with JSON and MessagePack support
- Add TextEncoder/TextDecoder polyfill for WeChat platform compatibility
- Add WebSocketAdapter interface for cross-platform WebSocket abstraction
## @esengine/network
### 变更 | Changed
- 重构 NetworkService拆分为 `RpcService<P>` 基类和 `GameNetworkService` 游戏服务类
- 新增 `gameProtocol`:类型安全的 API (join/leave) 和消息 (input/sync/spawn/despawn)
- 新增类型安全的便捷方法sendInput(), onSync(), onSpawn(), onDespawn()
- 更新 NetworkPlugin 使用新的服务架构
- 移除 TSRPC 依赖,改用 @esengine/rpc
---
- Refactor NetworkService into `RpcService<P>` base class and `GameNetworkService`
- Add `gameProtocol` with type-safe API (join/leave) and messages (input/sync/spawn/despawn)
- Add type-safe convenience methods: sendInput(), onSync(), onSpawn(), onDespawn()
- Update NetworkPlugin to use new service architecture
- Remove TSRPC dependency, migrate to @esengine/rpc
## @esengine/cli
### 变更 | Changed
- 更新 Node.js 适配器使用 `@esengine/rpc``@esengine/network`
- 生成的服务器代码改用 `RpcServer` + `gameProtocol`
- 添加 `ws``@types/ws` 依赖
- 更新 README 模板中的客户端连接示例
---
- Update Node.js adapter to use `@esengine/rpc` and `@esengine/network`
- Generated server code now uses `RpcServer` + `gameProtocol`
- Add `ws` and `@types/ws` dependencies
- Update client connection example in README template