This commit is contained in:
Iliyan Angelov
2025-09-14 23:24:25 +03:00
commit c67067a2a4
71311 changed files with 6800714 additions and 0 deletions

File diff suppressed because it is too large Load Diff

File diff suppressed because one or more lines are too long

File diff suppressed because one or more lines are too long

File diff suppressed because one or more lines are too long

View File

@@ -0,0 +1,137 @@
(function (global, factory) {
typeof exports === 'object' && typeof module !== 'undefined' ? factory(exports) :
typeof define === 'function' && define.amd ? define(['exports'], factory) :
(global = global || self, factory(global.ReactQueryCreateAsyncStoragePersistorExperimental = {}));
}(this, (function (exports) { 'use strict';
function _await(value, then, direct) {
if (direct) {
return then ? then(value) : value;
}
if (!value || !value.then) {
value = Promise.resolve(value);
}
return then ? value.then(then) : value;
}
function _async(f) {
return function () {
for (var args = [], i = 0; i < arguments.length; i++) {
args[i] = arguments[i];
}
try {
return Promise.resolve(f.apply(this, args));
} catch (e) {
return Promise.reject(e);
}
};
}
function _empty() {}
function _invokeIgnored(body) {
var result = body();
if (result && result.then) {
return result.then(_empty);
}
}
var createAsyncStoragePersistor = function createAsyncStoragePersistor(_ref) {
var storage = _ref.storage,
_ref$key = _ref.key,
key = _ref$key === void 0 ? "REACT_QUERY_OFFLINE_CACHE" : _ref$key,
_ref$throttleTime = _ref.throttleTime,
throttleTime = _ref$throttleTime === void 0 ? 1000 : _ref$throttleTime,
_ref$serialize = _ref.serialize,
serialize = _ref$serialize === void 0 ? JSON.stringify : _ref$serialize,
_ref$deserialize = _ref.deserialize,
deserialize = _ref$deserialize === void 0 ? JSON.parse : _ref$deserialize;
return {
persistClient: asyncThrottle(function (persistedClient) {
return storage.setItem(key, serialize(persistedClient));
}, {
interval: throttleTime
}),
restoreClient: _async(function () {
return _await(storage.getItem(key), function (cacheString) {
if (!cacheString) {
return;
}
return deserialize(cacheString);
});
}),
removeClient: function removeClient() {
return storage.removeItem(key);
}
};
};
function asyncThrottle(func, _temp) {
var _ref2 = _temp === void 0 ? {} : _temp,
_ref2$interval = _ref2.interval,
interval = _ref2$interval === void 0 ? 1000 : _ref2$interval,
_ref2$limit = _ref2.limit,
limit = _ref2$limit === void 0 ? 1 : _ref2$limit;
if (typeof func !== 'function') throw new Error('argument is not function.');
var running = {
current: false
};
var lastTime = 0;
var timeout;
var queue = [];
return function () {
for (var _len = arguments.length, args = new Array(_len), _key = 0; _key < _len; _key++) {
args[_key] = arguments[_key];
}
return _async(function () {
if (running.current) {
lastTime = Date.now();
if (queue.length > limit) {
queue.shift();
}
queue.push(args);
clearTimeout(timeout);
}
return _invokeIgnored(function () {
if (Date.now() - lastTime > interval) {
running.current = true;
return _await(func.apply(void 0, args), function () {
lastTime = Date.now();
running.current = false;
});
} else {
if (queue.length > 0) {
var lastArgs = queue[queue.length - 1];
timeout = setTimeout(_async(function () {
return _invokeIgnored(function () {
if (!running.current) {
running.current = true;
return _await(func.apply(void 0, lastArgs), function () {
running.current = false;
});
}
});
}), interval);
}
}
});
})();
};
}
exports.createAsyncStoragePersistor = createAsyncStoragePersistor;
Object.defineProperty(exports, '__esModule', { value: true });
})));
//# sourceMappingURL=createAsyncStoragePersistor-experimental.development.js.map

File diff suppressed because one or more lines are too long

View File

