jekyll-pwa-workbox 0.0.6 → 0.0.7.alpha

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (125) hide show
  1. checksums.yaml +4 -4
  2. data/lib/jekyll-pwa-workbox.rb +1 -1
  3. data/lib/vendor/workbox-v5.0.0.alpha1/workbox-background-sync.dev.js +819 -0
  4. data/lib/vendor/workbox-v5.0.0.alpha1/workbox-background-sync.dev.js.map +1 -0
  5. data/lib/vendor/workbox-v5.0.0.alpha1/workbox-background-sync.prod.js +2 -0
  6. data/lib/vendor/workbox-v5.0.0.alpha1/workbox-background-sync.prod.js.map +1 -0
  7. data/lib/vendor/workbox-v5.0.0.alpha1/workbox-broadcast-update.dev.js +486 -0
  8. data/lib/vendor/workbox-v5.0.0.alpha1/workbox-broadcast-update.dev.js.map +1 -0
  9. data/lib/vendor/workbox-v5.0.0.alpha1/workbox-broadcast-update.prod.js +2 -0
  10. data/lib/vendor/workbox-v5.0.0.alpha1/workbox-broadcast-update.prod.js.map +1 -0
  11. data/lib/vendor/workbox-v5.0.0.alpha1/workbox-cacheable-response.dev.js +192 -0
  12. data/lib/vendor/workbox-v5.0.0.alpha1/workbox-cacheable-response.dev.js.map +1 -0
  13. data/lib/vendor/workbox-v5.0.0.alpha1/workbox-cacheable-response.prod.js +2 -0
  14. data/lib/vendor/workbox-v5.0.0.alpha1/workbox-cacheable-response.prod.js.map +1 -0
  15. data/lib/vendor/workbox-v5.0.0.alpha1/workbox-core.dev.js +1643 -0
  16. data/lib/vendor/workbox-v5.0.0.alpha1/workbox-core.dev.js.map +1 -0
  17. data/lib/vendor/workbox-v5.0.0.alpha1/workbox-core.prod.js +2 -0
  18. data/lib/vendor/workbox-v5.0.0.alpha1/workbox-core.prod.js.map +1 -0
  19. data/lib/vendor/workbox-v5.0.0.alpha1/workbox-expiration.dev.js +652 -0
  20. data/lib/vendor/workbox-v5.0.0.alpha1/workbox-expiration.dev.js.map +1 -0
  21. data/lib/vendor/workbox-v5.0.0.alpha1/workbox-expiration.prod.js +2 -0
  22. data/lib/vendor/workbox-v5.0.0.alpha1/workbox-expiration.prod.js.map +1 -0
  23. data/lib/vendor/workbox-v5.0.0.alpha1/workbox-navigation-preload.dev.js +103 -0
  24. data/lib/vendor/workbox-v5.0.0.alpha1/workbox-navigation-preload.dev.js.map +1 -0
  25. data/lib/vendor/workbox-v5.0.0.alpha1/workbox-navigation-preload.prod.js +2 -0
  26. data/lib/vendor/workbox-v5.0.0.alpha1/workbox-navigation-preload.prod.js.map +1 -0
  27. data/lib/vendor/workbox-v5.0.0.alpha1/workbox-offline-ga.dev.js +236 -0
  28. data/lib/vendor/workbox-v5.0.0.alpha1/workbox-offline-ga.dev.js.map +1 -0
  29. data/lib/vendor/workbox-v5.0.0.alpha1/workbox-offline-ga.prod.js +2 -0
  30. data/lib/vendor/workbox-v5.0.0.alpha1/workbox-offline-ga.prod.js.map +1 -0
  31. data/lib/vendor/workbox-v5.0.0.alpha1/workbox-precaching.dev.js +994 -0
  32. data/lib/vendor/workbox-v5.0.0.alpha1/workbox-precaching.dev.js.map +1 -0
  33. data/lib/vendor/workbox-v5.0.0.alpha1/workbox-precaching.prod.js +2 -0
  34. data/lib/vendor/workbox-v5.0.0.alpha1/workbox-precaching.prod.js.map +1 -0
  35. data/lib/vendor/workbox-v5.0.0.alpha1/workbox-range-requests.dev.js +263 -0
  36. data/lib/vendor/workbox-v5.0.0.alpha1/workbox-range-requests.dev.js.map +1 -0
  37. data/lib/vendor/workbox-v5.0.0.alpha1/workbox-range-requests.prod.js +2 -0
  38. data/lib/vendor/workbox-v5.0.0.alpha1/workbox-range-requests.prod.js.map +1 -0
  39. data/lib/vendor/workbox-v5.0.0.alpha1/workbox-routing.dev.js +1026 -0
  40. data/lib/vendor/workbox-v5.0.0.alpha1/workbox-routing.dev.js.map +1 -0
  41. data/lib/vendor/workbox-v5.0.0.alpha1/workbox-routing.prod.js +2 -0
  42. data/lib/vendor/workbox-v5.0.0.alpha1/workbox-routing.prod.js.map +1 -0
  43. data/lib/vendor/workbox-v5.0.0.alpha1/workbox-strategies.dev.js +1127 -0
  44. data/lib/vendor/workbox-v5.0.0.alpha1/workbox-strategies.dev.js.map +1 -0
  45. data/lib/vendor/workbox-v5.0.0.alpha1/workbox-strategies.prod.js +2 -0
  46. data/lib/vendor/workbox-v5.0.0.alpha1/workbox-strategies.prod.js.map +1 -0
  47. data/lib/vendor/workbox-v5.0.0.alpha1/workbox-streams.dev.js +333 -0
  48. data/lib/vendor/workbox-v5.0.0.alpha1/workbox-streams.dev.js.map +1 -0
  49. data/lib/vendor/workbox-v5.0.0.alpha1/workbox-streams.prod.js +2 -0
  50. data/lib/vendor/workbox-v5.0.0.alpha1/workbox-streams.prod.js.map +1 -0
  51. data/lib/vendor/workbox-v5.0.0.alpha1/workbox-sw.js +2 -0
  52. data/lib/vendor/workbox-v5.0.0.alpha1/workbox-sw.js.map +1 -0
  53. data/lib/vendor/{workbox-v4.3.1 → workbox-v5.0.0.alpha1}/workbox-window.dev.es5.mjs +248 -262
  54. data/lib/vendor/workbox-v5.0.0.alpha1/workbox-window.dev.es5.mjs.map +1 -0
  55. data/lib/vendor/{workbox-v4.3.1 → workbox-v5.0.0.alpha1}/workbox-window.dev.mjs +234 -242
  56. data/lib/vendor/workbox-v5.0.0.alpha1/workbox-window.dev.mjs.map +1 -0
  57. data/lib/vendor/workbox-v5.0.0.alpha1/workbox-window.dev.umd.js +882 -0
  58. data/lib/vendor/workbox-v5.0.0.alpha1/workbox-window.dev.umd.js.map +1 -0
  59. data/lib/vendor/workbox-v5.0.0.alpha1/workbox-window.prod.es5.mjs +2 -0
  60. data/lib/vendor/workbox-v5.0.0.alpha1/workbox-window.prod.es5.mjs.map +1 -0
  61. data/lib/vendor/workbox-v5.0.0.alpha1/workbox-window.prod.mjs +2 -0
  62. data/lib/vendor/workbox-v5.0.0.alpha1/workbox-window.prod.mjs.map +1 -0
  63. data/lib/vendor/workbox-v5.0.0.alpha1/workbox-window.prod.umd.js +2 -0
  64. data/lib/vendor/workbox-v5.0.0.alpha1/workbox-window.prod.umd.js.map +1 -0
  65. metadata +75 -80
  66. data/lib/vendor/workbox-v4.3.1/workbox-background-sync.dev.js +0 -822
  67. data/lib/vendor/workbox-v4.3.1/workbox-background-sync.dev.js.map +0 -1
  68. data/lib/vendor/workbox-v4.3.1/workbox-background-sync.prod.js +0 -2
  69. data/lib/vendor/workbox-v4.3.1/workbox-background-sync.prod.js.map +0 -1
  70. data/lib/vendor/workbox-v4.3.1/workbox-broadcast-update.dev.js +0 -496
  71. data/lib/vendor/workbox-v4.3.1/workbox-broadcast-update.dev.js.map +0 -1
  72. data/lib/vendor/workbox-v4.3.1/workbox-broadcast-update.prod.js +0 -2
  73. data/lib/vendor/workbox-v4.3.1/workbox-broadcast-update.prod.js.map +0 -1
  74. data/lib/vendor/workbox-v4.3.1/workbox-cacheable-response.dev.js +0 -200
  75. data/lib/vendor/workbox-v4.3.1/workbox-cacheable-response.dev.js.map +0 -1
  76. data/lib/vendor/workbox-v4.3.1/workbox-cacheable-response.prod.js +0 -2
  77. data/lib/vendor/workbox-v4.3.1/workbox-cacheable-response.prod.js.map +0 -1
  78. data/lib/vendor/workbox-v4.3.1/workbox-core.dev.js +0 -1712
  79. data/lib/vendor/workbox-v4.3.1/workbox-core.dev.js.map +0 -1
  80. data/lib/vendor/workbox-v4.3.1/workbox-core.prod.js +0 -2
  81. data/lib/vendor/workbox-v4.3.1/workbox-core.prod.js.map +0 -1
  82. data/lib/vendor/workbox-v4.3.1/workbox-expiration.dev.js +0 -652
  83. data/lib/vendor/workbox-v4.3.1/workbox-expiration.dev.js.map +0 -1
  84. data/lib/vendor/workbox-v4.3.1/workbox-expiration.prod.js +0 -2
  85. data/lib/vendor/workbox-v4.3.1/workbox-expiration.prod.js.map +0 -1
  86. data/lib/vendor/workbox-v4.3.1/workbox-navigation-preload.dev.js +0 -110
  87. data/lib/vendor/workbox-v4.3.1/workbox-navigation-preload.dev.js.map +0 -1
  88. data/lib/vendor/workbox-v4.3.1/workbox-navigation-preload.prod.js +0 -2
  89. data/lib/vendor/workbox-v4.3.1/workbox-navigation-preload.prod.js.map +0 -1
  90. data/lib/vendor/workbox-v4.3.1/workbox-offline-ga.dev.js +0 -243
  91. data/lib/vendor/workbox-v4.3.1/workbox-offline-ga.dev.js.map +0 -1
  92. data/lib/vendor/workbox-v4.3.1/workbox-offline-ga.prod.js +0 -2
  93. data/lib/vendor/workbox-v4.3.1/workbox-offline-ga.prod.js.map +0 -1
  94. data/lib/vendor/workbox-v4.3.1/workbox-precaching.dev.js +0 -989
  95. data/lib/vendor/workbox-v4.3.1/workbox-precaching.dev.js.map +0 -1
  96. data/lib/vendor/workbox-v4.3.1/workbox-precaching.prod.js +0 -2
  97. data/lib/vendor/workbox-v4.3.1/workbox-precaching.prod.js.map +0 -1
  98. data/lib/vendor/workbox-v4.3.1/workbox-range-requests.dev.js +0 -268
  99. data/lib/vendor/workbox-v4.3.1/workbox-range-requests.dev.js.map +0 -1
  100. data/lib/vendor/workbox-v4.3.1/workbox-range-requests.prod.js +0 -2
  101. data/lib/vendor/workbox-v4.3.1/workbox-range-requests.prod.js.map +0 -1
  102. data/lib/vendor/workbox-v4.3.1/workbox-routing.dev.js +0 -1020
  103. data/lib/vendor/workbox-v4.3.1/workbox-routing.dev.js.map +0 -1
  104. data/lib/vendor/workbox-v4.3.1/workbox-routing.prod.js +0 -2
  105. data/lib/vendor/workbox-v4.3.1/workbox-routing.prod.js.map +0 -1
  106. data/lib/vendor/workbox-v4.3.1/workbox-strategies.dev.js +0 -1138
  107. data/lib/vendor/workbox-v4.3.1/workbox-strategies.dev.js.map +0 -1
  108. data/lib/vendor/workbox-v4.3.1/workbox-strategies.prod.js +0 -2
  109. data/lib/vendor/workbox-v4.3.1/workbox-strategies.prod.js.map +0 -1
  110. data/lib/vendor/workbox-v4.3.1/workbox-streams.dev.js +0 -337
  111. data/lib/vendor/workbox-v4.3.1/workbox-streams.dev.js.map +0 -1
  112. data/lib/vendor/workbox-v4.3.1/workbox-streams.prod.js +0 -2
  113. data/lib/vendor/workbox-v4.3.1/workbox-streams.prod.js.map +0 -1
  114. data/lib/vendor/workbox-v4.3.1/workbox-sw.js +0 -2
  115. data/lib/vendor/workbox-v4.3.1/workbox-sw.js.map +0 -1
  116. data/lib/vendor/workbox-v4.3.1/workbox-window.dev.es5.mjs.map +0 -1
  117. data/lib/vendor/workbox-v4.3.1/workbox-window.dev.mjs.map +0 -1
  118. data/lib/vendor/workbox-v4.3.1/workbox-window.dev.umd.js +0 -896
  119. data/lib/vendor/workbox-v4.3.1/workbox-window.dev.umd.js.map +0 -1
  120. data/lib/vendor/workbox-v4.3.1/workbox-window.prod.es5.mjs +0 -2
  121. data/lib/vendor/workbox-v4.3.1/workbox-window.prod.es5.mjs.map +0 -1
  122. data/lib/vendor/workbox-v4.3.1/workbox-window.prod.mjs +0 -2
  123. data/lib/vendor/workbox-v4.3.1/workbox-window.prod.mjs.map +0 -1
  124. data/lib/vendor/workbox-v4.3.1/workbox-window.prod.umd.js +0 -2
  125. data/lib/vendor/workbox-v4.3.1/workbox-window.prod.umd.js.map +0 -1
