UNPKG

uicore-ts

Version:

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 tha

136 lines (135 loc) 5.32 kB
"use strict"; var __create = Object.create; var __defProp = Object.defineProperty; var __getOwnPropDesc = Object.getOwnPropertyDescriptor; var __getOwnPropNames = Object.getOwnPropertyNames; var __getProtoOf = Object.getPrototypeOf; var __hasOwnProp = Object.prototype.hasOwnProperty; var __export = (target, all) => { for (var name in all) __defProp(target, name, { get: all[name], enumerable: true }); }; var __copyProps = (to, from, except, desc) => { if (from && typeof from === "object" || typeof from === "function") { for (let key of __getOwnPropNames(from)) if (!__hasOwnProp.call(to, key) && key !== except) __defProp(to, key, { get: () => from[key], enumerable: !(desc = __getOwnPropDesc(from, key)) || desc.enumerable }); } return to; }; var __toESM = (mod, isNodeMode, target) => (target = mod != null ? __create(__getProtoOf(mod)) : {}, __copyProps( isNodeMode || !mod || !mod.__esModule ? __defProp(target, "default", { value: mod, enumerable: true }) : target, mod )); var __toCommonJS = (mod) => __copyProps(__defProp({}, "__esModule", { value: true }), mod); var UIKeyValueStringFilter_exports = {}; __export(UIKeyValueStringFilter_exports, { UIKeyValueStringFilter: () => UIKeyValueStringFilter }); module.exports = __toCommonJS(UIKeyValueStringFilter_exports); var import_UIKeyValueStringFilterWebWorker_worker = __toESM(require("./UIKeyValueStringFilterWebWorker.worker.js")); var import_UIObject = require("./UIObject"); const _UIKeyValueStringFilter = class extends import_UIObject.UIObject { constructor(useSeparateWebWorkerHolder = import_UIObject.NO) { super(); this._isThreadClosed = import_UIObject.NO; this._webWorkerHolder = _UIKeyValueStringFilter._sharedWebWorkerHolder; if (useSeparateWebWorkerHolder) { this._webWorkerHolder = { webWorker: new import_UIKeyValueStringFilterWebWorker_worker.default(), UICore_isWorking: false, UICore_messagesToPost: void 0, UICore_completionFunctions: {} }; } _UIKeyValueStringFilter._instanceNumber = _UIKeyValueStringFilter._instanceNumber + 1; this._instanceNumber = _UIKeyValueStringFilter._instanceNumber; if ((0, import_UIObject.IS_NOT)(this._webWorkerHolder.webWorker.onmessage)) { this._webWorkerHolder.webWorker.onmessage = (message) => { this.isWorkerBusy = import_UIObject.NO; this.postNextMessageIfNeeded(); const key = "" + message.data.identifier + message.data.instanceIdentifier; const completionFunction = this.completionFunctions[key]; if ((0, import_UIObject.IS)(completionFunction)) { completionFunction(message.data.filteredData, message.data.filteredIndexes, message.data.identifier); } delete this.completionFunctions[key]; var asd = 1; }; } } get instanceIdentifier() { return this._instanceNumber; } get completionFunctions() { const key = "UICore_completionFunctions"; let result = this._webWorkerHolder[key]; if ((0, import_UIObject.IS_NOT)(result)) { result = {}; this._webWorkerHolder[key] = result; } return result; } get messagesToPost() { const key = "UICore_messagesToPost"; var result = this._webWorkerHolder[key]; if ((0, import_UIObject.IS_NOT)(result)) { result = []; this._webWorkerHolder[key] = result; } return result; } set isWorkerBusy(isWorkerBusy) { this._webWorkerHolder["UICore_isWorking"] = isWorkerBusy; } get isWorkerBusy() { return (0, import_UIObject.IS)(this._webWorkerHolder["UICore_isWorking"]); } postNextMessageIfNeeded() { if (this.messagesToPost.length && (0, import_UIObject.IS_NOT)(this.isWorkerBusy)) { this._webWorkerHolder.webWorker.postMessage(this.messagesToPost.firstElement); this.messagesToPost.removeElementAtIndex(0); this.isWorkerBusy = import_UIObject.YES; } } filterData(filteringString, data, excludedData, dataKeyPath, identifier, completion) { if (this._isThreadClosed) { return; } const instanceIdentifier = this.instanceIdentifier; const key = "" + identifier + instanceIdentifier; this.completionFunctions[key] = completion; try { this.messagesToPost.push({ "filteringString": filteringString, "data": data, "excludedData": excludedData, "dataKeyPath": dataKeyPath, "identifier": identifier, "instanceIdentifier": instanceIdentifier }); this.postNextMessageIfNeeded(); } catch (exception) { completion([], [], identifier); } } closeThread() { this._isThreadClosed = import_UIObject.YES; if (this._webWorkerHolder != _UIKeyValueStringFilter._sharedWebWorkerHolder) { this._webWorkerHolder.webWorker.terminate(); } } }; let UIKeyValueStringFilter = _UIKeyValueStringFilter; UIKeyValueStringFilter._sharedWebWorkerHolder = { webWorker: new import_UIKeyValueStringFilterWebWorker_worker.default(), UICore_isWorking: false, UICore_messagesToPost: void 0, UICore_completionFunctions: {} }; UIKeyValueStringFilter._instanceNumber = -1; // Annotate the CommonJS export names for ESM import in node: 0 && (module.exports = { UIKeyValueStringFilter }); //# sourceMappingURL=UIKeyValueStringFilter.js.map