Socket
Socket
Sign inDemoInstall

workbox-core

Package Overview
Dependencies
Maintainers
6
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 6.1.5 to 6.2.0-alpha.0

4

_private.d.ts

@@ -7,5 +7,3 @@ import { assert } from './_private/assert.js';

import { dontWaitFor } from './_private/dontWaitFor.js';
import { DBWrapper } from './_private/DBWrapper.js';
import { Deferred } from './_private/Deferred.js';
import { deleteDatabase } from './_private/deleteDatabase.js';
import { executeQuotaErrorCallbacks } from './_private/executeQuotaErrorCallbacks.js';

@@ -19,2 +17,2 @@ import { getFriendlyURL } from './_private/getFriendlyURL.js';

import './_version.js';
export { assert, cacheMatchIgnoreParams, cacheNames, canConstructReadableStream, canConstructResponseFromBodyStream, dontWaitFor, DBWrapper, Deferred, deleteDatabase, executeQuotaErrorCallbacks, getFriendlyURL, logger, resultingClientExists, timeout, waitUntil, WorkboxError, };
export { assert, cacheMatchIgnoreParams, cacheNames, canConstructReadableStream, canConstructResponseFromBodyStream, dontWaitFor, Deferred, executeQuotaErrorCallbacks, getFriendlyURL, logger, resultingClientExists, timeout, waitUntil, WorkboxError, };

@@ -15,5 +15,3 @@ /*

import { dontWaitFor } from './_private/dontWaitFor.js';
import { DBWrapper } from './_private/DBWrapper.js';
import { Deferred } from './_private/Deferred.js';
import { deleteDatabase } from './_private/deleteDatabase.js';
import { executeQuotaErrorCallbacks } from './_private/executeQuotaErrorCallbacks.js';

@@ -27,2 +25,2 @@ import { getFriendlyURL } from './_private/getFriendlyURL.js';

import './_version.js';
export { assert, cacheMatchIgnoreParams, cacheNames, canConstructReadableStream, canConstructResponseFromBodyStream, dontWaitFor, DBWrapper, Deferred, deleteDatabase, executeQuotaErrorCallbacks, getFriendlyURL, logger, resultingClientExists, timeout, waitUntil, WorkboxError, };
export { assert, cacheMatchIgnoreParams, cacheNames, canConstructReadableStream, canConstructResponseFromBodyStream, dontWaitFor, Deferred, executeQuotaErrorCallbacks, getFriendlyURL, logger, resultingClientExists, timeout, waitUntil, WorkboxError, };

@@ -6,7 +6,7 @@ import { MapLikeObject } from '../types.js';

isArray: (value: any[], details: MapLikeObject) => void;
isInstance: (object: {}, expectedClass: Function, details: MapLikeObject) => void;
isInstance: (object: unknown, expectedClass: Function, details: MapLikeObject) => void;
isOneOf: (value: any, validValues: any[], details: MapLikeObject) => void;
isType: (object: {}, expectedType: string, details: MapLikeObject) => void;
isType: (object: unknown, expectedType: string, details: MapLikeObject) => void;
isArrayOfClass: (value: any, expectedClass: Function, details: MapLikeObject) => void;
} | null;
export { finalAssertExports as assert };

@@ -34,5 +34,8 @@ /*

};
const isInstance = (object, expectedClass, details) => {
const isInstance = (object,
// Need the general type to do the check later.
// eslint-disable-next-line @typescript-eslint/ban-types
expectedClass, details) => {
if (!(object instanceof expectedClass)) {
details['expectedClass'] = expectedClass;
details['expectedClassName'] = expectedClass.name;
throw new WorkboxError('incorrect-class', details);

@@ -48,3 +51,6 @@ }

};
const isArrayOfClass = (value, expectedClass, details) => {
const isArrayOfClass = (value,
// Need general type to do check later.
expectedClass, // eslint-disable-line
details) => {
const error = new WorkboxError('not-array-of-class', details);

@@ -51,0 +57,0 @@ if (!Array.isArray(value)) {

@@ -12,3 +12,3 @@ import '../_version.js';

promise: Promise<T>;
resolve: (value?: T) => void;
resolve: (value: T) => void;
reject: (reason?: any) => void;

@@ -15,0 +15,0 @@ /**

@@ -15,3 +15,3 @@ /*

// Effective no-op.
promise.then(() => { });
void promise.then(() => { });
}

@@ -52,2 +52,3 @@ /*

};
// eslint-disable-next-line @typescript-eslint/ban-types
const api = {};

@@ -54,0 +55,0 @@ const loggerMethods = Object.keys(methodToColorMap);

"use strict";
// @ts-ignore
try {
self['workbox:core:6.1.5'] && _();
self['workbox:core:6.2.0-alpha.0'] && _();
}
catch (e) { }

@@ -6,3 +6,3 @@ this.workbox = this.workbox || {};

try {
self['workbox:core:6.1.5'] && _();
self['workbox:core:6.2.0-alpha.0'] && _();
} catch (e) {}

@@ -59,4 +59,5 @@

}
};
}; // eslint-disable-next-line @typescript-eslint/ban-types
const api = {};

@@ -118,6 +119,7 @@ const loggerMethods = Object.keys(methodToColorMap);

return `The parameter '${paramName}' passed into ` + `'${moduleName}.${className ? className + '.' : ''}` + `${funcName}()' must be of type ${expectedType}.`;
const classNameStr = className ? `${className}.` : '';
return `The parameter '${paramName}' passed into ` + `'${moduleName}.${classNameStr}` + `${funcName}()' must be of type ${expectedType}.`;
},
'incorrect-class': ({
expectedClass,
expectedClassName,
paramName,

@@ -129,11 +131,13 @@ moduleName,

}) => {
if (!expectedClass || !moduleName || !funcName) {
if (!expectedClassName || !moduleName || !funcName) {
throw new Error(`Unexpected input to 'incorrect-class' error.`);
}
const classNameStr = className ? `${className}.` : '';
if (isReturnValueProblem) {
return `The return value from ` + `'${moduleName}.${className ? className + '.' : ''}${funcName}()' ` + `must be an instance of class ${expectedClass.name}.`;
return `The return value from ` + `'${moduleName}.${classNameStr}${funcName}()' ` + `must be an instance of class ${expectedClassName}.`;
}
return `The parameter '${paramName}' passed into ` + `'${moduleName}.${className ? className + '.' : ''}${funcName}()' ` + `must be an instance of class ${expectedClass.name}.`;
return `The parameter '${paramName}' passed into ` + `'${moduleName}.${classNameStr}${funcName}()' ` + `must be an instance of class ${expectedClassName}.`;
},

@@ -166,12 +170,12 @@ 'missing-a-method': ({

return `Two of the entries passed to ` + `'workbox-precaching.PrecacheController.addToCacheList()' had the URL ` + `${firstEntry._entryId} but different revision details. Workbox is ` + `unable to cache and version the asset correctly. Please remove one ` + `of the entries.`;
return `Two of the entries passed to ` + `'workbox-precaching.PrecacheController.addToCacheList()' had the URL ` + `${firstEntry} but different revision details. Workbox is ` + `unable to cache and version the asset correctly. Please remove one ` + `of the entries.`;
},
'plugin-error-request-will-fetch': ({
thrownError
thrownErrorMessage
}) => {
if (!thrownError) {
if (!thrownErrorMessage) {
throw new Error(`Unexpected input to ` + `'plugin-error-request-will-fetch', error.`);
}
return `An error was thrown by a plugins 'requestWillFetch()' method. ` + `The thrown error message was: '${thrownError.message}'.`;
return `An error was thrown by a plugins 'requestWillFetch()' method. ` + `The thrown error message was: '${thrownErrorMessage}'.`;
},

@@ -448,5 +452,7 @@ 'invalid-cache-name': ({

const isInstance = (object, expectedClass, details) => {
const isInstance = (object, // Need the general type to do the check later.
// eslint-disable-next-line @typescript-eslint/ban-types
expectedClass, details) => {
if (!(object instanceof expectedClass)) {
details['expectedClass'] = expectedClass;
details['expectedClassName'] = expectedClass.name;
throw new WorkboxError('incorrect-class', details);

@@ -463,3 +469,5 @@ }

const isArrayOfClass = (value, expectedClass, details) => {
const isArrayOfClass = (value, // Need general type to do check later.
expectedClass, // eslint-disable-line
details) => {
const error = new WorkboxError('not-array-of-class', details);

@@ -494,2 +502,4 @@

*/
// Can't change Function type right now.
// eslint-disable-next-line @typescript-eslint/ban-types

