cross-state 0.7.1 → 0.8.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.
@@ -434,8 +434,10 @@ exports.Store = store.Store;
434
434
  exports.arrayMethods = store.arrayMethods;
435
435
  exports.calcDuration = store.calcDuration;
436
436
  exports.createStore = store.createStore;
437
+ exports.get = store.get;
437
438
  exports.mapMethods = store.mapMethods;
438
439
  exports.recordMethods = store.recordMethods;
440
+ exports.set = store.set;
439
441
  exports.setMethods = store.setMethods;
440
442
  exports.Cache = scope.Cache;
441
443
  exports.InstanceCache = scope.InstanceCache;
@@ -1 +1 @@
1
- {"version":3,"file":"index.cjs","sources":["../../src/core/subscriptionCache.ts","../../src/core/urlStore.ts","../../src/lib/updateHelpers.ts","../../src/persist/persistPathHelpers.ts","../../src/lib/maybeAsync.ts","../../src/persist/persistStorage.ts","../../src/lib/diff.ts","../../src/persist/persist.ts"],"sourcesContent":["import {\n type CalculationHelpers,\n type Cancel,\n type ConnectionState,\n type Duration,\n type Selector,\n} from './commonTypes';\nimport { allResources, type ResourceGroup } from './resourceGroup';\nimport { createStore, Store } from './store';\nimport { calcDuration } from '@lib/calcDuration';\nimport { InstanceCache } from '@lib/instanceCache';\nimport { type Path } from '@lib/path';\n\nexport interface SubscriptionCacheFunction<T, Args extends any[] = []> {\n (this: CalculationHelpers<T | undefined>, ...args: Args):\n | Cancel\n | void\n | ((cache: CalculationHelpers<T | undefined>) => Cancel | void);\n}\n\nexport interface SubstriptionCacheOptions {\n clearOnInvalidate?: boolean;\n clearUnusedAfter?: Duration | null;\n resourceGroup?: ResourceGroup | ResourceGroup[];\n retain?: Duration;\n}\n\nexport class SubstriptionCache<T> extends Store<T | undefined> {\n readonly state = createStore({\n connectionState: 'closed' as ConnectionState,\n error: undefined as unknown | undefined,\n });\n\n constructor(\n public readonly connectFunction: SubscriptionCacheFunction<T>,\n public readonly options: SubstriptionCacheOptions = {},\n public readonly derivedFromSubscriptionCache?: {\n subscriptionCache: SubstriptionCache<any>;\n selectors: (Selector<any, any> | Path<any>)[];\n },\n _call?: (...args: any[]) => any,\n ) {\n super(undefined, options, undefined, _call);\n\n this.calculationHelper.options = {\n ...this.calculationHelper.options,\n calculate: (helpers) => {\n let result = connectFunction.apply(helpers);\n\n if (result instanceof Function && result.length > 0) {\n result = result(helpers);\n }\n\n return result as Cancel | void;\n },\n onValue: (value) => {\n this.set(value);\n },\n onError: (error) => {\n this.state.set('error', error);\n },\n onConnectionState: (state) => {\n this.state.set('connectionState', state);\n },\n onInvalidate: () => {\n this.invalidate();\n },\n };\n }\n\n invalidate({ invalidateDependencies = true }: { invalidateDependencies?: boolean } = {}) {\n const { clearOnInvalidate = defaultOptions.clearOnInvalidate } = this.options;\n\n if (clearOnInvalidate) {\n return this.clear({ invalidateDependencies });\n }\n\n if (invalidateDependencies) {\n this.calculationHelper.invalidateDependencies();\n }\n\n this.calculationHelper.stop();\n\n if (this.isActive()) {\n this.calculationHelper.execute();\n }\n }\n\n clear({ invalidateDependencies = true }: { invalidateDependencies?: boolean } = {}): void {\n if (invalidateDependencies) {\n this.calculationHelper.invalidateDependencies();\n }\n\n this.calculationHelper.stop();\n\n if (this.isActive()) {\n this.calculationHelper.execute();\n }\n }\n}\n\nconst defaultOptions: SubstriptionCacheOptions = {\n clearUnusedAfter: { days: 1 },\n retain: { seconds: 1 },\n};\n\ntype CreateReturnType<T, Args extends any[]> = {\n (...args: Args): SubstriptionCache<T>;\n invalidateAll: () => void;\n clearAll: () => void;\n} & ([] extends Args ? SubstriptionCache<T> : {});\n\nfunction create<T, Args extends any[] = []>(\n cacheFunction: SubscriptionCacheFunction<T, Args>,\n options?: SubstriptionCacheOptions,\n): CreateReturnType<T, Args> {\n const { clearUnusedAfter = defaultOptions.clearUnusedAfter, resourceGroup } = options ?? {};\n\n let baseInstance: CreateReturnType<T, Args> & SubstriptionCache<T>;\n\n const instanceCache = new InstanceCache<Args, SubstriptionCache<T>>(\n (...args: Args): SubstriptionCache<T> => {\n if (args.length === 0 && baseInstance) {\n return baseInstance;\n }\n\n return new SubstriptionCache(function () {\n return cacheFunction.apply(this, args);\n }, options);\n },\n clearUnusedAfter ? calcDuration(clearUnusedAfter) : undefined,\n );\n\n const get = (...args: Args) => {\n return instanceCache.get(...args);\n };\n\n const invalidateAll = () => {\n for (const instance of instanceCache.values()) {\n instance.invalidate();\n }\n };\n\n const clearAll = () => {\n for (const instance of instanceCache.values()) {\n instance.clear();\n }\n };\n\n baseInstance = Object.assign(\n new SubstriptionCache<T>(\n function () {\n return cacheFunction.apply(this);\n },\n options,\n undefined,\n get,\n ),\n {\n invalidateAll,\n clearAll,\n },\n ) as CreateReturnType<T, Args> & SubstriptionCache<T>;\n\n const groups = Array.isArray(resourceGroup)\n ? resourceGroup\n : resourceGroup\n ? [resourceGroup]\n : [];\n for (const group of groups.concat(allResources)) {\n group.add(baseInstance);\n }\n\n get(...([] as any));\n\n return baseInstance;\n}\n\nexport const createSubscriptionCache = /* @__PURE__ */ Object.assign(create, {\n defaultOptions,\n});\n","import { type Update } from './commonTypes';\nimport { Store, type StoreOptions } from './store';\nimport { type Path, type Value } from '@lib/path';\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\nexport class UrlStore<T> extends Store<T> {\n private serializedDefaultValue = this.options.serialize(this.options.defaultValue);\n\n constructor(public readonly options: UrlStoreOptionsRequired<T>) {\n super(() => {\n const url = new URL(window.location.href);\n const parameters = new URLSearchParams(url[options.type].slice(1));\n const urlValue = parameters.get(options.key);\n const deserialize: (value: string) => T = options.deserialize ?? defaultDeserializer;\n return urlValue !== null ? deserialize(urlValue) : options.defaultValue;\n });\n\n this.addEffect(() => this.watchUrl());\n }\n\n override set(update: Update<T>): void;\n\n override set<P extends Path<T>>(path: P, update: Update<Value<T, P>>): void;\n\n override set(...args: any): void {\n super.set.apply(this, args);\n this.updateUrl(super.get());\n }\n\n protected watchUrl() {\n const originalPushState = window.history.pushState;\n const originalReplaceState = window.history.replaceState;\n\n window.history.pushState = (...args) => {\n originalPushState.apply(window.history, args);\n this.reset();\n };\n\n window.history.replaceState = (...args) => {\n originalReplaceState.apply(window.history, args);\n this.reset();\n };\n\n return () => {\n window.history.pushState = originalPushState;\n window.history.replaceState = originalReplaceState;\n };\n }\n\n protected updateUrl(value: T | undefined) {\n const url = new URL(window.location.href);\n const parameters = new URLSearchParams(url[this.options.type].slice(1));\n const serializedValue = value !== undefined ? this.options.serialize(value) : undefined;\n\n if (serializedValue === undefined || serializedValue === this.serializedDefaultValue) {\n parameters.delete(this.options.key);\n } else {\n parameters.set(this.options.key, serializedValue);\n }\n\n url[this.options.type] = parameters.toString();\n window.history.replaceState(null, '', url.toString());\n\n this.options.onCommit?.(value);\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>): UrlStore<T>;\nexport function createUrlStore<T>(options: UrlStoreOptions<T>): UrlStore<T | undefined>;\nexport function createUrlStore<T>(options: UrlStoreOptions<T>) {\n return new UrlStore({\n ...options,\n type: options.type ?? 'search',\n serialize: options.serialize ?? defaultSerializer,\n deserialize: options.deserialize ?? defaultDeserializer,\n defaultValue: options.defaultValue ?? (undefined as T),\n });\n}\n","export function findOrDefault<T>(\n array: T[],\n predicate: (item: T) => boolean,\n defaultValue: T | (() => T),\n): T {\n const index = array.findIndex(predicate);\n\n if (index >= 0) {\n return array[index]!;\n }\n\n const value = defaultValue instanceof Function ? defaultValue() : defaultValue;\n array.push(value);\n return value;\n}\n","import type { KeyType } from '@lib/path';\n\nexport const isAncestor = (ancestor: KeyType[], path: KeyType[]): boolean => {\n return (\n ancestor.length <= path.length &&\n ancestor.every((v, i) => v === '*' || path[i] === '*' || v === path[i])\n );\n};\n\nexport const split = (\n value: any,\n path: KeyType[],\n): [value: unknown, subValues: { path: KeyType[]; value: unknown }[]] => {\n const [first, ...rest] = path;\n if (first === undefined) return [value, []];\n\n if (rest.length === 0) {\n if (first === '*')\n return [{}, Object.entries(value).map(([k, v]) => ({ path: [k], value: v }))];\n if (!(first in value)) return [value, []];\n const { [first]: subValue, ...newValue } = value;\n return [newValue, [{ path: [first], value: subValue }]];\n }\n\n const newValue = { ...value };\n const subValues = new Array<{ path: KeyType[]; value: unknown }>();\n for (const key of first === '*' ? Object.keys(value) : [first]) {\n if (!(newValue[key] instanceof Object)) return [value, []];\n const result = split(newValue[key], rest);\n newValue[key] = result[0];\n subValues.push(...result[1].map((s) => ({ path: [key, ...s.path], value: s.value })));\n }\n return [newValue, subValues];\n};\n","import type { MaybePromise } from './maybePromise';\n\nexport function maybeAsync<T, R>(\n value: MaybePromise<T>,\n action: (value: T) => MaybePromise<R>,\n): MaybePromise<R> {\n if (value instanceof Promise) {\n return value.then(action);\n }\n return action(value);\n}\n\nexport function maybeAsyncArray<T>(values: (() => MaybePromise<T>)[]): MaybePromise<T[]> {\n const run = (remainingValues: (() => MaybePromise<T>)[], results: T[]): MaybePromise<T[]> => {\n const [first, ...rest] = remainingValues;\n if (!first) {\n return results;\n }\n\n return maybeAsync(first(), (result) => run(rest, results.concat(result)));\n };\n\n return run(values, []);\n}\n","import { maybeAsync, maybeAsyncArray } from '@lib/maybeAsync';\n\nexport interface PersistStorageBase {\n getItem: (key: string) => string | null | Promise<string | null>;\n setItem: (key: string, value: string) => unknown | Promise<unknown>;\n removeItem: (key: string) => unknown | Promise<unknown>;\n}\n\nexport interface PersistStorageWithKeys extends PersistStorageBase {\n keys: () => string[] | Promise<string[]>;\n}\n\nexport interface PersistStorageWithLength extends PersistStorageBase {\n length: number | (() => number | Promise<number>);\n key: (keyIndex: number) => string | null | Promise<string | null>;\n}\n\nexport type PersistStorage = PersistStorageBase &\n (PersistStorageWithKeys | PersistStorageWithLength);\n\nexport function normalizeStorage(storage: PersistStorage): PersistStorageWithKeys {\n return {\n getItem: storage.getItem.bind(storage),\n setItem: storage.setItem.bind(storage),\n removeItem: storage.removeItem.bind(storage),\n\n keys(): string[] | Promise<string[]> {\n if ('keys' in storage) {\n return storage.keys();\n }\n\n return maybeAsync(\n storage.length instanceof Function ? storage.length() : storage.length,\n (length) => {\n const keyPromises = maybeAsyncArray(\n Array.from({ length }, (_, index) => () => storage.key(index)),\n );\n\n return maybeAsync(keyPromises, (keys) =>\n keys.filter((key): key is string => typeof key === 'string'),\n );\n },\n );\n },\n };\n}\n","import type { KeyType } from './path';\n\nexport type Patch =\n | { op: 'add'; path: KeyType[]; value: any }\n | { op: 'remove'; path: KeyType[] }\n | { op: 'replace'; path: KeyType[]; value: any };\n\nexport function diff(a: any, b: any): [patches: Patch[], reversePatches: Patch[]] {\n const result = [..._diff(a, b)];\n const patches = result.map(([patch]) => patch);\n const reversePatches = result.map(([, reversePatch]) => reversePatch);\n\n return [patches, reversePatches];\n}\n\nfunction* _diff(\n a: any,\n b: any,\n prefix: KeyType[] = [],\n): Iterable<[patch: Patch, reversePatch: Patch]> {\n if (a === b) {\n return;\n }\n\n if (a instanceof Map && b instanceof Map) {\n return yield* mapDiff(a, b, prefix);\n }\n\n if (a instanceof Set && b instanceof Set) {\n a = [...a];\n b = [...b];\n }\n\n if (a instanceof Object && b instanceof Object && Array.isArray(a) === Array.isArray(b)) {\n return yield* objectDiff(a, b, prefix);\n }\n\n yield [\n { op: 'replace', path: prefix, value: b },\n { op: 'replace', path: prefix, value: a },\n ];\n}\n\nfunction* mapDiff(\n a: Map<any, any>,\n b: Map<any, any>,\n prefix: KeyType[],\n): Iterable<[patch: Patch, reversePatch: Patch]> {\n for (const [key, value] of a) {\n if (!b.has(key)) {\n yield [\n { op: 'remove', path: [...prefix, key] },\n { op: 'add', path: [...prefix, key], value },\n ];\n } else {\n yield* _diff(value, b.get(key), [...prefix, key]);\n }\n }\n\n for (const [key, value] of b) {\n if (!a.has(key)) {\n yield [\n { op: 'add', path: [...prefix, key], value },\n { op: 'remove', path: [...prefix, key] },\n ];\n }\n }\n}\n\nfunction* objectDiff(\n a: any,\n b: any,\n prefix: KeyType[],\n): Iterable<[patch: Patch, reversePatch: Patch]> {\n const castKey = (key: string) => (Array.isArray(a) ? Number(key) : key);\n\n for (const [key, value] of Object.entries(a)) {\n if (!(key in b)) {\n yield [\n { op: 'remove', path: [...prefix, castKey(key)] },\n { op: 'add', path: [...prefix, castKey(key)], value },\n ];\n } else {\n yield* _diff(value, b[key], [...prefix, castKey(key)]);\n }\n }\n\n for (const [key, value] of Object.entries(b)) {\n if (!(key in a)) {\n yield [\n { op: 'add', path: [...prefix, castKey(key)], value },\n { op: 'remove', path: [...prefix, castKey(key)] },\n ];\n }\n }\n}\n","import { isAncestor } from './persistPathHelpers';\nimport {\n normalizeStorage,\n type PersistStorage,\n type PersistStorageWithKeys,\n} from './persistStorage';\nimport { type Cancel, type Store } from '@core';\nimport { diff } from '@lib/diff';\nimport { shallowEqual } from '@lib/equals';\nimport { maybeAsync, maybeAsyncArray } from '@lib/maybeAsync';\nimport type { KeyType, WildcardPath } from '@lib/path';\nimport { castArrayPath, get, set } from '@lib/propAccess';\nimport { queue } from '@lib/queue';\n\nexport interface PersistOptions<T> {\n id: string;\n storage: PersistStorage;\n paths?:\n | WildcardPath<T>[]\n | {\n path: WildcardPath<T>;\n throttleMs?: number;\n }[];\n throttleMs?: number;\n}\n\nexport class Persist<T> {\n storage: PersistStorageWithKeys;\n\n paths: {\n path: KeyType[];\n throttleMs?: number;\n }[];\n\n channel: BroadcastChannel;\n\n queue = queue();\n\n handles = new Set<Cancel>();\n\n stopped = false;\n\n updateInProgress?: [any, any];\n\n constructor(public readonly store: Store<T>, public readonly options: PersistOptions<T>) {\n this.storage = normalizeStorage(options.storage);\n this.channel = new BroadcastChannel(`cross-state-persist_${options.id}`);\n\n this.paths = (options.paths ?? [])\n .map<{\n path: KeyType[];\n throttleMs?: number;\n }>((p) =>\n typeof p === 'string' || Array.isArray(p)\n ? {\n path: castArrayPath(p as any),\n }\n : {\n path: castArrayPath(p.path as any),\n throttleMs: p.throttleMs,\n },\n )\n .sort((a, b) => b.path.length - a.path.length);\n\n if (this.paths.length === 0) {\n this.paths.push({ path: ['*'] });\n }\n\n this.watchStore();\n this.watchStorage();\n }\n\n watchStore() {\n let committed = this.store.get();\n\n const cancel = this.store.subscribe(\n (value) => {\n const [patches] = diff(committed, value);\n committed = value;\n\n for (const patch of patches) {\n if (\n this.updateInProgress &&\n shallowEqual(this.updateInProgress[0], patch.path) &&\n this.updateInProgress[1] === (patch.op === 'remove' ? undefined : patch.value)\n ) {\n continue;\n }\n\n const ancestor = this.paths.find((p) => isAncestor(p.path, patch.path));\n\n if (!ancestor) {\n continue;\n }\n\n const pathToSave = patch.path.slice(0, ancestor.path.length);\n this.queue(() => this.save(pathToSave), pathToSave);\n }\n },\n { runNow: false },\n );\n\n this.handles.add(cancel);\n }\n\n async watchStorage() {\n let keys = this.storage.keys();\n if (keys instanceof Promise) {\n keys = await keys;\n }\n\n if (this.stopped) {\n return;\n }\n\n for (const key of keys) {\n const path = JSON.parse(key);\n this.queue(() => this.load(path));\n }\n\n const listener = (event: MessageEvent) => {\n this.queue(() => this.load(event.data));\n };\n\n this.channel.addEventListener('message', listener);\n this.handles.add(() => this.channel.removeEventListener('message', listener));\n }\n\n load(path: KeyType[]) {\n const matchingPath = this.paths.find(\n (p) => p.path.length === path.length && isAncestor(p.path, path),\n );\n if (!matchingPath) {\n return;\n }\n\n const key = JSON.stringify(path);\n\n return maybeAsync(this.storage.getItem(key), (value) => {\n if (this.stopped || !value) {\n return;\n }\n\n const inSaveQueue = this.queue\n .getRefs()\n .find((ref) => isAncestor(ref, path) || isAncestor(path, ref));\n if (inSaveQueue) {\n return;\n }\n\n const parsedValue = value === 'undefined' ? undefined : JSON.parse(value);\n\n this.updateInProgress = [path, parsedValue];\n this.store.set((state) => set(state, path as any, parsedValue));\n this.updateInProgress = undefined;\n });\n }\n\n save(path: KeyType[]) {\n const key = JSON.stringify(path);\n const value = get(this.store.get(), path as any);\n const serializedValue = value === undefined ? 'undefined' : JSON.stringify(value);\n\n return maybeAsync(this.storage.setItem(key, serializedValue), () => {\n this.channel.postMessage(path);\n\n return maybeAsync(this.storage.keys(), (keys) => {\n const toRemove = keys.filter((k) => {\n const parsedKey = JSON.parse(k);\n return (\n parsedKey.length > path.length && isAncestor(path, parsedKey)\n // !this.queue.getRefs().find((ref) => isAncestor(ref, parsedKey))\n );\n });\n\n return maybeAsyncArray(toRemove.map((k) => () => this.storage.removeItem(k)));\n });\n });\n }\n\n async stop() {\n this.stopped = true;\n\n for (const handle of this.handles) {\n handle();\n }\n\n await this.queue.whenDone();\n this.channel.close();\n }\n}\n\nexport function persist<T>(store: Store<T>, options: PersistOptions<T>): Persist<T> {\n return new Persist<T>(store, options);\n}\n"],"names":["Store","createStore","InstanceCache","calcDuration","allResources","store","queue","castArrayPath","shallowEqual","set","get"],"mappings":";;;;;AA2BO,MAAM,0BAA6BA,MAAAA,MAAqB;AAAA,EAM7D,YACkB,iBACA,UAAoC,CAAA,GACpC,8BAIhB,OACA;AACM,UAAA,QAAW,SAAS,QAAW,KAAK;AAR1B,SAAA,kBAAA;AACA,SA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AACrC,WAAA,MAAM,IAAI,CAAC,UAAUC,UAAI,OAAO,MAAa,WAAW,CAAC;AAC9D,WAAK,mBAAmB;AAAA,IAAA,CACzB;AAAA,EACH;AAAA,EAEA,KAAK,MAAiB;AACd,UAAA,MAAM,KAAK,UAAU,IAAI;AAC/B,UAAM,QAAQC,MAAAA,IAAI,KAAK,MAAM,IAAA,GAAO,IAAW;AAC/C,UAAM,kBAAkB,UAAU,SAAY,cAAc,KAAK,UAAU,KAAK;AAEhF,WAAO,WAAW,KAAK,QAAQ,QAAQ,KAAK,eAAe,GAAG,MAAM;AAC7D,WAAA,QAAQ,YAAY,IAAI;AAE7B,aAAO,WAAW,KAAK,QAAQ,KAAK,GAAG,CAAC,SAAS;AAC/C,cAAM,WAAW,KAAK,OAAO,CAAC,MAAM;AAC5B,gBAAA,YAAY,KAAK,MAAM,CAAC;AAC9B,iBACE,UAAU,SAAS,KAAK,UAAU,WAAW,MAAM,SAAS;AAAA,QAAA,CAG/D;AAEM,eAAA,gBAAgB,SAAS,IAAI,CAAC,MAAM,MAAM,KAAK,QAAQ,WAAW,CAAC,CAAC,CAAC;AAAA,MAAA,CAC7E;AAAA,IAAA,CACF;AAAA,EACH;AAAA,EAEA,MAAM,OAAO;AACX,SAAK,UAAU;AAEJ,eAAA,UAAU,KAAK,SAAS;AAC1B;IACT;AAEM,UAAA,KAAK,MAAM;AACjB,SAAK,QAAQ;EACf;AACF;AAEgB,SAAA,QAAWL,QAAiB,SAAwC;AAC3E,SAAA,IAAI,QAAWA,QAAO,OAAO;AACtC;;;;;;;;;;;;;;;;;;;;;"}
1
+ {"version":3,"file":"index.cjs","sources":["../../src/core/subscriptionCache.ts","../../src/core/urlStore.ts","../../src/lib/updateHelpers.ts","../../src/persist/persistPathHelpers.ts","../../src/lib/maybeAsync.ts","../../src/persist/persistStorage.ts","../../src/lib/diff.ts","../../src/persist/persist.ts"],"sourcesContent":["import {\n type CalculationHelpers,\n type Cancel,\n type ConnectionState,\n type Duration,\n type Selector,\n} from './commonTypes';\nimport { allResources, type ResourceGroup } from './resourceGroup';\nimport { createStore, Store } from './store';\nimport { calcDuration } from '@lib/calcDuration';\nimport { InstanceCache } from '@lib/instanceCache';\nimport { type Path } from '@lib/path';\n\nexport interface SubscriptionCacheFunction<T, Args extends any[] = []> {\n (this: CalculationHelpers<T | undefined>, ...args: Args):\n | Cancel\n | void\n | ((cache: CalculationHelpers<T | undefined>) => Cancel | void);\n}\n\nexport interface SubstriptionCacheOptions {\n clearOnInvalidate?: boolean;\n clearUnusedAfter?: Duration | null;\n resourceGroup?: ResourceGroup | ResourceGroup[];\n retain?: Duration;\n}\n\nexport class SubstriptionCache<T> extends Store<T | undefined> {\n readonly state = createStore({\n connectionState: 'closed' as ConnectionState,\n error: undefined as unknown | undefined,\n });\n\n constructor(\n public readonly connectFunction: SubscriptionCacheFunction<T>,\n public readonly options: SubstriptionCacheOptions = {},\n public readonly derivedFromSubscriptionCache?: {\n subscriptionCache: SubstriptionCache<any>;\n selectors: (Selector<any, any> | Path<any>)[];\n },\n _call?: (...args: any[]) => any,\n ) {\n super(undefined, options, undefined, _call);\n\n this.calculationHelper.options = {\n ...this.calculationHelper.options,\n calculate: (helpers) => {\n let result = connectFunction.apply(helpers);\n\n if (result instanceof Function && result.length > 0) {\n result = result(helpers);\n }\n\n return result as Cancel | void;\n },\n onValue: (value) => {\n this.set(value);\n },\n onError: (error) => {\n this.state.set('error', error);\n },\n onConnectionState: (state) => {\n this.state.set('connectionState', state);\n },\n onInvalidate: () => {\n this.invalidate();\n },\n };\n }\n\n invalidate({ invalidateDependencies = true }: { invalidateDependencies?: boolean } = {}) {\n const { clearOnInvalidate = defaultOptions.clearOnInvalidate } = this.options;\n\n if (clearOnInvalidate) {\n return this.clear({ invalidateDependencies });\n }\n\n if (invalidateDependencies) {\n this.calculationHelper.invalidateDependencies();\n }\n\n this.calculationHelper.stop();\n\n if (this.isActive()) {\n this.calculationHelper.execute();\n }\n }\n\n clear({ invalidateDependencies = true }: { invalidateDependencies?: boolean } = {}): void {\n if (invalidateDependencies) {\n this.calculationHelper.invalidateDependencies();\n }\n\n this.calculationHelper.stop();\n\n if (this.isActive()) {\n this.calculationHelper.execute();\n }\n }\n}\n\nconst defaultOptions: SubstriptionCacheOptions = {\n clearUnusedAfter: { days: 1 },\n retain: { seconds: 1 },\n};\n\ntype CreateReturnType<T, Args extends any[]> = {\n (...args: Args): SubstriptionCache<T>;\n invalidateAll: () => void;\n clearAll: () => void;\n} & ([] extends Args ? SubstriptionCache<T> : {});\n\nfunction create<T, Args extends any[] = []>(\n cacheFunction: SubscriptionCacheFunction<T, Args>,\n options?: SubstriptionCacheOptions,\n): CreateReturnType<T, Args> {\n const { clearUnusedAfter = defaultOptions.clearUnusedAfter, resourceGroup } = options ?? {};\n\n let baseInstance: CreateReturnType<T, Args> & SubstriptionCache<T>;\n\n const instanceCache = new InstanceCache<Args, SubstriptionCache<T>>(\n (...args: Args): SubstriptionCache<T> => {\n if (args.length === 0 && baseInstance) {\n return baseInstance;\n }\n\n return new SubstriptionCache(function () {\n return cacheFunction.apply(this, args);\n }, options);\n },\n clearUnusedAfter ? calcDuration(clearUnusedAfter) : undefined,\n );\n\n const get = (...args: Args) => {\n return instanceCache.get(...args);\n };\n\n const invalidateAll = () => {\n for (const instance of instanceCache.values()) {\n instance.invalidate();\n }\n };\n\n const clearAll = () => {\n for (const instance of instanceCache.values()) {\n instance.clear();\n }\n };\n\n baseInstance = Object.assign(\n new SubstriptionCache<T>(\n function () {\n return cacheFunction.apply(this);\n },\n options,\n undefined,\n get,\n ),\n {\n invalidateAll,\n clearAll,\n },\n ) as CreateReturnType<T, Args> & SubstriptionCache<T>;\n\n const groups = Array.isArray(resourceGroup)\n ? resourceGroup\n : resourceGroup\n ? [resourceGroup]\n : [];\n for (const group of groups.concat(allResources)) {\n group.add(baseInstance);\n }\n\n get(...([] as any));\n\n return baseInstance;\n}\n\nexport const createSubscriptionCache = /* @__PURE__ */ Object.assign(create, {\n defaultOptions,\n});\n","import { type Update } from './commonTypes';\nimport { Store, type StoreOptions } from './store';\nimport { type Path, type Value } from '@lib/path';\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\nexport class UrlStore<T> extends Store<T> {\n private serializedDefaultValue = this.options.serialize(this.options.defaultValue);\n\n constructor(public readonly options: UrlStoreOptionsRequired<T>) {\n super(() => {\n const url = new URL(window.location.href);\n const parameters = new URLSearchParams(url[options.type].slice(1));\n const urlValue = parameters.get(options.key);\n const deserialize: (value: string) => T = options.deserialize ?? defaultDeserializer;\n return urlValue !== null ? deserialize(urlValue) : options.defaultValue;\n });\n\n this.addEffect(() => this.watchUrl());\n }\n\n override set(update: Update<T>): void;\n\n override set<P extends Path<T>>(path: P, update: Update<Value<T, P>>): void;\n\n override set(...args: any): void {\n super.set.apply(this, args);\n this.updateUrl(super.get());\n }\n\n protected watchUrl() {\n const originalPushState = window.history.pushState;\n const originalReplaceState = window.history.replaceState;\n\n window.history.pushState = (...args) => {\n originalPushState.apply(window.history, args);\n this.reset();\n };\n\n window.history.replaceState = (...args) => {\n originalReplaceState.apply(window.history, args);\n this.reset();\n };\n\n return () => {\n window.history.pushState = originalPushState;\n window.history.replaceState = originalReplaceState;\n };\n }\n\n protected updateUrl(value: T | undefined) {\n const url = new URL(window.location.href);\n const parameters = new URLSearchParams(url[this.options.type].slice(1));\n const serializedValue = value !== undefined ? this.options.serialize(value) : undefined;\n\n if (serializedValue === undefined || serializedValue === this.serializedDefaultValue) {\n parameters.delete(this.options.key);\n } else {\n parameters.set(this.options.key, serializedValue);\n }\n\n url[this.options.type] = parameters.toString();\n window.history.replaceState(null, '', url.toString());\n\n this.options.onCommit?.(value);\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>): UrlStore<T>;\nexport function createUrlStore<T>(options: UrlStoreOptions<T>): UrlStore<T | undefined>;\nexport function createUrlStore<T>(options: UrlStoreOptions<T>) {\n return new UrlStore({\n ...options,\n type: options.type ?? 'search',\n serialize: options.serialize ?? defaultSerializer,\n deserialize: options.deserialize ?? defaultDeserializer,\n defaultValue: options.defaultValue ?? (undefined as T),\n });\n}\n","export function findOrDefault<T>(\n array: T[],\n predicate: (item: T) => boolean,\n defaultValue: T | (() => T),\n): T {\n const index = array.findIndex(predicate);\n\n if (index >= 0) {\n return array[index]!;\n }\n\n const value = defaultValue instanceof Function ? defaultValue() : defaultValue;\n array.push(value);\n return value;\n}\n","import type { KeyType } from '@lib/path';\n\nexport const isAncestor = (ancestor: KeyType[], path: KeyType[]): boolean => {\n return (\n ancestor.length <= path.length &&\n ancestor.every((v, i) => v === '*' || path[i] === '*' || v === path[i])\n );\n};\n\nexport const split = (\n value: any,\n path: KeyType[],\n): [value: unknown, subValues: { path: KeyType[]; value: unknown }[]] => {\n const [first, ...rest] = path;\n if (first === undefined) return [value, []];\n\n if (rest.length === 0) {\n if (first === '*')\n return [{}, Object.entries(value).map(([k, v]) => ({ path: [k], value: v }))];\n if (!(first in value)) return [value, []];\n const { [first]: subValue, ...newValue } = value;\n return [newValue, [{ path: [first], value: subValue }]];\n }\n\n const newValue = { ...value };\n const subValues = new Array<{ path: KeyType[]; value: unknown }>();\n for (const key of first === '*' ? Object.keys(value) : [first]) {\n if (!(newValue[key] instanceof Object)) return [value, []];\n const result = split(newValue[key], rest);\n newValue[key] = result[0];\n subValues.push(...result[1].map((s) => ({ path: [key, ...s.path], value: s.value })));\n }\n return [newValue, subValues];\n};\n","import type { MaybePromise } from './maybePromise';\n\nexport function maybeAsync<T, R>(\n value: MaybePromise<T>,\n action: (value: T) => MaybePromise<R>,\n): MaybePromise<R> {\n if (value instanceof Promise) {\n return value.then(action);\n }\n return action(value);\n}\n\nexport function maybeAsyncArray<T>(values: (() => MaybePromise<T>)[]): MaybePromise<T[]> {\n const run = (remainingValues: (() => MaybePromise<T>)[], results: T[]): MaybePromise<T[]> => {\n const [first, ...rest] = remainingValues;\n if (!first) {\n return results;\n }\n\n return maybeAsync(first(), (result) => run(rest, results.concat(result)));\n };\n\n return run(values, []);\n}\n","import { maybeAsync, maybeAsyncArray } from '@lib/maybeAsync';\n\nexport interface PersistStorageBase {\n getItem: (key: string) => string | null | Promise<string | null>;\n setItem: (key: string, value: string) => unknown | Promise<unknown>;\n removeItem: (key: string) => unknown | Promise<unknown>;\n}\n\nexport interface PersistStorageWithKeys extends PersistStorageBase {\n keys: () => string[] | Promise<string[]>;\n}\n\nexport interface PersistStorageWithLength extends PersistStorageBase {\n length: number | (() => number | Promise<number>);\n key: (keyIndex: number) => string | null | Promise<string | null>;\n}\n\nexport type PersistStorage = PersistStorageBase &\n (PersistStorageWithKeys | PersistStorageWithLength);\n\nexport function normalizeStorage(storage: PersistStorage): PersistStorageWithKeys {\n return {\n getItem: storage.getItem.bind(storage),\n setItem: storage.setItem.bind(storage),\n removeItem: storage.removeItem.bind(storage),\n\n keys(): string[] | Promise<string[]> {\n if ('keys' in storage) {\n return storage.keys();\n }\n\n return maybeAsync(\n storage.length instanceof Function ? storage.length() : storage.length,\n (length) => {\n const keyPromises = maybeAsyncArray(\n Array.from({ length }, (_, index) => () => storage.key(index)),\n );\n\n return maybeAsync(keyPromises, (keys) =>\n keys.filter((key): key is string => typeof key === 'string'),\n );\n },\n );\n },\n };\n}\n","import type { KeyType } from './path';\n\nexport type Patch =\n | { op: 'add'; path: KeyType[]; value: any }\n | { op: 'remove'; path: KeyType[] }\n | { op: 'replace'; path: KeyType[]; value: any };\n\nexport function diff(a: any, b: any): [patches: Patch[], reversePatches: Patch[]] {\n const result = [..._diff(a, b)];\n const patches = result.map(([patch]) => patch);\n const reversePatches = result.map(([, reversePatch]) => reversePatch);\n\n return [patches, reversePatches];\n}\n\nfunction* _diff(\n a: any,\n b: any,\n prefix: KeyType[] = [],\n): Iterable<[patch: Patch, reversePatch: Patch]> {\n if (a === b) {\n return;\n }\n\n if (a instanceof Map && b instanceof Map) {\n return yield* mapDiff(a, b, prefix);\n }\n\n if (a instanceof Set && b instanceof Set) {\n a = [...a];\n b = [...b];\n }\n\n if (a instanceof Object && b instanceof Object && Array.isArray(a) === Array.isArray(b)) {\n return yield* objectDiff(a, b, prefix);\n }\n\n yield [\n { op: 'replace', path: prefix, value: b },\n { op: 'replace', path: prefix, value: a },\n ];\n}\n\nfunction* mapDiff(\n a: Map<any, any>,\n b: Map<any, any>,\n prefix: KeyType[],\n): Iterable<[patch: Patch, reversePatch: Patch]> {\n for (const [key, value] of a) {\n if (!b.has(key)) {\n yield [\n { op: 'remove', path: [...prefix, key] },\n { op: 'add', path: [...prefix, key], value },\n ];\n } else {\n yield* _diff(value, b.get(key), [...prefix, key]);\n }\n }\n\n for (const [key, value] of b) {\n if (!a.has(key)) {\n yield [\n { op: 'add', path: [...prefix, key], value },\n { op: 'remove', path: [...prefix, key] },\n ];\n }\n }\n}\n\nfunction* objectDiff(\n a: any,\n b: any,\n prefix: KeyType[],\n): Iterable<[patch: Patch, reversePatch: Patch]> {\n const castKey = (key: string) => (Array.isArray(a) ? Number(key) : key);\n\n for (const [key, value] of Object.entries(a)) {\n if (!(key in b)) {\n yield [\n { op: 'remove', path: [...prefix, castKey(key)] },\n { op: 'add', path: [...prefix, castKey(key)], value },\n ];\n } else {\n yield* _diff(value, b[key], [...prefix, castKey(key)]);\n }\n }\n\n for (const [key, value] of Object.entries(b)) {\n if (!(key in a)) {\n yield [\n { op: 'add', path: [...prefix, castKey(key)], value },\n { op: 'remove', path: [...prefix, castKey(key)] },\n ];\n }\n }\n}\n","import { isAncestor } from './persistPathHelpers';\nimport {\n normalizeStorage,\n type PersistStorage,\n type PersistStorageWithKeys,\n} from './persistStorage';\nimport { type Cancel, type Store } from '@core';\nimport { diff } from '@lib/diff';\nimport { shallowEqual } from '@lib/equals';\nimport { maybeAsync, maybeAsyncArray } from '@lib/maybeAsync';\nimport type { KeyType, WildcardPath } from '@lib/path';\nimport { castArrayPath, get, set } from '@lib/propAccess';\nimport { queue } from '@lib/queue';\n\nexport interface PersistOptions<T> {\n id: string;\n storage: PersistStorage;\n paths?:\n | WildcardPath<T>[]\n | {\n path: WildcardPath<T>;\n throttleMs?: number;\n }[];\n throttleMs?: number;\n}\n\nexport class Persist<T> {\n storage: PersistStorageWithKeys;\n\n paths: {\n path: KeyType[];\n throttleMs?: number;\n }[];\n\n channel: BroadcastChannel;\n\n queue = queue();\n\n handles = new Set<Cancel>();\n\n stopped = false;\n\n updateInProgress?: [any, any];\n\n constructor(public readonly store: Store<T>, public readonly options: PersistOptions<T>) {\n this.storage = normalizeStorage(options.storage);\n this.channel = new BroadcastChannel(`cross-state-persist_${options.id}`);\n\n this.paths = (options.paths ?? [])\n .map<{\n path: KeyType[];\n throttleMs?: number;\n }>((p) =>\n typeof p === 'string' || Array.isArray(p)\n ? {\n path: castArrayPath(p as any),\n }\n : {\n path: castArrayPath(p.path as any),\n throttleMs: p.throttleMs,\n },\n )\n .sort((a, b) => b.path.length - a.path.length);\n\n if (this.paths.length === 0) {\n this.paths.push({ path: ['*'] });\n }\n\n this.watchStore();\n this.watchStorage();\n }\n\n watchStore() {\n let committed = this.store.get();\n\n const cancel = this.store.subscribe(\n (value) => {\n const [patches] = diff(committed, value);\n committed = value;\n\n for (const patch of patches) {\n if (\n this.updateInProgress &&\n shallowEqual(this.updateInProgress[0], patch.path) &&\n this.updateInProgress[1] === (patch.op === 'remove' ? undefined : patch.value)\n ) {\n continue;\n }\n\n const ancestor = this.paths.find((p) => isAncestor(p.path, patch.path));\n\n if (!ancestor) {\n continue;\n }\n\n const pathToSave = patch.path.slice(0, ancestor.path.length);\n this.queue(() => this.save(pathToSave), pathToSave);\n }\n },\n { runNow: false },\n );\n\n this.handles.add(cancel);\n }\n\n async watchStorage() {\n let keys = this.storage.keys();\n if (keys instanceof Promise) {\n keys = await keys;\n }\n\n if (this.stopped) {\n return;\n }\n\n for (const key of keys) {\n const path = JSON.parse(key);\n this.queue(() => this.load(path));\n }\n\n const listener = (event: MessageEvent) => {\n this.queue(() => this.load(event.data));\n };\n\n this.channel.addEventListener('message', listener);\n this.handles.add(() => this.channel.removeEventListener('message', listener));\n }\n\n load(path: KeyType[]) {\n const matchingPath = this.paths.find(\n (p) => p.path.length === path.length && isAncestor(p.path, path),\n );\n if (!matchingPath) {\n return;\n }\n\n const key = JSON.stringify(path);\n\n return maybeAsync(this.storage.getItem(key), (value) => {\n if (this.stopped || !value) {\n return;\n }\n\n const inSaveQueue = this.queue\n .getRefs()\n .find((ref) => isAncestor(ref, path) || isAncestor(path, ref));\n if (inSaveQueue) {\n return;\n }\n\n const parsedValue = value === 'undefined' ? undefined : JSON.parse(value);\n\n this.updateInProgress = [path, parsedValue];\n this.store.set((state) => set(state, path as any, parsedValue));\n this.updateInProgress = undefined;\n });\n }\n\n save(path: KeyType[]) {\n const key = JSON.stringify(path);\n const value = get(this.store.get(), path as any);\n const serializedValue = value === undefined ? 'undefined' : JSON.stringify(value);\n\n return maybeAsync(this.storage.setItem(key, serializedValue), () => {\n this.channel.postMessage(path);\n\n return maybeAsync(this.storage.keys(), (keys) => {\n const toRemove = keys.filter((k) => {\n const parsedKey = JSON.parse(k);\n return (\n parsedKey.length > path.length && isAncestor(path, parsedKey)\n // !this.queue.getRefs().find((ref) => isAncestor(ref, parsedKey))\n );\n });\n\n return maybeAsyncArray(toRemove.map((k) => () => this.storage.removeItem(k)));\n });\n });\n }\n\n async stop() {\n this.stopped = true;\n\n for (const handle of this.handles) {\n handle();\n }\n\n await this.queue.whenDone();\n this.channel.close();\n }\n}\n\nexport function persist<T>(store: Store<T>, options: PersistOptions<T>): Persist<T> {\n return new Persist<T>(store, options);\n}\n"],"names":["Store","createStore","InstanceCache","calcDuration","allResources","store","queue","castArrayPath","shallowEqual","set","get"],"mappings":";;;;;AA2BO,MAAM,0BAA6BA,MAAAA,MAAqB;AAAA,EAM7D,YACkB,iBACA,UAAoC,CAAA,GACpC,8BAIhB,OACA;AACM,UAAA,QAAW,SAAS,QAAW,KAAK;AAR1B,SAAA,kBAAA;AACA,SAAA,UAAA;AACA,SAAA,+BAAA;AARlB,SAAS,QAAQC,kBAAY;AAAA,MAC3B,iBAAiB;AAAA,MACjB,OAAO;AAAA,IAAA,CACR;AAaC,SAAK,kBAAkB,UAAU;AAAA,MAC/B,GAAG,KAAK,kBAAkB;AAAA,MAC1B,WAAW,CAAC,YAAY;AAClB,YAAA,SAAS,gBAAgB,MAAM,OAAO;AAE1C,YAAI,kBAAkB,YAAY,OAAO,SAAS,GAAG;AACnD,mBAAS,OAAO,OAAO;AAAA,QACzB;AAEO,eAAA;AAAA,MACT;AAAA,MACA,SAAS,CAAC,UAAU;AAClB,aAAK,IAAI,KAAK;AAAA,MAChB;AAAA,MACA,SAAS,CAAC,UAAU;AACb,aAAA,MAAM,IAAI,SAAS,KAAK;AAAA,MAC/B;AAAA,MACA,mBAAmB,CAAC,UAAU;AACvB,aAAA,MAAM,IAAI,mBAAmB,KAAK;AAAA,MACzC;AAAA,MACA,cAAc,MAAM;AAClB,aAAK,WAAW;AAAA,MAClB;AAAA,IAAA;AAAA,EAEJ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MAAM,MAAM,KAAK,QAAQ,WAAW,CAAC,CAAC,CAAC;AAAA,MAAA,CAC7E;AAAA,IAAA,CACF;AAAA,EACH;AAAA,EAEA,MAAM,OAAO;AACX,SAAK,UAAU;AAEJ,eAAA,UAAU,KAAK,SAAS;AAC1B;IACT;AAEM,UAAA,KAAK,MAAM;AACjB,SAAK,QAAQ;EACf;AACF;AAEgB,SAAA,QAAWL,QAAiB,SAAwC;AAC3E,SAAA,IAAI,QAAWA,QAAO,OAAO;AACtC;;;;;;;;;;;;;;;;;;;;;;;"}
@@ -12,51 +12,258 @@ var withSelector = {
12
12
  withSelectorExports = v;
13
13
  }
