Socket
Socket
Sign inDemoInstall

workbox-core

Package Overview
Dependencies
Maintainers
4
Versions
84
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 3.4.1 to 3.5.0

828

build/workbox-core.dev.js

@@ -43,3 +43,3 @@ /* eslint-disable */

try {
self.workbox.v['workbox:core:3.4.1'] = 1;
self.workbox.v['workbox:core:3.5.0'] = 1;
} catch (e) {} // eslint-disable-line

@@ -101,2 +101,80 @@

// Safari doesn't print all console.groupCollapsed() arguments.
// Related bug: https://bugs.webkit.org/show_bug.cgi?id=182754
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 getDefaultLogLevel = () => LOG_LEVELS.log;
let logLevel = getDefaultLogLevel();
const shouldPrint = minLevel => logLevel <= minLevel;
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;
}
if (!levelColor || keyName === 'groupCollapsed' && isSafari) {
console[keyName](...logArgs);
return;
}
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]));
/*
Copyright 2017 Google Inc.
Licensed under the Apache License, Version 2.0 (the "License");
you may not use this file except in compliance with the License.
You may obtain a copy of the License at
https://www.apache.org/licenses/LICENSE-2.0
Unless required by applicable law or agreed to in writing, software
distributed under the License is distributed on an "AS IS" BASIS,
WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
See the License for the specific language governing permissions and
limitations under the License.
*/
var messages = {

@@ -356,128 +434,3 @@ 'invalid-value': ({ paramName, validValueDescription, value }) => {

const _cacheNameDetails = {
prefix: 'workbox',
suffix: self.registration.scope,
googleAnalytics: 'googleAnalytics',
precache: 'precache',
runtime: 'runtime'
};
const _createCacheName = cacheName => {
return [_cacheNameDetails.prefix, cacheName, _cacheNameDetails.suffix].filter(value => value.length > 0).join('-');
};
const cacheNames = {
updateDetails: details => {
Object.keys(_cacheNameDetails).forEach(key => {
if (typeof details[key] !== 'undefined') {
_cacheNameDetails[key] = details[key];
}
});
},
getGoogleAnalyticsName: userCacheName => {
return userCacheName || _createCacheName(_cacheNameDetails.googleAnalytics);
},
getPrecacheName: userCacheName => {
return userCacheName || _createCacheName(_cacheNameDetails.precache);
},
getRuntimeName: userCacheName => {
return userCacheName || _createCacheName(_cacheNameDetails.runtime);
}
};
/*
Copyright 2017 Google Inc.
Licensed under the Apache License, Version 2.0 (the "License");
you may not use this file except in compliance with the License.
You may obtain a copy of the License at
https://www.apache.org/licenses/LICENSE-2.0
Unless required by applicable law or agreed to in writing, software
distributed under the License is distributed on an "AS IS" BASIS,
WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
See the License for the specific language governing permissions and
limitations under the License.
*/
// Safari doesn't print all console.groupCollapsed() arguments.
// Related bug: https://bugs.webkit.org/show_bug.cgi?id=182754
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 getDefaultLogLevel = () => LOG_LEVELS.log;
let logLevel = getDefaultLogLevel();
const shouldPrint = minLevel => logLevel <= minLevel;
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;
}
if (!levelColor || keyName === 'groupCollapsed' && isSafari) {
console[keyName](...logArgs);
return;
}
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]));
/*
Copyright 2017 Google Inc.
Licensed under the Apache License, Version 2.0 (the "License");
you may not use this file except in compliance with the License.
You may obtain a copy of the License at
https://www.apache.org/licenses/LICENSE-2.0
Unless required by applicable law or agreed to in writing, software
distributed under the License is distributed on an "AS IS" BASIS,
WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
See the License for the specific language governing permissions and
limitations under the License.
*/
/*
* This method returns true if the current context is a service worker.

@@ -567,253 +520,57 @@ */

