jekyll-pwa-plugin 2.1.1 → 2.2.1

Sign up to get free protection for your applications and to get access to all the features.
Files changed (69) hide show
  1. checksums.yaml +4 -4
  2. data/lib/jekyll-pwa-plugin.rb +1 -1
  3. data/lib/vendor/{workbox-v3.4.1 → workbox-v3.6.2}/workbox-background-sync.dev.js +1 -1
  4. data/lib/vendor/{workbox-v3.4.1 → workbox-v3.6.2}/workbox-background-sync.dev.js.map +1 -1
  5. data/lib/vendor/{workbox-v3.4.1 → workbox-v3.6.2}/workbox-background-sync.prod.js +1 -1
  6. data/lib/vendor/{workbox-v3.4.1 → workbox-v3.6.2}/workbox-background-sync.prod.js.map +1 -1
  7. data/lib/vendor/{workbox-v3.4.1 → workbox-v3.6.2}/workbox-broadcast-cache-update.dev.js +5 -5
  8. data/lib/vendor/{workbox-v3.4.1 → workbox-v3.6.2}/workbox-broadcast-cache-update.dev.js.map +1 -1
  9. data/lib/vendor/{workbox-v3.4.1 → workbox-v3.6.2}/workbox-broadcast-cache-update.prod.js +1 -1
  10. data/lib/vendor/{workbox-v3.4.1 → workbox-v3.6.2}/workbox-broadcast-cache-update.prod.js.map +1 -1
  11. data/lib/vendor/{workbox-v3.4.1 → workbox-v3.6.2}/workbox-cache-expiration.dev.js +12 -12
  12. data/lib/vendor/{workbox-v3.4.1 → workbox-v3.6.2}/workbox-cache-expiration.dev.js.map +1 -1
  13. data/lib/vendor/{workbox-v3.4.1 → workbox-v3.6.2}/workbox-cache-expiration.prod.js +1 -1
  14. data/lib/vendor/{workbox-v3.4.1 → workbox-v3.6.2}/workbox-cache-expiration.prod.js.map +1 -1
  15. data/lib/vendor/{workbox-v3.4.1 → workbox-v3.6.2}/workbox-cacheable-response.dev.js +1 -1
  16. data/lib/vendor/{workbox-v3.4.1 → workbox-v3.6.2}/workbox-cacheable-response.dev.js.map +1 -1
  17. data/lib/vendor/{workbox-v3.4.1 → workbox-v3.6.2}/workbox-cacheable-response.prod.js +1 -1
  18. data/lib/vendor/{workbox-v3.4.1 → workbox-v3.6.2}/workbox-cacheable-response.prod.js.map +1 -1
  19. data/lib/vendor/{workbox-v3.4.1 → workbox-v3.6.2}/workbox-core.dev.js +542 -515
  20. data/lib/vendor/workbox-v3.6.2/workbox-core.dev.js.map +1 -0
  21. data/lib/vendor/workbox-v3.6.2/workbox-core.prod.js +3 -0
  22. data/lib/vendor/workbox-v3.6.2/workbox-core.prod.js.map +1 -0
  23. data/lib/vendor/{workbox-v3.4.1 → workbox-v3.6.2}/workbox-google-analytics.dev.js +1 -1
  24. data/lib/vendor/{workbox-v3.4.1 → workbox-v3.6.2}/workbox-google-analytics.dev.js.map +1 -1
  25. data/lib/vendor/{workbox-v3.4.1 → workbox-v3.6.2}/workbox-google-analytics.prod.js +1 -1
  26. data/lib/vendor/{workbox-v3.4.1 → workbox-v3.6.2}/workbox-google-analytics.prod.js.map +1 -1
  27. data/lib/vendor/{workbox-v3.4.1 → workbox-v3.6.2}/workbox-navigation-preload.dev.js +39 -1
  28. data/lib/vendor/workbox-v3.6.2/workbox-navigation-preload.dev.js.map +1 -0
  29. data/lib/vendor/workbox-v3.6.2/workbox-navigation-preload.prod.js +3 -0
  30. data/lib/vendor/workbox-v3.6.2/workbox-navigation-preload.prod.js.map +1 -0
  31. data/lib/vendor/{workbox-v3.4.1 → workbox-v3.6.2}/workbox-precaching.dev.js +43 -23
  32. data/lib/vendor/workbox-v3.6.2/workbox-precaching.dev.js.map +1 -0
  33. data/lib/vendor/workbox-v3.6.2/workbox-precaching.prod.js +3 -0
  34. data/lib/vendor/workbox-v3.6.2/workbox-precaching.prod.js.map +1 -0
  35. data/lib/vendor/{workbox-v3.4.1 → workbox-v3.6.2}/workbox-range-requests.dev.js +1 -1
  36. data/lib/vendor/{workbox-v3.4.1 → workbox-v3.6.2}/workbox-range-requests.dev.js.map +1 -1
  37. data/lib/vendor/{workbox-v3.4.1 → workbox-v3.6.2}/workbox-range-requests.prod.js +1 -1
  38. data/lib/vendor/{workbox-v3.4.1 → workbox-v3.6.2}/workbox-range-requests.prod.js.map +1 -1
  39. data/lib/vendor/{workbox-v3.4.1 → workbox-v3.6.2}/workbox-routing.dev.js +5 -5
  40. data/lib/vendor/workbox-v3.6.2/workbox-routing.dev.js.map +1 -0
  41. data/lib/vendor/{workbox-v3.4.1 → workbox-v3.6.2}/workbox-routing.prod.js +1 -1
  42. data/lib/vendor/{workbox-v3.4.1 → workbox-v3.6.2}/workbox-routing.prod.js.map +1 -1
  43. data/lib/vendor/{workbox-v3.4.1 → workbox-v3.6.2}/workbox-strategies.dev.js +150 -77
  44. data/lib/vendor/workbox-v3.6.2/workbox-strategies.dev.js.map +1 -0
  45. data/lib/vendor/workbox-v3.6.2/workbox-strategies.prod.js +3 -0
  46. data/lib/vendor/workbox-v3.6.2/workbox-strategies.prod.js.map +1 -0
  47. data/lib/vendor/{workbox-v3.4.1 → workbox-v3.6.2}/workbox-streams.dev.js +23 -33
  48. data/lib/vendor/workbox-v3.6.2/workbox-streams.dev.js.map +1 -0
  49. data/lib/vendor/workbox-v3.6.2/workbox-streams.prod.js +3 -0
  50. data/lib/vendor/workbox-v3.6.2/workbox-streams.prod.js.map +1 -0
  51. data/lib/vendor/{workbox-v3.4.1 → workbox-v3.6.2}/workbox-sw.js +1 -1
  52. data/lib/vendor/{workbox-v3.4.1 → workbox-v3.6.2}/workbox-sw.js.map +1 -1
  53. metadata +54 -53
  54. data/lib/vendor/workbox-v3.4.1/workbox-core.dev.js.map +0 -1
  55. data/lib/vendor/workbox-v3.4.1/workbox-core.prod.js +0 -3
  56. data/lib/vendor/workbox-v3.4.1/workbox-core.prod.js.map +0 -1
  57. data/lib/vendor/workbox-v3.4.1/workbox-navigation-preload.dev.js.map +0 -1
  58. data/lib/vendor/workbox-v3.4.1/workbox-navigation-preload.prod.js +0 -3
  59. data/lib/vendor/workbox-v3.4.1/workbox-navigation-preload.prod.js.map +0 -1
  60. data/lib/vendor/workbox-v3.4.1/workbox-precaching.dev.js.map +0 -1
  61. data/lib/vendor/workbox-v3.4.1/workbox-precaching.prod.js +0 -3
  62. data/lib/vendor/workbox-v3.4.1/workbox-precaching.prod.js.map +0 -1
  63. data/lib/vendor/workbox-v3.4.1/workbox-routing.dev.js.map +0 -1
  64. data/lib/vendor/workbox-v3.4.1/workbox-strategies.dev.js.map +0 -1
  65. data/lib/vendor/workbox-v3.4.1/workbox-strategies.prod.js +0 -3
  66. data/lib/vendor/workbox-v3.4.1/workbox-strategies.prod.js.map +0 -1
  67. data/lib/vendor/workbox-v3.4.1/workbox-streams.dev.js.map +0 -1
  68. data/lib/vendor/workbox-v3.4.1/workbox-streams.prod.js +0 -3
  69. data/lib/vendor/workbox-v3.4.1/workbox-streams.prod.js.map +0 -1
checksums.yaml CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA1:
3
- metadata.gz: f3da8df7d69937fa573fcd18a06d24e86759da99
4
- data.tar.gz: df9566c4c00b475c8e6283c28b9e12eb385889e4
3
+ metadata.gz: c5407c4c53b372eb10d93be0efcaa326f4eb0d79
4
+ data.tar.gz: 16aabca2ebb56fdbe613743a7b21d9323601f103
5
5
  SHA512:
6
- metadata.gz: 5607ae8240c24036052798df61e933e9f0f716148d9a6926b9d3913011a3192c903173aea7da1ff7bd9b741bbcfb154616ef0a97c0107334447a145cadc6e06b
7
- data.tar.gz: 05f5d0ffc3953b7352054dbb07546ba75bd044cdd45d0a3b6ff4206c0cae6decf0bc4d0cf0b14ea27d08a57711f3f5bbdf3a3a4ef2ccf96cb5dbd6e9088134b9
6
+ metadata.gz: ca836c9a306622233c22bc8e33e4eb9a1d0b0aa973e456aa42656c090eb8d25567a19303feafea659d53d46b3179ea772617b79eba8f9a2086b6b3cec5bd932e
7
+ data.tar.gz: 74a3b9c2d80f4ec9e9365c775dc8a93b08959499e2afdff35b4c30d2cde6a01c4f516029a7679d04ff50d72499bb2194a4c1d3fb2074d97605758453c19540a6
@@ -1,5 +1,5 @@
1
1
  class SWHelper
2
- WORKBOX_VERSION = 'v3.4.1'
2
+ WORKBOX_VERSION = 'v3.6.2'
3
3
  def initialize(site, config)
4
4
  @site = site
5
5
  @config = config
