@woosh/meep-engine 2.105.0 → 2.106.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.
- package/build/bundle-worker-image-decoder.js +1 -1
- package/build/bundle-worker-terrain.js +1 -1
- package/build/meep.cjs +38 -23
- package/build/meep.min.js +1 -1
- package/build/meep.module.js +38 -23
- package/package.json +1 -1
- package/src/core/assert.d.ts.map +1 -1
- package/src/core/assert.js +3 -1
- package/src/core/cache/Cache.d.ts.map +1 -1
- package/src/core/cache/Cache.js +23 -19
- package/src/core/collection/map/HashMap.d.ts.map +1 -1
- package/src/core/collection/map/HashMap.js +16 -3
package/build/meep.module.js
CHANGED
|
@@ -249,7 +249,9 @@ class InMemoryDescriptor extends BaseDescription {
|
|
|
249
249
|
|
|
250
250
|
function equal(a, b, m) {
|
|
251
251
|
if (a !== b) {
|
|
252
|
-
const
|
|
252
|
+
const details = `${a} !== ${b}`;
|
|
253
|
+
|
|
254
|
+
const message = (m !== undefined && m !== "") ? `${m}. ${details}` : details;
|
|
253
255
|
throw new Error(message);
|
|
254
256
|
}
|
|
255
257
|
}
|
|
@@ -60139,6 +60141,8 @@ class HashMap {
|
|
|
60139
60141
|
this.#bin_count = 2 ** this.#bin_count_power_of_two;
|
|
60140
60142
|
this.#bin_count_mask = this.#bin_count - 1;
|
|
60141
60143
|
|
|
60144
|
+
const old_entry_allocation_count = this.#entries_allocated_count;
|
|
60145
|
+
|
|
60142
60146
|
this.#entries_allocated_count = 2 ** this.#entries_count_power_of_two;
|
|
60143
60147
|
|
|
60144
60148
|
const BinsArray = UintArrayForCount(this.#entries_allocated_count + ENTRY_BASE);
|
|
@@ -60150,7 +60154,7 @@ class HashMap {
|
|
|
60150
60154
|
|
|
60151
60155
|
this.#entries = new_entries;
|
|
60152
60156
|
|
|
60153
|
-
array_copy(old_entries, 0, new_entries, 0, min2(
|
|
60157
|
+
array_copy(old_entries, 0, new_entries, 0, min2(old_entry_allocation_count, this.#entries_allocated_count));
|
|
60154
60158
|
|
|
60155
60159
|
if (this.#size > 0) {
|
|
60156
60160
|
// re-hash
|
|
@@ -60220,6 +60224,7 @@ class HashMap {
|
|
|
60220
60224
|
|
|
60221
60225
|
if (this.#entries[i] !== undefined) {
|
|
60222
60226
|
const entry = this.#entries[i];
|
|
60227
|
+
|
|
60223
60228
|
entry.hash = hash;
|
|
60224
60229
|
entry.key = k;
|
|
60225
60230
|
entry.value = v;
|
|
@@ -60296,7 +60301,9 @@ class HashMap {
|
|
|
60296
60301
|
|
|
60297
60302
|
const entry_index = this.#allocate_entry(key, value, raw_hash);
|
|
60298
60303
|
|
|
60299
|
-
|
|
60304
|
+
const bin_value = entry_index + ENTRY_BASE;
|
|
60305
|
+
|
|
60306
|
+
this.#bins[bin_index] = bin_value;
|
|
60300
60307
|
|
|
60301
60308
|
break;
|
|
60302
60309
|
|
|
@@ -60526,7 +60533,11 @@ class HashMap {
|
|
|
60526
60533
|
|
|
60527
60534
|
let written_entries = 0;
|
|
60528
60535
|
|
|
60529
|
-
for (
|
|
60536
|
+
for (
|
|
60537
|
+
let existing_entry_index = this.#entries_start;
|
|
60538
|
+
existing_entry_index < entries_bound;
|
|
60539
|
+
existing_entry_index++
|
|
60540
|
+
) {
|
|
60530
60541
|
const entry = entries[existing_entry_index];
|
|
60531
60542
|
|
|
60532
60543
|
const hash = entry.hash;
|
|
@@ -61080,6 +61091,22 @@ class Cache {
|
|
|
61080
61091
|
let element = this.data.get(key);
|
|
61081
61092
|
|
|
61082
61093
|
if (element === undefined) {
|
|
61094
|
+
//compute weight
|
|
61095
|
+
const elementWeight = this.computeElementWeight(key, value);
|
|
61096
|
+
|
|
61097
|
+
/**
|
|
61098
|
+
* It's possible that element being added is larger than cache's capacity,
|
|
61099
|
+
* in which case entire cache will be evicted, but there still won't be enough space
|
|
61100
|
+
* @type {number}
|
|
61101
|
+
*/
|
|
61102
|
+
const weightTarget = this.#maxWeight - elementWeight;
|
|
61103
|
+
|
|
61104
|
+
if (weightTarget < 0) {
|
|
61105
|
+
// Special case
|
|
61106
|
+
// element does not fit into cache, attempting to insert it forcibly would result in a full flush and overflow
|
|
61107
|
+
return;
|
|
61108
|
+
}
|
|
61109
|
+
|
|
61083
61110
|
element = new CacheElement();
|
|
61084
61111
|
|
|
61085
61112
|
element.key = key;
|
|
@@ -61097,25 +61124,8 @@ class Cache {
|
|
|
61097
61124
|
this.__last = element;
|
|
61098
61125
|
}
|
|
61099
61126
|
|
|
61100
|
-
//compute weight
|
|
61101
|
-
const elementWeight = this.computeElementWeight(key, value);
|
|
61102
|
-
|
|
61103
61127
|
element.weight = elementWeight;
|
|
61104
61128
|
|
|
61105
|
-
|
|
61106
|
-
/**
|
|
61107
|
-
* It's possible that element being added is larger than cache's capacity,
|
|
61108
|
-
* in which case entire cache will be evicted, but there still won't be enough space
|
|
61109
|
-
* @type {number}
|
|
61110
|
-
*/
|
|
61111
|
-
const weightTarget = this.#maxWeight - elementWeight;
|
|
61112
|
-
|
|
61113
|
-
if (weightTarget < 0) {
|
|
61114
|
-
// Special case
|
|
61115
|
-
// element does not fit into cache, attempting to insert it forcibly would result in a full flush and overflow
|
|
61116
|
-
return;
|
|
61117
|
-
}
|
|
61118
|
-
|
|
61119
61129
|
//evict elements until there is enough space for the element
|
|
61120
61130
|
this.evictUntilWeight(weightTarget);
|
|
61121
61131
|
|
|
@@ -61128,9 +61138,14 @@ class Cache {
|
|
|
61128
61138
|
// check if value is the same
|
|
61129
61139
|
if (value === element.value) ; else {
|
|
61130
61140
|
// replace value, adjust weight
|
|
61131
|
-
this.#weight -=
|
|
61132
|
-
|
|
61141
|
+
this.#weight -= element.weight;
|
|
61142
|
+
|
|
61143
|
+
const elementWeight = this.computeElementWeight(key, value);
|
|
61144
|
+
|
|
61145
|
+
this.#weight += elementWeight;
|
|
61133
61146
|
|
|
61147
|
+
// assign new values
|
|
61148
|
+
element.weight = elementWeight;
|
|
61134
61149
|
element.value = value;
|
|
61135
61150
|
}
|
|
61136
61151
|
|
package/package.json
CHANGED
package/src/core/assert.d.ts.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"assert.d.ts","sourceRoot":"","sources":["../../../src/core/assert.js"],"names":[],"mappings":"
|
|
1
|
+
{"version":3,"file":"assert.d.ts","sourceRoot":"","sources":["../../../src/core/assert.js"],"names":[],"mappings":"AA+BA,6CAIC;;IAsJD;;;;;OAKG;IACH,kEAQC;;;;;;;;;;;;;;;IAmBD;;;;;;OAMG;IACH,uGAGC;IAGD;;;;OAIG;IACH,0DAMC;IAED;;;;OAIG;IACH,0DAMC;IAED;;;;OAIG;IACH,2DAMC;IAED;;;;OAIG;IACH,4DAMC;IAED;;;;OAIG;IACH,0DAMC;IAED;;;;OAIG;IACH,2DAMC;IAED;;;;OAIG;IACH,sEAMC;IAED;;;;OAIG;IACH,4DAKC;IAED;;;;OAIG;IACH,+EAKC;IAGD;;;;OAIG;IACH,yDAMC;IAED;;;;OAIG;IACH,wDAIC;IAED;;;;OAIG;IACH,yDAMC;IAED;;;;OAIG;IACH,2DAIC;IAED;;;;OAIG;IACH,mEAIC;IAED;;;;;OAKG;IACH,2EAgBC;;AA/ZD,wDAEC;AAED,6CAEC;AAfD,qDAOC;AAUD;;;;;GAKG;AACH,kCAJW,MAAM,KACN,MAAM,MACN,MAAM,QAIhB;AAQD;;;;;GAKG;AACH,gCAJW,MAAM,KACN,MAAM,MACN,MAAM,QAiBhB;AAyBD;;;;;GAKG;AACH,uCAJW,MAAM,KACN,MAAM,MACN,MAAM,QAiBhB;AA5CD;;;;;GAKG;AACH,6BAJW,MAAM,KACN,MAAM,MACN,MAAM,QAiBhB;AAyBD;;;;;GAKG;AACH,oCAJW,MAAM,KACN,MAAM,MACN,MAAM,QAiBhB;AAKD;;;;;GAKG;AACH,0CAHW,MAAM,cACN,MAAM,QAehB;AAED;;;;;GAKG;AACH,iEAFW,MAAM,QAIhB;AAED;;;;;GAKG;AACH,mEAFW,MAAM,QAIhB;AAED;;;;;GAKG;AACH,+IAFW,MAAM,QAMhB"}
|
package/src/core/assert.js
CHANGED
|
@@ -4,7 +4,9 @@ import { InMemoryDescriptor } from "./debug/InMemoryDescriptor.js";
|
|
|
4
4
|
|
|
5
5
|
function equal(a, b, m) {
|
|
6
6
|
if (a !== b) {
|
|
7
|
-
const
|
|
7
|
+
const details = `${a} !== ${b}`;
|
|
8
|
+
|
|
9
|
+
const message = (m !== undefined && m !== "") ? `${m}. ${details}` : details;
|
|
8
10
|
throw new Error(message);
|
|
9
11
|
}
|
|
10
12
|
}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"Cache.d.ts","sourceRoot":"","sources":["../../../../src/core/cache/Cache.js"],"names":[],"mappings":"AASA;;;;;GAKG;AACH;IASI;;;;;;;;OAQG;IACH,sGARW,MAAM,EAuFhB;IAxDG;;;;OAIG;IACH,mBAA4B;IAE5B;;;;OAIG;IACH,qBAAgC;IAEhC;;;;OAIG;IACH,gBAAmB;IACnB;;;;OAIG;IACH,eAAkB;IAGlB;;;;OAIG;IACH,aAIE;IAEF;;;OAGG;IACH,WAFU,OAAO,GAAG,EAAC,KAAK,CAAC,CAEE;IAE7B;;;OAGG;IACH,WAFU,OAAO,GAAG,EAAC,KAAK,CAAC,CAEE;IAE7B;;;OAGG;IACH,OAFU,OAAO,GAAG,EAAC,KAAK,CAAC,CAEF;IAG7B;;;;;OAKG;IACH,kBAyBC;IAED;;;OAGG;IACH,QAFa,MAAM,CAIlB;IAED;;OAEG;IACH,+BAEC;IAUD;;;OAGG;IACH,2BAQC;IAED,wBAEC;IAxBD;;;OAGG;IACH,qBAEC;IAoBD;;;;OAIG;IACH,wBAaC;IAED;;;;;;OAMG;IACH,yBAHW,GAAG,GACD,OAAO,CAgCnB;IAED;;;;;OAKG;IACH,6BAUC;IAED;;;OAGG;IACH,sBAFa,aAAa,GAAG,EAAC,KAAK,CAAC,GAAC,IAAI,CAIxC;IAED;;;OAGG;IACH,YAFa,OAAO,CAkBnB;IAED;;;OAGG;IACH,+BAFW,MAAM,QAWhB;IAED;;;;OAIG;IACH,SAHW,GAAG,SACH,KAAK,
|
|
1
|
+
{"version":3,"file":"Cache.d.ts","sourceRoot":"","sources":["../../../../src/core/cache/Cache.js"],"names":[],"mappings":"AASA;;;;;GAKG;AACH;IASI;;;;;;;;OAQG;IACH,sGARW,MAAM,EAuFhB;IAxDG;;;;OAIG;IACH,mBAA4B;IAE5B;;;;OAIG;IACH,qBAAgC;IAEhC;;;;OAIG;IACH,gBAAmB;IACnB;;;;OAIG;IACH,eAAkB;IAGlB;;;;OAIG;IACH,aAIE;IAEF;;;OAGG;IACH,WAFU,OAAO,GAAG,EAAC,KAAK,CAAC,CAEE;IAE7B;;;OAGG;IACH,WAFU,OAAO,GAAG,EAAC,KAAK,CAAC,CAEE;IAE7B;;;OAGG;IACH,OAFU,OAAO,GAAG,EAAC,KAAK,CAAC,CAEF;IAG7B;;;;;OAKG;IACH,kBAyBC;IAED;;;OAGG;IACH,QAFa,MAAM,CAIlB;IAED;;OAEG;IACH,+BAEC;IAUD;;;OAGG;IACH,2BAQC;IAED,wBAEC;IAxBD;;;OAGG;IACH,qBAEC;IAoBD;;;;OAIG;IACH,wBAaC;IAED;;;;;;OAMG;IACH,yBAHW,GAAG,GACD,OAAO,CAgCnB;IAED;;;;;OAKG;IACH,6BAUC;IAED;;;OAGG;IACH,sBAFa,aAAa,GAAG,EAAC,KAAK,CAAC,GAAC,IAAI,CAIxC;IAED;;;OAGG;IACH,YAFa,OAAO,CAkBnB;IAED;;;OAGG;IACH,+BAFW,MAAM,QAWhB;IAED;;;;OAIG;IACH,SAHW,GAAG,SACH,KAAK,QAwEf;IAED;;;;OAIG;IACH,cAHW,GAAG,GACD,OAAO,CAInB;IAED;;;;OAIG;IACH,SAHW,GAAG,GACD,KAAK,GAAC,IAAI,CAYtB;IAGD;;;;;;OAMG;IACH,kBALW,GAAG,kBACM,GAAG,KAAE,KAAK,0BAElB,KAAK,CAchB;IAED;;;;OAIG;IACH,wBAqBC;IAED;;;;OAIG;IACH,YAHW,GAAG,GACD,OAAO,CAgBnB;IAED;;;;;OAKG;IACH,kBAHW,GAAG,GACD,OAAO,CAanB;IAED;;OAEG;IACH,cAcC;IAED;;;OAGG;IACH,aAOC;IAED;;;;;OAKG;IACH,wCAFa,OAAO,CAMnB;IAGL;;;OAGG;IACH,6CAAmB;IAEnB;;;OAGG;IACH,+BA5FiB,OAAO,CA4FF;IAEtB;;;OAGG;IACH,4BA9KiB,OAAO,CA8KL;;CAlBlB;mBA/hBkB,4BAA4B;6BAIlB,mBAAmB"}
|
package/src/core/cache/Cache.js
CHANGED
|
@@ -317,6 +317,22 @@ export class Cache {
|
|
|
317
317
|
let element = this.data.get(key);
|
|
318
318
|
|
|
319
319
|
if (element === undefined) {
|
|
320
|
+
//compute weight
|
|
321
|
+
const elementWeight = this.computeElementWeight(key, value);
|
|
322
|
+
|
|
323
|
+
/**
|
|
324
|
+
* It's possible that element being added is larger than cache's capacity,
|
|
325
|
+
* in which case entire cache will be evicted, but there still won't be enough space
|
|
326
|
+
* @type {number}
|
|
327
|
+
*/
|
|
328
|
+
const weightTarget = this.#maxWeight - elementWeight;
|
|
329
|
+
|
|
330
|
+
if (weightTarget < 0) {
|
|
331
|
+
// Special case
|
|
332
|
+
// element does not fit into cache, attempting to insert it forcibly would result in a full flush and overflow
|
|
333
|
+
return;
|
|
334
|
+
}
|
|
335
|
+
|
|
320
336
|
element = new CacheElement();
|
|
321
337
|
|
|
322
338
|
element.key = key;
|
|
@@ -334,25 +350,8 @@ export class Cache {
|
|
|
334
350
|
this.__last = element;
|
|
335
351
|
}
|
|
336
352
|
|
|
337
|
-
//compute weight
|
|
338
|
-
const elementWeight = this.computeElementWeight(key, value);
|
|
339
|
-
|
|
340
353
|
element.weight = elementWeight;
|
|
341
354
|
|
|
342
|
-
|
|
343
|
-
/**
|
|
344
|
-
* It's possible that element being added is larger than cache's capacity,
|
|
345
|
-
* in which case entire cache will be evicted, but there still won't be enough space
|
|
346
|
-
* @type {number}
|
|
347
|
-
*/
|
|
348
|
-
const weightTarget = this.#maxWeight - elementWeight;
|
|
349
|
-
|
|
350
|
-
if (weightTarget < 0) {
|
|
351
|
-
// Special case
|
|
352
|
-
// element does not fit into cache, attempting to insert it forcibly would result in a full flush and overflow
|
|
353
|
-
return;
|
|
354
|
-
}
|
|
355
|
-
|
|
356
355
|
//evict elements until there is enough space for the element
|
|
357
356
|
this.evictUntilWeight(weightTarget);
|
|
358
357
|
|
|
@@ -367,9 +366,14 @@ export class Cache {
|
|
|
367
366
|
// same value, no action required
|
|
368
367
|
} else {
|
|
369
368
|
// replace value, adjust weight
|
|
370
|
-
this.#weight -=
|
|
371
|
-
|
|
369
|
+
this.#weight -= element.weight;
|
|
370
|
+
|
|
371
|
+
const elementWeight = this.computeElementWeight(key, value);
|
|
372
|
+
|
|
373
|
+
this.#weight += elementWeight;
|
|
372
374
|
|
|
375
|
+
// assign new values
|
|
376
|
+
element.weight = elementWeight;
|
|
373
377
|
element.value = value;
|
|
374
378
|
}
|
|
375
379
|
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"HashMap.d.ts","sourceRoot":"","sources":["../../../../../src/core/collection/map/HashMap.js"],"names":[],"mappings":"AAiBA;;;;;;;;;;;;GAYG;AACH,uFAIC;AA8FD;;;;;;;GAOG;AACH;IA+DI;;;;;;OAMG;IACH,4FALuB,MAAM,EAsC5B;IAlBG;;;;;OAKG;IACH,iCAAsC;IACtC;;;;;OAKG;IACH,qCAA8C;IAOlD,mBAEC;IAED;;;OAGG;IACH,kBAFa,MAAM,CAIlB;
|
|
1
|
+
{"version":3,"file":"HashMap.d.ts","sourceRoot":"","sources":["../../../../../src/core/collection/map/HashMap.js"],"names":[],"mappings":"AAiBA;;;;;;;;;;;;GAYG;AACH,uFAIC;AA8FD;;;;;;;GAOG;AACH;IA+DI;;;;;;OAMG;IACH,4FALuB,MAAM,EAsC5B;IAlBG;;;;;OAKG;IACH,iCAAsC;IACtC;;;;;OAKG;IACH,qCAA8C;IAOlD,mBAEC;IAED;;;OAGG;IACH,kBAFa,MAAM,CAIlB;IAuJD;;;;OAIG;IACH,SAHW,CAAC,SACD,CAAC,QA0EX;IAED;;;;OAIG;IACH,SAHW,CAAC,GACC,CAAC,GAAC,SAAS,CA+BvB;IAED;;;;;;;;OAQG;IACH,kBALW,CAAC,kBACQ,CAAC,KAAE,CAAC,0BAEZ,CAAC,CAcZ;IAED;;;;;OAKG;IACH,cAJW,CAAC,SACD,CAAC,GACA,CAAC,CAYZ;IAuBD;;;;OAIG;IACH,YAHW,CAAC,GACC,OAAO,CA+CnB;IAED;;;;;OAKG;IACH,4CAFa,OAAO,CA+BnB;IAOD;;OAEG;IACH,gBAsDC;IAmBD,2CAwBC;IAED;;;;OAIG;IACH,SAHW,CAAC,GACC,OAAO,CAInB;IAED;;OAEG;IACH,cA6BC;IA+BD;;;OAGG;IACH,UAFa,SAAS,CAAC,CAAC,CAOvB;IAED;;;OAGG;IACH,QAFa,SAAS,CAAC,CAAC,CAMvB;IAhDD,yDA2BC;;CAsBJ"}
|
|
@@ -271,6 +271,8 @@ export class HashMap {
|
|
|
271
271
|
this.#bin_count = 2 ** this.#bin_count_power_of_two;
|
|
272
272
|
this.#bin_count_mask = this.#bin_count - 1;
|
|
273
273
|
|
|
274
|
+
const old_entry_allocation_count = this.#entries_allocated_count;
|
|
275
|
+
|
|
274
276
|
this.#entries_allocated_count = 2 ** this.#entries_count_power_of_two;
|
|
275
277
|
|
|
276
278
|
const BinsArray = UintArrayForCount(this.#entries_allocated_count + ENTRY_BASE);
|
|
@@ -282,7 +284,7 @@ export class HashMap {
|
|
|
282
284
|
|
|
283
285
|
this.#entries = new_entries;
|
|
284
286
|
|
|
285
|
-
array_copy(old_entries, 0, new_entries, 0, min2(
|
|
287
|
+
array_copy(old_entries, 0, new_entries, 0, min2(old_entry_allocation_count, this.#entries_allocated_count));
|
|
286
288
|
|
|
287
289
|
if (this.#size > 0) {
|
|
288
290
|
// re-hash
|
|
@@ -357,6 +359,9 @@ export class HashMap {
|
|
|
357
359
|
|
|
358
360
|
if (this.#entries[i] !== undefined) {
|
|
359
361
|
const entry = this.#entries[i];
|
|
362
|
+
|
|
363
|
+
assert.equal(entry.hash, RESERVED_HASH, 'Entry is occupied');
|
|
364
|
+
|
|
360
365
|
entry.hash = hash;
|
|
361
366
|
entry.key = k;
|
|
362
367
|
entry.value = v;
|
|
@@ -441,7 +446,11 @@ export class HashMap {
|
|
|
441
446
|
assert.equal(this.#entries[entry_index].value, value, 'entry.value');
|
|
442
447
|
assert.equal(this.#entries[entry_index].key, key, 'entry.key');
|
|
443
448
|
|
|
444
|
-
|
|
449
|
+
const bin_value = entry_index + ENTRY_BASE;
|
|
450
|
+
|
|
451
|
+
this.#bins[bin_index] = bin_value;
|
|
452
|
+
|
|
453
|
+
assert.equal(bin_value, this.#bins[bin_index], 'Bin value write error');
|
|
445
454
|
|
|
446
455
|
break;
|
|
447
456
|
|
|
@@ -675,7 +684,11 @@ export class HashMap {
|
|
|
675
684
|
|
|
676
685
|
let written_entries = 0;
|
|
677
686
|
|
|
678
|
-
for (
|
|
687
|
+
for (
|
|
688
|
+
let existing_entry_index = this.#entries_start;
|
|
689
|
+
existing_entry_index < entries_bound;
|
|
690
|
+
existing_entry_index++
|
|
691
|
+
) {
|
|
679
692
|
const entry = entries[existing_entry_index];
|
|
680
693
|
|
|
681
694
|
const hash = entry.hash;
|