workbox-core
Advanced tools
Comparing version 6.3.0 to 6.4.0
@@ -45,4 +45,3 @@ /* | ||
if (!validValues.includes(value)) { | ||
details['validValueDescription'] = | ||
`Valid values are ${JSON.stringify(validValues)}.`; | ||
details['validValueDescription'] = `Valid values are ${JSON.stringify(validValues)}.`; | ||
throw new WorkboxError('invalid-value', details); | ||
@@ -65,10 +64,12 @@ } | ||
}; | ||
const finalAssertExports = process.env.NODE_ENV === 'production' ? null : { | ||
hasMethod, | ||
isArray, | ||
isInstance, | ||
isOneOf, | ||
isType, | ||
isArrayOfClass, | ||
}; | ||
const finalAssertExports = process.env.NODE_ENV === 'production' | ||
? null | ||
: { | ||
hasMethod, | ||
isArray, | ||
isInstance, | ||
isOneOf, | ||
isType, | ||
isArrayOfClass, | ||
}; | ||
export { finalAssertExports as assert }; |
@@ -8,57 +8,59 @@ /* | ||
import '../_version.js'; | ||
const logger = (process.env.NODE_ENV === 'production' ? null : (() => { | ||
// Don't overwrite this value if it's already set. | ||
// See https://github.com/GoogleChrome/workbox/pull/2284#issuecomment-560470923 | ||
if (!('__WB_DISABLE_DEV_LOGS' in self)) { | ||
self.__WB_DISABLE_DEV_LOGS = false; | ||
} | ||
let inGroup = false; | ||
const methodToColorMap = { | ||
debug: `#7f8c8d`, | ||
log: `#2ecc71`, | ||
warn: `#f39c12`, | ||
error: `#c0392b`, | ||
groupCollapsed: `#3498db`, | ||
groupEnd: null, | ||
}; | ||
const print = function (method, args) { | ||
if (self.__WB_DISABLE_DEV_LOGS) { | ||
return; | ||
const logger = (process.env.NODE_ENV === 'production' | ||
? null | ||
: (() => { | ||
// Don't overwrite this value if it's already set. | ||
// See https://github.com/GoogleChrome/workbox/pull/2284#issuecomment-560470923 | ||
if (!('__WB_DISABLE_DEV_LOGS' in self)) { | ||
self.__WB_DISABLE_DEV_LOGS = false; | ||
} | ||
if (method === 'groupCollapsed') { | ||
// Safari doesn't print all console.groupCollapsed() arguments: | ||
// https://bugs.webkit.org/show_bug.cgi?id=182754 | ||
if (/^((?!chrome|android).)*safari/i.test(navigator.userAgent)) { | ||
console[method](...args); | ||
let inGroup = false; | ||
const methodToColorMap = { | ||
debug: `#7f8c8d`, | ||
log: `#2ecc71`, | ||
warn: `#f39c12`, | ||
error: `#c0392b`, | ||
groupCollapsed: `#3498db`, | ||
groupEnd: null, // No colored prefix on groupEnd | ||
}; | ||
const print = function (method, args) { | ||
if (self.__WB_DISABLE_DEV_LOGS) { | ||
return; | ||
} | ||
if (method === 'groupCollapsed') { | ||
// Safari doesn't print all console.groupCollapsed() arguments: | ||
// https://bugs.webkit.org/show_bug.cgi?id=182754 | ||
if (/^((?!chrome|android).)*safari/i.test(navigator.userAgent)) { | ||
console[method](...args); | ||
return; | ||
} | ||
} | ||
const styles = [ | ||
`background: ${methodToColorMap[method]}`, | ||
`border-radius: 0.5em`, | ||
`color: white`, | ||
`font-weight: bold`, | ||
`padding: 2px 0.5em`, | ||
]; | ||
// When in a group, the workbox prefix is not displayed. | ||
const logPrefix = inGroup ? [] : ['%cworkbox', styles.join(';')]; | ||
console[method](...logPrefix, ...args); | ||
if (method === 'groupCollapsed') { | ||
inGroup = true; | ||
} | ||
if (method === 'groupEnd') { | ||
inGroup = false; | ||
} | ||
}; | ||
// eslint-disable-next-line @typescript-eslint/ban-types | ||
const api = {}; | ||
const loggerMethods = Object.keys(methodToColorMap); | ||
for (const key of loggerMethods) { | ||
const method = key; | ||
api[method] = (...args) => { | ||
print(method, args); | ||
}; | ||
} | ||
const styles = [ | ||
`background: ${methodToColorMap[method]}`, | ||
`border-radius: 0.5em`, | ||
`color: white`, | ||
`font-weight: bold`, | ||
`padding: 2px 0.5em`, | ||
]; | ||
// When in a group, the workbox prefix is not displayed. | ||
const logPrefix = inGroup ? [] : ['%cworkbox', styles.join(';')]; | ||
console[method](...logPrefix, ...args); | ||
if (method === 'groupCollapsed') { | ||
inGroup = true; | ||
} | ||
if (method === 'groupEnd') { | ||
inGroup = false; | ||
} | ||
}; | ||
// eslint-disable-next-line @typescript-eslint/ban-types | ||
const api = {}; | ||
const loggerMethods = Object.keys(methodToColorMap); | ||
for (const key of loggerMethods) { | ||
const method = key; | ||
api[method] = (...args) => { | ||
print(method, args); | ||
}; | ||
} | ||
return api; | ||
})()); | ||
return api; | ||
})()); | ||
export { logger }; |
"use strict"; | ||
// @ts-ignore | ||
try { | ||
self['workbox:core:6.2.4'] && _(); | ||
self['workbox:core:6.3.0'] && _(); | ||
} | ||
catch (e) { } |
@@ -6,3 +6,3 @@ this.workbox = this.workbox || {}; | ||
try { | ||
self['workbox:core:6.2.4'] && _(); | ||
self['workbox:core:6.3.0'] && _(); | ||
} catch (e) {} | ||
@@ -30,3 +30,4 @@ | ||
groupCollapsed: `#3498db`, | ||
groupEnd: null | ||
groupEnd: null // No colored prefix on groupEnd | ||
}; | ||
@@ -33,0 +34,0 @@ |
@@ -1,2 +0,2 @@ | ||
this.workbox=this.workbox||{},this.workbox.core=function(t){"use strict";try{self["workbox:core:6.2.4"]&&_()}catch(t){}const e=(t,...e)=>{let n=t;return e.length>0&&(n+=" :: "+JSON.stringify(e)),n};class n extends Error{constructor(t,n){super(e(t,n)),this.name=t,this.details=n}}const r=new Set;const o={googleAnalytics:"googleAnalytics",precache:"precache-v2",prefix:"workbox",runtime:"runtime",suffix:"undefined"!=typeof registration?registration.scope:""},s=t=>[o.prefix,t,o.suffix].filter((t=>t&&t.length>0)).join("-"),i={updateDetails:t=>{(t=>{for(const e of Object.keys(o))t(e)})((e=>{"string"==typeof t[e]&&(o[e]=t[e])}))},getGoogleAnalyticsName:t=>t||s(o.googleAnalytics),getPrecacheName:t=>t||s(o.precache),getPrefix:()=>o.prefix,getRuntimeName:t=>t||s(o.runtime),getSuffix:()=>o.suffix};function c(t,e){const n=new URL(t);for(const t of e)n.searchParams.delete(t);return n.href}let a,u;function f(){if(void 0===u){const t=new Response("");if("body"in t)try{new Response(t.body),u=!0}catch(t){u=!1}u=!1}return u}function l(t){return new Promise((e=>setTimeout(e,t)))}var g=Object.freeze({__proto__:null,assert:null,cacheMatchIgnoreParams:async function(t,e,n,r){const o=c(e.url,n);if(e.url===o)return t.match(e,r);const s=Object.assign(Object.assign({},r),{ignoreSearch:!0}),i=await t.keys(e,s);for(const e of i){if(o===c(e.url,n))return t.match(e,r)}},cacheNames:i,canConstructReadableStream:function(){if(void 0===a)try{new ReadableStream({start(){}}),a=!0}catch(t){a=!1}return a},canConstructResponseFromBodyStream:f,dontWaitFor:function(t){t.then((()=>{}))},Deferred:class{constructor(){this.promise=new Promise(((t,e)=>{this.resolve=t,this.reject=e}))}},executeQuotaErrorCallbacks:async function(){for(const t of r)await t()},getFriendlyURL:t=>new URL(String(t),location.href).href.replace(new RegExp("^"+location.origin),""),logger:null,resultingClientExists:async function(t){if(!t)return;let e=await self.clients.matchAll({type:"window"});const n=new Set(e.map((t=>t.id)));let r;const o=performance.now();for(;performance.now()-o<2e3&&(e=await self.clients.matchAll({type:"window"}),r=e.find((e=>t?e.id===t:!n.has(e.id))),!r);)await l(100);return r},timeout:l,waitUntil:function(t,e){const n=e();return t.waitUntil(n),n},WorkboxError:n});const w={get googleAnalytics(){return i.getGoogleAnalyticsName()},get precache(){return i.getPrecacheName()},get prefix(){return i.getPrefix()},get runtime(){return i.getRuntimeName()},get suffix(){return i.getSuffix()}};return t._private=g,t.cacheNames=w,t.clientsClaim=function(){self.addEventListener("activate",(()=>self.clients.claim()))},t.copyResponse=async function(t,e){let r=null;if(t.url){r=new URL(t.url).origin}if(r!==self.location.origin)throw new n("cross-origin-copy-response",{origin:r});const o=t.clone(),s={headers:new Headers(o.headers),status:o.status,statusText:o.statusText},i=e?e(s):s,c=f()?o.body:await o.blob();return new Response(c,i)},t.registerQuotaErrorCallback=function(t){r.add(t)},t.setCacheNameDetails=function(t){i.updateDetails(t)},t.skipWaiting=function(){self.skipWaiting()},t}({}); | ||
this.workbox=this.workbox||{},this.workbox.core=function(t){"use strict";try{self["workbox:core:6.3.0"]&&_()}catch(t){}const e=(t,...e)=>{let n=t;return e.length>0&&(n+=" :: "+JSON.stringify(e)),n};class n extends Error{constructor(t,n){super(e(t,n)),this.name=t,this.details=n}}const r=new Set;const o={googleAnalytics:"googleAnalytics",precache:"precache-v2",prefix:"workbox",runtime:"runtime",suffix:"undefined"!=typeof registration?registration.scope:""},s=t=>[o.prefix,t,o.suffix].filter((t=>t&&t.length>0)).join("-"),i={updateDetails:t=>{(t=>{for(const e of Object.keys(o))t(e)})((e=>{"string"==typeof t[e]&&(o[e]=t[e])}))},getGoogleAnalyticsName:t=>t||s(o.googleAnalytics),getPrecacheName:t=>t||s(o.precache),getPrefix:()=>o.prefix,getRuntimeName:t=>t||s(o.runtime),getSuffix:()=>o.suffix};function c(t,e){const n=new URL(t);for(const t of e)n.searchParams.delete(t);return n.href}let a,u;function f(){if(void 0===u){const t=new Response("");if("body"in t)try{new Response(t.body),u=!0}catch(t){u=!1}u=!1}return u}function l(t){return new Promise((e=>setTimeout(e,t)))}var g=Object.freeze({__proto__:null,assert:null,cacheMatchIgnoreParams:async function(t,e,n,r){const o=c(e.url,n);if(e.url===o)return t.match(e,r);const s=Object.assign(Object.assign({},r),{ignoreSearch:!0}),i=await t.keys(e,s);for(const e of i){if(o===c(e.url,n))return t.match(e,r)}},cacheNames:i,canConstructReadableStream:function(){if(void 0===a)try{new ReadableStream({start(){}}),a=!0}catch(t){a=!1}return a},canConstructResponseFromBodyStream:f,dontWaitFor:function(t){t.then((()=>{}))},Deferred:class{constructor(){this.promise=new Promise(((t,e)=>{this.resolve=t,this.reject=e}))}},executeQuotaErrorCallbacks:async function(){for(const t of r)await t()},getFriendlyURL:t=>new URL(String(t),location.href).href.replace(new RegExp("^"+location.origin),""),logger:null,resultingClientExists:async function(t){if(!t)return;let e=await self.clients.matchAll({type:"window"});const n=new Set(e.map((t=>t.id)));let r;const o=performance.now();for(;performance.now()-o<2e3&&(e=await self.clients.matchAll({type:"window"}),r=e.find((e=>t?e.id===t:!n.has(e.id))),!r);)await l(100);return r},timeout:l,waitUntil:function(t,e){const n=e();return t.waitUntil(n),n},WorkboxError:n});const w={get googleAnalytics(){return i.getGoogleAnalyticsName()},get precache(){return i.getPrecacheName()},get prefix(){return i.getPrefix()},get runtime(){return i.getRuntimeName()},get suffix(){return i.getSuffix()}};return t._private=g,t.cacheNames=w,t.clientsClaim=function(){self.addEventListener("activate",(()=>self.clients.claim()))},t.copyResponse=async function(t,e){let r=null;if(t.url){r=new URL(t.url).origin}if(r!==self.location.origin)throw new n("cross-origin-copy-response",{origin:r});const o=t.clone(),s={headers:new Headers(o.headers),status:o.status,statusText:o.statusText},i=e?e(s):s,c=f()?o.body:await o.blob();return new Response(c,i)},t.registerQuotaErrorCallback=function(t){r.add(t)},t.setCacheNameDetails=function(t){i.updateDetails(t)},t.skipWaiting=function(){self.skipWaiting()},t}({}); | ||
//# sourceMappingURL=workbox-core.prod.js.map |
@@ -52,6 +52,7 @@ /* | ||
// so fall back to reading the entire body into memory as a blob. | ||
const body = canConstructResponseFromBodyStream() ? | ||
clonedResponse.body : await clonedResponse.blob(); | ||
const body = canConstructResponseFromBodyStream() | ||
? clonedResponse.body | ||
: await clonedResponse.blob(); | ||
return new Response(body, modifiedResponseInit); | ||
} | ||
export { copyResponse }; |
@@ -24,3 +24,2 @@ /* | ||
}; | ||
export const messageGenerator = (process.env.NODE_ENV === 'production') ? | ||
fallback : generatorFunction; | ||
export const messageGenerator = process.env.NODE_ENV === 'production' ? fallback : generatorFunction; |
@@ -14,5 +14,5 @@ /* | ||
} | ||
return `The '${paramName}' parameter was given a value with an ` + | ||
return (`The '${paramName}' parameter was given a value with an ` + | ||
`unexpected value. ${validValueDescription} Received a value of ` + | ||
`${JSON.stringify(value)}.`; | ||
`${JSON.stringify(value)}.`); | ||
}, | ||
@@ -23,6 +23,6 @@ 'not-an-array': ({ moduleName, className, funcName, paramName }) => { | ||
} | ||
return `The parameter '${paramName}' passed into ` + | ||
`'${moduleName}.${className}.${funcName}()' must be an array.`; | ||
return (`The parameter '${paramName}' passed into ` + | ||
`'${moduleName}.${className}.${funcName}()' must be an array.`); | ||
}, | ||
'incorrect-type': ({ expectedType, paramName, moduleName, className, funcName }) => { | ||
'incorrect-type': ({ expectedType, paramName, moduleName, className, funcName, }) => { | ||
if (!expectedType || !paramName || !moduleName || !funcName) { | ||
@@ -32,7 +32,7 @@ throw new Error(`Unexpected input to 'incorrect-type' error.`); | ||
const classNameStr = className ? `${className}.` : ''; | ||
return `The parameter '${paramName}' passed into ` + | ||
return (`The parameter '${paramName}' passed into ` + | ||
`'${moduleName}.${classNameStr}` + | ||
`${funcName}()' must be of type ${expectedType}.`; | ||
`${funcName}()' must be of type ${expectedType}.`); | ||
}, | ||
'incorrect-class': ({ expectedClassName, paramName, moduleName, className, funcName, isReturnValueProblem }) => { | ||
'incorrect-class': ({ expectedClassName, paramName, moduleName, className, funcName, isReturnValueProblem, }) => { | ||
if (!expectedClassName || !moduleName || !funcName) { | ||
@@ -43,43 +43,44 @@ throw new Error(`Unexpected input to 'incorrect-class' error.`); | ||
if (isReturnValueProblem) { | ||
return `The return value from ` + | ||
return (`The return value from ` + | ||
`'${moduleName}.${classNameStr}${funcName}()' ` + | ||
`must be an instance of class ${expectedClassName}.`; | ||
`must be an instance of class ${expectedClassName}.`); | ||
} | ||
return `The parameter '${paramName}' passed into ` + | ||
return (`The parameter '${paramName}' passed into ` + | ||
`'${moduleName}.${classNameStr}${funcName}()' ` + | ||
`must be an instance of class ${expectedClassName}.`; | ||
`must be an instance of class ${expectedClassName}.`); | ||
}, | ||
'missing-a-method': ({ expectedMethod, paramName, moduleName, className, funcName }) => { | ||
if (!expectedMethod || !paramName || !moduleName || !className | ||
|| !funcName) { | ||
'missing-a-method': ({ expectedMethod, paramName, moduleName, className, funcName, }) => { | ||
if (!expectedMethod || | ||
!paramName || | ||
!moduleName || | ||
!className || | ||
!funcName) { | ||
throw new Error(`Unexpected input to 'missing-a-method' error.`); | ||
} | ||
return `${moduleName}.${className}.${funcName}() expected the ` + | ||
`'${paramName}' parameter to expose a '${expectedMethod}' method.`; | ||
return (`${moduleName}.${className}.${funcName}() expected the ` + | ||
`'${paramName}' parameter to expose a '${expectedMethod}' method.`); | ||
}, | ||
'add-to-cache-list-unexpected-type': ({ entry }) => { | ||
return `An unexpected entry was passed to ` + | ||
return (`An unexpected entry was passed to ` + | ||
`'workbox-precaching.PrecacheController.addToCacheList()' The entry ` + | ||
`'${JSON.stringify(entry)}' isn't supported. You must supply an array of ` + | ||
`strings with one or more characters, objects with a url property or ` + | ||
`Request objects.`; | ||
`Request objects.`); | ||
}, | ||
'add-to-cache-list-conflicting-entries': ({ firstEntry, secondEntry }) => { | ||
if (!firstEntry || !secondEntry) { | ||
throw new Error(`Unexpected input to ` + | ||
`'add-to-cache-list-duplicate-entries' error.`); | ||
throw new Error(`Unexpected input to ` + `'add-to-cache-list-duplicate-entries' error.`); | ||
} | ||
return `Two of the entries passed to ` + | ||
return (`Two of the entries passed to ` + | ||
`'workbox-precaching.PrecacheController.addToCacheList()' had the URL ` + | ||
`${firstEntry} but different revision details. Workbox is ` + | ||
`unable to cache and version the asset correctly. Please remove one ` + | ||
`of the entries.`; | ||
`of the entries.`); | ||
}, | ||
'plugin-error-request-will-fetch': ({ thrownErrorMessage }) => { | ||
if (!thrownErrorMessage) { | ||
throw new Error(`Unexpected input to ` + | ||
`'plugin-error-request-will-fetch', error.`); | ||
throw new Error(`Unexpected input to ` + `'plugin-error-request-will-fetch', error.`); | ||
} | ||
return `An error was thrown by a plugins 'requestWillFetch()' method. ` + | ||
`The thrown error message was: '${thrownErrorMessage}'.`; | ||
return (`An error was thrown by a plugins 'requestWillFetch()' method. ` + | ||
`The thrown error message was: '${thrownErrorMessage}'.`); | ||
}, | ||
@@ -90,5 +91,5 @@ 'invalid-cache-name': ({ cacheNameId, value }) => { | ||
} | ||
return `You must provide a name containing at least one character for ` + | ||
return (`You must provide a name containing at least one character for ` + | ||
`setCacheDetails({${cacheNameId}: '...'}). Received a value of ` + | ||
`'${JSON.stringify(value)}'`; | ||
`'${JSON.stringify(value)}'`); | ||
}, | ||
@@ -100,8 +101,8 @@ 'unregister-route-but-not-found-with-method': ({ method }) => { | ||
} | ||
return `The route you're trying to unregister was not previously ` + | ||
`registered for the method type '${method}'.`; | ||
return (`The route you're trying to unregister was not previously ` + | ||
`registered for the method type '${method}'.`); | ||
}, | ||
'unregister-route-route-not-registered': () => { | ||
return `The route you're trying to unregister was not previously ` + | ||
`registered.`; | ||
return (`The route you're trying to unregister was not previously ` + | ||
`registered.`); | ||
}, | ||
@@ -112,27 +113,27 @@ 'queue-replay-failed': ({ name }) => { | ||
'duplicate-queue-name': ({ name }) => { | ||
return `The Queue name '${name}' is already being used. ` + | ||
`All instances of backgroundSync.Queue must be given unique names.`; | ||
return (`The Queue name '${name}' is already being used. ` + | ||
`All instances of backgroundSync.Queue must be given unique names.`); | ||
}, | ||
'expired-test-without-max-age': ({ methodName, paramName }) => { | ||
return `The '${methodName}()' method can only be used when the ` + | ||
`'${paramName}' is used in the constructor.`; | ||
return (`The '${methodName}()' method can only be used when the ` + | ||
`'${paramName}' is used in the constructor.`); | ||
}, | ||
'unsupported-route-type': ({ moduleName, className, funcName, paramName }) => { | ||
return `The supplied '${paramName}' parameter was an unsupported type. ` + | ||
return (`The supplied '${paramName}' parameter was an unsupported type. ` + | ||
`Please check the docs for ${moduleName}.${className}.${funcName} for ` + | ||
`valid input types.`; | ||
`valid input types.`); | ||
}, | ||
'not-array-of-class': ({ value, expectedClass, moduleName, className, funcName, paramName }) => { | ||
return `The supplied '${paramName}' parameter must be an array of ` + | ||
'not-array-of-class': ({ value, expectedClass, moduleName, className, funcName, paramName, }) => { | ||
return (`The supplied '${paramName}' parameter must be an array of ` + | ||
`'${expectedClass}' objects. Received '${JSON.stringify(value)},'. ` + | ||
`Please check the call to ${moduleName}.${className}.${funcName}() ` + | ||
`to fix the issue.`; | ||
`to fix the issue.`); | ||
}, | ||
'max-entries-or-age-required': ({ moduleName, className, funcName }) => { | ||
return `You must define either config.maxEntries or config.maxAgeSeconds` + | ||
`in ${moduleName}.${className}.${funcName}`; | ||
return (`You must define either config.maxEntries or config.maxAgeSeconds` + | ||
`in ${moduleName}.${className}.${funcName}`); | ||
}, | ||
'statuses-or-headers-required': ({ moduleName, className, funcName }) => { | ||
return `You must define either config.statuses or config.headers` + | ||
`in ${moduleName}.${className}.${funcName}`; | ||
return (`You must define either config.statuses or config.headers` + | ||
`in ${moduleName}.${className}.${funcName}`); | ||
}, | ||
@@ -143,18 +144,18 @@ 'invalid-string': ({ moduleName, funcName, paramName }) => { | ||
} | ||
return `When using strings, the '${paramName}' parameter must start with ` + | ||
return (`When using strings, the '${paramName}' parameter must start with ` + | ||
`'http' (for cross-origin matches) or '/' (for same-origin matches). ` + | ||
`Please see the docs for ${moduleName}.${funcName}() for ` + | ||
`more info.`; | ||
`more info.`); | ||
}, | ||
'channel-name-required': () => { | ||
return `You must provide a channelName to construct a ` + | ||
`BroadcastCacheUpdate instance.`; | ||
return (`You must provide a channelName to construct a ` + | ||
`BroadcastCacheUpdate instance.`); | ||
}, | ||
'invalid-responses-are-same-args': () => { | ||
return `The arguments passed into responsesAreSame() appear to be ` + | ||
`invalid. Please ensure valid Responses are used.`; | ||
return (`The arguments passed into responsesAreSame() appear to be ` + | ||
`invalid. Please ensure valid Responses are used.`); | ||
}, | ||
'expire-custom-caches-only': () => { | ||
return `You must provide a 'cacheName' property when using the ` + | ||
`expiration plugin with a runtime caching strategy.`; | ||
return (`You must provide a 'cacheName' property when using the ` + | ||
`expiration plugin with a runtime caching strategy.`); | ||
}, | ||
@@ -165,4 +166,4 @@ 'unit-must-be-bytes': ({ normalizedRangeHeader }) => { | ||
} | ||
return `The 'unit' portion of the Range header must be set to 'bytes'. ` + | ||
`The Range header provided was "${normalizedRangeHeader}"`; | ||
return (`The 'unit' portion of the Range header must be set to 'bytes'. ` + | ||
`The Range header provided was "${normalizedRangeHeader}"`); | ||
}, | ||
@@ -173,5 +174,5 @@ 'single-range-only': ({ normalizedRangeHeader }) => { | ||
} | ||
return `Multiple ranges are not supported. Please use a single start ` + | ||
return (`Multiple ranges are not supported. Please use a single start ` + | ||
`value, and optional end value. The Range header provided was ` + | ||
`"${normalizedRangeHeader}"`; | ||
`"${normalizedRangeHeader}"`); | ||
}, | ||
@@ -182,5 +183,5 @@ 'invalid-range-values': ({ normalizedRangeHeader }) => { | ||
} | ||
return `The Range header is missing both start and end values. At least ` + | ||
return (`The Range header is missing both start and end values. At least ` + | ||
`one of those values is needed. The Range header provided was ` + | ||
`"${normalizedRangeHeader}"`; | ||
`"${normalizedRangeHeader}"`); | ||
}, | ||
@@ -191,12 +192,12 @@ 'no-range-header': () => { | ||
'range-not-satisfiable': ({ size, start, end }) => { | ||
return `The start (${start}) and end (${end}) values in the Range are ` + | ||
`not satisfiable by the cached response, which is ${size} bytes.`; | ||
return (`The start (${start}) and end (${end}) values in the Range are ` + | ||
`not satisfiable by the cached response, which is ${size} bytes.`); | ||
}, | ||
'attempt-to-cache-non-get-request': ({ url, method }) => { | ||
return `Unable to cache '${url}' because it is a '${method}' request and ` + | ||
`only 'GET' requests can be cached.`; | ||
return (`Unable to cache '${url}' because it is a '${method}' request and ` + | ||
`only 'GET' requests can be cached.`); | ||
}, | ||
'cache-put-with-no-response': ({ url }) => { | ||
return `There was an attempt to cache '${url}' but the response was not ` + | ||
`defined.`; | ||
return (`There was an attempt to cache '${url}' but the response was not ` + | ||
`defined.`); | ||
}, | ||
@@ -211,13 +212,13 @@ 'no-response': ({ url, error }) => { | ||
'bad-precaching-response': ({ url, status }) => { | ||
return `The precaching request for '${url}' failed` + | ||
(status ? ` with an HTTP status of ${status}.` : `.`); | ||
return (`The precaching request for '${url}' failed` + | ||
(status ? ` with an HTTP status of ${status}.` : `.`)); | ||
}, | ||
'non-precached-url': ({ url }) => { | ||
return `createHandlerBoundToURL('${url}') was called, but that URL is ` + | ||
`not precached. Please pass in a URL that is precached instead.`; | ||
return (`createHandlerBoundToURL('${url}') was called, but that URL is ` + | ||
`not precached. Please pass in a URL that is precached instead.`); | ||
}, | ||
'add-to-cache-list-conflicting-integrities': ({ url }) => { | ||
return `Two of the entries passed to ` + | ||
return (`Two of the entries passed to ` + | ||
`'workbox-precaching.PrecacheController.addToCacheList()' had the URL ` + | ||
`${url} with different integrity values. Please remove one of them.`; | ||
`${url} with different integrity values. Please remove one of them.`); | ||
}, | ||
@@ -228,5 +229,5 @@ 'missing-precache-entry': ({ cacheName, url }) => { | ||
'cross-origin-copy-response': ({ origin }) => { | ||
return `workbox-core.copyResponse() can only be used with same-origin ` + | ||
`responses. It was passed a response with origin ${origin}.`; | ||
return (`workbox-core.copyResponse() can only be used with same-origin ` + | ||
`responses. It was passed a response with origin ${origin}.`); | ||
}, | ||
}; |
{ | ||
"name": "workbox-core", | ||
"version": "6.3.0", | ||
"version": "6.4.0", | ||
"license": "MIT", | ||
@@ -23,3 +23,3 @@ "author": "Google's Web DevRel Team", | ||
"types": "index.d.ts", | ||
"gitHead": "03055e64014a46f6cc977a3a50ad814c6409d36a" | ||
"gitHead": "cdad230c678a3626c217615d5792eb0f1c77194c" | ||
} |
@@ -50,3 +50,4 @@ /* | ||
} | ||
if ('googleAnalytics' in details && details['googleAnalytics'].length === 0) { | ||
if ('googleAnalytics' in details && | ||
details['googleAnalytics'].length === 0) { | ||
throw new WorkboxError('invalid-cache-name', { | ||
@@ -53,0 +54,0 @@ cacheNameId: 'googleAnalytics', |
@@ -19,6 +19,3 @@ /* | ||
*/ | ||
const isArray = ( | ||
value: any[], | ||
details: MapLikeObject, | ||
) => { | ||
const isArray = (value: any[], details: MapLikeObject) => { | ||
if (!Array.isArray(value)) { | ||
@@ -65,9 +62,7 @@ throw new WorkboxError('not-an-array', details); | ||
const isOneOf = ( | ||
value: any, | ||
validValues: any[], | ||
details: MapLikeObject) => { | ||
const isOneOf = (value: any, validValues: any[], details: MapLikeObject) => { | ||
if (!validValues.includes(value)) { | ||
details['validValueDescription'] = | ||
`Valid values are ${JSON.stringify(validValues)}.` | ||
details['validValueDescription'] = `Valid values are ${JSON.stringify( | ||
validValues, | ||
)}.`; | ||
throw new WorkboxError('invalid-value', details); | ||
@@ -95,11 +90,14 @@ } | ||
const finalAssertExports = process.env.NODE_ENV === 'production' ? null : { | ||
hasMethod, | ||
isArray, | ||
isInstance, | ||
isOneOf, | ||
isType, | ||
isArrayOfClass, | ||
}; | ||
const finalAssertExports = | ||
process.env.NODE_ENV === 'production' | ||
? null | ||
: { | ||
hasMethod, | ||
isArray, | ||
isInstance, | ||
isOneOf, | ||
isType, | ||
isArrayOfClass, | ||
}; | ||
export {finalAssertExports as assert}; |
@@ -10,3 +10,2 @@ /* | ||
function stripParams(fullURL: string, ignoreParams: string[]) { | ||
@@ -20,3 +19,2 @@ const strippedURL = new URL(fullURL); | ||
/** | ||
@@ -23,0 +21,0 @@ * Matches an item in the cache, ignoring specific URL params. This is similar |
@@ -11,5 +11,4 @@ /* | ||
declare let registration: ServiceWorkerRegistration | undefined; | ||
declare let registration: ServiceWorkerRegistration|undefined; | ||
export interface CacheNameDetails { | ||
@@ -28,5 +27,8 @@ googleAnalytics: string; | ||
export type CacheNameDetailsProp = | ||
'googleAnalytics' | 'precache' | 'prefix' | 'runtime' | 'suffix'; | ||
| 'googleAnalytics' | ||
| 'precache' | ||
| 'prefix' | ||
| 'runtime' | ||
| 'suffix'; | ||
const _cacheNameDetails: CacheNameDetails = { | ||
@@ -42,4 +44,4 @@ googleAnalytics: 'googleAnalytics', | ||
return [_cacheNameDetails.prefix, cacheName, _cacheNameDetails.suffix] | ||
.filter((value) => value && value.length > 0) | ||
.join('-'); | ||
.filter((value) => value && value.length > 0) | ||
.join('-'); | ||
}; | ||
@@ -51,3 +53,3 @@ | ||
} | ||
} | ||
}; | ||
@@ -60,3 +62,3 @@ export const cacheNames = { | ||
} | ||
}) | ||
}); | ||
}, | ||
@@ -63,0 +65,0 @@ getGoogleAnalyticsName: (userCacheName?: string): string => { |
@@ -11,3 +11,2 @@ /* | ||
let supportStatus: boolean | undefined; | ||
@@ -14,0 +13,0 @@ |
@@ -11,3 +11,2 @@ /* | ||
let supportStatus: boolean | undefined; | ||
@@ -14,0 +13,0 @@ |
@@ -11,3 +11,2 @@ /* | ||
/** | ||
@@ -37,3 +36,2 @@ * The Deferred class composes Promises in a way that allows for them to be | ||
export {Deferred}; |
@@ -17,3 +17,3 @@ /* | ||
// Effective no-op. | ||
void promise.then(() => { }); | ||
void promise.then(() => {}); | ||
} |
@@ -13,3 +13,2 @@ /* | ||
/** | ||
@@ -24,4 +23,6 @@ * Runs all of the callback functions, one at a time sequentially, in the order | ||
if (process.env.NODE_ENV !== 'production') { | ||
logger.log(`About to run ${quotaErrorCallbacks.size} ` + | ||
`callbacks to clean up caches.`); | ||
logger.log( | ||
`About to run ${quotaErrorCallbacks.size} ` + | ||
`callbacks to clean up caches.`, | ||
); | ||
} | ||
@@ -28,0 +29,0 @@ |
@@ -21,71 +21,81 @@ /* | ||
type LoggerMethods = 'debug'|'log'|'warn'|'error'|'groupCollapsed'|'groupEnd'; | ||
type LoggerMethods = | ||
| 'debug' | ||
| 'log' | ||
| 'warn' | ||
| 'error' | ||
| 'groupCollapsed' | ||
| 'groupEnd'; | ||
const logger = (process.env.NODE_ENV === 'production' ? null : (() => { | ||
// Don't overwrite this value if it's already set. | ||
// See https://github.com/GoogleChrome/workbox/pull/2284#issuecomment-560470923 | ||
if (!('__WB_DISABLE_DEV_LOGS' in self)) { | ||
self.__WB_DISABLE_DEV_LOGS = false; | ||
} | ||
const logger = ( | ||
process.env.NODE_ENV === 'production' | ||
? null | ||
: (() => { | ||
// Don't overwrite this value if it's already set. | ||
// See https://github.com/GoogleChrome/workbox/pull/2284#issuecomment-560470923 | ||
if (!('__WB_DISABLE_DEV_LOGS' in self)) { | ||
self.__WB_DISABLE_DEV_LOGS = false; | ||
} | ||
let inGroup = false; | ||
let inGroup = false; | ||
const methodToColorMap: {[methodName: string]: string|null} = { | ||
debug: `#7f8c8d`, // Gray | ||
log: `#2ecc71`, // Green | ||
warn: `#f39c12`, // Yellow | ||
error: `#c0392b`, // Red | ||
groupCollapsed: `#3498db`, // Blue | ||
groupEnd: null, // No colored prefix on groupEnd | ||
}; | ||
const methodToColorMap: {[methodName: string]: string | null} = { | ||
debug: `#7f8c8d`, // Gray | ||
log: `#2ecc71`, // Green | ||
warn: `#f39c12`, // Yellow | ||
error: `#c0392b`, // Red | ||
groupCollapsed: `#3498db`, // Blue | ||
groupEnd: null, // No colored prefix on groupEnd | ||
}; | ||
const print = function(method: LoggerMethods, args: any[]) { | ||
if (self.__WB_DISABLE_DEV_LOGS) { | ||
return; | ||
} | ||
const print = function (method: LoggerMethods, args: any[]) { | ||
if (self.__WB_DISABLE_DEV_LOGS) { | ||
return; | ||
} | ||
if (method === 'groupCollapsed') { | ||
// Safari doesn't print all console.groupCollapsed() arguments: | ||
// https://bugs.webkit.org/show_bug.cgi?id=182754 | ||
if (/^((?!chrome|android).)*safari/i.test(navigator.userAgent)) { | ||
console[method](...args); | ||
return; | ||
} | ||
} | ||
if (method === 'groupCollapsed') { | ||
// Safari doesn't print all console.groupCollapsed() arguments: | ||
// https://bugs.webkit.org/show_bug.cgi?id=182754 | ||
if (/^((?!chrome|android).)*safari/i.test(navigator.userAgent)) { | ||
console[method](...args); | ||
return; | ||
} | ||
} | ||
const styles = [ | ||
`background: ${methodToColorMap[method]!}`, | ||
`border-radius: 0.5em`, | ||
`color: white`, | ||
`font-weight: bold`, | ||
`padding: 2px 0.5em`, | ||
]; | ||
const styles = [ | ||
`background: ${methodToColorMap[method]!}`, | ||
`border-radius: 0.5em`, | ||
`color: white`, | ||
`font-weight: bold`, | ||
`padding: 2px 0.5em`, | ||
]; | ||
// When in a group, the workbox prefix is not displayed. | ||
const logPrefix = inGroup ? [] : ['%cworkbox', styles.join(';')]; | ||
// When in a group, the workbox prefix is not displayed. | ||
const logPrefix = inGroup ? [] : ['%cworkbox', styles.join(';')]; | ||
console[method](...logPrefix, ...args); | ||
console[method](...logPrefix, ...args); | ||
if (method === 'groupCollapsed') { | ||
inGroup = true; | ||
} | ||
if (method === 'groupEnd') { | ||
inGroup = false; | ||
} | ||
}; | ||
// eslint-disable-next-line @typescript-eslint/ban-types | ||
const api: {[methodName: string]: Function} = {}; | ||
const loggerMethods = Object.keys(methodToColorMap); | ||
if (method === 'groupCollapsed') { | ||
inGroup = true; | ||
} | ||
if (method === 'groupEnd') { | ||
inGroup = false; | ||
} | ||
}; | ||
// eslint-disable-next-line @typescript-eslint/ban-types | ||
const api: {[methodName: string]: Function} = {}; | ||
const loggerMethods = Object.keys(methodToColorMap); | ||
for (const key of loggerMethods) { | ||
const method = key as LoggerMethods; | ||
for (const key of loggerMethods) { | ||
const method = key as LoggerMethods; | ||
api[method] = (...args: any[]) => { | ||
print(method, args); | ||
}; | ||
} | ||
api[method] = (...args: any[]) => { | ||
print(method, args); | ||
}; | ||
} | ||
return api as unknown; | ||
})()) as Console; | ||
return api as unknown; | ||
})() | ||
) as Console; | ||
export {logger}; |
@@ -11,3 +11,2 @@ /* | ||
// Give TypeScript the correct global. | ||
@@ -28,3 +27,5 @@ declare let self: ServiceWorkerGlobalScope; | ||
*/ | ||
export async function resultingClientExists(resultingClientId?: string): Promise<Client | undefined> { | ||
export async function resultingClientExists( | ||
resultingClientId?: string, | ||
): Promise<Client | undefined> { | ||
if (!resultingClientId) { | ||
@@ -47,6 +48,6 @@ return; | ||
// If we have a `resultingClientId`, we can match on that. | ||
return w.id === resultingClientId | ||
return w.id === resultingClientId; | ||
} else { | ||
// Otherwise match on finding a window not in `existingWindowIds`. | ||
return !existingWindowIds.has(w.id) | ||
return !existingWindowIds.has(w.id); | ||
} | ||
@@ -53,0 +54,0 @@ }); |
@@ -10,3 +10,2 @@ /* | ||
/** | ||
@@ -13,0 +12,0 @@ * Returns a promise that resolves and the passed number of milliseconds. |
@@ -10,3 +10,2 @@ /* | ||
/** | ||
@@ -21,3 +20,6 @@ * A utility method that makes it easier to use `event.waitUntil` with | ||
*/ | ||
function waitUntil(event: ExtendableEvent, asyncFn: () => Promise<any>): Promise<any> { | ||
function waitUntil( | ||
event: ExtendableEvent, | ||
asyncFn: () => Promise<any>, | ||
): Promise<any> { | ||
const returnPromise = asyncFn(); | ||
@@ -24,0 +26,0 @@ event.waitUntil(returnPromise); |
@@ -13,3 +13,2 @@ /* | ||
/** | ||
@@ -16,0 +15,0 @@ * Workbox errors should be thrown with this class. |
// @ts-ignore | ||
try{self['workbox:core:6.3.0']&&_()}catch(e){} | ||
try{self['workbox:core:6.4.0']&&_()}catch(e){} |
@@ -12,3 +12,2 @@ /* | ||
/** | ||
@@ -47,2 +46,2 @@ * Get the current cache names and prefix/suffix used by Workbox. | ||
export {cacheNames} | ||
export {cacheNames}; |
@@ -11,3 +11,2 @@ /* | ||
// Give TypeScript the correct global. | ||
@@ -26,2 +25,2 @@ declare let self: ServiceWorkerGlobalScope; | ||
export {clientsClaim} | ||
export {clientsClaim}; |
@@ -35,3 +35,3 @@ /* | ||
response: Response, | ||
modifier?: (responseInit: ResponseInit) => ResponseInit | ||
modifier?: (responseInit: ResponseInit) => ResponseInit, | ||
): Promise<Response> { | ||
@@ -56,3 +56,3 @@ let origin = null; | ||
statusText: clonedResponse.statusText, | ||
} | ||
}; | ||
@@ -65,4 +65,5 @@ // Apply any user modifications. | ||
// so fall back to reading the entire body into memory as a blob. | ||
const body = canConstructResponseFromBodyStream() ? | ||
clonedResponse.body : await clonedResponse.blob(); | ||
const body = canConstructResponseFromBodyStream() | ||
? clonedResponse.body | ||
: await clonedResponse.blob(); | ||
@@ -72,2 +73,2 @@ return new Response(body, modifiedResponseInit); | ||
export {copyResponse} | ||
export {copyResponse}; |
@@ -18,3 +18,2 @@ /* | ||
/** | ||
@@ -21,0 +20,0 @@ * All of the Workbox service worker libraries use workbox-core for shared |
@@ -29,3 +29,3 @@ /* | ||
export const messageGenerator = (process.env.NODE_ENV === 'production') ? | ||
fallback : generatorFunction; | ||
export const messageGenerator = | ||
process.env.NODE_ENV === 'production' ? fallback : generatorFunction; |
@@ -11,3 +11,2 @@ /* | ||
interface LoggableObject { | ||
@@ -25,5 +24,7 @@ [key: string]: string | number; | ||
} | ||
return `The '${paramName}' parameter was given a value with an ` + | ||
return ( | ||
`The '${paramName}' parameter was given a value with an ` + | ||
`unexpected value. ${validValueDescription} Received a value of ` + | ||
`${JSON.stringify(value)}.`; | ||
`${JSON.stringify(value)}.` | ||
); | ||
}, | ||
@@ -35,8 +36,15 @@ | ||
} | ||
return `The parameter '${paramName}' passed into ` + | ||
`'${moduleName}.${className}.${funcName}()' must be an array.`; | ||
return ( | ||
`The parameter '${paramName}' passed into ` + | ||
`'${moduleName}.${className}.${funcName}()' must be an array.` | ||
); | ||
}, | ||
'incorrect-type': ({expectedType, paramName, moduleName, className, | ||
funcName}) => { | ||
'incorrect-type': ({ | ||
expectedType, | ||
paramName, | ||
moduleName, | ||
className, | ||
funcName, | ||
}) => { | ||
if (!expectedType || !paramName || !moduleName || !funcName) { | ||
@@ -46,9 +54,17 @@ throw new Error(`Unexpected input to 'incorrect-type' error.`); | ||
const classNameStr = className ? `${className}.` : ''; | ||
return `The parameter '${paramName}' passed into ` + | ||
return ( | ||
`The parameter '${paramName}' passed into ` + | ||
`'${moduleName}.${classNameStr}` + | ||
`${funcName}()' must be of type ${expectedType}.`; | ||
`${funcName}()' must be of type ${expectedType}.` | ||
); | ||
}, | ||
'incorrect-class': ({expectedClassName, paramName, moduleName, className, | ||
funcName, isReturnValueProblem}) => { | ||
'incorrect-class': ({ | ||
expectedClassName, | ||
paramName, | ||
moduleName, | ||
className, | ||
funcName, | ||
isReturnValueProblem, | ||
}) => { | ||
if (!expectedClassName || !moduleName || !funcName) { | ||
@@ -59,28 +75,48 @@ throw new Error(`Unexpected input to 'incorrect-class' error.`); | ||
if (isReturnValueProblem) { | ||
return `The return value from ` + | ||
return ( | ||
`The return value from ` + | ||
`'${moduleName}.${classNameStr}${funcName}()' ` + | ||
`must be an instance of class ${expectedClassName}.`; | ||
`must be an instance of class ${expectedClassName}.` | ||
); | ||
} | ||
return `The parameter '${paramName}' passed into ` + | ||
return ( | ||
`The parameter '${paramName}' passed into ` + | ||
`'${moduleName}.${classNameStr}${funcName}()' ` + | ||
`must be an instance of class ${expectedClassName}.`; | ||
`must be an instance of class ${expectedClassName}.` | ||
); | ||
}, | ||
'missing-a-method': ({expectedMethod, paramName, moduleName, className, | ||
funcName}) => { | ||
if (!expectedMethod || !paramName || !moduleName || !className | ||
|| !funcName) { | ||
'missing-a-method': ({ | ||
expectedMethod, | ||
paramName, | ||
moduleName, | ||
className, | ||
funcName, | ||
}) => { | ||
if ( | ||
!expectedMethod || | ||
!paramName || | ||
!moduleName || | ||
!className || | ||
!funcName | ||
) { | ||
throw new Error(`Unexpected input to 'missing-a-method' error.`); | ||
} | ||
return `${moduleName}.${className}.${funcName}() expected the ` + | ||
`'${paramName}' parameter to expose a '${expectedMethod}' method.`; | ||
return ( | ||
`${moduleName}.${className}.${funcName}() expected the ` + | ||
`'${paramName}' parameter to expose a '${expectedMethod}' method.` | ||
); | ||
}, | ||
'add-to-cache-list-unexpected-type': ({entry}) => { | ||
return `An unexpected entry was passed to ` + | ||
`'workbox-precaching.PrecacheController.addToCacheList()' The entry ` + | ||
`'${JSON.stringify(entry)}' isn't supported. You must supply an array of ` + | ||
`strings with one or more characters, objects with a url property or ` + | ||
`Request objects.`; | ||
return ( | ||
`An unexpected entry was passed to ` + | ||
`'workbox-precaching.PrecacheController.addToCacheList()' The entry ` + | ||
`'${JSON.stringify( | ||
entry, | ||
)}' isn't supported. You must supply an array of ` + | ||
`strings with one or more characters, objects with a url property or ` + | ||
`Request objects.` | ||
); | ||
}, | ||
@@ -90,11 +126,14 @@ | ||
if (!firstEntry || !secondEntry) { | ||
throw new Error(`Unexpected input to ` + | ||
`'add-to-cache-list-duplicate-entries' error.`); | ||
throw new Error( | ||
`Unexpected input to ` + `'add-to-cache-list-duplicate-entries' error.`, | ||
); | ||
} | ||
return `Two of the entries passed to ` + | ||
return ( | ||
`Two of the entries passed to ` + | ||
`'workbox-precaching.PrecacheController.addToCacheList()' had the URL ` + | ||
`${firstEntry} but different revision details. Workbox is ` + | ||
`unable to cache and version the asset correctly. Please remove one ` + | ||
`of the entries.`; | ||
`of the entries.` | ||
); | ||
}, | ||
@@ -104,8 +143,11 @@ | ||
if (!thrownErrorMessage) { | ||
throw new Error(`Unexpected input to ` + | ||
`'plugin-error-request-will-fetch', error.`); | ||
throw new Error( | ||
`Unexpected input to ` + `'plugin-error-request-will-fetch', error.`, | ||
); | ||
} | ||
return `An error was thrown by a plugins 'requestWillFetch()' method. ` + | ||
`The thrown error message was: '${thrownErrorMessage}'.`; | ||
return ( | ||
`An error was thrown by a plugins 'requestWillFetch()' method. ` + | ||
`The thrown error message was: '${thrownErrorMessage}'.` | ||
); | ||
}, | ||
@@ -116,8 +158,11 @@ | ||
throw new Error( | ||
`Expected a 'cacheNameId' for error 'invalid-cache-name'`); | ||
`Expected a 'cacheNameId' for error 'invalid-cache-name'`, | ||
); | ||
} | ||
return `You must provide a name containing at least one character for ` + | ||
return ( | ||
`You must provide a name containing at least one character for ` + | ||
`setCacheDetails({${cacheNameId}: '...'}). Received a value of ` + | ||
`'${JSON.stringify(value)}'`; | ||
`'${JSON.stringify(value)}'` | ||
); | ||
}, | ||
@@ -127,13 +172,19 @@ | ||
if (!method) { | ||
throw new Error(`Unexpected input to ` + | ||
`'unregister-route-but-not-found-with-method' error.`); | ||
throw new Error( | ||
`Unexpected input to ` + | ||
`'unregister-route-but-not-found-with-method' error.`, | ||
); | ||
} | ||
return `The route you're trying to unregister was not previously ` + | ||
`registered for the method type '${method}'.`; | ||
return ( | ||
`The route you're trying to unregister was not previously ` + | ||
`registered for the method type '${method}'.` | ||
); | ||
}, | ||
'unregister-route-route-not-registered': () => { | ||
return `The route you're trying to unregister was not previously ` + | ||
`registered.`; | ||
return ( | ||
`The route you're trying to unregister was not previously ` + | ||
`registered.` | ||
); | ||
}, | ||
@@ -146,33 +197,51 @@ | ||
'duplicate-queue-name': ({name}) => { | ||
return `The Queue name '${name}' is already being used. ` + | ||
`All instances of backgroundSync.Queue must be given unique names.`; | ||
return ( | ||
`The Queue name '${name}' is already being used. ` + | ||
`All instances of backgroundSync.Queue must be given unique names.` | ||
); | ||
}, | ||
'expired-test-without-max-age': ({methodName, paramName}) => { | ||
return `The '${methodName}()' method can only be used when the ` + | ||
`'${paramName}' is used in the constructor.`; | ||
return ( | ||
`The '${methodName}()' method can only be used when the ` + | ||
`'${paramName}' is used in the constructor.` | ||
); | ||
}, | ||
'unsupported-route-type': ({moduleName, className, funcName, paramName}) => { | ||
return `The supplied '${paramName}' parameter was an unsupported type. ` + | ||
return ( | ||
`The supplied '${paramName}' parameter was an unsupported type. ` + | ||
`Please check the docs for ${moduleName}.${className}.${funcName} for ` + | ||
`valid input types.`; | ||
`valid input types.` | ||
); | ||
}, | ||
'not-array-of-class': ({value, expectedClass, | ||
moduleName, className, funcName, paramName}) => { | ||
return `The supplied '${paramName}' parameter must be an array of ` + | ||
'not-array-of-class': ({ | ||
value, | ||
expectedClass, | ||
moduleName, | ||
className, | ||
funcName, | ||
paramName, | ||
}) => { | ||
return ( | ||
`The supplied '${paramName}' parameter must be an array of ` + | ||
`'${expectedClass}' objects. Received '${JSON.stringify(value)},'. ` + | ||
`Please check the call to ${moduleName}.${className}.${funcName}() ` + | ||
`to fix the issue.`; | ||
`to fix the issue.` | ||
); | ||
}, | ||
'max-entries-or-age-required': ({moduleName, className, funcName}) => { | ||
return `You must define either config.maxEntries or config.maxAgeSeconds` + | ||
`in ${moduleName}.${className}.${funcName}`; | ||
return ( | ||
`You must define either config.maxEntries or config.maxAgeSeconds` + | ||
`in ${moduleName}.${className}.${funcName}` | ||
); | ||
}, | ||
'statuses-or-headers-required': ({moduleName, className, funcName}) => { | ||
return `You must define either config.statuses or config.headers` + | ||
`in ${moduleName}.${className}.${funcName}`; | ||
return ( | ||
`You must define either config.statuses or config.headers` + | ||
`in ${moduleName}.${className}.${funcName}` | ||
); | ||
}, | ||
@@ -184,21 +253,29 @@ | ||
} | ||
return `When using strings, the '${paramName}' parameter must start with ` + | ||
return ( | ||
`When using strings, the '${paramName}' parameter must start with ` + | ||
`'http' (for cross-origin matches) or '/' (for same-origin matches). ` + | ||
`Please see the docs for ${moduleName}.${funcName}() for ` + | ||
`more info.`; | ||
`more info.` | ||
); | ||
}, | ||
'channel-name-required': () => { | ||
return `You must provide a channelName to construct a ` + | ||
`BroadcastCacheUpdate instance.`; | ||
return ( | ||
`You must provide a channelName to construct a ` + | ||
`BroadcastCacheUpdate instance.` | ||
); | ||
}, | ||
'invalid-responses-are-same-args': () => { | ||
return `The arguments passed into responsesAreSame() appear to be ` + | ||
`invalid. Please ensure valid Responses are used.`; | ||
return ( | ||
`The arguments passed into responsesAreSame() appear to be ` + | ||
`invalid. Please ensure valid Responses are used.` | ||
); | ||
}, | ||
'expire-custom-caches-only': () => { | ||
return `You must provide a 'cacheName' property when using the ` + | ||
`expiration plugin with a runtime caching strategy.`; | ||
return ( | ||
`You must provide a 'cacheName' property when using the ` + | ||
`expiration plugin with a runtime caching strategy.` | ||
); | ||
}, | ||
@@ -210,4 +287,6 @@ | ||
} | ||
return `The 'unit' portion of the Range header must be set to 'bytes'. ` + | ||
`The Range header provided was "${normalizedRangeHeader}"`; | ||
return ( | ||
`The 'unit' portion of the Range header must be set to 'bytes'. ` + | ||
`The Range header provided was "${normalizedRangeHeader}"` | ||
); | ||
}, | ||
@@ -219,5 +298,7 @@ | ||
} | ||
return `Multiple ranges are not supported. Please use a single start ` + | ||
return ( | ||
`Multiple ranges are not supported. Please use a single start ` + | ||
`value, and optional end value. The Range header provided was ` + | ||
`"${normalizedRangeHeader}"`; | ||
`"${normalizedRangeHeader}"` | ||
); | ||
}, | ||
@@ -229,5 +310,7 @@ | ||
} | ||
return `The Range header is missing both start and end values. At least ` + | ||
return ( | ||
`The Range header is missing both start and end values. At least ` + | ||
`one of those values is needed. The Range header provided was ` + | ||
`"${normalizedRangeHeader}"`; | ||
`"${normalizedRangeHeader}"` | ||
); | ||
}, | ||
@@ -240,14 +323,20 @@ | ||
'range-not-satisfiable': ({size, start, end}) => { | ||
return `The start (${start}) and end (${end}) values in the Range are ` + | ||
`not satisfiable by the cached response, which is ${size} bytes.`; | ||
return ( | ||
`The start (${start}) and end (${end}) values in the Range are ` + | ||
`not satisfiable by the cached response, which is ${size} bytes.` | ||
); | ||
}, | ||
'attempt-to-cache-non-get-request': ({url, method}) => { | ||
return `Unable to cache '${url}' because it is a '${method}' request and ` + | ||
`only 'GET' requests can be cached.`; | ||
return ( | ||
`Unable to cache '${url}' because it is a '${method}' request and ` + | ||
`only 'GET' requests can be cached.` | ||
); | ||
}, | ||
'cache-put-with-no-response': ({url}) => { | ||
return `There was an attempt to cache '${url}' but the response was not ` + | ||
`defined.`; | ||
return ( | ||
`There was an attempt to cache '${url}' but the response was not ` + | ||
`defined.` | ||
); | ||
}, | ||
@@ -264,15 +353,21 @@ | ||
'bad-precaching-response': ({url, status}) => { | ||
return `The precaching request for '${url}' failed` + | ||
(status ? ` with an HTTP status of ${status}.` : `.`); | ||
return ( | ||
`The precaching request for '${url}' failed` + | ||
(status ? ` with an HTTP status of ${status}.` : `.`) | ||
); | ||
}, | ||
'non-precached-url': ({url}) => { | ||
return `createHandlerBoundToURL('${url}') was called, but that URL is ` + | ||
`not precached. Please pass in a URL that is precached instead.`; | ||
return ( | ||
`createHandlerBoundToURL('${url}') was called, but that URL is ` + | ||
`not precached. Please pass in a URL that is precached instead.` | ||
); | ||
}, | ||
'add-to-cache-list-conflicting-integrities': ({url}) => { | ||
return `Two of the entries passed to ` + | ||
return ( | ||
`Two of the entries passed to ` + | ||
`'workbox-precaching.PrecacheController.addToCacheList()' had the URL ` + | ||
`${url} with different integrity values. Please remove one of them.`; | ||
`${url} with different integrity values. Please remove one of them.` | ||
); | ||
}, | ||
@@ -285,5 +380,7 @@ | ||
'cross-origin-copy-response': ({origin}) => { | ||
return `workbox-core.copyResponse() can only be used with same-origin ` + | ||
`responses. It was passed a response with origin ${origin}.`; | ||
return ( | ||
`workbox-core.copyResponse() can only be used with same-origin ` + | ||
`responses. It was passed a response with origin ${origin}.` | ||
); | ||
}, | ||
}; |
@@ -11,3 +11,2 @@ /* | ||
export const enum pluginEvents { | ||
@@ -14,0 +13,0 @@ CACHE_DID_UPDATE = 'cacheDidUpdate', |
@@ -11,3 +11,2 @@ /* | ||
// Callbacks to be executed whenever there's a quota error. | ||
@@ -14,0 +13,0 @@ // Can't change Function type right now. |
@@ -14,3 +14,2 @@ /* | ||
/** | ||
@@ -17,0 +16,0 @@ * Adds a function to the set of quotaErrorCallbacks that will be executed if |
@@ -14,3 +14,2 @@ /* | ||
/** | ||
@@ -57,3 +56,6 @@ * Modifies the default cache names used by the Workbox packages. | ||
if ('googleAnalytics' in details && details['googleAnalytics'].length === 0) { | ||
if ( | ||
'googleAnalytics' in details && | ||
details['googleAnalytics'].length === 0 | ||
) { | ||
throw new WorkboxError('invalid-cache-name', { | ||
@@ -69,2 +71,2 @@ cacheNameId: 'googleAnalytics', | ||
export {setCacheNameDetails} | ||
export {setCacheNameDetails}; |
@@ -27,5 +27,7 @@ /* | ||
if (process.env.NODE_ENV !== 'production') { | ||
logger.warn(`skipWaiting() from workbox-core is no longer recommended ` + | ||
logger.warn( | ||
`skipWaiting() from workbox-core is no longer recommended ` + | ||
`and will be removed in Workbox v7. Using self.skipWaiting() instead ` + | ||
`is equivalent.`); | ||
`is equivalent.`, | ||
); | ||
} | ||
@@ -36,2 +38,2 @@ | ||
export {skipWaiting} | ||
export {skipWaiting}; |
@@ -11,3 +11,2 @@ /* | ||
export interface MapLikeObject { | ||
@@ -67,3 +66,4 @@ [key: string]: any; | ||
export type HandlerCallbackOptions = | ||
RouteHandlerCallbackOptions | ManualHandlerCallbackOptions; | ||
| RouteHandlerCallbackOptions | ||
| ManualHandlerCallbackOptions; | ||
@@ -154,3 +154,5 @@ /** | ||
export interface CacheWillUpdateCallback { | ||
(param: CacheWillUpdateCallbackParam): Promise<Response | void | null | undefined>; | ||
(param: CacheWillUpdateCallbackParam): Promise< | ||
Response | void | null | undefined | ||
>; | ||
} | ||
@@ -168,3 +170,5 @@ | ||
export interface CachedResponseWillBeUsedCallback { | ||
(param: CachedResponseWillBeUsedCallbackParam): Promise<Response | void | null | undefined>; | ||
(param: CachedResponseWillBeUsedCallbackParam): Promise< | ||
Response | void | null | undefined | ||
>; | ||
} | ||
@@ -171,0 +175,0 @@ |
@@ -12,3 +12,2 @@ /* | ||
export const pluginUtils = { | ||
@@ -15,0 +14,0 @@ filter: (plugins: WorkboxPlugin[], callbackName: string): WorkboxPlugin[] => { |
@@ -12,3 +12,2 @@ /* | ||
// A WorkboxCore instance must be exported before we can use the logger. | ||
@@ -19,18 +18,20 @@ // This is so it can get the current log level. | ||
logger.groupCollapsed('Welcome to Workbox!'); | ||
logger.log(`You are currently using a development build. ` + | ||
`By default this will switch to prod builds when not on localhost. ` + | ||
`You can force this with workbox.setConfig({debug: true|false}).`); | ||
logger.log( | ||
`📖 Read the guides and documentation\n` + | ||
`${padding}https://developers.google.com/web/tools/workbox/` | ||
`You are currently using a development build. ` + | ||
`By default this will switch to prod builds when not on localhost. ` + | ||
`You can force this with workbox.setConfig({debug: true|false}).`, | ||
); | ||
logger.log( | ||
`❓ Use the [workbox] tag on Stack Overflow to ask questions\n` + | ||
`${padding}https://stackoverflow.com/questions/ask?tags=workbox` | ||
`📖 Read the guides and documentation\n` + | ||
`${padding}https://developers.google.com/web/tools/workbox/`, | ||
); | ||
logger.log( | ||
`🐛 Found a bug? Report it on GitHub\n` + | ||
`${padding}https://github.com/GoogleChrome/workbox/issues/new` | ||
`❓ Use the [workbox] tag on Stack Overflow to ask questions\n` + | ||
`${padding}https://stackoverflow.com/questions/ask?tags=workbox`, | ||
); | ||
logger.log( | ||
`🐛 Found a bug? Report it on GitHub\n` + | ||
`${padding}https://github.com/GoogleChrome/workbox/issues/new`, | ||
); | ||
logger.groupEnd(); | ||
} |
@@ -8,5 +8,3 @@ { | ||
}, | ||
"include": [ | ||
"src/**/*.ts" | ||
] | ||
"include": ["src/**/*.ts"] | ||
} |
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
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
Unidentified License
License(Experimental) Something that seems like a license was found, but its contents could not be matched with a known license.
Found 2 instances 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
Unidentified License
License(Experimental) Something that seems like a license was found, but its contents could not be matched with a known license.
Found 2 instances in 1 package
4234
277003