Socket
Socket
Sign inDemoInstall

workbox-precaching

Package Overview
Dependencies
Maintainers
4
Versions
95
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

workbox-precaching - npm Package Compare versions

Comparing version 5.0.0-rc.1 to 5.0.0-rc.2

38

_types.d.ts
import './_version.js';
export interface InstallResult {
updatedURLs: string[];
notUpdatedURLs: string[];
}
export interface CleanupResult {
deletedCacheRequests: string[];
}
export interface PrecacheEntry {
integrity?: string;
url: string;
revision?: string;
}
export declare type urlManipulation = ({ url }: {
url: URL;
}) => URL[];
/**

@@ -9,8 +24,4 @@ * @typedef {Object} InstallResult

*
* @memberof workbox.precaching
* @memberof module:workbox-precaching
*/
export interface InstallResult {
updatedURLs: string[];
notUpdatedURLs: string[];
}
/**

@@ -21,7 +32,4 @@ * @typedef {Object} CleanupResult

*
* @memberof workbox.precaching
* @memberof module:workbox-precaching
*/
export interface CleanupResult {
deletedCacheRequests: string[];
}
/**

@@ -34,9 +42,4 @@ * @typedef {Object} PrecacheEntry

*
* @memberof workbox.precaching
* @memberof module:workbox-precaching
*/
export interface PrecacheEntry {
integrity?: string;
url: string;
revision?: string;
}
/**

@@ -56,6 +59,3 @@ * The "urlManipulation" callback can be used to determine if there are any

*
* @memberof workbox.precaching
* @memberof module:workbox-precaching
*/
export declare type urlManipulation = ({ url }: {
url: URL;
}) => URL[];

@@ -9,1 +9,48 @@ /*

import './_version.js';
// * * * IMPORTANT! * * *
// ------------------------------------------------------------------------- //
// jdsoc type definitions cannot be declared above TypeScript definitions or
// they'll be stripped from the built `.js` files, and they'll only be in the
// `d.ts` files, which aren't read by the jsdoc generator. As a result we
// have to put declare them below.
/**
* @typedef {Object} InstallResult
* @property {Array<string>} updatedURLs List of URLs that were updated during
* installation.
* @property {Array<string>} notUpdatedURLs List of URLs that were already up to
* date.
*
* @memberof module:workbox-precaching
*/
/**
* @typedef {Object} CleanupResult
* @property {Array<string>} deletedCacheRequests List of URLs that were deleted
* while cleaning up the cache.
*
* @memberof module:workbox-precaching
*/
/**
* @typedef {Object} PrecacheEntry
* @property {string} url URL to precache.
* @property {string} [revision] Revision information for the URL.
* @property {string} [integrity] Integrity metadata that will be used when
* making the network request for the URL.
*
* @memberof module:workbox-precaching
*/
/**
* The "urlManipulation" callback can be used to determine if there are any
* additional permutations of a URL that should be used to check against
* the available precached files.
*
* For example, Workbox supports checking for '/index.html' when the URL
* '/' is provided. This callback allows additional, custom checks.
*
* @callback ~urlManipulation
* @param {Object} context
* @param {URL} context.url The request's URL.
* @return {Array<URL>} To add additional urls to test, return an Array of
* URLs. Please note that these **should not be strings**, but URL objects.
*
* @memberof module:workbox-precaching
*/
"use strict";
// @ts-ignore
try {
self['workbox:precaching:5.0.0-rc.1'] && _();
self['workbox:precaching:5.0.0-rc.2'] && _();
}
catch (e) { }

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

*
* @alias workbox.precaching.addPlugins
* @memberof module:workbox-precaching
*/
declare const addPlugins: (newPlugins: WorkboxPlugin[]) => void;
declare function addPlugins(newPlugins: WorkboxPlugin[]): void;
export { addPlugins };

@@ -15,7 +15,8 @@ /*

*
* @alias workbox.precaching.addPlugins
* @memberof module:workbox-precaching
*/
const addPlugins = (newPlugins) => {
function addPlugins(newPlugins) {
precachePlugins.add(newPlugins);
};
}
;
export { addPlugins };

@@ -21,8 +21,9 @@ import { FetchListenerOptions } from './utils/addFetchListener.js';

* check the cache for the URL with a `.html` added to the end of the end.
* @param {workbox.precaching~urlManipulation} [options.urlManipulation]
* @param {module:workbox-precaching~urlManipulation} [options.urlManipulation]
* This is a function that should take a URL and return an array of
* alternative URLs that should be checked for precache matches.
*
* @alias workbox.precaching.addRoute
* @memberof module:workbox-precaching
*/
export declare const addRoute: (options?: FetchListenerOptions | undefined) => void;
declare function addRoute(options?: FetchListenerOptions): void;
export { addRoute };

@@ -28,9 +28,9 @@ /*

* check the cache for the URL with a `.html` added to the end of the end.
* @param {workbox.precaching~urlManipulation} [options.urlManipulation]
* @param {module:workbox-precaching~urlManipulation} [options.urlManipulation]
* This is a function that should take a URL and return an array of
* alternative URLs that should be checked for precache matches.
*
* @alias workbox.precaching.addRoute
* @memberof module:workbox-precaching
*/
export const addRoute = (options) => {
function addRoute(options) {
if (!listenerAdded) {

@@ -40,2 +40,4 @@ addFetchListener(options);

}
};
}
;
export { addRoute };

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

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

@@ -49,8 +49,8 @@

*
* @alias workbox.precaching.addPlugins
* @memberof module:workbox-precaching
*/
const addPlugins = newPlugins => {
function addPlugins(newPlugins) {
precachePlugins.add(newPlugins);
};
}

