@woosh/meep-engine 2.123.1 → 2.123.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/package.json CHANGED
@@ -5,7 +5,7 @@
5
5
  "description": "Fully featured ECS game engine written in JavaScript",
6
6
  "type": "module",
7
7
  "author": "Alexander Goldring",
8
- "version": "2.123.1",
8
+ "version": "2.123.2",
9
9
  "main": "build/meep.module.js",
10
10
  "module": "build/meep.module.js",
11
11
  "exports": {
@@ -20,12 +20,6 @@ export class UUID {
20
20
  * @return {string}
21
21
  */
22
22
  static string(): string;
23
- /**
24
- * Shortcut to generate 22-character base58 string
25
- * Uses v4(random) UUID
26
- * @return {string}
27
- */
28
- static base58(): string;
29
23
  /**
30
24
  *
31
25
  * @param {string} string
@@ -56,10 +50,6 @@ export class UUID {
56
50
  * @param {string} string String in UUID format
57
51
  */
58
52
  parse(string: string): void;
59
- /**
60
- * Use base58 encoding to represent UUID as a 22 character string
61
- */
62
- get base58(): string;
63
53
  /**
64
54
  * Standard UUID string in from: AAAAAAAA-BBBB-CCCC-DDDD-EEEEEEEEEEEE
65
55
  * Result is compatible with the {@link UUID.parse} method.
@@ -80,11 +70,18 @@ export class UUID {
80
70
  */
81
71
  equals(other: UUID): boolean;
82
72
  /**
83
- * @returns {number}
73
+ * Compute hash sum
74
+ * @returns {number} 32bit integer value
84
75
  */
85
76
  hash(): number;
86
- toJSON(): string;
87
- fromJSON(v: any): void;
77
+ /**
78
+ * @readonly
79
+ */
80
+ readonly toJSON: () => string;
81
+ /**
82
+ * @readonly
83
+ */
84
+ readonly fromJSON: (string: string) => void;
88
85
  /**
89
86
  * @readonly
90
87
  * @type {boolean}
@@ -1 +1 @@
1
- {"version":3,"file":"UUID.d.ts","sourceRoot":"","sources":["../../../../../src/engine/ecs/guid/UUID.js"],"names":[],"mappings":"AAyBA;;;;GAIG;AACH;IAiHI;;;OAGG;IACH,aAFY,IAAI,CAQf;IAED;;;OAGG;IACH,aAFa,IAAI,CAQhB;IAED;;;;OAIG;IACH,iBAFY,MAAM,CAIjB;IAED;;;;OAIG;IACH,iBAFY,MAAM,CAIjB;IAyCD;;;;OAIG;IACH,qBAHW,MAAM,GACL,IAAI,CAQf;IA1MD;;;OAGG;IACH,gBAFW,MAAM,EAAE,GAAC,UAAU,GAAC,SAAS,CAAC,MAAM,CAAC,EAO/C;IAED;;;OAGG;IACH,YAFa,UAAU,CAItB;IAED;;;OAGG;IACH,WAsEC;IAED;;OAEG;IACH,WAUC;IA4CD;;;OAGG;IACH,cAFW,MAAM,QAmChB;IAeD;;OAEG;IACH,qBAEC;IAED;;;;;;OAMG;IACH,YAFa,MAAM,CA2BlB;IAED;;;OAGG;IACH,YAFW,IAAI,QAId;IAED;;;;OAIG;IACH,cAHW,IAAI,GACF,OAAO,CAanB;IAED;;OAEG;IACH,QAFa,MAAM,CAWlB;IAED,iBAEC;IAED,uBAEC;IASL;;;OAGG;IACH,iBAFU,OAAO,CAEI;;CAZpB;;kBAIS,MAAM"}
1
+ {"version":3,"file":"UUID.d.ts","sourceRoot":"","sources":["../../../../../src/engine/ecs/guid/UUID.js"],"names":[],"mappings":"AAyBA;;;;GAIG;AACH;IAiHI;;;OAGG;IACH,aAFY,IAAI,CAQf;IAED;;;OAGG;IACH,aAFa,IAAI,CAQhB;IAED;;;;OAIG;IACH,iBAFY,MAAM,CAIjB;IAyCD;;;;OAIG;IACH,qBAHW,MAAM,GACL,IAAI,CAQf;IAjMD;;;OAGG;IACH,gBAFW,MAAM,EAAE,GAAC,UAAU,GAAC,SAAS,CAAC,MAAM,CAAC,EAO/C;IAED;;;OAGG;IACH,YAFa,UAAU,CAItB;IAED;;;OAGG;IACH,WAsEC;IAED;;OAEG;IACH,WAUC;IAmCD;;;OAGG;IACH,cAFW,MAAM,QAmChB;IAeD;;;;;;OAMG;IACH,YAFa,MAAM,CA2BlB;IAED;;;OAGG;IACH,YAFW,IAAI,QAId;IAED;;;;OAIG;IACH,cAHW,IAAI,GACF,OAAO,CAcnB;IAED;;;OAGG;IACH,QAFa,MAAM,CAYlB;IAIL;;OAEG;IACH,uBA7EiB,MAAM,CA6EF;IAErB;;OAEG;IACH,4BAzIe,MAAM,UAyIE;IAQvB;;;OAGG;IACH,iBAFU,OAAO,CAEI;;CAtBpB;;kBAcS,MAAM"}
@@ -1,6 +1,6 @@
1
1
  import { assert } from "../../../core/assert.js";
2
- import { base58_encode } from "../../../core/binary/base58/base58_encode.js";
3
2
  import { dec2hex } from "../../../core/binary/dec2hex.js";
3
+ import { hex2dec } from "../../../core/binary/hex2dec.js";
4
4
  import { array_copy } from "../../../core/collection/array/array_copy.js";
5
5
  import { randomBytes } from "../../../core/math/random/randomBytes.js";
6
6
  import { randomUint8 } from "../../../core/math/random/randomUint8.js";
@@ -174,15 +174,6 @@ export class UUID {
174
174
  return UUID.v4().toString();
175
175
  }
176
176
 
177
- /**
178
- * Shortcut to generate 22-character base58 string
179
- * Uses v4(random) UUID
180
- * @return {string}
181
- */
182
- static base58() {
183
- return UUID.v4().base58;
184
- }
185
-
186
177
  /***
187
178
  * Parses standard UUID string of form AAAAAAAA-BBBB-CCCC-DDDD-EEEEEEEEEEEE
188
179
  * @param {string} string String in UUID format
@@ -195,26 +186,26 @@ export class UUID {
195
186
  const arr = this.#data;
196
187
 
197
188
  // Parse ########-....-....-....-............
198
- arr[0] = (v = parseInt(string.slice(0, 8), 16)) >>> 24;
189
+ arr[0] = (v = hex2dec(string.slice(0, 8))) >>> 24;
199
190
  arr[1] = (v >>> 16) & 0xff;
200
191
  arr[2] = (v >>> 8) & 0xff;
201
192
  arr[3] = v & 0xff;
202
193
 
203
194
  // Parse ........-####-....-....-............
204
- arr[4] = (v = parseInt(string.slice(9, 13), 16)) >>> 8;
195
+ arr[4] = (v = hex2dec(string.slice(9, 13))) >>> 8;
205
196
  arr[5] = v & 0xff;
206
197
 
207
198
  // Parse ........-....-####-....-............
208
- arr[6] = (v = parseInt(string.slice(14, 18), 16)) >>> 8;
199
+ arr[6] = (v = hex2dec(string.slice(14, 18))) >>> 8;
209
200
  arr[7] = v & 0xff;
210
201
 
211
202
  // Parse ........-....-....-####-............
212
- arr[8] = (v = parseInt(string.slice(19, 23), 16)) >>> 8;
203
+ arr[8] = (v = hex2dec(string.slice(19, 23))) >>> 8;
213
204
  arr[9] = v & 0xff;
214
205
 
215
206
  // Parse ........-....-....-....-############
216
207
  // (Use "/" to avoid 32-bit truncation when bit-shifting high-order bytes)
217
- arr[10] = ((v = parseInt(string.slice(24, 36), 16)) / 0x10000000000) & 0xff;
208
+ arr[10] = ((v = hex2dec(string.slice(24, 36))) / 0x10000000000) & 0xff;
218
209
  arr[11] = (v / 0x100000000) & 0xff;
219
210
  arr[12] = (v >>> 24) & 0xff;
220
211
  arr[13] = (v >>> 16) & 0xff;
@@ -235,13 +226,6 @@ export class UUID {
235
226
  return r;
236
227
  }
237
228
 
238
- /**
239
- * Use base58 encoding to represent UUID as a 22 character string
240
- */
241
- get base58() {
242
- return base58_encode(this.#data, 0, 16);
243
- }
244
-
245
229
  /**
246
230
  * Standard UUID string in from: AAAAAAAA-BBBB-CCCC-DDDD-EEEEEEEEEEEE
247
231
  * Result is compatible with the {@link UUID.parse} method.
@@ -290,6 +274,7 @@ export class UUID {
290
274
  * @returns {boolean}
291
275
  */
292
276
  equals(other) {
277
+
293
278
  const this_data = this.#data;
294
279
  const other_data = other.#data;
295
280
 
@@ -303,12 +288,14 @@ export class UUID {
303
288
  }
304
289
 
305
290
  /**
306
- * @returns {number}
291
+ * Compute hash sum
292
+ * @returns {number} 32bit integer value
307
293
  */
308
294
  hash() {
309
295
  const data = this.#data;
310
296
 
311
- // use some non-metadata bytes as a hash
297
+ // use some non-metadata bytes as a hash, favoring speed as this is expected to be used a lot
298
+
312
299
  return data[3] // low byte of "time_low", very likely to differ between two UUIDs
313
300
  | data[5] << 8 // low byte of "time_mid"
314
301
  | data[9] << 16 // "clock_seq_low"
@@ -316,15 +303,18 @@ export class UUID {
316
303
  ;
317
304
  }
318
305
 
319
- toJSON() {
320
- return this.toString();
321
- }
322
-
323
- fromJSON(v) {
324
- this.parse(v);
325
- }
326
306
  }
327
307
 
308
+ /**
309
+ * @readonly
310
+ */
311
+ UUID.prototype.toJSON = UUID.prototype.toString;
312
+
313
+ /**
314
+ * @readonly
315
+ */
316
+ UUID.prototype.fromJSON = UUID.prototype.parse;
317
+
328
318
  /**
329
319
  * @readonly
330
320
  * @type {string}