jekyll-pwa-plugin 2.0.1 → 5.1.5

Sign up to get free protection for your applications and to get access to all the features.
Files changed (111) hide show
  1. checksums.yaml +5 -5
  2. data/lib/jekyll-pwa-plugin.rb +12 -4
  3. data/lib/vendor/workbox-v5.1.4/workbox-background-sync.dev.js +818 -0
  4. data/lib/vendor/workbox-v5.1.4/workbox-background-sync.dev.js.map +1 -0
  5. data/lib/vendor/workbox-v5.1.4/workbox-background-sync.prod.js +2 -0
  6. data/lib/vendor/workbox-v5.1.4/workbox-background-sync.prod.js.map +1 -0
  7. data/lib/vendor/workbox-v5.1.4/workbox-broadcast-update.dev.js +288 -0
  8. data/lib/vendor/workbox-v5.1.4/workbox-broadcast-update.dev.js.map +1 -0
  9. data/lib/vendor/workbox-v5.1.4/workbox-broadcast-update.prod.js +2 -0
  10. data/lib/vendor/workbox-v5.1.4/workbox-broadcast-update.prod.js.map +1 -0
  11. data/lib/vendor/workbox-v5.1.4/workbox-cacheable-response.dev.js +191 -0
  12. data/lib/vendor/workbox-v5.1.4/workbox-cacheable-response.dev.js.map +1 -0
  13. data/lib/vendor/workbox-v5.1.4/workbox-cacheable-response.prod.js +2 -0
  14. data/lib/vendor/workbox-v5.1.4/workbox-cacheable-response.prod.js.map +1 -0
  15. data/lib/vendor/workbox-v5.1.4/workbox-core.dev.js +1858 -0
  16. data/lib/vendor/workbox-v5.1.4/workbox-core.dev.js.map +1 -0
  17. data/lib/vendor/workbox-v5.1.4/workbox-core.prod.js +2 -0
  18. data/lib/vendor/workbox-v5.1.4/workbox-core.prod.js.map +1 -0
  19. data/lib/vendor/workbox-v5.1.4/workbox-expiration.dev.js +649 -0
  20. data/lib/vendor/workbox-v5.1.4/workbox-expiration.dev.js.map +1 -0
  21. data/lib/vendor/workbox-v5.1.4/workbox-expiration.prod.js +2 -0
  22. data/lib/vendor/workbox-v5.1.4/workbox-expiration.prod.js.map +1 -0
  23. data/lib/vendor/workbox-v5.1.4/workbox-navigation-preload.dev.js +102 -0
  24. data/lib/vendor/workbox-v5.1.4/workbox-navigation-preload.dev.js.map +1 -0
  25. data/lib/vendor/workbox-v5.1.4/workbox-navigation-preload.prod.js +2 -0
  26. data/lib/vendor/workbox-v5.1.4/workbox-navigation-preload.prod.js.map +1 -0
  27. data/lib/vendor/workbox-v5.1.4/workbox-offline-ga.dev.js +235 -0
  28. data/lib/vendor/workbox-v5.1.4/workbox-offline-ga.dev.js.map +1 -0
  29. data/lib/vendor/workbox-v5.1.4/workbox-offline-ga.prod.js +2 -0
  30. data/lib/vendor/workbox-v5.1.4/workbox-offline-ga.prod.js.map +1 -0
  31. data/lib/vendor/workbox-v5.1.4/workbox-precaching.dev.js +1210 -0
  32. data/lib/vendor/workbox-v5.1.4/workbox-precaching.dev.js.map +1 -0
  33. data/lib/vendor/workbox-v5.1.4/workbox-precaching.prod.js +2 -0
  34. data/lib/vendor/workbox-v5.1.4/workbox-precaching.prod.js.map +1 -0
  35. data/lib/vendor/workbox-v5.1.4/workbox-range-requests.dev.js +262 -0
  36. data/lib/vendor/workbox-v5.1.4/workbox-range-requests.dev.js.map +1 -0
  37. data/lib/vendor/workbox-v5.1.4/workbox-range-requests.prod.js +2 -0
  38. data/lib/vendor/workbox-v5.1.4/workbox-range-requests.prod.js.map +1 -0
  39. data/lib/vendor/workbox-v5.1.4/workbox-routing.dev.js +923 -0
  40. data/lib/vendor/workbox-v5.1.4/workbox-routing.dev.js.map +1 -0
  41. data/lib/vendor/workbox-v5.1.4/workbox-routing.prod.js +2 -0
  42. data/lib/vendor/workbox-v5.1.4/workbox-routing.prod.js.map +1 -0
  43. data/lib/vendor/workbox-v5.1.4/workbox-strategies.dev.js +923 -0
  44. data/lib/vendor/workbox-v5.1.4/workbox-strategies.dev.js.map +1 -0
  45. data/lib/vendor/workbox-v5.1.4/workbox-strategies.prod.js +2 -0
  46. data/lib/vendor/workbox-v5.1.4/workbox-strategies.prod.js.map +1 -0
  47. data/lib/vendor/workbox-v5.1.4/workbox-streams.dev.js +318 -0
  48. data/lib/vendor/workbox-v5.1.4/workbox-streams.dev.js.map +1 -0
  49. data/lib/vendor/workbox-v5.1.4/workbox-streams.prod.js +2 -0
  50. data/lib/vendor/workbox-v5.1.4/workbox-streams.prod.js.map +1 -0
  51. data/lib/vendor/workbox-v5.1.4/workbox-sw.js +2 -0
  52. data/lib/vendor/workbox-v5.1.4/workbox-sw.js.map +1 -0
  53. data/lib/vendor/workbox-v5.1.4/workbox-window.dev.es5.mjs +1125 -0
  54. data/lib/vendor/workbox-v5.1.4/workbox-window.dev.es5.mjs.map +1 -0
  55. data/lib/vendor/workbox-v5.1.4/workbox-window.dev.mjs +943 -0
  56. data/lib/vendor/workbox-v5.1.4/workbox-window.dev.mjs.map +1 -0
  57. data/lib/vendor/workbox-v5.1.4/workbox-window.dev.umd.js +1136 -0
  58. data/lib/vendor/workbox-v5.1.4/workbox-window.dev.umd.js.map +1 -0
  59. data/lib/vendor/workbox-v5.1.4/workbox-window.prod.es5.mjs +2 -0
  60. data/lib/vendor/workbox-v5.1.4/workbox-window.prod.es5.mjs.map +1 -0
  61. data/lib/vendor/workbox-v5.1.4/workbox-window.prod.mjs +2 -0
  62. data/lib/vendor/workbox-v5.1.4/workbox-window.prod.mjs.map +1 -0
  63. data/lib/vendor/workbox-v5.1.4/workbox-window.prod.umd.js +2 -0
  64. data/lib/vendor/workbox-v5.1.4/workbox-window.prod.umd.js.map +1 -0
  65. metadata +65 -50
  66. data/lib/vendor/workbox-v3.3.1/workbox-background-sync.dev.js +0 -593
  67. data/lib/vendor/workbox-v3.3.1/workbox-background-sync.dev.js.map +0 -1
  68. data/lib/vendor/workbox-v3.3.1/workbox-background-sync.prod.js +0 -3
  69. data/lib/vendor/workbox-v3.3.1/workbox-background-sync.prod.js.map +0 -1
  70. data/lib/vendor/workbox-v3.3.1/workbox-broadcast-cache-update.dev.js +0 -395
  71. data/lib/vendor/workbox-v3.3.1/workbox-broadcast-cache-update.dev.js.map +0 -1
  72. data/lib/vendor/workbox-v3.3.1/workbox-broadcast-cache-update.prod.js +0 -3
  73. data/lib/vendor/workbox-v3.3.1/workbox-broadcast-cache-update.prod.js.map +0 -1
  74. data/lib/vendor/workbox-v3.3.1/workbox-cache-expiration.dev.js +0 -740
  75. data/lib/vendor/workbox-v3.3.1/workbox-cache-expiration.dev.js.map +0 -1
  76. data/lib/vendor/workbox-v3.3.1/workbox-cache-expiration.prod.js +0 -3
  77. data/lib/vendor/workbox-v3.3.1/workbox-cache-expiration.prod.js.map +0 -1
  78. data/lib/vendor/workbox-v3.3.1/workbox-cacheable-response.dev.js +0 -236
  79. data/lib/vendor/workbox-v3.3.1/workbox-cacheable-response.dev.js.map +0 -1
  80. data/lib/vendor/workbox-v3.3.1/workbox-cacheable-response.prod.js +0 -3
  81. data/lib/vendor/workbox-v3.3.1/workbox-cacheable-response.prod.js.map +0 -1
  82. data/lib/vendor/workbox-v3.3.1/workbox-core.dev.js +0 -1690
  83. data/lib/vendor/workbox-v3.3.1/workbox-core.dev.js.map +0 -1
  84. data/lib/vendor/workbox-v3.3.1/workbox-core.prod.js +0 -3
  85. data/lib/vendor/workbox-v3.3.1/workbox-core.prod.js.map +0 -1
  86. data/lib/vendor/workbox-v3.3.1/workbox-google-analytics.dev.js +0 -255
  87. data/lib/vendor/workbox-v3.3.1/workbox-google-analytics.dev.js.map +0 -1
  88. data/lib/vendor/workbox-v3.3.1/workbox-google-analytics.prod.js +0 -3
  89. data/lib/vendor/workbox-v3.3.1/workbox-google-analytics.prod.js.map +0 -1
  90. data/lib/vendor/workbox-v3.3.1/workbox-precaching.dev.js +0 -1149
  91. data/lib/vendor/workbox-v3.3.1/workbox-precaching.dev.js.map +0 -1
  92. data/lib/vendor/workbox-v3.3.1/workbox-precaching.prod.js +0 -3
  93. data/lib/vendor/workbox-v3.3.1/workbox-precaching.prod.js.map +0 -1
  94. data/lib/vendor/workbox-v3.3.1/workbox-range-requests.dev.js +0 -299
  95. data/lib/vendor/workbox-v3.3.1/workbox-range-requests.dev.js.map +0 -1
  96. data/lib/vendor/workbox-v3.3.1/workbox-range-requests.prod.js +0 -3
  97. data/lib/vendor/workbox-v3.3.1/workbox-range-requests.prod.js.map +0 -1
  98. data/lib/vendor/workbox-v3.3.1/workbox-routing.dev.js +0 -863
  99. data/lib/vendor/workbox-v3.3.1/workbox-routing.dev.js.map +0 -1
  100. data/lib/vendor/workbox-v3.3.1/workbox-routing.prod.js +0 -3
  101. data/lib/vendor/workbox-v3.3.1/workbox-routing.prod.js.map +0 -1
  102. data/lib/vendor/workbox-v3.3.1/workbox-strategies.dev.js +0 -1091
  103. data/lib/vendor/workbox-v3.3.1/workbox-strategies.dev.js.map +0 -1
  104. data/lib/vendor/workbox-v3.3.1/workbox-strategies.prod.js +0 -3
  105. data/lib/vendor/workbox-v3.3.1/workbox-strategies.prod.js.map +0 -1
  106. data/lib/vendor/workbox-v3.3.1/workbox-streams.dev.js +0 -390
  107. data/lib/vendor/workbox-v3.3.1/workbox-streams.dev.js.map +0 -1
  108. data/lib/vendor/workbox-v3.3.1/workbox-streams.prod.js +0 -3
  109. data/lib/vendor/workbox-v3.3.1/workbox-streams.prod.js.map +0 -1
  110. data/lib/vendor/workbox-v3.3.1/workbox-sw.js +0 -3
  111. data/lib/vendor/workbox-v3.3.1/workbox-sw.js.map +0 -1
