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I,OAAO,OAAO,CAAC,UAAU,KAAK,QAAQ,EAAE,CAAC;gBAC3D,IAAI,CAAC,yBAAyB,GAAG,IAAI,CAAC;YACxC,CAAC;YAED,IACE,OAAO,CAAC,cAAc;gBACtB,OAAO,CAAC,cAAc,CAAC,IAAI,CAAC,IAAI,EAAE,CAAC,EAAE,IAAI,EAAE,QAAQ,CAAC,KAAK,KAAK,EAC9D,CAAC;gBACD,gEAAgE;gBAChE,6CAA6C;gBAC7C,OAAO;YACT,CAAC;QACH,CAAC;QAED,IAAI,CAAC,QAAQ,IAAI,CAAC,KAAK,CAAC,QAAQ,CAAC,MAAM,EAAE,IAAI,CAAC,MAAM,CAAC,EAAE,CAAC;YACtD,CAAC,CAAC,QAAQ,CAAC,CAAC,CAAC,CAAC,QAAQ,GAAG,IAAI,CAAC,EAAE,QAAQ,CAAC,CAAC;QAC5C,CAAC;IACH,CAAC;IAUH,oBAAC;AAAD,CAAC,AA3iBD,CAAmC,WAAW,GA2iB7C;;AAED,IAAI,OAAO,EAAE,CAAC;IACZ,aAAa,CAAC,SAAS,CAAC,kBAAkB,GAAG,+BAA+B,CAAC;AAC/E,CAAC","sourcesContent":["import { invariant } from \"../../utilities/globals/index.js\";\n\n// Make builtins like Map and Set safe to use with non-extensible objects.\nimport \"./fixPolyfills.js\";\n\nimport type { DocumentNode } from \"graphql\";\nimport type { OptimisticWrapperFunction } from \"optimism\";\nimport { wrap } from \"optimism\";\nimport { equal } from \"@wry/equality\";\n\nimport { ApolloCache } from \"../core/cache.js\";\nimport type { Cache } from \"../core/types/Cache.js\";\nimport { MissingFieldError } from \"../core/types/common.js\";\nimport type { StoreObject, Reference } from \"../../utilities/index.js\";\nimport {\n addTypenameToDocument,\n isReference,\n DocumentTransform,\n canonicalStringify,\n print,\n cacheSizes,\n defaultCacheSizes,\n} from \"../../utilities/index.js\";\nimport type { InMemoryCacheConfig, NormalizedCacheObject } from \"./types.js\";\nimport { StoreReader } from \"./readFromStore.js\";\nimport { StoreWriter } from \"./writeToStore.js\";\nimport { EntityStore, supportsResultCaching } from \"./entityStore.js\";\nimport { makeVar, forgetCache, recallCache } from \"./reactiveVars.js\";\nimport { Policies } from \"./policies.js\";\nimport { hasOwn, normalizeConfig, shouldCanonizeResults } from \"./helpers.js\";\nimport type { OperationVariables } from \"../../core/index.js\";\nimport { getInMemoryCacheMemoryInternals } from \"../../utilities/caching/getMemoryInternals.js\";\n\ntype BroadcastOptions = Pick<\n Cache.BatchOptions<InMemoryCache>,\n \"optimistic\" | \"onWatchUpdated\"\n>;\n\nexport class InMemoryCache extends ApolloCache<NormalizedCacheObject> {\n private data!: EntityStore;\n private optimisticData!: EntityStore;\n\n protected config: InMemoryCacheConfig;\n private watches = new Set<Cache.WatchOptions>();\n private addTypename: boolean;\n\n private storeReader!: StoreReader;\n private storeWriter!: StoreWriter;\n private addTypenameTransform = new DocumentTransform(addTypenameToDocument);\n\n private maybeBroadcastWatch!: OptimisticWrapperFunction<\n [Cache.WatchOptions, BroadcastOptions?],\n any,\n [Cache.WatchOptions]\n >;\n\n // Override the default value, since InMemoryCache result objects are frozen\n // in development and expected to remain logically immutable in production.\n public readonly assumeImmutableResults = true;\n\n // Dynamically imported code can augment existing typePolicies or\n // possibleTypes by calling cache.policies.addTypePolicies or\n // cache.policies.addPossibletypes.\n public readonly policies: Policies;\n\n public readonly makeVar = makeVar;\n\n constructor(config: InMemoryCacheConfig = {}) {\n super();\n this.config = normalizeConfig(config);\n this.addTypename = !!this.config.addTypename;\n\n this.policies = new Policies({\n cache: this,\n dataIdFromObject: this.config.dataIdFromObject,\n possibleTypes: this.config.possibleTypes,\n typePolicies: this.config.typePolicies,\n });\n\n this.init();\n }\n\n private init() {\n // Passing { resultCaching: false } in the InMemoryCache constructor options\n // will completely disable dependency tracking, which will improve memory\n // usage but worsen the performance of repeated reads.\n const rootStore = (this.data = new EntityStore.Root({\n policies: this.policies,\n resultCaching: this.config.resultCaching,\n }));\n\n // When no optimistic writes are currently active, cache.optimisticData ===\n // cache.data, so there are no additional layers on top of the actual data.\n // When an optimistic update happens, this.optimisticData will become a\n // linked list of EntityStore Layer objects that terminates with the\n // original this.data cache object.\n this.optimisticData = rootStore.stump;\n\n this.resetResultCache();\n }\n\n private resetResultCache(resetResultIdentities?: boolean) {\n const previousReader = this.storeReader;\n const { fragments } = this.config;\n\n // The StoreWriter is mostly stateless and so doesn't really need to be\n // reset, but it does need to have its writer.storeReader reference updated,\n // so it's simpler to update this.storeWriter as well.\n this.storeWriter = new StoreWriter(\n this,\n (this.storeReader = new StoreReader({\n cache: this,\n addTypename: this.addTypename,\n resultCacheMaxSize: this.config.resultCacheMaxSize,\n canonizeResults: shouldCanonizeResults(this.config),\n canon:\n resetResultIdentities ? void 0 : (\n previousReader && previousReader.canon\n ),\n fragments,\n })),\n fragments\n );\n\n this.maybeBroadcastWatch = wrap(\n (c: Cache.WatchOptions, options?: BroadcastOptions) => {\n return this.broadcastWatch(c, options);\n },\n {\n max:\n this.config.resultCacheMaxSize ||\n cacheSizes[\"inMemoryCache.maybeBroadcastWatch\"] ||\n defaultCacheSizes[\"inMemoryCache.maybeBroadcastWatch\"],\n makeCacheKey: (c: Cache.WatchOptions) => {\n // Return a cache key (thus enabling result caching) only if we're\n // currently using a data store that can track cache dependencies.\n const store = c.optimistic ? this.optimisticData : this.data;\n if (supportsResultCaching(store)) {\n const { optimistic, id, variables } = c;\n return store.makeCacheKey(\n c.query,\n // Different watches can have the same query, optimistic\n // status, rootId, and variables, but if their callbacks are\n // different, the (identical) result needs to be delivered to\n // each distinct callback. The easiest way to achieve that\n // separation is to include c.callback in the cache key for\n // maybeBroadcastWatch calls. See issue #5733.\n c.callback,\n canonicalStringify({ optimistic, id, variables })\n );\n }\n },\n }\n );\n\n // Since we have thrown away all the cached functions that depend on the\n // CacheGroup dependencies maintained by EntityStore, we should also reset\n // all CacheGroup dependency information.\n new Set([this.data.group, this.optimisticData.group]).forEach((group) =>\n group.resetCaching()\n );\n }\n\n public restore(data: NormalizedCacheObject): this {\n this.init();\n // Since calling this.init() discards/replaces the entire StoreReader, along\n // with the result caches it maintains, this.data.replace(data) won't have\n // to bother deleting the old data.\n if (data) this.data.replace(data);\n return this;\n }\n\n public extract(optimistic: boolean = false): NormalizedCacheObject {\n return (optimistic ? this.optimisticData : this.data).extract();\n }\n\n public read<T>(options: Cache.ReadOptions): T | null {\n const {\n // Since read returns data or null, without any additional metadata\n // about whether/where there might have been missing fields, the\n // default behavior cannot be returnPartialData = true (like it is\n // for the diff method), since defaulting to true would violate the\n // integrity of the T in the return type. However, partial data may\n // be useful in some cases, so returnPartialData:true may be\n // specified explicitly.\n returnPartialData = false,\n } = options;\n try {\n return (\n this.storeReader.diffQueryAgainstStore<T>({\n ...options,\n store: options.optimistic ? this.optimisticData : this.data,\n config: this.config,\n returnPartialData,\n }).result || null\n );\n } catch (e) {\n if (e instanceof MissingFieldError) {\n // Swallow MissingFieldError and return null, so callers do not need to\n // worry about catching \"normal\" exceptions resulting from incomplete\n // cache data. Unexpected errors will be re-thrown. If you need more\n // information about which fields were missing, use cache.diff instead,\n // and examine diffResult.missing.\n return null;\n }\n throw e;\n }\n }\n\n public write(options: Cache.WriteOptions): Reference | undefined {\n try {\n ++this.txCount;\n return this.storeWriter.writeToStore(this.data, options);\n } finally {\n if (!--this.txCount && options.broadcast !== false) {\n this.broadcastWatches();\n }\n }\n }\n\n public modify<Entity extends Record<string, any> = Record<string, any>>(\n options: Cache.ModifyOptions<Entity>\n ): boolean {\n if (hasOwn.call(options, \"id\") && !options.id) {\n // To my knowledge, TypeScript does not currently provide a way to\n // enforce that an optional property?:type must *not* be undefined\n // when present. That ability would be useful here, because we want\n // options.id to default to ROOT_QUERY only when no options.id was\n // provided. If the caller attempts to pass options.id with a\n // falsy/undefined value (perhaps because cache.identify failed), we\n // should not assume the goal was to modify the ROOT_QUERY object.\n // We could throw, but it seems natural to return false to indicate\n // that nothing was modified.\n return false;\n }\n const store =\n (\n options.optimistic // Defaults to false.\n ) ?\n this.optimisticData\n : this.data;\n try {\n ++this.txCount;\n return store.modify(options.id || \"ROOT_QUERY\", options.fields);\n } finally {\n if (!--this.txCount && options.broadcast !== false) {\n this.broadcastWatches();\n }\n }\n }\n\n public diff<TData, TVariables extends OperationVariables = any>(\n options: Cache.DiffOptions<TData, TVariables>\n ): Cache.DiffResult<TData> {\n return this.storeReader.diffQueryAgainstStore({\n ...options,\n store: options.optimistic ? this.optimisticData : this.data,\n rootId: options.id || \"ROOT_QUERY\",\n config: this.config,\n });\n }\n\n public watch<TData = any, TVariables = any>(\n watch: Cache.WatchOptions<TData, TVariables>\n ): () => void {\n if (!this.watches.size) {\n // In case we previously called forgetCache(this) because\n // this.watches became empty (see below), reattach this cache to any\n // reactive variables on which it previously depended. It might seem\n // paradoxical that we're able to recall something we supposedly\n // forgot, but the point of calling forgetCache(this) is to silence\n // useless broadcasts while this.watches is empty, and to allow the\n // cache to be garbage collected. If, however, we manage to call\n // recallCache(this) here, this cache object must not have been\n // garbage collected yet, and should resume receiving updates from\n // reactive variables, now that it has a watcher to notify.\n recallCache(this);\n }\n this.watches.add(watch);\n if (watch.immediate) {\n this.maybeBroadcastWatch(watch);\n }\n return () => {\n // Once we remove the last watch from this.watches, cache.broadcastWatches\n // no longer does anything, so we preemptively tell the reactive variable\n // system to exclude this cache from future broadcasts.\n if (this.watches.delete(watch) && !this.watches.size) {\n forgetCache(this);\n }\n // Remove this watch from the LRU cache managed by the\n // maybeBroadcastWatch OptimisticWrapperFunction, to prevent memory\n // leaks involving the closure of watch.callback.\n this.maybeBroadcastWatch.forget(watch);\n };\n }\n\n public gc(options?: {\n // If true, also free non-essential result cache memory by bulk-releasing\n // this.{store{Reader,Writer},maybeBroadcastWatch}. Defaults to false.\n resetResultCache?: boolean;\n // If resetResultCache is true, this.storeReader.canon will be preserved by\n // default, but can also be discarded by passing resetResultIdentities:true.\n // Defaults to false.\n resetResultIdentities?: boolean;\n }) {\n canonicalStringify.reset();\n print.reset();\n this.addTypenameTransform.resetCache();\n this.config.fragments?.resetCaches();\n const ids = this.optimisticData.gc();\n if (options && !this.txCount) {\n if (options.resetResultCache) {\n this.resetResultCache(options.resetResultIdentities);\n } else if (options.resetResultIdentities) {\n this.storeReader.resetCanon();\n }\n }\n return ids;\n }\n\n // Call this method to ensure the given root ID remains in the cache after\n // garbage collection, along with its transitive child entities. Note that\n // the cache automatically retains all directly written entities. By default,\n // the retainment persists after optimistic updates are removed. Pass true\n // for the optimistic argument if you would prefer for the retainment to be\n // discarded when the top-most optimistic layer is removed. Returns the\n // resulting (non-negative) retainment count.\n public retain(rootId: string, optimistic?: boolean): number {\n return (optimistic ? this.optimisticData : this.data).retain(rootId);\n }\n\n // Call this method to undo the effect of the retain method, above. Once the\n // retainment count falls to zero, the given ID will no longer be preserved\n // during garbage collection, though it may still be preserved by other safe\n // entities that refer to it. Returns the resulting (non-negative) retainment\n // count, in case that's useful.\n public release(rootId: string, optimistic?: boolean): number {\n return (optimistic ? this.optimisticData : this.data).release(rootId);\n }\n\n // Returns the canonical ID for a given StoreObject, obeying typePolicies\n // and keyFields (and dataIdFromObject, if you still use that). At minimum,\n // the object must contain a __typename and any primary key fields required\n // to identify entities of that type. If you pass a query result object, be\n // sure that none of the primary key fields have been renamed by aliasing.\n // If you pass a Reference object, its __ref ID string will be returned.\n public identify(object: StoreObject | Reference): string | undefined {\n if (isReference(object)) return object.__ref;\n try {\n return this.policies.identify(object)[0];\n } catch (e) {\n invariant.warn(e);\n }\n }\n\n public evict(options: Cache.EvictOptions): boolean {\n if (!options.id) {\n if (hasOwn.call(options, \"id\")) {\n // See comment in modify method about why we return false when\n // options.id exists but is falsy/undefined.\n return false;\n }\n options = { ...options, id: \"ROOT_QUERY\" };\n }\n try {\n // It's unlikely that the eviction will end up invoking any other\n // cache update operations while it's running, but {in,de}crementing\n // this.txCount still seems like a good idea, for uniformity with\n // the other update methods.\n ++this.txCount;\n // Pass this.data as a limit on the depth of the eviction, so evictions\n // during optimistic updates (when this.data is temporarily set equal to\n // this.optimisticData) do not escape their optimistic Layer.\n return this.optimisticData.evict(options, this.data);\n } finally {\n if (!--this.txCount && options.broadcast !== false) {\n this.broadcastWatches();\n }\n }\n }\n\n public reset(options?: Cache.ResetOptions): Promise<void> {\n this.init();\n\n canonicalStringify.reset();\n\n if (options && options.discardWatches) {\n // Similar to what happens in the unsubscribe function returned by\n // cache.watch, applied to all current watches.\n this.watches.forEach((watch) => this.maybeBroadcastWatch.forget(watch));\n this.watches.clear();\n forgetCache(this);\n } else {\n // Calling this.init() above unblocks all maybeBroadcastWatch caching, so\n // this.broadcastWatches() triggers a broadcast to every current watcher\n // (letting them know their data is now missing). This default behavior is\n // convenient because it means the watches do not have to be manually\n // reestablished after resetting the cache. To prevent this broadcast and\n // cancel all watches, pass true for options.discardWatches.\n this.broadcastWatches();\n }\n\n return Promise.resolve();\n }\n\n public removeOptimistic(idToRemove: string) {\n const newOptimisticData = this.optimisticData.removeLayer(idToRemove);\n if (newOptimisticData !== this.optimisticData) {\n this.optimisticData = newOptimisticData;\n this.broadcastWatches();\n }\n }\n\n private txCount = 0;\n\n public batch<TUpdateResult>(\n options: Cache.BatchOptions<InMemoryCache, TUpdateResult>\n ): TUpdateResult {\n const {\n update,\n optimistic = true,\n removeOptimistic,\n onWatchUpdated,\n } = options;\n\n let updateResult: TUpdateResult;\n const perform = (layer?: EntityStore): TUpdateResult => {\n const { data, optimisticData } = this;\n ++this.txCount;\n if (layer) {\n this.data = this.optimisticData = layer;\n }\n try {\n return (updateResult = update(this));\n } finally {\n --this.txCount;\n this.data = data;\n this.optimisticData = optimisticData;\n }\n };\n\n const alreadyDirty = new Set<Cache.WatchOptions>();\n\n if (onWatchUpdated && !this.txCount) {\n // If an options.onWatchUpdated callback is provided, we want to call it\n // with only the Cache.WatchOptions objects affected by options.update,\n // but there might be dirty watchers already waiting to be broadcast that\n // have nothing to do with the update. To prevent including those watchers\n // in the post-update broadcast, we perform this initial broadcast to\n // collect the dirty watchers, so we can re-dirty them later, after the\n // post-update broadcast, allowing them to receive their pending\n // broadcasts the next time broadcastWatches is called, just as they would\n // if we never called cache.batch.\n this.broadcastWatches({\n ...options,\n onWatchUpdated(watch) {\n alreadyDirty.add(watch);\n return false;\n },\n });\n }\n\n if (typeof optimistic === \"string\") {\n // Note that there can be multiple layers with the same optimistic ID.\n // When removeOptimistic(id) is called for that id, all matching layers\n // will be removed, and the remaining layers will be reapplied.\n this.optimisticData = this.optimisticData.addLayer(optimistic, perform);\n } else if (optimistic === false) {\n // Ensure both this.data and this.optimisticData refer to the root\n // (non-optimistic) layer of the cache during the update. Note that\n // this.data could be a Layer if we are currently executing an optimistic\n // update function, but otherwise will always be an EntityStore.Root\n // instance.\n perform(this.data);\n } else {\n // Otherwise, leave this.data and this.optimisticData unchanged and run\n // the update with broadcast batching.\n perform();\n }\n\n if (typeof removeOptimistic === \"string\") {\n this.optimisticData = this.optimisticData.removeLayer(removeOptimistic);\n }\n\n // Note: if this.txCount > 0, then alreadyDirty.size === 0, so this code\n // takes the else branch and calls this.broadcastWatches(options), which\n // does nothing when this.txCount > 0.\n if (onWatchUpdated && alreadyDirty.size) {\n this.broadcastWatches({\n ...options,\n onWatchUpdated(watch, diff) {\n const result = onWatchUpdated.call(this, watch, diff);\n if (result !== false) {\n // Since onWatchUpdated did not return false, this diff is\n // about to be broadcast to watch.callback, so we don't need\n // to re-dirty it with the other alreadyDirty watches below.\n alreadyDirty.delete(watch);\n }\n return result;\n },\n });\n // Silently re-dirty any watches that were already dirty before the update\n // was performed, and were not broadcast just now.\n if (alreadyDirty.size) {\n alreadyDirty.forEach((watch) => this.maybeBroadcastWatch.dirty(watch));\n }\n } else {\n // If alreadyDirty is empty or we don't have an onWatchUpdated\n // function, we don't need to go to the trouble of wrapping\n // options.onWatchUpdated.\n this.broadcastWatches(options);\n }\n\n return updateResult!;\n }\n\n public performTransaction(\n update: (cache: InMemoryCache) => any,\n optimisticId?: string | null\n ) {\n return this.batch({\n update,\n optimistic: optimisticId || optimisticId !== null,\n });\n }\n\n public transformDocument(document: DocumentNode): DocumentNode {\n return this.addTypenameToDocument(this.addFragmentsToDocument(document));\n }\n\n protected broadcastWatches(options?: BroadcastOptions) {\n if (!this.txCount) {\n this.watches.forEach((c) => this.maybeBroadcastWatch(c, options));\n }\n }\n\n private addFragmentsToDocument(document: DocumentNode) {\n const { fragments } = this.config;\n return fragments ? fragments.transform(document) : document;\n }\n\n private addTypenameToDocument(document: DocumentNode) {\n if (this.addTypename) {\n return this.addTypenameTransform.transformDocument(document);\n }\n return document;\n }\n\n // This method is wrapped by maybeBroadcastWatch, which is called by\n // broadcastWatches, so that we compute and broadcast results only when\n // the data that would be broadcast might have changed. It would be\n // simpler to check for changes after recomputing a result but before\n // broadcasting it, but this wrapping approach allows us to skip both\n // the recomputation and the broadcast, in most cases.\n private broadcastWatch(c: Cache.WatchOptions, options?: BroadcastOptions) {\n const { lastDiff } = c;\n\n // Both WatchOptions and DiffOptions extend ReadOptions, and DiffOptions\n // currently requires no additional properties, so we can use c (a\n // WatchOptions object) as DiffOptions, without having to allocate a new\n // object, and without having to enumerate the relevant properties (query,\n // variables, etc.) explicitly. There will be some additional properties\n // (lastDiff, callback, etc.), but cache.diff ignores them.\n const diff = this.diff<any>(c);\n\n if (options) {\n if (c.optimistic && typeof options.optimistic === \"string\") {\n diff.fromOptimisticTransaction = true;\n }\n\n if (\n options.onWatchUpdated &&\n options.onWatchUpdated.call(this, c, diff, lastDiff) === false\n ) {\n // Returning false from the onWatchUpdated callback will prevent\n // calling c.callback(diff) for this watcher.\n return;\n }\n }\n\n if (!lastDiff || !equal(lastDiff.result, diff.result)) {\n c.callback((c.lastDiff = diff), lastDiff);\n }\n }\n\n /**\n * @experimental\n * @internal\n * This is not a stable API - it is used in development builds to expose\n * information to the DevTools.\n * Use at your own risk!\n */\n public getMemoryInternals?: typeof getInMemoryCacheMemoryInternals;\n}\n\nif (__DEV__) {\n InMemoryCache.prototype.getMemoryInternals = getInMemoryCacheMemoryInternals;\n}\n"]} |