uicore-ts 1.1.6 → 1.1.10
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/UIKeyValueSorter.js +4 -0
- package/compiledScripts/UIKeyValueSorter.js.map +2 -2
- package/compiledScripts/UIKeyValueStringFilter.js +4 -0
- package/compiledScripts/UIKeyValueStringFilter.js.map +2 -2
- package/package.json +1 -1
- package/scripts/UIKeyValueSorter.ts +6 -2
- package/scripts/UIKeyValueStringFilter.ts +5 -0
|
@@ -96,6 +96,10 @@ const _UIKeyValueSorter = class extends import_UIObject.UIObject {
|
|
|
96
96
|
if (this._isThreadClosed) {
|
|
97
97
|
return;
|
|
98
98
|
}
|
|
99
|
+
if (!(data == null ? void 0 : data.length)) {
|
|
100
|
+
completion([], [], identifier);
|
|
101
|
+
return;
|
|
102
|
+
}
|
|
99
103
|
const instanceIdentifier = this.instanceIdentifier;
|
|
100
104
|
const key = "" + identifier + instanceIdentifier;
|
|
101
105
|
this.completionFunctions[key] = completion;
|
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
{
|
|
2
2
|
"version": 3,
|
|
3
3
|
"sources": ["../scripts/UIKeyValueSorter.ts"],
|
|
4
|
-
"sourcesContent": ["// @ts-ignore\nimport UIKeyValueSorterWebWorker from \"./UIKeyValueSorterWebWorker.worker\"\nimport { IS, IS_NOT, MAKE_ID, NO, UIObject, YES } from \"./UIObject\"\n\n\nexport interface UIKeyValueSorterSortingInstruction {\n \n keyPath: string;\n \n dataType: string;\n \n direction: string;\n \n \n}\n\n\nexport class UIKeyValueSorter extends UIObject {\n \n static _sharedWebWorkerHolder = {\n UICore_completionFunctions: {},\n UICore_isWorking: false,\n UICore_messagesToPost: undefined,\n webWorker: new UIKeyValueSorterWebWorker()\n }\n \n static _instanceNumber = -1\n \n _instanceNumber: number\n _isThreadClosed = NO\n \n private readonly _webWorkerHolder: {\n webWorker: any;\n UICore_isWorking: boolean\n UICore_messagesToPost: any\n UICore_completionFunctions: Record<string, (\n filteredData: string[],\n filteredIndexes: number[],\n identifier: any\n ) => void>\n } = UIKeyValueSorter._sharedWebWorkerHolder\n \n \n constructor(useSeparateWebWorkerHolder = NO) {\n \n super()\n \n if (useSeparateWebWorkerHolder) {\n \n this._webWorkerHolder = {\n webWorker: new UIKeyValueSorterWebWorker(),\n UICore_isWorking: false,\n UICore_messagesToPost: undefined,\n UICore_completionFunctions: {}\n }\n \n }\n \n UIKeyValueSorter._instanceNumber = UIKeyValueSorter._instanceNumber + 1\n this._instanceNumber = UIKeyValueSorter._instanceNumber\n \n if (IS_NOT(this._webWorkerHolder.webWorker.onmessage)) {\n \n this._webWorkerHolder.webWorker.onmessage = (message: { data: { identifier: string; instanceIdentifier: string; sortedData: any[]; sortedIndexes: number[]; }; }) => {\n \n this.isWorkerBusy = NO\n this.postNextMessageIfNeeded()\n \n const key = \"\" + message.data.identifier + message.data.instanceIdentifier\n \n const completionFunction = this.completionFunctions[key]\n \n if (IS(completionFunction)) {\n \n //console.log(\"Filtering took \" + (Date.now() - startTime) + \" ms\");\n \n completionFunction(message.data.sortedData, message.data.sortedIndexes, message.data.identifier)\n \n }\n \n delete this.completionFunctions[key]\n \n var asd = 1\n \n }\n \n }\n \n \n }\n \n \n get instanceIdentifier() {\n \n return this._instanceNumber\n \n }\n \n \n get completionFunctions() {\n \n const key = \"UICore_completionFunctions\"\n var result: {\n \n [x: string]: (sortedData: any[], sortedIndexes: number[], identifier: any) => void\n \n } = this._webWorkerHolder[key]\n \n if (IS_NOT(result)) {\n \n result = {}\n this._webWorkerHolder[key] = result\n \n }\n \n return result\n \n }\n \n get messagesToPost() {\n \n const key = \"UICore_messagesToPost\"\n var result: any[] = this._webWorkerHolder[key]\n \n if (IS_NOT(result)) {\n \n result = []\n this._webWorkerHolder[key] = result\n \n }\n \n return result\n \n }\n \n \n set isWorkerBusy(isWorkerBusy: boolean) {\n \n this._webWorkerHolder[\"UICore_isWorking\"] = isWorkerBusy\n \n }\n \n get isWorkerBusy() {\n \n return IS(this._webWorkerHolder[\"UICore_isWorking\"])\n \n }\n \n \n postNextMessageIfNeeded() {\n \n if (this.messagesToPost.length && IS_NOT(this.isWorkerBusy)) {\n \n this._webWorkerHolder.webWorker.postMessage(this.messagesToPost.firstElement)\n this.messagesToPost.removeElementAtIndex(0)\n \n this.isWorkerBusy = YES\n \n }\n \n }\n \n \n static dataType = {\n \n \"string\": \"string\",\n \"number\": \"number\"\n \n }\n \n \n static direction = {\n \n \"descending\": \"descending\",\n \"ascending\": \"ascending\"\n \n }\n \n \n sortData<T>(\n data: T[],\n sortingInstructions: UIKeyValueSorterSortingInstruction[],\n identifier: any,\n completion: (sortedData: T[], sortedIndexes: number[], identifier: any) => void\n ) {\n \n \n if (this._isThreadClosed) {\n \n return\n \n }\n
|
|
5
|
-
"mappings": ";;;;;;;;;;;;;;;;;;;;;;;;AAAA;AAAA;AAAA;AAAA;AAAA;AACA,uCAAsC;AACtC,sBAAuD;AAehD,MAAM,oBAAN,cAA+B,yBAAS;AAAA,EA0B3C,YAAY,6BAA6B,oBAAI;AAEzC,UAAM;AAhBV,2BAAkB;AAElB,SAAiB,mBASb,kBAAiB;AAOjB,QAAI,4BAA4B;AAE5B,WAAK,mBAAmB;AAAA,QACpB,WAAW,IAAI,iCAAAA,QAA0B;AAAA,QACzC,kBAAkB;AAAA,QAClB,uBAAuB;AAAA,QACvB,4BAA4B,CAAC;AAAA,MACjC;AAAA,IAEJ;AAEA,sBAAiB,kBAAkB,kBAAiB,kBAAkB;AACtE,SAAK,kBAAkB,kBAAiB;AAExC,YAAI,wBAAO,KAAK,iBAAiB,UAAU,SAAS,GAAG;AAEnD,WAAK,iBAAiB,UAAU,YAAY,CAAC,YAAwH;AAEjK,aAAK,eAAe;AACpB,aAAK,wBAAwB;AAE7B,cAAM,MAAM,KAAK,QAAQ,KAAK,aAAa,QAAQ,KAAK;AAExD,cAAM,qBAAqB,KAAK,oBAAoB;AAEpD,gBAAI,oBAAG,kBAAk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terSortingInstruction {\n \n keyPath: string;\n \n dataType: string;\n \n direction: string;\n \n \n}\n\n\nexport class UIKeyValueSorter extends UIObject {\n \n static _sharedWebWorkerHolder = {\n UICore_completionFunctions: {},\n UICore_isWorking: false,\n UICore_messagesToPost: undefined,\n webWorker: new UIKeyValueSorterWebWorker()\n }\n \n static _instanceNumber = -1\n \n _instanceNumber: number\n _isThreadClosed = NO\n \n private readonly _webWorkerHolder: {\n webWorker: any;\n UICore_isWorking: boolean\n UICore_messagesToPost: any\n UICore_completionFunctions: Record<string, (\n filteredData: string[],\n filteredIndexes: number[],\n identifier: any\n ) => void>\n } = UIKeyValueSorter._sharedWebWorkerHolder\n \n \n constructor(useSeparateWebWorkerHolder = NO) {\n \n super()\n \n if (useSeparateWebWorkerHolder) {\n \n this._webWorkerHolder = {\n webWorker: new UIKeyValueSorterWebWorker(),\n UICore_isWorking: false,\n UICore_messagesToPost: undefined,\n UICore_completionFunctions: {}\n }\n \n }\n \n UIKeyValueSorter._instanceNumber = UIKeyValueSorter._instanceNumber + 1\n this._instanceNumber = UIKeyValueSorter._instanceNumber\n \n if (IS_NOT(this._webWorkerHolder.webWorker.onmessage)) {\n \n this._webWorkerHolder.webWorker.onmessage = (message: { data: { identifier: string; instanceIdentifier: string; sortedData: any[]; sortedIndexes: number[]; }; }) => {\n \n this.isWorkerBusy = NO\n this.postNextMessageIfNeeded()\n \n const key = \"\" + message.data.identifier + message.data.instanceIdentifier\n \n const completionFunction = this.completionFunctions[key]\n \n if (IS(completionFunction)) {\n \n //console.log(\"Filtering took \" + (Date.now() - startTime) + \" ms\");\n \n completionFunction(message.data.sortedData, message.data.sortedIndexes, message.data.identifier)\n \n }\n \n delete this.completionFunctions[key]\n \n var asd = 1\n \n }\n \n }\n \n \n }\n \n \n get instanceIdentifier() {\n \n return this._instanceNumber\n \n }\n \n \n get completionFunctions() {\n \n const key = \"UICore_completionFunctions\"\n var result: {\n \n [x: string]: (sortedData: any[], sortedIndexes: number[], identifier: any) => void\n \n } = this._webWorkerHolder[key]\n \n if (IS_NOT(result)) {\n \n result = {}\n this._webWorkerHolder[key] = result\n \n }\n \n return result\n \n }\n \n get messagesToPost() {\n \n const key = \"UICore_messagesToPost\"\n var result: any[] = this._webWorkerHolder[key]\n \n if (IS_NOT(result)) {\n \n result = []\n this._webWorkerHolder[key] = result\n \n }\n \n return result\n \n }\n \n \n set isWorkerBusy(isWorkerBusy: boolean) {\n \n this._webWorkerHolder[\"UICore_isWorking\"] = isWorkerBusy\n \n }\n \n get isWorkerBusy() {\n \n return IS(this._webWorkerHolder[\"UICore_isWorking\"])\n \n }\n \n \n postNextMessageIfNeeded() {\n \n if (this.messagesToPost.length && IS_NOT(this.isWorkerBusy)) {\n \n this._webWorkerHolder.webWorker.postMessage(this.messagesToPost.firstElement)\n this.messagesToPost.removeElementAtIndex(0)\n \n this.isWorkerBusy = YES\n \n }\n \n }\n \n \n static dataType = {\n \n \"string\": \"string\",\n \"number\": \"number\"\n \n }\n \n \n static direction = {\n \n \"descending\": \"descending\",\n \"ascending\": \"ascending\"\n \n }\n \n \n sortData<T>(\n data: T[],\n sortingInstructions: UIKeyValueSorterSortingInstruction[],\n identifier: any,\n completion: (sortedData: T[], sortedIndexes: number[], identifier: any) => void\n ) {\n \n \n if (this._isThreadClosed) {\n \n return\n \n }\n \n if (!data?.length) {\n completion([], [], identifier)\n return\n }\n \n const instanceIdentifier = this.instanceIdentifier\n \n const key = \"\" + identifier + instanceIdentifier\n \n this.completionFunctions[key] = completion\n \n \n try {\n \n this.messagesToPost.push({\n \n \"data\": data,\n \"sortingInstructions\": sortingInstructions,\n \"identifier\": identifier,\n \"instanceIdentifier\": instanceIdentifier\n \n })\n \n this.postNextMessageIfNeeded()\n \n } catch (exception) {\n \n completion([], [], identifier)\n \n }\n \n \n }\n \n \n sortedData<T>(\n data: T[],\n sortingInstructions: UIKeyValueSorterSortingInstruction[],\n identifier: any = MAKE_ID()\n ) {\n \n const result: Promise<{\n \n sortedData: T[],\n sortedIndexes: number[],\n identifier: any\n \n }> = new Promise((resolve, reject) => {\n \n this.sortData(data, sortingInstructions, identifier, (sortedData, sortedIndexes, sortedIdentifier) => {\n \n if (sortedIdentifier == identifier) {\n \n resolve({\n \n sortedData: sortedData,\n sortedIndexes: sortedIndexes,\n identifier: sortedIdentifier\n \n })\n \n }\n \n \n })\n \n \n })\n \n return result\n \n }\n \n \n closeThread() {\n \n this._isThreadClosed = YES\n \n if (this._webWorkerHolder != UIKeyValueSorter._sharedWebWorkerHolder) {\n \n this._webWorkerHolder.webWorker.terminate()\n \n }\n \n \n }\n \n \n}\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n"],
|
|
5
|
+
"mappings": ";;;;;;;;;;;;;;;;;;;;;;;;AAAA;AAAA;AAAA;AAAA;AAAA;AACA,uCAAsC;AACtC,sBAAuD;AAehD,MAAM,oBAAN,cAA+B,yBAAS;AAAA,EA0B3C,YAAY,6BAA6B,oBAAI;AAEzC,UAAM;AAhBV,2BAAkB;AAElB,SAAiB,mBASb,kBAAiB;AAOjB,QAAI,4BAA4B;AAE5B,WAAK,mBAAmB;AAAA,QACpB,WAAW,IAAI,iCAAAA,QAA0B;AAAA,QACzC,kBAAkB;AAAA,QAClB,uBAAuB;AAAA,QACvB,4BAA4B,CAAC;AAAA,MACjC;AAAA,IAEJ;AAEA,sBAAiB,kBAAkB,kBAAiB,kBAAkB;AACtE,SAAK,kBAAkB,kBAAiB;AAExC,YAAI,wBAAO,KAAK,iBAAiB,UAAU,SAAS,GAAG;AAEnD,WAAK,iBAAiB,UAAU,YAAY,CAAC,YAAwH;AAEjK,aAAK,eAAe;AACpB,aAAK,wBAAwB;AAE7B,cAAM,MAAM,KAAK,QAAQ,KAAK,aAAa,QAAQ,KAAK;AAExD,cAAM,qBAAqB,KAAK,oBAAoB;AAEpD,gBAAI,oBAAG,kBAAkB,GAAG;AAIxB,6BAAmB,QAAQ,KAA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,WAAK,eAAe,KAAK;AAAA,QAErB,QAAQ;AAAA,QACR,uBAAuB;AAAA,QACvB,cAAc;AAAA,QACd,sBAAsB;AAAA,MAE1B,CAAC;AAED,WAAK,wBAAwB;AAAA,IAEjC,SAAS,WAAP;AAEE,iBAAW,CAAC,GAAG,CAAC,GAAG,UAAU;AAAA,IAEjC;AAAA,EAGJ;AAAA,EAGA,WACI,MACA,qBACA,iBAAkB,yBAAQ,GAC5B;AAEE,UAAM,SAMD,IAAI,QAAQ,CAAC,SAAS,WAAW;AAElC,WAAK,SAAS,MAAM,qBAAqB,YAAY,CAAC,YAAY,eAAe,qBAAqB;AAElG,YAAI,oBAAoB,YAAY;AAEhC,kBAAQ;AAAA,YAEJ;AAAA,YACA;AAAA,YACA,YAAY;AAAA,UAEhB,CAAC;AAAA,QAEL;AAAA,MAGJ,CAAC;AAAA,IAGL,CAAC;AAED,WAAO;AAAA,EAEX;AAAA,EAGA,cAAc;AAEV,SAAK,kBAAkB;AAEvB,QAAI,KAAK,oBAAoB,kBAAiB,wBAAwB;AAElE,WAAK,iBAAiB,UAAU,UAAU;AAAA,IAE9C;AAAA,EAGJ;AAGJ;AAxQO,IAAM,mBAAN;AAAM,iBAEF,yBAAyB;AAAA,EAC5B,4BAA4B,CAAC;AAAA,EAC7B,kBAAkB;AAAA,EAClB,uBAAuB;AAAA,EACvB,WAAW,IAAI,iCAAAA,QAA0B;AAC7C;AAPS,iBASF,kBAAkB;AAThB,iBAkJF,WAAW;AAAA,EAEd,UAAU;AAAA,EACV,UAAU;AAEd;AAvJS,iBA0JF,YAAY;AAAA,EAEf,cAAc;AAAA,EACd,aAAa;AAEjB;",
|
|
6
6
|
"names": ["UIKeyValueSorterWebWorker"]
|
|
7
7
|
}
|
|
@@ -96,6 +96,10 @@ const _UIKeyValueStringFilter = class extends import_UIObject.UIObject {
|
|
|
96
96
|
if (this._isThreadClosed) {
|
|
97
97
|
return;
|
|
98
98
|
}
|
|
99
|
+
if (!(data == null ? void 0 : data.length)) {
|
|
100
|
+
completion([], [], identifier);
|
|
101
|
+
return;
|
|
102
|
+
}
|
|
99
103
|
const instanceIdentifier = this.instanceIdentifier;
|
|
100
104
|
const key = "" + identifier + instanceIdentifier;
|
|
101
105
|
this.completionFunctions[key] = completion;
|
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
{
|
|
2
2
|
"version": 3,
|
|
3
3
|
"sources": ["../scripts/UIKeyValueStringFilter.ts"],
|
|
4
|
-
"sourcesContent": ["// @ts-ignore\nimport UIKeyValueStringFilterWebWorker from \"./UIKeyValueStringFilterWebWorker.worker.js\"\nimport { IS, IS_NOT, NO, UIObject, YES } from \"./UIObject\"\n\n\nexport class UIKeyValueStringFilter extends UIObject {\n \n static _sharedWebWorkerHolder: {\n webWorker: any\n UICore_completionFunctions: Record<string, (\n filteredData: string[],\n filteredIndexes: number[],\n identifier: any\n ) => void>\n UICore_messagesToPost: any\n UICore_isWorking: boolean\n } = {\n webWorker: new UIKeyValueStringFilterWebWorker(),\n UICore_isWorking: false,\n UICore_messagesToPost: undefined,\n UICore_completionFunctions: {}\n }\n static _instanceNumber = -1\n \n _instanceNumber: number\n _isThreadClosed = NO\n \n private readonly _webWorkerHolder = UIKeyValueStringFilter._sharedWebWorkerHolder\n \n constructor(useSeparateWebWorkerHolder = NO) {\n \n super()\n \n if (useSeparateWebWorkerHolder) {\n this._webWorkerHolder = {\n webWorker: new UIKeyValueStringFilterWebWorker(),\n UICore_isWorking: false,\n UICore_messagesToPost: undefined,\n UICore_completionFunctions: {}\n }\n }\n \n UIKeyValueStringFilter._instanceNumber = UIKeyValueStringFilter._instanceNumber + 1\n this._instanceNumber = UIKeyValueStringFilter._instanceNumber\n \n if (IS_NOT(this._webWorkerHolder.webWorker.onmessage)) {\n \n this._webWorkerHolder.webWorker.onmessage = (message: { data: { identifier: string; instanceIdentifier: string; filteredData: any[]; filteredIndexes: number[] } }) => {\n \n this.isWorkerBusy = NO\n this.postNextMessageIfNeeded()\n \n const key = \"\" + message.data.identifier + message.data.instanceIdentifier\n \n const completionFunction = this.completionFunctions[key]\n \n if (IS(completionFunction)) {\n \n //console.log(\"Filtering took \" + (Date.now() - startTime) + \" ms\");\n \n completionFunction(message.data.filteredData, message.data.filteredIndexes, message.data.identifier)\n \n }\n \n delete this.completionFunctions[key]\n \n var asd = 1\n \n }\n \n }\n \n \n }\n \n \n get instanceIdentifier() {\n \n return this._instanceNumber\n \n }\n \n \n get completionFunctions() {\n \n const key = \"UICore_completionFunctions\"\n let result: {\n \n [x: string]: (filteredData: any[], filteredIndexes: number[], identifier: any) => void;\n \n } = this._webWorkerHolder[key]\n \n if (IS_NOT(result)) {\n \n result = {}\n this._webWorkerHolder[key] = result\n \n }\n \n return result\n \n }\n \n get messagesToPost() {\n \n const key = \"UICore_messagesToPost\"\n var result: any[] = this._webWorkerHolder[key]\n \n if (IS_NOT(result)) {\n \n result = []\n this._webWorkerHolder[key] = result\n \n }\n \n return result\n \n }\n \n \n set isWorkerBusy(isWorkerBusy: boolean) {\n \n this._webWorkerHolder[\"UICore_isWorking\"] = isWorkerBusy\n \n }\n \n get isWorkerBusy() {\n \n return IS(this._webWorkerHolder[\"UICore_isWorking\"])\n \n }\n \n \n postNextMessageIfNeeded() {\n \n if (this.messagesToPost.length && IS_NOT(this.isWorkerBusy)) {\n \n this._webWorkerHolder.webWorker.postMessage(this.messagesToPost.firstElement)\n this.messagesToPost.removeElementAtIndex(0)\n \n this.isWorkerBusy = YES\n \n }\n \n }\n \n \n filterData<T extends object>(\n filteringString: string,\n data: T[],\n excludedData: string[],\n dataKeyPath: string,\n identifier: any,\n completion: (filteredData: T[], filteredIndexes: number[], identifier: any) => void\n ) {\n \n \n if (this._isThreadClosed) {\n \n return\n \n }\n \n \n const instanceIdentifier = this.instanceIdentifier\n \n const key = \"\" + identifier + instanceIdentifier\n \n this.completionFunctions[key] = completion\n \n \n try {\n \n this.messagesToPost.push({\n \n \"filteringString\": filteringString,\n \"data\": data,\n \"excludedData\": excludedData,\n \"dataKeyPath\": dataKeyPath,\n \"identifier\": identifier,\n \"instanceIdentifier\": instanceIdentifier\n \n })\n \n this.postNextMessageIfNeeded()\n \n } catch (exception) {\n \n completion([], [], identifier)\n \n }\n \n \n }\n \n \n closeThread() {\n \n this._isThreadClosed = YES\n \n if (this._webWorkerHolder != UIKeyValueStringFilter._sharedWebWorkerHolder) {\n \n this._webWorkerHolder.webWorker.terminate()\n \n }\n \n \n }\n \n \n}\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n"],
|
|
5
|
-
"mappings": ";;;;;;;;;;;;;;;;;;;;;;;;AAAA;AAAA;AAAA;AAAA;AAAA;AACA,oDAA4C;AAC5C,sBAA8C;AAGvC,MAAM,0BAAN,cAAqC,yBAAS;AAAA,EAwBjD,YAAY,6BAA6B,oBAAI;AAEzC,UAAM;AANV,2BAAkB;AAElB,SAAiB,mBAAmB,wBAAuB;AAMvD,QAAI,4BAA4B;AAC5B,WAAK,mBAAmB;AAAA,QACpB,WAAW,IAAI,8CAAAA,QAAgC;AAAA,QAC/C,kBAAkB;AAAA,QAClB,uBAAuB;AAAA,QACvB,4BAA4B,CAAC;AAAA,MACjC;AAAA,IACJ;AAEA,4BAAuB,kBAAkB,wBAAuB,kBAAkB;AAClF,SAAK,kBAAkB,wBAAuB;AAE9C,YAAI,wBAAO,KAAK,iBAAiB,UAAU,SAAS,GAAG;AAEnD,WAAK,iBAAiB,UAAU,YAAY,CAAC,YAA0H;AAEnK,aAAK,eAAe;AACpB,aAAK,wBAAwB;AAE7B,cAAM,MAAM,KAAK,QAAQ,KAAK,aAAa,QAAQ,KAAK;AAExD,cAAM,qBAAqB,KAAK,oBAAoB;AAEpD,gBAAI,oBAAG,kBAAkB,GAAG;AAIxB,6BAAmB,QAAQ,KAAK,cAAc,QAAQ,KAAK,iBAAiB,QAAQ,KAAK,UAAU;AAAA,QAEvG;AAEA,eAAO,KAAK,oBAAo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;AAAA,IAEjC,SAAS,WAAP;AAEE,iBAAW,CAAC,GAAG,CAAC,GAAG,UAAU;AAAA,IAEjC;AAAA,EAGJ;AAAA,EAGA,cAAc;AAEV,SAAK,kBAAkB;AAEvB,QAAI,KAAK,oBAAoB,wBAAuB,wBAAwB;AAExE,WAAK,iBAAiB,UAAU,UAAU;AAAA,IAE9C;AAAA,EAGJ;AAGJ;
|
|
4
|
+
"sourcesContent": ["// @ts-ignore\nimport UIKeyValueStringFilterWebWorker from \"./UIKeyValueStringFilterWebWorker.worker.js\"\nimport { IS, IS_NOT, NO, UIObject, YES } from \"./UIObject\"\n\n\nexport class UIKeyValueStringFilter extends UIObject {\n \n static _sharedWebWorkerHolder: {\n webWorker: any\n UICore_completionFunctions: Record<string, (\n filteredData: string[],\n filteredIndexes: number[],\n identifier: any\n ) => void>\n UICore_messagesToPost: any\n UICore_isWorking: boolean\n } = {\n webWorker: new UIKeyValueStringFilterWebWorker(),\n UICore_isWorking: false,\n UICore_messagesToPost: undefined,\n UICore_completionFunctions: {}\n }\n static _instanceNumber = -1\n \n _instanceNumber: number\n _isThreadClosed = NO\n \n private readonly _webWorkerHolder = UIKeyValueStringFilter._sharedWebWorkerHolder\n \n constructor(useSeparateWebWorkerHolder = NO) {\n \n super()\n \n if (useSeparateWebWorkerHolder) {\n this._webWorkerHolder = {\n webWorker: new UIKeyValueStringFilterWebWorker(),\n UICore_isWorking: false,\n UICore_messagesToPost: undefined,\n UICore_completionFunctions: {}\n }\n }\n \n UIKeyValueStringFilter._instanceNumber = UIKeyValueStringFilter._instanceNumber + 1\n this._instanceNumber = UIKeyValueStringFilter._instanceNumber\n \n if (IS_NOT(this._webWorkerHolder.webWorker.onmessage)) {\n \n this._webWorkerHolder.webWorker.onmessage = (message: { data: { identifier: string; instanceIdentifier: string; filteredData: any[]; filteredIndexes: number[] } }) => {\n \n this.isWorkerBusy = NO\n this.postNextMessageIfNeeded()\n \n const key = \"\" + message.data.identifier + message.data.instanceIdentifier\n \n const completionFunction = this.completionFunctions[key]\n \n if (IS(completionFunction)) {\n \n //console.log(\"Filtering took \" + (Date.now() - startTime) + \" ms\");\n \n completionFunction(message.data.filteredData, message.data.filteredIndexes, message.data.identifier)\n \n }\n \n delete this.completionFunctions[key]\n \n var asd = 1\n \n }\n \n }\n \n \n }\n \n \n get instanceIdentifier() {\n \n return this._instanceNumber\n \n }\n \n \n get completionFunctions() {\n \n const key = \"UICore_completionFunctions\"\n let result: {\n \n [x: string]: (filteredData: any[], filteredIndexes: number[], identifier: any) => void;\n \n } = this._webWorkerHolder[key]\n \n if (IS_NOT(result)) {\n \n result = {}\n this._webWorkerHolder[key] = result\n \n }\n \n return result\n \n }\n \n get messagesToPost() {\n \n const key = \"UICore_messagesToPost\"\n var result: any[] = this._webWorkerHolder[key]\n \n if (IS_NOT(result)) {\n \n result = []\n this._webWorkerHolder[key] = result\n \n }\n \n return result\n \n }\n \n \n set isWorkerBusy(isWorkerBusy: boolean) {\n \n this._webWorkerHolder[\"UICore_isWorking\"] = isWorkerBusy\n \n }\n \n get isWorkerBusy() {\n \n return IS(this._webWorkerHolder[\"UICore_isWorking\"])\n \n }\n \n \n postNextMessageIfNeeded() {\n \n if (this.messagesToPost.length && IS_NOT(this.isWorkerBusy)) {\n \n this._webWorkerHolder.webWorker.postMessage(this.messagesToPost.firstElement)\n this.messagesToPost.removeElementAtIndex(0)\n \n this.isWorkerBusy = YES\n \n }\n \n }\n \n \n filterData<T extends object>(\n filteringString: string,\n data: T[],\n excludedData: string[],\n dataKeyPath: string,\n identifier: any,\n completion: (filteredData: T[], filteredIndexes: number[], identifier: any) => void\n ) {\n \n \n if (this._isThreadClosed) {\n \n return\n \n }\n \n if (!data?.length) {\n completion([], [], identifier)\n return\n }\n \n \n const instanceIdentifier = this.instanceIdentifier\n \n const key = \"\" + identifier + instanceIdentifier\n \n this.completionFunctions[key] = completion\n \n \n try {\n \n this.messagesToPost.push({\n \n \"filteringString\": filteringString,\n \"data\": data,\n \"excludedData\": excludedData,\n \"dataKeyPath\": dataKeyPath,\n \"identifier\": identifier,\n \"instanceIdentifier\": instanceIdentifier\n \n })\n \n this.postNextMessageIfNeeded()\n \n } catch (exception) {\n \n completion([], [], identifier)\n \n }\n \n \n }\n \n \n closeThread() {\n \n this._isThreadClosed = YES\n \n if (this._webWorkerHolder != UIKeyValueStringFilter._sharedWebWorkerHolder) {\n \n this._webWorkerHolder.webWorker.terminate()\n \n }\n \n \n }\n \n \n}\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n"],
|
|
5
|
+
"mappings": ";;;;;;;;;;;;;;;;;;;;;;;;AAAA;AAAA;AAAA;AAAA;AAAA;AACA,oDAA4C;AAC5C,sBAA8C;AAGvC,MAAM,0BAAN,cAAqC,yBAAS;AAAA,EAwBjD,YAAY,6BAA6B,oBAAI;AAEzC,UAAM;AANV,2BAAkB;AAElB,SAAiB,mBAAmB,wBAAuB;AAMvD,QAAI,4BAA4B;AAC5B,WAAK,mBAAmB;AAAA,QACpB,WAAW,IAAI,8CAAAA,QAAgC;AAAA,QAC/C,kBAAkB;AAAA,QAClB,uBAAuB;AAAA,QACvB,4BAA4B,CAAC;AAAA,MACjC;AAAA,IACJ;AAEA,4BAAuB,kBAAkB,wBAAuB,kBAAkB;AAClF,SAAK,kBAAkB,wBAAuB;AAE9C,YAAI,wBAAO,KAAK,iBAAiB,UAAU,SAAS,GAAG;AAEnD,WAAK,iBAAiB,UAAU,YAAY,CAAC,YAA0H;AAEnK,aAAK,eAAe;AACpB,aAAK,wBAAwB;AAE7B,cAAM,MAAM,KAAK,QAAQ,KAAK,aAAa,QAAQ,KAAK;AAExD,cAAM,qBAAqB,KAAK,oBAAoB;AAEpD,gBAAI,oBAAG,kBAAkB,GAAG;AAIxB,6BAAmB,QAAQ,KAAK,cAAc,QAAQ,KAAK,iBAAiB,QAAQ,KAAK,UAAU;AAAA,QAEvG;AAEA,eAAO,KAAK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,gBAAgB;AAAA,QAChB,eAAe;AAAA,QACf,cAAc;AAAA,QACd,sBAAsB;AAAA,MAE1B,CAAC;AAED,WAAK,wBAAwB;AAAA,IAEjC,SAAS,WAAP;AAEE,iBAAW,CAAC,GAAG,CAAC,GAAG,UAAU;AAAA,IAEjC;AAAA,EAGJ;AAAA,EAGA,cAAc;AAEV,SAAK,kBAAkB;AAEvB,QAAI,KAAK,oBAAoB,wBAAuB,wBAAwB;AAExE,WAAK,iBAAiB,UAAU,UAAU;AAAA,IAE9C;AAAA,EAGJ;AAGJ;AAlNO,IAAM,yBAAN;AAAM,uBAEF,yBASH;AAAA,EACA,WAAW,IAAI,8CAAAA,QAAgC;AAAA,EAC/C,kBAAkB;AAAA,EAClB,uBAAuB;AAAA,EACvB,4BAA4B,CAAC;AACjC;AAhBS,uBAiBF,kBAAkB;",
|
|
6
6
|
"names": ["UIKeyValueStringFilterWebWorker"]
|
|
7
7
|
}
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "uicore-ts",
|
|
3
|
-
"version": "1.1.
|
|
3
|
+
"version": "1.1.10",
|
|
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",
|
|
@@ -190,8 +190,12 @@ export class UIKeyValueSorter extends UIObject {
|
|
|
190
190
|
return
|
|
191
191
|
|
|
192
192
|
}
|
|
193
|
-
|
|
194
|
-
|
|
193
|
+
|
|
194
|
+
if (!data?.length) {
|
|
195
|
+
completion([], [], identifier)
|
|
196
|
+
return
|
|
197
|
+
}
|
|
198
|
+
|
|
195
199
|
const instanceIdentifier = this.instanceIdentifier
|
|
196
200
|
|
|
197
201
|
const key = "" + identifier + instanceIdentifier
|