cross-state 0.7.2 → 0.8.1

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
@@ -1,7 +1,7 @@
1
1
  "use strict";
2
2
  Object.defineProperty(exports, Symbol.toStringTag, { value: "Module" });
3
- const scope = require("./scope.cjs");
4
3
  const store = require("./store.cjs");
4
+ const scope = require("./scope.cjs");
5
5
  require("./hash.cjs");
6
6
  class SubstriptionCache extends store.Store {
7
7
  constructor(connectFunction, options = {}, derivedFromSubscriptionCache, _call) {
@@ -430,6 +430,15 @@ class Persist {
430
430
  function persist(store2, options) {
431
431
  return new Persist(store2, options);
432
432
  }
433
+ exports.Store = store.Store;
434
+ exports.arrayMethods = store.arrayMethods;
435
+ exports.calcDuration = store.calcDuration;
436
+ exports.createStore = store.createStore;
437
+ exports.get = store.get;
438
+ exports.mapMethods = store.mapMethods;
439
+ exports.recordMethods = store.recordMethods;
440
+ exports.set = store.set;
441
+ exports.setMethods = store.setMethods;
433
442
  exports.Cache = scope.Cache;
434
443
  exports.InstanceCache = scope.InstanceCache;
435
444
  exports.ResourceGroup = scope.ResourceGroup;
@@ -438,13 +447,6 @@ exports.allResources = scope.allResources;
438
447
  exports.createCache = scope.createCache;
439
448
  exports.createResourceGroup = scope.createResourceGroup;
440
449
  exports.createScope = scope.createScope;
441
- exports.Store = store.Store;
442
- exports.arrayMethods = store.arrayMethods;
443
- exports.calcDuration = store.calcDuration;
444
- exports.createStore = store.createStore;
445
- exports.mapMethods = store.mapMethods;
446
- exports.recordMethods = store.recordMethods;
447
- exports.setMethods = store.setMethods;
448
450
  exports.SubstriptionCache = SubstriptionCache;
449
451
  exports.createSubscriptionCache = createSubscriptionCache;
450
452
  exports.createUrlStore = createUrlStore;
@@ -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,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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AC;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,UAA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K,MAAM,KAAK;AAEnE,WAAA,mBAAmB,CAAC,MAAM,WAAW;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,7 +1,7 @@
1
1
  "use strict";
2
2
  const scope = require("../scope2.cjs");
3
- const scope$1 = require("../scope.cjs");
4
3
  const store = require("../store.cjs");
4
+ const scope$1 = require("../scope.cjs");
5
5
  require("react");
6
6
  require("react/jsx-runtime");
7
7
  require("../hash.cjs");
@@ -425,9 +425,10 @@ function useStore(store$1, options) {
425
425
  return ((_a = lastEqualsRef.current) == null ? void 0 : _a.call(lastEqualsRef, newValue)) ?? false;
426
426
  })
427
427
  );
428
- const [proxiedValue, equals] = store.trackingProxy(value);
428
+ const [proxiedValue, equals, revoke] = store.trackingProxy(value);
429
429
  require$$0.useLayoutEffect(() => {
430
430
  lastEqualsRef.current = equals;
431
+ revoke == null ? void 0 : revoke();
431
432
  });
432
433
  require$$0.useDebugValue(value);
433
434
  return proxiedValue;
@@ -1 +1 @@
1
- {"version":3,"file":"scope2.cjs","sources":["../../node_modules/.pnpm/use-sync-external-store@1.2.0_react@18.2.0/node_modules/use-sync-external-store/cjs/use-sync-external-store-shim.production.min.js","../../node_modules/.pnpm/use-sync-external-store@1.2.0_react@18.2.0/node_modules/use-sync-external-store/cjs/use-sync-external-store-shim.development.js","../../node_modules/.pnpm/use-sync-external-store@1.2.0_react@18.2.0/node_modules/use-sync-external-store/shim/index.js","../../node_modules/.pnpm/use-sync-external-store@1.2.0_react@18.2.0/node_modules/use-sync-external-store/cjs/use-sync-external-store-shim/with-selector.production.min.js","../../node_modules/.pnpm/use-sync-external-store@1.2.0_react@18.2.0/node_modules/use-sync-external-store/cjs/use-sync-external-store-shim/with-selector.development.js","../../node_modules/.pnpm/use-sync-external-store@1.2.0_react@18.2.0/node_modules/use-sync-external-store/shim/with-selector.js","../../src/react/useStore.ts","../../src/react/useProp.ts","../../src/react/reactMethods.ts","../../src/react/useCache.ts","../../src/react/scope.tsx"],"sourcesContent":["/**\n * @license React\n * use-sync-external-store-shim.production.min.js\n *\n * Copyright (c) Facebook, Inc. and its affiliates.\n *\n * This source code is licensed under the MIT license found in the\n * LICENSE file in the root directory of this source tree.\n */\n'use strict';var e=require(\"react\");function h(a,b){return a===b&&(0!==a||1/a===1/b)||a!==a&&b!==b}var k=\"function\"===typeof Object.is?Object.is:h,l=e.useState,m=e.useEffect,n=e.useLayoutEffect,p=e.useDebugValue;function q(a,b){var d=b(),f=l({inst:{value:d,getSnapshot:b}}),c=f[0].inst,g=f[1];n(function(){c.value=d;c.getSnapshot=b;r(c)&&g({inst:c})},[a,d,b]);m(function(){r(c)&&g({inst:c});return a(function(){r(c)&&g({inst:c})})},[a]);p(d);return d}\nfunction r(a){var b=a.getSnapshot;a=a.value;try{var d=b();return!k(a,d)}catch(f){return!0}}function t(a,b){return b()}var u=\"undefined\"===typeof window||\"undefined\"===typeof window.document||\"undefined\"===typeof window.document.createElement?t:q;exports.useSyncExternalStore=void 0!==e.useSyncExternalStore?e.useSyncExternalStore:u;\n","/**\n * @license React\n * use-sync-external-store-shim.development.js\n *\n * Copyright (c) Facebook, Inc. and its affiliates.\n *\n * This source code is licensed under the MIT license found in the\n * LICENSE file in the root directory of this source tree.\n */\n\n'use strict';\n\nif (process.env.NODE_ENV !== \"production\") {\n (function() {\n\n 'use strict';\n\n/* global __REACT_DEVTOOLS_GLOBAL_HOOK__ */\nif (\n typeof __REACT_DEVTOOLS_GLOBAL_HOOK__ !== 'undefined' &&\n typeof __REACT_DEVTOOLS_GLOBAL_HOOK__.registerInternalModuleStart ===\n 'function'\n) {\n __REACT_DEVTOOLS_GLOBAL_HOOK__.registerInternalModuleStart(new Error());\n}\n var React = require('react');\n\nvar ReactSharedInternals = React.__SECRET_INTERNALS_DO_NOT_USE_OR_YOU_WILL_BE_FIRED;\n\nfunction error(format) {\n {\n {\n for (var _len2 = arguments.length, args = new Array(_len2 > 1 ? _len2 - 1 : 0), _key2 = 1; _key2 < _len2; _key2++) {\n args[_key2 - 1] = arguments[_key2];\n }\n\n printWarning('error', format, args);\n }\n }\n}\n\nfunction printWarning(level, format, args) {\n // When changing this logic, you might want to also\n // update consoleWithStackDev.www.js as well.\n {\n var ReactDebugCurrentFrame = ReactSharedInternals.ReactDebugCurrentFrame;\n var stack = ReactDebugCurrentFrame.getStackAddendum();\n\n if (stack !== '') {\n format += '%s';\n args = args.concat([stack]);\n } // eslint-disable-next-line react-internal/safe-string-coercion\n\n\n var argsWithFormat = args.map(function (item) {\n return String(item);\n }); // Careful: RN currently depends on this prefix\n\n argsWithFormat.unshift('Warning: ' + format); // We intentionally don't use spread (or .apply) directly because it\n // breaks IE9: https://github.com/facebook/react/issues/13610\n // eslint-disable-next-line react-internal/no-production-logging\n\n Function.prototype.apply.call(console[level], console, argsWithFormat);\n }\n}\n\n/**\n * inlined Object.is polyfill to avoid requiring consumers ship their own\n * https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/Object/is\n */\nfunction is(x, y) {\n return x === y && (x !== 0 || 1 / x === 1 / y) || x !== x && y !== y // eslint-disable-line no-self-compare\n ;\n}\n\nvar objectIs = typeof Object.is === 'function' ? Object.is : is;\n\n// dispatch for CommonJS interop named imports.\n\nvar useState = React.useState,\n useEffect = React.useEffect,\n useLayoutEffect = React.useLayoutEffect,\n useDebugValue = React.useDebugValue;\nvar didWarnOld18Alpha = false;\nvar didWarnUncachedGetSnapshot = false; // Disclaimer: This shim breaks many of the rules of React, and only works\n// because of a very particular set of implementation details and assumptions\n// -- change any one of them and it will break. The most important assumption\n// is that updates are always synchronous, because concurrent rendering is\n// only available in versions of React that also have a built-in\n// useSyncExternalStore API. And we only use this shim when the built-in API\n// does not exist.\n//\n// Do not assume that the clever hacks used by this hook also work in general.\n// The point of this shim is to replace the need for hacks by other libraries.\n\nfunction useSyncExternalStore(subscribe, getSnapshot, // Note: The shim does not use getServerSnapshot, because pre-18 versions of\n// React do not expose a way to check if we're hydrating. So users of the shim\n// will need to track that themselves and return the correct value\n// from `getSnapshot`.\ngetServerSnapshot) {\n {\n if (!didWarnOld18Alpha) {\n if (React.startTransition !== undefined) {\n didWarnOld18Alpha = true;\n\n error('You are using an outdated, pre-release alpha of React 18 that ' + 'does not support useSyncExternalStore. The ' + 'use-sync-external-store shim will not work correctly. Upgrade ' + 'to a newer pre-release.');\n }\n }\n } // Read the current snapshot from the store on every render. Again, this\n // breaks the rules of React, and only works here because of specific\n // implementation details, most importantly that updates are\n // always synchronous.\n\n\n var value = getSnapshot();\n\n {\n if (!didWarnUncachedGetSnapshot) {\n var cachedValue = getSnapshot();\n\n if (!objectIs(value, cachedValue)) {\n error('The result of getSnapshot should be cached to avoid an infinite loop');\n\n didWarnUncachedGetSnapshot = true;\n }\n }\n } // Because updates are synchronous, we don't queue them. Instead we force a\n // re-render whenever the subscribed state changes by updating an some\n // arbitrary useState hook. Then, during render, we call getSnapshot to read\n // the current value.\n //\n // Because we don't actually use the state returned by the useState hook, we\n // can save a bit of memory by storing other stuff in that slot.\n //\n // To implement the early bailout, we need to track some things on a mutable\n // object. Usually, we would put that in a useRef hook, but we can stash it in\n // our useState hook instead.\n //\n // To force a re-render, we call forceUpdate({inst}). That works because the\n // new object always fails an equality check.\n\n\n var _useState = useState({\n inst: {\n value: value,\n getSnapshot: getSnapshot\n }\n }),\n inst = _useState[0].inst,\n forceUpdate = _useState[1]; // Track the latest getSnapshot function with a ref. This needs to be updated\n // in the layout phase so we can access it during the tearing check that\n // happens on subscribe.\n\n\n useLayoutEffect(function () {\n inst.value = value;\n inst.getSnapshot = getSnapshot; // Whenever getSnapshot or subscribe changes, we need to check in the\n // commit phase if there was an interleaved mutation. In concurrent mode\n // this can happen all the time, but even in synchronous mode, an earlier\n // effect may have mutated the store.\n\n if (checkIfSnapshotChanged(inst)) {\n // Force a re-render.\n forceUpdate({\n inst: inst\n });\n }\n }, [subscribe, value, getSnapshot]);\n useEffect(function () {\n // Check for changes right before subscribing. Subsequent changes will be\n // detected in the subscription handler.\n if (checkIfSnapshotChanged(inst)) {\n // Force a re-render.\n forceUpdate({\n inst: inst\n });\n }\n\n var handleStoreChange = function () {\n // TODO: Because there is no cross-renderer API for batching updates, it's\n // up to the consumer of this library to wrap their subscription event\n // with unstable_batchedUpdates. Should we try to detect when this isn't\n // the case and print a warning in development?\n // The store changed. Check if the snapshot changed since the last time we\n // read from the store.\n if (checkIfSnapshotChanged(inst)) {\n // Force a re-render.\n forceUpdate({\n inst: inst\n });\n }\n }; // Subscribe to the store and return a clean-up function.\n\n\n return subscribe(handleStoreChange);\n }, [subscribe]);\n useDebugValue(value);\n return value;\n}\n\nfunction checkIfSnapshotChanged(inst) {\n var latestGetSnapshot = inst.getSnapshot;\n var prevValue = inst.value;\n\n try {\n var nextValue = latestGetSnapshot();\n return !objectIs(prevValue, nextValue);\n } catch (error) {\n return true;\n }\n}\n\nfunction useSyncExternalStore$1(subscribe, getSnapshot, getServerSnapshot) {\n // Note: The shim does not use getServerSnapshot, because pre-18 versions of\n // React do not expose a way to check if we're hydrating. So users of the shim\n // will need to track that themselves and return the correct value\n // from `getSnapshot`.\n return getSnapshot();\n}\n\nvar canUseDOM = !!(typeof window !== 'undefined' && typeof window.document !== 'undefined' && typeof window.document.createElement !== 'undefined');\n\nvar isServerEnvironment = !canUseDOM;\n\nvar shim = isServerEnvironment ? useSyncExternalStore$1 : useSyncExternalStore;\nvar useSyncExternalStore$2 = React.useSyncExternalStore !== undefined ? React.useSyncExternalStore : shim;\n\nexports.useSyncExternalStore = useSyncExternalStore$2;\n /* global __REACT_DEVTOOLS_GLOBAL_HOOK__ */\nif (\n typeof __REACT_DEVTOOLS_GLOBAL_HOOK__ !== 'undefined' &&\n typeof __REACT_DEVTOOLS_GLOBAL_HOOK__.registerInternalModuleStop ===\n 'function'\n) {\n __REACT_DEVTOOLS_GLOBAL_HOOK__.registerInternalModuleStop(new Error());\n}\n \n })();\n}\n","'use strict';\n\nif (process.env.NODE_ENV === 'production') {\n module.exports = require('../cjs/use-sync-external-store-shim.production.min.js');\n} else {\n module.exports = require('../cjs/use-sync-external-store-shim.development.js');\n}\n","/**\n * @license React\n * use-sync-external-store-shim/with-selector.production.min.js\n *\n * Copyright (c) Facebook, Inc. and its affiliates.\n *\n * This source code is licensed under the MIT license found in the\n * LICENSE file in the root directory of this source tree.\n */\n'use strict';var h=require(\"react\"),n=require(\"use-sync-external-store/shim\");function p(a,b){return a===b&&(0!==a||1/a===1/b)||a!==a&&b!==b}var q=\"function\"===typeof Object.is?Object.is:p,r=n.useSyncExternalStore,t=h.useRef,u=h.useEffect,v=h.useMemo,w=h.useDebugValue;\nexports.useSyncExternalStoreWithSelector=function(a,b,e,l,g){var c=t(null);if(null===c.current){var f={hasValue:!1,value:null};c.current=f}else f=c.current;c=v(function(){function a(a){if(!c){c=!0;d=a;a=l(a);if(void 0!==g&&f.hasValue){var b=f.value;if(g(b,a))return k=b}return k=a}b=k;if(q(d,a))return b;var e=l(a);if(void 0!==g&&g(b,e))return b;d=a;return k=e}var c=!1,d,k,m=void 0===e?null:e;return[function(){return a(b())},null===m?void 0:function(){return a(m())}]},[b,e,l,g]);var d=r(a,c[0],c[1]);\nu(function(){f.hasValue=!0;f.value=d},[d]);w(d);return d};\n","/**\n * @license React\n * use-sync-external-store-shim/with-selector.development.js\n *\n * Copyright (c) Facebook, Inc. and its affiliates.\n *\n * This source code is licensed under the MIT license found in the\n * LICENSE file in the root directory of this source tree.\n */\n\n'use strict';\n\nif (process.env.NODE_ENV !== \"production\") {\n (function() {\n\n 'use strict';\n\n/* global __REACT_DEVTOOLS_GLOBAL_HOOK__ */\nif (\n typeof __REACT_DEVTOOLS_GLOBAL_HOOK__ !== 'undefined' &&\n typeof __REACT_DEVTOOLS_GLOBAL_HOOK__.registerInternalModuleStart ===\n 'function'\n) {\n __REACT_DEVTOOLS_GLOBAL_HOOK__.registerInternalModuleStart(new Error());\n}\n var React = require('react');\nvar shim = require('use-sync-external-store/shim');\n\n/**\n * inlined Object.is polyfill to avoid requiring consumers ship their own\n * https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/Object/is\n */\nfunction is(x, y) {\n return x === y && (x !== 0 || 1 / x === 1 / y) || x !== x && y !== y // eslint-disable-line no-self-compare\n ;\n}\n\nvar objectIs = typeof Object.is === 'function' ? Object.is : is;\n\nvar useSyncExternalStore = shim.useSyncExternalStore;\n\n// for CommonJS interop.\n\nvar useRef = React.useRef,\n useEffect = React.useEffect,\n useMemo = React.useMemo,\n useDebugValue = React.useDebugValue; // Same as useSyncExternalStore, but supports selector and isEqual arguments.\n\nfunction useSyncExternalStoreWithSelector(subscribe, getSnapshot, getServerSnapshot, selector, isEqual) {\n // Use this to track the rendered snapshot.\n var instRef = useRef(null);\n var inst;\n\n if (instRef.current === null) {\n inst = {\n hasValue: false,\n value: null\n };\n instRef.current = inst;\n } else {\n inst = instRef.current;\n }\n\n var _useMemo = useMemo(function () {\n // Track the memoized state using closure variables that are local to this\n // memoized instance of a getSnapshot function. Intentionally not using a\n // useRef hook, because that state would be shared across all concurrent\n // copies of the hook/component.\n var hasMemo = false;\n var memoizedSnapshot;\n var memoizedSelection;\n\n var memoizedSelector = function (nextSnapshot) {\n if (!hasMemo) {\n // The first time the hook is called, there is no memoized result.\n hasMemo = true;\n memoizedSnapshot = nextSnapshot;\n\n var _nextSelection = selector(nextSnapshot);\n\n if (isEqual !== undefined) {\n // Even if the selector has changed, the currently rendered selection\n // may be equal to the new selection. We should attempt to reuse the\n // current value if possible, to preserve downstream memoizations.\n if (inst.hasValue) {\n var currentSelection = inst.value;\n\n if (isEqual(currentSelection, _nextSelection)) {\n memoizedSelection = currentSelection;\n return currentSelection;\n }\n }\n }\n\n memoizedSelection = _nextSelection;\n return _nextSelection;\n } // We may be able to reuse the previous invocation's result.\n\n\n // We may be able to reuse the previous invocation's result.\n var prevSnapshot = memoizedSnapshot;\n var prevSelection = memoizedSelection;\n\n if (objectIs(prevSnapshot, nextSnapshot)) {\n // The snapshot is the same as last time. Reuse the previous selection.\n return prevSelection;\n } // The snapshot has changed, so we need to compute a new selection.\n\n\n // The snapshot has changed, so we need to compute a new selection.\n var nextSelection = selector(nextSnapshot); // If a custom isEqual function is provided, use that to check if the data\n // has changed. If it hasn't, return the previous selection. That signals\n // to React that the selections are conceptually equal, and we can bail\n // out of rendering.\n\n // If a custom isEqual function is provided, use that to check if the data\n // has changed. If it hasn't, return the previous selection. That signals\n // to React that the selections are conceptually equal, and we can bail\n // out of rendering.\n if (isEqual !== undefined && isEqual(prevSelection, nextSelection)) {\n return prevSelection;\n }\n\n memoizedSnapshot = nextSnapshot;\n memoizedSelection = nextSelection;\n return nextSelection;\n }; // Assigning this to a constant so that Flow knows it can't change.\n\n\n // Assigning this to a constant so that Flow knows it can't change.\n var maybeGetServerSnapshot = getServerSnapshot === undefined ? null : getServerSnapshot;\n\n var getSnapshotWithSelector = function () {\n return memoizedSelector(getSnapshot());\n };\n\n var getServerSnapshotWithSelector = maybeGetServerSnapshot === null ? undefined : function () {\n return memoizedSelector(maybeGetServerSnapshot());\n };\n return [getSnapshotWithSelector, getServerSnapshotWithSelector];\n }, [getSnapshot, getServerSnapshot, selector, isEqual]),\n getSelection = _useMemo[0],\n getServerSelection = _useMemo[1];\n\n var value = useSyncExternalStore(subscribe, getSelection, getServerSelection);\n useEffect(function () {\n inst.hasValue = true;\n inst.value = value;\n }, [value]);\n useDebugValue(value);\n return value;\n}\n\nexports.useSyncExternalStoreWithSelector = useSyncExternalStoreWithSelector;\n /* global __REACT_DEVTOOLS_GLOBAL_HOOK__ */\nif (\n typeof __REACT_DEVTOOLS_GLOBAL_HOOK__ !== 'undefined' &&\n typeof __REACT_DEVTOOLS_GLOBAL_HOOK__.registerInternalModuleStop ===\n 'function'\n) {\n __REACT_DEVTOOLS_GLOBAL_HOOK__.registerInternalModuleStop(new Error());\n}\n \n })();\n}\n","'use strict';\n\nif (process.env.NODE_ENV === 'production') {\n module.exports = require('../cjs/use-sync-external-store-shim/with-selector.production.min.js');\n} else {\n module.exports = require('../cjs/use-sync-external-store-shim/with-selector.development.js');\n}\n","import { useCallback, useDebugValue, useLayoutEffect, useMemo, useRef } from 'react';\nimport { useSyncExternalStoreWithSelector } from 'use-sync-external-store/shim/with-selector.js';\nimport type { SubscribeOptions } from '@core/commonTypes';\nimport type { Store } from '@core/store';\nimport { hash } from '@lib/hash';\nimport { makeSelector } from '@lib/makeSelector';\nimport { trackingProxy } from '@lib/trackingProxy';\n\nexport type UseStoreOptions = Omit<SubscribeOptions, 'runNow' | 'passive'>;\n\nexport function useStore<T>(store: Store<T>, options?: UseStoreOptions): T {\n const lastEqualsRef = useRef<(newValue: T) => boolean>();\n\n const { rootStore, selector } = useMemo(() => {\n const rootStore = store.derivedFrom?.store ?? store;\n let selector = (x: any) => x;\n\n if (store.derivedFrom) {\n selector = (value: any) => {\n for (const s of store.derivedFrom!.selectors) {\n value = makeSelector(s)(value);\n }\n return value;\n };\n }\n\n return { rootStore, selector };\n }, [store]);\n\n const subOptions = { ...options, runNow: false, equals: undefined, passive: false };\n const subscribe = useCallback(\n (listener: () => void) => {\n return rootStore.subscribe(listener, subOptions);\n },\n [rootStore, hash(subOptions)],\n );\n\n const value = useSyncExternalStoreWithSelector<unknown, T>(\n //\n subscribe,\n rootStore.get,\n undefined,\n selector,\n options?.equals ?? ((_v, newValue) => lastEqualsRef.current?.(newValue) ?? false),\n );\n const [proxiedValue, equals] = trackingProxy(value);\n\n useLayoutEffect(() => {\n lastEqualsRef.current = equals;\n });\n\n useDebugValue(value);\n return proxiedValue;\n}\n","import type { UseStoreOptions } from './useStore';\nimport { useStore } from './useStore';\nimport type { Store } from '@core/store';\n\nexport function useProp<T>(\n store: Store<T>,\n options?: UseStoreOptions,\n): [value: T, setValue: typeof store.set] {\n const value = useStore(store, options);\n\n return [value, store.set];\n}\n","import { useProp } from './useProp';\nimport { type UseStoreOptions, useStore } from './useStore';\nimport type { Store } from '@core/store';\n\nexport const reactMethods = {\n useStore<T>(this: Store<T>, options?: UseStoreOptions) {\n return useStore(this, options);\n },\n\n useProp<T>(this: Store<T>, options?: UseStoreOptions) {\n return useProp(this, options);\n },\n};\n","import { useEffect, useMemo } from 'react';\nimport type { UseStoreOptions } from './useStore';\nimport { useStore } from './useStore';\nimport type { Cache } from '@core';\nimport type { CacheState } from '@lib/cacheState';\nimport { makeSelector } from '@lib/makeSelector';\n\nexport type UseCacheArray<T> = [\n value: T | undefined,\n error: unknown | undefined,\n isUpdating: boolean,\n isStale: boolean,\n];\n\nexport type UseCacheValue<T> = UseCacheArray<T> & CacheState<T>;\n\nexport interface UseCacheOptions extends UseStoreOptions {\n passive?: boolean;\n updateOnMount?: boolean;\n}\n\nexport function useCache<T>(\n cache: Cache<T>,\n { passive, updateOnMount, ...options }: UseCacheOptions = {},\n): UseCacheValue<T> {\n const mappedState = useMemo(() => {\n const rootCache: Cache<any> = cache.derivedFromCache?.cache ?? cache;\n let selector = (x: any) => x;\n\n if (cache.derivedFromCache) {\n selector = (value: any) => {\n for (const s of cache.derivedFromCache!.selectors) {\n value = makeSelector(s)(value);\n }\n return value;\n };\n }\n\n return rootCache.state.map((state) => {\n const value = state.status === 'value' ? selector(state.value) : undefined;\n\n return Object.assign<UseCacheArray<T>, CacheState<T>>(\n [value, state.error, state.isUpdating, state.isStale],\n { ...state, value },\n );\n });\n }, [cache]);\n\n useEffect(() => (!passive ? cache.subscribe(() => undefined) : undefined), [cache, passive]);\n\n useEffect(() => {\n if (updateOnMount) {\n cache.invalidate();\n }\n }, []);\n\n return useStore(mappedState, options);\n}\n","import type { Context, ReactNode } from 'react';\nimport { createContext, useContext, useMemo } from 'react';\nimport { useProp } from './useProp';\nimport { useStore, type UseStoreOptions } from './useStore';\nimport { createStore } from '@core/store';\nimport type { Store } from '@core/store';\nimport type { Scope } from '@core';\n\nexport type ScopeProps<T> = { scope: Scope<T>; store?: Store<T>; children?: ReactNode };\n\nconst contextMap = new WeakMap<Scope<any>, Context<Store<any>>>();\n\nfunction getScopeContext<T>(scope: Scope<T>): Context<Store<T>> {\n let context = contextMap.get(scope);\n\n if (!context) {\n context = createContext<Store<T>>(createStore(scope.defaultValue));\n contextMap.set(scope, context);\n }\n\n return context;\n}\n\nexport function ScopeProvider<T>({ scope, store: inputStore, children }: ScopeProps<T>) {\n const context = getScopeContext(scope);\n const currentStore = useMemo(\n () => inputStore ?? createStore(scope.defaultValue),\n [scope, inputStore],\n );\n\n return <context.Provider value={currentStore}>{children}</context.Provider>;\n}\n\nexport function useScope<T>(scope: Scope<T>): Store<T> {\n const context = getScopeContext(scope);\n return useContext(context);\n}\n\nexport function useScopeStore<T>(scope: Scope<T>, options?: UseStoreOptions): T {\n const store = useScope(scope);\n return useStore(store, options);\n}\n\nexport function useScopeProp<T>(scope: Scope<T>, options?: UseStoreOptions) {\n const store = useScope(scope);\n return useProp(store, options);\n}\n"],"names":["error","shim","module","require$$0","require$$1","a","c","d","b","e","store","useRef","useMemo","rootStore","selector","value","makeSelector","useCallback","hash","useSyncExternalStoreWithSelector","trackingProxy","useLayoutEffect","useDebugValue","useEffect","createContext","createStore","useContext"],"mappings":";;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;AASa,MAAI,IAAE;AAAiB,WAAS,EAAE,GAAE,GAAE;AAAC,WAAO,MAAI,MAAI,MAAI,KAAG,IAAE,MAAI,IAAE,MAAI,MAAI,KAAG,MAAI;AAAA,EAAC;AAAC,MAAI,IAAE,eAAa,OAAO,OAAO,KAAG,OAAO,KAAG,GAAE,IAAE,EAAE,UAAS,IAAE,EAAE,WAAU,IAAE,EAAE,iBAAgB,IAAE,EAAE;AAAc,WAAS,EAAE,GAAE,GAAE;AAAC,QAAI,IAAE,EAAC,GAAG,IAAE,EAAE,EAAC,MAAK,EAAC,OAAM,GAAE,aAAY,EAAC,EAAC,CAAC,GAAE,IAAE,EAAE,CAAC,EAAE,MAAK,IAAE,EAAE,CAAC;AAAE,MAAE,WAAU;AAAC,QAAE,QAAM;AAAE,QAAE,cAAY;AAAE,QAAE,CAAC,KAAG,EAAE,EAAC,MAAK,EAAC,CAAC;AAAA,IAAC,GAAE,CAAC,GAAE,GAAE,CAAC,CAAC;AAAE,MAAE,WAAU;AAAC,QAAE,CAAC,KAAG,EAAE,EAAC,MAAK,EAAC,CAAC;AAAE,aAAO,EAAE,WAAU;AAAC,UAAE,CAAC,KAAG,EAAE,EAAC,MAAK,EAAC,CAAC;AAAA,MAAC,CAAC;AAAA,IAAC,GAAE,CAAC,CAAC,CAAC;AAAE,MAAE,CAA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ClD,CAAC,OAAO,UAAU;AAAA,EAAA;AAGpB,wCAAQ,QAAQ,UAAR,EAAiB,OAAO,cAAe,SAAS,CAAA;AAC1D;AAEO,SAAS,SAAY,OAA2B;AAC/C,QAAA,UAAU,gBAAgB,KAAK;AACrC,SAAOC,WAAAA,WAAW,OAAO;AAC3B;AAEgB,SAAA,cAAiB,OAAiB,SAA8B;AACxE,QAAAhB,SAAQ,SAAS,KAAK;AACrB,SAAA,SAASA,QAAO,OAAO;AAChC;AAEgB,SAAA,aAAgB,OAAiB,SAA2B;AACpE,QAAAA,SAAQ,SAAS,KAAK;AACrB,SAAA,QAAQA,QAAO,OAAO;AAC/B;;;;;;;;;","x_google_ignoreList":[0,1,2,3,4,5]}
1
+ {"version":3,"file":"scope2.cjs","sources":["../../node_modules/.pnpm/use-sync-external-store@1.2.0_react@18.2.0/node_modules/use-sync-external-store/cjs/use-sync-external-store-shim.production.min.js","../../node_modules/.pnpm/use-sync-external-store@1.2.0_react@18.2.0/node_modules/use-sync-external-store/cjs/use-sync-external-store-shim.development.js","../../node_modules/.pnpm/use-sync-external-store@1.2.0_react@18.2.0/node_modules/use-sync-external-store/shim/index.js","../../node_modules/.pnpm/use-sync-external-store@1.2.0_react@18.2.0/node_modules/use-sync-external-store/cjs/use-sync-external-store-shim/with-selector.production.min.js","../../node_modules/.pnpm/use-sync-external-store@1.2.0_react@18.2.0/node_modules/use-sync-external-store/cjs/use-sync-external-store-shim/with-selector.development.js","../../node_modules/.pnpm/use-sync-external-store@1.2.0_react@18.2.0/node_modules/use-sync-external-store/shim/with-selector.js","../../src/react/useStore.ts","../../src/react/useProp.ts","../../src/react/reactMethods.ts","../../src/react/useCache.ts","../../src/react/scope.tsx"],"sourcesContent":["/**\n * @license React\n * use-sync-external-store-shim.production.min.js\n *\n * Copyright (c) Facebook, Inc. and its affiliates.\n *\n * This source code is licensed under the MIT license found in the\n * LICENSE file in the root directory of this source tree.\n */\n'use strict';var e=require(\"react\");function h(a,b){return a===b&&(0!==a||1/a===1/b)||a!==a&&b!==b}var k=\"function\"===typeof Object.is?Object.is:h,l=e.useState,m=e.useEffect,n=e.useLayoutEffect,p=e.useDebugValue;function q(a,b){var d=b(),f=l({inst:{value:d,getSnapshot:b}}),c=f[0].inst,g=f[1];n(function(){c.value=d;c.getSnapshot=b;r(c)&&g({inst:c})},[a,d,b]);m(function(){r(c)&&g({inst:c});return a(function(){r(c)&&g({inst:c})})},[a]);p(d);return d}\nfunction r(a){var b=a.getSnapshot;a=a.value;try{var d=b();return!k(a,d)}catch(f){return!0}}function t(a,b){return b()}var u=\"undefined\"===typeof window||\"undefined\"===typeof window.document||\"undefined\"===typeof window.document.createElement?t:q;exports.useSyncExternalStore=void 0!==e.useSyncExternalStore?e.useSyncExternalStore:u;\n","/**\n * @license React\n * use-sync-external-store-shim.development.js\n *\n * Copyright (c) Facebook, Inc. and its affiliates.\n *\n * This source code is licensed under the MIT license found in the\n * LICENSE file in the root directory of this source tree.\n */\n\n'use strict';\n\nif (process.env.NODE_ENV !== \"production\") {\n (function() {\n\n 'use strict';\n\n/* global __REACT_DEVTOOLS_GLOBAL_HOOK__ */\nif (\n typeof __REACT_DEVTOOLS_GLOBAL_HOOK__ !== 'undefined' &&\n typeof __REACT_DEVTOOLS_GLOBAL_HOOK__.registerInternalModuleStart ===\n 'function'\n) {\n __REACT_DEVTOOLS_GLOBAL_HOOK__.registerInternalModuleStart(new Error());\n}\n var React = require('react');\n\nvar ReactSharedInternals = React.__SECRET_INTERNALS_DO_NOT_USE_OR_YOU_WILL_BE_FIRED;\n\nfunction error(format) {\n {\n {\n for (var _len2 = arguments.length, args = new Array(_len2 > 1 ? _len2 - 1 : 0), _key2 = 1; _key2 < _len2; _key2++) {\n args[_key2 - 1] = arguments[_key2];\n }\n\n printWarning('error', format, args);\n }\n }\n}\n\nfunction printWarning(level, format, args) {\n // When changing this logic, you might want to also\n // update consoleWithStackDev.www.js as well.\n {\n var ReactDebugCurrentFrame = ReactSharedInternals.ReactDebugCurrentFrame;\n var stack = ReactDebugCurrentFrame.getStackAddendum();\n\n if (stack !== '') {\n format += '%s';\n args = args.concat([stack]);\n } // eslint-disable-next-line react-internal/safe-string-coercion\n\n\n var argsWithFormat = args.map(function (item) {\n return String(item);\n }); // Careful: RN currently depends on this prefix\n\n argsWithFormat.unshift('Warning: ' + format); // We intentionally don't use spread (or .apply) directly because it\n // breaks IE9: https://github.com/facebook/react/issues/13610\n // eslint-disable-next-line react-internal/no-production-logging\n\n Function.prototype.apply.call(console[level], console, argsWithFormat);\n }\n}\n\n/**\n * inlined Object.is polyfill to avoid requiring consumers ship their own\n * https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/Object/is\n */\nfunction is(x, y) {\n return x === y && (x !== 0 || 1 / x === 1 / y) || x !== x && y !== y // eslint-disable-line no-self-compare\n ;\n}\n\nvar objectIs = typeof Object.is === 'function' ? Object.is : is;\n\n// dispatch for CommonJS interop named imports.\n\nvar useState = React.useState,\n useEffect = React.useEffect,\n useLayoutEffect = React.useLayoutEffect,\n useDebugValue = React.useDebugValue;\nvar didWarnOld18Alpha = false;\nvar didWarnUncachedGetSnapshot = false; // Disclaimer: This shim breaks many of the rules of React, and only works\n// because of a very particular set of implementation details and assumptions\n// -- change any one of them and it will break. The most important assumption\n// is that updates are always synchronous, because concurrent rendering is\n// only available in versions of React that also have a built-in\n// useSyncExternalStore API. And we only use this shim when the built-in API\n// does not exist.\n//\n// Do not assume that the clever hacks used by this hook also work in general.\n// The point of this shim is to replace the need for hacks by other libraries.\n\nfunction useSyncExternalStore(subscribe, getSnapshot, // Note: The shim does not use getServerSnapshot, because pre-18 versions of\n// React do not expose a way to check if we're hydrating. So users of the shim\n// will need to track that themselves and return the correct value\n// from `getSnapshot`.\ngetServerSnapshot) {\n {\n if (!didWarnOld18Alpha) {\n if (React.startTransition !== undefined) {\n didWarnOld18Alpha = true;\n\n error('You are using an outdated, pre-release alpha of React 18 that ' + 'does not support useSyncExternalStore. The ' + 'use-sync-external-store shim will not work correctly. Upgrade ' + 'to a newer pre-release.');\n }\n }\n } // Read the current snapshot from the store on every render. Again, this\n // breaks the rules of React, and only works here because of specific\n // implementation details, most importantly that updates are\n // always synchronous.\n\n\n var value = getSnapshot();\n\n {\n if (!didWarnUncachedGetSnapshot) {\n var cachedValue = getSnapshot();\n\n if (!objectIs(value, cachedValue)) {\n error('The result of getSnapshot should be cached to avoid an infinite loop');\n\n didWarnUncachedGetSnapshot = true;\n }\n }\n } // Because updates are synchronous, we don't queue them. Instead we force a\n // re-render whenever the subscribed state changes by updating an some\n // arbitrary useState hook. Then, during render, we call getSnapshot to read\n // the current value.\n //\n // Because we don't actually use the state returned by the useState hook, we\n // can save a bit of memory by storing other stuff in that slot.\n //\n // To implement the early bailout, we need to track some things on a mutable\n // object. Usually, we would put that in a useRef hook, but we can stash it in\n // our useState hook instead.\n //\n // To force a re-render, we call forceUpdate({inst}). That works because the\n // new object always fails an equality check.\n\n\n var _useState = useState({\n inst: {\n value: value,\n getSnapshot: getSnapshot\n }\n }),\n inst = _useState[0].inst,\n forceUpdate = _useState[1]; // Track the latest getSnapshot function with a ref. This needs to be updated\n // in the layout phase so we can access it during the tearing check that\n // happens on subscribe.\n\n\n useLayoutEffect(function () {\n inst.value = value;\n inst.getSnapshot = getSnapshot; // Whenever getSnapshot or subscribe changes, we need to check in the\n // commit phase if there was an interleaved mutation. In concurrent mode\n // this can happen all the time, but even in synchronous mode, an earlier\n // effect may have mutated the store.\n\n if (checkIfSnapshotChanged(inst)) {\n // Force a re-render.\n forceUpdate({\n inst: inst\n });\n }\n }, [subscribe, value, getSnapshot]);\n useEffect(function () {\n // Check for changes right before subscribing. Subsequent changes will be\n // detected in the subscription handler.\n if (checkIfSnapshotChanged(inst)) {\n // Force a re-render.\n forceUpdate({\n inst: inst\n });\n }\n\n var handleStoreChange = function () {\n // TODO: Because there is no cross-renderer API for batching updates, it's\n // up to the consumer of this library to wrap their subscription event\n // with unstable_batchedUpdates. Should we try to detect when this isn't\n // the case and print a warning in development?\n // The store changed. Check if the snapshot changed since the last time we\n // read from the store.\n if (checkIfSnapshotChanged(inst)) {\n // Force a re-render.\n forceUpdate({\n inst: inst\n });\n }\n }; // Subscribe to the store and return a clean-up function.\n\n\n return subscribe(handleStoreChange);\n }, [subscribe]);\n useDebugValue(value);\n return value;\n}\n\nfunction checkIfSnapshotChanged(inst) {\n var latestGetSnapshot = inst.getSnapshot;\n var prevValue = inst.value;\n\n try {\n var nextValue = latestGetSnapshot();\n return !objectIs(prevValue, nextValue);\n } catch (error) {\n return true;\n }\n}\n\nfunction useSyncExternalStore$1(subscribe, getSnapshot, getServerSnapshot) {\n // Note: The shim does not use getServerSnapshot, because pre-18 versions of\n // React do not expose a way to check if we're hydrating. So users of the shim\n // will need to track that themselves and return the correct value\n // from `getSnapshot`.\n return getSnapshot();\n}\n\nvar canUseDOM = !!(typeof window !== 'undefined' && typeof window.document !== 'undefined' && typeof window.document.createElement !== 'undefined');\n\nvar isServerEnvironment = !canUseDOM;\n\nvar shim = isServerEnvironment ? useSyncExternalStore$1 : useSyncExternalStore;\nvar useSyncExternalStore$2 = React.useSyncExternalStore !== undefined ? React.useSyncExternalStore : shim;\n\nexports.useSyncExternalStore = useSyncExternalStore$2;\n /* global __REACT_DEVTOOLS_GLOBAL_HOOK__ */\nif (\n typeof __REACT_DEVTOOLS_GLOBAL_HOOK__ !== 'undefined' &&\n typeof __REACT_DEVTOOLS_GLOBAL_HOOK__.registerInternalModuleStop ===\n 'function'\n) {\n __REACT_DEVTOOLS_GLOBAL_HOOK__.registerInternalModuleStop(new Error());\n}\n \n })();\n}\n","'use strict';\n\nif (process.env.NODE_ENV === 'production') {\n module.exports = require('../cjs/use-sync-external-store-shim.production.min.js');\n} else {\n module.exports = require('../cjs/use-sync-external-store-shim.development.js');\n}\n","/**\n * @license React\n * use-sync-external-store-shim/with-selector.production.min.js\n *\n * Copyright (c) Facebook, Inc. and its affiliates.\n *\n * This source code is licensed under the MIT license found in the\n * LICENSE file in the root directory of this source tree.\n */\n'use strict';var h=require(\"react\"),n=require(\"use-sync-external-store/shim\");function p(a,b){return a===b&&(0!==a||1/a===1/b)||a!==a&&b!==b}var q=\"function\"===typeof Object.is?Object.is:p,r=n.useSyncExternalStore,t=h.useRef,u=h.useEffect,v=h.useMemo,w=h.useDebugValue;\nexports.useSyncExternalStoreWithSelector=function(a,b,e,l,g){var c=t(null);if(null===c.current){var f={hasValue:!1,value:null};c.current=f}else f=c.current;c=v(function(){function a(a){if(!c){c=!0;d=a;a=l(a);if(void 0!==g&&f.hasValue){var b=f.value;if(g(b,a))return k=b}return k=a}b=k;if(q(d,a))return b;var e=l(a);if(void 0!==g&&g(b,e))return b;d=a;return k=e}var c=!1,d,k,m=void 0===e?null:e;return[function(){return a(b())},null===m?void 0:function(){return a(m())}]},[b,e,l,g]);var d=r(a,c[0],c[1]);\nu(function(){f.hasValue=!0;f.value=d},[d]);w(d);return d};\n","/**\n * @license React\n * use-sync-external-store-shim/with-selector.development.js\n *\n * Copyright (c) Facebook, Inc. and its affiliates.\n *\n * This source code is licensed under the MIT license found in the\n * LICENSE file in the root directory of this source tree.\n */\n\n'use strict';\n\nif (process.env.NODE_ENV !== \"production\") {\n (function() {\n\n 'use strict';\n\n/* global __REACT_DEVTOOLS_GLOBAL_HOOK__ */\nif (\n typeof __REACT_DEVTOOLS_GLOBAL_HOOK__ !== 'undefined' &&\n typeof __REACT_DEVTOOLS_GLOBAL_HOOK__.registerInternalModuleStart ===\n 'function'\n) {\n __REACT_DEVTOOLS_GLOBAL_HOOK__.registerInternalModuleStart(new Error());\n}\n var React = require('react');\nvar shim = require('use-sync-external-store/shim');\n\n/**\n * inlined Object.is polyfill to avoid requiring consumers ship their own\n * https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/Object/is\n */\nfunction is(x, y) {\n return x === y && (x !== 0 || 1 / x === 1 / y) || x !== x && y !== y // eslint-disable-line no-self-compare\n ;\n}\n\nvar objectIs = typeof Object.is === 'function' ? Object.is : is;\n\nvar useSyncExternalStore = shim.useSyncExternalStore;\n\n// for CommonJS interop.\n\nvar useRef = React.useRef,\n useEffect = React.useEffect,\n useMemo = React.useMemo,\n useDebugValue = React.useDebugValue; // Same as useSyncExternalStore, but supports selector and isEqual arguments.\n\nfunction useSyncExternalStoreWithSelector(subscribe, getSnapshot, getServerSnapshot, selector, isEqual) {\n // Use this to track the rendered snapshot.\n var instRef = useRef(null);\n var inst;\n\n if (instRef.current === null) {\n inst = {\n hasValue: false,\n value: null\n };\n instRef.current = inst;\n } else {\n inst = instRef.current;\n }\n\n var _useMemo = useMemo(function () {\n // Track the memoized state using closure variables that are local to this\n // memoized instance of a getSnapshot function. Intentionally not using a\n // useRef hook, because that state would be shared across all concurrent\n // copies of the hook/component.\n var hasMemo = false;\n var memoizedSnapshot;\n var memoizedSelection;\n\n var memoizedSelector = function (nextSnapshot) {\n if (!hasMemo) {\n // The first time the hook is called, there is no memoized result.\n hasMemo = true;\n memoizedSnapshot = nextSnapshot;\n\n var _nextSelection = selector(nextSnapshot);\n\n if (isEqual !== undefined) {\n // Even if the selector has changed, the currently rendered selection\n // may be equal to the new selection. We should attempt to reuse the\n // current value if possible, to preserve downstream memoizations.\n if (inst.hasValue) {\n var currentSelection = inst.value;\n\n if (isEqual(currentSelection, _nextSelection)) {\n memoizedSelection = currentSelection;\n return currentSelection;\n }\n }\n }\n\n memoizedSelection = _nextSelection;\n return _nextSelection;\n } // We may be able to reuse the previous invocation's result.\n\n\n // We may be able to reuse the previous invocation's result.\n var prevSnapshot = memoizedSnapshot;\n var prevSelection = memoizedSelection;\n\n if (objectIs(prevSnapshot, nextSnapshot)) {\n // The snapshot is the same as last time. Reuse the previous selection.\n return prevSelection;\n } // The snapshot has changed, so we need to compute a new selection.\n\n\n // The snapshot has changed, so we need to compute a new selection.\n var nextSelection = selector(nextSnapshot); // If a custom isEqual function is provided, use that to check if the data\n // has changed. If it hasn't, return the previous selection. That signals\n // to React that the selections are conceptually equal, and we can bail\n // out of rendering.\n\n // If a custom isEqual function is provided, use that to check if the data\n // has changed. If it hasn't, return the previous selection. That signals\n // to React that the selections are conceptually equal, and we can bail\n // out of rendering.\n if (isEqual !== undefined && isEqual(prevSelection, nextSelection)) {\n return prevSelection;\n }\n\n memoizedSnapshot = nextSnapshot;\n memoizedSelection = nextSelection;\n return nextSelection;\n }; // Assigning this to a constant so that Flow knows it can't change.\n\n\n // Assigning this to a constant so that Flow knows it can't change.\n var maybeGetServerSnapshot = getServerSnapshot === undefined ? null : getServerSnapshot;\n\n var getSnapshotWithSelector = function () {\n return memoizedSelector(getSnapshot());\n };\n\n var getServerSnapshotWithSelector = maybeGetServerSnapshot === null ? undefined : function () {\n return memoizedSelector(maybeGetServerSnapshot());\n };\n return [getSnapshotWithSelector, getServerSnapshotWithSelector];\n }, [getSnapshot, getServerSnapshot, selector, isEqual]),\n getSelection = _useMemo[0],\n getServerSelection = _useMemo[1];\n\n var value = useSyncExternalStore(subscribe, getSelection, getServerSelection);\n useEffect(function () {\n inst.hasValue = true;\n inst.value = value;\n }, [value]);\n useDebugValue(value);\n return value;\n}\n\nexports.useSyncExternalStoreWithSelector = useSyncExternalStoreWithSelector;\n /* global __REACT_DEVTOOLS_GLOBAL_HOOK__ */\nif (\n typeof __REACT_DEVTOOLS_GLOBAL_HOOK__ !== 'undefined' &&\n typeof __REACT_DEVTOOLS_GLOBAL_HOOK__.registerInternalModuleStop ===\n 'function'\n) {\n __REACT_DEVTOOLS_GLOBAL_HOOK__.registerInternalModuleStop(new Error());\n}\n \n })();\n}\n","'use strict';\n\nif (process.env.NODE_ENV === 'production') {\n module.exports = require('../cjs/use-sync-external-store-shim/with-selector.production.min.js');\n} else {\n module.exports = require('../cjs/use-sync-external-store-shim/with-selector.development.js');\n}\n","import { useCallback, useDebugValue, useLayoutEffect, useMemo, useRef } from 'react';\nimport { useSyncExternalStoreWithSelector } from 'use-sync-external-store/shim/with-selector.js';\nimport type { SubscribeOptions } from '@core/commonTypes';\nimport type { Store } from '@core/store';\nimport { hash } from '@lib/hash';\nimport { makeSelector } from '@lib/makeSelector';\nimport { trackingProxy } from '@lib/trackingProxy';\n\nexport type UseStoreOptions = Omit<SubscribeOptions, 'runNow' | 'passive'>;\n\nexport function useStore<T>(store: Store<T>, options?: UseStoreOptions): T {\n const lastEqualsRef = useRef<(newValue: T) => boolean>();\n\n const { rootStore, selector } = useMemo(() => {\n const rootStore = store.derivedFrom?.store ?? store;\n let selector = (x: any) => x;\n\n if (store.derivedFrom) {\n selector = (value: any) => {\n for (const s of store.derivedFrom!.selectors) {\n value = makeSelector(s)(value);\n }\n return value;\n };\n }\n\n return { rootStore, selector };\n }, [store]);\n\n const subOptions = { ...options, runNow: false, equals: undefined, passive: false };\n const subscribe = useCallback(\n (listener: () => void) => {\n return rootStore.subscribe(listener, subOptions);\n },\n [rootStore, hash(subOptions)],\n );\n\n const value = useSyncExternalStoreWithSelector<unknown, T>(\n //\n subscribe,\n rootStore.get,\n undefined,\n selector,\n options?.equals ?? ((_v, newValue) => lastEqualsRef.current?.(newValue) ?? false),\n );\n const [proxiedValue, equals, revoke] = trackingProxy(value);\n\n useLayoutEffect(() => {\n lastEqualsRef.current = equals;\n revoke?.();\n });\n\n useDebugValue(value);\n return proxiedValue;\n}\n","import type { UseStoreOptions } from './useStore';\nimport { useStore } from './useStore';\nimport type { Store } from '@core/store';\n\nexport function useProp<T>(\n store: Store<T>,\n options?: UseStoreOptions,\n): [value: T, setValue: typeof store.set] {\n const value = useStore(store, options);\n\n return [value, store.set];\n}\n","import { useProp } from './useProp';\nimport { type UseStoreOptions, useStore } from './useStore';\nimport type { Store } from '@core/store';\n\nexport const reactMethods = {\n useStore<T>(this: Store<T>, options?: UseStoreOptions) {\n return useStore(this, options);\n },\n\n useProp<T>(this: Store<T>, options?: UseStoreOptions) {\n return useProp(this, options);\n },\n};\n","import { useEffect, useMemo } from 'react';\nimport type { UseStoreOptions } from './useStore';\nimport { useStore } from './useStore';\nimport type { Cache } from '@core';\nimport type { CacheState } from '@lib/cacheState';\nimport { makeSelector } from '@lib/makeSelector';\n\nexport type UseCacheArray<T> = [\n value: T | undefined,\n error: unknown | undefined,\n isUpdating: boolean,\n isStale: boolean,\n];\n\nexport type UseCacheValue<T> = UseCacheArray<T> & CacheState<T>;\n\nexport interface UseCacheOptions extends UseStoreOptions {\n passive?: boolean;\n updateOnMount?: boolean;\n}\n\nexport function useCache<T>(\n cache: Cache<T>,\n { passive, updateOnMount, ...options }: UseCacheOptions = {},\n): UseCacheValue<T> {\n const mappedState = useMemo(() => {\n const rootCache: Cache<any> = cache.derivedFromCache?.cache ?? cache;\n let selector = (x: any) => x;\n\n if (cache.derivedFromCache) {\n selector = (value: any) => {\n for (const s of cache.derivedFromCache!.selectors) {\n value = makeSelector(s)(value);\n }\n return value;\n };\n }\n\n return rootCache.state.map((state) => {\n const value = state.status === 'value' ? selector(state.value) : undefined;\n\n return Object.assign<UseCacheArray<T>, CacheState<T>>(\n [value, state.error, state.isUpdating, state.isStale],\n { ...state, value },\n );\n });\n }, [cache]);\n\n useEffect(() => (!passive ? cache.subscribe(() => undefined) : undefined), [cache, passive]);\n\n useEffect(() => {\n if (updateOnMount) {\n cache.invalidate();\n }\n }, []);\n\n return useStore(mappedState, options);\n}\n","import type { Context, ReactNode } from 'react';\nimport { createContext, useContext, useMemo } from 'react';\nimport { useProp } from './useProp';\nimport { useStore, type UseStoreOptions } from './useStore';\nimport { createStore } from '@core/store';\nimport type { Store } from '@core/store';\nimport type { Scope } from '@core';\n\nexport type ScopeProps<T> = { scope: Scope<T>; store?: Store<T>; children?: ReactNode };\n\nconst contextMap = new WeakMap<Scope<any>, Context<Store<any>>>();\n\nfunction getScopeContext<T>(scope: Scope<T>): Context<Store<T>> {\n let context = contextMap.get(scope);\n\n if (!context) {\n context = createContext<Store<T>>(createStore(scope.defaultValue));\n contextMap.set(scope, context);\n }\n\n return context;\n}\n\nexport function ScopeProvider<T>({ scope, store: inputStore, children }: ScopeProps<T>) {\n const context = getScopeContext(scope);\n const currentStore = useMemo(\n () => inputStore ?? createStore(scope.defaultValue),\n [scope, inputStore],\n );\n\n return <context.Provider value={currentStore}>{children}</context.Provider>;\n}\n\nexport function useScope<T>(scope: Scope<T>): Store<T> {\n const context = getScopeContext(scope);\n return useContext(context);\n}\n\nexport function useScopeStore<T>(scope: Scope<T>, options?: UseStoreOptions): T {\n const store = useScope(scope);\n return useStore(store, options);\n}\n\nexport function useScopeProp<T>(scope: Scope<T>, options?: UseStoreOptions) {\n const store = useScope(scope);\n return useProp(store, options);\n}\n"],"names":["error","shim","module","require$$0","require$$1","a","c","d","b","e","store","useRef","useMemo","rootStore","selector","value","makeSelector","useCallback","hash","useSyncExternalStoreWithSelector","trackingProxy","useLayoutEffect","useDebugValue","useEffect","createContext","createStore","useContext"],"mappings":";;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;AASa,MAAI,IAAE;AAAiB,WAAS,EAAE,GAAE,GAAE;AAAC,WAAO,MAAI,MAAI,MAAI,KAAG,IAAE,MAAI,IAAE,MAAI,MAAI,KAAG,MAAI;AAAA,EAAC;AAAC,MAAI,IAAE,eAAa,OAAO,OAAO,KAAG,OAAO,KAAG,GAAE,IAAE,EAAE,UAAS,IAAE,EAAE,WAAU,IAAE,EAAE,iBAAgB,IAAE,EAAE;AAAc,WAAS,EAAE,GAAE,GAAE;AAAC,QAAI,IAAE,EAAC,GAAG,IAAE,EAAE,EAAC,MAAK,EAAC,OAAM,GAAE,aAAY,EAAC,EAAC,CAAC,GAAE,IAAE,EAAE,CAAC,EAAE,MAAK,IAAE,EAAE,CAAC;AAAE,MAAE,WAAU;AAAC,QAAE,QAAM;AAAE,QAAE,cAAY;AAAE,QAAE,CAAC,KAAG,EAAE,EAAC,MAAK,EAAC,CAAC;AAAA,IAAC,GAAE,CAAC,GAAE,GAAE,CAAC,CAAC;AAAE,MAAE,WAAU;AAAC,QAAE,CAAC,KAAG,EAAE,EAAC,MAAK,EAAC,CAAC;AAAE,aAAO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cAAiB,EAAE,OAAO,OAAO,YAAY,YAA2B;AAChF,QAAA,UAAU,gBAAgB,KAAK;AACrC,QAAM,eAAeb,WAAA;AAAA,IACnB,MAAM,cAAca,MAAAA,YAAY,MAAM,YAAY;AAAA,IAClD,CAAC,OAAO,UAAU;AAAA,EAAA;AAGpB,wCAAQ,QAAQ,UAAR,EAAiB,OAAO,cAAe,SAAS,CAAA;AAC1D;AAEO,SAAS,SAAY,OAA2B;AAC/C,QAAA,UAAU,gBAAgB,KAAK;AACrC,SAAOC,WAAAA,WAAW,OAAO;AAC3B;AAEgB,SAAA,cAAiB,OAAiB,SAA8B;AACxE,QAAAhB,SAAQ,SAAS,KAAK;AACrB,SAAA,SAASA,QAAO,OAAO;AAChC;AAEgB,SAAA,aAAgB,OAAiB,SAA2B;AACpE,QAAAA,SAAQ,SAAS,KAAK;AACrB,SAAA,QAAQA,QAAO,OAAO;AAC/B;;;;;;;;;","x_google_ignoreList":[0,1,2,3,4,5]}
@@ -110,6 +110,7 @@ const internalEqual = (comp) => (a, b) => {
110
110
  }
111
111
  return false;
112
112
  };