/*
Copyright 2017 Google Inc.
Licensed under the Apache License, Version 2.0 (the "License");
you may not use this file except in compliance with the License.
You may obtain a copy of the License at
https://www.apache.org/licenses/LICENSE-2.0
Unless required by applicable law or agreed to in writing, software
distributed under the License is distributed on an "AS IS" BASIS,
WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
See the License for the specific language governing permissions and
limitations under the License.
*/
/**
* Logs a warning to the user recommending changing
* to max-age=0 or no-cache.
* Runs all of the callback functions, one at a time sequentially, in the order
* in which they were registered.
*
* @param {string} cacheControlHeader
*
* @memberof workbox.core
* @private
*/
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}`);
}
let executeQuotaErrorCallbacks = (() => {
var _ref = babelHelpers.asyncToGenerator(function* () {
{
defaultExport.log(`About to run ${callbacks.size} callbacks to clean up caches.`);
}
/**
* 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.
*
* @return {Promise}
* @private
*/
function checkSWFileCacheHeaders() {
// This is wrapped as an iife to allow async/await while making
// rollup exclude it in builds.
return babelHelpers.asyncToGenerator(function* () {
try {
const swFile = self.location.href;
const response = yield fetch(swFile);
if (!response.ok) {
// Response failed so nothing we can check;
return;
for (const callback of callbacks) {
yield callback();
{
defaultExport.log(callback, 'is complete.');
}
}
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
{
defaultExport.log('Finished running callbacks.');
}
})();
}
});
const finalCheckSWFileCacheHeaders = checkSWFileCacheHeaders;
return function executeQuotaErrorCallbacks() {
return _ref.apply(this, arguments);
};
})();
/*
Copyright 2017 Google Inc.
const callbacks = new Set();
Licensed under the Apache License, Version 2.0 (the "License");
you may not use this file except in compliance with the License.
You may obtain a copy of the License at
https://www.apache.org/licenses/LICENSE-2.0
Unless required by applicable law or agreed to in writing, software
distributed under the License is distributed on an "AS IS" BASIS,
WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
See the License for the specific language governing permissions and
limitations under the License.
*/
/**
* This class is never exposed publicly. Inidividual methods are exposed
* using jsdoc alias commands.
* Adds a function to the set of callbacks that will be executed when there's
* a quota error.
*
* @param {Function} callback
* @memberof workbox.core
* @private
*/
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 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();
}
}
function registerQuotaErrorCallback(callback) {
{
finalAssertExports.isType(callback, 'function', {
moduleName: 'workbox-core',
funcName: 'register',
paramName: 'callback'
});
}
/**
* 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()
};
}
callbacks.add(callback);
/**
* 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 ('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);
{
defaultExport.log('Registered a callback to respond to quota errors.', callback);
}
/**
* 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 (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
});
}
setLoggerLevel(newLevel);
}
}
var defaultExport$1 = new WorkboxCore();
/*

@@ -1213,2 +970,49 @@ Copyright 2017 Google Inc.

const _cacheNameDetails = {
prefix: 'workbox',
suffix: self.registration.scope,
googleAnalytics: 'googleAnalytics',
precache: 'precache',
runtime: 'runtime'
};
const _createCacheName = cacheName => {
return [_cacheNameDetails.prefix, cacheName, _cacheNameDetails.suffix].filter(value => value.length > 0).join('-');
};
const cacheNames = {
updateDetails: details => {
Object.keys(_cacheNameDetails).forEach(key => {
if (typeof details[key] !== 'undefined') {
_cacheNameDetails[key] = details[key];
}
});
},
getGoogleAnalyticsName: userCacheName => {
return userCacheName || _createCacheName(_cacheNameDetails.googleAnalytics);
},
getPrecacheName: userCacheName => {
return userCacheName || _createCacheName(_cacheNameDetails.precache);
},
getRuntimeName: userCacheName => {
return userCacheName || _createCacheName(_cacheNameDetails.runtime);
}
};
/*
Copyright 2017 Google Inc.
Licensed under the Apache License, Version 2.0 (the "License");
you may not use this file except in compliance with the License.
You may obtain a copy of the License at
https://www.apache.org/licenses/LICENSE-2.0
Unless required by applicable law or agreed to in writing, software
distributed under the License is distributed on an "AS IS" BASIS,
WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
See the License for the specific language governing permissions and
limitations under the License.
*/
var pluginEvents = {

@@ -1244,57 +1048,2 @@ CACHE_DID_UPDATE: 'cacheDidUpdate',

/**
* Runs all of the callback functions, one at a time sequentially, in the order
* in which they were registered.
*
* @memberof workbox.core
* @private
*/
let executeQuotaErrorCallbacks = (() => {
var _ref = babelHelpers.asyncToGenerator(function* () {
{
defaultExport.log(`About to run ${callbacks.size} callbacks to clean up caches.`);
}
for (const callback of callbacks) {
yield callback();
{
defaultExport.log(callback, 'is complete.');
}
}
{
defaultExport.log('Finished running callbacks.');
}
});
return function executeQuotaErrorCallbacks() {
return _ref.apply(this, arguments);
};
})();
const callbacks = new Set();
/**
* Adds a function to the set of callbacks that will be executed when there's
* a quota error.
*
* @param {Function} callback
* @memberof workbox.core
*/
function registerQuotaErrorCallback(callback) {
{
finalAssertExports.isType(callback, 'function', {
moduleName: 'workbox-core',
funcName: 'register',
paramName: 'callback'
});
}
callbacks.add(callback);
{
defaultExport.log('Registered a callback to respond to quota errors.', callback);
}
}
/*

@@ -1686,4 +1435,3 @@ Copyright 2017 Google Inc.

getFriendlyURL: getFriendlyURL,
logger: defaultExport,
registerQuotaErrorCallback: registerQuotaErrorCallback
logger: defaultExport
});

@@ -1707,5 +1455,257 @@

/**
* Logs a warning to the user recommending changing
* to max-age=0 or no-cache.
*
* @param {string} cacheControlHeader
*
* @private
*/
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}`);
}
/**
* 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.
*
* @return {Promise}
* @private
*/
function checkSWFileCacheHeaders() {
// This is wrapped as an iife to allow async/await while making
// rollup exclude it in builds.
return babelHelpers.asyncToGenerator(function* () {
try {
const swFile = self.location.href;
const response = yield fetch(swFile);
if (!response.ok) {
// Response failed so nothing we can check;
return;
}
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 2017 Google Inc.
Licensed under the Apache License, Version 2.0 (the "License");
you may not use this file except in compliance with the License.
You may obtain a copy of the License at
https://www.apache.org/licenses/LICENSE-2.0
Unless required by applicable law or agreed to in writing, software
distributed under the License is distributed on an "AS IS" BASIS,
WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
See the License for the specific language governing permissions and
limitations under the License.
*/
/**
* This class is never exposed publicly. Inidividual methods are exposed
* using jsdoc alias commands.
*
* @memberof workbox.core
* @private
*/
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 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 ('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 (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
});
}
setLoggerLevel(newLevel);
}
}
var defaultExport$1 = new WorkboxCore();
/*
Copyright 2017 Google Inc.
Licensed under the Apache License, Version 2.0 (the "License");
you may not use this file except in compliance with the License.
You may obtain a copy of the License at
https://www.apache.org/licenses/LICENSE-2.0
Unless required by applicable law or agreed to in writing, software
distributed under the License is distributed on an "AS IS" BASIS,
WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
See the License for the specific language governing permissions and
limitations under the License.
*/
const finalExports = Object.assign(defaultExport$1, {
_private,
LOG_LEVELS,
_private
registerQuotaErrorCallback
});

@@ -1712,0 +1712,0 @@

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

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

@@ -5,0 +5,0 @@ "author": "Google's Web DevRel Team",

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