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 5.0.0-beta.1 to 5.0.0-rc.0

_private/dontWaitFor.d.ts

3

_private.d.ts

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

import { canConstructResponseFromBodyStream } from './_private/canConstructResponseFromBodyStream.js';
import { dontWaitFor } from './_private/dontWaitFor.js';
import { DBWrapper } from './_private/DBWrapper.js';

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

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

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

import { canConstructResponseFromBodyStream } from './_private/canConstructResponseFromBodyStream.js';
import { dontWaitFor } from './_private/dontWaitFor.js';
import { DBWrapper } from './_private/DBWrapper.js';

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

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

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

if (type !== 'function') {
details.expectedMethod = expectedMethod;
details['expectedMethod'] = expectedMethod;
throw new WorkboxError('missing-a-method', details);

@@ -39,3 +39,3 @@ }

if (typeof object !== expectedType) {
details.expectedType = expectedType;
details['expectedType'] = expectedType;
throw new WorkboxError('incorrect-type', details);

@@ -46,3 +46,3 @@ }

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

@@ -53,3 +53,3 @@ }

if (!validValues.includes(value)) {
details.validValueDescription =
details['validValueDescription'] =
`Valid values are ${JSON.stringify(validValues)}.`;

@@ -56,0 +56,0 @@ throw new WorkboxError('invalid-value', details);

@@ -8,8 +8,8 @@ /*

*/
import { WorkboxError } from './WorkboxError.js';
import { assert } from './assert.js';
import { executeQuotaErrorCallbacks } from './executeQuotaErrorCallbacks.js';
import { getFriendlyURL } from './getFriendlyURL.js';
import { logger } from './logger.js';
import { executeQuotaErrorCallbacks } from './executeQuotaErrorCallbacks.js';
import { pluginUtils } from '../utils/pluginUtils.js';
import { WorkboxError } from './WorkboxError.js';
import '../_version.js';

@@ -103,3 +103,3 @@ /**

* cache entries.
* @param {Event} [options.event] The event that propted the action.
* @param {Event} [options.event] The event that prompted the action.
* @param {Object} [options.matchOptions] Options passed to cache.match().

@@ -106,0 +106,0 @@ * @param {Array<Object>} [options.plugins=[]] Array of plugins.

@@ -28,9 +28,9 @@ import '../_version.js';

private _db;
get: Function;
count: Function;
add: Function;
put: Function;
clear: Function;
delete: Function;
OPEN_TIMEOUT: number;
add?: Function;
clear?: Function;
count?: Function;
delete?: Function;
get?: Function;
put?: Function;
OPEN_TIMEOUT?: number;
/**

@@ -37,0 +37,0 @@ * @param {string} name

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

const objStore = txn.objectStore(storeName);
// TODO(philipwalton): Fix this underlying TS2684 error.
// @ts-ignore
const request = objStore[method].apply(objStore, args);

@@ -208,0 +210,0 @@ request.onsuccess = () => done(request.result);

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

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

@@ -16,0 +16,0 @@ * Creates a promise and exposes its resolve and reject functions as methods.

@@ -5,3 +5,3 @@ import { WorkboxPlugin } from '../types.js';

request: Request | string;
event?: FetchEvent | Event;
event?: ExtendableEvent;
plugins?: WorkboxPlugin[];

@@ -8,0 +8,0 @@ fetchOptions?: RequestInit;

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

* @param {Object} [options.fetchOptions]
* @param {Event} [options.event]
* @param {ExtendableEvent} [options.event]
* @param {Array<Object>} [options.plugins=[]]

@@ -25,0 +25,0 @@ * @return {Promise<Response>}

import '../_version.js';
/**
* Returns a promise that resolves and the passed number of milliseconds.
* This utily is an async/await-friendly version of `setTimeout`.
* This utility is an async/await-friendly version of `setTimeout`.
*

@@ -6,0 +6,0 @@ * @param {number} ms

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

* Returns a promise that resolves and the passed number of milliseconds.
* This utily is an async/await-friendly version of `setTimeout`.
* This utility is an async/await-friendly version of `setTimeout`.
*

@@ -13,0 +13,0 @@ * @param {number} ms

@@ -0,5 +1,6 @@

"use strict";
// @ts-ignore
try {
self['workbox:core:5.0.0-beta.1'] && _();
self['workbox:core:5.0.0-rc.0'] && _();
}
catch (e) { }

@@ -5,5 +5,4 @@ this.workbox = this.workbox || {};

// @ts-ignore
try {
self['workbox:core:5.0.0-beta.1'] && _();
self['workbox:core:5.0.0-rc.0'] && _();
} catch (e) {}

@@ -333,3 +332,3 @@

}) => {
return `createHandlerForURL('${url}') was called, but that URL is not ` + `precached. Please pass in a URL that is precached instead.`;
return `createHandlerBoundToURL('${url}') was called, but that URL is ` + `not precached. Please pass in a URL that is precached instead.`;
},

@@ -340,2 +339,8 @@ 'add-to-cache-list-conflicting-integrities': ({

return `Two of the entries passed to ` + `'workbox-precaching.PrecacheController.addToCacheList()' had the URL ` + `${url} with different integrity values. Please remove one of them.`;
},
'missing-precache-entry': ({
cacheName,
url
}) => {
return `Unable to find a precached response in ${cacheName} for ${url}.`;
}

@@ -435,3 +440,3 @@ };

if (type !== 'function') {
details.expectedMethod = expectedMethod;
details['expectedMethod'] = expectedMethod;
throw new WorkboxError('missing-a-method', details);

@@ -443,3 +448,3 @@ }

if (typeof object !== expectedType) {
details.expectedType = expectedType;
details['expectedType'] = expectedType;
throw new WorkboxError('incorrect-type', details);

@@ -451,3 +456,3 @@ }

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

@@ -459,3 +464,3 @@ }

if (!validValues.includes(value)) {
details.validValueDescription = `Valid values are ${JSON.stringify(validValues)}.`;
details['validValueDescription'] = `Valid values are ${JSON.stringify(validValues)}.`;
throw new WorkboxError('invalid-value', details);

@@ -587,20 +592,2 @@ }

*/
const getFriendlyURL = url => {
const urlObj = new URL(String(url), location.href);
if (urlObj.origin === location.origin) {
return urlObj.pathname;
}
return urlObj.href;
};
/*
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.
*/
/**

@@ -639,2 +626,20 @@ * Runs all of the callback functions, one at a time sequentially, in the order

*/
const getFriendlyURL = url => {
const urlObj = new URL(String(url), location.href);
if (urlObj.origin === location.origin) {
return urlObj.pathname;
}
return urlObj.href;
};
/*
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.
*/
const pluginUtils = {

@@ -763,3 +768,3 @@ filter: (plugins, callbackName) => {

* cache entries.
* @param {Event} [options.event] The event that propted the action.
* @param {Event} [options.event] The event that prompted the action.
* @param {Object} [options.matchOptions] Options passed to cache.match().

@@ -1035,2 +1040,19 @@ * @param {Array<Object>} [options.plugins=[]] Array of plugins.

/*
Copyright 2019 Google LLC
Use of this source code is governed by an MIT-style
license that can be found in the LICENSE file or at
https://opensource.org/licenses/MIT.
*/
/**
* A helper function that prevents a promise from being flagged as unused.
*
* @private
**/
function dontWaitFor(promise) {
// Effective no-op.
promise.then(() => {});
}
/*
Copyright 2018 Google LLC

@@ -1277,3 +1299,5 @@

const callback = (txn, done) => {
const objStore = txn.objectStore(storeName);
const objStore = txn.objectStore(storeName); // TODO(philipwalton): Fix this underlying TS2684 error.
// @ts-ignore
const request = objStore[method].apply(objStore, args);

@@ -1409,3 +1433,3 @@

* @param {Object} [options.fetchOptions]
* @param {Event} [options.event]
* @param {ExtendableEvent} [options.event]
* @param {Array<Object>} [options.plugins=[]]

@@ -1571,3 +1595,3 @@ * @return {Promise<Response>}

* Returns a promise that resolves and the passed number of milliseconds.
* This utily is an async/await-friendly version of `setTimeout`.
* This utility is an async/await-friendly version of `setTimeout`.
*

@@ -1652,2 +1676,3 @@ * @param {number} ms

canConstructResponseFromBodyStream: canConstructResponseFromBodyStream,
dontWaitFor: dontWaitFor,
DBWrapper: DBWrapper,

@@ -1805,20 +1830,20 @@ Deferred: Deferred,

if ('precache' in details && details.precache.length === 0) {
if ('precache' in details && details['precache'].length === 0) {
throw new WorkboxError('invalid-cache-name', {
cacheNameId: 'precache',
value: details.precache
value: details['precache']
});
}
if ('runtime' in details && details.runtime.length === 0) {
if ('runtime' in details && details['runtime'].length === 0) {
throw new WorkboxError('invalid-cache-name', {
cacheNameId: 'runtime',
value: details.runtime
value: details['runtime']
});
}
if ('googleAnalytics' in details && details.googleAnalytics.length === 0) {
if ('googleAnalytics' in details && details['googleAnalytics'].length === 0) {
throw new WorkboxError('invalid-cache-name', {
cacheNameId: 'googleAnalytics',
value: details.googleAnalytics
value: details['googleAnalytics']
});

@@ -1825,0 +1850,0 @@ }

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

this.workbox=this.workbox||{},this.workbox.core=function(e){"use strict";try{self["workbox:core:5.0.0-beta.1"]&&_()}catch(e){}const t=(e,...t)=>{let n=e;return t.length>0&&(n+=` :: ${JSON.stringify(t)}`),n};class n extends Error{constructor(e,n){super(t(e,n)),this.name=e,this.details=n}}const s=new Set;const r={googleAnalytics:"googleAnalytics",precache:"precache-v2",prefix:"workbox",runtime:"runtime",suffix:registration.scope},a=e=>[r.prefix,e,r.suffix].filter(e=>e&&e.length>0).join("-"),i={updateDetails:e=>{(e=>{for(const t of Object.keys(r))e(t)})(t=>{"string"==typeof e[t]&&(r[t]=e[t])})},getGoogleAnalyticsName:e=>e||a(r.googleAnalytics),getPrecacheName:e=>e||a(r.precache),getPrefix:()=>r.prefix,getRuntimeName:e=>e||a(r.runtime),getSuffix:()=>r.suffix},o=e=>{const t=new URL(String(e),location.href);return t.origin===location.origin?t.pathname:t.href};async function c(){for(const e of s)await e()}const u=(e,t)=>e.filter(e=>t in e),l=async({cacheName:e,request:t,event:n,matchOptions:s,plugins:r=[]})=>{const a=await caches.open(e),i=await f({plugins:r,request:t,mode:"read"});let o=await a.match(i,s);for(const t of r)if("cachedResponseWillBeUsed"in t){const r=t.cachedResponseWillBeUsed;o=await r.call(t,{cacheName:e,event:n,matchOptions:s,cachedResponse:o,request:i})}return o},h=async({request:e,response:t,event:n,plugins:s=[]})=>{let r=t,a=!1;for(let t of s)if("cacheWillUpdate"in t){a=!0;const s=t.cacheWillUpdate;if(!(r=await s.call(t,{request:e,response:r,event:n})))break}return a||(r=r&&200===r.status?r:void 0),r||null},f=async({request:e,mode:t,plugins:n=[]})=>{const s=u(n,"cacheKeyWillBeUsed");let r=e;for(const e of s)"string"==typeof(r=await e.cacheKeyWillBeUsed.call(e,{mode:t,request:r}))&&(r=new Request(r));return r},w={put:async({cacheName:e,request:t,response:s,event:r,plugins:a=[],matchOptions:i})=>{const w=await f({plugins:a,request:t,mode:"write"});if(!s)throw new n("cache-put-with-no-response",{url:o(w.url)});let d=await h({event:r,plugins:a,response:s,request:w});if(!d)return;const p=await caches.open(e),g=u(a,"cacheDidUpdate");let y=g.length>0?await l({cacheName:e,matchOptions:i,request:w}):null;try{await p.put(w,d)}catch(e){throw"QuotaExceededError"===e.name&&await c(),e}for(let t of g)await t.cacheDidUpdate.call(t,{cacheName:e,event:r,oldResponse:y,newResponse:d,request:w})},match:l};let d,p;function g(){if(void 0===p){const e=new Response("");if("body"in e)try{new Response(e.body),p=!0}catch(e){p=!1}p=!1}return p}class y{constructor(e,t,{onupgradeneeded:n,onversionchange:s}={}){this.t=null,this.s=e,this.i=t,this.o=n,this.u=s||(()=>this.close())}get db(){return this.t}async open(){if(!this.t)return this.t=await new Promise((e,t)=>{let n=!1;setTimeout(()=>{n=!0,t(new Error("The open request was blocked and timed out"))},this.OPEN_TIMEOUT);const s=indexedDB.open(this.s,this.i);s.onerror=(()=>t(s.error)),s.onupgradeneeded=(e=>{n?(s.transaction.abort(),s.result.close()):"function"==typeof this.o&&this.o(e)}),s.onsuccess=(()=>{const t=s.result;n?t.close():(t.onversionchange=this.u.bind(this),e(t))})}),this}async getKey(e,t){return(await this.getAllKeys(e,t,1))[0]}async getAll(e,t,n){return await this.getAllMatching(e,{query:t,count:n})}async getAllKeys(e,t,n){return(await this.getAllMatching(e,{query:t,count:n,includeKeys:!0})).map(e=>e.key)}async getAllMatching(e,{index:t,query:n=null,direction:s="next",count:r,includeKeys:a=!1}={}){return await this.transaction([e],"readonly",(i,o)=>{const c=i.objectStore(e),u=t?c.index(t):c,l=[],h=u.openCursor(n,s);h.onsuccess=(()=>{const e=h.result;e?(l.push(a?e:e.value),r&&l.length>=r?o(l):e.continue()):o(l)})})}async transaction(e,t,n){return await this.open(),await new Promise((s,r)=>{const a=this.t.transaction(e,t);a.onabort=(()=>r(a.error)),a.oncomplete=(()=>s()),n(a,e=>s(e))})}async l(e,t,n,...s){return await this.transaction([t],n,(n,r)=>{const a=n.objectStore(t),i=a[e].apply(a,s);i.onsuccess=(()=>r(i.result))})}close(){this.t&&(this.t.close(),this.t=null)}}y.prototype.OPEN_TIMEOUT=2e3;const m={readonly:["get","count","getKey","getAll","getAllKeys"],readwrite:["add","put","clear","delete"]};for(const[e,t]of Object.entries(m))for(const n of t)n in IDBObjectStore.prototype&&(y.prototype[n]=async function(t,...s){return await this.l(n,t,e,...s)});const q={fetch:async({request:e,fetchOptions:t,event:s,plugins:r=[]})=>{if("string"==typeof e&&(e=new Request(e)),s instanceof FetchEvent&&s.preloadResponse){const e=await s.preloadResponse;if(e)return e}const a=u(r,"fetchDidFail"),i=a.length>0?e.clone():null;try{for(let t of r)if("requestWillFetch"in t){const n=t.requestWillFetch,r=e.clone();e=await n.call(t,{request:r,event:s})}}catch(e){throw new n("plugin-error-request-will-fetch",{thrownError:e})}let o=e.clone();try{let n;n="navigate"===e.mode?await fetch(e):await fetch(e,t);for(const e of r)"fetchDidSucceed"in e&&(n=await e.fetchDidSucceed.call(e,{event:s,request:o,response:n}));return n}catch(e){for(const t of a)await t.fetchDidFail.call(t,{error:e,event:s,originalRequest:i.clone(),request:o.clone()});throw e}}};function v(e){return new Promise(t=>setTimeout(t,e))}const x=2e3;var R=Object.freeze({assert:null,cacheNames:i,cacheWrapper:w,canConstructReadableStream:function(){if(void 0===d)try{new ReadableStream({start(){}}),d=!0}catch(e){d=!1}return d},canConstructResponseFromBodyStream:g,DBWrapper:y,Deferred:class{constructor(){this.promise=new Promise((e,t)=>{this.resolve=e,this.reject=t})}},deleteDatabase:async e=>{await new Promise((t,n)=>{const s=indexedDB.deleteDatabase(e);s.onerror=(()=>{n(s.error)}),s.onblocked=(()=>{n(new Error("Delete blocked"))}),s.onsuccess=(()=>{t()})})},executeQuotaErrorCallbacks:c,fetchWrapper:q,getFriendlyURL:o,logger:null,resultingClientExists:async function(e){if(!e)return;let t=await self.clients.matchAll({type:"window"});const n=new Set(t.map(e=>e.id));let s;const r=performance.now();for(;performance.now()-r<x&&!(s=(t=await self.clients.matchAll({type:"window"})).find(t=>e?t.id===e:!n.has(t.id)));)await v(100);return s},timeout:v,WorkboxError:n});const b={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 e._private=R,e.cacheNames=b,e.clientsClaim=(()=>{addEventListener("activate",()=>self.clients.claim())}),e.copyResponse=async function(e,t){const n=e.clone(),s={headers:new Headers(n.headers),status:n.status,statusText:n.statusText},r=t?t(s):s,a=g()?n.body:await n.blob();return new Response(a,r)},e.registerQuotaErrorCallback=function(e){s.add(e)},e.setCacheNameDetails=(e=>{i.updateDetails(e)}),e.skipWaiting=(()=>{addEventListener("install",()=>self.skipWaiting())}),e}({});
this.workbox=this.workbox||{},this.workbox.core=function(e){"use strict";try{self["workbox:core:5.0.0-rc.0"]&&_()}catch(e){}const t=(e,...t)=>{let n=e;return t.length>0&&(n+=` :: ${JSON.stringify(t)}`),n};class n extends Error{constructor(e,n){super(t(e,n)),this.name=e,this.details=n}}const s=new Set;const r={googleAnalytics:"googleAnalytics",precache:"precache-v2",prefix:"workbox",runtime:"runtime",suffix:registration.scope},a=e=>[r.prefix,e,r.suffix].filter(e=>e&&e.length>0).join("-"),i={updateDetails:e=>{(e=>{for(const t of Object.keys(r))e(t)})(t=>{"string"==typeof e[t]&&(r[t]=e[t])})},getGoogleAnalyticsName:e=>e||a(r.googleAnalytics),getPrecacheName:e=>e||a(r.precache),getPrefix:()=>r.prefix,getRuntimeName:e=>e||a(r.runtime),getSuffix:()=>r.suffix};async function o(){for(const e of s)await e()}const c=e=>{const t=new URL(String(e),location.href);return t.origin===location.origin?t.pathname:t.href},u=(e,t)=>e.filter(e=>t in e),l=async({cacheName:e,request:t,event:n,matchOptions:s,plugins:r=[]})=>{const a=await caches.open(e),i=await f({plugins:r,request:t,mode:"read"});let o=await a.match(i,s);for(const t of r)if("cachedResponseWillBeUsed"in t){const r=t.cachedResponseWillBeUsed;o=await r.call(t,{cacheName:e,event:n,matchOptions:s,cachedResponse:o,request:i})}return o},h=async({request:e,response:t,event:n,plugins:s=[]})=>{let r=t,a=!1;for(let t of s)if("cacheWillUpdate"in t){a=!0;const s=t.cacheWillUpdate;if(!(r=await s.call(t,{request:e,response:r,event:n})))break}return a||(r=r&&200===r.status?r:void 0),r||null},f=async({request:e,mode:t,plugins:n=[]})=>{const s=u(n,"cacheKeyWillBeUsed");let r=e;for(const e of s)"string"==typeof(r=await e.cacheKeyWillBeUsed.call(e,{mode:t,request:r}))&&(r=new Request(r));return r},w={put:async({cacheName:e,request:t,response:s,event:r,plugins:a=[],matchOptions:i})=>{const w=await f({plugins:a,request:t,mode:"write"});if(!s)throw new n("cache-put-with-no-response",{url:c(w.url)});let d=await h({event:r,plugins:a,response:s,request:w});if(!d)return;const p=await caches.open(e),g=u(a,"cacheDidUpdate");let y=g.length>0?await l({cacheName:e,matchOptions:i,request:w}):null;try{await p.put(w,d)}catch(e){throw"QuotaExceededError"===e.name&&await o(),e}for(let t of g)await t.cacheDidUpdate.call(t,{cacheName:e,event:r,oldResponse:y,newResponse:d,request:w})},match:l};let d,p;function g(){if(void 0===p){const e=new Response("");if("body"in e)try{new Response(e.body),p=!0}catch(e){p=!1}p=!1}return p}class y{constructor(e,t,{onupgradeneeded:n,onversionchange:s}={}){this.t=null,this.s=e,this.i=t,this.o=n,this.u=s||(()=>this.close())}get db(){return this.t}async open(){if(!this.t)return this.t=await new Promise((e,t)=>{let n=!1;setTimeout(()=>{n=!0,t(new Error("The open request was blocked and timed out"))},this.OPEN_TIMEOUT);const s=indexedDB.open(this.s,this.i);s.onerror=(()=>t(s.error)),s.onupgradeneeded=(e=>{n?(s.transaction.abort(),s.result.close()):"function"==typeof this.o&&this.o(e)}),s.onsuccess=(()=>{const t=s.result;n?t.close():(t.onversionchange=this.u.bind(this),e(t))})}),this}async getKey(e,t){return(await this.getAllKeys(e,t,1))[0]}async getAll(e,t,n){return await this.getAllMatching(e,{query:t,count:n})}async getAllKeys(e,t,n){return(await this.getAllMatching(e,{query:t,count:n,includeKeys:!0})).map(e=>e.key)}async getAllMatching(e,{index:t,query:n=null,direction:s="next",count:r,includeKeys:a=!1}={}){return await this.transaction([e],"readonly",(i,o)=>{const c=i.objectStore(e),u=t?c.index(t):c,l=[],h=u.openCursor(n,s);h.onsuccess=(()=>{const e=h.result;e?(l.push(a?e:e.value),r&&l.length>=r?o(l):e.continue()):o(l)})})}async transaction(e,t,n){return await this.open(),await new Promise((s,r)=>{const a=this.t.transaction(e,t);a.onabort=(()=>r(a.error)),a.oncomplete=(()=>s()),n(a,e=>s(e))})}async l(e,t,n,...s){return await this.transaction([t],n,(n,r)=>{const a=n.objectStore(t),i=a[e].apply(a,s);i.onsuccess=(()=>r(i.result))})}close(){this.t&&(this.t.close(),this.t=null)}}y.prototype.OPEN_TIMEOUT=2e3;const m={readonly:["get","count","getKey","getAll","getAllKeys"],readwrite:["add","put","clear","delete"]};for(const[e,t]of Object.entries(m))for(const n of t)n in IDBObjectStore.prototype&&(y.prototype[n]=async function(t,...s){return await this.l(n,t,e,...s)});const q={fetch:async({request:e,fetchOptions:t,event:s,plugins:r=[]})=>{if("string"==typeof e&&(e=new Request(e)),s instanceof FetchEvent&&s.preloadResponse){const e=await s.preloadResponse;if(e)return e}const a=u(r,"fetchDidFail"),i=a.length>0?e.clone():null;try{for(let t of r)if("requestWillFetch"in t){const n=t.requestWillFetch,r=e.clone();e=await n.call(t,{request:r,event:s})}}catch(e){throw new n("plugin-error-request-will-fetch",{thrownError:e})}let o=e.clone();try{let n;n="navigate"===e.mode?await fetch(e):await fetch(e,t);for(const e of r)"fetchDidSucceed"in e&&(n=await e.fetchDidSucceed.call(e,{event:s,request:o,response:n}));return n}catch(e){for(const t of a)await t.fetchDidFail.call(t,{error:e,event:s,originalRequest:i.clone(),request:o.clone()});throw e}}};function v(e){return new Promise(t=>setTimeout(t,e))}const x=2e3;var R=Object.freeze({assert:null,cacheNames:i,cacheWrapper:w,canConstructReadableStream:function(){if(void 0===d)try{new ReadableStream({start(){}}),d=!0}catch(e){d=!1}return d},canConstructResponseFromBodyStream:g,dontWaitFor:function(e){e.then(()=>{})},DBWrapper:y,Deferred:class{constructor(){this.promise=new Promise((e,t)=>{this.resolve=e,this.reject=t})}},deleteDatabase:async e=>{await new Promise((t,n)=>{const s=indexedDB.deleteDatabase(e);s.onerror=(()=>{n(s.error)}),s.onblocked=(()=>{n(new Error("Delete blocked"))}),s.onsuccess=(()=>{t()})})},executeQuotaErrorCallbacks:o,fetchWrapper:q,getFriendlyURL:c,logger:null,resultingClientExists:async function(e){if(!e)return;let t=await self.clients.matchAll({type:"window"});const n=new Set(t.map(e=>e.id));let s;const r=performance.now();for(;performance.now()-r<x&&!(s=(t=await self.clients.matchAll({type:"window"})).find(t=>e?t.id===e:!n.has(t.id)));)await v(100);return s},timeout:v,WorkboxError:n});const b={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 e._private=R,e.cacheNames=b,e.clientsClaim=(()=>{addEventListener("activate",()=>self.clients.claim())}),e.copyResponse=async function(e,t){const n=e.clone(),s={headers:new Headers(n.headers),status:n.status,statusText:n.statusText},r=t?t(s):s,a=g()?n.body:await n.blob();return new Response(a,r)},e.registerQuotaErrorCallback=function(e){s.add(e)},e.setCacheNameDetails=(e=>{i.updateDetails(e)}),e.skipWaiting=(()=>{addEventListener("install",()=>self.skipWaiting())}),e}({});
//# sourceMappingURL=workbox-core.prod.js.map

@@ -17,1 +17,2 @@ import { registerQuotaErrorCallback } from './registerQuotaErrorCallback.js';

export { _private, cacheNames, clientsClaim, copyResponse, registerQuotaErrorCallback, setCacheNameDetails, skipWaiting, };
export * from './types.js';
import '../../_version.js';
export declare const messageGenerator: (code: string, ...args: any[]) => string;
export declare const messageGenerator: (code: string, details?: {}) => string;

@@ -207,4 +207,4 @@ /*

'non-precached-url': ({ url }) => {
return `createHandlerForURL('${url}') was called, but that URL is not ` +
`precached. Please pass in a URL that is precached instead.`;
return `createHandlerBoundToURL('${url}') was called, but that URL is ` +
`not precached. Please pass in a URL that is precached instead.`;
},

@@ -216,2 +216,5 @@ 'add-to-cache-list-conflicting-integrities': ({ url }) => {

},
'missing-precache-entry': ({ cacheName, url }) => {
return `Unable to find a precached response in ${cacheName} for ${url}.`;
},
};
{
"name": "workbox-core",
"version": "5.0.0-beta.1",
"version": "5.0.0-rc.0",
"license": "MIT",

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

"types": "index.d.ts",
"gitHead": "01a9e9be8291f0a592891c8e2eb8d2dd09b93caf"
"gitHead": "94542f92ceaec96ef59a09bda3aee1677ea5512b"
}

@@ -38,18 +38,18 @@ /*

});
if ('precache' in details && details.precache.length === 0) {
if ('precache' in details && details['precache'].length === 0) {
throw new WorkboxError('invalid-cache-name', {
cacheNameId: 'precache',
value: details.precache,
value: details['precache'],
});
}
if ('runtime' in details && details.runtime.length === 0) {
if ('runtime' in details && details['runtime'].length === 0) {
throw new WorkboxError('invalid-cache-name', {
cacheNameId: 'runtime',
value: details.runtime,
value: details['runtime'],
});
}
if ('googleAnalytics' in details && details.googleAnalytics.length === 0) {
if ('googleAnalytics' in details && details['googleAnalytics'].length === 0) {
throw new WorkboxError('invalid-cache-name', {
cacheNameId: 'googleAnalytics',
value: details.googleAnalytics,
value: details['googleAnalytics'],
});

@@ -56,0 +56,0 @@ }

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

import {canConstructResponseFromBodyStream} from './_private/canConstructResponseFromBodyStream.js';
import {dontWaitFor} from './_private/dontWaitFor.js';
import {DBWrapper} from './_private/DBWrapper.js';

@@ -35,2 +36,3 @@ import {Deferred} from './_private/Deferred.js';

canConstructResponseFromBodyStream,
dontWaitFor,
DBWrapper,

@@ -37,0 +39,0 @@ Deferred,

@@ -44,3 +44,3 @@ /*

if (type !== 'function') {
details.expectedMethod = expectedMethod;
details['expectedMethod'] = expectedMethod;
throw new WorkboxError('missing-a-method', details);

@@ -56,3 +56,3 @@ }

if (typeof object !== expectedType) {
details.expectedType = expectedType;
details['expectedType'] = expectedType;
throw new WorkboxError('incorrect-type', details);

@@ -68,3 +68,3 @@ }

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

@@ -79,3 +79,3 @@ }

if (!validValues.includes(value)) {
details.validValueDescription =
details['validValueDescription'] =
`Valid values are ${JSON.stringify(validValues)}.`

@@ -82,0 +82,0 @@ throw new WorkboxError('invalid-value', details);

@@ -9,13 +9,13 @@ /*

import {WorkboxError} from './WorkboxError.js';
import {assert} from './assert.js';
import {executeQuotaErrorCallbacks} from './executeQuotaErrorCallbacks.js';
import {getFriendlyURL} from './getFriendlyURL.js';
import {logger} from './logger.js';
import {executeQuotaErrorCallbacks} from './executeQuotaErrorCallbacks.js';
import {pluginEvents} from '../models/pluginEvents.js';
import {pluginUtils} from '../utils/pluginUtils.js';
import {WorkboxError} from './WorkboxError.js';
import {WorkboxPlugin} from '../types.js';
import {pluginUtils} from '../utils/pluginUtils.js';
import '../_version.js';
interface MatchWrapperOptions {

@@ -144,3 +144,3 @@ cacheName: string;

* cache entries.
* @param {Event} [options.event] The event that propted the action.
* @param {Event} [options.event] The event that prompted the action.
* @param {Object} [options.matchOptions] Options passed to cache.match().

@@ -303,3 +303,3 @@ * @param {Array<Object>} [options.plugins=[]] Array of plugins.

let effectiveRequest = request;
let effectiveRequest: Request | string = request;
for (const plugin of cacheKeyWillBeUsedPlugins) {

@@ -306,0 +306,0 @@ effectiveRequest = await plugin[pluginEvents.CACHE_KEY_WILL_BE_USED]!.call(

@@ -45,10 +45,10 @@ /*

// The following IDBObjectStore methods are shadowed on this class.
get: Function;
count: Function;
add: Function;
put: Function;
clear: Function;
delete: Function;
add?: Function;
clear?: Function;
count?: Function;
delete?: Function;
get?: Function;
put?: Function;
OPEN_TIMEOUT: number;
OPEN_TIMEOUT?: number;

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

const callback = (txn: IDBTransaction, done: Function) => {
const objStore = txn.objectStore(storeName)
const objStore = txn.objectStore(storeName);
// TODO(philipwalton): Fix this underlying TS2684 error.
// @ts-ignore
const request = <IDBRequest> objStore[method].apply(objStore, args);

@@ -273,0 +275,0 @@

@@ -22,4 +22,4 @@ /*

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

@@ -26,0 +26,0 @@ /**

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

request: Request | string;
event?: FetchEvent | Event;
event?: ExtendableEvent;
plugins?: WorkboxPlugin[];

@@ -35,3 +35,3 @@ fetchOptions?: RequestInit;

* @param {Object} [options.fetchOptions]
* @param {Event} [options.event]
* @param {ExtendableEvent} [options.event]
* @param {Array<Object>} [options.plugins=[]]

@@ -38,0 +38,0 @@ * @return {Promise<Response>}

@@ -13,3 +13,3 @@ /*

* Returns a promise that resolves and the passed number of milliseconds.
* This utily is an async/await-friendly version of `setTimeout`.
* This utility is an async/await-friendly version of `setTimeout`.
*

@@ -16,0 +16,0 @@ * @param {number} ms

// @ts-ignore
try{self['workbox:core:5.0.0-beta.1']&&_()}catch(e){}
try{self['workbox:core:5.0.0-rc.0']&&_()}catch(e){}

@@ -35,1 +35,3 @@ /*

};
export * from './types.js';

@@ -261,4 +261,4 @@ /*

'non-precached-url': ({url}) => {
return `createHandlerForURL('${url}') was called, but that URL is not ` +
`precached. Please pass in a URL that is precached instead.`;
return `createHandlerBoundToURL('${url}') was called, but that URL is ` +
`not precached. Please pass in a URL that is precached instead.`;
},

@@ -271,2 +271,6 @@

},
'missing-precache-entry': ({cacheName, url}) => {
return `Unable to find a precached response in ${cacheName} for ${url}.`;
},
};

@@ -42,20 +42,20 @@ /*

if ('precache' in details && details.precache!.length === 0) {
if ('precache' in details && details['precache']!.length === 0) {
throw new WorkboxError('invalid-cache-name', {
cacheNameId: 'precache',
value: details.precache,
value: details['precache'],
});
}
if ('runtime' in details && details.runtime!.length === 0) {
if ('runtime' in details && details['runtime']!.length === 0) {
throw new WorkboxError('invalid-cache-name', {
cacheNameId: 'runtime',
value: details.runtime,
value: details['runtime'],
});
}
if ('googleAnalytics' in details && details.googleAnalytics!.length === 0) {
if ('googleAnalytics' in details && details['googleAnalytics'].length === 0) {
throw new WorkboxError('invalid-cache-name', {
cacheNameId: 'googleAnalytics',
value: details.googleAnalytics,
value: details['googleAnalytics'],
});

@@ -62,0 +62,0 @@ }

@@ -77,6 +77,6 @@ /*

cacheName: string;
oldResponse?: Response;
oldResponse?: Response | null;
newResponse: Response;
request: Request;
event?: FetchEvent;
event?: Event;
}

@@ -83,0 +83,0 @@

@@ -63,6 +63,6 @@ import './_version.js';

cacheName: string;
oldResponse?: Response;
oldResponse?: Response | null;
newResponse: Response;
request: Request;
event?: FetchEvent;
event?: Event;
}

@@ -69,0 +69,0 @@ export interface CacheDidUpdateCallback {

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