@@ -0,0 +1,2 @@
!function(e,t){"object"==typeof exports&&"undefined"!=typeof module?t(exports):"function"==typeof define&&define.amd?define(["exports"],t):t((e=e||self).ReactQueryCreateAsyncStoragePersistorExperimental={})}(this,(function(e){"use strict";function t(e,t,n){return n?t?t(e):e:(e&&e.then||(e=Promise.resolve(e)),t?e.then(t):e)}function n(e){return function(){for(var t=[],n=0;n<arguments.length;n++)t[n]=arguments[n];try{return Promise.resolve(e.apply(this,t))}catch(e){return Promise.reject(e)}}}function r(){}function i(e){var t=e();if(t&&t.then)return t.then(r)}function o(e,r){var o=void 0===r?{}:r,u=o.interval,f=void 0===u?1e3:u,c=o.limit,s=void 0===c?1:c;if("function"!=typeof e)throw new Error("argument is not function.");var a,l={current:!1},v=0,d=[];return function(){for(var r=arguments.length,o=new Array(r),u=0;u<r;u++)o[u]=arguments[u];return n((function(){return l.current&&(v=Date.now(),d.length>s&&d.shift(),d.push(o),clearTimeout(a)),i((function(){if(Date.now()-v>f)return l.current=!0,t(e.apply(void 0,o),(function(){v=Date.now(),l.current=!1}));if(d.length>0){var r=d[d.length-1];a=setTimeout(n((function(){return i((function(){if(!l.current)return l.current=!0,t(e.apply(void 0,r),(function(){l.current=!1}))}))})),f)}}))}))()}}e.createAsyncStoragePersistor=function(e){var r=e.storage,i=e.key,u=void 0===i?"REACT_QUERY_OFFLINE_CACHE":i,f=e.throttleTime,c=void 0===f?1e3:f,s=e.serialize,a=void 0===s?JSON.stringify:s,l=e.deserialize,v=void 0===l?JSON.parse:l;return{persistClient:o((function(e){return r.setItem(u,a(e))}),{interval:c}),restoreClient:n((function(){return t(r.getItem(u),(function(e){if(e)return v(e)}))})),removeClient:function(){return r.removeItem(u)}}},Object.defineProperty(e,"__esModule",{value:!0})}));
//# sourceMappingURL=createAsyncStoragePersistor-experimental.production.min.js.map

View File

