cross-state 0.56.4 → 1.0.0

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (107) hide show
  1. package/dist/{diff-CElc7pJI.d.ts → diff-CAQaunfv.d.cts} +3 -3
  2. package/dist/{diff-BslUrJZE.d.cts → diff-DFvRd-Gf.d.ts} +3 -3
  3. package/dist/{extendedJson-BZkQBXEv.js → extendedJson-Dv9q6rps.js} +2 -2
  4. package/dist/{extendedJson-BZkQBXEv.js.map → extendedJson-Dv9q6rps.js.map} +1 -1
  5. package/dist/{extendedJson-Dn2F7Edo.cjs → extendedJson-ursQ8DbQ.cjs} +1 -1
  6. package/dist/{extendedJson-Dn2F7Edo.cjs.map → extendedJson-ursQ8DbQ.cjs.map} +1 -1
  7. package/dist/index.cjs +9 -11
  8. package/dist/index.cjs.map +1 -1
  9. package/dist/index.d.cts +4 -4
  10. package/dist/index.d.ts +4 -4
  11. package/dist/index.js +7 -9
  12. package/dist/index.js.map +1 -1
  13. package/dist/mutative/index.cjs +2 -1
  14. package/dist/mutative/index.d.cts +2 -2
  15. package/dist/mutative/index.d.ts +2 -2
  16. package/dist/mutative/index.js +2 -1
  17. package/dist/mutative/register.cjs +4 -3
  18. package/dist/mutative/register.cjs.map +1 -1
  19. package/dist/mutative/register.d.cts +2 -4
  20. package/dist/mutative/register.d.ts +2 -2
  21. package/dist/mutative/register.js +4 -3
  22. package/dist/mutative/register.js.map +1 -1
  23. package/dist/{mutativeMethods-Bhd1Yi22.d.ts → mutativeMethods-BT1Cim3p.d.ts} +3 -3
  24. package/dist/{mutativeMethods-DWhwZRzv.d.cts → mutativeMethods-C8VcZWED.d.cts} +3 -3
  25. package/dist/{mutativeMethods-CgXk_bMt.cjs → mutativeMethods-CkNycpO9.cjs} +6 -7
  26. package/dist/{mutativeMethods-CgXk_bMt.cjs.map → mutativeMethods-CkNycpO9.cjs.map} +1 -1
  27. package/dist/{mutativeMethods-CZKeRIDL.js → mutativeMethods-Jowr0Znn.js} +4 -6
  28. package/dist/{mutativeMethods-CZKeRIDL.js.map → mutativeMethods-Jowr0Znn.js.map} +1 -1
  29. package/dist/{patchMethods-hhlLwtqE.cjs → patchMethods-B7Hm5-Qh.cjs} +4 -6
  30. package/dist/{patchMethods-hhlLwtqE.cjs.map → patchMethods-B7Hm5-Qh.cjs.map} +1 -1
  31. package/dist/{patchMethods-DXWygPZ6.d.ts → patchMethods-BmyvvHnP.d.cts} +4 -4
  32. package/dist/{patchMethods-BT4Tg5aG.d.cts → patchMethods-CixmHmNt.d.ts} +4 -4
  33. package/dist/{patchMethods-C_f3PORQ.js → patchMethods-iK2F87G0.js} +5 -7
  34. package/dist/{patchMethods-C_f3PORQ.js.map → patchMethods-iK2F87G0.js.map} +1 -1
  35. package/dist/patches/index.cjs +3 -3
  36. package/dist/patches/index.d.cts +3 -3
  37. package/dist/patches/index.d.ts +3 -3
  38. package/dist/patches/index.js +3 -3
  39. package/dist/patches/register.cjs +4 -4
  40. package/dist/patches/register.cjs.map +1 -1
  41. package/dist/patches/register.d.cts +3 -5
  42. package/dist/patches/register.d.ts +3 -3
  43. package/dist/patches/register.js +4 -4
  44. package/dist/patches/register.js.map +1 -1
  45. package/dist/{chunk-CUT6urMc.cjs → path-B-Rq5q6m.cjs} +14 -1
  46. package/dist/path-B-Rq5q6m.cjs.map +1 -0
  47. package/dist/path-CyYq74W8.js +8 -0
  48. package/dist/path-CyYq74W8.js.map +1 -0
  49. package/dist/persist/register.cjs +5 -5
  50. package/dist/persist/register.cjs.map +1 -1
  51. package/dist/persist/register.d.cts +2 -4
  52. package/dist/persist/register.d.ts +2 -2
  53. package/dist/persist/register.js +5 -5
  54. package/dist/persist/register.js.map +1 -1
  55. package/dist/{persist-CLgS5Cqw.js → persist-Bunx8xfQ.js} +12 -15
  56. package/dist/persist-Bunx8xfQ.js.map +1 -0
  57. package/dist/{persist-olbNkcdZ.d.ts → persist-CHRYYolx.d.cts} +3 -3
  58. package/dist/{persist-DboMIMOK.cjs → persist-DMbVdqS_.cjs} +11 -14
  59. package/dist/persist-DMbVdqS_.cjs.map +1 -0
  60. package/dist/{persist-DVKRq8RQ.d.cts → persist-DyI_JLxZ.d.ts} +3 -3
  61. package/dist/{propAccess-BdLsqViO.cjs → propAccess-C2AIn9RC.cjs} +4 -6
  62. package/dist/{propAccess-BdLsqViO.cjs.map → propAccess-C2AIn9RC.cjs.map} +1 -1
  63. package/dist/{propAccess-B260LXN1.js → propAccess-DvWFpYoj.js} +5 -7
  64. package/dist/{propAccess-B260LXN1.js.map → propAccess-DvWFpYoj.js.map} +1 -1
  65. package/dist/react/index.cjs +66 -80
  66. package/dist/react/index.cjs.map +1 -1
  67. package/dist/react/index.d.cts +70 -70
  68. package/dist/react/index.d.ts +70 -70
  69. package/dist/react/index.js +62 -77
  70. package/dist/react/index.js.map +1 -1
  71. package/dist/react/register.cjs +5 -5
  72. package/dist/react/register.cjs.map +1 -1
  73. package/dist/react/register.d.cts +3 -5
  74. package/dist/react/register.d.ts +3 -3
  75. package/dist/react/register.js +5 -5
  76. package/dist/react/register.js.map +1 -1
  77. package/dist/{scope-CfLlLxo9.cjs → scope-C1bcfK8e.cjs} +32 -7
  78. package/dist/scope-C1bcfK8e.cjs.map +1 -0
  79. package/dist/{scope-D3jkIPgn.d.ts → scope-CESkVNvI.d.cts} +3 -3
  80. package/dist/{scope-7LeON9bZ.js → scope-CKGsCVn3.js} +20 -7
  81. package/dist/scope-CKGsCVn3.js.map +1 -0
  82. package/dist/{scope-CcBxgcrs.d.cts → scope-DJXSRsGy.d.ts} +3 -3
  83. package/dist/{store-MBrcOgtz.d.cts → store-BRHFhRPm.d.ts} +21 -21
  84. package/dist/{store-CdST5wJZ.cjs → store-C1NYHLgR.cjs} +12 -13
  85. package/dist/store-C1NYHLgR.cjs.map +1 -0
  86. package/dist/{store-DnZ6fsiJ.d.ts → store-XcnTdeiJ.d.cts} +21 -21
  87. package/dist/{store-Dx8w7yT-.js → store-v3RYWzVg.js} +13 -14
  88. package/dist/store-v3RYWzVg.js.map +1 -0
  89. package/dist/{storeMethods-B_RzvMaV.cjs → storeMethods-CNu7VD6w.cjs} +135 -60
  90. package/dist/storeMethods-CNu7VD6w.cjs.map +1 -0
  91. package/dist/{storeMethods-BrKuusQ2.js → storeMethods-CQhXlHpl.js} +115 -59
  92. package/dist/storeMethods-CQhXlHpl.js.map +1 -0
  93. package/dist/{storeMethods-CmWv1YMe.d.cts → storeMethods-Dsz0-Cda.d.ts} +4 -4
  94. package/dist/{storeMethods-Cb1ur5K3.d.ts → storeMethods-y3PlfTHV.d.cts} +4 -4
  95. package/package.json +26 -37
  96. package/dist/hash-DNFM5y_h.js +0 -19
  97. package/dist/hash-DNFM5y_h.js.map +0 -1
  98. package/dist/hash-Dv3XlmHn.cjs +0 -30
  99. package/dist/hash-Dv3XlmHn.cjs.map +0 -1
  100. package/dist/persist-CLgS5Cqw.js.map +0 -1
  101. package/dist/persist-DboMIMOK.cjs.map +0 -1
  102. package/dist/scope-7LeON9bZ.js.map +0 -1
  103. package/dist/scope-CfLlLxo9.cjs.map +0 -1
  104. package/dist/store-CdST5wJZ.cjs.map +0 -1
  105. package/dist/store-Dx8w7yT-.js.map +0 -1
  106. package/dist/storeMethods-B_RzvMaV.cjs.map +0 -1
  107. package/dist/storeMethods-BrKuusQ2.js.map +0 -1
