@apollo/client 3.9.6 → 3.9.8
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/CHANGELOG.md +20 -0
- package/apollo-client.cjs +41 -34
- package/apollo-client.cjs.map +1 -1
- package/apollo-client.min.cjs +1 -1
- package/core/ApolloClient.d.ts +7 -7
- package/core/ApolloClient.js +6 -6
- package/core/ApolloClient.js.map +1 -1
- package/core/LocalState.js +13 -13
- package/core/LocalState.js.map +1 -1
- package/core/QueryManager.js +7 -7
- package/core/QueryManager.js.map +1 -1
- package/core/core.cjs +21 -21
- package/core/core.cjs.map +1 -1
- package/core/core.cjs.native.js +21 -21
- package/core/watchQueryOptions.d.ts +3 -3
- package/dev/dev.cjs +18 -15
- package/dev/dev.cjs.map +1 -1
- package/dev/dev.cjs.native.js +18 -15
- package/dev/index.d.ts +2 -0
- package/dev/index.js +1 -0
- package/dev/index.js.map +1 -1
- package/dev/loadErrorMessageHandler.d.ts +6 -1
- package/dev/loadErrorMessageHandler.js +17 -14
- package/dev/loadErrorMessageHandler.js.map +1 -1
- package/dev/setErrorMessageHandler.d.ts +34 -0
- package/dev/setErrorMessageHandler.js +9 -0
- package/dev/setErrorMessageHandler.js.map +1 -0
- package/link/http/http.cjs +11 -8
- package/link/http/http.cjs.map +1 -1
- package/link/http/http.cjs.native.js +11 -8
- package/link/http/parseAndCheckHttpResponse.js +11 -8
- package/link/http/parseAndCheckHttpResponse.js.map +1 -1
- package/package.json +24 -24
- package/react/hooks/hooks.cjs +4 -1
- package/react/hooks/hooks.cjs.map +1 -1
- package/react/hooks/hooks.cjs.native.js +4 -1
- package/react/hooks/internal/useRenderGuard.js +1 -1
- package/react/hooks/internal/useRenderGuard.js.map +1 -1
- package/react/hooks/useFragment.d.ts +1 -1
- package/react/hooks/useFragment.js +5 -0
- package/react/hooks/useFragment.js.map +1 -1
- package/react/internal/cache/QueryReference.d.ts +2 -2
- package/react/internal/cache/QueryReference.js +13 -4
- package/react/internal/cache/QueryReference.js.map +1 -1
- package/react/internal/internal.cjs +5 -4
- package/react/internal/internal.cjs.map +1 -1
- package/react/internal/internal.cjs.native.js +5 -4
- package/react/query-preloader/createQueryPreloader.d.ts +6 -6
- package/react/query-preloader/createQueryPreloader.js.map +1 -1
- package/react/types/types.d.ts +3 -3
- package/react/types/types.documentation.d.ts +4 -4
- package/react/types/types.documentation.js.map +1 -1
- package/testing/internal/ObservableStream.js +3 -3
- package/testing/internal/ObservableStream.js.map +1 -1
- package/testing/internal/profile/profile.js +6 -6
- package/testing/internal/profile/profile.js.map +1 -1
- package/utilities/globals/globals.cjs +1 -1
- package/utilities/globals/globals.cjs.map +1 -1
- package/utilities/globals/globals.cjs.native.js +1 -1
- package/utilities/globals/invariantWrappers.d.ts +1 -1
- package/utilities/globals/invariantWrappers.js.map +1 -1
- package/utilities/subscriptions/relay/relay.cjs +11 -8
- package/utilities/subscriptions/relay/relay.cjs.map +1 -1
- package/utilities/subscriptions/relay/relay.cjs.native.js +11 -8
- package/utilities/subscriptions/urql/urql.cjs +11 -8
- package/utilities/subscriptions/urql/urql.cjs.map +1 -1
- package/utilities/subscriptions/urql/urql.cjs.native.js +11 -8
- package/version.js +1 -1
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"types.documentation.js","sourceRoot":"","sources":["../../../src/react/types/types.documentation.ts"],"names":[],"mappings":"","sourcesContent":["export interface QueryOptionsDocumentation {\n /**\n * A GraphQL query string parsed into an AST with the gql template literal.\n *\n * @docGroup 1. Operation options\n */\n query: unknown;\n\n /**\n * An object containing all of the GraphQL variables your query requires to execute.\n *\n * Each key in the object corresponds to a variable name, and that key's value corresponds to the variable value.\n *\n * @docGroup 1. Operation options\n */\n variables: unknown;\n\n /**\n * Specifies how the query handles a response that returns both GraphQL errors and partial results.\n *\n * For details, see [GraphQL error policies](https://www.apollographql.com/docs/react/data/error-handling/#graphql-error-policies).\n *\n * The default value is `none`, meaning that the query result includes error details but not partial results.\n *\n * @docGroup 1. Operation options\n */\n errorPolicy: unknown;\n\n /**\n * If you're using [Apollo Link](https://www.apollographql.com/docs/react/api/link/introduction/), this object is the initial value of the `context` object that's passed along your link chain.\n *\n * @docGroup 2. Networking options\n */\n context: unknown;\n\n /**\n * Specifies how the query interacts with the Apollo Client cache during execution (for example, whether it checks the cache for results before sending a request to the server).\n *\n * For details, see [Setting a fetch policy](https://www.apollographql.com/docs/react/data/queries/#setting-a-fetch-policy).\n *\n * The default value is `cache-first`.\n *\n * @docGroup 3. Caching options\n */\n fetchPolicy: unknown;\n\n /**\n * Specifies the {@link FetchPolicy} to be used after this query has completed.\n *\n * @docGroup 3. Caching options\n */\n nextFetchPolicy: unknown;\n\n /**\n * Defaults to the initial value of options.fetchPolicy, but can be explicitly\n * configured to specify the WatchQueryFetchPolicy to revert back to whenever\n * variables change (unless nextFetchPolicy intervenes).\n *\n * @docGroup 3. Caching options\n */\n initialFetchPolicy: unknown;\n\n /**\n * Specifies the interval (in milliseconds) at which the query polls for updated results.\n *\n * The default value is `0` (no polling).\n *\n * @docGroup 2. Networking options\n */\n pollInterval: unknown;\n\n /**\n * If `true`, the in-progress query's associated component re-renders whenever the network status changes or a network error occurs.\n *\n * The default value is `false`.\n *\n * @docGroup 2. Networking options\n */\n notifyOnNetworkStatusChange: unknown;\n\n /**\n * If `true`, the query can return partial results from the cache if the cache doesn't contain results for all queried fields.\n *\n * The default value is `false`.\n *\n * @docGroup 3. Caching options\n */\n returnPartialData: unknown;\n\n /**\n * Specifies whether a `NetworkStatus.refetch` operation should merge\n * incoming field data with existing data, or overwrite the existing data.\n * Overwriting is probably preferable, but merging is currently the default\n * behavior, for backwards compatibility with Apollo Client 3.x.\n *\n * @docGroup 3. Caching options\n */\n refetchWritePolicy: unknown;\n\n /**\n * Watched queries must opt into overwriting existing data on refetch, by passing refetchWritePolicy: \"overwrite\" in their WatchQueryOptions.\n *\n * The default value is \"overwrite\".\n *\n * @docGroup 3. Caching options\n */\n refetchWritePolicy_suspense: unknown;\n\n /**\n * If `true`, causes a query refetch if the query result is detected as partial.\n *\n * The default value is `false`.\n *\n * @deprecated\n * Setting this option is unnecessary in Apollo Client 3, thanks to a more consistent application of fetch policies. It might be removed in a future release.\n */\n partialRefetch: unknown;\n\n /**\n * Whether to canonize cache results before returning them. Canonization\n * takes some extra time, but it speeds up future deep equality comparisons.\n * Defaults to false.\n *\n * @deprecated\n * Using `canonizeResults` can result in memory leaks so we generally do not\n * recommend using this option anymore.\n * A future version of Apollo Client will contain a similar feature without\n * the risk of memory leaks.\n */\n canonizeResults: unknown;\n\n /**\n * If true, the query is not executed.\n *\n * The default value is `false`.\n *\n * @docGroup 1. Operation options\n */\n skip: unknown;\n\n /**\n * If `true`, the query is not executed. The default value is `false`.\n *\n * @deprecated We recommend using `skipToken` in place of the `skip` option as\n * it is more type-safe.\n *\n * This option is deprecated and only supported to ease the migration from useQuery. It will be removed in a future release.\n *\n * @docGroup 1. Operation options\n */\n skip_deprecated: unknown;\n\n /**\n * A callback function that's called when your query successfully completes with zero errors (or if `errorPolicy` is `ignore` and partial data is returned).\n *\n * This function is passed the query's result `data`.\n *\n * @docGroup 1. Operation options\n */\n onCompleted: unknown;\n /**\n * A callback function that's called when the query encounters one or more errors (unless `errorPolicy` is `ignore`).\n *\n * This function is passed an `ApolloError` object that contains either a `networkError` object or a `graphQLErrors` array, depending on the error(s) that occurred.\n *\n * @docGroup 1. Operation options\n */\n onError: unknown;\n\n /**\n * The instance of {@link ApolloClient} to use to execute the query.\n *\n * By default, the instance that's passed down via context is used, but you\n * can provide a different instance here.\n *\n * @docGroup 1. Operation options\n */\n client: unknown;\n\n /**\n * A unique identifier for the query. Each item in the array must be a stable\n * identifier to prevent infinite fetches.\n *\n * This is useful when using the same query and variables combination in more\n * than one component, otherwise the components may clobber each other. This\n * can also be used to force the query to re-evaluate fresh.\n *\n * @docGroup 1. Operation options\n */\n queryKey: unknown;\n\n /**\n * Pass `false` to skip executing the query during [server-side rendering](https://www.apollographql.com/docs/react/performance/server-side-rendering/).\n *\n * @docGroup 2. Networking options\n */\n ssr: unknown;\n\n /**\n * A callback function that's called whenever a refetch attempt occurs\n * while polling. If the function returns `true`, the refetch is\n * skipped and not reattempted until the next poll interval.\n *\n * @docGroup 2. Networking options\n */\n skipPollAttempt: unknown;\n}\n\nexport interface QueryResultDocumentation {\n /**\n * The instance of Apollo Client that executed the query.\n * Can be useful for manually executing followup queries or writing data to the cache.\n *\n * @docGroup 2. Network info\n */\n client: unknown;\n /**\n * A reference to the internal `ObservableQuery` used by the hook.\n */\n observable: unknown;\n /**\n * An object containing the result of your GraphQL query after it completes.\n *\n * This value might be `undefined` if a query results in one or more errors (depending on the query's `errorPolicy`).\n *\n * @docGroup 1. Operation data\n */\n data: unknown;\n /**\n * An object containing the result from the most recent _previous_ execution of this query.\n *\n * This value is `undefined` if this is the query's first execution.\n *\n * @docGroup 1. Operation data\n */\n previousData: unknown;\n /**\n * If the query produces one or more errors, this object contains either an array of `graphQLErrors` or a single `networkError`. Otherwise, this value is `undefined`.\n *\n * For more information, see [Handling operation errors](https://www.apollographql.com/docs/react/data/error-handling/).\n *\n * @docGroup 1. Operation data\n */\n error: unknown;\n /**\n * If `true`, the query is still in flight and results have not yet been returned.\n *\n * @docGroup 2. Network info\n */\n loading: unknown;\n /**\n * A number indicating the current network state of the query's associated request. [See possible values.](https://github.com/apollographql/apollo-client/blob/d96f4578f89b933c281bb775a39503f6cdb59ee8/src/core/networkStatus.ts#L4)\n *\n * Used in conjunction with the [`notifyOnNetworkStatusChange`](#notifyonnetworkstatuschange) option.\n *\n * @docGroup 2. Network info\n */\n networkStatus: unknown;\n /**\n * If `true`, the associated lazy query has been executed.\n *\n * This field is only present on the result object returned by [`useLazyQuery`](/react/data/queries/#executing-queries-manually).\n *\n * @docGroup 2. Network info\n */\n called: unknown;\n /**\n * An object containing the variables that were provided for the query.\n *\n * @docGroup 1. Operation data\n */\n variables: unknown;\n\n /**\n * A function that enables you to re-execute the query, optionally passing in new `variables`.\n *\n * To guarantee that the refetch performs a network request, its `fetchPolicy` is set to `network-only` (unless the original query's `fetchPolicy` is `no-cache` or `cache-and-network`, which also guarantee a network request).\n *\n * See also [Refetching](https://www.apollographql.com/docs/react/data/queries/#refetching).\n *\n * @docGroup 3. Helper functions\n */\n refetch: unknown;\n /**\n * {@inheritDoc @apollo/client!ObservableQuery#fetchMore:member(1)}\n *\n * @docGroup 3. Helper functions\n */\n fetchMore: unknown;\n /**\n * {@inheritDoc @apollo/client!ObservableQuery#startPolling:member(1)}\n *\n * @docGroup 3. Helper functions\n */\n startPolling: unknown;\n /**\n * {@inheritDoc @apollo/client!ObservableQuery#stopPolling:member(1)}\n *\n * @docGroup 3. Helper functions\n */\n stopPolling: unknown;\n /**\n * {@inheritDoc @apollo/client!ObservableQuery#subscribeToMore:member(1)}\n *\n * @docGroup 3. Helper functions\n */\n subscribeToMore: unknown;\n /**\n * {@inheritDoc @apollo/client!ObservableQuery#updateQuery:member(1)}\n *\n * @docGroup 3. Helper functions\n */\n updateQuery: unknown;\n}\n\nexport interface MutationOptionsDocumentation {\n /**\n * A GraphQL document, often created with `gql` from the `graphql-tag`\n * package, that contains a single mutation inside of it.\n *\n * @docGroup 1. Operation options\n */\n mutation: unknown;\n\n /**\n * Provide `no-cache` if the mutation's result should _not_ be written to the Apollo Client cache.\n *\n * The default value is `network-only` (which means the result _is_ written to the cache).\n *\n * Unlike queries, mutations _do not_ support [fetch policies](https://www.apollographql.com/docs/react/data/queries/#setting-a-fetch-policy) besides `network-only` and `no-cache`.\n *\n * @docGroup 3. Caching options\n */\n fetchPolicy: unknown;\n\n /**\n * To avoid retaining sensitive information from mutation root field\n * arguments, Apollo Client v3.4+ automatically clears any `ROOT_MUTATION`\n * fields from the cache after each mutation finishes. If you need this\n * information to remain in the cache, you can prevent the removal by passing\n * `keepRootFields: true` to the mutation. `ROOT_MUTATION` result data are\n * also passed to the mutation `update` function, so we recommend obtaining\n * the results that way, rather than using this option, if possible.\n */\n keepRootFields: unknown;\n\n /**\n * By providing either an object or a callback function that, when invoked after\n * a mutation, allows you to return optimistic data and optionally skip updates\n * via the `IGNORE` sentinel object, Apollo Client caches this temporary\n * (and potentially incorrect) response until the mutation completes, enabling\n * more responsive UI updates.\n *\n * For more information, see [Optimistic mutation results](https://www.apollographql.com/docs/react/performance/optimistic-ui/).\n *\n * @docGroup 3. Caching options\n */\n optimisticResponse: unknown;\n\n /**\n * A {@link MutationQueryReducersMap}, which is map from query names to\n * mutation query reducers. Briefly, this map defines how to incorporate the\n * results of the mutation into the results of queries that are currently\n * being watched by your application.\n */\n updateQueries: unknown;\n\n /**\n * An array (or a function that _returns_ an array) that specifies which queries you want to refetch after the mutation occurs.\n *\n * Each array value can be either:\n *\n * - An object containing the `query` to execute, along with any `variables`\n *\n * - A string indicating the operation name of the query to refetch\n *\n * @docGroup 1. Operation options\n */\n refetchQueries: unknown;\n\n /**\n * If `true`, makes sure all queries included in `refetchQueries` are completed before the mutation is considered complete.\n *\n * The default value is `false` (queries are refetched asynchronously).\n *\n * @docGroup 1. Operation options\n */\n awaitRefetchQueries: unknown;\n\n /**\n * A function used to update the Apollo Client cache after the mutation completes.\n *\n * For more information, see [Updating the cache after a mutation](https://www.apollographql.com/docs/react/data/mutations#updating-the-cache-after-a-mutation).\n *\n * @docGroup 3. Caching options\n */\n update: unknown;\n\n /**\n * Optional callback for intercepting queries whose cache data has been updated by the mutation, as well as any queries specified in the `refetchQueries: [...]` list passed to `client.mutate`.\n *\n * Returning a `Promise` from `onQueryUpdated` will cause the final mutation `Promise` to await the returned `Promise`. Returning `false` causes the query to be ignored.\n *\n * @docGroup 1. Operation options\n */\n onQueryUpdated: unknown;\n\n /**\n * Specifies how the mutation handles a response that returns both GraphQL errors and partial results.\n *\n * For details, see [GraphQL error policies](https://www.apollographql.com/docs/react/data/error-handling/#graphql-error-policies).\n *\n * The default value is `none`, meaning that the mutation result includes error details but _not_ partial results.\n *\n * @docGroup 1. Operation options\n */\n errorPolicy: unknown;\n\n /**\n * An object containing all of the GraphQL variables your mutation requires to execute.\n *\n * Each key in the object corresponds to a variable name, and that key's value corresponds to the variable value.\n *\n * @docGroup 1. Operation options\n */\n variables: unknown;\n\n /**\n * If you're using [Apollo Link](https://www.apollographql.com/docs/react/api/link/introduction/), this object is the initial value of the `context` object that's passed along your link chain.\n *\n * @docGroup 2. Networking options\n */\n context: unknown;\n\n /**\n * The instance of `ApolloClient` to use to execute the mutation.\n *\n * By default, the instance that's passed down via context is used, but you can provide a different instance here.\n *\n * @docGroup 2. Networking options\n */\n client: unknown;\n /**\n * If `true`, the in-progress mutation's associated component re-renders whenever the network status changes or a network error occurs.\n *\n * The default value is `false`.\n *\n * @docGroup 2. Networking options\n */\n notifyOnNetworkStatusChange: unknown;\n /**\n * A callback function that's called when your mutation successfully completes with zero errors (or if `errorPolicy` is `ignore` and partial data is returned).\n *\n * This function is passed the mutation's result `data` and any options passed to the mutation.\n *\n * @docGroup 1. Operation options\n */\n onCompleted: unknown;\n /**\n * A callback function that's called when the mutation encounters one or more errors (unless `errorPolicy` is `ignore`).\n *\n * This function is passed an [`ApolloError`](https://github.com/apollographql/apollo-client/blob/d96f4578f89b933c281bb775a39503f6cdb59ee8/src/errors/index.ts#L36-L39) object that contains either a `networkError` object or a `graphQLErrors` array, depending on the error(s) that occurred, as well as any options passed the mutation.\n *\n * @docGroup 1. Operation options\n */\n onError: unknown;\n /**\n * If `true`, the mutation's `data` property is not updated with the mutation's result.\n *\n * The default value is `false`.\n *\n * @docGroup 1. Operation options\n */\n ignoreResults: unknown;\n}\n\nexport interface MutationResultDocumentation {\n /**\n * The data returned from your mutation. Can be `undefined` if `ignoreResults` is `true`.\n */\n data: unknown;\n /**\n * If the mutation produces one or more errors, this object contains either an array of `graphQLErrors` or a single `networkError`. Otherwise, this value is `undefined`.\n *\n * For more information, see [Handling operation errors](https://www.apollographql.com/docs/react/data/error-handling/).\n */\n error: unknown;\n /**\n * If `true`, the mutation is currently in flight.\n */\n loading: unknown;\n /**\n * If `true`, the mutation's mutate function has been called.\n */\n called: unknown;\n /**\n * The instance of Apollo Client that executed the mutation.\n *\n * Can be useful for manually executing followup operations or writing data to the cache.\n */\n client: unknown;\n /**\n * A function that you can call to reset the mutation's result to its initial, uncalled state.\n */\n reset: unknown;\n}\n\nexport interface SubscriptionOptionsDocumentation {\n /**\n * A GraphQL document, often created with `gql` from the `graphql-tag`\n * package, that contains a single subscription inside of it.\n */\n query: unknown;\n /**\n * An object containing all of the variables your subscription needs to execute\n */\n variables: unknown;\n\n /**\n * Specifies the {@link ErrorPolicy} to be used for this operation\n */\n errorPolicy: unknown;\n\n /**\n * How you want your component to interact with the Apollo cache. For details, see [Setting a fetch policy](https://www.apollographql.com/docs/react/data/queries/#setting-a-fetch-policy).\n */\n fetchPolicy: unknown;\n\n /**\n * Determines if your subscription should be unsubscribed and subscribed again when an input to the hook (such as `subscription` or `variables`) changes.\n */\n shouldResubscribe: unknown;\n\n /**\n * An `ApolloClient` instance. By default `useSubscription` / `Subscription` uses the client passed down via context, but a different client can be passed in.\n */\n client: unknown;\n\n /**\n * Determines if the current subscription should be skipped. Useful if, for example, variables depend on previous queries and are not ready yet.\n */\n skip: unknown;\n\n /**\n * Shared context between your component and your network interface (Apollo Link).\n */\n context: unknown;\n\n /**\n * Allows the registration of a callback function that will be triggered each time the `useSubscription` Hook / `Subscription` component completes the subscription.\n *\n * @since 3.7.0\n */\n onComplete: unknown;\n\n /**\n * Allows the registration of a callback function that will be triggered each time the `useSubscription` Hook / `Subscription` component receives data. The callback `options` object param consists of the current Apollo Client instance in `client`, and the received subscription data in `data`.\n *\n * @since 3.7.0\n */\n onData: unknown;\n\n /**\n * Allows the registration of a callback function that will be triggered each time the `useSubscription` Hook / `Subscription` component receives data. The callback `options` object param consists of the current Apollo Client instance in `client`, and the received subscription data in `subscriptionData`.\n *\n * @deprecated Use `onData` instead\n */\n onSubscriptionData: unknown;\n\n /**\n * Allows the registration of a callback function that will be triggered each time the `useSubscription` Hook / `Subscription` component receives an error.\n *\n * @since 3.7.0\n */\n onError: unknown;\n\n /**\n * Allows the registration of a callback function that will be triggered when the `useSubscription` Hook / `Subscription` component completes the subscription.\n *\n * @deprecated Use `onComplete` instead\n */\n onSubscriptionComplete: unknown;\n}\n\nexport interface SubscriptionResultDocumentation {\n /**\n * A boolean that indicates whether any initial data has been returned\n */\n loading: unknown;\n /**\n * An object containing the result of your GraphQL subscription. Defaults to an empty object.\n */\n data: unknown;\n /**\n * A runtime error with `graphQLErrors` and `networkError` properties\n */\n error: unknown;\n}\n"]}
|
|
1
|
+
{"version":3,"file":"types.documentation.js","sourceRoot":"","sources":["../../../src/react/types/types.documentation.ts"],"names":[],"mappings":"","sourcesContent":["export interface QueryOptionsDocumentation {\n /**\n * A GraphQL query string parsed into an AST with the gql template literal.\n *\n * @docGroup 1. Operation options\n */\n query: unknown;\n\n /**\n * An object containing all of the GraphQL variables your query requires to execute.\n *\n * Each key in the object corresponds to a variable name, and that key's value corresponds to the variable value.\n *\n * @docGroup 1. Operation options\n */\n variables: unknown;\n\n /**\n * Specifies how the query handles a response that returns both GraphQL errors and partial results.\n *\n * For details, see [GraphQL error policies](https://www.apollographql.com/docs/react/data/error-handling/#graphql-error-policies).\n *\n * The default value is `none`, meaning that the query result includes error details but not partial results.\n *\n * @docGroup 1. Operation options\n */\n errorPolicy: unknown;\n\n /**\n * If you're using [Apollo Link](https://www.apollographql.com/docs/react/api/link/introduction/), this object is the initial value of the `context` object that's passed along your link chain.\n *\n * @docGroup 2. Networking options\n */\n context: unknown;\n\n /**\n * Specifies how the query interacts with the Apollo Client cache during execution (for example, whether it checks the cache for results before sending a request to the server).\n *\n * For details, see [Setting a fetch policy](https://www.apollographql.com/docs/react/data/queries/#setting-a-fetch-policy).\n *\n * The default value is `cache-first`.\n *\n * @docGroup 3. Caching options\n */\n fetchPolicy: unknown;\n\n /**\n * Specifies the `FetchPolicy` to be used after this query has completed.\n *\n * @docGroup 3. Caching options\n */\n nextFetchPolicy: unknown;\n\n /**\n * Defaults to the initial value of options.fetchPolicy, but can be explicitly\n * configured to specify the WatchQueryFetchPolicy to revert back to whenever\n * variables change (unless nextFetchPolicy intervenes).\n *\n * @docGroup 3. Caching options\n */\n initialFetchPolicy: unknown;\n\n /**\n * Specifies the interval (in milliseconds) at which the query polls for updated results.\n *\n * The default value is `0` (no polling).\n *\n * @docGroup 2. Networking options\n */\n pollInterval: unknown;\n\n /**\n * If `true`, the in-progress query's associated component re-renders whenever the network status changes or a network error occurs.\n *\n * The default value is `false`.\n *\n * @docGroup 2. Networking options\n */\n notifyOnNetworkStatusChange: unknown;\n\n /**\n * If `true`, the query can return partial results from the cache if the cache doesn't contain results for all queried fields.\n *\n * The default value is `false`.\n *\n * @docGroup 3. Caching options\n */\n returnPartialData: unknown;\n\n /**\n * Specifies whether a `NetworkStatus.refetch` operation should merge\n * incoming field data with existing data, or overwrite the existing data.\n * Overwriting is probably preferable, but merging is currently the default\n * behavior, for backwards compatibility with Apollo Client 3.x.\n *\n * @docGroup 3. Caching options\n */\n refetchWritePolicy: unknown;\n\n /**\n * Watched queries must opt into overwriting existing data on refetch, by passing refetchWritePolicy: \"overwrite\" in their WatchQueryOptions.\n *\n * The default value is \"overwrite\".\n *\n * @docGroup 3. Caching options\n */\n refetchWritePolicy_suspense: unknown;\n\n /**\n * If `true`, causes a query refetch if the query result is detected as partial.\n *\n * The default value is `false`.\n *\n * @deprecated\n * Setting this option is unnecessary in Apollo Client 3, thanks to a more consistent application of fetch policies. It might be removed in a future release.\n */\n partialRefetch: unknown;\n\n /**\n * Whether to canonize cache results before returning them. Canonization\n * takes some extra time, but it speeds up future deep equality comparisons.\n * Defaults to false.\n *\n * @deprecated\n * Using `canonizeResults` can result in memory leaks so we generally do not\n * recommend using this option anymore.\n * A future version of Apollo Client will contain a similar feature without\n * the risk of memory leaks.\n */\n canonizeResults: unknown;\n\n /**\n * If true, the query is not executed.\n *\n * The default value is `false`.\n *\n * @docGroup 1. Operation options\n */\n skip: unknown;\n\n /**\n * If `true`, the query is not executed. The default value is `false`.\n *\n * @deprecated We recommend using `skipToken` in place of the `skip` option as\n * it is more type-safe.\n *\n * This option is deprecated and only supported to ease the migration from useQuery. It will be removed in a future release.\n *\n * @docGroup 1. Operation options\n */\n skip_deprecated: unknown;\n\n /**\n * A callback function that's called when your query successfully completes with zero errors (or if `errorPolicy` is `ignore` and partial data is returned).\n *\n * This function is passed the query's result `data`.\n *\n * @docGroup 1. Operation options\n */\n onCompleted: unknown;\n /**\n * A callback function that's called when the query encounters one or more errors (unless `errorPolicy` is `ignore`).\n *\n * This function is passed an `ApolloError` object that contains either a `networkError` object or a `graphQLErrors` array, depending on the error(s) that occurred.\n *\n * @docGroup 1. Operation options\n */\n onError: unknown;\n\n /**\n * The instance of `ApolloClient` to use to execute the query.\n *\n * By default, the instance that's passed down via context is used, but you\n * can provide a different instance here.\n *\n * @docGroup 1. Operation options\n */\n client: unknown;\n\n /**\n * A unique identifier for the query. Each item in the array must be a stable\n * identifier to prevent infinite fetches.\n *\n * This is useful when using the same query and variables combination in more\n * than one component, otherwise the components may clobber each other. This\n * can also be used to force the query to re-evaluate fresh.\n *\n * @docGroup 1. Operation options\n */\n queryKey: unknown;\n\n /**\n * Pass `false` to skip executing the query during [server-side rendering](https://www.apollographql.com/docs/react/performance/server-side-rendering/).\n *\n * @docGroup 2. Networking options\n */\n ssr: unknown;\n\n /**\n * A callback function that's called whenever a refetch attempt occurs\n * while polling. If the function returns `true`, the refetch is\n * skipped and not reattempted until the next poll interval.\n *\n * @docGroup 2. Networking options\n */\n skipPollAttempt: unknown;\n}\n\nexport interface QueryResultDocumentation {\n /**\n * The instance of Apollo Client that executed the query.\n * Can be useful for manually executing followup queries or writing data to the cache.\n *\n * @docGroup 2. Network info\n */\n client: unknown;\n /**\n * A reference to the internal `ObservableQuery` used by the hook.\n */\n observable: unknown;\n /**\n * An object containing the result of your GraphQL query after it completes.\n *\n * This value might be `undefined` if a query results in one or more errors (depending on the query's `errorPolicy`).\n *\n * @docGroup 1. Operation data\n */\n data: unknown;\n /**\n * An object containing the result from the most recent _previous_ execution of this query.\n *\n * This value is `undefined` if this is the query's first execution.\n *\n * @docGroup 1. Operation data\n */\n previousData: unknown;\n /**\n * If the query produces one or more errors, this object contains either an array of `graphQLErrors` or a single `networkError`. Otherwise, this value is `undefined`.\n *\n * For more information, see [Handling operation errors](https://www.apollographql.com/docs/react/data/error-handling/).\n *\n * @docGroup 1. Operation data\n */\n error: unknown;\n /**\n * If `true`, the query is still in flight and results have not yet been returned.\n *\n * @docGroup 2. Network info\n */\n loading: unknown;\n /**\n * A number indicating the current network state of the query's associated request. [See possible values.](https://github.com/apollographql/apollo-client/blob/d96f4578f89b933c281bb775a39503f6cdb59ee8/src/core/networkStatus.ts#L4)\n *\n * Used in conjunction with the [`notifyOnNetworkStatusChange`](#notifyonnetworkstatuschange) option.\n *\n * @docGroup 2. Network info\n */\n networkStatus: unknown;\n /**\n * If `true`, the associated lazy query has been executed.\n *\n * This field is only present on the result object returned by [`useLazyQuery`](/react/data/queries/#executing-queries-manually).\n *\n * @docGroup 2. Network info\n */\n called: unknown;\n /**\n * An object containing the variables that were provided for the query.\n *\n * @docGroup 1. Operation data\n */\n variables: unknown;\n\n /**\n * A function that enables you to re-execute the query, optionally passing in new `variables`.\n *\n * To guarantee that the refetch performs a network request, its `fetchPolicy` is set to `network-only` (unless the original query's `fetchPolicy` is `no-cache` or `cache-and-network`, which also guarantee a network request).\n *\n * See also [Refetching](https://www.apollographql.com/docs/react/data/queries/#refetching).\n *\n * @docGroup 3. Helper functions\n */\n refetch: unknown;\n /**\n * {@inheritDoc @apollo/client!ObservableQuery#fetchMore:member(1)}\n *\n * @docGroup 3. Helper functions\n */\n fetchMore: unknown;\n /**\n * {@inheritDoc @apollo/client!ObservableQuery#startPolling:member(1)}\n *\n * @docGroup 3. Helper functions\n */\n startPolling: unknown;\n /**\n * {@inheritDoc @apollo/client!ObservableQuery#stopPolling:member(1)}\n *\n * @docGroup 3. Helper functions\n */\n stopPolling: unknown;\n /**\n * {@inheritDoc @apollo/client!ObservableQuery#subscribeToMore:member(1)}\n *\n * @docGroup 3. Helper functions\n */\n subscribeToMore: unknown;\n /**\n * {@inheritDoc @apollo/client!ObservableQuery#updateQuery:member(1)}\n *\n * @docGroup 3. Helper functions\n */\n updateQuery: unknown;\n}\n\nexport interface MutationOptionsDocumentation {\n /**\n * A GraphQL document, often created with `gql` from the `graphql-tag`\n * package, that contains a single mutation inside of it.\n *\n * @docGroup 1. Operation options\n */\n mutation: unknown;\n\n /**\n * Provide `no-cache` if the mutation's result should _not_ be written to the Apollo Client cache.\n *\n * The default value is `network-only` (which means the result _is_ written to the cache).\n *\n * Unlike queries, mutations _do not_ support [fetch policies](https://www.apollographql.com/docs/react/data/queries/#setting-a-fetch-policy) besides `network-only` and `no-cache`.\n *\n * @docGroup 3. Caching options\n */\n fetchPolicy: unknown;\n\n /**\n * To avoid retaining sensitive information from mutation root field\n * arguments, Apollo Client v3.4+ automatically clears any `ROOT_MUTATION`\n * fields from the cache after each mutation finishes. If you need this\n * information to remain in the cache, you can prevent the removal by passing\n * `keepRootFields: true` to the mutation. `ROOT_MUTATION` result data are\n * also passed to the mutation `update` function, so we recommend obtaining\n * the results that way, rather than using this option, if possible.\n */\n keepRootFields: unknown;\n\n /**\n * By providing either an object or a callback function that, when invoked after\n * a mutation, allows you to return optimistic data and optionally skip updates\n * via the `IGNORE` sentinel object, Apollo Client caches this temporary\n * (and potentially incorrect) response until the mutation completes, enabling\n * more responsive UI updates.\n *\n * For more information, see [Optimistic mutation results](https://www.apollographql.com/docs/react/performance/optimistic-ui/).\n *\n * @docGroup 3. Caching options\n */\n optimisticResponse: unknown;\n\n /**\n * A `MutationQueryReducersMap`, which is map from query names to\n * mutation query reducers. Briefly, this map defines how to incorporate the\n * results of the mutation into the results of queries that are currently\n * being watched by your application.\n */\n updateQueries: unknown;\n\n /**\n * An array (or a function that _returns_ an array) that specifies which queries you want to refetch after the mutation occurs.\n *\n * Each array value can be either:\n *\n * - An object containing the `query` to execute, along with any `variables`\n *\n * - A string indicating the operation name of the query to refetch\n *\n * @docGroup 1. Operation options\n */\n refetchQueries: unknown;\n\n /**\n * If `true`, makes sure all queries included in `refetchQueries` are completed before the mutation is considered complete.\n *\n * The default value is `false` (queries are refetched asynchronously).\n *\n * @docGroup 1. Operation options\n */\n awaitRefetchQueries: unknown;\n\n /**\n * A function used to update the Apollo Client cache after the mutation completes.\n *\n * For more information, see [Updating the cache after a mutation](https://www.apollographql.com/docs/react/data/mutations#updating-the-cache-after-a-mutation).\n *\n * @docGroup 3. Caching options\n */\n update: unknown;\n\n /**\n * Optional callback for intercepting queries whose cache data has been updated by the mutation, as well as any queries specified in the `refetchQueries: [...]` list passed to `client.mutate`.\n *\n * Returning a `Promise` from `onQueryUpdated` will cause the final mutation `Promise` to await the returned `Promise`. Returning `false` causes the query to be ignored.\n *\n * @docGroup 1. Operation options\n */\n onQueryUpdated: unknown;\n\n /**\n * Specifies how the mutation handles a response that returns both GraphQL errors and partial results.\n *\n * For details, see [GraphQL error policies](https://www.apollographql.com/docs/react/data/error-handling/#graphql-error-policies).\n *\n * The default value is `none`, meaning that the mutation result includes error details but _not_ partial results.\n *\n * @docGroup 1. Operation options\n */\n errorPolicy: unknown;\n\n /**\n * An object containing all of the GraphQL variables your mutation requires to execute.\n *\n * Each key in the object corresponds to a variable name, and that key's value corresponds to the variable value.\n *\n * @docGroup 1. Operation options\n */\n variables: unknown;\n\n /**\n * If you're using [Apollo Link](https://www.apollographql.com/docs/react/api/link/introduction/), this object is the initial value of the `context` object that's passed along your link chain.\n *\n * @docGroup 2. Networking options\n */\n context: unknown;\n\n /**\n * The instance of `ApolloClient` to use to execute the mutation.\n *\n * By default, the instance that's passed down via context is used, but you can provide a different instance here.\n *\n * @docGroup 2. Networking options\n */\n client: unknown;\n /**\n * If `true`, the in-progress mutation's associated component re-renders whenever the network status changes or a network error occurs.\n *\n * The default value is `false`.\n *\n * @docGroup 2. Networking options\n */\n notifyOnNetworkStatusChange: unknown;\n /**\n * A callback function that's called when your mutation successfully completes with zero errors (or if `errorPolicy` is `ignore` and partial data is returned).\n *\n * This function is passed the mutation's result `data` and any options passed to the mutation.\n *\n * @docGroup 1. Operation options\n */\n onCompleted: unknown;\n /**\n * A callback function that's called when the mutation encounters one or more errors (unless `errorPolicy` is `ignore`).\n *\n * This function is passed an [`ApolloError`](https://github.com/apollographql/apollo-client/blob/d96f4578f89b933c281bb775a39503f6cdb59ee8/src/errors/index.ts#L36-L39) object that contains either a `networkError` object or a `graphQLErrors` array, depending on the error(s) that occurred, as well as any options passed the mutation.\n *\n * @docGroup 1. Operation options\n */\n onError: unknown;\n /**\n * If `true`, the mutation's `data` property is not updated with the mutation's result.\n *\n * The default value is `false`.\n *\n * @docGroup 1. Operation options\n */\n ignoreResults: unknown;\n}\n\nexport interface MutationResultDocumentation {\n /**\n * The data returned from your mutation. Can be `undefined` if `ignoreResults` is `true`.\n */\n data: unknown;\n /**\n * If the mutation produces one or more errors, this object contains either an array of `graphQLErrors` or a single `networkError`. Otherwise, this value is `undefined`.\n *\n * For more information, see [Handling operation errors](https://www.apollographql.com/docs/react/data/error-handling/).\n */\n error: unknown;\n /**\n * If `true`, the mutation is currently in flight.\n */\n loading: unknown;\n /**\n * If `true`, the mutation's mutate function has been called.\n */\n called: unknown;\n /**\n * The instance of Apollo Client that executed the mutation.\n *\n * Can be useful for manually executing followup operations or writing data to the cache.\n */\n client: unknown;\n /**\n * A function that you can call to reset the mutation's result to its initial, uncalled state.\n */\n reset: unknown;\n}\n\nexport interface SubscriptionOptionsDocumentation {\n /**\n * A GraphQL document, often created with `gql` from the `graphql-tag`\n * package, that contains a single subscription inside of it.\n */\n query: unknown;\n /**\n * An object containing all of the variables your subscription needs to execute\n */\n variables: unknown;\n\n /**\n * Specifies the `ErrorPolicy` to be used for this operation\n */\n errorPolicy: unknown;\n\n /**\n * How you want your component to interact with the Apollo cache. For details, see [Setting a fetch policy](https://www.apollographql.com/docs/react/data/queries/#setting-a-fetch-policy).\n */\n fetchPolicy: unknown;\n\n /**\n * Determines if your subscription should be unsubscribed and subscribed again when an input to the hook (such as `subscription` or `variables`) changes.\n */\n shouldResubscribe: unknown;\n\n /**\n * An `ApolloClient` instance. By default `useSubscription` / `Subscription` uses the client passed down via context, but a different client can be passed in.\n */\n client: unknown;\n\n /**\n * Determines if the current subscription should be skipped. Useful if, for example, variables depend on previous queries and are not ready yet.\n */\n skip: unknown;\n\n /**\n * Shared context between your component and your network interface (Apollo Link).\n */\n context: unknown;\n\n /**\n * Allows the registration of a callback function that will be triggered each time the `useSubscription` Hook / `Subscription` component completes the subscription.\n *\n * @since 3.7.0\n */\n onComplete: unknown;\n\n /**\n * Allows the registration of a callback function that will be triggered each time the `useSubscription` Hook / `Subscription` component receives data. The callback `options` object param consists of the current Apollo Client instance in `client`, and the received subscription data in `data`.\n *\n * @since 3.7.0\n */\n onData: unknown;\n\n /**\n * Allows the registration of a callback function that will be triggered each time the `useSubscription` Hook / `Subscription` component receives data. The callback `options` object param consists of the current Apollo Client instance in `client`, and the received subscription data in `subscriptionData`.\n *\n * @deprecated Use `onData` instead\n */\n onSubscriptionData: unknown;\n\n /**\n * Allows the registration of a callback function that will be triggered each time the `useSubscription` Hook / `Subscription` component receives an error.\n *\n * @since 3.7.0\n */\n onError: unknown;\n\n /**\n * Allows the registration of a callback function that will be triggered when the `useSubscription` Hook / `Subscription` component completes the subscription.\n *\n * @deprecated Use `onComplete` instead\n */\n onSubscriptionComplete: unknown;\n}\n\nexport interface SubscriptionResultDocumentation {\n /**\n * A boolean that indicates whether any initial data has been returned\n */\n loading: unknown;\n /**\n * An object containing the result of your GraphQL subscription. Defaults to an empty object.\n */\n data: unknown;\n /**\n * A runtime error with `graphQLErrors` and `networkError` properties\n */\n error: unknown;\n}\n"]}
|
|
@@ -37,9 +37,9 @@ var IteratorStream = /** @class */ (function () {
|
|
|
37
37
|
function IteratorStream(iterator) {
|
|
38
38
|
this.iterator = iterator;
|
|
39
39
|
}
|
|
40
|
-
IteratorStream.prototype.take = function (
|
|
41
|
-
|
|
42
|
-
|
|
40
|
+
IteratorStream.prototype.take = function () {
|
|
41
|
+
return __awaiter(this, arguments, void 0, function (_a) {
|
|
42
|
+
var _b = _a === void 0 ? {} : _a, _c = _b.timeout, timeout = _c === void 0 ? 100 : _c;
|
|
43
43
|
return __generator(this, function (_d) {
|
|
44
44
|
return [2 /*return*/, Promise.race([
|
|
45
45
|
this.iterator.next().then(function (result) { return result.value; }),
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"ObservableStream.js","sourceRoot":"","sources":["../../../src/testing/internal/ObservableStream.ts"],"names":[],"mappings":";AAUA,SAAgB,8BAA8B,CAAI,UAAyB;;QAKzE,SAAS,YAAY;YACnB,QAAQ,CAAC,IAAI,CACX,IAAI,OAAO,CAAqB,UAAC,OAAO;gBACtC,WAAW,GAAG,UAAC,KAAyB;oBACtC,OAAO,CAAC,KAAK,CAAC,CAAC;oBACf,YAAY,EAAE,CAAC;gBACjB,CAAC,CAAC;YACJ,CAAC,CAAC,CACH,CAAC;QACJ,CAAC;;;;;oBAZK,QAAQ,GAAkC,EAAE,CAAC;oBACnD,YAAY,EAAE,CAAC;oBAaf,UAAU,CAAC,SAAS,CAClB,UAAC,KAAK,IAAK,OAAA,WAAW,CAAC,EAAE,IAAI,EAAE,MAAM,EAAE,KAAK,OAAA,EAAE,CAAC,EAApC,CAAoC,EAC/C,UAAC,KAAK,IAAK,OAAA,WAAW,CAAC,EAAE,IAAI,EAAE,OAAO,EAAE,KAAK,OAAA,EAAE,CAAC,EAArC,CAAqC,EAChD,cAAM,OAAA,WAAW,CAAC,EAAE,IAAI,EAAE,UAAU,EAAE,CAAC,EAAjC,CAAiC,CACxC,CAAC;iDACI,sBAAgE;wBAAtE,gCAAsE;;oBAAtE,SAAsE,CAAC;;;yBAEhE,IAAI;iDACH,QAAQ,CAAC,KAAK,EAAG;wBAAvB,gCAAuB;;oBAAvB,SAAuB,CAAC;;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;4BACxB,qBAAM,IAAI,CAAC,IAAI,CAAC,OAAO,CAAC,EAAA;;wBAAhC,KAAK,GAAG,SAAwB;wBACtC,MAAM,CAAC,KAAK,CAAC,CAAC,OAAO,CAAC,EAAE,IAAI,EAAE,UAAU,EAAE,CAAC,CAAC;;;;;KAC7C;IACH,uBAAC;AAAD,CAAC,AAzBD,CAAyC,cAAc,GAyBtD","sourcesContent":["import type { Observable } from \"../../utilities/index.js\";\n\ninterface TakeOptions {\n timeout?: number;\n}\ntype ObservableEvent<T> =\n | { type: \"next\"; value: T }\n | { type: \"error\"; error: any }\n | { type: \"complete\" };\n\nasync function* observableToAsyncEventIterator<T>(observable: Observable<T>) {\n let resolveNext: (value: ObservableEvent<T>) => void;\n const promises: Promise<ObservableEvent<T>>[] = [];\n queuePromise();\n\n function queuePromise() {\n promises.push(\n new Promise<ObservableEvent<T>>((resolve) => {\n resolveNext = (event: ObservableEvent<T>) => {\n resolve(event);\n queuePromise();\n };\n })\n );\n }\n\n observable.subscribe(\n (value) => resolveNext({ type: \"next\", value }),\n (error) => resolveNext({ type: \"error\", error }),\n () => resolveNext({ type: \"complete\" })\n );\n yield \"initialization value\" as unknown as Promise<ObservableEvent<T>>;\n\n while (true) {\n yield promises.shift()!;\n }\n}\n\nclass IteratorStream<T> {\n constructor(private iterator: AsyncGenerator<T, void, unknown>) {}\n\n async take({ timeout = 100 }: TakeOptions = {}): Promise<T> {\n return Promise.race([\n this.iterator.next().then((result) => result.value!),\n new Promise<T>((_, reject) => {\n setTimeout(\n reject,\n timeout,\n new Error(\"Timeout waiting for next event\")\n );\n }),\n ]);\n }\n}\n\nexport class ObservableStream<T> extends IteratorStream<ObservableEvent<T>> {\n constructor(observable: Observable<T>) {\n const iterator = observableToAsyncEventIterator(observable);\n // we need to call next() once to start the generator so we immediately subscribe.\n // the first value is always \"initialization value\" which we don't care about\n iterator.next();\n super(iterator);\n }\n\n async takeNext(options?: TakeOptions): Promise<T> {\n const event = await this.take(options);\n expect(event).toEqual({ type: \"next\", value: expect.anything() });\n return (event as ObservableEvent<T> & { type: \"next\" }).value;\n }\n\n async takeError(options?: TakeOptions): Promise<any> {\n const event = await this.take(options);\n expect(event).toEqual({ type: \"error\", error: expect.anything() });\n return (event as ObservableEvent<T> & { type: \"error\" }).error;\n }\n\n async takeComplete(options?: TakeOptions): Promise<void> {\n const event = await this.take(options);\n expect(event).toEqual({ type: \"complete\" });\n }\n}\n"]}
|
|
@@ -112,11 +112,11 @@ export function createProfiler(_a) {
|
|
|
112
112
|
totalRenderCount: function () {
|
|
113
113
|
return Profiler.renders.length;
|
|
114
114
|
},
|
|
115
|
-
peekRender: function (
|
|
116
|
-
|
|
117
|
-
return __awaiter(this, void 0, void 0, function () {
|
|
115
|
+
peekRender: function () {
|
|
116
|
+
return __awaiter(this, arguments, void 0, function (options) {
|
|
118
117
|
var render;
|
|
119
118
|
var _a;
|
|
119
|
+
if (options === void 0) { options = {}; }
|
|
120
120
|
return __generator(this, function (_b) {
|
|
121
121
|
if (iteratorPosition < Profiler.renders.length) {
|
|
122
122
|
render = Profiler.renders[iteratorPosition];
|
|
@@ -129,11 +129,11 @@ export function createProfiler(_a) {
|
|
|
129
129
|
});
|
|
130
130
|
});
|
|
131
131
|
},
|
|
132
|
-
takeRender: function (
|
|
133
|
-
|
|
134
|
-
return __awaiter(this, void 0, void 0, function () {
|
|
132
|
+
takeRender: function () {
|
|
133
|
+
return __awaiter(this, arguments, void 0, function (options) {
|
|
135
134
|
var env_1, _disabledActWarnings, error, e_1, e_2;
|
|
136
135
|
var _a;
|
|
136
|
+
if (options === void 0) { options = {}; }
|
|
137
137
|
return __generator(this, function (_b) {
|
|
138
138
|
switch (_b.label) {
|
|
139
139
|
case 0:
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"profile.js","sourceRoot":"","sources":["../../../../src/testing/internal/profile/profile.tsx"],"names":[],"mappings":";;AAAA,OAAO,KAAK,KAAK,MAAM,OAAO,CAAC;AAE/B,OAAO,EA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D;QACD,kBAAkB;YAChB,OAAO,QAAQ,CAAC,gBAAgB,EAAE,CAAC,QAAQ,CAAC;QAC9C,CAAC;QACK,mBAAmB,YAAC,OAAO;;;;gCACvB,qBAAM,QAAQ,CAAC,iBAAiB,CAAC,OAAO,CAAC,EAAA;gCAAjD,sBAAO,CAAC,SAAyC,CAAC,CAAC,QAAQ,EAAC;;;;SAC7D;KACwC,CAC5C,CAAC;AACJ,CAAC;AAED,SAAS,gBAAgB;;IACvB,OAAO,MAAA,MAAA,MAAC,KAAa,CAAC,kDAAkD,0CACpE,iBAAiB,0CAAE,OAAO,0CAAE,WAAW,CAAC;AAC9C,CAAC;AAED,MAAM,UAAU,eAAe,CAAC,EAAgC;QAAhC,qBAA8B,EAAE,KAAA,EAA9B,IAAI,UAAA;IACpC,IAAM,SAAS,GAAG,IAAI,IAAI,gBAAgB,EAAE,CAAC;IAE7C,IAAI,CAAC,SAAS,EAAE,CAAC;QACf,MAAM,IAAI,KAAK,CACb,yIAAyI,CAC1I,CAAC;IACJ,CAAC;IAED,IAAM,GAAG,GAAG,kBAAkB,EAAE,CAAC;IAEjC,IAAI,CAAC,GAAG,EAAE,CAAC;QACT,MAAM,IAAI,KAAK,CACb,6FAA6F,CAC9F,CAAC;IACJ,CAAC;IAED,KAAK,CAAC,eAAe,CAAC;QACpB,GAAG,CAAC,kBAAkB,CAAC,OAAO,CAAC,SAAS,CAAC,CAAC;IAC5C,CAAC,CAAC,CAAC;AACL,CAAC","sourcesContent":["import * as React from \"react\";\n\nimport { TextEncoder, TextDecoder } from \"util\";\n\nglobal.TextEncoder ??= TextEncoder;\n// @ts-ignore\nglobal.TextDecoder ??= TextDecoder;\nimport type { Render, BaseRender } from \"./Render.js\";\nimport { RenderInstance } from \"./Render.js\";\nimport { applyStackTrace, captureStackTrace } from \"./traces.js\";\nimport type { ProfilerContextValue } from \"./context.js\";\nimport { ProfilerContextProvider, useProfilerContext } from \"./context.js\";\nimport { disableActWarnings } from \"../disposables/index.js\";\n\ntype ValidSnapshot = void | (object & { /* not a function */ call?: never });\n\n/** only used for passing around data internally */\nconst _stackTrace = Symbol();\n/** @internal */\nexport interface NextRenderOptions {\n timeout?: number;\n [_stackTrace]?: string;\n}\n\n/** @internal */\ninterface ProfilerProps {\n children: React.ReactNode;\n}\n\n/** @internal */\nexport interface Profiler<Snapshot>\n extends React.FC<ProfilerProps>,\n ProfiledComponentFields<Snapshot>,\n ProfiledComponentOnlyFields<Snapshot> {}\n\ninterface ReplaceSnapshot<Snapshot> {\n (newSnapshot: Snapshot): void;\n (updateSnapshot: (lastSnapshot: Readonly<Snapshot>) => Snapshot): void;\n}\n\ninterface MergeSnapshot<Snapshot> {\n (partialSnapshot: Partial<Snapshot>): void;\n (\n updatePartialSnapshot: (\n lastSnapshot: Readonly<Snapshot>\n ) => Partial<Snapshot>\n ): void;\n}\n\ninterface ProfiledComponentOnlyFields<Snapshot> {\n // Allows for partial updating of the snapshot by shallow merging the results\n mergeSnapshot: MergeSnapshot<Snapshot>;\n // Performs a full replacement of the snapshot\n replaceSnapshot: ReplaceSnapshot<Snapshot>;\n}\ninterface ProfiledComponentFields<Snapshot> {\n /**\n * An array of all renders that have happened so far.\n * Errors thrown during component render will be captured here, too.\n */\n renders: Array<\n Render<Snapshot> | { phase: \"snapshotError\"; count: number; error: unknown }\n >;\n /**\n * Peeks the next render from the current iterator position, without advancing the iterator.\n * If no render has happened yet, it will wait for the next render to happen.\n * @throws {WaitForRenderTimeoutError} if no render happens within the timeout\n */\n peekRender(options?: NextRenderOptions): Promise<Render<Snapshot>>;\n /**\n * Iterates to the next render and returns it.\n * If no render has happened yet, it will wait for the next render to happen.\n * @throws {WaitForRenderTimeoutError} if no render happens within the timeout\n */\n takeRender(options?: NextRenderOptions): Promise<Render<Snapshot>>;\n /**\n * Returns the total number of renders.\n */\n totalRenderCount(): number;\n /**\n * Returns the current render.\n * @throws {Error} if no render has happened yet\n */\n getCurrentRender(): Render<Snapshot>;\n /**\n * Waits for the next render to happen.\n * Does not advance the render iterator.\n */\n waitForNextRender(options?: NextRenderOptions): Promise<Render<Snapshot>>;\n}\n\nexport interface ProfiledComponent<Snapshot extends ValidSnapshot, Props = {}>\n extends React.FC<Props>,\n ProfiledComponentFields<Snapshot>,\n ProfiledComponentOnlyFields<Snapshot> {}\n\n/** @internal */\nexport function profile<Snapshot extends ValidSnapshot = void, Props = {}>({\n Component,\n ...options\n}: Parameters<typeof createProfiler<Snapshot>>[0] & {\n Component: React.ComponentType<Props>;\n}): ProfiledComponent<Snapshot, Props> {\n const Profiler = createProfiler(options);\n\n return Object.assign(\n function ProfiledComponent(props: Props) {\n return (\n <Profiler>\n <Component {...(props as any)} />\n </Profiler>\n );\n },\n {\n mergeSnapshot: Profiler.mergeSnapshot,\n replaceSnapshot: Profiler.replaceSnapshot,\n getCurrentRender: Profiler.getCurrentRender,\n peekRender: Profiler.peekRender,\n takeRender: Profiler.takeRender,\n totalRenderCount: Profiler.totalRenderCount,\n waitForNextRender: Profiler.waitForNextRender,\n get renders() {\n return Profiler.renders;\n },\n }\n );\n}\n\n/** @internal */\nexport function createProfiler<Snapshot extends ValidSnapshot = void>({\n onRender,\n snapshotDOM = false,\n initialSnapshot,\n skipNonTrackingRenders,\n}: {\n onRender?: (\n info: BaseRender & {\n snapshot: Snapshot;\n replaceSnapshot: ReplaceSnapshot<Snapshot>;\n mergeSnapshot: MergeSnapshot<Snapshot>;\n }\n ) => void;\n snapshotDOM?: boolean;\n initialSnapshot?: Snapshot;\n /**\n * This will skip renders during which no renders tracked by\n * `useTrackRenders` occured.\n */\n skipNonTrackingRenders?: boolean;\n} = {}) {\n let nextRender: Promise<Render<Snapshot>> | undefined;\n let resolveNextRender: ((render: Render<Snapshot>) => void) | undefined;\n let rejectNextRender: ((error: unknown) => void) | undefined;\n const snapshotRef = { current: initialSnapshot };\n const replaceSnapshot: ReplaceSnapshot<Snapshot> = (snap) => {\n if (typeof snap === \"function\") {\n if (!initialSnapshot) {\n throw new Error(\n \"Cannot use a function to update the snapshot if no initial snapshot was provided.\"\n );\n }\n snapshotRef.current = snap(\n typeof snapshotRef.current === \"object\" ?\n // \"cheap best effort\" to prevent accidental mutation of the last snapshot\n { ...snapshotRef.current! }\n : snapshotRef.current!\n );\n } else {\n snapshotRef.current = snap;\n }\n };\n\n const mergeSnapshot: MergeSnapshot<Snapshot> = (partialSnapshot) => {\n replaceSnapshot((snapshot) => ({\n ...snapshot,\n ...(typeof partialSnapshot === \"function\" ?\n partialSnapshot(snapshot)\n : partialSnapshot),\n }));\n };\n\n const profilerContext: ProfilerContextValue = {\n renderedComponents: [],\n };\n\n const profilerOnRender: React.ProfilerOnRenderCallback = (\n id,\n phase,\n actualDuration,\n baseDuration,\n startTime,\n commitTime\n ) => {\n if (\n skipNonTrackingRenders &&\n profilerContext.renderedComponents.length === 0\n ) {\n return;\n }\n const baseRender = {\n id,\n phase,\n actualDuration,\n baseDuration,\n startTime,\n commitTime,\n count: Profiler.renders.length + 1,\n };\n try {\n /*\n * The `onRender` function could contain `expect` calls that throw\n * `JestAssertionError`s - but we are still inside of React, where errors\n * might be swallowed.\n * So we record them and re-throw them in `takeRender`\n * Additionally, we reject the `waitForNextRender` promise.\n */\n onRender?.({\n ...baseRender,\n replaceSnapshot,\n mergeSnapshot,\n snapshot: snapshotRef.current!,\n });\n\n const snapshot = snapshotRef.current as Snapshot;\n const domSnapshot =\n snapshotDOM ? window.document.body.innerHTML : undefined;\n const render = new RenderInstance(\n baseRender,\n snapshot,\n domSnapshot,\n profilerContext.renderedComponents\n );\n profilerContext.renderedComponents = [];\n Profiler.renders.push(render);\n resolveNextRender?.(render);\n } catch (error) {\n Profiler.renders.push({\n phase: \"snapshotError\",\n count: Profiler.renders.length,\n error,\n });\n rejectNextRender?.(error);\n } finally {\n nextRender = resolveNextRender = rejectNextRender = undefined;\n }\n };\n\n let iteratorPosition = 0;\n const Profiler: Profiler<Snapshot> = Object.assign(\n ({ children }: ProfilerProps) => {\n return (\n <ProfilerContextProvider value={profilerContext}>\n <React.Profiler id=\"test\" onRender={profilerOnRender}>\n {children}\n </React.Profiler>\n </ProfilerContextProvider>\n );\n },\n {\n replaceSnapshot,\n mergeSnapshot,\n } satisfies ProfiledComponentOnlyFields<Snapshot>,\n {\n renders: new Array<\n | Render<Snapshot>\n | { phase: \"snapshotError\"; count: number; error: unknown }\n >(),\n totalRenderCount() {\n return Profiler.renders.length;\n },\n async peekRender(options: NextRenderOptions = {}) {\n if (iteratorPosition < Profiler.renders.length) {\n const render = Profiler.renders[iteratorPosition];\n\n if (render.phase === \"snapshotError\") {\n throw render.error;\n }\n\n return render;\n }\n return Profiler.waitForNextRender({\n [_stackTrace]: captureStackTrace(Profiler.peekRender),\n ...options,\n });\n },\n async takeRender(options: NextRenderOptions = {}) {\n // In many cases we do not control the resolution of the suspended\n // promise which results in noisy tests when the profiler due to\n // repeated act warnings.\n using _disabledActWarnings = disableActWarnings();\n\n let error: unknown = undefined;\n\n try {\n return await Profiler.peekRender({\n [_stackTrace]: captureStackTrace(Profiler.takeRender),\n ...options,\n });\n } catch (e) {\n error = e;\n throw e;\n } finally {\n if (!(error && error instanceof WaitForRenderTimeoutError)) {\n iteratorPosition++;\n }\n }\n },\n getCurrentRender() {\n // The \"current\" render should point at the same render that the most\n // recent `takeRender` call returned, so we need to get the \"previous\"\n // iterator position, otherwise `takeRender` advances the iterator\n // to the next render. This means we need to call `takeRender` at least\n // once before we can get a current render.\n const currentPosition = iteratorPosition - 1;\n\n if (currentPosition < 0) {\n throw new Error(\n \"No current render available. You need to call `takeRender` before you can get the current render.\"\n );\n }\n\n const render = Profiler.renders[currentPosition];\n\n if (render.phase === \"snapshotError\") {\n throw render.error;\n }\n return render;\n },\n waitForNextRender({\n timeout = 1000,\n // capture the stack trace here so its stack trace is as close to the calling code as possible\n [_stackTrace]: stackTrace = captureStackTrace(\n Profiler.waitForNextRender\n ),\n }: NextRenderOptions = {}) {\n if (!nextRender) {\n nextRender = Promise.race<Render<Snapshot>>([\n new Promise<Render<Snapshot>>((resolve, reject) => {\n resolveNextRender = resolve;\n rejectNextRender = reject;\n }),\n new Promise<Render<Snapshot>>((_, reject) =>\n setTimeout(\n () =>\n reject(\n applyStackTrace(new WaitForRenderTimeoutError(), stackTrace)\n ),\n timeout\n )\n ),\n ]);\n }\n return nextRender;\n },\n } satisfies ProfiledComponentFields<Snapshot>\n );\n return Profiler;\n}\n\n/** @internal */\nexport class WaitForRenderTimeoutError extends Error {\n constructor() {\n super(\"Exceeded timeout waiting for next render.\");\n Object.setPrototypeOf(this, new.target.prototype);\n }\n}\n\ntype StringReplaceRenderWithSnapshot<T extends string> =\n T extends `${infer Pre}Render${infer Post}` ? `${Pre}Snapshot${Post}` : T;\n\ntype ResultReplaceRenderWithSnapshot<T> =\n T extends (...args: infer Args) => Render<infer Snapshot> ?\n (...args: Args) => Snapshot\n : T extends (...args: infer Args) => Promise<Render<infer Snapshot>> ?\n (...args: Args) => Promise<Snapshot>\n : T;\n\ntype ProfiledHookFields<ReturnValue> =\n ProfiledComponentFields<ReturnValue> extends infer PC ?\n {\n [K in keyof PC as StringReplaceRenderWithSnapshot<\n K & string\n >]: ResultReplaceRenderWithSnapshot<PC[K]>;\n }\n : never;\n\n/** @internal */\nexport interface ProfiledHook<Props, ReturnValue>\n extends React.FC<Props>,\n ProfiledHookFields<ReturnValue> {\n Profiler: Profiler<ReturnValue>;\n}\n\n/** @internal */\nexport function profileHook<ReturnValue extends ValidSnapshot, Props>(\n renderCallback: (props: Props) => ReturnValue\n): ProfiledHook<Props, ReturnValue> {\n const Profiler = createProfiler<ReturnValue>();\n\n const ProfiledHook = (props: Props) => {\n Profiler.replaceSnapshot(renderCallback(props));\n return null;\n };\n\n return Object.assign(\n function App(props: Props) {\n return (\n <Profiler>\n <ProfiledHook {...(props as any)} />\n </Profiler>\n );\n },\n {\n Profiler,\n },\n {\n renders: Profiler.renders,\n totalSnapshotCount: Profiler.totalRenderCount,\n async peekSnapshot(options) {\n return (await Profiler.peekRender(options)).snapshot;\n },\n async takeSnapshot(options) {\n return (await Profiler.takeRender(options)).snapshot;\n },\n getCurrentSnapshot() {\n return Profiler.getCurrentRender().snapshot;\n },\n async waitForNextSnapshot(options) {\n return (await Profiler.waitForNextRender(options)).snapshot;\n },\n } satisfies ProfiledHookFields<ReturnValue>\n );\n}\n\nfunction resolveHookOwner(): React.ComponentType | undefined {\n return (React as any).__SECRET_INTERNALS_DO_NOT_USE_OR_YOU_WILL_BE_FIRED\n ?.ReactCurrentOwner?.current?.elementType;\n}\n\nexport function useTrackRenders({ name }: { name?: string } = {}) {\n const component = name || resolveHookOwner();\n\n if (!component) {\n throw new Error(\n \"useTrackRender: Unable to determine component. Please ensure the hook is called inside a rendered component or provide a `name` option.\"\n );\n }\n\n const ctx = useProfilerContext();\n\n if (!ctx) {\n throw new Error(\n \"useTrackComponentRender: A Profiler must be created and rendered to track component renders\"\n );\n }\n\n React.useLayoutEffect(() => {\n ctx.renderedComponents.unshift(component);\n });\n}\n"]}
|
|
1
|
+
{"version":3,"file":"profile.js","sourceRoot":"","sources":["../../../../src/testing/internal/profile/profile.tsx"],"names":[],"mappings":";;AAAA,OAAO,KAAK,KAAK,MAAM,OAAO,CAAC;AAE/B,OAAO,EAAE,WAAW,EAAE,WAAW,EAAE,MAAM,MAAM,CAAC;AAEhD,MAAA,MAAM,CAAC,WAAW,oCAAlB,MAAM,CAAC,WAAW,GAAK,WAAW,EAAC;AACnC,aAAa;AACb,MAAA,MAAM,CAAC,WAAW,oCAAlB,MAAM,CAAC,WAAW,GAAK,WAAW,EAAC;AAEnC,OAAO,EAAE,cAAc,EAAE,MAAM,aAAa,CAAC;AAC7C,OAAO,EAAE,eAAe,EAAE,iBAAiB,EAAE,MAAM,aAAa,CAAC;AAEjE,OAAO,EAAE,uBAAuB,EAAE,kBAAkB,EAAE,MAAM,cAAc,CAAC;AAC3E,OAAO,EAAE,kBAAkB,EAAE,MAAM,yBAAyB,CAAC;AAI7D,mDAAmD;AACnD,IAAM,WAAW,GAAG,MAAM,E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AA;IACpC,IAAM,SAAS,GAAG,IAAI,IAAI,gBAAgB,EAAE,CAAC;IAE7C,IAAI,CAAC,SAAS,EAAE,CAAC;QACf,MAAM,IAAI,KAAK,CACb,yIAAyI,CAC1I,CAAC;IACJ,CAAC;IAED,IAAM,GAAG,GAAG,kBAAkB,EAAE,CAAC;IAEjC,IAAI,CAAC,GAAG,EAAE,CAAC;QACT,MAAM,IAAI,KAAK,CACb,6FAA6F,CAC9F,CAAC;IACJ,CAAC;IAED,KAAK,CAAC,eAAe,CAAC;QACpB,GAAG,CAAC,kBAAkB,CAAC,OAAO,CAAC,SAAS,CAAC,CAAC;IAC5C,CAAC,CAAC,CAAC;AACL,CAAC","sourcesContent":["import * as React from \"react\";\n\nimport { TextEncoder, TextDecoder } from \"util\";\n\nglobal.TextEncoder ??= TextEncoder;\n// @ts-ignore\nglobal.TextDecoder ??= TextDecoder;\nimport type { Render, BaseRender } from \"./Render.js\";\nimport { RenderInstance } from \"./Render.js\";\nimport { applyStackTrace, captureStackTrace } from \"./traces.js\";\nimport type { ProfilerContextValue } from \"./context.js\";\nimport { ProfilerContextProvider, useProfilerContext } from \"./context.js\";\nimport { disableActWarnings } from \"../disposables/index.js\";\n\ntype ValidSnapshot = void | (object & { /* not a function */ call?: never });\n\n/** only used for passing around data internally */\nconst _stackTrace = Symbol();\n/** @internal */\nexport interface NextRenderOptions {\n timeout?: number;\n [_stackTrace]?: string;\n}\n\n/** @internal */\ninterface ProfilerProps {\n children: React.ReactNode;\n}\n\n/** @internal */\nexport interface Profiler<Snapshot>\n extends React.FC<ProfilerProps>,\n ProfiledComponentFields<Snapshot>,\n ProfiledComponentOnlyFields<Snapshot> {}\n\ninterface ReplaceSnapshot<Snapshot> {\n (newSnapshot: Snapshot): void;\n (updateSnapshot: (lastSnapshot: Readonly<Snapshot>) => Snapshot): void;\n}\n\ninterface MergeSnapshot<Snapshot> {\n (partialSnapshot: Partial<Snapshot>): void;\n (\n updatePartialSnapshot: (\n lastSnapshot: Readonly<Snapshot>\n ) => Partial<Snapshot>\n ): void;\n}\n\ninterface ProfiledComponentOnlyFields<Snapshot> {\n // Allows for partial updating of the snapshot by shallow merging the results\n mergeSnapshot: MergeSnapshot<Snapshot>;\n // Performs a full replacement of the snapshot\n replaceSnapshot: ReplaceSnapshot<Snapshot>;\n}\ninterface ProfiledComponentFields<Snapshot> {\n /**\n * An array of all renders that have happened so far.\n * Errors thrown during component render will be captured here, too.\n */\n renders: Array<\n Render<Snapshot> | { phase: \"snapshotError\"; count: number; error: unknown }\n >;\n /**\n * Peeks the next render from the current iterator position, without advancing the iterator.\n * If no render has happened yet, it will wait for the next render to happen.\n * @throws {WaitForRenderTimeoutError} if no render happens within the timeout\n */\n peekRender(options?: NextRenderOptions): Promise<Render<Snapshot>>;\n /**\n * Iterates to the next render and returns it.\n * If no render has happened yet, it will wait for the next render to happen.\n * @throws {WaitForRenderTimeoutError} if no render happens within the timeout\n */\n takeRender(options?: NextRenderOptions): Promise<Render<Snapshot>>;\n /**\n * Returns the total number of renders.\n */\n totalRenderCount(): number;\n /**\n * Returns the current render.\n * @throws {Error} if no render has happened yet\n */\n getCurrentRender(): Render<Snapshot>;\n /**\n * Waits for the next render to happen.\n * Does not advance the render iterator.\n */\n waitForNextRender(options?: NextRenderOptions): Promise<Render<Snapshot>>;\n}\n\nexport interface ProfiledComponent<Snapshot extends ValidSnapshot, Props = {}>\n extends React.FC<Props>,\n ProfiledComponentFields<Snapshot>,\n ProfiledComponentOnlyFields<Snapshot> {}\n\n/** @internal */\nexport function profile<Snapshot extends ValidSnapshot = void, Props = {}>({\n Component,\n ...options\n}: Parameters<typeof createProfiler<Snapshot>>[0] & {\n Component: React.ComponentType<Props>;\n}): ProfiledComponent<Snapshot, Props> {\n const Profiler = createProfiler(options);\n\n return Object.assign(\n function ProfiledComponent(props: Props) {\n return (\n <Profiler>\n <Component {...(props as any)} />\n </Profiler>\n );\n },\n {\n mergeSnapshot: Profiler.mergeSnapshot,\n replaceSnapshot: Profiler.replaceSnapshot,\n getCurrentRender: Profiler.getCurrentRender,\n peekRender: Profiler.peekRender,\n takeRender: Profiler.takeRender,\n totalRenderCount: Profiler.totalRenderCount,\n waitForNextRender: Profiler.waitForNextRender,\n get renders() {\n return Profiler.renders;\n },\n }\n );\n}\n\n/** @internal */\nexport function createProfiler<Snapshot extends ValidSnapshot = void>({\n onRender,\n snapshotDOM = false,\n initialSnapshot,\n skipNonTrackingRenders,\n}: {\n onRender?: (\n info: BaseRender & {\n snapshot: Snapshot;\n replaceSnapshot: ReplaceSnapshot<Snapshot>;\n mergeSnapshot: MergeSnapshot<Snapshot>;\n }\n ) => void;\n snapshotDOM?: boolean;\n initialSnapshot?: Snapshot;\n /**\n * This will skip renders during which no renders tracked by\n * `useTrackRenders` occured.\n */\n skipNonTrackingRenders?: boolean;\n} = {}) {\n let nextRender: Promise<Render<Snapshot>> | undefined;\n let resolveNextRender: ((render: Render<Snapshot>) => void) | undefined;\n let rejectNextRender: ((error: unknown) => void) | undefined;\n const snapshotRef = { current: initialSnapshot };\n const replaceSnapshot: ReplaceSnapshot<Snapshot> = (snap) => {\n if (typeof snap === \"function\") {\n if (!initialSnapshot) {\n throw new Error(\n \"Cannot use a function to update the snapshot if no initial snapshot was provided.\"\n );\n }\n snapshotRef.current = snap(\n typeof snapshotRef.current === \"object\" ?\n // \"cheap best effort\" to prevent accidental mutation of the last snapshot\n { ...snapshotRef.current! }\n : snapshotRef.current!\n );\n } else {\n snapshotRef.current = snap;\n }\n };\n\n const mergeSnapshot: MergeSnapshot<Snapshot> = (partialSnapshot) => {\n replaceSnapshot((snapshot) => ({\n ...snapshot,\n ...(typeof partialSnapshot === \"function\" ?\n partialSnapshot(snapshot)\n : partialSnapshot),\n }));\n };\n\n const profilerContext: ProfilerContextValue = {\n renderedComponents: [],\n };\n\n const profilerOnRender: React.ProfilerOnRenderCallback = (\n id,\n phase,\n actualDuration,\n baseDuration,\n startTime,\n commitTime\n ) => {\n if (\n skipNonTrackingRenders &&\n profilerContext.renderedComponents.length === 0\n ) {\n return;\n }\n const baseRender = {\n id,\n phase,\n actualDuration,\n baseDuration,\n startTime,\n commitTime,\n count: Profiler.renders.length + 1,\n };\n try {\n /*\n * The `onRender` function could contain `expect` calls that throw\n * `JestAssertionError`s - but we are still inside of React, where errors\n * might be swallowed.\n * So we record them and re-throw them in `takeRender`\n * Additionally, we reject the `waitForNextRender` promise.\n */\n onRender?.({\n ...baseRender,\n replaceSnapshot,\n mergeSnapshot,\n snapshot: snapshotRef.current!,\n });\n\n const snapshot = snapshotRef.current as Snapshot;\n const domSnapshot =\n snapshotDOM ? window.document.body.innerHTML : undefined;\n const render = new RenderInstance(\n baseRender,\n snapshot,\n domSnapshot,\n profilerContext.renderedComponents\n );\n profilerContext.renderedComponents = [];\n Profiler.renders.push(render);\n resolveNextRender?.(render);\n } catch (error) {\n Profiler.renders.push({\n phase: \"snapshotError\",\n count: Profiler.renders.length,\n error,\n });\n rejectNextRender?.(error);\n } finally {\n nextRender = resolveNextRender = rejectNextRender = undefined;\n }\n };\n\n let iteratorPosition = 0;\n const Profiler: Profiler<Snapshot> = Object.assign(\n ({ children }: ProfilerProps) => {\n return (\n <ProfilerContextProvider value={profilerContext}>\n <React.Profiler id=\"test\" onRender={profilerOnRender}>\n {children}\n </React.Profiler>\n </ProfilerContextProvider>\n );\n },\n {\n replaceSnapshot,\n mergeSnapshot,\n } satisfies ProfiledComponentOnlyFields<Snapshot>,\n {\n renders: new Array<\n | Render<Snapshot>\n | { phase: \"snapshotError\"; count: number; error: unknown }\n >(),\n totalRenderCount() {\n return Profiler.renders.length;\n },\n async peekRender(options: NextRenderOptions = {}) {\n if (iteratorPosition < Profiler.renders.length) {\n const render = Profiler.renders[iteratorPosition];\n\n if (render.phase === \"snapshotError\") {\n throw render.error;\n }\n\n return render;\n }\n return Profiler.waitForNextRender({\n [_stackTrace]: captureStackTrace(Profiler.peekRender),\n ...options,\n });\n },\n async takeRender(options: NextRenderOptions = {}) {\n // In many cases we do not control the resolution of the suspended\n // promise which results in noisy tests when the profiler due to\n // repeated act warnings.\n using _disabledActWarnings = disableActWarnings();\n\n let error: unknown = undefined;\n\n try {\n return await Profiler.peekRender({\n [_stackTrace]: captureStackTrace(Profiler.takeRender),\n ...options,\n });\n } catch (e) {\n error = e;\n throw e;\n } finally {\n if (!(error && error instanceof WaitForRenderTimeoutError)) {\n iteratorPosition++;\n }\n }\n },\n getCurrentRender() {\n // The \"current\" render should point at the same render that the most\n // recent `takeRender` call returned, so we need to get the \"previous\"\n // iterator position, otherwise `takeRender` advances the iterator\n // to the next render. This means we need to call `takeRender` at least\n // once before we can get a current render.\n const currentPosition = iteratorPosition - 1;\n\n if (currentPosition < 0) {\n throw new Error(\n \"No current render available. You need to call `takeRender` before you can get the current render.\"\n );\n }\n\n const render = Profiler.renders[currentPosition];\n\n if (render.phase === \"snapshotError\") {\n throw render.error;\n }\n return render;\n },\n waitForNextRender({\n timeout = 1000,\n // capture the stack trace here so its stack trace is as close to the calling code as possible\n [_stackTrace]: stackTrace = captureStackTrace(\n Profiler.waitForNextRender\n ),\n }: NextRenderOptions = {}) {\n if (!nextRender) {\n nextRender = Promise.race<Render<Snapshot>>([\n new Promise<Render<Snapshot>>((resolve, reject) => {\n resolveNextRender = resolve;\n rejectNextRender = reject;\n }),\n new Promise<Render<Snapshot>>((_, reject) =>\n setTimeout(\n () =>\n reject(\n applyStackTrace(new WaitForRenderTimeoutError(), stackTrace)\n ),\n timeout\n )\n ),\n ]);\n }\n return nextRender;\n },\n } satisfies ProfiledComponentFields<Snapshot>\n );\n return Profiler;\n}\n\n/** @internal */\nexport class WaitForRenderTimeoutError extends Error {\n constructor() {\n super(\"Exceeded timeout waiting for next render.\");\n Object.setPrototypeOf(this, new.target.prototype);\n }\n}\n\ntype StringReplaceRenderWithSnapshot<T extends string> =\n T extends `${infer Pre}Render${infer Post}` ? `${Pre}Snapshot${Post}` : T;\n\ntype ResultReplaceRenderWithSnapshot<T> =\n T extends (...args: infer Args) => Render<infer Snapshot> ?\n (...args: Args) => Snapshot\n : T extends (...args: infer Args) => Promise<Render<infer Snapshot>> ?\n (...args: Args) => Promise<Snapshot>\n : T;\n\ntype ProfiledHookFields<ReturnValue> =\n ProfiledComponentFields<ReturnValue> extends infer PC ?\n {\n [K in keyof PC as StringReplaceRenderWithSnapshot<\n K & string\n >]: ResultReplaceRenderWithSnapshot<PC[K]>;\n }\n : never;\n\n/** @internal */\nexport interface ProfiledHook<Props, ReturnValue>\n extends React.FC<Props>,\n ProfiledHookFields<ReturnValue> {\n Profiler: Profiler<ReturnValue>;\n}\n\n/** @internal */\nexport function profileHook<ReturnValue extends ValidSnapshot, Props>(\n renderCallback: (props: Props) => ReturnValue\n): ProfiledHook<Props, ReturnValue> {\n const Profiler = createProfiler<ReturnValue>();\n\n const ProfiledHook = (props: Props) => {\n Profiler.replaceSnapshot(renderCallback(props));\n return null;\n };\n\n return Object.assign(\n function App(props: Props) {\n return (\n <Profiler>\n <ProfiledHook {...(props as any)} />\n </Profiler>\n );\n },\n {\n Profiler,\n },\n {\n renders: Profiler.renders,\n totalSnapshotCount: Profiler.totalRenderCount,\n async peekSnapshot(options) {\n return (await Profiler.peekRender(options)).snapshot;\n },\n async takeSnapshot(options) {\n return (await Profiler.takeRender(options)).snapshot;\n },\n getCurrentSnapshot() {\n return Profiler.getCurrentRender().snapshot;\n },\n async waitForNextSnapshot(options) {\n return (await Profiler.waitForNextRender(options)).snapshot;\n },\n } satisfies ProfiledHookFields<ReturnValue>\n );\n}\n\nfunction resolveHookOwner(): React.ComponentType | undefined {\n return (React as any).__SECRET_INTERNALS_DO_NOT_USE_OR_YOU_WILL_BE_FIRED\n ?.ReactCurrentOwner?.current?.elementType;\n}\n\nexport function useTrackRenders({ name }: { name?: string } = {}) {\n const component = name || resolveHookOwner();\n\n if (!component) {\n throw new Error(\n \"useTrackRender: Unable to determine component. Please ensure the hook is called inside a rendered component or provide a `name` option.\"\n );\n }\n\n const ctx = useProfilerContext();\n\n if (!ctx) {\n throw new Error(\n \"useTrackComponentRender: A Profiler must be created and rendered to track component renders\"\n );\n }\n\n React.useLayoutEffect(() => {\n ctx.renderedComponents.unshift(component);\n });\n}\n"]}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"globals.cjs","sources":["../../version.js","maybe.js","global.js","../common/makeUniqueId.js","../common/stringifyForDisplay.js","invariantWrappers.js","index.js"],"sourcesContent":["export var version = \"3.9.
|
|
1
|
+
{"version":3,"file":"globals.cjs","sources":["../../version.js","maybe.js","global.js","../common/makeUniqueId.js","../common/stringifyForDisplay.js","invariantWrappers.js","index.js"],"sourcesContent":["export var version = \"3.9.8\";\n//# sourceMappingURL=version.js.map","export function maybe(thunk) {\n try {\n return thunk();\n }\n catch (_a) { }\n}\n//# sourceMappingURL=maybe.js.map","import { maybe } from \"./maybe.js\";\nexport default (maybe(function () { return globalThis; }) ||\n maybe(function () { return window; }) ||\n maybe(function () { return self; }) ||\n maybe(function () { return global; }) || // We don't expect the Function constructor ever to be invoked at runtime, as\n// long as at least one of globalThis, window, self, or global is defined, so\n// we are under no obligation to make it easy for static analysis tools to\n// detect syntactic usage of the Function constructor. If you think you can\n// improve your static analysis to detect this obfuscation, think again. This\n// is an arms race you cannot win, at least not in JavaScript.\nmaybe(function () {\n return maybe.constructor(\"return this\")();\n}));\n//# sourceMappingURL=global.js.map","var prefixCounts = new Map();\n// These IDs won't be globally unique, but they will be unique within this\n// process, thanks to the counter, and unguessable thanks to the random suffix.\nexport function makeUniqueId(prefix) {\n var count = prefixCounts.get(prefix) || 1;\n prefixCounts.set(prefix, count + 1);\n return \"\".concat(prefix, \":\").concat(count, \":\").concat(Math.random().toString(36).slice(2));\n}\n//# sourceMappingURL=makeUniqueId.js.map","import { makeUniqueId } from \"./makeUniqueId.js\";\nexport function stringifyForDisplay(value, space) {\n if (space === void 0) { space = 0; }\n var undefId = makeUniqueId(\"stringifyForDisplay\");\n return JSON.stringify(value, function (key, value) {\n return value === void 0 ? undefId : value;\n }, space)\n .split(JSON.stringify(undefId))\n .join(\"<undefined>\");\n}\n//# sourceMappingURL=stringifyForDisplay.js.map","import { invariant as originalInvariant, InvariantError } from \"ts-invariant\";\nimport { version } from \"../../version.js\";\nimport global from \"./global.js\";\nimport { stringifyForDisplay } from \"../common/stringifyForDisplay.js\";\nfunction wrap(fn) {\n return function (message) {\n var args = [];\n for (var _i = 1; _i < arguments.length; _i++) {\n args[_i - 1] = arguments[_i];\n }\n if (typeof message === \"number\") {\n var arg0 = message;\n message = getHandledErrorMsg(arg0);\n if (!message) {\n message = getFallbackErrorMsg(arg0, args);\n args = [];\n }\n }\n fn.apply(void 0, [message].concat(args));\n };\n}\nvar invariant = Object.assign(function invariant(condition, message) {\n var args = [];\n for (var _i = 2; _i < arguments.length; _i++) {\n args[_i - 2] = arguments[_i];\n }\n if (!condition) {\n originalInvariant(condition, getHandledErrorMsg(message, args) || getFallbackErrorMsg(message, args));\n }\n}, {\n debug: wrap(originalInvariant.debug),\n log: wrap(originalInvariant.log),\n warn: wrap(originalInvariant.warn),\n error: wrap(originalInvariant.error),\n});\n/**\n * Returns an InvariantError.\n *\n * `message` can only be a string, a concatenation of strings, or a ternary statement\n * that results in a string. This will be enforced on build, where the message will\n * be replaced with a message number.\n * String substitutions with %s are supported and will also return\n * pretty-stringified objects.\n * Excess `optionalParams` will be swallowed.\n */\nfunction newInvariantError(message) {\n var optionalParams = [];\n for (var _i = 1; _i < arguments.length; _i++) {\n optionalParams[_i - 1] = arguments[_i];\n }\n return new InvariantError(getHandledErrorMsg(message, optionalParams) ||\n getFallbackErrorMsg(message, optionalParams));\n}\nvar ApolloErrorMessageHandler = Symbol.for(\"ApolloErrorMessageHandler_\" + version);\nfunction stringify(arg) {\n return typeof arg == \"string\" ? arg : (stringifyForDisplay(arg, 2).slice(0, 1000));\n}\nfunction getHandledErrorMsg(message, messageArgs) {\n if (messageArgs === void 0) { messageArgs = []; }\n if (!message)\n return;\n return (global[ApolloErrorMessageHandler] &&\n global[ApolloErrorMessageHandler](message, messageArgs.map(stringify)));\n}\nfunction getFallbackErrorMsg(message, messageArgs) {\n if (messageArgs === void 0) { messageArgs = []; }\n if (!message)\n return;\n return \"An error occurred! For more details, see the full error text at https://go.apollo.dev/c/err#\".concat(encodeURIComponent(JSON.stringify({\n version: version,\n message: message,\n args: messageArgs.map(stringify),\n })));\n}\nexport { invariant, InvariantError, newInvariantError, ApolloErrorMessageHandler, };\n//# sourceMappingURL=invariantWrappers.js.map","import { invariant, newInvariantError, InvariantError, } from \"./invariantWrappers.js\";\nexport { maybe } from \"./maybe.js\";\nexport { default as global } from \"./global.js\";\nexport { invariant, newInvariantError, InvariantError };\n/**\n * @deprecated we do not use this internally anymore,\n * it is just exported for backwards compatibility\n */\n// this file is extempt from automatic `__DEV__` replacement\n// so we have to write it out here\n// @ts-ignore\nexport var DEV = globalThis.__DEV__ !== false;\nexport { DEV as __DEV__ };\n//# sourceMappingURL=index.js.map"],"names":["originalInvariant","InvariantError","global"],"mappings":";;;;;;AAAO,IAAI,OAAO,GAAG,OAAO;;ACArB,SAAS,KAAK,CAAC,KAAK,EAAE;AAC7B,IAAI,IAAI;AACR,QAAQ,OAAO,KAAK,EAAE,CAAC;AACvB,KAAK;AACL,IAAI,OAAO,EAAE,EAAE,GAAG;AAClB;;ACJA,eAAe,CAAC,KAAK,CAAC,YAAY,EAAE,OAAO,UAAU,CAAC,EAAE,CAAC;AACzD,IAAI,KAAK,CAAC,YAAY,EAAE,OAAO,MAAM,CAAC,EAAE,CAAC;AACzC,IAAI,KAAK,CAAC,YAAY,EAAE,OAAO,IAAI,CAAC,EAAE,CAAC;AACvC,IAAI,KAAK,CAAC,YAAY,EAAE,OAAO,MAAM,CAAC,EAAE,CAAC;AAMzC,KAAK,CAAC,YAAY;AAClB,IAAI,OAAO,KAAK,CAAC,WAAW,CAAC,aAAa,CAAC,EAAE,CAAC;AAC9C,CAAC,CAAC;;ACZF,IAAI,YAAY,GAAG,IAAI,GAAG,EAAE,CAAC;AAGtB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C,EAAE;AACrD,IAAI,IAAI,CAAC,OAAO;AAChB,QAAQ,OAAO;AACf,IAAI,OAAO,8FAA8F,CAAC,MAAM,CAAC,kBAAkB,CAAC,IAAI,CAAC,SAAS,CAAC;AACnJ,QAAQ,OAAO,EAAE,OAAO;AACxB,QAAQ,OAAO,EAAE,OAAO;AACxB,QAAQ,IAAI,EAAE,WAAW,CAAC,GAAG,CAAC,SAAS,CAAC;AACxC,KAAK,CAAC,CAAC,CAAC,CAAC;AACT;;AC9DU,IAAC,GAAG,GAAG,UAAU,CAAC,OAAO,KAAK;;;;;;;;;;"}
|
|
@@ -56,7 +56,7 @@ declare const ApolloErrorMessageHandler: unique symbol;
|
|
|
56
56
|
declare global {
|
|
57
57
|
interface Window {
|
|
58
58
|
[ApolloErrorMessageHandler]?: {
|
|
59
|
-
(message: string | number, args:
|
|
59
|
+
(message: string | number, args: string[]): string | undefined;
|
|
60
60
|
} & ErrorCodes;
|
|
61
61
|
}
|
|
62
62
|
}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"invariantWrappers.js","sourceRoot":"","sources":["../../../src/utilities/globals/invariantWrappers.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,SAAS,IAAI,iBAAiB,EAAE,cAAc,EAAE,MAAM,cAAc,CAAC;AAC9E,OAAO,EAAE,OAAO,EAAE,MAAM,kBAAkB,CAAC;AAC3C,OAAO,MAAM,MAAM,aAAa,CAAC;AAEjC,OAAO,EAAE,mBAAmB,EAAE,MAAM,kCAAkC,CAAC;AAEvE,SAAS,IAAI,CAAC,EAA0C;IACtD,OAAO,UAAU,OAAyB;QAAE,cAAc;aAAd,UAAc,EAAd,qBAAc,EAAd,IAAc;YAAd,6BAAc;;QACxD,IAAI,OAAO,OAAO,KAAK,QAAQ,EAAE,CAAC;YAChC,IAAM,IAAI,GAAG,OAAO,CAAC;YACrB,OAAO,GAAG,kBAAkB,CAAC,IAAI,CAAC,CAAC;YACnC,IAAI,CAAC,OAAO,EAAE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AQ,CAAC,CAAC,CAAC,GAAG,CAAC,CAAC,CAAC,CAClC,mBAAmB,CAAC,GAAG,EAAE,CAAC,CAAC,CAAC,KAAK,CAAC,CAAC,EAAE,IAAI,CAAC,CAC3C,CAAC;AACN,CAAC;AAED,SAAS,kBAAkB,CACzB,OAAyB,EACzB,WAA2B;IAA3B,4BAAA,EAAA,gBAA2B;IAE3B,IAAI,CAAC,OAAO;QAAE,OAAO;IACrB,OAAO,CACL,MAAM,CAAC,yBAAyB,CAAC;QACjC,MAAM,CAAC,yBAAyB,CAAC,CAAC,OAAO,EAAE,WAAW,CAAC,GAAG,CAAC,SAAS,CAAC,CAAC,CACvE,CAAC;AACJ,CAAC;AAED,SAAS,mBAAmB,CAC1B,OAAyB,EACzB,WAA2B;IAA3B,4BAAA,EAAA,gBAA2B;IAE3B,IAAI,CAAC,OAAO;QAAE,OAAO;IACrB,OAAO,sGAA+F,kBAAkB,CACtH,IAAI,CAAC,SAAS,CAAC;QACb,OAAO,SAAA;QACP,OAAO,SAAA;QACP,IAAI,EAAE,WAAW,CAAC,GAAG,CAAC,SAAS,CAAC;KACjC,CAAC,CACH,CAAE,CAAC;AACN,CAAC;AAED,OAAO,EACL,SAAS,EACT,cAAc,EACd,iBAAiB,EACjB,yBAAyB,GAC1B,CAAC","sourcesContent":["import { invariant as originalInvariant, InvariantError } from \"ts-invariant\";\nimport { version } from \"../../version.js\";\nimport global from \"./global.js\";\nimport type { ErrorCodes } from \"../../invariantErrorCodes.js\";\nimport { stringifyForDisplay } from \"../common/stringifyForDisplay.js\";\n\nfunction wrap(fn: (msg?: string, ...args: any[]) => void) {\n return function (message?: string | number, ...args: any[]) {\n if (typeof message === \"number\") {\n const arg0 = message;\n message = getHandledErrorMsg(arg0);\n if (!message) {\n message = getFallbackErrorMsg(arg0, args);\n args = [];\n }\n }\n fn(...[message].concat(args));\n };\n}\n\ntype LogFunction = {\n /**\n * Logs a `$level` message if the user used `ts-invariant`'s `setVerbosity` to set\n * a verbosity level of `$level` or lower. (defaults to `\"log\"`).\n *\n * The user will either be presented with a link to the documentation for the message,\n * or they can use the `loadDevMessages` to add the message strings to the bundle.\n * The documentation will display the message without argument substitution.\n * Instead, the arguments will be printed on the console after the link.\n *\n * `message` can only be a string, a concatenation of strings, or a ternary statement\n * that results in a string. This will be enforced on build, where the message will\n * be replaced with a message number.\n *\n * String substitutions like %s, %o, %d or %f are supported.\n */\n (message?: any, ...optionalParams: unknown[]): void;\n};\n\ntype WrappedInvariant = {\n /**\n * Throws and InvariantError with the given message if the condition is false.\n *\n * `message` can only be a string, a concatenation of strings, or a ternary statement\n * that results in a string. This will be enforced on build, where the message will\n * be replaced with a message number.\n *\n * The user will either be presented with a link to the documentation for the message,\n * or they can use the `loadErrorMessages` to add the message strings to the bundle.\n * The documentation will display the message with the arguments substituted.\n *\n * String substitutions with %s are supported and will also return\n * pretty-stringified objects.\n * Excess `optionalParams` will be swallowed.\n */\n (\n condition: any,\n message?: string | number,\n ...optionalParams: unknown[]\n ): asserts condition;\n\n debug: LogFunction;\n log: LogFunction;\n warn: LogFunction;\n error: LogFunction;\n};\nconst invariant: WrappedInvariant = Object.assign(\n function invariant(\n condition: any,\n message?: string | number,\n ...args: unknown[]\n ): asserts condition {\n if (!condition) {\n originalInvariant(\n condition,\n getHandledErrorMsg(message, args) || getFallbackErrorMsg(message, args)\n );\n }\n },\n {\n debug: wrap(originalInvariant.debug),\n log: wrap(originalInvariant.log),\n warn: wrap(originalInvariant.warn),\n error: wrap(originalInvariant.error),\n }\n);\n\n/**\n * Returns an InvariantError.\n *\n * `message` can only be a string, a concatenation of strings, or a ternary statement\n * that results in a string. This will be enforced on build, where the message will\n * be replaced with a message number.\n * String substitutions with %s are supported and will also return\n * pretty-stringified objects.\n * Excess `optionalParams` will be swallowed.\n */\nfunction newInvariantError(\n message?: string | number,\n ...optionalParams: unknown[]\n) {\n return new InvariantError(\n getHandledErrorMsg(message, optionalParams) ||\n getFallbackErrorMsg(message, optionalParams)\n );\n}\n\nconst ApolloErrorMessageHandler = Symbol.for(\n \"ApolloErrorMessageHandler_\" + version\n);\ndeclare global {\n interface Window {\n [ApolloErrorMessageHandler]?: {\n (message: string | number, args:
|
|
1
|
+
{"version":3,"file":"invariantWrappers.js","sourceRoot":"","sources":["../../../src/utilities/globals/invariantWrappers.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,SAAS,IAAI,iBAAiB,EAAE,cAAc,EAAE,MAAM,cAAc,CAAC;AAC9E,OAAO,EAAE,OAAO,EAAE,MAAM,kBAAkB,CAAC;AAC3C,OAAO,MAAM,MAAM,aAAa,CAAC;AAEjC,OAAO,EAAE,mBAAmB,EAAE,MAAM,kCAAkC,CAAC;AAEvE,SAAS,IAAI,CAAC,EAA0C;IACtD,OAAO,UAAU,OAAyB;QAAE,cAAc;aAAd,UAAc,EAAd,qBAAc,EAAd,IAAc;YAAd,6BAAc;;QACxD,IAAI,OAAO,OAAO,KAAK,QAAQ,EAAE,CAAC;YAChC,IAAM,IAAI,GAAG,OAAO,CAAC;YACrB,OAAO,GAAG,kBAAkB,CAAC,IAAI,CAAC,CAAC;YACnC,IAAI,CAAC,OAAO,EAAE,CAAC;gBACb,OAAO,GAAG,mBAAmB,CAAC,IAAI,EAAE,IAAI,CAAC,CAAC;gBAC1C,IAAI,GAAG,EAAE,CAAC;YACZ,CAAC;QACH,CAAC;QACD,EAAE,eAAI,CAAC,OAAO,CAAC,CAAC,MAAM,CAAC,IAAI,CAAC,EAAE;IAChC,CAAC,CAAC;AACJ,CAAC;AAgDD,IAAM,SAAS,GAAqB,MAAM,CAAC,MAAM,CAC/C,SAAS,SAAS,CAChB,SAAc,EACd,OAAyB;IACzB,cAAkB;SAAlB,UAAkB,EAAlB,qBAAkB,EAAlB,IAAkB;QAAlB,6BAAkB;;IAElB,IAAI,CAAC,SAAS,EAAE,CAAC;QACf,iBAAiB,CACf,SAAS,EACT,kBAAkB,CAAC,OAAO,EAAE,IAAI,CAAC,IAAI,mBAAmB,CAAC,OAAO,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CAAC,OAAO;QAAE,OAAO;IACrB,OAAO,sGAA+F,kBAAkB,CACtH,IAAI,CAAC,SAAS,CAAC;QACb,OAAO,SAAA;QACP,OAAO,SAAA;QACP,IAAI,EAAE,WAAW,CAAC,GAAG,CAAC,SAAS,CAAC;KACjC,CAAC,CACH,CAAE,CAAC;AACN,CAAC;AAED,OAAO,EACL,SAAS,EACT,cAAc,EACd,iBAAiB,EACjB,yBAAyB,GAC1B,CAAC","sourcesContent":["import { invariant as originalInvariant, InvariantError } from \"ts-invariant\";\nimport { version } from \"../../version.js\";\nimport global from \"./global.js\";\nimport type { ErrorCodes } from \"../../invariantErrorCodes.js\";\nimport { stringifyForDisplay } from \"../common/stringifyForDisplay.js\";\n\nfunction wrap(fn: (msg?: string, ...args: any[]) => void) {\n return function (message?: string | number, ...args: any[]) {\n if (typeof message === \"number\") {\n const arg0 = message;\n message = getHandledErrorMsg(arg0);\n if (!message) {\n message = getFallbackErrorMsg(arg0, args);\n args = [];\n }\n }\n fn(...[message].concat(args));\n };\n}\n\ntype LogFunction = {\n /**\n * Logs a `$level` message if the user used `ts-invariant`'s `setVerbosity` to set\n * a verbosity level of `$level` or lower. (defaults to `\"log\"`).\n *\n * The user will either be presented with a link to the documentation for the message,\n * or they can use the `loadDevMessages` to add the message strings to the bundle.\n * The documentation will display the message without argument substitution.\n * Instead, the arguments will be printed on the console after the link.\n *\n * `message` can only be a string, a concatenation of strings, or a ternary statement\n * that results in a string. This will be enforced on build, where the message will\n * be replaced with a message number.\n *\n * String substitutions like %s, %o, %d or %f are supported.\n */\n (message?: any, ...optionalParams: unknown[]): void;\n};\n\ntype WrappedInvariant = {\n /**\n * Throws and InvariantError with the given message if the condition is false.\n *\n * `message` can only be a string, a concatenation of strings, or a ternary statement\n * that results in a string. This will be enforced on build, where the message will\n * be replaced with a message number.\n *\n * The user will either be presented with a link to the documentation for the message,\n * or they can use the `loadErrorMessages` to add the message strings to the bundle.\n * The documentation will display the message with the arguments substituted.\n *\n * String substitutions with %s are supported and will also return\n * pretty-stringified objects.\n * Excess `optionalParams` will be swallowed.\n */\n (\n condition: any,\n message?: string | number,\n ...optionalParams: unknown[]\n ): asserts condition;\n\n debug: LogFunction;\n log: LogFunction;\n warn: LogFunction;\n error: LogFunction;\n};\nconst invariant: WrappedInvariant = Object.assign(\n function invariant(\n condition: any,\n message?: string | number,\n ...args: unknown[]\n ): asserts condition {\n if (!condition) {\n originalInvariant(\n condition,\n getHandledErrorMsg(message, args) || getFallbackErrorMsg(message, args)\n );\n }\n },\n {\n debug: wrap(originalInvariant.debug),\n log: wrap(originalInvariant.log),\n warn: wrap(originalInvariant.warn),\n error: wrap(originalInvariant.error),\n }\n);\n\n/**\n * Returns an InvariantError.\n *\n * `message` can only be a string, a concatenation of strings, or a ternary statement\n * that results in a string. This will be enforced on build, where the message will\n * be replaced with a message number.\n * String substitutions with %s are supported and will also return\n * pretty-stringified objects.\n * Excess `optionalParams` will be swallowed.\n */\nfunction newInvariantError(\n message?: string | number,\n ...optionalParams: unknown[]\n) {\n return new InvariantError(\n getHandledErrorMsg(message, optionalParams) ||\n getFallbackErrorMsg(message, optionalParams)\n );\n}\n\nconst ApolloErrorMessageHandler = Symbol.for(\n \"ApolloErrorMessageHandler_\" + version\n);\ndeclare global {\n interface Window {\n [ApolloErrorMessageHandler]?: {\n (message: string | number, args: string[]): string | undefined;\n } & ErrorCodes;\n }\n}\n\nfunction stringify(arg: any) {\n return typeof arg == \"string\" ? arg : (\n stringifyForDisplay(arg, 2).slice(0, 1000)\n );\n}\n\nfunction getHandledErrorMsg(\n message?: string | number,\n messageArgs: unknown[] = []\n) {\n if (!message) return;\n return (\n global[ApolloErrorMessageHandler] &&\n global[ApolloErrorMessageHandler](message, messageArgs.map(stringify))\n );\n}\n\nfunction getFallbackErrorMsg(\n message?: string | number,\n messageArgs: unknown[] = []\n) {\n if (!message) return;\n return `An error occurred! For more details, see the full error text at https://go.apollo.dev/c/err#${encodeURIComponent(\n JSON.stringify({\n version,\n message,\n args: messageArgs.map(stringify),\n })\n )}`;\n}\n\nexport {\n invariant,\n InvariantError,\n newInvariantError,\n ApolloErrorMessageHandler,\n};\n"]}
|
|
@@ -180,10 +180,10 @@ function isApolloPayloadResult(value) {
|
|
|
180
180
|
}
|
|
181
181
|
|
|
182
182
|
function readMultipartBody(response, nextValue) {
|
|
183
|
-
var _a;
|
|
184
183
|
return tslib.__awaiter(this, void 0, void 0, function () {
|
|
185
|
-
var decoder, contentType, delimiter, boundaryVal, boundary, buffer, iterator, running,
|
|
186
|
-
var
|
|
184
|
+
var decoder, contentType, delimiter, boundaryVal, boundary, buffer, iterator, running, _a, value, done, chunk, searchFrom, bi, message, i, headers, contentType_1, body, result, next;
|
|
185
|
+
var _b, _c;
|
|
186
|
+
var _d;
|
|
187
187
|
return tslib.__generator(this, function (_e) {
|
|
188
188
|
switch (_e.label) {
|
|
189
189
|
case 0:
|
|
@@ -191,7 +191,7 @@ function readMultipartBody(response, nextValue) {
|
|
|
191
191
|
throw new Error("TextDecoder must be defined in the environment: please import a polyfill.");
|
|
192
192
|
}
|
|
193
193
|
decoder = new TextDecoder("utf-8");
|
|
194
|
-
contentType = (
|
|
194
|
+
contentType = (_d = response.headers) === null || _d === void 0 ? void 0 : _d.get("content-type");
|
|
195
195
|
delimiter = "boundary=";
|
|
196
196
|
boundaryVal = (contentType === null || contentType === void 0 ? void 0 : contentType.includes(delimiter)) ?
|
|
197
197
|
contentType === null || contentType === void 0 ? void 0 : contentType.substring((contentType === null || contentType === void 0 ? void 0 : contentType.indexOf(delimiter)) + delimiter.length).replace(/['"]/g, "").replace(/\;(.*)/gm, "").trim()
|
|
@@ -205,7 +205,7 @@ function readMultipartBody(response, nextValue) {
|
|
|
205
205
|
if (!running) return [3 , 3];
|
|
206
206
|
return [4 , iterator.next()];
|
|
207
207
|
case 2:
|
|
208
|
-
|
|
208
|
+
_a = _e.sent(), value = _a.value, done = _a.done;
|
|
209
209
|
chunk = typeof value === "string" ? value : decoder.decode(value);
|
|
210
210
|
searchFrom = buffer.length - boundary.length + 1;
|
|
211
211
|
running = !done;
|
|
@@ -213,10 +213,10 @@ function readMultipartBody(response, nextValue) {
|
|
|
213
213
|
bi = buffer.indexOf(boundary, searchFrom);
|
|
214
214
|
while (bi > -1) {
|
|
215
215
|
message = void 0;
|
|
216
|
-
|
|
216
|
+
_b = [
|
|
217
217
|
buffer.slice(0, bi),
|
|
218
218
|
buffer.slice(bi + boundary.length),
|
|
219
|
-
], message =
|
|
219
|
+
], message = _b[0], buffer = _b[1];
|
|
220
220
|
i = message.indexOf("\r\n\r\n");
|
|
221
221
|
headers = parseHeaders(message.slice(0, i));
|
|
222
222
|
contentType_1 = headers["content-type"];
|
|
@@ -235,10 +235,13 @@ function readMultipartBody(response, nextValue) {
|
|
|
235
235
|
if (isApolloPayloadResult(result)) {
|
|
236
236
|
next = {};
|
|
237
237
|
if ("payload" in result) {
|
|
238
|
+
if (Object.keys(result).length === 1 && result.payload === null) {
|
|
239
|
+
return [2 ];
|
|
240
|
+
}
|
|
238
241
|
next = tslib.__assign({}, result.payload);
|
|
239
242
|
}
|
|
240
243
|
if ("errors" in result) {
|
|
241
|
-
next = tslib.__assign(tslib.__assign({}, next), { extensions: tslib.__assign(tslib.__assign({}, ("extensions" in next ? next.extensions : null)), (
|
|
244
|
+
next = tslib.__assign(tslib.__assign({}, next), { extensions: tslib.__assign(tslib.__assign({}, ("extensions" in next ? next.extensions : null)), (_c = {}, _c[errors.PROTOCOL_ERRORS_SYMBOL] = result.errors, _c)) });
|
|
242
245
|
}
|
|
243
246
|
nextValue(next);
|
|
244
247
|
}
|