cross-state 0.9.3 → 0.10.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 (44) hide show
  1. package/dist/cjs/cache.cjs +2 -7
  2. package/dist/cjs/cache.cjs.map +1 -1
  3. package/dist/cjs/index.cjs +3 -89
  4. package/dist/cjs/index.cjs.map +1 -1
  5. package/dist/cjs/react/index.cjs +87 -36
  6. package/dist/cjs/react/index.cjs.map +1 -1
  7. package/dist/cjs/scope.cjs +2 -3
  8. package/dist/cjs/scope.cjs.map +1 -1
  9. package/dist/cjs/store.cjs +47 -9
  10. package/dist/cjs/store.cjs.map +1 -1
  11. package/dist/cjs/urlStore.cjs +94 -0
  12. package/dist/cjs/urlStore.cjs.map +1 -0
  13. package/dist/cjs/useCache.cjs +2 -7
  14. package/dist/cjs/useCache.cjs.map +1 -1
  15. package/dist/es/cache.mjs +3 -8
  16. package/dist/es/cache.mjs.map +1 -1
  17. package/dist/es/index.mjs +27 -113
  18. package/dist/es/index.mjs.map +1 -1
  19. package/dist/es/react/index.mjs +90 -39
  20. package/dist/es/react/index.mjs.map +1 -1
  21. package/dist/es/scope.mjs +2 -3
  22. package/dist/es/scope.mjs.map +1 -1
  23. package/dist/es/store.mjs +55 -17
  24. package/dist/es/store.mjs.map +1 -1
  25. package/dist/es/urlStore.mjs +95 -0
  26. package/dist/es/urlStore.mjs.map +1 -0
  27. package/dist/es/useCache.mjs +3 -8
  28. package/dist/es/useCache.mjs.map +1 -1
  29. package/dist/types/core/index.d.ts +1 -1
  30. package/dist/types/core/store.d.ts +1 -1
  31. package/dist/types/core/urlStore.d.ts +6 -14
  32. package/dist/types/index2.d.ts +2 -0
  33. package/dist/types/lib/autobind.d.ts +1 -0
  34. package/dist/types/lib/path.d.ts +1 -1
  35. package/dist/types/react/form/form.d.ts +18 -9
  36. package/dist/types/react/form/formField.d.ts +53 -0
  37. package/dist/types/react/form/index.d.ts +1 -1
  38. package/dist/types/react/index.d.ts +1 -0
  39. package/dist/types/react/reactMethods.d.ts +1 -1
  40. package/dist/types/react/register.d.ts +1 -1
  41. package/dist/types/react/scope.d.ts +7 -2
  42. package/dist/types/react/useUrlParamScope.d.ts +4 -0
  43. package/package.json +10 -10
  44. package/dist/types/react/form/formInput.d.ts +0 -48
