123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268 |
- /**
- * Copyright 2016 Google Inc. All rights reserved.
- *
- * Licensed under the Apache License, Version 2.0 (the "License");
- * you may not use this file except in compliance with the License.
- * You may obtain a copy of the License at
- *
- * http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing, software
- * distributed under the License is distributed on an "AS IS" BASIS,
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
- * See the License for the specific language governing permissions and
- * limitations under the License.
- */
- // DO NOT EDIT THIS GENERATED OUTPUT DIRECTLY!
- // This file should be overwritten as part of your build process.
- // If you need to extend the behavior of the generated service worker, the best approach is to write
- // additional code and include it using the importScripts option:
- // https://github.com/GoogleChrome/sw-precache#importscripts-arraystring
- //
- // Alternatively, it's possible to make changes to the underlying template file and then use that as the
- // new base for generating output, via the templateFilePath option:
- // https://github.com/GoogleChrome/sw-precache#templatefilepath-string
- //
- // If you go that route, make sure that whenever you update your sw-precache dependency, you reconcile any
- // changes made to this original template file with your modified copy.
- // This generated service worker JavaScript will precache your site's resources.
- // The code needs to be saved in a .js file at the top-level of your site, and registered
- // from your pages in order to be used. See
- // https://github.com/googlechrome/sw-precache/blob/master/demo/app/js/service-worker-registration.js
- // for an example of how you can register this script and handle various service worker events.
- /* eslint-env worker, serviceworker */
- /* eslint-disable indent, no-unused-vars, no-multiple-empty-lines, max-nested-callbacks, space-before-function-paren, quotes, comma-spacing */
- 'use strict';
- var precacheConfig = [["404.html","c806655c01bce5bfeed2af7b3ab4e8f8"],["apple-icon-precomposed.png","478755b1c3e0d2c8aea975033cff9ac8"],["apple-icon.png","478755b1c3e0d2c8aea975033cff9ac8"],["apple-touch-icon-114x114.png","95804b2192b0cea406b54cb31345c47d"],["apple-touch-icon-120x120.png","b5da0625c9e876bdf9768875f7dd9cca"],["apple-touch-icon-144x144.png","976151c9ecd72311dc6024917292209d"],["apple-touch-icon-152x152.png","8bd6a2e592c1c8463b5205ba8436227e"],["apple-touch-icon-180x180.png","56a93f4271dea903196794095e9f9ccc"],["apple-touch-icon-57x57.png","977183ab3bfb98da8d79e025f1cb4946"],["apple-touch-icon-60x60.png","55e9e05103a9b472a52f4c572a73b2b2"],["apple-touch-icon-72x72.png","1ef87a2887baab846f2501beb27445ee"],["apple-touch-icon-76x76.png","769826cd7526df4db7f4ba1a820158bd"],["browserconfig.xml","67c3113b1574fecc6015d56d774e1d38"],["categories/index.xml","1c183b48cab635f689386c900b9dc4aa"],["css/fonts/miriamlibre-bold.woff","96496f6f06535d25b3bcba876917ca35"],["css/fonts/miriamlibre-bold.woff2","668defa44d9a74dd709ce0c826a5eb11"],["css/images/arrow_effect.svg","1434d178461f70c16b77acb4bdbc51e3"],["css/images/icon-tick.svg","35d4d4728ea80d254508b2bca4109d70"],["css/images/stripe.svg","fa3f32a026b6a1bb04ee98d963432e15"],["css/prism.css","004029c8c70ed2bbaa5d9debcf14f8c7"],["css/styles.css","a49e31bec9b84088a94f09cee540400b"],["images/android-icon-144x144.png","43e1f47f182b13d0dee15f510213e928"],["images/android-icon-192x192.png","4c07782e52e0ab714074e6d3d69dc3ec"],["images/android-icon-36x36.png","3b2cd8c925a66bf84c89b68bb30e5f62"],["images/android-icon-48x48.png","45dc386eea1d8a46216a8b6de9b156c6"],["images/android-icon-512x512.png","42d6b28cc7eb41810a5392c81368340a"],["images/android-icon-72x72.png","b04c64637efed2b04fa900ddfcbfe75d"],["images/android-icon-96x96.png","bd9c126a4d6baf7ce442122ce0e89e11"],["images/bad_design_system.png","9c0e87a34e7d842b0e2831dc947249aa"],["images/browser-chrome-android.svg","3100b2a9c5f0e34982c717fc2aa46d73"],["images/browser-chrome.svg","fa39b4be6727525330e928f582fbe80a"],["images/browser-edge.svg","9e8265ab8f6a701587a4271dd3aa6a73"],["images/browser-firefox-android.svg","452df7b9e83c70a07e8e03b4e8dab9c4"],["images/browser-firefox.svg","d3093eda664be3d0cc6d791e1386420f"],["images/browser-ie.svg","13e192cf2b3fe17e7049a49b7d085caa"],["images/browser-opera.svg","95d65630c9f7deef6a3098af8f5baf9f"],["images/browser-safari-ios.svg","f729e629ec998ec40d313495d7257741"],["images/browser-safari.svg","523ee9491f5a937b8975f4d23aa77f62"],["images/favicon-16x16.png","7a99c20d6c00babddd26d03607b8721d"],["images/favicon-32x32.png","129881474a1bf130027bff7a1e89febd"],["images/favicon-96x96.png","bd9c126a4d6baf7ce442122ce0e89e11"],["images/favicon.ico","81c46feedbfcc6c6dc9495e4fd5adfad"],["images/icon-info.svg","53a6c555ce41f818556c71ab0dfc533b"],["images/icon-tag.svg","f067bbbc072941b2a0335679300bfc6c"],["images/icon-warning.svg","2a4322abbee9aed694fadb50e98a1f61"],["images/logo.svg","50293a256b796b9a737f1969d511a98e"],["images/ms-icon-144x144.png","43e1f47f182b13d0dee15f510213e928"],["images/ms-icon-150x150.png","e73370837ab9060772a18d62aaacd0f0"],["images/ms-icon-310x310.png","8a7143516b929702e3309bb537a99c5c"],["images/ms-icon-70x70.png","d7c6e7368733d53b5f979546d5aa4fe9"],["images/open_in_desktop.png","e899d6679b011aa7b0e783683d90d99b"],["images/samsung_homescreen.png","5ef40e64a18f966ce5c9084a024256db"],["images/serve_from_docs.png","15ae9eac3737a21593ebe00a9312bf9e"],["index.html","5a377d6e76e8b150bc20a07a2189a952"],["index.xml","57a3c0aa0932b3634b447ccd63d44254"],["js/dom-scripts.js","1d87ba44d730c37fae139d4ac47b118a"],["js/prism.js","0c1fb8d3a69ee7c91dbf0f361ded7763"],["js/service-worker-registration.js","d60f01dc1393cbaaf4f7435339074d5e"],["manifest.json","47399fd703e572a010a718a351c37b03"],["patterns/coding/code-blocks/index.html","6ceeb716d2605c3d33084543f4cec303"],["patterns/coding/color-palettes/index.html","6a8360de358f7e2d09254c397f4492ea"],["patterns/coding/command-line/index.html","cf30637361fcb03b2a8ba464bde305e7"],["patterns/coding/demo-embedding/index.html","1baed582a84fcf40b9494b25e6b3cd83"],["patterns/coding/file-trees/index.html","871d6d20536c22af6c3a06e4ee50e675"],["patterns/coding/index.html","74c91e62615ad5cb9ee83daa563f3a29"],["patterns/coding/index.xml","9103e9b80e3ea47df0759c7646b4b174"],["patterns/coding/tested/index.html","dda1c0051a0ab0dec2e530564030bd78"],["patterns/coding/writing-inline-demos/index.html","ea9e32f0a131e17fccc5e474d5fae29a"],["patterns/index.html","8a4d0dfbc2a5c1afa73d3b26738b4152"],["patterns/index.xml","276f7358cc6c122ee8b38ec4f86f116f"],["patterns/installation/index.html","d397a92a589e89c8c5cf7dea1fb6b6ef"],["patterns/media/including-images/index.html","d891fa677440bb18b7bfed5297d1050f"],["patterns/media/including-videos/index.html","5c20cbdbd55fa293ac5085c16806071f"],["patterns/media/index.html","e10373908b44e6396eb46cf13bcbc7d3"],["patterns/media/index.xml","69e133cec08e19eeb33cb005e90590e3"],["patterns/printing/index.html","2b42a73814b0ee5eb062e2b8cab12eae"],["patterns/serving/index.html","a837a2763994983dd2d9efda1acec4b7"],["patterns/setup/index.html","f50c97b80eb12c112ccbdd110d57f73f"],["patterns/updating/index.html","ce8eedfb191fcf9e7261e7dff4580dfb"],["patterns/writing/expandable-sections/index.html","c723677c80e8beafc99d841aa8f2c9e0"],["patterns/writing/index.html","09383a39024738377de5f042adfb0ad1"],["patterns/writing/index.xml","53aea727e5ea1133e83cd6a859115e7e"],["patterns/writing/markdown-and-metadata/index.html","3918094b119a27a9eaa15c9d4dbae4e8"],["patterns/writing/notes-and-warnings/index.html","20bcd56ab9d15558641ebadd12039bcd"],["patterns/writing/project-structure/index.html","8027f7dc04a841c13ef4afc8a075a8b2"],["patterns/writing/references/index.html","ec7f4edd0bfb91fa5c9de04f179585a9"],["patterns/writing/snippets/index.html","eac468f5863e72c1c19bd1fbad795a4e"],["patterns/writing/tables-of-contents/index.html","de3d3d7d0c04e05dd9d07fe00829bd0a"],["print-version/index.html","70ee750b862d9f1f9d56f199289b6808"],["sitemap.xml","e3f27a45b9955c8ee5f7f72517c65417"],["tags/index.xml","7445f2e8ccc722d44e7533263233d2df"],["tags/markdown/index.html","d6ac475b301073b3d78d2e02639d4f4a"],["tags/markdown/index.xml","5387a8d0317e6b6641e0803ac2f5af3c"],["tags/metadata/index.html","30f2e591a7cede252c38d72e31614b38"],["tags/metadata/index.xml","098f151053be1a17654318a88433154b"]];
- var cacheName = 'sw-precache-v3-sw-precache-' + (self.registration ? self.registration.scope : '');
- var ignoreUrlParametersMatching = [/^utm_/];
- var addDirectoryIndex = function (originalUrl, index) {
- var url = new URL(originalUrl);
- if (url.pathname.slice(-1) === '/') {
- url.pathname += index;
- }
- return url.toString();
- };
- var cleanResponse = function (originalResponse) {
- // If this is not a redirected response, then we don't have to do anything.
- if (!originalResponse.redirected) {
- return Promise.resolve(originalResponse);
- }
- // Firefox 50 and below doesn't support the Response.body stream, so we may
- // need to read the entire body to memory as a Blob.
- var bodyPromise = 'body' in originalResponse ?
- Promise.resolve(originalResponse.body) :
- originalResponse.blob();
- return bodyPromise.then(function(body) {
- // new Response() is happy when passed either a stream or a Blob.
- return new Response(body, {
- headers: originalResponse.headers,
- status: originalResponse.status,
- statusText: originalResponse.statusText
- });
- });
- };
- var createCacheKey = function (originalUrl, paramName, paramValue,
- dontCacheBustUrlsMatching) {
- // Create a new URL object to avoid modifying originalUrl.
- var url = new URL(originalUrl);
- // If dontCacheBustUrlsMatching is not set, or if we don't have a match,
- // then add in the extra cache-busting URL parameter.
- if (!dontCacheBustUrlsMatching ||
- !(url.pathname.match(dontCacheBustUrlsMatching))) {
- url.search += (url.search ? '&' : '') +
- encodeURIComponent(paramName) + '=' + encodeURIComponent(paramValue);
- }
- return url.toString();
- };
- var isPathWhitelisted = function (whitelist, absoluteUrlString) {
- // If the whitelist is empty, then consider all URLs to be whitelisted.
- if (whitelist.length === 0) {
- return true;
- }
- // Otherwise compare each path regex to the path of the URL passed in.
- var path = (new URL(absoluteUrlString)).pathname;
- return whitelist.some(function(whitelistedPathRegex) {
- return path.match(whitelistedPathRegex);
- });
- };
- var stripIgnoredUrlParameters = function (originalUrl,
- ignoreUrlParametersMatching) {
- var url = new URL(originalUrl);
- // Remove the hash; see https://github.com/GoogleChrome/sw-precache/issues/290
- url.hash = '';
- url.search = url.search.slice(1) // Exclude initial '?'
- .split('&') // Split into an array of 'key=value' strings
- .map(function(kv) {
- return kv.split('='); // Split each 'key=value' string into a [key, value] array
- })
- .filter(function(kv) {
- return ignoreUrlParametersMatching.every(function(ignoredRegex) {
- return !ignoredRegex.test(kv[0]); // Return true iff the key doesn't match any of the regexes.
- });
- })
- .map(function(kv) {
- return kv.join('='); // Join each [key, value] array into a 'key=value' string
- })
- .join('&'); // Join the array of 'key=value' strings into a string with '&' in between each
- return url.toString();
- };
- var hashParamName = '_sw-precache';
- var urlsToCacheKeys = new Map(
- precacheConfig.map(function(item) {
- var relativeUrl = item[0];
- var hash = item[1];
- var absoluteUrl = new URL(relativeUrl, self.location);
- var cacheKey = createCacheKey(absoluteUrl, hashParamName, hash, false);
- return [absoluteUrl.toString(), cacheKey];
- })
- );
- function setOfCachedUrls(cache) {
- return cache.keys().then(function(requests) {
- return requests.map(function(request) {
- return request.url;
- });
- }).then(function(urls) {
- return new Set(urls);
- });
- }
- self.addEventListener('install', function(event) {
- event.waitUntil(
- caches.open(cacheName).then(function(cache) {
- return setOfCachedUrls(cache).then(function(cachedUrls) {
- return Promise.all(
- Array.from(urlsToCacheKeys.values()).map(function(cacheKey) {
- // If we don't have a key matching url in the cache already, add it.
- if (!cachedUrls.has(cacheKey)) {
- var request = new Request(cacheKey, {credentials: 'same-origin'});
- return fetch(request).then(function(response) {
- // Bail out of installation unless we get back a 200 OK for
- // every request.
- if (!response.ok) {
- throw new Error('Request for ' + cacheKey + ' returned a ' +
- 'response with status ' + response.status);
- }
- return cleanResponse(response).then(function(responseToCache) {
- return cache.put(cacheKey, responseToCache);
- });
- });
- }
- })
- );
- });
- }).then(function() {
-
- // Force the SW to transition from installing -> active state
- return self.skipWaiting();
-
- })
- );
- });
- self.addEventListener('activate', function(event) {
- var setOfExpectedUrls = new Set(urlsToCacheKeys.values());
- event.waitUntil(
- caches.open(cacheName).then(function(cache) {
- return cache.keys().then(function(existingRequests) {
- return Promise.all(
- existingRequests.map(function(existingRequest) {
- if (!setOfExpectedUrls.has(existingRequest.url)) {
- return cache.delete(existingRequest);
- }
- })
- );
- });
- }).then(function() {
-
- return self.clients.claim();
-
- })
- );
- });
- self.addEventListener('fetch', function(event) {
- if (event.request.method === 'GET') {
- // Should we call event.respondWith() inside this fetch event handler?
- // This needs to be determined synchronously, which will give other fetch
- // handlers a chance to handle the request if need be.
- var shouldRespond;
- // First, remove all the ignored parameters and hash fragment, and see if we
- // have that URL in our cache. If so, great! shouldRespond will be true.
- var url = stripIgnoredUrlParameters(event.request.url, ignoreUrlParametersMatching);
- shouldRespond = urlsToCacheKeys.has(url);
- // If shouldRespond is false, check again, this time with 'index.html'
- // (or whatever the directoryIndex option is set to) at the end.
- var directoryIndex = 'index.html';
- if (!shouldRespond && directoryIndex) {
- url = addDirectoryIndex(url, directoryIndex);
- shouldRespond = urlsToCacheKeys.has(url);
- }
- // If shouldRespond is still false, check to see if this is a navigation
- // request, and if so, whether the URL matches navigateFallbackWhitelist.
- var navigateFallback = '';
- if (!shouldRespond &&
- navigateFallback &&
- (event.request.mode === 'navigate') &&
- isPathWhitelisted([], event.request.url)) {
- url = new URL(navigateFallback, self.location).toString();
- shouldRespond = urlsToCacheKeys.has(url);
- }
- // If shouldRespond was set to true at any point, then call
- // event.respondWith(), using the appropriate cache key.
- if (shouldRespond) {
- event.respondWith(
- caches.open(cacheName).then(function(cache) {
- return cache.match(urlsToCacheKeys.get(url)).then(function(response) {
- if (response) {
- return response;
- }
- throw Error('The cached response that was expected is missing.');
- });
- }).catch(function(e) {
- // Fall back to just fetch()ing the request if some unexpected error
- // prevented the cached response from being valid.
- console.warn('Couldn\'t serve response for "%s" from cache: %O', event.request.url, e);
- return fetch(event.request);
- })
- );
- }
- }
- });
|