@@ -323,3 +323,3 @@ /*

* and caching during install.
* @return {Promise<workbox.precaching.InstallResult>}
* @return {Promise<module:workbox-precaching.InstallResult>}
*/

@@ -393,3 +393,3 @@

*
* @return {Promise<workbox.precaching.CleanupResult>}
* @return {Promise<module:workbox-precaching.CleanupResult>}
*/

@@ -460,3 +460,3 @@

// valid by passing in a plugin implementing cacheWillUpdate(), e.g.
// a workbox.cacheableResponse.CacheableResponsePlugin instance.
// a `CacheableResponsePlugin` instance.

@@ -578,4 +578,5 @@ let cacheWillUpdatePlugin;

/**
* Returns a function that can be used within a {@link workbox.routing.Route}
* that will find a response for the incoming request against the precache.
* Returns a function that can be used within a
* {@link module:workbox-routing.Route} that will find a response for the
* incoming request against the precache.
*

@@ -588,3 +589,3 @@ * If for an unexpected reason there is a cache miss for the request,

* response from the network if there's a precache miss.
* @return {workbox.routing.Route~handlerCallback}
* @return {module:workbox-routing~handlerCallback}
*/

@@ -608,3 +609,3 @@

cacheName: this._cacheName,
url: request.url
url: request instanceof Request ? request.url : request
});

@@ -636,3 +637,3 @@ } catch (error) {

* response from the network if there's a precache miss.
* @return {workbox.routing.Route~handlerCallback}
* @return {module:workbox-routing~handlerCallback}
*/

@@ -918,10 +919,10 @@

* check the cache for the URL with a `.html` added to the end of the end.
* @param {workbox.precaching~urlManipulation} [options.urlManipulation]
* @param {module:workbox-precaching~urlManipulation} [options.urlManipulation]
* This is a function that should take a URL and return an array of
* alternative URLs that should be checked for precache matches.
*
* @alias workbox.precaching.addRoute
* @memberof module:workbox-precaching
*/
const addRoute = options => {
function addRoute(options) {
if (!listenerAdded) {

@@ -931,3 +932,3 @@ addFetchListener(options);

}
};
}

@@ -981,6 +982,6 @@ /*

*
* @alias workbox.precaching.cleanupOutdatedCaches
* @memberof module:workbox-precaching
*/
const cleanupOutdatedCaches = () => {
function cleanupOutdatedCaches() {
// See https://github.com/Microsoft/TypeScript/issues/28357#issuecomment-436484705

@@ -997,3 +998,3 @@ self.addEventListener('activate', event => {

});
};
}

@@ -1018,11 +1019,11 @@ /*

* response from the network if there's a precache miss.
* @return {workbox.routing.Route~handlerCallback}
* @return {module:workbox-routing~handlerCallback}
*
* @alias workbox.precaching.createHandler
* @memberof module:workbox-precaching
*/
const createHandler = (fallbackToNetwork = true) => {
function createHandler(fallbackToNetwork = true) {
const precacheController = getOrCreatePrecacheController();
return precacheController.createHandler(fallbackToNetwork);
};
}

@@ -1049,11 +1050,11 @@ /*

* response from the network if there's a precache miss.
* @return {workbox.routing.Route~handlerCallback}
* @return {module:workbox-routing~handlerCallback}
*
* @alias workbox.precaching.createHandlerBoundToURL
* @memberof module:workbox-precaching
*/
const createHandlerBoundToURL = url => {
function createHandlerBoundToURL(url) {
const precacheController = getOrCreatePrecacheController();
return precacheController.createHandlerBoundToURL(url);
};
}

@@ -1084,9 +1085,9 @@ /*

*
* @alias workbox.precaching.getCacheKeyForURL
* @memberof module:workbox-precaching
*/
const getCacheKeyForURL$1 = url => {
function getCacheKeyForURL$1(url) {
const precacheController = getOrCreatePrecacheController();
return precacheController.getCacheKeyForURL(url);
};
}

@@ -1113,9 +1114,9 @@ /*

*
* @alias workbox.precaching.matchPrecache
* @memberof module:workbox-precaching
*/
const matchPrecache = request => {
function matchPrecache(request) {
const precacheController = getOrCreatePrecacheController();
return precacheController.matchPrecache(request);
};
}

@@ -1167,7 +1168,7 @@ /*

*
* @alias workbox.precaching.precache
* @memberof module:workbox-precaching
*/
const precache = entries => {
function precache(entries) {
const precacheController = getOrCreatePrecacheController();

@@ -1184,3 +1185,3 @@ precacheController.addToCacheList(entries);

}
};
}

@@ -1206,9 +1207,9 @@ /*

*
* @alias workbox.precaching.precacheAndRoute
* @memberof module:workbox-precaching
*/
const precacheAndRoute = (entries, options) => {
function precacheAndRoute(entries, options) {
precache(entries);
addRoute(options);
};
}

