Compare commits
4 Commits
@esengine/
...
@esengine/
| Author | SHA1 | Date | |
|---|---|---|---|
|
|
bdbbf8a80a | ||
|
|
b28169b186 | ||
|
|
d21caa974e | ||
|
|
a08a84b7db |
@@ -228,6 +228,7 @@ If you want a complete engine solution with rendering:
|
|||||||
A visual editor built with Tauri for scene management:
|
A visual editor built with Tauri for scene management:
|
||||||
|
|
||||||
- Download from [Releases](https://github.com/esengine/esengine/releases)
|
- Download from [Releases](https://github.com/esengine/esengine/releases)
|
||||||
|
- [Build from source](./packages/editor/editor-app/README.md)
|
||||||
- Supports behavior tree editing, tilemap painting, visual scripting
|
- Supports behavior tree editing, tilemap painting, visual scripting
|
||||||
|
|
||||||
## Project Structure
|
## Project Structure
|
||||||
@@ -281,6 +282,7 @@ pnpm test
|
|||||||
|
|
||||||
- [ECS Framework Guide](./packages/framework/core/README.md)
|
- [ECS Framework Guide](./packages/framework/core/README.md)
|
||||||
- [Behavior Tree Guide](./packages/framework/behavior-tree/README.md)
|
- [Behavior Tree Guide](./packages/framework/behavior-tree/README.md)
|
||||||
|
- [Editor Setup Guide](./packages/editor/editor-app/README.md) ([中文](./packages/editor/editor-app/README_CN.md))
|
||||||
- [API Reference](https://esengine.cn/api/README)
|
- [API Reference](https://esengine.cn/api/README)
|
||||||
|
|
||||||
## Community
|
## Community
|
||||||
|
|||||||
@@ -228,6 +228,7 @@ npm install @esengine/world-streaming # 世界流送
|
|||||||
基于 Tauri 构建的可视化编辑器:
|
基于 Tauri 构建的可视化编辑器:
|
||||||
|
|
||||||
- 从 [Releases](https://github.com/esengine/esengine/releases) 下载
|
- 从 [Releases](https://github.com/esengine/esengine/releases) 下载
|
||||||
|
- [从源码构建](./packages/editor/editor-app/README.md)
|
||||||
- 支持行为树编辑、Tilemap 绘制、可视化脚本
|
- 支持行为树编辑、Tilemap 绘制、可视化脚本
|
||||||
|
|
||||||
## 项目结构
|
## 项目结构
|
||||||
@@ -281,6 +282,7 @@ pnpm test
|
|||||||
|
|
||||||
- [ECS 框架指南](./packages/framework/core/README.md)
|
- [ECS 框架指南](./packages/framework/core/README.md)
|
||||||
- [行为树指南](./packages/framework/behavior-tree/README.md)
|
- [行为树指南](./packages/framework/behavior-tree/README.md)
|
||||||
|
- [编辑器启动指南](./packages/editor/editor-app/README_CN.md) ([English](./packages/editor/editor-app/README.md))
|
||||||
- [API 参考](https://esengine.cn/api/README)
|
- [API 参考](https://esengine.cn/api/README)
|
||||||
|
|
||||||
## 社区
|
## 社区
|
||||||
|
|||||||
@@ -3,6 +3,102 @@ title: "State Sync"
|
|||||||
description: "Component sync, interpolation, prediction and snapshot buffers"
|
description: "Component sync, interpolation, prediction and snapshot buffers"
|
||||||
---
|
---
|
||||||
|
|
||||||
|
## @NetworkEntity Decorator
|
||||||
|
|
||||||
|
The `@NetworkEntity` decorator marks components for automatic spawn/despawn broadcasting. When an entity containing this component is created or destroyed, ECSRoom automatically broadcasts the corresponding message to all clients.
|
||||||
|
|
||||||
|
### Basic Usage
|
||||||
|
|
||||||
|
```typescript
|
||||||
|
import { Component, ECSComponent, sync, NetworkEntity } from '@esengine/ecs-framework';
|
||||||
|
|
||||||
|
@ECSComponent('Enemy')
|
||||||
|
@NetworkEntity('Enemy')
|
||||||
|
class EnemyComponent extends Component {
|
||||||
|
@sync('float32') x: number = 0;
|
||||||
|
@sync('float32') y: number = 0;
|
||||||
|
@sync('uint16') health: number = 100;
|
||||||
|
}
|
||||||
|
```
|
||||||
|
|
||||||
|
When adding this component to an entity, ECSRoom automatically broadcasts the spawn message:
|
||||||
|
|
||||||
|
```typescript
|
||||||
|
// Server-side
|
||||||
|
const entity = scene.createEntity('Enemy');
|
||||||
|
entity.addComponent(new EnemyComponent()); // Auto-broadcasts spawn
|
||||||
|
|
||||||
|
// Destroying auto-broadcasts despawn
|
||||||
|
entity.destroy(); // Auto-broadcasts despawn
|
||||||
|
```
|
||||||
|
|
||||||
|
### Configuration Options
|
||||||
|
|
||||||
|
```typescript
|
||||||
|
@NetworkEntity('Bullet', {
|
||||||
|
autoSpawn: true, // Auto-broadcast spawn (default true)
|
||||||
|
autoDespawn: false // Disable auto-broadcast despawn
|
||||||
|
})
|
||||||
|
class BulletComponent extends Component { }
|
||||||
|
```
|
||||||
|
|
||||||
|
| Option | Type | Default | Description |
|
||||||
|
|--------|------|---------|-------------|
|
||||||
|
| `autoSpawn` | `boolean` | `true` | Auto-broadcast spawn when component is added |
|
||||||
|
| `autoDespawn` | `boolean` | `true` | Auto-broadcast despawn when entity is destroyed |
|
||||||
|
|
||||||
|
### Initialization Order
|
||||||
|
|
||||||
|
When using `@NetworkEntity`, initialize data **before** adding the component:
|
||||||
|
|
||||||
|
```typescript
|
||||||
|
// ✅ Correct: Initialize first, then add
|
||||||
|
const comp = new PlayerComponent();
|
||||||
|
comp.playerId = player.id;
|
||||||
|
comp.x = 100;
|
||||||
|
comp.y = 200;
|
||||||
|
entity.addComponent(comp); // Data is correct at spawn
|
||||||
|
|
||||||
|
// ❌ Wrong: Add first, then initialize
|
||||||
|
const comp = entity.addComponent(new PlayerComponent());
|
||||||
|
comp.playerId = player.id; // Data has default values at spawn
|
||||||
|
```
|
||||||
|
|
||||||
|
### Simplified GameRoom
|
||||||
|
|
||||||
|
With `@NetworkEntity`, GameRoom becomes much cleaner:
|
||||||
|
|
||||||
|
```typescript
|
||||||
|
// No manual callbacks needed
|
||||||
|
class GameRoom extends ECSRoom {
|
||||||
|
private setupSystems(): void {
|
||||||
|
// Enemy spawn system (auto-broadcasts spawn)
|
||||||
|
this.addSystem(new EnemySpawnSystem());
|
||||||
|
|
||||||
|
// Enemy AI system
|
||||||
|
const enemyAI = new EnemyAISystem();
|
||||||
|
enemyAI.onDeath((enemy) => {
|
||||||
|
enemy.destroy(); // Auto-broadcasts despawn
|
||||||
|
});
|
||||||
|
this.addSystem(enemyAI);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
```
|
||||||
|
|
||||||
|
### ECSRoom Configuration
|
||||||
|
|
||||||
|
You can disable the auto network entity feature in ECSRoom:
|
||||||
|
|
||||||
|
```typescript
|
||||||
|
class GameRoom extends ECSRoom {
|
||||||
|
constructor() {
|
||||||
|
super({
|
||||||
|
enableAutoNetworkEntity: false // Disable auto-broadcasting
|
||||||
|
});
|
||||||
|
}
|
||||||
|
}
|
||||||
|
```
|
||||||
|
|
||||||
## Component Sync System
|
## Component Sync System
|
||||||
|
|
||||||
ECS component state synchronization based on `@sync` decorator.
|
ECS component state synchronization based on `@sync` decorator.
|
||||||
|
|||||||
@@ -3,6 +3,102 @@ title: "状态同步"
|
|||||||
description: "组件同步、插值、预测和快照缓冲区"
|
description: "组件同步、插值、预测和快照缓冲区"
|
||||||
---
|
---
|
||||||
|
|
||||||
|
## @NetworkEntity 装饰器
|
||||||
|
|
||||||
|
`@NetworkEntity` 装饰器用于标记需要自动广播生成/销毁的组件。当包含此组件的实体被创建或销毁时,ECSRoom 会自动广播相应的消息给所有客户端。
|
||||||
|
|
||||||
|
### 基本用法
|
||||||
|
|
||||||
|
```typescript
|
||||||
|
import { Component, ECSComponent, sync, NetworkEntity } from '@esengine/ecs-framework';
|
||||||
|
|
||||||
|
@ECSComponent('Enemy')
|
||||||
|
@NetworkEntity('Enemy')
|
||||||
|
class EnemyComponent extends Component {
|
||||||
|
@sync('float32') x: number = 0;
|
||||||
|
@sync('float32') y: number = 0;
|
||||||
|
@sync('uint16') health: number = 100;
|
||||||
|
}
|
||||||
|
```
|
||||||
|
|
||||||
|
当添加此组件到实体时,ECSRoom 会自动广播 spawn 消息:
|
||||||
|
|
||||||
|
```typescript
|
||||||
|
// 服务端
|
||||||
|
const entity = scene.createEntity('Enemy');
|
||||||
|
entity.addComponent(new EnemyComponent()); // 自动广播 spawn
|
||||||
|
|
||||||
|
// 销毁时自动广播 despawn
|
||||||
|
entity.destroy(); // 自动广播 despawn
|
||||||
|
```
|
||||||
|
|
||||||
|
### 配置选项
|
||||||
|
|
||||||
|
```typescript
|
||||||
|
@NetworkEntity('Bullet', {
|
||||||
|
autoSpawn: true, // 自动广播生成(默认 true)
|
||||||
|
autoDespawn: false // 禁用自动广播销毁
|
||||||
|
})
|
||||||
|
class BulletComponent extends Component { }
|
||||||
|
```
|
||||||
|
|
||||||
|
| 选项 | 类型 | 默认值 | 描述 |
|
||||||
|
|------|------|--------|------|
|
||||||
|
| `autoSpawn` | `boolean` | `true` | 添加组件时自动广播 spawn |
|
||||||
|
| `autoDespawn` | `boolean` | `true` | 销毁实体时自动广播 despawn |
|
||||||
|
|
||||||
|
### 初始化顺序
|
||||||
|
|
||||||
|
使用 `@NetworkEntity` 时,应在添加组件**之前**初始化数据:
|
||||||
|
|
||||||
|
```typescript
|
||||||
|
// ✅ 正确:先初始化,再添加
|
||||||
|
const comp = new PlayerComponent();
|
||||||
|
comp.playerId = player.id;
|
||||||
|
comp.x = 100;
|
||||||
|
comp.y = 200;
|
||||||
|
entity.addComponent(comp); // spawn 时数据已正确
|
||||||
|
|
||||||
|
// ❌ 错误:先添加,再初始化
|
||||||
|
const comp = entity.addComponent(new PlayerComponent());
|
||||||
|
comp.playerId = player.id; // spawn 时数据是默认值
|
||||||
|
```
|
||||||
|
|
||||||
|
### 简化 GameRoom
|
||||||
|
|
||||||
|
使用 `@NetworkEntity` 后,GameRoom 变得更加简洁:
|
||||||
|
|
||||||
|
```typescript
|
||||||
|
// 无需手动回调
|
||||||
|
class GameRoom extends ECSRoom {
|
||||||
|
private setupSystems(): void {
|
||||||
|
// 敌人生成系统(自动广播 spawn)
|
||||||
|
this.addSystem(new EnemySpawnSystem());
|
||||||
|
|
||||||
|
// 敌人 AI 系统
|
||||||
|
const enemyAI = new EnemyAISystem();
|
||||||
|
enemyAI.onDeath((enemy) => {
|
||||||
|
enemy.destroy(); // 自动广播 despawn
|
||||||
|
});
|
||||||
|
this.addSystem(enemyAI);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
```
|
||||||
|
|
||||||
|
### ECSRoom 配置
|
||||||
|
|
||||||
|
可以在 ECSRoom 中禁用自动网络实体功能:
|
||||||
|
|
||||||
|
```typescript
|
||||||
|
class GameRoom extends ECSRoom {
|
||||||
|
constructor() {
|
||||||
|
super({
|
||||||
|
enableAutoNetworkEntity: false // 禁用自动广播
|
||||||
|
});
|
||||||
|
}
|
||||||
|
}
|
||||||
|
```
|
||||||
|
|
||||||
## 组件同步系统
|
## 组件同步系统
|
||||||
|
|
||||||
基于 `@sync` 装饰器的 ECS 组件状态同步。
|
基于 `@sync` 装饰器的 ECS 组件状态同步。
|
||||||
|
|||||||
86
packages/editor/editor-app/README.md
Normal file
86
packages/editor/editor-app/README.md
Normal file
@@ -0,0 +1,86 @@
|
|||||||
|
# ESEngine Editor
|
||||||
|
|
||||||
|
A cross-platform desktop visual editor built with Tauri 2.x + React 18.
|
||||||
|
|
||||||
|
## Prerequisites
|
||||||
|
|
||||||
|
Before running the editor, ensure you have the following installed:
|
||||||
|
|
||||||
|
- **Node.js** >= 18.x
|
||||||
|
- **pnpm** >= 10.x
|
||||||
|
- **Rust** >= 1.70 (for Tauri)
|
||||||
|
- **Platform-specific dependencies**:
|
||||||
|
- **Windows**: Microsoft Visual Studio C++ Build Tools
|
||||||
|
- **macOS**: Xcode Command Line Tools (`xcode-select --install`)
|
||||||
|
- **Linux**: See [Tauri prerequisites](https://tauri.app/v1/guides/getting-started/prerequisites)
|
||||||
|
|
||||||
|
## Quick Start
|
||||||
|
|
||||||
|
### 1. Clone and Install
|
||||||
|
|
||||||
|
```bash
|
||||||
|
git clone https://github.com/esengine/esengine.git
|
||||||
|
cd esengine
|
||||||
|
pnpm install
|
||||||
|
```
|
||||||
|
|
||||||
|
### 2. Build Dependencies
|
||||||
|
|
||||||
|
From the project root:
|
||||||
|
|
||||||
|
```bash
|
||||||
|
pnpm build:editor
|
||||||
|
```
|
||||||
|
|
||||||
|
### 3. Run Editor
|
||||||
|
|
||||||
|
```bash
|
||||||
|
cd packages/editor/editor-app
|
||||||
|
pnpm tauri:dev
|
||||||
|
```
|
||||||
|
|
||||||
|
## Available Scripts
|
||||||
|
|
||||||
|
| Script | Description |
|
||||||
|
|--------|-------------|
|
||||||
|
| `pnpm tauri:dev` | Run editor in development mode with hot-reload |
|
||||||
|
| `pnpm tauri:build` | Build production application |
|
||||||
|
| `pnpm build:sdk` | Build editor-runtime SDK |
|
||||||
|
|
||||||
|
## Project Structure
|
||||||
|
|
||||||
|
```
|
||||||
|
editor-app/
|
||||||
|
├── src/ # React application source
|
||||||
|
│ ├── components/ # UI components
|
||||||
|
│ ├── panels/ # Editor panels
|
||||||
|
│ └── services/ # Core services
|
||||||
|
├── src-tauri/ # Tauri (Rust) backend
|
||||||
|
├── public/ # Static assets
|
||||||
|
└── scripts/ # Build scripts
|
||||||
|
```
|
||||||
|
|
||||||
|
## Troubleshooting
|
||||||
|
|
||||||
|
### Build Errors
|
||||||
|
|
||||||
|
```bash
|
||||||
|
pnpm clean
|
||||||
|
pnpm install
|
||||||
|
pnpm build:editor
|
||||||
|
```
|
||||||
|
|
||||||
|
### Rust/Tauri Errors
|
||||||
|
|
||||||
|
```bash
|
||||||
|
rustup update
|
||||||
|
```
|
||||||
|
|
||||||
|
## Documentation
|
||||||
|
|
||||||
|
- [ESEngine Documentation](https://esengine.cn/)
|
||||||
|
- [Tauri Documentation](https://tauri.app/)
|
||||||
|
|
||||||
|
## License
|
||||||
|
|
||||||
|
MIT License
|
||||||
86
packages/editor/editor-app/README_CN.md
Normal file
86
packages/editor/editor-app/README_CN.md
Normal file
@@ -0,0 +1,86 @@
|
|||||||
|
# ESEngine 编辑器
|
||||||
|
|
||||||
|
基于 Tauri 2.x + React 18 构建的跨平台桌面可视化编辑器。
|
||||||
|
|
||||||
|
## 环境要求
|
||||||
|
|
||||||
|
运行编辑器前,请确保已安装以下环境:
|
||||||
|
|
||||||
|
- **Node.js** >= 18.x
|
||||||
|
- **pnpm** >= 10.x
|
||||||
|
- **Rust** >= 1.70 (Tauri 需要)
|
||||||
|
- **平台相关依赖**:
|
||||||
|
- **Windows**: Microsoft Visual Studio C++ Build Tools
|
||||||
|
- **macOS**: Xcode Command Line Tools (`xcode-select --install`)
|
||||||
|
- **Linux**: 参考 [Tauri 环境配置](https://tauri.app/v1/guides/getting-started/prerequisites)
|
||||||
|
|
||||||
|
## 快速开始
|
||||||
|
|
||||||
|
### 1. 克隆并安装
|
||||||
|
|
||||||
|
```bash
|
||||||
|
git clone https://github.com/esengine/esengine.git
|
||||||
|
cd esengine
|
||||||
|
pnpm install
|
||||||
|
```
|
||||||
|
|
||||||
|
### 2. 构建依赖
|
||||||
|
|
||||||
|
在项目根目录执行:
|
||||||
|
|
||||||
|
```bash
|
||||||
|
pnpm build:editor
|
||||||
|
```
|
||||||
|
|
||||||
|
### 3. 启动编辑器
|
||||||
|
|
||||||
|
```bash
|
||||||
|
cd packages/editor/editor-app
|
||||||
|
pnpm tauri:dev
|
||||||
|
```
|
||||||
|
|
||||||
|
## 可用脚本
|
||||||
|
|
||||||
|
| 脚本 | 说明 |
|
||||||
|
|------|------|
|
||||||
|
| `pnpm tauri:dev` | 开发模式运行编辑器(支持热重载)|
|
||||||
|
| `pnpm tauri:build` | 构建生产版本应用 |
|
||||||
|
| `pnpm build:sdk` | 构建 editor-runtime SDK |
|
||||||
|
|
||||||
|
## 项目结构
|
||||||
|
|
||||||
|
```
|
||||||
|
editor-app/
|
||||||
|
├── src/ # React 应用源码
|
||||||
|
│ ├── components/ # UI 组件
|
||||||
|
│ ├── panels/ # 编辑器面板
|
||||||
|
│ └── services/ # 核心服务
|
||||||
|
├── src-tauri/ # Tauri (Rust) 后端
|
||||||
|
├── public/ # 静态资源
|
||||||
|
└── scripts/ # 构建脚本
|
||||||
|
```
|
||||||
|
|
||||||
|
## 常见问题
|
||||||
|
|
||||||
|
### 构建错误
|
||||||
|
|
||||||
|
```bash
|
||||||
|
pnpm clean
|
||||||
|
pnpm install
|
||||||
|
pnpm build:editor
|
||||||
|
```
|
||||||
|
|
||||||
|
### Rust/Tauri 错误
|
||||||
|
|
||||||
|
```bash
|
||||||
|
rustup update
|
||||||
|
```
|
||||||
|
|
||||||
|
## 文档
|
||||||
|
|
||||||
|
- [ESEngine 文档](https://esengine.cn/)
|
||||||
|
- [Tauri 文档](https://tauri.app/)
|
||||||
|
|
||||||
|
## 许可证
|
||||||
|
|
||||||
|
MIT License
|
||||||
@@ -9,7 +9,7 @@
|
|||||||
"build": "npm run build:sdk && tsc && vite build",
|
"build": "npm run build:sdk && tsc && vite build",
|
||||||
"build:watch": "vite build --watch",
|
"build:watch": "vite build --watch",
|
||||||
"tauri": "tauri",
|
"tauri": "tauri",
|
||||||
"copy-modules": "node ../../scripts/copy-engine-modules.mjs",
|
"copy-modules": "node ../../../scripts/copy-engine-modules.mjs",
|
||||||
"tauri:dev": "npm run build:sdk && npm run copy-modules && tauri dev",
|
"tauri:dev": "npm run build:sdk && npm run copy-modules && tauri dev",
|
||||||
"bundle:runtime": "node scripts/bundle-runtime.mjs",
|
"bundle:runtime": "node scripts/bundle-runtime.mjs",
|
||||||
"tauri:build": "npm run build:sdk && npm run copy-modules && npm run bundle:runtime && tauri build",
|
"tauri:build": "npm run build:sdk && npm run copy-modules && npm run bundle:runtime && tauri build",
|
||||||
|
|||||||
1010
packages/editor/editor-app/src-tauri/Cargo.lock
generated
1010
packages/editor/editor-app/src-tauri/Cargo.lock
generated
File diff suppressed because it is too large
Load Diff
@@ -10,16 +10,16 @@ name = "ecs_editor_lib"
|
|||||||
crate-type = ["staticlib", "cdylib", "rlib"]
|
crate-type = ["staticlib", "cdylib", "rlib"]
|
||||||
|
|
||||||
[build-dependencies]
|
[build-dependencies]
|
||||||
tauri-build = { version = "2.0", features = [] }
|
tauri-build = { version = "2", features = [] }
|
||||||
|
|
||||||
[dependencies]
|
[dependencies]
|
||||||
tauri = { version = "2.0", features = ["protocol-asset"] }
|
tauri = { version = "2", features = ["protocol-asset"] }
|
||||||
tauri-plugin-shell = "2.0"
|
tauri-plugin-shell = "2"
|
||||||
tauri-plugin-dialog = "2.0"
|
tauri-plugin-dialog = "2"
|
||||||
tauri-plugin-fs = "2.0"
|
tauri-plugin-fs = "2"
|
||||||
tauri-plugin-updater = "2"
|
tauri-plugin-updater = "2"
|
||||||
tauri-plugin-http = "2.0"
|
tauri-plugin-http = "2"
|
||||||
tauri-plugin-cli = "2.0"
|
tauri-plugin-cli = "2"
|
||||||
serde = { version = "1", features = ["derive"] }
|
serde = { version = "1", features = ["derive"] }
|
||||||
serde_json = "1"
|
serde_json = "1"
|
||||||
glob = "0.3"
|
glob = "0.3"
|
||||||
|
|||||||
@@ -30,6 +30,7 @@
|
|||||||
"devDependencies": {
|
"devDependencies": {
|
||||||
"@esengine/ecs-framework": "workspace:*",
|
"@esengine/ecs-framework": "workspace:*",
|
||||||
"@esengine/engine-core": "workspace:*",
|
"@esengine/engine-core": "workspace:*",
|
||||||
|
"@esengine/asset-system": "workspace:*",
|
||||||
"@esengine/editor-core": "workspace:*",
|
"@esengine/editor-core": "workspace:*",
|
||||||
"@esengine/editor-runtime": "workspace:*",
|
"@esengine/editor-runtime": "workspace:*",
|
||||||
"@esengine/node-editor": "workspace:*",
|
"@esengine/node-editor": "workspace:*",
|
||||||
|
|||||||
@@ -0,0 +1,45 @@
|
|||||||
|
/**
|
||||||
|
* @zh ESEngine 行为树运行时模块
|
||||||
|
* @en ESEngine Behavior Tree Runtime Module
|
||||||
|
*
|
||||||
|
* @zh 纯运行时模块,不依赖 asset-system。资产加载由编辑器在 install 时注册。
|
||||||
|
* @en Pure runtime module, no asset-system dependency. Asset loading is registered by editor during install.
|
||||||
|
*/
|
||||||
|
|
||||||
|
import type { IScene, ServiceContainer, IComponentRegistry } from '@esengine/ecs-framework';
|
||||||
|
import type { IRuntimeModule, SystemContext } from '@esengine/engine-core';
|
||||||
|
|
||||||
|
import {
|
||||||
|
BehaviorTreeRuntimeComponent,
|
||||||
|
BehaviorTreeExecutionSystem,
|
||||||
|
BehaviorTreeAssetManager,
|
||||||
|
GlobalBlackboardService,
|
||||||
|
BehaviorTreeSystemToken
|
||||||
|
} from '@esengine/behavior-tree';
|
||||||
|
|
||||||
|
export class BehaviorTreeRuntimeModule implements IRuntimeModule {
|
||||||
|
registerComponents(registry: IComponentRegistry): void {
|
||||||
|
registry.register(BehaviorTreeRuntimeComponent);
|
||||||
|
}
|
||||||
|
|
||||||
|
registerServices(services: ServiceContainer): void {
|
||||||
|
if (!services.isRegistered(GlobalBlackboardService)) {
|
||||||
|
services.registerSingleton(GlobalBlackboardService);
|
||||||
|
}
|
||||||
|
if (!services.isRegistered(BehaviorTreeAssetManager)) {
|
||||||
|
services.registerSingleton(BehaviorTreeAssetManager);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
createSystems(scene: IScene, context: SystemContext): void {
|
||||||
|
const ecsServices = (context as { ecsServices?: ServiceContainer }).ecsServices;
|
||||||
|
const behaviorTreeSystem = new BehaviorTreeExecutionSystem(ecsServices);
|
||||||
|
|
||||||
|
if (context.isEditor) {
|
||||||
|
behaviorTreeSystem.enabled = false;
|
||||||
|
}
|
||||||
|
|
||||||
|
scene.addSystem(behaviorTreeSystem);
|
||||||
|
context.services.register(BehaviorTreeSystemToken, behaviorTreeSystem);
|
||||||
|
}
|
||||||
|
}
|
||||||
@@ -30,8 +30,11 @@ import {
|
|||||||
LocaleService,
|
LocaleService,
|
||||||
} from '@esengine/editor-runtime';
|
} from '@esengine/editor-runtime';
|
||||||
|
|
||||||
// Runtime imports from @esengine/behavior-tree package
|
// Runtime imports
|
||||||
import { BehaviorTreeRuntimeComponent, BehaviorTreeRuntimeModule } from '@esengine/behavior-tree';
|
import { BehaviorTreeRuntimeComponent, BehaviorTreeAssetType } from '@esengine/behavior-tree';
|
||||||
|
import { AssetManagerToken } from '@esengine/asset-system';
|
||||||
|
import { BehaviorTreeRuntimeModule } from './BehaviorTreeRuntimeModule';
|
||||||
|
import { BehaviorTreeLoader } from './runtime/BehaviorTreeLoader';
|
||||||
|
|
||||||
// Editor components and services
|
// Editor components and services
|
||||||
import { BehaviorTreeService } from './services/BehaviorTreeService';
|
import { BehaviorTreeService } from './services/BehaviorTreeService';
|
||||||
@@ -71,6 +74,10 @@ export class BehaviorTreeEditorModule implements IEditorModuleLoader {
|
|||||||
// 设置插件上下文
|
// 设置插件上下文
|
||||||
PluginContext.setServices(services);
|
PluginContext.setServices(services);
|
||||||
|
|
||||||
|
// 注册行为树资产加载器到 AssetManager
|
||||||
|
// Register behavior tree asset loader to AssetManager
|
||||||
|
this.registerAssetLoader();
|
||||||
|
|
||||||
// 注册服务
|
// 注册服务
|
||||||
this.registerServices(services);
|
this.registerServices(services);
|
||||||
|
|
||||||
@@ -92,6 +99,22 @@ export class BehaviorTreeEditorModule implements IEditorModuleLoader {
|
|||||||
logger.info('BehaviorTree editor module installed');
|
logger.info('BehaviorTree editor module installed');
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 注册行为树资产加载器
|
||||||
|
* Register behavior tree asset loader
|
||||||
|
*/
|
||||||
|
private registerAssetLoader(): void {
|
||||||
|
try {
|
||||||
|
const assetManager = PluginAPI.resolve(AssetManagerToken);
|
||||||
|
if (assetManager) {
|
||||||
|
assetManager.registerLoader(BehaviorTreeAssetType, new BehaviorTreeLoader());
|
||||||
|
logger.info('BehaviorTree asset loader registered');
|
||||||
|
}
|
||||||
|
} catch (error) {
|
||||||
|
logger.warn('Failed to register asset loader:', error);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
private registerAssetCreationMappings(services: ServiceContainer): void {
|
private registerAssetCreationMappings(services: ServiceContainer): void {
|
||||||
try {
|
try {
|
||||||
const fileActionRegistry = services.resolve<FileActionRegistry>(IFileActionRegistry);
|
const fileActionRegistry = services.resolve<FileActionRegistry>(IFileActionRegistry);
|
||||||
@@ -376,7 +399,7 @@ export const BehaviorTreePlugin: IEditorPlugin = {
|
|||||||
editorModule: new BehaviorTreeEditorModule(),
|
editorModule: new BehaviorTreeEditorModule(),
|
||||||
};
|
};
|
||||||
|
|
||||||
export { BehaviorTreeRuntimeModule };
|
// BehaviorTreeRuntimeModule is internal, not re-exported
|
||||||
|
|
||||||
// Re-exports for editor functionality
|
// Re-exports for editor functionality
|
||||||
export { PluginContext } from './PluginContext';
|
export { PluginContext } from './PluginContext';
|
||||||
|
|||||||
@@ -0,0 +1,61 @@
|
|||||||
|
/**
|
||||||
|
* @zh ESEngine 资产加载器
|
||||||
|
* @en ESEngine asset loader
|
||||||
|
* @internal
|
||||||
|
*/
|
||||||
|
|
||||||
|
import { Core } from '@esengine/ecs-framework';
|
||||||
|
import {
|
||||||
|
BehaviorTreeAssetManager,
|
||||||
|
EditorToBehaviorTreeDataConverter,
|
||||||
|
BehaviorTreeAssetType,
|
||||||
|
type BehaviorTreeData
|
||||||
|
} from '@esengine/behavior-tree';
|
||||||
|
|
||||||
|
/**
|
||||||
|
* @zh 行为树资产接口
|
||||||
|
* @en Behavior tree asset interface
|
||||||
|
* @internal
|
||||||
|
*/
|
||||||
|
export interface IBehaviorTreeAsset {
|
||||||
|
data: BehaviorTreeData;
|
||||||
|
path: string;
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* @zh 行为树加载器
|
||||||
|
* @en Behavior tree loader implementing IAssetLoader interface
|
||||||
|
* @internal
|
||||||
|
*/
|
||||||
|
export class BehaviorTreeLoader {
|
||||||
|
readonly supportedType = BehaviorTreeAssetType;
|
||||||
|
readonly supportedExtensions = ['.btree'];
|
||||||
|
readonly contentType = 'text' as const;
|
||||||
|
|
||||||
|
async parse(content: { text?: string }, context: { metadata: { path: string } }): Promise<IBehaviorTreeAsset> {
|
||||||
|
if (!content.text) {
|
||||||
|
throw new Error('Behavior tree content is empty');
|
||||||
|
}
|
||||||
|
|
||||||
|
const treeData = EditorToBehaviorTreeDataConverter.fromEditorJSON(content.text);
|
||||||
|
const assetPath = context.metadata.path;
|
||||||
|
treeData.id = assetPath;
|
||||||
|
|
||||||
|
const btAssetManager = Core.services.tryResolve(BehaviorTreeAssetManager);
|
||||||
|
if (btAssetManager) {
|
||||||
|
btAssetManager.loadAsset(treeData);
|
||||||
|
}
|
||||||
|
|
||||||
|
return {
|
||||||
|
data: treeData,
|
||||||
|
path: assetPath
|
||||||
|
};
|
||||||
|
}
|
||||||
|
|
||||||
|
dispose(asset: IBehaviorTreeAsset): void {
|
||||||
|
const btAssetManager = Core.services.tryResolve(BehaviorTreeAssetManager);
|
||||||
|
if (btAssetManager && asset.data) {
|
||||||
|
btAssetManager.unloadAsset(asset.data.id);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
@@ -1,23 +1,15 @@
|
|||||||
{
|
{
|
||||||
|
"extends": "../../../../tsconfig.base.json",
|
||||||
"compilerOptions": {
|
"compilerOptions": {
|
||||||
"target": "ES2020",
|
"composite": false,
|
||||||
"module": "ES2020",
|
|
||||||
"moduleResolution": "bundler",
|
|
||||||
"lib": ["ES2020", "DOM"],
|
|
||||||
"outDir": "./dist",
|
|
||||||
"rootDir": "./src",
|
|
||||||
"strict": true,
|
|
||||||
"esModuleInterop": true,
|
|
||||||
"allowSyntheticDefaultImports": true,
|
|
||||||
"skipLibCheck": true,
|
|
||||||
"forceConsistentCasingInFileNames": true,
|
|
||||||
"declaration": true,
|
"declaration": true,
|
||||||
"declarationMap": true,
|
"declarationMap": true,
|
||||||
|
"outDir": "./dist",
|
||||||
|
"rootDir": "./src",
|
||||||
"jsx": "react-jsx",
|
"jsx": "react-jsx",
|
||||||
"resolveJsonModule": true,
|
"skipLibCheck": true,
|
||||||
"experimentalDecorators": true,
|
"moduleResolution": "bundler"
|
||||||
"emitDecoratorMetadata": true
|
|
||||||
},
|
},
|
||||||
"include": ["src/**/*"],
|
"include": ["src/**/*"],
|
||||||
"exclude": ["node_modules", "dist"]
|
"exclude": ["node_modules", "dist", "**/*.test.ts"]
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -2,6 +2,8 @@ import { defineConfig } from 'tsup';
|
|||||||
import { editorOnlyPreset } from '../../../tools/build-config/src/presets/plugin-tsup';
|
import { editorOnlyPreset } from '../../../tools/build-config/src/presets/plugin-tsup';
|
||||||
|
|
||||||
export default defineConfig({
|
export default defineConfig({
|
||||||
...editorOnlyPreset(),
|
...editorOnlyPreset({
|
||||||
|
external: ['@esengine/asset-system']
|
||||||
|
}),
|
||||||
tsconfig: 'tsconfig.build.json'
|
tsconfig: 'tsconfig.build.json'
|
||||||
});
|
});
|
||||||
|
|||||||
13
packages/editor/plugins/fairygui-editor/tsconfig.build.json
Normal file
13
packages/editor/plugins/fairygui-editor/tsconfig.build.json
Normal file
@@ -0,0 +1,13 @@
|
|||||||
|
{
|
||||||
|
"extends": "../../../../tsconfig.base.json",
|
||||||
|
"compilerOptions": {
|
||||||
|
"composite": false,
|
||||||
|
"declaration": true,
|
||||||
|
"declarationMap": true,
|
||||||
|
"outDir": "./dist",
|
||||||
|
"rootDir": "./src",
|
||||||
|
"jsx": "react-jsx"
|
||||||
|
},
|
||||||
|
"include": ["src/**/*"],
|
||||||
|
"exclude": ["node_modules", "dist", "**/*.test.ts"]
|
||||||
|
}
|
||||||
@@ -1,6 +1,7 @@
|
|||||||
{
|
{
|
||||||
"extends": "../build-config/tsconfig.json",
|
"extends": "../../../../tsconfig.base.json",
|
||||||
"compilerOptions": {
|
"compilerOptions": {
|
||||||
|
"composite": true,
|
||||||
"outDir": "./dist",
|
"outDir": "./dist",
|
||||||
"rootDir": "./src",
|
"rootDir": "./src",
|
||||||
"jsx": "react-jsx",
|
"jsx": "react-jsx",
|
||||||
|
|||||||
@@ -5,6 +5,7 @@ export default defineConfig({
|
|||||||
format: ['esm'],
|
format: ['esm'],
|
||||||
dts: true,
|
dts: true,
|
||||||
clean: true,
|
clean: true,
|
||||||
|
tsconfig: 'tsconfig.build.json',
|
||||||
external: [
|
external: [
|
||||||
'react',
|
'react',
|
||||||
'react-dom',
|
'react-dom',
|
||||||
|
|||||||
@@ -1,5 +1,19 @@
|
|||||||
# @esengine/behavior-tree
|
# @esengine/behavior-tree
|
||||||
|
|
||||||
|
## 3.0.0
|
||||||
|
|
||||||
|
### Patch Changes
|
||||||
|
|
||||||
|
- Updated dependencies []:
|
||||||
|
- @esengine/ecs-framework@2.6.0
|
||||||
|
|
||||||
|
## 2.0.1
|
||||||
|
|
||||||
|
### Patch Changes
|
||||||
|
|
||||||
|
- Updated dependencies [[`a08a84b`](https://github.com/esengine/esengine/commit/a08a84b7db28e1140cbc637d442552747ad81c76)]:
|
||||||
|
- @esengine/ecs-framework@2.5.1
|
||||||
|
|
||||||
## 2.0.0
|
## 2.0.0
|
||||||
|
|
||||||
### Patch Changes
|
### Patch Changes
|
||||||
|
|||||||
@@ -1,6 +1,6 @@
|
|||||||
{
|
{
|
||||||
"name": "@esengine/behavior-tree",
|
"name": "@esengine/behavior-tree",
|
||||||
"version": "2.0.0",
|
"version": "3.0.0",
|
||||||
"description": "ECS-based AI behavior tree system - works with any ECS framework (ESEngine, Cocos, Laya, etc.)",
|
"description": "ECS-based AI behavior tree system - works with any ECS framework (ESEngine, Cocos, Laya, etc.)",
|
||||||
"main": "dist/index.js",
|
"main": "dist/index.js",
|
||||||
"module": "dist/index.js",
|
"module": "dist/index.js",
|
||||||
|
|||||||
@@ -1,5 +1,19 @@
|
|||||||
# @esengine/blueprint
|
# @esengine/blueprint
|
||||||
|
|
||||||
|
## 3.0.0
|
||||||
|
|
||||||
|
### Patch Changes
|
||||||
|
|
||||||
|
- Updated dependencies []:
|
||||||
|
- @esengine/ecs-framework@2.6.0
|
||||||
|
|
||||||
|
## 2.0.1
|
||||||
|
|
||||||
|
### Patch Changes
|
||||||
|
|
||||||
|
- Updated dependencies [[`a08a84b`](https://github.com/esengine/esengine/commit/a08a84b7db28e1140cbc637d442552747ad81c76)]:
|
||||||
|
- @esengine/ecs-framework@2.5.1
|
||||||
|
|
||||||
## 2.0.0
|
## 2.0.0
|
||||||
|
|
||||||
### Patch Changes
|
### Patch Changes
|
||||||
|
|||||||
@@ -1,6 +1,6 @@
|
|||||||
{
|
{
|
||||||
"name": "@esengine/blueprint",
|
"name": "@esengine/blueprint",
|
||||||
"version": "2.0.0",
|
"version": "3.0.0",
|
||||||
"description": "Visual scripting system - works with any ECS framework (ESEngine, Cocos, Laya, etc.)",
|
"description": "Visual scripting system - works with any ECS framework (ESEngine, Cocos, Laya, etc.)",
|
||||||
"main": "dist/index.js",
|
"main": "dist/index.js",
|
||||||
"module": "dist/index.js",
|
"module": "dist/index.js",
|
||||||
|
|||||||
@@ -1,5 +1,76 @@
|
|||||||
# @esengine/ecs-framework
|
# @esengine/ecs-framework
|
||||||
|
|
||||||
|
## 2.6.0
|
||||||
|
|
||||||
|
### Minor Changes
|
||||||
|
|
||||||
|
- feat(ecs): 添加 @NetworkEntity 装饰器,支持自动广播实体生成/销毁
|
||||||
|
|
||||||
|
### 新功能
|
||||||
|
|
||||||
|
**@NetworkEntity 装饰器**
|
||||||
|
- 标记组件为网络实体,自动广播 spawn/despawn 消息
|
||||||
|
- 支持 `autoSpawn` 和 `autoDespawn` 配置选项
|
||||||
|
- 通过事件系统(`ECSEventType.COMPONENT_ADDED` / `ECSEventType.ENTITY_DESTROYED`)实现
|
||||||
|
|
||||||
|
**ECSRoom 增强**
|
||||||
|
- 新增 `enableAutoNetworkEntity` 配置选项(默认启用)
|
||||||
|
- 自动监听组件添加和实体销毁事件
|
||||||
|
- 简化 GameRoom 实现,无需手动回调
|
||||||
|
|
||||||
|
### 改进
|
||||||
|
|
||||||
|
**Entity 事件**
|
||||||
|
- `Entity.destroy()` 现在发出 `entity:destroyed` 事件
|
||||||
|
- `Entity.active` 变化时发出 `entity:enabled` / `entity:disabled` 事件
|
||||||
|
- 使用 `ECSEventType` 常量替代硬编码字符串
|
||||||
|
|
||||||
|
### 使用示例
|
||||||
|
|
||||||
|
```typescript
|
||||||
|
import { Component, ECSComponent, sync, NetworkEntity } from '@esengine/ecs-framework';
|
||||||
|
|
||||||
|
@ECSComponent('Enemy')
|
||||||
|
@NetworkEntity('Enemy')
|
||||||
|
class EnemyComponent extends Component {
|
||||||
|
@sync('float32') x: number = 0;
|
||||||
|
@sync('float32') y: number = 0;
|
||||||
|
}
|
||||||
|
|
||||||
|
// 服务端
|
||||||
|
const entity = scene.createEntity('Enemy');
|
||||||
|
entity.addComponent(new EnemyComponent()); // 自动广播 spawn
|
||||||
|
entity.destroy(); // 自动广播 despawn
|
||||||
|
```
|
||||||
|
|
||||||
|
## 2.5.1
|
||||||
|
|
||||||
|
### Patch Changes
|
||||||
|
|
||||||
|
- [#392](https://github.com/esengine/esengine/pull/392) [`a08a84b`](https://github.com/esengine/esengine/commit/a08a84b7db28e1140cbc637d442552747ad81c76) Thanks [@esengine](https://github.com/esengine)! - fix(sync): Decoder 现在使用 GlobalComponentRegistry 查找组件 | Decoder now uses GlobalComponentRegistry for component lookup
|
||||||
|
|
||||||
|
**问题 | Problem:**
|
||||||
|
1. `Decoder.ts` 有自己独立的 `componentRegistry` Map,与 `GlobalComponentRegistry` 完全分离。这导致通过 `@ECSComponent` 装饰器注册的组件在网络反序列化时找不到,产生 "Unknown component type" 错误。
|
||||||
|
2. `@sync` 装饰器使用 `constructor.name` 作为 `typeId`,而不是 `@ECSComponent` 装饰器指定的名称,导致编码和解码使用不同的类型 ID。
|
||||||
|
3. `Decoder.ts` had its own local `componentRegistry` Map that was completely separate from `GlobalComponentRegistry`. This caused components registered via `@ECSComponent` decorator to not be found during network deserialization, resulting in "Unknown component type" errors.
|
||||||
|
4. `@sync` decorator used `constructor.name` as `typeId` instead of the name specified by `@ECSComponent` decorator, causing encoding and decoding to use different type IDs.
|
||||||
|
|
||||||
|
**修改 | Changes:**
|
||||||
|
- 从 Decoder.ts 中移除本地 `componentRegistry`
|
||||||
|
- 更新 `decodeEntity` 和 `decodeSpawn` 使用 `GlobalComponentRegistry.getComponentType()`
|
||||||
|
- 移除已废弃的 `registerSyncComponent` 和 `autoRegisterSyncComponent` 函数
|
||||||
|
- 更新 `@sync` 装饰器使用 `getComponentTypeName()` 获取组件类型名称
|
||||||
|
- 更新 `@ECSComponent` 装饰器同步更新 `SYNC_METADATA.typeId`
|
||||||
|
- Removed local `componentRegistry` from Decoder.ts
|
||||||
|
- Updated `decodeEntity` and `decodeSpawn` to use `GlobalComponentRegistry.getComponentType()`
|
||||||
|
- Removed deprecated `registerSyncComponent` and `autoRegisterSyncComponent` functions
|
||||||
|
- Updated `@sync` decorator to use `getComponentTypeName()` for component type name
|
||||||
|
- Updated `@ECSComponent` decorator to sync update `SYNC_METADATA.typeId`
|
||||||
|
|
||||||
|
现在使用 `@ECSComponent` 装饰器的组件会自动可用于网络同步解码,无需手动注册。
|
||||||
|
|
||||||
|
Now `@ECSComponent` decorated components are automatically available for network sync decoding without any manual registration.
|
||||||
|
|
||||||
## 2.5.0
|
## 2.5.0
|
||||||
|
|
||||||
### Minor Changes
|
### Minor Changes
|
||||||
|
|||||||
@@ -1,16 +1,18 @@
|
|||||||
{
|
{
|
||||||
"name": "@esengine/ecs-framework",
|
"name": "@esengine/ecs-framework",
|
||||||
"version": "2.5.0",
|
"version": "2.6.0",
|
||||||
"description": "用于Laya、Cocos Creator等JavaScript游戏引擎的高性能ECS框架",
|
"description": "用于Laya、Cocos Creator等JavaScript游戏引擎的高性能ECS框架",
|
||||||
"main": "dist/index.cjs",
|
"main": "dist/index.cjs",
|
||||||
"module": "dist/index.mjs",
|
"module": "dist/index.mjs",
|
||||||
"types": "dist/index.d.ts",
|
"types": "dist/index.d.ts",
|
||||||
"unpkg": "dist/index.umd.js",
|
"unpkg": "dist/index.umd.js",
|
||||||
|
"sideEffects": false,
|
||||||
"exports": {
|
"exports": {
|
||||||
".": {
|
".": {
|
||||||
"types": "./dist/index.d.ts",
|
"types": "./dist/index.d.ts",
|
||||||
"import": "./dist/index.mjs",
|
"import": "./dist/index.mjs",
|
||||||
"require": "./dist/index.cjs"
|
"require": "./dist/index.cjs",
|
||||||
|
"source": "./src/index.ts"
|
||||||
}
|
}
|
||||||
},
|
},
|
||||||
"files": [
|
"files": [
|
||||||
@@ -50,23 +52,24 @@
|
|||||||
"@babel/plugin-transform-nullish-coalescing-operator": "^7.27.1",
|
"@babel/plugin-transform-nullish-coalescing-operator": "^7.27.1",
|
||||||
"@babel/plugin-transform-optional-chaining": "^7.27.1",
|
"@babel/plugin-transform-optional-chaining": "^7.27.1",
|
||||||
"@babel/preset-env": "^7.28.3",
|
"@babel/preset-env": "^7.28.3",
|
||||||
|
"@eslint/js": "^9.37.0",
|
||||||
|
"@jest/globals": "^29.7.0",
|
||||||
"@rollup/plugin-babel": "^6.0.4",
|
"@rollup/plugin-babel": "^6.0.4",
|
||||||
"@rollup/plugin-commonjs": "^28.0.3",
|
"@rollup/plugin-commonjs": "^28.0.3",
|
||||||
"@rollup/plugin-node-resolve": "^16.0.1",
|
"@rollup/plugin-node-resolve": "^16.0.1",
|
||||||
"@rollup/plugin-terser": "^0.4.4",
|
"@rollup/plugin-terser": "^0.4.4",
|
||||||
"@jest/globals": "^29.7.0",
|
|
||||||
"@types/jest": "^29.5.14",
|
"@types/jest": "^29.5.14",
|
||||||
"@types/node": "^20.19.17",
|
"@types/node": "^20.19.17",
|
||||||
"@eslint/js": "^9.37.0",
|
|
||||||
"eslint": "^9.37.0",
|
"eslint": "^9.37.0",
|
||||||
"typescript-eslint": "^8.46.1",
|
|
||||||
"jest": "^29.7.0",
|
"jest": "^29.7.0",
|
||||||
"jest-environment-jsdom": "^29.7.0",
|
"jest-environment-jsdom": "^29.7.0",
|
||||||
"rimraf": "^5.0.0",
|
"rimraf": "^5.0.0",
|
||||||
"rollup": "^4.42.0",
|
"rollup": "^4.42.0",
|
||||||
"rollup-plugin-dts": "^6.2.1",
|
"rollup-plugin-dts": "^6.2.1",
|
||||||
|
"rollup-plugin-sourcemaps": "^0.6.3",
|
||||||
"ts-jest": "^29.4.0",
|
"ts-jest": "^29.4.0",
|
||||||
"typescript": "^5.8.3"
|
"typescript": "^5.8.3",
|
||||||
|
"typescript-eslint": "^8.46.1"
|
||||||
},
|
},
|
||||||
"publishConfig": {
|
"publishConfig": {
|
||||||
"access": "public",
|
"access": "public",
|
||||||
|
|||||||
@@ -10,10 +10,16 @@ import { Int32 } from './Core/SoAStorage';
|
|||||||
* @en Components in ECS architecture should be pure data containers.
|
* @en Components in ECS architecture should be pure data containers.
|
||||||
* All game logic should be implemented in EntitySystem, not inside components.
|
* All game logic should be implemented in EntitySystem, not inside components.
|
||||||
*
|
*
|
||||||
|
* @zh **重要:所有 Component 子类都必须使用 @ECSComponent 装饰器!**
|
||||||
|
* @zh 该装饰器用于注册组件类型名称,是序列化、网络同步等功能正常工作的前提。
|
||||||
|
* @en **IMPORTANT: All Component subclasses MUST use the @ECSComponent decorator!**
|
||||||
|
* @en This decorator registers the component type name, which is required for serialization, network sync, etc.
|
||||||
|
*
|
||||||
* @example
|
* @example
|
||||||
* @zh 推荐做法:纯数据组件
|
* @zh 正确做法:使用 @ECSComponent 装饰器
|
||||||
* @en Recommended: Pure data component
|
* @en Correct: Use @ECSComponent decorator
|
||||||
* ```typescript
|
* ```typescript
|
||||||
|
* @ECSComponent('HealthComponent')
|
||||||
* class HealthComponent extends Component {
|
* class HealthComponent extends Component {
|
||||||
* public health: number = 100;
|
* public health: number = 100;
|
||||||
* public maxHealth: number = 100;
|
* public maxHealth: number = 100;
|
||||||
|
|||||||
@@ -19,6 +19,7 @@ import {
|
|||||||
type ComponentEditorOptions,
|
type ComponentEditorOptions,
|
||||||
type ComponentType
|
type ComponentType
|
||||||
} from '../Core/ComponentStorage/ComponentTypeUtils';
|
} from '../Core/ComponentStorage/ComponentTypeUtils';
|
||||||
|
import { SYNC_METADATA, type SyncMetadata } from '../Sync/types';
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* 存储系统类型名称的Symbol键
|
* 存储系统类型名称的Symbol键
|
||||||
@@ -138,6 +139,14 @@ export function ECSComponent(typeName: string, options?: ComponentOptions) {
|
|||||||
metadata[COMPONENT_EDITOR_OPTIONS] = options.editor;
|
metadata[COMPONENT_EDITOR_OPTIONS] = options.editor;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
// 更新 @sync 装饰器创建的 SYNC_METADATA.typeId(如果存在)
|
||||||
|
// Update SYNC_METADATA.typeId created by @sync decorator (if exists)
|
||||||
|
// Property decorators execute before class decorators, so @sync may have used constructor.name
|
||||||
|
const syncMeta = (target as any)[SYNC_METADATA] as SyncMetadata | undefined;
|
||||||
|
if (syncMeta) {
|
||||||
|
syncMeta.typeId = typeName;
|
||||||
|
}
|
||||||
|
|
||||||
// 自动注册到全局 ComponentRegistry,使组件可以通过名称查找
|
// 自动注册到全局 ComponentRegistry,使组件可以通过名称查找
|
||||||
// Auto-register to GlobalComponentRegistry, enabling lookup by name
|
// Auto-register to GlobalComponentRegistry, enabling lookup by name
|
||||||
GlobalComponentRegistry.register(target);
|
GlobalComponentRegistry.register(target);
|
||||||
|
|||||||
@@ -7,14 +7,7 @@ import { getComponentInstanceTypeName, getComponentTypeName } from './Decorators
|
|||||||
import { generateGUID } from '../Utils/GUID';
|
import { generateGUID } from '../Utils/GUID';
|
||||||
import type { IScene } from './IScene';
|
import type { IScene } from './IScene';
|
||||||
import { EntityHandle, NULL_HANDLE } from './Core/EntityHandle';
|
import { EntityHandle, NULL_HANDLE } from './Core/EntityHandle';
|
||||||
|
import { ECSEventType } from './CoreEvents';
|
||||||
/**
|
|
||||||
* @zh 组件活跃状态变化接口
|
|
||||||
* @en Interface for component active state change
|
|
||||||
*/
|
|
||||||
interface IActiveChangeable {
|
|
||||||
onActiveChanged(): void;
|
|
||||||
}
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* @zh 比较两个实体的优先级
|
* @zh 比较两个实体的优先级
|
||||||
@@ -482,7 +475,7 @@ export class Entity {
|
|||||||
}
|
}
|
||||||
|
|
||||||
if (this.scene.eventSystem) {
|
if (this.scene.eventSystem) {
|
||||||
this.scene.eventSystem.emitSync('component:added', {
|
this.scene.eventSystem.emitSync(ECSEventType.COMPONENT_ADDED, {
|
||||||
timestamp: Date.now(),
|
timestamp: Date.now(),
|
||||||
source: 'Entity',
|
source: 'Entity',
|
||||||
entityId: this.id,
|
entityId: this.id,
|
||||||
@@ -639,7 +632,7 @@ export class Entity {
|
|||||||
component.entityId = null;
|
component.entityId = null;
|
||||||
|
|
||||||
if (this.scene?.eventSystem) {
|
if (this.scene?.eventSystem) {
|
||||||
this.scene.eventSystem.emitSync('component:removed', {
|
this.scene.eventSystem.emitSync(ECSEventType.COMPONENT_REMOVED, {
|
||||||
timestamp: Date.now(),
|
timestamp: Date.now(),
|
||||||
source: 'Entity',
|
source: 'Entity',
|
||||||
entityId: this.id,
|
entityId: this.id,
|
||||||
@@ -770,19 +763,23 @@ export class Entity {
|
|||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* 活跃状态改变时的回调
|
* @zh 活跃状态改变时的回调
|
||||||
|
* @en Callback when active state changes
|
||||||
|
*
|
||||||
|
* @zh 通过事件系统发出 ENTITY_ENABLED 或 ENTITY_DISABLED 事件,
|
||||||
|
* 组件可以通过监听这些事件来响应实体状态变化。
|
||||||
|
* @en Emits ENTITY_ENABLED or ENTITY_DISABLED event through the event system.
|
||||||
|
* Components can listen to these events to respond to entity state changes.
|
||||||
*/
|
*/
|
||||||
private onActiveChanged(): void {
|
private onActiveChanged(): void {
|
||||||
for (const component of this.components) {
|
if (this.scene?.eventSystem) {
|
||||||
if ('onActiveChanged' in component && typeof component.onActiveChanged === 'function') {
|
const eventType = this._active
|
||||||
(component as IActiveChangeable).onActiveChanged();
|
? ECSEventType.ENTITY_ENABLED
|
||||||
}
|
: ECSEventType.ENTITY_DISABLED;
|
||||||
}
|
|
||||||
|
|
||||||
if (this.scene && this.scene.eventSystem) {
|
this.scene.eventSystem.emitSync(eventType, {
|
||||||
this.scene.eventSystem.emitSync('entity:activeChanged', {
|
|
||||||
entity: this,
|
entity: this,
|
||||||
active: this._active
|
scene: this.scene,
|
||||||
});
|
});
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@@ -801,6 +798,15 @@ export class Entity {
|
|||||||
|
|
||||||
this._isDestroyed = true;
|
this._isDestroyed = true;
|
||||||
|
|
||||||
|
// 在清理之前发出销毁事件(组件仍然可访问)
|
||||||
|
if (this.scene?.eventSystem) {
|
||||||
|
this.scene.eventSystem.emitSync(ECSEventType.ENTITY_DESTROYED, {
|
||||||
|
entity: this,
|
||||||
|
entityId: this.id,
|
||||||
|
scene: this.scene,
|
||||||
|
});
|
||||||
|
}
|
||||||
|
|
||||||
if (this.scene && this.scene.referenceTracker) {
|
if (this.scene && this.scene.referenceTracker) {
|
||||||
this.scene.referenceTracker.clearReferencesTo(this.id);
|
this.scene.referenceTracker.clearReferencesTo(this.id);
|
||||||
this.scene.referenceTracker.unregisterEntityScene(this.id);
|
this.scene.referenceTracker.unregisterEntityScene(this.id);
|
||||||
|
|||||||
147
packages/framework/core/src/ECS/Sync/NetworkEntityDecorator.ts
Normal file
147
packages/framework/core/src/ECS/Sync/NetworkEntityDecorator.ts
Normal file
@@ -0,0 +1,147 @@
|
|||||||
|
/**
|
||||||
|
* @zh 网络实体装饰器
|
||||||
|
* @en Network entity decorator
|
||||||
|
*
|
||||||
|
* @zh 提供 @NetworkEntity 装饰器,用于标记需要自动广播生成/销毁的组件
|
||||||
|
* @en Provides @NetworkEntity decorator to mark components for automatic spawn/despawn broadcasting
|
||||||
|
*/
|
||||||
|
|
||||||
|
/**
|
||||||
|
* @zh 网络实体元数据的 Symbol 键
|
||||||
|
* @en Symbol key for network entity metadata
|
||||||
|
*/
|
||||||
|
export const NETWORK_ENTITY_METADATA = Symbol('NetworkEntityMetadata');
|
||||||
|
|
||||||
|
/**
|
||||||
|
* @zh 网络实体元数据
|
||||||
|
* @en Network entity metadata
|
||||||
|
*/
|
||||||
|
export interface NetworkEntityMetadata {
|
||||||
|
/**
|
||||||
|
* @zh 预制体类型名称(用于客户端重建实体)
|
||||||
|
* @en Prefab type name (used by client to reconstruct entity)
|
||||||
|
*/
|
||||||
|
prefabType: string;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* @zh 是否自动广播生成
|
||||||
|
* @en Whether to auto-broadcast spawn
|
||||||
|
* @default true
|
||||||
|
*/
|
||||||
|
autoSpawn: boolean;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* @zh 是否自动广播销毁
|
||||||
|
* @en Whether to auto-broadcast despawn
|
||||||
|
* @default true
|
||||||
|
*/
|
||||||
|
autoDespawn: boolean;
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* @zh 网络实体装饰器配置选项
|
||||||
|
* @en Network entity decorator options
|
||||||
|
*/
|
||||||
|
export interface NetworkEntityOptions {
|
||||||
|
/**
|
||||||
|
* @zh 是否自动广播生成
|
||||||
|
* @en Whether to auto-broadcast spawn
|
||||||
|
* @default true
|
||||||
|
*/
|
||||||
|
autoSpawn?: boolean;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* @zh 是否自动广播销毁
|
||||||
|
* @en Whether to auto-broadcast despawn
|
||||||
|
* @default true
|
||||||
|
*/
|
||||||
|
autoDespawn?: boolean;
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* @zh 网络实体装饰器
|
||||||
|
* @en Network entity decorator
|
||||||
|
*
|
||||||
|
* @zh 标记组件类为网络实体。当包含此组件的实体被创建或销毁时,
|
||||||
|
* ECSRoom 会自动广播相应的 spawn/despawn 消息给所有客户端。
|
||||||
|
* @en Marks a component class as a network entity. When an entity containing
|
||||||
|
* this component is created or destroyed, ECSRoom will automatically broadcast
|
||||||
|
* the corresponding spawn/despawn messages to all clients.
|
||||||
|
*
|
||||||
|
* @param prefabType - @zh 预制体类型名称 @en Prefab type name
|
||||||
|
* @param options - @zh 可选配置 @en Optional configuration
|
||||||
|
*
|
||||||
|
* @example
|
||||||
|
* ```typescript
|
||||||
|
* import { Component, ECSComponent, NetworkEntity, sync } from '@esengine/ecs-framework';
|
||||||
|
*
|
||||||
|
* @ECSComponent('Enemy')
|
||||||
|
* @NetworkEntity('Enemy')
|
||||||
|
* class EnemyComponent extends Component {
|
||||||
|
* @sync('float32') x: number = 0;
|
||||||
|
* @sync('float32') y: number = 0;
|
||||||
|
* @sync('uint16') health: number = 100;
|
||||||
|
* }
|
||||||
|
*
|
||||||
|
* // 当添加此组件到实体时,ECSRoom 会自动广播 spawn
|
||||||
|
* const enemy = scene.createEntity('Enemy');
|
||||||
|
* enemy.addComponent(new EnemyComponent()); // 自动广播给所有客户端
|
||||||
|
*
|
||||||
|
* // 当实体销毁时,自动广播 despawn
|
||||||
|
* enemy.destroy(); // 自动广播给所有客户端
|
||||||
|
* ```
|
||||||
|
*
|
||||||
|
* @example
|
||||||
|
* ```typescript
|
||||||
|
* // 只自动广播生成,销毁由手动控制
|
||||||
|
* @ECSComponent('Bullet')
|
||||||
|
* @NetworkEntity('Bullet', { autoDespawn: false })
|
||||||
|
* class BulletComponent extends Component {
|
||||||
|
* @sync('float32') x: number = 0;
|
||||||
|
* @sync('float32') y: number = 0;
|
||||||
|
* }
|
||||||
|
* ```
|
||||||
|
*/
|
||||||
|
export function NetworkEntity(prefabType: string, options?: NetworkEntityOptions) {
|
||||||
|
return function <T extends new (...args: any[]) => any>(target: T): T {
|
||||||
|
const metadata: NetworkEntityMetadata = {
|
||||||
|
prefabType,
|
||||||
|
autoSpawn: options?.autoSpawn ?? true,
|
||||||
|
autoDespawn: options?.autoDespawn ?? true,
|
||||||
|
};
|
||||||
|
|
||||||
|
(target as any)[NETWORK_ENTITY_METADATA] = metadata;
|
||||||
|
|
||||||
|
return target;
|
||||||
|
};
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* @zh 获取组件类的网络实体元数据
|
||||||
|
* @en Get network entity metadata for a component class
|
||||||
|
*
|
||||||
|
* @param componentClass - @zh 组件类或组件实例 @en Component class or instance
|
||||||
|
* @returns @zh 网络实体元数据,如果不存在则返回 null @en Network entity metadata, or null if not exists
|
||||||
|
*/
|
||||||
|
export function getNetworkEntityMetadata(componentClass: any): NetworkEntityMetadata | null {
|
||||||
|
if (!componentClass) {
|
||||||
|
return null;
|
||||||
|
}
|
||||||
|
|
||||||
|
const constructor = typeof componentClass === 'function'
|
||||||
|
? componentClass
|
||||||
|
: componentClass.constructor;
|
||||||
|
|
||||||
|
return constructor[NETWORK_ENTITY_METADATA] || null;
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* @zh 检查组件是否标记为网络实体
|
||||||
|
* @en Check if a component is marked as a network entity
|
||||||
|
*
|
||||||
|
* @param component - @zh 组件类或组件实例 @en Component class or instance
|
||||||
|
* @returns @zh 如果是网络实体返回 true @en Returns true if is a network entity
|
||||||
|
*/
|
||||||
|
export function isNetworkEntity(component: any): boolean {
|
||||||
|
return getNetworkEntityMetadata(component) !== null;
|
||||||
|
}
|
||||||
@@ -9,6 +9,7 @@
|
|||||||
import type { SyncType, SyncFieldMetadata, SyncMetadata } from './types';
|
import type { SyncType, SyncFieldMetadata, SyncMetadata } from './types';
|
||||||
import { SYNC_METADATA, CHANGE_TRACKER } from './types';
|
import { SYNC_METADATA, CHANGE_TRACKER } from './types';
|
||||||
import { ChangeTracker } from './ChangeTracker';
|
import { ChangeTracker } from './ChangeTracker';
|
||||||
|
import { getComponentTypeName } from '../Core/ComponentStorage/ComponentTypeUtils';
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* @zh 获取或创建组件的同步元数据
|
* @zh 获取或创建组件的同步元数据
|
||||||
@@ -31,8 +32,9 @@ function getOrCreateSyncMetadata(target: any): SyncMetadata {
|
|||||||
const inheritedMetadata: SyncMetadata | undefined = constructor[SYNC_METADATA];
|
const inheritedMetadata: SyncMetadata | undefined = constructor[SYNC_METADATA];
|
||||||
|
|
||||||
// Create new metadata (copy from inherited if exists)
|
// Create new metadata (copy from inherited if exists)
|
||||||
|
// Use getComponentTypeName to get @ECSComponent decorator name, or fall back to constructor.name
|
||||||
const metadata: SyncMetadata = {
|
const metadata: SyncMetadata = {
|
||||||
typeId: constructor.name,
|
typeId: getComponentTypeName(constructor),
|
||||||
fields: inheritedMetadata ? [...inheritedMetadata.fields] : [],
|
fields: inheritedMetadata ? [...inheritedMetadata.fields] : [],
|
||||||
fieldIndexMap: inheritedMetadata ? new Map(inheritedMetadata.fieldIndexMap) : new Map()
|
fieldIndexMap: inheritedMetadata ? new Map(inheritedMetadata.fieldIndexMap) : new Map()
|
||||||
};
|
};
|
||||||
|
|||||||
@@ -12,39 +12,7 @@ import type { Scene } from '../../Scene';
|
|||||||
import type { SyncType, SyncMetadata } from '../types';
|
import type { SyncType, SyncMetadata } from '../types';
|
||||||
import { SyncOperation, SYNC_METADATA } from '../types';
|
import { SyncOperation, SYNC_METADATA } from '../types';
|
||||||
import { BinaryReader } from './BinaryReader';
|
import { BinaryReader } from './BinaryReader';
|
||||||
|
import { GlobalComponentRegistry } from '../../Core/ComponentStorage/ComponentRegistry';
|
||||||
/**
|
|
||||||
* @zh 组件类型注册表
|
|
||||||
* @en Component type registry
|
|
||||||
*/
|
|
||||||
const componentRegistry = new Map<string, new () => Component>();
|
|
||||||
|
|
||||||
/**
|
|
||||||
* @zh 注册组件类型
|
|
||||||
* @en Register component type
|
|
||||||
*
|
|
||||||
* @param typeId - @zh 组件类型 ID @en Component type ID
|
|
||||||
* @param componentClass - @zh 组件类 @en Component class
|
|
||||||
*/
|
|
||||||
export function registerSyncComponent<T extends Component>(
|
|
||||||
typeId: string,
|
|
||||||
componentClass: new () => T
|
|
||||||
): void {
|
|
||||||
componentRegistry.set(typeId, componentClass);
|
|
||||||
}
|
|
||||||
|
|
||||||
/**
|
|
||||||
* @zh 从 @ECSComponent 装饰器自动注册
|
|
||||||
* @en Auto-register from @ECSComponent decorator
|
|
||||||
*
|
|
||||||
* @param componentClass - @zh 组件类 @en Component class
|
|
||||||
*/
|
|
||||||
export function autoRegisterSyncComponent(componentClass: new () => Component): void {
|
|
||||||
const metadata: SyncMetadata | undefined = (componentClass as any)[SYNC_METADATA];
|
|
||||||
if (metadata) {
|
|
||||||
componentRegistry.set(metadata.typeId, componentClass);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* @zh 解码字段值
|
* @zh 解码字段值
|
||||||
@@ -166,8 +134,8 @@ export function decodeEntity(
|
|||||||
const typeId = reader.readString();
|
const typeId = reader.readString();
|
||||||
componentTypes.push(typeId);
|
componentTypes.push(typeId);
|
||||||
|
|
||||||
// Find component class from registry
|
// Find component class from GlobalComponentRegistry
|
||||||
const componentClass = componentRegistry.get(typeId);
|
const componentClass = GlobalComponentRegistry.getComponentType(typeId) as (new () => Component) | null;
|
||||||
if (!componentClass) {
|
if (!componentClass) {
|
||||||
console.warn(`Unknown component type: ${typeId}`);
|
console.warn(`Unknown component type: ${typeId}`);
|
||||||
// Skip component data - we need to read it to advance the reader
|
// Skip component data - we need to read it to advance the reader
|
||||||
@@ -306,7 +274,7 @@ export function decodeSpawn(
|
|||||||
const typeId = reader.readString();
|
const typeId = reader.readString();
|
||||||
componentTypes.push(typeId);
|
componentTypes.push(typeId);
|
||||||
|
|
||||||
const componentClass = componentRegistry.get(typeId);
|
const componentClass = GlobalComponentRegistry.getComponentType(typeId) as (new () => Component) | null;
|
||||||
if (!componentClass) {
|
if (!componentClass) {
|
||||||
console.warn(`Unknown component type: ${typeId}`);
|
console.warn(`Unknown component type: ${typeId}`);
|
||||||
// Try to skip
|
// Try to skip
|
||||||
@@ -322,7 +290,7 @@ export function decodeSpawn(
|
|||||||
continue;
|
continue;
|
||||||
}
|
}
|
||||||
|
|
||||||
const component = entity.addComponent(new componentClass());
|
const component = entity.addComponent(new (componentClass as new () => Component)());
|
||||||
decodeComponent(component, metadata, reader);
|
decodeComponent(component, metadata, reader);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
@@ -34,8 +34,6 @@ export {
|
|||||||
|
|
||||||
// Decoder
|
// Decoder
|
||||||
export {
|
export {
|
||||||
registerSyncComponent,
|
|
||||||
autoRegisterSyncComponent,
|
|
||||||
decodeComponent,
|
decodeComponent,
|
||||||
decodeEntity,
|
decodeEntity,
|
||||||
decodeSnapshot,
|
decodeSnapshot,
|
||||||
|
|||||||
@@ -51,5 +51,15 @@ export {
|
|||||||
hasChanges
|
hasChanges
|
||||||
} from './decorators';
|
} from './decorators';
|
||||||
|
|
||||||
|
// Network Entity Decorator
|
||||||
|
export {
|
||||||
|
NetworkEntity,
|
||||||
|
getNetworkEntityMetadata,
|
||||||
|
isNetworkEntity,
|
||||||
|
NETWORK_ENTITY_METADATA,
|
||||||
|
type NetworkEntityMetadata,
|
||||||
|
type NetworkEntityOptions
|
||||||
|
} from './NetworkEntityDecorator';
|
||||||
|
|
||||||
// Encoding
|
// Encoding
|
||||||
export * from './encoding';
|
export * from './encoding';
|
||||||
|
|||||||
@@ -53,7 +53,7 @@ describe('@sync 装饰器测试', () => {
|
|||||||
const metadata = getSyncMetadata(PlayerComponent);
|
const metadata = getSyncMetadata(PlayerComponent);
|
||||||
|
|
||||||
expect(metadata).not.toBeNull();
|
expect(metadata).not.toBeNull();
|
||||||
expect(metadata!.typeId).toBe('PlayerComponent');
|
expect(metadata!.typeId).toBe('SyncTest_PlayerComponent');
|
||||||
expect(metadata!.fields.length).toBe(4);
|
expect(metadata!.fields.length).toBe(4);
|
||||||
});
|
});
|
||||||
|
|
||||||
|
|||||||
@@ -13,8 +13,7 @@ import {
|
|||||||
import {
|
import {
|
||||||
decodeSnapshot,
|
decodeSnapshot,
|
||||||
decodeSpawn,
|
decodeSpawn,
|
||||||
processDespawn,
|
processDespawn
|
||||||
registerSyncComponent
|
|
||||||
} from '../../../src/ECS/Sync/encoding/Decoder';
|
} from '../../../src/ECS/Sync/encoding/Decoder';
|
||||||
import { SyncOperation } from '../../../src/ECS/Sync/types';
|
import { SyncOperation } from '../../../src/ECS/Sync/types';
|
||||||
|
|
||||||
@@ -320,10 +319,7 @@ describe('BinaryWriter/BinaryReader - 二进制读写器测试', () => {
|
|||||||
describe('Encoder/Decoder - 实体编解码测试', () => {
|
describe('Encoder/Decoder - 实体编解码测试', () => {
|
||||||
let scene: Scene;
|
let scene: Scene;
|
||||||
|
|
||||||
beforeAll(() => {
|
// Components are auto-registered via @ECSComponent decorator
|
||||||
registerSyncComponent('PlayerComponent', PlayerComponent);
|
|
||||||
registerSyncComponent('AllTypesComponent', AllTypesComponent);
|
|
||||||
});
|
|
||||||
|
|
||||||
beforeEach(() => {
|
beforeEach(() => {
|
||||||
scene = new Scene();
|
scene = new Scene();
|
||||||
@@ -414,7 +410,7 @@ describe('Encoder/Decoder - 实体编解码测试', () => {
|
|||||||
|
|
||||||
expect(result).not.toBeNull();
|
expect(result).not.toBeNull();
|
||||||
expect(result!.prefabType).toBe('Player');
|
expect(result!.prefabType).toBe('Player');
|
||||||
expect(result!.componentTypes).toContain('PlayerComponent');
|
expect(result!.componentTypes).toContain('EncodingTest_PlayerComponent');
|
||||||
|
|
||||||
const decodedComp = result!.entity.getComponent(PlayerComponent);
|
const decodedComp = result!.entity.getComponent(PlayerComponent);
|
||||||
expect(decodedComp!.name).toBe("SpawnedPlayer");
|
expect(decodedComp!.name).toBe("SpawnedPlayer");
|
||||||
@@ -470,10 +466,6 @@ describe('Encoder/Decoder - 实体编解码测试', () => {
|
|||||||
});
|
});
|
||||||
|
|
||||||
describe('所有同步类型编解码', () => {
|
describe('所有同步类型编解码', () => {
|
||||||
beforeAll(() => {
|
|
||||||
registerSyncComponent('AllTypesComponent', AllTypesComponent);
|
|
||||||
});
|
|
||||||
|
|
||||||
test('应该正确编解码所有类型', () => {
|
test('应该正确编解码所有类型', () => {
|
||||||
const entity = scene.createEntity('AllTypes');
|
const entity = scene.createEntity('AllTypes');
|
||||||
const comp = entity.addComponent(new AllTypesComponent());
|
const comp = entity.addComponent(new AllTypesComponent());
|
||||||
|
|||||||
@@ -1,5 +1,21 @@
|
|||||||
# @esengine/fsm
|
# @esengine/fsm
|
||||||
|
|
||||||
|
## 3.0.0
|
||||||
|
|
||||||
|
### Patch Changes
|
||||||
|
|
||||||
|
- Updated dependencies []:
|
||||||
|
- @esengine/ecs-framework@2.6.0
|
||||||
|
- @esengine/blueprint@3.0.0
|
||||||
|
|
||||||
|
## 2.0.1
|
||||||
|
|
||||||
|
### Patch Changes
|
||||||
|
|
||||||
|
- Updated dependencies [[`a08a84b`](https://github.com/esengine/esengine/commit/a08a84b7db28e1140cbc637d442552747ad81c76)]:
|
||||||
|
- @esengine/ecs-framework@2.5.1
|
||||||
|
- @esengine/blueprint@2.0.1
|
||||||
|
|
||||||
## 2.0.0
|
## 2.0.0
|
||||||
|
|
||||||
### Patch Changes
|
### Patch Changes
|
||||||
|
|||||||
@@ -1,6 +1,6 @@
|
|||||||
{
|
{
|
||||||
"name": "@esengine/fsm",
|
"name": "@esengine/fsm",
|
||||||
"version": "2.0.0",
|
"version": "3.0.0",
|
||||||
"description": "Finite State Machine for ECS Framework / ECS 框架的有限状态机",
|
"description": "Finite State Machine for ECS Framework / ECS 框架的有限状态机",
|
||||||
"type": "module",
|
"type": "module",
|
||||||
"main": "./dist/index.js",
|
"main": "./dist/index.js",
|
||||||
|
|||||||
@@ -1,5 +1,21 @@
|
|||||||
# @esengine/network
|
# @esengine/network
|
||||||
|
|
||||||
|
## 4.0.0
|
||||||
|
|
||||||
|
### Patch Changes
|
||||||
|
|
||||||
|
- Updated dependencies []:
|
||||||
|
- @esengine/ecs-framework@2.6.0
|
||||||
|
- @esengine/blueprint@3.0.0
|
||||||
|
|
||||||
|
## 3.0.1
|
||||||
|
|
||||||
|
### Patch Changes
|
||||||
|
|
||||||
|
- Updated dependencies [[`a08a84b`](https://github.com/esengine/esengine/commit/a08a84b7db28e1140cbc637d442552747ad81c76)]:
|
||||||
|
- @esengine/ecs-framework@2.5.1
|
||||||
|
- @esengine/blueprint@2.0.1
|
||||||
|
|
||||||
## 3.0.0
|
## 3.0.0
|
||||||
|
|
||||||
### Minor Changes
|
### Minor Changes
|
||||||
|
|||||||
@@ -1,6 +1,6 @@
|
|||||||
{
|
{
|
||||||
"name": "@esengine/network",
|
"name": "@esengine/network",
|
||||||
"version": "3.0.0",
|
"version": "4.0.0",
|
||||||
"description": "Network synchronization for multiplayer games",
|
"description": "Network synchronization for multiplayer games",
|
||||||
"esengine": {
|
"esengine": {
|
||||||
"plugin": true,
|
"plugin": true,
|
||||||
|
|||||||
@@ -23,7 +23,7 @@ import {
|
|||||||
decodeSnapshot,
|
decodeSnapshot,
|
||||||
decodeSpawn,
|
decodeSpawn,
|
||||||
processDespawn,
|
processDespawn,
|
||||||
registerSyncComponent,
|
GlobalComponentRegistry,
|
||||||
type DecodeSnapshotResult,
|
type DecodeSnapshotResult,
|
||||||
type DecodeSpawnResult,
|
type DecodeSpawnResult,
|
||||||
} from '@esengine/ecs-framework';
|
} from '@esengine/ecs-framework';
|
||||||
@@ -166,10 +166,7 @@ export class ComponentSyncSystem extends EntitySystem {
|
|||||||
* @en Client needs to call this to register all component types to be synced
|
* @en Client needs to call this to register all component types to be synced
|
||||||
*/
|
*/
|
||||||
public registerComponent<T extends new () => any>(componentClass: T): void {
|
public registerComponent<T extends new () => any>(componentClass: T): void {
|
||||||
const metadata: SyncMetadata | undefined = (componentClass as any)[SYNC_METADATA];
|
GlobalComponentRegistry.register(componentClass as any);
|
||||||
if (metadata) {
|
|
||||||
registerSyncComponent(metadata.typeId, componentClass as any);
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
|
||||||
// =========================================================================
|
// =========================================================================
|
||||||
|
|||||||
@@ -1,5 +1,21 @@
|
|||||||
# @esengine/pathfinding
|
# @esengine/pathfinding
|
||||||
|
|
||||||
|
## 3.0.0
|
||||||
|
|
||||||
|
### Patch Changes
|
||||||
|
|
||||||
|
- Updated dependencies []:
|
||||||
|
- @esengine/ecs-framework@2.6.0
|
||||||
|
- @esengine/blueprint@3.0.0
|
||||||
|
|
||||||
|
## 2.0.1
|
||||||
|
|
||||||
|
### Patch Changes
|
||||||
|
|
||||||
|
- Updated dependencies [[`a08a84b`](https://github.com/esengine/esengine/commit/a08a84b7db28e1140cbc637d442552747ad81c76)]:
|
||||||
|
- @esengine/ecs-framework@2.5.1
|
||||||
|
- @esengine/blueprint@2.0.1
|
||||||
|
|
||||||
## 2.0.0
|
## 2.0.0
|
||||||
|
|
||||||
### Patch Changes
|
### Patch Changes
|
||||||
|
|||||||
@@ -1,6 +1,6 @@
|
|||||||
{
|
{
|
||||||
"name": "@esengine/pathfinding",
|
"name": "@esengine/pathfinding",
|
||||||
"version": "2.0.0",
|
"version": "3.0.0",
|
||||||
"description": "寻路系统 | Pathfinding System - A*, Grid, NavMesh",
|
"description": "寻路系统 | Pathfinding System - A*, Grid, NavMesh",
|
||||||
"type": "module",
|
"type": "module",
|
||||||
"main": "./dist/index.js",
|
"main": "./dist/index.js",
|
||||||
|
|||||||
@@ -1,5 +1,21 @@
|
|||||||
# @esengine/procgen
|
# @esengine/procgen
|
||||||
|
|
||||||
|
## 3.0.0
|
||||||
|
|
||||||
|
### Patch Changes
|
||||||
|
|
||||||
|
- Updated dependencies []:
|
||||||
|
- @esengine/ecs-framework@2.6.0
|
||||||
|
- @esengine/blueprint@3.0.0
|
||||||
|
|
||||||
|
## 2.0.1
|
||||||
|
|
||||||
|
### Patch Changes
|
||||||
|
|
||||||
|
- Updated dependencies [[`a08a84b`](https://github.com/esengine/esengine/commit/a08a84b7db28e1140cbc637d442552747ad81c76)]:
|
||||||
|
- @esengine/ecs-framework@2.5.1
|
||||||
|
- @esengine/blueprint@2.0.1
|
||||||
|
|
||||||
## 2.0.0
|
## 2.0.0
|
||||||
|
|
||||||
### Patch Changes
|
### Patch Changes
|
||||||
|
|||||||
@@ -1,6 +1,6 @@
|
|||||||
{
|
{
|
||||||
"name": "@esengine/procgen",
|
"name": "@esengine/procgen",
|
||||||
"version": "2.0.0",
|
"version": "3.0.0",
|
||||||
"description": "Procedural generation tools for ECS Framework / ECS 框架的程序化生成工具",
|
"description": "Procedural generation tools for ECS Framework / ECS 框架的程序化生成工具",
|
||||||
"type": "module",
|
"type": "module",
|
||||||
"main": "./dist/index.js",
|
"main": "./dist/index.js",
|
||||||
|
|||||||
@@ -1,5 +1,53 @@
|
|||||||
# @esengine/server
|
# @esengine/server
|
||||||
|
|
||||||
|
## 3.0.0
|
||||||
|
|
||||||
|
### Minor Changes
|
||||||
|
|
||||||
|
- feat(ecs): 添加 @NetworkEntity 装饰器,支持自动广播实体生成/销毁
|
||||||
|
|
||||||
|
### 新功能
|
||||||
|
|
||||||
|
**@NetworkEntity 装饰器**
|
||||||
|
- 标记组件为网络实体,自动广播 spawn/despawn 消息
|
||||||
|
- 支持 `autoSpawn` 和 `autoDespawn` 配置选项
|
||||||
|
- 通过事件系统(`ECSEventType.COMPONENT_ADDED` / `ECSEventType.ENTITY_DESTROYED`)实现
|
||||||
|
|
||||||
|
**ECSRoom 增强**
|
||||||
|
- 新增 `enableAutoNetworkEntity` 配置选项(默认启用)
|
||||||
|
- 自动监听组件添加和实体销毁事件
|
||||||
|
- 简化 GameRoom 实现,无需手动回调
|
||||||
|
|
||||||
|
### 改进
|
||||||
|
|
||||||
|
**Entity 事件**
|
||||||
|
- `Entity.destroy()` 现在发出 `entity:destroyed` 事件
|
||||||
|
- `Entity.active` 变化时发出 `entity:enabled` / `entity:disabled` 事件
|
||||||
|
- 使用 `ECSEventType` 常量替代硬编码字符串
|
||||||
|
|
||||||
|
### 使用示例
|
||||||
|
|
||||||
|
```typescript
|
||||||
|
import { Component, ECSComponent, sync, NetworkEntity } from '@esengine/ecs-framework';
|
||||||
|
|
||||||
|
@ECSComponent('Enemy')
|
||||||
|
@NetworkEntity('Enemy')
|
||||||
|
class EnemyComponent extends Component {
|
||||||
|
@sync('float32') x: number = 0;
|
||||||
|
@sync('float32') y: number = 0;
|
||||||
|
}
|
||||||
|
|
||||||
|
// 服务端
|
||||||
|
const entity = scene.createEntity('Enemy');
|
||||||
|
entity.addComponent(new EnemyComponent()); // 自动广播 spawn
|
||||||
|
entity.destroy(); // 自动广播 despawn
|
||||||
|
```
|
||||||
|
|
||||||
|
### Patch Changes
|
||||||
|
|
||||||
|
- Updated dependencies []:
|
||||||
|
- @esengine/ecs-framework@2.6.0
|
||||||
|
|
||||||
## 2.0.0
|
## 2.0.0
|
||||||
|
|
||||||
### Minor Changes
|
### Minor Changes
|
||||||
|
|||||||
@@ -1,6 +1,6 @@
|
|||||||
{
|
{
|
||||||
"name": "@esengine/server",
|
"name": "@esengine/server",
|
||||||
"version": "2.0.0",
|
"version": "3.0.0",
|
||||||
"description": "Game server framework for ESEngine with file-based routing",
|
"description": "Game server framework for ESEngine with file-based routing",
|
||||||
"type": "module",
|
"type": "module",
|
||||||
"main": "./dist/index.js",
|
"main": "./dist/index.js",
|
||||||
@@ -51,7 +51,7 @@
|
|||||||
"peerDependencies": {
|
"peerDependencies": {
|
||||||
"ws": ">=8.0.0",
|
"ws": ">=8.0.0",
|
||||||
"jsonwebtoken": ">=9.0.0",
|
"jsonwebtoken": ">=9.0.0",
|
||||||
"@esengine/ecs-framework": ">=2.5.0"
|
"@esengine/ecs-framework": ">=2.6.0"
|
||||||
},
|
},
|
||||||
"peerDependenciesMeta": {
|
"peerDependenciesMeta": {
|
||||||
"jsonwebtoken": {
|
"jsonwebtoken": {
|
||||||
|
|||||||
@@ -20,6 +20,11 @@ import {
|
|||||||
encodeSpawn,
|
encodeSpawn,
|
||||||
encodeDespawn,
|
encodeDespawn,
|
||||||
initChangeTracker,
|
initChangeTracker,
|
||||||
|
// Network Entity
|
||||||
|
NETWORK_ENTITY_METADATA,
|
||||||
|
type NetworkEntityMetadata,
|
||||||
|
// Events
|
||||||
|
ECSEventType,
|
||||||
} from '@esengine/ecs-framework';
|
} from '@esengine/ecs-framework';
|
||||||
|
|
||||||
import { Room, type RoomOptions } from '../room/Room.js';
|
import { Room, type RoomOptions } from '../room/Room.js';
|
||||||
@@ -45,11 +50,19 @@ export interface ECSRoomConfig {
|
|||||||
* @en Whether to enable delta sync
|
* @en Whether to enable delta sync
|
||||||
*/
|
*/
|
||||||
enableDeltaSync: boolean;
|
enableDeltaSync: boolean;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* @zh 是否启用自动网络实体广播(基于 @NetworkEntity 装饰器)
|
||||||
|
* @en Whether to enable automatic network entity broadcasting (based on @NetworkEntity decorator)
|
||||||
|
* @default true
|
||||||
|
*/
|
||||||
|
enableAutoNetworkEntity: boolean;
|
||||||
}
|
}
|
||||||
|
|
||||||
const DEFAULT_ECS_CONFIG: ECSRoomConfig = {
|
const DEFAULT_ECS_CONFIG: ECSRoomConfig = {
|
||||||
syncInterval: 50, // 20 Hz
|
syncInterval: 50, // 20 Hz
|
||||||
enableDeltaSync: true,
|
enableDeltaSync: true,
|
||||||
|
enableAutoNetworkEntity: true,
|
||||||
};
|
};
|
||||||
|
|
||||||
/**
|
/**
|
||||||
@@ -116,6 +129,12 @@ export abstract class ECSRoom<TState = any, TPlayerData = Record<string, unknown
|
|||||||
*/
|
*/
|
||||||
private readonly _playerEntities: Map<string, Entity> = new Map();
|
private readonly _playerEntities: Map<string, Entity> = new Map();
|
||||||
|
|
||||||
|
/**
|
||||||
|
* @zh 网络实体映射(实体 ID -> prefabType)
|
||||||
|
* @en Network entity mapping (entity ID -> prefabType)
|
||||||
|
*/
|
||||||
|
private readonly _networkEntities: Map<number, string> = new Map();
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* @zh 上次同步时间
|
* @zh 上次同步时间
|
||||||
* @en Last sync time
|
* @en Last sync time
|
||||||
@@ -131,6 +150,47 @@ export abstract class ECSRoom<TState = any, TPlayerData = Record<string, unknown
|
|||||||
this.scene = this.world.createScene('game');
|
this.scene = this.world.createScene('game');
|
||||||
this.world.setSceneActive('game', true);
|
this.world.setSceneActive('game', true);
|
||||||
this.world.start();
|
this.world.start();
|
||||||
|
|
||||||
|
// 设置自动网络实体广播
|
||||||
|
if (this.ecsConfig.enableAutoNetworkEntity) {
|
||||||
|
this._setupAutoNetworkEntity();
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* @zh 设置自动网络实体广播
|
||||||
|
* @en Setup automatic network entity broadcasting
|
||||||
|
*/
|
||||||
|
private _setupAutoNetworkEntity(): void {
|
||||||
|
// 监听组件添加事件,自动广播 spawn
|
||||||
|
this.scene.eventSystem.on(ECSEventType.COMPONENT_ADDED, (event: any) => {
|
||||||
|
const { entity, component } = event;
|
||||||
|
const metadata: NetworkEntityMetadata | undefined =
|
||||||
|
(component.constructor as any)[NETWORK_ENTITY_METADATA];
|
||||||
|
|
||||||
|
if (metadata?.autoSpawn) {
|
||||||
|
// 避免重复广播同一实体
|
||||||
|
if (!this._networkEntities.has(entity.id)) {
|
||||||
|
this._networkEntities.set(entity.id, metadata.prefabType);
|
||||||
|
this.broadcastSpawn(entity, metadata.prefabType);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
// 记录需要自动 despawn 的实体
|
||||||
|
if (metadata?.autoDespawn && !this._networkEntities.has(entity.id)) {
|
||||||
|
this._networkEntities.set(entity.id, metadata.prefabType);
|
||||||
|
}
|
||||||
|
});
|
||||||
|
|
||||||
|
// 监听实体销毁事件,自动广播 despawn
|
||||||
|
this.scene.eventSystem.on(ECSEventType.ENTITY_DESTROYED, (event: any) => {
|
||||||
|
const { entityId } = event;
|
||||||
|
if (this._networkEntities.has(entityId)) {
|
||||||
|
const despawnData = encodeDespawn(entityId);
|
||||||
|
this.broadcastBinary(despawnData);
|
||||||
|
this._networkEntities.delete(entityId);
|
||||||
|
}
|
||||||
|
});
|
||||||
}
|
}
|
||||||
|
|
||||||
// =========================================================================
|
// =========================================================================
|
||||||
|
|||||||
@@ -32,6 +32,9 @@
|
|||||||
export { ECSRoom } from './ECSRoom.js';
|
export { ECSRoom } from './ECSRoom.js';
|
||||||
export type { ECSRoomConfig } from './ECSRoom.js';
|
export type { ECSRoomConfig } from './ECSRoom.js';
|
||||||
|
|
||||||
|
// Re-export Player for convenience
|
||||||
|
export { Player, type IPlayer } from '../room/Player.js';
|
||||||
|
|
||||||
// Re-export commonly used ECS types for convenience
|
// Re-export commonly used ECS types for convenience
|
||||||
export type {
|
export type {
|
||||||
Entity,
|
Entity,
|
||||||
|
|||||||
@@ -1,5 +1,21 @@
|
|||||||
# @esengine/spatial
|
# @esengine/spatial
|
||||||
|
|
||||||
|
## 3.0.0
|
||||||
|
|
||||||
|
### Patch Changes
|
||||||
|
|
||||||
|
- Updated dependencies []:
|
||||||
|
- @esengine/ecs-framework@2.6.0
|
||||||
|
- @esengine/blueprint@3.0.0
|
||||||
|
|
||||||
|
## 2.0.1
|
||||||
|
|
||||||
|
### Patch Changes
|
||||||
|
|
||||||
|
- Updated dependencies [[`a08a84b`](https://github.com/esengine/esengine/commit/a08a84b7db28e1140cbc637d442552747ad81c76)]:
|
||||||
|
- @esengine/ecs-framework@2.5.1
|
||||||
|
- @esengine/blueprint@2.0.1
|
||||||
|
|
||||||
## 2.0.0
|
## 2.0.0
|
||||||
|
|
||||||
### Patch Changes
|
### Patch Changes
|
||||||
|
|||||||
@@ -1,6 +1,6 @@
|
|||||||
{
|
{
|
||||||
"name": "@esengine/spatial",
|
"name": "@esengine/spatial",
|
||||||
"version": "2.0.0",
|
"version": "3.0.0",
|
||||||
"description": "Spatial query and indexing system for ECS Framework / ECS 框架的空间查询和索引系统",
|
"description": "Spatial query and indexing system for ECS Framework / ECS 框架的空间查询和索引系统",
|
||||||
"type": "module",
|
"type": "module",
|
||||||
"main": "./dist/index.js",
|
"main": "./dist/index.js",
|
||||||
|
|||||||
@@ -1,5 +1,21 @@
|
|||||||
# @esengine/timer
|
# @esengine/timer
|
||||||
|
|
||||||
|
## 3.0.0
|
||||||
|
|
||||||
|
### Patch Changes
|
||||||
|
|
||||||
|
- Updated dependencies []:
|
||||||
|
- @esengine/ecs-framework@2.6.0
|
||||||
|
- @esengine/blueprint@3.0.0
|
||||||
|
|
||||||
|
## 2.0.1
|
||||||
|
|
||||||
|
### Patch Changes
|
||||||
|
|
||||||
|
- Updated dependencies [[`a08a84b`](https://github.com/esengine/esengine/commit/a08a84b7db28e1140cbc637d442552747ad81c76)]:
|
||||||
|
- @esengine/ecs-framework@2.5.1
|
||||||
|
- @esengine/blueprint@2.0.1
|
||||||
|
|
||||||
## 2.0.0
|
## 2.0.0
|
||||||
|
|
||||||
### Patch Changes
|
### Patch Changes
|
||||||
|
|||||||
@@ -1,6 +1,6 @@
|
|||||||
{
|
{
|
||||||
"name": "@esengine/timer",
|
"name": "@esengine/timer",
|
||||||
"version": "2.0.0",
|
"version": "3.0.0",
|
||||||
"description": "Timer and cooldown system for ECS Framework / ECS 框架的定时器和冷却系统",
|
"description": "Timer and cooldown system for ECS Framework / ECS 框架的定时器和冷却系统",
|
||||||
"type": "module",
|
"type": "module",
|
||||||
"main": "./dist/index.js",
|
"main": "./dist/index.js",
|
||||||
|
|||||||
@@ -1,5 +1,12 @@
|
|||||||
# @esengine/transaction
|
# @esengine/transaction
|
||||||
|
|
||||||
|
## 2.0.4
|
||||||
|
|
||||||
|
### Patch Changes
|
||||||
|
|
||||||
|
- Updated dependencies []:
|
||||||
|
- @esengine/server@3.0.0
|
||||||
|
|
||||||
## 2.0.3
|
## 2.0.3
|
||||||
|
|
||||||
### Patch Changes
|
### Patch Changes
|
||||||
|
|||||||
@@ -1,6 +1,6 @@
|
|||||||
{
|
{
|
||||||
"name": "@esengine/transaction",
|
"name": "@esengine/transaction",
|
||||||
"version": "2.0.3",
|
"version": "2.0.4",
|
||||||
"description": "Game transaction system with distributed support | 游戏事务系统,支持分布式事务",
|
"description": "Game transaction system with distributed support | 游戏事务系统,支持分布式事务",
|
||||||
"type": "module",
|
"type": "module",
|
||||||
"main": "./dist/index.js",
|
"main": "./dist/index.js",
|
||||||
|
|||||||
@@ -121,9 +121,9 @@ export class WeChatRapier2DLoader implements IWasmLibraryLoader<RapierModule> {
|
|||||||
// 导入 Rapier2D 标准版
|
// 导入 Rapier2D 标准版
|
||||||
const RAPIER = await import('@esengine/rapier2d');
|
const RAPIER = await import('@esengine/rapier2d');
|
||||||
|
|
||||||
// 初始化 WASM - 标准版需要提供 WASM 路径
|
// 初始化 WASM - WASM 已经作为 base64 嵌入到包中
|
||||||
const wasmPath = this._config.minigame?.wasmPath || 'wasm/rapier_wasm2d_bg.wasm';
|
// Initialize WASM - WASM is embedded as base64 in the package
|
||||||
await RAPIER.init(wasmPath);
|
await RAPIER.init();
|
||||||
|
|
||||||
return RAPIER;
|
return RAPIER;
|
||||||
} finally {
|
} finally {
|
||||||
|
|||||||
@@ -53,10 +53,9 @@ export class WebRapier2DLoader implements IWasmLibraryLoader<RapierModule> {
|
|||||||
// 动态导入标准版
|
// 动态导入标准版
|
||||||
const RAPIER = await import('@esengine/rapier2d');
|
const RAPIER = await import('@esengine/rapier2d');
|
||||||
|
|
||||||
// 初始化 WASM - 标准版需要提供 WASM 路径
|
// 初始化 WASM - WASM 已经作为 base64 嵌入到包中
|
||||||
// 构建时 WASM 文件会被复制到 wasm/ 目录
|
// Initialize WASM - WASM is embedded as base64 in the package
|
||||||
const wasmPath = this._config.web?.wasmPath || 'wasm/rapier_wasm2d_bg.wasm';
|
await RAPIER.init();
|
||||||
await RAPIER.init(wasmPath);
|
|
||||||
|
|
||||||
console.log(`[${this._config.name}] 加载完成`);
|
console.log(`[${this._config.name}] 加载完成`);
|
||||||
return RAPIER;
|
return RAPIER;
|
||||||
|
|||||||
@@ -19,11 +19,13 @@
|
|||||||
],
|
],
|
||||||
"scripts": {
|
"scripts": {
|
||||||
"gen:src": "node scripts/gen-src.mjs",
|
"gen:src": "node scripts/gen-src.mjs",
|
||||||
"build": "pnpm gen:src && tsup",
|
"build": "tsup",
|
||||||
"clean": "rimraf dist src"
|
"build:regen": "pnpm gen:src && tsup",
|
||||||
|
"clean": "rimraf dist"
|
||||||
},
|
},
|
||||||
"license": "Apache-2.0",
|
"license": "Apache-2.0",
|
||||||
"devDependencies": {
|
"devDependencies": {
|
||||||
|
"base64-js": "^1.5.1",
|
||||||
"rimraf": "^5.0.0",
|
"rimraf": "^5.0.0",
|
||||||
"tsup": "^8.0.0",
|
"tsup": "^8.0.0",
|
||||||
"typescript": "^5.0.0"
|
"typescript": "^5.0.0"
|
||||||
|
|||||||
@@ -91,9 +91,8 @@ export class KinematicCharacterController {
|
|||||||
*/
|
*/
|
||||||
public setUp(vector: Vector) {
|
public setUp(vector: Vector) {
|
||||||
let rawVect = VectorOps.intoRaw(vector);
|
let rawVect = VectorOps.intoRaw(vector);
|
||||||
const result = this.raw.setUp(rawVect);
|
return this.raw.setUp(rawVect);
|
||||||
rawVect.free();
|
rawVect.free();
|
||||||
return result;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
public applyImpulsesToDynamicBodies(): boolean {
|
public applyImpulsesToDynamicBodies(): boolean {
|
||||||
|
|||||||
@@ -28,9 +28,6 @@ export class DynamicRayCastVehicleController {
|
|||||||
bodies: RigidBodySet,
|
bodies: RigidBodySet,
|
||||||
colliders: ColliderSet,
|
colliders: ColliderSet,
|
||||||
) {
|
) {
|
||||||
if (typeof RawDynamicRayCastVehicleController === 'undefined') {
|
|
||||||
throw new Error('DynamicRayCastVehicleController is not available in 2D mode');
|
|
||||||
}
|
|
||||||
this.raw = new RawDynamicRayCastVehicleController(chassis.handle);
|
this.raw = new RawDynamicRayCastVehicleController(chassis.handle);
|
||||||
this.broadPhase = broadPhase;
|
this.broadPhase = broadPhase;
|
||||||
this.narrowPhase = narrowPhase;
|
this.narrowPhase = narrowPhase;
|
||||||
|
|||||||
@@ -1,60 +1,12 @@
|
|||||||
/**
|
// @ts-ignore
|
||||||
* RAPIER initialization module with dynamic WASM loading support.
|
import wasmBase64 from "../pkg/rapier_wasm2d_bg.wasm";
|
||||||
* RAPIER 初始化模块,支持动态 WASM 加载。
|
|
||||||
*/
|
|
||||||
|
|
||||||
import wasmInit from "../pkg/rapier_wasm2d";
|
import wasmInit from "../pkg/rapier_wasm2d";
|
||||||
|
import base64 from "base64-js";
|
||||||
/**
|
|
||||||
* Input types for WASM initialization.
|
|
||||||
* WASM 初始化的输入类型。
|
|
||||||
*/
|
|
||||||
export type InitInput =
|
|
||||||
| RequestInfo // URL string or Request object
|
|
||||||
| URL // URL object
|
|
||||||
| Response // Fetch Response object
|
|
||||||
| BufferSource // ArrayBuffer or TypedArray
|
|
||||||
| WebAssembly.Module; // Pre-compiled module
|
|
||||||
|
|
||||||
let initialized = false;
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Initializes RAPIER.
|
* Initializes RAPIER.
|
||||||
* Has to be called and awaited before using any library methods.
|
* Has to be called and awaited before using any library methods.
|
||||||
*
|
|
||||||
* 初始化 RAPIER。
|
|
||||||
* 必须在使用任何库方法之前调用并等待。
|
|
||||||
*
|
|
||||||
* @param input - WASM source (required). Can be URL, Response, ArrayBuffer, etc.
|
|
||||||
* WASM 源(必需)。可以是 URL、Response、ArrayBuffer 等。
|
|
||||||
*
|
|
||||||
* @example
|
|
||||||
* // Load from URL | 从 URL 加载
|
|
||||||
* await RAPIER.init('wasm/rapier_wasm2d_bg.wasm');
|
|
||||||
*
|
|
||||||
* @example
|
|
||||||
* // Load from fetch response | 从 fetch 响应加载
|
|
||||||
* const response = await fetch('wasm/rapier_wasm2d_bg.wasm');
|
|
||||||
* await RAPIER.init(response);
|
|
||||||
*
|
|
||||||
* @example
|
|
||||||
* // Load from ArrayBuffer | 从 ArrayBuffer 加载
|
|
||||||
* const buffer = await fetch('wasm/rapier_wasm2d_bg.wasm').then(r => r.arrayBuffer());
|
|
||||||
* await RAPIER.init(buffer);
|
|
||||||
*/
|
*/
|
||||||
export async function init(input?: InitInput): Promise<void> {
|
export async function init() {
|
||||||
if (initialized) {
|
await wasmInit(base64.toByteArray(wasmBase64 as unknown as string).buffer);
|
||||||
return;
|
|
||||||
}
|
|
||||||
|
|
||||||
await wasmInit(input);
|
|
||||||
initialized = true;
|
|
||||||
}
|
|
||||||
|
|
||||||
/**
|
|
||||||
* Check if RAPIER is already initialized.
|
|
||||||
* 检查 RAPIER 是否已初始化。
|
|
||||||
*/
|
|
||||||
export function isInitialized(): boolean {
|
|
||||||
return initialized;
|
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -28,7 +28,7 @@ export class VectorOps {
|
|||||||
}
|
}
|
||||||
|
|
||||||
// FIXME: type ram: RawVector?
|
// FIXME: type ram: RawVector?
|
||||||
public static fromRaw(raw: RawVector): Vector | null {
|
public static fromRaw(raw: RawVector): Vector {
|
||||||
if (!raw) return null;
|
if (!raw) return null;
|
||||||
|
|
||||||
let res = VectorOps.new(raw.x, raw.y);
|
let res = VectorOps.new(raw.x, raw.y);
|
||||||
@@ -56,7 +56,7 @@ export class RotationOps {
|
|||||||
return 0.0;
|
return 0.0;
|
||||||
}
|
}
|
||||||
|
|
||||||
public static fromRaw(raw: RawRotation): Rotation | null {
|
public static fromRaw(raw: RawRotation): Rotation {
|
||||||
if (!raw) return null;
|
if (!raw) return null;
|
||||||
|
|
||||||
let res = raw.angle;
|
let res = raw.angle;
|
||||||
|
|||||||
@@ -7,4 +7,7 @@ export default defineConfig({
|
|||||||
sourcemap: true,
|
sourcemap: true,
|
||||||
clean: true,
|
clean: true,
|
||||||
external: ["../pkg/rapier_wasm2d.js"],
|
external: ["../pkg/rapier_wasm2d.js"],
|
||||||
|
loader: {
|
||||||
|
".wasm": "base64",
|
||||||
|
},
|
||||||
});
|
});
|
||||||
|
|||||||
@@ -1,5 +1,27 @@
|
|||||||
# @esengine/demos
|
# @esengine/demos
|
||||||
|
|
||||||
|
## 1.0.7
|
||||||
|
|
||||||
|
### Patch Changes
|
||||||
|
|
||||||
|
- Updated dependencies []:
|
||||||
|
- @esengine/fsm@3.0.0
|
||||||
|
- @esengine/pathfinding@3.0.0
|
||||||
|
- @esengine/procgen@3.0.0
|
||||||
|
- @esengine/spatial@3.0.0
|
||||||
|
- @esengine/timer@3.0.0
|
||||||
|
|
||||||
|
## 1.0.6
|
||||||
|
|
||||||
|
### Patch Changes
|
||||||
|
|
||||||
|
- Updated dependencies []:
|
||||||
|
- @esengine/fsm@2.0.1
|
||||||
|
- @esengine/pathfinding@2.0.1
|
||||||
|
- @esengine/procgen@2.0.1
|
||||||
|
- @esengine/spatial@2.0.1
|
||||||
|
- @esengine/timer@2.0.1
|
||||||
|
|
||||||
## 1.0.5
|
## 1.0.5
|
||||||
|
|
||||||
### Patch Changes
|
### Patch Changes
|
||||||
|
|||||||
@@ -1,6 +1,6 @@
|
|||||||
{
|
{
|
||||||
"name": "@esengine/demos",
|
"name": "@esengine/demos",
|
||||||
"version": "1.0.5",
|
"version": "1.0.7",
|
||||||
"private": true,
|
"private": true,
|
||||||
"description": "Demo tests for ESEngine modules documentation",
|
"description": "Demo tests for ESEngine modules documentation",
|
||||||
"type": "module",
|
"type": "module",
|
||||||
|
|||||||
72
pnpm-lock.yaml
generated
72
pnpm-lock.yaml
generated
@@ -569,6 +569,9 @@ importers:
|
|||||||
specifier: workspace:*
|
specifier: workspace:*
|
||||||
version: link:../../../framework/behavior-tree
|
version: link:../../../framework/behavior-tree
|
||||||
devDependencies:
|
devDependencies:
|
||||||
|
'@esengine/asset-system':
|
||||||
|
specifier: workspace:*
|
||||||
|
version: link:../../../engine/asset-system
|
||||||
'@esengine/build-config':
|
'@esengine/build-config':
|
||||||
specifier: workspace:*
|
specifier: workspace:*
|
||||||
version: link:../../../tools/build-config
|
version: link:../../../tools/build-config
|
||||||
@@ -1489,6 +1492,9 @@ importers:
|
|||||||
rollup-plugin-dts:
|
rollup-plugin-dts:
|
||||||
specifier: ^6.2.1
|
specifier: ^6.2.1
|
||||||
version: 6.3.0(rollup@4.54.0)(typescript@5.9.3)
|
version: 6.3.0(rollup@4.54.0)(typescript@5.9.3)
|
||||||
|
rollup-plugin-sourcemaps:
|
||||||
|
specifier: ^0.6.3
|
||||||
|
version: 0.6.3(@types/node@20.19.27)(rollup@4.54.0)
|
||||||
ts-jest:
|
ts-jest:
|
||||||
specifier: ^29.4.0
|
specifier: ^29.4.0
|
||||||
version: 29.4.6(@babel/core@7.28.5)(@jest/transform@29.7.0)(@jest/types@29.6.3)(babel-jest@29.7.0(@babel/core@7.28.5))(jest-util@29.7.0)(jest@29.7.0(@types/node@20.19.27)(ts-node@10.9.2(@swc/core@1.15.7(@swc/helpers@0.5.18))(@swc/wasm@1.15.7)(@types/node@20.19.27)(typescript@5.9.3)))(typescript@5.9.3)
|
version: 29.4.6(@babel/core@7.28.5)(@jest/transform@29.7.0)(@jest/types@29.6.3)(babel-jest@29.7.0(@babel/core@7.28.5))(jest-util@29.7.0)(jest@29.7.0(@types/node@20.19.27)(ts-node@10.9.2(@swc/core@1.15.7(@swc/helpers@0.5.18))(@swc/wasm@1.15.7)(@types/node@20.19.27)(typescript@5.9.3)))(typescript@5.9.3)
|
||||||
@@ -1861,6 +1867,9 @@ importers:
|
|||||||
|
|
||||||
packages/physics/rapier2d:
|
packages/physics/rapier2d:
|
||||||
devDependencies:
|
devDependencies:
|
||||||
|
base64-js:
|
||||||
|
specifier: ^1.5.1
|
||||||
|
version: 1.5.1
|
||||||
rimraf:
|
rimraf:
|
||||||
specifier: ^5.0.0
|
specifier: ^5.0.0
|
||||||
version: 5.0.10
|
version: 5.0.10
|
||||||
@@ -4484,6 +4493,12 @@ packages:
|
|||||||
rollup:
|
rollup:
|
||||||
optional: true
|
optional: true
|
||||||
|
|
||||||
|
'@rollup/pluginutils@3.1.0':
|
||||||
|
resolution: {integrity: sha512-GksZ6pr6TpIjHm8h9lSQ8pi8BE9VeubNT0OMJ3B5uZJ8pz73NPiqOtCog/x2/QzM1ENChPKxMDhiQuRHsqc+lg==}
|
||||||
|
engines: {node: '>= 8.0.0'}
|
||||||
|
peerDependencies:
|
||||||
|
rollup: ^1.20.0||^2.0.0
|
||||||
|
|
||||||
'@rollup/pluginutils@5.3.0':
|
'@rollup/pluginutils@5.3.0':
|
||||||
resolution: {integrity: sha512-5EdhGZtnu3V88ces7s53hhfK5KSASnJZv8Lulpc04cWO3REESroJXg73DFsOmgbU2BhwV0E20bu2IDZb3VKW4Q==}
|
resolution: {integrity: sha512-5EdhGZtnu3V88ces7s53hhfK5KSASnJZv8Lulpc04cWO3REESroJXg73DFsOmgbU2BhwV0E20bu2IDZb3VKW4Q==}
|
||||||
engines: {node: '>=14.0.0'}
|
engines: {node: '>=14.0.0'}
|
||||||
@@ -5150,6 +5165,9 @@ packages:
|
|||||||
'@types/estree-jsx@1.0.5':
|
'@types/estree-jsx@1.0.5':
|
||||||
resolution: {integrity: sha512-52CcUVNFyfb1A2ALocQw/Dd1BQFNmSdkuC3BkZ6iqhdMfQz7JWOFRuJFloOzjk+6WijU56m9oKXFAXc7o3Towg==}
|
resolution: {integrity: sha512-52CcUVNFyfb1A2ALocQw/Dd1BQFNmSdkuC3BkZ6iqhdMfQz7JWOFRuJFloOzjk+6WijU56m9oKXFAXc7o3Towg==}
|
||||||
|
|
||||||
|
'@types/estree@0.0.39':
|
||||||
|
resolution: {integrity: sha512-EYNwp3bU+98cpU4lAWYYL7Zz+2gryWH1qbdDTidVd6hkiR6weksdbMadyXKXNPEkQFhXM+hVO9ZygomHXp+AIw==}
|
||||||
|
|
||||||
'@types/estree@1.0.8':
|
'@types/estree@1.0.8':
|
||||||
resolution: {integrity: sha512-dWHzHa2WqEXI/O1E9OjrocMTKJl2mSrEolh1Iomrv6U+JuNwaHXsXx9bLu5gG7BUWFIN0skIQJQ/L1rIex4X6w==}
|
resolution: {integrity: sha512-dWHzHa2WqEXI/O1E9OjrocMTKJl2mSrEolh1Iomrv6U+JuNwaHXsXx9bLu5gG7BUWFIN0skIQJQ/L1rIex4X6w==}
|
||||||
|
|
||||||
@@ -5791,6 +5809,11 @@ packages:
|
|||||||
asynckit@0.4.0:
|
asynckit@0.4.0:
|
||||||
resolution: {integrity: sha512-Oei9OH4tRh0YqU3GxhX79dM/mwVgvbZJaSNaRk+bshkj0S5cfHcgYakreBjrHwatXKbz+IoIdYLxrKim2MjW0Q==}
|
resolution: {integrity: sha512-Oei9OH4tRh0YqU3GxhX79dM/mwVgvbZJaSNaRk+bshkj0S5cfHcgYakreBjrHwatXKbz+IoIdYLxrKim2MjW0Q==}
|
||||||
|
|
||||||
|
atob@2.1.2:
|
||||||
|
resolution: {integrity: sha512-Wm6ukoaOGJi/73p/cl2GvLjTI5JM1k/O14isD73YML8StrH/7/lRFgmg8nICZgD3bZZvjwCGxtMOD3wWNAu8cg==}
|
||||||
|
engines: {node: '>= 4.5.0'}
|
||||||
|
hasBin: true
|
||||||
|
|
||||||
axios@1.13.2:
|
axios@1.13.2:
|
||||||
resolution: {integrity: sha512-VPk9ebNqPcy5lRGuSlKx752IlDatOjT9paPlm8A7yOuW2Fbvp4X3JznJtT4f0GzGLLiWE9W8onz51SqLYwzGaA==}
|
resolution: {integrity: sha512-VPk9ebNqPcy5lRGuSlKx752IlDatOjT9paPlm8A7yOuW2Fbvp4X3JznJtT4f0GzGLLiWE9W8onz51SqLYwzGaA==}
|
||||||
|
|
||||||
@@ -6434,6 +6457,10 @@ packages:
|
|||||||
decode-named-character-reference@1.2.0:
|
decode-named-character-reference@1.2.0:
|
||||||
resolution: {integrity: sha512-c6fcElNV6ShtZXmsgNgFFV5tVX2PaV4g+MOAkb8eXHvn6sryJBrZa9r0zV6+dtTyoCKxtDy5tyQ5ZwQuidtd+Q==}
|
resolution: {integrity: sha512-c6fcElNV6ShtZXmsgNgFFV5tVX2PaV4g+MOAkb8eXHvn6sryJBrZa9r0zV6+dtTyoCKxtDy5tyQ5ZwQuidtd+Q==}
|
||||||
|
|
||||||
|
decode-uri-component@0.2.2:
|
||||||
|
resolution: {integrity: sha512-FqUYQ+8o158GyGTrMFJms9qh3CqTKvAqgqsTnkLI8sKu0028orqBhxNMFkFen0zGyg6epACD32pjVk58ngIErQ==}
|
||||||
|
engines: {node: '>=0.10'}
|
||||||
|
|
||||||
dedent@1.5.3:
|
dedent@1.5.3:
|
||||||
resolution: {integrity: sha512-NHQtfOOW68WD8lgypbLA5oT+Bt0xXJhiYvoR6SmmNXZfpzOGXwdKWmcwG8N7PwVVWV3eF/68nmD9BaJSsTBhyQ==}
|
resolution: {integrity: sha512-NHQtfOOW68WD8lgypbLA5oT+Bt0xXJhiYvoR6SmmNXZfpzOGXwdKWmcwG8N7PwVVWV3eF/68nmD9BaJSsTBhyQ==}
|
||||||
peerDependencies:
|
peerDependencies:
|
||||||
@@ -6838,6 +6865,9 @@ packages:
|
|||||||
estree-util-visit@2.0.0:
|
estree-util-visit@2.0.0:
|
||||||
resolution: {integrity: sha512-m5KgiH85xAhhW8Wta0vShLcUvOsh3LLPI2YVwcbio1l7E09NTLL1EyMZFM1OyWowoH0skScNbhOPl4kcBgzTww==}
|
resolution: {integrity: sha512-m5KgiH85xAhhW8Wta0vShLcUvOsh3LLPI2YVwcbio1l7E09NTLL1EyMZFM1OyWowoH0skScNbhOPl4kcBgzTww==}
|
||||||
|
|
||||||
|
estree-walker@1.0.1:
|
||||||
|
resolution: {integrity: sha512-1fMXF3YP4pZZVozF8j/ZLfvnR8NSIljt56UhbZ5PeeDmmGHpgpdwQt7ITlGvYaQukCvuBRMLEiKiYC+oeIg4cg==}
|
||||||
|
|
||||||
estree-walker@2.0.2:
|
estree-walker@2.0.2:
|
||||||
resolution: {integrity: sha512-Rfkk/Mp/DL7JVje3u18FxFujQlTNR2q6QfMSMB7AvCBx91NGj/ba3kCfza0f6dVDbw7YlRf/nDrn7pQrCCyQ/w==}
|
resolution: {integrity: sha512-Rfkk/Mp/DL7JVje3u18FxFujQlTNR2q6QfMSMB7AvCBx91NGj/ba3kCfza0f6dVDbw7YlRf/nDrn7pQrCCyQ/w==}
|
||||||
|
|
||||||
@@ -9844,6 +9874,16 @@ packages:
|
|||||||
rollup: ^3.29.4 || ^4
|
rollup: ^3.29.4 || ^4
|
||||||
typescript: ^4.5 || ^5.0
|
typescript: ^4.5 || ^5.0
|
||||||
|
|
||||||
|
rollup-plugin-sourcemaps@0.6.3:
|
||||||
|
resolution: {integrity: sha512-paFu+nT1xvuO1tPFYXGe+XnQvg4Hjqv/eIhG8i5EspfYYPBKL57X7iVbfv55aNVASg3dzWvES9dmWsL2KhfByw==}
|
||||||
|
engines: {node: '>=10.0.0'}
|
||||||
|
peerDependencies:
|
||||||
|
'@types/node': '>=10.0.0'
|
||||||
|
rollup: '>=0.31.2'
|
||||||
|
peerDependenciesMeta:
|
||||||
|
'@types/node':
|
||||||
|
optional: true
|
||||||
|
|
||||||
rollup@4.54.0:
|
rollup@4.54.0:
|
||||||
resolution: {integrity: sha512-3nk8Y3a9Ea8szgKhinMlGMhGMw89mqule3KWczxhIzqudyHdCIOHw8WJlj/r329fACjKLEh13ZSk7oE22kyeIw==}
|
resolution: {integrity: sha512-3nk8Y3a9Ea8szgKhinMlGMhGMw89mqule3KWczxhIzqudyHdCIOHw8WJlj/r329fACjKLEh13ZSk7oE22kyeIw==}
|
||||||
engines: {node: '>=18.0.0', npm: '>=8.0.0'}
|
engines: {node: '>=18.0.0', npm: '>=8.0.0'}
|
||||||
@@ -10043,6 +10083,10 @@ packages:
|
|||||||
resolution: {integrity: sha512-UXWMKhLOwVKb728IUtQPXxfYU+usdybtUrK/8uGE8CQMvrhOpwvzDBwj0QhSL7MQc7vIsISBG8VQ8+IDQxpfQA==}
|
resolution: {integrity: sha512-UXWMKhLOwVKb728IUtQPXxfYU+usdybtUrK/8uGE8CQMvrhOpwvzDBwj0QhSL7MQc7vIsISBG8VQ8+IDQxpfQA==}
|
||||||
engines: {node: '>=0.10.0'}
|
engines: {node: '>=0.10.0'}
|
||||||
|
|
||||||
|
source-map-resolve@0.6.0:
|
||||||
|
resolution: {integrity: sha512-KXBr9d/fO/bWo97NXsPIAW1bFSBOuCnjbNTBMO7N59hsv5i9yzRDfcYwwt0l04+VqnKC+EwzvJZIP/qkuMgR/w==}
|
||||||
|
deprecated: See https://github.com/lydell/source-map-resolve#deprecated
|
||||||
|
|
||||||
source-map-support@0.5.13:
|
source-map-support@0.5.13:
|
||||||
resolution: {integrity: sha512-SHSKFHadjVA5oR4PPqhtAVdcBWwRYVd6g6cAXnIbRiIwc2EhPrTuKUBdSLvlEKyIP3GCf89fltvcZiP9MMFA1w==}
|
resolution: {integrity: sha512-SHSKFHadjVA5oR4PPqhtAVdcBWwRYVd6g6cAXnIbRiIwc2EhPrTuKUBdSLvlEKyIP3GCf89fltvcZiP9MMFA1w==}
|
||||||
|
|
||||||
@@ -14128,6 +14172,13 @@ snapshots:
|
|||||||
optionalDependencies:
|
optionalDependencies:
|
||||||
rollup: 4.54.0
|
rollup: 4.54.0
|
||||||
|
|
||||||
|
'@rollup/pluginutils@3.1.0(rollup@4.54.0)':
|
||||||
|
dependencies:
|
||||||
|
'@types/estree': 0.0.39
|
||||||
|
estree-walker: 1.0.1
|
||||||
|
picomatch: 2.3.1
|
||||||
|
rollup: 4.54.0
|
||||||
|
|
||||||
'@rollup/pluginutils@5.3.0(rollup@4.54.0)':
|
'@rollup/pluginutils@5.3.0(rollup@4.54.0)':
|
||||||
dependencies:
|
dependencies:
|
||||||
'@types/estree': 1.0.8
|
'@types/estree': 1.0.8
|
||||||
@@ -14878,6 +14929,8 @@ snapshots:
|
|||||||
dependencies:
|
dependencies:
|
||||||
'@types/estree': 1.0.8
|
'@types/estree': 1.0.8
|
||||||
|
|
||||||
|
'@types/estree@0.0.39': {}
|
||||||
|
|
||||||
'@types/estree@1.0.8': {}
|
'@types/estree@1.0.8': {}
|
||||||
|
|
||||||
'@types/express-serve-static-core@5.1.0':
|
'@types/express-serve-static-core@5.1.0':
|
||||||
@@ -15745,6 +15798,8 @@ snapshots:
|
|||||||
|
|
||||||
asynckit@0.4.0: {}
|
asynckit@0.4.0: {}
|
||||||
|
|
||||||
|
atob@2.1.2: {}
|
||||||
|
|
||||||
axios@1.13.2:
|
axios@1.13.2:
|
||||||
dependencies:
|
dependencies:
|
||||||
follow-redirects: 1.15.11
|
follow-redirects: 1.15.11
|
||||||
@@ -16424,6 +16479,8 @@ snapshots:
|
|||||||
dependencies:
|
dependencies:
|
||||||
character-entities: 2.0.2
|
character-entities: 2.0.2
|
||||||
|
|
||||||
|
decode-uri-component@0.2.2: {}
|
||||||
|
|
||||||
dedent@1.5.3: {}
|
dedent@1.5.3: {}
|
||||||
|
|
||||||
dedent@1.7.1: {}
|
dedent@1.7.1: {}
|
||||||
@@ -16874,6 +16931,8 @@ snapshots:
|
|||||||
'@types/estree-jsx': 1.0.5
|
'@types/estree-jsx': 1.0.5
|
||||||
'@types/unist': 3.0.3
|
'@types/unist': 3.0.3
|
||||||
|
|
||||||
|
estree-walker@1.0.1: {}
|
||||||
|
|
||||||
estree-walker@2.0.2: {}
|
estree-walker@2.0.2: {}
|
||||||
|
|
||||||
estree-walker@3.0.3:
|
estree-walker@3.0.3:
|
||||||
@@ -20696,6 +20755,14 @@ snapshots:
|
|||||||
optionalDependencies:
|
optionalDependencies:
|
||||||
'@babel/code-frame': 7.27.1
|
'@babel/code-frame': 7.27.1
|
||||||
|
|
||||||
|
rollup-plugin-sourcemaps@0.6.3(@types/node@20.19.27)(rollup@4.54.0):
|
||||||
|
dependencies:
|
||||||
|
'@rollup/pluginutils': 3.1.0(rollup@4.54.0)
|
||||||
|
rollup: 4.54.0
|
||||||
|
source-map-resolve: 0.6.0
|
||||||
|
optionalDependencies:
|
||||||
|
'@types/node': 20.19.27
|
||||||
|
|
||||||
rollup@4.54.0:
|
rollup@4.54.0:
|
||||||
dependencies:
|
dependencies:
|
||||||
'@types/estree': 1.0.8
|
'@types/estree': 1.0.8
|
||||||
@@ -20990,6 +21057,11 @@ snapshots:
|
|||||||
|
|
||||||
source-map-js@1.2.1: {}
|
source-map-js@1.2.1: {}
|
||||||
|
|
||||||
|
source-map-resolve@0.6.0:
|
||||||
|
dependencies:
|
||||||
|
atob: 2.1.2
|
||||||
|
decode-uri-component: 0.2.2
|
||||||
|
|
||||||
source-map-support@0.5.13:
|
source-map-support@0.5.13:
|
||||||
dependencies:
|
dependencies:
|
||||||
buffer-from: 1.1.2
|
buffer-from: 1.1.2
|
||||||
|
|||||||
Reference in New Issue
Block a user