{"version":3,"sources":["iterable-handler.ts"],"sourcesContent":["import { Datex } from \"../mod.ts\";\nimport { ValueError } from \"../datex_all.ts\";\nimport { weakAction } from \"./weak-action.ts\";\n\n\nexport class IterableHandler<T, U = T> {\n\tprivate map: ((value: T, index: number, array: Iterable<T>) => U) | undefined\n\tprivate filter: ((value: T, index: number, array: Iterable<T>) => value is T&U) | undefined\n\n\tprivate onNewEntry: (entry:U, key:number,) => void\n\tprivate onEntryRemoved: (entry:U, key:number,) => void\n\tprivate onEmpty?: () => void\n\tprivate onSplice?: (start: number, deleteCount: number, ...items: U[]) => void\n\n\t\n\tconstructor(private iterable: Datex.RefOrValue<Iterable<T>>, callbacks: {\n\t\tmap?: (value: T, index: number, array: Iterable<T>) => U,\n\t\t// TODO:\n\t\tfilter?: (value: T, index: number, array: Iterable<T>) => value is T&U,\n\t\tonNewEntry: (this: IterableHandler<T, U>, entry:U, key:number) => void\n\t\tonEntryRemoved: (entry: U, key:number) => void,\n\t\tonEmpty?: () => void,\n\t\tonSplice?: (start: number, deleteCount: number, ...items: U[]) => void\n\t}) {\n\t\tthis.map = callbacks.map;\n\t\tthis.filter = callbacks.filter;\n\t\tthis.onNewEntry = callbacks.onNewEntry;\n\t\tthis.onEntryRemoved = callbacks.onEntryRemoved;\n\t\tthis.onEmpty = callbacks.onEmpty;\n\t\tthis.onSplice = callbacks.onSplice;\n\n\t\tthis.checkEmpty();\n\t\tthis.observe()\n\t}\n\n\tobserve() {\n\t\tconst callback = (v:any, k:any, t:any) => {\n\t\t\tthis.onValueChanged(v, k, t)\n\t\t}\n\t\tDatex.ReactiveValue.observeAndInit(this.iterable, callback);\n\t}\n\n\t[Symbol.dispose]() {\n\t\t// TODO: unobserve\n\t}\n\n\t/**\n\t * maps all keys of the iterable to the keys of the filtered iterable\n\t * (only relevant if a filter is set)\n\t */\n\t#filterKeyMap = new Map<number, number>();\n\tprivate setEntryWithMappedFilterKey(key: number, entry: U) {\n\t\tconst originalKey = key;\n\t\tlet mappedKey = -1;\n\t\t// append at the end if last item\n\t\tconst maxFilterMapKey = [...this.#filterKeyMap.keys()].reduce((a, b) => Math.max(a, b), 0);\n\t\tif (key >= maxFilterMapKey) {\n\t\t\tmappedKey = this.#filterKeyMap.size;\n\t\t\tthis.#filterKeyMap.set(originalKey, mappedKey);\n\t\t}\n\t\t// get mapped key\n\t\telse if (this.#filterKeyMap.has(key)) {\n\t\t\tmappedKey = this.#filterKeyMap.get(key)!;\n\t\t}\n\t\t// insert key at position\n\t\telse {\n\t\t\t// shift entries to the right to make space for new entry at key\n\t\t\tconst mappedKey = this.findFilterMapKey(key);\n\t\t\tthis.shiftEntriesForNewEntry(mappedKey, entry);\n\t\t\t// shift all following keys to the right in filterKeyMap\n\t\t\tfor (const [k, v] of this.#filterKeyMap) {\n\t\t\t\tif (v >= mappedKey) {\n\t\t\t\t\tthis.#filterKeyMap.set(k, v + 1);\n\t\t\t\t}\n\t\t\t}\n\t\t\tthis.#filterKeyMap.set(originalKey, mappedKey);\n\t\t\treturn -1;\n\t\t}\n\t\treturn mappedKey;\n\t}\n\n\t/**\n\t * Removes a key from the filterKeyMap\n\t * and shifts all following keys to the left\n\t * @param key \n\t */\n\tprivate deleteFilterKey(key: number) {\n\t\t// remove key from filterKeyMap\n\t\tconst mappedKey = this.#filterKeyMap.get(key) ?? Infinity; \n\n\t\tthis.#filterKeyMap.delete(key);\n\n\t\t// shift all following keys to the left in filterKeyMap\n\t\tfor (const [k, v] of this.#filterKeyMap) {\n\t\t\tif (v > mappedKey) {\n\t\t\t\tthis.#filterKeyMap.set(k, v - 1);\n\t\t\t\tconst entryKey = v-1;\n\t\t\t\tconst entry = this.entries.get(entryKey+1)!;\n\t\t\t\tthis.entries.set(entryKey, entry);\n\t\t\t\tthis.onNewEntry.call ? \n\t\t\t\t\tthis.onNewEntry.call(this, entry, entryKey) :\n\t\t\t\t\tthis.onNewEntry(entry, entryKey); // new entry handler\n\t\t\t}\n\t\t}\n\n\t\t// remove last key if not out of bounds\n\t\tif (mappedKey < this.entries.size) this.handleRemoveEntry(this.entries.size-1);\t\t\n\t}\n\n\n\t#entries?: Map<number, U>;\n\tpublic get entries() {\n\t\tif (!this.#entries)\n\t\t\tthis.#entries = new Map<number, U>();\n\t\treturn this.#entries;\n\t}\n\n\tprivate isPseudoIndex(){\n\t\treturn !(this.iterable instanceof Array)\n\t}\n\n\t// for map etc. shift entries to fill from start\n\t//    1=>x 3=>y 4=>z\n\t// to 1=>x 2=>y 3=>z\n\tprivate shiftEntries(key:number){\n\t\tconst max = [...this.entries.keys()].at(-1) || 0;\n\t\tif (key > max) return;\n\t\tfor (let k = key; k<max; k++) {\n\t\t\tthis.entries.set(k, this.entries.get(k+1)!)\n\t\t}\n\t\tthis.entries.delete(max);\n\t}\n\n\t// find the filter map key of an item that is not in #filterKeyMap\n\tprivate findFilterMapKey(key: number) {\n\t\t// check all nearby filter map keys\n\t\t// TODO: make this more performant\n\t\tlet nextUpperKey = Infinity;\n\t\tlet nextUpperIndex = 0;\n\t\tfor (const [k, v] of this.#filterKeyMap) {\n\t\t\tif (k > key && k < nextUpperKey) {\n\t\t\t\tnextUpperKey = k;\n\t\t\t\tnextUpperIndex = v;\n\t\t\t}\n\t\t}\n\t\treturn nextUpperIndex;\n\t}\n\n\t// shift entries to the right make space for new entry at key\n\tprivate shiftEntriesForNewEntry(key:number, entry: U){\n\t\tfor (let k = this.entries.size-1; k>=key; k--) {\n\t\t\tthis.entries.set(k+1, this.entries.get(k)!)\n\t\t}\n\t\tthis.entries.set(key, entry);\n\t\tif (!this.onSplice) throw new Error(\"onSplice is required when using filters with IterableHandler\")\n\t\tthis.onSplice?.(key, 0, entry);\n\t}\n\n\tprivate deleteEntry(key:number) {\n\t\tif (this.isPseudoIndex()) this.shiftEntries(key); // for map etc. shift entries to fill from start\n\t\telse this.entries.delete(key)\n\t}\n\n\t// pseudo keys for Sets, Maps and Objects which have no index\n\tprivate getPseudoIndex(key: unknown, value:T): number {\n\t\tif (this.iterable instanceof Set) return this.findIndex(this.iterable, value)\n\t\tif (this.iterable instanceof Map) return this.findIndex(this.iterable.keys(), key);\n\t\tif (this.iterable instanceof Object) return this.findIndex(Object.keys(this.iterable), key);\n\t\treturn -1;\n\t}\n\n\tprivate findIndex<T>(iterable: Iterable<T>, value: T) {\n\t\tlet i = 0;\n\t\tfor (const entry of iterable) {\n\t\t\tif (entry === value) return i;\n\t\t\ti++;\n\t\t}\n\t\treturn -1;\n\t}\n\n\t// pseudo keys for Sets which have no index\n\tprotected iterator(iterable:Set<any>|Map<any,any>|Object|Array<any>) {\n\t\tif (iterable instanceof Set) return iterable;\n\t\tif (iterable instanceof Array) return iterable;\n\t\tif (iterable instanceof Map) return iterable.entries();\n\t\tif (iterable instanceof Object) return Object.values(iterable);\n\t}\n\n\tprotected onValueChanged(value: Iterable<T>|T, key: number|undefined, type:Datex.ReactiveValue.UPDATE_TYPE) {\n\t\tif (type == Datex.ReactiveValue.UPDATE_TYPE.DELETE) return; // ignore DELETE event, only use BEFORE_DELETE event\n\t\tif (type == Datex.ReactiveValue.UPDATE_TYPE.REMOVE) return; // ignore REMOVE event, only use BEFORE_REMOVE event\n\n\t\t// compatibility with key-value iterables\n\t\t// Map or Object\n\t\tif (type != Datex.ReactiveValue.UPDATE_TYPE.INIT && type != Datex.ReactiveValue.UPDATE_TYPE.CLEAR && (this.iterable instanceof Map || !(this.iterable instanceof Set || this.iterable instanceof Array))) {\n\t\t\tconst original_value = value;\n\t\t\t// TODO: required?\n\t\t\tif (this.iterable instanceof Map) value = <Iterable<T>>[key, value]\n\t\t\tkey = this.getPseudoIndex(key, <T>original_value)\n\t\t\tif (key == -1) {\n\t\t\t\tconsole.log(original_value,value,key,type)\n\t\t\t\tthrow new ValueError(\"IterableValue: value not found in iterable\")\n\t\t\t}\n\t\t}\n\n\t\t// single property update\n\t\tif (type == Datex.ReactiveValue.UPDATE_TYPE.SET)\n\t\t\tthis.handleNewEntry(<T>value, key)\n\t\telse if (type == Datex.ReactiveValue.UPDATE_TYPE.ADD)\n\t\t\tthis.handleNewEntry(<T>value, this.getPseudoIndex(key, <T>value));\n\t\t// clear all\n\t\telse if (type == Datex.ReactiveValue.UPDATE_TYPE.CLEAR) {\n\t\t\t// handle onEmpty\n\t\t\tif (this.onEmpty) {\n\t\t\t\t// clear filterKeyMap\n\t\t\t\tthis.#filterKeyMap.clear();\n\t\t\t\t// clear entries\n\t\t\t\tthis.#entries?.clear();\n\t\t\t\tthis.onEmpty.call ?\n\t\t\t\t\tthis.onEmpty.call(this) :\n\t\t\t\t\tthis.onEmpty();\n\t\t\t}\n\t\t\t// alternative: delete all entries individually\n\t\t\telse {\n\t\t\t\tfor (const [key,] of [...this.#entries??[]].toReversed()) {\n\t\t\t\t\tthis.handleRemoveEntry(key);\n\t\t\t\t}\n\t\t\t}\n\t\t}\n\t\telse if (type == Datex.ReactiveValue.UPDATE_TYPE.BEFORE_DELETE)\n\t\t\tthis.handleRemoveEntry(key);\n\t\telse if (type == Datex.ReactiveValue.UPDATE_TYPE.BEFORE_REMOVE)\n\t\t\tthis.handleRemoveEntry(this.getPseudoIndex(key, <T>value));\n\t\t// completely new value\n\t\telse if (type == Datex.ReactiveValue.UPDATE_TYPE.INIT) {\n\t\t\tfor (const e of this.entries.keys())\n\t\t\t\tthis.handleRemoveEntry(e); // clear all entries\n\n\t\t\tconst it = <Iterable<T>>this.iterator(value??[]);\n\t\t\tconst initValue: T[] = [];\n\n\t\t\tfor (const child of it) {\n\t\t\t\tinitValue.push(child);\n\t\t\t}\n\n\t\t\tlet key = 0;\n\t\t\tfor (const child of initValue)\n\t\t\t\tthis.handleNewEntry(child, key++);\n\t\t}\n\t}\n\n\t// can be overriden\n\tprotected valueToEntry(value:T, key?: number):U {\n\t\tkey = Number(key);\n\t\treturn this.map ? \n\t\t\tthis.map(value, key??0, val(this.iterable)) :\n\t\t\tvalue as unknown as U;\n\t}\n\n\t// call valueToEntry and save entry in this.#entries\n\thandleNewEntry(value:T, key:number, filterResult?:boolean) {\n\t\tkey = Number(key);\n\t\tconst entry = this.valueToEntry(value, key)\n\n\t\tif (this.filter || filterResult != undefined) {\n\t\t\tconst filteredOut = ! (\n\t\t\t\tfilterResult != undefined ? filterResult : this.filter!(value, key, val(this.iterable))\n\t\t\t);\n\t\t\t// is filtered out\n\t\t\tif (filteredOut) {\n\t\t\t\tthis.deleteFilterKey(key);\n\t\t\t\treturn;\n\t\t\t}\n\n\t\t\t// get mapped filter key\n\t\t\telse {\n\t\t\t\tkey = this.setEntryWithMappedFilterKey(key, value);\n\t\t\t\t// update already handled, continue\n\t\t\t\tif (key == -1) return;\n\t\t\t}\n\t\t}\n\n\t\tif (key != undefined) {\n\t\t\t// // TODO: is this correct\n\t\t\t// if (!this.isPseudoIndex() && this.entries.has(key))\n\t\t\t// \tthis.handleRemoveEntry(key) // entry is overridden\n\t\t\tthis.entries.set(key, entry);\n\t\t}\n\t\tthis.onNewEntry.call ? \n\t\t\tthis.onNewEntry.call(this, entry, Number(key)) :\n\t\t\tthis.onNewEntry(entry, Number(key)); // new entry handler\n\t\tthis.checkEmpty();\n\t}\n\n\tprivate handleRemoveEntry(key:number) {\n\t\tkey = Number(key)\n\t\tconst entry = this.entries.get(key)!;\n\t\tthis.deleteEntry(key);\n\t\tthis.onEntryRemoved.call ? \n\t\t\tthis.onEntryRemoved.call(this, entry, key) :\n\t\t\tthis.onEntryRemoved(entry, key);\n\t\tthis.checkEmpty();\n\t}\n\n\tprivate checkEmpty() {\n\t\tif (this.onEmpty && this.#entries?.size == 0) {\n\t\t\t// clear filterKeyMap\n\t\t\tthis.#filterKeyMap.clear();\n\t\t\tthis.onEmpty.call ? \n\t\t\t\tthis.onEmpty.call(this) :\n\t\t\t\tthis.onEmpty();\n\t\t}\n\t\t\t\n\t}\n\n}"],"names":["Datex","ValueError","Symbol","dispose","IterableHandler","map","filter","onNewEntry","onEntryRemoved","onEmpty","onSplice","constructor","iterable","callbacks","Map","checkEmpty","observe","ReactiveValue","observeAndInit","v","k","t","onValueChanged","setEntryWithMappedFilterKey","key","entry","mappedKey","keys","reduce","a","b","Math","max","size","set","has","get","findFilterMapKey","shiftEntriesForNewEntry","deleteFilterKey","Infinity","delete","entryKey","entries","call","handleRemoveEntry","isPseudoIndex","Array","shiftEntries","at","nextUpperKey","nextUpperIndex","Error","deleteEntry","getPseudoIndex","value","Set","findIndex","Object","i","iterator","values","type","UPDATE_TYPE","DELETE","REMOVE","INIT","CLEAR","original_value","console","log","SET","handleNewEntry","ADD","clear","toReversed","BEFORE_DELETE","BEFORE_REMOVE","e","it","initValue","child","push","valueToEntry","Number","val","filterResult","undefined"],"mappings":";AAAA,SAASA,KAAK,QAAQ,YAAY;AAClC,SAASC,UAAU,QAAQ,kBAAkB;eAyC3CC,OAAOC,OAAO;AArChB,OAAO,MAAMC;;IACJC,IAAqE;IACrEC,OAAmF;IAEnFC,WAA0C;IAC1CC,eAA8C;IAC9CC,QAAoB;IACpBC,SAAsE;IAG9EC,YAAY,AAAQC,QAAuC,EAAEC,SAQ5D,CAAE;aARiBD,WAAAA,eAmCpB,CAAA,YAAa,GAAG,IAAIE,OA1BnB,IAAI,CAACT,GAAG,GAAGQ,UAAUR,GAAG,EACxB,IAAI,CAACC,MAAM,GAAGO,UAAUP,MAAM,EAC9B,IAAI,CAACC,UAAU,GAAGM,UAAUN,UAAU,EACtC,IAAI,CAACC,cAAc,GAAGK,UAAUL,cAAc,EAC9C,IAAI,CAACC,OAAO,GAAGI,UAAUJ,OAAO,EAChC,IAAI,CAACC,QAAQ,GAAGG,UAAUH,QAAQ,EAElC,IAAI,CAACK,UAAU,IACf,IAAI,CAACC,OAAO;IACb;IAEAA,UAAU;QAIThB,MAAMiB,aAAa,CAACC,cAAc,CAAC,IAAI,CAACN,QAAQ,EAH/B,CAACO,GAAOC,GAAOC;YAC/B,IAAI,CAACC,cAAc,CAACH,GAAGC,GAAGC;QAC3B;IAED;IAEA,iBAAmB,CAEnB;IAMA,CAAA,YAAa,CAA6B;IAClCE,4BAA4BC,GAAW,EAAE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