@@ -0,0 +1 @@
{"version":3,"file":"createAsyncStoragePersistor-experimental.production.min.js","sources":["../src/createAsyncStoragePersistor-experimental/index.ts"],"sourcesContent":["import { PersistedClient, Persistor } from '../persistQueryClient-experimental'\n\ninterface AsyncStorage {\n getItem: (key: string) => Promise<string | null>\n setItem: (key: string, value: string) => Promise<void>\n removeItem: (key: string) => Promise<void>\n}\n\ninterface CreateAsyncStoragePersistorOptions {\n /** The storage client used for setting an retrieving items from cache */\n storage: AsyncStorage\n /** The key to use when storing the cache */\n key?: string\n /** To avoid spamming,\n * pass a time in ms to throttle saving the cache to disk */\n throttleTime?: number\n /**\n * How to serialize the data to storage.\n * @default `JSON.stringify`\n */\n serialize?: (client: PersistedClient) => string\n /**\n * How to deserialize the data from storage.\n * @default `JSON.parse`\n */\n deserialize?: (cachedString: string) => PersistedClient\n}\n\nexport const createAsyncStoragePersistor = ({\n storage,\n key = `REACT_QUERY_OFFLINE_CACHE`,\n throttleTime = 1000,\n serialize = JSON.stringify,\n deserialize = JSON.parse,\n}: CreateAsyncStoragePersistorOptions): Persistor => {\n return {\n persistClient: asyncThrottle(\n persistedClient => storage.setItem(key, serialize(persistedClient)),\n { interval: throttleTime }\n ),\n restoreClient: async () => {\n const cacheString = await storage.getItem(key)\n\n if (!cacheString) {\n return\n }\n\n return deserialize(cacheString) as PersistedClient\n },\n removeClient: () => storage.removeItem(key),\n }\n}\n\nfunction asyncThrottle<Args extends readonly unknown[], Result>(\n func: (...args: Args) => Promise<Result>,\n { interval = 1000, limit = 1 }: { interval?: number; limit?: number } = {}\n) {\n if (typeof func !== 'function') throw new Error('argument is not function.')\n const running = { current: false }\n let lastTime = 0\n let timeout: number\n const queue: Array<Args> = []\n return (...args: Args) =>\n (async () => {\n if (running.current) {\n lastTime = Date.now()\n if (queue.length > limit) {\n queue.shift()\n }\n\n queue.push(args)\n clearTimeout(timeout)\n }\n if (Date.now() - lastTime > interval) {\n running.current = true\n await func(...args)\n lastTime = Date.now()\n running.current = false\n } else {\n if (queue.length > 0) {\n const lastArgs = queue[queue.length - 1]!\n timeout = setTimeout(async () => {\n if (!running.current) {\n running.current = true\n await func(...lastArgs)\n running.current = false\n }\n }, interval)\n }\n }\n })()\n}\n"],"names":["value","then","direct","Promise","resolve","f","args","i","arguments","length","apply","this","e","reject","body","result","asyncThrottle","func","interval","limit","Error","timeout","running","current","lastTime","queue","_async","Date","now","shift","push","clearTimeout","lastArgs","setTimeout","storage","key","throttleTime","serialize","JSON","stringify","deserialize","parse","persistClient","persistedClient","setItem","restoreClient","getItem","cacheString","removeClient","removeItem"],"mappings":"+OAoFO,WAAgBA,EAAOC,EAAMC,UAC/BA,EACID,EAAOA,EAAKD,GAASA,GAExBA,GAAUA,EAAMC,OACpBD,EAAQG,QAAQC,QAAQJ,IAElBC,EAAOD,EAAMC,KAAKA,GAAQD,GArB3B,WAAgBK,UACf,eACD,IAAIC,EAAO,GAAIC,EAAI,EAAGA,EAAIC,UAAUC,OAAQF,IAChDD,EAAKC,GAAKC,UAAUD,cAGbJ,QAAQC,QAAQC,EAAEK,MAAMC,KAAML,IACpC,MAAMM,UACAT,QAAQU,OAAOD,KAkhBlB,cAtDA,WAAwBE,OAC1BC,EAASD,OACTC,GAAUA,EAAOd,YACbc,EAAOd,QAxfhB,SAASe,EACPC,sBACwE,SAAtEC,SAAAA,aAAW,UAAMC,MAAAA,aAAQ,OAEP,mBAATF,EAAqB,MAAM,IAAIG,MAAM,iCAG5CC,EAFEC,EAAU,CAAEC,SAAS,GACvBC,EAAW,EAETC,EAAqB,UACpB,sCAAInB,2BAAAA,yBACToB,qBACMJ,EAAQC,UACVC,EAAWG,KAAKC,MACZH,EAAMhB,OAASU,GACjBM,EAAMI,QAGRJ,EAAMK,KAAKxB,GACXyB,aAAaV,qBAEXM,KAAKC,MAAQJ,EAAWN,SAC1BI,EAAQC,SAAU,IACZN,eAAQX,eACdkB,EAAWG,KAAKC,MAChBN,EAAQC,SAAU,QAEdE,EAAMhB,OAAS,OACXuB,EAAWP,EAAMA,EAAMhB,OAAS,GACtCY,EAAUY,kDACHX,EAAQC,eACXD,EAAQC,SAAU,IACZN,eAAQe,eACdV,EAAQC,SAAU,WAEnBL,SAxBTQ,kCAnCuC,gBACzCQ,IAAAA,YACAC,IAAAA,+CACAC,aAAAA,aAAe,UACfC,UAAAA,aAAYC,KAAKC,gBACjBC,YAAAA,aAAcF,KAAKG,cAEZ,CACLC,cAAe1B,GACb,SAAA2B,UAAmBT,EAAQU,QAAQT,EAAKE,EAAUM,MAClD,CAAEzB,SAAUkB,IAEdS,qCAC4BX,EAAQY,QAAQX,aAApCY,MAEDA,SAIEP,EAAYO,SAErBC,aAAc,kBAAMd,EAAQe,WAAWd"}

