@awesome-ecs/abstract 0.10.0 → 0.12.0

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.
@@ -1,5 +1,6 @@
1
1
  import { IComponent } from "./component";
2
2
  import { EntityTypeUid, IEntityModel } from "../entities/entity";
3
+ import { Immutable } from "../utils/types";
3
4
  export declare enum BasicComponentType {
4
5
  identity = "identity"
5
6
  }
@@ -15,7 +16,7 @@ export interface IdentityComponent<TModel extends IEntityModel> extends ICompone
15
16
  * The Model is the basic information needed to create an `IEntity` when it's first initialized.
16
17
  * It provides a first snapshot of information needed for the successful creation of an Entity instance.
17
18
  */
18
- readonly model: TModel;
19
+ readonly model: Immutable<TModel>;
19
20
  /**
20
21
  * Keeps track when the Entity's systems have ran last. Useful to calculate the `DeltaTime` between runs.
21
22
  */
@@ -1 +1 @@
1
- {"version":3,"file":"identity-component.js","sourceRoot":"","sources":["../../src/components/identity-component.ts"],"names":[],"mappings":";;;AAGA,IAAY,kBAEX;AAFD,WAAY,kBAAkB;IAC5B,2CAAqB,CAAA;AACvB,CAAC,EAFW,kBAAkB,GAAlB,0BAAkB,KAAlB,0BAAkB,QAE7B"}
1
+ {"version":3,"file":"identity-component.js","sourceRoot":"","sources":["../../src/components/identity-component.ts"],"names":[],"mappings":";;;AAIA,IAAY,kBAEX;AAFD,WAAY,kBAAkB;IAC5B,2CAAqB,CAAA;AACvB,CAAC,EAFW,kBAAkB,GAAlB,0BAAkB,KAAlB,0BAAkB,QAE7B"}
@@ -1,6 +1,7 @@
1
1
  import { EntityTypeUid, IEntityModel, IEntity } from "../../entities/entity";
2
2
  import { EntityProxy, IEntityProxy } from "../../entities/entity-proxies";
3
3
  import { IEntitySnapshot } from "../../entities/entity-snapshot";
4
+ import { Immutable } from "../../utils/types";
4
5
  /**
5
6
  * The `ISystemContextRepository` is the access point for the `IEntityRepository` related APIs.
6
7
  *
@@ -8,7 +9,7 @@ import { IEntitySnapshot } from "../../entities/entity-snapshot";
8
9
  */
9
10
  export interface ISystemContextRepository {
10
11
  addEntity(entityType: EntityTypeUid, model: IEntityModel, snapshot?: IEntitySnapshot): void;
11
- getEntity<TEntity extends IEntity>(proxy: EntityProxy<TEntity>): TEntity;
12
+ getEntity<TEntity extends IEntity>(proxy: EntityProxy<TEntity>): Immutable<TEntity>;
12
13
  updateEntity(target?: IEntityProxy): void;
13
14
  removeEntity(target: IEntityProxy): void;
14
15
  }
@@ -1,4 +1,5 @@
1
1
  import { IEntity } from "../../entities/entity";
2
+ import { IEntityProxy } from "../../entities/entity-proxies";
2
3
  import { IEntitySnapshot } from "../../entities/entity-snapshot";
3
4
  import { IJsonSerializer } from "../../utils/json-serializer";
4
5
  /**
@@ -10,4 +11,5 @@ export interface ISystemContextSnapshot {
10
11
  readonly serializer: IJsonSerializer;
11
12
  applySnapshot(snapshot: IEntitySnapshot): void;
12
13
  createSnapshot(entity?: IEntity): IEntitySnapshot;
14
+ dispatchSnapshot(snapshot: IEntitySnapshot, proxy?: IEntityProxy): void;
13
15
  }
@@ -1,3 +1,18 @@
1
1
  export declare type Mutable<T> = {
2
2
  -readonly [K in keyof T]: T[K];
3
3
  };
4
+ export declare type MutableDeep<T> = {
5
+ -readonly [K in keyof T]: Mutable<T[K]>;
6
+ };
7
+ declare type ImmutablePrimitive = undefined | null | boolean | string | number | Function;
8
+ export declare type Immutable<T> = T extends ImmutablePrimitive ? T : T extends Array<infer U> ? ImmutableArray<U> : T extends Map<infer K, infer V> ? ImmutableMap<K, V> : T extends Set<infer M> ? ImmutableSet<M> : ImmutableObject<T>;
9
+ export declare type ImmutableArray<T> = ReadonlyArray<Immutable<T>>;
10
+ export declare type ImmutableMap<K, V> = ReadonlyMap<Immutable<K>, Immutable<V>>;
11
+ export declare type ImmutableSet<T> = ReadonlySet<Immutable<T>>;
12
+ export declare type ImmutableObject<T> = {
13
+ readonly [K in keyof T]: T[K];
14
+ };
15
+ export declare type ImmutableObjectDeep<T> = {
16
+ readonly [K in keyof T]: Immutable<T[K]>;
17
+ };
18
+ export {};
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@awesome-ecs/abstract",
3
- "version": "0.10.0",
3
+ "version": "0.12.0",
4
4
  "description": "A comprehensive Entity-Component-System (ECS) Architecture implementation. Abstract components.",
5
5
  "main": "./dist/index.js",
6
6
  "types": "./dist/index.d.ts",
@@ -32,5 +32,5 @@
32
32
  "url": "https://github.com/andreicojocaru/awesome-ecs/issues"
33
33
  },
34
34
  "homepage": "https://github.com/andreicojocaru/awesome-ecs#readme",
35
- "gitHead": "0f60d8d0dc38b79229028714b2a55009589bd511"
35
+ "gitHead": "2b17c316d9799e4a04f7bb0e871ff305d59c95cc"
36
36
  }