PageSourceSearch

https://meltonpriorinstitut.org/sw.js

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