View File

@@ -0,0 +1,147 @@
(function (global, factory) {
typeof exports === 'object' && typeof module !== 'undefined' ? factory(exports) :
typeof define === 'function' && define.amd ? define(['exports'], factory) :
(global = global || self, factory(global.ReactQueryCreateWebStoragePersistorExperimental = {}));
}(this, (function (exports) { 'use strict';
function _extends() {
_extends = Object.assign || function (target) {
for (var i = 1; i < arguments.length; i++) {
var source = arguments[i];
for (var key in source) {
if (Object.prototype.hasOwnProperty.call(source, key)) {
target[key] = source[key];
}
}
}
return target;
};
return _extends.apply(this, arguments);
}
function noop() {
return undefined;
}
function createWebStoragePersistor(_ref) {
var storage = _ref.storage,
_ref$key = _ref.key,
key = _ref$key === void 0 ? "REACT_QUERY_OFFLINE_CACHE" : _ref$key,
_ref$throttleTime = _ref.throttleTime,
throttleTime = _ref$throttleTime === void 0 ? 1000 : _ref$throttleTime,
_ref$serialize = _ref.serialize,
serialize = _ref$serialize === void 0 ? JSON.stringify : _ref$serialize,
_ref$deserialize = _ref.deserialize,
deserialize = _ref$deserialize === void 0 ? JSON.parse : _ref$deserialize;
//try to save data to storage
function trySave(persistedClient) {
try {
storage.setItem(key, serialize(persistedClient));
} catch (_unused) {
return false;
}
return true;
}
if (typeof storage !== 'undefined') {
return {
persistClient: throttle(function (persistedClient) {
if (trySave(persistedClient) !== true) {
var mutations = [].concat(persistedClient.clientState.mutations);
var queries = [].concat(persistedClient.clientState.queries);
var _client = _extends({}, persistedClient, {
clientState: {
mutations: mutations,
queries: queries
}
}); // sort queries by dataUpdatedAt (oldest first)
var sortedQueries = [].concat(queries).sort(function (a, b) {
return a.state.dataUpdatedAt - b.state.dataUpdatedAt;
}); // clean old queries and try to save
var _loop = function _loop() {
var oldestData = sortedQueries.shift();
_client.clientState.queries = queries.filter(function (q) {
return q !== oldestData;
});
if (trySave(_client)) {
return {
v: void 0
}; // save success
}
};
while (sortedQueries.length > 0) {
var _ret = _loop();
if (typeof _ret === "object") return _ret.v;
} // clean mutations and try to save
while (mutations.shift()) {
if (trySave(_client)) {
return; // save success
}
}
}
}, throttleTime),
restoreClient: function restoreClient() {
var cacheString = storage.getItem(key);
if (!cacheString) {
return;
}
return deserialize(cacheString);
},
removeClient: function removeClient() {
storage.removeItem(key);
}
};
}
return {
persistClient: noop,
restoreClient: noop,
removeClient: noop
};
}
function throttle(func, wait) {
if (wait === void 0) {
wait = 100;
}
var timer = null;
var params;
return function () {
for (var _len = arguments.length, args = new Array(_len), _key = 0; _key < _len; _key++) {
args[_key] = arguments[_key];
}
params = args;
if (timer === null) {
timer = setTimeout(function () {
func.apply(void 0, params);
timer = null;
}, wait);
}
};
}
exports.createWebStoragePersistor = createWebStoragePersistor;
Object.defineProperty(exports, '__esModule', { value: true });
})));
//# sourceMappingURL=createWebStoragePersistor-experimental.development.js.map

File diff suppressed because one or more lines are too long

View File

