@woosh/meep-engine 2.115.0 → 2.116.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/meep.cjs +144 -144
- package/build/meep.min.js +1 -1
- package/build/meep.module.js +144 -144
- package/editor/view/ecs/HierarchicalEntityListView.js +2 -2
- package/package.json +1 -1
- package/src/core/collection/array/{compareArrays.d.ts → array_compare.d.ts} +2 -2
- package/src/core/collection/array/array_compare.d.ts.map +1 -0
- package/src/core/collection/array/{compareArrays.js → array_compare.js} +5 -1
- package/src/core/collection/array/{arrayIndexByEquality.d.ts → array_index_by_equality.d.ts} +2 -2
- package/src/core/collection/array/array_index_by_equality.d.ts.map +1 -0
- package/src/core/collection/array/{arrayIndexByEquality.js → array_index_by_equality.js} +1 -1
- package/src/core/collection/array/array_pick_best_element.d.ts.map +1 -0
- package/src/core/collection/array/{arrayPickBestElement.js → array_pick_best_element.js} +2 -2
- package/src/core/collection/array/array_pick_best_elements.d.ts +8 -0
- package/src/core/collection/array/array_pick_best_elements.d.ts.map +1 -0
- package/src/core/collection/array/{arrayPickBestElements.js → array_pick_best_elements.js} +1 -1
- package/src/core/collection/array/{arraySetDiff.d.ts → array_set_diff.d.ts} +3 -3
- package/src/core/collection/array/array_set_diff.d.ts.map +1 -0
- package/src/core/collection/array/{arraySetDiff.js → array_set_diff.js} +4 -4
- package/src/core/collection/array/{arraySetSortingDiff.d.ts → array_set_diff_sorting.d.ts} +2 -2
- package/src/core/collection/array/array_set_diff_sorting.d.ts.map +1 -0
- package/src/core/collection/array/{arraySetSortingDiff.js → array_set_diff_sorting.js} +1 -1
- package/src/core/collection/list/FilteredListProjection.d.ts.map +1 -1
- package/src/core/collection/list/FilteredListProjection.js +2 -2
- package/src/core/collection/list/List.js +4 -4
- package/src/core/geom/3d/topology/expandConnectivityByLocality.js +2 -2
- package/src/core/model/object/compareValues.js +3 -3
- package/src/engine/ecs/EntityComponentDataset.js +3 -3
- package/src/engine/graphics/ecs/mesh/SkeletonUtils.js +2 -2
- package/src/engine/platform/WebEnginePlatform.d.ts.map +1 -1
- package/src/engine/platform/WebEnginePlatform.js +4 -4
- package/src/engine/save/GameStateLoader.js +2 -2
- package/src/engine/ui/cursor/CursorCoalescence.d.ts.map +1 -1
- package/src/engine/ui/cursor/CursorCoalescence.js +2 -2
- package/src/view/elements/radial/RadialMenu.js +2 -2
- package/src/core/collection/array/arrayIndexByEquality.d.ts.map +0 -1
- package/src/core/collection/array/arrayPickBestElement.d.ts.map +0 -1
- package/src/core/collection/array/arrayPickBestElements.d.ts +0 -8
- package/src/core/collection/array/arrayPickBestElements.d.ts.map +0 -1
- package/src/core/collection/array/arraySetDiff.d.ts.map +0 -1
- package/src/core/collection/array/arraySetSortingDiff.d.ts.map +0 -1
- package/src/core/collection/array/compareArrays.d.ts.map +0 -1
- /package/src/core/collection/array/{arrayPickBestElement.d.ts → array_pick_best_element.d.ts} +0 -0
package/build/meep.module.js
CHANGED
|
@@ -61407,7 +61407,7 @@ function objectsEqual(a, b) {
|
|
|
61407
61407
|
* @param {function(a:T,b:T):boolean} equals
|
|
61408
61408
|
* @returns {number} index of first match or -1 if no matches found
|
|
61409
61409
|
*/
|
|
61410
|
-
function
|
|
61410
|
+
function array_index_by_equality(array, element, equals) {
|
|
61411
61411
|
const n = array.length;
|
|
61412
61412
|
|
|
61413
61413
|
for (let i = 0; i < n; i++) {
|
|
@@ -61423,14 +61423,14 @@ function arrayIndexByEquality(array, element, equals) {
|
|
|
61423
61423
|
|
|
61424
61424
|
/**
|
|
61425
61425
|
* Compute a diff between two arrays, result is a 3 way split between common items, unique items in `a` array and unique items in `b` array
|
|
61426
|
-
* @see prefer to use {@link
|
|
61426
|
+
* @see prefer to use {@link array_set_diff_sorting}, as it's much faster, especially for large sets
|
|
61427
61427
|
* @template T
|
|
61428
61428
|
* @param {T[]} a
|
|
61429
61429
|
* @param {T[]} b
|
|
61430
61430
|
* @param {function(a:T,b:T):boolean} [equals] method to determine equality between two elements
|
|
61431
61431
|
* @returns {{uniqueA:T[], uniqueB:T[], common:T[]}}
|
|
61432
61432
|
*/
|
|
61433
|
-
function
|
|
61433
|
+
function array_set_diff(a, b, equals = strictEquals) {
|
|
61434
61434
|
|
|
61435
61435
|
const uniqueA = a.slice();
|
|
61436
61436
|
const uniqueB = b.slice();
|
|
@@ -61442,7 +61442,7 @@ function arraySetDiff(a, b, equals = strictEquals) {
|
|
|
61442
61442
|
for (let i = 0; i < a_length; i++) {
|
|
61443
61443
|
const elA = uniqueA[i];
|
|
61444
61444
|
|
|
61445
|
-
const j =
|
|
61445
|
+
const j = array_index_by_equality(uniqueB, elA, equals);
|
|
61446
61446
|
|
|
61447
61447
|
if (j !== -1) {
|
|
61448
61448
|
// common element found
|
|
@@ -61667,7 +61667,7 @@ class List {
|
|
|
61667
61667
|
|
|
61668
61668
|
const data = this.data;
|
|
61669
61669
|
|
|
61670
|
-
const diff =
|
|
61670
|
+
const diff = array_set_diff(data, new_data, objectsEqual);
|
|
61671
61671
|
|
|
61672
61672
|
//resolve diff
|
|
61673
61673
|
const removals = diff.uniqueA;
|
|
@@ -62186,7 +62186,7 @@ class List {
|
|
|
62186
62186
|
for (let i = 0; i < nThisItems; i++) {
|
|
62187
62187
|
const a = thisItems[i];
|
|
62188
62188
|
|
|
62189
|
-
const index =
|
|
62189
|
+
const index = array_index_by_equality(otherItems, a, invokeObjectEquals);
|
|
62190
62190
|
|
|
62191
62191
|
if (index !== -1) {
|
|
62192
62192
|
newData[index] = a;
|
|
@@ -94307,7 +94307,7 @@ class EntityComponentDataset {
|
|
|
94307
94307
|
|
|
94308
94308
|
const newComponentTypeCount = map.length;
|
|
94309
94309
|
|
|
94310
|
-
const diff =
|
|
94310
|
+
const diff = array_set_diff(map, this.componentTypeMap);
|
|
94311
94311
|
|
|
94312
94312
|
const typesToAdd = diff.uniqueA;
|
|
94313
94313
|
const typesToRemove = diff.uniqueB;
|
|
@@ -94525,7 +94525,7 @@ class EntityComponentDataset {
|
|
|
94525
94525
|
* @returns {boolean} false if no new classes were added, true if at least one new class was added
|
|
94526
94526
|
*/
|
|
94527
94527
|
registerManyComponentTypes(types) {
|
|
94528
|
-
const diff =
|
|
94528
|
+
const diff = array_set_diff(types, this.componentTypeMap);
|
|
94529
94529
|
|
|
94530
94530
|
if (diff.uniqueA.length === 0) {
|
|
94531
94531
|
// all classes area already registered
|
|
@@ -115487,43 +115487,138 @@ function getURLHash() {
|
|
|
115487
115487
|
return result;
|
|
115488
115488
|
}
|
|
115489
115489
|
|
|
115490
|
-
|
|
115491
|
-
|
|
115492
|
-
|
|
115493
|
-
|
|
115494
|
-
|
|
115495
|
-
|
|
115490
|
+
/**
|
|
115491
|
+
* Picks element with highest score from the array using supplied scoring function.
|
|
115492
|
+
* If multiple elements with the same highest score exist, the result will be first such encountered element
|
|
115493
|
+
* @template T
|
|
115494
|
+
* @param {T[]} array
|
|
115495
|
+
* @param {function(el:T, index:number):number} scoreFunction
|
|
115496
|
+
* @returns {T|undefined}
|
|
115497
|
+
*/
|
|
115498
|
+
function array_pick_best_element(array, scoreFunction) {
|
|
115499
|
+
|
|
115500
|
+
let bestElement;
|
|
115501
|
+
let bestScore;
|
|
115502
|
+
|
|
115503
|
+
const size = array.length;
|
|
115504
|
+
|
|
115505
|
+
if (size === 0) {
|
|
115506
|
+
return undefined;
|
|
115496
115507
|
}
|
|
115497
115508
|
|
|
115498
|
-
|
|
115499
|
-
|
|
115500
|
-
|
|
115501
|
-
|
|
115502
|
-
|
|
115509
|
+
bestElement = array[0];
|
|
115510
|
+
|
|
115511
|
+
bestScore = scoreFunction(bestElement, 0);
|
|
115512
|
+
|
|
115513
|
+
for (let i = 1; i < size; i++) {
|
|
115514
|
+
const el = array[i];
|
|
115515
|
+
|
|
115516
|
+
// compute score
|
|
115517
|
+
const score = scoreFunction(el, i);
|
|
115518
|
+
|
|
115519
|
+
if (score > bestScore) {
|
|
115520
|
+
bestScore = score;
|
|
115521
|
+
bestElement = el;
|
|
115522
|
+
}
|
|
115523
|
+
}
|
|
115524
|
+
|
|
115525
|
+
return bestElement;
|
|
115526
|
+
}
|
|
115527
|
+
|
|
115528
|
+
/**
|
|
115529
|
+
* Base class for implementing achievement system API connectors
|
|
115530
|
+
*/
|
|
115531
|
+
class AchievementGateway {
|
|
115532
|
+
constructor() {
|
|
115533
|
+
|
|
115503
115534
|
}
|
|
115504
115535
|
|
|
115505
115536
|
/**
|
|
115506
|
-
*
|
|
115507
|
-
* @returns {
|
|
115537
|
+
* Retrieve list of unlocked achievements
|
|
115538
|
+
* @returns {Promise<String[]>} IDs of unlocked achievements
|
|
115508
115539
|
*/
|
|
115509
|
-
|
|
115540
|
+
getUnlocked() {
|
|
115541
|
+
//needs to be overridden in subclass
|
|
115510
115542
|
throw new Error('Not implemented');
|
|
115511
115543
|
}
|
|
115512
115544
|
|
|
115513
115545
|
/**
|
|
115546
|
+
* Unlock an achievements by ID
|
|
115547
|
+
* @param {String} id
|
|
115514
115548
|
* @returns {Promise}
|
|
115515
115549
|
*/
|
|
115516
|
-
|
|
115517
|
-
|
|
115550
|
+
unlock(id) {
|
|
115551
|
+
//needs to be overridden in subclass
|
|
115552
|
+
throw new Error('Not implemented');
|
|
115518
115553
|
}
|
|
115519
|
-
|
|
115554
|
+
}
|
|
115555
|
+
|
|
115556
|
+
class StorageAchievementGateway extends AchievementGateway {
|
|
115520
115557
|
/**
|
|
115521
|
-
*
|
|
115558
|
+
*
|
|
115559
|
+
* @param {Storage} storage
|
|
115560
|
+
* @param {String} [key]
|
|
115522
115561
|
*/
|
|
115523
|
-
|
|
115524
|
-
|
|
115562
|
+
constructor(storage, key = "achievements") {
|
|
115563
|
+
super();
|
|
115564
|
+
|
|
115565
|
+
this.storage = storage;
|
|
115566
|
+
|
|
115567
|
+
this.key = key;
|
|
115568
|
+
|
|
115569
|
+
this.last = Promise.resolve();
|
|
115525
115570
|
}
|
|
115526
115571
|
|
|
115572
|
+
getUnlocked() {
|
|
115573
|
+
return new Promise((resolve, reject) => {
|
|
115574
|
+
this.storage.load(this.key, (list) => {
|
|
115575
|
+
|
|
115576
|
+
if (list === undefined) {
|
|
115577
|
+
resolve([]);
|
|
115578
|
+
} else {
|
|
115579
|
+
resolve(list);
|
|
115580
|
+
}
|
|
115581
|
+
|
|
115582
|
+
}, reject, noop);
|
|
115583
|
+
});
|
|
115584
|
+
}
|
|
115585
|
+
|
|
115586
|
+
unlock(id) {
|
|
115587
|
+
const storage = this.storage;
|
|
115588
|
+
|
|
115589
|
+
const promise = this.last.finally(() => {
|
|
115590
|
+
return new Promise((resolve, reject) => {
|
|
115591
|
+
//read list of unlocked achievements
|
|
115592
|
+
storage.load(this.key, list => {
|
|
115593
|
+
|
|
115594
|
+
let unlocked;
|
|
115595
|
+
if (list !== undefined) {
|
|
115596
|
+
if (list.includes(id)) {
|
|
115597
|
+
//achievement is already unlocked
|
|
115598
|
+
resolve();
|
|
115599
|
+
return;
|
|
115600
|
+
}
|
|
115601
|
+
|
|
115602
|
+
unlocked = list.slice();
|
|
115603
|
+
|
|
115604
|
+
} else {
|
|
115605
|
+
unlocked = [];
|
|
115606
|
+
}
|
|
115607
|
+
|
|
115608
|
+
//modify unlocked achievements
|
|
115609
|
+
unlocked.push(id);
|
|
115610
|
+
|
|
115611
|
+
//write back
|
|
115612
|
+
storage.store(this.key, unlocked, resolve, reject, noop);
|
|
115613
|
+
}, reject, noop);
|
|
115614
|
+
});
|
|
115615
|
+
}
|
|
115616
|
+
);
|
|
115617
|
+
|
|
115618
|
+
this.last = promise;
|
|
115619
|
+
|
|
115620
|
+
return promise;
|
|
115621
|
+
}
|
|
115527
115622
|
}
|
|
115528
115623
|
|
|
115529
115624
|
class Storage {
|
|
@@ -115797,138 +115892,43 @@ class IndexedDBStorage extends Storage {
|
|
|
115797
115892
|
}
|
|
115798
115893
|
}
|
|
115799
115894
|
|
|
115800
|
-
|
|
115801
|
-
* Base class for implementing achievement system API connectors
|
|
115802
|
-
*/
|
|
115803
|
-
class AchievementGateway {
|
|
115804
|
-
constructor() {
|
|
115805
|
-
|
|
115806
|
-
}
|
|
115807
|
-
|
|
115895
|
+
class EnginePlatform {
|
|
115808
115896
|
/**
|
|
115809
|
-
*
|
|
115810
|
-
* @returns {Promise<String[]>} IDs of unlocked achievements
|
|
115897
|
+
* @returns {Storage}
|
|
115811
115898
|
*/
|
|
115812
|
-
|
|
115813
|
-
//needs to be overridden in subclass
|
|
115899
|
+
getStorage() {
|
|
115814
115900
|
throw new Error('Not implemented');
|
|
115815
115901
|
}
|
|
115816
115902
|
|
|
115817
115903
|
/**
|
|
115818
|
-
*
|
|
115819
|
-
* @param {String} id
|
|
115820
|
-
* @returns {Promise}
|
|
115904
|
+
* @returns {AchievementGateway}
|
|
115821
115905
|
*/
|
|
115822
|
-
|
|
115823
|
-
//needs to be overridden in subclass
|
|
115906
|
+
getAchievementGateway() {
|
|
115824
115907
|
throw new Error('Not implemented');
|
|
115825
115908
|
}
|
|
115826
|
-
|
|
115827
|
-
|
|
115828
|
-
class StorageAchievementGateway extends AchievementGateway {
|
|
115909
|
+
|
|
115829
115910
|
/**
|
|
115830
|
-
*
|
|
115831
|
-
* @
|
|
115832
|
-
* @param {String} [key]
|
|
115911
|
+
* @param {string[]} options
|
|
115912
|
+
* @returns {string}
|
|
115833
115913
|
*/
|
|
115834
|
-
|
|
115835
|
-
|
|
115836
|
-
|
|
115837
|
-
this.storage = storage;
|
|
115838
|
-
|
|
115839
|
-
this.key = key;
|
|
115840
|
-
|
|
115841
|
-
this.last = Promise.resolve();
|
|
115842
|
-
}
|
|
115843
|
-
|
|
115844
|
-
getUnlocked() {
|
|
115845
|
-
return new Promise((resolve, reject) => {
|
|
115846
|
-
this.storage.load(this.key, (list) => {
|
|
115847
|
-
|
|
115848
|
-
if (list === undefined) {
|
|
115849
|
-
resolve([]);
|
|
115850
|
-
} else {
|
|
115851
|
-
resolve(list);
|
|
115852
|
-
}
|
|
115853
|
-
|
|
115854
|
-
}, reject, noop);
|
|
115855
|
-
});
|
|
115856
|
-
}
|
|
115857
|
-
|
|
115858
|
-
unlock(id) {
|
|
115859
|
-
const storage = this.storage;
|
|
115860
|
-
|
|
115861
|
-
const promise = this.last.finally(() => {
|
|
115862
|
-
return new Promise((resolve, reject) => {
|
|
115863
|
-
//read list of unlocked achievements
|
|
115864
|
-
storage.load(this.key, list => {
|
|
115865
|
-
|
|
115866
|
-
let unlocked;
|
|
115867
|
-
if (list !== undefined) {
|
|
115868
|
-
if (list.includes(id)) {
|
|
115869
|
-
//achievement is already unlocked
|
|
115870
|
-
resolve();
|
|
115871
|
-
return;
|
|
115872
|
-
}
|
|
115873
|
-
|
|
115874
|
-
unlocked = list.slice();
|
|
115875
|
-
|
|
115876
|
-
} else {
|
|
115877
|
-
unlocked = [];
|
|
115878
|
-
}
|
|
115879
|
-
|
|
115880
|
-
//modify unlocked achievements
|
|
115881
|
-
unlocked.push(id);
|
|
115882
|
-
|
|
115883
|
-
//write back
|
|
115884
|
-
storage.store(this.key, unlocked, resolve, reject, noop);
|
|
115885
|
-
}, reject, noop);
|
|
115886
|
-
});
|
|
115887
|
-
}
|
|
115888
|
-
);
|
|
115889
|
-
|
|
115890
|
-
this.last = promise;
|
|
115891
|
-
|
|
115892
|
-
return promise;
|
|
115914
|
+
pickDefaultLocale(options) {
|
|
115915
|
+
throw new Error('Not implemented');
|
|
115893
115916
|
}
|
|
115894
|
-
}
|
|
115895
|
-
|
|
115896
|
-
/**
|
|
115897
|
-
* Picks element with highest score from the array using supplied scoring function.
|
|
115898
|
-
* If multiple elements with the same highest score exist, the result will be first such encountered element
|
|
115899
|
-
* @template T
|
|
115900
|
-
* @param {T[]} array
|
|
115901
|
-
* @param {function(el:T, index:number):number} scoreFunction
|
|
115902
|
-
* @returns {T|undefined}
|
|
115903
|
-
*/
|
|
115904
|
-
function arrayPickBestElement(array, scoreFunction) {
|
|
115905
115917
|
|
|
115906
|
-
|
|
115907
|
-
|
|
115908
|
-
|
|
115909
|
-
|
|
115910
|
-
|
|
115911
|
-
if (size === 0) {
|
|
115912
|
-
return undefined;
|
|
115918
|
+
/**
|
|
115919
|
+
* @returns {Promise}
|
|
115920
|
+
*/
|
|
115921
|
+
startup() {
|
|
115922
|
+
return Promise.resolve();
|
|
115913
115923
|
}
|
|
115914
115924
|
|
|
115915
|
-
|
|
115916
|
-
|
|
115917
|
-
|
|
115918
|
-
|
|
115919
|
-
|
|
115920
|
-
const el = array[i];
|
|
115921
|
-
|
|
115922
|
-
// compute score
|
|
115923
|
-
const score = scoreFunction(el, i);
|
|
115924
|
-
|
|
115925
|
-
if (score > bestScore) {
|
|
115926
|
-
bestScore = score;
|
|
115927
|
-
bestElement = el;
|
|
115928
|
-
}
|
|
115925
|
+
/**
|
|
115926
|
+
* @returns {Promise}
|
|
115927
|
+
*/
|
|
115928
|
+
shutdown() {
|
|
115929
|
+
return Promise.resolve();
|
|
115929
115930
|
}
|
|
115930
115931
|
|
|
115931
|
-
return bestElement;
|
|
115932
115932
|
}
|
|
115933
115933
|
|
|
115934
115934
|
class WebEnginePlatform extends EnginePlatform {
|
|
@@ -116003,7 +116003,7 @@ class WebEnginePlatform extends EnginePlatform {
|
|
|
116003
116003
|
};
|
|
116004
116004
|
});
|
|
116005
116005
|
|
|
116006
|
-
const best =
|
|
116006
|
+
const best = array_pick_best_element(scoredKeys, o => o.score);
|
|
116007
116007
|
|
|
116008
116008
|
if (best.score === 0) {
|
|
116009
116009
|
return 'en-gb';
|
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import {
|
|
1
|
+
import { array_set_diff_sorting } from "../../../src/core/collection/array/array_set_diff_sorting.js";
|
|
2
2
|
import List from "../../../src/core/collection/list/List.js";
|
|
3
3
|
import Signal from "../../../src/core/events/signal/Signal.js";
|
|
4
4
|
import { number_compare_ascending } from "../../../src/core/primitives/numbers/number_compare_ascending.js";
|
|
@@ -50,7 +50,7 @@ export class HierarchicalEntityListView extends EmptyView {
|
|
|
50
50
|
});
|
|
51
51
|
|
|
52
52
|
// perform patch
|
|
53
|
-
const diff =
|
|
53
|
+
const diff = array_set_diff_sorting(new_roots, this.#roots.asArray(), number_compare_ascending);
|
|
54
54
|
|
|
55
55
|
for (let i = 0; i < diff.uniqueB.length; i++) {
|
|
56
56
|
const removal_id = diff.uniqueB[i];
|
package/package.json
CHANGED
|
@@ -5,5 +5,5 @@
|
|
|
5
5
|
* @param {function(T,T):number} comparator
|
|
6
6
|
* @return {number}
|
|
7
7
|
*/
|
|
8
|
-
export function
|
|
9
|
-
//# sourceMappingURL=
|
|
8
|
+
export function array_compare<T>(as: T[], bs: T[], comparator: (arg0: T, arg1: T) => number): number;
|
|
9
|
+
//# sourceMappingURL=array_compare.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"array_compare.d.ts","sourceRoot":"","sources":["../../../../../src/core/collection/array/array_compare.js"],"names":[],"mappings":"AAEA;;;;;;GAMG;AACH,qFAHyB,MAAM,GACnB,MAAM,CA0BjB"}
|
|
@@ -1,3 +1,5 @@
|
|
|
1
|
+
import { assert } from "../../assert.js";
|
|
2
|
+
|
|
1
3
|
/**
|
|
2
4
|
* @template T
|
|
3
5
|
* @param {T[]} as
|
|
@@ -5,7 +7,9 @@
|
|
|
5
7
|
* @param {function(T,T):number} comparator
|
|
6
8
|
* @return {number}
|
|
7
9
|
*/
|
|
8
|
-
export function
|
|
10
|
+
export function array_compare(as, bs, comparator) {
|
|
11
|
+
assert.isFunction(comparator,'comparator');
|
|
12
|
+
|
|
9
13
|
const n = as.length;
|
|
10
14
|
const m = bs.length;
|
|
11
15
|
|
package/src/core/collection/array/{arrayIndexByEquality.d.ts → array_index_by_equality.d.ts}
RENAMED
|
@@ -6,5 +6,5 @@
|
|
|
6
6
|
* @param {function(a:T,b:T):boolean} equals
|
|
7
7
|
* @returns {number} index of first match or -1 if no matches found
|
|
8
8
|
*/
|
|
9
|
-
export function
|
|
10
|
-
//# sourceMappingURL=
|
|
9
|
+
export function array_index_by_equality<T>(array: T[], element: T, equals: any): number;
|
|
10
|
+
//# sourceMappingURL=array_index_by_equality.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"array_index_by_equality.d.ts","sourceRoot":"","sources":["../../../../../src/core/collection/array/array_index_by_equality.js"],"names":[],"mappings":"AAAA;;;;;;;GAOG;AACH,iFAFa,MAAM,CAclB"}
|
|
@@ -6,7 +6,7 @@
|
|
|
6
6
|
* @param {function(a:T,b:T):boolean} equals
|
|
7
7
|
* @returns {number} index of first match or -1 if no matches found
|
|
8
8
|
*/
|
|
9
|
-
export function
|
|
9
|
+
export function array_index_by_equality(array, element, equals) {
|
|
10
10
|
const n = array.length;
|
|
11
11
|
|
|
12
12
|
for (let i = 0; i < n; i++) {
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"array_pick_best_element.d.ts","sourceRoot":"","sources":["../../../../../src/core/collection/array/array_pick_best_element.js"],"names":[],"mappings":"AAEA;;;;;;;GAOG;AACH,8EAkCC"}
|
|
@@ -8,9 +8,9 @@ import { assert } from "../../assert.js";
|
|
|
8
8
|
* @param {function(el:T, index:number):number} scoreFunction
|
|
9
9
|
* @returns {T|undefined}
|
|
10
10
|
*/
|
|
11
|
-
export function
|
|
11
|
+
export function array_pick_best_element(array, scoreFunction) {
|
|
12
12
|
assert.notEqual(array, undefined, 'array is undefined');
|
|
13
|
-
assert.
|
|
13
|
+
assert.isFunction(scoreFunction, 'scoreFunction');
|
|
14
14
|
|
|
15
15
|
let bestElement;
|
|
16
16
|
let bestScore;
|
|
@@ -0,0 +1,8 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* @template T
|
|
3
|
+
* @param {T[]} array
|
|
4
|
+
* @param {function(el:T, index:number):number} scoreFunction
|
|
5
|
+
* @returns {T[]}
|
|
6
|
+
*/
|
|
7
|
+
export function array_pick_best_elements<T>(array: T[], scoreFunction: any): T[];
|
|
8
|
+
//# sourceMappingURL=array_pick_best_elements.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"array_pick_best_elements.d.ts","sourceRoot":"","sources":["../../../../../src/core/collection/array/array_pick_best_elements.js"],"names":[],"mappings":"AAEA;;;;;GAKG;AACH,iFA0CC"}
|
|
@@ -6,7 +6,7 @@ import { assert } from "../../assert.js";
|
|
|
6
6
|
* @param {function(el:T, index:number):number} scoreFunction
|
|
7
7
|
* @returns {T[]}
|
|
8
8
|
*/
|
|
9
|
-
export function
|
|
9
|
+
export function array_pick_best_elements(array, scoreFunction) {
|
|
10
10
|
assert.notEqual(array, undefined, 'array is undefined');
|
|
11
11
|
assert.isArray(array, 'array');
|
|
12
12
|
|
|
@@ -1,16 +1,16 @@
|
|
|
1
1
|
/**
|
|
2
2
|
* Compute a diff between two arrays, result is a 3 way split between common items, unique items in `a` array and unique items in `b` array
|
|
3
|
-
* @see prefer to use {@link
|
|
3
|
+
* @see prefer to use {@link array_set_diff_sorting}, as it's much faster, especially for large sets
|
|
4
4
|
* @template T
|
|
5
5
|
* @param {T[]} a
|
|
6
6
|
* @param {T[]} b
|
|
7
7
|
* @param {function(a:T,b:T):boolean} [equals] method to determine equality between two elements
|
|
8
8
|
* @returns {{uniqueA:T[], uniqueB:T[], common:T[]}}
|
|
9
9
|
*/
|
|
10
|
-
export function
|
|
10
|
+
export function array_set_diff<T>(a: T[], b: T[], equals?: typeof strictEquals): {
|
|
11
11
|
uniqueA: T[];
|
|
12
12
|
uniqueB: T[];
|
|
13
13
|
common: T[];
|
|
14
14
|
};
|
|
15
15
|
import { strictEquals } from "../../function/strictEquals.js";
|
|
16
|
-
//# sourceMappingURL=
|
|
16
|
+
//# sourceMappingURL=array_set_diff.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"array_set_diff.d.ts","sourceRoot":"","sources":["../../../../../src/core/collection/array/array_set_diff.js"],"names":[],"mappings":"AAKA;;;;;;;;GAQG;AACH;;;;EAoCC;6BAhD4B,gCAAgC"}
|
|
@@ -1,18 +1,18 @@
|
|
|
1
1
|
import { assert } from "../../assert.js";
|
|
2
2
|
|
|
3
3
|
import { strictEquals } from "../../function/strictEquals.js";
|
|
4
|
-
import {
|
|
4
|
+
import { array_index_by_equality } from "./array_index_by_equality.js";
|
|
5
5
|
|
|
6
6
|
/**
|
|
7
7
|
* Compute a diff between two arrays, result is a 3 way split between common items, unique items in `a` array and unique items in `b` array
|
|
8
|
-
* @see prefer to use {@link
|
|
8
|
+
* @see prefer to use {@link array_set_diff_sorting}, as it's much faster, especially for large sets
|
|
9
9
|
* @template T
|
|
10
10
|
* @param {T[]} a
|
|
11
11
|
* @param {T[]} b
|
|
12
12
|
* @param {function(a:T,b:T):boolean} [equals] method to determine equality between two elements
|
|
13
13
|
* @returns {{uniqueA:T[], uniqueB:T[], common:T[]}}
|
|
14
14
|
*/
|
|
15
|
-
export function
|
|
15
|
+
export function array_set_diff(a, b, equals = strictEquals) {
|
|
16
16
|
assert.isArray(a, 'a');
|
|
17
17
|
assert.isArray(b, 'b');
|
|
18
18
|
assert.isFunction(equals, 'equals');
|
|
@@ -27,7 +27,7 @@ export function arraySetDiff(a, b, equals = strictEquals) {
|
|
|
27
27
|
for (let i = 0; i < a_length; i++) {
|
|
28
28
|
const elA = uniqueA[i];
|
|
29
29
|
|
|
30
|
-
const j =
|
|
30
|
+
const j = array_index_by_equality(uniqueB, elA, equals);
|
|
31
31
|
|
|
32
32
|
if (j !== -1) {
|
|
33
33
|
// common element found
|
|
@@ -6,9 +6,9 @@
|
|
|
6
6
|
* @param {function(a:T,b:T):number} [compare]
|
|
7
7
|
* @returns {{uniqueA:T[], uniqueB:T[], common:T[]}}
|
|
8
8
|
*/
|
|
9
|
-
export function
|
|
9
|
+
export function array_set_diff_sorting<T>(a: T[], b: T[], compare: any): {
|
|
10
10
|
uniqueA: T[];
|
|
11
11
|
uniqueB: T[];
|
|
12
12
|
common: T[];
|
|
13
13
|
};
|
|
14
|
-
//# sourceMappingURL=
|
|
14
|
+
//# sourceMappingURL=array_set_diff_sorting.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"array_set_diff_sorting.d.ts","sourceRoot":"","sources":["../../../../../src/core/collection/array/array_set_diff_sorting.js"],"names":[],"mappings":"AAIA;;;;;;;GAOG;AACH;;;;EAsDC"}
|
|
@@ -10,7 +10,7 @@ import { assert } from "../../assert.js";
|
|
|
10
10
|
* @param {function(a:T,b:T):number} [compare]
|
|
11
11
|
* @returns {{uniqueA:T[], uniqueB:T[], common:T[]}}
|
|
12
12
|
*/
|
|
13
|
-
export function
|
|
13
|
+
export function array_set_diff_sorting(a, b, compare) {
|
|
14
14
|
assert.isFunction(compare, 'compare');
|
|
15
15
|
|
|
16
16
|
const uniqueA = a.slice();
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"FilteredListProjection.d.ts","sourceRoot":"","sources":["../../../../../src/core/collection/list/FilteredListProjection.js"],"names":[],"mappings":"AAKA;IACI;;;;;OAKG;IACH,qCAHW,sBAAsB,EA6BhC;IAzBG;;;OAGG;IACH,eAAkB;IAElB;;;OAGG;IACH,gBAAwB;IAExB;;;OAGG;IACH,SAFU,sBAAsB,CAEV;IAEtB;;;OAGG;IACH,UAFU,OAAO,CAEG;IAEpB,wBAAoD;IAGxD,eAMC;IAED;;;OAGG;IACH,oBAEC;IAED;;;OAGG;IACH,sBAEC;IAED;;;OAGG;IACH,0BAGC;IAED;;;OAGG;IACH,4BAGC;IAED,aAUC;IAED,eAQC;IAED,cAiFC;CACJ;
|
|
1
|
+
{"version":3,"file":"FilteredListProjection.d.ts","sourceRoot":"","sources":["../../../../../src/core/collection/list/FilteredListProjection.js"],"names":[],"mappings":"AAKA;IACI;;;;;OAKG;IACH,qCAHW,sBAAsB,EA6BhC;IAzBG;;;OAGG;IACH,eAAkB;IAElB;;;OAGG;IACH,gBAAwB;IAExB;;;OAGG;IACH,SAFU,sBAAsB,CAEV;IAEtB;;;OAGG;IACH,UAFU,OAAO,CAEG;IAEpB,wBAAoD;IAGxD,eAMC;IAED;;;OAGG;IACH,oBAEC;IAED;;;OAGG;IACH,sBAEC;IAED;;;OAGG;IACH,0BAGC;IAED;;;OAGG;IACH,4BAGC;IAED,aAUC;IAED,eAQC;IAED,cAiFC;CACJ;iBAvLgB,WAAW"}
|
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
import { frameThrottle } from "../../../engine/graphics/FrameThrottle.js";
|
|
2
2
|
import { invokeObjectEquals } from "../../model/object/invokeObjectEquals.js";
|
|
3
|
+
import { array_set_diff } from "../array/array_set_diff.js";
|
|
3
4
|
import List from "./List.js";
|
|
4
|
-
import { arraySetDiff } from "../array/arraySetDiff.js";
|
|
5
5
|
|
|
6
6
|
export class FilteredListProjection {
|
|
7
7
|
/**
|
|
@@ -136,7 +136,7 @@ export class FilteredListProjection {
|
|
|
136
136
|
newOutput.push(v);
|
|
137
137
|
}
|
|
138
138
|
|
|
139
|
-
const diff =
|
|
139
|
+
const diff = array_set_diff(oldOutput, newOutput, invokeObjectEquals);
|
|
140
140
|
|
|
141
141
|
//resolve diff
|
|
142
142
|
const removals = diff.uniqueA;
|
|
@@ -7,8 +7,8 @@ import { assert } from "../../assert.js";
|
|
|
7
7
|
import Signal from "../../events/signal/Signal.js";
|
|
8
8
|
import { objectsEqual } from "../../function/objectsEqual.js";
|
|
9
9
|
import { invokeObjectEquals } from "../../model/object/invokeObjectEquals.js";
|
|
10
|
-
import {
|
|
11
|
-
import {
|
|
10
|
+
import { array_index_by_equality } from "../array/array_index_by_equality.js";
|
|
11
|
+
import { array_set_diff } from "../array/array_set_diff.js";
|
|
12
12
|
|
|
13
13
|
|
|
14
14
|
/**
|
|
@@ -214,7 +214,7 @@ class List {
|
|
|
214
214
|
|
|
215
215
|
const data = this.data;
|
|
216
216
|
|
|
217
|
-
const diff =
|
|
217
|
+
const diff = array_set_diff(data, new_data, objectsEqual);
|
|
218
218
|
|
|
219
219
|
//resolve diff
|
|
220
220
|
const removals = diff.uniqueA;
|
|
@@ -744,7 +744,7 @@ class List {
|
|
|
744
744
|
for (let i = 0; i < nThisItems; i++) {
|
|
745
745
|
const a = thisItems[i];
|
|
746
746
|
|
|
747
|
-
const index =
|
|
747
|
+
const index = array_index_by_equality(otherItems, a, invokeObjectEquals);
|
|
748
748
|
|
|
749
749
|
if (index !== -1) {
|
|
750
750
|
newData[index] = a;
|