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": "runtime-9ede63e063d992016cec.js" 31 }, 32 { 33 "url": "styles.bd660ed8d7349443894b.css" 34 }, 35 { 36 "url": "vendors-cdd60c62-f69b83039436b5ab1162.js" 37 }, 38 { 39 "url": "vendors-d2eb5610-5c2ef395c5d81d5fd939.js" 40 }, 41 { 42 "url": "vendors-15f93fc0-c5812ecd0a726599e35a.js" 43 }, 44 { 45 "url": "vendors-2b4841d6-c562fe3e63a2ff071210.js" 46 }, 47 { 48 "url": "vendors-32266432-940f820ce8926775aabe.js" 49 }, 50 { 51 "url": "vendors-a0a7bb72-eb8f2ec5a1893c289312.js" 52 }, 53 { 54 "url": "vendors-b90ea302-543a6074de84da9e0e5e.js" 55 }, 56 { 57 "url": "vendors-17e8d8c2-178d00b4bdd72aa68893.js" 58 }, 59 { 60 "url": "vendors-cb2d071c-877cdc479928f6682636.js" 61 }, 62 { 63 "url": "vendors-3113a0cb-fee49cf9403edaf93de3.js" 64 }, 65 { 66 "url": "vendors-0e5d714b-6741211964ee0bcd2a91.js" 67 }, 68 { 69 "url": "vendors-27545368-8279f1674b6ad87e8dab.js" 70 }, 71 { 72 "url": "vendors-a5ce148e-602a0322ebb70831663c.js" 73 }, 74 { 75 "url": "app-fe8971fe-4b8070e7d1fcfb2db21c.js" 76 }, 77 { 78 "url": "app-67e89599-d174c16820a0be7eb527.js" 79 }, 80 { 81 "url": "app-296f7ffc-10bff64b44ec800e66c1.js" 82 }, 83 { 84 "url": "offline-plugin-app-shell-fallback/index.html", 85 "revision": "1c2079907740c6d58ce7f205f2d3728a" 86 }, 87 { 88 "url": "manifest.webmanifest", 89 "revision": "f8b8f81760726aaf36a7429ae8fad4f0" 90 } 91].concat(self.__precacheManifest || []); 92workbox.precaching.precacheAndRoute(self.__precacheManifest, {}); 93 94workbox.routing.registerRoute(/(\.js$|\.css$|static\/)/, new workbox.strategies.CacheFirst(), 'GET'); 95workbox.routing.registerRoute(/^https?:.*\/page-data\/.*\.json/, new workbox.strategies.StaleWhileRevalidate(), 'GET'); 96workbox.routing.registerRoute(/^https?:.*\.(png|jpg|jpeg|webp|avif|svg|gif|tiff|js|woff|woff2|json|css)$/, new workbox.strategies.StaleWhileRevalidate(), 'GET'); 97workbox.routing.registerRoute(/^https?:\/\/fonts\.googleapis\.com\/css/, new workbox.strategies.StaleWhileRevalidate(), 'GET'); 98 99/* global importScripts, workbox, idbKeyval */ 100importScripts(`idb-keyval-3.2.0-iife.min.js`) 101 102const { NavigationRoute } = workbox.routing 103 104let lastNavigationRequest = null 105let offlineShellEnabled = true 106 107// prefer standard object syntax to support more browsers 108const MessageAPI = { 109 setPathResources: (event, { path, resources }) => { 110 event.waitUntil(idbKeyval.set(`resources:${path}`, resources)) 111 }, 112 113 clearPathResources: event => { 114 event.waitUntil(idbKeyval.clear()) 115 116 // We detected compilation hash mismatch 117 // we should clear runtime cache as data 118 // files might be out of sync and we should 119 // do fresh fetches for them 120 event.waitUntil( 121 caches.keys().then(function (keyList) { 122 return Promise.all( 123 keyList.map(function (key) { 124 if (key && key.includes(`runtime`)) { 125 return caches.delete(key) 126 } 127 128 return Promise.resolve() 129 }) 130 ) 131 }) 132 ) 133 }, 134 135 enableOfflineShell: () => { 136 offlineShellEnabled = true 137 }, 138 139 disableOfflineShell: () => { 140 offlineShellEnabled = false 141 }, 142} 143 144self.addEventListener(`message`, event => { 145 const { gatsbyApi: api } = event.data 146 if (api) MessageAPI[api](event, event.data) 147}) 148 149function handleAPIRequest({ event }) { 150 const { pathname } = new URL(event.request.url) 151
152 const params = pathname.match(/:(.+)/)[1] 153 const data = {} 154 155 if (params.includes(`=`)) { 156 params.split(`&`).forEach(param => { 157 const [key, val] = param.split(`=`) 158 data[key] = val 159 }) 160 } else { 161 data.api = params 162 } 163 164 if (MessageAPI[data.api] !== undefined) { 165 MessageAPI[data.api]() 166 } 167 168 if (!data.redirect) { 169 return new Response() 170 } 171 172 return new Response(null, { 173 status: 302, 174 headers: { 175 Location: lastNavigationRequest, 176 }, 177 }) 178} 179 180const navigationRoute = new NavigationRoute(async ({ event }) => { 181 // handle API requests separately to normal navigation requests, so do this 182 // check first 183 if (event.request.url.match(/\/.gatsby-plugin-offline:.+/)) { 184 return handleAPIRequest({ event }) 185 } 186 187 if (!offlineShellEnabled) { 188 return await fetch(event.request) 189 } 190 191 lastNavigationRequest = event.request.url 192 193 let { pathname } = new URL(event.request.url) 194 pathname = pathname.replace(new RegExp(`^`), ``) 195 196 // Check for resources + the app bundle 197 // The latter may not exist if the SW is updating to a new version 198 const resources = await idbKeyval.get(`resources:${pathname}`) 199 if (!resources || !(await caches.match(`/app-fe8971fe-4b8070e7d1fcfb2db21c.js`))) { 200 return await fetch(event.request) 201 } 202 203 for (const resource of resources) { 204 // As soon as we detect a failed resource, fetch the entire page from 205 // network - that way we won't risk being in an inconsistent state with 206 // some parts of the page failing. 207 if (!(await caches.match(resource))) { 208 return await fetch(event.request) 209 } 210 } 211 212 const offlineShell = `/offline-plugin-app-shell-fallback/index.html` 213 const offlineShellWithKey = workbox.precaching.getCacheKeyForURL(offlineShell) 214 return await caches.match(offlineShellWithKey) 215}) 216 217workbox.routing.registerRoute(navigationRoute) 218 219// this route is used when performing a non-navigation request (e.g. fetch) 220workbox.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.