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

2

_private/cacheNames.js

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

runtime: 'runtime',
suffix: registration.scope,
suffix: typeof registration !== 'undefined' ? registration.scope : '',
};

@@ -17,0 +17,0 @@ const _createCacheName = (cacheName) => {

@@ -66,3 +66,3 @@ /*

}
const cache = await caches.open(cacheName);
const cache = await self.caches.open(cacheName);
const updatePlugins = pluginUtils.filter(plugins, "cacheDidUpdate" /* CACHE_DID_UPDATE */);

@@ -112,3 +112,3 @@ let oldResponse = updatePlugins.length > 0 ?

const matchWrapper = async ({ cacheName, request, event, matchOptions, plugins = [], }) => {
const cache = await caches.open(cacheName);
const cache = await self.caches.open(cacheName);
const effectiveRequest = await _getEffectiveRequest({

@@ -115,0 +115,0 @@ plugins, request, mode: 'read'

import '../_version.js';
declare global {
interface WorkerGlobalScope {
__WB_DISABLE_DEV_LOGS: boolean;
}
interface Window {
__WB_DISABLE_DEV_LOGS: boolean;
}
}
declare const logger: Console;
export { logger };

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

const logger = (process.env.NODE_ENV === 'production' ? null : (() => {
self.__WB_DISABLE_DEV_LOGS = false;
let inGroup = false;

@@ -20,2 +21,5 @@ const methodToColorMap = {

const print = function (method, args) {
if (self.__WB_DISABLE_DEV_LOGS) {
return;
}
if (method === 'groupCollapsed') {

@@ -22,0 +26,0 @@ // Safari doesn't print all console.groupCollapsed() arguments:

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

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

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

@@ -17,2 +17,3 @@

const logger = (() => {
self.__WB_DISABLE_DEV_LOGS = false;
let inGroup = false;

@@ -29,2 +30,6 @@ const methodToColorMap = {

const print = function (method, args) {
if (self.__WB_DISABLE_DEV_LOGS) {
return;
}
if (method === 'groupCollapsed') {

@@ -543,3 +548,3 @@ // Safari doesn't print all console.groupCollapsed() arguments:

runtime: 'runtime',
suffix: registration.scope
suffix: typeof registration !== 'undefined' ? registration.scope : ''
};

@@ -719,3 +724,3 @@

const cache = await caches.open(cacheName);
const cache = await self.caches.open(cacheName);
const updatePlugins = pluginUtils.filter(plugins, "cacheDidUpdate"

@@ -781,3 +786,3 @@ /* CACHE_DID_UPDATE */

}) => {
const cache = await caches.open(cacheName);
const cache = await self.caches.open(cacheName);
const effectiveRequest = await _getEffectiveRequest({

@@ -1783,3 +1788,3 @@ plugins,

const clientsClaim = () => {
addEventListener('activate', () => self.clients.claim());
self.addEventListener('activate', () => self.clients.claim());
};

@@ -1864,3 +1869,3 @@

// shadowing `skipWaiting` with this local function.
addEventListener('install', () => self.skipWaiting());
self.addEventListener('install', () => self.skipWaiting());
};

@@ -1867,0 +1872,0 @@

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

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}({});
this.workbox=this.workbox||{},this.workbox.core=function(e){"use strict";try{self["workbox:core:5.0.0-rc.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:"undefined"!=typeof registration?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 self.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 self.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=(()=>{self.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=(()=>{self.addEventListener("install",()=>self.skipWaiting())}),e}({});
//# sourceMappingURL=workbox-core.prod.js.map

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

export const clientsClaim = () => {
addEventListener('activate', () => self.clients.claim());
self.addEventListener('activate', () => self.clients.claim());
};
{
"name": "workbox-core",
"version": "5.0.0-rc.0",
"version": "5.0.0-rc.1",
"license": "MIT",

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

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

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

// shadowing `skipWaiting` with this local function.
addEventListener('install', () => self.skipWaiting());
self.addEventListener('install', () => self.skipWaiting());
};

@@ -12,3 +12,3 @@ /*

declare var registration : ServiceWorkerRegistration;
declare var registration : ServiceWorkerRegistration|undefined;

@@ -36,3 +36,3 @@ export interface CacheNameDetails {

runtime: 'runtime',
suffix: registration.scope,
suffix: typeof registration !== 'undefined' ? registration!.scope : '',
};

@@ -39,0 +39,0 @@

@@ -101,3 +101,3 @@ /*

const cache = await caches.open(cacheName);
const cache = await self.caches.open(cacheName);

@@ -159,3 +159,3 @@ const updatePlugins = pluginUtils.filter(

} : MatchWrapperOptions) : Promise<Response|undefined> => {
const cache = await caches.open(cacheName);
const cache = await self.caches.open(cacheName);

@@ -162,0 +162,0 @@ const effectiveRequest = await _getEffectiveRequest({

@@ -10,7 +10,18 @@ /*

// logger is used inside of both service workers and the window global scope.
declare global {
interface WorkerGlobalScope {
__WB_DISABLE_DEV_LOGS: boolean;
}
interface Window {
__WB_DISABLE_DEV_LOGS: boolean;
}
}
type LoggerMethods = 'debug'|'log'|'warn'|'error'|'groupCollapsed'|'groupEnd';
const logger = <Console> (process.env.NODE_ENV === 'production' ? null : (() => {
self.__WB_DISABLE_DEV_LOGS = false;
let inGroup = false;

@@ -28,2 +39,6 @@

const print = function(method: LoggerMethods, args: any[]) {
if (self.__WB_DISABLE_DEV_LOGS) {
return;
}
if (method === 'groupCollapsed') {

@@ -30,0 +45,0 @@ // Safari doesn't print all console.groupCollapsed() arguments:

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

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

export const clientsClaim = () => {
addEventListener('activate', () => self.clients.claim());
self.addEventListener('activate', () => self.clients.claim());
};

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

// shadowing `skipWaiting` with this local function.
addEventListener('install', () => self.skipWaiting());
self.addEventListener('install', () => self.skipWaiting());
};

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