Socket
Socket
Sign inDemoInstall

workbox-strategies

Package Overview
Dependencies
Maintainers
4
Versions
82
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

workbox-strategies - npm Package Compare versions

Comparing version 3.0.1 to 3.1.0

365

build/workbox-strategies.dev.js
this.workbox = this.workbox || {};
this.workbox.strategies = (function (logger_mjs,cacheNames_mjs,cacheWrapper_mjs,fetchWrapper_mjs,assert_mjs) {
this.workbox.strategies = (function (logger_mjs,cacheNames_mjs,cacheWrapper_mjs,fetchWrapper_mjs,assert_mjs,getFriendlyURL_mjs) {
'use strict';
try {
self.workbox.v['workbox:strategies:3.0.1'] = 1;
self.workbox.v['workbox:strategies:3.1.0'] = 1;
} catch (e) {} // eslint-disable-line
/*
Copyright 2016 Google Inc. All Rights Reserved.
Copyright 2018 Google Inc. All Rights Reserved.
Licensed under the Apache License, Version 2.0 (the "License");

@@ -33,3 +33,3 @@ you may not use this file except in compliance with the License.

var messages = {
strategyStart: (strategyName, event) => `Using ${strategyName} to respond ` + `to '${getFriendlyURL(event.request.url)}'`,
strategyStart: (strategyName, request) => `Using ${strategyName} to ` + `respond to '${getFriendlyURL(request.url)}'`,
printFinalResponse: response => {

@@ -45,3 +45,3 @@ if (response) {

/*
Copyright 2016 Google Inc. All Rights Reserved.
Copyright 2018 Google Inc. All Rights Reserved.
Licensed under the Apache License, Version 2.0 (the "License");

@@ -64,3 +64,3 @@ you may not use this file except in compliance with the License.

*
* A cache first strategy is useful for assets that have beeng revisioned,
* A cache first strategy is useful for assets that have been revisioned,
* such as URLs like `/styles/example.a8f5f1.css`, since they

@@ -72,4 +72,2 @@ * can be cached for long periods of time.

class CacheFirst {
// TODO: Replace `plugins` parameter link with link to d.g.c.
/**

@@ -80,3 +78,3 @@ * @param {Object} options

* [workbox-core]{@link workbox.core.cacheNames}.
* @param {string} options.plugins [Plugins]{@link https://docs.google.com/document/d/1Qye_GDVNF1lzGmhBaUvbgwfBWRQDdPgwUAgsbs8jhsk/edit?usp=sharing}
* @param {string} options.plugins [Plugins]{@link https://developers.google.com/web/tools/workbox/guides/using-plugins}
* to use in conjunction with this caching strategy.

@@ -107,3 +105,2 @@ * @param {Object} options.fetchOptions Values passed along to the

return babelHelpers.asyncToGenerator(function* () {
const logs = [];
{

@@ -118,11 +115,52 @@ assert_mjs.assert.isInstance(event, FetchEvent, {

let response = yield cacheWrapper_mjs.cacheWrapper.match(_this._cacheName, event.request, null, _this._plugins);
return _this.makeRequest({
event,
request: event.request
});
})();
}
/**
* This method can be used to perform a make a standalone request outside the
* context of the [Workbox Router]{@link workbox.routing.Router}.
*
* See "[Advanced Recipes](https://developers.google.com/web/tools/workbox/guides/advanced-recipes#make-requests)"
* for more usage information.
*
* @param {Object} input
* @param {Request|string} input.request Either a
* [`Request`]{@link https://developer.mozilla.org/en-US/docs/Web/API/Request}
* object, or a string URL, corresponding to the request to be made.
* @param {FetchEvent} [input.event] If provided, `event.waitUntil()` will be
* called automatically to extend the service worker's lifetime.
* @return {Promise<Response>}
*/
makeRequest({ event, request }) {
var _this2 = this;
return babelHelpers.asyncToGenerator(function* () {
const logs = [];
if (typeof request === 'string') {
request = new Request(request);
}
{
assert_mjs.assert.isInstance(request, Request, {
moduleName: 'workbox-strategies',
className: 'CacheFirst',
funcName: 'makeRequest',
paramName: 'request'
});
}
let response = yield cacheWrapper_mjs.cacheWrapper.match(_this2._cacheName, request, null, _this2._plugins);
let error;
if (!response) {
{
logs.push(`No response found in the '${_this._cacheName}' cache. ` + `Will respond with a network request.`);
logs.push(`No response found in the '${_this2._cacheName}' cache. ` + `Will respond with a network request.`);
}
try {
response = yield _this._getFromNetwork(event);
response = yield _this2._getFromNetwork(request, event);
} catch (err) {

@@ -141,3 +179,3 @@ error = err;

{
logs.push(`Found a cached response in the '${_this._cacheName}' cache.`);
logs.push(`Found a cached response in the '${_this2._cacheName}' cache.`);
}

@@ -147,3 +185,3 @@ }

{
logger_mjs.logger.groupCollapsed(messages.strategyStart('CacheFirst', event));
logger_mjs.logger.groupCollapsed(messages.strategyStart('CacheFirst', request));
for (let log of logs) {

@@ -169,3 +207,4 @@ logger_mjs.logger.log(log);

*
* @param {FetchEvent} event
* @param {Request} request
* @param {FetchEvent} [event]
* @return {Promise<Response>}

@@ -175,12 +214,16 @@ *

*/
_getFromNetwork(event) {
var _this2 = this;
_getFromNetwork(request, event) {
var _this3 = this;
return babelHelpers.asyncToGenerator(function* () {
const response = yield fetchWrapper_mjs.fetchWrapper.fetch(event.request, _this2._fetchOptions, _this2._plugins);
const response = yield fetchWrapper_mjs.fetchWrapper.fetch(request, _this3._fetchOptions, _this3._plugins);
// Keep the service worker while we put the request to the cache
const responseClone = response.clone();
event.waitUntil(cacheWrapper_mjs.cacheWrapper.put(_this2._cacheName, event.request, responseClone, _this2._plugins));
const cachePutPromise = cacheWrapper_mjs.cacheWrapper.put(_this3._cacheName, request, responseClone, _this3._plugins);
if (event) {
event.waitUntil(cachePutPromise);
}
return response;

@@ -192,3 +235,3 @@ })();

/*
Copyright 2016 Google Inc. All Rights Reserved.
Copyright 2018 Google Inc. All Rights Reserved.
Licensed under the Apache License, Version 2.0 (the "License");

@@ -207,6 +250,2 @@ you may not use this file except in compliance with the License.

// TODO: Replace `Workbox plugins` link in the class description with a
// link to d.g.c.
// TODO: Replace `plugins` parameter link with link to d.g.c.
/**

@@ -217,3 +256,3 @@ * An implementation of a

*
* This class is useful if you want to take advantage of any [Workbox plugins]{@link https://docs.google.com/document/d/1Qye_GDVNF1lzGmhBaUvbgwfBWRQDdPgwUAgsbs8jhsk/edit?usp=sharing}.
* This class is useful if you want to take advantage of any [Workbox plugins]{@link https://developers.google.com/web/tools/workbox/guides/using-plugins}.
*

@@ -228,3 +267,3 @@ * @memberof workbox.strategies

* [workbox-core]{@link workbox.core.cacheNames}.
* @param {string} options.plugins [Plugins]{@link https://docs.google.com/document/d/1Qye_GDVNF1lzGmhBaUvbgwfBWRQDdPgwUAgsbs8jhsk/edit?usp=sharing}
* @param {string} options.plugins [Plugins]{@link https://developers.google.com/web/tools/workbox/guides/using-plugins}
* to use in conjunction with this caching strategy.

@@ -260,11 +299,50 @@ */

const response = yield cacheWrapper_mjs.cacheWrapper.match(_this._cacheName, event.request, null, _this._plugins);
return _this.makeRequest({
event,
request: event.request
});
})();
}
/**
* This method can be used to perform a make a standalone request outside the
* context of the [Workbox Router]{@link workbox.routing.Router}.
*
* See "[Advanced Recipes](https://developers.google.com/web/tools/workbox/guides/advanced-recipes#make-requests)"
* for more usage information.
*
* @param {Object} input
* @param {Request|string} input.request Either a
* [`Request`]{@link https://developer.mozilla.org/en-US/docs/Web/API/Request}
* object, or a string URL, corresponding to the request to be made.
* @param {FetchEvent} [input.event] If provided, `event.waitUntil()` will be
* called automatically to extend the service worker's lifetime.
* @return {Promise<Response>}
*/
makeRequest({ event, request }) {
var _this2 = this;
return babelHelpers.asyncToGenerator(function* () {
if (typeof request === 'string') {
request = new Request(request);
}
{
logger_mjs.logger.groupCollapsed(messages.strategyStart('CacheOnly', event));
assert_mjs.assert.isInstance(request, Request, {
moduleName: 'workbox-strategies',
className: 'CacheOnly',
funcName: 'makeRequest',
paramName: 'request'
});
}
const response = yield cacheWrapper_mjs.cacheWrapper.match(_this2._cacheName, request, null, _this2._plugins);
{
logger_mjs.logger.groupCollapsed(messages.strategyStart('CacheOnly', request));
if (response) {
logger_mjs.logger.log(`Found a cached response in the '${_this._cacheName}'` + ` cache.`);
logger_mjs.logger.log(`Found a cached response in the '${_this2._cacheName}'` + ` cache.`);
messages.printFinalResponse(response);
} else {
logger_mjs.logger.log(`No response found in the '${_this._cacheName}' cache.`);
logger_mjs.logger.log(`No response found in the '${_this2._cacheName}' cache.`);
}

@@ -314,3 +392,3 @@ logger_mjs.logger.groupEnd();

/*
Copyright 2016 Google Inc. All Rights Reserved.
Copyright 2018 Google Inc. All Rights Reserved.
Licensed under the Apache License, Version 2.0 (the "License");

@@ -329,5 +407,2 @@ you may not use this file except in compliance with the License.

// TODO: Change opaque responses to d.g.c link
// TODO: Replace `plugins` parameter link with link to d.g.c.
/**

@@ -351,3 +426,3 @@ * An implementation of a

* [workbox-core]{@link workbox.core.cacheNames}.
* @param {string} options.plugins [Plugins]{@link https://docs.google.com/document/d/1Qye_GDVNF1lzGmhBaUvbgwfBWRQDdPgwUAgsbs8jhsk/edit?usp=sharing}
* @param {string} options.plugins [Plugins]{@link https://developers.google.com/web/tools/workbox/guides/using-plugins}
* to use in conjunction with this caching strategy.

@@ -404,3 +479,2 @@ * @param {Object} options.fetchOptions Values passed along to the

return babelHelpers.asyncToGenerator(function* () {
const logs = [];
{

@@ -415,7 +489,48 @@ assert_mjs.assert.isInstance(event, FetchEvent, {

return _this.makeRequest({
event,
request: event.request
});
})();
}
/**
* This method can be used to perform a make a standalone request outside the
* context of the [Workbox Router]{@link workbox.routing.Router}.
*
* See "[Advanced Recipes](https://developers.google.com/web/tools/workbox/guides/advanced-recipes#make-requests)"
* for more usage information.
*
* @param {Object} input
* @param {Request|string} input.request Either a
* [`Request`]{@link https://developer.mozilla.org/en-US/docs/Web/API/Request}
* object, or a string URL, corresponding to the request to be made.
* @param {FetchEvent} [input.event] If provided, `event.waitUntil()` will be
* called automatically to extend the service worker's lifetime.
* @return {Promise<Response>}
*/
makeRequest({ event, request }) {
var _this2 = this;
return babelHelpers.asyncToGenerator(function* () {
const logs = [];
if (typeof request === 'string') {
request = new Request(request);
}
{
assert_mjs.assert.isInstance(request, Request, {
moduleName: 'workbox-strategies',
className: 'NetworkFirst',
funcName: 'handle',
paramName: 'makeRequest'
});
}
const promises = [];
let timeoutId;
if (_this._networkTimeoutSeconds) {
const { id, promise } = _this._getTimeoutPromise(event, logs);
if (_this2._networkTimeoutSeconds) {
const { id, promise } = _this2._getTimeoutPromise(request, logs);
timeoutId = id;

@@ -425,3 +540,3 @@ promises.push(promise);

const networkPromise = _this._getNetworkPromise(timeoutId, event, logs);
const networkPromise = _this2._getNetworkPromise(timeoutId, event, request, logs);
promises.push(networkPromise);

@@ -441,3 +556,3 @@

{
logger_mjs.logger.groupCollapsed(messages.strategyStart('NetworkFirst', event));
logger_mjs.logger.groupCollapsed(messages.strategyStart('NetworkFirst', request));
for (let log of logs) {

@@ -455,3 +570,3 @@ logger_mjs.logger.log(log);

/**
* @param {FetchEvent} event
* @param {Request} request
* @param {Array} logs A reference to the logs array

@@ -462,4 +577,4 @@ * @return {Promise<Response>}

*/
_getTimeoutPromise(event, logs) {
var _this2 = this;
_getTimeoutPromise(request, logs) {
var _this3 = this;

@@ -471,6 +586,6 @@ let timeoutId;

{
logs.push(`Timing out the network response at ` + `${_this2._networkTimeoutSeconds} seconds.`);
logs.push(`Timing out the network response at ` + `${_this3._networkTimeoutSeconds} seconds.`);
}
resolve((yield _this2._respondFromCache(event.request)));
resolve((yield _this3._respondFromCache(request)));
});

@@ -494,3 +609,4 @@

* @param {number} timeoutId
* @param {FetchEvent} event
* @param {FetchEvent|null} event
* @param {Request} request
* @param {Array} logs A reference to the logs Array.

@@ -501,4 +617,4 @@ * @return {Promise<Response>}

*/
_getNetworkPromise(timeoutId, event, logs) {
var _this3 = this;
_getNetworkPromise(timeoutId, event, request, logs) {
var _this4 = this;

@@ -509,3 +625,3 @@ return babelHelpers.asyncToGenerator(function* () {

try {
response = yield fetchWrapper_mjs.fetchWrapper.fetch(event.request, _this3._fetchOptions, _this3._plugins);
response = yield fetchWrapper_mjs.fetchWrapper.fetch(request, _this4._fetchOptions, _this4._plugins);
} catch (err) {

@@ -528,8 +644,8 @@ error = err;

if (error || !response) {
response = yield _this3._respondFromCache(event.request);
response = yield _this4._respondFromCache(request);
{
if (response) {
logs.push(`Found a cached response in the '${_this3._cacheName}'` + ` cache.`);
logs.push(`Found a cached response in the '${_this4._cacheName}'` + ` cache.`);
} else {
logs.push(`No response found in the '${_this3._cacheName}' cache.`);
logs.push(`No response found in the '${_this4._cacheName}' cache.`);
}

@@ -540,3 +656,15 @@ }

const responseClone = response.clone();
event.waitUntil(cacheWrapper_mjs.cacheWrapper.put(_this3._cacheName, event.request, responseClone, _this3._plugins));
const cachePut = cacheWrapper_mjs.cacheWrapper.put(_this4._cacheName, request, responseClone, _this4._plugins);
if (event) {
try {
// The event has been responded to so we can keep the SW alive to
// respond to the request
event.waitUntil(cachePut);
} catch (err) {
{
logger_mjs.logger.warn(`Unable to ensure service worker stays alive when ` + `updating cache for '${getFriendlyURL_mjs.getFriendlyURL(event.request.url)}'.`);
}
}
}
}

@@ -562,3 +690,3 @@

/*
Copyright 2016 Google Inc. All Rights Reserved.
Copyright 2018 Google Inc. All Rights Reserved.
Licensed under the Apache License, Version 2.0 (the "License");

@@ -577,6 +705,2 @@ you may not use this file except in compliance with the License.

// TODO: Replace `Workbox plugins` link in the class description with a
// link to d.g.c.
// TODO: Replace `plugins` parameter link with link to d.g.c.
/**

@@ -587,3 +711,3 @@ * An implementation of a

*
* This class is useful if you want to take advantage of any [Workbox plugins]{@link https://docs.google.com/document/d/1Qye_GDVNF1lzGmhBaUvbgwfBWRQDdPgwUAgsbs8jhsk/edit?usp=sharing}.
* This class is useful if you want to take advantage of any [Workbox plugins]{@link https://developers.google.com/web/tools/workbox/guides/using-plugins}.
*

@@ -598,3 +722,3 @@ * @memberof workbox.strategies

* [workbox-core]{@link workbox.core.cacheNames}.
* @param {string} options.plugins [Plugins]{@link https://docs.google.com/document/d/1Qye_GDVNF1lzGmhBaUvbgwfBWRQDdPgwUAgsbs8jhsk/edit?usp=sharing}
* @param {string} options.plugins [Plugins]{@link https://developers.google.com/web/tools/workbox/guides/using-plugins}
* to use in conjunction with this caching strategy.

@@ -634,6 +758,45 @@ * @param {Object} options.fetchOptions Values passed along to the

return _this.makeRequest({
event,
request: event.request
});
})();
}
/**
* This method can be used to perform a make a standalone request outside the
* context of the [Workbox Router]{@link workbox.routing.Router}.
*
* See "[Advanced Recipes](https://developers.google.com/web/tools/workbox/guides/advanced-recipes#make-requests)"
* for more usage information.
*
* @param {Object} input
* @param {Request|string} input.request Either a
* [`Request`]{@link https://developer.mozilla.org/en-US/docs/Web/API/Request}
* object, or a string URL, corresponding to the request to be made.
* @param {FetchEvent} [input.event] If provided, `event.waitUntil()` will be
* called automatically to extend the service worker's lifetime.
* @return {Promise<Response>}
*/
makeRequest({ event, request }) {
var _this2 = this;
return babelHelpers.asyncToGenerator(function* () {
if (typeof request === 'string') {
request = new Request(request);
}
{
assert_mjs.assert.isInstance(request, Request, {
moduleName: 'workbox-strategies',
className: 'NetworkOnly',
funcName: 'handle',
paramName: 'request'
});
}
let error;
let response;
try {
response = yield fetchWrapper_mjs.fetchWrapper.fetch(event.request, _this._fetchOptions, _this._plugins);
response = yield fetchWrapper_mjs.fetchWrapper.fetch(request, _this2._fetchOptions, _this2._plugins);
} catch (err) {

@@ -644,3 +807,3 @@ error = err;

{
logger_mjs.logger.groupCollapsed(messages.strategyStart('NetworkOnly', event));
logger_mjs.logger.groupCollapsed(messages.strategyStart('NetworkOnly', request));
if (response) {

@@ -667,3 +830,3 @@ logger_mjs.logger.log(`Got response from network.`);

/*
Copyright 2016 Google Inc. All Rights Reserved.
Copyright 2018 Google Inc. All Rights Reserved.
Licensed under the Apache License, Version 2.0 (the "License");

@@ -682,6 +845,2 @@ you may not use this file except in compliance with the License.

// TODO: Replace `Workbox plugins` link in the class description with a
// link to d.g.c.
// TODO: Replace `plugins` parameter link with link to d.g.c.
/**

@@ -710,3 +869,3 @@ * An implementation of a

* [workbox-core]{@link workbox.core.cacheNames}.
* @param {string} options.plugins [Plugins]{@link https://docs.google.com/document/d/1Qye_GDVNF1lzGmhBaUvbgwfBWRQDdPgwUAgsbs8jhsk/edit?usp=sharing}
* @param {string} options.plugins [Plugins]{@link https://developers.google.com/web/tools/workbox/guides/using-plugins}
* to use in conjunction with this caching strategy.

@@ -746,3 +905,2 @@ * @param {Object} options.fetchOptions Values passed along to the

return babelHelpers.asyncToGenerator(function* () {
const logs = [];
{

@@ -757,9 +915,50 @@ assert_mjs.assert.isInstance(event, FetchEvent, {

const fetchAndCachePromise = _this._getFromNetwork(event);
return _this.makeRequest({
event,
request: event.request
});
})();
}
let response = yield cacheWrapper_mjs.cacheWrapper.match(_this._cacheName, event.request, null, _this._plugins);
/**
* This method can be used to perform a make a standalone request outside the
* context of the [Workbox Router]{@link workbox.routing.Router}.
*
* See "[Advanced Recipes](https://developers.google.com/web/tools/workbox/guides/advanced-recipes#make-requests)"
* for more usage information.
*
* @param {Object} input
* @param {Request|string} input.request Either a
* [`Request`]{@link https://developer.mozilla.org/en-US/docs/Web/API/Request}
* object, or a string URL, corresponding to the request to be made.
* @param {FetchEvent} [input.event] If provided, `event.waitUntil()` will be
* called automatically to extend the service worker's lifetime.
* @return {Promise<Response>}
*/
makeRequest({ event, request }) {
var _this2 = this;
return babelHelpers.asyncToGenerator(function* () {
const logs = [];
if (typeof request === 'string') {
request = new Request(request);
}
{
assert_mjs.assert.isInstance(request, Request, {
moduleName: 'workbox-strategies',
className: 'StaleWhileRevalidate',
funcName: 'handle',
paramName: 'request'
});
}
const fetchAndCachePromise = _this2._getFromNetwork(request, event);
let response = yield cacheWrapper_mjs.cacheWrapper.match(_this2._cacheName, request, null, _this2._plugins);
if (response) {
{
logs.push(`Found a cached response in the '${_this._cacheName}'` + ` cache. Will update with the network response in the background.`);
logs.push(`Found a cached response in the '${_this2._cacheName}'` + ` cache. Will update with the network response in the background.`);
}

@@ -769,3 +968,3 @@ event.waitUntil(fetchAndCachePromise);

{
logs.push(`No response found in the '${_this._cacheName}' cache. ` + `Will wait for the network response.`);
logs.push(`No response found in the '${_this2._cacheName}' cache. ` + `Will wait for the network response.`);
}

@@ -776,3 +975,3 @@ response = yield fetchAndCachePromise;

{
logger_mjs.logger.groupCollapsed(messages.strategyStart('StaleWhileRevalidate', event));
logger_mjs.logger.groupCollapsed(messages.strategyStart('StaleWhileRevalidate', request));
for (let log of logs) {

@@ -790,3 +989,4 @@ logger_mjs.logger.log(log);

/**
* @param {FetchEvent} event
* @param {Request} request
* @param {FetchEvent} [event]
* @return {Promise<Response>}

@@ -796,9 +996,12 @@ *

*/
_getFromNetwork(event) {
var _this2 = this;
_getFromNetwork(request, event) {
var _this3 = this;
return babelHelpers.asyncToGenerator(function* () {
const response = yield fetchWrapper_mjs.fetchWrapper.fetch(event.request, _this2._fetchOptions, _this2._plugins);
const response = yield fetchWrapper_mjs.fetchWrapper.fetch(request, _this3._fetchOptions, _this3._plugins);
event.waitUntil(cacheWrapper_mjs.cacheWrapper.put(_this2._cacheName, event.request, response.clone(), _this2._plugins));
const cachePutPromise = cacheWrapper_mjs.cacheWrapper.put(_this3._cacheName, request, response.clone(), _this3._plugins);
if (event) {
event.waitUntil(cachePutPromise);
}

@@ -911,4 +1114,4 @@ return response;

}(workbox.core._private,workbox.core._private,workbox.core._private,workbox.core._private,workbox.core._private));
}(workbox.core._private,workbox.core._private,workbox.core._private,workbox.core._private,workbox.core._private,workbox.core._private));
//# sourceMappingURL=workbox-strategies.dev.js.map

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

this.workbox=this.workbox||{},this.workbox.strategies=function(e,t,r){"use strict";try{self.workbox.v["workbox:strategies:3.0.1"]=1}catch(e){}class s{constructor(t={}){this.e=e.cacheNames.getRuntimeName(t.cacheName),this.t=t.plugins||[],this.r=t.fetchOptions||null}handle({event:e}){var r=this;return babelHelpers.asyncToGenerator(function*(){let s,n=yield t.cacheWrapper.match(r.e,e.request,null,r.t);if(!n)try{n=yield r.s(e)}catch(e){s=e}if(s)throw s;return n})()}s(e){var s=this;return babelHelpers.asyncToGenerator(function*(){const n=yield r.fetchWrapper.fetch(e.request,s.r,s.t),i=n.clone();return e.waitUntil(t.cacheWrapper.put(s.e,e.request,i,s.t)),n})()}}class n{constructor(t={}){this.e=e.cacheNames.getRuntimeName(t.cacheName),this.t=t.plugins||[]}handle({event:e}){var r=this;return babelHelpers.asyncToGenerator(function*(){return yield t.cacheWrapper.match(r.e,e.request,null,r.t)})()}}var i={cacheWillUpdate:({response:e})=>e.ok||0===e.status?e:null};class l{constructor(t={}){if(this.e=e.cacheNames.getRuntimeName(t.cacheName),t.plugins){let e=t.plugins.some(e=>!!e.cacheWillUpdate);this.t=e?t.plugins:[i,...t.plugins]}else this.t=[i];this.n=t.networkTimeoutSeconds,this.r=t.fetchOptions||null}handle({event:e}){var t=this;return babelHelpers.asyncToGenerator(function*(){const r=[],s=[];let n;if(t.n){const{id:i,promise:l}=t.i(e,r);n=i,s.push(l)}const i=t.l(n,e,r);s.push(i);let l=yield Promise.race(s);return l||(l=yield i),l})()}i(e,t){var r=this;let s;const n=new Promise(t=>{const n=(()=>{var s=babelHelpers.asyncToGenerator(function*(){t(yield r.o(e.request))});return function(){return s.apply(this,arguments)}})();s=setTimeout(n,1e3*this.n)});return{promise:n,id:s}}l(e,s,n){var i=this;return babelHelpers.asyncToGenerator(function*(){let n,l;try{l=yield r.fetchWrapper.fetch(s.request,i.r,i.t)}catch(e){n=e}if(e&&clearTimeout(e),n||!l)l=yield i.o(s.request);else{const e=l.clone();s.waitUntil(t.cacheWrapper.put(i.e,s.request,e,i.t))}return l})()}o(e){return t.cacheWrapper.match(this.e,e,null,this.t)}}class o{constructor(t={}){this.e=e.cacheNames.getRuntimeName(t.cacheName),this.t=t.plugins||[],this.r=t.fetchOptions||null}handle({event:e}){var t=this;return babelHelpers.asyncToGenerator(function*(){let s,n;try{n=yield r.fetchWrapper.fetch(e.request,t.r,t.t)}catch(e){s=e}if(s)throw s;return n})()}}class c{constructor(t={}){if(this.e=e.cacheNames.getRuntimeName(t.cacheName),this.t=t.plugins||[],t.plugins){let e=t.plugins.some(e=>!!e.cacheWillUpdate);this.t=e?t.plugins:[i,...t.plugins]}else this.t=[i];this.r=t.fetchOptions||null}handle({event:e}){var r=this;return babelHelpers.asyncToGenerator(function*(){const s=r.s(e);let n=yield t.cacheWrapper.match(r.e,e.request,null,r.t);return n?e.waitUntil(s):n=yield s,n})()}s(e){var s=this;return babelHelpers.asyncToGenerator(function*(){const n=yield r.fetchWrapper.fetch(e.request,s.r,s.t);return e.waitUntil(t.cacheWrapper.put(s.e,e.request,n.clone(),s.t)),n})()}}var h=Object.freeze({CacheFirst:s,CacheOnly:n,NetworkFirst:l,NetworkOnly:o,StaleWhileRevalidate:c});const u={cacheFirst:s,cacheOnly:n,networkFirst:l,networkOnly:o,staleWhileRevalidate:c},a={};Object.keys(u).forEach(e=>{a[e]=((t={})=>{return new(0,u[e])(Object.assign(t))})});return Object.assign(a,h)}(workbox.core._private,workbox.core._private,workbox.core._private);
this.workbox=this.workbox||{},this.workbox.strategies=function(e,t,r){"use strict";try{self.workbox.v["workbox:strategies:3.1.0"]=1}catch(e){}class n{constructor(t={}){this.e=e.cacheNames.getRuntimeName(t.cacheName),this.t=t.plugins||[],this.r=t.fetchOptions||null}handle({event:e}){var t=this;return babelHelpers.asyncToGenerator(function*(){return t.makeRequest({event:e,request:e.request})})()}makeRequest({event:e,request:r}){var n=this;return babelHelpers.asyncToGenerator(function*(){"string"==typeof r&&(r=new Request(r));let s,i=yield t.cacheWrapper.match(n.e,r,null,n.t);if(!i)try{i=yield n.n(r,e)}catch(e){s=e}if(s)throw s;return i})()}n(e,n){var s=this;return babelHelpers.asyncToGenerator(function*(){const i=yield r.fetchWrapper.fetch(e,s.r,s.t),l=i.clone(),u=t.cacheWrapper.put(s.e,e,l,s.t);return n&&n.waitUntil(u),i})()}}class s{constructor(t={}){this.e=e.cacheNames.getRuntimeName(t.cacheName),this.t=t.plugins||[]}handle({event:e}){var t=this;return babelHelpers.asyncToGenerator(function*(){return t.makeRequest({event:e,request:e.request})})()}makeRequest({event:e,request:r}){var n=this;return babelHelpers.asyncToGenerator(function*(){"string"==typeof r&&(r=new Request(r));return yield t.cacheWrapper.match(n.e,r,null,n.t)})()}}var i={cacheWillUpdate:({response:e})=>e.ok||0===e.status?e:null};class l{constructor(t={}){if(this.e=e.cacheNames.getRuntimeName(t.cacheName),t.plugins){let e=t.plugins.some(e=>!!e.cacheWillUpdate);this.t=e?t.plugins:[i,...t.plugins]}else this.t=[i];this.s=t.networkTimeoutSeconds,this.r=t.fetchOptions||null}handle({event:e}){var t=this;return babelHelpers.asyncToGenerator(function*(){return t.makeRequest({event:e,request:e.request})})()}makeRequest({event:e,request:t}){var r=this;return babelHelpers.asyncToGenerator(function*(){const n=[];"string"==typeof t&&(t=new Request(t));const s=[];let i;if(r.s){const{id:e,promise:l}=r.i(t,n);i=e,s.push(l)}const l=r.l(i,e,t,n);s.push(l);let u=yield Promise.race(s);return u||(u=yield l),u})()}i(e,t){var r=this;let n;const s=new Promise(t=>{const s=(()=>{var n=babelHelpers.asyncToGenerator(function*(){t(yield r.u(e))});return function(){return n.apply(this,arguments)}})();n=setTimeout(s,1e3*this.s)});return{promise:s,id:n}}l(e,n,s,i){var l=this;return babelHelpers.asyncToGenerator(function*(){let i,u;try{u=yield r.fetchWrapper.fetch(s,l.r,l.t)}catch(e){i=e}if(e&&clearTimeout(e),i||!u)u=yield l.u(s);else{const e=u.clone(),r=t.cacheWrapper.put(l.e,s,e,l.t);if(n)try{n.waitUntil(r)}catch(e){}}return u})()}u(e){return t.cacheWrapper.match(this.e,e,null,this.t)}}class u{constructor(t={}){this.e=e.cacheNames.getRuntimeName(t.cacheName),this.t=t.plugins||[],this.r=t.fetchOptions||null}handle({event:e}){var t=this;return babelHelpers.asyncToGenerator(function*(){return t.makeRequest({event:e,request:e.request})})()}makeRequest({event:e,request:t}){var n=this;return babelHelpers.asyncToGenerator(function*(){"string"==typeof t&&(t=new Request(t));let e,s;try{s=yield r.fetchWrapper.fetch(t,n.r,n.t)}catch(t){e=t}if(e)throw e;return s})()}}class o{constructor(t={}){if(this.e=e.cacheNames.getRuntimeName(t.cacheName),this.t=t.plugins||[],t.plugins){let e=t.plugins.some(e=>!!e.cacheWillUpdate);this.t=e?t.plugins:[i,...t.plugins]}else this.t=[i];this.r=t.fetchOptions||null}handle({event:e}){var t=this;return babelHelpers.asyncToGenerator(function*(){return t.makeRequest({event:e,request:e.request})})()}makeRequest({event:e,request:r}){var n=this;return babelHelpers.asyncToGenerator(function*(){"string"==typeof r&&(r=new Request(r));const s=n.n(r,e);let i=yield t.cacheWrapper.match(n.e,r,null,n.t);return i?e.waitUntil(s):i=yield s,i})()}n(e,n){var s=this;return babelHelpers.asyncToGenerator(function*(){const i=yield r.fetchWrapper.fetch(e,s.r,s.t),l=t.cacheWrapper.put(s.e,e,i.clone(),s.t);return n&&n.waitUntil(l),i})()}}var c=Object.freeze({CacheFirst:n,CacheOnly:s,NetworkFirst:l,NetworkOnly:u,StaleWhileRevalidate:o});const a={cacheFirst:n,cacheOnly:s,networkFirst:l,networkOnly:u,staleWhileRevalidate:o},h={};Object.keys(a).forEach(e=>{h[e]=((t={})=>{return new(0,a[e])(Object.assign(t))})});return Object.assign(h,c)}(workbox.core._private,workbox.core._private,workbox.core._private);
//# sourceMappingURL=workbox-strategies.prod.js.map
{
"name": "workbox-strategies",
"version": "3.0.1",
"version": "3.1.0",
"license": "Apache-2.0",

@@ -30,4 +30,4 @@ "author": "Google's Web DevRel Team",

"dependencies": {
"workbox-core": "^3.0.1"
"workbox-core": "^3.1.0"
}
}

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