1/** 2 * Welcome to your Workbox-powered service worker! 3 * 4 * You'll need to register this file in your web app and you should 5 * disable HTTP caching for this file too. 6 * See https://goo.gl/nhQhGp 7 * 8 * The rest of the code is auto-generated. Please don't update this file 9 * directly; instead, make changes to your Workbox build configuration 10 * and re-run your build process. 11 * See https://goo.gl/2aRDsh 12 */ 13 14importScripts("workbox-v4.3.1/workbox-sw.js"); 15workbox.setConfig({modulePathPrefix: "workbox-v4.3.1"}); 16 17workbox.core.setCacheNameDetails({prefix: "gatsby-plugin-offline"}); 18 19workbox.core.skipWaiting(); 20 21workbox.core.clientsClaim(); 22 23/** 24 * The workboxSW.precacheAndRoute() method efficiently caches and responds to 25 * requests for URLs in the manifest. 26 * See https://goo.gl/S9QRab 27 */ 28self.__precacheManifest = [ 29 { 30 "url": "webpack-runtime-f6bc56ccb15ec425bc4e.js" 31 }, 32 { 33 "url": "styles.930e593232938898b8ff.css" 34 }, 35 { 36 "url": "framework-faf90a0b7173d05090af.js" 37 }, 38 { 39 "url": "app-5cdb754f09ec618b9aba.js" 40 }, 41 { 42 "url": "offline-plugin-app-shell-fallback/index.html", 43 "revision": "0afc02094a7247149251ca5f765a628f" 44 }, 45 { 46 "url": "component---cache-caches-gatsby-plugin-offline-app-shell-js-237337bbe8165821fd87.js" 47 }, 48 { 49 "url": "polyfill-923c433e7afdc6cc3e7a.js" 50 }, 51 { 52 "url": "manifest.webmanifest", 53 "revision": "61e560498707b226785cd1397c93f39b" 54 } 55].concat(self.__precacheManifest || []); 56workbox.precaching.precacheAndRoute(self.__precacheManifest, {}); 57 58workbox.routing.registerRoute(/(\.js$|\.css$|static\/)/, new workbox.strategies.CacheFirst(), 'GET'); 59workbox.routing.registerRoute(/^https?:.*\/page-data\/.*\.json/, new workbox.strategies.StaleWhileRevalidate(), 'GET'); 60workbox.routing.registerRoute(/^https?:.*\.(png|jpg|jpeg|webp|avif|svg|gif|tiff|js|woff|woff2|json|css)$/, new workbox.strategies.StaleWhileRevalidate(), 'GET'); 61workbox.routing.registerRoute(/^https?:\/\/fonts\.googleapis\.com\/css/, new workbox.strategies.StaleWhileRevalidate(), 'GET'); 62 63/* global importScripts, workbox, idbKeyval */ 64importScripts(`idb-keyval-3.2.0-iife.min.js`) 65 66const { NavigationRoute } = workbox.routing 67 68let lastNavigationRequest = null 69let offlineShellEnabled = true 70 71// prefer standard object syntax to support more browsers 72const MessageAPI = { 73 setPathResources: (event, { path, resources }) => { 74 event.waitUntil(idbKeyval.set(`resources:${path}`, resources)) 75 }, 76 77 clearPathResources: event => { 78 event.waitUntil(idbKeyval.clear()) 79 }, 80 81 enableOfflineShell: () => { 82 offlineShellEnabled = true 83 }, 84 85 disableOfflineShell: () => { 86 offlineShellEnabled = false 87 }, 88} 89 90self.addEventListener(`message`, event => { 91 const { gatsbyApi: api } = event.data 92 if (api) MessageAPI[api](event, event.data) 93}) 94 95function handleAPIRequest({ event }) { 96 const { pathname } = new URL(event.request.url) 97 98 const params = pathname.match(/:(.+)/)[1] 99 const data = {} 100 101 if (params.includes(`=`)) { 102 params.split(`&`).forEach(param => { 103 const [key, val] = param.split(`=`) 104 data[key] = val 105 }) 106 } else { 107 data.api = params 108 } 109 110 if (MessageAPI[data.api] !== undefined) { 111 MessageAPI[data.api]() 112 } 113 114 if (!data.redirect) { 115 return new Response() 116 } 117 118 return new Response(null, { 119 status: 302, 120 headers: { 121 Location: lastNavigationRequest, 122 }, 123 }) 124} 125 126const navigationRoute = new NavigationRoute(async ({ event }) => { 127 // handle API requests separately to normal navigation requests, so do this 128 // check first 129 if (event.request.url.match(/\/.gatsby-plugin-offline:.+/)) { 130 return handleAPIRequest({ event }) 131 } 132 133 if (!offlineShellEnabled) { 134 return await fetch(event.request) 135 } 136 137 lastNavigationRequest = event.request.url 138 139 let { pathname } = new URL(event.request.url) 140 pathname = pathname.replace(new RegExp(`^`), ``) 141 142 // Check for resources + the app bundle 143 // The latter may not exist if the SW is updating to a new version 144 const resources = await idbKeyval.get(`resources:${pathname}`) 145 if (!resources || !(await caches.match(`/app-5cdb754f09ec618b9aba.js`))) { 146 return await fetch(event.request) 147 } 148 149 for (const resource of resources) { 150 // As soon as we detect a failed resource, fetch the entire page from 151 // network - that way we won't risk being in an inconsistent state with 152 // some parts of the page failing. 153 if (!(await caches.match(resource))) { 154 return await fetch(event.request) 155 } 156 } 157 158 const offlineShell = `/offline-plugin-app-shell-fallback/index.html` 159 const offlineShellWithKey = workbox.precaching.getCacheKeyForURL(offlineShell) 160 return await caches.match(offlineShellWithKey) 161}) 162 163workbox.routing.registerRoute(navigationRoute) 164 165// this route is used when performing a non-navigation request (e.g. fetch) 166workbox.routing.registerRoute(/\/.gatsby-plugin-offline:.+/, handleAPIRequest)
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.