@powerhousedao/connect 1.0.0-dev.211 → 1.0.0-dev.213

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.
Files changed (59) hide show
  1. package/dist/.env +1 -0
  2. package/dist/assets/{app-ec_tqKyy.js → app-DiHFmipv.js} +772 -577
  3. package/dist/assets/{app-loader-D_w1htsM.js → app-loader-CR-NiUOZ.js} +9 -7
  4. package/dist/assets/{browser-Ccv5jMQ2.js → browser-C10aMa50.js} +2937 -909
  5. package/dist/assets/{ccip-BINxWLhB.js → ccip-DMxcOGc8.js} +5 -5
  6. package/dist/assets/{content-xyBITmn7.js → content-BFPuAVvX.js} +186 -162
  7. package/dist/assets/{getEnsName-DtQ0D82H.js → getEnsName-08yGhvFP.js} +75 -55
  8. package/dist/assets/{index-B76kqOWF.js → index-BSiq93_2.js} +3 -3
  9. package/dist/assets/{index-F6sLtgJX.js → index-C6RulKld.js} +3 -3
  10. package/dist/assets/{index-DMwoEUPC.js → index-J6o4darV.js} +88 -2732
  11. package/dist/assets/{isAddressEqual-CVC2WsAk.js → isAddressEqual-BZ4M2bfj.js} +1 -1
  12. package/dist/assets/{main.CyEpz8Xq.js → main.GY5oyZm-.js} +1 -1
  13. package/dist/assets/{react-error-boundary.esm-CSTN2MP_.js → react-error-boundary.esm-C6q5J1bx.js} +10 -10
  14. package/dist/assets/{root-wxc1EfqI.js → root-BWz1808T.js} +7 -7
  15. package/dist/assets/{router-BJrY_t-B.js → router-DYMMZqez.js} +7 -7
  16. package/dist/icon.ico +0 -0
  17. package/dist/index.html +5 -4
  18. package/dist/modules/@powerhousedao/reactor-browser/{chunk-QP65GEDP.js → chunk-C5JXP4NO.js} +2 -2
  19. package/dist/modules/@powerhousedao/reactor-browser/{chunk-YAO66KBZ.js → chunk-FD4TUZZS.js} +353 -302
  20. package/dist/modules/@powerhousedao/reactor-browser/chunk-FD4TUZZS.js.map +7 -0
  21. package/dist/modules/@powerhousedao/reactor-browser/{chunk-VNJW3K7R.js → chunk-GJOMXDVW.js} +3 -3
  22. package/dist/modules/@powerhousedao/reactor-browser/chunk-GJOMXDVW.js.map +7 -0
  23. package/dist/modules/@powerhousedao/reactor-browser/{chunk-VHDG2FTR.js → chunk-GXLBC3KA.js} +2 -2
  24. package/dist/modules/@powerhousedao/reactor-browser/{chunk-NCCSZUHV.js → chunk-IDBZA52T.js} +2 -2
  25. package/dist/modules/@powerhousedao/reactor-browser/{chunk-5Q3OAWSW.js → chunk-LCQV2CEG.js} +9 -5
  26. package/dist/modules/@powerhousedao/reactor-browser/chunk-LCQV2CEG.js.map +7 -0
  27. package/dist/modules/@powerhousedao/reactor-browser/{chunk-PRKHJCY6.js → chunk-OJYBFBSZ.js} +2 -2
  28. package/dist/modules/@powerhousedao/reactor-browser/{chunk-XDWKADEF.js → chunk-UTLXXWAE.js} +5 -5
  29. package/dist/modules/@powerhousedao/reactor-browser/{chunk-XDWKADEF.js.map → chunk-UTLXXWAE.js.map} +3 -3
  30. package/dist/modules/@powerhousedao/reactor-browser/{chunk-GYHJG3BX.js → chunk-WSWYH5W2.js} +2 -2
  31. package/dist/modules/@powerhousedao/reactor-browser/{chunk-NG3UCFCH.js → chunk-XNBBEHKQ.js} +16 -7
  32. package/dist/modules/@powerhousedao/reactor-browser/chunk-XNBBEHKQ.js.map +7 -0
  33. package/dist/modules/@powerhousedao/reactor-browser/context/index.js +2 -2
  34. package/dist/modules/@powerhousedao/reactor-browser/context/read-mode.js +2 -2
  35. package/dist/modules/@powerhousedao/reactor-browser/hooks/document-state.js +87 -0
  36. package/dist/modules/@powerhousedao/reactor-browser/hooks/document-state.js.map +7 -0
  37. package/dist/modules/@powerhousedao/reactor-browser/hooks/index.js +11 -9
  38. package/dist/modules/@powerhousedao/reactor-browser/hooks/useAddDebouncedOperations.js +3 -3
  39. package/dist/modules/@powerhousedao/reactor-browser/hooks/useConnectCrypto.js +2 -2
  40. package/dist/modules/@powerhousedao/reactor-browser/hooks/useDocumentDrives.js +2 -2
  41. package/dist/modules/@powerhousedao/reactor-browser/hooks/useDocumentEditor.js +9 -7
  42. package/dist/modules/@powerhousedao/reactor-browser/hooks/useDriveActions.js +2 -2
  43. package/dist/modules/@powerhousedao/reactor-browser/hooks/useDriveActionsWithUiNodes.js +3 -3
  44. package/dist/modules/@powerhousedao/reactor-browser/index.js +13 -11
  45. package/dist/modules/@powerhousedao/reactor-browser/reactor.js +2 -2
  46. package/dist/swEnv.js +1 -0
  47. package/dist/vite-envs.sh +10 -1
  48. package/package.json +10 -10
  49. package/dist/modules/@powerhousedao/reactor-browser/chunk-5Q3OAWSW.js.map +0 -7
  50. package/dist/modules/@powerhousedao/reactor-browser/chunk-NG3UCFCH.js.map +0 -7
  51. package/dist/modules/@powerhousedao/reactor-browser/chunk-VNJW3K7R.js.map +0 -7
  52. package/dist/modules/@powerhousedao/reactor-browser/chunk-YAO66KBZ.js.map +0 -7
  53. package/dist/modules/@powerhousedao/reactor-browser/hooks/useDocumentsState.js +0 -44
  54. package/dist/modules/@powerhousedao/reactor-browser/hooks/useDocumentsState.js.map +0 -7
  55. /package/dist/modules/@powerhousedao/reactor-browser/{chunk-QP65GEDP.js.map → chunk-C5JXP4NO.js.map} +0 -0
  56. /package/dist/modules/@powerhousedao/reactor-browser/{chunk-VHDG2FTR.js.map → chunk-GXLBC3KA.js.map} +0 -0
  57. /package/dist/modules/@powerhousedao/reactor-browser/{chunk-NCCSZUHV.js.map → chunk-IDBZA52T.js.map} +0 -0
  58. /package/dist/modules/@powerhousedao/reactor-browser/{chunk-PRKHJCY6.js.map → chunk-OJYBFBSZ.js.map} +0 -0
  59. /package/dist/modules/@powerhousedao/reactor-browser/{chunk-GYHJG3BX.js.map → chunk-WSWYH5W2.js.map} +0 -0
