{"version":3,"names":[],"mappings":"","sources":["packages/workbox-precaching/browser.mjs"],"sourcesContent":["this.workbox = this.workbox || {};\nthis.workbox.precaching = (function (DBWrapper_mjs,logger_mjs,cacheNames_mjs,WorkboxError_mjs,fetchWrapper_mjs,cacheWrapper_mjs,assert_mjs,getFriendlyURL_mjs) {\n 'use strict';\n\n try {\n self.workbox.v['workbox:precaching:3.6.3'] = 1;\n } catch (e) {} // eslint-disable-line\n\n /*\n Copyright 2017 Google Inc.\n\n Licensed under the Apache License, Version 2.0 (the \"License\");\n you may not use this file except in compliance with the License.\n You may obtain a copy of the License at\n\n https://www.apache.org/licenses/LICENSE-2.0\n\n Unless required by applicable law or agreed to in writing, software\n distributed under the License is distributed on an \"AS IS\" BASIS,\n WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n See the License for the specific language governing permissions and\n limitations under the License.\n */\n\n /**\n * Used as a consistent way of referencing a URL to precache.\n *\n * @private\n * @memberof module:workbox-precaching\n */\n class PrecacheEntry {\n /**\n * This class ensures all cache list entries are consistent and\n * adds cache busting if required.\n *\n * @param {*} originalInput\n * @param {string} url\n * @param {string} revision\n * @param {boolean} shouldCacheBust\n */\n constructor(originalInput, url, revision, shouldCacheBust) {\n this._originalInput = originalInput;\n this._entryId = url;\n this._revision = revision;\n const requestAsCacheKey = new Request(url, { credentials: 'same-origin' });\n this._cacheRequest = requestAsCacheKey;\n this._networkRequest = shouldCacheBust ? this._cacheBustRequest(requestAsCacheKey) : requestAsCacheKey;\n }\n\n /**\n * This method will either use Request.cache option OR append a cache\n * busting parameter to the URL.\n *\n * @param {Request} request The request to cache bust\n * @return {Request} A cachebusted Request\n *\n * @private\n */\n _cacheBustRequest(request) {\n let url = request.url;\n const requestOptions = {\n credentials: 'same-origin'\n };\n if ('cache' in Request.prototype) {\n // Make use of the Request cache mode where we can.\n // Reload skips the HTTP cache for outgoing requests and updates\n // the cache with the returned response.\n requestOptions.cache = 'reload';\n } else {\n const parsedURL = new URL(url, location);\n\n // This is done so the minifier can mangle 'global.encodeURIComponent'\n const _encodeURIComponent = encodeURIComponent;\n\n parsedURL.search += (parsedURL.search ? '&' : '') + _encodeURIComponent(`_workbox-cache-bust`) + '=' + _encodeURIComponent(this._revision);\n url = parsedURL.toString();\n }\n\n return new Request(url, requestOptions);\n }\n }\n\n /*\n Copyright 2017 Google Inc.\n\n Licensed under the Apache License, Version 2.0 (the \"License\");\n you may not use this file except in compliance with the License.\n You may obtain a copy of the License at\n\n https://www.apache.org/licenses/LICENSE-2.0\n\n Unless required by applicable law or agreed to in writing, software\n distributed under the License is distributed on an \"AS IS\" BASIS,\n WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n See the License for the specific language governing permissions and\n limitations under the License.\n */\n\n // Allows minifier to mangle this name\n const REVISON_IDB_FIELD = 'revision';\n const URL_IDB_FIELD = 'url';\n const DB_STORE_NAME = 'precached-details-models';\n /**\n * This model will track the relevant information of entries that\n * are cached and their matching revision details.\n *\n * @private\n */\n class PrecachedDetailsModel {\n /**\n * Construct a new model for a specific cache.\n *\n * @param {string} dbName\n * @private\n */\n constructor(dbName) {\n // This ensures the db name contains only letters, numbers, '-', '_' and '$'\n const filteredDBName = dbName.replace(/[^\\w-]/g, '_');\n this._db = new DBWrapper_mjs.DBWrapper(filteredDBName, 2, {\n onupgradeneeded: this._handleUpgrade\n });\n }\n\n /**\n * Should perform an upgrade of indexedDB.\n *\n * @param {Event} evt\n *\n * @private\n */\n _handleUpgrade(evt) {\n const db = evt.target.result;\n if (evt.oldVersion < 2) {\n // IndexedDB version 1 used both 'workbox-precaching' and\n // 'precached-details-model' before upgrading to version 2.\n // Delete them and create a new store with latest schema.\n if (db.objectStoreNames.contains('workbox-precaching')) {\n db.deleteObjectStore('workbox-precaching');\n }\n if (db.objectStoreNames.contains(DB_STORE_NAME)) {\n db.deleteObjectStore(DB_STORE_NAME);\n }\n }\n db.createObjectStore(DB_STORE_NAME);\n }\n\n /**\n * Check if an entry is already cached. Returns false if\n * the entry isn't cached or the revision has changed.\n *\n * @param {string} cacheName\n * @param {PrecacheEntry} precacheEntry\n * @return {boolean}\n *\n * @private\n */\n _isEntryCached(cacheName, precacheEntry) {\n var _this = this;\n\n return babelHelpers.asyncToGenerator(function* () {\n const revisionDetails = yield _this._getRevision(precacheEntry._entryId);\n if (revisionDetails !== precacheEntry._revision) {\n return false;\n }\n\n const openCache = yield caches.open(cacheName);\n const cachedResponse = yield openCache.match(precacheEntry._cacheRequest);\n return !!cachedResponse;\n })();\n }\n\n /**\n * @return {Promise}\n *\n * @private\n */\n _getAllEntries() {\n var _this2 = this;\n\n return babelHelpers.asyncToGenerator(function* () {\n return yield _this2._db.getAllMatching(DB_STORE_NAME, {\n includeKeys: true\n });\n })();\n }\n\n /**\n * Get the current revision details.\n *\n * @param {Object} entryId\n * @return {Promise}\n *\n * @private\n */\n _getRevision(entryId) {\n var _this3 = this;\n\n return babelHelpers.asyncToGenerator(function* () {\n const data = yield _this3._db.get(DB_STORE_NAME, entryId);\n return data ? data[REVISON_IDB_FIELD] : null;\n })();\n }\n\n /**\n * Add an entry to the details model.\n *\n * @param {PrecacheEntry} precacheEntry\n *\n * @private\n */\n _addEntry(precacheEntry) {\n var _this4 = this;\n\n return babelHelpers.asyncToGenerator(function* () {\n yield _this4._db.put(DB_STORE_NAME, {\n [REVISON_IDB_FIELD]: precacheEntry._revision,\n [URL_IDB_FIELD]: precacheEntry._cacheRequest.url\n }, precacheEntry._entryId);\n })();\n }\n\n /**\n * Delete entry from details model.\n *\n * @param {string} entryId\n *\n * @private\n */\n _deleteEntry(entryId) {\n var _this5 = this;\n\n return babelHelpers.asyncToGenerator(function* () {\n yield _this5._db.delete(DB_STORE_NAME, entryId);\n })();\n }\n }\n\n /*\n Copyright 2017 Google Inc.\n\n Licensed under the Apache License, Version 2.0 (the \"License\");\n you may not use this file except in compliance with the License.\n You may obtain a copy of the License at\n\n https://www.apache.org/licenses/LICENSE-2.0\n\n Unless required by applicable law or agreed to in writing, software\n distributed under the License is distributed on an \"AS IS\" BASIS,\n WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n See the License for the specific language governing permissions and\n limitations under the License.\n */\n\n /**\n * This method will print out a warning if a precache entry doesn't have\n * a `revision` value.\n *\n * This is common if the asset if revisioned in the url like `index.1234.css`.\n *\n * @param {Map} entriesMap\n *\n * @private\n * @memberof module:workbox-preaching\n */\n var showWarningsIfNeeded = (entriesMap => {\n const urlOnlyEntries = [];\n entriesMap.forEach(entry => {\n if (typeof entry === 'string' || !entry._originalInput.revision) {\n urlOnlyEntries.push(entry._originalInput);\n }\n });\n\n if (urlOnlyEntries.length === 0) {\n // No warnings needed.\n return;\n }\n\n logger_mjs.logger.groupCollapsed('Are your precached assets revisioned?');\n\n const urlsList = urlOnlyEntries.map(urlOnlyEntry => {\n return ` - ${JSON.stringify(urlOnlyEntry)}`;\n }).join(`\\n`);\n\n logger_mjs.logger.warn(`The following precache entries might not be revisioned:` + `\\n\\n` + urlsList + `\\n\\n`);\n\n logger_mjs.logger.unprefixed.warn(`You can learn more about why this might be a ` + `problem here: https://developers.google.com/web/tools/workbox/modules/workbox-precaching`);\n\n logger_mjs.logger.groupEnd();\n });\n\n /*\n Copyright 2017 Google Inc.\n\n Licensed under the Apache License, Version 2.0 (the \"License\");\n you may not use this file except in compliance with the License.\n You may obtain a copy of the License at\n\n https://www.apache.org/licenses/LICENSE-2.0\n\n Unless required by applicable law or agreed to in writing, software\n distributed under the License is distributed on an \"AS IS\" BASIS,\n WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n See the License for the specific language governing permissions and\n limitations under the License.\n */\n\n /**\n * @param {string} groupTitle\n * @param {Array} entries\n *\n * @private\n */\n const _nestedGroup = (groupTitle, entries) => {\n if (entries.length === 0) {\n return;\n }\n\n logger_mjs.logger.groupCollapsed(groupTitle);\n\n entries.forEach(entry => {\n logger_mjs.logger.log(entry._originalInput);\n });\n\n logger_mjs.logger.groupEnd();\n };\n\n /**\n * @param {Array} entriesToPrecache\n * @param {Array} alreadyPrecachedEntries\n *\n * @private\n * @memberof module:workbox-precachig\n */\n var printInstallDetails = ((entriesToPrecache, alreadyPrecachedEntries) => {\n // Goal is to print the message:\n // Precaching X files.\n // Or:\n // Precaching X files. Y files were cached and up-to-date.\n\n const precachedCount = entriesToPrecache.length;\n const alreadyPrecachedCount = alreadyPrecachedEntries.length;\n let printText = `Precaching ${precachedCount} file${precachedCount === 1 ? '' : 's'}.`;\n if (alreadyPrecachedCount > 0) {\n printText += ` ${alreadyPrecachedCount} ` + `file${alreadyPrecachedCount === 1 ? ' is' : 's are'} already cached.`;\n }\n\n logger_mjs.logger.groupCollapsed(printText);\n\n _nestedGroup(`View precached URLs.`, entriesToPrecache);\n _nestedGroup(`View URLs that were already precached.`, alreadyPrecachedEntries);\n logger_mjs.logger.groupEnd();\n });\n\n /*\n Copyright 2017 Google Inc.\n\n Licensed under the Apache License, Version 2.0 (the \"License\");\n you may not use this file except in compliance with the License.\n You may obtain a copy of the License at\n\n https://www.apache.org/licenses/LICENSE-2.0\n\n Unless required by applicable law or agreed to in writing, software\n distributed under the License is distributed on an \"AS IS\" BASIS,\n WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n See the License for the specific language governing permissions and\n limitations under the License.\n */\n\n const logGroup = (groupTitle, urls) => {\n logger_mjs.logger.groupCollapsed(groupTitle);\n\n urls.forEach(url => {\n logger_mjs.logger.log(url);\n });\n\n logger_mjs.logger.groupEnd();\n };\n\n /**\n * @param {Array} deletedCacheRequests\n * @param {Array} deletedRevisionDetails\n *\n * @private\n * @memberof module:workbox-precachig\n */\n var printCleanupDetails = ((deletedCacheRequests, deletedRevisionDetails) => {\n if (deletedCacheRequests.length === 0 && deletedRevisionDetails.length === 0) {\n return;\n }\n\n const cacheDeleteCount = deletedCacheRequests.length;\n const revisionDeleteCount = deletedRevisionDetails.length;\n\n const cacheDeleteText = `${cacheDeleteCount} cached ` + `request${cacheDeleteCount === 1 ? ' was' : 's were'} deleted`;\n const revisionDeleteText = `${revisionDeleteCount} ` + `${revisionDeleteCount === 1 ? 'entry' : 'entries'} ` + `${revisionDeleteCount === 1 ? 'was' : 'were'} deleted from IndexedDB.`;\n\n logger_mjs.logger.groupCollapsed(`During precaching cleanup, ${cacheDeleteText} and ${revisionDeleteText}`);\n\n logGroup('Deleted Cache Requests', deletedCacheRequests);\n logGroup('Revision Details Deleted from DB', deletedRevisionDetails);\n\n logger_mjs.logger.groupEnd();\n });\n\n /*\n Copyright 2017 Google Inc.\n\n Licensed under the Apache License, Version 2.0 (the \"License\");\n you may not use this file except in compliance with the License.\n You may obtain a copy of the License at\n\n https://www.apache.org/licenses/LICENSE-2.0\n\n Unless required by applicable law or agreed to in writing, software\n distributed under the License is distributed on an \"AS IS\" BASIS,\n WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n See the License for the specific language governing permissions and\n limitations under the License.\n */\n\n /**\n * @param {Response} response\n * @return {Response}\n *\n * @private\n * @memberof module:workbox-precaching\n */\n const cleanRedirect = (() => {\n var _ref = babelHelpers.asyncToGenerator(function* (response) {\n const clonedResponse = response.clone();\n\n // Not all browsers support the Response.body stream, so fall back\n // to reading the entire body into memory as a blob.\n const bodyPromise = 'body' in clonedResponse ? Promise.resolve(clonedResponse.body) : clonedResponse.blob();\n\n const body = yield bodyPromise;\n\n // new Response() is happy when passed either a stream or a Blob.\n return new Response(body, {\n headers: clonedResponse.headers,\n status: clonedResponse.status,\n statusText: clonedResponse.statusText\n });\n });\n\n return function cleanRedirect(_x) {\n return _ref.apply(this, arguments);\n };\n })();\n\n /*\n Copyright 2017 Google Inc.\n\n Licensed under the Apache License, Version 2.0 (the \"License\");\n you may not use this file except in compliance with the License.\n You may obtain a copy of the License at\n\n https://www.apache.org/licenses/LICENSE-2.0\n\n Unless required by applicable law or agreed to in writing, software\n distributed under the License is distributed on an \"AS IS\" BASIS,\n WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n See the License for the specific language governing permissions and\n limitations under the License.\n */\n\n /**\n * Performs efficient precaching of assets.\n *\n * @memberof workbox.precaching\n */\n class PrecacheController {\n /**\n * Create a new PrecacheController.\n *\n * @param {string} cacheName\n */\n constructor(cacheName) {\n this._cacheName = cacheNames_mjs.cacheNames.getPrecacheName(cacheName);\n this._entriesToCacheMap = new Map();\n this._precacheDetailsModel = new PrecachedDetailsModel(this._cacheName);\n }\n\n /**\n * This method will add items to the precache list, removing duplicates\n * and ensuring the information is valid.\n *\n * @param {\n * Array\n * } entries Array of entries to\n * precache.\n */\n addToCacheList(entries) {\n {\n assert_mjs.assert.isArray(entries, {\n moduleName: 'workbox-precaching',\n className: 'PrecacheController',\n funcName: 'addToCacheList',\n paramName: 'entries'\n });\n }\n\n entries.map(userEntry => {\n this._addEntryToCacheList(this._parseEntry(userEntry));\n });\n }\n\n /**\n * This method returns a precache entry.\n *\n * @private\n * @param {string|Object} input\n * @return {PrecacheEntry}\n */\n _parseEntry(input) {\n switch (typeof input) {\n case 'string':\n {\n {\n if (input.length === 0) {\n throw new WorkboxError_mjs.WorkboxError('add-to-cache-list-unexpected-type', {\n entry: input\n });\n }\n }\n\n return new PrecacheEntry(input, input, input);\n }\n case 'object':\n {\n {\n if (!input || !input.url) {\n throw new WorkboxError_mjs.WorkboxError('add-to-cache-list-unexpected-type', {\n entry: input\n });\n }\n }\n\n return new PrecacheEntry(input, input.url, input.revision || input.url, !!input.revision);\n }\n default:\n throw new WorkboxError_mjs.WorkboxError('add-to-cache-list-unexpected-type', {\n entry: input\n });\n }\n }\n\n /**\n * Adds an entry to the precache list, accounting for possible duplicates.\n *\n * @private\n * @param {PrecacheEntry} entryToAdd\n */\n _addEntryToCacheList(entryToAdd) {\n // Check if the entry is already part of the map\n const existingEntry = this._entriesToCacheMap.get(entryToAdd._entryId);\n if (!existingEntry) {\n this._entriesToCacheMap.set(entryToAdd._entryId, entryToAdd);\n return;\n }\n\n // Duplicates are fine, but make sure the revision information\n // is the same.\n if (existingEntry._revision !== entryToAdd._revision) {\n throw new WorkboxError_mjs.WorkboxError('add-to-cache-list-conflicting-entries', {\n firstEntry: existingEntry._originalInput,\n secondEntry: entryToAdd._originalInput\n });\n }\n }\n\n /**\n * Call this method from a service work install event to start\n * precaching assets.\n *\n * @param {Object} options\n * @param {boolean} [options.suppressWarnings] Suppress warning messages.\n * @param {Event} [options.event] The install event (if needed).\n * @param {Array} [options.plugins] Plugins to be used for fetching\n * and caching during install.\n * @return {Promise}\n */\n install({ suppressWarnings = false, event, plugins } = {}) {\n var _this = this;\n\n return babelHelpers.asyncToGenerator(function* () {\n {\n if (suppressWarnings !== true) {\n showWarningsIfNeeded(_this._entriesToCacheMap);\n }\n\n if (plugins) {\n assert_mjs.assert.isArray(plugins, {\n moduleName: 'workbox-precaching',\n className: 'PrecacheController',\n funcName: 'install',\n paramName: 'plugins'\n });\n }\n }\n\n // Empty the temporary cache.\n // NOTE: We remove all entries instead of deleting the cache as the cache\n // may be marked for deletion but still exist until a later stage\n // resulting in unexpected behavior of being deletect when all references\n // are dropped.\n // https://github.com/GoogleChrome/workbox/issues/1368\n const tempCache = yield caches.open(_this._getTempCacheName());\n const requests = yield tempCache.keys();\n yield Promise.all(requests.map(function (request) {\n return tempCache.delete(request);\n }));\n\n const entriesToPrecache = [];\n const entriesAlreadyPrecached = [];\n\n for (const precacheEntry of _this._entriesToCacheMap.values()) {\n if (yield _this._precacheDetailsModel._isEntryCached(_this._cacheName, precacheEntry)) {\n entriesAlreadyPrecached.push(precacheEntry);\n } else {\n entriesToPrecache.push(precacheEntry);\n }\n }\n\n // Wait for all requests to be cached.\n yield Promise.all(entriesToPrecache.map(function (precacheEntry) {\n return _this._cacheEntryInTemp({ event, plugins, precacheEntry });\n }));\n\n {\n printInstallDetails(entriesToPrecache, entriesAlreadyPrecached);\n }\n\n return {\n updatedEntries: entriesToPrecache,\n notUpdatedEntries: entriesAlreadyPrecached\n };\n })();\n }\n\n /**\n * Takes the current set of temporary files and moves them to the final\n * cache, deleting the temporary cache once copying is complete.\n *\n * @param {Object} options\n * @param {Array} options.plugins Plugins to be used for fetching\n * and caching during install.\n * @return {\n * Promise}\n * Resolves with an object containing details of the deleted cache requests\n * and precache revision details.\n */\n activate(options = {}) {\n var _this2 = this;\n\n return babelHelpers.asyncToGenerator(function* () {\n const tempCache = yield caches.open(_this2._getTempCacheName());\n\n const requests = yield tempCache.keys();\n // Process each request/response one at a time, deleting the temporary entry\n // when done, to help avoid triggering quota errors.\n for (const request of requests) {\n const response = yield tempCache.match(request);\n yield cacheWrapper_mjs.cacheWrapper.put({\n cacheName: _this2._cacheName,\n request,\n response,\n plugins: options.plugins\n });\n yield tempCache.delete(request);\n }\n\n return _this2._cleanup();\n })();\n }\n\n /**\n * Returns the name of the temporary cache.\n *\n * @return {string}\n *\n * @private\n */\n _getTempCacheName() {\n return `${this._cacheName}-temp`;\n }\n\n /**\n * Requests the entry and saves it to the cache if the response\n * is valid.\n *\n * @private\n * @param {Object} options\n * @param {BaseCacheEntry} options.precacheEntry The entry to fetch and cache.\n * @param {Event} [options.event] The install event (if passed).\n * @param {Array} [options.plugins] An array of plugins to apply to\n * fetch and caching.\n * @return {Promise} Returns a promise that resolves once the entry\n * has been fetched and cached or skipped if no update is needed. The\n * promise resolves with true if the entry was cached / updated and\n * false if the entry is already cached and up-to-date.\n */\n _cacheEntryInTemp({ precacheEntry, event, plugins }) {\n var _this3 = this;\n\n return babelHelpers.asyncToGenerator(function* () {\n let response = yield fetchWrapper_mjs.fetchWrapper.fetch({\n request: precacheEntry._networkRequest,\n event,\n fetchOptions: null,\n plugins\n });\n\n if (response.redirected) {\n response = yield cleanRedirect(response);\n }\n\n yield cacheWrapper_mjs.cacheWrapper.put({\n cacheName: _this3._getTempCacheName(),\n request: precacheEntry._cacheRequest,\n response,\n event,\n plugins\n });\n\n yield _this3._precacheDetailsModel._addEntry(precacheEntry);\n\n return true;\n })();\n }\n\n /**\n * Compare the URLs and determines which assets are no longer required\n * in the cache.\n *\n * This should be called in the service worker activate event.\n *\n * @return {\n * Promise}\n * Resolves with an object containing details of the deleted cache requests\n * and precache revision details.\n *\n * @private\n */\n _cleanup() {\n var _this4 = this;\n\n return babelHelpers.asyncToGenerator(function* () {\n const expectedCacheUrls = [];\n _this4._entriesToCacheMap.forEach(function (entry) {\n const fullUrl = new URL(entry._cacheRequest.url, location).toString();\n expectedCacheUrls.push(fullUrl);\n });\n\n const [deletedCacheRequests, deletedRevisionDetails] = yield Promise.all([_this4._cleanupCache(expectedCacheUrls), _this4._cleanupDetailsModel(expectedCacheUrls)]);\n\n {\n printCleanupDetails(deletedCacheRequests, deletedRevisionDetails);\n }\n\n return {\n deletedCacheRequests,\n deletedRevisionDetails\n };\n })();\n }\n\n /**\n * Goes through all the cache entries and removes any that are\n * outdated.\n *\n * @private\n * @param {Array} expectedCacheUrls Array of URLs that are\n * expected to be cached.\n * @return {Promise>} Resolves to an array of URLs\n * of cached requests that were deleted.\n */\n _cleanupCache(expectedCacheUrls) {\n var _this5 = this;\n\n return babelHelpers.asyncToGenerator(function* () {\n if (!(yield caches.has(_this5._cacheName))) {\n // Cache doesn't exist, so nothing to delete\n return [];\n }\n\n const cache = yield caches.open(_this5._cacheName);\n const cachedRequests = yield cache.keys();\n const cachedRequestsToDelete = cachedRequests.filter(function (cachedRequest) {\n return !expectedCacheUrls.includes(new URL(cachedRequest.url, location).toString());\n });\n\n yield Promise.all(cachedRequestsToDelete.map(function (cacheUrl) {\n return cache.delete(cacheUrl);\n }));\n\n return cachedRequestsToDelete.map(function (request) {\n return request.url;\n });\n })();\n }\n\n /**\n * Goes through all entries in indexedDB and removes any that are outdated.\n *\n * @private\n * @param {Array} expectedCacheUrls Array of URLs that are\n * expected to be cached.\n * @return {Promise>} Resolves to an array of URLs removed\n * from indexedDB.\n */\n _cleanupDetailsModel(expectedCacheUrls) {\n var _this6 = this;\n\n return babelHelpers.asyncToGenerator(function* () {\n const revisionedEntries = yield _this6._precacheDetailsModel._getAllEntries();\n const detailsToDelete = revisionedEntries.filter(function (entry) {\n const fullUrl = new URL(entry.value.url, location).toString();\n return !expectedCacheUrls.includes(fullUrl);\n });\n\n yield Promise.all(detailsToDelete.map(function (entry) {\n return _this6._precacheDetailsModel._deleteEntry(entry.primaryKey);\n }));\n return detailsToDelete.map(function (entry) {\n return entry.value.url;\n });\n })();\n }\n\n /**\n * Returns an array of fully qualified URL's that will be precached.\n *\n * @return {Array} An array of URLs.\n */\n getCachedUrls() {\n return Array.from(this._entriesToCacheMap.keys()).map(url => new URL(url, location).href);\n }\n }\n\n /*\n Copyright 2017 Google Inc.\n\n Licensed under the Apache License, Version 2.0 (the \"License\");\n you may not use this file except in compliance with the License.\n You may obtain a copy of the License at\n\n https://www.apache.org/licenses/LICENSE-2.0\n\n Unless required by applicable law or agreed to in writing, software\n distributed under the License is distributed on an \"AS IS\" BASIS,\n WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n See the License for the specific language governing permissions and\n limitations under the License.\n */\n\n var publicAPI = /*#__PURE__*/Object.freeze({\n PrecacheController: PrecacheController\n });\n\n /*\n Copyright 2017 Google Inc.\n\n Licensed under the Apache License, Version 2.0 (the \"License\");\n you may not use this file except in compliance with the License.\n You may obtain a copy of the License at\n\n https://www.apache.org/licenses/LICENSE-2.0\n\n Unless required by applicable law or agreed to in writing, software\n distributed under the License is distributed on an \"AS IS\" BASIS,\n WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n See the License for the specific language governing permissions and\n limitations under the License.\n */\n\n {\n assert_mjs.assert.isSwEnv('workbox-precaching');\n }\n\n let installActivateListenersAdded = false;\n let fetchListenersAdded = false;\n let suppressWarnings = false;\n let plugins = [];\n\n const cacheName = cacheNames_mjs.cacheNames.getPrecacheName();\n const precacheController = new PrecacheController(cacheName);\n\n const _removeIgnoreUrlParams = (origUrlObject, ignoreUrlParametersMatching) => {\n // Exclude initial '?'\n const searchString = origUrlObject.search.slice(1);\n\n // Split into an array of 'key=value' strings\n const keyValueStrings = searchString.split('&');\n const keyValuePairs = keyValueStrings.map(keyValueString => {\n // Split each 'key=value' string into a [key, value] array\n return keyValueString.split('=');\n });\n const filteredKeyValuesPairs = keyValuePairs.filter(keyValuePair => {\n return ignoreUrlParametersMatching.every(ignoredRegex => {\n // Return true iff the key doesn't match any of the regexes.\n return !ignoredRegex.test(keyValuePair[0]);\n });\n });\n const filteredStrings = filteredKeyValuesPairs.map(keyValuePair => {\n // Join each [key, value] array into a 'key=value' string\n return keyValuePair.join('=');\n });\n\n // Join the array of 'key=value' strings into a string with '&' in\n // between each\n const urlClone = new URL(origUrlObject);\n urlClone.search = filteredStrings.join('&');\n return urlClone;\n };\n\n /**\n * This function will take the request URL and manipulate it based on the\n * configuration options.\n *\n * @param {string} url\n * @param {Object} options\n * @return {string|null} Returns the URL in the cache that matches the request\n * if available, other null.\n *\n * @private\n */\n const _getPrecachedUrl = (url, {\n ignoreUrlParametersMatching = [/^utm_/],\n directoryIndex = 'index.html',\n cleanUrls = true,\n urlManipulation = null\n } = {}) => {\n const urlObject = new URL(url, location);\n\n // Change '/some-url#123' => '/some-url'\n urlObject.hash = '';\n\n const urlWithoutIgnoredParams = _removeIgnoreUrlParams(urlObject, ignoreUrlParametersMatching);\n\n let urlsToAttempt = [\n // Test the URL that was fetched\n urlObject,\n // Test the URL without search params\n urlWithoutIgnoredParams];\n\n // Test the URL with a directory index\n if (directoryIndex && urlWithoutIgnoredParams.pathname.endsWith('/')) {\n const directoryUrl = new URL(urlWithoutIgnoredParams);\n directoryUrl.pathname += directoryIndex;\n urlsToAttempt.push(directoryUrl);\n }\n\n // Test the URL with a '.html' extension\n if (cleanUrls) {\n const cleanUrl = new URL(urlWithoutIgnoredParams);\n cleanUrl.pathname += '.html';\n urlsToAttempt.push(cleanUrl);\n }\n\n if (urlManipulation) {\n const additionalUrls = urlManipulation({ url: urlObject });\n urlsToAttempt = urlsToAttempt.concat(additionalUrls);\n }\n\n const cachedUrls = precacheController.getCachedUrls();\n for (const possibleUrl of urlsToAttempt) {\n if (cachedUrls.indexOf(possibleUrl.href) !== -1) {\n // It's a perfect match\n {\n logger_mjs.logger.debug(`Precaching found a match for ` + getFriendlyURL_mjs.getFriendlyURL(possibleUrl.toString()));\n }\n return possibleUrl.href;\n }\n }\n\n return null;\n };\n\n const moduleExports = {};\n\n /**\n * Add items to the precache list, removing any duplicates and\n * store the files in the\n * [\"precache cache\"]{@link module:workbox-core.cacheNames} when the service\n * worker installs.\n *\n * This method can be called multiple times.\n *\n * Please note: This method **will not** serve any of the cached files for you,\n * it only precaches files. To respond to a network request you call\n * [addRoute()]{@link module:workbox-precaching.addRoute}.\n *\n * If you have a single array of files to precache, you can just call\n * [precacheAndRoute()]{@link module:workbox-precaching.precacheAndRoute}.\n *\n * @param {Array} entries Array of entries to precache.\n *\n * @alias workbox.precaching.precache\n */\n moduleExports.precache = entries => {\n precacheController.addToCacheList(entries);\n\n if (installActivateListenersAdded || entries.length <= 0) {\n return;\n }\n\n installActivateListenersAdded = true;\n self.addEventListener('install', event => {\n event.waitUntil(precacheController.install({\n event,\n plugins,\n suppressWarnings\n }));\n });\n self.addEventListener('activate', event => {\n event.waitUntil(precacheController.activate({\n event,\n plugins\n }));\n });\n };\n\n /**\n * Add a `fetch` listener to the service worker that will\n * respond to\n * [network requests]{@link https://developer.mozilla.org/en-US/docs/Web/API/Service_Worker_API/Using_Service_Workers#Custom_responses_to_requests}\n * with precached assets.\n *\n * Requests for assets that aren't precached, the `FetchEvent` will not be\n * responded to, allowing the event to fall through to other `fetch` event\n * listeners.\n *\n * @param {Object} options\n * @param {string} [options.directoryIndex=index.html] The `directoryIndex` will\n * check cache entries for a URLs ending with '/' to see if there is a hit when\n * appending the `directoryIndex` value.\n * @param {Array} [options.ignoreUrlParametersMatching=[/^utm_/]] An\n * array of regex's to remove search params when looking for a cache match.\n * @param {boolean} [options.cleanUrls=true] The `cleanUrls` option will\n * check the cache for the URL with a `.html` added to the end of the end.\n * @param {workbox.precaching~urlManipulation} [options.urlManipulation]\n * This is a function that should take a URL and return an array of\n * alternative URL's that should be checked for precache matches.\n *\n * @alias workbox.precaching.addRoute\n */\n moduleExports.addRoute = options => {\n if (fetchListenersAdded) {\n // TODO: Throw error here.\n return;\n }\n\n fetchListenersAdded = true;\n self.addEventListener('fetch', event => {\n const precachedUrl = _getPrecachedUrl(event.request.url, options);\n if (!precachedUrl) {\n {\n logger_mjs.logger.debug(`Precaching found no match for ` + getFriendlyURL_mjs.getFriendlyURL(event.request.url));\n }\n return;\n }\n\n let responsePromise = caches.open(cacheName).then(cache => {\n return cache.match(precachedUrl);\n }).then(cachedResponse => {\n if (cachedResponse) {\n return cachedResponse;\n }\n\n // Fall back to the network if we don't have a cached response (perhaps\n // due to manual cache cleanup).\n {\n logger_mjs.logger.debug(`The precached response for ` + `${getFriendlyURL_mjs.getFriendlyURL(precachedUrl)} in ${cacheName} was not found. ` + `Falling back to the network instead.`);\n }\n\n return fetch(precachedUrl);\n });\n\n {\n responsePromise = responsePromise.then(response => {\n // Workbox is going to handle the route.\n // print the routing details to the console.\n logger_mjs.logger.groupCollapsed(`Precaching is responding to: ` + getFriendlyURL_mjs.getFriendlyURL(event.request.url));\n logger_mjs.logger.log(`Serving the precached url: ${precachedUrl}`);\n\n // The Request and Response objects contains a great deal of\n // information, hide it under a group in case developers want to see it.\n logger_mjs.logger.groupCollapsed(`View request details here.`);\n logger_mjs.logger.unprefixed.log(event.request);\n logger_mjs.logger.groupEnd();\n\n logger_mjs.logger.groupCollapsed(`View response details here.`);\n logger_mjs.logger.unprefixed.log(response);\n logger_mjs.logger.groupEnd();\n\n logger_mjs.logger.groupEnd();\n return response;\n });\n }\n event.respondWith(responsePromise);\n });\n };\n\n /**\n * This method will add entries to the precache list and add a route to\n * respond to fetch events.\n *\n * This is a convenience method that will call\n * [precache()]{@link module:workbox-precaching.precache} and\n * [addRoute()]{@link module:workbox-precaching.addRoute} in a single call.\n *\n * @param {Array} entries Array of entries to precache.\n * @param {Object} options See\n * [addRoute() options]{@link module:workbox-precaching.addRoute}.\n *\n * @alias workbox.precaching.precacheAndRoute\n */\n moduleExports.precacheAndRoute = (entries, options) => {\n moduleExports.precache(entries);\n moduleExports.addRoute(options);\n };\n\n /**\n * Warnings will be logged if any of the precached assets are entered without\n * a `revision` property. This is extremely dangerous if the URL's aren't\n * revisioned. However, the warnings can be supressed with this method.\n *\n * @param {boolean} suppress\n *\n * @alias workbox.precaching.suppressWarnings\n */\n moduleExports.suppressWarnings = suppress => {\n suppressWarnings = suppress;\n };\n\n /**\n * Add plugins to precaching.\n *\n * @param {Array} newPlugins\n *\n * @alias workbox.precaching.addPlugins\n */\n moduleExports.addPlugins = newPlugins => {\n plugins = plugins.concat(newPlugins);\n };\n\n /*\n Copyright 2017 Google Inc.\n\n Licensed under the Apache License, Version 2.0 (the \"License\");\n you may not use this file except in compliance with the License.\n You may obtain a copy of the License at\n\n https://www.apache.org/licenses/LICENSE-2.0\n\n Unless required by applicable law or agreed to in writing, software\n distributed under the License is distributed on an \"AS IS\" BASIS,\n WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n See the License for the specific language governing permissions and\n limitations under the License.\n */\n\n const finalExport = Object.assign(moduleExports, publicAPI);\n\n return finalExport;\n\n}(workbox.core._private,workbox.core._private,workbox.core._private,workbox.core._private,workbox.core._private,workbox.core._private,workbox.core._private,workbox.core._private));\n"],"file":"workbox-precaching.dev.js"}