@@ -0,0 +1,2 @@
!function(t,e){"object"==typeof exports&&"undefined"!=typeof module?e(exports):"function"==typeof define&&define.amd?define(["exports"],e):e((t=t||self).ReactQueryCreateWebStoragePersistorExperimental={})}(this,(function(t){"use strict";function e(){return(e=Object.assign||function(t){for(var e=1;e<arguments.length;e++){var r=arguments[e];for(var n in r)Object.prototype.hasOwnProperty.call(r,n)&&(t[n]=r[n])}return t}).apply(this,arguments)}function r(){}function n(t,e){void 0===e&&(e=100);var r,n=null;return function(){for(var i=arguments.length,o=new Array(i),a=0;a<i;a++)o[a]=arguments[a];r=o,null===n&&(n=setTimeout((function(){t.apply(void 0,r),n=null}),e))}}t.createWebStoragePersistor=function(t){var i=t.storage,o=t.key,a=void 0===o?"REACT_QUERY_OFFLINE_CACHE":o,u=t.throttleTime,f=void 0===u?1e3:u,s=t.serialize,c=void 0===s?JSON.stringify:s,l=t.deserialize,d=void 0===l?JSON.parse:l;function v(t){try{i.setItem(a,c(t))}catch(t){return!1}return!0}return void 0!==i?{persistClient:n((function(t){if(!0!==v(t)){for(var r=[].concat(t.clientState.mutations),n=[].concat(t.clientState.queries),i=e({},t,{clientState:{mutations:r,queries:n}}),o=[].concat(n).sort((function(t,e){return t.state.dataUpdatedAt-e.state.dataUpdatedAt})),a=function(){var t=o.shift();if(i.clientState.queries=n.filter((function(e){return e!==t})),v(i))return{v:void 0}};o.length>0;){var u=a();if("object"==typeof u)return u.v}for(;r.shift();)if(v(i))return}}),f),restoreClient:function(){var t=i.getItem(a);if(t)return d(t)},removeClient:function(){i.removeItem(a)}}:{persistClient:r,restoreClient:r,removeClient:r}},Object.defineProperty(t,"__esModule",{value:!0})}));
//# sourceMappingURL=createWebStoragePersistor-experimental.production.min.js.map

File diff suppressed because one or more lines are too long

View File

@@ -0,0 +1,124 @@
(function (global, factory) {
typeof exports === 'object' && typeof module !== 'undefined' ? factory(exports, require('react-query')) :
typeof define === 'function' && define.amd ? define(['exports', 'react-query'], factory) :
(global = global || self, factory(global.ReactQueryPersistQueryClientExperimental = {}, global.ReactQuery));
}(this, (function (exports, reactQuery) { 'use strict';
// TYPES
// FUNCTIONS
var logger = console;
function getLogger() {
return logger;
}
function _await(value, then, direct) {
if (direct) {
return then ? then(value) : value;
}
if (!value || !value.then) {
value = Promise.resolve(value);
}
return then ? value.then(then) : value;
}
function _catch(body, recover) {
try {
var result = body();
} catch (e) {
return recover(e);
}
if (result && result.then) {
return result.then(void 0, recover);
}
return result;
}
function _continue(value, then) {
return value && value.then ? value.then(then) : then(value);
}
function _empty() {}
function _invokeIgnored(body) {
var result = body();
if (result && result.then) {
return result.then(_empty);
}
}
function _async(f) {
return function () {
for (var args = [], i = 0; i < arguments.length; i++) {
args[i] = arguments[i];
}
try {
return Promise.resolve(f.apply(this, args));
} catch (e) {
return Promise.reject(e);
}
};
}
var persistQueryClient = _async(function (_ref) {
var queryClient = _ref.queryClient,
persistor = _ref.persistor,
_ref$maxAge = _ref.maxAge,
maxAge = _ref$maxAge === void 0 ? 1000 * 60 * 60 * 24 : _ref$maxAge,
_ref$buster = _ref.buster,
buster = _ref$buster === void 0 ? '' : _ref$buster,
hydrateOptions = _ref.hydrateOptions,
dehydrateOptions = _ref.dehydrateOptions;
return _invokeIgnored(function () {
if (typeof window !== 'undefined') {
// Subscribe to changes
var saveClient = function saveClient() {
var persistClient = {
buster: buster,
timestamp: Date.now(),
clientState: reactQuery.dehydrate(queryClient, dehydrateOptions)
};
persistor.persistClient(persistClient);
}; // Attempt restore
return _continue(_catch(function () {
return _await(persistor.restoreClient(), function (persistedClient) {
if (persistedClient) {
if (persistedClient.timestamp) {
var expired = Date.now() - persistedClient.timestamp > maxAge;
var busted = persistedClient.buster !== buster;
if (expired || busted) {
persistor.removeClient();
} else {
reactQuery.hydrate(queryClient, persistedClient.clientState, hydrateOptions);
}
} else {
persistor.removeClient();
}
}
});
}, function (err) {
getLogger().error(err);
getLogger().warn('Encountered an error attempting to restore client cache from persisted location. As a precaution, the persisted cache will be discarded.');
persistor.removeClient();
}), function () {
// Subscribe to changes in the query cache to trigger the save
queryClient.getQueryCache().subscribe(saveClient);
});
}
});
});
exports.persistQueryClient = persistQueryClient;
Object.defineProperty(exports, '__esModule', { value: true });
})));
//# sourceMappingURL=persistQueryClient-experimental.development.js.map

