@tanstack/react-query-persist-client 5.107.1 → 5.107.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.
- package/build/legacy/PersistQueryClientProvider.cjs +2 -2
- package/build/legacy/PersistQueryClientProvider.cjs.map +1 -1
- package/build/legacy/PersistQueryClientProvider.d.cts.map +1 -1
- package/build/legacy/PersistQueryClientProvider.d.ts +1 -1
- package/build/legacy/PersistQueryClientProvider.d.ts.map +1 -1
- package/build/legacy/PersistQueryClientProvider.js +1 -1
- package/build/legacy/PersistQueryClientProvider.js.map +1 -1
- package/build/legacy/index.d.cts +1 -1
- package/build/legacy/index.d.ts +1 -1
- package/build/modern/PersistQueryClientProvider.cjs +2 -2
- package/build/modern/PersistQueryClientProvider.cjs.map +1 -1
- package/build/modern/PersistQueryClientProvider.d.cts.map +1 -1
- package/build/modern/PersistQueryClientProvider.d.ts +1 -1
- package/build/modern/PersistQueryClientProvider.d.ts.map +1 -1
- package/build/modern/PersistQueryClientProvider.js +1 -1
- package/build/modern/PersistQueryClientProvider.js.map +1 -1
- package/build/modern/index.d.cts +1 -1
- package/build/modern/index.d.ts +1 -1
- package/package.json +4 -4
- package/src/PersistQueryClientProvider.tsx +1 -2
- package/src/index.ts +3 -1
|
@@ -21,10 +21,10 @@ var __toESM = (mod, isNodeMode, target) => (target = mod != null ? __create(__ge
|
|
|
21
21
|
value: mod,
|
|
22
22
|
enumerable: true
|
|
23
23
|
}) : target, mod));
|
|
24
|
-
let react = require("react");
|
|
25
|
-
react = __toESM(react, 1);
|
|
26
24
|
let _tanstack_query_persist_client_core = require("@tanstack/query-persist-client-core");
|
|
27
25
|
let _tanstack_react_query = require("@tanstack/react-query");
|
|
26
|
+
let react = require("react");
|
|
27
|
+
react = __toESM(react, 1);
|
|
28
28
|
let react_jsx_runtime = require("react/jsx-runtime");
|
|
29
29
|
// src/PersistQueryClientProvider.tsx
|
|
30
30
|
/**
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"PersistQueryClientProvider.cjs","names":["React","persistQueryClientSubscribe","QueryClientProvider","IsRestoringProvider"],"sources":["../../src/PersistQueryClientProvider.tsx"],"sourcesContent":["'use client'\nimport
|
|
1
|
+
{"version":3,"file":"PersistQueryClientProvider.cjs","names":["React","persistQueryClientSubscribe","QueryClientProvider","IsRestoringProvider"],"sources":["../../src/PersistQueryClientProvider.tsx"],"sourcesContent":["'use client'\nimport {\n persistQueryClientRestore,\n persistQueryClientSubscribe,\n} from '@tanstack/query-persist-client-core'\nimport { IsRestoringProvider, QueryClientProvider } from '@tanstack/react-query'\nimport * as React from 'react'\nimport type { PersistQueryClientOptions } from '@tanstack/query-persist-client-core'\nimport type { OmitKeyof, QueryClientProviderProps } from '@tanstack/react-query'\n\n/**\n * The props of `PersistQueryClientProvider`: the props of `QueryClientProvider`, plus the\n * `persistOptions` and callbacks for when restoring succeeds or fails.\n */\nexport type PersistQueryClientProviderProps = QueryClientProviderProps & {\n persistOptions: OmitKeyof<PersistQueryClientOptions, 'queryClient'>\n onSuccess?: () => Promise<unknown> | unknown\n onError?: () => Promise<unknown> | unknown\n}\n\n/**\n * Provides the `QueryClient` like `QueryClientProvider`, and restores the persisted client first:\n * while restoring, `useIsRestoring` returns `true` and queries wait for the restore to finish\n * before subscribing. Once restored, the client is saved with the persister whenever the cache\n * changes.\n * @param props - The `QueryClientProvider` props, the `persistOptions`, and the `onSuccess` and\n * `onError` callbacks. `onSuccess` is called once restoring finishes, even if nothing was restored\n * (e.g. because the persisted client expired), and `onError` if restoring or `onSuccess` throws.\n * @returns The `QueryClientProvider` wrapping the children.\n */\nexport const PersistQueryClientProvider = ({\n children,\n persistOptions,\n onSuccess,\n onError,\n ...props\n}: PersistQueryClientProviderProps): React.JSX.Element => {\n const [isRestoring, setIsRestoring] = React.useState(true)\n const optionsRef = React.useRef({ persistOptions, onSuccess, onError })\n const didRestoreRef = React.useRef(false)\n\n React.useEffect(() => {\n optionsRef.current = { persistOptions, onSuccess, onError }\n })\n\n React.useEffect(() => {\n const options = {\n ...optionsRef.current.persistOptions,\n queryClient: props.client,\n }\n if (!didRestoreRef.current) {\n didRestoreRef.current = true\n persistQueryClientRestore(options)\n .then(() => optionsRef.current.onSuccess?.())\n .catch(() => optionsRef.current.onError?.())\n .finally(() => {\n setIsRestoring(false)\n })\n }\n return isRestoring ? undefined : persistQueryClientSubscribe(options)\n }, [props.client, isRestoring])\n\n return (\n <QueryClientProvider {...props}>\n <IsRestoringProvider value={isRestoring}>{children}</IsRestoringProvider>\n </QueryClientProvider>\n )\n}\n"],"mappings":";;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;AA8BA,MAAa,8BAA8B,EACzC,UACA,gBACA,WACA,SACA,GAAG,YACqD;CACxD,MAAM,CAAC,aAAa,kBAAkBA,MAAM,SAAS,IAAI;CACzD,MAAM,aAAaA,MAAM,OAAO;EAAE;EAAgB;EAAW;CAAQ,CAAC;CACtE,MAAM,gBAAgBA,MAAM,OAAO,KAAK;CAExC,MAAM,gBAAgB;EACpB,WAAW,UAAU;GAAE;GAAgB;GAAW;EAAQ;CAC5D,CAAC;CAED,MAAM,gBAAgB;EACpB,MAAM,UAAU;GACd,GAAG,WAAW,QAAQ;GACtB,aAAa,MAAM;EACrB;EACA,IAAI,CAAC,cAAc,SAAS;GAC1B,cAAc,UAAU;GACxB,CAAA,GAAA,oCAAA,0BAAA,CAA0B,OAAO,CAAC,CAC/B,WAAW;;IAAW,QAAA,yBAAA,sBAAA,WAAA,QAAA,CAAQ,eAAA,QAAA,0BAAA,KAAA,IAAA,KAAA,IAAA,sBAAA,KAAA,mBAAY;GAAC,CAAA,CAAC,CAC5C,YAAY;;IAAW,QAAA,0BAAA,uBAAA,WAAA,QAAA,CAAQ,aAAA,QAAA,2BAAA,KAAA,IAAA,KAAA,IAAA,uBAAA,KAAA,oBAAU;GAAC,CAAA,CAAC,CAC3C,cAAc;IACb,eAAe,KAAK;GACtB,CAAC;EACL;EACA,OAAO,cAAc,KAAA,KAAA,GAAYC,oCAAAA,4BAAAA,CAA4B,OAAO;CACtE,GAAG,CAAC,MAAM,QAAQ,WAAW,CAAC;CAE9B,OACE,iBAAA,GAAA,kBAAA,IAAA,CAACC,sBAAAA,qBAAD;EAAqB,GAAI;EACvB,UAAA,iBAAA,GAAA,kBAAA,IAAA,CAACC,sBAAAA,qBAAD;GAAqB,OAAO;GAAc;EAA8B,CAAA;CACrD,CAAA;AAEzB"}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"PersistQueryClientProvider.d.cts","names":[],"sources":["../../src/PersistQueryClientProvider.tsx"],"mappings":";;;;;;;
|
|
1
|
+
{"version":3,"file":"PersistQueryClientProvider.d.cts","names":[],"sources":["../../src/PersistQueryClientProvider.tsx"],"mappings":";;;;;;;YAcY,kCAAkC;EAC5C,gBAAgB,UAAU;EAC1B,kBAAkB;EAClB,gBAAgB;;;;;;;;;;;;qBAaL,+BAA8B,UAAA,gBAAA,WAAA,YAAA,SAMxC,oCAAkC,MAAM,IAAI"}
|
|
@@ -1,6 +1,6 @@
|
|
|
1
|
-
import * as React from "react";
|
|
2
1
|
import { PersistQueryClientOptions } from "@tanstack/query-persist-client-core";
|
|
3
2
|
import { OmitKeyof, QueryClientProviderProps } from "@tanstack/react-query";
|
|
3
|
+
import * as React from "react";
|
|
4
4
|
/**
|
|
5
5
|
* The props of `PersistQueryClientProvider`: the props of `QueryClientProvider`, plus the
|
|
6
6
|
* `persistOptions` and callbacks for when restoring succeeds or fails.
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"PersistQueryClientProvider.d.ts","names":[],"sources":["../../src/PersistQueryClientProvider.tsx"],"mappings":";;;;;;;
|
|
1
|
+
{"version":3,"file":"PersistQueryClientProvider.d.ts","names":[],"sources":["../../src/PersistQueryClientProvider.tsx"],"mappings":";;;;;;;YAcY,kCAAkC;EAC5C,gBAAgB,UAAU;EAC1B,kBAAkB;EAClB,gBAAgB;;;;;;;;;;;;qBAaL,+BAA8B,UAAA,gBAAA,WAAA,YAAA,SAMxC,oCAAkC,MAAM,IAAI"}
|
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
"use client";
|
|
2
|
-
import * as React from "react";
|
|
3
2
|
import { persistQueryClientRestore, persistQueryClientSubscribe } from "@tanstack/query-persist-client-core";
|
|
4
3
|
import { IsRestoringProvider, QueryClientProvider } from "@tanstack/react-query";
|
|
4
|
+
import * as React from "react";
|
|
5
5
|
import { jsx } from "react/jsx-runtime";
|
|
6
6
|
// src/PersistQueryClientProvider.tsx
|
|
7
7
|
/**
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"PersistQueryClientProvider.js","names":[],"sources":["../../src/PersistQueryClientProvider.tsx"],"sourcesContent":["'use client'\nimport
|
|
1
|
+
{"version":3,"file":"PersistQueryClientProvider.js","names":[],"sources":["../../src/PersistQueryClientProvider.tsx"],"sourcesContent":["'use client'\nimport {\n persistQueryClientRestore,\n persistQueryClientSubscribe,\n} from '@tanstack/query-persist-client-core'\nimport { IsRestoringProvider, QueryClientProvider } from '@tanstack/react-query'\nimport * as React from 'react'\nimport type { PersistQueryClientOptions } from '@tanstack/query-persist-client-core'\nimport type { OmitKeyof, QueryClientProviderProps } from '@tanstack/react-query'\n\n/**\n * The props of `PersistQueryClientProvider`: the props of `QueryClientProvider`, plus the\n * `persistOptions` and callbacks for when restoring succeeds or fails.\n */\nexport type PersistQueryClientProviderProps = QueryClientProviderProps & {\n persistOptions: OmitKeyof<PersistQueryClientOptions, 'queryClient'>\n onSuccess?: () => Promise<unknown> | unknown\n onError?: () => Promise<unknown> | unknown\n}\n\n/**\n * Provides the `QueryClient` like `QueryClientProvider`, and restores the persisted client first:\n * while restoring, `useIsRestoring` returns `true` and queries wait for the restore to finish\n * before subscribing. Once restored, the client is saved with the persister whenever the cache\n * changes.\n * @param props - The `QueryClientProvider` props, the `persistOptions`, and the `onSuccess` and\n * `onError` callbacks. `onSuccess` is called once restoring finishes, even if nothing was restored\n * (e.g. because the persisted client expired), and `onError` if restoring or `onSuccess` throws.\n * @returns The `QueryClientProvider` wrapping the children.\n */\nexport const PersistQueryClientProvider = ({\n children,\n persistOptions,\n onSuccess,\n onError,\n ...props\n}: PersistQueryClientProviderProps): React.JSX.Element => {\n const [isRestoring, setIsRestoring] = React.useState(true)\n const optionsRef = React.useRef({ persistOptions, onSuccess, onError })\n const didRestoreRef = React.useRef(false)\n\n React.useEffect(() => {\n optionsRef.current = { persistOptions, onSuccess, onError }\n })\n\n React.useEffect(() => {\n const options = {\n ...optionsRef.current.persistOptions,\n queryClient: props.client,\n }\n if (!didRestoreRef.current) {\n didRestoreRef.current = true\n persistQueryClientRestore(options)\n .then(() => optionsRef.current.onSuccess?.())\n .catch(() => optionsRef.current.onError?.())\n .finally(() => {\n setIsRestoring(false)\n })\n }\n return isRestoring ? undefined : persistQueryClientSubscribe(options)\n }, [props.client, isRestoring])\n\n return (\n <QueryClientProvider {...props}>\n <IsRestoringProvider value={isRestoring}>{children}</IsRestoringProvider>\n </QueryClientProvider>\n )\n}\n"],"mappings":";;;;;;;;;;;;;;;;AA8BA,MAAa,8BAA8B,EACzC,UACA,gBACA,WACA,SACA,GAAG,YACqD;CACxD,MAAM,CAAC,aAAa,kBAAkB,MAAM,SAAS,IAAI;CACzD,MAAM,aAAa,MAAM,OAAO;EAAE;EAAgB;EAAW;CAAQ,CAAC;CACtE,MAAM,gBAAgB,MAAM,OAAO,KAAK;CAExC,MAAM,gBAAgB;EACpB,WAAW,UAAU;GAAE;GAAgB;GAAW;EAAQ;CAC5D,CAAC;CAED,MAAM,gBAAgB;EACpB,MAAM,UAAU;GACd,GAAG,WAAW,QAAQ;GACtB,aAAa,MAAM;EACrB;EACA,IAAI,CAAC,cAAc,SAAS;GAC1B,cAAc,UAAU;GACxB,0BAA0B,OAAO,CAAC,CAC/B,WAAW;;IAAW,QAAA,yBAAA,sBAAA,WAAA,QAAA,CAAQ,eAAA,QAAA,0BAAA,KAAA,IAAA,KAAA,IAAA,sBAAA,KAAA,mBAAY;GAAC,CAAA,CAAC,CAC5C,YAAY;;IAAW,QAAA,0BAAA,uBAAA,WAAA,QAAA,CAAQ,aAAA,QAAA,2BAAA,KAAA,IAAA,KAAA,IAAA,uBAAA,KAAA,oBAAU;GAAC,CAAA,CAAC,CAC3C,cAAc;IACb,eAAe,KAAK;GACtB,CAAC;EACL;EACA,OAAO,cAAc,KAAA,IAAY,4BAA4B,OAAO;CACtE,GAAG,CAAC,MAAM,QAAQ,WAAW,CAAC;CAE9B,OACE,oBAAC,qBAAD;EAAqB,GAAI;EACvB,UAAA,oBAAC,qBAAD;GAAqB,OAAO;GAAc;EAA8B,CAAA;CACrD,CAAA;AAEzB"}
|
package/build/legacy/index.d.cts
CHANGED
|
@@ -1,3 +1,3 @@
|
|
|
1
1
|
import { PersistQueryClientProvider, PersistQueryClientProviderProps } from "./PersistQueryClientProvider.cjs";
|
|
2
2
|
export * from "@tanstack/query-persist-client-core";
|
|
3
|
-
export { PersistQueryClientProvider, PersistQueryClientProviderProps };
|
|
3
|
+
export { PersistQueryClientProvider, type PersistQueryClientProviderProps };
|
package/build/legacy/index.d.ts
CHANGED
|
@@ -1,3 +1,3 @@
|
|
|
1
1
|
import { PersistQueryClientProvider, PersistQueryClientProviderProps } from "./PersistQueryClientProvider.js";
|
|
2
2
|
export * from "@tanstack/query-persist-client-core";
|
|
3
|
-
export { PersistQueryClientProvider, PersistQueryClientProviderProps };
|
|
3
|
+
export { PersistQueryClientProvider, type PersistQueryClientProviderProps };
|
|
@@ -21,10 +21,10 @@ var __toESM = (mod, isNodeMode, target) => (target = mod != null ? __create(__ge
|
|
|
21
21
|
value: mod,
|
|
22
22
|
enumerable: true
|
|
23
23
|
}) : target, mod));
|
|
24
|
-
let react = require("react");
|
|
25
|
-
react = __toESM(react, 1);
|
|
26
24
|
let _tanstack_query_persist_client_core = require("@tanstack/query-persist-client-core");
|
|
27
25
|
let _tanstack_react_query = require("@tanstack/react-query");
|
|
26
|
+
let react = require("react");
|
|
27
|
+
react = __toESM(react, 1);
|
|
28
28
|
let react_jsx_runtime = require("react/jsx-runtime");
|
|
29
29
|
// src/PersistQueryClientProvider.tsx
|
|
30
30
|
/**
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"PersistQueryClientProvider.cjs","names":["React","persistQueryClientSubscribe","QueryClientProvider","IsRestoringProvider"],"sources":["../../src/PersistQueryClientProvider.tsx"],"sourcesContent":["'use client'\nimport
|
|
1
|
+
{"version":3,"file":"PersistQueryClientProvider.cjs","names":["React","persistQueryClientSubscribe","QueryClientProvider","IsRestoringProvider"],"sources":["../../src/PersistQueryClientProvider.tsx"],"sourcesContent":["'use client'\nimport {\n persistQueryClientRestore,\n persistQueryClientSubscribe,\n} from '@tanstack/query-persist-client-core'\nimport { IsRestoringProvider, QueryClientProvider } from '@tanstack/react-query'\nimport * as React from 'react'\nimport type { PersistQueryClientOptions } from '@tanstack/query-persist-client-core'\nimport type { OmitKeyof, QueryClientProviderProps } from '@tanstack/react-query'\n\n/**\n * The props of `PersistQueryClientProvider`: the props of `QueryClientProvider`, plus the\n * `persistOptions` and callbacks for when restoring succeeds or fails.\n */\nexport type PersistQueryClientProviderProps = QueryClientProviderProps & {\n persistOptions: OmitKeyof<PersistQueryClientOptions, 'queryClient'>\n onSuccess?: () => Promise<unknown> | unknown\n onError?: () => Promise<unknown> | unknown\n}\n\n/**\n * Provides the `QueryClient` like `QueryClientProvider`, and restores the persisted client first:\n * while restoring, `useIsRestoring` returns `true` and queries wait for the restore to finish\n * before subscribing. Once restored, the client is saved with the persister whenever the cache\n * changes.\n * @param props - The `QueryClientProvider` props, the `persistOptions`, and the `onSuccess` and\n * `onError` callbacks. `onSuccess` is called once restoring finishes, even if nothing was restored\n * (e.g. because the persisted client expired), and `onError` if restoring or `onSuccess` throws.\n * @returns The `QueryClientProvider` wrapping the children.\n */\nexport const PersistQueryClientProvider = ({\n children,\n persistOptions,\n onSuccess,\n onError,\n ...props\n}: PersistQueryClientProviderProps): React.JSX.Element => {\n const [isRestoring, setIsRestoring] = React.useState(true)\n const optionsRef = React.useRef({ persistOptions, onSuccess, onError })\n const didRestoreRef = React.useRef(false)\n\n React.useEffect(() => {\n optionsRef.current = { persistOptions, onSuccess, onError }\n })\n\n React.useEffect(() => {\n const options = {\n ...optionsRef.current.persistOptions,\n queryClient: props.client,\n }\n if (!didRestoreRef.current) {\n didRestoreRef.current = true\n persistQueryClientRestore(options)\n .then(() => optionsRef.current.onSuccess?.())\n .catch(() => optionsRef.current.onError?.())\n .finally(() => {\n setIsRestoring(false)\n })\n }\n return isRestoring ? undefined : persistQueryClientSubscribe(options)\n }, [props.client, isRestoring])\n\n return (\n <QueryClientProvider {...props}>\n <IsRestoringProvider value={isRestoring}>{children}</IsRestoringProvider>\n </QueryClientProvider>\n )\n}\n"],"mappings":";;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;AA8BA,MAAa,8BAA8B,EACzC,UACA,gBACA,WACA,SACA,GAAG,YACqD;CACxD,MAAM,CAAC,aAAa,kBAAkBA,MAAM,SAAS,IAAI;CACzD,MAAM,aAAaA,MAAM,OAAO;EAAE;EAAgB;EAAW;CAAQ,CAAC;CACtE,MAAM,gBAAgBA,MAAM,OAAO,KAAK;CAExC,MAAM,gBAAgB;EACpB,WAAW,UAAU;GAAE;GAAgB;GAAW;EAAQ;CAC5D,CAAC;CAED,MAAM,gBAAgB;EACpB,MAAM,UAAU;GACd,GAAG,WAAW,QAAQ;GACtB,aAAa,MAAM;EACrB;EACA,IAAI,CAAC,cAAc,SAAS;GAC1B,cAAc,UAAU;GACxB,CAAA,GAAA,oCAAA,0BAAA,CAA0B,OAAO,CAAC,CAC/B,WAAW,WAAW,QAAQ,YAAY,CAAC,CAAC,CAC5C,YAAY,WAAW,QAAQ,UAAU,CAAC,CAAC,CAC3C,cAAc;IACb,eAAe,KAAK;GACtB,CAAC;EACL;EACA,OAAO,cAAc,KAAA,KAAA,GAAYC,oCAAAA,4BAAAA,CAA4B,OAAO;CACtE,GAAG,CAAC,MAAM,QAAQ,WAAW,CAAC;CAE9B,OACE,iBAAA,GAAA,kBAAA,IAAA,CAACC,sBAAAA,qBAAD;EAAqB,GAAI;EACvB,UAAA,iBAAA,GAAA,kBAAA,IAAA,CAACC,sBAAAA,qBAAD;GAAqB,OAAO;GAAc;EAA8B,CAAA;CACrD,CAAA;AAEzB"}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"PersistQueryClientProvider.d.cts","names":[],"sources":["../../src/PersistQueryClientProvider.tsx"],"mappings":";;;;;;;
|
|
1
|
+
{"version":3,"file":"PersistQueryClientProvider.d.cts","names":[],"sources":["../../src/PersistQueryClientProvider.tsx"],"mappings":";;;;;;;YAcY,kCAAkC;EAC5C,gBAAgB,UAAU;EAC1B,kBAAkB;EAClB,gBAAgB;;;;;;;;;;;;qBAaL,+BAA8B,UAAA,gBAAA,WAAA,YAAA,SAMxC,oCAAkC,MAAM,IAAI"}
|
|
@@ -1,6 +1,6 @@
|
|
|
1
|
-
import * as React from "react";
|
|
2
1
|
import { PersistQueryClientOptions } from "@tanstack/query-persist-client-core";
|
|
3
2
|
import { OmitKeyof, QueryClientProviderProps } from "@tanstack/react-query";
|
|
3
|
+
import * as React from "react";
|
|
4
4
|
/**
|
|
5
5
|
* The props of `PersistQueryClientProvider`: the props of `QueryClientProvider`, plus the
|
|
6
6
|
* `persistOptions` and callbacks for when restoring succeeds or fails.
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"PersistQueryClientProvider.d.ts","names":[],"sources":["../../src/PersistQueryClientProvider.tsx"],"mappings":";;;;;;;
|
|
1
|
+
{"version":3,"file":"PersistQueryClientProvider.d.ts","names":[],"sources":["../../src/PersistQueryClientProvider.tsx"],"mappings":";;;;;;;YAcY,kCAAkC;EAC5C,gBAAgB,UAAU;EAC1B,kBAAkB;EAClB,gBAAgB;;;;;;;;;;;;qBAaL,+BAA8B,UAAA,gBAAA,WAAA,YAAA,SAMxC,oCAAkC,MAAM,IAAI"}
|
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
"use client";
|
|
2
|
-
import * as React from "react";
|
|
3
2
|
import { persistQueryClientRestore, persistQueryClientSubscribe } from "@tanstack/query-persist-client-core";
|
|
4
3
|
import { IsRestoringProvider, QueryClientProvider } from "@tanstack/react-query";
|
|
4
|
+
import * as React from "react";
|
|
5
5
|
import { jsx } from "react/jsx-runtime";
|
|
6
6
|
// src/PersistQueryClientProvider.tsx
|
|
7
7
|
/**
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"PersistQueryClientProvider.js","names":[],"sources":["../../src/PersistQueryClientProvider.tsx"],"sourcesContent":["'use client'\nimport
|
|
1
|
+
{"version":3,"file":"PersistQueryClientProvider.js","names":[],"sources":["../../src/PersistQueryClientProvider.tsx"],"sourcesContent":["'use client'\nimport {\n persistQueryClientRestore,\n persistQueryClientSubscribe,\n} from '@tanstack/query-persist-client-core'\nimport { IsRestoringProvider, QueryClientProvider } from '@tanstack/react-query'\nimport * as React from 'react'\nimport type { PersistQueryClientOptions } from '@tanstack/query-persist-client-core'\nimport type { OmitKeyof, QueryClientProviderProps } from '@tanstack/react-query'\n\n/**\n * The props of `PersistQueryClientProvider`: the props of `QueryClientProvider`, plus the\n * `persistOptions` and callbacks for when restoring succeeds or fails.\n */\nexport type PersistQueryClientProviderProps = QueryClientProviderProps & {\n persistOptions: OmitKeyof<PersistQueryClientOptions, 'queryClient'>\n onSuccess?: () => Promise<unknown> | unknown\n onError?: () => Promise<unknown> | unknown\n}\n\n/**\n * Provides the `QueryClient` like `QueryClientProvider`, and restores the persisted client first:\n * while restoring, `useIsRestoring` returns `true` and queries wait for the restore to finish\n * before subscribing. Once restored, the client is saved with the persister whenever the cache\n * changes.\n * @param props - The `QueryClientProvider` props, the `persistOptions`, and the `onSuccess` and\n * `onError` callbacks. `onSuccess` is called once restoring finishes, even if nothing was restored\n * (e.g. because the persisted client expired), and `onError` if restoring or `onSuccess` throws.\n * @returns The `QueryClientProvider` wrapping the children.\n */\nexport const PersistQueryClientProvider = ({\n children,\n persistOptions,\n onSuccess,\n onError,\n ...props\n}: PersistQueryClientProviderProps): React.JSX.Element => {\n const [isRestoring, setIsRestoring] = React.useState(true)\n const optionsRef = React.useRef({ persistOptions, onSuccess, onError })\n const didRestoreRef = React.useRef(false)\n\n React.useEffect(() => {\n optionsRef.current = { persistOptions, onSuccess, onError }\n })\n\n React.useEffect(() => {\n const options = {\n ...optionsRef.current.persistOptions,\n queryClient: props.client,\n }\n if (!didRestoreRef.current) {\n didRestoreRef.current = true\n persistQueryClientRestore(options)\n .then(() => optionsRef.current.onSuccess?.())\n .catch(() => optionsRef.current.onError?.())\n .finally(() => {\n setIsRestoring(false)\n })\n }\n return isRestoring ? undefined : persistQueryClientSubscribe(options)\n }, [props.client, isRestoring])\n\n return (\n <QueryClientProvider {...props}>\n <IsRestoringProvider value={isRestoring}>{children}</IsRestoringProvider>\n </QueryClientProvider>\n )\n}\n"],"mappings":";;;;;;;;;;;;;;;;AA8BA,MAAa,8BAA8B,EACzC,UACA,gBACA,WACA,SACA,GAAG,YACqD;CACxD,MAAM,CAAC,aAAa,kBAAkB,MAAM,SAAS,IAAI;CACzD,MAAM,aAAa,MAAM,OAAO;EAAE;EAAgB;EAAW;CAAQ,CAAC;CACtE,MAAM,gBAAgB,MAAM,OAAO,KAAK;CAExC,MAAM,gBAAgB;EACpB,WAAW,UAAU;GAAE;GAAgB;GAAW;EAAQ;CAC5D,CAAC;CAED,MAAM,gBAAgB;EACpB,MAAM,UAAU;GACd,GAAG,WAAW,QAAQ;GACtB,aAAa,MAAM;EACrB;EACA,IAAI,CAAC,cAAc,SAAS;GAC1B,cAAc,UAAU;GACxB,0BAA0B,OAAO,CAAC,CAC/B,WAAW,WAAW,QAAQ,YAAY,CAAC,CAAC,CAC5C,YAAY,WAAW,QAAQ,UAAU,CAAC,CAAC,CAC3C,cAAc;IACb,eAAe,KAAK;GACtB,CAAC;EACL;EACA,OAAO,cAAc,KAAA,IAAY,4BAA4B,OAAO;CACtE,GAAG,CAAC,MAAM,QAAQ,WAAW,CAAC;CAE9B,OACE,oBAAC,qBAAD;EAAqB,GAAI;EACvB,UAAA,oBAAC,qBAAD;GAAqB,OAAO;GAAc;EAA8B,CAAA;CACrD,CAAA;AAEzB"}
|
package/build/modern/index.d.cts
CHANGED
|
@@ -1,3 +1,3 @@
|
|
|
1
1
|
import { PersistQueryClientProvider, PersistQueryClientProviderProps } from "./PersistQueryClientProvider.cjs";
|
|
2
2
|
export * from "@tanstack/query-persist-client-core";
|
|
3
|
-
export { PersistQueryClientProvider, PersistQueryClientProviderProps };
|
|
3
|
+
export { PersistQueryClientProvider, type PersistQueryClientProviderProps };
|
package/build/modern/index.d.ts
CHANGED
|
@@ -1,3 +1,3 @@
|
|
|
1
1
|
import { PersistQueryClientProvider, PersistQueryClientProviderProps } from "./PersistQueryClientProvider.js";
|
|
2
2
|
export * from "@tanstack/query-persist-client-core";
|
|
3
|
-
export { PersistQueryClientProvider, PersistQueryClientProviderProps };
|
|
3
|
+
export { PersistQueryClientProvider, type PersistQueryClientProviderProps };
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@tanstack/react-query-persist-client",
|
|
3
|
-
"version": "5.107.
|
|
3
|
+
"version": "5.107.2",
|
|
4
4
|
"description": "React bindings to work with persisters in TanStack/react-query",
|
|
5
5
|
"author": "tannerlinsley",
|
|
6
6
|
"license": "MIT",
|
|
@@ -40,12 +40,12 @@
|
|
|
40
40
|
"!src/__tests__"
|
|
41
41
|
],
|
|
42
42
|
"dependencies": {
|
|
43
|
-
"@tanstack/query-persist-client-core": "5.107.
|
|
43
|
+
"@tanstack/query-persist-client-core": "5.107.2"
|
|
44
44
|
},
|
|
45
45
|
"devDependencies": {
|
|
46
46
|
"@eslint-react/eslint-plugin": "^5.28.8",
|
|
47
47
|
"@tanstack/query-test-utils": "0.0.0",
|
|
48
|
-
"@tanstack/react-query": "5.107.
|
|
48
|
+
"@tanstack/react-query": "5.107.2",
|
|
49
49
|
"@testing-library/react": "^16.1.0",
|
|
50
50
|
"@types/react": "^19.3.0",
|
|
51
51
|
"@vitejs/plugin-react": "^6.2.1",
|
|
@@ -54,7 +54,7 @@
|
|
|
54
54
|
"typescript": "6.0.3"
|
|
55
55
|
},
|
|
56
56
|
"peerDependencies": {
|
|
57
|
-
"@tanstack/react-query": "^5.107.
|
|
57
|
+
"@tanstack/react-query": "^5.107.2",
|
|
58
58
|
"@types/react": "^18 || ^19",
|
|
59
59
|
"react": "^18 || ^19"
|
|
60
60
|
},
|
|
@@ -1,11 +1,10 @@
|
|
|
1
1
|
'use client'
|
|
2
|
-
import * as React from 'react'
|
|
3
|
-
|
|
4
2
|
import {
|
|
5
3
|
persistQueryClientRestore,
|
|
6
4
|
persistQueryClientSubscribe,
|
|
7
5
|
} from '@tanstack/query-persist-client-core'
|
|
8
6
|
import { IsRestoringProvider, QueryClientProvider } from '@tanstack/react-query'
|
|
7
|
+
import * as React from 'react'
|
|
9
8
|
import type { PersistQueryClientOptions } from '@tanstack/query-persist-client-core'
|
|
10
9
|
import type { OmitKeyof, QueryClientProviderProps } from '@tanstack/react-query'
|
|
11
10
|
|
package/src/index.ts
CHANGED
|
@@ -1,4 +1,6 @@
|
|
|
1
1
|
// Re-export core
|
|
2
|
+
// oxlint-disable-next-line tanstack-query/no-restricted-syntax
|
|
2
3
|
export * from '@tanstack/query-persist-client-core'
|
|
3
4
|
|
|
4
|
-
export
|
|
5
|
+
export { PersistQueryClientProvider } from './PersistQueryClientProvider'
|
|
6
|
+
export type { PersistQueryClientProviderProps } from './PersistQueryClientProvider'
|