@@ -1215,0 +1216,0 @@ /*

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

this.workbox=this.workbox||{},this.workbox.precaching=function(t,e,n,s,i,r){"use strict";try{self["workbox:precaching:5.0.0-rc.1"]&&_()}catch(t){}const c=[],o={get:()=>c,add(t){c.push(...t)}},a="__WB_REVISION__";function h(t){if(!t)throw new i.WorkboxError("add-to-cache-list-unexpected-type",{entry:t});if("string"==typeof t){const e=new URL(t,location.href);return{cacheKey:e.href,url:e.href}}const{revision:e,url:n}=t;if(!n)throw new i.WorkboxError("add-to-cache-list-unexpected-type",{entry:t});if(!e){const t=new URL(n,location.href);return{cacheKey:t.href,url:t.href}}const s=new URL(n,location.href),r=new URL(n,location.href);return s.searchParams.set(a,e),{cacheKey:s.href,url:r.href}}class l{constructor(t){this.t=e.cacheNames.getPrecacheName(t),this.s=new Map,this.i=new Map,this.o=new Map}addToCacheList(t){const e=[];for(const n of t){"string"==typeof n?e.push(n):n&&void 0===n.revision&&e.push(n.url);const{cacheKey:t,url:s}=h(n),r="string"!=typeof n&&n.revision?"reload":"default";if(this.s.has(s)&&this.s.get(s)!==t)throw new i.WorkboxError("add-to-cache-list-conflicting-entries",{firstEntry:this.s.get(s),secondEntry:t});if("string"!=typeof n&&n.integrity){if(this.o.has(t)&&this.o.get(t)!==n.integrity)throw new i.WorkboxError("add-to-cache-list-conflicting-integrities",{url:s});this.o.set(t,n.integrity)}if(this.s.set(s,t),this.i.set(s,r),e.length>0){const t="Workbox is precaching URLs without revision "+`info: ${e.join(", ")}\nThis is generally NOT safe. `+"Learn more at https://bit.ly/wb-precache";console.warn(t)}}}async install({event:t,plugins:e}={}){const n=[],s=[],i=await self.caches.open(this.t),r=await i.keys(),c=new Set(r.map(t=>t.url));for(const[t,e]of this.s)c.has(e)?s.push(t):n.push({cacheKey:e,url:t});const o=n.map(({cacheKey:n,url:s})=>{const i=this.o.get(n),r=this.i.get(s);return this.h({cacheKey:n,cacheMode:r,event:t,integrity:i,plugins:e,url:s})});return await Promise.all(o),{updatedURLs:n.map(t=>t.url),notUpdatedURLs:s}}async activate(){const t=await self.caches.open(this.t),e=await t.keys(),n=new Set(this.s.values()),s=[];for(const i of e)n.has(i.url)||(await t.delete(i),s.push(i.url));return{deletedURLs:s}}async h({cacheKey:t,url:e,cacheMode:c,event:o,plugins:a,integrity:h}){const l=new Request(e,{integrity:h,cache:c,credentials:"same-origin"});let u,f=await s.fetchWrapper.fetch({event:o,plugins:a,request:l});for(const t of a||[])"cacheWillUpdate"in t&&(u=t);if(!(u?await u.cacheWillUpdate({event:o,request:l,response:f}):f.status<400))throw new i.WorkboxError("bad-precaching-response",{url:e,status:f.status});f.redirected&&(f=await r.copyResponse(f)),await n.cacheWrapper.put({event:o,plugins:a,response:f,request:t===e?l:new Request(t),cacheName:this.t,matchOptions:{ignoreSearch:!0}})}getURLsToCacheKeys(){return this.s}getCachedURLs(){return[...this.s.keys()]}getCacheKeyForURL(t){const e=new URL(t,location.href);return this.s.get(e.href)}async matchPrecache(t){const e=t instanceof Request?t.url:t,n=this.getCacheKeyForURL(e);if(n){return(await self.caches.open(this.t)).match(n)}}createHandler(t=!0){return async({request:e})=>{try{const n=await this.matchPrecache(e);if(n)return n;throw new i.WorkboxError("missing-precache-entry",{cacheName:this.t,url:e.url})}catch(n){if(t)return fetch(e);throw n}}}createHandlerBoundToURL(t,e=!0){if(!this.getCacheKeyForURL(t))throw new i.WorkboxError("non-precached-url",{url:t});const n=this.createHandler(e),s=new Request(t);return()=>n({request:s})}}let u;const f=()=>(u||(u=new l),u);const w=(t,e)=>{const n=f().getURLsToCacheKeys();for(const s of function*(t,{ignoreURLParametersMatching:e,directoryIndex:n,cleanURLs:s,urlManipulation:i}={}){const r=new URL(t,location.href);r.hash="",yield r.href;const c=function(t,e=[]){for(const n of[...t.searchParams.keys()])e.some(t=>t.test(n))&&t.searchParams.delete(n);return t}(r,e);if(yield c.href,n&&c.pathname.endsWith("/")){const t=new URL(c.href);t.pathname+=n,yield t.href}if(s){const t=new URL(c.href);t.pathname+=".html",yield t.href}if(i){const t=i({url:r});for(const e of t)yield e.href}}(t,e)){const t=n.get(s);if(t)return t}};let d=!1;const y=t=>{d||((({ignoreURLParametersMatching:t=[/^utm_/],directoryIndex:n="index.html",cleanURLs:s=!0,urlManipulation:i}={})=>{const r=e.cacheNames.getPrecacheName();self.addEventListener("fetch",e=>{const c=w(e.request.url,{cleanURLs:s,directoryIndex:n,ignoreURLParametersMatching:t,urlManipulation:i});if(!c)return;let o=self.caches.open(r).then(t=>t.match(c)).then(t=>t||fetch(c));e.respondWith(o)})})(t),d=!0)},p=t=>{const e=f(),n=o.get();t.waitUntil(e.install({event:t,plugins:n}).catch(t=>{throw t}))},g=t=>{const e=f();t.waitUntil(e.activate())},R=t=>{f().addToCacheList(t),t.length>0&&(self.addEventListener("install",p),self.addEventListener("activate",g))};return t.PrecacheController=l,t.addPlugins=(t=>{o.add(t)}),t.addRoute=y,t.cleanupOutdatedCaches=(()=>{self.addEventListener("activate",t=>{const n=e.cacheNames.getPrecacheName();t.waitUntil((async(t,e="-precache-")=>{const n=(await self.caches.keys()).filter(n=>n.includes(e)&&n.includes(self.registration.scope)&&n!==t);return await Promise.all(n.map(t=>self.caches.delete(t))),n})(n).then(t=>{}))})}),t.createHandler=((t=!0)=>{return f().createHandler(t)}),t.createHandlerBoundToURL=(t=>{return f().createHandlerBoundToURL(t)}),t.getCacheKeyForURL=(t=>{return f().getCacheKeyForURL(t)}),t.matchPrecache=(t=>{return f().matchPrecache(t)}),t.precache=R,t.precacheAndRoute=((t,e)=>{R(t),y(e)}),t}({},workbox.core._private,workbox.core._private,workbox.core._private,workbox.core._private,workbox.core);
this.workbox=this.workbox||{},this.workbox.precaching=function(t,e,n,i,s,c){"use strict";try{self["workbox:precaching:5.0.0-rc.2"]&&_()}catch(t){}const o=[],r={get:()=>o,add(t){o.push(...t)}};const a="__WB_REVISION__";function h(t){if(!t)throw new s.WorkboxError("add-to-cache-list-unexpected-type",{entry:t});if("string"==typeof t){const e=new URL(t,location.href);return{cacheKey:e.href,url:e.href}}const{revision:e,url:n}=t;if(!n)throw new s.WorkboxError("add-to-cache-list-unexpected-type",{entry:t});if(!e){const t=new URL(n,location.href);return{cacheKey:t.href,url:t.href}}const i=new URL(n,location.href),c=new URL(n,location.href);return i.searchParams.set(a,e),{cacheKey:i.href,url:c.href}}class u{constructor(t){this.t=e.cacheNames.getPrecacheName(t),this.i=new Map,this.s=new Map,this.o=new Map}addToCacheList(t){const e=[];for(const n of t){"string"==typeof n?e.push(n):n&&void 0===n.revision&&e.push(n.url);const{cacheKey:t,url:i}=h(n),c="string"!=typeof n&&n.revision?"reload":"default";if(this.i.has(i)&&this.i.get(i)!==t)throw new s.WorkboxError("add-to-cache-list-conflicting-entries",{firstEntry:this.i.get(i),secondEntry:t});if("string"!=typeof n&&n.integrity){if(this.o.has(t)&&this.o.get(t)!==n.integrity)throw new s.WorkboxError("add-to-cache-list-conflicting-integrities",{url:i});this.o.set(t,n.integrity)}if(this.i.set(i,t),this.s.set(i,c),e.length>0){const t="Workbox is precaching URLs without revision "+`info: ${e.join(", ")}\nThis is generally NOT safe. `+"Learn more at https://bit.ly/wb-precache";console.warn(t)}}}async install({event:t,plugins:e}={}){const n=[],i=[],s=await self.caches.open(this.t),c=await s.keys(),o=new Set(c.map(t=>t.url));for(const[t,e]of this.i)o.has(e)?i.push(t):n.push({cacheKey:e,url:t});const r=n.map(({cacheKey:n,url:i})=>{const s=this.o.get(n),c=this.s.get(i);return this.h({cacheKey:n,cacheMode:c,event:t,integrity:s,plugins:e,url:i})});return await Promise.all(r),{updatedURLs:n.map(t=>t.url),notUpdatedURLs:i}}async activate(){const t=await self.caches.open(this.t),e=await t.keys(),n=new Set(this.i.values()),i=[];for(const s of e)n.has(s.url)||(await t.delete(s),i.push(s.url));return{deletedURLs:i}}async h({cacheKey:t,url:e,cacheMode:o,event:r,plugins:a,integrity:h}){const u=new Request(e,{integrity:h,cache:o,credentials:"same-origin"});let l,f=await i.fetchWrapper.fetch({event:r,plugins:a,request:u});for(const t of a||[])"cacheWillUpdate"in t&&(l=t);if(!(l?await l.cacheWillUpdate({event:r,request:u,response:f}):f.status<400))throw new s.WorkboxError("bad-precaching-response",{url:e,status:f.status});f.redirected&&(f=await c.copyResponse(f)),await n.cacheWrapper.put({event:r,plugins:a,response:f,request:t===e?u:new Request(t),cacheName:this.t,matchOptions:{ignoreSearch:!0}})}getURLsToCacheKeys(){return this.i}getCachedURLs(){return[...this.i.keys()]}getCacheKeyForURL(t){const e=new URL(t,location.href);return this.i.get(e.href)}async matchPrecache(t){const e=t instanceof Request?t.url:t,n=this.getCacheKeyForURL(e);if(n){return(await self.caches.open(this.t)).match(n)}}createHandler(t=!0){return async({request:e})=>{try{const n=await this.matchPrecache(e);if(n)return n;throw new s.WorkboxError("missing-precache-entry",{cacheName:this.t,url:e instanceof Request?e.url:e})}catch(n){if(t)return fetch(e);throw n}}}createHandlerBoundToURL(t,e=!0){if(!this.getCacheKeyForURL(t))throw new s.WorkboxError("non-precached-url",{url:t});const n=this.createHandler(e),i=new Request(t);return()=>n({request:i})}}let l;const f=()=>(l||(l=new u),l);const w=(t,e)=>{const n=f().getURLsToCacheKeys();for(const i of function*(t,{ignoreURLParametersMatching:e,directoryIndex:n,cleanURLs:i,urlManipulation:s}={}){const c=new URL(t,location.href);c.hash="",yield c.href;const o=function(t,e=[]){for(const n of[...t.searchParams.keys()])e.some(t=>t.test(n))&&t.searchParams.delete(n);return t}(c,e);if(yield o.href,n&&o.pathname.endsWith("/")){const t=new URL(o.href);t.pathname+=n,yield t.href}if(i){const t=new URL(o.href);t.pathname+=".html",yield t.href}if(s){const t=s({url:c});for(const e of t)yield e.href}}(t,e)){const t=n.get(i);if(t)return t}},d=({ignoreURLParametersMatching:t=[/^utm_/],directoryIndex:n="index.html",cleanURLs:i=!0,urlManipulation:s}={})=>{const c=e.cacheNames.getPrecacheName();self.addEventListener("fetch",e=>{const o=w(e.request.url,{cleanURLs:i,directoryIndex:n,ignoreURLParametersMatching:t,urlManipulation:s});if(!o)return;let r=self.caches.open(c).then(t=>t.match(o)).then(t=>t||fetch(o));e.respondWith(r)})};let y=!1;function p(t){y||(d(t),y=!0)}const g=async(t,e="-precache-")=>{const n=(await self.caches.keys()).filter(n=>n.includes(e)&&n.includes(self.registration.scope)&&n!==t);return await Promise.all(n.map(t=>self.caches.delete(t))),n};const R=t=>{const e=f(),n=r.get();t.waitUntil(e.install({event:t,plugins:n}).catch(t=>{throw t}))},L=t=>{const e=f();t.waitUntil(e.activate())};function U(t){f().addToCacheList(t),t.length>0&&(self.addEventListener("install",R),self.addEventListener("activate",L))}return t.PrecacheController=u,t.addPlugins=function(t){r.add(t)},t.addRoute=p,t.cleanupOutdatedCaches=function(){self.addEventListener("activate",t=>{const n=e.cacheNames.getPrecacheName();t.waitUntil(g(n).then(t=>{}))})},t.createHandler=function(t=!0){return f().createHandler(t)},t.createHandlerBoundToURL=function(t){return f().createHandlerBoundToURL(t)},t.getCacheKeyForURL=function(t){return f().getCacheKeyForURL(t)},t.matchPrecache=function(t){return f().matchPrecache(t)},t.precache=U,t.precacheAndRoute=function(t,e){U(t),p(e)},t}({},workbox.core._private,workbox.core._private,workbox.core._private,workbox.core._private,workbox.core);
//# sourceMappingURL=workbox-precaching.prod.js.map

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

*
* @alias workbox.precaching.cleanupOutdatedCaches
* @memberof module:workbox-precaching
*/
export declare const cleanupOutdatedCaches: () => void;
declare function cleanupOutdatedCaches(): void;
export { cleanupOutdatedCaches };

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

