@apollo/client 0.0.0-pr-10521-20230206180228
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.
- package/LICENSE +22 -0
- package/README.md +45 -0
- package/apollo-client.cjs +7614 -0
- package/apollo-client.cjs.map +1 -0
- package/apollo-client.min.cjs +1 -0
- package/cache/cache.cjs +2425 -0
- package/cache/cache.cjs.map +1 -0
- package/cache/cache.cjs.native.js +2425 -0
- package/cache/core/cache.d.ts +32 -0
- package/cache/core/cache.d.ts.map +1 -0
- package/cache/core/cache.js +84 -0
- package/cache/core/cache.js.map +1 -0
- package/cache/core/types/Cache.d.ts +55 -0
- package/cache/core/types/Cache.d.ts.map +1 -0
- package/cache/core/types/Cache.js +4 -0
- package/cache/core/types/Cache.js.map +1 -0
- package/cache/core/types/DataProxy.d.ts +52 -0
- package/cache/core/types/DataProxy.d.ts.map +1 -0
- package/cache/core/types/DataProxy.js +2 -0
- package/cache/core/types/DataProxy.js.map +1 -0
- package/cache/core/types/common.d.ts +47 -0
- package/cache/core/types/common.d.ts.map +1 -0
- package/cache/core/types/common.js +26 -0
- package/cache/core/types/common.js.map +1 -0
- package/cache/index.d.ts +15 -0
- package/cache/index.d.ts.map +1 -0
- package/cache/index.js +14 -0
- package/cache/index.js.map +1 -0
- package/cache/inmemory/__mocks__/optimism.d.ts +2 -0
- package/cache/inmemory/__mocks__/optimism.d.ts.map +1 -0
- package/cache/inmemory/__mocks__/optimism.js +14 -0
- package/cache/inmemory/__mocks__/optimism.js.map +1 -0
- package/cache/inmemory/entityStore.d.ts +83 -0
- package/cache/inmemory/entityStore.d.ts.map +1 -0
- package/cache/inmemory/entityStore.js +467 -0
- package/cache/inmemory/entityStore.js.map +1 -0
- package/cache/inmemory/fixPolyfills.d.ts +1 -0
- package/cache/inmemory/fixPolyfills.d.ts.map +1 -0
- package/cache/inmemory/fixPolyfills.js +1 -0
- package/cache/inmemory/fixPolyfills.js.map +1 -0
- package/cache/inmemory/fixPolyfills.native.d.ts +2 -0
- package/cache/inmemory/fixPolyfills.native.d.ts.map +1 -0
- package/cache/inmemory/fixPolyfills.native.js +48 -0
- package/cache/inmemory/fixPolyfills.native.js.map +1 -0
- package/cache/inmemory/fragmentRegistry.d.ts +8 -0
- package/cache/inmemory/fragmentRegistry.d.ts.map +1 -0
- package/cache/inmemory/fragmentRegistry.js +113 -0
- package/cache/inmemory/fragmentRegistry.js.map +1 -0
- package/cache/inmemory/helpers.d.ts +27 -0
- package/cache/inmemory/helpers.d.ts.map +1 -0
- package/cache/inmemory/helpers.js +85 -0
- package/cache/inmemory/helpers.js.map +1 -0
- package/cache/inmemory/inMemoryCache.d.ts +52 -0
- package/cache/inmemory/inMemoryCache.d.ts.map +1 -0
- package/cache/inmemory/inMemoryCache.js +316 -0
- package/cache/inmemory/inMemoryCache.js.map +1 -0
- package/cache/inmemory/key-extractor.d.ts +9 -0
- package/cache/inmemory/key-extractor.d.ts.map +1 -0
- package/cache/inmemory/key-extractor.js +118 -0
- package/cache/inmemory/key-extractor.js.map +1 -0
- package/cache/inmemory/object-canon.d.ts +17 -0
- package/cache/inmemory/object-canon.d.ts.map +1 -0
- package/cache/inmemory/object-canon.js +120 -0
- package/cache/inmemory/object-canon.js.map +1 -0
- package/cache/inmemory/policies.d.ts +96 -0
- package/cache/inmemory/policies.d.ts.map +1 -0
- package/cache/inmemory/policies.js +416 -0
- package/cache/inmemory/policies.js.map +1 -0
- package/cache/inmemory/reactiveVars.d.ts +18 -0
- package/cache/inmemory/reactiveVars.d.ts.map +1 -0
- package/cache/inmemory/reactiveVars.js +65 -0
- package/cache/inmemory/reactiveVars.js.map +1 -0
- package/cache/inmemory/readFromStore.d.ts +36 -0
- package/cache/inmemory/readFromStore.d.ts.map +1 -0
- package/cache/inmemory/readFromStore.js +267 -0
- package/cache/inmemory/readFromStore.js.map +1 -0
- package/cache/inmemory/types.d.ts +81 -0
- package/cache/inmemory/types.d.ts.map +1 -0
- package/cache/inmemory/types.js +4 -0
- package/cache/inmemory/types.js.map +1 -0
- package/cache/inmemory/writeToStore.d.ts +37 -0
- package/cache/inmemory/writeToStore.d.ts.map +1 -0
- package/cache/inmemory/writeToStore.js +394 -0
- package/cache/inmemory/writeToStore.js.map +1 -0
- package/cache/package.json +8 -0
- package/config/jest/setup.d.ts +2 -0
- package/config/jest/setup.d.ts.map +1 -0
- package/config/jest/setup.js +5 -0
- package/config/jest/setup.js.map +1 -0
- package/core/ApolloClient.d.ts +76 -0
- package/core/ApolloClient.d.ts.map +1 -0
- package/core/ApolloClient.js +240 -0
- package/core/ApolloClient.js.map +1 -0
- package/core/LocalState.d.ts +69 -0
- package/core/LocalState.d.ts.map +1 -0
- package/core/LocalState.js +321 -0
- package/core/LocalState.js.map +1 -0
- package/core/ObservableQuery.d.ts +74 -0
- package/core/ObservableQuery.d.ts.map +1 -0
- package/core/ObservableQuery.js +507 -0
- package/core/ObservableQuery.js.map +1 -0
- package/core/QueryInfo.d.ts +62 -0
- package/core/QueryInfo.d.ts.map +1 -0
- package/core/QueryInfo.js +287 -0
- package/core/QueryInfo.js.map +1 -0
- package/core/QueryManager.d.ts +120 -0
- package/core/QueryManager.d.ts.map +1 -0
- package/core/QueryManager.js +890 -0
- package/core/QueryManager.js.map +1 -0
- package/core/core.cjs +2349 -0
- package/core/core.cjs.map +1 -0
- package/core/core.cjs.native.js +2349 -0
- package/core/index.d.ts +17 -0
- package/core/index.d.ts.map +1 -0
- package/core/index.js +17 -0
- package/core/index.js.map +1 -0
- package/core/networkStatus.d.ts +11 -0
- package/core/networkStatus.d.ts.map +1 -0
- package/core/networkStatus.js +14 -0
- package/core/networkStatus.js.map +1 -0
- package/core/package.json +8 -0
- package/core/types.d.ts +74 -0
- package/core/types.d.ts.map +1 -0
- package/core/types.js +3 -0
- package/core/types.js.map +1 -0
- package/core/watchQueryOptions.d.ts +78 -0
- package/core/watchQueryOptions.d.ts.map +1 -0
- package/core/watchQueryOptions.js +2 -0
- package/core/watchQueryOptions.js.map +1 -0
- package/errors/errors.cjs +49 -0
- package/errors/errors.cjs.map +1 -0
- package/errors/errors.cjs.native.js +49 -0
- package/errors/index.d.ts +23 -0
- package/errors/index.d.ts.map +1 -0
- package/errors/index.js +42 -0
- package/errors/index.js.map +1 -0
- package/errors/package.json +8 -0
- package/index.d.ts +3 -0
- package/index.d.ts.map +1 -0
- package/index.js +3 -0
- package/index.js.map +1 -0
- package/invariantErrorCodes.js +339 -0
- package/link/batch/batch.cjs +159 -0
- package/link/batch/batch.cjs.map +1 -0
- package/link/batch/batch.cjs.native.js +159 -0
- package/link/batch/batchLink.d.ts +19 -0
- package/link/batch/batchLink.d.ts.map +1 -0
- package/link/batch/batchLink.js +31 -0
- package/link/batch/batchLink.js.map +1 -0
- package/link/batch/batching.d.ts +27 -0
- package/link/batch/batching.d.ts.map +1 -0
- package/link/batch/batching.js +125 -0
- package/link/batch/batching.js.map +1 -0
- package/link/batch/index.d.ts +2 -0
- package/link/batch/index.d.ts.map +1 -0
- package/link/batch/index.js +2 -0
- package/link/batch/index.js.map +1 -0
- package/link/batch/package.json +8 -0
- package/link/batch-http/batch-http.cjs +137 -0
- package/link/batch-http/batch-http.cjs.map +1 -0
- package/link/batch-http/batch-http.cjs.native.js +137 -0
- package/link/batch-http/batchHttpLink.d.ts +16 -0
- package/link/batch-http/batchHttpLink.d.ts.map +1 -0
- package/link/batch-http/batchHttpLink.js +131 -0
- package/link/batch-http/batchHttpLink.js.map +1 -0
- package/link/batch-http/index.d.ts +2 -0
- package/link/batch-http/index.d.ts.map +1 -0
- package/link/batch-http/index.js +2 -0
- package/link/batch-http/index.js.map +1 -0
- package/link/batch-http/package.json +8 -0
- package/link/context/context.cjs +38 -0
- package/link/context/context.cjs.map +1 -0
- package/link/context/context.cjs.native.js +38 -0
- package/link/context/index.d.ts +5 -0
- package/link/context/index.d.ts.map +1 -0
- package/link/context/index.js +31 -0
- package/link/context/index.js.map +1 -0
- package/link/context/package.json +8 -0
- package/link/core/ApolloLink.d.ts +16 -0
- package/link/core/ApolloLink.d.ts.map +1 -0
- package/link/core/ApolloLink.js +100 -0
- package/link/core/ApolloLink.js.map +1 -0
- package/link/core/concat.d.ts +3 -0
- package/link/core/concat.d.ts.map +1 -0
- package/link/core/concat.js +3 -0
- package/link/core/concat.js.map +1 -0
- package/link/core/core.cjs +121 -0
- package/link/core/core.cjs.map +1 -0
- package/link/core/core.cjs.native.js +121 -0
- package/link/core/empty.d.ts +3 -0
- package/link/core/empty.d.ts.map +1 -0
- package/link/core/empty.js +3 -0
- package/link/core/empty.js.map +1 -0
- package/link/core/execute.d.ts +3 -0
- package/link/core/execute.d.ts.map +1 -0
- package/link/core/execute.js +3 -0
- package/link/core/execute.js.map +1 -0
- package/link/core/from.d.ts +3 -0
- package/link/core/from.d.ts.map +1 -0
- package/link/core/from.js +3 -0
- package/link/core/from.js.map +1 -0
- package/link/core/index.d.ts +9 -0
- package/link/core/index.d.ts.map +1 -0
- package/link/core/index.js +9 -0
- package/link/core/index.js.map +1 -0
- package/link/core/package.json +8 -0
- package/link/core/split.d.ts +3 -0
- package/link/core/split.d.ts.map +1 -0
- package/link/core/split.js +3 -0
- package/link/core/split.js.map +1 -0
- package/link/core/types.d.ts +52 -0
- package/link/core/types.d.ts.map +1 -0
- package/link/core/types.js +2 -0
- package/link/core/types.js.map +1 -0
- package/link/error/error.cjs +90 -0
- package/link/error/error.cjs.map +1 -0
- package/link/error/error.cjs.native.js +90 -0
- package/link/error/index.d.ts +24 -0
- package/link/error/index.d.ts.map +1 -0
- package/link/error/index.js +83 -0
- package/link/error/index.js.map +1 -0
- package/link/error/package.json +8 -0
- package/link/http/HttpLink.d.ts +8 -0
- package/link/http/HttpLink.d.ts.map +1 -0
- package/link/http/HttpLink.js +15 -0
- package/link/http/HttpLink.js.map +1 -0
- package/link/http/checkFetcher.d.ts +2 -0
- package/link/http/checkFetcher.d.ts.map +1 -0
- package/link/http/checkFetcher.js +7 -0
- package/link/http/checkFetcher.js.map +1 -0
- package/link/http/createHttpLink.d.ts +4 -0
- package/link/http/createHttpLink.d.ts.map +1 -0
- package/link/http/createHttpLink.js +127 -0
- package/link/http/createHttpLink.js.map +1 -0
- package/link/http/createSignalIfSupported.d.ts +8 -0
- package/link/http/createSignalIfSupported.d.ts.map +1 -0
- package/link/http/createSignalIfSupported.js +8 -0
- package/link/http/createSignalIfSupported.js.map +1 -0
- package/link/http/http.cjs +593 -0
- package/link/http/http.cjs.map +1 -0
- package/link/http/http.cjs.native.js +593 -0
- package/link/http/index.d.ts +11 -0
- package/link/http/index.d.ts.map +1 -0
- package/link/http/index.js +11 -0
- package/link/http/index.js.map +1 -0
- package/link/http/iterators/async.d.ts +2 -0
- package/link/http/iterators/async.d.ts.map +1 -0
- package/link/http/iterators/async.js +14 -0
- package/link/http/iterators/async.js.map +1 -0
- package/link/http/iterators/nodeStream.d.ts +4 -0
- package/link/http/iterators/nodeStream.d.ts.map +1 -0
- package/link/http/iterators/nodeStream.js +71 -0
- package/link/http/iterators/nodeStream.js.map +1 -0
- package/link/http/iterators/promise.d.ts +2 -0
- package/link/http/iterators/promise.d.ts.map +1 -0
- package/link/http/iterators/promise.js +28 -0
- package/link/http/iterators/promise.js.map +1 -0
- package/link/http/iterators/reader.d.ts +2 -0
- package/link/http/iterators/reader.d.ts.map +1 -0
- package/link/http/iterators/reader.js +15 -0
- package/link/http/iterators/reader.js.map +1 -0
- package/link/http/package.json +8 -0
- package/link/http/parseAndCheckHttpResponse.d.ts +14 -0
- package/link/http/parseAndCheckHttpResponse.d.ts.map +1 -0
- package/link/http/parseAndCheckHttpResponse.js +148 -0
- package/link/http/parseAndCheckHttpResponse.js.map +1 -0
- package/link/http/responseIterator.d.ts +3 -0
- package/link/http/responseIterator.d.ts.map +1 -0
- package/link/http/responseIterator.js +23 -0
- package/link/http/responseIterator.js.map +1 -0
- package/link/http/rewriteURIForGET.d.ts +9 -0
- package/link/http/rewriteURIForGET.d.ts.map +1 -0
- package/link/http/rewriteURIForGET.js +43 -0
- package/link/http/rewriteURIForGET.js.map +1 -0
- package/link/http/selectHttpOptionsAndBody.d.ts +57 -0
- package/link/http/selectHttpOptionsAndBody.d.ts.map +1 -0
- package/link/http/selectHttpOptionsAndBody.js +78 -0
- package/link/http/selectHttpOptionsAndBody.js.map +1 -0
- package/link/http/selectURI.d.ts +3 -0
- package/link/http/selectURI.d.ts.map +1 -0
- package/link/http/selectURI.js +14 -0
- package/link/http/selectURI.js.map +1 -0
- package/link/http/serializeFetchParameter.d.ts +6 -0
- package/link/http/serializeFetchParameter.d.ts.map +1 -0
- package/link/http/serializeFetchParameter.js +14 -0
- package/link/http/serializeFetchParameter.js.map +1 -0
- package/link/persisted-queries/index.d.ts +31 -0
- package/link/persisted-queries/index.d.ts.map +1 -0
- package/link/persisted-queries/index.js +170 -0
- package/link/persisted-queries/index.js.map +1 -0
- package/link/persisted-queries/package.json +8 -0
- package/link/persisted-queries/persisted-queries.cjs +174 -0
- package/link/persisted-queries/persisted-queries.cjs.map +1 -0
- package/link/persisted-queries/persisted-queries.cjs.native.js +174 -0
- package/link/retry/delayFunction.d.ts +11 -0
- package/link/retry/delayFunction.d.ts.map +1 -0
- package/link/retry/delayFunction.js +12 -0
- package/link/retry/delayFunction.js.map +1 -0
- package/link/retry/index.d.ts +2 -0
- package/link/retry/index.d.ts.map +1 -0
- package/link/retry/index.js +2 -0
- package/link/retry/index.js.map +1 -0
- package/link/retry/package.json +8 -0
- package/link/retry/retry.cjs +170 -0
- package/link/retry/retry.cjs.map +1 -0
- package/link/retry/retry.cjs.native.js +170 -0
- package/link/retry/retryFunction.d.ts +10 -0
- package/link/retry/retryFunction.d.ts.map +1 -0
- package/link/retry/retryFunction.js +9 -0
- package/link/retry/retryFunction.js.map +1 -0
- package/link/retry/retryLink.d.ts +17 -0
- package/link/retry/retryLink.d.ts.map +1 -0
- package/link/retry/retryLink.js +145 -0
- package/link/retry/retryLink.js.map +1 -0
- package/link/schema/index.d.ts +22 -0
- package/link/schema/index.d.ts.map +1 -0
- package/link/schema/index.js +50 -0
- package/link/schema/index.js.map +1 -0
- package/link/schema/package.json +8 -0
- package/link/schema/schema.cjs +56 -0
- package/link/schema/schema.cjs.map +1 -0
- package/link/schema/schema.cjs.native.js +56 -0
- package/link/subscriptions/index.d.ts +9 -0
- package/link/subscriptions/index.d.ts.map +1 -0
- package/link/subscriptions/index.js +39 -0
- package/link/subscriptions/index.js.map +1 -0
- package/link/subscriptions/package.json +8 -0
- package/link/subscriptions/subscriptions.cjs +45 -0
- package/link/subscriptions/subscriptions.cjs.map +1 -0
- package/link/subscriptions/subscriptions.cjs.native.js +45 -0
- package/link/utils/createOperation.d.ts +3 -0
- package/link/utils/createOperation.d.ts.map +1 -0
- package/link/utils/createOperation.js +23 -0
- package/link/utils/createOperation.js.map +1 -0
- package/link/utils/fromError.d.ts +3 -0
- package/link/utils/fromError.d.ts.map +1 -0
- package/link/utils/fromError.js +7 -0
- package/link/utils/fromError.js.map +1 -0
- package/link/utils/fromPromise.d.ts +3 -0
- package/link/utils/fromPromise.d.ts.map +1 -0
- package/link/utils/fromPromise.js +12 -0
- package/link/utils/fromPromise.js.map +1 -0
- package/link/utils/index.d.ts +9 -0
- package/link/utils/index.d.ts.map +1 -0
- package/link/utils/index.js +9 -0
- package/link/utils/index.js.map +1 -0
- package/link/utils/package.json +8 -0
- package/link/utils/throwServerError.d.ts +7 -0
- package/link/utils/throwServerError.d.ts.map +1 -0
- package/link/utils/throwServerError.js +9 -0
- package/link/utils/throwServerError.js.map +1 -0
- package/link/utils/toPromise.d.ts +3 -0
- package/link/utils/toPromise.d.ts.map +1 -0
- package/link/utils/toPromise.js +19 -0
- package/link/utils/toPromise.js.map +1 -0
- package/link/utils/transformOperation.d.ts +3 -0
- package/link/utils/transformOperation.d.ts.map +1 -0
- package/link/utils/transformOperation.js +17 -0
- package/link/utils/transformOperation.js.map +1 -0
- package/link/utils/utils.cjs +115 -0
- package/link/utils/utils.cjs.map +1 -0
- package/link/utils/utils.cjs.native.js +115 -0
- package/link/utils/validateOperation.d.ts +3 -0
- package/link/utils/validateOperation.d.ts.map +1 -0
- package/link/utils/validateOperation.js +18 -0
- package/link/utils/validateOperation.js.map +1 -0
- package/link/ws/index.d.ts +17 -0
- package/link/ws/index.d.ts.map +1 -0
- package/link/ws/index.js +22 -0
- package/link/ws/index.js.map +1 -0
- package/link/ws/package.json +8 -0
- package/link/ws/ws.cjs +28 -0
- package/link/ws/ws.cjs.map +1 -0
- package/link/ws/ws.cjs.native.js +28 -0
- package/main.cjs +16 -0
- package/main.cjs.map +1 -0
- package/main.cjs.native.js +16 -0
- package/package.json +141 -0
- package/react/cache/SuspenseCache.d.ts +18 -0
- package/react/cache/SuspenseCache.d.ts.map +1 -0
- package/react/cache/SuspenseCache.js +49 -0
- package/react/cache/SuspenseCache.js.map +1 -0
- package/react/cache/index.d.ts +2 -0
- package/react/cache/index.d.ts.map +1 -0
- package/react/cache/index.js +2 -0
- package/react/cache/index.js.map +1 -0
- package/react/components/Mutation.d.ts +12 -0
- package/react/components/Mutation.d.ts.map +1 -0
- package/react/components/Mutation.js +22 -0
- package/react/components/Mutation.js.map +1 -0
- package/react/components/Query.d.ts +12 -0
- package/react/components/Query.d.ts.map +1 -0
- package/react/components/Query.js +23 -0
- package/react/components/Query.js.map +1 -0
- package/react/components/Subscription.d.ts +12 -0
- package/react/components/Subscription.d.ts.map +1 -0
- package/react/components/Subscription.js +17 -0
- package/react/components/Subscription.js.map +1 -0
- package/react/components/components.cjs +81 -0
- package/react/components/components.cjs.map +1 -0
- package/react/components/components.cjs.native.js +81 -0
- package/react/components/index.d.ts +5 -0
- package/react/components/index.d.ts.map +1 -0
- package/react/components/index.js +5 -0
- package/react/components/index.js.map +1 -0
- package/react/components/package.json +8 -0
- package/react/components/types.d.ts +18 -0
- package/react/components/types.d.ts.map +1 -0
- package/react/components/types.js +2 -0
- package/react/components/types.js.map +1 -0
- package/react/context/ApolloConsumer.d.ts +7 -0
- package/react/context/ApolloConsumer.d.ts.map +1 -0
- package/react/context/ApolloConsumer.js +12 -0
- package/react/context/ApolloConsumer.js.map +1 -0
- package/react/context/ApolloContext.d.ts +12 -0
- package/react/context/ApolloContext.d.ts.map +1 -0
- package/react/context/ApolloContext.js +20 -0
- package/react/context/ApolloContext.js.map +1 -0
- package/react/context/ApolloProvider.d.ts +10 -0
- package/react/context/ApolloProvider.d.ts.map +1 -0
- package/react/context/ApolloProvider.js +20 -0
- package/react/context/ApolloProvider.js.map +1 -0
- package/react/context/context.cjs +70 -0
- package/react/context/context.cjs.map +1 -0
- package/react/context/context.cjs.native.js +70 -0
- package/react/context/index.d.ts +5 -0
- package/react/context/index.d.ts.map +1 -0
- package/react/context/index.js +5 -0
- package/react/context/index.js.map +1 -0
- package/react/context/package.json +8 -0
- package/react/hoc/graphql.d.ts +6 -0
- package/react/hoc/graphql.d.ts.map +1 -0
- package/react/hoc/graphql.js +17 -0
- package/react/hoc/graphql.js.map +1 -0
- package/react/hoc/hoc-utils.d.ts +17 -0
- package/react/hoc/hoc-utils.d.ts.map +1 -0
- package/react/hoc/hoc-utils.js +47 -0
- package/react/hoc/hoc-utils.js.map +1 -0
- package/react/hoc/hoc.cjs +325 -0
- package/react/hoc/hoc.cjs.map +1 -0
- package/react/hoc/hoc.cjs.native.js +325 -0
- package/react/hoc/index.d.ts +8 -0
- package/react/hoc/index.d.ts.map +1 -0
- package/react/hoc/index.js +8 -0
- package/react/hoc/index.js.map +1 -0
- package/react/hoc/mutation-hoc.d.ts +7 -0
- package/react/hoc/mutation-hoc.d.ts.map +1 -0
- package/react/hoc/mutation-hoc.js +63 -0
- package/react/hoc/mutation-hoc.js.map +1 -0
- package/react/hoc/package.json +8 -0
- package/react/hoc/query-hoc.d.ts +5 -0
- package/react/hoc/query-hoc.d.ts.map +1 -0
- package/react/hoc/query-hoc.js +70 -0
- package/react/hoc/query-hoc.js.map +1 -0
- package/react/hoc/subscription-hoc.d.ts +5 -0
- package/react/hoc/subscription-hoc.d.ts.map +1 -0
- package/react/hoc/subscription-hoc.js +80 -0
- package/react/hoc/subscription-hoc.js.map +1 -0
- package/react/hoc/types.d.ts +43 -0
- package/react/hoc/types.d.ts.map +1 -0
- package/react/hoc/types.js +2 -0
- package/react/hoc/types.js.map +1 -0
- package/react/hoc/withApollo.d.ts +4 -0
- package/react/hoc/withApollo.d.ts.map +1 -0
- package/react/hoc/withApollo.js +45 -0
- package/react/hoc/withApollo.js.map +1 -0
- package/react/hooks/compareResults.d.ts +3 -0
- package/react/hooks/compareResults.d.ts.map +1 -0
- package/react/hooks/compareResults.js +63 -0
- package/react/hooks/compareResults.js.map +1 -0
- package/react/hooks/hooks.cjs +913 -0
- package/react/hooks/hooks.cjs.map +1 -0
- package/react/hooks/hooks.cjs.native.js +913 -0
- package/react/hooks/index.d.ts +10 -0
- package/react/hooks/index.d.ts.map +1 -0
- package/react/hooks/index.js +10 -0
- package/react/hooks/index.js.map +1 -0
- package/react/hooks/internal/index.d.ts +3 -0
- package/react/hooks/internal/index.d.ts.map +1 -0
- package/react/hooks/internal/index.js +3 -0
- package/react/hooks/internal/index.js.map +1 -0
- package/react/hooks/internal/useDeepMemo.d.ts +3 -0
- package/react/hooks/internal/useDeepMemo.d.ts.map +1 -0
- package/react/hooks/internal/useDeepMemo.js +10 -0
- package/react/hooks/internal/useDeepMemo.js.map +1 -0
- package/react/hooks/internal/useIsomorphicLayoutEffect.d.ts +3 -0
- package/react/hooks/internal/useIsomorphicLayoutEffect.d.ts.map +1 -0
- package/react/hooks/internal/useIsomorphicLayoutEffect.js +6 -0
- package/react/hooks/internal/useIsomorphicLayoutEffect.js.map +1 -0
- package/react/hooks/package.json +8 -0
- package/react/hooks/useApolloClient.d.ts +3 -0
- package/react/hooks/useApolloClient.d.ts.map +1 -0
- package/react/hooks/useApolloClient.js +12 -0
- package/react/hooks/useApolloClient.js.map +1 -0
- package/react/hooks/useFragment.d.ts +13 -0
- package/react/hooks/useFragment.d.ts.map +1 -0
- package/react/hooks/useFragment.js +39 -0
- package/react/hooks/useFragment.js.map +1 -0
- package/react/hooks/useLazyQuery.d.ts +6 -0
- package/react/hooks/useLazyQuery.d.ts.map +1 -0
- package/react/hooks/useLazyQuery.js +71 -0
- package/react/hooks/useLazyQuery.js.map +1 -0
- package/react/hooks/useMutation.d.ts +6 -0
- package/react/hooks/useMutation.d.ts.map +1 -0
- package/react/hooks/useMutation.js +100 -0
- package/react/hooks/useMutation.js.map +1 -0
- package/react/hooks/useQuery.d.ts +41 -0
- package/react/hooks/useQuery.d.ts.map +1 -0
- package/react/hooks/useQuery.js +302 -0
- package/react/hooks/useQuery.js.map +1 -0
- package/react/hooks/useReactiveVar.d.ts +3 -0
- package/react/hooks/useReactiveVar.d.ts.map +1 -0
- package/react/hooks/useReactiveVar.js +16 -0
- package/react/hooks/useReactiveVar.js.map +1 -0
- package/react/hooks/useSubscription.d.ts +6 -0
- package/react/hooks/useSubscription.d.ts.map +1 -0
- package/react/hooks/useSubscription.js +141 -0
- package/react/hooks/useSubscription.js.map +1 -0
- package/react/hooks/useSuspenseCache.d.ts +2 -0
- package/react/hooks/useSuspenseCache.d.ts.map +1 -0
- package/react/hooks/useSuspenseCache.js +10 -0
- package/react/hooks/useSuspenseCache.js.map +1 -0
- package/react/hooks/useSuspenseQuery.d.ts +12 -0
- package/react/hooks/useSuspenseQuery.d.ts.map +1 -0
- package/react/hooks/useSuspenseQuery.js +181 -0
- package/react/hooks/useSuspenseQuery.js.map +1 -0
- package/react/hooks/useSyncExternalStore.d.ts +4 -0
- package/react/hooks/useSyncExternalStore.d.ts.map +1 -0
- package/react/hooks/useSyncExternalStore.js +48 -0
- package/react/hooks/useSyncExternalStore.js.map +1 -0
- package/react/index.d.ts +7 -0
- package/react/index.d.ts.map +1 -0
- package/react/index.js +7 -0
- package/react/index.js.map +1 -0
- package/react/package.json +8 -0
- package/react/parser/index.d.ts +15 -0
- package/react/parser/index.d.ts.map +1 -0
- package/react/parser/index.js +94 -0
- package/react/parser/index.js.map +1 -0
- package/react/parser/package.json +8 -0
- package/react/parser/parser.cjs +103 -0
- package/react/parser/parser.cjs.map +1 -0
- package/react/parser/parser.cjs.native.js +103 -0
- package/react/react.cjs +69 -0
- package/react/react.cjs.map +1 -0
- package/react/react.cjs.native.js +69 -0
- package/react/ssr/RenderPromises.d.ts +22 -0
- package/react/ssr/RenderPromises.d.ts.map +1 -0
- package/react/ssr/RenderPromises.js +90 -0
- package/react/ssr/RenderPromises.js.map +1 -0
- package/react/ssr/getDataFromTree.d.ts +13 -0
- package/react/ssr/getDataFromTree.d.ts.map +1 -0
- package/react/ssr/getDataFromTree.js +32 -0
- package/react/ssr/getDataFromTree.js.map +1 -0
- package/react/ssr/index.d.ts +4 -0
- package/react/ssr/index.d.ts.map +1 -0
- package/react/ssr/index.js +4 -0
- package/react/ssr/index.js.map +1 -0
- package/react/ssr/package.json +8 -0
- package/react/ssr/renderToStringWithData.d.ts +3 -0
- package/react/ssr/renderToStringWithData.d.ts.map +1 -0
- package/react/ssr/renderToStringWithData.js +9 -0
- package/react/ssr/renderToStringWithData.js.map +1 -0
- package/react/ssr/ssr.cjs +151 -0
- package/react/ssr/ssr.cjs.map +1 -0
- package/react/ssr/ssr.cjs.native.js +151 -0
- package/react/types/types.d.ts +130 -0
- package/react/types/types.d.ts.map +1 -0
- package/react/types/types.js +2 -0
- package/react/types/types.js.map +1 -0
- package/testing/core/core.cjs +315 -0
- package/testing/core/core.cjs.map +1 -0
- package/testing/core/core.cjs.native.js +315 -0
- package/testing/core/index.d.ts +8 -0
- package/testing/core/index.d.ts.map +1 -0
- package/testing/core/index.js +8 -0
- package/testing/core/index.js.map +1 -0
- package/testing/core/itAsync.d.ts +6 -0
- package/testing/core/itAsync.d.ts.map +1 -0
- package/testing/core/itAsync.js +19 -0
- package/testing/core/itAsync.js.map +1 -0
- package/testing/core/mocking/mockClient.d.ts +5 -0
- package/testing/core/mocking/mockClient.d.ts.map +1 -0
- package/testing/core/mocking/mockClient.js +14 -0
- package/testing/core/mocking/mockClient.js.map +1 -0
- package/testing/core/mocking/mockFetch.d.ts +24 -0
- package/testing/core/mocking/mockFetch.d.ts.map +1 -0
- package/testing/core/mocking/mockFetch.js +83 -0
- package/testing/core/mocking/mockFetch.js.map +1 -0
- package/testing/core/mocking/mockLink.d.ts +28 -0
- package/testing/core/mocking/mockLink.d.ts.map +1 -0
- package/testing/core/mocking/mockLink.js +139 -0
- package/testing/core/mocking/mockLink.js.map +1 -0
- package/testing/core/mocking/mockQueryManager.d.ts +5 -0
- package/testing/core/mocking/mockQueryManager.d.ts.map +1 -0
- package/testing/core/mocking/mockQueryManager.js +14 -0
- package/testing/core/mocking/mockQueryManager.js.map +1 -0
- package/testing/core/mocking/mockSubscriptionLink.d.ts +24 -0
- package/testing/core/mocking/mockSubscriptionLink.d.ts.map +1 -0
- package/testing/core/mocking/mockSubscriptionLink.js +62 -0
- package/testing/core/mocking/mockSubscriptionLink.js.map +1 -0
- package/testing/core/mocking/mockWatchQuery.d.ts +5 -0
- package/testing/core/mocking/mockWatchQuery.d.ts.map +1 -0
- package/testing/core/mocking/mockWatchQuery.js +15 -0
- package/testing/core/mocking/mockWatchQuery.js.map +1 -0
- package/testing/core/observableToPromise.d.ts +15 -0
- package/testing/core/observableToPromise.d.ts.map +1 -0
- package/testing/core/observableToPromise.js +65 -0
- package/testing/core/observableToPromise.js.map +1 -0
- package/testing/core/package.json +8 -0
- package/testing/core/subscribeAndCount.d.ts +3 -0
- package/testing/core/subscribeAndCount.d.ts.map +1 -0
- package/testing/core/subscribeAndCount.js +16 -0
- package/testing/core/subscribeAndCount.js.map +1 -0
- package/testing/core/wait.d.ts +3 -0
- package/testing/core/wait.d.ts.map +1 -0
- package/testing/core/wait.js +16 -0
- package/testing/core/wait.js.map +1 -0
- package/testing/core/withConsoleSpy.d.ts +4 -0
- package/testing/core/withConsoleSpy.d.ts.map +1 -0
- package/testing/core/withConsoleSpy.js +39 -0
- package/testing/core/withConsoleSpy.js.map +1 -0
- package/testing/core/wrap.d.ts +4 -0
- package/testing/core/wrap.d.ts.map +1 -0
- package/testing/core/wrap.js +26 -0
- package/testing/core/wrap.js.map +1 -0
- package/testing/index.d.ts +4 -0
- package/testing/index.d.ts.map +1 -0
- package/testing/index.js +4 -0
- package/testing/index.js.map +1 -0
- package/testing/package.json +8 -0
- package/testing/react/MockedProvider.d.ts +30 -0
- package/testing/react/MockedProvider.d.ts.map +1 -0
- package/testing/react/MockedProvider.js +39 -0
- package/testing/react/MockedProvider.js.map +1 -0
- package/testing/testing.cjs +109 -0
- package/testing/testing.cjs.map +1 -0
- package/testing/testing.cjs.native.js +109 -0
- package/utilities/common/arrays.d.ts +2 -0
- package/utilities/common/arrays.d.ts.map +1 -0
- package/utilities/common/arrays.js +4 -0
- package/utilities/common/arrays.js.map +1 -0
- package/utilities/common/canUse.d.ts +7 -0
- package/utilities/common/canUse.d.ts.map +1 -0
- package/utilities/common/canUse.js +11 -0
- package/utilities/common/canUse.js.map +1 -0
- package/utilities/common/cloneDeep.d.ts +2 -0
- package/utilities/common/cloneDeep.d.ts.map +1 -0
- package/utilities/common/cloneDeep.js +33 -0
- package/utilities/common/cloneDeep.js.map +1 -0
- package/utilities/common/compact.d.ts +3 -0
- package/utilities/common/compact.d.ts.map +1 -0
- package/utilities/common/compact.js +19 -0
- package/utilities/common/compact.js.map +1 -0
- package/utilities/common/errorHandling.d.ts +4 -0
- package/utilities/common/errorHandling.d.ts.map +1 -0
- package/utilities/common/errorHandling.js +21 -0
- package/utilities/common/errorHandling.js.map +1 -0
- package/utilities/common/filterInPlace.d.ts +2 -0
- package/utilities/common/filterInPlace.d.ts.map +1 -0
- package/utilities/common/filterInPlace.js +11 -0
- package/utilities/common/filterInPlace.js.map +1 -0
- package/utilities/common/incrementalResult.d.ts +6 -0
- package/utilities/common/incrementalResult.d.ts.map +1 -0
- package/utilities/common/incrementalResult.js +32 -0
- package/utilities/common/incrementalResult.js.map +1 -0
- package/utilities/common/makeUniqueId.d.ts +2 -0
- package/utilities/common/makeUniqueId.d.ts.map +1 -0
- package/utilities/common/makeUniqueId.js +7 -0
- package/utilities/common/makeUniqueId.js.map +1 -0
- package/utilities/common/maybeDeepFreeze.d.ts +2 -0
- package/utilities/common/maybeDeepFreeze.d.ts.map +1 -0
- package/utilities/common/maybeDeepFreeze.js +34 -0
- package/utilities/common/maybeDeepFreeze.js.map +1 -0
- package/utilities/common/mergeDeep.d.ts +14 -0
- package/utilities/common/mergeDeep.d.ts.map +1 -0
- package/utilities/common/mergeDeep.js +76 -0
- package/utilities/common/mergeDeep.js.map +1 -0
- package/utilities/common/mergeOptions.d.ts +5 -0
- package/utilities/common/mergeOptions.d.ts.map +1 -0
- package/utilities/common/mergeOptions.js +8 -0
- package/utilities/common/mergeOptions.js.map +1 -0
- package/utilities/common/objects.d.ts +2 -0
- package/utilities/common/objects.d.ts.map +1 -0
- package/utilities/common/objects.js +4 -0
- package/utilities/common/objects.js.map +1 -0
- package/utilities/common/responseIterator.d.ts +10 -0
- package/utilities/common/responseIterator.d.ts.map +1 -0
- package/utilities/common/responseIterator.js +21 -0
- package/utilities/common/responseIterator.js.map +1 -0
- package/utilities/common/stringifyForDisplay.d.ts +2 -0
- package/utilities/common/stringifyForDisplay.d.ts.map +1 -0
- package/utilities/common/stringifyForDisplay.js +8 -0
- package/utilities/common/stringifyForDisplay.js.map +1 -0
- package/utilities/globals/DEV.d.ts +3 -0
- package/utilities/globals/DEV.d.ts.map +1 -0
- package/utilities/globals/DEV.js +9 -0
- package/utilities/globals/DEV.js.map +1 -0
- package/utilities/globals/fix-graphql.d.ts +2 -0
- package/utilities/globals/fix-graphql.d.ts.map +1 -0
- package/utilities/globals/fix-graphql.js +6 -0
- package/utilities/globals/fix-graphql.js.map +1 -0
- package/utilities/globals/global.d.ts +5 -0
- package/utilities/globals/global.d.ts.map +1 -0
- package/utilities/globals/global.js +6 -0
- package/utilities/globals/global.js.map +1 -0
- package/utilities/globals/globals.cjs +42 -0
- package/utilities/globals/globals.cjs.map +1 -0
- package/utilities/globals/globals.cjs.native.js +42 -0
- package/utilities/globals/index.d.ts +8 -0
- package/utilities/globals/index.d.ts.map +1 -0
- package/utilities/globals/index.js +10 -0
- package/utilities/globals/index.js.map +1 -0
- package/utilities/globals/maybe.d.ts +2 -0
- package/utilities/globals/maybe.d.ts.map +1 -0
- package/utilities/globals/maybe.js +7 -0
- package/utilities/globals/maybe.js.map +1 -0
- package/utilities/globals/package.json +8 -0
- package/utilities/graphql/directives.d.ts +18 -0
- package/utilities/graphql/directives.d.ts.map +1 -0
- package/utilities/graphql/directives.js +72 -0
- package/utilities/graphql/directives.js.map +1 -0
- package/utilities/graphql/fragments.d.ts +9 -0
- package/utilities/graphql/fragments.d.ts.map +1 -0
- package/utilities/graphql/fragments.js +64 -0
- package/utilities/graphql/fragments.js.map +1 -0
- package/utilities/graphql/getFromAST.d.ts +10 -0
- package/utilities/graphql/getFromAST.d.ts.map +1 -0
- package/utilities/graphql/getFromAST.js +76 -0
- package/utilities/graphql/getFromAST.js.map +1 -0
- package/utilities/graphql/storeUtils.d.ts +32 -0
- package/utilities/graphql/storeUtils.d.ts.map +1 -0
- package/utilities/graphql/storeUtils.js +208 -0
- package/utilities/graphql/storeUtils.js.map +1 -0
- package/utilities/graphql/transform.d.ts +27 -0
- package/utilities/graphql/transform.d.ts.map +1 -0
- package/utilities/graphql/transform.js +281 -0
- package/utilities/graphql/transform.js.map +1 -0
- package/utilities/index.d.ts +27 -0
- package/utilities/index.d.ts.map +1 -0
- package/utilities/index.js +27 -0
- package/utilities/index.js.map +1 -0
- package/utilities/observables/Concast.d.ts +27 -0
- package/utilities/observables/Concast.d.ts.map +1 -0
- package/utilities/observables/Concast.js +137 -0
- package/utilities/observables/Concast.js.map +1 -0
- package/utilities/observables/Observable.d.ts +5 -0
- package/utilities/observables/Observable.d.ts.map +1 -0
- package/utilities/observables/Observable.js +9 -0
- package/utilities/observables/Observable.js.map +1 -0
- package/utilities/observables/asyncMap.d.ts +3 -0
- package/utilities/observables/asyncMap.d.ts.map +1 -0
- package/utilities/observables/asyncMap.js +49 -0
- package/utilities/observables/asyncMap.js.map +1 -0
- package/utilities/observables/iteration.d.ts +3 -0
- package/utilities/observables/iteration.d.ts.map +1 -0
- package/utilities/observables/iteration.js +6 -0
- package/utilities/observables/iteration.js.map +1 -0
- package/utilities/observables/subclassing.d.ts +3 -0
- package/utilities/observables/subclassing.d.ts.map +1 -0
- package/utilities/observables/subclassing.js +13 -0
- package/utilities/observables/subclassing.js.map +1 -0
- package/utilities/package.json +8 -0
- package/utilities/policies/pagination.d.ts +28 -0
- package/utilities/policies/pagination.d.ts.map +1 -0
- package/utilities/policies/pagination.js +151 -0
- package/utilities/policies/pagination.js.map +1 -0
- package/utilities/types/IsStrictlyAny.d.ts +5 -0
- package/utilities/types/IsStrictlyAny.d.ts.map +1 -0
- package/utilities/types/IsStrictlyAny.js +2 -0
- package/utilities/types/IsStrictlyAny.js.map +1 -0
- package/utilities/utilities.cjs +1371 -0
- package/utilities/utilities.cjs.map +1 -0
- package/utilities/utilities.cjs.native.js +1371 -0
- package/version.d.ts +2 -0
- package/version.d.ts.map +1 -0
- package/version.js +2 -0
- package/version.js.map +1 -0
|
@@ -0,0 +1,103 @@
|
|
|
1
|
+
'use strict';
|
|
2
|
+
|
|
3
|
+
Object.defineProperty(exports, '__esModule', { value: true });
|
|
4
|
+
|
|
5
|
+
var globals = require('../../utilities/globals');
|
|
6
|
+
|
|
7
|
+
exports.DocumentType = void 0;
|
|
8
|
+
(function (DocumentType) {
|
|
9
|
+
DocumentType[DocumentType["Query"] = 0] = "Query";
|
|
10
|
+
DocumentType[DocumentType["Mutation"] = 1] = "Mutation";
|
|
11
|
+
DocumentType[DocumentType["Subscription"] = 2] = "Subscription";
|
|
12
|
+
})(exports.DocumentType || (exports.DocumentType = {}));
|
|
13
|
+
var cache = new Map();
|
|
14
|
+
function operationName(type) {
|
|
15
|
+
var name;
|
|
16
|
+
switch (type) {
|
|
17
|
+
case exports.DocumentType.Query:
|
|
18
|
+
name = 'Query';
|
|
19
|
+
break;
|
|
20
|
+
case exports.DocumentType.Mutation:
|
|
21
|
+
name = 'Mutation';
|
|
22
|
+
break;
|
|
23
|
+
case exports.DocumentType.Subscription:
|
|
24
|
+
name = 'Subscription';
|
|
25
|
+
break;
|
|
26
|
+
}
|
|
27
|
+
return name;
|
|
28
|
+
}
|
|
29
|
+
function parser(document) {
|
|
30
|
+
var cached = cache.get(document);
|
|
31
|
+
if (cached)
|
|
32
|
+
return cached;
|
|
33
|
+
var variables, type, name;
|
|
34
|
+
globals.__DEV__ ? globals.invariant(!!document && !!document.kind, "Argument of ".concat(document, " passed to parser was not a valid GraphQL ") +
|
|
35
|
+
"DocumentNode. You may need to use 'graphql-tag' or another method " +
|
|
36
|
+
"to convert your operation into a document") : globals.invariant(!!document && !!document.kind, 35);
|
|
37
|
+
var fragments = [];
|
|
38
|
+
var queries = [];
|
|
39
|
+
var mutations = [];
|
|
40
|
+
var subscriptions = [];
|
|
41
|
+
for (var _i = 0, _a = document.definitions; _i < _a.length; _i++) {
|
|
42
|
+
var x = _a[_i];
|
|
43
|
+
if (x.kind === 'FragmentDefinition') {
|
|
44
|
+
fragments.push(x);
|
|
45
|
+
continue;
|
|
46
|
+
}
|
|
47
|
+
if (x.kind === 'OperationDefinition') {
|
|
48
|
+
switch (x.operation) {
|
|
49
|
+
case 'query':
|
|
50
|
+
queries.push(x);
|
|
51
|
+
break;
|
|
52
|
+
case 'mutation':
|
|
53
|
+
mutations.push(x);
|
|
54
|
+
break;
|
|
55
|
+
case 'subscription':
|
|
56
|
+
subscriptions.push(x);
|
|
57
|
+
break;
|
|
58
|
+
}
|
|
59
|
+
}
|
|
60
|
+
}
|
|
61
|
+
globals.__DEV__ ? globals.invariant(!fragments.length ||
|
|
62
|
+
(queries.length || mutations.length || subscriptions.length), "Passing only a fragment to 'graphql' is not yet supported. " +
|
|
63
|
+
"You must include a query, subscription or mutation as well") : globals.invariant(!fragments.length ||
|
|
64
|
+
(queries.length || mutations.length || subscriptions.length), 36);
|
|
65
|
+
globals.__DEV__ ? globals.invariant(queries.length + mutations.length + subscriptions.length <= 1, "react-apollo only supports a query, subscription, or a mutation per HOC. " +
|
|
66
|
+
"".concat(document, " had ").concat(queries.length, " queries, ").concat(subscriptions.length, " ") +
|
|
67
|
+
"subscriptions and ".concat(mutations.length, " mutations. ") +
|
|
68
|
+
"You can use 'compose' to join multiple operation types to a component") : globals.invariant(queries.length + mutations.length + subscriptions.length <= 1, 37);
|
|
69
|
+
type = queries.length ? exports.DocumentType.Query : exports.DocumentType.Mutation;
|
|
70
|
+
if (!queries.length && !mutations.length)
|
|
71
|
+
type = exports.DocumentType.Subscription;
|
|
72
|
+
var definitions = queries.length
|
|
73
|
+
? queries
|
|
74
|
+
: mutations.length
|
|
75
|
+
? mutations
|
|
76
|
+
: subscriptions;
|
|
77
|
+
globals.__DEV__ ? globals.invariant(definitions.length === 1, "react-apollo only supports one definition per HOC. ".concat(document, " had ") +
|
|
78
|
+
"".concat(definitions.length, " definitions. ") +
|
|
79
|
+
"You can use 'compose' to join multiple operation types to a component") : globals.invariant(definitions.length === 1, 38);
|
|
80
|
+
var definition = definitions[0];
|
|
81
|
+
variables = definition.variableDefinitions || [];
|
|
82
|
+
if (definition.name && definition.name.kind === 'Name') {
|
|
83
|
+
name = definition.name.value;
|
|
84
|
+
}
|
|
85
|
+
else {
|
|
86
|
+
name = 'data';
|
|
87
|
+
}
|
|
88
|
+
var payload = { name: name, type: type, variables: variables };
|
|
89
|
+
cache.set(document, payload);
|
|
90
|
+
return payload;
|
|
91
|
+
}
|
|
92
|
+
function verifyDocumentType(document, type) {
|
|
93
|
+
var operation = parser(document);
|
|
94
|
+
var requiredOperationName = operationName(type);
|
|
95
|
+
var usedOperationName = operationName(operation.type);
|
|
96
|
+
globals.__DEV__ ? globals.invariant(operation.type === type, "Running a ".concat(requiredOperationName, " requires a graphql ") +
|
|
97
|
+
"".concat(requiredOperationName, ", but a ").concat(usedOperationName, " was used instead.")) : globals.invariant(operation.type === type, 39);
|
|
98
|
+
}
|
|
99
|
+
|
|
100
|
+
exports.operationName = operationName;
|
|
101
|
+
exports.parser = parser;
|
|
102
|
+
exports.verifyDocumentType = verifyDocumentType;
|
|
103
|
+
//# sourceMappingURL=parser.cjs.map
|
package/react/react.cjs
ADDED
|
@@ -0,0 +1,69 @@
|
|
|
1
|
+
'use strict';
|
|
2
|
+
|
|
3
|
+
Object.defineProperty(exports, '__esModule', { value: true });
|
|
4
|
+
|
|
5
|
+
require('../utilities/globals');
|
|
6
|
+
var context = require('./context');
|
|
7
|
+
var hooks = require('./hooks');
|
|
8
|
+
var parser = require('./parser');
|
|
9
|
+
var cache = require('../cache');
|
|
10
|
+
|
|
11
|
+
var SuspenseCache = (function () {
|
|
12
|
+
function SuspenseCache() {
|
|
13
|
+
this.queries = new Map();
|
|
14
|
+
}
|
|
15
|
+
SuspenseCache.prototype.add = function (query, variables, _a) {
|
|
16
|
+
var promise = _a.promise, observable = _a.observable;
|
|
17
|
+
var variablesKey = this.getVariablesKey(variables);
|
|
18
|
+
var map = this.queries.get(query) || new Map();
|
|
19
|
+
var entry = {
|
|
20
|
+
observable: observable,
|
|
21
|
+
fulfilled: false,
|
|
22
|
+
promise: promise
|
|
23
|
+
.catch(function () {
|
|
24
|
+
})
|
|
25
|
+
.finally(function () {
|
|
26
|
+
entry.fulfilled = true;
|
|
27
|
+
}),
|
|
28
|
+
};
|
|
29
|
+
map.set(variablesKey, entry);
|
|
30
|
+
this.queries.set(query, map);
|
|
31
|
+
return entry;
|
|
32
|
+
};
|
|
33
|
+
SuspenseCache.prototype.lookup = function (query, variables) {
|
|
34
|
+
var _a;
|
|
35
|
+
return (_a = this.queries
|
|
36
|
+
.get(query)) === null || _a === void 0 ? void 0 : _a.get(this.getVariablesKey(variables));
|
|
37
|
+
};
|
|
38
|
+
SuspenseCache.prototype.remove = function (query, variables) {
|
|
39
|
+
var map = this.queries.get(query);
|
|
40
|
+
if (!map) {
|
|
41
|
+
return;
|
|
42
|
+
}
|
|
43
|
+
var key = this.getVariablesKey(variables);
|
|
44
|
+
var entry = map.get(key);
|
|
45
|
+
if (entry && !entry.observable.hasObservers()) {
|
|
46
|
+
map.delete(key);
|
|
47
|
+
}
|
|
48
|
+
if (map.size === 0) {
|
|
49
|
+
this.queries.delete(query);
|
|
50
|
+
}
|
|
51
|
+
};
|
|
52
|
+
SuspenseCache.prototype.getVariablesKey = function (variables) {
|
|
53
|
+
return cache.canonicalStringify(variables || Object.create(null));
|
|
54
|
+
};
|
|
55
|
+
return SuspenseCache;
|
|
56
|
+
}());
|
|
57
|
+
|
|
58
|
+
exports.ApolloConsumer = context.ApolloConsumer;
|
|
59
|
+
exports.ApolloProvider = context.ApolloProvider;
|
|
60
|
+
exports.getApolloContext = context.getApolloContext;
|
|
61
|
+
exports.resetApolloContext = context.resetApolloContext;
|
|
62
|
+
exports.DocumentType = parser.DocumentType;
|
|
63
|
+
exports.operationName = parser.operationName;
|
|
64
|
+
exports.parser = parser.parser;
|
|
65
|
+
exports.SuspenseCache = SuspenseCache;
|
|
66
|
+
for (var k in hooks) {
|
|
67
|
+
if (k !== 'default' && !exports.hasOwnProperty(k)) exports[k] = hooks[k];
|
|
68
|
+
}
|
|
69
|
+
//# sourceMappingURL=react.cjs.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"react.cjs","sources":["cache/SuspenseCache.js"],"sourcesContent":["import { canonicalStringify } from '../../cache';\nvar SuspenseCache = (function () {\n function SuspenseCache() {\n this.queries = new Map();\n }\n SuspenseCache.prototype.add = function (query, variables, _a) {\n var promise = _a.promise, observable = _a.observable;\n var variablesKey = this.getVariablesKey(variables);\n var map = this.queries.get(query) || new Map();\n var entry = {\n observable: observable,\n fulfilled: false,\n promise: promise\n .catch(function () {\n })\n .finally(function () {\n entry.fulfilled = true;\n }),\n };\n map.set(variablesKey, entry);\n this.queries.set(query, map);\n return entry;\n };\n SuspenseCache.prototype.lookup = function (query, variables) {\n var _a;\n return (_a = this.queries\n .get(query)) === null || _a === void 0 ? void 0 : _a.get(this.getVariablesKey(variables));\n };\n SuspenseCache.prototype.remove = function (query, variables) {\n var map = this.queries.get(query);\n if (!map) {\n return;\n }\n var key = this.getVariablesKey(variables);\n var entry = map.get(key);\n if (entry && !entry.observable.hasObservers()) {\n map.delete(key);\n }\n if (map.size === 0) {\n this.queries.delete(query);\n }\n };\n SuspenseCache.prototype.getVariablesKey = function (variables) {\n return canonicalStringify(variables || Object.create(null));\n };\n return SuspenseCache;\n}());\nexport { SuspenseCache };\n//# sourceMappingURL=SuspenseCache.js.map"],"names":["canonicalStringify"],"mappings":";;;;;;;;;;AACG,IAAC,aAAa,IAAI,YAAY;AACjC,IAAI,SAAS,aAAa,GAAG;AAC7B,QAAQ,IAAI,CAAC,OAAO,GAAG,IAAI,GAAG,EAAE,CAAC;AACjC,KAAK;AACL,IAAI,aAAa,CAAC,SAAS,CAAC,GAAG,GAAG,UAAU,KAAK,EAAE,SAAS,EAAE,EAAE,EAAE;AAClE,QAAQ,IAAI,OAAO,GAAG,EAAE,CAAC,OAAO,EAAE,UAAU,GAAG,EAAE,CAAC,UAAU,CAAC;AAC7D,QAAQ,IAAI,YAAY,GAAG,IAAI,CAAC,eAAe,CAAC,SAAS,CAAC,CAAC;AAC3D,QAAQ,IAAI,GAAG,GAAG,IAAI,CAAC,OAAO,CAAC,GAAG,CAAC,KAAK,CAAC,IAAI,IAAI,GAAG,EAAE,CAAC;AACvD,QAAQ,IAAI,KAAK,GAAG;AACpB,YAAY,UAAU,EAAE,UAAU;AAClC,YAAY,SAAS,EAAE,KAAK;AAC5B,YAAY,OAAO,EAAE,OAAO;AAC5B,iBAAiB,KAAK,CAAC,YAAY;AACnC,aAAa,CAAC;AACd,iBAAiB,OAAO,CAAC,YAAY;AACrC,gBAAgB,KAAK,CAAC,SAAS,GAAG,IAAI,CAAC;AACvC,aAAa,CAAC;AACd,SAAS,CAAC;AACV,QAAQ,GAAG,CAAC,GAAG,CAAC,YAAY,EAAE,KAAK,CAAC,CAAC;AACrC,QAAQ,IAAI,CAAC,OAAO,CAAC,GAAG,CAAC,KAAK,EAAE,GAAG,CAAC,CAAC;AACrC,QAAQ,OAAO,KAAK,CAAC;AACrB,KAAK,CAAC;AACN,IAAI,aAAa,CAAC,SAAS,CAAC,MAAM,GAAG,UAAU,KAAK,EAAE,SAAS,EAAE;AACjE,QAAQ,IAAI,EAAE,CAAC;AACf,QAAQ,OAAO,CAAC,EAAE,GAAG,IAAI,CAAC,OAAO;AACjC,aAAa,GAAG,CAAC,KAAK,CAAC,MAAM,IAAI,IAAI,EAAE,KAAK,KAAK,CAAC,GAAG,KAAK,CAAC,GAAG,EAAE,CAAC,GAAG,CAAC,IAAI,CAAC,eAAe,CAAC,SAAS,CAAC,CAAC,CAAC;AACtG,KAAK,CAAC;AACN,IAAI,aAAa,CAAC,SAAS,CAAC,MAAM,GAAG,UAAU,KAAK,EAAE,SAAS,EAAE;AACjE,QAAQ,IAAI,GAAG,GAAG,IAAI,CAAC,OAAO,CAAC,GAAG,CAAC,KAAK,CAAC,CAAC;AAC1C,QAAQ,IAAI,CAAC,GAAG,EAAE;AAClB,YAAY,OAAO;AACnB,SAAS;AACT,QAAQ,IAAI,GAAG,GAAG,IAAI,CAAC,eAAe,CAAC,SAAS,CAAC,CAAC;AAClD,QAAQ,IAAI,KAAK,GAAG,GAAG,CAAC,GAAG,CAAC,GAAG,CAAC,CAAC;AACjC,QAAQ,IAAI,KAAK,IAAI,CAAC,KAAK,CAAC,UAAU,CAAC,YAAY,EAAE,EAAE;AACvD,YAAY,GAAG,CAAC,MAAM,CAAC,GAAG,CAAC,CAAC;AAC5B,SAAS;AACT,QAAQ,IAAI,GAAG,CAAC,IAAI,KAAK,CAAC,EAAE;AAC5B,YAAY,IAAI,CAAC,OAAO,CAAC,MAAM,CAAC,KAAK,CAAC,CAAC;AACvC,SAAS;AACT,KAAK,CAAC;AACN,IAAI,aAAa,CAAC,SAAS,CAAC,eAAe,GAAG,UAAU,SAAS,EAAE;AACnE,QAAQ,OAAOA,wBAAkB,CAAC,SAAS,IAAI,MAAM,CAAC,MAAM,CAAC,IAAI,CAAC,CAAC,CAAC;AACpE,KAAK,CAAC;AACN,IAAI,OAAO,aAAa,CAAC;AACzB,CAAC,EAAE;;;;;;;;;;;;;;"}
|
|
@@ -0,0 +1,69 @@
|
|
|
1
|
+
'use strict';
|
|
2
|
+
|
|
3
|
+
Object.defineProperty(exports, '__esModule', { value: true });
|
|
4
|
+
|
|
5
|
+
require('../utilities/globals');
|
|
6
|
+
var context = require('./context');
|
|
7
|
+
var hooks = require('./hooks');
|
|
8
|
+
var parser = require('./parser');
|
|
9
|
+
var cache = require('../cache');
|
|
10
|
+
|
|
11
|
+
var SuspenseCache = (function () {
|
|
12
|
+
function SuspenseCache() {
|
|
13
|
+
this.queries = new Map();
|
|
14
|
+
}
|
|
15
|
+
SuspenseCache.prototype.add = function (query, variables, _a) {
|
|
16
|
+
var promise = _a.promise, observable = _a.observable;
|
|
17
|
+
var variablesKey = this.getVariablesKey(variables);
|
|
18
|
+
var map = this.queries.get(query) || new Map();
|
|
19
|
+
var entry = {
|
|
20
|
+
observable: observable,
|
|
21
|
+
fulfilled: false,
|
|
22
|
+
promise: promise
|
|
23
|
+
.catch(function () {
|
|
24
|
+
})
|
|
25
|
+
.finally(function () {
|
|
26
|
+
entry.fulfilled = true;
|
|
27
|
+
}),
|
|
28
|
+
};
|
|
29
|
+
map.set(variablesKey, entry);
|
|
30
|
+
this.queries.set(query, map);
|
|
31
|
+
return entry;
|
|
32
|
+
};
|
|
33
|
+
SuspenseCache.prototype.lookup = function (query, variables) {
|
|
34
|
+
var _a;
|
|
35
|
+
return (_a = this.queries
|
|
36
|
+
.get(query)) === null || _a === void 0 ? void 0 : _a.get(this.getVariablesKey(variables));
|
|
37
|
+
};
|
|
38
|
+
SuspenseCache.prototype.remove = function (query, variables) {
|
|
39
|
+
var map = this.queries.get(query);
|
|
40
|
+
if (!map) {
|
|
41
|
+
return;
|
|
42
|
+
}
|
|
43
|
+
var key = this.getVariablesKey(variables);
|
|
44
|
+
var entry = map.get(key);
|
|
45
|
+
if (entry && !entry.observable.hasObservers()) {
|
|
46
|
+
map.delete(key);
|
|
47
|
+
}
|
|
48
|
+
if (map.size === 0) {
|
|
49
|
+
this.queries.delete(query);
|
|
50
|
+
}
|
|
51
|
+
};
|
|
52
|
+
SuspenseCache.prototype.getVariablesKey = function (variables) {
|
|
53
|
+
return cache.canonicalStringify(variables || Object.create(null));
|
|
54
|
+
};
|
|
55
|
+
return SuspenseCache;
|
|
56
|
+
}());
|
|
57
|
+
|
|
58
|
+
exports.ApolloConsumer = context.ApolloConsumer;
|
|
59
|
+
exports.ApolloProvider = context.ApolloProvider;
|
|
60
|
+
exports.getApolloContext = context.getApolloContext;
|
|
61
|
+
exports.resetApolloContext = context.resetApolloContext;
|
|
62
|
+
exports.DocumentType = parser.DocumentType;
|
|
63
|
+
exports.operationName = parser.operationName;
|
|
64
|
+
exports.parser = parser.parser;
|
|
65
|
+
exports.SuspenseCache = SuspenseCache;
|
|
66
|
+
for (var k in hooks) {
|
|
67
|
+
if (k !== 'default' && !exports.hasOwnProperty(k)) exports[k] = hooks[k];
|
|
68
|
+
}
|
|
69
|
+
//# sourceMappingURL=react.cjs.map
|
|
@@ -0,0 +1,22 @@
|
|
|
1
|
+
/// <reference types="react" />
|
|
2
|
+
import { ObservableQuery, OperationVariables } from '../../core';
|
|
3
|
+
import { QueryDataOptions } from '../types/types';
|
|
4
|
+
interface QueryData {
|
|
5
|
+
getOptions(): any;
|
|
6
|
+
fetchData(): Promise<void>;
|
|
7
|
+
}
|
|
8
|
+
export declare class RenderPromises {
|
|
9
|
+
private queryPromises;
|
|
10
|
+
private queryInfoTrie;
|
|
11
|
+
private stopped;
|
|
12
|
+
stop(): void;
|
|
13
|
+
registerSSRObservable<TData, TVariables extends OperationVariables>(observable: ObservableQuery<any, TVariables>): void;
|
|
14
|
+
getSSRObservable<TData, TVariables extends OperationVariables>(props: QueryDataOptions<TData, TVariables>): ObservableQuery<any, TVariables> | null;
|
|
15
|
+
addQueryPromise(queryInstance: QueryData, finish?: () => React.ReactNode): React.ReactNode;
|
|
16
|
+
addObservableQueryPromise<TData, TVariables extends OperationVariables>(obsQuery: ObservableQuery<TData, TVariables>): import("react").ReactNode;
|
|
17
|
+
hasPromises(): boolean;
|
|
18
|
+
consumeAndAwaitPromises(): Promise<any[]>;
|
|
19
|
+
private lookupQueryInfo;
|
|
20
|
+
}
|
|
21
|
+
export {};
|
|
22
|
+
//# sourceMappingURL=RenderPromises.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"RenderPromises.d.ts","sourceRoot":"","sources":["../../../src/react/ssr/RenderPromises.ts"],"names":[],"mappings":";AAEA,OAAO,EAAE,eAAe,EAAE,kBAAkB,EAAE,MAAM,YAAY,CAAC;AACjE,OAAO,EAAE,gBAAgB,EAAE,MAAM,gBAAgB,CAAC;AAIlD,UAAU,SAAS;IACjB,UAAU,IAAI,GAAG,CAAC;IAClB,SAAS,IAAI,OAAO,CAAC,IAAI,CAAC,CAAC;CAC5B;AAcD,qBAAa,cAAc;IAEzB,OAAO,CAAC,aAAa,CAAuD;IAM5E,OAAO,CAAC,aAAa,CAAmD;IAExE,OAAO,CAAC,OAAO,CAAS;IACjB,IAAI;IASJ,qBAAqB,CAAC,KAAK,EAAE,UAAU,SAAS,kBAAkB,EACvE,UAAU,EAAE,eAAe,CAAC,GAAG,EAAE,UAAU,CAAC;IAOvC,gBAAgB,CAAC,KAAK,EAAE,UAAU,SAAS,kBAAkB,EAClE,KAAK,EAAE,gBAAgB,CAAC,KAAK,EAAE,UAAU,CAAC,GACzC,eAAe,CAAC,GAAG,EAAE,UAAU,CAAC,GAAG,IAAI;IAInC,eAAe,CACpB,aAAa,EAAE,SAAS,EACxB,MAAM,CAAC,EAAE,MAAM,KAAK,CAAC,SAAS,GAC7B,KAAK,CAAC,SAAS;IAkBX,yBAAyB,CAAC,KAAK,EAAE,UAAU,SAAS,kBAAkB,EAC3E,QAAQ,EAAE,eAAe,CAAC,KAAK,EAAE,UAAU,CAAC;IA0BvC,WAAW;IAIX,uBAAuB;IAmB9B,OAAO,CAAC,eAAe;CAYxB"}
|
|
@@ -0,0 +1,90 @@
|
|
|
1
|
+
function makeDefaultQueryInfo() {
|
|
2
|
+
return {
|
|
3
|
+
seen: false,
|
|
4
|
+
observable: null
|
|
5
|
+
};
|
|
6
|
+
}
|
|
7
|
+
var RenderPromises = (function () {
|
|
8
|
+
function RenderPromises() {
|
|
9
|
+
this.queryPromises = new Map();
|
|
10
|
+
this.queryInfoTrie = new Map();
|
|
11
|
+
this.stopped = false;
|
|
12
|
+
}
|
|
13
|
+
RenderPromises.prototype.stop = function () {
|
|
14
|
+
if (!this.stopped) {
|
|
15
|
+
this.queryPromises.clear();
|
|
16
|
+
this.queryInfoTrie.clear();
|
|
17
|
+
this.stopped = true;
|
|
18
|
+
}
|
|
19
|
+
};
|
|
20
|
+
RenderPromises.prototype.registerSSRObservable = function (observable) {
|
|
21
|
+
if (this.stopped)
|
|
22
|
+
return;
|
|
23
|
+
this.lookupQueryInfo(observable.options).observable = observable;
|
|
24
|
+
};
|
|
25
|
+
RenderPromises.prototype.getSSRObservable = function (props) {
|
|
26
|
+
return this.lookupQueryInfo(props).observable;
|
|
27
|
+
};
|
|
28
|
+
RenderPromises.prototype.addQueryPromise = function (queryInstance, finish) {
|
|
29
|
+
if (!this.stopped) {
|
|
30
|
+
var info = this.lookupQueryInfo(queryInstance.getOptions());
|
|
31
|
+
if (!info.seen) {
|
|
32
|
+
this.queryPromises.set(queryInstance.getOptions(), new Promise(function (resolve) {
|
|
33
|
+
resolve(queryInstance.fetchData());
|
|
34
|
+
}));
|
|
35
|
+
return null;
|
|
36
|
+
}
|
|
37
|
+
}
|
|
38
|
+
return finish ? finish() : null;
|
|
39
|
+
};
|
|
40
|
+
RenderPromises.prototype.addObservableQueryPromise = function (obsQuery) {
|
|
41
|
+
return this.addQueryPromise({
|
|
42
|
+
getOptions: function () { return obsQuery.options; },
|
|
43
|
+
fetchData: function () { return new Promise(function (resolve) {
|
|
44
|
+
var sub = obsQuery.subscribe({
|
|
45
|
+
next: function (result) {
|
|
46
|
+
if (!result.loading) {
|
|
47
|
+
resolve();
|
|
48
|
+
sub.unsubscribe();
|
|
49
|
+
}
|
|
50
|
+
},
|
|
51
|
+
error: function () {
|
|
52
|
+
resolve();
|
|
53
|
+
sub.unsubscribe();
|
|
54
|
+
},
|
|
55
|
+
complete: function () {
|
|
56
|
+
resolve();
|
|
57
|
+
},
|
|
58
|
+
});
|
|
59
|
+
}); },
|
|
60
|
+
});
|
|
61
|
+
};
|
|
62
|
+
RenderPromises.prototype.hasPromises = function () {
|
|
63
|
+
return this.queryPromises.size > 0;
|
|
64
|
+
};
|
|
65
|
+
RenderPromises.prototype.consumeAndAwaitPromises = function () {
|
|
66
|
+
var _this = this;
|
|
67
|
+
var promises = [];
|
|
68
|
+
this.queryPromises.forEach(function (promise, queryInstance) {
|
|
69
|
+
_this.lookupQueryInfo(queryInstance).seen = true;
|
|
70
|
+
promises.push(promise);
|
|
71
|
+
});
|
|
72
|
+
this.queryPromises.clear();
|
|
73
|
+
return Promise.all(promises);
|
|
74
|
+
};
|
|
75
|
+
RenderPromises.prototype.lookupQueryInfo = function (props) {
|
|
76
|
+
var queryInfoTrie = this.queryInfoTrie;
|
|
77
|
+
var query = props.query, variables = props.variables;
|
|
78
|
+
var varMap = queryInfoTrie.get(query) || new Map();
|
|
79
|
+
if (!queryInfoTrie.has(query))
|
|
80
|
+
queryInfoTrie.set(query, varMap);
|
|
81
|
+
var variablesString = JSON.stringify(variables);
|
|
82
|
+
var info = varMap.get(variablesString) || makeDefaultQueryInfo();
|
|
83
|
+
if (!varMap.has(variablesString))
|
|
84
|
+
varMap.set(variablesString, info);
|
|
85
|
+
return info;
|
|
86
|
+
};
|
|
87
|
+
return RenderPromises;
|
|
88
|
+
}());
|
|
89
|
+
export { RenderPromises };
|
|
90
|
+
//# sourceMappingURL=RenderPromises.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"RenderPromises.js","sourceRoot":"","sources":["../../../src/react/ssr/RenderPromises.ts"],"names":[],"mappings":"AAiBA,SAAS,oBAAoB;IAC3B,OAAO;QACL,IAAI,EAAE,KAAK;QACX,UAAU,EAAE,IAAI;KACjB,CAAC;AACJ,CAAC;AAED;IAAA;QAEU,kBAAa,GAAG,IAAI,GAAG,EAA4C,CAAC;QAMpE,kBAAa,GAAG,IAAI,GAAG,EAAwC,CAAC;QAEhE,YAAO,GAAG,KAAK,CAAC;IA2G1B,CAAC;IA1GQ,6BAAI,GAAX;QACE,IAAI,CAAC,IAAI,CAAC,OAAO,EAAE;YACjB,IAAI,CAAC,aAAa,CAAC,KAAK,EAAE,CAAC;YAC3B,IAAI,CAAC,aAAa,CAAC,KAAK,EAAE,CAAC;YAC3B,IAAI,CAAC,OAAO,GAAG,IAAI,CAAC;SACrB;IACH,CAAC;IAGM,8CAAqB,GAA5B,UACE,UAA4C;QAE5C,IAAI,IAAI,CAAC,OAAO;YAAE,OAAO;QACzB,IAAI,CAAC,eAAe,CAAC,UAAU,CAAC,OAAO,CAAC,CAAC,UAAU,GAAG,UAAU,CAAC;IACnE,CAAC;IAGM,yCAAgB,GAAvB,UACE,KAA0C;QAE1C,OAAO,IAAI,CAAC,eAAe,CAAC,KAAK,CAAC,CAAC,UAAU,CAAC;IAChD,CAAC;IAEM,wCAAe,GAAtB,UACE,aAAwB,EACxB,MAA8B;QAE9B,IAAI,CAAC,IAAI,CAAC,OAAO,EAAE;YACjB,IAAM,IAAI,GAAG,IAAI,CAAC,eAAe,CAAC,aAAa,CAAC,UAAU,EAAE,CAAC,CAAC;YAC9D,IAAI,CAAC,IAAI,CAAC,IAAI,EAAE;gBACd,IAAI,CAAC,aAAa,CAAC,GAAG,CACpB,aAAa,CAAC,UAAU,EAAE,EAC1B,IAAI,OAAO,CAAC,UAAA,OAAO;oBACjB,OAAO,CAAC,aAAa,CAAC,SAAS,EAAE,CAAC,CAAC;gBACrC,CAAC,CAAC,CACH,CAAC;gBAGF,OAAO,IAAI,CAAC;aACb;SACF;QACD,OAAO,MAAM,CAAC,CAAC,CAAC,MAAM,EAAE,CAAC,CAAC,CAAC,IAAI,CAAC;IAClC,CAAC;IAEM,kDAAyB,GAAhC,UACE,QAA4C;QAE5C,OAAO,IAAI,CAAC,eAAe,CAAC;YAG1B,UAAU,EAAE,cAAM,OAAA,QAAQ,CAAC,OAAO,EAAhB,CAAgB;YAClC,SAAS,EAAE,cAAM,OAAA,IAAI,OAAO,CAAO,UAAC,OAAO;gBACzC,IAAM,GAAG,GAAG,QAAQ,CAAC,SAAS,CAAC;oBAC7B,IAAI,YAAC,MAAM;wBACT,IAAI,CAAC,MAAM,CAAC,OAAO,EAAE;4BACnB,OAAO,EAAE,CAAA;4BACT,GAAG,CAAC,WAAW,EAAE,CAAC;yBACnB;oBACH,CAAC;oBACD,KAAK;wBACH,OAAO,EAAE,CAAC;wBACV,GAAG,CAAC,WAAW,EAAE,CAAC;oBACpB,CAAC;oBACD,QAAQ;wBACN,OAAO,EAAE,CAAC;oBACZ,CAAC;iBACF,CAAC,CAAC;YACL,CAAC,CAAC,EAhBe,CAgBf;SACH,CAAC,CAAC;IACL,CAAC;IAEM,oCAAW,GAAlB;QACE,OAAO,IAAI,CAAC,aAAa,CAAC,IAAI,GAAG,CAAC,CAAC;IACrC,CAAC;IAEM,gDAAuB,GAA9B;QAAA,iBAiBC;QAhBC,IAAM,QAAQ,GAAmB,EAAE,CAAC;QACpC,IAAI,CAAC,aAAa,CAAC,OAAO,CAAC,UAAC,OAAO,EAAE,aAAa;YAUhD,KAAI,CAAC,eAAe,CAAC,aAAa,CAAC,CAAC,IAAI,GAAG,IAAI,CAAC;YAChD,QAAQ,CAAC,IAAI,CAAC,OAAO,CAAC,CAAC;QACzB,CAAC,CAAC,CAAC;QACH,IAAI,CAAC,aAAa,CAAC,KAAK,EAAE,CAAC;QAC3B,OAAO,OAAO,CAAC,GAAG,CAAC,QAAQ,CAAC,CAAC;IAC/B,CAAC;IAEO,wCAAe,GAAvB,UACE,KAA0C;QAElC,IAAA,aAAa,GAAK,IAAI,cAAT,CAAU;QACvB,IAAA,KAAK,GAAgB,KAAK,MAArB,EAAE,SAAS,GAAK,KAAK,UAAV,CAAW;QACnC,IAAM,MAAM,GAAG,aAAa,CAAC,GAAG,CAAC,KAAK,CAAC,IAAI,IAAI,GAAG,EAAqB,CAAC;QACxE,IAAI,CAAC,aAAa,CAAC,GAAG,CAAC,KAAK,CAAC;YAAE,aAAa,CAAC,GAAG,CAAC,KAAK,EAAE,MAAM,CAAC,CAAC;QAChE,IAAM,eAAe,GAAG,IAAI,CAAC,SAAS,CAAC,SAAS,CAAC,CAAC;QAClD,IAAM,IAAI,GAAG,MAAM,CAAC,GAAG,CAAC,eAAe,CAAC,IAAI,oBAAoB,EAAE,CAAC;QACnE,IAAI,CAAC,MAAM,CAAC,GAAG,CAAC,eAAe,CAAC;YAAE,MAAM,CAAC,GAAG,CAAC,eAAe,EAAE,IAAI,CAAC,CAAC;QACpE,OAAO,IAAI,CAAC;IACd,CAAC;IACH,qBAAC;AAAD,CAAC,AArHD,IAqHC","sourcesContent":["import { DocumentNode } from 'graphql';\n\nimport { ObservableQuery, OperationVariables } from '../../core';\nimport { QueryDataOptions } from '../types/types';\n\n// TODO: A vestigial interface from when hooks were implemented with utility\n// classes, which should be deleted in the future.\ninterface QueryData {\n getOptions(): any;\n fetchData(): Promise<void>;\n}\n\ntype QueryInfo = {\n seen: boolean;\n observable: ObservableQuery<any, any> | null;\n};\n\nfunction makeDefaultQueryInfo(): QueryInfo {\n return {\n seen: false,\n observable: null\n };\n}\n\nexport class RenderPromises {\n // Map from Query component instances to pending fetchData promises.\n private queryPromises = new Map<QueryDataOptions<any, any>, Promise<any>>();\n\n // Two-layered map from (query document, stringified variables) to QueryInfo\n // objects. These QueryInfo objects are intended to survive through the whole\n // getMarkupFromTree process, whereas specific Query instances do not survive\n // beyond a single call to renderToStaticMarkup.\n private queryInfoTrie = new Map<DocumentNode, Map<string, QueryInfo>>();\n\n private stopped = false;\n public stop() {\n if (!this.stopped) {\n this.queryPromises.clear();\n this.queryInfoTrie.clear();\n this.stopped = true;\n }\n }\n\n // Registers the server side rendered observable.\n public registerSSRObservable<TData, TVariables extends OperationVariables>(\n observable: ObservableQuery<any, TVariables>,\n ) {\n if (this.stopped) return;\n this.lookupQueryInfo(observable.options).observable = observable;\n }\n\n // Get's the cached observable that matches the SSR Query instances query and variables.\n public getSSRObservable<TData, TVariables extends OperationVariables>(\n props: QueryDataOptions<TData, TVariables>\n ): ObservableQuery<any, TVariables> | null {\n return this.lookupQueryInfo(props).observable;\n }\n\n public addQueryPromise(\n queryInstance: QueryData,\n finish?: () => React.ReactNode,\n ): React.ReactNode {\n if (!this.stopped) {\n const info = this.lookupQueryInfo(queryInstance.getOptions());\n if (!info.seen) {\n this.queryPromises.set(\n queryInstance.getOptions(),\n new Promise(resolve => {\n resolve(queryInstance.fetchData());\n })\n );\n // Render null to abandon this subtree for this rendering, so that we\n // can wait for the data to arrive.\n return null;\n }\n }\n return finish ? finish() : null;\n }\n\n public addObservableQueryPromise<TData, TVariables extends OperationVariables>(\n obsQuery: ObservableQuery<TData, TVariables>,\n ) {\n return this.addQueryPromise({\n // The only options which seem to actually be used by the\n // RenderPromises class are query and variables.\n getOptions: () => obsQuery.options,\n fetchData: () => new Promise<void>((resolve) => {\n const sub = obsQuery.subscribe({\n next(result) {\n if (!result.loading) {\n resolve()\n sub.unsubscribe();\n }\n },\n error() {\n resolve();\n sub.unsubscribe();\n },\n complete() {\n resolve();\n },\n });\n }),\n });\n }\n\n public hasPromises() {\n return this.queryPromises.size > 0;\n }\n\n public consumeAndAwaitPromises() {\n const promises: Promise<any>[] = [];\n this.queryPromises.forEach((promise, queryInstance) => {\n // Make sure we never try to call fetchData for this query document and\n // these variables again. Since the queryInstance objects change with\n // every rendering, deduplicating them by query and variables is the\n // best we can do. If a different Query component happens to have the\n // same query document and variables, it will be immediately rendered\n // by calling finish() in addQueryPromise, which could result in the\n // rendering of an unwanted loading state, but that's not nearly as bad\n // as getting stuck in an infinite rendering loop because we kept calling\n // queryInstance.fetchData for the same Query component indefinitely.\n this.lookupQueryInfo(queryInstance).seen = true;\n promises.push(promise);\n });\n this.queryPromises.clear();\n return Promise.all(promises);\n }\n\n private lookupQueryInfo<TData, TVariables extends OperationVariables>(\n props: QueryDataOptions<TData, TVariables>\n ): QueryInfo {\n const { queryInfoTrie } = this;\n const { query, variables } = props;\n const varMap = queryInfoTrie.get(query) || new Map<string, QueryInfo>();\n if (!queryInfoTrie.has(query)) queryInfoTrie.set(query, varMap);\n const variablesString = JSON.stringify(variables);\n const info = varMap.get(variablesString) || makeDefaultQueryInfo();\n if (!varMap.has(variablesString)) varMap.set(variablesString, info);\n return info;\n }\n}\n"]}
|
|
@@ -0,0 +1,13 @@
|
|
|
1
|
+
import * as React from 'react';
|
|
2
|
+
export declare function getDataFromTree(tree: React.ReactNode, context?: {
|
|
3
|
+
[key: string]: any;
|
|
4
|
+
}): Promise<string>;
|
|
5
|
+
export type GetMarkupFromTreeOptions = {
|
|
6
|
+
tree: React.ReactNode;
|
|
7
|
+
context?: {
|
|
8
|
+
[key: string]: any;
|
|
9
|
+
};
|
|
10
|
+
renderFunction?: (tree: React.ReactElement<any>) => string | PromiseLike<string>;
|
|
11
|
+
};
|
|
12
|
+
export declare function getMarkupFromTree({ tree, context, renderFunction }: GetMarkupFromTreeOptions): Promise<string>;
|
|
13
|
+
//# sourceMappingURL=getDataFromTree.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"getDataFromTree.d.ts","sourceRoot":"","sources":["../../../src/react/ssr/getDataFromTree.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,KAAK,MAAM,OAAO,CAAC;AAK/B,wBAAgB,eAAe,CAC7B,IAAI,EAAE,KAAK,CAAC,SAAS,EACrB,OAAO,GAAE;IAAE,CAAC,GAAG,EAAE,MAAM,GAAG,GAAG,CAAA;CAAO,mBASrC;AAED,MAAM,MAAM,wBAAwB,GAAG;IACrC,IAAI,EAAE,KAAK,CAAC,SAAS,CAAC;IACtB,OAAO,CAAC,EAAE;QAAE,CAAC,GAAG,EAAE,MAAM,GAAG,GAAG,CAAA;KAAE,CAAC;IACjC,cAAc,CAAC,EAAE,CACf,IAAI,EAAE,KAAK,CAAC,YAAY,CAAC,GAAG,CAAC,KAC1B,MAAM,GAAG,WAAW,CAAC,MAAM,CAAC,CAAC;CACnC,CAAC;AAEF,wBAAgB,iBAAiB,CAAC,EAChC,IAAI,EACJ,OAAY,EAIZ,cAAqC,EACtC,EAAE,wBAAwB,GAAG,OAAO,CAAC,MAAM,CAAC,CA4B5C"}
|
|
@@ -0,0 +1,32 @@
|
|
|
1
|
+
import { __assign } from "tslib";
|
|
2
|
+
import * as React from 'react';
|
|
3
|
+
import { getApolloContext } from "../context/index.js";
|
|
4
|
+
import { RenderPromises } from "./RenderPromises.js";
|
|
5
|
+
import { renderToStaticMarkup } from 'react-dom/server';
|
|
6
|
+
export function getDataFromTree(tree, context) {
|
|
7
|
+
if (context === void 0) { context = {}; }
|
|
8
|
+
return getMarkupFromTree({
|
|
9
|
+
tree: tree,
|
|
10
|
+
context: context,
|
|
11
|
+
renderFunction: renderToStaticMarkup
|
|
12
|
+
});
|
|
13
|
+
}
|
|
14
|
+
export function getMarkupFromTree(_a) {
|
|
15
|
+
var tree = _a.tree, _b = _a.context, context = _b === void 0 ? {} : _b, _c = _a.renderFunction, renderFunction = _c === void 0 ? renderToStaticMarkup : _c;
|
|
16
|
+
var renderPromises = new RenderPromises();
|
|
17
|
+
function process() {
|
|
18
|
+
var ApolloContext = getApolloContext();
|
|
19
|
+
return new Promise(function (resolve) {
|
|
20
|
+
var element = React.createElement(ApolloContext.Provider, { value: __assign(__assign({}, context), { renderPromises: renderPromises }) }, tree);
|
|
21
|
+
resolve(renderFunction(element));
|
|
22
|
+
}).then(function (html) {
|
|
23
|
+
return renderPromises.hasPromises()
|
|
24
|
+
? renderPromises.consumeAndAwaitPromises().then(process)
|
|
25
|
+
: html;
|
|
26
|
+
}).finally(function () {
|
|
27
|
+
renderPromises.stop();
|
|
28
|
+
});
|
|
29
|
+
}
|
|
30
|
+
return Promise.resolve().then(process);
|
|
31
|
+
}
|
|
32
|
+
//# sourceMappingURL=getDataFromTree.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"getDataFromTree.js","sourceRoot":"","sources":["../../../src/react/ssr/getDataFromTree.ts"],"names":[],"mappings":";AAAA,OAAO,KAAK,KAAK,MAAM,OAAO,CAAC;AAC/B,OAAO,EAAE,gBAAgB,EAAE,MAAM,YAAY,CAAC;AAC9C,OAAO,EAAE,cAAc,EAAE,MAAM,kBAAkB,CAAC;AAClD,OAAO,EAAE,oBAAoB,EAAE,MAAM,kBAAkB,CAAC;AAExD,MAAM,UAAU,eAAe,CAC7B,IAAqB,EACrB,OAAoC;IAApC,wBAAA,EAAA,YAAoC;IAEpC,OAAO,iBAAiB,CAAC;QACvB,IAAI,MAAA;QACJ,OAAO,SAAA;QAGP,cAAc,EAAE,oBAAoB;KACrC,CAAC,CAAC;AACL,CAAC;AAUD,MAAM,UAAU,iBAAiB,CAAC,EAOP;QANzB,IAAI,UAAA,EACJ,eAAY,EAAZ,OAAO,mBAAG,EAAE,KAAA,EAIZ,sBAAqC,EAArC,cAAc,mBAAG,oBAAoB,KAAA;IAErC,IAAM,cAAc,GAAG,IAAI,cAAc,EAAE,CAAC;IAE5C,SAAS,OAAO;QAMd,IAAM,aAAa,GAAG,gBAAgB,EAAE,CAAC;QAEzC,OAAO,IAAI,OAAO,CAAS,UAAA,OAAO;YAChC,IAAM,OAAO,GAAG,KAAK,CAAC,aAAa,CACjC,aAAa,CAAC,QAAQ,EACtB,EAAE,KAAK,wBAAO,OAAO,KAAE,cAAc,gBAAA,GAAE,EAAC,EACxC,IAAI,CACL,CAAC;YACF,OAAO,CAAC,cAAc,CAAC,OAAO,CAAC,CAAC,CAAC;QACnC,CAAC,CAAC,CAAC,IAAI,CAAC,UAAA,IAAI;YACV,OAAO,cAAc,CAAC,WAAW,EAAE;gBACjC,CAAC,CAAC,cAAc,CAAC,uBAAuB,EAAE,CAAC,IAAI,CAAC,OAAO,CAAC;gBACxD,CAAC,CAAC,IAAI,CAAC;QACX,CAAC,CAAC,CAAC,OAAO,CAAC;YACT,cAAc,CAAC,IAAI,EAAE,CAAC;QACxB,CAAC,CAAC,CAAC;IACL,CAAC;IAED,OAAO,OAAO,CAAC,OAAO,EAAE,CAAC,IAAI,CAAC,OAAO,CAAC,CAAC;AACzC,CAAC","sourcesContent":["import * as React from 'react';\nimport { getApolloContext } from '../context';\nimport { RenderPromises } from './RenderPromises';\nimport { renderToStaticMarkup } from 'react-dom/server';\n\nexport function getDataFromTree(\n tree: React.ReactNode,\n context: { [key: string]: any } = {}\n) {\n return getMarkupFromTree({\n tree,\n context,\n // If you need to configure this renderFunction, call getMarkupFromTree\n // directly instead of getDataFromTree.\n renderFunction: renderToStaticMarkup\n });\n}\n\nexport type GetMarkupFromTreeOptions = {\n tree: React.ReactNode;\n context?: { [key: string]: any };\n renderFunction?: (\n tree: React.ReactElement<any>,\n ) => string | PromiseLike<string>;\n};\n\nexport function getMarkupFromTree({\n tree,\n context = {},\n // The rendering function is configurable! We use renderToStaticMarkup as\n // the default, because it's a little less expensive than renderToString,\n // and legacy usage of getDataFromTree ignores the return value anyway.\n renderFunction = renderToStaticMarkup\n}: GetMarkupFromTreeOptions): Promise<string> {\n const renderPromises = new RenderPromises();\n\n function process(): Promise<string> {\n // Always re-render from the rootElement, even though it might seem\n // better to render the children of the component responsible for the\n // promise, because it is not possible to reconstruct the full context\n // of the original rendering (including all unknown context provider\n // elements) for a subtree of the original component tree.\n const ApolloContext = getApolloContext();\n\n return new Promise<string>(resolve => {\n const element = React.createElement(\n ApolloContext.Provider,\n { value: { ...context, renderPromises }},\n tree,\n );\n resolve(renderFunction(element));\n }).then(html => {\n return renderPromises.hasPromises()\n ? renderPromises.consumeAndAwaitPromises().then(process)\n : html;\n }).finally(() => {\n renderPromises.stop();\n });\n }\n\n return Promise.resolve().then(process);\n}\n"]}
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../../src/react/ssr/index.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,iBAAiB,EAAE,eAAe,EAAE,MAAM,mBAAmB,CAAC;AACvE,OAAO,EAAE,sBAAsB,EAAE,MAAM,0BAA0B,CAAC;AAClE,OAAO,EAAE,cAAc,EAAE,MAAM,kBAAkB,CAAC"}
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"index.js","sourceRoot":"","sources":["../../../src/react/ssr/index.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,iBAAiB,EAAE,eAAe,EAAE,MAAM,mBAAmB,CAAC;AACvE,OAAO,EAAE,sBAAsB,EAAE,MAAM,0BAA0B,CAAC;AAClE,OAAO,EAAE,cAAc,EAAE,MAAM,kBAAkB,CAAC","sourcesContent":["export { getMarkupFromTree, getDataFromTree } from './getDataFromTree';\nexport { renderToStringWithData } from './renderToStringWithData';\nexport { RenderPromises } from './RenderPromises';\n"]}
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"renderToStringWithData.d.ts","sourceRoot":"","sources":["../../../src/react/ssr/renderToStringWithData.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,YAAY,EAAE,MAAM,OAAO,CAAC;AAIrC,wBAAgB,sBAAsB,CACpC,SAAS,EAAE,YAAY,CAAC,GAAG,CAAC,GAC3B,OAAO,CAAC,MAAM,CAAC,CAKjB"}
|
|
@@ -0,0 +1,9 @@
|
|
|
1
|
+
import { getMarkupFromTree } from "./getDataFromTree.js";
|
|
2
|
+
import { renderToString } from 'react-dom/server';
|
|
3
|
+
export function renderToStringWithData(component) {
|
|
4
|
+
return getMarkupFromTree({
|
|
5
|
+
tree: component,
|
|
6
|
+
renderFunction: renderToString
|
|
7
|
+
});
|
|
8
|
+
}
|
|
9
|
+
//# sourceMappingURL=renderToStringWithData.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"renderToStringWithData.js","sourceRoot":"","sources":["../../../src/react/ssr/renderToStringWithData.ts"],"names":[],"mappings":"AACA,OAAO,EAAE,iBAAiB,EAAE,MAAM,mBAAmB,CAAC;AACtD,OAAO,EAAE,cAAc,EAAE,MAAM,kBAAkB,CAAC;AAElD,MAAM,UAAU,sBAAsB,CACpC,SAA4B;IAE5B,OAAO,iBAAiB,CAAC;QACvB,IAAI,EAAE,SAAS;QACf,cAAc,EAAE,cAAc;KAC/B,CAAC,CAAC;AACL,CAAC","sourcesContent":["import { ReactElement } from 'react';\nimport { getMarkupFromTree } from './getDataFromTree';\nimport { renderToString } from 'react-dom/server';\n\nexport function renderToStringWithData(\n component: ReactElement<any>\n): Promise<string> {\n return getMarkupFromTree({\n tree: component,\n renderFunction: renderToString\n });\n}\n"]}
|
|
@@ -0,0 +1,151 @@
|
|
|
1
|
+
'use strict';
|
|
2
|
+
|
|
3
|
+
Object.defineProperty(exports, '__esModule', { value: true });
|
|
4
|
+
|
|
5
|
+
var tslib = require('tslib');
|
|
6
|
+
var React = require('react');
|
|
7
|
+
var context = require('../context');
|
|
8
|
+
var server = require('react-dom/server');
|
|
9
|
+
|
|
10
|
+
function _interopNamespace(e) {
|
|
11
|
+
if (e && e.__esModule) return e;
|
|
12
|
+
var n = Object.create(null);
|
|
13
|
+
if (e) {
|
|
14
|
+
for (var k in e) {
|
|
15
|
+
n[k] = e[k];
|
|
16
|
+
}
|
|
17
|
+
}
|
|
18
|
+
n["default"] = e;
|
|
19
|
+
return Object.freeze(n);
|
|
20
|
+
}
|
|
21
|
+
|
|
22
|
+
var React__namespace = /*#__PURE__*/_interopNamespace(React);
|
|
23
|
+
|
|
24
|
+
function makeDefaultQueryInfo() {
|
|
25
|
+
return {
|
|
26
|
+
seen: false,
|
|
27
|
+
observable: null
|
|
28
|
+
};
|
|
29
|
+
}
|
|
30
|
+
var RenderPromises = (function () {
|
|
31
|
+
function RenderPromises() {
|
|
32
|
+
this.queryPromises = new Map();
|
|
33
|
+
this.queryInfoTrie = new Map();
|
|
34
|
+
this.stopped = false;
|
|
35
|
+
}
|
|
36
|
+
RenderPromises.prototype.stop = function () {
|
|
37
|
+
if (!this.stopped) {
|
|
38
|
+
this.queryPromises.clear();
|
|
39
|
+
this.queryInfoTrie.clear();
|
|
40
|
+
this.stopped = true;
|
|
41
|
+
}
|
|
42
|
+
};
|
|
43
|
+
RenderPromises.prototype.registerSSRObservable = function (observable) {
|
|
44
|
+
if (this.stopped)
|
|
45
|
+
return;
|
|
46
|
+
this.lookupQueryInfo(observable.options).observable = observable;
|
|
47
|
+
};
|
|
48
|
+
RenderPromises.prototype.getSSRObservable = function (props) {
|
|
49
|
+
return this.lookupQueryInfo(props).observable;
|
|
50
|
+
};
|
|
51
|
+
RenderPromises.prototype.addQueryPromise = function (queryInstance, finish) {
|
|
52
|
+
if (!this.stopped) {
|
|
53
|
+
var info = this.lookupQueryInfo(queryInstance.getOptions());
|
|
54
|
+
if (!info.seen) {
|
|
55
|
+
this.queryPromises.set(queryInstance.getOptions(), new Promise(function (resolve) {
|
|
56
|
+
resolve(queryInstance.fetchData());
|
|
57
|
+
}));
|
|
58
|
+
return null;
|
|
59
|
+
}
|
|
60
|
+
}
|
|
61
|
+
return finish ? finish() : null;
|
|
62
|
+
};
|
|
63
|
+
RenderPromises.prototype.addObservableQueryPromise = function (obsQuery) {
|
|
64
|
+
return this.addQueryPromise({
|
|
65
|
+
getOptions: function () { return obsQuery.options; },
|
|
66
|
+
fetchData: function () { return new Promise(function (resolve) {
|
|
67
|
+
var sub = obsQuery.subscribe({
|
|
68
|
+
next: function (result) {
|
|
69
|
+
if (!result.loading) {
|
|
70
|
+
resolve();
|
|
71
|
+
sub.unsubscribe();
|
|
72
|
+
}
|
|
73
|
+
},
|
|
74
|
+
error: function () {
|
|
75
|
+
resolve();
|
|
76
|
+
sub.unsubscribe();
|
|
77
|
+
},
|
|
78
|
+
complete: function () {
|
|
79
|
+
resolve();
|
|
80
|
+
},
|
|
81
|
+
});
|
|
82
|
+
}); },
|
|
83
|
+
});
|
|
84
|
+
};
|
|
85
|
+
RenderPromises.prototype.hasPromises = function () {
|
|
86
|
+
return this.queryPromises.size > 0;
|
|
87
|
+
};
|
|
88
|
+
RenderPromises.prototype.consumeAndAwaitPromises = function () {
|
|
89
|
+
var _this = this;
|
|
90
|
+
var promises = [];
|
|
91
|
+
this.queryPromises.forEach(function (promise, queryInstance) {
|
|
92
|
+
_this.lookupQueryInfo(queryInstance).seen = true;
|
|
93
|
+
promises.push(promise);
|
|
94
|
+
});
|
|
95
|
+
this.queryPromises.clear();
|
|
96
|
+
return Promise.all(promises);
|
|
97
|
+
};
|
|
98
|
+
RenderPromises.prototype.lookupQueryInfo = function (props) {
|
|
99
|
+
var queryInfoTrie = this.queryInfoTrie;
|
|
100
|
+
var query = props.query, variables = props.variables;
|
|
101
|
+
var varMap = queryInfoTrie.get(query) || new Map();
|
|
102
|
+
if (!queryInfoTrie.has(query))
|
|
103
|
+
queryInfoTrie.set(query, varMap);
|
|
104
|
+
var variablesString = JSON.stringify(variables);
|
|
105
|
+
var info = varMap.get(variablesString) || makeDefaultQueryInfo();
|
|
106
|
+
if (!varMap.has(variablesString))
|
|
107
|
+
varMap.set(variablesString, info);
|
|
108
|
+
return info;
|
|
109
|
+
};
|
|
110
|
+
return RenderPromises;
|
|
111
|
+
}());
|
|
112
|
+
|
|
113
|
+
function getDataFromTree(tree, context) {
|
|
114
|
+
if (context === void 0) { context = {}; }
|
|
115
|
+
return getMarkupFromTree({
|
|
116
|
+
tree: tree,
|
|
117
|
+
context: context,
|
|
118
|
+
renderFunction: server.renderToStaticMarkup
|
|
119
|
+
});
|
|
120
|
+
}
|
|
121
|
+
function getMarkupFromTree(_a) {
|
|
122
|
+
var tree = _a.tree, _b = _a.context, context$1 = _b === void 0 ? {} : _b, _c = _a.renderFunction, renderFunction = _c === void 0 ? server.renderToStaticMarkup : _c;
|
|
123
|
+
var renderPromises = new RenderPromises();
|
|
124
|
+
function process() {
|
|
125
|
+
var ApolloContext = context.getApolloContext();
|
|
126
|
+
return new Promise(function (resolve) {
|
|
127
|
+
var element = React__namespace.createElement(ApolloContext.Provider, { value: tslib.__assign(tslib.__assign({}, context$1), { renderPromises: renderPromises }) }, tree);
|
|
128
|
+
resolve(renderFunction(element));
|
|
129
|
+
}).then(function (html) {
|
|
130
|
+
return renderPromises.hasPromises()
|
|
131
|
+
? renderPromises.consumeAndAwaitPromises().then(process)
|
|
132
|
+
: html;
|
|
133
|
+
}).finally(function () {
|
|
134
|
+
renderPromises.stop();
|
|
135
|
+
});
|
|
136
|
+
}
|
|
137
|
+
return Promise.resolve().then(process);
|
|
138
|
+
}
|
|
139
|
+
|
|
140
|
+
function renderToStringWithData(component) {
|
|
141
|
+
return getMarkupFromTree({
|
|
142
|
+
tree: component,
|
|
143
|
+
renderFunction: server.renderToString
|
|
144
|
+
});
|
|
145
|
+
}
|
|
146
|
+
|
|
147
|
+
exports.RenderPromises = RenderPromises;
|
|
148
|
+
exports.getDataFromTree = getDataFromTree;
|
|
149
|
+
exports.getMarkupFromTree = getMarkupFromTree;
|
|
150
|
+
exports.renderToStringWithData = renderToStringWithData;
|
|
151
|
+
//# sourceMappingURL=ssr.cjs.map
|