mirror of
https://github.com/CamHenlin/MessagesForMacintosh.git
synced 2024-11-26 20:50:30 +00:00
1 line
8.8 KiB
Plaintext
1 line
8.8 KiB
Plaintext
{"version":3,"file":"bundle.esm.js","sources":["../src/index.ts"],"sourcesContent":["/* necessary for backward compat */\nexport * from 'apollo-client';\nexport * from 'apollo-link';\nexport * from 'apollo-cache-inmemory';\n\nimport { Operation, ApolloLink, Observable } from 'apollo-link';\nimport { HttpLink, UriFunction } from 'apollo-link-http';\nimport { onError, ErrorLink } from 'apollo-link-error';\nimport { ApolloCache } from 'apollo-cache';\nimport { InMemoryCache, CacheResolverMap } from 'apollo-cache-inmemory';\nimport gql from 'graphql-tag';\nimport ApolloClient, {\n Resolvers,\n LocalStateFragmentMatcher,\n} from 'apollo-client';\nimport { DocumentNode } from 'graphql';\nimport { invariant } from 'ts-invariant';\n\nexport { gql, HttpLink };\n\ntype ClientStateConfig = {\n cache?: ApolloCache<any>;\n defaults?: Record<string, any>;\n resolvers?: Resolvers | Resolvers[];\n typeDefs?: string | string[] | DocumentNode | DocumentNode[];\n fragmentMatcher?: LocalStateFragmentMatcher;\n};\n\nexport interface PresetConfig {\n request?: (operation: Operation) => Promise<void> | void;\n uri?: string | UriFunction;\n credentials?: string;\n headers?: any;\n fetch?: WindowOrWorkerGlobalScope['fetch'];\n fetchOptions?: HttpLink.Options;\n clientState?: ClientStateConfig;\n onError?: ErrorLink.ErrorHandler;\n cacheRedirects?: CacheResolverMap;\n cache?: ApolloCache<any>;\n name?: string;\n version?: string;\n resolvers?: Resolvers | Resolvers[];\n typeDefs?: string | string[] | DocumentNode | DocumentNode[];\n fragmentMatcher?: LocalStateFragmentMatcher;\n assumeImmutableResults?: boolean;\n}\n\n// Yes, these are the exact same as the `PresetConfig` interface. We're\n// defining these again so they can be used to verify that valid config\n// options are being used in the `DefaultClient` constructor, for clients\n// that aren't using Typescript. This duplication is unfortunate, and at\n// some point can likely be adjusted so these items are inferred from\n// the `PresetConfig` interface using a Typescript transform at compilation\n// time. Unfortunately, TS transforms with rollup don't appear to be quite\n// working properly, so this will have to be re-visited at some point.\n// For now, when updating the properties of the `PresetConfig` interface,\n// please also update this constant.\nconst PRESET_CONFIG_KEYS = [\n 'request',\n 'uri',\n 'credentials',\n 'headers',\n 'fetch',\n 'fetchOptions',\n 'clientState',\n 'onError',\n 'cacheRedirects',\n 'cache',\n 'name',\n 'version',\n 'resolvers',\n 'typeDefs',\n 'fragmentMatcher',\n];\n\nexport default class DefaultClient<TCache> extends ApolloClient<TCache> {\n constructor(config: PresetConfig = {}) {\n if (config) {\n const diff = Object.keys(config).filter(\n key => PRESET_CONFIG_KEYS.indexOf(key) === -1,\n );\n\n if (diff.length > 0) {\n invariant.warn(\n 'ApolloBoost was initialized with unsupported options: ' +\n `${diff.join(' ')}`,\n );\n }\n }\n\n const {\n request,\n uri,\n credentials,\n headers,\n fetch,\n fetchOptions,\n clientState,\n cacheRedirects,\n onError: errorCallback,\n name,\n version,\n resolvers,\n typeDefs,\n fragmentMatcher,\n } = config;\n\n let { cache } = config;\n\n invariant(\n !cache || !cacheRedirects,\n 'Incompatible cache configuration. When not providing `cache`, ' +\n 'configure the provided instance with `cacheRedirects` instead.',\n );\n\n if (!cache) {\n cache = cacheRedirects\n ? new InMemoryCache({ cacheRedirects })\n : new InMemoryCache();\n }\n\n const errorLink = errorCallback\n ? onError(errorCallback)\n : onError(({ graphQLErrors, networkError }) => {\n if (graphQLErrors) {\n graphQLErrors.forEach(({ message, locations, path }) =>\n // tslint:disable-next-line\n invariant.warn(\n `[GraphQL error]: Message: ${message}, Location: ` +\n `${locations}, Path: ${path}`,\n ),\n );\n }\n if (networkError) {\n // tslint:disable-next-line\n invariant.warn(`[Network error]: ${networkError}`);\n }\n });\n\n const requestHandler = request\n ? new ApolloLink(\n (operation, forward) =>\n new Observable(observer => {\n let handle: any;\n Promise.resolve(operation)\n .then(oper => request(oper))\n .then(() => {\n handle = forward(operation).subscribe({\n next: observer.next.bind(observer),\n error: observer.error.bind(observer),\n complete: observer.complete.bind(observer),\n });\n })\n .catch(observer.error.bind(observer));\n\n return () => {\n if (handle) {\n handle.unsubscribe();\n }\n };\n }),\n )\n : false;\n\n const httpLink = new HttpLink({\n uri: uri || '/graphql',\n fetch,\n fetchOptions: fetchOptions || {},\n credentials: credentials || 'same-origin',\n headers: headers || {},\n });\n\n const link = ApolloLink.from([errorLink, requestHandler, httpLink].filter(\n x => !!x,\n ) as ApolloLink[]);\n\n let activeResolvers = resolvers;\n let activeTypeDefs = typeDefs;\n let activeFragmentMatcher = fragmentMatcher;\n if (clientState) {\n if (clientState.defaults) {\n cache.writeData({\n data: clientState.defaults,\n });\n }\n activeResolvers = clientState.resolvers;\n activeTypeDefs = clientState.typeDefs;\n activeFragmentMatcher = clientState.fragmentMatcher;\n }\n\n // super hacky, we will fix the types eventually\n super({\n cache,\n link,\n name,\n version,\n resolvers: activeResolvers,\n typeDefs: activeTypeDefs,\n fragmentMatcher: activeFragmentMatcher,\n } as any);\n }\n}\n"],"names":["ApolloClient"],"mappings":";;;;;;;;;;;;;AAyDA,IAAM,kBAAkB,GAAG;IACzB,SAAS;IACT,KAAK;IACL,aAAa;IACb,SAAS;IACT,OAAO;IACP,cAAc;IACd,aAAa;IACb,SAAS;IACT,gBAAgB;IAChB,OAAO;IACP,MAAM;IACN,SAAS;IACT,WAAW;IACX,UAAU;IACV,iBAAiB;CAClB,CAAC;AAEF;IAAmD,iCAAoB;IACrE,uBAAY,MAAyB;QAAzB,uBAAA,EAAA,WAAyB;QAArC,iBA4HC;QA3HC,IAAI,MAAM,EAAE;YACV,IAAM,IAAI,GAAG,MAAM,CAAC,IAAI,CAAC,MAAM,CAAC,CAAC,MAAM,CACrC,UAAA,GAAG,IAAI,OAAA,kBAAkB,CAAC,OAAO,CAAC,GAAG,CAAC,KAAK,CAAC,CAAC,GAAA,CAC9C,CAAC;YAEF,IAAI,IAAI,CAAC,MAAM,GAAG,CAAC,EAAE;gBACnB;qBAEI,KAAG,IAAI,CAAC,IA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