PageSourceSearch

https://lynnzheng.netlify.app/sw.js

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