*
* @alias workbox.precaching.cleanupOutdatedCaches
* @memberof module:workbox-precaching
*/
export const cleanupOutdatedCaches = () => {
function cleanupOutdatedCaches() {
// See https://github.com/Microsoft/TypeScript/issues/28357#issuecomment-436484705

@@ -32,2 +32,4 @@ self.addEventListener('activate', ((event) => {

}));
};
}
;
export { cleanupOutdatedCaches };

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

* response from the network if there's a precache miss.
* @return {workbox.routing.Route~handlerCallback}
* @return {module:workbox-routing~handlerCallback}
*
* @alias workbox.precaching.createHandler
* @memberof module:workbox-precaching
*/
export declare const createHandler: (fallbackToNetwork?: boolean) => import("workbox-core/types").RouteHandlerCallback;
declare function createHandler(fallbackToNetwork?: boolean): import("workbox-core/types").RouteHandlerCallback;
export { createHandler };

@@ -21,9 +21,11 @@ /*

* response from the network if there's a precache miss.
* @return {workbox.routing.Route~handlerCallback}
* @return {module:workbox-routing~handlerCallback}
*
* @alias workbox.precaching.createHandler
* @memberof module:workbox-precaching
*/
export const createHandler = (fallbackToNetwork = true) => {
function createHandler(fallbackToNetwork = true) {
const precacheController = getOrCreatePrecacheController();
return precacheController.createHandler(fallbackToNetwork);
};
}
;
export { createHandler };

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