File diff suppressed because one or more lines are too long

View File

@@ -0,0 +1,2 @@
!function(e,t){"object"==typeof exports&&"undefined"!=typeof module?t(exports,require("react-query")):"function"==typeof define&&define.amd?define(["exports","react-query"],t):t((e=e||self).ReactQueryPersistQueryClientExperimental={},e.ReactQuery)}(this,(function(e,t){"use strict";var r=console;function n(){return r}function i(){}var o,u=(o=function(e){var r=e.queryClient,o=e.persistor,u=e.maxAge,a=void 0===u?864e5:u,c=e.buster,s=void 0===c?"":c,f=e.hydrateOptions,d=e.dehydrateOptions;return function(e){var t=e();if(t&&t.then)return t.then(i)}((function(){if("undefined"!=typeof window){var e=function(){var e={buster:s,timestamp:Date.now(),clientState:t.dehydrate(r,d)};o.persistClient(e)};return function(e,t){return e&&e.then?e.then(t):t(e)}(function(e,t){try{var r=e()}catch(e){return t(e)}return r&&r.then?r.then(void 0,t):r}((function(){return e=o.restoreClient(),n=function(e){if(e)if(e.timestamp){var n=Date.now()-e.timestamp>a,i=e.buster!==s;n||i?o.removeClient():t.hydrate(r,e.clientState,f)}else o.removeClient()},i?n?n(e):e:(e&&e.then||(e=Promise.resolve(e)),n?e.then(n):e);var e,n,i}),(function(e){n().error(e),n().warn("Encountered an error attempting to restore client cache from persisted location. As a precaution, the persisted cache will be discarded."),o.removeClient()})),(function(){r.getQueryCache().subscribe(e)}))}}))},function(){for(var e=[],t=0;t<arguments.length;t++)e[t]=arguments[t];try{return Promise.resolve(o.apply(this,e))}catch(e){return Promise.reject(e)}});e.persistQueryClient=u,Object.defineProperty(e,"__esModule",{value:!0})}));
//# sourceMappingURL=persistQueryClient-experimental.production.min.js.map

View File

