@dcl/ecs 7.0.3-3583938384.commit-827bc9a → 7.0.3-3584900424.commit-d08747d

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 CHANGED
@@ -8,18 +8,3 @@ Run `make build`
8
8
 
9
9
  ## Testing
10
10
  Run `make test`, you can also debug the test in VS code, selecting the launch `Jest current file` or just `Jest` (this will run all test)
11
-
12
- ## Wishlist
13
- Use this project as template for TypeScript libraries
14
- - [x] as any MutableGroupOf
15
- - [x] Tests for system
16
- - [ ] Basic Components ( Transform ) w/Tests
17
- - [ ] Sync Component W/Tests
18
- - [x] CRDT System
19
- - [ ] Kindof Scene Tests. Component & Systems. Maybe physics system? SolarSystem
20
- - [ ] Integration with old ecs ( CRDT/Door Scene )
21
- - [ ] RPC Transport. JSON { entityId, componentId, data: } vs Protocol Buffers
22
- - [ ] EntityID generator
23
- - [ ] Static vs Dynamic entities.
24
- - [ ] Sync Components ?
25
- - [ ] Where the state lives ? State cross realms/islands ? StateFull questions. StorableComponent ?
@@ -11,7 +11,6 @@ export declare namespace EntityUtils {
11
11
  const RESERVED_ENTITIES_RANGE: EntityRange;
12
12
  const STATIC_ENTITIES_RANGE: EntityRange;
13
13
  const DYNAMIC_ENTITIES_RANGE: EntityRange;
14
- function isDynamicEntity(entity: Entity): boolean;
15
14
  function isStaticEntity(entity: Entity): boolean;
16
15
  function isReservedEntity(entity: Entity): boolean;
17
16
  }
@@ -9,7 +9,8 @@ export var EntityUtils;
9
9
  ];
10
10
  EntityUtils.STATIC_ENTITIES_RANGE = [
11
11
  EntityUtils.RESERVED_STATIC_ENTITIES,
12
- EntityUtils.DYNAMIC_ENTITIES_START_AT - 1
12
+ EntityUtils.MAX_ENTITIES
13
+ // DYNAMIC_ENTITIES_START_AT - 1
13
14
  ];