@@ -3,7 +3,7 @@ this.workbox.backgroundSync = (function (DBWrapper_mjs,WorkboxError_mjs,logger_m
3
3
  'use strict';
4
4
 
5
5
  try {
6
- self.workbox.v['workbox:background-sync:3.4.1'] = 1;
6
+ self.workbox.v['workbox:background-sync:3.6.2'] = 1;
7
7
  } catch (e) {} // eslint-disable-line
8
8
 
9
9
  /*
@@ -1 +1 @@
1
- {"version":3,"names":[],"mappings":"","sources":["packages/workbox-background-sync/browser.mjs"],"sourcesContent":["this.workbox = this.workbox || {};\nthis.workbox.backgroundSync = (function (DBWrapper_mjs,WorkboxError_mjs,logger_mjs,assert_mjs,getFriendlyURL_mjs) {\n 'use strict';\n\n try {\n self.workbox.v['workbox:background-sync:3.4.1'] = 1;\n } catch (e) {} // eslint-disable-line\n\n /*\n Copyright 2017 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\n http://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 serializableProperties = ['method', 'referrer', 'referrerPolicy', 'mode', 'credentials', 'cache', 'redirect', 'integrity', 'keepalive'];\n\n /**\n * A class to make it easier to serialize and de-serialize requests so they\n * can be stored in IndexedDB.\n *\n * @private\n */\n class StorableRequest {\n /**\n * Converts a Request object to a plain object that can be structured\n * cloned or JSON-stringified.\n *\n * @param {Request} request\n * @return {Promise<StorableRequest>}\n *\n * @private\n */\n static fromRequest(request) {\n return babelHelpers.asyncToGenerator(function* () {\n const requestInit = { headers: {} };\n\n // Set the body if present.\n if (request.method !== 'GET') {\n // Use blob to support non-text request bodies,\n // and clone first in case the caller still needs the request.\n requestInit.body = yield request.clone().blob();\n }\n\n // Convert the headers from an iterable to an object.\n for (const [key, value] of request.headers.entries()) {\n requestInit.headers[key] = value;\n }\n\n // Add all other serializable request properties\n for (const prop of serializableProperties) {\n if (request[prop] !== undefined) {\n requestInit[prop] = request[prop];\n }\n }\n\n return new StorableRequest({ url: request.url, requestInit });\n })();\n }\n\n /**\n * Accepts a URL and RequestInit dictionary that can be used to create a\n * new Request object. A timestamp is also generated so consumers can\n * reference when the object was created.\n *\n * @param {Object} param1\n * @param {string} param1.url\n * @param {Object} param1.requestInit\n * See: https://fetch.spec.whatwg.org/#requestinit\n * @param {number} param1.timestamp The time the request was created,\n * defaulting to the current time if not specified.\n *\n * @private\n */\n constructor({ url, requestInit, timestamp = Date.now() }) {\n this.url = url;\n this.requestInit = requestInit;\n\n // \"Private\"\n this._timestamp = timestamp;\n }\n\n /**\n * Gets the private _timestamp property.\n *\n * @return {number}\n *\n * @private\n */\n get timestamp() {\n return this._timestamp;\n }\n\n /**\n * Coverts this instance to a plain Object.\n *\n * @return {Object}\n *\n * @private\n */\n toObject() {\n return {\n url: this.url,\n timestamp: this.timestamp,\n requestInit: this.requestInit\n };\n }\n\n /**\n * Converts this instance to a Request.\n *\n * @return {Request}\n *\n * @private\n */\n toRequest() {\n return new Request(this.url, this.requestInit);\n }\n\n /**\n * Creates and returns a deep clone of the instance.\n *\n * @return {StorableRequest}\n *\n * @private\n */\n clone() {\n const requestInit = Object.assign({}, this.requestInit);\n requestInit.headers = Object.assign({}, this.requestInit.headers);\n if (this.requestInit.body) {\n requestInit.body = this.requestInit.body.slice();\n }\n\n return new StorableRequest({\n url: this.url,\n timestamp: this.timestamp,\n requestInit\n });\n }\n }\n\n /*\n Copyright 2017 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\n http://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 DB_NAME = 'workbox-background-sync';\n const OBJECT_STORE_NAME = 'requests';\n const INDEXED_PROP = 'queueName';\n const TAG_PREFIX = 'workbox-background-sync';\n const MAX_RETENTION_TIME = 60 * 24 * 7; // 7 days in minutes\n\n /*\n Copyright 2017 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\n http://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 * A class to manage storing requests from a Queue in IndexedbDB,\n * indexed by their queue name for easier access.\n *\n * @private\n */\n class QueueStore {\n /**\n * Associates this instance with a Queue instance, so entries added can be\n * identified by their queue name.\n *\n * @param {Queue} queue\n *\n * @private\n */\n constructor(queue) {\n this._queue = queue;\n this._db = new DBWrapper_mjs.DBWrapper(DB_NAME, 1, {\n onupgradeneeded: evt => evt.target.result.createObjectStore(OBJECT_STORE_NAME, { autoIncrement: true }).createIndex(INDEXED_PROP, INDEXED_PROP, { unique: false })\n });\n }\n\n /**\n * Takes a StorableRequest instance, converts it to an object and adds it\n * as an entry in the object store.\n *\n * @param {StorableRequest} storableRequest\n *\n * @private\n */\n addEntry(storableRequest) {\n var _this = this;\n\n return babelHelpers.asyncToGenerator(function* () {\n yield _this._db.add(OBJECT_STORE_NAME, {\n queueName: _this._queue.name,\n storableRequest: storableRequest.toObject()\n });\n })();\n }\n\n /**\n * Gets the oldest entry in the object store, removes it, and returns the\n * value as a StorableRequest instance. If no entry exists, it returns\n * undefined.\n *\n * @return {StorableRequest|undefined}\n *\n * @private\n */\n getAndRemoveOldestEntry() {\n var _this2 = this;\n\n return babelHelpers.asyncToGenerator(function* () {\n const [entry] = yield _this2._db.getAllMatching(OBJECT_STORE_NAME, {\n index: INDEXED_PROP,\n query: IDBKeyRange.only(_this2._queue.name),\n count: 1,\n includeKeys: true\n });\n\n if (entry) {\n yield _this2._db.delete(OBJECT_STORE_NAME, entry.primaryKey);\n return new StorableRequest(entry.value.storableRequest);\n }\n })();\n }\n }\n\n /*\n Copyright 2017 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\n http://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 queueNames = new Set();\n\n /**\n * A class to manage storing failed requests in IndexedDB and retrying them\n * later. All parts of the storing and replaying process are observable via\n * callbacks.\n *\n * @memberof workbox.backgroundSync\n */\n class Queue {\n /**\n * Creates an instance of Queue with the given options\n *\n * @param {string} name The unique name for this queue. This name must be\n * unique as it's used to register sync events and store requests\n * in IndexedDB specific to this instance. An error will be thrown if\n * a duplicate name is detected.\n * @param {Object} [options]\n * @param {Object} [options.callbacks] Callbacks to observe the lifecycle of\n * queued requests. Use these to respond to or modify the requests\n * during the replay process.\n * @param {function(StorableRequest):undefined}\n * [options.callbacks.requestWillEnqueue]\n * Invoked immediately before the request is stored to IndexedDB. Use\n * this callback to modify request data at store time.\n * @param {function(StorableRequest):undefined}\n * [options.callbacks.requestWillReplay]\n * Invoked immediately before the request is re-fetched. Use this\n * callback to modify request data at fetch time.\n * @param {function(Array<StorableRequest>):undefined}\n * [options.callbacks.queueDidReplay]\n * Invoked after all requests in the queue have successfully replayed.\n * @param {number} [options.maxRetentionTime = 7 days] The amount of time (in\n * minutes) a request may be retried. After this amount of time has\n * passed, the request will be deleted from the queue.\n */\n constructor(name, {\n callbacks = {},\n maxRetentionTime = MAX_RETENTION_TIME\n } = {}) {\n // Ensure the store name is not already being used\n if (queueNames.has(name)) {\n throw new WorkboxError_mjs.WorkboxError('duplicate-queue-name', { name });\n } else {\n queueNames.add(name);\n }\n\n this._name = name;\n this._callbacks = callbacks;\n this._maxRetentionTime = maxRetentionTime;\n this._queueStore = new QueueStore(this);\n\n this._addSyncListener();\n }\n\n /**\n * @return {string}\n */\n get name() {\n return this._name;\n }\n\n /**\n * Stores the passed request into IndexedDB. The database used is\n * `workbox-background-sync` and the object store name is the same as\n * the name this instance was created with (to guarantee it's unique).\n *\n * @param {Request} request The request object to store.\n */\n addRequest(request) {\n var _this = this;\n\n return babelHelpers.asyncToGenerator(function* () {\n {\n assert_mjs.assert.isInstance(request, Request, {\n moduleName: 'workbox-background-sync',\n className: 'Queue',\n funcName: 'addRequest',\n paramName: 'request'\n });\n }\n\n const storableRequest = yield StorableRequest.fromRequest(request.clone());\n yield _this._runCallback('requestWillEnqueue', storableRequest);\n yield _this._queueStore.addEntry(storableRequest);\n yield _this._registerSync();\n {\n logger_mjs.logger.log(`Request for '${getFriendlyURL_mjs.getFriendlyURL(storableRequest.url)}' has been\n added to background sync queue '${_this._name}'.`);\n }\n })();\n }\n\n /**\n * Retrieves all stored requests in IndexedDB and retries them. If the\n * queue contained requests that were successfully replayed, the\n * `queueDidReplay` callback is invoked (which implies the queue is\n * now empty). If any of the requests fail, a new sync registration is\n * created to retry again later.\n */\n replayRequests() {\n var _this2 = this;\n\n return babelHelpers.asyncToGenerator(function* () {\n const now = Date.now();\n const replayedRequests = [];\n const failedRequests = [];\n\n let storableRequest;\n while (storableRequest = yield _this2._queueStore.getAndRemoveOldestEntry()) {\n // Make a copy so the unmodified request can be stored\n // in the event of a replay failure.\n const storableRequestClone = storableRequest.clone();\n\n // Ignore requests older than maxRetentionTime.\n const maxRetentionTimeInMs = _this2._maxRetentionTime * 60 * 1000;\n if (now - storableRequest.timestamp > maxRetentionTimeInMs) {\n continue;\n }\n\n yield _this2._runCallback('requestWillReplay', storableRequest);\n\n const replay = { request: storableRequest.toRequest() };\n\n try {\n // Clone the request before fetching so callbacks get an unused one.\n replay.response = yield fetch(replay.request.clone());\n {\n logger_mjs.logger.log(`Request for '${getFriendlyURL_mjs.getFriendlyURL(storableRequest.url)}'\n has been replayed`);\n }\n } catch (err) {\n {\n logger_mjs.logger.log(`Request for '${getFriendlyURL_mjs.getFriendlyURL(storableRequest.url)}'\n failed to replay`);\n }\n replay.error = err;\n failedRequests.push(storableRequestClone);\n }\n\n replayedRequests.push(replay);\n }\n\n yield _this2._runCallback('queueDidReplay', replayedRequests);\n\n // If any requests failed, put the failed requests back in the queue\n // and rethrow the failed requests count.\n if (failedRequests.length) {\n yield Promise.all(failedRequests.map(function (storableRequest) {\n return _this2._queueStore.addEntry(storableRequest);\n }));\n\n throw new WorkboxError_mjs.WorkboxError('queue-replay-failed', { name: _this2._name, count: failedRequests.length });\n }\n })();\n }\n\n /**\n * Runs the passed callback if it exists.\n *\n * @private\n * @param {string} name The name of the callback on this._callbacks.\n * @param {...*} args The arguments to invoke the callback with.\n */\n _runCallback(name, ...args) {\n var _this3 = this;\n\n return babelHelpers.asyncToGenerator(function* () {\n if (typeof _this3._callbacks[name] === 'function') {\n yield _this3._callbacks[name].apply(null, args);\n }\n })();\n }\n\n /**\n * In sync-supporting browsers, this adds a listener for the sync event.\n * In non-sync-supporting browsers, this will retry the queue on service\n * worker startup.\n *\n * @private\n */\n _addSyncListener() {\n if ('sync' in registration) {\n self.addEventListener('sync', event => {\n if (event.tag === `${TAG_PREFIX}:${this._name}`) {\n {\n logger_mjs.logger.log(`Background sync for tag '${event.tag}'\n has been received, starting replay now`);\n }\n event.waitUntil(this.replayRequests());\n }\n });\n } else {\n {\n logger_mjs.logger.log(`Background sync replaying without background sync event`);\n }\n // If the browser doesn't support background sync, retry\n // every time the service worker starts up as a fallback.\n this.replayRequests();\n }\n }\n\n /**\n * Registers a sync event with a tag unique to this instance.\n *\n * @private\n */\n _registerSync() {\n var _this4 = this;\n\n return babelHelpers.asyncToGenerator(function* () {\n if ('sync' in registration) {\n try {\n yield registration.sync.register(`${TAG_PREFIX}:${_this4._name}`);\n } catch (err) {\n // This means the registration failed for some reason, possibly due to\n // the user disabling it.\n {\n logger_mjs.logger.warn(`Unable to register sync event for '${_this4._name}'.`, err);\n }\n }\n }\n })();\n }\n\n /**\n * Returns the set of queue names. This is primarily used to reset the list\n * of queue names in tests.\n *\n * @return {Set}\n *\n * @private\n */\n static get _queueNames() {\n return queueNames;\n }\n }\n\n /*\n Copyright 2017 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\n http://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 * A class implementing the `fetchDidFail` lifecycle callback. This makes it\n * easier to add failed requests to a background sync Queue.\n *\n * @memberof workbox.backgroundSync\n */\n class Plugin {\n /**\n * @param {...*} queueArgs Args to forward to the composed Queue instance.\n * See the [Queue]{@link workbox.backgroundSync.Queue} documentation for\n * parameter details.\n */\n constructor(...queueArgs) {\n this._queue = new Queue(...queueArgs);\n this.fetchDidFail = this.fetchDidFail.bind(this);\n }\n\n /**\n * @param {Object} options\n * @param {Request} options.request\n * @private\n */\n fetchDidFail({ request }) {\n var _this = this;\n\n return babelHelpers.asyncToGenerator(function* () {\n yield _this._queue.addRequest(request);\n })();\n }\n }\n\n /*\n Copyright 2017 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\n http://www.apache.org/licenses/LICENSE-2.0\n\n Unless required by applicable law or agreed to in writing, software\n distributed under the License is distributed on an \"AS IS\" BASIS,\n WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n See the License for the specific language governing permissions and\n limitations under the License.\n */\n\n var publicAPI = /*#__PURE__*/Object.freeze({\n Queue: Queue,\n Plugin: Plugin\n });\n\n /*\n Copyright 2017 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\n http://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 return publicAPI;\n\n}(workbox.core._private,workbox.core._private,workbox.core._private,workbox.core._private,workbox.core._private));\n"],"file":"workbox-background-sync.dev.js"}
1
+ {"version":3,"names":[],"mappings":"","sources":["packages/workbox-background-sync/browser.mjs"],"sourcesContent":["this.workbox = this.workbox || {};\nthis.workbox.backgroundSync = (function (DBWrapper_mjs,WorkboxError_mjs,logger_mjs,assert_mjs,getFriendlyURL_mjs) {\n 'use strict';\n\n try {\n self.workbox.v['workbox:background-sync:3.6.2'] = 1;\n } catch (e) {} // eslint-disable-line\n\n /*\n Copyright 2017 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\n http://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 serializableProperties = ['method', 'referrer', 'referrerPolicy', 'mode', 'credentials', 'cache', 'redirect', 'integrity', 'keepalive'];\n\n /**\n * A class to make it easier to serialize and de-serialize requests so they\n * can be stored in IndexedDB.\n *\n * @private\n */\n class StorableRequest {\n /**\n * Converts a Request object to a plain object that can be structured\n * cloned or JSON-stringified.\n *\n * @param {Request} request\n * @return {Promise<StorableRequest>}\n *\n * @private\n */\n static fromRequest(request) {\n return babelHelpers.asyncToGenerator(function* () {\n const requestInit = { headers: {} };\n\n // Set the body if present.\n if (request.method !== 'GET') {\n // Use blob to support non-text request bodies,\n // and clone first in case the caller still needs the request.\n requestInit.body = yield request.clone().blob();\n }\n\n // Convert the headers from an iterable to an object.\n for (const [key, value] of request.headers.entries()) {\n requestInit.headers[key] = value;\n }\n\n // Add all other serializable request properties\n for (const prop of serializableProperties) {\n if (request[prop] !== undefined) {\n requestInit[prop] = request[prop];\n }\n }\n\n return new StorableRequest({ url: request.url, requestInit });\n })();\n }\n\n /**\n * Accepts a URL and RequestInit dictionary that can be used to create a\n * new Request object. A timestamp is also generated so consumers can\n * reference when the object was created.\n *\n * @param {Object} param1\n * @param {string} param1.url\n * @param {Object} param1.requestInit\n * See: https://fetch.spec.whatwg.org/#requestinit\n * @param {number} param1.timestamp The time the request was created,\n * defaulting to the current time if not specified.\n *\n * @private\n */\n constructor({ url, requestInit, timestamp = Date.now() }) {\n this.url = url;\n this.requestInit = requestInit;\n\n // \"Private\"\n this._timestamp = timestamp;\n }\n\n /**\n * Gets the private _timestamp property.\n *\n * @return {number}\n *\n * @private\n */\n get timestamp() {\n return this._timestamp;\n }\n\n /**\n * Coverts this instance to a plain Object.\n *\n * @return {Object}\n *\n * @private\n */\n toObject() {\n return {\n url: this.url,\n timestamp: this.timestamp,\n requestInit: this.requestInit\n };\n }\n\n /**\n * Converts this instance to a Request.\n *\n * @return {Request}\n *\n * @private\n */\n toRequest() {\n return new Request(this.url, this.requestInit);\n }\n\n /**\n * Creates and returns a deep clone of the instance.\n *\n * @return {StorableRequest}\n *\n * @private\n */\n clone() {\n const requestInit = Object.assign({}, this.requestInit);\n requestInit.headers = Object.assign({}, this.requestInit.headers);\n if (this.requestInit.body) {\n requestInit.body = this.requestInit.body.slice();\n }\n\n return new StorableRequest({\n url: this.url,\n timestamp: this.timestamp,\n requestInit\n });\n }\n }\n\n /*\n Copyright 2017 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\n http://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 DB_NAME = 'workbox-background-sync';\n const OBJECT_STORE_NAME = 'requests';\n const INDEXED_PROP = 'queueName';\n const TAG_PREFIX = 'workbox-background-sync';\n const MAX_RETENTION_TIME = 60 * 24 * 7; // 7 days in minutes\n\n /*\n Copyright 2017 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\n http://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 * A class to manage storing requests from a Queue in IndexedbDB,\n * indexed by their queue name for easier access.\n *\n * @private\n */\n class QueueStore {\n /**\n * Associates this instance with a Queue instance, so entries added can be\n * identified by their queue name.\n *\n * @param {Queue} queue\n *\n * @private\n */\n constructor(queue) {\n this._queue = queue;\n this._db = new DBWrapper_mjs.DBWrapper(DB_NAME, 1, {\n onupgradeneeded: evt => evt.target.result.createObjectStore(OBJECT_STORE_NAME, { autoIncrement: true }).createIndex(INDEXED_PROP, INDEXED_PROP, { unique: false })\n });\n }\n\n /**\n * Takes a StorableRequest instance, converts it to an object and adds it\n * as an entry in the object store.\n *\n * @param {StorableRequest} storableRequest\n *\n * @private\n */\n addEntry(storableRequest) {\n var _this = this;\n\n return babelHelpers.asyncToGenerator(function* () {\n yield _this._db.add(OBJECT_STORE_NAME, {\n queueName: _this._queue.name,\n storableRequest: storableRequest.toObject()\n });\n })();\n }\n\n /**\n * Gets the oldest entry in the object store, removes it, and returns the\n * value as a StorableRequest instance. If no entry exists, it returns\n * undefined.\n *\n * @return {StorableRequest|undefined}\n *\n * @private\n */\n getAndRemoveOldestEntry() {\n var _this2 = this;\n\n return babelHelpers.asyncToGenerator(function* () {\n const [entry] = yield _this2._db.getAllMatching(OBJECT_STORE_NAME, {\n index: INDEXED_PROP,\n query: IDBKeyRange.only(_this2._queue.name),\n count: 1,\n includeKeys: true\n });\n\n if (entry) {\n yield _this2._db.delete(OBJECT_STORE_NAME, entry.primaryKey);\n return new StorableRequest(entry.value.storableRequest);\n }\n })();\n }\n }\n\n /*\n Copyright 2017 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\n http://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 queueNames = new Set();\n\n /**\n * A class to manage storing failed requests in IndexedDB and retrying them\n * later. All parts of the storing and replaying process are observable via\n * callbacks.\n *\n * @memberof workbox.backgroundSync\n */\n class Queue {\n /**\n * Creates an instance of Queue with the given options\n *\n * @param {string} name The unique name for this queue. This name must be\n * unique as it's used to register sync events and store requests\n * in IndexedDB specific to this instance. An error will be thrown if\n * a duplicate name is detected.\n * @param {Object} [options]\n * @param {Object} [options.callbacks] Callbacks to observe the lifecycle of\n * queued requests. Use these to respond to or modify the requests\n * during the replay process.\n * @param {function(StorableRequest):undefined}\n * [options.callbacks.requestWillEnqueue]\n * Invoked immediately before the request is stored to IndexedDB. Use\n * this callback to modify request data at store time.\n * @param {function(StorableRequest):undefined}\n * [options.callbacks.requestWillReplay]\n * Invoked immediately before the request is re-fetched. Use this\n * callback to modify request data at fetch time.\n * @param {function(Array<StorableRequest>):undefined}\n * [options.callbacks.queueDidReplay]\n * Invoked after all requests in the queue have successfully replayed.\n * @param {number} [options.maxRetentionTime = 7 days] The amount of time (in\n * minutes) a request may be retried. After this amount of time has\n * passed, the request will be deleted from the queue.\n */\n constructor(name, {\n callbacks = {},\n maxRetentionTime = MAX_RETENTION_TIME\n } = {}) {\n // Ensure the store name is not already being used\n if (queueNames.has(name)) {\n throw new WorkboxError_mjs.WorkboxError('duplicate-queue-name', { name });\n } else {\n queueNames.add(name);\n }\n\n this._name = name;\n this._callbacks = callbacks;\n this._maxRetentionTime = maxRetentionTime;\n this._queueStore = new QueueStore(this);\n\n this._addSyncListener();\n }\n\n /**\n * @return {string}\n */\n get name() {\n return this._name;\n }\n\n /**\n * Stores the passed request into IndexedDB. The database used is\n * `workbox-background-sync` and the object store name is the same as\n * the name this instance was created with (to guarantee it's unique).\n *\n * @param {Request} request The request object to store.\n */\n addRequest(request) {\n var _this = this;\n\n return babelHelpers.asyncToGenerator(function* () {\n {\n assert_mjs.assert.isInstance(request, Request, {\n moduleName: 'workbox-background-sync',\n className: 'Queue',\n funcName: 'addRequest',\n paramName: 'request'\n });\n }\n\n const storableRequest = yield StorableRequest.fromRequest(request.clone());\n yield _this._runCallback('requestWillEnqueue', storableRequest);\n yield _this._queueStore.addEntry(storableRequest);\n yield _this._registerSync();\n {\n logger_mjs.logger.log(`Request for '${getFriendlyURL_mjs.getFriendlyURL(storableRequest.url)}' has been\n added to background sync queue '${_this._name}'.`);\n }\n })();\n }\n\n /**\n * Retrieves all stored requests in IndexedDB and retries them. If the\n * queue contained requests that were successfully replayed, the\n * `queueDidReplay` callback is invoked (which implies the queue is\n * now empty). If any of the requests fail, a new sync registration is\n * created to retry again later.\n */\n replayRequests() {\n var _this2 = this;\n\n return babelHelpers.asyncToGenerator(function* () {\n const now = Date.now();\n const replayedRequests = [];\n const failedRequests = [];\n\n let storableRequest;\n while (storableRequest = yield _this2._queueStore.getAndRemoveOldestEntry()) {\n // Make a copy so the unmodified request can be stored\n // in the event of a replay failure.\n const storableRequestClone = storableRequest.clone();\n\n // Ignore requests older than maxRetentionTime.\n const maxRetentionTimeInMs = _this2._maxRetentionTime * 60 * 1000;\n if (now - storableRequest.timestamp > maxRetentionTimeInMs) {\n continue;\n }\n\n yield _this2._runCallback('requestWillReplay', storableRequest);\n\n const replay = { request: storableRequest.toRequest() };\n\n try {\n // Clone the request before fetching so callbacks get an unused one.\n replay.response = yield fetch(replay.request.clone());\n {\n logger_mjs.logger.log(`Request for '${getFriendlyURL_mjs.getFriendlyURL(storableRequest.url)}'\n has been replayed`);\n }\n } catch (err) {\n {\n logger_mjs.logger.log(`Request for '${getFriendlyURL_mjs.getFriendlyURL(storableRequest.url)}'\n failed to replay`);\n }\n replay.error = err;\n failedRequests.push(storableRequestClone);\n }\n\n replayedRequests.push(replay);\n }\n\n yield _this2._runCallback('queueDidReplay', replayedRequests);\n\n // If any requests failed, put the failed requests back in the queue\n // and rethrow the failed requests count.\n if (failedRequests.length) {\n yield Promise.all(failedRequests.map(function (storableRequest) {\n return _this2._queueStore.addEntry(storableRequest);\n }));\n\n throw new WorkboxError_mjs.WorkboxError('queue-replay-failed', { name: _this2._name, count: failedRequests.length });\n }\n })();\n }\n\n /**\n * Runs the passed callback if it exists.\n *\n * @private\n * @param {string} name The name of the callback on this._callbacks.\n * @param {...*} args The arguments to invoke the callback with.\n */\n _runCallback(name, ...args) {\n var _this3 = this;\n\n return babelHelpers.asyncToGenerator(function* () {\n if (typeof _this3._callbacks[name] === 'function') {\n yield _this3._callbacks[name].apply(null, args);\n }\n })();\n }\n\n /**\n * In sync-supporting browsers, this adds a listener for the sync event.\n * In non-sync-supporting browsers, this will retry the queue on service\n * worker startup.\n *\n * @private\n */\n _addSyncListener() {\n if ('sync' in registration) {\n self.addEventListener('sync', event => {\n if (event.tag === `${TAG_PREFIX}:${this._name}`) {\n {\n logger_mjs.logger.log(`Background sync for tag '${event.tag}'\n has been received, starting replay now`);\n }\n event.waitUntil(this.replayRequests());\n }\n });\n } else {\n {\n logger_mjs.logger.log(`Background sync replaying without background sync event`);\n }\n // If the browser doesn't support background sync, retry\n // every time the service worker starts up as a fallback.\n this.replayRequests();\n }\n }\n\n /**\n * Registers a sync event with a tag unique to this instance.\n *\n * @private\n */\n _registerSync() {\n var _this4 = this;\n\n return babelHelpers.asyncToGenerator(function* () {\n if ('sync' in registration) {\n try {\n yield registration.sync.register(`${TAG_PREFIX}:${_this4._name}`);\n } catch (err) {\n // This means the registration failed for some reason, possibly due to\n // the user disabling it.\n {\n logger_mjs.logger.warn(`Unable to register sync event for '${_this4._name}'.`, err);\n }\n }\n }\n })();\n }\n\n /**\n * Returns the set of queue names. This is primarily used to reset the list\n * of queue names in tests.\n *\n * @return {Set}\n *\n * @private\n */\n static get _queueNames() {\n return queueNames;\n }\n }\n\n /*\n Copyright 2017 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\n http://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 * A class implementing the `fetchDidFail` lifecycle callback. This makes it\n * easier to add failed requests to a background sync Queue.\n *\n * @memberof workbox.backgroundSync\n */\n class Plugin {\n /**\n * @param {...*} queueArgs Args to forward to the composed Queue instance.\n * See the [Queue]{@link workbox.backgroundSync.Queue} documentation for\n * parameter details.\n */\n constructor(...queueArgs) {\n this._queue = new Queue(...queueArgs);\n this.fetchDidFail = this.fetchDidFail.bind(this);\n }\n\n /**\n * @param {Object} options\n * @param {Request} options.request\n * @private\n */\n fetchDidFail({ request }) {\n var _this = this;\n\n return babelHelpers.asyncToGenerator(function* () {\n yield _this._queue.addRequest(request);\n })();\n }\n }\n\n /*\n Copyright 2017 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\n http://www.apache.org/licenses/LICENSE-2.0\n\n Unless required by applicable law or agreed to in writing, software\n distributed under the License is distributed on an \"AS IS\" BASIS,\n WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n See the License for the specific language governing permissions and\n limitations under the License.\n */\n\n var publicAPI = /*#__PURE__*/Object.freeze({\n Queue: Queue,\n Plugin: Plugin\n });\n\n /*\n Copyright 2017 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\n http://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 return publicAPI;\n\n}(workbox.core._private,workbox.core._private,workbox.core._private,workbox.core._private,workbox.core._private));\n"],"file":"workbox-background-sync.dev.js"}
@@ -1,3 +1,3 @@
1
- this.workbox=this.workbox||{},this.workbox.backgroundSync=function(e,t){"use strict";try{self.workbox.v["workbox:background-sync:3.4.1"]=1}catch(e){}const r=["method","referrer","referrerPolicy","mode","credentials","cache","redirect","integrity","keepalive"];class s{static fromRequest(e){return babelHelpers.asyncToGenerator(function*(){const t={headers:{}};"GET"!==e.method&&(t.body=yield e.clone().blob());for(const[r,s]of e.headers.entries())t.headers[r]=s;for(const s of r)void 0!==e[s]&&(t[s]=e[s]);return new s({url:e.url,requestInit:t})})()}constructor({url:e,requestInit:t,timestamp:r=Date.now()}){this.url=e,this.requestInit=t,this.e=r}get timestamp(){return this.e}toObject(){return{url:this.url,timestamp:this.timestamp,requestInit:this.requestInit}}toRequest(){return new Request(this.url,this.requestInit)}clone(){const e=Object.assign({},this.requestInit);return e.headers=Object.assign({},this.requestInit.headers),this.requestInit.body&&(e.body=this.requestInit.body.slice()),new s({url:this.url,timestamp:this.timestamp,requestInit:e})}}const i="workbox-background-sync",n="requests",u="queueName",c="workbox-background-sync",o=10080;class l{constructor(t){this.t=t,this.r=new e.DBWrapper(i,1,{onupgradeneeded:e=>e.target.result.createObjectStore(n,{autoIncrement:!0}).createIndex(u,u,{unique:!1})})}addEntry(e){var t=this;return babelHelpers.asyncToGenerator(function*(){yield t.r.add(n,{queueName:t.t.name,storableRequest:e.toObject()})})()}getAndRemoveOldestEntry(){var e=this;return babelHelpers.asyncToGenerator(function*(){const[t]=yield e.r.getAllMatching(n,{index:u,query:IDBKeyRange.only(e.t.name),count:1,includeKeys:!0});if(t)return yield e.r.delete(n,t.primaryKey),new s(t.value.storableRequest)})()}}const a=new Set;class h{constructor(e,{callbacks:r={},maxRetentionTime:s=o}={}){if(a.has(e))throw new t.WorkboxError("duplicate-queue-name",{name:e});a.add(e),this.s=e,this.i=r,this.n=s,this.u=new l(this),this.c()}get name(){return this.s}addRequest(e){var t=this;return babelHelpers.asyncToGenerator(function*(){const r=yield s.fromRequest(e.clone());yield t.o("requestWillEnqueue",r),yield t.u.addEntry(r),yield t.l()})()}replayRequests(){var e=this;return babelHelpers.asyncToGenerator(function*(){const r=Date.now(),s=[],i=[];let n;for(;n=yield e.u.getAndRemoveOldestEntry();){const t=n.clone(),u=60*e.n*1e3;if(r-n.timestamp>u)continue;yield e.o("requestWillReplay",n);const c={request:n.toRequest()};try{c.response=yield fetch(c.request.clone())}catch(e){c.error=e,i.push(t)}s.push(c)}if(yield e.o("queueDidReplay",s),i.length)throw yield Promise.all(i.map(function(t){return e.u.addEntry(t)})),new t.WorkboxError("queue-replay-failed",{name:e.s,count:i.length})})()}o(e,...t){var r=this;return babelHelpers.asyncToGenerator(function*(){"function"==typeof r.i[e]&&(yield r.i[e].apply(null,t))})()}c(){"sync"in registration?self.addEventListener("sync",e=>{e.tag===`${c}:${this.s}`&&e.waitUntil(this.replayRequests())}):this.replayRequests()}l(){var e=this;return babelHelpers.asyncToGenerator(function*(){if("sync"in registration)try{yield registration.sync.register(`${c}:${e.s}`)}catch(e){}})()}static get a(){return a}}return Object.freeze({Queue:h,Plugin:class{constructor(...e){this.t=new h(...e),this.fetchDidFail=this.fetchDidFail.bind(this)}fetchDidFail({request:e}){var t=this;return babelHelpers.asyncToGenerator(function*(){yield t.t.addRequest(e)})()}}})}(workbox.core._private,workbox.core._private);
1
+ this.workbox=this.workbox||{},this.workbox.backgroundSync=function(e,t){"use strict";try{self.workbox.v["workbox:background-sync:3.6.2"]=1}catch(e){}const r=["method","referrer","referrerPolicy","mode","credentials","cache","redirect","integrity","keepalive"];class s{static fromRequest(e){return babelHelpers.asyncToGenerator(function*(){const t={headers:{}};"GET"!==e.method&&(t.body=yield e.clone().blob());for(const[r,s]of e.headers.entries())t.headers[r]=s;for(const s of r)void 0!==e[s]&&(t[s]=e[s]);return new s({url:e.url,requestInit:t})})()}constructor({url:e,requestInit:t,timestamp:r=Date.now()}){this.url=e,this.requestInit=t,this.e=r}get timestamp(){return this.e}toObject(){return{url:this.url,timestamp:this.timestamp,requestInit:this.requestInit}}toRequest(){return new Request(this.url,this.requestInit)}clone(){const e=Object.assign({},this.requestInit);return e.headers=Object.assign({},this.requestInit.headers),this.requestInit.body&&(e.body=this.requestInit.body.slice()),new s({url:this.url,timestamp:this.timestamp,requestInit:e})}}const i="workbox-background-sync",n="requests",u="queueName",c="workbox-background-sync",o=10080;class l{constructor(t){this.t=t,this.r=new e.DBWrapper(i,1,{onupgradeneeded:e=>e.target.result.createObjectStore(n,{autoIncrement:!0}).createIndex(u,u,{unique:!1})})}addEntry(e){var t=this;return babelHelpers.asyncToGenerator(function*(){yield t.r.add(n,{queueName:t.t.name,storableRequest:e.toObject()})})()}getAndRemoveOldestEntry(){var e=this;return babelHelpers.asyncToGenerator(function*(){const[t]=yield e.r.getAllMatching(n,{index:u,query:IDBKeyRange.only(e.t.name),count:1,includeKeys:!0});if(t)return yield e.r.delete(n,t.primaryKey),new s(t.value.storableRequest)})()}}const a=new Set;class h{constructor(e,{callbacks:r={},maxRetentionTime:s=o}={}){if(a.has(e))throw new t.WorkboxError("duplicate-queue-name",{name:e});a.add(e),this.s=e,this.i=r,this.n=s,this.u=new l(this),this.c()}get name(){return this.s}addRequest(e){var t=this;return babelHelpers.asyncToGenerator(function*(){const r=yield s.fromRequest(e.clone());yield t.o("requestWillEnqueue",r),yield t.u.addEntry(r),yield t.l()})()}replayRequests(){var e=this;return babelHelpers.asyncToGenerator(function*(){const r=Date.now(),s=[],i=[];let n;for(;n=yield e.u.getAndRemoveOldestEntry();){const t=n.clone(),u=60*e.n*1e3;if(r-n.timestamp>u)continue;yield e.o("requestWillReplay",n);const c={request:n.toRequest()};try{c.response=yield fetch(c.request.clone())}catch(e){c.error=e,i.push(t)}s.push(c)}if(yield e.o("queueDidReplay",s),i.length)throw yield Promise.all(i.map(function(t){return e.u.addEntry(t)})),new t.WorkboxError("queue-replay-failed",{name:e.s,count:i.length})})()}o(e,...t){var r=this;return babelHelpers.asyncToGenerator(function*(){"function"==typeof r.i[e]&&(yield r.i[e].apply(null,t))})()}c(){"sync"in registration?self.addEventListener("sync",e=>{e.tag===`${c}:${this.s}`&&e.waitUntil(this.replayRequests())}):this.replayRequests()}l(){var e=this;return babelHelpers.asyncToGenerator(function*(){if("sync"in registration)try{yield registration.sync.register(`${c}:${e.s}`)}catch(e){}})()}static get a(){return a}}return Object.freeze({Queue:h,Plugin:class{constructor(...e){this.t=new h(...e),this.fetchDidFail=this.fetchDidFail.bind(this)}fetchDidFail({request:e}){var t=this;return babelHelpers.asyncToGenerator(function*(){yield t.t.addRequest(e)})()}}})}(workbox.core._private,workbox.core._private);
2
2
 
3
3
  //# sourceMappingURL=workbox-background-sync.prod.js.map
@@ -1 +1 @@
1
- {"version":3,"names":[],"mappings":"","sources":["packages/workbox-background-sync/browser.mjs"],"sourcesContent":["this.workbox=this.workbox||{},this.workbox.backgroundSync=function(e,t){\"use strict\";try{self.workbox.v[\"workbox:background-sync:3.4.1\"]=1}catch(e){}const r=[\"method\",\"referrer\",\"referrerPolicy\",\"mode\",\"credentials\",\"cache\",\"redirect\",\"integrity\",\"keepalive\"];class s{static fromRequest(e){return babelHelpers.asyncToGenerator(function*(){const t={headers:{}};\"GET\"!==e.method&&(t.body=yield e.clone().blob());for(const[r,s]of e.headers.entries())t.headers[r]=s;for(const s of r)void 0!==e[s]&&(t[s]=e[s]);return new s({url:e.url,requestInit:t})})()}constructor({url:e,requestInit:t,timestamp:r=Date.now()}){this.url=e,this.requestInit=t,this.e=r}get timestamp(){return this.e}toObject(){return{url:this.url,timestamp:this.timestamp,requestInit:this.requestInit}}toRequest(){return new Request(this.url,this.requestInit)}clone(){const e=Object.assign({},this.requestInit);return e.headers=Object.assign({},this.requestInit.headers),this.requestInit.body&&(e.body=this.requestInit.body.slice()),new s({url:this.url,timestamp:this.timestamp,requestInit:e})}}const i=\"workbox-background-sync\",n=\"requests\",u=\"queueName\",c=\"workbox-background-sync\",o=10080;class l{constructor(t){this.t=t,this.r=new e.DBWrapper(i,1,{onupgradeneeded:e=>e.target.result.createObjectStore(n,{autoIncrement:!0}).createIndex(u,u,{unique:!1})})}addEntry(e){var t=this;return babelHelpers.asyncToGenerator(function*(){yield t.r.add(n,{queueName:t.t.name,storableRequest:e.toObject()})})()}getAndRemoveOldestEntry(){var e=this;return babelHelpers.asyncToGenerator(function*(){const[t]=yield e.r.getAllMatching(n,{index:u,query:IDBKeyRange.only(e.t.name),count:1,includeKeys:!0});if(t)return yield e.r.delete(n,t.primaryKey),new s(t.value.storableRequest)})()}}const a=new Set;class h{constructor(e,{callbacks:r={},maxRetentionTime:s=o}={}){if(a.has(e))throw new t.WorkboxError(\"duplicate-queue-name\",{name:e});a.add(e),this.s=e,this.i=r,this.n=s,this.u=new l(this),this.c()}get name(){return this.s}addRequest(e){var t=this;return babelHelpers.asyncToGenerator(function*(){const r=yield s.fromRequest(e.clone());yield t.o(\"requestWillEnqueue\",r),yield t.u.addEntry(r),yield t.l()})()}replayRequests(){var e=this;return babelHelpers.asyncToGenerator(function*(){const r=Date.now(),s=[],i=[];let n;for(;n=yield e.u.getAndRemoveOldestEntry();){const t=n.clone(),u=60*e.n*1e3;if(r-n.timestamp>u)continue;yield e.o(\"requestWillReplay\",n);const c={request:n.toRequest()};try{c.response=yield fetch(c.request.clone())}catch(e){c.error=e,i.push(t)}s.push(c)}if(yield e.o(\"queueDidReplay\",s),i.length)throw yield Promise.all(i.map(function(t){return e.u.addEntry(t)})),new t.WorkboxError(\"queue-replay-failed\",{name:e.s,count:i.length})})()}o(e,...t){var r=this;return babelHelpers.asyncToGenerator(function*(){\"function\"==typeof r.i[e]&&(yield r.i[e].apply(null,t))})()}c(){\"sync\"in registration?self.addEventListener(\"sync\",e=>{e.tag===`${c}:${this.s}`&&e.waitUntil(this.replayRequests())}):this.replayRequests()}l(){var e=this;return babelHelpers.asyncToGenerator(function*(){if(\"sync\"in registration)try{yield registration.sync.register(`${c}:${e.s}`)}catch(e){}})()}static get a(){return a}}return Object.freeze({Queue:h,Plugin:class{constructor(...e){this.t=new h(...e),this.fetchDidFail=this.fetchDidFail.bind(this)}fetchDidFail({request:e}){var t=this;return babelHelpers.asyncToGenerator(function*(){yield t.t.addRequest(e)})()}}})}(workbox.core._private,workbox.core._private);\n"],"file":"workbox-background-sync.prod.js"}
1
+ {"version":3,"names":[],"mappings":"","sources":["packages/workbox-background-sync/browser.mjs"],"sourcesContent":["this.workbox=this.workbox||{},this.workbox.backgroundSync=function(e,t){\"use strict\";try{self.workbox.v[\"workbox:background-sync:3.6.2\"]=1}catch(e){}const r=[\"method\",\"referrer\",\"referrerPolicy\",\"mode\",\"credentials\",\"cache\",\"redirect\",\"integrity\",\"keepalive\"];class s{static fromRequest(e){return babelHelpers.asyncToGenerator(function*(){const t={headers:{}};\"GET\"!==e.method&&(t.body=yield e.clone().blob());for(const[r,s]of e.headers.entries())t.headers[r]=s;for(const s of r)void 0!==e[s]&&(t[s]=e[s]);return new s({url:e.url,requestInit:t})})()}constructor({url:e,requestInit:t,timestamp:r=Date.now()}){this.url=e,this.requestInit=t,this.e=r}get timestamp(){return this.e}toObject(){return{url:this.url,timestamp:this.timestamp,requestInit:this.requestInit}}toRequest(){return new Request(this.url,this.requestInit)}clone(){const e=Object.assign({},this.requestInit);return e.headers=Object.assign({},this.requestInit.headers),this.requestInit.body&&(e.body=this.requestInit.body.slice()),new s({url:this.url,timestamp:this.timestamp,requestInit:e})}}const i=\"workbox-background-sync\",n=\"requests\",u=\"queueName\",c=\"workbox-background-sync\",o=10080;class l{constructor(t){this.t=t,this.r=new e.DBWrapper(i,1,{onupgradeneeded:e=>e.target.result.createObjectStore(n,{autoIncrement:!0}).createIndex(u,u,{unique:!1})})}addEntry(e){var t=this;return babelHelpers.asyncToGenerator(function*(){yield t.r.add(n,{queueName:t.t.name,storableRequest:e.toObject()})})()}getAndRemoveOldestEntry(){var e=this;return babelHelpers.asyncToGenerator(function*(){const[t]=yield e.r.getAllMatching(n,{index:u,query:IDBKeyRange.only(e.t.name),count:1,includeKeys:!0});if(t)return yield e.r.delete(n,t.primaryKey),new s(t.value.storableRequest)})()}}const a=new Set;class h{constructor(e,{callbacks:r={},maxRetentionTime:s=o}={}){if(a.has(e))throw new t.WorkboxError(\"duplicate-queue-name\",{name:e});a.add(e),this.s=e,this.i=r,this.n=s,this.u=new l(this),this.c()}get name(){return this.s}addRequest(e){var t=this;return babelHelpers.asyncToGenerator(function*(){const r=yield s.fromRequest(e.clone());yield t.o(\"requestWillEnqueue\",r),yield t.u.addEntry(r),yield t.l()})()}replayRequests(){var e=this;return babelHelpers.asyncToGenerator(function*(){const r=Date.now(),s=[],i=[];let n;for(;n=yield e.u.getAndRemoveOldestEntry();){const t=n.clone(),u=60*e.n*1e3;if(r-n.timestamp>u)continue;yield e.o(\"requestWillReplay\",n);const c={request:n.toRequest()};try{c.response=yield fetch(c.request.clone())}catch(e){c.error=e,i.push(t)}s.push(c)}if(yield e.o(\"queueDidReplay\",s),i.length)throw yield Promise.all(i.map(function(t){return e.u.addEntry(t)})),new t.WorkboxError(\"queue-replay-failed\",{name:e.s,count:i.length})})()}o(e,...t){var r=this;return babelHelpers.asyncToGenerator(function*(){\"function\"==typeof r.i[e]&&(yield r.i[e].apply(null,t))})()}c(){\"sync\"in registration?self.addEventListener(\"sync\",e=>{e.tag===`${c}:${this.s}`&&e.waitUntil(this.replayRequests())}):this.replayRequests()}l(){var e=this;return babelHelpers.asyncToGenerator(function*(){if(\"sync\"in registration)try{yield registration.sync.register(`${c}:${e.s}`)}catch(e){}})()}static get a(){return a}}return Object.freeze({Queue:h,Plugin:class{constructor(...e){this.t=new h(...e),this.fetchDidFail=this.fetchDidFail.bind(this)}fetchDidFail({request:e}){var t=this;return babelHelpers.asyncToGenerator(function*(){yield t.t.addRequest(e)})()}}})}(workbox.core._private,workbox.core._private);\n"],"file":"workbox-background-sync.prod.js"}
@@ -3,7 +3,7 @@ this.workbox.broadcastUpdate = (function (exports,WorkboxError_mjs,logger_mjs,as
3
3
  'use strict';
4
4
 
5
5
  try {
6
- self.workbox.v['workbox:broadcast-cache-update:3.4.1'] = 1;
6
+ self.workbox.v['workbox:broadcast-cache-update:3.6.2'] = 1;
7
7
  } catch (e) {} // eslint-disable-line
8
8
 
9
9
  /*
@@ -315,10 +315,10 @@ this.workbox.broadcastUpdate = (function (exports,WorkboxError_mjs,logger_mjs,as
315
315
  * added to a cache.
316
316
  *
317
317
  * @private
318
- * @param {Object} input The input object to this function.
319
- * @param {string} input.cacheName Name of the cache the responses belong to.
320
- * @param {Response} [input.oldResponse] The previous cached value, if any.
321
- * @param {Response} input.newResponse The new value in the cache.
318
+ * @param {Object} options The input object to this function.
319
+ * @param {string} options.cacheName Name of the cache being updated.
320
+ * @param {Response} [options.oldResponse] The previous cached value, if any.
321
+ * @param {Response} options.newResponse The new value in the cache.
322
322
  */
323
323
  cacheDidUpdate({ cacheName, oldResponse, newResponse, request }) {
324
324
  {
@@ -1 +1 @@
1
- {"version":3,"names":[],"mappings":"","sources":["packages/workbox-broadcast-cache-update/browser.mjs"],"sourcesContent":["this.workbox = this.workbox || {};\nthis.workbox.broadcastUpdate = (function (exports,WorkboxError_mjs,logger_mjs,assert_mjs) {\n 'use strict';\n\n try {\n self.workbox.v['workbox:broadcast-cache-update:3.4.1'] = 1;\n } catch (e) {} // eslint-disable-line\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\n http://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 * Given two `Response's`, compares several header values to see if they are\n * the same or not.\n *\n * @param {Response} firstResponse\n * @param {Response} secondResponse\n * @param {Array<string>} headersToCheck\n * @return {boolean}\n *\n * @memberof workbox.broadcastUpdate\n * @private\n */\n const responsesAreSame = (firstResponse, secondResponse, headersToCheck) => {\n {\n if (!(firstResponse instanceof Response && secondResponse instanceof Response)) {\n throw new WorkboxError_mjs.WorkboxError('invalid-responses-are-same-args');\n }\n }\n\n const atLeastOneHeaderAvailable = headersToCheck.some(header => {\n return firstResponse.headers.has(header) && secondResponse.headers.has(header);\n });\n\n if (!atLeastOneHeaderAvailable) {\n {\n logger_mjs.logger.warn(`Unable to determine where the response has been updated ` + `because none of the headers that would be checked are present.`);\n logger_mjs.logger.debug(`Attempting to compare the following: `, firstResponse, secondResponse, headersToCheck);\n }\n\n // Just return true, indicating the that responses are the same, since we\n // can't determine otherwise.\n return true;\n }\n\n return headersToCheck.every(header => {\n const headerStateComparison = firstResponse.headers.has(header) === secondResponse.headers.has(header);\n const headerValueComparison = firstResponse.headers.get(header) === secondResponse.headers.get(header);\n\n return headerStateComparison && headerValueComparison;\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\n http://www.apache.org/licenses/LICENSE-2.0\n\n Unless required by applicable law or agreed to in writing, software\n distributed under the License is distributed on an \"AS IS\" BASIS,\n WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n See the License for the specific language governing permissions and\n limitations under the License.\n */\n\n var messageTypes = {\n CACHE_UPDATED: 'CACHE_UPDATED'\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\n http://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 * You would not normally call this method directly; it's called automatically\n * by an instance of the {@link BroadcastCacheUpdate} class. It's exposed here\n * for the benefit of developers who would rather not use the full\n * `BroadcastCacheUpdate` implementation.\n *\n * Calling this will dispatch a message on the provided\n * {@link https://developers.google.com/web/updates/2016/09/broadcastchannel|Broadcast Channel}\n * to notify interested subscribers about a change to a cached resource.\n *\n * The message that's posted has a formation inspired by the\n * [Flux standard action](https://github.com/acdlite/flux-standard-action#introduction)\n * format like so:\n *\n * ```\n * {\n * type: 'CACHE_UPDATED',\n * meta: 'workbox-broadcast-cache-update',\n * payload: {\n * cacheName: 'the-cache-name',\n * updatedUrl: 'https://example.com/'\n * }\n * }\n * ```\n *\n * (Usage of [Flux](https://facebook.github.io/flux/) itself is not at\n * all required.)\n *\n * @param {BroadcastChannel} channel The `BroadcastChannel` to use.\n * @param {string} cacheName The name of the cache in which the updated\n * `Response` was stored.\n * @param {string} url The URL associated with the updated `Response`.\n * @param {string} source A string identifying this library as the source\n * of the update message.\n *\n * @memberof workbox.broadcastUpdate\n */\n const broadcastUpdate = (channel, cacheName, url, source) => {\n // There are browsers which support service workers but don't support the\n // Broadcast Channel API.\n // See https://github.com/GoogleChrome/workbox/issues/1304\n if (!('BroadcastChannel' in self && channel)) {\n {\n logger_mjs.logger.debug(`${url} was updated, but the Broadcast Channel API is not ` + `available in the current browser.`);\n }\n return;\n }\n\n {\n assert_mjs.assert.isInstance(channel, BroadcastChannel, {\n moduleName: 'workbox-broadcast-cache-update',\n className: '~',\n funcName: 'broadcastUpdate',\n paramName: 'channel'\n });\n assert_mjs.assert.isType(cacheName, 'string', {\n moduleName: 'workbox-broadcast-cache-update',\n className: '~',\n funcName: 'broadcastUpdate',\n paramName: 'cacheName'\n });\n assert_mjs.assert.isType(url, 'string', {\n moduleName: 'workbox-broadcast-cache-update',\n className: '~',\n funcName: 'broadcastUpdate',\n paramName: 'url'\n });\n assert_mjs.assert.isType(source, 'string', {\n moduleName: 'workbox-broadcast-cache-update',\n className: '~',\n funcName: 'broadcastUpdate',\n paramName: 'source'\n });\n }\n\n channel.postMessage({\n type: messageTypes.CACHE_UPDATED,\n meta: source,\n payload: {\n cacheName: cacheName,\n updatedUrl: url\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\n http://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 * Uses the [Broadcast Channel API]{@link https://developers.google.com/web/updates/2016/09/broadcastchannel}\n * to notify interested parties when a cached response has been updated.\n *\n * For efficiency's sake, the underlying response bodies are not compared;\n * only specific response headers are checked.\n *\n * @memberof workbox.broadcastUpdate\n */\n class BroadcastCacheUpdate {\n /**\n * Construct a BroadcastCacheUpdate instance with a specific `channelName` to\n * broadcast messages on\n *\n * @param {string} channelName The name that will be used when creating\n * the `BroadcastChannel`.\n * @param {Object} options\n * @param {Array<string>}\n * [options.headersToCheck=['content-length', 'etag', 'last-modified']] A\n * list of headers that will be used to determine whether the responses\n * differ.\n * @param {string} [options.source='workbox-broadcast-cache-update'] An\n * attribution value that indicates where the update originated.\n */\n constructor(channelName, { headersToCheck, source } = {}) {\n {\n if (typeof channelName !== 'string' || channelName.length === 0) {\n throw new WorkboxError_mjs.WorkboxError('channel-name-required');\n }\n }\n\n this._channelName = channelName;\n this._headersToCheck = headersToCheck || ['content-length', 'etag', 'last-modified'];\n this._source = source || 'workbox-broadcast-cache-update';\n\n // TODO assert typeof headersToCheck instanceof Array\n }\n\n /**\n * @return {BroadcastChannel|undefined} The BroadcastChannel instance used for\n * broadcasting updates, or undefined if the browser doesn't support the\n * Broadcast Channel API.\n *\n * @private\n */\n _getChannel() {\n if ('BroadcastChannel' in self && !this._channel) {\n this._channel = new BroadcastChannel(this._channelName);\n }\n return this._channel;\n }\n\n /**\n * Compare two [Responses](https://developer.mozilla.org/en-US/docs/Web/API/Response)\n * and send a message via the\n * {@link https://developers.google.com/web/updates/2016/09/broadcastchannel|Broadcast Channel API}\n * if they differ.\n *\n * Neither of the Responses can be {@link http://stackoverflow.com/questions/39109789|opaque}.\n *\n * @param {Response} firstResponse First responses to compare.\n * @param {Response} secondResponse Second responses to compare.\n * @param {string} url The URL of the updated request.\n * @param {string} cacheName Name of the cache the responses belong to.\n * This is included in the message posted on the broadcast channel.\n */\n notifyIfUpdated(firstResponse, secondResponse, url, cacheName) {\n if (!responsesAreSame(firstResponse, secondResponse, this._headersToCheck)) {\n broadcastUpdate(this._getChannel(), cacheName, url, this._source);\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\n http://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 plugin will automatically broadcast a message whenever a cached response\n * is updated.\n *\n * @memberof workbox.broadcastUpdate\n */\n class Plugin {\n /**\n * Construct a new instance with a specific `channelName` to\n * broadcast messages on\n *\n * @param {string} channelName The name that will be used when creating\n * the `BroadcastChannel`.\n * @param {Object} options\n * @param {Array<string>}\n * [options.headersToCheck=['content-length', 'etag', 'last-modified']] A\n * list of headers that will be used to determine whether the responses\n * differ.\n * @param {string} [options.source='workbox-broadcast-cache-update'] An\n * attribution value that indicates where the update originated.\n */\n constructor(channelName, options) {\n this._broadcastUpdate = new BroadcastCacheUpdate(channelName, options);\n }\n /**\n * A \"lifecycle\" callback that will be triggered automatically by the\n * `workbox-sw` and `workbox-runtime-caching` handlers when an entry is\n * added to a cache.\n *\n * @private\n * @param {Object} input The input object to this function.\n * @param {string} input.cacheName Name of the cache the responses belong to.\n * @param {Response} [input.oldResponse] The previous cached value, if any.\n * @param {Response} input.newResponse The new value in the cache.\n */\n cacheDidUpdate({ cacheName, oldResponse, newResponse, request }) {\n {\n assert_mjs.assert.isType(cacheName, 'string', {\n moduleName: 'workbox-broadcast-cache-update',\n className: 'Plugin',\n funcName: 'cacheDidUpdate',\n paramName: 'cacheName'\n });\n assert_mjs.assert.isInstance(newResponse, Response, {\n moduleName: 'workbox-broadcast-cache-update',\n className: 'Plugin',\n funcName: 'cacheDidUpdate',\n paramName: 'newResponse'\n });\n assert_mjs.assert.isInstance(request, Request, {\n moduleName: 'workbox-broadcast-cache-update',\n className: 'Plugin',\n funcName: 'cacheDidUpdate',\n paramName: 'request'\n });\n }\n\n if (!oldResponse) {\n // Without a two responses there is nothing to compare.\n return;\n }\n\n this._broadcastUpdate.notifyIfUpdated(oldResponse, newResponse, request.url, cacheName);\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.BroadcastCacheUpdate = BroadcastCacheUpdate;\n exports.Plugin = Plugin;\n exports.broadcastUpdate = broadcastUpdate;\n exports.messageTypes = messageTypes;\n\n return exports;\n\n}({},workbox.core._private,workbox.core._private,workbox.core._private));\n"],"file":"workbox-broadcast-cache-update.dev.js"}
1
+ {"version":3,"names":[],"mappings":"","sources":["packages/workbox-broadcast-cache-update/browser.mjs"],"sourcesContent":["this.workbox = this.workbox || {};\nthis.workbox.broadcastUpdate = (function (exports,WorkboxError_mjs,logger_mjs,assert_mjs) {\n 'use strict';\n\n try {\n self.workbox.v['workbox:broadcast-cache-update:3.6.2'] = 1;\n } catch (e) {} // eslint-disable-line\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\n http://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 * Given two `Response's`, compares several header values to see if they are\n * the same or not.\n *\n * @param {Response} firstResponse\n * @param {Response} secondResponse\n * @param {Array<string>} headersToCheck\n * @return {boolean}\n *\n * @memberof workbox.broadcastUpdate\n * @private\n */\n const responsesAreSame = (firstResponse, secondResponse, headersToCheck) => {\n {\n if (!(firstResponse instanceof Response && secondResponse instanceof Response)) {\n throw new WorkboxError_mjs.WorkboxError('invalid-responses-are-same-args');\n }\n }\n\n const atLeastOneHeaderAvailable = headersToCheck.some(header => {\n return firstResponse.headers.has(header) && secondResponse.headers.has(header);\n });\n\n if (!atLeastOneHeaderAvailable) {\n {\n logger_mjs.logger.warn(`Unable to determine where the response has been updated ` + `because none of the headers that would be checked are present.`);\n logger_mjs.logger.debug(`Attempting to compare the following: `, firstResponse, secondResponse, headersToCheck);\n }\n\n // Just return true, indicating the that responses are the same, since we\n // can't determine otherwise.\n return true;\n }\n\n return headersToCheck.every(header => {\n const headerStateComparison = firstResponse.headers.has(header) === secondResponse.headers.has(header);\n const headerValueComparison = firstResponse.headers.get(header) === secondResponse.headers.get(header);\n\n return headerStateComparison && headerValueComparison;\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\n http://www.apache.org/licenses/LICENSE-2.0\n\n Unless required by applicable law or agreed to in writing, software\n distributed under the License is distributed on an \"AS IS\" BASIS,\n WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n See the License for the specific language governing permissions and\n limitations under the License.\n */\n\n var messageTypes = {\n CACHE_UPDATED: 'CACHE_UPDATED'\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\n http://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 * You would not normally call this method directly; it's called automatically\n * by an instance of the {@link BroadcastCacheUpdate} class. It's exposed here\n * for the benefit of developers who would rather not use the full\n * `BroadcastCacheUpdate` implementation.\n *\n * Calling this will dispatch a message on the provided\n * {@link https://developers.google.com/web/updates/2016/09/broadcastchannel|Broadcast Channel}\n * to notify interested subscribers about a change to a cached resource.\n *\n * The message that's posted has a formation inspired by the\n * [Flux standard action](https://github.com/acdlite/flux-standard-action#introduction)\n * format like so:\n *\n * ```\n * {\n * type: 'CACHE_UPDATED',\n * meta: 'workbox-broadcast-cache-update',\n * payload: {\n * cacheName: 'the-cache-name',\n * updatedUrl: 'https://example.com/'\n * }\n * }\n * ```\n *\n * (Usage of [Flux](https://facebook.github.io/flux/) itself is not at\n * all required.)\n *\n * @param {BroadcastChannel} channel The `BroadcastChannel` to use.\n * @param {string} cacheName The name of the cache in which the updated\n * `Response` was stored.\n * @param {string} url The URL associated with the updated `Response`.\n * @param {string} source A string identifying this library as the source\n * of the update message.\n *\n * @memberof workbox.broadcastUpdate\n */\n const broadcastUpdate = (channel, cacheName, url, source) => {\n // There are browsers which support service workers but don't support the\n // Broadcast Channel API.\n // See https://github.com/GoogleChrome/workbox/issues/1304\n if (!('BroadcastChannel' in self && channel)) {\n {\n logger_mjs.logger.debug(`${url} was updated, but the Broadcast Channel API is not ` + `available in the current browser.`);\n }\n return;\n }\n\n {\n assert_mjs.assert.isInstance(channel, BroadcastChannel, {\n moduleName: 'workbox-broadcast-cache-update',\n className: '~',\n funcName: 'broadcastUpdate',\n paramName: 'channel'\n });\n assert_mjs.assert.isType(cacheName, 'string', {\n moduleName: 'workbox-broadcast-cache-update',\n className: '~',\n funcName: 'broadcastUpdate',\n paramName: 'cacheName'\n });\n assert_mjs.assert.isType(url, 'string', {\n moduleName: 'workbox-broadcast-cache-update',\n className: '~',\n funcName: 'broadcastUpdate',\n paramName: 'url'\n });\n assert_mjs.assert.isType(source, 'string', {\n moduleName: 'workbox-broadcast-cache-update',\n className: '~',\n funcName: 'broadcastUpdate',\n paramName: 'source'\n });\n }\n\n channel.postMessage({\n type: messageTypes.CACHE_UPDATED,\n meta: source,\n payload: {\n cacheName: cacheName,\n updatedUrl: url\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\n http://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 * Uses the [Broadcast Channel API]{@link https://developers.google.com/web/updates/2016/09/broadcastchannel}\n * to notify interested parties when a cached response has been updated.\n *\n * For efficiency's sake, the underlying response bodies are not compared;\n * only specific response headers are checked.\n *\n * @memberof workbox.broadcastUpdate\n */\n class BroadcastCacheUpdate {\n /**\n * Construct a BroadcastCacheUpdate instance with a specific `channelName` to\n * broadcast messages on\n *\n * @param {string} channelName The name that will be used when creating\n * the `BroadcastChannel`.\n * @param {Object} options\n * @param {Array<string>}\n * [options.headersToCheck=['content-length', 'etag', 'last-modified']] A\n * list of headers that will be used to determine whether the responses\n * differ.\n * @param {string} [options.source='workbox-broadcast-cache-update'] An\n * attribution value that indicates where the update originated.\n */\n constructor(channelName, { headersToCheck, source } = {}) {\n {\n if (typeof channelName !== 'string' || channelName.length === 0) {\n throw new WorkboxError_mjs.WorkboxError('channel-name-required');\n }\n }\n\n this._channelName = channelName;\n this._headersToCheck = headersToCheck || ['content-length', 'etag', 'last-modified'];\n this._source = source || 'workbox-broadcast-cache-update';\n\n // TODO assert typeof headersToCheck instanceof Array\n }\n\n /**\n * @return {BroadcastChannel|undefined} The BroadcastChannel instance used for\n * broadcasting updates, or undefined if the browser doesn't support the\n * Broadcast Channel API.\n *\n * @private\n */\n _getChannel() {\n if ('BroadcastChannel' in self && !this._channel) {\n this._channel = new BroadcastChannel(this._channelName);\n }\n return this._channel;\n }\n\n /**\n * Compare two [Responses](https://developer.mozilla.org/en-US/docs/Web/API/Response)\n * and send a message via the\n * {@link https://developers.google.com/web/updates/2016/09/broadcastchannel|Broadcast Channel API}\n * if they differ.\n *\n * Neither of the Responses can be {@link http://stackoverflow.com/questions/39109789|opaque}.\n *\n * @param {Response} firstResponse First responses to compare.\n * @param {Response} secondResponse Second responses to compare.\n * @param {string} url The URL of the updated request.\n * @param {string} cacheName Name of the cache the responses belong to.\n * This is included in the message posted on the broadcast channel.\n */\n notifyIfUpdated(firstResponse, secondResponse, url, cacheName) {\n if (!responsesAreSame(firstResponse, secondResponse, this._headersToCheck)) {\n broadcastUpdate(this._getChannel(), cacheName, url, this._source);\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\n http://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 plugin will automatically broadcast a message whenever a cached response\n * is updated.\n *\n * @memberof workbox.broadcastUpdate\n */\n class Plugin {\n /**\n * Construct a new instance with a specific `channelName` to\n * broadcast messages on\n *\n * @param {string} channelName The name that will be used when creating\n * the `BroadcastChannel`.\n * @param {Object} options\n * @param {Array<string>}\n * [options.headersToCheck=['content-length', 'etag', 'last-modified']] A\n * list of headers that will be used to determine whether the responses\n * differ.\n * @param {string} [options.source='workbox-broadcast-cache-update'] An\n * attribution value that indicates where the update originated.\n */\n constructor(channelName, options) {\n this._broadcastUpdate = new BroadcastCacheUpdate(channelName, options);\n }\n /**\n * A \"lifecycle\" callback that will be triggered automatically by the\n * `workbox-sw` and `workbox-runtime-caching` handlers when an entry is\n * added to a cache.\n *\n * @private\n * @param {Object} options The input object to this function.\n * @param {string} options.cacheName Name of the cache being updated.\n * @param {Response} [options.oldResponse] The previous cached value, if any.\n * @param {Response} options.newResponse The new value in the cache.\n */\n cacheDidUpdate({ cacheName, oldResponse, newResponse, request }) {\n {\n assert_mjs.assert.isType(cacheName, 'string', {\n moduleName: 'workbox-broadcast-cache-update',\n className: 'Plugin',\n funcName: 'cacheDidUpdate',\n paramName: 'cacheName'\n });\n assert_mjs.assert.isInstance(newResponse, Response, {\n moduleName: 'workbox-broadcast-cache-update',\n className: 'Plugin',\n funcName: 'cacheDidUpdate',\n paramName: 'newResponse'\n });\n assert_mjs.assert.isInstance(request, Request, {\n moduleName: 'workbox-broadcast-cache-update',\n className: 'Plugin',\n funcName: 'cacheDidUpdate',\n paramName: 'request'\n });\n }\n\n if (!oldResponse) {\n // Without a two responses there is nothing to compare.\n return;\n }\n\n this._broadcastUpdate.notifyIfUpdated(oldResponse, newResponse, request.url, cacheName);\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.BroadcastCacheUpdate = BroadcastCacheUpdate;\n exports.Plugin = Plugin;\n exports.broadcastUpdate = broadcastUpdate;\n exports.messageTypes = messageTypes;\n\n return exports;\n\n}({},workbox.core._private,workbox.core._private,workbox.core._private));\n"],"file":"workbox-broadcast-cache-update.dev.js"}
@@ -1,3 +1,3 @@
1
- this.workbox=this.workbox||{},this.workbox.broadcastUpdate=function(t){"use strict";try{self.workbox.v["workbox:broadcast-cache-update:3.4.1"]=1}catch(t){}const e=(t,e,s)=>{return!s.some(s=>t.headers.has(s)&&e.headers.has(s))||s.every(s=>{const a=t.headers.has(s)===e.headers.has(s),n=t.headers.get(s)===e.headers.get(s);return a&&n})};var s={CACHE_UPDATED:"CACHE_UPDATED"};const a=(t,e,a,n)=>{"BroadcastChannel"in self&&t&&t.postMessage({type:s.CACHE_UPDATED,meta:n,payload:{cacheName:e,updatedUrl:a}})};class n{constructor(t,{headersToCheck:e,source:s}={}){this.t=t,this.e=e||["content-length","etag","last-modified"],this.s=s||"workbox-broadcast-cache-update"}a(){return"BroadcastChannel"in self&&!this.n&&(this.n=new BroadcastChannel(this.t)),this.n}notifyIfUpdated(t,s,n,c){e(t,s,this.e)||a(this.a(),c,n,this.s)}}return t.BroadcastCacheUpdate=n,t.Plugin=class{constructor(t,e){this.c=new n(t,e)}cacheDidUpdate({cacheName:t,oldResponse:e,newResponse:s,request:a}){e&&this.c.notifyIfUpdated(e,s,a.url,t)}},t.broadcastUpdate=a,t.messageTypes=s,t}({});
1
+ this.workbox=this.workbox||{},this.workbox.broadcastUpdate=function(t){"use strict";try{self.workbox.v["workbox:broadcast-cache-update:3.6.2"]=1}catch(t){}const e=(t,e,s)=>{return!s.some(s=>t.headers.has(s)&&e.headers.has(s))||s.every(s=>{const a=t.headers.has(s)===e.headers.has(s),n=t.headers.get(s)===e.headers.get(s);return a&&n})};var s={CACHE_UPDATED:"CACHE_UPDATED"};const a=(t,e,a,n)=>{"BroadcastChannel"in self&&t&&t.postMessage({type:s.CACHE_UPDATED,meta:n,payload:{cacheName:e,updatedUrl:a}})};class n{constructor(t,{headersToCheck:e,source:s}={}){this.t=t,this.e=e||["content-length","etag","last-modified"],this.s=s||"workbox-broadcast-cache-update"}a(){return"BroadcastChannel"in self&&!this.n&&(this.n=new BroadcastChannel(this.t)),this.n}notifyIfUpdated(t,s,n,c){e(t,s,this.e)||a(this.a(),c,n,this.s)}}return t.BroadcastCacheUpdate=n,t.Plugin=class{constructor(t,e){this.c=new n(t,e)}cacheDidUpdate({cacheName:t,oldResponse:e,newResponse:s,request:a}){e&&this.c.notifyIfUpdated(e,s,a.url,t)}},t.broadcastUpdate=a,t.messageTypes=s,t}({});
2
2
 
3
3
  //# sourceMappingURL=workbox-broadcast-cache-update.prod.js.map
@@ -1 +1 @@
1
- {"version":3,"names":[],"mappings":"","sources":["packages/workbox-broadcast-cache-update/browser.mjs"],"sourcesContent":["this.workbox=this.workbox||{},this.workbox.broadcastUpdate=function(t){\"use strict\";try{self.workbox.v[\"workbox:broadcast-cache-update:3.4.1\"]=1}catch(t){}const e=(t,e,s)=>{return!s.some(s=>t.headers.has(s)&&e.headers.has(s))||s.every(s=>{const a=t.headers.has(s)===e.headers.has(s),n=t.headers.get(s)===e.headers.get(s);return a&&n})};var s={CACHE_UPDATED:\"CACHE_UPDATED\"};const a=(t,e,a,n)=>{\"BroadcastChannel\"in self&&t&&t.postMessage({type:s.CACHE_UPDATED,meta:n,payload:{cacheName:e,updatedUrl:a}})};class n{constructor(t,{headersToCheck:e,source:s}={}){this.t=t,this.e=e||[\"content-length\",\"etag\",\"last-modified\"],this.s=s||\"workbox-broadcast-cache-update\"}a(){return\"BroadcastChannel\"in self&&!this.n&&(this.n=new BroadcastChannel(this.t)),this.n}notifyIfUpdated(t,s,n,c){e(t,s,this.e)||a(this.a(),c,n,this.s)}}return t.BroadcastCacheUpdate=n,t.Plugin=class{constructor(t,e){this.c=new n(t,e)}cacheDidUpdate({cacheName:t,oldResponse:e,newResponse:s,request:a}){e&&this.c.notifyIfUpdated(e,s,a.url,t)}},t.broadcastUpdate=a,t.messageTypes=s,t}({});\n"],"file":"workbox-broadcast-cache-update.prod.js"}
1
+ {"version":3,"names":[],"mappings":"","sources":["packages/workbox-broadcast-cache-update/browser.mjs"],"sourcesContent":["this.workbox=this.workbox||{},this.workbox.broadcastUpdate=function(t){\"use strict\";try{self.workbox.v[\"workbox:broadcast-cache-update:3.6.2\"]=1}catch(t){}const e=(t,e,s)=>{return!s.some(s=>t.headers.has(s)&&e.headers.has(s))||s.every(s=>{const a=t.headers.has(s)===e.headers.has(s),n=t.headers.get(s)===e.headers.get(s);return a&&n})};var s={CACHE_UPDATED:\"CACHE_UPDATED\"};const a=(t,e,a,n)=>{\"BroadcastChannel\"in self&&t&&t.postMessage({type:s.CACHE_UPDATED,meta:n,payload:{cacheName:e,updatedUrl:a}})};class n{constructor(t,{headersToCheck:e,source:s}={}){this.t=t,this.e=e||[\"content-length\",\"etag\",\"last-modified\"],this.s=s||\"workbox-broadcast-cache-update\"}a(){return\"BroadcastChannel\"in self&&!this.n&&(this.n=new BroadcastChannel(this.t)),this.n}notifyIfUpdated(t,s,n,c){e(t,s,this.e)||a(this.a(),c,n,this.s)}}return t.BroadcastCacheUpdate=n,t.Plugin=class{constructor(t,e){this.c=new n(t,e)}cacheDidUpdate({cacheName:t,oldResponse:e,newResponse:s,request:a}){e&&this.c.notifyIfUpdated(e,s,a.url,t)}},t.broadcastUpdate=a,t.messageTypes=s,t}({});\n"],"file":"workbox-broadcast-cache-update.prod.js"}
@@ -1,9 +1,9 @@
1
1
  this.workbox = this.workbox || {};
2
- this.workbox.expiration = (function (exports,DBWrapper_mjs,WorkboxError_mjs,assert_mjs,logger_mjs,cacheNames_mjs,quota_mjs) {
2
+ this.workbox.expiration = (function (exports,DBWrapper_mjs,WorkboxError_mjs,assert_mjs,logger_mjs,cacheNames_mjs,index_mjs) {
3
3
  'use strict';
4
4
 
5
5
  try {
6
- self.workbox.v['workbox:cache-expiration:3.4.1'] = 1;
6
+ self.workbox.v['workbox:cache-expiration:3.6.2'] = 1;
7
7
  } catch (e) {} // eslint-disable-line
8
8
 
9
9
  /*
@@ -518,7 +518,7 @@ this.workbox.expiration = (function (exports,DBWrapper_mjs,WorkboxError_mjs,asse
518
518
  this._cacheExpirations = new Map();
519
519
 
520
520
  if (config.purgeOnQuotaError) {
521
- quota_mjs.registerQuotaErrorCallback(() => this.deleteCacheAndMetadata());
521
+ index_mjs.registerQuotaErrorCallback(() => this.deleteCacheAndMetadata());
522
522
  }
523
523
  }
524
524
 
@@ -552,12 +552,12 @@ this.workbox.expiration = (function (exports,DBWrapper_mjs,WorkboxError_mjs,asse
552
552
  * prevents it from being used if the `Response`'s `Date` header value is
553
553
  * older than the configured `maxAgeSeconds`.
554
554
  *
555
- * @param {Object} input
556
- * @param {string} input.cacheName Name of the cache the responses belong to.
557
- * @param {Response} input.cachedResponse The `Response` object that's been
558
- * read from a cache and whose freshness should be checked.
555
+ * @param {Object} options
556
+ * @param {string} options.cacheName Name of the cache the response is in.
557
+ * @param {Response} options.cachedResponse The `Response` object that's been
558
+ * read from a cache and whose freshness should be checked.
559
559
  * @return {Response} Either the `cachedResponse`, if it's
560
- * fresh, or `null` if the `Response` is older than `maxAgeSeconds`.
560
+ * fresh, or `null` if the `Response` is older than `maxAgeSeconds`.
561
561
  *
562
562
  * @private
563
563
  */
@@ -634,9 +634,9 @@ this.workbox.expiration = (function (exports,DBWrapper_mjs,WorkboxError_mjs,asse
634
634
  * A "lifecycle" callback that will be triggered automatically by the
635
635
  * `workbox.runtimeCaching` handlers when an entry is added to a cache.
636
636
  *
637
- * @param {Object} input
638
- * @param {string} input.cacheName Name of the cache the responses belong to.
639
- * @param {string} input.request The Request for the cached entry.
637
+ * @param {Object} options
638
+ * @param {string} options.cacheName Name of the cache that was updated.
639
+ * @param {string} options.request The Request for the cached entry.
640
640
  *
641
641
  * @private
642
642
  */
@@ -735,6 +735,6 @@ this.workbox.expiration = (function (exports,DBWrapper_mjs,WorkboxError_mjs,asse
735
735
 
736
736
  return exports;
737
737
 
738
- }({},workbox.core._private,workbox.core._private,workbox.core._private,workbox.core._private,workbox.core._private,workbox.core._private));
738
+ }({},workbox.core._private,workbox.core._private,workbox.core._private,workbox.core._private,workbox.core._private,workbox.core));
739
739
 
740
740
  //# sourceMappingURL=workbox-cache-expiration.dev.js.map
@@ -1 +1 @@
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.4.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
+ {"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,index_mjs) {\n 'use strict';\n\n try {\n self.workbox.v['workbox:cache-expiration:3.6.2'] = 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 index_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} options\n * @param {string} options.cacheName Name of the cache the response is in.\n * @param {Response} options.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} options\n * @param {string} options.cacheName Name of the cache that was updated.\n * @param {string} options.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));\n"],"file":"workbox-cache-expiration.dev.js"}
@@ -1,3 +1,3 @@
1
- this.workbox=this.workbox||{},this.workbox.expiration=function(e,t,r,n,i){"use strict";try{self.workbox.v["workbox:cache-expiration:3.4.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);
1
+ this.workbox=this.workbox||{},this.workbox.expiration=function(e,t,r,n,i){"use strict";try{self.workbox.v["workbox:cache-expiration:3.6.2"]=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);
2
2
 
3
3
  //# sourceMappingURL=workbox-cache-expiration.prod.js.map
@@ -1 +1 @@
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.4.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
+ {"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.6.2\"]=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);\n"],"file":"workbox-cache-expiration.prod.js"}
@@ -3,7 +3,7 @@ this.workbox.cacheableResponse = (function (exports,WorkboxError_mjs,assert_mjs,
3
3
  'use strict';
4
4
 
5
5
  try {
6
- self.workbox.v['workbox:cacheable-response:3.4.1'] = 1;
6
+ self.workbox.v['workbox:cacheable-response:3.6.2'] = 1;
7
7
  } catch (e) {} // eslint-disable-line
8
8
 
9
9
  /*
@@ -1 +1 @@
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.4.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
+ {"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.6.2'] = 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 +1,3 @@
1
- this.workbox=this.workbox||{},this.workbox.cacheableResponse=function(t){"use strict";try{self.workbox.v["workbox:cacheable-response:3.4.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}({});
1
+ this.workbox=this.workbox||{},this.workbox.cacheableResponse=function(t){"use strict";try{self.workbox.v["workbox:cacheable-response:3.6.2"]=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
2
 
3
3
  //# sourceMappingURL=workbox-cacheable-response.prod.js.map
@@ -1 +1 @@
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.4.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
+ {"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.6.2\"]=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"}
@@ -40,7 +40,7 @@ this.workbox.core = (function () {
40
40
  'use strict';
41
41
 
42
42
  try {
43
- self.workbox.v['workbox:core:3.4.1'] = 1;
43
+ self.workbox.v['workbox:core:3.6.2'] = 1;
44
44
  } catch (e) {} // eslint-disable-line
45
45
 
46
46
  /*
@@ -97,6 +97,84 @@ this.workbox.core = (function () {
97
97
  limitations under the License.
98
98
  */
99
99
 
100
+ // Safari doesn't print all console.groupCollapsed() arguments.
101
+ // Related bug: https://bugs.webkit.org/show_bug.cgi?id=182754
102
+ const isSafari = /^((?!chrome|android).)*safari/i.test(navigator.userAgent);
103
+
104
+ const GREY = `#7f8c8d`;
105
+ const GREEN = `#2ecc71`;
106
+ const YELLOW = `#f39c12`;
107
+ const RED = `#c0392b`;
108
+ const BLUE = `#3498db`;
109
+
110
+ const getDefaultLogLevel = () => LOG_LEVELS.log;
111
+
112
+ let logLevel = getDefaultLogLevel();
113
+ const shouldPrint = minLevel => logLevel <= minLevel;
114
+ const setLoggerLevel = newLogLevel => logLevel = newLogLevel;
115
+ const getLoggerLevel = () => logLevel;
116
+
117
+ // We always want groups to be logged unless logLevel is silent.
118
+ const groupLevel = LOG_LEVELS.error;
119
+
120
+ const _print = function (keyName, logArgs, levelColor) {
121
+ const logLevel = keyName.indexOf('group') === 0 ? groupLevel : LOG_LEVELS[keyName];
122
+ if (!shouldPrint(logLevel)) {
123
+ return;
124
+ }
125
+
126
+ if (!levelColor || keyName === 'groupCollapsed' && isSafari) {
127
+ console[keyName](...logArgs);
128
+ return;
129
+ }
130
+
131
+ const logPrefix = ['%cworkbox', `background: ${levelColor}; color: white; padding: 2px 0.5em; ` + `border-radius: 0.5em;`];
132
+ console[keyName](...logPrefix, ...logArgs);
133
+ };
134
+
135
+ const groupEnd = () => {
136
+ if (shouldPrint(groupLevel)) {
137
+ console.groupEnd();
138
+ }
139
+ };
140
+
141
+ const defaultExport = {
142
+ groupEnd,
143
+ unprefixed: {
144
+ groupEnd
145
+ }
146
+ };
147
+
148
+ const setupLogs = (keyName, color) => {
149
+ defaultExport[keyName] = (...args) => _print(keyName, args, color);
150
+ defaultExport.unprefixed[keyName] = (...args) => _print(keyName, args);
151
+ };
152
+
153
+ const levelToColor = {
154
+ debug: GREY,
155
+ log: GREEN,
156
+ warn: YELLOW,
157
+ error: RED,
158
+ groupCollapsed: BLUE
159
+ };
160
+ Object.keys(levelToColor).forEach(keyName => setupLogs(keyName, levelToColor[keyName]));
161
+
162
+ /*
163
+ Copyright 2017 Google Inc.
164
+
165
+ Licensed under the Apache License, Version 2.0 (the "License");
166
+ you may not use this file except in compliance with the License.
167
+ You may obtain a copy of the License at
168
+
169
+ https://www.apache.org/licenses/LICENSE-2.0
170
+
171
+ Unless required by applicable law or agreed to in writing, software
172
+ distributed under the License is distributed on an "AS IS" BASIS,
173
+ WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
174
+ See the License for the specific language governing permissions and
175
+ limitations under the License.
176
+ */
177
+
100
178
  var messages = {
101
179
  'invalid-value': ({ paramName, validValueDescription, value }) => {
102
180
  if (!paramName || !validValueDescription) {
@@ -351,131 +429,6 @@ this.workbox.core = (function () {
351
429
  limitations under the License.
352
430
  */
353
431
 
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
432
  /*
480
433
  * This method returns true if the current context is a service worker.
481
434
  */
@@ -502,315 +455,119 @@ this.workbox.core = (function () {
502
455
  }
503
456
  };
504
457
 
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
- }
458
+ const hasMethod = (object, expectedMethod, { moduleName, className, funcName, paramName }) => {
459
+ const type = typeof object[expectedMethod];
460
+ if (type !== 'function') {
461
+ throw new WorkboxError('missing-a-method', { paramName, expectedMethod,
462
+ moduleName, className, funcName });
463
+ }
464
+ };
753
465
 
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
- }
466
+ const isType = (object, expectedType, { moduleName, className, funcName, paramName }) => {
467
+ if (typeof object !== expectedType) {
468
+ throw new WorkboxError('incorrect-type', { paramName, expectedType,
469
+ moduleName, className, funcName });
470
+ }
471
+ };
760
472
 
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
- }
473
+ const isInstance = (object, expectedClass, { moduleName, className, funcName,
474
+ paramName, isReturnValueProblem }) => {
475
+ if (!(object instanceof expectedClass)) {
476
+ throw new WorkboxError('incorrect-class', { paramName, expectedClass,
477
+ moduleName, className, funcName, isReturnValueProblem });
478
+ }
479
+ };
768
480
 
769
- cacheNames.updateDetails(details);
481
+ const isOneOf = (value, validValues, { paramName }) => {
482
+ if (!validValues.includes(value)) {
483
+ throw new WorkboxError('invalid-value', {
484
+ paramName,
485
+ value,
486
+ validValueDescription: `Valid values are ${JSON.stringify(validValues)}.`
487
+ });
770
488
  }
489
+ };
771
490
 
772
- /**
773
- * Get the current log level.
774
- *
775
- * @return {number}.
776
- *
777
- * @alias workbox.core.logLevel
778
- */
779
- get logLevel() {
780
- return getLoggerLevel();
491
+ const isArrayOfClass = (value, expectedClass, { moduleName, className, funcName, paramName }) => {
492
+ const error = new WorkboxError('not-array-of-class', {
493
+ value, expectedClass,
494
+ moduleName, className, funcName, paramName
495
+ });
496
+ if (!Array.isArray(value)) {
497
+ throw error;
781
498
  }
782
499
 
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) {
500
+ for (let item of value) {
501
+ if (!(item instanceof expectedClass)) {
502
+ throw error;
503
+ }
504
+ }
505
+ };
506
+
507
+ const finalAssertExports = {
508
+ hasMethod,
509
+ isArray,
510
+ isInstance,
511
+ isOneOf,
512
+ isSwEnv,
513
+ isType,
514
+ isArrayOfClass
515
+ };
516
+
517
+ /**
518
+ * Runs all of the callback functions, one at a time sequentially, in the order
519
+ * in which they were registered.
520
+ *
521
+ * @memberof workbox.core
522
+ * @private
523
+ */
524
+ let executeQuotaErrorCallbacks = (() => {
525
+ var _ref = babelHelpers.asyncToGenerator(function* () {
792
526
  {
793
- finalAssertExports.isType(newLevel, 'number', {
794
- moduleName: 'workbox-core',
795
- className: 'WorkboxCore',
796
- funcName: 'logLevel [setter]',
797
- paramName: `logLevel`
798
- });
527
+ defaultExport.log(`About to run ${callbacks.size} callbacks to clean up caches.`);
799
528
  }
800
529
 
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
- });
530
+ for (const callback of callbacks) {
531
+ yield callback();
532
+ {
533
+ defaultExport.log(callback, 'is complete.');
534
+ }
807
535
  }
808
536
 
809
- setLoggerLevel(newLevel);
537
+ {
538
+ defaultExport.log('Finished running callbacks.');
539
+ }
540
+ });
541
+
542
+ return function executeQuotaErrorCallbacks() {
543
+ return _ref.apply(this, arguments);
544
+ };
545
+ })();
546
+
547
+ const callbacks = new Set();
548
+
549
+ /**
550
+ * Adds a function to the set of callbacks that will be executed when there's
551
+ * a quota error.
552
+ *
553
+ * @param {Function} callback
554
+ * @memberof workbox.core
555
+ */
556
+ function registerQuotaErrorCallback(callback) {
557
+ {
558
+ finalAssertExports.isType(callback, 'function', {
559
+ moduleName: 'workbox-core',
560
+ funcName: 'register',
561
+ paramName: 'callback'
562
+ });
810
563
  }
811
- }
812
564
 
813
- var defaultExport$1 = new WorkboxCore();
565
+ callbacks.add(callback);
566
+
567
+ {
568
+ defaultExport.log('Registered a callback to respond to quota errors.', callback);
569
+ }
570
+ }
814
571
 
815
572
  /*
816
573
  Copyright 2017 Google Inc.
@@ -1206,6 +963,53 @@ this.workbox.core = (function () {
1206
963
  limitations under the License.
1207
964
  */
1208
965
 
966
+ const _cacheNameDetails = {
967
+ prefix: 'workbox',
968
+ suffix: self.registration.scope,
969
+ googleAnalytics: 'googleAnalytics',
970
+ precache: 'precache',
971
+ runtime: 'runtime'
972
+ };
973
+
974
+ const _createCacheName = cacheName => {
975
+ return [_cacheNameDetails.prefix, cacheName, _cacheNameDetails.suffix].filter(value => value.length > 0).join('-');
976
+ };
977
+
978
+ const cacheNames = {
979
+ updateDetails: details => {
980
+ Object.keys(_cacheNameDetails).forEach(key => {
981
+ if (typeof details[key] !== 'undefined') {
982
+ _cacheNameDetails[key] = details[key];
983
+ }
984
+ });
985
+ },
986
+ getGoogleAnalyticsName: userCacheName => {
987
+ return userCacheName || _createCacheName(_cacheNameDetails.googleAnalytics);
988
+ },
989
+ getPrecacheName: userCacheName => {
990
+ return userCacheName || _createCacheName(_cacheNameDetails.precache);
991
+ },
992
+ getRuntimeName: userCacheName => {
993
+ return userCacheName || _createCacheName(_cacheNameDetails.runtime);
994
+ }
995
+ };
996
+
997
+ /*
998
+ Copyright 2017 Google Inc.
999
+
1000
+ Licensed under the Apache License, Version 2.0 (the "License");
1001
+ you may not use this file except in compliance with the License.
1002
+ You may obtain a copy of the License at
1003
+
1004
+ https://www.apache.org/licenses/LICENSE-2.0
1005
+
1006
+ Unless required by applicable law or agreed to in writing, software
1007
+ distributed under the License is distributed on an "AS IS" BASIS,
1008
+ WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
1009
+ See the License for the specific language governing permissions and
1010
+ limitations under the License.
1011
+ */
1012
+
1209
1013
  var pluginEvents = {
1210
1014
  CACHE_DID_UPDATE: 'cacheDidUpdate',
1211
1015
  CACHE_WILL_UPDATE: 'cacheWillUpdate',
@@ -1231,65 +1035,10 @@ this.workbox.core = (function () {
1231
1035
  */
1232
1036
 
1233
1037
  var pluginUtils = {
1234
- filter: (plugins, callbackname) => {
1235
- return plugins.filter(plugin => callbackname in plugin);
1236
- }
1237
- };
1238
-
1239
- /**
1240
- * Runs all of the callback functions, one at a time sequentially, in the order
1241
- * in which they were registered.
1242
- *
1243
- * @memberof workbox.core
1244
- * @private
1245
- */
1246
- let executeQuotaErrorCallbacks = (() => {
1247
- var _ref = babelHelpers.asyncToGenerator(function* () {
1248
- {
1249
- defaultExport.log(`About to run ${callbacks.size} callbacks to clean up caches.`);
1250
- }
1251
-
1252
- for (const callback of callbacks) {
1253
- yield callback();
1254
- {
1255
- defaultExport.log(callback, 'is complete.');
1256
- }
1257
- }
1258
-
1259
- {
1260
- defaultExport.log('Finished running callbacks.');
1261
- }
1262
- });
1263
-
1264
- return function executeQuotaErrorCallbacks() {
1265
- return _ref.apply(this, arguments);
1266
- };
1267
- })();
1268
-
1269
- const callbacks = new Set();
1270
-
1271
- /**
1272
- * Adds a function to the set of callbacks that will be executed when there's
1273
- * a quota error.
1274
- *
1275
- * @param {Function} callback
1276
- * @memberof workbox.core
1277
- */
1278
- function registerQuotaErrorCallback(callback) {
1279
- {
1280
- finalAssertExports.isType(callback, 'function', {
1281
- moduleName: 'workbox-core',
1282
- funcName: 'register',
1283
- paramName: 'callback'
1284
- });
1285
- }
1286
-
1287
- callbacks.add(callback);
1288
-
1289
- {
1290
- defaultExport.log('Registered a callback to respond to quota errors.', callback);
1038
+ filter: (plugins, callbackname) => {
1039
+ return plugins.filter(plugin => callbackname in plugin);
1291
1040
  }
1292
- }
1041
+ };
1293
1042
 
1294
1043
  /*
1295
1044
  Copyright 2017 Google Inc.
@@ -1336,16 +1085,24 @@ this.workbox.core = (function () {
1336
1085
  *
1337
1086
  * Will call `cacheDidUpdate` on plugins if the cache was updated.
1338
1087
  *
1339
- * @param {string} cacheName
1340
- * @param {Request} request
1341
- * @param {Response} response
1342
- * @param {Array<Object>} [plugins]
1088
+ * @param {Object} options
1089
+ * @param {string} options.cacheName
1090
+ * @param {Request} options.request
1091
+ * @param {Response} options.response
1092
+ * @param {Event} [options.event]
1093
+ * @param {Array<Object>} [options.plugins=[]]
1343
1094
  *
1344
1095
  * @private
1345
1096
  * @memberof module:workbox-core
1346
1097
  */
1347
1098
  const putWrapper = (() => {
1348
- var _ref = babelHelpers.asyncToGenerator(function* (cacheName, request, response, plugins = []) {
1099
+ var _ref = babelHelpers.asyncToGenerator(function* ({
1100
+ cacheName,
1101
+ request,
1102
+ response,
1103
+ event,
1104
+ plugins = []
1105
+ } = {}) {
1349
1106
  if (!response) {
1350
1107
  {
1351
1108
  defaultExport.error(`Cannot cache non-existent response for ` + `'${getFriendlyURL(request.url)}'.`);
@@ -1356,7 +1113,7 @@ this.workbox.core = (function () {
1356
1113
  });
1357
1114
  }
1358
1115
 
1359
- let responseToCache = yield _isResponseSafeToCache(request, response, plugins);
1116
+ let responseToCache = yield _isResponseSafeToCache({ request, response, event, plugins });
1360
1117
 
1361
1118
  if (!responseToCache) {
1362
1119
  {
@@ -1378,7 +1135,7 @@ this.workbox.core = (function () {
1378
1135
 
1379
1136
  const updatePlugins = pluginUtils.filter(plugins, pluginEvents.CACHE_DID_UPDATE);
1380
1137
 
1381
- let oldResponse = updatePlugins.length > 0 ? yield matchWrapper(cacheName, request) : null;
1138
+ let oldResponse = updatePlugins.length > 0 ? yield matchWrapper({ cacheName, request }) : null;
1382
1139
 
1383
1140
  {
1384
1141
  defaultExport.debug(`Updating the '${cacheName}' cache with a new Response for ` + `${getFriendlyURL(request.url)}.`);
@@ -1398,13 +1155,14 @@ this.workbox.core = (function () {
1398
1155
  yield plugin[pluginEvents.CACHE_DID_UPDATE].call(plugin, {
1399
1156
  cacheName,
1400
1157
  request,
1158
+ event,
1401
1159
  oldResponse,
1402
1160
  newResponse: responseToCache
1403
1161
  });
1404
1162
  }
1405
1163
  });
1406
1164
 
1407
- return function putWrapper(_x, _x2, _x3) {
1165
+ return function putWrapper() {
1408
1166
  return _ref.apply(this, arguments);
1409
1167
  };
1410
1168
  })();
@@ -1412,18 +1170,25 @@ this.workbox.core = (function () {
1412
1170
  /**
1413
1171
  * This is a wrapper around cache.match().
1414
1172
  *
1415
- * @param {string} cacheName Name of the cache to match against.
1416
- * @param {Request} request The Request that will be used to look up cache
1417
- * entries.
1418
- * @param {Object} matchOptions Options passed to cache.match().
1419
- * @param {Array<Object>} [plugins] Array of plugins.
1173
+ * @param {Object} options
1174
+ * @param {string} options.cacheName Name of the cache to match against.
1175
+ * @param {Request} options.request The Request that will be used to look up
1176
+ *. cache entries.
1177
+ * @param {Event} [options.event] The event that propted the action.
1178
+ * @param {Object} [options.matchOptions] Options passed to cache.match().
1179
+ * @param {Array<Object>} [options.plugins=[]] Array of plugins.
1420
1180
  * @return {Response} A cached response if available.
1421
1181
  *
1422
1182
  * @private
1423
1183
  * @memberof module:workbox-core
1424
1184
  */
1425
1185
  const matchWrapper = (() => {
1426
- var _ref2 = babelHelpers.asyncToGenerator(function* (cacheName, request, matchOptions, plugins = []) {
1186
+ var _ref2 = babelHelpers.asyncToGenerator(function* ({
1187
+ cacheName,
1188
+ request,
1189
+ event,
1190
+ matchOptions,
1191
+ plugins = [] }) {
1427
1192
  const cache = yield caches.open(cacheName);
1428
1193
  let cachedResponse = yield cache.match(request, matchOptions);
1429
1194
  {
@@ -1438,6 +1203,7 @@ this.workbox.core = (function () {
1438
1203
  cachedResponse = yield plugin[pluginEvents.CACHED_RESPONSE_WILL_BE_USED].call(plugin, {
1439
1204
  cacheName,
1440
1205
  request,
1206
+ event,
1441
1207
  matchOptions,
1442
1208
  cachedResponse
1443
1209
  });
@@ -1455,7 +1221,7 @@ this.workbox.core = (function () {
1455
1221
  return cachedResponse;
1456
1222
  });
1457
1223
 
1458
- return function matchWrapper(_x4, _x5, _x6) {
1224
+ return function matchWrapper(_x) {
1459
1225
  return _ref2.apply(this, arguments);
1460
1226
  };
1461
1227
  })();
@@ -1464,16 +1230,18 @@ this.workbox.core = (function () {
1464
1230
  * This method will call cacheWillUpdate on the available plugins (or use
1465
1231
  * response.ok) to determine if the Response is safe and valid to cache.
1466
1232
  *
1467
- * @param {Request} request
1468
- * @param {Response} response
1469
- * @param {Array<Object>} plugins
1233
+ * @param {Object} options
1234
+ * @param {Request} options.request
1235
+ * @param {Response} options.response
1236
+ * @param {Event} [options.event]
1237
+ * @param {Array<Object>} [options.plugins=[]]
1470
1238
  * @return {Promise<Response>}
1471
1239
  *
1472
1240
  * @private
1473
1241
  * @memberof module:workbox-core
1474
1242
  */
1475
1243
  const _isResponseSafeToCache = (() => {
1476
- var _ref3 = babelHelpers.asyncToGenerator(function* (request, response, plugins) {
1244
+ var _ref3 = babelHelpers.asyncToGenerator(function* ({ request, response, event, plugins }) {
1477
1245
  let responseToCache = response;
1478
1246
  let pluginsUsed = false;
1479
1247
  for (let plugin of plugins) {
@@ -1481,7 +1249,8 @@ this.workbox.core = (function () {
1481
1249
  pluginsUsed = true;
1482
1250
  responseToCache = yield plugin[pluginEvents.CACHE_WILL_UPDATE].call(plugin, {
1483
1251
  request,
1484
- response: responseToCache
1252
+ response: responseToCache,
1253
+ event
1485
1254
  });
1486
1255
 
1487
1256
  {
@@ -1516,7 +1285,7 @@ this.workbox.core = (function () {
1516
1285
  return responseToCache ? responseToCache : null;
1517
1286
  });
1518
1287
 
1519
- return function _isResponseSafeToCache(_x7, _x8, _x9) {
1288
+ return function _isResponseSafeToCache(_x2) {
1520
1289
  return _ref3.apply(this, arguments);
1521
1290
  };
1522
1291
  })();
@@ -1547,22 +1316,27 @@ this.workbox.core = (function () {
1547
1316
  *
1548
1317
  * Will call requestWillFetch on available plugins.
1549
1318
  *
1550
- * @param {Request|string} request
1551
- * @param {Object} fetchOptions
1552
- * @param {Array<Object>} [plugins]
1553
- * @param {Promise<Response>} [preloadResponse]
1319
+ * @param {Object} options
1320
+ * @param {Request|string} options.request
1321
+ * @param {Object} [options.fetchOptions]
1322
+ * @param {Event} [options.event]
1323
+ * @param {Array<Object>} [options.plugins=[]]
1554
1324
  * @return {Promise<Response>}
1555
1325
  *
1556
1326
  * @private
1557
1327
  * @memberof module:workbox-core
1558
1328
  */
1559
1329
  const wrappedFetch = (() => {
1560
- var _ref = babelHelpers.asyncToGenerator(function* (request, fetchOptions, plugins = [], preloadResponse) {
1561
- // We *should* be able to call `await preloadResponse` even if it's undefined,
1562
- // but for some reason, doing so leads to errors in our Node unit tests.
1563
- // To work around that, explicitly check preloadResponse's value first.
1564
- if (preloadResponse) {
1565
- const possiblePreloadResponse = yield preloadResponse;
1330
+ var _ref = babelHelpers.asyncToGenerator(function* ({
1331
+ request,
1332
+ fetchOptions,
1333
+ event,
1334
+ plugins = [] }) {
1335
+ // We *should* be able to call `await event.preloadResponse` even if it's
1336
+ // undefined, but for some reason, doing so leads to errors in our Node unit
1337
+ // tests. To work around that, explicitly check preloadResponse's value first.
1338
+ if (event && event.preloadResponse) {
1339
+ const possiblePreloadResponse = yield event.preloadResponse;
1566
1340
  if (possiblePreloadResponse) {
1567
1341
  {
1568
1342
  defaultExport.log(`Using a preloaded navigation response for ` + `'${getFriendlyURL(request.url)}'`);
@@ -1596,7 +1370,8 @@ this.workbox.core = (function () {
1596
1370
  for (let plugin of plugins) {
1597
1371
  if (pluginEvents.REQUEST_WILL_FETCH in plugin) {
1598
1372
  request = yield plugin[pluginEvents.REQUEST_WILL_FETCH].call(plugin, {
1599
- request: request.clone()
1373
+ request: request.clone(),
1374
+ event
1600
1375
  });
1601
1376
 
1602
1377
  {
@@ -1635,6 +1410,7 @@ this.workbox.core = (function () {
1635
1410
  for (let plugin of failedFetchPlugins) {
1636
1411
  yield plugin[pluginEvents.FETCH_DID_FAIL].call(plugin, {
1637
1412
  error,
1413
+ event,
1638
1414
  originalRequest: originalRequest.clone(),
1639
1415
  request: pluginFilteredRequest.clone()
1640
1416
  });
@@ -1644,7 +1420,7 @@ this.workbox.core = (function () {
1644
1420
  }
1645
1421
  });
1646
1422
 
1647
- return function wrappedFetch(_x, _x2) {
1423
+ return function wrappedFetch(_x) {
1648
1424
  return _ref.apply(this, arguments);
1649
1425
  };
1650
1426
  })();
@@ -1677,8 +1453,7 @@ this.workbox.core = (function () {
1677
1453
  cacheWrapper: cacheWrapper,
1678
1454
  fetchWrapper: fetchWrapper,
1679
1455
  getFriendlyURL: getFriendlyURL,
1680
- logger: defaultExport,
1681
- registerQuotaErrorCallback: registerQuotaErrorCallback
1456
+ logger: defaultExport
1682
1457
  });
1683
1458
 
1684
1459
  /*
@@ -1697,9 +1472,261 @@ this.workbox.core = (function () {
1697
1472
  limitations under the License.
1698
1473
  */
1699
1474
 
1475
+ /**
1476
+ * Logs a warning to the user recommending changing
1477
+ * to max-age=0 or no-cache.
1478
+ *
1479
+ * @param {string} cacheControlHeader
1480
+ *
1481
+ * @private
1482
+ */
1483
+ function showWarning(cacheControlHeader) {
1484
+ const docsUrl = 'https://developers.google.com/web/tools/workbox/guides/service-worker-checklist#cache-control_of_your_service_worker_file';
1485
+ 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}`);
1486
+ }
1487
+
1488
+ /**
1489
+ * Checks for cache-control header on SW file and
1490
+ * warns the developer if it exists with a value
1491
+ * other than max-age=0 or no-cache.
1492
+ *
1493
+ * @return {Promise}
1494
+ * @private
1495
+ */
1496
+ function checkSWFileCacheHeaders() {
1497
+ // This is wrapped as an iife to allow async/await while making
1498
+ // rollup exclude it in builds.
1499
+ return babelHelpers.asyncToGenerator(function* () {
1500
+ try {
1501
+ const swFile = self.location.href;
1502
+ const response = yield fetch(swFile);
1503
+ if (!response.ok) {
1504
+ // Response failed so nothing we can check;
1505
+ return;
1506
+ }
1507
+
1508
+ if (!response.headers.has('cache-control')) {
1509
+ // No cache control header.
1510
+ return;
1511
+ }
1512
+
1513
+ const cacheControlHeader = response.headers.get('cache-control');
1514
+ const maxAgeResult = /max-age\s*=\s*(\d*)/g.exec(cacheControlHeader);
1515
+ if (maxAgeResult) {
1516
+ if (parseInt(maxAgeResult[1], 10) === 0) {
1517
+ return;
1518
+ }
1519
+ }
1520
+
1521
+ if (cacheControlHeader.indexOf('no-cache') !== -1) {
1522
+ return;
1523
+ }
1524
+
1525
+ if (cacheControlHeader.indexOf('no-store') !== -1) {
1526
+ return;
1527
+ }
1528
+
1529
+ showWarning(cacheControlHeader);
1530
+ } catch (err) {
1531
+ // NOOP
1532
+ }
1533
+ })();
1534
+ }
1535
+
1536
+ const finalCheckSWFileCacheHeaders = checkSWFileCacheHeaders;
1537
+
1538
+ /*
1539
+ Copyright 2017 Google Inc.
1540
+
1541
+ Licensed under the Apache License, Version 2.0 (the "License");
1542
+ you may not use this file except in compliance with the License.
1543
+ You may obtain a copy of the License at
1544
+
1545
+ https://www.apache.org/licenses/LICENSE-2.0
1546
+
1547
+ Unless required by applicable law or agreed to in writing, software
1548
+ distributed under the License is distributed on an "AS IS" BASIS,
1549
+ WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
1550
+ See the License for the specific language governing permissions and
1551
+ limitations under the License.
1552
+ */
1553
+
1554
+ /**
1555
+ * This class is never exposed publicly. Inidividual methods are exposed
1556
+ * using jsdoc alias commands.
1557
+ *
1558
+ * @memberof workbox.core
1559
+ * @private
1560
+ */
1561
+ class WorkboxCore {
1562
+ /**
1563
+ * You should not instantiate this object directly.
1564
+ *
1565
+ * @private
1566
+ */
1567
+ constructor() {
1568
+ // Give our version strings something to hang off of.
1569
+ try {
1570
+ self.workbox.v = self.workbox.v || {};
1571
+ } catch (err) {}
1572
+ // NOOP
1573
+
1574
+
1575
+ // A WorkboxCore instance must be exported before we can use the logger.
1576
+ // This is so it can get the current log level.
1577
+ {
1578
+ const padding = ' ';
1579
+ defaultExport.groupCollapsed('Welcome to Workbox!');
1580
+ 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}).`);
1581
+ defaultExport.unprefixed.log(`📖 Read the guides and documentation\n` + `${padding}https://developers.google.com/web/tools/workbox/`);
1582
+ defaultExport.unprefixed.log(`❓ Use the [workbox] tag on Stack Overflow to ask questions\n` + `${padding}https://stackoverflow.com/questions/ask?tags=workbox`);
1583
+ defaultExport.unprefixed.log(`🐛 Found a bug? Report it on GitHub\n` + `${padding}https://github.com/GoogleChrome/workbox/issues/new`);
1584
+ defaultExport.groupEnd();
1585
+
1586
+ if (typeof finalCheckSWFileCacheHeaders === 'function') {
1587
+ finalCheckSWFileCacheHeaders();
1588
+ }
1589
+ }
1590
+ }
1591
+
1592
+ /**
1593
+ * Get the current cache names used by Workbox.
1594
+ *
1595
+ * `cacheNames.precache` is used for precached assets,
1596
+ * `cacheNames.googleAnalytics` is used by `workbox-google-analytics` to
1597
+ * store `analytics.js`,
1598
+ * and `cacheNames.runtime` is used for everything else.
1599
+ *
1600
+ * @return {Object} An object with `precache` and `runtime` cache names.
1601
+ *
1602
+ * @alias workbox.core.cacheNames
1603
+ */
1604
+ get cacheNames() {
1605
+ return {
1606
+ googleAnalytics: cacheNames.getGoogleAnalyticsName(),
1607
+ precache: cacheNames.getPrecacheName(),
1608
+ runtime: cacheNames.getRuntimeName()
1609
+ };
1610
+ }
1611
+
1612
+ /**
1613
+ * You can alter the default cache names used by the Workbox modules by
1614
+ * changing the cache name details.
1615
+ *
1616
+ * Cache names are generated as `<prefix>-<Cache Name>-<suffix>`.
1617
+ *
1618
+ * @param {Object} details
1619
+ * @param {Object} details.prefix The string to add to the beginning of
1620
+ * the precache and runtime cache names.
1621
+ * @param {Object} details.suffix The string to add to the end of
1622
+ * the precache and runtime cache names.
1623
+ * @param {Object} details.precache The cache name to use for precache
1624
+ * caching.
1625
+ * @param {Object} details.runtime The cache name to use for runtime caching.
1626
+ * @param {Object} details.googleAnalytics The cache name to use for
1627
+ * `workbox-google-analytics` caching.
1628
+ *
1629
+ * @alias workbox.core.setCacheNameDetails
1630
+ */
1631
+ setCacheNameDetails(details) {
1632
+ {
1633
+ Object.keys(details).forEach(key => {
1634
+ finalAssertExports.isType(details[key], 'string', {
1635
+ moduleName: 'workbox-core',
1636
+ className: 'WorkboxCore',
1637
+ funcName: 'setCacheNameDetails',
1638
+ paramName: `details.${key}`
1639
+ });
1640
+ });
1641
+
1642
+ if ('precache' in details && details.precache.length === 0) {
1643
+ throw new WorkboxError('invalid-cache-name', {
1644
+ cacheNameId: 'precache',
1645
+ value: details.precache
1646
+ });
1647
+ }
1648
+
1649
+ if ('runtime' in details && details.runtime.length === 0) {
1650
+ throw new WorkboxError('invalid-cache-name', {
1651
+ cacheNameId: 'runtime',
1652
+ value: details.runtime
1653
+ });
1654
+ }
1655
+
1656
+ if ('googleAnalytics' in details && details.googleAnalytics.length === 0) {
1657
+ throw new WorkboxError('invalid-cache-name', {
1658
+ cacheNameId: 'googleAnalytics',
1659
+ value: details.googleAnalytics
1660
+ });
1661
+ }
1662
+ }
1663
+
1664
+ cacheNames.updateDetails(details);
1665
+ }
1666
+
1667
+ /**
1668
+ * Get the current log level.
1669
+ *
1670
+ * @return {number}.
1671
+ *
1672
+ * @alias workbox.core.logLevel
1673
+ */
1674
+ get logLevel() {
1675
+ return getLoggerLevel();
1676
+ }
1677
+
1678
+ /**
1679
+ * Set the current log level passing in one of the values from
1680
+ * [LOG_LEVELS]{@link module:workbox-core.LOG_LEVELS}.
1681
+ *
1682
+ * @param {number} newLevel The new log level to use.
1683
+ *
1684
+ * @alias workbox.core.setLogLevel
1685
+ */
1686
+ setLogLevel(newLevel) {
1687
+ {
1688
+ finalAssertExports.isType(newLevel, 'number', {
1689
+ moduleName: 'workbox-core',
1690
+ className: 'WorkboxCore',
1691
+ funcName: 'logLevel [setter]',
1692
+ paramName: `logLevel`
1693
+ });
1694
+ }
1695
+
1696
+ if (newLevel > LOG_LEVELS.silent || newLevel < LOG_LEVELS.debug) {
1697
+ throw new WorkboxError('invalid-value', {
1698
+ paramName: 'logLevel',
1699
+ validValueDescription: `Please use a value from LOG_LEVELS, i.e ` + `'logLevel = workbox.core.LOG_LEVELS.debug'.`,
1700
+ value: newLevel
1701
+ });
1702
+ }
1703
+
1704
+ setLoggerLevel(newLevel);
1705
+ }
1706
+ }
1707
+
1708
+ var defaultExport$1 = new WorkboxCore();
1709
+
1710
+ /*
1711
+ Copyright 2017 Google Inc.
1712
+
1713
+ Licensed under the Apache License, Version 2.0 (the "License");
1714
+ you may not use this file except in compliance with the License.
1715
+ You may obtain a copy of the License at
1716
+
1717
+ https://www.apache.org/licenses/LICENSE-2.0
1718
+
1719
+ Unless required by applicable law or agreed to in writing, software
1720
+ distributed under the License is distributed on an "AS IS" BASIS,
1721
+ WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
1722
+ See the License for the specific language governing permissions and
1723
+ limitations under the License.
1724
+ */
1725
+
1700
1726
  const finalExports = Object.assign(defaultExport$1, {
1727
+ _private,
1701
1728
  LOG_LEVELS,
1702
- _private
1729
+ registerQuotaErrorCallback
1703
1730
  });
1704
1731
 
1705
1732
  return finalExports;