14
14
  };
15
- var useSyncExternalStoreWithSelector_production_min = {};
15
+ var withSelector_production_min = {};
16
+ var shimExports = {};
17
+ var shim = {
18
+ get exports() {
19
+ return shimExports;
20
+ },
21
+ set exports(v) {
22
+ shimExports = v;
23
+ }
24
+ };
25
+ var useSyncExternalStoreShim_production_min = {};
26
+ /**
27
+ * @license React
28
+ * use-sync-external-store-shim.production.min.js
29
+ *
30
+ * Copyright (c) Facebook, Inc. and its affiliates.
31
+ *
32
+ * This source code is licensed under the MIT license found in the
33
+ * LICENSE file in the root directory of this source tree.
34
+ */
35
+ var hasRequiredUseSyncExternalStoreShim_production_min;
36
+ function requireUseSyncExternalStoreShim_production_min() {
37
+ if (hasRequiredUseSyncExternalStoreShim_production_min)
38
+ return useSyncExternalStoreShim_production_min;
39
+ hasRequiredUseSyncExternalStoreShim_production_min = 1;
40
+ var e = require$$0;
41
+ function h(a, b) {
42
+ return a === b && (0 !== a || 1 / a === 1 / b) || a !== a && b !== b;
43
+ }
44
+ var k = "function" === typeof Object.is ? Object.is : h, l = e.useState, m = e.useEffect, n = e.useLayoutEffect, p = e.useDebugValue;
45
+ function q(a, b) {
46
+ var d = b(), f = l({ inst: { value: d, getSnapshot: b } }), c = f[0].inst, g = f[1];
47
+ n(function() {
48
+ c.value = d;
49
+ c.getSnapshot = b;
50
+ r(c) && g({ inst: c });
51
+ }, [a, d, b]);
52
+ m(function() {
53
+ r(c) && g({ inst: c });
54
+ return a(function() {
55
+ r(c) && g({ inst: c });
56
+ });
57
+ }, [a]);
58
+ p(d);
59
+ return d;
60
+ }
61
+ function r(a) {
62
+ var b = a.getSnapshot;
63
+ a = a.value;
64
+ try {
65
+ var d = b();
66
+ return !k(a, d);
67
+ } catch (f) {
68
+ return true;
69
+ }
70
+ }
71
+ function t(a, b) {
72
+ return b();
73
+ }
74
+ var u = "undefined" === typeof window || "undefined" === typeof window.document || "undefined" === typeof window.document.createElement ? t : q;
75
+ useSyncExternalStoreShim_production_min.useSyncExternalStore = void 0 !== e.useSyncExternalStore ? e.useSyncExternalStore : u;
76
+ return useSyncExternalStoreShim_production_min;
77
+ }
78
+ var useSyncExternalStoreShim_development = {};
79
+ /**
80
+ * @license React
81
+ * use-sync-external-store-shim.development.js
82
+ *
83
+ * Copyright (c) Facebook, Inc. and its affiliates.
84
+ *
85
+ * This source code is licensed under the MIT license found in the
86
+ * LICENSE file in the root directory of this source tree.
87
+ */
88
+ var hasRequiredUseSyncExternalStoreShim_development;
89
+ function requireUseSyncExternalStoreShim_development() {
90
+ if (hasRequiredUseSyncExternalStoreShim_development)
91
+ return useSyncExternalStoreShim_development;
92
+ hasRequiredUseSyncExternalStoreShim_development = 1;
93
+ if (process.env.NODE_ENV !== "production") {
94
+ (function() {
95
+ if (typeof __REACT_DEVTOOLS_GLOBAL_HOOK__ !== "undefined" && typeof __REACT_DEVTOOLS_GLOBAL_HOOK__.registerInternalModuleStart === "function") {
96
+ __REACT_DEVTOOLS_GLOBAL_HOOK__.registerInternalModuleStart(new Error());
97
+ }
98
+ var React = require$$0;
99
+ var ReactSharedInternals = React.__SECRET_INTERNALS_DO_NOT_USE_OR_YOU_WILL_BE_FIRED;
100
+ function error(format) {
101
+ {
102
+ {
103
+ for (var _len2 = arguments.length, args = new Array(_len2 > 1 ? _len2 - 1 : 0), _key2 = 1; _key2 < _len2; _key2++) {
104
+ args[_key2 - 1] = arguments[_key2];
105
+ }
106
+ printWarning("error", format, args);
107
+ }
108
+ }
109
+ }
110
+ function printWarning(level, format, args) {
111
+ {
112
+ var ReactDebugCurrentFrame = ReactSharedInternals.ReactDebugCurrentFrame;
113
+ var stack = ReactDebugCurrentFrame.getStackAddendum();
114
+ if (stack !== "") {
115
+ format += "%s";
116
+ args = args.concat([stack]);
117
+ }
118
+ var argsWithFormat = args.map(function(item) {
119
+ return String(item);
120
+ });
121
+ argsWithFormat.unshift("Warning: " + format);
122
+ Function.prototype.apply.call(console[level], console, argsWithFormat);
123
+ }
124
+ }
125
+ function is(x, y) {
126
+ return x === y && (x !== 0 || 1 / x === 1 / y) || x !== x && y !== y;
127
+ }
128
+ var objectIs = typeof Object.is === "function" ? Object.is : is;
129
+ var useState = React.useState, useEffect = React.useEffect, useLayoutEffect = React.useLayoutEffect, useDebugValue = React.useDebugValue;
130
+ var didWarnOld18Alpha = false;
131
+ var didWarnUncachedGetSnapshot = false;
132
+ function useSyncExternalStore(subscribe, getSnapshot, getServerSnapshot) {
133
+ {
134
+ if (!didWarnOld18Alpha) {
135
+ if (React.startTransition !== void 0) {
136
+ didWarnOld18Alpha = true;
137
+ 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.");
138
+ }
139
+ }
140
+ }
141
+ var value = getSnapshot();
142
+ {
143
+ if (!didWarnUncachedGetSnapshot) {
144
+ var cachedValue = getSnapshot();
145
+ if (!objectIs(value, cachedValue)) {
146
+ error("The result of getSnapshot should be cached to avoid an infinite loop");
147
+ didWarnUncachedGetSnapshot = true;
148
+ }
149
+ }
150
+ }
151
+ var _useState = useState({
152
+ inst: {
153
+ value,
154
+ getSnapshot
155
+ }
156
+ }), inst = _useState[0].inst, forceUpdate = _useState[1];
157
+ useLayoutEffect(function() {
158
+ inst.value = value;
159
+ inst.getSnapshot = getSnapshot;
160
+ if (checkIfSnapshotChanged(inst)) {
161
+ forceUpdate({
162
+ inst
163
+ });
164
+ }
165
+ }, [subscribe, value, getSnapshot]);
166
+ useEffect(function() {
167
+ if (checkIfSnapshotChanged(inst)) {
168
+ forceUpdate({
169
+ inst
170
+ });
171
+ }
172
+ var handleStoreChange = function() {
173
+ if (checkIfSnapshotChanged(inst)) {
174
+ forceUpdate({
175
+ inst
176
+ });
177
+ }
178
+ };
179
+ return subscribe(handleStoreChange);
180
+ }, [subscribe]);
181
+ useDebugValue(value);
182
+ return value;
183
+ }
184
+ function checkIfSnapshotChanged(inst) {
185
+ var latestGetSnapshot = inst.getSnapshot;
186
+ var prevValue = inst.value;
187
+ try {
188
+ var nextValue = latestGetSnapshot();
189
+ return !objectIs(prevValue, nextValue);
190
+ } catch (error2) {
191
+ return true;
192
+ }
193
+ }
194
+ function useSyncExternalStore$1(subscribe, getSnapshot, getServerSnapshot) {
195
+ return getSnapshot();
196
+ }
197
+ var canUseDOM = !!(typeof window !== "undefined" && typeof window.document !== "undefined" && typeof window.document.createElement !== "undefined");
198
+ var isServerEnvironment = !canUseDOM;
199
+ var shim2 = isServerEnvironment ? useSyncExternalStore$1 : useSyncExternalStore;
200
+ var useSyncExternalStore$2 = React.useSyncExternalStore !== void 0 ? React.useSyncExternalStore : shim2;
201
+ useSyncExternalStoreShim_development.useSyncExternalStore = useSyncExternalStore$2;
202
+ if (typeof __REACT_DEVTOOLS_GLOBAL_HOOK__ !== "undefined" && typeof __REACT_DEVTOOLS_GLOBAL_HOOK__.registerInternalModuleStop === "function") {
203
+ __REACT_DEVTOOLS_GLOBAL_HOOK__.registerInternalModuleStop(new Error());
204
+ }
205
+ })();
206
+ }
207
+ return useSyncExternalStoreShim_development;
208
+ }
209
+ var hasRequiredShim;
210
+ function requireShim() {
211
+ if (hasRequiredShim)
212
+ return shimExports;
213
+ hasRequiredShim = 1;
214
+ (function(module2) {
215
+ if (process.env.NODE_ENV === "production") {
216
+ module2.exports = requireUseSyncExternalStoreShim_production_min();
217
+ } else {
218
+ module2.exports = requireUseSyncExternalStoreShim_development();
219
+ }
220
+ })(shim);
221
+ return shimExports;
222
+ }
16
223
  /**
17
224
  * @license React
18
- * use-sync-external-store-with-selector.production.min.js
225
+ * use-sync-external-store-shim/with-selector.production.min.js
19
226
  *
20
227
  * Copyright (c) Facebook, Inc. and its affiliates.
21
228
  *
22
229
  * This source code is licensed under the MIT license found in the
23
230
  * LICENSE file in the root directory of this source tree.
24
231
  */