14
15
  EntityUtils.DYNAMIC_ENTITIES_RANGE = [
15
16
  EntityUtils.DYNAMIC_ENTITIES_START_AT,
@@ -18,6 +19,7 @@ export var EntityUtils;
18
19
  function isInRange(entity, range) {
19
20
  return entity >= range[0] && entity <= range[1];
20
21
  }
22
+ // @internal
21
23
  function isDynamicEntity(entity) {
22
24
  return isInRange(entity, EntityUtils.DYNAMIC_ENTITIES_RANGE);
23
25
  }
@@ -4,7 +4,11 @@ export function EntityContainer() {
4
4
  const dynamicEntity = Entity(EntityUtils.DYNAMIC_ENTITIES_RANGE);
5
5
  return {
6
6
  generateEntity(dynamic = false) {
7
+ /* istanbul ignore next */
7
8
  if (dynamic) {
9
+ // Dynamic entities are not being used, but since we dont know the future of the dynamic entities
10
+ // I prefer to comment the code instead of removing all the logic
11
+ /* istanbul ignore next */
8
12
  return dynamicEntity.generateEntity();
9
13
  }
10
14
  else {
@@ -5,6 +5,7 @@ import { defineComponent as defComponent } from './component';
5
5
  import { EntityContainer } from './entity';
6
6
  import { SystemContainer, SYSTEMS_REGULAR_PRIORITY } from './systems';
7
7
  export * from './input';
8
+ import { checkNotThenable } from '../runtime/invariant';
8
9
  export * from './readonly';
9
10
  export * from './types';
10
11
  function preEngine() {
@@ -17,17 +18,13 @@ function preEngine() {
17
18
  function removeSystem(selector) {
18
19
  return systems.remove(selector);
19
20
  }
20
- function addEntity(dynamic = false) {
21
- // entitiesCompnonent.set(entity, new Set())
22
- const entity = entityContainer.generateEntity(dynamic);
21
+ function addEntity() {
22
+ const entity = entityContainer.generateEntity();
23
23
  return entity;
24
24
  }
25
25
  function entityExists(entity) {
26
26
  return entityContainer.entityExists(entity);
27
27
  }
28
- function addDynamicEntity() {
29
- return addEntity(true);
30
- }
31
28
  function removeEntity(entity) {
32
29
  for (const [, component] of componentsDefinition) {
33
30
  if (component.has(entity)) {
@@ -91,7 +88,6 @@ function preEngine() {
91
88
  entityExists,
92
89
  componentsDefinition,
93
90
  addEntity,
94
- addDynamicEntity,
95
91
  removeEntity,
96
92
  addSystem,
97
93
  getSystems,
@@ -114,11 +110,7 @@ export function Engine() {
114
110
  crdtSystem.receiveMessages();
115
111
  for (const system of engine.getSystems()) {
116
112
  const ret = system.fn(dt);
117
- if (globalThis.DEBUG) {
118
- if (ret && typeof ret === 'object' && typeof ret.then === 'function') {
119
- throw new Error(`A system (${system.name || 'anonymous'}) returned a thenable. Systems cannot be async functions. Documentation: https://dcl.gg/sdk/sync-systems`);
120
- }
121
- }
113
+ checkNotThenable(ret, `A system (${system.name || 'anonymous'}) returned a thenable. Systems cannot be async functions. Documentation: https://dcl.gg/sdk/sync-systems`);
122
114
  }
123
115
  // TODO: Perf tip
124
116
  // Should we add some dirtyIteratorSet at engine level so we dont have
@@ -157,12 +149,10 @@ export function Engine() {
157
149
  }
158
150
  return {
159
151
  addEntity: engine.addEntity,
160
- addDynamicEntity: engine.addDynamicEntity,
161
152
  removeEntity: engine.removeEntity,
162
153
  removeEntityWithChildren,
163
154
  addSystem: engine.addSystem,
164
155
  removeSystem: engine.removeSystem,
165
- // TODO: fix this type
166
156
  defineComponent: engine.defineComponent,
167
157
  defineComponentFromSchema: engine.defineComponentFromSchema,
168
158
  getEntitiesWith: engine.getEntitiesWith,
@@ -26,10 +26,6 @@ export declare type IEngine = {
26
26
  * @returns the next entity unused
27
27
  */
28
28
  addEntity(dynamic?: boolean): Entity;
29
- /**
30
- * An alias of engine.addEntity(true)
31
- */
32
- addDynamicEntity(): Entity;
33
29
  /**
34
30
  * Remove all components of an entity
35
31
  * @param entity - entity
@@ -1 +1,3 @@
1
- export declare function checkNotThenable<T>(t: T, error: string): T;
1
+ declare type K = unknown | Promise<unknown>;
2
+ export declare function checkNotThenable<T extends K>(t: T, error: string): T;
3
+ export {};
@@ -1,6 +1,8 @@
1
1
  export function checkNotThenable(t, error) {
2
2
  if (globalThis.DEBUG) {
3
- if (t && typeof t === 'object' && typeof t.then === 'function') {
3
+ if (t &&
4
+ typeof t === 'object' &&
5
+ typeof t.then === 'function') {
4
6
  throw new Error(error);
5
7
  }
6
8
  }
@@ -5,14 +5,12 @@ export function IMap(spec) {
5
5
  return {
6
6
  serialize(value, builder) {
7
7
  for (const key in spec) {
8
- // TODO: as any
9
8
  spec[key].serialize(value[key], builder);
10
9
  }
11
10
  },
12
11
  deserialize(reader) {
13
12
  const newValue = {};
14
13
  for (const key in spec) {
15
- // TODO: as any
16
14
  ;
17
15
  newValue[key] = spec[key].deserialize(reader);
18
16
  }
@@ -21,7 +19,6 @@ export function IMap(spec) {
21
19
  create() {
22
20
  const newValue = {};
23
21
  for (const key in spec) {
24
- // TODO: as any
25
22
  ;
26
23
  newValue[key] = spec[key].create();
27
24
  }
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@dcl/ecs",
3
- "version": "7.0.3-3583938384.commit-827bc9a",
3
+ "version": "7.0.3-3584900424.commit-d08747d",
4
4
  "description": "Decentraland ECS",
5
5
  "main": "./dist/index.js",
6
6
  "typings": "./dist/index.d.ts",
@@ -35,5 +35,5 @@
35
35
  "dist",
36
36
  "etc"
37
37
  ],
38
- "commit": "827bc9acb5825d817445521eb790ee256788a01c"
38
+ "commit": "d08747dea26ba46738fda26e28689bbc03603b71"
39
39
  }