@tanstack/react-query 4.39.0 → 4.39.2

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.
Files changed (150) hide show
  1. package/build/lib/Hydrate.esm.js +32 -0
  2. package/build/lib/Hydrate.esm.js.map +1 -0
  3. package/build/lib/Hydrate.js +57 -0
  4. package/build/lib/Hydrate.js.map +1 -0
  5. package/build/lib/Hydrate.mjs +32 -0
  6. package/build/lib/Hydrate.mjs.map +1 -0
  7. package/build/lib/QueryClientProvider.esm.js +66 -0
  8. package/build/lib/QueryClientProvider.esm.js.map +1 -0
  9. package/build/lib/QueryClientProvider.js +92 -0
  10. package/build/lib/QueryClientProvider.js.map +1 -0
  11. package/build/lib/QueryClientProvider.mjs +66 -0
  12. package/build/lib/QueryClientProvider.mjs.map +1 -0
  13. package/build/lib/QueryErrorResetBoundary.esm.js +33 -0
  14. package/build/lib/QueryErrorResetBoundary.esm.js.map +1 -0
  15. package/build/lib/QueryErrorResetBoundary.js +58 -0
  16. package/build/lib/QueryErrorResetBoundary.js.map +1 -0
  17. package/build/lib/QueryErrorResetBoundary.mjs +33 -0
  18. package/build/lib/QueryErrorResetBoundary.mjs.map +1 -0
  19. package/build/lib/errorBoundaryUtils.esm.js +28 -0
  20. package/build/lib/errorBoundaryUtils.esm.js.map +1 -0
  21. package/build/lib/errorBoundaryUtils.js +54 -0
  22. package/build/lib/errorBoundaryUtils.js.map +1 -0
  23. package/build/lib/errorBoundaryUtils.mjs +28 -0
  24. package/build/lib/errorBoundaryUtils.mjs.map +1 -0
  25. package/build/lib/index.esm.js +16 -0
  26. package/build/lib/index.esm.js.map +1 -0
  27. package/build/lib/index.js +47 -0
  28. package/build/lib/index.js.map +1 -0
  29. package/build/lib/index.mjs +16 -0
  30. package/build/lib/index.mjs.map +1 -0
  31. package/build/lib/isRestoring.esm.js +9 -0
  32. package/build/lib/isRestoring.esm.js.map +1 -0
  33. package/build/lib/isRestoring.js +34 -0
  34. package/build/lib/isRestoring.js.map +1 -0
  35. package/build/lib/isRestoring.mjs +9 -0
  36. package/build/lib/isRestoring.mjs.map +1 -0
  37. package/build/lib/queryOptions.d.ts +2 -2
  38. package/build/lib/queryOptions.esm.js +6 -0
  39. package/build/lib/queryOptions.esm.js.map +1 -0
  40. package/build/lib/queryOptions.js +10 -0
  41. package/build/lib/queryOptions.js.map +1 -0
  42. package/build/lib/queryOptions.mjs +6 -0
  43. package/build/lib/queryOptions.mjs.map +1 -0
  44. package/build/lib/reactBatchedUpdates.esm.js +7 -0
  45. package/build/lib/reactBatchedUpdates.esm.js.map +1 -0
  46. package/build/lib/reactBatchedUpdates.js +31 -0
  47. package/build/lib/reactBatchedUpdates.js.map +1 -0
  48. package/build/lib/reactBatchedUpdates.mjs +7 -0
  49. package/build/lib/reactBatchedUpdates.mjs.map +1 -0
  50. package/build/lib/reactBatchedUpdates.native.esm.js +2 -0
  51. package/build/lib/reactBatchedUpdates.native.esm.js.map +1 -0
  52. package/build/lib/reactBatchedUpdates.native.js +13 -0
  53. package/build/lib/reactBatchedUpdates.native.js.map +1 -0
  54. package/build/lib/reactBatchedUpdates.native.mjs +2 -0
  55. package/build/lib/reactBatchedUpdates.native.mjs.map +1 -0
  56. package/build/lib/setBatchUpdatesFn.esm.js +5 -0
  57. package/build/lib/setBatchUpdatesFn.esm.js.map +1 -0
  58. package/build/lib/setBatchUpdatesFn.js +7 -0
  59. package/build/lib/setBatchUpdatesFn.js.map +1 -0
  60. package/build/lib/setBatchUpdatesFn.mjs +5 -0
  61. package/build/lib/setBatchUpdatesFn.mjs.map +1 -0
  62. package/build/lib/suspense.esm.js +24 -0
  63. package/build/lib/suspense.esm.js.map +1 -0
  64. package/build/lib/suspense.js +31 -0
  65. package/build/lib/suspense.js.map +1 -0
  66. package/build/lib/suspense.mjs +24 -0
  67. package/build/lib/suspense.mjs.map +1 -0
  68. package/build/lib/useBaseQuery.esm.js +72 -0
  69. package/build/lib/useBaseQuery.esm.js.map +1 -0
  70. package/build/lib/useBaseQuery.js +96 -0
  71. package/build/lib/useBaseQuery.js.map +1 -0
  72. package/build/lib/useBaseQuery.mjs +72 -0
  73. package/build/lib/useBaseQuery.mjs.map +1 -0
  74. package/build/lib/useInfiniteQuery.esm.js +11 -0
  75. package/build/lib/useInfiniteQuery.esm.js.map +1 -0
  76. package/build/lib/useInfiniteQuery.js +15 -0
  77. package/build/lib/useInfiniteQuery.js.map +1 -0
  78. package/build/lib/useInfiniteQuery.mjs +11 -0
  79. package/build/lib/useInfiniteQuery.mjs.map +1 -0
  80. package/build/lib/useIsFetching.esm.js +17 -0
  81. package/build/lib/useIsFetching.esm.js.map +1 -0
  82. package/build/lib/useIsFetching.js +41 -0
  83. package/build/lib/useIsFetching.js.map +1 -0
  84. package/build/lib/useIsFetching.mjs +17 -0
  85. package/build/lib/useIsFetching.mjs.map +1 -0
  86. package/build/lib/useIsMutating.esm.js +17 -0
  87. package/build/lib/useIsMutating.esm.js.map +1 -0
  88. package/build/lib/useIsMutating.js +41 -0
  89. package/build/lib/useIsMutating.js.map +1 -0
  90. package/build/lib/useIsMutating.mjs +17 -0
  91. package/build/lib/useIsMutating.mjs.map +1 -0
  92. package/build/lib/useMutation.esm.js +35 -0
  93. package/build/lib/useMutation.esm.js.map +1 -0
  94. package/build/lib/useMutation.js +59 -0
  95. package/build/lib/useMutation.js.map +1 -0
  96. package/build/lib/useMutation.mjs +35 -0
  97. package/build/lib/useMutation.mjs.map +1 -0
  98. package/build/lib/useQueries.esm.js +81 -0
  99. package/build/lib/useQueries.esm.js.map +1 -0
  100. package/build/lib/useQueries.js +105 -0
  101. package/build/lib/useQueries.js.map +1 -0
  102. package/build/lib/useQueries.mjs +81 -0
  103. package/build/lib/useQueries.mjs.map +1 -0
  104. package/build/lib/useQuery.d.ts +0 -3
  105. package/build/lib/useQuery.esm.js +12 -0
  106. package/build/lib/useQuery.esm.js.map +1 -0
  107. package/build/lib/useQuery.js +16 -0
  108. package/build/lib/useQuery.js.map +1 -0
  109. package/build/lib/useQuery.mjs +12 -0
  110. package/build/lib/useQuery.mjs.map +1 -0
  111. package/build/lib/useSuspenseQueries.esm.js +20 -0
  112. package/build/lib/useSuspenseQueries.esm.js.map +1 -0
  113. package/build/lib/useSuspenseQueries.js +24 -0
  114. package/build/lib/useSuspenseQueries.js.map +1 -0
  115. package/build/lib/useSuspenseQueries.mjs +20 -0
  116. package/build/lib/useSuspenseQueries.mjs.map +1 -0
  117. package/build/lib/useSuspenseQuery.d.ts +1 -3
  118. package/build/lib/useSuspenseQuery.esm.js +15 -0
  119. package/build/lib/useSuspenseQuery.esm.js.map +1 -0
  120. package/build/lib/useSuspenseQuery.js +19 -0
  121. package/build/lib/useSuspenseQuery.js.map +1 -0
  122. package/build/lib/useSuspenseQuery.mjs +15 -0
  123. package/build/lib/useSuspenseQuery.mjs.map +1 -0
  124. package/build/lib/useSyncExternalStore.esm.js +7 -0
  125. package/build/lib/useSyncExternalStore.esm.js.map +1 -0
  126. package/build/lib/useSyncExternalStore.js +11 -0
  127. package/build/lib/useSyncExternalStore.js.map +1 -0
  128. package/build/lib/useSyncExternalStore.mjs +7 -0
  129. package/build/lib/useSyncExternalStore.mjs.map +1 -0
  130. package/build/lib/useSyncExternalStore.native.esm.js +2 -0
  131. package/build/lib/useSyncExternalStore.native.esm.js.map +1 -0
  132. package/build/lib/useSyncExternalStore.native.js +13 -0
  133. package/build/lib/useSyncExternalStore.native.js.map +1 -0
  134. package/build/lib/useSyncExternalStore.native.mjs +2 -0
  135. package/build/lib/useSyncExternalStore.native.mjs.map +1 -0
  136. package/build/lib/utils.esm.js +11 -0
  137. package/build/lib/utils.esm.js.map +1 -0
  138. package/build/lib/utils.js +15 -0
  139. package/build/lib/utils.js.map +1 -0
  140. package/build/lib/utils.mjs +11 -0
  141. package/build/lib/utils.mjs.map +1 -0
  142. package/build/umd/index.development.js +4049 -0
  143. package/build/umd/index.development.js.map +1 -0
  144. package/build/umd/index.production.js +2 -0
  145. package/build/umd/index.production.js.map +1 -0
  146. package/package.json +2 -2
  147. package/src/__tests__/useQuery.types.test.tsx +35 -0
  148. package/src/queryOptions.ts +2 -2
  149. package/src/useQuery.ts +0 -20
  150. package/src/useSuspenseQuery.ts +1 -4