@@ -1 +0,0 @@
1
- {"version":3,"file":"workbox-expiration.dev.js","sources":["../_version.mjs","../models/CacheTimestampsModel.mjs","../CacheExpiration.mjs","../Plugin.mjs","../index.mjs"],"sourcesContent":["try{self['workbox:expiration:4.3.1']&&_()}catch(e){}// eslint-disable-line","/*\n Copyright 2018 Google LLC\n\n Use of this source code is governed by an MIT-style\n license that can be found in the LICENSE file or at\n https://opensource.org/licenses/MIT.\n*/\n\nimport {DBWrapper} from 'workbox-core/_private/DBWrapper.mjs';\nimport {deleteDatabase} from 'workbox-core/_private/deleteDatabase.mjs';\nimport '../_version.mjs';\n\n\nconst DB_NAME = 'workbox-expiration';\nconst OBJECT_STORE_NAME = 'cache-entries';\n\nconst normalizeURL = (unNormalizedUrl) => {\n const url = new URL(unNormalizedUrl, location);\n url.hash = '';\n\n return url.href;\n};\n\n\n/**\n * Returns the timestamp model.\n *\n * @private\n */\nclass CacheTimestampsModel {\n /**\n *\n * @param {string} cacheName\n *\n * @private\n */\n constructor(cacheName) {\n this._cacheName = cacheName;\n\n this._db = new DBWrapper(DB_NAME, 1, {\n onupgradeneeded: (event) => this._handleUpgrade(event),\n });\n }\n\n /**\n * Should perform an upgrade of indexedDB.\n *\n * @param {Event} event\n *\n * @private\n */\n _handleUpgrade(event) {\n const db = event.target.result;\n\n // TODO(philipwalton): EdgeHTML doesn't support arrays as a keyPath, so we\n // have to use the `id` keyPath here and create our own values (a\n // concatenation of `url + cacheName`) instead of simply using\n // `keyPath: ['url', 'cacheName']`, which is supported in other browsers.\n const objStore = db.createObjectStore(OBJECT_STORE_NAME, {keyPath: 'id'});\n\n // TODO(philipwalton): once we don't have to support EdgeHTML, we can\n // create a single index with the keyPath `['cacheName', 'timestamp']`\n // instead of doing both these indexes.\n objStore.createIndex('cacheName', 'cacheName', {unique: false});\n objStore.createIndex('timestamp', 'timestamp', {unique: false});\n\n // Previous versions of `workbox-expiration` used `this._cacheName`\n // as the IDBDatabase name.\n deleteDatabase(this._cacheName);\n }\n\n /**\n * @param {string} url\n * @param {number} timestamp\n *\n * @private\n */\n async setTimestamp(url, timestamp) {\n url = normalizeURL(url);\n\n await this._db.put(OBJECT_STORE_NAME, {\n url,\n timestamp,\n cacheName: this._cacheName,\n // Creating an ID from the URL and cache name won't be necessary once\n // Edge switches to Chromium and all browsers we support work with\n // array keyPaths.\n id: this._getId(url),\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 async getTimestamp(url) {\n const entry = await this._db.get(OBJECT_STORE_NAME, this._getId(url));\n return entry.timestamp;\n }\n\n /**\n * Iterates through all the entries in the object store (from newest to\n * oldest) and removes entries once either `maxCount` is reached or the\n * entry's timestamp is less than `minTimestamp`.\n *\n * @param {number} minTimestamp\n * @param {number} maxCount\n *\n * @private\n */\n async expireEntries(minTimestamp, maxCount) {\n const entriesToDelete = await this._db.transaction(\n OBJECT_STORE_NAME, 'readwrite', (txn, done) => {\n const store = txn.objectStore(OBJECT_STORE_NAME);\n const entriesToDelete = [];\n let entriesNotDeletedCount = 0;\n\n store.index('timestamp')\n .openCursor(null, 'prev')\n .onsuccess = ({target}) => {\n const cursor = target.result;\n if (cursor) {\n const result = cursor.value;\n // TODO(philipwalton): once we can use a multi-key index, we\n // won't have to check `cacheName` here.\n if (result.cacheName === this._cacheName) {\n // Delete an entry if it's older than the max age or\n // if we already have the max number allowed.\n if ((minTimestamp && result.timestamp < minTimestamp) ||\n (maxCount && entriesNotDeletedCount >= maxCount)) {\n // TODO(philipwalton): we should be able to delete the\n // entry right here, but doing so causes an iteration\n // bug in Safari stable (fixed in TP). Instead we can\n // store the keys of the entries to delete, and then\n // delete the separate transactions.\n // https://github.com/GoogleChrome/workbox/issues/1978\n // cursor.delete();\n\n // We only need to return the URL, not the whole entry.\n entriesToDelete.push(cursor.value);\n } else {\n entriesNotDeletedCount++;\n }\n }\n cursor.continue();\n } else {\n done(entriesToDelete);\n }\n };\n });\n\n // TODO(philipwalton): once the Safari bug in the following issue is fixed,\n // we should be able to remove this loop and do the entry deletion in the\n // cursor loop above:\n // https://github.com/GoogleChrome/workbox/issues/1978\n const urlsDeleted = [];\n for (const entry of entriesToDelete) {\n await this._db.delete(OBJECT_STORE_NAME, entry.id);\n urlsDeleted.push(entry.url);\n }\n\n return urlsDeleted;\n }\n\n /**\n * Takes a URL and returns an ID that will be unique in the object store.\n *\n * @param {string} url\n * @return {string}\n *\n * @private\n */\n _getId(url) {\n // Creating an ID from the URL and cache name won't be necessary once\n // Edge switches to Chromium and all browsers we support work with\n // array keyPaths.\n return this._cacheName + '|' + normalizeURL(url);\n }\n}\n\nexport {CacheTimestampsModel};\n","/*\n Copyright 2018 Google LLC\n\n Use of this source code is governed by an MIT-style\n license that can be found in the LICENSE file or at\n https://opensource.org/licenses/MIT.\n*/\n\nimport {CacheTimestampsModel} from './models/CacheTimestampsModel.mjs';\nimport {WorkboxError} from 'workbox-core/_private/WorkboxError.mjs';\nimport {assert} from 'workbox-core/_private/assert.mjs';\nimport {logger} from 'workbox-core/_private/logger.mjs';\n\nimport './_version.mjs';\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 */\nclass 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 if (process.env.NODE_ENV !== 'production') {\n assert.isType(cacheName, 'string', {\n moduleName: 'workbox-expiration',\n className: 'CacheExpiration',\n funcName: 'constructor',\n paramName: 'cacheName',\n });\n\n if (!(config.maxEntries || config.maxAgeSeconds)) {\n throw new WorkboxError('max-entries-or-age-required', {\n moduleName: 'workbox-expiration',\n className: 'CacheExpiration',\n funcName: 'constructor',\n });\n }\n\n if (config.maxEntries) {\n assert.isType(config.maxEntries, 'number', {\n moduleName: 'workbox-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.isType(config.maxAgeSeconds, 'number', {\n moduleName: 'workbox-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 async expireEntries() {\n if (this._isRunning) {\n this._rerunRequested = true;\n return;\n }\n this._isRunning = true;\n\n const minTimestamp = this._maxAgeSeconds ?\n Date.now() - (this._maxAgeSeconds * 1000) : undefined;\n\n const urlsExpired = await this._timestampModel.expireEntries(\n minTimestamp, this._maxEntries);\n\n // Delete URLs from the cache\n const cache = await caches.open(this._cacheName);\n for (const url of urlsExpired) {\n await cache.delete(url);\n }\n\n if (process.env.NODE_ENV !== 'production') {\n if (urlsExpired.length > 0) {\n logger.groupCollapsed(\n `Expired ${urlsExpired.length} ` +\n `${urlsExpired.length === 1 ? 'entry' : 'entries'} and removed ` +\n `${urlsExpired.length === 1 ? 'it' : 'them'} from the ` +\n `'${this._cacheName}' cache.`);\n logger.log(`Expired the following ${urlsExpired.length === 1 ?\n 'URL' : 'URLs'}:`);\n urlsExpired.forEach((url) => logger.log(` ${url}`));\n logger.groupEnd();\n } else {\n 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 * 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 async updateTimestamp(url) {\n if (process.env.NODE_ENV !== 'production') {\n assert.isType(url, 'string', {\n moduleName: 'workbox-expiration',\n className: 'CacheExpiration',\n funcName: 'updateTimestamp',\n paramName: 'url',\n });\n }\n\n await this._timestampModel.setTimestamp(url, Date.now());\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 async isURLExpired(url) {\n if (process.env.NODE_ENV !== 'production') {\n if (!this._maxAgeSeconds) {\n throw new WorkboxError(`expired-test-without-max-age`, {\n methodName: 'isURLExpired',\n paramName: 'maxAgeSeconds',\n });\n }\n }\n\n const timestamp = await this._timestampModel.getTimestamp(url);\n const expireOlderThan = Date.now() - (this._maxAgeSeconds * 1000);\n return (timestamp < expireOlderThan);\n }\n\n /**\n * Removes the IndexedDB object store used to keep track of cache expiration\n * metadata.\n */\n async delete() {\n // Make sure we don't attempt another rerun if we're called in the middle of\n // a cache expiration.\n this._rerunRequested = false;\n await this._timestampModel.expireEntries(Infinity); // Expires all.\n }\n}\n\nexport {CacheExpiration};\n","/*\n Copyright 2018 Google LLC\n\n Use of this source code is governed by an MIT-style\n license that can be found in the LICENSE file or at\n https://opensource.org/licenses/MIT.\n*/\n\nimport {assert} from 'workbox-core/_private/assert.mjs';\nimport {cacheNames} from 'workbox-core/_private/cacheNames.mjs';\nimport {getFriendlyURL} from 'workbox-core/_private/getFriendlyURL.mjs';\nimport {logger} from 'workbox-core/_private/logger.mjs';\nimport {WorkboxError} from 'workbox-core/_private/WorkboxError.mjs';\nimport {registerQuotaErrorCallback}\n from 'workbox-core/registerQuotaErrorCallback.mjs';\n\nimport {CacheExpiration} from './CacheExpiration.mjs';\nimport './_version.mjs';\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 entry least-recently requested will be removed from the cache first.\n *\n * @memberof workbox.expiration\n */\nclass 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 if (process.env.NODE_ENV !== 'production') {\n if (!(config.maxEntries || config.maxAgeSeconds)) {\n throw new WorkboxError('max-entries-or-age-required', {\n moduleName: 'workbox-expiration',\n className: 'Plugin',\n funcName: 'constructor',\n });\n }\n\n if (config.maxEntries) {\n assert.isType(config.maxEntries, 'number', {\n moduleName: 'workbox-expiration',\n className: 'Plugin',\n funcName: 'constructor',\n paramName: 'config.maxEntries',\n });\n }\n\n if (config.maxAgeSeconds) {\n assert.isType(config.maxAgeSeconds, 'number', {\n moduleName: 'workbox-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 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.getRuntimeName()) {\n throw new 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.strategies` 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({event, request, 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 // Update the metadata for the request URL to the current timestamp,\n // but don't `await` it as we don't want to block the response.\n const updateTimestampDone = cacheExpiration.updateTimestamp(request.url);\n if (event) {\n try {\n event.waitUntil(updateTimestampDone);\n } catch (error) {\n if (process.env.NODE_ENV !== 'production') {\n logger.warn(`Unable to ensure service worker stays alive when ` +\n `updating cache entry for '${getFriendlyURL(event.request.url)}'.`);\n }\n }\n }\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.strategies` 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 async cacheDidUpdate({cacheName, request}) {\n if (process.env.NODE_ENV !== 'production') {\n assert.isType(cacheName, 'string', {\n moduleName: 'workbox-expiration',\n className: 'Plugin',\n funcName: 'cacheDidUpdate',\n paramName: 'cacheName',\n });\n assert.isInstance(request, Request, {\n moduleName: 'workbox-expiration',\n className: 'Plugin',\n funcName: 'cacheDidUpdate',\n paramName: 'request',\n });\n }\n\n const cacheExpiration = this._getCacheExpiration(cacheName);\n await cacheExpiration.updateTimestamp(request.url);\n await 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 your 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 async deleteCacheAndMetadata() {\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 this._cacheExpirations) {\n await caches.delete(cacheName);\n await cacheExpiration.delete();\n }\n\n // Reset this._cacheExpirations to its initial state.\n this._cacheExpirations = new Map();\n }\n}\n\nexport {Plugin};\n","/*\n Copyright 2018 Google LLC\n\n Use of this source code is governed by an MIT-style\n license that can be found in the LICENSE file or at\n https://opensource.org/licenses/MIT.\n*/\n\nimport {CacheExpiration} from './CacheExpiration.mjs';\nimport {Plugin} from './Plugin.mjs';\nimport './_version.mjs';\n\n\n/**\n * @namespace workbox.expiration\n */\n\nexport {\n CacheExpiration,\n Plugin,\n};\n"],"names":["self","_","e","DB_NAME","OBJECT_STORE_NAME","normalizeURL","unNormalizedUrl","url","URL","location","hash","href","CacheTimestampsModel","constructor","cacheName","_cacheName","_db","DBWrapper","onupgradeneeded","event","_handleUpgrade","db","target","result","objStore","createObjectStore","keyPath","createIndex","unique","deleteDatabase","setTimestamp","timestamp","put","id","_getId","getTimestamp","entry","get","expireEntries","minTimestamp","maxCount","entriesToDelete","transaction","txn","done","store","objectStore","entriesNotDeletedCount","index","openCursor","onsuccess","cursor","value","push","continue","urlsDeleted","delete","CacheExpiration","config","assert","isType","moduleName","className","funcName","paramName","maxEntries","maxAgeSeconds","WorkboxError","_isRunning","_rerunRequested","_maxEntries","_maxAgeSeconds","_timestampModel","Date","now","undefined","urlsExpired","cache","caches","open","length","logger","groupCollapsed","log","forEach","groupEnd","debug","updateTimestamp","isURLExpired","methodName","expireOlderThan","Infinity","Plugin","_config","_cacheExpirations","Map","purgeOnQuotaError","registerQuotaErrorCallback","deleteCacheAndMetadata","_getCacheExpiration","cacheNames","getRuntimeName","cacheExpiration","set","cachedResponseWillBeUsed","request","cachedResponse","isFresh","_isResponseDateFresh","updateTimestampDone","waitUntil","error","warn","getFriendlyURL","dateHeaderTimestamp","_getDateHeaderTimestamp","headers","has","dateHeader","parsedDate","headerTime","getTime","isNaN","cacheDidUpdate","isInstance","Request"],"mappings":";;;;EAAA,IAAG;EAACA,EAAAA,IAAI,CAAC,0BAAD,CAAJ,IAAkCC,CAAC,EAAnC;EAAsC,CAA1C,CAA0C,OAAMC,CAAN,EAAQ;;ECAlD;;;;;;;AAQA,EAKA,MAAMC,OAAO,GAAG,oBAAhB;EACA,MAAMC,iBAAiB,GAAG,eAA1B;;EAEA,MAAMC,YAAY,GAAIC,eAAD,IAAqB;EACxC,QAAMC,GAAG,GAAG,IAAIC,GAAJ,CAAQF,eAAR,EAAyBG,QAAzB,CAAZ;EACAF,EAAAA,GAAG,CAACG,IA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B;EAC7B;EACA;EACA,SAAK,MAAM,CAACpF,SAAD,EAAYwF,eAAZ,CAAX,IAA2C,KAAKR,iBAAhD,EAAmE;EACjE,YAAMhB,MAAM,CAACtB,MAAP,CAAc1C,SAAd,CAAN;EACA,YAAMwF,eAAe,CAAC9C,MAAhB,EAAN;EACD,KAN4B;;;EAS7B,SAAKsC,iBAAL,GAAyB,IAAIC,GAAJ,EAAzB;EACD;;EApOU;;ECpCb;;;;;;;;;;;;;;;;;"}
@@ -1,2 +0,0 @@
1
- this.workbox=this.workbox||{},this.workbox.expiration=function(t,e,s,i,a,n){"use strict";try{self["workbox:expiration:4.3.1"]&&_()}catch(t){}const h="workbox-expiration",c="cache-entries",r=t=>{const e=new URL(t,location);return e.hash="",e.href};class o{constructor(t){this.t=t,this.s=new e.DBWrapper(h,1,{onupgradeneeded:t=>this.i(t)})}i(t){const e=t.target.result.createObjectStore(c,{keyPath:"id"});e.createIndex("cacheName","cacheName",{unique:!1}),e.createIndex("timestamp","timestamp",{unique:!1}),s.deleteDatabase(this.t)}async setTimestamp(t,e){t=r(t),await this.s.put(c,{url:t,timestamp:e,cacheName:this.t,id:this.h(t)})}async getTimestamp(t){return(await this.s.get(c,this.h(t))).timestamp}async expireEntries(t,e){const s=await this.s.transaction(c,"readwrite",(s,i)=>{const a=s.objectStore(c),n=[];let h=0;a.index("timestamp").openCursor(null,"prev").onsuccess=(({target:s})=>{const a=s.result;if(a){const s=a.value;s.cacheName===this.t&&(t&&s.timestamp<t||e&&h>=e?n.push(a.value):h++),a.continue()}else i(n)})}),i=[];for(const t of s)await this.s.delete(c,t.id),i.push(t.url);return i}h(t){return this.t+"|"+r(t)}}class u{constructor(t,e={}){this.o=!1,this.u=!1,this.l=e.maxEntries,this.p=e.maxAgeSeconds,this.t=t,this.m=new o(t)}async expireEntries(){if(this.o)return void(this.u=!0);this.o=!0;const t=this.p?Date.now()-1e3*this.p:void 0,e=await this.m.expireEntries(t,this.l),s=await caches.open(this.t);for(const t of e)await s.delete(t);this.o=!1,this.u&&(this.u=!1,this.expireEntries())}async updateTimestamp(t){await this.m.setTimestamp(t,Date.now())}async isURLExpired(t){return await this.m.getTimestamp(t)<Date.now()-1e3*this.p}async delete(){this.u=!1,await this.m.expireEntries(1/0)}}return t.CacheExpiration=u,t.Plugin=class{constructor(t={}){this.D=t,this.p=t.maxAgeSeconds,this.g=new Map,t.purgeOnQuotaError&&n.registerQuotaErrorCallback(()=>this.deleteCacheAndMetadata())}k(t){if(t===a.cacheNames.getRuntimeName())throw new i.WorkboxError("expire-custom-caches-only");let e=this.g.get(t);return e||(e=new u(t,this.D),this.g.set(t,e)),e}cachedResponseWillBeUsed({event:t,request:e,cacheName:s,cachedResponse:i}){if(!i)return null;let a=this.N(i);const n=this.k(s);n.expireEntries();const h=n.updateTimestamp(e.url);if(t)try{t.waitUntil(h)}catch(t){}return a?i:null}N(t){if(!this.p)return!0;const e=this._(t);return null===e||e>=Date.now()-1e3*this.p}_(t){if(!t.headers.has("date"))return null;const e=t.headers.get("date"),s=new Date(e).getTime();return isNaN(s)?null:s}async cacheDidUpdate({cacheName:t,request:e}){const s=this.k(t);await s.updateTimestamp(e.url),await s.expireEntries()}async deleteCacheAndMetadata(){for(const[t,e]of this.g)await caches.delete(t),await e.delete();this.g=new Map}},t}({},workbox.core._private,workbox.core._private,workbox.core._private,workbox.core._private,workbox.core);
2
- //# sourceMappingURL=workbox-expiration.prod.js.map
@@ -1 +0,0 @@
1
- {"version":3,"file":"workbox-expiration.prod.js","sources":["../_version.mjs","../models/CacheTimestampsModel.mjs","../CacheExpiration.mjs","../Plugin.mjs"],"sourcesContent":["try{self['workbox:expiration:4.3.1']&&_()}catch(e){}// eslint-disable-line","/*\n Copyright 2018 Google LLC\n\n Use of this source code is governed by an MIT-style\n license that can be found in the LICENSE file or at\n https://opensource.org/licenses/MIT.\n*/\n\nimport {DBWrapper} from 'workbox-core/_private/DBWrapper.mjs';\nimport {deleteDatabase} from 'workbox-core/_private/deleteDatabase.mjs';\nimport '../_version.mjs';\n\n\nconst DB_NAME = 'workbox-expiration';\nconst OBJECT_STORE_NAME = 'cache-entries';\n\nconst normalizeURL = (unNormalizedUrl) => {\n const url = new URL(unNormalizedUrl, location);\n url.hash = '';\n\n return url.href;\n};\n\n\n/**\n * Returns the timestamp model.\n *\n * @private\n */\nclass CacheTimestampsModel {\n /**\n *\n * @param {string} cacheName\n *\n * @private\n */\n constructor(cacheName) {\n this._cacheName = cacheName;\n\n this._db = new DBWrapper(DB_NAME, 1, {\n onupgradeneeded: (event) => this._handleUpgrade(event),\n });\n }\n\n /**\n * Should perform an upgrade of indexedDB.\n *\n * @param {Event} event\n *\n * @private\n */\n _handleUpgrade(event) {\n const db = event.target.result;\n\n // TODO(philipwalton): EdgeHTML doesn't support arrays as a keyPath, so we\n // have to use the `id` keyPath here and create our own values (a\n // concatenation of `url + cacheName`) instead of simply using\n // `keyPath: ['url', 'cacheName']`, which is supported in other browsers.\n const objStore = db.createObjectStore(OBJECT_STORE_NAME, {keyPath: 'id'});\n\n // TODO(philipwalton): once we don't have to support EdgeHTML, we can\n // create a single index with the keyPath `['cacheName', 'timestamp']`\n // instead of doing both these indexes.\n objStore.createIndex('cacheName', 'cacheName', {unique: false});\n objStore.createIndex('timestamp', 'timestamp', {unique: false});\n\n // Previous versions of `workbox-expiration` used `this._cacheName`\n // as the IDBDatabase name.\n deleteDatabase(this._cacheName);\n }\n\n /**\n * @param {string} url\n * @param {number} timestamp\n *\n * @private\n */\n async setTimestamp(url, timestamp) {\n url = normalizeURL(url);\n\n await this._db.put(OBJECT_STORE_NAME, {\n url,\n timestamp,\n cacheName: this._cacheName,\n // Creating an ID from the URL and cache name won't be necessary once\n // Edge switches to Chromium and all browsers we support work with\n // array keyPaths.\n id: this._getId(url),\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 async getTimestamp(url) {\n const entry = await this._db.get(OBJECT_STORE_NAME, this._getId(url));\n return entry.timestamp;\n }\n\n /**\n * Iterates through all the entries in the object store (from newest to\n * oldest) and removes entries once either `maxCount` is reached or the\n * entry's timestamp is less than `minTimestamp`.\n *\n * @param {number} minTimestamp\n * @param {number} maxCount\n *\n * @private\n */\n async expireEntries(minTimestamp, maxCount) {\n const entriesToDelete = await this._db.transaction(\n OBJECT_STORE_NAME, 'readwrite', (txn, done) => {\n const store = txn.objectStore(OBJECT_STORE_NAME);\n const entriesToDelete = [];\n let entriesNotDeletedCount = 0;\n\n store.index('timestamp')\n .openCursor(null, 'prev')\n .onsuccess = ({target}) => {\n const cursor = target.result;\n if (cursor) {\n const result = cursor.value;\n // TODO(philipwalton): once we can use a multi-key index, we\n // won't have to check `cacheName` here.\n if (result.cacheName === this._cacheName) {\n // Delete an entry if it's older than the max age or\n // if we already have the max number allowed.\n if ((minTimestamp && result.timestamp < minTimestamp) ||\n (maxCount && entriesNotDeletedCount >= maxCount)) {\n // TODO(philipwalton): we should be able to delete the\n // entry right here, but doing so causes an iteration\n // bug in Safari stable (fixed in TP). Instead we can\n // store the keys of the entries to delete, and then\n // delete the separate transactions.\n // https://github.com/GoogleChrome/workbox/issues/1978\n // cursor.delete();\n\n // We only need to return the URL, not the whole entry.\n entriesToDelete.push(cursor.value);\n } else {\n entriesNotDeletedCount++;\n }\n }\n cursor.continue();\n } else {\n done(entriesToDelete);\n }\n };\n });\n\n // TODO(philipwalton): once the Safari bug in the following issue is fixed,\n // we should be able to remove this loop and do the entry deletion in the\n // cursor loop above:\n // https://github.com/GoogleChrome/workbox/issues/1978\n const urlsDeleted = [];\n for (const entry of entriesToDelete) {\n await this._db.delete(OBJECT_STORE_NAME, entry.id);\n urlsDeleted.push(entry.url);\n }\n\n return urlsDeleted;\n }\n\n /**\n * Takes a URL and returns an ID that will be unique in the object store.\n *\n * @param {string} url\n * @return {string}\n *\n * @private\n */\n _getId(url) {\n // Creating an ID from the URL and cache name won't be necessary once\n // Edge switches to Chromium and all browsers we support work with\n // array keyPaths.\n return this._cacheName + '|' + normalizeURL(url);\n }\n}\n\nexport {CacheTimestampsModel};\n","/*\n Copyright 2018 Google LLC\n\n Use of this source code is governed by an MIT-style\n license that can be found in the LICENSE file or at\n https://opensource.org/licenses/MIT.\n*/\n\nimport {CacheTimestampsModel} from './models/CacheTimestampsModel.mjs';\nimport {WorkboxError} from 'workbox-core/_private/WorkboxError.mjs';\nimport {assert} from 'workbox-core/_private/assert.mjs';\nimport {logger} from 'workbox-core/_private/logger.mjs';\n\nimport './_version.mjs';\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 */\nclass 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 if (process.env.NODE_ENV !== 'production') {\n assert.isType(cacheName, 'string', {\n moduleName: 'workbox-expiration',\n className: 'CacheExpiration',\n funcName: 'constructor',\n paramName: 'cacheName',\n });\n\n if (!(config.maxEntries || config.maxAgeSeconds)) {\n throw new WorkboxError('max-entries-or-age-required', {\n moduleName: 'workbox-expiration',\n className: 'CacheExpiration',\n funcName: 'constructor',\n });\n }\n\n if (config.maxEntries) {\n assert.isType(config.maxEntries, 'number', {\n moduleName: 'workbox-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.isType(config.maxAgeSeconds, 'number', {\n moduleName: 'workbox-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 async expireEntries() {\n if (this._isRunning) {\n this._rerunRequested = true;\n return;\n }\n this._isRunning = true;\n\n const minTimestamp = this._maxAgeSeconds ?\n Date.now() - (this._maxAgeSeconds * 1000) : undefined;\n\n const urlsExpired = await this._timestampModel.expireEntries(\n minTimestamp, this._maxEntries);\n\n // Delete URLs from the cache\n const cache = await caches.open(this._cacheName);\n for (const url of urlsExpired) {\n await cache.delete(url);\n }\n\n if (process.env.NODE_ENV !== 'production') {\n if (urlsExpired.length > 0) {\n logger.groupCollapsed(\n `Expired ${urlsExpired.length} ` +\n `${urlsExpired.length === 1 ? 'entry' : 'entries'} and removed ` +\n `${urlsExpired.length === 1 ? 'it' : 'them'} from the ` +\n `'${this._cacheName}' cache.`);\n logger.log(`Expired the following ${urlsExpired.length === 1 ?\n 'URL' : 'URLs'}:`);\n urlsExpired.forEach((url) => logger.log(` ${url}`));\n logger.groupEnd();\n } else {\n 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 * 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 async updateTimestamp(url) {\n if (process.env.NODE_ENV !== 'production') {\n assert.isType(url, 'string', {\n moduleName: 'workbox-expiration',\n className: 'CacheExpiration',\n funcName: 'updateTimestamp',\n paramName: 'url',\n });\n }\n\n await this._timestampModel.setTimestamp(url, Date.now());\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 async isURLExpired(url) {\n if (process.env.NODE_ENV !== 'production') {\n if (!this._maxAgeSeconds) {\n throw new WorkboxError(`expired-test-without-max-age`, {\n methodName: 'isURLExpired',\n paramName: 'maxAgeSeconds',\n });\n }\n }\n\n const timestamp = await this._timestampModel.getTimestamp(url);\n const expireOlderThan = Date.now() - (this._maxAgeSeconds * 1000);\n return (timestamp < expireOlderThan);\n }\n\n /**\n * Removes the IndexedDB object store used to keep track of cache expiration\n * metadata.\n */\n async delete() {\n // Make sure we don't attempt another rerun if we're called in the middle of\n // a cache expiration.\n this._rerunRequested = false;\n await this._timestampModel.expireEntries(Infinity); // Expires all.\n }\n}\n\nexport {CacheExpiration};\n","/*\n Copyright 2018 Google LLC\n\n Use of this source code is governed by an MIT-style\n license that can be found in the LICENSE file or at\n https://opensource.org/licenses/MIT.\n*/\n\nimport {assert} from 'workbox-core/_private/assert.mjs';\nimport {cacheNames} from 'workbox-core/_private/cacheNames.mjs';\nimport {getFriendlyURL} from 'workbox-core/_private/getFriendlyURL.mjs';\nimport {logger} from 'workbox-core/_private/logger.mjs';\nimport {WorkboxError} from 'workbox-core/_private/WorkboxError.mjs';\nimport {registerQuotaErrorCallback}\n from 'workbox-core/registerQuotaErrorCallback.mjs';\n\nimport {CacheExpiration} from './CacheExpiration.mjs';\nimport './_version.mjs';\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 entry least-recently requested will be removed from the cache first.\n *\n * @memberof workbox.expiration\n */\nclass 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 if (process.env.NODE_ENV !== 'production') {\n if (!(config.maxEntries || config.maxAgeSeconds)) {\n throw new WorkboxError('max-entries-or-age-required', {\n moduleName: 'workbox-expiration',\n className: 'Plugin',\n funcName: 'constructor',\n });\n }\n\n if (config.maxEntries) {\n assert.isType(config.maxEntries, 'number', {\n moduleName: 'workbox-expiration',\n className: 'Plugin',\n funcName: 'constructor',\n paramName: 'config.maxEntries',\n });\n }\n\n if (config.maxAgeSeconds) {\n assert.isType(config.maxAgeSeconds, 'number', {\n moduleName: 'workbox-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 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.getRuntimeName()) {\n throw new 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.strategies` 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({event, request, 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 // Update the metadata for the request URL to the current timestamp,\n // but don't `await` it as we don't want to block the response.\n const updateTimestampDone = cacheExpiration.updateTimestamp(request.url);\n if (event) {\n try {\n event.waitUntil(updateTimestampDone);\n } catch (error) {\n if (process.env.NODE_ENV !== 'production') {\n logger.warn(`Unable to ensure service worker stays alive when ` +\n `updating cache entry for '${getFriendlyURL(event.request.url)}'.`);\n }\n }\n }\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.strategies` 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 async cacheDidUpdate({cacheName, request}) {\n if (process.env.NODE_ENV !== 'production') {\n assert.isType(cacheName, 'string', {\n moduleName: 'workbox-expiration',\n className: 'Plugin',\n funcName: 'cacheDidUpdate',\n paramName: 'cacheName',\n });\n assert.isInstance(request, Request, {\n moduleName: 'workbox-expiration',\n className: 'Plugin',\n funcName: 'cacheDidUpdate',\n paramName: 'request',\n });\n }\n\n const cacheExpiration = this._getCacheExpiration(cacheName);\n await cacheExpiration.updateTimestamp(request.url);\n await 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 your 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 async deleteCacheAndMetadata() {\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 this._cacheExpirations) {\n await caches.delete(cacheName);\n await cacheExpiration.delete();\n }\n\n // Reset this._cacheExpirations to its initial state.\n this._cacheExpirations = new Map();\n }\n}\n\nexport {Plugin};\n"],"names":["self","_","e","DB_NAME","OBJECT_STORE_NAME","normalizeURL","unNormalizedUrl","url","URL","location","hash","href","CacheTimestampsModel","constructor","cacheName","_cacheName","_db","DBWrapper","onupgradeneeded","event","this","_handleUpgrade","objStore","target","result","createObjectStore","keyPath","createIndex","unique","deleteDatabase","timestamp","put","id","_getId","get","minTimestamp","maxCount","entriesToDelete","transaction","txn","done","store","objectStore","entriesNotDeletedCount","index","openCursor","onsuccess","cursor","value","push","continue","urlsDeleted","entry","delete","CacheExpiration","config","_isRunning","_rerunRequested","_maxEntries","maxEntries","_maxAgeSeconds","maxAgeSeconds","_timestampModel","Date","now","undefined","urlsExpired","expireEntries","cache","caches","open","setTimestamp","getTimestamp","Infinity","_config","_cacheExpirations","Map","purgeOnQuotaError","registerQuotaErrorCallback","deleteCacheAndMetadata","_getCacheExpiration","cacheNames","getRuntimeName","WorkboxError","cacheExpiration","set","cachedResponseWillBeUsed","request","cachedResponse","isFresh","_isResponseDateFresh","updateTimestampDone","updateTimestamp","waitUntil","error","dateHeaderTimestamp","_getDateHeaderTimestamp","headers","has","dateHeader","headerTime","getTime","isNaN"],"mappings":"yFAAA,IAAIA,KAAK,6BAA6BC,IAAI,MAAMC,ICahD,MAAMC,EAAU,qBACVC,EAAoB,gBAEpBC,EAAgBC,UACdC,EAAM,IAAIC,IAAIF,EAAiBG,iBACrCF,EAAIG,KAAO,GAEJH,EAAII,MASb,MAAMC,EAOJC,YAAYC,QACLC,EAAaD,OAEbE,EAAM,IAAIC,YAAUd,EAAS,EAAG,CACnCe,gBAAkBC,GAAUC,KAAKC,EAAeF,KAWpDE,EAAeF,SAOPG,EANKH,EAAMI,OAAOC,OAMJC,kBAAkBrB,EAAmB,CAACsB,QAAS,OAKnEJ,EAASK,YAAY,YAAa,YAAa,CAACC,QAAQ,IACxDN,EAASK,YAAY,YAAa,YAAa,CAACC,QAAQ,IAIxDC,iBAAeT,KAAKL,sBASHR,EAAKuB,GACtBvB,EAAMF,EAAaE,SAEba,KAAKJ,EAAIe,IAAI3B,EAAmB,CACpCG,IAAA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6E,EAAgBjB,mDAuBjB,MAAOrD,EAAWsE,KAAoBhE,KAAKuD,QACxCN,OAAOhB,OAAOvC,SACdsE,EAAgB/B,cAInBsB,EAAoB,IAAIC"}
@@ -1,110 +0,0 @@
1
- this.workbox = this.workbox || {};
2
- this.workbox.navigationPreload = (function (exports, logger_mjs) {
3
- 'use strict';
4
-
5
- try {
6
- self['workbox:navigation-preload:4.3.1'] && _();
7
- } catch (e) {} // eslint-disable-line
8
-
9
- /*
10
- Copyright 2018 Google LLC
11
-
12
- Use of this source code is governed by an MIT-style
13
- license that can be found in the LICENSE file or at
14
- https://opensource.org/licenses/MIT.
15
- */
16
- /**
17
- * @return {boolean} Whether or not the current browser supports enabling
18
- * navigation preload.
19
- *
20
- * @memberof workbox.navigationPreload
21
- */
22
-
23
- function isSupported() {
24
- return Boolean(self.registration && self.registration.navigationPreload);
25
- }
26
-
27
- /*
28
- Copyright 2018 Google LLC
29
-
30
- Use of this source code is governed by an MIT-style
31
- license that can be found in the LICENSE file or at
32
- https://opensource.org/licenses/MIT.
33
- */
34
- /**
35
- * If the browser supports Navigation Preload, then this will disable it.
36
- *
37
- * @memberof workbox.navigationPreload
38
- */
39
-
40
- function disable() {
41
- if (isSupported()) {
42
- self.addEventListener('activate', event => {
43
- event.waitUntil(self.registration.navigationPreload.disable().then(() => {
44
- {
45
- logger_mjs.logger.log(`Navigation preload is disabled.`);
46
- }
47
- }));
48
- });
49
- } else {
50
- {
51
- logger_mjs.logger.log(`Navigation preload is not supported in this browser.`);
52
- }
53
- }
54
- }
55
-
56
- /*
57
- Copyright 2018 Google LLC
58
-
59
- Use of this source code is governed by an MIT-style
60
- license that can be found in the LICENSE file or at
61
- https://opensource.org/licenses/MIT.
62
- */
63
- /**
64
- * If the browser supports Navigation Preload, then this will enable it.
65
- *
66
- * @param {string} [headerValue] Optionally, allows developers to
67
- * [override](https://developers.google.com/web/updates/2017/02/navigation-preload#changing_the_header)
68
- * the value of the `Service-Worker-Navigation-Preload` header which will be
69
- * sent to the server when making the navigation request.
70
- *
71
- * @memberof workbox.navigationPreload
72
- */
73
-
74
- function enable(headerValue) {
75
- if (isSupported()) {
76
- self.addEventListener('activate', event => {
77
- event.waitUntil(self.registration.navigationPreload.enable().then(() => {
78
- // Defaults to Service-Worker-Navigation-Preload: true if not set.
79
- if (headerValue) {
80
- self.registration.navigationPreload.setHeaderValue(headerValue);
81
- }
82
-
83
- {
84
- logger_mjs.logger.log(`Navigation preload is enabled.`);
85
- }
86
- }));
87
- });
88
- } else {
89
- {
90
- logger_mjs.logger.log(`Navigation preload is not supported in this browser.`);
91
- }
92
- }
93
- }
94
-
95
- /*
96
- Copyright 2018 Google LLC
97
-
98
- Use of this source code is governed by an MIT-style
99
- license that can be found in the LICENSE file or at
100
- https://opensource.org/licenses/MIT.
101
- */
102
-
103
- exports.disable = disable;
104
- exports.enable = enable;
105
- exports.isSupported = isSupported;
106
-
107
- return exports;
108
-
109
- }({}, workbox.core._private));
110
- //# sourceMappingURL=workbox-navigation-preload.dev.js.map
@@ -1 +0,0 @@
1
- {"version":3,"file":"workbox-navigation-preload.dev.js","sources":["../_version.mjs","../isSupported.mjs","../disable.mjs","../enable.mjs","../index.mjs"],"sourcesContent":["try{self['workbox:navigation-preload:4.3.1']&&_()}catch(e){}// eslint-disable-line","/*\n Copyright 2018 Google LLC\n\n Use of this source code is governed by an MIT-style\n license that can be found in the LICENSE file or at\n https://opensource.org/licenses/MIT.\n*/\n\nimport './_version.mjs';\n\n/**\n * @return {boolean} Whether or not the current browser supports enabling\n * navigation preload.\n *\n * @memberof workbox.navigationPreload\n */\nfunction isSupported() {\n return Boolean(self.registration && self.registration.navigationPreload);\n}\n\nexport {isSupported};\n","/*\n Copyright 2018 Google LLC\n\n Use of this source code is governed by an MIT-style\n license that can be found in the LICENSE file or at\n https://opensource.org/licenses/MIT.\n*/\n\nimport {logger} from 'workbox-core/_private/logger.mjs';\n\nimport {isSupported} from './isSupported.mjs';\n\nimport './_version.mjs';\n\n/**\n * If the browser supports Navigation Preload, then this will disable it.\n *\n * @memberof workbox.navigationPreload\n */\nfunction disable() {\n if (isSupported()) {\n self.addEventListener('activate', (event) => {\n event.waitUntil(\n self.registration.navigationPreload.disable().then(() => {\n if (process.env.NODE_ENV !== 'production') {\n logger.log(`Navigation preload is disabled.`);\n }\n })\n );\n });\n } else {\n if (process.env.NODE_ENV !== 'production') {\n logger.log(`Navigation preload is not supported in this browser.`);\n }\n }\n}\n\nexport {disable};\n","/*\n Copyright 2018 Google LLC\n\n Use of this source code is governed by an MIT-style\n license that can be found in the LICENSE file or at\n https://opensource.org/licenses/MIT.\n*/\n\nimport {logger} from 'workbox-core/_private/logger.mjs';\n\nimport {isSupported} from './isSupported.mjs';\n\nimport './_version.mjs';\n\n/**\n * If the browser supports Navigation Preload, then this will enable it.\n *\n * @param {string} [headerValue] Optionally, allows developers to\n * [override](https://developers.google.com/web/updates/2017/02/navigation-preload#changing_the_header)\n * the value of the `Service-Worker-Navigation-Preload` header which will be\n * sent to the server when making the navigation request.\n *\n * @memberof workbox.navigationPreload\n */\nfunction enable(headerValue) {\n if (isSupported()) {\n self.addEventListener('activate', (event) => {\n event.waitUntil(\n self.registration.navigationPreload.enable().then(() => {\n // Defaults to Service-Worker-Navigation-Preload: true if not set.\n if (headerValue) {\n self.registration.navigationPreload.setHeaderValue(headerValue);\n }\n\n if (process.env.NODE_ENV !== 'production') {\n logger.log(`Navigation preload is enabled.`);\n }\n })\n );\n });\n } else {\n if (process.env.NODE_ENV !== 'production') {\n logger.log(`Navigation preload is not supported in this browser.`);\n }\n }\n}\n\nexport {enable};\n","/*\n Copyright 2018 Google LLC\n\n Use of this source code is governed by an MIT-style\n license that can be found in the LICENSE file or at\n https://opensource.org/licenses/MIT.\n*/\n\nimport {disable} from './disable.mjs';\nimport {enable} from './enable.mjs';\nimport {isSupported} from './isSupported.mjs';\nimport './_version.mjs';\n\n\n/**\n * @namespace workbox.navigationPreload\n */\n\nexport {\n disable,\n enable,\n isSupported,\n};\n"],"names":["self","_","e","isSupported","Boolean","registration","navigationPreload","disable","addEventListener","event","waitUntil","then","logger","log","enable","headerValue","setHeaderValue"],"mappings":";;;;EAAA,IAAG;EAACA,EAAAA,IAAI,CAAC,kCAAD,CAAJ,IAA0CC,CAAC,EAA3C;EAA8C,CAAlD,CAAkD,OAAMC,CAAN,EAAQ;;ECA1D;;;;;;;AAQA,EAEA;;;;;;;EAMA,SAASC,WAAT,GAAuB;EACrB,SAAOC,OAAO,CAACJ,IAAI,CAACK,YAAL,IAAqBL,IAAI,CAACK,YAAL,CAAkBC,iBAAxC,CAAd;EACD;;EClBD;;;;;;;AAQA,EAMA;;;;;;EAKA,SAASC,OAAT,GAAmB;EACjB,MAAIJ,WAAW,EAAf,EAAmB;EACjBH,IAAAA,IAAI,CAACQ,gBAAL,CAAsB,UAAtB,EAAmCC,KAAD,IAAW;EAC3CA,MAAAA,KAAK,CAACC,SAAN,CACIV,IAAI,CAACK,YAAL,CAAkBC,iBAAlB,CAAoCC,OAApC,GAA8CI,IAA9C,CAAmD,MAAM;EACvD,QAA2C;EACzCC,UAAAA,iBAAM,CAACC,GAAP,CAAY,iCAAZ;EACD;EACF,OAJD,CADJ;EAOD,KARD;EASD,GAVD,MAUO;EACL,IAA2C;EACzCD,MAAAA,iBAAM,CAACC,GAAP,CAAY,sDAAZ;EACD;EACF;EACF;;ECnCD;;;;;;;AAQA,EAMA;;;;;;;;;;;EAUA,SAASC,MAAT,CAAgBC,WAAhB,EAA6B;EAC3B,MAAIZ,WAAW,EAAf,EAAmB;EACjBH,IAAAA,IAAI,CAACQ,gBAAL,CAAsB,UAAtB,EAAmCC,KAAD,IAAW;EAC3CA,MAAAA,KAAK,CAACC,SAAN,CACIV,IAAI,CAACK,YAAL,CAAkBC,iBAAlB,CAAoCQ,MAApC,GAA6CH,IAA7C,CAAkD,MAAM;EACxD;EACE,YAAII,WAAJ,EAAiB;EACff,UAAAA,IAAI,CAACK,YAAL,CAAkBC,iBAAlB,CAAoCU,cAApC,CAAmDD,WAAnD;EACD;;EAED,QAA2C;EACzCH,UAAAA,iBAAM,CAACC,GAAP,CAAY,gCAAZ;EACD;EACF,OATD,CADJ;EAYD,KAbD;EAcD,GAfD,MAeO;EACL,IAA2C;EACzCD,MAAAA,iBAAM,CAACC,GAAP,CAAY,sDAAZ;EACD;EACF;EACF;;EC7CD;;;;;;;;;;;;;;;;;;"}
@@ -1,2 +0,0 @@
1
- this.workbox=this.workbox||{},this.workbox.navigationPreload=function(t){"use strict";try{self["workbox:navigation-preload:4.3.1"]&&_()}catch(t){}function e(){return Boolean(self.registration&&self.registration.navigationPreload)}return t.disable=function(){e()&&self.addEventListener("activate",t=>{t.waitUntil(self.registration.navigationPreload.disable().then(()=>{}))})},t.enable=function(t){e()&&self.addEventListener("activate",e=>{e.waitUntil(self.registration.navigationPreload.enable().then(()=>{t&&self.registration.navigationPreload.setHeaderValue(t)}))})},t.isSupported=e,t}({});
2
- //# sourceMappingURL=workbox-navigation-preload.prod.js.map
@@ -1 +0,0 @@
1
- {"version":3,"file":"workbox-navigation-preload.prod.js","sources":["../_version.mjs","../isSupported.mjs","../disable.mjs","../enable.mjs"],"sourcesContent":["try{self['workbox:navigation-preload:4.3.1']&&_()}catch(e){}// eslint-disable-line","/*\n Copyright 2018 Google LLC\n\n Use of this source code is governed by an MIT-style\n license that can be found in the LICENSE file or at\n https://opensource.org/licenses/MIT.\n*/\n\nimport './_version.mjs';\n\n/**\n * @return {boolean} Whether or not the current browser supports enabling\n * navigation preload.\n *\n * @memberof workbox.navigationPreload\n */\nfunction isSupported() {\n return Boolean(self.registration && self.registration.navigationPreload);\n}\n\nexport {isSupported};\n","/*\n Copyright 2018 Google LLC\n\n Use of this source code is governed by an MIT-style\n license that can be found in the LICENSE file or at\n https://opensource.org/licenses/MIT.\n*/\n\nimport {logger} from 'workbox-core/_private/logger.mjs';\n\nimport {isSupported} from './isSupported.mjs';\n\nimport './_version.mjs';\n\n/**\n * If the browser supports Navigation Preload, then this will disable it.\n *\n * @memberof workbox.navigationPreload\n */\nfunction disable() {\n if (isSupported()) {\n self.addEventListener('activate', (event) => {\n event.waitUntil(\n self.registration.navigationPreload.disable().then(() => {\n if (process.env.NODE_ENV !== 'production') {\n logger.log(`Navigation preload is disabled.`);\n }\n })\n );\n });\n } else {\n if (process.env.NODE_ENV !== 'production') {\n logger.log(`Navigation preload is not supported in this browser.`);\n }\n }\n}\n\nexport {disable};\n","/*\n Copyright 2018 Google LLC\n\n Use of this source code is governed by an MIT-style\n license that can be found in the LICENSE file or at\n https://opensource.org/licenses/MIT.\n*/\n\nimport {logger} from 'workbox-core/_private/logger.mjs';\n\nimport {isSupported} from './isSupported.mjs';\n\nimport './_version.mjs';\n\n/**\n * If the browser supports Navigation Preload, then this will enable it.\n *\n * @param {string} [headerValue] Optionally, allows developers to\n * [override](https://developers.google.com/web/updates/2017/02/navigation-preload#changing_the_header)\n * the value of the `Service-Worker-Navigation-Preload` header which will be\n * sent to the server when making the navigation request.\n *\n * @memberof workbox.navigationPreload\n */\nfunction enable(headerValue) {\n if (isSupported()) {\n self.addEventListener('activate', (event) => {\n event.waitUntil(\n self.registration.navigationPreload.enable().then(() => {\n // Defaults to Service-Worker-Navigation-Preload: true if not set.\n if (headerValue) {\n self.registration.navigationPreload.setHeaderValue(headerValue);\n }\n\n if (process.env.NODE_ENV !== 'production') {\n logger.log(`Navigation preload is enabled.`);\n }\n })\n );\n });\n } else {\n if (process.env.NODE_ENV !== 'production') {\n logger.log(`Navigation preload is not supported in this browser.`);\n }\n }\n}\n\nexport {enable};\n"],"names":["self","_","e","isSupported","Boolean","registration","navigationPreload","addEventListener","event","waitUntil","disable","then","headerValue","enable","setHeaderValue"],"mappings":"sFAAA,IAAIA,KAAK,qCAAqCC,IAAI,MAAMC,ICgBxD,SAASC,WACAC,QAAQJ,KAAKK,cAAgBL,KAAKK,aAAaC,oCCExD,WACMH,KACFH,KAAKO,iBAAiB,WAAaC,IACjCA,EAAMC,UACFT,KAAKK,aAAaC,kBAAkBI,UAAUC,KAAK,qBCC7D,SAAgBC,GACVT,KACFH,KAAKO,iBAAiB,WAAaC,IACjCA,EAAMC,UACFT,KAAKK,aAAaC,kBAAkBO,SAASF,KAAK,KAE5CC,GACFZ,KAAKK,aAAaC,kBAAkBQ,eAAeF"}
@@ -1,243 +0,0 @@
1
- this.workbox = this.workbox || {};
2
- this.workbox.googleAnalytics = (function (exports, Plugin_mjs, cacheNames_mjs, getFriendlyURL_mjs, logger_mjs, Route_mjs, Router_mjs, NetworkFirst_mjs, NetworkOnly_mjs) {
3
- 'use strict';
4
-
5
- try {
6
- self['workbox:google-analytics:4.3.1'] && _();
7
- } catch (e) {} // eslint-disable-line
8
-
9
- /*
10
- Copyright 2018 Google LLC
11
-
12
- Use of this source code is governed by an MIT-style
13
- license that can be found in the LICENSE file or at
14
- https://opensource.org/licenses/MIT.
15
- */
16
- const QUEUE_NAME = 'workbox-google-analytics';
17
- const MAX_RETENTION_TIME = 60 * 48; // Two days in minutes
18
-
19
- const GOOGLE_ANALYTICS_HOST = 'www.google-analytics.com';
20
- const GTM_HOST = 'www.googletagmanager.com';
21
- const ANALYTICS_JS_PATH = '/analytics.js';
22
- const GTAG_JS_PATH = '/gtag/js';
23
- const GTM_JS_PATH = '/gtm.js';
24
- // endpoints. Most of the time the default path (/collect) is used, but
25
- // occasionally an experimental endpoint is used when testing new features,
26
- // (e.g. /r/collect or /j/collect)
27
-
28
- const COLLECT_PATHS_REGEX = /^\/(\w+\/)?collect/;
29
-
30
- /*
31
- Copyright 2018 Google LLC
32
-
33
- Use of this source code is governed by an MIT-style
34
- license that can be found in the LICENSE file or at
35
- https://opensource.org/licenses/MIT.
36
- */
37
- /**
38
- * Creates the requestWillDequeue callback to be used with the background
39
- * sync queue plugin. The callback takes the failed request and adds the
40
- * `qt` param based on the current time, as well as applies any other
41
- * user-defined hit modifications.
42
- *
43
- * @param {Object} config See workbox.googleAnalytics.initialize.
44
- * @return {Function} The requestWillDequeu callback function.
45
- *
46
- * @private
47
- */
48
-
49
- const createOnSyncCallback = config => {
50
- return async ({
51
- queue
52
- }) => {
53
- let entry;
54
-
55
- while (entry = await queue.shiftRequest()) {
56
- const {
57
- request,
58
- timestamp
59
- } = entry;
60
- const url = new URL(request.url);
61
-
62
- try {
63
- // Measurement protocol requests can set their payload parameters in
64
- // either the URL query string (for GET requests) or the POST body.
65
- const params = request.method === 'POST' ? new URLSearchParams((await request.clone().text())) : url.searchParams; // Calculate the qt param, accounting for the fact that an existing
66
- // qt param may be present and should be updated rather than replaced.
67
-
68
- const originalHitTime = timestamp - (Number(params.get('qt')) || 0);
69
- const queueTime = Date.now() - originalHitTime; // Set the qt param prior to applying hitFilter or parameterOverrides.
70
-
71
- params.set('qt', queueTime); // Apply `paramterOverrideds`, if set.
72
-
73
- if (config.parameterOverrides) {
74
- for (const param of Object.keys(config.parameterOverrides)) {
75
- const value = config.parameterOverrides[param];
76
- params.set(param, value);
77
- }
78
- } // Apply `hitFilter`, if set.
79
-
80
-
81
- if (typeof config.hitFilter === 'function') {
82
- config.hitFilter.call(null, params);
83
- } // Retry the fetch. Ignore URL search params from the URL as they're
84
- // now in the post body.
85
-
86
-
87
- await fetch(new Request(url.origin + url.pathname, {
88
- body: params.toString(),
89
- method: 'POST',
90
- mode: 'cors',
91
- credentials: 'omit',
92
- headers: {
93
- 'Content-Type': 'text/plain'
94
- }
95
- }));
96
-
97
- {
98
- logger_mjs.logger.log(`Request for '${getFriendlyURL_mjs.getFriendlyURL(url.href)}'` + `has been replayed`);
99
- }
100
- } catch (err) {
101
- await queue.unshiftRequest(entry);
102
-
103
- {
104
- logger_mjs.logger.log(`Request for '${getFriendlyURL_mjs.getFriendlyURL(url.href)}'` + `failed to replay, putting it back in the queue.`);
105
- }
106
-
107
- throw err;
108
- }
109
- }
110
-
111
- {
112
- logger_mjs.logger.log(`All Google Analytics request successfully replayed; ` + `the queue is now empty!`);
113
- }
114
- };
115
- };
116
- /**
117
- * Creates GET and POST routes to catch failed Measurement Protocol hits.
118
- *
119
- * @param {Plugin} queuePlugin
120
- * @return {Array<Route>} The created routes.
121
- *
122
- * @private
123
- */
124
-
125
-
126
- const createCollectRoutes = queuePlugin => {
127
- const match = ({
128
- url
129
- }) => url.hostname === GOOGLE_ANALYTICS_HOST && COLLECT_PATHS_REGEX.test(url.pathname);
130
-
131
- const handler = new NetworkOnly_mjs.NetworkOnly({
132
- plugins: [queuePlugin]
133
- });
134
- return [new Route_mjs.Route(match, handler, 'GET'), new Route_mjs.Route(match, handler, 'POST')];
135
- };
136
- /**
137
- * Creates a route with a network first strategy for the analytics.js script.
138
- *
139
- * @param {string} cacheName
140
- * @return {Route} The created route.
141
- *
142
- * @private
143
- */
144
-
145
-
146
- const createAnalyticsJsRoute = cacheName => {
147
- const match = ({
148
- url
149
- }) => url.hostname === GOOGLE_ANALYTICS_HOST && url.pathname === ANALYTICS_JS_PATH;
150
-
151
- const handler = new NetworkFirst_mjs.NetworkFirst({
152
- cacheName
153
- });
154
- return new Route_mjs.Route(match, handler, 'GET');
155
- };
156
- /**
157
- * Creates a route with a network first strategy for the gtag.js script.
158
- *
159
- * @param {string} cacheName
160
- * @return {Route} The created route.
161
- *
162
- * @private
163
- */
164
-
165
-
166
- const createGtagJsRoute = cacheName => {
167
- const match = ({
168
- url
169
- }) => url.hostname === GTM_HOST && url.pathname === GTAG_JS_PATH;
170
-
171
- const handler = new NetworkFirst_mjs.NetworkFirst({
172
- cacheName
173
- });
174
- return new Route_mjs.Route(match, handler, 'GET');
175
- };
176
- /**
177
- * Creates a route with a network first strategy for the gtm.js script.
178
- *
179
- * @param {string} cacheName
180
- * @return {Route} The created route.
181
- *
182
- * @private
183
- */
184
-
185
-
186
- const createGtmJsRoute = cacheName => {
187
- const match = ({
188
- url
189
- }) => url.hostname === GTM_HOST && url.pathname === GTM_JS_PATH;
190
-
191
- const handler = new NetworkFirst_mjs.NetworkFirst({
192
- cacheName
193
- });
194
- return new Route_mjs.Route(match, handler, 'GET');
195
- };
196
- /**
197
- * @param {Object=} [options]
198
- * @param {Object} [options.cacheName] The cache name to store and retrieve
199
- * analytics.js. Defaults to the cache names provided by `workbox-core`.
200
- * @param {Object} [options.parameterOverrides]
201
- * [Measurement Protocol parameters](https://developers.google.com/analytics/devguides/collection/protocol/v1/parameters),
202
- * expressed as key/value pairs, to be added to replayed Google Analytics
203
- * requests. This can be used to, e.g., set a custom dimension indicating
204
- * that the request was replayed.
205
- * @param {Function} [options.hitFilter] A function that allows you to modify
206
- * the hit parameters prior to replaying
207
- * the hit. The function is invoked with the original hit's URLSearchParams
208
- * object as its only argument.
209
- *
210
- * @memberof workbox.googleAnalytics
211
- */
212
-
213
-
214
- const initialize = (options = {}) => {
215
- const cacheName = cacheNames_mjs.cacheNames.getGoogleAnalyticsName(options.cacheName);
216
- const queuePlugin = new Plugin_mjs.Plugin(QUEUE_NAME, {
217
- maxRetentionTime: MAX_RETENTION_TIME,
218
- onSync: createOnSyncCallback(options)
219
- });
220
- const routes = [createGtmJsRoute(cacheName), createAnalyticsJsRoute(cacheName), createGtagJsRoute(cacheName), ...createCollectRoutes(queuePlugin)];
221
- const router = new Router_mjs.Router();
222
-
223
- for (const route of routes) {
224
- router.registerRoute(route);
225
- }
226
-
227
- router.addFetchListener();
228
- };
229
-
230
- /*
231
- Copyright 2018 Google LLC
232
-
233
- Use of this source code is governed by an MIT-style
234
- license that can be found in the LICENSE file or at
235
- https://opensource.org/licenses/MIT.
236
- */
237
-
238
- exports.initialize = initialize;
239
-
240
- return exports;
241
-
242
- }({}, workbox.backgroundSync, workbox.core._private, workbox.core._private, workbox.core._private, workbox.routing, workbox.routing, workbox.strategies, workbox.strategies));
243
- //# sourceMappingURL=workbox-offline-ga.dev.js.map
@@ -1 +0,0 @@
1
- {"version":3,"file":"workbox-offline-ga.dev.js","sources":["../_version.mjs","../utils/constants.mjs","../initialize.mjs","../index.mjs"],"sourcesContent":["try{self['workbox:google-analytics:4.3.1']&&_()}catch(e){}// eslint-disable-line","/*\n Copyright 2018 Google LLC\n\n Use of this source code is governed by an MIT-style\n license that can be found in the LICENSE file or at\n https://opensource.org/licenses/MIT.\n*/\n\nimport '../_version.mjs';\n\nexport const QUEUE_NAME = 'workbox-google-analytics';\nexport const MAX_RETENTION_TIME = 60 * 48; // Two days in minutes\nexport const GOOGLE_ANALYTICS_HOST = 'www.google-analytics.com';\nexport const GTM_HOST = 'www.googletagmanager.com';\nexport const ANALYTICS_JS_PATH = '/analytics.js';\nexport const GTAG_JS_PATH = '/gtag/js';\nexport const GTM_JS_PATH = '/gtm.js';\nexport const COLLECT_DEFAULT_PATH = '/collect';\n\n// This RegExp matches all known Measurement Protocol single-hit collect\n// endpoints. Most of the time the default path (/collect) is used, but\n// occasionally an experimental endpoint is used when testing new features,\n// (e.g. /r/collect or /j/collect)\nexport const COLLECT_PATHS_REGEX = /^\\/(\\w+\\/)?collect/;\n","/*\n Copyright 2018 Google LLC\n\n Use of this source code is governed by an MIT-style\n license that can be found in the LICENSE file or at\n https://opensource.org/licenses/MIT.\n*/\n\nimport {Plugin} from 'workbox-background-sync/Plugin.mjs';\nimport {cacheNames} from 'workbox-core/_private/cacheNames.mjs';\nimport {getFriendlyURL} from 'workbox-core/_private/getFriendlyURL.mjs';\nimport {logger} from 'workbox-core/_private/logger.mjs';\nimport {Route} from 'workbox-routing/Route.mjs';\nimport {Router} from 'workbox-routing/Router.mjs';\nimport {NetworkFirst} from 'workbox-strategies/NetworkFirst.mjs';\nimport {NetworkOnly} from 'workbox-strategies/NetworkOnly.mjs';\nimport {\n QUEUE_NAME,\n MAX_RETENTION_TIME,\n GOOGLE_ANALYTICS_HOST,\n GTM_HOST,\n ANALYTICS_JS_PATH,\n GTAG_JS_PATH,\n GTM_JS_PATH,\n COLLECT_PATHS_REGEX,\n} from './utils/constants.mjs';\nimport './_version.mjs';\n\n/**\n * Creates the requestWillDequeue callback to be used with the background\n * sync queue plugin. The callback takes the failed request and adds the\n * `qt` param based on the current time, as well as applies any other\n * user-defined hit modifications.\n *\n * @param {Object} config See workbox.googleAnalytics.initialize.\n * @return {Function} The requestWillDequeu callback function.\n *\n * @private\n */\nconst createOnSyncCallback = (config) => {\n return async ({queue}) => {\n let entry;\n while (entry = await queue.shiftRequest()) {\n const {request, timestamp} = entry;\n const url = new URL(request.url);\n\n try {\n // Measurement protocol requests can set their payload parameters in\n // either the URL query string (for GET requests) or the POST body.\n const params = request.method === 'POST' ?\n new URLSearchParams(await request.clone().text()) :\n url.searchParams;\n\n // Calculate the qt param, accounting for the fact that an existing\n // qt param may be present and should be updated rather than replaced.\n const originalHitTime = timestamp - (Number(params.get('qt')) || 0);\n const queueTime = Date.now() - originalHitTime;\n\n // Set the qt param prior to applying hitFilter or parameterOverrides.\n params.set('qt', queueTime);\n\n // Apply `paramterOverrideds`, if set.\n if (config.parameterOverrides) {\n for (const param of Object.keys(config.parameterOverrides)) {\n const value = config.parameterOverrides[param];\n params.set(param, value);\n }\n }\n\n // Apply `hitFilter`, if set.\n if (typeof config.hitFilter === 'function') {\n config.hitFilter.call(null, params);\n }\n\n // Retry the fetch. Ignore URL search params from the URL as they're\n // now in the post body.\n await fetch(new Request(url.origin + url.pathname, {\n body: params.toString(),\n method: 'POST',\n mode: 'cors',\n credentials: 'omit',\n headers: {'Content-Type': 'text/plain'},\n }));\n\n\n if (process.env.NODE_ENV !== 'production') {\n logger.log(`Request for '${getFriendlyURL(url.href)}'` +\n `has been replayed`);\n }\n } catch (err) {\n await queue.unshiftRequest(entry);\n\n if (process.env.NODE_ENV !== 'production') {\n logger.log(`Request for '${getFriendlyURL(url.href)}'` +\n `failed to replay, putting it back in the queue.`);\n }\n throw err;\n }\n }\n if (process.env.NODE_ENV !== 'production') {\n logger.log(`All Google Analytics request successfully replayed; ` +\n `the queue is now empty!`);\n }\n };\n};\n\n/**\n * Creates GET and POST routes to catch failed Measurement Protocol hits.\n *\n * @param {Plugin} queuePlugin\n * @return {Array<Route>} The created routes.\n *\n * @private\n */\nconst createCollectRoutes = (queuePlugin) => {\n const match = ({url}) => url.hostname === GOOGLE_ANALYTICS_HOST &&\n COLLECT_PATHS_REGEX.test(url.pathname);\n\n const handler = new NetworkOnly({\n plugins: [queuePlugin],\n });\n\n return [\n new Route(match, handler, 'GET'),\n new Route(match, handler, 'POST'),\n ];\n};\n\n/**\n * Creates a route with a network first strategy for the analytics.js script.\n *\n * @param {string} cacheName\n * @return {Route} The created route.\n *\n * @private\n */\nconst createAnalyticsJsRoute = (cacheName) => {\n const match = ({url}) => url.hostname === GOOGLE_ANALYTICS_HOST &&\n url.pathname === ANALYTICS_JS_PATH;\n const handler = new NetworkFirst({cacheName});\n\n return new Route(match, handler, 'GET');\n};\n\n/**\n * Creates a route with a network first strategy for the gtag.js script.\n *\n * @param {string} cacheName\n * @return {Route} The created route.\n *\n * @private\n */\nconst createGtagJsRoute = (cacheName) => {\n const match = ({url}) => url.hostname === GTM_HOST &&\n url.pathname === GTAG_JS_PATH;\n const handler = new NetworkFirst({cacheName});\n\n return new Route(match, handler, 'GET');\n};\n\n/**\n * Creates a route with a network first strategy for the gtm.js script.\n *\n * @param {string} cacheName\n * @return {Route} The created route.\n *\n * @private\n */\nconst createGtmJsRoute = (cacheName) => {\n const match = ({url}) => url.hostname === GTM_HOST &&\n url.pathname === GTM_JS_PATH;\n const handler = new NetworkFirst({cacheName});\n\n return new Route(match, handler, 'GET');\n};\n\n/**\n * @param {Object=} [options]\n * @param {Object} [options.cacheName] The cache name to store and retrieve\n * analytics.js. Defaults to the cache names provided by `workbox-core`.\n * @param {Object} [options.parameterOverrides]\n * [Measurement Protocol parameters](https://developers.google.com/analytics/devguides/collection/protocol/v1/parameters),\n * expressed as key/value pairs, to be added to replayed Google Analytics\n * requests. This can be used to, e.g., set a custom dimension indicating\n * that the request was replayed.\n * @param {Function} [options.hitFilter] A function that allows you to modify\n * the hit parameters prior to replaying\n * the hit. The function is invoked with the original hit's URLSearchParams\n * object as its only argument.\n *\n * @memberof workbox.googleAnalytics\n */\nconst initialize = (options = {}) => {\n const cacheName = cacheNames.getGoogleAnalyticsName(options.cacheName);\n\n const queuePlugin = new Plugin(QUEUE_NAME, {\n maxRetentionTime: MAX_RETENTION_TIME,\n onSync: createOnSyncCallback(options),\n });\n\n const routes = [\n createGtmJsRoute(cacheName),\n createAnalyticsJsRoute(cacheName),\n createGtagJsRoute(cacheName),\n ...createCollectRoutes(queuePlugin),\n ];\n\n const router = new Router();\n for (const route of routes) {\n router.registerRoute(route);\n }\n\n router.addFetchListener();\n};\n\nexport {\n initialize,\n};\n","/*\n Copyright 2018 Google LLC\n\n Use of this source code is governed by an MIT-style\n license that can be found in the LICENSE file or at\n https://opensource.org/licenses/MIT.\n*/\n\nimport {initialize} from './initialize.mjs';\nimport './_version.mjs';\n\n\n/**\n * @namespace workbox.googleAnalytics\n */\n\nexport {\n initialize,\n};\n"],"names":["self","_","e","QUEUE_NAME","MAX_RETENTION_TIME","GOOGLE_ANALYTICS_HOST","GTM_HOST","ANALYTICS_JS_PATH","GTAG_JS_PATH","GTM_JS_PATH","COLLECT_PATHS_REGEX","createOnSyncCallback","config","queue","entry","shiftRequest","request","timestamp","url","URL","params","method","URLSearchParams","clone","text","searchParams","originalHitTime","Number","get","queueTime","Date","now","set","parameterOverrides","param","Object","keys","value","hitFilter","call","fetch","Request","origin","pathname","body","toString","mode","credentials","headers","logger","log","getFriendlyURL","href","err","unshiftRequest","createCollectRoutes","queuePlugin","match","hostname","test","handler","NetworkOnly","plugins","Route","createAnalyticsJsRoute","cacheName","NetworkFirst","createGtagJsRoute","createGtmJsRoute","initialize","options","cacheNames","getGoogleAnalyticsName","Plugin","maxRetentionTime","onSync","routes","router","Router","route","registerRoute","addFetchListener"],"mappings":";;;;EAAA,IAAG;EAACA,EAAAA,IAAI,CAAC,gCAAD,CAAJ,IAAwCC,CAAC,EAAzC;EAA4C,CAAhD,CAAgD,OAAMC,CAAN,EAAQ;;ECAxD;;;;;;;AAQA,EAEO,MAAMC,UAAU,GAAG,0BAAnB;AACP,EAAO,MAAMC,kBAAkB,GAAG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;EAACvC,IAAAA;EAAD,GAAD,KAAWA,GAAG,CAACwC,QAAJ,KAAiBpD,QAAjB,IACrBY,GAAG,CAACyB,QAAJ,KAAiBlC,WADrB;;EAEA,QAAMmD,OAAO,GAAG,IAAIM,6BAAJ,CAAiB;EAACD,IAAAA;EAAD,GAAjB,CAAhB;EAEA,SAAO,IAAIF,eAAJ,CAAUN,KAAV,EAAiBG,OAAjB,EAA0B,KAA1B,CAAP;EACD,CAND;EAQA;;;;;;;;;;;;;;;;;;AAgBA,QAAMS,UAAU,GAAG,CAACC,OAAO,GAAG,EAAX,KAAkB;EACnC,QAAML,SAAS,GAAGM,yBAAU,CAACC,sBAAX,CAAkCF,OAAO,CAACL,SAA1C,CAAlB;EAEA,QAAMT,WAAW,GAAG,IAAIiB,iBAAJ,CAAWtE,UAAX,EAAuB;EACzCuE,IAAAA,gBAAgB,EAAEtE,kBADuB;EAEzCuE,IAAAA,MAAM,EAAEhE,oBAAoB,CAAC2D,OAAD;EAFa,GAAvB,CAApB;EAKA,QAAMM,MAAM,GAAG,CACbR,gBAAgB,CAACH,SAAD,CADH,EAEbD,sBAAsB,CAACC,SAAD,CAFT,EAGbE,iBAAiB,CAACF,SAAD,CAHJ,EAIb,GAAGV,mBAAmB,CAACC,WAAD,CAJT,CAAf;EAOA,QAAMqB,MAAM,GAAG,IAAIC,iBAAJ,EAAf;;EACA,OAAK,MAAMC,KAAX,IAAoBH,MAApB,EAA4B;EAC1BC,IAAAA,MAAM,CAACG,aAAP,CAAqBD,KAArB;EACD;;EAEDF,EAAAA,MAAM,CAACI,gBAAP;EACD,CArBD;;EChMA;;;;;;;;;;;;;;;;"}
@@ -1,2 +0,0 @@
1
- this.workbox=this.workbox||{},this.workbox.googleAnalytics=function(e,t,o,n,a,c,w){"use strict";try{self["workbox:google-analytics:4.3.1"]&&_()}catch(e){}const r=/^\/(\w+\/)?collect/,s=e=>async({queue:t})=>{let o;for(;o=await t.shiftRequest();){const{request:n,timestamp:a}=o,c=new URL(n.url);try{const w="POST"===n.method?new URLSearchParams(await n.clone().text()):c.searchParams,r=a-(Number(w.get("qt"))||0),s=Date.now()-r;if(w.set("qt",s),e.parameterOverrides)for(const t of Object.keys(e.parameterOverrides)){const o=e.parameterOverrides[t];w.set(t,o)}"function"==typeof e.hitFilter&&e.hitFilter.call(null,w),await fetch(new Request(c.origin+c.pathname,{body:w.toString(),method:"POST",mode:"cors",credentials:"omit",headers:{"Content-Type":"text/plain"}}))}catch(e){throw await t.unshiftRequest(o),e}}},i=e=>{const t=({url:e})=>"www.google-analytics.com"===e.hostname&&r.test(e.pathname),o=new w.NetworkOnly({plugins:[e]});return[new n.Route(t,o,"GET"),new n.Route(t,o,"POST")]},l=e=>{const t=new c.NetworkFirst({cacheName:e});return new n.Route(({url:e})=>"www.google-analytics.com"===e.hostname&&"/analytics.js"===e.pathname,t,"GET")},m=e=>{const t=new c.NetworkFirst({cacheName:e});return new n.Route(({url:e})=>"www.googletagmanager.com"===e.hostname&&"/gtag/js"===e.pathname,t,"GET")},u=e=>{const t=new c.NetworkFirst({cacheName:e});return new n.Route(({url:e})=>"www.googletagmanager.com"===e.hostname&&"/gtm.js"===e.pathname,t,"GET")};return e.initialize=((e={})=>{const n=o.cacheNames.getGoogleAnalyticsName(e.cacheName),c=new t.Plugin("workbox-google-analytics",{maxRetentionTime:2880,onSync:s(e)}),w=[u(n),l(n),m(n),...i(c)],r=new a.Router;for(const e of w)r.registerRoute(e);r.addFetchListener()}),e}({},workbox.backgroundSync,workbox.core._private,workbox.routing,workbox.routing,workbox.strategies,workbox.strategies);
2
- //# sourceMappingURL=workbox-offline-ga.prod.js.map
@@ -1 +0,0 @@
1
- {"version":3,"file":"workbox-offline-ga.prod.js","sources":["../_version.mjs","../utils/constants.mjs","../initialize.mjs"],"sourcesContent":["try{self['workbox:google-analytics:4.3.1']&&_()}catch(e){}// eslint-disable-line","/*\n Copyright 2018 Google LLC\n\n Use of this source code is governed by an MIT-style\n license that can be found in the LICENSE file or at\n https://opensource.org/licenses/MIT.\n*/\n\nimport '../_version.mjs';\n\nexport const QUEUE_NAME = 'workbox-google-analytics';\nexport const MAX_RETENTION_TIME = 60 * 48; // Two days in minutes\nexport const GOOGLE_ANALYTICS_HOST = 'www.google-analytics.com';\nexport const GTM_HOST = 'www.googletagmanager.com';\nexport const ANALYTICS_JS_PATH = '/analytics.js';\nexport const GTAG_JS_PATH = '/gtag/js';\nexport const GTM_JS_PATH = '/gtm.js';\nexport const COLLECT_DEFAULT_PATH = '/collect';\n\n// This RegExp matches all known Measurement Protocol single-hit collect\n// endpoints. Most of the time the default path (/collect) is used, but\n// occasionally an experimental endpoint is used when testing new features,\n// (e.g. /r/collect or /j/collect)\nexport const COLLECT_PATHS_REGEX = /^\\/(\\w+\\/)?collect/;\n","/*\n Copyright 2018 Google LLC\n\n Use of this source code is governed by an MIT-style\n license that can be found in the LICENSE file or at\n https://opensource.org/licenses/MIT.\n*/\n\nimport {Plugin} from 'workbox-background-sync/Plugin.mjs';\nimport {cacheNames} from 'workbox-core/_private/cacheNames.mjs';\nimport {getFriendlyURL} from 'workbox-core/_private/getFriendlyURL.mjs';\nimport {logger} from 'workbox-core/_private/logger.mjs';\nimport {Route} from 'workbox-routing/Route.mjs';\nimport {Router} from 'workbox-routing/Router.mjs';\nimport {NetworkFirst} from 'workbox-strategies/NetworkFirst.mjs';\nimport {NetworkOnly} from 'workbox-strategies/NetworkOnly.mjs';\nimport {\n QUEUE_NAME,\n MAX_RETENTION_TIME,\n GOOGLE_ANALYTICS_HOST,\n GTM_HOST,\n ANALYTICS_JS_PATH,\n GTAG_JS_PATH,\n GTM_JS_PATH,\n COLLECT_PATHS_REGEX,\n} from './utils/constants.mjs';\nimport './_version.mjs';\n\n/**\n * Creates the requestWillDequeue callback to be used with the background\n * sync queue plugin. The callback takes the failed request and adds the\n * `qt` param based on the current time, as well as applies any other\n * user-defined hit modifications.\n *\n * @param {Object} config See workbox.googleAnalytics.initialize.\n * @return {Function} The requestWillDequeu callback function.\n *\n * @private\n */\nconst createOnSyncCallback = (config) => {\n return async ({queue}) => {\n let entry;\n while (entry = await queue.shiftRequest()) {\n const {request, timestamp} = entry;\n const url = new URL(request.url);\n\n try {\n // Measurement protocol requests can set their payload parameters in\n // either the URL query string (for GET requests) or the POST body.\n const params = request.method === 'POST' ?\n new URLSearchParams(await request.clone().text()) :\n url.searchParams;\n\n // Calculate the qt param, accounting for the fact that an existing\n // qt param may be present and should be updated rather than replaced.\n const originalHitTime = timestamp - (Number(params.get('qt')) || 0);\n const queueTime = Date.now() - originalHitTime;\n\n // Set the qt param prior to applying hitFilter or parameterOverrides.\n params.set('qt', queueTime);\n\n // Apply `paramterOverrideds`, if set.\n if (config.parameterOverrides) {\n for (const param of Object.keys(config.parameterOverrides)) {\n const value = config.parameterOverrides[param];\n params.set(param, value);\n }\n }\n\n // Apply `hitFilter`, if set.\n if (typeof config.hitFilter === 'function') {\n config.hitFilter.call(null, params);\n }\n\n // Retry the fetch. Ignore URL search params from the URL as they're\n // now in the post body.\n await fetch(new Request(url.origin + url.pathname, {\n body: params.toString(),\n method: 'POST',\n mode: 'cors',\n credentials: 'omit',\n headers: {'Content-Type': 'text/plain'},\n }));\n\n\n if (process.env.NODE_ENV !== 'production') {\n logger.log(`Request for '${getFriendlyURL(url.href)}'` +\n `has been replayed`);\n }\n } catch (err) {\n await queue.unshiftRequest(entry);\n\n if (process.env.NODE_ENV !== 'production') {\n logger.log(`Request for '${getFriendlyURL(url.href)}'` +\n `failed to replay, putting it back in the queue.`);\n }\n throw err;\n }\n }\n if (process.env.NODE_ENV !== 'production') {\n logger.log(`All Google Analytics request successfully replayed; ` +\n `the queue is now empty!`);\n }\n };\n};\n\n/**\n * Creates GET and POST routes to catch failed Measurement Protocol hits.\n *\n * @param {Plugin} queuePlugin\n * @return {Array<Route>} The created routes.\n *\n * @private\n */\nconst createCollectRoutes = (queuePlugin) => {\n const match = ({url}) => url.hostname === GOOGLE_ANALYTICS_HOST &&\n COLLECT_PATHS_REGEX.test(url.pathname);\n\n const handler = new NetworkOnly({\n plugins: [queuePlugin],\n });\n\n return [\n new Route(match, handler, 'GET'),\n new Route(match, handler, 'POST'),\n ];\n};\n\n/**\n * Creates a route with a network first strategy for the analytics.js script.\n *\n * @param {string} cacheName\n * @return {Route} The created route.\n *\n * @private\n */\nconst createAnalyticsJsRoute = (cacheName) => {\n const match = ({url}) => url.hostname === GOOGLE_ANALYTICS_HOST &&\n url.pathname === ANALYTICS_JS_PATH;\n const handler = new NetworkFirst({cacheName});\n\n return new Route(match, handler, 'GET');\n};\n\n/**\n * Creates a route with a network first strategy for the gtag.js script.\n *\n * @param {string} cacheName\n * @return {Route} The created route.\n *\n * @private\n */\nconst createGtagJsRoute = (cacheName) => {\n const match = ({url}) => url.hostname === GTM_HOST &&\n url.pathname === GTAG_JS_PATH;\n const handler = new NetworkFirst({cacheName});\n\n return new Route(match, handler, 'GET');\n};\n\n/**\n * Creates a route with a network first strategy for the gtm.js script.\n *\n * @param {string} cacheName\n * @return {Route} The created route.\n *\n * @private\n */\nconst createGtmJsRoute = (cacheName) => {\n const match = ({url}) => url.hostname === GTM_HOST &&\n url.pathname === GTM_JS_PATH;\n const handler = new NetworkFirst({cacheName});\n\n return new Route(match, handler, 'GET');\n};\n\n/**\n * @param {Object=} [options]\n * @param {Object} [options.cacheName] The cache name to store and retrieve\n * analytics.js. Defaults to the cache names provided by `workbox-core`.\n * @param {Object} [options.parameterOverrides]\n * [Measurement Protocol parameters](https://developers.google.com/analytics/devguides/collection/protocol/v1/parameters),\n * expressed as key/value pairs, to be added to replayed Google Analytics\n * requests. This can be used to, e.g., set a custom dimension indicating\n * that the request was replayed.\n * @param {Function} [options.hitFilter] A function that allows you to modify\n * the hit parameters prior to replaying\n * the hit. The function is invoked with the original hit's URLSearchParams\n * object as its only argument.\n *\n * @memberof workbox.googleAnalytics\n */\nconst initialize = (options = {}) => {\n const cacheName = cacheNames.getGoogleAnalyticsName(options.cacheName);\n\n const queuePlugin = new Plugin(QUEUE_NAME, {\n maxRetentionTime: MAX_RETENTION_TIME,\n onSync: createOnSyncCallback(options),\n });\n\n const routes = [\n createGtmJsRoute(cacheName),\n createAnalyticsJsRoute(cacheName),\n createGtagJsRoute(cacheName),\n ...createCollectRoutes(queuePlugin),\n ];\n\n const router = new Router();\n for (const route of routes) {\n router.registerRoute(route);\n }\n\n router.addFetchListener();\n};\n\nexport {\n initialize,\n};\n"],"names":["self","_","e","COLLECT_PATHS_REGEX","createOnSyncCallback","config","async","queue","entry","shiftRequest","request","timestamp","url","URL","params","method","URLSearchParams","clone","text","searchParams","originalHitTime","Number","get","queueTime","Date","now","set","parameterOverrides","param","Object","keys","value","hitFilter","call","fetch","Request","origin","pathname","body","toString","mode","credentials","headers","err","unshiftRequest","createCollectRoutes","queuePlugin","match","hostname","test","handler","NetworkOnly","plugins","Route","createAnalyticsJsRoute","cacheName","NetworkFirst","createGtagJsRoute","createGtmJsRoute","options","cacheNames","getGoogleAnalyticsName","Plugin","maxRetentionTime","onSync","routes","router","Router","route","registerRoute","addFetchListener"],"mappings":"gGAAA,IAAIA,KAAK,mCAAmCC,IAAI,MAAMC,ICU/C,MAaMC,EAAsB,qBCgB7BC,EAAwBC,GACrBC,OAAQC,MAAAA,UACTC,OACGA,QAAcD,EAAME,gBAAgB,OACnCC,QAACA,EAADC,UAAUA,GAAaH,EACvBI,EAAM,IAAIC,IAAIH,EAAQE,eAKpBE,EAA4B,SAAnBJ,EAAQK,OACnB,IAAIC,sBAAsBN,EAAQO,QAAQC,QAC1CN,EAAIO,aAIFC,EAAkBT,GAAaU,OAAOP,EAAOQ,IAAI,QAAU,GAC3DC,EAAYC,KAAKC,MAAQL,KAG/BN,EAAOY,IAAI,KAAMH,GAGblB,EAAOsB,uBACJ,MAAMC,KAASC,OAAOC,KAAKzB,EAAOsB,oBAAqB,OACpDI,EAAQ1B,EAAOsB,mBAAmBC,GACxCd,EAAOY,IAAIE,EAAOG,GAKU,mBAArB1B,EAAO2B,WAChB3B,EAAO2B,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"}
@@ -1,989 +0,0 @@
1
- this.workbox = this.workbox || {};
2
- this.workbox.precaching = (function (exports, assert_mjs, cacheNames_mjs, getFriendlyURL_mjs, logger_mjs, cacheWrapper_mjs, fetchWrapper_mjs, WorkboxError_mjs) {
3
- 'use strict';
4
-
5
- try {
6
- self['workbox:precaching:4.3.1'] && _();
7
- } catch (e) {} // eslint-disable-line
8
-
9
- /*
10
- Copyright 2019 Google LLC
11
-
12
- Use of this source code is governed by an MIT-style
13
- license that can be found in the LICENSE file or at
14
- https://opensource.org/licenses/MIT.
15
- */
16
- const plugins = [];
17
- const precachePlugins = {
18
- /*
19
- * @return {Array}
20
- * @private
21
- */
22
- get() {
23
- return plugins;
24
- },
25
-
26
- /*
27
- * @param {Array} newPlugins
28
- * @private
29
- */
30
- add(newPlugins) {
31
- plugins.push(...newPlugins);
32
- }
33
-
34
- };
35
-
36
- /*
37
- Copyright 2019 Google LLC
38
-
39
- Use of this source code is governed by an MIT-style
40
- license that can be found in the LICENSE file or at
41
- https://opensource.org/licenses/MIT.
42
- */
43
- /**
44
- * Adds plugins to precaching.
45
- *
46
- * @param {Array<Object>} newPlugins
47
- *
48
- * @alias workbox.precaching.addPlugins
49
- */
50
-
51
- const addPlugins = newPlugins => {
52
- precachePlugins.add(newPlugins);
53
- };
54
-
55
- /*
56
- Copyright 2018 Google LLC
57
-
58
- Use of this source code is governed by an MIT-style
59
- license that can be found in the LICENSE file or at
60
- https://opensource.org/licenses/MIT.
61
- */
62
- /**
63
- * @param {Response} response
64
- * @return {Response}
65
- *
66
- * @private
67
- * @memberof module:workbox-precaching
68
- */
69
-
70
- async function cleanRedirect(response) {
71
- const clonedResponse = response.clone(); // Not all browsers support the Response.body stream, so fall back
72
- // to reading the entire body into memory as a blob.
73
-
74
- const bodyPromise = 'body' in clonedResponse ? Promise.resolve(clonedResponse.body) : clonedResponse.blob();
75
- const body = await bodyPromise; // new Response() is happy when passed either a stream or a Blob.
76
-
77
- return new Response(body, {
78
- headers: clonedResponse.headers,
79
- status: clonedResponse.status,
80
- statusText: clonedResponse.statusText
81
- });
82
- }
83
-
84
- /*
85
- Copyright 2018 Google LLC
86
-
87
- Use of this source code is governed by an MIT-style
88
- license that can be found in the LICENSE file or at
89
- https://opensource.org/licenses/MIT.
90
- */
91
-
92
- const REVISION_SEARCH_PARAM = '__WB_REVISION__';
93
- /**
94
- * Converts a manifest entry into a versioned URL suitable for precaching.
95
- *
96
- * @param {Object} entry
97
- * @return {string} A URL with versioning info.
98
- *
99
- * @private
100
- * @memberof module:workbox-precaching
101
- */
102
-
103
- function createCacheKey(entry) {
104
- if (!entry) {
105
- throw new WorkboxError_mjs.WorkboxError('add-to-cache-list-unexpected-type', {
106
- entry
107
- });
108
- } // If a precache manifest entry is a string, it's assumed to be a versioned
109
- // URL, like '/app.abcd1234.js'. Return as-is.
110
-
111
-
112
- if (typeof entry === 'string') {
113
- const urlObject = new URL(entry, location);
114
- return {
115
- cacheKey: urlObject.href,
116
- url: urlObject.href
117
- };
118
- }
119
-
120
- const {
121
- revision,
122
- url
123
- } = entry;
124
-
125
- if (!url) {
126
- throw new WorkboxError_mjs.WorkboxError('add-to-cache-list-unexpected-type', {
127
- entry
128
- });
129
- } // If there's just a URL and no revision, then it's also assumed to be a
130
- // versioned URL.
131
-
132
-
133
- if (!revision) {
134
- const urlObject = new URL(url, location);
135
- return {
136
- cacheKey: urlObject.href,
137
- url: urlObject.href
138
- };
139
- } // Otherwise, construct a properly versioned URL using the custom Workbox
140
- // search parameter along with the revision info.
141
-
142
-
143
- const originalURL = new URL(url, location);
144
- const cacheKeyURL = new URL(url, location);
145
- cacheKeyURL.searchParams.set(REVISION_SEARCH_PARAM, revision);
146
- return {
147
- cacheKey: cacheKeyURL.href,
148
- url: originalURL.href
149
- };
150
- }
151
-
152
- /*
153
- Copyright 2018 Google LLC
154
-
155
- Use of this source code is governed by an MIT-style
156
- license that can be found in the LICENSE file or at
157
- https://opensource.org/licenses/MIT.
158
- */
159
-
160
- const logGroup = (groupTitle, deletedURLs) => {
161
- logger_mjs.logger.groupCollapsed(groupTitle);
162
-
163
- for (const url of deletedURLs) {
164
- logger_mjs.logger.log(url);
165
- }
166
-
167
- logger_mjs.logger.groupEnd();
168
- };
169
- /**
170
- * @param {Array<string>} deletedURLs
171
- *
172
- * @private
173
- * @memberof module:workbox-precaching
174
- */
175
-
176
-
177
- function printCleanupDetails(deletedURLs) {
178
- const deletionCount = deletedURLs.length;
179
-
180
- if (deletionCount > 0) {
181
- logger_mjs.logger.groupCollapsed(`During precaching cleanup, ` + `${deletionCount} cached ` + `request${deletionCount === 1 ? ' was' : 's were'} deleted.`);
182
- logGroup('Deleted Cache Requests', deletedURLs);
183
- logger_mjs.logger.groupEnd();
184
- }
185
- }
186
-
187
- /*
188
- Copyright 2018 Google LLC
189
-
190
- Use of this source code is governed by an MIT-style
191
- license that can be found in the LICENSE file or at
192
- https://opensource.org/licenses/MIT.
193
- */
194
- /**
195
- * @param {string} groupTitle
196
- * @param {Array<string>} urls
197
- *
198
- * @private
199
- */
200
-
201
- function _nestedGroup(groupTitle, urls) {
202
- if (urls.length === 0) {
203
- return;
204
- }
205
-
206
- logger_mjs.logger.groupCollapsed(groupTitle);
207
-
208
- for (const url of urls) {
209
- logger_mjs.logger.log(url);
210
- }
211
-
212
- logger_mjs.logger.groupEnd();
213
- }
214
- /**
215
- * @param {Array<string>} urlsToPrecache
216
- * @param {Array<string>} urlsAlreadyPrecached
217
- *
218
- * @private
219
- * @memberof module:workbox-precaching
220
- */
221
-
222
-
223
- function printInstallDetails(urlsToPrecache, urlsAlreadyPrecached) {
224
- const precachedCount = urlsToPrecache.length;
225
- const alreadyPrecachedCount = urlsAlreadyPrecached.length;
226
-
227
- if (precachedCount || alreadyPrecachedCount) {
228
- let message = `Precaching ${precachedCount} file${precachedCount === 1 ? '' : 's'}.`;
229
-
230
- if (alreadyPrecachedCount > 0) {
231
- message += ` ${alreadyPrecachedCount} ` + `file${alreadyPrecachedCount === 1 ? ' is' : 's are'} already cached.`;
232
- }
233
-
234
- logger_mjs.logger.groupCollapsed(message);
235
-
236
- _nestedGroup(`View newly precached URLs.`, urlsToPrecache);
237
-
238
- _nestedGroup(`View previously precached URLs.`, urlsAlreadyPrecached);
239
-
240
- logger_mjs.logger.groupEnd();
241
- }
242
- }
243
-
244
- /*
245
- Copyright 2018 Google LLC
246
-
247
- Use of this source code is governed by an MIT-style
248
- license that can be found in the LICENSE file or at
249
- https://opensource.org/licenses/MIT.
250
- */
251
- /**
252
- * Performs efficient precaching of assets.
253
- *
254
- * @memberof module:workbox-precaching
255
- */
256
-
257
- class PrecacheController {
258
- /**
259
- * Create a new PrecacheController.
260
- *
261
- * @param {string} [cacheName] An optional name for the cache, to override
262
- * the default precache name.
263
- */
264
- constructor(cacheName) {
265
- this._cacheName = cacheNames_mjs.cacheNames.getPrecacheName(cacheName);
266
- this._urlsToCacheKeys = new Map();
267
- }
268
- /**
269
- * This method will add items to the precache list, removing duplicates
270
- * and ensuring the information is valid.
271
- *
272
- * @param {
273
- * Array<module:workbox-precaching.PrecacheController.PrecacheEntry|string>
274
- * } entries Array of entries to precache.
275
- */
276
-
277
-
278
- addToCacheList(entries) {
279
- {
280
- assert_mjs.assert.isArray(entries, {
281
- moduleName: 'workbox-precaching',
282
- className: 'PrecacheController',
283
- funcName: 'addToCacheList',
284
- paramName: 'entries'
285
- });
286
- }
287
-
288
- for (const entry of entries) {
289
- const {
290
- cacheKey,
291
- url
292
- } = createCacheKey(entry);
293
-
294
- if (this._urlsToCacheKeys.has(url) && this._urlsToCacheKeys.get(url) !== cacheKey) {
295
- throw new WorkboxError_mjs.WorkboxError('add-to-cache-list-conflicting-entries', {
296
- firstEntry: this._urlsToCacheKeys.get(url),
297
- secondEntry: cacheKey
298
- });
299
- }
300
-
301
- this._urlsToCacheKeys.set(url, cacheKey);
302
- }
303
- }
304
- /**
305
- * Precaches new and updated assets. Call this method from the service worker
306
- * install event.
307
- *
308
- * @param {Object} options
309
- * @param {Event} [options.event] The install event (if needed).
310
- * @param {Array<Object>} [options.plugins] Plugins to be used for fetching
311
- * and caching during install.
312
- * @return {Promise<workbox.precaching.InstallResult>}
313
- */
314
-
315
-
316
- async install({
317
- event,
318
- plugins
319
- } = {}) {
320
- {
321
- if (plugins) {
322
- assert_mjs.assert.isArray(plugins, {
323
- moduleName: 'workbox-precaching',
324
- className: 'PrecacheController',
325
- funcName: 'install',
326
- paramName: 'plugins'
327
- });
328
- }
329
- }
330
-
331
- const urlsToPrecache = [];
332
- const urlsAlreadyPrecached = [];
333
- const cache = await caches.open(this._cacheName);
334
- const alreadyCachedRequests = await cache.keys();
335
- const alreadyCachedURLs = new Set(alreadyCachedRequests.map(request => request.url));
336
-
337
- for (const cacheKey of this._urlsToCacheKeys.values()) {
338
- if (alreadyCachedURLs.has(cacheKey)) {
339
- urlsAlreadyPrecached.push(cacheKey);
340
- } else {
341
- urlsToPrecache.push(cacheKey);
342
- }
343
- }
344
-
345
- const precacheRequests = urlsToPrecache.map(url => {
346
- return this._addURLToCache({
347
- event,
348
- plugins,
349
- url
350
- });
351
- });
352
- await Promise.all(precacheRequests);
353
-
354
- {
355
- printInstallDetails(urlsToPrecache, urlsAlreadyPrecached);
356
- }
357
-
358
- return {
359
- updatedURLs: urlsToPrecache,
360
- notUpdatedURLs: urlsAlreadyPrecached
361
- };
362
- }
363
- /**
364
- * Deletes assets that are no longer present in the current precache manifest.
365
- * Call this method from the service worker activate event.
366
- *
367
- * @return {Promise<workbox.precaching.CleanupResult>}
368
- */
369
-
370
-
371
- async activate() {
372
- const cache = await caches.open(this._cacheName);
373
- const currentlyCachedRequests = await cache.keys();
374
- const expectedCacheKeys = new Set(this._urlsToCacheKeys.values());
375
- const deletedURLs = [];
376
-
377
- for (const request of currentlyCachedRequests) {
378
- if (!expectedCacheKeys.has(request.url)) {
379
- await cache.delete(request);
380
- deletedURLs.push(request.url);
381
- }
382
- }
383
-
384
- {
385
- printCleanupDetails(deletedURLs);
386
- }
387
-
388
- return {
389
- deletedURLs
390
- };
391
- }
392
- /**
393
- * Requests the entry and saves it to the cache if the response is valid.
394
- * By default, any response with a status code of less than 400 (including
395
- * opaque responses) is considered valid.
396
- *
397
- * If you need to use custom criteria to determine what's valid and what
398
- * isn't, then pass in an item in `options.plugins` that implements the
399
- * `cacheWillUpdate()` lifecycle event.
400
- *
401
- * @private
402
- * @param {Object} options
403
- * @param {string} options.url The URL to fetch and cache.
404
- * @param {Event} [options.event] The install event (if passed).
405
- * @param {Array<Object>} [options.plugins] An array of plugins to apply to
406
- * fetch and caching.
407
- */
408
-
409
-
410
- async _addURLToCache({
411
- url,
412
- event,
413
- plugins
414
- }) {
415
- const request = new Request(url, {
416
- credentials: 'same-origin'
417
- });
418
- let response = await fetchWrapper_mjs.fetchWrapper.fetch({
419
- event,
420
- plugins,
421
- request
422
- }); // Allow developers to override the default logic about what is and isn't
423
- // valid by passing in a plugin implementing cacheWillUpdate(), e.g.
424
- // a workbox.cacheableResponse.Plugin instance.
425
-
426
- let cacheWillUpdateCallback;
427
-
428
- for (const plugin of plugins || []) {
429
- if ('cacheWillUpdate' in plugin) {
430
- cacheWillUpdateCallback = plugin.cacheWillUpdate.bind(plugin);
431
- }
432
- }
433
-
434
- const isValidResponse = cacheWillUpdateCallback ? // Use a callback if provided. It returns a truthy value if valid.
435
- cacheWillUpdateCallback({
436
- event,
437
- request,
438
- response
439
- }) : // Otherwise, default to considering any response status under 400 valid.
440
- // This includes, by default, considering opaque responses valid.
441
- response.status < 400; // Consider this a failure, leading to the `install` handler failing, if
442
- // we get back an invalid response.
443
-
444
- if (!isValidResponse) {
445
- throw new WorkboxError_mjs.WorkboxError('bad-precaching-response', {
446
- url,
447
- status: response.status
448
- });
449
- }
450
-
451
- if (response.redirected) {
452
- response = await cleanRedirect(response);
453
- }
454
-
455
- await cacheWrapper_mjs.cacheWrapper.put({
456
- event,
457
- plugins,
458
- request,
459
- response,
460
- cacheName: this._cacheName,
461
- matchOptions: {
462
- ignoreSearch: true
463
- }
464
- });
465
- }
466
- /**
467
- * Returns a mapping of a precached URL to the corresponding cache key, taking
468
- * into account the revision information for the URL.
469
- *
470
- * @return {Map<string, string>} A URL to cache key mapping.
471
- */
472
-
473
-
474
- getURLsToCacheKeys() {
475
- return this._urlsToCacheKeys;
476
- }
477
- /**
478
- * Returns a list of all the URLs that have been precached by the current
479
- * service worker.
480
- *
481
- * @return {Array<string>} The precached URLs.
482
- */
483
-
484
-
485
- getCachedURLs() {
486
- return [...this._urlsToCacheKeys.keys()];
487
- }
488
- /**
489
- * Returns the cache key used for storing a given URL. If that URL is
490
- * unversioned, like `/index.html', then the cache key will be the original
491
- * URL with a search parameter appended to it.
492
- *
493
- * @param {string} url A URL whose cache key you want to look up.
494
- * @return {string} The versioned URL that corresponds to a cache key
495
- * for the original URL, or undefined if that URL isn't precached.
496
- */
497
-
498
-
499
- getCacheKeyForURL(url) {
500
- const urlObject = new URL(url, location);
501
- return this._urlsToCacheKeys.get(urlObject.href);
502
- }
503
-
504
- }
505
-
506
- /*
507
- Copyright 2019 Google LLC
508
-
509
- Use of this source code is governed by an MIT-style
510
- license that can be found in the LICENSE file or at
511
- https://opensource.org/licenses/MIT.
512
- */
513
- let precacheController;
514
- /**
515
- * @return {PrecacheController}
516
- * @private
517
- */
518
-
519
- const getOrCreatePrecacheController = () => {
520
- if (!precacheController) {
521
- precacheController = new PrecacheController();
522
- }
523
-
524
- return precacheController;
525
- };
526
-
527
- /*
528
- Copyright 2018 Google LLC
529
-
530
- Use of this source code is governed by an MIT-style
531
- license that can be found in the LICENSE file or at
532
- https://opensource.org/licenses/MIT.
533
- */
534
- /**
535
- * Removes any URL search parameters that should be ignored.
536
- *
537
- * @param {URL} urlObject The original URL.
538
- * @param {Array<RegExp>} ignoreURLParametersMatching RegExps to test against
539
- * each search parameter name. Matches mean that the search parameter should be
540
- * ignored.
541
- * @return {URL} The URL with any ignored search parameters removed.
542
- *
543
- * @private
544
- * @memberof module:workbox-precaching
545
- */
546
-
547
- function removeIgnoredSearchParams(urlObject, ignoreURLParametersMatching) {
548
- // Convert the iterable into an array at the start of the loop to make sure
549
- // deletion doesn't mess up iteration.
550
- for (const paramName of [...urlObject.searchParams.keys()]) {
551
- if (ignoreURLParametersMatching.some(regExp => regExp.test(paramName))) {
552
- urlObject.searchParams.delete(paramName);
553
- }
554
- }
555
-
556
- return urlObject;
557
- }
558
-
559
- /*
560
- Copyright 2019 Google LLC
561
-
562
- Use of this source code is governed by an MIT-style
563
- license that can be found in the LICENSE file or at
564
- https://opensource.org/licenses/MIT.
565
- */
566
- /**
567
- * Generator function that yields possible variations on the original URL to
568
- * check, one at a time.
569
- *
570
- * @param {string} url
571
- * @param {Object} options
572
- *
573
- * @private
574
- * @memberof module:workbox-precaching
575
- */
576
-
577
- function* generateURLVariations(url, {
578
- ignoreURLParametersMatching,
579
- directoryIndex,
580
- cleanURLs,
581
- urlManipulation
582
- } = {}) {
583
- const urlObject = new URL(url, location);
584
- urlObject.hash = '';
585
- yield urlObject.href;
586
- const urlWithoutIgnoredParams = removeIgnoredSearchParams(urlObject, ignoreURLParametersMatching);
587
- yield urlWithoutIgnoredParams.href;
588
-
589
- if (directoryIndex && urlWithoutIgnoredParams.pathname.endsWith('/')) {
590
- const directoryURL = new URL(urlWithoutIgnoredParams);
591
- directoryURL.pathname += directoryIndex;
592
- yield directoryURL.href;
593
- }
594
-
595
- if (cleanURLs) {
596
- const cleanURL = new URL(urlWithoutIgnoredParams);
597
- cleanURL.pathname += '.html';
598
- yield cleanURL.href;
599
- }
600
-
601
- if (urlManipulation) {
602
- const additionalURLs = urlManipulation({
603
- url: urlObject
604
- });
605
-
606
- for (const urlToAttempt of additionalURLs) {
607
- yield urlToAttempt.href;
608
- }
609
- }
610
- }
611
-
612
- /*
613
- Copyright 2019 Google LLC
614
-
615
- Use of this source code is governed by an MIT-style
616
- license that can be found in the LICENSE file or at
617
- https://opensource.org/licenses/MIT.
618
- */
619
- /**
620
- * This function will take the request URL and manipulate it based on the
621
- * configuration options.
622
- *
623
- * @param {string} url
624
- * @param {Object} options
625
- * @return {string} Returns the URL in the cache that matches the request,
626
- * if possible.
627
- *
628
- * @private
629
- */
630
-
631
- const getCacheKeyForURL = (url, options) => {
632
- const precacheController = getOrCreatePrecacheController();
633
- const urlsToCacheKeys = precacheController.getURLsToCacheKeys();
634
-
635
- for (const possibleURL of generateURLVariations(url, options)) {
636
- const possibleCacheKey = urlsToCacheKeys.get(possibleURL);
637
-
638
- if (possibleCacheKey) {
639
- return possibleCacheKey;
640
- }
641
- }
642
- };
643
-
644
- /*
645
- Copyright 2019 Google LLC
646
-
647
- Use of this source code is governed by an MIT-style
648
- license that can be found in the LICENSE file or at
649
- https://opensource.org/licenses/MIT.
650
- */
651
- /**
652
- * Adds a `fetch` listener to the service worker that will
653
- * respond to
654
- * [network requests]{@link https://developer.mozilla.org/en-US/docs/Web/API/Service_Worker_API/Using_Service_Workers#Custom_responses_to_requests}
655
- * with precached assets.
656
- *
657
- * Requests for assets that aren't precached, the `FetchEvent` will not be
658
- * responded to, allowing the event to fall through to other `fetch` event
659
- * listeners.
660
- *
661
- * NOTE: when called more than once this method will replace the previously set
662
- * configuration options. Calling it more than once is not recommended outside
663
- * of tests.
664
- *
665
- * @private
666
- * @param {Object} options
667
- * @param {string} [options.directoryIndex=index.html] The `directoryIndex` will
668
- * check cache entries for a URLs ending with '/' to see if there is a hit when
669
- * appending the `directoryIndex` value.
670
- * @param {Array<RegExp>} [options.ignoreURLParametersMatching=[/^utm_/]] An
671
- * array of regex's to remove search params when looking for a cache match.
672
- * @param {boolean} [options.cleanURLs=true] The `cleanURLs` option will
673
- * check the cache for the URL with a `.html` added to the end of the end.
674
- * @param {workbox.precaching~urlManipulation} [options.urlManipulation]
675
- * This is a function that should take a URL and return an array of
676
- * alternative URL's that should be checked for precache matches.
677
- */
678
-
679
- const addFetchListener = ({
680
- ignoreURLParametersMatching = [/^utm_/],
681
- directoryIndex = 'index.html',
682
- cleanURLs = true,
683
- urlManipulation = null
684
- } = {}) => {
685
- const cacheName = cacheNames_mjs.cacheNames.getPrecacheName();
686
- addEventListener('fetch', event => {
687
- const precachedURL = getCacheKeyForURL(event.request.url, {
688
- cleanURLs,
689
- directoryIndex,
690
- ignoreURLParametersMatching,
691
- urlManipulation
692
- });
693
-
694
- if (!precachedURL) {
695
- {
696
- logger_mjs.logger.debug(`Precaching did not find a match for ` + getFriendlyURL_mjs.getFriendlyURL(event.request.url));
697
- }
698
-
699
- return;
700
- }
701
-
702
- let responsePromise = caches.open(cacheName).then(cache => {
703
- return cache.match(precachedURL);
704
- }).then(cachedResponse => {
705
- if (cachedResponse) {
706
- return cachedResponse;
707
- } // Fall back to the network if we don't have a cached response
708
- // (perhaps due to manual cache cleanup).
709
-
710
-
711
- {
712
- logger_mjs.logger.warn(`The precached response for ` + `${getFriendlyURL_mjs.getFriendlyURL(precachedURL)} in ${cacheName} was not found. ` + `Falling back to the network instead.`);
713
- }
714
-
715
- return fetch(precachedURL);
716
- });
717
-
718
- {
719
- responsePromise = responsePromise.then(response => {
720
- // Workbox is going to handle the route.
721
- // print the routing details to the console.
722
- logger_mjs.logger.groupCollapsed(`Precaching is responding to: ` + getFriendlyURL_mjs.getFriendlyURL(event.request.url));
723
- logger_mjs.logger.log(`Serving the precached url: ${precachedURL}`);
724
- logger_mjs.logger.groupCollapsed(`View request details here.`);
725
- logger_mjs.logger.log(event.request);
726
- logger_mjs.logger.groupEnd();
727
- logger_mjs.logger.groupCollapsed(`View response details here.`);
728
- logger_mjs.logger.log(response);
729
- logger_mjs.logger.groupEnd();
730
- logger_mjs.logger.groupEnd();
731
- return response;
732
- });
733
- }
734
-
735
- event.respondWith(responsePromise);
736
- });
737
- };
738
-
739
- /*
740
- Copyright 2019 Google LLC
741
- Use of this source code is governed by an MIT-style
742
- license that can be found in the LICENSE file or at
743
- https://opensource.org/licenses/MIT.
744
- */
745
- let listenerAdded = false;
746
- /**
747
- * Add a `fetch` listener to the service worker that will
748
- * respond to
749
- * [network requests]{@link https://developer.mozilla.org/en-US/docs/Web/API/Service_Worker_API/Using_Service_Workers#Custom_responses_to_requests}
750
- * with precached assets.
751
- *
752
- * Requests for assets that aren't precached, the `FetchEvent` will not be
753
- * responded to, allowing the event to fall through to other `fetch` event
754
- * listeners.
755
- *
756
- * @param {Object} options
757
- * @param {string} [options.directoryIndex=index.html] The `directoryIndex` will
758
- * check cache entries for a URLs ending with '/' to see if there is a hit when
759
- * appending the `directoryIndex` value.
760
- * @param {Array<RegExp>} [options.ignoreURLParametersMatching=[/^utm_/]] An
761
- * array of regex's to remove search params when looking for a cache match.
762
- * @param {boolean} [options.cleanURLs=true] The `cleanURLs` option will
763
- * check the cache for the URL with a `.html` added to the end of the end.
764
- * @param {workbox.precaching~urlManipulation} [options.urlManipulation]
765
- * This is a function that should take a URL and return an array of
766
- * alternative URL's that should be checked for precache matches.
767
- *
768
- * @alias workbox.precaching.addRoute
769
- */
770
-
771
- const addRoute = options => {
772
- if (!listenerAdded) {
773
- addFetchListener(options);
774
- listenerAdded = true;
775
- }
776
- };
777
-
778
- /*
779
- Copyright 2018 Google LLC
780
-
781
- Use of this source code is governed by an MIT-style
782
- license that can be found in the LICENSE file or at
783
- https://opensource.org/licenses/MIT.
784
- */
785
- const SUBSTRING_TO_FIND = '-precache-';
786
- /**
787
- * Cleans up incompatible precaches that were created by older versions of
788
- * Workbox, by a service worker registered under the current scope.
789
- *
790
- * This is meant to be called as part of the `activate` event.
791
- *
792
- * This should be safe to use as long as you don't include `substringToFind`
793
- * (defaulting to `-precache-`) in your non-precache cache names.
794
- *
795
- * @param {string} currentPrecacheName The cache name currently in use for
796
- * precaching. This cache won't be deleted.
797
- * @param {string} [substringToFind='-precache-'] Cache names which include this
798
- * substring will be deleted (excluding `currentPrecacheName`).
799
- * @return {Array<string>} A list of all the cache names that were deleted.
800
- *
801
- * @private
802
- * @memberof module:workbox-precaching
803
- */
804
-
805
- const deleteOutdatedCaches = async (currentPrecacheName, substringToFind = SUBSTRING_TO_FIND) => {
806
- const cacheNames = await caches.keys();
807
- const cacheNamesToDelete = cacheNames.filter(cacheName => {
808
- return cacheName.includes(substringToFind) && cacheName.includes(self.registration.scope) && cacheName !== currentPrecacheName;
809
- });
810
- await Promise.all(cacheNamesToDelete.map(cacheName => caches.delete(cacheName)));
811
- return cacheNamesToDelete;
812
- };
813
-
814
- /*
815
- Copyright 2019 Google LLC
816
-
817
- Use of this source code is governed by an MIT-style
818
- license that can be found in the LICENSE file or at
819
- https://opensource.org/licenses/MIT.
820
- */
821
- /**
822
- * Adds an `activate` event listener which will clean up incompatible
823
- * precaches that were created by older versions of Workbox.
824
- *
825
- * @alias workbox.precaching.cleanupOutdatedCaches
826
- */
827
-
828
- const cleanupOutdatedCaches = () => {
829
- addEventListener('activate', event => {
830
- const cacheName = cacheNames_mjs.cacheNames.getPrecacheName();
831
- event.waitUntil(deleteOutdatedCaches(cacheName).then(cachesDeleted => {
832
- {
833
- if (cachesDeleted.length > 0) {
834
- logger_mjs.logger.log(`The following out-of-date precaches were cleaned up ` + `automatically:`, cachesDeleted);
835
- }
836
- }
837
- }));
838
- });
839
- };
840
-
841
- /*
842
- Copyright 2019 Google LLC
843
-
844
- Use of this source code is governed by an MIT-style
845
- license that can be found in the LICENSE file or at
846
- https://opensource.org/licenses/MIT.
847
- */
848
- /**
849
- * Takes in a URL, and returns the corresponding URL that could be used to
850
- * lookup the entry in the precache.
851
- *
852
- * If a relative URL is provided, the location of the service worker file will
853
- * be used as the base.
854
- *
855
- * For precached entries without revision information, the cache key will be the
856
- * same as the original URL.
857
- *
858
- * For precached entries with revision information, the cache key will be the
859
- * original URL with the addition of a query parameter used for keeping track of
860
- * the revision info.
861
- *
862
- * @param {string} url The URL whose cache key to look up.
863
- * @return {string} The cache key that corresponds to that URL.
864
- *
865
- * @alias workbox.precaching.getCacheKeyForURL
866
- */
867
-
868
- const getCacheKeyForURL$1 = url => {
869
- const precacheController = getOrCreatePrecacheController();
870
- return precacheController.getCacheKeyForURL(url);
871
- };
872
-
873
- /*
874
- Copyright 2019 Google LLC
875
-
876
- Use of this source code is governed by an MIT-style
877
- license that can be found in the LICENSE file or at
878
- https://opensource.org/licenses/MIT.
879
- */
880
-
881
- const installListener = event => {
882
- const precacheController = getOrCreatePrecacheController();
883
- const plugins = precachePlugins.get();
884
- event.waitUntil(precacheController.install({
885
- event,
886
- plugins
887
- }).catch(error => {
888
- {
889
- logger_mjs.logger.error(`Service worker installation failed. It will ` + `be retried automatically during the next navigation.`);
890
- } // Re-throw the error to ensure installation fails.
891
-
892
-
893
- throw error;
894
- }));
895
- };
896
-
897
- const activateListener = event => {
898
- const precacheController = getOrCreatePrecacheController();
899
- const plugins = precachePlugins.get();
900
- event.waitUntil(precacheController.activate({
901
- event,
902
- plugins
903
- }));
904
- };
905
- /**
906
- * Adds items to the precache list, removing any duplicates and
907
- * stores the files in the
908
- * ["precache cache"]{@link module:workbox-core.cacheNames} when the service
909
- * worker installs.
910
- *
911
- * This method can be called multiple times.
912
- *
913
- * Please note: This method **will not** serve any of the cached files for you.
914
- * It only precaches files. To respond to a network request you call
915
- * [addRoute()]{@link module:workbox-precaching.addRoute}.
916
- *
917
- * If you have a single array of files to precache, you can just call
918
- * [precacheAndRoute()]{@link module:workbox-precaching.precacheAndRoute}.
919
- *
920
- * @param {Array<Object|string>} entries Array of entries to precache.
921
- *
922
- * @alias workbox.precaching.precache
923
- */
924
-
925
-
926
- const precache = entries => {
927
- const precacheController = getOrCreatePrecacheController();
928
- precacheController.addToCacheList(entries);
929
-
930
- if (entries.length > 0) {
931
- // NOTE: these listeners will only be added once (even if the `precache()`
932
- // method is called multiple times) because event listeners are implemented
933
- // as a set, where each listener must be unique.
934
- addEventListener('install', installListener);
935
- addEventListener('activate', activateListener);
936
- }
937
- };
938
-
939
- /*
940
- Copyright 2019 Google LLC
941
-
942
- Use of this source code is governed by an MIT-style
943
- license that can be found in the LICENSE file or at
944
- https://opensource.org/licenses/MIT.
945
- */
946
- /**
947
- * This method will add entries to the precache list and add a route to
948
- * respond to fetch events.
949
- *
950
- * This is a convenience method that will call
951
- * [precache()]{@link module:workbox-precaching.precache} and
952
- * [addRoute()]{@link module:workbox-precaching.addRoute} in a single call.
953
- *
954
- * @param {Array<Object|string>} entries Array of entries to precache.
955
- * @param {Object} options See
956
- * [addRoute() options]{@link module:workbox-precaching.addRoute}.
957
- *
958
- * @alias workbox.precaching.precacheAndRoute
959
- */
960
-
961
- const precacheAndRoute = (entries, options) => {
962
- precache(entries);
963
- addRoute(options);
964
- };
965
-
966
- /*
967
- Copyright 2018 Google LLC
968
-
969
- Use of this source code is governed by an MIT-style
970
- license that can be found in the LICENSE file or at
971
- https://opensource.org/licenses/MIT.
972
- */
973
-
974
- {
975
- assert_mjs.assert.isSWEnv('workbox-precaching');
976
- }
977
-
978
- exports.addPlugins = addPlugins;
979
- exports.addRoute = addRoute;
980
- exports.cleanupOutdatedCaches = cleanupOutdatedCaches;
981
- exports.getCacheKeyForURL = getCacheKeyForURL$1;
982
- exports.precache = precache;
983
- exports.precacheAndRoute = precacheAndRoute;
984
- exports.PrecacheController = PrecacheController;
985
-
986
- return exports;
987
-
988
- }({}, workbox.core._private, workbox.core._private, workbox.core._private, workbox.core._private, workbox.core._private, workbox.core._private, workbox.core._private));
989
- //# sourceMappingURL=workbox-precaching.dev.js.map