@tanstack/preact-query-persist-client 0.0.1 → 5.92.0

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
package/LICENSE ADDED
@@ -0,0 +1,21 @@
1
+ MIT License
2
+
3
+ Copyright (c) 2021-present Tanner Linsley
4
+
5
+ Permission is hereby granted, free of charge, to any person obtaining a copy
6
+ of this software and associated documentation files (the "Software"), to deal
7
+ in the Software without restriction, including without limitation the rights
8
+ to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
9
+ copies of the Software, and to permit persons to whom the Software is
10
+ furnished to do so, subject to the following conditions:
11
+
12
+ The above copyright notice and this permission notice shall be included in all
13
+ copies or substantial portions of the Software.
14
+
15
+ THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
16
+ IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
17
+ FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
18
+ AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
19
+ LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
20
+ OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
21
+ SOFTWARE.
@@ -0,0 +1,68 @@
1
+ "use strict";
2
+ var __defProp = Object.defineProperty;
3
+ var __getOwnPropDesc = Object.getOwnPropertyDescriptor;
4
+ var __getOwnPropNames = Object.getOwnPropertyNames;
5
+ var __hasOwnProp = Object.prototype.hasOwnProperty;
6
+ var __export = (target, all) => {
7
+ for (var name in all)
8
+ __defProp(target, name, { get: all[name], enumerable: true });
9
+ };
10
+ var __copyProps = (to, from, except, desc) => {
11
+ if (from && typeof from === "object" || typeof from === "function") {
12
+ for (let key of __getOwnPropNames(from))
13
+ if (!__hasOwnProp.call(to, key) && key !== except)
14
+ __defProp(to, key, { get: () => from[key], enumerable: !(desc = __getOwnPropDesc(from, key)) || desc.enumerable });
15
+ }
16
+ return to;
17
+ };
18
+ var __toCommonJS = (mod) => __copyProps(__defProp({}, "__esModule", { value: true }), mod);
19
+
20
+ // src/PersistQueryClientProvider.tsx
21
+ var PersistQueryClientProvider_exports = {};
22
+ __export(PersistQueryClientProvider_exports, {
23
+ PersistQueryClientProvider: () => PersistQueryClientProvider
24
+ });
25
+ module.exports = __toCommonJS(PersistQueryClientProvider_exports);
26
+ var import_hooks = require("preact/hooks");
27
+ var import_query_persist_client_core = require("@tanstack/query-persist-client-core");
28
+ var import_preact_query = require("@tanstack/preact-query");
29
+ var import_jsx_runtime = require("preact/jsx-runtime");
30
+ var PersistQueryClientProvider = ({
31
+ children,
32
+ persistOptions,
33
+ onSuccess,
34
+ onError,
35
+ ...props
36
+ }) => {
37
+ const [isRestoring, setIsRestoring] = (0, import_hooks.useState)(true);
38
+ const refs = (0, import_hooks.useRef)({ persistOptions, onSuccess, onError });
39
+ const didRestore = (0, import_hooks.useRef)(false);
40
+ (0, import_hooks.useEffect)(() => {
41
+ refs.current = { persistOptions, onSuccess, onError };
42
+ });
43
+ (0, import_hooks.useEffect)(() => {
44
+ const options = {
45
+ ...refs.current.persistOptions,
46
+ queryClient: props.client
47
+ };
48
+ if (!didRestore.current) {
49
+ didRestore.current = true;
50
+ (0, import_query_persist_client_core.persistQueryClientRestore)(options).then(() => {
51
+ var _a, _b;
52
+ return (_b = (_a = refs.current).onSuccess) == null ? void 0 : _b.call(_a);
53
+ }).catch(() => {
54
+ var _a, _b;
55
+ return (_b = (_a = refs.current).onError) == null ? void 0 : _b.call(_a);
56
+ }).finally(() => {
57
+ setIsRestoring(false);
58
+ });
59
+ }
60
+ return isRestoring ? void 0 : (0, import_query_persist_client_core.persistQueryClientSubscribe)(options);
61
+ }, [props.client, isRestoring]);
62
+ return /* @__PURE__ */ (0, import_jsx_runtime.jsx)(import_preact_query.QueryClientProvider, { ...props, children: /* @__PURE__ */ (0, import_jsx_runtime.jsx)(import_preact_query.IsRestoringProvider, { value: isRestoring, children }) });
63
+ };
64
+ // Annotate the CommonJS export names for ESM import in node:
65
+ 0 && (module.exports = {
66
+ PersistQueryClientProvider
67
+ });
68
+ //# sourceMappingURL=PersistQueryClientProvider.cjs.map
@@ -0,0 +1 @@
1
+ {"version":3,"sources":["../../src/PersistQueryClientProvider.tsx"],"sourcesContent":["import { useEffect, useRef, useState } from 'preact/hooks'\nimport type { VNode } from 'preact'\n\nimport {\n persistQueryClientRestore,\n persistQueryClientSubscribe,\n} from '@tanstack/query-persist-client-core'\nimport {\n IsRestoringProvider,\n QueryClientProvider,\n} from '@tanstack/preact-query'\nimport type { PersistQueryClientOptions } from '@tanstack/query-persist-client-core'\nimport type {\n OmitKeyof,\n QueryClientProviderProps,\n} from '@tanstack/preact-query'\n\nexport type PersistQueryClientProviderProps = QueryClientProviderProps & {\n persistOptions: OmitKeyof<PersistQueryClientOptions, 'queryClient'>\n onSuccess?: () => Promise<unknown> | unknown\n onError?: () => Promise<unknown> | unknown\n}\n\nexport const PersistQueryClientProvider = ({\n children,\n persistOptions,\n onSuccess,\n onError,\n ...props\n}: PersistQueryClientProviderProps): VNode => {\n const [isRestoring, setIsRestoring] = useState(true)\n const refs = useRef({ persistOptions, onSuccess, onError })\n const didRestore = useRef(false)\n\n useEffect(() => {\n refs.current = { persistOptions, onSuccess, onError }\n })\n\n useEffect(() => {\n const options = {\n ...refs.current.persistOptions,\n queryClient: props.client,\n }\n if (!didRestore.current) {\n didRestore.current = true\n persistQueryClientRestore(options)\n .then(() => refs.current.onSuccess?.())\n .catch(() => refs.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":";;;;;;;;;;;;;;;;;;;;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA,mBAA4C;AAG5C,uCAGO;AACP,0BAGO;AA+CD;AAlCC,IAAM,6BAA6B,CAAC;AAAA,EACzC;AAAA,EACA;AAAA,EACA;AAAA,EACA;AAAA,EACA,GAAG;AACL,MAA8C;AAC5C,QAAM,CAAC,aAAa,cAAc,QAAI,uBAAS,IAAI;AACnD,QAAM,WAAO,qBAAO,EAAE,gBAAgB,WAAW,QAAQ,CAAC;AAC1D,QAAM,iBAAa,qBAAO,KAAK;AAE/B,8BAAU,MAAM;AACd,SAAK,UAAU,EAAE,gBAAgB,WAAW,QAAQ;AAAA,EACtD,CAAC;AAED,8BAAU,MAAM;AACd,UAAM,UAAU;AAAA,MACd,GAAG,KAAK,QAAQ;AAAA,MAChB,aAAa,MAAM;AAAA,IACrB;AACA,QAAI,CAAC,WAAW,SAAS;AACvB,iBAAW,UAAU;AACrB,sEAA0B,OAAO,EAC9B,KAAK,MAAG;AA9CjB;AA8CoB,gCAAK,SAAQ,cAAb;AAAA,OAA0B,EACrC,MAAM,MAAG;AA/ClB;AA+CqB,gCAAK,SAAQ,YAAb;AAAA,OAAwB,EACpC,QAAQ,MAAM;AACb,uBAAe,KAAK;AAAA,MACtB,CAAC;AAAA,IACL;AACA,WAAO,cAAc,aAAY,8DAA4B,OAAO;AAAA,EACtE,GAAG,CAAC,MAAM,QAAQ,WAAW,CAAC;AAE9B,SACE,4CAAC,2CAAqB,GAAG,OACvB,sDAAC,2CAAoB,OAAO,aAAc,UAAS,GACrD;AAEJ;","names":[]}
@@ -0,0 +1,12 @@
1
+ import { PersistQueryClientOptions } from '@tanstack/query-persist-client-core';
2
+ import { VNode } from 'preact';
3
+ import { QueryClientProviderProps, OmitKeyof } from '@tanstack/preact-query';
4
+
5
+ type PersistQueryClientProviderProps = QueryClientProviderProps & {
6
+ persistOptions: OmitKeyof<PersistQueryClientOptions, 'queryClient'>;
7
+ onSuccess?: () => Promise<unknown> | unknown;
8
+ onError?: () => Promise<unknown> | unknown;
9
+ };
10
+ declare const PersistQueryClientProvider: ({ children, persistOptions, onSuccess, onError, ...props }: PersistQueryClientProviderProps) => VNode;
11
+
12
+ export { PersistQueryClientProvider, type PersistQueryClientProviderProps };
@@ -0,0 +1,12 @@
1
+ import { PersistQueryClientOptions } from '@tanstack/query-persist-client-core';
2
+ import { VNode } from 'preact';
3
+ import { QueryClientProviderProps, OmitKeyof } from '@tanstack/preact-query';
4
+
5
+ type PersistQueryClientProviderProps = QueryClientProviderProps & {
6
+ persistOptions: OmitKeyof<PersistQueryClientOptions, 'queryClient'>;
7
+ onSuccess?: () => Promise<unknown> | unknown;
8
+ onError?: () => Promise<unknown> | unknown;
9
+ };
10
+ declare const PersistQueryClientProvider: ({ children, persistOptions, onSuccess, onError, ...props }: PersistQueryClientProviderProps) => VNode;
11
+
12
+ export { PersistQueryClientProvider, type PersistQueryClientProviderProps };
@@ -0,0 +1,49 @@
1
+ // src/PersistQueryClientProvider.tsx
2
+ import { useEffect, useRef, useState } from "preact/hooks";
3
+ import {
4
+ persistQueryClientRestore,
5
+ persistQueryClientSubscribe
6
+ } from "@tanstack/query-persist-client-core";
7
+ import {
8
+ IsRestoringProvider,
9
+ QueryClientProvider
10
+ } from "@tanstack/preact-query";
11
+ import { jsx } from "preact/jsx-runtime";
12
+ var PersistQueryClientProvider = ({
13
+ children,
14
+ persistOptions,
15
+ onSuccess,
16
+ onError,
17
+ ...props
18
+ }) => {
19
+ const [isRestoring, setIsRestoring] = useState(true);
20
+ const refs = useRef({ persistOptions, onSuccess, onError });
21
+ const didRestore = useRef(false);
22
+ useEffect(() => {
23
+ refs.current = { persistOptions, onSuccess, onError };
24
+ });
25
+ useEffect(() => {
26
+ const options = {
27
+ ...refs.current.persistOptions,
28
+ queryClient: props.client
29
+ };
30
+ if (!didRestore.current) {
31
+ didRestore.current = true;
32
+ persistQueryClientRestore(options).then(() => {
33
+ var _a, _b;
34
+ return (_b = (_a = refs.current).onSuccess) == null ? void 0 : _b.call(_a);
35
+ }).catch(() => {
36
+ var _a, _b;
37
+ return (_b = (_a = refs.current).onError) == null ? void 0 : _b.call(_a);
38
+ }).finally(() => {
39
+ setIsRestoring(false);
40
+ });
41
+ }
42
+ return isRestoring ? void 0 : persistQueryClientSubscribe(options);
43
+ }, [props.client, isRestoring]);
44
+ return /* @__PURE__ */ jsx(QueryClientProvider, { ...props, children: /* @__PURE__ */ jsx(IsRestoringProvider, { value: isRestoring, children }) });
45
+ };
46
+ export {
47
+ PersistQueryClientProvider
48
+ };
49
+ //# sourceMappingURL=PersistQueryClientProvider.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"sources":["../../src/PersistQueryClientProvider.tsx"],"sourcesContent":["import { useEffect, useRef, useState } from 'preact/hooks'\nimport type { VNode } from 'preact'\n\nimport {\n persistQueryClientRestore,\n persistQueryClientSubscribe,\n} from '@tanstack/query-persist-client-core'\nimport {\n IsRestoringProvider,\n QueryClientProvider,\n} from '@tanstack/preact-query'\nimport type { PersistQueryClientOptions } from '@tanstack/query-persist-client-core'\nimport type {\n OmitKeyof,\n QueryClientProviderProps,\n} from '@tanstack/preact-query'\n\nexport type PersistQueryClientProviderProps = QueryClientProviderProps & {\n persistOptions: OmitKeyof<PersistQueryClientOptions, 'queryClient'>\n onSuccess?: () => Promise<unknown> | unknown\n onError?: () => Promise<unknown> | unknown\n}\n\nexport const PersistQueryClientProvider = ({\n children,\n persistOptions,\n onSuccess,\n onError,\n ...props\n}: PersistQueryClientProviderProps): VNode => {\n const [isRestoring, setIsRestoring] = useState(true)\n const refs = useRef({ persistOptions, onSuccess, onError })\n const didRestore = useRef(false)\n\n useEffect(() => {\n refs.current = { persistOptions, onSuccess, onError }\n })\n\n useEffect(() => {\n const options = {\n ...refs.current.persistOptions,\n queryClient: props.client,\n }\n if (!didRestore.current) {\n didRestore.current = true\n persistQueryClientRestore(options)\n .then(() => refs.current.onSuccess?.())\n .catch(() => refs.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":";AAAA,SAAS,WAAW,QAAQ,gBAAgB;AAG5C;AAAA,EACE;AAAA,EACA;AAAA,OACK;AACP;AAAA,EACE;AAAA,EACA;AAAA,OACK;AA+CD;AAlCC,IAAM,6BAA6B,CAAC;AAAA,EACzC;AAAA,EACA;AAAA,EACA;AAAA,EACA;AAAA,EACA,GAAG;AACL,MAA8C;AAC5C,QAAM,CAAC,aAAa,cAAc,IAAI,SAAS,IAAI;AACnD,QAAM,OAAO,OAAO,EAAE,gBAAgB,WAAW,QAAQ,CAAC;AAC1D,QAAM,aAAa,OAAO,KAAK;AAE/B,YAAU,MAAM;AACd,SAAK,UAAU,EAAE,gBAAgB,WAAW,QAAQ;AAAA,EACtD,CAAC;AAED,YAAU,MAAM;AACd,UAAM,UAAU;AAAA,MACd,GAAG,KAAK,QAAQ;AAAA,MAChB,aAAa,MAAM;AAAA,IACrB;AACA,QAAI,CAAC,WAAW,SAAS;AACvB,iBAAW,UAAU;AACrB,gCAA0B,OAAO,EAC9B,KAAK,MAAG;AA9CjB;AA8CoB,gCAAK,SAAQ,cAAb;AAAA,OAA0B,EACrC,MAAM,MAAG;AA/ClB;AA+CqB,gCAAK,SAAQ,YAAb;AAAA,OAAwB,EACpC,QAAQ,MAAM;AACb,uBAAe,KAAK;AAAA,MACtB,CAAC;AAAA,IACL;AACA,WAAO,cAAc,SAAY,4BAA4B,OAAO;AAAA,EACtE,GAAG,CAAC,MAAM,QAAQ,WAAW,CAAC;AAE9B,SACE,oBAAC,uBAAqB,GAAG,OACvB,8BAAC,uBAAoB,OAAO,aAAc,UAAS,GACrD;AAEJ;","names":[]}
@@ -0,0 +1,27 @@
1
+ "use strict";
2
+ var __defProp = Object.defineProperty;
3
+ var __getOwnPropDesc = Object.getOwnPropertyDescriptor;
4
+ var __getOwnPropNames = Object.getOwnPropertyNames;
5
+ var __hasOwnProp = Object.prototype.hasOwnProperty;
6
+ var __copyProps = (to, from, except, desc) => {
7
+ if (from && typeof from === "object" || typeof from === "function") {
8
+ for (let key of __getOwnPropNames(from))
9
+ if (!__hasOwnProp.call(to, key) && key !== except)
10
+ __defProp(to, key, { get: () => from[key], enumerable: !(desc = __getOwnPropDesc(from, key)) || desc.enumerable });
11
+ }
12
+ return to;
13
+ };
14
+ var __reExport = (target, mod, secondTarget) => (__copyProps(target, mod, "default"), secondTarget && __copyProps(secondTarget, mod, "default"));
15
+ var __toCommonJS = (mod) => __copyProps(__defProp({}, "__esModule", { value: true }), mod);
16
+
17
+ // src/index.ts
18
+ var index_exports = {};
19
+ module.exports = __toCommonJS(index_exports);
20
+ __reExport(index_exports, require("@tanstack/query-persist-client-core"), module.exports);
21
+ __reExport(index_exports, require("./PersistQueryClientProvider.cjs"), module.exports);
22
+ // Annotate the CommonJS export names for ESM import in node:
23
+ 0 && (module.exports = {
24
+ ...require("@tanstack/query-persist-client-core"),
25
+ ...require("./PersistQueryClientProvider.cjs")
26
+ });
27
+ //# sourceMappingURL=index.cjs.map
@@ -0,0 +1 @@
1
+ {"version":3,"sources":["../../src/index.ts"],"sourcesContent":["// Re-export core\nexport * from '@tanstack/query-persist-client-core'\n\nexport * from './PersistQueryClientProvider'\n"],"mappings":";;;;;;;;;;;;;;;;;AAAA;AAAA;AACA,0BAAc,gDADd;AAGA,0BAAc,6CAHd;","names":[]}
@@ -0,0 +1,4 @@
1
+ export * from '@tanstack/query-persist-client-core';
2
+ export { PersistQueryClientProvider, PersistQueryClientProviderProps } from './PersistQueryClientProvider.cjs';
3
+ import 'preact';
4
+ import '@tanstack/preact-query';
@@ -0,0 +1,4 @@
1
+ export * from '@tanstack/query-persist-client-core';
2
+ export { PersistQueryClientProvider, PersistQueryClientProviderProps } from './PersistQueryClientProvider.js';
3
+ import 'preact';
4
+ import '@tanstack/preact-query';
@@ -0,0 +1,4 @@
1
+ // src/index.ts
2
+ export * from "@tanstack/query-persist-client-core";
3
+ export * from "./PersistQueryClientProvider.js";
4
+ //# sourceMappingURL=index.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"sources":["../../src/index.ts"],"sourcesContent":["// Re-export core\nexport * from '@tanstack/query-persist-client-core'\n\nexport * from './PersistQueryClientProvider'\n"],"mappings":";AACA,cAAc;AAEd,cAAc;","names":[]}
@@ -0,0 +1,62 @@
1
+ "use strict";
2
+ var __defProp = Object.defineProperty;
3
+ var __getOwnPropDesc = Object.getOwnPropertyDescriptor;
4
+ var __getOwnPropNames = Object.getOwnPropertyNames;
5
+ var __hasOwnProp = Object.prototype.hasOwnProperty;
6
+ var __export = (target, all) => {
7
+ for (var name in all)
8
+ __defProp(target, name, { get: all[name], enumerable: true });
9
+ };
10
+ var __copyProps = (to, from, except, desc) => {
11
+ if (from && typeof from === "object" || typeof from === "function") {
12
+ for (let key of __getOwnPropNames(from))
13
+ if (!__hasOwnProp.call(to, key) && key !== except)
14
+ __defProp(to, key, { get: () => from[key], enumerable: !(desc = __getOwnPropDesc(from, key)) || desc.enumerable });
15
+ }
16
+ return to;
17
+ };
18
+ var __toCommonJS = (mod) => __copyProps(__defProp({}, "__esModule", { value: true }), mod);
19
+
20
+ // src/PersistQueryClientProvider.tsx
21
+ var PersistQueryClientProvider_exports = {};
22
+ __export(PersistQueryClientProvider_exports, {
23
+ PersistQueryClientProvider: () => PersistQueryClientProvider
24
+ });
25
+ module.exports = __toCommonJS(PersistQueryClientProvider_exports);
26
+ var import_hooks = require("preact/hooks");
27
+ var import_query_persist_client_core = require("@tanstack/query-persist-client-core");
28
+ var import_preact_query = require("@tanstack/preact-query");
29
+ var import_jsx_runtime = require("preact/jsx-runtime");
30
+ var PersistQueryClientProvider = ({
31
+ children,
32
+ persistOptions,
33
+ onSuccess,
34
+ onError,
35
+ ...props
36
+ }) => {
37
+ const [isRestoring, setIsRestoring] = (0, import_hooks.useState)(true);
38
+ const refs = (0, import_hooks.useRef)({ persistOptions, onSuccess, onError });
39
+ const didRestore = (0, import_hooks.useRef)(false);
40
+ (0, import_hooks.useEffect)(() => {
41
+ refs.current = { persistOptions, onSuccess, onError };
42
+ });
43
+ (0, import_hooks.useEffect)(() => {
44
+ const options = {
45
+ ...refs.current.persistOptions,
46
+ queryClient: props.client
47
+ };
48
+ if (!didRestore.current) {
49
+ didRestore.current = true;
50
+ (0, import_query_persist_client_core.persistQueryClientRestore)(options).then(() => refs.current.onSuccess?.()).catch(() => refs.current.onError?.()).finally(() => {
51
+ setIsRestoring(false);
52
+ });
53
+ }
54
+ return isRestoring ? void 0 : (0, import_query_persist_client_core.persistQueryClientSubscribe)(options);
55
+ }, [props.client, isRestoring]);
56
+ return /* @__PURE__ */ (0, import_jsx_runtime.jsx)(import_preact_query.QueryClientProvider, { ...props, children: /* @__PURE__ */ (0, import_jsx_runtime.jsx)(import_preact_query.IsRestoringProvider, { value: isRestoring, children }) });
57
+ };
58
+ // Annotate the CommonJS export names for ESM import in node:
59
+ 0 && (module.exports = {
60
+ PersistQueryClientProvider
61
+ });
62
+ //# sourceMappingURL=PersistQueryClientProvider.cjs.map
@@ -0,0 +1 @@
1
+ {"version":3,"sources":["../../src/PersistQueryClientProvider.tsx"],"sourcesContent":["import { useEffect, useRef, useState } from 'preact/hooks'\nimport type { VNode } from 'preact'\n\nimport {\n persistQueryClientRestore,\n persistQueryClientSubscribe,\n} from '@tanstack/query-persist-client-core'\nimport {\n IsRestoringProvider,\n QueryClientProvider,\n} from '@tanstack/preact-query'\nimport type { PersistQueryClientOptions } from '@tanstack/query-persist-client-core'\nimport type {\n OmitKeyof,\n QueryClientProviderProps,\n} from '@tanstack/preact-query'\n\nexport type PersistQueryClientProviderProps = QueryClientProviderProps & {\n persistOptions: OmitKeyof<PersistQueryClientOptions, 'queryClient'>\n onSuccess?: () => Promise<unknown> | unknown\n onError?: () => Promise<unknown> | unknown\n}\n\nexport const PersistQueryClientProvider = ({\n children,\n persistOptions,\n onSuccess,\n onError,\n ...props\n}: PersistQueryClientProviderProps): VNode => {\n const [isRestoring, setIsRestoring] = useState(true)\n const refs = useRef({ persistOptions, onSuccess, onError })\n const didRestore = useRef(false)\n\n useEffect(() => {\n refs.current = { persistOptions, onSuccess, onError }\n })\n\n useEffect(() => {\n const options = {\n ...refs.current.persistOptions,\n queryClient: props.client,\n }\n if (!didRestore.current) {\n didRestore.current = true\n persistQueryClientRestore(options)\n .then(() => refs.current.onSuccess?.())\n .catch(() => refs.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":";;;;;;;;;;;;;;;;;;;;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA,mBAA4C;AAG5C,uCAGO;AACP,0BAGO;AA+CD;AAlCC,IAAM,6BAA6B,CAAC;AAAA,EACzC;AAAA,EACA;AAAA,EACA;AAAA,EACA;AAAA,EACA,GAAG;AACL,MAA8C;AAC5C,QAAM,CAAC,aAAa,cAAc,QAAI,uBAAS,IAAI;AACnD,QAAM,WAAO,qBAAO,EAAE,gBAAgB,WAAW,QAAQ,CAAC;AAC1D,QAAM,iBAAa,qBAAO,KAAK;AAE/B,8BAAU,MAAM;AACd,SAAK,UAAU,EAAE,gBAAgB,WAAW,QAAQ;AAAA,EACtD,CAAC;AAED,8BAAU,MAAM;AACd,UAAM,UAAU;AAAA,MACd,GAAG,KAAK,QAAQ;AAAA,MAChB,aAAa,MAAM;AAAA,IACrB;AACA,QAAI,CAAC,WAAW,SAAS;AACvB,iBAAW,UAAU;AACrB,sEAA0B,OAAO,EAC9B,KAAK,MAAM,KAAK,QAAQ,YAAY,CAAC,EACrC,MAAM,MAAM,KAAK,QAAQ,UAAU,CAAC,EACpC,QAAQ,MAAM;AACb,uBAAe,KAAK;AAAA,MACtB,CAAC;AAAA,IACL;AACA,WAAO,cAAc,aAAY,8DAA4B,OAAO;AAAA,EACtE,GAAG,CAAC,MAAM,QAAQ,WAAW,CAAC;AAE9B,SACE,4CAAC,2CAAqB,GAAG,OACvB,sDAAC,2CAAoB,OAAO,aAAc,UAAS,GACrD;AAEJ;","names":[]}
@@ -0,0 +1,12 @@
1
+ import { PersistQueryClientOptions } from '@tanstack/query-persist-client-core';
2
+ import { VNode } from 'preact';
3
+ import { QueryClientProviderProps, OmitKeyof } from '@tanstack/preact-query';
4
+
5
+ type PersistQueryClientProviderProps = QueryClientProviderProps & {
6
+ persistOptions: OmitKeyof<PersistQueryClientOptions, 'queryClient'>;
7
+ onSuccess?: () => Promise<unknown> | unknown;
8
+ onError?: () => Promise<unknown> | unknown;
9
+ };
10
+ declare const PersistQueryClientProvider: ({ children, persistOptions, onSuccess, onError, ...props }: PersistQueryClientProviderProps) => VNode;
11
+
12
+ export { PersistQueryClientProvider, type PersistQueryClientProviderProps };
@@ -0,0 +1,12 @@
1
+ import { PersistQueryClientOptions } from '@tanstack/query-persist-client-core';
2
+ import { VNode } from 'preact';
3
+ import { QueryClientProviderProps, OmitKeyof } from '@tanstack/preact-query';
4
+
5
+ type PersistQueryClientProviderProps = QueryClientProviderProps & {
6
+ persistOptions: OmitKeyof<PersistQueryClientOptions, 'queryClient'>;
7
+ onSuccess?: () => Promise<unknown> | unknown;
8
+ onError?: () => Promise<unknown> | unknown;
9
+ };
10
+ declare const PersistQueryClientProvider: ({ children, persistOptions, onSuccess, onError, ...props }: PersistQueryClientProviderProps) => VNode;
11
+
12
+ export { PersistQueryClientProvider, type PersistQueryClientProviderProps };
@@ -0,0 +1,43 @@
1
+ // src/PersistQueryClientProvider.tsx
2
+ import { useEffect, useRef, useState } from "preact/hooks";
3
+ import {
4
+ persistQueryClientRestore,
5
+ persistQueryClientSubscribe
6
+ } from "@tanstack/query-persist-client-core";
7
+ import {
8
+ IsRestoringProvider,
9
+ QueryClientProvider
10
+ } from "@tanstack/preact-query";
11
+ import { jsx } from "preact/jsx-runtime";
12
+ var PersistQueryClientProvider = ({
13
+ children,
14
+ persistOptions,
15
+ onSuccess,
16
+ onError,
17
+ ...props
18
+ }) => {
19
+ const [isRestoring, setIsRestoring] = useState(true);
20
+ const refs = useRef({ persistOptions, onSuccess, onError });
21
+ const didRestore = useRef(false);
22
+ useEffect(() => {
23
+ refs.current = { persistOptions, onSuccess, onError };
24
+ });
25
+ useEffect(() => {
26
+ const options = {
27
+ ...refs.current.persistOptions,
28
+ queryClient: props.client
29
+ };
30
+ if (!didRestore.current) {
31
+ didRestore.current = true;
32
+ persistQueryClientRestore(options).then(() => refs.current.onSuccess?.()).catch(() => refs.current.onError?.()).finally(() => {
33
+ setIsRestoring(false);
34
+ });
35
+ }
36
+ return isRestoring ? void 0 : persistQueryClientSubscribe(options);
37
+ }, [props.client, isRestoring]);
38
+ return /* @__PURE__ */ jsx(QueryClientProvider, { ...props, children: /* @__PURE__ */ jsx(IsRestoringProvider, { value: isRestoring, children }) });
39
+ };
40
+ export {
41
+ PersistQueryClientProvider
42
+ };
43
+ //# sourceMappingURL=PersistQueryClientProvider.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"sources":["../../src/PersistQueryClientProvider.tsx"],"sourcesContent":["import { useEffect, useRef, useState } from 'preact/hooks'\nimport type { VNode } from 'preact'\n\nimport {\n persistQueryClientRestore,\n persistQueryClientSubscribe,\n} from '@tanstack/query-persist-client-core'\nimport {\n IsRestoringProvider,\n QueryClientProvider,\n} from '@tanstack/preact-query'\nimport type { PersistQueryClientOptions } from '@tanstack/query-persist-client-core'\nimport type {\n OmitKeyof,\n QueryClientProviderProps,\n} from '@tanstack/preact-query'\n\nexport type PersistQueryClientProviderProps = QueryClientProviderProps & {\n persistOptions: OmitKeyof<PersistQueryClientOptions, 'queryClient'>\n onSuccess?: () => Promise<unknown> | unknown\n onError?: () => Promise<unknown> | unknown\n}\n\nexport const PersistQueryClientProvider = ({\n children,\n persistOptions,\n onSuccess,\n onError,\n ...props\n}: PersistQueryClientProviderProps): VNode => {\n const [isRestoring, setIsRestoring] = useState(true)\n const refs = useRef({ persistOptions, onSuccess, onError })\n const didRestore = useRef(false)\n\n useEffect(() => {\n refs.current = { persistOptions, onSuccess, onError }\n })\n\n useEffect(() => {\n const options = {\n ...refs.current.persistOptions,\n queryClient: props.client,\n }\n if (!didRestore.current) {\n didRestore.current = true\n persistQueryClientRestore(options)\n .then(() => refs.current.onSuccess?.())\n .catch(() => refs.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":";AAAA,SAAS,WAAW,QAAQ,gBAAgB;AAG5C;AAAA,EACE;AAAA,EACA;AAAA,OACK;AACP;AAAA,EACE;AAAA,EACA;AAAA,OACK;AA+CD;AAlCC,IAAM,6BAA6B,CAAC;AAAA,EACzC;AAAA,EACA;AAAA,EACA;AAAA,EACA;AAAA,EACA,GAAG;AACL,MAA8C;AAC5C,QAAM,CAAC,aAAa,cAAc,IAAI,SAAS,IAAI;AACnD,QAAM,OAAO,OAAO,EAAE,gBAAgB,WAAW,QAAQ,CAAC;AAC1D,QAAM,aAAa,OAAO,KAAK;AAE/B,YAAU,MAAM;AACd,SAAK,UAAU,EAAE,gBAAgB,WAAW,QAAQ;AAAA,EACtD,CAAC;AAED,YAAU,MAAM;AACd,UAAM,UAAU;AAAA,MACd,GAAG,KAAK,QAAQ;AAAA,MAChB,aAAa,MAAM;AAAA,IACrB;AACA,QAAI,CAAC,WAAW,SAAS;AACvB,iBAAW,UAAU;AACrB,gCAA0B,OAAO,EAC9B,KAAK,MAAM,KAAK,QAAQ,YAAY,CAAC,EACrC,MAAM,MAAM,KAAK,QAAQ,UAAU,CAAC,EACpC,QAAQ,MAAM;AACb,uBAAe,KAAK;AAAA,MACtB,CAAC;AAAA,IACL;AACA,WAAO,cAAc,SAAY,4BAA4B,OAAO;AAAA,EACtE,GAAG,CAAC,MAAM,QAAQ,WAAW,CAAC;AAE9B,SACE,oBAAC,uBAAqB,GAAG,OACvB,8BAAC,uBAAoB,OAAO,aAAc,UAAS,GACrD;AAEJ;","names":[]}
@@ -0,0 +1,27 @@
1
+ "use strict";
2
+ var __defProp = Object.defineProperty;
3
+ var __getOwnPropDesc = Object.getOwnPropertyDescriptor;
4
+ var __getOwnPropNames = Object.getOwnPropertyNames;
5
+ var __hasOwnProp = Object.prototype.hasOwnProperty;
6
+ var __copyProps = (to, from, except, desc) => {
7
+ if (from && typeof from === "object" || typeof from === "function") {
8
+ for (let key of __getOwnPropNames(from))
9
+ if (!__hasOwnProp.call(to, key) && key !== except)
10
+ __defProp(to, key, { get: () => from[key], enumerable: !(desc = __getOwnPropDesc(from, key)) || desc.enumerable });
11
+ }
12
+ return to;
13
+ };
14
+ var __reExport = (target, mod, secondTarget) => (__copyProps(target, mod, "default"), secondTarget && __copyProps(secondTarget, mod, "default"));
15
+ var __toCommonJS = (mod) => __copyProps(__defProp({}, "__esModule", { value: true }), mod);
16
+
17
+ // src/index.ts
18
+ var index_exports = {};
19
+ module.exports = __toCommonJS(index_exports);
20
+ __reExport(index_exports, require("@tanstack/query-persist-client-core"), module.exports);
21
+ __reExport(index_exports, require("./PersistQueryClientProvider.cjs"), module.exports);
22
+ // Annotate the CommonJS export names for ESM import in node:
23
+ 0 && (module.exports = {
24
+ ...require("@tanstack/query-persist-client-core"),
25
+ ...require("./PersistQueryClientProvider.cjs")
26
+ });
27
+ //# sourceMappingURL=index.cjs.map
@@ -0,0 +1 @@
1
+ {"version":3,"sources":["../../src/index.ts"],"sourcesContent":["// Re-export core\nexport * from '@tanstack/query-persist-client-core'\n\nexport * from './PersistQueryClientProvider'\n"],"mappings":";;;;;;;;;;;;;;;;;AAAA;AAAA;AACA,0BAAc,gDADd;AAGA,0BAAc,6CAHd;","names":[]}
@@ -0,0 +1,4 @@
1
+ export * from '@tanstack/query-persist-client-core';
2
+ export { PersistQueryClientProvider, PersistQueryClientProviderProps } from './PersistQueryClientProvider.cjs';
3
+ import 'preact';
4
+ import '@tanstack/preact-query';
@@ -0,0 +1,4 @@
1
+ export * from '@tanstack/query-persist-client-core';
2
+ export { PersistQueryClientProvider, PersistQueryClientProviderProps } from './PersistQueryClientProvider.js';
3
+ import 'preact';
4
+ import '@tanstack/preact-query';
@@ -0,0 +1,4 @@
1
+ // src/index.ts
2
+ export * from "@tanstack/query-persist-client-core";
3
+ export * from "./PersistQueryClientProvider.js";
4
+ //# sourceMappingURL=index.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"sources":["../../src/index.ts"],"sourcesContent":["// Re-export core\nexport * from '@tanstack/query-persist-client-core'\n\nexport * from './PersistQueryClientProvider'\n"],"mappings":";AACA,cAAc;AAEd,cAAc;","names":[]}
package/package.json CHANGED
@@ -1,10 +1,77 @@
1
1
  {
2
2
  "name": "@tanstack/preact-query-persist-client",
3
- "version": "0.0.1",
4
- "description": "OIDC trusted publishing setup package for @tanstack/preact-query-persist-client",
5
- "keywords": [
6
- "oidc",
7
- "trusted-publishing",
8
- "setup"
9
- ]
10
- }
3
+ "version": "5.92.0",
4
+ "description": "Preact bindings to work with persisters in TanStack/preact-query",
5
+ "author": "tannerlinsley",
6
+ "license": "MIT",
7
+ "repository": {
8
+ "type": "git",
9
+ "url": "git+https://github.com/TanStack/query.git",
10
+ "directory": "packages/preact-query-persist-client"
11
+ },
12
+ "homepage": "https://tanstack.com/query",
13
+ "funding": {
14
+ "type": "github",
15
+ "url": "https://github.com/sponsors/tannerlinsley"
16
+ },
17
+ "type": "module",
18
+ "types": "build/legacy/index.d.ts",
19
+ "main": "build/legacy/index.cjs",
20
+ "module": "build/legacy/index.js",
21
+ "exports": {
22
+ ".": {
23
+ "@tanstack/custom-condition": "./src/index.ts",
24
+ "import": {
25
+ "types": "./build/modern/index.d.ts",
26
+ "default": "./build/modern/index.js"
27
+ },
28
+ "require": {
29
+ "types": "./build/modern/index.d.cts",
30
+ "default": "./build/modern/index.cjs"
31
+ }
32
+ },
33
+ "./package.json": "./package.json"
34
+ },
35
+ "sideEffects": false,
36
+ "files": [
37
+ "build",
38
+ "src",
39
+ "!src/__tests__"
40
+ ],
41
+ "dependencies": {
42
+ "@tanstack/query-persist-client-core": "5.92.1"
43
+ },
44
+ "devDependencies": {
45
+ "@preact/preset-vite": "^2.10.2",
46
+ "@testing-library/preact": "^3.2.4",
47
+ "eslint-config-preact": "^2.0.0",
48
+ "npm-run-all2": "^5.0.0",
49
+ "preact": "^10.28.0",
50
+ "typescript-eslint": "^8.54.0",
51
+ "@tanstack/preact-query": "5.93.0",
52
+ "@tanstack/query-test-utils": "0.0.0"
53
+ },
54
+ "peerDependencies": {
55
+ "preact": "^10.0.0",
56
+ "@tanstack/preact-query": "^5.93.0"
57
+ },
58
+ "scripts": {
59
+ "clean": "premove ./build ./coverage ./dist-ts",
60
+ "compile": "tsc --build",
61
+ "test:eslint": "eslint --concurrency=auto ./src",
62
+ "test:types": "npm-run-all --serial test:types:*",
63
+ "test:types:ts50": "node ../../node_modules/typescript50/lib/tsc.js --build tsconfig.legacy.json",
64
+ "test:types:ts51": "node ../../node_modules/typescript51/lib/tsc.js --build tsconfig.legacy.json",
65
+ "test:types:ts52": "node ../../node_modules/typescript52/lib/tsc.js --build tsconfig.legacy.json",
66
+ "test:types:ts53": "node ../../node_modules/typescript53/lib/tsc.js --build tsconfig.legacy.json",
67
+ "test:types:ts54": "node ../../node_modules/typescript54/lib/tsc.js --build tsconfig.legacy.json",
68
+ "test:types:ts55": "node ../../node_modules/typescript55/lib/tsc.js --build tsconfig.legacy.json",
69
+ "test:types:ts56": "node ../../node_modules/typescript56/lib/tsc.js --build tsconfig.legacy.json",
70
+ "test:types:ts57": "node ../../node_modules/typescript57/lib/tsc.js --build tsconfig.legacy.json",
71
+ "test:types:tscurrent": "tsc --build",
72
+ "test:lib": "vitest --retry=3",
73
+ "test:lib:dev": "pnpm run test:lib --watch",
74
+ "test:build": "publint --strict && attw --pack",
75
+ "build": "tsup --tsconfig tsconfig.prod.json"
76
+ }
77
+ }
@@ -0,0 +1,61 @@
1
+ import { useEffect, useRef, useState } from 'preact/hooks'
2
+ import type { VNode } from 'preact'
3
+
4
+ import {
5
+ persistQueryClientRestore,
6
+ persistQueryClientSubscribe,
7
+ } from '@tanstack/query-persist-client-core'
8
+ import {
9
+ IsRestoringProvider,
10
+ QueryClientProvider,
11
+ } from '@tanstack/preact-query'
12
+ import type { PersistQueryClientOptions } from '@tanstack/query-persist-client-core'
13
+ import type {
14
+ OmitKeyof,
15
+ QueryClientProviderProps,
16
+ } from '@tanstack/preact-query'
17
+
18
+ export type PersistQueryClientProviderProps = QueryClientProviderProps & {
19
+ persistOptions: OmitKeyof<PersistQueryClientOptions, 'queryClient'>
20
+ onSuccess?: () => Promise<unknown> | unknown
21
+ onError?: () => Promise<unknown> | unknown
22
+ }
23
+
24
+ export const PersistQueryClientProvider = ({
25
+ children,
26
+ persistOptions,
27
+ onSuccess,
28
+ onError,
29
+ ...props
30
+ }: PersistQueryClientProviderProps): VNode => {
31
+ const [isRestoring, setIsRestoring] = useState(true)
32
+ const refs = useRef({ persistOptions, onSuccess, onError })
33
+ const didRestore = useRef(false)
34
+
35
+ useEffect(() => {
36
+ refs.current = { persistOptions, onSuccess, onError }
37
+ })
38
+
39
+ useEffect(() => {
40
+ const options = {
41
+ ...refs.current.persistOptions,
42
+ queryClient: props.client,
43
+ }
44
+ if (!didRestore.current) {
45
+ didRestore.current = true
46
+ persistQueryClientRestore(options)
47
+ .then(() => refs.current.onSuccess?.())
48
+ .catch(() => refs.current.onError?.())
49
+ .finally(() => {
50
+ setIsRestoring(false)
51
+ })
52
+ }
53
+ return isRestoring ? undefined : persistQueryClientSubscribe(options)
54
+ }, [props.client, isRestoring])
55
+
56
+ return (
57
+ <QueryClientProvider {...props}>
58
+ <IsRestoringProvider value={isRestoring}>{children}</IsRestoringProvider>
59
+ </QueryClientProvider>
60
+ )
61
+ }
package/src/index.ts ADDED
@@ -0,0 +1,4 @@
1
+ // Re-export core
2
+ export * from '@tanstack/query-persist-client-core'
3
+
4
+ export * from './PersistQueryClientProvider'
package/README.md DELETED
@@ -1,45 +0,0 @@
1
- # @tanstack/preact-query-persist-client
2
-
3
- ## ⚠️ IMPORTANT NOTICE ⚠️
4
-
5
- **This package is created solely for the purpose of setting up OIDC (OpenID Connect) trusted publishing with npm.**
6
-
7
- This is **NOT** a functional package and contains **NO** code or functionality beyond the OIDC setup configuration.
8
-
9
- ## Purpose
10
-
11
- This package exists to:
12
- 1. Configure OIDC trusted publishing for the package name `@tanstack/preact-query-persist-client`
13
- 2. Enable secure, token-less publishing from CI/CD workflows
14
- 3. Establish provenance for packages published under this name
15
-
16
- ## What is OIDC Trusted Publishing?
17
-
18
- OIDC trusted publishing allows package maintainers to publish packages directly from their CI/CD workflows without needing to manage npm access tokens. Instead, it uses OpenID Connect to establish trust between the CI/CD provider (like GitHub Actions) and npm.
19
-
20
- ## Setup Instructions
21
-
22
- To properly configure OIDC trusted publishing for this package:
23
-
24
- 1. Go to [npmjs.com](https://www.npmjs.com/) and navigate to your package settings
25
- 2. Configure the trusted publisher (e.g., GitHub Actions)
26
- 3. Specify the repository and workflow that should be allowed to publish
27
- 4. Use the configured workflow to publish your actual package
28
-
29
- ## DO NOT USE THIS PACKAGE
30
-
31
- This package is a placeholder for OIDC configuration only. It:
32
- - Contains no executable code
33
- - Provides no functionality
34
- - Should not be installed as a dependency
35
- - Exists only for administrative purposes
36
-
37
- ## More Information
38
-
39
- For more details about npm's trusted publishing feature, see:
40
- - [npm Trusted Publishing Documentation](https://docs.npmjs.com/generating-provenance-statements)
41
- - [GitHub Actions OIDC Documentation](https://docs.github.com/en/actions/deployment/security-hardening-your-deployments/about-security-hardening-with-openid-connect)
42
-
43
- ---
44
-
45
- **Maintained for OIDC setup purposes only**