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

workbox-core

Package Overview
Dependencies
Maintainers
4
Versions
85
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

workbox-core - npm Package Compare versions

Comparing version 4.0.0-beta.0 to 4.0.0-beta.1

cacheNames.mjs

558

build/workbox-core.dev.js
this.workbox = this.workbox || {};
this.workbox.core = (function () {
this.workbox.core = (function (exports) {
'use strict';
try {
self.workbox.v['workbox:core:4.0.0-beta.0'] = 1;
self.workbox.v['workbox:core:4.0.0-beta.1'] = 1;
} catch (e) {} // eslint-disable-line
/*
Copyright 2018 Google LLC
Copyright 2019 Google LLC
Use of this source code is governed by an MIT-style

@@ -16,97 +15,54 @@ license that can be found in the LICENSE file or at

*/
/**
* The available log levels in Workbox: debug, log, warn, error and silent.
*
* @property {int} debug Prints all logs from Workbox. Useful for debugging.
* @property {int} log Prints console log, warn, error and groups. Default for
* debug builds.
* @property {int} warn Prints console warn, error and groups. Default for
* non-debug builds.
* @property {int} error Print console error and groups.
* @property {int} silent Force no logging from Workbox.
*
* @alias workbox.core.LOG_LEVELS
*/
const logger = (() => {
let inGroup = false;
const methodToColorMap = {
debug: `#7f8c8d`,
// Gray
log: `#2ecc71`,
// Green
warn: `#f39c12`,
// Yellow
error: `#c0392b`,
// Red
groupCollapsed: `#3498db`,
// Blue
groupEnd: null // No colored prefix on groupEnd
var LOG_LEVELS = {
debug: 0,
log: 1,
warn: 2,
error: 3,
silent: 4
};
};
/*
Copyright 2018 Google LLC
const print = function (method, args) {
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;
}
}
Use of this source code is governed by an MIT-style
license that can be found in the LICENSE file or at
https://opensource.org/licenses/MIT.
*/
// Related bug: https://bugs.webkit.org/show_bug.cgi?id=182754
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 isSafari = /^((?!chrome|android).)*safari/i.test(navigator.userAgent);
const GREY = `#7f8c8d`;
const GREEN = `#2ecc71`;
const YELLOW = `#f39c12`;
const RED = `#c0392b`;
const BLUE = `#3498db`;
const logPrefix = inGroup ? [] : ['%cworkbox', styles.join(';')];
console[method](...logPrefix, ...args);
const getDefaultLogLevel = () => LOG_LEVELS.log;
if (method === 'groupCollapsed') {
inGroup = true;
}
let logLevel = getDefaultLogLevel();
if (method === 'groupEnd') {
inGroup = false;
}
};
const shouldPrint = minLevel => logLevel <= minLevel;
const api = {};
const setLoggerLevel = newLogLevel => logLevel = newLogLevel;
const getLoggerLevel = () => logLevel; // We always want groups to be logged unless logLevel is silent.
const groupLevel = LOG_LEVELS.error;
const _print = function (keyName, logArgs, levelColor) {
const logLevel = keyName.indexOf('group') === 0 ? groupLevel : LOG_LEVELS[keyName];
if (!shouldPrint(logLevel)) {
return;
for (const method of Object.keys(methodToColorMap)) {
api[method] = (...args) => {
print(method, args);
};
}
if (!levelColor || keyName === 'groupCollapsed' && isSafari) {
console[keyName](...logArgs);
return;
}
return api;
})();
const logPrefix = ['%cworkbox', `background: ${levelColor}; color: white; padding: 2px 0.5em; ` + `border-radius: 0.5em;`];
console[keyName](...logPrefix, ...logArgs);
};
const groupEnd = () => {
if (shouldPrint(groupLevel)) {
console.groupEnd();
}
};
const defaultExport = {
groupEnd,
unprefixed: {
groupEnd
}
};
const setupLogs = (keyName, color) => {
defaultExport[keyName] = (...args) => _print(keyName, args, color);
defaultExport.unprefixed[keyName] = (...args) => _print(keyName, args);
};
const levelToColor = {
debug: GREY,
log: GREEN,
warn: YELLOW,
error: RED,
groupCollapsed: BLUE
};
Object.keys(levelToColor).forEach(keyName => setupLogs(keyName, levelToColor[keyName]));
/*

@@ -119,3 +75,3 @@ Copyright 2018 Google LLC

*/
var messages = {
const messages = {
'invalid-value': ({

@@ -210,3 +166,3 @@ paramName,

return `Two of the entries passed to ` + `'workbox-precaching.PrecacheController.addToCacheList()' had matching ` + `URLs but different revision details. This means workbox-precaching ` + `is unable to determine cache the asset correctly. Please remove one ` + `of the entries.`;
return `Two of the entries passed to ` + `'workbox-precaching.PrecacheController.addToCacheList()' had the URL ` + `${firstEntry._entryId} but different revision details. Workbox is ` + `is unable to cache and version the asset correctly. Please remove one ` + `of the entries.`;
},

@@ -298,7 +254,7 @@ 'plugin-error-request-will-fetch': ({

}) => {
if (!paramName || !moduleName || !className || !funcName) {
if (!paramName || !moduleName || !funcName) {
throw new Error(`Unexpected input to 'invalid-string' error.`);
}
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}.${className}.${funcName}() for ` + `more info.`;
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.`;
},

@@ -400,3 +356,3 @@ 'channel-name-required': () => {

const exportedValue = generatorFunction;
const messageGenerator = generatorFunction;

@@ -430,3 +386,3 @@ /*

constructor(errorCode, details) {
let message = exportedValue(errorCode, details);
let message = messageGenerator(errorCode, details);
super(message);

@@ -450,3 +406,3 @@ this.name = errorCode;

const isSwEnv = moduleName => {
const isSWEnv = moduleName => {
if (!('ServiceWorkerGlobalScope' in self)) {

@@ -580,3 +536,3 @@ throw new WorkboxError('not-in-sw', {

isOneOf,
isSwEnv,
isSWEnv,
isType,

@@ -614,3 +570,3 @@ isArrayOfClass

{
defaultExport.log('Registered a callback to respond to quota errors.', callback);
logger.log('Registered a callback to respond to quota errors.', callback);
}

@@ -629,3 +585,3 @@ }

{
defaultExport.log(`About to run ${callbacks.size} callbacks to clean up caches.`);
logger.log(`About to run ${callbacks.size} callbacks to clean up caches.`);
}

@@ -637,3 +593,3 @@

{
defaultExport.log(callback, 'is complete.');
logger.log(callback, 'is complete.');
}

@@ -643,3 +599,3 @@ }

{
defaultExport.log('Finished running callbacks.');
logger.log('Finished running callbacks.');
}

@@ -649,2 +605,10 @@ }

/*
Copyright 2019 Google LLC
Use of this source code is governed by an MIT-style
license that can be found in the LICENSE file or at
https://opensource.org/licenses/MIT.
*/
/*
Copyright 2018 Google LLC

@@ -1039,7 +1003,7 @@

const _cacheNameDetails = {
googleAnalytics: 'googleAnalytics',
precache: 'precache-v2',
prefix: 'workbox',
suffix: self.registration.scope,
googleAnalytics: 'googleAnalytics',
precache: 'precache',
runtime: 'runtime'
runtime: 'runtime',
suffix: self.registration.scope
};

@@ -1077,3 +1041,3 @@

*/
var pluginEvents = {
const pluginEvents = {
CACHE_DID_UPDATE: 'cacheDidUpdate',

@@ -1083,2 +1047,3 @@ CACHE_WILL_UPDATE: 'cacheWillUpdate',

FETCH_DID_FAIL: 'fetchDidFail',
FETCH_DID_SUCCEED: 'fetchDidSucceed',
REQUEST_WILL_FETCH: 'requestWillFetch'

@@ -1094,5 +1059,5 @@ };

*/
var pluginUtils = {
filter: (plugins, callbackname) => {
return plugins.filter(plugin => callbackname in plugin);
const pluginUtils = {
filter: (plugins, callbackName) => {
return plugins.filter(plugin => callbackName in plugin);
}

@@ -1151,3 +1116,3 @@ };

{
defaultExport.error(`Cannot cache non-existent response for ` + `'${getFriendlyURL(request.url)}'.`);
logger.error(`Cannot cache non-existent response for ` + `'${getFriendlyURL(request.url)}'.`);
}

@@ -1169,3 +1134,3 @@

{
defaultExport.debug(`Response '${getFriendlyURL(request.url)}' will not be ` + `cached.`, responseToCache);
logger.debug(`Response '${getFriendlyURL(request.url)}' will not be ` + `cached.`, responseToCache);
}

@@ -1193,3 +1158,3 @@

{
defaultExport.debug(`Updating the '${cacheName}' cache with a new Response for ` + `${getFriendlyURL(request.url)}.`);
logger.debug(`Updating the '${cacheName}' cache with a new Response for ` + `${getFriendlyURL(request.url)}.`);
}

@@ -1247,9 +1212,9 @@

if (cachedResponse) {
defaultExport.debug(`Found a cached response in '${cacheName}'.`);
logger.debug(`Found a cached response in '${cacheName}'.`);
} else {
defaultExport.debug(`No cached response found in '${cacheName}'.`);
logger.debug(`No cached response found in '${cacheName}'.`);
}
}
for (let plugin of plugins) {
for (const plugin of plugins) {
if (pluginEvents.CACHED_RESPONSE_WILL_BE_USED in plugin) {

@@ -1280,3 +1245,3 @@ cachedResponse = await plugin[pluginEvents.CACHED_RESPONSE_WILL_BE_USED].call(plugin, {

* This method will call cacheWillUpdate on the available plugins (or use
* response.ok) to determine if the Response is safe and valid to cache.
* status === 200) to determine if the Response is safe and valid to cache.
*

@@ -1331,7 +1296,7 @@ * @param {Object} options

{
if (!responseToCache.ok) {
if (!responseToCache.status === 200) {
if (responseToCache.status === 0) {
defaultExport.warn(`The response for '${request.url}' is an opaque ` + `response. The caching strategy that you're using will not ` + `cache opaque responses by default.`);
logger.warn(`The response for '${request.url}' is an opaque ` + `response. The caching strategy that you're using will not ` + `cache opaque responses by default.`);
} else {
defaultExport.debug(`The response for '${request.url}' returned ` + `a status code of '${response.status}' and won't be cached as a ` + `result.`);
logger.debug(`The response for '${request.url}' returned ` + `a status code of '${response.status}' and won't be cached as a ` + `result.`);
}

@@ -1341,3 +1306,3 @@ }

responseToCache = responseToCache.ok ? responseToCache : null;
responseToCache = responseToCache.status === 200 ? responseToCache : null;
}

@@ -1390,3 +1355,3 @@

{
defaultExport.log(`Using a preloaded navigation response for ` + `'${getFriendlyURL(request.url)}'`);
logger.log(`Using a preloaded navigation response for ` + `'${getFriendlyURL(request.url)}'`);
}

@@ -1446,18 +1411,47 @@

const pluginFilteredRequest = request.clone();
let pluginFilteredRequest = request.clone();
try {
const fetchResponse = await fetch(request, fetchOptions);
let fetchResponse; // See https://github.com/GoogleChrome/workbox/issues/1796
if (request.mode === 'navigate' && fetchOptions && Object.keys(fetchOptions).length > 0) {
pluginFilteredRequest = new Request(request, {
mode: 'same-origin'
});
fetchResponse = await fetch(pluginFilteredRequest, fetchOptions);
} else {
fetchResponse = await fetch(request, fetchOptions);
}
{
defaultExport.debug(`Network request for ` + `'${getFriendlyURL(request.url)}' returned a response with ` + `status '${fetchResponse.status}'.`);
logger.debug(`Network request for ` + `'${getFriendlyURL(request.url)}' returned a response with ` + `status '${fetchResponse.status}'.`);
}
for (const plugin of plugins) {
if (pluginEvents.FETCH_DID_SUCCEED in plugin) {
fetchResponse = await plugin[pluginEvents.FETCH_DID_SUCCEED].call(plugin, {
event,
request: pluginFilteredRequest,
response: fetchResponse
});
{
if (fetchResponse) {
finalAssertExports.isInstance(fetchResponse, Response, {
moduleName: 'Plugin',
funcName: pluginEvents.FETCH_DID_SUCCEED,
isReturnValueProblem: true
});
}
}
}
}
return fetchResponse;
} catch (error) {
{
defaultExport.error(`Network request for ` + `'${getFriendlyURL(request.url)}' threw an error.`, error);
logger.error(`Network request for ` + `'${getFriendlyURL(request.url)}' threw an error.`, error);
}
for (let plugin of failedFetchPlugins) {
for (const plugin of failedFetchPlugins) {
await plugin[pluginEvents.FETCH_DID_FAIL].call(plugin, {

@@ -1497,7 +1491,7 @@ error,

getFriendlyURL: getFriendlyURL,
logger: defaultExport
logger: logger
});
/*
Copyright 2018 Google LLC
Copyright 2019 Google LLC

@@ -1509,69 +1503,49 @@ Use of this source code is governed by an MIT-style

/**
* Logs a warning to the user recommending changing
* to max-age=0 or no-cache.
* Claim any currently available clients once the service worker
* becomes active. This is normally used in conjunction with `skipWaiting()`.
*
* @param {string} cacheControlHeader
*
* @private
* @alias workbox.core.clientsClaim
*/
function showWarning(cacheControlHeader) {
const docsUrl = 'https://developers.google.com/web/tools/workbox/guides/service-worker-checklist#cache-control_of_your_service_worker_file';
defaultExport.warn(`You are setting a 'cache-control' header of ` + `'${cacheControlHeader}' on your service worker file. This should be ` + `set to 'max-age=0' or 'no-cache' to ensure the latest service worker ` + `is served to your users. Learn more here: ${docsUrl}`);
}
const clientsClaim = () => {
addEventListener('activate', () => clients.claim());
};
/*
Copyright 2019 Google LLC
Use of this source code is governed by an MIT-style
license that can be found in the LICENSE file or at
https://opensource.org/licenses/MIT.
*/
/**
* Checks for cache-control header on SW file and
* warns the developer if it exists with a value
* other than max-age=0 or no-cache.
* Get the current cache names used by Workbox.
*
* @return {Promise}
* @private
* `cacheNames.precache` is used for precached assets,
* `cacheNames.googleAnalytics` is used by `workbox-google-analytics` to
* store `analytics.js`, and `cacheNames.runtime` is used for everything else.
*
* @return {Object} An object with `precache`, `runtime`, and
* `googleAnalytics` cache names.
*
* @alias workbox.core.cacheNames
*/
const cacheNames$1 = {
get googleAnalytics() {
return cacheNames.getGoogleAnalyticsName();
},
function checkSWFileCacheHeaders() {
// This is wrapped as an iife to allow async/await while making
// rollup exclude it in builds.
return (async () => {
try {
const swFile = self.location.href;
const response = await fetch(swFile);
get precache() {
return cacheNames.getPrecacheName();
},
if (!response.ok) {
// Response failed so nothing we can check;
return;
}
get runtime() {
return cacheNames.getRuntimeName();
}
if (!response.headers.has('cache-control')) {
// No cache control header.
return;
}
};
const cacheControlHeader = response.headers.get('cache-control');
const maxAgeResult = /max-age\s*=\s*(\d*)/g.exec(cacheControlHeader);
if (maxAgeResult) {
if (parseInt(maxAgeResult[1], 10) === 0) {
return;
}
}
if (cacheControlHeader.indexOf('no-cache') !== -1) {
return;
}
if (cacheControlHeader.indexOf('no-store') !== -1) {
return;
}
showWarning(cacheControlHeader);
} catch (err) {// NOOP
}
})();
}
const finalCheckSWFileCacheHeaders = checkSWFileCacheHeaders;
/*
Copyright 2018 Google LLC
Copyright 2019 Google LLC

@@ -1583,162 +1557,74 @@ Use of this source code is governed by an MIT-style

/**
* This class is never exposed publicly. Inidividual methods are exposed
* using jsdoc alias commands.
* Modifies the default cache names used by the Workbox packages.
* Cache names are generated as `<prefix>-<Cache Name>-<suffix>`.
*
* @memberof workbox.core
* @private
* @param {Object} details
* @param {Object} [details.prefix] The string to add to the beginning of
* the precache and runtime cache names.
* @param {Object} [details.suffix] The string to add to the end of
* the precache and runtime cache names.
* @param {Object} [details.precache] The cache name to use for precache
* caching.
* @param {Object} [details.runtime] The cache name to use for runtime caching.
* @param {Object} [details.googleAnalytics] The cache name to use for
* `workbox-google-analytics` caching.
*
* @alias workbox.core.setCacheNameDetails
*/
class WorkboxCore {
/**
* You should not instantiate this object directly.
*
* @private
*/
constructor() {
// Give our version strings something to hang off of.
try {
self.workbox.v = self.workbox.v || {};
} catch (err) {} // NOOP
// A WorkboxCore instance must be exported before we can use the logger.
// This is so it can get the current log level.
const setCacheNameDetails = details => {
{
Object.keys(details).forEach(key => {
finalAssertExports.isType(details[key], 'string', {
moduleName: 'workbox-core',
funcName: 'setCacheNameDetails',
paramName: `details.${key}`
});
});
{
const padding = ' ';
defaultExport.groupCollapsed('Welcome to Workbox!');
defaultExport.unprefixed.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}).`);
defaultExport.unprefixed.log(`📖 Read the guides and documentation\n` + `${padding}https://developers.google.com/web/tools/workbox/`);
defaultExport.unprefixed.log(`❓ Use the [workbox] tag on Stack Overflow to ask questions\n` + `${padding}https://stackoverflow.com/questions/ask?tags=workbox`);
defaultExport.unprefixed.log(`🐛 Found a bug? Report it on GitHub\n` + `${padding}https://github.com/GoogleChrome/workbox/issues/new`);
defaultExport.groupEnd();
if (typeof finalCheckSWFileCacheHeaders === 'function') {
finalCheckSWFileCacheHeaders();
}
}
}
/**
* Get the current cache names used by Workbox.
*
* `cacheNames.precache` is used for precached assets,
* `cacheNames.googleAnalytics` is used by `workbox-google-analytics` to
* store `analytics.js`,
* and `cacheNames.runtime` is used for everything else.
*
* @return {Object} An object with `precache` and `runtime` cache names.
*
* @alias workbox.core.cacheNames
*/
get cacheNames() {
return {
googleAnalytics: cacheNames.getGoogleAnalyticsName(),
precache: cacheNames.getPrecacheName(),
runtime: cacheNames.getRuntimeName()
};
}
/**
* You can alter the default cache names used by the Workbox modules by
* changing the cache name details.
*
* Cache names are generated as `<prefix>-<Cache Name>-<suffix>`.
*
* @param {Object} details
* @param {Object} details.prefix The string to add to the beginning of
* the precache and runtime cache names.
* @param {Object} details.suffix The string to add to the end of
* the precache and runtime cache names.
* @param {Object} details.precache The cache name to use for precache
* caching.
* @param {Object} details.runtime The cache name to use for runtime caching.
* @param {Object} details.googleAnalytics The cache name to use for
* `workbox-google-analytics` caching.
*
* @alias workbox.core.setCacheNameDetails
*/
setCacheNameDetails(details) {
{
Object.keys(details).forEach(key => {
finalAssertExports.isType(details[key], 'string', {
moduleName: 'workbox-core',
className: 'WorkboxCore',
funcName: 'setCacheNameDetails',
paramName: `details.${key}`
});
if ('precache' in details && details.precache.length === 0) {
throw new WorkboxError('invalid-cache-name', {
cacheNameId: 'precache',
value: details.precache
});
if ('precache' in details && details.precache.length === 0) {
throw new WorkboxError('invalid-cache-name', {
cacheNameId: 'precache',
value: details.precache
});
}
if ('runtime' in details && details.runtime.length === 0) {
throw new WorkboxError('invalid-cache-name', {
cacheNameId: 'runtime',
value: details.runtime
});
}
if ('googleAnalytics' in details && details.googleAnalytics.length === 0) {
throw new WorkboxError('invalid-cache-name', {
cacheNameId: 'googleAnalytics',
value: details.googleAnalytics
});
}
}
cacheNames.updateDetails(details);
}
/**
* Get the current log level.
*
* @return {number}.
*
* @alias workbox.core.logLevel
*/
get logLevel() {
return getLoggerLevel();
}
/**
* Set the current log level passing in one of the values from
* [LOG_LEVELS]{@link module:workbox-core.LOG_LEVELS}.
*
* @param {number} newLevel The new log level to use.
*
* @alias workbox.core.setLogLevel
*/
setLogLevel(newLevel) {
{
finalAssertExports.isType(newLevel, 'number', {
moduleName: 'workbox-core',
className: 'WorkboxCore',
funcName: 'logLevel [setter]',
paramName: `logLevel`
if ('runtime' in details && details.runtime.length === 0) {
throw new WorkboxError('invalid-cache-name', {
cacheNameId: 'runtime',
value: details.runtime
});
}
if (newLevel > LOG_LEVELS.silent || newLevel < LOG_LEVELS.debug) {
throw new WorkboxError('invalid-value', {
paramName: 'logLevel',
validValueDescription: `Please use a value from LOG_LEVELS, i.e ` + `'logLevel = workbox.core.LOG_LEVELS.debug'.`,
value: newLevel
if ('googleAnalytics' in details && details.googleAnalytics.length === 0) {
throw new WorkboxError('invalid-cache-name', {
cacheNameId: 'googleAnalytics',
value: details.googleAnalytics
});
}
setLoggerLevel(newLevel);
}
}
cacheNames.updateDetails(details);
};
var defaultExport$1 = new WorkboxCore();
/*
Copyright 2019 Google LLC
Use of this source code is governed by an MIT-style
license that can be found in the LICENSE file or at
https://opensource.org/licenses/MIT.
*/
/**
* Force a service worker to become active, instead of waiting. This is
* normally used in conjunction with `clientsClaim()`.
*
* @alias workbox.core.skipWaiting
*/
const skipWaiting = () => {
// We need to explicitly call `self.skipWaiting()` here because we're
// shadowing `skipWaiting` with this local function.
addEventListener('install', () => self.skipWaiting());
};
/*

@@ -1751,12 +1637,18 @@ Copyright 2018 Google LLC

*/
const finalExports = Object.assign(defaultExport$1, {
_private,
LOG_LEVELS,
registerQuotaErrorCallback
});
return finalExports;
try {
self.workbox.v = self.workbox.v || {};
} catch (errer) {} // NOOP
}());
exports._private = _private;
exports.clientsClaim = clientsClaim;
exports.cacheNames = cacheNames$1;
exports.registerQuotaErrorCallback = registerQuotaErrorCallback;
exports.setCacheNameDetails = setCacheNameDetails;
exports.skipWaiting = skipWaiting;
return exports;
}({}));
//# sourceMappingURL=workbox-core.dev.js.map

@@ -1,3 +0,3 @@

this.workbox=this.workbox||{},this.workbox.core=function(){"use strict";try{self.workbox.v["workbox:core:4.0.0-beta.0"]=1}catch(e){}var e={debug:0,log:1,warn:2,error:3,silent:4};const t=/^((?!chrome|android).)*safari/i.test(navigator.userAgent);let r=(()=>e.warn)();const n=e=>r<=e,a=e=>r=e,s=()=>r,o=e.error,c=function(r,a,s){const c=0===r.indexOf("group")?o:e[r];if(!n(c))return;if(!s||"groupCollapsed"===r&&t)return void console[r](...a);const i=["%cworkbox",`background: ${s}; color: white; padding: 2px 0.5em; `+"border-radius: 0.5em;"];console[r](...i,...a)},i=()=>{n(o)&&console.groupEnd()},l={groupEnd:i,unprefixed:{groupEnd:i}},u={debug:"#7f8c8d",log:"#2ecc71",warn:"#f39c12",error:"#c0392b",groupCollapsed:"#3498db"};Object.keys(u).forEach(e=>((e,t)=>{l[e]=((...r)=>c(e,r,t)),l.unprefixed[e]=((...t)=>c(e,t))})(e,u[e]));const h=(e,...t)=>{let r=e;return t.length>0&&(r+=` :: ${JSON.stringify(t)}`),r};class g extends Error{constructor(e,t){super(h(e,t)),this.name=e,this.details=t}}const d=new Set;class p{constructor(e,t,{onupgradeneeded:r,onversionchange:n=this.e}={}){this.t=e,this.r=t,this.n=r,this.e=n,this.a=null}get db(){return this.a}async open(){if(!this.a)return this.a=await new Promise((e,t)=>{let r=!1;setTimeout(()=>{r=!0,t(new Error("The open request was blocked and timed out"))},this.OPEN_TIMEOUT);const n=indexedDB.open(this.t,this.r);n.onerror=(()=>t(n.error)),n.onupgradeneeded=(e=>{r?(n.transaction.abort(),e.target.result.close()):this.n&&this.n(e)}),n.onsuccess=(({target:t})=>{const n=t.result;r?n.close():(n.onversionchange=this.e,e(n))})}),this}async getKey(e,t){return(await this.getAllKeys(e,t,1))[0]}async getAll(e,t,r){return await this.getAllMatching(e,{query:t,count:r})}async getAllKeys(e,t,r){return(await this.getAllMatching(e,{query:t,count:r,includeKeys:!0})).map(({key:e})=>e)}async getAllMatching(e,{index:t,query:r=null,direction:n="next",count:a,includeKeys:s}={}){return await this.transaction([e],"readonly",(o,c)=>{const i=o.objectStore(e),l=t?i.index(t):i,u=[];l.openCursor(r,n).onsuccess=(({target:e})=>{const t=e.result;if(t){const{primaryKey:e,key:r,value:n}=t;u.push(s?{primaryKey:e,key:r,value:n}:n),a&&u.length>=a?c(u):t.continue()}else c(u)})})}async transaction(e,t,r){return await this.open(),await new Promise((n,a)=>{const s=this.a.transaction(e,t);s.onabort=(({target:e})=>a(e.error)),s.oncomplete=(()=>n()),r(s,e=>n(e))})}async s(e,t,r,...n){return await this.transaction([t],r,(r,a)=>{r.objectStore(t)[e](...n).onsuccess=(({target:e})=>{a(e.result)})})}e(){this.close()}close(){this.a&&this.a.close()}}p.prototype.OPEN_TIMEOUT=2e3;const w={readonly:["get","count","getKey","getAll","getAllKeys"],readwrite:["add","put","clear","delete"]};for(const[e,t]of Object.entries(w))for(const r of t)r in IDBObjectStore.prototype&&(p.prototype[r]=async function(t,...n){return await this.s(r,t,e,...n)});const f={prefix:"workbox",suffix:self.registration.scope,googleAnalytics:"googleAnalytics",precache:"precache",runtime:"runtime"},y=e=>[f.prefix,e,f.suffix].filter(e=>e.length>0).join("-"),m={updateDetails:e=>{Object.keys(f).forEach(t=>{void 0!==e[t]&&(f[t]=e[t])})},getGoogleAnalyticsName:e=>e||y(f.googleAnalytics),getPrecacheName:e=>e||y(f.precache),getRuntimeName:e=>e||y(f.runtime)};var v="cacheDidUpdate",b="cacheWillUpdate",q="cachedResponseWillBeUsed",E="fetchDidFail",L="requestWillFetch",x=(e,t)=>e.filter(e=>t in e);const N=e=>{const t=new URL(e,location);return t.origin===location.origin?t.pathname:t.href},O=async({cacheName:e,request:t,event:r,matchOptions:n,plugins:a=[]})=>{const s=await caches.open(e);let o=await s.match(t,n);for(let s of a)q in s&&(o=await s[q].call(s,{cacheName:e,request:t,event:r,matchOptions:n,cachedResponse:o}));return o},k=async({request:e,response:t,event:r,plugins:n})=>{let a=t,s=!1;for(let t of n)if(b in t&&(s=!0,!(a=await t[b].call(t,{request:e,response:a,event:r}))))break;return s||(a=a.ok?a:null),a||null},D={put:async({cacheName:e,request:t,response:r,event:n,plugins:a=[]}={})=>{if(!r)throw new g("cache-put-with-no-response",{url:N(t.url)});let s=await k({request:t,response:r,event:n,plugins:a});if(!s)return;const o=await caches.open(e),c=x(a,v);let i=c.length>0?await O({cacheName:e,request:t}):null;try{await o.put(t,s)}catch(e){throw"QuotaExceededError"===e.name&&await async function(){for(const e of d)await e()}(),e}for(let r of c)await r[v].call(r,{cacheName:e,request:t,event:n,oldResponse:i,newResponse:s})},match:O},A={fetch:async({request:e,fetchOptions:t,event:r,plugins:n=[]})=>{if(r&&r.preloadResponse){const e=await r.preloadResponse;if(e)return e}"string"==typeof e&&(e=new Request(e));const a=x(n,E),s=a.length>0?e.clone():null;try{for(let t of n)L in t&&(e=await t[L].call(t,{request:e.clone(),event:r}))}catch(e){throw new g("plugin-error-request-will-fetch",{thrownError:e})}const o=e.clone();try{return await fetch(e,t)}catch(e){for(let t of a)await t[E].call(t,{error:e,event:r,originalRequest:s.clone(),request:o.clone()});throw e}}};var R=Object.freeze({DBWrapper:p,deleteDatabase:async e=>{await new Promise((t,r)=>{const n=indexedDB.deleteDatabase(e);n.onerror=(({target:e})=>{r(e.error)}),n.onblocked=(()=>{r(new Error("Delete blocked"))}),n.onsuccess=(()=>{t()})})},migrateDb:(e,t)=>{let{oldVersion:r,newVersion:n}=e;const a=e=>{const r=()=>{++e<=n&&a(e)},s=t[`v${e}`];"function"==typeof s?s(r):r()};a(r)},WorkboxError:g,assert:null,cacheNames:m,cacheWrapper:D,fetchWrapper:A,getFriendlyURL:N,logger:l});var K=new class{constructor(){try{self.workbox.v=self.workbox.v||{}}catch(e){}}get cacheNames(){return{googleAnalytics:m.getGoogleAnalyticsName(),precache:m.getPrecacheName(),runtime:m.getRuntimeName()}}setCacheNameDetails(e){m.updateDetails(e)}get logLevel(){return s()}setLogLevel(t){if(t>e.silent||t<e.debug)throw new g("invalid-value",{paramName:"logLevel",validValueDescription:"Please use a value from LOG_LEVELS, i.e 'logLevel = workbox.core.LOG_LEVELS.debug'.",value:t});a(t)}};return Object.assign(K,{_private:R,LOG_LEVELS:e,registerQuotaErrorCallback:function(e){d.add(e)}})}();
this.workbox=this.workbox||{},this.workbox.core=function(e){"use strict";try{self.workbox.v["workbox:core:4.0.0-beta.1"]=1}catch(e){}const t=(e,...t)=>{let n=e;return t.length>0&&(n+=` :: ${JSON.stringify(t)}`),n};class n extends Error{constructor(e,n){super(t(e,n)),this.name=e,this.details=n}}const s=new Set;class r{constructor(e,t,{onupgradeneeded:n,onversionchange:s=this.e}={}){this.t=e,this.n=t,this.s=n,this.e=s,this.r=null}get db(){return this.r}async open(){if(!this.r)return this.r=await new Promise((e,t)=>{let n=!1;setTimeout(()=>{n=!0,t(new Error("The open request was blocked and timed out"))},this.OPEN_TIMEOUT);const s=indexedDB.open(this.t,this.n);s.onerror=(()=>t(s.error)),s.onupgradeneeded=(e=>{n?(s.transaction.abort(),e.target.result.close()):this.s&&this.s(e)}),s.onsuccess=(({target:t})=>{const s=t.result;n?s.close():(s.onversionchange=this.e,e(s))})}),this}async getKey(e,t){return(await this.getAllKeys(e,t,1))[0]}async getAll(e,t,n){return await this.getAllMatching(e,{query:t,count:n})}async getAllKeys(e,t,n){return(await this.getAllMatching(e,{query:t,count:n,includeKeys:!0})).map(({key:e})=>e)}async getAllMatching(e,{index:t,query:n=null,direction:s="next",count:r,includeKeys:a}={}){return await this.transaction([e],"readonly",(i,c)=>{const o=i.objectStore(e),l=t?o.index(t):o,u=[];l.openCursor(n,s).onsuccess=(({target:e})=>{const t=e.result;if(t){const{primaryKey:e,key:n,value:s}=t;u.push(a?{primaryKey:e,key:n,value:s}:s),r&&u.length>=r?c(u):t.continue()}else c(u)})})}async transaction(e,t,n){return await this.open(),await new Promise((s,r)=>{const a=this.r.transaction(e,t);a.onabort=(({target:e})=>r(e.error)),a.oncomplete=(()=>s()),n(a,e=>s(e))})}async a(e,t,n,...s){return await this.transaction([t],n,(n,r)=>{n.objectStore(t)[e](...s).onsuccess=(({target:e})=>{r(e.result)})})}e(){this.close()}close(){this.r&&this.r.close()}}r.prototype.OPEN_TIMEOUT=2e3;const a={readonly:["get","count","getKey","getAll","getAllKeys"],readwrite:["add","put","clear","delete"]};for(const[e,t]of Object.entries(a))for(const n of t)n in IDBObjectStore.prototype&&(r.prototype[n]=async function(t,...s){return await this.a(n,t,e,...s)});const i={googleAnalytics:"googleAnalytics",precache:"precache-v2",prefix:"workbox",runtime:"runtime",suffix:self.registration.scope},c=e=>[i.prefix,e,i.suffix].filter(e=>e.length>0).join("-"),o={updateDetails:e=>{Object.keys(i).forEach(t=>{void 0!==e[t]&&(i[t]=e[t])})},getGoogleAnalyticsName:e=>e||c(i.googleAnalytics),getPrecacheName:e=>e||c(i.precache),getRuntimeName:e=>e||c(i.runtime)},l="cacheDidUpdate",u="cacheWillUpdate",h="cachedResponseWillBeUsed",w="fetchDidFail",f="fetchDidSucceed",d="requestWillFetch",g=(e,t)=>e.filter(e=>t in e),y=e=>{const t=new URL(e,location);return t.origin===location.origin?t.pathname:t.href},p=async({cacheName:e,request:t,event:n,matchOptions:s,plugins:r=[]})=>{const a=await caches.open(e);let i=await a.match(t,s);for(const a of r)h in a&&(i=await a[h].call(a,{cacheName:e,request:t,event:n,matchOptions:s,cachedResponse:i}));return i},m=async({request:e,response:t,event:n,plugins:s})=>{let r=t,a=!1;for(let t of s)if(u in t&&(a=!0,!(r=await t[u].call(t,{request:e,response:r,event:n}))))break;return a||(r=200===r.status?r:null),r||null},v={put:async({cacheName:e,request:t,response:r,event:a,plugins:i=[]}={})=>{if(!r)throw new n("cache-put-with-no-response",{url:y(t.url)});let c=await m({request:t,response:r,event:a,plugins:i});if(!c)return;const o=await caches.open(e),u=g(i,l);let h=u.length>0?await p({cacheName:e,request:t}):null;try{await o.put(t,c)}catch(e){throw"QuotaExceededError"===e.name&&await async function(){for(const e of s)await e()}(),e}for(let n of u)await n[l].call(n,{cacheName:e,request:t,event:a,oldResponse:h,newResponse:c})},match:p},q={fetch:async({request:e,fetchOptions:t,event:s,plugins:r=[]})=>{if(s&&s.preloadResponse){const e=await s.preloadResponse;if(e)return e}"string"==typeof e&&(e=new Request(e));const a=g(r,w),i=a.length>0?e.clone():null;try{for(let t of r)d in t&&(e=await t[d].call(t,{request:e.clone(),event:s}))}catch(e){throw new n("plugin-error-request-will-fetch",{thrownError:e})}let c=e.clone();try{let n;"navigate"===e.mode&&t&&Object.keys(t).length>0?(c=new Request(e,{mode:"same-origin"}),n=await fetch(c,t)):n=await fetch(e,t);for(const e of r)f in e&&(n=await e[f].call(e,{event:s,request:c,response:n}));return n}catch(e){for(const t of a)await t[w].call(t,{error:e,event:s,originalRequest:i.clone(),request:c.clone()});throw e}}};var b=Object.freeze({DBWrapper:r,deleteDatabase:async e=>{await new Promise((t,n)=>{const s=indexedDB.deleteDatabase(e);s.onerror=(({target:e})=>{n(e.error)}),s.onblocked=(()=>{n(new Error("Delete blocked"))}),s.onsuccess=(()=>{t()})})},migrateDb:(e,t)=>{let{oldVersion:n,newVersion:s}=e;const r=e=>{const n=()=>{++e<=s&&r(e)},a=t[`v${e}`];"function"==typeof a?a(n):n()};r(n)},WorkboxError:n,assert:null,cacheNames:o,cacheWrapper:v,fetchWrapper:q,getFriendlyURL:y,logger:null});const D={get googleAnalytics(){return o.getGoogleAnalyticsName()},get precache(){return o.getPrecacheName()},get runtime(){return o.getRuntimeName()}};try{self.workbox.v=self.workbox.v||{}}catch(e){}return e._private=b,e.clientsClaim=(()=>{addEventListener("activate",()=>clients.claim())}),e.cacheNames=D,e.registerQuotaErrorCallback=function(e){s.add(e)},e.setCacheNameDetails=(e=>{o.updateDetails(e)}),e.skipWaiting=(()=>{addEventListener("install",()=>self.skipWaiting())}),e}({});
//# sourceMappingURL=workbox-core.prod.js.map
{
"name": "workbox-core",
"version": "4.0.0-beta.0",
"version": "4.0.0-beta.1",
"license": "MIT",

@@ -27,3 +27,3 @@ "author": "Google's Web DevRel Team",

"module": "index.mjs",
"gitHead": "bc90cc4bdb1f8ad435564aa84b0c90acfac611e2"
"gitHead": "dda07c48e184f57ce5dfe3b3e93af316989a0877"
}

Sorry, the diff of this file is not supported yet

Sorry, the diff of this file is not supported yet

Sorry, the diff of this file is not supported yet

Sorry, the diff of this file is not supported yet

Sorry, the diff of this file is not supported yet

Sorry, the diff of this file is not supported yet

Sorry, the diff of this file is not supported yet

Sorry, the diff of this file is not supported yet

Sorry, the diff of this file is not supported yet

Sorry, the diff of this file is not supported yet

Sorry, the diff of this file is not supported yet

Sorry, the diff of this file is not supported yet

Sorry, the diff of this file is not supported yet

Sorry, the diff of this file is not supported yet

Sorry, the diff of this file is not supported yet

SocketSocket SOC 2 Logo

Product

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

Packages

npm

Stay in touch

Get open source security insights delivered straight into your inbox.


  • Terms
  • Privacy
  • Security

Made with ⚡️ by Socket Inc