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": "icons/icon-144x144.png", 31 "revision": "402e13da27f00d55a547c98fa2f5b5cb" 32 }, 33 { 34 "url": "icons/icon-192x192.png", 35 "revision": "3650815627fb6c257973336cf3241143" 36 }, 37 { 38 "url": "icons/icon-256x256.png", 39 "revision": "a628436808cfabc0f13e44f880c4e30d" 40 }, 41 { 42 "url": "icons/icon-384x384.png", 43 "revision": "94e3fd94fd7a8135d55c7923fbdc01e0" 44 }, 45 { 46 "url": "icons/icon-48x48.png", 47 "revision": "12bded481bf2a60eab614f92cc9147b0" 48 }, 49 { 50 "url": "icons/icon-512x512.png", 51 "revision": "261b3f4c7f3b07ea376ed4e2194de35d" 52 }, 53 { 54 "url": "icons/icon-72x72.png", 55 "revision": "6370834efd526f979c3f6a2e66c612a2" 56 }, 57 { 58 "url": "icons/icon-96x96.png", 59 "revision": "84828724fb18dd5b3a10745436a5d6c8" 60 }, 61 { 62 "url": "obr/icon-popover.svg", 63 "revision": "91ce3ffe0a7f380fd991cbe9d6822f29" 64 }, 65 { 66 "url": "framework-e1310d47c6b663329633.js" 67 }, 68 { 69 "url": "styles.cf242e5cf494ded62607.css" 70 }, 71 { 72 "url": "styles-57c3f1459b4a5e1efec6.js" 73 }, 74 { 75 "url": "5c0b189e-65b1f4e0625c82dc03f7.js" 76 }, 77 { 78 "url": "app-65fccdea4936c67812d6.js" 79 }, 80 { 81 "url": "offline-plugin-app-shell-fallback/index.html", 82 "revision": "a1f3511e721412b344e1478cc1c9b93f" 83 }, 84 { 85 "url": "webpack-runtime-4911c54dd6ddc3285597.js" 86 }, 87 { 88 "url": "manifest.webmanifest", 89 "revision": "9a9349bf22147d93ae9d1407d8dde40a" 90 } 91].concat(self.__precacheManifest || []); 92workbox.precaching.precacheAndRoute(self.__precacheManifest, {}); 93 94workbox.routing.registerRoute(/\/doc\/pagefind\//, new workbox.strategies.NetworkFirst(), 'GET'); 95workbox.routing.registerRoute(/\/iframe\//, new workbox.strategies.NetworkOnly(), 'GET'); 96workbox.routing.registerRoute(/^https?:\/\/api\.longstoryshort\.app\//, new workbox.strategies.NetworkOnly(), 'GET'); 97workbox.routing.registerRoute(/(\.js$|static\/)/, new workbox.strategies.CacheFirst(), 'GET'); 98workbox.routing.registerRoute(/\.css$/, new workbox.strategies.StaleWhileRevalidate(), 'GET'); 99workbox.routing.registerRoute(/^https?:.*\/page-data\/.*\.json/, new workbox.strategies.NetworkFirst(), 'GET'); 100workbox.routing.registerRoute(/^https?:.*\.(png|jpg|jpeg|webp|svg|gif|tiff|js|woff|woff2|json|css)$/, new workbox.strategies.StaleWhileRevalidate(), 'GET'); 101workbox.routing.registerRoute(/^https?:\/\/fonts\.googleapis\.com\/css/, new workbox.strategies.StaleWhileRevalidate(), 'GET'); 102workbox.routing.registerRoute(/\/adventures\/$/, new workbox.strategies.NetworkOnly(), 'GET'); 103workbox.routing.registerRoute(/\/$/, new workbox.strategies.StaleWhileRevalidate(), 'GET'); 104 105/* global importScripts, workbox, idbKeyval */ 106importScripts(`idb-keyval-3.2.0-iife.min.js`) 107 108const { NavigationRoute } = workbox.routing 109 110let lastNavigationRequest = null 111let offlineShellEnabled = true 112 113// prefer standard object syntax to support more browsers 114const MessageAPI = { 115 setPathResources: (event, { path, resources }) => { 116 event.waitUntil(idbKeyval.set(`resources:${path}`, resources)) 117 }, 118 119 clearPathResources: event => { 120 event.waitUntil(idbKeyval.clear()) 121 122 // We detected compilation hash mismatch 123 // we should clear runtime cache as data 124 // files might be out of sync and we should 125 // do fresh fetches for them 126 event.waitUntil( 127 caches.keys().then(function (keyList) { 128 return Promise.all( 129 keyList.map(function (key) { 130 if (key && key.includes(`runtime`)) { 131 return caches.delete(key) 132 } 133 134 return Promise.resolve() 135 }) 136 ) 137 }) 138 ) 139 }, 140 141 enableOfflineShell: () => { 142 offlineShellEnabled = true 143 }, 144 145 disableOfflineShell: () => { 146 offlineShellEnabled = false 147 }, 148} 149 150self.addEventListener(`message`, event => { 151 const { gatsbyApi: api } = event.data 152 if (api) MessageAPI[api](event, event.data) 153}) 154 155function handleAPIRequest({ event }) { 156 const { pathname } = new URL(event.request.url) 157
158 const params = pathname.match(/:(.+)/)[1] 159 const data = {} 160 161 if (params.includes(`=`)) { 162 params.split(`&`).forEach(param => { 163 const [key, val] = param.split(`=`) 164 data[key] = val 165 }) 166 } else { 167 data.api = params 168 } 169 170 if (MessageAPI[data.api] !== undefined) { 171 MessageAPI[data.api]() 172 } 173 174 if (!data.redirect) { 175 return new Response() 176 } 177 178 return new Response(null, { 179 status: 302, 180 headers: { 181 Location: lastNavigationRequest, 182 }, 183 }) 184} 185 186const navigationRoute = new NavigationRoute(async ({ event }) => { 187 // handle API requests separately to normal navigation requests, so do this 188 // check first 189 if (event.request.url.match(/\/.gatsby-plugin-offline:.+/)) { 190 return handleAPIRequest({ event }) 191 } 192 193 if (!offlineShellEnabled) { 194 return await fetch(event.request) 195 } 196 197 lastNavigationRequest = event.request.url 198 199 let { pathname } = new URL(event.request.url) 200 pathname = pathname.replace(new RegExp(`^`), ``) 201 202 // Check for resources + the app bundle 203 // The latter may not exist if the SW is updating to a new version 204 const resources = await idbKeyval.get(`resources:${pathname}`) 205 if (!resources || !(await caches.match(`/app-65fccdea4936c67812d6.js`))) { 206 return await fetch(event.request) 207 } 208 209 for (const resource of resources) { 210 // As soon as we detect a failed resource, fetch the entire page from 211 // network - that way we won't risk being in an inconsistent state with 212 // some parts of the page failing. 213 if (!(await caches.match(resource))) { 214 return await fetch(event.request) 215 } 216 } 217 218 const offlineShell = `/offline-plugin-app-shell-fallback/index.html` 219 const offlineShellWithKey = workbox.precaching.getCacheKeyForURL(offlineShell) 220 return await caches.match(offlineShellWithKey) 221}) 222 223workbox.routing.registerRoute(navigationRoute) 224 225// this route is used when performing a non-navigation request (e.g. fetch) 226workbox.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.