workbox-broadcast-update
Advanced tools
Comparing version
"use strict"; | ||
// @ts-ignore | ||
try { | ||
self['workbox:broadcast-update:6.2.4'] && _(); | ||
self['workbox:broadcast-update:6.3.0'] && _(); | ||
} | ||
catch (e) { } |
@@ -9,3 +9,3 @@ /* | ||
import { dontWaitFor } from 'workbox-core/_private/dontWaitFor.js'; | ||
import { BroadcastCacheUpdate } from './BroadcastCacheUpdate.js'; | ||
import { BroadcastCacheUpdate, } from './BroadcastCacheUpdate.js'; | ||
import './_version.js'; | ||
@@ -12,0 +12,0 @@ /** |
@@ -6,3 +6,3 @@ this.workbox = this.workbox || {}; | ||
try { | ||
self['workbox:broadcast-update:6.2.4'] && _(); | ||
self['workbox:broadcast-update:6.3.0'] && _(); | ||
} catch (e) {} | ||
@@ -9,0 +9,0 @@ |
@@ -1,2 +0,2 @@ | ||
this.workbox=this.workbox||{},this.workbox.broadcastUpdate=function(t,s,a,e){"use strict";try{self["workbox:broadcast-update:6.2.4"]&&_()}catch(t){}const n=(t,s,a)=>!a.some((a=>t.headers.has(a)&&s.headers.has(a)))||a.every((a=>{const e=t.headers.has(a)===s.headers.has(a),n=t.headers.get(a)===s.headers.get(a);return e&&n})),i=["content-length","etag","last-modified"],o=/^((?!chrome|android).)*safari/i.test(navigator.userAgent);function c(t){return{cacheName:t.cacheName,updatedURL:t.request.url}}class r{constructor({generatePayload:t,headersToCheck:s,notifyAllClients:a}={}){this.C=s||i,this.A=t||c,this.U=null==a||a}async notifyIfUpdated(t){if(t.oldResponse&&!n(t.oldResponse,t.newResponse,this.C)){const e={type:"CACHE_UPDATED",meta:"workbox-broadcast-update",payload:this.A(t)};if("navigate"===t.request.mode){let e;t.event instanceof FetchEvent&&(e=t.event.resultingClientId);await a.resultingClientExists(e)&&!o||await s.timeout(3500)}if(this.U){const t=await self.clients.matchAll({type:"window"});for(const s of t)s.postMessage(e)}else if(t.event instanceof FetchEvent){const s=await self.clients.get(t.event.clientId);null==s||s.postMessage(e)}}}}return t.BroadcastCacheUpdate=r,t.BroadcastUpdatePlugin=class{constructor(t){this.cacheDidUpdate=async t=>{e.dontWaitFor(this.F.notifyIfUpdated(t))},this.F=new r(t)}},t.responsesAreSame=n,t}({},workbox.core._private,workbox.core._private,workbox.core._private); | ||
this.workbox=this.workbox||{},this.workbox.broadcastUpdate=function(t,s,a,e){"use strict";try{self["workbox:broadcast-update:6.3.0"]&&_()}catch(t){}const n=(t,s,a)=>!a.some((a=>t.headers.has(a)&&s.headers.has(a)))||a.every((a=>{const e=t.headers.has(a)===s.headers.has(a),n=t.headers.get(a)===s.headers.get(a);return e&&n})),i=["content-length","etag","last-modified"],o=/^((?!chrome|android).)*safari/i.test(navigator.userAgent);function c(t){return{cacheName:t.cacheName,updatedURL:t.request.url}}class r{constructor({generatePayload:t,headersToCheck:s,notifyAllClients:a}={}){this.C=s||i,this.A=t||c,this.U=null==a||a}async notifyIfUpdated(t){if(t.oldResponse&&!n(t.oldResponse,t.newResponse,this.C)){const e={type:"CACHE_UPDATED",meta:"workbox-broadcast-update",payload:this.A(t)};if("navigate"===t.request.mode){let e;t.event instanceof FetchEvent&&(e=t.event.resultingClientId);await a.resultingClientExists(e)&&!o||await s.timeout(3500)}if(this.U){const t=await self.clients.matchAll({type:"window"});for(const s of t)s.postMessage(e)}else if(t.event instanceof FetchEvent){const s=await self.clients.get(t.event.clientId);null==s||s.postMessage(e)}}}}return t.BroadcastCacheUpdate=r,t.BroadcastUpdatePlugin=class{constructor(t){this.cacheDidUpdate=async t=>{e.dontWaitFor(this.F.notifyIfUpdated(t))},this.F=new r(t)}},t.responsesAreSame=n,t}({},workbox.core._private,workbox.core._private,workbox.core._private); | ||
//# sourceMappingURL=workbox-broadcast-update.prod.js.map |
@@ -8,2 +8,2 @@ import { BroadcastCacheUpdate } from './BroadcastCacheUpdate.js'; | ||
*/ | ||
export { BroadcastCacheUpdate, BroadcastUpdatePlugin, responsesAreSame, }; | ||
export { BroadcastCacheUpdate, BroadcastUpdatePlugin, responsesAreSame }; |
@@ -15,2 +15,2 @@ /* | ||
*/ | ||
export { BroadcastCacheUpdate, BroadcastUpdatePlugin, responsesAreSame, }; | ||
export { BroadcastCacheUpdate, BroadcastUpdatePlugin, responsesAreSame }; |
{ | ||
"name": "workbox-broadcast-update", | ||
"version": "6.3.0", | ||
"version": "6.4.0", | ||
"license": "MIT", | ||
@@ -25,5 +25,5 @@ "author": "Google's Web DevRel Team", | ||
"dependencies": { | ||
"workbox-core": "6.3.0" | ||
"workbox-core": "6.4.0" | ||
}, | ||
"gitHead": "03055e64014a46f6cc977a3a50ad814c6409d36a" | ||
"gitHead": "cdad230c678a3626c217615d5792eb0f1c77194c" | ||
} |
@@ -24,4 +24,3 @@ /* | ||
if (process.env.NODE_ENV !== 'production') { | ||
if (!(firstResponse instanceof Response && | ||
secondResponse instanceof Response)) { | ||
if (!(firstResponse instanceof Response && secondResponse instanceof Response)) { | ||
throw new WorkboxError('invalid-responses-are-same-args'); | ||
@@ -31,4 +30,3 @@ } | ||
const atLeastOneHeaderAvailable = headersToCheck.some((header) => { | ||
return firstResponse.headers.has(header) && | ||
secondResponse.headers.has(header); | ||
return (firstResponse.headers.has(header) && secondResponse.headers.has(header)); | ||
}); | ||
@@ -46,6 +44,4 @@ if (!atLeastOneHeaderAvailable) { | ||
return headersToCheck.every((header) => { | ||
const headerStateComparison = firstResponse.headers.has(header) === | ||
secondResponse.headers.has(header); | ||
const headerValueComparison = firstResponse.headers.get(header) === | ||
secondResponse.headers.get(header); | ||
const headerStateComparison = firstResponse.headers.has(header) === secondResponse.headers.has(header); | ||
const headerValueComparison = firstResponse.headers.get(header) === secondResponse.headers.get(header); | ||
return headerStateComparison && headerValueComparison; | ||
@@ -52,0 +48,0 @@ }); |
// @ts-ignore | ||
try{self['workbox:broadcast-update:6.3.0']&&_()}catch(e){} | ||
try{self['workbox:broadcast-update:6.4.0']&&_()}catch(e){} |
@@ -12,3 +12,6 @@ /* | ||
import {BroadcastCacheUpdate, BroadcastCacheUpdateOptions} from './BroadcastCacheUpdate.js'; | ||
import { | ||
BroadcastCacheUpdate, | ||
BroadcastCacheUpdateOptions, | ||
} from './BroadcastCacheUpdate.js'; | ||
@@ -58,5 +61,5 @@ import './_version.js'; | ||
dontWaitFor(this._broadcastUpdate.notifyIfUpdated(options)); | ||
} | ||
}; | ||
} | ||
export {BroadcastUpdatePlugin}; |
@@ -14,3 +14,2 @@ /* | ||
/** | ||
@@ -20,6 +19,2 @@ * @module workbox-broadcast-update | ||
export { | ||
BroadcastCacheUpdate, | ||
BroadcastUpdatePlugin, | ||
responsesAreSame, | ||
}; | ||
export {BroadcastCacheUpdate, BroadcastUpdatePlugin, responsesAreSame}; |
@@ -13,3 +13,2 @@ /* | ||
/** | ||
@@ -32,4 +31,5 @@ * Given two `Response's`, compares several header values to see if they are | ||
if (process.env.NODE_ENV !== 'production') { | ||
if (!(firstResponse instanceof Response && | ||
secondResponse instanceof Response)) { | ||
if ( | ||
!(firstResponse instanceof Response && secondResponse instanceof Response) | ||
) { | ||
throw new WorkboxError('invalid-responses-are-same-args'); | ||
@@ -40,4 +40,5 @@ } | ||
const atLeastOneHeaderAvailable = headersToCheck.some((header) => { | ||
return firstResponse.headers.has(header) && | ||
secondResponse.headers.has(header); | ||
return ( | ||
firstResponse.headers.has(header) && secondResponse.headers.has(header) | ||
); | ||
}); | ||
@@ -47,6 +48,12 @@ | ||
if (process.env.NODE_ENV !== 'production') { | ||
logger.warn(`Unable to determine where the response has been updated ` + | ||
`because none of the headers that would be checked are present.`); | ||
logger.debug(`Attempting to compare the following: `, | ||
firstResponse, secondResponse, headersToCheck); | ||
logger.warn( | ||
`Unable to determine where the response has been updated ` + | ||
`because none of the headers that would be checked are present.`, | ||
); | ||
logger.debug( | ||
`Attempting to compare the following: `, | ||
firstResponse, | ||
secondResponse, | ||
headersToCheck, | ||
); | ||
} | ||
@@ -60,6 +67,6 @@ | ||
return headersToCheck.every((header) => { | ||
const headerStateComparison = firstResponse.headers.has(header) === | ||
secondResponse.headers.has(header); | ||
const headerValueComparison = firstResponse.headers.get(header) === | ||
secondResponse.headers.get(header); | ||
const headerStateComparison = | ||
firstResponse.headers.has(header) === secondResponse.headers.has(header); | ||
const headerValueComparison = | ||
firstResponse.headers.get(header) === secondResponse.headers.get(header); | ||
@@ -66,0 +73,0 @@ return headerStateComparison && headerValueComparison; |
@@ -8,8 +8,4 @@ { | ||
}, | ||
"include": [ | ||
"src/**/*.ts" | ||
], | ||
"references": [ | ||
{ "path": "../workbox-core/" } | ||
] | ||
"include": ["src/**/*.ts"], | ||
"references": [{"path": "../workbox-core/"}] | ||
} |
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
103769
-44.58%1058
-0.09%+ Added
- Removed
Updated