@@ -0,0 +1 @@
1
+ {"version":3,"file":"scope-CKGsCVn3.js","names":["hash: unique symbol","factory: (...args: Args) => T","cacheTime?: number","name?: string","allResources: ResourceGroup","args: Args","options: CacheOptions<T, Args>","derivedFromCache?: {\n cache: Cache<any, any>;\n selectors: (Selector<any, any> | AnyPath)[];\n }","options","baseInstance: CacheBundle<T, Args, TCache> & TCache","defaultCacheOptions: CacheOptions<any, any>","createCache: typeof create & { defaultOptions: CacheOptions<any, any> }","defaultValue: T"],"sources":["../src/lib/hash.ts","../src/lib/instanceCache.ts","../src/core/resourceGroup.ts","../src/core/cache.ts","../src/core/scope.ts"],"sourcesContent":["import { isPlainObject } from '@lib/helpers';\n\nexport interface Hashable {\n [hash](): string;\n}\n\nexport const hash: unique symbol = Symbol('hash');\n\nfunction hasHashFunction(value: unknown): value is Hashable {\n return (\n typeof value === 'object' &&\n value !== null &&\n hash in value &&\n typeof (value as any)[hash] === 'function' &&\n (value as any)[hash].length === 0\n );\n}\n\nexport function simpleHash(value: unknown): string {\n if (hasHashFunction(value)) {\n return value[hash]();\n }\n\n if (value instanceof Set) {\n return `s[${[...value].map(simpleHash).sort().join(',')}]`;\n }\n\n if (value instanceof Map) {\n return `m[${[...value.entries()].map(simpleHash).sort().join(',')}]`;\n }\n\n if (Array.isArray(value)) {\n return `[${value.map(simpleHash).join(',')}]`;\n }\n\n if (isPlainObject(value)) {\n return `o[${Object.entries(value).map(simpleHash).sort().join(',')}]`;\n }\n\n return JSON.stringify(value);\n}\n","import { simpleHash } from './hash';\n\nexport class InstanceCache<Args extends any[], T extends object> {\n private cache = new Map<string, { t: number; ref?: T; weakRef: WeakRef<T> }>();\n\n private interval = this.cacheTime\n ? setInterval(() => this.cleanup(), Math.max(this.cacheTime / 10, 1))\n : undefined;\n\n constructor(\n public readonly factory: (...args: Args) => T,\n public readonly cacheTime?: number,\n ) {}\n\n cleanup(): void {\n const cutoff = this.now() - (this.cacheTime ?? 0);\n\n for (const [key, entry] of this.cache.entries()) {\n if (entry.ref && entry.t <= cutoff) {\n delete entry.ref;\n }\n\n if (!entry.ref && !entry.weakRef?.deref()) {\n this.cache.delete(key);\n }\n }\n }\n\n get(...args: Args): T {\n return this.getWithKey(args, args);\n }\n\n getWithKey(args: Args, cacheKey: unknown): T {\n const key = simpleHash(cacheKey);\n let entry = this.cache.get(key);\n let value = entry?.ref ?? entry?.weakRef?.deref();\n\n if (!entry || !value) {\n value = this.factory(...args);\n entry = {\n t: this.now(),\n ref: value,\n weakRef: new WeakRef(value),\n };\n\n this.cache.set(key, entry);\n } else {\n entry.t = this.now();\n entry.ref ??= value;\n }\n\n return value;\n }\n\n values(): T[] {\n return [...this.cache.values()]\n .map((entry) => entry.ref ?? entry.weakRef?.deref())\n .filter((value): value is T => !!value);\n }\n\n stop(): void {\n if (this.interval) {\n clearInterval(this.interval);\n }\n }\n\n stats(): { count: number; withRef: number; withWeakRef: number } {\n return {\n count: this.cache.size,\n withRef: [...this.cache.values()].filter((x) => !!x.ref).length,\n withWeakRef: [...this.cache.values()].filter((x) => !!x.weakRef?.deref()).length,\n };\n }\n\n private now() {\n return performance.now();\n }\n}\n","import { autobind } from '@lib/autobind';\n\nexport interface Resource {\n invalidateAll(): void;\n clearAll(): void;\n}\n\nexport class ResourceGroup {\n private refMap = new WeakMap<Resource, WeakRef<Resource>>();\n\n private refSet = new Set<WeakRef<Resource>>();\n\n constructor(public readonly name?: string) {\n autobind(ResourceGroup);\n }\n\n add(resource: Resource): void {\n const ref = new WeakRef(resource);\n this.refMap.set(resource, ref);\n this.refSet.add(ref);\n }\n\n delete(resource: Resource): void {\n const ref = this.refMap.get(resource);\n if (ref) {\n this.refMap.delete(resource);\n this.refSet.delete(ref);\n }\n }\n\n invalidateAll(): void {\n for (const ref of this.refSet) {\n const resource = ref.deref();\n if (resource) {\n resource.invalidateAll();\n } else {\n this.refSet.delete(ref);\n }\n }\n }\n\n clearAll(): void {\n for (const ref of this.refSet) {\n const resource = ref.deref();\n if (resource) {\n resource.clearAll();\n } else {\n this.refSet.delete(ref);\n }\n }\n }\n}\n\nexport const allResources: ResourceGroup = /* @__PURE__ */ new ResourceGroup();\n\nexport function createResourceGroup(name?: string): ResourceGroup {\n return new ResourceGroup(name);\n}\n","import { autobind } from '@lib/autobind';\nimport type { CacheState, ErrorState, ValueState } from '@lib/cacheState';\nimport { calcDuration } from '@lib/calcDuration';\nimport { calculatedValue } from '@lib/calculatedValue';\nimport type { Constrain } from '@lib/constrain';\nimport { deepEqual } from '@lib/equals';\nimport { InstanceCache } from '@lib/instanceCache';\nimport { makeSelector } from '@lib/makeSelector';\nimport { type MaybePromise } from '@lib/maybePromise';\nimport type { AnyPath, Path, Value } from '@lib/path';\nimport { PromiseWithState } from '@lib/promiseWithState';\nimport type { Duration, Selector } from './commonTypes';\nimport { allResources, type ResourceGroup } from './resourceGroup';\nimport { Store, createStore, type Calculate, type StoreOptions } from './store';\n\nexport interface CacheGetOptions {\n /**\n * How to handle the cache when getting the value.\n * - `whenMissing`: Only fetch a new value if there is no cached value.\n * - `whenStale`: Fetch a new value if there is no cached value or if the cached value is stale.\n * - `force`: Always fetch a new value, regardless of the cache state.\n */\n update?: 'whenMissing' | 'whenStale' | 'force';\n\n /**\n * If set to `true`, the cache will be updated in the background.\n * This means that a stale value will be returned immediately, if available, while the new value is being fetched.\n */\n backgroundUpdate?: boolean;\n}\n\nexport interface CacheFunction<T, Args extends any[] = []> {\n (...args: Args): Promise<T> | Calculate<Promise<T>>;\n}\n\nexport interface CacheOptions<T, Args extends any[]> extends StoreOptions<Promise<T>> {\n /**\n * How long to keep the cache entry before it is considered stale.\n * If set to `undefined` or `null`, the cache entry will never be invalidated automatically.\n *\n * @example\n * ```typescript\n * createCache(fetchData, {\n * invalidateAfter: { seconds: 10 },\n * });\n * ```\n */\n invalidateAfter?: Duration | ((state: ValueState<T> | ErrorState) => Duration | null) | null;\n\n /**\n * If set, the cache will be invalidated when the window gets focused.\n * This is useful for caches that are used in a browser environment and might become stale when the user switches tabs.\n */\n invalidateOnWindowFocus?: boolean;\n\n /**\n * If set, the cached value will be cleared when the cache is invalidated.\n * Without this option, the cache will keep the last value as stale until a new value becomes available.\n */\n clearOnInvalidate?: boolean;\n\n /**\n * If set, cache entries will be cleared after approximately the specified duration.\n * This is useful for long lived pages or applications and helps to prevent memory leaks.\n * The exact time when the entry is cleared is not guaranteed, since it will be cleared during garbage collection.\n */\n clearUnusedAfter?: Duration | null;\n\n /**\n * Add the cache to the specified resource group(s).\n * This allows you to invalidate or clear multiple caches that belong to the same group.\n * All caches are always added to the `allResources` group.\n */\n resourceGroup?: ResourceGroup | ResourceGroup[];\n\n /**\n * Function to generate a custom cache key based on the provided arguments.\n * This allows you to control how cache entries are identified and reused.\n * By default, the arguments array is used as the cache key.\n *\n * @example\n * ```typescript\n * // Will use the same instance when provided with `undefined`, `{ num: 0 }`, `{ bool: false }`, etc.\n * createCache((filter?: { num?: number, bool?: boolean }) => fetchData(filter), {\n * getCacheKey: (filter?) => ({\n * num: filter?.num ?? 0,\n * bool: filter?.bool ?? false,\n * }),\n * });\n * ```\n */\n getCacheKey?: (...args: NoInfer<Args>) => unknown;\n}\n\nexport class Cache<T, Args extends any[] = []> extends Store<Promise<T>> {\n readonly state: Store<CacheState<T>> = createStore<CacheState<T>>({\n status: 'pending',\n isStale: true,\n isUpdating: false,\n isConnected: false,\n });\n\n protected stalePromise?: Promise<T>;\n\n protected invalidationTimer?: ReturnType<typeof setTimeout>;\n\n constructor(\n getter: Calculate<Promise<T>>,\n public readonly args: Args,\n public readonly options: CacheOptions<T, Args> = {},\n public readonly derivedFromCache?: {\n cache: Cache<any, any>;\n selectors: (Selector<any, any> | AnyPath)[];\n },\n ) {\n super(getter, options, undefined);\n autobind(Cache);\n\n this.watchPromise();\n this.watchFocus();\n }\n\n get({ update = 'whenStale', backgroundUpdate = false }: CacheGetOptions = {}): Promise<T> {\n if (!this.calculatedValue?.check()) {\n this.calculatedValue?.stop();\n this.calculatedValue = undefined;\n }\n\n const promise = this.calculatedValue?.value;\n const stalePromise = this.stalePromise;\n\n if (\n (update === 'whenMissing' && !promise && !stalePromise) ||\n (update === 'whenStale' && !promise) ||\n update === 'force'\n ) {\n this.calculatedValue = calculatedValue(this, this.notify);\n this.notify();\n\n if ((!promise && !stalePromise) || !backgroundUpdate) {\n return this.calculatedValue.value;\n }\n }\n\n if (!promise || (stalePromise && backgroundUpdate)) {\n return stalePromise!;\n }\n\n return promise;\n }\n\n updateValue(value: MaybePromise<T> | ((value: T | undefined) => T)): void {\n if (value instanceof Function) {\n value = value(this.state.get().value);\n }\n this.set(PromiseWithState.resolve(value));\n }\n\n updateError(error: unknown): void {\n this.set(PromiseWithState.reject(error));\n }\n\n invalidate(recursive?: boolean): void {\n const { clearOnInvalidate } = this.options;\n\n if (clearOnInvalidate) {\n return this.clear(recursive);\n }\n\n const { status, isStale, isUpdating } = this.state.get();\n if (status !== 'pending' && !isStale && !isUpdating) {\n this.stalePromise = this.calculatedValue?.value;\n }\n\n this.state.set((state) => ({\n ...state,\n isStale: true,\n isUpdating: false,\n }));\n\n super.invalidate(recursive);\n }\n\n clear(recursive?: boolean): void {\n this.state.set({\n status: 'pending',\n isStale: true,\n isUpdating: false,\n isConnected: false,\n });\n delete this.stalePromise;\n\n super.invalidate(recursive);\n }\n\n mapValue<S>(selector: Selector<T, S>): Cache<S, Args>;\n\n mapValue<const P extends AnyPath>(\n selector: P extends Path<T> ? P : Path<T>,\n ): Cache<Value<T, P>, Args>;\n\n mapValue(selector: Selector<any, any> | AnyPath) {\n return mapValue(this, selector);\n }\n\n protected watchPromise(): void {\n this.subscribe(\n async (promise) => {\n if (promise instanceof PromiseWithState && promise.state.status !== 'pending') {\n promise.catch(() => undefined);\n\n this.state.set((state) => ({\n ...promise.state,\n isStale: false,\n isUpdating: false,\n isConnected: state.isConnected,\n }));\n\n delete this.stalePromise;\n this.setTimers();\n return;\n }\n\n this.state.set((state) => ({\n ...state,\n isUpdating: true,\n }));\n\n this.setTimers();\n\n try {\n const value = await promise;\n\n if (promise !== this.calculatedValue?.value) {\n return;\n }\n\n this.state.set((state) => ({\n status: 'value',\n value,\n isStale: false,\n isUpdating: false,\n isConnected: state.isConnected,\n }));\n delete this.stalePromise;\n this.setTimers();\n } catch (error) {\n if (promise !== this.calculatedValue?.value) {\n return;\n }\n\n this.state.set((state) => ({\n status: 'error',\n error,\n isStale: false,\n isUpdating: false,\n isConnected: state.isConnected,\n }));\n delete this.stalePromise;\n this.setTimers();\n }\n },\n { passive: true },\n );\n }\n\n protected setTimers(): void {\n if (this.invalidationTimer) {\n clearTimeout(this.invalidationTimer);\n }\n this.invalidationTimer = undefined;\n\n const state = this.state.get();\n let { invalidateAfter } = this.options;\n const ref = new WeakRef(this);\n\n if (state.status === 'pending') {\n return;\n }\n\n if (invalidateAfter instanceof Function) {\n invalidateAfter = invalidateAfter(state);\n }\n\n if (invalidateAfter !== null && invalidateAfter !== undefined) {\n this.invalidationTimer = setTimeout(\n () => ref?.deref()?.invalidate(),\n calcDuration(invalidateAfter),\n );\n }\n }\n\n protected watchFocus(): void {\n const { invalidateOnWindowFocus } = this.options;\n\n if (\n !invalidateOnWindowFocus ||\n typeof document === 'undefined' ||\n typeof document.addEventListener === 'undefined'\n ) {\n return;\n }\n\n const ref = new WeakRef(this);\n\n const onFocus = () => {\n const that = ref?.deref();\n if (!that) {\n document.removeEventListener('visibilitychange', onFocus);\n return;\n }\n\n if (!document.hidden && !that.state.get().isConnected) {\n that.invalidate();\n }\n };\n\n document.addEventListener('visibilitychange', onFocus);\n }\n}\n\nfunction mapValue<T, S, Args extends any[]>(\n cache: Cache<T, Args>,\n _selector: Selector<T, S> | AnyPath,\n): Cache<S, Args> {\n const selector = makeSelector(_selector);\n const derivedFromCache = {\n cache: cache.derivedFromCache ? cache.derivedFromCache.cache : cache,\n selectors: cache.derivedFromCache\n ? [...cache.derivedFromCache.selectors, _selector]\n : [_selector],\n };\n\n return new Cache<S, Args>(\n async ({ use }) => {\n const value = await use(cache);\n return selector(value);\n },\n cache.args,\n {\n equals: cache.options.equals,\n },\n derivedFromCache,\n );\n}\n\nexport type CreateCacheResult<\n T,\n Args extends any[],\n TCache extends Cache<T, Args>,\n> = [] extends Args ? CacheBundle<T, Args, TCache> & TCache : CacheBundle<T, Args, TCache>;\n\nexport interface InvalidationOptions<T, Args extends any[], TCache extends Cache<T, Args>> {\n filter?: (cache: TCache) => boolean;\n}\n\nexport type CacheBundle<T, Args extends any[], TCache extends Cache<T, Args>> = {\n (...args: Args): TCache;\n mapCache<S>(selector: Selector<T, S>): CreateCacheResult<S, Args, Cache<S, Args>>;\n mapValue<const P>(\n selector: Constrain<P, Path<T>>,\n ): CreateCacheResult<Value<T, P>, Args, Cache<Value<T, P>, Args>>;\n invalidateAll: (options?: InvalidationOptions<T, Args, TCache>) => void;\n clearAll: (options?: InvalidationOptions<T, Args, TCache>) => void;\n getInstances: () => TCache[];\n};\n\nfunction create<T, Args extends any[] = []>(\n cacheFunction: CacheFunction<T, Args>,\n options?: CacheOptions<T, Args>,\n): CreateCacheResult<T, Args, Cache<T, Args>> {\n return internalCreate<T, Args, Cache<T, Args>>(\n (args, options) =>\n new Cache(\n (helpers) => {\n const result = cacheFunction.apply(helpers, args);\n\n if (result instanceof Function) {\n return result(helpers);\n }\n\n return result;\n },\n args,\n options,\n undefined,\n ),\n options,\n );\n}\n\nexport function internalCreate<T, Args extends any[], TCache extends Cache<T, Args>>(\n factory: (args: Args, options: CacheOptions<T, Args>) => TCache,\n options?: CacheOptions<T, Args>,\n): CreateCacheResult<T, Args, TCache> {\n options = { ...createCache.defaultOptions, ...options };\n const { clearUnusedAfter, resourceGroup } = options ?? {};\n\n let baseInstance: CacheBundle<T, Args, TCache> & TCache;\n\n const instanceCache = new InstanceCache<Args, TCache>(\n (...args) => factory(args, options),\n clearUnusedAfter ? calcDuration(clearUnusedAfter) : undefined,\n );\n\n function get(...args: Args) {\n const sliceAfter = args.lastIndexOf(undefined);\n if (sliceAfter !== -1) {\n args = args.slice(0, sliceAfter) as Args;\n }\n\n const cacheKey = options?.getCacheKey ? options.getCacheKey(...args) : args;\n return instanceCache.getWithKey(args, cacheKey);\n }\n\n const mapCache = (selector: any) => {\n return internalCreate<any, Args, Cache<any, Args>>((args: Args) =>\n mapValue(baseInstance(...args), selector),\n );\n };\n\n const invalidateAll = ({ filter = () => true }: InvalidationOptions<T, Args, TCache> = {}) => {\n for (const instance of instanceCache.values()) {\n if (filter(instance)) {\n instance.invalidate();\n }\n }\n };\n\n const clearAll = ({ filter = () => true }: InvalidationOptions<T, Args, TCache> = {}) => {\n for (const instance of instanceCache.values()) {\n if (filter(instance)) {\n instance.clear();\n }\n }\n };\n\n const getInstances = () => {\n return instanceCache.values();\n };\n\n baseInstance = new Proxy(\n Object.assign(() => undefined, {\n mapCache,\n invalidateAll,\n clearAll,\n getInstances,\n }),\n {\n apply(_target, _thisArg, argArray) {\n return get(...(argArray as unknown as Args));\n },\n get(target, p, receiver) {\n if (Reflect.has(target, p)) {\n return Reflect.get(target, p, receiver);\n }\n\n const baseCache = get(...([] as unknown as Args));\n return Reflect.get(baseCache, p, baseCache);\n },\n },\n ) as unknown as CacheBundle<T, Args, TCache> & TCache;\n\n const groups = Array.isArray(resourceGroup)\n ? resourceGroup\n : resourceGroup\n ? [resourceGroup]\n : [];\n\n for (const group of groups.concat(allResources)) {\n group.add(baseInstance);\n }\n\n return baseInstance;\n}\n\nexport const defaultCacheOptions: CacheOptions<any, any> = {\n invalidateOnWindowFocus: true,\n clearUnusedAfter: { days: 1 },\n retain: { milliseconds: 1 },\n equals: deepEqual,\n};\n\nexport const createCache: typeof create & { defaultOptions: CacheOptions<any, any> } =\n /* @__PURE__ */ Object.assign(create, {\n defaultOptions: defaultCacheOptions,\n });\n","import { autobind } from '@lib/autobind';\n\nexport class Scope<T> {\n constructor(public readonly defaultValue: T) {\n autobind(Scope);\n }\n}\n\nexport function createScope<T>(defaultValue: T): Scope<T> {\n return new Scope(defaultValue);\n}\n"],"mappings":";;;;AAMA,MAAaA,OAAsB,OAAO,OAAO;AAEjD,SAAS,gBAAgB,OAAmC;AAC1D,QACE,OAAO,UAAU,YACjB,UAAU,QACV,QAAQ,SACR,OAAQ,MAAc,UAAU,cAC/B,MAAc,MAAM,WAAW;;AAIpC,SAAgB,WAAW,OAAwB;AACjD,KAAI,gBAAgB,MAAM,CACxB,QAAO,MAAM,OAAO;AAGtB,KAAI,iBAAiB,IACnB,QAAO,KAAK,CAAC,GAAG,MAAM,CAAC,IAAI,WAAW,CAAC,MAAM,CAAC,KAAK,IAAI,CAAC;AAG1D,KAAI,iBAAiB,IACnB,QAAO,KAAK,CAAC,GAAG,MAAM,SAAS,C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AY,IAAI,GAAI,EAAE,CAAqB;AACjD,UAAO,QAAQ,IAAI,WAAW,GAAG,UAAU;;EAE9C,CACF;CAED,MAAM,SAAS,MAAM,QAAQ,cAAc,GACvC,gBACA,gBACE,CAAC,cAAc,GACf,EAAE;AAER,MAAK,MAAM,SAAS,OAAO,OAAO,aAAa,CAC7C,OAAM,IAAI,aAAa;AAGzB,QAAO;;AAGT,MAAaC,sBAA8C;CACzD,yBAAyB;CACzB,kBAAkB,EAAE,MAAM,GAAG;CAC7B,QAAQ,EAAE,cAAc,GAAG;CAC3B,QAAQ;CACT;AAED,MAAaC,cACK,uBAAO,OAAO,QAAQ,EACpC,gBAAgB,qBACjB,CAAC;;;;ACpeJ,IAAa,QAAb,MAAa,MAAS;CACpB,YAAY,AAAgBC,cAAiB;EAAjB;AAC1B,WAAS,MAAM;;;AAInB,SAAgB,YAAe,cAA2B;AACxD,QAAO,IAAI,MAAM,aAAa"}
@@ -1,4 +1,4 @@
1
- import { AnyPath, Calculate, Constrain, Duration, MaybePromise, Path, Selector, Store, StoreOptions, Value } from "./store-MBrcOgtz.cjs";
1
+ import { B as Value, C as Selector, G as MaybePromise, K as Constrain, N as Path, a as StoreOptions, b as Duration, k as AnyPath, n as Calculate, r as Store } from "./store-BRHFhRPm.js";
2
2
 
