{ "version": 3, "sources": ["../../../lib.web.primitives/index.ts", "../../../lib.web.primitives/eventbus.ts", "../../../lib.web.primitives/best_effort_store.ts", "../../../lib.web.primitives/in_memory_store.ts", "../../../../node_modules/idb/build/wrap-idb-value.js", "../../../../node_modules/idb/build/index.js", "../../../lib.web.primitives/indexed_db_store.ts", "../../../lib.web.primitives/buffered_store.ts", "../../../../node_modules/safari-14-idb-fix/dist/index.js", "../../../lib.web.primitives/cached_store.ts", "../../../lib.web.primitives/default_store.ts"], "sourcesContent": ["export * from \"./eventbus\"\nexport * from \"./best_effort_store\"\nexport * from \"./default_store\"\nexport * from \"./in_memory_store\"\nexport * from \"./indexed_db_store\"\nexport * from \"./buffered_store\"\nexport * from \"./cached_store\"\n", "import {nop} from \"@cling/lib.shared.utils\"\n\ntype Listener<T> = (msg: {data: T}) => void\n\n/**\n * An eventbus that will broadcast messages to all other tabs *and* itself.\n */\nexport interface EventBus<T> {\n postMessage: (msg: T) => void\n addEventListener: (listener: Listener<T>) => void\n}\n\nexport function blackhole_eventbus<T>(): EventBus<T> {\n return {\n postMessage: nop,\n addEventListener: nop,\n }\n}\n\nexport function local_eventbus<T>(): EventBus<T> {\n const listeners: Listener<T>[] = []\n return {\n addEventListener: (listener) => {\n listeners.push(listener)\n },\n postMessage: (msg) => {\n listeners.forEach((x) => x({data: msg}))\n },\n }\n}\n", "export type Meta = {_to_pb: (args: any) => any}\nexport type Value<META extends Meta> = {value: Uint8Array; metadata: META}\n\n/**\n * A key/value store that *never* throws an error but rather discards entries.\n */\nexport interface BestEffortStore<META extends Meta> {\n /**\n * Put the value(s) asynchronously - they will be stored eventually (or not).\n */\n put(key: string, value: Uint8Array, metadata: META): void\n put(entries: Array<[/* key: */ string, /* value: */ Value<META>]>): void\n put_and_wait(key: string, value: Uint8Array, metadata: META): Promise<void>\n put_and_wait(entries: Array<[/* key: */ string, /* value: */ Value<META>]>): Promise<void>\n get(key: string): Promise<Value<META> | undefined>\n /**\n * Remove the key(s) asynchronously - they will be removed eventually (or not).\n */\n remove(key: string): void\n remove(keys: Array<string>): void\n remove_and_wait(key_or_keys: string | Array<string>): Promise<void>\n keys(prefix?: string): Promise<Iterable<string>>\n entries(): Promise<Iterable<[string, Value<META>]>>\n close(): Promise<void>\n name: string\n}\n\n/**\n * Evict entries from a store.\n *\n * @param eviction_sort will be used to sort the keys of the store before removing the first\n * `fraction` elements.\n * @param fraction a number between 0 and 1.\n * @return the number of evicted entries or 0 if the store is already empty\n */\nexport async function evict(\n store: BestEffortStore<any>,\n eviction_sort: (k1: string, k2: string) => number,\n fraction: number,\n): Promise<number> {\n const keys = [...(await store.keys())]\n if (keys.length === 0) {\n return 0\n }\n keys.sort(eviction_sort)\n const keys_to_remove = keys.slice(0, Math.ceil(keys.length * fraction))\n await store.remove_and_wait(keys_to_remove)\n return keys_to_remove.length\n}\n", "import type {BestEffortStore, Meta, Value} from \"./best_effort_store\"\nimport {as_uint8array, not_null} from \"@cling/lib.shared.utils\"\nimport {report_error} from \"@cling/lib.shared.debug\"\n\nexport function in_memory_store<META extends Meta>(\n name: string,\n): BestEffortStore<META> & {\n concat: (m: Iterable<[string, {value: Uint8Array; metadata: META}]>) => void\n} {\n const map = new Map<string, {value: Uint8Array; metadata: META}>()\n const store = {\n name,\n put: (\n key_or_entries: string | Array<[/* key: */ string, /* value: */ Value<META>]>,\n value?: Uint8Array,\n metadata?: META,\n ) => {\n store\n .put_and_wait(key_or_entries, value, metadata)\n .catch((error) => report_error(`[${name}] Failed to put_and_wait`, error))\n },\n put_and_wait: async (\n key_or_entries: string | Array<[/* key: */ string, /* value: */ Value<META>]>,\n value?: Uint8Array,\n metadata?: META,\n ) => {\n let entries: Array<[/* key: */ string, /* value: */ Value<META>]>\n if (Array.isArray(key_or_entries)) {\n entries = key_or_entries\n } else {\n entries = [[key_or_entries, {value: not_null(value), metadata: not_null(metadata)}]]\n }\n for (const [key, entry] of entries) {\n // Ensure that we always store `Uint8Array` instances.\n map.set(key, {value: as_uint8array(entry.value), metadata: entry.metadata})\n }\n },\n get: async (key: string): Promise<{value: Uint8Array; metadata: META} | undefined> => {\n return map.get(key)\n },\n remove: (key_or_keys: string | Array<string>) => {\n store\n .remove_and_wait(key_or_keys)\n .catch((error) => report_error(`[${name}] Failed to remove_and_wait`, error))\n },\n remove_and_wait: async (key_or_keys: string | Array<string>) => {\n if (Array.isArray(key_or_keys)) {\n for (const key of key_or_keys) {\n map.delete(key)\n }\n } else {\n map.delete(key_or_keys)\n }\n },\n keys: async (prefix?: string): Promise<Iterable<string>> => {\n if (!prefix) {\n return map.keys()\n }\n return [...map.keys()].filter((x) => x.startsWith(prefix))\n },\n entries: async (): Promise<Iterable<[string, Value<META>]>> => [...map.entries()],\n close: async () => map.clear(),\n concat: (m: Iterable<[string, {value: Uint8Array; metadata: META}]>) => {\n for (const x of m) {\n map.set(x[0], x[1])\n }\n },\n }\n return store\n}\n", "const instanceOfAny = (object, constructors) => constructors.some((c) => object instanceof c);\n\nlet idbProxyableTypes;\nlet cursorAdvanceMethods;\n// This is a function to prevent it throwing up in node environments.\nfunction getIdbProxyableTypes() {\n return (idbProxyableTypes ||\n (idbProxyableTypes = [\n IDBDatabase,\n IDBObjectStore,\n IDBIndex,\n IDBCursor,\n IDBTransaction,\n ]));\n}\n// This is a function to prevent it throwing up in node environments.\nfunction getCursorAdvanceMethods() {\n return (cursorAdvanceMethods ||\n (cursorAdvanceMethods = [\n IDBCursor.prototype.advance,\n IDBCursor.prototype.continue,\n IDBCursor.prototype.continuePrimaryKey,\n ]));\n}\nconst cursorRequestMap = new WeakMap();\nconst transactionDoneMap = new WeakMap();\nconst transactionStoreNamesMap = new WeakMap();\nconst transformCache = new WeakMap();\nconst reverseTransformCache = new WeakMap();\nfunction promisifyRequest(request) {\n const promise = new Promise((resolve, reject) => {\n const unlisten = () => {\n request.removeEventListener('success', success);\n request.removeEventListener('error', error);\n };\n const success = () => {\n resolve(wrap(request.result));\n unlisten();\n };\n const error = () => {\n reject(request.error);\n unlisten();\n };\n request.addEventListener('success', success);\n request.addEventListener('error', error);\n });\n promise\n .then((value) => {\n // Since cursoring reuses the IDBRequest (*sigh*), we cache it for later retrieval\n // (see wrapFunction).\n if (value instanceof IDBCursor) {\n cursorRequestMap.set(value, request);\n }\n // Catching to avoid \"Uncaught Promise exceptions\"\n })\n .catch(() => { });\n // This mapping exists in reverseTransformCache but doesn't doesn't exist in transformCache. This\n // is because we create many promises from a single IDBRequest.\n reverseTransformCache.set(promise, request);\n return promise;\n}\nfunction cacheDonePromiseForTransaction(tx) {\n // Early bail if we've already created a done promise for this transaction.\n if (transactionDoneMap.has(tx))\n return;\n const done = new Promise((resolve, reject) => {\n const unlisten = () => {\n tx.removeEventListener('complete', complete);\n tx.removeEventListener('error', error);\n tx.removeEventListener('abort', error);\n };\n const complete = () => {\n resolve();\n unlisten();\n };\n const error = () => {\n reject(tx.error || new DOMException('AbortError', 'AbortError'));\n unlisten();\n };\n tx.addEventListener('complete', complete);\n tx.addEventListener('error', error);\n tx.addEventListener('abort', error);\n });\n // Cache it for later retrieval.\n transactionDoneMap.set(tx, done);\n}\nlet idbProxyTraps = {\n get(target, prop, receiver) {\n if (target instanceof IDBTransaction) {\n // Special handling for transaction.done.\n if (prop === 'done')\n return transactionDoneMap.get(target);\n // Polyfill for objectStoreNames because of Edge.\n if (prop === 'objectStoreNames') {\n return target.objectStoreNames || transactionStoreNamesMap.get(target);\n }\n // Make tx.store return the only store in the transaction, or undefined if there are many.\n if (prop === 'store') {\n return receiver.objectStoreNames[1]\n ? undefined\n : receiver.objectStore(receiver.objectStoreNames[0]);\n }\n }\n // Else transform whatever we get back.\n return wrap(target[prop]);\n },\n set(target, prop, value) {\n target[prop] = value;\n return true;\n },\n has(target, prop) {\n if (target instanceof IDBTransaction &&\n (prop === 'done' || prop === 'store')) {\n return true;\n }\n return prop in target;\n },\n};\nfunction replaceTraps(callback) {\n idbProxyTraps = callback(idbProxyTraps);\n}\nfunction wrapFunction(func) {\n // Due to expected object equality (which is enforced by the caching in `wrap`), we\n // only create one new func per func.\n // Edge doesn't support objectStoreNames (booo), so we polyfill it here.\n if (func === IDBDatabase.prototype.transaction &&\n !('objectStoreNames' in IDBTransaction.prototype)) {\n return function (storeNames, ...args) {\n const tx = func.call(unwrap(this), storeNames, ...args);\n transactionStoreNamesMap.set(tx, storeNames.sort ? storeNames.sort() : [storeNames]);\n return wrap(tx);\n };\n }\n // Cursor methods are special, as the behaviour is a little more different to standard IDB. In\n // IDB, you advance the cursor and wait for a new 'success' on the IDBRequest that gave you the\n // cursor. It's kinda like a promise that can resolve with many values. That doesn't make sense\n // with real promises, so each advance methods returns a new promise for the cursor object, or\n // undefined if the end of the cursor has been reached.\n if (getCursorAdvanceMethods().includes(func)) {\n return function (...args) {\n // Calling the original function with the proxy as 'this' causes ILLEGAL INVOCATION, so we use\n // the original object.\n func.apply(unwrap(this), args);\n return wrap(cursorRequestMap.get(this));\n };\n }\n return function (...args) {\n // Calling the original function with the proxy as 'this' causes ILLEGAL INVOCATION, so we use\n // the original object.\n return wrap(func.apply(unwrap(this), args));\n };\n}\nfunction transformCachableValue(value) {\n if (typeof value === 'function')\n return wrapFunction(value);\n // This doesn't return, it just creates a 'done' promise for the transaction,\n // which is later returned for transaction.done (see idbObjectHandler).\n if (value instanceof IDBTransaction)\n cacheDonePromiseForTransaction(value);\n if (instanceOfAny(value, getIdbProxyableTypes()))\n return new Proxy(value, idbProxyTraps);\n // Return the same value back if we're not going to transform it.\n return value;\n}\nfunction wrap(value) {\n // We sometimes generate multiple promises from a single IDBRequest (eg when cursoring), because\n // IDB is weird and a single IDBRequest can yield many responses, so these can't be cached.\n if (value instanceof IDBRequest)\n return promisifyRequest(value);\n // If we've already transformed this value before, reuse the transformed value.\n // This is faster, but it also provides object equality.\n if (transformCache.has(value))\n return transformCache.get(value);\n const newValue = transformCachableValue(value);\n // Not all types are transformed.\n // These may be primitive types, so they can't be WeakMap keys.\n if (newValue !== value) {\n transformCache.set(value, newValue);\n reverseTransformCache.set(newValue, value);\n }\n return newValue;\n}\nconst unwrap = (value) => reverseTransformCache.get(value);\n\nexport { reverseTransformCache as a, instanceOfAny as i, replaceTraps as r, unwrap as u, wrap as w };\n", "import { w as wrap, r as replaceTraps } from './wrap-idb-value.js';\nexport { u as unwrap, w as wrap } from './wrap-idb-value.js';\n\n/**\n * Open a database.\n *\n * @param name Name of the database.\n * @param version Schema version.\n * @param callbacks Additional callbacks.\n */\nfunction openDB(name, version, { blocked, upgrade, blocking, terminated } = {}) {\n const request = indexedDB.open(name, version);\n const openPromise = wrap(request);\n if (upgrade) {\n request.addEventListener('upgradeneeded', (event) => {\n upgrade(wrap(request.result), event.oldVersion, event.newVersion, wrap(request.transaction));\n });\n }\n if (blocked)\n request.addEventListener('blocked', () => blocked());\n openPromise\n .then((db) => {\n if (terminated)\n db.addEventListener('close', () => terminated());\n if (blocking)\n db.addEventListener('versionchange', () => blocking());\n })\n .catch(() => { });\n return openPromise;\n}\n/**\n * Delete a database.\n *\n * @param name Name of the database.\n */\nfunction deleteDB(name, { blocked } = {}) {\n const request = indexedDB.deleteDatabase(name);\n if (blocked)\n request.addEventListener('blocked', () => blocked());\n return wrap(request).then(() => undefined);\n}\n\nconst readMethods = ['get', 'getKey', 'getAll', 'getAllKeys', 'count'];\nconst writeMethods = ['put', 'add', 'delete', 'clear'];\nconst cachedMethods = new Map();\nfunction getMethod(target, prop) {\n if (!(target instanceof IDBDatabase &&\n !(prop in target) &&\n typeof prop === 'string')) {\n return;\n }\n if (cachedMethods.get(prop))\n return cachedMethods.get(prop);\n const targetFuncName = prop.replace(/FromIndex$/, '');\n const useIndex = prop !== targetFuncName;\n const isWrite = writeMethods.includes(targetFuncName);\n if (\n // Bail if the target doesn't exist on the target. Eg, getAll isn't in Edge.\n !(targetFuncName in (useIndex ? IDBIndex : IDBObjectStore).prototype) ||\n !(isWrite || readMethods.includes(targetFuncName))) {\n return;\n }\n const method = async function (storeName, ...args) {\n // isWrite ? 'readwrite' : undefined gzipps better, but fails in Edge :(\n const tx = this.transaction(storeName, isWrite ? 'readwrite' : 'readonly');\n let target = tx.store;\n if (useIndex)\n target = target.index(args.shift());\n // Must reject if op rejects.\n // If it's a write operation, must reject if tx.done rejects.\n // Must reject with op rejection first.\n // Must resolve with op value.\n // Must handle both promises (no unhandled rejections)\n return (await Promise.all([\n target[targetFuncName](...args),\n isWrite && tx.done,\n ]))[0];\n };\n cachedMethods.set(prop, method);\n return method;\n}\nreplaceTraps((oldTraps) => ({\n ...oldTraps,\n get: (target, prop, receiver) => getMethod(target, prop) || oldTraps.get(target, prop, receiver),\n has: (target, prop) => !!getMethod(target, prop) || oldTraps.has(target, prop),\n}));\n\nexport { deleteDB, openDB };\n", "import type {BestEffortStore, Meta, Value} from \"./best_effort_store\"\nimport {all_finished, as_uint8array, not_null, with_timeout} from \"@cling/lib.shared.utils\"\nimport {from_buffer, to_uint8array} from \"@cling/lib.shared.model\"\nimport * as idb from \"idb\"\nimport type {openDB} from \"idb/build/entry.d.ts\"\nimport {report_error} from \"@cling/lib.shared.debug\"\n\nexport class IndexedDBTransactionFailedWithoutReason extends Error {\n constructor(store_name: string) {\n super(`[${store_name}] IndexedDB transaction failed without any reason`)\n // This is needed according to https://goo.gl/N2zvkR\n Object.setPrototypeOf(this, IndexedDBTransactionFailedWithoutReason.prototype)\n }\n}\n\nexport class IndexedDBOpenFailed extends Error {\n constructor(\n store_name: string,\n public readonly cause: Error,\n ) {\n super(\n `[${store_name}] Failed to open IndexedDB database. ` +\n \"We deleted it and it should be re-created \" +\n \"automatically before the next store operation.\",\n )\n // This is needed according to https://goo.gl/N2zvkR\n Object.setPrototypeOf(this, IndexedDBOpenFailed.prototype)\n }\n}\n\nexport class IndexedDBTransactionAbortedWithoutReason extends Error {\n constructor(store_name: string) {\n super(`[${store_name}] IndexedDB transaction aborted without any reason`)\n // This is needed according to https://goo.gl/N2zvkR\n Object.setPrototypeOf(this, IndexedDBTransactionAbortedWithoutReason.prototype)\n }\n}\n\nexport class IndexedDBNearQuota extends Error {\n constructor(\n store_name: string,\n public readonly quota_usage: number,\n public readonly quota_limit: number,\n ) {\n super(`[${store_name}] IndexedDB is near the quota (${quota_usage}/${quota_limit})`)\n // This is needed according to https://goo.gl/N2zvkR\n Object.setPrototypeOf(this, IndexedDBNearQuota.prototype)\n }\n}\n\nexport async function indexed_db_store<META extends Meta>(\n name: string,\n metadata_type: {_from_pb: (p: any) => META},\n store_opts: {\n on_error?: (error: Error) => void\n throw_errors?: boolean\n write_timeout?: number\n read_timeout?: number\n durability: \"strict\" | \"relaxed\"\n } = {\n durability: \"relaxed\",\n },\n): Promise<BestEffortStore<META>> {\n const _write_timeout = store_opts.write_timeout ?? 7000\n const _read_timeout = store_opts.read_timeout ?? 7000\n const idb_store = ((idb as any).openDB as typeof openDB)(name, 1, {\n upgrade(db) {\n db.createObjectStore(\"d\")\n },\n })\n function _on_error(error: Error) {\n try {\n store_opts.on_error?.(error)\n } catch {\n // Ignored\n }\n }\n async function _run<T>(\n f: () => Promise<T>,\n opts: {\n description: string\n key?: string\n timeout: number\n },\n ): Promise<T | \"ERROR\"> {\n const {key, description, timeout} = opts\n try {\n return await with_timeout(timeout, f(), {\n description: [name, description, key].filter((x) => !!x).join(\", \"),\n })\n } catch (error) {\n if (store_opts.throw_errors) {\n throw error\n }\n if (error && key) {\n error.best_effort_store_key = key\n }\n _on_error(error)\n return \"ERROR\"\n }\n }\n const store = {\n name,\n put: async (\n key_or_entries: string | Array<[/* key: */ string, /* value: */ Value<META>]>,\n value?: Uint8Array,\n metadata?: META,\n ) => {\n store\n .put(key_or_entries, value, metadata)\n .catch((error) => report_error(`[${name}] Failed to put`, error))\n },\n put_and_wait: async (\n key_or_entries: string | Array<[/* key: */ string, /* value: */ Value<META>]>,\n value?: Uint8Array,\n metadata?: META,\n ) => {\n try {\n if (navigator.storage && navigator.storage.estimate) {\n const quota = await navigator.storage.estimate()\n if (quota.usage && quota.quota && quota.quota - quota.usage < 50_000_000) {\n _on_error(new IndexedDBNearQuota(name, quota.usage, quota.quota))\n }\n }\n } catch {\n // This might fail on Safari 17, maybe only if called from a worker.\n // We ignore this error because all of this is an optimization anyway.\n }\n let entries: Array<[/* key: */ string, /* value: */ Value<META>]>\n if (Array.isArray(key_or_entries)) {\n entries = key_or_entries\n } else {\n entries = [[key_or_entries, {value: not_null(value), metadata: not_null(metadata)}]]\n }\n await _run(\n async () => {\n const tx = (await idb_store).transaction(\"d\", \"readwrite\", {\n durability: store_opts.durability,\n })\n const promises = [tx.done as Promise<any>]\n try {\n for (const x of entries) {\n promises.push(\n tx.store.put(\n {m: to_uint8array(x[1].metadata), b: as_uint8array(x[1].value)},\n x[0],\n ),\n )\n }\n } finally {\n await all_finished(promises)\n }\n },\n {\n key: entries.length === 1 ? entries[0][0] : undefined,\n description: \"op=put\",\n timeout: _write_timeout,\n },\n )\n },\n get: async (key: string): Promise<{value: Uint8Array; metadata: META} | undefined> => {\n const res = await _run(\n async () => {\n const value = await (await idb_store).get(\"d\", key)\n if (value) {\n return {metadata: from_buffer(metadata_type, value.m), value: value.b}\n }\n },\n {key, description: \"op=get\", timeout: _read_timeout},\n )\n if (res === \"ERROR\") {\n return\n }\n return res\n },\n remove: (key_or_keys: string | Array<string>) => {\n store\n .remove_and_wait(key_or_keys)\n .catch((error) => report_error(`[${name}] Failed to remove_and_wait`, error))\n },\n remove_and_wait: async (key_or_keys: string | Array<string>) => {\n await _run(\n async () => {\n const tx = (await idb_store).transaction(\"d\", \"readwrite\", {\n durability: store_opts.durability,\n })\n const promises = [tx.done as Promise<any>]\n try {\n for (const x of Array.isArray(key_or_keys) ? key_or_keys : [key_or_keys]) {\n promises.push(tx.store.delete(x))\n }\n } finally {\n await all_finished(promises)\n }\n },\n {description: \"op=remove\", timeout: _write_timeout},\n )\n },\n keys: async (prefix?: string): Promise<Iterable<string>> => {\n const res = await _run(\n async () =>\n (await idb_store).getAllKeys(\n \"d\",\n prefix\n ? IDBKeyRange.bound(\n prefix,\n prefix.slice(0, -1) +\n String.fromCharCode(prefix.charCodeAt(prefix.length - 1) + 1),\n false,\n true,\n )\n : undefined,\n ),\n {\n description: \"op=keys\",\n timeout: _read_timeout,\n },\n )\n if (res === \"ERROR\") {\n return []\n }\n return res.map((x) => x.toString())\n },\n entries: async (): Promise<Iterable<[string, Value<META>]>> => {\n const res = await _run(\n async () => {\n const tx = (await idb_store).transaction(\"d\", \"readonly\")\n let cursor = await tx.store.openCursor()\n const entries = []\n while (cursor) {\n entries.push([cursor.key, cursor.value])\n cursor = await cursor.continue()\n }\n return entries\n },\n {\n description: \"op=entries\",\n timeout: _read_timeout,\n },\n )\n if (res === \"ERROR\") {\n return []\n }\n return res.map((x) => [\n x[0],\n {value: x[1].b, metadata: from_buffer(metadata_type, x[1].m)},\n ])\n },\n close: async () => {\n try {\n const s = await idb_store\n s.close()\n } catch (error) {\n _on_error(error)\n }\n },\n }\n return store\n}\n", "import type {BestEffortStore, Meta, Value} from \"./best_effort_store\"\nimport {not_null, sleep} from \"@cling/lib.shared.utils\"\nimport {report_error} from \"@cling/lib.shared.debug\"\n\nexport function buffered_store<META extends Meta>(\n wrapped: BestEffortStore<META>,\n): BestEffortStore<META> {\n const put_buffer = new Map<string, Value<META>>()\n const remove_buffer = new Set<string>()\n const update = async () => {\n try {\n while (remove_buffer.size || put_buffer.size) {\n if (remove_buffer.size) {\n const keys = Array.from(remove_buffer.keys())\n await wrapped.remove_and_wait(keys)\n for (const key of keys) {\n remove_buffer.delete(key)\n }\n }\n if (put_buffer.size) {\n const entries = Array.from(put_buffer.entries())\n await wrapped.put_and_wait(entries)\n for (const [key] of entries) {\n put_buffer.delete(key)\n }\n }\n await sleep(57)\n }\n } finally {\n pending_update = undefined\n }\n }\n let pending_update: undefined | Promise<void>\n const store = {\n name: wrapped.name,\n put: (\n key_or_entries: string | Array<[/* key: */ string, /* value: */ Value<META>]>,\n value?: Uint8Array,\n metadata?: META,\n ) => {\n store\n .put_and_wait(key_or_entries, value, metadata)\n .catch((error) => report_error(`[${wrapped.name}] Failed to put_and_wait`, error))\n },\n put_and_wait: (\n key_or_entries: string | Array<[/* key: */ string, /* value: */ Value<META>]>,\n value?: Uint8Array,\n metadata?: META,\n ) => {\n let entries: Array<[/* key: */ string, /* value: */ Value<META>]>\n if (Array.isArray(key_or_entries)) {\n entries = key_or_entries\n } else {\n entries = [[key_or_entries, {value: not_null(value), metadata: not_null(metadata)}]]\n }\n for (const [k, v] of entries) {\n put_buffer.set(k, v)\n remove_buffer.delete(k)\n }\n if (!pending_update) {\n pending_update = update()\n }\n return pending_update\n },\n get(key: string): Promise<Value<META> | undefined> {\n const buffered = put_buffer.get(key)\n if (buffered) {\n return Promise.resolve(buffered)\n }\n if (remove_buffer.has(key)) {\n return Promise.resolve(undefined)\n }\n return wrapped.get(key)\n },\n remove: async (key_or_keys: string | Array<string>) => {\n store\n .remove_and_wait(key_or_keys)\n .catch((error) =>\n report_error(`[${wrapped.name}] Failed to remove_and_wait`, error),\n )\n },\n remove_and_wait: async (key_or_keys: string | Array<string>) => {\n let keys: Array<string>\n if (Array.isArray(key_or_keys)) {\n keys = key_or_keys\n } else {\n keys = [key_or_keys]\n }\n for (const key of keys) {\n put_buffer.delete(key)\n remove_buffer.add(key)\n }\n if (!pending_update) {\n pending_update = update()\n }\n return pending_update\n },\n keys: async (prefix?: string): Promise<Iterable<string>> => {\n const keys = new Set(await wrapped.keys(prefix))\n for (const key of put_buffer.keys()) {\n if (!prefix || key.startsWith(prefix)) {\n keys.add(key)\n }\n }\n for (const key of remove_buffer) {\n keys.delete(key)\n }\n return keys\n },\n entries: async (): Promise<Array<[string, Value<META>]>> => {\n const entries = new Map(await wrapped.entries())\n for (const [key, value] of put_buffer.entries()) {\n entries.set(key, value)\n }\n for (const key of remove_buffer) {\n entries.delete(key)\n }\n return Array.from(entries.entries())\n },\n close(): Promise<void> {\n return wrapped.close()\n },\n }\n return store\n}\n", "/**\n * Work around Safari 14 IndexedDB open bug.\n *\n * Safari has a horrible bug where IDB requests can hang while the browser is starting up. https://bugs.webkit.org/show_bug.cgi?id=226547\n * The only solution is to keep nudging it until it's awake.\n */\nfunction idbReady() {\n var isSafari = !navigator.userAgentData &&\n /Safari\\//.test(navigator.userAgent) &&\n !/Chrom(e|ium)\\//.test(navigator.userAgent);\n // No point putting other browsers or older versions of Safari through this mess.\n if (!isSafari || !indexedDB.databases)\n return Promise.resolve();\n var intervalId;\n return new Promise(function (resolve) {\n var tryIdb = function () { return indexedDB.databases().finally(resolve); };\n intervalId = setInterval(tryIdb, 100);\n tryIdb();\n }).finally(function () { return clearInterval(intervalId); });\n}\n\nexport default idbReady;\n", "import {report_error, report_info} from \"@cling/lib.shared.debug\"\nimport {not_null, with_timeout} from \"@cling/lib.shared.utils\"\nimport {in_memory_store} from \"./in_memory_store\"\nimport type {BestEffortStore, Meta, Value} from \"./best_effort_store\"\n\n/**\n * Load the entire store and then operate in memory but persist changes\n * to the underyling store.\n */\nexport function cached_store<META extends Meta>(\n wrapped: BestEffortStore<META>,\n opts: {cache_fill_timeout: number},\n): BestEffortStore<META> {\n const memory = in_memory_store<META>(wrapped.name)\n const t0 = Date.now()\n const init_promise = with_timeout(\n opts.cache_fill_timeout,\n wrapped.entries().then((entries) => {\n memory.concat(entries)\n report_info(`[${wrapped.name}] Entries read in ${Date.now() - t0} ms`)\n }),\n {description: `${wrapped.name},cache_fill`},\n ).catch((error) => report_error(`[${wrapped.name}] Failed to fill cache`, error))\n const store = {\n name: wrapped.name,\n put: (\n key_or_entries: string | Array<[/* key: */ string, /* value: */ Value<META>]>,\n value?: Uint8Array,\n metadata?: META,\n ) => {\n store\n .put_and_wait(key_or_entries, value, metadata)\n .catch((error) => report_error(`[${wrapped.name}] Failed to put_and_wait`, error))\n },\n put_and_wait: async (\n key_or_entries: string | Array<[/* key: */ string, /* value: */ Value<META>]>,\n value?: Uint8Array,\n metadata?: META,\n ) => {\n await init_promise\n if (Array.isArray(key_or_entries)) {\n await memory.put_and_wait(key_or_entries)\n await wrapped.put_and_wait(key_or_entries)\n } else {\n await memory.put_and_wait(key_or_entries, not_null(value), not_null(metadata))\n await wrapped.put_and_wait(key_or_entries, not_null(value), not_null(metadata))\n }\n },\n get: async (key: string): Promise<Value<META> | undefined> => {\n await init_promise\n return memory.get(key)\n },\n remove: async (key_or_keys: string | Array<string>) => {\n await init_promise\n store\n .remove_and_wait(key_or_keys)\n .catch((error) =>\n report_error(`[${wrapped.name}] Failed to remove_and_wait`, error),\n )\n },\n remove_and_wait: async (key_or_keys: string | Array<string>) => {\n await init_promise\n await memory.remove_and_wait(key_or_keys)\n await wrapped.remove_and_wait(key_or_keys)\n },\n keys: async (prefix?: string): Promise<Iterable<string>> => {\n await init_promise\n return memory.keys(prefix)\n },\n entries: async (): Promise<Iterable<[string, Value<META>]>> => {\n await init_promise\n return await memory.entries()\n },\n close: async (): Promise<void> => {\n await memory.close()\n return wrapped.close()\n },\n }\n return store\n}\n", "import type {BestEffortStore, Meta} from \"./best_effort_store\"\nimport {log} from \"@cling/lib.shared.logging\"\nimport {with_timeout} from \"@cling/lib.shared.utils\"\nimport {report_info} from \"@cling/lib.shared.debug\"\nimport {in_memory_store} from \"./in_memory_store\"\nimport {indexed_db_store} from \"./indexed_db_store\"\nimport {buffered_store} from \"./buffered_store\"\nimport wait_for_safari_idb from \"safari-14-idb-fix\"\nimport {cached_store} from \"./cached_store\"\n\nlet indexed_db_available: boolean | undefined\n\n/**\n * Return the most suitable `BestEffortStore` for the current environment.\n */\nexport async function default_store<META extends Meta>(\n name: string,\n metadata_type: {_from_pb: (p: any) => META},\n opts: {\n on_error?: (error: Error) => void\n throw_errors?: boolean\n memory_cache?: boolean\n durability?: \"relaxed\" | \"strict\"\n },\n): Promise<BestEffortStore<META>> {\n if (typeof indexedDB !== \"undefined\" && indexed_db_available !== false) {\n try {\n return await with_timeout(\n 7000,\n (async () => {\n if (!indexed_db_available) {\n await wait_for_safari_idb()\n const idb = await new Promise<IDBDatabase>((resolve, reject) => {\n const req = indexedDB.open(\"__test__\", 1)\n req.onerror = function () {\n reject(this.error)\n }\n req.onsuccess = function () {\n resolve(this.result)\n }\n req.onupgradeneeded = () => {\n // Don't do anything.\n }\n })\n idb.close()\n }\n const store = await indexed_db_store(name, metadata_type, {\n ...opts,\n durability: opts.durability || \"relaxed\",\n read_timeout: 7000,\n write_timeout: 60000,\n })\n await store.get(\"just checking if IndexedDB responds\")\n indexed_db_available = true\n const buffered = buffered_store(store)\n ;(buffered as any).__test_only_wrapped = store\n if (opts.memory_cache) {\n log.info(\n `[${name}] Using \\`cached_store(buffered_store(indexed_db_store))\\``,\n )\n const cached = cached_store(buffered, {cache_fill_timeout: 10000})\n ;(cached as any).__test_only_wrapped = buffered\n return cached\n } else {\n log.info(`[${name}] Using \\`buffered_store(indexed_db_store)\\``)\n }\n return buffered\n })(),\n {description: `[${name}] Setting up \\`indexed_db_store\\``},\n )\n } catch (error) {\n report_info(\n `[${name}] IndexedDB not supported by browser, using \\`in_memory_store\\``,\n error,\n )\n }\n }\n report_info(`[${name}] IndexedDB not supported by browser, using \\`in_memory_store\\``)\n return in_memory_store(name)\n}\n"], "mappings": "kOAAA,IAAAA,GAAA,GAAAC,GAAAD,GAAA,wBAAAE,EAAA,wBAAAC,EAAA,6CAAAC,EAAA,4CAAAC,EAAA,uBAAAC,GAAA,mBAAAC,EAAA,iBAAAC,EAAA,kBAAAC,GAAA,UAAAC,GAAA,oBAAAC,EAAA,qBAAAC,EAAA,mBAAAC,KCYO,SAASC,IAAqC,CACjD,MAAO,CACH,YAAaC,EACb,iBAAkBA,CACtB,CACJ,CALgBC,EAAAF,GAAA,sBAOT,SAASG,IAAiC,CAC7C,IAAMC,EAA2B,CAAC,EAClC,MAAO,CACH,iBAAkBF,EAACG,GAAa,CAC5BD,EAAU,KAAKC,CAAQ,CAC3B,EAFkB,oBAGlB,YAAaH,EAACI,GAAQ,CAClBF,EAAU,QAASG,GAAMA,EAAE,CAAC,KAAMD,CAAG,CAAC,CAAC,CAC3C,EAFa,cAGjB,CACJ,CAVgBJ,EAAAC,GAAA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,eAAsBC,GAClBC,EACAC,EACAC,EAM8B,CAC9B,GAAI,OAAO,UAAc,KAAeJ,IAAyB,GAC7D,GAAI,CACA,OAAO,MAAMK,EACT,KACC,SAAY,CACJL,IACD,MAAMM,GAAoB,GACd,MAAM,IAAI,QAAqB,CAACC,EAASC,IAAW,CAC5D,IAAMC,EAAM,UAAU,KAAK,WAAY,CAAC,EACxCA,EAAI,QAAU,UAAY,CACtBD,EAAO,KAAK,KAAK,CACrB,EACAC,EAAI,UAAY,UAAY,CACxBF,EAAQ,KAAK,MAAM,CACvB,EACAE,EAAI,gBAAkB,IAAM,CAE5B,CACJ,CAAC,GACG,MAAM,GAEd,IAAMC,EAAQ,MAAMC,EAAiBT,EAAMC,EAAe,CACtD,GAAGC,EACH,WAAYA,EAAK,YAAc,UAC/B,aAAc,IACd,cAAe,GACnB,CAAC,EACD,MAAMM,EAAM,IAAI,qCAAqC,EACrDV,EAAuB,GACvB,IAAMY,EAAWC,EAAeH,CAAK,EAErC,GADEE,EAAiB,oBAAsBF,EACrCN,EAAK,aAAc,CACnBU,EAAI,KACA,IAAIZ,CAAI,4DACZ,EACA,IAAMa,EAASC,EAAaJ,EAAU,CAAC,mBAAoB,GAAK,CAAC,EAChE,OAACG,EAAe,oBAAsBH,EAChCG,CACX,MACID,EAAI,KAAK,IAAIZ,CAAI,8CAA8C,EAEnE,OAAOU,CACX,GAAG,EACH,CAAC,YAAa,IAAIV,CAAI,mCAAmC,CAC7D,CACJ,OAASe,EAAO,CACZC,EACI,IAAIhB,CAAI,kEACRe,CACJ,CACJ,CAEJ,OAAAC,EAAY,IAAIhB,CAAI,iEAAiE,EAC9EiB,EAAgBjB,CAAI,CAC/B,CAhEsBkB,EAAAnB,GAAA", "names": ["lib_web_exports", "__export", "IndexedDBNearQuota", "IndexedDBOpenFailed", "IndexedDBTransactionAbortedWithoutReason", "IndexedDBTransactionFailedWithoutReason", "blackhole_eventbus", "buffered_store", "cached_store", "default_store", "evict", "in_memory_store", "indexed_db_store", "local_eventbus", "blackhole_eventbus", "nop", "__name", "local_eventbus", "listeners", "listener", "msg", "x", "evict", "store", "eviction_sort", "fraction", "keys", "keys_to_remove", "__name", "in_memory_store", "name", "map", "store", "__name", "key_or_entries", "value", "metadata", "error", "report_error", "entries", "not_null", "key", "entry", "as_uint8array", "key_or_keys", "prefix", "x", "m", "instanceOfAny", "__name", "object", "constructors", "c", "idbProxyableTypes", "cursorAdvanceMethods", "getIdbProxyableTypes", "getCursorAdvanceMethods", "cursorRequestMap", "transactionDoneMap", "transactionStoreNamesMap", "transformCache", "reverseTransformCache", "promisifyRequest", "request", "promise", "resolve", "reject", "unlisten", "success", "error", "wrap", "value", "cacheDonePromiseForTransaction", "tx", "done", "complete", "idbProxyTraps", "target", "prop", "receiver", "replaceTraps", "callback", "wrapFunction", "func", "storeNames", "args", "unwrap", "transformCachableValue", "newValue", "openDB", "name", "version", "blocked", "upgrade", "blocking", "terminated", "request", "openPromise", "wrap", "event", "db", "__name", "readMethods", "writeMethods", "cachedMethods", "getMethod", "target", "prop", "targetFuncName", "useIndex", "isWrite", "method", "__name", "storeName", "args", "tx", "replaceTraps", "oldTraps", "receiver", "_IndexedDBTransactionFailedWithoutReason", "store_name", "__name", "IndexedDBTransactionFailedWithoutReason", "_IndexedDBOpenFailed", "cause", "IndexedDBOpenFailed", "_IndexedDBTransactionAbortedWithoutReason", "IndexedDBTransactionAbortedWithoutReason", "_IndexedDBNearQuota", "quota_usage", "quota_limit", "IndexedDBNearQuota", "indexed_db_store", "name", "metadata_type", "store_opts", "_write_timeout", "_read_timeout", "idb_store", "openDB", "db", "_on_error", "error", "_run", "f", "opts", "key", "description", "timeout", "with_timeout", "x", "store", "key_or_entries", "value", "metadata", "report_error", "quota", "entries", "not_null", "tx", "promises", "to_uint8array", "as_uint8array", "all_finished", "res", "from_buffer", "key_or_keys", "prefix", "cursor", "buffered_store", "wrapped", "put_buffer", "remove_buffer", "update", "__name", "keys", "key", "entries", "sleep", "pending_update", "store", "key_or_entries", "value", "metadata", "error", "report_error", "not_null", "k", "v", "buffered", "key_or_keys", "prefix", "idbReady", "isSafari", "intervalId", "resolve", "tryIdb", "__name", "dist_default", "cached_store", "wrapped", "opts", "memory", "in_memory_store", "t0", "init_promise", "with_timeout", "entries", "report_info", "error", "report_error", "store", "__name", "key_or_entries", "value", "metadata", "not_null", "key", "key_or_keys", "prefix", "indexed_db_available", "default_store", "name", "metadata_type", "opts", "with_timeout", "dist_default", "resolve", "reject", "req", "store", "indexed_db_store", "buffered", "buffered_store", "log", "cached", "cached_store", "error", "report_info", "in_memory_store", "__name"] }