@@ -0,0 +1,32 @@
1
+ 'use client';
2
+ import * as React from 'react';
3
+ import { hydrate } from '@tanstack/query-core';
4
+ import { useQueryClient } from './QueryClientProvider.esm.js';
5
+
6
+ function useHydrate(state, options = {}) {
7
+ const queryClient = useQueryClient({
8
+ context: options.context
9
+ });
10
+ const optionsRef = React.useRef(options);
11
+ optionsRef.current = options; // Running hydrate again with the same queries is safe,
12
+ // it wont overwrite or initialize existing queries,
13
+ // relying on useMemo here is only a performance optimization.
14
+ // hydrate can and should be run *during* render here for SSR to work properly
15
+
16
+ React.useMemo(() => {
17
+ if (state) {
18
+ hydrate(queryClient, state, optionsRef.current);
19
+ }
20
+ }, [queryClient, state]);
21
+ }
22
+ const Hydrate = ({
23
+ children,
24
+ options,
25
+ state
26
+ }) => {
27
+ useHydrate(state, options);
28
+ return children;
29
+ };
30
+
31
+ export { Hydrate, useHydrate };
32
+ //# sourceMappingURL=Hydrate.esm.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"Hydrate.esm.js","sources":["../../src/Hydrate.tsx"],"sourcesContent":["'use client'\nimport * as React from 'react'\n\nimport { hydrate } from '@tanstack/query-core'\nimport { useQueryClient } from './QueryClientProvider'\nimport type { HydrateOptions } from '@tanstack/query-core'\nimport type { ContextOptions } from './types'\n\nexport function useHydrate(\n state: unknown,\n options: HydrateOptions & ContextOptions = {},\n) {\n const queryClient = useQueryClient({ context: options.context })\n\n const optionsRef = React.useRef(options)\n optionsRef.current = options\n\n // Running hydrate again with the same queries is safe,\n // it wont overwrite or initialize existing queries,\n // relying on useMemo here is only a performance optimization.\n // hydrate can and should be run *during* render here for SSR to work properly\n React.useMemo(() => {\n if (state) {\n hydrate(queryClient, state, optionsRef.current)\n }\n }, [queryClient, state])\n}\n\nexport interface HydrateProps {\n state?: unknown\n options?: HydrateOptions\n children?: React.ReactNode\n}\n\nexport const Hydrate = ({ children, options, state }: HydrateProps) => {\n useHydrate(state, options)\n return children as React.ReactElement\n}\n"],"names":["optionsRef","state","useHydrate"],"mappings":";;;;;AAQO;;;AAI8B;AAEnC;AACAA;AAGA;AACA;AACA;;;AAEE;;AAEC;AACF;AACF;AAQM;;;AAAsCC;AAArB;AACtBC;AACA;AACD;;"}
@@ -0,0 +1,57 @@
1
+ 'use client';
2
+ 'use strict';
3
+
4
+ Object.defineProperty(exports, '__esModule', { value: true });
5
+
6
+ var React = require('react');
7
+ var queryCore = require('@tanstack/query-core');
8
+ var QueryClientProvider = require('./QueryClientProvider.js');
9
+
10
+ function _interopNamespace(e) {
11
+ if (e && e.__esModule) return e;
12
+ var n = Object.create(null);
13
+ if (e) {
14
+ Object.keys(e).forEach(function (k) {
15
+ if (k !== 'default') {
16
+ var d = Object.getOwnPropertyDescriptor(e, k);
17
+ Object.defineProperty(n, k, d.get ? d : {
18
+ enumerable: true,
19
+ get: function () { return e[k]; }
20
+ });
21
+ }
22
+ });
23
+ }
24
+ n["default"] = e;
25
+ return Object.freeze(n);
26
+ }
27
+
28
+ var React__namespace = /*#__PURE__*/_interopNamespace(React);
29
+
30
+ function useHydrate(state, options = {}) {
31
+ const queryClient = QueryClientProvider.useQueryClient({
32
+ context: options.context
33
+ });
34
+ const optionsRef = React__namespace.useRef(options);
35
+ optionsRef.current = options; // Running hydrate again with the same queries is safe,
36
+ // it wont overwrite or initialize existing queries,
37
+ // relying on useMemo here is only a performance optimization.
38
+ // hydrate can and should be run *during* render here for SSR to work properly
39
+
40
+ React__namespace.useMemo(() => {
41
+ if (state) {
42
+ queryCore.hydrate(queryClient, state, optionsRef.current);
43
+ }
44
+ }, [queryClient, state]);
45
+ }
46
+ const Hydrate = ({
47
+ children,
48
+ options,
49
+ state
50
+ }) => {
51
+ useHydrate(state, options);
52
+ return children;
53
+ };
54
+
55
+ exports.Hydrate = Hydrate;
56
+ exports.useHydrate = useHydrate;
57
+ //# sourceMappingURL=Hydrate.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"Hydrate.js","sources":["../../src/Hydrate.tsx"],"sourcesContent":["'use client'\nimport * as React from 'react'\n\nimport { hydrate } from '@tanstack/query-core'\nimport { useQueryClient } from './QueryClientProvider'\nimport type { HydrateOptions } from '@tanstack/query-core'\nimport type { ContextOptions } from './types'\n\nexport function useHydrate(\n state: unknown,\n options: HydrateOptions & ContextOptions = {},\n) {\n const queryClient = useQueryClient({ context: options.context })\n\n const optionsRef = React.useRef(options)\n optionsRef.current = options\n\n // Running hydrate again with the same queries is safe,\n // it wont overwrite or initialize existing queries,\n // relying on useMemo here is only a performance optimization.\n // hydrate can and should be run *during* render here for SSR to work properly\n React.useMemo(() => {\n if (state) {\n hydrate(queryClient, state, optionsRef.current)\n }\n }, [queryClient, state])\n}\n\nexport interface HydrateProps {\n state?: unknown\n options?: HydrateOptions\n children?: React.ReactNode\n}\n\nexport const Hydrate = ({ children, options, state }: HydrateProps) => {\n useHydrate(state, options)\n return children as React.ReactElement\n}\n"],"names":["optionsRef","state","useHydrate"],"mappings":";;;;;;;;;;;;;;;;;;;;;;;;;;;;;AAQO;;;AAI8B;AAEnC;AACAA;AAGA;AACA;AACA;;;AAEE;;AAEC;AACF;AACF;AAQM;;;AAAsCC;AAArB;AACtBC;AACA;AACD;;;"}
@@ -0,0 +1,32 @@
1
+ 'use client';
2
+ import * as React from 'react';
3
+ import { hydrate } from '@tanstack/query-core';
4
+ import { useQueryClient } from './QueryClientProvider.mjs';
5
+
6
+ function useHydrate(state, options = {}) {
7
+ const queryClient = useQueryClient({
8
+ context: options.context
9
+ });
10
+ const optionsRef = React.useRef(options);
11
+ optionsRef.current = options; // Running hydrate again with the same queries is safe,
12
+ // it wont overwrite or initialize existing queries,
13
+ // relying on useMemo here is only a performance optimization.
14
+ // hydrate can and should be run *during* render here for SSR to work properly
15
+
16
+ React.useMemo(() => {
17
+ if (state) {
18
+ hydrate(queryClient, state, optionsRef.current);
19
+ }
20
+ }, [queryClient, state]);
21
+ }
22
+ const Hydrate = ({
23
+ children,
24
+ options,
25
+ state
26
+ }) => {
27
+ useHydrate(state, options);
28
+ return children;
29
+ };
30
+
31
+ export { Hydrate, useHydrate };
32
+ //# sourceMappingURL=Hydrate.mjs.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"Hydrate.mjs","sources":["../../src/Hydrate.tsx"],"sourcesContent":["'use client'\nimport * as React from 'react'\n\nimport { hydrate } from '@tanstack/query-core'\nimport { useQueryClient } from './QueryClientProvider'\nimport type { HydrateOptions } from '@tanstack/query-core'\nimport type { ContextOptions } from './types'\n\nexport function useHydrate(\n state: unknown,\n options: HydrateOptions & ContextOptions = {},\n) {\n const queryClient = useQueryClient({ context: options.context })\n\n const optionsRef = React.useRef(options)\n optionsRef.current = options\n\n // Running hydrate again with the same queries is safe,\n // it wont overwrite or initialize existing queries,\n // relying on useMemo here is only a performance optimization.\n // hydrate can and should be run *during* render here for SSR to work properly\n React.useMemo(() => {\n if (state) {\n hydrate(queryClient, state, optionsRef.current)\n }\n }, [queryClient, state])\n}\n\nexport interface HydrateProps {\n state?: unknown\n options?: HydrateOptions\n children?: React.ReactNode\n}\n\nexport const Hydrate = ({ children, options, state }: HydrateProps) => {\n useHydrate(state, options)\n return children as React.ReactElement\n}\n"],"names":["optionsRef","state","useHydrate"],"mappings":";;;;;AAQO;;;AAI8B;AAEnC;AACAA;AAGA;AACA;AACA;;;AAEE;;AAEC;AACF;AACF;AAQM;;;AAAsCC;AAArB;AACtBC;AACA;AACD;;"}
@@ -0,0 +1,66 @@
1
+ 'use client';
2
+ import * as React from 'react';
3
+
4
+ const defaultContext = /*#__PURE__*/React.createContext(undefined);
5
+ const QueryClientSharingContext = /*#__PURE__*/React.createContext(false); // If we are given a context, we will use it.
6
+ // Otherwise, if contextSharing is on, we share the first and at least one
7
+ // instance of the context across the window
8
+ // to ensure that if React Query is used across
9
+ // different bundles or microfrontends they will
10
+ // all use the same **instance** of context, regardless
11
+ // of module scoping.
12
+
13
+ function getQueryClientContext(context, contextSharing) {
14
+ if (context) {
15
+ return context;
16
+ }
17
+
18
+ if (contextSharing && typeof window !== 'undefined') {
19
+ if (!window.ReactQueryClientContext) {
20
+ window.ReactQueryClientContext = defaultContext;
21
+ }
22
+
23
+ return window.ReactQueryClientContext;
24
+ }
25
+
26
+ return defaultContext;
27
+ }
28
+
29
+ const useQueryClient = ({
30
+ context
31
+ } = {}) => {
32
+ const queryClient = React.useContext(getQueryClientContext(context, React.useContext(QueryClientSharingContext)));
33
+
34
+ if (!queryClient) {
35
+ throw new Error('No QueryClient set, use QueryClientProvider to set one');
36
+ }
37
+
38
+ return queryClient;
39
+ };
40
+ const QueryClientProvider = ({
41
+ client,
42
+ children,
43
+ context,
44
+ contextSharing = false
45
+ }) => {
46
+ React.useEffect(() => {
47
+ client.mount();
48
+ return () => {
49
+ client.unmount();
50
+ };
51
+ }, [client]);
52
+
53
+ if (process.env.NODE_ENV !== 'production' && contextSharing) {
54
+ client.getLogger().error("The contextSharing option has been deprecated and will be removed in the next major version");
55
+ }
56
+
57
+ const Context = getQueryClientContext(context, contextSharing);
58
+ return /*#__PURE__*/React.createElement(QueryClientSharingContext.Provider, {
59
+ value: !context && contextSharing
60
+ }, /*#__PURE__*/React.createElement(Context.Provider, {
61
+ value: client
62
+ }, children));
63
+ };
64
+
65
+ export { QueryClientProvider, defaultContext, useQueryClient };
66
+ //# sourceMappingURL=QueryClientProvider.esm.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"QueryClientProvider.esm.js","sources":["../../src/QueryClientProvider.tsx"],"sourcesContent":["'use client'\nimport * as React from 'react'\n\nimport type { QueryClient } from '@tanstack/query-core'\nimport type { ContextOptions } from './types'\n\ndeclare global {\n interface Window {\n ReactQueryClientContext?: React.Context<QueryClient | undefined>\n }\n}\n\nexport const defaultContext = React.createContext<QueryClient | undefined>(\n undefined,\n)\nconst QueryClientSharingContext = React.createContext<boolean>(false)\n\n// If we are given a context, we will use it.\n// Otherwise, if contextSharing is on, we share the first and at least one\n// instance of the context across the window\n// to ensure that if React Query is used across\n// different bundles or microfrontends they will\n// all use the same **instance** of context, regardless\n// of module scoping.\nfunction getQueryClientContext(\n context: React.Context<QueryClient | undefined> | undefined,\n contextSharing: boolean,\n) {\n if (context) {\n return context\n }\n if (contextSharing && typeof window !== 'undefined') {\n if (!window.ReactQueryClientContext) {\n window.ReactQueryClientContext = defaultContext\n }\n\n return window.ReactQueryClientContext\n }\n\n return defaultContext\n}\n\nexport const useQueryClient = ({ context }: ContextOptions = {}) => {\n const queryClient = React.useContext(\n getQueryClientContext(context, React.useContext(QueryClientSharingContext)),\n )\n\n if (!queryClient) {\n throw new Error('No QueryClient set, use QueryClientProvider to set one')\n }\n\n return queryClient\n}\n\ntype QueryClientProviderPropsBase = {\n client: QueryClient\n children?: React.ReactNode\n}\ntype QueryClientProviderPropsWithContext = ContextOptions & {\n contextSharing?: never\n} & QueryClientProviderPropsBase\ntype QueryClientProviderPropsWithContextSharing = {\n context?: never\n contextSharing?: boolean\n} & QueryClientProviderPropsBase\n\nexport type QueryClientProviderProps =\n | QueryClientProviderPropsWithContext\n | QueryClientProviderPropsWithContextSharing\n\nexport const QueryClientProvider = ({\n client,\n children,\n context,\n contextSharing = false,\n}: QueryClientProviderProps): JSX.Element => {\n React.useEffect(() => {\n client.mount()\n return () => {\n client.unmount()\n }\n }, [client])\n\n if (process.env.NODE_ENV !== 'production' && contextSharing) {\n client\n .getLogger()\n .error(\n `The contextSharing option has been deprecated and will be removed in the next major version`,\n )\n }\n\n const Context = getQueryClientContext(context, contextSharing)\n\n return (\n <QueryClientSharingContext.Provider value={!context && contextSharing}>\n <Context.Provider value={client}>{children}</Context.Provider>\n </QueryClientSharingContext.Provider>\n )\n}\n"],"names":["context","contextSharing","client"],"mappings":";;;AAYO;AAGP;AAGA;AACA;AACA;AACA;AACA;AACA;;AACA;AAIE;AACE;AACD;;AACD;AACE;;AAEC;;;AAGF;;AAED;AACD;;AAEM;AAA0BA;AAAF;AAC7B;;;AAKE;AACD;;AAED;AACD;AAkBM;;;;AAILC;AAJkC;;AAOhCC;AACA;AACEA;;;;;;AAUH;;AAED;;;;AAIsB;;AAGvB;;"}
@@ -0,0 +1,92 @@
1
+ 'use client';
2
+ 'use strict';
3
+
4
+ Object.defineProperty(exports, '__esModule', { value: true });
5
+
6
+ var React = require('react');
7
+
8
+ function _interopNamespace(e) {
9
+ if (e && e.__esModule) return e;
10
+ var n = Object.create(null);
11
+ if (e) {
12
+ Object.keys(e).forEach(function (k) {
13
+ if (k !== 'default') {
14
+ var d = Object.getOwnPropertyDescriptor(e, k);
15
+ Object.defineProperty(n, k, d.get ? d : {
16
+ enumerable: true,
17
+ get: function () { return e[k]; }
18
+ });
19
+ }
20
+ });
21
+ }
22
+ n["default"] = e;
23
+ return Object.freeze(n);
24
+ }
25
+
26
+ var React__namespace = /*#__PURE__*/_interopNamespace(React);
27
+
28
+ const defaultContext = /*#__PURE__*/React__namespace.createContext(undefined);
29
+ const QueryClientSharingContext = /*#__PURE__*/React__namespace.createContext(false); // If we are given a context, we will use it.
30
+ // Otherwise, if contextSharing is on, we share the first and at least one
31
+ // instance of the context across the window
32
+ // to ensure that if React Query is used across
33
+ // different bundles or microfrontends they will
34
+ // all use the same **instance** of context, regardless
35
+ // of module scoping.
36
+
37
+ function getQueryClientContext(context, contextSharing) {
38
+ if (context) {
39
+ return context;
40
+ }
41
+
42
+ if (contextSharing && typeof window !== 'undefined') {
43
+ if (!window.ReactQueryClientContext) {
44
+ window.ReactQueryClientContext = defaultContext;
45
+ }
46
+
47
+ return window.ReactQueryClientContext;
48
+ }
49
+
50
+ return defaultContext;
51
+ }
52
+
53
+ const useQueryClient = ({
54
+ context
55
+ } = {}) => {
56
+ const queryClient = React__namespace.useContext(getQueryClientContext(context, React__namespace.useContext(QueryClientSharingContext)));
57
+
58
+ if (!queryClient) {
59
+ throw new Error('No QueryClient set, use QueryClientProvider to set one');
60
+ }
61
+
62
+ return queryClient;
63
+ };
64
+ const QueryClientProvider = ({
65
+ client,
66
+ children,
67
+ context,
68
+ contextSharing = false
69
+ }) => {
70
+ React__namespace.useEffect(() => {
71
+ client.mount();
72
+ return () => {
73
+ client.unmount();
74
+ };
75
+ }, [client]);
76
+
77
+ if (process.env.NODE_ENV !== 'production' && contextSharing) {
78
+ client.getLogger().error("The contextSharing option has been deprecated and will be removed in the next major version");
79
+ }
80
+
81
+ const Context = getQueryClientContext(context, contextSharing);
82
+ return /*#__PURE__*/React__namespace.createElement(QueryClientSharingContext.Provider, {
83
+ value: !context && contextSharing
84
+ }, /*#__PURE__*/React__namespace.createElement(Context.Provider, {
85
+ value: client
86
+ }, children));
87
+ };
88
+
89
+ exports.QueryClientProvider = QueryClientProvider;
90
+ exports.defaultContext = defaultContext;
91
+ exports.useQueryClient = useQueryClient;
92
+ //# sourceMappingURL=QueryClientProvider.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"QueryClientProvider.js","sources":["../../src/QueryClientProvider.tsx"],"sourcesContent":["'use client'\nimport * as React from 'react'\n\nimport type { QueryClient } from '@tanstack/query-core'\nimport type { ContextOptions } from './types'\n\ndeclare global {\n interface Window {\n ReactQueryClientContext?: React.Context<QueryClient | undefined>\n }\n}\n\nexport const defaultContext = React.createContext<QueryClient | undefined>(\n undefined,\n)\nconst QueryClientSharingContext = React.createContext<boolean>(false)\n\n// If we are given a context, we will use it.\n// Otherwise, if contextSharing is on, we share the first and at least one\n// instance of the context across the window\n// to ensure that if React Query is used across\n// different bundles or microfrontends they will\n// all use the same **instance** of context, regardless\n// of module scoping.\nfunction getQueryClientContext(\n context: React.Context<QueryClient | undefined> | undefined,\n contextSharing: boolean,\n) {\n if (context) {\n return context\n }\n if (contextSharing && typeof window !== 'undefined') {\n if (!window.ReactQueryClientContext) {\n window.ReactQueryClientContext = defaultContext\n }\n\n return window.ReactQueryClientContext\n }\n\n return defaultContext\n}\n\nexport const useQueryClient = ({ context }: ContextOptions = {}) => {\n const queryClient = React.useContext(\n getQueryClientContext(context, React.useContext(QueryClientSharingContext)),\n )\n\n if (!queryClient) {\n throw new Error('No QueryClient set, use QueryClientProvider to set one')\n }\n\n return queryClient\n}\n\ntype QueryClientProviderPropsBase = {\n client: QueryClient\n children?: React.ReactNode\n}\ntype QueryClientProviderPropsWithContext = ContextOptions & {\n contextSharing?: never\n} & QueryClientProviderPropsBase\ntype QueryClientProviderPropsWithContextSharing = {\n context?: never\n contextSharing?: boolean\n} & QueryClientProviderPropsBase\n\nexport type QueryClientProviderProps =\n | QueryClientProviderPropsWithContext\n | QueryClientProviderPropsWithContextSharing\n\nexport const QueryClientProvider = ({\n client,\n children,\n context,\n contextSharing = false,\n}: QueryClientProviderProps): JSX.Element => {\n React.useEffect(() => {\n client.mount()\n return () => {\n client.unmount()\n }\n }, [client])\n\n if (process.env.NODE_ENV !== 'production' && contextSharing) {\n client\n .getLogger()\n .error(\n `The contextSharing option has been deprecated and will be removed in the next major version`,\n )\n }\n\n const Context = getQueryClientContext(context, contextSharing)\n\n return (\n <QueryClientSharingContext.Provider value={!context && contextSharing}>\n <Context.Provider value={client}>{children}</Context.Provider>\n </QueryClientSharingContext.Provider>\n )\n}\n"],"names":["context","contextSharing","client"],"mappings":";;;;;;;;;;;;;;;;;;;;;;;;;;;AAYO;AAGP;AAGA;AACA;AACA;AACA;AACA;AACA;;AACA;AAIE;AACE;AACD;;AACD;AACE;;AAEC;;;AAGF;;AAED;AACD;;AAEM;AAA0BA;AAAF;AAC7B;;;AAKE;AACD;;AAED;AACD;AAkBM;;;;AAILC;AAJkC;;AAOhCC;AACA;AACEA;;;;;;AAUH;;AAED;;;;AAIsB;;AAGvB;;;;"}
@@ -0,0 +1,66 @@
1
+ 'use client';
2
+ import * as React from 'react';
3
+
4
+ const defaultContext = /*#__PURE__*/React.createContext(undefined);
5
+ const QueryClientSharingContext = /*#__PURE__*/React.createContext(false); // If we are given a context, we will use it.
6
+ // Otherwise, if contextSharing is on, we share the first and at least one
7
+ // instance of the context across the window
8
+ // to ensure that if React Query is used across
9
+ // different bundles or microfrontends they will
10
+ // all use the same **instance** of context, regardless
11
+ // of module scoping.
12
+
13
+ function getQueryClientContext(context, contextSharing) {
14
+ if (context) {
15
+ return context;
16
+ }
17
+
18
+ if (contextSharing && typeof window !== 'undefined') {
19
+ if (!window.ReactQueryClientContext) {
20
+ window.ReactQueryClientContext = defaultContext;
21
+ }
22
+
23
+ return window.ReactQueryClientContext;
24
+ }
25
+
26
+ return defaultContext;
27
+ }
28
+
29
+ const useQueryClient = ({
30
+ context
31
+ } = {}) => {
32
+ const queryClient = React.useContext(getQueryClientContext(context, React.useContext(QueryClientSharingContext)));
33
+
34
+ if (!queryClient) {
35
+ throw new Error('No QueryClient set, use QueryClientProvider to set one');
36
+ }
37
+
38
+ return queryClient;
39
+ };
40
+ const QueryClientProvider = ({
41
+ client,
42
+ children,
43
+ context,
44
+ contextSharing = false
45
+ }) => {
46
+ React.useEffect(() => {
47
+ client.mount();
48
+ return () => {
49
+ client.unmount();
50
+ };
51
+ }, [client]);
52
+
53
+ if (process.env.NODE_ENV !== 'production' && contextSharing) {
54
+ client.getLogger().error("The contextSharing option has been deprecated and will be removed in the next major version");
55
+ }
56
+
57
+ const Context = getQueryClientContext(context, contextSharing);
58
+ return /*#__PURE__*/React.createElement(QueryClientSharingContext.Provider, {
59
+ value: !context && contextSharing
60
+ }, /*#__PURE__*/React.createElement(Context.Provider, {
61
+ value: client
62
+ }, children));
63
+ };
64
+
65
+ export { QueryClientProvider, defaultContext, useQueryClient };
66
+ //# sourceMappingURL=QueryClientProvider.mjs.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"QueryClientProvider.mjs","sources":["../../src/QueryClientProvider.tsx"],"sourcesContent":["'use client'\nimport * as React from 'react'\n\nimport type { QueryClient } from '@tanstack/query-core'\nimport type { ContextOptions } from './types'\n\ndeclare global {\n interface Window {\n ReactQueryClientContext?: React.Context<QueryClient | undefined>\n }\n}\n\nexport const defaultContext = React.createContext<QueryClient | undefined>(\n undefined,\n)\nconst QueryClientSharingContext = React.createContext<boolean>(false)\n\n// If we are given a context, we will use it.\n// Otherwise, if contextSharing is on, we share the first and at least one\n// instance of the context across the window\n// to ensure that if React Query is used across\n// different bundles or microfrontends they will\n// all use the same **instance** of context, regardless\n// of module scoping.\nfunction getQueryClientContext(\n context: React.Context<QueryClient | undefined> | undefined,\n contextSharing: boolean,\n) {\n if (context) {\n return context\n }\n if (contextSharing && typeof window !== 'undefined') {\n if (!window.ReactQueryClientContext) {\n window.ReactQueryClientContext = defaultContext\n }\n\n return window.ReactQueryClientContext\n }\n\n return defaultContext\n}\n\nexport const useQueryClient = ({ context }: ContextOptions = {}) => {\n const queryClient = React.useContext(\n getQueryClientContext(context, React.useContext(QueryClientSharingContext)),\n )\n\n if (!queryClient) {\n throw new Error('No QueryClient set, use QueryClientProvider to set one')\n }\n\n return queryClient\n}\n\ntype QueryClientProviderPropsBase = {\n client: QueryClient\n children?: React.ReactNode\n}\ntype QueryClientProviderPropsWithContext = ContextOptions & {\n contextSharing?: never\n} & QueryClientProviderPropsBase\ntype QueryClientProviderPropsWithContextSharing = {\n context?: never\n contextSharing?: boolean\n} & QueryClientProviderPropsBase\n\nexport type QueryClientProviderProps =\n | QueryClientProviderPropsWithContext\n | QueryClientProviderPropsWithContextSharing\n\nexport const QueryClientProvider = ({\n client,\n children,\n context,\n contextSharing = false,\n}: QueryClientProviderProps): JSX.Element => {\n React.useEffect(() => {\n client.mount()\n return () => {\n client.unmount()\n }\n }, [client])\n\n if (process.env.NODE_ENV !== 'production' && contextSharing) {\n client\n .getLogger()\n .error(\n `The contextSharing option has been deprecated and will be removed in the next major version`,\n )\n }\n\n const Context = getQueryClientContext(context, contextSharing)\n\n return (\n <QueryClientSharingContext.Provider value={!context && contextSharing}>\n <Context.Provider value={client}>{children}</Context.Provider>\n </QueryClientSharingContext.Provider>\n )\n}\n"],"names":["context","contextSharing","client"],"mappings":";;;AAYO;AAGP;AAGA;AACA;AACA;AACA;AACA;AACA;;AACA;AAIE;AACE;AACD;;AACD;AACE;;AAEC;;;AAGF;;AAED;AACD;;AAEM;AAA0BA;AAAF;AAC7B;;;AAKE;AACD;;AAED;AACD;AAkBM;;;;AAILC;AAJkC;;AAOhCC;AACA;AACEA;;;;;;AAUH;;AAED;;;;AAIsB;;AAGvB;;"}
@@ -0,0 +1,33 @@
1
+ 'use client';
2
+ import * as React from 'react';
3
+
4
+ function createValue() {
5
+ let isReset = false;
6
+ return {
7
+ clearReset: () => {
8
+ isReset = false;
9
+ },
10
+ reset: () => {
11
+ isReset = true;
12
+ },
13
+ isReset: () => {
14
+ return isReset;
15
+ }
16
+ };
17
+ }
18
+
19
+ const QueryErrorResetBoundaryContext = /*#__PURE__*/React.createContext(createValue()); // HOOK
20
+
21
+ const useQueryErrorResetBoundary = () => React.useContext(QueryErrorResetBoundaryContext); // COMPONENT
22
+
23
+ const QueryErrorResetBoundary = ({
24
+ children
25
+ }) => {
26
+ const [value] = React.useState(() => createValue());
27
+ return /*#__PURE__*/React.createElement(QueryErrorResetBoundaryContext.Provider, {
28
+ value: value
29
+ }, typeof children === 'function' ? children(value) : children);
30
+ };
31
+
32
+ export { QueryErrorResetBoundary, useQueryErrorResetBoundary };
33
+ //# sourceMappingURL=QueryErrorResetBoundary.esm.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"QueryErrorResetBoundary.esm.js","sources":["../../src/QueryErrorResetBoundary.tsx"],"sourcesContent":["'use client'\nimport * as React from 'react'\n\n// CONTEXT\n\nexport interface QueryErrorResetBoundaryValue {\n clearReset: () => void\n isReset: () => boolean\n reset: () => void\n}\n\nfunction createValue(): QueryErrorResetBoundaryValue {\n let isReset = false\n return {\n clearReset: () => {\n isReset = false\n },\n reset: () => {\n isReset = true\n },\n isReset: () => {\n return isReset\n },\n }\n}\n\nconst QueryErrorResetBoundaryContext = React.createContext(createValue())\n\n// HOOK\n\nexport const useQueryErrorResetBoundary = () =>\n React.useContext(QueryErrorResetBoundaryContext)\n\n// COMPONENT\n\nexport interface QueryErrorResetBoundaryProps {\n children:\n | ((value: QueryErrorResetBoundaryValue) => React.ReactNode)\n | React.ReactNode\n}\n\nexport const QueryErrorResetBoundary = ({\n children,\n}: QueryErrorResetBoundaryProps) => {\n const [value] = React.useState(() => createValue())\n return (\n <QueryErrorResetBoundaryContext.Provider value={value}>\n {typeof children === 'function'\n ? (children as Function)(value)\n : children}\n </QueryErrorResetBoundaryContext.Provider>\n )\n}\n"],"names":["clearReset","isReset","reset","children"],"mappings":";;;AAWA;;;AAGIA;AACEC;;AAEFC;AACED;;AAEFA;AACE;AACD;;AAEJ;;AAED;;AAIO;;AAWA;AACLE;AADsC;;;AAKK;;AAM5C;;"}
@@ -0,0 +1,58 @@
1
+ 'use client';
2
+ 'use strict';
3
+
4
+ Object.defineProperty(exports, '__esModule', { value: true });
5
+
6
+ var React = require('react');
7
+
8
+ function _interopNamespace(e) {
9
+ if (e && e.__esModule) return e;
10
+ var n = Object.create(null);
11
+ if (e) {
12
+ Object.keys(e).forEach(function (k) {
13
+ if (k !== 'default') {
14
+ var d = Object.getOwnPropertyDescriptor(e, k);
15
+ Object.defineProperty(n, k, d.get ? d : {
16
+ enumerable: true,
17
+ get: function () { return e[k]; }
18
+ });
19
+ }
20
+ });
21
+ }
22
+ n["default"] = e;
23
+ return Object.freeze(n);
24
+ }
25
+
26
+ var React__namespace = /*#__PURE__*/_interopNamespace(React);
27
+
28
+ function createValue() {
29
+ let isReset = false;
30
+ return {
31
+ clearReset: () => {
32
+ isReset = false;
33
+ },
34
+ reset: () => {
35
+ isReset = true;
36
+ },
37
+ isReset: () => {
38
+ return isReset;
39
+ }
40
+ };
41
+ }
42
+
43
+ const QueryErrorResetBoundaryContext = /*#__PURE__*/React__namespace.createContext(createValue()); // HOOK
44
+
45
+ const useQueryErrorResetBoundary = () => React__namespace.useContext(QueryErrorResetBoundaryContext); // COMPONENT
46
+
47
+ const QueryErrorResetBoundary = ({
48
+ children
49
+ }) => {
50
+ const [value] = React__namespace.useState(() => createValue());
51
+ return /*#__PURE__*/React__namespace.createElement(QueryErrorResetBoundaryContext.Provider, {
52
+ value: value
53
+ }, typeof children === 'function' ? children(value) : children);
54
+ };
55
+
56
+ exports.QueryErrorResetBoundary = QueryErrorResetBoundary;
57
+ exports.useQueryErrorResetBoundary = useQueryErrorResetBoundary;
58
+ //# sourceMappingURL=QueryErrorResetBoundary.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"QueryErrorResetBoundary.js","sources":["../../src/QueryErrorResetBoundary.tsx"],"sourcesContent":["'use client'\nimport * as React from 'react'\n\n// CONTEXT\n\nexport interface QueryErrorResetBoundaryValue {\n clearReset: () => void\n isReset: () => boolean\n reset: () => void\n}\n\nfunction createValue(): QueryErrorResetBoundaryValue {\n let isReset = false\n return {\n clearReset: () => {\n isReset = false\n },\n reset: () => {\n isReset = true\n },\n isReset: () => {\n return isReset\n },\n }\n}\n\nconst QueryErrorResetBoundaryContext = React.createContext(createValue())\n\n// HOOK\n\nexport const useQueryErrorResetBoundary = () =>\n React.useContext(QueryErrorResetBoundaryContext)\n\n// COMPONENT\n\nexport interface QueryErrorResetBoundaryProps {\n children:\n | ((value: QueryErrorResetBoundaryValue) => React.ReactNode)\n | React.ReactNode\n}\n\nexport const QueryErrorResetBoundary = ({\n children,\n}: QueryErrorResetBoundaryProps) => {\n const [value] = React.useState(() => createValue())\n return (\n <QueryErrorResetBoundaryContext.Provider value={value}>\n {typeof children === 'function'\n ? (children as Function)(value)\n : children}\n </QueryErrorResetBoundaryContext.Provider>\n )\n}\n"],"names":["clearReset","isReset","reset","children"],"mappings":";;;;;;;;;;;;;;;;;;;;;;;;;;;AAWA;;;AAGIA;AACEC;;AAEFC;AACED;;AAEFA;AACE;AACD;;AAEJ;;AAED;;AAIO;;AAWA;AACLE;AADsC;;;AAKK;;AAM5C;;;"}
@@ -0,0 +1,33 @@
1
+ 'use client';
2
+ import * as React from 'react';
3
+
4
+ function createValue() {
5
+ let isReset = false;
6
+ return {
7
+ clearReset: () => {
8
+ isReset = false;
9
+ },
10
+ reset: () => {
11
+ isReset = true;
12
+ },
13
+ isReset: () => {
14
+ return isReset;
15
+ }
16
+ };
17
+ }
18
+
19
+ const QueryErrorResetBoundaryContext = /*#__PURE__*/React.createContext(createValue()); // HOOK
20
+
21
+ const useQueryErrorResetBoundary = () => React.useContext(QueryErrorResetBoundaryContext); // COMPONENT
22
+
23
+ const QueryErrorResetBoundary = ({
24
+ children
25
+ }) => {
26
+ const [value] = React.useState(() => createValue());
27
+ return /*#__PURE__*/React.createElement(QueryErrorResetBoundaryContext.Provider, {
28
+ value: value
29
+ }, typeof children === 'function' ? children(value) : children);
30
+ };
31
+
32
+ export { QueryErrorResetBoundary, useQueryErrorResetBoundary };
33
+ //# sourceMappingURL=QueryErrorResetBoundary.mjs.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"QueryErrorResetBoundary.mjs","sources":["../../src/QueryErrorResetBoundary.tsx"],"sourcesContent":["'use client'\nimport * as React from 'react'\n\n// CONTEXT\n\nexport interface QueryErrorResetBoundaryValue {\n clearReset: () => void\n isReset: () => boolean\n reset: () => void\n}\n\nfunction createValue(): QueryErrorResetBoundaryValue {\n let isReset = false\n return {\n clearReset: () => {\n isReset = false\n },\n reset: () => {\n isReset = true\n },\n isReset: () => {\n return isReset\n },\n }\n}\n\nconst QueryErrorResetBoundaryContext = React.createContext(createValue())\n\n// HOOK\n\nexport const useQueryErrorResetBoundary = () =>\n React.useContext(QueryErrorResetBoundaryContext)\n\n// COMPONENT\n\nexport interface QueryErrorResetBoundaryProps {\n children:\n | ((value: QueryErrorResetBoundaryValue) => React.ReactNode)\n | React.ReactNode\n}\n\nexport const QueryErrorResetBoundary = ({\n children,\n}: QueryErrorResetBoundaryProps) => {\n const [value] = React.useState(() => createValue())\n return (\n <QueryErrorResetBoundaryContext.Provider value={value}>\n {typeof children === 'function'\n ? (children as Function)(value)\n : children}\n </QueryErrorResetBoundaryContext.Provider>\n )\n}\n"],"names":["clearReset","isReset","reset","children"],"mappings":";;;AAWA;;;AAGIA;AACEC;;AAEFC;AACED;;AAEFA;AACE;AACD;;AAEJ;;AAED;;AAIO;;AAWA;AACLE;AADsC;;;AAKK;;AAM5C;;"}
@@ -0,0 +1,28 @@
1
+ 'use client';
2
+ import * as React from 'react';
3
+ import { shouldThrowError } from './utils.esm.js';
4
+
5
+ const ensurePreventErrorBoundaryRetry = (options, errorResetBoundary) => {
6
+ if (options.suspense || options.useErrorBoundary) {
7
+ // Prevent retrying failed query if the error boundary has not been reset yet
8
+ if (!errorResetBoundary.isReset()) {
9
+ options.retryOnMount = false;
10
+ }
11
+ }
12
+ };
13
+ const useClearResetErrorBoundary = errorResetBoundary => {
14
+ React.useEffect(() => {
15
+ errorResetBoundary.clearReset();
16
+ }, [errorResetBoundary]);
17
+ };
18
+ const getHasError = ({
19
+ result,
20
+ errorResetBoundary,
21
+ useErrorBoundary,
22
+ query
23
+ }) => {
24
+ return result.isError && !errorResetBoundary.isReset() && !result.isFetching && shouldThrowError(useErrorBoundary, [result.error, query]);
25
+ };
26
+
27
+ export { ensurePreventErrorBoundaryRetry, getHasError, useClearResetErrorBoundary };
28
+ //# sourceMappingURL=errorBoundaryUtils.esm.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"errorBoundaryUtils.esm.js","sources":["../../src/errorBoundaryUtils.ts"],"sourcesContent":["'use client'\nimport * as React from 'react'\nimport { shouldThrowError } from './utils'\nimport type {\n DefaultedQueryObserverOptions,\n Query,\n QueryKey,\n QueryObserverResult,\n UseErrorBoundary,\n} from '@tanstack/query-core'\nimport type { QueryErrorResetBoundaryValue } from './QueryErrorResetBoundary'\n\nexport const ensurePreventErrorBoundaryRetry = <\n TQueryFnData,\n TError,\n TData,\n TQueryData,\n TQueryKey extends QueryKey,\n>(\n options: DefaultedQueryObserverOptions<\n TQueryFnData,\n TError,\n TData,\n TQueryData,\n TQueryKey\n >,\n errorResetBoundary: QueryErrorResetBoundaryValue,\n) => {\n if (options.suspense || options.useErrorBoundary) {\n // Prevent retrying failed query if the error boundary has not been reset yet\n if (!errorResetBoundary.isReset()) {\n options.retryOnMount = false\n }\n }\n}\n\nexport const useClearResetErrorBoundary = (\n errorResetBoundary: QueryErrorResetBoundaryValue,\n) => {\n React.useEffect(() => {\n errorResetBoundary.clearReset()\n }, [errorResetBoundary])\n}\n\nexport const getHasError = <\n TData,\n TError,\n TQueryFnData,\n TQueryData,\n TQueryKey extends QueryKey,\n>({\n result,\n errorResetBoundary,\n useErrorBoundary,\n query,\n}: {\n result: QueryObserverResult<TData, TError>\n errorResetBoundary: QueryErrorResetBoundaryValue\n useErrorBoundary: UseErrorBoundary<\n TQueryFnData,\n TError,\n TQueryData,\n TQueryKey\n >\n query: Query<TQueryFnData, TError, TQueryData, TQueryKey>\n}) => {\n return (\n result.isError &&\n !errorResetBoundary.isReset() &&\n !result.isFetching &&\n shouldThrowError(useErrorBoundary, [result.error, query])\n )\n}\n"],"names":["useClearResetErrorBoundary","errorResetBoundary","query"],"mappings":";;;;;AA4BE;AACE;AACA;;AAEC;AACF;AACF;AAEYA;;AAITC;;AAEH;AAEM;;;;AAULC;AAJA;;AAsBD;;"}
@@ -0,0 +1,54 @@
1
+ 'use client';
2
+ 'use strict';
3
+
4
+ Object.defineProperty(exports, '__esModule', { value: true });
5
+
6
+ var React = require('react');
7
+ var utils = require('./utils.js');
8
+
9
+ function _interopNamespace(e) {
10
+ if (e && e.__esModule) return e;
11
+ var n = Object.create(null);
12
+ if (e) {
13
+ Object.keys(e).forEach(function (k) {
14
+ if (k !== 'default') {
15
+ var d = Object.getOwnPropertyDescriptor(e, k);
16
+ Object.defineProperty(n, k, d.get ? d : {
17
+ enumerable: true,
18
+ get: function () { return e[k]; }
19
+ });
20
+ }
21
+ });
22
+ }
23
+ n["default"] = e;
24
+ return Object.freeze(n);
25
+ }
26
+
27
+ var React__namespace = /*#__PURE__*/_interopNamespace(React);
28
+
29
+ const ensurePreventErrorBoundaryRetry = (options, errorResetBoundary) => {
30
+ if (options.suspense || options.useErrorBoundary) {
31
+ // Prevent retrying failed query if the error boundary has not been reset yet
32
+ if (!errorResetBoundary.isReset()) {
33
+ options.retryOnMount = false;
34
+ }
35
+ }
36
+ };
37
+ const useClearResetErrorBoundary = errorResetBoundary => {
38
+ React__namespace.useEffect(() => {
39
+ errorResetBoundary.clearReset();
40
+ }, [errorResetBoundary]);
41
+ };
42
+ const getHasError = ({
43
+ result,
44
+ errorResetBoundary,
45
+ useErrorBoundary,
46
+ query
47
+ }) => {
48
+ return result.isError && !errorResetBoundary.isReset() && !result.isFetching && utils.shouldThrowError(useErrorBoundary, [result.error, query]);
49
+ };
50
+
51
+ exports.ensurePreventErrorBoundaryRetry = ensurePreventErrorBoundaryRetry;
52
+ exports.getHasError = getHasError;
53
+ exports.useClearResetErrorBoundary = useClearResetErrorBoundary;
54
+ //# sourceMappingURL=errorBoundaryUtils.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"errorBoundaryUtils.js","sources":["../../src/errorBoundaryUtils.ts"],"sourcesContent":["'use client'\nimport * as React from 'react'\nimport { shouldThrowError } from './utils'\nimport type {\n DefaultedQueryObserverOptions,\n Query,\n QueryKey,\n QueryObserverResult,\n UseErrorBoundary,\n} from '@tanstack/query-core'\nimport type { QueryErrorResetBoundaryValue } from './QueryErrorResetBoundary'\n\nexport const ensurePreventErrorBoundaryRetry = <\n TQueryFnData,\n TError,\n TData,\n TQueryData,\n TQueryKey extends QueryKey,\n>(\n options: DefaultedQueryObserverOptions<\n TQueryFnData,\n TError,\n TData,\n TQueryData,\n TQueryKey\n >,\n errorResetBoundary: QueryErrorResetBoundaryValue,\n) => {\n if (options.suspense || options.useErrorBoundary) {\n // Prevent retrying failed query if the error boundary has not been reset yet\n if (!errorResetBoundary.isReset()) {\n options.retryOnMount = false\n }\n }\n}\n\nexport const useClearResetErrorBoundary = (\n errorResetBoundary: QueryErrorResetBoundaryValue,\n) => {\n React.useEffect(() => {\n errorResetBoundary.clearReset()\n }, [errorResetBoundary])\n}\n\nexport const getHasError = <\n TData,\n TError,\n TQueryFnData,\n TQueryData,\n TQueryKey extends QueryKey,\n>({\n result,\n errorResetBoundary,\n useErrorBoundary,\n query,\n}: {\n result: QueryObserverResult<TData, TError>\n errorResetBoundary: QueryErrorResetBoundaryValue\n useErrorBoundary: UseErrorBoundary<\n TQueryFnData,\n TError,\n TQueryData,\n TQueryKey\n >\n query: Query<TQueryFnData, TError, TQueryData, TQueryKey>\n}) => {\n return (\n result.isError &&\n !errorResetBoundary.isReset() &&\n !result.isFetching &&\n shouldThrowError(useErrorBoundary, [result.error, query])\n )\n}\n"],"names":["useClearResetErrorBoundary","errorResetBoundary","query"],"mappings":";;;;;;;;;;;;;;;;;;;;;;;;;;;;;AA4BE;AACE;AACA;;AAEC;AACF;AACF;AAEYA;;AAITC;;AAEH;AAEM;;;;AAULC;AAJA;;AAsBD;;;;"}