jekyll-pwa-workbox 0.0.6 → 0.0.7.alpha

Sign up to get free protection for your applications and to get access to all the features.
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
@@ -0,0 +1 @@
1
+ {"version":3,"file":"workbox-expiration.dev.js","sources":["../_version.js","../models/CacheTimestampsModel.js","../CacheExpiration.js","../Plugin.js"],"sourcesContent":["// @ts-ignore\ntry {\n self['workbox:expiration:5.0.0-alpha.0'] && _();\n}\ncatch (e) { }\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*/\nimport { DBWrapper } from 'workbox-core/_private/DBWrapper.js';\nimport { deleteDatabase } from 'workbox-core/_private/deleteDatabase.js';\nimport '../_version.js';\nconst DB_NAME = 'workbox-expiration';\nconst OBJECT_STORE_NAME = 'cache-entries';\nconst normalizeURL = (unNormalizedUrl) => {\n const url = new URL(unNormalizedUrl, location.href);\n url.hash = '';\n return url.href;\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 this._db = new DBWrapper(DB_NAME, 1, {\n onupgradeneeded: (event) => this._handleUpgrade(event),\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 // 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 // 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 // Previous versions of `workbox-expiration` used `this._cacheName`\n // as the IDBDatabase name.\n deleteDatabase(this._cacheName);\n }\n /**\n * @param {string} url\n * @param {number} timestamp\n *\n * @private\n */\n async setTimestamp(url, timestamp) {\n url = normalizeURL(url);\n const entry = {\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 await this._db.put(OBJECT_STORE_NAME, entry);\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 * 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 * @return {Array<string>}\n *\n * @private\n */\n async expireEntries(minTimestamp, maxCount) {\n const entriesToDelete = await this._db.transaction(OBJECT_STORE_NAME, 'readwrite', (txn, done) => {\n const store = txn.objectStore(OBJECT_STORE_NAME);\n const request = store.index('timestamp').openCursor(null, 'prev');\n const entriesToDelete = [];\n let entriesNotDeletedCount = 0;\n request.onsuccess = () => {\n const cursor = request.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 // We only need to return the URL, not the whole entry.\n entriesToDelete.push(cursor.value);\n }\n else {\n entriesNotDeletedCount++;\n }\n }\n cursor.continue();\n }\n else {\n done(entriesToDelete);\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 return urlsDeleted;\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}\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*/\nimport { CacheTimestampsModel } from './models/CacheTimestampsModel.js';\nimport { WorkboxError } from 'workbox-core/_private/WorkboxError.js';\nimport { assert } from 'workbox-core/_private/assert.js';\nimport { logger } from 'workbox-core/_private/logger.js';\nimport './_version.js';\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 this._isRunning = false;\n this._rerunRequested = false;\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 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 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 // TODO: Assert is positive\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 // TODO: Assert is positive\n }\n }\n this._maxEntries = config.maxEntries;\n this._maxAgeSeconds = config.maxAgeSeconds;\n this._cacheName = cacheName;\n this._timestampModel = new CacheTimestampsModel(cacheName);\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 const minTimestamp = this._maxAgeSeconds ?\n Date.now() - (this._maxAgeSeconds * 1000) : 0;\n const urlsExpired = await this._timestampModel.expireEntries(minTimestamp, this._maxEntries);\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 if (process.env.NODE_ENV !== 'production') {\n if (urlsExpired.length > 0) {\n logger.groupCollapsed(`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 }\n else {\n logger.debug(`Cache expiration ran and found no entries to remove.`);\n }\n }\n this._isRunning = false;\n if (this._rerunRequested) {\n this._rerunRequested = false;\n this.expireEntries();\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 await this._timestampModel.setTimestamp(url, Date.now());\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 (!this._maxAgeSeconds) {\n if (process.env.NODE_ENV !== 'production') {\n throw new WorkboxError(`expired-test-without-max-age`, {\n methodName: 'isURLExpired',\n paramName: 'maxAgeSeconds',\n });\n }\n return false;\n }\n else {\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}\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*/\nimport { assert } from 'workbox-core/_private/assert.js';\nimport { cacheNames } from 'workbox-core/_private/cacheNames.js';\nimport { getFriendlyURL } from 'workbox-core/_private/getFriendlyURL.js';\nimport { logger } from 'workbox-core/_private/logger.js';\nimport { WorkboxError } from 'workbox-core/_private/WorkboxError.js';\nimport { registerQuotaErrorCallback } from 'workbox-core/registerQuotaErrorCallback.js';\nimport { CacheExpiration } from './CacheExpiration.js';\nimport './_version.js';\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\n * 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 /**\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 this.cachedResponseWillBeUsed = async ({ event, request, cacheName, cachedResponse }) => {\n if (!cachedResponse) {\n return null;\n }\n let isFresh = this._isResponseDateFresh(cachedResponse);\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 // 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 }\n catch (error) {\n if (process.env.NODE_ENV !== 'production') {\n // The event may not be a fetch event; only log the URL if it is.\n if ('request' in event) {\n logger.warn(`Unable to ensure service worker stays alive when ` +\n `updating cache entry for ` +\n `'${getFriendlyURL(event.request.url)}'.`);\n }\n }\n }\n }\n return isFresh ? cachedResponse : null;\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 this.cacheDidUpdate = async ({ 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 const cacheExpiration = this._getCacheExpiration(cacheName);\n await cacheExpiration.updateTimestamp(request.url);\n await cacheExpiration.expireEntries();\n };\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 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 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 this._config = config;\n this._maxAgeSeconds = config.maxAgeSeconds;\n this._cacheExpirations = new Map();\n if (config.purgeOnQuotaError) {\n registerQuotaErrorCallback(() => this.deleteCacheAndMetadata());\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 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 * @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 // 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 // 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 * This method will extract the data header and parse it into a useful\n * value.\n *\n * @param {Response} cachedResponse\n * @return {number|null}\n *\n * @private\n */\n _getDateHeaderTimestamp(cachedResponse) {\n if (!cachedResponse.headers.has('date')) {\n return null;\n }\n const dateHeader = cachedResponse.headers.get('date');\n const parsedDate = new Date(dateHeader);\n const headerTime = parsedDate.getTime();\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 return headerTime;\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 // Reset this._cacheExpirations to its initial state.\n this._cacheExpirations = new Map();\n }\n}\nexport { Plugin };\n"],"names":["self","_","e","DB_NAME","OBJECT_STORE_NAME","normalizeURL","unNormalizedUrl","url","URL","location","href","hash","CacheTimestampsModel","constructor","cacheName","_cacheName","_db","DBWrapper","onupgradeneeded","event","_handleUpgrade","db","target","result","objStore","createObjectStore","keyPath","createIndex","unique","deleteDatabase","setTimestamp","timestamp","entry","id","_getId","put","getTimestamp","get","expireEntries","minTimestamp","maxCount","entriesToDelete","transaction","txn","done","store","objectStore","request","index","openCursor","entriesNotDeletedCount","onsuccess","cursor","value","push","continue","urlsDeleted","delete","CacheExpiration","config","_isRunning","_rerunRequested","assert","isType","moduleName","className","funcName","paramName","maxEntries","maxAgeSeconds","WorkboxError","_maxEntries","_maxAgeSeconds","_timestampModel","Date","now","urlsExpired","cache","caches","open","length","logger","groupCollapsed","log","forEach","groupEnd","debug","updateTimestamp","isURLExpired","methodName","expireOlderThan","Infinity","Plugin","cachedResponseWillBeUsed","cachedResponse","isFresh","_isResponseDateFresh","cacheExpiration","_getCacheExpiration","updateTimestampDone","waitUntil","error","warn","getFriendlyURL","cacheDidUpdate","isInstance","Request","_config","_cacheExpirations","Map","purgeOnQuotaError","registerQuotaErrorCallback","deleteCacheAndMetadata","cacheNames","getRuntimeName","set","dateHeaderTimestamp","_getDateHeaderTimestamp","headers","has","dateHeader","parsedDate","headerTime","getTime","isNaN"],"mappings":";;;;IAAA;IACA,IAAI;IACAA,EAAAA,IAAI,CAAC,kCAAD,CAAJ,IAA4CC,CAAC,EAA7C;IACH,CAFD,CAGA,OAAOC,CAAP,EAAU;;ICJV;;;;;;;AAOA,IAGA,MAAMC,OAAO,GAAG,oBAAhB;IACA,MAAMC,iBAAiB,GAAG,eAA1B;;IACA,MAAMC,YAAY,GAAIC,eAAD,IAAqB;IACtC,QAAMC,GAAG,GAAG,IAAIC,GAAJ,CAAQF,eAAR,EAAyBG,QAAQ,CAACC,IAAlC,CAAZ;IACAH,EAAAA,GAAG,CAACI,IAAJ,GAAW,EAAX;IACA,SAAOJ,GAAG,CAACG,IAAX;IACH,CAJD;IAKA;;;;;;;IAKA,MAAME,oBAAN,CAA2B;IACvB;;;;;;IAMAC,EAAAA,WAAW,CAACC,SAAD,EAAY;IACnB,SAAKC,UAAL,GAAkBD,SAAlB;IACA,SAAKE,GAAL,GAAW,IAAIC,sBAAJ,CAAcd,OAAd,EAAuB,CAAvB,EAA0B;IACjCe,MAAAA,eAAe,EAAGC,KAAD,IAAW,KAAKC,cAAL,CAAoBD,KAApB;IADK,KAA1B,CAAX;IAGH;IACD;;;;;;;;;IAOAC,EA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ACH,KAN0B;;;IAQ3B,SAAKmD,iBAAL,GAAyB,IAAIC,GAAJ,EAAzB;IACH;;IAlNQ;;;;;;;;;;;"}
@@ -0,0 +1,2 @@
1
+ this.workbox=this.workbox||{},this.workbox.expiration=function(t,s,e,i,a,n){"use strict";try{self["workbox:expiration:5.0.0-alpha.0"]&&_()}catch(t){}const h="workbox-expiration",r="cache-entries",c=t=>{const s=new URL(t,location.href);return s.hash="",s.href};class o{constructor(t){this.t=t,this.s=new s.DBWrapper(h,1,{onupgradeneeded:t=>this.i(t)})}i(t){const s=t.target.result.createObjectStore(r,{keyPath:"id"});s.createIndex("cacheName","cacheName",{unique:!1}),s.createIndex("timestamp","timestamp",{unique:!1}),e.deleteDatabase(this.t)}async setTimestamp(t,s){const e={url:t=c(t),timestamp:s,cacheName:this.t,id:this.h(t)};await this.s.put(r,e)}async getTimestamp(t){return(await this.s.get(r,this.h(t))).timestamp}async expireEntries(t,s){const e=await this.s.transaction(r,"readwrite",(e,i)=>{const a=e.objectStore(r).index("timestamp").openCursor(null,"prev"),n=[];let h=0;a.onsuccess=(()=>{const e=a.result;if(e){const i=e.value;i.cacheName===this.t&&(t&&i.timestamp<t||s&&h>=s?n.push(e.value):h++),e.continue()}else i(n)})}),i=[];for(const t of e)await this.s.delete(r,t.id),i.push(t.url);return i}h(t){return this.t+"|"+c(t)}}class u{constructor(t,s={}){this.o=!1,this.u=!1,this.l=s.maxEntries,this.m=s.maxAgeSeconds,this.t=t,this.p=new o(t)}async expireEntries(){if(this.o)return void(this.u=!0);this.o=!0;const t=this.m?Date.now()-1e3*this.m:0,s=await this.p.expireEntries(t,this.l),e=await caches.open(this.t);for(const t of s)await e.delete(t);this.o=!1,this.u&&(this.u=!1,this.expireEntries())}async updateTimestamp(t){await this.p.setTimestamp(t,Date.now())}async isURLExpired(t){if(this.m){return await this.p.getTimestamp(t)<Date.now()-1e3*this.m}return!1}async delete(){this.u=!1,await this.p.expireEntries(1/0)}}return t.CacheExpiration=u,t.Plugin=class{constructor(t={}){this.cachedResponseWillBeUsed=(async({event:t,request:s,cacheName:e,cachedResponse:i})=>{if(!i)return null;let a=this.k(i);const n=this.D(e);n.expireEntries();const h=n.updateTimestamp(s.url);if(t)try{t.waitUntil(h)}catch(t){}return a?i:null}),this.cacheDidUpdate=(async({cacheName:t,request:s})=>{const e=this.D(t);await e.updateTimestamp(s.url),await e.expireEntries()}),this.N=t,this.m=t.maxAgeSeconds,this.g=new Map,t.purgeOnQuotaError&&n.registerQuotaErrorCallback(()=>this.deleteCacheAndMetadata())}D(t){if(t===a.cacheNames.getRuntimeName())throw new i.WorkboxError("expire-custom-caches-only");let s=this.g.get(t);return s||(s=new u(t,this.N),this.g.set(t,s)),s}k(t){if(!this.m)return!0;const s=this._(t);return null===s||s>=Date.now()-1e3*this.m}_(t){if(!t.headers.has("date"))return null;const s=t.headers.get("date"),e=new Date(s).getTime();return isNaN(e)?null:e}async deleteCacheAndMetadata(){for(const[t,s]of this.g)await caches.delete(t),await s.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
@@ -0,0 +1 @@
1
+ {"version":3,"file":"workbox-expiration.prod.js","sources":["../_version.js","../models/CacheTimestampsModel.js","../CacheExpiration.js","../Plugin.js"],"sourcesContent":["// @ts-ignore\ntry {\n self['workbox:expiration:5.0.0-alpha.0'] && _();\n}\ncatch (e) { }\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*/\nimport { DBWrapper } from 'workbox-core/_private/DBWrapper.js';\nimport { deleteDatabase } from 'workbox-core/_private/deleteDatabase.js';\nimport '../_version.js';\nconst DB_NAME = 'workbox-expiration';\nconst OBJECT_STORE_NAME = 'cache-entries';\nconst normalizeURL = (unNormalizedUrl) => {\n const url = new URL(unNormalizedUrl, location.href);\n url.hash = '';\n return url.href;\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 this._db = new DBWrapper(DB_NAME, 1, {\n onupgradeneeded: (event) => this._handleUpgrade(event),\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 // 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 // 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 // Previous versions of `workbox-expiration` used `this._cacheName`\n // as the IDBDatabase name.\n deleteDatabase(this._cacheName);\n }\n /**\n * @param {string} url\n * @param {number} timestamp\n *\n * @private\n */\n async setTimestamp(url, timestamp) {\n url = normalizeURL(url);\n const entry = {\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 await this._db.put(OBJECT_STORE_NAME, entry);\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 * 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 * @return {Array<string>}\n *\n * @private\n */\n async expireEntries(minTimestamp, maxCount) {\n const entriesToDelete = await this._db.transaction(OBJECT_STORE_NAME, 'readwrite', (txn, done) => {\n const store = txn.objectStore(OBJECT_STORE_NAME);\n const request = store.index('timestamp').openCursor(null, 'prev');\n const entriesToDelete = [];\n let entriesNotDeletedCount = 0;\n request.onsuccess = () => {\n const cursor = request.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 // We only need to return the URL, not the whole entry.\n entriesToDelete.push(cursor.value);\n }\n else {\n entriesNotDeletedCount++;\n }\n }\n cursor.continue();\n }\n else {\n done(entriesToDelete);\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 return urlsDeleted;\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}\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*/\nimport { CacheTimestampsModel } from './models/CacheTimestampsModel.js';\nimport { WorkboxError } from 'workbox-core/_private/WorkboxError.js';\nimport { assert } from 'workbox-core/_private/assert.js';\nimport { logger } from 'workbox-core/_private/logger.js';\nimport './_version.js';\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 this._isRunning = false;\n this._rerunRequested = false;\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 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 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 // TODO: Assert is positive\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 // TODO: Assert is positive\n }\n }\n this._maxEntries = config.maxEntries;\n this._maxAgeSeconds = config.maxAgeSeconds;\n this._cacheName = cacheName;\n this._timestampModel = new CacheTimestampsModel(cacheName);\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 const minTimestamp = this._maxAgeSeconds ?\n Date.now() - (this._maxAgeSeconds * 1000) : 0;\n const urlsExpired = await this._timestampModel.expireEntries(minTimestamp, this._maxEntries);\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 if (process.env.NODE_ENV !== 'production') {\n if (urlsExpired.length > 0) {\n logger.groupCollapsed(`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 }\n else {\n logger.debug(`Cache expiration ran and found no entries to remove.`);\n }\n }\n this._isRunning = false;\n if (this._rerunRequested) {\n this._rerunRequested = false;\n this.expireEntries();\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 await this._timestampModel.setTimestamp(url, Date.now());\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 (!this._maxAgeSeconds) {\n if (process.env.NODE_ENV !== 'production') {\n throw new WorkboxError(`expired-test-without-max-age`, {\n methodName: 'isURLExpired',\n paramName: 'maxAgeSeconds',\n });\n }\n return false;\n }\n else {\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}\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*/\nimport { assert } from 'workbox-core/_private/assert.js';\nimport { cacheNames } from 'workbox-core/_private/cacheNames.js';\nimport { getFriendlyURL } from 'workbox-core/_private/getFriendlyURL.js';\nimport { logger } from 'workbox-core/_private/logger.js';\nimport { WorkboxError } from 'workbox-core/_private/WorkboxError.js';\nimport { registerQuotaErrorCallback } from 'workbox-core/registerQuotaErrorCallback.js';\nimport { CacheExpiration } from './CacheExpiration.js';\nimport './_version.js';\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\n * 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 /**\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 this.cachedResponseWillBeUsed = async ({ event, request, cacheName, cachedResponse }) => {\n if (!cachedResponse) {\n return null;\n }\n let isFresh = this._isResponseDateFresh(cachedResponse);\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 // 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 }\n catch (error) {\n if (process.env.NODE_ENV !== 'production') {\n // The event may not be a fetch event; only log the URL if it is.\n if ('request' in event) {\n logger.warn(`Unable to ensure service worker stays alive when ` +\n `updating cache entry for ` +\n `'${getFriendlyURL(event.request.url)}'.`);\n }\n }\n }\n }\n return isFresh ? cachedResponse : null;\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 this.cacheDidUpdate = async ({ 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 const cacheExpiration = this._getCacheExpiration(cacheName);\n await cacheExpiration.updateTimestamp(request.url);\n await cacheExpiration.expireEntries();\n };\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 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 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 this._config = config;\n this._maxAgeSeconds = config.maxAgeSeconds;\n this._cacheExpirations = new Map();\n if (config.purgeOnQuotaError) {\n registerQuotaErrorCallback(() => this.deleteCacheAndMetadata());\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 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 * @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 // 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 // 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 * This method will extract the data header and parse it into a useful\n * value.\n *\n * @param {Response} cachedResponse\n * @return {number|null}\n *\n * @private\n */\n _getDateHeaderTimestamp(cachedResponse) {\n if (!cachedResponse.headers.has('date')) {\n return null;\n }\n const dateHeader = cachedResponse.headers.get('date');\n const parsedDate = new Date(dateHeader);\n const headerTime = parsedDate.getTime();\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 return headerTime;\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 // Reset this._cacheExpirations to its initial state.\n this._cacheExpirations = new Map();\n }\n}\nexport { Plugin };\n"],"names":["self","_","e","DB_NAME","OBJECT_STORE_NAME","normalizeURL","unNormalizedUrl","url","URL","location","href","hash","CacheTimestampsModel","constructor","cacheName","_cacheName","_db","DBWrapper","onupgradeneeded","event","this","_handleUpgrade","objStore","target","result","createObjectStore","keyPath","createIndex","unique","deleteDatabase","timestamp","entry","id","_getId","put","get","minTimestamp","maxCount","entriesToDelete","transaction","txn","done","request","objectStore","index","openCursor","entriesNotDeletedCount","onsuccess","cursor","value","push","continue","urlsDeleted","delete","CacheExpiration","config","_isRunning","_rerunRequested","_maxEntries","maxEntries","_maxAgeSeconds","maxAgeSeconds","_timestampModel","Date","now","urlsExpired","expireEntries","cache","caches","open","setTimestamp","getTimestamp","Infinity","cachedResponseWillBeUsed","async","cachedResponse","isFresh","_isResponseDateFresh","cacheExpiration","_getCacheExpiration","updateTimestampDone","updateTimestamp","waitUntil","error","cacheDidUpdate","_config","_cacheExpirations","Map","purgeOnQuotaError","registerQuotaErrorCallback","deleteCacheAndMetadata","cacheNames","getRuntimeName","WorkboxError","set","dateHeaderTimestamp","_getDateHeaderTimestamp","headers","has","dateHeader","headerTime","getTime","isNaN"],"mappings":"yFACA,IACIA,KAAK,qCAAuCC,IAEhD,MAAOC,ICMP,MAAMC,EAAU,qBACVC,EAAoB,gBACpBC,EAAgBC,UACZC,EAAM,IAAIC,IAAIF,EAAiBG,SAASC,aAC9CH,EAAII,KAAO,GACJJ,EAAIG,MAOf,MAAME,EAOFC,YAAYC,QACHC,EAAaD,OACbE,EAAM,IAAIC,YAAUd,EAAS,EAAG,CACjCe,gBAAkBC,GAAUC,KAAKC,EAAeF,KAUxDE,EAAeF,SAMLG,EALKH,EAAMI,OAAOC,OAKJC,kBAAkBrB,EAAmB,CAAEsB,QAAS,OAIpEJ,EAASK,YAAY,YAAa,YAAa,CAAEC,QAAQ,IACzDN,EAASK,YAAY,YAAa,YAAa,CAAEC,QAAQ,IAGzDC,iBAAeT,KAAKL,sBAQLR,EAAKuB,SAEdC,EAAQ,CACVxB,IAFJA,EAAMF,EAAaE,GAGfuB,UAAAA,EACAhB,UAAWM,KAAKL,EAIhBiB,GAAIZ,KAAKa,EAAO1B,UAEda,KAAKJ,EAAIkB,IAAI9B,EAAmB2B,sBAUvBxB,gBACKa,KAAKJ,EAAImB,IAAI/B,EAAmBgB,KAAKa,EAAO1B,KACnDuB,8BAaGM,EAAcC,SACxBC,QAAwBlB,KAAKJ,EAAIuB,YAAYnC,EAAmB,YAAa,CAACo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function (exports, logger_js) {
3
+ 'use strict';
4
+
5
+ // @ts-ignore
6
+ try {
7
+ self['workbox:navigation-preload:5.0.0-alpha.0'] && _();
8
+ } catch (e) {}
9
+
10
+ /*
11
+ Copyright 2018 Google LLC
12
+
13
+ Use of this source code is governed by an MIT-style
14
+ license that can be found in the LICENSE file or at
15
+ https://opensource.org/licenses/MIT.
16
+ */
17
+ /**
18
+ * @return {boolean} Whether or not the current browser supports enabling
19
+ * navigation preload.
20
+ *
21
+ * @memberof workbox.navigationPreload
22
+ */
23
+
24
+ function isSupported() {
25
+ return Boolean(self.registration && self.registration.navigationPreload);
26
+ }
27
+
28
+ /*
29
+ Copyright 2018 Google LLC
30
+
31
+ Use of this source code is governed by an MIT-style
32
+ license that can be found in the LICENSE file or at
33
+ https://opensource.org/licenses/MIT.
34
+ */
35
+ /**
36
+ * If the browser supports Navigation Preload, then this will disable it.
37
+ *
38
+ * @memberof workbox.navigationPreload
39
+ */
40
+
41
+ function disable() {
42
+ if (isSupported()) {
43
+ self.addEventListener('activate', event => {
44
+ event.waitUntil(self.registration.navigationPreload.disable().then(() => {
45
+ {
46
+ logger_js.logger.log(`Navigation preload is disabled.`);
47
+ }
48
+ }));
49
+ });
50
+ } else {
51
+ {
52
+ logger_js.logger.log(`Navigation preload is not supported in this browser.`);
53
+ }
54
+ }
55
+ }
56
+
57
+ /*
58
+ Copyright 2018 Google LLC
59
+
60
+ Use of this source code is governed by an MIT-style
61
+ license that can be found in the LICENSE file or at
62
+ https://opensource.org/licenses/MIT.
63
+ */
64
+ /**
65
+ * If the browser supports Navigation Preload, then this will enable it.
66
+ *
67
+ * @param {string} [headerValue] Optionally, allows developers to
68
+ * [override](https://developers.google.com/web/updates/2017/02/navigation-preload#changing_the_header)
69
+ * the value of the `Service-Worker-Navigation-Preload` header which will be
70
+ * sent to the server when making the navigation request.
71
+ *
72
+ * @memberof workbox.navigationPreload
73
+ */
74
+
75
+ function enable(headerValue) {
76
+ if (isSupported()) {
77
+ self.addEventListener('activate', event => {
78
+ event.waitUntil(self.registration.navigationPreload.enable().then(() => {
79
+ // Defaults to Service-Worker-Navigation-Preload: true if not set.
80
+ if (headerValue) {
81
+ self.registration.navigationPreload.setHeaderValue(headerValue);
82
+ }
83
+
84
+ {
85
+ logger_js.logger.log(`Navigation preload is enabled.`);
86
+ }
87
+ }));
88
+ });
89
+ } else {
90
+ {
91
+ logger_js.logger.log(`Navigation preload is not supported in this browser.`);
92
+ }
93
+ }
94
+ }
95
+
96
+ exports.disable = disable;
97
+ exports.enable = enable;
98
+ exports.isSupported = isSupported;
99
+
100
+ return exports;
101
+
102
+ }({}, workbox.core._private));
103
+ //# sourceMappingURL=workbox-navigation-preload.dev.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"workbox-navigation-preload.dev.js","sources":["../_version.js","../isSupported.js","../disable.js","../enable.js"],"sourcesContent":["// @ts-ignore\ntry {\n self['workbox:navigation-preload:5.0.0-alpha.0'] && _();\n}\ncatch (e) { }\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*/\nimport './_version.js';\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}\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*/\nimport { logger } from 'workbox-core/_private/logger.js';\nimport { isSupported } from './isSupported.js';\nimport './_version.js';\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(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}\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*/\nimport { logger } from 'workbox-core/_private/logger.js';\nimport { isSupported } from './isSupported.js';\nimport './_version.js';\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(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 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}\nexport { enable };\n"],"names":["self","_","e","isSupported","Boolean","registration","navigationPreload","disable","addEventListener","event","waitUntil","then","logger","log","enable","headerValue","setHeaderValue"],"mappings":";;;;IAAA;IACA,IAAI;IACAA,EAAAA,IAAI,CAAC,0CAAD,CAAJ,IAAoDC,CAAC,EAArD;IACH,CAFD,CAGA,OAAOC,CAAP,EAAU;;ICJV;;;;;;;AAOA,IACA;;;;;;;IAMA,SAASC,WAAT,GAAuB;IACnB,SAAOC,OAAO,CAACJ,IAAI,CAACK,YAAL,IAAqBL,IAAI,CAACK,YAAL,CAAkBC,iBAAxC,CAAd;IACH;;IChBD;;;;;;;AAOA,IAGA;;;;;;IAKA,SAASC,OAAT,GAAmB;IACf,MAAIJ,WAAW,EAAf,EAAmB;IACfH,IAAAA,IAAI,CAACQ,gBAAL,CAAsB,UAAtB,EAAmCC,KAAD,IAAW;IACzCA,MAAAA,KAAK,CAACC,SAAN,CAAgBV,IAAI,CAACK,YAAL,CAAkBC,iBAAlB,CAAoCC,OAApC,GAA8CI,IAA9C,CAAmD,MAAM;IACrE,QAA2C;IACvCC,UAAAA,gBAAM,CAACC,GAAP,CAAY,iCAAZ;IACH;IACJ,OAJe,CAAhB;IAKH,KAND;IAOH,GARD,MASK;IACD,IAA2C;IACvCD,MAAAA,gBAAM,CAACC,GAAP,CAAY,sDAAZ;IACH;IACJ;IACJ;;IC9BD;;;;;;;AAOA,IAGA;;;;;;;;;;;IAUA,SAASC,MAAT,CAAgBC,WAAhB,EAA6B;IACzB,MAAIZ,WAAW,EAAf,EAAmB;IACfH,IAAAA,IAAI,CAACQ,gBAAL,CAAsB,UAAtB,EAAmCC,KAAD,IAAW;IACzCA,MAAAA,KAAK,CAACC,SAAN,CAAgBV,IAAI,CAACK,YAAL,CAAkBC,iBAAlB,CAAoCQ,MAApC,GAA6CH,IAA7C,CAAkD,MAAM;IACpE;IACA,YAAII,WAAJ,EAAiB;IACbf,UAAAA,IAAI,CAACK,YAAL,CAAkBC,iBAAlB,CAAoCU,cAApC,CAAmDD,WAAnD;IACH;;IACD,QAA2C;IACvCH,UAAAA,gBAAM,CAACC,GAAP,CAAY,gCAAZ;IACH;IACJ,OARe,CAAhB;IASH,KAVD;IAWH,GAZD,MAaK;IACD,IAA2C;IACvCD,MAAAA,gBAAM,CAACC,GAAP,CAAY,sDAAZ;IACH;IACJ;IACJ;;;;;;;;;;;;"}
@@ -0,0 +1,2 @@
1
+ this.workbox=this.workbox||{},this.workbox.navigationPreload=function(t){"use strict";try{self["workbox:navigation-preload:5.0.0-alpha.0"]&&_()}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
@@ -0,0 +1 @@
1
+ {"version":3,"file":"workbox-navigation-preload.prod.js","sources":["../_version.js","../isSupported.js","../disable.js","../enable.js"],"sourcesContent":["// @ts-ignore\ntry {\n self['workbox:navigation-preload:5.0.0-alpha.0'] && _();\n}\ncatch (e) { }\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*/\nimport './_version.js';\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}\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*/\nimport { logger } from 'workbox-core/_private/logger.js';\nimport { isSupported } from './isSupported.js';\nimport './_version.js';\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(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}\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*/\nimport { logger } from 'workbox-core/_private/logger.js';\nimport { isSupported } from './isSupported.js';\nimport './_version.js';\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(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 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}\nexport { enable };\n"],"names":["self","_","e","isSupported","Boolean","registration","navigationPreload","addEventListener","event","waitUntil","disable","then","headerValue","enable","setHeaderValue"],"mappings":"sFACA,IACIA,KAAK,6CAA+CC,IAExD,MAAOC,ICUP,SAASC,WACEC,QAAQJ,KAAKK,cAAgBL,KAAKK,aAAaC,oCCA1D,WACQH,KACAH,KAAKO,iBAAiB,WAAaC,IAC/BA,EAAMC,UAAUT,KAAKK,aAAaC,kBAAkBI,UAAUC,KAAK,qBCE/E,SAAgBC,GACRT,KACAH,KAAKO,iBAAiB,WAAaC,IAC/BA,EAAMC,UAAUT,KAAKK,aAAaC,kBAAkBO,SAASF,KAAK,KAE1DC,GACAZ,KAAKK,aAAaC,kBAAkBQ,eAAeF"}
@@ -0,0 +1,236 @@
1
+ this.workbox = this.workbox || {};
2
+ this.workbox.googleAnalytics = (function (exports, Plugin_js, cacheNames_js, getFriendlyURL_js, logger_js, Route_js, Router_js, NetworkFirst_js, NetworkOnly_js) {
3
+ 'use strict';
4
+
5
+ // @ts-ignore
6
+ try {
7
+ self['workbox:google-analytics:5.0.0-alpha.0'] && _();
8
+ } catch (e) {}
9
+
10
+ /*
11
+ Copyright 2018 Google LLC
12
+
13
+ Use of this source code is governed by an MIT-style
14
+ license that can be found in the LICENSE file or at
15
+ https://opensource.org/licenses/MIT.
16
+ */
17
+ const QUEUE_NAME = 'workbox-google-analytics';
18
+ const MAX_RETENTION_TIME = 60 * 48; // Two days in minutes
19
+
20
+ const GOOGLE_ANALYTICS_HOST = 'www.google-analytics.com';
21
+ const GTM_HOST = 'www.googletagmanager.com';
22
+ const ANALYTICS_JS_PATH = '/analytics.js';
23
+ const GTAG_JS_PATH = '/gtag/js';
24
+ const GTM_JS_PATH = '/gtm.js';
25
+ // endpoints. Most of the time the default path (/collect) is used, but
26
+ // occasionally an experimental endpoint is used when testing new features,
27
+ // (e.g. /r/collect or /j/collect)
28
+
29
+ const COLLECT_PATHS_REGEX = /^\/(\w+\/)?collect/;
30
+
31
+ /*
32
+ Copyright 2018 Google LLC
33
+
34
+ Use of this source code is governed by an MIT-style
35
+ license that can be found in the LICENSE file or at
36
+ https://opensource.org/licenses/MIT.
37
+ */
38
+ /**
39
+ * Creates the requestWillDequeue callback to be used with the background
40
+ * sync queue plugin. The callback takes the failed request and adds the
41
+ * `qt` param based on the current time, as well as applies any other
42
+ * user-defined hit modifications.
43
+ *
44
+ * @param {Object} config See workbox.googleAnalytics.initialize.
45
+ * @return {Function} The requestWillDequeu callback function.
46
+ *
47
+ * @private
48
+ */
49
+
50
+ const createOnSyncCallback = config => {
51
+ return async ({
52
+ queue
53
+ }) => {
54
+ let entry;
55
+
56
+ while (entry = await queue.shiftRequest()) {
57
+ const {
58
+ request,
59
+ timestamp
60
+ } = entry;
61
+ const url = new URL(request.url);
62
+
63
+ try {
64
+ // Measurement protocol requests can set their payload parameters in
65
+ // either the URL query string (for GET requests) or the POST body.
66
+ const params = request.method === 'POST' ? new URLSearchParams((await request.clone().text())) : url.searchParams; // Calculate the qt param, accounting for the fact that an existing
67
+ // qt param may be present and should be updated rather than replaced.
68
+
69
+ const originalHitTime = timestamp - (Number(params.get('qt')) || 0);
70
+ const queueTime = Date.now() - originalHitTime; // Set the qt param prior to applying hitFilter or parameterOverrides.
71
+
72
+ params.set('qt', String(queueTime)); // Apply `paramterOverrideds`, if set.
73
+
74
+ if (config.parameterOverrides) {
75
+ for (const param of Object.keys(config.parameterOverrides)) {
76
+ const value = config.parameterOverrides[param];
77
+ params.set(param, value);
78
+ }
79
+ } // Apply `hitFilter`, if set.
80
+
81
+
82
+ if (typeof config.hitFilter === 'function') {
83
+ config.hitFilter.call(null, params);
84
+ } // Retry the fetch. Ignore URL search params from the URL as they're
85
+ // now in the post body.
86
+
87
+
88
+ await fetch(new Request(url.origin + url.pathname, {
89
+ body: params.toString(),
90
+ method: 'POST',
91
+ mode: 'cors',
92
+ credentials: 'omit',
93
+ headers: {
94
+ 'Content-Type': 'text/plain'
95
+ }
96
+ }));
97
+
98
+ if ("dev" !== 'production') {
99
+ logger_js.logger.log(`Request for '${getFriendlyURL_js.getFriendlyURL(url.href)}'` + `has been replayed`);
100
+ }
101
+ } catch (err) {
102
+ await queue.unshiftRequest(entry);
103
+
104
+ {
105
+ logger_js.logger.log(`Request for '${getFriendlyURL_js.getFriendlyURL(url.href)}'` + `failed to replay, putting it back in the queue.`);
106
+ }
107
+
108
+ throw err;
109
+ }
110
+ }
111
+
112
+ {
113
+ logger_js.logger.log(`All Google Analytics request successfully replayed; ` + `the queue is now empty!`);
114
+ }
115
+ };
116
+ };
117
+ /**
118
+ * Creates GET and POST routes to catch failed Measurement Protocol hits.
119
+ *
120
+ * @param {Plugin} queuePlugin
121
+ * @return {Array<Route>} The created routes.
122
+ *
123
+ * @private
124
+ */
125
+
126
+
127
+ const createCollectRoutes = queuePlugin => {
128
+ const match = ({
129
+ url
130
+ }) => url.hostname === GOOGLE_ANALYTICS_HOST && COLLECT_PATHS_REGEX.test(url.pathname);
131
+
132
+ const handler = new NetworkOnly_js.NetworkOnly({
133
+ plugins: [queuePlugin]
134
+ });
135
+ return [new Route_js.Route(match, handler, 'GET'), new Route_js.Route(match, handler, 'POST')];
136
+ };
137
+ /**
138
+ * Creates a route with a network first strategy for the analytics.js script.
139
+ *
140
+ * @param {string} cacheName
141
+ * @return {Route} The created route.
142
+ *
143
+ * @private
144
+ */
145
+
146
+
147
+ const createAnalyticsJsRoute = cacheName => {
148
+ const match = ({
149
+ url
150
+ }) => url.hostname === GOOGLE_ANALYTICS_HOST && url.pathname === ANALYTICS_JS_PATH;
151
+
152
+ const handler = new NetworkFirst_js.NetworkFirst({
153
+ cacheName
154
+ });
155
+ return new Route_js.Route(match, handler, 'GET');
156
+ };
157
+ /**
158
+ * Creates a route with a network first strategy for the gtag.js script.
159
+ *
160
+ * @param {string} cacheName
161
+ * @return {Route} The created route.
162
+ *
163
+ * @private
164
+ */
165
+
166
+
167
+ const createGtagJsRoute = cacheName => {
168
+ const match = ({
169
+ url
170
+ }) => url.hostname === GTM_HOST && url.pathname === GTAG_JS_PATH;
171
+
172
+ const handler = new NetworkFirst_js.NetworkFirst({
173
+ cacheName
174
+ });
175
+ return new Route_js.Route(match, handler, 'GET');
176
+ };
177
+ /**
178
+ * Creates a route with a network first strategy for the gtm.js script.
179
+ *
180
+ * @param {string} cacheName
181
+ * @return {Route} The created route.
182
+ *
183
+ * @private
184
+ */
185
+
186
+
187
+ const createGtmJsRoute = cacheName => {
188
+ const match = ({
189
+ url
190
+ }) => url.hostname === GTM_HOST && url.pathname === GTM_JS_PATH;
191
+
192
+ const handler = new NetworkFirst_js.NetworkFirst({
193
+ cacheName
194
+ });
195
+ return new Route_js.Route(match, handler, 'GET');
196
+ };
197
+ /**
198
+ * @param {Object=} [options]
199
+ * @param {Object} [options.cacheName] The cache name to store and retrieve
200
+ * analytics.js. Defaults to the cache names provided by `workbox-core`.
201
+ * @param {Object} [options.parameterOverrides]
202
+ * [Measurement Protocol parameters](https://developers.google.com/analytics/devguides/collection/protocol/v1/parameters),
203
+ * expressed as key/value pairs, to be added to replayed Google Analytics
204
+ * requests. This can be used to, e.g., set a custom dimension indicating
205
+ * that the request was replayed.
206
+ * @param {Function} [options.hitFilter] A function that allows you to modify
207
+ * the hit parameters prior to replaying
208
+ * the hit. The function is invoked with the original hit's URLSearchParams
209
+ * object as its only argument.
210
+ *
211
+ * @memberof workbox.googleAnalytics
212
+ */
213
+
214
+
215
+ const initialize = (options = {}) => {
216
+ const cacheName = cacheNames_js.cacheNames.getGoogleAnalyticsName(options.cacheName);
217
+ const queuePlugin = new Plugin_js.Plugin(QUEUE_NAME, {
218
+ maxRetentionTime: MAX_RETENTION_TIME,
219
+ onSync: createOnSyncCallback(options)
220
+ });
221
+ const routes = [createGtmJsRoute(cacheName), createAnalyticsJsRoute(cacheName), createGtagJsRoute(cacheName), ...createCollectRoutes(queuePlugin)];
222
+ const router = new Router_js.Router();
223
+
224
+ for (const route of routes) {
225
+ router.registerRoute(route);
226
+ }
227
+
228
+ router.addFetchListener();
229
+ };
230
+
231
+ exports.initialize = initialize;
232
+
233
+ return exports;
234
+
235
+ }({}, workbox.backgroundSync, workbox.core._private, workbox.core._private, workbox.core._private, workbox.routing, workbox.routing, workbox.strategies, workbox.strategies));
236
+ //# sourceMappingURL=workbox-offline-ga.dev.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"workbox-offline-ga.dev.js","sources":["../_version.js","../utils/constants.js","../initialize.js"],"sourcesContent":["// @ts-ignore\ntry {\n self['workbox:google-analytics:5.0.0-alpha.0'] && _();\n}\ncatch (e) { }\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*/\nimport '../_version.js';\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// 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*/\nimport { Plugin } from 'workbox-background-sync/Plugin.js';\nimport { cacheNames } from 'workbox-core/_private/cacheNames.js';\nimport { getFriendlyURL } from 'workbox-core/_private/getFriendlyURL.js';\nimport { logger } from 'workbox-core/_private/logger.js';\nimport { Route } from 'workbox-routing/Route.js';\nimport { Router } from 'workbox-routing/Router.js';\nimport { NetworkFirst } from 'workbox-strategies/NetworkFirst.js';\nimport { NetworkOnly } from 'workbox-strategies/NetworkOnly.js';\nimport { QUEUE_NAME, MAX_RETENTION_TIME, GOOGLE_ANALYTICS_HOST, GTM_HOST, ANALYTICS_JS_PATH, GTAG_JS_PATH, GTM_JS_PATH, COLLECT_PATHS_REGEX, } from './utils/constants.js';\nimport './_version.js';\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 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 // 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 // Set the qt param prior to applying hitFilter or parameterOverrides.\n params.set('qt', String(queueTime));\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 // Apply `hitFilter`, if set.\n if (typeof config.hitFilter === 'function') {\n config.hitFilter.call(null, params);\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 if (process.env.NODE_ENV !== 'production') {\n logger.log(`Request for '${getFriendlyURL(url.href)}'` +\n `has been replayed`);\n }\n }\n catch (err) {\n await queue.unshiftRequest(entry);\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 * 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 const handler = new NetworkOnly({\n plugins: [queuePlugin],\n });\n return [\n new Route(match, handler, 'GET'),\n new Route(match, handler, 'POST'),\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 return new Route(match, handler, 'GET');\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 return new Route(match, handler, 'GET');\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 return new Route(match, handler, 'GET');\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 const queuePlugin = new Plugin(QUEUE_NAME, {\n maxRetentionTime: MAX_RETENTION_TIME,\n onSync: createOnSyncCallback(options),\n });\n const routes = [\n createGtmJsRoute(cacheName),\n createAnalyticsJsRoute(cacheName),\n createGtagJsRoute(cacheName),\n ...createCollectRoutes(queuePlugin),\n ];\n const router = new Router();\n for (const route of routes) {\n router.registerRoute(route);\n }\n router.addFetchListener();\n};\nexport { initialize, };\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","String","parameterOverrides","param","Object","keys","value","hitFilter","call","fetch","Request","origin","pathname","body","toString","mode","credentials","headers","process","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":";;;;IAAA;IACA,IAAI;IACAA,EAAAA,IAAI,CAAC,wCAAD,CAAJ,IAAkDC,CAAC,EAAnD;IACH,CAFD,CAGA,OAAOC,CAAP,EAAU;;ICJV;;;;;;;AAOA,IACO,MAAMC,UAAU,GAAG,0BAAnB;AACP,IAAO,MAAMC,kBAAkB,GAAG,KAAK,EAAhC;;AACP,IAAO,MAAMC,qBAAqB,GAAG,0BAA9B;AACP,IAAO,MAAMC,QAAQ,GAAG,0BAAjB;AACP,IAAO,MAAMC,iBAAiB,GAAG,eAA1B;AACP,IAAO,MAAMC,YAAY,GAAG,UAArB;AACP,IAAO,MAAMC,WAAW,GAAG,SAApB;AACP,IAEA;IACA;IACA;;AACA,IAAO,MAAMC,mBAAmB,GAAG,oBAA5B;;ICpBP;;;;;;;AAOA,IAUA;;;;;;;;;;;;IAWA,MAAMC,oBAAoB,GAAIC,MAAD,IAAY;IACrC,SAAO,OAAO;IAAEC,IAAAA;IAAF,GAAP,KAAqB;IACxB,QAAIC,KAAJ;;IACA,WAAOA,KAAK,GAAG,MAAMD,KAAK,CAACE,YAAN,EAArB,EAA2C;IACvC,YAAM;IAAEC,QAAAA,OAAF;IAAWC,QAAAA;IAAX,UAAyBH,KAA/B;IACA,YAAMI,GAAG,GAAG,IAAIC,GAAJ,CAAQH,OAAO,CAACE,GAAhB,CAAZ;;IACA,UAAI;IACA;IACA;IACA,cAAME,MAAM,GAAGJ,OAAO,CAACK,MAAR,KAAmB,MAAnB,GACX,IAAIC,eAAJ,EAAoB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AAD,CADL,EAEXD,sBAAsB,CAACC,SAAD,CAFX,EAGXE,iBAAiB,CAACF,SAAD,CAHN,EAIX,GAAGV,mBAAmB,CAACC,WAAD,CAJX,CAAf;IAMA,QAAMqB,MAAM,GAAG,IAAIC,gBAAJ,EAAf;;IACA,OAAK,MAAMC,KAAX,IAAoBH,MAApB,EAA4B;IACxBC,IAAAA,MAAM,CAACG,aAAP,CAAqBD,KAArB;IACH;;IACDF,EAAAA,MAAM,CAACI,gBAAP;IACH,CAjBD;;;;;;;;;;"}
@@ -0,0 +1,2 @@
1
+ this.workbox=this.workbox||{},this.workbox.googleAnalytics=function(t,e,o,n,a,c,w,r,s){"use strict";try{self["workbox:google-analytics:5.0.0-alpha.0"]&&_()}catch(t){}const i=/^\/(\w+\/)?collect/,l=t=>async({queue:e})=>{let o;for(;o=await e.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",String(s)),t.parameterOverrides)for(const e of Object.keys(t.parameterOverrides)){const o=t.parameterOverrides[e];w.set(e,o)}"function"==typeof t.hitFilter&&t.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(t){throw await e.unshiftRequest(o),t}}},g=t=>{const e=({url:t})=>"www.google-analytics.com"===t.hostname&&i.test(t.pathname),o=new s.NetworkOnly({plugins:[t]});return[new c.Route(e,o,"GET"),new c.Route(e,o,"POST")]},m=t=>{const e=new r.NetworkFirst({cacheName:t});return new c.Route(({url:t})=>"www.google-analytics.com"===t.hostname&&"/analytics.js"===t.pathname,e,"GET")},u=t=>{const e=new r.NetworkFirst({cacheName:t});return new c.Route(({url:t})=>"www.googletagmanager.com"===t.hostname&&"/gtag/js"===t.pathname,e,"GET")},h=t=>{const e=new r.NetworkFirst({cacheName:t});return new c.Route(({url:t})=>"www.googletagmanager.com"===t.hostname&&"/gtm.js"===t.pathname,e,"GET")};return t.initialize=((t={})=>{const n=o.cacheNames.getGoogleAnalyticsName(t.cacheName),a=new e.Plugin("workbox-google-analytics",{maxRetentionTime:2880,onSync:l(t)}),c=[h(n),m(n),u(n),...g(a)],r=new w.Router;for(const t of c)r.registerRoute(t);r.addFetchListener()}),t}({},workbox.backgroundSync,workbox.core._private,workbox.core._private,workbox.core._private,workbox.routing,workbox.routing,workbox.strategies,workbox.strategies);
2
+ //# sourceMappingURL=workbox-offline-ga.prod.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"workbox-offline-ga.prod.js","sources":["../_version.js","../utils/constants.js","../initialize.js"],"sourcesContent":["// @ts-ignore\ntry {\n self['workbox:google-analytics:5.0.0-alpha.0'] && _();\n}\ncatch (e) { }\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*/\nimport '../_version.js';\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// 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*/\nimport { Plugin } from 'workbox-background-sync/Plugin.js';\nimport { cacheNames } from 'workbox-core/_private/cacheNames.js';\nimport { getFriendlyURL } from 'workbox-core/_private/getFriendlyURL.js';\nimport { logger } from 'workbox-core/_private/logger.js';\nimport { Route } from 'workbox-routing/Route.js';\nimport { Router } from 'workbox-routing/Router.js';\nimport { NetworkFirst } from 'workbox-strategies/NetworkFirst.js';\nimport { NetworkOnly } from 'workbox-strategies/NetworkOnly.js';\nimport { QUEUE_NAME, MAX_RETENTION_TIME, GOOGLE_ANALYTICS_HOST, GTM_HOST, ANALYTICS_JS_PATH, GTAG_JS_PATH, GTM_JS_PATH, COLLECT_PATHS_REGEX, } from './utils/constants.js';\nimport './_version.js';\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 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 // 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 // Set the qt param prior to applying hitFilter or parameterOverrides.\n params.set('qt', String(queueTime));\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 // Apply `hitFilter`, if set.\n if (typeof config.hitFilter === 'function') {\n config.hitFilter.call(null, params);\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 if (process.env.NODE_ENV !== 'production') {\n logger.log(`Request for '${getFriendlyURL(url.href)}'` +\n `has been replayed`);\n }\n }\n catch (err) {\n await queue.unshiftRequest(entry);\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 * 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 const handler = new NetworkOnly({\n plugins: [queuePlugin],\n });\n return [\n new Route(match, handler, 'GET'),\n new Route(match, handler, 'POST'),\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 return new Route(match, handler, 'GET');\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 return new Route(match, handler, 'GET');\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 return new Route(match, handler, 'GET');\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 const queuePlugin = new Plugin(QUEUE_NAME, {\n maxRetentionTime: MAX_RETENTION_TIME,\n onSync: createOnSyncCallback(options),\n });\n const routes = [\n createGtmJsRoute(cacheName),\n createAnalyticsJsRoute(cacheName),\n createGtagJsRoute(cacheName),\n ...createCollectRoutes(queuePlugin),\n ];\n const router = new Router();\n for (const route of routes) {\n router.registerRoute(route);\n }\n router.addFetchListener();\n};\nexport { initialize, };\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","String","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":"oGACA,IACIA,KAAK,2CAA6CC,IAEtD,MAAOC,ICIA,MAYMC,EAAsB,qBCQ7BC,EAAwBC,GACnB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HP,aCoHpBrC,EAAI0B,SAEgBa,EAAS,QAU/BQ,EAAoBH,UAGhBL,EAAU,IAAIM,eAAa,CAAED,UAAAA,WAC5B,IAAIF,QAHG,EAAG1C,IAAAA,KDnIG,6BCmIOA,EAAIqC,UDhIR,YCiInBrC,EAAI0B,SAEgBa,EAAS,4BAkBlB,EAACS,EAAU,YACpBJ,EAAYK,aAAWC,uBAAuBF,EAAQJ,WACtDT,EAAc,IAAIgB,SD7JF,2BC6JqB,CACvCC,iBD7J0B,KC8J1BC,OAAQ7D,EAAqBwD,KAE3BM,EAAS,CACXP,EAAiBH,GACjBD,EAAuBC,GACvBE,EAAkBF,MACfV,EAAoBC,IAErBoB,EAAS,IAAIC,aACd,MAAMC,KAASH,EAChBC,EAAOG,cAAcD,GAEzBF,EAAOI"}
@@ -0,0 +1,994 @@
1
+ this.workbox = this.workbox || {};
2
+ this.workbox.precaching = (function (exports, assert_js, cacheNames_js, getFriendlyURL_js, logger_js, cacheWrapper_js, fetchWrapper_js, WorkboxError_js) {
3
+ 'use strict';
4
+
5
+ // @ts-ignore
6
+ try {
7
+ self['workbox:precaching:5.0.0-alpha.0'] && _();
8
+ } catch (e) {}
9
+
10
+ /*
11
+ Copyright 2019 Google LLC
12
+
13
+ Use of this source code is governed by an MIT-style
14
+ license that can be found in the LICENSE file or at
15
+ https://opensource.org/licenses/MIT.
16
+ */
17
+ const plugins = [];
18
+ const precachePlugins = {
19
+ /*
20
+ * @return {Array}
21
+ * @private
22
+ */
23
+ get() {
24
+ return plugins;
25
+ },
26
+
27
+ /*
28
+ * @param {Array} newPlugins
29
+ * @private
30
+ */
31
+ add(newPlugins) {
32
+ plugins.push(...newPlugins);
33
+ }
34
+
35
+ };
36
+
37
+ /*
38
+ Copyright 2019 Google LLC
39
+
40
+ Use of this source code is governed by an MIT-style
41
+ license that can be found in the LICENSE file or at
42
+ https://opensource.org/licenses/MIT.
43
+ */
44
+ /**
45
+ * Adds plugins to precaching.
46
+ *
47
+ * @param {Array<Object>} newPlugins
48
+ *
49
+ * @alias workbox.precaching.addPlugins
50
+ */
51
+
52
+ const addPlugins = newPlugins => {
53
+ precachePlugins.add(newPlugins);
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
+ * @param {Response} response
65
+ * @return {Response}
66
+ *
67
+ * @private
68
+ * @memberof module:workbox-precaching
69
+ */
70
+
71
+ async function cleanRedirect(response) {
72
+ const clonedResponse = response.clone(); // Not all browsers support the Response.body stream, so fall back
73
+ // to reading the entire body into memory as a blob.
74
+
75
+ const bodyPromise = 'body' in clonedResponse ? Promise.resolve(clonedResponse.body) : clonedResponse.blob();
76
+ const body = await bodyPromise; // new Response() is happy when passed either a stream or a Blob.
77
+
78
+ return new Response(body, {
79
+ headers: clonedResponse.headers,
80
+ status: clonedResponse.status,
81
+ statusText: clonedResponse.statusText
82
+ });
83
+ }
84
+
85
+ /*
86
+ Copyright 2018 Google LLC
87
+
88
+ Use of this source code is governed by an MIT-style
89
+ license that can be found in the LICENSE file or at
90
+ https://opensource.org/licenses/MIT.
91
+ */
92
+
93
+ const REVISION_SEARCH_PARAM = '__WB_REVISION__';
94
+ /**
95
+ * Converts a manifest entry into a versioned URL suitable for precaching.
96
+ *
97
+ * @param {Object|string} entry
98
+ * @return {string} A URL with versioning info.
99
+ *
100
+ * @private
101
+ * @memberof module:workbox-precaching
102
+ */
103
+
104
+ function createCacheKey(entry) {
105
+ if (!entry) {
106
+ throw new WorkboxError_js.WorkboxError('add-to-cache-list-unexpected-type', {
107
+ entry
108
+ });
109
+ } // If a precache manifest entry is a string, it's assumed to be a versioned
110
+ // URL, like '/app.abcd1234.js'. Return as-is.
111
+
112
+
113
+ if (typeof entry === 'string') {
114
+ const urlObject = new URL(entry, location.href);
115
+ return {
116
+ cacheKey: urlObject.href,
117
+ url: urlObject.href
118
+ };
119
+ }
120
+
121
+ const {
122
+ revision,
123
+ url
124
+ } = entry;
125
+
126
+ if (!url) {
127
+ throw new WorkboxError_js.WorkboxError('add-to-cache-list-unexpected-type', {
128
+ entry
129
+ });
130
+ } // If there's just a URL and no revision, then it's also assumed to be a
131
+ // versioned URL.
132
+
133
+
134
+ if (!revision) {
135
+ const urlObject = new URL(url, location.href);
136
+ return {
137
+ cacheKey: urlObject.href,
138
+ url: urlObject.href
139
+ };
140
+ } // Otherwise, construct a properly versioned URL using the custom Workbox
141
+ // search parameter along with the revision info.
142
+
143
+
144
+ const cacheKeyURL = new URL(url, location.href);
145
+ const originalURL = new URL(url, location.href);
146
+ cacheKeyURL.searchParams.set(REVISION_SEARCH_PARAM, revision);
147
+ return {
148
+ cacheKey: cacheKeyURL.href,
149
+ url: originalURL.href
150
+ };
151
+ }
152
+
153
+ /*
154
+ Copyright 2018 Google LLC
155
+
156
+ Use of this source code is governed by an MIT-style
157
+ license that can be found in the LICENSE file or at
158
+ https://opensource.org/licenses/MIT.
159
+ */
160
+ /**
161
+ * @param {string} groupTitle
162
+ * @param {Array<string>} deletedURLs
163
+ *
164
+ * @private
165
+ */
166
+
167
+ const logGroup = (groupTitle, deletedURLs) => {
168
+ logger_js.logger.groupCollapsed(groupTitle);
169
+
170
+ for (const url of deletedURLs) {
171
+ logger_js.logger.log(url);
172
+ }
173
+
174
+ logger_js.logger.groupEnd();
175
+ };
176
+ /**
177
+ * @param {Array<string>} deletedURLs
178
+ *
179
+ * @private
180
+ * @memberof module:workbox-precaching
181
+ */
182
+
183
+
184
+ function printCleanupDetails(deletedURLs) {
185
+ const deletionCount = deletedURLs.length;
186
+
187
+ if (deletionCount > 0) {
188
+ logger_js.logger.groupCollapsed(`During precaching cleanup, ` + `${deletionCount} cached ` + `request${deletionCount === 1 ? ' was' : 's were'} deleted.`);
189
+ logGroup('Deleted Cache Requests', deletedURLs);
190
+ logger_js.logger.groupEnd();
191
+ }
192
+ }
193
+
194
+ /*
195
+ Copyright 2018 Google LLC
196
+
197
+ Use of this source code is governed by an MIT-style
198
+ license that can be found in the LICENSE file or at
199
+ https://opensource.org/licenses/MIT.
200
+ */
201
+ /**
202
+ * @param {string} groupTitle
203
+ * @param {Array<string>} urls
204
+ *
205
+ * @private
206
+ */
207
+
208
+ function _nestedGroup(groupTitle, urls) {
209
+ if (urls.length === 0) {
210
+ return;
211
+ }
212
+
213
+ logger_js.logger.groupCollapsed(groupTitle);
214
+
215
+ for (const url of urls) {
216
+ logger_js.logger.log(url);
217
+ }
218
+
219
+ logger_js.logger.groupEnd();
220
+ }
221
+ /**
222
+ * @param {Array<string>} urlsToPrecache
223
+ * @param {Array<string>} urlsAlreadyPrecached
224
+ *
225
+ * @private
226
+ * @memberof module:workbox-precaching
227
+ */
228
+
229
+
230
+ function printInstallDetails(urlsToPrecache, urlsAlreadyPrecached) {
231
+ const precachedCount = urlsToPrecache.length;
232
+ const alreadyPrecachedCount = urlsAlreadyPrecached.length;
233
+
234
+ if (precachedCount || alreadyPrecachedCount) {
235
+ let message = `Precaching ${precachedCount} file${precachedCount === 1 ? '' : 's'}.`;
236
+
237
+ if (alreadyPrecachedCount > 0) {
238
+ message += ` ${alreadyPrecachedCount} ` + `file${alreadyPrecachedCount === 1 ? ' is' : 's are'} already cached.`;
239
+ }
240
+
241
+ logger_js.logger.groupCollapsed(message);
242
+
243
+ _nestedGroup(`View newly precached URLs.`, urlsToPrecache);
244
+
245
+ _nestedGroup(`View previously precached URLs.`, urlsAlreadyPrecached);
246
+
247
+ logger_js.logger.groupEnd();
248
+ }
249
+ }
250
+
251
+ /*
252
+ Copyright 2018 Google LLC
253
+
254
+ Use of this source code is governed by an MIT-style
255
+ license that can be found in the LICENSE file or at
256
+ https://opensource.org/licenses/MIT.
257
+ */
258
+ /**
259
+ * Performs efficient precaching of assets.
260
+ *
261
+ * @memberof module:workbox-precaching
262
+ */
263
+
264
+ class PrecacheController {
265
+ /**
266
+ * Create a new PrecacheController.
267
+ *
268
+ * @param {string} [cacheName] An optional name for the cache, to override
269
+ * the default precache name.
270
+ */
271
+ constructor(cacheName) {
272
+ this._cacheName = cacheNames_js.cacheNames.getPrecacheName(cacheName);
273
+ this._urlsToCacheKeys = new Map();
274
+ }
275
+ /**
276
+ * This method will add items to the precache list, removing duplicates
277
+ * and ensuring the information is valid.
278
+ *
279
+ * @param {
280
+ * Array<module:workbox-precaching.PrecacheController.PrecacheEntry|string>
281
+ * } entries Array of entries to precache.
282
+ */
283
+
284
+
285
+ addToCacheList(entries) {
286
+ {
287
+ assert_js.assert.isArray(entries, {
288
+ moduleName: 'workbox-precaching',
289
+ className: 'PrecacheController',
290
+ funcName: 'addToCacheList',
291
+ paramName: 'entries'
292
+ });
293
+ }
294
+
295
+ for (const entry of entries) {
296
+ const {
297
+ cacheKey,
298
+ url
299
+ } = createCacheKey(entry);
300
+
301
+ if (this._urlsToCacheKeys.has(url) && this._urlsToCacheKeys.get(url) !== cacheKey) {
302
+ throw new WorkboxError_js.WorkboxError('add-to-cache-list-conflicting-entries', {
303
+ firstEntry: this._urlsToCacheKeys.get(url),
304
+ secondEntry: cacheKey
305
+ });
306
+ }
307
+
308
+ this._urlsToCacheKeys.set(url, cacheKey);
309
+ }
310
+ }
311
+ /**
312
+ * Precaches new and updated assets. Call this method from the service worker
313
+ * install event.
314
+ *
315
+ * @param {Object} options
316
+ * @param {Event} [options.event] The install event (if needed).
317
+ * @param {Array<Object>} [options.plugins] Plugins to be used for fetching
318
+ * and caching during install.
319
+ * @return {Promise<workbox.precaching.InstallResult>}
320
+ */
321
+
322
+
323
+ async install({
324
+ event,
325
+ plugins
326
+ } = {}) {
327
+ {
328
+ if (plugins) {
329
+ assert_js.assert.isArray(plugins, {
330
+ moduleName: 'workbox-precaching',
331
+ className: 'PrecacheController',
332
+ funcName: 'install',
333
+ paramName: 'plugins'
334
+ });
335
+ }
336
+ }
337
+
338
+ const urlsToPrecache = [];
339
+ const urlsAlreadyPrecached = [];
340
+ const cache = await caches.open(this._cacheName);
341
+ const alreadyCachedRequests = await cache.keys();
342
+ const alreadyCachedURLs = new Set(alreadyCachedRequests.map(request => request.url));
343
+
344
+ for (const cacheKey of this._urlsToCacheKeys.values()) {
345
+ if (alreadyCachedURLs.has(cacheKey)) {
346
+ urlsAlreadyPrecached.push(cacheKey);
347
+ } else {
348
+ urlsToPrecache.push(cacheKey);
349
+ }
350
+ }
351
+
352
+ const precacheRequests = urlsToPrecache.map(url => {
353
+ return this._addURLToCache({
354
+ event,
355
+ plugins,
356
+ url
357
+ });
358
+ });
359
+ await Promise.all(precacheRequests);
360
+
361
+ {
362
+ printInstallDetails(urlsToPrecache, urlsAlreadyPrecached);
363
+ }
364
+
365
+ return {
366
+ updatedURLs: urlsToPrecache,
367
+ notUpdatedURLs: urlsAlreadyPrecached
368
+ };
369
+ }
370
+ /**
371
+ * Deletes assets that are no longer present in the current precache manifest.
372
+ * Call this method from the service worker activate event.
373
+ *
374
+ * @return {Promise<workbox.precaching.CleanupResult>}
375
+ */
376
+
377
+
378
+ async activate() {
379
+ const cache = await caches.open(this._cacheName);
380
+ const currentlyCachedRequests = await cache.keys();
381
+ const expectedCacheKeys = new Set(this._urlsToCacheKeys.values());
382
+ const deletedURLs = [];
383
+
384
+ for (const request of currentlyCachedRequests) {
385
+ if (!expectedCacheKeys.has(request.url)) {
386
+ await cache.delete(request);
387
+ deletedURLs.push(request.url);
388
+ }
389
+ }
390
+
391
+ {
392
+ printCleanupDetails(deletedURLs);
393
+ }
394
+
395
+ return {
396
+ deletedURLs
397
+ };
398
+ }
399
+ /**
400
+ * Requests the entry and saves it to the cache if the response is valid.
401
+ * By default, any response with a status code of less than 400 (including
402
+ * opaque responses) is considered valid.
403
+ *
404
+ * If you need to use custom criteria to determine what's valid and what
405
+ * isn't, then pass in an item in `options.plugins` that implements the
406
+ * `cacheWillUpdate()` lifecycle event.
407
+ *
408
+ * @private
409
+ * @param {Object} options
410
+ * @param {string} options.url The URL to fetch and cache.
411
+ * @param {Event} [options.event] The install event (if passed).
412
+ * @param {Array<Object>} [options.plugins] An array of plugins to apply to
413
+ * fetch and caching.
414
+ */
415
+
416
+
417
+ async _addURLToCache({
418
+ url,
419
+ event,
420
+ plugins
421
+ }) {
422
+ const request = new Request(url, {
423
+ credentials: 'same-origin'
424
+ });
425
+ let response = await fetchWrapper_js.fetchWrapper.fetch({
426
+ event,
427
+ plugins,
428
+ request
429
+ }); // Allow developers to override the default logic about what is and isn't
430
+ // valid by passing in a plugin implementing cacheWillUpdate(), e.g.
431
+ // a workbox.cacheableResponse.Plugin instance.
432
+
433
+ let cacheWillUpdatePlugin;
434
+
435
+ for (const plugin of plugins || []) {
436
+ if ('cacheWillUpdate' in plugin) {
437
+ cacheWillUpdatePlugin = plugin;
438
+ }
439
+ }
440
+
441
+ const isValidResponse = cacheWillUpdatePlugin ? // Use a callback if provided. It returns a truthy value if valid.
442
+ // NOTE: invoke the method on the plugin instance so the `this` context
443
+ // is correct.
444
+ cacheWillUpdatePlugin.cacheWillUpdate({
445
+ event,
446
+ request,
447
+ response
448
+ }) : // Otherwise, default to considering any response status under 400 valid.
449
+ // This includes, by default, considering opaque responses valid.
450
+ response.status < 400; // Consider this a failure, leading to the `install` handler failing, if
451
+ // we get back an invalid response.
452
+
453
+ if (!isValidResponse) {
454
+ throw new WorkboxError_js.WorkboxError('bad-precaching-response', {
455
+ url,
456
+ status: response.status
457
+ });
458
+ }
459
+
460
+ if (response.redirected) {
461
+ response = await cleanRedirect(response);
462
+ }
463
+
464
+ await cacheWrapper_js.cacheWrapper.put({
465
+ event,
466
+ plugins,
467
+ request,
468
+ response,
469
+ cacheName: this._cacheName,
470
+ matchOptions: {
471
+ ignoreSearch: true
472
+ }
473
+ });
474
+ }
475
+ /**
476
+ * Returns a mapping of a precached URL to the corresponding cache key, taking
477
+ * into account the revision information for the URL.
478
+ *
479
+ * @return {Map<string, string>} A URL to cache key mapping.
480
+ */
481
+
482
+
483
+ getURLsToCacheKeys() {
484
+ return this._urlsToCacheKeys;
485
+ }
486
+ /**
487
+ * Returns a list of all the URLs that have been precached by the current
488
+ * service worker.
489
+ *
490
+ * @return {Array<string>} The precached URLs.
491
+ */
492
+
493
+
494
+ getCachedURLs() {
495
+ return [...this._urlsToCacheKeys.keys()];
496
+ }
497
+ /**
498
+ * Returns the cache key used for storing a given URL. If that URL is
499
+ * unversioned, like `/index.html', then the cache key will be the original
500
+ * URL with a search parameter appended to it.
501
+ *
502
+ * @param {string} url A URL whose cache key you want to look up.
503
+ * @return {string} The versioned URL that corresponds to a cache key
504
+ * for the original URL, or undefined if that URL isn't precached.
505
+ */
506
+
507
+
508
+ getCacheKeyForURL(url) {
509
+ const urlObject = new URL(url, location.href);
510
+ return this._urlsToCacheKeys.get(urlObject.href);
511
+ }
512
+
513
+ }
514
+
515
+ /*
516
+ Copyright 2019 Google LLC
517
+
518
+ Use of this source code is governed by an MIT-style
519
+ license that can be found in the LICENSE file or at
520
+ https://opensource.org/licenses/MIT.
521
+ */
522
+ let precacheController;
523
+ /**
524
+ * @return {PrecacheController}
525
+ * @private
526
+ */
527
+
528
+ const getOrCreatePrecacheController = () => {
529
+ if (!precacheController) {
530
+ precacheController = new PrecacheController();
531
+ }
532
+
533
+ return precacheController;
534
+ };
535
+
536
+ /*
537
+ Copyright 2018 Google LLC
538
+
539
+ Use of this source code is governed by an MIT-style
540
+ license that can be found in the LICENSE file or at
541
+ https://opensource.org/licenses/MIT.
542
+ */
543
+ /**
544
+ * Removes any URL search parameters that should be ignored.
545
+ *
546
+ * @param {URL} urlObject The original URL.
547
+ * @param {Array<RegExp>} ignoreURLParametersMatching RegExps to test against
548
+ * each search parameter name. Matches mean that the search parameter should be
549
+ * ignored.
550
+ * @return {URL} The URL with any ignored search parameters removed.
551
+ *
552
+ * @private
553
+ * @memberof module:workbox-precaching
554
+ */
555
+
556
+ function removeIgnoredSearchParams(urlObject, ignoreURLParametersMatching = []) {
557
+ // Convert the iterable into an array at the start of the loop to make sure
558
+ // deletion doesn't mess up iteration.
559
+ for (const paramName of [...urlObject.searchParams.keys()]) {
560
+ if (ignoreURLParametersMatching.some(regExp => regExp.test(paramName))) {
561
+ urlObject.searchParams.delete(paramName);
562
+ }
563
+ }
564
+
565
+ return urlObject;
566
+ }
567
+
568
+ /*
569
+ Copyright 2019 Google LLC
570
+
571
+ Use of this source code is governed by an MIT-style
572
+ license that can be found in the LICENSE file or at
573
+ https://opensource.org/licenses/MIT.
574
+ */
575
+ /**
576
+ * Generator function that yields possible variations on the original URL to
577
+ * check, one at a time.
578
+ *
579
+ * @param {string} url
580
+ * @param {Object} options
581
+ *
582
+ * @private
583
+ * @memberof module:workbox-precaching
584
+ */
585
+
586
+ function* generateURLVariations(url, {
587
+ ignoreURLParametersMatching,
588
+ directoryIndex,
589
+ cleanURLs,
590
+ urlManipulation
591
+ } = {}) {
592
+ const urlObject = new URL(url, location.href);
593
+ urlObject.hash = '';
594
+ yield urlObject.href;
595
+ const urlWithoutIgnoredParams = removeIgnoredSearchParams(urlObject, ignoreURLParametersMatching);
596
+ yield urlWithoutIgnoredParams.href;
597
+
598
+ if (directoryIndex && urlWithoutIgnoredParams.pathname.endsWith('/')) {
599
+ const directoryURL = new URL(urlWithoutIgnoredParams.href);
600
+ directoryURL.pathname += directoryIndex;
601
+ yield directoryURL.href;
602
+ }
603
+
604
+ if (cleanURLs) {
605
+ const cleanURL = new URL(urlWithoutIgnoredParams.href);
606
+ cleanURL.pathname += '.html';
607
+ yield cleanURL.href;
608
+ }
609
+
610
+ if (urlManipulation) {
611
+ const additionalURLs = urlManipulation({
612
+ url: urlObject
613
+ });
614
+
615
+ for (const urlToAttempt of additionalURLs) {
616
+ yield urlToAttempt.href;
617
+ }
618
+ }
619
+ }
620
+
621
+ /*
622
+ Copyright 2019 Google LLC
623
+
624
+ Use of this source code is governed by an MIT-style
625
+ license that can be found in the LICENSE file or at
626
+ https://opensource.org/licenses/MIT.
627
+ */
628
+ /**
629
+ * This function will take the request URL and manipulate it based on the
630
+ * configuration options.
631
+ *
632
+ * @param {string} url
633
+ * @param {Object} options
634
+ * @return {string} Returns the URL in the cache that matches the request,
635
+ * if possible.
636
+ *
637
+ * @private
638
+ */
639
+
640
+ const getCacheKeyForURL = (url, options) => {
641
+ const precacheController = getOrCreatePrecacheController();
642
+ const urlsToCacheKeys = precacheController.getURLsToCacheKeys();
643
+
644
+ for (const possibleURL of generateURLVariations(url, options)) {
645
+ const possibleCacheKey = urlsToCacheKeys.get(possibleURL);
646
+
647
+ if (possibleCacheKey) {
648
+ return possibleCacheKey;
649
+ }
650
+ }
651
+ };
652
+
653
+ /*
654
+ Copyright 2019 Google LLC
655
+
656
+ Use of this source code is governed by an MIT-style
657
+ license that can be found in the LICENSE file or at
658
+ https://opensource.org/licenses/MIT.
659
+ */
660
+ /**
661
+ * Adds a `fetch` listener to the service worker that will
662
+ * respond to
663
+ * [network requests]{@link https://developer.mozilla.org/en-US/docs/Web/API/Service_Worker_API/Using_Service_Workers#Custom_responses_to_requests}
664
+ * with precached assets.
665
+ *
666
+ * Requests for assets that aren't precached, the `FetchEvent` will not be
667
+ * responded to, allowing the event to fall through to other `fetch` event
668
+ * listeners.
669
+ *
670
+ * NOTE: when called more than once this method will replace the previously set
671
+ * configuration options. Calling it more than once is not recommended outside
672
+ * of tests.
673
+ *
674
+ * @private
675
+ * @param {Object} options
676
+ * @param {string} [options.directoryIndex=index.html] The `directoryIndex` will
677
+ * check cache entries for a URLs ending with '/' to see if there is a hit when
678
+ * appending the `directoryIndex` value.
679
+ * @param {Array<RegExp>} [options.ignoreURLParametersMatching=[/^utm_/]] An
680
+ * array of regex's to remove search params when looking for a cache match.
681
+ * @param {boolean} [options.cleanURLs=true] The `cleanURLs` option will
682
+ * check the cache for the URL with a `.html` added to the end of the end.
683
+ * @param {workbox.precaching~urlManipulation} [options.urlManipulation]
684
+ * This is a function that should take a URL and return an array of
685
+ * alternative URL's that should be checked for precache matches.
686
+ */
687
+
688
+ const addFetchListener = ({
689
+ ignoreURLParametersMatching = [/^utm_/],
690
+ directoryIndex = 'index.html',
691
+ cleanURLs = true,
692
+ urlManipulation
693
+ } = {}) => {
694
+ const cacheName = cacheNames_js.cacheNames.getPrecacheName();
695
+ addEventListener('fetch', event => {
696
+ const precachedURL = getCacheKeyForURL(event.request.url, {
697
+ cleanURLs,
698
+ directoryIndex,
699
+ ignoreURLParametersMatching,
700
+ urlManipulation
701
+ });
702
+
703
+ if (!precachedURL) {
704
+ {
705
+ logger_js.logger.debug(`Precaching did not find a match for ` + getFriendlyURL_js.getFriendlyURL(event.request.url));
706
+ }
707
+
708
+ return;
709
+ }
710
+
711
+ let responsePromise = caches.open(cacheName).then(cache => {
712
+ return cache.match(precachedURL);
713
+ }).then(cachedResponse => {
714
+ if (cachedResponse) {
715
+ return cachedResponse;
716
+ } // Fall back to the network if we don't have a cached response
717
+ // (perhaps due to manual cache cleanup).
718
+
719
+
720
+ {
721
+ logger_js.logger.warn(`The precached response for ` + `${getFriendlyURL_js.getFriendlyURL(precachedURL)} in ${cacheName} was not found. ` + `Falling back to the network instead.`);
722
+ }
723
+
724
+ return fetch(precachedURL);
725
+ });
726
+
727
+ {
728
+ responsePromise = responsePromise.then(response => {
729
+ // Workbox is going to handle the route.
730
+ // print the routing details to the console.
731
+ logger_js.logger.groupCollapsed(`Precaching is responding to: ` + getFriendlyURL_js.getFriendlyURL(event.request.url));
732
+ logger_js.logger.log(`Serving the precached url: ${precachedURL}`);
733
+ logger_js.logger.groupCollapsed(`View request details here.`);
734
+ logger_js.logger.log(event.request);
735
+ logger_js.logger.groupEnd();
736
+ logger_js.logger.groupCollapsed(`View response details here.`);
737
+ logger_js.logger.log(response);
738
+ logger_js.logger.groupEnd();
739
+ logger_js.logger.groupEnd();
740
+ return response;
741
+ });
742
+ }
743
+
744
+ event.respondWith(responsePromise);
745
+ });
746
+ };
747
+
748
+ /*
749
+ Copyright 2019 Google LLC
750
+ Use of this source code is governed by an MIT-style
751
+ license that can be found in the LICENSE file or at
752
+ https://opensource.org/licenses/MIT.
753
+ */
754
+ let listenerAdded = false;
755
+ /**
756
+ * Add a `fetch` listener to the service worker that will
757
+ * respond to
758
+ * [network requests]{@link https://developer.mozilla.org/en-US/docs/Web/API/Service_Worker_API/Using_Service_Workers#Custom_responses_to_requests}
759
+ * with precached assets.
760
+ *
761
+ * Requests for assets that aren't precached, the `FetchEvent` will not be
762
+ * responded to, allowing the event to fall through to other `fetch` event
763
+ * listeners.
764
+ *
765
+ * @param {Object} options
766
+ * @param {string} [options.directoryIndex=index.html] The `directoryIndex` will
767
+ * check cache entries for a URLs ending with '/' to see if there is a hit when
768
+ * appending the `directoryIndex` value.
769
+ * @param {Array<RegExp>} [options.ignoreURLParametersMatching=[/^utm_/]] An
770
+ * array of regex's to remove search params when looking for a cache match.
771
+ * @param {boolean} [options.cleanURLs=true] The `cleanURLs` option will
772
+ * check the cache for the URL with a `.html` added to the end of the end.
773
+ * @param {workbox.precaching~urlManipulation} [options.urlManipulation]
774
+ * This is a function that should take a URL and return an array of
775
+ * alternative URL's that should be checked for precache matches.
776
+ *
777
+ * @alias workbox.precaching.addRoute
778
+ */
779
+
780
+ const addRoute = options => {
781
+ if (!listenerAdded) {
782
+ addFetchListener(options);
783
+ listenerAdded = true;
784
+ }
785
+ };
786
+
787
+ /*
788
+ Copyright 2018 Google LLC
789
+
790
+ Use of this source code is governed by an MIT-style
791
+ license that can be found in the LICENSE file or at
792
+ https://opensource.org/licenses/MIT.
793
+ */
794
+ const SUBSTRING_TO_FIND = '-precache-';
795
+ /**
796
+ * Cleans up incompatible precaches that were created by older versions of
797
+ * Workbox, by a service worker registered under the current scope.
798
+ *
799
+ * This is meant to be called as part of the `activate` event.
800
+ *
801
+ * This should be safe to use as long as you don't include `substringToFind`
802
+ * (defaulting to `-precache-`) in your non-precache cache names.
803
+ *
804
+ * @param {string} currentPrecacheName The cache name currently in use for
805
+ * precaching. This cache won't be deleted.
806
+ * @param {string} [substringToFind='-precache-'] Cache names which include this
807
+ * substring will be deleted (excluding `currentPrecacheName`).
808
+ * @return {Array<string>} A list of all the cache names that were deleted.
809
+ *
810
+ * @private
811
+ * @memberof module:workbox-precaching
812
+ */
813
+
814
+ const deleteOutdatedCaches = async (currentPrecacheName, substringToFind = SUBSTRING_TO_FIND) => {
815
+ const cacheNames = await caches.keys();
816
+ const cacheNamesToDelete = cacheNames.filter(cacheName => {
817
+ return cacheName.includes(substringToFind) && cacheName.includes(self.registration.scope) && cacheName !== currentPrecacheName;
818
+ });
819
+ await Promise.all(cacheNamesToDelete.map(cacheName => caches.delete(cacheName)));
820
+ return cacheNamesToDelete;
821
+ };
822
+
823
+ /*
824
+ Copyright 2019 Google LLC
825
+
826
+ Use of this source code is governed by an MIT-style
827
+ license that can be found in the LICENSE file or at
828
+ https://opensource.org/licenses/MIT.
829
+ */
830
+ /**
831
+ * Adds an `activate` event listener which will clean up incompatible
832
+ * precaches that were created by older versions of Workbox.
833
+ *
834
+ * @alias workbox.precaching.cleanupOutdatedCaches
835
+ */
836
+
837
+ const cleanupOutdatedCaches = () => {
838
+ addEventListener('activate', event => {
839
+ const cacheName = cacheNames_js.cacheNames.getPrecacheName();
840
+ event.waitUntil(deleteOutdatedCaches(cacheName).then(cachesDeleted => {
841
+ {
842
+ if (cachesDeleted.length > 0) {
843
+ logger_js.logger.log(`The following out-of-date precaches were cleaned up ` + `automatically:`, cachesDeleted);
844
+ }
845
+ }
846
+ }));
847
+ });
848
+ };
849
+
850
+ /*
851
+ Copyright 2019 Google LLC
852
+
853
+ Use of this source code is governed by an MIT-style
854
+ license that can be found in the LICENSE file or at
855
+ https://opensource.org/licenses/MIT.
856
+ */
857
+ /**
858
+ * Takes in a URL, and returns the corresponding URL that could be used to
859
+ * lookup the entry in the precache.
860
+ *
861
+ * If a relative URL is provided, the location of the service worker file will
862
+ * be used as the base.
863
+ *
864
+ * For precached entries without revision information, the cache key will be the
865
+ * same as the original URL.
866
+ *
867
+ * For precached entries with revision information, the cache key will be the
868
+ * original URL with the addition of a query parameter used for keeping track of
869
+ * the revision info.
870
+ *
871
+ * @param {string} url The URL whose cache key to look up.
872
+ * @return {string} The cache key that corresponds to that URL.
873
+ *
874
+ * @alias workbox.precaching.getCacheKeyForURL
875
+ */
876
+
877
+ const getCacheKeyForURL$1 = url => {
878
+ const precacheController = getOrCreatePrecacheController();
879
+ return precacheController.getCacheKeyForURL(url);
880
+ };
881
+
882
+ /*
883
+ Copyright 2019 Google LLC
884
+
885
+ Use of this source code is governed by an MIT-style
886
+ license that can be found in the LICENSE file or at
887
+ https://opensource.org/licenses/MIT.
888
+ */
889
+
890
+ const installListener = event => {
891
+ const precacheController = getOrCreatePrecacheController();
892
+ const plugins = precachePlugins.get();
893
+ event.waitUntil(precacheController.install({
894
+ event,
895
+ plugins
896
+ }).catch(error => {
897
+ {
898
+ logger_js.logger.error(`Service worker installation failed. It will ` + `be retried automatically during the next navigation.`);
899
+ } // Re-throw the error to ensure installation fails.
900
+
901
+
902
+ throw error;
903
+ }));
904
+ };
905
+
906
+ const activateListener = event => {
907
+ const precacheController = getOrCreatePrecacheController();
908
+ event.waitUntil(precacheController.activate());
909
+ };
910
+ /**
911
+ * Adds items to the precache list, removing any duplicates and
912
+ * stores the files in the
913
+ * ["precache cache"]{@link module:workbox-core.cacheNames} when the service
914
+ * worker installs.
915
+ *
916
+ * This method can be called multiple times.
917
+ *
918
+ * Please note: This method **will not** serve any of the cached files for you.
919
+ * It only precaches files. To respond to a network request you call
920
+ * [addRoute()]{@link module:workbox-precaching.addRoute}.
921
+ *
922
+ * If you have a single array of files to precache, you can just call
923
+ * [precacheAndRoute()]{@link module:workbox-precaching.precacheAndRoute}.
924
+ *
925
+ * @param {Array<Object|string>} [entries=[]] Array of entries to precache.
926
+ *
927
+ * @alias workbox.precaching.precache
928
+ */
929
+
930
+
931
+ const precache = entries => {
932
+ const precacheController = getOrCreatePrecacheController();
933
+ precacheController.addToCacheList(entries);
934
+
935
+ if (entries.length > 0) {
936
+ // NOTE: these listeners will only be added once (even if the `precache()`
937
+ // method is called multiple times) because event listeners are implemented
938
+ // as a set, where each listener must be unique.
939
+ addEventListener('install', installListener);
940
+ addEventListener('activate', activateListener);
941
+ }
942
+ };
943
+
944
+ /*
945
+ Copyright 2019 Google LLC
946
+
947
+ Use of this source code is governed by an MIT-style
948
+ license that can be found in the LICENSE file or at
949
+ https://opensource.org/licenses/MIT.
950
+ */
951
+ /**
952
+ * This method will add entries to the precache list and add a route to
953
+ * respond to fetch events.
954
+ *
955
+ * This is a convenience method that will call
956
+ * [precache()]{@link module:workbox-precaching.precache} and
957
+ * [addRoute()]{@link module:workbox-precaching.addRoute} in a single call.
958
+ *
959
+ * @param {Array<Object|string>} entries Array of entries to precache.
960
+ * @param {Object} options See
961
+ * [addRoute() options]{@link module:workbox-precaching.addRoute}.
962
+ *
963
+ * @alias workbox.precaching.precacheAndRoute
964
+ */
965
+
966
+ const precacheAndRoute = (entries, options) => {
967
+ precache(entries);
968
+ addRoute(options);
969
+ };
970
+
971
+ /*
972
+ Copyright 2018 Google LLC
973
+
974
+ Use of this source code is governed by an MIT-style
975
+ license that can be found in the LICENSE file or at
976
+ https://opensource.org/licenses/MIT.
977
+ */
978
+
979
+ {
980
+ assert_js.assert.isSWEnv('workbox-precaching');
981
+ }
982
+
983
+ exports.PrecacheController = PrecacheController;
984
+ exports.addPlugins = addPlugins;
985
+ exports.addRoute = addRoute;
986
+ exports.cleanupOutdatedCaches = cleanupOutdatedCaches;
987
+ exports.getCacheKeyForURL = getCacheKeyForURL$1;
988
+ exports.precache = precache;
989
+ exports.precacheAndRoute = precacheAndRoute;
990
+
991
+ return exports;
992
+
993
+ }({}, workbox.core._private, workbox.core._private, workbox.core._private, workbox.core._private, workbox.core._private, workbox.core._private, workbox.core._private));
994
+ //# sourceMappingURL=workbox-precaching.dev.js.map