{"version":3,"file":"useStore.js","names":[],"sources":["esm/useStore.js"],"sourcesContent":["import React from \"react\";\nimport { isEqualSubsetShallow } from \"./comparators\";\nimport { configureOpts } from \"./configureUseStore\";\nimport { UNWRAP_PROXY, defaultOptions } from \"./constants\";\nimport { UNWRAP_STORE_INFO, cache, getStoreDescriptors, getStoreUid, simpleStr } from \"./helpers\";\nimport { DebugStores, shouldDebug, useCurrentComponent } from \"./useStoreDebug\";\n\nconst idFn = (_) => _;\nfunction useStore(StoreKlass, props, options = defaultOptions) {\n\treturn useStoreFromInfo(getOrCreateStoreInfo(StoreKlass, props, options), options.selector, options);\n}\nfunction useStoreDebug(StoreKlass, props) {\n\treturn useStore(StoreKlass, props, { debug: true });\n}\nfunction createStore(StoreKlass, props, options) {\n\treturn getOrCreateStoreInfo(StoreKlass, props, options)?.store;\n}\nfunction useGlobalStore(instance, debug) {\n\tconst store = instance[UNWRAP_PROXY];\n\tconst uid = getStoreUid(store.constructor, store.props);\n\tconst info = cache.get(uid);\n\tif (!info) throw new Error(`This store not created using createStore()`);\n\treturn useStoreFromInfo(info, void 0, { debug });\n}\nfunction useGlobalStoreSelector(instance, selector, debug) {\n\tconst store = instance[UNWRAP_PROXY];\n\tconst uid = getStoreUid(store.constructor, store.props);\n\tconst info = cache.get(uid);\n\tif (!info) throw new Error(`This store not created using createStore()`);\n\treturn useStoreFromInfo(info, selector, { debug });\n}\nfunction createUseStore(StoreKlass) {\n\treturn (props, options) => useStore(StoreKlass, props, options);\n}\nfunction createUseStoreSelector(StoreKlass, selector) {\n\treturn (props) => {\n\t\treturn useStore(StoreKlass, props, { selector });\n\t};\n}\nfunction useStoreSelector(StoreKlass, selector, props) {\n\treturn useStore(StoreKlass, props, { selector });\n}\nconst storeAccessTrackers = /* @__PURE__ */ new Set();\nfunction trackStoresAccess(cb) {\n\tstoreAccessTrackers.add(cb);\n\treturn () => {\n\t\tstoreAccessTrackers.delete(cb);\n\t};\n}\nfunction getStore(StoreKlass, props) {\n\treturn getStoreInfo(StoreKlass, props)?.store;\n}\nfunction getOrCreateStore(StoreKlass, props) {\n\treturn getOrCreateStoreInfo(StoreKlass, props, { refuseCreation: false })?.store;\n}\nfunction getStoreInfo(StoreKlass, props) {\n\treturn getOrCreateStoreInfo(StoreKlass, props, { refuseCreation: true });\n}\nconst onCreateListeners = /* @__PURE__ */ new Set();\nfunction onCreateStore(cb) {\n\tonCreateListeners.add(cb);\n\treturn () => {\n\t\tonCreateListeners.delete(cb);\n\t};\n}\nfunction getOrCreateStoreInfo(StoreKlass, props, options, propsKeyCalculated) {\n\tif (!StoreKlass) return null;\n\tconst uid = getStoreUid(StoreKlass, propsKeyCalculated ?? props);\n\tif (!options?.avoidCache && cache.has(uid)) return cache.get(uid);\n\tif (options?.refuseCreation) throw new Error(`No store exists (${StoreKlass.name}) with props: ${props}`);\n\tconst storeInstance = new StoreKlass(props);\n\tstoreInstance.props = props;\n\tconst getters = {};\n\tconst actions = {};\n\tconst stateKeys = /* @__PURE__ */ new Set();\n\tconst descriptors = getStoreDescriptors(storeInstance);\n\tfor (const key in descriptors) {\n\t\tconst descriptor = descriptors[key];\n\t\tif (typeof descriptor.value === \"function\") actions[key] = descriptor.value;\n\t\telse if (typeof descriptor.get === \"function\") getters[key] = descriptor.get;\n\t\telse if (key !== \"props\" && key[0] !== \"_\") stateKeys.add(key);\n\t}\n\tconst keyComparators = storeInstance[\"_comparators\"];\n\tconst listeners = /* @__PURE__ */ new Set();\n\tconst storeInfo = {\n\t\tuid,\n\t\tkeyComparators,\n\t\tstoreInstance,\n\t\tgetters,\n\t\tstateKeys,\n\t\tprops,\n\t\tactions,\n\t\tdebug: options?.debug,\n\t\tdisableTracking: false,\n\t\tgettersState: {\n\t\t\tgetCache: /* @__PURE__ */ new Map(),\n\t\t\tdepsToGetter: /* @__PURE__ */ new Map(),\n\t\t\tcurGetKeys: /* @__PURE__ */ new Set(),\n\t\t\tisGetting: false\n\t\t},\n\t\tlisteners,\n\t\ttrackers: /* @__PURE__ */ new Set(),\n\t\tversion: 0,\n\t\tsubscribe: (onChanged) => {\n\t\t\tlisteners.add(onChanged);\n\t\t\treturn () => {\n\t\t\t\tlisteners.delete(onChanged);\n\t\t\t};\n\t\t},\n\t\ttriggerUpdate: () => {\n\t\t\tstoreInfo.version = (storeInfo.version + 1) % Number.MAX_SAFE_INTEGER;\n\t\t\tfor (const cb of listeners) cb();\n\t\t}\n\t};\n\tconst store = createProxiedStore(storeInfo);\n\tif (process.env.NODE_ENV === \"development\") allStores[StoreKlass.name + uid] = store;\n\tstore.mount?.();\n\tstoreInfo.store = store;\n\tconst result = storeInfo;\n\tcache.set(uid, result);\n\tonCreateListeners.forEach((cb) => cb(result));\n\treturn result;\n}\nconst allStores = {};\nif (process.env.NODE_ENV === \"development\") globalThis[\"Store\"] ||= allStores;\nconst emptyObj = {};\nconst selectKeys = (obj, keys) => {\n\tif (!keys.length) return emptyObj;\n\tconst res = {};\n\tfor (const key of keys) res[key] = obj[key];\n\treturn res;\n};\nlet isInReaction = false;\nconst setIsInReaction = (val) => {\n\tisInReaction = val;\n};\nfunction useStoreFromInfo(info, userSelector, options) {\n\tconst store = info?.store;\n\tconst internal = React.useRef(void 0);\n\tconst component = useCurrentComponent();\n\tif (!internal.current) internal.current = {\n\t\tcomponent,\n\t\ttracked: /* @__PURE__ */ new Set(),\n\t\tlast: null,\n\t\tlastKeys: null\n\t};\n\tconst curInternal = internal.current;\n\tconst shouldPrintDebug = options?.debug;\n\tconst getSnapshot = React.useCallback(() => {\n\t\tif (!info || !store) return;\n\t\tconst curInternal2 = internal.current;\n\t\tconst isTracking = curInternal2.tracked.size;\n\t\tconst keys = [...!isTracking ? info.stateKeys : curInternal2.tracked];\n\t\tconst nextKeys = `${info.version}${keys.join(\"\")}${userSelector || \"\"}`;\n\t\tconst lastKeys = curInternal2.lastKeys;\n\t\tif (nextKeys === curInternal2.lastKeys) return curInternal2.last;\n\t\tcurInternal2.lastKeys = nextKeys;\n\t\tlet snap;\n\t\tinfo.disableTracking = true;\n\t\tconst last = curInternal2.last;\n\t\tif (userSelector) snap = userSelector(store);\n\t\telse snap = selectKeys(store, keys);\n\t\tinfo.disableTracking = false;\n\t\tconst isUnchanged = !userSelector && !isTracking && last || typeof last !== \"undefined\" && isEqualSubsetShallow(last, snap, { keyComparators: info.keyComparators });\n\t\tif (shouldPrintDebug) console.info(\"🌑 getSnapshot\", {\n\t\t\tstoreState: selectKeys(store, Object.keys(store)),\n\t\t\tuserSelector,\n\t\t\tinfo,\n\t\t\tisUnchanged,\n\t\t\tcomponent,\n\t\t\tkeys,\n\t\t\tlast,\n\t\t\tsnap,\n\t\t\tcurInternal: curInternal2,\n\t\t\tnextKeys,\n\t\t\tlastKeys\n\t\t});\n\t\tif (isUnchanged) return last;\n\t\tcurInternal2.last = snap;\n\t\treturn snap;\n\t}, [store]);\n\tconst state = React.useSyncExternalStore(info?.subscribe || idFn, getSnapshot, getSnapshot);\n\tif (!info || !store || !state) return state;\n\tif (userSelector) return state;\n\treturn new Proxy(store, { get(target, key) {\n\t\tconst curVal = Reflect.get(target, key);\n\t\tif (isInReaction) return curVal;\n\t\tconst keyString = key;\n\t\tif (info.stateKeys.has(keyString) || keyString in info.getters) {\n\t\t\tif (shouldPrintDebug) console.info(\"👀 tracking\", keyString);\n\t\t\tcurInternal.tracked.add(keyString);\n\t\t}\n\t\tif (Reflect.has(state, key)) return Reflect.get(state, key);\n\t\treturn curVal;\n\t} });\n}\nlet setters = /* @__PURE__ */ new Set();\nconst logStack = /* @__PURE__ */ new Set();\nfunction createProxiedStore(storeInfo) {\n\tconst { actions, storeInstance, getters, gettersState } = storeInfo;\n\tconst { getCache, curGetKeys, depsToGetter } = gettersState;\n\tconst constr = storeInstance.constructor;\n\tconst shouldDebug2 = storeInfo.debug ?? DebugStores.has(constr);\n\tlet didSet = false;\n\tconst wrappedActions = {};\n\tfor (const key in actions) {\n\t\tif (key === \"subscribe\") continue;\n\t\tconst actionFn = actions[key];\n\t\tconst isGetFn = key.startsWith(\"get\");\n\t\twrappedActions[key] = function useStoreAction(...args) {\n\t\t\tlet res;\n\t\t\tif (isGetFn || gettersState.isGetting) return Reflect.apply(actionFn, proxiedStore, args);\n\t\t\tif (process.env.NODE_ENV === \"development\" && shouldDebug2) console.info(\"(debug) startAction\", key);\n\t\t\tres = Reflect.apply(actionFn, proxiedStore, args);\n\t\t\tif (res instanceof Promise) return res.then(finishAction);\n\t\t\tfinishAction();\n\t\t\treturn res;\n\t\t};\n\t\tif (process.env.NODE_ENV === \"development\") {\n\t\t\tlet hashCode = function(str) {\n\t\t\t\tlet hash = 0;\n\t\t\t\tfor (let i = 0; i < str.length; i++) hash = str.charCodeAt(i) + ((hash << 5) - hash);\n\t\t\t\treturn hash;\n\t\t\t}, strColor = function(str) {\n\t\t\t\treturn `hsl(${hashCode(str) % 360}, 90%, 40%)`;\n\t\t\t};\n\t\t\tif (!key.startsWith(\"get\") && !key.startsWith(\"_\") && key !== \"subscribe\") {\n\t\t\t\tconst ogAction = wrappedActions[key];\n\t\t\t\twrappedActions[key] = new Proxy(ogAction, { apply(target, thisArg, args) {\n\t\t\t\t\tconst isDebugging = shouldDebug2 || storeInfo.debug;\n\t\t\t\t\tif (!(process.env.LOG_LEVEL !== \"0\" && (isDebugging || configureOpts.logLevel !== \"error\"))) return Reflect.apply(target, thisArg, args);\n\t\t\t\t\tsetters = /* @__PURE__ */ new Set();\n\t\t\t\t\tconst curSetters = setters;\n\t\t\t\t\tconst isTopLevelLogger = logStack.size == 0;\n\t\t\t\t\tconst logs = /* @__PURE__ */ new Set();\n\t\t\t\t\tlogStack.add(logs);\n\t\t\t\t\tlet res;\n\t\t\t\t\tconst id = counter++;\n\t\t\t\t\ttry {\n\t\t\t\t\t\tres = Reflect.apply(target, thisArg, args);\n\t\t\t\t\t} catch (err) {\n\t\t\t\t\t\tconsole.error(\"Error\", err);\n\t\t\t\t\t\tthrow err;\n\t\t\t\t\t} finally {\n\t\t\t\t\t\tlogStack.add(\"end\");\n\t\t\t\t\t\tconst name = constr.name;\n\t\t\t\t\t\tconst color = strColor(name);\n\t\t\t\t\t\tconst simpleArgs = args.map(simpleStr);\n\t\t\t\t\t\tlogs.add([\n\t\t\t\t\t\t\t`%c \\u{1F311} ${id} ${name.padStart(isTopLevelLogger ? 8 : 4)}%c.${key}(${simpleArgs.join(\", \")})${isTopLevelLogger && logStack.size > 1 ? ` (+${logStack.size - 1})` : \"\"}`,\n\t\t\t\t\t\t\t`color: ${color};`,\n\t\t\t\t\t\t\t\"color: black;\"\n\t\t\t\t\t\t]);\n\t\t\t\t\t\tif (curSetters.size) curSetters.forEach(({ key: key2, value }) => {\n\t\t\t\t\t\t\tif (typeof value === \"string\" || typeof value === \"number\" || typeof value === \"boolean\") logs.add([` SET ${key2} ${value}`, value]);\n\t\t\t\t\t\t\telse logs.add([` SET ${key2}`, value]);\n\t\t\t\t\t\t});\n\t\t\t\t\t\tif (isTopLevelLogger) {\n\t\t\t\t\t\t\tlet error = null;\n\t\t\t\t\t\t\ttry {\n\t\t\t\t\t\t\t\tfor (const item of logStack) {\n\t\t\t\t\t\t\t\t\tif (item === \"end\") {\n\t\t\t\t\t\t\t\t\t\tconsole.groupEnd();\n\t\t\t\t\t\t\t\t\t\tcontinue;\n\t\t\t\t\t\t\t\t\t}\n\t\t\t\t\t\t\t\t\tconst [head, ...rest] = item;\n\t\t\t\t\t\t\t\t\tif (head) {\n\t\t\t\t\t\t\t\t\t\tconsole.groupCollapsed(...head);\n\t\t\t\t\t\t\t\t\t\tconsole.groupCollapsed(\"...\");\n\t\t\t\t\t\t\t\t\t\tconsole.info(\"args\", args);\n\t\t\t\t\t\t\t\t\t\tconsole.info(\"response\", res);\n\t\t\t\t\t\t\t\t\t\tconsole.groupCollapsed(\"trace\");\n\t\t\t\t\t\t\t\t\t\tconsole.trace();\n\t\t\t\t\t\t\t\t\t\tconsole.groupEnd();\n\t\t\t\t\t\t\t\t\t\tconsole.groupEnd();\n\t\t\t\t\t\t\t\t\t\tfor (const [name2, ...log] of rest) {\n\t\t\t\t\t\t\t\t\t\t\tconsole.groupCollapsed(name2);\n\t\t\t\t\t\t\t\t\t\t\tconsole.info(...log);\n\t\t\t\t\t\t\t\t\t\t\tconsole.groupEnd();\n\t\t\t\t\t\t\t\t\t\t}\n\t\t\t\t\t\t\t\t\t} else console.info(\"Weird log\", head, ...rest);\n\t\t\t\t\t\t\t\t}\n\t\t\t\t\t\t\t} catch (err) {\n\t\t\t\t\t\t\t\terror = err;\n\t\t\t\t\t\t\t}\n\t\t\t\t\t\t\tfor (const _ of logStack) console.groupEnd();\n\t\t\t\t\t\t\tif (error) console.error(`error loggin`, error);\n\t\t\t\t\t\t\tlogStack.clear();\n\t\t\t\t\t\t}\n\t\t\t\t\t\treturn res;\n\t\t\t\t\t}\n\t\t\t\t} });\n\t\t\t}\n\t\t}\n\t}\n\tconst finishAction = (val) => {\n\t\tif (process.env.NODE_ENV === \"development\" && shouldDebug2) console.info(\"(debug) finishAction\", { didSet });\n\t\tif (didSet) {\n\t\t\tstoreInfo.triggerUpdate();\n\t\t\tdidSet = false;\n\t\t}\n\t\treturn val;\n\t};\n\tlet isTriggering = false;\n\tconst proxiedStore = new Proxy(storeInstance, {\n\t\tget(_, key) {\n\t\t\tif (key in wrappedActions) return wrappedActions[key];\n\t\t\tif (key in passThroughKeys) return Reflect.get(storeInstance, key);\n\t\t\tif (key === UNWRAP_PROXY) return storeInstance;\n\t\t\tif (key === UNWRAP_STORE_INFO) return storeInfo;\n\t\t\tif (storeAccessTrackers.size) storeAccessTrackers.forEach((cb) => cb(storeInfo));\n\t\t\tif (typeof key !== \"string\") return Reflect.get(storeInstance, key);\n\t\t\tif (!storeInfo.disableTracking) {\n\t\t\t\tif (gettersState.isGetting) gettersState.curGetKeys.add(key);\n\t\t\t}\n\t\t\tif (key in getters) {\n\t\t\t\tif (getCache.has(key)) return getCache.get(key);\n\t\t\t\tcurGetKeys.clear();\n\t\t\t\tconst isSubGetter = gettersState.isGetting;\n\t\t\t\tgettersState.isGetting = true;\n\t\t\t\tconst res = getters[key].call(proxiedStore);\n\t\t\t\tif (!isSubGetter) gettersState.isGetting = false;\n\t\t\t\tfor (const gk of curGetKeys) {\n\t\t\t\t\tif (!depsToGetter.has(gk)) depsToGetter.set(gk, /* @__PURE__ */ new Set());\n\t\t\t\t\tdepsToGetter.get(gk).add(key);\n\t\t\t\t}\n\t\t\t\tgetCache.set(key, res);\n\t\t\t\treturn res;\n\t\t\t}\n\t\t\treturn Reflect.get(storeInstance, key);\n\t\t},\n\t\tset(target, key, value, receiver) {\n\t\t\tconst cur = Reflect.get(target, key);\n\t\t\tconst res = Reflect.set(target, key, value, receiver);\n\t\t\tif (res && cur !== value) {\n\t\t\t\tif (typeof key === \"string\") {\n\t\t\t\t\tclearGetterCache(key);\n\t\t\t\t\tif (shouldDebug2) {\n\t\t\t\t\t\tsetters.add({\n\t\t\t\t\t\t\tkey,\n\t\t\t\t\t\t\tvalue\n\t\t\t\t\t\t});\n\t\t\t\t\t\tif (getShouldDebug(storeInfo)) console.info(\"(debug) SET\", res, key, value);\n\t\t\t\t\t}\n\t\t\t\t\tif (process.env.NODE_ENV === \"development\" && shouldDebug2) console.info(\"SET...\", {\n\t\t\t\t\t\tkey,\n\t\t\t\t\t\tvalue\n\t\t\t\t\t});\n\t\t\t\t}\n\t\t\t\tif (!isTriggering) {\n\t\t\t\t\tisTriggering = true;\n\t\t\t\t\twaitForEventLoop(() => {\n\t\t\t\t\t\tstoreInfo.triggerUpdate();\n\t\t\t\t\t\tisTriggering = false;\n\t\t\t\t\t});\n\t\t\t\t}\n\t\t\t}\n\t\t\treturn res;\n\t\t}\n\t});\n\tfunction clearGetterCache(setKey) {\n\t\tconst parentGetters = depsToGetter.get(setKey);\n\t\tgetCache.delete(setKey);\n\t\tif (!parentGetters) return;\n\t\tfor (const gk of parentGetters) {\n\t\t\tgetCache.delete(gk);\n\t\t\tif (depsToGetter.has(gk)) clearGetterCache(gk);\n\t\t}\n\t}\n\treturn proxiedStore;\n}\nconst waitForEventLoop = process.env.NODE_ENV === \"test\" || false ? (cb) => cb() : queueMicrotask;\nlet counter = 0;\nconst passThroughKeys = {\n\tsubscribe: true,\n\t_version: true,\n\t_trackers: true,\n\t$$typeof: true,\n\t_listeners: true,\n\t_enableTracking: true\n};\nfunction getShouldDebug(storeInfo) {\n\tconst info = { storeInstance: storeInfo.store };\n\treturn [...storeInfo.trackers].some((tracker) => tracker.component && shouldDebug(tracker.component, info));\n}\n\nexport { allStores, createStore, createUseStore, createUseStoreSelector, getOrCreateStore, getStore, getStoreInfo, onCreateStore, setIsInReaction, trackStoresAccess, useGlobalStore, useGlobalStoreSelector, useStore, useStoreDebug, useStoreSelector };"],"mappings":";;;;;;;;AAOA,MAAM,QAAQ,MAAM;AACpB,SAAS,SAAS,YAAY,OAAO,UAAU,gBAAgB;CAC9D,OAAO,iBAAiB,qBAAqB,YAAY,OAAO,OAAO,GAAG,QAAQ,UAAU,OAAO;AACpG;AACA,SAAS,cAAc,YAAY,OAAO;CACzC,OAAO,SAAS,YAAY,OAAO,EAAE,OAAO,KAAK,CAAC;AACnD;AACA,SAAS,YAAY,YAAY,OAAO,SAAS;CAChD,OAAO,qBAAqB,YAAY,OAAO,OAAO,CAAC,EAAE;AAC1D;AACA,SAAS,eAAe,UAAU,OAAO;CACxC,MAAM,QAAQ,SAAS;CACvB,MAAM,MAAM,YAAY,MAAM,aAAa,MAAM,KAAK;CACtD,MAAM,OAAO,MAAM,IAAI,GAAG;CAC1B,IAAI,CAAC,MAAM,MAAM,IAAI,MAAM,4CAA4C;CACvE,OAAO,iBAAiB,MAAM,KAAK,GAAG,EAAE,MAAM,CAAC;AAChD;AACA,SAAS,uBAAuB,UAAU,UAAU,OAAO;CAC1D,MAAM,QAAQ,SAAS;CACvB,MAAM,MAAM,YAAY,MAAM,aAAa,MAAM,KAAK;CACtD,MAAM,OAAO,MAAM,IAAI,GAAG;CAC1B,IAAI,CAAC,MAAM,MAAM,IAAI,MAAM,4CAA4C;CACvE,OAAO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