@esengine/ecs-framework 2.4.3 → 2.4.4
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/{dist/index.d.ts → index.d.ts} +1 -1
- package/package.json +22 -58
- package/README.md +0 -188
- package/dist/package.json +0 -47
- /package/{dist/index.cjs → index.cjs} +0 -0
- /package/{dist/index.cjs.map → index.cjs.map} +0 -0
- /package/{dist/index.es5.js → index.es5.js} +0 -0
- /package/{dist/index.es5.js.map → index.es5.js.map} +0 -0
- /package/{dist/index.mjs → index.mjs} +0 -0
- /package/{dist/index.mjs.map → index.mjs.map} +0 -0
- /package/{dist/index.umd.js → index.umd.js} +0 -0
- /package/{dist/index.umd.js.map → index.umd.js.map} +0 -0
package/package.json
CHANGED
|
@@ -1,83 +1,47 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@esengine/ecs-framework",
|
|
3
|
-
"version": "2.4.
|
|
3
|
+
"version": "2.4.4",
|
|
4
4
|
"description": "用于Laya、Cocos Creator等JavaScript游戏引擎的高性能ECS框架",
|
|
5
|
-
"main": "
|
|
6
|
-
"module": "
|
|
7
|
-
"
|
|
8
|
-
"
|
|
5
|
+
"main": "index.cjs",
|
|
6
|
+
"module": "index.mjs",
|
|
7
|
+
"unpkg": "index.umd.js",
|
|
8
|
+
"types": "index.d.ts",
|
|
9
9
|
"exports": {
|
|
10
10
|
".": {
|
|
11
|
-
"
|
|
12
|
-
"
|
|
13
|
-
"
|
|
11
|
+
"import": "./index.mjs",
|
|
12
|
+
"require": "./index.cjs",
|
|
13
|
+
"types": "./index.d.ts"
|
|
14
14
|
}
|
|
15
15
|
},
|
|
16
16
|
"files": [
|
|
17
|
-
"
|
|
17
|
+
"index.mjs",
|
|
18
|
+
"index.mjs.map",
|
|
19
|
+
"index.cjs",
|
|
20
|
+
"index.cjs.map",
|
|
21
|
+
"index.umd.js",
|
|
22
|
+
"index.umd.js.map",
|
|
23
|
+
"index.es5.js",
|
|
24
|
+
"index.es5.js.map",
|
|
25
|
+
"index.d.ts"
|
|
18
26
|
],
|
|
19
27
|
"keywords": [
|
|
20
28
|
"ecs",
|
|
21
29
|
"entity-component-system",
|
|
22
30
|
"game-engine",
|
|
23
31
|
"typescript",
|
|
32
|
+
"cocos-creator",
|
|
24
33
|
"laya",
|
|
25
|
-
"
|
|
26
|
-
"egret"
|
|
34
|
+
"rollup"
|
|
27
35
|
],
|
|
28
36
|
"author": "yhh",
|
|
29
37
|
"license": "MIT",
|
|
30
|
-
"devDependencies": {
|
|
31
|
-
"@babel/core": "^7.28.3",
|
|
32
|
-
"@babel/plugin-transform-nullish-coalescing-operator": "^7.27.1",
|
|
33
|
-
"@babel/plugin-transform-optional-chaining": "^7.27.1",
|
|
34
|
-
"@babel/preset-env": "^7.28.3",
|
|
35
|
-
"@rollup/plugin-babel": "^6.0.4",
|
|
36
|
-
"@rollup/plugin-commonjs": "^28.0.3",
|
|
37
|
-
"@rollup/plugin-node-resolve": "^16.0.1",
|
|
38
|
-
"@rollup/plugin-terser": "^0.4.4",
|
|
39
|
-
"@jest/globals": "^29.7.0",
|
|
40
|
-
"@types/jest": "^29.5.14",
|
|
41
|
-
"@types/node": "^20.19.17",
|
|
42
|
-
"@eslint/js": "^9.37.0",
|
|
43
|
-
"eslint": "^9.37.0",
|
|
44
|
-
"typescript-eslint": "^8.46.1",
|
|
45
|
-
"jest": "^29.7.0",
|
|
46
|
-
"jest-environment-jsdom": "^29.7.0",
|
|
47
|
-
"rimraf": "^5.0.0",
|
|
48
|
-
"rollup": "^4.42.0",
|
|
49
|
-
"rollup-plugin-dts": "^6.2.1",
|
|
50
|
-
"ts-jest": "^29.4.0",
|
|
51
|
-
"typescript": "^5.8.3"
|
|
52
|
-
},
|
|
53
|
-
"publishConfig": {
|
|
54
|
-
"access": "public",
|
|
55
|
-
"registry": "https://registry.npmjs.org/"
|
|
56
|
-
},
|
|
57
38
|
"repository": {
|
|
58
39
|
"type": "git",
|
|
59
40
|
"url": "https://github.com/esengine/esengine.git",
|
|
60
41
|
"directory": "packages/core"
|
|
61
42
|
},
|
|
62
|
-
"
|
|
63
|
-
"
|
|
43
|
+
"engines": {
|
|
44
|
+
"node": ">=16.0.0"
|
|
64
45
|
},
|
|
65
|
-
"
|
|
66
|
-
"clean": "rimraf bin dist tsconfig.tsbuildinfo",
|
|
67
|
-
"build:ts": "tsc",
|
|
68
|
-
"prebuild": "npm run clean",
|
|
69
|
-
"build": "npm run build:ts && node build-rollup.cjs",
|
|
70
|
-
"build:watch": "tsc --watch",
|
|
71
|
-
"rebuild": "npm run clean && npm run build",
|
|
72
|
-
"build:npm": "npm run build",
|
|
73
|
-
"test": "jest --config jest.config.cjs",
|
|
74
|
-
"test:watch": "jest --watch --config jest.config.cjs",
|
|
75
|
-
"test:performance": "jest --config jest.performance.config.cjs",
|
|
76
|
-
"test:coverage": "jest --coverage --config jest.config.cjs",
|
|
77
|
-
"test:ci": "jest --ci --coverage --config jest.config.cjs",
|
|
78
|
-
"test:clear": "jest --clearCache",
|
|
79
|
-
"type-check": "npx tsc --noEmit",
|
|
80
|
-
"lint": "eslint \"src/**/*.{ts,tsx}\"",
|
|
81
|
-
"lint:fix": "eslint \"src/**/*.{ts,tsx}\" --fix"
|
|
82
|
-
}
|
|
46
|
+
"sideEffects": false
|
|
83
47
|
}
|
package/README.md
DELETED
|
@@ -1,188 +0,0 @@
|
|
|
1
|
-
<h1 align="center">
|
|
2
|
-
@esengine/ecs-framework
|
|
3
|
-
</h1>
|
|
4
|
-
|
|
5
|
-
<p align="center">
|
|
6
|
-
<strong>High-performance ECS Framework for JavaScript Game Engines</strong>
|
|
7
|
-
</p>
|
|
8
|
-
|
|
9
|
-
<p align="center">
|
|
10
|
-
<a href="https://www.npmjs.com/package/@esengine/ecs-framework"><img src="https://img.shields.io/npm/v/@esengine/ecs-framework?style=flat-square&color=blue" alt="npm"></a>
|
|
11
|
-
<a href="https://github.com/esengine/esengine/blob/master/LICENSE"><img src="https://img.shields.io/badge/license-MIT-green?style=flat-square" alt="license"></a>
|
|
12
|
-
<img src="https://img.shields.io/badge/TypeScript-5.0+-blue?style=flat-square&logo=typescript&logoColor=white" alt="TypeScript">
|
|
13
|
-
<img src="https://img.shields.io/badge/zero-dependencies-brightgreen?style=flat-square" alt="zero dependencies">
|
|
14
|
-
</p>
|
|
15
|
-
|
|
16
|
-
<p align="center">
|
|
17
|
-
<b>English</b> | <a href="./README_CN.md">中文</a>
|
|
18
|
-
</p>
|
|
19
|
-
|
|
20
|
-
---
|
|
21
|
-
|
|
22
|
-
## Overview
|
|
23
|
-
|
|
24
|
-
A standalone, zero-dependency ECS (Entity-Component-System) framework designed for use with **any** JavaScript game engine:
|
|
25
|
-
|
|
26
|
-
- **Cocos Creator**
|
|
27
|
-
- **Laya**
|
|
28
|
-
- **Egret**
|
|
29
|
-
- **Phaser**
|
|
30
|
-
- **Or your own engine**
|
|
31
|
-
|
|
32
|
-
This package is the core of [ESEngine](https://github.com/esengine/esengine), but can be used completely independently.
|
|
33
|
-
|
|
34
|
-
## Installation
|
|
35
|
-
|
|
36
|
-
### npm / pnpm / yarn
|
|
37
|
-
|
|
38
|
-
```bash
|
|
39
|
-
npm install @esengine/ecs-framework
|
|
40
|
-
```
|
|
41
|
-
|
|
42
|
-
### Clone Source Code Only
|
|
43
|
-
|
|
44
|
-
If you only want the ECS framework source code (not the full ESEngine):
|
|
45
|
-
|
|
46
|
-
```bash
|
|
47
|
-
# Step 1: Clone repo skeleton without downloading files (requires Git 2.25+)
|
|
48
|
-
git clone --filter=blob:none --sparse https://github.com/esengine/esengine.git
|
|
49
|
-
|
|
50
|
-
# Step 2: Enter directory
|
|
51
|
-
cd esengine
|
|
52
|
-
|
|
53
|
-
# Step 3: Specify which folder to checkout
|
|
54
|
-
git sparse-checkout set packages/core
|
|
55
|
-
|
|
56
|
-
# Now you only have packages/core/ - other folders are not downloaded
|
|
57
|
-
```
|
|
58
|
-
|
|
59
|
-
## Quick Start
|
|
60
|
-
|
|
61
|
-
```typescript
|
|
62
|
-
import {
|
|
63
|
-
Core, Scene, Entity, Component, EntitySystem,
|
|
64
|
-
Matcher, Time, ECSComponent, ECSSystem
|
|
65
|
-
} from '@esengine/ecs-framework';
|
|
66
|
-
|
|
67
|
-
// Define components (pure data)
|
|
68
|
-
@ECSComponent('Position')
|
|
69
|
-
class Position extends Component {
|
|
70
|
-
x = 0;
|
|
71
|
-
y = 0;
|
|
72
|
-
}
|
|
73
|
-
|
|
74
|
-
@ECSComponent('Velocity')
|
|
75
|
-
class Velocity extends Component {
|
|
76
|
-
dx = 0;
|
|
77
|
-
dy = 0;
|
|
78
|
-
}
|
|
79
|
-
|
|
80
|
-
// Define system (logic)
|
|
81
|
-
@ECSSystem('Movement')
|
|
82
|
-
class MovementSystem extends EntitySystem {
|
|
83
|
-
constructor() {
|
|
84
|
-
super(Matcher.all(Position, Velocity));
|
|
85
|
-
}
|
|
86
|
-
|
|
87
|
-
protected process(entities: readonly Entity[]): void {
|
|
88
|
-
for (const entity of entities) {
|
|
89
|
-
const pos = entity.getComponent(Position);
|
|
90
|
-
const vel = entity.getComponent(Velocity);
|
|
91
|
-
pos.x += vel.dx * Time.deltaTime;
|
|
92
|
-
pos.y += vel.dy * Time.deltaTime;
|
|
93
|
-
}
|
|
94
|
-
}
|
|
95
|
-
}
|
|
96
|
-
|
|
97
|
-
// Initialize
|
|
98
|
-
Core.create();
|
|
99
|
-
const scene = new Scene();
|
|
100
|
-
scene.addSystem(new MovementSystem());
|
|
101
|
-
|
|
102
|
-
const player = scene.createEntity('Player');
|
|
103
|
-
player.addComponent(new Position());
|
|
104
|
-
player.addComponent(new Velocity());
|
|
105
|
-
|
|
106
|
-
Core.setScene(scene);
|
|
107
|
-
|
|
108
|
-
// Game loop (integrate with your engine's loop)
|
|
109
|
-
function update(dt: number) {
|
|
110
|
-
Core.update(dt);
|
|
111
|
-
}
|
|
112
|
-
```
|
|
113
|
-
|
|
114
|
-
## Integration Examples
|
|
115
|
-
|
|
116
|
-
### With Cocos Creator
|
|
117
|
-
|
|
118
|
-
```typescript
|
|
119
|
-
import { _decorator, Component as CCComponent } from 'cc';
|
|
120
|
-
import { Core, Scene } from '@esengine/ecs-framework';
|
|
121
|
-
|
|
122
|
-
const { ccclass } = _decorator;
|
|
123
|
-
|
|
124
|
-
@ccclass('GameManager')
|
|
125
|
-
export class GameManager extends CCComponent {
|
|
126
|
-
private scene: Scene;
|
|
127
|
-
|
|
128
|
-
onLoad() {
|
|
129
|
-
Core.create();
|
|
130
|
-
this.scene = new Scene();
|
|
131
|
-
// Register your systems...
|
|
132
|
-
Core.setScene(this.scene);
|
|
133
|
-
}
|
|
134
|
-
|
|
135
|
-
update(dt: number) {
|
|
136
|
-
Core.update(dt);
|
|
137
|
-
}
|
|
138
|
-
}
|
|
139
|
-
```
|
|
140
|
-
|
|
141
|
-
### With Laya
|
|
142
|
-
|
|
143
|
-
```typescript
|
|
144
|
-
import { Core, Scene } from '@esengine/ecs-framework';
|
|
145
|
-
|
|
146
|
-
export class Main {
|
|
147
|
-
private scene: Scene;
|
|
148
|
-
|
|
149
|
-
constructor() {
|
|
150
|
-
Core.create();
|
|
151
|
-
this.scene = new Scene();
|
|
152
|
-
Core.setScene(this.scene);
|
|
153
|
-
|
|
154
|
-
Laya.timer.frameLoop(1, this, this.onUpdate);
|
|
155
|
-
}
|
|
156
|
-
|
|
157
|
-
onUpdate() {
|
|
158
|
-
Core.update(Laya.timer.delta / 1000);
|
|
159
|
-
}
|
|
160
|
-
}
|
|
161
|
-
```
|
|
162
|
-
|
|
163
|
-
## Features
|
|
164
|
-
|
|
165
|
-
| Feature | Description |
|
|
166
|
-
|---------|-------------|
|
|
167
|
-
| **Zero Dependencies** | No external runtime dependencies |
|
|
168
|
-
| **Type-Safe Queries** | Fluent API with full TypeScript support |
|
|
169
|
-
| **Change Detection** | Epoch-based dirty tracking for optimization |
|
|
170
|
-
| **Serialization** | Built-in scene serialization and snapshots |
|
|
171
|
-
| **Service Container** | Dependency injection for systems |
|
|
172
|
-
| **Performance Monitoring** | Built-in profiling tools |
|
|
173
|
-
|
|
174
|
-
## Documentation
|
|
175
|
-
|
|
176
|
-
- [API Reference](https://esengine.cn/api/README)
|
|
177
|
-
- [Architecture Guide](https://esengine.cn/guide/)
|
|
178
|
-
- [Full ESEngine Documentation](https://esengine.cn/)
|
|
179
|
-
|
|
180
|
-
## License
|
|
181
|
-
|
|
182
|
-
MIT License - Use freely in commercial and open source projects.
|
|
183
|
-
|
|
184
|
-
---
|
|
185
|
-
|
|
186
|
-
<p align="center">
|
|
187
|
-
Part of <a href="https://github.com/esengine/esengine">ESEngine</a> · Can be used standalone
|
|
188
|
-
</p>
|
package/dist/package.json
DELETED
|
@@ -1,47 +0,0 @@
|
|
|
1
|
-
{
|
|
2
|
-
"name": "@esengine/ecs-framework",
|
|
3
|
-
"version": "2.4.3",
|
|
4
|
-
"description": "用于Laya、Cocos Creator等JavaScript游戏引擎的高性能ECS框架",
|
|
5
|
-
"main": "index.cjs",
|
|
6
|
-
"module": "index.mjs",
|
|
7
|
-
"unpkg": "index.umd.js",
|
|
8
|
-
"types": "index.d.ts",
|
|
9
|
-
"exports": {
|
|
10
|
-
".": {
|
|
11
|
-
"import": "./index.mjs",
|
|
12
|
-
"require": "./index.cjs",
|
|
13
|
-
"types": "./index.d.ts"
|
|
14
|
-
}
|
|
15
|
-
},
|
|
16
|
-
"files": [
|
|
17
|
-
"index.mjs",
|
|
18
|
-
"index.mjs.map",
|
|
19
|
-
"index.cjs",
|
|
20
|
-
"index.cjs.map",
|
|
21
|
-
"index.umd.js",
|
|
22
|
-
"index.umd.js.map",
|
|
23
|
-
"index.es5.js",
|
|
24
|
-
"index.es5.js.map",
|
|
25
|
-
"index.d.ts"
|
|
26
|
-
],
|
|
27
|
-
"keywords": [
|
|
28
|
-
"ecs",
|
|
29
|
-
"entity-component-system",
|
|
30
|
-
"game-engine",
|
|
31
|
-
"typescript",
|
|
32
|
-
"cocos-creator",
|
|
33
|
-
"laya",
|
|
34
|
-
"rollup"
|
|
35
|
-
],
|
|
36
|
-
"author": "yhh",
|
|
37
|
-
"license": "MIT",
|
|
38
|
-
"repository": {
|
|
39
|
-
"type": "git",
|
|
40
|
-
"url": "https://github.com/esengine/esengine.git",
|
|
41
|
-
"directory": "packages/core"
|
|
42
|
-
},
|
|
43
|
-
"engines": {
|
|
44
|
-
"node": ">=16.0.0"
|
|
45
|
-
},
|
|
46
|
-
"sideEffects": false
|
|
47
|
-
}
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|