@@ -1,7 +0,0 @@
1
- {
2
- "version": 3,
3
- "sources": ["../../../../../../packages/reactor-browser/dist/src/hooks/useDocumentDrives.js", "../../../../../../node_modules/.pnpm/jotai@2.11.1_@types+react@18.3.18_react@18.3.1/node_modules/jotai/esm/vanilla/utils.mjs"],
4
- "sourcesContent": ["import { useMemo, useCallback } from \"react\";\nimport { atom, useAtom } from \"jotai\";\nimport { atomFamily } from \"jotai/utils\";\nimport { documentToHash } from \"../utils/index.js\";\nconst documentDrivesAtom = atom(new Map());\nexport function drivesToHash(drives) {\n return drives.map(documentToHash).join(\"&\");\n}\nconst readWriteDocumentDrivesAtom = (server) => () => atom((get) => (server ? (get(documentDrivesAtom).get(server) ?? []) : []), (_get, set, newDrives) => {\n set(documentDrivesAtom, (map) => {\n if (!server) {\n return new Map();\n }\n const currentDrives = map.get(server) ?? [];\n if (currentDrives.length !== newDrives.length ||\n drivesToHash(currentDrives) !== drivesToHash(newDrives)) {\n return new Map(map).set(server, newDrives);\n }\n else {\n return map;\n }\n });\n});\nexport const documentDrivesInitializedMapAtomFamily = atomFamily(() => atom(\"INITIAL\"));\nexport function useDocumentDrives(reactor) {\n const [documentDrives, setDocumentDrives] = useAtom(useMemo(readWriteDocumentDrivesAtom(reactor), [reactor]));\n const refreshDocumentDrives = useCallback(async () => {\n if (!reactor) {\n return;\n }\n const documentDrives = [];\n try {\n const driveIds = await reactor.getDrives();\n for (const id of driveIds) {\n try {\n const drive = await reactor.getDrive(id);\n documentDrives.push(drive);\n }\n catch (error) {\n console.error(error);\n }\n }\n }\n catch (error) {\n console.error(error);\n }\n finally {\n setDocumentDrives(documentDrives);\n }\n }, [reactor]);\n const [status, setStatus] = useAtom(documentDrivesInitializedMapAtomFamily(reactor));\n if (status === \"INITIAL\") {\n setStatus(\"LOADING\");\n refreshDocumentDrives()\n .then(() => setStatus(\"LOADED\"))\n .catch(() => setStatus(\"ERROR\"));\n }\n const serverSubscribeUpdates = useCallback((clientErrorhandler) => {\n if (!reactor) {\n return;\n }\n const unsub1 = reactor.on(\"syncStatus\", async (_event, _status, error) => {\n if (error) {\n console.error(error);\n }\n await refreshDocumentDrives();\n });\n const unsub2 = reactor.on(\"strandUpdate\", () => refreshDocumentDrives());\n const unsubOnSyncError = reactor.on(\"clientStrandsError\", clientErrorhandler.strandsErrorHandler);\n const unsub3 = reactor.on(\"defaultRemoteDrive\", () => refreshDocumentDrives());\n return () => {\n unsub1();\n unsub2();\n unsubOnSyncError();\n unsub3();\n };\n }, [reactor, refreshDocumentDrives]);\n return useMemo(() => [\n documentDrives,\n refreshDocumentDrives,\n serverSubscribeUpdates,\n status,\n ], [documentDrives, status]);\n}\n", "import { atom } from 'jotai/vanilla';\n\nconst RESET = Symbol(\n (import.meta.env ? import.meta.env.MODE : undefined) !== \"production\" ? \"RESET\" : \"\"\n);\n\nfunction atomWithReset(initialValue) {\n const anAtom = atom(\n initialValue,\n (get, set, update) => {\n const nextValue = typeof update === \"function\" ? update(get(anAtom)) : update;\n set(anAtom, nextValue === RESET ? initialValue : nextValue);\n }\n );\n return anAtom;\n}\n\nfunction atomWithReducer(initialValue, reducer) {\n return atom(initialValue, function(get, set, action) {\n set(this, reducer(get(this), action));\n });\n}\n\nfunction atomFamily(initializeAtom, areEqual) {\n let shouldRemove = null;\n const atoms = /* @__PURE__ */ new Map();\n const listeners = /* @__PURE__ */ new Set();\n const createAtom = (param) => {\n let item;\n if (areEqual === undefined) {\n item = atoms.get(param);\n } else {\n for (const [key, value] of atoms) {\n if (areEqual(key, param)) {\n item = value;\n break;\n }\n }\n }\n if (item !== undefined) {\n if (shouldRemove == null ? undefined : shouldRemove(item[1], param)) {\n createAtom.remove(param);\n } else {\n return item[0];\n }\n }\n const newAtom = initializeAtom(param);\n atoms.set(param, [newAtom, Date.now()]);\n notifyListeners(\"CREATE\", param, newAtom);\n return newAtom;\n };\n function notifyListeners(type, param, atom) {\n for (const listener of listeners) {\n listener({ type, param, atom });\n }\n }\n createAtom.unstable_listen = (callback) => {\n listeners.add(callback);\n return () => {\n listeners.delete(callback);\n };\n };\n createAtom.getParams = () => atoms.keys();\n createAtom.remove = (param) => {\n if (areEqual === undefined) {\n if (!atoms.has(param)) return;\n const [atom] = atoms.get(param);\n atoms.delete(param);\n notifyListeners(\"REMOVE\", param, atom);\n } else {\n for (const [key, [atom]] of atoms) {\n if (areEqual(key, param)) {\n atoms.delete(key);\n notifyListeners(\"REMOVE\", key, atom);\n break;\n }\n }\n }\n };\n createAtom.setShouldRemove = (fn) => {\n shouldRemove = fn;\n if (!shouldRemove) return;\n for (const [key, [atom, createdAt]] of atoms) {\n if (shouldRemove(createdAt, key)) {\n atoms.delete(key);\n notifyListeners(\"REMOVE\", key, atom);\n }\n }\n };\n return createAtom;\n}\n\nconst getCached$2 = (c, m, k) => (m.has(k) ? m : m.set(k, c())).get(k);\nconst cache1$3 = /* @__PURE__ */ new WeakMap();\nconst memo3 = (create, dep1, dep2, dep3) => {\n const cache2 = getCached$2(() => /* @__PURE__ */ new WeakMap(), cache1$3, dep1);\n const cache3 = getCached$2(() => /* @__PURE__ */ new WeakMap(), cache2, dep2);\n return getCached$2(create, cache3, dep3);\n};\nfunction selectAtom(anAtom, selector, equalityFn = Object.is) {\n return memo3(\n () => {\n const EMPTY = Symbol();\n const selectValue = ([value, prevSlice]) => {\n if (prevSlice === EMPTY) {\n return selector(value);\n }\n const slice = selector(value, prevSlice);\n return equalityFn(prevSlice, slice) ? prevSlice : slice;\n };\n const derivedAtom = atom((get) => {\n const prev = get(derivedAtom);\n const value = get(anAtom);\n return selectValue([value, prev]);\n });\n derivedAtom.init = EMPTY;\n return derivedAtom;\n },\n anAtom,\n selector,\n equalityFn\n );\n}\n\nconst frozenAtoms = /* @__PURE__ */ new WeakSet();\nconst deepFreeze = (obj) => {\n if (typeof obj !== \"object\" || obj === null) return;\n Object.freeze(obj);\n const propNames = Object.getOwnPropertyNames(obj);\n for (const name of propNames) {\n const value = obj[name];\n deepFreeze(value);\n }\n return obj;\n};\nfunction freezeAtom(anAtom) {\n if (frozenAtoms.has(anAtom)) {\n return anAtom;\n }\n frozenAtoms.add(anAtom);\n const origRead = anAtom.read;\n anAtom.read = function(get, options) {\n return deepFreeze(origRead.call(this, get, options));\n };\n if (\"write\" in anAtom) {\n const origWrite = anAtom.write;\n anAtom.write = function(get, set, ...args) {\n return origWrite.call(\n this,\n get,\n (...setArgs) => {\n if (setArgs[0] === anAtom) {\n setArgs[1] = deepFreeze(setArgs[1]);\n }\n return set(...setArgs);\n },\n ...args\n );\n };\n }\n return anAtom;\n}\nfunction freezeAtomCreator(createAtom) {\n if ((import.meta.env ? import.meta.env.MODE : undefined) !== \"production\") {\n console.warn(\n \"[DEPRECATED] freezeAtomCreator is deprecated, define it on users end\"\n );\n }\n return (...args) => freezeAtom(createAtom(...args));\n}\n\nconst getCached$1 = (c, m, k) => (m.has(k) ? m : m.set(k, c())).get(k);\nconst cache1$2 = /* @__PURE__ */ new WeakMap();\nconst memo2$1 = (create, dep1, dep2) => {\n const cache2 = getCached$1(() => /* @__PURE__ */ new WeakMap(), cache1$2, dep1);\n return getCached$1(create, cache2, dep2);\n};\nconst cacheKeyForEmptyKeyExtractor = {};\nconst isWritable = (atom2) => !!atom2.write;\nconst isFunction = (x) => typeof x === \"function\";\nfunction splitAtom(arrAtom, keyExtractor) {\n return memo2$1(\n () => {\n const mappingCache = /* @__PURE__ */ new WeakMap();\n const getMapping = (arr, prev) => {\n let mapping = mappingCache.get(arr);\n if (mapping) {\n return mapping;\n }\n const prevMapping = prev && mappingCache.get(prev);\n const atomList = [];\n const keyList = [];\n arr.forEach((item, index) => {\n const key = keyExtractor ? keyExtractor(item) : index;\n keyList[index] = key;\n const cachedAtom = prevMapping && prevMapping.atomList[prevMapping.keyList.indexOf(key)];\n if (cachedAtom) {\n atomList[index] = cachedAtom;\n return;\n }\n const read = (get) => {\n const prev2 = get(mappingAtom);\n const currArr = get(arrAtom);\n const mapping2 = getMapping(currArr, prev2 == null ? undefined : prev2.arr);\n const index2 = mapping2.keyList.indexOf(key);\n if (index2 < 0 || index2 >= currArr.length) {\n const prevItem = arr[getMapping(arr).keyList.indexOf(key)];\n if (prevItem) {\n return prevItem;\n }\n throw new Error(\"splitAtom: index out of bounds for read\");\n }\n return currArr[index2];\n };\n const write = (get, set, update) => {\n const prev2 = get(mappingAtom);\n const arr2 = get(arrAtom);\n const mapping2 = getMapping(arr2, prev2 == null ? undefined : prev2.arr);\n const index2 = mapping2.keyList.indexOf(key);\n if (index2 < 0 || index2 >= arr2.length) {\n throw new Error(\"splitAtom: index out of bounds for write\");\n }\n const nextItem = isFunction(update) ? update(arr2[index2]) : update;\n if (!Object.is(arr2[index2], nextItem)) {\n set(arrAtom, [\n ...arr2.slice(0, index2),\n nextItem,\n ...arr2.slice(index2 + 1)\n ]);\n }\n };\n atomList[index] = isWritable(arrAtom) ? atom(read, write) : atom(read);\n });\n if (prevMapping && prevMapping.keyList.length === keyList.length && prevMapping.keyList.every((x, i) => x === keyList[i])) {\n mapping = prevMapping;\n } else {\n mapping = { arr, atomList, keyList };\n }\n mappingCache.set(arr, mapping);\n return mapping;\n };\n const mappingAtom = atom((get) => {\n const prev = get(mappingAtom);\n const arr = get(arrAtom);\n const mapping = getMapping(arr, prev == null ? undefined : prev.arr);\n return mapping;\n });\n if ((import.meta.env ? import.meta.env.MODE : undefined) !== \"production\") {\n mappingAtom.debugPrivate = true;\n }\n mappingAtom.init = undefined;\n const splittedAtom = isWritable(arrAtom) ? atom(\n (get) => get(mappingAtom).atomList,\n (get, set, action) => {\n switch (action.type) {\n case \"remove\": {\n const index = get(splittedAtom).indexOf(action.atom);\n if (index >= 0) {\n const arr = get(arrAtom);\n set(arrAtom, [\n ...arr.slice(0, index),\n ...arr.slice(index + 1)\n ]);\n }\n break;\n }\n case \"insert\": {\n const index = action.before ? get(splittedAtom).indexOf(action.before) : get(splittedAtom).length;\n if (index >= 0) {\n const arr = get(arrAtom);\n set(arrAtom, [\n ...arr.slice(0, index),\n action.value,\n ...arr.slice(index)\n ]);\n }\n break;\n }\n case \"move\": {\n const index1 = get(splittedAtom).indexOf(action.atom);\n const index2 = action.before ? get(splittedAtom).indexOf(action.before) : get(splittedAtom).length;\n if (index1 >= 0 && index2 >= 0) {\n const arr = get(arrAtom);\n if (index1 < index2) {\n set(arrAtom, [\n ...arr.slice(0, index1),\n ...arr.slice(index1 + 1, index2),\n arr[index1],\n ...arr.slice(index2)\n ]);\n } else {\n set(arrAtom, [\n ...arr.slice(0, index2),\n arr[index1],\n ...arr.slice(index2, index1),\n ...arr.slice(index1 + 1)\n ]);\n }\n }\n break;\n }\n }\n }\n ) : atom((get) => get(mappingAtom).atomList);\n return splittedAtom;\n },\n arrAtom,\n keyExtractor || cacheKeyForEmptyKeyExtractor\n );\n}\n\nfunction atomWithDefault(getDefault) {\n const EMPTY = Symbol();\n const overwrittenAtom = atom(EMPTY);\n if ((import.meta.env ? import.meta.env.MODE : undefined) !== \"production\") {\n overwrittenAtom.debugPrivate = true;\n }\n const anAtom = atom(\n (get, options) => {\n const overwritten = get(overwrittenAtom);\n if (overwritten !== EMPTY) {\n return overwritten;\n }\n return getDefault(get, options);\n },\n (get, set, update) => {\n if (update === RESET) {\n set(overwrittenAtom, EMPTY);\n } else if (typeof update === \"function\") {\n const prevValue = get(anAtom);\n set(overwrittenAtom, update(prevValue));\n } else {\n set(overwrittenAtom, update);\n }\n }\n );\n return anAtom;\n}\n\nconst isPromiseLike = (x) => typeof (x == null ? undefined : x.then) === \"function\";\nfunction withStorageValidator(validator) {\n return (unknownStorage) => {\n const storage = {\n ...unknownStorage,\n getItem: (key, initialValue) => {\n const validate = (value2) => {\n if (!validator(value2)) {\n return initialValue;\n }\n return value2;\n };\n const value = unknownStorage.getItem(key, initialValue);\n if (isPromiseLike(value)) {\n return value.then(validate);\n }\n return validate(value);\n }\n };\n return storage;\n };\n}\nfunction createJSONStorage(getStringStorage = () => {\n try {\n return window.localStorage;\n } catch (e) {\n if ((import.meta.env ? import.meta.env.MODE : undefined) !== \"production\") {\n if (typeof window !== \"undefined\") {\n console.warn(e);\n }\n }\n return undefined;\n }\n}, options) {\n var _a;\n let lastStr;\n let lastValue;\n const storage = {\n getItem: (key, initialValue) => {\n var _a2, _b;\n const parse = (str2) => {\n str2 = str2 || \"\";\n if (lastStr !== str2) {\n try {\n lastValue = JSON.parse(str2, options == null ? void 0 : options.reviver);\n } catch (e) {\n return initialValue;\n }\n lastStr = str2;\n }\n return lastValue;\n };\n const str = (_b = (_a2 = getStringStorage()) == null ? undefined : _a2.getItem(key)) != null ? _b : null;\n if (isPromiseLike(str)) {\n return str.then(parse);\n }\n return parse(str);\n },\n setItem: (key, newValue) => {\n var _a2;\n return (_a2 = getStringStorage()) == null ? undefined : _a2.setItem(\n key,\n JSON.stringify(newValue, options == null ? undefined : options.replacer)\n );\n },\n removeItem: (key) => {\n var _a2;\n return (_a2 = getStringStorage()) == null ? undefined : _a2.removeItem(key);\n }\n };\n const createHandleSubscribe = (subscriber2) => (key, callback, initialValue) => subscriber2(key, (v) => {\n let newValue;\n try {\n newValue = JSON.parse(v || \"\");\n } catch (e) {\n newValue = initialValue;\n }\n callback(newValue);\n });\n let subscriber;\n try {\n subscriber = (_a = getStringStorage()) == null ? void 0 : _a.subscribe;\n } catch (e) {\n }\n if (!subscriber && typeof window !== \"undefined\" && typeof window.addEventListener === \"function\" && window.Storage) {\n subscriber = (key, callback) => {\n if (!(getStringStorage() instanceof window.Storage)) {\n return () => {\n };\n }\n const storageEventCallback = (e) => {\n if (e.storageArea === getStringStorage() && e.key === key) {\n callback(e.newValue);\n }\n };\n window.addEventListener(\"storage\", storageEventCallback);\n return () => {\n window.removeEventListener(\"storage\", storageEventCallback);\n };\n };\n }\n if (subscriber) {\n storage.subscribe = createHandleSubscribe(subscriber);\n }\n return storage;\n}\nconst defaultStorage = createJSONStorage();\nfunction atomWithStorage(key, initialValue, storage = defaultStorage, options) {\n const getOnInit = options == null ? undefined : options.getOnInit;\n const baseAtom = atom(\n getOnInit ? storage.getItem(key, initialValue) : initialValue\n );\n if ((import.meta.env ? import.meta.env.MODE : undefined) !== \"production\") {\n baseAtom.debugPrivate = true;\n }\n baseAtom.onMount = (setAtom) => {\n setAtom(storage.getItem(key, initialValue));\n let unsub;\n if (storage.subscribe) {\n unsub = storage.subscribe(key, setAtom, initialValue);\n }\n return unsub;\n };\n const anAtom = atom(\n (get) => get(baseAtom),\n (get, set, update) => {\n const nextValue = typeof update === \"function\" ? update(get(baseAtom)) : update;\n if (nextValue === RESET) {\n set(baseAtom, initialValue);\n return storage.removeItem(key);\n }\n if (nextValue instanceof Promise) {\n return nextValue.then((resolvedValue) => {\n set(baseAtom, resolvedValue);\n return storage.setItem(key, resolvedValue);\n });\n }\n set(baseAtom, nextValue);\n return storage.setItem(key, nextValue);\n }\n );\n return anAtom;\n}\n\nfunction atomWithObservable(getObservable, options) {\n const returnResultData = (result) => {\n if (\"e\" in result) {\n throw result.e;\n }\n return result.d;\n };\n const observableResultAtom = atom((get) => {\n var _a;\n let observable = getObservable(get);\n const itself = (_a = observable[Symbol.observable]) == null ? undefined : _a.call(observable);\n if (itself) {\n observable = itself;\n }\n let resolve;\n const makePending = () => new Promise((r) => {\n resolve = r;\n });\n const initialResult = options && \"initialValue\" in options ? {\n d: typeof options.initialValue === \"function\" ? options.initialValue() : options.initialValue\n } : makePending();\n let setResult;\n let lastResult;\n const listener = (result) => {\n lastResult = result;\n resolve == null ? undefined : resolve(result);\n setResult == null ? undefined : setResult(result);\n };\n let subscription;\n let timer;\n const isNotMounted = () => !setResult;\n const start = () => {\n if (subscription) {\n clearTimeout(timer);\n subscription.unsubscribe();\n }\n subscription = observable.subscribe({\n next: (d) => listener({ d }),\n error: (e) => listener({ e }),\n complete: () => {\n }\n });\n if (isNotMounted() && (options == null ? undefined : options.unstable_timeout)) {\n timer = setTimeout(() => {\n if (subscription) {\n subscription.unsubscribe();\n subscription = undefined;\n }\n }, options.unstable_timeout);\n }\n };\n start();\n const resultAtom = atom(lastResult || initialResult);\n if ((import.meta.env ? import.meta.env.MODE : undefined) !== \"production\") {\n resultAtom.debugPrivate = true;\n }\n resultAtom.onMount = (update) => {\n setResult = update;\n if (lastResult) {\n update(lastResult);\n }\n if (subscription) {\n clearTimeout(timer);\n } else {\n start();\n }\n return () => {\n setResult = undefined;\n if (subscription) {\n subscription.unsubscribe();\n subscription = undefined;\n }\n };\n };\n return [resultAtom, observable, makePending, start, isNotMounted];\n });\n if ((import.meta.env ? import.meta.env.MODE : undefined) !== \"production\") {\n observableResultAtom.debugPrivate = true;\n }\n const observableAtom = atom(\n (get) => {\n const [resultAtom] = get(observableResultAtom);\n const result = get(resultAtom);\n if (result instanceof Promise) {\n return result.then(returnResultData);\n }\n return returnResultData(result);\n },\n (get, set, data) => {\n const [resultAtom, observable, makePending, start, isNotMounted] = get(observableResultAtom);\n if (\"next\" in observable) {\n if (isNotMounted()) {\n set(resultAtom, makePending());\n start();\n }\n observable.next(data);\n } else {\n throw new Error(\"observable is not subject\");\n }\n }\n );\n return observableAtom;\n}\n\nconst cache1$1 = /* @__PURE__ */ new WeakMap();\nconst memo1 = (create, dep1) => (cache1$1.has(dep1) ? cache1$1 : cache1$1.set(dep1, create())).get(dep1);\nconst isPromise$1 = (x) => x instanceof Promise;\nconst LOADING = { state: \"loading\" };\nfunction loadable(anAtom) {\n return memo1(() => {\n const loadableCache = /* @__PURE__ */ new WeakMap();\n const refreshAtom = atom(0);\n if ((import.meta.env ? import.meta.env.MODE : undefined) !== \"production\") {\n refreshAtom.debugPrivate = true;\n }\n const derivedAtom = atom(\n (get, { setSelf }) => {\n get(refreshAtom);\n let value;\n try {\n value = get(anAtom);\n } catch (error) {\n return { state: \"hasError\", error };\n }\n if (!isPromise$1(value)) {\n return { state: \"hasData\", data: value };\n }\n const promise = value;\n const cached1 = loadableCache.get(promise);\n if (cached1) {\n return cached1;\n }\n promise.then(\n (data) => {\n loadableCache.set(promise, { state: \"hasData\", data });\n setSelf();\n },\n (error) => {\n loadableCache.set(promise, { state: \"hasError\", error });\n setSelf();\n }\n );\n const cached2 = loadableCache.get(promise);\n if (cached2) {\n return cached2;\n }\n loadableCache.set(promise, LOADING);\n return LOADING;\n },\n (_get, set) => {\n set(refreshAtom, (c) => c + 1);\n }\n );\n if ((import.meta.env ? import.meta.env.MODE : undefined) !== \"production\") {\n derivedAtom.debugPrivate = true;\n }\n return atom((get) => get(derivedAtom));\n }, anAtom);\n}\n\nconst getCached = (c, m, k) => (m.has(k) ? m : m.set(k, c())).get(k);\nconst cache1 = /* @__PURE__ */ new WeakMap();\nconst memo2 = (create, dep1, dep2) => {\n const cache2 = getCached(() => /* @__PURE__ */ new WeakMap(), cache1, dep1);\n return getCached(create, cache2, dep2);\n};\nconst isPromise = (x) => x instanceof Promise;\nconst defaultFallback = () => undefined;\nfunction unwrap(anAtom, fallback = defaultFallback) {\n return memo2(\n () => {\n const promiseErrorCache = /* @__PURE__ */ new WeakMap();\n const promiseResultCache = /* @__PURE__ */ new WeakMap();\n const refreshAtom = atom(0);\n if ((import.meta.env ? import.meta.env.MODE : undefined) !== \"production\") {\n refreshAtom.debugPrivate = true;\n }\n const promiseAndValueAtom = atom(\n (get, { setSelf }) => {\n get(refreshAtom);\n const prev = get(promiseAndValueAtom);\n const promise = get(anAtom);\n if (!isPromise(promise)) {\n return { v: promise };\n }\n if (promise !== (prev == null ? undefined : prev.p)) {\n promise.then(\n (v) => {\n promiseResultCache.set(promise, v);\n setSelf();\n },\n (e) => {\n promiseErrorCache.set(promise, e);\n setSelf();\n }\n );\n }\n if (promiseErrorCache.has(promise)) {\n throw promiseErrorCache.get(promise);\n }\n if (promiseResultCache.has(promise)) {\n return {\n p: promise,\n v: promiseResultCache.get(promise)\n };\n }\n if (prev && \"v\" in prev) {\n return { p: promise, f: fallback(prev.v), v: prev.v };\n }\n return { p: promise, f: fallback() };\n },\n (_get, set) => {\n set(refreshAtom, (c) => c + 1);\n }\n );\n promiseAndValueAtom.init = undefined;\n if ((import.meta.env ? import.meta.env.MODE : undefined) !== \"production\") {\n promiseAndValueAtom.debugPrivate = true;\n }\n return atom(\n (get) => {\n const state = get(promiseAndValueAtom);\n if (\"f\" in state) {\n return state.f;\n }\n return state.v;\n },\n (_get, set, ...args) => set(anAtom, ...args)\n );\n },\n anAtom,\n fallback\n );\n}\n\nfunction atomWithRefresh(read, write) {\n const refreshAtom = atom(0);\n if ((import.meta.env ? import.meta.env.MODE : undefined) !== \"production\") {\n refreshAtom.debugPrivate = true;\n }\n return atom(\n (get, options) => {\n get(refreshAtom);\n return read(get, options);\n },\n (get, set, ...args) => {\n if (args.length === 0) {\n set(refreshAtom, (c) => c + 1);\n } else if (write) {\n return write(get, set, ...args);\n }\n }\n );\n}\n\nfunction atomWithLazy(makeInitial) {\n const a = atom(undefined);\n delete a.init;\n Object.defineProperty(a, \"init\", {\n get() {\n return makeInitial();\n }\n });\n return a;\n}\n\nexport { RESET, atomFamily, atomWithDefault, atomWithLazy, atomWithObservable, atomWithReducer, atomWithRefresh, atomWithReset, atomWithStorage, createJSONStorage, freezeAtom, freezeAtomCreator, loadable, selectAtom, splitAtom, withStorageValidator as unstable_withStorageValidator, unwrap };\n"],
5
- "mappings": ";;;;;;;;;AAAA,SAAS,SAAS,mBAAmB;;;ACErC,IAAM,QAAQ;AAAA,GACX,YAAY,MAAM,YAAY,IAAI,OAAO,YAAe,eAAe,UAAU;AACpF;AAmBA,SAAS,WAAW,gBAAgB,UAAU;AAC5C,MAAI,eAAe;AACnB,QAAM,QAAwB,oBAAI,IAAI;AACtC,QAAM,YAA4B,oBAAI,IAAI;AAC1C,QAAM,aAAa,CAAC,UAAU;AAC5B,QAAI;AACJ,QAAI,aAAa,QAAW;AAC1B,aAAO,MAAM,IAAI,KAAK;AAAA,IACxB,OAAO;AACL,iBAAW,CAAC,KAAK,KAAK,KAAK,OAAO;AAChC,YAAI,SAAS,KAAK,KAAK,GAAG;AACxB,iBAAO;AACP;AAAA,QACF;AAAA,MACF;AAAA,IACF;AACA,QAAI,SAAS,QAAW;AACtB,UAAI,gBAAgB,OAAO,SAAY,aAAa,KAAK,CAAC,GAAG,KAAK,GAAG;AACnE,mBAAW,OAAO,KAAK;AAAA,MACzB,OAAO;AACL,eAAO,KAAK,CAAC;AAAA,MACf;AAAA,IACF;AACA,UA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;AAAA,IAChC,CAAC;AACD,UAAM,SAAS,QAAQ,GAAG,gBAAgB,MAAM,sBAAsB,CAAC;AACvE,UAAM,mBAAmB,QAAQ,GAAG,sBAAsB,mBAAmB,mBAAmB;AAChG,UAAM,SAAS,QAAQ,GAAG,sBAAsB,MAAM,sBAAsB,CAAC;AAC7E,WAAO,MAAM;AACT,aAAO;AACP,aAAO;AACP,uBAAiB;AACjB,aAAO;AAAA,IACX;AAAA,EACJ,GAAG,CAAC,SAAS,qBAAqB,CAAC;AACnC,SAAO,QAAQ,MAAM;AAAA,IACjB;AAAA,IACA;AAAA,IACA;AAAA,IACA;AAAA,EACJ,GAAG,CAAC,gBAAgB,MAAM,CAAC;AAC/B;",
6
- "names": ["atom", "documentDrives"]
7
- }
@@ -1,7 +0,0 @@
1
- {
2
- "version": 3,
3
- "sources": ["../../../../../../node_modules/.pnpm/jotai@2.11.1_@types+react@18.3.18_react@18.3.1/node_modules/jotai/esm/vanilla.mjs", "../../../../../../node_modules/.pnpm/jotai@2.11.1_@types+react@18.3.18_react@18.3.1/node_modules/jotai/esm/react.mjs"],
4
- "sourcesContent": ["let keyCount = 0;\nfunction atom(read, write) {\n const key = `atom${++keyCount}`;\n const config = {\n toString() {\n return (import.meta.env ? import.meta.env.MODE : undefined) !== \"production\" && this.debugLabel ? key + \":\" + this.debugLabel : key;\n }\n };\n if (typeof read === \"function\") {\n config.read = read;\n } else {\n config.init = read;\n config.read = defaultRead;\n config.write = defaultWrite;\n }\n if (write) {\n config.write = write;\n }\n return config;\n}\nfunction defaultRead(get) {\n return get(this);\n}\nfunction defaultWrite(get, set, arg) {\n return set(\n this,\n typeof arg === \"function\" ? arg(get(this)) : arg\n );\n}\n\nconst isSelfAtom = (atom, a) => atom.unstable_is ? atom.unstable_is(a) : a === atom;\nconst hasInitialValue = (atom) => \"init\" in atom;\nconst isActuallyWritableAtom = (atom) => !!atom.write;\nconst cancelablePromiseMap = /* @__PURE__ */ new WeakMap();\nconst isPendingPromise = (value) => {\n var _a;\n return isPromiseLike(value) && !((_a = cancelablePromiseMap.get(value)) == null ? undefined : _a[1]);\n};\nconst cancelPromise = (promise, nextValue) => {\n const promiseState = cancelablePromiseMap.get(promise);\n if (promiseState) {\n promiseState[1] = true;\n promiseState[0].forEach((fn) => fn(nextValue));\n } else if ((import.meta.env ? import.meta.env.MODE : undefined) !== \"production\") {\n throw new Error(\"[Bug] cancelable promise not found\");\n }\n};\nconst patchPromiseForCancelability = (promise) => {\n if (cancelablePromiseMap.has(promise)) {\n return;\n }\n const promiseState = [/* @__PURE__ */ new Set(), false];\n cancelablePromiseMap.set(promise, promiseState);\n const settle = () => {\n promiseState[1] = true;\n };\n promise.then(settle, settle);\n promise.onCancel = (fn) => {\n promiseState[0].add(fn);\n };\n};\nconst isPromiseLike = (p) => typeof (p == null ? undefined : p.then) === \"function\";\nconst isAtomStateInitialized = (atomState) => \"v\" in atomState || \"e\" in atomState;\nconst returnAtomValue = (atomState) => {\n if (\"e\" in atomState) {\n throw atomState.e;\n }\n if ((import.meta.env ? import.meta.env.MODE : undefined) !== \"production\" && !(\"v\" in atomState)) {\n throw new Error(\"[Bug] atom state is not initialized\");\n }\n return atomState.v;\n};\nconst addPendingPromiseToDependency = (atom, promise, dependencyAtomState) => {\n if (!dependencyAtomState.p.has(atom)) {\n dependencyAtomState.p.add(atom);\n promise.then(\n () => {\n dependencyAtomState.p.delete(atom);\n },\n () => {\n dependencyAtomState.p.delete(atom);\n }\n );\n }\n};\nconst addDependency = (atom, atomState, a, aState) => {\n var _a;\n if ((import.meta.env ? import.meta.env.MODE : undefined) !== \"production\" && a === atom) {\n throw new Error(\"[Bug] atom cannot depend on itself\");\n }\n atomState.d.set(a, aState.n);\n if (isPendingPromise(atomState.v)) {\n addPendingPromiseToDependency(atom, atomState.v, aState);\n }\n (_a = aState.m) == null ? undefined : _a.t.add(atom);\n};\nconst INTERNAL_flushStoreHook = Symbol.for(\"JOTAI.EXPERIMENTAL.FLUSHSTOREHOOK\");\nconst buildStore = (...storeArgs) => {\n const [\n getAtomState,\n setAtomState,\n atomRead,\n atomWrite,\n atomOnInit,\n atomOnMount\n ] = storeArgs;\n const ensureAtomState = (atom) => {\n if ((import.meta.env ? import.meta.env.MODE : undefined) !== \"production\" && !atom) {\n throw new Error(\"Atom is undefined or null\");\n }\n let atomState = getAtomState(atom);\n if (!atomState) {\n atomState = { d: /* @__PURE__ */ new Map(), p: /* @__PURE__ */ new Set(), n: 0 };\n setAtomState(atom, atomState);\n atomOnInit == null ? undefined : atomOnInit(atom, store);\n }\n return atomState;\n };\n const invalidatedAtoms = /* @__PURE__ */ new WeakMap();\n const changedAtoms = /* @__PURE__ */ new Map();\n const unmountCallbacks = /* @__PURE__ */ new Set();\n const mountCallbacks = /* @__PURE__ */ new Set();\n const flushCallbacks = () => {\n var _a;\n const errors = [];\n const call = (fn) => {\n try {\n fn();\n } catch (e) {\n errors.push(e);\n }\n };\n do {\n (_a = store[INTERNAL_flushStoreHook]) == null ? undefined : _a.call(store);\n const callbacks = /* @__PURE__ */ new Set();\n const add = callbacks.add.bind(callbacks);\n changedAtoms.forEach((atomState) => {\n var _a2;\n return (_a2 = atomState.m) == null ? undefined : _a2.l.forEach(add);\n });\n changedAtoms.clear();\n unmountCallbacks.forEach(add);\n unmountCallbacks.clear();\n mountCallbacks.forEach(add);\n mountCallbacks.clear();\n callbacks.forEach(call);\n if (changedAtoms.size) {\n recomputeInvalidatedAtoms();\n }\n } while (changedAtoms.size || unmountCallbacks.size || mountCallbacks.size);\n if (errors.length) {\n throw errors[0];\n }\n };\n const setAtomStateValueOrPromise = (atom, atomState, valueOrPromise) => {\n const hasPrevValue = \"v\" in atomState;\n const prevValue = atomState.v;\n const pendingPromise = isPendingPromise(atomState.v) ? atomState.v : null;\n if (isPromiseLike(valueOrPromise)) {\n patchPromiseForCancelability(valueOrPromise);\n for (const a of atomState.d.keys()) {\n addPendingPromiseToDependency(atom, valueOrPromise, ensureAtomState(a));\n }\n atomState.v = valueOrPromise;\n } else {\n atomState.v = valueOrPromise;\n }\n delete atomState.e;\n if (!hasPrevValue || !Object.is(prevValue, atomState.v)) {\n ++atomState.n;\n if (pendingPromise) {\n cancelPromise(pendingPromise, valueOrPromise);\n }\n }\n };\n const readAtomState = (atom) => {\n var _a;\n const atomState = ensureAtomState(atom);\n if (isAtomStateInitialized(atomState)) {\n if (atomState.m && invalidatedAtoms.get(atom) !== atomState.n) {\n return atomState;\n }\n if (Array.from(atomState.d).every(\n ([a, n]) => (\n // Recursively, read the atom state of the dependency, and\n // check if the atom epoch number is unchanged\n readAtomState(a).n === n\n )\n )) {\n return atomState;\n }\n }\n atomState.d.clear();\n let isSync = true;\n const mountDependenciesIfAsync = () => {\n if (atomState.m) {\n mountDependencies(atom, atomState);\n recomputeInvalidatedAtoms();\n flushCallbacks();\n }\n };\n const getter = (a) => {\n if (isSelfAtom(atom, a)) {\n const aState2 = ensureAtomState(a);\n if (!isAtomStateInitialized(aState2)) {\n if (hasInitialValue(a)) {\n setAtomStateValueOrPromise(a, aState2, a.init);\n } else {\n throw new Error(\"no atom init\");\n }\n }\n return returnAtomValue(aState2);\n }\n const aState = readAtomState(a);\n try {\n return returnAtomValue(aState);\n } finally {\n addDependency(atom, atomState, a, aState);\n if (!isSync) {\n mountDependenciesIfAsync();\n }\n }\n };\n let controller;\n let setSelf;\n const options = {\n get signal() {\n if (!controller) {\n controller = new AbortController();\n }\n return controller.signal;\n },\n get setSelf() {\n if ((import.meta.env ? import.meta.env.MODE : undefined) !== \"production\" && !isActuallyWritableAtom(atom)) {\n console.warn(\"setSelf function cannot be used with read-only atom\");\n }\n if (!setSelf && isActuallyWritableAtom(atom)) {\n setSelf = (...args) => {\n if ((import.meta.env ? import.meta.env.MODE : undefined) !== \"production\" && isSync) {\n console.warn(\"setSelf function cannot be called in sync\");\n }\n if (!isSync) {\n return writeAtom(atom, ...args);\n }\n };\n }\n return setSelf;\n }\n };\n try {\n const valueOrPromise = atomRead(atom, getter, options);\n setAtomStateValueOrPromise(atom, atomState, valueOrPromise);\n if (isPromiseLike(valueOrPromise)) {\n (_a = valueOrPromise.onCancel) == null ? void 0 : _a.call(valueOrPromise, () => controller == null ? void 0 : controller.abort());\n valueOrPromise.then(mountDependenciesIfAsync, mountDependenciesIfAsync);\n }\n return atomState;\n } catch (error) {\n delete atomState.v;\n atomState.e = error;\n ++atomState.n;\n return atomState;\n } finally {\n isSync = false;\n }\n };\n const readAtom = (atom) => returnAtomValue(readAtomState(atom));\n const getMountedOrPendingDependents = (atomState) => {\n var _a;\n const dependents = /* @__PURE__ */ new Map();\n for (const a of ((_a = atomState.m) == null ? undefined : _a.t) || []) {\n const aState = ensureAtomState(a);\n if (aState.m) {\n dependents.set(a, aState);\n }\n }\n for (const atomWithPendingPromise of atomState.p) {\n dependents.set(\n atomWithPendingPromise,\n ensureAtomState(atomWithPendingPromise)\n );\n }\n return dependents;\n };\n const invalidateDependents = (atomState) => {\n const stack = [atomState];\n while (stack.length) {\n const aState = stack.pop();\n for (const [d, s] of getMountedOrPendingDependents(aState)) {\n if (!invalidatedAtoms.has(d)) {\n invalidatedAtoms.set(d, s.n);\n stack.push(s);\n }\n }\n }\n };\n const recomputeInvalidatedAtoms = () => {\n var _a;\n const topSortedReversed = [];\n const visiting = /* @__PURE__ */ new WeakSet();\n const visited = /* @__PURE__ */ new WeakSet();\n const stack = Array.from(changedAtoms);\n while (stack.length) {\n const [a, aState] = stack[stack.length - 1];\n if (visited.has(a)) {\n stack.pop();\n continue;\n }\n if (visiting.has(a)) {\n if (invalidatedAtoms.get(a) === aState.n) {\n topSortedReversed.push([a, aState, aState.n]);\n } else {\n invalidatedAtoms.delete(a);\n changedAtoms.set(a, aState);\n }\n visited.add(a);\n stack.pop();\n continue;\n }\n visiting.add(a);\n for (const [d, s] of getMountedOrPendingDependents(aState)) {\n if (!visiting.has(d)) {\n stack.push([d, s]);\n }\n }\n }\n for (let i = topSortedReversed.length - 1; i >= 0; --i) {\n const [a, aState, prevEpochNumber] = topSortedReversed[i];\n let hasChangedDeps = false;\n for (const dep of aState.d.keys()) {\n if (dep !== a && changedAtoms.has(dep)) {\n hasChangedDeps = true;\n break;\n }\n }\n if (hasChangedDeps) {\n readAtomState(a);\n mountDependencies(a, aState);\n if (prevEpochNumber !== aState.n) {\n changedAtoms.set(a, aState);\n (_a = aState.u) == null ? undefined : _a.call(aState);\n }\n }\n invalidatedAtoms.delete(a);\n }\n };\n const writeAtomState = (atom, ...args) => {\n let isSync = true;\n const getter = (a) => returnAtomValue(readAtomState(a));\n const setter = (a, ...args2) => {\n var _a;\n const aState = ensureAtomState(a);\n try {\n if (isSelfAtom(atom, a)) {\n if (!hasInitialValue(a)) {\n throw new Error(\"atom not writable\");\n }\n const prevEpochNumber = aState.n;\n const v = args2[0];\n setAtomStateValueOrPromise(a, aState, v);\n mountDependencies(a, aState);\n if (prevEpochNumber !== aState.n) {\n changedAtoms.set(a, aState);\n (_a = aState.u) == null ? void 0 : _a.call(aState);\n invalidateDependents(aState);\n }\n return void 0;\n } else {\n return writeAtomState(a, ...args2);\n }\n } finally {\n if (!isSync) {\n recomputeInvalidatedAtoms();\n flushCallbacks();\n }\n }\n };\n try {\n return atomWrite(atom, getter, setter, ...args);\n } finally {\n isSync = false;\n }\n };\n const writeAtom = (atom, ...args) => {\n try {\n return writeAtomState(atom, ...args);\n } finally {\n recomputeInvalidatedAtoms();\n flushCallbacks();\n }\n };\n const mountDependencies = (atom, atomState) => {\n var _a;\n if (atomState.m && !isPendingPromise(atomState.v)) {\n for (const [a, n] of atomState.d) {\n if (!atomState.m.d.has(a)) {\n const aState = ensureAtomState(a);\n const aMounted = mountAtom(a, aState);\n aMounted.t.add(atom);\n atomState.m.d.add(a);\n if (n !== aState.n) {\n changedAtoms.set(a, aState);\n (_a = aState.u) == null ? undefined : _a.call(aState);\n invalidateDependents(aState);\n }\n }\n }\n for (const a of atomState.m.d || []) {\n if (!atomState.d.has(a)) {\n atomState.m.d.delete(a);\n const aMounted = unmountAtom(a, ensureAtomState(a));\n aMounted == null ? undefined : aMounted.t.delete(atom);\n }\n }\n }\n };\n const mountAtom = (atom, atomState) => {\n var _a;\n if (!atomState.m) {\n readAtomState(atom);\n for (const a of atomState.d.keys()) {\n const aMounted = mountAtom(a, ensureAtomState(a));\n aMounted.t.add(atom);\n }\n atomState.m = {\n l: /* @__PURE__ */ new Set(),\n d: new Set(atomState.d.keys()),\n t: /* @__PURE__ */ new Set()\n };\n (_a = atomState.h) == null ? undefined : _a.call(atomState);\n if (isActuallyWritableAtom(atom)) {\n const mounted = atomState.m;\n const processOnMount = () => {\n let isSync = true;\n const setAtom = (...args) => {\n try {\n return writeAtomState(atom, ...args);\n } finally {\n if (!isSync) {\n recomputeInvalidatedAtoms();\n flushCallbacks();\n }\n }\n };\n try {\n const onUnmount = atomOnMount(atom, setAtom);\n if (onUnmount) {\n mounted.u = () => {\n isSync = true;\n try {\n onUnmount();\n } finally {\n isSync = false;\n }\n };\n }\n } finally {\n isSync = false;\n }\n };\n mountCallbacks.add(processOnMount);\n }\n }\n return atomState.m;\n };\n const unmountAtom = (atom, atomState) => {\n var _a;\n if (atomState.m && !atomState.m.l.size && !Array.from(atomState.m.t).some((a) => {\n var _a2;\n return (_a2 = ensureAtomState(a).m) == null ? undefined : _a2.d.has(atom);\n })) {\n const onUnmount = atomState.m.u;\n if (onUnmount) {\n unmountCallbacks.add(onUnmount);\n }\n delete atomState.m;\n (_a = atomState.h) == null ? undefined : _a.call(atomState);\n for (const a of atomState.d.keys()) {\n const aMounted = unmountAtom(a, ensureAtomState(a));\n aMounted == null ? undefined : aMounted.t.delete(atom);\n }\n return undefined;\n }\n return atomState.m;\n };\n const subscribeAtom = (atom, listener) => {\n const atomState = ensureAtomState(atom);\n const mounted = mountAtom(atom, atomState);\n const listeners = mounted.l;\n listeners.add(listener);\n flushCallbacks();\n return () => {\n listeners.delete(listener);\n unmountAtom(atom, atomState);\n flushCallbacks();\n };\n };\n const unstable_derive = (fn) => buildStore(...fn(...storeArgs));\n const store = {\n get: readAtom,\n set: writeAtom,\n sub: subscribeAtom,\n unstable_derive\n };\n return store;\n};\nconst deriveDevStoreRev4 = (store) => {\n const debugMountedAtoms = /* @__PURE__ */ new Set();\n let savedGetAtomState;\n let inRestoreAtom = 0;\n const derivedStore = store.unstable_derive((...storeArgs) => {\n const [getAtomState, setAtomState, , atomWrite] = storeArgs;\n savedGetAtomState = getAtomState;\n storeArgs[1] = function devSetAtomState(atom, atomState) {\n setAtomState(atom, atomState);\n const originalMounted = atomState.h;\n atomState.h = () => {\n originalMounted == null ? undefined : originalMounted();\n if (atomState.m) {\n debugMountedAtoms.add(atom);\n } else {\n debugMountedAtoms.delete(atom);\n }\n };\n };\n storeArgs[3] = function devAtomWrite(atom, getter, setter, ...args) {\n if (inRestoreAtom) {\n return setter(atom, ...args);\n }\n return atomWrite(atom, getter, setter, ...args);\n };\n return storeArgs;\n });\n const savedStoreSet = derivedStore.set;\n const devStore = {\n // store dev methods (these are tentative and subject to change without notice)\n dev4_get_internal_weak_map: () => ({\n get: (atom) => {\n const atomState = savedGetAtomState(atom);\n if (!atomState || atomState.n === 0) {\n return undefined;\n }\n return atomState;\n }\n }),\n dev4_get_mounted_atoms: () => debugMountedAtoms,\n dev4_restore_atoms: (values) => {\n const restoreAtom = {\n read: () => null,\n write: (_get, set) => {\n ++inRestoreAtom;\n try {\n for (const [atom, value] of values) {\n if (hasInitialValue(atom)) {\n set(atom, value);\n }\n }\n } finally {\n --inRestoreAtom;\n }\n }\n };\n savedStoreSet(restoreAtom);\n }\n };\n return Object.assign(derivedStore, devStore);\n};\nconst createStore = () => {\n const atomStateMap = /* @__PURE__ */ new WeakMap();\n const store = buildStore(\n (atom) => atomStateMap.get(atom),\n (atom, atomState) => atomStateMap.set(atom, atomState).get(atom),\n (atom, ...params) => atom.read(...params),\n (atom, ...params) => atom.write(...params),\n (atom, ...params) => {\n var _a;\n return (_a = atom.unstable_onInit) == null ? undefined : _a.call(atom, ...params);\n },\n (atom, ...params) => {\n var _a;\n return (_a = atom.onMount) == null ? undefined : _a.call(atom, ...params);\n }\n );\n if ((import.meta.env ? import.meta.env.MODE : undefined) !== \"production\") {\n return deriveDevStoreRev4(store);\n }\n return store;\n};\nlet defaultStore;\nconst getDefaultStore = () => {\n if (!defaultStore) {\n defaultStore = createStore();\n if ((import.meta.env ? import.meta.env.MODE : undefined) !== \"production\") {\n globalThis.__JOTAI_DEFAULT_STORE__ || (globalThis.__JOTAI_DEFAULT_STORE__ = defaultStore);\n if (globalThis.__JOTAI_DEFAULT_STORE__ !== defaultStore) {\n console.warn(\n \"Detected multiple Jotai instances. It may cause unexpected behavior with the default store. https://github.com/pmndrs/jotai/discussions/2044\"\n );\n }\n }\n }\n return defaultStore;\n};\n\nexport { atom, createStore, getDefaultStore };\n", "'use client';\nimport ReactExports, { createContext, useContext, useRef, createElement, useReducer, useEffect, useDebugValue, useCallback } from 'react';\nimport { getDefaultStore, createStore } from 'jotai/vanilla';\n\nconst StoreContext = createContext(\n undefined\n);\nconst useStore = (options) => {\n const store = useContext(StoreContext);\n return (options == null ? undefined : options.store) || store || getDefaultStore();\n};\nconst Provider = ({\n children,\n store\n}) => {\n const storeRef = useRef(undefined);\n if (!store && !storeRef.current) {\n storeRef.current = createStore();\n }\n return createElement(\n StoreContext.Provider,\n {\n value: store || storeRef.current\n },\n children\n );\n};\n\nconst isPromiseLike = (x) => typeof (x == null ? undefined : x.then) === \"function\";\nconst attachPromiseMeta = (promise) => {\n promise.status = \"pending\";\n promise.then(\n (v) => {\n promise.status = \"fulfilled\";\n promise.value = v;\n },\n (e) => {\n promise.status = \"rejected\";\n promise.reason = e;\n }\n );\n};\nconst use = ReactExports.use || ((promise) => {\n if (promise.status === \"pending\") {\n throw promise;\n } else if (promise.status === \"fulfilled\") {\n return promise.value;\n } else if (promise.status === \"rejected\") {\n throw promise.reason;\n } else {\n attachPromiseMeta(promise);\n throw promise;\n }\n});\nconst continuablePromiseMap = /* @__PURE__ */ new WeakMap();\nconst createContinuablePromise = (promise) => {\n let continuablePromise = continuablePromiseMap.get(promise);\n if (!continuablePromise) {\n continuablePromise = new Promise((resolve, reject) => {\n let curr = promise;\n const onFulfilled = (me) => (v) => {\n if (curr === me) {\n resolve(v);\n }\n };\n const onRejected = (me) => (e) => {\n if (curr === me) {\n reject(e);\n }\n };\n const registerCancelHandler = (p) => {\n if (\"onCancel\" in p && typeof p.onCancel === \"function\") {\n p.onCancel((nextValue) => {\n if ((import.meta.env ? import.meta.env.MODE : undefined) !== \"production\" && nextValue === p) {\n throw new Error(\"[Bug] p is not updated even after cancelation\");\n }\n if (isPromiseLike(nextValue)) {\n continuablePromiseMap.set(nextValue, continuablePromise);\n curr = nextValue;\n nextValue.then(onFulfilled(nextValue), onRejected(nextValue));\n registerCancelHandler(nextValue);\n } else {\n resolve(nextValue);\n }\n });\n }\n };\n promise.then(onFulfilled(promise), onRejected(promise));\n registerCancelHandler(promise);\n });\n continuablePromiseMap.set(promise, continuablePromise);\n }\n return continuablePromise;\n};\nfunction useAtomValue(atom, options) {\n const store = useStore(options);\n const [[valueFromReducer, storeFromReducer, atomFromReducer], rerender] = useReducer(\n (prev) => {\n const nextValue = store.get(atom);\n if (Object.is(prev[0], nextValue) && prev[1] === store && prev[2] === atom) {\n return prev;\n }\n return [nextValue, store, atom];\n },\n undefined,\n () => [store.get(atom), store, atom]\n );\n let value = valueFromReducer;\n if (storeFromReducer !== store || atomFromReducer !== atom) {\n rerender();\n value = store.get(atom);\n }\n const delay = options == null ? undefined : options.delay;\n useEffect(() => {\n const unsub = store.sub(atom, () => {\n if (typeof delay === \"number\") {\n const value2 = store.get(atom);\n if (isPromiseLike(value2)) {\n attachPromiseMeta(createContinuablePromise(value2));\n }\n setTimeout(rerender, delay);\n return;\n }\n rerender();\n });\n rerender();\n return unsub;\n }, [store, atom, delay]);\n useDebugValue(value);\n if (isPromiseLike(value)) {\n const promise = createContinuablePromise(value);\n return use(promise);\n }\n return value;\n}\n\nfunction useSetAtom(atom, options) {\n const store = useStore(options);\n const setAtom = useCallback(\n (...args) => {\n if ((import.meta.env ? import.meta.env.MODE : undefined) !== \"production\" && !(\"write\" in atom)) {\n throw new Error(\"not writable atom\");\n }\n return store.set(atom, ...args);\n },\n [store, atom]\n );\n return setAtom;\n}\n\nfunction useAtom(atom, options) {\n return [\n useAtomValue(atom, options),\n // We do wrong type assertion here, which results in throwing an error.\n useSetAtom(atom, options)\n ];\n}\n\nexport { Provider, useAtom, useAtomValue, useSetAtom, useStore };\n"],
5
- "mappings": ";AAAA,IAAI,WAAW;AACf,SAAS,KAAK,MAAM,OAAO;AACzB,QAAM,MAAM,OAAO,EAAE,QAAQ;AAC7B,QAAM,SAAS;AAAA,IACb,WAAW;AACT,cAAQ,YAAY,MAAM,YAAY,IAAI,OAAO,YAAe,gBAAgB,KAAK,aAAa,MAAM,MAAM,KAAK,aAAa;AAAA,IAClI;AAAA,EACF;AACA,MAAI,OAAO,SAAS,YAAY;AAC9B,WAAO,OAAO;AAAA,EAChB,OAAO;AACL,WAAO,OAAO;AACd,WAAO,OAAO;AACd,WAAO,QAAQ;AAAA,EACjB;AACA,MAAI,OAAO;AACT,WAAO,QAAQ;AAAA,EACjB;AACA,SAAO;AACT;AACA,SAAS,YAAY,KAAK;AACxB,SAAO,IAAI,IAAI;AACjB;AACA,SAAS,aAAa,KAAK,KAAK,KAAK;AACnC,SAAO;AAAA,IACL;AAAA,IACA,OAAO,QAAQ,aAAa,IAAI,IAAI,IAAI,CAAC,IAAI;AAAA,EAC/C;AACF;AAEA,IAAM,aAAa,CAACA,OAAM,MAAMA,MAAK,cAAcA,MAAK,YAAY,CAAC,IAAI,MAAMA;AAC/E,IAAM,kBAAkB,CAACA,UAAS,UAAUA;AAC5C,IAAM,yBAAyB,CAACA,UAAS,CAAC,CAACA,MAAK;AAChD,IAAM,uBAAuC,oBAAI,QAAQ;AACzD,IAAM,mBAAmB,CAAC,UAAU;AAClC,MAAI;AACJ,SAAO,cAAc,KAAK,KAAK,GAAG,KAAK,qBAAqB,IAAI,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,UAAU,yBAAyB,KAAK;AAC9C,WAAO,IAAI,OAAO;AAAA,EACpB;AACA,SAAO;AACT;AAEA,SAAS,WAAWC,OAAM,SAAS;AACjC,QAAM,QAAQ,SAAS,OAAO;AAC9B,QAAM,UAAU;AAAA,IACd,IAAI,SAAS;AACX,WAAK,YAAY,MAAM,YAAY,IAAI,OAAO,YAAe,gBAAgB,EAAE,WAAWA,QAAO;AAC/F,cAAM,IAAI,MAAM,mBAAmB;AAAA,MACrC;AACA,aAAO,MAAM,IAAIA,OAAM,GAAG,IAAI;AAAA,IAChC;AAAA,IACA,CAAC,OAAOA,KAAI;AAAA,EACd;AACA,SAAO;AACT;AAEA,SAAS,QAAQA,OAAM,SAAS;AAC9B,SAAO;AAAA,IACL,aAAaA,OAAM,OAAO;AAAA;AAAA,IAE1B,WAAWA,OAAM,OAAO;AAAA,EAC1B;AACF;",
6
- "names": ["atom", "isPromiseLike", "atom"]
7
- }
@@ -1,44 +0,0 @@
1
- import "../chunk-PLDDJCW6.js";
2
-
3
- // ../../packages/reactor-browser/dist/src/hooks/useDocumentsState.js
4
- import { useEffect, useMemo, useRef, useState } from "react";
5
- function useDocumentsState(args) {
6
- const { reactor, driveId, options } = args;
7
- const [statesByDocumentId, setStatesByDocumentId] = useState({});
8
- const isInitialized = useRef(false);
9
- useEffect(() => {
10
- async function initialize() {
11
- if (isInitialized.current)
12
- return;
13
- if (!reactor || !driveId)
14
- return;
15
- isInitialized.current = true;
16
- const documentIds = await reactor.getDocuments(driveId);
17
- const statesByDocumentId2 = {};
18
- for (const id of documentIds) {
19
- const document = await reactor.getDocument(driveId, id, options);
20
- statesByDocumentId2[id] = document.state;
21
- }
22
- setStatesByDocumentId(statesByDocumentId2);
23
- }
24
- void initialize();
25
- }, [reactor, driveId, options]);
26
- useEffect(() => {
27
- if (!reactor || !driveId)
28
- return;
29
- const unsubscribe = reactor.on("strandUpdate", async (update) => {
30
- const updatedDocument = await reactor.getDocument(driveId, update.documentId, options);
31
- setStatesByDocumentId((prev) => {
32
- const newStatesByDocumentId = { ...prev };
33
- newStatesByDocumentId[update.documentId] = updatedDocument.state;
34
- return newStatesByDocumentId;
35
- });
36
- });
37
- return unsubscribe;
38
- }, [reactor, driveId, options]);
39
- return useMemo(() => statesByDocumentId, [statesByDocumentId]);
40
- }
41
- export {
42
- useDocumentsState
43
- };
44
- //# sourceMappingURL=useDocumentsState.js.map
@@ -1,7 +0,0 @@
1
- {
2
- "version": 3,
3
- "sources": ["../../../../../../../packages/reactor-browser/dist/src/hooks/useDocumentsState.js"],
4
- "sourcesContent": ["import { useEffect, useMemo, useRef, useState } from \"react\";\nexport function useDocumentsState(args) {\n const { reactor, driveId, options } = args;\n const [statesByDocumentId, setStatesByDocumentId] = useState({});\n const isInitialized = useRef(false);\n useEffect(() => {\n async function initialize() {\n if (isInitialized.current)\n return;\n if (!reactor || !driveId)\n return;\n isInitialized.current = true;\n const documentIds = await reactor.getDocuments(driveId);\n const statesByDocumentId = {};\n for (const id of documentIds) {\n const document = await reactor.getDocument(driveId, id, options);\n statesByDocumentId[id] = document.state;\n }\n setStatesByDocumentId(statesByDocumentId);\n }\n void initialize();\n }, [reactor, driveId, options]);\n useEffect(() => {\n if (!reactor || !driveId)\n return;\n const unsubscribe = reactor.on(\"strandUpdate\", async (update) => {\n const updatedDocument = await reactor.getDocument(driveId, update.documentId, options);\n setStatesByDocumentId((prev) => {\n const newStatesByDocumentId = { ...prev };\n newStatesByDocumentId[update.documentId] = updatedDocument.state;\n return newStatesByDocumentId;\n });\n });\n return unsubscribe;\n }, [reactor, driveId, options]);\n return useMemo(() => statesByDocumentId, [statesByDocumentId]);\n}\n"],
5
- "mappings": ";;;AAAA,SAAS,WAAW,SAAS,QAAQ,gBAAgB;AAC9C,SAAS,kBAAkB,MAAM;AACpC,QAAM,EAAE,SAAS,SAAS,QAAQ,IAAI;AACtC,QAAM,CAAC,oBAAoB,qBAAqB,IAAI,SAAS,CAAC,CAAC;AAC/D,QAAM,gBAAgB,OAAO,KAAK;AAClC,YAAU,MAAM;AACZ,mBAAe,aAAa;AACxB,UAAI,cAAc;AACd;AACJ,UAAI,CAAC,WAAW,CAAC;AACb;AACJ,oBAAc,UAAU;AACxB,YAAM,cAAc,MAAM,QAAQ,aAAa,OAAO;AACtD,YAAMA,sBAAqB,CAAC;AAC5B,iBAAW,MAAM,aAAa;AAC1B,cAAM,WAAW,MAAM,QAAQ,YAAY,SAAS,IAAI,OAAO;AAC/D,QAAAA,oBAAmB,EAAE,IAAI,SAAS;AAAA,MACtC;AACA,4BAAsBA,mBAAkB;AAAA,IAC5C;AACA,SAAK,WAAW;AAAA,EACpB,GAAG,CAAC,SAAS,SAAS,OAAO,CAAC;AAC9B,YAAU,MAAM;AACZ,QAAI,CAAC,WAAW,CAAC;AACb;AACJ,UAAM,cAAc,QAAQ,GAAG,gBAAgB,OAAO,WAAW;AAC7D,YAAM,kBAAkB,MAAM,QAAQ,YAAY,SAAS,OAAO,YAAY,OAAO;AACrF,4BAAsB,CAAC,SAAS;AAC5B,cAAM,wBAAwB,EAAE,GAAG,KAAK;AACxC,8BAAsB,OAAO,UAAU,IAAI,gBAAgB;AAC3D,eAAO;AAAA,MACX,CAAC;AAAA,IACL,CAAC;AACD,WAAO;AAAA,EACX,GAAG,CAAC,SAAS,SAAS,OAAO,CAAC;AAC9B,SAAO,QAAQ,MAAM,oBAAoB,CAAC,kBAAkB,CAAC;AACjE;",
6
- "names": ["statesByDocumentId"]
7
- }