uicore-ts 1.0.527 → 1.0.528
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.
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
import { UIObject } from "./UIObject";
|
|
2
|
-
export interface
|
|
2
|
+
export interface UIKeyValueSorterSortingInstruction {
|
|
3
3
|
keyPath: string;
|
|
4
4
|
dataType: string;
|
|
5
5
|
direction: string;
|
|
@@ -32,8 +32,8 @@ export declare class UIKeyValueSorter extends UIObject {
|
|
|
32
32
|
descending: string;
|
|
33
33
|
ascending: string;
|
|
34
34
|
};
|
|
35
|
-
sortData<T>(data: T[], sortingInstructions:
|
|
36
|
-
sortedData<T>(data: T[], sortingInstructions:
|
|
35
|
+
sortData<T>(data: T[], sortingInstructions: UIKeyValueSorterSortingInstruction[], identifier: any, completion: (sortedData: T[], sortedIndexes: number[], identifier: any) => void): void;
|
|
36
|
+
sortedData<T>(data: T[], sortingInstructions: UIKeyValueSorterSortingInstruction[], identifier?: any): Promise<{
|
|
37
37
|
sortedData: T[];
|
|
38
38
|
sortedIndexes: number[];
|
|
39
39
|
identifier: any;
|
|
@@ -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
|
|
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 \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
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,KAAK,YAAY,QAAQ,KAAK,eAAe,QAAQ,KAAK,UAAU;AAAA,QAEnG;AAEA,eAAO,KAAK,oBAAoB;AAEhC,YAAI,MAAM;AAAA,MAEd;AAAA,IAEJ;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J;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;AApQO,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
|
}
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "uicore-ts",
|
|
3
|
-
"version": "1.0.
|
|
3
|
+
"version": "1.0.528",
|
|
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",
|
|
@@ -3,7 +3,7 @@ import UIKeyValueSorterWebWorker from "./UIKeyValueSorterWebWorker.worker"
|
|
|
3
3
|
import { IS, IS_NOT, MAKE_ID, NO, UIObject, YES } from "./UIObject"
|
|
4
4
|
|
|
5
5
|
|
|
6
|
-
export interface
|
|
6
|
+
export interface UIKeyValueSorterSortingInstruction {
|
|
7
7
|
|
|
8
8
|
keyPath: string;
|
|
9
9
|
|
|
@@ -179,7 +179,7 @@ export class UIKeyValueSorter extends UIObject {
|
|
|
179
179
|
|
|
180
180
|
sortData<T>(
|
|
181
181
|
data: T[],
|
|
182
|
-
sortingInstructions:
|
|
182
|
+
sortingInstructions: UIKeyValueSorterSortingInstruction[],
|
|
183
183
|
identifier: any,
|
|
184
184
|
completion: (sortedData: T[], sortedIndexes: number[], identifier: any) => void
|
|
185
185
|
) {
|
|
@@ -224,7 +224,7 @@ export class UIKeyValueSorter extends UIObject {
|
|
|
224
224
|
|
|
225
225
|
sortedData<T>(
|
|
226
226
|
data: T[],
|
|
227
|
-
sortingInstructions:
|
|
227
|
+
sortingInstructions: UIKeyValueSorterSortingInstruction[],
|
|
228
228
|
identifier: any = MAKE_ID()
|
|
229
229
|
) {
|
|
230
230
|
|