* response from the network if there's a precache miss.
* @return {workbox.routing.Route~handlerCallback}
* @return {module:workbox-routing~handlerCallback}
*
* @alias workbox.precaching.createHandlerBoundToURL
* @memberof module:workbox-precaching
*/
export declare const createHandlerBoundToURL: (url: string) => import("workbox-core/types").RouteHandlerCallback;
declare function createHandlerBoundToURL(url: string): import("workbox-core/types").RouteHandlerCallback;
export { createHandlerBoundToURL };

@@ -23,9 +23,11 @@ /*

* response from the network if there's a precache miss.
* @return {workbox.routing.Route~handlerCallback}
* @return {module:workbox-routing~handlerCallback}
*
* @alias workbox.precaching.createHandlerBoundToURL
* @memberof module:workbox-precaching
*/
export const createHandlerBoundToURL = (url) => {
function createHandlerBoundToURL(url) {
const precacheController = getOrCreatePrecacheController();
return precacheController.createHandlerBoundToURL(url);
};
}
;
export { createHandlerBoundToURL };

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

*
* @alias workbox.precaching.getCacheKeyForURL
* @memberof module:workbox-precaching
*/
export declare const getCacheKeyForURL: (url: string) => string | undefined;
declare function getCacheKeyForURL(url: string): string | undefined;
export { getCacheKeyForURL };

@@ -27,7 +27,9 @@ /*

*
* @alias workbox.precaching.getCacheKeyForURL
* @memberof module:workbox-precaching
*/
export const getCacheKeyForURL = (url) => {
function getCacheKeyForURL(url) {
const precacheController = getOrCreatePrecacheController();
return precacheController.getCacheKeyForURL(url);
};
}
;
export { getCacheKeyForURL };