@@ -1 +1 @@
1
- {"version":3,"file":"store.mjs","sources":["../../src/lib/calcDuration.ts","../../src/lib/equals.ts","../../src/lib/queue.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","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 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","import { deepEqual } from './equals';\nimport type { MaybePromise } from './maybePromise';\nimport { queue } from './queue';\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) => {\n if (isCancled) {\n return store.get();\n }\n\n const value = store.get();\n const equals = (newValue: any) => {\n return deepEqual(newValue, 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 { KeyType, Path, Value } from './path';\n\nexport function castArrayPath(path: string | KeyType[]): KeyType[] {\n if (Array.isArray(path)) {\n return path;\n }\n\n if (path === '') {\n return [];\n }\n\n return (path as string).split('.');\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);\n }\n\n if (object instanceof Set) {\n return get(Array.from(object)[Number(first)], rest);\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);\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} 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.reset = this.reset.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 this.notify = this.notify.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>(selector: Selector<T, S>, updater?: (value: S) => Update<T>): Store<S>;\n\n map<P extends Path<T>>(selector: P): 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 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));\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":[],"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;ACXgB,SAAA,aAAa,GAAQ,GAAQ;AAC3C,SAAO,MAAM;AACf;AAEgB,SAAA,aAAa,GAAQ,GAAiB;AACpD,SAAO,cAAc,YAAY,EAAE,GAAG,CAAC;AACzC;AAEgB,SAAA,UAAU,GAAQ,GAAiB;AACjD,SAAO,cAAc,SAAS,EAAE,GAAG,CAAC;AACtC;AAEA,MAAM,gBAAgB,CAAC,SAAsC,CAAC,GAAQ,MAAW;AAC/E,MAAI,MAAM,GAAG;AACJ,WAAA;AAAA,EACT;AAEI,MAAA,MAAM,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,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/autobind.ts","../../src/lib/calcDuration.ts","../../src/lib/equals.ts","../../src/lib/queue.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":["const processedClasses = new Set<any>();\n\nexport const autobind = <\n TClass extends abstract new (...args: any) => any = abstract new (...args: any) => any,\n>(\n _class: TClass,\n _context?: ClassDecoratorContext<TClass>,\n) => {\n if (_class.prototype.__autobind_done__) {\n return _class;\n }\n if (processedClasses.has(_class)) {\n return _class;\n }\n processedClasses.add(_class);\n\n for (const key of Reflect.ownKeys(_class.prototype)) {\n if (key === 'constructor') {\n continue;\n }\n\n const descriptor = Object.getOwnPropertyDescriptor(_class.prototype, key);\n\n // Only methods need binding\n if (typeof descriptor?.value === 'function') {\n let method = descriptor.value as (...args: any[]) => any;\n let isBinding = false;\n\n Object.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 isBinding = true;\n\n Object.defineProperty(this, key, {\n configurable: true,\n get() {\n return boundMethod;\n },\n set(v) {\n method = v;\n // delete this[key];\n },\n });\n\n isBinding = false;\n return boundMethod;\n },\n set(v) {\n method = v;\n },\n });\n }\n }\n\n return _class;\n};\n","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","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 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","import { deepEqual } from './equals';\nimport type { MaybePromise } from './maybePromise';\nimport { queue } from './queue';\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) => {\n if (isCancled) {\n return store.get();\n }\n\n const value = store.get();\n const equals = (newValue: any) => {\n return deepEqual(newValue, 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 { KeyType, Path, Value } from './path';\n\nexport function castArrayPath(path: string | KeyType[]): KeyType[] {\n if (Array.isArray(path)) {\n return path;\n }\n\n if (path === '') {\n return [];\n }\n\n return (path as string).split('.');\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);\n }\n\n if (object instanceof Set) {\n return get(Array.from(object)[Number(first)], rest);\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);\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} from './commonTypes';\nimport { autobind } from '@lib/autobind';\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 autobind(Store);\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<const 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>(selector: Selector<T, S>, updater?: (value: S) => Update<T>): Store<S>;\n\n map<P extends Path<T>>(selector: P): 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 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));\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":[],"mappings":"AAAA,MAAM,uCAAuB;AAEhB,MAAA,WAAW,CAGtB,QACA,aACG;AACC,MAAA,OAAO,UAAU,mBAAmB;AAC/B,WAAA;AAAA,EACT;AACI,MAAA,iBAAiB,IAAI,MAAM,GAAG;AACzB,WAAA;AAAA,EACT;AACA,mBAAiB,IAAI,MAAM;AAE3B,aAAW,OAAO,QAAQ,QAAQ,OAAO,SAAS,GAAG;AACnD,QAAI,QAAQ,eAAe;AACzB;AAAA,IACF;AAEA,UAAM,aAAa,OAAO,yBAAyB,OAAO,WAAW,GAAG;AAGpE,QAAA,QAAO,yCAAY,WAAU,YAAY;AAC3C,UAAI,SAAS,WAAW;AACxB,UAAI,YAAY;AAET,aAAA,eAAe,OAAO,WAAW,KAAK;AAAA,QAC3C,cAAc;AAAA,QACd,MAAM;AACJ,cACE,aACA,SAAS,OAAO,aAChB,OAAO,UAAU,eAAe,KAAK,MAAM,GAAG,KAC9C,OAAO,WAAW,YAClB;AACO,mBAAA;AAAA,UACT;AAEA,gBAAM,cAAc,IAAI,SAAgB,QAAQ,MAAM,QAAQ,MAAM,IAAI;AAC5D,sBAAA;AAEL,iBAAA,eAAe,MAAM,KAAK;AAAA,YAC/B,cAAc;AAAA,YACd,MAAM;AACG,qBAAA;AAAA,YACT;AAAA,YACA,IAAI,GAAG;AACI,uBAAA;AAAA,YAEX;AAAA,UAAA,CACD;AAEW,sBAAA;AACL,iBAAA;AAAA,QACT;AAAA,QACA,IAAI,GAAG;AACI,mBAAA;AAAA,QACX;AAAA,MAAA,CACD;AAAA,IACH;AAAA,EACF;AAEO,SAAA;AACT;AC/DO,SAAS,aAAa,GAAa;AACxC,MAAI,OAAO,MAAM;AAAiB,WAAA;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G,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;"}
@@ -0,0 +1,95 @@
1
+ import { c as createStore } from "./store.mjs";
2
+ const urlStore = createStore(() => typeof window !== "undefined" ? window.location.href : "");
3
+ urlStore.addEffect(() => {
4
+ const originalPushState = window.history.pushState;
5
+ const originalReplaceState = window.history.replaceState;
6
+ const update = () => {
7
+ urlStore.set(window.location.href);
8
+ };
9
+ window.history.pushState = (...args) => {
10
+ originalPushState.apply(window.history, args);
11
+ update();
12
+ };
13
+ window.history.replaceState = (...args) => {
14
+ originalReplaceState.apply(window.history, args);
15
+ update();
16
+ };
17
+ window.addEventListener("popstate", update);
18
+ return () => {
19
+ window.history.pushState = originalPushState;
20
+ window.history.replaceState = originalReplaceState;
21
+ window.removeEventListener("popstate", update);
22
+ };
23
+ });
24
+ function connectUrl(store, {
25
+ key,
26
+ type = "search",
27
+ serialize = defaultSerializer,
28
+ deserialize = defaultDeserializer,
29
+ defaultValue = void 0,
30
+ onCommit
31
+ }) {
32
+ const serializedDefaultValue = serialize(defaultValue);
33
+ const cancelUrlListener = urlStore.subscribe((_url) => {
34
+ const url = new URL(_url);
35
+ const parameters = new URLSearchParams(url[type].slice(1));
36
+ const urlValue = parameters.get(key);
37
+ store.set(urlValue !== null ? deserialize(urlValue) : defaultValue);
38
+ });
39
+ const cancelSubscription = store.subscribe((value) => {
40
+ const url = new URL(window.location.href);
41
+ const parameters = new URLSearchParams(url[type].slice(1));
42
+ const serializedValue = value !== void 0 ? serialize(value) : void 0;
43
+ if (serializedValue === void 0 || serializedValue === serializedDefaultValue) {
44
+ parameters.delete(key);
45
+ } else {
46
+ parameters.set(key, serializedValue);
47
+ }
48
+ url[type] = parameters.toString();
49
+ window.history.replaceState(null, "", url.toString());
50
+ onCommit == null ? void 0 : onCommit(value);
51
+ });
52
+ return () => {
53
+ cancelUrlListener();
54
+ cancelSubscription();
55
+ };
56
+ }
57
+ function defaultDeserializer(value) {
58
+ if (value === void 0) {
59
+ return void 0;
60
+ }
61
+ try {
62
+ return JSON.parse(value, (_k, v) => {
63
+ if (typeof v === "object" && v !== null && "__set" in v) {
64
+ return new Set(v.__set);
65
+ }
66
+ if (typeof v === "object" && v !== null && "__map" in v) {
67
+ return new Map(v.__map);
68
+ }
69
+ return v;
70
+ });
71
+ } catch {
72
+ return void 0;
73
+ }
74
+ }
75
+ function defaultSerializer(value) {
76
+ return JSON.stringify(value, (_k, v) => {
77
+ if (v instanceof Set) {
78
+ return { __set: Array.from(v) };
79
+ }
80
+ if (v instanceof Map) {
81
+ return { __map: Array.from(v) };
82
+ }
83
+ return v;
84
+ });
85
+ }
86
+ function createUrlStore(options) {
87
+ const store = createStore(options.defaultValue, options);
88
+ connectUrl(store, options);
89
+ return store;
90
+ }
91
+ export {
92
+ createUrlStore as a,
93
+ connectUrl as c
94
+ };
95
+ //# sourceMappingURL=urlStore.mjs.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"urlStore.mjs","sources":["../../src/core/urlStore.ts"],"sourcesContent":["import { type Cancel } from './commonTypes';\nimport { createStore, type Store, type StoreOptions } from './store';\n\nexport interface UrlStoreOptions<T> extends StoreOptions {\n key: string;\n type?: 'search' | 'hash';\n serialize?: (value: T) => string;\n deserialize?: (value: string) => T;\n defaultValue?: T;\n onCommit?: (value: T | undefined) => void;\n}\n\nexport interface UrlStoreOptionsWithDefaults<T> extends UrlStoreOptions<T> {\n defaultValue: T;\n}\n\nexport type UrlStoreOptionsRequired<T> = UrlStoreOptions<T> &\n Required<Pick<UrlStoreOptions<T>, 'type' | 'serialize' | 'deserialize' | 'defaultValue'>>;\n\nconst urlStore = createStore(() => (typeof window !== 'undefined' ? window.location.href : ''));\n\nurlStore.addEffect(() => {\n const originalPushState = window.history.pushState;\n const originalReplaceState = window.history.replaceState;\n\n const update = () => {\n urlStore.set(window.location.href);\n };\n\n window.history.pushState = (...args) => {\n originalPushState.apply(window.history, args);\n update();\n };\n\n window.history.replaceState = (...args) => {\n originalReplaceState.apply(window.history, args);\n update();\n };\n\n window.addEventListener('popstate', update);\n\n return () => {\n window.history.pushState = originalPushState;\n window.history.replaceState = originalReplaceState;\n window.removeEventListener('popstate', update);\n };\n});\n\nexport function connectUrl<T>(store: Store<T>, options: UrlStoreOptionsWithDefaults<T>): Cancel;\n\nexport function connectUrl<T>(store: Store<T | undefined>, options: UrlStoreOptions<T>): Cancel;\n\nexport function connectUrl<T>(\n store: Store<T>,\n {\n key,\n type = 'search',\n serialize = defaultSerializer,\n deserialize = defaultDeserializer,\n defaultValue = undefined as T,\n onCommit,\n }: UrlStoreOptions<T>,\n): Cancel {\n const serializedDefaultValue = serialize(defaultValue);\n\n const cancelUrlListener = urlStore.subscribe((_url) => {\n const url = new URL(_url);\n const parameters = new URLSearchParams(url[type].slice(1));\n const urlValue = parameters.get(key);\n\n store.set(urlValue !== null ? deserialize(urlValue) : defaultValue);\n });\n\n const cancelSubscription = store.subscribe((value) => {\n const url = new URL(window.location.href);\n const parameters = new URLSearchParams(url[type].slice(1));\n const serializedValue = value !== undefined ? serialize(value) : undefined;\n\n if (serializedValue === undefined || serializedValue === serializedDefaultValue) {\n parameters.delete(key);\n } else {\n parameters.set(key, serializedValue);\n }\n\n url[type] = parameters.toString();\n\n window.history.replaceState(null, '', url.toString());\n\n onCommit?.(value);\n });\n\n return () => {\n cancelUrlListener();\n cancelSubscription();\n };\n}\n\nfunction defaultDeserializer(value: string): any {\n if (value === undefined) {\n return undefined;\n }\n\n try {\n return JSON.parse(value, (_k, v) => {\n if (typeof v === 'object' && v !== null && '__set' in v) {\n return new Set(v.__set);\n }\n if (typeof v === 'object' && v !== null && '__map' in v) {\n return new Map(v.__map);\n }\n return v;\n });\n } catch {\n return undefined;\n }\n}\n\nfunction defaultSerializer(value: any): string {\n return JSON.stringify(value, (_k, v) => {\n if (v instanceof Set) {\n return { __set: Array.from(v) };\n }\n if (v instanceof Map) {\n return { __map: Array.from(v) };\n }\n return v;\n });\n}\n\nexport function createUrlStore<T>(options: UrlStoreOptionsWithDefaults<T>): Store<T>;\n\nexport function createUrlStore<T>(options: UrlStoreOptions<T>): Store<T | undefined>;\n\nexport function createUrlStore<T>(options: UrlStoreOptions<T>) {\n const store = createStore(options.defaultValue, options);\n connectUrl(store, options);\n return store;\n}\n"],"names":[],"mappings":";AAmBA,MAAM,WAAW,YAAY,MAAO,OAAO,WAAW,cAAc,OAAO,SAAS,OAAO,EAAG;AAE9F,SAAS,UAAU,MAAM;AACjB,QAAA,oBAAoB,OAAO,QAAQ;AACnC,QAAA,uBAAuB,OAAO,QAAQ;AAE5C,QAAM,SAAS,MAAM;AACV,aAAA,IAAI,OAAO,SAAS,IAAI;AAAA,EAAA;AAG5B,SAAA,QAAQ,YAAY,IAAI,SAAS;AACpB,sBAAA,MAAM,OAAO,SAAS,IAAI;AACrC;EAAA;AAGF,SAAA,QAAQ,eAAe,IAAI,SAAS;AACpB,yBAAA,MAAM,OAAO,SAAS,IAAI;AACxC;EAAA;AAGF,SAAA,iBAAiB,YAAY,MAAM;AAE1C,SAAO,MAAM;AACX,WAAO,QAAQ,YAAY;AAC3B,WAAO,QAAQ,eAAe;AACvB,WAAA,oBAAoB,YAAY,MAAM;AAAA,EAAA;AAEjD,CAAC;AAMM,SAAS,WACd,OACA;AA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AACO,aAAA;AAAA,IAAA,CACR;AAAA,EAAA,QACD;AACO,WAAA;AAAA,EACT;AACF;AAEA,SAAS,kBAAkB,OAAoB;AAC7C,SAAO,KAAK,UAAU,OAAO,CAAC,IAAI,MAAM;AACtC,QAAI,aAAa,KAAK;AACpB,aAAO,EAAE,OAAO,MAAM,KAAK,CAAC,EAAE;AAAA,IAChC;AACA,QAAI,aAAa,KAAK;AACpB,aAAO,EAAE,OAAO,MAAM,KAAK,CAAC,EAAE;AAAA,IAChC;AACO,WAAA;AAAA,EAAA,CACR;AACH;AAMO,SAAS,eAAkB,SAA6B;AAC7D,QAAM,QAAQ,YAAY,QAAQ,cAAc,OAAO;AACvD,aAAW,OAAO,OAAO;AAClB,SAAA;AACT;"}
@@ -1,6 +1,6 @@
1
1
  import { jsx } from "react/jsx-runtime";
2
2
  import require$$0, { useRef, useMemo, useCallback, useLayoutEffect, useDebugValue, useContext, createContext, useEffect } from "react";
3
- import { d as deepEqual, m as makeSelector, c as createStore } from "./store.mjs";
3
+ import { j as deepEqual, m as makeSelector, c as createStore } from "./store.mjs";
4
4
  import { h as hash } from "./scope.mjs";
5
5
  var withSelector = { exports: {} };
6
6
  var withSelector_production_min = {};
@@ -510,14 +510,9 @@ function useProp(store, argument1, argument2, argument3) {
510
510
  const value = useStore(store, options);
511
511
  return [value, store.set];
512
512
  }
513
- const contextMap = /* @__PURE__ */ new WeakMap();
514
513
  function getScopeContext(scope) {
515
- let context = contextMap.get(scope);
516
- if (!context) {
517
- context = createContext(createStore(scope.defaultValue));
518
- contextMap.set(scope, context);
519
- }
520
- return context;
514
+ scope.context ?? (scope.context = createContext(createStore(scope.defaultValue)));
515
+ return scope.context;
521
516
  }
522
517
  function ScopeProvider({ scope, store: inputStore, children }) {
523
518
  const context = getScopeContext(scope);
@@ -1 +1 @@
1
- {"version":3,"file":"useCache.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/lib/trackingProxy.ts","../../src/react/useStore.ts","../../src/react/useProp.ts","../../src/react/scope.tsx","../../src/react/reactMethods.ts","../../src/react/useCache.ts"],"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 { 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 { useCallback, useDebugValue, useLayoutEffect, useMemo, useRef } from 'react';\nimport { useSyncExternalStoreWithSelector } from 'use-sync-external-store/shim/with-selector.js';\nimport type { Selector, SubscribeOptions } from '@core/commonTypes';\nimport type { Store } from '@core/store';\nimport { deepEqual } from '@lib/equals';\nimport { hash } from '@lib/hash';\nimport { makeSelector } from '@lib/makeSelector';\nimport { trackingProxy } from '@lib/trackingProxy';\nimport { type Path, type Value } from '@lib/path';\n\nexport interface UseStoreOptions extends Omit<SubscribeOptions, 'runNow' | 'passive'> {\n disableTrackingProxy?: boolean;\n}\n\nexport function useStore<T, S>(\n store: Store<T>,\n selector: Selector<T, S>,\n option?: UseStoreOptions,\n): S;\n\nexport function useStore<T, P extends Path<T>>(\n store: Store<T>,\n selector: P,\n option?: UseStoreOptions,\n): Value<T, P>;\n\nexport function useStore<T>(store: Store<T>, option?: UseStoreOptions): T;\n\nexport function useStore<T, S>(store: Store<T>, argument1?: any, argument2?: any): S {\n const selector = makeSelector<T, S>(\n typeof argument1 === 'function' || typeof argument1 === 'string' ? argument1 : undefined,\n );\n const {\n disableTrackingProxy = true,\n equals = deepEqual,\n ...options\n } = (typeof argument1 === 'object' ? argument1 : argument2 ?? {}) as UseStoreOptions;\n\n const lastEqualsRef = useRef<(newValue: S) => boolean>();\n\n const { rootStore, mappingSelector } = useMemo(() => {\n const rootStore = store.derivedFrom?.store ?? store;\n let mappingSelector = (x: any) => x;\n\n if (store.derivedFrom) {\n mappingSelector = (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, mappingSelector };\n }, [store]);\n\n const subOptions = { ...options, runNow: false, passive: false };\n const subscribe = useCallback(\n (listener: () => void) => {\n return rootStore.subscribe(listener, subOptions);\n },\n [rootStore, hash(subOptions)],\n );\n\n let value = useSyncExternalStoreWithSelector<unknown, S>(\n //\n subscribe,\n rootStore.get,\n undefined,\n (x) => selector(mappingSelector(x)),\n (_v, newValue) => lastEqualsRef.current?.(newValue) ?? false,\n );\n let lastEquals = (newValue: S) => equals(newValue, value);\n let revoke: (() => void) | undefined;\n\n if (!disableTrackingProxy) {\n [value, lastEquals, revoke] = trackingProxy(value, equals);\n }\n\n useLayoutEffect(() => {\n lastEqualsRef.current = lastEquals;\n revoke?.();\n });\n\n useDebugValue(value);\n return value;\n}\n","import type { UseStoreOptions } from './useStore';\nimport { useStore } from './useStore';\nimport { type Selector, type Update } from '@core/commonTypes';\nimport type { Store } from '@core/store';\nimport { type Path, type Value } from '@lib/path';\n\nexport function useProp<T, S>(\n store: Store<T>,\n selector: Selector<T, S>,\n updater: (value: S) => Update<T>,\n options?: UseStoreOptions,\n): [value: S, setValue: Store<S>['set']];\n\nexport function useProp<T, P extends Path<T>>(\n store: Store<T>,\n selector: P,\n options?: UseStoreOptions,\n): [value: Value<T, P>, setValue: Store<Value<T, P>>['set']];\n\nexport function useProp<T>(\n store: Store<T>,\n options?: UseStoreOptions,\n): [value: T, setValue: Store<T>['set']];\n\nexport function useProp<T, S>(\n store: Store<T>,\n argument1?: any,\n argument2?: any,\n argument3?: any,\n): [value: S, setValue: Store<S>['set']] {\n const selector =\n typeof argument1 === 'function' || typeof argument1 === 'string' ? argument1 : undefined;\n const updater = typeof argument2 === 'function' ? argument2 : undefined;\n const options =\n typeof argument1 === 'object'\n ? argument1\n : typeof argument2 === 'object'\n ? argument2\n : argument3;\n\n if (selector) {\n store = store.map(selector, updater);\n }\n\n const value = useStore(store, options) as S;\n return [value, store.set as Store<S>['set']];\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","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"],"names":["useEffect","useLayoutEffect","useDebugValue","error","shim","shimModule","require$$0","require$$1","a","c","d","b","e","useRef","useMemo","withSelectorMod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AC,UAAU,MAAM,UAAU,MAAM,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;","x_google_ignoreList":[0,1,2,3,4,5]}
1
+ {"version":3,"file":"useCache.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/lib/trackingProxy.ts","../../src/react/useStore.ts","../../src/react/useProp.ts","../../src/react/scope.tsx","../../src/react/reactMethods.ts","../../src/react/useCache.ts"],"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 { 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 { useCallback, useDebugValue, useLayoutEffect, useMemo, useRef } from 'react';\nimport { useSyncExternalStoreWithSelector } from 'use-sync-external-store/shim/with-selector.js';\nimport type { Selector, SubscribeOptions } from '@core/commonTypes';\nimport type { Store } from '@core/store';\nimport { deepEqual } from '@lib/equals';\nimport { hash } from '@lib/hash';\nimport { makeSelector } from '@lib/makeSelector';\nimport { trackingProxy } from '@lib/trackingProxy';\nimport { type Path, type Value } from '@lib/path';\n\nexport interface UseStoreOptions extends Omit<SubscribeOptions, 'runNow' | 'passive'> {\n disableTrackingProxy?: boolean;\n}\n\nexport function useStore<T, S>(\n store: Store<T>,\n selector: Selector<T, S>,\n option?: UseStoreOptions,\n): S;\n\nexport function useStore<T, P extends Path<T>>(\n store: Store<T>,\n selector: P,\n option?: UseStoreOptions,\n): Value<T, P>;\n\nexport function useStore<T>(store: Store<T>, option?: UseStoreOptions): T;\n\nexport function useStore<T, S>(store: Store<T>, argument1?: any, argument2?: any): S {\n const selector = makeSelector<T, S>(\n typeof argument1 === 'function' || typeof argument1 === 'string' ? argument1 : undefined,\n );\n const {\n disableTrackingProxy = true,\n equals = deepEqual,\n ...options\n } = (typeof argument1 === 'object' ? argument1 : argument2 ?? {}) as UseStoreOptions;\n\n const lastEqualsRef = useRef<(newValue: S) => boolean>();\n\n const { rootStore, mappingSelector } = useMemo(() => {\n const rootStore = store.derivedFrom?.store ?? store;\n let mappingSelector = (x: any) => x;\n\n if (store.derivedFrom) {\n mappingSelector = (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, mappingSelector };\n }, [store]);\n\n const subOptions = { ...options, runNow: false, passive: false };\n const subscribe = useCallback(\n (listener: () => void) => {\n return rootStore.subscribe(listener, subOptions);\n },\n [rootStore, hash(subOptions)],\n );\n\n let value = useSyncExternalStoreWithSelector<unknown, S>(\n //\n subscribe,\n rootStore.get,\n undefined,\n (x) => selector(mappingSelector(x)),\n (_v, newValue) => lastEqualsRef.current?.(newValue) ?? false,\n );\n let lastEquals = (newValue: S) => equals(newValue, value);\n let revoke: (() => void) | undefined;\n\n if (!disableTrackingProxy) {\n [value, lastEquals, revoke] = trackingProxy(value, equals);\n }\n\n useLayoutEffect(() => {\n lastEqualsRef.current = lastEquals;\n revoke?.();\n });\n\n useDebugValue(value);\n return value;\n}\n","import type { UseStoreOptions } from './useStore';\nimport { useStore } from './useStore';\nimport { type Selector, type Update } from '@core/commonTypes';\nimport type { Store } from '@core/store';\nimport { type Path, type Value } from '@lib/path';\n\nexport function useProp<T, S>(\n store: Store<T>,\n selector: Selector<T, S>,\n updater: (value: S) => Update<T>,\n options?: UseStoreOptions,\n): [value: S, setValue: Store<S>['set']];\n\nexport function useProp<T, P extends Path<T>>(\n store: Store<T>,\n selector: P,\n options?: UseStoreOptions,\n): [value: Value<T, P>, setValue: Store<Value<T, P>>['set']];\n\nexport function useProp<T>(\n store: Store<T>,\n options?: UseStoreOptions,\n): [value: T, setValue: Store<T>['set']];\n\nexport function useProp<T, S>(\n store: Store<T>,\n argument1?: any,\n argument2?: any,\n argument3?: any,\n): [value: S, setValue: Store<S>['set']] {\n const selector =\n typeof argument1 === 'function' || typeof argument1 === 'string' ? argument1 : undefined;\n const updater = typeof argument2 === 'function' ? argument2 : undefined;\n const options =\n typeof argument1 === 'object'\n ? argument1\n : typeof argument2 === 'object'\n ? argument2\n : argument3;\n\n if (selector) {\n store = store.map(selector, updater);\n }\n\n const value = useStore(store, options) as S;\n return [value, store.set as Store<S>['set']];\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\ndeclare module '@core' {\n interface Scope<T> {\n context?: Context<Store<T>>;\n }\n}\n\nfunction getScopeContext<T>(scope: Scope<T>): Context<Store<T>> {\n scope.context ??= createContext<Store<T>>(createStore(scope.defaultValue));\n return scope.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","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"],"names":["useEffect","useLayoutEffect","useDebugValue","error","shim","shimModule","require$$0","require$$1","a","c","d","b","e","useRef","useMemo","withSelectorModule","equals","rootStore","mappingSelector","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,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,CAAC,KAAG,EAAE,EAAC,MAAK,EAAC,CAAC;AAAA,MAAC,CAAC;AAAA,IAAC,GAAE,CAAC,CAAC,CAAC;AAAE,MAAE,CAAC;AAAE,WAAO;AAAA,EA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K,IAAI;AAEjE,aAAO,OAAO;AAAA,QACZ,CAAC,OAAO,MAAM,OAAO,MAAM,YAAY,MAAM,OAAO;AAAA,QACpD,EAAE,GAAG,OAAO,MAAM;AAAA,MAAA;AAAA,IACpB,CACD;AAAA,EAAA,GACA,CAAC,KAAK,CAAC;AAEV,YAAU,MAAO,CAAC,UAAU,MAAM,UAAU,MAAM,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;","x_google_ignoreList":[0,1,2,3,4,5]}
@@ -4,4 +4,4 @@ export { ResourceGroup, allResources, createResourceGroup, type Resource } from
4
4
  export { Scope, createScope } from './scope';
5
5
  export { Store, createStore, type BoundStoreMethods, type StoreMethods, type StoreOptions, type StoreOptionsWithMethods, } from './store';
6
6
  export { SubstriptionCache, createSubscriptionCache, type SubscriptionCacheFunction, type SubstriptionCacheOptions, } from './subscriptionCache';
7
- export { createUrlStore, type UrlStore, type UrlStoreOptions } from './urlStore';
7
+ export { connectUrl, createUrlStore, type UrlStoreOptions } from './urlStore';
@@ -41,7 +41,7 @@ export declare class Store<T> extends Callable<any, any> {
41
41
  } | undefined, _call?: (...args: any[]) => any);
42
42
  get(): T;
43
43
  set(update: Update<T>): void;
44
- set<P extends Path<T>>(path: P, update: Update<Value<T, P>>): void;
44
+ set<const P extends Path<T>>(path: P, update: Update<Value<T, P>>): void;
45
45
  protected reset(): void;
46
46
  subscribe(listener: Listener<T>, options?: SubscribeOptions): Cancel;
47
47
  once<S extends T>(condition: (value: T) => value is S): Promise<S>;