attain
Advanced tools
Comparing version 0.0.184 to 0.0.185
@@ -1,8 +0,2 @@ | ||
// This is the "Offline page" service worker | ||
const CACHE = "pwabuilder-page" | ||
// TODO: replace the following with the correct offline fallback page i.e.: const offlineFallbackPage = "offline.html"; | ||
const offlineFallbackPage = "offline.html" | ||
// Install stage sets up the offline page in the cache and opens a new cache | ||
@@ -12,47 +6,18 @@ self.addEventListener("install", function (event) { | ||
event.waitUntil( | ||
caches.open(CACHE).then(function (cache) { | ||
console.log("[PWA Builder] Cached offline page during install") | ||
// event.waitUntil( | ||
// caches.open(CACHE).then(function (cache) { | ||
// console.log("[PWA Builder] Cached offline page during install") | ||
if (offlineFallbackPage === "offline.html") { | ||
return cache.add(new Response("<h1>Offline</h1>")) | ||
} | ||
// if (offlineFallbackPage === "offline.html") { | ||
// return cache.add(new Response("<h1>Offline</h1>")) | ||
// } | ||
return cache.add(offlineFallbackPage) | ||
}) | ||
) | ||
}) | ||
// return cache.add(offlineFallbackPage) | ||
// }) | ||
// ) | ||
// If any fetch fails, it will show the offline page. | ||
self.addEventListener("fetch", function (event) { | ||
if (event.request.method !== "GET") return | ||
event.respondWith( | ||
fetch(event.request).catch(function (error) { | ||
// The following validates that the request was for a navigation to a new document | ||
if ( | ||
event.request.destination !== "document" || | ||
event.request.mode !== "navigate" | ||
) { | ||
return | ||
} | ||
console.error("[PWA Builder] Network request Failed. Serving offline page " + error) | ||
return caches.open(CACHE).then(function (cache) { | ||
return cache.match(offlineFallbackPage) | ||
}) | ||
}) | ||
) | ||
return Promise.resolve() | ||
}) | ||
// This is an event that can be fired from your page to tell the SW to update the offline page | ||
self.addEventListener("refreshOffline", function () { | ||
const offlinePageRequest = new Request(offlineFallbackPage) | ||
return fetch(offlineFallbackPage).then(function (response) { | ||
return caches.open(CACHE).then(function (cache) { | ||
console.log("[PWA Builder] Offline page updated from refreshOffline event: " + response.url) | ||
return cache.put(offlinePageRequest, response) | ||
}) | ||
}) | ||
}) | ||
// self.addEventListener("fetch", function (event) { | ||
// }) |
{ | ||
"name": "attain", | ||
"version": "0.0.184", | ||
"version": "0.0.185", | ||
"description": "A library for modelling and accessing data.", | ||
@@ -5,0 +5,0 @@ "main": "dist/attain.min.js", |
Network access
Supply chain riskThis module accesses the network.
Found 1 instance in 1 package
0
1635242
10702