@@ -14,3 +14,3 @@ import { addPlugins } from './addPlugins.js';

* Most consumers of this module will want to use the
* [precacheAndRoute()]{@link workbox.precaching.precacheAndRoute}
* [precacheAndRoute()]{@link module:workbox-precaching.precacheAndRoute}
* method to add assets to the Cache and respond to network requests with these

@@ -20,7 +20,7 @@ * cached assets.

* If you require finer grained control, you can use the
* [PrecacheController]{@link workbox.precaching.PrecacheController}
* [PrecacheController]{@link module:workbox-precaching.PrecacheController}
* to determine when performed.
*
* @namespace workbox.precaching
* @module workbox-precaching
*/
export { addPlugins, addRoute, cleanupOutdatedCaches, createHandler, createHandlerBoundToURL, getCacheKeyForURL, matchPrecache, precache, precacheAndRoute, PrecacheController, };

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

* Most consumers of this module will want to use the
* [precacheAndRoute()]{@link workbox.precaching.precacheAndRoute}
* [precacheAndRoute()]{@link module:workbox-precaching.precacheAndRoute}
* method to add assets to the Cache and respond to network requests with these

@@ -31,7 +31,7 @@ * cached assets.

* If you require finer grained control, you can use the
* [PrecacheController]{@link workbox.precaching.PrecacheController}
* [PrecacheController]{@link module:workbox-precaching.PrecacheController}
* to determine when performed.
*
* @namespace workbox.precaching
* @module workbox-precaching
*/
export { addPlugins, addRoute, cleanupOutdatedCaches, createHandler, createHandlerBoundToURL, getCacheKeyForURL, matchPrecache, precache, precacheAndRoute, PrecacheController, };

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

*
* @alias workbox.precaching.matchPrecache
* @memberof module:workbox-precaching
*/
export declare const matchPrecache: (request: RequestInfo) => Promise<Response | undefined>;
declare function matchPrecache(request: string | Request): Promise<Response | undefined>;
export { matchPrecache };

@@ -23,7 +23,9 @@ /*

*
* @alias workbox.precaching.matchPrecache
* @memberof module:workbox-precaching
*/
export const matchPrecache = (request) => {
function matchPrecache(request) {
const precacheController = getOrCreatePrecacheController();
return precacheController.matchPrecache(request);
};
}
;
export { matchPrecache };
{
"name": "workbox-precaching",
"version": "5.0.0-rc.1",
"version": "5.0.0-rc.2",
"license": "MIT",

@@ -29,5 +29,5 @@ "author": "Google's Web DevRel Team",

"dependencies": {
"workbox-core": "^5.0.0-rc.1"
"workbox-core": "^5.0.0-rc.2"
},
"gitHead": "f03f71e50507e13d82d4e0a875cc49ba4501aff3"
"gitHead": "89904768b2210e59c830dd380cf88a06e1c26a2b"
}

@@ -25,4 +25,5 @@ import { PrecacheEntry } from './_types.js';

*
* @alias workbox.precaching.precache
* @memberof module:workbox-precaching
*/
export declare const precache: (entries: (string | PrecacheEntry)[]) => void;
declare function precache(entries: Array<PrecacheEntry | string>): void;
export { precache };

@@ -46,5 +46,5 @@ /*

*
* @alias workbox.precaching.precache
* @memberof module:workbox-precaching
*/
export const precache = (entries) => {
function precache(entries) {
const precacheController = getOrCreatePrecacheController();

@@ -60,2 +60,4 @@ precacheController.addToCacheList(entries);

}
};
}
;
export { precache };

@@ -21,4 +21,5 @@ import { FetchListenerOptions } from './utils/addFetchListener.js';

*
* @alias workbox.precaching.precacheAndRoute
* @memberof module:workbox-precaching
*/
export declare const precacheAndRoute: (entries: (string | PrecacheEntry)[], options?: FetchListenerOptions | undefined) => void;
declare function precacheAndRoute(entries: Array<PrecacheEntry | string>, options?: FetchListenerOptions): void;
export { precacheAndRoute };

@@ -23,7 +23,9 @@ /*

*
* @alias workbox.precaching.precacheAndRoute
* @memberof module:workbox-precaching
*/
export const precacheAndRoute = (entries, options) => {
function precacheAndRoute(entries, options) {
precache(entries);
addRoute(options);
};
}
;
export { precacheAndRoute };

@@ -39,3 +39,3 @@ import { RouteHandlerCallback } from 'workbox-core/types.js';

* and caching during install.
* @return {Promise<workbox.precaching.InstallResult>}
* @return {Promise<module:workbox-precaching.InstallResult>}
*/

