uicore-ts 1.0.1 → 1.0.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/compiledScripts/UIKeyValueStringFilter.js +2 -2
- package/compiledScripts/UIKeyValueStringFilter.js.map +1 -1
- package/compiledScripts/UIKeyValueStringFilterWebWorker.d.ts +4 -0
- package/compiledScripts/UIKeyValueStringFilterWebWorker.js +76 -0
- package/compiledScripts/UIKeyValueStringFilterWebWorker.js.map +1 -0
- package/compiledScripts/UIKeyValueStringSorter.js +2 -2
- package/compiledScripts/UIKeyValueStringSorter.js.map +1 -1
- package/compiledScripts/UIKeyValueStringSorterWebWorker.d.ts +6 -0
- package/compiledScripts/UIKeyValueStringSorterWebWorker.js +81 -0
- package/compiledScripts/UIKeyValueStringSorterWebWorker.js.map +1 -0
- package/compiledScripts/UIStringFilter.js +2 -2
- package/compiledScripts/UIStringFilter.js.map +1 -1
- package/compiledScripts/UIStringFilterWebWorker.d.ts +4 -0
- package/compiledScripts/UIStringFilterWebWorker.js +67 -0
- package/compiledScripts/UIStringFilterWebWorker.js.map +1 -0
- package/package.json +1 -1
- package/scripts/UIKeyValueStringFilter.ts +2 -2
- package/scripts/UIKeyValueStringFilterWebWorker.ts +166 -0
- package/scripts/UIKeyValueStringSorter.ts +2 -2
- package/scripts/UIKeyValueStringSorterWebWorker.ts +218 -0
- package/scripts/UIStringFilter.ts +33 -33
- package/scripts/UIStringFilterWebWorker.ts +150 -0
|
@@ -10,7 +10,7 @@ class UIKeyValueStringFilter extends UIObject_1.UIObject {
|
|
|
10
10
|
this._class = UIKeyValueStringFilter;
|
|
11
11
|
this.superclass = UIObject_1.UIObject;
|
|
12
12
|
if (useSeparateWebWorkerHolder) {
|
|
13
|
-
this._webWorkerHolder = { webWorker: new Worker(
|
|
13
|
+
this._webWorkerHolder = { webWorker: new Worker(new URL('UIKeyValueStringFilterWebWorker.ts')) };
|
|
14
14
|
}
|
|
15
15
|
UIKeyValueStringFilter._instanceNumber = UIKeyValueStringFilter._instanceNumber + 1;
|
|
16
16
|
this._instanceNumber = UIKeyValueStringFilter._instanceNumber;
|
|
@@ -93,6 +93,6 @@ class UIKeyValueStringFilter extends UIObject_1.UIObject {
|
|
|
93
93
|
}
|
|
94
94
|
}
|
|
95
95
|
exports.UIKeyValueStringFilter = UIKeyValueStringFilter;
|
|
96
|
-
UIKeyValueStringFilter._sharedWebWorkerHolder = { webWorker: new Worker(
|
|
96
|
+
UIKeyValueStringFilter._sharedWebWorkerHolder = { webWorker: new Worker(new URL('UIKeyValueStringFilterWebWorker.ts')) };
|
|
97
97
|
UIKeyValueStringFilter._instanceNumber = -1;
|
|
98
98
|
//# sourceMappingURL=UIKeyValueStringFilter.js.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"UIKeyValueStringFilter.js","sourceRoot":"","sources":["../scripts/UIKeyValueStringFilter.ts"],"names":[],"mappings":";;;AAAA,yCAA0D;AAM1D,MAAa,sBAAuB,SAAQ,mBAAQ;IAchD,YAAY,0BAA0B,GAAG,aAAE;QAGvC,KAAK,EAAE,CAAA;QAPX,oBAAe,GAAG,aAAE,CAAA;QAEZ,qBAAgB,GAAG,sBAAsB,CAAC,sBAAsB,CAAA;QAOpE,IAAI,CAAC,MAAM,GAAG,sBAAsB,CAAA;QACpC,IAAI,CAAC,UAAU,GAAG,mBAAQ,CAAA;QAG1B,IAAI,0BAA0B,EAAE;YAE5B,IAAI,CAAC,gBAAgB,GAAG,EAAE,SAAS,EAAE,IAAI,MAAM,CAAC,
|
|
1
|
+
{"version":3,"file":"UIKeyValueStringFilter.js","sourceRoot":"","sources":["../scripts/UIKeyValueStringFilter.ts"],"names":[],"mappings":";;;AAAA,yCAA0D;AAM1D,MAAa,sBAAuB,SAAQ,mBAAQ;IAchD,YAAY,0BAA0B,GAAG,aAAE;QAGvC,KAAK,EAAE,CAAA;QAPX,oBAAe,GAAG,aAAE,CAAA;QAEZ,qBAAgB,GAAG,sBAAs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W,EACX,YAAsB,EACtB,WAAmB,EACnB,UAAe,EACf,UAAwF;QAIxF,IAAI,IAAI,CAAC,eAAe,EAAE;YAEtB,OAAM;SAET;QAID,MAAM,kBAAkB,GAAG,IAAI,CAAC,kBAAkB,CAAA;QAElD,MAAM,GAAG,GAAG,EAAE,GAAG,UAAU,GAAG,kBAAkB,CAAA;QAEhD,IAAI,CAAC,mBAAmB,CAAC,GAAG,CAAC,GAAG,UAAU,CAAA;QAG1C,IAAI;YAEA,IAAI,CAAC,cAAc,CAAC,IAAI,CAAC;gBAErB,iBAAiB,EAAE,eAAe;gBAClC,MAAM,EAAE,IAAI;gBACZ,cAAc,EAAE,YAAY;gBAC5B,aAAa,EAAE,WAAW;gBAC1B,YAAY,EAAE,UAAU;gBACxB,oBAAoB,EAAE,kBAAkB;aAE3C,CAAC,CAAA;YAEF,IAAI,CAAC,uBAAuB,EAAE,CAAA;SAEjC;QAAC,OAAO,SAAS,EAAE;YAEhB,UAAU,CAAC,EAAE,EAAE,EAAE,EAAE,UAAU,CAAC,CAAA;SAEjC;IAML,CAAC;IAMD,WAAW;QAEP,IAAI,CAAC,eAAe,GAAG,cAAG,CAAA;QAE1B,IAAI,IAAI,CAAC,gBAAgB,IAAI,sBAAsB,CAAC,sBAAsB,EAAE;YAExE,IAAI,CAAC,gBAAgB,CAAC,SAAS,CAAC,SAAS,EAAE,CAAA;SAE9C;IAIL,CAAC;;AAlNL,wDAwNC;AArNU,6CAAsB,GAAG,EAAE,SAAS,EAAE,IAAI,MAAM,CAAC,IAAI,GAAG,CAAC,oCAAoC,CAAC,CAAC,EAAE,CAAA;AAEjG,sCAAe,GAAG,CAAC,CAAC,CAAA"}
|
|
@@ -0,0 +1,76 @@
|
|
|
1
|
+
// @ts-check
|
|
2
|
+
if ("contains" in Array.prototype == false) {
|
|
3
|
+
// @ts-ignore
|
|
4
|
+
Array.prototype.contains = function (element) {
|
|
5
|
+
var result = (this.indexOf(element) != -1);
|
|
6
|
+
return result;
|
|
7
|
+
};
|
|
8
|
+
}
|
|
9
|
+
if ("contains" in String.prototype == false) {
|
|
10
|
+
// @ts-ignore
|
|
11
|
+
String.prototype.contains = function (string) {
|
|
12
|
+
var result = (this.indexOf(string) != -1);
|
|
13
|
+
return result;
|
|
14
|
+
};
|
|
15
|
+
}
|
|
16
|
+
onmessage = function (event) {
|
|
17
|
+
//console.log('Message received from main script');
|
|
18
|
+
var workerResult = filterKeyValuePathData(event.data.filteringString, event.data.data, event.data.excludedData, event.data.dataKeyPath);
|
|
19
|
+
// @ts-ignore
|
|
20
|
+
workerResult.identifier = event.data.identifier;
|
|
21
|
+
// @ts-ignore
|
|
22
|
+
workerResult.instanceIdentifier = event.data.instanceIdentifier;
|
|
23
|
+
// @ts-ignore
|
|
24
|
+
postMessage(workerResult);
|
|
25
|
+
};
|
|
26
|
+
function filterKeyValuePathData(filteringString, data, excludedData, dataKeyPath) {
|
|
27
|
+
function valueForKeyPath(keyPath, object) {
|
|
28
|
+
var keys = keyPath.split(".");
|
|
29
|
+
var currentObject = object;
|
|
30
|
+
keys.forEach(function (key, index, array) {
|
|
31
|
+
currentObject = currentObject[key];
|
|
32
|
+
});
|
|
33
|
+
return currentObject;
|
|
34
|
+
}
|
|
35
|
+
var filteredData = [];
|
|
36
|
+
var filteredIndexes = [];
|
|
37
|
+
if (filteringString) {
|
|
38
|
+
var filteringStringWords = [];
|
|
39
|
+
filteringString.split(" ").forEach(function (word, index, array) {
|
|
40
|
+
if (word) {
|
|
41
|
+
filteringStringWords.push(word.toLowerCase());
|
|
42
|
+
}
|
|
43
|
+
});
|
|
44
|
+
data.forEach(function (dataObject, index, array) {
|
|
45
|
+
var dataString = valueForKeyPath(dataKeyPath, dataObject);
|
|
46
|
+
var lowercaseDataString = dataString.toLowerCase();
|
|
47
|
+
// Look through all the words in the input
|
|
48
|
+
var wordsFound = [];
|
|
49
|
+
filteringStringWords.forEach(function (word) {
|
|
50
|
+
wordsFound.push(lowercaseDataString.contains(word) && !excludedData.contains(dataString));
|
|
51
|
+
});
|
|
52
|
+
// Only show the dataString if it matches all of them
|
|
53
|
+
// @ts-ignore
|
|
54
|
+
if (wordsFound.contains(true) && !wordsFound.contains(false)) {
|
|
55
|
+
filteredData.push(dataObject);
|
|
56
|
+
filteredIndexes.push(index);
|
|
57
|
+
}
|
|
58
|
+
});
|
|
59
|
+
}
|
|
60
|
+
else if (excludedData.length) {
|
|
61
|
+
filteredData = data.forEach(function (dataObject, index, array) {
|
|
62
|
+
if (excludedData.indexOf(dataObject) == -1) {
|
|
63
|
+
filteredData.push(dataObject);
|
|
64
|
+
filteredIndexes.push(index);
|
|
65
|
+
}
|
|
66
|
+
});
|
|
67
|
+
}
|
|
68
|
+
else {
|
|
69
|
+
filteredData = data;
|
|
70
|
+
data.forEach(function (object, index, array) {
|
|
71
|
+
filteredIndexes.push(index);
|
|
72
|
+
});
|
|
73
|
+
}
|
|
74
|
+
return { "filteredData": filteredData, "filteredIndexes": filteredIndexes };
|
|
75
|
+
}
|
|
76
|
+
//# sourceMappingURL=UIKeyValueStringFilterWebWorker.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"UIKeyValueStringFilterWebWorker.js","sourceRoot":"","sources":["../scripts/UIKeyValueStringFilterWebWorker.ts"],"names":[],"mappings":"AACA,YAAY;AAEZ,IAAI,UAAU,IAAI,KAAK,CAAC,SAAS,IAAI,KAAK,EAAE;IAExC,aAAa;IACb,KAAK,CAAC,SAAS,CAAC,QAAQ,GAAG,UAAU,OAAO;QAExC,IAAI,MAAM,GAAG,CAAC,IAAI,CAAC,OAAO,CAAC,OAAO,CAAC,IAAI,CAAC,CAAC,CAAC,CAAC;QAC3C,OAAO,MAAM,CAAC;IAElB,CAAC,CAAA;CAEJ;AAED,IAAI,UAAU,IAAI,MAAM,CAAC,SAAS,IAAI,KAAK,EAAE;IAEzC,aAAa;IACb,MAAM,CAAC,SAAS,CAAC,QAAQ,GAAG,UAAU,MAAM;QAExC,IAAI,MAAM,GAAG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AAE,KAAK;YAEvC,eAAe,CAAC,IAAI,CAAC,KAAK,CAAC,CAAC;QAEhC,CAAC,CAAC,CAAA;KAEL;IAID,OAAO,EAAE,cAAc,EAAE,YAAY,EAAE,iBAAiB,EAAE,eAAe,EAAE,CAAC;AAIhF,CAAC"}
|
|
@@ -10,7 +10,7 @@ class UIKeyValueStringSorter extends UIObject_1.UIObject {
|
|
|
10
10
|
this._class = UIKeyValueStringSorter;
|
|
11
11
|
this.superclass = UIObject_1.UIObject;
|
|
12
12
|
if (useSeparateWebWorkerHolder) {
|
|
13
|
-
this._webWorkerHolder = { webWorker: new Worker(
|
|
13
|
+
this._webWorkerHolder = { webWorker: new Worker(new URL('UIKeyValueStringSorterWebWorker.ts')) };
|
|
14
14
|
}
|
|
15
15
|
UIKeyValueStringSorter._instanceNumber = UIKeyValueStringSorter._instanceNumber + 1;
|
|
16
16
|
this._instanceNumber = UIKeyValueStringSorter._instanceNumber;
|
|
@@ -105,7 +105,7 @@ class UIKeyValueStringSorter extends UIObject_1.UIObject {
|
|
|
105
105
|
}
|
|
106
106
|
}
|
|
107
107
|
exports.UIKeyValueStringSorter = UIKeyValueStringSorter;
|
|
108
|
-
UIKeyValueStringSorter._sharedWebWorkerHolder = { webWorker: new Worker(
|
|
108
|
+
UIKeyValueStringSorter._sharedWebWorkerHolder = { webWorker: new Worker(new URL('UIKeyValueStringSorterWebWorker.ts')) };
|
|
109
109
|
UIKeyValueStringSorter._instanceNumber = -1;
|
|
110
110
|
UIKeyValueStringSorter.dataType = {
|
|
111
111
|
"string": "string"
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"UIKeyValueStringSorter.js","sourceRoot":"","sources":["../scripts/UIKeyValueStringSorter.ts"],"names":[],"mappings":";;;AAAA,yCAAmE;AAkBnE,MAAa,sBAAuB,SAAQ,mBAAQ;IAehD,YAAY,0BAA0B,GAAG,aAAE;QAGvC,KAAK,EAAE,CAAA;QARX,oBAAe,GAAG,aAAE,CAAA;QAEZ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AAE,MAAM,EAAE,EAAE;YAEjC,IAAI,CAAC,QAAQ,CAAC,IAAI,EAAE,mBAAmB,EAAE,UAAU,EAAE,CAAC,UAAU,EAAE,aAAa,EAAE,gBAAgB,EAAE,EAAE;gBAEjG,IAAI,gBAAgB,IAAI,UAAU,EAAE;oBAEhC,OAAO,CAAC;wBAEJ,UAAU,EAAE,UAAU;wBACtB,aAAa,EAAE,aAAa;wBAC5B,UAAU,EAAE,gBAAgB;qBAE/B,CAAC,CAAA;iBAEL;YAIL,CAAC,CAAC,CAAA;QAIN,CAAC,CAAC,CAAA;QAEF,OAAO,MAAM,CAAA;IAEjB,CAAC;IAMD,WAAW;QAEP,IAAI,CAAC,eAAe,GAAG,cAAG,CAAA;QAE1B,IAAI,IAAI,CAAC,gBAAgB,IAAI,sBAAsB,CAAC,sBAAsB,EAAE;YAExE,IAAI,CAAC,gBAAgB,CAAC,SAAS,CAAC,SAAS,EAAE,CAAC;SAE/C;IAIL,CAAC;;AAnRL,wDAyRC;AAtRU,6CAAsB,GAAG,EAAE,SAAS,EAAE,IAAI,MAAM,CAAC,IAAI,GAAG,CAAC,oCAAoC,CAAC,CAAC,EAAE,CAAA;AAEjG,sCAAe,GAAG,CAAC,CAAC,CAAA;AAiJpB,+BAAQ,GAAG;IAEd,QAAQ,EAAE,QAAQ;CAErB,CAAA;AAGM,gCAAS,GAAG;IAEf,YAAY,EAAE,YAAY;IAC1B,WAAW,EAAE,WAAW;CAE3B,CAAA"}
|
|
@@ -0,0 +1,6 @@
|
|
|
1
|
+
declare function valueForKeyPath(keyPath: any, object: any): any;
|
|
2
|
+
declare function compare(firstObject: any, secondObject: any, sortingInstructions: any): any;
|
|
3
|
+
declare function sortData(data: any, sortingInstructions: any): {
|
|
4
|
+
sortedData: any;
|
|
5
|
+
sortedIndexes: any;
|
|
6
|
+
};
|
|
@@ -0,0 +1,81 @@
|
|
|
1
|
+
// @ts-check
|
|
2
|
+
onmessage = function (event) {
|
|
3
|
+
//console.log('Message received from main script');
|
|
4
|
+
var workerResult = sortData(event.data.data, event.data.sortingInstructions);
|
|
5
|
+
// @ts-ignore
|
|
6
|
+
workerResult.identifier = event.data.identifier;
|
|
7
|
+
// @ts-ignore
|
|
8
|
+
workerResult.instanceIdentifier = event.data.instanceIdentifier;
|
|
9
|
+
// @ts-ignore
|
|
10
|
+
postMessage(workerResult);
|
|
11
|
+
};
|
|
12
|
+
function valueForKeyPath(keyPath, object) {
|
|
13
|
+
var keys = keyPath.split(".");
|
|
14
|
+
var currentObject = object;
|
|
15
|
+
for (var i = 0; i < keys.length; i++) {
|
|
16
|
+
var key = keys[i];
|
|
17
|
+
if (key.substring(0, 2) == "[]") {
|
|
18
|
+
// This next object will be an array and the rest of the keys need to be run for each of the elements
|
|
19
|
+
currentObject = currentObject[key.substring(2)];
|
|
20
|
+
// CurrentObject is now an array
|
|
21
|
+
var remainingKeyPath = keys.slice(i + 1).join(".");
|
|
22
|
+
var currentArray = currentObject;
|
|
23
|
+
currentObject = currentArray.map(function (subObject, index, array) {
|
|
24
|
+
var result = valueForKeyPath(remainingKeyPath, subObject);
|
|
25
|
+
return result;
|
|
26
|
+
});
|
|
27
|
+
break;
|
|
28
|
+
}
|
|
29
|
+
currentObject = (currentObject || {})[key];
|
|
30
|
+
}
|
|
31
|
+
return currentObject;
|
|
32
|
+
}
|
|
33
|
+
function compare(firstObject, secondObject, sortingInstructions) {
|
|
34
|
+
if (sortingInstructions.length == 0) {
|
|
35
|
+
return 0;
|
|
36
|
+
}
|
|
37
|
+
var sortingInstruction = sortingInstructions[0];
|
|
38
|
+
var directionMultiplier = 1;
|
|
39
|
+
if (sortingInstruction.direction == "descending") {
|
|
40
|
+
directionMultiplier = -1;
|
|
41
|
+
}
|
|
42
|
+
var firstDataString = firstObject[sortingInstruction.keyPath];
|
|
43
|
+
var secondDataString = secondObject[sortingInstruction.keyPath];
|
|
44
|
+
if (firstDataString < secondDataString) {
|
|
45
|
+
return -1 * directionMultiplier;
|
|
46
|
+
}
|
|
47
|
+
if (firstDataString > secondDataString) {
|
|
48
|
+
return 1 * directionMultiplier;
|
|
49
|
+
}
|
|
50
|
+
if (sortingInstructions.length > 1) {
|
|
51
|
+
var remainingSortingInstructions = sortingInstructions.slice(1);
|
|
52
|
+
return compare(firstObject, secondObject, remainingSortingInstructions);
|
|
53
|
+
}
|
|
54
|
+
return 0;
|
|
55
|
+
}
|
|
56
|
+
function sortData(data, sortingInstructions) {
|
|
57
|
+
var sortingObjects = data.map(function (dataItem, index, array) {
|
|
58
|
+
var result = {
|
|
59
|
+
"_UIKeyValueStringSorterWebWorkerSortingObjectIndex": index
|
|
60
|
+
};
|
|
61
|
+
sortingInstructions.forEach(function (instruction, index, instructionsArray) {
|
|
62
|
+
result[instruction.keyPath] = JSON.stringify(valueForKeyPath(instruction.keyPath, dataItem) || {}).toLowerCase();
|
|
63
|
+
});
|
|
64
|
+
return result;
|
|
65
|
+
});
|
|
66
|
+
var sortedData = sortingObjects.sort(function (firstObject, secondObject) {
|
|
67
|
+
return compare(firstObject, secondObject, sortingInstructions);
|
|
68
|
+
});
|
|
69
|
+
var sortedIndexes = sortedData.map(function (object, index, array) {
|
|
70
|
+
var sortedIndex = object._UIKeyValueStringSorterWebWorkerSortingObjectIndex;
|
|
71
|
+
return sortedIndex;
|
|
72
|
+
});
|
|
73
|
+
var result = {
|
|
74
|
+
"sortedData": sortedIndexes.map(function (sortedIndex, index, array) {
|
|
75
|
+
return data[sortedIndex];
|
|
76
|
+
}),
|
|
77
|
+
"sortedIndexes": sortedIndexes
|
|
78
|
+
};
|
|
79
|
+
return result;
|
|
80
|
+
}
|
|
81
|
+
//# sourceMappingURL=UIKeyValueStringSorterWebWorker.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"UIKeyValueStringSorterWebWorker.js","sourceRoot":"","sources":["../scripts/UIKeyValueStringSorterWebWorker.ts"],"names":[],"mappings":"AACA,YAAY;AAUZ,SAAS,GAAG,UAAU,KAAK;IAEvB,mDA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B;YAEtE,MAAM,CAAC,WAAW,CAAC,OAAO,CAAC,GAAG,IAAI,CAAC,SAAS,CAAC,eAAe,CAAC,WAAW,CAAC,OAAO,EAAE,QAAQ,CAAC,IAAI,EAAE,CAAC,CAAC,WAAW,EAAE,CAAC;QAErH,CAAC,CAAC,CAAA;QAKF,OAAO,MAAM,CAAC;IAGlB,CAAC,CAAC,CAAA;IAGF,IAAI,UAAU,GAAG,cAAc,CAAC,IAAI,CAAC,UAAU,WAAW,EAAE,YAAY;QAEpE,OAAO,OAAO,CAAC,WAAW,EAAE,YAAY,EAAE,mBAAmB,CAAC,CAAC;IAEnE,CAAC,CAAC,CAAA;IAEF,IAAI,aAAa,GAAG,UAAU,CAAC,GAAG,CAAC,UAAU,MAAM,EAAE,KAAK,EAAE,KAAK;QAE7D,IAAI,WAAW,GAAG,MAAM,CAAC,kDAAkD,CAAC;QAE5E,OAAO,WAAW,CAAC;IAEvB,CAAC,CAAC,CAAA;IAEF,IAAI,MAAM,GAAG;QAET,YAAY,EAAE,aAAa,CAAC,GAAG,CAAC,UAAU,WAAW,EAAE,KAAK,EAAE,KAAK;YAE/D,OAAO,IAAI,CAAC,WAAW,CAAC,CAAC;QAE7B,CAAC,CAAC;QACF,eAAe,EAAE,aAAa;KAEjC,CAAA;IAGD,OAAO,MAAM,CAAC;AAGlB,CAAC"}
|
|
@@ -10,7 +10,7 @@ class UIStringFilter extends UIObject_1.UIObject {
|
|
|
10
10
|
this._class = UIStringFilter;
|
|
11
11
|
this.superclass = UIObject_1.UIObject;
|
|
12
12
|
if (useSeparateWebWorkerHolder) {
|
|
13
|
-
this._webWorkerHolder = { webWorker: new Worker("
|
|
13
|
+
this._webWorkerHolder = { webWorker: new Worker(new URL("UIStringFilterWebWorker.ts")) };
|
|
14
14
|
}
|
|
15
15
|
UIStringFilter._instanceNumber = UIStringFilter._instanceNumber + 1;
|
|
16
16
|
this._instanceNumber = UIStringFilter._instanceNumber;
|
|
@@ -102,6 +102,6 @@ class UIStringFilter extends UIObject_1.UIObject {
|
|
|
102
102
|
}
|
|
103
103
|
}
|
|
104
104
|
exports.UIStringFilter = UIStringFilter;
|
|
105
|
-
UIStringFilter._sharedWebWorkerHolder = { webWorker: new Worker("
|
|
105
|
+
UIStringFilter._sharedWebWorkerHolder = { webWorker: new Worker(new URL("UIStringFilterWebWorker.ts"), { type: 'module' }) };
|
|
106
106
|
UIStringFilter._instanceNumber = -1;
|
|
107
107
|
//# sourceMappingURL=UIStringFilter.js.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"UIStringFilter.js","sourceRoot":"","sources":["../scripts/UIStringFilter.ts"],"names":[],"mappings":";;;AAAA,yCAAmE;AAGnE,MAAa,cAAe,SAAQ,mBAAQ;IAkBxC,YAAY,0BAA0B,GAAG,aAAE;QAGvC,KAAK,EAAE,CAAA;QATX,oBAAe,GAAG,aAAE,CAAA;QAEH,qBAAgB,GAAG,cAAc,CAAC,sBAAsB,CAAA;QASrE,IAAI,CAAC,MAAM,GAAG,cAAc,CAAA;QAC5B,IAAI,CAAC,UAAU,GAAG,mBAAQ,CAAA;QAG1B,IAAI,0BAA0B,EAAE;YAE5B,IAAI,CAAC,gBAAgB,GAAG,EAAE,SAAS,EAAE,IAAI,MAAM,CAAC,
|
|
1
|
+
{"version":3,"file":"UIStringFilter.js","sourceRoot":"","sources":["../scripts/UIStringFilter.ts"],"names":[],"mappings":";;;AAAA,yCAAmE;AAGnE,MAAa,cAAe,SAAQ,mBAAQ;IAkBxC,YAAY,0BAA0B,GAAG,aAAE;QAGvC,KAAK,EAAE,CAAA;QATX,oBAAe,GAAG,aAAE,CAAA;QAEH,qBAAgB,GAAG,cAAc,CAAC,sBAAsB,CAAA;QASrE,IAAI,CAAC,MAAM,GAAG,cAAc,CAAA;QAC5B,IAAI,CAAC,UAAU,GAAG,mBAAQ,CAAA;QAG1B,IAAI,0BAA0B,EAAE;YAE5B,IAAI,CAAC,gBAAgB,GAAG,EAAE,SAAS,EAAE,IAAI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E,CAAA;AAE3G,8BAAe,GAAG,CAAC,CAAC,CAAA"}
|
|
@@ -0,0 +1,67 @@
|
|
|
1
|
+
// @ts-check
|
|
2
|
+
if ("contains" in Array.prototype == false) {
|
|
3
|
+
// @ts-ignore
|
|
4
|
+
Array.prototype.contains = function (element) {
|
|
5
|
+
var result = (this.indexOf(element) != -1);
|
|
6
|
+
return result;
|
|
7
|
+
};
|
|
8
|
+
}
|
|
9
|
+
if ("contains" in String.prototype == false) {
|
|
10
|
+
// @ts-ignore
|
|
11
|
+
String.prototype.contains = function (string) {
|
|
12
|
+
var result = (this.indexOf(string) != -1);
|
|
13
|
+
return result;
|
|
14
|
+
};
|
|
15
|
+
}
|
|
16
|
+
onmessage = function (event) {
|
|
17
|
+
//console.log('Message received from main script');
|
|
18
|
+
var workerResult = filterData(event.data.filteringString, event.data.data, event.data.excludedData);
|
|
19
|
+
// @ts-ignore
|
|
20
|
+
workerResult.identifier = event.data.identifier;
|
|
21
|
+
// @ts-ignore
|
|
22
|
+
workerResult.instanceIdentifier = event.data.instanceIdentifier;
|
|
23
|
+
// @ts-ignore
|
|
24
|
+
postMessage(workerResult);
|
|
25
|
+
};
|
|
26
|
+
function filterData(filteringString, data, excludedData) {
|
|
27
|
+
var filteredData = [];
|
|
28
|
+
var filteredIndexes = [];
|
|
29
|
+
if (filteringString) {
|
|
30
|
+
var filteringStringWords = [];
|
|
31
|
+
filteringString.split(" ").forEach(function (word, index, array) {
|
|
32
|
+
if (word) {
|
|
33
|
+
filteringStringWords.push(word.toLowerCase());
|
|
34
|
+
}
|
|
35
|
+
});
|
|
36
|
+
data.forEach(function (dataString, index, array) {
|
|
37
|
+
var lowercaseDataString = dataString.toLowerCase();
|
|
38
|
+
// Look through all the words in the input
|
|
39
|
+
var wordsFound = [];
|
|
40
|
+
filteringStringWords.forEach(function (word) {
|
|
41
|
+
wordsFound.push(lowercaseDataString.contains(word) && !excludedData.contains(dataString));
|
|
42
|
+
});
|
|
43
|
+
// Only show the dataString if it matches all of them
|
|
44
|
+
// @ts-ignore
|
|
45
|
+
if (wordsFound.contains(true) && !wordsFound.contains(false)) {
|
|
46
|
+
filteredData.push(dataString);
|
|
47
|
+
filteredIndexes.push(index);
|
|
48
|
+
}
|
|
49
|
+
});
|
|
50
|
+
}
|
|
51
|
+
else if (excludedData.length) {
|
|
52
|
+
filteredData = data.forEach(function (dataString, index, array) {
|
|
53
|
+
if (excludedData.indexOf(dataString) == -1) {
|
|
54
|
+
filteredData.push(dataString);
|
|
55
|
+
filteredIndexes.push(index);
|
|
56
|
+
}
|
|
57
|
+
});
|
|
58
|
+
}
|
|
59
|
+
else {
|
|
60
|
+
filteredData = data;
|
|
61
|
+
data.forEach(function (string, index, array) {
|
|
62
|
+
filteredIndexes.push(index);
|
|
63
|
+
});
|
|
64
|
+
}
|
|
65
|
+
return { "filteredData": filteredData, "filteredIndexes": filteredIndexes };
|
|
66
|
+
}
|
|
67
|
+
//# sourceMappingURL=UIStringFilterWebWorker.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"UIStringFilterWebWorker.js","sourceRoot":"","sources":["../scripts/UIStringFilterWebWorker.ts"],"names":[],"mappings":"AACA,YAAY;AAEZ,IAAI,UAAU,IAAI,KAAK,CAAC,SAAS,IAAI,KAAK,EAAE;IAExC,aAAa;IACb,KAAK,CAAC,SAAS,CAAC,QAAQ,GAAG,UAAU,OAAO;QAExC,IAAI,MAAM,GAAG,CAAC,IAAI,CAAC,OAAO,CAAC,OAAO,CAAC,IAAI,CAAC,CAAC,CAAC,CAAC;QAC3C,OAAO,MAAM,CAAC;IAElB,CAAC,CAAA;CAEJ;AAED,IAAI,UAAU,IAAI,MAAM,CAAC,SAAS,IAAI,KAAK,EAAE;IAEzC,aAAa;IACb,MAAM,CAAC,SAAS,CAAC,QAAQ,GAAG,UAAU,MAAM;QAExC,IAAI,MAAM,GAAG,CAAC,IAAI,CAAC,OAAO,CAAC,MAAM,CAAC,IAAI,CAAC,CAAC,CAA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AAC,CAAC,CAAC;YAC9F,CAAC,CAAC,CAAA;YAEF,qDAAqD;YACrD,aAAa;YACb,IAAI,UAAU,CAAC,QAAQ,CAAC,IAAI,CAAC,IAAI,CAAC,UAAU,CAAC,QAAQ,CAAC,KAAK,CAAC,EAAE;gBAE1D,YAAY,CAAC,IAAI,CAAC,UAAU,CAAC,CAAC;gBAC9B,eAAe,CAAC,IAAI,CAAC,KAAK,CAAC,CAAC;aAE/B;QAEL,CAAC,CAAC,CAAA;KAIL;SACI,IAAI,YAAY,CAAC,MAAM,EAAE;QAG1B,YAAY,GAAG,IAAI,CAAC,OAAO,CAAC,UAAU,UAAU,EAAE,KAAK,EAAE,KAAK;YAE1D,IAAI,YAAY,CAAC,OAAO,CAAC,UAAU,CAAC,IAAI,CAAC,CAAC,EAAE;gBAExC,YAAY,CAAC,IAAI,CAAC,UAAU,CAAC,CAAC;gBAC9B,eAAe,CAAC,IAAI,CAAC,KAAK,CAAC,CAAC;aAE/B;QAEL,CAAC,CAAC,CAAA;KAEL;SACI;QAED,YAAY,GAAG,IAAI,CAAC;QAEpB,IAAI,CAAC,OAAO,CAAC,UAAU,MAAM,EAAE,KAAK,EAAE,KAAK;YAEvC,eAAe,CAAC,IAAI,CAAC,KAAK,CAAC,CAAC;QAEhC,CAAC,CAAC,CAAA;KAEL;IAID,OAAO,EAAE,cAAc,EAAE,YAAY,EAAE,iBAAiB,EAAE,eAAe,EAAE,CAAC;AAIhF,CAAC"}
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "uicore-ts",
|
|
3
|
-
"version": "1.0.
|
|
3
|
+
"version": "1.0.2",
|
|
4
4
|
"description": "UICore is a library to build native-like user interfaces using pure Typescript. No HTML is needed at all. Components are described as TS classes and all user interactions are handled explicitly. This library is strongly inspired by the UIKit framework that is used in IOS. In addition, UICore has tools to handle URL based routing, array sorting and filtering and adds a number of other utilities for convenience.",
|
|
5
5
|
"main": "compiledScripts/index.js",
|
|
6
6
|
"types": "compiledScripts/index.d.ts",
|
|
@@ -7,7 +7,7 @@ import { IS, IS_NOT, NO, UIObject, YES } from "./UIObject"
|
|
|
7
7
|
export class UIKeyValueStringFilter extends UIObject {
|
|
8
8
|
|
|
9
9
|
|
|
10
|
-
static _sharedWebWorkerHolder = { webWorker: new Worker(
|
|
10
|
+
static _sharedWebWorkerHolder = { webWorker: new Worker(new URL('UIKeyValueStringFilterWebWorker.ts')) }
|
|
11
11
|
|
|
12
12
|
static _instanceNumber = -1
|
|
13
13
|
|
|
@@ -29,7 +29,7 @@ export class UIKeyValueStringFilter extends UIObject {
|
|
|
29
29
|
|
|
30
30
|
if (useSeparateWebWorkerHolder) {
|
|
31
31
|
|
|
32
|
-
this._webWorkerHolder = { webWorker: new Worker(
|
|
32
|
+
this._webWorkerHolder = { webWorker: new Worker(new URL('UIKeyValueStringFilterWebWorker.ts')) }
|
|
33
33
|
|
|
34
34
|
}
|
|
35
35
|
|
|
@@ -0,0 +1,166 @@
|
|
|
1
|
+
|
|
2
|
+
// @ts-check
|
|
3
|
+
|
|
4
|
+
if ("contains" in Array.prototype == false) {
|
|
5
|
+
|
|
6
|
+
// @ts-ignore
|
|
7
|
+
Array.prototype.contains = function (element) {
|
|
8
|
+
|
|
9
|
+
var result = (this.indexOf(element) != -1);
|
|
10
|
+
return result;
|
|
11
|
+
|
|
12
|
+
}
|
|
13
|
+
|
|
14
|
+
}
|
|
15
|
+
|
|
16
|
+
if ("contains" in String.prototype == false) {
|
|
17
|
+
|
|
18
|
+
// @ts-ignore
|
|
19
|
+
String.prototype.contains = function (string) {
|
|
20
|
+
|
|
21
|
+
var result = (this.indexOf(string) != -1);
|
|
22
|
+
return result;
|
|
23
|
+
|
|
24
|
+
}
|
|
25
|
+
|
|
26
|
+
}
|
|
27
|
+
|
|
28
|
+
|
|
29
|
+
|
|
30
|
+
|
|
31
|
+
|
|
32
|
+
onmessage = function (event) {
|
|
33
|
+
|
|
34
|
+
//console.log('Message received from main script');
|
|
35
|
+
var workerResult = filterKeyValuePathData(event.data.filteringString, event.data.data, event.data.excludedData, event.data.dataKeyPath);
|
|
36
|
+
|
|
37
|
+
// @ts-ignore
|
|
38
|
+
workerResult.identifier = event.data.identifier;
|
|
39
|
+
// @ts-ignore
|
|
40
|
+
workerResult.instanceIdentifier = event.data.instanceIdentifier;
|
|
41
|
+
|
|
42
|
+
|
|
43
|
+
// @ts-ignore
|
|
44
|
+
postMessage(workerResult);
|
|
45
|
+
|
|
46
|
+
}
|
|
47
|
+
|
|
48
|
+
|
|
49
|
+
|
|
50
|
+
|
|
51
|
+
|
|
52
|
+
|
|
53
|
+
|
|
54
|
+
|
|
55
|
+
|
|
56
|
+
function filterKeyValuePathData(filteringString, data, excludedData, dataKeyPath) {
|
|
57
|
+
|
|
58
|
+
function valueForKeyPath(keyPath, object) {
|
|
59
|
+
|
|
60
|
+
var keys = keyPath.split(".");
|
|
61
|
+
var currentObject = object;
|
|
62
|
+
|
|
63
|
+
keys.forEach(function (key, index, array) {
|
|
64
|
+
currentObject = currentObject[key];
|
|
65
|
+
})
|
|
66
|
+
|
|
67
|
+
return currentObject;
|
|
68
|
+
|
|
69
|
+
}
|
|
70
|
+
|
|
71
|
+
var filteredData = [];
|
|
72
|
+
var filteredIndexes = [];
|
|
73
|
+
|
|
74
|
+
if (filteringString) {
|
|
75
|
+
|
|
76
|
+
var filteringStringWords = [];
|
|
77
|
+
filteringString.split(" ").forEach(function (word, index, array) {
|
|
78
|
+
if (word) {
|
|
79
|
+
filteringStringWords.push(word.toLowerCase());
|
|
80
|
+
}
|
|
81
|
+
})
|
|
82
|
+
|
|
83
|
+
data.forEach(function (dataObject, index, array) {
|
|
84
|
+
|
|
85
|
+
var dataString = valueForKeyPath(dataKeyPath, dataObject);
|
|
86
|
+
|
|
87
|
+
var lowercaseDataString = dataString.toLowerCase();
|
|
88
|
+
|
|
89
|
+
// Look through all the words in the input
|
|
90
|
+
var wordsFound = [];
|
|
91
|
+
filteringStringWords.forEach(function (word) {
|
|
92
|
+
wordsFound.push(lowercaseDataString.contains(word) && !excludedData.contains(dataString));
|
|
93
|
+
})
|
|
94
|
+
|
|
95
|
+
// Only show the dataString if it matches all of them
|
|
96
|
+
// @ts-ignore
|
|
97
|
+
if (wordsFound.contains(true) && !wordsFound.contains(false)) {
|
|
98
|
+
|
|
99
|
+
filteredData.push(dataObject);
|
|
100
|
+
filteredIndexes.push(index);
|
|
101
|
+
|
|
102
|
+
}
|
|
103
|
+
|
|
104
|
+
})
|
|
105
|
+
|
|
106
|
+
|
|
107
|
+
|
|
108
|
+
}
|
|
109
|
+
else if (excludedData.length) {
|
|
110
|
+
|
|
111
|
+
|
|
112
|
+
filteredData = data.forEach(function (dataObject, index, array) {
|
|
113
|
+
|
|
114
|
+
if (excludedData.indexOf(dataObject) == -1) {
|
|
115
|
+
|
|
116
|
+
filteredData.push(dataObject);
|
|
117
|
+
filteredIndexes.push(index);
|
|
118
|
+
|
|
119
|
+
}
|
|
120
|
+
|
|
121
|
+
})
|
|
122
|
+
|
|
123
|
+
}
|
|
124
|
+
else {
|
|
125
|
+
|
|
126
|
+
filteredData = data;
|
|
127
|
+
|
|
128
|
+
data.forEach(function (object, index, array) {
|
|
129
|
+
|
|
130
|
+
filteredIndexes.push(index);
|
|
131
|
+
|
|
132
|
+
})
|
|
133
|
+
|
|
134
|
+
}
|
|
135
|
+
|
|
136
|
+
|
|
137
|
+
|
|
138
|
+
return { "filteredData": filteredData, "filteredIndexes": filteredIndexes };
|
|
139
|
+
|
|
140
|
+
|
|
141
|
+
|
|
142
|
+
}
|
|
143
|
+
|
|
144
|
+
|
|
145
|
+
|
|
146
|
+
|
|
147
|
+
|
|
148
|
+
|
|
149
|
+
|
|
150
|
+
|
|
151
|
+
|
|
152
|
+
|
|
153
|
+
|
|
154
|
+
|
|
155
|
+
|
|
156
|
+
|
|
157
|
+
|
|
158
|
+
|
|
159
|
+
|
|
160
|
+
|
|
161
|
+
|
|
162
|
+
|
|
163
|
+
|
|
164
|
+
|
|
165
|
+
|
|
166
|
+
|
|
@@ -19,7 +19,7 @@ export interface UIKeyValueStringSorterSortingInstruction {
|
|
|
19
19
|
export class UIKeyValueStringSorter extends UIObject {
|
|
20
20
|
|
|
21
21
|
|
|
22
|
-
static _sharedWebWorkerHolder = { webWorker: new Worker(
|
|
22
|
+
static _sharedWebWorkerHolder = { webWorker: new Worker(new URL('UIKeyValueStringSorterWebWorker.ts')) }
|
|
23
23
|
|
|
24
24
|
static _instanceNumber = -1
|
|
25
25
|
|
|
@@ -42,7 +42,7 @@ export class UIKeyValueStringSorter extends UIObject {
|
|
|
42
42
|
|
|
43
43
|
if (useSeparateWebWorkerHolder) {
|
|
44
44
|
|
|
45
|
-
this._webWorkerHolder = { webWorker: new Worker(
|
|
45
|
+
this._webWorkerHolder = { webWorker: new Worker(new URL('UIKeyValueStringSorterWebWorker.ts')) }
|
|
46
46
|
|
|
47
47
|
}
|
|
48
48
|
|
|
@@ -0,0 +1,218 @@
|
|
|
1
|
+
|
|
2
|
+
// @ts-check
|
|
3
|
+
|
|
4
|
+
|
|
5
|
+
|
|
6
|
+
|
|
7
|
+
|
|
8
|
+
|
|
9
|
+
|
|
10
|
+
|
|
11
|
+
|
|
12
|
+
onmessage = function (event) {
|
|
13
|
+
|
|
14
|
+
//console.log('Message received from main script');
|
|
15
|
+
var workerResult = sortData(
|
|
16
|
+
event.data.data,
|
|
17
|
+
event.data.sortingInstructions
|
|
18
|
+
)
|
|
19
|
+
|
|
20
|
+
// @ts-ignore
|
|
21
|
+
workerResult.identifier = event.data.identifier;
|
|
22
|
+
// @ts-ignore
|
|
23
|
+
workerResult.instanceIdentifier = event.data.instanceIdentifier;
|
|
24
|
+
|
|
25
|
+
|
|
26
|
+
// @ts-ignore
|
|
27
|
+
postMessage(workerResult);
|
|
28
|
+
|
|
29
|
+
}
|
|
30
|
+
|
|
31
|
+
|
|
32
|
+
|
|
33
|
+
|
|
34
|
+
|
|
35
|
+
function valueForKeyPath(keyPath, object) {
|
|
36
|
+
|
|
37
|
+
var keys = keyPath.split(".");
|
|
38
|
+
var currentObject = object;
|
|
39
|
+
|
|
40
|
+
for (var i = 0; i < keys.length; i++) {
|
|
41
|
+
|
|
42
|
+
var key = keys[i];
|
|
43
|
+
|
|
44
|
+
if (key.substring(0, 2) == "[]") {
|
|
45
|
+
|
|
46
|
+
// This next object will be an array and the rest of the keys need to be run for each of the elements
|
|
47
|
+
|
|
48
|
+
currentObject = currentObject[key.substring(2)];
|
|
49
|
+
|
|
50
|
+
// CurrentObject is now an array
|
|
51
|
+
|
|
52
|
+
var remainingKeyPath = keys.slice(i + 1).join(".");
|
|
53
|
+
|
|
54
|
+
var currentArray = currentObject;
|
|
55
|
+
|
|
56
|
+
currentObject = currentArray.map(function (subObject, index, array) {
|
|
57
|
+
|
|
58
|
+
var result = valueForKeyPath(remainingKeyPath, subObject);
|
|
59
|
+
|
|
60
|
+
return result;
|
|
61
|
+
|
|
62
|
+
})
|
|
63
|
+
|
|
64
|
+
break;
|
|
65
|
+
|
|
66
|
+
}
|
|
67
|
+
|
|
68
|
+
currentObject = (currentObject || {})[key];
|
|
69
|
+
|
|
70
|
+
|
|
71
|
+
}
|
|
72
|
+
|
|
73
|
+
return currentObject;
|
|
74
|
+
|
|
75
|
+
}
|
|
76
|
+
|
|
77
|
+
|
|
78
|
+
|
|
79
|
+
|
|
80
|
+
|
|
81
|
+
|
|
82
|
+
|
|
83
|
+
function compare(firstObject, secondObject, sortingInstructions) {
|
|
84
|
+
|
|
85
|
+
|
|
86
|
+
if (sortingInstructions.length == 0) {
|
|
87
|
+
return 0;
|
|
88
|
+
}
|
|
89
|
+
|
|
90
|
+
|
|
91
|
+
var sortingInstruction = sortingInstructions[0];
|
|
92
|
+
|
|
93
|
+
|
|
94
|
+
var directionMultiplier = 1;
|
|
95
|
+
if (sortingInstruction.direction == "descending") {
|
|
96
|
+
directionMultiplier = -1;
|
|
97
|
+
}
|
|
98
|
+
|
|
99
|
+
|
|
100
|
+
var firstDataString = firstObject[sortingInstruction.keyPath];
|
|
101
|
+
|
|
102
|
+
var secondDataString = secondObject[sortingInstruction.keyPath];
|
|
103
|
+
|
|
104
|
+
|
|
105
|
+
|
|
106
|
+
|
|
107
|
+
if (firstDataString < secondDataString) {
|
|
108
|
+
|
|
109
|
+
return -1 * directionMultiplier;
|
|
110
|
+
|
|
111
|
+
}
|
|
112
|
+
|
|
113
|
+
if (firstDataString > secondDataString) {
|
|
114
|
+
|
|
115
|
+
return 1 * directionMultiplier;
|
|
116
|
+
|
|
117
|
+
}
|
|
118
|
+
|
|
119
|
+
if (sortingInstructions.length > 1) {
|
|
120
|
+
|
|
121
|
+
var remainingSortingInstructions = sortingInstructions.slice(1);
|
|
122
|
+
|
|
123
|
+
|
|
124
|
+
|
|
125
|
+
return compare(firstObject, secondObject, remainingSortingInstructions);
|
|
126
|
+
|
|
127
|
+
|
|
128
|
+
}
|
|
129
|
+
|
|
130
|
+
return 0;
|
|
131
|
+
|
|
132
|
+
}
|
|
133
|
+
|
|
134
|
+
|
|
135
|
+
|
|
136
|
+
|
|
137
|
+
|
|
138
|
+
function sortData(data, sortingInstructions) {
|
|
139
|
+
|
|
140
|
+
|
|
141
|
+
var sortingObjects = data.map(function (dataItem, index, array) {
|
|
142
|
+
|
|
143
|
+
var result = {
|
|
144
|
+
|
|
145
|
+
"_UIKeyValueStringSorterWebWorkerSortingObjectIndex": index
|
|
146
|
+
|
|
147
|
+
}
|
|
148
|
+
|
|
149
|
+
|
|
150
|
+
sortingInstructions.forEach(function(instruction, index, instructionsArray) {
|
|
151
|
+
|
|
152
|
+
result[instruction.keyPath] = JSON.stringify(valueForKeyPath(instruction.keyPath, dataItem) || {}).toLowerCase();
|
|
153
|
+
|
|
154
|
+
})
|
|
155
|
+
|
|
156
|
+
|
|
157
|
+
|
|
158
|
+
|
|
159
|
+
return result;
|
|
160
|
+
|
|
161
|
+
|
|
162
|
+
})
|
|
163
|
+
|
|
164
|
+
|
|
165
|
+
var sortedData = sortingObjects.sort(function (firstObject, secondObject) {
|
|
166
|
+
|
|
167
|
+
return compare(firstObject, secondObject, sortingInstructions);
|
|
168
|
+
|
|
169
|
+
})
|
|
170
|
+
|
|
171
|
+
var sortedIndexes = sortedData.map(function (object, index, array) {
|
|
172
|
+
|
|
173
|
+
var sortedIndex = object._UIKeyValueStringSorterWebWorkerSortingObjectIndex;
|
|
174
|
+
|
|
175
|
+
return sortedIndex;
|
|
176
|
+
|
|
177
|
+
})
|
|
178
|
+
|
|
179
|
+
var result = {
|
|
180
|
+
|
|
181
|
+
"sortedData": sortedIndexes.map(function (sortedIndex, index, array) {
|
|
182
|
+
|
|
183
|
+
return data[sortedIndex];
|
|
184
|
+
|
|
185
|
+
}),
|
|
186
|
+
"sortedIndexes": sortedIndexes
|
|
187
|
+
|
|
188
|
+
}
|
|
189
|
+
|
|
190
|
+
|
|
191
|
+
return result;
|
|
192
|
+
|
|
193
|
+
|
|
194
|
+
}
|
|
195
|
+
|
|
196
|
+
|
|
197
|
+
|
|
198
|
+
|
|
199
|
+
|
|
200
|
+
|
|
201
|
+
|
|
202
|
+
|
|
203
|
+
|
|
204
|
+
|
|
205
|
+
|
|
206
|
+
|
|
207
|
+
|
|
208
|
+
|
|
209
|
+
|
|
210
|
+
|
|
211
|
+
|
|
212
|
+
|
|
213
|
+
|
|
214
|
+
|
|
215
|
+
|
|
216
|
+
|
|
217
|
+
|
|
218
|
+
|
|
@@ -6,7 +6,7 @@ export class UIStringFilter extends UIObject {
|
|
|
6
6
|
|
|
7
7
|
|
|
8
8
|
|
|
9
|
-
static _sharedWebWorkerHolder = { webWorker: new Worker("
|
|
9
|
+
static _sharedWebWorkerHolder = { webWorker: new Worker(new URL("UIStringFilterWebWorker.ts"), {type: 'module'}) }
|
|
10
10
|
|
|
11
11
|
static _instanceNumber = -1
|
|
12
12
|
|
|
@@ -30,7 +30,7 @@ export class UIStringFilter extends UIObject {
|
|
|
30
30
|
|
|
31
31
|
if (useSeparateWebWorkerHolder) {
|
|
32
32
|
|
|
33
|
-
this._webWorkerHolder = { webWorker: new Worker("
|
|
33
|
+
this._webWorkerHolder = { webWorker: new Worker(new URL("UIStringFilterWebWorker.ts")) }
|
|
34
34
|
|
|
35
35
|
}
|
|
36
36
|
|
|
@@ -40,25 +40,25 @@ export class UIStringFilter extends UIObject {
|
|
|
40
40
|
if (IS_NOT(this._webWorkerHolder.webWorker.onmessage)) {
|
|
41
41
|
|
|
42
42
|
this._webWorkerHolder.webWorker.onmessage = message => {
|
|
43
|
-
|
|
44
|
-
this.isWorkerBusy = NO
|
|
45
|
-
this.postNextMessageIfNeeded()
|
|
43
|
+
|
|
44
|
+
this.isWorkerBusy = NO
|
|
45
|
+
this.postNextMessageIfNeeded()
|
|
46
46
|
|
|
47
47
|
const key = "" + message.data.identifier + message.data.instanceIdentifier
|
|
48
|
-
|
|
48
|
+
|
|
49
49
|
const completionFunction = this.completionFunctions[key]
|
|
50
|
-
|
|
50
|
+
|
|
51
51
|
if (IS(completionFunction)) {
|
|
52
|
-
|
|
52
|
+
|
|
53
53
|
//console.log("Filtering took " + (Date.now() - startTime) + " ms");
|
|
54
|
-
|
|
54
|
+
|
|
55
55
|
completionFunction(message.data.filteredData, message.data.filteredIndexes, message.data.identifier)
|
|
56
|
-
|
|
56
|
+
|
|
57
57
|
}
|
|
58
58
|
|
|
59
|
-
delete this.completionFunctions[key]
|
|
59
|
+
delete this.completionFunctions[key]
|
|
60
60
|
|
|
61
|
-
var asd = 1
|
|
61
|
+
var asd = 1
|
|
62
62
|
|
|
63
63
|
}
|
|
64
64
|
|
|
@@ -66,8 +66,8 @@ export class UIStringFilter extends UIObject {
|
|
|
66
66
|
|
|
67
67
|
|
|
68
68
|
|
|
69
|
-
|
|
70
|
-
|
|
69
|
+
|
|
70
|
+
|
|
71
71
|
}
|
|
72
72
|
|
|
73
73
|
|
|
@@ -83,50 +83,50 @@ export class UIStringFilter extends UIObject {
|
|
|
83
83
|
|
|
84
84
|
get completionFunctions() {
|
|
85
85
|
|
|
86
|
-
const key = "UICore_completionFunctions"
|
|
86
|
+
const key = "UICore_completionFunctions"
|
|
87
87
|
var result: {
|
|
88
|
-
|
|
88
|
+
|
|
89
89
|
[x: string]: (filteredData: string[], filteredIndexes: number[], identifier: any) => void;
|
|
90
90
|
|
|
91
|
-
} = this._webWorkerHolder[key]
|
|
91
|
+
} = this._webWorkerHolder[key]
|
|
92
92
|
|
|
93
93
|
if (IS_NOT(result)) {
|
|
94
94
|
|
|
95
|
-
result = {}
|
|
96
|
-
this._webWorkerHolder[key] = result
|
|
95
|
+
result = {}
|
|
96
|
+
this._webWorkerHolder[key] = result
|
|
97
97
|
|
|
98
98
|
}
|
|
99
99
|
|
|
100
|
-
return result
|
|
100
|
+
return result
|
|
101
101
|
|
|
102
102
|
}
|
|
103
103
|
|
|
104
104
|
get messagesToPost() {
|
|
105
105
|
|
|
106
|
-
const key = "UICore_messagesToPost"
|
|
107
|
-
var result: any[] = this._webWorkerHolder[key]
|
|
106
|
+
const key = "UICore_messagesToPost"
|
|
107
|
+
var result: any[] = this._webWorkerHolder[key]
|
|
108
108
|
|
|
109
109
|
if (IS_NOT(result)) {
|
|
110
110
|
|
|
111
|
-
result = []
|
|
112
|
-
this._webWorkerHolder[key] = result
|
|
111
|
+
result = []
|
|
112
|
+
this._webWorkerHolder[key] = result
|
|
113
113
|
|
|
114
114
|
}
|
|
115
115
|
|
|
116
|
-
return result
|
|
116
|
+
return result
|
|
117
117
|
|
|
118
118
|
}
|
|
119
119
|
|
|
120
120
|
|
|
121
121
|
set isWorkerBusy(isWorkerBusy: boolean) {
|
|
122
122
|
|
|
123
|
-
this._webWorkerHolder["UICore_isWorking"] = isWorkerBusy
|
|
123
|
+
this._webWorkerHolder["UICore_isWorking"] = isWorkerBusy
|
|
124
124
|
|
|
125
125
|
}
|
|
126
126
|
|
|
127
127
|
get isWorkerBusy() {
|
|
128
128
|
|
|
129
|
-
return IS(this._webWorkerHolder["UICore_isWorking"])
|
|
129
|
+
return IS(this._webWorkerHolder["UICore_isWorking"])
|
|
130
130
|
|
|
131
131
|
}
|
|
132
132
|
|
|
@@ -136,10 +136,10 @@ export class UIStringFilter extends UIObject {
|
|
|
136
136
|
|
|
137
137
|
if (this.messagesToPost.length && IS_NOT(this.isWorkerBusy)) {
|
|
138
138
|
|
|
139
|
-
this._webWorkerHolder.webWorker.postMessage(this.messagesToPost.firstElement)
|
|
140
|
-
this.messagesToPost.removeElementAtIndex(0)
|
|
139
|
+
this._webWorkerHolder.webWorker.postMessage(this.messagesToPost.firstElement)
|
|
140
|
+
this.messagesToPost.removeElementAtIndex(0)
|
|
141
141
|
|
|
142
|
-
this.isWorkerBusy = YES
|
|
142
|
+
this.isWorkerBusy = YES
|
|
143
143
|
|
|
144
144
|
}
|
|
145
145
|
|
|
@@ -180,9 +180,9 @@ export class UIStringFilter extends UIObject {
|
|
|
180
180
|
"identifier": identifier,
|
|
181
181
|
"instanceIdentifier": instanceIdentifier
|
|
182
182
|
|
|
183
|
-
})
|
|
183
|
+
})
|
|
184
184
|
|
|
185
|
-
this.postNextMessageIfNeeded()
|
|
185
|
+
this.postNextMessageIfNeeded()
|
|
186
186
|
|
|
187
187
|
|
|
188
188
|
}
|
|
@@ -241,7 +241,7 @@ export class UIStringFilter extends UIObject {
|
|
|
241
241
|
|
|
242
242
|
if (this._webWorkerHolder != UIStringFilter._sharedWebWorkerHolder) {
|
|
243
243
|
|
|
244
|
-
this._webWorkerHolder.webWorker.terminate()
|
|
244
|
+
this._webWorkerHolder.webWorker.terminate()
|
|
245
245
|
|
|
246
246
|
}
|
|
247
247
|
|
|
@@ -0,0 +1,150 @@
|
|
|
1
|
+
|
|
2
|
+
// @ts-check
|
|
3
|
+
|
|
4
|
+
if ("contains" in Array.prototype == false) {
|
|
5
|
+
|
|
6
|
+
// @ts-ignore
|
|
7
|
+
Array.prototype.contains = function (element) {
|
|
8
|
+
|
|
9
|
+
var result = (this.indexOf(element) != -1);
|
|
10
|
+
return result;
|
|
11
|
+
|
|
12
|
+
}
|
|
13
|
+
|
|
14
|
+
}
|
|
15
|
+
|
|
16
|
+
if ("contains" in String.prototype == false) {
|
|
17
|
+
|
|
18
|
+
// @ts-ignore
|
|
19
|
+
String.prototype.contains = function (string) {
|
|
20
|
+
|
|
21
|
+
var result = (this.indexOf(string) != -1);
|
|
22
|
+
return result;
|
|
23
|
+
|
|
24
|
+
}
|
|
25
|
+
|
|
26
|
+
}
|
|
27
|
+
|
|
28
|
+
|
|
29
|
+
|
|
30
|
+
|
|
31
|
+
|
|
32
|
+
onmessage = function (event) {
|
|
33
|
+
|
|
34
|
+
//console.log('Message received from main script');
|
|
35
|
+
var workerResult = filterData(event.data.filteringString, event.data.data, event.data.excludedData);
|
|
36
|
+
|
|
37
|
+
// @ts-ignore
|
|
38
|
+
workerResult.identifier = event.data.identifier;
|
|
39
|
+
// @ts-ignore
|
|
40
|
+
workerResult.instanceIdentifier = event.data.instanceIdentifier;
|
|
41
|
+
|
|
42
|
+
// @ts-ignore
|
|
43
|
+
postMessage(workerResult);
|
|
44
|
+
|
|
45
|
+
}
|
|
46
|
+
|
|
47
|
+
|
|
48
|
+
|
|
49
|
+
|
|
50
|
+
|
|
51
|
+
|
|
52
|
+
|
|
53
|
+
|
|
54
|
+
|
|
55
|
+
function filterData(filteringString, data, excludedData) {
|
|
56
|
+
|
|
57
|
+
var filteredData = [];
|
|
58
|
+
var filteredIndexes = [];
|
|
59
|
+
|
|
60
|
+
if (filteringString) {
|
|
61
|
+
|
|
62
|
+
var filteringStringWords = [];
|
|
63
|
+
filteringString.split(" ").forEach(function (word, index, array) {
|
|
64
|
+
if (word) {
|
|
65
|
+
filteringStringWords.push(word.toLowerCase());
|
|
66
|
+
}
|
|
67
|
+
})
|
|
68
|
+
|
|
69
|
+
data.forEach(function (dataString, index, array) {
|
|
70
|
+
|
|
71
|
+
var lowercaseDataString = dataString.toLowerCase();
|
|
72
|
+
|
|
73
|
+
// Look through all the words in the input
|
|
74
|
+
var wordsFound = [];
|
|
75
|
+
filteringStringWords.forEach(function (word) {
|
|
76
|
+
wordsFound.push(lowercaseDataString.contains(word) && !excludedData.contains(dataString));
|
|
77
|
+
})
|
|
78
|
+
|
|
79
|
+
// Only show the dataString if it matches all of them
|
|
80
|
+
// @ts-ignore
|
|
81
|
+
if (wordsFound.contains(true) && !wordsFound.contains(false)) {
|
|
82
|
+
|
|
83
|
+
filteredData.push(dataString);
|
|
84
|
+
filteredIndexes.push(index);
|
|
85
|
+
|
|
86
|
+
}
|
|
87
|
+
|
|
88
|
+
})
|
|
89
|
+
|
|
90
|
+
|
|
91
|
+
|
|
92
|
+
}
|
|
93
|
+
else if (excludedData.length) {
|
|
94
|
+
|
|
95
|
+
|
|
96
|
+
filteredData = data.forEach(function (dataString, index, array) {
|
|
97
|
+
|
|
98
|
+
if (excludedData.indexOf(dataString) == -1) {
|
|
99
|
+
|
|
100
|
+
filteredData.push(dataString);
|
|
101
|
+
filteredIndexes.push(index);
|
|
102
|
+
|
|
103
|
+
}
|
|
104
|
+
|
|
105
|
+
})
|
|
106
|
+
|
|
107
|
+
}
|
|
108
|
+
else {
|
|
109
|
+
|
|
110
|
+
filteredData = data;
|
|
111
|
+
|
|
112
|
+
data.forEach(function (string, index, array) {
|
|
113
|
+
|
|
114
|
+
filteredIndexes.push(index);
|
|
115
|
+
|
|
116
|
+
})
|
|
117
|
+
|
|
118
|
+
}
|
|
119
|
+
|
|
120
|
+
|
|
121
|
+
|
|
122
|
+
return { "filteredData": filteredData, "filteredIndexes": filteredIndexes };
|
|
123
|
+
|
|
124
|
+
|
|
125
|
+
|
|
126
|
+
}
|
|
127
|
+
|
|
128
|
+
|
|
129
|
+
|
|
130
|
+
|
|
131
|
+
|
|
132
|
+
|
|
133
|
+
|
|
134
|
+
|
|
135
|
+
|
|
136
|
+
|
|
137
|
+
|
|
138
|
+
|
|
139
|
+
|
|
140
|
+
|
|
141
|
+
|
|
142
|
+
|
|
143
|
+
|
|
144
|
+
|
|
145
|
+
|
|
146
|
+
|
|
147
|
+
|
|
148
|
+
|
|
149
|
+
|
|
150
|
+
|