@@ -0,0 +1 @@
{"version":3,"file":"persistQueryClient-experimental.production.min.js","sources":["../src/core/logger.ts","../src/persistQueryClient-experimental/index.ts"],"sourcesContent":["// TYPES\n\nexport interface Logger {\n log: LogFunction\n warn: LogFunction\n error: LogFunction\n}\n\ntype LogFunction = (...args: any[]) => void\n\n// FUNCTIONS\n\nlet logger: Logger = console\n\nexport function getLogger(): Logger {\n return logger\n}\n\nexport function setLogger(newLogger: Logger) {\n logger = newLogger\n}\n","import { QueryClient } from '../core'\nimport { getLogger } from '../core/logger'\nimport {\n dehydrate,\n DehydratedState,\n DehydrateOptions,\n HydrateOptions,\n hydrate,\n} from 'react-query'\nimport { Promisable } from 'type-fest'\n\nexport interface Persistor {\n persistClient(persistClient: PersistedClient): Promisable<void>\n restoreClient(): Promisable<PersistedClient | undefined>\n removeClient(): Promisable<void>\n}\n\nexport interface PersistedClient {\n timestamp: number\n buster: string\n clientState: DehydratedState\n}\n\nexport interface PersistQueryClientOptions {\n /** The QueryClient to persist */\n queryClient: QueryClient\n /** The Persistor interface for storing and restoring the cache\n * to/from a persisted location */\n persistor: Persistor\n /** The max-allowed age of the cache.\n * If a persisted cache is found that is older than this\n * time, it will be discarded */\n maxAge?: number\n /** A unique string that can be used to forcefully\n * invalidate existing caches if they do not share the same buster string */\n buster?: string\n /** The options passed to the hydrate function */\n hydrateOptions?: HydrateOptions\n /** The options passed to the dehydrate function */\n dehydrateOptions?: DehydrateOptions\n}\n\nexport async function persistQueryClient({\n queryClient,\n persistor,\n maxAge = 1000 * 60 * 60 * 24,\n buster = '',\n hydrateOptions,\n dehydrateOptions,\n}: PersistQueryClientOptions) {\n if (typeof window !== 'undefined') {\n // Subscribe to changes\n const saveClient = () => {\n const persistClient: PersistedClient = {\n buster,\n timestamp: Date.now(),\n clientState: dehydrate(queryClient, dehydrateOptions),\n }\n\n persistor.persistClient(persistClient)\n }\n\n // Attempt restore\n try {\n const persistedClient = await persistor.restoreClient()\n\n if (persistedClient) {\n if (persistedClient.timestamp) {\n const expired = Date.now() - persistedClient.timestamp > maxAge\n const busted = persistedClient.buster !== buster\n if (expired || busted) {\n persistor.removeClient()\n } else {\n hydrate(queryClient, persistedClient.clientState, hydrateOptions)\n }\n } else {\n persistor.removeClient()\n }\n }\n } catch (err) {\n getLogger().error(err)\n getLogger().warn(\n 'Encountered an error attempting to restore client cache from persisted location. As a precaution, the persisted cache will be discarded.'\n )\n persistor.removeClient()\n }\n\n // Subscribe to changes in the query cache to trigger the save\n queryClient.getQueryCache().subscribe(saveClient)\n }\n}\n"],"names":["logger","console","getLogger","f","persistQueryClient","queryClient","persistor","maxAge","buster","hydrateOptions","dehydrateOptions","body","result","then","window","saveClient","persistClient","timestamp","Date","now","clientState","dehydrate","value","recover","e","restoreClient","persistedClient","expired","busted","removeClient","hydrate","direct","Promise","resolve","err","error","warn","getQueryCache","subscribe","args","i","arguments","length","apply","this","reject"],"mappings":"0RAYA,IAAIA,EAAiBC,QAEd,SAASC,WACPF,ECilBF,kBA1hBgBG,EA5BDC,GA4BCD,kBA3BrBE,IAAAA,YACAC,IAAAA,cACAC,OAAAA,aAAS,YACTC,OAAAA,aAAS,KACTC,IAAAA,eACAC,IAAAA,wBA0fK,SAAwBC,OAC1BC,EAASD,OACTC,GAAUA,EAAOC,YACbD,EAAOC,wBA3fQ,oBAAXC,YAEHC,EAAa,eACXC,EAAiC,CACrCR,OAAAA,EACAS,UAAWC,KAAKC,MAChBC,YAAaC,YAAUhB,EAAaK,IAGtCJ,EAAUU,cAAcA,WA2CvB,SAAmBM,EAAOT,UACzBS,GAASA,EAAMT,KAAOS,EAAMT,KAAKA,GAAQA,EAAKS,IA2c/C,SAAgBX,EAAMY,WAEvBX,EAASD,IACZ,MAAMa,UACAD,EAAQC,UAEZZ,GAAUA,EAAOC,KACbD,EAAOC,UAAK,EAAQU,GAErBX,sBAveeU,EApBahB,EAAUmB,gBAoBhBZ,WApBlBa,MAEFA,KACEA,EAAgBT,eACZU,EAAUT,KAAKC,MAAQO,EAAgBT,UAAYV,EACnDqB,EAASF,EAAgBlB,SAAWA,EACtCmB,GAAWC,EACbtB,EAAUuB,eAEVC,UAAQzB,EAAaqB,EAAgBN,YAAaX,QAGpDH,EAAUuB,gBASfE,EACIlB,EAAOA,EAAKS,GAASA,GAExBA,GAAUA,EAAMT,OACpBS,EAAQU,QAAQC,QAAQX,IAElBT,EAAOS,EAAMT,KAAKA,GAAQS,GAP3B,IAAgBA,EAAOT,EAAMkB,cALvBG,GACPhC,IAAYiC,MAAMD,GAClBhC,IAAYkC,KACV,4IAEF9B,EAAUuB,8BAIZxB,EAAYgC,gBAAgBC,UAAUvB,WAjBlC,eACD,IAAIwB,EAAO,GAAIC,EAAI,EAAGA,EAAIC,UAAUC,OAAQF,IAChDD,EAAKC,GAAKC,UAAUD,cAGbR,QAAQC,QAAQ9B,EAAEwC,MAAMC,KAAML,IACpC,MAAMf,UACAQ,QAAQa,OAAOrB"}

