@woosh/meep-engine 2.126.11 → 2.126.14

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/package.json CHANGED
@@ -5,7 +5,7 @@
5
5
  "description": "Pure JavaScript game engine. Fully featured and production ready.",
6
6
  "type": "module",
7
7
  "author": "Alexander Goldring",
8
- "version": "2.126.11",
8
+ "version": "2.126.14",
9
9
  "main": "build/meep.module.js",
10
10
  "module": "build/meep.module.js",
11
11
  "exports": {
@@ -1,9 +1,14 @@
1
+ export type SerializationFlags = number;
1
2
  export namespace SerializationFlags {
2
3
  let Transient: number;
3
4
  }
5
+ /**
6
+ * Stores settings for entity serialization
7
+ */
4
8
  export class SerializationMetadata {
5
9
  /**
6
- *
10
+ * 32 bit bitfield.
11
+ * Use {@link setFlag}/{@link getFlag} etc. to read individual flag values
7
12
  * @type {number}
8
13
  */
9
14
  flags: number;
@@ -12,33 +17,25 @@ export class SerializationMetadata {
12
17
  * @param {number|SerializationFlags} flag
13
18
  * @returns {void}
14
19
  */
15
- setFlag(flag: number | {
16
- Transient: number;
17
- }): void;
20
+ setFlag(flag: number | SerializationFlags): void;
18
21
  /**
19
22
  *
20
23
  * @param {number|SerializationFlags} flag
21
24
  * @returns {void}
22
25
  */
23
- clearFlag(flag: number | {
24
- Transient: number;
25
- }): void;
26
+ clearFlag(flag: number | SerializationFlags): void;
26
27
  /**
27
28
  *
28
29
  * @param {number|SerializationFlags} flag
29
30
  * @param {boolean} value
30
31
  */
31
- writeFlag(flag: number | {
32
- Transient: number;
33
- }, value: boolean): void;
32
+ writeFlag(flag: number | SerializationFlags, value: boolean): void;
34
33
  /**
35
34
  *
36
35
  * @param {number|SerializationFlags} flag
37
36
  * @returns {boolean}
38
37
  */
39
- getFlag(flag: number | {
40
- Transient: number;
41
- }): boolean;
38
+ getFlag(flag: number | SerializationFlags): boolean;
42
39
  toJSON(): {
43
40
  flags: number;
44
41
  };
@@ -1 +1 @@
1
- {"version":3,"file":"SerializationMetadata.d.ts","sourceRoot":"","sources":["../../../../../src/engine/ecs/components/SerializationMetadata.js"],"names":[],"mappings":";;;AAIA;IAEI;;;OAGG;IACH,OAFU,MAAM,CAEN;IAEV;;;;OAIG;IACH,cAHW,MAAM;;KAAmB,GACvB,IAAI,CAIhB;IAED;;;;OAIG;IACH,gBAHW,MAAM;;KAAmB,GACvB,IAAI,CAIhB;IAED;;;;OAIG;IACH,gBAHW,MAAM;;KAAmB,SACzB,OAAO,QAQjB;IAED;;;;OAIG;IACH,cAHW,MAAM;;KAAmB,GACvB,OAAO,CAInB;IAED;;MAIC;IAED;;aAEC;CACJ"}
1
+ {"version":3,"file":"SerializationMetadata.d.ts","sourceRoot":"","sources":["../../../../../src/engine/ecs/components/SerializationMetadata.js"],"names":[],"mappings":"iCAEU,MAAM;;;;AAShB;;GAEG;AACH;IAEI;;;;OAIG;IACH,OAFU,MAAM,CAEN;IAEV;;;;OAIG;IACH,cAHW,MAAM,GAAC,kBAAkB,GACvB,IAAI,CAIhB;IAED;;;;OAIG;IACH,gBAHW,MAAM,GAAC,kBAAkB,GACvB,IAAI,CAIhB;IAED;;;;OAIG;IACH,gBAHW,MAAM,GAAC,kBAAkB,SACzB,OAAO,QAQjB;IAED;;;;OAIG;IACH,cAHW,MAAM,GAAC,kBAAkB,GACvB,OAAO,CAInB;IAED;;MAIC;IAED;;aAEC;CACJ"}
@@ -1,11 +1,22 @@
1
+ /**
2
+ *
3
+ * @enum {number}
4
+ */
1
5
  export const SerializationFlags = {
6
+ /**
7
+ * When set, entity is considered non-permanent and should not be serialized
8
+ */
2
9
  Transient: 1
3
10
  };
4
11
 
12
+ /**
13
+ * Stores settings for entity serialization
14
+ */
5
15
  export class SerializationMetadata {
6
16
 
7
17
  /**
8
- *
18
+ * 32 bit bitfield.
19
+ * Use {@link setFlag}/{@link getFlag} etc. to read individual flag values
9
20
  * @type {number}
10
21
  */
11
22
  flags = 0;
@@ -1,15 +1,18 @@
1
1
  export default BinaryBufferSerializer;
2
- declare class BinaryBufferSerializer {
2
+ /**
3
+ * @template CTX
4
+ */
5
+ declare class BinaryBufferSerializer<CTX> {
3
6
  /**
4
7
  *
5
8
  * @type {BinarySerializationRegistry}
6
9
  */
7
10
  registry: BinarySerializationRegistry;
8
11
  /**
9
- *
10
- * @type {Engine|null}
12
+ * Context to be supplied to individual serialization adapters
13
+ * @type {CTX|null}
11
14
  */
12
- engine: Engine | null;
15
+ engine: CTX | null;
13
16
  /**
14
17
  *
15
18
  * @param {EntityComponentDataset} dataset
@@ -1 +1 @@
1
- {"version":3,"file":"BinaryBufferSerializer.d.ts","sourceRoot":"","sources":["../../../../../src/engine/ecs/storage/BinaryBufferSerializer.js"],"names":[],"mappings":";AAmDA;IACI;;;OAGG;IACH,UAFU,2BAA2B,CAErB;IAEhB;;;OAGG;IACH,QAFU,MAAM,GAAC,IAAI,CAEP;IAEd;;;;OAIG;IACH,gBAFW,YAAY,WADZ,sBAAsB,QA6HhC;CACJ"}
1
+ {"version":3,"file":"BinaryBufferSerializer.d.ts","sourceRoot":"","sources":["../../../../../src/engine/ecs/storage/BinaryBufferSerializer.js"],"names":[],"mappings":";AAmDA;;GAEG;AACH,qCAFa,GAAG;IAGZ;;;OAGG;IACH,UAFU,2BAA2B,CAErB;IAEhB;;;OAGG;IACH,QAFU,GAAG,GAAC,IAAI,CAEJ;IAEd;;;;OAIG;IACH,gBAFW,YAAY,WADZ,sBAAsB,QA+HhC;CACJ"}
@@ -16,7 +16,7 @@ function isComponentClassSerializable(componentClass) {
16
16
  }
17
17
 
18
18
  /**
19
- * Whether or not an entity should be serialized at all
19
+ * Whether an entity should be serialized at all
20
20
  * @param {number} entity
21
21
  * @param {EntityComponentDataset} dataset
22
22
  * @param {number} smComponentIndex
@@ -49,6 +49,9 @@ function isEntityTransient(entity, dataset, smComponentIndex, componentInstance)
49
49
  return isTransient;
50
50
  }
51
51
 
52
+ /**
53
+ * @template CTX
54
+ */
52
55
  class BinaryBufferSerializer {
53
56
  /**
54
57
  *
@@ -57,8 +60,8 @@ class BinaryBufferSerializer {
57
60
  registry = null;
58
61
 
59
62
  /**
60
- *
61
- * @type {Engine|null}
63
+ * Context to be supplied to individual serialization adapters
64
+ * @type {CTX|null}
62
65
  */
63
66
  engine = null;
64
67
 
@@ -79,11 +82,13 @@ class BinaryBufferSerializer {
79
82
 
80
83
  const numSerializableTypes = serializableComponentTypes.length;
81
84
 
82
- const typeCountAddress = buffer.position;
83
85
 
84
86
  const FORMAT_VERSION = 0;
85
87
 
86
88
  buffer.writeUint16(FORMAT_VERSION)
89
+
90
+ const typeCountAddress = buffer.position;
91
+
87
92
  buffer.writeUint16(numSerializableTypes);
88
93
 
89
94
  const collectionSerializer = new BinaryCollectionSerializer();
@@ -144,13 +149,13 @@ class BinaryBufferSerializer {
144
149
 
145
150
  dataset.traverseComponents(componentType, function (componentInstance, entity) {
146
151
  if (isEntityTransient(entity, dataset, smComponentIndex, componentInstance)) {
147
- //skip
152
+ // skip
148
153
  return;
149
154
  }
150
155
 
151
156
  assert.ok(entity >= lastEntity, `entity[=${entity}] < lastEntity[=${lastEntity}]`);
152
157
 
153
- //write only the entity step
158
+ // write only the entity step
154
159
  const step = entity - lastEntity;
155
160
 
156
161
  lastEntity = entity;
@@ -169,22 +174,22 @@ class BinaryBufferSerializer {
169
174
 
170
175
  const currentPosition = buffer.position;
171
176
 
172
- //print size of the component set
177
+ // print size of the component set
173
178
  const componentsByteSize = currentPosition - positionComponentsStart;
174
179
  console.log(`Component ${componentType.typeName} written. Count: ${numComponentsWritten}, Bytes: ${componentsByteSize}, Bytes/component: ${Math.ceil(componentsByteSize / numComponentsWritten)}. Time taken: ${((__end_time - __start_time) * 1000).toFixed(2)}ms`);
175
180
  } else {
176
- //no elements written, lets re-wind to skip the type
181
+ // no elements written, lets re-wind to skip the type
177
182
  buffer.position = positionComponentsStart;
178
183
  }
179
184
  }
180
185
 
181
- //go back and patch actual number of written classes
186
+ // go back and patch actual number of written classes
182
187
  const p = buffer.position;
183
188
 
184
189
  buffer.position = typeCountAddress;
185
- buffer.writeUint32(numTypesWritten);
190
+ buffer.writeUint16(numTypesWritten);
186
191
 
187
- //restore position
192
+ // restore position
188
193
  buffer.position = p;
189
194
 
190
195
  console.timeEnd('serializing');