PageSourceSearch

https://www.a11ywithlindsey.com/sw.js

js a11ywithlindsey.com collected 2026-10-02 04:09:21 UTC 4,856 bytes, 165 lines download raw bytes

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-04ee07f01a3316bb5a37.js"
31  },
32  {
33    "url": "styles.bf63ffca541d1ab536ba.css"
34  },
35  {
36    "url": "styles-407fe62976dc5310c43e.js"
37  },
38  {
39    "url": "framework-25679e2f2e739b4a55ca.js"
40  },
41  {
42    "url": "app-c9c16c8991030db0db65.js"
43  },
44  {
45    "url": "offline-plugin-app-shell-fallback/index.html",
46    "revision": "cb1868058de3cf4aea4f9409c8ac4049"
47  },
48  {
49    "url": "component---cache-caches-gatsby-plugin-offline-app-shell-js-47c8d8b7529f7a984452.js"
50  },
51  {
52    "url": "polyfill-d22790a7c7927829ee5c.js"
53  }
54].concat(self.__precacheManifest || []);
55workbox.precaching.precacheAndRoute(self.__precacheManifest, {});
56
57workbox.routing.registerRoute(/(\.js$|\.css$|static\/)/, new workbox.strategies.CacheFirst(), 'GET');
58workbox.routing.registerRoute(/^https?:.*\/page-data\/.*\.json/, new workbox.strategies.StaleWhileRevalidate(), 'GET');
59workbox.routing.registerRoute(/^https?:.*\.(png|jpg|jpeg|webp|avif|svg|gif|tiff|js|woff|woff2|json|css)$/, new workbox.strategies.StaleWhileRevalidate(), 'GET');
60workbox.routing.registerRoute(/^https?:\/\/fonts\.googleapis\.com\/css/, new workbox.strategies.StaleWhileRevalidate(), 'GET');
61
62/* global importScripts, workbox, idbKeyval */
63importScripts(`idb-keyval-3.2.0-iife.min.js`)
64
65const { NavigationRoute } = workbox.routing
66
67let lastNavigationRequest = null
68let offlineShellEnabled = true
69
70// prefer standard object syntax to support more browsers
71const MessageAPI = {
72  setPathResources: (event, { path, resources }) => {
73    event.waitUntil(idbKeyval.set(`resources:${path}`, resources))
74  },
75
76  clearPathResources: event => {
77    event.waitUntil(idbKeyval.clear())
78  },
79
80  enableOfflineShell: () => {
81    offlineShellEnabled = true
82  },
83
84  disableOfflineShell: () => {
85    offlineShellEnabled = false
86  },
87}
88
89self.addEventListener(`message`, event => {
90  const { gatsbyApi: api } = event.data
91  if (api) MessageAPI[api](event, event.data)
92})
93
94function handleAPIRequest({ event }) {
95  const { pathname } = new URL(event.request.url)
96
97  const params = pathname.match(/:(.+)/)[1]
98  const data = {}
99
100  if (params.includes(`=`)) {
101    params.split(`&`).forEach(param => {
102      const [key, val] = param.split(`=`)
103      data[key] = val
104    })
105  } else {
106    data.api = params
107  }
108
109  if (MessageAPI[data.api] !== undefined) {
110    MessageAPI[data.api]()
111  }
112
113  if (!data.redirect) {
114    return new Response()
115  }
116
117  return new Response(null, {
118    status: 302,
119    headers: {
120      Location: lastNavigationRequest,
121    },
122  })
123}
124
125const navigationRoute = new NavigationRoute(async ({ event }) => {
126  // handle API requests separately to normal navigation requests, so do this
127  // check first
128  if (event.request.url.match(/\/.gatsby-plugin-offline:.+/)) {
129    return handleAPIRequest({ event })
130  }
131
132  if (!offlineShellEnabled) {
133    return await fetch(event.request)
134  }
135
136  lastNavigationRequest = event.request.url
137
138  let { pathname } = new URL(event.request.url)
139  pathname = pathname.replace(new RegExp(`^`), ``)
140
141  // Check for resources + the app bundle
142  // The latter may not exist if the SW is updating to a new version
143  const resources = await idbKeyval.get(`resources:${pathname}`)
144  if (!resources || !(await caches.match(`/app-c9c16c8991030db0db65.js`))) {
145    return await fetch(event.request)
146  }
147
148  for (const resource of resources) {
149    // As soon as we detect a failed resource, fetch the entire page from
150    // network - that way we won't risk being in an inconsistent state with
151    // some parts of the page failing.
152    if (!(await caches.match(resource))) {
153      return await fetch(event.request)
154    }
155  }
156
157  const offlineShell = `/offline-plugin-app-shell-fallback/index.html`
158  const offlineShellWithKey = workbox.precaching.getCacheKeyForURL(offlineShell)
159  return await caches.match(offlineShellWithKey)
160})
161
162workbox.routing.registerRoute(navigationRoute)
163
164// this route is used when performing a non-navigation request (e.g. fetch)
165workbox.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.