cross-state 0.8.0 → 0.8.1

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.
@@ -425,9 +425,10 @@ function useStore(store$1, options) {
425
425
  return ((_a = lastEqualsRef.current) == null ? void 0 : _a.call(lastEqualsRef, newValue)) ?? false;
426
426
  })
427
427
  );
428
- const [proxiedValue, equals] = store.trackingProxy(value);
428
+ const [proxiedValue, equals, revoke] = store.trackingProxy(value);
429
429
  require$$0.useLayoutEffect(() => {
430
430
  lastEqualsRef.current = equals;
431
+ revoke == null ? void 0 : revoke();
431
432
  });
432
433
  require$$0.useDebugValue(value);
433
434
  return proxiedValue;
@@ -1 +1 @@
1
- {"version":3,"file":"scope2.cjs","sources":["../../node_modules/.pnpm/use-sync-external-store@1.2.0_react@18.2.0/node_modules/use-sync-external-store/cjs/use-sync-external-store-shim.production.min.js","../../node_modules/.pnpm/use-sync-external-store@1.2.0_react@18.2.0/node_modules/use-sync-external-store/cjs/use-sync-external-store-shim.development.js","../../node_modules/.pnpm/use-sync-external-store@1.2.0_react@18.2.0/node_modules/use-sync-external-store/shim/index.js","../../node_modules/.pnpm/use-sync-external-store@1.2.0_react@18.2.0/node_modules/use-sync-external-store/cjs/use-sync-external-store-shim/with-selector.production.min.js","../../node_modules/.pnpm/use-sync-external-store@1.2.0_react@18.2.0/node_modules/use-sync-external-store/cjs/use-sync-external-store-shim/with-selector.development.js","../../node_modules/.pnpm/use-sync-external-store@1.2.0_react@18.2.0/node_modules/use-sync-external-store/shim/with-selector.js","../../src/react/useStore.ts","../../src/react/useProp.ts","../../src/react/reactMethods.ts","../../src/react/useCache.ts","../../src/react/scope.tsx"],"sourcesContent":["/**\n * @license React\n * use-sync-external-store-shim.production.min.js\n *\n * Copyright (c) Facebook, Inc. and its affiliates.\n *\n * This source code is licensed under the MIT license found in the\n * LICENSE file in the root directory of this source tree.\n */\n'use strict';var e=require(\"react\");function h(a,b){return a===b&&(0!==a||1/a===1/b)||a!==a&&b!==b}var k=\"function\"===typeof Object.is?Object.is:h,l=e.useState,m=e.useEffect,n=e.useLayoutEffect,p=e.useDebugValue;function q(a,b){var d=b(),f=l({inst:{value:d,getSnapshot:b}}),c=f[0].inst,g=f[1];n(function(){c.value=d;c.getSnapshot=b;r(c)&&g({inst:c})},[a,d,b]);m(function(){r(c)&&g({inst:c});return a(function(){r(c)&&g({inst:c})})},[a]);p(d);return d}\nfunction r(a){var b=a.getSnapshot;a=a.value;try{var d=b();return!k(a,d)}catch(f){return!0}}function t(a,b){return b()}var u=\"undefined\"===typeof window||\"undefined\"===typeof window.document||\"undefined\"===typeof window.document.createElement?t:q;exports.useSyncExternalStore=void 0!==e.useSyncExternalStore?e.useSyncExternalStore:u;\n","/**\n * @license React\n * use-sync-external-store-shim.development.js\n *\n * Copyright (c) Facebook, Inc. and its affiliates.\n *\n * This source code is licensed under the MIT license found in the\n * LICENSE file in the root directory of this source tree.\n */\n\n'use strict';\n\nif (process.env.NODE_ENV !== \"production\") {\n (function() {\n\n 'use strict';\n\n/* global __REACT_DEVTOOLS_GLOBAL_HOOK__ */\nif (\n typeof __REACT_DEVTOOLS_GLOBAL_HOOK__ !== 'undefined' &&\n typeof __REACT_DEVTOOLS_GLOBAL_HOOK__.registerInternalModuleStart ===\n 'function'\n) {\n __REACT_DEVTOOLS_GLOBAL_HOOK__.registerInternalModuleStart(new Error());\n}\n var React = require('react');\n\nvar ReactSharedInternals = React.__SECRET_INTERNALS_DO_NOT_USE_OR_YOU_WILL_BE_FIRED;\n\nfunction error(format) {\n {\n {\n for (var _len2 = arguments.length, args = new Array(_len2 > 1 ? _len2 - 1 : 0), _key2 = 1; _key2 < _len2; _key2++) {\n args[_key2 - 1] = arguments[_key2];\n }\n\n printWarning('error', format, args);\n }\n }\n}\n\nfunction printWarning(level, format, args) {\n // When changing this logic, you might want to also\n // update consoleWithStackDev.www.js as well.\n {\n var ReactDebugCurrentFrame = ReactSharedInternals.ReactDebugCurrentFrame;\n var stack = ReactDebugCurrentFrame.getStackAddendum();\n\n if (stack !== '') {\n format += '%s';\n args = args.concat([stack]);\n } // eslint-disable-next-line react-internal/safe-string-coercion\n\n\n var argsWithFormat = args.map(function (item) {\n return String(item);\n }); // Careful: RN currently depends on this prefix\n\n argsWithFormat.unshift('Warning: ' + format); // We intentionally don't use spread (or .apply) directly because it\n // breaks IE9: https://github.com/facebook/react/issues/13610\n // eslint-disable-next-line react-internal/no-production-logging\n\n Function.prototype.apply.call(console[level], console, argsWithFormat);\n }\n}\n\n/**\n * inlined Object.is polyfill to avoid requiring consumers ship their own\n * https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/Object/is\n */\nfunction is(x, y) {\n return x === y && (x !== 0 || 1 / x === 1 / y) || x !== x && y !== y // eslint-disable-line no-self-compare\n ;\n}\n\nvar objectIs = typeof Object.is === 'function' ? Object.is : is;\n\n// dispatch for CommonJS interop named imports.\n\nvar useState = React.useState,\n useEffect = React.useEffect,\n useLayoutEffect = React.useLayoutEffect,\n useDebugValue = React.useDebugValue;\nvar didWarnOld18Alpha = false;\nvar didWarnUncachedGetSnapshot = false; // Disclaimer: This shim breaks many of the rules of React, and only works\n// because of a very particular set of implementation details and assumptions\n// -- change any one of them and it will break. The most important assumption\n// is that updates are always synchronous, because concurrent rendering is\n// only available in versions of React that also have a built-in\n// useSyncExternalStore API. And we only use this shim when the built-in API\n// does not exist.\n//\n// Do not assume that the clever hacks used by this hook also work in general.\n// The point of this shim is to replace the need for hacks by other libraries.\n\nfunction useSyncExternalStore(subscribe, getSnapshot, // Note: The shim does not use getServerSnapshot, because pre-18 versions of\n// React do not expose a way to check if we're hydrating. So users of the shim\n// will need to track that themselves and return the correct value\n// from `getSnapshot`.\ngetServerSnapshot) {\n {\n if (!didWarnOld18Alpha) {\n if (React.startTransition !== undefined) {\n didWarnOld18Alpha = true;\n\n error('You are using an outdated, pre-release alpha of React 18 that ' + 'does not support useSyncExternalStore. The ' + 'use-sync-external-store shim will not work correctly. Upgrade ' + 'to a newer pre-release.');\n }\n }\n } // Read the current snapshot from the store on every render. Again, this\n // breaks the rules of React, and only works here because of specific\n // implementation details, most importantly that updates are\n // always synchronous.\n\n\n var value = getSnapshot();\n\n {\n if (!didWarnUncachedGetSnapshot) {\n var cachedValue = getSnapshot();\n\n if (!objectIs(value, cachedValue)) {\n error('The result of getSnapshot should be cached to avoid an infinite loop');\n\n didWarnUncachedGetSnapshot = true;\n }\n }\n } // Because updates are synchronous, we don't queue them. Instead we force a\n // re-render whenever the subscribed state changes by updating an some\n // arbitrary useState hook. Then, during render, we call getSnapshot to read\n // the current value.\n //\n // Because we don't actually use the state returned by the useState hook, we\n // can save a bit of memory by storing other stuff in that slot.\n //\n // To implement the early bailout, we need to track some things on a mutable\n // object. Usually, we would put that in a useRef hook, but we can stash it in\n // our useState hook instead.\n //\n // To force a re-render, we call forceUpdate({inst}). That works because the\n // new object always fails an equality check.\n\n\n var _useState = useState({\n inst: {\n value: value,\n getSnapshot: getSnapshot\n }\n }),\n inst = _useState[0].inst,\n forceUpdate = _useState[1]; // Track the latest getSnapshot function with a ref. This needs to be updated\n // in the layout phase so we can access it during the tearing check that\n // happens on subscribe.\n\n\n useLayoutEffect(function () {\n inst.value = value;\n inst.getSnapshot = getSnapshot; // Whenever getSnapshot or subscribe changes, we need to check in the\n // commit phase if there was an interleaved mutation. In concurrent mode\n // this can happen all the time, but even in synchronous mode, an earlier\n // effect may have mutated the store.\n\n if (checkIfSnapshotChanged(inst)) {\n // Force a re-render.\n forceUpdate({\n inst: inst\n });\n }\n }, [subscribe, value, getSnapshot]);\n useEffect(function () {\n // Check for changes right before subscribing. Subsequent changes will be\n // detected in the subscription handler.\n if (checkIfSnapshotChanged(inst)) {\n // Force a re-render.\n forceUpdate({\n inst: inst\n });\n }\n\n var handleStoreChange = function () {\n // TODO: Because there is no cross-renderer API for batching updates, it's\n // up to the consumer of this library to wrap their subscription event\n // with unstable_batchedUpdates. Should we try to detect when this isn't\n // the case and print a warning in development?\n // The store changed. Check if the snapshot changed since the last time we\n // read from the store.\n if (checkIfSnapshotChanged(inst)) {\n // Force a re-render.\n forceUpdate({\n inst: inst\n });\n }\n }; // Subscribe to the store and return a clean-up function.\n\n\n return subscribe(handleStoreChange);\n }, [subscribe]);\n useDebugValue(value);\n return value;\n}\n\nfunction checkIfSnapshotChanged(inst) {\n var latestGetSnapshot = inst.getSnapshot;\n var prevValue = inst.value;\n\n try {\n var nextValue = latestGetSnapshot();\n return !objectIs(prevValue, nextValue);\n } catch (error) {\n return true;\n }\n}\n\nfunction useSyncExternalStore$1(subscribe, getSnapshot, getServerSnapshot) {\n // Note: The shim does not use getServerSnapshot, because pre-18 versions of\n // React do not expose a way to check if we're hydrating. So users of the shim\n // will need to track that themselves and return the correct value\n // from `getSnapshot`.\n return getSnapshot();\n}\n\nvar canUseDOM = !!(typeof window !== 'undefined' && typeof window.document !== 'undefined' && typeof window.document.createElement !== 'undefined');\n\nvar isServerEnvironment = !canUseDOM;\n\nvar shim = isServerEnvironment ? useSyncExternalStore$1 : useSyncExternalStore;\nvar useSyncExternalStore$2 = React.useSyncExternalStore !== undefined ? React.useSyncExternalStore : shim;\n\nexports.useSyncExternalStore = useSyncExternalStore$2;\n /* global __REACT_DEVTOOLS_GLOBAL_HOOK__ */\nif (\n typeof __REACT_DEVTOOLS_GLOBAL_HOOK__ !== 'undefined' &&\n typeof __REACT_DEVTOOLS_GLOBAL_HOOK__.registerInternalModuleStop ===\n 'function'\n) {\n __REACT_DEVTOOLS_GLOBAL_HOOK__.registerInternalModuleStop(new Error());\n}\n \n })();\n}\n","'use strict';\n\nif (process.env.NODE_ENV === 'production') {\n module.exports = require('../cjs/use-sync-external-store-shim.production.min.js');\n} else {\n module.exports = require('../cjs/use-sync-external-store-shim.development.js');\n}\n","/**\n * @license React\n * use-sync-external-store-shim/with-selector.production.min.js\n *\n * Copyright (c) Facebook, Inc. and its affiliates.\n *\n * This source code is licensed under the MIT license found in the\n * LICENSE file in the root directory of this source tree.\n */\n'use strict';var h=require(\"react\"),n=require(\"use-sync-external-store/shim\");function p(a,b){return a===b&&(0!==a||1/a===1/b)||a!==a&&b!==b}var q=\"function\"===typeof Object.is?Object.is:p,r=n.useSyncExternalStore,t=h.useRef,u=h.useEffect,v=h.useMemo,w=h.useDebugValue;\nexports.useSyncExternalStoreWithSelector=function(a,b,e,l,g){var c=t(null);if(null===c.current){var f={hasValue:!1,value:null};c.current=f}else f=c.current;c=v(function(){function a(a){if(!c){c=!0;d=a;a=l(a);if(void 0!==g&&f.hasValue){var b=f.value;if(g(b,a))return k=b}return k=a}b=k;if(q(d,a))return b;var e=l(a);if(void 0!==g&&g(b,e))return b;d=a;return k=e}var c=!1,d,k,m=void 0===e?null:e;return[function(){return a(b())},null===m?void 0:function(){return a(m())}]},[b,e,l,g]);var d=r(a,c[0],c[1]);\nu(function(){f.hasValue=!0;f.value=d},[d]);w(d);return d};\n","/**\n * @license React\n * use-sync-external-store-shim/with-selector.development.js\n *\n * Copyright (c) Facebook, Inc. and its affiliates.\n *\n * This source code is licensed under the MIT license found in the\n * LICENSE file in the root directory of this source tree.\n */\n\n'use strict';\n\nif (process.env.NODE_ENV !== \"production\") {\n (function() {\n\n 'use strict';\n\n/* global __REACT_DEVTOOLS_GLOBAL_HOOK__ */\nif (\n typeof __REACT_DEVTOOLS_GLOBAL_HOOK__ !== 'undefined' &&\n typeof __REACT_DEVTOOLS_GLOBAL_HOOK__.registerInternalModuleStart ===\n 'function'\n) {\n __REACT_DEVTOOLS_GLOBAL_HOOK__.registerInternalModuleStart(new Error());\n}\n var React = require('react');\nvar shim = require('use-sync-external-store/shim');\n\n/**\n * inlined Object.is polyfill to avoid requiring consumers ship their own\n * https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/Object/is\n */\nfunction is(x, y) {\n return x === y && (x !== 0 || 1 / x === 1 / y) || x !== x && y !== y // eslint-disable-line no-self-compare\n ;\n}\n\nvar objectIs = typeof Object.is === 'function' ? Object.is : is;\n\nvar useSyncExternalStore = shim.useSyncExternalStore;\n\n// for CommonJS interop.\n\nvar useRef = React.useRef,\n useEffect = React.useEffect,\n useMemo = React.useMemo,\n useDebugValue = React.useDebugValue; // Same as useSyncExternalStore, but supports selector and isEqual arguments.\n\nfunction useSyncExternalStoreWithSelector(subscribe, getSnapshot, getServerSnapshot, selector, isEqual) {\n // Use this to track the rendered snapshot.\n var instRef = useRef(null);\n var inst;\n\n if (instRef.current === null) {\n inst = {\n hasValue: false,\n value: null\n };\n instRef.current = inst;\n } else {\n inst = instRef.current;\n }\n\n var _useMemo = useMemo(function () {\n // Track the memoized state using closure variables that are local to this\n // memoized instance of a getSnapshot function. Intentionally not using a\n // useRef hook, because that state would be shared across all concurrent\n // copies of the hook/component.\n var hasMemo = false;\n var memoizedSnapshot;\n var memoizedSelection;\n\n var memoizedSelector = function (nextSnapshot) {\n if (!hasMemo) {\n // The first time the hook is called, there is no memoized result.\n hasMemo = true;\n memoizedSnapshot = nextSnapshot;\n\n var _nextSelection = selector(nextSnapshot);\n\n if (isEqual !== undefined) {\n // Even if the selector has changed, the currently rendered selection\n // may be equal to the new selection. We should attempt to reuse the\n // current value if possible, to preserve downstream memoizations.\n if (inst.hasValue) {\n var currentSelection = inst.value;\n\n if (isEqual(currentSelection, _nextSelection)) {\n memoizedSelection = currentSelection;\n return currentSelection;\n }\n }\n }\n\n memoizedSelection = _nextSelection;\n return _nextSelection;\n } // We may be able to reuse the previous invocation's result.\n\n\n // We may be able to reuse the previous invocation's result.\n var prevSnapshot = memoizedSnapshot;\n var prevSelection = memoizedSelection;\n\n if (objectIs(prevSnapshot, nextSnapshot)) {\n // The snapshot is the same as last time. Reuse the previous selection.\n return prevSelection;\n } // The snapshot has changed, so we need to compute a new selection.\n\n\n // The snapshot has changed, so we need to compute a new selection.\n var nextSelection = selector(nextSnapshot); // If a custom isEqual function is provided, use that to check if the data\n // has changed. If it hasn't, return the previous selection. That signals\n // to React that the selections are conceptually equal, and we can bail\n // out of rendering.\n\n // If a custom isEqual function is provided, use that to check if the data\n // has changed. If it hasn't, return the previous selection. That signals\n // to React that the selections are conceptually equal, and we can bail\n // out of rendering.\n if (isEqual !== undefined && isEqual(prevSelection, nextSelection)) {\n return prevSelection;\n }\n\n memoizedSnapshot = nextSnapshot;\n memoizedSelection = nextSelection;\n return nextSelection;\n }; // Assigning this to a constant so that Flow knows it can't change.\n\n\n // Assigning this to a constant so that Flow knows it can't change.\n var maybeGetServerSnapshot = getServerSnapshot === undefined ? null : getServerSnapshot;\n\n var getSnapshotWithSelector = function () {\n return memoizedSelector(getSnapshot());\n };\n\n var getServerSnapshotWithSelector = maybeGetServerSnapshot === null ? undefined : function () {\n return memoizedSelector(maybeGetServerSnapshot());\n };\n return [getSnapshotWithSelector, getServerSnapshotWithSelector];\n }, [getSnapshot, getServerSnapshot, selector, isEqual]),\n getSelection = _useMemo[0],\n getServerSelection = _useMemo[1];\n\n var value = useSyncExternalStore(subscribe, getSelection, getServerSelection);\n useEffect(function () {\n inst.hasValue = true;\n inst.value = value;\n }, [value]);\n useDebugValue(value);\n return value;\n}\n\nexports.useSyncExternalStoreWithSelector = useSyncExternalStoreWithSelector;\n /* global __REACT_DEVTOOLS_GLOBAL_HOOK__ */\nif (\n typeof __REACT_DEVTOOLS_GLOBAL_HOOK__ !== 'undefined' &&\n typeof __REACT_DEVTOOLS_GLOBAL_HOOK__.registerInternalModuleStop ===\n 'function'\n) {\n __REACT_DEVTOOLS_GLOBAL_HOOK__.registerInternalModuleStop(new Error());\n}\n \n })();\n}\n","'use strict';\n\nif (process.env.NODE_ENV === 'production') {\n module.exports = require('../cjs/use-sync-external-store-shim/with-selector.production.min.js');\n} else {\n module.exports = require('../cjs/use-sync-external-store-shim/with-selector.development.js');\n}\n","import { useCallback, useDebugValue, useLayoutEffect, useMemo, useRef } from 'react';\nimport { useSyncExternalStoreWithSelector } from 'use-sync-external-store/shim/with-selector.js';\nimport type { SubscribeOptions } from '@core/commonTypes';\nimport type { Store } from '@core/store';\nimport { hash } from '@lib/hash';\nimport { makeSelector } from '@lib/makeSelector';\nimport { trackingProxy } from '@lib/trackingProxy';\n\nexport type UseStoreOptions = Omit<SubscribeOptions, 'runNow' | 'passive'>;\n\nexport function useStore<T>(store: Store<T>, options?: UseStoreOptions): T {\n const lastEqualsRef = useRef<(newValue: T) => boolean>();\n\n const { rootStore, selector } = useMemo(() => {\n const rootStore = store.derivedFrom?.store ?? store;\n let selector = (x: any) => x;\n\n if (store.derivedFrom) {\n selector = (value: any) => {\n for (const s of store.derivedFrom!.selectors) {\n value = makeSelector(s)(value);\n }\n return value;\n };\n }\n\n return { rootStore, selector };\n }, [store]);\n\n const subOptions = { ...options, runNow: false, equals: undefined, passive: false };\n const subscribe = useCallback(\n (listener: () => void) => {\n return rootStore.subscribe(listener, subOptions);\n },\n [rootStore, hash(subOptions)],\n );\n\n const value = useSyncExternalStoreWithSelector<unknown, T>(\n //\n subscribe,\n rootStore.get,\n undefined,\n selector,\n options?.equals ?? ((_v, newValue) => lastEqualsRef.current?.(newValue) ?? false),\n );\n const [proxiedValue, equals] = trackingProxy(value);\n\n useLayoutEffect(() => {\n lastEqualsRef.current = equals;\n });\n\n useDebugValue(value);\n return proxiedValue;\n}\n","import type { UseStoreOptions } from './useStore';\nimport { useStore } from './useStore';\nimport type { Store } from '@core/store';\n\nexport function useProp<T>(\n store: Store<T>,\n options?: UseStoreOptions,\n): [value: T, setValue: typeof store.set] {\n const value = useStore(store, options);\n\n return [value, store.set];\n}\n","import { useProp } from './useProp';\nimport { type UseStoreOptions, useStore } from './useStore';\nimport type { Store } from '@core/store';\n\nexport const reactMethods = {\n useStore<T>(this: Store<T>, options?: UseStoreOptions) {\n return useStore(this, options);\n },\n\n useProp<T>(this: Store<T>, options?: UseStoreOptions) {\n return useProp(this, options);\n },\n};\n","import { useEffect, useMemo } from 'react';\nimport type { UseStoreOptions } from './useStore';\nimport { useStore } from './useStore';\nimport type { Cache } from '@core';\nimport type { CacheState } from '@lib/cacheState';\nimport { makeSelector } from '@lib/makeSelector';\n\nexport type UseCacheArray<T> = [\n value: T | undefined,\n error: unknown | undefined,\n isUpdating: boolean,\n isStale: boolean,\n];\n\nexport type UseCacheValue<T> = UseCacheArray<T> & CacheState<T>;\n\nexport interface UseCacheOptions extends UseStoreOptions {\n passive?: boolean;\n updateOnMount?: boolean;\n}\n\nexport function useCache<T>(\n cache: Cache<T>,\n { passive, updateOnMount, ...options }: UseCacheOptions = {},\n): UseCacheValue<T> {\n const mappedState = useMemo(() => {\n const rootCache: Cache<any> = cache.derivedFromCache?.cache ?? cache;\n let selector = (x: any) => x;\n\n if (cache.derivedFromCache) {\n selector = (value: any) => {\n for (const s of cache.derivedFromCache!.selectors) {\n value = makeSelector(s)(value);\n }\n return value;\n };\n }\n\n return rootCache.state.map((state) => {\n const value = state.status === 'value' ? selector(state.value) : undefined;\n\n return Object.assign<UseCacheArray<T>, CacheState<T>>(\n [value, state.error, state.isUpdating, state.isStale],\n { ...state, value },\n );\n });\n }, [cache]);\n\n useEffect(() => (!passive ? cache.subscribe(() => undefined) : undefined), [cache, passive]);\n\n useEffect(() => {\n if (updateOnMount) {\n cache.invalidate();\n }\n }, []);\n\n return useStore(mappedState, options);\n}\n","import type { Context, ReactNode } from 'react';\nimport { createContext, useContext, useMemo } from 'react';\nimport { useProp } from './useProp';\nimport { useStore, type UseStoreOptions } from './useStore';\nimport { createStore } from '@core/store';\nimport type { Store } from '@core/store';\nimport type { Scope } from '@core';\n\nexport type ScopeProps<T> = { scope: Scope<T>; store?: Store<T>; children?: ReactNode };\n\nconst contextMap = new WeakMap<Scope<any>, Context<Store<any>>>();\n\nfunction getScopeContext<T>(scope: Scope<T>): Context<Store<T>> {\n let context = contextMap.get(scope);\n\n if (!context) {\n context = createContext<Store<T>>(createStore(scope.defaultValue));\n contextMap.set(scope, context);\n }\n\n return context;\n}\n\nexport function ScopeProvider<T>({ scope, store: inputStore, children }: ScopeProps<T>) {\n const context = getScopeContext(scope);\n const currentStore = useMemo(\n () => inputStore ?? createStore(scope.defaultValue),\n [scope, inputStore],\n );\n\n return <context.Provider value={currentStore}>{children}</context.Provider>;\n}\n\nexport function useScope<T>(scope: Scope<T>): Store<T> {\n const context = getScopeContext(scope);\n return useContext(context);\n}\n\nexport function useScopeStore<T>(scope: Scope<T>, options?: UseStoreOptions): T {\n const store = useScope(scope);\n return useStore(store, options);\n}\n\nexport function useScopeProp<T>(scope: Scope<T>, options?: UseStoreOptions) {\n const store = useScope(scope);\n return useProp(store, options);\n}\n"],"names":["error","shim","module","require$$0","require$$1","a","c","d","b","e","store","useRef","useMemo","rootStore","selector","value","makeSelector","useCallback","hash","useSyncExternalStoreWithSelector","trackingProxy","useLayoutEffect","useDebugValue","useEffect","createContext","createStore","useContext"],"mappings":";;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;AASa,MAAI,IAAE;AAAiB,WAAS,EAAE,GAAE,GAAE;AAAC,WAAO,MAAI,MAAI,MAAI,KAAG,IAAE,MAAI,IAAE,MAAI,MAAI,KAAG,MAAI;AAAA,EAAC;AAAC,MAAI,IAAE,eAAa,OAAO,OAAO,KAAG,OAAO,KAAG,GAAE,IAAE,EAAE,UAAS,IAAE,EAAE,WAAU,IAAE,EAAE,iBAAgB,IAAE,EAAE;AAAc,WAAS,EAAE,GAAE,GAAE;AAAC,QAAI,IAAE,EAAC,GAAG,IAAE,EAAE,EAAC,MAAK,EAAC,OAAM,GAAE,aAAY,EAAC,EAAC,CAAC,GAAE,IAAE,EAAE,CAAC,EAAE,MAAK,IAAE,EAAE,CAAC;AAAE,MAAE,WAAU;AAAC,QAAE,QAAM;AAAE,QAAE,cAAY;AAAE,QAAE,CAAC,KAAG,EAAE,EAAC,MAAK,EAAC,CAAC;AAAA,IAAC,GAAE,CAAC,GAAE,GAAE,CAAC,CAAC;AAAE,MAAE,WAAU;AAAC,QAAE,CAAC,KAAG,EAAE,EAAC,MAAK,EAAC,CAAC;AAAE,aAAO,EAAE,WAAU;AAAC,UAAE,CA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QAAA,UAAU,gBAAgB,KAAK;AACrC,QAAM,eAAeb,WAAA;AAAA,IACnB,MAAM,cAAca,MAAAA,YAAY,MAAM,YAAY;AAAA,IAClD,CAAC,OAAO,UAAU;AAAA,EAAA;AAGpB,wCAAQ,QAAQ,UAAR,EAAiB,OAAO,cAAe,SAAS,CAAA;AAC1D;AAEO,SAAS,SAAY,OAA2B;AAC/C,QAAA,UAAU,gBAAgB,KAAK;AACrC,SAAOC,WAAAA,WAAW,OAAO;AAC3B;AAEgB,SAAA,cAAiB,OAAiB,SAA8B;AACxE,QAAAhB,SAAQ,SAAS,KAAK;AACrB,SAAA,SAASA,QAAO,OAAO;AAChC;AAEgB,SAAA,aAAgB,OAAiB,SAA2B;AACpE,QAAAA,SAAQ,SAAS,KAAK;AACrB,SAAA,QAAQA,QAAO,OAAO;AAC/B;;;;;;;;;","x_google_ignoreList":[0,1,2,3,4,5]}
1
+ {"version":3,"file":"scope2.cjs","sources":["../../node_modules/.pnpm/use-sync-external-store@1.2.0_react@18.2.0/node_modules/use-sync-external-store/cjs/use-sync-external-store-shim.production.min.js","../../node_modules/.pnpm/use-sync-external-store@1.2.0_react@18.2.0/node_modules/use-sync-external-store/cjs/use-sync-external-store-shim.development.js","../../node_modules/.pnpm/use-sync-external-store@1.2.0_react@18.2.0/node_modules/use-sync-external-store/shim/index.js","../../node_modules/.pnpm/use-sync-external-store@1.2.0_react@18.2.0/node_modules/use-sync-external-store/cjs/use-sync-external-store-shim/with-selector.production.min.js","../../node_modules/.pnpm/use-sync-external-store@1.2.0_react@18.2.0/node_modules/use-sync-external-store/cjs/use-sync-external-store-shim/with-selector.development.js","../../node_modules/.pnpm/use-sync-external-store@1.2.0_react@18.2.0/node_modules/use-sync-external-store/shim/with-selector.js","../../src/react/useStore.ts","../../src/react/useProp.ts","../../src/react/reactMethods.ts","../../src/react/useCache.ts","../../src/react/scope.tsx"],"sourcesContent":["/**\n * @license React\n * use-sync-external-store-shim.production.min.js\n *\n * Copyright (c) Facebook, Inc. and its affiliates.\n *\n * This source code is licensed under the MIT license found in the\n * LICENSE file in the root directory of this source tree.\n */\n'use strict';var e=require(\"react\");function h(a,b){return a===b&&(0!==a||1/a===1/b)||a!==a&&b!==b}var k=\"function\"===typeof Object.is?Object.is:h,l=e.useState,m=e.useEffect,n=e.useLayoutEffect,p=e.useDebugValue;function q(a,b){var d=b(),f=l({inst:{value:d,getSnapshot:b}}),c=f[0].inst,g=f[1];n(function(){c.value=d;c.getSnapshot=b;r(c)&&g({inst:c})},[a,d,b]);m(function(){r(c)&&g({inst:c});return a(function(){r(c)&&g({inst:c})})},[a]);p(d);return d}\nfunction r(a){var b=a.getSnapshot;a=a.value;try{var d=b();return!k(a,d)}catch(f){return!0}}function t(a,b){return b()}var u=\"undefined\"===typeof window||\"undefined\"===typeof window.document||\"undefined\"===typeof window.document.createElement?t:q;exports.useSyncExternalStore=void 0!==e.useSyncExternalStore?e.useSyncExternalStore:u;\n","/**\n * @license React\n * use-sync-external-store-shim.development.js\n *\n * Copyright (c) Facebook, Inc. and its affiliates.\n *\n * This source code is licensed under the MIT license found in the\n * LICENSE file in the root directory of this source tree.\n */\n\n'use strict';\n\nif (process.env.NODE_ENV !== \"production\") {\n (function() {\n\n 'use strict';\n\n/* global __REACT_DEVTOOLS_GLOBAL_HOOK__ */\nif (\n typeof __REACT_DEVTOOLS_GLOBAL_HOOK__ !== 'undefined' &&\n typeof __REACT_DEVTOOLS_GLOBAL_HOOK__.registerInternalModuleStart ===\n 'function'\n) {\n __REACT_DEVTOOLS_GLOBAL_HOOK__.registerInternalModuleStart(new Error());\n}\n var React = require('react');\n\nvar ReactSharedInternals = React.__SECRET_INTERNALS_DO_NOT_USE_OR_YOU_WILL_BE_FIRED;\n\nfunction error(format) {\n {\n {\n for (var _len2 = arguments.length, args = new Array(_len2 > 1 ? _len2 - 1 : 0), _key2 = 1; _key2 < _len2; _key2++) {\n args[_key2 - 1] = arguments[_key2];\n }\n\n printWarning('error', format, args);\n }\n }\n}\n\nfunction printWarning(level, format, args) {\n // When changing this logic, you might want to also\n // update consoleWithStackDev.www.js as well.\n {\n var ReactDebugCurrentFrame = ReactSharedInternals.ReactDebugCurrentFrame;\n var stack = ReactDebugCurrentFrame.getStackAddendum();\n\n if (stack !== '') {\n format += '%s';\n args = args.concat([stack]);\n } // eslint-disable-next-line react-internal/safe-string-coercion\n\n\n var argsWithFormat = args.map(function (item) {\n return String(item);\n }); // Careful: RN currently depends on this prefix\n\n argsWithFormat.unshift('Warning: ' + format); // We intentionally don't use spread (or .apply) directly because it\n // breaks IE9: https://github.com/facebook/react/issues/13610\n // eslint-disable-next-line react-internal/no-production-logging\n\n Function.prototype.apply.call(console[level], console, argsWithFormat);\n }\n}\n\n/**\n * inlined Object.is polyfill to avoid requiring consumers ship their own\n * https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/Object/is\n */\nfunction is(x, y) {\n return x === y && (x !== 0 || 1 / x === 1 / y) || x !== x && y !== y // eslint-disable-line no-self-compare\n ;\n}\n\nvar objectIs = typeof Object.is === 'function' ? Object.is : is;\n\n// dispatch for CommonJS interop named imports.\n\nvar useState = React.useState,\n useEffect = React.useEffect,\n useLayoutEffect = React.useLayoutEffect,\n useDebugValue = React.useDebugValue;\nvar didWarnOld18Alpha = false;\nvar didWarnUncachedGetSnapshot = false; // Disclaimer: This shim breaks many of the rules of React, and only works\n// because of a very particular set of implementation details and assumptions\n// -- change any one of them and it will break. The most important assumption\n// is that updates are always synchronous, because concurrent rendering is\n// only available in versions of React that also have a built-in\n// useSyncExternalStore API. And we only use this shim when the built-in API\n// does not exist.\n//\n// Do not assume that the clever hacks used by this hook also work in general.\n// The point of this shim is to replace the need for hacks by other libraries.\n\nfunction useSyncExternalStore(subscribe, getSnapshot, // Note: The shim does not use getServerSnapshot, because pre-18 versions of\n// React do not expose a way to check if we're hydrating. So users of the shim\n// will need to track that themselves and return the correct value\n// from `getSnapshot`.\ngetServerSnapshot) {\n {\n if (!didWarnOld18Alpha) {\n if (React.startTransition !== undefined) {\n didWarnOld18Alpha = true;\n\n error('You are using an outdated, pre-release alpha of React 18 that ' + 'does not support useSyncExternalStore. The ' + 'use-sync-external-store shim will not work correctly. Upgrade ' + 'to a newer pre-release.');\n }\n }\n } // Read the current snapshot from the store on every render. Again, this\n // breaks the rules of React, and only works here because of specific\n // implementation details, most importantly that updates are\n // always synchronous.\n\n\n var value = getSnapshot();\n\n {\n if (!didWarnUncachedGetSnapshot) {\n var cachedValue = getSnapshot();\n\n if (!objectIs(value, cachedValue)) {\n error('The result of getSnapshot should be cached to avoid an infinite loop');\n\n didWarnUncachedGetSnapshot = true;\n }\n }\n } // Because updates are synchronous, we don't queue them. Instead we force a\n // re-render whenever the subscribed state changes by updating an some\n // arbitrary useState hook. Then, during render, we call getSnapshot to read\n // the current value.\n //\n // Because we don't actually use the state returned by the useState hook, we\n // can save a bit of memory by storing other stuff in that slot.\n //\n // To implement the early bailout, we need to track some things on a mutable\n // object. Usually, we would put that in a useRef hook, but we can stash it in\n // our useState hook instead.\n //\n // To force a re-render, we call forceUpdate({inst}). That works because the\n // new object always fails an equality check.\n\n\n var _useState = useState({\n inst: {\n value: value,\n getSnapshot: getSnapshot\n }\n }),\n inst = _useState[0].inst,\n forceUpdate = _useState[1]; // Track the latest getSnapshot function with a ref. This needs to be updated\n // in the layout phase so we can access it during the tearing check that\n // happens on subscribe.\n\n\n useLayoutEffect(function () {\n inst.value = value;\n inst.getSnapshot = getSnapshot; // Whenever getSnapshot or subscribe changes, we need to check in the\n // commit phase if there was an interleaved mutation. In concurrent mode\n // this can happen all the time, but even in synchronous mode, an earlier\n // effect may have mutated the store.\n\n if (checkIfSnapshotChanged(inst)) {\n // Force a re-render.\n forceUpdate({\n inst: inst\n });\n }\n }, [subscribe, value, getSnapshot]);\n useEffect(function () {\n // Check for changes right before subscribing. Subsequent changes will be\n // detected in the subscription handler.\n if (checkIfSnapshotChanged(inst)) {\n // Force a re-render.\n forceUpdate({\n inst: inst\n });\n }\n\n var handleStoreChange = function () {\n // TODO: Because there is no cross-renderer API for batching updates, it's\n // up to the consumer of this library to wrap their subscription event\n // with unstable_batchedUpdates. Should we try to detect when this isn't\n // the case and print a warning in development?\n // The store changed. Check if the snapshot changed since the last time we\n // read from the store.\n if (checkIfSnapshotChanged(inst)) {\n // Force a re-render.\n forceUpdate({\n inst: inst\n });\n }\n }; // Subscribe to the store and return a clean-up function.\n\n\n return subscribe(handleStoreChange);\n }, [subscribe]);\n useDebugValue(value);\n return value;\n}\n\nfunction checkIfSnapshotChanged(inst) {\n var latestGetSnapshot = inst.getSnapshot;\n var prevValue = inst.value;\n\n try {\n var nextValue = latestGetSnapshot();\n return !objectIs(prevValue, nextValue);\n } catch (error) {\n return true;\n }\n}\n\nfunction useSyncExternalStore$1(subscribe, getSnapshot, getServerSnapshot) {\n // Note: The shim does not use getServerSnapshot, because pre-18 versions of\n // React do not expose a way to check if we're hydrating. So users of the shim\n // will need to track that themselves and return the correct value\n // from `getSnapshot`.\n return getSnapshot();\n}\n\nvar canUseDOM = !!(typeof window !== 'undefined' && typeof window.document !== 'undefined' && typeof window.document.createElement !== 'undefined');\n\nvar isServerEnvironment = !canUseDOM;\n\nvar shim = isServerEnvironment ? useSyncExternalStore$1 : useSyncExternalStore;\nvar useSyncExternalStore$2 = React.useSyncExternalStore !== undefined ? React.useSyncExternalStore : shim;\n\nexports.useSyncExternalStore = useSyncExternalStore$2;\n /* global __REACT_DEVTOOLS_GLOBAL_HOOK__ */\nif (\n typeof __REACT_DEVTOOLS_GLOBAL_HOOK__ !== 'undefined' &&\n typeof __REACT_DEVTOOLS_GLOBAL_HOOK__.registerInternalModuleStop ===\n 'function'\n) {\n __REACT_DEVTOOLS_GLOBAL_HOOK__.registerInternalModuleStop(new Error());\n}\n \n })();\n}\n","'use strict';\n\nif (process.env.NODE_ENV === 'production') {\n module.exports = require('../cjs/use-sync-external-store-shim.production.min.js');\n} else {\n module.exports = require('../cjs/use-sync-external-store-shim.development.js');\n}\n","/**\n * @license React\n * use-sync-external-store-shim/with-selector.production.min.js\n *\n * Copyright (c) Facebook, Inc. and its affiliates.\n *\n * This source code is licensed under the MIT license found in the\n * LICENSE file in the root directory of this source tree.\n */\n'use strict';var h=require(\"react\"),n=require(\"use-sync-external-store/shim\");function p(a,b){return a===b&&(0!==a||1/a===1/b)||a!==a&&b!==b}var q=\"function\"===typeof Object.is?Object.is:p,r=n.useSyncExternalStore,t=h.useRef,u=h.useEffect,v=h.useMemo,w=h.useDebugValue;\nexports.useSyncExternalStoreWithSelector=function(a,b,e,l,g){var c=t(null);if(null===c.current){var f={hasValue:!1,value:null};c.current=f}else f=c.current;c=v(function(){function a(a){if(!c){c=!0;d=a;a=l(a);if(void 0!==g&&f.hasValue){var b=f.value;if(g(b,a))return k=b}return k=a}b=k;if(q(d,a))return b;var e=l(a);if(void 0!==g&&g(b,e))return b;d=a;return k=e}var c=!1,d,k,m=void 0===e?null:e;return[function(){return a(b())},null===m?void 0:function(){return a(m())}]},[b,e,l,g]);var d=r(a,c[0],c[1]);\nu(function(){f.hasValue=!0;f.value=d},[d]);w(d);return d};\n","/**\n * @license React\n * use-sync-external-store-shim/with-selector.development.js\n *\n * Copyright (c) Facebook, Inc. and its affiliates.\n *\n * This source code is licensed under the MIT license found in the\n * LICENSE file in the root directory of this source tree.\n */\n\n'use strict';\n\nif (process.env.NODE_ENV !== \"production\") {\n (function() {\n\n 'use strict';\n\n/* global __REACT_DEVTOOLS_GLOBAL_HOOK__ */\nif (\n typeof __REACT_DEVTOOLS_GLOBAL_HOOK__ !== 'undefined' &&\n typeof __REACT_DEVTOOLS_GLOBAL_HOOK__.registerInternalModuleStart ===\n 'function'\n) {\n __REACT_DEVTOOLS_GLOBAL_HOOK__.registerInternalModuleStart(new Error());\n}\n var React = require('react');\nvar shim = require('use-sync-external-store/shim');\n\n/**\n * inlined Object.is polyfill to avoid requiring consumers ship their own\n * https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/Object/is\n */\nfunction is(x, y) {\n return x === y && (x !== 0 || 1 / x === 1 / y) || x !== x && y !== y // eslint-disable-line no-self-compare\n ;\n}\n\nvar objectIs = typeof Object.is === 'function' ? Object.is : is;\n\nvar useSyncExternalStore = shim.useSyncExternalStore;\n\n// for CommonJS interop.\n\nvar useRef = React.useRef,\n useEffect = React.useEffect,\n useMemo = React.useMemo,\n useDebugValue = React.useDebugValue; // Same as useSyncExternalStore, but supports selector and isEqual arguments.\n\nfunction useSyncExternalStoreWithSelector(subscribe, getSnapshot, getServerSnapshot, selector, isEqual) {\n // Use this to track the rendered snapshot.\n var instRef = useRef(null);\n var inst;\n\n if (instRef.current === null) {\n inst = {\n hasValue: false,\n value: null\n };\n instRef.current = inst;\n } else {\n inst = instRef.current;\n }\n\n var _useMemo = useMemo(function () {\n // Track the memoized state using closure variables that are local to this\n // memoized instance of a getSnapshot function. Intentionally not using a\n // useRef hook, because that state would be shared across all concurrent\n // copies of the hook/component.\n var hasMemo = false;\n var memoizedSnapshot;\n var memoizedSelection;\n\n var memoizedSelector = function (nextSnapshot) {\n if (!hasMemo) {\n // The first time the hook is called, there is no memoized result.\n hasMemo = true;\n memoizedSnapshot = nextSnapshot;\n\n var _nextSelection = selector(nextSnapshot);\n\n if (isEqual !== undefined) {\n // Even if the selector has changed, the currently rendered selection\n // may be equal to the new selection. We should attempt to reuse the\n // current value if possible, to preserve downstream memoizations.\n if (inst.hasValue) {\n var currentSelection = inst.value;\n\n if (isEqual(currentSelection, _nextSelection)) {\n memoizedSelection = currentSelection;\n return currentSelection;\n }\n }\n }\n\n memoizedSelection = _nextSelection;\n return _nextSelection;\n } // We may be able to reuse the previous invocation's result.\n\n\n // We may be able to reuse the previous invocation's result.\n var prevSnapshot = memoizedSnapshot;\n var prevSelection = memoizedSelection;\n\n if (objectIs(prevSnapshot, nextSnapshot)) {\n // The snapshot is the same as last time. Reuse the previous selection.\n return prevSelection;\n } // The snapshot has changed, so we need to compute a new selection.\n\n\n // The snapshot has changed, so we need to compute a new selection.\n var nextSelection = selector(nextSnapshot); // If a custom isEqual function is provided, use that to check if the data\n // has changed. If it hasn't, return the previous selection. That signals\n // to React that the selections are conceptually equal, and we can bail\n // out of rendering.\n\n // If a custom isEqual function is provided, use that to check if the data\n // has changed. If it hasn't, return the previous selection. That signals\n // to React that the selections are conceptually equal, and we can bail\n // out of rendering.\n if (isEqual !== undefined && isEqual(prevSelection, nextSelection)) {\n return prevSelection;\n }\n\n memoizedSnapshot = nextSnapshot;\n memoizedSelection = nextSelection;\n return nextSelection;\n }; // Assigning this to a constant so that Flow knows it can't change.\n\n\n // Assigning this to a constant so that Flow knows it can't change.\n var maybeGetServerSnapshot = getServerSnapshot === undefined ? null : getServerSnapshot;\n\n var getSnapshotWithSelector = function () {\n return memoizedSelector(getSnapshot());\n };\n\n var getServerSnapshotWithSelector = maybeGetServerSnapshot === null ? undefined : function () {\n return memoizedSelector(maybeGetServerSnapshot());\n };\n return [getSnapshotWithSelector, getServerSnapshotWithSelector];\n }, [getSnapshot, getServerSnapshot, selector, isEqual]),\n getSelection = _useMemo[0],\n getServerSelection = _useMemo[1];\n\n var value = useSyncExternalStore(subscribe, getSelection, getServerSelection);\n useEffect(function () {\n inst.hasValue = true;\n inst.value = value;\n }, [value]);\n useDebugValue(value);\n return value;\n}\n\nexports.useSyncExternalStoreWithSelector = useSyncExternalStoreWithSelector;\n /* global __REACT_DEVTOOLS_GLOBAL_HOOK__ */\nif (\n typeof __REACT_DEVTOOLS_GLOBAL_HOOK__ !== 'undefined' &&\n typeof __REACT_DEVTOOLS_GLOBAL_HOOK__.registerInternalModuleStop ===\n 'function'\n) {\n __REACT_DEVTOOLS_GLOBAL_HOOK__.registerInternalModuleStop(new Error());\n}\n \n })();\n}\n","'use strict';\n\nif (process.env.NODE_ENV === 'production') {\n module.exports = require('../cjs/use-sync-external-store-shim/with-selector.production.min.js');\n} else {\n module.exports = require('../cjs/use-sync-external-store-shim/with-selector.development.js');\n}\n","import { useCallback, useDebugValue, useLayoutEffect, useMemo, useRef } from 'react';\nimport { useSyncExternalStoreWithSelector } from 'use-sync-external-store/shim/with-selector.js';\nimport type { SubscribeOptions } from '@core/commonTypes';\nimport type { Store } from '@core/store';\nimport { hash } from '@lib/hash';\nimport { makeSelector } from '@lib/makeSelector';\nimport { trackingProxy } from '@lib/trackingProxy';\n\nexport type UseStoreOptions = Omit<SubscribeOptions, 'runNow' | 'passive'>;\n\nexport function useStore<T>(store: Store<T>, options?: UseStoreOptions): T {\n const lastEqualsRef = useRef<(newValue: T) => boolean>();\n\n const { rootStore, selector } = useMemo(() => {\n const rootStore = store.derivedFrom?.store ?? store;\n let selector = (x: any) => x;\n\n if (store.derivedFrom) {\n selector = (value: any) => {\n for (const s of store.derivedFrom!.selectors) {\n value = makeSelector(s)(value);\n }\n return value;\n };\n }\n\n return { rootStore, selector };\n }, [store]);\n\n const subOptions = { ...options, runNow: false, equals: undefined, passive: false };\n const subscribe = useCallback(\n (listener: () => void) => {\n return rootStore.subscribe(listener, subOptions);\n },\n [rootStore, hash(subOptions)],\n );\n\n const value = useSyncExternalStoreWithSelector<unknown, T>(\n //\n subscribe,\n rootStore.get,\n undefined,\n selector,\n options?.equals ?? ((_v, newValue) => lastEqualsRef.current?.(newValue) ?? false),\n );\n const [proxiedValue, equals, revoke] = trackingProxy(value);\n\n useLayoutEffect(() => {\n lastEqualsRef.current = equals;\n revoke?.();\n });\n\n useDebugValue(value);\n return proxiedValue;\n}\n","import type { UseStoreOptions } from './useStore';\nimport { useStore } from './useStore';\nimport type { Store } from '@core/store';\n\nexport function useProp<T>(\n store: Store<T>,\n options?: UseStoreOptions,\n): [value: T, setValue: typeof store.set] {\n const value = useStore(store, options);\n\n return [value, store.set];\n}\n","import { useProp } from './useProp';\nimport { type UseStoreOptions, useStore } from './useStore';\nimport type { Store } from '@core/store';\n\nexport const reactMethods = {\n useStore<T>(this: Store<T>, options?: UseStoreOptions) {\n return useStore(this, options);\n },\n\n useProp<T>(this: Store<T>, options?: UseStoreOptions) {\n return useProp(this, options);\n },\n};\n","import { useEffect, useMemo } from 'react';\nimport type { UseStoreOptions } from './useStore';\nimport { useStore } from './useStore';\nimport type { Cache } from '@core';\nimport type { CacheState } from '@lib/cacheState';\nimport { makeSelector } from '@lib/makeSelector';\n\nexport type UseCacheArray<T> = [\n value: T | undefined,\n error: unknown | undefined,\n isUpdating: boolean,\n isStale: boolean,\n];\n\nexport type UseCacheValue<T> = UseCacheArray<T> & CacheState<T>;\n\nexport interface UseCacheOptions extends UseStoreOptions {\n passive?: boolean;\n updateOnMount?: boolean;\n}\n\nexport function useCache<T>(\n cache: Cache<T>,\n { passive, updateOnMount, ...options }: UseCacheOptions = {},\n): UseCacheValue<T> {\n const mappedState = useMemo(() => {\n const rootCache: Cache<any> = cache.derivedFromCache?.cache ?? cache;\n let selector = (x: any) => x;\n\n if (cache.derivedFromCache) {\n selector = (value: any) => {\n for (const s of cache.derivedFromCache!.selectors) {\n value = makeSelector(s)(value);\n }\n return value;\n };\n }\n\n return rootCache.state.map((state) => {\n const value = state.status === 'value' ? selector(state.value) : undefined;\n\n return Object.assign<UseCacheArray<T>, CacheState<T>>(\n [value, state.error, state.isUpdating, state.isStale],\n { ...state, value },\n );\n });\n }, [cache]);\n\n useEffect(() => (!passive ? cache.subscribe(() => undefined) : undefined), [cache, passive]);\n\n useEffect(() => {\n if (updateOnMount) {\n cache.invalidate();\n }\n }, []);\n\n return useStore(mappedState, options);\n}\n","import type { Context, ReactNode } from 'react';\nimport { createContext, useContext, useMemo } from 'react';\nimport { useProp } from './useProp';\nimport { useStore, type UseStoreOptions } from './useStore';\nimport { createStore } from '@core/store';\nimport type { Store } from '@core/store';\nimport type { Scope } from '@core';\n\nexport type ScopeProps<T> = { scope: Scope<T>; store?: Store<T>; children?: ReactNode };\n\nconst contextMap = new WeakMap<Scope<any>, Context<Store<any>>>();\n\nfunction getScopeContext<T>(scope: Scope<T>): Context<Store<T>> {\n let context = contextMap.get(scope);\n\n if (!context) {\n context = createContext<Store<T>>(createStore(scope.defaultValue));\n contextMap.set(scope, context);\n }\n\n return context;\n}\n\nexport function ScopeProvider<T>({ scope, store: inputStore, children }: ScopeProps<T>) {\n const context = getScopeContext(scope);\n const currentStore = useMemo(\n () => inputStore ?? createStore(scope.defaultValue),\n [scope, inputStore],\n );\n\n return <context.Provider value={currentStore}>{children}</context.Provider>;\n}\n\nexport function useScope<T>(scope: Scope<T>): Store<T> {\n const context = getScopeContext(scope);\n return useContext(context);\n}\n\nexport function useScopeStore<T>(scope: Scope<T>, options?: UseStoreOptions): T {\n const store = useScope(scope);\n return useStore(store, options);\n}\n\nexport function useScopeProp<T>(scope: Scope<T>, options?: UseStoreOptions) {\n const store = useScope(scope);\n return useProp(store, options);\n}\n"],"names":["error","shim","module","require$$0","require$$1","a","c","d","b","e","store","useRef","useMemo","rootStore","selector","value","makeSelector","useCallback","hash","useSyncExternalStoreWithSelector","trackingProxy","useLayoutEffect","useDebugValue","useEffect","createContext","createStore","useContext"],"mappings":";;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;AASa,MAAI,IAAE;AAAiB,WAAS,EAAE,GAAE,GAAE;AAAC,WAAO,MAAI,MAAI,MAAI,KAAG,IAAE,MAAI,IAAE,MAAI,MAAI,KAAG,MAAI;AAAA,EAAC;AAAC,MAAI,IAAE,eAAa,OAAO,OAAO,KAAG,OAAO,KAAG,GAAE,IAAE,EAAE,UAAS,IAAE,EAAE,WAAU,IAAE,EAAE,iBAAgB,IAAE,EAAE;AAAc,WAAS,EAAE,GAAE,GAAE;AAAC,QAAI,IAAE,EAAC,GAAG,IAAE,EAAE,EAAC,MAAK,EAAC,OAAM,GAAE,aAAY,EAAC,EAAC,CAAC,GAAE,IAAE,EAAE,CAAC,EAAE,MAAK,IAAE,EAAE,CAAC;AAAE,MAAE,WAAU;AAAC,QAAE,QAAM;AAAE,QAAE,cAAY;AAAE,QAAE,CAAC,KAAG,EAAE,EAAC,MAAK,EAAC,CAAC;AAAA,IAAC,GAAE,CAA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AwBC,MAAAA,YAAY,MAAM,YAAY,CAAC;AACtD,eAAA,IAAI,OAAO,OAAO;AAAA,EAC/B;AAEO,SAAA;AACT;AAEO,SAAS,cAAiB,EAAE,OAAO,OAAO,YAAY,YAA2B;AAChF,QAAA,UAAU,gBAAgB,KAAK;AACrC,QAAM,eAAeb,WAAA;AAAA,IACnB,MAAM,cAAca,MAAAA,YAAY,MAAM,YAAY;AAAA,IAClD,CAAC,OAAO,UAAU;AAAA,EAAA;AAGpB,wCAAQ,QAAQ,UAAR,EAAiB,OAAO,cAAe,SAAS,CAAA;AAC1D;AAEO,SAAS,SAAY,OAA2B;AAC/C,QAAA,UAAU,gBAAgB,KAAK;AACrC,SAAOC,WAAAA,WAAW,OAAO;AAC3B;AAEgB,SAAA,cAAiB,OAAiB,SAA8B;AACxE,QAAAhB,SAAQ,SAAS,KAAK;AACrB,SAAA,SAASA,QAAO,OAAO;AAChC;AAEgB,SAAA,aAAgB,OAAiB,SAA2B;AACpE,QAAAA,SAAQ,SAAS,KAAK;AACrB,SAAA,QAAQA,QAAO,OAAO;AAC/B;;;;;;;;;","x_google_ignoreList":[0,1,2,3,4,5]}
@@ -110,6 +110,7 @@ const internalEqual = (comp) => (a, b) => {
110
110
  }
