react-clear-cache
Advanced tools
Comparing version 1.4.10 to 1.4.11
@@ -79,3 +79,3 @@ import { useRef, useEffect, useState, createContext, createElement, useContext } from 'react'; | ||
function r(t,r,i,o){void 0===i&&(i=global),void 0===o&&(o={});var c=useRef(),u=o.capture,a=o.passive,v=o.once;useEffect(function(){c.current=r;},[r]),useEffect(function(){if(i&&i.addEventListener){var e=function(e){return c.current(e)},n={capture:u,passive:a,once:v};return i.addEventListener(t,e,n),function(){i.removeEventListener(t,e,n);}}},[t,i,u,a,v]);} | ||
function r(e,r,i){void 0===i&&(i=global);var o=useRef();useEffect(function(){o.current=r;},[r]),useEffect(function(){if(i&&i.addEventListener){var n=function(n){return o.current(n)};return i.addEventListener(e,n),function(){i.removeEventListener(e,n);}}},[e,i]);} | ||
@@ -121,22 +121,21 @@ var u={},c=function(t,n,e){return u[t]||(u[t]={callbacks:[],value:e}),u[t].callbacks.push(n),{deregister:function(){var e=u[t].callbacks,r$$1=e.indexOf(n);r$$1>-1&&e.splice(r$$1,1);},emit:function(e){u[t].value!==e&&(u[t].value=e,u[t].callbacks.forEach(function(t){n!==t&&t(e);}));}}};function createPersistedState(u,i){if(void 0===i&&(i=global.localStorage),i){var o=function(t){return {get:function(n,e){var r$$1=t.getItem(n);return null===r$$1?"function"==typeof e?e():e:JSON.parse(r$$1)},set:function(n,e){t.setItem(n,JSON.stringify(e));}}}(i);return function(i){return function(u,i,o){var a=o.get,f=o.set,l=useRef(null),s=useState(function(){return a(i,u)}),v=s[0],g=s[1];return r("storage",function(t){var n=t.key,e=JSON.parse(t.newValue);n===i&&v!==e&&g(e);}),useEffect(function(){return l.current=c(i,g,u),function(){l.current.deregister();}},[]),useEffect(function(){f(i,v),l.current.emit(v);},[v]),[v,g]}(i,u,o)}}return useState} | ||
var emptyCacheStorage = function (version) { return __awaiter(_this, void 0, void 0, function () { | ||
var cacheKeys; | ||
return __generator(this, function (_a) { | ||
switch (_a.label) { | ||
case 0: | ||
if ('caches' in window) { | ||
// Service worker cache should be cleared with caches.delete() | ||
caches.keys().then(function (names) { | ||
// eslint-disable-next-line no-restricted-syntax | ||
for (var _i = 0, names_1 = names; _i < names_1.length; _i++) { | ||
var name_1 = names_1[_i]; | ||
caches.delete(name_1); | ||
} | ||
}); | ||
} | ||
// clear browser cache and reload page | ||
return [4 /*yield*/, setVersion(version || latestVersion).then(function () { | ||
return window.location.reload(true); | ||
})]; | ||
if (!('caches' in window)) return [3 /*break*/, 3]; | ||
return [4 /*yield*/, window.caches.keys()]; | ||
case 1: | ||
cacheKeys = _a.sent(); | ||
return [4 /*yield*/, Promise.all(cacheKeys.map(window.caches.delete))]; | ||
case 2: | ||
_a.sent(); | ||
_a.label = 3; | ||
case 3: | ||
// clear browser cache and reload page | ||
return [4 /*yield*/, setVersion(version || latestVersion)]; | ||
case 4: | ||
// clear browser cache and reload page | ||
_a.sent(); | ||
window.location.reload(true); | ||
return [2 /*return*/]; | ||
@@ -187,14 +186,16 @@ } | ||
}, [loading]); | ||
var onFocus = useRef(function () { }); | ||
var onBlur = useRef(function () { }); | ||
onFocus.current = function () { | ||
fetchCacheTimeout = setInterval(function () { return fetchMeta(); }, duration); | ||
var startVersionCheck = useRef(function () { }); | ||
var stopVersionCheck = useRef(function () { }); | ||
startVersionCheck.current = function () { | ||
if (window.navigator.onLine) { | ||
fetchCacheTimeout = setInterval(function () { return fetchMeta(); }, duration); | ||
} | ||
}; | ||
onBlur.current = function () { | ||
stopVersionCheck.current = function () { | ||
clearInterval(fetchCacheTimeout); | ||
}; | ||
useEffect(function () { | ||
window.addEventListener('focus', onFocus.current); | ||
window.addEventListener('blur', onBlur.current); | ||
}); | ||
window.addEventListener('focus', startVersionCheck.current); | ||
window.addEventListener('blur', stopVersionCheck.current); | ||
}, []); | ||
useEffect(function () { | ||
@@ -201,0 +202,0 @@ fetchMeta(); |
@@ -83,3 +83,3 @@ 'use strict'; | ||
function r(t,r,i,o){void 0===i&&(i=global),void 0===o&&(o={});var c=React.useRef(),u=o.capture,a=o.passive,v=o.once;React.useEffect(function(){c.current=r;},[r]),React.useEffect(function(){if(i&&i.addEventListener){var e=function(e){return c.current(e)},n={capture:u,passive:a,once:v};return i.addEventListener(t,e,n),function(){i.removeEventListener(t,e,n);}}},[t,i,u,a,v]);} | ||
function r(e,r,i){void 0===i&&(i=global);var o=React.useRef();React.useEffect(function(){o.current=r;},[r]),React.useEffect(function(){if(i&&i.addEventListener){var n=function(n){return o.current(n)};return i.addEventListener(e,n),function(){i.removeEventListener(e,n);}}},[e,i]);} | ||
@@ -125,22 +125,21 @@ var u={},c=function(t,n,e){return u[t]||(u[t]={callbacks:[],value:e}),u[t].callbacks.push(n),{deregister:function(){var e=u[t].callbacks,r$$1=e.indexOf(n);r$$1>-1&&e.splice(r$$1,1);},emit:function(e){u[t].value!==e&&(u[t].value=e,u[t].callbacks.forEach(function(t){n!==t&&t(e);}));}}};function createPersistedState(u,i){if(void 0===i&&(i=global.localStorage),i){var o=function(t){return {get:function(n,e){var r$$1=t.getItem(n);return null===r$$1?"function"==typeof e?e():e:JSON.parse(r$$1)},set:function(n,e){t.setItem(n,JSON.stringify(e));}}}(i);return function(i){return function(u,i,o){var a=o.get,f=o.set,l=React.useRef(null),s=React.useState(function(){return a(i,u)}),v=s[0],g=s[1];return r("storage",function(t){var n=t.key,e=JSON.parse(t.newValue);n===i&&v!==e&&g(e);}),React.useEffect(function(){return l.current=c(i,g,u),function(){l.current.deregister();}},[]),React.useEffect(function(){f(i,v),l.current.emit(v);},[v]),[v,g]}(i,u,o)}}return React.useState} | ||
var emptyCacheStorage = function (version) { return __awaiter(_this, void 0, void 0, function () { | ||
var cacheKeys; | ||
return __generator(this, function (_a) { | ||
switch (_a.label) { | ||
case 0: | ||
if ('caches' in window) { | ||
// Service worker cache should be cleared with caches.delete() | ||
caches.keys().then(function (names) { | ||
// eslint-disable-next-line no-restricted-syntax | ||
for (var _i = 0, names_1 = names; _i < names_1.length; _i++) { | ||
var name_1 = names_1[_i]; | ||
caches.delete(name_1); | ||
} | ||
}); | ||
} | ||
// clear browser cache and reload page | ||
return [4 /*yield*/, setVersion(version || latestVersion).then(function () { | ||
return window.location.reload(true); | ||
})]; | ||
if (!('caches' in window)) return [3 /*break*/, 3]; | ||
return [4 /*yield*/, window.caches.keys()]; | ||
case 1: | ||
cacheKeys = _a.sent(); | ||
return [4 /*yield*/, Promise.all(cacheKeys.map(window.caches.delete))]; | ||
case 2: | ||
_a.sent(); | ||
_a.label = 3; | ||
case 3: | ||
// clear browser cache and reload page | ||
return [4 /*yield*/, setVersion(version || latestVersion)]; | ||
case 4: | ||
// clear browser cache and reload page | ||
_a.sent(); | ||
window.location.reload(true); | ||
return [2 /*return*/]; | ||
@@ -191,14 +190,16 @@ } | ||
}, [loading]); | ||
var onFocus = React.useRef(function () { }); | ||
var onBlur = React.useRef(function () { }); | ||
onFocus.current = function () { | ||
fetchCacheTimeout = setInterval(function () { return fetchMeta(); }, duration); | ||
var startVersionCheck = React.useRef(function () { }); | ||
var stopVersionCheck = React.useRef(function () { }); | ||
startVersionCheck.current = function () { | ||
if (window.navigator.onLine) { | ||
fetchCacheTimeout = setInterval(function () { return fetchMeta(); }, duration); | ||
} | ||
}; | ||
onBlur.current = function () { | ||
stopVersionCheck.current = function () { | ||
clearInterval(fetchCacheTimeout); | ||
}; | ||
React.useEffect(function () { | ||
window.addEventListener('focus', onFocus.current); | ||
window.addEventListener('blur', onBlur.current); | ||
}); | ||
window.addEventListener('focus', startVersionCheck.current); | ||
window.addEventListener('blur', stopVersionCheck.current); | ||
}, []); | ||
React.useEffect(function () { | ||
@@ -205,0 +206,0 @@ fetchMeta(); |
{ | ||
"name": "react-clear-cache", | ||
"version": "1.4.10", | ||
"version": "1.4.11", | ||
"description": "A component to manage application updates.", | ||
@@ -5,0 +5,0 @@ "author": "noahjohn9259", |
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
License Policy Violation
LicenseThis package is not allowed per your license policy. Review the package's license to ensure compliance.
Found 1 instance in 1 package
License Policy Violation
LicenseThis package is not allowed per your license policy. Review the package's license to ensure compliance.
Found 1 instance in 1 package
485
86308