@@ -1 +0,0 @@
1
- {"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.3.1'] = 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<Array>}\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<string|null>}\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<PrecacheEntry>} 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<Object>} entriesToPrecache\n * @param {Array<Object>} 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<string>} deletedCacheRequests\n * @param {Array<string>} 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-precachig\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, ['headers', 'status', 'statusText'].map(function (key) {\n return clonedResponse[key];\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<module:workbox-precaching.PrecacheController.PrecacheEntry|string>\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 {Array<Object>} options.plugins Plugins to be used for fetching\n * and caching during install.\n * @return {\n * Promise<workbox.precaching.InstallResult>}\n */\n install(options = {}) {\n var _this = this;\n\n return babelHelpers.asyncToGenerator(function* () {\n {\n if (options.suppressWarnings !== true) {\n showWarningsIfNeeded(_this._entriesToCacheMap);\n }\n\n if (options.plugins) {\n assert_mjs.assert.isArray(options.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(precacheEntry, options.plugins);\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<Object>} options.plugins Plugins to be used for fetching\n * and caching during install.\n * @return {\n * Promise<workbox.precaching.CleanupResult>}\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(_this2._cacheName, request, response, options.plugins);\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 {BaseCacheEntry} precacheEntry The entry to fetch and cache.\n * @param {Array<Object>} plugins Array of plugins to apply to fetch and\n * caching.\n * @return {Promise<boolean>} 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, plugins) {\n var _this3 = this;\n\n return babelHelpers.asyncToGenerator(function* () {\n let response = yield fetchWrapper_mjs.fetchWrapper.fetch(precacheEntry._networkRequest, null, plugins);\n\n if (response.redirected) {\n response = yield cleanRedirect(response);\n }\n\n yield cacheWrapper_mjs.cacheWrapper.put(_this3._getTempCacheName(), precacheEntry._cacheRequest, response, plugins);\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<workbox.precaching.CleanupResult>}\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<string>} expectedCacheUrls Array of URLs that are\n * expected to be cached.\n * @return {Promise<Array<string>>} 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<string>} expectedCacheUrls Array of URLs that are\n * expected to be cached.\n * @return {Promise<Array<string>>} 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<string>} 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<Object|string>} 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 suppressWarnings,\n plugins\n }));\n });\n self.addEventListener('activate', event => {\n event.waitUntil(precacheController.activate({\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<RegExp>} [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<Object|string>} 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<Object>} 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"}
@@ -1,3 +0,0 @@
1
- this.workbox=this.workbox||{},this.workbox.precaching=function(e,t,n,r,s){"use strict";try{self.workbox.v["workbox:precaching:3.3.1"]=1}catch(e){}class i{constructor(e,t,n,r){this.e=e,this.t=t,this.n=n;const s=new Request(t,{credentials:"same-origin"});this.r=s,this.s=r?this.i(s):s}i(e){let t=e.url;const n={credentials:"same-origin"};if("cache"in Request.prototype)n.cache="reload";else{const e=new URL(t,location),n=encodeURIComponent;e.search+=(e.search?"&":"")+n("_workbox-cache-bust")+"="+n(this.n),t=e.toString()}return new Request(t,n)}}const c="revision",o="url",l="precached-details-models";class a{constructor(t){const n=t.replace(/[^\w-]/g,"_");this.c=new e.DBWrapper(n,2,{onupgradeneeded:this.o})}o(e){const t=e.target.result;e.oldVersion<2&&(t.objectStoreNames.contains("workbox-precaching")&&t.deleteObjectStore("workbox-precaching"),t.objectStoreNames.contains(l)&&t.deleteObjectStore(l)),t.createObjectStore(l)}l(e,t){var n=this;return babelHelpers.asyncToGenerator(function*(){return(yield n.a(t.t))===t.n&&!!(yield(yield caches.open(e)).match(t.r))})()}u(){var e=this;return babelHelpers.asyncToGenerator(function*(){return yield e.c.getAllMatching(l,{includeKeys:!0})})()}a(e){var t=this;return babelHelpers.asyncToGenerator(function*(){const n=yield t.c.get(l,e);return n?n[c]:null})()}d(e){var t=this;return babelHelpers.asyncToGenerator(function*(){yield t.c.put(l,{[c]:e.n,[o]:e.r.url},e.t)})()}h(e){var t=this;return babelHelpers.asyncToGenerator(function*(){yield t.c.delete(l,e)})()}}const u=(d=babelHelpers.asyncToGenerator(function*(e){const t=e.clone(),n=yield"body"in t?Promise.resolve(t.body):t.blob();return new Response(n,["headers","status","statusText"].map(function(e){return t[e]}))}),function(e){return d.apply(this,arguments)});var d;class h{constructor(e){this.f=t.cacheNames.getPrecacheName(e),this.y=new Map,this.p=new a(this.f)}addToCacheList(e){e.map(e=>{this.b(this.w(e))})}w(e){switch(typeof e){case"string":return new i(e,e,e);case"object":return new i(e,e.url,e.revision||e.url,!!e.revision);default:throw new n.WorkboxError("add-to-cache-list-unexpected-type",{entry:e})}}b(e){const t=this.y.get(e.t);if(t){if(t.n!==e.n)throw new n.WorkboxError("add-to-cache-list-conflicting-entries",{firstEntry:t.e,secondEntry:e.e})}else this.y.set(e.t,e)}install(e={}){var t=this;return babelHelpers.asyncToGenerator(function*(){const n=yield caches.open(t.g()),r=yield n.keys();yield Promise.all(r.map(function(e){return n.delete(e)}));const s=[],i=[];for(const e of t.y.values())(yield t.p.l(t.f,e))?i.push(e):s.push(e);return yield Promise.all(s.map(function(n){return t.R(n,e.plugins)})),{updatedEntries:s,notUpdatedEntries:i}})()}activate(e={}){var t=this;return babelHelpers.asyncToGenerator(function*(){const n=yield caches.open(t.g()),r=yield n.keys();for(const i of r){const r=yield n.match(i);yield s.cacheWrapper.put(t.f,i,r,e.plugins),yield n.delete(i)}return t.m()})()}g(){return`${this.f}-temp`}R(e,t){var n=this;return babelHelpers.asyncToGenerator(function*(){let i=yield r.fetchWrapper.fetch(e.s,null,t);return i.redirected&&(i=yield u(i)),yield s.cacheWrapper.put(n.g(),e.r,i,t),yield n.p.d(e),!0})()}m(){var e=this;return babelHelpers.asyncToGenerator(function*(){const t=[];e.y.forEach(function(e){const n=new URL(e.r.url,location).toString();t.push(n)});const[n,r]=yield Promise.all([e._(t),e.U(t)]);return{deletedCacheRequests:n,deletedRevisionDetails:r}})()}_(e){var t=this;return babelHelpers.asyncToGenerator(function*(){if(!(yield caches.has(t.f)))return[];const n=yield caches.open(t.f),r=(yield n.keys()).filter(function(t){return!e.includes(new URL(t.url,location).toString())});return yield Promise.all(r.map(function(e){return n.delete(e)})),r.map(function(e){return e.url})})()}U(e){var t=this;return babelHelpers.asyncToGenerator(function*(){const n=(yield t.p.u()).filter(function(t){const n=new URL(t.value.url,location).toString();return!e.includes(n)});return yield Promise.all(n.map(function(e){return t.p.h(e.primaryKey)})),n.map(function(e){return e.value.url})})()}getCachedUrls(){return Array.from(this.y.keys()).map(e=>new URL(e,location).href)}}var f=Object.freeze({PrecacheController:h});let y=!1,p=!1,b=!1,w=[];const g=t.cacheNames.getPrecacheName(),R=new h(g),m=(e,{ignoreUrlParametersMatching:t=[/^utm_/],directoryIndex:n="index.html",cleanUrls:r=!0,urlManipulation:s=null}={})=>{const i=new URL(e,location);i.hash="";const c=((e,t)=>{const n=e.search.slice(1).split("&").map(e=>e.split("=")).filter(e=>t.every(t=>!t.test(e[0]))).map(e=>e.join("=")),r=new URL(e);return r.search=n.join("&"),r})(i,t);let o=[i,c];if(n&&c.pathname.endsWith("/")){const e=new URL(c);e.pathname+=n,o.push(e)}if(r){const e=new URL(c);e.pathname+=".html",o.push(e)}if(s){const e=s({url:i});o=o.concat(e)}const l=R.getCachedUrls();for(const e of o)if(-1!==l.indexOf(e.href))return e.href;return null},v={precache:e=>{R.addToCacheList(e),y||e.length<=0||(y=!0,self.addEventListener("install",e=>{e.waitUntil(R.install({suppressWarnings:b,plugins:w}))}),self.addEventListener("activate",e=>{e.waitUntil(R.activate({plugins:w}))}))},addRoute:e=>{p||(p=!0,self.addEventListener("fetch",t=>{const n=m(t.request.url,e);if(!n)return;let r=caches.open(g).then(e=>e.match(n)).then(e=>e||fetch(n));t.respondWith(r)}))},precacheAndRoute:(e,t)=>{v.precache(e),v.addRoute(t)},suppressWarnings:e=>{b=e},addPlugins:e=>{w=w.concat(e)}};return Object.assign(v,f)}(workbox.core._private,workbox.core._private,workbox.core._private,workbox.core._private,workbox.core._private);
2
-
3
- //# sourceMappingURL=workbox-precaching.prod.js.map
@@ -1 +0,0 @@
1
- {"version":3,"names":[],"mappings":"","sources":["packages/workbox-precaching/browser.mjs"],"sourcesContent":["this.workbox=this.workbox||{},this.workbox.precaching=function(e,t,n,r,s){\"use strict\";try{self.workbox.v[\"workbox:precaching:3.3.1\"]=1}catch(e){}class i{constructor(e,t,n,r){this.e=e,this.t=t,this.n=n;const s=new Request(t,{credentials:\"same-origin\"});this.r=s,this.s=r?this.i(s):s}i(e){let t=e.url;const n={credentials:\"same-origin\"};if(\"cache\"in Request.prototype)n.cache=\"reload\";else{const e=new URL(t,location),n=encodeURIComponent;e.search+=(e.search?\"&\":\"\")+n(\"_workbox-cache-bust\")+\"=\"+n(this.n),t=e.toString()}return new Request(t,n)}}const c=\"revision\",o=\"url\",l=\"precached-details-models\";class a{constructor(t){const n=t.replace(/[^\\w-]/g,\"_\");this.c=new e.DBWrapper(n,2,{onupgradeneeded:this.o})}o(e){const t=e.target.result;e.oldVersion<2&&(t.objectStoreNames.contains(\"workbox-precaching\")&&t.deleteObjectStore(\"workbox-precaching\"),t.objectStoreNames.contains(l)&&t.deleteObjectStore(l)),t.createObjectStore(l)}l(e,t){var n=this;return babelHelpers.asyncToGenerator(function*(){return(yield n.a(t.t))===t.n&&!!(yield(yield caches.open(e)).match(t.r))})()}u(){var e=this;return babelHelpers.asyncToGenerator(function*(){return yield e.c.getAllMatching(l,{includeKeys:!0})})()}a(e){var t=this;return babelHelpers.asyncToGenerator(function*(){const n=yield t.c.get(l,e);return n?n[c]:null})()}d(e){var t=this;return babelHelpers.asyncToGenerator(function*(){yield t.c.put(l,{[c]:e.n,[o]:e.r.url},e.t)})()}h(e){var t=this;return babelHelpers.asyncToGenerator(function*(){yield t.c.delete(l,e)})()}}const u=(d=babelHelpers.asyncToGenerator(function*(e){const t=e.clone(),n=yield\"body\"in t?Promise.resolve(t.body):t.blob();return new Response(n,[\"headers\",\"status\",\"statusText\"].map(function(e){return t[e]}))}),function(e){return d.apply(this,arguments)});var d;class h{constructor(e){this.f=t.cacheNames.getPrecacheName(e),this.y=new Map,this.p=new a(this.f)}addToCacheList(e){e.map(e=>{this.b(this.w(e))})}w(e){switch(typeof e){case\"string\":return new i(e,e,e);case\"object\":return new i(e,e.url,e.revision||e.url,!!e.revision);default:throw new n.WorkboxError(\"add-to-cache-list-unexpected-type\",{entry:e})}}b(e){const t=this.y.get(e.t);if(t){if(t.n!==e.n)throw new n.WorkboxError(\"add-to-cache-list-conflicting-entries\",{firstEntry:t.e,secondEntry:e.e})}else this.y.set(e.t,e)}install(e={}){var t=this;return babelHelpers.asyncToGenerator(function*(){const n=yield caches.open(t.g()),r=yield n.keys();yield Promise.all(r.map(function(e){return n.delete(e)}));const s=[],i=[];for(const e of t.y.values())(yield t.p.l(t.f,e))?i.push(e):s.push(e);return yield Promise.all(s.map(function(n){return t.R(n,e.plugins)})),{updatedEntries:s,notUpdatedEntries:i}})()}activate(e={}){var t=this;return babelHelpers.asyncToGenerator(function*(){const n=yield caches.open(t.g()),r=yield n.keys();for(const i of r){const r=yield n.match(i);yield s.cacheWrapper.put(t.f,i,r,e.plugins),yield n.delete(i)}return t.m()})()}g(){return`${this.f}-temp`}R(e,t){var n=this;return babelHelpers.asyncToGenerator(function*(){let i=yield r.fetchWrapper.fetch(e.s,null,t);return i.redirected&&(i=yield u(i)),yield s.cacheWrapper.put(n.g(),e.r,i,t),yield n.p.d(e),!0})()}m(){var e=this;return babelHelpers.asyncToGenerator(function*(){const t=[];e.y.forEach(function(e){const n=new URL(e.r.url,location).toString();t.push(n)});const[n,r]=yield Promise.all([e._(t),e.U(t)]);return{deletedCacheRequests:n,deletedRevisionDetails:r}})()}_(e){var t=this;return babelHelpers.asyncToGenerator(function*(){if(!(yield caches.has(t.f)))return[];const n=yield caches.open(t.f),r=(yield n.keys()).filter(function(t){return!e.includes(new URL(t.url,location).toString())});return yield Promise.all(r.map(function(e){return n.delete(e)})),r.map(function(e){return e.url})})()}U(e){var t=this;return babelHelpers.asyncToGenerator(function*(){const n=(yield t.p.u()).filter(function(t){const n=new URL(t.value.url,location).toString();return!e.includes(n)});return yield Promise.all(n.map(function(e){return t.p.h(e.primaryKey)})),n.map(function(e){return e.value.url})})()}getCachedUrls(){return Array.from(this.y.keys()).map(e=>new URL(e,location).href)}}var f=Object.freeze({PrecacheController:h});let y=!1,p=!1,b=!1,w=[];const g=t.cacheNames.getPrecacheName(),R=new h(g),m=(e,{ignoreUrlParametersMatching:t=[/^utm_/],directoryIndex:n=\"index.html\",cleanUrls:r=!0,urlManipulation:s=null}={})=>{const i=new URL(e,location);i.hash=\"\";const c=((e,t)=>{const n=e.search.slice(1).split(\"&\").map(e=>e.split(\"=\")).filter(e=>t.every(t=>!t.test(e[0]))).map(e=>e.join(\"=\")),r=new URL(e);return r.search=n.join(\"&\"),r})(i,t);let o=[i,c];if(n&&c.pathname.endsWith(\"/\")){const e=new URL(c);e.pathname+=n,o.push(e)}if(r){const e=new URL(c);e.pathname+=\".html\",o.push(e)}if(s){const e=s({url:i});o=o.concat(e)}const l=R.getCachedUrls();for(const e of o)if(-1!==l.indexOf(e.href))return e.href;return null},v={precache:e=>{R.addToCacheList(e),y||e.length<=0||(y=!0,self.addEventListener(\"install\",e=>{e.waitUntil(R.install({suppressWarnings:b,plugins:w}))}),self.addEventListener(\"activate\",e=>{e.waitUntil(R.activate({plugins:w}))}))},addRoute:e=>{p||(p=!0,self.addEventListener(\"fetch\",t=>{const n=m(t.request.url,e);if(!n)return;let r=caches.open(g).then(e=>e.match(n)).then(e=>e||fetch(n));t.respondWith(r)}))},precacheAndRoute:(e,t)=>{v.precache(e),v.addRoute(t)},suppressWarnings:e=>{b=e},addPlugins:e=>{w=w.concat(e)}};return Object.assign(v,f)}(workbox.core._private,workbox.core._private,workbox.core._private,workbox.core._private,workbox.core._private);\n"],"file":"workbox-precaching.prod.js"}
@@ -1,299 +0,0 @@
1
- this.workbox = this.workbox || {};
2
- this.workbox.rangeRequests = (function (exports,WorkboxError_mjs,assert_mjs,logger_mjs) {
3
- 'use strict';
4
-
5
- try {
6
- self.workbox.v['workbox:range-requests:3.3.1'] = 1;
7
- } catch (e) {} // eslint-disable-line
8
-
9
- /*
10
- Copyright 2017 Google Inc.
11
-
12
- Licensed under the Apache License, Version 2.0 (the "License");
13
- you may not use this file except in compliance with the License.
14
- You may obtain a copy of the License at
15
-
16
- https://www.apache.org/licenses/LICENSE-2.0
17
-
18
- Unless required by applicable law or agreed to in writing, software
19
- distributed under the License is distributed on an "AS IS" BASIS,
20
- WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
21
- See the License for the specific language governing permissions and
22
- limitations under the License.
23
- */
24
-
25
- /**
26
- * @param {Blob} blob A source blob.
27
- * @param {number|null} start The offset to use as the start of the
28
- * slice.
29
- * @param {number|null} end The offset to use as the end of the slice.
30
- * @return {Object} An object with `start` and `end` properties, reflecting
31
- * the effective boundaries to use given the size of the blob.
32
- *
33
- * @private
34
- */
35
- function calculateEffectiveBoundaries(blob, start, end) {
36
- {
37
- assert_mjs.assert.isInstance(blob, Blob, {
38
- moduleName: 'workbox-range-requests',
39
- funcName: 'calculateEffectiveBoundaries',
40
- paramName: 'blob'
41
- });
42
- }
43
-
44
- const blobSize = blob.size;
45
-
46
- if (end > blobSize || start < 0) {
47
- throw new WorkboxError_mjs.WorkboxError('range-not-satisfiable', {
48
- size: blobSize,
49
- end,
50
- start
51
- });
52
- }
53
-
54
- let effectiveStart;
55
- let effectiveEnd;
56
-
57
- if (start === null) {
58
- effectiveStart = blobSize - end;
59
- effectiveEnd = blobSize;
60
- } else if (end === null) {
61
- effectiveStart = start;
62
- effectiveEnd = blobSize;
63
- } else {
64
- effectiveStart = start;
65
- // Range values are inclusive, so add 1 to the value.
66
- effectiveEnd = end + 1;
67
- }
68
-
69
- return {
70
- start: effectiveStart,
71
- end: effectiveEnd
72
- };
73
- }
74
-
75
- /*
76
- Copyright 2017 Google Inc.
77
-
78
- Licensed under the Apache License, Version 2.0 (the "License");
79
- you may not use this file except in compliance with the License.
80
- You may obtain a copy of the License at
81
-
82
- https://www.apache.org/licenses/LICENSE-2.0
83
-
84
- Unless required by applicable law or agreed to in writing, software
85
- distributed under the License is distributed on an "AS IS" BASIS,
86
- WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
87
- See the License for the specific language governing permissions and
88
- limitations under the License.
89
- */
90
-
91
- /**
92
- * @param {string} rangeHeader A Range: header value.
93
- * @return {Object} An object with `start` and `end` properties, reflecting
94
- * the parsed value of the Range: header. If either the `start` or `end` are
95
- * omitted, then `null` will be returned.
96
- *
97
- * @private
98
- */
99
- function parseRangeHeader(rangeHeader) {
100
- {
101
- assert_mjs.assert.isType(rangeHeader, 'string', {
102
- moduleName: 'workbox-range-requests',
103
- funcName: 'parseRangeHeader',
104
- paramName: 'rangeHeader'
105
- });
106
- }
107
-
108
- const normalizedRangeHeader = rangeHeader.trim().toLowerCase();
109
- if (!normalizedRangeHeader.startsWith('bytes=')) {
110
- throw new WorkboxError_mjs.WorkboxError('unit-must-be-bytes', { normalizedRangeHeader });
111
- }
112
-
113
- // Specifying multiple ranges separate by commas is valid syntax, but this
114
- // library only attempts to handle a single, contiguous sequence of bytes.
115
- // https://developer.mozilla.org/en-US/docs/Web/HTTP/Headers/Range#Syntax
116
- if (normalizedRangeHeader.includes(',')) {
117
- throw new WorkboxError_mjs.WorkboxError('single-range-only', { normalizedRangeHeader });
118
- }
119
-
120
- const rangeParts = /(\d*)-(\d*)/.exec(normalizedRangeHeader);
121
- // We need either at least one of the start or end values.
122
- if (rangeParts === null || !(rangeParts[1] || rangeParts[2])) {
123
- throw new WorkboxError_mjs.WorkboxError('invalid-range-values', { normalizedRangeHeader });
124
- }
125
-
126
- return {
127
- start: rangeParts[1] === '' ? null : Number(rangeParts[1]),
128
- end: rangeParts[2] === '' ? null : Number(rangeParts[2])
129
- };
130
- }
131
-
132
- /**
133
- * Given a `Request` and `Response` objects as input, this will return a
134
- * promise for a new `Response`.
135
- *
136
- * @param {Request} request A request, which should contain a Range:
137
- * header.
138
- * @param {Response} originalResponse An original response containing the full
139
- * content.
140
- * @return {Promise<Response>} Either a `206 Partial Content` response, with
141
- * the response body set to the slice of content specified by the request's
142
- * `Range:` header, or a `416 Range Not Satisfiable` response if the
143
- * conditions of the `Range:` header can't be met.
144
- *
145
- * @memberof workbox.rangeRequests
146
- */
147
- let createPartialResponse = (() => {
148
- var _ref = babelHelpers.asyncToGenerator(function* (request, originalResponse) {
149
- try {
150
- {
151
- assert_mjs.assert.isInstance(request, Request, {
152
- moduleName: 'workbox-range-requests',
153
- funcName: 'createPartialResponse',
154
- paramName: 'request'
155
- });
156
-
157
- assert_mjs.assert.isInstance(originalResponse, Response, {
158
- moduleName: 'workbox-range-requests',
159
- funcName: 'createPartialResponse',
160
- paramName: 'originalResponse'
161
- });
162
- }
163
-
164
- const rangeHeader = request.headers.get('range');
165
- if (!rangeHeader) {
166
- throw new WorkboxError_mjs.WorkboxError('no-range-header');
167
- }
168
-
169
- const boundaries = parseRangeHeader(rangeHeader);
170
- const originalBlob = yield originalResponse.blob();
171
-
172
- const effectiveBoundaries = calculateEffectiveBoundaries(originalBlob, boundaries.start, boundaries.end);
173
-
174
- const slicedBlob = originalBlob.slice(effectiveBoundaries.start, effectiveBoundaries.end);
175
- const slicedBlobSize = slicedBlob.size;
176
-
177
- const slicedResponse = new Response(slicedBlob, {
178
- // Status code 206 is for a Partial Content response.
179
- // See https://developer.mozilla.org/en-US/docs/Web/HTTP/Status/206
180
- status: 206,
181
- statusText: 'Partial Content',
182
- headers: originalResponse.headers
183
- });
184
-
185
- slicedResponse.headers.set('Content-Length', slicedBlobSize);
186
- slicedResponse.headers.set('Content-Range', `bytes ${effectiveBoundaries.start}-${effectiveBoundaries.end - 1}/` + originalBlob.size);
187
-
188
- return slicedResponse;
189
- } catch (error) {
190
- {
191
- logger_mjs.logger.warn(`Unable to construct a partial response; returning a ` + `416 Range Not Satisfiable response instead.`);
192
- logger_mjs.logger.groupCollapsed(`View details here.`);
193
- logger_mjs.logger.unprefixed.log(error);
194
- logger_mjs.logger.unprefixed.log(request);
195
- logger_mjs.logger.unprefixed.log(originalResponse);
196
- logger_mjs.logger.groupEnd();
197
- }
198
-
199
- return new Response('', {
200
- status: 416,
201
- statusText: 'Range Not Satisfiable'
202
- });
203
- }
204
- });
205
-
206
- return function createPartialResponse(_x, _x2) {
207
- return _ref.apply(this, arguments);
208
- };
209
- })();
210
-
211
- /*
212
- Copyright 2016 Google Inc. All Rights Reserved.
213
- Licensed under the Apache License, Version 2.0 (the "License");
214
- you may not use this file except in compliance with the License.
215
- You may obtain a copy of the License at
216
- http://www.apache.org/licenses/LICENSE-2.0
217
- Unless required by applicable law or agreed to in writing, software
218
- distributed under the License is distributed on an "AS IS" BASIS,
219
- WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
220
- See the License for the specific language governing permissions and
221
- limitations under the License.
222
- */
223
-
224
- /**
225
- * The range request plugin makes it easy for a request with a 'Range' header to
226
- * be fulfilled by a cached response.
227
- *
228
- * It does this by intercepting the `cachedResponseWillBeUsed` plugin callback
229
- * and returning the appropriate subset of the cached response body.
230
- *
231
- * @memberof workbox.rangeRequests
232
- */
233
- class Plugin {
234
- /**
235
- * @param {Object} options
236
- * @param {Request} options.request The original request, which may or may not
237
- * contain a Range: header.
238
- * @param {Response} options.cachedResponse The complete cached response.
239
- * @return {Promise<Response>} If request contains a 'Range' header, then a
240
- * new response with status 206 whose body is a subset of `cachedResponse` is
241
- * returned. Otherwise, `cachedResponse` is returned as-is.
242
- *
243
- * @private
244
- */
245
- cachedResponseWillBeUsed({ request, cachedResponse }) {
246
- return babelHelpers.asyncToGenerator(function* () {
247
- // Only return a sliced response if there's something valid in the cache,
248
- // and there's a Range: header in the request.
249
- if (cachedResponse && request.headers.has('range')) {
250
- return yield createPartialResponse(request, cachedResponse);
251
- }
252
-
253
- // If there was no Range: header, or if cachedResponse wasn't valid, just
254
- // pass it through as-is.
255
- return cachedResponse;
256
- })();
257
- }
258
- }
259
-
260
- /*
261
- Copyright 2017 Google Inc.
262
-
263
- Licensed under the Apache License, Version 2.0 (the "License");
264
- you may not use this file except in compliance with the License.
265
- You may obtain a copy of the License at
266
-
267
- https://www.apache.org/licenses/LICENSE-2.0
268
-
269
- Unless required by applicable law or agreed to in writing, software
270
- distributed under the License is distributed on an "AS IS" BASIS,
271
- WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
272
- See the License for the specific language governing permissions and
273
- limitations under the License.
274
- */
275
-
276
- /*
277
- Copyright 2017 Google Inc.
278
-
279
- Licensed under the Apache License, Version 2.0 (the "License");
280
- you may not use this file except in compliance with the License.
281
- You may obtain a copy of the License at
282
-
283
- https://www.apache.org/licenses/LICENSE-2.0
284
-
285
- Unless required by applicable law or agreed to in writing, software
286
- distributed under the License is distributed on an "AS IS" BASIS,
287
- WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
288
- See the License for the specific language governing permissions and
289
- limitations under the License.
290
- */
291
-
292
- exports.createPartialResponse = createPartialResponse;
293
- exports.Plugin = Plugin;
294
-
295
- return exports;
296
-
297
- }({},workbox.core._private,workbox.core._private,workbox.core._private));
298
-
299
- //# sourceMappingURL=workbox-range-requests.dev.js.map
@@ -1 +0,0 @@
1
- {"version":3,"names":[],"mappings":"","sources":["packages/workbox-range-requests/browser.mjs"],"sourcesContent":["this.workbox = this.workbox || {};\nthis.workbox.rangeRequests = (function (exports,WorkboxError_mjs,assert_mjs,logger_mjs) {\n 'use strict';\n\n try {\n self.workbox.v['workbox:range-requests:3.3.1'] = 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 * @param {Blob} blob A source blob.\n * @param {number|null} start The offset to use as the start of the\n * slice.\n * @param {number|null} end The offset to use as the end of the slice.\n * @return {Object} An object with `start` and `end` properties, reflecting\n * the effective boundaries to use given the size of the blob.\n *\n * @private\n */\n function calculateEffectiveBoundaries(blob, start, end) {\n {\n assert_mjs.assert.isInstance(blob, Blob, {\n moduleName: 'workbox-range-requests',\n funcName: 'calculateEffectiveBoundaries',\n paramName: 'blob'\n });\n }\n\n const blobSize = blob.size;\n\n if (end > blobSize || start < 0) {\n throw new WorkboxError_mjs.WorkboxError('range-not-satisfiable', {\n size: blobSize,\n end,\n start\n });\n }\n\n let effectiveStart;\n let effectiveEnd;\n\n if (start === null) {\n effectiveStart = blobSize - end;\n effectiveEnd = blobSize;\n } else if (end === null) {\n effectiveStart = start;\n effectiveEnd = blobSize;\n } else {\n effectiveStart = start;\n // Range values are inclusive, so add 1 to the value.\n effectiveEnd = end + 1;\n }\n\n return {\n start: effectiveStart,\n end: effectiveEnd\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 * @param {string} rangeHeader A Range: header value.\n * @return {Object} An object with `start` and `end` properties, reflecting\n * the parsed value of the Range: header. If either the `start` or `end` are\n * omitted, then `null` will be returned.\n *\n * @private\n */\n function parseRangeHeader(rangeHeader) {\n {\n assert_mjs.assert.isType(rangeHeader, 'string', {\n moduleName: 'workbox-range-requests',\n funcName: 'parseRangeHeader',\n paramName: 'rangeHeader'\n });\n }\n\n const normalizedRangeHeader = rangeHeader.trim().toLowerCase();\n if (!normalizedRangeHeader.startsWith('bytes=')) {\n throw new WorkboxError_mjs.WorkboxError('unit-must-be-bytes', { normalizedRangeHeader });\n }\n\n // Specifying multiple ranges separate by commas is valid syntax, but this\n // library only attempts to handle a single, contiguous sequence of bytes.\n // https://developer.mozilla.org/en-US/docs/Web/HTTP/Headers/Range#Syntax\n if (normalizedRangeHeader.includes(',')) {\n throw new WorkboxError_mjs.WorkboxError('single-range-only', { normalizedRangeHeader });\n }\n\n const rangeParts = /(\\d*)-(\\d*)/.exec(normalizedRangeHeader);\n // We need either at least one of the start or end values.\n if (rangeParts === null || !(rangeParts[1] || rangeParts[2])) {\n throw new WorkboxError_mjs.WorkboxError('invalid-range-values', { normalizedRangeHeader });\n }\n\n return {\n start: rangeParts[1] === '' ? null : Number(rangeParts[1]),\n end: rangeParts[2] === '' ? null : Number(rangeParts[2])\n };\n }\n\n /**\n * Given a `Request` and `Response` objects as input, this will return a\n * promise for a new `Response`.\n *\n * @param {Request} request A request, which should contain a Range:\n * header.\n * @param {Response} originalResponse An original response containing the full\n * content.\n * @return {Promise<Response>} Either a `206 Partial Content` response, with\n * the response body set to the slice of content specified by the request's\n * `Range:` header, or a `416 Range Not Satisfiable` response if the\n * conditions of the `Range:` header can't be met.\n *\n * @memberof workbox.rangeRequests\n */\n let createPartialResponse = (() => {\n var _ref = babelHelpers.asyncToGenerator(function* (request, originalResponse) {\n try {\n {\n assert_mjs.assert.isInstance(request, Request, {\n moduleName: 'workbox-range-requests',\n funcName: 'createPartialResponse',\n paramName: 'request'\n });\n\n assert_mjs.assert.isInstance(originalResponse, Response, {\n moduleName: 'workbox-range-requests',\n funcName: 'createPartialResponse',\n paramName: 'originalResponse'\n });\n }\n\n const rangeHeader = request.headers.get('range');\n if (!rangeHeader) {\n throw new WorkboxError_mjs.WorkboxError('no-range-header');\n }\n\n const boundaries = parseRangeHeader(rangeHeader);\n const originalBlob = yield originalResponse.blob();\n\n const effectiveBoundaries = calculateEffectiveBoundaries(originalBlob, boundaries.start, boundaries.end);\n\n const slicedBlob = originalBlob.slice(effectiveBoundaries.start, effectiveBoundaries.end);\n const slicedBlobSize = slicedBlob.size;\n\n const slicedResponse = new Response(slicedBlob, {\n // Status code 206 is for a Partial Content response.\n // See https://developer.mozilla.org/en-US/docs/Web/HTTP/Status/206\n status: 206,\n statusText: 'Partial Content',\n headers: originalResponse.headers\n });\n\n slicedResponse.headers.set('Content-Length', slicedBlobSize);\n slicedResponse.headers.set('Content-Range', `bytes ${effectiveBoundaries.start}-${effectiveBoundaries.end - 1}/` + originalBlob.size);\n\n return slicedResponse;\n } catch (error) {\n {\n logger_mjs.logger.warn(`Unable to construct a partial response; returning a ` + `416 Range Not Satisfiable response instead.`);\n logger_mjs.logger.groupCollapsed(`View details here.`);\n logger_mjs.logger.unprefixed.log(error);\n logger_mjs.logger.unprefixed.log(request);\n logger_mjs.logger.unprefixed.log(originalResponse);\n logger_mjs.logger.groupEnd();\n }\n\n return new Response('', {\n status: 416,\n statusText: 'Range Not Satisfiable'\n });\n }\n });\n\n return function createPartialResponse(_x, _x2) {\n return _ref.apply(this, arguments);\n };\n })();\n\n /*\n Copyright 2016 Google Inc. All Rights Reserved.\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 http://www.apache.org/licenses/LICENSE-2.0\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 * The range request plugin makes it easy for a request with a 'Range' header to\n * be fulfilled by a cached response.\n *\n * It does this by intercepting the `cachedResponseWillBeUsed` plugin callback\n * and returning the appropriate subset of the cached response body.\n *\n * @memberof workbox.rangeRequests\n */\n class Plugin {\n /**\n * @param {Object} options\n * @param {Request} options.request The original request, which may or may not\n * contain a Range: header.\n * @param {Response} options.cachedResponse The complete cached response.\n * @return {Promise<Response>} If request contains a 'Range' header, then a\n * new response with status 206 whose body is a subset of `cachedResponse` is\n * returned. Otherwise, `cachedResponse` is returned as-is.\n *\n * @private\n */\n cachedResponseWillBeUsed({ request, cachedResponse }) {\n return babelHelpers.asyncToGenerator(function* () {\n // Only return a sliced response if there's something valid in the cache,\n // and there's a Range: header in the request.\n if (cachedResponse && request.headers.has('range')) {\n return yield createPartialResponse(request, cachedResponse);\n }\n\n // If there was no Range: header, or if cachedResponse wasn't valid, just\n // pass it through as-is.\n return cachedResponse;\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 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 exports.createPartialResponse = createPartialResponse;\n exports.Plugin = Plugin;\n\n return exports;\n\n}({},workbox.core._private,workbox.core._private,workbox.core._private));\n"],"file":"workbox-range-requests.dev.js"}
@@ -1,3 +0,0 @@
1
- this.workbox=this.workbox||{},this.workbox.rangeRequests=function(e,n){"use strict";try{self.workbox.v["workbox:range-requests:3.3.1"]=1}catch(e){}let t=(r=babelHelpers.asyncToGenerator(function*(e,t){try{const r=e.headers.get("range");if(!r)throw new n.WorkboxError("no-range-header");const s=function(e){const t=e.trim().toLowerCase();if(!t.startsWith("bytes="))throw new n.WorkboxError("unit-must-be-bytes",{normalizedRangeHeader:t});if(t.includes(","))throw new n.WorkboxError("single-range-only",{normalizedRangeHeader:t});const r=/(\d*)-(\d*)/.exec(t);if(null===r||!r[1]&&!r[2])throw new n.WorkboxError("invalid-range-values",{normalizedRangeHeader:t});return{start:""===r[1]?null:Number(r[1]),end:""===r[2]?null:Number(r[2])}}(r),a=yield t.blob(),i=function(e,t,r){const s=e.size;if(r>s||t<0)throw new n.WorkboxError("range-not-satisfiable",{size:s,end:r,start:t});let a,i;return null===t?(a=s-r,i=s):null===r?(a=t,i=s):(a=t,i=r+1),{start:a,end:i}}(a,s.start,s.end),l=a.slice(i.start,i.end),o=l.size,u=new Response(l,{status:206,statusText:"Partial Content",headers:t.headers});return u.headers.set("Content-Length",o),u.headers.set("Content-Range",`bytes ${i.start}-${i.end-1}/`+a.size),u}catch(e){return new Response("",{status:416,statusText:"Range Not Satisfiable"})}}),function(e,n){return r.apply(this,arguments)});var r;return e.createPartialResponse=t,e.Plugin=class{cachedResponseWillBeUsed({request:e,cachedResponse:n}){return babelHelpers.asyncToGenerator(function*(){return n&&e.headers.has("range")?yield t(e,n):n})()}},e}({},workbox.core._private);
2
-
3
- //# sourceMappingURL=workbox-range-requests.prod.js.map
@@ -1 +0,0 @@
1
- {"version":3,"names":[],"mappings":"","sources":["packages/workbox-range-requests/browser.mjs"],"sourcesContent":["this.workbox=this.workbox||{},this.workbox.rangeRequests=function(e,n){\"use strict\";try{self.workbox.v[\"workbox:range-requests:3.3.1\"]=1}catch(e){}let t=(r=babelHelpers.asyncToGenerator(function*(e,t){try{const r=e.headers.get(\"range\");if(!r)throw new n.WorkboxError(\"no-range-header\");const s=function(e){const t=e.trim().toLowerCase();if(!t.startsWith(\"bytes=\"))throw new n.WorkboxError(\"unit-must-be-bytes\",{normalizedRangeHeader:t});if(t.includes(\",\"))throw new n.WorkboxError(\"single-range-only\",{normalizedRangeHeader:t});const r=/(\\d*)-(\\d*)/.exec(t);if(null===r||!r[1]&&!r[2])throw new n.WorkboxError(\"invalid-range-values\",{normalizedRangeHeader:t});return{start:\"\"===r[1]?null:Number(r[1]),end:\"\"===r[2]?null:Number(r[2])}}(r),a=yield t.blob(),i=function(e,t,r){const s=e.size;if(r>s||t<0)throw new n.WorkboxError(\"range-not-satisfiable\",{size:s,end:r,start:t});let a,i;return null===t?(a=s-r,i=s):null===r?(a=t,i=s):(a=t,i=r+1),{start:a,end:i}}(a,s.start,s.end),l=a.slice(i.start,i.end),o=l.size,u=new Response(l,{status:206,statusText:\"Partial Content\",headers:t.headers});return u.headers.set(\"Content-Length\",o),u.headers.set(\"Content-Range\",`bytes ${i.start}-${i.end-1}/`+a.size),u}catch(e){return new Response(\"\",{status:416,statusText:\"Range Not Satisfiable\"})}}),function(e,n){return r.apply(this,arguments)});var r;return e.createPartialResponse=t,e.Plugin=class{cachedResponseWillBeUsed({request:e,cachedResponse:n}){return babelHelpers.asyncToGenerator(function*(){return n&&e.headers.has(\"range\")?yield t(e,n):n})()}},e}({},workbox.core._private);\n"],"file":"workbox-range-requests.prod.js"}
@@ -1,863 +0,0 @@
1
- this.workbox = this.workbox || {};
2
- this.workbox.routing = (function (assert_mjs,logger_mjs,WorkboxError_mjs,getFriendlyURL_mjs,cacheNames_mjs) {
3
- 'use strict';
4
-
5
- try {
6
- self.workbox.v['workbox:routing:3.3.1'] = 1;
7
- } catch (e) {} // eslint-disable-line
8
-
9
- /*
10
- Copyright 2017 Google Inc. All Rights Reserved.
11
- Licensed under the Apache License, Version 2.0 (the "License");
12
- you may not use this file except in compliance with the License.
13
- You may obtain a copy of the License at
14
-
15
- http://www.apache.org/licenses/LICENSE-2.0
16
-
17
- Unless required by applicable law or agreed to in writing, software
18
- distributed under the License is distributed on an "AS IS" BASIS,
19
- WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
20
- See the License for the specific language governing permissions and
21
- limitations under the License.
22
- */
23
-
24
- /**
25
- * The default HTTP method, 'GET', used when there's no specific method
26
- * configured for a route.
27
- *
28
- * @type {string}
29
- *
30
- * @private
31
- */
32
- const defaultMethod = 'GET';
33
-
34
- /**
35
- * The list of valid HTTP methods associated with requests that could be routed.
36
- *
37
- * @type {Array<string>}
38
- *
39
- * @private
40
- */
41
- const validMethods = ['DELETE', 'GET', 'HEAD', 'POST', 'PUT'];
42
-
43
- /*
44
- Copyright 2017 Google Inc. All Rights Reserved.
45
- Licensed under the Apache License, Version 2.0 (the "License");
46
- you may not use this file except in compliance with the License.
47
- You may obtain a copy of the License at
48
-
49
- http://www.apache.org/licenses/LICENSE-2.0
50
-
51
- Unless required by applicable law or agreed to in writing, software
52
- distributed under the License is distributed on an "AS IS" BASIS,
53
- WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
54
- See the License for the specific language governing permissions and
55
- limitations under the License.
56
- */
57
-
58
- /**
59
- * @param {function()|Object} handler Either a function, or an object with a
60
- * 'handle' method.
61
- * @return {Object} An object with a handle method.
62
- *
63
- * @private
64
- */
65
- var normalizeHandler = (handler => {
66
- if (handler && typeof handler === 'object') {
67
- {
68
- assert_mjs.assert.hasMethod(handler, 'handle', {
69
- moduleName: 'workbox-routing',
70
- className: 'Route',
71
- funcName: 'constructor',
72
- paramName: 'handler'
73
- });
74
- }
75
- return handler;
76
- } else {
77
- {
78
- assert_mjs.assert.isType(handler, 'function', {
79
- moduleName: 'workbox-routing',
80
- className: 'Route',
81
- funcName: 'constructor',
82
- paramName: 'handler'
83
- });
84
- }
85
- return { handle: handler };
86
- }
87
- });
88
-
89
- /*
90
- Copyright 2017 Google Inc. All Rights Reserved.
91
- Licensed under the Apache License, Version 2.0 (the "License");
92
- you may not use this file except in compliance with the License.
93
- You may obtain a copy of the License at
94
-
95
- http://www.apache.org/licenses/LICENSE-2.0
96
-
97
- Unless required by applicable law or agreed to in writing, software
98
- distributed under the License is distributed on an "AS IS" BASIS,
99
- WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
100
- See the License for the specific language governing permissions and
101
- limitations under the License.
102
- */
103
-
104
- /**
105
- * A `Route` consists of a pair of callback functions, "match" and "handler".
106
- * The "match" callback determine if a route should be used to "handle" a
107
- * request by returning a non-falsy value if it can. The "handler" callback
108
- * is called when there is a match and should return a Promise that resolves
109
- * to a `Response`.
110
- *
111
- * @memberof workbox.routing
112
- */
113
- class Route {
114
- /**
115
- * Constructor for Route class.
116
- *
117
- * @param {workbox.routing.Route~matchCallback} match
118
- * A callback function that determines whether the route matches a given
119
- * `fetch` event by returning a non-falsy value.
120
- * @param {workbox.routing.Route~handlerCallback} handler A callback
121
- * function that returns a Promise resolving to a Response.
122
- * @param {string} [method='GET'] The HTTP method to match the Route
123
- * against.
124
- */
125
- constructor(match, handler, method) {
126
- {
127
- assert_mjs.assert.isType(match, 'function', {
128
- moduleName: 'workbox-routing',
129
- className: 'Route',
130
- funcName: 'constructor',
131
- paramName: 'match'
132
- });
133
-
134
- if (method) {
135
- assert_mjs.assert.isOneOf(method, validMethods, { paramName: 'method' });
136
- }
137
- }
138
-
139
- // These values are referenced directly by Router so cannot be
140
- // altered by minifification.
141
- this.handler = normalizeHandler(handler);
142
- this.match = match;
143
- this.method = method || defaultMethod;
144
- }
145
- }
146
-
147
- /*
148
- Copyright 2017 Google Inc. All Rights Reserved.
149
- Licensed under the Apache License, Version 2.0 (the "License");
150
- you may not use this file except in compliance with the License.
151
- You may obtain a copy of the License at
152
-
153
- http://www.apache.org/licenses/LICENSE-2.0
154
-
155
- Unless required by applicable law or agreed to in writing, software
156
- distributed under the License is distributed on an "AS IS" BASIS,
157
- WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
158
- See the License for the specific language governing permissions and
159
- limitations under the License.
160
- */
161
-
162
- /**
163
- * RegExpRoute makes it easy to create a regular expression based
164
- * [Route]{@link workbox.routing.Route}.
165
- *
166
- * For same-origin requests the RegExp only needs to match part of the URL. For
167
- * requests against third-party servers, you must define a RegExp that matches
168
- * the start of the URL.
169
- *
170
- * [See the module docs for info.]{@link https://developers.google.com/web/tools/workbox/modules/workbox-routing}
171
- *
172
- * @memberof workbox.routing
173
- * @extends workbox.routing.Route
174
- */
175
- class RegExpRoute extends Route {
176
- /**
177
- * If the regulard expression contains
178
- * [capture groups]{@link https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/RegExp#grouping-back-references},
179
- * th ecaptured values will be passed to the
180
- * [handler's]{@link workbox.routing.Route~handlerCallback} `params`
181
- * argument.
182
- *
183
- * @param {RegExp} regExp The regular expression to match against URLs.
184
- * @param {workbox.routing.Route~handlerCallback} handler A callback
185
- * function that returns a Promise resulting in a Response.
186
- * @param {string} [method='GET'] The HTTP method to match the Route
187
- * against.
188
- */
189
- constructor(regExp, handler, method) {
190
- {
191
- assert_mjs.assert.isInstance(regExp, RegExp, {
192
- moduleName: 'workbox-routing',
193
- className: 'RegExpRoute',
194
- funcName: 'constructor',
195
- paramName: 'pattern'
196
- });
197
- }
198
-
199
- const match = ({ url }) => {
200
- const result = regExp.exec(url.href);
201
-
202
- // Return null immediately if there's no match.
203
- if (!result) {
204
- return null;
205
- }
206
-
207
- // Require that the match start at the first character in the URL string
208
- // if it's a cross-origin request.
209
- // See https://github.com/GoogleChrome/workbox/issues/281 for the context
210
- // behind this behavior.
211
- if (url.origin !== location.origin && result.index !== 0) {
212
- {
213
- logger_mjs.logger.debug(`The regular expression '${regExp}' only partially matched ` + `against the cross-origin URL '${url}'. RegExpRoute's will only ` + `handle cross-origin requests if they match the entire URL.`);
214
- }
215
-
216
- return null;
217
- }
218
-
219
- // If the route matches, but there aren't any capture groups defined, then
220
- // this will return [], which is truthy and therefore sufficient to
221
- // indicate a match.
222
- // If there are capture groups, then it will return their values.
223
- return result.slice(1);
224
- };
225
-
226
- super(match, handler, method);
227
- }
228
- }
229
-
230
- /*
231
- Copyright 2017 Google Inc. All Rights Reserved.
232
- Licensed under the Apache License, Version 2.0 (the "License");
233
- you may not use this file except in compliance with the License.
234
- You may obtain a copy of the License at
235
-
236
- http://www.apache.org/licenses/LICENSE-2.0
237
-
238
- Unless required by applicable law or agreed to in writing, software
239
- distributed under the License is distributed on an "AS IS" BASIS,
240
- WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
241
- See the License for the specific language governing permissions and
242
- limitations under the License.
243
- */
244
-
245
- /**
246
- * The Router can be used to process a FetchEvent through one or more
247
- * [Routes]{@link workbox.routing.Route} responding with a Request if
248
- * a matching route exists.
249
- *
250
- * If no route matches a given a request, the Router will use a "default"
251
- * handler if one is defined.
252
- *
253
- * Should the matching Route throw an error, the Router will use a "catch"
254
- * handler if one is defined to gracefully deal with issues and respond with a
255
- * Request.
256
- *
257
- * If a request matches multiple routes, the **earliest** registered route will
258
- * be used to respond to the request.
259
- *
260
- * @memberof workbox.routing
261
- */
262
- class Router {
263
- /**
264
- * Initializes a new Router.
265
- */
266
- constructor() {
267
- // _routes will contain a mapping of HTTP method name ('GET', etc.) to an
268
- // array of all the corresponding Route instances that are registered.
269
- this._routes = new Map();
270
- }
271
-
272
- /**
273
- * Apply the routing rules to a FetchEvent object to get a Response from an
274
- * appropriate Route's handler.
275
- *
276
- * @param {FetchEvent} event The event from a service worker's 'fetch' event
277
- * listener.
278
- * @return {Promise<Response>|undefined} A promise is returned if a
279
- * registered route can handle the FetchEvent's request. If there is no
280
- * matching route and there's no `defaultHandler`, `undefined` is returned.
281
- */
282
- handleRequest(event) {
283
- {
284
- assert_mjs.assert.isInstance(event, FetchEvent, {
285
- moduleName: 'workbox-routing',
286
- className: 'Router',
287
- funcName: 'handleRequest',
288
- paramName: 'event'
289
- });
290
- }
291
-
292
- const url = new URL(event.request.url);
293
- if (!url.protocol.startsWith('http')) {
294
- {
295
- logger_mjs.logger.debug(`Workbox Router only supports URLs that start with 'http'.`);
296
- }
297
- return;
298
- }
299
-
300
- let route = null;
301
- let handler = null;
302
- let params = null;
303
- let debugMessages = [];
304
-
305
- const result = this._findHandlerAndParams(event, url);
306
- handler = result.handler;
307
- params = result.params;
308
- route = result.route;
309
- {
310
- if (handler) {
311
- debugMessages.push([`Found a route to handle this request:`, route]);
312
-
313
- if (params) {
314
- debugMessages.push([`Passing the following params to the route's handler:`, params]);
315
- }
316
- }
317
- }
318
-
319
- // If we don't have a handler because there was no matching route, then
320
- // fall back to defaultHandler if that's defined.
321
- if (!handler && this._defaultHandler) {
322
- {
323
- debugMessages.push(`Failed to find a matching route. Falling ` + `back to the default handler.`);
324
-
325
- // This is used for debugging in logs in the case of an error.
326
- route = '[Default Handler]';
327
- }
328
- handler = this._defaultHandler;
329
- }
330
-
331
- if (!handler) {
332
- {
333
- // No handler so Workbox will do nothing. If logs is set of debug
334
- // i.e. verbose, we should print out this information.
335
- logger_mjs.logger.debug(`No route found for: ${getFriendlyURL_mjs.getFriendlyURL(url)}`);
336
- }
337
- return;
338
- }
339
-
340
- {
341
- // We have a handler, meaning Workbox is going to handle the route.
342
- // print the routing details to the console.
343
- logger_mjs.logger.groupCollapsed(`Router is responding to: ${getFriendlyURL_mjs.getFriendlyURL(url)}`);
344
- debugMessages.forEach(msg => {
345
- if (Array.isArray(msg)) {
346
- logger_mjs.logger.log(...msg);
347
- } else {
348
- logger_mjs.logger.log(msg);
349
- }
350
- });
351
-
352
- // The Request and Response objects contains a great deal of information,
353
- // hide it under a group in case developers want to see it.
354
- logger_mjs.logger.groupCollapsed(`View request details here.`);
355
- logger_mjs.logger.unprefixed.log(event.request);
356
- logger_mjs.logger.groupEnd();
357
-
358
- logger_mjs.logger.groupEnd();
359
- }
360
-
361
- // Wrap in try and catch in case the handle method throws a synchronous
362
- // error. It should still callback to the catch handler.
363
- let responsePromise;
364
- try {
365
- responsePromise = handler.handle({ url, event, params });
366
- } catch (err) {
367
- responsePromise = Promise.reject(err);
368
- }
369
-
370
- if (responsePromise && this._catchHandler) {
371
- responsePromise = responsePromise.catch(err => {
372
- {
373
- // Still include URL here as it will be async from the console group
374
- // and may not make sense without the URL
375
- logger_mjs.logger.groupCollapsed(`Error thrown when responding to: ` + ` ${getFriendlyURL_mjs.getFriendlyURL(url)}. Falling back to Catch Handler.`);
376
- logger_mjs.logger.unprefixed.error(`Error thrown by:`, route);
377
- logger_mjs.logger.unprefixed.error(err);
378
- logger_mjs.logger.groupEnd();
379
- }
380
- return this._catchHandler.handle({ url, event, err });
381
- });
382
- }
383
-
384
- return responsePromise;
385
- }
386
-
387
- /**
388
- * Checks the incoming `event.request` against the registered routes, and if
389
- * there's a match, returns the corresponding handler along with any params
390
- * generated by the match.
391
- *
392
- * @param {FetchEvent} event
393
- * @param {URL} url
394
- * @return {Object} Returns an object with `handler` and `params` properties.
395
- * They are populated if a matching route was found or `undefined` otherwise.
396
- *
397
- * @private
398
- */
399
- _findHandlerAndParams(event, url) {
400
- const routes = this._routes.get(event.request.method) || [];
401
- for (const route of routes) {
402
- let matchResult = route.match({ url, event });
403
- if (matchResult) {
404
- if (Array.isArray(matchResult) && matchResult.length === 0) {
405
- // Instead of passing an empty array in as params, use undefined.
406
- matchResult = undefined;
407
- } else if (matchResult.constructor === Object && Object.keys(matchResult).length === 0 || matchResult === true) {
408
- // Instead of passing an empty object in as params, use undefined.
409
- matchResult = undefined;
410
- }
411
-
412
- // Break out of the loop and return the appropriate values as soon as
413
- // we have a match.
414
- return {
415
- route,
416
- params: matchResult,
417
- handler: route.handler
418
- };
419
- }
420
- }
421
-
422
- // If we didn't have a match, then return undefined values.
423
- return { handler: undefined, params: undefined };
424
- }
425
-
426
- /**
427
- * Define a default `handler` that's called when no routes explicitly
428
- * match the incoming request.
429
- *
430
- * Without a default handler, unmatched requests will go against the
431
- * network as if there were no service worker present.
432
- *
433
- * @param {workbox.routing.Route~handlerCallback} handler A callback
434
- * function that returns a Promise resulting in a Response.
435
- */
436
- setDefaultHandler(handler) {
437
- this._defaultHandler = normalizeHandler(handler);
438
- }
439
-
440
- /**
441
- * If a Route throws an error while handling a request, this `handler`
442
- * will be called and given a chance to provide a response.
443
- *
444
- * @param {workbox.routing.Route~handlerCallback} handler A callback
445
- * function that returns a Promise resulting in a Response.
446
- */
447
- setCatchHandler(handler) {
448
- this._catchHandler = normalizeHandler(handler);
449
- }
450
-
451
- /**
452
- * Registers a route with the router.
453
- *
454
- * @param {workbox.routing.Route} route The route to register.
455
- */
456
- registerRoute(route) {
457
- {
458
- assert_mjs.assert.isType(route, 'object', {
459
- moduleName: 'workbox-routing',
460
- className: 'Router',
461
- funcName: 'registerRoute',
462
- paramName: 'route'
463
- });
464
-
465
- assert_mjs.assert.hasMethod(route, 'match', {
466
- moduleName: 'workbox-routing',
467
- className: 'Router',
468
- funcName: 'registerRoute',
469
- paramName: 'route'
470
- });
471
-
472
- assert_mjs.assert.isType(route.handler, 'object', {
473
- moduleName: 'workbox-routing',
474
- className: 'Router',
475
- funcName: 'registerRoute',
476
- paramName: 'route'
477
- });
478
-
479
- assert_mjs.assert.hasMethod(route.handler, 'handle', {
480
- moduleName: 'workbox-routing',
481
- className: 'Router',
482
- funcName: 'registerRoute',
483
- paramName: 'route.handler'
484
- });
485
-
486
- assert_mjs.assert.isType(route.method, 'string', {
487
- moduleName: 'workbox-routing',
488
- className: 'Router',
489
- funcName: 'registerRoute',
490
- paramName: 'route.method'
491
- });
492
- }
493
-
494
- if (!this._routes.has(route.method)) {
495
- this._routes.set(route.method, []);
496
- }
497
-
498
- // Give precedence to all of the earlier routes by adding this additional
499
- // route to the end of the array.
500
- this._routes.get(route.method).push(route);
501
- }
502
-
503
- /**
504
- * Unregisters a route with the router.
505
- *
506
- * @param {workbox.routing.Route} route The route to unregister.
507
- */
508
- unregisterRoute(route) {
509
- if (!this._routes.has(route.method)) {
510
- throw new WorkboxError_mjs.WorkboxError('unregister-route-but-not-found-with-method', {
511
- method: route.method
512
- });
513
- }
514
-
515
- const routeIndex = this._routes.get(route.method).indexOf(route);
516
- if (routeIndex > -1) {
517
- this._routes.get(route.method).splice(routeIndex, 1);
518
- } else {
519
- throw new WorkboxError_mjs.WorkboxError('unregister-route-route-not-registered');
520
- }
521
- }
522
- }
523
-
524
- /*
525
- Copyright 2016 Google Inc. All Rights Reserved.
526
- Licensed under the Apache License, Version 2.0 (the "License");
527
- you may not use this file except in compliance with the License.
528
- You may obtain a copy of the License at
529
-
530
- http://www.apache.org/licenses/LICENSE-2.0
531
-
532
- Unless required by applicable law or agreed to in writing, software
533
- distributed under the License is distributed on an "AS IS" BASIS,
534
- WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
535
- See the License for the specific language governing permissions and
536
- limitations under the License.
537
- */
538
-
539
- /**
540
- * NavigationRoute makes it easy to create a [Route]{@link
541
- * workbox.routing.Route} that matches for browser
542
- * [navigation requests]{@link https://developers.google.com/web/fundamentals/primers/service-workers/high-performance-loading#first_what_are_navigation_requests}.
543
- *
544
- * It will only match incoming Requests whose
545
- * [`mode`]{@link https://fetch.spec.whatwg.org/#concept-request-mode}
546
- * is set to `navigate`.
547
- *
548
- * You can optionally only apply this route to a subset of navigation requests
549
- * by using one or both of the `blacklist` and `whitelist` parameters.
550
- *
551
- * @memberof workbox.routing
552
- * @extends workbox.routing.Route
553
- */
554
- class NavigationRoute extends Route {
555
- /**
556
- * If both `blacklist` and `whiltelist` are provided, the `blacklist` will
557
- * take precedence and the request will not match this route.
558
- *
559
- * The regular expressions in `whitelist` and `blacklist`
560
- * are matched against the concatenated
561
- * [`pathname`]{@link https://developer.mozilla.org/en-US/docs/Web/API/HTMLHyperlinkElementUtils/pathname}
562
- * and [`search`]{@link https://developer.mozilla.org/en-US/docs/Web/API/HTMLHyperlinkElementUtils/search}
563
- * portions of the requested URL.
564
- *
565
- * @param {workbox.routing.Route~handlerCallback} handler A callback
566
- * function that returns a Promise resulting in a Response.
567
- * @param {Object} options
568
- * @param {Array<RegExp>} [options.blacklist] If any of these patterns match,
569
- * the route will not handle the request (even if a whitelist RegExp matches).
570
- * @param {Array<RegExp>} [options.whitelist=[/./]] If any of these patterns
571
- * match the URL's pathname and search parameter, the route will handle the
572
- * request (assuming the blacklist doesn't match).
573
- */
574
- constructor(handler, { whitelist = [/./], blacklist = [] } = {}) {
575
- {
576
- assert_mjs.assert.isArrayOfClass(whitelist, RegExp, {
577
- moduleName: 'workbox-routing',
578
- className: 'NavigationRoute',
579
- funcName: 'constructor',
580
- paramName: 'options.whitelist'
581
- });
582
- assert_mjs.assert.isArrayOfClass(blacklist, RegExp, {
583
- moduleName: 'workbox-routing',
584
- className: 'NavigationRoute',
585
- funcName: 'constructor',
586
- paramName: 'options.blacklist'
587
- });
588
- }
589
-
590
- super((...args) => this._match(...args), handler);
591
-
592
- this._whitelist = whitelist;
593
- this._blacklist = blacklist;
594
- }
595
-
596
- /**
597
- * Routes match handler.
598
- *
599
- * @param {Object} input
600
- * @param {FetchEvent} input.event
601
- * @param {URL} input.url
602
- * @return {boolean}
603
- *
604
- * @private
605
- */
606
- _match({ event, url }) {
607
- if (event.request.mode !== 'navigate') {
608
- return false;
609
- }
610
-
611
- const pathnameAndSearch = url.pathname + url.search;
612
-
613
- if (this._blacklist.some(regExp => regExp.test(pathnameAndSearch))) {
614
- {
615
- logger_mjs.logger.debug(`The navigation route is not being used, since the ` + `request URL matches both the whitelist and blacklist.`);
616
- }
617
- return false;
618
- }
619
-
620
- if (this._whitelist.some(regExp => regExp.test(pathnameAndSearch))) {
621
- {
622
- logger_mjs.logger.debug(`The navigation route is being used.`);
623
- }
624
- return true;
625
- } else {
626
- {
627
- logger_mjs.logger.debug(`The navigation route is not being used, since the ` + `URL being navigated to doesn't match the whitelist.`);
628
- }
629
- }
630
-
631
- return false;
632
- }
633
- }
634
-
635
- /*
636
- Copyright 2017 Google Inc.
637
-
638
- Licensed under the Apache License, Version 2.0 (the "License");
639
- you may not use this file except in compliance with the License.
640
- You may obtain a copy of the License at
641
-
642
- https://www.apache.org/licenses/LICENSE-2.0
643
-
644
- Unless required by applicable law or agreed to in writing, software
645
- distributed under the License is distributed on an "AS IS" BASIS,
646
- WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
647
- See the License for the specific language governing permissions and
648
- limitations under the License.
649
- */
650
-
651
- var publicAPI = /*#__PURE__*/Object.freeze({
652
- RegExpRoute: RegExpRoute,
653
- Route: Route,
654
- Router: Router,
655
- NavigationRoute: NavigationRoute
656
- });
657
-
658
- /*
659
- Copyright 2017 Google Inc.
660
-
661
- Licensed under the Apache License, Version 2.0 (the "License");
662
- you may not use this file except in compliance with the License.
663
- You may obtain a copy of the License at
664
-
665
- https://www.apache.org/licenses/LICENSE-2.0
666
-
667
- Unless required by applicable law or agreed to in writing, software
668
- distributed under the License is distributed on an "AS IS" BASIS,
669
- WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
670
- See the License for the specific language governing permissions and
671
- limitations under the License.
672
- */
673
-
674
- {
675
- assert_mjs.assert.isSwEnv('workbox-routing');
676
- }
677
-
678
- /**
679
- * @private
680
- */
681
- class DefaultRouter extends Router {
682
- /**
683
- * Easily register a RegExp, string, or function with a caching
684
- * strategy to the Router.
685
- *
686
- * This method will generate a Route for you if needed and
687
- * call [Router.registerRoute()]{@link
688
- * workbox.routing.Router#registerRoute}.
689
- *
690
- * @param {
691
- * RegExp|
692
- * string|
693
- * workbox.routing.Route~matchCallback|
694
- * workbox.routing.Route
695
- * } capture
696
- * If the capture param is a `Route`, all other arguments will be ignored.
697
- * @param {workbox.routing.Route~handlerCallback} handler A callback
698
- * function that returns a Promise resulting in a Response.
699
- * @param {string} [method='GET'] The HTTP method to match the Route
700
- * against.
701
- * @return {workbox.routing.Route} The generated `Route`(Useful for
702
- * unregistering).
703
- *
704
- * @alias workbox.routing.registerRoute
705
- */
706
- registerRoute(capture, handler, method = 'GET') {
707
- let route;
708
-
709
- if (typeof capture === 'string') {
710
- const captureUrl = new URL(capture, location);
711
-
712
- {
713
- if (!(capture.startsWith('/') || capture.startsWith('http'))) {
714
- throw new WorkboxError_mjs.WorkboxError('invalid-string', {
715
- moduleName: 'workbox-routing',
716
- className: 'DefaultRouter',
717
- funcName: 'registerRoute',
718
- paramName: 'capture'
719
- });
720
- }
721
-
722
- // We want to check if Express-style wildcards are in the pathname only.
723
- // TODO: Remove this log message in v4.
724
- const valueToCheck = capture.startsWith('http') ? captureUrl.pathname : capture;
725
- // See https://github.com/pillarjs/path-to-regexp#parameters
726
- const wildcards = '[*:?+]';
727
- if (valueToCheck.match(new RegExp(`${wildcards}`))) {
728
- logger_mjs.logger.debug(`The '$capture' parameter contains an Express-style wildcard ` + `character (${wildcards}). Strings are now always interpreted as ` + `exact matches; use a RegExp for partial or wildcard matches.`);
729
- }
730
- }
731
-
732
- const matchCallback = ({ url }) => {
733
- {
734
- if (url.pathname === captureUrl.pathname && url.origin !== captureUrl.origin) {
735
- logger_mjs.logger.debug(`${capture} only partially matches the cross-origin URL ` + `${url}. This route will only handle cross-origin requests ` + `if they match the entire URL.`);
736
- }
737
- }
738
-
739
- return url.href === captureUrl.href;
740
- };
741
-
742
- route = new Route(matchCallback, handler, method);
743
- } else if (capture instanceof RegExp) {
744
- route = new RegExpRoute(capture, handler, method);
745
- } else if (typeof capture === 'function') {
746
- route = new Route(capture, handler, method);
747
- } else if (capture instanceof Route) {
748
- route = capture;
749
- } else {
750
- throw new WorkboxError_mjs.WorkboxError('unsupported-route-type', {
751
- moduleName: 'workbox-routing',
752
- className: 'DefaultRouter',
753
- funcName: 'registerRoute',
754
- paramName: 'capture'
755
- });
756
- }
757
-
758
- super.registerRoute(route);
759
- return route;
760
- }
761
-
762
- /**
763
- * Register a route that will return a precached file for a navigation
764
- * request. This is useful for the
765
- * [application shell pattern]{@link https://developers.google.com/web/fundamentals/architecture/app-shell}.
766
- *
767
- * This method will generate a
768
- * [NavigationRoute]{@link workbox.routing.NavigationRoute}
769
- * and call
770
- * [Router.registerRoute()]{@link workbox.routing.Router#registerRoute}
771
- * .
772
- *
773
- * @param {string} cachedAssetUrl
774
- * @param {Object} [options]
775
- * @param {string} [options.cacheName] Cache name to store and retrieve
776
- * requests. Defaults to precache cache name provided by
777
- * [workbox-core.cacheNames]{@link workbox.core.cacheNames}.
778
- * @param {Array<RegExp>} [options.blacklist=[]] If any of these patterns
779
- * match, the route will not handle the request (even if a whitelist entry
780
- * matches).
781
- * @param {Array<RegExp>} [options.whitelist=[/./]] If any of these patterns
782
- * match the URL's pathname and search parameter, the route will handle the
783
- * request (assuming the blacklist doesn't match).
784
- * @return {workbox.routing.NavigationRoute} Returns the generated
785
- * Route.
786
- *
787
- * @alias workbox.routing.registerNavigationRoute
788
- */
789
- registerNavigationRoute(cachedAssetUrl, options = {}) {
790
- {
791
- assert_mjs.assert.isType(cachedAssetUrl, 'string', {
792
- moduleName: 'workbox-routing',
793
- className: '[default export]',
794
- funcName: 'registerNavigationRoute',
795
- paramName: 'cachedAssetUrl'
796
- });
797
- }
798
-
799
- const cacheName = cacheNames_mjs.cacheNames.getPrecacheName(options.cacheName);
800
- const handler = () => caches.match(cachedAssetUrl, { cacheName }).then(response => {
801
- if (response) {
802
- return response;
803
- }
804
- // This shouldn't normally happen, but there are edge cases:
805
- // https://github.com/GoogleChrome/workbox/issues/1441
806
- throw new Error(`The cache ${cacheName} did not have an entry for ` + `${cachedAssetUrl}.`);
807
- }).catch(error => {
808
- // If there's either a cache miss, or the caches.match() call threw
809
- // an exception, then attempt to fulfill the navigation request with
810
- // a response from the network rather than leaving the user with a
811
- // failed navigation.
812
- {
813
- logger_mjs.logger.debug(`Unable to respond to navigation request with cached ` + `response: ${error.message}. Falling back to network.`);
814
- }
815
-
816
- // This might still fail if the browser is offline...
817
- return fetch(cachedAssetUrl);
818
- });
819
-
820
- const route = new NavigationRoute(handler, {
821
- whitelist: options.whitelist,
822
- blacklist: options.blacklist
823
- });
824
- super.registerRoute(route);
825
-
826
- return route;
827
- }
828
- }
829
-
830
- const router = new DefaultRouter();
831
-
832
- // By default, register a fetch event listener that will respond to a request
833
- // only if there's a matching route.
834
- self.addEventListener('fetch', event => {
835
- const responsePromise = router.handleRequest(event);
836
- if (responsePromise) {
837
- event.respondWith(responsePromise);
838
- }
839
- });
840
-
841
- /*
842
- Copyright 2017 Google Inc.
843
-
844
- Licensed under the Apache License, Version 2.0 (the "License");
845
- you may not use this file except in compliance with the License.
846
- You may obtain a copy of the License at
847
-
848
- https://www.apache.org/licenses/LICENSE-2.0
849
-
850
- Unless required by applicable law or agreed to in writing, software
851
- distributed under the License is distributed on an "AS IS" BASIS,
852
- WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
853
- See the License for the specific language governing permissions and
854
- limitations under the License.
855
- */
856
-
857
- const finalExport = Object.assign(router, publicAPI);
858
-
859
- return finalExport;
860
-
861
- }(workbox.core._private,workbox.core._private,workbox.core._private,workbox.core._private,workbox.core._private));
862
-
863
- //# sourceMappingURL=workbox-routing.dev.js.map