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.6.2 to 4.0.0-alpha.0

_private/Deferred.mjs

1462

build/workbox-core.dev.js

@@ -1,38 +0,1 @@

/* eslint-disable */
// This is extracted from the Babel runtime (original source: https://github.com/babel/babel/blob/9e0f5235b1ca5167c368a576ad7c5af62d20b0e3/packages/babel-helpers/src/helpers.js#L240).
// As part of the Rollup bundling process, it's injected once into workbox-core
// and reused throughout all of the other modules, avoiding code duplication.
// See https://github.com/GoogleChrome/workbox/pull/1048#issuecomment-344698046
// for further background.
self.babelHelpers = {
asyncToGenerator: function(fn) {
return function() {
var gen = fn.apply(this, arguments);
return new Promise(function(resolve, reject) {
function step(key, arg) {
try {
var info = gen[key](arg);
var value = info.value;
} catch (error) {
reject(error);
return;
}
if (info.done) {
resolve(value);
} else {
return Promise.resolve(value).then(function(value) {
step('next', value);
}, function(err) {
step('throw', err);
});
}
}
return step('next');
});
};
},
};
this.workbox = this.workbox || {};

@@ -43,21 +6,12 @@ this.workbox.core = (function () {

try {
self.workbox.v['workbox:core:3.6.2'] = 1;
self.workbox.v['workbox:core:4.0.0-alpha.0'] = 1;
} catch (e) {} // eslint-disable-line
/*
Copyright 2017 Google Inc.
Copyright 2018 Google LLC
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.
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.
*/
/**

@@ -86,21 +40,11 @@ * The available log levels in Workbox: debug, log, warn, error and silent.

/*
Copyright 2017 Google Inc.
Copyright 2018 Google LLC
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.
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
// 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`;

@@ -115,7 +59,10 @@ const GREEN = `#2ecc71`;

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 getLoggerLevel = () => logLevel; // We always want groups to be logged unless logLevel is silent.
const groupLevel = LOG_LEVELS.error;

@@ -125,2 +72,3 @@

const logLevel = keyName.indexOf('group') === 0 ? groupLevel : LOG_LEVELS[keyName];
if (!shouldPrint(logLevel)) {

@@ -154,2 +102,3 @@ return;

defaultExport[keyName] = (...args) => _print(keyName, args, color);
defaultExport.unprefixed[keyName] = (...args) => _print(keyName, args);

@@ -168,49 +117,62 @@ };

/*
Copyright 2017 Google Inc.
Copyright 2018 Google LLC
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.
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.
*/
var messages = {
'invalid-value': ({ paramName, validValueDescription, value }) => {
'invalid-value': ({
paramName,
validValueDescription,
value
}) => {
if (!paramName || !validValueDescription) {
throw new Error(`Unexpected input to 'invalid-value' error.`);
}
return `The '${paramName}' parameter was given a value with an ` + `unexpected value. ${validValueDescription} Received a value of ` + `${JSON.stringify(value)}.`;
},
'not-in-sw': ({ moduleName }) => {
'not-in-sw': ({
moduleName
}) => {
if (!moduleName) {
throw new Error(`Unexpected input to 'not-in-sw' error.`);
}
return `The '${moduleName}' must be used in a service worker.`;
},
'not-an-array': ({ moduleName, className, funcName, paramName }) => {
'not-an-array': ({
moduleName,
className,
funcName,
paramName
}) => {
if (!moduleName || !className || !funcName || !paramName) {
throw new Error(`Unexpected input to 'not-an-array' error.`);
}
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) {
throw new Error(`Unexpected input to 'incorrect-type' error.`);
}
return `The parameter '${paramName}' passed into ` + `'${moduleName}.${className ? className + '.' : ''}` + `${funcName}()' must be of type ${expectedType}.`;
},
'incorrect-class': ({ expectedClass, paramName, moduleName, className,
funcName, isReturnValueProblem }) => {
'incorrect-class': ({
expectedClass,
paramName,
moduleName,
className,
funcName,
isReturnValueProblem
}) => {
if (!expectedClass || !moduleName || !funcName) {

@@ -226,16 +188,24 @@ throw new Error(`Unexpected input to 'incorrect-class' error.`);

},
'missing-a-method': ({ 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.`;
},
'add-to-cache-list-unexpected-type': ({ entry }) => {
'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.`;
},
'add-to-cache-list-conflicting-entries': ({ firstEntry, secondEntry }) => {
'add-to-cache-list-conflicting-entries': ({
firstEntry,
secondEntry
}) => {
if (!firstEntry || !secondEntry) {

@@ -247,4 +217,5 @@ throw new Error(`Unexpected input to ` + `'add-to-cache-list-duplicate-entries' error.`);

},
'plugin-error-request-will-fetch': ({ thrownError }) => {
'plugin-error-request-will-fetch': ({
thrownError
}) => {
if (!thrownError) {

@@ -256,4 +227,6 @@ throw new Error(`Unexpected input to ` + `'plugin-error-request-will-fetch', error.`);

},
'invalid-cache-name': ({ cacheNameId, value }) => {
'invalid-cache-name': ({
cacheNameId,
value
}) => {
if (!cacheNameId) {

@@ -265,4 +238,5 @@ throw new Error(`Expected a 'cacheNameId' for error 'invalid-cache-name'`);

},
'unregister-route-but-not-found-with-method': ({ method }) => {
'unregister-route-but-not-found-with-method': ({
method
}) => {
if (!method) {

@@ -274,40 +248,64 @@ throw new Error(`Unexpected input to ` + `'unregister-route-but-not-found-with-method' error.`);

},
'unregister-route-route-not-registered': () => {
return `The route you're trying to unregister was not previously ` + `registered.`;
},
'queue-replay-failed': ({ name, count }) => {
'queue-replay-failed': ({
name,
count
}) => {
return `${count} requests failed, while trying to replay Queue: ${name}.`;
},
'duplicate-queue-name': ({ name }) => {
'duplicate-queue-name': ({
name
}) => {
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 }) => {
'expired-test-without-max-age': ({
methodName,
paramName
}) => {
return `The '${methodName}()' method can only be used when the ` + `'${paramName}' is used in the constructor.`;
},
'unsupported-route-type': ({ moduleName, className, funcName, paramName }) => {
'unsupported-route-type': ({
moduleName,
className,
funcName,
paramName
}) => {
return `The supplied '${paramName}' parameter was an unsupported type. ` + `Please check the docs for ${moduleName}.${className}.${funcName} for ` + `valid input types.`;
},
'not-array-of-class': ({ value, expectedClass,
moduleName, className, funcName, paramName }) => {
'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.`;
},
'max-entries-or-age-required': ({ moduleName, className, funcName }) => {
'max-entries-or-age-required': ({
moduleName,
className,
funcName
}) => {
return `You must define either config.maxEntries or config.maxAgeSeconds` + `in ${moduleName}.${className}.${funcName}`;
},
'statuses-or-headers-required': ({ moduleName, className, funcName }) => {
'statuses-or-headers-required': ({
moduleName,
className,
funcName
}) => {
return `You must define either config.statuses or config.headers` + `in ${moduleName}.${className}.${funcName}`;
},
'invalid-string': ({ moduleName, className, funcName, paramName }) => {
'invalid-string': ({
moduleName,
className,
funcName,
paramName
}) => {
if (!paramName || !moduleName || !className || !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.`;

@@ -324,18 +322,27 @@ },

},
'unit-must-be-bytes': ({ normalizedRangeHeader }) => {
'unit-must-be-bytes': ({
normalizedRangeHeader
}) => {
if (!normalizedRangeHeader) {
throw new Error(`Unexpected input to 'unit-must-be-bytes' error.`);
}
return `The 'unit' portion of the Range header must be set to 'bytes'. ` + `The Range header provided was "${normalizedRangeHeader}"`;
},
'single-range-only': ({ normalizedRangeHeader }) => {
'single-range-only': ({
normalizedRangeHeader
}) => {
if (!normalizedRangeHeader) {
throw new Error(`Unexpected input to 'single-range-only' error.`);
}
return `Multiple ranges are not supported. Please use a single start ` + `value, and optional end value. The Range header provided was ` + `"${normalizedRangeHeader}"`;
},
'invalid-range-values': ({ normalizedRangeHeader }) => {
'invalid-range-values': ({
normalizedRangeHeader
}) => {
if (!normalizedRangeHeader) {
throw new Error(`Unexpected input to 'invalid-range-values' error.`);
}
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}"`;

@@ -346,10 +353,31 @@ },

},
'range-not-satisfiable': ({ size, start, end }) => {
'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.`;
},
'attempt-to-cache-non-get-request': ({ url, method }) => {
'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.`;
},
'cache-put-with-no-response': ({ url }) => {
'cache-put-with-no-response': ({
url
}) => {
return `There was an attempt to cache '${url}' but the response was not ` + `defined.`;
},
'no-response': ({
url,
error
}) => {
let message = `The strategy could not generate a response for '${url}'.`;
if (error) {
message += ` The underlying error is ${error}.`;
}
return message;
}

@@ -359,15 +387,7 @@ };

/*
Copyright 2017 Google Inc.
Copyright 2018 Google LLC
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.
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.
*/

@@ -377,2 +397,3 @@

const message = messages[code];
if (!message) {

@@ -388,17 +409,8 @@ throw new Error(`Unable to find message for code '${code}'.`);

/*
Copyright 2017 Google Inc.
Copyright 2018 Google LLC
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.
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.
*/
/**

@@ -413,2 +425,3 @@ * Workbox errors should be thrown with this class.

*/
class WorkboxError extends Error {

@@ -425,35 +438,27 @@ /**

let message = exportedValue(errorCode, details);
super(message);
this.name = errorCode;
this.details = details;
}
}
/*
Copyright 2017 Google Inc.
Copyright 2018 Google LLC
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.
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.
*/
/*
* This method returns true if the current context is a service worker.
*/
const isSwEnv = moduleName => {
if (!('ServiceWorkerGlobalScope' in self)) {
throw new WorkboxError('not-in-sw', { moduleName });
throw new WorkboxError('not-in-sw', {
moduleName
});
}
};
/*

@@ -465,3 +470,10 @@ * This method throws if the supplied value is not an array.

*/
const isArray = (value, { moduleName, className, funcName, paramName }) => {
const isArray = (value, {
moduleName,
className,
funcName,
paramName
}) => {
if (!Array.isArray(value)) {

@@ -477,26 +489,60 @@ throw new WorkboxError('not-an-array', {

const hasMethod = (object, expectedMethod, { moduleName, className, funcName, paramName }) => {
const hasMethod = (object, expectedMethod, {
moduleName,
className,
funcName,
paramName
}) => {
const type = typeof object[expectedMethod];
if (type !== 'function') {
throw new WorkboxError('missing-a-method', { paramName, expectedMethod,
moduleName, className, funcName });
throw new WorkboxError('missing-a-method', {
paramName,
expectedMethod,
moduleName,
className,
funcName
});
}
};
const isType = (object, expectedType, { moduleName, className, funcName, paramName }) => {
const isType = (object, expectedType, {
moduleName,
className,
funcName,
paramName
}) => {
if (typeof object !== expectedType) {
throw new WorkboxError('incorrect-type', { paramName, expectedType,
moduleName, className, funcName });
throw new WorkboxError('incorrect-type', {
paramName,
expectedType,
moduleName,
className,
funcName
});
}
};
const isInstance = (object, expectedClass, { moduleName, className, funcName,
paramName, isReturnValueProblem }) => {
const isInstance = (object, expectedClass, {
moduleName,
className,
funcName,
paramName,
isReturnValueProblem
}) => {
if (!(object instanceof expectedClass)) {
throw new WorkboxError('incorrect-class', { paramName, expectedClass,
moduleName, className, funcName, isReturnValueProblem });
throw new WorkboxError('incorrect-class', {
paramName,
expectedClass,
moduleName,
className,
funcName,
isReturnValueProblem
});
}
};
const isOneOf = (value, validValues, { paramName }) => {
const isOneOf = (value, validValues, {
paramName
}) => {
if (!validValues.includes(value)) {

@@ -511,7 +557,17 @@ throw new WorkboxError('invalid-value', {

const isArrayOfClass = (value, expectedClass, { moduleName, className, funcName, paramName }) => {
const isArrayOfClass = (value, expectedClass, {
moduleName,
className,
funcName,
paramName
}) => {
const error = new WorkboxError('not-array-of-class', {
value, expectedClass,
moduleName, className, funcName, paramName
value,
expectedClass,
moduleName,
className,
funcName,
paramName
});
if (!Array.isArray(value)) {

@@ -538,34 +594,10 @@ throw error;

/**
* 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.`);
}
/*
Copyright 2018 Google LLC
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);
};
})();
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.
*/
const callbacks = new Set();
/**

@@ -578,2 +610,3 @@ * Adds a function to the set of callbacks that will be executed when there's

*/
function registerQuotaErrorCallback(callback) {

@@ -594,19 +627,36 @@ {

}
/**
* Runs all of the callback functions, one at a time sequentially, in the order
* in which they were registered.
*
* @memberof workbox.core
* @private
*/
/*
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
async function executeQuotaErrorCallbacks() {
{
defaultExport.log(`About to run ${callbacks.size} callbacks to clean up caches.`);
}
https://www.apache.org/licenses/LICENSE-2.0
for (const callback of callbacks) {
await callback();
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.
{
defaultExport.log(callback, 'is complete.');
}
}
{
defaultExport.log('Finished running callbacks.');
}
}
/*
Copyright 2018 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.
*/
/**

@@ -619,2 +669,3 @@ * A class that wraps common IndexedDB functionality in a promise-based API.

*/
class DBWrapper {

@@ -636,8 +687,6 @@ /**

this._onupgradeneeded = onupgradeneeded;
this._onversionchange = onversionchange;
this._onversionchange = onversionchange; // If this is null, it means the database isn't open.
// If this is null, it means the database isn't open.
this._db = null;
}
/**

@@ -651,47 +700,43 @@ * Opens a connected to an IDBDatabase, invokes any onupgradedneeded

*/
open() {
var _this = this;
return babelHelpers.asyncToGenerator(function* () {
if (_this._db) return;
_this._db = yield new Promise(function (resolve, reject) {
// This flag is flipped to true if the timeout callback runs prior
// to the request failing or succeeding. Note: we use a timeout instead
// of an onblocked handler since there are cases where onblocked will
// never never run. A timeout better handles all possible scenarios:
// https://github.com/w3c/IndexedDB/issues/223
let openRequestTimedOut = false;
setTimeout(function () {
openRequestTimedOut = true;
reject(new Error('The open request was blocked and timed out'));
}, _this.OPEN_TIMEOUT);
async open() {
if (this._db) return;
this._db = await new Promise((resolve, reject) => {
// This flag is flipped to true if the timeout callback runs prior
// to the request failing or succeeding. Note: we use a timeout instead
// of an onblocked handler since there are cases where onblocked will
// never never run. A timeout better handles all possible scenarios:
// https://github.com/w3c/IndexedDB/issues/223
let openRequestTimedOut = false;
setTimeout(() => {
openRequestTimedOut = true;
reject(new Error('The open request was blocked and timed out'));
}, this.OPEN_TIMEOUT);
const openRequest = indexedDB.open(this._name, this._version);
const openRequest = indexedDB.open(_this._name, _this._version);
openRequest.onerror = function (evt) {
return reject(openRequest.error);
};
openRequest.onupgradeneeded = function (evt) {
if (openRequestTimedOut) {
openRequest.transaction.abort();
evt.target.result.close();
} else if (_this._onupgradeneeded) {
_this._onupgradeneeded(evt);
}
};
openRequest.onsuccess = function (evt) {
const db = evt.target.result;
if (openRequestTimedOut) {
db.close();
} else {
db.onversionchange = _this._onversionchange;
resolve(db);
}
};
});
openRequest.onerror = evt => reject(openRequest.error);
return _this;
})();
openRequest.onupgradeneeded = evt => {
if (openRequestTimedOut) {
openRequest.transaction.abort();
evt.target.result.close();
} else if (this._onupgradeneeded) {
this._onupgradeneeded(evt);
}
};
openRequest.onsuccess = evt => {
const db = evt.target.result;
if (openRequestTimedOut) {
db.close();
} else {
db.onversionchange = this._onversionchange;
resolve(db);
}
};
});
return this;
}
/**

@@ -706,10 +751,7 @@ * Delegates to the native `get()` method for the object store.

*/
get(storeName, ...args) {
var _this2 = this;
return babelHelpers.asyncToGenerator(function* () {
return yield _this2._call('get', storeName, 'readonly', ...args);
})();
async get(storeName, ...args) {
return await this._call('get', storeName, 'readonly', ...args);
}
/**

@@ -724,10 +766,7 @@ * Delegates to the native `add()` method for the object store.

*/
add(storeName, ...args) {
var _this3 = this;
return babelHelpers.asyncToGenerator(function* () {
return yield _this3._call('add', storeName, 'readwrite', ...args);
})();
async add(storeName, ...args) {
return await this._call('add', storeName, 'readwrite', ...args);
}
/**

@@ -742,10 +781,7 @@ * Delegates to the native `put()` method for the object store.

*/
put(storeName, ...args) {
var _this4 = this;
return babelHelpers.asyncToGenerator(function* () {
return yield _this4._call('put', storeName, 'readwrite', ...args);
})();
async put(storeName, ...args) {
return await this._call('put', storeName, 'readwrite', ...args);
}
/**

@@ -759,10 +795,7 @@ * Delegates to the native `delete()` method for the object store.

*/
delete(storeName, ...args) {
var _this5 = this;
return babelHelpers.asyncToGenerator(function* () {
yield _this5._call('delete', storeName, 'readwrite', ...args);
})();
async delete(storeName, ...args) {
await this._call('delete', storeName, 'readwrite', ...args);
}
/**

@@ -774,23 +807,17 @@ * Deletes the underlying database, ensuring that any open connections are

*/
deleteDatabase() {
var _this6 = this;
return babelHelpers.asyncToGenerator(function* () {
_this6.close();
_this6._db = null;
yield new Promise(function (resolve, reject) {
const request = indexedDB.deleteDatabase(_this6._name);
request.onerror = function (evt) {
return reject(evt.target.error);
};
request.onblocked = function () {
return reject(new Error('Deletion was blocked.'));
};
request.onsuccess = function () {
return resolve();
};
});
})();
async deleteDatabase() {
this.close();
this._db = null;
await new Promise((resolve, reject) => {
const request = indexedDB.deleteDatabase(this._name);
request.onerror = evt => reject(evt.target.error);
request.onblocked = () => reject(new Error('Deletion was blocked.'));
request.onsuccess = () => resolve();
});
}
/**

@@ -807,14 +834,14 @@ * Delegates to the native `getAll()` or polyfills it via the `find()`

*/
getAll(storeName, query, count) {
var _this7 = this;
return babelHelpers.asyncToGenerator(function* () {
if ('getAll' in IDBObjectStore.prototype) {
return yield _this7._call('getAll', storeName, 'readonly', query, count);
} else {
return yield _this7.getAllMatching(storeName, { query, count });
}
})();
async getAll(storeName, query, count) {
if ('getAll' in IDBObjectStore.prototype) {
return await this._call('getAll', storeName, 'readonly', query, count);
} else {
return await this.getAllMatching(storeName, {
query,
count
});
}
}
/**

@@ -838,34 +865,41 @@ * Supports flexible lookup in an object store by specifying an index,

*/
getAllMatching(storeName, opts = {}) {
var _this8 = this;
return babelHelpers.asyncToGenerator(function* () {
return yield _this8.transaction([storeName], 'readonly', function (stores, done) {
const store = stores[storeName];
const target = opts.index ? store.index(opts.index) : store;
const results = [];
// Passing `undefined` arguments to Edge's `openCursor(...)` causes
// 'DOMException: DataError'
// Details in issue: https://github.com/GoogleChrome/workbox/issues/1509
const query = opts.query || null;
const direction = opts.direction || 'next';
target.openCursor(query, direction).onsuccess = function (evt) {
const cursor = evt.target.result;
if (cursor) {
const { primaryKey, key, value } = cursor;
results.push(opts.includeKeys ? { primaryKey, key, value } : value);
if (opts.count && results.length >= opts.count) {
done(results);
} else {
cursor.continue();
}
async getAllMatching(storeName, opts = {}) {
return await this.transaction([storeName], 'readonly', (stores, done) => {
const store = stores[storeName];
const target = opts.index ? store.index(opts.index) : store;
const results = []; // Passing `undefined` arguments to Edge's `openCursor(...)` causes
// 'DOMException: DataError'
// Details in issue: https://github.com/GoogleChrome/workbox/issues/1509
const query = opts.query || null;
const direction = opts.direction || 'next';
target.openCursor(query, direction).onsuccess = evt => {
const cursor = evt.target.result;
if (cursor) {
const {
primaryKey,
key,
value
} = cursor;
results.push(opts.includeKeys ? {
primaryKey,
key,
value
} : value);
if (opts.count && results.length >= opts.count) {
done(results);
} else {
done(results);
cursor.continue();
}
};
});
})();
} else {
done(results);
}
};
});
}
/**

@@ -890,36 +924,32 @@ * Accepts a list of stores, a transaction type, and a callback and

*/
transaction(storeNames, type, callback) {
var _this9 = this;
return babelHelpers.asyncToGenerator(function* () {
yield _this9.open();
const result = yield new Promise(function (resolve, reject) {
const txn = _this9._db.transaction(storeNames, type);
const done = function (value) {
return resolve(value);
};
const abort = function () {
reject(new Error('The transaction was manually aborted'));
txn.abort();
};
txn.onerror = function (evt) {
return reject(evt.target.error);
};
txn.onabort = function (evt) {
return reject(evt.target.error);
};
txn.oncomplete = function () {
return resolve();
};
const stores = {};
for (const storeName of storeNames) {
stores[storeName] = txn.objectStore(storeName);
}
callback(stores, done, abort);
});
return result;
})();
async transaction(storeNames, type, callback) {
await this.open();
const result = await new Promise((resolve, reject) => {
const txn = this._db.transaction(storeNames, type);
const done = value => resolve(value);
const abort = () => {
reject(new Error('The transaction was manually aborted'));
txn.abort();
};
txn.onerror = evt => reject(evt.target.error);
txn.onabort = evt => reject(evt.target.error);
txn.oncomplete = () => resolve();
const stores = {};
for (const storeName of storeNames) {
stores[storeName] = txn.objectStore(storeName);
}
callback(stores, done, abort);
});
return result;
}
/**

@@ -936,17 +966,15 @@ * Delegates async to a native IDBObjectStore method.

*/
_call(method, storeName, type, ...args) {
var _this10 = this;
return babelHelpers.asyncToGenerator(function* () {
yield _this10.open();
const callback = function (stores, done) {
stores[storeName][method](...args).onsuccess = function (evt) {
done(evt.target.result);
};
async _call(method, storeName, type, ...args) {
await this.open();
const callback = (stores, done) => {
stores[storeName][method](...args).onsuccess = evt => {
done(evt.target.result);
};
};
return yield _this10.transaction([storeName], type, callback);
})();
return await this.transaction([storeName], type, callback);
}
/**

@@ -960,6 +988,7 @@ * The default onversionchange handler, which closes the database so other

*/
_onversionchange(evt) {
this.close();
}
/**

@@ -978,27 +1007,21 @@ * Closes the connection opened by `DBWrapper.open()`. Generally this method

*/
close() {
if (this._db) this._db.close();
}
}
// Exposed to let users modify the default timeout on a per-instance
} // Exposed to let users modify the default timeout on a per-instance
// or global basis.
DBWrapper.prototype.OPEN_TIMEOUT = 2000;
/*
Copyright 2017 Google Inc.
Copyright 2018 Google LLC
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.
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.
*/
const _cacheNameDetails = {

@@ -1036,17 +1059,8 @@ prefix: 'workbox',

/*
Copyright 2017 Google Inc.
Copyright 2018 Google LLC
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.
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.
*/
var pluginEvents = {

@@ -1061,17 +1075,8 @@ CACHE_DID_UPDATE: 'cacheDidUpdate',

/*
Copyright 2017 Google Inc.
Copyright 2018 Google LLC
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.
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.
*/
var pluginUtils = {

@@ -1084,15 +1089,7 @@ filter: (plugins, callbackname) => {

/*
Copyright 2017 Google Inc.
Copyright 2018 Google LLC
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.
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.
*/

@@ -1102,5 +1099,7 @@

const urlObj = new URL(url, location);
if (urlObj.origin === location.origin) {
return urlObj.pathname;
}
return urlObj.href;

@@ -1110,17 +1109,8 @@ };

/*
Copyright 2017 Google Inc.
Copyright 2018 Google LLC
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.
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.
*/
/**

@@ -1141,74 +1131,76 @@ * Wrapper around cache.put().

*/
const putWrapper = (() => {
var _ref = babelHelpers.asyncToGenerator(function* ({
cacheName,
request,
response,
event,
plugins = []
} = {}) {
if (!response) {
{
defaultExport.error(`Cannot cache non-existent response for ` + `'${getFriendlyURL(request.url)}'.`);
}
throw new WorkboxError('cache-put-with-no-response', {
url: getFriendlyURL(request.url)
});
const putWrapper = async ({
cacheName,
request,
response,
event,
plugins = []
} = {}) => {
if (!response) {
{
defaultExport.error(`Cannot cache non-existent response for ` + `'${getFriendlyURL(request.url)}'.`);
}
let responseToCache = yield _isResponseSafeToCache({ request, response, event, plugins });
throw new WorkboxError('cache-put-with-no-response', {
url: getFriendlyURL(request.url)
});
}
if (!responseToCache) {
{
defaultExport.debug(`Response '${getFriendlyURL(request.url)}' will not be ` + `cached.`, responseToCache);
}
return;
}
let responseToCache = await _isResponseSafeToCache({
request,
response,
event,
plugins
});
if (!responseToCache) {
{
if (responseToCache.method && responseToCache.method !== 'GET') {
throw new WorkboxError('attempt-to-cache-non-get-request', {
url: getFriendlyURL(request.url),
method: responseToCache.method
});
}
defaultExport.debug(`Response '${getFriendlyURL(request.url)}' will not be ` + `cached.`, responseToCache);
}
const cache = yield caches.open(cacheName);
return;
}
const updatePlugins = pluginUtils.filter(plugins, pluginEvents.CACHE_DID_UPDATE);
{
if (responseToCache.method && responseToCache.method !== 'GET') {
throw new WorkboxError('attempt-to-cache-non-get-request', {
url: getFriendlyURL(request.url),
method: responseToCache.method
});
}
}
let oldResponse = updatePlugins.length > 0 ? yield matchWrapper({ cacheName, request }) : null;
const cache = await caches.open(cacheName);
const updatePlugins = pluginUtils.filter(plugins, pluginEvents.CACHE_DID_UPDATE);
let oldResponse = updatePlugins.length > 0 ? await matchWrapper({
cacheName,
request
}) : null;
{
defaultExport.debug(`Updating the '${cacheName}' cache with a new Response for ` + `${getFriendlyURL(request.url)}.`);
}
{
defaultExport.debug(`Updating the '${cacheName}' cache with a new Response for ` + `${getFriendlyURL(request.url)}.`);
}
try {
yield cache.put(request, responseToCache);
} catch (error) {
// See https://developer.mozilla.org/en-US/docs/Web/API/DOMException#exception-QuotaExceededError
if (error.name === 'QuotaExceededError') {
yield executeQuotaErrorCallbacks();
}
throw error;
try {
await cache.put(request, responseToCache);
} catch (error) {
// See https://developer.mozilla.org/en-US/docs/Web/API/DOMException#exception-QuotaExceededError
if (error.name === 'QuotaExceededError') {
await executeQuotaErrorCallbacks();
}
for (let plugin of updatePlugins) {
yield plugin[pluginEvents.CACHE_DID_UPDATE].call(plugin, {
cacheName,
request,
event,
oldResponse,
newResponse: responseToCache
});
}
});
throw error;
}
return function putWrapper() {
return _ref.apply(this, arguments);
};
})();
for (let plugin of updatePlugins) {
await plugin[pluginEvents.CACHE_DID_UPDATE].call(plugin, {
cacheName,
request,
event,
oldResponse,
newResponse: responseToCache
});
}
};
/**

@@ -1220,3 +1212,3 @@ * This is a wrapper around cache.match().

* @param {Request} options.request The Request that will be used to look up
*. cache entries.
* cache entries.
* @param {Event} [options.event] The event that propted the action.

@@ -1230,46 +1222,46 @@ * @param {Object} [options.matchOptions] Options passed to cache.match().

*/
const matchWrapper = (() => {
var _ref2 = babelHelpers.asyncToGenerator(function* ({
cacheName,
request,
event,
matchOptions,
plugins = [] }) {
const cache = yield caches.open(cacheName);
let cachedResponse = yield cache.match(request, matchOptions);
{
if (cachedResponse) {
defaultExport.debug(`Found a cached response in '${cacheName}'.`);
} else {
defaultExport.debug(`No cached response found in '${cacheName}'.`);
}
const matchWrapper = async ({
cacheName,
request,
event,
matchOptions,
plugins = []
}) => {
const cache = await caches.open(cacheName);
let cachedResponse = await cache.match(request, matchOptions);
{
if (cachedResponse) {
defaultExport.debug(`Found a cached response in '${cacheName}'.`);
} else {
defaultExport.debug(`No cached response found in '${cacheName}'.`);
}
for (let plugin of plugins) {
if (pluginEvents.CACHED_RESPONSE_WILL_BE_USED in plugin) {
cachedResponse = yield plugin[pluginEvents.CACHED_RESPONSE_WILL_BE_USED].call(plugin, {
cacheName,
request,
event,
matchOptions,
cachedResponse
});
{
if (cachedResponse) {
finalAssertExports.isInstance(cachedResponse, Response, {
moduleName: 'Plugin',
funcName: pluginEvents.CACHED_RESPONSE_WILL_BE_USED,
isReturnValueProblem: true
});
}
}
for (let plugin of plugins) {
if (pluginEvents.CACHED_RESPONSE_WILL_BE_USED in plugin) {
cachedResponse = await plugin[pluginEvents.CACHED_RESPONSE_WILL_BE_USED].call(plugin, {
cacheName,
request,
event,
matchOptions,
cachedResponse
});
{
if (cachedResponse) {
finalAssertExports.isInstance(cachedResponse, Response, {
moduleName: 'Plugin',
funcName: pluginEvents.CACHED_RESPONSE_WILL_BE_USED,
isReturnValueProblem: true
});
}
}
}
return cachedResponse;
});
}
return function matchWrapper(_x) {
return _ref2.apply(this, arguments);
};
})();
return cachedResponse;
};
/**

@@ -1289,51 +1281,54 @@ * This method will call cacheWillUpdate on the available plugins (or use

*/
const _isResponseSafeToCache = (() => {
var _ref3 = babelHelpers.asyncToGenerator(function* ({ request, response, event, plugins }) {
let responseToCache = response;
let pluginsUsed = false;
for (let plugin of plugins) {
if (pluginEvents.CACHE_WILL_UPDATE in plugin) {
pluginsUsed = true;
responseToCache = yield plugin[pluginEvents.CACHE_WILL_UPDATE].call(plugin, {
request,
response: responseToCache,
event
});
{
if (responseToCache) {
finalAssertExports.isInstance(responseToCache, Response, {
moduleName: 'Plugin',
funcName: pluginEvents.CACHE_WILL_UPDATE,
isReturnValueProblem: true
});
}
}
if (!responseToCache) {
break;
const _isResponseSafeToCache = async ({
request,
response,
event,
plugins
}) => {
let responseToCache = response;
let pluginsUsed = false;
for (let plugin of plugins) {
if (pluginEvents.CACHE_WILL_UPDATE in plugin) {
pluginsUsed = true;
responseToCache = await plugin[pluginEvents.CACHE_WILL_UPDATE].call(plugin, {
request,
response: responseToCache,
event
});
{
if (responseToCache) {
finalAssertExports.isInstance(responseToCache, Response, {
moduleName: 'Plugin',
funcName: pluginEvents.CACHE_WILL_UPDATE,
isReturnValueProblem: true
});
}
}
if (!responseToCache) {
break;
}
}
}
if (!pluginsUsed) {
{
if (!responseToCache.ok) {
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.`);
} else {
defaultExport.debug(`The response for '${request.url}' returned ` + `a status code of '${response.status}' and won't be cached as a ` + `result.`);
}
if (!pluginsUsed) {
{
if (!responseToCache.ok) {
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.`);
} else {
defaultExport.debug(`The response for '${request.url}' returned ` + `a status code of '${response.status}' and won't be cached as a ` + `result.`);
}
}
responseToCache = responseToCache.ok ? responseToCache : null;
}
return responseToCache ? responseToCache : null;
});
responseToCache = responseToCache.ok ? responseToCache : null;
}
return function _isResponseSafeToCache(_x2) {
return _ref3.apply(this, arguments);
};
})();
return responseToCache ? responseToCache : null;
};

@@ -1346,17 +1341,8 @@ const cacheWrapper = {

/*
Copyright 2017 Google Inc.
Copyright 2018 Google LLC
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.
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.
*/
/**

@@ -1377,101 +1363,100 @@ * Wrapper around the fetch API.

*/
const wrappedFetch = (() => {
var _ref = babelHelpers.asyncToGenerator(function* ({
request,
fetchOptions,
event,
plugins = [] }) {
// We *should* be able to call `await event.preloadResponse` even if it's
// undefined, but for some reason, doing so leads to errors in our Node unit
// tests. To work around that, explicitly check preloadResponse's value first.
if (event && event.preloadResponse) {
const possiblePreloadResponse = yield event.preloadResponse;
if (possiblePreloadResponse) {
{
defaultExport.log(`Using a preloaded navigation response for ` + `'${getFriendlyURL(request.url)}'`);
}
return possiblePreloadResponse;
const wrappedFetch = async ({
request,
fetchOptions,
event,
plugins = []
}) => {
// We *should* be able to call `await event.preloadResponse` even if it's
// undefined, but for some reason, doing so leads to errors in our Node unit
// tests. To work around that, explicitly check preloadResponse's value first.
if (event && event.preloadResponse) {
const possiblePreloadResponse = await event.preloadResponse;
if (possiblePreloadResponse) {
{
defaultExport.log(`Using a preloaded navigation response for ` + `'${getFriendlyURL(request.url)}'`);
}
}
if (typeof request === 'string') {
request = new Request(request);
return possiblePreloadResponse;
}
}
{
finalAssertExports.isInstance(request, Request, {
paramName: request,
expectedClass: 'Request',
moduleName: 'workbox-core',
className: 'fetchWrapper',
funcName: 'wrappedFetch'
});
}
if (typeof request === 'string') {
request = new Request(request);
}
const failedFetchPlugins = pluginUtils.filter(plugins, pluginEvents.FETCH_DID_FAIL);
{
finalAssertExports.isInstance(request, Request, {
paramName: request,
expectedClass: 'Request',
moduleName: 'workbox-core',
className: 'fetchWrapper',
funcName: 'wrappedFetch'
});
}
// If there is a fetchDidFail plugin, we need to save a clone of the
// original request before it's either modified by a requestWillFetch
// plugin or before the original request's body is consumed via fetch().
const originalRequest = failedFetchPlugins.length > 0 ? request.clone() : null;
const failedFetchPlugins = pluginUtils.filter(plugins, pluginEvents.FETCH_DID_FAIL); // If there is a fetchDidFail plugin, we need to save a clone of the
// original request before it's either modified by a requestWillFetch
// plugin or before the original request's body is consumed via fetch().
try {
for (let plugin of plugins) {
if (pluginEvents.REQUEST_WILL_FETCH in plugin) {
request = yield plugin[pluginEvents.REQUEST_WILL_FETCH].call(plugin, {
request: request.clone(),
event
});
const originalRequest = failedFetchPlugins.length > 0 ? request.clone() : null;
{
if (request) {
finalAssertExports.isInstance(request, Request, {
moduleName: 'Plugin',
funcName: pluginEvents.CACHED_RESPONSE_WILL_BE_USED,
isReturnValueProblem: true
});
}
try {
for (let plugin of plugins) {
if (pluginEvents.REQUEST_WILL_FETCH in plugin) {
request = await plugin[pluginEvents.REQUEST_WILL_FETCH].call(plugin, {
request: request.clone(),
event
});
{
if (request) {
finalAssertExports.isInstance(request, Request, {
moduleName: 'Plugin',
funcName: pluginEvents.CACHED_RESPONSE_WILL_BE_USED,
isReturnValueProblem: true
});
}
}
}
} catch (err) {
throw new WorkboxError('plugin-error-request-will-fetch', {
thrownError: err
});
}
} catch (err) {
throw new WorkboxError('plugin-error-request-will-fetch', {
thrownError: err
});
} // The request can be altered by plugins with `requestWillFetch` making
// the original request (Most likely from a `fetch` event) to be different
// to the Request we make. Pass both to `fetchDidFail` to aid debugging.
// The request can be altered by plugins with `requestWillFetch` making
// the original request (Most likely from a `fetch` event) to be different
// to the Request we make. Pass both to `fetchDidFail` to aid debugging.
const pluginFilteredRequest = request.clone();
try {
const fetchResponse = yield fetch(request, fetchOptions);
{
defaultExport.debug(`Network request for ` + `'${getFriendlyURL(request.url)}' returned a response with ` + `status '${fetchResponse.status}'.`);
}
return fetchResponse;
} catch (error) {
{
defaultExport.error(`Network request for ` + `'${getFriendlyURL(request.url)}' threw an error.`, error);
}
const pluginFilteredRequest = request.clone();
for (let plugin of failedFetchPlugins) {
yield plugin[pluginEvents.FETCH_DID_FAIL].call(plugin, {
error,
event,
originalRequest: originalRequest.clone(),
request: pluginFilteredRequest.clone()
});
}
try {
const fetchResponse = await fetch(request, fetchOptions);
throw error;
{
defaultExport.debug(`Network request for ` + `'${getFriendlyURL(request.url)}' returned a response with ` + `status '${fetchResponse.status}'.`);
}
});
return function wrappedFetch(_x) {
return _ref.apply(this, arguments);
};
})();
return fetchResponse;
} catch (error) {
{
defaultExport.error(`Network request for ` + `'${getFriendlyURL(request.url)}' threw an error.`, error);
}
for (let plugin of failedFetchPlugins) {
await plugin[pluginEvents.FETCH_DID_FAIL].call(plugin, {
error,
event,
originalRequest: originalRequest.clone(),
request: pluginFilteredRequest.clone()
});
}
throw error;
}
};
const fetchWrapper = {

@@ -1482,15 +1467,7 @@ fetch: wrappedFetch

/*
Copyright 2017 Google Inc.
Copyright 2018 Google LLC
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.
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.
*/

@@ -1510,17 +1487,8 @@

/*
Copyright 2017 Google Inc.
Copyright 2018 Google LLC
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.
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.
*/
/**

@@ -1534,2 +1502,3 @@ * Logs a warning to the user recommending changing

*/
function showWarning(cacheControlHeader) {

@@ -1539,3 +1508,2 @@ const docsUrl = 'https://developers.google.com/web/tools/workbox/guides/service-worker-checklist#cache-control_of_your_service_worker_file';

}
/**

@@ -1549,9 +1517,12 @@ * Checks for cache-control header on SW file and

*/
function checkSWFileCacheHeaders() {
// This is wrapped as an iife to allow async/await while making
// rollup exclude it in builds.
return babelHelpers.asyncToGenerator(function* () {
return (async () => {
try {
const swFile = self.location.href;
const response = yield fetch(swFile);
const response = await fetch(swFile);
if (!response.ok) {

@@ -1569,2 +1540,3 @@ // Response failed so nothing we can check;

const maxAgeResult = /max-age\s*=\s*(\d*)/g.exec(cacheControlHeader);
if (maxAgeResult) {

@@ -1585,4 +1557,3 @@ if (parseInt(maxAgeResult[1], 10) === 0) {

showWarning(cacheControlHeader);
} catch (err) {
// NOOP
} catch (err) {// NOOP
}

@@ -1595,17 +1566,8 @@ })();

/*
Copyright 2017 Google Inc.
Copyright 2018 Google LLC
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.
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.
*/
/**

@@ -1618,2 +1580,3 @@ * This class is never exposed publicly. Inidividual methods are exposed

*/
class WorkboxCore {

@@ -1629,8 +1592,7 @@ /**

self.workbox.v = self.workbox.v || {};
} catch (err) {}
// NOOP
} 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.
// A WorkboxCore instance must be exported before we can use the logger.
// This is so it can get the current log level.
{

@@ -1650,3 +1612,2 @@ const padding = ' ';

}
/**

@@ -1664,2 +1625,4 @@ * Get the current cache names used by Workbox.

*/
get cacheNames() {

@@ -1672,3 +1635,2 @@ return {

}
/**

@@ -1693,2 +1655,4 @@ * You can alter the default cache names used by the Workbox modules by

*/
setCacheNameDetails(details) {

@@ -1729,3 +1693,2 @@ {

}
/**

@@ -1738,6 +1701,7 @@ * Get the current log level.

*/
get logLevel() {
return getLoggerLevel();
}
/**

@@ -1751,2 +1715,4 @@ * Set the current log level passing in one of the values from

*/
setLogLevel(newLevel) {

@@ -1772,2 +1738,3 @@ {

}
}

@@ -1778,17 +1745,8 @@

/*
Copyright 2017 Google Inc.
Copyright 2018 Google LLC
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.
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.
*/
const finalExports = Object.assign(defaultExport$1, {

@@ -1795,0 +1753,0 @@ _private,

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

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

@@ -23,7 +23,7 @@ "description": "This module is used by a number of the other Workbox modules to share common code.",

"browserNamespace": "workbox.core",
"packageType": "browser",
"includeBabelHelpers": true
"packageType": "browser"
},
"main": "build/workbox-core.prod.js",
"module": "index.mjs"
"module": "index.mjs",
"gitHead": "db1fb73fd32fbd5cbf42e246e6144011a5c6edc2"
}

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

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