{"version":3,"sources":["../src/useRead.ts","../src/useCache.ts","../src/contexts/CacheContext.ts"],"sourcesContent":["import { useSyncExternalStore } from 'react'\nimport type { ResolvedCached } from './Cache'\nimport type { CacheKey, CacheOptions } from './types'\nimport { useCache } from './useCache'\n\n/**\n * @experimental This is experimental feature.\n */\nexport function useRead<TData, TCacheKey extends CacheKey>(\n  options: CacheOptions<TData, TCacheKey>\n): ResolvedCached<TData, TCacheKey>['state'] {\n  const cache = useCache()\n  return useSyncExternalStore<ResolvedCached<TData, TCacheKey>>(\n    cache.subscribe,\n    () => cache.suspend<TData, TCacheKey>(options),\n    () => cache.suspend<TData, TCacheKey>(options)\n  ).state\n}\n","import { useContext } from 'react'\nimport type { Cache } from './Cache'\nimport { CacheContext } from './contexts'\n\n/**\n * @experimental This is experimental feature.\n */\nexport function useCache(): Cache {\n  const cache = useContext(CacheContext)\n  if (cache == null) {\n    throw new Error('CacheProvider should be in parent')\n  }\n  return cache\n}\n","import { createContext } from 'react'\nimport type { Cache } from '../Cache'\n\nexport const CacheContext = createContext<Cache | null>(null)\n"],"mappings":";;;;;;;;;;;;;;;;;;;;;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA,IAAAA,gBAAqC;;;ACArC,IAAAC,gBAA2B;;;ACA3B,mBAA8B;AAGvB,IAAM,mBAAe,4BAA4B,IAAI;;;ADIrD,SAAS,WAAkB;AAChC,QAAM,YAAQ,0BAAW,YAAY;AACrC,MAAI,SAAS,MAAM;AACjB,UAAM,IAAI,MAAM,mCAAmC;AAAA,EACrD;AACA,SAAO;AACT;;;ADLO,SAAS,QACd,SAC2C;AAC3C,QAAM,QAAQ,SAAS;AACvB,aAAO;AAAA,IACL,MAAM;AAAA,IACN,MAAM,MAAM,QAA0B,OAAO;AAAA,IAC7C,MAAM,MAAM,QAA0B,OAAO;AAAA,EAC/C,EAAE;AACJ;","names":["import_react","import_react"]}