25
- var hasRequiredUseSyncExternalStoreWithSelector_production_min;
26
- function requireUseSyncExternalStoreWithSelector_production_min() {
27
- if (hasRequiredUseSyncExternalStoreWithSelector_production_min)
28
- return useSyncExternalStoreWithSelector_production_min;
29
- hasRequiredUseSyncExternalStoreWithSelector_production_min = 1;
30
- var g = require$$0;
31
- function n(a, b) {
232
+ var hasRequiredWithSelector_production_min;
233
+ function requireWithSelector_production_min() {
234
+ if (hasRequiredWithSelector_production_min)
235
+ return withSelector_production_min;
236
+ hasRequiredWithSelector_production_min = 1;
237
+ var h = require$$0, n = requireShim();
238
+ function p(a, b) {
32
239
  return a === b && (0 !== a || 1 / a === 1 / b) || a !== a && b !== b;
33
240
  }
34
- var p = "function" === typeof Object.is ? Object.is : n, q = g.useSyncExternalStore, r = g.useRef, t = g.useEffect, u = g.useMemo, v = g.useDebugValue;
35
- useSyncExternalStoreWithSelector_production_min.useSyncExternalStoreWithSelector = function(a, b, e, l, h) {
36
- var c = r(null);
241
+ var q = "function" === typeof Object.is ? Object.is : p, r = n.useSyncExternalStore, t = h.useRef, u = h.useEffect, v = h.useMemo, w = h.useDebugValue;
242
+ withSelector_production_min.useSyncExternalStoreWithSelector = function(a, b, e, l, g) {
243
+ var c = t(null);
37
244
  if (null === c.current) {
38
245
  var f = { hasValue: false, value: null };
39
246
  c.current = f;
40
247
  } else
41
248
  f = c.current;
42
- c = u(function() {
249
+ c = v(function() {
43
250
  function a2(a3) {
44
251
  if (!c2) {
45
252
  c2 = true;
46
253
  d2 = a3;
47
254
  a3 = l(a3);
48
- if (void 0 !== h && f.hasValue) {
255
+ if (void 0 !== g && f.hasValue) {
49
256
  var b2 = f.value;
50
- if (h(b2, a3))
257
+ if (g(b2, a3))
51
258
  return k = b2;
52
259
  }
53
260
  return k = a3;
54
261
  }
55
262
  b2 = k;
56
- if (p(d2, a3))
263
+ if (q(d2, a3))
57
264
  return b2;
58
265
  var e2 = l(a3);
59
- if (void 0 !== h && h(b2, e2))
266
+ if (void 0 !== g && g(b2, e2))
60
267
  return b2;
61
268
  d2 = a3;
62
269
  return k = e2;
@@ -67,43 +274,44 @@ function requireUseSyncExternalStoreWithSelector_production_min() {
67
274
  }, null === m ? void 0 : function() {
68
275
  return a2(m());
69
276
  }];
70
- }, [b, e, l, h]);
71
- var d = q(a, c[0], c[1]);
72
- t(function() {
277
+ }, [b, e, l, g]);
278
+ var d = r(a, c[0], c[1]);
279
+ u(function() {
73
280
  f.hasValue = true;
74
281
  f.value = d;
75
282
  }, [d]);
76
- v(d);
283
+ w(d);
77
284
  return d;
78
285
  };
79
- return useSyncExternalStoreWithSelector_production_min;
286
+ return withSelector_production_min;
80
287
  }
81
- var useSyncExternalStoreWithSelector_development = {};
288
+ var withSelector_development = {};
82
289
  /**
83
290
  * @license React
84
- * use-sync-external-store-with-selector.development.js
291
+ * use-sync-external-store-shim/with-selector.development.js
85
292
  *
86
293
  * Copyright (c) Facebook, Inc. and its affiliates.
87
294
  *
88
295
  * This source code is licensed under the MIT license found in the
89
296
  * LICENSE file in the root directory of this source tree.
90
297
  */
91
- var hasRequiredUseSyncExternalStoreWithSelector_development;
92
- function requireUseSyncExternalStoreWithSelector_development() {
93
- if (hasRequiredUseSyncExternalStoreWithSelector_development)
94
- return useSyncExternalStoreWithSelector_development;
95
- hasRequiredUseSyncExternalStoreWithSelector_development = 1;
298
+ var hasRequiredWithSelector_development;
299
+ function requireWithSelector_development() {
300
+ if (hasRequiredWithSelector_development)
301
+ return withSelector_development;
302
+ hasRequiredWithSelector_development = 1;
96
303
  if (process.env.NODE_ENV !== "production") {
97
304
  (function() {
98
305
  if (typeof __REACT_DEVTOOLS_GLOBAL_HOOK__ !== "undefined" && typeof __REACT_DEVTOOLS_GLOBAL_HOOK__.registerInternalModuleStart === "function") {
99
306
  __REACT_DEVTOOLS_GLOBAL_HOOK__.registerInternalModuleStart(new Error());
100
307
  }
101
308
  var React = require$$0;
309
+ var shim2 = requireShim();
102
310
  function is(x, y) {
103
311
  return x === y && (x !== 0 || 1 / x === 1 / y) || x !== x && y !== y;
104
312
  }
105
313
  var objectIs = typeof Object.is === "function" ? Object.is : is;
106
- var useSyncExternalStore = React.useSyncExternalStore;
314
+ var useSyncExternalStore = shim2.useSyncExternalStore;
107
315
  var useRef = React.useRef, useEffect = React.useEffect, useMemo = React.useMemo, useDebugValue = React.useDebugValue;
108
316
  function useSyncExternalStoreWithSelector(subscribe, getSnapshot, getServerSnapshot, selector, isEqual) {
109
317
  var instRef = useRef(null);
@@ -168,19 +376,19 @@ function requireUseSyncExternalStoreWithSelector_development() {
168
376
  useDebugValue(value);
169
377
  return value;
170
378
  }
171
- useSyncExternalStoreWithSelector_development.useSyncExternalStoreWithSelector = useSyncExternalStoreWithSelector;
379
+ withSelector_development.useSyncExternalStoreWithSelector = useSyncExternalStoreWithSelector;
172
380
  if (typeof __REACT_DEVTOOLS_GLOBAL_HOOK__ !== "undefined" && typeof __REACT_DEVTOOLS_GLOBAL_HOOK__.registerInternalModuleStop === "function") {
173
381
  __REACT_DEVTOOLS_GLOBAL_HOOK__.registerInternalModuleStop(new Error());
174
382
  }
175
383
  })();
176
384
  }
177
- return useSyncExternalStoreWithSelector_development;
385
+ return withSelector_development;
178
386
  }
179
387
  (function(module2) {
180
388
  if (process.env.NODE_ENV === "production") {
181
- module2.exports = requireUseSyncExternalStoreWithSelector_production_min();
389
+ module2.exports = requireWithSelector_production_min();
182
390
  } else {
183
- module2.exports = requireUseSyncExternalStoreWithSelector_development();
391
+ module2.exports = requireWithSelector_development();
184
392
  }
185
393
  })(withSelector);
186
394
  function useStore(store$1, options) {
@@ -1 +1 @@
1
- {"version":3,"file":"scope2.cjs","sources":["../../node_modules/.pnpm/use-sync-external-store@1.2.0_react@18.2.0/node_modules/use-sync-external-store/cjs/use-sync-external-store-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-with-selector.development.js","../../node_modules/.pnpm/use-sync-external-store@1.2.0_react@18.2.0/node_modules/use-sync-external-store/with-selector.js","../../src/react/useStore.ts","../../src/react/useProp.ts","../../src/react/reactMethods.ts","../../src/react/useCache.ts","../../src/react/scope.tsx"],"sourcesContent":["/**\n * @license React\n * use-sync-external-store-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 g=require(\"react\");function n(a,b){return a===b&&(0!==a||1/a===1/b)||a!==a&&b!==b}var p=\"function\"===typeof Object.is?Object.is:n,q=g.useSyncExternalStore,r=g.useRef,t=g.useEffect,u=g.useMemo,v=g.useDebugValue;\nexports.useSyncExternalStoreWithSelector=function(a,b,e,l,h){var c=r(null);if(null===c.current){var f={hasValue:!1,value:null};c.current=f}else f=c.current;c=u(function(){function a(a){if(!c){c=!0;d=a;a=l(a);if(void 0!==h&&f.hasValue){var b=f.value;if(h(b,a))return k=b}return k=a}b=k;if(p(d,a))return b;var e=l(a);if(void 0!==h&&h(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,h]);var d=q(a,c[0],c[1]);\nt(function(){f.hasValue=!0;f.value=d},[d]);v(d);return d};\n","/**\n * @license React\n * use-sync-external-store-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');\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 = React.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-with-selector.production.min.js');\n} else {\n module.exports = require('./cjs/use-sync-external-store-with-selector.development.js');\n}\n","import { useCallback, useDebugValue, useLayoutEffect, useMemo, useRef } from 'react';\nimport { useSyncExternalStoreWithSelector } from 'use-sync-external-store/with-selector.js';\nimport type { SubscribeOptions } from '@core/commonTypes';\nimport type { Store } from '@core/store';\nimport { hash } from '@lib/hash';\nimport { makeSelector } from '@lib/makeSelector';\nimport { trackingProxy } from '@lib/trackingProxy';\n\nexport type UseStoreOptions = Omit<SubscribeOptions, 'runNow' | 'passive'>;\n\nexport function useStore<T>(store: Store<T>, options?: UseStoreOptions): T {\n const lastEqualsRef = useRef<(newValue: T) => boolean>();\n\n const { rootStore, selector } = useMemo(() => {\n const rootStore = store.derivedFrom?.store ?? store;\n let selector = (x: any) => x;\n\n if (store.derivedFrom) {\n selector = (value: any) => {\n for (const s of store.derivedFrom!.selectors) {\n value = makeSelector(s)(value);\n }\n return value;\n };\n }\n\n return { rootStore, selector };\n }, [store]);\n\n const subOptions = { ...options, runNow: false, equals: undefined, passive: false };\n const subscribe = useCallback(\n (listener: () => void) => {\n return rootStore.subscribe(listener, subOptions);\n },\n [rootStore, hash(subOptions)],\n );\n\n const value = useSyncExternalStoreWithSelector<unknown, T>(\n //\n subscribe,\n rootStore.get,\n undefined,\n selector,\n options?.equals ?? ((_v, newValue) => lastEqualsRef.current?.(newValue) ?? false),\n );\n const [proxiedValue, equals] = trackingProxy(value);\n\n useLayoutEffect(() => {\n lastEqualsRef.current = equals;\n });\n\n useDebugValue(value);\n return proxiedValue;\n}\n","import type { UseStoreOptions } from './useStore';\nimport { useStore } from './useStore';\nimport type { Store } from '@core/store';\n\nexport function useProp<T>(\n store: Store<T>,\n options?: UseStoreOptions,\n): [value: T, setValue: typeof store.set] {\n const value = useStore(store, options);\n\n return [value, store.set];\n}\n","import { useProp } from './useProp';\nimport { type UseStoreOptions, useStore } from './useStore';\nimport type { Store } from '@core/store';\n\nexport const reactMethods = {\n useStore<T>(this: Store<T>, options?: UseStoreOptions) {\n return useStore(this, options);\n },\n\n useProp<T>(this: Store<T>, options?: UseStoreOptions) {\n return useProp(this, options);\n },\n};\n","import { useEffect, useMemo } from 'react';\nimport type { UseStoreOptions } from './useStore';\nimport { useStore } from './useStore';\nimport type { Cache } from '@core';\nimport type { CacheState } from '@lib/cacheState';\nimport { makeSelector } from '@lib/makeSelector';\n\nexport type UseCacheArray<T> = [\n value: T | undefined,\n error: unknown | undefined,\n isUpdating: boolean,\n isStale: boolean,\n];\n\nexport type UseCacheValue<T> = UseCacheArray<T> & CacheState<T>;\n\nexport interface UseCacheOptions extends UseStoreOptions {\n passive?: boolean;\n updateOnMount?: boolean;\n}\n\nexport function useCache<T>(\n cache: Cache<T>,\n { passive, updateOnMount, ...options }: UseCacheOptions = {},\n): UseCacheValue<T> {\n const mappedState = useMemo(() => {\n const rootCache: Cache<any> = cache.derivedFromCache?.cache ?? cache;\n let selector = (x: any) => x;\n\n if (cache.derivedFromCache) {\n selector = (value: any) => {\n for (const s of cache.derivedFromCache!.selectors) {\n value = makeSelector(s)(value);\n }\n return value;\n };\n }\n\n return rootCache.state.map((state) => {\n const value = state.status === 'value' ? selector(state.value) : undefined;\n\n return Object.assign<UseCacheArray<T>, CacheState<T>>(\n [value, state.error, state.isUpdating, state.isStale],\n { ...state, value },\n );\n });\n }, [cache]);\n\n useEffect(() => (!passive ? cache.subscribe(() => undefined) : undefined), [cache, passive]);\n\n useEffect(() => {\n if (updateOnMount) {\n cache.invalidate();\n }\n }, []);\n\n return useStore(mappedState, options);\n}\n","import type { Context, ReactNode } from 'react';\nimport { createContext, useContext, useMemo } from 'react';\nimport { useProp } from './useProp';\nimport { useStore, type UseStoreOptions } from './useStore';\nimport { createStore } from '@core/store';\nimport type { Store } from '@core/store';\nimport type { Scope } from '@core';\n\nexport type ScopeProps<T> = { scope: Scope<T>; store?: Store<T>; children?: ReactNode };\n\nconst contextMap = new WeakMap<Scope<any>, Context<Store<any>>>();\n\nfunction getScopeContext<T>(scope: Scope<T>): Context<Store<T>> {\n let context = contextMap.get(scope);\n\n if (!context) {\n context = createContext<Store<T>>(createStore(scope.defaultValue));\n contextMap.set(scope, context);\n }\n\n return context;\n}\n\nexport function ScopeProvider<T>({ scope, store: inputStore, children }: ScopeProps<T>) {\n const context = getScopeContext(scope);\n const currentStore = useMemo(\n () => inputStore ?? createStore(scope.defaultValue),\n [scope, inputStore],\n );\n\n return <context.Provider value={currentStore}>{children}</context.Provider>;\n}\n\nexport function useScope<T>(scope: Scope<T>): Store<T> {\n const context = getScopeContext(scope);\n return useContext(context);\n}\n\nexport function useScopeStore<T>(scope: Scope<T>, options?: UseStoreOptions): T {\n const store = useScope(scope);\n return useStore(store, options);\n}\n\nexport function useScopeProp<T>(scope: Scope<T>, options?: UseStoreOptions) {\n const store = useScope(scope);\n return useProp(store, options);\n}\n"],"names":["a","c","d","b","e","module","require$$0","require$$1","store","useRef","useMemo","rootStore","selector","value","makeSelector","useCallback","hash","useSyncExternalStoreWithSelector","trackingProxy","useLayoutEffect","useDebugValue","useEffect","createContext","createStore","useContext"],"mappings":";;;;;;;;;;;;;;;;;;;;;;;;;;;;;AASa,MAAI,IAAE;AAAiB,WAAS,EAAE,GAAE,GAAE;AAAC,WAAO,MAAI,MAAI,MAAI,KAAG,IAAE,MAAI,IAAE,MAAI,MAAI,KAAG,MAAI;AAAA,EAAC;AAAC,MAAI,IAAE,eAAa,OAAO,OAAO,KAAG,OAAO,KAAG,GAAE,IAAE,EAAE,sBAAqB,IAAE,EAAE,QAAO,IAAE,EAAE,WAAU,IAAE,EAAE,SAAQ,IAAE,EAAE;A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B;AAC/C,QAAA,UAAU,gBAAgB,KAAK;AACrC,SAAOC,WAAAA,WAAW,OAAO;AAC3B;AAEgB,SAAA,cAAiB,OAAiB,SAA8B;AACxE,QAAAhB,SAAQ,SAAS,KAAK;AACrB,SAAA,SAASA,QAAO,OAAO;AAChC;AAEgB,SAAA,aAAgB,OAAiB,SAA2B;AACpE,QAAAA,SAAQ,SAAS,KAAK;AACrB,SAAA,QAAQA,QAAO,OAAO;AAC/B;;;;;;;;;","x_google_ignoreList":[0,1,2]}
1
+ {"version":3,"file":"scope2.cjs","sources":["../../node_modules/.pnpm/use-sync-external-store@1.2.0_react@18.2.0/node_modules/use-sync-external-store/cjs/use-sync-external-store-shim.production.min.js","../../node_modules/.pnpm/use-sync-external-store@1.2.0_react@18.2.0/node_modules/use-sync-external-store/cjs/use-sync-external-store-shim.development.js","../../node_modules/.pnpm/use-sync-external-store@1.2.0_react@18.2.0/node_modules/use-sync-external-store/shim/index.js","../../node_modules/.pnpm/use-sync-external-store@1.2.0_react@18.2.0/node_modules/use-sync-external-store/cjs/use-sync-external-store-shim/with-selector.production.min.js","../../node_modules/.pnpm/use-sync-external-store@1.2.0_react@18.2.0/node_modules/use-sync-external-store/cjs/use-sync-external-store-shim/with-selector.development.js","../../node_modules/.pnpm/use-sync-external-store@1.2.0_react@18.2.0/node_modules/use-sync-external-store/shim/with-selector.js","../../src/react/useStore.ts","../../src/react/useProp.ts","../../src/react/reactMethods.ts","../../src/react/useCache.ts","../../src/react/scope.tsx"],"sourcesContent":["/**\n * @license React\n * use-sync-external-store-shim.production.min.js\n *\n * Copyright (c) Facebook, Inc. and its affiliates.\n *\n * This source code is licensed under the MIT license found in the\n * LICENSE file in the root directory of this source tree.\n */\n'use strict';var e=require(\"react\");function h(a,b){return a===b&&(0!==a||1/a===1/b)||a!==a&&b!==b}var k=\"function\"===typeof Object.is?Object.is:h,l=e.useState,m=e.useEffect,n=e.useLayoutEffect,p=e.useDebugValue;function q(a,b){var d=b(),f=l({inst:{value:d,getSnapshot:b}}),c=f[0].inst,g=f[1];n(function(){c.value=d;c.getSnapshot=b;r(c)&&g({inst:c})},[a,d,b]);m(function(){r(c)&&g({inst:c});return a(function(){r(c)&&g({inst:c})})},[a]);p(d);return d}\nfunction r(a){var b=a.getSnapshot;a=a.value;try{var d=b();return!k(a,d)}catch(f){return!0}}function t(a,b){return b()}var u=\"undefined\"===typeof window||\"undefined\"===typeof window.document||\"undefined\"===typeof window.document.createElement?t:q;exports.useSyncExternalStore=void 0!==e.useSyncExternalStore?e.useSyncExternalStore:u;\n","/**\n * @license React\n * use-sync-external-store-shim.development.js\n *\n * Copyright (c) Facebook, Inc. and its affiliates.\n *\n * This source code is licensed under the MIT license found in the\n * LICENSE file in the root directory of this source tree.\n */\n\n'use strict';\n\nif (process.env.NODE_ENV !== \"production\") {\n (function() {\n\n 'use strict';\n\n/* global __REACT_DEVTOOLS_GLOBAL_HOOK__ */\nif (\n typeof __REACT_DEVTOOLS_GLOBAL_HOOK__ !== 'undefined' &&\n typeof __REACT_DEVTOOLS_GLOBAL_HOOK__.registerInternalModuleStart ===\n 'function'\n) {\n __REACT_DEVTOOLS_GLOBAL_HOOK__.registerInternalModuleStart(new Error());\n}\n var React = require('react');\n\nvar ReactSharedInternals = React.__SECRET_INTERNALS_DO_NOT_USE_OR_YOU_WILL_BE_FIRED;\n\nfunction error(format) {\n {\n {\n for (var _len2 = arguments.length, args = new Array(_len2 > 1 ? _len2 - 1 : 0), _key2 = 1; _key2 < _len2; _key2++) {\n args[_key2 - 1] = arguments[_key2];\n }\n\n printWarning('error', format, args);\n }\n }\n}\n\nfunction printWarning(level, format, args) {\n // When changing this logic, you might want to also\n // update consoleWithStackDev.www.js as well.\n {\n var ReactDebugCurrentFrame = ReactSharedInternals.ReactDebugCurrentFrame;\n var stack = ReactDebugCurrentFrame.getStackAddendum();\n\n if (stack !== '') {\n format += '%s';\n args = args.concat([stack]);\n } // eslint-disable-next-line react-internal/safe-string-coercion\n\n\n var argsWithFormat = args.map(function (item) {\n return String(item);\n }); // Careful: RN currently depends on this prefix\n\n argsWithFormat.unshift('Warning: ' + format); // We intentionally don't use spread (or .apply) directly because it\n // breaks IE9: https://github.com/facebook/react/issues/13610\n // eslint-disable-next-line react-internal/no-production-logging\n\n Function.prototype.apply.call(console[level], console, argsWithFormat);\n }\n}\n\n/**\n * inlined Object.is polyfill to avoid requiring consumers ship their own\n * https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/Object/is\n */\nfunction is(x, y) {\n return x === y && (x !== 0 || 1 / x === 1 / y) || x !== x && y !== y // eslint-disable-line no-self-compare\n ;\n}\n\nvar objectIs = typeof Object.is === 'function' ? Object.is : is;\n\n// dispatch for CommonJS interop named imports.\n\nvar useState = React.useState,\n useEffect = React.useEffect,\n useLayoutEffect = React.useLayoutEffect,\n useDebugValue = React.useDebugValue;\nvar didWarnOld18Alpha = false;\nvar didWarnUncachedGetSnapshot = false; // Disclaimer: This shim breaks many of the rules of React, and only works\n// because of a very particular set of implementation details and assumptions\n// -- change any one of them and it will break. The most important assumption\n// is that updates are always synchronous, because concurrent rendering is\n// only available in versions of React that also have a built-in\n// useSyncExternalStore API. And we only use this shim when the built-in API\n// does not exist.\n//\n// Do not assume that the clever hacks used by this hook also work in general.\n// The point of this shim is to replace the need for hacks by other libraries.\n\nfunction useSyncExternalStore(subscribe, getSnapshot, // Note: The shim does not use getServerSnapshot, because pre-18 versions of\n// React do not expose a way to check if we're hydrating. So users of the shim\n// will need to track that themselves and return the correct value\n// from `getSnapshot`.\ngetServerSnapshot) {\n {\n if (!didWarnOld18Alpha) {\n if (React.startTransition !== undefined) {\n didWarnOld18Alpha = true;\n\n error('You are using an outdated, pre-release alpha of React 18 that ' + 'does not support useSyncExternalStore. The ' + 'use-sync-external-store shim will not work correctly. Upgrade ' + 'to a newer pre-release.');\n }\n }\n } // Read the current snapshot from the store on every render. Again, this\n // breaks the rules of React, and only works here because of specific\n // implementation details, most importantly that updates are\n // always synchronous.\n\n\n var value = getSnapshot();\n\n {\n if (!didWarnUncachedGetSnapshot) {\n var cachedValue = getSnapshot();\n\n if (!objectIs(value, cachedValue)) {\n error('The result of getSnapshot should be cached to avoid an infinite loop');\n\n didWarnUncachedGetSnapshot = true;\n }\n }\n } // Because updates are synchronous, we don't queue them. Instead we force a\n // re-render whenever the subscribed state changes by updating an some\n // arbitrary useState hook. Then, during render, we call getSnapshot to read\n // the current value.\n //\n // Because we don't actually use the state returned by the useState hook, we\n // can save a bit of memory by storing other stuff in that slot.\n //\n // To implement the early bailout, we need to track some things on a mutable\n // object. Usually, we would put that in a useRef hook, but we can stash it in\n // our useState hook instead.\n //\n // To force a re-render, we call forceUpdate({inst}). That works because the\n // new object always fails an equality check.\n\n\n var _useState = useState({\n inst: {\n value: value,\n getSnapshot: getSnapshot\n }\n }),\n inst = _useState[0].inst,\n forceUpdate = _useState[1]; // Track the latest getSnapshot function with a ref. This needs to be updated\n // in the layout phase so we can access it during the tearing check that\n // happens on subscribe.\n\n\n useLayoutEffect(function () {\n inst.value = value;\n inst.getSnapshot = getSnapshot; // Whenever getSnapshot or subscribe changes, we need to check in the\n // commit phase if there was an interleaved mutation. In concurrent mode\n // this can happen all the time, but even in synchronous mode, an earlier\n // effect may have mutated the store.\n\n if (checkIfSnapshotChanged(inst)) {\n // Force a re-render.\n forceUpdate({\n inst: inst\n });\n }\n }, [subscribe, value, getSnapshot]);\n useEffect(function () {\n // Check for changes right before subscribing. Subsequent changes will be\n // detected in the subscription handler.\n if (checkIfSnapshotChanged(inst)) {\n // Force a re-render.\n forceUpdate({\n inst: inst\n });\n }\n\n var handleStoreChange = function () {\n // TODO: Because there is no cross-renderer API for batching updates, it's\n // up to the consumer of this library to wrap their subscription event\n // with unstable_batchedUpdates. Should we try to detect when this isn't\n // the case and print a warning in development?\n // The store changed. Check if the snapshot changed since the last time we\n // read from the store.\n if (checkIfSnapshotChanged(inst)) {\n // Force a re-render.\n forceUpdate({\n inst: inst\n });\n }\n }; // Subscribe to the store and return a clean-up function.\n\n\n return subscribe(handleStoreChange);\n }, [subscribe]);\n useDebugValue(value);\n return value;\n}\n\nfunction checkIfSnapshotChanged(inst) {\n var latestGetSnapshot = inst.getSnapshot;\n var prevValue = inst.value;\n\n try {\n var nextValue = latestGetSnapshot();\n return !objectIs(prevValue, nextValue);\n } catch (error) {\n return true;\n }\n}\n\nfunction useSyncExternalStore$1(subscribe, getSnapshot, getServerSnapshot) {\n // Note: The shim does not use getServerSnapshot, because pre-18 versions of\n // React do not expose a way to check if we're hydrating. So users of the shim\n // will need to track that themselves and return the correct value\n // from `getSnapshot`.\n return getSnapshot();\n}\n\nvar canUseDOM = !!(typeof window !== 'undefined' && typeof window.document !== 'undefined' && typeof window.document.createElement !== 'undefined');\n\nvar isServerEnvironment = !canUseDOM;\n\nvar shim = isServerEnvironment ? useSyncExternalStore$1 : useSyncExternalStore;\nvar useSyncExternalStore$2 = React.useSyncExternalStore !== undefined ? React.useSyncExternalStore : shim;\n\nexports.useSyncExternalStore = useSyncExternalStore$2;\n /* global __REACT_DEVTOOLS_GLOBAL_HOOK__ */\nif (\n typeof __REACT_DEVTOOLS_GLOBAL_HOOK__ !== 'undefined' &&\n typeof __REACT_DEVTOOLS_GLOBAL_HOOK__.registerInternalModuleStop ===\n 'function'\n) {\n __REACT_DEVTOOLS_GLOBAL_HOOK__.registerInternalModuleStop(new Error());\n}\n \n })();\n}\n","'use strict';\n\nif (process.env.NODE_ENV === 'production') {\n module.exports = require('../cjs/use-sync-external-store-shim.production.min.js');\n} else {\n module.exports = require('../cjs/use-sync-external-store-shim.development.js');\n}\n","/**\n * @license React\n * use-sync-external-store-shim/with-selector.production.min.js\n *\n * Copyright (c) Facebook, Inc. and its affiliates.\n *\n * This source code is licensed under the MIT license found in the\n * LICENSE file in the root directory of this source tree.\n */\n'use strict';var h=require(\"react\"),n=require(\"use-sync-external-store/shim\");function p(a,b){return a===b&&(0!==a||1/a===1/b)||a!==a&&b!==b}var q=\"function\"===typeof Object.is?Object.is:p,r=n.useSyncExternalStore,t=h.useRef,u=h.useEffect,v=h.useMemo,w=h.useDebugValue;\nexports.useSyncExternalStoreWithSelector=function(a,b,e,l,g){var c=t(null);if(null===c.current){var f={hasValue:!1,value:null};c.current=f}else f=c.current;c=v(function(){function a(a){if(!c){c=!0;d=a;a=l(a);if(void 0!==g&&f.hasValue){var b=f.value;if(g(b,a))return k=b}return k=a}b=k;if(q(d,a))return b;var e=l(a);if(void 0!==g&&g(b,e))return b;d=a;return k=e}var c=!1,d,k,m=void 0===e?null:e;return[function(){return a(b())},null===m?void 0:function(){return a(m())}]},[b,e,l,g]);var d=r(a,c[0],c[1]);\nu(function(){f.hasValue=!0;f.value=d},[d]);w(d);return d};\n","/**\n * @license React\n * use-sync-external-store-shim/with-selector.development.js\n *\n * Copyright (c) Facebook, Inc. and its affiliates.\n *\n * This source code is licensed under the MIT license found in the\n * LICENSE file in the root directory of this source tree.\n */\n\n'use strict';\n\nif (process.env.NODE_ENV !== \"production\") {\n (function() {\n\n 'use strict';\n\n/* global __REACT_DEVTOOLS_GLOBAL_HOOK__ */\nif (\n typeof __REACT_DEVTOOLS_GLOBAL_HOOK__ !== 'undefined' &&\n typeof __REACT_DEVTOOLS_GLOBAL_HOOK__.registerInternalModuleStart ===\n 'function'\n) {\n __REACT_DEVTOOLS_GLOBAL_HOOK__.registerInternalModuleStart(new Error());\n}\n var React = require('react');\nvar shim = require('use-sync-external-store/shim');\n\n/**\n * inlined Object.is polyfill to avoid requiring consumers ship their own\n * https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/Object/is\n */\nfunction is(x, y) {\n return x === y && (x !== 0 || 1 / x === 1 / y) || x !== x && y !== y // eslint-disable-line no-self-compare\n ;\n}\n\nvar objectIs = typeof Object.is === 'function' ? Object.is : is;\n\nvar useSyncExternalStore = shim.useSyncExternalStore;\n\n// for CommonJS interop.\n\nvar useRef = React.useRef,\n useEffect = React.useEffect,\n useMemo = React.useMemo,\n useDebugValue = React.useDebugValue; // Same as useSyncExternalStore, but supports selector and isEqual arguments.\n\nfunction useSyncExternalStoreWithSelector(subscribe, getSnapshot, getServerSnapshot, selector, isEqual) {\n // Use this to track the rendered snapshot.\n var instRef = useRef(null);\n var inst;\n\n if (instRef.current === null) {\n inst = {\n hasValue: false,\n value: null\n };\n instRef.current = inst;\n } else {\n inst = instRef.current;\n }\n\n var _useMemo = useMemo(function () {\n // Track the memoized state using closure variables that are local to this\n // memoized instance of a getSnapshot function. Intentionally not using a\n // useRef hook, because that state would be shared across all concurrent\n // copies of the hook/component.\n var hasMemo = false;\n var memoizedSnapshot;\n var memoizedSelection;\n\n var memoizedSelector = function (nextSnapshot) {\n if (!hasMemo) {\n // The first time the hook is called, there is no memoized result.\n hasMemo = true;\n memoizedSnapshot = nextSnapshot;\n\n var _nextSelection = selector(nextSnapshot);\n\n if (isEqual !== undefined) {\n // Even if the selector has changed, the currently rendered selection\n // may be equal to the new selection. We should attempt to reuse the\n // current value if possible, to preserve downstream memoizations.\n if (inst.hasValue) {\n var currentSelection = inst.value;\n\n if (isEqual(currentSelection, _nextSelection)) {\n memoizedSelection = currentSelection;\n return currentSelection;\n }\n }\n }\n\n memoizedSelection = _nextSelection;\n return _nextSelection;\n } // We may be able to reuse the previous invocation's result.\n\n\n // We may be able to reuse the previous invocation's result.\n var prevSnapshot = memoizedSnapshot;\n var prevSelection = memoizedSelection;\n\n if (objectIs(prevSnapshot, nextSnapshot)) {\n // The snapshot is the same as last time. Reuse the previous selection.\n return prevSelection;\n } // The snapshot has changed, so we need to compute a new selection.\n\n\n // The snapshot has changed, so we need to compute a new selection.\n var nextSelection = selector(nextSnapshot); // If a custom isEqual function is provided, use that to check if the data\n // has changed. If it hasn't, return the previous selection. That signals\n // to React that the selections are conceptually equal, and we can bail\n // out of rendering.\n\n // If a custom isEqual function is provided, use that to check if the data\n // has changed. If it hasn't, return the previous selection. That signals\n // to React that the selections are conceptually equal, and we can bail\n // out of rendering.\n if (isEqual !== undefined && isEqual(prevSelection, nextSelection)) {\n return prevSelection;\n }\n\n memoizedSnapshot = nextSnapshot;\n memoizedSelection = nextSelection;\n return nextSelection;\n }; // Assigning this to a constant so that Flow knows it can't change.\n\n\n // Assigning this to a constant so that Flow knows it can't change.\n var maybeGetServerSnapshot = getServerSnapshot === undefined ? null : getServerSnapshot;\n\n var getSnapshotWithSelector = function () {\n return memoizedSelector(getSnapshot());\n };\n\n var getServerSnapshotWithSelector = maybeGetServerSnapshot === null ? undefined : function () {\n return memoizedSelector(maybeGetServerSnapshot());\n };\n return [getSnapshotWithSelector, getServerSnapshotWithSelector];\n }, [getSnapshot, getServerSnapshot, selector, isEqual]),\n getSelection = _useMemo[0],\n getServerSelection = _useMemo[1];\n\n var value = useSyncExternalStore(subscribe, getSelection, getServerSelection);\n useEffect(function () {\n inst.hasValue = true;\n inst.value = value;\n }, [value]);\n useDebugValue(value);\n return value;\n}\n\nexports.useSyncExternalStoreWithSelector = useSyncExternalStoreWithSelector;\n /* global __REACT_DEVTOOLS_GLOBAL_HOOK__ */\nif (\n typeof __REACT_DEVTOOLS_GLOBAL_HOOK__ !== 'undefined' &&\n typeof __REACT_DEVTOOLS_GLOBAL_HOOK__.registerInternalModuleStop ===\n 'function'\n) {\n __REACT_DEVTOOLS_GLOBAL_HOOK__.registerInternalModuleStop(new Error());\n}\n \n })();\n}\n","'use strict';\n\nif (process.env.NODE_ENV === 'production') {\n module.exports = require('../cjs/use-sync-external-store-shim/with-selector.production.min.js');\n} else {\n module.exports = require('../cjs/use-sync-external-store-shim/with-selector.development.js');\n}\n","import { useCallback, useDebugValue, useLayoutEffect, useMemo, useRef } from 'react';\nimport { useSyncExternalStoreWithSelector } from 'use-sync-external-store/shim/with-selector.js';\nimport type { SubscribeOptions } from '@core/commonTypes';\nimport type { Store } from '@core/store';\nimport { hash } from '@lib/hash';\nimport { makeSelector } from '@lib/makeSelector';\nimport { trackingProxy } from '@lib/trackingProxy';\n\nexport type UseStoreOptions = Omit<SubscribeOptions, 'runNow' | 'passive'>;\n\nexport function useStore<T>(store: Store<T>, options?: UseStoreOptions): T {\n const lastEqualsRef = useRef<(newValue: T) => boolean>();\n\n const { rootStore, selector } = useMemo(() => {\n const rootStore = store.derivedFrom?.store ?? store;\n let selector = (x: any) => x;\n\n if (store.derivedFrom) {\n selector = (value: any) => {\n for (const s of store.derivedFrom!.selectors) {\n value = makeSelector(s)(value);\n }\n return value;\n };\n }\n\n return { rootStore, selector };\n }, [store]);\n\n const subOptions = { ...options, runNow: false, equals: undefined, passive: false };\n const subscribe = useCallback(\n (listener: () => void) => {\n return rootStore.subscribe(listener, subOptions);\n },\n [rootStore, hash(subOptions)],\n );\n\n const value = useSyncExternalStoreWithSelector<unknown, T>(\n //\n subscribe,\n rootStore.get,\n undefined,\n selector,\n options?.equals ?? ((_v, newValue) => lastEqualsRef.current?.(newValue) ?? false),\n );\n const [proxiedValue, equals] = trackingProxy(value);\n\n useLayoutEffect(() => {\n lastEqualsRef.current = equals;\n });\n\n useDebugValue(value);\n return proxiedValue;\n}\n","import type { UseStoreOptions } from './useStore';\nimport { useStore } from './useStore';\nimport type { Store } from '@core/store';\n\nexport function useProp<T>(\n store: Store<T>,\n options?: UseStoreOptions,\n): [value: T, setValue: typeof store.set] {\n const value = useStore(store, options);\n\n return [value, store.set];\n}\n","import { useProp } from './useProp';\nimport { type UseStoreOptions, useStore } from './useStore';\nimport type { Store } from '@core/store';\n\nexport const reactMethods = {\n useStore<T>(this: Store<T>, options?: UseStoreOptions) {\n return useStore(this, options);\n },\n\n useProp<T>(this: Store<T>, options?: UseStoreOptions) {\n return useProp(this, options);\n },\n};\n","import { useEffect, useMemo } from 'react';\nimport type { UseStoreOptions } from './useStore';\nimport { useStore } from './useStore';\nimport type { Cache } from '@core';\nimport type { CacheState } from '@lib/cacheState';\nimport { makeSelector } from '@lib/makeSelector';\n\nexport type UseCacheArray<T> = [\n value: T | undefined,\n error: unknown | undefined,\n isUpdating: boolean,\n isStale: boolean,\n];\n\nexport type UseCacheValue<T> = UseCacheArray<T> & CacheState<T>;\n\nexport interface UseCacheOptions extends UseStoreOptions {\n passive?: boolean;\n updateOnMount?: boolean;\n}\n\nexport function useCache<T>(\n cache: Cache<T>,\n { passive, updateOnMount, ...options }: UseCacheOptions = {},\n): UseCacheValue<T> {\n const mappedState = useMemo(() => {\n const rootCache: Cache<any> = cache.derivedFromCache?.cache ?? cache;\n let selector = (x: any) => x;\n\n if (cache.derivedFromCache) {\n selector = (value: any) => {\n for (const s of cache.derivedFromCache!.selectors) {\n value = makeSelector(s)(value);\n }\n return value;\n };\n }\n\n return rootCache.state.map((state) => {\n const value = state.status === 'value' ? selector(state.value) : undefined;\n\n return Object.assign<UseCacheArray<T>, CacheState<T>>(\n [value, state.error, state.isUpdating, state.isStale],\n { ...state, value },\n );\n });\n }, [cache]);\n\n useEffect(() => (!passive ? cache.subscribe(() => undefined) : undefined), [cache, passive]);\n\n useEffect(() => {\n if (updateOnMount) {\n cache.invalidate();\n }\n }, []);\n\n return useStore(mappedState, options);\n}\n","import type { Context, ReactNode } from 'react';\nimport { createContext, useContext, useMemo } from 'react';\nimport { useProp } from './useProp';\nimport { useStore, type UseStoreOptions } from './useStore';\nimport { createStore } from '@core/store';\nimport type { Store } from '@core/store';\nimport type { Scope } from '@core';\n\nexport type ScopeProps<T> = { scope: Scope<T>; store?: Store<T>; children?: ReactNode };\n\nconst contextMap = new WeakMap<Scope<any>, Context<Store<any>>>();\n\nfunction getScopeContext<T>(scope: Scope<T>): Context<Store<T>> {\n let context = contextMap.get(scope);\n\n if (!context) {\n context = createContext<Store<T>>(createStore(scope.defaultValue));\n contextMap.set(scope, context);\n }\n\n return context;\n}\n\nexport function ScopeProvider<T>({ scope, store: inputStore, children }: ScopeProps<T>) {\n const context = getScopeContext(scope);\n const currentStore = useMemo(\n () => inputStore ?? createStore(scope.defaultValue),\n [scope, inputStore],\n );\n\n return <context.Provider value={currentStore}>{children}</context.Provider>;\n}\n\nexport function useScope<T>(scope: Scope<T>): Store<T> {\n const context = getScopeContext(scope);\n return useContext(context);\n}\n\nexport function useScopeStore<T>(scope: Scope<T>, options?: UseStoreOptions): T {\n const store = useScope(scope);\n return useStore(store, options);\n}\n\nexport function useScopeProp<T>(scope: Scope<T>, options?: UseStoreOptions) {\n const store = useScope(scope);\n return useProp(store, options);\n}\n"],"names":["error","shim","module","require$$0","require$$1","a","c","d","b","e","store","useRef","useMemo","rootStore","selector","value","makeSelector","useCallback","hash","useSyncExternalStoreWithSelector","trackingProxy","useLayoutEffect","useDebugValue","useEffect","createContext","createStore","useContext"],"mappings":";;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;AASa,MAAI,IAAE;AAAiB,WAAS,EAAE,GAAE,GAAE;AAAC,WAAO,MAAI,MAAI,MAAI,KAAG,IAAE,MAAI,IAAE,MAAI,MAAI,KAAG,MAAI;AAAA,EAAC;AAAC,MAAI,IAAE,eAAa,OAAO,OAAO,KAAG,OAAO,KAAG,GAAE,IAAE,EAAE,UAAS,IAAE,EAAE,WAAU,IAAE,EAAE,iBAAgB,IAAE,EAAE;AAAc,WAAS,EAAE,GAAE,GAAE;AAAC,QAAI,IAAE,EAAC,GAAG,IAAE,EAAE,EAAC,MAAK,EAAC,OAAM,GAAE,aAAY,EAAC,EAAC,CAAC,GAAE,IAAE,EAAE,CAAC,EAAE,MAAK,IAAE,EAAE,CAAC;AAAE,MAAE,WAAU;AAAC,QAAE,QAAM;AAAE,QAAE,cAAY;AAAE,QAAE,CAAC,KAAG,EAAE,EAAC,MAAK,EAAC,CAAC;AAAA,IAAC,GAAE,CAAC,GAAE,GAAE,CAAC,CAAC;AAAE,MAAE,WAAU;AAAC,QAAE,CAAC,KAAG,EAAE,EAAC,MAAK,EAAC,CAAC;AAAE,aAAO,EAAE,WAAU;AAAC,UAAE,CAAC,KAAG,EAAE,EAAC,MAAK,EAAC,CAAC;AAAA,MAAC,CAAC;AAAA,IAAC,GAAE,CAAC,CAAC,CAAC;AAAE,MAAE,CAAC;AAAE,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,OAAO,UAAU;AAAA,EAAA;AAGpB,wCAAQ,QAAQ,UAAR,EAAiB,OAAO,cAAe,SAAS,CAAA;AAC1D;AAEO,SAAS,SAAY,OAA2B;AAC/C,QAAA,UAAU,gBAAgB,KAAK;AACrC,SAAOC,WAAAA,WAAW,OAAO;AAC3B;AAEgB,SAAA,cAAiB,OAAiB,SAA8B;AACxE,QAAAhB,SAAQ,SAAS,KAAK;AACrB,SAAA,SAASA,QAAO,OAAO;AAChC;AAEgB,SAAA,aAAgB,OAAiB,SAA2B;AACpE,QAAAA,SAAQ,SAAS,KAAK;AACrB,SAAA,QAAQA,QAAO,OAAO;AAC/B;;;;;;;;;","x_google_ignoreList":[0,1,2,3,4,5]}
package/dist/es/index.mjs CHANGED
@@ -447,9 +447,11 @@ export {
447
447
  createSubscriptionCache,
448
448
  createUrlStore,
449
449
  findOrDefault,
450
+ get,
450
451
  m as mapMethods,
451
452
  persist,
452
453
  r as recordMethods,
454
+ set,
453
455
  f as setMethods
454
456
  };
455
457
  //# sourceMappingURL=index.mjs.map
@@ -11,51 +11,258 @@ var withSelector = {
11
11
  withSelectorExports = v;
12
12
  }
13
13
  };
14
- var useSyncExternalStoreWithSelector_production_min = {};
14
+ var withSelector_production_min = {};
15
+ var shimExports = {};
16
+ var shim = {
17
+ get exports() {
18
+ return shimExports;
19
+ },
20
+ set exports(v) {
21
+ shimExports = v;
22
+ }
23
+ };
24
+ var useSyncExternalStoreShim_production_min = {};
25
+ /**
26
+ * @license React
27
+ * use-sync-external-store-shim.production.min.js
28
+ *
29
+ * Copyright (c) Facebook, Inc. and its affiliates.
30
+ *
31
+ * This source code is licensed under the MIT license found in the
32
+ * LICENSE file in the root directory of this source tree.
33
+ */
34
+ var hasRequiredUseSyncExternalStoreShim_production_min;
35
+ function requireUseSyncExternalStoreShim_production_min() {
36
+ if (hasRequiredUseSyncExternalStoreShim_production_min)
37
+ return useSyncExternalStoreShim_production_min;
38
+ hasRequiredUseSyncExternalStoreShim_production_min = 1;
39
+ var e = require$$0;
40
+ function h(a, b) {
41
+ return a === b && (0 !== a || 1 / a === 1 / b) || a !== a && b !== b;
42
+ }
43
+ var k = "function" === typeof Object.is ? Object.is : h, l = e.useState, m = e.useEffect, n = e.useLayoutEffect, p = e.useDebugValue;
44
+ function q(a, b) {
45
+ var d = b(), f = l({ inst: { value: d, getSnapshot: b } }), c = f[0].inst, g = f[1];
46
+ n(function() {
47
+ c.value = d;
48
+ c.getSnapshot = b;
49
+ r(c) && g({ inst: c });
50
+ }, [a, d, b]);
51
+ m(function() {
52
+ r(c) && g({ inst: c });
53
+ return a(function() {
54
+ r(c) && g({ inst: c });
55
+ });
56
+ }, [a]);
57
+ p(d);
58
+ return d;
59
+ }
60
+ function r(a) {
61
+ var b = a.getSnapshot;
62
+ a = a.value;
63
+ try {
64
+ var d = b();
65
+ return !k(a, d);
66
+ } catch (f) {
67
+ return true;
68
+ }
69
+ }
70
+ function t(a, b) {
71
+ return b();
72
+ }
73
+ var u = "undefined" === typeof window || "undefined" === typeof window.document || "undefined" === typeof window.document.createElement ? t : q;
74
+ useSyncExternalStoreShim_production_min.useSyncExternalStore = void 0 !== e.useSyncExternalStore ? e.useSyncExternalStore : u;
75
+ return useSyncExternalStoreShim_production_min;
76
+ }
77
+ var useSyncExternalStoreShim_development = {};
78
+ /**
79
+ * @license React
80
+ * use-sync-external-store-shim.development.js
81
+ *
82
+ * Copyright (c) Facebook, Inc. and its affiliates.
83
+ *
84
+ * This source code is licensed under the MIT license found in the
85
+ * LICENSE file in the root directory of this source tree.
86
+ */
87
+ var hasRequiredUseSyncExternalStoreShim_development;
88
+ function requireUseSyncExternalStoreShim_development() {
89
+ if (hasRequiredUseSyncExternalStoreShim_development)
90
+ return useSyncExternalStoreShim_development;
91
+ hasRequiredUseSyncExternalStoreShim_development = 1;
92
+ if (process.env.NODE_ENV !== "production") {
93
+ (function() {
94
+ if (typeof __REACT_DEVTOOLS_GLOBAL_HOOK__ !== "undefined" && typeof __REACT_DEVTOOLS_GLOBAL_HOOK__.registerInternalModuleStart === "function") {
95
+ __REACT_DEVTOOLS_GLOBAL_HOOK__.registerInternalModuleStart(new Error());
96
+ }
97
+ var React = require$$0;
98
+ var ReactSharedInternals = React.__SECRET_INTERNALS_DO_NOT_USE_OR_YOU_WILL_BE_FIRED;
99
+ function error(format) {
100
+ {
101
+ {
102
+ for (var _len2 = arguments.length, args = new Array(_len2 > 1 ? _len2 - 1 : 0), _key2 = 1; _key2 < _len2; _key2++) {
103
+ args[_key2 - 1] = arguments[_key2];
104
+ }
105
+ printWarning("error", format, args);
106
+ }
107
+ }
108
+ }
109
+ function printWarning(level, format, args) {
110
+ {
111
+ var ReactDebugCurrentFrame = ReactSharedInternals.ReactDebugCurrentFrame;
112
+ var stack = ReactDebugCurrentFrame.getStackAddendum();
113
+ if (stack !== "") {
114
+ format += "%s";
115
+ args = args.concat([stack]);
116
+ }
117
+ var argsWithFormat = args.map(function(item) {
118
+ return String(item);
119
+ });
120
+ argsWithFormat.unshift("Warning: " + format);
121
+ Function.prototype.apply.call(console[level], console, argsWithFormat);
122
+ }
123
+ }
124
+ function is(x, y) {
125
+ return x === y && (x !== 0 || 1 / x === 1 / y) || x !== x && y !== y;
126
+ }
127
+ var objectIs = typeof Object.is === "function" ? Object.is : is;
128
+ var useState = React.useState, useEffect2 = React.useEffect, useLayoutEffect2 = React.useLayoutEffect, useDebugValue2 = React.useDebugValue;
129
+ var didWarnOld18Alpha = false;
130
+ var didWarnUncachedGetSnapshot = false;
131
+ function useSyncExternalStore(subscribe, getSnapshot, getServerSnapshot) {
132
+ {
133
+ if (!didWarnOld18Alpha) {
134
+ if (React.startTransition !== void 0) {
135
+ didWarnOld18Alpha = true;
136
+ 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.");
137
+ }
138
+ }
139
+ }
140
+ var value = getSnapshot();
141
+ {
142
+ if (!didWarnUncachedGetSnapshot) {
143
+ var cachedValue = getSnapshot();
144
+ if (!objectIs(value, cachedValue)) {
145
+ error("The result of getSnapshot should be cached to avoid an infinite loop");
146
+ didWarnUncachedGetSnapshot = true;
147
+ }
148
+ }
149
+ }
150
+ var _useState = useState({
151
+ inst: {
152
+ value,
153
+ getSnapshot
154
+ }
155
+ }), inst = _useState[0].inst, forceUpdate = _useState[1];
156
+ useLayoutEffect2(function() {
157
+ inst.value = value;
158
+ inst.getSnapshot = getSnapshot;
159
+ if (checkIfSnapshotChanged(inst)) {
160
+ forceUpdate({
161
+ inst
162
+ });
163
+ }
164
+ }, [subscribe, value, getSnapshot]);
165
+ useEffect2(function() {
166
+ if (checkIfSnapshotChanged(inst)) {
167
+ forceUpdate({
168
+ inst
169
+ });
170
+ }
171
+ var handleStoreChange = function() {
172
+ if (checkIfSnapshotChanged(inst)) {
173
+ forceUpdate({
174
+ inst
175
+ });
176
+ }
177
+ };
178
+ return subscribe(handleStoreChange);
179
+ }, [subscribe]);
180
+ useDebugValue2(value);
181
+ return value;
182
+ }
183
+ function checkIfSnapshotChanged(inst) {
184
+ var latestGetSnapshot = inst.getSnapshot;
185
+ var prevValue = inst.value;
186
+ try {
187
+ var nextValue = latestGetSnapshot();
188
+ return !objectIs(prevValue, nextValue);
189
+ } catch (error2) {
190
+ return true;
191
+ }
192
+ }
193
+ function useSyncExternalStore$1(subscribe, getSnapshot, getServerSnapshot) {
194
+ return getSnapshot();
195
+ }
196
+ var canUseDOM = !!(typeof window !== "undefined" && typeof window.document !== "undefined" && typeof window.document.createElement !== "undefined");
197
+ var isServerEnvironment = !canUseDOM;
198
+ var shim2 = isServerEnvironment ? useSyncExternalStore$1 : useSyncExternalStore;
199
+ var useSyncExternalStore$2 = React.useSyncExternalStore !== void 0 ? React.useSyncExternalStore : shim2;
200
+ useSyncExternalStoreShim_development.useSyncExternalStore = useSyncExternalStore$2;
201
+ if (typeof __REACT_DEVTOOLS_GLOBAL_HOOK__ !== "undefined" && typeof __REACT_DEVTOOLS_GLOBAL_HOOK__.registerInternalModuleStop === "function") {
202
+ __REACT_DEVTOOLS_GLOBAL_HOOK__.registerInternalModuleStop(new Error());
203
+ }
204
+ })();
205
+ }
206
+ return useSyncExternalStoreShim_development;
207
+ }
208
+ var hasRequiredShim;
209
+ function requireShim() {
210
+ if (hasRequiredShim)
211
+ return shimExports;
212
+ hasRequiredShim = 1;
213
+ (function(module) {
214
+ if (process.env.NODE_ENV === "production") {
215
+ module.exports = requireUseSyncExternalStoreShim_production_min();
216
+ } else {
217
+ module.exports = requireUseSyncExternalStoreShim_development();
218
+ }
219
+ })(shim);
220
+ return shimExports;
221
+ }
15
222
  /**
16
223
  * @license React
17
- * use-sync-external-store-with-selector.production.min.js
224
+ * use-sync-external-store-shim/with-selector.production.min.js
18
225
  *
19
226
  * Copyright (c) Facebook, Inc. and its affiliates.
20
227
  *
21
228
  * This source code is licensed under the MIT license found in the
22
229
  * LICENSE file in the root directory of this source tree.
23
230
  */
24
- var hasRequiredUseSyncExternalStoreWithSelector_production_min;
25
- function requireUseSyncExternalStoreWithSelector_production_min() {
26
- if (hasRequiredUseSyncExternalStoreWithSelector_production_min)
27
- return useSyncExternalStoreWithSelector_production_min;
28
- hasRequiredUseSyncExternalStoreWithSelector_production_min = 1;
29
- var g = require$$0;
30
- function n(a, b) {
231
+ var hasRequiredWithSelector_production_min;
232
+ function requireWithSelector_production_min() {
233
+ if (hasRequiredWithSelector_production_min)
234
+ return withSelector_production_min;
235
+ hasRequiredWithSelector_production_min = 1;
236
+ var h = require$$0, n = requireShim();
237
+ function p(a, b) {
31
238
  return a === b && (0 !== a || 1 / a === 1 / b) || a !== a && b !== b;
32
239
  }
33
- var p = "function" === typeof Object.is ? Object.is : n, q = g.useSyncExternalStore, r = g.useRef, t = g.useEffect, u = g.useMemo, v = g.useDebugValue;
34
- useSyncExternalStoreWithSelector_production_min.useSyncExternalStoreWithSelector = function(a, b, e, l, h) {
35
- var c = r(null);
240
+ var q = "function" === typeof Object.is ? Object.is : p, r = n.useSyncExternalStore, t = h.useRef, u = h.useEffect, v = h.useMemo, w = h.useDebugValue;
241
+ withSelector_production_min.useSyncExternalStoreWithSelector = function(a, b, e, l, g) {
242
+ var c = t(null);
36
243
  if (null === c.current) {
37
244
  var f = { hasValue: false, value: null };
38
245
  c.current = f;
39
246
  } else
40
247
  f = c.current;
41
- c = u(function() {
248
+ c = v(function() {
42
249
  function a2(a3) {
43
250
  if (!c2) {
44
251
  c2 = true;
45
252
  d2 = a3;
46
253
  a3 = l(a3);
47
- if (void 0 !== h && f.hasValue) {
254
+ if (void 0 !== g && f.hasValue) {
48
255
  var b2 = f.value;
49
- if (h(b2, a3))
256
+ if (g(b2, a3))
50
257
  return k = b2;
51
258
  }
52
259
  return k = a3;
53
260
  }
54
261
  b2 = k;
55
- if (p(d2, a3))
262
+ if (q(d2, a3))
56
263
  return b2;
57
264
  var e2 = l(a3);
58
- if (void 0 !== h && h(b2, e2))
265
+ if (void 0 !== g && g(b2, e2))
59
266
  return b2;
60
267
  d2 = a3;
61
268
  return k = e2;
@@ -66,43 +273,44 @@ function requireUseSyncExternalStoreWithSelector_production_min() {
66
273
  }, null === m ? void 0 : function() {
67
274
  return a2(m());
68
275
  }];
69
- }, [b, e, l, h]);
70
- var d = q(a, c[0], c[1]);
71
- t(function() {
276
+ }, [b, e, l, g]);
277
+ var d = r(a, c[0], c[1]);
278
+ u(function() {
72
279
  f.hasValue = true;
73
280
  f.value = d;
74
281
  }, [d]);
75
- v(d);
282
+ w(d);
76
283
  return d;
77
284
  };
78
- return useSyncExternalStoreWithSelector_production_min;
285
+ return withSelector_production_min;
79
286
  }
80
- var useSyncExternalStoreWithSelector_development = {};
287
+ var withSelector_development = {};
81
288
  /**
82
289
  * @license React
83
- * use-sync-external-store-with-selector.development.js
290
+ * use-sync-external-store-shim/with-selector.development.js
84
291
  *
85
292
  * Copyright (c) Facebook, Inc. and its affiliates.
86
293
  *
87
294
  * This source code is licensed under the MIT license found in the
88
295
  * LICENSE file in the root directory of this source tree.
89
296
  */
90
- var hasRequiredUseSyncExternalStoreWithSelector_development;
91
- function requireUseSyncExternalStoreWithSelector_development() {
92
- if (hasRequiredUseSyncExternalStoreWithSelector_development)
93
- return useSyncExternalStoreWithSelector_development;
94
- hasRequiredUseSyncExternalStoreWithSelector_development = 1;
297
+ var hasRequiredWithSelector_development;
298
+ function requireWithSelector_development() {
299
+ if (hasRequiredWithSelector_development)
300
+ return withSelector_development;
301
+ hasRequiredWithSelector_development = 1;
95
302
  if (process.env.NODE_ENV !== "production") {
96
303
  (function() {
97
304
  if (typeof __REACT_DEVTOOLS_GLOBAL_HOOK__ !== "undefined" && typeof __REACT_DEVTOOLS_GLOBAL_HOOK__.registerInternalModuleStart === "function") {
98
305
  __REACT_DEVTOOLS_GLOBAL_HOOK__.registerInternalModuleStart(new Error());
99
306
  }
100
307
  var React = require$$0;
308
+ var shim2 = requireShim();
101
309
  function is(x, y) {
102
310
  return x === y && (x !== 0 || 1 / x === 1 / y) || x !== x && y !== y;
103
311
  }
104
312
  var objectIs = typeof Object.is === "function" ? Object.is : is;
105
- var useSyncExternalStore = React.useSyncExternalStore;
313
+ var useSyncExternalStore = shim2.useSyncExternalStore;
106
314
  var useRef2 = React.useRef, useEffect2 = React.useEffect, useMemo2 = React.useMemo, useDebugValue2 = React.useDebugValue;
107
315
  function useSyncExternalStoreWithSelector(subscribe, getSnapshot, getServerSnapshot, selector, isEqual) {
108
316
  var instRef = useRef2(null);
@@ -167,19 +375,19 @@ function requireUseSyncExternalStoreWithSelector_development() {
167
375
  useDebugValue2(value);
168
376
  return value;
169
377
  }
170
- useSyncExternalStoreWithSelector_development.useSyncExternalStoreWithSelector = useSyncExternalStoreWithSelector;
378
+ withSelector_development.useSyncExternalStoreWithSelector = useSyncExternalStoreWithSelector;
171
379
  if (typeof __REACT_DEVTOOLS_GLOBAL_HOOK__ !== "undefined" && typeof __REACT_DEVTOOLS_GLOBAL_HOOK__.registerInternalModuleStop === "function") {
172
380
  __REACT_DEVTOOLS_GLOBAL_HOOK__.registerInternalModuleStop(new Error());
173
381
  }
174
382
  })();
175
383
  }
176
- return useSyncExternalStoreWithSelector_development;
384
+ return withSelector_development;
177
385
  }
178
386
  (function(module) {
179
387
  if (process.env.NODE_ENV === "production") {
180
- module.exports = requireUseSyncExternalStoreWithSelector_production_min();
388
+ module.exports = requireWithSelector_production_min();
181
389
  } else {
182
- module.exports = requireUseSyncExternalStoreWithSelector_development();
390
+ module.exports = requireWithSelector_development();
183
391
  }
184
392
  })(withSelector);
185
393
  function useStore(store, options) {
@@ -1 +1 @@
1
- {"version":3,"file":"scope2.mjs","sources":["../../node_modules/.pnpm/use-sync-external-store@1.2.0_react@18.2.0/node_modules/use-sync-external-store/cjs/use-sync-external-store-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-with-selector.development.js","../../node_modules/.pnpm/use-sync-external-store@1.2.0_react@18.2.0/node_modules/use-sync-external-store/with-selector.js","../../src/react/useStore.ts","../../src/react/useProp.ts","../../src/react/reactMethods.ts","../../src/react/useCache.ts","../../src/react/scope.tsx"],"sourcesContent":["/**\n * @license React\n * use-sync-external-store-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 g=require(\"react\");function n(a,b){return a===b&&(0!==a||1/a===1/b)||a!==a&&b!==b}var p=\"function\"===typeof Object.is?Object.is:n,q=g.useSyncExternalStore,r=g.useRef,t=g.useEffect,u=g.useMemo,v=g.useDebugValue;\nexports.useSyncExternalStoreWithSelector=function(a,b,e,l,h){var c=r(null);if(null===c.current){var f={hasValue:!1,value:null};c.current=f}else f=c.current;c=u(function(){function a(a){if(!c){c=!0;d=a;a=l(a);if(void 0!==h&&f.hasValue){var b=f.value;if(h(b,a))return k=b}return k=a}b=k;if(p(d,a))return b;var e=l(a);if(void 0!==h&&h(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,h]);var d=q(a,c[0],c[1]);\nt(function(){f.hasValue=!0;f.value=d},[d]);v(d);return d};\n","/**\n * @license React\n * use-sync-external-store-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');\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 = React.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-with-selector.production.min.js');\n} else {\n module.exports = require('./cjs/use-sync-external-store-with-selector.development.js');\n}\n","import { useCallback, useDebugValue, useLayoutEffect, useMemo, useRef } from 'react';\nimport { useSyncExternalStoreWithSelector } from 'use-sync-external-store/with-selector.js';\nimport type { SubscribeOptions } from '@core/commonTypes';\nimport type { Store } from '@core/store';\nimport { hash } from '@lib/hash';\nimport { makeSelector } from '@lib/makeSelector';\nimport { trackingProxy } from '@lib/trackingProxy';\n\nexport type UseStoreOptions = Omit<SubscribeOptions, 'runNow' | 'passive'>;\n\nexport function useStore<T>(store: Store<T>, options?: UseStoreOptions): T {\n const lastEqualsRef = useRef<(newValue: T) => boolean>();\n\n const { rootStore, selector } = useMemo(() => {\n const rootStore = store.derivedFrom?.store ?? store;\n let selector = (x: any) => x;\n\n if (store.derivedFrom) {\n selector = (value: any) => {\n for (const s of store.derivedFrom!.selectors) {\n value = makeSelector(s)(value);\n }\n return value;\n };\n }\n\n return { rootStore, selector };\n }, [store]);\n\n const subOptions = { ...options, runNow: false, equals: undefined, passive: false };\n const subscribe = useCallback(\n (listener: () => void) => {\n return rootStore.subscribe(listener, subOptions);\n },\n [rootStore, hash(subOptions)],\n );\n\n const value = useSyncExternalStoreWithSelector<unknown, T>(\n //\n subscribe,\n rootStore.get,\n undefined,\n selector,\n options?.equals ?? ((_v, newValue) => lastEqualsRef.current?.(newValue) ?? false),\n );\n const [proxiedValue, equals] = trackingProxy(value);\n\n useLayoutEffect(() => {\n lastEqualsRef.current = equals;\n });\n\n useDebugValue(value);\n return proxiedValue;\n}\n","import type { UseStoreOptions } from './useStore';\nimport { useStore } from './useStore';\nimport type { Store } from '@core/store';\n\nexport function useProp<T>(\n store: Store<T>,\n options?: UseStoreOptions,\n): [value: T, setValue: typeof store.set] {\n const value = useStore(store, options);\n\n return [value, store.set];\n}\n","import { useProp } from './useProp';\nimport { type UseStoreOptions, useStore } from './useStore';\nimport type { Store } from '@core/store';\n\nexport const reactMethods = {\n useStore<T>(this: Store<T>, options?: UseStoreOptions) {\n return useStore(this, options);\n },\n\n useProp<T>(this: Store<T>, options?: UseStoreOptions) {\n return useProp(this, options);\n },\n};\n","import { useEffect, useMemo } from 'react';\nimport type { UseStoreOptions } from './useStore';\nimport { useStore } from './useStore';\nimport type { Cache } from '@core';\nimport type { CacheState } from '@lib/cacheState';\nimport { makeSelector } from '@lib/makeSelector';\n\nexport type UseCacheArray<T> = [\n value: T | undefined,\n error: unknown | undefined,\n isUpdating: boolean,\n isStale: boolean,\n];\n\nexport type UseCacheValue<T> = UseCacheArray<T> & CacheState<T>;\n\nexport interface UseCacheOptions extends UseStoreOptions {\n passive?: boolean;\n updateOnMount?: boolean;\n}\n\nexport function useCache<T>(\n cache: Cache<T>,\n { passive, updateOnMount, ...options }: UseCacheOptions = {},\n): UseCacheValue<T> {\n const mappedState = useMemo(() => {\n const rootCache: Cache<any> = cache.derivedFromCache?.cache ?? cache;\n let selector = (x: any) => x;\n\n if (cache.derivedFromCache) {\n selector = (value: any) => {\n for (const s of cache.derivedFromCache!.selectors) {\n value = makeSelector(s)(value);\n }\n return value;\n };\n }\n\n return rootCache.state.map((state) => {\n const value = state.status === 'value' ? selector(state.value) : undefined;\n\n return Object.assign<UseCacheArray<T>, CacheState<T>>(\n [value, state.error, state.isUpdating, state.isStale],\n { ...state, value },\n );\n });\n }, [cache]);\n\n useEffect(() => (!passive ? cache.subscribe(() => undefined) : undefined), [cache, passive]);\n\n useEffect(() => {\n if (updateOnMount) {\n cache.invalidate();\n }\n }, []);\n\n return useStore(mappedState, options);\n}\n","import type { Context, ReactNode } from 'react';\nimport { createContext, useContext, useMemo } from 'react';\nimport { useProp } from './useProp';\nimport { useStore, type UseStoreOptions } from './useStore';\nimport { createStore } from '@core/store';\nimport type { Store } from '@core/store';\nimport type { Scope } from '@core';\n\nexport type ScopeProps<T> = { scope: Scope<T>; store?: Store<T>; children?: ReactNode };\n\nconst contextMap = new WeakMap<Scope<any>, Context<Store<any>>>();\n\nfunction getScopeContext<T>(scope: Scope<T>): Context<Store<T>> {\n let context = contextMap.get(scope);\n\n if (!context) {\n context = createContext<Store<T>>(createStore(scope.defaultValue));\n contextMap.set(scope, context);\n }\n\n return context;\n}\n\nexport function ScopeProvider<T>({ scope, store: inputStore, children }: ScopeProps<T>) {\n const context = getScopeContext(scope);\n const currentStore = useMemo(\n () => inputStore ?? createStore(scope.defaultValue),\n [scope, inputStore],\n );\n\n return <context.Provider value={currentStore}>{children}</context.Provider>;\n}\n\nexport function useScope<T>(scope: Scope<T>): Store<T> {\n const context = getScopeContext(scope);\n return useContext(context);\n}\n\nexport function useScopeStore<T>(scope: Scope<T>, options?: UseStoreOptions): T {\n const store = useScope(scope);\n return useStore(store, options);\n}\n\nexport function useScopeProp<T>(scope: Scope<T>, options?: UseStoreOptions) {\n const store = useScope(scope);\n return useProp(store, options);\n}\n"],"names":["a","c","d","b","e","useRef","useEffect","useMemo","useDebugValue","require$$0","require$$1","rootStore","selector","value","useSyncExternalStoreWithSelector"],"mappings":";;;;;;;;;;;;;;;;;;;;;;;;;;;;AASa,MAAI,IAAE;AAAiB,W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YAAY,MAAM,YAAY;AAAA,IAClD,CAAC,OAAO,UAAU;AAAA,EAAA;AAGpB,6BAAQ,QAAQ,UAAR,EAAiB,OAAO,cAAe,SAAS,CAAA;AAC1D;AAEO,SAAS,SAAY,OAA2B;AAC/C,QAAA,UAAU,gBAAgB,KAAK;AACrC,SAAO,WAAW,OAAO;AAC3B;AAEgB,SAAA,cAAiB,OAAiB,SAA8B;AACxE,QAAA,QAAQ,SAAS,KAAK;AACrB,SAAA,SAAS,OAAO,OAAO;AAChC;AAEgB,SAAA,aAAgB,OAAiB,SAA2B;AACpE,QAAA,QAAQ,SAAS,KAAK;AACrB,SAAA,QAAQ,OAAO,OAAO;AAC/B;","x_google_ignoreList":[0,1,2]}
1
+ {"version":3,"file":"scope2.mjs","sources":["../../node_modules/.pnpm/use-sync-external-store@1.2.0_react@18.2.0/node_modules/use-sync-external-store/cjs/use-sync-external-store-shim.production.min.js","../../node_modules/.pnpm/use-sync-external-store@1.2.0_react@18.2.0/node_modules/use-sync-external-store/cjs/use-sync-external-store-shim.development.js","../../node_modules/.pnpm/use-sync-external-store@1.2.0_react@18.2.0/node_modules/use-sync-external-store/shim/index.js","../../node_modules/.pnpm/use-sync-external-store@1.2.0_react@18.2.0/node_modules/use-sync-external-store/cjs/use-sync-external-store-shim/with-selector.production.min.js","../../node_modules/.pnpm/use-sync-external-store@1.2.0_react@18.2.0/node_modules/use-sync-external-store/cjs/use-sync-external-store-shim/with-selector.development.js","../../node_modules/.pnpm/use-sync-external-store@1.2.0_react@18.2.0/node_modules/use-sync-external-store/shim/with-selector.js","../../src/react/useStore.ts","../../src/react/useProp.ts","../../src/react/reactMethods.ts","../../src/react/useCache.ts","../../src/react/scope.tsx"],"sourcesContent":["/**\n * @license React\n * use-sync-external-store-shim.production.min.js\n *\n * Copyright (c) Facebook, Inc. and its affiliates.\n *\n * This source code is licensed under the MIT license found in the\n * LICENSE file in the root directory of this source tree.\n */\n'use strict';var e=require(\"react\");function h(a,b){return a===b&&(0!==a||1/a===1/b)||a!==a&&b!==b}var k=\"function\"===typeof Object.is?Object.is:h,l=e.useState,m=e.useEffect,n=e.useLayoutEffect,p=e.useDebugValue;function q(a,b){var d=b(),f=l({inst:{value:d,getSnapshot:b}}),c=f[0].inst,g=f[1];n(function(){c.value=d;c.getSnapshot=b;r(c)&&g({inst:c})},[a,d,b]);m(function(){r(c)&&g({inst:c});return a(function(){r(c)&&g({inst:c})})},[a]);p(d);return d}\nfunction r(a){var b=a.getSnapshot;a=a.value;try{var d=b();return!k(a,d)}catch(f){return!0}}function t(a,b){return b()}var u=\"undefined\"===typeof window||\"undefined\"===typeof window.document||\"undefined\"===typeof window.document.createElement?t:q;exports.useSyncExternalStore=void 0!==e.useSyncExternalStore?e.useSyncExternalStore:u;\n","/**\n * @license React\n * use-sync-external-store-shim.development.js\n *\n * Copyright (c) Facebook, Inc. and its affiliates.\n *\n * This source code is licensed under the MIT license found in the\n * LICENSE file in the root directory of this source tree.\n */\n\n'use strict';\n\nif (process.env.NODE_ENV !== \"production\") {\n (function() {\n\n 'use strict';\n\n/* global __REACT_DEVTOOLS_GLOBAL_HOOK__ */\nif (\n typeof __REACT_DEVTOOLS_GLOBAL_HOOK__ !== 'undefined' &&\n typeof __REACT_DEVTOOLS_GLOBAL_HOOK__.registerInternalModuleStart ===\n 'function'\n) {\n __REACT_DEVTOOLS_GLOBAL_HOOK__.registerInternalModuleStart(new Error());\n}\n var React = require('react');\n\nvar ReactSharedInternals = React.__SECRET_INTERNALS_DO_NOT_USE_OR_YOU_WILL_BE_FIRED;\n\nfunction error(format) {\n {\n {\n for (var _len2 = arguments.length, args = new Array(_len2 > 1 ? _len2 - 1 : 0), _key2 = 1; _key2 < _len2; _key2++) {\n args[_key2 - 1] = arguments[_key2];\n }\n\n printWarning('error', format, args);\n }\n }\n}\n\nfunction printWarning(level, format, args) {\n // When changing this logic, you might want to also\n // update consoleWithStackDev.www.js as well.\n {\n var ReactDebugCurrentFrame = ReactSharedInternals.ReactDebugCurrentFrame;\n var stack = ReactDebugCurrentFrame.getStackAddendum();\n\n if (stack !== '') {\n format += '%s';\n args = args.concat([stack]);\n } // eslint-disable-next-line react-internal/safe-string-coercion\n\n\n var argsWithFormat = args.map(function (item) {\n return String(item);\n }); // Careful: RN currently depends on this prefix\n\n argsWithFormat.unshift('Warning: ' + format); // We intentionally don't use spread (or .apply) directly because it\n // breaks IE9: https://github.com/facebook/react/issues/13610\n // eslint-disable-next-line react-internal/no-production-logging\n\n Function.prototype.apply.call(console[level], console, argsWithFormat);\n }\n}\n\n/**\n * inlined Object.is polyfill to avoid requiring consumers ship their own\n * https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/Object/is\n */\nfunction is(x, y) {\n return x === y && (x !== 0 || 1 / x === 1 / y) || x !== x && y !== y // eslint-disable-line no-self-compare\n ;\n}\n\nvar objectIs = typeof Object.is === 'function' ? Object.is : is;\n\n// dispatch for CommonJS interop named imports.\n\nvar useState = React.useState,\n useEffect = React.useEffect,\n useLayoutEffect = React.useLayoutEffect,\n useDebugValue = React.useDebugValue;\nvar didWarnOld18Alpha = false;\nvar didWarnUncachedGetSnapshot = false; // Disclaimer: This shim breaks many of the rules of React, and only works\n// because of a very particular set of implementation details and assumptions\n// -- change any one of them and it will break. The most important assumption\n// is that updates are always synchronous, because concurrent rendering is\n// only available in versions of React that also have a built-in\n// useSyncExternalStore API. And we only use this shim when the built-in API\n// does not exist.\n//\n// Do not assume that the clever hacks used by this hook also work in general.\n// The point of this shim is to replace the need for hacks by other libraries.\n\nfunction useSyncExternalStore(subscribe, getSnapshot, // Note: The shim does not use getServerSnapshot, because pre-18 versions of\n// React do not expose a way to check if we're hydrating. So users of the shim\n// will need to track that themselves and return the correct value\n// from `getSnapshot`.\ngetServerSnapshot) {\n {\n if (!didWarnOld18Alpha) {\n if (React.startTransition !== undefined) {\n didWarnOld18Alpha = true;\n\n error('You are using an outdated, pre-release alpha of React 18 that ' + 'does not support useSyncExternalStore. The ' + 'use-sync-external-store shim will not work correctly. Upgrade ' + 'to a newer pre-release.');\n }\n }\n } // Read the current snapshot from the store on every render. Again, this\n // breaks the rules of React, and only works here because of specific\n // implementation details, most importantly that updates are\n // always synchronous.\n\n\n var value = getSnapshot();\n\n {\n if (!didWarnUncachedGetSnapshot) {\n var cachedValue = getSnapshot();\n\n if (!objectIs(value, cachedValue)) {\n error('The result of getSnapshot should be cached to avoid an infinite loop');\n\n didWarnUncachedGetSnapshot = true;\n }\n }\n } // Because updates are synchronous, we don't queue them. Instead we force a\n // re-render whenever the subscribed state changes by updating an some\n // arbitrary useState hook. Then, during render, we call getSnapshot to read\n // the current value.\n //\n // Because we don't actually use the state returned by the useState hook, we\n // can save a bit of memory by storing other stuff in that slot.\n //\n // To implement the early bailout, we need to track some things on a mutable\n // object. Usually, we would put that in a useRef hook, but we can stash it in\n // our useState hook instead.\n //\n // To force a re-render, we call forceUpdate({inst}). That works because the\n // new object always fails an equality check.\n\n\n var _useState = useState({\n inst: {\n value: value,\n getSnapshot: getSnapshot\n }\n }),\n inst = _useState[0].inst,\n forceUpdate = _useState[1]; // Track the latest getSnapshot function with a ref. This needs to be updated\n // in the layout phase so we can access it during the tearing check that\n // happens on subscribe.\n\n\n useLayoutEffect(function () {\n inst.value = value;\n inst.getSnapshot = getSnapshot; // Whenever getSnapshot or subscribe changes, we need to check in the\n // commit phase if there was an interleaved mutation. In concurrent mode\n // this can happen all the time, but even in synchronous mode, an earlier\n // effect may have mutated the store.\n\n if (checkIfSnapshotChanged(inst)) {\n // Force a re-render.\n forceUpdate({\n inst: inst\n });\n }\n }, [subscribe, value, getSnapshot]);\n useEffect(function () {\n // Check for changes right before subscribing. Subsequent changes will be\n // detected in the subscription handler.\n if (checkIfSnapshotChanged(inst)) {\n // Force a re-render.\n forceUpdate({\n inst: inst\n });\n }\n\n var handleStoreChange = function () {\n // TODO: Because there is no cross-renderer API for batching updates, it's\n // up to the consumer of this library to wrap their subscription event\n // with unstable_batchedUpdates. Should we try to detect when this isn't\n // the case and print a warning in development?\n // The store changed. Check if the snapshot changed since the last time we\n // read from the store.\n if (checkIfSnapshotChanged(inst)) {\n // Force a re-render.\n forceUpdate({\n inst: inst\n });\n }\n }; // Subscribe to the store and return a clean-up function.\n\n\n return subscribe(handleStoreChange);\n }, [subscribe]);\n useDebugValue(value);\n return value;\n}\n\nfunction checkIfSnapshotChanged(inst) {\n var latestGetSnapshot = inst.getSnapshot;\n var prevValue = inst.value;\n\n try {\n var nextValue = latestGetSnapshot();\n return !objectIs(prevValue, nextValue);\n } catch (error) {\n return true;\n }\n}\n\nfunction useSyncExternalStore$1(subscribe, getSnapshot, getServerSnapshot) {\n // Note: The shim does not use getServerSnapshot, because pre-18 versions of\n // React do not expose a way to check if we're hydrating. So users of the shim\n // will need to track that themselves and return the correct value\n // from `getSnapshot`.\n return getSnapshot();\n}\n\nvar canUseDOM = !!(typeof window !== 'undefined' && typeof window.document !== 'undefined' && typeof window.document.createElement !== 'undefined');\n\nvar isServerEnvironment = !canUseDOM;\n\nvar shim = isServerEnvironment ? useSyncExternalStore$1 : useSyncExternalStore;\nvar useSyncExternalStore$2 = React.useSyncExternalStore !== undefined ? React.useSyncExternalStore : shim;\n\nexports.useSyncExternalStore = useSyncExternalStore$2;\n /* global __REACT_DEVTOOLS_GLOBAL_HOOK__ */\nif (\n typeof __REACT_DEVTOOLS_GLOBAL_HOOK__ !== 'undefined' &&\n typeof __REACT_DEVTOOLS_GLOBAL_HOOK__.registerInternalModuleStop ===\n 'function'\n) {\n __REACT_DEVTOOLS_GLOBAL_HOOK__.registerInternalModuleStop(new Error());\n}\n \n })();\n}\n","'use strict';\n\nif (process.env.NODE_ENV === 'production') {\n module.exports = require('../cjs/use-sync-external-store-shim.production.min.js');\n} else {\n module.exports = require('../cjs/use-sync-external-store-shim.development.js');\n}\n","/**\n * @license React\n * use-sync-external-store-shim/with-selector.production.min.js\n *\n * Copyright (c) Facebook, Inc. and its affiliates.\n *\n * This source code is licensed under the MIT license found in the\n * LICENSE file in the root directory of this source tree.\n */\n'use strict';var h=require(\"react\"),n=require(\"use-sync-external-store/shim\");function p(a,b){return a===b&&(0!==a||1/a===1/b)||a!==a&&b!==b}var q=\"function\"===typeof Object.is?Object.is:p,r=n.useSyncExternalStore,t=h.useRef,u=h.useEffect,v=h.useMemo,w=h.useDebugValue;\nexports.useSyncExternalStoreWithSelector=function(a,b,e,l,g){var c=t(null);if(null===c.current){var f={hasValue:!1,value:null};c.current=f}else f=c.current;c=v(function(){function a(a){if(!c){c=!0;d=a;a=l(a);if(void 0!==g&&f.hasValue){var b=f.value;if(g(b,a))return k=b}return k=a}b=k;if(q(d,a))return b;var e=l(a);if(void 0!==g&&g(b,e))return b;d=a;return k=e}var c=!1,d,k,m=void 0===e?null:e;return[function(){return a(b())},null===m?void 0:function(){return a(m())}]},[b,e,l,g]);var d=r(a,c[0],c[1]);\nu(function(){f.hasValue=!0;f.value=d},[d]);w(d);return d};\n","/**\n * @license React\n * use-sync-external-store-shim/with-selector.development.js\n *\n * Copyright (c) Facebook, Inc. and its affiliates.\n *\n * This source code is licensed under the MIT license found in the\n * LICENSE file in the root directory of this source tree.\n */\n\n'use strict';\n\nif (process.env.NODE_ENV !== \"production\") {\n (function() {\n\n 'use strict';\n\n/* global __REACT_DEVTOOLS_GLOBAL_HOOK__ */\nif (\n typeof __REACT_DEVTOOLS_GLOBAL_HOOK__ !== 'undefined' &&\n typeof __REACT_DEVTOOLS_GLOBAL_HOOK__.registerInternalModuleStart ===\n 'function'\n) {\n __REACT_DEVTOOLS_GLOBAL_HOOK__.registerInternalModuleStart(new Error());\n}\n var React = require('react');\nvar shim = require('use-sync-external-store/shim');\n\n/**\n * inlined Object.is polyfill to avoid requiring consumers ship their own\n * https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/Object/is\n */\nfunction is(x, y) {\n return x === y && (x !== 0 || 1 / x === 1 / y) || x !== x && y !== y // eslint-disable-line no-self-compare\n ;\n}\n\nvar objectIs = typeof Object.is === 'function' ? Object.is : is;\n\nvar useSyncExternalStore = shim.useSyncExternalStore;\n\n// for CommonJS interop.\n\nvar useRef = React.useRef,\n useEffect = React.useEffect,\n useMemo = React.useMemo,\n useDebugValue = React.useDebugValue; // Same as useSyncExternalStore, but supports selector and isEqual arguments.\n\nfunction useSyncExternalStoreWithSelector(subscribe, getSnapshot, getServerSnapshot, selector, isEqual) {\n // Use this to track the rendered snapshot.\n var instRef = useRef(null);\n var inst;\n\n if (instRef.current === null) {\n inst = {\n hasValue: false,\n value: null\n };\n instRef.current = inst;\n } else {\n inst = instRef.current;\n }\n\n var _useMemo = useMemo(function () {\n // Track the memoized state using closure variables that are local to this\n // memoized instance of a getSnapshot function. Intentionally not using a\n // useRef hook, because that state would be shared across all concurrent\n // copies of the hook/component.\n var hasMemo = false;\n var memoizedSnapshot;\n var memoizedSelection;\n\n var memoizedSelector = function (nextSnapshot) {\n if (!hasMemo) {\n // The first time the hook is called, there is no memoized result.\n hasMemo = true;\n memoizedSnapshot = nextSnapshot;\n\n var _nextSelection = selector(nextSnapshot);\n\n if (isEqual !== undefined) {\n // Even if the selector has changed, the currently rendered selection\n // may be equal to the new selection. We should attempt to reuse the\n // current value if possible, to preserve downstream memoizations.\n if (inst.hasValue) {\n var currentSelection = inst.value;\n\n if (isEqual(currentSelection, _nextSelection)) {\n memoizedSelection = currentSelection;\n return currentSelection;\n }\n }\n }\n\n memoizedSelection = _nextSelection;\n return _nextSelection;\n } // We may be able to reuse the previous invocation's result.\n\n\n // We may be able to reuse the previous invocation's result.\n var prevSnapshot = memoizedSnapshot;\n var prevSelection = memoizedSelection;\n\n if (objectIs(prevSnapshot, nextSnapshot)) {\n // The snapshot is the same as last time. Reuse the previous selection.\n return prevSelection;\n } // The snapshot has changed, so we need to compute a new selection.\n\n\n // The snapshot has changed, so we need to compute a new selection.\n var nextSelection = selector(nextSnapshot); // If a custom isEqual function is provided, use that to check if the data\n // has changed. If it hasn't, return the previous selection. That signals\n // to React that the selections are conceptually equal, and we can bail\n // out of rendering.\n\n // If a custom isEqual function is provided, use that to check if the data\n // has changed. If it hasn't, return the previous selection. That signals\n // to React that the selections are conceptually equal, and we can bail\n // out of rendering.\n if (isEqual !== undefined && isEqual(prevSelection, nextSelection)) {\n return prevSelection;\n }\n\n memoizedSnapshot = nextSnapshot;\n memoizedSelection = nextSelection;\n return nextSelection;\n }; // Assigning this to a constant so that Flow knows it can't change.\n\n\n // Assigning this to a constant so that Flow knows it can't change.\n var maybeGetServerSnapshot = getServerSnapshot === undefined ? null : getServerSnapshot;\n\n var getSnapshotWithSelector = function () {\n return memoizedSelector(getSnapshot());\n };\n\n var getServerSnapshotWithSelector = maybeGetServerSnapshot === null ? undefined : function () {\n return memoizedSelector(maybeGetServerSnapshot());\n };\n return [getSnapshotWithSelector, getServerSnapshotWithSelector];\n }, [getSnapshot, getServerSnapshot, selector, isEqual]),\n getSelection = _useMemo[0],\n getServerSelection = _useMemo[1];\n\n var value = useSyncExternalStore(subscribe, getSelection, getServerSelection);\n useEffect(function () {\n inst.hasValue = true;\n inst.value = value;\n }, [value]);\n useDebugValue(value);\n return value;\n}\n\nexports.useSyncExternalStoreWithSelector = useSyncExternalStoreWithSelector;\n /* global __REACT_DEVTOOLS_GLOBAL_HOOK__ */\nif (\n typeof __REACT_DEVTOOLS_GLOBAL_HOOK__ !== 'undefined' &&\n typeof __REACT_DEVTOOLS_GLOBAL_HOOK__.registerInternalModuleStop ===\n 'function'\n) {\n __REACT_DEVTOOLS_GLOBAL_HOOK__.registerInternalModuleStop(new Error());\n}\n \n })();\n}\n","'use strict';\n\nif (process.env.NODE_ENV === 'production') {\n module.exports = require('../cjs/use-sync-external-store-shim/with-selector.production.min.js');\n} else {\n module.exports = require('../cjs/use-sync-external-store-shim/with-selector.development.js');\n}\n","import { useCallback, useDebugValue, useLayoutEffect, useMemo, useRef } from 'react';\nimport { useSyncExternalStoreWithSelector } from 'use-sync-external-store/shim/with-selector.js';\nimport type { SubscribeOptions } from '@core/commonTypes';\nimport type { Store } from '@core/store';\nimport { hash } from '@lib/hash';\nimport { makeSelector } from '@lib/makeSelector';\nimport { trackingProxy } from '@lib/trackingProxy';\n\nexport type UseStoreOptions = Omit<SubscribeOptions, 'runNow' | 'passive'>;\n\nexport function useStore<T>(store: Store<T>, options?: UseStoreOptions): T {\n const lastEqualsRef = useRef<(newValue: T) => boolean>();\n\n const { rootStore, selector } = useMemo(() => {\n const rootStore = store.derivedFrom?.store ?? store;\n let selector = (x: any) => x;\n\n if (store.derivedFrom) {\n selector = (value: any) => {\n for (const s of store.derivedFrom!.selectors) {\n value = makeSelector(s)(value);\n }\n return value;\n };\n }\n\n return { rootStore, selector };\n }, [store]);\n\n const subOptions = { ...options, runNow: false, equals: undefined, passive: false };\n const subscribe = useCallback(\n (listener: () => void) => {\n return rootStore.subscribe(listener, subOptions);\n },\n [rootStore, hash(subOptions)],\n );\n\n const value = useSyncExternalStoreWithSelector<unknown, T>(\n //\n subscribe,\n rootStore.get,\n undefined,\n selector,\n options?.equals ?? ((_v, newValue) => lastEqualsRef.current?.(newValue) ?? false),\n );\n const [proxiedValue, equals] = trackingProxy(value);\n\n useLayoutEffect(() => {\n lastEqualsRef.current = equals;\n });\n\n useDebugValue(value);\n return proxiedValue;\n}\n","import type { UseStoreOptions } from './useStore';\nimport { useStore } from './useStore';\nimport type { Store } from '@core/store';\n\nexport function useProp<T>(\n store: Store<T>,\n options?: UseStoreOptions,\n): [value: T, setValue: typeof store.set] {\n const value = useStore(store, options);\n\n return [value, store.set];\n}\n","import { useProp } from './useProp';\nimport { type UseStoreOptions, useStore } from './useStore';\nimport type { Store } from '@core/store';\n\nexport const reactMethods = {\n useStore<T>(this: Store<T>, options?: UseStoreOptions) {\n return useStore(this, options);\n },\n\n useProp<T>(this: Store<T>, options?: UseStoreOptions) {\n return useProp(this, options);\n },\n};\n","import { useEffect, useMemo } from 'react';\nimport type { UseStoreOptions } from './useStore';\nimport { useStore } from './useStore';\nimport type { Cache } from '@core';\nimport type { CacheState } from '@lib/cacheState';\nimport { makeSelector } from '@lib/makeSelector';\n\nexport type UseCacheArray<T> = [\n value: T | undefined,\n error: unknown | undefined,\n isUpdating: boolean,\n isStale: boolean,\n];\n\nexport type UseCacheValue<T> = UseCacheArray<T> & CacheState<T>;\n\nexport interface UseCacheOptions extends UseStoreOptions {\n passive?: boolean;\n updateOnMount?: boolean;\n}\n\nexport function useCache<T>(\n cache: Cache<T>,\n { passive, updateOnMount, ...options }: UseCacheOptions = {},\n): UseCacheValue<T> {\n const mappedState = useMemo(() => {\n const rootCache: Cache<any> = cache.derivedFromCache?.cache ?? cache;\n let selector = (x: any) => x;\n\n if (cache.derivedFromCache) {\n selector = (value: any) => {\n for (const s of cache.derivedFromCache!.selectors) {\n value = makeSelector(s)(value);\n }\n return value;\n };\n }\n\n return rootCache.state.map((state) => {\n const value = state.status === 'value' ? selector(state.value) : undefined;\n\n return Object.assign<UseCacheArray<T>, CacheState<T>>(\n [value, state.error, state.isUpdating, state.isStale],\n { ...state, value },\n );\n });\n }, [cache]);\n\n useEffect(() => (!passive ? cache.subscribe(() => undefined) : undefined), [cache, passive]);\n\n useEffect(() => {\n if (updateOnMount) {\n cache.invalidate();\n }\n }, []);\n\n return useStore(mappedState, options);\n}\n","import type { Context, ReactNode } from 'react';\nimport { createContext, useContext, useMemo } from 'react';\nimport { useProp } from './useProp';\nimport { useStore, type UseStoreOptions } from './useStore';\nimport { createStore } from '@core/store';\nimport type { Store } from '@core/store';\nimport type { Scope } from '@core';\n\nexport type ScopeProps<T> = { scope: Scope<T>; store?: Store<T>; children?: ReactNode };\n\nconst contextMap = new WeakMap<Scope<any>, Context<Store<any>>>();\n\nfunction getScopeContext<T>(scope: Scope<T>): Context<Store<T>> {\n let context = contextMap.get(scope);\n\n if (!context) {\n context = createContext<Store<T>>(createStore(scope.defaultValue));\n contextMap.set(scope, context);\n }\n\n return context;\n}\n\nexport function ScopeProvider<T>({ scope, store: inputStore, children }: ScopeProps<T>) {\n const context = getScopeContext(scope);\n const currentStore = useMemo(\n () => inputStore ?? createStore(scope.defaultValue),\n [scope, inputStore],\n );\n\n return <context.Provider value={currentStore}>{children}</context.Provider>;\n}\n\nexport function useScope<T>(scope: Scope<T>): Store<T> {\n const context = getScopeContext(scope);\n return useContext(context);\n}\n\nexport function useScopeStore<T>(scope: Scope<T>, options?: UseStoreOptions): T {\n const store = useScope(scope);\n return useStore(store, options);\n}\n\nexport function useScopeProp<T>(scope: Scope<T>, options?: UseStoreOptions) {\n const store = useScope(scope);\n return useProp(store, options);\n}\n"],"names":["useEffect","useLayoutEffect","useDebugValue","error","shim","require$$0","require$$1","a","c","d","b","e","useRef","useMemo","rootStore","selector","value","useSyncExternalStoreWithSelector"],"mappings":";;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;AASa,MAAI,IAAE;AAAiB,WAAS,EAAE,GAAE,GAAE;AAAC,WAAO,MAAI,MAAI,MAAI,KAAG,IAAE,MAAI,IAAE,MAAI,MAAI,KAAG,MAAI;AAAA,EAAC;AAAC,MAAI,IAAE,eAAa,OAAO,OAAO,KAAG,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,C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,EAAA;AAGpB,6BAAQ,QAAQ,UAAR,EAAiB,OAAO,cAAe,SAAS,CAAA;AAC1D;AAEO,SAAS,SAAY,OAA2B;AAC/C,QAAA,UAAU,gBAAgB,KAAK;AACrC,SAAO,WAAW,OAAO;AAC3B;AAEgB,SAAA,cAAiB,OAAiB,SAA8B;AACxE,QAAA,QAAQ,SAAS,KAAK;AACrB,SAAA,SAAS,OAAO,OAAO;AAChC;AAEgB,SAAA,aAAgB,OAAiB,SAA2B;AACpE,QAAA,QAAQ,SAAS,KAAK;AACrB,SAAA,QAAQ,OAAO,OAAO;AAC/B;","x_google_ignoreList":[0,1,2,3,4,5]}
@@ -1,6 +1,8 @@
1
1
  export * from './core';
2
2
  export { calcDuration } from './lib/calcDuration';
3
3
  export { InstanceCache } from './lib/instanceCache';
4
+ export { type Path, type PathAsArray, type PathAsString, type Value } from './lib/path';
5
+ export { get, set } from './lib/propAccess';
4
6
  export { arrayMethods, mapMethods, recordMethods, setMethods } from './lib/standardMethods';
5
7
  export * from './lib/updateHelpers';
6
8
  export * from './persist';
@@ -4,6 +4,6 @@ export declare const reactMethods: {
4
4
  useStore<T>(this: Store<T>, options?: UseStoreOptions): T;
5
5
  useProp<T_1>(this: Store<T_1>, options?: UseStoreOptions): [value: T_1, setValue: {
6
6
  (update: import("../core/commonTypes").Update<T_1>): void;
7
- <P extends import("../lib/path").Path<T_1>>(path: P, update: import("../core/commonTypes").Update<import("../lib/path").Value<T_1, P>>): void;
7
+ <P extends import("..").Path<T_1>>(path: P, update: import("../core/commonTypes").Update<import("..").Value<T_1, P>>): void;
8
8
  }];
9
9
  };
@@ -22,7 +22,7 @@ declare const scopeMethods: {
22
22
  useStore<T_1>(this: Scope<T_1>, options?: UseStoreOptions): T_1;
23
23
  useProp<T_2>(this: Scope<T_2>, options?: UseStoreOptions): [value: T_2, setValue: {
24
24
  (update: import("../core/commonTypes").Update<T_2>): void;
25
- <P extends import("../lib/path").Path<T_2>>(path: P, update: import("../core/commonTypes").Update<import("../lib/path").Value<T_2, P>>): void;
25
+ <P extends import("..").Path<T_2>>(path: P, update: import("../core/commonTypes").Update<import("..").Value<T_2, P>>): void;
26
26
  }];
27
27
  Provider<T_3>(this: Scope<T_3>, props: Omit<ScopeProps<T_3>, "scope">): JSX.Element;
28
28
  };
@@ -12,5 +12,5 @@ export declare function useScope<T>(scope: Scope<T>): Store<T>;
12
12
  export declare function useScopeStore<T>(scope: Scope<T>, options?: UseStoreOptions): T;
13
13
  export declare function useScopeProp<T>(scope: Scope<T>, options?: UseStoreOptions): [value: T, setValue: {
14
14
  (update: import("../core/commonTypes").Update<T>): void;
15
- <P extends import("../lib/path").Path<T>>(path: P, update: import("../core/commonTypes").Update<import("../lib/path").Value<T, P>>): void;
15
+ <P extends import("..").Path<T>>(path: P, update: import("../core/commonTypes").Update<import("..").Value<T, P>>): void;
16
16
  }];
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "cross-state",
3
- "version": "0.7.1",
3
+ "version": "0.8.0",
4
4
  "description": "(React) state library",
5
5
  "license": "ISC",
6
6
  "repository": "schummar/schummar-state",
@@ -188,7 +188,7 @@
188
188
  {
189
189
  "name": "/react",
190
190
  "path": "dist/es/react/index.mjs",
191
- "limit": "5.4 KB"
191
+ "limit": "6 KB"
192
192
  },
193
193
  {
194
194
  "name": "/immer",