archetype-ecs 1.3.1 → 1.3.2
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/README.md +104 -34
- package/bench/allocations-1m.js +1 -1
- package/bench/multi-ecs-bench.js +1 -1
- package/bench/typed-vs-bitecs-1m.js +1 -1
- package/bench/typed-vs-untyped.js +81 -81
- package/bench/vs-bitecs.js +31 -56
- package/dist/ComponentRegistry.d.ts +18 -0
- package/dist/ComponentRegistry.js +29 -0
- package/dist/EntityManager.d.ts +52 -0
- package/dist/EntityManager.js +891 -0
- package/dist/Profiler.d.ts +12 -0
- package/dist/Profiler.js +38 -0
- package/dist/System.d.ts +41 -0
- package/dist/System.js +159 -0
- package/dist/index.d.ts +12 -0
- package/dist/index.js +29 -0
- package/dist/src/ComponentRegistry.d.ts +18 -0
- package/dist/src/ComponentRegistry.js +29 -0
- package/dist/src/EntityManager.d.ts +49 -0
- package/dist/src/EntityManager.js +853 -0
- package/dist/src/Profiler.d.ts +12 -0
- package/dist/src/Profiler.js +38 -0
- package/dist/src/System.d.ts +37 -0
- package/dist/src/System.js +139 -0
- package/dist/src/index.d.ts +14 -0
- package/dist/src/index.js +29 -0
- package/dist/tests/EntityManager.test.d.ts +1 -0
- package/dist/tests/EntityManager.test.js +651 -0
- package/dist/tests/System.test.d.ts +1 -0
- package/dist/tests/System.test.js +630 -0
- package/dist/tests/types.d.ts +1 -0
- package/dist/tests/types.js +129 -0
- package/package.json +9 -7
- package/src/ComponentRegistry.ts +49 -0
- package/src/EntityManager.ts +1018 -0
- package/src/{Profiler.js → Profiler.ts} +18 -5
- package/src/System.ts +226 -0
- package/src/index.ts +44 -0
- package/tests/{EntityManager.test.js → EntityManager.test.ts} +338 -70
- package/tests/System.test.ts +730 -0
- package/tests/types.ts +67 -66
- package/tsconfig.json +8 -5
- package/tsconfig.test.json +13 -0
- package/src/ComponentRegistry.js +0 -21
- package/src/EntityManager.js +0 -578
- package/src/index.d.ts +0 -118
- package/src/index.js +0 -37
package/src/index.js
DELETED
|
@@ -1,37 +0,0 @@
|
|
|
1
|
-
export { createEntityManager } from './EntityManager.js';
|
|
2
|
-
export { profiler } from './Profiler.js';
|
|
3
|
-
export { TYPED, componentSchemas } from './ComponentRegistry.js';
|
|
4
|
-
import { TYPE_MAP, componentSchemas } from './ComponentRegistry.js';
|
|
5
|
-
|
|
6
|
-
export function component(name, typeOrSchema, fields) {
|
|
7
|
-
const sym = Symbol(name);
|
|
8
|
-
const comp = { _sym: sym, _name: name };
|
|
9
|
-
|
|
10
|
-
let schema;
|
|
11
|
-
|
|
12
|
-
if (typeof typeOrSchema === 'string' && Array.isArray(fields)) {
|
|
13
|
-
// Short form: component('Position', 'f32', ['x', 'y'])
|
|
14
|
-
const Ctor = TYPE_MAP[typeOrSchema];
|
|
15
|
-
if (!Ctor) throw new Error(`Unknown type "${typeOrSchema}"`);
|
|
16
|
-
schema = {};
|
|
17
|
-
for (const f of fields) {
|
|
18
|
-
schema[f] = Ctor;
|
|
19
|
-
comp[f] = { _sym: sym, _field: f };
|
|
20
|
-
}
|
|
21
|
-
} else if (typeOrSchema && typeof typeOrSchema === 'object') {
|
|
22
|
-
// Schema form: component('Position', { x: 'f32', y: 'f32' })
|
|
23
|
-
schema = {};
|
|
24
|
-
for (const [field, type] of Object.entries(typeOrSchema)) {
|
|
25
|
-
const Ctor = TYPE_MAP[type];
|
|
26
|
-
if (!Ctor) throw new Error(`Unknown type "${type}" for field "${field}"`);
|
|
27
|
-
schema[field] = Ctor;
|
|
28
|
-
comp[field] = { _sym: sym, _field: field };
|
|
29
|
-
}
|
|
30
|
-
}
|
|
31
|
-
|
|
32
|
-
if (schema) {
|
|
33
|
-
componentSchemas.set(sym, schema);
|
|
34
|
-
}
|
|
35
|
-
|
|
36
|
-
return comp;
|
|
37
|
-
}
|