@@ -53,3 +53,3 @@ install({ event, plugins }?: {

*
* @return {Promise<workbox.precaching.CleanupResult>}
* @return {Promise<module:workbox-precaching.CleanupResult>}
*/

@@ -130,4 +130,5 @@ activate(): Promise<{

/**
* Returns a function that can be used within a {@link workbox.routing.Route}
* that will find a response for the incoming request against the precache.
* Returns a function that can be used within a
* {@link module:workbox-routing.Route} that will find a response for the
* incoming request against the precache.
*

@@ -140,3 +141,3 @@ * If for an unexpected reason there is a cache miss for the request,

* response from the network if there's a precache miss.
* @return {workbox.routing.Route~handlerCallback}
* @return {module:workbox-routing~handlerCallback}
*/

@@ -156,3 +157,3 @@ createHandler(fallbackToNetwork?: boolean): RouteHandlerCallback;

* response from the network if there's a precache miss.
* @return {workbox.routing.Route~handlerCallback}
* @return {module:workbox-routing~handlerCallback}
*/

@@ -159,0 +160,0 @@ createHandlerBoundToURL(url: string, fallbackToNetwork?: boolean): RouteHandlerCallback;

@@ -107,3 +107,3 @@ /*

* and caching during install.
* @return {Promise<workbox.precaching.InstallResult>}
* @return {Promise<module:workbox-precaching.InstallResult>}
*/

@@ -160,3 +160,3 @@ async install({ event, plugins } = {}) {

*
* @return {Promise<workbox.precaching.CleanupResult>}
* @return {Promise<module:workbox-precaching.CleanupResult>}
*/

@@ -212,3 +212,3 @@ async activate() {

// valid by passing in a plugin implementing cacheWillUpdate(), e.g.
// a workbox.cacheableResponse.CacheableResponsePlugin instance.
// a `CacheableResponsePlugin` instance.
let cacheWillUpdatePlugin;

@@ -313,4 +313,5 @@ for (const plugin of (plugins || [])) {

/**
* Returns a function that can be used within a {@link workbox.routing.Route}
* that will find a response for the incoming request against the precache.
* Returns a function that can be used within a
* {@link module:workbox-routing.Route} that will find a response for the
* incoming request against the precache.
*

@@ -323,3 +324,3 @@ * If for an unexpected reason there is a cache miss for the request,

* response from the network if there's a precache miss.
* @return {workbox.routing.Route~handlerCallback}
* @return {module:workbox-routing~handlerCallback}
*/

@@ -337,3 +338,3 @@ createHandler(fallbackToNetwork = true) {

cacheName: this._cacheName,
url: request.url,
url: request instanceof Request ? request.url : request,
});

@@ -365,3 +366,3 @@ }

* response from the network if there's a precache miss.
* @return {workbox.routing.Route~handlerCallback}
* @return {module:workbox-routing~handlerCallback}
*/

@@ -368,0 +369,0 @@ createHandlerBoundToURL(url, fallbackToNetwork = true) {

@@ -11,2 +11,26 @@ /*

export interface InstallResult {
updatedURLs: string[];
notUpdatedURLs: string[];
}
export interface CleanupResult {
deletedCacheRequests: string[],
}
export interface PrecacheEntry {
integrity?: string;
url: string;
revision?: string;
}
export type urlManipulation = ({url}: {url: URL}) => URL[];
// * * * IMPORTANT! * * *
// ------------------------------------------------------------------------- //
// jdsoc type definitions cannot be declared above TypeScript definitions or
// they'll be stripped from the built `.js` files, and they'll only be in the
// `d.ts` files, which aren't read by the jsdoc generator. As a result we
// have to put declare them below.
/**

@@ -19,8 +43,4 @@ * @typedef {Object} InstallResult

*
* @memberof workbox.precaching
* @memberof module:workbox-precaching
*/
export interface InstallResult {
updatedURLs: string[];
notUpdatedURLs: string[];
}

@@ -32,7 +52,4 @@ /**

*
* @memberof workbox.precaching
* @memberof module:workbox-precaching
*/
export interface CleanupResult {
deletedCacheRequests: string[],
}

@@ -46,9 +63,4 @@ /**

*
* @memberof workbox.precaching
* @memberof module:workbox-precaching
*/
export interface PrecacheEntry {
integrity?: string;
url: string;
revision?: string;
}

@@ -69,4 +81,3 @@ /**

*
* @memberof workbox.precaching
* @memberof module:workbox-precaching
*/
export type urlManipulation = ({url}: {url: URL}) => URL[];
// @ts-ignore
try{self['workbox:precaching:5.0.0-rc.1']&&_()}catch(e){}
try{self['workbox:precaching:5.0.0-rc.2']&&_()}catch(e){}

@@ -19,5 +19,5 @@ /*

*
* @alias workbox.precaching.addPlugins
* @memberof module:workbox-precaching
*/
const addPlugins = (newPlugins: WorkboxPlugin[]) => {
function addPlugins(newPlugins: WorkboxPlugin[]) {
precachePlugins.add(newPlugins);

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

@@ -33,9 +33,9 @@

* check the cache for the URL with a `.html` added to the end of the end.
* @param {workbox.precaching~urlManipulation} [options.urlManipulation]
* @param {module:workbox-precaching~urlManipulation} [options.urlManipulation]
* This is a function that should take a URL and return an array of
* alternative URLs that should be checked for precache matches.
*
* @alias workbox.precaching.addRoute
* @memberof module:workbox-precaching
*/
export const addRoute = (options?: FetchListenerOptions) => {
function addRoute(options?: FetchListenerOptions) {
if (!listenerAdded) {

@@ -46,1 +46,3 @@ addFetchListener(options);

};
export {addRoute}

@@ -19,5 +19,5 @@ /*

*
* @alias workbox.precaching.cleanupOutdatedCaches
* @memberof module:workbox-precaching
*/
export const cleanupOutdatedCaches = () => {
function cleanupOutdatedCaches() {
// See https://github.com/Microsoft/TypeScript/issues/28357#issuecomment-436484705

@@ -37,1 +37,3 @@ self.addEventListener('activate', ((event: ExtendableEvent) => {

};
export {cleanupOutdatedCaches}

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

* {@link PrecacheController} instance.
*
*
* If you are creating your own {@link PrecacheController}, then call the

@@ -25,9 +25,11 @@ * {@link PrecacheController#createHandler} on that instance,

* response from the network if there's a precache miss.
* @return {workbox.routing.Route~handlerCallback}
* @return {module:workbox-routing~handlerCallback}
*
* @alias workbox.precaching.createHandler
* @memberof module:workbox-precaching
*/
export const createHandler = (fallbackToNetwork = true) => {
function createHandler(fallbackToNetwork = true) {
const precacheController = getOrCreatePrecacheController();
return precacheController.createHandler(fallbackToNetwork);
};
export {createHandler}

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

* {@link PrecacheController} instance.
*
*
* If you are creating your own {@link PrecacheController}, then call the

@@ -27,9 +27,11 @@ * {@link PrecacheController#createHandlerBoundToURL} on that instance,

* response from the network if there's a precache miss.
* @return {workbox.routing.Route~handlerCallback}
* @return {module:workbox-routing~handlerCallback}
*
* @alias workbox.precaching.createHandlerBoundToURL
* @memberof module:workbox-precaching
*/
export const createHandlerBoundToURL = (url: string) => {
function createHandlerBoundToURL(url: string) {
const precacheController = getOrCreatePrecacheController();
return precacheController.createHandlerBoundToURL(url);
};
export {createHandlerBoundToURL}

@@ -30,7 +30,9 @@ /*

*
* @alias workbox.precaching.getCacheKeyForURL
* @memberof module:workbox-precaching
*/
export const getCacheKeyForURL = (url: string) => {
function getCacheKeyForURL(url: string) {
const precacheController = getOrCreatePrecacheController();
return precacheController.getCacheKeyForURL(url);
};
export {getCacheKeyForURL}

@@ -30,3 +30,3 @@ /*

* Most consumers of this module will want to use the
* [precacheAndRoute()]{@link workbox.precaching.precacheAndRoute}
* [precacheAndRoute()]{@link module:workbox-precaching.precacheAndRoute}
* method to add assets to the Cache and respond to network requests with these

@@ -36,6 +36,6 @@ * cached assets.

* If you require finer grained control, you can use the
* [PrecacheController]{@link workbox.precaching.PrecacheController}
* [PrecacheController]{@link module:workbox-precaching.PrecacheController}
* to determine when performed.
*
* @namespace workbox.precaching
* @module workbox-precaching
*/

@@ -42,0 +42,0 @@

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

* {@link PrecacheController} instance.
*
*
* If you are creating your own {@link PrecacheController}, then call

@@ -27,7 +27,9 @@ * {@link PrecacheController#matchPrecache} on that instance,

*
* @alias workbox.precaching.matchPrecache
* @memberof module:workbox-precaching
*/
export const matchPrecache = (request: string|Request) => {
function matchPrecache(request: string|Request) {
const precacheController = getOrCreatePrecacheController();
return precacheController.matchPrecache(request);
};
export {matchPrecache}

@@ -61,5 +61,5 @@ /*

*
* @alias workbox.precaching.precache
* @memberof module:workbox-precaching
*/
export const precache = (entries: Array<PrecacheEntry|string>) => {
function precache(entries: Array<PrecacheEntry|string>) {
const precacheController = getOrCreatePrecacheController();

@@ -77,1 +77,3 @@ precacheController.addToCacheList(entries);

};
export {precache}

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

*
* @alias workbox.precaching.precacheAndRoute
* @memberof module:workbox-precaching
*/
export const precacheAndRoute =
(entries: Array<PrecacheEntry|string>, options?: FetchListenerOptions) => {
function precacheAndRoute(entries: Array<PrecacheEntry|string>, options?: FetchListenerOptions) {
precache(entries);
addRoute(options);
};
export {precacheAndRoute}

@@ -126,3 +126,3 @@ /*

* and caching during install.
* @return {Promise<workbox.precaching.InstallResult>}
* @return {Promise<module:workbox-precaching.InstallResult>}
*/

@@ -190,3 +190,3 @@ async install({event, plugins}: {

*
* @return {Promise<workbox.precaching.CleanupResult>}
* @return {Promise<module:workbox-precaching.CleanupResult>}
*/

@@ -255,3 +255,3 @@ async activate() {

// valid by passing in a plugin implementing cacheWillUpdate(), e.g.
// a workbox.cacheableResponse.CacheableResponsePlugin instance.
// a `CacheableResponsePlugin` instance.
let cacheWillUpdatePlugin;

@@ -340,3 +340,3 @@ for (const plugin of (plugins || [])) {

* with the following differences:
*
*
* - It knows what the name of the precache is, and only checks in that cache.

@@ -346,3 +346,3 @@ * - It allows you to pass in an "original" URL without versioning parameters,

* active revision of that URL.
*
*
* E.g., `matchPrecache('index.html')` will find the correct precached

@@ -367,4 +367,5 @@ * response for the currently active service worker, even if the actual cache

/**
* Returns a function that can be used within a {@link workbox.routing.Route}
* that will find a response for the incoming request against the precache.
* Returns a function that can be used within a
* {@link module:workbox-routing.Route} that will find a response for the
* incoming request against the precache.
*

@@ -377,3 +378,3 @@ * If for an unexpected reason there is a cache miss for the request,

* response from the network if there's a precache miss.
* @return {workbox.routing.Route~handlerCallback}
* @return {module:workbox-routing~handlerCallback}
*/

@@ -392,3 +393,3 @@ createHandler(fallbackToNetwork = true): RouteHandlerCallback {

cacheName: this._cacheName,
url: request.url,
url: request instanceof Request ? request.url : request,
});

@@ -421,3 +422,3 @@ } catch (error) {

* response from the network if there's a precache miss.
* @return {workbox.routing.Route~handlerCallback}
* @return {module:workbox-routing~handlerCallback}
*/

@@ -424,0 +425,0 @@ createHandlerBoundToURL(url: string, fallbackToNetwork = true): RouteHandlerCallback {

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