{"version":3,"sources":["storage-map.ts"],"sourcesContent":["// deno-lint-ignore-file no-this-alias\n\nimport { Compiler } from \"../compiler/compiler.ts\";\nimport { VOID } from \"../runtime/constants.ts\";\nimport { Pointer, ReactiveValue } from \"../runtime/pointers.ts\";\nimport { MatchOptions, Storage } from \"../storage/storage.ts\";\nimport { Class } from \"../utils/global_types.ts\";\nimport { MatchInput, MatchResult, match } from \"../utils/match.ts\";\nimport { Type } from \"./type.ts\";\n\n\n/**\n * WeakMap that outsources values to storage.\n * The API is similar to the JS WeakMap API, but all methods are async.\n * In contrast to JS WeakMaps, primitive keys are also allowed.\n * The StorageWeakMap holds no strong references to its keys in storage.\n * This means that the pointer of a key can be garbage collected.\n */\nexport class StorageWeakMap<K,V> {\n\n\t/**\n\t * Create a new StorageWeakMap instance with the given key and value types.\n\t * @param keyType Class or DATEX Type of the keys\n\t * @param valueType\tClass or DATEX Type of the values\n\t * @returns \n\t */\n\tstatic of<K,V>(keyType:Class<K>|Type<K>|undefined|null, valueType: Class<V>|Type<V>): StorageWeakMap<K,V> {\n\t\tconst storageMap = new this<K,V>();\n\t\tstorageMap.#_type = valueType instanceof Type ? valueType : Type.getClassDatexType(valueType);\n\t\tstorageMap._type = storageMap.#_type.namespace + \":\" + storageMap.#_type.name;\n\t\treturn storageMap;\n\t}\n\n\t_type?: string\n\t#_type?: Type<V>;\n\n\tprotected get type() {\n\t\tif (!this._type) return undefined;\n\t\tif (!this.#_type) this.#_type = Type.get(this._type);\n\t\treturn this.#_type;\n\t}\n\n\t#prefix?: string;\n\n\t/**\n\t * Time in milliseconds after which a value is removed from the in-memory cache\n\t * Default: 5min\n\t */\n\tcacheTimeout = 5 * 60 * 1000;\n\n\t/**\n\t * If true, non-pointer objects are allowed as \n\t * values in the map (default)\n\t * Otherwise, object values are automatically proxified\n\t * when added to the map.\n\t */\n\tallowNonPointerObjectValues = false;\n\n\t// StorageWeakMaps are not bound to a pointer per default, but a pointer is automatically created if needed\n\t#_pointer?: Pointer;\n\tget #pointer() {\n\t\tif (!this.#_pointer) this.#_pointer = Pointer.getByValue(this);\n\t\tif (!this.#_pointer) {\n\t\t\tPointer.proxifyValue(this);\n\t\t\tthis.#_pointer = Pointer.getByValue(this)!;\n\t\t}\n\t\treturn this.#_pointer;\n\t}\n\n\tstatic async from<K,V>(entries: readonly (readonly [K, V])[]){\n\t\tconst map = $$(new StorageWeakMap<K,V>());\n\t\tfor (const [key, value] of entries) await map.set(key, value);\n\t\treturn map;\n\t}\n\n\tprotected get _prefix() {\n\t\tif (!this.#prefix) this.#prefix = 'dxmap::'+this.#pointer.idString()+'.';\n\t\treturn this.#prefix;\n\t}\n\n\tasync get(key: K): Promise<V|undefined> {\n\t\tconst storage_key = await this.getStorageKey(key);\n\t\treturn this._get(storage_key);\n\t}\n\n\tprotected _get(storage_key:string) {\n\t\tthis.handleBeforeNonReferencableGet();\n\t\tthis.activateCacheTimeout(storage_key);\n\t\treturn Storage.getItem(storage_key);\n\t}\n\n\tasync has(key: K): Promise<boolean> {\n\t\tconst storage_key = await this.getStorageKey(key);\n\t\treturn this._has(storage_key);\n\t}\n\tprotected _has(storage_key:string) {\n\t\tthis.handleBeforeNonReferencableGet();\n\t\treturn Storage.hasItem(storage_key)\n\t}\n\n\tasync delete(key: K) {\n\t\tconst storage_key = await this.getStorageKey(key);\n\t\treturn this._delete(storage_key, key);\n\t}\n\tprotected async _delete(storage_key:string, key: K) {\n\t\tconst res = await Storage.removeItem(storage_key)\n\t\tthis.#pointer.callObservers(VOID, key, ReactiveValue.UPDATE_TYPE.DELETE);\n\t\treturn res;\n\t}\n\n\tasync set(key: K, value:V) {\n\t\tconst storage_key = await this.getStorageKey(key);\n\t\treturn this._set(storage_key, key, value);\n\t}\n\tprotected async _set(storage_key:string, key:K, value:V) {\n\t\t// proxify value\n\t\tif (!this.allowNonPointerObjectValues) {\n\t\t\tvalue = this.#pointer.proxifyChild(\"\", value);\n\t\t}\n\t\tthis.activateCacheTimeout(storage_key);\n\t\tawait Storage.setItem(storage_key, value);\n\t\tthis.#pointer.callObservers(value, key, ReactiveValue.UPDATE_TYPE.SET, false, false)\n\t\treturn this;\n\t}\n\n\tprotected activateCacheTimeout(storage_key:string){\n\t\tsetTimeout(()=>{\n\t\t\tStorage.cache.delete(storage_key)\n\t\t}, this.cacheTimeout);\n\t}\n\n\tprotected async getStorageKey(key: K) {\n\t\tconst keyHash = await Compiler.getUniqueValueIdentifier(key);\n\t\t// @ts-ignore DX_PTR\n\t\treturn this._prefix + keyHash;\n\t}\n\n\tasync clear() {\n\t\tconst promises = [];\n\t\tfor (const key of await Storage.getItemKeysStartingWith(this._prefix)) {\n\t\t\tpromises.push(Storage.removeItem(key));\n\t\t}\n\t\tawait Promise.all(promises);\n\t\tthis.handleClear();\n\t}\n\n\tprotected handleBeforeNonReferencableGet() {\n\t\tthis.#pointer.handleBeforeNonReferencableGet();\n\t}\n\n\tprotected handleClear() {\n\t\tthis.#pointer.callObservers(VOID, VOID, ReactiveValue.UPDATE_TYPE.CLEAR);\n\t}\n}\n\n/**\n * Set that outsources values to storage.\n * The API is similar to the JS Map API, but all methods are async.\n */\nexport class StorageMap<K,V> extends StorageWeakMap<K,V> {\n\n\t/**\n\t * Create a new StorageMap instance with the given key and value types.\n\t * @param keyType Class or DATEX Type of the keys\n\t * @param valueType Class or DATEX Type of the values\n\t * @returns \n\t */\n\tstatic override of<K, V>(keyType:Class<K>|Type<K>, valueType: Class<V>|Type<V>): StorageMap<K, V> {\n\t\treturn super.of(keyType, valueType) as StorageMap<K, V>;\n\t}\n\n\tstatic override async from<K,V>(entries: readonly (readonly [K, V])[]){\n\t\tconst map = $$(new StorageMap<K,V>());\n\t\tfor (const [key, value] of entries) await map.set(key, value);\n\t\treturn map;\n\t}\n\n\t#key_prefix = 'key.'\n\n\t#size?: number;\n\n\tget size() {\n\t\tthis.handleBeforeNonReferencableGet();\n\t\tif (this.#size == undefined) throw new Error(\"size not yet available. use getSize() instead\");\n\t\treturn this.#size;\n\t}\n\n\tasync getSize() {\n\t\tthis.handleBeforeNonReferencableGet();\n\t\tif (this.#size != undefined) return this.#size;\n\t\telse {\n\t\t\tawait this.#determineSizeFromStorage(); \n\t\t\treturn this.#size!\n\t\t}\n\t}\n\n\tasync getKeyForValue(value: V): Promise<K|undefined> {\n\t\tthis.handleBeforeNonReferencableGet();\n\t\tconst keyId = await Storage.getItemKey(value);\n\t\tconst key = await Storage.getItem(this.#key_prefix + keyId);\n\t\treturn key;\n\t}\n\n\t/**\n\t * Sets this.#size to the correct value determined from storage.\n\t */\n\tasync #determineSizeFromStorage() {\n\t\tconst calculatedSize = await Storage.getItemCountStartingWith(this._prefix);\n\t\tthis.#updateSize(calculatedSize);\n\t}\n\n\t#updateSize(newSize: number) {\n\t\tthis.#size = newSize;\n\t}\n\n\tasync #incrementSize() {\n\t\tthis.#updateSize(this.#size == undefined ? await this.getSize() : this.#size + 1);\n\t}\n\t\n\tasync #decrementSize() {\n\t\tthis.#updateSize(this.#size == undefined ? await this.getSize() : this.#size - 1);\n\t}\n\n\toverride async set(key: K, value: V): Promise<this> {\n\t\tconst storage_key = await this.getStorageKey(key);\n\t\tconst storage_item_key = this.#key_prefix + storage_key;\n\t\t// store value\n\t\tawait this._set(storage_key, key, value);\n\t\t// store key\n\t\tthis.activateCacheTimeout(storage_item_key);\n\t\tconst alreadyExisted = await Storage.setItem(storage_item_key, key);\n\t\tif (!alreadyExisted) await this.#incrementSize();\n\t\treturn this;\n\t}\n\n\toverride async delete(key: K) {\n\t\tconst storage_key = await this.getStorageKey(key);\n\t\tconst storage_item_key = this.#key_prefix + storage_key;\n\t\t// delete value\n\t\tawait this._delete(storage_key, key);\n\t\t// delete key\n\t\tconst existed = await Storage.removeItem(storage_item_key)\n\t\tif (existed) await this.#decrementSize();\n\t\treturn existed;\n\t}\n\n\t/**\n\t * Async iterator that returns all keys.\n\t */\n\tkeys() {\n\t\tthis.handleBeforeNonReferencableGet();\n\t\tconst self = this;\n\t\tconst key_prefix = this.#key_prefix;\n\t\treturn (async function*(){\n\t\t\tconst keyGenerator = await Storage.getItemKeysStartingWith(self._prefix);\n\t\t\t\n\t\t\tfor (const key of keyGenerator) {\n\t\t\t\tconst keyValue = await Storage.getItem(key_prefix+key);\n\t\t\t\tyield (<K> keyValue);\n\t\t\t}\n\t\t})()\n\t}\n\n\t/**\n\t * Returns an array containing all keys.\n\t * This can be used to iterate over the keys without using a (for await of) loop.\n\t */\n\tasync keysArray() {\n\t\tconst keys = [];\n\t\tfor await (const key of this.keys()) keys.push(key);\n\t\treturn keys;\n\t}\n\n\t/**\n\t * Async iterator that returns all values.\n\t */\n\tvalues() {\n\t\tthis.handleBeforeNonReferencableGet();\n\t\tconst self = this;\n\t\treturn (async function*(){\n\t\t\tconst keyGenerator = await Storage.getItemKeysStartingWith(self._prefix);\n\t\t\t\n\t\t\tfor (const key of keyGenerator) {\n\t\t\t\tconst value = await Storage.getItem(key);\n\t\t\t\tyield (<V> value);\n\t\t\t}\n\t\t})()\n\t}\n\n\t/**\n\t * Returns an array containing all values.\n\t * This can be used to iterate over the values without using a (for await of) loop.\n\t */\n\tasync valuesArray() {\n\t\tconst values = [];\n\t\tfor await (const value of this.values()) values.push(value);\n\t\treturn values;\n\t}\n\n\t/**\n\t * Async iterator that returns all entries.\n\t */\n\tentries() {\n\t\treturn this[Symbol.asyncIterator]()\n\t}\n\n\t/**\n\t * Returns an array containing all entries.\n\t * This can be used to iterate over the entries without using a (for await of) loop.\n\t */\n\tasync entriesArray() {\n\t\tconst entries = [];\n\t\tfor await (const entry of this.entries()) entries.push(entry);\n\t\treturn entries;\n\t}\n\n\tasync *[Symbol.asyncIterator]() {\n\t\tthis.handleBeforeNonReferencableGet();\n\t\tconst keyGenerator = await Storage.getItemKeysStartingWith(this._prefix);\n\t\t\n\t\tfor (const key of keyGenerator) {\n\t\t\tconst keyValue = await Storage.getItem(this.#key_prefix+key);\n\t\t\tconst value = await Storage.getItem(key);\n\t\t\tyield (<[K,V]> [keyValue, value]);\n\t\t}\n\t}\n\n\toverride async clear() {\n\t\tconst promises = [];\n\t\tfor (const key of await Storage.getItemKeysStartingWith(this._prefix)) {\n\t\t\tpromises.push(await Storage.removeItem(key));\n\t\t\tpromises.push(await Storage.removeItem(this.#key_prefix+key));\n\t\t}\n\t\tawait Promise.all(promises);\n\t\tthis.handleClear();\n\t}\n\n\tmatch<Options extends MatchOptions, T extends V & object>(matchInput: MatchInput<T>, options?: Options, valueType?: Type<T>): Promise<MatchResult<Options['returnKeys'] extends true ? K : T, Options>> {\n\t\tthis.handleBeforeNonReferencableGet();\n\t\tvalueType ??= this.type as any;\n\t\tif (!valueType) throw new Error(\"Cannot determine value type. Please provide a valueType parameter to match()\");\n\t\treturn match(this as unknown as StorageMap<unknown, T>, valueType, matchInput, options) as any;\n\t}\n\n}"],"names":["Compiler","VOID","Pointer","ReactiveValue","Storage","match","Type","StorageWeakMap","of","keyType","valueType","storageMap","getClassDatexType","_type","namespace","name","type","get","cacheTimeout","allowNonPointerObjectValues","getByValue","proxifyValue","from","entries","map","$$","key","value","set","_prefix","idString","storage_key","getStorageKey","_get","handleBeforeNonReferencableGet","activateCacheTimeout","getItem","has","_has","hasItem","delete","_delete","res","removeItem","callObservers","UPDATE_TYPE","DELETE","_set","proxifyChild","setItem","SET","setTimeout","cache","keyHash","getUniqueValueIdentifier","clear","promises","getItemKeysStartingWith","push","Promise","all","handleClear","CLEAR","Symbol","asyncIterator","StorageMap","size","undefined","Error","getSize","getKeyForValue","keyId","getItemKey","calculatedSize","getItemCountStartingWith","newSize","storage_item_key","existed","keys","self","key_prefix","keyValue","keysArray","values","valuesArray","entriesArray","entry","matchInput","options"],"mappings":";AAEA,SAASA,QAAQ,QAAQ,0BAA0B;AACnD,SAASC,IAAI,QAAQ,0BAA0B;AAC/C,SAASC,OAAO,EAAEC,aAAa,QAAQ,yBAAyB;AAChE,SAAuBC,OAAO,QAAQ,wBAAwB;AAE9D,SAAkCC,KAAK,QAAQ,oBAAoB;AACnE,SAASC,IAAI,QAAQ,Y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