Huge News!Announcing our $40M Series B led by Abstract Ventures.Learn More
Socket
Sign inDemoInstall
Socket

@tanstack/react-query-persist-client

Package Overview
Dependencies
Maintainers
1
Versions
341
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

@tanstack/react-query-persist-client - npm Package Compare versions

Comparing version 4.0.3 to 4.0.5

6

build/cjs/react-query-persist-client/src/PersistQueryClientProvider.js

@@ -18,3 +18,3 @@ /**

var persist = require('./persist.js');
var index = require('../../react-query/build/esm/index.js');
var reactQuery = require('@tanstack/react-query');

@@ -76,5 +76,5 @@ function _interopNamespace(e) {

}, [client]);
return /*#__PURE__*/React__namespace.createElement(index.QueryClientProvider, _rollupPluginBabelHelpers["extends"]({
return /*#__PURE__*/React__namespace.createElement(reactQuery.QueryClientProvider, _rollupPluginBabelHelpers["extends"]({
client: client
}, props), /*#__PURE__*/React__namespace.createElement(index.IsRestoringProvider, {
}, props), /*#__PURE__*/React__namespace.createElement(reactQuery.IsRestoringProvider, {
value: isRestoring

@@ -81,0 +81,0 @@ }, children));

@@ -12,3 +12,3 @@ /**

import * as React from 'react';
import 'use-sync-external-store/shim';
import { QueryClientProvider, IsRestoringProvider } from '@tanstack/react-query';

@@ -25,3 +25,3 @@ /**

*/
class Subscribable$1 {
class Subscribable {
constructor() {

@@ -55,5 +55,5 @@ this.listeners = [];

// UTILS
const isServer$1 = typeof window === 'undefined';
const isServer = typeof window === 'undefined';
class FocusManager$1 extends Subscribable$1 {
class FocusManager extends Subscribable {
constructor() {

@@ -65,3 +65,3 @@ super();

// eslint-disable-next-line @typescript-eslint/no-unnecessary-condition
if (!isServer$1 && window.addEventListener) {
if (!isServer && window.addEventListener) {
const listener = () => onFocus(); // Listen to visibillitychange and focus

@@ -138,5 +138,5 @@

}
new FocusManager$1();
new FocusManager();
class OnlineManager$1 extends Subscribable$1 {
class OnlineManager extends Subscribable {
constructor() {

@@ -148,3 +148,3 @@ super();

// eslint-disable-next-line @typescript-eslint/no-unnecessary-condition
if (!isServer$1 && window.addEventListener) {
if (!isServer && window.addEventListener) {
const listener = () => onOnline(); // Listen to online

@@ -220,3 +220,3 @@

}
new OnlineManager$1();
new OnlineManager();

@@ -433,262 +433,2 @@ // TYPES

/**
* react-query
*
* Copyright (c) TanStack
*
* This source code is licensed under the MIT license found in the
* LICENSE.md file in the root directory of this source tree.
*
* @license MIT
*/
/**
* query-core
*
* Copyright (c) TanStack
*
* This source code is licensed under the MIT license found in the
* LICENSE.md file in the root directory of this source tree.
*
* @license MIT
*/
class Subscribable {
constructor() {
this.listeners = [];
this.subscribe = this.subscribe.bind(this);
}
subscribe(listener) {
this.listeners.push(listener);
this.onSubscribe();
return () => {
this.listeners = this.listeners.filter(x => x !== listener);
this.onUnsubscribe();
};
}
hasListeners() {
return this.listeners.length > 0;
}
onSubscribe() {// Do nothing
}
onUnsubscribe() {// Do nothing
}
}
// TYPES
// UTILS
const isServer = typeof window === 'undefined';
class FocusManager extends Subscribable {
constructor() {
super();
this.setup = onFocus => {
// addEventListener does not exist in React Native, but window does
// eslint-disable-next-line @typescript-eslint/no-unnecessary-condition
if (!isServer && window.addEventListener) {
const listener = () => onFocus(); // Listen to visibillitychange and focus
window.addEventListener('visibilitychange', listener, false);
window.addEventListener('focus', listener, false);
return () => {
// Be sure to unsubscribe if a new handler is set
window.removeEventListener('visibilitychange', listener);
window.removeEventListener('focus', listener);
};
}
};
}
onSubscribe() {
if (!this.cleanup) {
this.setEventListener(this.setup);
}
}
onUnsubscribe() {
if (!this.hasListeners()) {
var _this$cleanup;
(_this$cleanup = this.cleanup) == null ? void 0 : _this$cleanup.call(this);
this.cleanup = undefined;
}
}
setEventListener(setup) {
var _this$cleanup2;
this.setup = setup;
(_this$cleanup2 = this.cleanup) == null ? void 0 : _this$cleanup2.call(this);
this.cleanup = setup(focused => {
if (typeof focused === 'boolean') {
this.setFocused(focused);
} else {
this.onFocus();
}
});
}
setFocused(focused) {
this.focused = focused;
if (focused) {
this.onFocus();
}
}
onFocus() {
this.listeners.forEach(listener => {
listener();
});
}
isFocused() {
if (typeof this.focused === 'boolean') {
return this.focused;
} // document global can be unavailable in react native
if (typeof document === 'undefined') {
return true;
}
return [undefined, 'visible', 'prerender'].includes(document.visibilityState);
}
}
new FocusManager();
class OnlineManager extends Subscribable {
constructor() {
super();
this.setup = onOnline => {
// addEventListener does not exist in React Native, but window does
// eslint-disable-next-line @typescript-eslint/no-unnecessary-condition
if (!isServer && window.addEventListener) {
const listener = () => onOnline(); // Listen to online
window.addEventListener('online', listener, false);
window.addEventListener('offline', listener, false);
return () => {
// Be sure to unsubscribe if a new handler is set
window.removeEventListener('online', listener);
window.removeEventListener('offline', listener);
};
}
};
}
onSubscribe() {
if (!this.cleanup) {
this.setEventListener(this.setup);
}
}
onUnsubscribe() {
if (!this.hasListeners()) {
var _this$cleanup;
(_this$cleanup = this.cleanup) == null ? void 0 : _this$cleanup.call(this);
this.cleanup = undefined;
}
}
setEventListener(setup) {
var _this$cleanup2;
this.setup = setup;
(_this$cleanup2 = this.cleanup) == null ? void 0 : _this$cleanup2.call(this);
this.cleanup = setup(online => {
if (typeof online === 'boolean') {
this.setOnline(online);
} else {
this.onOnline();
}
});
}
setOnline(online) {
this.online = online;
if (online) {
this.onOnline();
}
}
onOnline() {
this.listeners.forEach(listener => {
listener();
});
}
isOnline() {
if (typeof this.online === 'boolean') {
return this.online;
}
if (typeof navigator === 'undefined' || typeof navigator.onLine === 'undefined') {
return true;
}
return navigator.onLine;
}
}
new OnlineManager();
const defaultContext = /*#__PURE__*/React.createContext(undefined);
const QueryClientSharingContext = /*#__PURE__*/React.createContext(false); // If we are given a context, we will use it.
// Otherwise, if contextSharing is on, we share the first and at least one
// instance of the context across the window
// to ensure that if React Query is used across
// different bundles or microfrontends they will
// all use the same **instance** of context, regardless
// of module scoping.
function getQueryClientContext(context, contextSharing) {
if (context) {
return context;
}
if (contextSharing && typeof window !== 'undefined') {
if (!window.ReactQueryClientContext) {
window.ReactQueryClientContext = defaultContext;
}
return window.ReactQueryClientContext;
}
return defaultContext;
}
const QueryClientProvider = ({
client,
children,
context,
contextSharing = false
}) => {
React.useEffect(() => {
client.mount();
return () => {
client.unmount();
};
}, [client]);
const Context = getQueryClientContext(context, contextSharing);
return /*#__PURE__*/React.createElement(QueryClientSharingContext.Provider, {
value: !context && contextSharing
}, /*#__PURE__*/React.createElement(Context.Provider, {
value: client
}, children));
};
const IsRestoringContext = /*#__PURE__*/React.createContext(false);
const IsRestoringProvider = IsRestoringContext.Provider;
const PersistQueryClientProvider = ({

@@ -695,0 +435,0 @@ client,

@@ -14,3 +14,3 @@ {

"name": "query-core/build/esm/index.js",
"uid": "f312-281"
"uid": "f3f3-279"
},

@@ -21,22 +21,18 @@ {

{
"uid": "f312-283",
"uid": "f3f3-281",
"name": "persist.ts"
},
{
"uid": "f312-289",
"uid": "f3f3-285",
"name": "PersistQueryClientProvider.tsx"
},
{
"uid": "f312-291",
"uid": "f3f3-287",
"name": "retryStrategies.ts"
},
{
"uid": "f312-293",
"uid": "f3f3-289",
"name": "index.ts"
}
]
},
{
"name": "react-query/build/esm/index.js",
"uid": "f312-287"
}

@@ -46,3 +42,3 @@ ]

{
"uid": "f312-285",
"uid": "f3f3-283",
"name": "\u0000rollupPluginBabelHelpers.js"

@@ -56,50 +52,44 @@ }

"nodeParts": {
"f312-281": {
"renderedLength": 7970,
"gzipLength": 1872,
"f3f3-279": {
"renderedLength": 7950,
"gzipLength": 1867,
"brotliLength": 0,
"mainUid": "f312-280"
"mainUid": "f3f3-278"
},
"f312-283": {
"f3f3-281": {
"renderedLength": 2704,
"gzipLength": 803,
"brotliLength": 0,
"mainUid": "f312-282"
"mainUid": "f3f3-280"
},
"f312-285": {
"f3f3-283": {
"renderedLength": 431,
"gzipLength": 240,
"brotliLength": 0,
"mainUid": "f312-284"
"mainUid": "f3f3-282"
},
"f312-287": {
"renderedLength": 6581,
"gzipLength": 1582,
"f3f3-285": {
"renderedLength": 1168,
"gzipLength": 430,
"brotliLength": 0,
"mainUid": "f312-286"
"mainUid": "f3f3-284"
},
"f312-289": {
"renderedLength": 1146,
"gzipLength": 425,
"brotliLength": 0,
"mainUid": "f312-288"
},
"f312-291": {
"f3f3-287": {
"renderedLength": 687,
"gzipLength": 306,
"brotliLength": 0,
"mainUid": "f312-290"
"mainUid": "f3f3-286"
},
"f312-293": {
"f3f3-289": {
"renderedLength": 0,
"gzipLength": 0,
"brotliLength": 0,
"mainUid": "f312-292"
"mainUid": "f3f3-288"
}
},
"nodeMetas": {
"f312-280": {
"f3f3-278": {
"id": "/packages/query-core/build/esm/index.js",
"moduleParts": {
"index.production.js": "f312-281"
"index.production.js": "f3f3-279"
},

@@ -109,14 +99,14 @@ "imported": [],

{
"uid": "f312-282"
"uid": "f3f3-280"
}
]
},
"f312-282": {
"f3f3-280": {
"id": "/packages/react-query-persist-client/src/persist.ts",
"moduleParts": {
"index.production.js": "f312-283"
"index.production.js": "f3f3-281"
},
"imported": [
{
"uid": "f312-280"
"uid": "f3f3-278"
}

@@ -126,13 +116,13 @@ ],

{
"uid": "f312-292"
"uid": "f3f3-288"
},
{
"uid": "f312-288"
"uid": "f3f3-284"
}
]
},
"f312-284": {
"f3f3-282": {
"id": "\u0000rollupPluginBabelHelpers.js",
"moduleParts": {
"index.production.js": "f312-285"
"index.production.js": "f3f3-283"
},

@@ -142,42 +132,23 @@ "imported": [],

{
"uid": "f312-288"
"uid": "f3f3-284"
}
]
},
"f312-286": {
"id": "/packages/react-query/build/esm/index.js",
"moduleParts": {
"index.production.js": "f312-287"
},
"imported": [
{
"uid": "f312-294"
},
{
"uid": "f312-295"
}
],
"importedBy": [
{
"uid": "f312-288"
}
]
},
"f312-288": {
"f3f3-284": {
"id": "/packages/react-query-persist-client/src/PersistQueryClientProvider.tsx",
"moduleParts": {
"index.production.js": "f312-289"
"index.production.js": "f3f3-285"
},
"imported": [
{
"uid": "f312-284"
"uid": "f3f3-282"
},
{
"uid": "f312-294"
"uid": "f3f3-290"
},
{
"uid": "f312-282"
"uid": "f3f3-280"
},
{
"uid": "f312-286"
"uid": "f3f3-291"
}

@@ -187,10 +158,10 @@ ],

{
"uid": "f312-292"
"uid": "f3f3-288"
}
]
},
"f312-290": {
"f3f3-286": {
"id": "/packages/react-query-persist-client/src/retryStrategies.ts",
"moduleParts": {
"index.production.js": "f312-291"
"index.production.js": "f3f3-287"
},

@@ -200,20 +171,20 @@ "imported": [],

{
"uid": "f312-292"
"uid": "f3f3-288"
}
]
},
"f312-292": {
"f3f3-288": {
"id": "/packages/react-query-persist-client/src/index.ts",
"moduleParts": {
"index.production.js": "f312-293"
"index.production.js": "f3f3-289"
},
"imported": [
{
"uid": "f312-282"
"uid": "f3f3-280"
},
{
"uid": "f312-288"
"uid": "f3f3-284"
},
{
"uid": "f312-290"
"uid": "f3f3-286"
}

@@ -224,3 +195,3 @@ ],

},
"f312-294": {
"f3f3-290": {
"id": "react",

@@ -231,6 +202,3 @@ "moduleParts": {},

{
"uid": "f312-288"
},
{
"uid": "f312-286"
"uid": "f3f3-284"
}

@@ -240,4 +208,4 @@ ],

},
"f312-295": {
"id": "use-sync-external-store/shim",
"f3f3-291": {
"id": "@tanstack/react-query",
"moduleParts": {},

@@ -247,3 +215,3 @@ "imported": [],

{
"uid": "f312-286"
"uid": "f3f3-284"
}

@@ -250,0 +218,0 @@ ],

@@ -12,6 +12,6 @@ /**

(function (global, factory) {
typeof exports === 'object' && typeof module !== 'undefined' ? factory(exports, require('react'), require('use-sync-external-store/shim')) :
typeof define === 'function' && define.amd ? define(['exports', 'react', 'use-sync-external-store/shim'], factory) :
(global = typeof globalThis !== 'undefined' ? globalThis : global || self, factory(global.ReactQueryPersistClient = {}, global.React));
})(this, (function (exports, React) { 'use strict';
typeof exports === 'object' && typeof module !== 'undefined' ? factory(exports, require('react'), require('@tanstack/react-query')) :
typeof define === 'function' && define.amd ? define(['exports', 'react', '@tanstack/react-query'], factory) :
(global = typeof globalThis !== 'undefined' ? globalThis : global || self, factory(global.ReactQueryPersistClient = {}, global.React, global.ReactQuery));
})(this, (function (exports, React, reactQuery) { 'use strict';

@@ -48,3 +48,3 @@ function _interopNamespace(e) {

*/
class Subscribable$1 {
class Subscribable {
constructor() {

@@ -78,5 +78,5 @@ this.listeners = [];

// UTILS
const isServer$1 = typeof window === 'undefined';
const isServer = typeof window === 'undefined';
class FocusManager$1 extends Subscribable$1 {
class FocusManager extends Subscribable {
constructor() {

@@ -88,3 +88,3 @@ super();

// eslint-disable-next-line @typescript-eslint/no-unnecessary-condition
if (!isServer$1 && window.addEventListener) {
if (!isServer && window.addEventListener) {
const listener = () => onFocus(); // Listen to visibillitychange and focus

@@ -161,5 +161,5 @@

}
new FocusManager$1();
new FocusManager();
class OnlineManager$1 extends Subscribable$1 {
class OnlineManager extends Subscribable {
constructor() {

@@ -171,3 +171,3 @@ super();

// eslint-disable-next-line @typescript-eslint/no-unnecessary-condition
if (!isServer$1 && window.addEventListener) {
if (!isServer && window.addEventListener) {
const listener = () => onOnline(); // Listen to online

@@ -243,3 +243,3 @@

}
new OnlineManager$1();
new OnlineManager();

@@ -456,262 +456,2 @@ // TYPES

/**
* react-query
*
* Copyright (c) TanStack
*
* This source code is licensed under the MIT license found in the
* LICENSE.md file in the root directory of this source tree.
*
* @license MIT
*/
/**
* query-core
*
* Copyright (c) TanStack
*
* This source code is licensed under the MIT license found in the
* LICENSE.md file in the root directory of this source tree.
*
* @license MIT
*/
class Subscribable {
constructor() {
this.listeners = [];
this.subscribe = this.subscribe.bind(this);
}
subscribe(listener) {
this.listeners.push(listener);
this.onSubscribe();
return () => {
this.listeners = this.listeners.filter(x => x !== listener);
this.onUnsubscribe();
};
}
hasListeners() {
return this.listeners.length > 0;
}
onSubscribe() {// Do nothing
}
onUnsubscribe() {// Do nothing
}
}
// TYPES
// UTILS
const isServer = typeof window === 'undefined';
class FocusManager extends Subscribable {
constructor() {
super();
this.setup = onFocus => {
// addEventListener does not exist in React Native, but window does
// eslint-disable-next-line @typescript-eslint/no-unnecessary-condition
if (!isServer && window.addEventListener) {
const listener = () => onFocus(); // Listen to visibillitychange and focus
window.addEventListener('visibilitychange', listener, false);
window.addEventListener('focus', listener, false);
return () => {
// Be sure to unsubscribe if a new handler is set
window.removeEventListener('visibilitychange', listener);
window.removeEventListener('focus', listener);
};
}
};
}
onSubscribe() {
if (!this.cleanup) {
this.setEventListener(this.setup);
}
}
onUnsubscribe() {
if (!this.hasListeners()) {
var _this$cleanup;
(_this$cleanup = this.cleanup) == null ? void 0 : _this$cleanup.call(this);
this.cleanup = undefined;
}
}
setEventListener(setup) {
var _this$cleanup2;
this.setup = setup;
(_this$cleanup2 = this.cleanup) == null ? void 0 : _this$cleanup2.call(this);
this.cleanup = setup(focused => {
if (typeof focused === 'boolean') {
this.setFocused(focused);
} else {
this.onFocus();
}
});
}
setFocused(focused) {
this.focused = focused;
if (focused) {
this.onFocus();
}
}
onFocus() {
this.listeners.forEach(listener => {
listener();
});
}
isFocused() {
if (typeof this.focused === 'boolean') {
return this.focused;
} // document global can be unavailable in react native
if (typeof document === 'undefined') {
return true;
}
return [undefined, 'visible', 'prerender'].includes(document.visibilityState);
}
}
new FocusManager();
class OnlineManager extends Subscribable {
constructor() {
super();
this.setup = onOnline => {
// addEventListener does not exist in React Native, but window does
// eslint-disable-next-line @typescript-eslint/no-unnecessary-condition
if (!isServer && window.addEventListener) {
const listener = () => onOnline(); // Listen to online
window.addEventListener('online', listener, false);
window.addEventListener('offline', listener, false);
return () => {
// Be sure to unsubscribe if a new handler is set
window.removeEventListener('online', listener);
window.removeEventListener('offline', listener);
};
}
};
}
onSubscribe() {
if (!this.cleanup) {
this.setEventListener(this.setup);
}
}
onUnsubscribe() {
if (!this.hasListeners()) {
var _this$cleanup;
(_this$cleanup = this.cleanup) == null ? void 0 : _this$cleanup.call(this);
this.cleanup = undefined;
}
}
setEventListener(setup) {
var _this$cleanup2;
this.setup = setup;
(_this$cleanup2 = this.cleanup) == null ? void 0 : _this$cleanup2.call(this);
this.cleanup = setup(online => {
if (typeof online === 'boolean') {
this.setOnline(online);
} else {
this.onOnline();
}
});
}
setOnline(online) {
this.online = online;
if (online) {
this.onOnline();
}
}
onOnline() {
this.listeners.forEach(listener => {
listener();
});
}
isOnline() {
if (typeof this.online === 'boolean') {
return this.online;
}
if (typeof navigator === 'undefined' || typeof navigator.onLine === 'undefined') {
return true;
}
return navigator.onLine;
}
}
new OnlineManager();
const defaultContext = /*#__PURE__*/React__namespace.createContext(undefined);
const QueryClientSharingContext = /*#__PURE__*/React__namespace.createContext(false); // If we are given a context, we will use it.
// Otherwise, if contextSharing is on, we share the first and at least one
// instance of the context across the window
// to ensure that if React Query is used across
// different bundles or microfrontends they will
// all use the same **instance** of context, regardless
// of module scoping.
function getQueryClientContext(context, contextSharing) {
if (context) {
return context;
}
if (contextSharing && typeof window !== 'undefined') {
if (!window.ReactQueryClientContext) {
window.ReactQueryClientContext = defaultContext;
}
return window.ReactQueryClientContext;
}
return defaultContext;
}
const QueryClientProvider = ({
client,
children,
context,
contextSharing = false
}) => {
React__namespace.useEffect(() => {
client.mount();
return () => {
client.unmount();
};
}, [client]);
const Context = getQueryClientContext(context, contextSharing);
return /*#__PURE__*/React__namespace.createElement(QueryClientSharingContext.Provider, {
value: !context && contextSharing
}, /*#__PURE__*/React__namespace.createElement(Context.Provider, {
value: client
}, children));
};
const IsRestoringContext = /*#__PURE__*/React__namespace.createContext(false);
const IsRestoringProvider = IsRestoringContext.Provider;
const PersistQueryClientProvider = ({

@@ -752,5 +492,5 @@ client,

}, [client]);
return /*#__PURE__*/React__namespace.createElement(QueryClientProvider, _extends({
return /*#__PURE__*/React__namespace.createElement(reactQuery.QueryClientProvider, _extends({
client: client
}, props), /*#__PURE__*/React__namespace.createElement(IsRestoringProvider, {
}, props), /*#__PURE__*/React__namespace.createElement(reactQuery.IsRestoringProvider, {
value: isRestoring

@@ -757,0 +497,0 @@ }, children));

@@ -11,3 +11,3 @@ /**

*/
!function(e,t){"object"==typeof exports&&"undefined"!=typeof module?t(exports,require("react"),require("use-sync-external-store/shim")):"function"==typeof define&&define.amd?define(["exports","react","use-sync-external-store/shim"],t):t((e="undefined"!=typeof globalThis?globalThis:e||self).ReactQueryPersistClient={},e.React)}(this,(function(e,t){"use strict";function n(e){if(e&&e.__esModule)return e;var t=Object.create(null);return e&&Object.keys(e).forEach((function(n){if("default"!==n){var s=Object.getOwnPropertyDescriptor(e,n);Object.defineProperty(t,n,s.get?s:{enumerable:!0,get:function(){return e[n]}})}})),t.default=e,Object.freeze(t)}var s=n(t);
!function(e,t){"object"==typeof exports&&"undefined"!=typeof module?t(exports,require("react"),require("@tanstack/react-query")):"function"==typeof define&&define.amd?define(["exports","react","@tanstack/react-query"],t):t((e="undefined"!=typeof globalThis?globalThis:e||self).ReactQueryPersistClient={},e.React,e.ReactQuery)}(this,(function(e,t,n){"use strict";function s(e){if(e&&e.__esModule)return e;var t=Object.create(null);return e&&Object.keys(e).forEach((function(n){if("default"!==n){var s=Object.getOwnPropertyDescriptor(e,n);Object.defineProperty(t,n,s.get?s:{enumerable:!0,get:function(){return e[n]}})}})),t.default=e,Object.freeze(t)}var i=s(t);
/**

@@ -22,23 +22,3 @@ * query-core

* @license MIT
*/class i{constructor(){this.listeners=[],this.subscribe=this.subscribe.bind(this)}subscribe(e){return this.listeners.push(e),this.onSubscribe(),()=>{this.listeners=this.listeners.filter((t=>t!==e)),this.onUnsubscribe()}}hasListeners(){return this.listeners.length>0}onSubscribe(){}onUnsubscribe(){}}const r="undefined"==typeof window;new class extends i{constructor(){super(),this.setup=e=>{if(!r&&window.addEventListener){const t=()=>e();return window.addEventListener("visibilitychange",t,!1),window.addEventListener("focus",t,!1),()=>{window.removeEventListener("visibilitychange",t),window.removeEventListener("focus",t)}}}}onSubscribe(){this.cleanup||this.setEventListener(this.setup)}onUnsubscribe(){var e;this.hasListeners()||(null==(e=this.cleanup)||e.call(this),this.cleanup=void 0)}setEventListener(e){var t;this.setup=e,null==(t=this.cleanup)||t.call(this),this.cleanup=e((e=>{"boolean"==typeof e?this.setFocused(e):this.onFocus()}))}setFocused(e){this.focused=e,e&&this.onFocus()}onFocus(){this.listeners.forEach((e=>{e()}))}isFocused(){return"boolean"==typeof this.focused?this.focused:"undefined"==typeof document||[void 0,"visible","prerender"].includes(document.visibilityState)}};function o(e){return e.state.isPaused}function u(e){return"success"===e.state.status}function c(e,t={}){const n=[],s=[];if(!1!==t.dehydrateMutations){const s=t.shouldDehydrateMutation||o;e.getMutationCache().getAll().forEach((e=>{s(e)&&n.push(function(e){return{mutationKey:e.options.mutationKey,state:e.state}}(e))}))}if(!1!==t.dehydrateQueries){const n=t.shouldDehydrateQuery||u;e.getQueryCache().getAll().forEach((e=>{n(e)&&s.push(function(e){return{state:e.state,queryKey:e.queryKey,queryHash:e.queryHash}}(e))}))}return{mutations:n,queries:s}}async function a({queryClient:e,persister:t,maxAge:n=864e5,buster:s="",hydrateOptions:i}){try{const r=await t.restoreClient();if(r)if(r.timestamp){const o=Date.now()-r.timestamp>n,u=r.buster!==s;o||u?t.removeClient():function(e,t,n){if("object"!=typeof t||null===t)return;const s=e.getMutationCache(),i=e.getQueryCache(),r=t.mutations||[],o=t.queries||[];r.forEach((t=>{var i;s.build(e,{...null==n||null==(i=n.defaultOptions)?void 0:i.mutations,mutationKey:t.mutationKey},t.state)})),o.forEach((t=>{var s;const r=i.get(t.queryHash);r?r.state.dataUpdatedAt<t.state.dataUpdatedAt&&r.setState(t.state):i.build(e,{...null==n||null==(s=n.defaultOptions)?void 0:s.queries,queryKey:t.queryKey,queryHash:t.queryHash},t.state)}))}(e,r.clientState,i)}else t.removeClient()}catch(e){t.removeClient()}}async function l({queryClient:e,persister:t,buster:n="",dehydrateOptions:s}){const i={buster:n,timestamp:Date.now(),clientState:c(e,s)};await t.persistClient(i)}function h(e){const t=e.queryClient.getQueryCache().subscribe((()=>{l(e)})),n=e.queryClient.getMutationCache().subscribe((()=>{l(e)}));return()=>{t(),n()}}function d(e){let t,n=!1;return[()=>{n=!0,null==t||t()},a(e).then((()=>{n||(t=h(e))}))]}function f(){return f=Object.assign?Object.assign.bind():function(e){for(var t=1;t<arguments.length;t++){var n=arguments[t];for(var s in n)Object.prototype.hasOwnProperty.call(n,s)&&(e[s]=n[s])}return e},f.apply(this,arguments)}
/**
* react-query
*
* Copyright (c) TanStack
*
* This source code is licensed under the MIT license found in the
* LICENSE.md file in the root directory of this source tree.
*
* @license MIT
*/
/**
* query-core
*
* Copyright (c) TanStack
*
* This source code is licensed under the MIT license found in the
* LICENSE.md file in the root directory of this source tree.
*
* @license MIT
*/new class extends i{constructor(){super(),this.setup=e=>{if(!r&&window.addEventListener){const t=()=>e();return window.addEventListener("online",t,!1),window.addEventListener("offline",t,!1),()=>{window.removeEventListener("online",t),window.removeEventListener("offline",t)}}}}onSubscribe(){this.cleanup||this.setEventListener(this.setup)}onUnsubscribe(){var e;this.hasListeners()||(null==(e=this.cleanup)||e.call(this),this.cleanup=void 0)}setEventListener(e){var t;this.setup=e,null==(t=this.cleanup)||t.call(this),this.cleanup=e((e=>{"boolean"==typeof e?this.setOnline(e):this.onOnline()}))}setOnline(e){this.online=e,e&&this.onOnline()}onOnline(){this.listeners.forEach((e=>{e()}))}isOnline(){return"boolean"==typeof this.online?this.online:"undefined"==typeof navigator||void 0===navigator.onLine||navigator.onLine}};class p{constructor(){this.listeners=[],this.subscribe=this.subscribe.bind(this)}subscribe(e){return this.listeners.push(e),this.onSubscribe(),()=>{this.listeners=this.listeners.filter((t=>t!==e)),this.onUnsubscribe()}}hasListeners(){return this.listeners.length>0}onSubscribe(){}onUnsubscribe(){}}const v="undefined"==typeof window;new class extends p{constructor(){super(),this.setup=e=>{if(!v&&window.addEventListener){const t=()=>e();return window.addEventListener("visibilitychange",t,!1),window.addEventListener("focus",t,!1),()=>{window.removeEventListener("visibilitychange",t),window.removeEventListener("focus",t)}}}}onSubscribe(){this.cleanup||this.setEventListener(this.setup)}onUnsubscribe(){var e;this.hasListeners()||(null==(e=this.cleanup)||e.call(this),this.cleanup=void 0)}setEventListener(e){var t;this.setup=e,null==(t=this.cleanup)||t.call(this),this.cleanup=e((e=>{"boolean"==typeof e?this.setFocused(e):this.onFocus()}))}setFocused(e){this.focused=e,e&&this.onFocus()}onFocus(){this.listeners.forEach((e=>{e()}))}isFocused(){return"boolean"==typeof this.focused?this.focused:"undefined"==typeof document||[void 0,"visible","prerender"].includes(document.visibilityState)}};new class extends p{constructor(){super(),this.setup=e=>{if(!v&&window.addEventListener){const t=()=>e();return window.addEventListener("online",t,!1),window.addEventListener("offline",t,!1),()=>{window.removeEventListener("online",t),window.removeEventListener("offline",t)}}}}onSubscribe(){this.cleanup||this.setEventListener(this.setup)}onUnsubscribe(){var e;this.hasListeners()||(null==(e=this.cleanup)||e.call(this),this.cleanup=void 0)}setEventListener(e){var t;this.setup=e,null==(t=this.cleanup)||t.call(this),this.cleanup=e((e=>{"boolean"==typeof e?this.setOnline(e):this.onOnline()}))}setOnline(e){this.online=e,e&&this.onOnline()}onOnline(){this.listeners.forEach((e=>{e()}))}isOnline(){return"boolean"==typeof this.online?this.online:"undefined"==typeof navigator||void 0===navigator.onLine||navigator.onLine}};const b=s.createContext(void 0),y=s.createContext(!1);const w=({client:e,children:t,context:n,contextSharing:i=!1})=>{s.useEffect((()=>(e.mount(),()=>{e.unmount()})),[e]);const r=function(e,t){return e||(t&&"undefined"!=typeof window?(window.ReactQueryClientContext||(window.ReactQueryClientContext=b),window.ReactQueryClientContext):b)}(n,i);return s.createElement(y.Provider,{value:!n&&i},s.createElement(r.Provider,{value:e},t))},E=s.createContext(!1).Provider;e.PersistQueryClientProvider=({client:e,children:t,persistOptions:n,onSuccess:i,...r})=>{const[o,u]=s.useState(!0),c=s.useRef({persistOptions:n,onSuccess:i});return s.useEffect((()=>{c.current={persistOptions:n,onSuccess:i}})),s.useEffect((()=>{let t=!1;u(!0);const[n,s]=d({...c.current.persistOptions,queryClient:e});return s.then((()=>{t||(null==c.current.onSuccess||c.current.onSuccess(),u(!1))})),()=>{t=!0,n()}}),[e]),s.createElement(w,f({client:e},r),s.createElement(E,{value:o},t))},e.persistQueryClient=d,e.persistQueryClientRestore=a,e.persistQueryClientSave=l,e.persistQueryClientSubscribe=h,e.removeOldestQuery=({persistedClient:e})=>{const t=[...e.clientState.mutations],n=[...e.clientState.queries],s={...e,clientState:{mutations:t,queries:n}},i=[...n].sort(((e,t)=>e.state.dataUpdatedAt-t.state.dataUpdatedAt));if(i.length>0){const e=i.shift();return s.clientState.queries=n.filter((t=>t!==e)),s}},Object.defineProperty(e,"__esModule",{value:!0})}));
*/class r{constructor(){this.listeners=[],this.subscribe=this.subscribe.bind(this)}subscribe(e){return this.listeners.push(e),this.onSubscribe(),()=>{this.listeners=this.listeners.filter((t=>t!==e)),this.onUnsubscribe()}}hasListeners(){return this.listeners.length>0}onSubscribe(){}onUnsubscribe(){}}const u="undefined"==typeof window;new class extends r{constructor(){super(),this.setup=e=>{if(!u&&window.addEventListener){const t=()=>e();return window.addEventListener("visibilitychange",t,!1),window.addEventListener("focus",t,!1),()=>{window.removeEventListener("visibilitychange",t),window.removeEventListener("focus",t)}}}}onSubscribe(){this.cleanup||this.setEventListener(this.setup)}onUnsubscribe(){var e;this.hasListeners()||(null==(e=this.cleanup)||e.call(this),this.cleanup=void 0)}setEventListener(e){var t;this.setup=e,null==(t=this.cleanup)||t.call(this),this.cleanup=e((e=>{"boolean"==typeof e?this.setFocused(e):this.onFocus()}))}setFocused(e){this.focused=e,e&&this.onFocus()}onFocus(){this.listeners.forEach((e=>{e()}))}isFocused(){return"boolean"==typeof this.focused?this.focused:"undefined"==typeof document||[void 0,"visible","prerender"].includes(document.visibilityState)}};function o(e){return e.state.isPaused}function a(e){return"success"===e.state.status}function c(e,t={}){const n=[],s=[];if(!1!==t.dehydrateMutations){const s=t.shouldDehydrateMutation||o;e.getMutationCache().getAll().forEach((e=>{s(e)&&n.push(function(e){return{mutationKey:e.options.mutationKey,state:e.state}}(e))}))}if(!1!==t.dehydrateQueries){const n=t.shouldDehydrateQuery||a;e.getQueryCache().getAll().forEach((e=>{n(e)&&s.push(function(e){return{state:e.state,queryKey:e.queryKey,queryHash:e.queryHash}}(e))}))}return{mutations:n,queries:s}}async function l({queryClient:e,persister:t,maxAge:n=864e5,buster:s="",hydrateOptions:i}){try{const r=await t.restoreClient();if(r)if(r.timestamp){const u=Date.now()-r.timestamp>n,o=r.buster!==s;u||o?t.removeClient():function(e,t,n){if("object"!=typeof t||null===t)return;const s=e.getMutationCache(),i=e.getQueryCache(),r=t.mutations||[],u=t.queries||[];r.forEach((t=>{var i;s.build(e,{...null==n||null==(i=n.defaultOptions)?void 0:i.mutations,mutationKey:t.mutationKey},t.state)})),u.forEach((t=>{var s;const r=i.get(t.queryHash);r?r.state.dataUpdatedAt<t.state.dataUpdatedAt&&r.setState(t.state):i.build(e,{...null==n||null==(s=n.defaultOptions)?void 0:s.queries,queryKey:t.queryKey,queryHash:t.queryHash},t.state)}))}(e,r.clientState,i)}else t.removeClient()}catch(e){t.removeClient()}}async function d({queryClient:e,persister:t,buster:n="",dehydrateOptions:s}){const i={buster:n,timestamp:Date.now(),clientState:c(e,s)};await t.persistClient(i)}function h(e){const t=e.queryClient.getQueryCache().subscribe((()=>{d(e)})),n=e.queryClient.getMutationCache().subscribe((()=>{d(e)}));return()=>{t(),n()}}function f(e){let t,n=!1;return[()=>{n=!0,null==t||t()},l(e).then((()=>{n||(t=h(e))}))]}function p(){return p=Object.assign?Object.assign.bind():function(e){for(var t=1;t<arguments.length;t++){var n=arguments[t];for(var s in n)Object.prototype.hasOwnProperty.call(n,s)&&(e[s]=n[s])}return e},p.apply(this,arguments)}new class extends r{constructor(){super(),this.setup=e=>{if(!u&&window.addEventListener){const t=()=>e();return window.addEventListener("online",t,!1),window.addEventListener("offline",t,!1),()=>{window.removeEventListener("online",t),window.removeEventListener("offline",t)}}}}onSubscribe(){this.cleanup||this.setEventListener(this.setup)}onUnsubscribe(){var e;this.hasListeners()||(null==(e=this.cleanup)||e.call(this),this.cleanup=void 0)}setEventListener(e){var t;this.setup=e,null==(t=this.cleanup)||t.call(this),this.cleanup=e((e=>{"boolean"==typeof e?this.setOnline(e):this.onOnline()}))}setOnline(e){this.online=e,e&&this.onOnline()}onOnline(){this.listeners.forEach((e=>{e()}))}isOnline(){return"boolean"==typeof this.online?this.online:"undefined"==typeof navigator||void 0===navigator.onLine||navigator.onLine}};e.PersistQueryClientProvider=({client:e,children:t,persistOptions:s,onSuccess:r,...u})=>{const[o,a]=i.useState(!0),c=i.useRef({persistOptions:s,onSuccess:r});return i.useEffect((()=>{c.current={persistOptions:s,onSuccess:r}})),i.useEffect((()=>{let t=!1;a(!0);const[n,s]=f({...c.current.persistOptions,queryClient:e});return s.then((()=>{t||(null==c.current.onSuccess||c.current.onSuccess(),a(!1))})),()=>{t=!0,n()}}),[e]),i.createElement(n.QueryClientProvider,p({client:e},u),i.createElement(n.IsRestoringProvider,{value:o},t))},e.persistQueryClient=f,e.persistQueryClientRestore=l,e.persistQueryClientSave=d,e.persistQueryClientSubscribe=h,e.removeOldestQuery=({persistedClient:e})=>{const t=[...e.clientState.mutations],n=[...e.clientState.queries],s={...e,clientState:{mutations:t,queries:n}},i=[...n].sort(((e,t)=>e.state.dataUpdatedAt-t.state.dataUpdatedAt));if(i.length>0){const e=i.shift();return s.clientState.queries=n.filter((t=>t!==e)),s}},Object.defineProperty(e,"__esModule",{value:!0})}));
//# sourceMappingURL=index.production.js.map
{
"name": "@tanstack/react-query-persist-client",
"version": "4.0.3",
"version": "4.0.5",
"description": "TODO",

@@ -5,0 +5,0 @@ "author": "tannerlinsley",

Sorry, the diff of this file is not supported yet

Sorry, the diff of this file is not supported yet

Sorry, the diff of this file is not supported yet

Sorry, the diff of this file is not supported yet

Sorry, the diff of this file is not supported yet

SocketSocket SOC 2 Logo

Product

  • Package Alerts
  • Integrations
  • Docs
  • Pricing
  • FAQ
  • Roadmap
  • Changelog

Packages

npm

Stay in touch

Get open source security insights delivered straight into your inbox.


  • Terms
  • Privacy
  • Security

Made with ⚡️ by Socket Inc