1const options = {"workboxURL":"https://cdn.jsdelivr.net/npm/[email protected]/workbox/workbox-sw.js","importScripts":[],"config":{"debug":false},"clientsClaim":true,"skipWaiting":true,"cleanupOutdatedCaches":true,"offlineAnalytics":false,"preCaching":["/?standalone=true"],"runtimeCaching":[{"urlPattern":"^https://eataly-bbb.cdn.prismic.io/api/v2/.*(menu_structure|mddm_ecommerce_content|mddm_editorial_content|footer_content).*","strategyOptions":{"cacheName":"PrismicMenuCustomTypes"},"handler":"CacheFirst","strategyPlugins":[{"use":"expiration.ExpirationPlugin","config":[{"maxEntries":20,"maxAgeSeconds":3600}]}],"method":"GET"},{"urlPattern":"^https://eataly-bbb.cdn.prismic.io/api/v2/.*(announcement_bar|homepage|pdp_content|footer_checkout|error_page_404|massive_promotion|modal_upcoming_features).*","strategyOptions":{"cacheName":"PrismicGlobalCustomTypes"},"handler":"CacheFirst","strategyPlugins":[{"use":"expiration.ExpirationPlugin","config":[{"maxEntries":20,"maxAgeSeconds":3600}]}],"method":"GET"},{"urlPattern":"^https://eataly-bbb.cdn.prismic.io/api/v2/.*(?<!my.)(?:news_filtered)(?!.[a-z_]).*","strategyOptions":{"cacheName":"PrismicNewsFiltered"},"handler":"CacheFirst","strategyPlugins":[{"use":"expiration.ExpirationPlugin","config":[{"maxEntries":20,"maxAgeSeconds":900}]}],"method":"GET"},{"urlPattern":"^https://eataly-bbb.cdn.prismic.io/api/v2/.*(category_content).*","strategyOptions":{"cacheName":"PrismicCategoryContent"},"handler":"CacheFirst","strategyPlugins":[{"use":"expiration.ExpirationPlugin","config":[{"maxEntries":20,"maxAgeSeconds":3600}]}],"method":"GET"},{"handler":"NetworkFirst","method":"GET","strategyPlugins":[]},{"handler":"NetworkFirst","method":"GET","strategyPlugins":[]},{"urlPattern":"^https://fonts.googleapis.com/.*","handler":"NetworkFirst","method":"GET","strategyPlugins":[]},{"urlPattern":"^https://cdn.jsdelivr.net/.*","handler":"NetworkFirst","method":"GET","strategyPlugins":[]},{"urlPattern":"^https://track.adform.net/.*","handler":"NetworkOnly","method":"GET","strategyPlugins":[]},{"urlPattern":"^https://sslwidget.criteo.com/.*","handler":"NetworkOnly","method":"GET","strategyPlugins":[]},{"urlPattern":"https://connect.facebook.net/en_US/sdk.js$","handler":"NetworkOnly","method":"GET","strategyPlugins":[]},{"urlPattern":"^https://connect.facebook.net/.*","handler":"NetworkOnly","method":"GET","strategyPlugins":[]},{"urlPattern":"^https://eataly-bbb.cdn.prismic.io/api/v2$","strategyOptions":{"cacheName":"PrismicApiRoot"},"handler":"StaleWhileRevalidate","strategyPlugins":[{"use":"expiration.ExpirationPlugin","config":[{"maxEntries":5,"maxAgeSeconds":86400}]}],"method":"GET"},{"urlPattern":"^undefined/.*","handler":"NetworkOnly","method":"GET","strategyPlugins":[]},{"urlPattern":"^https://www.google-analytics.com/.*","handler":"NetworkOnly","method":"GET","strategyPlugins":[]},{"urlPattern":"/cdn/7f67ba3036b8671eff6de215b1960142f5d88d5f/","handler":"CacheFirst","method":"GET","strategyPlugins":[]},{"urlPattern":"/","handler":"NetworkFirst","method":"GET","strategyPlugins":[]}],"offlinePage":null,"pagesURLPattern":"/","offlineStrategy":"NetworkFirst"} 2 3importScripts(...[options.workboxURL, ...options.importScripts]) 4 5initWorkbox(workbox, options) 6workboxExtensions(workbox, options) 7precacheAssets(workbox, options) 8cachingExtensions(workbox, options) 9runtimeCaching(workbox, options) 10offlinePage(workbox, options) 11routingExtensions(workbox, options) 12 13function getProp(obj, prop) { 14 return prop.split('.').reduce((p, c) => p[c], obj) 15} 16 17function initWorkbox(workbox, options) { 18 if (options.config) { 19 // Set workbox config 20 workbox.setConfig(options.config) 21 } 22 23 if (options.cacheNames) { 24 // Set workbox cache names 25 workbox.core.setCacheNameDetails(options.cacheNames) 26 } 27 28 if (options.clientsClaim) { 29 // Start controlling any existing clients as soon as it activates 30 workbox.core.clientsClaim() 31 } 32 33 if (options.skipWaiting) { 34 workbox.core.skipWaiting() 35 } 36 37 if (options.cleanupOutdatedCaches) { 38 workbox.precaching.cleanupOutdatedCaches() 39 } 40 41 if (options.offlineAnalytics) { 42 // Enable offline Google Analytics tracking 43 workbox.googleAnalytics.initialize() 44 } 45} 46 47function precacheAssets(workbox, options) { 48 if (options.preCaching.length) { 49 workbox.precaching.precacheAndRoute(options.preCaching, options.cacheOptions) 50 } 51} 52 53function runtimeCaching(workbox, options) { 54 for (const entry of options.runtimeCaching) { 55 const urlPattern = new RegExp(entry.urlPattern) 56 const method = entry.method || 'GET' 57 58 const plugins = (entry.strategyPlugins || []) 59 .map(p => new (getProp(workbox, p.use))(...p.config)) 60 61 const strategyOptions = { ...entry.strategyOptions, plugins } 62 63 const strategy = new workbox.strategies[entry.handler](strategyOptions) 64 65 workbox.routing.registerRoute(urlPattern, strategy, method) 66 } 67} 68 69function offlinePage(workbox, options) { 70 if (options.offlinePage) { 71 // Register router handler for offlinePage 72 workbox.routing.registerRoute(new RegExp(options.pagesURLPattern), ({ request, event }) => { 73 const strategy = new workbox.strategies[options.offlineStrategy] 74 return strategy 75 .handle({ request, event }) 76 .catch(() => caches.match(options.offlinePage)) 77 }) 78 } 79} 80 81function workboxExtensions(workbox, options) { 82 83} 84 85function cachingExtensions(workbox, options) { 86 87} 88
89function routingExtensions(workbox, options) { 90 91}
Line numbers count LF bytes from the start of the resource, as the search results do. Vendor segments are library code the classifier recognised; they are stored but not indexed. Bytes are shown as Latin1 characters, one per byte.