1const options = {"workboxURL":"https://cdn.jsdelivr.net/npm/[email protected]/workbox/workbox-sw.js","importScripts":[],"config":{"debug":false},"cacheOptions":{"cacheId":"client-prod","directoryIndex":"/","revision":"TsHpF8y1ZnGu"},"clientsClaim":true,"skipWaiting":true,"cleanupOutdatedCaches":true,"offlineAnalytics":false,"preCaching":[{"revision":"TsHpF8y1ZnGu","url":"/?standalone=true"},{"revision":"TsHpF8y1ZnGu","url":"/?standalone=true"}],"runtimeCaching":[{"urlPattern":"/_nuxt/","handler":"CacheFirst","method":"GET","strategyPlugins":[]},{"urlPattern":"/","handler":"NetworkFirst","method":"GET","strategyPlugins":[]},{"urlPattern":"/_nuxt/","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 53 54function runtimeCaching(workbox, options) { 55 for (const entry of options.runtimeCaching) { 56 const urlPattern = new RegExp(entry.urlPattern) 57 const method = entry.method || 'GET' 58 59 const plugins = (entry.strategyPlugins || []) 60 .map(p => new (getProp(workbox, p.use))(...p.config)) 61 62 const strategyOptions = { ...entry.strategyOptions, plugins } 63 64 const strategy = new workbox.strategies[entry.handler](strategyOptions) 65 66 workbox.routing.registerRoute(urlPattern, strategy, method) 67 } 68} 69 70function offlinePage(workbox, options) { 71 if (options.offlinePage) { 72 // Register router handler for offlinePage 73 workbox.routing.registerRoute(new RegExp(options.pagesURLPattern), ({ request, event }) => { 74 const strategy = new workbox.strategies[options.offlineStrategy] 75 return strategy 76 .handle({ request, event }) 77 .catch(() => caches.match(options.offlinePage)) 78 }) 79 } 80} 81 82function workboxExtensions(workbox, options) { 83 84} 85 86function cachingExtensions(workbox, options) { 87 88} 89 90function routingExtensions(workbox, options) { 91 92}
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.