111
111
  return false;
112
112
  };
113
+ const unwrapProxySymbol = /* @__PURE__ */ Symbol("unwrapProxy");
113
114
  function isPlainObject(value) {
114
115
  return typeof value === "object" && value !== null && Object.getPrototypeOf(value) === Object.prototype;
115
116
  }
@@ -117,15 +118,21 @@ function trackingProxy(value, equals = deepEqual) {
117
118
  if (!isPlainObject(value) && !Array.isArray(value)) {
118
119
  return [value, (other) => equals(value, other)];
119
120
  }
121
+ value = value[unwrapProxySymbol] ?? value;
120
122
  const deps = new Array();
123
+ const revokations = new Array();
124
+ let revoked = false;
121
125
  function trackComplexProp(function_, ...args) {
122
- const [proxiedValue, equals2] = trackingProxy(function_(value, ...args));
126
+ const [proxiedValue, equals2, revoke] = trackingProxy(function_(value, ...args));
123
127
  deps.push((otherValue) => {
124
128
  if (!isPlainObject(otherValue) && !Array.isArray(otherValue)) {
125
129
  return false;
126
130
  }
127
131
  return equals2(function_(otherValue, ...args));
128
132
  });
133
+ if (revoke) {
134
+ revokations.push(revoke);
135
+ }
129
136
  return proxiedValue;
130
137
  }
131
138
  function trackSimpleProp(function_, ...args) {
@@ -137,6 +144,12 @@ function trackingProxy(value, equals = deepEqual) {
137
144
  }
138
145
  const proxy = new Proxy(value, {
139
146
  get(target, p, receiver) {
147
+ if (p === unwrapProxySymbol) {
148
+ return value;
149
+ }
150
+ if (revoked) {
151
+ return target[p];
152
+ }
140
153
  const { writable, configurable } = Object.getOwnPropertyDescriptor(target, p) ?? {};
141
154
  if (writable === false && configurable === false) {
142
155
  return target[p];
@@ -163,7 +176,14 @@ function trackingProxy(value, equals = deepEqual) {
163
176
  return trackSimpleProp(Reflect.isExtensible);
164
177
  }
165
178
  });
166
- return [proxy, (other) => !!other && deps.every((equals2) => equals2(other))];
179
+ return [
180
+ proxy,
181
+ (other) => !!other && deps.every((equals2) => equals2(other)),
182
+ () => {
183
+ revoked = true;
184
+ revokations.forEach((revoke) => revoke());
185
+ }
186
+ ];
167
187
  }
168
188
  class CalculationHelper {
169
189
  constructor(options) {
@@ -1 +1 @@
1
- {"version":3,"file":"store.cjs","sources":["../../src/lib/calcDuration.ts","../../src/lib/queue.ts","../../src/lib/equals.ts","../../src/lib/trackingProxy.ts","../../src/lib/calculationHelper.ts","../../src/lib/callable.ts","../../src/lib/debounce.ts","../../src/lib/forwardError.ts","../../src/lib/clone.ts","../../src/lib/propAccess.ts","../../src/lib/makeSelector.ts","../../src/lib/standardMethods.ts","../../src/lib/throttle.ts","../../src/core/store.ts"],"sourcesContent":["import type { Duration } from '../core/commonTypes';\n\nexport function calcDuration(t: Duration) {\n if (typeof t === 'number') return t;\n return (\n (t.milliseconds ?? 0) +\n (t.seconds ?? 0) * 1000 +\n (t.minutes ?? 0) * 60 * 1000 +\n (t.hours ?? 0) * 60 * 60 * 1000 +\n (t.days ?? 0) * 24 * 60 * 60 * 1000\n );\n}\n","import type { MaybePromise } from './maybePromise';\nimport type { Listener } from '@core';\n\ntype Action<T> = () => MaybePromise<T>;\n\nexport interface Queue {\n <T>(action: Action<T>, ref?: any): Promise<T>;\n clear: () => void;\n whenDone: () => Promise<void>;\n size: number;\n getRefs: () => any[];\n}\n\nexport function queue(): Queue {\n const q: {\n action: Action<any>;\n resolve: (value: any) => void;\n reject: (error: unknown) => void;\n ref?: any;\n }[] = [];\n const completionListeners = new Set<Listener<void>>();\n let active = false;\n\n const notify = () => {\n for (const listener of completionListeners) {\n listener();\n }\n\n completionListeners.clear();\n };\n\n const run = async () => {\n if (!active) {\n active = true;\n\n let next;\n while ((next = q.shift())) {\n try {\n let result = next.action();\n if (result instanceof Promise) {\n result = await result;\n }\n\n next.resolve(result);\n } catch (error) {\n next.reject(error);\n }\n }\n\n active = false;\n notify();\n }\n };\n\n return Object.assign(\n <T>(action: Action<T>, ref?: any) => {\n return new Promise<T>((resolve, reject) => {\n q.push({ action, resolve, reject, ref });\n run();\n });\n },\n {\n clear() {\n q.length = 0;\n },\n\n whenDone() {\n if (!active) {\n return Promise.resolve();\n }\n\n return new Promise<void>((resolve) => {\n completionListeners.add(resolve);\n });\n },\n\n get size() {\n return q.length;\n },\n\n getRefs() {\n return q.map((item) => item.ref).filter((x) => x !== undefined);\n },\n },\n );\n}\n","export function defaultEqual(a: any, b: any) {\n return a === b;\n}\n\nexport function shallowEqual(a: any, b: any): boolean {\n return internalEqual(defaultEqual)(a, b);\n}\n\nexport function deepEqual(a: any, b: any): boolean {\n return internalEqual(deepEqual)(a, b);\n}\n\nconst internalEqual = (comp: (a: any, b: any) => boolean) => (a: any, b: any) => {\n if (a === b) {\n return true;\n }\n\n if (a === null || b === null || typeof a !== 'object' || typeof b !== 'object') {\n // eslint-disable-next-line no-self-compare\n return a !== a && b !== b;\n }\n\n if (a.constructor !== b.constructor) {\n return false;\n }\n\n if (a.constructor === Object) {\n const entries1 = Object.entries(a);\n const entries2 = Object.entries(b);\n return (\n entries1.length === entries2.length && entries1.every(([key, value]) => comp(value, b[key]))\n );\n }\n\n if (Array.isArray(a)) {\n return a.length === b.length && a.every((value, i) => comp(value, b[i]));\n }\n\n if (a instanceof Date) {\n return a.getTime() === b.getTime();\n }\n\n if (a instanceof RegExp) {\n return a.source === b.source && a.flags === b.flags;\n }\n\n if (a instanceof Map) {\n return a.size === b.size && [...a.entries()].every(([key, value]) => comp(value, b.get(key)));\n }\n\n if (a instanceof Set) {\n return a.size === b.size && [...a.values()].every((value) => b.has(value));\n }\n\n if (typeof ArrayBuffer !== 'undefined' && ArrayBuffer.isView(a)) {\n if (a.byteLength !== b.byteLength) {\n return false;\n }\n\n const a_ = new Int8Array(a.buffer);\n const b_ = new Int8Array(b.buffer);\n return a_.every((value, i) => value === b_[i]);\n }\n\n return false;\n};\n","import { deepEqual } from './equals';\n\nexport type TrackingProxy<T> = [value: T, equals: (newValue: T) => boolean];\ntype Object_ = Record<string | symbol, unknown>;\n\nfunction isPlainObject(value: unknown) {\n return (\n typeof value === 'object' && value !== null && Object.getPrototypeOf(value) === Object.prototype\n );\n}\n\nexport function trackingProxy<T>(value: T, equals = deepEqual): TrackingProxy<T> {\n if (!isPlainObject(value) && !Array.isArray(value)) {\n return [value, (other) => equals(value, other)];\n }\n\n const deps = new Array<TrackingProxy<any>[1]>();\n\n function trackComplexProp(function_: any, ...args: any[]) {\n const [proxiedValue, equals] = trackingProxy(function_(value, ...args));\n\n deps.push((otherValue) => {\n if (!isPlainObject(otherValue) && !Array.isArray(otherValue)) {\n return false;\n }\n\n return equals(function_(otherValue, ...args));\n });\n\n return proxiedValue;\n }\n\n function trackSimpleProp(function_: any, ...args: any[]) {\n const calculatedValue = function_(value, ...args);\n\n deps.push((otherValue) => {\n return function_(otherValue, ...args) === calculatedValue;\n });\n\n return calculatedValue;\n }\n\n const proxy = new Proxy(value as T & Object_, {\n get(target, p, receiver) {\n const { writable, configurable } = Object.getOwnPropertyDescriptor(target, p) ?? {};\n if (writable === false && configurable === false) {\n return target[p];\n }\n\n return trackComplexProp(Reflect.get, p, receiver);\n },\n\n getOwnPropertyDescriptor(target, p) {\n const { writable, configurable } = Object.getOwnPropertyDescriptor(target, p) ?? {};\n if (writable === false && configurable === false) {\n return Reflect.getOwnPropertyDescriptor(target, p);\n }\n\n return trackComplexProp(Reflect.getOwnPropertyDescriptor, p);\n },\n\n ownKeys() {\n return trackComplexProp(Reflect.ownKeys);\n },\n\n getPrototypeOf() {\n return trackSimpleProp(Reflect.getPrototypeOf);\n },\n\n has(_target, p) {\n return trackSimpleProp(Reflect.has, p);\n },\n\n isExtensible() {\n return trackSimpleProp(Reflect.isExtensible);\n },\n });\n\n return [proxy, (other) => !!other && deps.every((equals) => equals(other))];\n}\n","import type { MaybePromise } from './maybePromise';\nimport { queue } from './queue';\nimport { trackingProxy } from './trackingProxy';\nimport { deepEqual } from './equals';\nimport type { Store } from '@core/store';\nimport type {\n CalculationHelpers,\n Cancel,\n ConnectionState,\n UpdateFrom,\n Use,\n} from '@core/commonTypes';\n\nexport class CalculationHelper<T> {\n private current?: {\n cancel: Cancel;\n check: () => void;\n invalidateDependencies: () => void;\n };\n\n constructor(\n public options: {\n calculate: (helpers: CalculationHelpers<T>) => Cancel | void;\n addEffect: (effect: () => Cancel | void) => Cancel;\n getValue?: () => T | undefined;\n onValue?: (value: T) => void;\n onError?: (error: unknown) => void;\n onConnectionState?: (state: ConnectionState) => void;\n onInvalidate?: () => void;\n },\n ) {\n options.addEffect(() => {\n if (this.current) {\n this.current.check();\n } else {\n this.execute();\n }\n });\n }\n\n execute() {\n this.stop();\n\n const { calculate, addEffect, getValue, onValue, onError, onConnectionState, onInvalidate } =\n this.options;\n const checks = new Array<() => boolean>();\n const deps = new Map<Store<any>, { on: () => void; off: () => void; invalidate: () => void }>();\n const q = queue();\n let isActive = false;\n let isCancled = false;\n\n const cancelEffect = addEffect(() => {\n isActive = true;\n\n for (const dep of deps.values()) {\n dep.on();\n }\n\n return () => {\n isActive = false;\n\n for (const dep of deps.values()) {\n dep.off();\n }\n\n if (cancelSubscription) {\n cancelSubscription();\n cancelSubscription = undefined;\n cancel();\n onInvalidate?.();\n }\n };\n });\n\n const cancel = () => {\n isCancled = true;\n cancelSubscription?.();\n cancelEffect();\n delete this.current;\n };\n\n const checkAll = () => {\n if (!checks.every((check) => check())) {\n cancel();\n onInvalidate?.();\n }\n };\n\n const invalidateDependencies = () => {\n for (const dep of deps.values()) {\n dep.invalidate();\n }\n };\n\n const use: Use = (store, { disableProxy } = {}) => {\n if (isCancled) {\n return store.get();\n }\n\n let value = store.get();\n let equals = (newValue: any) => {\n return deepEqual(newValue, value);\n };\n\n if (!disableProxy) {\n [value, equals] = trackingProxy(value);\n }\n\n const check = () => equals(store.get());\n let sub: Cancel | undefined;\n\n const dep = {\n on() {\n this.off();\n\n sub = store.subscribe(\n () => {\n if (sub && !check()) {\n cancel();\n onInvalidate?.();\n }\n },\n { runNow: false },\n );\n },\n off() {\n sub?.();\n sub = undefined;\n },\n invalidate() {\n if ('invalidate' in store && store.invalidate instanceof Function) {\n store.invalidate();\n }\n },\n };\n\n if (isActive) {\n dep.on();\n }\n\n checks.push(check);\n deps.set(store, dep);\n\n return value;\n };\n\n const updateValue = (update: UpdateFrom<MaybePromise<T>, [T | undefined]>) =>\n q(async () => {\n if (isCancled) {\n return;\n }\n\n if (update instanceof Function) {\n try {\n update = update(getValue?.());\n } catch (error) {\n onError?.(error);\n return;\n }\n }\n\n if (update instanceof Promise) {\n try {\n update = await update;\n } catch (error) {\n if (!isCancled) {\n onError?.(error);\n }\n return;\n }\n }\n\n if (!isCancled) {\n onValue?.(update);\n }\n });\n\n const updateError = (error: unknown) =>\n q(() => {\n if (!isCancled) {\n onError?.(error);\n }\n });\n\n const updateConnectionState = (state: ConnectionState) =>\n q(() => {\n if (!isCancled) {\n onConnectionState?.(state);\n }\n });\n\n let cancelSubscription: Cancel | void;\n try {\n cancelSubscription = calculate({ use, updateValue, updateError, updateConnectionState });\n } catch (error) {\n onError?.(error);\n }\n\n this.current = { cancel, check: checkAll, invalidateDependencies };\n }\n\n stop() {\n this.current?.cancel();\n }\n\n check() {\n this.current?.check();\n }\n\n checkOrExecute() {\n if (this.current) {\n this.check();\n } else {\n this.execute();\n }\n }\n\n invalidateDependencies() {\n this.current?.invalidateDependencies();\n }\n}\n","export class Callable<Args extends any[], T> extends Function {\n constructor(protected _call: (...args: Args) => T) {\n super('...args', 'return this._call(...args)');\n\n // eslint-disable-next-line no-constructor-return\n return this.bind(this);\n }\n}\n","import { calcDuration } from './calcDuration';\nimport type { Duration } from '@core';\n\nexport type DebounceOptions =\n | Duration\n | {\n wait: Duration;\n maxWait?: Duration;\n };\n\nexport function debounce<Args extends any[]>(\n action: (...args: Args) => void,\n options: Duration | DebounceOptions,\n): (...args: Args) => void {\n const wait =\n typeof options === 'object' && 'wait' in options\n ? calcDuration(options.wait)\n : calcDuration(options);\n\n const maxWait =\n typeof options === 'object' && 'maxWait' in options && options.maxWait !== undefined\n ? calcDuration(options.maxWait)\n : undefined;\n\n let timeout: ReturnType<typeof setTimeout> | undefined;\n let timeoutStarted: number | undefined;\n\n return (...args: Args) => {\n const now = Date.now();\n timeoutStarted ??= now;\n\n const deadline = Math.min(\n //\n now + wait,\n timeoutStarted + (maxWait ?? Number.POSITIVE_INFINITY),\n );\n\n if (timeout !== undefined) {\n clearTimeout(timeout);\n }\n\n timeout = setTimeout(() => {\n timeout = undefined;\n timeoutStarted = undefined;\n action(...args);\n }, deadline - now);\n };\n}\n","export function forwardError(error: unknown) {\n setTimeout(() => {\n throw error;\n });\n}\n","export function flatClone<T>(object: T): T {\n if (object instanceof Map) {\n return new Map(object) as any;\n }\n\n if (object instanceof Set) {\n return new Set(object) as any;\n }\n\n if (Array.isArray(object)) {\n return [...object] as any;\n }\n\n if (object instanceof Object) {\n return { ...object };\n }\n\n return object;\n}\n","import type { Update } from '../core/commonTypes';\nimport { flatClone } from './clone';\nimport type { Path, Value } from './path';\n\nexport function castArrayPath(path: string | KeyType[]): KeyType[] {\n if (Array.isArray(path)) {\n return path as any;\n }\n\n if (path === '') {\n return [] as any;\n }\n\n return (path as string).split('.') as any;\n}\n\nexport function get<T, P extends Path<T>>(object: T, path: P): Value<T, P> {\n const _path = castArrayPath(path as any);\n const [first, ...rest] = _path;\n\n if (first === undefined || !object) {\n return object as Value<T, P>;\n }\n\n if (object instanceof Map) {\n return get(object.get(first), rest as any);\n }\n\n if (object instanceof Set) {\n return get(Array.from(object)[Number(first)], rest as any);\n }\n\n if (object instanceof Object) {\n return get(object[first as keyof T], rest as any) as Value<T, P>;\n }\n\n throw new Error(`Could not get ${path} of ${object}`);\n}\n\nexport function set<T, P extends Path<T>>(\n object: T,\n path: P,\n value: Update<Value<T, P>>,\n rootPath = path,\n): T {\n const _path = castArrayPath(path as any);\n const [first, ...rest] = _path;\n\n if (first === undefined) {\n return value as any;\n }\n\n const updateChild = (child: any) => {\n if (!child && rest.length > 0) {\n const _rootPath = castArrayPath(rootPath as any);\n\n const prefix = _rootPath.slice(0, -rest.length) as KeyType[];\n throw new Error(`Cannot set ${rootPath} because ${prefix.join('.')} is ${child}`);\n }\n\n return set(child, rest as any, value, rootPath);\n };\n\n if (object instanceof Map) {\n const copy = flatClone(object);\n const child = copy.get(first);\n copy.set(first, updateChild(child));\n return copy;\n }\n\n if (object instanceof Set) {\n const copy = [...object];\n const child = copy[Number(first)];\n copy[Number(first)] = updateChild(child);\n return new Set(copy) as any;\n }\n\n if (object instanceof Object || object === undefined) {\n const copy = flatClone(object ?? ({} as T));\n copy[first as keyof T] = updateChild(copy[first as keyof T]);\n return copy;\n }\n\n throw new Error(`Could not set ${path} of ${object}`);\n}\n\nexport function remove<T, P extends Path<T, true>>(object: T, path: P): T {\n const _path = castArrayPath(path as any);\n\n if (_path.length === 0) {\n return undefined as any;\n }\n\n const parentPath = _path.slice(0, -1);\n const key = _path[_path.length - 1];\n\n const parent = flatClone(get(object, parentPath as any));\n\n if (parent instanceof Map) {\n parent.delete(key);\n } else if (parent instanceof Set) {\n const value = Array.from(parent)[Number(key)];\n parent.delete(value);\n } else {\n delete parent[key as keyof typeof parent];\n }\n\n return set(object, parentPath as any, parent);\n}\n","import type { Path } from './path';\nimport { get } from './propAccess';\n\nexport function makeSelector<T, S>(selector?: ((value: T) => S) | Path<any>): (value: T) => S {\n if (!selector) {\n return (x) => x as any;\n }\n\n if (selector instanceof Function) {\n return selector;\n }\n\n return (x) => get(x, selector as any) as any;\n}\n","import type { Store } from '../core/store';\nimport type { OptionalPropertyOf } from './typeHelpers';\n\ntype Function_ = (...args: any) => any;\n\nfunction createArrayAction<P extends keyof Array<any>>(prop: P) {\n return function arrayAction<T extends Array<any>>(\n this: Store<T>,\n ...args: T[P] extends Function_ ? Parameters<T[P]> : never\n ): T[P] extends Function_ ? ReturnType<T[P]> : never {\n const newArray = this.get().slice() as T;\n const result = (newArray[prop] as Function_)(...(args as any));\n this.set(newArray);\n return result;\n };\n}\nexport const arrayMethods = {\n splice: /* @__PURE__ */ createArrayAction('splice'),\n push: /* @__PURE__ */ createArrayAction('push'),\n pop: /* @__PURE__ */ createArrayAction('pop'),\n shift: /* @__PURE__ */ createArrayAction('shift'),\n unshift: /* @__PURE__ */ createArrayAction('unshift'),\n reverse: /* @__PURE__ */ createArrayAction('reverse'),\n sort: /* @__PURE__ */ createArrayAction('sort'),\n};\n\nexport const recordMethods = {\n delete<T extends Record<any, any>, K extends OptionalPropertyOf<T>>(this: Store<T>, key: K) {\n const copy = { ...this.get() };\n delete copy[key];\n this.set(copy);\n },\n\n clear<T extends Record<any, any>>(this: Store<Partial<T>>) {\n this.set({} as T);\n },\n};\n\nexport const mapMethods = {\n delete<K, V>(this: Store<Map<K, V>>, key: K) {\n const newMap = new Map(this.get());\n const result = newMap.delete(key);\n this.set(newMap);\n return result;\n },\n\n clear<K, V>(this: Store<Map<K, V>>) {\n this.set(new Map());\n },\n};\n\nexport const setMethods = {\n add<T>(this: Store<Set<T>>, value: T) {\n const newSet = new Set(this.get());\n newSet.add(value);\n this.set(newSet);\n },\n\n delete<T>(this: Store<Set<T>>, value: T) {\n const newSet = new Set(this.get());\n newSet.delete(value);\n this.set(newSet);\n },\n\n clear<T>(this: Store<Set<T>>) {\n this.set(new Set());\n },\n};\n","import { calcDuration } from './calcDuration';\nimport type { Duration } from '@core';\n\nexport function throttle<Args extends any[]>(\n action: (...args: Args) => void,\n duration: Duration,\n): (...args: Args) => void {\n const ms = calcDuration(duration);\n\n let t = 0;\n let timeout: ReturnType<typeof setTimeout> | undefined;\n\n return (...args: Args) => {\n if (timeout !== undefined) {\n clearTimeout(timeout);\n }\n\n const dt = t + ms - Date.now();\n if (dt <= 0) {\n action(...args);\n t = Date.now();\n return;\n }\n\n timeout = setTimeout(() => {\n action(...args);\n t = Date.now();\n }, dt);\n };\n}\n","import type {\n CalculationHelpers,\n Cancel,\n Duration,\n Effect,\n Listener,\n Selector,\n SubscribeOptions,\n Update,\n Use,\n UseOptions,\n} from './commonTypes';\nimport { calcDuration } from '@lib/calcDuration';\nimport { CalculationHelper } from '@lib/calculationHelper';\nimport { Callable } from '@lib/callable';\nimport { debounce } from '@lib/debounce';\nimport { deepEqual } from '@lib/equals';\nimport { forwardError } from '@lib/forwardError';\nimport { makeSelector } from '@lib/makeSelector';\nimport type { Path, Value } from '@lib/path';\nimport { get, set } from '@lib/propAccess';\nimport { arrayMethods, mapMethods, recordMethods, setMethods } from '@lib/standardMethods';\nimport { throttle } from '@lib/throttle';\n\nexport type StoreMethods = Record<string, (...args: any[]) => any>;\n\nexport type BoundStoreMethods<T, Methods extends StoreMethods> = Methods &\n ThisType<Store<T> & Methods>;\n\nexport interface StoreOptions {\n retain?: Duration;\n}\n\nexport interface StoreOptionsWithMethods<T, Methods extends StoreMethods> extends StoreOptions {\n methods?: Methods & ThisType<Store<T> & Methods & StandardMethods<T>>;\n}\n\nexport type Calculate<T> = (this: CalculationHelpers<T>, helpers: CalculationHelpers<T>) => T;\n\ntype StandardMethods<T> = T extends Map<any, any>\n ? typeof mapMethods\n : T extends Set<any>\n ? typeof setMethods\n : T extends Array<any>\n ? typeof arrayMethods\n : T extends Record<any, any>\n ? typeof recordMethods\n : Record<string, never>;\n\ntype StoreWithMethods<T, Methods extends StoreMethods> = Store<T> &\n Omit<BoundStoreMethods<T, Methods>, keyof Store<T>> &\n StandardMethods<T>;\n\nfunction noop() {\n return undefined;\n}\n\nexport class Store<T> extends Callable<any, any> {\n protected _value?: { v: T };\n\n protected listeners = new Map<Listener, boolean>();\n\n protected effects = new Map<\n Effect,\n { handle?: Cancel; retain?: number; timeout?: ReturnType<typeof setTimeout> }\n >();\n\n protected notifyId = {};\n\n protected calculationHelper = new CalculationHelper<T>({\n calculate: (helpers) => {\n if (this.getter instanceof Function) {\n const value = this.getter.apply(helpers, [helpers]);\n this._value = { v: value };\n this.notify();\n }\n },\n addEffect: (effect) => this.addEffect(effect, this.options.retain),\n getValue: () => this._value?.v,\n onInvalidate: () => this.reset(),\n });\n\n constructor(\n public readonly getter: T | Calculate<T>,\n public readonly options: StoreOptions = {},\n public readonly derivedFrom?: {\n store: Store<any>;\n selectors: (Selector<any, any> | Path<any>)[];\n updater: (state: any) => void;\n },\n protected readonly _call: (...args: any[]) => any = () => undefined,\n ) {\n super(_call);\n this.get = this.get.bind(this);\n this.set = this.set.bind(this);\n this.subscribe = this.subscribe.bind(this);\n this.once = this.once.bind(this);\n this.map = this.map.bind(this);\n this.addEffect = this.addEffect.bind(this);\n this.isActive = this.isActive.bind(this);\n\n if (!(getter instanceof Function)) {\n this._value = { v: getter };\n }\n }\n\n get(): T {\n this.calculationHelper.check();\n\n if (!this._value) {\n this.calculationHelper.execute();\n return this.get();\n }\n\n return this._value.v;\n }\n\n set(update: Update<T>): void;\n\n set<P extends Path<T>>(path: P, update: Update<Value<T, P>>): void;\n\n set(...args: any[]): void {\n const path: any = args.length > 1 ? args[0] : [];\n let update: Update<any> = args.length > 1 ? args[1] : args[0];\n\n if (update instanceof Function) {\n const before = this.get();\n const valueBefore = get(before, path);\n const valueAfter = update(valueBefore);\n update = set(before, path, valueAfter);\n } else if (path.length > 0) {\n update = set(this.get(), path, update);\n }\n\n if (this.derivedFrom) {\n this.derivedFrom.updater(update);\n return;\n }\n\n this._value = { v: update };\n this.notify();\n }\n\n protected reset() {\n this._value = undefined;\n\n if (this.isActive()) {\n this.calculationHelper.execute();\n }\n }\n\n subscribe(listener: Listener<T>, options?: SubscribeOptions): Cancel {\n const {\n passive,\n runNow = true,\n throttle: throttleOption,\n debounce: debounceOption,\n equals = deepEqual,\n } = options ?? {};\n\n let compareToValue = this._value?.v;\n let previousValue: T | undefined;\n let hasRun = false;\n\n let innerListener = (force?: boolean | void) => {\n if (!this._value) {\n return;\n }\n\n const value = this._value.v;\n\n if (!force && equals(value, compareToValue)) {\n return;\n }\n\n compareToValue = value;\n const _previousValue = previousValue;\n previousValue = value;\n hasRun = true;\n\n try {\n listener(value, _previousValue);\n } catch (error) {\n forwardError(error);\n }\n };\n\n if (throttleOption) {\n innerListener = throttle(innerListener, throttleOption);\n } else if (debounceOption) {\n innerListener = debounce(innerListener, debounceOption);\n }\n\n this.listeners.set(innerListener, !passive);\n if (!passive) {\n this.onSubscribe();\n }\n\n if (runNow && !hasRun) {\n innerListener(true);\n }\n\n return () => {\n this.listeners.delete(innerListener);\n if (!passive) {\n this.onUnsubscribe();\n }\n };\n }\n\n once<S extends T>(condition: (value: T) => value is S): Promise<S>;\n\n once(condition?: (value: T) => boolean): Promise<T>;\n\n once(condition: (value: T) => boolean = (value) => !!value): Promise<any> {\n return new Promise<T>((resolve) => {\n let stopped = false;\n const cancel = this.subscribe(\n (value) => {\n if (stopped || (condition && !condition(value))) {\n return;\n }\n\n resolve(value);\n stopped = true;\n setTimeout(() => cancel());\n },\n {\n runNow: !!condition,\n },\n );\n });\n }\n\n map<S>(\n selector: Selector<T, S>,\n updater?: (value: S) => Update<T>,\n options?: UseOptions,\n ): Store<S>;\n\n map<P extends Path<T>>(selector: P, options?: UseOptions): Store<Value<T, P>>;\n\n map(_selector: Selector<T, any> | Path<any>, ...args: any[]): Store<any> {\n const updater: ((value: any) => Update<T>) | undefined =\n _selector instanceof Function\n ? args[0]\n : (value) => (state) => set(state, _selector as Path<T>, value);\n\n const options = _selector instanceof Function ? args[1] : args[0];\n\n const selector = makeSelector(_selector);\n\n const derivedFrom = {\n store: this.derivedFrom ? this.derivedFrom.store : this,\n selectors: this.derivedFrom ? [...this.derivedFrom.selectors, _selector] : [_selector],\n\n updater: (value: any) => {\n if (!updater) {\n throw new TypeError(\n 'Can only updated computed stores that either are derived from other stores using string selectors or have an updater function.',\n );\n }\n\n let update = updater(value);\n\n if (update instanceof Function) {\n update = update(this.get());\n }\n\n if (this.derivedFrom) {\n this.derivedFrom.updater(update);\n } else {\n this.set(update);\n }\n },\n };\n\n return new Store(\n ({ use }) => {\n return selector(use(this, options));\n },\n this.options,\n derivedFrom,\n );\n }\n\n /** Add an effect that will be executed when the store becomes active, which means when it has at least one subscriber.\n * @param effect\n * If there is already a subscriber, the effect will be executed immediately.\n * Otherweise it will be executed as soon as the first subscription is created.\n * Every time all subscriptions are removed and the first is created again, the effect will be executed again.\n * @param retain\n * If provided, delay tearing down effects when the last subscriber is removed. This is useful if a short gap in subscriber coverage is supposed to be ignored. E.g. when switching pages, the old page might unsubscribe, while the new page subscribes immediately after.\n * @returns\n * The effect can return a teardown callback, which will be executed when the last subscription is removed and potentially the ratain time has passed.\n */\n addEffect(effect: Effect, retain?: Duration) {\n this.effects.set(effect, {\n handle: this.isActive() ? effect() ?? noop : undefined,\n retain: retain !== undefined ? calcDuration(retain) : undefined,\n });\n\n return () => {\n const { handle, timeout } = this.effects.get(effect) ?? {};\n handle?.();\n\n if (timeout !== undefined) {\n clearTimeout(timeout);\n }\n\n this.effects.delete(effect);\n };\n }\n\n /** Return whether the store is currently active, which means whether it has at least one subscriber. */\n isActive() {\n return [...this.listeners.values()].some(Boolean);\n }\n\n protected onSubscribe() {\n if ([...this.listeners.values()].filter(Boolean).length > 1) return;\n\n for (const [effect, { handle, retain, timeout }] of this.effects.entries()) {\n if (timeout !== undefined) {\n clearTimeout(timeout);\n }\n\n this.effects.set(effect, {\n handle: handle ?? effect() ?? noop,\n retain,\n timeout: undefined,\n });\n }\n }\n\n protected onUnsubscribe() {\n if ([...this.listeners.values()].some(Boolean)) return;\n\n for (const [effect, { handle, retain, timeout }] of this.effects.entries()) {\n if (!retain) {\n handle?.();\n }\n\n if (timeout !== undefined) {\n clearTimeout(timeout);\n }\n\n this.effects.set(effect, {\n handle: retain ? handle : undefined,\n retain,\n timeout: retain && handle ? setTimeout(handle, retain) : undefined,\n });\n }\n }\n\n protected notify() {\n const n = {};\n this.notifyId = n;\n\n const snapshot = [...this.listeners.keys()];\n for (const listener of snapshot) {\n listener();\n if (n !== this.notifyId) break;\n }\n }\n}\n\nconst defaultOptions: StoreOptions = {};\n\nfunction create<T>(\n calculate: (this: { use: Use }, fns: { use: Use }) => T,\n options?: StoreOptions,\n): Store<T>;\nfunction create<T, Methods extends StoreMethods = {}>(\n initialState: T,\n options?: StoreOptionsWithMethods<T, Methods>,\n): StoreWithMethods<T, Methods>;\nfunction create<T, Methods extends StoreMethods>(\n initialState: T | ((this: { use: Use }, fns: { use: Use }) => T),\n options?: StoreOptionsWithMethods<T, Methods>,\n): StoreWithMethods<T, Methods> | Store<T> {\n const store = new Store(initialState, options);\n\n if (initialState instanceof Function) {\n return store;\n }\n\n let methods: StoreMethods | undefined = options?.methods;\n\n if (initialState instanceof Map) {\n methods = { ...mapMethods, ...methods };\n } else if (initialState instanceof Set) {\n methods = { ...setMethods, ...methods };\n } else if (Array.isArray(initialState)) {\n methods = { ...arrayMethods, ...methods };\n } else if (initialState instanceof Object) {\n methods = { ...recordMethods, ...methods };\n }\n\n const boundMethods = Object.fromEntries(\n Object.entries(methods ?? ({} as BoundStoreMethods<T, any>))\n .filter(([name]) => !(name in store))\n .map(([name, action]) => [name, (action as any).bind(store)]),\n ) as BoundStoreMethods<T, any>;\n\n return Object.assign(store, boundMethods);\n}\n\nexport const createStore = /* @__PURE__ */ Object.assign(create, { defaultOptions });\n"],"names":["equals"],"mappings":";AAEO,SAAS,aAAa,GAAa;AACxC,MAAI,OAAO,MAAM;AAAiB,WAAA;AAE/B,UAAA,EAAE,gBAAgB,MAClB,EAAE,WAAW,KAAK,OAClB,EAAE,WAAW,KAAK,KAAK,OACvB,EAAE,SAAS,KAAK,KAAK,KAAK,OAC1B,EAAE,QAAQ,KAAK,KAAK,KAAK,KAAK;AAEnC;ACEO,SAAS,QAAe;AAC7B,QAAM,IAKA,CAAA;AACA,QAAA,0CAA0B;AAChC,MAAI,SAAS;AAEb,QAAM,SAAS,MAAM;AACnB,eAAW,YAAY,qBAAqB;AACjC;IACX;AAEA,wBAAoB,MAAM;AAAA,EAAA;AAG5B,QAAM,MAAM,YAAY;AACtB,QAAI,CAAC,QAAQ;AACF,eAAA;AAEL,UAAA;AACI,aAAA,OAAO,EAAE,SAAU;AACrB,YAAA;AACE,cAAA,SAAS,KAAK;AAClB,cAAI,kBAAkB,SAAS;AAC7B,qBAAS,MAAM;AAAA,UACjB;AAEA,eAAK,QAAQ,MAAM;AAAA,iBACZ;AACP,eAAK,OAAO,KAAK;AAAA,QACnB;AAAA,MACF;AAES,eAAA;AACF;IACT;AAAA,EAAA;AAGF,SAAO,OAAO;AAAA,IACZ,CAAI,QAAmB,QAAc;AACnC,aAAO,IAAI,QAAW,CAAC,SAAS,WAAW;AACzC,UAAE,KAAK,EAAE,QAAQ,SAAS,QAAQ,KAAK;AACnC;MAAA,CACL;AAAA,IACH;AAAA,IACA;AAAA,MACE,QAAQ;AACN,UAAE,SAAS;AAAA,MACb;AAAA,MAEA,WAAW;AACT,YAAI,CAAC,QAAQ;AACX,iBAAO,QAAQ;QACjB;AAEO,eAAA,IAAI,QAAc,CAAC,YAAY;AACpC,8BAAoB,IAAI,OAAO;AAAA,QAAA,CAChC;AAAA,MACH;AAAA,MAEA,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wB,QAAQ;AACzC,cAAU,EAAE,GAAG,eAAe,GAAG,QAAQ;AAAA,EAC3C;AAEA,QAAM,eAAe,OAAO;AAAA,IAC1B,OAAO,QAAQ,WAAY,EAAgC,EACxD,OAAO,CAAC,CAAC,IAAI,MAAM,EAAE,QAAQ,MAAM,EACnC,IAAI,CAAC,CAAC,MAAM,MAAM,MAAM,CAAC,MAAO,OAAe,KAAK,KAAK,CAAC,CAAC;AAAA,EAAA;AAGzD,SAAA,OAAO,OAAO,OAAO,YAAY;AAC1C;AAEO,MAAM,cAAqC,uBAAA,OAAO,QAAQ,EAAE,eAAgB,CAAA;;;;;;;;;;;;;;;;;"}
1
+ {"version":3,"file":"store.cjs","sources":["../../src/lib/calcDuration.ts","../../src/lib/queue.ts","../../src/lib/equals.ts","../../src/lib/trackingProxy.ts","../../src/lib/calculationHelper.ts","../../src/lib/callable.ts","../../src/lib/debounce.ts","../../src/lib/forwardError.ts","../../src/lib/clone.ts","../../src/lib/propAccess.ts","../../src/lib/makeSelector.ts","../../src/lib/standardMethods.ts","../../src/lib/throttle.ts","../../src/core/store.ts"],"sourcesContent":["import type { Duration } from '../core/commonTypes';\n\nexport function calcDuration(t: Duration) {\n if (typeof t === 'number') return t;\n return (\n (t.milliseconds ?? 0) +\n (t.seconds ?? 0) * 1000 +\n (t.minutes ?? 0) * 60 * 1000 +\n (t.hours ?? 0) * 60 * 60 * 1000 +\n (t.days ?? 0) * 24 * 60 * 60 * 1000\n );\n}\n","import type { MaybePromise } from './maybePromise';\nimport type { Listener } from '@core';\n\ntype Action<T> = () => MaybePromise<T>;\n\nexport interface Queue {\n <T>(action: Action<T>, ref?: any): Promise<T>;\n clear: () => void;\n whenDone: () => Promise<void>;\n size: number;\n getRefs: () => any[];\n}\n\nexport function queue(): Queue {\n const q: {\n action: Action<any>;\n resolve: (value: any) => void;\n reject: (error: unknown) => void;\n ref?: any;\n }[] = [];\n const completionListeners = new Set<Listener<void>>();\n let active = false;\n\n const notify = () => {\n for (const listener of completionListeners) {\n listener();\n }\n\n completionListeners.clear();\n };\n\n const run = async () => {\n if (!active) {\n active = true;\n\n let next;\n while ((next = q.shift())) {\n try {\n let result = next.action();\n if (result instanceof Promise) {\n result = await result;\n }\n\n next.resolve(result);\n } catch (error) {\n next.reject(error);\n }\n }\n\n active = false;\n notify();\n }\n };\n\n return Object.assign(\n <T>(action: Action<T>, ref?: any) => {\n return new Promise<T>((resolve, reject) => {\n q.push({ action, resolve, reject, ref });\n run();\n });\n },\n {\n clear() {\n q.length = 0;\n },\n\n whenDone() {\n if (!active) {\n return Promise.resolve();\n }\n\n return new Promise<void>((resolve) => {\n completionListeners.add(resolve);\n });\n },\n\n get size() {\n return q.length;\n },\n\n getRefs() {\n return q.map((item) => item.ref).filter((x) => x !== undefined);\n },\n },\n );\n}\n","export function defaultEqual(a: any, b: any) {\n return a === b;\n}\n\nexport function shallowEqual(a: any, b: any): boolean {\n return internalEqual(defaultEqual)(a, b);\n}\n\nexport function deepEqual(a: any, b: any): boolean {\n return internalEqual(deepEqual)(a, b);\n}\n\nconst internalEqual = (comp: (a: any, b: any) => boolean) => (a: any, b: any) => {\n if (a === b) {\n return true;\n }\n\n if (a === null || b === null || typeof a !== 'object' || typeof b !== 'object') {\n // eslint-disable-next-line no-self-compare\n return a !== a && b !== b;\n }\n\n if (a.constructor !== b.constructor) {\n return false;\n }\n\n if (a.constructor === Object) {\n const entries1 = Object.entries(a);\n const entries2 = Object.entries(b);\n return (\n entries1.length === entries2.length && entries1.every(([key, value]) => comp(value, b[key]))\n );\n }\n\n if (Array.isArray(a)) {\n return a.length === b.length && a.every((value, i) => comp(value, b[i]));\n }\n\n if (a instanceof Date) {\n return a.getTime() === b.getTime();\n }\n\n if (a instanceof RegExp) {\n return a.source === b.source && a.flags === b.flags;\n }\n\n if (a instanceof Map) {\n return a.size === b.size && [...a.entries()].every(([key, value]) => comp(value, b.get(key)));\n }\n\n if (a instanceof Set) {\n return a.size === b.size && [...a.values()].every((value) => b.has(value));\n }\n\n if (typeof ArrayBuffer !== 'undefined' && ArrayBuffer.isView(a)) {\n if (a.byteLength !== b.byteLength) {\n return false;\n }\n\n const a_ = new Int8Array(a.buffer);\n const b_ = new Int8Array(b.buffer);\n return a_.every((value, i) => value === b_[i]);\n }\n\n return false;\n};\n","import { deepEqual } from './equals';\n\nconst unwrapProxySymbol = /* @__PURE__ */ Symbol('unwrapProxy');\n\nexport type TrackingProxy<T> = [value: T, equals: (newValue: T) => boolean, revoke?: () => void];\ntype Object_ = Record<string | symbol, unknown>;\n\nfunction isPlainObject(value: unknown) {\n return (\n typeof value === 'object' && value !== null && Object.getPrototypeOf(value) === Object.prototype\n );\n}\n\nexport function trackingProxy<T>(value: T, equals = deepEqual): TrackingProxy<T> {\n if (!isPlainObject(value) && !Array.isArray(value)) {\n return [value, (other) => equals(value, other)];\n }\n\n // Unpack proxies, we don't want to nest them\n value = (value as any)[unwrapProxySymbol] ?? value;\n\n const deps = new Array<TrackingProxy<any>[1]>();\n const revokations = new Array<() => void>();\n let revoked = false;\n\n function trackComplexProp(function_: any, ...args: any[]) {\n const [proxiedValue, equals, revoke] = trackingProxy(function_(value, ...args));\n\n deps.push((otherValue) => {\n if (!isPlainObject(otherValue) && !Array.isArray(otherValue)) {\n return false;\n }\n\n return equals(function_(otherValue, ...args));\n });\n\n if (revoke) {\n revokations.push(revoke);\n }\n\n return proxiedValue;\n }\n\n function trackSimpleProp(function_: any, ...args: any[]) {\n const calculatedValue = function_(value, ...args);\n\n deps.push((otherValue) => {\n return function_(otherValue, ...args) === calculatedValue;\n });\n\n return calculatedValue;\n }\n\n const proxy = new Proxy(value as T & Object_, {\n get(target, p, receiver) {\n if (p === unwrapProxySymbol) {\n return value;\n }\n\n if (revoked) {\n return target[p];\n }\n\n const { writable, configurable } = Object.getOwnPropertyDescriptor(target, p) ?? {};\n if (writable === false && configurable === false) {\n return target[p];\n }\n\n return trackComplexProp(Reflect.get, p, receiver);\n },\n\n getOwnPropertyDescriptor(target, p) {\n const { writable, configurable } = Object.getOwnPropertyDescriptor(target, p) ?? {};\n if (writable === false && configurable === false) {\n return Reflect.getOwnPropertyDescriptor(target, p);\n }\n\n return trackComplexProp(Reflect.getOwnPropertyDescriptor, p);\n },\n\n ownKeys() {\n return trackComplexProp(Reflect.ownKeys);\n },\n\n getPrototypeOf() {\n return trackSimpleProp(Reflect.getPrototypeOf);\n },\n\n has(_target, p) {\n return trackSimpleProp(Reflect.has, p);\n },\n\n isExtensible() {\n return trackSimpleProp(Reflect.isExtensible);\n },\n });\n\n return [\n proxy,\n (other) => !!other && deps.every((equals) => equals(other)),\n () => {\n revoked = true;\n revokations.forEach((revoke) => revoke());\n },\n ];\n}\n","import type { MaybePromise } from './maybePromise';\nimport { queue } from './queue';\nimport { trackingProxy } from './trackingProxy';\nimport { deepEqual } from './equals';\nimport type { Store } from '@core/store';\nimport type {\n CalculationHelpers,\n Cancel,\n ConnectionState,\n UpdateFrom,\n Use,\n} from '@core/commonTypes';\n\nexport class CalculationHelper<T> {\n private current?: {\n cancel: Cancel;\n check: () => void;\n invalidateDependencies: () => void;\n };\n\n constructor(\n public options: {\n calculate: (helpers: CalculationHelpers<T>) => Cancel | void;\n addEffect: (effect: () => Cancel | void) => Cancel;\n getValue?: () => T | undefined;\n onValue?: (value: T) => void;\n onError?: (error: unknown) => void;\n onConnectionState?: (state: ConnectionState) => void;\n onInvalidate?: () => void;\n },\n ) {\n options.addEffect(() => {\n if (this.current) {\n this.current.check();\n } else {\n this.execute();\n }\n });\n }\n\n execute() {\n this.stop();\n\n const { calculate, addEffect, getValue, onValue, onError, onConnectionState, onInvalidate } =\n this.options;\n const checks = new Array<() => boolean>();\n const deps = new Map<Store<any>, { on: () => void; off: () => void; invalidate: () => void }>();\n const q = queue();\n let isActive = false;\n let isCancled = false;\n\n const cancelEffect = addEffect(() => {\n isActive = true;\n\n for (const dep of deps.values()) {\n dep.on();\n }\n\n return () => {\n isActive = false;\n\n for (const dep of deps.values()) {\n dep.off();\n }\n\n if (cancelSubscription) {\n cancelSubscription();\n cancelSubscription = undefined;\n cancel();\n onInvalidate?.();\n }\n };\n });\n\n const cancel = () => {\n isCancled = true;\n cancelSubscription?.();\n cancelEffect();\n delete this.current;\n };\n\n const checkAll = () => {\n if (!checks.every((check) => check())) {\n cancel();\n onInvalidate?.();\n }\n };\n\n const invalidateDependencies = () => {\n for (const dep of deps.values()) {\n dep.invalidate();\n }\n };\n\n const use: Use = (store, { disableProxy } = {}) => {\n if (isCancled) {\n return store.get();\n }\n\n let value = store.get();\n let equals = (newValue: any) => {\n return deepEqual(newValue, value);\n };\n\n if (!disableProxy) {\n [value, equals] = trackingProxy(value);\n }\n\n const check = () => equals(store.get());\n let sub: Cancel | undefined;\n\n const dep = {\n on() {\n this.off();\n\n sub = store.subscribe(\n () => {\n if (sub && !check()) {\n cancel();\n onInvalidate?.();\n }\n },\n { runNow: false },\n );\n },\n off() {\n sub?.();\n sub = undefined;\n },\n invalidate() {\n if ('invalidate' in store && store.invalidate instanceof Function) {\n store.invalidate();\n }\n },\n };\n\n if (isActive) {\n dep.on();\n }\n\n checks.push(check);\n deps.set(store, dep);\n\n return value;\n };\n\n const updateValue = (update: UpdateFrom<MaybePromise<T>, [T | undefined]>) =>\n q(async () => {\n if (isCancled) {\n return;\n }\n\n if (update instanceof Function) {\n try {\n update = update(getValue?.());\n } catch (error) {\n onError?.(error);\n return;\n }\n }\n\n if (update instanceof Promise) {\n try {\n update = await update;\n } catch (error) {\n if (!isCancled) {\n onError?.(error);\n }\n return;\n }\n }\n\n if (!isCancled) {\n onValue?.(update);\n }\n });\n\n const updateError = (error: unknown) =>\n q(() => {\n if (!isCancled) {\n onError?.(error);\n }\n });\n\n const updateConnectionState = (state: ConnectionState) =>\n q(() => {\n if (!isCancled) {\n onConnectionState?.(state);\n }\n });\n\n let cancelSubscription: Cancel | void;\n try {\n cancelSubscription = calculate({ use, updateValue, updateError, updateConnectionState });\n } catch (error) {\n onError?.(error);\n }\n\n this.current = { cancel, check: checkAll, invalidateDependencies };\n }\n\n stop() {\n this.current?.cancel();\n }\n\n check() {\n this.current?.check();\n }\n\n checkOrExecute() {\n if (this.current) {\n this.check();\n } else {\n this.execute();\n }\n }\n\n invalidateDependencies() {\n this.current?.invalidateDependencies();\n }\n}\n","export class Callable<Args extends any[], T> extends Function {\n constructor(protected _call: (...args: Args) => T) {\n super('...args', 'return this._call(...args)');\n\n // eslint-disable-next-line no-constructor-return\n return this.bind(this);\n }\n}\n","import { calcDuration } from './calcDuration';\nimport type { Duration } from '@core';\n\nexport type DebounceOptions =\n | Duration\n | {\n wait: Duration;\n maxWait?: Duration;\n };\n\nexport function debounce<Args extends any[]>(\n action: (...args: Args) => void,\n options: Duration | DebounceOptions,\n): (...args: Args) => void {\n const wait =\n typeof options === 'object' && 'wait' in options\n ? calcDuration(options.wait)\n : calcDuration(options);\n\n const maxWait =\n typeof options === 'object' && 'maxWait' in options && options.maxWait !== undefined\n ? calcDuration(options.maxWait)\n : undefined;\n\n let timeout: ReturnType<typeof setTimeout> | undefined;\n let timeoutStarted: number | undefined;\n\n return (...args: Args) => {\n const now = Date.now();\n timeoutStarted ??= now;\n\n const deadline = Math.min(\n //\n now + wait,\n timeoutStarted + (maxWait ?? Number.POSITIVE_INFINITY),\n );\n\n if (timeout !== undefined) {\n clearTimeout(timeout);\n }\n\n timeout = setTimeout(() => {\n timeout = undefined;\n timeoutStarted = undefined;\n action(...args);\n }, deadline - now);\n };\n}\n","export function forwardError(error: unknown) {\n setTimeout(() => {\n throw error;\n });\n}\n","export function flatClone<T>(object: T): T {\n if (object instanceof Map) {\n return new Map(object) as any;\n }\n\n if (object instanceof Set) {\n return new Set(object) as any;\n }\n\n if (Array.isArray(object)) {\n return [...object] as any;\n }\n\n if (object instanceof Object) {\n return { ...object };\n }\n\n return object;\n}\n","import type { Update } from '../core/commonTypes';\nimport { flatClone } from './clone';\nimport type { Path, Value } from './path';\n\nexport function castArrayPath(path: string | KeyType[]): KeyType[] {\n if (Array.isArray(path)) {\n return path as any;\n }\n\n if (path === '') {\n return [] as any;\n }\n\n return (path as string).split('.') as any;\n}\n\nexport function get<T, P extends Path<T>>(object: T, path: P): Value<T, P> {\n const _path = castArrayPath(path as any);\n const [first, ...rest] = _path;\n\n if (first === undefined || !object) {\n return object as Value<T, P>;\n }\n\n if (object instanceof Map) {\n return get(object.get(first), rest as any);\n }\n\n if (object instanceof Set) {\n return get(Array.from(object)[Number(first)], rest as any);\n }\n\n if (object instanceof Object) {\n return get(object[first as keyof T], rest as any) as Value<T, P>;\n }\n\n throw new Error(`Could not get ${path} of ${object}`);\n}\n\nexport function set<T, P extends Path<T>>(\n object: T,\n path: P,\n value: Update<Value<T, P>>,\n rootPath = path,\n): T {\n const _path = castArrayPath(path as any);\n const [first, ...rest] = _path;\n\n if (first === undefined) {\n return value as any;\n }\n\n const updateChild = (child: any) => {\n if (!child && rest.length > 0) {\n const _rootPath = castArrayPath(rootPath as any);\n\n const prefix = _rootPath.slice(0, -rest.length) as KeyType[];\n throw new Error(`Cannot set ${rootPath} because ${prefix.join('.')} is ${child}`);\n }\n\n return set(child, rest as any, value, rootPath);\n };\n\n if (object instanceof Map) {\n const copy = flatClone(object);\n const child = copy.get(first);\n copy.set(first, updateChild(child));\n return copy;\n }\n\n if (object instanceof Set) {\n const copy = [...object];\n const child = copy[Number(first)];\n copy[Number(first)] = updateChild(child);\n return new Set(copy) as any;\n }\n\n if (object instanceof Object || object === undefined) {\n const copy = flatClone(object ?? ({} as T));\n copy[first as keyof T] = updateChild(copy[first as keyof T]);\n return copy;\n }\n\n throw new Error(`Could not set ${path} of ${object}`);\n}\n\nexport function remove<T, P extends Path<T, true>>(object: T, path: P): T {\n const _path = castArrayPath(path as any);\n\n if (_path.length === 0) {\n return undefined as any;\n }\n\n const parentPath = _path.slice(0, -1);\n const key = _path[_path.length - 1];\n\n const parent = flatClone(get(object, parentPath as any));\n\n if (parent instanceof Map) {\n parent.delete(key);\n } else if (parent instanceof Set) {\n const value = Array.from(parent)[Number(key)];\n parent.delete(value);\n } else {\n delete parent[key as keyof typeof parent];\n }\n\n return set(object, parentPath as any, parent);\n}\n","import type { Path } from './path';\nimport { get } from './propAccess';\n\nexport function makeSelector<T, S>(selector?: ((value: T) => S) | Path<any>): (value: T) => S {\n if (!selector) {\n return (x) => x as any;\n }\n\n if (selector instanceof Function) {\n return selector;\n }\n\n return (x) => get(x, selector as any) as any;\n}\n","import type { Store } from '../core/store';\nimport type { OptionalPropertyOf } from './typeHelpers';\n\ntype Function_ = (...args: any) => any;\n\nfunction createArrayAction<P extends keyof Array<any>>(prop: P) {\n return function arrayAction<T extends Array<any>>(\n this: Store<T>,\n ...args: T[P] extends Function_ ? Parameters<T[P]> : never\n ): T[P] extends Function_ ? ReturnType<T[P]> : never {\n const newArray = this.get().slice() as T;\n const result = (newArray[prop] as Function_)(...(args as any));\n this.set(newArray);\n return result;\n };\n}\nexport const arrayMethods = {\n splice: /* @__PURE__ */ createArrayAction('splice'),\n push: /* @__PURE__ */ createArrayAction('push'),\n pop: /* @__PURE__ */ createArrayAction('pop'),\n shift: /* @__PURE__ */ createArrayAction('shift'),\n unshift: /* @__PURE__ */ createArrayAction('unshift'),\n reverse: /* @__PURE__ */ createArrayAction('reverse'),\n sort: /* @__PURE__ */ createArrayAction('sort'),\n};\n\nexport const recordMethods = {\n delete<T extends Record<any, any>, K extends OptionalPropertyOf<T>>(this: Store<T>, key: K) {\n const copy = { ...this.get() };\n delete copy[key];\n this.set(copy);\n },\n\n clear<T extends Record<any, any>>(this: Store<Partial<T>>) {\n this.set({} as T);\n },\n};\n\nexport const mapMethods = {\n delete<K, V>(this: Store<Map<K, V>>, key: K) {\n const newMap = new Map(this.get());\n const result = newMap.delete(key);\n this.set(newMap);\n return result;\n },\n\n clear<K, V>(this: Store<Map<K, V>>) {\n this.set(new Map());\n },\n};\n\nexport const setMethods = {\n add<T>(this: Store<Set<T>>, value: T) {\n const newSet = new Set(this.get());\n newSet.add(value);\n this.set(newSet);\n },\n\n delete<T>(this: Store<Set<T>>, value: T) {\n const newSet = new Set(this.get());\n newSet.delete(value);\n this.set(newSet);\n },\n\n clear<T>(this: Store<Set<T>>) {\n this.set(new Set());\n },\n};\n","import { calcDuration } from './calcDuration';\nimport type { Duration } from '@core';\n\nexport function throttle<Args extends any[]>(\n action: (...args: Args) => void,\n duration: Duration,\n): (...args: Args) => void {\n const ms = calcDuration(duration);\n\n let t = 0;\n let timeout: ReturnType<typeof setTimeout> | undefined;\n\n return (...args: Args) => {\n if (timeout !== undefined) {\n clearTimeout(timeout);\n }\n\n const dt = t + ms - Date.now();\n if (dt <= 0) {\n action(...args);\n t = Date.now();\n return;\n }\n\n timeout = setTimeout(() => {\n action(...args);\n t = Date.now();\n }, dt);\n };\n}\n","import type {\n CalculationHelpers,\n Cancel,\n Duration,\n Effect,\n Listener,\n Selector,\n SubscribeOptions,\n Update,\n Use,\n UseOptions,\n} from './commonTypes';\nimport { calcDuration } from '@lib/calcDuration';\nimport { CalculationHelper } from '@lib/calculationHelper';\nimport { Callable } from '@lib/callable';\nimport { debounce } from '@lib/debounce';\nimport { deepEqual } from '@lib/equals';\nimport { forwardError } from '@lib/forwardError';\nimport { makeSelector } from '@lib/makeSelector';\nimport type { Path, Value } from '@lib/path';\nimport { get, set } from '@lib/propAccess';\nimport { arrayMethods, mapMethods, recordMethods, setMethods } from '@lib/standardMethods';\nimport { throttle } from '@lib/throttle';\n\nexport type StoreMethods = Record<string, (...args: any[]) => any>;\n\nexport type BoundStoreMethods<T, Methods extends StoreMethods> = Methods &\n ThisType<Store<T> & Methods>;\n\nexport interface StoreOptions {\n retain?: Duration;\n}\n\nexport interface StoreOptionsWithMethods<T, Methods extends StoreMethods> extends StoreOptions {\n methods?: Methods & ThisType<Store<T> & Methods & StandardMethods<T>>;\n}\n\nexport type Calculate<T> = (this: CalculationHelpers<T>, helpers: CalculationHelpers<T>) => T;\n\ntype StandardMethods<T> = T extends Map<any, any>\n ? typeof mapMethods\n : T extends Set<any>\n ? typeof setMethods\n : T extends Array<any>\n ? typeof arrayMethods\n : T extends Record<any, any>\n ? typeof recordMethods\n : Record<string, never>;\n\ntype StoreWithMethods<T, Methods extends StoreMethods> = Store<T> &\n Omit<BoundStoreMethods<T, Methods>, keyof Store<T>> &\n StandardMethods<T>;\n\nfunction noop() {\n return undefined;\n}\n\nexport class Store<T> extends Callable<any, any> {\n protected _value?: { v: T };\n\n protected listeners = new Map<Listener, boolean>();\n\n protected effects = new Map<\n Effect,\n { handle?: Cancel; retain?: number; timeout?: ReturnType<typeof setTimeout> }\n >();\n\n protected notifyId = {};\n\n protected calculationHelper = new CalculationHelper<T>({\n calculate: (helpers) => {\n if (this.getter instanceof Function) {\n const value = this.getter.apply(helpers, [helpers]);\n this._value = { v: value };\n this.notify();\n }\n },\n addEffect: (effect) => this.addEffect(effect, this.options.retain),\n getValue: () => this._value?.v,\n onInvalidate: () => this.reset(),\n });\n\n constructor(\n public readonly getter: T | Calculate<T>,\n public readonly options: StoreOptions = {},\n public readonly derivedFrom?: {\n store: Store<any>;\n selectors: (Selector<any, any> | Path<any>)[];\n updater: (state: any) => void;\n },\n protected readonly _call: (...args: any[]) => any = () => undefined,\n ) {\n super(_call);\n this.get = this.get.bind(this);\n this.set = this.set.bind(this);\n this.subscribe = this.subscribe.bind(this);\n this.once = this.once.bind(this);\n this.map = this.map.bind(this);\n this.addEffect = this.addEffect.bind(this);\n this.isActive = this.isActive.bind(this);\n\n if (!(getter instanceof Function)) {\n this._value = { v: getter };\n }\n }\n\n get(): T {\n this.calculationHelper.check();\n\n if (!this._value) {\n this.calculationHelper.execute();\n return this.get();\n }\n\n return this._value.v;\n }\n\n set(update: Update<T>): void;\n\n set<P extends Path<T>>(path: P, update: Update<Value<T, P>>): void;\n\n set(...args: any[]): void {\n const path: any = args.length > 1 ? args[0] : [];\n let update: Update<any> = args.length > 1 ? args[1] : args[0];\n\n if (update instanceof Function) {\n const before = this.get();\n const valueBefore = get(before, path);\n const valueAfter = update(valueBefore);\n update = set(before, path, valueAfter);\n } else if (path.length > 0) {\n update = set(this.get(), path, update);\n }\n\n if (this.derivedFrom) {\n this.derivedFrom.updater(update);\n return;\n }\n\n this._value = { v: update };\n this.notify();\n }\n\n protected reset() {\n this._value = undefined;\n\n if (this.isActive()) {\n this.calculationHelper.execute();\n }\n }\n\n subscribe(listener: Listener<T>, options?: SubscribeOptions): Cancel {\n const {\n passive,\n runNow = true,\n throttle: throttleOption,\n debounce: debounceOption,\n equals = deepEqual,\n } = options ?? {};\n\n let compareToValue = this._value?.v;\n let previousValue: T | undefined;\n let hasRun = false;\n\n let innerListener = (force?: boolean | void) => {\n if (!this._value) {\n return;\n }\n\n const value = this._value.v;\n\n if (!force && equals(value, compareToValue)) {\n return;\n }\n\n compareToValue = value;\n const _previousValue = previousValue;\n previousValue = value;\n hasRun = true;\n\n try {\n listener(value, _previousValue);\n } catch (error) {\n forwardError(error);\n }\n };\n\n if (throttleOption) {\n innerListener = throttle(innerListener, throttleOption);\n } else if (debounceOption) {\n innerListener = debounce(innerListener, debounceOption);\n }\n\n this.listeners.set(innerListener, !passive);\n if (!passive) {\n this.onSubscribe();\n }\n\n if (runNow && !hasRun) {\n innerListener(true);\n }\n\n return () => {\n this.listeners.delete(innerListener);\n if (!passive) {\n this.onUnsubscribe();\n }\n };\n }\n\n once<S extends T>(condition: (value: T) => value is S): Promise<S>;\n\n once(condition?: (value: T) => boolean): Promise<T>;\n\n once(condition: (value: T) => boolean = (value) => !!value): Promise<any> {\n return new Promise<T>((resolve) => {\n let stopped = false;\n const cancel = this.subscribe(\n (value) => {\n if (stopped || (condition && !condition(value))) {\n return;\n }\n\n resolve(value);\n stopped = true;\n setTimeout(() => cancel());\n },\n {\n runNow: !!condition,\n },\n );\n });\n }\n\n map<S>(\n selector: Selector<T, S>,\n updater?: (value: S) => Update<T>,\n options?: UseOptions,\n ): Store<S>;\n\n map<P extends Path<T>>(selector: P, options?: UseOptions): Store<Value<T, P>>;\n\n map(_selector: Selector<T, any> | Path<any>, ...args: any[]): Store<any> {\n const updater: ((value: any) => Update<T>) | undefined =\n _selector instanceof Function\n ? args[0]\n : (value) => (state) => set(state, _selector as Path<T>, value);\n\n const options = _selector instanceof Function ? args[1] : args[0];\n\n const selector = makeSelector(_selector);\n\n const derivedFrom = {\n store: this.derivedFrom ? this.derivedFrom.store : this,\n selectors: this.derivedFrom ? [...this.derivedFrom.selectors, _selector] : [_selector],\n\n updater: (value: any) => {\n if (!updater) {\n throw new TypeError(\n 'Can only updated computed stores that either are derived from other stores using string selectors or have an updater function.',\n );\n }\n\n let update = updater(value);\n\n if (update instanceof Function) {\n update = update(this.get());\n }\n\n if (this.derivedFrom) {\n this.derivedFrom.updater(update);\n } else {\n this.set(update);\n }\n },\n };\n\n return new Store(\n ({ use }) => {\n return selector(use(this, options));\n },\n this.options,\n derivedFrom,\n );\n }\n\n /** Add an effect that will be executed when the store becomes active, which means when it has at least one subscriber.\n * @param effect\n * If there is already a subscriber, the effect will be executed immediately.\n * Otherweise it will be executed as soon as the first subscription is created.\n * Every time all subscriptions are removed and the first is created again, the effect will be executed again.\n * @param retain\n * If provided, delay tearing down effects when the last subscriber is removed. This is useful if a short gap in subscriber coverage is supposed to be ignored. E.g. when switching pages, the old page might unsubscribe, while the new page subscribes immediately after.\n * @returns\n * The effect can return a teardown callback, which will be executed when the last subscription is removed and potentially the ratain time has passed.\n */\n addEffect(effect: Effect, retain?: Duration) {\n this.effects.set(effect, {\n handle: this.isActive() ? effect() ?? noop : undefined,\n retain: retain !== undefined ? calcDuration(retain) : undefined,\n });\n\n return () => {\n const { handle, timeout } = this.effects.get(effect) ?? {};\n handle?.();\n\n if (timeout !== undefined) {\n clearTimeout(timeout);\n }\n\n this.effects.delete(effect);\n };\n }\n\n /** Return whether the store is currently active, which means whether it has at least one subscriber. */\n isActive() {\n return [...this.listeners.values()].some(Boolean);\n }\n\n protected onSubscribe() {\n if ([...this.listeners.values()].filter(Boolean).length > 1) return;\n\n for (const [effect, { handle, retain, timeout }] of this.effects.entries()) {\n if (timeout !== undefined) {\n clearTimeout(timeout);\n }\n\n this.effects.set(effect, {\n handle: handle ?? effect() ?? noop,\n retain,\n timeout: undefined,\n });\n }\n }\n\n protected onUnsubscribe() {\n if ([...this.listeners.values()].some(Boolean)) return;\n\n for (const [effect, { handle, retain, timeout }] of this.effects.entries()) {\n if (!retain) {\n handle?.();\n }\n\n if (timeout !== undefined) {\n clearTimeout(timeout);\n }\n\n this.effects.set(effect, {\n handle: retain ? handle : undefined,\n retain,\n timeout: retain && handle ? setTimeout(handle, retain) : undefined,\n });\n }\n }\n\n protected notify() {\n const n = {};\n this.notifyId = n;\n\n const snapshot = [...this.listeners.keys()];\n for (const listener of snapshot) {\n listener();\n if (n !== this.notifyId) break;\n }\n }\n}\n\nconst defaultOptions: StoreOptions = {};\n\nfunction create<T>(\n calculate: (this: { use: Use }, fns: { use: Use }) => T,\n options?: StoreOptions,\n): Store<T>;\nfunction create<T, Methods extends StoreMethods = {}>(\n initialState: T,\n options?: StoreOptionsWithMethods<T, Methods>,\n): StoreWithMethods<T, Methods>;\nfunction create<T, Methods extends StoreMethods>(\n initialState: T | ((this: { use: Use }, fns: { use: Use }) => T),\n options?: StoreOptionsWithMethods<T, Methods>,\n): StoreWithMethods<T, Methods> | Store<T> {\n const store = new Store(initialState, options);\n\n if (initialState instanceof Function) {\n return store;\n }\n\n let methods: StoreMethods | undefined = options?.methods;\n\n if (initialState instanceof Map) {\n methods = { ...mapMethods, ...methods };\n } else if (initialState instanceof Set) {\n methods = { ...setMethods, ...methods };\n } else if (Array.isArray(initialState)) {\n methods = { ...arrayMethods, ...methods };\n } else if (initialState instanceof Object) {\n methods = { ...recordMethods, ...methods };\n }\n\n const boundMethods = Object.fromEntries(\n Object.entries(methods ?? ({} as BoundStoreMethods<T, any>))\n .filter(([name]) => !(name in store))\n .map(([name, action]) => [name, (action as any).bind(store)]),\n ) as BoundStoreMethods<T, any>;\n\n return Object.assign(store, boundMethods);\n}\n\nexport const createStore = /* @__PURE__ */ Object.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A,EACT;AAEA,MAAI,UAAoC,mCAAS;AAEjD,MAAI,wBAAwB,KAAK;AAC/B,cAAU,EAAE,GAAG,YAAY,GAAG,QAAQ;AAAA,EAAA,WAC7B,wBAAwB,KAAK;AACtC,cAAU,EAAE,GAAG,YAAY,GAAG,QAAQ;AAAA,EAC7B,WAAA,MAAM,QAAQ,YAAY,GAAG;AACtC,cAAU,EAAE,GAAG,cAAc,GAAG,QAAQ;AAAA,EAAA,WAC/B,wBAAwB,QAAQ;AACzC,cAAU,EAAE,GAAG,eAAe,GAAG,QAAQ;AAAA,EAC3C;AAEA,QAAM,eAAe,OAAO;AAAA,IAC1B,OAAO,QAAQ,WAAY,EAAgC,EACxD,OAAO,CAAC,CAAC,IAAI,MAAM,EAAE,QAAQ,MAAM,EACnC,IAAI,CAAC,CAAC,MAAM,MAAM,MAAM,CAAC,MAAO,OAAe,KAAK,KAAK,CAAC,CAAC;AAAA,EAAA;AAGzD,SAAA,OAAO,OAAO,OAAO,YAAY;AAC1C;AAEO,MAAM,cAAqC,uBAAA,OAAO,QAAQ,EAAE,eAAgB,CAAA;;;;;;;;;;;;;;;;;"}
@@ -424,9 +424,10 @@ function useStore(store, options) {
424
424
  return ((_a = lastEqualsRef.current) == null ? void 0 : _a.call(lastEqualsRef, newValue)) ?? false;
425
425
  })
426
426
  );
427
- const [proxiedValue, equals] = trackingProxy(value);
427
+ const [proxiedValue, equals, revoke] = trackingProxy(value);
428
428
  useLayoutEffect(() => {
429
429
  lastEqualsRef.current = equals;
430
+ revoke == null ? void 0 : revoke();
430
431
  });
431
432
  useDebugValue(value);
432
433
  return proxiedValue;
@@ -1 +1 @@
1
- {"version":3,"file":"scope2.mjs","sources":["../../node_modules/.pnpm/use-sync-external-store@1.2.0_react@18.2.0/node_modules/use-sync-external-store/cjs/use-sync-external-store-shim.production.min.js","../../node_modules/.pnpm/use-sync-external-store@1.2.0_react@18.2.0/node_modules/use-sync-external-store/cjs/use-sync-external-store-shim.development.js","../../node_modules/.pnpm/use-sync-external-store@1.2.0_react@18.2.0/node_modules/use-sync-external-store/shim/index.js","../../node_modules/.pnpm/use-sync-external-store@1.2.0_react@18.2.0/node_modules/use-sync-external-store/cjs/use-sync-external-store-shim/with-selector.production.min.js","../../node_modules/.pnpm/use-sync-external-store@1.2.0_react@18.2.0/node_modules/use-sync-external-store/cjs/use-sync-external-store-shim/with-selector.development.js","../../node_modules/.pnpm/use-sync-external-store@1.2.0_react@18.2.0/node_modules/use-sync-external-store/shim/with-selector.js","../../src/react/useStore.ts","../../src/react/useProp.ts","../../src/react/reactMethods.ts","../../src/react/useCache.ts","../../src/react/scope.tsx"],"sourcesContent":["/**\n * @license React\n * use-sync-external-store-shim.production.min.js\n *\n * Copyright (c) Facebook, Inc. and its affiliates.\n *\n * This source code is licensed under the MIT license found in the\n * LICENSE file in the root directory of this source tree.\n */\n'use strict';var e=require(\"react\");function h(a,b){return a===b&&(0!==a||1/a===1/b)||a!==a&&b!==b}var k=\"function\"===typeof Object.is?Object.is:h,l=e.useState,m=e.useEffect,n=e.useLayoutEffect,p=e.useDebugValue;function q(a,b){var d=b(),f=l({inst:{value:d,getSnapshot:b}}),c=f[0].inst,g=f[1];n(function(){c.value=d;c.getSnapshot=b;r(c)&&g({inst:c})},[a,d,b]);m(function(){r(c)&&g({inst:c});return a(function(){r(c)&&g({inst:c})})},[a]);p(d);return d}\nfunction r(a){var b=a.getSnapshot;a=a.value;try{var d=b();return!k(a,d)}catch(f){return!0}}function t(a,b){return b()}var u=\"undefined\"===typeof window||\"undefined\"===typeof window.document||\"undefined\"===typeof window.document.createElement?t:q;exports.useSyncExternalStore=void 0!==e.useSyncExternalStore?e.useSyncExternalStore:u;\n","/**\n * @license React\n * use-sync-external-store-shim.development.js\n *\n * Copyright (c) Facebook, Inc. and its affiliates.\n *\n * This source code is licensed under the MIT license found in the\n * LICENSE file in the root directory of this source tree.\n */\n\n'use strict';\n\nif (process.env.NODE_ENV !== \"production\") {\n (function() {\n\n 'use strict';\n\n/* global __REACT_DEVTOOLS_GLOBAL_HOOK__ */\nif (\n typeof __REACT_DEVTOOLS_GLOBAL_HOOK__ !== 'undefined' &&\n typeof __REACT_DEVTOOLS_GLOBAL_HOOK__.registerInternalModuleStart ===\n 'function'\n) {\n __REACT_DEVTOOLS_GLOBAL_HOOK__.registerInternalModuleStart(new Error());\n}\n var React = require('react');\n\nvar ReactSharedInternals = React.__SECRET_INTERNALS_DO_NOT_USE_OR_YOU_WILL_BE_FIRED;\n\nfunction error(format) {\n {\n {\n for (var _len2 = arguments.length, args = new Array(_len2 > 1 ? _len2 - 1 : 0), _key2 = 1; _key2 < _len2; _key2++) {\n args[_key2 - 1] = arguments[_key2];\n }\n\n printWarning('error', format, args);\n }\n }\n}\n\nfunction printWarning(level, format, args) {\n // When changing this logic, you might want to also\n // update consoleWithStackDev.www.js as well.\n {\n var ReactDebugCurrentFrame = ReactSharedInternals.ReactDebugCurrentFrame;\n var stack = ReactDebugCurrentFrame.getStackAddendum();\n\n if (stack !== '') {\n format += '%s';\n args = args.concat([stack]);\n } // eslint-disable-next-line react-internal/safe-string-coercion\n\n\n var argsWithFormat = args.map(function (item) {\n return String(item);\n }); // Careful: RN currently depends on this prefix\n\n argsWithFormat.unshift('Warning: ' + format); // We intentionally don't use spread (or .apply) directly because it\n // breaks IE9: https://github.com/facebook/react/issues/13610\n // eslint-disable-next-line react-internal/no-production-logging\n\n Function.prototype.apply.call(console[level], console, argsWithFormat);\n }\n}\n\n/**\n * inlined Object.is polyfill to avoid requiring consumers ship their own\n * https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/Object/is\n */\nfunction is(x, y) {\n return x === y && (x !== 0 || 1 / x === 1 / y) || x !== x && y !== y // eslint-disable-line no-self-compare\n ;\n}\n\nvar objectIs = typeof Object.is === 'function' ? Object.is : is;\n\n// dispatch for CommonJS interop named imports.\n\nvar useState = React.useState,\n useEffect = React.useEffect,\n useLayoutEffect = React.useLayoutEffect,\n useDebugValue = React.useDebugValue;\nvar didWarnOld18Alpha = false;\nvar didWarnUncachedGetSnapshot = false; // Disclaimer: This shim breaks many of the rules of React, and only works\n// because of a very particular set of implementation details and assumptions\n// -- change any one of them and it will break. The most important assumption\n// is that updates are always synchronous, because concurrent rendering is\n// only available in versions of React that also have a built-in\n// useSyncExternalStore API. And we only use this shim when the built-in API\n// does not exist.\n//\n// Do not assume that the clever hacks used by this hook also work in general.\n// The point of this shim is to replace the need for hacks by other libraries.\n\nfunction useSyncExternalStore(subscribe, getSnapshot, // Note: The shim does not use getServerSnapshot, because pre-18 versions of\n// React do not expose a way to check if we're hydrating. So users of the shim\n// will need to track that themselves and return the correct value\n// from `getSnapshot`.\ngetServerSnapshot) {\n {\n if (!didWarnOld18Alpha) {\n if (React.startTransition !== undefined) {\n didWarnOld18Alpha = true;\n\n error('You are using an outdated, pre-release alpha of React 18 that ' + 'does not support useSyncExternalStore. The ' + 'use-sync-external-store shim will not work correctly. Upgrade ' + 'to a newer pre-release.');\n }\n }\n } // Read the current snapshot from the store on every render. Again, this\n // breaks the rules of React, and only works here because of specific\n // implementation details, most importantly that updates are\n // always synchronous.\n\n\n var value = getSnapshot();\n\n {\n if (!didWarnUncachedGetSnapshot) {\n var cachedValue = getSnapshot();\n\n if (!objectIs(value, cachedValue)) {\n error('The result of getSnapshot should be cached to avoid an infinite loop');\n\n didWarnUncachedGetSnapshot = true;\n }\n }\n } // Because updates are synchronous, we don't queue them. Instead we force a\n // re-render whenever the subscribed state changes by updating an some\n // arbitrary useState hook. Then, during render, we call getSnapshot to read\n // the current value.\n //\n // Because we don't actually use the state returned by the useState hook, we\n // can save a bit of memory by storing other stuff in that slot.\n //\n // To implement the early bailout, we need to track some things on a mutable\n // object. Usually, we would put that in a useRef hook, but we can stash it in\n // our useState hook instead.\n //\n // To force a re-render, we call forceUpdate({inst}). That works because the\n // new object always fails an equality check.\n\n\n var _useState = useState({\n inst: {\n value: value,\n getSnapshot: getSnapshot\n }\n }),\n inst = _useState[0].inst,\n forceUpdate = _useState[1]; // Track the latest getSnapshot function with a ref. This needs to be updated\n // in the layout phase so we can access it during the tearing check that\n // happens on subscribe.\n\n\n useLayoutEffect(function () {\n inst.value = value;\n inst.getSnapshot = getSnapshot; // Whenever getSnapshot or subscribe changes, we need to check in the\n // commit phase if there was an interleaved mutation. In concurrent mode\n // this can happen all the time, but even in synchronous mode, an earlier\n // effect may have mutated the store.\n\n if (checkIfSnapshotChanged(inst)) {\n // Force a re-render.\n forceUpdate({\n inst: inst\n });\n }\n }, [subscribe, value, getSnapshot]);\n useEffect(function () {\n // Check for changes right before subscribing. Subsequent changes will be\n // detected in the subscription handler.\n if (checkIfSnapshotChanged(inst)) {\n // Force a re-render.\n forceUpdate({\n inst: inst\n });\n }\n\n var handleStoreChange = function () {\n // TODO: Because there is no cross-renderer API for batching updates, it's\n // up to the consumer of this library to wrap their subscription event\n // with unstable_batchedUpdates. Should we try to detect when this isn't\n // the case and print a warning in development?\n // The store changed. Check if the snapshot changed since the last time we\n // read from the store.\n if (checkIfSnapshotChanged(inst)) {\n // Force a re-render.\n forceUpdate({\n inst: inst\n });\n }\n }; // Subscribe to the store and return a clean-up function.\n\n\n return subscribe(handleStoreChange);\n }, [subscribe]);\n useDebugValue(value);\n return value;\n}\n\nfunction checkIfSnapshotChanged(inst) {\n var latestGetSnapshot = inst.getSnapshot;\n var prevValue = inst.value;\n\n try {\n var nextValue = latestGetSnapshot();\n return !objectIs(prevValue, nextValue);\n } catch (error) {\n return true;\n }\n}\n\nfunction useSyncExternalStore$1(subscribe, getSnapshot, getServerSnapshot) {\n // Note: The shim does not use getServerSnapshot, because pre-18 versions of\n // React do not expose a way to check if we're hydrating. So users of the shim\n // will need to track that themselves and return the correct value\n // from `getSnapshot`.\n return getSnapshot();\n}\n\nvar canUseDOM = !!(typeof window !== 'undefined' && typeof window.document !== 'undefined' && typeof window.document.createElement !== 'undefined');\n\nvar isServerEnvironment = !canUseDOM;\n\nvar shim = isServerEnvironment ? useSyncExternalStore$1 : useSyncExternalStore;\nvar useSyncExternalStore$2 = React.useSyncExternalStore !== undefined ? React.useSyncExternalStore : shim;\n\nexports.useSyncExternalStore = useSyncExternalStore$2;\n /* global __REACT_DEVTOOLS_GLOBAL_HOOK__ */\nif (\n typeof __REACT_DEVTOOLS_GLOBAL_HOOK__ !== 'undefined' &&\n typeof __REACT_DEVTOOLS_GLOBAL_HOOK__.registerInternalModuleStop ===\n 'function'\n) {\n __REACT_DEVTOOLS_GLOBAL_HOOK__.registerInternalModuleStop(new Error());\n}\n \n })();\n}\n","'use strict';\n\nif (process.env.NODE_ENV === 'production') {\n module.exports = require('../cjs/use-sync-external-store-shim.production.min.js');\n} else {\n module.exports = require('../cjs/use-sync-external-store-shim.development.js');\n}\n","/**\n * @license React\n * use-sync-external-store-shim/with-selector.production.min.js\n *\n * Copyright (c) Facebook, Inc. and its affiliates.\n *\n * This source code is licensed under the MIT license found in the\n * LICENSE file in the root directory of this source tree.\n */\n'use strict';var h=require(\"react\"),n=require(\"use-sync-external-store/shim\");function p(a,b){return a===b&&(0!==a||1/a===1/b)||a!==a&&b!==b}var q=\"function\"===typeof Object.is?Object.is:p,r=n.useSyncExternalStore,t=h.useRef,u=h.useEffect,v=h.useMemo,w=h.useDebugValue;\nexports.useSyncExternalStoreWithSelector=function(a,b,e,l,g){var c=t(null);if(null===c.current){var f={hasValue:!1,value:null};c.current=f}else f=c.current;c=v(function(){function a(a){if(!c){c=!0;d=a;a=l(a);if(void 0!==g&&f.hasValue){var b=f.value;if(g(b,a))return k=b}return k=a}b=k;if(q(d,a))return b;var e=l(a);if(void 0!==g&&g(b,e))return b;d=a;return k=e}var c=!1,d,k,m=void 0===e?null:e;return[function(){return a(b())},null===m?void 0:function(){return a(m())}]},[b,e,l,g]);var d=r(a,c[0],c[1]);\nu(function(){f.hasValue=!0;f.value=d},[d]);w(d);return d};\n","/**\n * @license React\n * use-sync-external-store-shim/with-selector.development.js\n *\n * Copyright (c) Facebook, Inc. and its affiliates.\n *\n * This source code is licensed under the MIT license found in the\n * LICENSE file in the root directory of this source tree.\n */\n\n'use strict';\n\nif (process.env.NODE_ENV !== \"production\") {\n (function() {\n\n 'use strict';\n\n/* global __REACT_DEVTOOLS_GLOBAL_HOOK__ */\nif (\n typeof __REACT_DEVTOOLS_GLOBAL_HOOK__ !== 'undefined' &&\n typeof __REACT_DEVTOOLS_GLOBAL_HOOK__.registerInternalModuleStart ===\n 'function'\n) {\n __REACT_DEVTOOLS_GLOBAL_HOOK__.registerInternalModuleStart(new Error());\n}\n var React = require('react');\nvar shim = require('use-sync-external-store/shim');\n\n/**\n * inlined Object.is polyfill to avoid requiring consumers ship their own\n * https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/Object/is\n */\nfunction is(x, y) {\n return x === y && (x !== 0 || 1 / x === 1 / y) || x !== x && y !== y // eslint-disable-line no-self-compare\n ;\n}\n\nvar objectIs = typeof Object.is === 'function' ? Object.is : is;\n\nvar useSyncExternalStore = shim.useSyncExternalStore;\n\n// for CommonJS interop.\n\nvar useRef = React.useRef,\n useEffect = React.useEffect,\n useMemo = React.useMemo,\n useDebugValue = React.useDebugValue; // Same as useSyncExternalStore, but supports selector and isEqual arguments.\n\nfunction useSyncExternalStoreWithSelector(subscribe, getSnapshot, getServerSnapshot, selector, isEqual) {\n // Use this to track the rendered snapshot.\n var instRef = useRef(null);\n var inst;\n\n if (instRef.current === null) {\n inst = {\n hasValue: false,\n value: null\n };\n instRef.current = inst;\n } else {\n inst = instRef.current;\n }\n\n var _useMemo = useMemo(function () {\n // Track the memoized state using closure variables that are local to this\n // memoized instance of a getSnapshot function. Intentionally not using a\n // useRef hook, because that state would be shared across all concurrent\n // copies of the hook/component.\n var hasMemo = false;\n var memoizedSnapshot;\n var memoizedSelection;\n\n var memoizedSelector = function (nextSnapshot) {\n if (!hasMemo) {\n // The first time the hook is called, there is no memoized result.\n hasMemo = true;\n memoizedSnapshot = nextSnapshot;\n\n var _nextSelection = selector(nextSnapshot);\n\n if (isEqual !== undefined) {\n // Even if the selector has changed, the currently rendered selection\n // may be equal to the new selection. We should attempt to reuse the\n // current value if possible, to preserve downstream memoizations.\n if (inst.hasValue) {\n var currentSelection = inst.value;\n\n if (isEqual(currentSelection, _nextSelection)) {\n memoizedSelection = currentSelection;\n return currentSelection;\n }\n }\n }\n\n memoizedSelection = _nextSelection;\n return _nextSelection;\n } // We may be able to reuse the previous invocation's result.\n\n\n // We may be able to reuse the previous invocation's result.\n var prevSnapshot = memoizedSnapshot;\n var prevSelection = memoizedSelection;\n\n if (objectIs(prevSnapshot, nextSnapshot)) {\n // The snapshot is the same as last time. Reuse the previous selection.\n return prevSelection;\n } // The snapshot has changed, so we need to compute a new selection.\n\n\n // The snapshot has changed, so we need to compute a new selection.\n var nextSelection = selector(nextSnapshot); // If a custom isEqual function is provided, use that to check if the data\n // has changed. If it hasn't, return the previous selection. That signals\n // to React that the selections are conceptually equal, and we can bail\n // out of rendering.\n\n // If a custom isEqual function is provided, use that to check if the data\n // has changed. If it hasn't, return the previous selection. That signals\n // to React that the selections are conceptually equal, and we can bail\n // out of rendering.\n if (isEqual !== undefined && isEqual(prevSelection, nextSelection)) {\n return prevSelection;\n }\n\n memoizedSnapshot = nextSnapshot;\n memoizedSelection = nextSelection;\n return nextSelection;\n }; // Assigning this to a constant so that Flow knows it can't change.\n\n\n // Assigning this to a constant so that Flow knows it can't change.\n var maybeGetServerSnapshot = getServerSnapshot === undefined ? null : getServerSnapshot;\n\n var getSnapshotWithSelector = function () {\n return memoizedSelector(getSnapshot());\n };\n\n var getServerSnapshotWithSelector = maybeGetServerSnapshot === null ? undefined : function () {\n return memoizedSelector(maybeGetServerSnapshot());\n };\n return [getSnapshotWithSelector, getServerSnapshotWithSelector];\n }, [getSnapshot, getServerSnapshot, selector, isEqual]),\n getSelection = _useMemo[0],\n getServerSelection = _useMemo[1];\n\n var value = useSyncExternalStore(subscribe, getSelection, getServerSelection);\n useEffect(function () {\n inst.hasValue = true;\n inst.value = value;\n }, [value]);\n useDebugValue(value);\n return value;\n}\n\nexports.useSyncExternalStoreWithSelector = useSyncExternalStoreWithSelector;\n /* global __REACT_DEVTOOLS_GLOBAL_HOOK__ */\nif (\n typeof __REACT_DEVTOOLS_GLOBAL_HOOK__ !== 'undefined' &&\n typeof __REACT_DEVTOOLS_GLOBAL_HOOK__.registerInternalModuleStop ===\n 'function'\n) {\n __REACT_DEVTOOLS_GLOBAL_HOOK__.registerInternalModuleStop(new Error());\n}\n \n })();\n}\n","'use strict';\n\nif (process.env.NODE_ENV === 'production') {\n module.exports = require('../cjs/use-sync-external-store-shim/with-selector.production.min.js');\n} else {\n module.exports = require('../cjs/use-sync-external-store-shim/with-selector.development.js');\n}\n","import { useCallback, useDebugValue, useLayoutEffect, useMemo, useRef } from 'react';\nimport { useSyncExternalStoreWithSelector } from 'use-sync-external-store/shim/with-selector.js';\nimport type { SubscribeOptions } from '@core/commonTypes';\nimport type { Store } from '@core/store';\nimport { hash } from '@lib/hash';\nimport { makeSelector } from '@lib/makeSelector';\nimport { trackingProxy } from '@lib/trackingProxy';\n\nexport type UseStoreOptions = Omit<SubscribeOptions, 'runNow' | 'passive'>;\n\nexport function useStore<T>(store: Store<T>, options?: UseStoreOptions): T {\n const lastEqualsRef = useRef<(newValue: T) => boolean>();\n\n const { rootStore, selector } = useMemo(() => {\n const rootStore = store.derivedFrom?.store ?? store;\n let selector = (x: any) => x;\n\n if (store.derivedFrom) {\n selector = (value: any) => {\n for (const s of store.derivedFrom!.selectors) {\n value = makeSelector(s)(value);\n }\n return value;\n };\n }\n\n return { rootStore, selector };\n }, [store]);\n\n const subOptions = { ...options, runNow: false, equals: undefined, passive: false };\n const subscribe = useCallback(\n (listener: () => void) => {\n return rootStore.subscribe(listener, subOptions);\n },\n [rootStore, hash(subOptions)],\n );\n\n const value = useSyncExternalStoreWithSelector<unknown, T>(\n //\n subscribe,\n rootStore.get,\n undefined,\n selector,\n options?.equals ?? ((_v, newValue) => lastEqualsRef.current?.(newValue) ?? false),\n );\n const [proxiedValue, equals] = trackingProxy(value);\n\n useLayoutEffect(() => {\n lastEqualsRef.current = equals;\n });\n\n useDebugValue(value);\n return proxiedValue;\n}\n","import type { UseStoreOptions } from './useStore';\nimport { useStore } from './useStore';\nimport type { Store } from '@core/store';\n\nexport function useProp<T>(\n store: Store<T>,\n options?: UseStoreOptions,\n): [value: T, setValue: typeof store.set] {\n const value = useStore(store, options);\n\n return [value, store.set];\n}\n","import { useProp } from './useProp';\nimport { type UseStoreOptions, useStore } from './useStore';\nimport type { Store } from '@core/store';\n\nexport const reactMethods = {\n useStore<T>(this: Store<T>, options?: UseStoreOptions) {\n return useStore(this, options);\n },\n\n useProp<T>(this: Store<T>, options?: UseStoreOptions) {\n return useProp(this, options);\n },\n};\n","import { useEffect, useMemo } from 'react';\nimport type { UseStoreOptions } from './useStore';\nimport { useStore } from './useStore';\nimport type { Cache } from '@core';\nimport type { CacheState } from '@lib/cacheState';\nimport { makeSelector } from '@lib/makeSelector';\n\nexport type UseCacheArray<T> = [\n value: T | undefined,\n error: unknown | undefined,\n isUpdating: boolean,\n isStale: boolean,\n];\n\nexport type UseCacheValue<T> = UseCacheArray<T> & CacheState<T>;\n\nexport interface UseCacheOptions extends UseStoreOptions {\n passive?: boolean;\n updateOnMount?: boolean;\n}\n\nexport function useCache<T>(\n cache: Cache<T>,\n { passive, updateOnMount, ...options }: UseCacheOptions = {},\n): UseCacheValue<T> {\n const mappedState = useMemo(() => {\n const rootCache: Cache<any> = cache.derivedFromCache?.cache ?? cache;\n let selector = (x: any) => x;\n\n if (cache.derivedFromCache) {\n selector = (value: any) => {\n for (const s of cache.derivedFromCache!.selectors) {\n value = makeSelector(s)(value);\n }\n return value;\n };\n }\n\n return rootCache.state.map((state) => {\n const value = state.status === 'value' ? selector(state.value) : undefined;\n\n return Object.assign<UseCacheArray<T>, CacheState<T>>(\n [value, state.error, state.isUpdating, state.isStale],\n { ...state, value },\n );\n });\n }, [cache]);\n\n useEffect(() => (!passive ? cache.subscribe(() => undefined) : undefined), [cache, passive]);\n\n useEffect(() => {\n if (updateOnMount) {\n cache.invalidate();\n }\n }, []);\n\n return useStore(mappedState, options);\n}\n","import type { Context, ReactNode } from 'react';\nimport { createContext, useContext, useMemo } from 'react';\nimport { useProp } from './useProp';\nimport { useStore, type UseStoreOptions } from './useStore';\nimport { createStore } from '@core/store';\nimport type { Store } from '@core/store';\nimport type { Scope } from '@core';\n\nexport type ScopeProps<T> = { scope: Scope<T>; store?: Store<T>; children?: ReactNode };\n\nconst contextMap = new WeakMap<Scope<any>, Context<Store<any>>>();\n\nfunction getScopeContext<T>(scope: Scope<T>): Context<Store<T>> {\n let context = contextMap.get(scope);\n\n if (!context) {\n context = createContext<Store<T>>(createStore(scope.defaultValue));\n contextMap.set(scope, context);\n }\n\n return context;\n}\n\nexport function ScopeProvider<T>({ scope, store: inputStore, children }: ScopeProps<T>) {\n const context = getScopeContext(scope);\n const currentStore = useMemo(\n () => inputStore ?? createStore(scope.defaultValue),\n [scope, inputStore],\n );\n\n return <context.Provider value={currentStore}>{children}</context.Provider>;\n}\n\nexport function useScope<T>(scope: Scope<T>): Store<T> {\n const context = getScopeContext(scope);\n return useContext(context);\n}\n\nexport function useScopeStore<T>(scope: Scope<T>, options?: UseStoreOptions): T {\n const store = useScope(scope);\n return useStore(store, options);\n}\n\nexport function useScopeProp<T>(scope: Scope<T>, options?: UseStoreOptions) {\n const store = useScope(scope);\n return useProp(store, options);\n}\n"],"names":["useEffect","useLayoutEffect","useDebugValue","error","shim","require$$0","require$$1","a","c","d","b","e","useRef","useMemo","rootStore","selector","value","useSyncExternalStoreWithSelector"],"mappings":";;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;AASa,MAAI,IAAE;AAAiB,WAAS,EAAE,GAAE,GAAE;AAAC,WAAO,MAAI,MAAI,MAAI,KAAG,IAAE,MAAI,IAAE,MAAI,MAAI,KAAG,MAAI;AAAA,EAAC;AAAC,MAAI,IAAE,eAAa,OAAO,OAAO,KAAG,O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,MAAS,IAAI,QAAY,CAAC,OAAO,OAAO,CAAC;AAE3F,YAAU,MAAM;AACd,QAAI,eAAe;AACjB,YAAM,WAAW;AAAA,IACnB;AAAA,EACF,GAAG,CAAE,CAAA;AAEE,SAAA,SAAS,aAAa,OAAO;AACtC;AC/CA,MAAM,iCAAiB;AAEvB,SAAS,gBAAmB,OAAoC;AAC1D,MAAA,UAAU,WAAW,IAAI,KAAK;AAElC,MAAI,CAAC,SAAS;AACZ,cAAU,cAAwB,YAAY,MAAM,YAAY,CAAC;AACtD,eAAA,IAAI,OAAO,OAAO;AAAA,EAC/B;AAEO,SAAA;AACT;AAEO,SAAS,cAAiB,EAAE,OAAO,OAAO,YAAY,YAA2B;AAChF,QAAA,UAAU,gBAAgB,KAAK;AACrC,QAAM,eAAe;AAAA,IACnB,MAAM,cAAc,YAAY,MAAM,YAAY;AAAA,IAClD,CAAC,OAAO,UAAU;AAAA,EAAA;AAGpB,6BAAQ,QAAQ,UAAR,EAAiB,OAAO,cAAe,SAAS,CAAA;AAC1D;AAEO,SAAS,SAAY,OAA2B;AAC/C,QAAA,UAAU,gBAAgB,KAAK;AACrC,SAAO,WAAW,OAAO;AAC3B;AAEgB,SAAA,cAAiB,OAAiB,SAA8B;AACxE,QAAA,QAAQ,SAAS,KAAK;AACrB,SAAA,SAAS,OAAO,OAAO;AAChC;AAEgB,SAAA,aAAgB,OAAiB,SAA2B;AACpE,QAAA,QAAQ,SAAS,KAAK;AACrB,SAAA,QAAQ,OAAO,OAAO;AAC/B;","x_google_ignoreList":[0,1,2,3,4,5]}
1
+ {"version":3,"file":"scope2.mjs","sources":["../../node_modules/.pnpm/use-sync-external-store@1.2.0_react@18.2.0/node_modules/use-sync-external-store/cjs/use-sync-external-store-shim.production.min.js","../../node_modules/.pnpm/use-sync-external-store@1.2.0_react@18.2.0/node_modules/use-sync-external-store/cjs/use-sync-external-store-shim.development.js","../../node_modules/.pnpm/use-sync-external-store@1.2.0_react@18.2.0/node_modules/use-sync-external-store/shim/index.js","../../node_modules/.pnpm/use-sync-external-store@1.2.0_react@18.2.0/node_modules/use-sync-external-store/cjs/use-sync-external-store-shim/with-selector.production.min.js","../../node_modules/.pnpm/use-sync-external-store@1.2.0_react@18.2.0/node_modules/use-sync-external-store/cjs/use-sync-external-store-shim/with-selector.development.js","../../node_modules/.pnpm/use-sync-external-store@1.2.0_react@18.2.0/node_modules/use-sync-external-store/shim/with-selector.js","../../src/react/useStore.ts","../../src/react/useProp.ts","../../src/react/reactMethods.ts","../../src/react/useCache.ts","../../src/react/scope.tsx"],"sourcesContent":["/**\n * @license React\n * use-sync-external-store-shim.production.min.js\n *\n * Copyright (c) Facebook, Inc. and its affiliates.\n *\n * This source code is licensed under the MIT license found in the\n * LICENSE file in the root directory of this source tree.\n */\n'use strict';var e=require(\"react\");function h(a,b){return a===b&&(0!==a||1/a===1/b)||a!==a&&b!==b}var k=\"function\"===typeof Object.is?Object.is:h,l=e.useState,m=e.useEffect,n=e.useLayoutEffect,p=e.useDebugValue;function q(a,b){var d=b(),f=l({inst:{value:d,getSnapshot:b}}),c=f[0].inst,g=f[1];n(function(){c.value=d;c.getSnapshot=b;r(c)&&g({inst:c})},[a,d,b]);m(function(){r(c)&&g({inst:c});return a(function(){r(c)&&g({inst:c})})},[a]);p(d);return d}\nfunction r(a){var b=a.getSnapshot;a=a.value;try{var d=b();return!k(a,d)}catch(f){return!0}}function t(a,b){return b()}var u=\"undefined\"===typeof window||\"undefined\"===typeof window.document||\"undefined\"===typeof window.document.createElement?t:q;exports.useSyncExternalStore=void 0!==e.useSyncExternalStore?e.useSyncExternalStore:u;\n","/**\n * @license React\n * use-sync-external-store-shim.development.js\n *\n * Copyright (c) Facebook, Inc. and its affiliates.\n *\n * This source code is licensed under the MIT license found in the\n * LICENSE file in the root directory of this source tree.\n */\n\n'use strict';\n\nif (process.env.NODE_ENV !== \"production\") {\n (function() {\n\n 'use strict';\n\n/* global __REACT_DEVTOOLS_GLOBAL_HOOK__ */\nif (\n typeof __REACT_DEVTOOLS_GLOBAL_HOOK__ !== 'undefined' &&\n typeof __REACT_DEVTOOLS_GLOBAL_HOOK__.registerInternalModuleStart ===\n 'function'\n) {\n __REACT_DEVTOOLS_GLOBAL_HOOK__.registerInternalModuleStart(new Error());\n}\n var React = require('react');\n\nvar ReactSharedInternals = React.__SECRET_INTERNALS_DO_NOT_USE_OR_YOU_WILL_BE_FIRED;\n\nfunction error(format) {\n {\n {\n for (var _len2 = arguments.length, args = new Array(_len2 > 1 ? _len2 - 1 : 0), _key2 = 1; _key2 < _len2; _key2++) {\n args[_key2 - 1] = arguments[_key2];\n }\n\n printWarning('error', format, args);\n }\n }\n}\n\nfunction printWarning(level, format, args) {\n // When changing this logic, you might want to also\n // update consoleWithStackDev.www.js as well.\n {\n var ReactDebugCurrentFrame = ReactSharedInternals.ReactDebugCurrentFrame;\n var stack = ReactDebugCurrentFrame.getStackAddendum();\n\n if (stack !== '') {\n format += '%s';\n args = args.concat([stack]);\n } // eslint-disable-next-line react-internal/safe-string-coercion\n\n\n var argsWithFormat = args.map(function (item) {\n return String(item);\n }); // Careful: RN currently depends on this prefix\n\n argsWithFormat.unshift('Warning: ' + format); // We intentionally don't use spread (or .apply) directly because it\n // breaks IE9: https://github.com/facebook/react/issues/13610\n // eslint-disable-next-line react-internal/no-production-logging\n\n Function.prototype.apply.call(console[level], console, argsWithFormat);\n }\n}\n\n/**\n * inlined Object.is polyfill to avoid requiring consumers ship their own\n * https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/Object/is\n */\nfunction is(x, y) {\n return x === y && (x !== 0 || 1 / x === 1 / y) || x !== x && y !== y // eslint-disable-line no-self-compare\n ;\n}\n\nvar objectIs = typeof Object.is === 'function' ? Object.is : is;\n\n// dispatch for CommonJS interop named imports.\n\nvar useState = React.useState,\n useEffect = React.useEffect,\n useLayoutEffect = React.useLayoutEffect,\n useDebugValue = React.useDebugValue;\nvar didWarnOld18Alpha = false;\nvar didWarnUncachedGetSnapshot = false; // Disclaimer: This shim breaks many of the rules of React, and only works\n// because of a very particular set of implementation details and assumptions\n// -- change any one of them and it will break. The most important assumption\n// is that updates are always synchronous, because concurrent rendering is\n// only available in versions of React that also have a built-in\n// useSyncExternalStore API. And we only use this shim when the built-in API\n// does not exist.\n//\n// Do not assume that the clever hacks used by this hook also work in general.\n// The point of this shim is to replace the need for hacks by other libraries.\n\nfunction useSyncExternalStore(subscribe, getSnapshot, // Note: The shim does not use getServerSnapshot, because pre-18 versions of\n// React do not expose a way to check if we're hydrating. So users of the shim\n// will need to track that themselves and return the correct value\n// from `getSnapshot`.\ngetServerSnapshot) {\n {\n if (!didWarnOld18Alpha) {\n if (React.startTransition !== undefined) {\n didWarnOld18Alpha = true;\n\n error('You are using an outdated, pre-release alpha of React 18 that ' + 'does not support useSyncExternalStore. The ' + 'use-sync-external-store shim will not work correctly. Upgrade ' + 'to a newer pre-release.');\n }\n }\n } // Read the current snapshot from the store on every render. Again, this\n // breaks the rules of React, and only works here because of specific\n // implementation details, most importantly that updates are\n // always synchronous.\n\n\n var value = getSnapshot();\n\n {\n if (!didWarnUncachedGetSnapshot) {\n var cachedValue = getSnapshot();\n\n if (!objectIs(value, cachedValue)) {\n error('The result of getSnapshot should be cached to avoid an infinite loop');\n\n didWarnUncachedGetSnapshot = true;\n }\n }\n } // Because updates are synchronous, we don't queue them. Instead we force a\n // re-render whenever the subscribed state changes by updating an some\n // arbitrary useState hook. Then, during render, we call getSnapshot to read\n // the current value.\n //\n // Because we don't actually use the state returned by the useState hook, we\n // can save a bit of memory by storing other stuff in that slot.\n //\n // To implement the early bailout, we need to track some things on a mutable\n // object. Usually, we would put that in a useRef hook, but we can stash it in\n // our useState hook instead.\n //\n // To force a re-render, we call forceUpdate({inst}). That works because the\n // new object always fails an equality check.\n\n\n var _useState = useState({\n inst: {\n value: value,\n getSnapshot: getSnapshot\n }\n }),\n inst = _useState[0].inst,\n forceUpdate = _useState[1]; // Track the latest getSnapshot function with a ref. This needs to be updated\n // in the layout phase so we can access it during the tearing check that\n // happens on subscribe.\n\n\n useLayoutEffect(function () {\n inst.value = value;\n inst.getSnapshot = getSnapshot; // Whenever getSnapshot or subscribe changes, we need to check in the\n // commit phase if there was an interleaved mutation. In concurrent mode\n // this can happen all the time, but even in synchronous mode, an earlier\n // effect may have mutated the store.\n\n if (checkIfSnapshotChanged(inst)) {\n // Force a re-render.\n forceUpdate({\n inst: inst\n });\n }\n }, [subscribe, value, getSnapshot]);\n useEffect(function () {\n // Check for changes right before subscribing. Subsequent changes will be\n // detected in the subscription handler.\n if (checkIfSnapshotChanged(inst)) {\n // Force a re-render.\n forceUpdate({\n inst: inst\n });\n }\n\n var handleStoreChange = function () {\n // TODO: Because there is no cross-renderer API for batching updates, it's\n // up to the consumer of this library to wrap their subscription event\n // with unstable_batchedUpdates. Should we try to detect when this isn't\n // the case and print a warning in development?\n // The store changed. Check if the snapshot changed since the last time we\n // read from the store.\n if (checkIfSnapshotChanged(inst)) {\n // Force a re-render.\n forceUpdate({\n inst: inst\n });\n }\n }; // Subscribe to the store and return a clean-up function.\n\n\n return subscribe(handleStoreChange);\n }, [subscribe]);\n useDebugValue(value);\n return value;\n}\n\nfunction checkIfSnapshotChanged(inst) {\n var latestGetSnapshot = inst.getSnapshot;\n var prevValue = inst.value;\n\n try {\n var nextValue = latestGetSnapshot();\n return !objectIs(prevValue, nextValue);\n } catch (error) {\n return true;\n }\n}\n\nfunction useSyncExternalStore$1(subscribe, getSnapshot, getServerSnapshot) {\n // Note: The shim does not use getServerSnapshot, because pre-18 versions of\n // React do not expose a way to check if we're hydrating. So users of the shim\n // will need to track that themselves and return the correct value\n // from `getSnapshot`.\n return getSnapshot();\n}\n\nvar canUseDOM = !!(typeof window !== 'undefined' && typeof window.document !== 'undefined' && typeof window.document.createElement !== 'undefined');\n\nvar isServerEnvironment = !canUseDOM;\n\nvar shim = isServerEnvironment ? useSyncExternalStore$1 : useSyncExternalStore;\nvar useSyncExternalStore$2 = React.useSyncExternalStore !== undefined ? React.useSyncExternalStore : shim;\n\nexports.useSyncExternalStore = useSyncExternalStore$2;\n /* global __REACT_DEVTOOLS_GLOBAL_HOOK__ */\nif (\n typeof __REACT_DEVTOOLS_GLOBAL_HOOK__ !== 'undefined' &&\n typeof __REACT_DEVTOOLS_GLOBAL_HOOK__.registerInternalModuleStop ===\n 'function'\n) {\n __REACT_DEVTOOLS_GLOBAL_HOOK__.registerInternalModuleStop(new Error());\n}\n \n })();\n}\n","'use strict';\n\nif (process.env.NODE_ENV === 'production') {\n module.exports = require('../cjs/use-sync-external-store-shim.production.min.js');\n} else {\n module.exports = require('../cjs/use-sync-external-store-shim.development.js');\n}\n","/**\n * @license React\n * use-sync-external-store-shim/with-selector.production.min.js\n *\n * Copyright (c) Facebook, Inc. and its affiliates.\n *\n * This source code is licensed under the MIT license found in the\n * LICENSE file in the root directory of this source tree.\n */\n'use strict';var h=require(\"react\"),n=require(\"use-sync-external-store/shim\");function p(a,b){return a===b&&(0!==a||1/a===1/b)||a!==a&&b!==b}var q=\"function\"===typeof Object.is?Object.is:p,r=n.useSyncExternalStore,t=h.useRef,u=h.useEffect,v=h.useMemo,w=h.useDebugValue;\nexports.useSyncExternalStoreWithSelector=function(a,b,e,l,g){var c=t(null);if(null===c.current){var f={hasValue:!1,value:null};c.current=f}else f=c.current;c=v(function(){function a(a){if(!c){c=!0;d=a;a=l(a);if(void 0!==g&&f.hasValue){var b=f.value;if(g(b,a))return k=b}return k=a}b=k;if(q(d,a))return b;var e=l(a);if(void 0!==g&&g(b,e))return b;d=a;return k=e}var c=!1,d,k,m=void 0===e?null:e;return[function(){return a(b())},null===m?void 0:function(){return a(m())}]},[b,e,l,g]);var d=r(a,c[0],c[1]);\nu(function(){f.hasValue=!0;f.value=d},[d]);w(d);return d};\n","/**\n * @license React\n * use-sync-external-store-shim/with-selector.development.js\n *\n * Copyright (c) Facebook, Inc. and its affiliates.\n *\n * This source code is licensed under the MIT license found in the\n * LICENSE file in the root directory of this source tree.\n */\n\n'use strict';\n\nif (process.env.NODE_ENV !== \"production\") {\n (function() {\n\n 'use strict';\n\n/* global __REACT_DEVTOOLS_GLOBAL_HOOK__ */\nif (\n typeof __REACT_DEVTOOLS_GLOBAL_HOOK__ !== 'undefined' &&\n typeof __REACT_DEVTOOLS_GLOBAL_HOOK__.registerInternalModuleStart ===\n 'function'\n) {\n __REACT_DEVTOOLS_GLOBAL_HOOK__.registerInternalModuleStart(new Error());\n}\n var React = require('react');\nvar shim = require('use-sync-external-store/shim');\n\n/**\n * inlined Object.is polyfill to avoid requiring consumers ship their own\n * https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/Object/is\n */\nfunction is(x, y) {\n return x === y && (x !== 0 || 1 / x === 1 / y) || x !== x && y !== y // eslint-disable-line no-self-compare\n ;\n}\n\nvar objectIs = typeof Object.is === 'function' ? Object.is : is;\n\nvar useSyncExternalStore = shim.useSyncExternalStore;\n\n// for CommonJS interop.\n\nvar useRef = React.useRef,\n useEffect = React.useEffect,\n useMemo = React.useMemo,\n useDebugValue = React.useDebugValue; // Same as useSyncExternalStore, but supports selector and isEqual arguments.\n\nfunction useSyncExternalStoreWithSelector(subscribe, getSnapshot, getServerSnapshot, selector, isEqual) {\n // Use this to track the rendered snapshot.\n var instRef = useRef(null);\n var inst;\n\n if (instRef.current === null) {\n inst = {\n hasValue: false,\n value: null\n };\n instRef.current = inst;\n } else {\n inst = instRef.current;\n }\n\n var _useMemo = useMemo(function () {\n // Track the memoized state using closure variables that are local to this\n // memoized instance of a getSnapshot function. Intentionally not using a\n // useRef hook, because that state would be shared across all concurrent\n // copies of the hook/component.\n var hasMemo = false;\n var memoizedSnapshot;\n var memoizedSelection;\n\n var memoizedSelector = function (nextSnapshot) {\n if (!hasMemo) {\n // The first time the hook is called, there is no memoized result.\n hasMemo = true;\n memoizedSnapshot = nextSnapshot;\n\n var _nextSelection = selector(nextSnapshot);\n\n if (isEqual !== undefined) {\n // Even if the selector has changed, the currently rendered selection\n // may be equal to the new selection. We should attempt to reuse the\n // current value if possible, to preserve downstream memoizations.\n if (inst.hasValue) {\n var currentSelection = inst.value;\n\n if (isEqual(currentSelection, _nextSelection)) {\n memoizedSelection = currentSelection;\n return currentSelection;\n }\n }\n }\n\n memoizedSelection = _nextSelection;\n return _nextSelection;\n } // We may be able to reuse the previous invocation's result.\n\n\n // We may be able to reuse the previous invocation's result.\n var prevSnapshot = memoizedSnapshot;\n var prevSelection = memoizedSelection;\n\n if (objectIs(prevSnapshot, nextSnapshot)) {\n // The snapshot is the same as last time. Reuse the previous selection.\n return prevSelection;\n } // The snapshot has changed, so we need to compute a new selection.\n\n\n // The snapshot has changed, so we need to compute a new selection.\n var nextSelection = selector(nextSnapshot); // If a custom isEqual function is provided, use that to check if the data\n // has changed. If it hasn't, return the previous selection. That signals\n // to React that the selections are conceptually equal, and we can bail\n // out of rendering.\n\n // If a custom isEqual function is provided, use that to check if the data\n // has changed. If it hasn't, return the previous selection. That signals\n // to React that the selections are conceptually equal, and we can bail\n // out of rendering.\n if (isEqual !== undefined && isEqual(prevSelection, nextSelection)) {\n return prevSelection;\n }\n\n memoizedSnapshot = nextSnapshot;\n memoizedSelection = nextSelection;\n return nextSelection;\n }; // Assigning this to a constant so that Flow knows it can't change.\n\n\n // Assigning this to a constant so that Flow knows it can't change.\n var maybeGetServerSnapshot = getServerSnapshot === undefined ? null : getServerSnapshot;\n\n var getSnapshotWithSelector = function () {\n return memoizedSelector(getSnapshot());\n };\n\n var getServerSnapshotWithSelector = maybeGetServerSnapshot === null ? undefined : function () {\n return memoizedSelector(maybeGetServerSnapshot());\n };\n return [getSnapshotWithSelector, getServerSnapshotWithSelector];\n }, [getSnapshot, getServerSnapshot, selector, isEqual]),\n getSelection = _useMemo[0],\n getServerSelection = _useMemo[1];\n\n var value = useSyncExternalStore(subscribe, getSelection, getServerSelection);\n useEffect(function () {\n inst.hasValue = true;\n inst.value = value;\n }, [value]);\n useDebugValue(value);\n return value;\n}\n\nexports.useSyncExternalStoreWithSelector = useSyncExternalStoreWithSelector;\n /* global __REACT_DEVTOOLS_GLOBAL_HOOK__ */\nif (\n typeof __REACT_DEVTOOLS_GLOBAL_HOOK__ !== 'undefined' &&\n typeof __REACT_DEVTOOLS_GLOBAL_HOOK__.registerInternalModuleStop ===\n 'function'\n) {\n __REACT_DEVTOOLS_GLOBAL_HOOK__.registerInternalModuleStop(new Error());\n}\n \n })();\n}\n","'use strict';\n\nif (process.env.NODE_ENV === 'production') {\n module.exports = require('../cjs/use-sync-external-store-shim/with-selector.production.min.js');\n} else {\n module.exports = require('../cjs/use-sync-external-store-shim/with-selector.development.js');\n}\n","import { useCallback, useDebugValue, useLayoutEffect, useMemo, useRef } from 'react';\nimport { useSyncExternalStoreWithSelector } from 'use-sync-external-store/shim/with-selector.js';\nimport type { SubscribeOptions } from '@core/commonTypes';\nimport type { Store } from '@core/store';\nimport { hash } from '@lib/hash';\nimport { makeSelector } from '@lib/makeSelector';\nimport { trackingProxy } from '@lib/trackingProxy';\n\nexport type UseStoreOptions = Omit<SubscribeOptions, 'runNow' | 'passive'>;\n\nexport function useStore<T>(store: Store<T>, options?: UseStoreOptions): T {\n const lastEqualsRef = useRef<(newValue: T) => boolean>();\n\n const { rootStore, selector } = useMemo(() => {\n const rootStore = store.derivedFrom?.store ?? store;\n let selector = (x: any) => x;\n\n if (store.derivedFrom) {\n selector = (value: any) => {\n for (const s of store.derivedFrom!.selectors) {\n value = makeSelector(s)(value);\n }\n return value;\n };\n }\n\n return { rootStore, selector };\n }, [store]);\n\n const subOptions = { ...options, runNow: false, equals: undefined, passive: false };\n const subscribe = useCallback(\n (listener: () => void) => {\n return rootStore.subscribe(listener, subOptions);\n },\n [rootStore, hash(subOptions)],\n );\n\n const value = useSyncExternalStoreWithSelector<unknown, T>(\n //\n subscribe,\n rootStore.get,\n undefined,\n selector,\n options?.equals ?? ((_v, newValue) => lastEqualsRef.current?.(newValue) ?? false),\n );\n const [proxiedValue, equals, revoke] = trackingProxy(value);\n\n useLayoutEffect(() => {\n lastEqualsRef.current = equals;\n revoke?.();\n });\n\n useDebugValue(value);\n return proxiedValue;\n}\n","import type { UseStoreOptions } from './useStore';\nimport { useStore } from './useStore';\nimport type { Store } from '@core/store';\n\nexport function useProp<T>(\n store: Store<T>,\n options?: UseStoreOptions,\n): [value: T, setValue: typeof store.set] {\n const value = useStore(store, options);\n\n return [value, store.set];\n}\n","import { useProp } from './useProp';\nimport { type UseStoreOptions, useStore } from './useStore';\nimport type { Store } from '@core/store';\n\nexport const reactMethods = {\n useStore<T>(this: Store<T>, options?: UseStoreOptions) {\n return useStore(this, options);\n },\n\n useProp<T>(this: Store<T>, options?: UseStoreOptions) {\n return useProp(this, options);\n },\n};\n","import { useEffect, useMemo } from 'react';\nimport type { UseStoreOptions } from './useStore';\nimport { useStore } from './useStore';\nimport type { Cache } from '@core';\nimport type { CacheState } from '@lib/cacheState';\nimport { makeSelector } from '@lib/makeSelector';\n\nexport type UseCacheArray<T> = [\n value: T | undefined,\n error: unknown | undefined,\n isUpdating: boolean,\n isStale: boolean,\n];\n\nexport type UseCacheValue<T> = UseCacheArray<T> & CacheState<T>;\n\nexport interface UseCacheOptions extends UseStoreOptions {\n passive?: boolean;\n updateOnMount?: boolean;\n}\n\nexport function useCache<T>(\n cache: Cache<T>,\n { passive, updateOnMount, ...options }: UseCacheOptions = {},\n): UseCacheValue<T> {\n const mappedState = useMemo(() => {\n const rootCache: Cache<any> = cache.derivedFromCache?.cache ?? cache;\n let selector = (x: any) => x;\n\n if (cache.derivedFromCache) {\n selector = (value: any) => {\n for (const s of cache.derivedFromCache!.selectors) {\n value = makeSelector(s)(value);\n }\n return value;\n };\n }\n\n return rootCache.state.map((state) => {\n const value = state.status === 'value' ? selector(state.value) : undefined;\n\n return Object.assign<UseCacheArray<T>, CacheState<T>>(\n [value, state.error, state.isUpdating, state.isStale],\n { ...state, value },\n );\n });\n }, [cache]);\n\n useEffect(() => (!passive ? cache.subscribe(() => undefined) : undefined), [cache, passive]);\n\n useEffect(() => {\n if (updateOnMount) {\n cache.invalidate();\n }\n }, []);\n\n return useStore(mappedState, options);\n}\n","import type { Context, ReactNode } from 'react';\nimport { createContext, useContext, useMemo } from 'react';\nimport { useProp } from './useProp';\nimport { useStore, type UseStoreOptions } from './useStore';\nimport { createStore } from '@core/store';\nimport type { Store } from '@core/store';\nimport type { Scope } from '@core';\n\nexport type ScopeProps<T> = { scope: Scope<T>; store?: Store<T>; children?: ReactNode };\n\nconst contextMap = new WeakMap<Scope<any>, Context<Store<any>>>();\n\nfunction getScopeContext<T>(scope: Scope<T>): Context<Store<T>> {\n let context = contextMap.get(scope);\n\n if (!context) {\n context = createContext<Store<T>>(createStore(scope.defaultValue));\n contextMap.set(scope, context);\n }\n\n return context;\n}\n\nexport function ScopeProvider<T>({ scope, store: inputStore, children }: ScopeProps<T>) {\n const context = getScopeContext(scope);\n const currentStore = useMemo(\n () => inputStore ?? createStore(scope.defaultValue),\n [scope, inputStore],\n );\n\n return <context.Provider value={currentStore}>{children}</context.Provider>;\n}\n\nexport function useScope<T>(scope: Scope<T>): Store<T> {\n const context = getScopeContext(scope);\n return useContext(context);\n}\n\nexport function useScopeStore<T>(scope: Scope<T>, options?: UseStoreOptions): T {\n const store = useScope(scope);\n return useStore(store, options);\n}\n\nexport function useScopeProp<T>(scope: Scope<T>, options?: UseStoreOptions) {\n const store = useScope(scope);\n return useProp(store, options);\n}\n"],"names":["useEffect","useLayoutEffect","useDebugValue","error","shim","require$$0","require$$1","a","c","d","b","e","useRef","useMemo","rootStore","selector","value","useSyncExternalStoreWithSelector"],"mappings":";;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;AASa,MAAI,IAAE;AAAiB,WAAS,EAAE,GAAE,GAAE;AAAC,WAAO,MAAI,MAAI,MAAI,KAAG,IAAE,MAAI,IAAE,MAAI,MAAI,KAAG,MAAI;AAAA,EAAC;AAAC,MAAI,IAAE,eAAa,OAAO,OAAO,KAAG,OAAO,KAAG,GAAE,IAAE,EAAE,UA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AAC,OAAO,OAAO,CAAC;AAE3F,YAAU,MAAM;AACd,QAAI,eAAe;AACjB,YAAM,WAAW;AAAA,IACnB;AAAA,EACF,GAAG,CAAE,CAAA;AAEE,SAAA,SAAS,aAAa,OAAO;AACtC;AC/CA,MAAM,iCAAiB;AAEvB,SAAS,gBAAmB,OAAoC;AAC1D,MAAA,UAAU,WAAW,IAAI,KAAK;AAElC,MAAI,CAAC,SAAS;AACZ,cAAU,cAAwB,YAAY,MAAM,YAAY,CAAC;AACtD,eAAA,IAAI,OAAO,OAAO;AAAA,EAC/B;AAEO,SAAA;AACT;AAEO,SAAS,cAAiB,EAAE,OAAO,OAAO,YAAY,YAA2B;AAChF,QAAA,UAAU,gBAAgB,KAAK;AACrC,QAAM,eAAe;AAAA,IACnB,MAAM,cAAc,YAAY,MAAM,YAAY;AAAA,IAClD,CAAC,OAAO,UAAU;AAAA,EAAA;AAGpB,6BAAQ,QAAQ,UAAR,EAAiB,OAAO,cAAe,SAAS,CAAA;AAC1D;AAEO,SAAS,SAAY,OAA2B;AAC/C,QAAA,UAAU,gBAAgB,KAAK;AACrC,SAAO,WAAW,OAAO;AAC3B;AAEgB,SAAA,cAAiB,OAAiB,SAA8B;AACxE,QAAA,QAAQ,SAAS,KAAK;AACrB,SAAA,SAAS,OAAO,OAAO;AAChC;AAEgB,SAAA,aAAgB,OAAiB,SAA2B;AACpE,QAAA,QAAQ,SAAS,KAAK;AACrB,SAAA,QAAQ,OAAO,OAAO;AAC/B;","x_google_ignoreList":[0,1,2,3,4,5]}
package/dist/es/store.mjs CHANGED
@@ -109,6 +109,7 @@ const internalEqual = (comp) => (a, b) => {
109
109
  }
110
110
  return false;
111
111
  };
112
+ const unwrapProxySymbol = /* @__PURE__ */ Symbol("unwrapProxy");
112
113
  function isPlainObject(value) {
113
114
  return typeof value === "object" && value !== null && Object.getPrototypeOf(value) === Object.prototype;
114
115
  }
@@ -116,15 +117,21 @@ function trackingProxy(value, equals = deepEqual) {
116
117
  if (!isPlainObject(value) && !Array.isArray(value)) {
117
118
  return [value, (other) => equals(value, other)];
118
119
  }
120
+ value = value[unwrapProxySymbol] ?? value;
119
121
  const deps = new Array();
122
+ const revokations = new Array();
123
+ let revoked = false;
120
124
  function trackComplexProp(function_, ...args) {
121
- const [proxiedValue, equals2] = trackingProxy(function_(value, ...args));
125
+ const [proxiedValue, equals2, revoke] = trackingProxy(function_(value, ...args));
122
126
  deps.push((otherValue) => {
123
127
  if (!isPlainObject(otherValue) && !Array.isArray(otherValue)) {
124
128
  return false;
125
129
  }
126
130
  return equals2(function_(otherValue, ...args));
127
131
  });
132
+ if (revoke) {
133
+ revokations.push(revoke);
134
+ }
128
135
  return proxiedValue;
129
136
  }
130
137
  function trackSimpleProp(function_, ...args) {
@@ -136,6 +143,12 @@ function trackingProxy(value, equals = deepEqual) {
136
143
  }
137
144
  const proxy = new Proxy(value, {
138
145
  get(target, p, receiver) {
146
+ if (p === unwrapProxySymbol) {
147
+ return value;
148
+ }
149
+ if (revoked) {
150
+ return target[p];
151
+ }
139
152
  const { writable, configurable } = Object.getOwnPropertyDescriptor(target, p) ?? {};
140
153
  if (writable === false && configurable === false) {
141
154
  return target[p];
@@ -162,7 +175,14 @@ function trackingProxy(value, equals = deepEqual) {
162
175
  return trackSimpleProp(Reflect.isExtensible);
163
176
  }
164
177
  });
165
- return [proxy, (other) => !!other && deps.every((equals2) => equals2(other))];
178
+ return [
179
+ proxy,
180
+ (other) => !!other && deps.every((equals2) => equals2(other)),
181
+ () => {
182
+ revoked = true;
183
+ revokations.forEach((revoke) => revoke());
184
+ }
185
+ ];
166
186
  }
167
187
  class CalculationHelper {
168
188
  constructor(options) {
@@ -1 +1 @@
1
- {"version":3,"file":"store.mjs","sources":["../../src/lib/calcDuration.ts","../../src/lib/queue.ts","../../src/lib/equals.ts","../../src/lib/trackingProxy.ts","../../src/lib/calculationHelper.ts","../../src/lib/callable.ts","../../src/lib/debounce.ts","../../src/lib/forwardError.ts","../../src/lib/clone.ts","../../src/lib/propAccess.ts","../../src/lib/makeSelector.ts","../../src/lib/standardMethods.ts","../../src/lib/throttle.ts","../../src/core/store.ts"],"sourcesContent":["import type { Duration } from '../core/commonTypes';\n\nexport function calcDuration(t: Duration) {\n if (typeof t === 'number') return t;\n return (\n (t.milliseconds ?? 0) +\n (t.seconds ?? 0) * 1000 +\n (t.minutes ?? 0) * 60 * 1000 +\n (t.hours ?? 0) * 60 * 60 * 1000 +\n (t.days ?? 0) * 24 * 60 * 60 * 1000\n );\n}\n","import type { MaybePromise } from './maybePromise';\nimport type { Listener } from '@core';\n\ntype Action<T> = () => MaybePromise<T>;\n\nexport interface Queue {\n <T>(action: Action<T>, ref?: any): Promise<T>;\n clear: () => void;\n whenDone: () => Promise<void>;\n size: number;\n getRefs: () => any[];\n}\n\nexport function queue(): Queue {\n const q: {\n action: Action<any>;\n resolve: (value: any) => void;\n reject: (error: unknown) => void;\n ref?: any;\n }[] = [];\n const completionListeners = new Set<Listener<void>>();\n let active = false;\n\n const notify = () => {\n for (const listener of completionListeners) {\n listener();\n }\n\n completionListeners.clear();\n };\n\n const run = async () => {\n if (!active) {\n active = true;\n\n let next;\n while ((next = q.shift())) {\n try {\n let result = next.action();\n if (result instanceof Promise) {\n result = await result;\n }\n\n next.resolve(result);\n } catch (error) {\n next.reject(error);\n }\n }\n\n active = false;\n notify();\n }\n };\n\n return Object.assign(\n <T>(action: Action<T>, ref?: any) => {\n return new Promise<T>((resolve, reject) => {\n q.push({ action, resolve, reject, ref });\n run();\n });\n },\n {\n clear() {\n q.length = 0;\n },\n\n whenDone() {\n if (!active) {\n return Promise.resolve();\n }\n\n return new Promise<void>((resolve) => {\n completionListeners.add(resolve);\n });\n },\n\n get size() {\n return q.length;\n },\n\n getRefs() {\n return q.map((item) => item.ref).filter((x) => x !== undefined);\n },\n },\n );\n}\n","export function defaultEqual(a: any, b: any) {\n return a === b;\n}\n\nexport function shallowEqual(a: any, b: any): boolean {\n return internalEqual(defaultEqual)(a, b);\n}\n\nexport function deepEqual(a: any, b: any): boolean {\n return internalEqual(deepEqual)(a, b);\n}\n\nconst internalEqual = (comp: (a: any, b: any) => boolean) => (a: any, b: any) => {\n if (a === b) {\n return true;\n }\n\n if (a === null || b === null || typeof a !== 'object' || typeof b !== 'object') {\n // eslint-disable-next-line no-self-compare\n return a !== a && b !== b;\n }\n\n if (a.constructor !== b.constructor) {\n return false;\n }\n\n if (a.constructor === Object) {\n const entries1 = Object.entries(a);\n const entries2 = Object.entries(b);\n return (\n entries1.length === entries2.length && entries1.every(([key, value]) => comp(value, b[key]))\n );\n }\n\n if (Array.isArray(a)) {\n return a.length === b.length && a.every((value, i) => comp(value, b[i]));\n }\n\n if (a instanceof Date) {\n return a.getTime() === b.getTime();\n }\n\n if (a instanceof RegExp) {\n return a.source === b.source && a.flags === b.flags;\n }\n\n if (a instanceof Map) {\n return a.size === b.size && [...a.entries()].every(([key, value]) => comp(value, b.get(key)));\n }\n\n if (a instanceof Set) {\n return a.size === b.size && [...a.values()].every((value) => b.has(value));\n }\n\n if (typeof ArrayBuffer !== 'undefined' && ArrayBuffer.isView(a)) {\n if (a.byteLength !== b.byteLength) {\n return false;\n }\n\n const a_ = new Int8Array(a.buffer);\n const b_ = new Int8Array(b.buffer);\n return a_.every((value, i) => value === b_[i]);\n }\n\n return false;\n};\n","import { deepEqual } from './equals';\n\nexport type TrackingProxy<T> = [value: T, equals: (newValue: T) => boolean];\ntype Object_ = Record<string | symbol, unknown>;\n\nfunction isPlainObject(value: unknown) {\n return (\n typeof value === 'object' && value !== null && Object.getPrototypeOf(value) === Object.prototype\n );\n}\n\nexport function trackingProxy<T>(value: T, equals = deepEqual): TrackingProxy<T> {\n if (!isPlainObject(value) && !Array.isArray(value)) {\n return [value, (other) => equals(value, other)];\n }\n\n const deps = new Array<TrackingProxy<any>[1]>();\n\n function trackComplexProp(function_: any, ...args: any[]) {\n const [proxiedValue, equals] = trackingProxy(function_(value, ...args));\n\n deps.push((otherValue) => {\n if (!isPlainObject(otherValue) && !Array.isArray(otherValue)) {\n return false;\n }\n\n return equals(function_(otherValue, ...args));\n });\n\n return proxiedValue;\n }\n\n function trackSimpleProp(function_: any, ...args: any[]) {\n const calculatedValue = function_(value, ...args);\n\n deps.push((otherValue) => {\n return function_(otherValue, ...args) === calculatedValue;\n });\n\n return calculatedValue;\n }\n\n const proxy = new Proxy(value as T & Object_, {\n get(target, p, receiver) {\n const { writable, configurable } = Object.getOwnPropertyDescriptor(target, p) ?? {};\n if (writable === false && configurable === false) {\n return target[p];\n }\n\n return trackComplexProp(Reflect.get, p, receiver);\n },\n\n getOwnPropertyDescriptor(target, p) {\n const { writable, configurable } = Object.getOwnPropertyDescriptor(target, p) ?? {};\n if (writable === false && configurable === false) {\n return Reflect.getOwnPropertyDescriptor(target, p);\n }\n\n return trackComplexProp(Reflect.getOwnPropertyDescriptor, p);\n },\n\n ownKeys() {\n return trackComplexProp(Reflect.ownKeys);\n },\n\n getPrototypeOf() {\n return trackSimpleProp(Reflect.getPrototypeOf);\n },\n\n has(_target, p) {\n return trackSimpleProp(Reflect.has, p);\n },\n\n isExtensible() {\n return trackSimpleProp(Reflect.isExtensible);\n },\n });\n\n return [proxy, (other) => !!other && deps.every((equals) => equals(other))];\n}\n","import type { MaybePromise } from './maybePromise';\nimport { queue } from './queue';\nimport { trackingProxy } from './trackingProxy';\nimport { deepEqual } from './equals';\nimport type { Store } from '@core/store';\nimport type {\n CalculationHelpers,\n Cancel,\n ConnectionState,\n UpdateFrom,\n Use,\n} from '@core/commonTypes';\n\nexport class CalculationHelper<T> {\n private current?: {\n cancel: Cancel;\n check: () => void;\n invalidateDependencies: () => void;\n };\n\n constructor(\n public options: {\n calculate: (helpers: CalculationHelpers<T>) => Cancel | void;\n addEffect: (effect: () => Cancel | void) => Cancel;\n getValue?: () => T | undefined;\n onValue?: (value: T) => void;\n onError?: (error: unknown) => void;\n onConnectionState?: (state: ConnectionState) => void;\n onInvalidate?: () => void;\n },\n ) {\n options.addEffect(() => {\n if (this.current) {\n this.current.check();\n } else {\n this.execute();\n }\n });\n }\n\n execute() {\n this.stop();\n\n const { calculate, addEffect, getValue, onValue, onError, onConnectionState, onInvalidate } =\n this.options;\n const checks = new Array<() => boolean>();\n const deps = new Map<Store<any>, { on: () => void; off: () => void; invalidate: () => void }>();\n const q = queue();\n let isActive = false;\n let isCancled = false;\n\n const cancelEffect = addEffect(() => {\n isActive = true;\n\n for (const dep of deps.values()) {\n dep.on();\n }\n\n return () => {\n isActive = false;\n\n for (const dep of deps.values()) {\n dep.off();\n }\n\n if (cancelSubscription) {\n cancelSubscription();\n cancelSubscription = undefined;\n cancel();\n onInvalidate?.();\n }\n };\n });\n\n const cancel = () => {\n isCancled = true;\n cancelSubscription?.();\n cancelEffect();\n delete this.current;\n };\n\n const checkAll = () => {\n if (!checks.every((check) => check())) {\n cancel();\n onInvalidate?.();\n }\n };\n\n const invalidateDependencies = () => {\n for (const dep of deps.values()) {\n dep.invalidate();\n }\n };\n\n const use: Use = (store, { disableProxy } = {}) => {\n if (isCancled) {\n return store.get();\n }\n\n let value = store.get();\n let equals = (newValue: any) => {\n return deepEqual(newValue, value);\n };\n\n if (!disableProxy) {\n [value, equals] = trackingProxy(value);\n }\n\n const check = () => equals(store.get());\n let sub: Cancel | undefined;\n\n const dep = {\n on() {\n this.off();\n\n sub = store.subscribe(\n () => {\n if (sub && !check()) {\n cancel();\n onInvalidate?.();\n }\n },\n { runNow: false },\n );\n },\n off() {\n sub?.();\n sub = undefined;\n },\n invalidate() {\n if ('invalidate' in store && store.invalidate instanceof Function) {\n store.invalidate();\n }\n },\n };\n\n if (isActive) {\n dep.on();\n }\n\n checks.push(check);\n deps.set(store, dep);\n\n return value;\n };\n\n const updateValue = (update: UpdateFrom<MaybePromise<T>, [T | undefined]>) =>\n q(async () => {\n if (isCancled) {\n return;\n }\n\n if (update instanceof Function) {\n try {\n update = update(getValue?.());\n } catch (error) {\n onError?.(error);\n return;\n }\n }\n\n if (update instanceof Promise) {\n try {\n update = await update;\n } catch (error) {\n if (!isCancled) {\n onError?.(error);\n }\n return;\n }\n }\n\n if (!isCancled) {\n onValue?.(update);\n }\n });\n\n const updateError = (error: unknown) =>\n q(() => {\n if (!isCancled) {\n onError?.(error);\n }\n });\n\n const updateConnectionState = (state: ConnectionState) =>\n q(() => {\n if (!isCancled) {\n onConnectionState?.(state);\n }\n });\n\n let cancelSubscription: Cancel | void;\n try {\n cancelSubscription = calculate({ use, updateValue, updateError, updateConnectionState });\n } catch (error) {\n onError?.(error);\n }\n\n this.current = { cancel, check: checkAll, invalidateDependencies };\n }\n\n stop() {\n this.current?.cancel();\n }\n\n check() {\n this.current?.check();\n }\n\n checkOrExecute() {\n if (this.current) {\n this.check();\n } else {\n this.execute();\n }\n }\n\n invalidateDependencies() {\n this.current?.invalidateDependencies();\n }\n}\n","export class Callable<Args extends any[], T> extends Function {\n constructor(protected _call: (...args: Args) => T) {\n super('...args', 'return this._call(...args)');\n\n // eslint-disable-next-line no-constructor-return\n return this.bind(this);\n }\n}\n","import { calcDuration } from './calcDuration';\nimport type { Duration } from '@core';\n\nexport type DebounceOptions =\n | Duration\n | {\n wait: Duration;\n maxWait?: Duration;\n };\n\nexport function debounce<Args extends any[]>(\n action: (...args: Args) => void,\n options: Duration | DebounceOptions,\n): (...args: Args) => void {\n const wait =\n typeof options === 'object' && 'wait' in options\n ? calcDuration(options.wait)\n : calcDuration(options);\n\n const maxWait =\n typeof options === 'object' && 'maxWait' in options && options.maxWait !== undefined\n ? calcDuration(options.maxWait)\n : undefined;\n\n let timeout: ReturnType<typeof setTimeout> | undefined;\n let timeoutStarted: number | undefined;\n\n return (...args: Args) => {\n const now = Date.now();\n timeoutStarted ??= now;\n\n const deadline = Math.min(\n //\n now + wait,\n timeoutStarted + (maxWait ?? Number.POSITIVE_INFINITY),\n );\n\n if (timeout !== undefined) {\n clearTimeout(timeout);\n }\n\n timeout = setTimeout(() => {\n timeout = undefined;\n timeoutStarted = undefined;\n action(...args);\n }, deadline - now);\n };\n}\n","export function forwardError(error: unknown) {\n setTimeout(() => {\n throw error;\n });\n}\n","export function flatClone<T>(object: T): T {\n if (object instanceof Map) {\n return new Map(object) as any;\n }\n\n if (object instanceof Set) {\n return new Set(object) as any;\n }\n\n if (Array.isArray(object)) {\n return [...object] as any;\n }\n\n if (object instanceof Object) {\n return { ...object };\n }\n\n return object;\n}\n","import type { Update } from '../core/commonTypes';\nimport { flatClone } from './clone';\nimport type { Path, Value } from './path';\n\nexport function castArrayPath(path: string | KeyType[]): KeyType[] {\n if (Array.isArray(path)) {\n return path as any;\n }\n\n if (path === '') {\n return [] as any;\n }\n\n return (path as string).split('.') as any;\n}\n\nexport function get<T, P extends Path<T>>(object: T, path: P): Value<T, P> {\n const _path = castArrayPath(path as any);\n const [first, ...rest] = _path;\n\n if (first === undefined || !object) {\n return object as Value<T, P>;\n }\n\n if (object instanceof Map) {\n return get(object.get(first), rest as any);\n }\n\n if (object instanceof Set) {\n return get(Array.from(object)[Number(first)], rest as any);\n }\n\n if (object instanceof Object) {\n return get(object[first as keyof T], rest as any) as Value<T, P>;\n }\n\n throw new Error(`Could not get ${path} of ${object}`);\n}\n\nexport function set<T, P extends Path<T>>(\n object: T,\n path: P,\n value: Update<Value<T, P>>,\n rootPath = path,\n): T {\n const _path = castArrayPath(path as any);\n const [first, ...rest] = _path;\n\n if (first === undefined) {\n return value as any;\n }\n\n const updateChild = (child: any) => {\n if (!child && rest.length > 0) {\n const _rootPath = castArrayPath(rootPath as any);\n\n const prefix = _rootPath.slice(0, -rest.length) as KeyType[];\n throw new Error(`Cannot set ${rootPath} because ${prefix.join('.')} is ${child}`);\n }\n\n return set(child, rest as any, value, rootPath);\n };\n\n if (object instanceof Map) {\n const copy = flatClone(object);\n const child = copy.get(first);\n copy.set(first, updateChild(child));\n return copy;\n }\n\n if (object instanceof Set) {\n const copy = [...object];\n const child = copy[Number(first)];\n copy[Number(first)] = updateChild(child);\n return new Set(copy) as any;\n }\n\n if (object instanceof Object || object === undefined) {\n const copy = flatClone(object ?? ({} as T));\n copy[first as keyof T] = updateChild(copy[first as keyof T]);\n return copy;\n }\n\n throw new Error(`Could not set ${path} of ${object}`);\n}\n\nexport function remove<T, P extends Path<T, true>>(object: T, path: P): T {\n const _path = castArrayPath(path as any);\n\n if (_path.length === 0) {\n return undefined as any;\n }\n\n const parentPath = _path.slice(0, -1);\n const key = _path[_path.length - 1];\n\n const parent = flatClone(get(object, parentPath as any));\n\n if (parent instanceof Map) {\n parent.delete(key);\n } else if (parent instanceof Set) {\n const value = Array.from(parent)[Number(key)];\n parent.delete(value);\n } else {\n delete parent[key as keyof typeof parent];\n }\n\n return set(object, parentPath as any, parent);\n}\n","import type { Path } from './path';\nimport { get } from './propAccess';\n\nexport function makeSelector<T, S>(selector?: ((value: T) => S) | Path<any>): (value: T) => S {\n if (!selector) {\n return (x) => x as any;\n }\n\n if (selector instanceof Function) {\n return selector;\n }\n\n return (x) => get(x, selector as any) as any;\n}\n","import type { Store } from '../core/store';\nimport type { OptionalPropertyOf } from './typeHelpers';\n\ntype Function_ = (...args: any) => any;\n\nfunction createArrayAction<P extends keyof Array<any>>(prop: P) {\n return function arrayAction<T extends Array<any>>(\n this: Store<T>,\n ...args: T[P] extends Function_ ? Parameters<T[P]> : never\n ): T[P] extends Function_ ? ReturnType<T[P]> : never {\n const newArray = this.get().slice() as T;\n const result = (newArray[prop] as Function_)(...(args as any));\n this.set(newArray);\n return result;\n };\n}\nexport const arrayMethods = {\n splice: /* @__PURE__ */ createArrayAction('splice'),\n push: /* @__PURE__ */ createArrayAction('push'),\n pop: /* @__PURE__ */ createArrayAction('pop'),\n shift: /* @__PURE__ */ createArrayAction('shift'),\n unshift: /* @__PURE__ */ createArrayAction('unshift'),\n reverse: /* @__PURE__ */ createArrayAction('reverse'),\n sort: /* @__PURE__ */ createArrayAction('sort'),\n};\n\nexport const recordMethods = {\n delete<T extends Record<any, any>, K extends OptionalPropertyOf<T>>(this: Store<T>, key: K) {\n const copy = { ...this.get() };\n delete copy[key];\n this.set(copy);\n },\n\n clear<T extends Record<any, any>>(this: Store<Partial<T>>) {\n this.set({} as T);\n },\n};\n\nexport const mapMethods = {\n delete<K, V>(this: Store<Map<K, V>>, key: K) {\n const newMap = new Map(this.get());\n const result = newMap.delete(key);\n this.set(newMap);\n return result;\n },\n\n clear<K, V>(this: Store<Map<K, V>>) {\n this.set(new Map());\n },\n};\n\nexport const setMethods = {\n add<T>(this: Store<Set<T>>, value: T) {\n const newSet = new Set(this.get());\n newSet.add(value);\n this.set(newSet);\n },\n\n delete<T>(this: Store<Set<T>>, value: T) {\n const newSet = new Set(this.get());\n newSet.delete(value);\n this.set(newSet);\n },\n\n clear<T>(this: Store<Set<T>>) {\n this.set(new Set());\n },\n};\n","import { calcDuration } from './calcDuration';\nimport type { Duration } from '@core';\n\nexport function throttle<Args extends any[]>(\n action: (...args: Args) => void,\n duration: Duration,\n): (...args: Args) => void {\n const ms = calcDuration(duration);\n\n let t = 0;\n let timeout: ReturnType<typeof setTimeout> | undefined;\n\n return (...args: Args) => {\n if (timeout !== undefined) {\n clearTimeout(timeout);\n }\n\n const dt = t + ms - Date.now();\n if (dt <= 0) {\n action(...args);\n t = Date.now();\n return;\n }\n\n timeout = setTimeout(() => {\n action(...args);\n t = Date.now();\n }, dt);\n };\n}\n","import type {\n CalculationHelpers,\n Cancel,\n Duration,\n Effect,\n Listener,\n Selector,\n SubscribeOptions,\n Update,\n Use,\n UseOptions,\n} from './commonTypes';\nimport { calcDuration } from '@lib/calcDuration';\nimport { CalculationHelper } from '@lib/calculationHelper';\nimport { Callable } from '@lib/callable';\nimport { debounce } from '@lib/debounce';\nimport { deepEqual } from '@lib/equals';\nimport { forwardError } from '@lib/forwardError';\nimport { makeSelector } from '@lib/makeSelector';\nimport type { Path, Value } from '@lib/path';\nimport { get, set } from '@lib/propAccess';\nimport { arrayMethods, mapMethods, recordMethods, setMethods } from '@lib/standardMethods';\nimport { throttle } from '@lib/throttle';\n\nexport type StoreMethods = Record<string, (...args: any[]) => any>;\n\nexport type BoundStoreMethods<T, Methods extends StoreMethods> = Methods &\n ThisType<Store<T> & Methods>;\n\nexport interface StoreOptions {\n retain?: Duration;\n}\n\nexport interface StoreOptionsWithMethods<T, Methods extends StoreMethods> extends StoreOptions {\n methods?: Methods & ThisType<Store<T> & Methods & StandardMethods<T>>;\n}\n\nexport type Calculate<T> = (this: CalculationHelpers<T>, helpers: CalculationHelpers<T>) => T;\n\ntype StandardMethods<T> = T extends Map<any, any>\n ? typeof mapMethods\n : T extends Set<any>\n ? typeof setMethods\n : T extends Array<any>\n ? typeof arrayMethods\n : T extends Record<any, any>\n ? typeof recordMethods\n : Record<string, never>;\n\ntype StoreWithMethods<T, Methods extends StoreMethods> = Store<T> &\n Omit<BoundStoreMethods<T, Methods>, keyof Store<T>> &\n StandardMethods<T>;\n\nfunction noop() {\n return undefined;\n}\n\nexport class Store<T> extends Callable<any, any> {\n protected _value?: { v: T };\n\n protected listeners = new Map<Listener, boolean>();\n\n protected effects = new Map<\n Effect,\n { handle?: Cancel; retain?: number; timeout?: ReturnType<typeof setTimeout> }\n >();\n\n protected notifyId = {};\n\n protected calculationHelper = new CalculationHelper<T>({\n calculate: (helpers) => {\n if (this.getter instanceof Function) {\n const value = this.getter.apply(helpers, [helpers]);\n this._value = { v: value };\n this.notify();\n }\n },\n addEffect: (effect) => this.addEffect(effect, this.options.retain),\n getValue: () => this._value?.v,\n onInvalidate: () => this.reset(),\n });\n\n constructor(\n public readonly getter: T | Calculate<T>,\n public readonly options: StoreOptions = {},\n public readonly derivedFrom?: {\n store: Store<any>;\n selectors: (Selector<any, any> | Path<any>)[];\n updater: (state: any) => void;\n },\n protected readonly _call: (...args: any[]) => any = () => undefined,\n ) {\n super(_call);\n this.get = this.get.bind(this);\n this.set = this.set.bind(this);\n this.subscribe = this.subscribe.bind(this);\n this.once = this.once.bind(this);\n this.map = this.map.bind(this);\n this.addEffect = this.addEffect.bind(this);\n this.isActive = this.isActive.bind(this);\n\n if (!(getter instanceof Function)) {\n this._value = { v: getter };\n }\n }\n\n get(): T {\n this.calculationHelper.check();\n\n if (!this._value) {\n this.calculationHelper.execute();\n return this.get();\n }\n\n return this._value.v;\n }\n\n set(update: Update<T>): void;\n\n set<P extends Path<T>>(path: P, update: Update<Value<T, P>>): void;\n\n set(...args: any[]): void {\n const path: any = args.length > 1 ? args[0] : [];\n let update: Update<any> = args.length > 1 ? args[1] : args[0];\n\n if (update instanceof Function) {\n const before = this.get();\n const valueBefore = get(before, path);\n const valueAfter = update(valueBefore);\n update = set(before, path, valueAfter);\n } else if (path.length > 0) {\n update = set(this.get(), path, update);\n }\n\n if (this.derivedFrom) {\n this.derivedFrom.updater(update);\n return;\n }\n\n this._value = { v: update };\n this.notify();\n }\n\n protected reset() {\n this._value = undefined;\n\n if (this.isActive()) {\n this.calculationHelper.execute();\n }\n }\n\n subscribe(listener: Listener<T>, options?: SubscribeOptions): Cancel {\n const {\n passive,\n runNow = true,\n throttle: throttleOption,\n debounce: debounceOption,\n equals = deepEqual,\n } = options ?? {};\n\n let compareToValue = this._value?.v;\n let previousValue: T | undefined;\n let hasRun = false;\n\n let innerListener = (force?: boolean | void) => {\n if (!this._value) {\n return;\n }\n\n const value = this._value.v;\n\n if (!force && equals(value, compareToValue)) {\n return;\n }\n\n compareToValue = value;\n const _previousValue = previousValue;\n previousValue = value;\n hasRun = true;\n\n try {\n listener(value, _previousValue);\n } catch (error) {\n forwardError(error);\n }\n };\n\n if (throttleOption) {\n innerListener = throttle(innerListener, throttleOption);\n } else if (debounceOption) {\n innerListener = debounce(innerListener, debounceOption);\n }\n\n this.listeners.set(innerListener, !passive);\n if (!passive) {\n this.onSubscribe();\n }\n\n if (runNow && !hasRun) {\n innerListener(true);\n }\n\n return () => {\n this.listeners.delete(innerListener);\n if (!passive) {\n this.onUnsubscribe();\n }\n };\n }\n\n once<S extends T>(condition: (value: T) => value is S): Promise<S>;\n\n once(condition?: (value: T) => boolean): Promise<T>;\n\n once(condition: (value: T) => boolean = (value) => !!value): Promise<any> {\n return new Promise<T>((resolve) => {\n let stopped = false;\n const cancel = this.subscribe(\n (value) => {\n if (stopped || (condition && !condition(value))) {\n return;\n }\n\n resolve(value);\n stopped = true;\n setTimeout(() => cancel());\n },\n {\n runNow: !!condition,\n },\n );\n });\n }\n\n map<S>(\n selector: Selector<T, S>,\n updater?: (value: S) => Update<T>,\n options?: UseOptions,\n ): Store<S>;\n\n map<P extends Path<T>>(selector: P, options?: UseOptions): Store<Value<T, P>>;\n\n map(_selector: Selector<T, any> | Path<any>, ...args: any[]): Store<any> {\n const updater: ((value: any) => Update<T>) | undefined =\n _selector instanceof Function\n ? args[0]\n : (value) => (state) => set(state, _selector as Path<T>, value);\n\n const options = _selector instanceof Function ? args[1] : args[0];\n\n const selector = makeSelector(_selector);\n\n const derivedFrom = {\n store: this.derivedFrom ? this.derivedFrom.store : this,\n selectors: this.derivedFrom ? [...this.derivedFrom.selectors, _selector] : [_selector],\n\n updater: (value: any) => {\n if (!updater) {\n throw new TypeError(\n 'Can only updated computed stores that either are derived from other stores using string selectors or have an updater function.',\n );\n }\n\n let update = updater(value);\n\n if (update instanceof Function) {\n update = update(this.get());\n }\n\n if (this.derivedFrom) {\n this.derivedFrom.updater(update);\n } else {\n this.set(update);\n }\n },\n };\n\n return new Store(\n ({ use }) => {\n return selector(use(this, options));\n },\n this.options,\n derivedFrom,\n );\n }\n\n /** Add an effect that will be executed when the store becomes active, which means when it has at least one subscriber.\n * @param effect\n * If there is already a subscriber, the effect will be executed immediately.\n * Otherweise it will be executed as soon as the first subscription is created.\n * Every time all subscriptions are removed and the first is created again, the effect will be executed again.\n * @param retain\n * If provided, delay tearing down effects when the last subscriber is removed. This is useful if a short gap in subscriber coverage is supposed to be ignored. E.g. when switching pages, the old page might unsubscribe, while the new page subscribes immediately after.\n * @returns\n * The effect can return a teardown callback, which will be executed when the last subscription is removed and potentially the ratain time has passed.\n */\n addEffect(effect: Effect, retain?: Duration) {\n this.effects.set(effect, {\n handle: this.isActive() ? effect() ?? noop : undefined,\n retain: retain !== undefined ? calcDuration(retain) : undefined,\n });\n\n return () => {\n const { handle, timeout } = this.effects.get(effect) ?? {};\n handle?.();\n\n if (timeout !== undefined) {\n clearTimeout(timeout);\n }\n\n this.effects.delete(effect);\n };\n }\n\n /** Return whether the store is currently active, which means whether it has at least one subscriber. */\n isActive() {\n return [...this.listeners.values()].some(Boolean);\n }\n\n protected onSubscribe() {\n if ([...this.listeners.values()].filter(Boolean).length > 1) return;\n\n for (const [effect, { handle, retain, timeout }] of this.effects.entries()) {\n if (timeout !== undefined) {\n clearTimeout(timeout);\n }\n\n this.effects.set(effect, {\n handle: handle ?? effect() ?? noop,\n retain,\n timeout: undefined,\n });\n }\n }\n\n protected onUnsubscribe() {\n if ([...this.listeners.values()].some(Boolean)) return;\n\n for (const [effect, { handle, retain, timeout }] of this.effects.entries()) {\n if (!retain) {\n handle?.();\n }\n\n if (timeout !== undefined) {\n clearTimeout(timeout);\n }\n\n this.effects.set(effect, {\n handle: retain ? handle : undefined,\n retain,\n timeout: retain && handle ? setTimeout(handle, retain) : undefined,\n });\n }\n }\n\n protected notify() {\n const n = {};\n this.notifyId = n;\n\n const snapshot = [...this.listeners.keys()];\n for (const listener of snapshot) {\n listener();\n if (n !== this.notifyId) break;\n }\n }\n}\n\nconst defaultOptions: StoreOptions = {};\n\nfunction create<T>(\n calculate: (this: { use: Use }, fns: { use: Use }) => T,\n options?: StoreOptions,\n): Store<T>;\nfunction create<T, Methods extends StoreMethods = {}>(\n initialState: T,\n options?: StoreOptionsWithMethods<T, Methods>,\n): StoreWithMethods<T, Methods>;\nfunction create<T, Methods extends StoreMethods>(\n initialState: T | ((this: { use: Use }, fns: { use: Use }) => T),\n options?: StoreOptionsWithMethods<T, Methods>,\n): StoreWithMethods<T, Methods> | Store<T> {\n const store = new Store(initialState, options);\n\n if (initialState instanceof Function) {\n return store;\n }\n\n let methods: StoreMethods | undefined = options?.methods;\n\n if (initialState instanceof Map) {\n methods = { ...mapMethods, ...methods };\n } else if (initialState instanceof Set) {\n methods = { ...setMethods, ...methods };\n } else if (Array.isArray(initialState)) {\n methods = { ...arrayMethods, ...methods };\n } else if (initialState instanceof Object) {\n methods = { ...recordMethods, ...methods };\n }\n\n const boundMethods = Object.fromEntries(\n Object.entries(methods ?? ({} as BoundStoreMethods<T, any>))\n .filter(([name]) => !(name in store))\n .map(([name, action]) => [name, (action as any).bind(store)]),\n ) as BoundStoreMethods<T, any>;\n\n return Object.assign(store, boundMethods);\n}\n\nexport const createStore = /* @__PURE__ */ Object.assign(create, { defaultOptions });\n"],"names":["equals"],"mappings":"AAEO,SAAS,aAAa,GAAa;AACxC,MAAI,OAAO,MAAM;AAAiB,WAAA;AAE/B,UAAA,EAAE,gBAAgB,MAClB,EAAE,WAAW,KAAK,OAClB,EAAE,WAAW,KAAK,KAAK,OACvB,EAAE,SAAS,KAAK,KAAK,KAAK,OAC1B,EAAE,QAAQ,KAAK,KAAK,KAAK,KAAK;AAEnC;ACEO,SAAS,QAAe;AAC7B,QAAM,IAKA,CAAA;AACA,QAAA,0CAA0B;AAChC,MAAI,SAAS;AAEb,QAAM,SAAS,MAAM;AACnB,eAAW,YAAY,qBAAqB;AACjC;IACX;AAEA,wBAAoB,MAAM;AAAA,EAAA;AAG5B,QAAM,MAAM,YAAY;AACtB,QAAI,CAAC,QAAQ;AACF,eAAA;AAEL,UAAA;AACI,aAAA,OAAO,EAAE,SAAU;AACrB,YAAA;AACE,cAAA,SAAS,KAAK;AAClB,cAAI,kBAAkB,SAAS;AAC7B,qBAAS,MAAM;AAAA,UACjB;AAEA,eAAK,QAAQ,MAAM;AAAA,iBACZ;AACP,eAAK,OAAO,KAAK;AAAA,QACnB;AAAA,MACF;AAES,eAAA;AACF;IACT;AAAA,EAAA;AAGF,SAAO,OAAO;AAAA,IACZ,CAAI,QAAmB,QAAc;AACnC,aAAO,IAAI,QAAW,CAAC,SAAS,WAAW;AACzC,UAAE,KAAK,EAAE,QAAQ,SAAS,QAAQ,KAA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A;AAAA,EACT;AAEA,MAAI,UAAoC,mCAAS;AAEjD,MAAI,wBAAwB,KAAK;AAC/B,cAAU,EAAE,GAAG,YAAY,GAAG,QAAQ;AAAA,EAAA,WAC7B,wBAAwB,KAAK;AACtC,cAAU,EAAE,GAAG,YAAY,GAAG,QAAQ;AAAA,EAC7B,WAAA,MAAM,QAAQ,YAAY,GAAG;AACtC,cAAU,EAAE,GAAG,cAAc,GAAG,QAAQ;AAAA,EAAA,WAC/B,wBAAwB,QAAQ;AACzC,cAAU,EAAE,GAAG,eAAe,GAAG,QAAQ;AAAA,EAC3C;AAEA,QAAM,eAAe,OAAO;AAAA,IAC1B,OAAO,QAAQ,WAAY,EAAgC,EACxD,OAAO,CAAC,CAAC,IAAI,MAAM,EAAE,QAAQ,MAAM,EACnC,IAAI,CAAC,CAAC,MAAM,MAAM,MAAM,CAAC,MAAO,OAAe,KAAK,KAAK,CAAC,CAAC;AAAA,EAAA;AAGzD,SAAA,OAAO,OAAO,OAAO,YAAY;AAC1C;AAEO,MAAM,cAAqC,uBAAA,OAAO,QAAQ,EAAE,eAAgB,CAAA;"}
1
+ {"version":3,"file":"store.mjs","sources":["../../src/lib/calcDuration.ts","../../src/lib/queue.ts","../../src/lib/equals.ts","../../src/lib/trackingProxy.ts","../../src/lib/calculationHelper.ts","../../src/lib/callable.ts","../../src/lib/debounce.ts","../../src/lib/forwardError.ts","../../src/lib/clone.ts","../../src/lib/propAccess.ts","../../src/lib/makeSelector.ts","../../src/lib/standardMethods.ts","../../src/lib/throttle.ts","../../src/core/store.ts"],"sourcesContent":["import type { Duration } from '../core/commonTypes';\n\nexport function calcDuration(t: Duration) {\n if (typeof t === 'number') return t;\n return (\n (t.milliseconds ?? 0) +\n (t.seconds ?? 0) * 1000 +\n (t.minutes ?? 0) * 60 * 1000 +\n (t.hours ?? 0) * 60 * 60 * 1000 +\n (t.days ?? 0) * 24 * 60 * 60 * 1000\n );\n}\n","import type { MaybePromise } from './maybePromise';\nimport type { Listener } from '@core';\n\ntype Action<T> = () => MaybePromise<T>;\n\nexport interface Queue {\n <T>(action: Action<T>, ref?: any): Promise<T>;\n clear: () => void;\n whenDone: () => Promise<void>;\n size: number;\n getRefs: () => any[];\n}\n\nexport function queue(): Queue {\n const q: {\n action: Action<any>;\n resolve: (value: any) => void;\n reject: (error: unknown) => void;\n ref?: any;\n }[] = [];\n const completionListeners = new Set<Listener<void>>();\n let active = false;\n\n const notify = () => {\n for (const listener of completionListeners) {\n listener();\n }\n\n completionListeners.clear();\n };\n\n const run = async () => {\n if (!active) {\n active = true;\n\n let next;\n while ((next = q.shift())) {\n try {\n let result = next.action();\n if (result instanceof Promise) {\n result = await result;\n }\n\n next.resolve(result);\n } catch (error) {\n next.reject(error);\n }\n }\n\n active = false;\n notify();\n }\n };\n\n return Object.assign(\n <T>(action: Action<T>, ref?: any) => {\n return new Promise<T>((resolve, reject) => {\n q.push({ action, resolve, reject, ref });\n run();\n });\n },\n {\n clear() {\n q.length = 0;\n },\n\n whenDone() {\n if (!active) {\n return Promise.resolve();\n }\n\n return new Promise<void>((resolve) => {\n completionListeners.add(resolve);\n });\n },\n\n get size() {\n return q.length;\n },\n\n getRefs() {\n return q.map((item) => item.ref).filter((x) => x !== undefined);\n },\n },\n );\n}\n","export function defaultEqual(a: any, b: any) {\n return a === b;\n}\n\nexport function shallowEqual(a: any, b: any): boolean {\n return internalEqual(defaultEqual)(a, b);\n}\n\nexport function deepEqual(a: any, b: any): boolean {\n return internalEqual(deepEqual)(a, b);\n}\n\nconst internalEqual = (comp: (a: any, b: any) => boolean) => (a: any, b: any) => {\n if (a === b) {\n return true;\n }\n\n if (a === null || b === null || typeof a !== 'object' || typeof b !== 'object') {\n // eslint-disable-next-line no-self-compare\n return a !== a && b !== b;\n }\n\n if (a.constructor !== b.constructor) {\n return false;\n }\n\n if (a.constructor === Object) {\n const entries1 = Object.entries(a);\n const entries2 = Object.entries(b);\n return (\n entries1.length === entries2.length && entries1.every(([key, value]) => comp(value, b[key]))\n );\n }\n\n if (Array.isArray(a)) {\n return a.length === b.length && a.every((value, i) => comp(value, b[i]));\n }\n\n if (a instanceof Date) {\n return a.getTime() === b.getTime();\n }\n\n if (a instanceof RegExp) {\n return a.source === b.source && a.flags === b.flags;\n }\n\n if (a instanceof Map) {\n return a.size === b.size && [...a.entries()].every(([key, value]) => comp(value, b.get(key)));\n }\n\n if (a instanceof Set) {\n return a.size === b.size && [...a.values()].every((value) => b.has(value));\n }\n\n if (typeof ArrayBuffer !== 'undefined' && ArrayBuffer.isView(a)) {\n if (a.byteLength !== b.byteLength) {\n return false;\n }\n\n const a_ = new Int8Array(a.buffer);\n const b_ = new Int8Array(b.buffer);\n return a_.every((value, i) => value === b_[i]);\n }\n\n return false;\n};\n","import { deepEqual } from './equals';\n\nconst unwrapProxySymbol = /* @__PURE__ */ Symbol('unwrapProxy');\n\nexport type TrackingProxy<T> = [value: T, equals: (newValue: T) => boolean, revoke?: () => void];\ntype Object_ = Record<string | symbol, unknown>;\n\nfunction isPlainObject(value: unknown) {\n return (\n typeof value === 'object' && value !== null && Object.getPrototypeOf(value) === Object.prototype\n );\n}\n\nexport function trackingProxy<T>(value: T, equals = deepEqual): TrackingProxy<T> {\n if (!isPlainObject(value) && !Array.isArray(value)) {\n return [value, (other) => equals(value, other)];\n }\n\n // Unpack proxies, we don't want to nest them\n value = (value as any)[unwrapProxySymbol] ?? value;\n\n const deps = new Array<TrackingProxy<any>[1]>();\n const revokations = new Array<() => void>();\n let revoked = false;\n\n function trackComplexProp(function_: any, ...args: any[]) {\n const [proxiedValue, equals, revoke] = trackingProxy(function_(value, ...args));\n\n deps.push((otherValue) => {\n if (!isPlainObject(otherValue) && !Array.isArray(otherValue)) {\n return false;\n }\n\n return equals(function_(otherValue, ...args));\n });\n\n if (revoke) {\n revokations.push(revoke);\n }\n\n return proxiedValue;\n }\n\n function trackSimpleProp(function_: any, ...args: any[]) {\n const calculatedValue = function_(value, ...args);\n\n deps.push((otherValue) => {\n return function_(otherValue, ...args) === calculatedValue;\n });\n\n return calculatedValue;\n }\n\n const proxy = new Proxy(value as T & Object_, {\n get(target, p, receiver) {\n if (p === unwrapProxySymbol) {\n return value;\n }\n\n if (revoked) {\n return target[p];\n }\n\n const { writable, configurable } = Object.getOwnPropertyDescriptor(target, p) ?? {};\n if (writable === false && configurable === false) {\n return target[p];\n }\n\n return trackComplexProp(Reflect.get, p, receiver);\n },\n\n getOwnPropertyDescriptor(target, p) {\n const { writable, configurable } = Object.getOwnPropertyDescriptor(target, p) ?? {};\n if (writable === false && configurable === false) {\n return Reflect.getOwnPropertyDescriptor(target, p);\n }\n\n return trackComplexProp(Reflect.getOwnPropertyDescriptor, p);\n },\n\n ownKeys() {\n return trackComplexProp(Reflect.ownKeys);\n },\n\n getPrototypeOf() {\n return trackSimpleProp(Reflect.getPrototypeOf);\n },\n\n has(_target, p) {\n return trackSimpleProp(Reflect.has, p);\n },\n\n isExtensible() {\n return trackSimpleProp(Reflect.isExtensible);\n },\n });\n\n return [\n proxy,\n (other) => !!other && deps.every((equals) => equals(other)),\n () => {\n revoked = true;\n revokations.forEach((revoke) => revoke());\n },\n ];\n}\n","import type { MaybePromise } from './maybePromise';\nimport { queue } from './queue';\nimport { trackingProxy } from './trackingProxy';\nimport { deepEqual } from './equals';\nimport type { Store } from '@core/store';\nimport type {\n CalculationHelpers,\n Cancel,\n ConnectionState,\n UpdateFrom,\n Use,\n} from '@core/commonTypes';\n\nexport class CalculationHelper<T> {\n private current?: {\n cancel: Cancel;\n check: () => void;\n invalidateDependencies: () => void;\n };\n\n constructor(\n public options: {\n calculate: (helpers: CalculationHelpers<T>) => Cancel | void;\n addEffect: (effect: () => Cancel | void) => Cancel;\n getValue?: () => T | undefined;\n onValue?: (value: T) => void;\n onError?: (error: unknown) => void;\n onConnectionState?: (state: ConnectionState) => void;\n onInvalidate?: () => void;\n },\n ) {\n options.addEffect(() => {\n if (this.current) {\n this.current.check();\n } else {\n this.execute();\n }\n });\n }\n\n execute() {\n this.stop();\n\n const { calculate, addEffect, getValue, onValue, onError, onConnectionState, onInvalidate } =\n this.options;\n const checks = new Array<() => boolean>();\n const deps = new Map<Store<any>, { on: () => void; off: () => void; invalidate: () => void }>();\n const q = queue();\n let isActive = false;\n let isCancled = false;\n\n const cancelEffect = addEffect(() => {\n isActive = true;\n\n for (const dep of deps.values()) {\n dep.on();\n }\n\n return () => {\n isActive = false;\n\n for (const dep of deps.values()) {\n dep.off();\n }\n\n if (cancelSubscription) {\n cancelSubscription();\n cancelSubscription = undefined;\n cancel();\n onInvalidate?.();\n }\n };\n });\n\n const cancel = () => {\n isCancled = true;\n cancelSubscription?.();\n cancelEffect();\n delete this.current;\n };\n\n const checkAll = () => {\n if (!checks.every((check) => check())) {\n cancel();\n onInvalidate?.();\n }\n };\n\n const invalidateDependencies = () => {\n for (const dep of deps.values()) {\n dep.invalidate();\n }\n };\n\n const use: Use = (store, { disableProxy } = {}) => {\n if (isCancled) {\n return store.get();\n }\n\n let value = store.get();\n let equals = (newValue: any) => {\n return deepEqual(newValue, value);\n };\n\n if (!disableProxy) {\n [value, equals] = trackingProxy(value);\n }\n\n const check = () => equals(store.get());\n let sub: Cancel | undefined;\n\n const dep = {\n on() {\n this.off();\n\n sub = store.subscribe(\n () => {\n if (sub && !check()) {\n cancel();\n onInvalidate?.();\n }\n },\n { runNow: false },\n );\n },\n off() {\n sub?.();\n sub = undefined;\n },\n invalidate() {\n if ('invalidate' in store && store.invalidate instanceof Function) {\n store.invalidate();\n }\n },\n };\n\n if (isActive) {\n dep.on();\n }\n\n checks.push(check);\n deps.set(store, dep);\n\n return value;\n };\n\n const updateValue = (update: UpdateFrom<MaybePromise<T>, [T | undefined]>) =>\n q(async () => {\n if (isCancled) {\n return;\n }\n\n if (update instanceof Function) {\n try {\n update = update(getValue?.());\n } catch (error) {\n onError?.(error);\n return;\n }\n }\n\n if (update instanceof Promise) {\n try {\n update = await update;\n } catch (error) {\n if (!isCancled) {\n onError?.(error);\n }\n return;\n }\n }\n\n if (!isCancled) {\n onValue?.(update);\n }\n });\n\n const updateError = (error: unknown) =>\n q(() => {\n if (!isCancled) {\n onError?.(error);\n }\n });\n\n const updateConnectionState = (state: ConnectionState) =>\n q(() => {\n if (!isCancled) {\n onConnectionState?.(state);\n }\n });\n\n let cancelSubscription: Cancel | void;\n try {\n cancelSubscription = calculate({ use, updateValue, updateError, updateConnectionState });\n } catch (error) {\n onError?.(error);\n }\n\n this.current = { cancel, check: checkAll, invalidateDependencies };\n }\n\n stop() {\n this.current?.cancel();\n }\n\n check() {\n this.current?.check();\n }\n\n checkOrExecute() {\n if (this.current) {\n this.check();\n } else {\n this.execute();\n }\n }\n\n invalidateDependencies() {\n this.current?.invalidateDependencies();\n }\n}\n","export class Callable<Args extends any[], T> extends Function {\n constructor(protected _call: (...args: Args) => T) {\n super('...args', 'return this._call(...args)');\n\n // eslint-disable-next-line no-constructor-return\n return this.bind(this);\n }\n}\n","import { calcDuration } from './calcDuration';\nimport type { Duration } from '@core';\n\nexport type DebounceOptions =\n | Duration\n | {\n wait: Duration;\n maxWait?: Duration;\n };\n\nexport function debounce<Args extends any[]>(\n action: (...args: Args) => void,\n options: Duration | DebounceOptions,\n): (...args: Args) => void {\n const wait =\n typeof options === 'object' && 'wait' in options\n ? calcDuration(options.wait)\n : calcDuration(options);\n\n const maxWait =\n typeof options === 'object' && 'maxWait' in options && options.maxWait !== undefined\n ? calcDuration(options.maxWait)\n : undefined;\n\n let timeout: ReturnType<typeof setTimeout> | undefined;\n let timeoutStarted: number | undefined;\n\n return (...args: Args) => {\n const now = Date.now();\n timeoutStarted ??= now;\n\n const deadline = Math.min(\n //\n now + wait,\n timeoutStarted + (maxWait ?? Number.POSITIVE_INFINITY),\n );\n\n if (timeout !== undefined) {\n clearTimeout(timeout);\n }\n\n timeout = setTimeout(() => {\n timeout = undefined;\n timeoutStarted = undefined;\n action(...args);\n }, deadline - now);\n };\n}\n","export function forwardError(error: unknown) {\n setTimeout(() => {\n throw error;\n });\n}\n","export function flatClone<T>(object: T): T {\n if (object instanceof Map) {\n return new Map(object) as any;\n }\n\n if (object instanceof Set) {\n return new Set(object) as any;\n }\n\n if (Array.isArray(object)) {\n return [...object] as any;\n }\n\n if (object instanceof Object) {\n return { ...object };\n }\n\n return object;\n}\n","import type { Update } from '../core/commonTypes';\nimport { flatClone } from './clone';\nimport type { Path, Value } from './path';\n\nexport function castArrayPath(path: string | KeyType[]): KeyType[] {\n if (Array.isArray(path)) {\n return path as any;\n }\n\n if (path === '') {\n return [] as any;\n }\n\n return (path as string).split('.') as any;\n}\n\nexport function get<T, P extends Path<T>>(object: T, path: P): Value<T, P> {\n const _path = castArrayPath(path as any);\n const [first, ...rest] = _path;\n\n if (first === undefined || !object) {\n return object as Value<T, P>;\n }\n\n if (object instanceof Map) {\n return get(object.get(first), rest as any);\n }\n\n if (object instanceof Set) {\n return get(Array.from(object)[Number(first)], rest as any);\n }\n\n if (object instanceof Object) {\n return get(object[first as keyof T], rest as any) as Value<T, P>;\n }\n\n throw new Error(`Could not get ${path} of ${object}`);\n}\n\nexport function set<T, P extends Path<T>>(\n object: T,\n path: P,\n value: Update<Value<T, P>>,\n rootPath = path,\n): T {\n const _path = castArrayPath(path as any);\n const [first, ...rest] = _path;\n\n if (first === undefined) {\n return value as any;\n }\n\n const updateChild = (child: any) => {\n if (!child && rest.length > 0) {\n const _rootPath = castArrayPath(rootPath as any);\n\n const prefix = _rootPath.slice(0, -rest.length) as KeyType[];\n throw new Error(`Cannot set ${rootPath} because ${prefix.join('.')} is ${child}`);\n }\n\n return set(child, rest as any, value, rootPath);\n };\n\n if (object instanceof Map) {\n const copy = flatClone(object);\n const child = copy.get(first);\n copy.set(first, updateChild(child));\n return copy;\n }\n\n if (object instanceof Set) {\n const copy = [...object];\n const child = copy[Number(first)];\n copy[Number(first)] = updateChild(child);\n return new Set(copy) as any;\n }\n\n if (object instanceof Object || object === undefined) {\n const copy = flatClone(object ?? ({} as T));\n copy[first as keyof T] = updateChild(copy[first as keyof T]);\n return copy;\n }\n\n throw new Error(`Could not set ${path} of ${object}`);\n}\n\nexport function remove<T, P extends Path<T, true>>(object: T, path: P): T {\n const _path = castArrayPath(path as any);\n\n if (_path.length === 0) {\n return undefined as any;\n }\n\n const parentPath = _path.slice(0, -1);\n const key = _path[_path.length - 1];\n\n const parent = flatClone(get(object, parentPath as any));\n\n if (parent instanceof Map) {\n parent.delete(key);\n } else if (parent instanceof Set) {\n const value = Array.from(parent)[Number(key)];\n parent.delete(value);\n } else {\n delete parent[key as keyof typeof parent];\n }\n\n return set(object, parentPath as any, parent);\n}\n","import type { Path } from './path';\nimport { get } from './propAccess';\n\nexport function makeSelector<T, S>(selector?: ((value: T) => S) | Path<any>): (value: T) => S {\n if (!selector) {\n return (x) => x as any;\n }\n\n if (selector instanceof Function) {\n return selector;\n }\n\n return (x) => get(x, selector as any) as any;\n}\n","import type { Store } from '../core/store';\nimport type { OptionalPropertyOf } from './typeHelpers';\n\ntype Function_ = (...args: any) => any;\n\nfunction createArrayAction<P extends keyof Array<any>>(prop: P) {\n return function arrayAction<T extends Array<any>>(\n this: Store<T>,\n ...args: T[P] extends Function_ ? Parameters<T[P]> : never\n ): T[P] extends Function_ ? ReturnType<T[P]> : never {\n const newArray = this.get().slice() as T;\n const result = (newArray[prop] as Function_)(...(args as any));\n this.set(newArray);\n return result;\n };\n}\nexport const arrayMethods = {\n splice: /* @__PURE__ */ createArrayAction('splice'),\n push: /* @__PURE__ */ createArrayAction('push'),\n pop: /* @__PURE__ */ createArrayAction('pop'),\n shift: /* @__PURE__ */ createArrayAction('shift'),\n unshift: /* @__PURE__ */ createArrayAction('unshift'),\n reverse: /* @__PURE__ */ createArrayAction('reverse'),\n sort: /* @__PURE__ */ createArrayAction('sort'),\n};\n\nexport const recordMethods = {\n delete<T extends Record<any, any>, K extends OptionalPropertyOf<T>>(this: Store<T>, key: K) {\n const copy = { ...this.get() };\n delete copy[key];\n this.set(copy);\n },\n\n clear<T extends Record<any, any>>(this: Store<Partial<T>>) {\n this.set({} as T);\n },\n};\n\nexport const mapMethods = {\n delete<K, V>(this: Store<Map<K, V>>, key: K) {\n const newMap = new Map(this.get());\n const result = newMap.delete(key);\n this.set(newMap);\n return result;\n },\n\n clear<K, V>(this: Store<Map<K, V>>) {\n this.set(new Map());\n },\n};\n\nexport const setMethods = {\n add<T>(this: Store<Set<T>>, value: T) {\n const newSet = new Set(this.get());\n newSet.add(value);\n this.set(newSet);\n },\n\n delete<T>(this: Store<Set<T>>, value: T) {\n const newSet = new Set(this.get());\n newSet.delete(value);\n this.set(newSet);\n },\n\n clear<T>(this: Store<Set<T>>) {\n this.set(new Set());\n },\n};\n","import { calcDuration } from './calcDuration';\nimport type { Duration } from '@core';\n\nexport function throttle<Args extends any[]>(\n action: (...args: Args) => void,\n duration: Duration,\n): (...args: Args) => void {\n const ms = calcDuration(duration);\n\n let t = 0;\n let timeout: ReturnType<typeof setTimeout> | undefined;\n\n return (...args: Args) => {\n if (timeout !== undefined) {\n clearTimeout(timeout);\n }\n\n const dt = t + ms - Date.now();\n if (dt <= 0) {\n action(...args);\n t = Date.now();\n return;\n }\n\n timeout = setTimeout(() => {\n action(...args);\n t = Date.now();\n }, dt);\n };\n}\n","import type {\n CalculationHelpers,\n Cancel,\n Duration,\n Effect,\n Listener,\n Selector,\n SubscribeOptions,\n Update,\n Use,\n UseOptions,\n} from './commonTypes';\nimport { calcDuration } from '@lib/calcDuration';\nimport { CalculationHelper } from '@lib/calculationHelper';\nimport { Callable } from '@lib/callable';\nimport { debounce } from '@lib/debounce';\nimport { deepEqual } from '@lib/equals';\nimport { forwardError } from '@lib/forwardError';\nimport { makeSelector } from '@lib/makeSelector';\nimport type { Path, Value } from '@lib/path';\nimport { get, set } from '@lib/propAccess';\nimport { arrayMethods, mapMethods, recordMethods, setMethods } from '@lib/standardMethods';\nimport { throttle } from '@lib/throttle';\n\nexport type StoreMethods = Record<string, (...args: any[]) => any>;\n\nexport type BoundStoreMethods<T, Methods extends StoreMethods> = Methods &\n ThisType<Store<T> & Methods>;\n\nexport interface StoreOptions {\n retain?: Duration;\n}\n\nexport interface StoreOptionsWithMethods<T, Methods extends StoreMethods> extends StoreOptions {\n methods?: Methods & ThisType<Store<T> & Methods & StandardMethods<T>>;\n}\n\nexport type Calculate<T> = (this: CalculationHelpers<T>, helpers: CalculationHelpers<T>) => T;\n\ntype StandardMethods<T> = T extends Map<any, any>\n ? typeof mapMethods\n : T extends Set<any>\n ? typeof setMethods\n : T extends Array<any>\n ? typeof arrayMethods\n : T extends Record<any, any>\n ? typeof recordMethods\n : Record<string, never>;\n\ntype StoreWithMethods<T, Methods extends StoreMethods> = Store<T> &\n Omit<BoundStoreMethods<T, Methods>, keyof Store<T>> &\n StandardMethods<T>;\n\nfunction noop() {\n return undefined;\n}\n\nexport class Store<T> extends Callable<any, any> {\n protected _value?: { v: T };\n\n protected listeners = new Map<Listener, boolean>();\n\n protected effects = new Map<\n Effect,\n { handle?: Cancel; retain?: number; timeout?: ReturnType<typeof setTimeout> }\n >();\n\n protected notifyId = {};\n\n protected calculationHelper = new CalculationHelper<T>({\n calculate: (helpers) => {\n if (this.getter instanceof Function) {\n const value = this.getter.apply(helpers, [helpers]);\n this._value = { v: value };\n this.notify();\n }\n },\n addEffect: (effect) => this.addEffect(effect, this.options.retain),\n getValue: () => this._value?.v,\n onInvalidate: () => this.reset(),\n });\n\n constructor(\n public readonly getter: T | Calculate<T>,\n public readonly options: StoreOptions = {},\n public readonly derivedFrom?: {\n store: Store<any>;\n selectors: (Selector<any, any> | Path<any>)[];\n updater: (state: any) => void;\n },\n protected readonly _call: (...args: any[]) => any = () => undefined,\n ) {\n super(_call);\n this.get = this.get.bind(this);\n this.set = this.set.bind(this);\n this.subscribe = this.subscribe.bind(this);\n this.once = this.once.bind(this);\n this.map = this.map.bind(this);\n this.addEffect = this.addEffect.bind(this);\n this.isActive = this.isActive.bind(this);\n\n if (!(getter instanceof Function)) {\n this._value = { v: getter };\n }\n }\n\n get(): T {\n this.calculationHelper.check();\n\n if (!this._value) {\n this.calculationHelper.execute();\n return this.get();\n }\n\n return this._value.v;\n }\n\n set(update: Update<T>): void;\n\n set<P extends Path<T>>(path: P, update: Update<Value<T, P>>): void;\n\n set(...args: any[]): void {\n const path: any = args.length > 1 ? args[0] : [];\n let update: Update<any> = args.length > 1 ? args[1] : args[0];\n\n if (update instanceof Function) {\n const before = this.get();\n const valueBefore = get(before, path);\n const valueAfter = update(valueBefore);\n update = set(before, path, valueAfter);\n } else if (path.length > 0) {\n update = set(this.get(), path, update);\n }\n\n if (this.derivedFrom) {\n this.derivedFrom.updater(update);\n return;\n }\n\n this._value = { v: update };\n this.notify();\n }\n\n protected reset() {\n this._value = undefined;\n\n if (this.isActive()) {\n this.calculationHelper.execute();\n }\n }\n\n subscribe(listener: Listener<T>, options?: SubscribeOptions): Cancel {\n const {\n passive,\n runNow = true,\n throttle: throttleOption,\n debounce: debounceOption,\n equals = deepEqual,\n } = options ?? {};\n\n let compareToValue = this._value?.v;\n let previousValue: T | undefined;\n let hasRun = false;\n\n let innerListener = (force?: boolean | void) => {\n if (!this._value) {\n return;\n }\n\n const value = this._value.v;\n\n if (!force && equals(value, compareToValue)) {\n return;\n }\n\n compareToValue = value;\n const _previousValue = previousValue;\n previousValue = value;\n hasRun = true;\n\n try {\n listener(value, _previousValue);\n } catch (error) {\n forwardError(error);\n }\n };\n\n if (throttleOption) {\n innerListener = throttle(innerListener, throttleOption);\n } else if (debounceOption) {\n innerListener = debounce(innerListener, debounceOption);\n }\n\n this.listeners.set(innerListener, !passive);\n if (!passive) {\n this.onSubscribe();\n }\n\n if (runNow && !hasRun) {\n innerListener(true);\n }\n\n return () => {\n this.listeners.delete(innerListener);\n if (!passive) {\n this.onUnsubscribe();\n }\n };\n }\n\n once<S extends T>(condition: (value: T) => value is S): Promise<S>;\n\n once(condition?: (value: T) => boolean): Promise<T>;\n\n once(condition: (value: T) => boolean = (value) => !!value): Promise<any> {\n return new Promise<T>((resolve) => {\n let stopped = false;\n const cancel = this.subscribe(\n (value) => {\n if (stopped || (condition && !condition(value))) {\n return;\n }\n\n resolve(value);\n stopped = true;\n setTimeout(() => cancel());\n },\n {\n runNow: !!condition,\n },\n );\n });\n }\n\n map<S>(\n selector: Selector<T, S>,\n updater?: (value: S) => Update<T>,\n options?: UseOptions,\n ): Store<S>;\n\n map<P extends Path<T>>(selector: P, options?: UseOptions): Store<Value<T, P>>;\n\n map(_selector: Selector<T, any> | Path<any>, ...args: any[]): Store<any> {\n const updater: ((value: any) => Update<T>) | undefined =\n _selector instanceof Function\n ? args[0]\n : (value) => (state) => set(state, _selector as Path<T>, value);\n\n const options = _selector instanceof Function ? args[1] : args[0];\n\n const selector = makeSelector(_selector);\n\n const derivedFrom = {\n store: this.derivedFrom ? this.derivedFrom.store : this,\n selectors: this.derivedFrom ? [...this.derivedFrom.selectors, _selector] : [_selector],\n\n updater: (value: any) => {\n if (!updater) {\n throw new TypeError(\n 'Can only updated computed stores that either are derived from other stores using string selectors or have an updater function.',\n );\n }\n\n let update = updater(value);\n\n if (update instanceof Function) {\n update = update(this.get());\n }\n\n if (this.derivedFrom) {\n this.derivedFrom.updater(update);\n } else {\n this.set(update);\n }\n },\n };\n\n return new Store(\n ({ use }) => {\n return selector(use(this, options));\n },\n this.options,\n derivedFrom,\n );\n }\n\n /** Add an effect that will be executed when the store becomes active, which means when it has at least one subscriber.\n * @param effect\n * If there is already a subscriber, the effect will be executed immediately.\n * Otherweise it will be executed as soon as the first subscription is created.\n * Every time all subscriptions are removed and the first is created again, the effect will be executed again.\n * @param retain\n * If provided, delay tearing down effects when the last subscriber is removed. This is useful if a short gap in subscriber coverage is supposed to be ignored. E.g. when switching pages, the old page might unsubscribe, while the new page subscribes immediately after.\n * @returns\n * The effect can return a teardown callback, which will be executed when the last subscription is removed and potentially the ratain time has passed.\n */\n addEffect(effect: Effect, retain?: Duration) {\n this.effects.set(effect, {\n handle: this.isActive() ? effect() ?? noop : undefined,\n retain: retain !== undefined ? calcDuration(retain) : undefined,\n });\n\n return () => {\n const { handle, timeout } = this.effects.get(effect) ?? {};\n handle?.();\n\n if (timeout !== undefined) {\n clearTimeout(timeout);\n }\n\n this.effects.delete(effect);\n };\n }\n\n /** Return whether the store is currently active, which means whether it has at least one subscriber. */\n isActive() {\n return [...this.listeners.values()].some(Boolean);\n }\n\n protected onSubscribe() {\n if ([...this.listeners.values()].filter(Boolean).length > 1) return;\n\n for (const [effect, { handle, retain, timeout }] of this.effects.entries()) {\n if (timeout !== undefined) {\n clearTimeout(timeout);\n }\n\n this.effects.set(effect, {\n handle: handle ?? effect() ?? noop,\n retain,\n timeout: undefined,\n });\n }\n }\n\n protected onUnsubscribe() {\n if ([...this.listeners.values()].some(Boolean)) return;\n\n for (const [effect, { handle, retain, timeout }] of this.effects.entries()) {\n if (!retain) {\n handle?.();\n }\n\n if (timeout !== undefined) {\n clearTimeout(timeout);\n }\n\n this.effects.set(effect, {\n handle: retain ? handle : undefined,\n retain,\n timeout: retain && handle ? setTimeout(handle, retain) : undefined,\n });\n }\n }\n\n protected notify() {\n const n = {};\n this.notifyId = n;\n\n const snapshot = [...this.listeners.keys()];\n for (const listener of snapshot) {\n listener();\n if (n !== this.notifyId) break;\n }\n }\n}\n\nconst defaultOptions: StoreOptions = {};\n\nfunction create<T>(\n calculate: (this: { use: Use }, fns: { use: Use }) => T,\n options?: StoreOptions,\n): Store<T>;\nfunction create<T, Methods extends StoreMethods = {}>(\n initialState: T,\n options?: StoreOptionsWithMethods<T, Methods>,\n): StoreWithMethods<T, Methods>;\nfunction create<T, Methods extends StoreMethods>(\n initialState: T | ((this: { use: Use }, fns: { use: Use }) => T),\n options?: StoreOptionsWithMethods<T, Methods>,\n): StoreWithMethods<T, Methods> | Store<T> {\n const store = new Store(initialState, options);\n\n if (initialState instanceof Function) {\n return store;\n }\n\n let methods: StoreMethods | undefined = options?.methods;\n\n if (initialState instanceof Map) {\n methods = { ...mapMethods, ...methods };\n } else if (initialState instanceof Set) {\n methods = { ...setMethods, ...methods };\n } else if (Array.isArray(initialState)) {\n methods = { ...arrayMethods, ...methods };\n } else if (initialState instanceof Object) {\n methods = { ...recordMethods, ...methods };\n }\n\n const boundMethods = Object.fromEntries(\n Object.entries(methods ?? ({} as BoundStoreMethods<T, any>))\n .filter(([name]) => !(name in store))\n .map(([name, action]) => [name, (action as any).bind(store)]),\n ) as BoundStoreMethods<T, any>;\n\n return Object.assign(store, boundMethods);\n}\n\nexport const createStore = /* @__PURE__ */ Object.assign(create, { defaultOptions });\n"],"names":["equals"],"mappings":"AAEO,SAAS,aAAa,GAAa;AACxC,MAAI,OAAO,MAAM;AAAiB,WAAA;AAE/B,UAAA,EAAE,gBAAgB,MAClB,EAAE,WAAW,KAAK,OAClB,EAAE,WAAW,KAAK,KAAK,OACvB,EAAE,SAAS,KAAK,KAAK,KAAK,OAC1B,EAAE,QAAQ,KAAK,KAAK,KAAK,KAAK;AAEnC;ACEO,SAAS,QAAe;AAC7B,QAAM,IAKA,CAAA;AACA,QAAA,0CAA0B;AAChC,MAAI,SAAS;AAEb,QAAM,SAAS,MAAM;AACnB,eAAW,YAAY,qBAAqB;AACjC;IACX;AAEA,wBAAoB,MAAM;AAAA,EAAA;AAG5B,QAAM,MAAM,YAAY;AACtB,QAAI,CAAC,QAAQ;AACF,eAAA;AAEL,UAAA;AACI,aAAA,OAAO,EAAE,SAAU;AACrB,YAAA;AACE,cAAA,SAAS,KAAK;AAClB,cAAI,kBAAkB,SAAS;AAC7B,qBAAS,MAAM;AAAA,UACjB;AAEA,eAAK,QAAQ,MAAM;AAAA,iBACZ;AACP,eAAK,OAAO,KAAK;AAAA,QACnB;AAAA,MACF;AAES,eAAA;AACF;IACT;AAAA,EAAA;AAGF,SAAO,OAAO;AAAA,IACZ,CAAI,QAAmB,QAAc;AACnC,aAAO,IAAI,QAAW,CAAC,SAAS,WAAW;AACzC,UAAE,KAAK,EAAE,QAAQ,SAAS,QAAQ,KAAK;AACnC;MAAA,CACL;AAAA,IACH;AAAA,IACA;AAAA,MACE,QAA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B,UAAM,IAAI,CAAA;AACV,SAAK,WAAW;AAEhB,UAAM,WAAW,CAAC,GAAG,KAAK,UAAU,KAAM,CAAA;AAC1C,eAAW,YAAY,UAAU;AACtB;AACT,UAAI,MAAM,KAAK;AAAU;AAAA,IAC3B;AAAA,EACF;AACF;AAEA,MAAM,iBAA+B,CAAA;AAUrC,SAAS,OACP,cACA,SACyC;AACzC,QAAM,QAAQ,IAAI,MAAM,cAAc,OAAO;AAE7C,MAAI,wBAAwB,UAAU;AAC7B,WAAA;AAAA,EACT;AAEA,MAAI,UAAoC,mCAAS;AAEjD,MAAI,wBAAwB,KAAK;AAC/B,cAAU,EAAE,GAAG,YAAY,GAAG,QAAQ;AAAA,EAAA,WAC7B,wBAAwB,KAAK;AACtC,cAAU,EAAE,GAAG,YAAY,GAAG,QAAQ;AAAA,EAC7B,WAAA,MAAM,QAAQ,YAAY,GAAG;AACtC,cAAU,EAAE,GAAG,cAAc,GAAG,QAAQ;AAAA,EAAA,WAC/B,wBAAwB,QAAQ;AACzC,cAAU,EAAE,GAAG,eAAe,GAAG,QAAQ;AAAA,EAC3C;AAEA,QAAM,eAAe,OAAO;AAAA,IAC1B,OAAO,QAAQ,WAAY,EAAgC,EACxD,OAAO,CAAC,CAAC,IAAI,MAAM,EAAE,QAAQ,MAAM,EACnC,IAAI,CAAC,CAAC,MAAM,MAAM,MAAM,CAAC,MAAO,OAAe,KAAK,KAAK,CAAC,CAAC;AAAA,EAAA;AAGzD,SAAA,OAAO,OAAO,OAAO,YAAY;AAC1C;AAEO,MAAM,cAAqC,uBAAA,OAAO,QAAQ,EAAE,eAAgB,CAAA;"}
@@ -1,3 +1,3 @@
1
1
  import { deepEqual } from './equals';
2
- export type TrackingProxy<T> = [value: T, equals: (newValue: T) => boolean];
2
+ export type TrackingProxy<T> = [value: T, equals: (newValue: T) => boolean, revoke?: () => void];
3
3
  export declare function trackingProxy<T>(value: T, equals?: typeof deepEqual): TrackingProxy<T>;
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "cross-state",
3
- "version": "0.8.0",
3
+ "version": "0.8.1",
4
4
  "description": "(React) state library",
5
5
  "license": "ISC",
6
6
  "repository": "schummar/schummar-state",
@@ -159,7 +159,7 @@
159
159
  "name": "core: Store",
160
160
  "path": "dist/es/index.mjs",
161
161
  "import": "{createStore}",
162
- "limit": "3.6 KB"
162
+ "limit": "4 KB"
163
163
  },
164
164
  {
165
165
  "name": "core: Cache",
@@ -183,7 +183,7 @@
183
183
  "name": "core: urlStore",
184
184
  "path": "dist/es/index.mjs",
185
185
  "import": "{createUrlStore}",
186
- "limit": "3.8 KB"
186
+ "limit": "4 KB"
187
187
  },
188
188
  {
189
189
  "name": "/react",