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-cache-expiration/browser.mjs"],"sourcesContent":["this.workbox = this.workbox || {};\nthis.workbox.expiration = (function (exports,DBWrapper_mjs,WorkboxError_mjs,assert_mjs,logger_mjs,cacheNames_mjs,quota_mjs) {\n 'use strict';\n\n try {\n self.workbox.v['workbox:cache-expiration: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 const URL_KEY = 'url';\n const TIMESTAMP_KEY = 'timestamp';\n\n /**\n * Returns the timestamp model.\n *\n * @private\n */\n class CacheTimestampsModel {\n /**\n *\n * @param {string} cacheName\n *\n * @private\n */\n constructor(cacheName) {\n // TODO Check cacheName\n\n this._cacheName = cacheName;\n this._storeName = cacheName;\n\n this._db = new DBWrapper_mjs.DBWrapper(this._cacheName, 2, {\n onupgradeneeded: evt => this._handleUpgrade(evt)\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 // Remove old databases.\n if (db.objectStoreNames.contains('workbox-cache-expiration')) {\n db.deleteObjectStore('workbox-cache-expiration');\n }\n }\n\n db.createObjectStore(this._storeName, { keyPath: URL_KEY }).createIndex(TIMESTAMP_KEY, TIMESTAMP_KEY, { unique: false });\n }\n\n /**\n * @param {string} url\n * @param {number} timestamp\n *\n * @private\n */\n setTimestamp(url, timestamp) {\n var _this = this;\n\n return babelHelpers.asyncToGenerator(function* () {\n yield _this._db.put(_this._storeName, {\n [URL_KEY]: new URL(url, location).href,\n [TIMESTAMP_KEY]: timestamp\n });\n })();\n }\n\n /**\n * Get all of the timestamps in the indexedDB.\n *\n * @return {Array<Objects>}\n *\n * @private\n */\n getAllTimestamps() {\n var _this2 = this;\n\n return babelHelpers.asyncToGenerator(function* () {\n return yield _this2._db.getAllMatching(_this2._storeName, {\n index: TIMESTAMP_KEY\n });\n })();\n }\n\n /**\n * Returns the timestamp stored for a given URL.\n *\n * @param {string} url\n * @return {number}\n *\n * @private\n */\n getTimestamp(url) {\n var _this3 = this;\n\n return babelHelpers.asyncToGenerator(function* () {\n const timestampObject = yield _this3._db.get(_this3._storeName, url);\n return timestampObject.timestamp;\n })();\n }\n\n /**\n * @param {string} url\n *\n * @private\n */\n deleteUrl(url) {\n var _this4 = this;\n\n return babelHelpers.asyncToGenerator(function* () {\n yield _this4._db.delete(_this4._storeName, new URL(url, location).href);\n })();\n }\n\n /**\n * Removes the underlying IndexedDB object store entirely.\n */\n delete() {\n var _this5 = this;\n\n return babelHelpers.asyncToGenerator(function* () {\n yield _this5._db.deleteDatabase();\n _this5._db = null;\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 * The `CacheExpiration` class allows you define an expiration and / or\n * limit on the number of responses stored in a\n * [`Cache`](https://developer.mozilla.org/en-US/docs/Web/API/Cache).\n *\n * @memberof workbox.expiration\n */\n class CacheExpiration {\n /**\n * To construct a new CacheExpiration instance you must provide at least\n * one of the `config` properties.\n *\n * @param {string} cacheName Name of the cache to apply restrictions to.\n * @param {Object} config\n * @param {number} [config.maxEntries] The maximum number of entries to cache.\n * Entries used the least will be removed as the maximum is reached.\n * @param {number} [config.maxAgeSeconds] The maximum age of an entry before\n * it's treated as stale and removed.\n */\n constructor(cacheName, config = {}) {\n {\n assert_mjs.assert.isType(cacheName, 'string', {\n moduleName: 'workbox-cache-expiration',\n className: 'CacheExpiration',\n funcName: 'constructor',\n paramName: 'cacheName'\n });\n\n if (!(config.maxEntries || config.maxAgeSeconds)) {\n throw new WorkboxError_mjs.WorkboxError('max-entries-or-age-required', {\n moduleName: 'workbox-cache-expiration',\n className: 'CacheExpiration',\n funcName: 'constructor'\n });\n }\n\n if (config.maxEntries) {\n assert_mjs.assert.isType(config.maxEntries, 'number', {\n moduleName: 'workbox-cache-expiration',\n className: 'CacheExpiration',\n funcName: 'constructor',\n paramName: 'config.maxEntries'\n });\n\n // TODO: Assert is positive\n }\n\n if (config.maxAgeSeconds) {\n assert_mjs.assert.isType(config.maxAgeSeconds, 'number', {\n moduleName: 'workbox-cache-expiration',\n className: 'CacheExpiration',\n funcName: 'constructor',\n paramName: 'config.maxAgeSeconds'\n });\n\n // TODO: Assert is positive\n }\n }\n\n this._isRunning = false;\n this._rerunRequested = false;\n this._maxEntries = config.maxEntries;\n this._maxAgeSeconds = config.maxAgeSeconds;\n this._cacheName = cacheName;\n this._timestampModel = new CacheTimestampsModel(cacheName);\n }\n\n /**\n * Expires entries for the given cache and given criteria.\n */\n expireEntries() {\n var _this = this;\n\n return babelHelpers.asyncToGenerator(function* () {\n if (_this._isRunning) {\n _this._rerunRequested = true;\n return;\n }\n _this._isRunning = true;\n\n const now = Date.now();\n\n // First, expire old entries, if maxAgeSeconds is set.\n const oldEntries = yield _this._findOldEntries(now);\n\n // Once that's done, check for the maximum size.\n const extraEntries = yield _this._findExtraEntries();\n\n // Use a Set to remove any duplicates following the concatenation, then\n // convert back into an array.\n const allUrls = [...new Set(oldEntries.concat(extraEntries))];\n\n yield Promise.all([_this._deleteFromCache(allUrls), _this._deleteFromIDB(allUrls)]);\n\n {\n // TODO: break apart entries deleted due to expiration vs size restraints\n if (allUrls.length > 0) {\n logger_mjs.logger.groupCollapsed(`Expired ${allUrls.length} ` + `${allUrls.length === 1 ? 'entry' : 'entries'} and removed ` + `${allUrls.length === 1 ? 'it' : 'them'} from the ` + `'${_this._cacheName}' cache.`);\n logger_mjs.logger.log(`Expired the following ${allUrls.length === 1 ? 'URL' : 'URLs'}:`);\n allUrls.forEach(function (url) {\n return logger_mjs.logger.log(` ${url}`);\n });\n logger_mjs.logger.groupEnd();\n } else {\n logger_mjs.logger.debug(`Cache expiration ran and found no entries to remove.`);\n }\n }\n\n _this._isRunning = false;\n if (_this._rerunRequested) {\n _this._rerunRequested = false;\n _this.expireEntries();\n }\n })();\n }\n\n /**\n * Expires entries based on the maximum age.\n *\n * @param {number} expireFromTimestamp A timestamp.\n * @return {Promise<Array<string>>} A list of the URLs that were expired.\n *\n * @private\n */\n _findOldEntries(expireFromTimestamp) {\n var _this2 = this;\n\n return babelHelpers.asyncToGenerator(function* () {\n {\n assert_mjs.assert.isType(expireFromTimestamp, 'number', {\n moduleName: 'workbox-cache-expiration',\n className: 'CacheExpiration',\n funcName: '_findOldEntries',\n paramName: 'expireFromTimestamp'\n });\n }\n\n if (!_this2._maxAgeSeconds) {\n return [];\n }\n\n const expireOlderThan = expireFromTimestamp - _this2._maxAgeSeconds * 1000;\n const timestamps = yield _this2._timestampModel.getAllTimestamps();\n const expiredUrls = [];\n timestamps.forEach(function (timestampDetails) {\n if (timestampDetails.timestamp < expireOlderThan) {\n expiredUrls.push(timestampDetails.url);\n }\n });\n\n return expiredUrls;\n })();\n }\n\n /**\n * @return {Promise<Array>}\n *\n * @private\n */\n _findExtraEntries() {\n var _this3 = this;\n\n return babelHelpers.asyncToGenerator(function* () {\n const extraUrls = [];\n\n if (!_this3._maxEntries) {\n return [];\n }\n\n const timestamps = yield _this3._timestampModel.getAllTimestamps();\n while (timestamps.length > _this3._maxEntries) {\n const lastUsed = timestamps.shift();\n extraUrls.push(lastUsed.url);\n }\n\n return extraUrls;\n })();\n }\n\n /**\n * @param {Array<string>} urls Array of URLs to delete from cache.\n *\n * @private\n */\n _deleteFromCache(urls) {\n var _this4 = this;\n\n return babelHelpers.asyncToGenerator(function* () {\n const cache = yield caches.open(_this4._cacheName);\n for (const url of urls) {\n yield cache.delete(url);\n }\n })();\n }\n\n /**\n * @param {Array<string>} urls Array of URLs to delete from IDB\n *\n * @private\n */\n _deleteFromIDB(urls) {\n var _this5 = this;\n\n return babelHelpers.asyncToGenerator(function* () {\n for (const url of urls) {\n yield _this5._timestampModel.deleteUrl(url);\n }\n })();\n }\n\n /**\n * Update the timestamp for the given URL. This ensures the when\n * removing entries based on maximum entries, most recently used\n * is accurate or when expiring, the timestamp is up-to-date.\n *\n * @param {string} url\n */\n updateTimestamp(url) {\n var _this6 = this;\n\n return babelHelpers.asyncToGenerator(function* () {\n {\n assert_mjs.assert.isType(url, 'string', {\n moduleName: 'workbox-cache-expiration',\n className: 'CacheExpiration',\n funcName: 'updateTimestamp',\n paramName: 'url'\n });\n }\n\n const urlObject = new URL(url, location);\n urlObject.hash = '';\n\n yield _this6._timestampModel.setTimestamp(urlObject.href, Date.now());\n })();\n }\n\n /**\n * Can be used to check if a URL has expired or not before it's used.\n *\n * This requires a look up from IndexedDB, so can be slow.\n *\n * Note: This method will not remove the cached entry, call\n * `expireEntries()` to remove indexedDB and Cache entries.\n *\n * @param {string} url\n * @return {boolean}\n */\n isURLExpired(url) {\n var _this7 = this;\n\n return babelHelpers.asyncToGenerator(function* () {\n if (!_this7._maxAgeSeconds) {\n throw new WorkboxError_mjs.WorkboxError(`expired-test-without-max-age`, {\n methodName: 'isURLExpired',\n paramName: 'maxAgeSeconds'\n });\n }\n const urlObject = new URL(url, location);\n urlObject.hash = '';\n\n const timestamp = yield _this7._timestampModel.getTimestamp(urlObject.href);\n const expireOlderThan = Date.now() - _this7._maxAgeSeconds * 1000;\n return timestamp < expireOlderThan;\n })();\n }\n\n /**\n * Removes the IndexedDB object store used to keep track of cache expiration\n * metadata.\n */\n delete() {\n var _this8 = this;\n\n return babelHelpers.asyncToGenerator(function* () {\n // Make sure we don't attempt another rerun if we're called in the middle of\n // a cache expiration.\n _this8._rerunRequested = false;\n yield _this8._timestampModel.delete();\n })();\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 * This plugin can be used in the Workbox APIs to regularly enforce a\n * limit on the age and / or the number of cached requests.\n *\n * Whenever a cached request is used or updated, this plugin will look\n * at the used Cache and remove any old or extra requests.\n *\n * When using `maxAgeSeconds`, requests may be used *once* after expiring\n * because the expiration clean up will not have occurred until *after* the\n * cached request has been used. If the request has a \"Date\" header, then\n * a light weight expiration check is performed and the request will not be\n * used immediately.\n *\n * When using `maxEntries`, the last request to be used will be the request\n * that is removed from the Cache.\n *\n * @memberof workbox.expiration\n */\n class Plugin {\n /**\n * @param {Object} config\n * @param {number} [config.maxEntries] The maximum number of entries to cache.\n * Entries used the least will be removed as the maximum is reached.\n * @param {number} [config.maxAgeSeconds] The maximum age of an entry before\n * it's treated as stale and removed.\n * @param {boolean} [config.purgeOnQuotaError] Whether to opt this cache in to\n * automatic deletion if the available storage quota has been exceeded.\n */\n constructor(config = {}) {\n {\n if (!(config.maxEntries || config.maxAgeSeconds)) {\n throw new WorkboxError_mjs.WorkboxError('max-entries-or-age-required', {\n moduleName: 'workbox-cache-expiration',\n className: 'Plugin',\n funcName: 'constructor'\n });\n }\n\n if (config.maxEntries) {\n assert_mjs.assert.isType(config.maxEntries, 'number', {\n moduleName: 'workbox-cache-expiration',\n className: 'Plugin',\n funcName: 'constructor',\n paramName: 'config.maxEntries'\n });\n }\n\n if (config.maxAgeSeconds) {\n assert_mjs.assert.isType(config.maxAgeSeconds, 'number', {\n moduleName: 'workbox-cache-expiration',\n className: 'Plugin',\n funcName: 'constructor',\n paramName: 'config.maxAgeSeconds'\n });\n }\n }\n\n this._config = config;\n this._maxAgeSeconds = config.maxAgeSeconds;\n this._cacheExpirations = new Map();\n\n if (config.purgeOnQuotaError) {\n quota_mjs.registerQuotaErrorCallback(() => this.deleteCacheAndMetadata());\n }\n }\n\n /**\n * A simple helper method to return a CacheExpiration instance for a given\n * cache name.\n *\n * @param {string} cacheName\n * @return {CacheExpiration}\n *\n * @private\n */\n _getCacheExpiration(cacheName) {\n if (cacheName === cacheNames_mjs.cacheNames.getRuntimeName()) {\n throw new WorkboxError_mjs.WorkboxError('expire-custom-caches-only');\n }\n\n let cacheExpiration = this._cacheExpirations.get(cacheName);\n if (!cacheExpiration) {\n cacheExpiration = new CacheExpiration(cacheName, this._config);\n this._cacheExpirations.set(cacheName, cacheExpiration);\n }\n return cacheExpiration;\n }\n\n /**\n * A \"lifecycle\" callback that will be triggered automatically by the\n * `workbox.runtimeCaching` handlers when a `Response` is about to be returned\n * from a [Cache](https://developer.mozilla.org/en-US/docs/Web/API/Cache) to\n * the handler. It allows the `Response` to be inspected for freshness and\n * prevents it from being used if the `Response`'s `Date` header value is\n * older than the configured `maxAgeSeconds`.\n *\n * @param {Object} input\n * @param {string} input.cacheName Name of the cache the responses belong to.\n * @param {Response} input.cachedResponse The `Response` object that's been\n * read from a cache and whose freshness should be checked.\n * @return {Response} Either the `cachedResponse`, if it's\n * fresh, or `null` if the `Response` is older than `maxAgeSeconds`.\n *\n * @private\n */\n cachedResponseWillBeUsed({ cacheName, cachedResponse }) {\n if (!cachedResponse) {\n return null;\n }\n\n let isFresh = this._isResponseDateFresh(cachedResponse);\n\n // Expire entries to ensure that even if the expiration date has\n // expired, it'll only be used once.\n const cacheExpiration = this._getCacheExpiration(cacheName);\n cacheExpiration.expireEntries();\n\n return isFresh ? cachedResponse : null;\n }\n\n /**\n * @param {Response} cachedResponse\n * @return {boolean}\n *\n * @private\n */\n _isResponseDateFresh(cachedResponse) {\n if (!this._maxAgeSeconds) {\n // We aren't expiring by age, so return true, it's fresh\n return true;\n }\n\n // Check if the 'date' header will suffice a quick expiration check.\n // See https://github.com/GoogleChromeLabs/sw-toolbox/issues/164 for\n // discussion.\n const dateHeaderTimestamp = this._getDateHeaderTimestamp(cachedResponse);\n if (dateHeaderTimestamp === null) {\n // Unable to parse date, so assume it's fresh.\n return true;\n }\n\n // If we have a valid headerTime, then our response is fresh iff the\n // headerTime plus maxAgeSeconds is greater than the current time.\n const now = Date.now();\n return dateHeaderTimestamp >= now - this._maxAgeSeconds * 1000;\n }\n\n /**\n * This method will extract the data header and parse it into a useful\n * value.\n *\n * @param {Response} cachedResponse\n * @return {number}\n *\n * @private\n */\n _getDateHeaderTimestamp(cachedResponse) {\n if (!cachedResponse.headers.has('date')) {\n return null;\n }\n\n const dateHeader = cachedResponse.headers.get('date');\n const parsedDate = new Date(dateHeader);\n const headerTime = parsedDate.getTime();\n\n // If the Date header was invalid for some reason, parsedDate.getTime()\n // will return NaN.\n if (isNaN(headerTime)) {\n return null;\n }\n\n return headerTime;\n }\n\n /**\n * A \"lifecycle\" callback that will be triggered automatically by the\n * `workbox.runtimeCaching` handlers when an entry is added to a cache.\n *\n * @param {Object} input\n * @param {string} input.cacheName Name of the cache the responses belong to.\n * @param {string} input.request The Request for the cached entry.\n *\n * @private\n */\n cacheDidUpdate({ cacheName, request }) {\n var _this = this;\n\n return babelHelpers.asyncToGenerator(function* () {\n {\n assert_mjs.assert.isType(cacheName, 'string', {\n moduleName: 'workbox-cache-expiration',\n className: 'Plugin',\n funcName: 'cacheDidUpdate',\n paramName: 'cacheName'\n });\n assert_mjs.assert.isInstance(request, Request, {\n moduleName: 'workbox-cache-expiration',\n className: 'Plugin',\n funcName: 'cacheDidUpdate',\n paramName: 'request'\n });\n }\n\n const cacheExpiration = _this._getCacheExpiration(cacheName);\n yield cacheExpiration.updateTimestamp(request.url);\n yield cacheExpiration.expireEntries();\n })();\n }\n\n /**\n * This is a helper method that performs two operations:\n *\n * - Deletes *all* the underlying Cache instances associated with this plugin\n * instance, by calling caches.delete() on you behalf.\n * - Deletes the metadata from IndexedDB used to keep track of expiration\n * details for each Cache instance.\n *\n * When using cache expiration, calling this method is preferable to calling\n * `caches.delete()` directly, since this will ensure that the IndexedDB\n * metadata is also cleanly removed and open IndexedDB instances are deleted.\n *\n * Note that if you're *not* using cache expiration for a given cache, calling\n * `caches.delete()` and passing in the cache's name should be sufficient.\n * There is no Workbox-specific method needed for cleanup in that case.\n */\n deleteCacheAndMetadata() {\n var _this2 = this;\n\n return babelHelpers.asyncToGenerator(function* () {\n // Do this one at a time instead of all at once via `Promise.all()` to\n // reduce the chance of inconsistency if a promise rejects.\n for (const [cacheName, cacheExpiration] of _this2._cacheExpirations) {\n yield caches.delete(cacheName);\n yield cacheExpiration.delete();\n }\n\n // Reset this._cacheExpirations to its initial state.\n _this2._cacheExpirations = new Map();\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.CacheExpiration = CacheExpiration;\n exports.Plugin = Plugin;\n\n return exports;\n\n}({},workbox.core._private,workbox.core._private,workbox.core._private,workbox.core._private,workbox.core._private,workbox.core._private));\n"],"file":"workbox-cache-expiration.dev.js"}
@@ -1,3 +0,0 @@
1
- this.workbox=this.workbox||{},this.workbox.expiration=function(e,t,r,n,i){"use strict";try{self.workbox.v["workbox:cache-expiration:3.3.1"]=1}catch(e){}const s="url",a="timestamp";class l{constructor(e){this.e=e,this.t=e,this.r=new t.DBWrapper(this.e,2,{onupgradeneeded:e=>this.n(e)})}n(e){const t=e.target.result;e.oldVersion<2&&t.objectStoreNames.contains("workbox-cache-expiration")&&t.deleteObjectStore("workbox-cache-expiration"),t.createObjectStore(this.t,{keyPath:s}).createIndex(a,a,{unique:!1})}setTimestamp(e,t){var r=this;return babelHelpers.asyncToGenerator(function*(){yield r.r.put(r.t,{[s]:new URL(e,location).href,[a]:t})})()}getAllTimestamps(){var e=this;return babelHelpers.asyncToGenerator(function*(){return yield e.r.getAllMatching(e.t,{index:a})})()}getTimestamp(e){var t=this;return babelHelpers.asyncToGenerator(function*(){return(yield t.r.get(t.t,e)).timestamp})()}deleteUrl(e){var t=this;return babelHelpers.asyncToGenerator(function*(){yield t.r.delete(t.t,new URL(e,location).href)})()}delete(){var e=this;return babelHelpers.asyncToGenerator(function*(){yield e.r.deleteDatabase(),e.r=null})()}}class o{constructor(e,t={}){this.i=!1,this.s=!1,this.a=t.maxEntries,this.l=t.maxAgeSeconds,this.e=e,this.o=new l(e)}expireEntries(){var e=this;return babelHelpers.asyncToGenerator(function*(){if(e.i)return void(e.s=!0);e.i=!0;const t=Date.now(),r=yield e.c(t),n=yield e.u(),i=[...new Set(r.concat(n))];yield Promise.all([e.h(i),e.d(i)]),e.i=!1,e.s&&(e.s=!1,e.expireEntries())})()}c(e){var t=this;return babelHelpers.asyncToGenerator(function*(){if(!t.l)return[];const r=e-1e3*t.l,n=[];return(yield t.o.getAllTimestamps()).forEach(function(e){e.timestamp<r&&n.push(e.url)}),n})()}u(){var e=this;return babelHelpers.asyncToGenerator(function*(){const t=[];if(!e.a)return[];const r=yield e.o.getAllTimestamps();for(;r.length>e.a;){const e=r.shift();t.push(e.url)}return t})()}h(e){var t=this;return babelHelpers.asyncToGenerator(function*(){const r=yield caches.open(t.e);for(const t of e)yield r.delete(t)})()}d(e){var t=this;return babelHelpers.asyncToGenerator(function*(){for(const r of e)yield t.o.deleteUrl(r)})()}updateTimestamp(e){var t=this;return babelHelpers.asyncToGenerator(function*(){const r=new URL(e,location);r.hash="",yield t.o.setTimestamp(r.href,Date.now())})()}isURLExpired(e){var t=this;return babelHelpers.asyncToGenerator(function*(){if(!t.l)throw new r.WorkboxError("expired-test-without-max-age",{methodName:"isURLExpired",paramName:"maxAgeSeconds"});const n=new URL(e,location);return n.hash="",(yield t.o.getTimestamp(n.href))<Date.now()-1e3*t.l})()}delete(){var e=this;return babelHelpers.asyncToGenerator(function*(){e.s=!1,yield e.o.delete()})()}}return e.CacheExpiration=o,e.Plugin=class{constructor(e={}){this.p=e,this.l=e.maxAgeSeconds,this.b=new Map,e.purgeOnQuotaError&&i.registerQuotaErrorCallback(()=>this.deleteCacheAndMetadata())}f(e){if(e===n.cacheNames.getRuntimeName())throw new r.WorkboxError("expire-custom-caches-only");let t=this.b.get(e);return t||(t=new o(e,this.p),this.b.set(e,t)),t}cachedResponseWillBeUsed({cacheName:e,cachedResponse:t}){if(!t)return null;let r=this.m(t);return this.f(e).expireEntries(),r?t:null}m(e){if(!this.l)return!0;const t=this.y(e);return null===t||t>=Date.now()-1e3*this.l}y(e){if(!e.headers.has("date"))return null;const t=e.headers.get("date"),r=new Date(t).getTime();return isNaN(r)?null:r}cacheDidUpdate({cacheName:e,request:t}){var r=this;return babelHelpers.asyncToGenerator(function*(){const n=r.f(e);yield n.updateTimestamp(t.url),yield n.expireEntries()})()}deleteCacheAndMetadata(){var e=this;return babelHelpers.asyncToGenerator(function*(){for(const[t,r]of e.b)yield caches.delete(t),yield r.delete();e.b=new Map})()}},e}({},workbox.core._private,workbox.core._private,workbox.core._private,workbox.core._private);
2
-
3
- //# sourceMappingURL=workbox-cache-expiration.prod.js.map
@@ -1 +0,0 @@
1
- {"version":3,"names":[],"mappings":"","sources":["packages/workbox-cache-expiration/browser.mjs"],"sourcesContent":["this.workbox=this.workbox||{},this.workbox.expiration=function(e,t,r,n,i){\"use strict\";try{self.workbox.v[\"workbox:cache-expiration:3.3.1\"]=1}catch(e){}const s=\"url\",a=\"timestamp\";class l{constructor(e){this.e=e,this.t=e,this.r=new t.DBWrapper(this.e,2,{onupgradeneeded:e=>this.n(e)})}n(e){const t=e.target.result;e.oldVersion<2&&t.objectStoreNames.contains(\"workbox-cache-expiration\")&&t.deleteObjectStore(\"workbox-cache-expiration\"),t.createObjectStore(this.t,{keyPath:s}).createIndex(a,a,{unique:!1})}setTimestamp(e,t){var r=this;return babelHelpers.asyncToGenerator(function*(){yield r.r.put(r.t,{[s]:new URL(e,location).href,[a]:t})})()}getAllTimestamps(){var e=this;return babelHelpers.asyncToGenerator(function*(){return yield e.r.getAllMatching(e.t,{index:a})})()}getTimestamp(e){var t=this;return babelHelpers.asyncToGenerator(function*(){return(yield t.r.get(t.t,e)).timestamp})()}deleteUrl(e){var t=this;return babelHelpers.asyncToGenerator(function*(){yield t.r.delete(t.t,new URL(e,location).href)})()}delete(){var e=this;return babelHelpers.asyncToGenerator(function*(){yield e.r.deleteDatabase(),e.r=null})()}}class o{constructor(e,t={}){this.i=!1,this.s=!1,this.a=t.maxEntries,this.l=t.maxAgeSeconds,this.e=e,this.o=new l(e)}expireEntries(){var e=this;return babelHelpers.asyncToGenerator(function*(){if(e.i)return void(e.s=!0);e.i=!0;const t=Date.now(),r=yield e.c(t),n=yield e.u(),i=[...new Set(r.concat(n))];yield Promise.all([e.h(i),e.d(i)]),e.i=!1,e.s&&(e.s=!1,e.expireEntries())})()}c(e){var t=this;return babelHelpers.asyncToGenerator(function*(){if(!t.l)return[];const r=e-1e3*t.l,n=[];return(yield t.o.getAllTimestamps()).forEach(function(e){e.timestamp<r&&n.push(e.url)}),n})()}u(){var e=this;return babelHelpers.asyncToGenerator(function*(){const t=[];if(!e.a)return[];const r=yield e.o.getAllTimestamps();for(;r.length>e.a;){const e=r.shift();t.push(e.url)}return t})()}h(e){var t=this;return babelHelpers.asyncToGenerator(function*(){const r=yield caches.open(t.e);for(const t of e)yield r.delete(t)})()}d(e){var t=this;return babelHelpers.asyncToGenerator(function*(){for(const r of e)yield t.o.deleteUrl(r)})()}updateTimestamp(e){var t=this;return babelHelpers.asyncToGenerator(function*(){const r=new URL(e,location);r.hash=\"\",yield t.o.setTimestamp(r.href,Date.now())})()}isURLExpired(e){var t=this;return babelHelpers.asyncToGenerator(function*(){if(!t.l)throw new r.WorkboxError(\"expired-test-without-max-age\",{methodName:\"isURLExpired\",paramName:\"maxAgeSeconds\"});const n=new URL(e,location);return n.hash=\"\",(yield t.o.getTimestamp(n.href))<Date.now()-1e3*t.l})()}delete(){var e=this;return babelHelpers.asyncToGenerator(function*(){e.s=!1,yield e.o.delete()})()}}return e.CacheExpiration=o,e.Plugin=class{constructor(e={}){this.p=e,this.l=e.maxAgeSeconds,this.b=new Map,e.purgeOnQuotaError&&i.registerQuotaErrorCallback(()=>this.deleteCacheAndMetadata())}f(e){if(e===n.cacheNames.getRuntimeName())throw new r.WorkboxError(\"expire-custom-caches-only\");let t=this.b.get(e);return t||(t=new o(e,this.p),this.b.set(e,t)),t}cachedResponseWillBeUsed({cacheName:e,cachedResponse:t}){if(!t)return null;let r=this.m(t);return this.f(e).expireEntries(),r?t:null}m(e){if(!this.l)return!0;const t=this.y(e);return null===t||t>=Date.now()-1e3*this.l}y(e){if(!e.headers.has(\"date\"))return null;const t=e.headers.get(\"date\"),r=new Date(t).getTime();return isNaN(r)?null:r}cacheDidUpdate({cacheName:e,request:t}){var r=this;return babelHelpers.asyncToGenerator(function*(){const n=r.f(e);yield n.updateTimestamp(t.url),yield n.expireEntries()})()}deleteCacheAndMetadata(){var e=this;return babelHelpers.asyncToGenerator(function*(){for(const[t,r]of e.b)yield caches.delete(t),yield r.delete();e.b=new Map})()}},e}({},workbox.core._private,workbox.core._private,workbox.core._private,workbox.core._private);\n"],"file":"workbox-cache-expiration.prod.js"}
@@ -1,236 +0,0 @@
1
- this.workbox = this.workbox || {};
2
- this.workbox.cacheableResponse = (function (exports,WorkboxError_mjs,assert_mjs,getFriendlyURL_mjs,logger_mjs) {
3
- 'use strict';
4
-
5
- try {
6
- self.workbox.v['workbox:cacheable-response: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
- * This class allows you to set up rules determining what
27
- * status codes and/or headers need to be present in order for a
28
- * [`Response`](https://developer.mozilla.org/en-US/docs/Web/API/Response)
29
- * to be considered cacheable.
30
- *
31
- * @memberof workbox.cacheableResponse
32
- */
33
- class CacheableResponse {
34
- /**
35
- * To construct a new CacheableResponse instance you must provide at least
36
- * one of the `config` properties.
37
- *
38
- * If both `statuses` and `headers` are specified, then both conditions must
39
- * be met for the `Response` to be considered cacheable.
40
- *
41
- * @param {Object} config
42
- * @param {Array<number>} [config.statuses] One or more status codes that a
43
- * `Response` can have and be considered cacheable.
44
- * @param {Object<string,string>} [config.headers] A mapping of header names
45
- * and expected values that a `Response` can have and be considered cacheable.
46
- * If multiple headers are provided, only one needs to be present.
47
- */
48
- constructor(config = {}) {
49
- {
50
- if (!(config.statuses || config.headers)) {
51
- throw new WorkboxError_mjs.WorkboxError('statuses-or-headers-required', {
52
- moduleName: 'workbox-cacheable-response',
53
- className: 'CacheableResponse',
54
- funcName: 'constructor'
55
- });
56
- }
57
-
58
- if (config.statuses) {
59
- assert_mjs.assert.isArray(config.statuses, {
60
- moduleName: 'workbox-cacheable-response',
61
- className: 'CacheableResponse',
62
- funcName: 'constructor',
63
- paramName: 'config.statuses'
64
- });
65
- }
66
-
67
- if (config.headers) {
68
- assert_mjs.assert.isType(config.headers, 'object', {
69
- moduleName: 'workbox-cacheable-response',
70
- className: 'CacheableResponse',
71
- funcName: 'constructor',
72
- paramName: 'config.headers'
73
- });
74
- }
75
- }
76
-
77
- this._statuses = config.statuses;
78
- this._headers = config.headers;
79
- }
80
-
81
- /**
82
- * Checks a response to see whether it's cacheable or not, based on this
83
- * object's configuration.
84
- *
85
- * @param {Response} response The response whose cacheability is being
86
- * checked.
87
- * @return {boolean} `true` if the `Response` is cacheable, and `false`
88
- * otherwise.
89
- */
90
- isResponseCacheable(response) {
91
- {
92
- assert_mjs.assert.isInstance(response, Response, {
93
- moduleName: 'workbox-cacheable-response',
94
- className: 'CacheableResponse',
95
- funcName: 'isResponseCacheable',
96
- paramName: 'response'
97
- });
98
- }
99
-
100
- let cacheable = true;
101
-
102
- if (this._statuses) {
103
- cacheable = this._statuses.includes(response.status);
104
- }
105
-
106
- if (this._headers && cacheable) {
107
- cacheable = Object.keys(this._headers).some(headerName => {
108
- return response.headers.get(headerName) === this._headers[headerName];
109
- });
110
- }
111
-
112
- {
113
- if (!cacheable) {
114
- logger_mjs.logger.groupCollapsed(`The request for ` + `'${getFriendlyURL_mjs.getFriendlyURL(response.url)}' returned a response that does ` + `not meet the criteria for being cached.`);
115
-
116
- logger_mjs.logger.groupCollapsed(`View cacheability criteria here.`);
117
- logger_mjs.logger.unprefixed.log(`Cacheable statuses: ` + JSON.stringify(this._statuses));
118
- logger_mjs.logger.unprefixed.log(`Cacheable headers: ` + JSON.stringify(this._headers, null, 2));
119
- logger_mjs.logger.groupEnd();
120
-
121
- const logFriendlyHeaders = {};
122
- response.headers.forEach((value, key) => {
123
- logFriendlyHeaders[key] = value;
124
- });
125
-
126
- logger_mjs.logger.groupCollapsed(`View response status and headers here.`);
127
- logger_mjs.logger.unprefixed.log(`Response status: ` + response.status);
128
- logger_mjs.logger.unprefixed.log(`Response headers: ` + JSON.stringify(logFriendlyHeaders, null, 2));
129
- logger_mjs.logger.groupEnd();
130
-
131
- logger_mjs.logger.groupCollapsed(`View full response details here.`);
132
- logger_mjs.logger.unprefixed.log(response.headers);
133
- logger_mjs.logger.unprefixed.log(response);
134
- logger_mjs.logger.groupEnd();
135
-
136
- logger_mjs.logger.groupEnd();
137
- }
138
- }
139
-
140
- return cacheable;
141
- }
142
- }
143
-
144
- /*
145
- Copyright 2016 Google Inc. All Rights Reserved.
146
- Licensed under the Apache License, Version 2.0 (the "License");
147
- you may not use this file except in compliance with the License.
148
- You may obtain a copy of the License at
149
- http://www.apache.org/licenses/LICENSE-2.0
150
- Unless required by applicable law or agreed to in writing, software
151
- distributed under the License is distributed on an "AS IS" BASIS,
152
- WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
153
- See the License for the specific language governing permissions and
154
- limitations under the License.
155
- */
156
-
157
- /**
158
- * A class implementing the `cacheWillUpdate` lifecycle callback. This makes it
159
- * easier to add in cacheability checks to requests made via Workbox's built-in
160
- * strategies.
161
- *
162
- * @memberof workbox.cacheableResponse
163
- */
164
- class Plugin {
165
- /**
166
- * To construct a new cacheable response Plugin instance you must provide at
167
- * least one of the `config` properties.
168
- *
169
- * If both `statuses` and `headers` are specified, then both conditions must
170
- * be met for the `Response` to be considered cacheable.
171
- *
172
- * @param {Object} config
173
- * @param {Array<number>} [config.statuses] One or more status codes that a
174
- * `Response` can have and be considered cacheable.
175
- * @param {Object<string,string>} [config.headers] A mapping of header names
176
- * and expected values that a `Response` can have and be considered cacheable.
177
- * If multiple headers are provided, only one needs to be present.
178
- */
179
- constructor(config) {
180
- this._cacheableResponse = new CacheableResponse(config);
181
- }
182
-
183
- /**
184
- * @param {Object} options
185
- * @param {Response} options.response
186
- * @return {boolean}
187
- * @private
188
- */
189
- cacheWillUpdate({ response }) {
190
- if (this._cacheableResponse.isResponseCacheable(response)) {
191
- return response;
192
- }
193
- return null;
194
- }
195
- }
196
-
197
- /*
198
- Copyright 2017 Google Inc.
199
-
200
- Licensed under the Apache License, Version 2.0 (the "License");
201
- you may not use this file except in compliance with the License.
202
- You may obtain a copy of the License at
203
-
204
- https://www.apache.org/licenses/LICENSE-2.0
205
-
206
- Unless required by applicable law or agreed to in writing, software
207
- distributed under the License is distributed on an "AS IS" BASIS,
208
- WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
209
- See the License for the specific language governing permissions and
210
- limitations under the License.
211
- */
212
-
213
- /*
214
- Copyright 2017 Google Inc.
215
-
216
- Licensed under the Apache License, Version 2.0 (the "License");
217
- you may not use this file except in compliance with the License.
218
- You may obtain a copy of the License at
219
-
220
- https://www.apache.org/licenses/LICENSE-2.0
221
-
222
- Unless required by applicable law or agreed to in writing, software
223
- distributed under the License is distributed on an "AS IS" BASIS,
224
- WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
225
- See the License for the specific language governing permissions and
226
- limitations under the License.
227
- */
228
-
229
- exports.CacheableResponse = CacheableResponse;
230
- exports.Plugin = Plugin;
231
-
232
- return exports;
233
-
234
- }({},workbox.core._private,workbox.core._private,workbox.core._private,workbox.core._private));
235
-
236
- //# sourceMappingURL=workbox-cacheable-response.dev.js.map
@@ -1 +0,0 @@
1
- {"version":3,"names":[],"mappings":"","sources":["packages/workbox-cacheable-response/browser.mjs"],"sourcesContent":["this.workbox = this.workbox || {};\nthis.workbox.cacheableResponse = (function (exports,WorkboxError_mjs,assert_mjs,getFriendlyURL_mjs,logger_mjs) {\n 'use strict';\n\n try {\n self.workbox.v['workbox:cacheable-response: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 * This class allows you to set up rules determining what\n * status codes and/or headers need to be present in order for a\n * [`Response`](https://developer.mozilla.org/en-US/docs/Web/API/Response)\n * to be considered cacheable.\n *\n * @memberof workbox.cacheableResponse\n */\n class CacheableResponse {\n /**\n * To construct a new CacheableResponse instance you must provide at least\n * one of the `config` properties.\n *\n * If both `statuses` and `headers` are specified, then both conditions must\n * be met for the `Response` to be considered cacheable.\n *\n * @param {Object} config\n * @param {Array<number>} [config.statuses] One or more status codes that a\n * `Response` can have and be considered cacheable.\n * @param {Object<string,string>} [config.headers] A mapping of header names\n * and expected values that a `Response` can have and be considered cacheable.\n * If multiple headers are provided, only one needs to be present.\n */\n constructor(config = {}) {\n {\n if (!(config.statuses || config.headers)) {\n throw new WorkboxError_mjs.WorkboxError('statuses-or-headers-required', {\n moduleName: 'workbox-cacheable-response',\n className: 'CacheableResponse',\n funcName: 'constructor'\n });\n }\n\n if (config.statuses) {\n assert_mjs.assert.isArray(config.statuses, {\n moduleName: 'workbox-cacheable-response',\n className: 'CacheableResponse',\n funcName: 'constructor',\n paramName: 'config.statuses'\n });\n }\n\n if (config.headers) {\n assert_mjs.assert.isType(config.headers, 'object', {\n moduleName: 'workbox-cacheable-response',\n className: 'CacheableResponse',\n funcName: 'constructor',\n paramName: 'config.headers'\n });\n }\n }\n\n this._statuses = config.statuses;\n this._headers = config.headers;\n }\n\n /**\n * Checks a response to see whether it's cacheable or not, based on this\n * object's configuration.\n *\n * @param {Response} response The response whose cacheability is being\n * checked.\n * @return {boolean} `true` if the `Response` is cacheable, and `false`\n * otherwise.\n */\n isResponseCacheable(response) {\n {\n assert_mjs.assert.isInstance(response, Response, {\n moduleName: 'workbox-cacheable-response',\n className: 'CacheableResponse',\n funcName: 'isResponseCacheable',\n paramName: 'response'\n });\n }\n\n let cacheable = true;\n\n if (this._statuses) {\n cacheable = this._statuses.includes(response.status);\n }\n\n if (this._headers && cacheable) {\n cacheable = Object.keys(this._headers).some(headerName => {\n return response.headers.get(headerName) === this._headers[headerName];\n });\n }\n\n {\n if (!cacheable) {\n logger_mjs.logger.groupCollapsed(`The request for ` + `'${getFriendlyURL_mjs.getFriendlyURL(response.url)}' returned a response that does ` + `not meet the criteria for being cached.`);\n\n logger_mjs.logger.groupCollapsed(`View cacheability criteria here.`);\n logger_mjs.logger.unprefixed.log(`Cacheable statuses: ` + JSON.stringify(this._statuses));\n logger_mjs.logger.unprefixed.log(`Cacheable headers: ` + JSON.stringify(this._headers, null, 2));\n logger_mjs.logger.groupEnd();\n\n const logFriendlyHeaders = {};\n response.headers.forEach((value, key) => {\n logFriendlyHeaders[key] = value;\n });\n\n logger_mjs.logger.groupCollapsed(`View response status and headers here.`);\n logger_mjs.logger.unprefixed.log(`Response status: ` + response.status);\n logger_mjs.logger.unprefixed.log(`Response headers: ` + JSON.stringify(logFriendlyHeaders, null, 2));\n logger_mjs.logger.groupEnd();\n\n logger_mjs.logger.groupCollapsed(`View full response details here.`);\n logger_mjs.logger.unprefixed.log(response.headers);\n logger_mjs.logger.unprefixed.log(response);\n logger_mjs.logger.groupEnd();\n\n logger_mjs.logger.groupEnd();\n }\n }\n\n return cacheable;\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 * A class implementing the `cacheWillUpdate` lifecycle callback. This makes it\n * easier to add in cacheability checks to requests made via Workbox's built-in\n * strategies.\n *\n * @memberof workbox.cacheableResponse\n */\n class Plugin {\n /**\n * To construct a new cacheable response Plugin instance you must provide at\n * least one of the `config` properties.\n *\n * If both `statuses` and `headers` are specified, then both conditions must\n * be met for the `Response` to be considered cacheable.\n *\n * @param {Object} config\n * @param {Array<number>} [config.statuses] One or more status codes that a\n * `Response` can have and be considered cacheable.\n * @param {Object<string,string>} [config.headers] A mapping of header names\n * and expected values that a `Response` can have and be considered cacheable.\n * If multiple headers are provided, only one needs to be present.\n */\n constructor(config) {\n this._cacheableResponse = new CacheableResponse(config);\n }\n\n /**\n * @param {Object} options\n * @param {Response} options.response\n * @return {boolean}\n * @private\n */\n cacheWillUpdate({ response }) {\n if (this._cacheableResponse.isResponseCacheable(response)) {\n return response;\n }\n return null;\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.CacheableResponse = CacheableResponse;\n exports.Plugin = Plugin;\n\n return exports;\n\n}({},workbox.core._private,workbox.core._private,workbox.core._private,workbox.core._private));\n"],"file":"workbox-cacheable-response.dev.js"}
@@ -1,3 +0,0 @@
1
- this.workbox=this.workbox||{},this.workbox.cacheableResponse=function(t){"use strict";try{self.workbox.v["workbox:cacheable-response:3.3.1"]=1}catch(t){}class s{constructor(t={}){this.t=t.statuses,this.s=t.headers}isResponseCacheable(t){let s=!0;return this.t&&(s=this.t.includes(t.status)),this.s&&s&&(s=Object.keys(this.s).some(s=>t.headers.get(s)===this.s[s])),s}}return t.CacheableResponse=s,t.Plugin=class{constructor(t){this.e=new s(t)}cacheWillUpdate({response:t}){return this.e.isResponseCacheable(t)?t:null}},t}({});
2
-
3
- //# sourceMappingURL=workbox-cacheable-response.prod.js.map
@@ -1 +0,0 @@
1
- {"version":3,"names":[],"mappings":"","sources":["packages/workbox-cacheable-response/browser.mjs"],"sourcesContent":["this.workbox=this.workbox||{},this.workbox.cacheableResponse=function(t){\"use strict\";try{self.workbox.v[\"workbox:cacheable-response:3.3.1\"]=1}catch(t){}class s{constructor(t={}){this.t=t.statuses,this.s=t.headers}isResponseCacheable(t){let s=!0;return this.t&&(s=this.t.includes(t.status)),this.s&&s&&(s=Object.keys(this.s).some(s=>t.headers.get(s)===this.s[s])),s}}return t.CacheableResponse=s,t.Plugin=class{constructor(t){this.e=new s(t)}cacheWillUpdate({response:t}){return this.e.isResponseCacheable(t)?t:null}},t}({});\n"],"file":"workbox-cacheable-response.prod.js"}
@@ -1,1690 +0,0 @@
1
- /* eslint-disable */
2
- // This is extracted from the Babel runtime (original source: https://github.com/babel/babel/blob/9e0f5235b1ca5167c368a576ad7c5af62d20b0e3/packages/babel-helpers/src/helpers.js#L240).
3
- // As part of the Rollup bundling process, it's injected once into workbox-core
4
- // and reused throughout all of the other modules, avoiding code duplication.
5
- // See https://github.com/GoogleChrome/workbox/pull/1048#issuecomment-344698046
6
- // for further background.
7
- self.babelHelpers = {
8
- asyncToGenerator: function(fn) {
9
- return function() {
10
- var gen = fn.apply(this, arguments);
11
- return new Promise(function(resolve, reject) {
12
- function step(key, arg) {
13
- try {
14
- var info = gen[key](arg);
15
- var value = info.value;
16
- } catch (error) {
17
- reject(error);
18
- return;
19
- }
20
-
21
- if (info.done) {
22
- resolve(value);
23
- } else {
24
- return Promise.resolve(value).then(function(value) {
25
- step('next', value);
26
- }, function(err) {
27
- step('throw', err);
28
- });
29
- }
30
- }
31
-
32
- return step('next');
33
- });
34
- };
35
- },
36
- };
37
-
38
- this.workbox = this.workbox || {};
39
- this.workbox.core = (function () {
40
- 'use strict';
41
-
42
- try {
43
- self.workbox.v['workbox:core:3.3.1'] = 1;
44
- } catch (e) {} // eslint-disable-line
45
-
46
- /*
47
- Copyright 2017 Google Inc.
48
-
49
- Licensed under the Apache License, Version 2.0 (the "License");
50
- you may not use this file except in compliance with the License.
51
- You may obtain a copy of the License at
52
-
53
- https://www.apache.org/licenses/LICENSE-2.0
54
-
55
- Unless required by applicable law or agreed to in writing, software
56
- distributed under the License is distributed on an "AS IS" BASIS,
57
- WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
58
- See the License for the specific language governing permissions and
59
- limitations under the License.
60
- */
61
-
62
- /**
63
- * The available log levels in Workbox: debug, log, warn, error and silent.
64
- *
65
- * @property {int} debug Prints all logs from Workbox. Useful for debugging.
66
- * @property {int} log Prints console log, warn, error and groups. Default for
67
- * debug builds.
68
- * @property {int} warn Prints console warn, error and groups. Default for
69
- * non-debug builds.
70
- * @property {int} error Print console error and groups.
71
- * @property {int} silent Force no logging from Workbox.
72
- *
73
- * @alias workbox.core.LOG_LEVELS
74
- */
75
-
76
- var LOG_LEVELS = {
77
- debug: 0,
78
- log: 1,
79
- warn: 2,
80
- error: 3,
81
- silent: 4
82
- };
83
-
84
- /*
85
- Copyright 2017 Google Inc.
86
-
87
- Licensed under the Apache License, Version 2.0 (the "License");
88
- you may not use this file except in compliance with the License.
89
- You may obtain a copy of the License at
90
-
91
- https://www.apache.org/licenses/LICENSE-2.0
92
-
93
- Unless required by applicable law or agreed to in writing, software
94
- distributed under the License is distributed on an "AS IS" BASIS,
95
- WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
96
- See the License for the specific language governing permissions and
97
- limitations under the License.
98
- */
99
-
100
- var messages = {
101
- 'invalid-value': ({ paramName, validValueDescription, value }) => {
102
- if (!paramName || !validValueDescription) {
103
- throw new Error(`Unexpected input to 'invalid-value' error.`);
104
- }
105
- return `The '${paramName}' parameter was given a value with an ` + `unexpected value. ${validValueDescription} Received a value of ` + `${JSON.stringify(value)}.`;
106
- },
107
-
108
- 'not-in-sw': ({ moduleName }) => {
109
- if (!moduleName) {
110
- throw new Error(`Unexpected input to 'not-in-sw' error.`);
111
- }
112
- return `The '${moduleName}' must be used in a service worker.`;
113
- },
114
-
115
- 'not-an-array': ({ moduleName, className, funcName, paramName }) => {
116
- if (!moduleName || !className || !funcName || !paramName) {
117
- throw new Error(`Unexpected input to 'not-an-array' error.`);
118
- }
119
- return `The parameter '${paramName}' passed into ` + `'${moduleName}.${className}.${funcName}()' must be an array.`;
120
- },
121
-
122
- 'incorrect-type': ({ expectedType, paramName, moduleName, className,
123
- funcName }) => {
124
- if (!expectedType || !paramName || !moduleName || !funcName) {
125
- throw new Error(`Unexpected input to 'incorrect-type' error.`);
126
- }
127
- return `The parameter '${paramName}' passed into ` + `'${moduleName}.${className ? className + '.' : ''}` + `${funcName}()' must be of type ${expectedType}.`;
128
- },
129
-
130
- 'incorrect-class': ({ expectedClass, paramName, moduleName, className,
131
- funcName, isReturnValueProblem }) => {
132
- if (!expectedClass || !moduleName || !funcName) {
133
- throw new Error(`Unexpected input to 'incorrect-class' error.`);
134
- }
135
-
136
- if (isReturnValueProblem) {
137
- return `The return value from ` + `'${moduleName}.${className ? className + '.' : ''}${funcName}()' ` + `must be an instance of class ${expectedClass.name}.`;
138
- }
139
-
140
- return `The parameter '${paramName}' passed into ` + `'${moduleName}.${className ? className + '.' : ''}${funcName}()' ` + `must be an instance of class ${expectedClass.name}.`;
141
- },
142
-
143
- 'missing-a-method': ({ expectedMethod, paramName, moduleName, className,
144
- funcName }) => {
145
- if (!expectedMethod || !paramName || !moduleName || !className || !funcName) {
146
- throw new Error(`Unexpected input to 'missing-a-method' error.`);
147
- }
148
- return `${moduleName}.${className}.${funcName}() expected the ` + `'${paramName}' parameter to expose a '${expectedMethod}' method.`;
149
- },
150
-
151
- 'add-to-cache-list-unexpected-type': ({ entry }) => {
152
- return `An unexpected entry was passed to ` + `'workbox-precaching.PrecacheController.addToCacheList()' The entry ` + `'${JSON.stringify(entry)}' isn't supported. You must supply an array of ` + `strings with one or more characters, objects with a url property or ` + `Request objects.`;
153
- },
154
-
155
- 'add-to-cache-list-conflicting-entries': ({ firstEntry, secondEntry }) => {
156
- if (!firstEntry || !secondEntry) {
157
- throw new Error(`Unexpected input to ` + `'add-to-cache-list-duplicate-entries' error.`);
158
- }
159
-
160
- return `Two of the entries passed to ` + `'workbox-precaching.PrecacheController.addToCacheList()' had matching ` + `URLs but different revision details. This means workbox-precaching ` + `is unable to determine cache the asset correctly. Please remove one ` + `of the entries.`;
161
- },
162
-
163
- 'plugin-error-request-will-fetch': ({ thrownError }) => {
164
- if (!thrownError) {
165
- throw new Error(`Unexpected input to ` + `'plugin-error-request-will-fetch', error.`);
166
- }
167
-
168
- return `An error was thrown by a plugins 'requestWillFetch()' method. ` + `The thrown error message was: '${thrownError.message}'.`;
169
- },
170
-
171
- 'invalid-cache-name': ({ cacheNameId, value }) => {
172
- if (!cacheNameId) {
173
- throw new Error(`Expected a 'cacheNameId' for error 'invalid-cache-name'`);
174
- }
175
-
176
- return `You must provide a name containing at least one character for ` + `setCacheDeatils({${cacheNameId}: '...'}). Received a value of ` + `'${JSON.stringify(value)}'`;
177
- },
178
-
179
- 'unregister-route-but-not-found-with-method': ({ method }) => {
180
- if (!method) {
181
- throw new Error(`Unexpected input to ` + `'unregister-route-but-not-found-with-method' error.`);
182
- }
183
-
184
- return `The route you're trying to unregister was not previously ` + `registered for the method type '${method}'.`;
185
- },
186
-
187
- 'unregister-route-route-not-registered': () => {
188
- return `The route you're trying to unregister was not previously ` + `registered.`;
189
- },
190
-
191
- 'queue-replay-failed': ({ name, count }) => {
192
- return `${count} requests failed, while trying to replay Queue: ${name}.`;
193
- },
194
-
195
- 'duplicate-queue-name': ({ name }) => {
196
- return `The Queue name '${name}' is already being used. ` + `All instances of backgroundSync.Queue must be given unique names.`;
197
- },
198
-
199
- 'expired-test-without-max-age': ({ methodName, paramName }) => {
200
- return `The '${methodName}()' method can only be used when the ` + `'${paramName}' is used in the constructor.`;
201
- },
202
-
203
- 'unsupported-route-type': ({ moduleName, className, funcName, paramName }) => {
204
- return `The supplied '${paramName}' parameter was an unsupported type. ` + `Please check the docs for ${moduleName}.${className}.${funcName} for ` + `valid input types.`;
205
- },
206
-
207
- 'not-array-of-class': ({ value, expectedClass,
208
- moduleName, className, funcName, paramName }) => {
209
- return `The supplied '${paramName}' parameter must be an array of ` + `'${expectedClass}' objects. Received '${JSON.stringify(value)},'. ` + `Please check the call to ${moduleName}.${className}.${funcName}() ` + `to fix the issue.`;
210
- },
211
-
212
- 'max-entries-or-age-required': ({ moduleName, className, funcName }) => {
213
- return `You must define either config.maxEntries or config.maxAgeSeconds` + `in ${moduleName}.${className}.${funcName}`;
214
- },
215
-
216
- 'statuses-or-headers-required': ({ moduleName, className, funcName }) => {
217
- return `You must define either config.statuses or config.headers` + `in ${moduleName}.${className}.${funcName}`;
218
- },
219
-
220
- 'invalid-string': ({ moduleName, className, funcName, paramName }) => {
221
- if (!paramName || !moduleName || !className || !funcName) {
222
- throw new Error(`Unexpected input to 'invalid-string' error.`);
223
- }
224
- return `When using strings, the '${paramName}' parameter must start with ` + `'http' (for cross-origin matches) or '/' (for same-origin matches). ` + `Please see the docs for ${moduleName}.${className}.${funcName}() for ` + `more info.`;
225
- },
226
- 'channel-name-required': () => {
227
- return `You must provide a channelName to construct a ` + `BroadcastCacheUpdate instance.`;
228
- },
229
- 'invalid-responses-are-same-args': () => {
230
- return `The arguments passed into responsesAreSame() appear to be ` + `invalid. Please ensure valid Responses are used.`;
231
- },
232
- 'expire-custom-caches-only': () => {
233
- return `You must provide a 'cacheName' property when using the ` + `expiration plugin with a runtime caching strategy.`;
234
- },
235
- 'unit-must-be-bytes': ({ normalizedRangeHeader }) => {
236
- if (!normalizedRangeHeader) {
237
- throw new Error(`Unexpected input to 'unit-must-be-bytes' error.`);
238
- }
239
- return `The 'unit' portion of the Range header must be set to 'bytes'. ` + `The Range header provided was "${normalizedRangeHeader}"`;
240
- },
241
- 'single-range-only': ({ normalizedRangeHeader }) => {
242
- if (!normalizedRangeHeader) {
243
- throw new Error(`Unexpected input to 'single-range-only' error.`);
244
- }
245
- return `Multiple ranges are not supported. Please use a single start ` + `value, and optional end value. The Range header provided was ` + `"${normalizedRangeHeader}"`;
246
- },
247
- 'invalid-range-values': ({ normalizedRangeHeader }) => {
248
- if (!normalizedRangeHeader) {
249
- throw new Error(`Unexpected input to 'invalid-range-values' error.`);
250
- }
251
- return `The Range header is missing both start and end values. At least ` + `one of those values is needed. The Range header provided was ` + `"${normalizedRangeHeader}"`;
252
- },
253
- 'no-range-header': () => {
254
- return `No Range header was found in the Request provided.`;
255
- },
256
- 'range-not-satisfiable': ({ size, start, end }) => {
257
- return `The start (${start}) and end (${end}) values in the Range are ` + `not satisfiable by the cached response, which is ${size} bytes.`;
258
- },
259
- 'attempt-to-cache-non-get-request': ({ url, method }) => {
260
- return `Unable to cache '${url}' because it is a '${method}' request and ` + `only 'GET' requests can be cached.`;
261
- },
262
- 'cache-put-with-no-response': ({ url }) => {
263
- return `There was an attempt to cache '${url}' but the response was not ` + `defined.`;
264
- }
265
- };
266
-
267
- /*
268
- Copyright 2017 Google Inc.
269
-
270
- Licensed under the Apache License, Version 2.0 (the "License");
271
- you may not use this file except in compliance with the License.
272
- You may obtain a copy of the License at
273
-
274
- https://www.apache.org/licenses/LICENSE-2.0
275
-
276
- Unless required by applicable law or agreed to in writing, software
277
- distributed under the License is distributed on an "AS IS" BASIS,
278
- WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
279
- See the License for the specific language governing permissions and
280
- limitations under the License.
281
- */
282
-
283
- const generatorFunction = (code, ...args) => {
284
- const message = messages[code];
285
- if (!message) {
286
- throw new Error(`Unable to find message for code '${code}'.`);
287
- }
288
-
289
- return message(...args);
290
- };
291
-
292
- const exportedValue = generatorFunction;
293
-
294
- /*
295
- Copyright 2017 Google Inc.
296
-
297
- Licensed under the Apache License, Version 2.0 (the "License");
298
- you may not use this file except in compliance with the License.
299
- You may obtain a copy of the License at
300
-
301
- https://www.apache.org/licenses/LICENSE-2.0
302
-
303
- Unless required by applicable law or agreed to in writing, software
304
- distributed under the License is distributed on an "AS IS" BASIS,
305
- WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
306
- See the License for the specific language governing permissions and
307
- limitations under the License.
308
- */
309
-
310
- /**
311
- * Workbox errors should be thrown with this class.
312
- * This allows use to ensure the type easily in tests,
313
- * helps developers identify errors from workbox
314
- * easily and allows use to optimise error
315
- * messages correctly.
316
- *
317
- * @private
318
- */
319
- class WorkboxError extends Error {
320
- /**
321
- *
322
- * @param {string} errorCode The error code that
323
- * identifies this particular error.
324
- * @param {Object=} details Any relevant arguments
325
- * that will help developers identify issues should
326
- * be added as a key on the context object.
327
- */
328
- constructor(errorCode, details) {
329
- let message = exportedValue(errorCode, details);
330
-
331
- super(message);
332
-
333
- this.name = errorCode;
334
- this.details = details;
335
- }
336
- }
337
-
338
- /*
339
- Copyright 2017 Google Inc.
340
-
341
- Licensed under the Apache License, Version 2.0 (the "License");
342
- you may not use this file except in compliance with the License.
343
- You may obtain a copy of the License at
344
-
345
- https://www.apache.org/licenses/LICENSE-2.0
346
-
347
- Unless required by applicable law or agreed to in writing, software
348
- distributed under the License is distributed on an "AS IS" BASIS,
349
- WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
350
- See the License for the specific language governing permissions and
351
- limitations under the License.
352
- */
353
-
354
- const _cacheNameDetails = {
355
- prefix: 'workbox',
356
- suffix: self.registration.scope,
357
- googleAnalytics: 'googleAnalytics',
358
- precache: 'precache',
359
- runtime: 'runtime'
360
- };
361
-
362
- const _createCacheName = cacheName => {
363
- return [_cacheNameDetails.prefix, cacheName, _cacheNameDetails.suffix].filter(value => value.length > 0).join('-');
364
- };
365
-
366
- const cacheNames = {
367
- updateDetails: details => {
368
- Object.keys(_cacheNameDetails).forEach(key => {
369
- if (typeof details[key] !== 'undefined') {
370
- _cacheNameDetails[key] = details[key];
371
- }
372
- });
373
- },
374
- getGoogleAnalyticsName: userCacheName => {
375
- return userCacheName || _createCacheName(_cacheNameDetails.googleAnalytics);
376
- },
377
- getPrecacheName: userCacheName => {
378
- return userCacheName || _createCacheName(_cacheNameDetails.precache);
379
- },
380
- getRuntimeName: userCacheName => {
381
- return userCacheName || _createCacheName(_cacheNameDetails.runtime);
382
- }
383
- };
384
-
385
- /*
386
- Copyright 2017 Google Inc.
387
-
388
- Licensed under the Apache License, Version 2.0 (the "License");
389
- you may not use this file except in compliance with the License.
390
- You may obtain a copy of the License at
391
-
392
- https://www.apache.org/licenses/LICENSE-2.0
393
-
394
- Unless required by applicable law or agreed to in writing, software
395
- distributed under the License is distributed on an "AS IS" BASIS,
396
- WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
397
- See the License for the specific language governing permissions and
398
- limitations under the License.
399
- */
400
-
401
- // Safari doesn't print all console.groupCollapsed() arguments.
402
- // Related bug: https://bugs.webkit.org/show_bug.cgi?id=182754
403
- const isSafari = /^((?!chrome|android).)*safari/i.test(navigator.userAgent);
404
-
405
- const GREY = `#7f8c8d`;
406
- const GREEN = `#2ecc71`;
407
- const YELLOW = `#f39c12`;
408
- const RED = `#c0392b`;
409
- const BLUE = `#3498db`;
410
-
411
- const getDefaultLogLevel = () => LOG_LEVELS.log;
412
-
413
- let logLevel = getDefaultLogLevel();
414
- const shouldPrint = minLevel => logLevel <= minLevel;
415
- const setLoggerLevel = newLogLevel => logLevel = newLogLevel;
416
- const getLoggerLevel = () => logLevel;
417
-
418
- // We always want groups to be logged unless logLevel is silent.
419
- const groupLevel = LOG_LEVELS.error;
420
-
421
- const _print = function (keyName, logArgs, levelColor) {
422
- const logLevel = keyName.indexOf('group') === 0 ? groupLevel : LOG_LEVELS[keyName];
423
- if (!shouldPrint(logLevel)) {
424
- return;
425
- }
426
-
427
- if (!levelColor || keyName === 'groupCollapsed' && isSafari) {
428
- console[keyName](...logArgs);
429
- return;
430
- }
431
-
432
- const logPrefix = ['%cworkbox', `background: ${levelColor}; color: white; padding: 2px 0.5em; ` + `border-radius: 0.5em;`];
433
- console[keyName](...logPrefix, ...logArgs);
434
- };
435
-
436
- const groupEnd = () => {
437
- if (shouldPrint(groupLevel)) {
438
- console.groupEnd();
439
- }
440
- };
441
-
442
- const defaultExport = {
443
- groupEnd,
444
- unprefixed: {
445
- groupEnd
446
- }
447
- };
448
-
449
- const setupLogs = (keyName, color) => {
450
- defaultExport[keyName] = (...args) => _print(keyName, args, color);
451
- defaultExport.unprefixed[keyName] = (...args) => _print(keyName, args);
452
- };
453
-
454
- const levelToColor = {
455
- debug: GREY,
456
- log: GREEN,
457
- warn: YELLOW,
458
- error: RED,
459
- groupCollapsed: BLUE
460
- };
461
- Object.keys(levelToColor).forEach(keyName => setupLogs(keyName, levelToColor[keyName]));
462
-
463
- /*
464
- Copyright 2017 Google Inc.
465
-
466
- Licensed under the Apache License, Version 2.0 (the "License");
467
- you may not use this file except in compliance with the License.
468
- You may obtain a copy of the License at
469
-
470
- https://www.apache.org/licenses/LICENSE-2.0
471
-
472
- Unless required by applicable law or agreed to in writing, software
473
- distributed under the License is distributed on an "AS IS" BASIS,
474
- WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
475
- See the License for the specific language governing permissions and
476
- limitations under the License.
477
- */
478
-
479
- /*
480
- * This method returns true if the current context is a service worker.
481
- */
482
- const isSwEnv = moduleName => {
483
- if (!('ServiceWorkerGlobalScope' in self)) {
484
- throw new WorkboxError('not-in-sw', { moduleName });
485
- }
486
- };
487
-
488
- /*
489
- * This method throws if the supplied value is not an array.
490
- * The destructed values are required to produce a meaningful error for users.
491
- * The destructed and restructured object is so it's clear what is
492
- * needed.
493
- */
494
- const isArray = (value, { moduleName, className, funcName, paramName }) => {
495
- if (!Array.isArray(value)) {
496
- throw new WorkboxError('not-an-array', {
497
- moduleName,
498
- className,
499
- funcName,
500
- paramName
501
- });
502
- }
503
- };
504
-
505
- const hasMethod = (object, expectedMethod, { moduleName, className, funcName, paramName }) => {
506
- const type = typeof object[expectedMethod];
507
- if (type !== 'function') {
508
- throw new WorkboxError('missing-a-method', { paramName, expectedMethod,
509
- moduleName, className, funcName });
510
- }
511
- };
512
-
513
- const isType = (object, expectedType, { moduleName, className, funcName, paramName }) => {
514
- if (typeof object !== expectedType) {
515
- throw new WorkboxError('incorrect-type', { paramName, expectedType,
516
- moduleName, className, funcName });
517
- }
518
- };
519
-
520
- const isInstance = (object, expectedClass, { moduleName, className, funcName,
521
- paramName, isReturnValueProblem }) => {
522
- if (!(object instanceof expectedClass)) {
523
- throw new WorkboxError('incorrect-class', { paramName, expectedClass,
524
- moduleName, className, funcName, isReturnValueProblem });
525
- }
526
- };
527
-
528
- const isOneOf = (value, validValues, { paramName }) => {
529
- if (!validValues.includes(value)) {
530
- throw new WorkboxError('invalid-value', {
531
- paramName,
532
- value,
533
- validValueDescription: `Valid values are ${JSON.stringify(validValues)}.`
534
- });
535
- }
536
- };
537
-
538
- const isArrayOfClass = (value, expectedClass, { moduleName, className, funcName, paramName }) => {
539
- const error = new WorkboxError('not-array-of-class', {
540
- value, expectedClass,
541
- moduleName, className, funcName, paramName
542
- });
543
- if (!Array.isArray(value)) {
544
- throw error;
545
- }
546
-
547
- for (let item of value) {
548
- if (!(item instanceof expectedClass)) {
549
- throw error;
550
- }
551
- }
552
- };
553
-
554
- const finalAssertExports = {
555
- hasMethod,
556
- isArray,
557
- isInstance,
558
- isOneOf,
559
- isSwEnv,
560
- isType,
561
- isArrayOfClass
562
- };
563
-
564
- /*
565
- Copyright 2017 Google Inc.
566
-
567
- Licensed under the Apache License, Version 2.0 (the "License");
568
- you may not use this file except in compliance with the License.
569
- You may obtain a copy of the License at
570
-
571
- https://www.apache.org/licenses/LICENSE-2.0
572
-
573
- Unless required by applicable law or agreed to in writing, software
574
- distributed under the License is distributed on an "AS IS" BASIS,
575
- WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
576
- See the License for the specific language governing permissions and
577
- limitations under the License.
578
- */
579
-
580
- /**
581
- * Logs a warning to the user recommending changing
582
- * to max-age=0 or no-cache.
583
- *
584
- * @param {string} cacheControlHeader
585
- *
586
- * @private
587
- */
588
- function showWarning(cacheControlHeader) {
589
- const docsUrl = 'https://developers.google.com/web/tools/workbox/guides/service-worker-checklist#cache-control_of_your_service_worker_file';
590
- defaultExport.warn(`You are setting a 'cache-control' header of ` + `'${cacheControlHeader}' on your service worker file. This should be ` + `set to 'max-age=0' or 'no-cache' to ensure the latest service worker ` + `is served to your users. Learn more here: ${docsUrl}`);
591
- }
592
-
593
- /**
594
- * Checks for cache-control header on SW file and
595
- * warns the developer if it exists with a value
596
- * other than max-age=0 or no-cache.
597
- *
598
- * @return {Promise}
599
- * @private
600
- */
601
- function checkSWFileCacheHeaders() {
602
- // This is wrapped as an iife to allow async/await while making
603
- // rollup exclude it in builds.
604
- return babelHelpers.asyncToGenerator(function* () {
605
- try {
606
- const swFile = self.location.href;
607
- const response = yield fetch(swFile);
608
- if (!response.ok) {
609
- // Response failed so nothing we can check;
610
- return;
611
- }
612
-
613
- if (!response.headers.has('cache-control')) {
614
- // No cache control header.
615
- return;
616
- }
617
-
618
- const cacheControlHeader = response.headers.get('cache-control');
619
- const maxAgeResult = /max-age\s*=\s*(\d*)/g.exec(cacheControlHeader);
620
- if (maxAgeResult) {
621
- if (parseInt(maxAgeResult[1], 10) === 0) {
622
- return;
623
- }
624
- }
625
-
626
- if (cacheControlHeader.indexOf('no-cache') !== -1) {
627
- return;
628
- }
629
-
630
- if (cacheControlHeader.indexOf('no-store') !== -1) {
631
- return;
632
- }
633
-
634
- showWarning(cacheControlHeader);
635
- } catch (err) {
636
- // NOOP
637
- }
638
- })();
639
- }
640
-
641
- const finalCheckSWFileCacheHeaders = checkSWFileCacheHeaders;
642
-
643
- /*
644
- Copyright 2017 Google Inc.
645
-
646
- Licensed under the Apache License, Version 2.0 (the "License");
647
- you may not use this file except in compliance with the License.
648
- You may obtain a copy of the License at
649
-
650
- https://www.apache.org/licenses/LICENSE-2.0
651
-
652
- Unless required by applicable law or agreed to in writing, software
653
- distributed under the License is distributed on an "AS IS" BASIS,
654
- WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
655
- See the License for the specific language governing permissions and
656
- limitations under the License.
657
- */
658
-
659
- /**
660
- * This class is never exposed publicly. Inidividual methods are exposed
661
- * using jsdoc alias commands.
662
- *
663
- * @memberof workbox.core
664
- * @private
665
- */
666
- class WorkboxCore {
667
- /**
668
- * You should not instantiate this object directly.
669
- *
670
- * @private
671
- */
672
- constructor() {
673
- // Give our version strings something to hang off of.
674
- try {
675
- self.workbox.v = self.workbox.v || {};
676
- } catch (err) {}
677
- // NOOP
678
-
679
-
680
- // A WorkboxCore instance must be exported before we can use the logger.
681
- // This is so it can get the current log level.
682
- {
683
- const padding = ' ';
684
- defaultExport.groupCollapsed('Welcome to Workbox!');
685
- defaultExport.unprefixed.log(`You are currently using a development build. ` + `By default this will switch to prod builds when not on localhost. ` + `You can force this with workbox.setConfig({debug: true|false}).`);
686
- defaultExport.unprefixed.log(`📖 Read the guides and documentation\n` + `${padding}https://developers.google.com/web/tools/workbox/`);
687
- defaultExport.unprefixed.log(`❓ Use the [workbox] tag on Stack Overflow to ask questions\n` + `${padding}https://stackoverflow.com/questions/ask?tags=workbox`);
688
- defaultExport.unprefixed.log(`🐛 Found a bug? Report it on GitHub\n` + `${padding}https://github.com/GoogleChrome/workbox/issues/new`);
689
- defaultExport.groupEnd();
690
-
691
- if (typeof finalCheckSWFileCacheHeaders === 'function') {
692
- finalCheckSWFileCacheHeaders();
693
- }
694
- }
695
- }
696
-
697
- /**
698
- * Get the current cache names used by Workbox.
699
- *
700
- * `cacheNames.precache` is used for precached assets,
701
- * `cacheNames.googleAnalytics` is used by `workbox-google-analytics` to
702
- * store `analytics.js`,
703
- * and `cacheNames.runtime` is used for everything else.
704
- *
705
- * @return {Object} An object with `precache` and `runtime` cache names.
706
- *
707
- * @alias workbox.core.cacheNames
708
- */
709
- get cacheNames() {
710
- return {
711
- googleAnalytics: cacheNames.getGoogleAnalyticsName(),
712
- precache: cacheNames.getPrecacheName(),
713
- runtime: cacheNames.getRuntimeName()
714
- };
715
- }
716
-
717
- /**
718
- * You can alter the default cache names used by the Workbox modules by
719
- * changing the cache name details.
720
- *
721
- * Cache names are generated as `<prefix>-<Cache Name>-<suffix>`.
722
- *
723
- * @param {Object} details
724
- * @param {Object} details.prefix The string to add to the beginning of
725
- * the precache and runtime cache names.
726
- * @param {Object} details.suffix The string to add to the end of
727
- * the precache and runtime cache names.
728
- * @param {Object} details.precache The cache name to use for precache
729
- * caching.
730
- * @param {Object} details.runtime The cache name to use for runtime caching.
731
- * @param {Object} details.googleAnalytics The cache name to use for
732
- * `workbox-google-analytics` caching.
733
- *
734
- * @alias workbox.core.setCacheNameDetails
735
- */
736
- setCacheNameDetails(details) {
737
- {
738
- Object.keys(details).forEach(key => {
739
- finalAssertExports.isType(details[key], 'string', {
740
- moduleName: 'workbox-core',
741
- className: 'WorkboxCore',
742
- funcName: 'setCacheNameDetails',
743
- paramName: `details.${key}`
744
- });
745
- });
746
-
747
- if ('precache' in details && details.precache.length === 0) {
748
- throw new WorkboxError('invalid-cache-name', {
749
- cacheNameId: 'precache',
750
- value: details.precache
751
- });
752
- }
753
-
754
- if ('runtime' in details && details.runtime.length === 0) {
755
- throw new WorkboxError('invalid-cache-name', {
756
- cacheNameId: 'runtime',
757
- value: details.runtime
758
- });
759
- }
760
-
761
- if ('googleAnalytics' in details && details.googleAnalytics.length === 0) {
762
- throw new WorkboxError('invalid-cache-name', {
763
- cacheNameId: 'googleAnalytics',
764
- value: details.googleAnalytics
765
- });
766
- }
767
- }
768
-
769
- cacheNames.updateDetails(details);
770
- }
771
-
772
- /**
773
- * Get the current log level.
774
- *
775
- * @return {number}.
776
- *
777
- * @alias workbox.core.logLevel
778
- */
779
- get logLevel() {
780
- return getLoggerLevel();
781
- }
782
-
783
- /**
784
- * Set the current log level passing in one of the values from
785
- * [LOG_LEVELS]{@link module:workbox-core.LOG_LEVELS}.
786
- *
787
- * @param {number} newLevel The new log level to use.
788
- *
789
- * @alias workbox.core.setLogLevel
790
- */
791
- setLogLevel(newLevel) {
792
- {
793
- finalAssertExports.isType(newLevel, 'number', {
794
- moduleName: 'workbox-core',
795
- className: 'WorkboxCore',
796
- funcName: 'logLevel [setter]',
797
- paramName: `logLevel`
798
- });
799
- }
800
-
801
- if (newLevel > LOG_LEVELS.silent || newLevel < LOG_LEVELS.debug) {
802
- throw new WorkboxError('invalid-value', {
803
- paramName: 'logLevel',
804
- validValueDescription: `Please use a value from LOG_LEVELS, i.e ` + `'logLevel = workbox.core.LOG_LEVELS.debug'.`,
805
- value: newLevel
806
- });
807
- }
808
-
809
- setLoggerLevel(newLevel);
810
- }
811
- }
812
-
813
- var defaultExport$1 = new WorkboxCore();
814
-
815
- /*
816
- Copyright 2017 Google Inc.
817
-
818
- Licensed under the Apache License, Version 2.0 (the "License");
819
- you may not use this file except in compliance with the License.
820
- You may obtain a copy of the License at
821
-
822
- https://www.apache.org/licenses/LICENSE-2.0
823
-
824
- Unless required by applicable law or agreed to in writing, software
825
- distributed under the License is distributed on an "AS IS" BASIS,
826
- WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
827
- See the License for the specific language governing permissions and
828
- limitations under the License.
829
- */
830
-
831
- /**
832
- * A class that wraps common IndexedDB functionality in a promise-based API.
833
- * It exposes all the underlying power and functionality of IndexedDB, but
834
- * wraps the most commonly used features in a way that's much simpler to use.
835
- *
836
- * @private
837
- */
838
- class DBWrapper {
839
- /**
840
- * @param {string} name
841
- * @param {number} version
842
- * @param {Object=} [callback]
843
- * @param {function(this:DBWrapper, Event)} [callbacks.onupgradeneeded]
844
- * @param {function(this:DBWrapper, Event)} [callbacks.onversionchange]
845
- * Defaults to DBWrapper.prototype._onversionchange when not specified.
846
- */
847
- constructor(name, version, {
848
- onupgradeneeded,
849
- onversionchange = this._onversionchange
850
- } = {}) {
851
- this._name = name;
852
- this._version = version;
853
- this._onupgradeneeded = onupgradeneeded;
854
- this._onversionchange = onversionchange;
855
-
856
- // If this is null, it means the database isn't open.
857
- this._db = null;
858
- }
859
-
860
- /**
861
- * Opens a connected to an IDBDatabase, invokes any onupgradedneeded
862
- * callback, and added an onversionchange callback to the database.
863
- *
864
- * @return {IDBDatabase}
865
- *
866
- * @private
867
- */
868
- open() {
869
- var _this = this;
870
-
871
- return babelHelpers.asyncToGenerator(function* () {
872
- if (_this._db) return;
873
-
874
- _this._db = yield new Promise(function (resolve, reject) {
875
- // This flag is flipped to true if the timeout callback runs prior
876
- // to the request failing or succeeding. Note: we use a timeout instead
877
- // of an onblocked handler since there are cases where onblocked will
878
- // never never run. A timeout better handles all possible scenarios:
879
- // https://github.com/w3c/IndexedDB/issues/223
880
- let openRequestTimedOut = false;
881
- setTimeout(function () {
882
- openRequestTimedOut = true;
883
- reject(new Error('The open request was blocked and timed out'));
884
- }, _this.OPEN_TIMEOUT);
885
-
886
- const openRequest = indexedDB.open(_this._name, _this._version);
887
- openRequest.onerror = function (evt) {
888
- return reject(openRequest.error);
889
- };
890
- openRequest.onupgradeneeded = function (evt) {
891
- if (openRequestTimedOut) {
892
- openRequest.transaction.abort();
893
- evt.target.result.close();
894
- } else if (_this._onupgradeneeded) {
895
- _this._onupgradeneeded(evt);
896
- }
897
- };
898
- openRequest.onsuccess = function (evt) {
899
- const db = evt.target.result;
900
- if (openRequestTimedOut) {
901
- db.close();
902
- } else {
903
- db.onversionchange = _this._onversionchange;
904
- resolve(db);
905
- }
906
- };
907
- });
908
-
909
- return _this;
910
- })();
911
- }
912
-
913
- /**
914
- * Delegates to the native `get()` method for the object store.
915
- *
916
- * @param {string} storeName The name of the object store to put the value.
917
- * @param {...*} args The values passed to the delegated method.
918
- * @return {*} The key of the entry.
919
- *
920
- * @private
921
- */
922
- get(storeName, ...args) {
923
- var _this2 = this;
924
-
925
- return babelHelpers.asyncToGenerator(function* () {
926
- return yield _this2._call('get', storeName, 'readonly', ...args);
927
- })();
928
- }
929
-
930
- /**
931
- * Delegates to the native `add()` method for the object store.
932
- *
933
- * @param {string} storeName The name of the object store to put the value.
934
- * @param {...*} args The values passed to the delegated method.
935
- * @return {*} The key of the entry.
936
- *
937
- * @private
938
- */
939
- add(storeName, ...args) {
940
- var _this3 = this;
941
-
942
- return babelHelpers.asyncToGenerator(function* () {
943
- return yield _this3._call('add', storeName, 'readwrite', ...args);
944
- })();
945
- }
946
-
947
- /**
948
- * Delegates to the native `put()` method for the object store.
949
- *
950
- * @param {string} storeName The name of the object store to put the value.
951
- * @param {...*} args The values passed to the delegated method.
952
- * @return {*} The key of the entry.
953
- *
954
- * @private
955
- */
956
- put(storeName, ...args) {
957
- var _this4 = this;
958
-
959
- return babelHelpers.asyncToGenerator(function* () {
960
- return yield _this4._call('put', storeName, 'readwrite', ...args);
961
- })();
962
- }
963
-
964
- /**
965
- * Delegates to the native `delete()` method for the object store.
966
- *
967
- * @param {string} storeName
968
- * @param {...*} args The values passed to the delegated method.
969
- *
970
- * @private
971
- */
972
- delete(storeName, ...args) {
973
- var _this5 = this;
974
-
975
- return babelHelpers.asyncToGenerator(function* () {
976
- yield _this5._call('delete', storeName, 'readwrite', ...args);
977
- })();
978
- }
979
-
980
- /**
981
- * Deletes the underlying database, ensuring that any open connections are
982
- * closed first.
983
- *
984
- * @private
985
- */
986
- deleteDatabase() {
987
- var _this6 = this;
988
-
989
- return babelHelpers.asyncToGenerator(function* () {
990
- _this6.close();
991
- _this6._db = null;
992
- yield new Promise(function (resolve, reject) {
993
- const request = indexedDB.deleteDatabase(_this6._name);
994
- request.onerror = function (evt) {
995
- return reject(evt.target.error);
996
- };
997
- request.onblocked = function () {
998
- return reject(new Error('Deletion was blocked.'));
999
- };
1000
- request.onsuccess = function () {
1001
- return resolve();
1002
- };
1003
- });
1004
- })();
1005
- }
1006
-
1007
- /**
1008
- * Delegates to the native `getAll()` or polyfills it via the `find()`
1009
- * method in older browsers.
1010
- *
1011
- * @param {string} storeName
1012
- * @param {*} query
1013
- * @param {number} count
1014
- * @return {Array}
1015
- *
1016
- * @private
1017
- */
1018
- getAll(storeName, query, count) {
1019
- var _this7 = this;
1020
-
1021
- return babelHelpers.asyncToGenerator(function* () {
1022
- if ('getAll' in IDBObjectStore.prototype) {
1023
- return yield _this7._call('getAll', storeName, 'readonly', query, count);
1024
- } else {
1025
- return yield _this7.getAllMatching(storeName, { query, count });
1026
- }
1027
- })();
1028
- }
1029
-
1030
- /**
1031
- * Supports flexible lookup in an object store by specifying an index,
1032
- * query, direction, and count. This method returns an array of objects
1033
- * with the signature .
1034
- *
1035
- * @param {string} storeName
1036
- * @param {Object} [opts]
1037
- * @param {IDBCursorDirection} [opts.direction]
1038
- * @param {*} [opts.query]
1039
- * @param {string} [opts.index] The index to use (if specified).
1040
- * @param {number} [opts.count] The max number of results to return.
1041
- * @param {boolean} [opts.includeKeys] When true, the structure of the
1042
- * returned objects is changed from an array of values to an array of
1043
- * objects in the form {key, primaryKey, value}.
1044
- * @return {Array}
1045
- *
1046
- * @private
1047
- */
1048
- getAllMatching(storeName, opts = {}) {
1049
- var _this8 = this;
1050
-
1051
- return babelHelpers.asyncToGenerator(function* () {
1052
- return yield _this8.transaction([storeName], 'readonly', function (stores, done) {
1053
- const store = stores[storeName];
1054
- const target = opts.index ? store.index(opts.index) : store;
1055
- const results = [];
1056
-
1057
- target.openCursor(opts.query, opts.direction).onsuccess = function (evt) {
1058
- const cursor = evt.target.result;
1059
- if (cursor) {
1060
- const { primaryKey, key, value } = cursor;
1061
- results.push(opts.includeKeys ? { primaryKey, key, value } : value);
1062
- if (opts.count && results.length >= opts.count) {
1063
- done(results);
1064
- } else {
1065
- cursor.continue();
1066
- }
1067
- } else {
1068
- done(results);
1069
- }
1070
- };
1071
- });
1072
- })();
1073
- }
1074
-
1075
- /**
1076
- * Accepts a list of stores, a transaction type, and a callback and
1077
- * performs a transaction. A promise is returned that resolves to whatever
1078
- * value the callback chooses. The callback holds all the transaction logic
1079
- * and is invoked with three arguments:
1080
- * 1. An object mapping object store names to IDBObjectStore values.
1081
- * 2. A `done` function, that's used to resolve the promise when
1082
- * when the transaction is done.
1083
- * 3. An `abort` function that can be called to abort the transaction
1084
- * at any time.
1085
- *
1086
- * @param {Array<string>} storeNames An array of object store names
1087
- * involved in the transaction.
1088
- * @param {string} type Can be `readonly` or `readwrite`.
1089
- * @param {function(Object, function(), function(*)):?IDBRequest} callback
1090
- * @return {*} The result of the transaction ran by the callback.
1091
- *
1092
- * @private
1093
- */
1094
- transaction(storeNames, type, callback) {
1095
- var _this9 = this;
1096
-
1097
- return babelHelpers.asyncToGenerator(function* () {
1098
- yield _this9.open();
1099
- const result = yield new Promise(function (resolve, reject) {
1100
- const txn = _this9._db.transaction(storeNames, type);
1101
- const done = function (value) {
1102
- return resolve(value);
1103
- };
1104
- const abort = function () {
1105
- reject(new Error('The transaction was manually aborted'));
1106
- txn.abort();
1107
- };
1108
- txn.onerror = function (evt) {
1109
- return reject(evt.target.error);
1110
- };
1111
- txn.onabort = function (evt) {
1112
- return reject(evt.target.error);
1113
- };
1114
- txn.oncomplete = function () {
1115
- return resolve();
1116
- };
1117
-
1118
- const stores = {};
1119
- for (const storeName of storeNames) {
1120
- stores[storeName] = txn.objectStore(storeName);
1121
- }
1122
- callback(stores, done, abort);
1123
- });
1124
- return result;
1125
- })();
1126
- }
1127
-
1128
- /**
1129
- * Delegates async to a native IDBObjectStore method.
1130
- *
1131
- * @param {string} method The method name.
1132
- * @param {string} storeName The object store name.
1133
- * @param {string} type Can be `readonly` or `readwrite`.
1134
- * @param {...*} args The list of args to pass to the native method.
1135
- * @return {*} The result of the transaction.
1136
- *
1137
- * @private
1138
- */
1139
- _call(method, storeName, type, ...args) {
1140
- var _this10 = this;
1141
-
1142
- return babelHelpers.asyncToGenerator(function* () {
1143
- yield _this10.open();
1144
- const callback = function (stores, done) {
1145
- stores[storeName][method](...args).onsuccess = function (evt) {
1146
- done(evt.target.result);
1147
- };
1148
- };
1149
-
1150
- return yield _this10.transaction([storeName], type, callback);
1151
- })();
1152
- }
1153
-
1154
- /**
1155
- * The default onversionchange handler, which closes the database so other
1156
- * connections can open without being blocked.
1157
- *
1158
- * @param {Event} evt
1159
- *
1160
- * @private
1161
- */
1162
- _onversionchange(evt) {
1163
- this.close();
1164
- }
1165
-
1166
- /**
1167
- * Closes the connection opened by `DBWrapper.open()`. Generally this method
1168
- * doesn't need to be called since:
1169
- * 1. It's usually better to keep a connection open since opening
1170
- * a new connection is somewhat slow.
1171
- * 2. Connections are automatically closed when the reference is
1172
- * garbage collected.
1173
- * The primary use case for needing to close a connection is when another
1174
- * reference (typically in another tab) needs to upgrade it and would be
1175
- * blocked by the current, open connection.
1176
- *
1177
- * @private
1178
- */
1179
- close() {
1180
- if (this._db) this._db.close();
1181
- }
1182
- }
1183
-
1184
- // Exposed to let users modify the default timeout on a per-instance
1185
- // or global basis.
1186
- DBWrapper.prototype.OPEN_TIMEOUT = 2000;
1187
-
1188
- /*
1189
- Copyright 2017 Google Inc.
1190
-
1191
- Licensed under the Apache License, Version 2.0 (the "License");
1192
- you may not use this file except in compliance with the License.
1193
- You may obtain a copy of the License at
1194
-
1195
- https://www.apache.org/licenses/LICENSE-2.0
1196
-
1197
- Unless required by applicable law or agreed to in writing, software
1198
- distributed under the License is distributed on an "AS IS" BASIS,
1199
- WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
1200
- See the License for the specific language governing permissions and
1201
- limitations under the License.
1202
- */
1203
-
1204
- var pluginEvents = {
1205
- CACHE_DID_UPDATE: 'cacheDidUpdate',
1206
- CACHE_WILL_UPDATE: 'cacheWillUpdate',
1207
- CACHED_RESPONSE_WILL_BE_USED: 'cachedResponseWillBeUsed',
1208
- FETCH_DID_FAIL: 'fetchDidFail',
1209
- REQUEST_WILL_FETCH: 'requestWillFetch'
1210
- };
1211
-
1212
- /*
1213
- Copyright 2017 Google Inc.
1214
-
1215
- Licensed under the Apache License, Version 2.0 (the "License");
1216
- you may not use this file except in compliance with the License.
1217
- You may obtain a copy of the License at
1218
-
1219
- https://www.apache.org/licenses/LICENSE-2.0
1220
-
1221
- Unless required by applicable law or agreed to in writing, software
1222
- distributed under the License is distributed on an "AS IS" BASIS,
1223
- WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
1224
- See the License for the specific language governing permissions and
1225
- limitations under the License.
1226
- */
1227
-
1228
- var pluginUtils = {
1229
- filter: (plugins, callbackname) => {
1230
- return plugins.filter(plugin => callbackname in plugin);
1231
- }
1232
- };
1233
-
1234
- /**
1235
- * Runs all of the callback functions, one at a time sequentially, in the order
1236
- * in which they were registered.
1237
- *
1238
- * @memberof workbox.core
1239
- * @private
1240
- */
1241
- let executeQuotaErrorCallbacks = (() => {
1242
- var _ref = babelHelpers.asyncToGenerator(function* () {
1243
- {
1244
- defaultExport.log(`About to run ${callbacks.size} callbacks to clean up caches.`);
1245
- }
1246
-
1247
- for (const callback of callbacks) {
1248
- yield callback();
1249
- {
1250
- defaultExport.log(callback, 'is complete.');
1251
- }
1252
- }
1253
-
1254
- {
1255
- defaultExport.log('Finished running callbacks.');
1256
- }
1257
- });
1258
-
1259
- return function executeQuotaErrorCallbacks() {
1260
- return _ref.apply(this, arguments);
1261
- };
1262
- })();
1263
-
1264
- const callbacks = new Set();
1265
-
1266
- /**
1267
- * Adds a function to the set of callbacks that will be executed when there's
1268
- * a quota error.
1269
- *
1270
- * @param {Function} callback
1271
- * @memberof workbox.core
1272
- */
1273
- function registerQuotaErrorCallback(callback) {
1274
- {
1275
- finalAssertExports.isType(callback, 'function', {
1276
- moduleName: 'workbox-core',
1277
- funcName: 'register',
1278
- paramName: 'callback'
1279
- });
1280
- }
1281
-
1282
- callbacks.add(callback);
1283
-
1284
- {
1285
- defaultExport.log('Registered a callback to respond to quota errors.', callback);
1286
- }
1287
- }
1288
-
1289
- /*
1290
- Copyright 2017 Google Inc.
1291
-
1292
- Licensed under the Apache License, Version 2.0 (the "License");
1293
- you may not use this file except in compliance with the License.
1294
- You may obtain a copy of the License at
1295
-
1296
- https://www.apache.org/licenses/LICENSE-2.0
1297
-
1298
- Unless required by applicable law or agreed to in writing, software
1299
- distributed under the License is distributed on an "AS IS" BASIS,
1300
- WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
1301
- See the License for the specific language governing permissions and
1302
- limitations under the License.
1303
- */
1304
-
1305
- const getFriendlyURL = url => {
1306
- const urlObj = new URL(url, location);
1307
- if (urlObj.origin === location.origin) {
1308
- return urlObj.pathname;
1309
- }
1310
- return urlObj.href;
1311
- };
1312
-
1313
- /*
1314
- Copyright 2017 Google Inc.
1315
-
1316
- Licensed under the Apache License, Version 2.0 (the "License");
1317
- you may not use this file except in compliance with the License.
1318
- You may obtain a copy of the License at
1319
-
1320
- https://www.apache.org/licenses/LICENSE-2.0
1321
-
1322
- Unless required by applicable law or agreed to in writing, software
1323
- distributed under the License is distributed on an "AS IS" BASIS,
1324
- WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
1325
- See the License for the specific language governing permissions and
1326
- limitations under the License.
1327
- */
1328
-
1329
- /**
1330
- * Wrapper around cache.put().
1331
- *
1332
- * Will call `cacheDidUpdate` on plugins if the cache was updated.
1333
- *
1334
- * @param {string} cacheName
1335
- * @param {Request} request
1336
- * @param {Response} response
1337
- * @param {Array<Object>} [plugins]
1338
- *
1339
- * @private
1340
- * @memberof module:workbox-core
1341
- */
1342
- const putWrapper = (() => {
1343
- var _ref = babelHelpers.asyncToGenerator(function* (cacheName, request, response, plugins = []) {
1344
- if (!response) {
1345
- {
1346
- defaultExport.error(`Cannot cache non-existent response for ` + `'${getFriendlyURL(request.url)}'.`);
1347
- }
1348
-
1349
- throw new WorkboxError('cache-put-with-no-response', {
1350
- url: getFriendlyURL(request.url)
1351
- });
1352
- }
1353
-
1354
- let responseToCache = yield _isResponseSafeToCache(request, response, plugins);
1355
-
1356
- if (!responseToCache) {
1357
- {
1358
- defaultExport.debug(`Response '${getFriendlyURL(request.url)}' will not be ` + `cached.`, responseToCache);
1359
- }
1360
- return;
1361
- }
1362
-
1363
- {
1364
- if (responseToCache.method && responseToCache.method !== 'GET') {
1365
- throw new WorkboxError('attempt-to-cache-non-get-request', {
1366
- url: getFriendlyURL(request.url),
1367
- method: responseToCache.method
1368
- });
1369
- }
1370
- }
1371
-
1372
- const cache = yield caches.open(cacheName);
1373
-
1374
- const updatePlugins = pluginUtils.filter(plugins, pluginEvents.CACHE_DID_UPDATE);
1375
-
1376
- let oldResponse = updatePlugins.length > 0 ? yield matchWrapper(cacheName, request) : null;
1377
-
1378
- {
1379
- defaultExport.debug(`Updating the '${cacheName}' cache with a new Response for ` + `${getFriendlyURL(request.url)}.`);
1380
- }
1381
-
1382
- try {
1383
- yield cache.put(request, responseToCache);
1384
- } catch (error) {
1385
- // See https://developer.mozilla.org/en-US/docs/Web/API/DOMException#exception-QuotaExceededError
1386
- if (error.name === 'QuotaExceededError') {
1387
- yield executeQuotaErrorCallbacks();
1388
- }
1389
- throw error;
1390
- }
1391
-
1392
- for (let plugin of updatePlugins) {
1393
- yield plugin[pluginEvents.CACHE_DID_UPDATE].call(plugin, {
1394
- cacheName,
1395
- request,
1396
- oldResponse,
1397
- newResponse: responseToCache
1398
- });
1399
- }
1400
- });
1401
-
1402
- return function putWrapper(_x, _x2, _x3) {
1403
- return _ref.apply(this, arguments);
1404
- };
1405
- })();
1406
-
1407
- /**
1408
- * This is a wrapper around cache.match().
1409
- *
1410
- * @param {string} cacheName Name of the cache to match against.
1411
- * @param {Request} request The Request that will be used to look up cache
1412
- * entries.
1413
- * @param {Object} matchOptions Options passed to cache.match().
1414
- * @param {Array<Object>} [plugins] Array of plugins.
1415
- * @return {Response} A cached response if available.
1416
- *
1417
- * @private
1418
- * @memberof module:workbox-core
1419
- */
1420
- const matchWrapper = (() => {
1421
- var _ref2 = babelHelpers.asyncToGenerator(function* (cacheName, request, matchOptions, plugins = []) {
1422
- const cache = yield caches.open(cacheName);
1423
- let cachedResponse = yield cache.match(request, matchOptions);
1424
- {
1425
- if (cachedResponse) {
1426
- defaultExport.debug(`Found a cached response in '${cacheName}'.`);
1427
- } else {
1428
- defaultExport.debug(`No cached response found in '${cacheName}'.`);
1429
- }
1430
- }
1431
- for (let plugin of plugins) {
1432
- if (pluginEvents.CACHED_RESPONSE_WILL_BE_USED in plugin) {
1433
- cachedResponse = yield plugin[pluginEvents.CACHED_RESPONSE_WILL_BE_USED].call(plugin, {
1434
- cacheName,
1435
- request,
1436
- matchOptions,
1437
- cachedResponse
1438
- });
1439
- {
1440
- if (cachedResponse) {
1441
- finalAssertExports.isInstance(cachedResponse, Response, {
1442
- moduleName: 'Plugin',
1443
- funcName: pluginEvents.CACHED_RESPONSE_WILL_BE_USED,
1444
- isReturnValueProblem: true
1445
- });
1446
- }
1447
- }
1448
- }
1449
- }
1450
- return cachedResponse;
1451
- });
1452
-
1453
- return function matchWrapper(_x4, _x5, _x6) {
1454
- return _ref2.apply(this, arguments);
1455
- };
1456
- })();
1457
-
1458
- /**
1459
- * This method will call cacheWillUpdate on the available plugins (or use
1460
- * response.ok) to determine if the Response is safe and valid to cache.
1461
- *
1462
- * @param {Request} request
1463
- * @param {Response} response
1464
- * @param {Array<Object>} plugins
1465
- * @return {Promise<Response>}
1466
- *
1467
- * @private
1468
- * @memberof module:workbox-core
1469
- */
1470
- const _isResponseSafeToCache = (() => {
1471
- var _ref3 = babelHelpers.asyncToGenerator(function* (request, response, plugins) {
1472
- let responseToCache = response;
1473
- let pluginsUsed = false;
1474
- for (let plugin of plugins) {
1475
- if (pluginEvents.CACHE_WILL_UPDATE in plugin) {
1476
- pluginsUsed = true;
1477
- responseToCache = yield plugin[pluginEvents.CACHE_WILL_UPDATE].call(plugin, {
1478
- request,
1479
- response: responseToCache
1480
- });
1481
-
1482
- {
1483
- if (responseToCache) {
1484
- finalAssertExports.isInstance(responseToCache, Response, {
1485
- moduleName: 'Plugin',
1486
- funcName: pluginEvents.CACHE_WILL_UPDATE,
1487
- isReturnValueProblem: true
1488
- });
1489
- }
1490
- }
1491
-
1492
- if (!responseToCache) {
1493
- break;
1494
- }
1495
- }
1496
- }
1497
-
1498
- if (!pluginsUsed) {
1499
- {
1500
- if (!responseToCache.ok) {
1501
- if (responseToCache.status === 0) {
1502
- defaultExport.warn(`The response for '${request.url}' is an opaque ` + `response. The caching strategy that you're using will not ` + `cache opaque responses by default.`);
1503
- } else {
1504
- defaultExport.debug(`The response for '${request.url}' returned ` + `a status code of '${response.status}' and won't be cached as a ` + `result.`);
1505
- }
1506
- }
1507
- }
1508
- responseToCache = responseToCache.ok ? responseToCache : null;
1509
- }
1510
-
1511
- return responseToCache ? responseToCache : null;
1512
- });
1513
-
1514
- return function _isResponseSafeToCache(_x7, _x8, _x9) {
1515
- return _ref3.apply(this, arguments);
1516
- };
1517
- })();
1518
-
1519
- const cacheWrapper = {
1520
- put: putWrapper,
1521
- match: matchWrapper
1522
- };
1523
-
1524
- /*
1525
- Copyright 2017 Google Inc.
1526
-
1527
- Licensed under the Apache License, Version 2.0 (the "License");
1528
- you may not use this file except in compliance with the License.
1529
- You may obtain a copy of the License at
1530
-
1531
- https://www.apache.org/licenses/LICENSE-2.0
1532
-
1533
- Unless required by applicable law or agreed to in writing, software
1534
- distributed under the License is distributed on an "AS IS" BASIS,
1535
- WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
1536
- See the License for the specific language governing permissions and
1537
- limitations under the License.
1538
- */
1539
-
1540
- /**
1541
- * Wrapper around the fetch API.
1542
- *
1543
- * Will call requestWillFetch on available plugins.
1544
- *
1545
- * @param {Request|string} request
1546
- * @param {Object} fetchOptions
1547
- * @param {Array<Object>} [plugins]
1548
- * @return {Promise<Response>}
1549
- *
1550
- * @private
1551
- * @memberof module:workbox-core
1552
- */
1553
- const wrappedFetch = (() => {
1554
- var _ref = babelHelpers.asyncToGenerator(function* (request, fetchOptions, plugins = []) {
1555
- if (typeof request === 'string') {
1556
- request = new Request(request);
1557
- }
1558
-
1559
- {
1560
- finalAssertExports.isInstance(request, Request, {
1561
- paramName: request,
1562
- expectedClass: 'Request',
1563
- moduleName: 'workbox-core',
1564
- className: 'fetchWrapper',
1565
- funcName: 'wrappedFetch'
1566
- });
1567
- }
1568
-
1569
- const failedFetchPlugins = pluginUtils.filter(plugins, pluginEvents.FETCH_DID_FAIL);
1570
-
1571
- // If there is a fetchDidFail plugin, we need to save a clone of the
1572
- // original request before it's either modified by a requestWillFetch
1573
- // plugin or before the original request's body is consumed via fetch().
1574
- const originalRequest = failedFetchPlugins.length > 0 ? request.clone() : null;
1575
-
1576
- try {
1577
- for (let plugin of plugins) {
1578
- if (pluginEvents.REQUEST_WILL_FETCH in plugin) {
1579
- request = yield plugin[pluginEvents.REQUEST_WILL_FETCH].call(plugin, {
1580
- request: request.clone()
1581
- });
1582
-
1583
- {
1584
- if (request) {
1585
- finalAssertExports.isInstance(request, Request, {
1586
- moduleName: 'Plugin',
1587
- funcName: pluginEvents.CACHED_RESPONSE_WILL_BE_USED,
1588
- isReturnValueProblem: true
1589
- });
1590
- }
1591
- }
1592
- }
1593
- }
1594
- } catch (err) {
1595
- throw new WorkboxError('plugin-error-request-will-fetch', {
1596
- thrownError: err
1597
- });
1598
- }
1599
-
1600
- // The request can be altered by plugins with `requestWillFetch` making
1601
- // the original request (Most likely from a `fetch` event) to be different
1602
- // to the Request we make. Pass both to `fetchDidFail` to aid debugging.
1603
- const pluginFilteredRequest = request.clone();
1604
-
1605
- try {
1606
- const response = yield fetch(request, fetchOptions);
1607
- {
1608
- defaultExport.debug(`Network request for ` + `'${getFriendlyURL(request.url)}' returned a response with ` + `status '${response.status}'.`);
1609
- }
1610
- return response;
1611
- } catch (error) {
1612
- {
1613
- defaultExport.error(`Network request for ` + `'${getFriendlyURL(request.url)}' threw an error.`, error);
1614
- }
1615
-
1616
- for (let plugin of failedFetchPlugins) {
1617
- yield plugin[pluginEvents.FETCH_DID_FAIL].call(plugin, {
1618
- error,
1619
- originalRequest: originalRequest.clone(),
1620
- request: pluginFilteredRequest.clone()
1621
- });
1622
- }
1623
-
1624
- throw error;
1625
- }
1626
- });
1627
-
1628
- return function wrappedFetch(_x, _x2) {
1629
- return _ref.apply(this, arguments);
1630
- };
1631
- })();
1632
-
1633
- const fetchWrapper = {
1634
- fetch: wrappedFetch
1635
- };
1636
-
1637
- /*
1638
- Copyright 2017 Google Inc.
1639
-
1640
- Licensed under the Apache License, Version 2.0 (the "License");
1641
- you may not use this file except in compliance with the License.
1642
- You may obtain a copy of the License at
1643
-
1644
- https://www.apache.org/licenses/LICENSE-2.0
1645
-
1646
- Unless required by applicable law or agreed to in writing, software
1647
- distributed under the License is distributed on an "AS IS" BASIS,
1648
- WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
1649
- See the License for the specific language governing permissions and
1650
- limitations under the License.
1651
- */
1652
-
1653
- var _private = /*#__PURE__*/Object.freeze({
1654
- DBWrapper: DBWrapper,
1655
- WorkboxError: WorkboxError,
1656
- assert: finalAssertExports,
1657
- cacheNames: cacheNames,
1658
- cacheWrapper: cacheWrapper,
1659
- fetchWrapper: fetchWrapper,
1660
- getFriendlyURL: getFriendlyURL,
1661
- logger: defaultExport,
1662
- registerQuotaErrorCallback: registerQuotaErrorCallback
1663
- });
1664
-
1665
- /*
1666
- Copyright 2017 Google Inc.
1667
-
1668
- Licensed under the Apache License, Version 2.0 (the "License");
1669
- you may not use this file except in compliance with the License.
1670
- You may obtain a copy of the License at
1671
-
1672
- https://www.apache.org/licenses/LICENSE-2.0
1673
-
1674
- Unless required by applicable law or agreed to in writing, software
1675
- distributed under the License is distributed on an "AS IS" BASIS,
1676
- WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
1677
- See the License for the specific language governing permissions and
1678
- limitations under the License.
1679
- */
1680
-
1681
- const finalExports = Object.assign(defaultExport$1, {
1682
- LOG_LEVELS,
1683
- _private
1684
- });
1685
-
1686
- return finalExports;
1687
-
1688
- }());
1689
-
1690
- //# sourceMappingURL=workbox-core.dev.js.map