PageSourceSearch

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

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