@tanstack/solid-query-persist-client 6.0.0-rc.5 → 6.0.0-rc.6

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/dev.cjs CHANGED
@@ -1,55 +1,64 @@
1
- 'use strict';
2
-
3
- var queryPersistClientCore = require('@tanstack/query-persist-client-core');
4
- var solidJs = require('solid-js');
5
- require('solid-js/internal');
6
- var solidQuery = require('@tanstack/solid-query');
7
-
8
- // src/index.ts
9
- exports.PersistQueryClientProvider = (props) => {
10
- const [isRestoring, setIsRestoring] = solidJs.createSignal(true);
11
- let didRestore = false;
12
- const options = solidJs.createMemo(() => ({
13
- ...props.persistOptions,
14
- queryClient: props.client
15
- }));
16
- solidJs.createEffect(() => {
17
- const opts = options();
18
- if (!didRestore) {
19
- didRestore = true;
20
- queryPersistClientCore.persistQueryClientRestore(opts).then(() => props.onSuccess?.()).catch(() => props.onError?.()).finally(() => {
21
- setIsRestoring(false);
22
- });
23
- }
24
- }, () => {
25
- });
26
- solidJs.createEffect(() => {
27
- let unsubscribe = () => {
28
- };
29
- if (!isRestoring()) {
30
- unsubscribe = queryPersistClientCore.persistQueryClientSubscribe(options());
31
- }
32
- solidJs.onCleanup(() => unsubscribe());
33
- }, () => {
34
- });
35
- return solidJs.createComponent(solidQuery.QueryClientProvider, {
36
- get client() {
37
- return props.client;
38
- },
39
- get children() {
40
- return solidJs.createComponent(solidQuery.IsRestoringContext, {
41
- value: isRestoring,
42
- get children() {
43
- return props.children;
44
- }
45
- });
46
- }
47
- });
1
+ Object.defineProperty(exports, Symbol.toStringTag, { value: "Module" });
2
+ let _tanstack_query_persist_client_core = require("@tanstack/query-persist-client-core");
3
+ let _solidjs_web = require("@solidjs/web");
4
+ let solid_js = require("solid-js");
5
+ let _tanstack_solid_query = require("@tanstack/solid-query");
6
+ // src/PersistQueryClientProvider.tsx
7
+ /**
8
+ * The props of `PersistQueryClientProvider`: the props of `QueryClientProvider`, plus the
9
+ * `persistOptions` and callbacks for when restoring succeeds or fails.
10
+ */
11
+ /**
12
+ * Provides the `QueryClient` like `QueryClientProvider`, and restores the persisted client first:
13
+ * while restoring, `useIsRestoring` returns `true` and queries wait for the restore to finish
14
+ * before subscribing. Once restored, the client is saved with the persister whenever the cache
15
+ * changes.
16
+ * @param props - The `QueryClientProvider` props, the `persistOptions`, and the `onSuccess` and
17
+ * `onError` callbacks. `onSuccess` is called once restoring finishes, even if nothing was restored
18
+ * (e.g. because the persisted client expired), and `onError` if restoring or `onSuccess` throws.
19
+ * @returns The `QueryClientProvider` wrapping the children.
20
+ */
21
+ const PersistQueryClientProvider = (props) => {
22
+ const [isRestoring, setIsRestoring] = (0, solid_js.createSignal)(true);
23
+ let didRestore = false;
24
+ const options = (0, solid_js.createMemo)(() => ({
25
+ ...props.persistOptions,
26
+ queryClient: props.client
27
+ }));
28
+ (0, solid_js.createEffect)(() => {
29
+ const opts = options();
30
+ if (!didRestore) {
31
+ didRestore = true;
32
+ (0, _tanstack_query_persist_client_core.persistQueryClientRestore)(opts).then(() => props.onSuccess?.()).catch(() => props.onError?.()).finally(() => {
33
+ setIsRestoring(false);
34
+ });
35
+ }
36
+ }, () => {});
37
+ (0, solid_js.createEffect)(() => {
38
+ let unsubscribe = () => {};
39
+ if (!isRestoring()) unsubscribe = (0, _tanstack_query_persist_client_core.persistQueryClientSubscribe)(options());
40
+ (0, solid_js.onCleanup)(() => unsubscribe());
41
+ }, () => {});
42
+ return (0, _solidjs_web.createComponent)(_tanstack_solid_query.QueryClientProvider, {
43
+ get client() {
44
+ return props.client;
45
+ },
46
+ get children() {
47
+ return (0, _solidjs_web.createComponent)(_tanstack_solid_query.IsRestoringContext, {
48
+ value: isRestoring,
49
+ get children() {
50
+ return props.children;
51
+ }
52
+ });
53
+ }
54
+ });
48
55
  };
49
-
50
- Object.keys(queryPersistClientCore).forEach(function (k) {
51
- if (k !== 'default' && !Object.prototype.hasOwnProperty.call(exports, k)) Object.defineProperty(exports, k, {
52
- enumerable: true,
53
- get: function () { return queryPersistClientCore[k]; }
54
- });
56
+ exports.PersistQueryClientProvider = PersistQueryClientProvider;
57
+ Object.keys(_tanstack_query_persist_client_core).forEach(function(k) {
58
+ if (k !== "default" && !Object.prototype.hasOwnProperty.call(exports, k)) Object.defineProperty(exports, k, {
59
+ enumerable: true,
60
+ get: function() {
61
+ return _tanstack_query_persist_client_core[k];
62
+ }
63
+ });
55
64
  });
package/build/dev.js CHANGED
@@ -1,49 +1,56 @@
1
- import { persistQueryClientRestore, persistQueryClientSubscribe } from '@tanstack/query-persist-client-core';
2
- export * from '@tanstack/query-persist-client-core';
3
- import { createSignal, createMemo, createEffect, onCleanup, createComponent } from 'solid-js';
4
- import 'solid-js/internal';
5
- import { QueryClientProvider, IsRestoringContext } from '@tanstack/solid-query';
6
-
7
- // src/index.ts
8
- var PersistQueryClientProvider = (props) => {
9
- const [isRestoring, setIsRestoring] = createSignal(true);
10
- let didRestore = false;
11
- const options = createMemo(() => ({
12
- ...props.persistOptions,
13
- queryClient: props.client
14
- }));
15
- createEffect(() => {
16
- const opts = options();
17
- if (!didRestore) {
18
- didRestore = true;
19
- persistQueryClientRestore(opts).then(() => props.onSuccess?.()).catch(() => props.onError?.()).finally(() => {
20
- setIsRestoring(false);
21
- });
22
- }
23
- }, () => {
24
- });
25
- createEffect(() => {
26
- let unsubscribe = () => {
27
- };
28
- if (!isRestoring()) {
29
- unsubscribe = persistQueryClientSubscribe(options());
30
- }
31
- onCleanup(() => unsubscribe());
32
- }, () => {
33
- });
34
- return createComponent(QueryClientProvider, {
35
- get client() {
36
- return props.client;
37
- },
38
- get children() {
39
- return createComponent(IsRestoringContext, {
40
- value: isRestoring,
41
- get children() {
42
- return props.children;
43
- }
44
- });
45
- }
46
- });
1
+ import { persistQueryClientRestore, persistQueryClientSubscribe } from "@tanstack/query-persist-client-core";
2
+ import { createComponent } from "@solidjs/web";
3
+ import { createEffect, createMemo, createSignal, onCleanup } from "solid-js";
4
+ import { IsRestoringContext, QueryClientProvider } from "@tanstack/solid-query";
5
+ export * from "@tanstack/query-persist-client-core";
6
+ // src/PersistQueryClientProvider.tsx
7
+ /**
8
+ * The props of `PersistQueryClientProvider`: the props of `QueryClientProvider`, plus the
9
+ * `persistOptions` and callbacks for when restoring succeeds or fails.
10
+ */
11
+ /**
12
+ * Provides the `QueryClient` like `QueryClientProvider`, and restores the persisted client first:
13
+ * while restoring, `useIsRestoring` returns `true` and queries wait for the restore to finish
14
+ * before subscribing. Once restored, the client is saved with the persister whenever the cache
15
+ * changes.
16
+ * @param props - The `QueryClientProvider` props, the `persistOptions`, and the `onSuccess` and
17
+ * `onError` callbacks. `onSuccess` is called once restoring finishes, even if nothing was restored
18
+ * (e.g. because the persisted client expired), and `onError` if restoring or `onSuccess` throws.
19
+ * @returns The `QueryClientProvider` wrapping the children.
20
+ */
21
+ const PersistQueryClientProvider = (props) => {
22
+ const [isRestoring, setIsRestoring] = createSignal(true);
23
+ let didRestore = false;
24
+ const options = createMemo(() => ({
25
+ ...props.persistOptions,
26
+ queryClient: props.client
27
+ }));
28
+ createEffect(() => {
29
+ const opts = options();
30
+ if (!didRestore) {
31
+ didRestore = true;
32
+ persistQueryClientRestore(opts).then(() => props.onSuccess?.()).catch(() => props.onError?.()).finally(() => {
33
+ setIsRestoring(false);
34
+ });
35
+ }
36
+ }, () => {});
37
+ createEffect(() => {
38
+ let unsubscribe = () => {};
39
+ if (!isRestoring()) unsubscribe = persistQueryClientSubscribe(options());
40
+ onCleanup(() => unsubscribe());
41
+ }, () => {});
42
+ return createComponent(QueryClientProvider, {
43
+ get client() {
44
+ return props.client;
45
+ },
46
+ get children() {
47
+ return createComponent(IsRestoringContext, {
48
+ value: isRestoring,
49
+ get children() {
50
+ return props.children;
51
+ }
52
+ });
53
+ }
54
+ });
47
55
  };
48
-
49
56
  export { PersistQueryClientProvider };
package/build/index.cjs CHANGED
@@ -1,55 +1 @@
1
- 'use strict';
2
-
3
- var queryPersistClientCore = require('@tanstack/query-persist-client-core');
4
- var solidJs = require('solid-js');
5
- require('solid-js/internal');
6
- var solidQuery = require('@tanstack/solid-query');
7
-
8
- // src/index.ts
9
- exports.PersistQueryClientProvider = (props) => {
10
- const [isRestoring, setIsRestoring] = solidJs.createSignal(true);
11
- let didRestore = false;
12
- const options = solidJs.createMemo(() => ({
13
- ...props.persistOptions,
14
- queryClient: props.client
15
- }));
16
- solidJs.createEffect(() => {
17
- const opts = options();
18
- if (!didRestore) {
19
- didRestore = true;
20
- queryPersistClientCore.persistQueryClientRestore(opts).then(() => props.onSuccess?.()).catch(() => props.onError?.()).finally(() => {
21
- setIsRestoring(false);
22
- });
23
- }
24
- }, () => {
25
- });
26
- solidJs.createEffect(() => {
27
- let unsubscribe = () => {
28
- };
29
- if (!isRestoring()) {
30
- unsubscribe = queryPersistClientCore.persistQueryClientSubscribe(options());
31
- }
32
- solidJs.onCleanup(() => unsubscribe());
33
- }, () => {
34
- });
35
- return solidJs.createComponent(solidQuery.QueryClientProvider, {
36
- get client() {
37
- return props.client;
38
- },
39
- get children() {
40
- return solidJs.createComponent(solidQuery.IsRestoringContext, {
41
- value: isRestoring,
42
- get children() {
43
- return props.children;
44
- }
45
- });
46
- }
47
- });
48
- };
49
-
50
- Object.keys(queryPersistClientCore).forEach(function (k) {
51
- if (k !== 'default' && !Object.prototype.hasOwnProperty.call(exports, k)) Object.defineProperty(exports, k, {
52
- enumerable: true,
53
- get: function () { return queryPersistClientCore[k]; }
54
- });
55
- });
1
+ Object.defineProperty(exports,Symbol.toStringTag,{value:`Module`});let e=require("@tanstack/query-persist-client-core"),t=require("@solidjs/web"),n=require("solid-js"),r=require("@tanstack/solid-query");const i=i=>{let[a,o]=(0,n.createSignal)(!0),s=!1,c=(0,n.createMemo)(()=>({...i.persistOptions,queryClient:i.client}));return(0,n.createEffect)(()=>{let t=c();s||(s=!0,(0,e.persistQueryClientRestore)(t).then(()=>i.onSuccess?.()).catch(()=>i.onError?.()).finally(()=>{o(!1)}))},()=>{}),(0,n.createEffect)(()=>{let t=()=>{};a()||(t=(0,e.persistQueryClientSubscribe)(c())),(0,n.onCleanup)(()=>t())},()=>{}),(0,t.createComponent)(r.QueryClientProvider,{get client(){return i.client},get children(){return(0,t.createComponent)(r.IsRestoringContext,{value:a,get children(){return i.children}})}})};exports.PersistQueryClientProvider=i,Object.keys(e).forEach(function(t){t!=="default"&&!Object.prototype.hasOwnProperty.call(exports,t)&&Object.defineProperty(exports,t,{enumerable:!0,get:function(){return e[t]}})});
package/build/index.d.cts CHANGED
@@ -1,21 +1,26 @@
1
- export { persistQueryClientRestore } from './_tsup-dts-rollup.cjs';
2
- export { persistQueryClientSave } from './_tsup-dts-rollup.cjs';
3
- export { persistQueryClientSubscribe } from './_tsup-dts-rollup.cjs';
4
- export { persistQueryClient } from './_tsup-dts-rollup.cjs';
5
- export { Promisable } from './_tsup-dts-rollup.cjs';
6
- export { Persister } from './_tsup-dts-rollup.cjs';
7
- export { PersistedClient } from './_tsup-dts-rollup.cjs';
8
- export { PersistQueryClientRootOptions } from './_tsup-dts-rollup.cjs';
9
- export { PersistedQueryClientRestoreOptions } from './_tsup-dts-rollup.cjs';
10
- export { PersistedQueryClientSaveOptions } from './_tsup-dts-rollup.cjs';
11
- export { PersistQueryClientOptions } from './_tsup-dts-rollup.cjs';
12
- export { PersistRetryer } from './_tsup-dts-rollup.cjs';
13
- export { removeOldestQuery } from './_tsup-dts-rollup.cjs';
14
- export { experimental_createQueryPersister } from './_tsup-dts-rollup.cjs';
15
- export { PersistedQuery } from './_tsup-dts-rollup.cjs';
16
- export { MaybePromise } from './_tsup-dts-rollup.cjs';
17
- export { AsyncStorage } from './_tsup-dts-rollup.cjs';
18
- export { StoragePersisterOptions } from './_tsup-dts-rollup.cjs';
19
- export { PERSISTER_KEY_PREFIX } from './_tsup-dts-rollup.cjs';
20
- export { PersistQueryClientProviderProps_alias_1 as PersistQueryClientProviderProps } from './_tsup-dts-rollup.cjs';
21
- export { PersistQueryClientProvider_alias_1 as PersistQueryClientProvider } from './_tsup-dts-rollup.cjs';
1
+ import { PersistQueryClientOptions } from "@tanstack/query-persist-client-core";
2
+ import { OmitKeyof, QueryClientProviderProps } from "@tanstack/solid-query";
3
+ import { JSX } from "@solidjs/web";
4
+ export * from "@tanstack/query-persist-client-core";
5
+ /**
6
+ * The props of `PersistQueryClientProvider`: the props of `QueryClientProvider`, plus the
7
+ * `persistOptions` and callbacks for when restoring succeeds or fails.
8
+ */
9
+ type PersistQueryClientProviderProps = QueryClientProviderProps & {
10
+ persistOptions: OmitKeyof<PersistQueryClientOptions, 'queryClient'>;
11
+ onSuccess?: () => void;
12
+ onError?: () => void;
13
+ };
14
+ /**
15
+ * Provides the `QueryClient` like `QueryClientProvider`, and restores the persisted client first:
16
+ * while restoring, `useIsRestoring` returns `true` and queries wait for the restore to finish
17
+ * before subscribing. Once restored, the client is saved with the persister whenever the cache
18
+ * changes.
19
+ * @param props - The `QueryClientProvider` props, the `persistOptions`, and the `onSuccess` and
20
+ * `onError` callbacks. `onSuccess` is called once restoring finishes, even if nothing was restored
21
+ * (e.g. because the persisted client expired), and `onError` if restoring or `onSuccess` throws.
22
+ * @returns The `QueryClientProvider` wrapping the children.
23
+ */
24
+ export declare const PersistQueryClientProvider: (props: PersistQueryClientProviderProps) => JSX.Element;
25
+ export type { PersistQueryClientProviderProps };
26
+ //# sourceMappingURL=index.d.cts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"index.d.cts","names":[],"sources":["../src/PersistQueryClientProvider.tsx"],"mappings":";;;;;;;;KAcY,kCAAkC;EAC5C,gBAAgB,UAAU;EAC1B;EACA;;;;;;;;;;;;qBAaW,6BACX,OAAO,oCACN,IAAI"}
package/build/index.d.ts CHANGED
@@ -1,21 +1,26 @@
1
- export { persistQueryClientRestore } from './_tsup-dts-rollup.js';
2
- export { persistQueryClientSave } from './_tsup-dts-rollup.js';
3
- export { persistQueryClientSubscribe } from './_tsup-dts-rollup.js';
4
- export { persistQueryClient } from './_tsup-dts-rollup.js';
5
- export { Promisable } from './_tsup-dts-rollup.js';
6
- export { Persister } from './_tsup-dts-rollup.js';
7
- export { PersistedClient } from './_tsup-dts-rollup.js';
8
- export { PersistQueryClientRootOptions } from './_tsup-dts-rollup.js';
9
- export { PersistedQueryClientRestoreOptions } from './_tsup-dts-rollup.js';
10
- export { PersistedQueryClientSaveOptions } from './_tsup-dts-rollup.js';
11
- export { PersistQueryClientOptions } from './_tsup-dts-rollup.js';
12
- export { PersistRetryer } from './_tsup-dts-rollup.js';
13
- export { removeOldestQuery } from './_tsup-dts-rollup.js';
14
- export { experimental_createQueryPersister } from './_tsup-dts-rollup.js';
15
- export { PersistedQuery } from './_tsup-dts-rollup.js';
16
- export { MaybePromise } from './_tsup-dts-rollup.js';
17
- export { AsyncStorage } from './_tsup-dts-rollup.js';
18
- export { StoragePersisterOptions } from './_tsup-dts-rollup.js';
19
- export { PERSISTER_KEY_PREFIX } from './_tsup-dts-rollup.js';
20
- export { PersistQueryClientProviderProps_alias_1 as PersistQueryClientProviderProps } from './_tsup-dts-rollup.js';
21
- export { PersistQueryClientProvider_alias_1 as PersistQueryClientProvider } from './_tsup-dts-rollup.js';
1
+ import { PersistQueryClientOptions } from "@tanstack/query-persist-client-core";
2
+ import { JSX } from "@solidjs/web";
3
+ import { OmitKeyof, QueryClientProviderProps } from "@tanstack/solid-query";
4
+ export * from "@tanstack/query-persist-client-core";
5
+ /**
6
+ * The props of `PersistQueryClientProvider`: the props of `QueryClientProvider`, plus the
7
+ * `persistOptions` and callbacks for when restoring succeeds or fails.
8
+ */
9
+ type PersistQueryClientProviderProps = QueryClientProviderProps & {
10
+ persistOptions: OmitKeyof<PersistQueryClientOptions, 'queryClient'>;
11
+ onSuccess?: () => void;
12
+ onError?: () => void;
13
+ };
14
+ /**
15
+ * Provides the `QueryClient` like `QueryClientProvider`, and restores the persisted client first:
16
+ * while restoring, `useIsRestoring` returns `true` and queries wait for the restore to finish
17
+ * before subscribing. Once restored, the client is saved with the persister whenever the cache
18
+ * changes.
19
+ * @param props - The `QueryClientProvider` props, the `persistOptions`, and the `onSuccess` and
20
+ * `onError` callbacks. `onSuccess` is called once restoring finishes, even if nothing was restored
21
+ * (e.g. because the persisted client expired), and `onError` if restoring or `onSuccess` throws.
22
+ * @returns The `QueryClientProvider` wrapping the children.
23
+ */
24
+ export declare const PersistQueryClientProvider: (props: PersistQueryClientProviderProps) => JSX.Element;
25
+ export type { PersistQueryClientProviderProps };
26
+ //# sourceMappingURL=index.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"index.d.ts","names":[],"sources":["../src/PersistQueryClientProvider.tsx"],"mappings":";;;;;;;;KAcY,kCAAkC;EAC5C,gBAAgB,UAAU;EAC1B;EACA;;;;;;;;;;;;qBAaW,6BACX,OAAO,oCACN,IAAI"}
package/build/index.js CHANGED
@@ -1,49 +1,2 @@
1
- import { persistQueryClientRestore, persistQueryClientSubscribe } from '@tanstack/query-persist-client-core';
2
- export * from '@tanstack/query-persist-client-core';
3
- import { createSignal, createMemo, createEffect, onCleanup, createComponent } from 'solid-js';
4
- import 'solid-js/internal';
5
- import { QueryClientProvider, IsRestoringContext } from '@tanstack/solid-query';
6
-
7
- // src/index.ts
8
- var PersistQueryClientProvider = (props) => {
9
- const [isRestoring, setIsRestoring] = createSignal(true);
10
- let didRestore = false;
11
- const options = createMemo(() => ({
12
- ...props.persistOptions,
13
- queryClient: props.client
14
- }));
15
- createEffect(() => {
16
- const opts = options();
17
- if (!didRestore) {
18
- didRestore = true;
19
- persistQueryClientRestore(opts).then(() => props.onSuccess?.()).catch(() => props.onError?.()).finally(() => {
20
- setIsRestoring(false);
21
- });
22
- }
23
- }, () => {
24
- });
25
- createEffect(() => {
26
- let unsubscribe = () => {
27
- };
28
- if (!isRestoring()) {
29
- unsubscribe = persistQueryClientSubscribe(options());
30
- }
31
- onCleanup(() => unsubscribe());
32
- }, () => {
33
- });
34
- return createComponent(QueryClientProvider, {
35
- get client() {
36
- return props.client;
37
- },
38
- get children() {
39
- return createComponent(IsRestoringContext, {
40
- value: isRestoring,
41
- get children() {
42
- return props.children;
43
- }
44
- });
45
- }
46
- });
47
- };
48
-
49
- export { PersistQueryClientProvider };
1
+ import{persistQueryClientRestore as e,persistQueryClientSubscribe as t}from"@tanstack/query-persist-client-core";import{createComponent as n}from"@solidjs/web";import{createEffect as r,createMemo as i,createSignal as a,onCleanup as o}from"solid-js";import{IsRestoringContext as s,QueryClientProvider as c}from"@tanstack/solid-query";export*from"@tanstack/query-persist-client-core";const l=l=>{let[u,d]=a(!0),f=!1,p=i(()=>({...l.persistOptions,queryClient:l.client}));return r(()=>{let t=p();f||(f=!0,e(t).then(()=>l.onSuccess?.()).catch(()=>l.onError?.()).finally(()=>{d(!1)}))},()=>{}),r(()=>{let e=()=>{};u()||(e=t(p())),o(()=>e())},()=>{}),n(c,{get client(){return l.client},get children(){return n(s,{value:u,get children(){return l.children}})}})};export{l as PersistQueryClientProvider};
2
+ //# sourceMappingURL=index.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"index.js","names":["persistQueryClientRestore","persistQueryClientSubscribe","createEffect","createMemo","createSignal","onCleanup","IsRestoringContext","QueryClientProvider","PersistQueryClientProvider","props","isRestoring","setIsRestoring","didRestore","options","persistOptions","queryClient","client","opts","then","onSuccess","catch","onError","finally","unsubscribe","_$createComponent","children","value","_$createComponent","PersistQueryClientProvider","isRestoring","setIsRestoring","createSignal","didRestore","options","createMemo","props","createEffect","opts","persistQueryClientRestore","unsubscribe","persistQueryClientSubscribe","onCleanup","createComponent","QueryClientProvider","IsRestoringContext"],"sources":["../src/PersistQueryClientProvider.tsx"],"sourcesContent":["import {\n persistQueryClientRestore,\n persistQueryClientSubscribe,\n} from '@tanstack/query-persist-client-core'\nimport { createEffect, createMemo, createSignal, onCleanup } from 'solid-js'\nimport { IsRestoringContext, QueryClientProvider } from '@tanstack/solid-query'\nimport type { PersistQueryClientOptions } from '@tanstack/query-persist-client-core'\nimport type { OmitKeyof, QueryClientProviderProps } from '@tanstack/solid-query'\nimport type { JSX } from '@solidjs/web'\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?: () => void\n onError?: () => void\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 props: PersistQueryClientProviderProps,\n): JSX.Element => {\n const [isRestoring, setIsRestoring] = createSignal(true)\n let didRestore = false\n\n const options = createMemo(() => ({\n ...props.persistOptions,\n queryClient: props.client,\n }))\n\n createEffect(\n () => {\n const opts = options()\n if (!didRestore) {\n didRestore = true\n persistQueryClientRestore(opts)\n .then(() => props.onSuccess?.())\n .catch(() => props.onError?.())\n .finally(() => {\n setIsRestoring(false)\n })\n }\n },\n () => {},\n )\n\n createEffect(\n () => {\n let unsubscribe = () => {}\n if (!isRestoring()) {\n unsubscribe = persistQueryClientSubscribe(options())\n }\n onCleanup(() => unsubscribe())\n },\n () => {},\n )\n\n return (\n <QueryClientProvider client={props.client}>\n <IsRestoringContext value={isRestoring}>\n {props.children}\n </IsRestoringContext>\n </QueryClientProvider>\n )\n}\n"],"mappings":"A,8XA8BA,MAAaQ,EACXC,GACgB,CAChB,GAAM,CAACC,EAAaC,GAAkBP,EAAa,EAAI,EACnDQ,EAAa,GAEXC,EAAUV,OAAkB,CAChC,GAAGM,EAAMK,eACTC,YAAaN,EAAMO,MACrB,EAAE,EA6BF,OA3BAd,MACQ,CACJ,IAAMe,EAAOJ,EAAQ,EAChBD,IACHA,EAAa,GACbZ,EAA0BiB,CAAI,CAAC,CAC5BC,SAAWT,EAAMU,YAAY,CAAC,CAAC,CAC/BC,UAAYX,EAAMY,UAAU,CAAC,CAAC,CAC9BC,YAAc,CACbX,EAAe,EAAK,CACtB,CAAC,EAEP,MACM,CAAC,CACT,EAEAT,MACQ,CACJ,IAAIqB,MAAoB,CAAC,EACpBb,EAAY,IACfa,EAActB,EAA4BY,EAAQ,CAAC,GAErDR,MAAgBkB,EAAY,CAAC,CAC/B,MACM,CAAC,CACT,EAEAC,EACGjB,EAAmB,CAAA,IAACS,QAAM,CAAA,OAAEP,EAAMO,MAAM,EAAA,IAAAS,UAAA,CAAA,OAAAD,EACtClB,EAAkB,CAACoB,MAAOhB,EAAW,IAAAe,UAAA,CAAA,OACnChB,EAAMgB,QAAQ,CAAA,CAAA,CAAA,CAAA,CAAA,CAIvB,E"}
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@tanstack/solid-query-persist-client",
3
- "version": "6.0.0-rc.5",
3
+ "version": "6.0.0-rc.6",
4
4
  "description": "Solid.js bindings to work with persisters in TanStack/solid-query",
5
5
  "author": "tannerlinsley",
6
6
  "license": "MIT",
@@ -46,43 +46,41 @@
46
46
  "!src/__tests__"
47
47
  ],
48
48
  "dependencies": {
49
- "@tanstack/query-persist-client-core": "5.101.4"
49
+ "@tanstack/query-persist-client-core": "5.107.1"
50
50
  },
51
51
  "devDependencies": {
52
52
  "@babel/core": "^7.28.0",
53
53
  "@babel/preset-typescript": "^7.18.6",
54
- "@solidjs/babel-plugin": "^2.0.0-rc.13",
54
+ "@solidjs/babel-plugin": "^2.0.0",
55
55
  "@solidjs/testing-library": "^0.8.10",
56
- "@solidjs/vite-plugin": "^3.0.0-next.46",
57
- "@solidjs/web": "^2.0.0-rc.13",
58
- "@vitest/coverage-istanbul": "4.0.6",
59
- "npm-run-all2": "^5.0.0",
60
- "solid-js": "^2.0.0-rc.13",
61
- "tsup-preset-solid": "^2.2.0",
62
- "vite": "^8.3.0",
63
- "vitest": "^4.0.18",
56
+ "@solidjs/vite-plugin": "^3.0.0",
57
+ "@solidjs/web": "^2.0.0",
64
58
  "@tanstack/query-test-utils": "0.0.0",
65
- "@tanstack/solid-query": "6.0.0-rc.5"
59
+ "@tanstack/solid-query": "6.0.0-rc.6",
60
+ "@types/babel__core": "^7.20.5",
61
+ "eslint-plugin-solid": "^0.18.1",
62
+ "solid-js": "^2.0.0",
63
+ "typescript": "6.0.3"
66
64
  },
67
65
  "peerDependencies": {
68
- "solid-js": ">=2.0.0-rc.13 <3.0.0",
69
- "@tanstack/solid-query": "^6.0.0-rc.5"
66
+ "@solidjs/web": "^2.0.0",
67
+ "@tanstack/solid-query": "^6.0.0-rc.6",
68
+ "solid-js": "^2.0.0"
70
69
  },
71
70
  "scripts": {
72
- "clean": "premove ./build ./coverage ./dist-ts",
73
- "compile": "tsc --build",
74
- "test:eslint": "eslint --concurrency=auto ./src",
75
- "test:types": "npm run compile && npm-run-all --serial test:types:*",
76
- "test:types:ts54": "node ../../node_modules/typescript54/lib/tsc.js --build",
77
- "test:types:ts55": "node ../../node_modules/typescript55/lib/tsc.js --build",
78
- "test:types:ts56": "node ../../node_modules/typescript56/lib/tsc.js --build",
79
- "test:types:ts57": "node ../../node_modules/typescript57/lib/tsc.js --build",
80
- "test:types:ts58": "node ../../node_modules/typescript58/lib/tsc.js --build",
81
- "test:types:ts59": "node ../../node_modules/typescript59/lib/tsc.js --build",
82
- "test:types:ts60": "node ../../node_modules/typescript60/lib/tsc.js --build",
71
+ "clean": "premove ./build ./coverage ./dist-ts ./.cache/test-types",
72
+ "compile": "tsc --project tsconfig.json",
73
+ "test:oxlint": "oxlint ./src",
74
+ "test:types": "npm-run-all --serial test:types:*",
75
+ "test:types:ts57": "node ../../node_modules/typescript57/lib/tsc.js --project tsconfig.legacy.json --outDir .cache/test-types/ts57 --tsBuildInfoFile .cache/test-types/ts57.tsbuildinfo",
76
+ "test:types:ts58": "node ../../node_modules/typescript58/lib/tsc.js --project tsconfig.legacy.json --outDir .cache/test-types/ts58 --tsBuildInfoFile .cache/test-types/ts58.tsbuildinfo",
77
+ "test:types:ts59": "node ../../node_modules/typescript59/lib/tsc.js --project tsconfig.legacy.json --outDir .cache/test-types/ts59 --tsBuildInfoFile .cache/test-types/ts59.tsbuildinfo",
78
+ "test:types:tscurrent": "tsc --project tsconfig.json --outDir .cache/test-types/tscurrent --tsBuildInfoFile .cache/test-types/tscurrent.tsbuildinfo",
79
+ "test:types:ts70": "node ../../node_modules/typescript70/lib/tsc.js --project tsconfig.legacy.json --outDir .cache/test-types/ts70 --tsBuildInfoFile .cache/test-types/ts70.tsbuildinfo",
80
+ "test:types:ts71": "node ../../node_modules/typescript71/lib/tsc.js --project tsconfig.legacy.json --outDir .cache/test-types/ts71 --tsBuildInfoFile .cache/test-types/ts71.tsbuildinfo",
83
81
  "test:lib": "vitest",
84
82
  "test:lib:dev": "pnpm run test:lib --watch",
85
83
  "test:build": "publint --strict && attw --pack",
86
- "build": "tsup --tsconfig tsconfig.prod.json"
84
+ "build": "tsdown --tsconfig tsconfig.prod.json"
87
85
  }
88
86
  }
@@ -8,12 +8,26 @@ import type { PersistQueryClientOptions } from '@tanstack/query-persist-client-c
8
8
  import type { OmitKeyof, QueryClientProviderProps } from '@tanstack/solid-query'
9
9
  import type { JSX } from '@solidjs/web'
10
10
 
11
+ /**
12
+ * The props of `PersistQueryClientProvider`: the props of `QueryClientProvider`, plus the
13
+ * `persistOptions` and callbacks for when restoring succeeds or fails.
14
+ */
11
15
  export type PersistQueryClientProviderProps = QueryClientProviderProps & {
12
16
  persistOptions: OmitKeyof<PersistQueryClientOptions, 'queryClient'>
13
17
  onSuccess?: () => void
14
18
  onError?: () => void
15
19
  }
16
20
 
21
+ /**
22
+ * Provides the `QueryClient` like `QueryClientProvider`, and restores the persisted client first:
23
+ * while restoring, `useIsRestoring` returns `true` and queries wait for the restore to finish
24
+ * before subscribing. Once restored, the client is saved with the persister whenever the cache
25
+ * changes.
26
+ * @param props - The `QueryClientProvider` props, the `persistOptions`, and the `onSuccess` and
27
+ * `onError` callbacks. `onSuccess` is called once restoring finishes, even if nothing was restored
28
+ * (e.g. because the persisted client expired), and `onError` if restoring or `onSuccess` throws.
29
+ * @returns The `QueryClientProvider` wrapping the children.
30
+ */
17
31
  export const PersistQueryClientProvider = (
18
32
  props: PersistQueryClientProviderProps,
19
33
  ): JSX.Element => {
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 * from './PersistQueryClientProvider'
5
+ export { PersistQueryClientProvider } from './PersistQueryClientProvider'
6
+ export type { PersistQueryClientProviderProps } from './PersistQueryClientProvider'
@@ -1,74 +0,0 @@
1
- import { AsyncStorage } from '@tanstack/query-persist-client-core';
2
- import { experimental_createQueryPersister } from '@tanstack/query-persist-client-core';
3
- import type { JSX } from '@solidjs/web';
4
- import { MaybePromise } from '@tanstack/query-persist-client-core';
5
- import type { OmitKeyof } from '@tanstack/solid-query';
6
- import { PersistedClient } from '@tanstack/query-persist-client-core';
7
- import { PersistedQuery } from '@tanstack/query-persist-client-core';
8
- import { PersistedQueryClientRestoreOptions } from '@tanstack/query-persist-client-core';
9
- import { PersistedQueryClientSaveOptions } from '@tanstack/query-persist-client-core';
10
- import { Persister } from '@tanstack/query-persist-client-core';
11
- import { PERSISTER_KEY_PREFIX } from '@tanstack/query-persist-client-core';
12
- import { persistQueryClient } from '@tanstack/query-persist-client-core';
13
- import { PersistQueryClientOptions } from '@tanstack/query-persist-client-core';
14
- import { persistQueryClientRestore } from '@tanstack/query-persist-client-core';
15
- import { PersistQueryClientRootOptions } from '@tanstack/query-persist-client-core';
16
- import { persistQueryClientSave } from '@tanstack/query-persist-client-core';
17
- import { persistQueryClientSubscribe } from '@tanstack/query-persist-client-core';
18
- import { PersistRetryer } from '@tanstack/query-persist-client-core';
19
- import { Promisable } from '@tanstack/query-persist-client-core';
20
- import type { QueryClientProviderProps } from '@tanstack/solid-query';
21
- import { removeOldestQuery } from '@tanstack/query-persist-client-core';
22
- import { StoragePersisterOptions } from '@tanstack/query-persist-client-core';
23
-
24
- export { AsyncStorage }
25
-
26
- export { experimental_createQueryPersister }
27
-
28
- export { MaybePromise }
29
-
30
- export { PersistedClient }
31
-
32
- export { PersistedQuery }
33
-
34
- export { PersistedQueryClientRestoreOptions }
35
-
36
- export { PersistedQueryClientSaveOptions }
37
-
38
- export { Persister }
39
-
40
- export { PERSISTER_KEY_PREFIX }
41
-
42
- export { persistQueryClient }
43
-
44
- export { PersistQueryClientOptions }
45
-
46
- declare const PersistQueryClientProvider: (props: PersistQueryClientProviderProps) => JSX.Element;
47
- export { PersistQueryClientProvider }
48
- export { PersistQueryClientProvider as PersistQueryClientProvider_alias_1 }
49
-
50
- declare type PersistQueryClientProviderProps = QueryClientProviderProps & {
51
- persistOptions: OmitKeyof<PersistQueryClientOptions, 'queryClient'>;
52
- onSuccess?: () => void;
53
- onError?: () => void;
54
- };
55
- export { PersistQueryClientProviderProps }
56
- export { PersistQueryClientProviderProps as PersistQueryClientProviderProps_alias_1 }
57
-
58
- export { persistQueryClientRestore }
59
-
60
- export { PersistQueryClientRootOptions }
61
-
62
- export { persistQueryClientSave }
63
-
64
- export { persistQueryClientSubscribe }
65
-
66
- export { PersistRetryer }
67
-
68
- export { Promisable }
69
-
70
- export { removeOldestQuery }
71
-
72
- export { StoragePersisterOptions }
73
-
74
- export { }
@@ -1,74 +0,0 @@
1
- import { AsyncStorage } from '@tanstack/query-persist-client-core';
2
- import { experimental_createQueryPersister } from '@tanstack/query-persist-client-core';
3
- import type { JSX } from '@solidjs/web';
4
- import { MaybePromise } from '@tanstack/query-persist-client-core';
5
- import type { OmitKeyof } from '@tanstack/solid-query';
6
- import { PersistedClient } from '@tanstack/query-persist-client-core';
7
- import { PersistedQuery } from '@tanstack/query-persist-client-core';
8
- import { PersistedQueryClientRestoreOptions } from '@tanstack/query-persist-client-core';
9
- import { PersistedQueryClientSaveOptions } from '@tanstack/query-persist-client-core';
10
- import { Persister } from '@tanstack/query-persist-client-core';
11
- import { PERSISTER_KEY_PREFIX } from '@tanstack/query-persist-client-core';
12
- import { persistQueryClient } from '@tanstack/query-persist-client-core';
13
- import { PersistQueryClientOptions } from '@tanstack/query-persist-client-core';
14
- import { persistQueryClientRestore } from '@tanstack/query-persist-client-core';
15
- import { PersistQueryClientRootOptions } from '@tanstack/query-persist-client-core';
16
- import { persistQueryClientSave } from '@tanstack/query-persist-client-core';
17
- import { persistQueryClientSubscribe } from '@tanstack/query-persist-client-core';
18
- import { PersistRetryer } from '@tanstack/query-persist-client-core';
19
- import { Promisable } from '@tanstack/query-persist-client-core';
20
- import type { QueryClientProviderProps } from '@tanstack/solid-query';
21
- import { removeOldestQuery } from '@tanstack/query-persist-client-core';
22
- import { StoragePersisterOptions } from '@tanstack/query-persist-client-core';
23
-
24
- export { AsyncStorage }
25
-
26
- export { experimental_createQueryPersister }
27
-
28
- export { MaybePromise }
29
-
30
- export { PersistedClient }
31
-
32
- export { PersistedQuery }
33
-
34
- export { PersistedQueryClientRestoreOptions }
35
-
36
- export { PersistedQueryClientSaveOptions }
37
-
38
- export { Persister }
39
-
40
- export { PERSISTER_KEY_PREFIX }
41
-
42
- export { persistQueryClient }
43
-
44
- export { PersistQueryClientOptions }
45
-
46
- declare const PersistQueryClientProvider: (props: PersistQueryClientProviderProps) => JSX.Element;
47
- export { PersistQueryClientProvider }
48
- export { PersistQueryClientProvider as PersistQueryClientProvider_alias_1 }
49
-
50
- declare type PersistQueryClientProviderProps = QueryClientProviderProps & {
51
- persistOptions: OmitKeyof<PersistQueryClientOptions, 'queryClient'>;
52
- onSuccess?: () => void;
53
- onError?: () => void;
54
- };
55
- export { PersistQueryClientProviderProps }
56
- export { PersistQueryClientProviderProps as PersistQueryClientProviderProps_alias_1 }
57
-
58
- export { persistQueryClientRestore }
59
-
60
- export { PersistQueryClientRootOptions }
61
-
62
- export { persistQueryClientSave }
63
-
64
- export { persistQueryClientSubscribe }
65
-
66
- export { PersistRetryer }
67
-
68
- export { Promisable }
69
-
70
- export { removeOldestQuery }
71
-
72
- export { StoragePersisterOptions }
73
-
74
- export { }
package/build/dev.d.cts DELETED
@@ -1,21 +0,0 @@
1
- export { persistQueryClientRestore } from './_tsup-dts-rollup.cjs';
2
- export { persistQueryClientSave } from './_tsup-dts-rollup.cjs';
3
- export { persistQueryClientSubscribe } from './_tsup-dts-rollup.cjs';
4
- export { persistQueryClient } from './_tsup-dts-rollup.cjs';
5
- export { Promisable } from './_tsup-dts-rollup.cjs';
6
- export { Persister } from './_tsup-dts-rollup.cjs';
7
- export { PersistedClient } from './_tsup-dts-rollup.cjs';
8
- export { PersistQueryClientRootOptions } from './_tsup-dts-rollup.cjs';
9
- export { PersistedQueryClientRestoreOptions } from './_tsup-dts-rollup.cjs';
10
- export { PersistedQueryClientSaveOptions } from './_tsup-dts-rollup.cjs';
11
- export { PersistQueryClientOptions } from './_tsup-dts-rollup.cjs';
12
- export { PersistRetryer } from './_tsup-dts-rollup.cjs';
13
- export { removeOldestQuery } from './_tsup-dts-rollup.cjs';
14
- export { experimental_createQueryPersister } from './_tsup-dts-rollup.cjs';
15
- export { PersistedQuery } from './_tsup-dts-rollup.cjs';
16
- export { MaybePromise } from './_tsup-dts-rollup.cjs';
17
- export { AsyncStorage } from './_tsup-dts-rollup.cjs';
18
- export { StoragePersisterOptions } from './_tsup-dts-rollup.cjs';
19
- export { PERSISTER_KEY_PREFIX } from './_tsup-dts-rollup.cjs';
20
- export { PersistQueryClientProviderProps_alias_1 as PersistQueryClientProviderProps } from './_tsup-dts-rollup.cjs';
21
- export { PersistQueryClientProvider_alias_1 as PersistQueryClientProvider } from './_tsup-dts-rollup.cjs';
package/build/dev.d.ts DELETED
@@ -1,21 +0,0 @@
1
- export { persistQueryClientRestore } from './_tsup-dts-rollup.js';
2
- export { persistQueryClientSave } from './_tsup-dts-rollup.js';
3
- export { persistQueryClientSubscribe } from './_tsup-dts-rollup.js';
4
- export { persistQueryClient } from './_tsup-dts-rollup.js';
5
- export { Promisable } from './_tsup-dts-rollup.js';
6
- export { Persister } from './_tsup-dts-rollup.js';
7
- export { PersistedClient } from './_tsup-dts-rollup.js';
8
- export { PersistQueryClientRootOptions } from './_tsup-dts-rollup.js';
9
- export { PersistedQueryClientRestoreOptions } from './_tsup-dts-rollup.js';
10
- export { PersistedQueryClientSaveOptions } from './_tsup-dts-rollup.js';
11
- export { PersistQueryClientOptions } from './_tsup-dts-rollup.js';
12
- export { PersistRetryer } from './_tsup-dts-rollup.js';
13
- export { removeOldestQuery } from './_tsup-dts-rollup.js';
14
- export { experimental_createQueryPersister } from './_tsup-dts-rollup.js';
15
- export { PersistedQuery } from './_tsup-dts-rollup.js';
16
- export { MaybePromise } from './_tsup-dts-rollup.js';
17
- export { AsyncStorage } from './_tsup-dts-rollup.js';
18
- export { StoragePersisterOptions } from './_tsup-dts-rollup.js';
19
- export { PERSISTER_KEY_PREFIX } from './_tsup-dts-rollup.js';
20
- export { PersistQueryClientProviderProps_alias_1 as PersistQueryClientProviderProps } from './_tsup-dts-rollup.js';
21
- export { PersistQueryClientProvider_alias_1 as PersistQueryClientProvider } from './_tsup-dts-rollup.js';