3
3
  //#region src/lib/cacheState.d.ts
4
4
  type ValueState<T> = {
@@ -163,5 +163,5 @@ declare class Scope<T> {
163
163
  }
164
164
  declare function createScope<T>(defaultValue: T): Scope<T>;
165
165
  //#endregion
166
- export { Cache, CacheBundle, CacheFunction, CacheGetOptions, CacheOptions, CacheState, CreateCacheResult, ErrorState, PendingState, Resource, ResourceGroup, Scope, ValueState, allResources, createCache, createResourceGroup, createScope };
167
- //# sourceMappingURL=scope-CcBxgcrs.d.cts.map
166
+ export { ValueState as _, CacheFunction as a, CreateCacheResult as c, ResourceGroup as d, allResources as f, PendingState as g, ErrorState as h, CacheBundle as i, createCache as l, CacheState as m, createScope as n, CacheGetOptions as o, createResourceGroup as p, Cache as r, CacheOptions as s, Scope as t, Resource as u };
167
+ //# sourceMappingURL=scope-DJXSRsGy.d.ts.map
@@ -1,5 +1,5 @@
1
1
  //#region src/lib/constrain.d.ts
2
- type Constrain<T, S> = T & S;
2
+ type Constrain<T, S$1> = T & S$1;
3
3
  //#endregion
4
4
  //#region src/lib/maybePromise.d.ts
5
5
  type MaybePromise<T> = T | Promise<T>;
@@ -23,18 +23,18 @@ type _PathAsArray<T, Optional, MaxDepth, Depth extends 1[]> = (Optional extends
23
23
  type PathAsArray<T, Optional extends boolean = false, MaxDepth extends number = 5> = _PathAsArray<T, Optional, MaxDepth, []>;
24
24
  type PathAsString<T, Optional extends boolean = false, MaxDepth extends number = 5> = ArrayToStringPath<PathAsArray<T, Optional, MaxDepth>>;
25
25
  type Path<T, Optional extends boolean = false, MaxDepth extends number = 5> = PathAsString<T, Optional, MaxDepth> | PathAsArray<T, Optional, MaxDepth>;
26
- type Value$1<T, P> = P extends readonly [] ? T : true extends IsAny<T> | IsAny<P> ? any : true extends IsNever<T> | IsNever<P> ? never : P extends string ? Value$1<T, StringToArrayPath<P>> : P extends readonly [infer First extends KeyType, ...infer Rest extends readonly KeyType[]] ? T extends Map<any, infer V> | Set<infer V> ? Value$1<V, Rest> | undefined : T extends Array_ ? any[] extends T ? Value$1<T[First & keyof T], Rest> | undefined : Value$1<T[First & keyof T], Rest> : T extends Object_ ? Record<any, any> extends T ? Value$1<T[First], Rest> | undefined : Value$1<T[First], Rest> : never : never;
26
+ type Value<T, P$1> = P$1 extends readonly [] ? T : true extends IsAny<T> | IsAny<P$1> ? any : true extends IsNever<T> | IsNever<P$1> ? never : P$1 extends string ? Value<T, StringToArrayPath<P$1>> : P$1 extends readonly [infer First extends KeyType, ...infer Rest extends readonly KeyType[]] ? T extends Map<any, infer V> | Set<infer V> ? Value<V, Rest> | undefined : T extends Array_ ? any[] extends T ? Value<T[First & keyof T], Rest> | undefined : Value<T[First & keyof T], Rest> : T extends Object_ ? Record<any, any> extends T ? Value<T[First], Rest> | undefined : Value<T[First], Rest> : never : never;
27
27
  type _WildcardPathAsArray<T, MaxDepth, Depth extends 1[]> = [] | (0 extends 1 & T ? KeyType[] : T extends never ? never : T extends Object_ ? Depth["length"] extends MaxDepth ? string[] : T extends Map<infer K extends KeyType, infer V> ? ["*"] | [K] | [K, ..._WildcardPathAsArray<V, MaxDepth, [...Depth, 1]>] : T extends Set<any> ? ["*"] | [number] : Record<string, any> extends T ? ["*"] | ["*", ..._WildcardPathAsArray<T[string], MaxDepth, [...Depth, 1]>] : { [K in GetKeys<T>]: ["*"] | ["*", ..._WildcardPathAsArray<T[T extends readonly any[] ? number : keyof T], MaxDepth, [...Depth, 1]>] | [K] | [K, ..._WildcardPathAsArray<T[K], MaxDepth, [...Depth, 1]>] }[GetKeys<T>] : never);
28
28
  type WildcardPathAsArray<T, MaxDepth extends number = 5> = _WildcardPathAsArray<T, MaxDepth, []>;
29
29
  type WildcardPathAsString<T, MaxDepth extends number = 5> = ArrayToStringPath<_WildcardPathAsArray<T, MaxDepth, []>>;
30
30
  type WildcardPath<T, MaxDepth extends number = 5> = WildcardPathAsString<T, MaxDepth> | WildcardPathAsArray<T, MaxDepth>;
31
- type WildcardValue<T, P> = true extends IsAny<T> | IsAny<P> ? any : true extends IsNever<T> | IsNever<P> ? never : P extends string ? WildcardValue<T, StringToArrayPath<P>> : P extends readonly [infer First extends KeyType, ...infer Rest extends KeyType[]] ? T extends Map<any, infer V> | Set<infer V> ? WildcardValue<V, Rest> | (First extends "*" ? never : undefined) : T extends Array_ ? First extends "*" ? WildcardValue<T[number], Rest> : any[] extends T ? WildcardValue<T[First & keyof T], Rest> | undefined : First extends keyof T ? WildcardValue<T[First], Rest> : undefined : T extends Object_ ? First extends "*" ? WildcardValue<T[keyof T], Rest> : Record<any, any> extends T ? WildcardValue<T[First], Rest> | undefined : WildcardValue<T[First], Rest> : never : T;
31
+ type WildcardValue<T, P$1> = true extends IsAny<T> | IsAny<P$1> ? any : true extends IsNever<T> | IsNever<P$1> ? never : P$1 extends string ? WildcardValue<T, StringToArrayPath<P$1>> : P$1 extends readonly [infer First extends KeyType, ...infer Rest extends KeyType[]] ? T extends Map<any, infer V> | Set<infer V> ? WildcardValue<V, Rest> | (First extends "*" ? never : undefined) : T extends Array_ ? First extends "*" ? WildcardValue<T[number], Rest> : any[] extends T ? WildcardValue<T[First & keyof T], Rest> | undefined : First extends keyof T ? WildcardValue<T[First], Rest> : undefined : T extends Object_ ? First extends "*" ? WildcardValue<T[keyof T], Rest> : Record<any, any> extends T ? WildcardValue<T[First], Rest> | undefined : WildcardValue<T[First], Rest> : never : T;
32
32
  type Join<A extends string | number, B extends string | number> = A extends "" ? B : B extends "" ? A : `${A}.${B}`;
33
33
  type _SettablePathAsArray<T, MaxDepth, Depth extends 1[]> = readonly [] | (true extends IsAny<T> ? readonly KeyType[] : undefined extends T ? T extends Map<any, any> | Set<any> ? never : T extends Object_ ? { [K in GetKeys<T>]: Partial<T> extends Omit<T, K> ? readonly [K] | readonly [K, ..._SettablePathAsArray<T[K], MaxDepth, [...Depth, 1]>] : readonly [] }[GetKeys<T>] : never : T extends never ? never : T extends Object_ ? Depth["length"] extends MaxDepth ? readonly string[] : T extends Map<infer K extends KeyType, infer V> ? readonly [K] | readonly [K, ..._SettablePathAsArray<V, MaxDepth, [...Depth, 1]>] : T extends Set<any> ? readonly [number] : { [K in GetKeys<T>]: readonly [K] | readonly [K, ..._SettablePathAsArray<T[K], MaxDepth, [...Depth, 1]>] }[GetKeys<T>] : never);
34
34
  type SettablePathAsArray<T, MaxDepth extends number = 5> = _SettablePathAsArray<T, MaxDepth, []>;
35
35
  type SettablePathAsString<T, MaxDepth extends number = 5> = ArrayToStringPath<SettablePathAsArray<T, MaxDepth>>;
36
36
  type SettablePath<T, MaxDepth extends number = 5> = SettablePathAsString<T, MaxDepth> | SettablePathAsArray<T, MaxDepth>;
37
- type SettableValue<T, P> = P extends readonly [] ? T : true extends IsAny<T> | IsAny<P> ? any : true extends IsNever<T> | IsNever<P> ? never : P extends string ? SettableValue<T, StringToArrayPath<P>> : P extends readonly [infer First extends KeyType, ...infer Rest extends readonly KeyType[]] ? T extends Map<any, infer V> | Set<infer V> ? SettableValue<V, Rest> : T extends Array_ ? SettableValue<T[First & keyof T], Rest> : T extends Object_ ? SettableValue<T[First], Rest> : never : never;
37
+ type SettableValue<T, P$1> = P$1 extends readonly [] ? T : true extends IsAny<T> | IsAny<P$1> ? any : true extends IsNever<T> | IsNever<P$1> ? never : P$1 extends string ? SettableValue<T, StringToArrayPath<P$1>> : P$1 extends readonly [infer First extends KeyType, ...infer Rest extends readonly KeyType[]] ? T extends Map<any, infer V> | Set<infer V> ? SettableValue<V, Rest> : T extends Array_ ? SettableValue<T[First & keyof T], Rest> : T extends Object_ ? SettableValue<T[First], Rest> : never : never;
38
38
  //#endregion
39
39
  //#region src/lib/debounce.d.ts
40
40
  type DebounceOptions = Duration | {
@@ -47,8 +47,8 @@ type DebounceOptions = Duration | {
47
47
  interface Listener<T = void, TThis = unknown> {
48
48
  (this: TThis, value: T, previouseValue?: T): void;
49
49
  }
50
- interface Selector<T, S> {
51
- (value: T): S;
50
+ interface Selector<T, S$1> {
51
+ (value: T): S$1;
52
52
  }
53
53
  interface Effect<T> {
54
54
  (this: T, context: T): void | Cancel;
@@ -88,13 +88,13 @@ type Duration = number | {
88
88
  hours?: number;
89
89
  days?: number;
90
90
  };
91
- type UpdateFrom<Value, From extends any[]> = Value | ((...args: From) => Value);
92
- type Update<Value> = UpdateFrom<Value, [Value]>;
93
- interface UpdateFunction<Value> {
94
- (update: Update<Value>): void;
91
+ type UpdateFrom<Value$1, From extends any[]> = Value$1 | ((...args: From) => Value$1);
92
+ type Update<Value$1> = UpdateFrom<Value$1, [Value$1]>;
93
+ interface UpdateFunction<Value$1> {
94
+ (update: Update<Value$1>): void;
95
95
  }
96
- interface AsyncUpdateFunction<Value> {
97
- (update: UpdateFrom<MaybePromise<Value>, [Value]>): void;
96
+ interface AsyncUpdateFunction<Value$1> {
97
+ (update: UpdateFrom<MaybePromise<Value$1>, [Value$1]>): void;
98
98
  }
99
99
  interface StoreLike<T> {
100
100
  get(): T;
@@ -144,12 +144,12 @@ declare class PromiseWithCancel<T> extends Promise<T> {
144
144
  type Function_ = (...args: any) => any;
145
145
  declare const arrayMethods: { [P in "splice" | "push" | "pop" | "shift" | "unshift" | "reverse" | "sort"]: <T extends Array<any>>(this: Store<T>, ...args: T[P] extends Function_ ? Parameters<T[P]> : never) => T[P] extends Function_ ? ReturnType<T[P]> : never };
146
146
  declare const recordMethods: {
147
- delete<T extends Record<any, any>, K extends OptionalPropertyOf<T>>(this: Store<T>, key: K): void;
147
+ delete<T extends Record<any, any>, K$1 extends OptionalPropertyOf<T>>(this: Store<T>, key: K$1): void;
148
148
  clear<T extends Record<any, any>>(this: OptionalProperties<T> extends T ? Store<T> : never): void;
149
149
  };
150
150
  declare const mapMethods: {
151
- delete<K, V>(this: Store<Map<K, V>>, key: K): boolean;
152
- clear<K, V>(this: Store<Map<K, V>>): void;
151
+ delete<K$1, V$1>(this: Store<Map<K$1, V$1>>, key: K$1): boolean;
152
+ clear<K$1, V$1>(this: Store<Map<K$1, V$1>>): void;
153
153
  };
154
154
  declare const setMethods: {
155
155
  add<T>(this: Store<Set<T>>, value: T): void;
@@ -206,16 +206,16 @@ declare class Store<T> {
206
206
  } | undefined);
207
207
  get(): T;
208
208
  set(update: Update<T>): void;
209
- set<const P>(path: Constrain<P, Path<T>>, update: Update<Value$1<T, P>>): void;
209
+ set<const P$1>(path: Constrain<P$1, Path<T>>, update: Update<Value<T, P$1>>): void;
210
210
  invalidate(recursive?: boolean): void;
211
211
  subscribe(listener: Listener<T, {
212
212
  cancel: Cancel;
213
213
  }>, options?: SubscribeOptions): DisposableCancel;
214
- once<S extends T>(condition: (value: T) => value is S, options?: OnceOptions): PromiseWithCancel<S>;
214
+ once<S$1 extends T>(condition: (value: T) => value is S$1, options?: OnceOptions): PromiseWithCancel<S$1>;
215
215
  once(condition: (value: T) => boolean, options?: OnceOptions): PromiseWithCancel<T>;
216
216
  once(options?: OnceOptions): PromiseWithCancel<Exclude<T, undefined>>;
217
- map<S>(selector: Selector<T, S>, updater?: (value: S) => Update<T>): Store<S>;
218
- map<const P>(selector: Constrain<P, SettablePath<T>>): Store<Value$1<T, P>>;
217
+ map<S$1>(selector: Selector<T, S$1>, updater?: (value: S$1) => Update<T>): Store<S$1>;
218
+ map<const P$1>(selector: Constrain<P$1, SettablePath<T>>): Store<Value<T, P$1>>;
219
219
  /** Add an effect that will be executed when the store becomes active, which means when it has at least one subscriber.
220
220
  * @param effect
221
221
  * If there is already a subscriber, the effect will be executed immediately.
@@ -239,5 +239,5 @@ declare const createStore: typeof create & {
239
239
  defaultOptions: StoreOptions<any>;
240
240
  };
241
241
  //#endregion
242
- export { AnyPath, AsyncConnectionActions, AsyncUpdateFunction, BaseConnectionActions, BoundStoreMethods, Calculate, CalculationActions, Cancel, Connection, ConnectionActions, Constrain, DisposableCancel, Duration, Effect, GetKeys, Join, KeyType, Listener, MaybePromise, Object_, Path, PathAsArray, PathAsString, Selector, SettablePath, SettablePathAsArray, SettablePathAsString, SettableValue, Store, StoreMethods, StoreOptions, StoreOptionsWithMethods, SubscribeOptions, Update, UpdateFrom, UpdateFunction, Use, Value$1 as Value, WildcardPath, WildcardPathAsString, WildcardValue, arrayMethods, createStore, mapMethods, recordMethods, setMethods };
243
- //# sourceMappingURL=store-MBrcOgtz.d.cts.map
242
+ export { GetKeys as A, Value as B, Selector as C, UpdateFunction as D, UpdateFrom as E, PathAsString as F, MaybePromise as G, WildcardPathAsString as H, SettablePath as I, Constrain as K, SettablePathAsArray as L, KeyType as M, Path as N, Use as O, PathAsArray as P, SettablePathAsString as R, Listener as S, Update as T, WildcardValue as U, WildcardPath as V, Object_ as W, Connection as _, StoreOptions as a, Duration as b, arrayMethods as c, setMethods as d, AsyncConnectionActions as f, Cancel as g, CalculationActions as h, StoreMethods as i, Join as j, AnyPath as k, mapMethods as l, BaseConnectionActions as m, Calculate as n, StoreOptionsWithMethods as o, AsyncUpdateFunction as p, Store as r, createStore as s, BoundStoreMethods as t, recordMethods as u, ConnectionActions as v, SubscribeOptions as w, Effect as x, DisposableCancel as y, SettableValue as z };
243
+ //# sourceMappingURL=store-BRHFhRPm.d.ts.map
@@ -1,4 +1,4 @@
1
- const require_propAccess = require('./propAccess-BdLsqViO.cjs');
1
+ const require_propAccess = require('./propAccess-C2AIn9RC.cjs');
2
2
 
3
3
  //#region src/lib/autobind.ts
4
4
  const marker = Symbol("autobind");
@@ -330,8 +330,11 @@ function staticValue(value) {
330
330
 
331
331
  //#endregion
332
332
  //#region src/lib/makeSelector.ts
333
+ function identity(x) {
334
+ return x;
335
+ }
333
336
  function makeSelector(selector) {
334
- if (!selector) return (x) => x;
337
+ if (!selector) return identity;
335
338
  if (selector instanceof Function) return selector;
336
339
  return (x) => require_propAccess.get(x, selector);
337
340
  }
@@ -494,9 +497,7 @@ function throttle(action, duration) {
494
497
 
495
498
  //#endregion
496
499
  //#region src/core/store.ts
497
- function noop() {
498
- return void 0;
499
- }
500
+ function noop() {}
500
501
  var Store = class Store {
501
502
  static addHook(hook) {
502
503
  this.hooks ??= /* @__PURE__ */ new Set();
@@ -530,8 +531,7 @@ var Store = class Store {
530
531
  if (update instanceof Function) {
531
532
  const before = this.get();
532
533
  const valueBefore = require_propAccess.get(before, path);
533
- const valueAfter = update(valueBefore);
534
- update = require_propAccess.set(before, path, valueAfter);
534
+ update = require_propAccess.set(before, path, update(valueBefore));
535
535
  } else if (path.length > 0) update = require_propAccess.set(this.get(), path, update);
536
536
  if (this.derivedFrom) {
537
537
  this.derivedFrom.updater(update);
@@ -606,7 +606,9 @@ var Store = class Store {
606
606
  map(_selector, ...args) {
607
607
  const updater = _selector instanceof Function ? args[0] : (value) => (state) => require_propAccess.set(state, _selector, value);
608
608
  const selector = makeSelector(_selector);
609
- const derivedFrom = {
609
+ return new Store(({ use }) => {
610
+ return selector(use(this));
611
+ }, void 0, {
610
612
  store: this.derivedFrom ? this.derivedFrom.store : this,
611
613
  selectors: this.derivedFrom ? [...this.derivedFrom.selectors, _selector] : [_selector],
612
614
  updater: (value) => {
@@ -616,10 +618,7 @@ var Store = class Store {
616
618
  if (this.derivedFrom) this.derivedFrom.updater(update);
617
619
  else this.set(update);
618
620
  }
619
- };
620
- return new Store(({ use }) => {
621
- return selector(use(this));
622
- }, void 0, derivedFrom);
621
+ });
623
622
  }
624
623
  /** Add an effect that will be executed when the store becomes active, which means when it has at least one subscriber.
625
624
  * @param effect
@@ -818,4 +817,4 @@ Object.defineProperty(exports, 'throttle', {
818
817
  return throttle;
819
818
  }
820
819
  });
821
- //# sourceMappingURL=store-CdST5wJZ.cjs.map
820
+ //# sourceMappingURL=store-C1NYHLgR.cjs.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"store-C1NYHLgR.cjs","names":["state: ValueState<T> | ErrorState | PendingState","value","q: {\n action: Action<any>;\n resolve: (value: any) => void;\n reject: (error: unknown) => void;\n ref?: any;\n }[]","value: T | undefined","connection: { active: boolean; cancel?: Cancel } | undefined","value","cancel: Cancel | undefined","actions: AsyncConnectionActions<any>","_cancel: Cancel | undefined","deepEqual","get","run: (() => void) | undefined","timeout: ReturnType<typeof setTimeout> | undefined","timeoutStarted: number | undefined","debounce","arrayMethods: {\n [P in 'splice' | 'push' | 'pop' | 'shift' | 'unshift' | 'reverse' | 'sort']: <\n T extends Array<any>,\n >(\n this: Store<T>,\n ...args: T[P] extends Function_ ? Parameters<T[P]> : never\n ) => T[P] extends Function_ ? ReturnType<T[P]> : never;\n}","timeout: ReturnType<typeof setTimeout> | undefined","getter: T | Calculate<T>","options: StoreOptions<T>","derivedFrom?: {\n store: Store<any>;\n selectors: (Selector<any, any> | AnyPath)[];\n updater: (state: any) => void;\n }","path: any","update: Update<any>","get","set","deepEqual","previousValue: { value: T } | undefined","timer: ReturnType<typeof setTimeout> | undefined","updater: ((value: any) => Update<T>) | undefined","active","methods: StoreMethods | undefined","isObject","createStore: typeof create & { defaultOptions: StoreOptions<any> }"],"sources":["../src/lib/autobind.ts","../src/lib/calcDuration.ts","../src/lib/deferred.ts","../src/lib/isPromise.ts","../src/lib/promiseWithState.ts","../src/lib/queue.ts","../src/lib/calculatedValue.ts","../src/lib/makeSelector.ts","../src/lib/debounce.ts","../src/lib/disposable.ts","../src/lib/forwardError.ts","../src/lib/promiseWithCancel.ts","../src/lib/standardMethods.ts","../src/lib/throttle.ts","../src/core/store.ts"],"sourcesContent":["const marker = Symbol('autobind');\n\nexport const autobind = <\n TClass extends abstract new (...args: any) => any = abstract new (...args: any) => any,\n>(\n _class: TClass,\n): TClass => {\n for (const key of Reflect.ownKeys(_class.prototype)) {\n if (key === 'constructor') {\n continue;\n }\n\n const descriptor = Reflect.getOwnPropertyDescriptor(_class.prototype, key);\n let method = descriptor?.get?.() ?? descriptor?.value;\n let isBinding = false;\n\n if (typeof method !== 'function' || method[marker]) {\n continue;\n }\n\n Reflect.defineProperty(_class.prototype, key, {\n configurable: true,\n get() {\n if (\n isBinding ||\n this === _class.prototype ||\n Object.prototype.hasOwnProperty.call(this, key) ||\n typeof method !== 'function'\n ) {\n return method;\n }\n\n const boundMethod = (...args: any[]) => Reflect.apply(method, this, args);\n boundMethod[marker] = true;\n isBinding = true;\n\n Object.defineProperty(this, key, {\n configurable: true,\n get() {\n return boundMethod;\n },\n });\n\n isBinding = false;\n return boundMethod;\n },\n set(v) {\n method = v;\n },\n });\n }\n\n return _class;\n};\n","import type { Duration } from '../core/commonTypes';\n\nexport function calcDuration(t: Duration): number {\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","export class Deferred<T = void> extends Promise<T> {\n resolve: (value: T | PromiseLike<T>) => void = () => undefined;\n reject: (reason?: any) => void = () => undefined;\n\n constructor() {\n Object.defineProperty(Deferred, Symbol.species, {\n value: Promise,\n });\n\n const that = {};\n\n super((resolve, reject) => {\n Object.assign(that, { resolve, reject });\n });\n\n Object.assign(this, that);\n }\n}\n","export default function isPromise(value: unknown): value is Promise<unknown> {\n return (\n typeof value === 'object' &&\n value !== null &&\n 'then' in value &&\n typeof value.then === 'function'\n );\n}\n","import isPromise from '@lib/isPromise';\nimport { type ErrorState, type PendingState, type ValueState } from './cacheState';\nimport { type MaybePromise } from './maybePromise';\n\nexport class PromiseWithState<T> extends Promise<T> {\n static override resolve(): PromiseWithState<void>;\n\n static override resolve<T>(value: MaybePromise<T>): PromiseWithState<T>;\n\n static override resolve<T>(value?: MaybePromise<T>) {\n return new PromiseWithState<T>(value as MaybePromise<T>);\n }\n\n static override reject<T = never>(error: unknown): PromiseWithState<T> {\n return new PromiseWithState<T>(Promise.reject(error), { status: 'error', error });\n }\n\n constructor(\n value: MaybePromise<T>,\n public state: ValueState<T> | ErrorState | PendingState = { status: 'pending' },\n ) {\n super((resolve) => resolve(value));\n\n Object.defineProperty(PromiseWithState, Symbol.species, {\n value: Promise,\n });\n\n if (isPromise(value)) {\n value\n .then((value) => {\n this.state = { status: 'value', value: value };\n })\n .catch((error) => {\n this.state = { status: 'error', error };\n });\n } else {\n this.state = { status: 'value', value: value };\n }\n }\n}\n","import isPromise from '@lib/isPromise';\nimport 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 (isPromise(result)) {\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","import type { Cache } from '@core';\nimport type { AsyncConnectionActions, Cancel, Connection, StoreLike } from '@core/commonTypes';\nimport type { Store } from '@core/store';\nimport { Deferred } from '@lib/deferred';\nimport isPromise from '@lib/isPromise';\nimport { PromiseWithState } from '@lib/promiseWithState';\nimport { queue } from '@lib/queue';\nimport { deepEqual } from './equals';\n\nexport interface CalculatedValue<T> {\n value: T;\n check: () => void;\n stop(): void;\n invalidateDependencies(recursive?: boolean): void;\n}\n\nexport function calculatedValue<T>(store: Store<T>, notify: () => void): CalculatedValue<T> {\n if (!(store.getter instanceof Function)) {\n return staticValue(store.getter);\n }\n\n let active = false;\n const deps = new Array<{ store: StoreLike<any>; value: any; on: () => void; off: () => void }>();\n let value: T | undefined;\n const whenConnected = new Deferred();\n const whenExecuted = new Deferred();\n const ac = new AbortController();\n let connection: { active: boolean; cancel?: Cancel } | undefined;\n const q = queue();\n q(() => whenExecuted);\n\n const cancelEffect = store.addEffect(() => {\n if (connection) {\n store.invalidate();\n return;\n }\n\n active = true;\n\n for (const dep of deps) {\n dep.on();\n }\n\n return () => {\n active = false;\n\n for (const dep of deps) {\n dep.off();\n }\n\n if (connection) {\n connection.active = false;\n connection.cancel?.();\n q.clear();\n\n if ('state' in store) {\n (store as unknown as Cache<any>).state.set((state) => ({\n ...state,\n isConnected: false,\n isStale: true,\n }));\n }\n }\n };\n });\n\n function use<S>(dep: StoreLike<S>) {\n const value = dep.get();\n let cancel: Cancel | undefined;\n\n const on = () => {\n cancel ||= dep.subscribe(() => store.invalidate(), { runNow: false });\n };\n\n const off = () => {\n cancel?.();\n cancel = undefined;\n };\n\n deps.push({ store: dep, value, on, off });\n\n if (active) {\n on();\n }\n\n return value;\n }\n\n async function connect(createConnection: Connection<T>) {\n if (!active) {\n connection = { active: false };\n return;\n }\n\n const actions: AsyncConnectionActions<any> = {\n set(_value) {\n q(() => {\n if (!connection?.active) {\n return;\n }\n\n value = _value;\n notify();\n });\n },\n updateValue(update) {\n q(async () => {\n if (!connection?.active) {\n return;\n }\n\n if (update instanceof Function) {\n const currentValue = await value;\n\n if (!connection?.active) {\n return;\n }\n\n try {\n update = update(currentValue);\n } catch (error) {\n value = PromiseWithState.reject(error) as T;\n notify();\n connection.active = false;\n connection.cancel?.();\n return;\n }\n }\n\n value = PromiseWithState.resolve(update) as T;\n notify();\n });\n },\n updateError(error) {\n q(() => {\n if (!connection?.active) {\n return;\n }\n\n connection.active = false;\n connection.cancel?.();\n\n if ('state' in store) {\n (store as unknown as Cache<any>).state.set({\n status: 'error',\n error,\n isConnected: false,\n isUpdating: false,\n isStale: false,\n });\n }\n\n value = PromiseWithState.reject(error) as T;\n notify();\n });\n },\n updateIsConnected(isConnected) {\n if (isConnected) {\n whenConnected.resolve();\n }\n\n q(() => {\n if (!connection?.active) {\n return;\n }\n\n if ('state' in store) {\n (store as unknown as Cache<any>).state.set('isConnected', isConnected);\n }\n });\n },\n close() {\n if (connection?.active) {\n store.invalidate();\n }\n },\n };\n\n connection = { active: true };\n let _cancel: Cancel | undefined = createConnection(actions as any);\n\n connection.cancel = () => {\n _cancel?.();\n _cancel = undefined;\n };\n\n if (!connection.active) {\n connection.cancel();\n }\n\n return whenConnected;\n }\n\n try {\n value = store.getter({ signal: ac.signal, use, connect });\n } catch (error) {\n value = PromiseWithState.reject(error) as T;\n\n if (connection) {\n connection.active = false;\n connection.cancel?.();\n q.clear();\n }\n }\n\n if (isPromise(value)) {\n value.finally(() => whenExecuted.resolve()).catch(() => undefined);\n } else {\n whenExecuted.resolve();\n }\n\n function check() {\n if (store.options.cacheValue === false) {\n return false;\n }\n\n for (const dep of deps) {\n if (!deepEqual(dep.store.get(), dep.value)) {\n return false;\n }\n }\n return true;\n }\n\n function stop() {\n cancelEffect();\n whenExecuted.resolve();\n whenConnected.resolve();\n ac.abort();\n\n if (connection) {\n connection.active = false;\n connection.cancel?.();\n q.clear();\n }\n }\n\n function invalidateDependencies(recursive?: boolean) {\n for (const dep of deps) {\n dep.store.invalidate(recursive);\n }\n }\n\n return {\n get value() {\n return value!;\n },\n check,\n stop,\n invalidateDependencies,\n };\n}\n\nexport function staticValue<T>(value: T): CalculatedValue<T> {\n return {\n value,\n check: () => true,\n stop: () => undefined,\n invalidateDependencies: () => undefined,\n };\n}\n\nexport function staleValue<T>(value: T): CalculatedValue<T> {\n return {\n value,\n check: () => false,\n stop: () => undefined,\n invalidateDependencies: () => undefined,\n };\n}\n","import type { AnyPath } from './path';\nimport { get } from './propAccess';\n\nfunction identity<T>(x: T): T {\n return x;\n}\n\nexport function makeSelector<T, S>(selector?: ((value: T) => S) | AnyPath): (value: T) => S {\n if (!selector) {\n return identity as (value: T) => S;\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 { calcDuration } from './calcDuration';\nimport type { Duration } from '@core';\n\nexport type DebounceOptions =\n | Duration\n | {\n wait: Duration;\n maxWait?: Duration;\n waitOnRunNow?: boolean;\n };\n\nexport function debounce<Args extends any[]>(\n action: (...args: Args) => void,\n options: Duration | DebounceOptions,\n): {\n (...args: Args): void;\n flush(): void;\n cancel(): void;\n isScheduled(): boolean;\n} {\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 run: (() => void) | undefined;\n let timeout: ReturnType<typeof setTimeout> | undefined;\n let timeoutStarted: number | undefined;\n\n function flush() {\n if (timeout !== undefined) {\n clearTimeout(timeout);\n }\n\n run?.();\n }\n\n function cancel() {\n if (timeout !== undefined) {\n clearTimeout(timeout);\n }\n\n run = undefined;\n timeout = undefined;\n timeoutStarted = undefined;\n }\n\n function isScheduled() {\n return timeout !== undefined;\n }\n\n function debounce(...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 run = () => {\n run = undefined;\n timeout = undefined;\n timeoutStarted = undefined;\n\n action(...args);\n };\n\n timeout = setTimeout(run, deadline - now);\n }\n\n return Object.assign(debounce, { flush, cancel, isScheduled });\n}\n","import type { Cancel } from '@core';\nimport type { DisposableCancel } from '@core/commonTypes';\n\nexport default function disposable(dispose: Cancel): DisposableCancel {\n return Object.assign(\n dispose,\n Symbol.dispose ? { [Symbol.dispose]: dispose } : {},\n ) as DisposableCancel;\n}\n","export function forwardError(error: unknown): void {\n setTimeout(() => {\n throw error;\n });\n}\n","import { autobind } from '@lib/autobind';\n\nexport class PromiseCancelError extends Error {\n constructor() {\n super('cancelled');\n }\n}\n\nexport class PromiseWithCancel<T> extends Promise<T> {\n private abortController;\n\n constructor(\n executor: (\n resolve: (value: T) => void,\n reject: (error: unknown) => void,\n signal: AbortSignal,\n ) => void,\n ) {\n autobind(PromiseWithCancel);\n const abortController = new AbortController();\n\n super((resolve, reject) => {\n executor(resolve, reject, abortController.signal);\n\n abortController.signal.addEventListener('abort', () => {\n reject(abortController.signal.reason);\n });\n });\n\n this.abortController = abortController;\n }\n\n cancel(reason: any = new PromiseCancelError()): void {\n this.abortController.abort(reason);\n }\n}\n","import type { Store } from '../core/store';\nimport type { OptionalProperties, 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 [P in 'splice' | 'push' | 'pop' | 'shift' | 'unshift' | 'reverse' | 'sort']: <\n T extends Array<any>,\n >(\n this: Store<T>,\n ...args: T[P] extends Function_ ? Parameters<T[P]> : never\n ) => T[P] extends Function_ ? ReturnType<T[P]> : never;\n} = {\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>>(\n this: Store<T>,\n key: K,\n ): void {\n const copy = { ...this.get() };\n delete copy[key];\n this.set(copy);\n },\n\n clear<T extends Record<any, any>>(\n this: OptionalProperties<T> extends T ? Store<T> : never,\n ): void {\n this.set({} as T);\n },\n};\n\nexport const mapMethods = {\n delete<K, V>(this: Store<Map<K, V>>, key: K): boolean {\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>>): void {\n this.set(new Map());\n },\n};\n\nexport const setMethods = {\n add<T>(this: Store<Set<T>>, value: T): void {\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): void {\n const newSet = new Set(this.get());\n newSet.delete(value);\n this.set(newSet);\n },\n\n clear<T>(this: Store<Set<T>>): void {\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 { autobind } from '@lib/autobind';\nimport { calcDuration } from '@lib/calcDuration';\nimport { calculatedValue, staticValue, type CalculatedValue } from '@lib/calculatedValue';\nimport type { Constrain } from '@lib/constrain';\nimport { debounce } from '@lib/debounce';\nimport disposable from '@lib/disposable';\nimport { deepEqual } from '@lib/equals';\nimport { forwardError } from '@lib/forwardError';\nimport { isObject } from '@lib/helpers';\nimport { makeSelector } from '@lib/makeSelector';\nimport type { AnyPath, Path, SettablePath, Value } from '@lib/path';\nimport { PromiseWithCancel } from '@lib/promiseWithCancel';\nimport { get, set } from '@lib/propAccess';\nimport { arrayMethods, mapMethods, recordMethods, setMethods } from '@lib/standardMethods';\nimport { throttle } from '@lib/throttle';\nimport type {\n CalculationActions,\n Cancel,\n DisposableCancel,\n Duration,\n Effect,\n Listener,\n Selector,\n SubscribeOptions,\n Update,\n} from './commonTypes';\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<T> {\n retain?: Duration;\n equals?: SubscribeOptions['equals'];\n effect?: Effect<Store<T>> | { effect: Effect<Store<T>>; retain?: Duration };\n cacheValue?: boolean;\n}\n\nexport interface StoreOptionsWithMethods<T, Methods extends StoreMethods> extends StoreOptions<T> {\n methods?: Methods & ThisType<Store<T> & Methods & StandardMethods<T>>;\n}\n\nexport type Calculate<T> = (helpers: CalculationActions<T>) => T;\n\ntype StandardMethods<T> =\n 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\nexport interface OnceOptions {\n signal?: AbortSignal;\n timeout?: Duration;\n}\n\nfunction noop() {\n return undefined;\n}\n\nexport class Store<T> {\n private static hooks?: Set<(this: Store<any>, store: Store<any>) => void>;\n\n static addHook(hook: (store: Store<any>) => void): DisposableCancel {\n this.hooks ??= new Set();\n this.hooks.add(hook);\n return disposable(() => this.hooks?.delete(hook));\n }\n\n version?: string;\n\n protected calculatedValue?: CalculatedValue<T>;\n protected defaultValue?: CalculatedValue<T>;\n\n protected listeners: Map<Listener, boolean> = new Map();\n\n protected effects: Map<\n Effect<Store<T>>,\n { handle?: Cancel; retain?: number; timeout?: ReturnType<typeof setTimeout> }\n > = new Map();\n\n protected notifyId = {};\n\n constructor(\n public readonly getter: T | Calculate<T>,\n public readonly options: StoreOptions<T> = {},\n public readonly derivedFrom?: {\n store: Store<any>;\n selectors: (Selector<any, any> | AnyPath)[];\n updater: (state: any) => void;\n },\n ) {\n autobind(Store);\n\n if (typeof getter !== 'function') {\n this.calculatedValue = this.defaultValue = staticValue(getter);\n }\n\n for (const hook of Store.hooks ?? []) {\n hook.apply(this, [this]);\n }\n\n if (options.effect instanceof Function) {\n this.addEffect(options.effect);\n } else if (options.effect) {\n this.addEffect(options.effect.effect, options.effect.retain);\n }\n }\n\n get(): T {\n if (!this.calculatedValue?.check()) {\n this.calculatedValue?.stop();\n this.calculatedValue = undefined;\n }\n\n if (!this.calculatedValue) {\n this.calculatedValue = calculatedValue(this, this.notify);\n }\n\n return this.calculatedValue.value;\n }\n\n set(update: Update<T>): void;\n\n set<const P>(path: Constrain<P, Path<T>>, 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.calculatedValue?.stop();\n this.calculatedValue = staticValue(update);\n this.notify();\n }\n\n invalidate(recursive?: boolean): void {\n if (recursive) {\n this.calculatedValue?.invalidateDependencies(recursive);\n }\n\n this.calculatedValue?.stop();\n this.calculatedValue = this.defaultValue;\n this.notify();\n }\n\n subscribe(\n listener: Listener<T, { cancel: Cancel }>,\n options?: SubscribeOptions,\n ): DisposableCancel {\n const {\n passive,\n runNow = true,\n throttle: throttleOption,\n debounce: debounceOption,\n equals = this.options.equals ?? deepEqual,\n } = options ?? {};\n\n let isSetup = false;\n let previousValue: { value: T } | undefined;\n\n let innerListener = () => {\n if (!isSetup) {\n return;\n }\n\n const value = passive ? this.calculatedValue : { value: this.get() };\n\n if (!value) {\n return;\n }\n\n if (previousValue && equals(value.value, previousValue.value)) {\n return;\n }\n\n const _previousValue = previousValue?.value;\n previousValue = this.calculatedValue && { value: this.calculatedValue?.value };\n\n try {\n listener.apply({ cancel }, [value.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 const cancel = () => {\n if (this.listeners.delete(innerListener) && !passive) {\n this.onUnsubscribe();\n }\n };\n\n if (!passive) {\n this.onSubscribe();\n }\n\n isSetup = true;\n\n if (runNow) {\n innerListener();\n\n if (\n !throttleOption &&\n typeof debounceOption === 'object' &&\n 'waitOnRunNow' in debounceOption &&\n debounceOption.waitOnRunNow === false &&\n 'flush' in innerListener\n ) {\n (innerListener as { flush: () => void }).flush();\n }\n } else {\n previousValue = passive\n ? this.calculatedValue && { value: this.calculatedValue.value }\n : { value: this.get() };\n }\n\n return disposable(cancel);\n }\n\n once<S extends T>(\n condition: (value: T) => value is S,\n options?: OnceOptions,\n ): PromiseWithCancel<S>;\n\n once(condition: (value: T) => boolean, options?: OnceOptions): PromiseWithCancel<T>;\n\n once(options?: OnceOptions): PromiseWithCancel<Exclude<T, undefined>>;\n\n once(\n ...args: [condition: (value: any) => boolean, options?: OnceOptions] | [options?: OnceOptions]\n ): PromiseWithCancel<any> {\n const condition = args[0] instanceof Function ? args[0] : (x: T) => x !== undefined;\n const options = args[0] instanceof Function ? args[1] : args[0];\n\n return new PromiseWithCancel<T>((resolve, reject, signal) => {\n let stopped = false;\n let timer: ReturnType<typeof setTimeout> | undefined;\n\n const cancel = this.subscribe(\n (value) => {\n if (stopped || !condition(value)) {\n return;\n }\n\n resolve(value);\n stopped = true;\n if (timer) {\n clearTimeout(timer);\n }\n setTimeout(() => cancel());\n },\n {\n runNow: !!condition,\n },\n );\n\n if (stopped) {\n return;\n }\n\n signal.addEventListener('abort', cancel);\n\n options?.signal?.addEventListener('abort', () => {\n cancel();\n reject(options.signal?.reason ?? new Error('cancelled'));\n });\n\n if (options?.timeout !== undefined) {\n timer = setTimeout(() => {\n cancel();\n reject(new Error('timeout'));\n }, calcDuration(options.timeout));\n }\n });\n }\n\n map<S>(selector: Selector<T, S>, updater?: (value: S) => Update<T>): Store<S>;\n\n map<const P>(selector: Constrain<P, SettablePath<T>>): Store<Value<T, P>>;\n\n map(_selector: Selector<T, any> | SettablePath<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 any, value);\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 update 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));\n },\n undefined,\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(\n effect: Effect<Store<T>>,\n retain: Duration | undefined = this.options.retain,\n ): DisposableCancel {\n this.effects.set(effect, {\n handle: this.isActive() ? (effect.apply(this, [this]) ?? noop) : undefined,\n retain: retain !== undefined ? calcDuration(retain) : undefined,\n });\n\n return disposable(() => {\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(): boolean {\n return [...this.listeners.values()].some(Boolean);\n }\n\n protected onSubscribe(): void {\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.apply(this, [this]) ?? noop,\n retain,\n timeout: undefined,\n });\n }\n }\n\n protected onUnsubscribe(): void {\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 if (timeout !== undefined) {\n clearTimeout(timeout);\n }\n\n this.effects.set(effect, {\n handle: undefined,\n retain,\n timeout: undefined,\n });\n\n continue;\n }\n\n const newTimeout =\n timeout ??\n (handle\n ? setTimeout(() => {\n handle();\n this.effects.set(effect, {\n handle: undefined,\n retain,\n timeout: undefined,\n });\n }, retain)\n : undefined);\n\n this.effects.set(effect, {\n handle,\n retain,\n timeout: newTimeout,\n });\n }\n }\n\n protected notify(): void {\n const n = {};\n this.notifyId = n;\n\n const snapshot = [...this.listeners.entries()];\n const active = snapshot.filter(([, active]) => active);\n const passive = snapshot.filter(([, active]) => !active);\n for (const [listener] of [...active, ...passive]) {\n listener();\n if (n !== this.notifyId) break;\n }\n }\n}\n\nfunction create<T>(calculate: Calculate<T>, options?: StoreOptions<T>): 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 | Calculate<T>,\n options?: StoreOptionsWithMethods<T, Methods>,\n): StoreWithMethods<T, Methods> | Store<T> {\n options = { ...createStore.defaultOptions, ...options };\n\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 (isObject(initialState)) {\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: typeof create & { defaultOptions: StoreOptions<any> } =\n /* @__PURE__ */ Object.assign(create, {\n defaultOptions: {\n equals: deepEqual,\n } as StoreOptions<any>,\n });\n"],"mappings":";;;AAAA,MAAM,SAAS,OAAO,WAAW;AAEjC,MAAa,YAGX,WACW;AACX,MAAK,MAAM,OAAO,QAAQ,QAAQ,OAAO,UAAU,EAAE;AACnD,MAAI,QAAQ,cACV;EAGF,MAAM,aAAa,QAAQ,yBAAyB,OAAO,WAAW,IAAI;EAC1E,IAAI,SAAS,YAAY,OAAO,IAAI,YAAY;EAChD,IAAI,YAAY;AAEhB,MAAI,OAAO,WAAW,cAAc,OAAO,QACzC;AAGF,UAAQ,eAAe,OAAO,WAAW,KAAK;GAC5C,cAAc;GACd,MAAM;AACJ,QACE,aACA,SAAS,OAAO,aAChB,OAAO,UAAU,eAAe,KAAK,MAAM,IAAI,IAC/C,OAAO,WAAW,WAElB,QAAO;IAGT,MAAM,eAAe,GAAG,SAAgB,QAAQ,MAAM,QAAQ,MAAM,KAAK;AACzE,gBAAY,UAAU;AACtB,gBAAY;AAEZ,WAAO,eAAe,MAAM,KAAK;KAC/B,cAAc;KACd,MAAM;AACJ,aAAO;;KAEV,CAAC;AAEF,gBAAY;AACZ,WAAO;;GAET,IAAI,GAAG;AACL,aAAS;;GAEZ,CAAC;;AAGJ,QAAO;;;;;AClDT,SAAgB,aAAa,GAAqB;AAChD,KAAI,OAAO,MAAM,SAAU,QAAO;AAClC,SACG,EAAE,gBAAgB,MAClB,EAAE,WAAW,KAAK,OAClB,EAAE,WAAW,KAAK,KAAK,OACvB,EAAE,SAAS,KAAK,KAAK,KAAK,OAC1B,EAAE,QAAQ,KAAK,KAAK,KAAK,KAAK;;;;;ACTnC,IAAa,WAAb,MAAa,iBAA2B,QAAW;CAIjD,cAAc;AACZ,SAAO,eAAe,UAAU,OAAO,SAAS,EAC9C,OAAO,SACR,CAAC;EA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WAAU;EAAE,GAAG,YAAY;EAAgB,GAAG;EAAS;CAEvD,MAAM,QAAQ,IAAI,MAAM,cAAc,QAAQ;AAE9C,KAAI,wBAAwB,SAC1B,QAAO;CAGT,IAAIC,UAAoC,SAAS;AAEjD,KAAI,wBAAwB,IAC1B,WAAU;EAAE,GAAG;EAAY,GAAG;EAAS;UAC9B,wBAAwB,IACjC,WAAU;EAAE,GAAG;EAAY,GAAG;EAAS;UAC9B,MAAM,QAAQ,aAAa,CACpC,WAAU;EAAE,GAAG;EAAc,GAAG;EAAS;UAChCC,4BAAS,aAAa,CAC/B,WAAU;EAAE,GAAG;EAAe,GAAG;EAAS;CAG5C,MAAM,eAAe,OAAO,YAC1B,OAAO,QAAQ,WAAY,EAAE,CAA+B,CACzD,QAAQ,CAAC,UAAU,EAAE,QAAQ,OAAO,CACpC,KAAK,CAAC,MAAM,YAAY,CAAC,MAAO,OAAe,KAAK,MAAM,CAAC,CAAC,CAChE;AAED,QAAO,OAAO,OAAO,OAAO,aAAa;;AAG3C,MAAaC,cACK,uBAAO,OAAO,QAAQ,EACpC,gBAAgB,EACd,QAAQP,8BACT,EACF,CAAC"}
@@ -1,5 +1,5 @@
1
1
  //#region src/lib/constrain.d.ts
2
- type Constrain<T, S> = T & S;
2
+ type Constrain<T, S$1> = T & S$1;
3
3
  //#endregion
4
4
  //#region src/lib/maybePromise.d.ts
5
5
  type MaybePromise<T> = T | Promise<T>;
@@ -23,18 +23,18 @@ type _PathAsArray<T, Optional, MaxDepth, Depth extends 1[]> = (Optional extends
23
23
  type PathAsArray<T, Optional extends boolean = false, MaxDepth extends number = 5> = _PathAsArray<T, Optional, MaxDepth, []>;
24
24
  type PathAsString<T, Optional extends boolean = false, MaxDepth extends number = 5> = ArrayToStringPath<PathAsArray<T, Optional, MaxDepth>>;
25
25
  type Path<T, Optional extends boolean = false, MaxDepth extends number = 5> = PathAsString<T, Optional, MaxDepth> | PathAsArray<T, Optional, MaxDepth>;
26
- type Value$1<T, P> = P extends readonly [] ? T : true extends IsAny<T> | IsAny<P> ? any : true extends IsNever<T> | IsNever<P> ? never : P extends string ? Value$1<T, StringToArrayPath<P>> : P extends readonly [infer First extends KeyType, ...infer Rest extends readonly KeyType[]] ? T extends Map<any, infer V> | Set<infer V> ? Value$1<V, Rest> | undefined : T extends Array_ ? any[] extends T ? Value$1<T[First & keyof T], Rest> | undefined : Value$1<T[First & keyof T], Rest> : T extends Object_ ? Record<any, any> extends T ? Value$1<T[First], Rest> | undefined : Value$1<T[First], Rest> : never : never;
26
+ type Value<T, P$1> = P$1 extends readonly [] ? T : true extends IsAny<T> | IsAny<P$1> ? any : true extends IsNever<T> | IsNever<P$1> ? never : P$1 extends string ? Value<T, StringToArrayPath<P$1>> : P$1 extends readonly [infer First extends KeyType, ...infer Rest extends readonly KeyType[]] ? T extends Map<any, infer V> | Set<infer V> ? Value<V, Rest> | undefined : T extends Array_ ? any[] extends T ? Value<T[First & keyof T], Rest> | undefined : Value<T[First & keyof T], Rest> : T extends Object_ ? Record<any, any> extends T ? Value<T[First], Rest> | undefined : Value<T[First], Rest> : never : never;
27
27
  type _WildcardPathAsArray<T, MaxDepth, Depth extends 1[]> = [] | (0 extends 1 & T ? KeyType[] : T extends never ? never : T extends Object_ ? Depth["length"] extends MaxDepth ? string[] : T extends Map<infer K extends KeyType, infer V> ? ["*"] | [K] | [K, ..._WildcardPathAsArray<V, MaxDepth, [...Depth, 1]>] : T extends Set<any> ? ["*"] | [number] : Record<string, any> extends T ? ["*"] | ["*", ..._WildcardPathAsArray<T[string], MaxDepth, [...Depth, 1]>] : { [K in GetKeys<T>]: ["*"] | ["*", ..._WildcardPathAsArray<T[T extends readonly any[] ? number : keyof T], MaxDepth, [...Depth, 1]>] | [K] | [K, ..._WildcardPathAsArray<T[K], MaxDepth, [...Depth, 1]>] }[GetKeys<T>] : never);
28
28
  type WildcardPathAsArray<T, MaxDepth extends number = 5> = _WildcardPathAsArray<T, MaxDepth, []>;
29
29
  type WildcardPathAsString<T, MaxDepth extends number = 5> = ArrayToStringPath<_WildcardPathAsArray<T, MaxDepth, []>>;
30
30
  type WildcardPath<T, MaxDepth extends number = 5> = WildcardPathAsString<T, MaxDepth> | WildcardPathAsArray<T, MaxDepth>;
31
- type WildcardValue<T, P> = true extends IsAny<T> | IsAny<P> ? any : true extends IsNever<T> | IsNever<P> ? never : P extends string ? WildcardValue<T, StringToArrayPath<P>> : P extends readonly [infer First extends KeyType, ...infer Rest extends KeyType[]] ? T extends Map<any, infer V> | Set<infer V> ? WildcardValue<V, Rest> | (First extends "*" ? never : undefined) : T extends Array_ ? First extends "*" ? WildcardValue<T[number], Rest> : any[] extends T ? WildcardValue<T[First & keyof T], Rest> | undefined : First extends keyof T ? WildcardValue<T[First], Rest> : undefined : T extends Object_ ? First extends "*" ? WildcardValue<T[keyof T], Rest> : Record<any, any> extends T ? WildcardValue<T[First], Rest> | undefined : WildcardValue<T[First], Rest> : never : T;
31
+ type WildcardValue<T, P$1> = true extends IsAny<T> | IsAny<P$1> ? any : true extends IsNever<T> | IsNever<P$1> ? never : P$1 extends string ? WildcardValue<T, StringToArrayPath<P$1>> : P$1 extends readonly [infer First extends KeyType, ...infer Rest extends KeyType[]] ? T extends Map<any, infer V> | Set<infer V> ? WildcardValue<V, Rest> | (First extends "*" ? never : undefined) : T extends Array_ ? First extends "*" ? WildcardValue<T[number], Rest> : any[] extends T ? WildcardValue<T[First & keyof T], Rest> | undefined : First extends keyof T ? WildcardValue<T[First], Rest> : undefined : T extends Object_ ? First extends "*" ? WildcardValue<T[keyof T], Rest> : Record<any, any> extends T ? WildcardValue<T[First], Rest> | undefined : WildcardValue<T[First], Rest> : never : T;
32
32
  type Join<A extends string | number, B extends string | number> = A extends "" ? B : B extends "" ? A : `${A}.${B}`;
33
33
  type _SettablePathAsArray<T, MaxDepth, Depth extends 1[]> = readonly [] | (true extends IsAny<T> ? readonly KeyType[] : undefined extends T ? T extends Map<any, any> | Set<any> ? never : T extends Object_ ? { [K in GetKeys<T>]: Partial<T> extends Omit<T, K> ? readonly [K] | readonly [K, ..._SettablePathAsArray<T[K], MaxDepth, [...Depth, 1]>] : readonly [] }[GetKeys<T>] : never : T extends never ? never : T extends Object_ ? Depth["length"] extends MaxDepth ? readonly string[] : T extends Map<infer K extends KeyType, infer V> ? readonly [K] | readonly [K, ..._SettablePathAsArray<V, MaxDepth, [...Depth, 1]>] : T extends Set<any> ? readonly [number] : { [K in GetKeys<T>]: readonly [K] | readonly [K, ..._SettablePathAsArray<T[K], MaxDepth, [...Depth, 1]>] }[GetKeys<T>] : never);
34
34
  type SettablePathAsArray<T, MaxDepth extends number = 5> = _SettablePathAsArray<T, MaxDepth, []>;
35
35
  type SettablePathAsString<T, MaxDepth extends number = 5> = ArrayToStringPath<SettablePathAsArray<T, MaxDepth>>;
36
36
  type SettablePath<T, MaxDepth extends number = 5> = SettablePathAsString<T, MaxDepth> | SettablePathAsArray<T, MaxDepth>;
37
- type SettableValue<T, P> = P extends readonly [] ? T : true extends IsAny<T> | IsAny<P> ? any : true extends IsNever<T> | IsNever<P> ? never : P extends string ? SettableValue<T, StringToArrayPath<P>> : P extends readonly [infer First extends KeyType, ...infer Rest extends readonly KeyType[]] ? T extends Map<any, infer V> | Set<infer V> ? SettableValue<V, Rest> : T extends Array_ ? SettableValue<T[First & keyof T], Rest> : T extends Object_ ? SettableValue<T[First], Rest> : never : never;
37
+ type SettableValue<T, P$1> = P$1 extends readonly [] ? T : true extends IsAny<T> | IsAny<P$1> ? any : true extends IsNever<T> | IsNever<P$1> ? never : P$1 extends string ? SettableValue<T, StringToArrayPath<P$1>> : P$1 extends readonly [infer First extends KeyType, ...infer Rest extends readonly KeyType[]] ? T extends Map<any, infer V> | Set<infer V> ? SettableValue<V, Rest> : T extends Array_ ? SettableValue<T[First & keyof T], Rest> : T extends Object_ ? SettableValue<T[First], Rest> : never : never;
38
38
  //#endregion
39
39
  //#region src/lib/debounce.d.ts
40
40
  type DebounceOptions = Duration | {
@@ -47,8 +47,8 @@ type DebounceOptions = Duration | {
47
47
  interface Listener<T = void, TThis = unknown> {
48
48
  (this: TThis, value: T, previouseValue?: T): void;
49
49
  }
50
- interface Selector<T, S> {
51
- (value: T): S;
50
+ interface Selector<T, S$1> {
51
+ (value: T): S$1;
52
52
  }
53
53
  interface Effect<T> {
54
54
  (this: T, context: T): void | Cancel;
@@ -88,13 +88,13 @@ type Duration = number | {
88
88
  hours?: number;
89
89
  days?: number;
90
90
  };
91
- type UpdateFrom<Value, From extends any[]> = Value | ((...args: From) => Value);
92
- type Update<Value> = UpdateFrom<Value, [Value]>;
93
- interface UpdateFunction<Value> {
94
- (update: Update<Value>): void;
91
+ type UpdateFrom<Value$1, From extends any[]> = Value$1 | ((...args: From) => Value$1);
92
+ type Update<Value$1> = UpdateFrom<Value$1, [Value$1]>;
93
+ interface UpdateFunction<Value$1> {
94
+ (update: Update<Value$1>): void;
95
95
  }
96
- interface AsyncUpdateFunction<Value> {
97
- (update: UpdateFrom<MaybePromise<Value>, [Value]>): void;
96
+ interface AsyncUpdateFunction<Value$1> {
97
+ (update: UpdateFrom<MaybePromise<Value$1>, [Value$1]>): void;
98
98
  }
99
99
  interface StoreLike<T> {
100
100
  get(): T;
@@ -144,12 +144,12 @@ declare class PromiseWithCancel<T> extends Promise<T> {
144
144
  type Function_ = (...args: any) => any;
145
145
  declare const arrayMethods: { [P in "splice" | "push" | "pop" | "shift" | "unshift" | "reverse" | "sort"]: <T extends Array<any>>(this: Store<T>, ...args: T[P] extends Function_ ? Parameters<T[P]> : never) => T[P] extends Function_ ? ReturnType<T[P]> : never };
146
146
  declare const recordMethods: {
147
- delete<T extends Record<any, any>, K extends OptionalPropertyOf<T>>(this: Store<T>, key: K): void;
147
+ delete<T extends Record<any, any>, K$1 extends OptionalPropertyOf<T>>(this: Store<T>, key: K$1): void;
148
148
  clear<T extends Record<any, any>>(this: OptionalProperties<T> extends T ? Store<T> : never): void;
149
149
  };
150
150
  declare const mapMethods: {
151
- delete<K, V>(this: Store<Map<K, V>>, key: K): boolean;
152
- clear<K, V>(this: Store<Map<K, V>>): void;
151
+ delete<K$1, V$1>(this: Store<Map<K$1, V$1>>, key: K$1): boolean;
152
+ clear<K$1, V$1>(this: Store<Map<K$1, V$1>>): void;
153
153
  };
154
154
  declare const setMethods: {
155
155
  add<T>(this: Store<Set<T>>, value: T): void;
@@ -206,16 +206,16 @@ declare class Store<T> {
206
206
  } | undefined);
207
207
  get(): T;
208
208
  set(update: Update<T>): void;
209
- set<const P>(path: Constrain<P, Path<T>>, update: Update<Value$1<T, P>>): void;
209
+ set<const P$1>(path: Constrain<P$1, Path<T>>, update: Update<Value<T, P$1>>): void;
210
210
  invalidate(recursive?: boolean): void;
211
211
  subscribe(listener: Listener<T, {
212
212
  cancel: Cancel;
213
213
  }>, options?: SubscribeOptions): DisposableCancel;
214
- once<S extends T>(condition: (value: T) => value is S, options?: OnceOptions): PromiseWithCancel<S>;
214
+ once<S$1 extends T>(condition: (value: T) => value is S$1, options?: OnceOptions): PromiseWithCancel<S$1>;
215
215
  once(condition: (value: T) => boolean, options?: OnceOptions): PromiseWithCancel<T>;
216
216
  once(options?: OnceOptions): PromiseWithCancel<Exclude<T, undefined>>;
217
- map<S>(selector: Selector<T, S>, updater?: (value: S) => Update<T>): Store<S>;
218
- map<const P>(selector: Constrain<P, SettablePath<T>>): Store<Value$1<T, P>>;
217
+ map<S$1>(selector: Selector<T, S$1>, updater?: (value: S$1) => Update<T>): Store<S$1>;
218
+ map<const P$1>(selector: Constrain<P$1, SettablePath<T>>): Store<Value<T, P$1>>;
219
219
  /** Add an effect that will be executed when the store becomes active, which means when it has at least one subscriber.
220
220
  * @param effect
221
221
  * If there is already a subscriber, the effect will be executed immediately.
@@ -239,5 +239,5 @@ declare const createStore: typeof create & {
239
239
  defaultOptions: StoreOptions<any>;
240
240
  };
241
241
  //#endregion
242
- export { AnyPath, AsyncConnectionActions, AsyncUpdateFunction, BaseConnectionActions, BoundStoreMethods, Calculate, CalculationActions, Cancel, Connection, ConnectionActions, Constrain, DisposableCancel, Duration, Effect, GetKeys, Join, KeyType, Listener, MaybePromise, Object_, Path, PathAsArray, PathAsString, Selector, SettablePath, SettablePathAsArray, SettablePathAsString, SettableValue, Store, StoreMethods, StoreOptions, StoreOptionsWithMethods, SubscribeOptions, Update, UpdateFrom, UpdateFunction, Use, Value$1 as Value, WildcardPath, WildcardPathAsString, WildcardValue, arrayMethods, createStore, mapMethods, recordMethods, setMethods };
243
- //# sourceMappingURL=store-DnZ6fsiJ.d.ts.map
242
+ export { GetKeys as A, Value as B, Selector as C, UpdateFunction as D, UpdateFrom as E, PathAsString as F, MaybePromise as G, WildcardPathAsString as H, SettablePath as I, Constrain as K, SettablePathAsArray as L, KeyType as M, Path as N, Use as O, PathAsArray as P, SettablePathAsString as R, Listener as S, Update as T, WildcardValue as U, WildcardPath as V, Object_ as W, Connection as _, StoreOptions as a, Duration as b, arrayMethods as c, setMethods as d, AsyncConnectionActions as f, Cancel as g, CalculationActions as h, StoreMethods as i, Join as j, AnyPath as k, mapMethods as l, BaseConnectionActions as m, Calculate as n, StoreOptionsWithMethods as o, AsyncUpdateFunction as p, Store as r, createStore as s, BoundStoreMethods as t, recordMethods as u, ConnectionActions as v, SubscribeOptions as w, Effect as x, DisposableCancel as y, SettableValue as z };
243
+ //# sourceMappingURL=store-XcnTdeiJ.d.cts.map
@@ -1,4 +1,4 @@
1
- import { deepEqual, get, isObject, set } from "./propAccess-B260LXN1.js";
1
+ import { a as set, c as deepEqual, n as get, o as isObject } from "./propAccess-DvWFpYoj.js";
2
2
 
3
3
  //#region src/lib/autobind.ts
4
4
  const marker = Symbol("autobind");
@@ -330,8 +330,11 @@ function staticValue(value) {
330
330
 
331
331
  //#endregion
332
332
  //#region src/lib/makeSelector.ts
333
+ function identity(x) {
334
+ return x;
335
+ }
333
336
  function makeSelector(selector) {
334
- if (!selector) return (x) => x;
337
+ if (!selector) return identity;
335
338
  if (selector instanceof Function) return selector;
336
339
  return (x) => get(x, selector);
337
340
  }
@@ -494,9 +497,7 @@ function throttle(action, duration) {
494
497
 
495
498
  //#endregion
496
499
  //#region src/core/store.ts
497
- function noop() {
498
- return void 0;
499
- }
500
+ function noop() {}
500
501
  var Store = class Store {
501
502
  static addHook(hook) {
502
503
  this.hooks ??= /* @__PURE__ */ new Set();
@@ -530,8 +531,7 @@ var Store = class Store {
530
531
  if (update instanceof Function) {
531
532
  const before = this.get();
532
533
  const valueBefore = get(before, path);
533
- const valueAfter = update(valueBefore);
534
- update = set(before, path, valueAfter);
534
+ update = set(before, path, update(valueBefore));
535
535
  } else if (path.length > 0) update = set(this.get(), path, update);
536
536
  if (this.derivedFrom) {
537
537
  this.derivedFrom.updater(update);
@@ -606,7 +606,9 @@ var Store = class Store {
606
606
  map(_selector, ...args) {
607
607
  const updater = _selector instanceof Function ? args[0] : (value) => (state) => set(state, _selector, value);
608
608
  const selector = makeSelector(_selector);
609
- const derivedFrom = {
609
+ return new Store(({ use }) => {
610
+ return selector(use(this));
611
+ }, void 0, {
610
612
  store: this.derivedFrom ? this.derivedFrom.store : this,
611
613
  selectors: this.derivedFrom ? [...this.derivedFrom.selectors, _selector] : [_selector],
612
614
  updater: (value) => {
@@ -616,10 +618,7 @@ var Store = class Store {
616
618
  if (this.derivedFrom) this.derivedFrom.updater(update);
617
619
  else this.set(update);
618
620
  }
619
- };
620
- return new Store(({ use }) => {
621
- return selector(use(this));
622
- }, void 0, derivedFrom);
621
+ });
623
622
  }
624
623
  /** Add an effect that will be executed when the store becomes active, which means when it has at least one subscriber.
625
624
  * @param effect
@@ -728,5 +727,5 @@ function create(initialState, options) {
728
727
  const createStore = /* @__PURE__ */ Object.assign(create, { defaultOptions: { equals: deepEqual } });
729
728
 
730
729
  //#endregion
731
- export { PromiseWithState, Store, arrayMethods, autobind, calcDuration, calculatedValue, createStore, debounce, isPromise, makeSelector, mapMethods, queue, recordMethods, setMethods, throttle };
732
- //# sourceMappingURL=store-Dx8w7yT-.js.map
730
+ export { mapMethods as a, debounce as c, queue as d, PromiseWithState as f, autobind as h, arrayMethods as i, makeSelector as l, calcDuration as m, createStore as n, recordMethods as o, isPromise as p, throttle as r, setMethods as s, Store as t, calculatedValue as u };
731
+ //# sourceMappingURL=store-v3RYWzVg.js.map