@@ -512,2 +522,4 @@ const quotaErrorCallbacks = new Set();

*/
// Can't change Function type
// eslint-disable-next-line @typescript-eslint/ban-types

@@ -733,3 +745,3 @@ function registerQuotaErrorCallback(callback) {

// Effective no-op.
promise.then(() => {});
void promise.then(() => {});
}

@@ -745,298 +757,2 @@

/**
* A class that wraps common IndexedDB functionality in a promise-based API.
* It exposes all the underlying power and functionality of IndexedDB, but
* wraps the most commonly used features in a way that's much simpler to use.
*
* @private
*/
class DBWrapper {
/**
* @param {string} name
* @param {number} version
* @param {Object=} [callback]
* @param {!Function} [callbacks.onupgradeneeded]
* @param {!Function} [callbacks.onversionchange] Defaults to
* DBWrapper.prototype._onversionchange when not specified.
* @private
*/
constructor(name, version, {
onupgradeneeded,
onversionchange
} = {}) {
this._db = null;
this._name = name;
this._version = version;
this._onupgradeneeded = onupgradeneeded;
this._onversionchange = onversionchange || (() => this.close());
}
/**
* Returns the IDBDatabase instance (not normally needed).
* @return {IDBDatabase|undefined}
*
* @private
*/
get db() {
return this._db;
}
/**
* Opens a connected to an IDBDatabase, invokes any onupgradedneeded
* callback, and added an onversionchange callback to the database.
*
* @return {IDBDatabase}
* @private
*/
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);
openRequest.onerror = () => reject(openRequest.error);
openRequest.onupgradeneeded = evt => {
if (openRequestTimedOut) {
openRequest.transaction.abort();
openRequest.result.close();
} else if (typeof this._onupgradeneeded === 'function') {
this._onupgradeneeded(evt);
}
};
openRequest.onsuccess = () => {
const db = openRequest.result;
if (openRequestTimedOut) {
db.close();
} else {
db.onversionchange = this._onversionchange.bind(this);
resolve(db);
}
};
});
return this;
}
/**
* Polyfills the native `getKey()` method. Note, this is overridden at
* runtime if the browser supports the native method.
*
* @param {string} storeName
* @param {*} query
* @return {Array}
* @private
*/
async getKey(storeName, query) {
return (await this.getAllKeys(storeName, query, 1))[0];
}
/**
* Polyfills the native `getAll()` method. Note, this is overridden at
* runtime if the browser supports the native method.
*
* @param {string} storeName
* @param {*} query
* @param {number} count
* @return {Array}
* @private
*/
async getAll(storeName, query, count) {
return await this.getAllMatching(storeName, {
query,
count
});
}
/**
* Polyfills the native `getAllKeys()` method. Note, this is overridden at
* runtime if the browser supports the native method.
*
* @param {string} storeName
* @param {*} query
* @param {number} count
* @return {Array}
* @private
*/
async getAllKeys(storeName, query, count) {
const entries = await this.getAllMatching(storeName, {
query,
count,
includeKeys: true
});
return entries.map(entry => entry.key);
}
/**
* Supports flexible lookup in an object store by specifying an index,
* query, direction, and count. This method returns an array of objects
* with the signature .
*
* @param {string} storeName
* @param {Object} [opts]
* @param {string} [opts.index] The index to use (if specified).
* @param {*} [opts.query]
* @param {IDBCursorDirection} [opts.direction]
* @param {number} [opts.count] The max number of results to return.
* @param {boolean} [opts.includeKeys] When true, the structure of the
* returned objects is changed from an array of values to an array of
* objects in the form {key, primaryKey, value}.
* @return {Array}
* @private
*/
async getAllMatching(storeName, {
index,
query = null,
// IE/Edge errors if query === `undefined`.
direction = 'next',
count,
includeKeys = false
} = {}) {
return await this.transaction([storeName], 'readonly', (txn, done) => {
const store = txn.objectStore(storeName);
const target = index ? store.index(index) : store;
const results = [];
const request = target.openCursor(query, direction);
request.onsuccess = () => {
const cursor = request.result;
if (cursor) {
results.push(includeKeys ? cursor : cursor.value);
if (count && results.length >= count) {
done(results);
} else {
cursor.continue();
}
} else {
done(results);
}
};
});
}
/**
* Accepts a list of stores, a transaction type, and a callback and
* performs a transaction. A promise is returned that resolves to whatever
* value the callback chooses. The callback holds all the transaction logic
* and is invoked with two arguments:
* 1. The IDBTransaction object
* 2. A `done` function, that's used to resolve the promise when
* when the transaction is done, if passed a value, the promise is
* resolved to that value.
*
* @param {Array<string>} storeNames An array of object store names
* involved in the transaction.
* @param {string} type Can be `readonly` or `readwrite`.
* @param {!Function} callback
* @return {*} The result of the transaction ran by the callback.
* @private
*/
async transaction(storeNames, type, callback) {
await this.open();
return await new Promise((resolve, reject) => {
const txn = this._db.transaction(storeNames, type);
txn.onabort = () => reject(txn.error);
txn.oncomplete = () => resolve();
callback(txn, value => resolve(value));
});
}
/**
* Delegates async to a native IDBObjectStore method.
*
* @param {string} method The method name.
* @param {string} storeName The object store name.
* @param {string} type Can be `readonly` or `readwrite`.
* @param {...*} args The list of args to pass to the native method.
* @return {*} The result of the transaction.
* @private
*/
async _call(method, storeName, type, ...args) {
const callback = (txn, done) => {
const objStore = txn.objectStore(storeName); // TODO(philipwalton): Fix this underlying TS2684 error.
// @ts-ignore
const request = objStore[method].apply(objStore, args);
request.onsuccess = () => done(request.result);
};
return await this.transaction([storeName], type, callback);
}
/**
* Closes the connection opened by `DBWrapper.open()`. Generally this method
* doesn't need to be called since:
* 1. It's usually better to keep a connection open since opening
* a new connection is somewhat slow.
* 2. Connections are automatically closed when the reference is
* garbage collected.
* The primary use case for needing to close a connection is when another
* reference (typically in another tab) needs to upgrade it and would be
* blocked by the current, open connection.
*
* @private
*/
close() {
if (this._db) {
this._db.close();
this._db = null;
}
}
} // Exposed on the prototype to let users modify the default timeout on a
// per-instance or global basis.
DBWrapper.prototype.OPEN_TIMEOUT = 2000; // Wrap native IDBObjectStore methods according to their mode.
const methodsToWrap = {
readonly: ['get', 'count', 'getKey', 'getAll', 'getAllKeys'],
readwrite: ['add', 'put', 'clear', 'delete']
};
for (const [mode, methods] of Object.entries(methodsToWrap)) {
for (const method of methods) {
if (method in IDBObjectStore.prototype) {
// Don't use arrow functions here since we're outside of the class.
DBWrapper.prototype[method] = async function (storeName, ...args) {
return await this._call(method, storeName, mode, ...args);
};
}
}
}
/*
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.
*/
/**
* The Deferred class composes Promises in a way that allows for them to be

@@ -1071,37 +787,2 @@ * resolved or rejected from outside the constructor. In most cases promises

/**
* Deletes the database.
* Note: this is exported separately from the DBWrapper module because most
* usages of IndexedDB in workbox dont need deleting, and this way it can be
* reused in tests to delete databases without creating DBWrapper instances.
*
* @param {string} name The database name.
* @private
*/
const deleteDatabase = async name => {
await new Promise((resolve, reject) => {
const request = indexedDB.deleteDatabase(name);
request.onerror = () => {
reject(request.error);
};
request.onblocked = () => {
reject(new Error('Delete blocked'));
};
request.onsuccess = () => {
resolve();
};
});
};
/*
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.
*/
/**
* Runs all of the callback functions, one at a time sequentially, in the order

@@ -1259,5 +940,3 @@ * in which they were registered.

dontWaitFor: dontWaitFor,
DBWrapper: DBWrapper,
Deferred: Deferred,
deleteDatabase: deleteDatabase,
executeQuotaErrorCallbacks: executeQuotaErrorCallbacks,

@@ -1475,3 +1154,3 @@ getFriendlyURL: getFriendlyURL,

self.skipWaiting();
void self.skipWaiting();
}

@@ -1478,0 +1157,0 @@

@@ -1,2 +0,2 @@

this.workbox=this.workbox||{},this.workbox.core=function(t){"use strict";try{self["workbox:core:6.1.5"]&&_()}catch(t){}const e=(t,...e)=>{let n=t;return e.length>0&&(n+=" :: "+JSON.stringify(e)),n};class n extends Error{constructor(t,n){super(e(t,n)),this.name=t,this.details=n}}const r=new Set;const s={googleAnalytics:"googleAnalytics",precache:"precache-v2",prefix:"workbox",runtime:"runtime",suffix:"undefined"!=typeof registration?registration.scope:""},o=t=>[s.prefix,t,s.suffix].filter((t=>t&&t.length>0)).join("-"),i={updateDetails:t=>{(t=>{for(const e of Object.keys(s))t(e)})((e=>{"string"==typeof t[e]&&(s[e]=t[e])}))},getGoogleAnalyticsName:t=>t||o(s.googleAnalytics),getPrecacheName:t=>t||o(s.precache),getPrefix:()=>s.prefix,getRuntimeName:t=>t||o(s.runtime),getSuffix:()=>s.suffix};function c(){return(c=Object.assign||function(t){for(var e=1;e<arguments.length;e++){var n=arguments[e];for(var r in n)Object.prototype.hasOwnProperty.call(n,r)&&(t[r]=n[r])}return t}).apply(this,arguments)}function a(t,e){const n=new URL(t);for(const t of e)n.searchParams.delete(t);return n.href}let u,l;function f(){if(void 0===l){const t=new Response("");if("body"in t)try{new Response(t.body),l=!0}catch(t){l=!1}l=!1}return l}class h{constructor(t,e,{onupgradeneeded:n,onversionchange:r}={}){this.i=null,this.m=t,this.P=e,this.K=n,this.N=r||(()=>this.close())}get db(){return this.i}async open(){if(!this.i)return this.i=await new Promise(((t,e)=>{let n=!1;setTimeout((()=>{n=!0,e(new Error("The open request was blocked and timed out"))}),this.OPEN_TIMEOUT);const r=indexedDB.open(this.m,this.P);r.onerror=()=>e(r.error),r.onupgradeneeded=t=>{n?(r.transaction.abort(),r.result.close()):"function"==typeof this.K&&this.K(t)},r.onsuccess=()=>{const e=r.result;n?e.close():(e.onversionchange=this.N.bind(this),t(e))}})),this}async getKey(t,e){return(await this.getAllKeys(t,e,1))[0]}async getAll(t,e,n){return await this.getAllMatching(t,{query:e,count:n})}async getAllKeys(t,e,n){return(await this.getAllMatching(t,{query:e,count:n,includeKeys:!0})).map((t=>t.key))}async getAllMatching(t,{index:e,query:n=null,direction:r="next",count:s,includeKeys:o=!1}={}){return await this.transaction([t],"readonly",((i,c)=>{const a=i.objectStore(t),u=e?a.index(e):a,l=[],f=u.openCursor(n,r);f.onsuccess=()=>{const t=f.result;t?(l.push(o?t:t.value),s&&l.length>=s?c(l):t.continue()):c(l)}}))}async transaction(t,e,n){return await this.open(),await new Promise(((r,s)=>{const o=this.i.transaction(t,e);o.onabort=()=>s(o.error),o.oncomplete=()=>r(),n(o,(t=>r(t)))}))}async L(t,e,n,...r){return await this.transaction([e],n,((n,s)=>{const o=n.objectStore(e),i=o[t].apply(o,r);i.onsuccess=()=>s(i.result)}))}close(){this.i&&(this.i.close(),this.i=null)}}h.prototype.OPEN_TIMEOUT=2e3;const w={readonly:["get","count","getKey","getAll","getAllKeys"],readwrite:["add","put","clear","delete"]};for(const[t,e]of Object.entries(w))for(const n of e)n in IDBObjectStore.prototype&&(h.prototype[n]=async function(e,...r){return await this.L(n,e,t,...r)});function g(t){return new Promise((e=>setTimeout(e,t)))}var d=Object.freeze({__proto__:null,assert:null,cacheMatchIgnoreParams:async function(t,e,n,r){const s=a(e.url,n);if(e.url===s)return t.match(e,r);const o=c({},r,{ignoreSearch:!0}),i=await t.keys(e,o);for(const e of i){if(s===a(e.url,n))return t.match(e,r)}},cacheNames:i,canConstructReadableStream:function(){if(void 0===u)try{new ReadableStream({start(){}}),u=!0}catch(t){u=!1}return u},canConstructResponseFromBodyStream:f,dontWaitFor:function(t){t.then((()=>{}))},DBWrapper:h,Deferred:class{constructor(){this.promise=new Promise(((t,e)=>{this.resolve=t,this.reject=e}))}},deleteDatabase:async t=>{await new Promise(((e,n)=>{const r=indexedDB.deleteDatabase(t);r.onerror=()=>{n(r.error)},r.onblocked=()=>{n(new Error("Delete blocked"))},r.onsuccess=()=>{e()}}))},executeQuotaErrorCallbacks:async function(){for(const t of r)await t()},getFriendlyURL:t=>new URL(String(t),location.href).href.replace(new RegExp("^"+location.origin),""),logger:null,resultingClientExists:async function(t){if(!t)return;let e=await self.clients.matchAll({type:"window"});const n=new Set(e.map((t=>t.id)));let r;const s=performance.now();for(;performance.now()-s<2e3&&(e=await self.clients.matchAll({type:"window"}),r=e.find((e=>t?e.id===t:!n.has(e.id))),!r);)await g(100);return r},timeout:g,waitUntil:function(t,e){const n=e();return t.waitUntil(n),n},WorkboxError:n});const y={get googleAnalytics(){return i.getGoogleAnalyticsName()},get precache(){return i.getPrecacheName()},get prefix(){return i.getPrefix()},get runtime(){return i.getRuntimeName()},get suffix(){return i.getSuffix()}};return t._private=d,t.cacheNames=y,t.clientsClaim=function(){self.addEventListener("activate",(()=>self.clients.claim()))},t.copyResponse=async function(t,e){let r=null;if(t.url){r=new URL(t.url).origin}if(r!==self.location.origin)throw new n("cross-origin-copy-response",{origin:r});const s=t.clone(),o={headers:new Headers(s.headers),status:s.status,statusText:s.statusText},i=e?e(o):o,c=f()?s.body:await s.blob();return new Response(c,i)},t.registerQuotaErrorCallback=function(t){r.add(t)},t.setCacheNameDetails=function(t){i.updateDetails(t)},t.skipWaiting=function(){self.skipWaiting()},t}({});
this.workbox=this.workbox||{},this.workbox.core=function(t){"use strict";try{self["workbox:core:6.2.0-alpha.0"]&&_()}catch(t){}const e=(t,...e)=>{let n=t;return e.length>0&&(n+=" :: "+JSON.stringify(e)),n};class n extends Error{constructor(t,n){super(e(t,n)),this.name=t,this.details=n}}const r=new Set;const o={googleAnalytics:"googleAnalytics",precache:"precache-v2",prefix:"workbox",runtime:"runtime",suffix:"undefined"!=typeof registration?registration.scope:""},i=t=>[o.prefix,t,o.suffix].filter((t=>t&&t.length>0)).join("-"),s={updateDetails:t=>{(t=>{for(const e of Object.keys(o))t(e)})((e=>{"string"==typeof t[e]&&(o[e]=t[e])}))},getGoogleAnalyticsName:t=>t||i(o.googleAnalytics),getPrecacheName:t=>t||i(o.precache),getPrefix:()=>o.prefix,getRuntimeName:t=>t||i(o.runtime),getSuffix:()=>o.suffix};function c(){return(c=Object.assign||function(t){for(var e=1;e<arguments.length;e++){var n=arguments[e];for(var r in n)Object.prototype.hasOwnProperty.call(n,r)&&(t[r]=n[r])}return t}).apply(this,arguments)}function a(t,e){const n=new URL(t);for(const t of e)n.searchParams.delete(t);return n.href}let u,f;function l(){if(void 0===f){const t=new Response("");if("body"in t)try{new Response(t.body),f=!0}catch(t){f=!1}f=!1}return f}function g(t){return new Promise((e=>setTimeout(e,t)))}var w=Object.freeze({__proto__:null,assert:null,cacheMatchIgnoreParams:async function(t,e,n,r){const o=a(e.url,n);if(e.url===o)return t.match(e,r);const i=c({},r,{ignoreSearch:!0}),s=await t.keys(e,i);for(const e of s){if(o===a(e.url,n))return t.match(e,r)}},cacheNames:s,canConstructReadableStream:function(){if(void 0===u)try{new ReadableStream({start(){}}),u=!0}catch(t){u=!1}return u},canConstructResponseFromBodyStream:l,dontWaitFor:function(t){t.then((()=>{}))},Deferred:class{constructor(){this.promise=new Promise(((t,e)=>{this.resolve=t,this.reject=e}))}},executeQuotaErrorCallbacks:async function(){for(const t of r)await t()},getFriendlyURL:t=>new URL(String(t),location.href).href.replace(new RegExp("^"+location.origin),""),logger:null,resultingClientExists:async function(t){if(!t)return;let e=await self.clients.matchAll({type:"window"});const n=new Set(e.map((t=>t.id)));let r;const o=performance.now();for(;performance.now()-o<2e3&&(e=await self.clients.matchAll({type:"window"}),r=e.find((e=>t?e.id===t:!n.has(e.id))),!r);)await g(100);return r},timeout:g,waitUntil:function(t,e){const n=e();return t.waitUntil(n),n},WorkboxError:n});const h={get googleAnalytics(){return s.getGoogleAnalyticsName()},get precache(){return s.getPrecacheName()},get prefix(){return s.getPrefix()},get runtime(){return s.getRuntimeName()},get suffix(){return s.getSuffix()}};return t._private=w,t.cacheNames=h,t.clientsClaim=function(){self.addEventListener("activate",(()=>self.clients.claim()))},t.copyResponse=async function(t,e){let r=null;if(t.url){r=new URL(t.url).origin}if(r!==self.location.origin)throw new n("cross-origin-copy-response",{origin:r});const o=t.clone(),i={headers:new Headers(o.headers),status:o.status,statusText:o.statusText},s=e?e(i):i,c=l()?o.body:await o.blob();return new Response(c,s)},t.registerQuotaErrorCallback=function(t){r.add(t)},t.setCacheNameDetails=function(t){s.updateDetails(t)},t.skipWaiting=function(){self.skipWaiting()},t}({});
//# sourceMappingURL=workbox-core.prod.js.map

@@ -1,7 +0,9 @@

import { MapLikeObject } from '../../types.js';
import '../../_version.js';
interface LoggableObject {
[key: string]: string | number;
}
interface MessageMap {
[messageID: string]: (param: MapLikeObject) => string;
[messageID: string]: (param: LoggableObject) => string;
}
export declare const messages: MessageMap;
export {};

@@ -29,18 +29,20 @@ /*

}
const classNameStr = className ? `${className}.` : '';
return `The parameter '${paramName}' passed into ` +
`'${moduleName}.${className ? (className + '.') : ''}` +
`'${moduleName}.${classNameStr}` +
`${funcName}()' must be of type ${expectedType}.`;
},
'incorrect-class': ({ expectedClass, paramName, moduleName, className, funcName, isReturnValueProblem }) => {
if (!expectedClass || !moduleName || !funcName) {
'incorrect-class': ({ expectedClassName, paramName, moduleName, className, funcName, isReturnValueProblem }) => {
if (!expectedClassName || !moduleName || !funcName) {
throw new Error(`Unexpected input to 'incorrect-class' error.`);
}
const classNameStr = className ? `${className}.` : '';
if (isReturnValueProblem) {
return `The return value from ` +
`'${moduleName}.${className ? (className + '.') : ''}${funcName}()' ` +
`must be an instance of class ${expectedClass.name}.`;
`'${moduleName}.${classNameStr}${funcName}()' ` +
`must be an instance of class ${expectedClassName}.`;
}
return `The parameter '${paramName}' passed into ` +
`'${moduleName}.${className ? (className + '.') : ''}${funcName}()' ` +
`must be an instance of class ${expectedClass.name}.`;
`'${moduleName}.${classNameStr}${funcName}()' ` +
`must be an instance of class ${expectedClassName}.`;
},

@@ -69,8 +71,8 @@ 'missing-a-method': ({ expectedMethod, paramName, moduleName, className, funcName }) => {

`'workbox-precaching.PrecacheController.addToCacheList()' had the URL ` +
`${firstEntry._entryId} but different revision details. Workbox is ` +
`${firstEntry} but different revision details. Workbox is ` +
`unable to cache and version the asset correctly. Please remove one ` +
`of the entries.`;
},
'plugin-error-request-will-fetch': ({ thrownError }) => {
if (!thrownError) {
'plugin-error-request-will-fetch': ({ thrownErrorMessage }) => {
if (!thrownErrorMessage) {
throw new Error(`Unexpected input to ` +

@@ -80,3 +82,3 @@ `'plugin-error-request-will-fetch', error.`);

return `An error was thrown by a plugins 'requestWillFetch()' method. ` +
`The thrown error message was: '${thrownError.message}'.`;
`The thrown error message was: '${thrownErrorMessage}'.`;
},

@@ -83,0 +85,0 @@ 'invalid-cache-name': ({ cacheNameId, value }) => {

@@ -10,3 +10,5 @@ /*

// Callbacks to be executed whenever there's a quota error.
// Can't change Function type right now.
// eslint-disable-next-line @typescript-eslint/ban-types
const quotaErrorCallbacks = new Set();
export { quotaErrorCallbacks };
{
"name": "workbox-core",
"version": "6.1.5",
"version": "6.2.0-alpha.0",
"license": "MIT",

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

"types": "index.d.ts",
"gitHead": "d559fc8b3240f723fd9721f3976797dcedf7112b"
"gitHead": "46af63c1780955345c117c63c8c8dd54f3d40220"
}

@@ -19,2 +19,4 @@ /*

*/
// Can't change Function type
// eslint-disable-next-line @typescript-eslint/ban-types
function registerQuotaErrorCallback(callback) {

@@ -21,0 +23,0 @@ if (process.env.NODE_ENV !== 'production') {

@@ -25,4 +25,4 @@ /*

}
self.skipWaiting();
void self.skipWaiting();
}
export { skipWaiting };

@@ -16,5 +16,3 @@ /*

import {dontWaitFor} from './_private/dontWaitFor.js';
import {DBWrapper} from './_private/DBWrapper.js';
import {Deferred} from './_private/Deferred.js';
import {deleteDatabase} from './_private/deleteDatabase.js';
import {executeQuotaErrorCallbacks} from './_private/executeQuotaErrorCallbacks.js';

@@ -37,5 +35,3 @@ import {getFriendlyURL} from './_private/getFriendlyURL.js';

dontWaitFor,
DBWrapper,
Deferred,
deleteDatabase,
executeQuotaErrorCallbacks,

@@ -42,0 +38,0 @@ getFriendlyURL,

@@ -41,3 +41,3 @@ /*

const isType = (
object: {},
object: unknown,
expectedType: string,

@@ -53,3 +53,5 @@ details: MapLikeObject,

const isInstance = (
object: {},
object: unknown,
// Need the general type to do the check later.
// eslint-disable-next-line @typescript-eslint/ban-types
expectedClass: Function,

@@ -59,3 +61,3 @@ details: MapLikeObject,

if (!(object instanceof expectedClass)) {
details['expectedClass'] = expectedClass;
details['expectedClassName'] = expectedClass.name;
throw new WorkboxError('incorrect-class', details);

@@ -78,3 +80,4 @@ }

value: any,
expectedClass: Function,
// Need general type to do check later.
expectedClass: Function, // eslint-disable-line
details: MapLikeObject,

@@ -81,0 +84,0 @@ ) => {

@@ -15,6 +15,6 @@ /*

export interface CacheNameDetails {
googleAnalytics: string;
precache: string;
prefix: string;
runtime: string;
googleAnalytics: string;
precache: string;
prefix: string;
runtime: string;
suffix: string;

@@ -45,11 +45,11 @@ }

const eachCacheNameDetail = (fn: Function): void => {
const eachCacheNameDetail = (fn: (key: CacheNameDetailsProp) => void): void => {
for (const key of Object.keys(_cacheNameDetails)) {
fn(key as CacheNameDetailsProp);
}
}
}
export const cacheNames = {
updateDetails: (details: PartialCacheNameDetails) => {
eachCacheNameDetail((key: CacheNameDetailsProp) => {
updateDetails: (details: PartialCacheNameDetails): void => {
eachCacheNameDetail((key: CacheNameDetailsProp): void => {
if (typeof details[key] === 'string') {

@@ -60,17 +60,17 @@ _cacheNameDetails[key] = details[key];

},
getGoogleAnalyticsName: (userCacheName?: string) => {
getGoogleAnalyticsName: (userCacheName?: string): string => {
return userCacheName || _createCacheName(_cacheNameDetails.googleAnalytics);
},
getPrecacheName: (userCacheName?: string) => {
getPrecacheName: (userCacheName?: string): string => {
return userCacheName || _createCacheName(_cacheNameDetails.precache);
},
getPrefix: () => {
getPrefix: (): string => {
return _cacheNameDetails.prefix;
},
getRuntimeName: (userCacheName?: string) => {
getRuntimeName: (userCacheName?: string): string => {
return userCacheName || _createCacheName(_cacheNameDetails.runtime);
},
getSuffix: () => {
getSuffix: (): string => {
return _cacheNameDetails.suffix;
},
};

@@ -22,3 +22,3 @@ /*

promise: Promise<T>;
resolve!: (value?: T) => void;
resolve!: (value: T) => void;
reject!: (reason?: any) => void;

@@ -25,0 +25,0 @@

@@ -17,3 +17,3 @@ /*

// Effective no-op.
promise.then(() => {});
void promise.then(() => { });
}

@@ -21,3 +21,3 @@ /*

*/
async function executeQuotaErrorCallbacks() {
async function executeQuotaErrorCallbacks(): Promise<void> {
if (process.env.NODE_ENV !== 'production') {

@@ -24,0 +24,0 @@ logger.log(`About to run ${quotaErrorCallbacks.size} ` +

@@ -11,3 +11,3 @@ /*

const getFriendlyURL = (url: URL | string) => {
const getFriendlyURL = (url: URL | string): string => {
const urlObj = new URL(String(url), location.href);

@@ -14,0 +14,0 @@ // See https://github.com/GoogleChrome/workbox/issues/2323

@@ -22,3 +22,3 @@ /*

type LoggerMethods = 'debug'|'log'|'warn'|'error'|'groupCollapsed'|'groupEnd';
const logger = (process.env.NODE_ENV === 'production' ? null : (() => {

@@ -57,3 +57,3 @@ // Don't overwrite this value if it's already set.

const styles = [
`background: ${methodToColorMap[method]}`,
`background: ${methodToColorMap[method]!}`,
`border-radius: 0.5em`,

@@ -77,3 +77,3 @@ `color: white`,

};
// eslint-disable-next-line @typescript-eslint/ban-types
const api: {[methodName: string]: Function} = {};

@@ -80,0 +80,0 @@ const loggerMethods = Object.keys(methodToColorMap);

@@ -20,4 +20,4 @@ /*

export function timeout(ms: number) {
export function timeout(ms: number): Promise<unknown> {
return new Promise((resolve) => setTimeout(resolve, ms));
}

@@ -20,3 +20,3 @@ /*

*/
function waitUntil(event: ExtendableEvent, asyncFn: () => Promise<any>) {
function waitUntil(event: ExtendableEvent, asyncFn: () => Promise<any>): Promise<any> {
const returnPromise = asyncFn();

@@ -23,0 +23,0 @@ event.waitUntil(returnPromise);

// @ts-ignore
try{self['workbox:core:6.1.5']&&_()}catch(e){}
try{self['workbox:core:6.2.0-alpha.0']&&_()}catch(e){}

@@ -29,15 +29,15 @@ /*

const cacheNames = {
get googleAnalytics() {
get googleAnalytics(): string {
return _cacheNames.getGoogleAnalyticsName();
},
get precache() {
get precache(): string {
return _cacheNames.getPrecacheName();
},
get prefix() {
get prefix(): string {
return _cacheNames.getPrefix();
},
get runtime() {
get runtime(): string {
return _cacheNames.getRuntimeName();
},
get suffix() {
get suffix(): string {
return _cacheNames.getSuffix();

@@ -44,0 +44,0 @@ },

@@ -21,3 +21,3 @@ /*

*/
function clientsClaim() {
function clientsClaim(): void {
self.addEventListener('activate', () => self.clients.claim());

@@ -24,0 +24,0 @@ }

@@ -25,3 +25,3 @@ /*

* new object.
*
*
* This method is intentionally limited to same-origin responses, regardless of

@@ -37,3 +37,3 @@ * whether CORS was used or not.

modifier?: (responseInit: ResponseInit) => ResponseInit
) {
): Promise<Response> {
let origin = null;

@@ -40,0 +40,0 @@ // If response.url isn't set, assume it's cross-origin and keep origin null.

@@ -9,8 +9,10 @@ /*

import {MapLikeObject} from '../../types.js';
import '../../_version.js';
interface LoggableObject {
[key: string]: string | number;
}
interface MessageMap {
[messageID: string]: (param: MapLikeObject) => string;
[messageID: string]: (param: LoggableObject) => string;
}

@@ -41,22 +43,23 @@

}
const classNameStr = className ? `${className}.` : '';
return `The parameter '${paramName}' passed into ` +
`'${moduleName}.${className ? (className + '.') : ''}` +
`'${moduleName}.${classNameStr}` +
`${funcName}()' must be of type ${expectedType}.`;
},
'incorrect-class': ({expectedClass, paramName, moduleName, className,
'incorrect-class': ({expectedClassName, paramName, moduleName, className,
funcName, isReturnValueProblem}) => {
if (!expectedClass || !moduleName || !funcName) {
if (!expectedClassName || !moduleName || !funcName) {
throw new Error(`Unexpected input to 'incorrect-class' error.`);
}
const classNameStr = className ? `${className}.` : '';
if (isReturnValueProblem) {
return `The return value from ` +
`'${moduleName}.${className ? (className + '.') : ''}${funcName}()' ` +
`must be an instance of class ${expectedClass.name}.`;
`'${moduleName}.${classNameStr}${funcName}()' ` +
`must be an instance of class ${expectedClassName}.`;
}
return `The parameter '${paramName}' passed into ` +
`'${moduleName}.${className ? (className + '.') : ''}${funcName}()' ` +
`must be an instance of class ${expectedClass.name}.`;
`'${moduleName}.${classNameStr}${funcName}()' ` +
`must be an instance of class ${expectedClassName}.`;
},

@@ -90,3 +93,3 @@

`'workbox-precaching.PrecacheController.addToCacheList()' had the URL ` +
`${firstEntry._entryId} but different revision details. Workbox is ` +
`${firstEntry} but different revision details. Workbox is ` +
`unable to cache and version the asset correctly. Please remove one ` +

@@ -96,4 +99,4 @@ `of the entries.`;

'plugin-error-request-will-fetch': ({thrownError}) => {
if (!thrownError) {
'plugin-error-request-will-fetch': ({thrownErrorMessage}) => {
if (!thrownErrorMessage) {
throw new Error(`Unexpected input to ` +

@@ -104,3 +107,3 @@ `'plugin-error-request-will-fetch', error.`);

return `An error was thrown by a plugins 'requestWillFetch()' method. ` +
`The thrown error message was: '${thrownError.message}'.`;
`The thrown error message was: '${thrownErrorMessage}'.`;
},

@@ -107,0 +110,0 @@

@@ -13,4 +13,6 @@ /*

// Callbacks to be executed whenever there's a quota error.
// Can't change Function type right now.
// eslint-disable-next-line @typescript-eslint/ban-types
const quotaErrorCallbacks: Set<Function> = new Set();
export {quotaErrorCallbacks};

@@ -22,3 +22,5 @@ /*

*/
function registerQuotaErrorCallback(callback: Function) {
// Can't change Function type
// eslint-disable-next-line @typescript-eslint/ban-types
function registerQuotaErrorCallback(callback: Function): void {
if (process.env.NODE_ENV !== 'production') {

@@ -25,0 +27,0 @@ assert!.isType(callback, 'function', {

@@ -32,3 +32,3 @@ /*

*/
function setCacheNameDetails(details: PartialCacheNameDetails) {
function setCacheNameDetails(details: PartialCacheNameDetails): void {
if (process.env.NODE_ENV !== 'production') {

@@ -35,0 +35,0 @@ Object.keys(details).forEach((key) => {

@@ -18,3 +18,3 @@ /*

* This method is deprecated, and will be removed in Workbox v7.
*
*
* Calling self.skipWaiting() is equivalent, and should be used instead.

@@ -24,3 +24,3 @@ *

*/
function skipWaiting() {
function skipWaiting(): void {
// Just call self.skipWaiting() directly.

@@ -34,5 +34,5 @@ // See https://github.com/GoogleChrome/workbox/issues/2525

self.skipWaiting();
void self.skipWaiting();
}
export {skipWaiting}

@@ -212,3 +212,3 @@ /*

interface HandlerDidErrorCallbackParam {
export interface HandlerDidErrorCallbackParam {
request: Request;

@@ -215,0 +215,0 @@ event: ExtendableEvent;

@@ -14,5 +14,5 @@ /*

export const pluginUtils = {
filter: (plugins: WorkboxPlugin[], callbackName: string) => {
filter: (plugins: WorkboxPlugin[], callbackName: string): WorkboxPlugin[] => {
return plugins.filter((plugin) => callbackName in plugin);
},
};

@@ -172,3 +172,3 @@ import './_version.js';

}
interface HandlerDidErrorCallbackParam {
export interface HandlerDidErrorCallbackParam {
request: Request;

@@ -233,2 +233,1 @@ event: ExtendableEvent;

}
export {};

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