Socket
Socket
Sign inDemoInstall

workbox-routing

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-routing - npm Package Compare versions

Comparing version 4.0.0-beta.2 to 4.0.0-rc.0

9

build/workbox-routing.dev.js

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

try {
self['workbox:routing:4.0.0-beta.2'] && _();
self['workbox:routing:4.0.0-rc.0'] && _();
} catch (e) {} // eslint-disable-line

@@ -783,2 +783,7 @@

*
* When determining the URL of the precached HTML document, you will likely need
* to call `workbox.precaching.getCacheKeyForURL(originalUrl)`, to account for
* the fact that Workbox's precaching naming conventions often results in URL
* cache keys that contain extra revisioning info.
*
* This method will generate a

@@ -790,3 +795,3 @@ * [NavigationRoute]{@link workbox.routing.NavigationRoute}

*
* @param {string} cachedAssetUrl
* @param {string} cachedAssetUrl The cache key to use for the HTML file.
* @param {Object} [options]

@@ -793,0 +798,0 @@ * @param {string} [options.cacheName] Cache name to store and retrieve

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

this.workbox=this.workbox||{},this.workbox.routing=function(t,e,r){"use strict";try{self["workbox:routing:4.0.0-beta.2"]&&_()}catch(t){}const s="GET",n=t=>t&&"object"==typeof t?t:{handle:t};class o{constructor(t,e,r){this.handler=n(e),this.match=t,this.method=r||s}}class i extends o{constructor(t,{whitelist:e=[/./],blacklist:r=[]}={}){super(t=>this.t(t),t),this.e=e,this.r=r}t({url:t,request:e}){if("navigate"!==e.mode)return!1;const r=t.pathname+t.search;for(const t of this.r)if(t.test(r))return!1;return!!this.e.some(t=>t.test(r))}}class u extends o{constructor(t,e,r){super(({url:e})=>{const r=t.exec(e.href);return r?e.origin!==location.origin&&0!==r.index?null:r.slice(1):null},e,r)}}class c{constructor(){this.s=new Map}get routes(){return this.s}addFetchListener(){self.addEventListener("fetch",t=>{const{request:e}=t,r=this.handleRequest({request:e,event:t});r&&t.respondWith(r)})}addCacheListener(){self.addEventListener("message",t=>{const{type:e,meta:r,payload:s}=t.data;if("CACHE_URLS"===e&&"workbox-window"===r)for(let e of s.urlsToCache){"string"==typeof e&&(e=[e]);const r=new Request(...e);this.handleRequest({request:r,event:t})}})}handleRequest({request:t,event:e}){const r=new URL(t.url,location);if(!r.protocol.startsWith("http"))return;let s,{params:n,route:o}=this.findMatchingRoute({url:r,request:t,event:e}),i=o&&o.handler;if(!i&&this.n&&(i=this.n),i){try{s=i.handle({url:r,request:t,event:e,params:n})}catch(t){s=Promise.reject(t)}return s&&this.o&&(s=s.catch(t=>this.o.handle({url:r,event:e,err:t}))),s}}findMatchingRoute({url:t,request:e,event:r}){const s=this.s.get(e.method)||[];for(const n of s){let s,o=n.match({url:t,request:e,event:r});if(o)return Array.isArray(o)&&o.length>0?s=o:o.constructor===Object&&Object.keys(o).length>0&&(s=o),{route:n,params:s}}return{}}setDefaultHandler(t){this.n=n(t)}setCatchHandler(t){this.o=n(t)}registerRoute(t){this.s.has(t.method)||this.s.set(t.method,[]),this.s.get(t.method).push(t)}unregisterRoute(t){if(!this.s.has(t.method))throw new e.WorkboxError("unregister-route-but-not-found-with-method",{method:t.method});const r=this.s.get(t.method).indexOf(t);if(!(r>-1))throw new e.WorkboxError("unregister-route-route-not-registered");this.s.get(t.method).splice(r,1)}}let h;const a=()=>(h||((h=new c).addFetchListener(),h.addCacheListener()),h);return t.NavigationRoute=i,t.RegExpRoute=u,t.registerNavigationRoute=((t,e={})=>{const s=r.cacheNames.getPrecacheName(e.cacheName),n=new i(async()=>{try{const e=await caches.match(t,{cacheName:s});if(e)return e;throw new Error(`The cache ${s} did not have an entry for `+`${t}.`)}catch(e){return fetch(t)}},{whitelist:e.whitelist,blacklist:e.blacklist});return a().registerRoute(n),n}),t.registerRoute=((t,r,s="GET")=>{let n;if("string"==typeof t){const e=new URL(t,location);n=new o(({url:t})=>t.href===e.href,r,s)}else if(t instanceof RegExp)n=new u(t,r,s);else if("function"==typeof t)n=new o(t,r,s);else{if(!(t instanceof o))throw new e.WorkboxError("unsupported-route-type",{moduleName:"workbox-routing",funcName:"registerRoute",paramName:"capture"});n=t}return a().registerRoute(n),n}),t.Route=o,t.Router=c,t}({},workbox.core._private,workbox.core._private);
this.workbox=this.workbox||{},this.workbox.routing=function(t,e,r){"use strict";try{self["workbox:routing:4.0.0-rc.0"]&&_()}catch(t){}const s="GET",n=t=>t&&"object"==typeof t?t:{handle:t};class o{constructor(t,e,r){this.handler=n(e),this.match=t,this.method=r||s}}class i extends o{constructor(t,{whitelist:e=[/./],blacklist:r=[]}={}){super(t=>this.t(t),t),this.e=e,this.r=r}t({url:t,request:e}){if("navigate"!==e.mode)return!1;const r=t.pathname+t.search;for(const t of this.r)if(t.test(r))return!1;return!!this.e.some(t=>t.test(r))}}class u extends o{constructor(t,e,r){super(({url:e})=>{const r=t.exec(e.href);return r?e.origin!==location.origin&&0!==r.index?null:r.slice(1):null},e,r)}}class c{constructor(){this.s=new Map}get routes(){return this.s}addFetchListener(){self.addEventListener("fetch",t=>{const{request:e}=t,r=this.handleRequest({request:e,event:t});r&&t.respondWith(r)})}addCacheListener(){self.addEventListener("message",t=>{const{type:e,meta:r,payload:s}=t.data;if("CACHE_URLS"===e&&"workbox-window"===r)for(let e of s.urlsToCache){"string"==typeof e&&(e=[e]);const r=new Request(...e);this.handleRequest({request:r,event:t})}})}handleRequest({request:t,event:e}){const r=new URL(t.url,location);if(!r.protocol.startsWith("http"))return;let s,{params:n,route:o}=this.findMatchingRoute({url:r,request:t,event:e}),i=o&&o.handler;if(!i&&this.n&&(i=this.n),i){try{s=i.handle({url:r,request:t,event:e,params:n})}catch(t){s=Promise.reject(t)}return s&&this.o&&(s=s.catch(t=>this.o.handle({url:r,event:e,err:t}))),s}}findMatchingRoute({url:t,request:e,event:r}){const s=this.s.get(e.method)||[];for(const n of s){let s,o=n.match({url:t,request:e,event:r});if(o)return Array.isArray(o)&&o.length>0?s=o:o.constructor===Object&&Object.keys(o).length>0&&(s=o),{route:n,params:s}}return{}}setDefaultHandler(t){this.n=n(t)}setCatchHandler(t){this.o=n(t)}registerRoute(t){this.s.has(t.method)||this.s.set(t.method,[]),this.s.get(t.method).push(t)}unregisterRoute(t){if(!this.s.has(t.method))throw new e.WorkboxError("unregister-route-but-not-found-with-method",{method:t.method});const r=this.s.get(t.method).indexOf(t);if(!(r>-1))throw new e.WorkboxError("unregister-route-route-not-registered");this.s.get(t.method).splice(r,1)}}let h;const a=()=>(h||((h=new c).addFetchListener(),h.addCacheListener()),h);return t.NavigationRoute=i,t.RegExpRoute=u,t.registerNavigationRoute=((t,e={})=>{const s=r.cacheNames.getPrecacheName(e.cacheName),n=new i(async()=>{try{const e=await caches.match(t,{cacheName:s});if(e)return e;throw new Error(`The cache ${s} did not have an entry for `+`${t}.`)}catch(e){return fetch(t)}},{whitelist:e.whitelist,blacklist:e.blacklist});return a().registerRoute(n),n}),t.registerRoute=((t,r,s="GET")=>{let n;if("string"==typeof t){const e=new URL(t,location);n=new o(({url:t})=>t.href===e.href,r,s)}else if(t instanceof RegExp)n=new u(t,r,s);else if("function"==typeof t)n=new o(t,r,s);else{if(!(t instanceof o))throw new e.WorkboxError("unsupported-route-type",{moduleName:"workbox-routing",funcName:"registerRoute",paramName:"capture"});n=t}return a().registerRoute(n),n}),t.Route=o,t.Router=c,t}({},workbox.core._private,workbox.core._private);
//# sourceMappingURL=workbox-routing.prod.js.map
{
"name": "workbox-routing",
"version": "4.0.0-beta.2",
"version": "4.0.0-rc.0",
"license": "MIT",

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

"dependencies": {
"workbox-core": "^4.0.0-beta.2"
"workbox-core": "^4.0.0-rc.0"
},
"gitHead": "a0baa6ac838e1bff9a140ccbe2e78551d9605466"
"gitHead": "895940b985bea024e086713c319af216f7c5ee95"
}

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