File diff suppressed because it is too large Load Diff

File diff suppressed because one or more lines are too long

File diff suppressed because one or more lines are too long

File diff suppressed because one or more lines are too long

File diff suppressed because it is too large Load Diff

File diff suppressed because one or more lines are too long

File diff suppressed because one or more lines are too long

File diff suppressed because one or more lines are too long

View File

@@ -0,0 +1,35 @@
(function (global, factory) {
typeof exports === 'object' && typeof module !== 'undefined' ? factory(exports, require('react-query')) :
typeof define === 'function' && define.amd ? define(['exports', 'react-query'], factory) :
(global = global || self, factory(global.ReactQueryHydration = {}, global.ReactQuery));
}(this, (function (exports, reactQuery) { 'use strict';
Object.defineProperty(exports, 'Hydrate', {
enumerable: true,
get: function () {
return reactQuery.Hydrate;
}
});
Object.defineProperty(exports, 'dehydrate', {
enumerable: true,
get: function () {
return reactQuery.dehydrate;
}
});
Object.defineProperty(exports, 'hydrate', {
enumerable: true,
get: function () {
return reactQuery.hydrate;
}
});
Object.defineProperty(exports, 'useHydrate', {
enumerable: true,
get: function () {
return reactQuery.useHydrate;
}
});
Object.defineProperty(exports, '__esModule', { value: true });
})));
//# sourceMappingURL=react-query-hydration.development.js.map

View File

@@ -0,0 +1 @@
{"version":3,"file":"react-query-hydration.development.js","sources":[],"sourcesContent":[],"names":[],"mappings":";;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;"}

View File

@@ -0,0 +1,2 @@
!function(e,t){"object"==typeof exports&&"undefined"!=typeof module?t(exports,require("react-query")):"function"==typeof define&&define.amd?define(["exports","react-query"],t):t((e=e||self).ReactQueryHydration={},e.ReactQuery)}(this,(function(e,t){"use strict";Object.defineProperty(e,"Hydrate",{enumerable:!0,get:function(){return t.Hydrate}}),Object.defineProperty(e,"dehydrate",{enumerable:!0,get:function(){return t.dehydrate}}),Object.defineProperty(e,"hydrate",{enumerable:!0,get:function(){return t.hydrate}}),Object.defineProperty(e,"useHydrate",{enumerable:!0,get:function(){return t.useHydrate}}),Object.defineProperty(e,"__esModule",{value:!0})}));
//# sourceMappingURL=react-query-hydration.production.min.js.map

View File

@@ -0,0 +1 @@
{"version":3,"file":"react-query-hydration.production.min.js","sources":[],"sourcesContent":[],"names":[],"mappings":""}

File diff suppressed because it is too large Load Diff

File diff suppressed because one or more lines are too long

File diff suppressed because one or more lines are too long

File diff suppressed because one or more lines are too long