113
+ const unwrapProxySymbol = /* @__PURE__ */ Symbol("unwrapProxy");
113
114
  function isPlainObject(value) {
114
115
  return typeof value === "object" && value !== null && Object.getPrototypeOf(value) === Object.prototype;
115
116
  }
@@ -117,15 +118,21 @@ function trackingProxy(value, equals = deepEqual) {
117
118
  if (!isPlainObject(value) && !Array.isArray(value)) {
118
119
  return [value, (other) => equals(value, other)];
119
120
  }
121
+ value = value[unwrapProxySymbol] ?? value;
120
122
  const deps = new Array();
123
+ const revokations = new Array();
124
+ let revoked = false;
121
125
  function trackComplexProp(function_, ...args) {
122
- const [proxiedValue, equals2] = trackingProxy(function_(value, ...args));
126
+ const [proxiedValue, equals2, revoke] = trackingProxy(function_(value, ...args));
123
127
  deps.push((otherValue) => {
124
128
  if (!isPlainObject(otherValue) && !Array.isArray(otherValue)) {
125
129
  return false;
126
130
  }
127
131
  return equals2(function_(otherValue, ...args));
128
132
  });
133
+ if (revoke) {
134
+ revokations.push(revoke);
135
+ }
129
136
  return proxiedValue;
130
137
  }
131
138
  function trackSimpleProp(function_, ...args) {
@@ -137,6 +144,12 @@ function trackingProxy(value, equals = deepEqual) {
137
144
  }
138
145
  const proxy = new Proxy(value, {
139
146
  get(target, p, receiver) {
147
+ if (p === unwrapProxySymbol) {
148
+ return value;
149
+ }
150
+ if (revoked) {
151
+ return target[p];
152
+ }
140
153
  const { writable, configurable } = Object.getOwnPropertyDescriptor(target, p) ?? {};
141
154
  if (writable === false && configurable === false) {
142
155
  return target[p];
@@ -163,7 +176,14 @@ function trackingProxy(value, equals = deepEqual) {
163
176
  return trackSimpleProp(Reflect.isExtensible);
164
177
  }
165
178
  });
166
- return [proxy, (other) => !!other && deps.every((equals2) => equals2(other))];
179
+ return [
180
+ proxy,
181
+ (other) => !!other && deps.every((equals2) => equals2(other)),
182
+ () => {
183
+ revoked = true;
184
+ revokations.forEach((revoke) => revoke());
185
+ }
186
+ ];
167
187
  }
168
188
  class CalculationHelper {
169
189
  constructor(options) {