-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathservice-worker.min.js.map
1 lines (1 loc) · 11.8 KB
/
service-worker.min.js.map
1
{"version":3,"sources":["../src/js/service-worker.js"],"names":[],"mappings":"+pCAAM,CAAA,aAAa,CAAG,C,CAEhB,gBAAgB,CAAG,CACvB,oBADuB,CAEvB,kBAFuB,CAGvB,mBAHuB,CAIvB,mBAJuB,C,CAOnB,mBAAmB,CAAG,CAC1B,oBAD0B,CAE1B,kBAF0B,CAG1B,mBAH0B,CAI1B,mBAJ0B,CAK1B,WAL0B,C,CAQtB,qBAAqB,CAAG,CAC5B,oBAD4B,CAE5B,kBAF4B,CAG5B,mBAH4B,CAI5B,mBAJ4B,CAK5B,WAL4B,C,CAQxB,YAAY,CAAG,W,CACf,cAAc,CAAG,W,CAEjB,cAAc,CAAG,CACrB,MAAM,YADe,CAErB,OAAO,aAFc,CAGrB,OAAO,aAHc,CAIrB,QAAQ,SAJa,C,CAQjB,OAAO,CAAG,CACd,IAAK,IADS,CAEd,IAAI,CAAE,IAFQ,CAGd,IAAI,CAAE,KAHQ,CAId,EAAE,CAAE,KAJU,CAKd,GAAG,CAAE,KALS,C,CAQV,eAAe,CAAG,CACtB,SAAC,CAAD,CAAS,CACP,MAAO,CAAC,CAAG,CAAC,UAAJ,CAAe,kBAAf,CACT,CAHqB,C,CAMlB,iBAAiB,CAAG,CAAC,KAAD,C,CAO1B,QAAS,CAAA,aAAT,CAAuB,CAAvB,CAA4B,CAC1B,SAAgC,CAAzB,CAAA,eAAe,CAAC,MAAvB,GACI,CAAC,eAAe,CAAC,MAAhB,CAAuB,SAAC,CAAD,CAAU,SACZ,UAAhB,QAAO,CAAA,CADqB,GAEvB,CAAC,CAAI,CAAC,CAAD,CAIf,CANA,EAME,MAER,CAOD,QAAS,CAAA,gBAAT,CAA0B,CAA1B,CAA+B,CAC7B,GAAM,CAAA,CAAS,CAAG,CAAG,CAAC,KAAJ,CAAU,GAAV,EAAe,OAAf,GAAyB,CAA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,CAAc,2BAAd,CAA2C,CAA3C,CACA,CAAM,CACP,CApFI,CAqFR,CAtFD,CADF,CAyFD,CA1FD,C","file":"service-worker.min.js","sourcesContent":["const CACHE_VERSION = 1;\n\nconst BASE_CACHE_FILES = [\n '/css/style.min.css',\n '/js/theme.min.js',\n '/site.webmanifest',\n '/images/fixit.svg'\n];\n\nconst OFFLINE_CACHE_FILES = [\n '/css/style.min.css',\n '/js/theme.min.js',\n '/site.webmanifest',\n '/images/fixit.svg',\n '/offline/'\n];\n\nconst NOT_FOUND_CACHE_FILES = [\n '/css/style.min.css',\n '/js/theme.min.js',\n '/site.webmanifest',\n '/images/fixit.svg',\n '/404.html'\n];\n\nconst OFFLINE_PAGE = '/offline/';\nconst NOT_FOUND_PAGE = '/404.html';\n\nconst CACHE_VERSIONS = {\n assets: 'assets-v' + CACHE_VERSION,\n content: 'content-v' + CACHE_VERSION,\n offline: 'offline-v' + CACHE_VERSION,\n notFound: '404-v' + CACHE_VERSION\n};\n\n// Define MAX_TTL's in SECONDS for specific file extensions\nconst MAX_TTL = {\n '/': 3600,\n html: 3600,\n json: 86400,\n js: 86400,\n css: 86400\n};\n\nconst CACHE_BLACKLIST = [\n (str) => {\n return !str.startsWith('http://localhost');\n }\n];\n\nconst SUPPORTED_METHODS = ['GET'];\n\n/**\n * isBlackListed\n * @param {string} url\n * @returns {boolean}\n */\nfunction isBlacklisted(url) {\n return CACHE_BLACKLIST.length > 0\n ? !CACHE_BLACKLIST.filter((rule) => {\n if (typeof rule === 'function') {\n return !rule(url);\n } else {\n return false;\n }\n }).length\n : false;\n}\n\n/**\n * getFileExtension\n * @param {string} url\n * @returns {string}\n */\nfunction getFileExtension(url) {\n const extension = url.split('.').reverse()[0].split('?')[0];\n return extension.endsWith('/') ? '/' : extension;\n}\n\n/**\n * getTTL\n * @param {string} url\n */\nfunction getTTL(url) {\n if (typeof url === 'string') {\n const extension = getFileExtension(url);\n if (typeof MAX_TTL[extension] === 'number') {\n return MAX_TTL[extension];\n } else {\n return null;\n }\n } else {\n return null;\n }\n}\n\n/**\n * installServiceWorker\n * @returns {Promise}\n */\nfunction installServiceWorker() {\n return Promise.all([\n caches.open(CACHE_VERSIONS.assets).then((cache) => {\n return cache.addAll(BASE_CACHE_FILES);\n }),\n caches.open(CACHE_VERSIONS.offline).then((cache) => {\n return cache.addAll(OFFLINE_CACHE_FILES);\n }),\n caches.open(CACHE_VERSIONS.notFound).then((cache) => {\n return cache.addAll(NOT_FOUND_CACHE_FILES);\n })\n ]).then(() => {\n return self.skipWaiting();\n });\n}\n\n/**\n * cleanupLegacyCache\n * @returns {Promise}\n */\nfunction cleanupLegacyCache() {\n const currentCaches = Object.keys(CACHE_VERSIONS).map((key) => {\n return CACHE_VERSIONS[key];\n });\n\n return new Promise((resolve, reject) => {\n caches\n .keys()\n .then((keys) => {\n return keys.filter((key) => {\n return !~currentCaches.indexOf(key);\n });\n })\n .then((legacy) => {\n if (legacy.length) {\n Promise.all(\n legacy.map((legacyKey) => {\n return caches.delete(legacyKey);\n })\n )\n .then(() => {\n resolve();\n })\n .catch((err) => {\n reject(err);\n });\n } else {\n resolve();\n }\n })\n .catch((err) => {\n reject(err);\n });\n });\n}\n\nself.addEventListener('install', (event) => {\n event.waitUntil(Promise.all([installServiceWorker(), self.skipWaiting()]));\n});\n\n// The activate handler takes care of cleaning up old caches.\nself.addEventListener('activate', (event) => {\n event.waitUntil(\n Promise.all([\n cleanupLegacyCache(),\n self.clients.claim(),\n self.skipWaiting()\n ]).catch((err) => {\n console.log(err);\n self.skipWaiting();\n })\n );\n});\n\nself.addEventListener('fetch', (event) => {\n event.respondWith(\n caches.open(CACHE_VERSIONS.content).then((cache) => {\n return cache\n .match(event.request)\n .then((response) => {\n if (response) {\n const headers = response.headers.entries();\n let date = null;\n\n for (const pair of headers) {\n if (pair[0] === 'date') {\n date = new Date(pair[1]);\n }\n }\n if (date) {\n const age = parseInt(\n (new Date().getTime() - date.getTime()) / 1000\n );\n const ttl = getTTL(event.request.url);\n\n if (ttl && age > ttl) {\n return new Promise((resolve) => {\n return fetch(event.request.clone())\n .then((updatedResponse) => {\n if (updatedResponse) {\n cache.put(event.request, updatedResponse.clone());\n resolve(updatedResponse);\n } else {\n resolve(response);\n }\n })\n .catch(() => {\n resolve(response);\n });\n }).catch((err) => {\n console.log(err);\n return response;\n });\n } else {\n return response;\n }\n } else {\n return response;\n }\n } else {\n return null;\n }\n })\n .then((response) => {\n if (response) {\n return response;\n } else {\n return fetch(event.request.clone())\n .then((response) => {\n if (response.status < 400) {\n if (\n ~SUPPORTED_METHODS.indexOf(event.request.method) &&\n !isBlacklisted(event.request.url) &&\n event.request.url.slice(0, 4) === 'http'\n ) {\n cache.put(event.request, response.clone());\n }\n return response;\n } else {\n return caches.open(CACHE_VERSIONS.notFound).then((cache) => {\n return cache.match(NOT_FOUND_PAGE);\n });\n }\n })\n .then((response) => {\n if (response) {\n return response;\n }\n })\n .catch(() => {\n return caches\n .open(CACHE_VERSIONS.offline)\n .then((offlineCache) => {\n return offlineCache.match(OFFLINE_PAGE);\n });\n });\n }\n })\n .catch((error) => {\n console.error(' Error in fetch handler:', error);\n throw error;\n });\n })\n );\n});\n"]}